board-nhk8815.c 6.5 KB

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