board-ap4evb.c 18 KB

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