board-ap4evb.c 30 KB

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