setup.c 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339
  1. /*
  2. * Copyright (C) 2009 Renesas Solutions Corp.
  3. *
  4. * Kuninori Morimoto <morimoto.kuninori@renesas.com>
  5. *
  6. * This file is subject to the terms and conditions of the GNU General Public
  7. * License. See the file "COPYING" in the main directory of this archive
  8. * for more details.
  9. */
  10. #include <linux/init.h>
  11. #include <linux/device.h>
  12. #include <linux/platform_device.h>
  13. #include <linux/mfd/sh_mobile_sdhi.h>
  14. #include <linux/mmc/host.h>
  15. #include <linux/mmc/sh_mmcif.h>
  16. #include <linux/mtd/physmap.h>
  17. #include <linux/gpio.h>
  18. #include <linux/interrupt.h>
  19. #include <linux/io.h>
  20. #include <linux/delay.h>
  21. #include <linux/usb/r8a66597.h>
  22. #include <linux/i2c.h>
  23. #include <linux/i2c/tsc2007.h>
  24. #include <linux/spi/spi.h>
  25. #include <linux/spi/sh_msiof.h>
  26. #include <linux/spi/mmc_spi.h>
  27. #include <linux/input.h>
  28. #include <linux/input/sh_keysc.h>
  29. #include <video/sh_mobile_lcdc.h>
  30. #include <sound/sh_fsi.h>
  31. #include <media/sh_mobile_ceu.h>
  32. #include <media/tw9910.h>
  33. #include <media/mt9t112.h>
  34. #include <asm/heartbeat.h>
  35. #include <asm/sh_eth.h>
  36. #include <asm/clock.h>
  37. #include <asm/suspend.h>
  38. #include <cpu/sh7724.h>
  39. /*
  40. * Address Interface BusWidth
  41. *-----------------------------------------
  42. * 0x0000_0000 uboot 16bit
  43. * 0x0004_0000 Linux romImage 16bit
  44. * 0x0014_0000 MTD for Linux 16bit
  45. * 0x0400_0000 Internal I/O 16/32bit
  46. * 0x0800_0000 DRAM 32bit
  47. * 0x1800_0000 MFI 16bit
  48. */
  49. /* SWITCH
  50. *------------------------------
  51. * DS2[1] = FlashROM write protect ON : write protect
  52. * OFF : No write protect
  53. * DS2[2] = RMII / TS, SCIF ON : RMII
  54. * OFF : TS, SCIF3
  55. * DS2[3] = Camera / Video ON : Camera
  56. * OFF : NTSC/PAL (IN)
  57. * DS2[5] = NTSC_OUT Clock ON : On board OSC
  58. * OFF : SH7724 DV_CLK
  59. * DS2[6-7] = MMC / SD ON-OFF : SD
  60. * OFF-ON : MMC
  61. */
  62. /* Heartbeat */
  63. static unsigned char led_pos[] = { 0, 1, 2, 3 };
  64. static struct heartbeat_data heartbeat_data = {
  65. .nr_bits = 4,
  66. .bit_pos = led_pos,
  67. };
  68. static struct resource heartbeat_resource = {
  69. .start = 0xA405012C, /* PTG */
  70. .end = 0xA405012E - 1,
  71. .flags = IORESOURCE_MEM | IORESOURCE_MEM_8BIT,
  72. };
  73. static struct platform_device heartbeat_device = {
  74. .name = "heartbeat",
  75. .id = -1,
  76. .dev = {
  77. .platform_data = &heartbeat_data,
  78. },
  79. .num_resources = 1,
  80. .resource = &heartbeat_resource,
  81. };
  82. /* MTD */
  83. static struct mtd_partition nor_flash_partitions[] = {
  84. {
  85. .name = "boot loader",
  86. .offset = 0,
  87. .size = (5 * 1024 * 1024),
  88. .mask_flags = MTD_WRITEABLE, /* force read-only */
  89. }, {
  90. .name = "free-area",
  91. .offset = MTDPART_OFS_APPEND,
  92. .size = MTDPART_SIZ_FULL,
  93. },
  94. };
  95. static struct physmap_flash_data nor_flash_data = {
  96. .width = 2,
  97. .parts = nor_flash_partitions,
  98. .nr_parts = ARRAY_SIZE(nor_flash_partitions),
  99. };
  100. static struct resource nor_flash_resources[] = {
  101. [0] = {
  102. .name = "NOR Flash",
  103. .start = 0x00000000,
  104. .end = 0x03ffffff,
  105. .flags = IORESOURCE_MEM,
  106. }
  107. };
  108. static struct platform_device nor_flash_device = {
  109. .name = "physmap-flash",
  110. .resource = nor_flash_resources,
  111. .num_resources = ARRAY_SIZE(nor_flash_resources),
  112. .dev = {
  113. .platform_data = &nor_flash_data,
  114. },
  115. };
  116. /* SH Eth */
  117. #define SH_ETH_ADDR (0xA4600000)
  118. static struct resource sh_eth_resources[] = {
  119. [0] = {
  120. .start = SH_ETH_ADDR,
  121. .end = SH_ETH_ADDR + 0x1FC,
  122. .flags = IORESOURCE_MEM,
  123. },
  124. [1] = {
  125. .start = 91,
  126. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  127. },
  128. };
  129. static struct sh_eth_plat_data sh_eth_plat = {
  130. .phy = 0x1f, /* SMSC LAN8700 */
  131. .edmac_endian = EDMAC_LITTLE_ENDIAN,
  132. .ether_link_active_low = 1
  133. };
  134. static struct platform_device sh_eth_device = {
  135. .name = "sh-eth",
  136. .id = 0,
  137. .dev = {
  138. .platform_data = &sh_eth_plat,
  139. },
  140. .num_resources = ARRAY_SIZE(sh_eth_resources),
  141. .resource = sh_eth_resources,
  142. .archdata = {
  143. .hwblk_id = HWBLK_ETHER,
  144. },
  145. };
  146. /* USB0 host */
  147. static void usb0_port_power(int port, int power)
  148. {
  149. gpio_set_value(GPIO_PTB4, power);
  150. }
  151. static struct r8a66597_platdata usb0_host_data = {
  152. .on_chip = 1,
  153. .port_power = usb0_port_power,
  154. };
  155. static struct resource usb0_host_resources[] = {
  156. [0] = {
  157. .start = 0xa4d80000,
  158. .end = 0xa4d80124 - 1,
  159. .flags = IORESOURCE_MEM,
  160. },
  161. [1] = {
  162. .start = 65,
  163. .end = 65,
  164. .flags = IORESOURCE_IRQ | IRQF_TRIGGER_LOW,
  165. },
  166. };
  167. static struct platform_device usb0_host_device = {
  168. .name = "r8a66597_hcd",
  169. .id = 0,
  170. .dev = {
  171. .dma_mask = NULL, /* not use dma */
  172. .coherent_dma_mask = 0xffffffff,
  173. .platform_data = &usb0_host_data,
  174. },
  175. .num_resources = ARRAY_SIZE(usb0_host_resources),
  176. .resource = usb0_host_resources,
  177. };
  178. /* USB1 host/function */
  179. static void usb1_port_power(int port, int power)
  180. {
  181. gpio_set_value(GPIO_PTB5, power);
  182. }
  183. static struct r8a66597_platdata usb1_common_data = {
  184. .on_chip = 1,
  185. .port_power = usb1_port_power,
  186. };
  187. static struct resource usb1_common_resources[] = {
  188. [0] = {
  189. .start = 0xa4d90000,
  190. .end = 0xa4d90124 - 1,
  191. .flags = IORESOURCE_MEM,
  192. },
  193. [1] = {
  194. .start = 66,
  195. .end = 66,
  196. .flags = IORESOURCE_IRQ | IRQF_TRIGGER_LOW,
  197. },
  198. };
  199. static struct platform_device usb1_common_device = {
  200. /* .name will be added in arch_setup */
  201. .id = 1,
  202. .dev = {
  203. .dma_mask = NULL, /* not use dma */
  204. .coherent_dma_mask = 0xffffffff,
  205. .platform_data = &usb1_common_data,
  206. },
  207. .num_resources = ARRAY_SIZE(usb1_common_resources),
  208. .resource = usb1_common_resources,
  209. };
  210. /* LCDC */
  211. const static struct fb_videomode ecovec_lcd_modes[] = {
  212. {
  213. .name = "Panel",
  214. .xres = 800,
  215. .yres = 480,
  216. .left_margin = 220,
  217. .right_margin = 110,
  218. .hsync_len = 70,
  219. .upper_margin = 20,
  220. .lower_margin = 5,
  221. .vsync_len = 5,
  222. .sync = 0, /* hsync and vsync are active low */
  223. },
  224. };
  225. const static struct fb_videomode ecovec_dvi_modes[] = {
  226. {
  227. .name = "DVI",
  228. .xres = 1280,
  229. .yres = 720,
  230. .left_margin = 220,
  231. .right_margin = 110,
  232. .hsync_len = 40,
  233. .upper_margin = 20,
  234. .lower_margin = 5,
  235. .vsync_len = 5,
  236. .sync = 0, /* hsync and vsync are active low */
  237. },
  238. };
  239. static struct sh_mobile_lcdc_info lcdc_info = {
  240. .ch[0] = {
  241. .interface_type = RGB18,
  242. .chan = LCDC_CHAN_MAINLCD,
  243. .bpp = 16,
  244. .lcd_size_cfg = { /* 7.0 inch */
  245. .width = 152,
  246. .height = 91,
  247. },
  248. .board_cfg = {
  249. },
  250. }
  251. };
  252. static struct resource lcdc_resources[] = {
  253. [0] = {
  254. .name = "LCDC",
  255. .start = 0xfe940000,
  256. .end = 0xfe942fff,
  257. .flags = IORESOURCE_MEM,
  258. },
  259. [1] = {
  260. .start = 106,
  261. .flags = IORESOURCE_IRQ,
  262. },
  263. };
  264. static struct platform_device lcdc_device = {
  265. .name = "sh_mobile_lcdc_fb",
  266. .num_resources = ARRAY_SIZE(lcdc_resources),
  267. .resource = lcdc_resources,
  268. .dev = {
  269. .platform_data = &lcdc_info,
  270. },
  271. .archdata = {
  272. .hwblk_id = HWBLK_LCDC,
  273. },
  274. };
  275. /* CEU0 */
  276. static struct sh_mobile_ceu_info sh_mobile_ceu0_info = {
  277. .flags = SH_CEU_FLAG_USE_8BIT_BUS,
  278. };
  279. static struct resource ceu0_resources[] = {
  280. [0] = {
  281. .name = "CEU0",
  282. .start = 0xfe910000,
  283. .end = 0xfe91009f,
  284. .flags = IORESOURCE_MEM,
  285. },
  286. [1] = {
  287. .start = 52,
  288. .flags = IORESOURCE_IRQ,
  289. },
  290. [2] = {
  291. /* place holder for contiguous memory */
  292. },
  293. };
  294. static struct platform_device ceu0_device = {
  295. .name = "sh_mobile_ceu",
  296. .id = 0, /* "ceu0" clock */
  297. .num_resources = ARRAY_SIZE(ceu0_resources),
  298. .resource = ceu0_resources,
  299. .dev = {
  300. .platform_data = &sh_mobile_ceu0_info,
  301. },
  302. .archdata = {
  303. .hwblk_id = HWBLK_CEU0,
  304. },
  305. };
  306. /* CEU1 */
  307. static struct sh_mobile_ceu_info sh_mobile_ceu1_info = {
  308. .flags = SH_CEU_FLAG_USE_8BIT_BUS,
  309. };
  310. static struct resource ceu1_resources[] = {
  311. [0] = {
  312. .name = "CEU1",
  313. .start = 0xfe914000,
  314. .end = 0xfe91409f,
  315. .flags = IORESOURCE_MEM,
  316. },
  317. [1] = {
  318. .start = 63,
  319. .flags = IORESOURCE_IRQ,
  320. },
  321. [2] = {
  322. /* place holder for contiguous memory */
  323. },
  324. };
  325. static struct platform_device ceu1_device = {
  326. .name = "sh_mobile_ceu",
  327. .id = 1, /* "ceu1" clock */
  328. .num_resources = ARRAY_SIZE(ceu1_resources),
  329. .resource = ceu1_resources,
  330. .dev = {
  331. .platform_data = &sh_mobile_ceu1_info,
  332. },
  333. .archdata = {
  334. .hwblk_id = HWBLK_CEU1,
  335. },
  336. };
  337. /* I2C device */
  338. static struct i2c_board_info i2c0_devices[] = {
  339. {
  340. I2C_BOARD_INFO("da7210", 0x1a),
  341. },
  342. };
  343. static struct i2c_board_info i2c1_devices[] = {
  344. {
  345. I2C_BOARD_INFO("r2025sd", 0x32),
  346. },
  347. {
  348. I2C_BOARD_INFO("lis3lv02d", 0x1c),
  349. .irq = 33,
  350. }
  351. };
  352. /* KEYSC */
  353. static struct sh_keysc_info keysc_info = {
  354. .mode = SH_KEYSC_MODE_1,
  355. .scan_timing = 3,
  356. .delay = 50,
  357. .kycr2_delay = 100,
  358. .keycodes = { KEY_1, 0, 0, 0, 0,
  359. KEY_2, 0, 0, 0, 0,
  360. KEY_3, 0, 0, 0, 0,
  361. KEY_4, 0, 0, 0, 0,
  362. KEY_5, 0, 0, 0, 0,
  363. KEY_6, 0, 0, 0, 0, },
  364. };
  365. static struct resource keysc_resources[] = {
  366. [0] = {
  367. .name = "KEYSC",
  368. .start = 0x044b0000,
  369. .end = 0x044b000f,
  370. .flags = IORESOURCE_MEM,
  371. },
  372. [1] = {
  373. .start = 79,
  374. .flags = IORESOURCE_IRQ,
  375. },
  376. };
  377. static struct platform_device keysc_device = {
  378. .name = "sh_keysc",
  379. .id = 0, /* keysc0 clock */
  380. .num_resources = ARRAY_SIZE(keysc_resources),
  381. .resource = keysc_resources,
  382. .dev = {
  383. .platform_data = &keysc_info,
  384. },
  385. .archdata = {
  386. .hwblk_id = HWBLK_KEYSC,
  387. },
  388. };
  389. /* TouchScreen */
  390. #define IRQ0 32
  391. static int ts_get_pendown_state(void)
  392. {
  393. int val = 0;
  394. gpio_free(GPIO_FN_INTC_IRQ0);
  395. gpio_request(GPIO_PTZ0, NULL);
  396. gpio_direction_input(GPIO_PTZ0);
  397. val = gpio_get_value(GPIO_PTZ0);
  398. gpio_free(GPIO_PTZ0);
  399. gpio_request(GPIO_FN_INTC_IRQ0, NULL);
  400. return val ? 0 : 1;
  401. }
  402. static int ts_init(void)
  403. {
  404. gpio_request(GPIO_FN_INTC_IRQ0, NULL);
  405. return 0;
  406. }
  407. static struct tsc2007_platform_data tsc2007_info = {
  408. .model = 2007,
  409. .x_plate_ohms = 180,
  410. .get_pendown_state = ts_get_pendown_state,
  411. .init_platform_hw = ts_init,
  412. };
  413. static struct i2c_board_info ts_i2c_clients = {
  414. I2C_BOARD_INFO("tsc2007", 0x48),
  415. .type = "tsc2007",
  416. .platform_data = &tsc2007_info,
  417. .irq = IRQ0,
  418. };
  419. #ifdef CONFIG_MFD_SH_MOBILE_SDHI
  420. /* SDHI0 */
  421. static void sdhi0_set_pwr(struct platform_device *pdev, int state)
  422. {
  423. gpio_set_value(GPIO_PTB6, state);
  424. }
  425. static struct sh_mobile_sdhi_info sdhi0_info = {
  426. .dma_slave_tx = SHDMA_SLAVE_SDHI0_TX,
  427. .dma_slave_rx = SHDMA_SLAVE_SDHI0_RX,
  428. .set_pwr = sdhi0_set_pwr,
  429. .tmio_caps = MMC_CAP_SDIO_IRQ | MMC_CAP_POWER_OFF_CARD,
  430. };
  431. static struct resource sdhi0_resources[] = {
  432. [0] = {
  433. .name = "SDHI0",
  434. .start = 0x04ce0000,
  435. .end = 0x04ce01ff,
  436. .flags = IORESOURCE_MEM,
  437. },
  438. [1] = {
  439. .start = 100,
  440. .flags = IORESOURCE_IRQ,
  441. },
  442. };
  443. static struct platform_device sdhi0_device = {
  444. .name = "sh_mobile_sdhi",
  445. .num_resources = ARRAY_SIZE(sdhi0_resources),
  446. .resource = sdhi0_resources,
  447. .id = 0,
  448. .dev = {
  449. .platform_data = &sdhi0_info,
  450. },
  451. .archdata = {
  452. .hwblk_id = HWBLK_SDHI0,
  453. },
  454. };
  455. #if !defined(CONFIG_MMC_SH_MMCIF)
  456. /* SDHI1 */
  457. static void sdhi1_set_pwr(struct platform_device *pdev, int state)
  458. {
  459. gpio_set_value(GPIO_PTB7, state);
  460. }
  461. static struct sh_mobile_sdhi_info sdhi1_info = {
  462. .dma_slave_tx = SHDMA_SLAVE_SDHI1_TX,
  463. .dma_slave_rx = SHDMA_SLAVE_SDHI1_RX,
  464. .tmio_caps = MMC_CAP_SDIO_IRQ | MMC_CAP_POWER_OFF_CARD,
  465. .set_pwr = sdhi1_set_pwr,
  466. };
  467. static struct resource sdhi1_resources[] = {
  468. [0] = {
  469. .name = "SDHI1",
  470. .start = 0x04cf0000,
  471. .end = 0x04cf01ff,
  472. .flags = IORESOURCE_MEM,
  473. },
  474. [1] = {
  475. .start = 23,
  476. .flags = IORESOURCE_IRQ,
  477. },
  478. };
  479. static struct platform_device sdhi1_device = {
  480. .name = "sh_mobile_sdhi",
  481. .num_resources = ARRAY_SIZE(sdhi1_resources),
  482. .resource = sdhi1_resources,
  483. .id = 1,
  484. .dev = {
  485. .platform_data = &sdhi1_info,
  486. },
  487. .archdata = {
  488. .hwblk_id = HWBLK_SDHI1,
  489. },
  490. };
  491. #endif /* CONFIG_MMC_SH_MMCIF */
  492. #else
  493. /* MMC SPI */
  494. static int mmc_spi_get_ro(struct device *dev)
  495. {
  496. return gpio_get_value(GPIO_PTY6);
  497. }
  498. static int mmc_spi_get_cd(struct device *dev)
  499. {
  500. return !gpio_get_value(GPIO_PTY7);
  501. }
  502. static void mmc_spi_setpower(struct device *dev, unsigned int maskval)
  503. {
  504. gpio_set_value(GPIO_PTB6, maskval ? 1 : 0);
  505. }
  506. static struct mmc_spi_platform_data mmc_spi_info = {
  507. .get_ro = mmc_spi_get_ro,
  508. .get_cd = mmc_spi_get_cd,
  509. .caps = MMC_CAP_NEEDS_POLL,
  510. .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, /* 3.3V only */
  511. .setpower = mmc_spi_setpower,
  512. };
  513. static struct spi_board_info spi_bus[] = {
  514. {
  515. .modalias = "mmc_spi",
  516. .platform_data = &mmc_spi_info,
  517. .max_speed_hz = 5000000,
  518. .mode = SPI_MODE_0,
  519. .controller_data = (void *) GPIO_PTM4,
  520. },
  521. };
  522. /* MSIOF0 */
  523. static struct sh_msiof_spi_info msiof0_data = {
  524. .num_chipselect = 1,
  525. };
  526. static struct resource msiof0_resources[] = {
  527. [0] = {
  528. .name = "MSIOF0",
  529. .start = 0xa4c40000,
  530. .end = 0xa4c40063,
  531. .flags = IORESOURCE_MEM,
  532. },
  533. [1] = {
  534. .start = 84,
  535. .flags = IORESOURCE_IRQ,
  536. },
  537. };
  538. static struct platform_device msiof0_device = {
  539. .name = "spi_sh_msiof",
  540. .id = 0, /* MSIOF0 */
  541. .dev = {
  542. .platform_data = &msiof0_data,
  543. },
  544. .num_resources = ARRAY_SIZE(msiof0_resources),
  545. .resource = msiof0_resources,
  546. .archdata = {
  547. .hwblk_id = HWBLK_MSIOF0,
  548. },
  549. };
  550. #endif
  551. /* I2C Video/Camera */
  552. static struct i2c_board_info i2c_camera[] = {
  553. {
  554. I2C_BOARD_INFO("tw9910", 0x45),
  555. },
  556. {
  557. /* 1st camera */
  558. I2C_BOARD_INFO("mt9t112", 0x3c),
  559. },
  560. {
  561. /* 2nd camera */
  562. I2C_BOARD_INFO("mt9t112", 0x3c),
  563. },
  564. };
  565. /* tw9910 */
  566. static int tw9910_power(struct device *dev, int mode)
  567. {
  568. int val = mode ? 0 : 1;
  569. gpio_set_value(GPIO_PTU2, val);
  570. if (mode)
  571. mdelay(100);
  572. return 0;
  573. }
  574. static struct tw9910_video_info tw9910_info = {
  575. .buswidth = SOCAM_DATAWIDTH_8,
  576. .mpout = TW9910_MPO_FIELD,
  577. };
  578. static struct soc_camera_link tw9910_link = {
  579. .i2c_adapter_id = 0,
  580. .bus_id = 1,
  581. .power = tw9910_power,
  582. .board_info = &i2c_camera[0],
  583. .priv = &tw9910_info,
  584. };
  585. /* mt9t112 */
  586. static int mt9t112_power1(struct device *dev, int mode)
  587. {
  588. gpio_set_value(GPIO_PTA3, mode);
  589. if (mode)
  590. mdelay(100);
  591. return 0;
  592. }
  593. static struct mt9t112_camera_info mt9t112_info1 = {
  594. .flags = MT9T112_FLAG_PCLK_RISING_EDGE | MT9T112_FLAG_DATAWIDTH_8,
  595. .divider = { 0x49, 0x6, 0, 6, 0, 9, 9, 6, 0 }, /* for 24MHz */
  596. };
  597. static struct soc_camera_link mt9t112_link1 = {
  598. .i2c_adapter_id = 0,
  599. .power = mt9t112_power1,
  600. .bus_id = 0,
  601. .board_info = &i2c_camera[1],
  602. .priv = &mt9t112_info1,
  603. };
  604. static int mt9t112_power2(struct device *dev, int mode)
  605. {
  606. gpio_set_value(GPIO_PTA4, mode);
  607. if (mode)
  608. mdelay(100);
  609. return 0;
  610. }
  611. static struct mt9t112_camera_info mt9t112_info2 = {
  612. .flags = MT9T112_FLAG_PCLK_RISING_EDGE | MT9T112_FLAG_DATAWIDTH_8,
  613. .divider = { 0x49, 0x6, 0, 6, 0, 9, 9, 6, 0 }, /* for 24MHz */
  614. };
  615. static struct soc_camera_link mt9t112_link2 = {
  616. .i2c_adapter_id = 1,
  617. .power = mt9t112_power2,
  618. .bus_id = 1,
  619. .board_info = &i2c_camera[2],
  620. .priv = &mt9t112_info2,
  621. };
  622. static struct platform_device camera_devices[] = {
  623. {
  624. .name = "soc-camera-pdrv",
  625. .id = 0,
  626. .dev = {
  627. .platform_data = &tw9910_link,
  628. },
  629. },
  630. {
  631. .name = "soc-camera-pdrv",
  632. .id = 1,
  633. .dev = {
  634. .platform_data = &mt9t112_link1,
  635. },
  636. },
  637. {
  638. .name = "soc-camera-pdrv",
  639. .id = 2,
  640. .dev = {
  641. .platform_data = &mt9t112_link2,
  642. },
  643. },
  644. };
  645. /* FSI */
  646. static struct sh_fsi_platform_info fsi_info = {
  647. .portb_flags = SH_FSI_BRS_INV,
  648. };
  649. static struct resource fsi_resources[] = {
  650. [0] = {
  651. .name = "FSI",
  652. .start = 0xFE3C0000,
  653. .end = 0xFE3C021d,
  654. .flags = IORESOURCE_MEM,
  655. },
  656. [1] = {
  657. .start = 108,
  658. .flags = IORESOURCE_IRQ,
  659. },
  660. };
  661. static struct platform_device fsi_device = {
  662. .name = "sh_fsi",
  663. .id = 0,
  664. .num_resources = ARRAY_SIZE(fsi_resources),
  665. .resource = fsi_resources,
  666. .dev = {
  667. .platform_data = &fsi_info,
  668. },
  669. .archdata = {
  670. .hwblk_id = HWBLK_SPU, /* FSI needs SPU hwblk */
  671. },
  672. };
  673. /* IrDA */
  674. static struct resource irda_resources[] = {
  675. [0] = {
  676. .name = "IrDA",
  677. .start = 0xA45D0000,
  678. .end = 0xA45D0049,
  679. .flags = IORESOURCE_MEM,
  680. },
  681. [1] = {
  682. .start = 20,
  683. .flags = IORESOURCE_IRQ,
  684. },
  685. };
  686. static struct platform_device irda_device = {
  687. .name = "sh_sir",
  688. .num_resources = ARRAY_SIZE(irda_resources),
  689. .resource = irda_resources,
  690. };
  691. #include <media/ak881x.h>
  692. #include <media/sh_vou.h>
  693. static struct ak881x_pdata ak881x_pdata = {
  694. .flags = AK881X_IF_MODE_SLAVE,
  695. };
  696. static struct i2c_board_info ak8813 = {
  697. I2C_BOARD_INFO("ak8813", 0x20),
  698. .platform_data = &ak881x_pdata,
  699. };
  700. static struct sh_vou_pdata sh_vou_pdata = {
  701. .bus_fmt = SH_VOU_BUS_8BIT,
  702. .flags = SH_VOU_HSYNC_LOW | SH_VOU_VSYNC_LOW,
  703. .board_info = &ak8813,
  704. .i2c_adap = 0,
  705. };
  706. static struct resource sh_vou_resources[] = {
  707. [0] = {
  708. .start = 0xfe960000,
  709. .end = 0xfe962043,
  710. .flags = IORESOURCE_MEM,
  711. },
  712. [1] = {
  713. .start = 55,
  714. .flags = IORESOURCE_IRQ,
  715. },
  716. };
  717. static struct platform_device vou_device = {
  718. .name = "sh-vou",
  719. .id = -1,
  720. .num_resources = ARRAY_SIZE(sh_vou_resources),
  721. .resource = sh_vou_resources,
  722. .dev = {
  723. .platform_data = &sh_vou_pdata,
  724. },
  725. .archdata = {
  726. .hwblk_id = HWBLK_VOU,
  727. },
  728. };
  729. #if defined(CONFIG_MMC_SH_MMCIF)
  730. /* SH_MMCIF */
  731. static void mmcif_set_pwr(struct platform_device *pdev, int state)
  732. {
  733. gpio_set_value(GPIO_PTB7, state);
  734. }
  735. static void mmcif_down_pwr(struct platform_device *pdev)
  736. {
  737. gpio_set_value(GPIO_PTB7, 0);
  738. }
  739. static struct resource sh_mmcif_resources[] = {
  740. [0] = {
  741. .name = "SH_MMCIF",
  742. .start = 0xA4CA0000,
  743. .end = 0xA4CA00FF,
  744. .flags = IORESOURCE_MEM,
  745. },
  746. [1] = {
  747. /* MMC2I */
  748. .start = 29,
  749. .flags = IORESOURCE_IRQ,
  750. },
  751. [2] = {
  752. /* MMC3I */
  753. .start = 30,
  754. .flags = IORESOURCE_IRQ,
  755. },
  756. };
  757. static struct sh_mmcif_plat_data sh_mmcif_plat = {
  758. .set_pwr = mmcif_set_pwr,
  759. .down_pwr = mmcif_down_pwr,
  760. .sup_pclk = 0, /* SH7724: Max Pclk/2 */
  761. .caps = MMC_CAP_4_BIT_DATA |
  762. MMC_CAP_8_BIT_DATA |
  763. MMC_CAP_NEEDS_POLL,
  764. .ocr = MMC_VDD_32_33 | MMC_VDD_33_34,
  765. };
  766. static struct platform_device sh_mmcif_device = {
  767. .name = "sh_mmcif",
  768. .id = 0,
  769. .dev = {
  770. .platform_data = &sh_mmcif_plat,
  771. },
  772. .num_resources = ARRAY_SIZE(sh_mmcif_resources),
  773. .resource = sh_mmcif_resources,
  774. };
  775. #endif
  776. static struct platform_device *ecovec_devices[] __initdata = {
  777. &heartbeat_device,
  778. &nor_flash_device,
  779. &sh_eth_device,
  780. &usb0_host_device,
  781. &usb1_common_device,
  782. &lcdc_device,
  783. &ceu0_device,
  784. &ceu1_device,
  785. &keysc_device,
  786. #ifdef CONFIG_MFD_SH_MOBILE_SDHI
  787. &sdhi0_device,
  788. #if !defined(CONFIG_MMC_SH_MMCIF)
  789. &sdhi1_device,
  790. #endif
  791. #else
  792. &msiof0_device,
  793. #endif
  794. &camera_devices[0],
  795. &camera_devices[1],
  796. &camera_devices[2],
  797. &fsi_device,
  798. &irda_device,
  799. &vou_device,
  800. #if defined(CONFIG_MMC_SH_MMCIF)
  801. &sh_mmcif_device,
  802. #endif
  803. };
  804. #ifdef CONFIG_I2C
  805. #define EEPROM_ADDR 0x50
  806. static u8 mac_read(struct i2c_adapter *a, u8 command)
  807. {
  808. struct i2c_msg msg[2];
  809. u8 buf;
  810. int ret;
  811. msg[0].addr = EEPROM_ADDR;
  812. msg[0].flags = 0;
  813. msg[0].len = 1;
  814. msg[0].buf = &command;
  815. msg[1].addr = EEPROM_ADDR;
  816. msg[1].flags = I2C_M_RD;
  817. msg[1].len = 1;
  818. msg[1].buf = &buf;
  819. ret = i2c_transfer(a, msg, 2);
  820. if (ret < 0) {
  821. printk(KERN_ERR "error %d\n", ret);
  822. buf = 0xff;
  823. }
  824. return buf;
  825. }
  826. static void __init sh_eth_init(struct sh_eth_plat_data *pd)
  827. {
  828. struct i2c_adapter *a = i2c_get_adapter(1);
  829. int i;
  830. if (!a) {
  831. pr_err("can not get I2C 1\n");
  832. return;
  833. }
  834. /* read MAC address frome EEPROM */
  835. for (i = 0; i < sizeof(pd->mac_addr); i++) {
  836. pd->mac_addr[i] = mac_read(a, 0x10 + i);
  837. msleep(10);
  838. }
  839. i2c_put_adapter(a);
  840. }
  841. #else
  842. static void __init sh_eth_init(struct sh_eth_plat_data *pd)
  843. {
  844. pr_err("unable to read sh_eth MAC address\n");
  845. }
  846. #endif
  847. #define PORT_HIZA 0xA4050158
  848. #define IODRIVEA 0xA405018A
  849. extern char ecovec24_sdram_enter_start;
  850. extern char ecovec24_sdram_enter_end;
  851. extern char ecovec24_sdram_leave_start;
  852. extern char ecovec24_sdram_leave_end;
  853. static int __init arch_setup(void)
  854. {
  855. struct clk *clk;
  856. /* register board specific self-refresh code */
  857. sh_mobile_register_self_refresh(SUSP_SH_STANDBY | SUSP_SH_SF |
  858. SUSP_SH_RSTANDBY,
  859. &ecovec24_sdram_enter_start,
  860. &ecovec24_sdram_enter_end,
  861. &ecovec24_sdram_leave_start,
  862. &ecovec24_sdram_leave_end);
  863. /* enable STATUS0, STATUS2 and PDSTATUS */
  864. gpio_request(GPIO_FN_STATUS0, NULL);
  865. gpio_request(GPIO_FN_STATUS2, NULL);
  866. gpio_request(GPIO_FN_PDSTATUS, NULL);
  867. /* enable SCIFA0 */
  868. gpio_request(GPIO_FN_SCIF0_TXD, NULL);
  869. gpio_request(GPIO_FN_SCIF0_RXD, NULL);
  870. /* enable debug LED */
  871. gpio_request(GPIO_PTG0, NULL);
  872. gpio_request(GPIO_PTG1, NULL);
  873. gpio_request(GPIO_PTG2, NULL);
  874. gpio_request(GPIO_PTG3, NULL);
  875. gpio_direction_output(GPIO_PTG0, 0);
  876. gpio_direction_output(GPIO_PTG1, 0);
  877. gpio_direction_output(GPIO_PTG2, 0);
  878. gpio_direction_output(GPIO_PTG3, 0);
  879. __raw_writew((__raw_readw(PORT_HIZA) & ~(0x1 << 1)) , PORT_HIZA);
  880. /* enable SH-Eth */
  881. gpio_request(GPIO_PTA1, NULL);
  882. gpio_direction_output(GPIO_PTA1, 1);
  883. mdelay(20);
  884. gpio_request(GPIO_FN_RMII_RXD0, NULL);
  885. gpio_request(GPIO_FN_RMII_RXD1, NULL);
  886. gpio_request(GPIO_FN_RMII_TXD0, NULL);
  887. gpio_request(GPIO_FN_RMII_TXD1, NULL);
  888. gpio_request(GPIO_FN_RMII_REF_CLK, NULL);
  889. gpio_request(GPIO_FN_RMII_TX_EN, NULL);
  890. gpio_request(GPIO_FN_RMII_RX_ER, NULL);
  891. gpio_request(GPIO_FN_RMII_CRS_DV, NULL);
  892. gpio_request(GPIO_FN_MDIO, NULL);
  893. gpio_request(GPIO_FN_MDC, NULL);
  894. gpio_request(GPIO_FN_LNKSTA, NULL);
  895. /* enable USB */
  896. __raw_writew(0x0000, 0xA4D80000);
  897. __raw_writew(0x0000, 0xA4D90000);
  898. gpio_request(GPIO_PTB3, NULL);
  899. gpio_request(GPIO_PTB4, NULL);
  900. gpio_request(GPIO_PTB5, NULL);
  901. gpio_direction_input(GPIO_PTB3);
  902. gpio_direction_output(GPIO_PTB4, 0);
  903. gpio_direction_output(GPIO_PTB5, 0);
  904. __raw_writew(0x0600, 0xa40501d4);
  905. __raw_writew(0x0600, 0xa4050192);
  906. if (gpio_get_value(GPIO_PTB3)) {
  907. printk(KERN_INFO "USB1 function is selected\n");
  908. usb1_common_device.name = "r8a66597_udc";
  909. } else {
  910. printk(KERN_INFO "USB1 host is selected\n");
  911. usb1_common_device.name = "r8a66597_hcd";
  912. }
  913. /* enable LCDC */
  914. gpio_request(GPIO_FN_LCDD23, NULL);
  915. gpio_request(GPIO_FN_LCDD22, NULL);
  916. gpio_request(GPIO_FN_LCDD21, NULL);
  917. gpio_request(GPIO_FN_LCDD20, NULL);
  918. gpio_request(GPIO_FN_LCDD19, NULL);
  919. gpio_request(GPIO_FN_LCDD18, NULL);
  920. gpio_request(GPIO_FN_LCDD17, NULL);
  921. gpio_request(GPIO_FN_LCDD16, NULL);
  922. gpio_request(GPIO_FN_LCDD15, NULL);
  923. gpio_request(GPIO_FN_LCDD14, NULL);
  924. gpio_request(GPIO_FN_LCDD13, NULL);
  925. gpio_request(GPIO_FN_LCDD12, NULL);
  926. gpio_request(GPIO_FN_LCDD11, NULL);
  927. gpio_request(GPIO_FN_LCDD10, NULL);
  928. gpio_request(GPIO_FN_LCDD9, NULL);
  929. gpio_request(GPIO_FN_LCDD8, NULL);
  930. gpio_request(GPIO_FN_LCDD7, NULL);
  931. gpio_request(GPIO_FN_LCDD6, NULL);
  932. gpio_request(GPIO_FN_LCDD5, NULL);
  933. gpio_request(GPIO_FN_LCDD4, NULL);
  934. gpio_request(GPIO_FN_LCDD3, NULL);
  935. gpio_request(GPIO_FN_LCDD2, NULL);
  936. gpio_request(GPIO_FN_LCDD1, NULL);
  937. gpio_request(GPIO_FN_LCDD0, NULL);
  938. gpio_request(GPIO_FN_LCDDISP, NULL);
  939. gpio_request(GPIO_FN_LCDHSYN, NULL);
  940. gpio_request(GPIO_FN_LCDDCK, NULL);
  941. gpio_request(GPIO_FN_LCDVSYN, NULL);
  942. gpio_request(GPIO_FN_LCDDON, NULL);
  943. gpio_request(GPIO_FN_LCDLCLK, NULL);
  944. __raw_writew((__raw_readw(PORT_HIZA) & ~0x0001), PORT_HIZA);
  945. gpio_request(GPIO_PTE6, NULL);
  946. gpio_request(GPIO_PTU1, NULL);
  947. gpio_request(GPIO_PTR1, NULL);
  948. gpio_request(GPIO_PTA2, NULL);
  949. gpio_direction_input(GPIO_PTE6);
  950. gpio_direction_output(GPIO_PTU1, 0);
  951. gpio_direction_output(GPIO_PTR1, 0);
  952. gpio_direction_output(GPIO_PTA2, 0);
  953. /* I/O buffer drive ability is high */
  954. __raw_writew((__raw_readw(IODRIVEA) & ~0x00c0) | 0x0080 , IODRIVEA);
  955. if (gpio_get_value(GPIO_PTE6)) {
  956. /* DVI */
  957. lcdc_info.clock_source = LCDC_CLK_EXTERNAL;
  958. lcdc_info.ch[0].clock_divider = 1;
  959. lcdc_info.ch[0].lcd_cfg = ecovec_dvi_modes;
  960. lcdc_info.ch[0].num_cfg = ARRAY_SIZE(ecovec_dvi_modes);
  961. gpio_set_value(GPIO_PTA2, 1);
  962. gpio_set_value(GPIO_PTU1, 1);
  963. } else {
  964. /* Panel */
  965. lcdc_info.clock_source = LCDC_CLK_PERIPHERAL;
  966. lcdc_info.ch[0].clock_divider = 2;
  967. lcdc_info.ch[0].lcd_cfg = ecovec_lcd_modes;
  968. lcdc_info.ch[0].num_cfg = ARRAY_SIZE(ecovec_lcd_modes);
  969. gpio_set_value(GPIO_PTR1, 1);
  970. /* FIXME
  971. *
  972. * LCDDON control is needed for Panel,
  973. * but current sh_mobile_lcdc driver doesn't control it.
  974. * It is temporary correspondence
  975. */
  976. gpio_request(GPIO_PTF4, NULL);
  977. gpio_direction_output(GPIO_PTF4, 1);
  978. /* enable TouchScreen */
  979. i2c_register_board_info(0, &ts_i2c_clients, 1);
  980. set_irq_type(IRQ0, IRQ_TYPE_LEVEL_LOW);
  981. }
  982. /* enable CEU0 */
  983. gpio_request(GPIO_FN_VIO0_D15, NULL);
  984. gpio_request(GPIO_FN_VIO0_D14, NULL);
  985. gpio_request(GPIO_FN_VIO0_D13, NULL);
  986. gpio_request(GPIO_FN_VIO0_D12, NULL);
  987. gpio_request(GPIO_FN_VIO0_D11, NULL);
  988. gpio_request(GPIO_FN_VIO0_D10, NULL);
  989. gpio_request(GPIO_FN_VIO0_D9, NULL);
  990. gpio_request(GPIO_FN_VIO0_D8, NULL);
  991. gpio_request(GPIO_FN_VIO0_D7, NULL);
  992. gpio_request(GPIO_FN_VIO0_D6, NULL);
  993. gpio_request(GPIO_FN_VIO0_D5, NULL);
  994. gpio_request(GPIO_FN_VIO0_D4, NULL);
  995. gpio_request(GPIO_FN_VIO0_D3, NULL);
  996. gpio_request(GPIO_FN_VIO0_D2, NULL);
  997. gpio_request(GPIO_FN_VIO0_D1, NULL);
  998. gpio_request(GPIO_FN_VIO0_D0, NULL);
  999. gpio_request(GPIO_FN_VIO0_VD, NULL);
  1000. gpio_request(GPIO_FN_VIO0_CLK, NULL);
  1001. gpio_request(GPIO_FN_VIO0_FLD, NULL);
  1002. gpio_request(GPIO_FN_VIO0_HD, NULL);
  1003. platform_resource_setup_memory(&ceu0_device, "ceu0", 4 << 20);
  1004. /* enable CEU1 */
  1005. gpio_request(GPIO_FN_VIO1_D7, NULL);
  1006. gpio_request(GPIO_FN_VIO1_D6, NULL);
  1007. gpio_request(GPIO_FN_VIO1_D5, NULL);
  1008. gpio_request(GPIO_FN_VIO1_D4, NULL);
  1009. gpio_request(GPIO_FN_VIO1_D3, NULL);
  1010. gpio_request(GPIO_FN_VIO1_D2, NULL);
  1011. gpio_request(GPIO_FN_VIO1_D1, NULL);
  1012. gpio_request(GPIO_FN_VIO1_D0, NULL);
  1013. gpio_request(GPIO_FN_VIO1_FLD, NULL);
  1014. gpio_request(GPIO_FN_VIO1_HD, NULL);
  1015. gpio_request(GPIO_FN_VIO1_VD, NULL);
  1016. gpio_request(GPIO_FN_VIO1_CLK, NULL);
  1017. platform_resource_setup_memory(&ceu1_device, "ceu1", 4 << 20);
  1018. /* enable KEYSC */
  1019. gpio_request(GPIO_FN_KEYOUT5_IN5, NULL);
  1020. gpio_request(GPIO_FN_KEYOUT4_IN6, NULL);
  1021. gpio_request(GPIO_FN_KEYOUT3, NULL);
  1022. gpio_request(GPIO_FN_KEYOUT2, NULL);
  1023. gpio_request(GPIO_FN_KEYOUT1, NULL);
  1024. gpio_request(GPIO_FN_KEYOUT0, NULL);
  1025. gpio_request(GPIO_FN_KEYIN0, NULL);
  1026. /* enable user debug switch */
  1027. gpio_request(GPIO_PTR0, NULL);
  1028. gpio_request(GPIO_PTR4, NULL);
  1029. gpio_request(GPIO_PTR5, NULL);
  1030. gpio_request(GPIO_PTR6, NULL);
  1031. gpio_direction_input(GPIO_PTR0);
  1032. gpio_direction_input(GPIO_PTR4);
  1033. gpio_direction_input(GPIO_PTR5);
  1034. gpio_direction_input(GPIO_PTR6);
  1035. #ifdef CONFIG_MFD_SH_MOBILE_SDHI
  1036. /* enable SDHI0 on CN11 (needs DS2.4 set to ON) */
  1037. gpio_request(GPIO_FN_SDHI0CD, NULL);
  1038. gpio_request(GPIO_FN_SDHI0WP, NULL);
  1039. gpio_request(GPIO_FN_SDHI0CMD, NULL);
  1040. gpio_request(GPIO_FN_SDHI0CLK, NULL);
  1041. gpio_request(GPIO_FN_SDHI0D3, NULL);
  1042. gpio_request(GPIO_FN_SDHI0D2, NULL);
  1043. gpio_request(GPIO_FN_SDHI0D1, NULL);
  1044. gpio_request(GPIO_FN_SDHI0D0, NULL);
  1045. gpio_request(GPIO_PTB6, NULL);
  1046. gpio_direction_output(GPIO_PTB6, 0);
  1047. #if !defined(CONFIG_MMC_SH_MMCIF)
  1048. /* enable SDHI1 on CN12 (needs DS2.6,7 set to ON,OFF) */
  1049. gpio_request(GPIO_FN_SDHI1CD, NULL);
  1050. gpio_request(GPIO_FN_SDHI1WP, NULL);
  1051. gpio_request(GPIO_FN_SDHI1CMD, NULL);
  1052. gpio_request(GPIO_FN_SDHI1CLK, NULL);
  1053. gpio_request(GPIO_FN_SDHI1D3, NULL);
  1054. gpio_request(GPIO_FN_SDHI1D2, NULL);
  1055. gpio_request(GPIO_FN_SDHI1D1, NULL);
  1056. gpio_request(GPIO_FN_SDHI1D0, NULL);
  1057. gpio_request(GPIO_PTB7, NULL);
  1058. gpio_direction_output(GPIO_PTB7, 0);
  1059. /* I/O buffer drive ability is high for SDHI1 */
  1060. __raw_writew((__raw_readw(IODRIVEA) & ~0x3000) | 0x2000 , IODRIVEA);
  1061. #endif /* CONFIG_MMC_SH_MMCIF */
  1062. #else
  1063. /* enable MSIOF0 on CN11 (needs DS2.4 set to OFF) */
  1064. gpio_request(GPIO_FN_MSIOF0_TXD, NULL);
  1065. gpio_request(GPIO_FN_MSIOF0_RXD, NULL);
  1066. gpio_request(GPIO_FN_MSIOF0_TSCK, NULL);
  1067. gpio_request(GPIO_PTM4, NULL); /* software CS control of TSYNC pin */
  1068. gpio_direction_output(GPIO_PTM4, 1); /* active low CS */
  1069. gpio_request(GPIO_PTB6, NULL); /* 3.3V power control */
  1070. gpio_direction_output(GPIO_PTB6, 0); /* disable power by default */
  1071. gpio_request(GPIO_PTY6, NULL); /* write protect */
  1072. gpio_direction_input(GPIO_PTY6);
  1073. gpio_request(GPIO_PTY7, NULL); /* card detect */
  1074. gpio_direction_input(GPIO_PTY7);
  1075. spi_register_board_info(spi_bus, ARRAY_SIZE(spi_bus));
  1076. #endif
  1077. /* enable Video */
  1078. gpio_request(GPIO_PTU2, NULL);
  1079. gpio_direction_output(GPIO_PTU2, 1);
  1080. /* enable Camera */
  1081. gpio_request(GPIO_PTA3, NULL);
  1082. gpio_request(GPIO_PTA4, NULL);
  1083. gpio_direction_output(GPIO_PTA3, 0);
  1084. gpio_direction_output(GPIO_PTA4, 0);
  1085. /* enable FSI */
  1086. gpio_request(GPIO_FN_FSIMCKB, NULL);
  1087. gpio_request(GPIO_FN_FSIIBSD, NULL);
  1088. gpio_request(GPIO_FN_FSIOBSD, NULL);
  1089. gpio_request(GPIO_FN_FSIIBBCK, NULL);
  1090. gpio_request(GPIO_FN_FSIIBLRCK, NULL);
  1091. gpio_request(GPIO_FN_FSIOBBCK, NULL);
  1092. gpio_request(GPIO_FN_FSIOBLRCK, NULL);
  1093. gpio_request(GPIO_FN_CLKAUDIOBO, NULL);
  1094. /* set SPU2 clock to 83.4 MHz */
  1095. clk = clk_get(NULL, "spu_clk");
  1096. if (!IS_ERR(clk)) {
  1097. clk_set_rate(clk, clk_round_rate(clk, 83333333));
  1098. clk_put(clk);
  1099. }
  1100. /* change parent of FSI B */
  1101. clk = clk_get(NULL, "fsib_clk");
  1102. if (!IS_ERR(clk)) {
  1103. /* 48kHz dummy clock was used to make sure 1/1 divide */
  1104. clk_set_rate(&sh7724_fsimckb_clk, 48000);
  1105. clk_set_parent(clk, &sh7724_fsimckb_clk);
  1106. clk_set_rate(clk, 48000);
  1107. clk_put(clk);
  1108. }
  1109. gpio_request(GPIO_PTU0, NULL);
  1110. gpio_direction_output(GPIO_PTU0, 0);
  1111. mdelay(20);
  1112. /* enable motion sensor */
  1113. gpio_request(GPIO_FN_INTC_IRQ1, NULL);
  1114. gpio_direction_input(GPIO_FN_INTC_IRQ1);
  1115. /* set VPU clock to 166 MHz */
  1116. clk = clk_get(NULL, "vpu_clk");
  1117. if (!IS_ERR(clk)) {
  1118. clk_set_rate(clk, clk_round_rate(clk, 166000000));
  1119. clk_put(clk);
  1120. }
  1121. /* enable IrDA */
  1122. gpio_request(GPIO_FN_IRDA_OUT, NULL);
  1123. gpio_request(GPIO_FN_IRDA_IN, NULL);
  1124. gpio_request(GPIO_PTU5, NULL);
  1125. gpio_direction_output(GPIO_PTU5, 0);
  1126. #if defined(CONFIG_MMC_SH_MMCIF)
  1127. /* enable MMCIF (needs DS2.6,7 set to OFF,ON) */
  1128. gpio_request(GPIO_FN_MMC_D7, NULL);
  1129. gpio_request(GPIO_FN_MMC_D6, NULL);
  1130. gpio_request(GPIO_FN_MMC_D5, NULL);
  1131. gpio_request(GPIO_FN_MMC_D4, NULL);
  1132. gpio_request(GPIO_FN_MMC_D3, NULL);
  1133. gpio_request(GPIO_FN_MMC_D2, NULL);
  1134. gpio_request(GPIO_FN_MMC_D1, NULL);
  1135. gpio_request(GPIO_FN_MMC_D0, NULL);
  1136. gpio_request(GPIO_FN_MMC_CLK, NULL);
  1137. gpio_request(GPIO_FN_MMC_CMD, NULL);
  1138. gpio_request(GPIO_PTB7, NULL);
  1139. gpio_direction_output(GPIO_PTB7, 0);
  1140. /* I/O buffer drive ability is high for MMCIF */
  1141. __raw_writew((__raw_readw(IODRIVEA) & ~0x3000) | 0x2000 , IODRIVEA);
  1142. #endif
  1143. /* enable I2C device */
  1144. i2c_register_board_info(0, i2c0_devices,
  1145. ARRAY_SIZE(i2c0_devices));
  1146. i2c_register_board_info(1, i2c1_devices,
  1147. ARRAY_SIZE(i2c1_devices));
  1148. /* VOU */
  1149. gpio_request(GPIO_FN_DV_D15, NULL);
  1150. gpio_request(GPIO_FN_DV_D14, NULL);
  1151. gpio_request(GPIO_FN_DV_D13, NULL);
  1152. gpio_request(GPIO_FN_DV_D12, NULL);
  1153. gpio_request(GPIO_FN_DV_D11, NULL);
  1154. gpio_request(GPIO_FN_DV_D10, NULL);
  1155. gpio_request(GPIO_FN_DV_D9, NULL);
  1156. gpio_request(GPIO_FN_DV_D8, NULL);
  1157. gpio_request(GPIO_FN_DV_CLKI, NULL);
  1158. gpio_request(GPIO_FN_DV_CLK, NULL);
  1159. gpio_request(GPIO_FN_DV_VSYNC, NULL);
  1160. gpio_request(GPIO_FN_DV_HSYNC, NULL);
  1161. /* AK8813 power / reset sequence */
  1162. gpio_request(GPIO_PTG4, NULL);
  1163. gpio_request(GPIO_PTU3, NULL);
  1164. /* Reset */
  1165. gpio_direction_output(GPIO_PTG4, 0);
  1166. /* Power down */
  1167. gpio_direction_output(GPIO_PTU3, 1);
  1168. udelay(10);
  1169. /* Power up, reset */
  1170. gpio_set_value(GPIO_PTU3, 0);
  1171. udelay(10);
  1172. /* Remove reset */
  1173. gpio_set_value(GPIO_PTG4, 1);
  1174. return platform_add_devices(ecovec_devices,
  1175. ARRAY_SIZE(ecovec_devices));
  1176. }
  1177. arch_initcall(arch_setup);
  1178. static int __init devices_setup(void)
  1179. {
  1180. sh_eth_init(&sh_eth_plat);
  1181. return 0;
  1182. }
  1183. device_initcall(devices_setup);
  1184. static struct sh_machine_vector mv_ecovec __initmv = {
  1185. .mv_name = "R0P7724 (EcoVec)",
  1186. };