board-nhk8815.c 7.8 KB

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