board-nhk8815.c 7.9 KB

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