board-ap4evb.c 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290
  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/mfd/tmio.h>
  29. #include <linux/mmc/host.h>
  30. #include <linux/mtd/mtd.h>
  31. #include <linux/mtd/partitions.h>
  32. #include <linux/mtd/physmap.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/leds.h>
  43. #include <linux/input/sh_keysc.h>
  44. #include <linux/usb/r8a66597.h>
  45. #include <media/sh_mobile_ceu.h>
  46. #include <media/sh_mobile_csi2.h>
  47. #include <media/soc_camera.h>
  48. #include <sound/sh_fsi.h>
  49. #include <video/sh_mobile_hdmi.h>
  50. #include <video/sh_mobile_lcdc.h>
  51. #include <video/sh_mipi_dsi.h>
  52. #include <mach/common.h>
  53. #include <mach/irqs.h>
  54. #include <mach/sh7372.h>
  55. #include <asm/mach-types.h>
  56. #include <asm/mach/arch.h>
  57. #include <asm/mach/map.h>
  58. #include <asm/mach/time.h>
  59. /*
  60. * Address Interface BusWidth note
  61. * ------------------------------------------------------------------
  62. * 0x0000_0000 NOR Flash ROM (MCP) 16bit SW7 : bit1 = ON
  63. * 0x0800_0000 user area -
  64. * 0x1000_0000 NOR Flash ROM (MCP) 16bit SW7 : bit1 = OFF
  65. * 0x1400_0000 Ether (LAN9220) 16bit
  66. * 0x1600_0000 user area - cannot use with NAND
  67. * 0x1800_0000 user area -
  68. * 0x1A00_0000 -
  69. * 0x4000_0000 LPDDR2-SDRAM (POP) 32bit
  70. */
  71. /*
  72. * NOR Flash ROM
  73. *
  74. * SW1 | SW2 | SW7 | NOR Flash ROM
  75. * bit1 | bit1 bit2 | bit1 | Memory allocation
  76. * ------+------------+------+------------------
  77. * OFF | ON OFF | ON | Area 0
  78. * OFF | ON OFF | OFF | Area 4
  79. */
  80. /*
  81. * NAND Flash ROM
  82. *
  83. * SW1 | SW2 | SW7 | NAND Flash ROM
  84. * bit1 | bit1 bit2 | bit2 | Memory allocation
  85. * ------+------------+------+------------------
  86. * OFF | ON OFF | ON | FCE 0
  87. * OFF | ON OFF | OFF | FCE 1
  88. */
  89. /*
  90. * SMSC 9220
  91. *
  92. * SW1 SMSC 9220
  93. * -----------------------
  94. * ON access disable
  95. * OFF access enable
  96. */
  97. /*
  98. * LCD / IRQ / KEYSC / IrDA
  99. *
  100. * IRQ = IRQ26 (TS), IRQ27 (VIO), IRQ28 (QHD-TouchScreen)
  101. * LCD = 2nd LCDC (WVGA)
  102. *
  103. * | SW43 |
  104. * SW3 | ON | OFF |
  105. * -------------+-----------------------+---------------+
  106. * ON | KEY / IrDA | LCD |
  107. * OFF | KEY / IrDA / IRQ | IRQ |
  108. *
  109. *
  110. * QHD / WVGA display
  111. *
  112. * You can choice display type on menuconfig.
  113. * Then, check above dip-switch.
  114. */
  115. /*
  116. * USB
  117. *
  118. * J7 : 1-2 MAX3355E VBUS
  119. * 2-3 DC 5.0V
  120. *
  121. * S39: bit2: off
  122. */
  123. /*
  124. * FSI/FSMI
  125. *
  126. * SW41 : ON : SH-Mobile AP4 Audio Mode
  127. * : OFF : Bluetooth Audio Mode
  128. */
  129. /*
  130. * MMC0/SDHI1 (CN7)
  131. *
  132. * J22 : select card voltage
  133. * 1-2 pin : 1.8v
  134. * 2-3 pin : 3.3v
  135. *
  136. * SW1 | SW33
  137. * | bit1 | bit2 | bit3 | bit4
  138. * ------------+------+------+------+-------
  139. * MMC0 OFF | OFF | ON | ON | X
  140. * SDHI1 OFF | ON | X | OFF | ON
  141. *
  142. * voltage lebel
  143. * CN7 : 1.8v
  144. * CN12: 3.3v
  145. */
  146. /* MTD */
  147. static struct mtd_partition nor_flash_partitions[] = {
  148. {
  149. .name = "loader",
  150. .offset = 0x00000000,
  151. .size = 512 * 1024,
  152. .mask_flags = MTD_WRITEABLE,
  153. },
  154. {
  155. .name = "bootenv",
  156. .offset = MTDPART_OFS_APPEND,
  157. .size = 512 * 1024,
  158. .mask_flags = MTD_WRITEABLE,
  159. },
  160. {
  161. .name = "kernel_ro",
  162. .offset = MTDPART_OFS_APPEND,
  163. .size = 8 * 1024 * 1024,
  164. .mask_flags = MTD_WRITEABLE,
  165. },
  166. {
  167. .name = "kernel",
  168. .offset = MTDPART_OFS_APPEND,
  169. .size = 8 * 1024 * 1024,
  170. },
  171. {
  172. .name = "data",
  173. .offset = MTDPART_OFS_APPEND,
  174. .size = MTDPART_SIZ_FULL,
  175. },
  176. };
  177. static struct physmap_flash_data nor_flash_data = {
  178. .width = 2,
  179. .parts = nor_flash_partitions,
  180. .nr_parts = ARRAY_SIZE(nor_flash_partitions),
  181. };
  182. static struct resource nor_flash_resources[] = {
  183. [0] = {
  184. .start = 0x00000000,
  185. .end = 0x08000000 - 1,
  186. .flags = IORESOURCE_MEM,
  187. }
  188. };
  189. static struct platform_device nor_flash_device = {
  190. .name = "physmap-flash",
  191. .dev = {
  192. .platform_data = &nor_flash_data,
  193. },
  194. .num_resources = ARRAY_SIZE(nor_flash_resources),
  195. .resource = nor_flash_resources,
  196. };
  197. /* SMSC 9220 */
  198. static struct resource smc911x_resources[] = {
  199. {
  200. .start = 0x14000000,
  201. .end = 0x16000000 - 1,
  202. .flags = IORESOURCE_MEM,
  203. }, {
  204. .start = evt2irq(0x02c0) /* IRQ6A */,
  205. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
  206. },
  207. };
  208. static struct smsc911x_platform_config smsc911x_info = {
  209. .flags = SMSC911X_USE_16BIT | SMSC911X_SAVE_MAC_ADDRESS,
  210. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
  211. .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
  212. };
  213. static struct platform_device smc911x_device = {
  214. .name = "smsc911x",
  215. .id = -1,
  216. .num_resources = ARRAY_SIZE(smc911x_resources),
  217. .resource = smc911x_resources,
  218. .dev = {
  219. .platform_data = &smsc911x_info,
  220. },
  221. };
  222. /*
  223. * The card detect pin of the top SD/MMC slot (CN7) is active low and is
  224. * connected to GPIO A22 of SH7372 (GPIO_PORT41).
  225. */
  226. static int slot_cn7_get_cd(struct platform_device *pdev)
  227. {
  228. if (gpio_is_valid(GPIO_PORT41))
  229. return !gpio_get_value(GPIO_PORT41);
  230. else
  231. return -ENXIO;
  232. }
  233. /* SH_MMCIF */
  234. static struct resource sh_mmcif_resources[] = {
  235. [0] = {
  236. .name = "MMCIF",
  237. .start = 0xE6BD0000,
  238. .end = 0xE6BD00FF,
  239. .flags = IORESOURCE_MEM,
  240. },
  241. [1] = {
  242. /* MMC ERR */
  243. .start = evt2irq(0x1ac0),
  244. .flags = IORESOURCE_IRQ,
  245. },
  246. [2] = {
  247. /* MMC NOR */
  248. .start = evt2irq(0x1ae0),
  249. .flags = IORESOURCE_IRQ,
  250. },
  251. };
  252. static struct sh_mmcif_plat_data sh_mmcif_plat = {
  253. .sup_pclk = 0,
  254. .ocr = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34,
  255. .caps = MMC_CAP_4_BIT_DATA |
  256. MMC_CAP_8_BIT_DATA |
  257. MMC_CAP_NEEDS_POLL,
  258. .get_cd = slot_cn7_get_cd,
  259. };
  260. static struct platform_device sh_mmcif_device = {
  261. .name = "sh_mmcif",
  262. .id = 0,
  263. .dev = {
  264. .dma_mask = NULL,
  265. .coherent_dma_mask = 0xffffffff,
  266. .platform_data = &sh_mmcif_plat,
  267. },
  268. .num_resources = ARRAY_SIZE(sh_mmcif_resources),
  269. .resource = sh_mmcif_resources,
  270. };
  271. /* SDHI0 */
  272. static struct sh_mobile_sdhi_info sdhi0_info = {
  273. .dma_slave_tx = SHDMA_SLAVE_SDHI0_TX,
  274. .dma_slave_rx = SHDMA_SLAVE_SDHI0_RX,
  275. };
  276. static struct resource sdhi0_resources[] = {
  277. [0] = {
  278. .name = "SDHI0",
  279. .start = 0xe6850000,
  280. .end = 0xe68501ff,
  281. .flags = IORESOURCE_MEM,
  282. },
  283. [1] = {
  284. .start = evt2irq(0x0e00) /* SDHI0 */,
  285. .flags = IORESOURCE_IRQ,
  286. },
  287. };
  288. static struct platform_device sdhi0_device = {
  289. .name = "sh_mobile_sdhi",
  290. .num_resources = ARRAY_SIZE(sdhi0_resources),
  291. .resource = sdhi0_resources,
  292. .id = 0,
  293. .dev = {
  294. .platform_data = &sdhi0_info,
  295. },
  296. };
  297. /* SDHI1 */
  298. static struct sh_mobile_sdhi_info sdhi1_info = {
  299. .dma_slave_tx = SHDMA_SLAVE_SDHI1_TX,
  300. .dma_slave_rx = SHDMA_SLAVE_SDHI1_RX,
  301. .tmio_ocr_mask = MMC_VDD_165_195,
  302. .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE,
  303. .tmio_caps = MMC_CAP_NEEDS_POLL,
  304. .get_cd = slot_cn7_get_cd,
  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. static 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. const static struct fb_videomode ap4evb_lcdc_modes[] = {
  363. {
  364. #ifdef CONFIG_AP4EVB_QHD
  365. .name = "R63302(QHD)",
  366. .xres = 544,
  367. .yres = 961,
  368. .left_margin = 72,
  369. .right_margin = 600,
  370. .hsync_len = 16,
  371. .upper_margin = 8,
  372. .lower_margin = 8,
  373. .vsync_len = 2,
  374. .sync = FB_SYNC_VERT_HIGH_ACT | FB_SYNC_HOR_HIGH_ACT,
  375. #else
  376. .name = "WVGA Panel",
  377. .xres = 800,
  378. .yres = 480,
  379. .left_margin = 220,
  380. .right_margin = 110,
  381. .hsync_len = 70,
  382. .upper_margin = 20,
  383. .lower_margin = 5,
  384. .vsync_len = 5,
  385. .sync = 0,
  386. #endif
  387. },
  388. };
  389. static struct sh_mobile_lcdc_info lcdc_info = {
  390. .ch[0] = {
  391. .chan = LCDC_CHAN_MAINLCD,
  392. .bpp = 16,
  393. .lcd_cfg = ap4evb_lcdc_modes,
  394. .num_cfg = ARRAY_SIZE(ap4evb_lcdc_modes),
  395. }
  396. };
  397. static struct resource lcdc_resources[] = {
  398. [0] = {
  399. .name = "LCDC",
  400. .start = 0xfe940000, /* P4-only space */
  401. .end = 0xfe943fff,
  402. .flags = IORESOURCE_MEM,
  403. },
  404. [1] = {
  405. .start = intcs_evt2irq(0x580),
  406. .flags = IORESOURCE_IRQ,
  407. },
  408. };
  409. static struct platform_device lcdc_device = {
  410. .name = "sh_mobile_lcdc_fb",
  411. .num_resources = ARRAY_SIZE(lcdc_resources),
  412. .resource = lcdc_resources,
  413. .dev = {
  414. .platform_data = &lcdc_info,
  415. .coherent_dma_mask = ~0,
  416. },
  417. };
  418. /*
  419. * QHD display
  420. */
  421. #ifdef CONFIG_AP4EVB_QHD
  422. /* KEYSC (Needs SW43 set to ON) */
  423. static struct sh_keysc_info keysc_info = {
  424. .mode = SH_KEYSC_MODE_1,
  425. .scan_timing = 3,
  426. .delay = 2500,
  427. .keycodes = {
  428. KEY_0, KEY_1, KEY_2, KEY_3, KEY_4,
  429. KEY_5, KEY_6, KEY_7, KEY_8, KEY_9,
  430. KEY_A, KEY_B, KEY_C, KEY_D, KEY_E,
  431. KEY_F, KEY_G, KEY_H, KEY_I, KEY_J,
  432. KEY_K, KEY_L, KEY_M, KEY_N, KEY_O,
  433. },
  434. };
  435. static struct resource keysc_resources[] = {
  436. [0] = {
  437. .name = "KEYSC",
  438. .start = 0xe61b0000,
  439. .end = 0xe61b0063,
  440. .flags = IORESOURCE_MEM,
  441. },
  442. [1] = {
  443. .start = evt2irq(0x0be0), /* KEYSC_KEY */
  444. .flags = IORESOURCE_IRQ,
  445. },
  446. };
  447. static struct platform_device keysc_device = {
  448. .name = "sh_keysc",
  449. .id = 0, /* "keysc0" clock */
  450. .num_resources = ARRAY_SIZE(keysc_resources),
  451. .resource = keysc_resources,
  452. .dev = {
  453. .platform_data = &keysc_info,
  454. },
  455. };
  456. /* MIPI-DSI */
  457. static struct resource mipidsi0_resources[] = {
  458. [0] = {
  459. .start = 0xffc60000,
  460. .end = 0xffc63073,
  461. .flags = IORESOURCE_MEM,
  462. },
  463. [1] = {
  464. .start = 0xffc68000,
  465. .end = 0xffc680ef,
  466. .flags = IORESOURCE_MEM,
  467. },
  468. };
  469. static struct sh_mipi_dsi_info mipidsi0_info = {
  470. .data_format = MIPI_RGB888,
  471. .lcd_chan = &lcdc_info.ch[0],
  472. };
  473. static struct platform_device mipidsi0_device = {
  474. .name = "sh-mipi-dsi",
  475. .num_resources = ARRAY_SIZE(mipidsi0_resources),
  476. .resource = mipidsi0_resources,
  477. .id = 0,
  478. .dev = {
  479. .platform_data = &mipidsi0_info,
  480. },
  481. };
  482. /* This function will disappear when we switch to (runtime) PM */
  483. static int __init ap4evb_init_display_clk(void)
  484. {
  485. struct clk *lcdc_clk;
  486. struct clk *dsitx_clk;
  487. int ret;
  488. lcdc_clk = clk_get(&lcdc_device.dev, "sh_mobile_lcdc_fb.0");
  489. if (IS_ERR(lcdc_clk))
  490. return PTR_ERR(lcdc_clk);
  491. dsitx_clk = clk_get(&mipidsi0_device.dev, "sh-mipi-dsi.0");
  492. if (IS_ERR(dsitx_clk)) {
  493. ret = PTR_ERR(dsitx_clk);
  494. goto eclkdsitxget;
  495. }
  496. ret = clk_enable(lcdc_clk);
  497. if (ret < 0)
  498. goto eclklcdcon;
  499. ret = clk_enable(dsitx_clk);
  500. if (ret < 0)
  501. goto eclkdsitxon;
  502. return 0;
  503. eclkdsitxon:
  504. clk_disable(lcdc_clk);
  505. eclklcdcon:
  506. clk_put(dsitx_clk);
  507. eclkdsitxget:
  508. clk_put(lcdc_clk);
  509. return ret;
  510. }
  511. device_initcall(ap4evb_init_display_clk);
  512. static struct platform_device *qhd_devices[] __initdata = {
  513. &mipidsi0_device,
  514. &keysc_device,
  515. };
  516. #endif /* CONFIG_AP4EVB_QHD */
  517. /* FSI */
  518. #define IRQ_FSI evt2irq(0x1840)
  519. static int fsi_set_rate(int is_porta, int rate)
  520. {
  521. struct clk *fsib_clk;
  522. struct clk *fdiv_clk = &sh7372_fsidivb_clk;
  523. int ret;
  524. /* set_rate is not needed if port A */
  525. if (is_porta)
  526. return 0;
  527. fsib_clk = clk_get(NULL, "fsib_clk");
  528. if (IS_ERR(fsib_clk))
  529. return -EINVAL;
  530. switch (rate) {
  531. case 44100:
  532. clk_set_rate(fsib_clk, clk_round_rate(fsib_clk, 11283000));
  533. ret = SH_FSI_ACKMD_256 | SH_FSI_BPFMD_64;
  534. break;
  535. case 48000:
  536. clk_set_rate(fsib_clk, clk_round_rate(fsib_clk, 85428000));
  537. clk_set_rate(fdiv_clk, clk_round_rate(fdiv_clk, 12204000));
  538. ret = SH_FSI_ACKMD_256 | SH_FSI_BPFMD_64;
  539. break;
  540. default:
  541. pr_err("unsupported rate in FSI2 port B\n");
  542. ret = -EINVAL;
  543. break;
  544. }
  545. clk_put(fsib_clk);
  546. return ret;
  547. }
  548. static struct sh_fsi_platform_info fsi_info = {
  549. .porta_flags = SH_FSI_BRS_INV |
  550. SH_FSI_OUT_SLAVE_MODE |
  551. SH_FSI_IN_SLAVE_MODE |
  552. SH_FSI_OFMT(PCM) |
  553. SH_FSI_IFMT(PCM),
  554. .portb_flags = SH_FSI_BRS_INV |
  555. SH_FSI_BRM_INV |
  556. SH_FSI_LRS_INV |
  557. SH_FSI_OFMT(SPDIF),
  558. .set_rate = fsi_set_rate,
  559. };
  560. static struct resource fsi_resources[] = {
  561. [0] = {
  562. .name = "FSI",
  563. .start = 0xFE3C0000,
  564. .end = 0xFE3C0400 - 1,
  565. .flags = IORESOURCE_MEM,
  566. },
  567. [1] = {
  568. .start = IRQ_FSI,
  569. .flags = IORESOURCE_IRQ,
  570. },
  571. };
  572. static struct platform_device fsi_device = {
  573. .name = "sh_fsi2",
  574. .id = -1,
  575. .num_resources = ARRAY_SIZE(fsi_resources),
  576. .resource = fsi_resources,
  577. .dev = {
  578. .platform_data = &fsi_info,
  579. },
  580. };
  581. static struct sh_mobile_lcdc_info sh_mobile_lcdc1_info = {
  582. .clock_source = LCDC_CLK_EXTERNAL,
  583. .ch[0] = {
  584. .chan = LCDC_CHAN_MAINLCD,
  585. .bpp = 16,
  586. .interface_type = RGB24,
  587. .clock_divider = 1,
  588. .flags = LCDC_FLAGS_DWPOL,
  589. }
  590. };
  591. static struct resource lcdc1_resources[] = {
  592. [0] = {
  593. .name = "LCDC1",
  594. .start = 0xfe944000,
  595. .end = 0xfe947fff,
  596. .flags = IORESOURCE_MEM,
  597. },
  598. [1] = {
  599. .start = intcs_evt2irq(0x1780),
  600. .flags = IORESOURCE_IRQ,
  601. },
  602. };
  603. static struct platform_device lcdc1_device = {
  604. .name = "sh_mobile_lcdc_fb",
  605. .num_resources = ARRAY_SIZE(lcdc1_resources),
  606. .resource = lcdc1_resources,
  607. .id = 1,
  608. .dev = {
  609. .platform_data = &sh_mobile_lcdc1_info,
  610. .coherent_dma_mask = ~0,
  611. },
  612. };
  613. static struct sh_mobile_hdmi_info hdmi_info = {
  614. .lcd_chan = &sh_mobile_lcdc1_info.ch[0],
  615. .lcd_dev = &lcdc1_device.dev,
  616. .flags = HDMI_SND_SRC_SPDIF,
  617. };
  618. static struct resource hdmi_resources[] = {
  619. [0] = {
  620. .name = "HDMI",
  621. .start = 0xe6be0000,
  622. .end = 0xe6be00ff,
  623. .flags = IORESOURCE_MEM,
  624. },
  625. [1] = {
  626. /* There's also an HDMI interrupt on INTCS @ 0x18e0 */
  627. .start = evt2irq(0x17e0),
  628. .flags = IORESOURCE_IRQ,
  629. },
  630. };
  631. static struct platform_device hdmi_device = {
  632. .name = "sh-mobile-hdmi",
  633. .num_resources = ARRAY_SIZE(hdmi_resources),
  634. .resource = hdmi_resources,
  635. .id = -1,
  636. .dev = {
  637. .platform_data = &hdmi_info,
  638. },
  639. };
  640. static struct gpio_led ap4evb_leds[] = {
  641. {
  642. .name = "led4",
  643. .gpio = GPIO_PORT185,
  644. .default_state = LEDS_GPIO_DEFSTATE_ON,
  645. },
  646. {
  647. .name = "led2",
  648. .gpio = GPIO_PORT186,
  649. .default_state = LEDS_GPIO_DEFSTATE_ON,
  650. },
  651. {
  652. .name = "led3",
  653. .gpio = GPIO_PORT187,
  654. .default_state = LEDS_GPIO_DEFSTATE_ON,
  655. },
  656. {
  657. .name = "led1",
  658. .gpio = GPIO_PORT188,
  659. .default_state = LEDS_GPIO_DEFSTATE_ON,
  660. }
  661. };
  662. static struct gpio_led_platform_data ap4evb_leds_pdata = {
  663. .num_leds = ARRAY_SIZE(ap4evb_leds),
  664. .leds = ap4evb_leds,
  665. };
  666. static struct platform_device leds_device = {
  667. .name = "leds-gpio",
  668. .id = 0,
  669. .dev = {
  670. .platform_data = &ap4evb_leds_pdata,
  671. },
  672. };
  673. static struct i2c_board_info imx074_info = {
  674. I2C_BOARD_INFO("imx074", 0x1a),
  675. };
  676. struct soc_camera_link imx074_link = {
  677. .bus_id = 0,
  678. .board_info = &imx074_info,
  679. .i2c_adapter_id = 0,
  680. .module_name = "imx074",
  681. };
  682. static struct platform_device ap4evb_camera = {
  683. .name = "soc-camera-pdrv",
  684. .id = 0,
  685. .dev = {
  686. .platform_data = &imx074_link,
  687. },
  688. };
  689. static struct sh_csi2_client_config csi2_clients[] = {
  690. {
  691. .phy = SH_CSI2_PHY_MAIN,
  692. .lanes = 3,
  693. .channel = 0,
  694. .pdev = &ap4evb_camera,
  695. },
  696. };
  697. static struct sh_csi2_pdata csi2_info = {
  698. .type = SH_CSI2C,
  699. .clients = csi2_clients,
  700. .num_clients = ARRAY_SIZE(csi2_clients),
  701. .flags = SH_CSI2_ECC | SH_CSI2_CRC,
  702. };
  703. static struct resource csi2_resources[] = {
  704. [0] = {
  705. .name = "CSI2",
  706. .start = 0xffc90000,
  707. .end = 0xffc90fff,
  708. .flags = IORESOURCE_MEM,
  709. },
  710. [1] = {
  711. .start = intcs_evt2irq(0x17a0),
  712. .flags = IORESOURCE_IRQ,
  713. },
  714. };
  715. static struct platform_device csi2_device = {
  716. .name = "sh-mobile-csi2",
  717. .id = 0,
  718. .num_resources = ARRAY_SIZE(csi2_resources),
  719. .resource = csi2_resources,
  720. .dev = {
  721. .platform_data = &csi2_info,
  722. },
  723. };
  724. static struct sh_mobile_ceu_info sh_mobile_ceu_info = {
  725. .flags = SH_CEU_FLAG_USE_8BIT_BUS,
  726. .csi2_dev = &csi2_device.dev,
  727. };
  728. static struct resource ceu_resources[] = {
  729. [0] = {
  730. .name = "CEU",
  731. .start = 0xfe910000,
  732. .end = 0xfe91009f,
  733. .flags = IORESOURCE_MEM,
  734. },
  735. [1] = {
  736. .start = intcs_evt2irq(0x880),
  737. .flags = IORESOURCE_IRQ,
  738. },
  739. [2] = {
  740. /* place holder for contiguous memory */
  741. },
  742. };
  743. static struct platform_device ceu_device = {
  744. .name = "sh_mobile_ceu",
  745. .id = 0, /* "ceu0" clock */
  746. .num_resources = ARRAY_SIZE(ceu_resources),
  747. .resource = ceu_resources,
  748. .dev = {
  749. .platform_data = &sh_mobile_ceu_info,
  750. },
  751. };
  752. static struct platform_device *ap4evb_devices[] __initdata = {
  753. &leds_device,
  754. &nor_flash_device,
  755. &smc911x_device,
  756. &sdhi0_device,
  757. &sdhi1_device,
  758. &usb1_host_device,
  759. &fsi_device,
  760. &sh_mmcif_device,
  761. &lcdc1_device,
  762. &lcdc_device,
  763. &hdmi_device,
  764. &csi2_device,
  765. &ceu_device,
  766. &ap4evb_camera,
  767. };
  768. static int __init hdmi_init_pm_clock(void)
  769. {
  770. struct clk *hdmi_ick = clk_get(&hdmi_device.dev, "ick");
  771. int ret;
  772. long rate;
  773. if (IS_ERR(hdmi_ick)) {
  774. ret = PTR_ERR(hdmi_ick);
  775. pr_err("Cannot get HDMI ICK: %d\n", ret);
  776. goto out;
  777. }
  778. ret = clk_set_parent(&sh7372_pllc2_clk, &sh7372_dv_clki_div2_clk);
  779. if (ret < 0) {
  780. pr_err("Cannot set PLLC2 parent: %d, %d users\n", ret, sh7372_pllc2_clk.usecount);
  781. goto out;
  782. }
  783. pr_debug("PLLC2 initial frequency %lu\n", clk_get_rate(&sh7372_pllc2_clk));
  784. rate = clk_round_rate(&sh7372_pllc2_clk, 594000000);
  785. if (rate < 0) {
  786. pr_err("Cannot get suitable rate: %ld\n", rate);
  787. ret = rate;
  788. goto out;
  789. }
  790. ret = clk_set_rate(&sh7372_pllc2_clk, rate);
  791. if (ret < 0) {
  792. pr_err("Cannot set rate %ld: %d\n", rate, ret);
  793. goto out;
  794. }
  795. pr_debug("PLLC2 set frequency %lu\n", rate);
  796. ret = clk_set_parent(hdmi_ick, &sh7372_pllc2_clk);
  797. if (ret < 0) {
  798. pr_err("Cannot set HDMI parent: %d\n", ret);
  799. goto out;
  800. }
  801. out:
  802. if (!IS_ERR(hdmi_ick))
  803. clk_put(hdmi_ick);
  804. return ret;
  805. }
  806. device_initcall(hdmi_init_pm_clock);
  807. #define FSIACK_DUMMY_RATE 48000
  808. static int __init fsi_init_pm_clock(void)
  809. {
  810. struct clk *fsia_ick;
  811. int ret;
  812. /*
  813. * FSIACK is connected to AK4642,
  814. * and the rate is depend on playing sound rate.
  815. * So, set dummy rate (= 48k) here
  816. */
  817. ret = clk_set_rate(&sh7372_fsiack_clk, FSIACK_DUMMY_RATE);
  818. if (ret < 0) {
  819. pr_err("Cannot set FSIACK dummy rate: %d\n", ret);
  820. return ret;
  821. }
  822. fsia_ick = clk_get(&fsi_device.dev, "icka");
  823. if (IS_ERR(fsia_ick)) {
  824. ret = PTR_ERR(fsia_ick);
  825. pr_err("Cannot get FSI ICK: %d\n", ret);
  826. return ret;
  827. }
  828. ret = clk_set_parent(fsia_ick, &sh7372_fsiack_clk);
  829. if (ret < 0) {
  830. pr_err("Cannot set FSI-A parent: %d\n", ret);
  831. goto out;
  832. }
  833. ret = clk_set_rate(fsia_ick, FSIACK_DUMMY_RATE);
  834. if (ret < 0)
  835. pr_err("Cannot set FSI-A rate: %d\n", ret);
  836. out:
  837. clk_put(fsia_ick);
  838. return ret;
  839. }
  840. device_initcall(fsi_init_pm_clock);
  841. /*
  842. * FIXME !!
  843. *
  844. * gpio_no_direction
  845. * are quick_hack.
  846. *
  847. * current gpio frame work doesn't have
  848. * the method to control only pull up/down/free.
  849. * this function should be replaced by correct gpio function
  850. */
  851. static void __init gpio_no_direction(u32 addr)
  852. {
  853. __raw_writeb(0x00, addr);
  854. }
  855. /* TouchScreen */
  856. #ifdef CONFIG_AP4EVB_QHD
  857. # define GPIO_TSC_IRQ GPIO_FN_IRQ28_123
  858. # define GPIO_TSC_PORT GPIO_PORT123
  859. #else /* WVGA */
  860. # define GPIO_TSC_IRQ GPIO_FN_IRQ7_40
  861. # define GPIO_TSC_PORT GPIO_PORT40
  862. #endif
  863. #define IRQ28 evt2irq(0x3380) /* IRQ28A */
  864. #define IRQ7 evt2irq(0x02e0) /* IRQ7A */
  865. static int ts_get_pendown_state(void)
  866. {
  867. int val;
  868. gpio_free(GPIO_TSC_IRQ);
  869. gpio_request(GPIO_TSC_PORT, NULL);
  870. gpio_direction_input(GPIO_TSC_PORT);
  871. val = gpio_get_value(GPIO_TSC_PORT);
  872. gpio_request(GPIO_TSC_IRQ, NULL);
  873. return !val;
  874. }
  875. static int ts_init(void)
  876. {
  877. gpio_request(GPIO_TSC_IRQ, NULL);
  878. return 0;
  879. }
  880. static struct tsc2007_platform_data tsc2007_info = {
  881. .model = 2007,
  882. .x_plate_ohms = 180,
  883. .get_pendown_state = ts_get_pendown_state,
  884. .init_platform_hw = ts_init,
  885. };
  886. static struct i2c_board_info tsc_device = {
  887. I2C_BOARD_INFO("tsc2007", 0x48),
  888. .type = "tsc2007",
  889. .platform_data = &tsc2007_info,
  890. /*.irq is selected on ap4evb_init */
  891. };
  892. /* I2C */
  893. static struct i2c_board_info i2c0_devices[] = {
  894. {
  895. I2C_BOARD_INFO("ak4643", 0x13),
  896. },
  897. };
  898. static struct i2c_board_info i2c1_devices[] = {
  899. {
  900. I2C_BOARD_INFO("r2025sd", 0x32),
  901. },
  902. };
  903. static struct map_desc ap4evb_io_desc[] __initdata = {
  904. /* create a 1:1 entity map for 0xe6xxxxxx
  905. * used by CPGA, INTC and PFC.
  906. */
  907. {
  908. .virtual = 0xe6000000,
  909. .pfn = __phys_to_pfn(0xe6000000),
  910. .length = 256 << 20,
  911. .type = MT_DEVICE_NONSHARED
  912. },
  913. };
  914. static void __init ap4evb_map_io(void)
  915. {
  916. iotable_init(ap4evb_io_desc, ARRAY_SIZE(ap4evb_io_desc));
  917. /* setup early devices and console here as well */
  918. sh7372_add_early_devices();
  919. shmobile_setup_console();
  920. }
  921. #define GPIO_PORT9CR 0xE6051009
  922. #define GPIO_PORT10CR 0xE605100A
  923. #define USCCR1 0xE6058144
  924. static void __init ap4evb_init(void)
  925. {
  926. u32 srcr4;
  927. struct clk *clk;
  928. sh7372_pinmux_init();
  929. /* enable SCIFA0 */
  930. gpio_request(GPIO_FN_SCIFA0_TXD, NULL);
  931. gpio_request(GPIO_FN_SCIFA0_RXD, NULL);
  932. /* enable SMSC911X */
  933. gpio_request(GPIO_FN_CS5A, NULL);
  934. gpio_request(GPIO_FN_IRQ6_39, NULL);
  935. /* enable Debug switch (S6) */
  936. gpio_request(GPIO_PORT32, NULL);
  937. gpio_request(GPIO_PORT33, NULL);
  938. gpio_request(GPIO_PORT34, NULL);
  939. gpio_request(GPIO_PORT35, NULL);
  940. gpio_direction_input(GPIO_PORT32);
  941. gpio_direction_input(GPIO_PORT33);
  942. gpio_direction_input(GPIO_PORT34);
  943. gpio_direction_input(GPIO_PORT35);
  944. gpio_export(GPIO_PORT32, 0);
  945. gpio_export(GPIO_PORT33, 0);
  946. gpio_export(GPIO_PORT34, 0);
  947. gpio_export(GPIO_PORT35, 0);
  948. /* SDHI0 */
  949. gpio_request(GPIO_FN_SDHICD0, NULL);
  950. gpio_request(GPIO_FN_SDHIWP0, NULL);
  951. gpio_request(GPIO_FN_SDHICMD0, NULL);
  952. gpio_request(GPIO_FN_SDHICLK0, NULL);
  953. gpio_request(GPIO_FN_SDHID0_3, NULL);
  954. gpio_request(GPIO_FN_SDHID0_2, NULL);
  955. gpio_request(GPIO_FN_SDHID0_1, NULL);
  956. gpio_request(GPIO_FN_SDHID0_0, NULL);
  957. /* SDHI1 */
  958. gpio_request(GPIO_FN_SDHICMD1, NULL);
  959. gpio_request(GPIO_FN_SDHICLK1, NULL);
  960. gpio_request(GPIO_FN_SDHID1_3, NULL);
  961. gpio_request(GPIO_FN_SDHID1_2, NULL);
  962. gpio_request(GPIO_FN_SDHID1_1, NULL);
  963. gpio_request(GPIO_FN_SDHID1_0, NULL);
  964. /* MMCIF */
  965. gpio_request(GPIO_FN_MMCD0_0, NULL);
  966. gpio_request(GPIO_FN_MMCD0_1, NULL);
  967. gpio_request(GPIO_FN_MMCD0_2, NULL);
  968. gpio_request(GPIO_FN_MMCD0_3, NULL);
  969. gpio_request(GPIO_FN_MMCD0_4, NULL);
  970. gpio_request(GPIO_FN_MMCD0_5, NULL);
  971. gpio_request(GPIO_FN_MMCD0_6, NULL);
  972. gpio_request(GPIO_FN_MMCD0_7, NULL);
  973. gpio_request(GPIO_FN_MMCCMD0, NULL);
  974. gpio_request(GPIO_FN_MMCCLK0, NULL);
  975. /* USB enable */
  976. gpio_request(GPIO_FN_VBUS0_1, NULL);
  977. gpio_request(GPIO_FN_IDIN_1_18, NULL);
  978. gpio_request(GPIO_FN_PWEN_1_115, NULL);
  979. gpio_request(GPIO_FN_OVCN_1_114, NULL);
  980. gpio_request(GPIO_FN_EXTLP_1, NULL);
  981. gpio_request(GPIO_FN_OVCN2_1, NULL);
  982. /* setup USB phy */
  983. __raw_writew(0x8a0a, 0xE6058130); /* USBCR2 */
  984. /* enable FSI2 port A (ak4643) */
  985. gpio_request(GPIO_FN_FSIAIBT, NULL);
  986. gpio_request(GPIO_FN_FSIAILR, NULL);
  987. gpio_request(GPIO_FN_FSIAISLD, NULL);
  988. gpio_request(GPIO_FN_FSIAOSLD, NULL);
  989. gpio_request(GPIO_PORT161, NULL);
  990. gpio_direction_output(GPIO_PORT161, 0); /* slave */
  991. gpio_request(GPIO_PORT9, NULL);
  992. gpio_request(GPIO_PORT10, NULL);
  993. gpio_no_direction(GPIO_PORT9CR); /* FSIAOBT needs no direction */
  994. gpio_no_direction(GPIO_PORT10CR); /* FSIAOLR needs no direction */
  995. /* card detect pin for MMC slot (CN7) */
  996. gpio_request(GPIO_PORT41, NULL);
  997. gpio_direction_input(GPIO_PORT41);
  998. /* setup FSI2 port B (HDMI) */
  999. gpio_request(GPIO_FN_FSIBCK, NULL);
  1000. __raw_writew(__raw_readw(USCCR1) & ~(1 << 6), USCCR1); /* use SPDIF */
  1001. /* set SPU2 clock to 119.6 MHz */
  1002. clk = clk_get(NULL, "spu_clk");
  1003. if (!IS_ERR(clk)) {
  1004. clk_set_rate(clk, clk_round_rate(clk, 119600000));
  1005. clk_put(clk);
  1006. }
  1007. /*
  1008. * set irq priority, to avoid sound chopping
  1009. * when NFS rootfs is used
  1010. * FSI(3) > SMSC911X(2)
  1011. */
  1012. intc_set_priority(IRQ_FSI, 3);
  1013. i2c_register_board_info(0, i2c0_devices,
  1014. ARRAY_SIZE(i2c0_devices));
  1015. i2c_register_board_info(1, i2c1_devices,
  1016. ARRAY_SIZE(i2c1_devices));
  1017. #ifdef CONFIG_AP4EVB_QHD
  1018. /*
  1019. * For QHD Panel (MIPI-DSI, CONFIG_AP4EVB_QHD=y) and
  1020. * IRQ28 for Touch Panel, set dip switches S3, S43 as OFF, ON.
  1021. */
  1022. /* enable KEYSC */
  1023. gpio_request(GPIO_FN_KEYOUT0, NULL);
  1024. gpio_request(GPIO_FN_KEYOUT1, NULL);
  1025. gpio_request(GPIO_FN_KEYOUT2, NULL);
  1026. gpio_request(GPIO_FN_KEYOUT3, NULL);
  1027. gpio_request(GPIO_FN_KEYOUT4, NULL);
  1028. gpio_request(GPIO_FN_KEYIN0_136, NULL);
  1029. gpio_request(GPIO_FN_KEYIN1_135, NULL);
  1030. gpio_request(GPIO_FN_KEYIN2_134, NULL);
  1031. gpio_request(GPIO_FN_KEYIN3_133, NULL);
  1032. gpio_request(GPIO_FN_KEYIN4, NULL);
  1033. /* enable TouchScreen */
  1034. set_irq_type(IRQ28, IRQ_TYPE_LEVEL_LOW);
  1035. tsc_device.irq = IRQ28;
  1036. i2c_register_board_info(1, &tsc_device, 1);
  1037. /* LCDC0 */
  1038. lcdc_info.clock_source = LCDC_CLK_PERIPHERAL;
  1039. lcdc_info.ch[0].interface_type = RGB24;
  1040. lcdc_info.ch[0].clock_divider = 1;
  1041. lcdc_info.ch[0].flags = LCDC_FLAGS_DWPOL;
  1042. lcdc_info.ch[0].lcd_size_cfg.width = 44;
  1043. lcdc_info.ch[0].lcd_size_cfg.height = 79;
  1044. platform_add_devices(qhd_devices, ARRAY_SIZE(qhd_devices));
  1045. #else
  1046. /*
  1047. * For WVGA Panel (18-bit RGB, CONFIG_AP4EVB_WVGA=y) and
  1048. * IRQ7 for Touch Panel, set dip switches S3, S43 to ON, OFF.
  1049. */
  1050. gpio_request(GPIO_FN_LCDD17, NULL);
  1051. gpio_request(GPIO_FN_LCDD16, NULL);
  1052. gpio_request(GPIO_FN_LCDD15, NULL);
  1053. gpio_request(GPIO_FN_LCDD14, NULL);
  1054. gpio_request(GPIO_FN_LCDD13, NULL);
  1055. gpio_request(GPIO_FN_LCDD12, NULL);
  1056. gpio_request(GPIO_FN_LCDD11, NULL);
  1057. gpio_request(GPIO_FN_LCDD10, NULL);
  1058. gpio_request(GPIO_FN_LCDD9, NULL);
  1059. gpio_request(GPIO_FN_LCDD8, NULL);
  1060. gpio_request(GPIO_FN_LCDD7, NULL);
  1061. gpio_request(GPIO_FN_LCDD6, NULL);
  1062. gpio_request(GPIO_FN_LCDD5, NULL);
  1063. gpio_request(GPIO_FN_LCDD4, NULL);
  1064. gpio_request(GPIO_FN_LCDD3, NULL);
  1065. gpio_request(GPIO_FN_LCDD2, NULL);
  1066. gpio_request(GPIO_FN_LCDD1, NULL);
  1067. gpio_request(GPIO_FN_LCDD0, NULL);
  1068. gpio_request(GPIO_FN_LCDDISP, NULL);
  1069. gpio_request(GPIO_FN_LCDDCK, NULL);
  1070. gpio_request(GPIO_PORT189, NULL); /* backlight */
  1071. gpio_direction_output(GPIO_PORT189, 1);
  1072. gpio_request(GPIO_PORT151, NULL); /* LCDDON */
  1073. gpio_direction_output(GPIO_PORT151, 1);
  1074. lcdc_info.clock_source = LCDC_CLK_BUS;
  1075. lcdc_info.ch[0].interface_type = RGB18;
  1076. lcdc_info.ch[0].clock_divider = 2;
  1077. lcdc_info.ch[0].flags = 0;
  1078. lcdc_info.ch[0].lcd_size_cfg.width = 152;
  1079. lcdc_info.ch[0].lcd_size_cfg.height = 91;
  1080. /* enable TouchScreen */
  1081. set_irq_type(IRQ7, IRQ_TYPE_LEVEL_LOW);
  1082. tsc_device.irq = IRQ7;
  1083. i2c_register_board_info(0, &tsc_device, 1);
  1084. #endif /* CONFIG_AP4EVB_QHD */
  1085. /* CEU */
  1086. /*
  1087. * TODO: reserve memory for V4L2 DMA buffers, when a suitable API
  1088. * becomes available
  1089. */
  1090. /* MIPI-CSI stuff */
  1091. gpio_request(GPIO_FN_VIO_CKO, NULL);
  1092. clk = clk_get(NULL, "vck1_clk");
  1093. if (!IS_ERR(clk)) {
  1094. clk_set_rate(clk, clk_round_rate(clk, 13000000));
  1095. clk_enable(clk);
  1096. clk_put(clk);
  1097. }
  1098. sh7372_add_standard_devices();
  1099. /* HDMI */
  1100. gpio_request(GPIO_FN_HDMI_HPD, NULL);
  1101. gpio_request(GPIO_FN_HDMI_CEC, NULL);
  1102. /* Reset HDMI, must be held at least one EXTALR (32768Hz) period */
  1103. #define SRCR4 0xe61580bc
  1104. srcr4 = __raw_readl(SRCR4);
  1105. __raw_writel(srcr4 | (1 << 13), SRCR4);
  1106. udelay(50);
  1107. __raw_writel(srcr4 & ~(1 << 13), SRCR4);
  1108. platform_add_devices(ap4evb_devices, ARRAY_SIZE(ap4evb_devices));
  1109. }
  1110. static void __init ap4evb_timer_init(void)
  1111. {
  1112. sh7372_clock_init();
  1113. shmobile_timer.init();
  1114. /* External clock source */
  1115. clk_set_rate(&sh7372_dv_clki_clk, 27000000);
  1116. }
  1117. static struct sys_timer ap4evb_timer = {
  1118. .init = ap4evb_timer_init,
  1119. };
  1120. MACHINE_START(AP4EVB, "ap4evb")
  1121. .map_io = ap4evb_map_io,
  1122. .init_irq = sh7372_init_irq,
  1123. .init_machine = ap4evb_init,
  1124. .timer = &ap4evb_timer,
  1125. MACHINE_END