board-ag5evm.c 6.2 KB

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