board-ap4evb.c 30 KB

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