board-mackerel.c 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963
  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/kernel.h>
  25. #include <linux/init.h>
  26. #include <linux/interrupt.h>
  27. #include <linux/irq.h>
  28. #include <linux/platform_device.h>
  29. #include <linux/gpio.h>
  30. #include <linux/input.h>
  31. #include <linux/io.h>
  32. #include <linux/i2c.h>
  33. #include <linux/leds.h>
  34. #include <linux/mfd/sh_mobile_sdhi.h>
  35. #include <linux/mfd/tmio.h>
  36. #include <linux/mmc/host.h>
  37. #include <linux/mmc/sh_mmcif.h>
  38. #include <linux/mtd/mtd.h>
  39. #include <linux/mtd/partitions.h>
  40. #include <linux/mtd/physmap.h>
  41. #include <linux/smsc911x.h>
  42. #include <linux/sh_intc.h>
  43. #include <linux/tca6416_keypad.h>
  44. #include <linux/usb/r8a66597.h>
  45. #include <video/sh_mobile_lcdc.h>
  46. #include <media/sh_mobile_ceu.h>
  47. #include <media/soc_camera.h>
  48. #include <media/soc_camera_platform.h>
  49. #include <sound/sh_fsi.h>
  50. #include <mach/common.h>
  51. #include <mach/sh7372.h>
  52. #include <asm/mach/arch.h>
  53. #include <asm/mach/time.h>
  54. #include <asm/mach/map.h>
  55. #include <asm/mach-types.h>
  56. /*
  57. * Address Interface BusWidth note
  58. * ------------------------------------------------------------------
  59. * 0x0000_0000 NOR Flash ROM (MCP) 16bit SW7 : bit1 = ON
  60. * 0x0800_0000 user area -
  61. * 0x1000_0000 NOR Flash ROM (MCP) 16bit SW7 : bit1 = OFF
  62. * 0x1400_0000 Ether (LAN9220) 16bit
  63. * 0x1600_0000 user area - cannot use with NAND
  64. * 0x1800_0000 user area -
  65. * 0x1A00_0000 -
  66. * 0x4000_0000 LPDDR2-SDRAM (POP) 32bit
  67. */
  68. /*
  69. * CPU mode
  70. *
  71. * SW4 | Boot Area| Master | Remarks
  72. * 1 | 2 | 3 | 4 | 5 | 6 | 8 | | Processor|
  73. * ----+-----+-----+-----+-----+-----+-----+----------+----------+--------------
  74. * ON | ON | OFF | ON | ON | OFF | OFF | External | System | External ROM
  75. * ON | ON | ON | ON | ON | OFF | OFF | External | System | ROM Debug
  76. * ON | ON | X | ON | OFF | OFF | OFF | Built-in | System | ROM Debug
  77. * X | OFF | X | X | X | X | OFF | Built-in | System | MaskROM
  78. * OFF | X | X | X | X | X | OFF | Built-in | System | MaskROM
  79. * X | X | X | OFF | X | X | OFF | Built-in | System | MaskROM
  80. * OFF | ON | OFF | X | X | OFF | ON | External | System | Standalone
  81. * ON | OFF | OFF | X | X | OFF | ON | External | Realtime | Standalone
  82. */
  83. /*
  84. * NOR Flash ROM
  85. *
  86. * SW1 | SW2 | SW7 | NOR Flash ROM
  87. * bit1 | bit1 bit2 | bit1 | Memory allocation
  88. * ------+------------+------+------------------
  89. * OFF | ON OFF | ON | Area 0
  90. * OFF | ON OFF | OFF | Area 4
  91. */
  92. /*
  93. * SMSC 9220
  94. *
  95. * SW1 SMSC 9220
  96. * -----------------------
  97. * ON access disable
  98. * OFF access enable
  99. */
  100. /*
  101. * NAND Flash ROM
  102. *
  103. * SW1 | SW2 | SW7 | NAND Flash ROM
  104. * bit1 | bit1 bit2 | bit2 | Memory allocation
  105. * ------+------------+------+------------------
  106. * OFF | ON OFF | ON | FCE 0
  107. * OFF | ON OFF | OFF | FCE 1
  108. */
  109. /*
  110. * External interrupt pin settings
  111. *
  112. * IRQX | pin setting | device | level
  113. * ------+--------------------+--------------------+-------
  114. * IRQ0 | ICR1A.IRQ0SA=0010 | SDHI2 card detect | Low
  115. * IRQ6 | ICR1A.IRQ6SA=0011 | Ether(LAN9220) | High
  116. * IRQ7 | ICR1A.IRQ7SA=0010 | LCD Tuch Panel | Low
  117. * IRQ8 | ICR2A.IRQ8SA=0010 | MMC/SD card detect | Low
  118. * IRQ9 | ICR2A.IRQ9SA=0010 | KEY(TCA6408) | Low
  119. * IRQ21 | ICR4A.IRQ21SA=0011 | Sensor(ADXL345) | High
  120. * IRQ22 | ICR4A.IRQ22SA=0011 | Sensor(AK8975) | High
  121. */
  122. /*
  123. * USB
  124. *
  125. * USB0 : CN22 : Function
  126. * USB1 : CN31 : Function/Host *1
  127. *
  128. * J30 (for CN31) *1
  129. * ----------+---------------+-------------
  130. * 1-2 short | VBUS 5V | Host
  131. * open | external VBUS | Function
  132. *
  133. * *1
  134. * CN31 is used as Host in Linux.
  135. */
  136. /*
  137. * SDHI0 (CN12)
  138. *
  139. * SW56 : OFF
  140. *
  141. */
  142. /* MMC /SDHI1 (CN7)
  143. *
  144. * I/O voltage : 1.8v
  145. *
  146. * Power voltage : 1.8v or 3.3v
  147. * J22 : select power voltage *1
  148. * 1-2 pin : 1.8v
  149. * 2-3 pin : 3.3v
  150. *
  151. * *1
  152. * Please change J22 depends the card to be used.
  153. * MMC's OCR field set to support either voltage for the card inserted.
  154. *
  155. * SW1 | SW33
  156. * | bit1 | bit2 | bit3 | bit4
  157. * -------------+------+------+------+-------
  158. * MMC0 OFF | OFF | ON | ON | X
  159. * MMC1 ON | OFF | ON | X | ON
  160. * SDHI1 OFF | ON | X | OFF | ON
  161. *
  162. */
  163. /*
  164. * SDHI2 (CN23)
  165. *
  166. * microSD card sloct
  167. *
  168. */
  169. /*
  170. * FIXME !!
  171. *
  172. * gpio_no_direction
  173. * are quick_hack.
  174. *
  175. * current gpio frame work doesn't have
  176. * the method to control only pull up/down/free.
  177. * this function should be replaced by correct gpio function
  178. */
  179. static void __init gpio_no_direction(u32 addr)
  180. {
  181. __raw_writeb(0x00, addr);
  182. }
  183. /* MTD */
  184. static struct mtd_partition nor_flash_partitions[] = {
  185. {
  186. .name = "loader",
  187. .offset = 0x00000000,
  188. .size = 512 * 1024,
  189. .mask_flags = MTD_WRITEABLE,
  190. },
  191. {
  192. .name = "bootenv",
  193. .offset = MTDPART_OFS_APPEND,
  194. .size = 512 * 1024,
  195. .mask_flags = MTD_WRITEABLE,
  196. },
  197. {
  198. .name = "kernel_ro",
  199. .offset = MTDPART_OFS_APPEND,
  200. .size = 8 * 1024 * 1024,
  201. .mask_flags = MTD_WRITEABLE,
  202. },
  203. {
  204. .name = "kernel",
  205. .offset = MTDPART_OFS_APPEND,
  206. .size = 8 * 1024 * 1024,
  207. },
  208. {
  209. .name = "data",
  210. .offset = MTDPART_OFS_APPEND,
  211. .size = MTDPART_SIZ_FULL,
  212. },
  213. };
  214. static struct physmap_flash_data nor_flash_data = {
  215. .width = 2,
  216. .parts = nor_flash_partitions,
  217. .nr_parts = ARRAY_SIZE(nor_flash_partitions),
  218. };
  219. static struct resource nor_flash_resources[] = {
  220. [0] = {
  221. .start = 0x00000000,
  222. .end = 0x08000000 - 1,
  223. .flags = IORESOURCE_MEM,
  224. }
  225. };
  226. static struct platform_device nor_flash_device = {
  227. .name = "physmap-flash",
  228. .dev = {
  229. .platform_data = &nor_flash_data,
  230. },
  231. .num_resources = ARRAY_SIZE(nor_flash_resources),
  232. .resource = nor_flash_resources,
  233. };
  234. /* SMSC */
  235. static struct resource smc911x_resources[] = {
  236. {
  237. .start = 0x14000000,
  238. .end = 0x16000000 - 1,
  239. .flags = IORESOURCE_MEM,
  240. }, {
  241. .start = evt2irq(0x02c0) /* IRQ6A */,
  242. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
  243. },
  244. };
  245. static struct smsc911x_platform_config smsc911x_info = {
  246. .flags = SMSC911X_USE_16BIT | SMSC911X_SAVE_MAC_ADDRESS,
  247. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
  248. .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
  249. };
  250. static struct platform_device smc911x_device = {
  251. .name = "smsc911x",
  252. .id = -1,
  253. .num_resources = ARRAY_SIZE(smc911x_resources),
  254. .resource = smc911x_resources,
  255. .dev = {
  256. .platform_data = &smsc911x_info,
  257. },
  258. };
  259. /* LCDC */
  260. static struct fb_videomode mackerel_lcdc_modes[] = {
  261. {
  262. .name = "WVGA Panel",
  263. .xres = 800,
  264. .yres = 480,
  265. .left_margin = 220,
  266. .right_margin = 110,
  267. .hsync_len = 70,
  268. .upper_margin = 20,
  269. .lower_margin = 5,
  270. .vsync_len = 5,
  271. .sync = 0,
  272. },
  273. };
  274. static struct sh_mobile_lcdc_info lcdc_info = {
  275. .clock_source = LCDC_CLK_BUS,
  276. .ch[0] = {
  277. .chan = LCDC_CHAN_MAINLCD,
  278. .bpp = 16,
  279. .lcd_cfg = mackerel_lcdc_modes,
  280. .num_cfg = ARRAY_SIZE(mackerel_lcdc_modes),
  281. .interface_type = RGB24,
  282. .clock_divider = 2,
  283. .flags = 0,
  284. .lcd_size_cfg.width = 152,
  285. .lcd_size_cfg.height = 91,
  286. }
  287. };
  288. static struct resource lcdc_resources[] = {
  289. [0] = {
  290. .name = "LCDC",
  291. .start = 0xfe940000,
  292. .end = 0xfe943fff,
  293. .flags = IORESOURCE_MEM,
  294. },
  295. [1] = {
  296. .start = intcs_evt2irq(0x580),
  297. .flags = IORESOURCE_IRQ,
  298. },
  299. };
  300. static struct platform_device lcdc_device = {
  301. .name = "sh_mobile_lcdc_fb",
  302. .num_resources = ARRAY_SIZE(lcdc_resources),
  303. .resource = lcdc_resources,
  304. .dev = {
  305. .platform_data = &lcdc_info,
  306. .coherent_dma_mask = ~0,
  307. },
  308. };
  309. /* USB1 (Host) */
  310. static void usb1_host_port_power(int port, int power)
  311. {
  312. if (!power) /* only power-on is supported for now */
  313. return;
  314. /* set VBOUT/PWEN and EXTLP1 in DVSTCTR */
  315. __raw_writew(__raw_readw(0xE68B0008) | 0x600, 0xE68B0008);
  316. }
  317. static struct r8a66597_platdata usb1_host_data = {
  318. .on_chip = 1,
  319. .port_power = usb1_host_port_power,
  320. };
  321. static struct resource usb1_host_resources[] = {
  322. [0] = {
  323. .name = "USBHS",
  324. .start = 0xE68B0000,
  325. .end = 0xE68B00E6 - 1,
  326. .flags = IORESOURCE_MEM,
  327. },
  328. [1] = {
  329. .start = evt2irq(0x1ce0) /* USB1_USB1I0 */,
  330. .flags = IORESOURCE_IRQ,
  331. },
  332. };
  333. static struct platform_device usb1_host_device = {
  334. .name = "r8a66597_hcd",
  335. .id = 1,
  336. .dev = {
  337. .dma_mask = NULL, /* not use dma */
  338. .coherent_dma_mask = 0xffffffff,
  339. .platform_data = &usb1_host_data,
  340. },
  341. .num_resources = ARRAY_SIZE(usb1_host_resources),
  342. .resource = usb1_host_resources,
  343. };
  344. /* LED */
  345. static struct gpio_led mackerel_leds[] = {
  346. {
  347. .name = "led0",
  348. .gpio = GPIO_PORT0,
  349. .default_state = LEDS_GPIO_DEFSTATE_ON,
  350. },
  351. {
  352. .name = "led1",
  353. .gpio = GPIO_PORT1,
  354. .default_state = LEDS_GPIO_DEFSTATE_ON,
  355. },
  356. {
  357. .name = "led2",
  358. .gpio = GPIO_PORT2,
  359. .default_state = LEDS_GPIO_DEFSTATE_ON,
  360. },
  361. {
  362. .name = "led3",
  363. .gpio = GPIO_PORT159,
  364. .default_state = LEDS_GPIO_DEFSTATE_ON,
  365. }
  366. };
  367. static struct gpio_led_platform_data mackerel_leds_pdata = {
  368. .leds = mackerel_leds,
  369. .num_leds = ARRAY_SIZE(mackerel_leds),
  370. };
  371. static struct platform_device leds_device = {
  372. .name = "leds-gpio",
  373. .id = 0,
  374. .dev = {
  375. .platform_data = &mackerel_leds_pdata,
  376. },
  377. };
  378. /* FSI */
  379. #define IRQ_FSI evt2irq(0x1840)
  380. static struct sh_fsi_platform_info fsi_info = {
  381. .porta_flags = SH_FSI_BRS_INV |
  382. SH_FSI_OUT_SLAVE_MODE |
  383. SH_FSI_IN_SLAVE_MODE |
  384. SH_FSI_OFMT(PCM) |
  385. SH_FSI_IFMT(PCM),
  386. };
  387. static struct resource fsi_resources[] = {
  388. [0] = {
  389. .name = "FSI",
  390. .start = 0xFE3C0000,
  391. .end = 0xFE3C0400 - 1,
  392. .flags = IORESOURCE_MEM,
  393. },
  394. [1] = {
  395. .start = IRQ_FSI,
  396. .flags = IORESOURCE_IRQ,
  397. },
  398. };
  399. static struct platform_device fsi_device = {
  400. .name = "sh_fsi2",
  401. .id = -1,
  402. .num_resources = ARRAY_SIZE(fsi_resources),
  403. .resource = fsi_resources,
  404. .dev = {
  405. .platform_data = &fsi_info,
  406. },
  407. };
  408. static struct platform_device fsi_ak4643_device = {
  409. .name = "sh_fsi2_a_ak4643",
  410. };
  411. /*
  412. * The card detect pin of the top SD/MMC slot (CN7) is active low and is
  413. * connected to GPIO A22 of SH7372 (GPIO_PORT41).
  414. */
  415. static int slot_cn7_get_cd(struct platform_device *pdev)
  416. {
  417. if (gpio_is_valid(GPIO_PORT41))
  418. return !gpio_get_value(GPIO_PORT41);
  419. else
  420. return -ENXIO;
  421. }
  422. /* SDHI0 */
  423. static struct sh_mobile_sdhi_info sdhi0_info = {
  424. .dma_slave_tx = SHDMA_SLAVE_SDHI0_TX,
  425. .dma_slave_rx = SHDMA_SLAVE_SDHI0_RX,
  426. .tmio_caps = MMC_CAP_SD_HIGHSPEED,
  427. };
  428. static struct resource sdhi0_resources[] = {
  429. [0] = {
  430. .name = "SDHI0",
  431. .start = 0xe6850000,
  432. .end = 0xe68501ff,
  433. .flags = IORESOURCE_MEM,
  434. },
  435. [1] = {
  436. .start = evt2irq(0x0e00) /* SDHI0 */,
  437. .flags = IORESOURCE_IRQ,
  438. },
  439. };
  440. static struct platform_device sdhi0_device = {
  441. .name = "sh_mobile_sdhi",
  442. .num_resources = ARRAY_SIZE(sdhi0_resources),
  443. .resource = sdhi0_resources,
  444. .id = 0,
  445. .dev = {
  446. .platform_data = &sdhi0_info,
  447. },
  448. };
  449. #if !defined(CONFIG_MMC_SH_MMCIF)
  450. /* SDHI1 */
  451. static struct sh_mobile_sdhi_info sdhi1_info = {
  452. .dma_slave_tx = SHDMA_SLAVE_SDHI1_TX,
  453. .dma_slave_rx = SHDMA_SLAVE_SDHI1_RX,
  454. .tmio_ocr_mask = MMC_VDD_165_195,
  455. .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE,
  456. .tmio_caps = MMC_CAP_SD_HIGHSPEED |
  457. MMC_CAP_NEEDS_POLL,
  458. .get_cd = slot_cn7_get_cd,
  459. };
  460. static struct resource sdhi1_resources[] = {
  461. [0] = {
  462. .name = "SDHI1",
  463. .start = 0xe6860000,
  464. .end = 0xe68601ff,
  465. .flags = IORESOURCE_MEM,
  466. },
  467. [1] = {
  468. .start = evt2irq(0x0e80),
  469. .flags = IORESOURCE_IRQ,
  470. },
  471. };
  472. static struct platform_device sdhi1_device = {
  473. .name = "sh_mobile_sdhi",
  474. .num_resources = ARRAY_SIZE(sdhi1_resources),
  475. .resource = sdhi1_resources,
  476. .id = 1,
  477. .dev = {
  478. .platform_data = &sdhi1_info,
  479. },
  480. };
  481. #endif
  482. /* SDHI2 */
  483. static struct sh_mobile_sdhi_info sdhi2_info = {
  484. .dma_slave_tx = SHDMA_SLAVE_SDHI2_TX,
  485. .dma_slave_rx = SHDMA_SLAVE_SDHI2_RX,
  486. .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE,
  487. .tmio_caps = MMC_CAP_SD_HIGHSPEED |
  488. MMC_CAP_NEEDS_POLL,
  489. };
  490. static struct resource sdhi2_resources[] = {
  491. [0] = {
  492. .name = "SDHI2",
  493. .start = 0xe6870000,
  494. .end = 0xe68701ff,
  495. .flags = IORESOURCE_MEM,
  496. },
  497. [1] = {
  498. .start = evt2irq(0x1200),
  499. .flags = IORESOURCE_IRQ,
  500. },
  501. };
  502. static struct platform_device sdhi2_device = {
  503. .name = "sh_mobile_sdhi",
  504. .num_resources = ARRAY_SIZE(sdhi2_resources),
  505. .resource = sdhi2_resources,
  506. .id = 2,
  507. .dev = {
  508. .platform_data = &sdhi2_info,
  509. },
  510. };
  511. /* SH_MMCIF */
  512. static struct resource sh_mmcif_resources[] = {
  513. [0] = {
  514. .name = "MMCIF",
  515. .start = 0xE6BD0000,
  516. .end = 0xE6BD00FF,
  517. .flags = IORESOURCE_MEM,
  518. },
  519. [1] = {
  520. /* MMC ERR */
  521. .start = evt2irq(0x1ac0),
  522. .flags = IORESOURCE_IRQ,
  523. },
  524. [2] = {
  525. /* MMC NOR */
  526. .start = evt2irq(0x1ae0),
  527. .flags = IORESOURCE_IRQ,
  528. },
  529. };
  530. static struct sh_mmcif_plat_data sh_mmcif_plat = {
  531. .sup_pclk = 0,
  532. .ocr = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34,
  533. .caps = MMC_CAP_4_BIT_DATA |
  534. MMC_CAP_8_BIT_DATA |
  535. MMC_CAP_NEEDS_POLL,
  536. .get_cd = slot_cn7_get_cd,
  537. };
  538. static struct platform_device sh_mmcif_device = {
  539. .name = "sh_mmcif",
  540. .id = 0,
  541. .dev = {
  542. .dma_mask = NULL,
  543. .coherent_dma_mask = 0xffffffff,
  544. .platform_data = &sh_mmcif_plat,
  545. },
  546. .num_resources = ARRAY_SIZE(sh_mmcif_resources),
  547. .resource = sh_mmcif_resources,
  548. };
  549. static int mackerel_camera_add(struct soc_camera_link *icl, struct device *dev);
  550. static void mackerel_camera_del(struct soc_camera_link *icl);
  551. static int camera_set_capture(struct soc_camera_platform_info *info,
  552. int enable)
  553. {
  554. return 0; /* camera sensor always enabled */
  555. }
  556. static struct soc_camera_platform_info camera_info = {
  557. .format_name = "UYVY",
  558. .format_depth = 16,
  559. .format = {
  560. .code = V4L2_MBUS_FMT_UYVY8_2X8,
  561. .colorspace = V4L2_COLORSPACE_SMPTE170M,
  562. .field = V4L2_FIELD_NONE,
  563. .width = 640,
  564. .height = 480,
  565. },
  566. .bus_param = SOCAM_PCLK_SAMPLE_RISING | SOCAM_HSYNC_ACTIVE_HIGH |
  567. SOCAM_VSYNC_ACTIVE_HIGH | SOCAM_MASTER | SOCAM_DATAWIDTH_8 |
  568. SOCAM_DATA_ACTIVE_HIGH,
  569. .set_capture = camera_set_capture,
  570. };
  571. static struct soc_camera_link camera_link = {
  572. .bus_id = 0,
  573. .add_device = mackerel_camera_add,
  574. .del_device = mackerel_camera_del,
  575. .module_name = "soc_camera_platform",
  576. .priv = &camera_info,
  577. };
  578. static void dummy_release(struct device *dev)
  579. {
  580. }
  581. static struct platform_device camera_device = {
  582. .name = "soc_camera_platform",
  583. .dev = {
  584. .platform_data = &camera_info,
  585. .release = dummy_release,
  586. },
  587. };
  588. static int mackerel_camera_add(struct soc_camera_link *icl,
  589. struct device *dev)
  590. {
  591. if (icl != &camera_link)
  592. return -ENODEV;
  593. camera_info.dev = dev;
  594. return platform_device_register(&camera_device);
  595. }
  596. static void mackerel_camera_del(struct soc_camera_link *icl)
  597. {
  598. if (icl != &camera_link)
  599. return;
  600. platform_device_unregister(&camera_device);
  601. memset(&camera_device.dev.kobj, 0,
  602. sizeof(camera_device.dev.kobj));
  603. }
  604. static struct sh_mobile_ceu_info sh_mobile_ceu_info = {
  605. .flags = SH_CEU_FLAG_USE_8BIT_BUS,
  606. };
  607. static struct resource ceu_resources[] = {
  608. [0] = {
  609. .name = "CEU",
  610. .start = 0xfe910000,
  611. .end = 0xfe91009f,
  612. .flags = IORESOURCE_MEM,
  613. },
  614. [1] = {
  615. .start = intcs_evt2irq(0x880),
  616. .flags = IORESOURCE_IRQ,
  617. },
  618. [2] = {
  619. /* place holder for contiguous memory */
  620. },
  621. };
  622. static struct platform_device ceu_device = {
  623. .name = "sh_mobile_ceu",
  624. .id = 0, /* "ceu0" clock */
  625. .num_resources = ARRAY_SIZE(ceu_resources),
  626. .resource = ceu_resources,
  627. .dev = {
  628. .platform_data = &sh_mobile_ceu_info,
  629. },
  630. };
  631. static struct platform_device mackerel_camera = {
  632. .name = "soc-camera-pdrv",
  633. .id = 0,
  634. .dev = {
  635. .platform_data = &camera_link,
  636. },
  637. };
  638. static struct platform_device *mackerel_devices[] __initdata = {
  639. &nor_flash_device,
  640. &smc911x_device,
  641. &lcdc_device,
  642. &usb1_host_device,
  643. &leds_device,
  644. &fsi_device,
  645. &fsi_ak4643_device,
  646. &sdhi0_device,
  647. #if !defined(CONFIG_MMC_SH_MMCIF)
  648. &sdhi1_device,
  649. #endif
  650. &sdhi2_device,
  651. &sh_mmcif_device,
  652. &ceu_device,
  653. &mackerel_camera,
  654. };
  655. /* Keypad Initialization */
  656. #define KEYPAD_BUTTON(ev_type, ev_code, act_low) \
  657. { \
  658. .type = ev_type, \
  659. .code = ev_code, \
  660. .active_low = act_low, \
  661. }
  662. #define KEYPAD_BUTTON_LOW(event_code) KEYPAD_BUTTON(EV_KEY, event_code, 1)
  663. static struct tca6416_button mackerel_gpio_keys[] = {
  664. KEYPAD_BUTTON_LOW(KEY_HOME),
  665. KEYPAD_BUTTON_LOW(KEY_MENU),
  666. KEYPAD_BUTTON_LOW(KEY_BACK),
  667. KEYPAD_BUTTON_LOW(KEY_POWER),
  668. };
  669. static struct tca6416_keys_platform_data mackerel_tca6416_keys_info = {
  670. .buttons = mackerel_gpio_keys,
  671. .nbuttons = ARRAY_SIZE(mackerel_gpio_keys),
  672. .rep = 1,
  673. .use_polling = 0,
  674. .pinmask = 0x000F,
  675. };
  676. /* I2C */
  677. #define IRQ9 evt2irq(0x0320)
  678. static struct i2c_board_info i2c0_devices[] = {
  679. {
  680. I2C_BOARD_INFO("ak4643", 0x13),
  681. },
  682. /* Keypad */
  683. {
  684. I2C_BOARD_INFO("tca6408-keys", 0x20),
  685. .platform_data = &mackerel_tca6416_keys_info,
  686. .irq = IRQ9,
  687. },
  688. };
  689. #define IRQ21 evt2irq(0x32a0)
  690. static struct i2c_board_info i2c1_devices[] = {
  691. /* Accelerometer */
  692. {
  693. I2C_BOARD_INFO("adxl34x", 0x53),
  694. .irq = IRQ21,
  695. },
  696. };
  697. static struct map_desc mackerel_io_desc[] __initdata = {
  698. /* create a 1:1 entity map for 0xe6xxxxxx
  699. * used by CPGA, INTC and PFC.
  700. */
  701. {
  702. .virtual = 0xe6000000,
  703. .pfn = __phys_to_pfn(0xe6000000),
  704. .length = 256 << 20,
  705. .type = MT_DEVICE_NONSHARED
  706. },
  707. };
  708. static void __init mackerel_map_io(void)
  709. {
  710. iotable_init(mackerel_io_desc, ARRAY_SIZE(mackerel_io_desc));
  711. /* setup early devices and console here as well */
  712. sh7372_add_early_devices();
  713. shmobile_setup_console();
  714. }
  715. #define GPIO_PORT9CR 0xE6051009
  716. #define GPIO_PORT10CR 0xE605100A
  717. static void __init mackerel_init(void)
  718. {
  719. sh7372_pinmux_init();
  720. /* enable SCIFA0 */
  721. gpio_request(GPIO_FN_SCIFA0_TXD, NULL);
  722. gpio_request(GPIO_FN_SCIFA0_RXD, NULL);
  723. /* enable SMSC911X */
  724. gpio_request(GPIO_FN_CS5A, NULL);
  725. gpio_request(GPIO_FN_IRQ6_39, NULL);
  726. /* LCDC */
  727. gpio_request(GPIO_FN_LCDD23, NULL);
  728. gpio_request(GPIO_FN_LCDD22, NULL);
  729. gpio_request(GPIO_FN_LCDD21, NULL);
  730. gpio_request(GPIO_FN_LCDD20, NULL);
  731. gpio_request(GPIO_FN_LCDD19, NULL);
  732. gpio_request(GPIO_FN_LCDD18, NULL);
  733. gpio_request(GPIO_FN_LCDD17, NULL);
  734. gpio_request(GPIO_FN_LCDD16, NULL);
  735. gpio_request(GPIO_FN_LCDD15, NULL);
  736. gpio_request(GPIO_FN_LCDD14, NULL);
  737. gpio_request(GPIO_FN_LCDD13, NULL);
  738. gpio_request(GPIO_FN_LCDD12, NULL);
  739. gpio_request(GPIO_FN_LCDD11, NULL);
  740. gpio_request(GPIO_FN_LCDD10, NULL);
  741. gpio_request(GPIO_FN_LCDD9, NULL);
  742. gpio_request(GPIO_FN_LCDD8, NULL);
  743. gpio_request(GPIO_FN_LCDD7, NULL);
  744. gpio_request(GPIO_FN_LCDD6, NULL);
  745. gpio_request(GPIO_FN_LCDD5, NULL);
  746. gpio_request(GPIO_FN_LCDD4, NULL);
  747. gpio_request(GPIO_FN_LCDD3, NULL);
  748. gpio_request(GPIO_FN_LCDD2, NULL);
  749. gpio_request(GPIO_FN_LCDD1, NULL);
  750. gpio_request(GPIO_FN_LCDD0, NULL);
  751. gpio_request(GPIO_FN_LCDDISP, NULL);
  752. gpio_request(GPIO_FN_LCDDCK, NULL);
  753. gpio_request(GPIO_PORT31, NULL); /* backlight */
  754. gpio_direction_output(GPIO_PORT31, 1);
  755. gpio_request(GPIO_PORT151, NULL); /* LCDDON */
  756. gpio_direction_output(GPIO_PORT151, 1);
  757. /* USB enable */
  758. gpio_request(GPIO_FN_VBUS0_1, NULL);
  759. gpio_request(GPIO_FN_IDIN_1_18, NULL);
  760. gpio_request(GPIO_FN_PWEN_1_115, NULL);
  761. gpio_request(GPIO_FN_OVCN_1_114, NULL);
  762. gpio_request(GPIO_FN_EXTLP_1, NULL);
  763. gpio_request(GPIO_FN_OVCN2_1, NULL);
  764. /* setup USB phy */
  765. __raw_writew(0x8a0a, 0xE6058130); /* USBCR4 */
  766. /* enable FSI2 port A (ak4643) */
  767. gpio_request(GPIO_FN_FSIAIBT, NULL);
  768. gpio_request(GPIO_FN_FSIAILR, NULL);
  769. gpio_request(GPIO_FN_FSIAISLD, NULL);
  770. gpio_request(GPIO_FN_FSIAOSLD, NULL);
  771. gpio_request(GPIO_PORT161, NULL);
  772. gpio_direction_output(GPIO_PORT161, 0); /* slave */
  773. gpio_request(GPIO_PORT9, NULL);
  774. gpio_request(GPIO_PORT10, NULL);
  775. gpio_no_direction(GPIO_PORT9CR); /* FSIAOBT needs no direction */
  776. gpio_no_direction(GPIO_PORT10CR); /* FSIAOLR needs no direction */
  777. intc_set_priority(IRQ_FSI, 3); /* irq priority FSI(3) > SMSC911X(2) */
  778. /* enable Keypad */
  779. gpio_request(GPIO_FN_IRQ9_42, NULL);
  780. set_irq_type(IRQ9, IRQ_TYPE_LEVEL_HIGH);
  781. /* enable Accelerometer */
  782. gpio_request(GPIO_FN_IRQ21, NULL);
  783. set_irq_type(IRQ21, IRQ_TYPE_LEVEL_HIGH);
  784. /* enable SDHI0 */
  785. gpio_request(GPIO_FN_SDHICD0, NULL);
  786. gpio_request(GPIO_FN_SDHIWP0, NULL);
  787. gpio_request(GPIO_FN_SDHICMD0, NULL);
  788. gpio_request(GPIO_FN_SDHICLK0, NULL);
  789. gpio_request(GPIO_FN_SDHID0_3, NULL);
  790. gpio_request(GPIO_FN_SDHID0_2, NULL);
  791. gpio_request(GPIO_FN_SDHID0_1, NULL);
  792. gpio_request(GPIO_FN_SDHID0_0, NULL);
  793. #if !defined(CONFIG_MMC_SH_MMCIF)
  794. /* enable SDHI1 */
  795. gpio_request(GPIO_FN_SDHICMD1, NULL);
  796. gpio_request(GPIO_FN_SDHICLK1, NULL);
  797. gpio_request(GPIO_FN_SDHID1_3, NULL);
  798. gpio_request(GPIO_FN_SDHID1_2, NULL);
  799. gpio_request(GPIO_FN_SDHID1_1, NULL);
  800. gpio_request(GPIO_FN_SDHID1_0, NULL);
  801. #endif
  802. /* card detect pin for MMC slot (CN7) */
  803. gpio_request(GPIO_PORT41, NULL);
  804. gpio_direction_input(GPIO_PORT41);
  805. /* enable SDHI2 */
  806. gpio_request(GPIO_FN_SDHICMD2, NULL);
  807. gpio_request(GPIO_FN_SDHICLK2, NULL);
  808. gpio_request(GPIO_FN_SDHID2_3, NULL);
  809. gpio_request(GPIO_FN_SDHID2_2, NULL);
  810. gpio_request(GPIO_FN_SDHID2_1, NULL);
  811. gpio_request(GPIO_FN_SDHID2_0, NULL);
  812. /* MMCIF */
  813. gpio_request(GPIO_FN_MMCD0_0, NULL);
  814. gpio_request(GPIO_FN_MMCD0_1, NULL);
  815. gpio_request(GPIO_FN_MMCD0_2, NULL);
  816. gpio_request(GPIO_FN_MMCD0_3, NULL);
  817. gpio_request(GPIO_FN_MMCD0_4, NULL);
  818. gpio_request(GPIO_FN_MMCD0_5, NULL);
  819. gpio_request(GPIO_FN_MMCD0_6, NULL);
  820. gpio_request(GPIO_FN_MMCD0_7, NULL);
  821. gpio_request(GPIO_FN_MMCCMD0, NULL);
  822. gpio_request(GPIO_FN_MMCCLK0, NULL);
  823. /* enable GPS module (GT-720F) */
  824. gpio_request(GPIO_FN_SCIFA2_TXD1, NULL);
  825. gpio_request(GPIO_FN_SCIFA2_RXD1, NULL);
  826. /* CEU */
  827. gpio_request(GPIO_FN_VIO_CLK, NULL);
  828. gpio_request(GPIO_FN_VIO_VD, NULL);
  829. gpio_request(GPIO_FN_VIO_HD, NULL);
  830. gpio_request(GPIO_FN_VIO_FIELD, NULL);
  831. gpio_request(GPIO_FN_VIO_CKO, NULL);
  832. gpio_request(GPIO_FN_VIO_D7, NULL);
  833. gpio_request(GPIO_FN_VIO_D6, NULL);
  834. gpio_request(GPIO_FN_VIO_D5, NULL);
  835. gpio_request(GPIO_FN_VIO_D4, NULL);
  836. gpio_request(GPIO_FN_VIO_D3, NULL);
  837. gpio_request(GPIO_FN_VIO_D2, NULL);
  838. gpio_request(GPIO_FN_VIO_D1, NULL);
  839. gpio_request(GPIO_FN_VIO_D0, NULL);
  840. i2c_register_board_info(0, i2c0_devices,
  841. ARRAY_SIZE(i2c0_devices));
  842. i2c_register_board_info(1, i2c1_devices,
  843. ARRAY_SIZE(i2c1_devices));
  844. sh7372_add_standard_devices();
  845. platform_add_devices(mackerel_devices, ARRAY_SIZE(mackerel_devices));
  846. }
  847. static void __init mackerel_timer_init(void)
  848. {
  849. sh7372_clock_init();
  850. shmobile_timer.init();
  851. }
  852. static struct sys_timer mackerel_timer = {
  853. .init = mackerel_timer_init,
  854. };
  855. MACHINE_START(MACKEREL, "mackerel")
  856. .map_io = mackerel_map_io,
  857. .init_irq = sh7372_init_irq,
  858. .init_machine = mackerel_init,
  859. .timer = &mackerel_timer,
  860. MACHINE_END