board-ap4evb.c 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337
  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. * it needs amixer settings for playing
  135. *
  136. * amixer set "Headphone Enable" on
  137. */
  138. /*
  139. * MMC0/SDHI1 (CN7)
  140. *
  141. * J22 : select card voltage
  142. * 1-2 pin : 1.8v
  143. * 2-3 pin : 3.3v
  144. *
  145. * SW1 | SW33
  146. * | bit1 | bit2 | bit3 | bit4
  147. * ------------+------+------+------+-------
  148. * MMC0 OFF | OFF | ON | ON | X
  149. * SDHI1 OFF | ON | X | OFF | ON
  150. *
  151. * voltage lebel
  152. * CN7 : 1.8v
  153. * CN12: 3.3v
  154. */
  155. /* Dummy supplies, where voltage doesn't matter */
  156. static struct regulator_consumer_supply fixed1v8_power_consumers[] =
  157. {
  158. /* J22 default position: 1.8V */
  159. REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.1"),
  160. REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.1"),
  161. REGULATOR_SUPPLY("vmmc", "sh_mmcif.0"),
  162. REGULATOR_SUPPLY("vqmmc", "sh_mmcif.0"),
  163. };
  164. static struct regulator_consumer_supply fixed3v3_power_consumers[] =
  165. {
  166. REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.0"),
  167. REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.0"),
  168. };
  169. static struct regulator_consumer_supply dummy_supplies[] = {
  170. REGULATOR_SUPPLY("vddvario", "smsc911x"),
  171. REGULATOR_SUPPLY("vdd33a", "smsc911x"),
  172. };
  173. /* MTD */
  174. static struct mtd_partition nor_flash_partitions[] = {
  175. {
  176. .name = "loader",
  177. .offset = 0x00000000,
  178. .size = 512 * 1024,
  179. .mask_flags = MTD_WRITEABLE,
  180. },
  181. {
  182. .name = "bootenv",
  183. .offset = MTDPART_OFS_APPEND,
  184. .size = 512 * 1024,
  185. .mask_flags = MTD_WRITEABLE,
  186. },
  187. {
  188. .name = "kernel_ro",
  189. .offset = MTDPART_OFS_APPEND,
  190. .size = 8 * 1024 * 1024,
  191. .mask_flags = MTD_WRITEABLE,
  192. },
  193. {
  194. .name = "kernel",
  195. .offset = MTDPART_OFS_APPEND,
  196. .size = 8 * 1024 * 1024,
  197. },
  198. {
  199. .name = "data",
  200. .offset = MTDPART_OFS_APPEND,
  201. .size = MTDPART_SIZ_FULL,
  202. },
  203. };
  204. static struct physmap_flash_data nor_flash_data = {
  205. .width = 2,
  206. .parts = nor_flash_partitions,
  207. .nr_parts = ARRAY_SIZE(nor_flash_partitions),
  208. };
  209. static struct resource nor_flash_resources[] = {
  210. [0] = {
  211. .start = 0x20000000, /* CS0 shadow instead of regular CS0 */
  212. .end = 0x28000000 - 1, /* needed by USB MASK ROM boot */
  213. .flags = IORESOURCE_MEM,
  214. }
  215. };
  216. static struct platform_device nor_flash_device = {
  217. .name = "physmap-flash",
  218. .dev = {
  219. .platform_data = &nor_flash_data,
  220. },
  221. .num_resources = ARRAY_SIZE(nor_flash_resources),
  222. .resource = nor_flash_resources,
  223. };
  224. /* SMSC 9220 */
  225. static struct resource smc911x_resources[] = {
  226. {
  227. .start = 0x14000000,
  228. .end = 0x16000000 - 1,
  229. .flags = IORESOURCE_MEM,
  230. }, {
  231. .start = evt2irq(0x02c0) /* IRQ6A */,
  232. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
  233. },
  234. };
  235. static struct smsc911x_platform_config smsc911x_info = {
  236. .flags = SMSC911X_USE_16BIT | SMSC911X_SAVE_MAC_ADDRESS,
  237. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
  238. .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
  239. };
  240. static struct platform_device smc911x_device = {
  241. .name = "smsc911x",
  242. .id = -1,
  243. .num_resources = ARRAY_SIZE(smc911x_resources),
  244. .resource = smc911x_resources,
  245. .dev = {
  246. .platform_data = &smsc911x_info,
  247. },
  248. };
  249. /*
  250. * The card detect pin of the top SD/MMC slot (CN7) is active low and is
  251. * connected to GPIO A22 of SH7372 (GPIO_PORT41).
  252. */
  253. static int slot_cn7_get_cd(struct platform_device *pdev)
  254. {
  255. return !gpio_get_value(GPIO_PORT41);
  256. }
  257. /* MERAM */
  258. static struct sh_mobile_meram_info meram_info = {
  259. .addr_mode = SH_MOBILE_MERAM_MODE1,
  260. };
  261. static struct resource meram_resources[] = {
  262. [0] = {
  263. .name = "regs",
  264. .start = 0xe8000000,
  265. .end = 0xe807ffff,
  266. .flags = IORESOURCE_MEM,
  267. },
  268. [1] = {
  269. .name = "meram",
  270. .start = 0xe8080000,
  271. .end = 0xe81fffff,
  272. .flags = IORESOURCE_MEM,
  273. },
  274. };
  275. static struct platform_device meram_device = {
  276. .name = "sh_mobile_meram",
  277. .id = 0,
  278. .num_resources = ARRAY_SIZE(meram_resources),
  279. .resource = meram_resources,
  280. .dev = {
  281. .platform_data = &meram_info,
  282. },
  283. };
  284. /* SH_MMCIF */
  285. static struct resource sh_mmcif_resources[] = {
  286. [0] = {
  287. .name = "MMCIF",
  288. .start = 0xE6BD0000,
  289. .end = 0xE6BD00FF,
  290. .flags = IORESOURCE_MEM,
  291. },
  292. [1] = {
  293. /* MMC ERR */
  294. .start = evt2irq(0x1ac0),
  295. .flags = IORESOURCE_IRQ,
  296. },
  297. [2] = {
  298. /* MMC NOR */
  299. .start = evt2irq(0x1ae0),
  300. .flags = IORESOURCE_IRQ,
  301. },
  302. };
  303. static struct sh_mmcif_plat_data sh_mmcif_plat = {
  304. .sup_pclk = 0,
  305. .ocr = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34,
  306. .caps = MMC_CAP_4_BIT_DATA |
  307. MMC_CAP_8_BIT_DATA |
  308. MMC_CAP_NEEDS_POLL,
  309. .get_cd = slot_cn7_get_cd,
  310. .slave_id_tx = SHDMA_SLAVE_MMCIF_TX,
  311. .slave_id_rx = SHDMA_SLAVE_MMCIF_RX,
  312. };
  313. static struct platform_device sh_mmcif_device = {
  314. .name = "sh_mmcif",
  315. .id = 0,
  316. .dev = {
  317. .dma_mask = NULL,
  318. .coherent_dma_mask = 0xffffffff,
  319. .platform_data = &sh_mmcif_plat,
  320. },
  321. .num_resources = ARRAY_SIZE(sh_mmcif_resources),
  322. .resource = sh_mmcif_resources,
  323. };
  324. /* SDHI0 */
  325. static struct sh_mobile_sdhi_info sdhi0_info = {
  326. .dma_slave_tx = SHDMA_SLAVE_SDHI0_TX,
  327. .dma_slave_rx = SHDMA_SLAVE_SDHI0_RX,
  328. .tmio_caps = MMC_CAP_SDIO_IRQ,
  329. };
  330. static struct resource sdhi0_resources[] = {
  331. [0] = {
  332. .name = "SDHI0",
  333. .start = 0xe6850000,
  334. .end = 0xe68500ff,
  335. .flags = IORESOURCE_MEM,
  336. },
  337. [1] = {
  338. .start = evt2irq(0x0e00) /* SDHI0_SDHI0I0 */,
  339. .flags = IORESOURCE_IRQ,
  340. },
  341. [2] = {
  342. .start = evt2irq(0x0e20) /* SDHI0_SDHI0I1 */,
  343. .flags = IORESOURCE_IRQ,
  344. },
  345. [3] = {
  346. .start = evt2irq(0x0e40) /* SDHI0_SDHI0I2 */,
  347. .flags = IORESOURCE_IRQ,
  348. },
  349. };
  350. static struct platform_device sdhi0_device = {
  351. .name = "sh_mobile_sdhi",
  352. .num_resources = ARRAY_SIZE(sdhi0_resources),
  353. .resource = sdhi0_resources,
  354. .id = 0,
  355. .dev = {
  356. .platform_data = &sdhi0_info,
  357. },
  358. };
  359. /* SDHI1 */
  360. static struct sh_mobile_sdhi_info sdhi1_info = {
  361. .dma_slave_tx = SHDMA_SLAVE_SDHI1_TX,
  362. .dma_slave_rx = SHDMA_SLAVE_SDHI1_RX,
  363. .tmio_ocr_mask = MMC_VDD_165_195,
  364. .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE,
  365. .tmio_caps = MMC_CAP_NEEDS_POLL | MMC_CAP_SDIO_IRQ,
  366. .get_cd = slot_cn7_get_cd,
  367. };
  368. static struct resource sdhi1_resources[] = {
  369. [0] = {
  370. .name = "SDHI1",
  371. .start = 0xe6860000,
  372. .end = 0xe68600ff,
  373. .flags = IORESOURCE_MEM,
  374. },
  375. [1] = {
  376. .start = evt2irq(0x0e80), /* SDHI1_SDHI1I0 */
  377. .flags = IORESOURCE_IRQ,
  378. },
  379. [2] = {
  380. .start = evt2irq(0x0ea0), /* SDHI1_SDHI1I1 */
  381. .flags = IORESOURCE_IRQ,
  382. },
  383. [3] = {
  384. .start = evt2irq(0x0ec0), /* SDHI1_SDHI1I2 */
  385. .flags = IORESOURCE_IRQ,
  386. },
  387. };
  388. static struct platform_device sdhi1_device = {
  389. .name = "sh_mobile_sdhi",
  390. .num_resources = ARRAY_SIZE(sdhi1_resources),
  391. .resource = sdhi1_resources,
  392. .id = 1,
  393. .dev = {
  394. .platform_data = &sdhi1_info,
  395. },
  396. };
  397. /* USB1 */
  398. static void usb1_host_port_power(int port, int power)
  399. {
  400. if (!power) /* only power-on supported for now */
  401. return;
  402. /* set VBOUT/PWEN and EXTLP1 in DVSTCTR */
  403. __raw_writew(__raw_readw(IOMEM(0xE68B0008)) | 0x600, IOMEM(0xE68B0008));
  404. }
  405. static struct r8a66597_platdata usb1_host_data = {
  406. .on_chip = 1,
  407. .port_power = usb1_host_port_power,
  408. };
  409. static struct resource usb1_host_resources[] = {
  410. [0] = {
  411. .name = "USBHS",
  412. .start = 0xE68B0000,
  413. .end = 0xE68B00E6 - 1,
  414. .flags = IORESOURCE_MEM,
  415. },
  416. [1] = {
  417. .start = evt2irq(0x1ce0) /* USB1_USB1I0 */,
  418. .flags = IORESOURCE_IRQ,
  419. },
  420. };
  421. static struct platform_device usb1_host_device = {
  422. .name = "r8a66597_hcd",
  423. .id = 1,
  424. .dev = {
  425. .dma_mask = NULL, /* not use dma */
  426. .coherent_dma_mask = 0xffffffff,
  427. .platform_data = &usb1_host_data,
  428. },
  429. .num_resources = ARRAY_SIZE(usb1_host_resources),
  430. .resource = usb1_host_resources,
  431. };
  432. /*
  433. * QHD display
  434. */
  435. #ifdef CONFIG_AP4EVB_QHD
  436. /* KEYSC (Needs SW43 set to ON) */
  437. static struct sh_keysc_info keysc_info = {
  438. .mode = SH_KEYSC_MODE_1,
  439. .scan_timing = 3,
  440. .delay = 2500,
  441. .keycodes = {
  442. KEY_0, KEY_1, KEY_2, KEY_3, KEY_4,
  443. KEY_5, KEY_6, KEY_7, KEY_8, KEY_9,
  444. KEY_A, KEY_B, KEY_C, KEY_D, KEY_E,
  445. KEY_F, KEY_G, KEY_H, KEY_I, KEY_J,
  446. KEY_K, KEY_L, KEY_M, KEY_N, KEY_O,
  447. },
  448. };
  449. static struct resource keysc_resources[] = {
  450. [0] = {
  451. .name = "KEYSC",
  452. .start = 0xe61b0000,
  453. .end = 0xe61b0063,
  454. .flags = IORESOURCE_MEM,
  455. },
  456. [1] = {
  457. .start = evt2irq(0x0be0), /* KEYSC_KEY */
  458. .flags = IORESOURCE_IRQ,
  459. },
  460. };
  461. static struct platform_device keysc_device = {
  462. .name = "sh_keysc",
  463. .id = 0, /* "keysc0" clock */
  464. .num_resources = ARRAY_SIZE(keysc_resources),
  465. .resource = keysc_resources,
  466. .dev = {
  467. .platform_data = &keysc_info,
  468. },
  469. };
  470. /* MIPI-DSI */
  471. static int sh_mipi_set_dot_clock(struct platform_device *pdev,
  472. void __iomem *base,
  473. int enable)
  474. {
  475. struct clk *pck = clk_get(&pdev->dev, "dsip_clk");
  476. if (IS_ERR(pck))
  477. return PTR_ERR(pck);
  478. if (enable) {
  479. /*
  480. * DSIPCLK = 24MHz
  481. * D-PHY = DSIPCLK * ((0x6*2)+1) = 312MHz (see .phyctrl)
  482. * HsByteCLK = D-PHY/8 = 39MHz
  483. *
  484. * X * Y * FPS =
  485. * (544+72+600+16) * (961+8+8+2) * 30 = 36.1MHz
  486. */
  487. clk_set_rate(pck, clk_round_rate(pck, 24000000));
  488. clk_enable(pck);
  489. } else {
  490. clk_disable(pck);
  491. }
  492. clk_put(pck);
  493. return 0;
  494. }
  495. static struct resource mipidsi0_resources[] = {
  496. [0] = {
  497. .start = 0xffc60000,
  498. .end = 0xffc63073,
  499. .flags = IORESOURCE_MEM,
  500. },
  501. [1] = {
  502. .start = 0xffc68000,
  503. .end = 0xffc680ef,
  504. .flags = IORESOURCE_MEM,
  505. },
  506. };
  507. static struct sh_mipi_dsi_info mipidsi0_info = {
  508. .data_format = MIPI_RGB888,
  509. .channel = LCDC_CHAN_MAINLCD,
  510. .lane = 2,
  511. .vsynw_offset = 17,
  512. .phyctrl = 0x6 << 8,
  513. .flags = SH_MIPI_DSI_SYNC_PULSES_MODE |
  514. SH_MIPI_DSI_HSbyteCLK,
  515. .set_dot_clock = sh_mipi_set_dot_clock,
  516. };
  517. static struct platform_device mipidsi0_device = {
  518. .name = "sh-mipi-dsi",
  519. .num_resources = ARRAY_SIZE(mipidsi0_resources),
  520. .resource = mipidsi0_resources,
  521. .id = 0,
  522. .dev = {
  523. .platform_data = &mipidsi0_info,
  524. },
  525. };
  526. static struct platform_device *qhd_devices[] __initdata = {
  527. &mipidsi0_device,
  528. &keysc_device,
  529. };
  530. #endif /* CONFIG_AP4EVB_QHD */
  531. /* LCDC0 */
  532. static const struct fb_videomode ap4evb_lcdc_modes[] = {
  533. {
  534. #ifdef CONFIG_AP4EVB_QHD
  535. .name = "R63302(QHD)",
  536. .xres = 544,
  537. .yres = 961,
  538. .left_margin = 72,
  539. .right_margin = 600,
  540. .hsync_len = 16,
  541. .upper_margin = 8,
  542. .lower_margin = 8,
  543. .vsync_len = 2,
  544. .sync = FB_SYNC_VERT_HIGH_ACT | FB_SYNC_HOR_HIGH_ACT,
  545. #else
  546. .name = "WVGA Panel",
  547. .xres = 800,
  548. .yres = 480,
  549. .left_margin = 220,
  550. .right_margin = 110,
  551. .hsync_len = 70,
  552. .upper_margin = 20,
  553. .lower_margin = 5,
  554. .vsync_len = 5,
  555. .sync = 0,
  556. #endif
  557. },
  558. };
  559. static const struct sh_mobile_meram_cfg lcd_meram_cfg = {
  560. .icb[0] = {
  561. .meram_size = 0x40,
  562. },
  563. .icb[1] = {
  564. .meram_size = 0x40,
  565. },
  566. };
  567. static struct sh_mobile_lcdc_info lcdc_info = {
  568. .meram_dev = &meram_info,
  569. .ch[0] = {
  570. .chan = LCDC_CHAN_MAINLCD,
  571. .fourcc = V4L2_PIX_FMT_RGB565,
  572. .lcd_modes = ap4evb_lcdc_modes,
  573. .num_modes = ARRAY_SIZE(ap4evb_lcdc_modes),
  574. .meram_cfg = &lcd_meram_cfg,
  575. #ifdef CONFIG_AP4EVB_QHD
  576. .tx_dev = &mipidsi0_device,
  577. #endif
  578. }
  579. };
  580. static struct resource lcdc_resources[] = {
  581. [0] = {
  582. .name = "LCDC",
  583. .start = 0xfe940000, /* P4-only space */
  584. .end = 0xfe943fff,
  585. .flags = IORESOURCE_MEM,
  586. },
  587. [1] = {
  588. .start = intcs_evt2irq(0x580),
  589. .flags = IORESOURCE_IRQ,
  590. },
  591. };
  592. static struct platform_device lcdc_device = {
  593. .name = "sh_mobile_lcdc_fb",
  594. .num_resources = ARRAY_SIZE(lcdc_resources),
  595. .resource = lcdc_resources,
  596. .dev = {
  597. .platform_data = &lcdc_info,
  598. .coherent_dma_mask = ~0,
  599. },
  600. };
  601. /* FSI */
  602. #define IRQ_FSI evt2irq(0x1840)
  603. static struct sh_fsi_platform_info fsi_info = {
  604. .port_b = {
  605. .flags = SH_FSI_CLK_CPG |
  606. SH_FSI_FMT_SPDIF,
  607. },
  608. };
  609. static struct resource fsi_resources[] = {
  610. [0] = {
  611. .name = "FSI",
  612. .start = 0xFE3C0000,
  613. .end = 0xFE3C0400 - 1,
  614. .flags = IORESOURCE_MEM,
  615. },
  616. [1] = {
  617. .start = IRQ_FSI,
  618. .flags = IORESOURCE_IRQ,
  619. },
  620. };
  621. static struct platform_device fsi_device = {
  622. .name = "sh_fsi2",
  623. .id = -1,
  624. .num_resources = ARRAY_SIZE(fsi_resources),
  625. .resource = fsi_resources,
  626. .dev = {
  627. .platform_data = &fsi_info,
  628. },
  629. };
  630. static struct asoc_simple_card_info fsi2_ak4643_info = {
  631. .name = "AK4643",
  632. .card = "FSI2A-AK4643",
  633. .codec = "ak4642-codec.0-0013",
  634. .platform = "sh_fsi2",
  635. .daifmt = SND_SOC_DAIFMT_LEFT_J,
  636. .cpu_dai = {
  637. .name = "fsia-dai",
  638. .fmt = SND_SOC_DAIFMT_CBS_CFS,
  639. },
  640. .codec_dai = {
  641. .name = "ak4642-hifi",
  642. .fmt = SND_SOC_DAIFMT_CBM_CFM,
  643. .sysclk = 11289600,
  644. },
  645. };
  646. static struct platform_device fsi_ak4643_device = {
  647. .name = "asoc-simple-card",
  648. .dev = {
  649. .platform_data = &fsi2_ak4643_info,
  650. },
  651. };
  652. /* LCDC1 */
  653. static long ap4evb_clk_optimize(unsigned long target, unsigned long *best_freq,
  654. unsigned long *parent_freq);
  655. static struct sh_mobile_hdmi_info hdmi_info = {
  656. .flags = HDMI_SND_SRC_SPDIF,
  657. .clk_optimize_parent = ap4evb_clk_optimize,
  658. };
  659. static struct resource hdmi_resources[] = {
  660. [0] = {
  661. .name = "HDMI",
  662. .start = 0xe6be0000,
  663. .end = 0xe6be00ff,
  664. .flags = IORESOURCE_MEM,
  665. },
  666. [1] = {
  667. /* There's also an HDMI interrupt on INTCS @ 0x18e0 */
  668. .start = evt2irq(0x17e0),
  669. .flags = IORESOURCE_IRQ,
  670. },
  671. };
  672. static struct platform_device hdmi_device = {
  673. .name = "sh-mobile-hdmi",
  674. .num_resources = ARRAY_SIZE(hdmi_resources),
  675. .resource = hdmi_resources,
  676. .id = -1,
  677. .dev = {
  678. .platform_data = &hdmi_info,
  679. },
  680. };
  681. static long ap4evb_clk_optimize(unsigned long target, unsigned long *best_freq,
  682. unsigned long *parent_freq)
  683. {
  684. struct clk *hdmi_ick = clk_get(&hdmi_device.dev, "ick");
  685. long error;
  686. if (IS_ERR(hdmi_ick)) {
  687. int ret = PTR_ERR(hdmi_ick);
  688. pr_err("Cannot get HDMI ICK: %d\n", ret);
  689. return ret;
  690. }
  691. error = clk_round_parent(hdmi_ick, target, best_freq, parent_freq, 1, 64);
  692. clk_put(hdmi_ick);
  693. return error;
  694. }
  695. static const struct sh_mobile_meram_cfg hdmi_meram_cfg = {
  696. .icb[0] = {
  697. .meram_size = 0x100,
  698. },
  699. .icb[1] = {
  700. .meram_size = 0x100,
  701. },
  702. };
  703. static struct sh_mobile_lcdc_info sh_mobile_lcdc1_info = {
  704. .clock_source = LCDC_CLK_EXTERNAL,
  705. .meram_dev = &meram_info,
  706. .ch[0] = {
  707. .chan = LCDC_CHAN_MAINLCD,
  708. .fourcc = V4L2_PIX_FMT_RGB565,
  709. .interface_type = RGB24,
  710. .clock_divider = 1,
  711. .flags = LCDC_FLAGS_DWPOL,
  712. .meram_cfg = &hdmi_meram_cfg,
  713. .tx_dev = &hdmi_device,
  714. }
  715. };
  716. static struct resource lcdc1_resources[] = {
  717. [0] = {
  718. .name = "LCDC1",
  719. .start = 0xfe944000,
  720. .end = 0xfe947fff,
  721. .flags = IORESOURCE_MEM,
  722. },
  723. [1] = {
  724. .start = intcs_evt2irq(0x1780),
  725. .flags = IORESOURCE_IRQ,
  726. },
  727. };
  728. static struct platform_device lcdc1_device = {
  729. .name = "sh_mobile_lcdc_fb",
  730. .num_resources = ARRAY_SIZE(lcdc1_resources),
  731. .resource = lcdc1_resources,
  732. .id = 1,
  733. .dev = {
  734. .platform_data = &sh_mobile_lcdc1_info,
  735. .coherent_dma_mask = ~0,
  736. },
  737. };
  738. static struct asoc_simple_card_info fsi2_hdmi_info = {
  739. .name = "HDMI",
  740. .card = "FSI2B-HDMI",
  741. .codec = "sh-mobile-hdmi",
  742. .platform = "sh_fsi2",
  743. .cpu_dai = {
  744. .name = "fsib-dai",
  745. .fmt = SND_SOC_DAIFMT_CBM_CFM | SND_SOC_DAIFMT_IB_NF,
  746. },
  747. .codec_dai = {
  748. .name = "sh_mobile_hdmi-hifi",
  749. },
  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_one(GPIO_TSC_PORT, GPIOF_IN, NULL);
  938. val = gpio_get_value(GPIO_TSC_PORT);
  939. gpio_request(GPIO_TSC_IRQ, NULL);
  940. return !val;
  941. }
  942. static int ts_init(void)
  943. {
  944. gpio_request(GPIO_TSC_IRQ, NULL);
  945. return 0;
  946. }
  947. static struct tsc2007_platform_data tsc2007_info = {
  948. .model = 2007,
  949. .x_plate_ohms = 180,
  950. .get_pendown_state = ts_get_pendown_state,
  951. .init_platform_hw = ts_init,
  952. };
  953. static struct i2c_board_info tsc_device = {
  954. I2C_BOARD_INFO("tsc2007", 0x48),
  955. .type = "tsc2007",
  956. .platform_data = &tsc2007_info,
  957. /*.irq is selected on ap4evb_init */
  958. };
  959. /* I2C */
  960. static struct i2c_board_info i2c0_devices[] = {
  961. {
  962. I2C_BOARD_INFO("ak4643", 0x13),
  963. },
  964. };
  965. static struct i2c_board_info i2c1_devices[] = {
  966. {
  967. I2C_BOARD_INFO("r2025sd", 0x32),
  968. },
  969. };
  970. #define GPIO_PORT9CR IOMEM(0xE6051009)
  971. #define GPIO_PORT10CR IOMEM(0xE605100A)
  972. #define USCCR1 IOMEM(0xE6058144)
  973. static void __init ap4evb_init(void)
  974. {
  975. struct pm_domain_device domain_devices[] = {
  976. { "A4LC", &lcdc1_device, },
  977. { "A4LC", &lcdc_device, },
  978. { "A4MP", &fsi_device, },
  979. { "A3SP", &sh_mmcif_device, },
  980. { "A3SP", &sdhi0_device, },
  981. { "A3SP", &sdhi1_device, },
  982. { "A4R", &ceu_device, },
  983. };
  984. u32 srcr4;
  985. struct clk *clk;
  986. regulator_register_always_on(0, "fixed-1.8V", fixed1v8_power_consumers,
  987. ARRAY_SIZE(fixed1v8_power_consumers), 1800000);
  988. regulator_register_always_on(1, "fixed-3.3V", fixed3v3_power_consumers,
  989. ARRAY_SIZE(fixed3v3_power_consumers), 3300000);
  990. regulator_register_fixed(2, dummy_supplies, ARRAY_SIZE(dummy_supplies));
  991. /* External clock source */
  992. clk_set_rate(&sh7372_dv_clki_clk, 27000000);
  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_one(GPIO_PORT32, GPIOF_IN | GPIOF_EXPORT, NULL);
  1002. gpio_request_one(GPIO_PORT33, GPIOF_IN | GPIOF_EXPORT, NULL);
  1003. gpio_request_one(GPIO_PORT34, GPIOF_IN | GPIOF_EXPORT, NULL);
  1004. gpio_request_one(GPIO_PORT35, GPIOF_IN | GPIOF_EXPORT, NULL);
  1005. /* SDHI0 */
  1006. gpio_request(GPIO_FN_SDHICD0, NULL);
  1007. gpio_request(GPIO_FN_SDHIWP0, NULL);
  1008. gpio_request(GPIO_FN_SDHICMD0, NULL);
  1009. gpio_request(GPIO_FN_SDHICLK0, NULL);
  1010. gpio_request(GPIO_FN_SDHID0_3, NULL);
  1011. gpio_request(GPIO_FN_SDHID0_2, NULL);
  1012. gpio_request(GPIO_FN_SDHID0_1, NULL);
  1013. gpio_request(GPIO_FN_SDHID0_0, NULL);
  1014. /* SDHI1 */
  1015. gpio_request(GPIO_FN_SDHICMD1, NULL);
  1016. gpio_request(GPIO_FN_SDHICLK1, NULL);
  1017. gpio_request(GPIO_FN_SDHID1_3, NULL);
  1018. gpio_request(GPIO_FN_SDHID1_2, NULL);
  1019. gpio_request(GPIO_FN_SDHID1_1, NULL);
  1020. gpio_request(GPIO_FN_SDHID1_0, NULL);
  1021. /* MMCIF */
  1022. gpio_request(GPIO_FN_MMCD0_0, NULL);
  1023. gpio_request(GPIO_FN_MMCD0_1, NULL);
  1024. gpio_request(GPIO_FN_MMCD0_2, NULL);
  1025. gpio_request(GPIO_FN_MMCD0_3, NULL);
  1026. gpio_request(GPIO_FN_MMCD0_4, NULL);
  1027. gpio_request(GPIO_FN_MMCD0_5, NULL);
  1028. gpio_request(GPIO_FN_MMCD0_6, NULL);
  1029. gpio_request(GPIO_FN_MMCD0_7, NULL);
  1030. gpio_request(GPIO_FN_MMCCMD0, NULL);
  1031. gpio_request(GPIO_FN_MMCCLK0, NULL);
  1032. /* USB enable */
  1033. gpio_request(GPIO_FN_VBUS0_1, NULL);
  1034. gpio_request(GPIO_FN_IDIN_1_18, NULL);
  1035. gpio_request(GPIO_FN_PWEN_1_115, NULL);
  1036. gpio_request(GPIO_FN_OVCN_1_114, NULL);
  1037. gpio_request(GPIO_FN_EXTLP_1, NULL);
  1038. gpio_request(GPIO_FN_OVCN2_1, NULL);
  1039. /* setup USB phy */
  1040. __raw_writew(0x8a0a, IOMEM(0xE6058130)); /* USBCR4 */
  1041. /* enable FSI2 port A (ak4643) */
  1042. gpio_request(GPIO_FN_FSIAIBT, NULL);
  1043. gpio_request(GPIO_FN_FSIAILR, NULL);
  1044. gpio_request(GPIO_FN_FSIAISLD, NULL);
  1045. gpio_request(GPIO_FN_FSIAOSLD, NULL);
  1046. gpio_request_one(GPIO_PORT161, GPIOF_OUT_INIT_LOW, NULL); /* slave */
  1047. gpio_request(GPIO_PORT9, NULL);
  1048. gpio_request(GPIO_PORT10, NULL);
  1049. gpio_direction_none(GPIO_PORT9CR); /* FSIAOBT needs no direction */
  1050. gpio_direction_none(GPIO_PORT10CR); /* FSIAOLR needs no direction */
  1051. /* card detect pin for MMC slot (CN7) */
  1052. gpio_request_one(GPIO_PORT41, GPIOF_IN, NULL);
  1053. /* setup FSI2 port B (HDMI) */
  1054. gpio_request(GPIO_FN_FSIBCK, NULL);
  1055. __raw_writew(__raw_readw(USCCR1) & ~(1 << 6), USCCR1); /* use SPDIF */
  1056. /* set SPU2 clock to 119.6 MHz */
  1057. clk = clk_get(NULL, "spu_clk");
  1058. if (!IS_ERR(clk)) {
  1059. clk_set_rate(clk, clk_round_rate(clk, 119600000));
  1060. clk_put(clk);
  1061. }
  1062. /*
  1063. * set irq priority, to avoid sound chopping
  1064. * when NFS rootfs is used
  1065. * FSI(3) > SMSC911X(2)
  1066. */
  1067. intc_set_priority(IRQ_FSI, 3);
  1068. i2c_register_board_info(0, i2c0_devices,
  1069. ARRAY_SIZE(i2c0_devices));
  1070. i2c_register_board_info(1, i2c1_devices,
  1071. ARRAY_SIZE(i2c1_devices));
  1072. #ifdef CONFIG_AP4EVB_QHD
  1073. /*
  1074. * For QHD Panel (MIPI-DSI, CONFIG_AP4EVB_QHD=y) and
  1075. * IRQ28 for Touch Panel, set dip switches S3, S43 as OFF, ON.
  1076. */
  1077. /* enable KEYSC */
  1078. gpio_request(GPIO_FN_KEYOUT0, NULL);
  1079. gpio_request(GPIO_FN_KEYOUT1, NULL);
  1080. gpio_request(GPIO_FN_KEYOUT2, NULL);
  1081. gpio_request(GPIO_FN_KEYOUT3, NULL);
  1082. gpio_request(GPIO_FN_KEYOUT4, NULL);
  1083. gpio_request(GPIO_FN_KEYIN0_136, NULL);
  1084. gpio_request(GPIO_FN_KEYIN1_135, NULL);
  1085. gpio_request(GPIO_FN_KEYIN2_134, NULL);
  1086. gpio_request(GPIO_FN_KEYIN3_133, NULL);
  1087. gpio_request(GPIO_FN_KEYIN4, NULL);
  1088. /* enable TouchScreen */
  1089. irq_set_irq_type(IRQ28, IRQ_TYPE_LEVEL_LOW);
  1090. tsc_device.irq = IRQ28;
  1091. i2c_register_board_info(1, &tsc_device, 1);
  1092. /* LCDC0 */
  1093. lcdc_info.clock_source = LCDC_CLK_PERIPHERAL;
  1094. lcdc_info.ch[0].interface_type = RGB24;
  1095. lcdc_info.ch[0].clock_divider = 1;
  1096. lcdc_info.ch[0].flags = LCDC_FLAGS_DWPOL;
  1097. lcdc_info.ch[0].panel_cfg.width = 44;
  1098. lcdc_info.ch[0].panel_cfg.height = 79;
  1099. platform_add_devices(qhd_devices, ARRAY_SIZE(qhd_devices));
  1100. #else
  1101. /*
  1102. * For WVGA Panel (18-bit RGB, CONFIG_AP4EVB_WVGA=y) and
  1103. * IRQ7 for Touch Panel, set dip switches S3, S43 to ON, OFF.
  1104. */
  1105. gpio_request(GPIO_FN_LCDD17, NULL);
  1106. gpio_request(GPIO_FN_LCDD16, NULL);
  1107. gpio_request(GPIO_FN_LCDD15, NULL);
  1108. gpio_request(GPIO_FN_LCDD14, NULL);
  1109. gpio_request(GPIO_FN_LCDD13, NULL);
  1110. gpio_request(GPIO_FN_LCDD12, NULL);
  1111. gpio_request(GPIO_FN_LCDD11, NULL);
  1112. gpio_request(GPIO_FN_LCDD10, NULL);
  1113. gpio_request(GPIO_FN_LCDD9, NULL);
  1114. gpio_request(GPIO_FN_LCDD8, NULL);
  1115. gpio_request(GPIO_FN_LCDD7, NULL);
  1116. gpio_request(GPIO_FN_LCDD6, NULL);
  1117. gpio_request(GPIO_FN_LCDD5, NULL);
  1118. gpio_request(GPIO_FN_LCDD4, NULL);
  1119. gpio_request(GPIO_FN_LCDD3, NULL);
  1120. gpio_request(GPIO_FN_LCDD2, NULL);
  1121. gpio_request(GPIO_FN_LCDD1, NULL);
  1122. gpio_request(GPIO_FN_LCDD0, NULL);
  1123. gpio_request(GPIO_FN_LCDDISP, NULL);
  1124. gpio_request(GPIO_FN_LCDDCK, NULL);
  1125. gpio_request_one(GPIO_PORT189, GPIOF_OUT_INIT_HIGH, NULL); /* backlight */
  1126. gpio_request_one(GPIO_PORT151, GPIOF_OUT_INIT_HIGH, NULL); /* LCDDON */
  1127. lcdc_info.clock_source = LCDC_CLK_BUS;
  1128. lcdc_info.ch[0].interface_type = RGB18;
  1129. lcdc_info.ch[0].clock_divider = 3;
  1130. lcdc_info.ch[0].flags = 0;
  1131. lcdc_info.ch[0].panel_cfg.width = 152;
  1132. lcdc_info.ch[0].panel_cfg.height = 91;
  1133. /* enable TouchScreen */
  1134. irq_set_irq_type(IRQ7, IRQ_TYPE_LEVEL_LOW);
  1135. tsc_device.irq = IRQ7;
  1136. i2c_register_board_info(0, &tsc_device, 1);
  1137. #endif /* CONFIG_AP4EVB_QHD */
  1138. /* CEU */
  1139. /*
  1140. * TODO: reserve memory for V4L2 DMA buffers, when a suitable API
  1141. * becomes available
  1142. */
  1143. /* MIPI-CSI stuff */
  1144. gpio_request(GPIO_FN_VIO_CKO, NULL);
  1145. clk = clk_get(NULL, "vck1_clk");
  1146. if (!IS_ERR(clk)) {
  1147. clk_set_rate(clk, clk_round_rate(clk, 13000000));
  1148. clk_enable(clk);
  1149. clk_put(clk);
  1150. }
  1151. sh7372_add_standard_devices();
  1152. /* HDMI */
  1153. gpio_request(GPIO_FN_HDMI_HPD, NULL);
  1154. gpio_request(GPIO_FN_HDMI_CEC, NULL);
  1155. /* Reset HDMI, must be held at least one EXTALR (32768Hz) period */
  1156. #define SRCR4 IOMEM(0xe61580bc)
  1157. srcr4 = __raw_readl(SRCR4);
  1158. __raw_writel(srcr4 | (1 << 13), SRCR4);
  1159. udelay(50);
  1160. __raw_writel(srcr4 & ~(1 << 13), SRCR4);
  1161. platform_add_devices(ap4evb_devices, ARRAY_SIZE(ap4evb_devices));
  1162. rmobile_add_devices_to_domains(domain_devices,
  1163. ARRAY_SIZE(domain_devices));
  1164. hdmi_init_pm_clock();
  1165. sh7372_pm_init();
  1166. pm_clk_add(&fsi_device.dev, "spu2");
  1167. pm_clk_add(&lcdc1_device.dev, "hdmi");
  1168. }
  1169. MACHINE_START(AP4EVB, "ap4evb")
  1170. .map_io = sh7372_map_io,
  1171. .init_early = sh7372_add_early_devices,
  1172. .init_irq = sh7372_init_irq,
  1173. .handle_irq = shmobile_handle_irq_intc,
  1174. .init_machine = ap4evb_init,
  1175. .init_late = sh7372_pm_init_late,
  1176. .init_time = sh7372_earlytimer_init,
  1177. MACHINE_END