board-kota2.c 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. /*
  2. * kota2 board support
  3. *
  4. * Copyright (C) 2011 Renesas Solutions Corp.
  5. * Copyright (C) 2011 Magnus Damm
  6. * Copyright (C) 2010 Takashi Yoshii <yoshii.takashi.zj@renesas.com>
  7. * Copyright (C) 2009 Yoshihiro Shimoda <shimoda.yoshihiro@renesas.com>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; version 2 of the License.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  21. */
  22. #include <linux/kernel.h>
  23. #include <linux/init.h>
  24. #include <linux/interrupt.h>
  25. #include <linux/irq.h>
  26. #include <linux/platform_device.h>
  27. #include <linux/delay.h>
  28. #include <linux/io.h>
  29. #include <linux/smsc911x.h>
  30. #include <linux/gpio.h>
  31. #include <linux/input.h>
  32. #include <linux/input/sh_keysc.h>
  33. #include <mach/hardware.h>
  34. #include <mach/sh73a0.h>
  35. #include <mach/common.h>
  36. #include <asm/mach-types.h>
  37. #include <asm/mach/arch.h>
  38. #include <asm/mach/map.h>
  39. #include <asm/mach/time.h>
  40. #include <asm/hardware/gic.h>
  41. #include <asm/hardware/cache-l2x0.h>
  42. #include <asm/traps.h>
  43. static struct resource smsc9220_resources[] = {
  44. [0] = {
  45. .start = 0x14000000, /* CS5A */
  46. .end = 0x140000ff, /* A1->A7 */
  47. .flags = IORESOURCE_MEM,
  48. },
  49. [1] = {
  50. .start = gic_spi(33), /* PINTA2 @ PORT144 */
  51. .flags = IORESOURCE_IRQ,
  52. },
  53. };
  54. static struct smsc911x_platform_config smsc9220_platdata = {
  55. .flags = SMSC911X_USE_32BIT, /* 32-bit SW on 16-bit HW bus */
  56. .phy_interface = PHY_INTERFACE_MODE_MII,
  57. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
  58. .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
  59. };
  60. static struct platform_device eth_device = {
  61. .name = "smsc911x",
  62. .id = 0,
  63. .dev = {
  64. .platform_data = &smsc9220_platdata,
  65. },
  66. .resource = smsc9220_resources,
  67. .num_resources = ARRAY_SIZE(smsc9220_resources),
  68. };
  69. static struct sh_keysc_info keysc_platdata = {
  70. .mode = SH_KEYSC_MODE_6,
  71. .scan_timing = 3,
  72. .delay = 100,
  73. .keycodes = {
  74. KEY_NUMERIC_STAR, KEY_NUMERIC_0, KEY_NUMERIC_POUND,
  75. 0, 0, 0, 0, 0,
  76. KEY_NUMERIC_7, KEY_NUMERIC_8, KEY_NUMERIC_9,
  77. 0, KEY_DOWN, 0, 0, 0,
  78. KEY_NUMERIC_4, KEY_NUMERIC_5, KEY_NUMERIC_6,
  79. KEY_LEFT, KEY_ENTER, KEY_RIGHT, 0, 0,
  80. KEY_NUMERIC_1, KEY_NUMERIC_2, KEY_NUMERIC_3,
  81. 0, KEY_UP, 0, 0, 0,
  82. 0, 0, 0, 0, 0, 0, 0, 0,
  83. 0, 0, 0, 0, 0, 0, 0, 0,
  84. 0, 0, 0, 0, 0, 0, 0, 0,
  85. 0, 0, 0, 0, 0, 0, 0, 0,
  86. },
  87. };
  88. static struct resource keysc_resources[] = {
  89. [0] = {
  90. .name = "KEYSC",
  91. .start = 0xe61b0000,
  92. .end = 0xe61b0098 - 1,
  93. .flags = IORESOURCE_MEM,
  94. },
  95. [1] = {
  96. .start = gic_spi(71),
  97. .flags = IORESOURCE_IRQ,
  98. },
  99. };
  100. static struct platform_device keysc_device = {
  101. .name = "sh_keysc",
  102. .id = 0,
  103. .num_resources = ARRAY_SIZE(keysc_resources),
  104. .resource = keysc_resources,
  105. .dev = {
  106. .platform_data = &keysc_platdata,
  107. },
  108. };
  109. static struct platform_device *kota2_devices[] __initdata = {
  110. &eth_device,
  111. &keysc_device,
  112. };
  113. static struct map_desc kota2_io_desc[] __initdata = {
  114. /* create a 1:1 entity map for 0xe6xxxxxx
  115. * used by CPGA, INTC and PFC.
  116. */
  117. {
  118. .virtual = 0xe6000000,
  119. .pfn = __phys_to_pfn(0xe6000000),
  120. .length = 256 << 20,
  121. .type = MT_DEVICE_NONSHARED
  122. },
  123. };
  124. static void __init kota2_map_io(void)
  125. {
  126. iotable_init(kota2_io_desc, ARRAY_SIZE(kota2_io_desc));
  127. /* setup early devices and console here as well */
  128. sh73a0_add_early_devices();
  129. shmobile_setup_console();
  130. }
  131. #define PINTER0A 0xe69000a0
  132. #define PINTCR0A 0xe69000b0
  133. void __init kota2_init_irq(void)
  134. {
  135. sh73a0_init_irq();
  136. /* setup PINT: enable PINTA2 as active low */
  137. __raw_writel(1 << 29, PINTER0A);
  138. __raw_writew(2 << 10, PINTCR0A);
  139. }
  140. static void __init kota2_init(void)
  141. {
  142. sh73a0_pinmux_init();
  143. /* SCIFA2 (UART2) */
  144. gpio_request(GPIO_FN_SCIFA2_TXD1, NULL);
  145. gpio_request(GPIO_FN_SCIFA2_RXD1, NULL);
  146. gpio_request(GPIO_FN_SCIFA2_RTS1_, NULL);
  147. gpio_request(GPIO_FN_SCIFA2_CTS1_, NULL);
  148. /* SMSC911X */
  149. gpio_request(GPIO_FN_D0_NAF0, NULL);
  150. gpio_request(GPIO_FN_D1_NAF1, NULL);
  151. gpio_request(GPIO_FN_D2_NAF2, NULL);
  152. gpio_request(GPIO_FN_D3_NAF3, NULL);
  153. gpio_request(GPIO_FN_D4_NAF4, NULL);
  154. gpio_request(GPIO_FN_D5_NAF5, NULL);
  155. gpio_request(GPIO_FN_D6_NAF6, NULL);
  156. gpio_request(GPIO_FN_D7_NAF7, NULL);
  157. gpio_request(GPIO_FN_D8_NAF8, NULL);
  158. gpio_request(GPIO_FN_D9_NAF9, NULL);
  159. gpio_request(GPIO_FN_D10_NAF10, NULL);
  160. gpio_request(GPIO_FN_D11_NAF11, NULL);
  161. gpio_request(GPIO_FN_D12_NAF12, NULL);
  162. gpio_request(GPIO_FN_D13_NAF13, NULL);
  163. gpio_request(GPIO_FN_D14_NAF14, NULL);
  164. gpio_request(GPIO_FN_D15_NAF15, NULL);
  165. gpio_request(GPIO_FN_CS5A_, NULL);
  166. gpio_request(GPIO_FN_WE0__FWE, NULL);
  167. gpio_request(GPIO_PORT144, NULL); /* PINTA2 */
  168. gpio_direction_input(GPIO_PORT144);
  169. gpio_request(GPIO_PORT145, NULL); /* RESET */
  170. gpio_direction_output(GPIO_PORT145, 1);
  171. /* KEYSC */
  172. gpio_request(GPIO_FN_KEYIN0_PU, NULL);
  173. gpio_request(GPIO_FN_KEYIN1_PU, NULL);
  174. gpio_request(GPIO_FN_KEYIN2_PU, NULL);
  175. gpio_request(GPIO_FN_KEYIN3_PU, NULL);
  176. gpio_request(GPIO_FN_KEYIN4_PU, NULL);
  177. gpio_request(GPIO_FN_KEYIN5_PU, NULL);
  178. gpio_request(GPIO_FN_KEYIN6_PU, NULL);
  179. gpio_request(GPIO_FN_KEYIN7_PU, NULL);
  180. gpio_request(GPIO_FN_KEYOUT0, NULL);
  181. gpio_request(GPIO_FN_KEYOUT1, NULL);
  182. gpio_request(GPIO_FN_KEYOUT2, NULL);
  183. gpio_request(GPIO_FN_KEYOUT3, NULL);
  184. gpio_request(GPIO_FN_KEYOUT4, NULL);
  185. gpio_request(GPIO_FN_KEYOUT5, NULL);
  186. gpio_request(GPIO_FN_PORT59_KEYOUT6, NULL);
  187. gpio_request(GPIO_FN_PORT58_KEYOUT7, NULL);
  188. gpio_request(GPIO_FN_KEYOUT8, NULL);
  189. #ifdef CONFIG_CACHE_L2X0
  190. /* Early BRESP enable, Shared attribute override enable, 64K*8way */
  191. l2x0_init(__io(0xf0100000), 0x40460000, 0x82000fff);
  192. #endif
  193. sh73a0_add_standard_devices();
  194. platform_add_devices(kota2_devices, ARRAY_SIZE(kota2_devices));
  195. }
  196. static void __init kota2_timer_init(void)
  197. {
  198. sh73a0_clock_init();
  199. shmobile_timer.init();
  200. return;
  201. }
  202. struct sys_timer kota2_timer = {
  203. .init = kota2_timer_init,
  204. };
  205. MACHINE_START(KOTA2, "kota2")
  206. .map_io = kota2_map_io,
  207. .init_irq = kota2_init_irq,
  208. .handle_irq = shmobile_handle_irq_gic,
  209. .init_machine = kota2_init,
  210. .timer = &kota2_timer,
  211. MACHINE_END