board-kota2.c 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  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 <linux/gpio_keys.h>
  34. #include <linux/leds.h>
  35. #include <linux/mmc/host.h>
  36. #include <linux/mmc/sh_mmcif.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, /* CS5A */
  50. .end = 0x140000ff, /* A1->A7 */
  51. .flags = IORESOURCE_MEM,
  52. },
  53. [1] = {
  54. .start = gic_spi(33), /* PINTA2 @ PORT144 */
  55. .flags = IORESOURCE_IRQ,
  56. },
  57. };
  58. static struct smsc911x_platform_config smsc9220_platdata = {
  59. .flags = SMSC911X_USE_32BIT, /* 32-bit SW on 16-bit HW bus */
  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_NUMERIC_STAR, KEY_NUMERIC_0, KEY_NUMERIC_POUND,
  79. 0, 0, 0, 0, 0,
  80. KEY_NUMERIC_7, KEY_NUMERIC_8, KEY_NUMERIC_9,
  81. 0, KEY_DOWN, 0, 0, 0,
  82. KEY_NUMERIC_4, KEY_NUMERIC_5, KEY_NUMERIC_6,
  83. KEY_LEFT, KEY_ENTER, KEY_RIGHT, 0, 0,
  84. KEY_NUMERIC_1, KEY_NUMERIC_2, KEY_NUMERIC_3,
  85. 0, KEY_UP, 0, 0, 0,
  86. 0, 0, 0, 0, 0, 0, 0, 0,
  87. 0, 0, 0, 0, 0, 0, 0, 0,
  88. 0, 0, 0, 0, 0, 0, 0, 0,
  89. 0, 0, 0, 0, 0, 0, 0, 0,
  90. },
  91. };
  92. static struct resource keysc_resources[] = {
  93. [0] = {
  94. .name = "KEYSC",
  95. .start = 0xe61b0000,
  96. .end = 0xe61b0098 - 1,
  97. .flags = IORESOURCE_MEM,
  98. },
  99. [1] = {
  100. .start = gic_spi(71),
  101. .flags = IORESOURCE_IRQ,
  102. },
  103. };
  104. static struct platform_device keysc_device = {
  105. .name = "sh_keysc",
  106. .id = 0,
  107. .num_resources = ARRAY_SIZE(keysc_resources),
  108. .resource = keysc_resources,
  109. .dev = {
  110. .platform_data = &keysc_platdata,
  111. },
  112. };
  113. #define GPIO_KEY(c, g, d) { .code = c, .gpio = g, .desc = d, .active_low = 1 }
  114. static struct gpio_keys_button gpio_buttons[] = {
  115. GPIO_KEY(KEY_VOLUMEUP, GPIO_PORT56, "+"), /* S2: VOL+ [IRQ9] */
  116. GPIO_KEY(KEY_VOLUMEDOWN, GPIO_PORT54, "-"), /* S3: VOL- [IRQ10] */
  117. GPIO_KEY(KEY_MENU, GPIO_PORT27, "Menu"), /* S4: MENU [IRQ30] */
  118. GPIO_KEY(KEY_HOMEPAGE, GPIO_PORT26, "Home"), /* S5: HOME [IRQ31] */
  119. GPIO_KEY(KEY_BACK, GPIO_PORT11, "Back"), /* S6: BACK [IRQ0] */
  120. GPIO_KEY(KEY_PHONE, GPIO_PORT238, "Tel"), /* S7: TEL [IRQ11] */
  121. GPIO_KEY(KEY_POWER, GPIO_PORT239, "C1"), /* S8: CAM [IRQ13] */
  122. GPIO_KEY(KEY_MAIL, GPIO_PORT224, "Mail"), /* S9: MAIL [IRQ3] */
  123. /* Omitted button "C3?": GPIO_PORT223 - S10: CUST [IRQ8] */
  124. GPIO_KEY(KEY_CAMERA, GPIO_PORT164, "C2"), /* S11: CAM_HALF [IRQ25] */
  125. /* Omitted button "?": GPIO_PORT152 - S12: CAM_FULL [No IRQ] */
  126. };
  127. static struct gpio_keys_platform_data gpio_key_info = {
  128. .buttons = gpio_buttons,
  129. .nbuttons = ARRAY_SIZE(gpio_buttons),
  130. .poll_interval = 250, /* polled for now */
  131. };
  132. static struct platform_device gpio_keys_device = {
  133. .name = "gpio-keys-polled", /* polled for now */
  134. .id = -1,
  135. .dev = {
  136. .platform_data = &gpio_key_info,
  137. },
  138. };
  139. #define GPIO_LED(n, g) { .name = n, .gpio = g }
  140. static struct gpio_led gpio_leds[] = {
  141. GPIO_LED("V2513", GPIO_PORT153), /* PORT153 [TPU1T02] -> V2513 */
  142. GPIO_LED("V2514", GPIO_PORT199), /* PORT199 [TPU4TO1] -> V2514 */
  143. GPIO_LED("V2515", GPIO_PORT197), /* PORT197 [TPU2TO1] -> V2515 */
  144. GPIO_LED("KEYLED", GPIO_PORT163), /* PORT163 [TPU3TO0] -> KEYLED */
  145. GPIO_LED("G", GPIO_PORT20), /* PORT20 [GPO0] -> LED7 -> "G" */
  146. GPIO_LED("H", GPIO_PORT21), /* PORT21 [GPO1] -> LED8 -> "H" */
  147. GPIO_LED("J", GPIO_PORT22), /* PORT22 [GPO2] -> LED9 -> "J" */
  148. };
  149. static struct gpio_led_platform_data gpio_leds_info = {
  150. .leds = gpio_leds,
  151. .num_leds = ARRAY_SIZE(gpio_leds),
  152. };
  153. static struct platform_device gpio_leds_device = {
  154. .name = "leds-gpio",
  155. .id = -1,
  156. .dev = {
  157. .platform_data = &gpio_leds_info,
  158. },
  159. };
  160. static struct resource mmcif_resources[] = {
  161. [0] = {
  162. .name = "MMCIF",
  163. .start = 0xe6bd0000,
  164. .end = 0xe6bd00ff,
  165. .flags = IORESOURCE_MEM,
  166. },
  167. [1] = {
  168. .start = gic_spi(140),
  169. .flags = IORESOURCE_IRQ,
  170. },
  171. [2] = {
  172. .start = gic_spi(141),
  173. .flags = IORESOURCE_IRQ,
  174. },
  175. };
  176. static struct sh_mmcif_plat_data mmcif_info = {
  177. .ocr = MMC_VDD_165_195,
  178. .caps = MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE,
  179. };
  180. static struct platform_device mmcif_device = {
  181. .name = "sh_mmcif",
  182. .id = 0,
  183. .dev = {
  184. .platform_data = &mmcif_info,
  185. },
  186. .num_resources = ARRAY_SIZE(mmcif_resources),
  187. .resource = mmcif_resources,
  188. };
  189. static struct platform_device *kota2_devices[] __initdata = {
  190. &eth_device,
  191. &keysc_device,
  192. &gpio_keys_device,
  193. &gpio_leds_device,
  194. &mmcif_device,
  195. };
  196. static struct map_desc kota2_io_desc[] __initdata = {
  197. /* create a 1:1 entity map for 0xe6xxxxxx
  198. * used by CPGA, INTC and PFC.
  199. */
  200. {
  201. .virtual = 0xe6000000,
  202. .pfn = __phys_to_pfn(0xe6000000),
  203. .length = 256 << 20,
  204. .type = MT_DEVICE_NONSHARED
  205. },
  206. };
  207. static void __init kota2_map_io(void)
  208. {
  209. iotable_init(kota2_io_desc, ARRAY_SIZE(kota2_io_desc));
  210. /* setup early devices and console here as well */
  211. sh73a0_add_early_devices();
  212. shmobile_setup_console();
  213. }
  214. #define PINTER0A 0xe69000a0
  215. #define PINTCR0A 0xe69000b0
  216. void __init kota2_init_irq(void)
  217. {
  218. sh73a0_init_irq();
  219. /* setup PINT: enable PINTA2 as active low */
  220. __raw_writel(1 << 29, PINTER0A);
  221. __raw_writew(2 << 10, PINTCR0A);
  222. }
  223. static void __init kota2_init(void)
  224. {
  225. sh73a0_pinmux_init();
  226. /* SCIFA2 (UART2) */
  227. gpio_request(GPIO_FN_SCIFA2_TXD1, NULL);
  228. gpio_request(GPIO_FN_SCIFA2_RXD1, NULL);
  229. gpio_request(GPIO_FN_SCIFA2_RTS1_, NULL);
  230. gpio_request(GPIO_FN_SCIFA2_CTS1_, NULL);
  231. /* SMSC911X */
  232. gpio_request(GPIO_FN_D0_NAF0, NULL);
  233. gpio_request(GPIO_FN_D1_NAF1, NULL);
  234. gpio_request(GPIO_FN_D2_NAF2, NULL);
  235. gpio_request(GPIO_FN_D3_NAF3, NULL);
  236. gpio_request(GPIO_FN_D4_NAF4, NULL);
  237. gpio_request(GPIO_FN_D5_NAF5, NULL);
  238. gpio_request(GPIO_FN_D6_NAF6, NULL);
  239. gpio_request(GPIO_FN_D7_NAF7, NULL);
  240. gpio_request(GPIO_FN_D8_NAF8, NULL);
  241. gpio_request(GPIO_FN_D9_NAF9, NULL);
  242. gpio_request(GPIO_FN_D10_NAF10, NULL);
  243. gpio_request(GPIO_FN_D11_NAF11, NULL);
  244. gpio_request(GPIO_FN_D12_NAF12, NULL);
  245. gpio_request(GPIO_FN_D13_NAF13, NULL);
  246. gpio_request(GPIO_FN_D14_NAF14, NULL);
  247. gpio_request(GPIO_FN_D15_NAF15, NULL);
  248. gpio_request(GPIO_FN_CS5A_, NULL);
  249. gpio_request(GPIO_FN_WE0__FWE, NULL);
  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. /* KEYSC */
  255. gpio_request(GPIO_FN_KEYIN0_PU, NULL);
  256. gpio_request(GPIO_FN_KEYIN1_PU, NULL);
  257. gpio_request(GPIO_FN_KEYIN2_PU, NULL);
  258. gpio_request(GPIO_FN_KEYIN3_PU, NULL);
  259. gpio_request(GPIO_FN_KEYIN4_PU, NULL);
  260. gpio_request(GPIO_FN_KEYIN5_PU, NULL);
  261. gpio_request(GPIO_FN_KEYIN6_PU, NULL);
  262. gpio_request(GPIO_FN_KEYIN7_PU, NULL);
  263. gpio_request(GPIO_FN_KEYOUT0, NULL);
  264. gpio_request(GPIO_FN_KEYOUT1, NULL);
  265. gpio_request(GPIO_FN_KEYOUT2, NULL);
  266. gpio_request(GPIO_FN_KEYOUT3, NULL);
  267. gpio_request(GPIO_FN_KEYOUT4, NULL);
  268. gpio_request(GPIO_FN_KEYOUT5, NULL);
  269. gpio_request(GPIO_FN_PORT59_KEYOUT6, NULL);
  270. gpio_request(GPIO_FN_PORT58_KEYOUT7, NULL);
  271. gpio_request(GPIO_FN_KEYOUT8, NULL);
  272. /* MMCIF */
  273. gpio_request(GPIO_FN_MMCCLK0, NULL);
  274. gpio_request(GPIO_FN_MMCD0_0, NULL);
  275. gpio_request(GPIO_FN_MMCD0_1, NULL);
  276. gpio_request(GPIO_FN_MMCD0_2, NULL);
  277. gpio_request(GPIO_FN_MMCD0_3, NULL);
  278. gpio_request(GPIO_FN_MMCD0_4, NULL);
  279. gpio_request(GPIO_FN_MMCD0_5, NULL);
  280. gpio_request(GPIO_FN_MMCD0_6, NULL);
  281. gpio_request(GPIO_FN_MMCD0_7, NULL);
  282. gpio_request(GPIO_FN_MMCCMD0, NULL);
  283. gpio_request(GPIO_PORT208, NULL); /* Reset */
  284. gpio_direction_output(GPIO_PORT208, 1);
  285. #ifdef CONFIG_CACHE_L2X0
  286. /* Early BRESP enable, Shared attribute override enable, 64K*8way */
  287. l2x0_init(__io(0xf0100000), 0x40460000, 0x82000fff);
  288. #endif
  289. sh73a0_add_standard_devices();
  290. platform_add_devices(kota2_devices, ARRAY_SIZE(kota2_devices));
  291. }
  292. static void __init kota2_timer_init(void)
  293. {
  294. sh73a0_clock_init();
  295. shmobile_timer.init();
  296. return;
  297. }
  298. struct sys_timer kota2_timer = {
  299. .init = kota2_timer_init,
  300. };
  301. MACHINE_START(KOTA2, "kota2")
  302. .map_io = kota2_map_io,
  303. .init_irq = kota2_init_irq,
  304. .handle_irq = shmobile_handle_irq_gic,
  305. .init_machine = kota2_init,
  306. .timer = &kota2_timer,
  307. MACHINE_END