board-ag5evm.c 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  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 resource fsi_resources[] = {
  112. [0] = {
  113. .name = "FSI",
  114. .start = 0xEC230000,
  115. .end = 0xEC230400 - 1,
  116. .flags = IORESOURCE_MEM,
  117. },
  118. [1] = {
  119. .start = gic_spi(146),
  120. .flags = IORESOURCE_IRQ,
  121. },
  122. };
  123. static struct platform_device fsi_device = {
  124. .name = "sh_fsi2",
  125. .id = -1,
  126. .num_resources = ARRAY_SIZE(fsi_resources),
  127. .resource = fsi_resources,
  128. };
  129. static struct resource sh_mmcif_resources[] = {
  130. [0] = {
  131. .name = "MMCIF",
  132. .start = 0xe6bd0000,
  133. .end = 0xe6bd00ff,
  134. .flags = IORESOURCE_MEM,
  135. },
  136. [1] = {
  137. .start = gic_spi(141),
  138. .flags = IORESOURCE_IRQ,
  139. },
  140. [2] = {
  141. .start = gic_spi(140),
  142. .flags = IORESOURCE_IRQ,
  143. },
  144. };
  145. static struct sh_mmcif_plat_data sh_mmcif_platdata = {
  146. .sup_pclk = 0,
  147. .ocr = MMC_VDD_165_195,
  148. .caps = MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE,
  149. };
  150. static struct platform_device mmc_device = {
  151. .name = "sh_mmcif",
  152. .id = 0,
  153. .dev = {
  154. .dma_mask = NULL,
  155. .coherent_dma_mask = 0xffffffff,
  156. .platform_data = &sh_mmcif_platdata,
  157. },
  158. .num_resources = ARRAY_SIZE(sh_mmcif_resources),
  159. .resource = sh_mmcif_resources,
  160. };
  161. static struct platform_device *ag5evm_devices[] __initdata = {
  162. &eth_device,
  163. &keysc_device,
  164. &fsi_device,
  165. &mmc_device,
  166. };
  167. static struct map_desc ag5evm_io_desc[] __initdata = {
  168. /* create a 1:1 entity map for 0xe6xxxxxx
  169. * used by CPGA, INTC and PFC.
  170. */
  171. {
  172. .virtual = 0xe6000000,
  173. .pfn = __phys_to_pfn(0xe6000000),
  174. .length = 256 << 20,
  175. .type = MT_DEVICE_NONSHARED
  176. },
  177. };
  178. static void __init ag5evm_map_io(void)
  179. {
  180. iotable_init(ag5evm_io_desc, ARRAY_SIZE(ag5evm_io_desc));
  181. /* setup early devices and console here as well */
  182. sh73a0_add_early_devices();
  183. shmobile_setup_console();
  184. }
  185. #define PINTC_ADDR 0xe6900000
  186. #define PINTER0A (PINTC_ADDR + 0xa0)
  187. #define PINTCR0A (PINTC_ADDR + 0xb0)
  188. void __init ag5evm_init_irq(void)
  189. {
  190. sh73a0_init_irq();
  191. /* setup PINT: enable PINTA2 as active low */
  192. __raw_writel(__raw_readl(PINTER0A) | (1<<29), PINTER0A);
  193. __raw_writew(__raw_readw(PINTCR0A) | (2<<10), PINTCR0A);
  194. }
  195. static void __init ag5evm_init(void)
  196. {
  197. sh73a0_pinmux_init();
  198. /* enable SCIFA2 */
  199. gpio_request(GPIO_FN_SCIFA2_TXD1, NULL);
  200. gpio_request(GPIO_FN_SCIFA2_RXD1, NULL);
  201. gpio_request(GPIO_FN_SCIFA2_RTS1_, NULL);
  202. gpio_request(GPIO_FN_SCIFA2_CTS1_, NULL);
  203. /* enable KEYSC */
  204. gpio_request(GPIO_FN_KEYIN0_PU, NULL);
  205. gpio_request(GPIO_FN_KEYIN1_PU, NULL);
  206. gpio_request(GPIO_FN_KEYIN2_PU, NULL);
  207. gpio_request(GPIO_FN_KEYIN3_PU, NULL);
  208. gpio_request(GPIO_FN_KEYIN4_PU, NULL);
  209. gpio_request(GPIO_FN_KEYIN5_PU, NULL);
  210. gpio_request(GPIO_FN_KEYIN6_PU, NULL);
  211. gpio_request(GPIO_FN_KEYIN7_PU, NULL);
  212. gpio_request(GPIO_FN_KEYOUT0, NULL);
  213. gpio_request(GPIO_FN_KEYOUT1, NULL);
  214. gpio_request(GPIO_FN_KEYOUT2, NULL);
  215. gpio_request(GPIO_FN_KEYOUT3, NULL);
  216. gpio_request(GPIO_FN_KEYOUT4, NULL);
  217. gpio_request(GPIO_FN_KEYOUT5, NULL);
  218. gpio_request(GPIO_FN_PORT59_KEYOUT6, NULL);
  219. gpio_request(GPIO_FN_PORT58_KEYOUT7, NULL);
  220. gpio_request(GPIO_FN_KEYOUT8, NULL);
  221. gpio_request(GPIO_FN_PORT149_KEYOUT9, NULL);
  222. /* enable I2C channel 2 and 3 */
  223. gpio_request(GPIO_FN_PORT236_I2C_SDA2, NULL);
  224. gpio_request(GPIO_FN_PORT237_I2C_SCL2, NULL);
  225. gpio_request(GPIO_FN_PORT248_I2C_SCL3, NULL);
  226. gpio_request(GPIO_FN_PORT249_I2C_SDA3, NULL);
  227. /* enable MMCIF */
  228. gpio_request(GPIO_FN_MMCCLK0, NULL);
  229. gpio_request(GPIO_FN_MMCCMD0_PU, NULL);
  230. gpio_request(GPIO_FN_MMCD0_0, NULL);
  231. gpio_request(GPIO_FN_MMCD0_1, NULL);
  232. gpio_request(GPIO_FN_MMCD0_2, NULL);
  233. gpio_request(GPIO_FN_MMCD0_3, NULL);
  234. gpio_request(GPIO_FN_MMCD0_4, NULL);
  235. gpio_request(GPIO_FN_MMCD0_5, NULL);
  236. gpio_request(GPIO_FN_MMCD0_6, NULL);
  237. gpio_request(GPIO_FN_MMCD0_7, NULL);
  238. gpio_request(GPIO_PORT208, NULL); /* Reset */
  239. gpio_direction_output(GPIO_PORT208, 1);
  240. /* enable SMSC911X */
  241. gpio_request(GPIO_PORT144, NULL); /* PINTA2 */
  242. gpio_direction_input(GPIO_PORT144);
  243. gpio_request(GPIO_PORT145, NULL); /* RESET */
  244. gpio_direction_output(GPIO_PORT145, 1);
  245. /* FSI A */
  246. gpio_request(GPIO_FN_FSIACK, NULL);
  247. gpio_request(GPIO_FN_FSIAILR, NULL);
  248. gpio_request(GPIO_FN_FSIAIBT, NULL);
  249. gpio_request(GPIO_FN_FSIAISLD, NULL);
  250. gpio_request(GPIO_FN_FSIAOSLD, NULL);
  251. #ifdef CONFIG_CACHE_L2X0
  252. /* Shared attribute override enable, 64K*8way */
  253. l2x0_init(__io(0xf0100000), 0x00460000, 0xc2000fff);
  254. #endif
  255. sh73a0_add_standard_devices();
  256. platform_add_devices(ag5evm_devices, ARRAY_SIZE(ag5evm_devices));
  257. }
  258. static void __init ag5evm_timer_init(void)
  259. {
  260. sh73a0_clock_init();
  261. shmobile_timer.init();
  262. return;
  263. }
  264. struct sys_timer ag5evm_timer = {
  265. .init = ag5evm_timer_init,
  266. };
  267. MACHINE_START(AG5EVM, "ag5evm")
  268. .map_io = ag5evm_map_io,
  269. .init_irq = ag5evm_init_irq,
  270. .handle_irq = shmobile_handle_irq_gic,
  271. .init_machine = ag5evm_init,
  272. .timer = &ag5evm_timer,
  273. MACHINE_END