board-ag5evm.c 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  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 <sound/sh_fsi.h>
  35. #include <mach/hardware.h>
  36. #include <mach/sh73a0.h>
  37. #include <mach/common.h>
  38. #include <asm/mach-types.h>
  39. #include <asm/mach/arch.h>
  40. #include <asm/mach/map.h>
  41. #include <asm/mach/time.h>
  42. #include <asm/hardware/gic.h>
  43. #include <asm/hardware/cache-l2x0.h>
  44. #include <asm/traps.h>
  45. static struct resource smsc9220_resources[] = {
  46. [0] = {
  47. .start = 0x14000000,
  48. .end = 0x14000000 + SZ_64K - 1,
  49. .flags = IORESOURCE_MEM,
  50. },
  51. [1] = {
  52. .start = gic_spi(33), /* PINT1 */
  53. .flags = IORESOURCE_IRQ,
  54. },
  55. };
  56. static struct smsc911x_platform_config smsc9220_platdata = {
  57. .flags = SMSC911X_USE_32BIT | SMSC911X_SAVE_MAC_ADDRESS,
  58. .phy_interface = PHY_INTERFACE_MODE_MII,
  59. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
  60. .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
  61. };
  62. static struct platform_device eth_device = {
  63. .name = "smsc911x",
  64. .id = 0,
  65. .dev = {
  66. .platform_data = &smsc9220_platdata,
  67. },
  68. .resource = smsc9220_resources,
  69. .num_resources = ARRAY_SIZE(smsc9220_resources),
  70. };
  71. static struct sh_keysc_info keysc_platdata = {
  72. .mode = SH_KEYSC_MODE_6,
  73. .scan_timing = 3,
  74. .delay = 100,
  75. .keycodes = {
  76. KEY_A, KEY_B, KEY_C, KEY_D, KEY_E, KEY_F, KEY_G,
  77. KEY_H, KEY_I, KEY_J, KEY_K, KEY_L, KEY_M, KEY_N,
  78. KEY_O, KEY_P, KEY_Q, KEY_R, KEY_S, KEY_T, KEY_U,
  79. KEY_V, KEY_W, KEY_X, KEY_Y, KEY_Z, KEY_HOME, KEY_SLEEP,
  80. KEY_SPACE, KEY_9, KEY_6, KEY_3, KEY_WAKEUP, KEY_RIGHT, \
  81. KEY_COFFEE,
  82. KEY_0, KEY_8, KEY_5, KEY_2, KEY_DOWN, KEY_ENTER, KEY_UP,
  83. KEY_KPASTERISK, KEY_7, KEY_4, KEY_1, KEY_STOP, KEY_LEFT, \
  84. KEY_COMPUTER,
  85. },
  86. };
  87. static struct resource keysc_resources[] = {
  88. [0] = {
  89. .name = "KEYSC",
  90. .start = 0xe61b0000,
  91. .end = 0xe61b0098 - 1,
  92. .flags = IORESOURCE_MEM,
  93. },
  94. [1] = {
  95. .start = gic_spi(71),
  96. .flags = IORESOURCE_IRQ,
  97. },
  98. };
  99. static struct platform_device keysc_device = {
  100. .name = "sh_keysc",
  101. .id = 0,
  102. .num_resources = ARRAY_SIZE(keysc_resources),
  103. .resource = keysc_resources,
  104. .dev = {
  105. .platform_data = &keysc_platdata,
  106. },
  107. };
  108. /* FSI A */
  109. static struct sh_fsi_platform_info fsi_info = {
  110. .porta_flags = SH_FSI_OUT_SLAVE_MODE |
  111. SH_FSI_IN_SLAVE_MODE |
  112. SH_FSI_OFMT(I2S) |
  113. SH_FSI_IFMT(I2S),
  114. };
  115. static struct resource fsi_resources[] = {
  116. [0] = {
  117. .name = "FSI",
  118. .start = 0xEC230000,
  119. .end = 0xEC230400 - 1,
  120. .flags = IORESOURCE_MEM,
  121. },
  122. [1] = {
  123. .start = gic_spi(146),
  124. .flags = IORESOURCE_IRQ,
  125. },
  126. };
  127. static struct platform_device fsi_device = {
  128. .name = "sh_fsi2",
  129. .id = -1,
  130. .num_resources = ARRAY_SIZE(fsi_resources),
  131. .resource = fsi_resources,
  132. .dev = {
  133. .platform_data = &fsi_info,
  134. },
  135. };
  136. static struct platform_device *ag5evm_devices[] __initdata = {
  137. &eth_device,
  138. &keysc_device,
  139. &fsi_device,
  140. };
  141. static struct map_desc ag5evm_io_desc[] __initdata = {
  142. /* create a 1:1 entity map for 0xe6xxxxxx
  143. * used by CPGA, INTC and PFC.
  144. */
  145. {
  146. .virtual = 0xe6000000,
  147. .pfn = __phys_to_pfn(0xe6000000),
  148. .length = 256 << 20,
  149. .type = MT_DEVICE_NONSHARED
  150. },
  151. };
  152. static void __init ag5evm_map_io(void)
  153. {
  154. iotable_init(ag5evm_io_desc, ARRAY_SIZE(ag5evm_io_desc));
  155. /* setup early devices and console here as well */
  156. sh73a0_add_early_devices();
  157. shmobile_setup_console();
  158. }
  159. #define PINTC_ADDR 0xe6900000
  160. #define PINTER0A (PINTC_ADDR + 0xa0)
  161. #define PINTCR0A (PINTC_ADDR + 0xb0)
  162. void __init ag5evm_init_irq(void)
  163. {
  164. /* setup PINT: enable PINTA2 as active low */
  165. __raw_writel(__raw_readl(PINTER0A) | (1<<29), PINTER0A);
  166. __raw_writew(__raw_readw(PINTCR0A) | (2<<10), PINTCR0A);
  167. gic_dist_init(0, __io(0xf0001000), 29);
  168. gic_cpu_init(0, __io(0xf0000100));
  169. }
  170. static void __init ag5evm_init(void)
  171. {
  172. sh73a0_pinmux_init();
  173. /* enable SCIFA2 */
  174. gpio_request(GPIO_FN_SCIFA2_TXD1, NULL);
  175. gpio_request(GPIO_FN_SCIFA2_RXD1, NULL);
  176. gpio_request(GPIO_FN_SCIFA2_RTS1_, NULL);
  177. gpio_request(GPIO_FN_SCIFA2_CTS1_, NULL);
  178. /* enable KEYSC */
  179. gpio_request(GPIO_FN_KEYIN0, NULL);
  180. gpio_request(GPIO_FN_KEYIN1, NULL);
  181. gpio_request(GPIO_FN_KEYIN2, NULL);
  182. gpio_request(GPIO_FN_KEYIN3, NULL);
  183. gpio_request(GPIO_FN_KEYIN4, NULL);
  184. gpio_request(GPIO_FN_KEYIN5, NULL);
  185. gpio_request(GPIO_FN_KEYIN6, NULL);
  186. gpio_request(GPIO_FN_KEYIN7, NULL);
  187. gpio_request(GPIO_FN_KEYOUT0, NULL);
  188. gpio_request(GPIO_FN_KEYOUT1, NULL);
  189. gpio_request(GPIO_FN_KEYOUT2, NULL);
  190. gpio_request(GPIO_FN_KEYOUT3, NULL);
  191. gpio_request(GPIO_FN_KEYOUT4, NULL);
  192. gpio_request(GPIO_FN_KEYOUT5, NULL);
  193. gpio_request(GPIO_FN_PORT59_KEYOUT6, NULL);
  194. gpio_request(GPIO_FN_PORT58_KEYOUT7, NULL);
  195. gpio_request(GPIO_FN_KEYOUT8, NULL);
  196. gpio_request(GPIO_FN_PORT149_KEYOUT9, NULL);
  197. /* enable IC2 2 and 3 */
  198. gpio_request(GPIO_FN_PORT236_I2C_SDA2, NULL);
  199. gpio_request(GPIO_FN_PORT237_I2C_SCL2, NULL);
  200. gpio_request(GPIO_FN_PORT248_I2C_SCL3, NULL);
  201. gpio_request(GPIO_FN_PORT249_I2C_SDA3, NULL);
  202. /* enable SMSC911X */
  203. gpio_request(GPIO_PORT144, NULL); /* PINTA2 */
  204. gpio_direction_input(GPIO_PORT144);
  205. gpio_request(GPIO_PORT145, NULL); /* RESET */
  206. gpio_direction_output(GPIO_PORT145, 1);
  207. /* FSI A */
  208. gpio_request(GPIO_FN_FSIACK, NULL);
  209. gpio_request(GPIO_FN_FSIAILR, NULL);
  210. gpio_request(GPIO_FN_FSIAIBT, NULL);
  211. gpio_request(GPIO_FN_FSIAISLD, NULL);
  212. gpio_request(GPIO_FN_FSIAOSLD, NULL);
  213. #ifdef CONFIG_CACHE_L2X0
  214. /* Shared attribute override enable, 64K*8way */
  215. l2x0_init(__io(0xf0100000), 0x00460000, 0xc2000fff);
  216. #endif
  217. sh73a0_add_standard_devices();
  218. platform_add_devices(ag5evm_devices, ARRAY_SIZE(ag5evm_devices));
  219. }
  220. static void __init ag5evm_timer_init(void)
  221. {
  222. sh73a0_clock_init();
  223. shmobile_timer.init();
  224. return;
  225. }
  226. struct sys_timer ag5evm_timer = {
  227. .init = ag5evm_timer_init,
  228. };
  229. MACHINE_START(AG5EVM, "ag5evm")
  230. .map_io = ag5evm_map_io,
  231. .init_irq = ag5evm_init_irq,
  232. .init_machine = ag5evm_init,
  233. .timer = &ag5evm_timer,
  234. MACHINE_END