board-ag5evm.c 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  1. /*
  2. * arch/arm/mach-shmobile/board-ag5evm.c
  3. *
  4. * Copyright (C) 2010 Takashi Yoshii <yoshii.takashi.zj@renesas.com>
  5. * Copyright (C) 2009 Yoshihiro Shimoda <shimoda.yoshihiro@renesas.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; version 2 of the License.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  19. *
  20. */
  21. #include <linux/kernel.h>
  22. #include <linux/init.h>
  23. #include <linux/interrupt.h>
  24. #include <linux/irq.h>
  25. #include <linux/platform_device.h>
  26. #include <linux/delay.h>
  27. #include <linux/io.h>
  28. #include <linux/dma-mapping.h>
  29. #include <linux/serial_sci.h>
  30. #include <linux/smsc911x.h>
  31. #include <linux/gpio.h>
  32. #include <linux/input.h>
  33. #include <linux/input/sh_keysc.h>
  34. #include <linux/mmc/host.h>
  35. #include <linux/mmc/sh_mmcif.h>
  36. #include <sound/sh_fsi.h>
  37. #include <mach/hardware.h>
  38. #include <mach/sh73a0.h>
  39. #include <mach/common.h>
  40. #include <asm/mach-types.h>
  41. #include <asm/mach/arch.h>
  42. #include <asm/mach/map.h>
  43. #include <asm/mach/time.h>
  44. #include <asm/hardware/gic.h>
  45. #include <asm/hardware/cache-l2x0.h>
  46. #include <asm/traps.h>
  47. static struct resource smsc9220_resources[] = {
  48. [0] = {
  49. .start = 0x14000000,
  50. .end = 0x14000000 + SZ_64K - 1,
  51. .flags = IORESOURCE_MEM,
  52. },
  53. [1] = {
  54. .start = gic_spi(33), /* PINT1 */
  55. .flags = IORESOURCE_IRQ,
  56. },
  57. };
  58. static struct smsc911x_platform_config smsc9220_platdata = {
  59. .flags = SMSC911X_USE_32BIT | SMSC911X_SAVE_MAC_ADDRESS,
  60. .phy_interface = PHY_INTERFACE_MODE_MII,
  61. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
  62. .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
  63. };
  64. static struct platform_device eth_device = {
  65. .name = "smsc911x",
  66. .id = 0,
  67. .dev = {
  68. .platform_data = &smsc9220_platdata,
  69. },
  70. .resource = smsc9220_resources,
  71. .num_resources = ARRAY_SIZE(smsc9220_resources),
  72. };
  73. static struct sh_keysc_info keysc_platdata = {
  74. .mode = SH_KEYSC_MODE_6,
  75. .scan_timing = 3,
  76. .delay = 100,
  77. .keycodes = {
  78. KEY_A, KEY_B, KEY_C, KEY_D, KEY_E, KEY_F, KEY_G,
  79. KEY_H, KEY_I, KEY_J, KEY_K, KEY_L, KEY_M, KEY_N,
  80. KEY_O, KEY_P, KEY_Q, KEY_R, KEY_S, KEY_T, KEY_U,
  81. KEY_V, KEY_W, KEY_X, KEY_Y, KEY_Z, KEY_HOME, KEY_SLEEP,
  82. KEY_SPACE, KEY_9, KEY_6, KEY_3, KEY_WAKEUP, KEY_RIGHT, \
  83. KEY_COFFEE,
  84. KEY_0, KEY_8, KEY_5, KEY_2, KEY_DOWN, KEY_ENTER, KEY_UP,
  85. KEY_KPASTERISK, KEY_7, KEY_4, KEY_1, KEY_STOP, KEY_LEFT, \
  86. KEY_COMPUTER,
  87. },
  88. };
  89. static struct resource keysc_resources[] = {
  90. [0] = {
  91. .name = "KEYSC",
  92. .start = 0xe61b0000,
  93. .end = 0xe61b0098 - 1,
  94. .flags = IORESOURCE_MEM,
  95. },
  96. [1] = {
  97. .start = gic_spi(71),
  98. .flags = IORESOURCE_IRQ,
  99. },
  100. };
  101. static struct platform_device keysc_device = {
  102. .name = "sh_keysc",
  103. .id = 0,
  104. .num_resources = ARRAY_SIZE(keysc_resources),
  105. .resource = keysc_resources,
  106. .dev = {
  107. .platform_data = &keysc_platdata,
  108. },
  109. };
  110. /* FSI A */
  111. static struct sh_fsi_platform_info fsi_info = {
  112. .porta_flags = SH_FSI_OUT_SLAVE_MODE |
  113. SH_FSI_IN_SLAVE_MODE |
  114. SH_FSI_OFMT(I2S) |
  115. SH_FSI_IFMT(I2S),
  116. };
  117. static struct resource fsi_resources[] = {
  118. [0] = {
  119. .name = "FSI",
  120. .start = 0xEC230000,
  121. .end = 0xEC230400 - 1,
  122. .flags = IORESOURCE_MEM,
  123. },
  124. [1] = {
  125. .start = gic_spi(146),
  126. .flags = IORESOURCE_IRQ,
  127. },
  128. };
  129. static struct platform_device fsi_device = {
  130. .name = "sh_fsi2",
  131. .id = -1,
  132. .num_resources = ARRAY_SIZE(fsi_resources),
  133. .resource = fsi_resources,
  134. .dev = {
  135. .platform_data = &fsi_info,
  136. },
  137. };
  138. static struct resource sh_mmcif_resources[] = {
  139. [0] = {
  140. .name = "MMCIF",
  141. .start = 0xe6bd0000,
  142. .end = 0xe6bd00ff,
  143. .flags = IORESOURCE_MEM,
  144. },
  145. [1] = {
  146. .start = gic_spi(141),
  147. .flags = IORESOURCE_IRQ,
  148. },
  149. [2] = {
  150. .start = gic_spi(140),
  151. .flags = IORESOURCE_IRQ,
  152. },
  153. };
  154. static struct sh_mmcif_plat_data sh_mmcif_platdata = {
  155. .sup_pclk = 0,
  156. .ocr = MMC_VDD_165_195,
  157. .caps = MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE,
  158. };
  159. static struct platform_device mmc_device = {
  160. .name = "sh_mmcif",
  161. .id = 0,
  162. .dev = {
  163. .dma_mask = NULL,
  164. .coherent_dma_mask = 0xffffffff,
  165. .platform_data = &sh_mmcif_platdata,
  166. },
  167. .num_resources = ARRAY_SIZE(sh_mmcif_resources),
  168. .resource = sh_mmcif_resources,
  169. };
  170. /* IrDA */
  171. static struct resource irda_resources[] = {
  172. [0] = {
  173. .start = 0xE6D00000,
  174. .end = 0xE6D01FD4 - 1,
  175. .flags = IORESOURCE_MEM,
  176. },
  177. [1] = {
  178. .start = gic_spi(95),
  179. .flags = IORESOURCE_IRQ,
  180. },
  181. };
  182. static struct platform_device irda_device = {
  183. .name = "sh_irda",
  184. .id = 0,
  185. .resource = irda_resources,
  186. .num_resources = ARRAY_SIZE(irda_resources),
  187. };
  188. static struct platform_device *ag5evm_devices[] __initdata = {
  189. &eth_device,
  190. &keysc_device,
  191. &fsi_device,
  192. &mmc_device,
  193. &irda_device,
  194. };
  195. static struct map_desc ag5evm_io_desc[] __initdata = {
  196. /* create a 1:1 entity map for 0xe6xxxxxx
  197. * used by CPGA, INTC and PFC.
  198. */
  199. {
  200. .virtual = 0xe6000000,
  201. .pfn = __phys_to_pfn(0xe6000000),
  202. .length = 256 << 20,
  203. .type = MT_DEVICE_NONSHARED
  204. },
  205. };
  206. static void __init ag5evm_map_io(void)
  207. {
  208. iotable_init(ag5evm_io_desc, ARRAY_SIZE(ag5evm_io_desc));
  209. /* setup early devices and console here as well */
  210. sh73a0_add_early_devices();
  211. shmobile_setup_console();
  212. }
  213. #define PINTC_ADDR 0xe6900000
  214. #define PINTER0A (PINTC_ADDR + 0xa0)
  215. #define PINTCR0A (PINTC_ADDR + 0xb0)
  216. void __init ag5evm_init_irq(void)
  217. {
  218. sh73a0_init_irq();
  219. /* setup PINT: enable PINTA2 as active low */
  220. __raw_writel(__raw_readl(PINTER0A) | (1<<29), PINTER0A);
  221. __raw_writew(__raw_readw(PINTCR0A) | (2<<10), PINTCR0A);
  222. }
  223. static void __init ag5evm_init(void)
  224. {
  225. sh73a0_pinmux_init();
  226. /* enable SCIFA2 */
  227. gpio_request(GPIO_FN_SCIFA2_TXD1, NULL);
  228. gpio_request(GPIO_FN_SCIFA2_RXD1, NULL);
  229. gpio_request(GPIO_FN_SCIFA2_RTS1_, NULL);
  230. gpio_request(GPIO_FN_SCIFA2_CTS1_, NULL);
  231. /* enable KEYSC */
  232. gpio_request(GPIO_FN_KEYIN0_PU, NULL);
  233. gpio_request(GPIO_FN_KEYIN1_PU, NULL);
  234. gpio_request(GPIO_FN_KEYIN2_PU, NULL);
  235. gpio_request(GPIO_FN_KEYIN3_PU, NULL);
  236. gpio_request(GPIO_FN_KEYIN4_PU, NULL);
  237. gpio_request(GPIO_FN_KEYIN5_PU, NULL);
  238. gpio_request(GPIO_FN_KEYIN6_PU, NULL);
  239. gpio_request(GPIO_FN_KEYIN7_PU, NULL);
  240. gpio_request(GPIO_FN_KEYOUT0, NULL);
  241. gpio_request(GPIO_FN_KEYOUT1, NULL);
  242. gpio_request(GPIO_FN_KEYOUT2, NULL);
  243. gpio_request(GPIO_FN_KEYOUT3, NULL);
  244. gpio_request(GPIO_FN_KEYOUT4, NULL);
  245. gpio_request(GPIO_FN_KEYOUT5, NULL);
  246. gpio_request(GPIO_FN_PORT59_KEYOUT6, NULL);
  247. gpio_request(GPIO_FN_PORT58_KEYOUT7, NULL);
  248. gpio_request(GPIO_FN_KEYOUT8, NULL);
  249. gpio_request(GPIO_FN_PORT149_KEYOUT9, NULL);
  250. /* enable I2C channel 2 and 3 */
  251. gpio_request(GPIO_FN_PORT236_I2C_SDA2, NULL);
  252. gpio_request(GPIO_FN_PORT237_I2C_SCL2, NULL);
  253. gpio_request(GPIO_FN_PORT248_I2C_SCL3, NULL);
  254. gpio_request(GPIO_FN_PORT249_I2C_SDA3, NULL);
  255. /* enable MMCIF */
  256. gpio_request(GPIO_FN_MMCCLK0, NULL);
  257. gpio_request(GPIO_FN_MMCCMD0_PU, NULL);
  258. gpio_request(GPIO_FN_MMCD0_0, NULL);
  259. gpio_request(GPIO_FN_MMCD0_1, NULL);
  260. gpio_request(GPIO_FN_MMCD0_2, NULL);
  261. gpio_request(GPIO_FN_MMCD0_3, NULL);
  262. gpio_request(GPIO_FN_MMCD0_4, NULL);
  263. gpio_request(GPIO_FN_MMCD0_5, NULL);
  264. gpio_request(GPIO_FN_MMCD0_6, NULL);
  265. gpio_request(GPIO_FN_MMCD0_7, NULL);
  266. gpio_request(GPIO_PORT208, NULL); /* Reset */
  267. gpio_direction_output(GPIO_PORT208, 1);
  268. /* enable SMSC911X */
  269. gpio_request(GPIO_PORT144, NULL); /* PINTA2 */
  270. gpio_direction_input(GPIO_PORT144);
  271. gpio_request(GPIO_PORT145, NULL); /* RESET */
  272. gpio_direction_output(GPIO_PORT145, 1);
  273. /* FSI A */
  274. gpio_request(GPIO_FN_FSIACK, NULL);
  275. gpio_request(GPIO_FN_FSIAILR, NULL);
  276. gpio_request(GPIO_FN_FSIAIBT, NULL);
  277. gpio_request(GPIO_FN_FSIAISLD, NULL);
  278. gpio_request(GPIO_FN_FSIAOSLD, NULL);
  279. /* IrDA */
  280. gpio_request(GPIO_FN_PORT241_IRDA_OUT, NULL);
  281. gpio_request(GPIO_FN_PORT242_IRDA_IN, NULL);
  282. gpio_request(GPIO_FN_PORT243_IRDA_FIRSEL, NULL);
  283. #ifdef CONFIG_CACHE_L2X0
  284. /* Shared attribute override enable, 64K*8way */
  285. l2x0_init(__io(0xf0100000), 0x00460000, 0xc2000fff);
  286. #endif
  287. sh73a0_add_standard_devices();
  288. platform_add_devices(ag5evm_devices, ARRAY_SIZE(ag5evm_devices));
  289. }
  290. static void __init ag5evm_timer_init(void)
  291. {
  292. sh73a0_clock_init();
  293. shmobile_timer.init();
  294. return;
  295. }
  296. struct sys_timer ag5evm_timer = {
  297. .init = ag5evm_timer_init,
  298. };
  299. MACHINE_START(AG5EVM, "ag5evm")
  300. .map_io = ag5evm_map_io,
  301. .init_irq = ag5evm_init_irq,
  302. .handle_irq = shmobile_handle_irq_gic,
  303. .init_machine = ag5evm_init,
  304. .timer = &ag5evm_timer,
  305. MACHINE_END