board-mackerel.c 39 KB

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