setup.c 36 KB

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