setup.c 34 KB

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