board-ag5evm.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482
  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 <linux/sh_clk.h>
  37. #include <video/sh_mobile_lcdc.h>
  38. #include <video/sh_mipi_dsi.h>
  39. #include <sound/sh_fsi.h>
  40. #include <mach/hardware.h>
  41. #include <mach/sh73a0.h>
  42. #include <mach/common.h>
  43. #include <asm/mach-types.h>
  44. #include <asm/mach/arch.h>
  45. #include <asm/mach/map.h>
  46. #include <asm/mach/time.h>
  47. #include <asm/hardware/gic.h>
  48. #include <asm/hardware/cache-l2x0.h>
  49. #include <asm/traps.h>
  50. static struct resource smsc9220_resources[] = {
  51. [0] = {
  52. .start = 0x14000000,
  53. .end = 0x14000000 + SZ_64K - 1,
  54. .flags = IORESOURCE_MEM,
  55. },
  56. [1] = {
  57. .start = gic_spi(33), /* PINT1 */
  58. .flags = IORESOURCE_IRQ,
  59. },
  60. };
  61. static struct smsc911x_platform_config smsc9220_platdata = {
  62. .flags = SMSC911X_USE_32BIT | SMSC911X_SAVE_MAC_ADDRESS,
  63. .phy_interface = PHY_INTERFACE_MODE_MII,
  64. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
  65. .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
  66. };
  67. static struct platform_device eth_device = {
  68. .name = "smsc911x",
  69. .id = 0,
  70. .dev = {
  71. .platform_data = &smsc9220_platdata,
  72. },
  73. .resource = smsc9220_resources,
  74. .num_resources = ARRAY_SIZE(smsc9220_resources),
  75. };
  76. static struct sh_keysc_info keysc_platdata = {
  77. .mode = SH_KEYSC_MODE_6,
  78. .scan_timing = 3,
  79. .delay = 100,
  80. .keycodes = {
  81. KEY_A, KEY_B, KEY_C, KEY_D, KEY_E, KEY_F, KEY_G,
  82. KEY_H, KEY_I, KEY_J, KEY_K, KEY_L, KEY_M, KEY_N,
  83. KEY_O, KEY_P, KEY_Q, KEY_R, KEY_S, KEY_T, KEY_U,
  84. KEY_V, KEY_W, KEY_X, KEY_Y, KEY_Z, KEY_HOME, KEY_SLEEP,
  85. KEY_SPACE, KEY_9, KEY_6, KEY_3, KEY_WAKEUP, KEY_RIGHT, \
  86. KEY_COFFEE,
  87. KEY_0, KEY_8, KEY_5, KEY_2, KEY_DOWN, KEY_ENTER, KEY_UP,
  88. KEY_KPASTERISK, KEY_7, KEY_4, KEY_1, KEY_STOP, KEY_LEFT, \
  89. KEY_COMPUTER,
  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. /* FSI A */
  114. static struct resource fsi_resources[] = {
  115. [0] = {
  116. .name = "FSI",
  117. .start = 0xEC230000,
  118. .end = 0xEC230400 - 1,
  119. .flags = IORESOURCE_MEM,
  120. },
  121. [1] = {
  122. .start = gic_spi(146),
  123. .flags = IORESOURCE_IRQ,
  124. },
  125. };
  126. static struct platform_device fsi_device = {
  127. .name = "sh_fsi2",
  128. .id = -1,
  129. .num_resources = ARRAY_SIZE(fsi_resources),
  130. .resource = fsi_resources,
  131. };
  132. static struct resource sh_mmcif_resources[] = {
  133. [0] = {
  134. .name = "MMCIF",
  135. .start = 0xe6bd0000,
  136. .end = 0xe6bd00ff,
  137. .flags = IORESOURCE_MEM,
  138. },
  139. [1] = {
  140. .start = gic_spi(141),
  141. .flags = IORESOURCE_IRQ,
  142. },
  143. [2] = {
  144. .start = gic_spi(140),
  145. .flags = IORESOURCE_IRQ,
  146. },
  147. };
  148. static struct sh_mmcif_plat_data sh_mmcif_platdata = {
  149. .sup_pclk = 0,
  150. .ocr = MMC_VDD_165_195,
  151. .caps = MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE,
  152. };
  153. static struct platform_device mmc_device = {
  154. .name = "sh_mmcif",
  155. .id = 0,
  156. .dev = {
  157. .dma_mask = NULL,
  158. .coherent_dma_mask = 0xffffffff,
  159. .platform_data = &sh_mmcif_platdata,
  160. },
  161. .num_resources = ARRAY_SIZE(sh_mmcif_resources),
  162. .resource = sh_mmcif_resources,
  163. };
  164. /* IrDA */
  165. static struct resource irda_resources[] = {
  166. [0] = {
  167. .start = 0xE6D00000,
  168. .end = 0xE6D01FD4 - 1,
  169. .flags = IORESOURCE_MEM,
  170. },
  171. [1] = {
  172. .start = gic_spi(95),
  173. .flags = IORESOURCE_IRQ,
  174. },
  175. };
  176. static struct platform_device irda_device = {
  177. .name = "sh_irda",
  178. .id = 0,
  179. .resource = irda_resources,
  180. .num_resources = ARRAY_SIZE(irda_resources),
  181. };
  182. static unsigned char lcd_backlight_seq[3][2] = {
  183. { 0x04, 0x07 },
  184. { 0x23, 0x80 },
  185. { 0x03, 0x01 },
  186. };
  187. static void lcd_backlight_on(void)
  188. {
  189. struct i2c_adapter *a;
  190. struct i2c_msg msg;
  191. int k;
  192. a = i2c_get_adapter(1);
  193. for (k = 0; a && k < 3; k++) {
  194. msg.addr = 0x6d;
  195. msg.buf = &lcd_backlight_seq[k][0];
  196. msg.len = 2;
  197. msg.flags = 0;
  198. if (i2c_transfer(a, &msg, 1) != 1)
  199. break;
  200. }
  201. }
  202. static void lcd_backlight_reset(void)
  203. {
  204. gpio_set_value(GPIO_PORT235, 0);
  205. mdelay(24);
  206. gpio_set_value(GPIO_PORT235, 1);
  207. }
  208. static void lcd_on(void *board_data, struct fb_info *info)
  209. {
  210. lcd_backlight_on();
  211. }
  212. static void lcd_off(void *board_data)
  213. {
  214. lcd_backlight_reset();
  215. }
  216. /* LCDC0 */
  217. static const struct fb_videomode lcdc0_modes[] = {
  218. {
  219. .name = "R63302(QHD)",
  220. .xres = 544,
  221. .yres = 961,
  222. .left_margin = 72,
  223. .right_margin = 600,
  224. .hsync_len = 16,
  225. .upper_margin = 8,
  226. .lower_margin = 8,
  227. .vsync_len = 2,
  228. .sync = FB_SYNC_VERT_HIGH_ACT | FB_SYNC_HOR_HIGH_ACT,
  229. },
  230. };
  231. static struct sh_mobile_lcdc_info lcdc0_info = {
  232. .clock_source = LCDC_CLK_PERIPHERAL,
  233. .ch[0] = {
  234. .chan = LCDC_CHAN_MAINLCD,
  235. .interface_type = RGB24,
  236. .clock_divider = 1,
  237. .flags = LCDC_FLAGS_DWPOL,
  238. .lcd_size_cfg.width = 44,
  239. .lcd_size_cfg.height = 79,
  240. .bpp = 16,
  241. .lcd_cfg = lcdc0_modes,
  242. .num_cfg = ARRAY_SIZE(lcdc0_modes),
  243. .board_cfg = {
  244. .display_on = lcd_on,
  245. .display_off = lcd_off,
  246. },
  247. }
  248. };
  249. static struct resource lcdc0_resources[] = {
  250. [0] = {
  251. .name = "LCDC0",
  252. .start = 0xfe940000, /* P4-only space */
  253. .end = 0xfe943fff,
  254. .flags = IORESOURCE_MEM,
  255. },
  256. [1] = {
  257. .start = intcs_evt2irq(0x580),
  258. .flags = IORESOURCE_IRQ,
  259. },
  260. };
  261. static struct platform_device lcdc0_device = {
  262. .name = "sh_mobile_lcdc_fb",
  263. .num_resources = ARRAY_SIZE(lcdc0_resources),
  264. .resource = lcdc0_resources,
  265. .id = 0,
  266. .dev = {
  267. .platform_data = &lcdc0_info,
  268. .coherent_dma_mask = ~0,
  269. },
  270. };
  271. /* MIPI-DSI */
  272. static struct resource mipidsi0_resources[] = {
  273. [0] = {
  274. .start = 0xfeab0000,
  275. .end = 0xfeab3fff,
  276. .flags = IORESOURCE_MEM,
  277. },
  278. [1] = {
  279. .start = 0xfeab4000,
  280. .end = 0xfeab7fff,
  281. .flags = IORESOURCE_MEM,
  282. },
  283. };
  284. static struct sh_mipi_dsi_info mipidsi0_info = {
  285. .data_format = MIPI_RGB888,
  286. .lcd_chan = &lcdc0_info.ch[0],
  287. .vsynw_offset = 20,
  288. .clksrc = 1,
  289. .flags = SH_MIPI_DSI_HSABM,
  290. };
  291. static struct platform_device mipidsi0_device = {
  292. .name = "sh-mipi-dsi",
  293. .num_resources = ARRAY_SIZE(mipidsi0_resources),
  294. .resource = mipidsi0_resources,
  295. .id = 0,
  296. .dev = {
  297. .platform_data = &mipidsi0_info,
  298. },
  299. };
  300. static struct platform_device *ag5evm_devices[] __initdata = {
  301. &eth_device,
  302. &keysc_device,
  303. &fsi_device,
  304. &mmc_device,
  305. &irda_device,
  306. &lcdc0_device,
  307. &mipidsi0_device,
  308. };
  309. static struct map_desc ag5evm_io_desc[] __initdata = {
  310. /* create a 1:1 entity map for 0xe6xxxxxx
  311. * used by CPGA, INTC and PFC.
  312. */
  313. {
  314. .virtual = 0xe6000000,
  315. .pfn = __phys_to_pfn(0xe6000000),
  316. .length = 256 << 20,
  317. .type = MT_DEVICE_NONSHARED
  318. },
  319. };
  320. static void __init ag5evm_map_io(void)
  321. {
  322. iotable_init(ag5evm_io_desc, ARRAY_SIZE(ag5evm_io_desc));
  323. /* setup early devices and console here as well */
  324. sh73a0_add_early_devices();
  325. shmobile_setup_console();
  326. }
  327. #define PINTC_ADDR 0xe6900000
  328. #define PINTER0A (PINTC_ADDR + 0xa0)
  329. #define PINTCR0A (PINTC_ADDR + 0xb0)
  330. void __init ag5evm_init_irq(void)
  331. {
  332. sh73a0_init_irq();
  333. /* setup PINT: enable PINTA2 as active low */
  334. __raw_writel(__raw_readl(PINTER0A) | (1<<29), PINTER0A);
  335. __raw_writew(__raw_readw(PINTCR0A) | (2<<10), PINTCR0A);
  336. }
  337. #define DSI0PHYCR 0xe615006c
  338. static void __init ag5evm_init(void)
  339. {
  340. sh73a0_pinmux_init();
  341. /* enable SCIFA2 */
  342. gpio_request(GPIO_FN_SCIFA2_TXD1, NULL);
  343. gpio_request(GPIO_FN_SCIFA2_RXD1, NULL);
  344. gpio_request(GPIO_FN_SCIFA2_RTS1_, NULL);
  345. gpio_request(GPIO_FN_SCIFA2_CTS1_, NULL);
  346. /* enable KEYSC */
  347. gpio_request(GPIO_FN_KEYIN0_PU, NULL);
  348. gpio_request(GPIO_FN_KEYIN1_PU, NULL);
  349. gpio_request(GPIO_FN_KEYIN2_PU, NULL);
  350. gpio_request(GPIO_FN_KEYIN3_PU, NULL);
  351. gpio_request(GPIO_FN_KEYIN4_PU, NULL);
  352. gpio_request(GPIO_FN_KEYIN5_PU, NULL);
  353. gpio_request(GPIO_FN_KEYIN6_PU, NULL);
  354. gpio_request(GPIO_FN_KEYIN7_PU, NULL);
  355. gpio_request(GPIO_FN_KEYOUT0, NULL);
  356. gpio_request(GPIO_FN_KEYOUT1, NULL);
  357. gpio_request(GPIO_FN_KEYOUT2, NULL);
  358. gpio_request(GPIO_FN_KEYOUT3, NULL);
  359. gpio_request(GPIO_FN_KEYOUT4, NULL);
  360. gpio_request(GPIO_FN_KEYOUT5, NULL);
  361. gpio_request(GPIO_FN_PORT59_KEYOUT6, NULL);
  362. gpio_request(GPIO_FN_PORT58_KEYOUT7, NULL);
  363. gpio_request(GPIO_FN_KEYOUT8, NULL);
  364. gpio_request(GPIO_FN_PORT149_KEYOUT9, NULL);
  365. /* enable I2C channel 2 and 3 */
  366. gpio_request(GPIO_FN_PORT236_I2C_SDA2, NULL);
  367. gpio_request(GPIO_FN_PORT237_I2C_SCL2, NULL);
  368. gpio_request(GPIO_FN_PORT248_I2C_SCL3, NULL);
  369. gpio_request(GPIO_FN_PORT249_I2C_SDA3, NULL);
  370. /* enable MMCIF */
  371. gpio_request(GPIO_FN_MMCCLK0, NULL);
  372. gpio_request(GPIO_FN_MMCCMD0_PU, NULL);
  373. gpio_request(GPIO_FN_MMCD0_0, NULL);
  374. gpio_request(GPIO_FN_MMCD0_1, NULL);
  375. gpio_request(GPIO_FN_MMCD0_2, NULL);
  376. gpio_request(GPIO_FN_MMCD0_3, NULL);
  377. gpio_request(GPIO_FN_MMCD0_4, NULL);
  378. gpio_request(GPIO_FN_MMCD0_5, NULL);
  379. gpio_request(GPIO_FN_MMCD0_6, NULL);
  380. gpio_request(GPIO_FN_MMCD0_7, NULL);
  381. gpio_request(GPIO_PORT208, NULL); /* Reset */
  382. gpio_direction_output(GPIO_PORT208, 1);
  383. /* enable SMSC911X */
  384. gpio_request(GPIO_PORT144, NULL); /* PINTA2 */
  385. gpio_direction_input(GPIO_PORT144);
  386. gpio_request(GPIO_PORT145, NULL); /* RESET */
  387. gpio_direction_output(GPIO_PORT145, 1);
  388. /* FSI A */
  389. gpio_request(GPIO_FN_FSIACK, NULL);
  390. gpio_request(GPIO_FN_FSIAILR, NULL);
  391. gpio_request(GPIO_FN_FSIAIBT, NULL);
  392. gpio_request(GPIO_FN_FSIAISLD, NULL);
  393. gpio_request(GPIO_FN_FSIAOSLD, NULL);
  394. /* IrDA */
  395. gpio_request(GPIO_FN_PORT241_IRDA_OUT, NULL);
  396. gpio_request(GPIO_FN_PORT242_IRDA_IN, NULL);
  397. gpio_request(GPIO_FN_PORT243_IRDA_FIRSEL, NULL);
  398. /* LCD panel */
  399. gpio_request(GPIO_PORT217, NULL); /* RESET */
  400. gpio_direction_output(GPIO_PORT217, 0);
  401. mdelay(1);
  402. gpio_set_value(GPIO_PORT217, 1);
  403. mdelay(100);
  404. /* LCD backlight controller */
  405. gpio_request(GPIO_PORT235, NULL); /* RESET */
  406. gpio_direction_output(GPIO_PORT235, 0);
  407. lcd_backlight_reset();
  408. /* MIPI-DSI clock setup */
  409. __raw_writel(0x2a809010, DSI0PHYCR);
  410. #ifdef CONFIG_CACHE_L2X0
  411. /* Shared attribute override enable, 64K*8way */
  412. l2x0_init(__io(0xf0100000), 0x00460000, 0xc2000fff);
  413. #endif
  414. sh73a0_add_standard_devices();
  415. platform_add_devices(ag5evm_devices, ARRAY_SIZE(ag5evm_devices));
  416. }
  417. static void __init ag5evm_timer_init(void)
  418. {
  419. sh73a0_clock_init();
  420. shmobile_timer.init();
  421. return;
  422. }
  423. struct sys_timer ag5evm_timer = {
  424. .init = ag5evm_timer_init,
  425. };
  426. MACHINE_START(AG5EVM, "ag5evm")
  427. .map_io = ag5evm_map_io,
  428. .init_irq = ag5evm_init_irq,
  429. .handle_irq = shmobile_handle_irq_gic,
  430. .init_machine = ag5evm_init,
  431. .timer = &ag5evm_timer,
  432. MACHINE_END