board-ap4evb.c 18 KB

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