board-nhk8815.c 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. /*
  2. * linux/arch/arm/mach-nomadik/board-8815nhk.c
  3. *
  4. * Copyright (C) STMicroelectronics
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2, as
  8. * published by the Free Software Foundation.
  9. *
  10. * NHK15 board specifc driver definition
  11. */
  12. #include <linux/types.h>
  13. #include <linux/kernel.h>
  14. #include <linux/init.h>
  15. #include <linux/platform_device.h>
  16. #include <linux/amba/bus.h>
  17. #include <linux/interrupt.h>
  18. #include <linux/gpio.h>
  19. #include <linux/mtd/mtd.h>
  20. #include <linux/mtd/nand.h>
  21. #include <linux/mtd/onenand.h>
  22. #include <linux/mtd/partitions.h>
  23. #include <linux/io.h>
  24. #include <asm/sizes.h>
  25. #include <asm/mach-types.h>
  26. #include <asm/mach/arch.h>
  27. #include <asm/mach/irq.h>
  28. #include <asm/mach/flash.h>
  29. #include <plat/mtu.h>
  30. #include <mach/setup.h>
  31. #include <mach/nand.h>
  32. #include <mach/fsmc.h>
  33. #include "clock.h"
  34. /* Initial value for SRC control register: all timers use MXTAL/8 source */
  35. #define SRC_CR_INIT_MASK 0x00007fff
  36. #define SRC_CR_INIT_VAL 0x2aaa8000
  37. /* These adresses span 16MB, so use three individual pages */
  38. static struct resource nhk8815_nand_resources[] = {
  39. {
  40. .name = "nand_addr",
  41. .start = NAND_IO_ADDR,
  42. .end = NAND_IO_ADDR + 0xfff,
  43. .flags = IORESOURCE_MEM,
  44. }, {
  45. .name = "nand_cmd",
  46. .start = NAND_IO_CMD,
  47. .end = NAND_IO_CMD + 0xfff,
  48. .flags = IORESOURCE_MEM,
  49. }, {
  50. .name = "nand_data",
  51. .start = NAND_IO_DATA,
  52. .end = NAND_IO_DATA + 0xfff,
  53. .flags = IORESOURCE_MEM,
  54. }
  55. };
  56. static int nhk8815_nand_init(void)
  57. {
  58. /* FSMC setup for nand chip select (8-bit nand in 8815NHK) */
  59. writel(0x0000000E, FSMC_PCR(0));
  60. writel(0x000D0A00, FSMC_PMEM(0));
  61. writel(0x00100A00, FSMC_PATT(0));
  62. /* enable access to the chip select area */
  63. writel(readl(FSMC_PCR(0)) | 0x04, FSMC_PCR(0));
  64. return 0;
  65. }
  66. /*
  67. * These partitions are the same as those used in the 2.6.20 release
  68. * shipped by the vendor; the first two partitions are mandated
  69. * by the boot ROM, and the bootloader area is somehow oversized...
  70. */
  71. static struct mtd_partition nhk8815_partitions[] = {
  72. {
  73. .name = "X-Loader(NAND)",
  74. .offset = 0,
  75. .size = SZ_256K,
  76. }, {
  77. .name = "MemInit(NAND)",
  78. .offset = MTDPART_OFS_APPEND,
  79. .size = SZ_256K,
  80. }, {
  81. .name = "BootLoader(NAND)",
  82. .offset = MTDPART_OFS_APPEND,
  83. .size = SZ_2M,
  84. }, {
  85. .name = "Kernel zImage(NAND)",
  86. .offset = MTDPART_OFS_APPEND,
  87. .size = 3 * SZ_1M,
  88. }, {
  89. .name = "Root Filesystem(NAND)",
  90. .offset = MTDPART_OFS_APPEND,
  91. .size = 22 * SZ_1M,
  92. }, {
  93. .name = "User Filesystem(NAND)",
  94. .offset = MTDPART_OFS_APPEND,
  95. .size = MTDPART_SIZ_FULL,
  96. }
  97. };
  98. static struct nomadik_nand_platform_data nhk8815_nand_data = {
  99. .parts = nhk8815_partitions,
  100. .nparts = ARRAY_SIZE(nhk8815_partitions),
  101. .options = NAND_COPYBACK | NAND_CACHEPRG | NAND_NO_PADDING \
  102. | NAND_NO_READRDY | NAND_NO_AUTOINCR,
  103. .init = nhk8815_nand_init,
  104. };
  105. static struct platform_device nhk8815_nand_device = {
  106. .name = "nomadik_nand",
  107. .dev = {
  108. .platform_data = &nhk8815_nand_data,
  109. },
  110. .resource = nhk8815_nand_resources,
  111. .num_resources = ARRAY_SIZE(nhk8815_nand_resources),
  112. };
  113. /* These are the partitions for the OneNand device, different from above */
  114. static struct mtd_partition nhk8815_onenand_partitions[] = {
  115. {
  116. .name = "X-Loader(OneNAND)",
  117. .offset = 0,
  118. .size = SZ_256K,
  119. }, {
  120. .name = "MemInit(OneNAND)",
  121. .offset = MTDPART_OFS_APPEND,
  122. .size = SZ_256K,
  123. }, {
  124. .name = "BootLoader(OneNAND)",
  125. .offset = MTDPART_OFS_APPEND,
  126. .size = SZ_2M-SZ_256K,
  127. }, {
  128. .name = "SysImage(OneNAND)",
  129. .offset = MTDPART_OFS_APPEND,
  130. .size = 4 * SZ_1M,
  131. }, {
  132. .name = "Root Filesystem(OneNAND)",
  133. .offset = MTDPART_OFS_APPEND,
  134. .size = 22 * SZ_1M,
  135. }, {
  136. .name = "User Filesystem(OneNAND)",
  137. .offset = MTDPART_OFS_APPEND,
  138. .size = MTDPART_SIZ_FULL,
  139. }
  140. };
  141. static struct onenand_platform_data nhk8815_onenand_data = {
  142. .parts = nhk8815_onenand_partitions,
  143. .nr_parts = ARRAY_SIZE(nhk8815_onenand_partitions),
  144. };
  145. static struct resource nhk8815_onenand_resource[] = {
  146. {
  147. .start = 0x30000000,
  148. .end = 0x30000000 + SZ_128K - 1,
  149. .flags = IORESOURCE_MEM,
  150. },
  151. };
  152. static struct platform_device nhk8815_onenand_device = {
  153. .name = "onenand-flash",
  154. .id = -1,
  155. .dev = {
  156. .platform_data = &nhk8815_onenand_data,
  157. },
  158. .resource = nhk8815_onenand_resource,
  159. .num_resources = ARRAY_SIZE(nhk8815_onenand_resource),
  160. };
  161. static void __init nhk8815_onenand_init(void)
  162. {
  163. #ifdef CONFIG_MTD_ONENAND
  164. /* Set up SMCS0 for OneNand */
  165. writel(0x000030db, FSMC_BCR(0));
  166. writel(0x02100551, FSMC_BTR(0));
  167. #endif
  168. }
  169. #define __MEM_4K_RESOURCE(x) \
  170. .res = {.start = (x), .end = (x) + SZ_4K - 1, .flags = IORESOURCE_MEM}
  171. static struct amba_device uart0_device = {
  172. .dev = { .init_name = "uart0" },
  173. __MEM_4K_RESOURCE(NOMADIK_UART0_BASE),
  174. .irq = {IRQ_UART0, NO_IRQ},
  175. };
  176. static struct amba_device uart1_device = {
  177. .dev = { .init_name = "uart1" },
  178. __MEM_4K_RESOURCE(NOMADIK_UART1_BASE),
  179. .irq = {IRQ_UART1, NO_IRQ},
  180. };
  181. static struct amba_device *amba_devs[] __initdata = {
  182. &uart0_device,
  183. &uart1_device,
  184. };
  185. /* We have a fixed clock alone, by now */
  186. static struct clk nhk8815_clk_48 = {
  187. .rate = 48*1000*1000,
  188. };
  189. static struct resource nhk8815_eth_resources[] = {
  190. {
  191. .name = "smc91x-regs",
  192. .start = 0x34000000 + 0x300,
  193. .end = 0x34000000 + SZ_64K - 1,
  194. .flags = IORESOURCE_MEM,
  195. }, {
  196. .start = NOMADIK_GPIO_TO_IRQ(115),
  197. .end = NOMADIK_GPIO_TO_IRQ(115),
  198. .flags = IORESOURCE_IRQ | IRQF_TRIGGER_RISING,
  199. }
  200. };
  201. static struct platform_device nhk8815_eth_device = {
  202. .name = "smc91x",
  203. .resource = nhk8815_eth_resources,
  204. .num_resources = ARRAY_SIZE(nhk8815_eth_resources),
  205. };
  206. static int __init nhk8815_eth_init(void)
  207. {
  208. int gpio_nr = 115; /* hardwired in the board */
  209. int err;
  210. err = gpio_request(gpio_nr, "eth_irq");
  211. if (!err) err = nmk_gpio_set_mode(gpio_nr, NMK_GPIO_ALT_GPIO);
  212. if (!err) err = gpio_direction_input(gpio_nr);
  213. if (err)
  214. pr_err("Error %i in %s\n", err, __func__);
  215. return err;
  216. }
  217. device_initcall(nhk8815_eth_init);
  218. static struct platform_device *nhk8815_platform_devices[] __initdata = {
  219. &nhk8815_nand_device,
  220. &nhk8815_onenand_device,
  221. &nhk8815_eth_device,
  222. /* will add more devices */
  223. };
  224. static void __init nomadik_timer_init(void)
  225. {
  226. u32 src_cr;
  227. /* Configure timer sources in "system reset controller" ctrl reg */
  228. src_cr = readl(io_p2v(NOMADIK_SRC_BASE));
  229. src_cr &= SRC_CR_INIT_MASK;
  230. src_cr |= SRC_CR_INIT_VAL;
  231. writel(src_cr, io_p2v(NOMADIK_SRC_BASE));
  232. /* Save global pointer to mtu, used by platform timer code */
  233. mtu_base = io_p2v(NOMADIK_MTU0_BASE);
  234. nmdk_timer_init();
  235. }
  236. static struct sys_timer nomadik_timer = {
  237. .init = nomadik_timer_init,
  238. };
  239. static void __init nhk8815_platform_init(void)
  240. {
  241. int i;
  242. cpu8815_platform_init();
  243. nhk8815_onenand_init();
  244. platform_add_devices(nhk8815_platform_devices,
  245. ARRAY_SIZE(nhk8815_platform_devices));
  246. for (i = 0; i < ARRAY_SIZE(amba_devs); i++) {
  247. nmdk_clk_create(&nhk8815_clk_48, amba_devs[i]->dev.init_name);
  248. amba_device_register(amba_devs[i], &iomem_resource);
  249. }
  250. }
  251. MACHINE_START(NOMADIK, "NHK8815")
  252. /* Maintainer: ST MicroElectronics */
  253. .phys_io = NOMADIK_UART0_BASE,
  254. .io_pg_offst = (IO_ADDRESS(NOMADIK_UART0_BASE) >> 18) & 0xfffc,
  255. .boot_params = 0x100,
  256. .map_io = cpu8815_map_io,
  257. .init_irq = cpu8815_init_irq,
  258. .timer = &nomadik_timer,
  259. .init_machine = nhk8815_platform_init,
  260. MACHINE_END