board-mackerel.c 20 KB

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