board-mackerel.c 39 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595
  1. /*
  2. * mackerel board support
  3. *
  4. * Copyright (C) 2010 Renesas Solutions Corp.
  5. * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
  6. *
  7. * based on ap4evb
  8. * Copyright (C) 2010 Magnus Damm
  9. * Copyright (C) 2008 Yoshihiro Shimoda
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; version 2 of the License.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  23. */
  24. #include <linux/delay.h>
  25. #include <linux/kernel.h>
  26. #include <linux/init.h>
  27. #include <linux/interrupt.h>
  28. #include <linux/irq.h>
  29. #include <linux/platform_device.h>
  30. #include <linux/gpio.h>
  31. #include <linux/input.h>
  32. #include <linux/io.h>
  33. #include <linux/i2c.h>
  34. #include <linux/leds.h>
  35. #include <linux/mfd/tmio.h>
  36. #include <linux/mmc/host.h>
  37. #include <linux/mmc/sh_mmcif.h>
  38. #include <linux/mmc/sh_mobile_sdhi.h>
  39. #include <linux/mtd/mtd.h>
  40. #include <linux/mtd/partitions.h>
  41. #include <linux/mtd/physmap.h>
  42. #include <linux/mtd/sh_flctl.h>
  43. #include <linux/pm_clock.h>
  44. #include <linux/regulator/fixed.h>
  45. #include <linux/regulator/machine.h>
  46. #include <linux/smsc911x.h>
  47. #include <linux/sh_intc.h>
  48. #include <linux/tca6416_keypad.h>
  49. #include <linux/usb/renesas_usbhs.h>
  50. #include <linux/dma-mapping.h>
  51. #include <video/sh_mobile_hdmi.h>
  52. #include <video/sh_mobile_lcdc.h>
  53. #include <media/sh_mobile_ceu.h>
  54. #include <media/soc_camera.h>
  55. #include <media/soc_camera_platform.h>
  56. #include <sound/sh_fsi.h>
  57. #include <sound/simple_card.h>
  58. #include <mach/common.h>
  59. #include <mach/irqs.h>
  60. #include <mach/sh7372.h>
  61. #include <asm/mach/arch.h>
  62. #include <asm/mach-types.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. * CPU mode
  78. *
  79. * SW4 | Boot Area| Master | Remarks
  80. * 1 | 2 | 3 | 4 | 5 | 6 | 8 | | Processor|
  81. * ----+-----+-----+-----+-----+-----+-----+----------+----------+--------------
  82. * ON | ON | OFF | ON | ON | OFF | OFF | External | System | External ROM
  83. * ON | ON | ON | ON | ON | OFF | OFF | External | System | ROM Debug
  84. * ON | ON | X | ON | OFF | OFF | OFF | Built-in | System | ROM Debug
  85. * X | OFF | X | X | X | X | OFF | Built-in | System | MaskROM
  86. * OFF | X | X | X | X | X | OFF | Built-in | System | MaskROM
  87. * X | X | X | OFF | X | X | OFF | Built-in | System | MaskROM
  88. * OFF | ON | OFF | X | X | OFF | ON | External | System | Standalone
  89. * ON | OFF | OFF | X | X | OFF | ON | External | Realtime | Standalone
  90. */
  91. /*
  92. * NOR Flash ROM
  93. *
  94. * SW1 | SW2 | SW7 | NOR Flash ROM
  95. * bit1 | bit1 bit2 | bit1 | Memory allocation
  96. * ------+------------+------+------------------
  97. * OFF | ON OFF | ON | Area 0
  98. * OFF | ON OFF | OFF | Area 4
  99. */
  100. /*
  101. * SMSC 9220
  102. *
  103. * SW1 SMSC 9220
  104. * -----------------------
  105. * ON access disable
  106. * OFF access enable
  107. */
  108. /*
  109. * NAND Flash ROM
  110. *
  111. * SW1 | SW2 | SW7 | NAND Flash ROM
  112. * bit1 | bit1 bit2 | bit2 | Memory allocation
  113. * ------+------------+------+------------------
  114. * OFF | ON OFF | ON | FCE 0
  115. * OFF | ON OFF | OFF | FCE 1
  116. */
  117. /*
  118. * External interrupt pin settings
  119. *
  120. * IRQX | pin setting | device | level
  121. * ------+--------------------+--------------------+-------
  122. * IRQ0 | ICR1A.IRQ0SA=0010 | SDHI2 card detect | Low
  123. * IRQ6 | ICR1A.IRQ6SA=0011 | Ether(LAN9220) | High
  124. * IRQ7 | ICR1A.IRQ7SA=0010 | LCD Touch Panel | Low
  125. * IRQ8 | ICR2A.IRQ8SA=0010 | MMC/SD card detect | Low
  126. * IRQ9 | ICR2A.IRQ9SA=0010 | KEY(TCA6408) | Low
  127. * IRQ21 | ICR4A.IRQ21SA=0011 | Sensor(ADXL345) | High
  128. * IRQ22 | ICR4A.IRQ22SA=0011 | Sensor(AK8975) | High
  129. */
  130. /*
  131. * USB
  132. *
  133. * USB0 : CN22 : Function
  134. * USB1 : CN31 : Function/Host *1
  135. *
  136. * J30 (for CN31) *1
  137. * ----------+---------------+-------------
  138. * 1-2 short | VBUS 5V | Host
  139. * open | external VBUS | Function
  140. *
  141. * CAUTION
  142. *
  143. * renesas_usbhs driver can use external interrupt mode
  144. * (which come from USB-PHY) or autonomy mode (it use own interrupt)
  145. * for detecting connection/disconnection when Function.
  146. * USB will be power OFF while it has been disconnecting
  147. * if external interrupt mode, and it is always power ON if autonomy mode,
  148. *
  149. * mackerel can not use external interrupt (IRQ7-PORT167) mode on "USB0",
  150. * because Touchscreen is using IRQ7-PORT40.
  151. * It is impossible to use IRQ7 demux on this board.
  152. */
  153. /*
  154. * SDHI0 (CN12)
  155. *
  156. * SW56 : OFF
  157. *
  158. */
  159. /* MMC /SDHI1 (CN7)
  160. *
  161. * I/O voltage : 1.8v
  162. *
  163. * Power voltage : 1.8v or 3.3v
  164. * J22 : select power voltage *1
  165. * 1-2 pin : 1.8v
  166. * 2-3 pin : 3.3v
  167. *
  168. * *1
  169. * Please change J22 depends the card to be used.
  170. * MMC's OCR field set to support either voltage for the card inserted.
  171. *
  172. * SW1 | SW33
  173. * | bit1 | bit2 | bit3 | bit4
  174. * -------------+------+------+------+-------
  175. * MMC0 OFF | OFF | X | ON | X (Use MMCIF)
  176. * SDHI1 OFF | ON | X | OFF | X (Use MFD_SH_MOBILE_SDHI)
  177. *
  178. */
  179. /*
  180. * SDHI2 (CN23)
  181. *
  182. * microSD card sloct
  183. *
  184. */
  185. /*
  186. * FSI - AK4642
  187. *
  188. * it needs amixer settings for playing
  189. *
  190. * amixer set "Headphone" on
  191. * amixer set "HPOUTL Mixer DACH" on
  192. * amixer set "HPOUTR Mixer DACH" on
  193. */
  194. /* Fixed 3.3V and 1.8V regulators to be used by multiple devices */
  195. static struct regulator_consumer_supply fixed1v8_power_consumers[] =
  196. {
  197. /*
  198. * J22 on mackerel switches mmcif.0 and sdhi.1 between 1.8V and 3.3V
  199. * Since we cannot support both voltages, we support the default 1.8V
  200. */
  201. REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.1"),
  202. REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.1"),
  203. REGULATOR_SUPPLY("vmmc", "sh_mmcif.0"),
  204. REGULATOR_SUPPLY("vqmmc", "sh_mmcif.0"),
  205. };
  206. static struct regulator_consumer_supply fixed3v3_power_consumers[] =
  207. {
  208. REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.0"),
  209. REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.0"),
  210. REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.2"),
  211. REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.2"),
  212. };
  213. /* Dummy supplies, where voltage doesn't matter */
  214. static struct regulator_consumer_supply dummy_supplies[] = {
  215. REGULATOR_SUPPLY("vddvario", "smsc911x"),
  216. REGULATOR_SUPPLY("vdd33a", "smsc911x"),
  217. };
  218. /* MTD */
  219. static struct mtd_partition nor_flash_partitions[] = {
  220. {
  221. .name = "loader",
  222. .offset = 0x00000000,
  223. .size = 512 * 1024,
  224. .mask_flags = MTD_WRITEABLE,
  225. },
  226. {
  227. .name = "bootenv",
  228. .offset = MTDPART_OFS_APPEND,
  229. .size = 512 * 1024,
  230. .mask_flags = MTD_WRITEABLE,
  231. },
  232. {
  233. .name = "kernel_ro",
  234. .offset = MTDPART_OFS_APPEND,
  235. .size = 8 * 1024 * 1024,
  236. .mask_flags = MTD_WRITEABLE,
  237. },
  238. {
  239. .name = "kernel",
  240. .offset = MTDPART_OFS_APPEND,
  241. .size = 8 * 1024 * 1024,
  242. },
  243. {
  244. .name = "data",
  245. .offset = MTDPART_OFS_APPEND,
  246. .size = MTDPART_SIZ_FULL,
  247. },
  248. };
  249. static struct physmap_flash_data nor_flash_data = {
  250. .width = 2,
  251. .parts = nor_flash_partitions,
  252. .nr_parts = ARRAY_SIZE(nor_flash_partitions),
  253. };
  254. static struct resource nor_flash_resources[] = {
  255. [0] = {
  256. .start = 0x20000000, /* CS0 shadow instead of regular CS0 */
  257. .end = 0x28000000 - 1, /* needed by USB MASK ROM boot */
  258. .flags = IORESOURCE_MEM,
  259. }
  260. };
  261. static struct platform_device nor_flash_device = {
  262. .name = "physmap-flash",
  263. .dev = {
  264. .platform_data = &nor_flash_data,
  265. },
  266. .num_resources = ARRAY_SIZE(nor_flash_resources),
  267. .resource = nor_flash_resources,
  268. };
  269. /* SMSC */
  270. static struct resource smc911x_resources[] = {
  271. {
  272. .start = 0x14000000,
  273. .end = 0x16000000 - 1,
  274. .flags = IORESOURCE_MEM,
  275. }, {
  276. .start = evt2irq(0x02c0) /* IRQ6A */,
  277. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
  278. },
  279. };
  280. static struct smsc911x_platform_config smsc911x_info = {
  281. .flags = SMSC911X_USE_16BIT | SMSC911X_SAVE_MAC_ADDRESS,
  282. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
  283. .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
  284. };
  285. static struct platform_device smc911x_device = {
  286. .name = "smsc911x",
  287. .id = -1,
  288. .num_resources = ARRAY_SIZE(smc911x_resources),
  289. .resource = smc911x_resources,
  290. .dev = {
  291. .platform_data = &smsc911x_info,
  292. },
  293. };
  294. /* MERAM */
  295. static struct sh_mobile_meram_info mackerel_meram_info = {
  296. .addr_mode = SH_MOBILE_MERAM_MODE1,
  297. };
  298. static struct resource meram_resources[] = {
  299. [0] = {
  300. .name = "regs",
  301. .start = 0xe8000000,
  302. .end = 0xe807ffff,
  303. .flags = IORESOURCE_MEM,
  304. },
  305. [1] = {
  306. .name = "meram",
  307. .start = 0xe8080000,
  308. .end = 0xe81fffff,
  309. .flags = IORESOURCE_MEM,
  310. },
  311. };
  312. static struct platform_device meram_device = {
  313. .name = "sh_mobile_meram",
  314. .id = 0,
  315. .num_resources = ARRAY_SIZE(meram_resources),
  316. .resource = meram_resources,
  317. .dev = {
  318. .platform_data = &mackerel_meram_info,
  319. },
  320. };
  321. /* LCDC */
  322. static struct fb_videomode mackerel_lcdc_modes[] = {
  323. {
  324. .name = "WVGA Panel",
  325. .xres = 800,
  326. .yres = 480,
  327. .left_margin = 220,
  328. .right_margin = 110,
  329. .hsync_len = 70,
  330. .upper_margin = 20,
  331. .lower_margin = 5,
  332. .vsync_len = 5,
  333. .sync = 0,
  334. },
  335. };
  336. static int mackerel_set_brightness(int brightness)
  337. {
  338. gpio_set_value(GPIO_PORT31, brightness);
  339. return 0;
  340. }
  341. static const struct sh_mobile_meram_cfg lcd_meram_cfg = {
  342. .icb[0] = {
  343. .meram_size = 0x40,
  344. },
  345. .icb[1] = {
  346. .meram_size = 0x40,
  347. },
  348. };
  349. static struct sh_mobile_lcdc_info lcdc_info = {
  350. .meram_dev = &mackerel_meram_info,
  351. .clock_source = LCDC_CLK_BUS,
  352. .ch[0] = {
  353. .chan = LCDC_CHAN_MAINLCD,
  354. .fourcc = V4L2_PIX_FMT_RGB565,
  355. .lcd_modes = mackerel_lcdc_modes,
  356. .num_modes = ARRAY_SIZE(mackerel_lcdc_modes),
  357. .interface_type = RGB24,
  358. .clock_divider = 3,
  359. .flags = 0,
  360. .panel_cfg = {
  361. .width = 152,
  362. .height = 91,
  363. },
  364. .bl_info = {
  365. .name = "sh_mobile_lcdc_bl",
  366. .max_brightness = 1,
  367. .set_brightness = mackerel_set_brightness,
  368. },
  369. .meram_cfg = &lcd_meram_cfg,
  370. }
  371. };
  372. static struct resource lcdc_resources[] = {
  373. [0] = {
  374. .name = "LCDC",
  375. .start = 0xfe940000,
  376. .end = 0xfe943fff,
  377. .flags = IORESOURCE_MEM,
  378. },
  379. [1] = {
  380. .start = intcs_evt2irq(0x580),
  381. .flags = IORESOURCE_IRQ,
  382. },
  383. };
  384. static struct platform_device lcdc_device = {
  385. .name = "sh_mobile_lcdc_fb",
  386. .num_resources = ARRAY_SIZE(lcdc_resources),
  387. .resource = lcdc_resources,
  388. .dev = {
  389. .platform_data = &lcdc_info,
  390. .coherent_dma_mask = ~0,
  391. },
  392. };
  393. /* HDMI */
  394. static struct sh_mobile_hdmi_info hdmi_info = {
  395. .flags = HDMI_SND_SRC_SPDIF,
  396. };
  397. static struct resource hdmi_resources[] = {
  398. [0] = {
  399. .name = "HDMI",
  400. .start = 0xe6be0000,
  401. .end = 0xe6be00ff,
  402. .flags = IORESOURCE_MEM,
  403. },
  404. [1] = {
  405. /* There's also an HDMI interrupt on INTCS @ 0x18e0 */
  406. .start = evt2irq(0x17e0),
  407. .flags = IORESOURCE_IRQ,
  408. },
  409. };
  410. static struct platform_device hdmi_device = {
  411. .name = "sh-mobile-hdmi",
  412. .num_resources = ARRAY_SIZE(hdmi_resources),
  413. .resource = hdmi_resources,
  414. .id = -1,
  415. .dev = {
  416. .platform_data = &hdmi_info,
  417. },
  418. };
  419. static const struct sh_mobile_meram_cfg hdmi_meram_cfg = {
  420. .icb[0] = {
  421. .meram_size = 0x100,
  422. },
  423. .icb[1] = {
  424. .meram_size = 0x100,
  425. },
  426. };
  427. static struct sh_mobile_lcdc_info hdmi_lcdc_info = {
  428. .meram_dev = &mackerel_meram_info,
  429. .clock_source = LCDC_CLK_EXTERNAL,
  430. .ch[0] = {
  431. .chan = LCDC_CHAN_MAINLCD,
  432. .fourcc = V4L2_PIX_FMT_RGB565,
  433. .interface_type = RGB24,
  434. .clock_divider = 1,
  435. .flags = LCDC_FLAGS_DWPOL,
  436. .meram_cfg = &hdmi_meram_cfg,
  437. .tx_dev = &hdmi_device,
  438. }
  439. };
  440. static struct resource hdmi_lcdc_resources[] = {
  441. [0] = {
  442. .name = "LCDC1",
  443. .start = 0xfe944000,
  444. .end = 0xfe947fff,
  445. .flags = IORESOURCE_MEM,
  446. },
  447. [1] = {
  448. .start = intcs_evt2irq(0x1780),
  449. .flags = IORESOURCE_IRQ,
  450. },
  451. };
  452. static struct platform_device hdmi_lcdc_device = {
  453. .name = "sh_mobile_lcdc_fb",
  454. .num_resources = ARRAY_SIZE(hdmi_lcdc_resources),
  455. .resource = hdmi_lcdc_resources,
  456. .id = 1,
  457. .dev = {
  458. .platform_data = &hdmi_lcdc_info,
  459. .coherent_dma_mask = ~0,
  460. },
  461. };
  462. static struct asoc_simple_dai_init_info fsi2_hdmi_init_info = {
  463. .cpu_daifmt = SND_SOC_DAIFMT_CBM_CFM |
  464. SND_SOC_DAIFMT_IB_NF,
  465. };
  466. static struct asoc_simple_card_info fsi2_hdmi_info = {
  467. .name = "HDMI",
  468. .card = "FSI2B-HDMI",
  469. .cpu_dai = "fsib-dai",
  470. .codec = "sh-mobile-hdmi",
  471. .platform = "sh_fsi2",
  472. .codec_dai = "sh_mobile_hdmi-hifi",
  473. .init = &fsi2_hdmi_init_info,
  474. };
  475. static struct platform_device fsi_hdmi_device = {
  476. .name = "asoc-simple-card",
  477. .id = 1,
  478. .dev = {
  479. .platform_data = &fsi2_hdmi_info,
  480. },
  481. };
  482. static void __init hdmi_init_pm_clock(void)
  483. {
  484. struct clk *hdmi_ick = clk_get(&hdmi_device.dev, "ick");
  485. int ret;
  486. long rate;
  487. if (IS_ERR(hdmi_ick)) {
  488. ret = PTR_ERR(hdmi_ick);
  489. pr_err("Cannot get HDMI ICK: %d\n", ret);
  490. goto out;
  491. }
  492. ret = clk_set_parent(&sh7372_pllc2_clk, &sh7372_dv_clki_div2_clk);
  493. if (ret < 0) {
  494. pr_err("Cannot set PLLC2 parent: %d, %d users\n",
  495. ret, sh7372_pllc2_clk.usecount);
  496. goto out;
  497. }
  498. pr_debug("PLLC2 initial frequency %lu\n",
  499. clk_get_rate(&sh7372_pllc2_clk));
  500. rate = clk_round_rate(&sh7372_pllc2_clk, 594000000);
  501. if (rate < 0) {
  502. pr_err("Cannot get suitable rate: %ld\n", rate);
  503. ret = rate;
  504. goto out;
  505. }
  506. ret = clk_set_rate(&sh7372_pllc2_clk, rate);
  507. if (ret < 0) {
  508. pr_err("Cannot set rate %ld: %d\n", rate, ret);
  509. goto out;
  510. }
  511. pr_debug("PLLC2 set frequency %lu\n", rate);
  512. ret = clk_set_parent(hdmi_ick, &sh7372_pllc2_clk);
  513. if (ret < 0)
  514. pr_err("Cannot set HDMI parent: %d\n", ret);
  515. out:
  516. if (!IS_ERR(hdmi_ick))
  517. clk_put(hdmi_ick);
  518. }
  519. /* USBHS0 is connected to CN22 which takes a USB Mini-B plug
  520. *
  521. * The sh7372 SoC has IRQ7 set aside for USBHS0 hotplug,
  522. * but on this particular board IRQ7 is already used by
  523. * the touch screen. This leaves us with software polling.
  524. */
  525. #define USBHS0_POLL_INTERVAL (HZ * 5)
  526. struct usbhs_private {
  527. void __iomem *usbphyaddr;
  528. void __iomem *usbcrcaddr;
  529. struct renesas_usbhs_platform_info info;
  530. struct delayed_work work;
  531. struct platform_device *pdev;
  532. };
  533. #define usbhs_get_priv(pdev) \
  534. container_of(renesas_usbhs_get_info(pdev), \
  535. struct usbhs_private, info)
  536. #define usbhs_is_connected(priv) \
  537. (!((1 << 7) & __raw_readw(priv->usbcrcaddr)))
  538. static int usbhs_get_vbus(struct platform_device *pdev)
  539. {
  540. return usbhs_is_connected(usbhs_get_priv(pdev));
  541. }
  542. static void usbhs_phy_reset(struct platform_device *pdev)
  543. {
  544. struct usbhs_private *priv = usbhs_get_priv(pdev);
  545. /* init phy */
  546. __raw_writew(0x8a0a, priv->usbcrcaddr);
  547. }
  548. static int usbhs0_get_id(struct platform_device *pdev)
  549. {
  550. return USBHS_GADGET;
  551. }
  552. static void usbhs0_work_function(struct work_struct *work)
  553. {
  554. struct usbhs_private *priv = container_of(work, struct usbhs_private,
  555. work.work);
  556. renesas_usbhs_call_notify_hotplug(priv->pdev);
  557. schedule_delayed_work(&priv->work, USBHS0_POLL_INTERVAL);
  558. }
  559. static int usbhs0_hardware_init(struct platform_device *pdev)
  560. {
  561. struct usbhs_private *priv = usbhs_get_priv(pdev);
  562. priv->pdev = pdev;
  563. INIT_DELAYED_WORK(&priv->work, usbhs0_work_function);
  564. schedule_delayed_work(&priv->work, USBHS0_POLL_INTERVAL);
  565. return 0;
  566. }
  567. static void usbhs0_hardware_exit(struct platform_device *pdev)
  568. {
  569. struct usbhs_private *priv = usbhs_get_priv(pdev);
  570. cancel_delayed_work_sync(&priv->work);
  571. }
  572. static struct usbhs_private usbhs0_private = {
  573. .usbcrcaddr = IOMEM(0xe605810c), /* USBCR2 */
  574. .info = {
  575. .platform_callback = {
  576. .hardware_init = usbhs0_hardware_init,
  577. .hardware_exit = usbhs0_hardware_exit,
  578. .phy_reset = usbhs_phy_reset,
  579. .get_id = usbhs0_get_id,
  580. .get_vbus = usbhs_get_vbus,
  581. },
  582. .driver_param = {
  583. .buswait_bwait = 4,
  584. .d0_tx_id = SHDMA_SLAVE_USB0_TX,
  585. .d1_rx_id = SHDMA_SLAVE_USB0_RX,
  586. },
  587. },
  588. };
  589. static struct resource usbhs0_resources[] = {
  590. [0] = {
  591. .name = "USBHS0",
  592. .start = 0xe6890000,
  593. .end = 0xe68900e6 - 1,
  594. .flags = IORESOURCE_MEM,
  595. },
  596. [1] = {
  597. .start = evt2irq(0x1ca0) /* USB0_USB0I0 */,
  598. .flags = IORESOURCE_IRQ,
  599. },
  600. };
  601. static struct platform_device usbhs0_device = {
  602. .name = "renesas_usbhs",
  603. .id = 0,
  604. .dev = {
  605. .platform_data = &usbhs0_private.info,
  606. },
  607. .num_resources = ARRAY_SIZE(usbhs0_resources),
  608. .resource = usbhs0_resources,
  609. };
  610. /* USBHS1 is connected to CN31 which takes a USB Mini-AB plug
  611. *
  612. * Use J30 to select between Host and Function. This setting
  613. * can however not be detected by software. Hotplug of USBHS1
  614. * is provided via IRQ8.
  615. *
  616. * Current USB1 works as "USB Host".
  617. * - set J30 "short"
  618. *
  619. * If you want to use it as "USB gadget",
  620. * - J30 "open"
  621. * - modify usbhs1_get_id() USBHS_HOST -> USBHS_GADGET
  622. * - add .get_vbus = usbhs_get_vbus in usbhs1_private
  623. * - check usbhs0_device(pio)/usbhs1_device(irq) order in mackerel_devices.
  624. */
  625. #define IRQ8 evt2irq(0x0300)
  626. #define USB_PHY_MODE (1 << 4)
  627. #define USB_PHY_INT_EN ((1 << 3) | (1 << 2))
  628. #define USB_PHY_ON (1 << 1)
  629. #define USB_PHY_OFF (1 << 0)
  630. #define USB_PHY_INT_CLR (USB_PHY_ON | USB_PHY_OFF)
  631. static irqreturn_t usbhs1_interrupt(int irq, void *data)
  632. {
  633. struct platform_device *pdev = data;
  634. struct usbhs_private *priv = usbhs_get_priv(pdev);
  635. dev_dbg(&pdev->dev, "%s\n", __func__);
  636. renesas_usbhs_call_notify_hotplug(pdev);
  637. /* clear status */
  638. __raw_writew(__raw_readw(priv->usbphyaddr) | USB_PHY_INT_CLR,
  639. priv->usbphyaddr);
  640. return IRQ_HANDLED;
  641. }
  642. static int usbhs1_hardware_init(struct platform_device *pdev)
  643. {
  644. struct usbhs_private *priv = usbhs_get_priv(pdev);
  645. int ret;
  646. /* clear interrupt status */
  647. __raw_writew(USB_PHY_MODE | USB_PHY_INT_CLR, priv->usbphyaddr);
  648. ret = request_irq(IRQ8, usbhs1_interrupt, IRQF_TRIGGER_HIGH,
  649. dev_name(&pdev->dev), pdev);
  650. if (ret) {
  651. dev_err(&pdev->dev, "request_irq err\n");
  652. return ret;
  653. }
  654. /* enable USB phy interrupt */
  655. __raw_writew(USB_PHY_MODE | USB_PHY_INT_EN, priv->usbphyaddr);
  656. return 0;
  657. }
  658. static void usbhs1_hardware_exit(struct platform_device *pdev)
  659. {
  660. struct usbhs_private *priv = usbhs_get_priv(pdev);
  661. /* clear interrupt status */
  662. __raw_writew(USB_PHY_MODE | USB_PHY_INT_CLR, priv->usbphyaddr);
  663. free_irq(IRQ8, pdev);
  664. }
  665. static int usbhs1_get_id(struct platform_device *pdev)
  666. {
  667. return USBHS_HOST;
  668. }
  669. static u32 usbhs1_pipe_cfg[] = {
  670. USB_ENDPOINT_XFER_CONTROL,
  671. USB_ENDPOINT_XFER_ISOC,
  672. USB_ENDPOINT_XFER_ISOC,
  673. USB_ENDPOINT_XFER_BULK,
  674. USB_ENDPOINT_XFER_BULK,
  675. USB_ENDPOINT_XFER_BULK,
  676. USB_ENDPOINT_XFER_INT,
  677. USB_ENDPOINT_XFER_INT,
  678. USB_ENDPOINT_XFER_INT,
  679. USB_ENDPOINT_XFER_BULK,
  680. USB_ENDPOINT_XFER_BULK,
  681. USB_ENDPOINT_XFER_BULK,
  682. USB_ENDPOINT_XFER_BULK,
  683. USB_ENDPOINT_XFER_BULK,
  684. USB_ENDPOINT_XFER_BULK,
  685. USB_ENDPOINT_XFER_BULK,
  686. };
  687. static struct usbhs_private usbhs1_private = {
  688. .usbphyaddr = IOMEM(0xe60581e2), /* USBPHY1INTAP */
  689. .usbcrcaddr = IOMEM(0xe6058130), /* USBCR4 */
  690. .info = {
  691. .platform_callback = {
  692. .hardware_init = usbhs1_hardware_init,
  693. .hardware_exit = usbhs1_hardware_exit,
  694. .get_id = usbhs1_get_id,
  695. .phy_reset = usbhs_phy_reset,
  696. },
  697. .driver_param = {
  698. .buswait_bwait = 4,
  699. .has_otg = 1,
  700. .pipe_type = usbhs1_pipe_cfg,
  701. .pipe_size = ARRAY_SIZE(usbhs1_pipe_cfg),
  702. .d0_tx_id = SHDMA_SLAVE_USB1_TX,
  703. .d1_rx_id = SHDMA_SLAVE_USB1_RX,
  704. },
  705. },
  706. };
  707. static struct resource usbhs1_resources[] = {
  708. [0] = {
  709. .name = "USBHS1",
  710. .start = 0xe68b0000,
  711. .end = 0xe68b00e6 - 1,
  712. .flags = IORESOURCE_MEM,
  713. },
  714. [1] = {
  715. .start = evt2irq(0x1ce0) /* USB1_USB1I0 */,
  716. .flags = IORESOURCE_IRQ,
  717. },
  718. };
  719. static struct platform_device usbhs1_device = {
  720. .name = "renesas_usbhs",
  721. .id = 1,
  722. .dev = {
  723. .platform_data = &usbhs1_private.info,
  724. .dma_mask = &usbhs1_device.dev.coherent_dma_mask,
  725. .coherent_dma_mask = DMA_BIT_MASK(32),
  726. },
  727. .num_resources = ARRAY_SIZE(usbhs1_resources),
  728. .resource = usbhs1_resources,
  729. };
  730. /* LED */
  731. static struct gpio_led mackerel_leds[] = {
  732. {
  733. .name = "led0",
  734. .gpio = GPIO_PORT0,
  735. .default_state = LEDS_GPIO_DEFSTATE_ON,
  736. },
  737. {
  738. .name = "led1",
  739. .gpio = GPIO_PORT1,
  740. .default_state = LEDS_GPIO_DEFSTATE_ON,
  741. },
  742. {
  743. .name = "led2",
  744. .gpio = GPIO_PORT2,
  745. .default_state = LEDS_GPIO_DEFSTATE_ON,
  746. },
  747. {
  748. .name = "led3",
  749. .gpio = GPIO_PORT159,
  750. .default_state = LEDS_GPIO_DEFSTATE_ON,
  751. }
  752. };
  753. static struct gpio_led_platform_data mackerel_leds_pdata = {
  754. .leds = mackerel_leds,
  755. .num_leds = ARRAY_SIZE(mackerel_leds),
  756. };
  757. static struct platform_device leds_device = {
  758. .name = "leds-gpio",
  759. .id = 0,
  760. .dev = {
  761. .platform_data = &mackerel_leds_pdata,
  762. },
  763. };
  764. /* FSI */
  765. #define IRQ_FSI evt2irq(0x1840)
  766. static struct sh_fsi_platform_info fsi_info = {
  767. .port_a = {
  768. .tx_id = SHDMA_SLAVE_FSIA_TX,
  769. .rx_id = SHDMA_SLAVE_FSIA_RX,
  770. },
  771. .port_b = {
  772. .flags = SH_FSI_CLK_CPG |
  773. SH_FSI_FMT_SPDIF,
  774. }
  775. };
  776. static struct resource fsi_resources[] = {
  777. [0] = {
  778. /* we need 0xFE1F0000 to access DMA
  779. * instead of 0xFE3C0000 */
  780. .name = "FSI",
  781. .start = 0xFE1F0000,
  782. .end = 0xFE1F0400 - 1,
  783. .flags = IORESOURCE_MEM,
  784. },
  785. [1] = {
  786. .start = IRQ_FSI,
  787. .flags = IORESOURCE_IRQ,
  788. },
  789. };
  790. static struct platform_device fsi_device = {
  791. .name = "sh_fsi2",
  792. .id = -1,
  793. .num_resources = ARRAY_SIZE(fsi_resources),
  794. .resource = fsi_resources,
  795. .dev = {
  796. .platform_data = &fsi_info,
  797. },
  798. };
  799. static struct asoc_simple_dai_init_info fsi2_ak4643_init_info = {
  800. .fmt = SND_SOC_DAIFMT_LEFT_J,
  801. .codec_daifmt = SND_SOC_DAIFMT_CBM_CFM,
  802. .cpu_daifmt = SND_SOC_DAIFMT_CBS_CFS,
  803. .sysclk = 11289600,
  804. };
  805. static struct asoc_simple_card_info fsi2_ak4643_info = {
  806. .name = "AK4643",
  807. .card = "FSI2A-AK4643",
  808. .cpu_dai = "fsia-dai",
  809. .codec = "ak4642-codec.0-0013",
  810. .platform = "sh_fsi2",
  811. .codec_dai = "ak4642-hifi",
  812. .init = &fsi2_ak4643_init_info,
  813. };
  814. static struct platform_device fsi_ak4643_device = {
  815. .name = "asoc-simple-card",
  816. .dev = {
  817. .platform_data = &fsi2_ak4643_info,
  818. },
  819. };
  820. /* FLCTL */
  821. static struct mtd_partition nand_partition_info[] = {
  822. {
  823. .name = "system",
  824. .offset = 0,
  825. .size = 128 * 1024 * 1024,
  826. },
  827. {
  828. .name = "userdata",
  829. .offset = MTDPART_OFS_APPEND,
  830. .size = 256 * 1024 * 1024,
  831. },
  832. {
  833. .name = "cache",
  834. .offset = MTDPART_OFS_APPEND,
  835. .size = 128 * 1024 * 1024,
  836. },
  837. };
  838. static struct resource nand_flash_resources[] = {
  839. [0] = {
  840. .start = 0xe6a30000,
  841. .end = 0xe6a3009b,
  842. .flags = IORESOURCE_MEM,
  843. },
  844. [1] = {
  845. .start = evt2irq(0x0d80), /* flstei: status error irq */
  846. .flags = IORESOURCE_IRQ,
  847. },
  848. };
  849. static struct sh_flctl_platform_data nand_flash_data = {
  850. .parts = nand_partition_info,
  851. .nr_parts = ARRAY_SIZE(nand_partition_info),
  852. .flcmncr_val = CLK_16B_12L_4H | TYPESEL_SET
  853. | SHBUSSEL | SEL_16BIT | SNAND_E,
  854. .use_holden = 1,
  855. };
  856. static struct platform_device nand_flash_device = {
  857. .name = "sh_flctl",
  858. .resource = nand_flash_resources,
  859. .num_resources = ARRAY_SIZE(nand_flash_resources),
  860. .dev = {
  861. .platform_data = &nand_flash_data,
  862. },
  863. };
  864. /*
  865. * The card detect pin of the top SD/MMC slot (CN7) is active low and is
  866. * connected to GPIO A22 of SH7372 (GPIO_PORT41).
  867. */
  868. static int slot_cn7_get_cd(struct platform_device *pdev)
  869. {
  870. return !gpio_get_value(GPIO_PORT41);
  871. }
  872. /* SDHI0 */
  873. static struct sh_mobile_sdhi_info sdhi0_info = {
  874. .dma_slave_tx = SHDMA_SLAVE_SDHI0_TX,
  875. .dma_slave_rx = SHDMA_SLAVE_SDHI0_RX,
  876. .tmio_flags = TMIO_MMC_USE_GPIO_CD,
  877. .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ,
  878. .cd_gpio = GPIO_PORT172,
  879. };
  880. static struct resource sdhi0_resources[] = {
  881. [0] = {
  882. .name = "SDHI0",
  883. .start = 0xe6850000,
  884. .end = 0xe68500ff,
  885. .flags = IORESOURCE_MEM,
  886. },
  887. [1] = {
  888. .start = evt2irq(0x0e00) /* SDHI0_SDHI0I0 */,
  889. .flags = IORESOURCE_IRQ,
  890. },
  891. [2] = {
  892. .start = evt2irq(0x0e20) /* SDHI0_SDHI0I1 */,
  893. .flags = IORESOURCE_IRQ,
  894. },
  895. [3] = {
  896. .start = evt2irq(0x0e40) /* SDHI0_SDHI0I2 */,
  897. .flags = IORESOURCE_IRQ,
  898. },
  899. };
  900. static struct platform_device sdhi0_device = {
  901. .name = "sh_mobile_sdhi",
  902. .num_resources = ARRAY_SIZE(sdhi0_resources),
  903. .resource = sdhi0_resources,
  904. .id = 0,
  905. .dev = {
  906. .platform_data = &sdhi0_info,
  907. },
  908. };
  909. #if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE)
  910. /* SDHI1 */
  911. static struct sh_mobile_sdhi_info sdhi1_info = {
  912. .dma_slave_tx = SHDMA_SLAVE_SDHI1_TX,
  913. .dma_slave_rx = SHDMA_SLAVE_SDHI1_RX,
  914. .tmio_ocr_mask = MMC_VDD_165_195,
  915. .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE,
  916. .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |
  917. MMC_CAP_NEEDS_POLL,
  918. .get_cd = slot_cn7_get_cd,
  919. };
  920. static struct resource sdhi1_resources[] = {
  921. [0] = {
  922. .name = "SDHI1",
  923. .start = 0xe6860000,
  924. .end = 0xe68600ff,
  925. .flags = IORESOURCE_MEM,
  926. },
  927. [1] = {
  928. .name = SH_MOBILE_SDHI_IRQ_CARD_DETECT,
  929. .start = evt2irq(0x0e80), /* SDHI1_SDHI1I0 */
  930. .flags = IORESOURCE_IRQ,
  931. },
  932. [2] = {
  933. .name = SH_MOBILE_SDHI_IRQ_SDCARD,
  934. .start = evt2irq(0x0ea0), /* SDHI1_SDHI1I1 */
  935. .flags = IORESOURCE_IRQ,
  936. },
  937. [3] = {
  938. .name = SH_MOBILE_SDHI_IRQ_SDIO,
  939. .start = evt2irq(0x0ec0), /* SDHI1_SDHI1I2 */
  940. .flags = IORESOURCE_IRQ,
  941. },
  942. };
  943. static struct platform_device sdhi1_device = {
  944. .name = "sh_mobile_sdhi",
  945. .num_resources = ARRAY_SIZE(sdhi1_resources),
  946. .resource = sdhi1_resources,
  947. .id = 1,
  948. .dev = {
  949. .platform_data = &sdhi1_info,
  950. },
  951. };
  952. #endif
  953. /*
  954. * The card detect pin of the top SD/MMC slot (CN23) is active low and is
  955. * connected to GPIO SCIFB_SCK of SH7372 (GPIO_PORT162).
  956. */
  957. static int slot_cn23_get_cd(struct platform_device *pdev)
  958. {
  959. return !gpio_get_value(GPIO_PORT162);
  960. }
  961. /* SDHI2 */
  962. static struct sh_mobile_sdhi_info sdhi2_info = {
  963. .dma_slave_tx = SHDMA_SLAVE_SDHI2_TX,
  964. .dma_slave_rx = SHDMA_SLAVE_SDHI2_RX,
  965. .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE,
  966. .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |
  967. MMC_CAP_NEEDS_POLL,
  968. .get_cd = slot_cn23_get_cd,
  969. };
  970. static struct resource sdhi2_resources[] = {
  971. [0] = {
  972. .name = "SDHI2",
  973. .start = 0xe6870000,
  974. .end = 0xe68700ff,
  975. .flags = IORESOURCE_MEM,
  976. },
  977. [1] = {
  978. .name = SH_MOBILE_SDHI_IRQ_CARD_DETECT,
  979. .start = evt2irq(0x1200), /* SDHI2_SDHI2I0 */
  980. .flags = IORESOURCE_IRQ,
  981. },
  982. [2] = {
  983. .name = SH_MOBILE_SDHI_IRQ_SDCARD,
  984. .start = evt2irq(0x1220), /* SDHI2_SDHI2I1 */
  985. .flags = IORESOURCE_IRQ,
  986. },
  987. [3] = {
  988. .name = SH_MOBILE_SDHI_IRQ_SDIO,
  989. .start = evt2irq(0x1240), /* SDHI2_SDHI2I2 */
  990. .flags = IORESOURCE_IRQ,
  991. },
  992. };
  993. static struct platform_device sdhi2_device = {
  994. .name = "sh_mobile_sdhi",
  995. .num_resources = ARRAY_SIZE(sdhi2_resources),
  996. .resource = sdhi2_resources,
  997. .id = 2,
  998. .dev = {
  999. .platform_data = &sdhi2_info,
  1000. },
  1001. };
  1002. /* SH_MMCIF */
  1003. static struct resource sh_mmcif_resources[] = {
  1004. [0] = {
  1005. .name = "MMCIF",
  1006. .start = 0xE6BD0000,
  1007. .end = 0xE6BD00FF,
  1008. .flags = IORESOURCE_MEM,
  1009. },
  1010. [1] = {
  1011. /* MMC ERR */
  1012. .start = evt2irq(0x1ac0),
  1013. .flags = IORESOURCE_IRQ,
  1014. },
  1015. [2] = {
  1016. /* MMC NOR */
  1017. .start = evt2irq(0x1ae0),
  1018. .flags = IORESOURCE_IRQ,
  1019. },
  1020. };
  1021. static struct sh_mmcif_plat_data sh_mmcif_plat = {
  1022. .sup_pclk = 0,
  1023. .ocr = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34,
  1024. .caps = MMC_CAP_4_BIT_DATA |
  1025. MMC_CAP_8_BIT_DATA |
  1026. MMC_CAP_NEEDS_POLL,
  1027. .get_cd = slot_cn7_get_cd,
  1028. .slave_id_tx = SHDMA_SLAVE_MMCIF_TX,
  1029. .slave_id_rx = SHDMA_SLAVE_MMCIF_RX,
  1030. };
  1031. static struct platform_device sh_mmcif_device = {
  1032. .name = "sh_mmcif",
  1033. .id = 0,
  1034. .dev = {
  1035. .dma_mask = NULL,
  1036. .coherent_dma_mask = 0xffffffff,
  1037. .platform_data = &sh_mmcif_plat,
  1038. },
  1039. .num_resources = ARRAY_SIZE(sh_mmcif_resources),
  1040. .resource = sh_mmcif_resources,
  1041. };
  1042. static int mackerel_camera_add(struct soc_camera_device *icd);
  1043. static void mackerel_camera_del(struct soc_camera_device *icd);
  1044. static int camera_set_capture(struct soc_camera_platform_info *info,
  1045. int enable)
  1046. {
  1047. return 0; /* camera sensor always enabled */
  1048. }
  1049. static struct soc_camera_platform_info camera_info = {
  1050. .format_name = "UYVY",
  1051. .format_depth = 16,
  1052. .format = {
  1053. .code = V4L2_MBUS_FMT_UYVY8_2X8,
  1054. .colorspace = V4L2_COLORSPACE_SMPTE170M,
  1055. .field = V4L2_FIELD_NONE,
  1056. .width = 640,
  1057. .height = 480,
  1058. },
  1059. .mbus_param = V4L2_MBUS_PCLK_SAMPLE_RISING | V4L2_MBUS_MASTER |
  1060. V4L2_MBUS_VSYNC_ACTIVE_HIGH | V4L2_MBUS_HSYNC_ACTIVE_HIGH |
  1061. V4L2_MBUS_DATA_ACTIVE_HIGH,
  1062. .mbus_type = V4L2_MBUS_PARALLEL,
  1063. .set_capture = camera_set_capture,
  1064. };
  1065. static struct soc_camera_link camera_link = {
  1066. .bus_id = 0,
  1067. .add_device = mackerel_camera_add,
  1068. .del_device = mackerel_camera_del,
  1069. .module_name = "soc_camera_platform",
  1070. .priv = &camera_info,
  1071. };
  1072. static struct platform_device *camera_device;
  1073. static void mackerel_camera_release(struct device *dev)
  1074. {
  1075. soc_camera_platform_release(&camera_device);
  1076. }
  1077. static int mackerel_camera_add(struct soc_camera_device *icd)
  1078. {
  1079. return soc_camera_platform_add(icd, &camera_device, &camera_link,
  1080. mackerel_camera_release, 0);
  1081. }
  1082. static void mackerel_camera_del(struct soc_camera_device *icd)
  1083. {
  1084. soc_camera_platform_del(icd, camera_device, &camera_link);
  1085. }
  1086. static struct sh_mobile_ceu_info sh_mobile_ceu_info = {
  1087. .flags = SH_CEU_FLAG_USE_8BIT_BUS,
  1088. .max_width = 8188,
  1089. .max_height = 8188,
  1090. };
  1091. static struct resource ceu_resources[] = {
  1092. [0] = {
  1093. .name = "CEU",
  1094. .start = 0xfe910000,
  1095. .end = 0xfe91009f,
  1096. .flags = IORESOURCE_MEM,
  1097. },
  1098. [1] = {
  1099. .start = intcs_evt2irq(0x880),
  1100. .flags = IORESOURCE_IRQ,
  1101. },
  1102. [2] = {
  1103. /* place holder for contiguous memory */
  1104. },
  1105. };
  1106. static struct platform_device ceu_device = {
  1107. .name = "sh_mobile_ceu",
  1108. .id = 0, /* "ceu0" clock */
  1109. .num_resources = ARRAY_SIZE(ceu_resources),
  1110. .resource = ceu_resources,
  1111. .dev = {
  1112. .platform_data = &sh_mobile_ceu_info,
  1113. .coherent_dma_mask = 0xffffffff,
  1114. },
  1115. };
  1116. static struct platform_device mackerel_camera = {
  1117. .name = "soc-camera-pdrv",
  1118. .id = 0,
  1119. .dev = {
  1120. .platform_data = &camera_link,
  1121. },
  1122. };
  1123. static struct platform_device *mackerel_devices[] __initdata = {
  1124. &nor_flash_device,
  1125. &smc911x_device,
  1126. &lcdc_device,
  1127. &usbhs0_device,
  1128. &usbhs1_device,
  1129. &leds_device,
  1130. &fsi_device,
  1131. &fsi_ak4643_device,
  1132. &fsi_hdmi_device,
  1133. &nand_flash_device,
  1134. &sdhi0_device,
  1135. #if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE)
  1136. &sdhi1_device,
  1137. #endif
  1138. &sdhi2_device,
  1139. &sh_mmcif_device,
  1140. &ceu_device,
  1141. &mackerel_camera,
  1142. &hdmi_device,
  1143. &hdmi_lcdc_device,
  1144. &meram_device,
  1145. };
  1146. /* Keypad Initialization */
  1147. #define KEYPAD_BUTTON(ev_type, ev_code, act_low) \
  1148. { \
  1149. .type = ev_type, \
  1150. .code = ev_code, \
  1151. .active_low = act_low, \
  1152. }
  1153. #define KEYPAD_BUTTON_LOW(event_code) KEYPAD_BUTTON(EV_KEY, event_code, 1)
  1154. static struct tca6416_button mackerel_gpio_keys[] = {
  1155. KEYPAD_BUTTON_LOW(KEY_HOME),
  1156. KEYPAD_BUTTON_LOW(KEY_MENU),
  1157. KEYPAD_BUTTON_LOW(KEY_BACK),
  1158. KEYPAD_BUTTON_LOW(KEY_POWER),
  1159. };
  1160. static struct tca6416_keys_platform_data mackerel_tca6416_keys_info = {
  1161. .buttons = mackerel_gpio_keys,
  1162. .nbuttons = ARRAY_SIZE(mackerel_gpio_keys),
  1163. .rep = 1,
  1164. .use_polling = 0,
  1165. .pinmask = 0x000F,
  1166. };
  1167. /* I2C */
  1168. #define IRQ7 evt2irq(0x02e0)
  1169. #define IRQ9 evt2irq(0x0320)
  1170. static struct i2c_board_info i2c0_devices[] = {
  1171. {
  1172. I2C_BOARD_INFO("ak4643", 0x13),
  1173. },
  1174. /* Keypad */
  1175. {
  1176. I2C_BOARD_INFO("tca6408-keys", 0x20),
  1177. .platform_data = &mackerel_tca6416_keys_info,
  1178. .irq = IRQ9,
  1179. },
  1180. /* Touchscreen */
  1181. {
  1182. I2C_BOARD_INFO("st1232-ts", 0x55),
  1183. .irq = IRQ7,
  1184. },
  1185. };
  1186. #define IRQ21 evt2irq(0x32a0)
  1187. static struct i2c_board_info i2c1_devices[] = {
  1188. /* Accelerometer */
  1189. {
  1190. I2C_BOARD_INFO("adxl34x", 0x53),
  1191. .irq = IRQ21,
  1192. },
  1193. };
  1194. #define GPIO_PORT9CR IOMEM(0xE6051009)
  1195. #define GPIO_PORT10CR IOMEM(0xE605100A)
  1196. #define GPIO_PORT167CR IOMEM(0xE60520A7)
  1197. #define GPIO_PORT168CR IOMEM(0xE60520A8)
  1198. #define SRCR4 IOMEM(0xe61580bc)
  1199. #define USCCR1 IOMEM(0xE6058144)
  1200. static void __init mackerel_init(void)
  1201. {
  1202. struct pm_domain_device domain_devices[] = {
  1203. { "A4LC", &lcdc_device, },
  1204. { "A4LC", &hdmi_lcdc_device, },
  1205. { "A4LC", &meram_device, },
  1206. { "A4MP", &fsi_device, },
  1207. { "A3SP", &usbhs0_device, },
  1208. { "A3SP", &usbhs1_device, },
  1209. { "A3SP", &nand_flash_device, },
  1210. { "A3SP", &sh_mmcif_device, },
  1211. { "A3SP", &sdhi0_device, },
  1212. #if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE)
  1213. { "A3SP", &sdhi1_device, },
  1214. #endif
  1215. { "A3SP", &sdhi2_device, },
  1216. { "A4R", &ceu_device, },
  1217. };
  1218. u32 srcr4;
  1219. struct clk *clk;
  1220. regulator_register_always_on(0, "fixed-1.8V", fixed1v8_power_consumers,
  1221. ARRAY_SIZE(fixed1v8_power_consumers), 1800000);
  1222. regulator_register_always_on(1, "fixed-3.3V", fixed3v3_power_consumers,
  1223. ARRAY_SIZE(fixed3v3_power_consumers), 3300000);
  1224. regulator_register_fixed(2, dummy_supplies, ARRAY_SIZE(dummy_supplies));
  1225. /* External clock source */
  1226. clk_set_rate(&sh7372_dv_clki_clk, 27000000);
  1227. sh7372_pinmux_init();
  1228. /* enable SCIFA0 */
  1229. gpio_request(GPIO_FN_SCIFA0_TXD, NULL);
  1230. gpio_request(GPIO_FN_SCIFA0_RXD, NULL);
  1231. /* enable SMSC911X */
  1232. gpio_request(GPIO_FN_CS5A, NULL);
  1233. gpio_request(GPIO_FN_IRQ6_39, NULL);
  1234. /* LCDC */
  1235. gpio_request(GPIO_FN_LCDD23, NULL);
  1236. gpio_request(GPIO_FN_LCDD22, NULL);
  1237. gpio_request(GPIO_FN_LCDD21, NULL);
  1238. gpio_request(GPIO_FN_LCDD20, NULL);
  1239. gpio_request(GPIO_FN_LCDD19, NULL);
  1240. gpio_request(GPIO_FN_LCDD18, NULL);
  1241. gpio_request(GPIO_FN_LCDD17, NULL);
  1242. gpio_request(GPIO_FN_LCDD16, NULL);
  1243. gpio_request(GPIO_FN_LCDD15, NULL);
  1244. gpio_request(GPIO_FN_LCDD14, NULL);
  1245. gpio_request(GPIO_FN_LCDD13, NULL);
  1246. gpio_request(GPIO_FN_LCDD12, NULL);
  1247. gpio_request(GPIO_FN_LCDD11, NULL);
  1248. gpio_request(GPIO_FN_LCDD10, NULL);
  1249. gpio_request(GPIO_FN_LCDD9, NULL);
  1250. gpio_request(GPIO_FN_LCDD8, NULL);
  1251. gpio_request(GPIO_FN_LCDD7, NULL);
  1252. gpio_request(GPIO_FN_LCDD6, NULL);
  1253. gpio_request(GPIO_FN_LCDD5, NULL);
  1254. gpio_request(GPIO_FN_LCDD4, NULL);
  1255. gpio_request(GPIO_FN_LCDD3, NULL);
  1256. gpio_request(GPIO_FN_LCDD2, NULL);
  1257. gpio_request(GPIO_FN_LCDD1, NULL);
  1258. gpio_request(GPIO_FN_LCDD0, NULL);
  1259. gpio_request(GPIO_FN_LCDDISP, NULL);
  1260. gpio_request(GPIO_FN_LCDDCK, NULL);
  1261. gpio_request(GPIO_PORT31, NULL); /* backlight */
  1262. gpio_direction_output(GPIO_PORT31, 0); /* off by default */
  1263. gpio_request(GPIO_PORT151, NULL); /* LCDDON */
  1264. gpio_direction_output(GPIO_PORT151, 1);
  1265. /* USBHS0 */
  1266. gpio_request(GPIO_FN_VBUS0_0, NULL);
  1267. gpio_request_pulldown(GPIO_PORT168CR); /* VBUS0_0 pull down */
  1268. /* USBHS1 */
  1269. gpio_request(GPIO_FN_VBUS0_1, NULL);
  1270. gpio_request_pulldown(GPIO_PORT167CR); /* VBUS0_1 pull down */
  1271. gpio_request(GPIO_FN_IDIN_1_113, NULL);
  1272. /* enable FSI2 port A (ak4643) */
  1273. gpio_request(GPIO_FN_FSIAIBT, NULL);
  1274. gpio_request(GPIO_FN_FSIAILR, NULL);
  1275. gpio_request(GPIO_FN_FSIAISLD, NULL);
  1276. gpio_request(GPIO_FN_FSIAOSLD, NULL);
  1277. gpio_request(GPIO_PORT161, NULL);
  1278. gpio_direction_output(GPIO_PORT161, 0); /* slave */
  1279. gpio_request(GPIO_PORT9, NULL);
  1280. gpio_request(GPIO_PORT10, NULL);
  1281. gpio_direction_none(GPIO_PORT9CR); /* FSIAOBT needs no direction */
  1282. gpio_direction_none(GPIO_PORT10CR); /* FSIAOLR needs no direction */
  1283. intc_set_priority(IRQ_FSI, 3); /* irq priority FSI(3) > SMSC911X(2) */
  1284. /* setup FSI2 port B (HDMI) */
  1285. gpio_request(GPIO_FN_FSIBCK, NULL);
  1286. __raw_writew(__raw_readw(USCCR1) & ~(1 << 6), USCCR1); /* use SPDIF */
  1287. /* set SPU2 clock to 119.6 MHz */
  1288. clk = clk_get(NULL, "spu_clk");
  1289. if (!IS_ERR(clk)) {
  1290. clk_set_rate(clk, clk_round_rate(clk, 119600000));
  1291. clk_put(clk);
  1292. }
  1293. /* enable Keypad */
  1294. gpio_request(GPIO_FN_IRQ9_42, NULL);
  1295. irq_set_irq_type(IRQ9, IRQ_TYPE_LEVEL_HIGH);
  1296. /* enable Touchscreen */
  1297. gpio_request(GPIO_FN_IRQ7_40, NULL);
  1298. irq_set_irq_type(IRQ7, IRQ_TYPE_LEVEL_LOW);
  1299. /* enable Accelerometer */
  1300. gpio_request(GPIO_FN_IRQ21, NULL);
  1301. irq_set_irq_type(IRQ21, IRQ_TYPE_LEVEL_HIGH);
  1302. /* enable SDHI0 */
  1303. gpio_request(GPIO_FN_SDHIWP0, NULL);
  1304. gpio_request(GPIO_FN_SDHICMD0, NULL);
  1305. gpio_request(GPIO_FN_SDHICLK0, NULL);
  1306. gpio_request(GPIO_FN_SDHID0_3, NULL);
  1307. gpio_request(GPIO_FN_SDHID0_2, NULL);
  1308. gpio_request(GPIO_FN_SDHID0_1, NULL);
  1309. gpio_request(GPIO_FN_SDHID0_0, NULL);
  1310. /* SDHI0 PORT172 card-detect IRQ26 */
  1311. gpio_request(GPIO_FN_IRQ26_172, NULL);
  1312. #if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE)
  1313. /* enable SDHI1 */
  1314. gpio_request(GPIO_FN_SDHICMD1, NULL);
  1315. gpio_request(GPIO_FN_SDHICLK1, NULL);
  1316. gpio_request(GPIO_FN_SDHID1_3, NULL);
  1317. gpio_request(GPIO_FN_SDHID1_2, NULL);
  1318. gpio_request(GPIO_FN_SDHID1_1, NULL);
  1319. gpio_request(GPIO_FN_SDHID1_0, NULL);
  1320. #endif
  1321. /* card detect pin for MMC slot (CN7) */
  1322. gpio_request(GPIO_PORT41, NULL);
  1323. gpio_direction_input(GPIO_PORT41);
  1324. /* enable SDHI2 */
  1325. gpio_request(GPIO_FN_SDHICMD2, NULL);
  1326. gpio_request(GPIO_FN_SDHICLK2, NULL);
  1327. gpio_request(GPIO_FN_SDHID2_3, NULL);
  1328. gpio_request(GPIO_FN_SDHID2_2, NULL);
  1329. gpio_request(GPIO_FN_SDHID2_1, NULL);
  1330. gpio_request(GPIO_FN_SDHID2_0, NULL);
  1331. /* card detect pin for microSD slot (CN23) */
  1332. gpio_request(GPIO_PORT162, NULL);
  1333. gpio_direction_input(GPIO_PORT162);
  1334. /* MMCIF */
  1335. gpio_request(GPIO_FN_MMCD0_0, NULL);
  1336. gpio_request(GPIO_FN_MMCD0_1, NULL);
  1337. gpio_request(GPIO_FN_MMCD0_2, NULL);
  1338. gpio_request(GPIO_FN_MMCD0_3, NULL);
  1339. gpio_request(GPIO_FN_MMCD0_4, NULL);
  1340. gpio_request(GPIO_FN_MMCD0_5, NULL);
  1341. gpio_request(GPIO_FN_MMCD0_6, NULL);
  1342. gpio_request(GPIO_FN_MMCD0_7, NULL);
  1343. gpio_request(GPIO_FN_MMCCMD0, NULL);
  1344. gpio_request(GPIO_FN_MMCCLK0, NULL);
  1345. /* FLCTL */
  1346. gpio_request(GPIO_FN_D0_NAF0, NULL);
  1347. gpio_request(GPIO_FN_D1_NAF1, NULL);
  1348. gpio_request(GPIO_FN_D2_NAF2, NULL);
  1349. gpio_request(GPIO_FN_D3_NAF3, NULL);
  1350. gpio_request(GPIO_FN_D4_NAF4, NULL);
  1351. gpio_request(GPIO_FN_D5_NAF5, NULL);
  1352. gpio_request(GPIO_FN_D6_NAF6, NULL);
  1353. gpio_request(GPIO_FN_D7_NAF7, NULL);
  1354. gpio_request(GPIO_FN_D8_NAF8, NULL);
  1355. gpio_request(GPIO_FN_D9_NAF9, NULL);
  1356. gpio_request(GPIO_FN_D10_NAF10, NULL);
  1357. gpio_request(GPIO_FN_D11_NAF11, NULL);
  1358. gpio_request(GPIO_FN_D12_NAF12, NULL);
  1359. gpio_request(GPIO_FN_D13_NAF13, NULL);
  1360. gpio_request(GPIO_FN_D14_NAF14, NULL);
  1361. gpio_request(GPIO_FN_D15_NAF15, NULL);
  1362. gpio_request(GPIO_FN_FCE0, NULL);
  1363. gpio_request(GPIO_FN_WE0_FWE, NULL);
  1364. gpio_request(GPIO_FN_FRB, NULL);
  1365. gpio_request(GPIO_FN_A4_FOE, NULL);
  1366. gpio_request(GPIO_FN_A5_FCDE, NULL);
  1367. gpio_request(GPIO_FN_RD_FSC, NULL);
  1368. /* enable GPS module (GT-720F) */
  1369. gpio_request(GPIO_FN_SCIFA2_TXD1, NULL);
  1370. gpio_request(GPIO_FN_SCIFA2_RXD1, NULL);
  1371. /* CEU */
  1372. gpio_request(GPIO_FN_VIO_CLK, NULL);
  1373. gpio_request(GPIO_FN_VIO_VD, NULL);
  1374. gpio_request(GPIO_FN_VIO_HD, NULL);
  1375. gpio_request(GPIO_FN_VIO_FIELD, NULL);
  1376. gpio_request(GPIO_FN_VIO_CKO, NULL);
  1377. gpio_request(GPIO_FN_VIO_D7, NULL);
  1378. gpio_request(GPIO_FN_VIO_D6, NULL);
  1379. gpio_request(GPIO_FN_VIO_D5, NULL);
  1380. gpio_request(GPIO_FN_VIO_D4, NULL);
  1381. gpio_request(GPIO_FN_VIO_D3, NULL);
  1382. gpio_request(GPIO_FN_VIO_D2, NULL);
  1383. gpio_request(GPIO_FN_VIO_D1, NULL);
  1384. gpio_request(GPIO_FN_VIO_D0, NULL);
  1385. /* HDMI */
  1386. gpio_request(GPIO_FN_HDMI_HPD, NULL);
  1387. gpio_request(GPIO_FN_HDMI_CEC, NULL);
  1388. /* Reset HDMI, must be held at least one EXTALR (32768Hz) period */
  1389. srcr4 = __raw_readl(SRCR4);
  1390. __raw_writel(srcr4 | (1 << 13), SRCR4);
  1391. udelay(50);
  1392. __raw_writel(srcr4 & ~(1 << 13), SRCR4);
  1393. i2c_register_board_info(0, i2c0_devices,
  1394. ARRAY_SIZE(i2c0_devices));
  1395. i2c_register_board_info(1, i2c1_devices,
  1396. ARRAY_SIZE(i2c1_devices));
  1397. sh7372_add_standard_devices();
  1398. platform_add_devices(mackerel_devices, ARRAY_SIZE(mackerel_devices));
  1399. rmobile_add_devices_to_domains(domain_devices,
  1400. ARRAY_SIZE(domain_devices));
  1401. hdmi_init_pm_clock();
  1402. sh7372_pm_init();
  1403. pm_clk_add(&fsi_device.dev, "spu2");
  1404. pm_clk_add(&hdmi_lcdc_device.dev, "hdmi");
  1405. }
  1406. static const char *mackerel_boards_compat_dt[] __initdata = {
  1407. "renesas,mackerel",
  1408. NULL,
  1409. };
  1410. DT_MACHINE_START(MACKEREL_DT, "mackerel")
  1411. .map_io = sh7372_map_io,
  1412. .init_early = sh7372_add_early_devices,
  1413. .init_irq = sh7372_init_irq,
  1414. .handle_irq = shmobile_handle_irq_intc,
  1415. .init_machine = mackerel_init,
  1416. .init_late = sh7372_pm_init_late,
  1417. .timer = &shmobile_timer,
  1418. .dt_compat = mackerel_boards_compat_dt,
  1419. MACHINE_END