board-nhk8815.c 6.9 KB

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