board-nhk8815.c 6.7 KB

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