board-nhk8815.c 6.5 KB

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