board-ap4evb.c 31 KB

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