board-nhk8815.c 9.5 KB

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