board-nhk8815.c 6.9 KB

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