setup.c 34 KB

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