board-mackerel.c 39 KB

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