board-ag5evm.c 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  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. static struct platform_device *ag5evm_devices[] __initdata = {
  171. &eth_device,
  172. &keysc_device,
  173. &fsi_device,
  174. &mmc_device,
  175. };
  176. static struct map_desc ag5evm_io_desc[] __initdata = {
  177. /* create a 1:1 entity map for 0xe6xxxxxx
  178. * used by CPGA, INTC and PFC.
  179. */
  180. {
  181. .virtual = 0xe6000000,
  182. .pfn = __phys_to_pfn(0xe6000000),
  183. .length = 256 << 20,
  184. .type = MT_DEVICE_NONSHARED
  185. },
  186. };
  187. static void __init ag5evm_map_io(void)
  188. {
  189. iotable_init(ag5evm_io_desc, ARRAY_SIZE(ag5evm_io_desc));
  190. /* setup early devices and console here as well */
  191. sh73a0_add_early_devices();
  192. shmobile_setup_console();
  193. }
  194. #define PINTC_ADDR 0xe6900000
  195. #define PINTER0A (PINTC_ADDR + 0xa0)
  196. #define PINTCR0A (PINTC_ADDR + 0xb0)
  197. void __init ag5evm_init_irq(void)
  198. {
  199. sh73a0_init_irq();
  200. /* setup PINT: enable PINTA2 as active low */
  201. __raw_writel(__raw_readl(PINTER0A) | (1<<29), PINTER0A);
  202. __raw_writew(__raw_readw(PINTCR0A) | (2<<10), PINTCR0A);
  203. }
  204. static void __init ag5evm_init(void)
  205. {
  206. sh73a0_pinmux_init();
  207. /* enable SCIFA2 */
  208. gpio_request(GPIO_FN_SCIFA2_TXD1, NULL);
  209. gpio_request(GPIO_FN_SCIFA2_RXD1, NULL);
  210. gpio_request(GPIO_FN_SCIFA2_RTS1_, NULL);
  211. gpio_request(GPIO_FN_SCIFA2_CTS1_, NULL);
  212. /* enable KEYSC */
  213. gpio_request(GPIO_FN_KEYIN0_PU, NULL);
  214. gpio_request(GPIO_FN_KEYIN1_PU, NULL);
  215. gpio_request(GPIO_FN_KEYIN2_PU, NULL);
  216. gpio_request(GPIO_FN_KEYIN3_PU, NULL);
  217. gpio_request(GPIO_FN_KEYIN4_PU, NULL);
  218. gpio_request(GPIO_FN_KEYIN5_PU, NULL);
  219. gpio_request(GPIO_FN_KEYIN6_PU, NULL);
  220. gpio_request(GPIO_FN_KEYIN7_PU, NULL);
  221. gpio_request(GPIO_FN_KEYOUT0, NULL);
  222. gpio_request(GPIO_FN_KEYOUT1, NULL);
  223. gpio_request(GPIO_FN_KEYOUT2, NULL);
  224. gpio_request(GPIO_FN_KEYOUT3, NULL);
  225. gpio_request(GPIO_FN_KEYOUT4, NULL);
  226. gpio_request(GPIO_FN_KEYOUT5, NULL);
  227. gpio_request(GPIO_FN_PORT59_KEYOUT6, NULL);
  228. gpio_request(GPIO_FN_PORT58_KEYOUT7, NULL);
  229. gpio_request(GPIO_FN_KEYOUT8, NULL);
  230. gpio_request(GPIO_FN_PORT149_KEYOUT9, NULL);
  231. /* enable I2C channel 2 and 3 */
  232. gpio_request(GPIO_FN_PORT236_I2C_SDA2, NULL);
  233. gpio_request(GPIO_FN_PORT237_I2C_SCL2, NULL);
  234. gpio_request(GPIO_FN_PORT248_I2C_SCL3, NULL);
  235. gpio_request(GPIO_FN_PORT249_I2C_SDA3, NULL);
  236. /* enable MMCIF */
  237. gpio_request(GPIO_FN_MMCCLK0, NULL);
  238. gpio_request(GPIO_FN_MMCCMD0_PU, NULL);
  239. gpio_request(GPIO_FN_MMCD0_0, NULL);
  240. gpio_request(GPIO_FN_MMCD0_1, NULL);
  241. gpio_request(GPIO_FN_MMCD0_2, NULL);
  242. gpio_request(GPIO_FN_MMCD0_3, NULL);
  243. gpio_request(GPIO_FN_MMCD0_4, NULL);
  244. gpio_request(GPIO_FN_MMCD0_5, NULL);
  245. gpio_request(GPIO_FN_MMCD0_6, NULL);
  246. gpio_request(GPIO_FN_MMCD0_7, NULL);
  247. gpio_request(GPIO_PORT208, NULL); /* Reset */
  248. gpio_direction_output(GPIO_PORT208, 1);
  249. /* enable SMSC911X */
  250. gpio_request(GPIO_PORT144, NULL); /* PINTA2 */
  251. gpio_direction_input(GPIO_PORT144);
  252. gpio_request(GPIO_PORT145, NULL); /* RESET */
  253. gpio_direction_output(GPIO_PORT145, 1);
  254. /* FSI A */
  255. gpio_request(GPIO_FN_FSIACK, NULL);
  256. gpio_request(GPIO_FN_FSIAILR, NULL);
  257. gpio_request(GPIO_FN_FSIAIBT, NULL);
  258. gpio_request(GPIO_FN_FSIAISLD, NULL);
  259. gpio_request(GPIO_FN_FSIAOSLD, NULL);
  260. #ifdef CONFIG_CACHE_L2X0
  261. /* Shared attribute override enable, 64K*8way */
  262. l2x0_init(__io(0xf0100000), 0x00460000, 0xc2000fff);
  263. #endif
  264. sh73a0_add_standard_devices();
  265. platform_add_devices(ag5evm_devices, ARRAY_SIZE(ag5evm_devices));
  266. }
  267. static void __init ag5evm_timer_init(void)
  268. {
  269. sh73a0_clock_init();
  270. shmobile_timer.init();
  271. return;
  272. }
  273. struct sys_timer ag5evm_timer = {
  274. .init = ag5evm_timer_init,
  275. };
  276. MACHINE_START(AG5EVM, "ag5evm")
  277. .map_io = ag5evm_map_io,
  278. .init_irq = ag5evm_init_irq,
  279. .handle_irq = shmobile_handle_irq_gic,
  280. .init_machine = ag5evm_init,
  281. .timer = &ag5evm_timer,
  282. MACHINE_END