board-mackerel.c 40 KB

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