board-mackerel.c 40 KB

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