board-ap4evb.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892
  1. /*
  2. * AP4EVB board support
  3. *
  4. * Copyright (C) 2010 Magnus Damm
  5. * Copyright (C) 2008 Yoshihiro Shimoda
  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. #include <linux/clk.h>
  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/mfd/sh_mobile_sdhi.h>
  28. #include <linux/mmc/host.h>
  29. #include <linux/mtd/mtd.h>
  30. #include <linux/mtd/partitions.h>
  31. #include <linux/mtd/physmap.h>
  32. #include <linux/mmc/host.h>
  33. #include <linux/mmc/sh_mmcif.h>
  34. #include <linux/i2c.h>
  35. #include <linux/i2c/tsc2007.h>
  36. #include <linux/io.h>
  37. #include <linux/smsc911x.h>
  38. #include <linux/sh_intc.h>
  39. #include <linux/sh_clk.h>
  40. #include <linux/gpio.h>
  41. #include <linux/input.h>
  42. #include <linux/input/sh_keysc.h>
  43. #include <linux/usb/r8a66597.h>
  44. #include <sound/sh_fsi.h>
  45. #include <video/sh_mobile_lcdc.h>
  46. #include <video/sh_mipi_dsi.h>
  47. #include <mach/common.h>
  48. #include <mach/irqs.h>
  49. #include <mach/sh7372.h>
  50. #include <asm/mach-types.h>
  51. #include <asm/mach/arch.h>
  52. #include <asm/mach/map.h>
  53. #include <asm/mach/time.h>
  54. /*
  55. * Address Interface BusWidth note
  56. * ------------------------------------------------------------------
  57. * 0x0000_0000 NOR Flash ROM (MCP) 16bit SW7 : bit1 = ON
  58. * 0x0800_0000 user area -
  59. * 0x1000_0000 NOR Flash ROM (MCP) 16bit SW7 : bit1 = OFF
  60. * 0x1400_0000 Ether (LAN9220) 16bit
  61. * 0x1600_0000 user area - cannot use with NAND
  62. * 0x1800_0000 user area -
  63. * 0x1A00_0000 -
  64. * 0x4000_0000 LPDDR2-SDRAM (POP) 32bit
  65. */
  66. /*
  67. * NOR Flash ROM
  68. *
  69. * SW1 | SW2 | SW7 | NOR Flash ROM
  70. * bit1 | bit1 bit2 | bit1 | Memory allocation
  71. * ------+------------+------+------------------
  72. * OFF | ON OFF | ON | Area 0
  73. * OFF | ON OFF | OFF | Area 4
  74. */
  75. /*
  76. * NAND Flash ROM
  77. *
  78. * SW1 | SW2 | SW7 | NAND Flash ROM
  79. * bit1 | bit1 bit2 | bit2 | Memory allocation
  80. * ------+------------+------+------------------
  81. * OFF | ON OFF | ON | FCE 0
  82. * OFF | ON OFF | OFF | FCE 1
  83. */
  84. /*
  85. * SMSC 9220
  86. *
  87. * SW1 SMSC 9220
  88. * -----------------------
  89. * ON access disable
  90. * OFF access enable
  91. */
  92. /*
  93. * LCD / IRQ / KEYSC / IrDA
  94. *
  95. * IRQ = IRQ26 (TS), IRQ27 (VIO), IRQ28 (QHD-TouchScreen)
  96. * LCD = 2nd LCDC (WVGA)
  97. *
  98. * | SW43 |
  99. * SW3 | ON | OFF |
  100. * -------------+-----------------------+---------------+
  101. * ON | KEY / IrDA | LCD |
  102. * OFF | KEY / IrDA / IRQ | IRQ |
  103. *
  104. *
  105. * QHD / WVGA display
  106. *
  107. * You can choice display type on menuconfig.
  108. * Then, check above dip-switch.
  109. */
  110. /*
  111. * USB
  112. *
  113. * J7 : 1-2 MAX3355E VBUS
  114. * 2-3 DC 5.0V
  115. *
  116. * S39: bit2: off
  117. */
  118. /*
  119. * FSI/FSMI
  120. *
  121. * SW41 : ON : SH-Mobile AP4 Audio Mode
  122. * : OFF : Bluetooth Audio Mode
  123. */
  124. /*
  125. * MMC0/SDHI1 (CN7)
  126. *
  127. * J22 : select card voltage
  128. * 1-2 pin : 1.8v
  129. * 2-3 pin : 3.3v
  130. *
  131. * SW1 | SW33
  132. * | bit1 | bit2 | bit3 | bit4
  133. * ------------+------+------+------+-------
  134. * MMC0 OFF | OFF | ON | ON | X
  135. * SDHI1 OFF | ON | X | OFF | ON
  136. *
  137. * voltage lebel
  138. * CN7 : 1.8v
  139. * CN12: 3.3v
  140. */
  141. /* MTD */
  142. static struct mtd_partition nor_flash_partitions[] = {
  143. {
  144. .name = "loader",
  145. .offset = 0x00000000,
  146. .size = 512 * 1024,
  147. },
  148. {
  149. .name = "bootenv",
  150. .offset = MTDPART_OFS_APPEND,
  151. .size = 512 * 1024,
  152. },
  153. {
  154. .name = "kernel_ro",
  155. .offset = MTDPART_OFS_APPEND,
  156. .size = 8 * 1024 * 1024,
  157. .mask_flags = MTD_WRITEABLE,
  158. },
  159. {
  160. .name = "kernel",
  161. .offset = MTDPART_OFS_APPEND,
  162. .size = 8 * 1024 * 1024,
  163. },
  164. {
  165. .name = "data",
  166. .offset = MTDPART_OFS_APPEND,
  167. .size = MTDPART_SIZ_FULL,
  168. },
  169. };
  170. static struct physmap_flash_data nor_flash_data = {
  171. .width = 2,
  172. .parts = nor_flash_partitions,
  173. .nr_parts = ARRAY_SIZE(nor_flash_partitions),
  174. };
  175. static struct resource nor_flash_resources[] = {
  176. [0] = {
  177. .start = 0x00000000,
  178. .end = 0x08000000 - 1,
  179. .flags = IORESOURCE_MEM,
  180. }
  181. };
  182. static struct platform_device nor_flash_device = {
  183. .name = "physmap-flash",
  184. .dev = {
  185. .platform_data = &nor_flash_data,
  186. },
  187. .num_resources = ARRAY_SIZE(nor_flash_resources),
  188. .resource = nor_flash_resources,
  189. };
  190. /* SMSC 9220 */
  191. static struct resource smc911x_resources[] = {
  192. {
  193. .start = 0x14000000,
  194. .end = 0x16000000 - 1,
  195. .flags = IORESOURCE_MEM,
  196. }, {
  197. .start = evt2irq(0x02c0) /* IRQ6A */,
  198. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
  199. },
  200. };
  201. static struct smsc911x_platform_config smsc911x_info = {
  202. .flags = SMSC911X_USE_16BIT | SMSC911X_SAVE_MAC_ADDRESS,
  203. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
  204. .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
  205. };
  206. static struct platform_device smc911x_device = {
  207. .name = "smsc911x",
  208. .id = -1,
  209. .num_resources = ARRAY_SIZE(smc911x_resources),
  210. .resource = smc911x_resources,
  211. .dev = {
  212. .platform_data = &smsc911x_info,
  213. },
  214. };
  215. /* SH_MMCIF */
  216. static struct resource sh_mmcif_resources[] = {
  217. [0] = {
  218. .name = "SH_MMCIF",
  219. .start = 0xE6BD0000,
  220. .end = 0xE6BD00FF,
  221. .flags = IORESOURCE_MEM,
  222. },
  223. [1] = {
  224. /* MMC ERR */
  225. .start = evt2irq(0x1ac0),
  226. .flags = IORESOURCE_IRQ,
  227. },
  228. [2] = {
  229. /* MMC NOR */
  230. .start = evt2irq(0x1ae0),
  231. .flags = IORESOURCE_IRQ,
  232. },
  233. };
  234. static struct sh_mmcif_plat_data sh_mmcif_plat = {
  235. .sup_pclk = 0,
  236. .ocr = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34,
  237. .caps = MMC_CAP_4_BIT_DATA |
  238. MMC_CAP_8_BIT_DATA |
  239. MMC_CAP_NEEDS_POLL,
  240. };
  241. static struct platform_device sh_mmcif_device = {
  242. .name = "sh_mmcif",
  243. .id = 0,
  244. .dev = {
  245. .dma_mask = NULL,
  246. .coherent_dma_mask = 0xffffffff,
  247. .platform_data = &sh_mmcif_plat,
  248. },
  249. .num_resources = ARRAY_SIZE(sh_mmcif_resources),
  250. .resource = sh_mmcif_resources,
  251. };
  252. /* SDHI0 */
  253. static struct sh_mobile_sdhi_info sdhi0_info = {
  254. .dma_slave_tx = SHDMA_SLAVE_SDHI0_TX,
  255. .dma_slave_rx = SHDMA_SLAVE_SDHI0_RX,
  256. };
  257. static struct resource sdhi0_resources[] = {
  258. [0] = {
  259. .name = "SDHI0",
  260. .start = 0xe6850000,
  261. .end = 0xe68501ff,
  262. .flags = IORESOURCE_MEM,
  263. },
  264. [1] = {
  265. .start = evt2irq(0x0e00) /* SDHI0 */,
  266. .flags = IORESOURCE_IRQ,
  267. },
  268. };
  269. static struct platform_device sdhi0_device = {
  270. .name = "sh_mobile_sdhi",
  271. .num_resources = ARRAY_SIZE(sdhi0_resources),
  272. .resource = sdhi0_resources,
  273. .id = 0,
  274. .dev = {
  275. .platform_data = &sdhi0_info,
  276. },
  277. };
  278. /* SDHI1 */
  279. static struct sh_mobile_sdhi_info sdhi1_info = {
  280. .dma_slave_tx = SHDMA_SLAVE_SDHI1_TX,
  281. .dma_slave_rx = SHDMA_SLAVE_SDHI1_RX,
  282. .tmio_ocr_mask = MMC_VDD_165_195,
  283. };
  284. static struct resource sdhi1_resources[] = {
  285. [0] = {
  286. .name = "SDHI1",
  287. .start = 0xe6860000,
  288. .end = 0xe68601ff,
  289. .flags = IORESOURCE_MEM,
  290. },
  291. [1] = {
  292. .start = evt2irq(0x0e80),
  293. .flags = IORESOURCE_IRQ,
  294. },
  295. };
  296. static struct platform_device sdhi1_device = {
  297. .name = "sh_mobile_sdhi",
  298. .num_resources = ARRAY_SIZE(sdhi1_resources),
  299. .resource = sdhi1_resources,
  300. .id = 1,
  301. .dev = {
  302. .platform_data = &sdhi1_info,
  303. },
  304. };
  305. /* USB1 */
  306. static void usb1_host_port_power(int port, int power)
  307. {
  308. if (!power) /* only power-on supported for now */
  309. return;
  310. /* set VBOUT/PWEN and EXTLP1 in DVSTCTR */
  311. __raw_writew(__raw_readw(0xE68B0008) | 0x600, 0xE68B0008);
  312. }
  313. static struct r8a66597_platdata usb1_host_data = {
  314. .on_chip = 1,
  315. .port_power = usb1_host_port_power,
  316. };
  317. static struct resource usb1_host_resources[] = {
  318. [0] = {
  319. .name = "USBHS",
  320. .start = 0xE68B0000,
  321. .end = 0xE68B00E6 - 1,
  322. .flags = IORESOURCE_MEM,
  323. },
  324. [1] = {
  325. .start = evt2irq(0x1ce0) /* USB1_USB1I0 */,
  326. .flags = IORESOURCE_IRQ,
  327. },
  328. };
  329. static struct platform_device usb1_host_device = {
  330. .name = "r8a66597_hcd",
  331. .id = 1,
  332. .dev = {
  333. .dma_mask = NULL, /* not use dma */
  334. .coherent_dma_mask = 0xffffffff,
  335. .platform_data = &usb1_host_data,
  336. },
  337. .num_resources = ARRAY_SIZE(usb1_host_resources),
  338. .resource = usb1_host_resources,
  339. };
  340. static struct sh_mobile_lcdc_info lcdc_info = {
  341. .ch[0] = {
  342. .chan = LCDC_CHAN_MAINLCD,
  343. .bpp = 16,
  344. }
  345. };
  346. static struct resource lcdc_resources[] = {
  347. [0] = {
  348. .name = "LCDC",
  349. .start = 0xfe940000, /* P4-only space */
  350. .end = 0xfe943fff,
  351. .flags = IORESOURCE_MEM,
  352. },
  353. [1] = {
  354. .start = intcs_evt2irq(0x580),
  355. .flags = IORESOURCE_IRQ,
  356. },
  357. };
  358. static struct platform_device lcdc_device = {
  359. .name = "sh_mobile_lcdc_fb",
  360. .num_resources = ARRAY_SIZE(lcdc_resources),
  361. .resource = lcdc_resources,
  362. .dev = {
  363. .platform_data = &lcdc_info,
  364. .coherent_dma_mask = ~0,
  365. },
  366. };
  367. /*
  368. * QHD display
  369. */
  370. #ifdef CONFIG_AP4EVB_QHD
  371. /* KEYSC (Needs SW43 set to ON) */
  372. static struct sh_keysc_info keysc_info = {
  373. .mode = SH_KEYSC_MODE_1,
  374. .scan_timing = 3,
  375. .delay = 2500,
  376. .keycodes = {
  377. KEY_0, KEY_1, KEY_2, KEY_3, KEY_4,
  378. KEY_5, KEY_6, KEY_7, KEY_8, KEY_9,
  379. KEY_A, KEY_B, KEY_C, KEY_D, KEY_E,
  380. KEY_F, KEY_G, KEY_H, KEY_I, KEY_J,
  381. KEY_K, KEY_L, KEY_M, KEY_N, KEY_O,
  382. },
  383. };
  384. static struct resource keysc_resources[] = {
  385. [0] = {
  386. .name = "KEYSC",
  387. .start = 0xe61b0000,
  388. .end = 0xe61b0063,
  389. .flags = IORESOURCE_MEM,
  390. },
  391. [1] = {
  392. .start = evt2irq(0x0be0), /* KEYSC_KEY */
  393. .flags = IORESOURCE_IRQ,
  394. },
  395. };
  396. static struct platform_device keysc_device = {
  397. .name = "sh_keysc",
  398. .id = 0, /* "keysc0" clock */
  399. .num_resources = ARRAY_SIZE(keysc_resources),
  400. .resource = keysc_resources,
  401. .dev = {
  402. .platform_data = &keysc_info,
  403. },
  404. };
  405. /* MIPI-DSI */
  406. static struct resource mipidsi0_resources[] = {
  407. [0] = {
  408. .start = 0xffc60000,
  409. .end = 0xffc68fff,
  410. .flags = IORESOURCE_MEM,
  411. },
  412. };
  413. static struct sh_mipi_dsi_info mipidsi0_info = {
  414. .data_format = MIPI_RGB888,
  415. .lcd_chan = &lcdc_info.ch[0],
  416. };
  417. static struct platform_device mipidsi0_device = {
  418. .name = "sh-mipi-dsi",
  419. .num_resources = ARRAY_SIZE(mipidsi0_resources),
  420. .resource = mipidsi0_resources,
  421. .id = 0,
  422. .dev = {
  423. .platform_data = &mipidsi0_info,
  424. },
  425. };
  426. /* This function will disappear when we switch to (runtime) PM */
  427. static int __init ap4evb_init_display_clk(void)
  428. {
  429. struct clk *lcdc_clk;
  430. struct clk *dsitx_clk;
  431. int ret;
  432. lcdc_clk = clk_get(&lcdc_device.dev, "sh_mobile_lcdc_fb.0");
  433. if (IS_ERR(lcdc_clk))
  434. return PTR_ERR(lcdc_clk);
  435. dsitx_clk = clk_get(&mipidsi0_device.dev, "sh-mipi-dsi.0");
  436. if (IS_ERR(dsitx_clk)) {
  437. ret = PTR_ERR(dsitx_clk);
  438. goto eclkdsitxget;
  439. }
  440. ret = clk_enable(lcdc_clk);
  441. if (ret < 0)
  442. goto eclklcdcon;
  443. ret = clk_enable(dsitx_clk);
  444. if (ret < 0)
  445. goto eclkdsitxon;
  446. return 0;
  447. eclkdsitxon:
  448. clk_disable(lcdc_clk);
  449. eclklcdcon:
  450. clk_put(dsitx_clk);
  451. eclkdsitxget:
  452. clk_put(lcdc_clk);
  453. return ret;
  454. }
  455. device_initcall(ap4evb_init_display_clk);
  456. static struct platform_device *qhd_devices[] __initdata = {
  457. &mipidsi0_device,
  458. &keysc_device,
  459. };
  460. #endif /* CONFIG_AP4EVB_QHD */
  461. /* FSI */
  462. #define IRQ_FSI evt2irq(0x1840)
  463. #define FSIACKCR 0xE6150018
  464. static void fsiackcr_init(struct clk *clk)
  465. {
  466. u32 status = __raw_readl(clk->enable_reg);
  467. /* use external clock */
  468. status &= ~0x000000ff;
  469. status |= 0x00000080;
  470. __raw_writel(status, clk->enable_reg);
  471. }
  472. static struct clk_ops fsiackcr_clk_ops = {
  473. .init = fsiackcr_init,
  474. };
  475. static struct clk fsiackcr_clk = {
  476. .ops = &fsiackcr_clk_ops,
  477. .enable_reg = (void __iomem *)FSIACKCR,
  478. .rate = 0, /* unknown */
  479. };
  480. static struct sh_fsi_platform_info fsi_info = {
  481. .porta_flags = SH_FSI_BRS_INV |
  482. SH_FSI_OUT_SLAVE_MODE |
  483. SH_FSI_IN_SLAVE_MODE |
  484. SH_FSI_OFMT(PCM) |
  485. SH_FSI_IFMT(PCM),
  486. };
  487. static struct resource fsi_resources[] = {
  488. [0] = {
  489. .name = "FSI",
  490. .start = 0xFE3C0000,
  491. .end = 0xFE3C0400 - 1,
  492. .flags = IORESOURCE_MEM,
  493. },
  494. [1] = {
  495. .start = IRQ_FSI,
  496. .flags = IORESOURCE_IRQ,
  497. },
  498. };
  499. static struct platform_device fsi_device = {
  500. .name = "sh_fsi2",
  501. .id = 0,
  502. .num_resources = ARRAY_SIZE(fsi_resources),
  503. .resource = fsi_resources,
  504. .dev = {
  505. .platform_data = &fsi_info,
  506. },
  507. };
  508. static struct platform_device *ap4evb_devices[] __initdata = {
  509. &nor_flash_device,
  510. &smc911x_device,
  511. &sdhi0_device,
  512. &sdhi1_device,
  513. &usb1_host_device,
  514. &lcdc_device,
  515. &fsi_device,
  516. &sh_mmcif_device
  517. };
  518. /* TouchScreen */
  519. #define IRQ28 evt2irq(0x3380) /* IRQ28A */
  520. #define IRQ7 evt2irq(0x02e0) /* IRQ7A */
  521. static struct tsc2007_platform_data tsc2007_info = {
  522. .model = 2007,
  523. .x_plate_ohms = 180,
  524. };
  525. static struct i2c_board_info tsc_device = {
  526. I2C_BOARD_INFO("tsc2007", 0x48),
  527. .type = "tsc2007",
  528. .platform_data = &tsc2007_info,
  529. /*.irq is selected on ap4evb_init */
  530. };
  531. /* I2C */
  532. static struct i2c_board_info i2c0_devices[] = {
  533. {
  534. I2C_BOARD_INFO("ak4643", 0x13),
  535. },
  536. };
  537. static struct i2c_board_info i2c1_devices[] = {
  538. {
  539. I2C_BOARD_INFO("r2025sd", 0x32),
  540. },
  541. };
  542. static struct map_desc ap4evb_io_desc[] __initdata = {
  543. /* create a 1:1 entity map for 0xe6xxxxxx
  544. * used by CPGA, INTC and PFC.
  545. */
  546. {
  547. .virtual = 0xe6000000,
  548. .pfn = __phys_to_pfn(0xe6000000),
  549. .length = 256 << 20,
  550. .type = MT_DEVICE_NONSHARED
  551. },
  552. };
  553. static void __init ap4evb_map_io(void)
  554. {
  555. iotable_init(ap4evb_io_desc, ARRAY_SIZE(ap4evb_io_desc));
  556. /* setup early devices and console here as well */
  557. sh7372_add_early_devices();
  558. shmobile_setup_console();
  559. }
  560. /*
  561. * FIXME !!
  562. *
  563. * gpio_no_direction is quick_hack.
  564. *
  565. * current gpio frame work doesn't have
  566. * the method to control only pull up/down/free.
  567. * this function should be replaced by correct gpio function
  568. */
  569. static void __init gpio_no_direction(u32 addr)
  570. {
  571. __raw_writeb(0x00, addr);
  572. }
  573. #define GPIO_PORT9CR 0xE6051009
  574. #define GPIO_PORT10CR 0xE605100A
  575. static void __init ap4evb_init(void)
  576. {
  577. struct clk *clk;
  578. sh7372_pinmux_init();
  579. /* enable SCIFA0 */
  580. gpio_request(GPIO_FN_SCIFA0_TXD, NULL);
  581. gpio_request(GPIO_FN_SCIFA0_RXD, NULL);
  582. /* enable SMSC911X */
  583. gpio_request(GPIO_FN_CS5A, NULL);
  584. gpio_request(GPIO_FN_IRQ6_39, NULL);
  585. /* enable LED 1 - 4 */
  586. gpio_request(GPIO_PORT185, NULL);
  587. gpio_request(GPIO_PORT186, NULL);
  588. gpio_request(GPIO_PORT187, NULL);
  589. gpio_request(GPIO_PORT188, NULL);
  590. gpio_direction_output(GPIO_PORT185, 1);
  591. gpio_direction_output(GPIO_PORT186, 1);
  592. gpio_direction_output(GPIO_PORT187, 1);
  593. gpio_direction_output(GPIO_PORT188, 1);
  594. gpio_export(GPIO_PORT185, 0);
  595. gpio_export(GPIO_PORT186, 0);
  596. gpio_export(GPIO_PORT187, 0);
  597. gpio_export(GPIO_PORT188, 0);
  598. /* enable Debug switch (S6) */
  599. gpio_request(GPIO_PORT32, NULL);
  600. gpio_request(GPIO_PORT33, NULL);
  601. gpio_request(GPIO_PORT34, NULL);
  602. gpio_request(GPIO_PORT35, NULL);
  603. gpio_direction_input(GPIO_PORT32);
  604. gpio_direction_input(GPIO_PORT33);
  605. gpio_direction_input(GPIO_PORT34);
  606. gpio_direction_input(GPIO_PORT35);
  607. gpio_export(GPIO_PORT32, 0);
  608. gpio_export(GPIO_PORT33, 0);
  609. gpio_export(GPIO_PORT34, 0);
  610. gpio_export(GPIO_PORT35, 0);
  611. /* SDHI0 */
  612. gpio_request(GPIO_FN_SDHICD0, NULL);
  613. gpio_request(GPIO_FN_SDHIWP0, NULL);
  614. gpio_request(GPIO_FN_SDHICMD0, NULL);
  615. gpio_request(GPIO_FN_SDHICLK0, NULL);
  616. gpio_request(GPIO_FN_SDHID0_3, NULL);
  617. gpio_request(GPIO_FN_SDHID0_2, NULL);
  618. gpio_request(GPIO_FN_SDHID0_1, NULL);
  619. gpio_request(GPIO_FN_SDHID0_0, NULL);
  620. /* SDHI1 */
  621. gpio_request(GPIO_FN_SDHICMD1, NULL);
  622. gpio_request(GPIO_FN_SDHICLK1, NULL);
  623. gpio_request(GPIO_FN_SDHID1_3, NULL);
  624. gpio_request(GPIO_FN_SDHID1_2, NULL);
  625. gpio_request(GPIO_FN_SDHID1_1, NULL);
  626. gpio_request(GPIO_FN_SDHID1_0, NULL);
  627. /* MMCIF */
  628. gpio_request(GPIO_FN_MMCD0_0, NULL);
  629. gpio_request(GPIO_FN_MMCD0_1, NULL);
  630. gpio_request(GPIO_FN_MMCD0_2, NULL);
  631. gpio_request(GPIO_FN_MMCD0_3, NULL);
  632. gpio_request(GPIO_FN_MMCD0_4, NULL);
  633. gpio_request(GPIO_FN_MMCD0_5, NULL);
  634. gpio_request(GPIO_FN_MMCD0_6, NULL);
  635. gpio_request(GPIO_FN_MMCD0_7, NULL);
  636. gpio_request(GPIO_FN_MMCCMD0, NULL);
  637. gpio_request(GPIO_FN_MMCCLK0, NULL);
  638. /* USB enable */
  639. gpio_request(GPIO_FN_VBUS0_1, NULL);
  640. gpio_request(GPIO_FN_IDIN_1_18, NULL);
  641. gpio_request(GPIO_FN_PWEN_1_115, NULL);
  642. gpio_request(GPIO_FN_OVCN_1_114, NULL);
  643. gpio_request(GPIO_FN_EXTLP_1, NULL);
  644. gpio_request(GPIO_FN_OVCN2_1, NULL);
  645. /* setup USB phy */
  646. __raw_writew(0x8a0a, 0xE6058130); /* USBCR2 */
  647. /* enable FSI2 */
  648. gpio_request(GPIO_FN_FSIAIBT, NULL);
  649. gpio_request(GPIO_FN_FSIAILR, NULL);
  650. gpio_request(GPIO_FN_FSIAISLD, NULL);
  651. gpio_request(GPIO_FN_FSIAOSLD, NULL);
  652. gpio_request(GPIO_PORT161, NULL);
  653. gpio_direction_output(GPIO_PORT161, 0); /* slave */
  654. gpio_request(GPIO_PORT9, NULL);
  655. gpio_request(GPIO_PORT10, NULL);
  656. gpio_no_direction(GPIO_PORT9CR); /* FSIAOBT needs no direction */
  657. gpio_no_direction(GPIO_PORT10CR); /* FSIAOLR needs no direction */
  658. /* set SPU2 clock to 119.6 MHz */
  659. clk = clk_get(NULL, "spu_clk");
  660. if (!IS_ERR(clk)) {
  661. clk_set_rate(clk, clk_round_rate(clk, 119600000));
  662. clk_put(clk);
  663. }
  664. /* change parent of FSI A */
  665. clk = clk_get(NULL, "fsia_clk");
  666. if (!IS_ERR(clk)) {
  667. clk_register(&fsiackcr_clk);
  668. clk_set_parent(clk, &fsiackcr_clk);
  669. clk_put(clk);
  670. }
  671. /*
  672. * set irq priority, to avoid sound chopping
  673. * when NFS rootfs is used
  674. * FSI(3) > SMSC911X(2)
  675. */
  676. intc_set_priority(IRQ_FSI, 3);
  677. i2c_register_board_info(0, i2c0_devices,
  678. ARRAY_SIZE(i2c0_devices));
  679. i2c_register_board_info(1, i2c1_devices,
  680. ARRAY_SIZE(i2c1_devices));
  681. #ifdef CONFIG_AP4EVB_QHD
  682. /*
  683. * QHD
  684. */
  685. /* enable KEYSC */
  686. gpio_request(GPIO_FN_KEYOUT0, NULL);
  687. gpio_request(GPIO_FN_KEYOUT1, NULL);
  688. gpio_request(GPIO_FN_KEYOUT2, NULL);
  689. gpio_request(GPIO_FN_KEYOUT3, NULL);
  690. gpio_request(GPIO_FN_KEYOUT4, NULL);
  691. gpio_request(GPIO_FN_KEYIN0_136, NULL);
  692. gpio_request(GPIO_FN_KEYIN1_135, NULL);
  693. gpio_request(GPIO_FN_KEYIN2_134, NULL);
  694. gpio_request(GPIO_FN_KEYIN3_133, NULL);
  695. gpio_request(GPIO_FN_KEYIN4, NULL);
  696. /* enable TouchScreen */
  697. gpio_request(GPIO_FN_IRQ28_123, NULL);
  698. set_irq_type(IRQ28, IRQ_TYPE_LEVEL_LOW);
  699. tsc_device.irq = IRQ28;
  700. i2c_register_board_info(1, &tsc_device, 1);
  701. /* LCDC0 */
  702. lcdc_info.clock_source = LCDC_CLK_PERIPHERAL;
  703. lcdc_info.ch[0].interface_type = RGB24;
  704. lcdc_info.ch[0].clock_divider = 1;
  705. lcdc_info.ch[0].flags = LCDC_FLAGS_DWPOL;
  706. lcdc_info.ch[0].lcd_cfg.name = "R63302(QHD)";
  707. lcdc_info.ch[0].lcd_cfg.xres = 544;
  708. lcdc_info.ch[0].lcd_cfg.yres = 961;
  709. lcdc_info.ch[0].lcd_cfg.left_margin = 72;
  710. lcdc_info.ch[0].lcd_cfg.right_margin = 600;
  711. lcdc_info.ch[0].lcd_cfg.hsync_len = 16;
  712. lcdc_info.ch[0].lcd_cfg.upper_margin = 8;
  713. lcdc_info.ch[0].lcd_cfg.lower_margin = 8;
  714. lcdc_info.ch[0].lcd_cfg.vsync_len = 2;
  715. lcdc_info.ch[0].lcd_cfg.sync = FB_SYNC_VERT_HIGH_ACT |
  716. FB_SYNC_HOR_HIGH_ACT;
  717. lcdc_info.ch[0].lcd_size_cfg.width = 44;
  718. lcdc_info.ch[0].lcd_size_cfg.height = 79;
  719. platform_add_devices(qhd_devices, ARRAY_SIZE(qhd_devices));
  720. #else
  721. /*
  722. * WVGA
  723. */
  724. gpio_request(GPIO_FN_LCDD17, NULL);
  725. gpio_request(GPIO_FN_LCDD16, NULL);
  726. gpio_request(GPIO_FN_LCDD15, NULL);
  727. gpio_request(GPIO_FN_LCDD14, NULL);
  728. gpio_request(GPIO_FN_LCDD13, NULL);
  729. gpio_request(GPIO_FN_LCDD12, NULL);
  730. gpio_request(GPIO_FN_LCDD11, NULL);
  731. gpio_request(GPIO_FN_LCDD10, NULL);
  732. gpio_request(GPIO_FN_LCDD9, NULL);
  733. gpio_request(GPIO_FN_LCDD8, NULL);
  734. gpio_request(GPIO_FN_LCDD7, NULL);
  735. gpio_request(GPIO_FN_LCDD6, NULL);
  736. gpio_request(GPIO_FN_LCDD5, NULL);
  737. gpio_request(GPIO_FN_LCDD4, NULL);
  738. gpio_request(GPIO_FN_LCDD3, NULL);
  739. gpio_request(GPIO_FN_LCDD2, NULL);
  740. gpio_request(GPIO_FN_LCDD1, NULL);
  741. gpio_request(GPIO_FN_LCDD0, NULL);
  742. gpio_request(GPIO_FN_LCDDISP, NULL);
  743. gpio_request(GPIO_FN_LCDDCK, NULL);
  744. gpio_request(GPIO_PORT189, NULL); /* backlight */
  745. gpio_direction_output(GPIO_PORT189, 1);
  746. gpio_request(GPIO_PORT151, NULL); /* LCDDON */
  747. gpio_direction_output(GPIO_PORT151, 1);
  748. lcdc_info.clock_source = LCDC_CLK_BUS;
  749. lcdc_info.ch[0].interface_type = RGB18;
  750. lcdc_info.ch[0].clock_divider = 2;
  751. lcdc_info.ch[0].flags = 0;
  752. lcdc_info.ch[0].lcd_cfg.name = "WVGA Panel";
  753. lcdc_info.ch[0].lcd_cfg.xres = 800;
  754. lcdc_info.ch[0].lcd_cfg.yres = 480;
  755. lcdc_info.ch[0].lcd_cfg.left_margin = 220;
  756. lcdc_info.ch[0].lcd_cfg.right_margin = 110;
  757. lcdc_info.ch[0].lcd_cfg.hsync_len = 70;
  758. lcdc_info.ch[0].lcd_cfg.upper_margin = 20;
  759. lcdc_info.ch[0].lcd_cfg.lower_margin = 5;
  760. lcdc_info.ch[0].lcd_cfg.vsync_len = 5;
  761. lcdc_info.ch[0].lcd_cfg.sync = 0;
  762. lcdc_info.ch[0].lcd_size_cfg.width = 152;
  763. lcdc_info.ch[0].lcd_size_cfg.height = 91;
  764. /* enable TouchScreen */
  765. gpio_request(GPIO_FN_IRQ7_40, NULL);
  766. set_irq_type(IRQ7, IRQ_TYPE_LEVEL_LOW);
  767. tsc_device.irq = IRQ7;
  768. i2c_register_board_info(0, &tsc_device, 1);
  769. #endif /* CONFIG_AP4EVB_QHD */
  770. sh7372_add_standard_devices();
  771. platform_add_devices(ap4evb_devices, ARRAY_SIZE(ap4evb_devices));
  772. }
  773. static void __init ap4evb_timer_init(void)
  774. {
  775. sh7372_clock_init();
  776. shmobile_timer.init();
  777. }
  778. static struct sys_timer ap4evb_timer = {
  779. .init = ap4evb_timer_init,
  780. };
  781. MACHINE_START(AP4EVB, "ap4evb")
  782. .phys_io = 0xe6000000,
  783. .io_pg_offst = ((0xe6000000) >> 18) & 0xfffc,
  784. .map_io = ap4evb_map_io,
  785. .init_irq = sh7372_init_irq,
  786. .init_machine = ap4evb_init,
  787. .timer = &ap4evb_timer,
  788. MACHINE_END