board-ap4evb.c 30 KB

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