1aaf9128aSKuninori Morimoto // SPDX-License-Identifier: GPL-2.0
24138b740SKuninori Morimoto /*
34138b740SKuninori Morimoto * Copyright (C) 2009 Renesas Solutions Corp.
44138b740SKuninori Morimoto *
54138b740SKuninori Morimoto * Kuninori Morimoto <morimoto.kuninori@renesas.com>
64138b740SKuninori Morimoto */
7c2f9b05fSJacopo Mondi #include <asm/clock.h>
8c2f9b05fSJacopo Mondi #include <asm/heartbeat.h>
9c2f9b05fSJacopo Mondi #include <asm/suspend.h>
10c2f9b05fSJacopo Mondi #include <cpu/sh7724.h>
11c2f9b05fSJacopo Mondi #include <linux/delay.h>
124138b740SKuninori Morimoto #include <linux/device.h>
13c2f9b05fSJacopo Mondi #include <linux/i2c.h>
14c2f9b05fSJacopo Mondi #include <linux/io.h>
15c2f9b05fSJacopo Mondi #include <linux/init.h>
16c2f9b05fSJacopo Mondi #include <linux/input.h>
17c2f9b05fSJacopo Mondi #include <linux/input/sh_keysc.h>
18c2f9b05fSJacopo Mondi #include <linux/interrupt.h>
19c2f9b05fSJacopo Mondi #include <linux/memblock.h>
20c2f9b05fSJacopo Mondi #include <linux/mfd/tmio.h>
211238c684SYusuke Goda #include <linux/mmc/host.h>
2213acb62cSWolfram Sang #include <linux/platform_data/sh_mmcif.h>
234138b740SKuninori Morimoto #include <linux/mtd/physmap.h>
244138b740SKuninori Morimoto #include <linux/gpio.h>
25c2f9b05fSJacopo Mondi #include <linux/gpio/machine.h>
26c2f9b05fSJacopo Mondi #include <linux/platform_data/gpio_backlight.h>
27c2f9b05fSJacopo Mondi #include <linux/platform_data/tsc2007.h>
28c2f9b05fSJacopo Mondi #include <linux/platform_device.h>
29d4c191dfSGuennadi Liakhovetski #include <linux/regulator/fixed.h>
30d4c191dfSGuennadi Liakhovetski #include <linux/regulator/machine.h>
31cf8e56bfSYoshihiro Shimoda #include <linux/sh_eth.h>
329307d115SPaul Mundt #include <linux/sh_intc.h>
33c2f9b05fSJacopo Mondi #include <linux/spi/mmc_spi.h>
34c2f9b05fSJacopo Mondi #include <linux/spi/sh_msiof.h>
35c2f9b05fSJacopo Mondi #include <linux/spi/spi.h>
36c2f9b05fSJacopo Mondi #include <linux/usb/r8a66597.h>
37c2f9b05fSJacopo Mondi #include <linux/usb/renesas_usbhs.h>
38a1ad8033SGuennadi Liakhovetski #include <linux/videodev2.h>
390a0f0d8bSChristoph Hellwig #include <linux/dma-map-ops.h>
40c2f9b05fSJacopo Mondi
41c2f9b05fSJacopo Mondi #include <media/drv-intf/renesas-ceu.h>
42c2f9b05fSJacopo Mondi #include <media/i2c/mt9t112.h>
43c2f9b05fSJacopo Mondi #include <media/i2c/tw9910.h>
44c2f9b05fSJacopo Mondi
451980fdc4SKuninori Morimoto #include <sound/sh_fsi.h>
46064bfadaSKuninori Morimoto #include <sound/simple_card.h>
47c2f9b05fSJacopo Mondi
48c2f9b05fSJacopo Mondi #include <video/sh_mobile_lcdc.h>
494138b740SKuninori Morimoto
504138b740SKuninori Morimoto /*
51b7056bc1SKuninori Morimoto * Address Interface BusWidth
52b7056bc1SKuninori Morimoto *-----------------------------------------
53b7056bc1SKuninori Morimoto * 0x0000_0000 uboot 16bit
54b7056bc1SKuninori Morimoto * 0x0004_0000 Linux romImage 16bit
55b7056bc1SKuninori Morimoto * 0x0014_0000 MTD for Linux 16bit
56b7056bc1SKuninori Morimoto * 0x0400_0000 Internal I/O 16/32bit
57b7056bc1SKuninori Morimoto * 0x0800_0000 DRAM 32bit
58b7056bc1SKuninori Morimoto * 0x1800_0000 MFI 16bit
594138b740SKuninori Morimoto */
604138b740SKuninori Morimoto
619c472c4dSKuninori Morimoto /* SWITCH
629c472c4dSKuninori Morimoto *------------------------------
639c472c4dSKuninori Morimoto * DS2[1] = FlashROM write protect ON : write protect
649c472c4dSKuninori Morimoto * OFF : No write protect
659c472c4dSKuninori Morimoto * DS2[2] = RMII / TS, SCIF ON : RMII
669c472c4dSKuninori Morimoto * OFF : TS, SCIF3
679c472c4dSKuninori Morimoto * DS2[3] = Camera / Video ON : Camera
689c472c4dSKuninori Morimoto * OFF : NTSC/PAL (IN)
699c472c4dSKuninori Morimoto * DS2[5] = NTSC_OUT Clock ON : On board OSC
709c472c4dSKuninori Morimoto * OFF : SH7724 DV_CLK
719c472c4dSKuninori Morimoto * DS2[6-7] = MMC / SD ON-OFF : SD
729c472c4dSKuninori Morimoto * OFF-ON : MMC
739c472c4dSKuninori Morimoto */
749c472c4dSKuninori Morimoto
75035688d9SKuninori Morimoto /*
76035688d9SKuninori Morimoto * FSI - DA7210
77035688d9SKuninori Morimoto *
78035688d9SKuninori Morimoto * it needs amixer settings for playing
79035688d9SKuninori Morimoto *
80035688d9SKuninori Morimoto * amixer set 'HeadPhone' 80
81035688d9SKuninori Morimoto * amixer set 'Out Mixer Left DAC Left' on
82035688d9SKuninori Morimoto * amixer set 'Out Mixer Right DAC Right' on
83035688d9SKuninori Morimoto */
84035688d9SKuninori Morimoto
85c2f9b05fSJacopo Mondi #define CEU_BUFFER_MEMORY_SIZE (4 << 20)
86c2f9b05fSJacopo Mondi static phys_addr_t ceu0_dma_membase;
87c2f9b05fSJacopo Mondi static phys_addr_t ceu1_dma_membase;
88c2f9b05fSJacopo Mondi
894138b740SKuninori Morimoto /* Heartbeat */
904138b740SKuninori Morimoto static unsigned char led_pos[] = { 0, 1, 2, 3 };
91a09d2831SPaul Mundt
924138b740SKuninori Morimoto static struct heartbeat_data heartbeat_data = {
934138b740SKuninori Morimoto .nr_bits = 4,
944138b740SKuninori Morimoto .bit_pos = led_pos,
954138b740SKuninori Morimoto };
964138b740SKuninori Morimoto
97a09d2831SPaul Mundt static struct resource heartbeat_resource = {
984138b740SKuninori Morimoto .start = 0xA405012C, /* PTG */
994138b740SKuninori Morimoto .end = 0xA405012E - 1,
100a09d2831SPaul Mundt .flags = IORESOURCE_MEM | IORESOURCE_MEM_8BIT,
1014138b740SKuninori Morimoto };
1024138b740SKuninori Morimoto
1034138b740SKuninori Morimoto static struct platform_device heartbeat_device = {
1044138b740SKuninori Morimoto .name = "heartbeat",
1054138b740SKuninori Morimoto .id = -1,
1064138b740SKuninori Morimoto .dev = {
1074138b740SKuninori Morimoto .platform_data = &heartbeat_data,
1084138b740SKuninori Morimoto },
109a09d2831SPaul Mundt .num_resources = 1,
110a09d2831SPaul Mundt .resource = &heartbeat_resource,
1114138b740SKuninori Morimoto };
1124138b740SKuninori Morimoto
1134138b740SKuninori Morimoto /* MTD */
1144138b740SKuninori Morimoto static struct mtd_partition nor_flash_partitions[] = {
1154138b740SKuninori Morimoto {
116b7056bc1SKuninori Morimoto .name = "boot loader",
1174138b740SKuninori Morimoto .offset = 0,
118b7056bc1SKuninori Morimoto .size = (5 * 1024 * 1024),
119d5ce010cSKuninori Morimoto .mask_flags = MTD_WRITEABLE, /* force read-only */
1204138b740SKuninori Morimoto }, {
1214138b740SKuninori Morimoto .name = "free-area",
1224138b740SKuninori Morimoto .offset = MTDPART_OFS_APPEND,
1234138b740SKuninori Morimoto .size = MTDPART_SIZ_FULL,
1244138b740SKuninori Morimoto },
1254138b740SKuninori Morimoto };
1264138b740SKuninori Morimoto
1274138b740SKuninori Morimoto static struct physmap_flash_data nor_flash_data = {
1284138b740SKuninori Morimoto .width = 2,
1294138b740SKuninori Morimoto .parts = nor_flash_partitions,
1304138b740SKuninori Morimoto .nr_parts = ARRAY_SIZE(nor_flash_partitions),
1314138b740SKuninori Morimoto };
1324138b740SKuninori Morimoto
1334138b740SKuninori Morimoto static struct resource nor_flash_resources[] = {
1344138b740SKuninori Morimoto [0] = {
1354138b740SKuninori Morimoto .name = "NOR Flash",
1364138b740SKuninori Morimoto .start = 0x00000000,
1374138b740SKuninori Morimoto .end = 0x03ffffff,
1384138b740SKuninori Morimoto .flags = IORESOURCE_MEM,
1394138b740SKuninori Morimoto }
1404138b740SKuninori Morimoto };
1414138b740SKuninori Morimoto
1424138b740SKuninori Morimoto static struct platform_device nor_flash_device = {
1434138b740SKuninori Morimoto .name = "physmap-flash",
1444138b740SKuninori Morimoto .resource = nor_flash_resources,
1454138b740SKuninori Morimoto .num_resources = ARRAY_SIZE(nor_flash_resources),
1464138b740SKuninori Morimoto .dev = {
1474138b740SKuninori Morimoto .platform_data = &nor_flash_data,
1484138b740SKuninori Morimoto },
1494138b740SKuninori Morimoto };
1504138b740SKuninori Morimoto
15135a35408SKuninori Morimoto /* SH Eth */
15235a35408SKuninori Morimoto #define SH_ETH_ADDR (0xA4600000)
15335a35408SKuninori Morimoto static struct resource sh_eth_resources[] = {
15435a35408SKuninori Morimoto [0] = {
15535a35408SKuninori Morimoto .start = SH_ETH_ADDR,
15635a35408SKuninori Morimoto .end = SH_ETH_ADDR + 0x1FC,
15735a35408SKuninori Morimoto .flags = IORESOURCE_MEM,
15835a35408SKuninori Morimoto },
15935a35408SKuninori Morimoto [1] = {
1609307d115SPaul Mundt .start = evt2irq(0xd60),
16135a35408SKuninori Morimoto .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
16235a35408SKuninori Morimoto },
16335a35408SKuninori Morimoto };
16435a35408SKuninori Morimoto
1653ce09334SKuninori Morimoto static struct sh_eth_plat_data sh_eth_plat = {
16635a35408SKuninori Morimoto .phy = 0x1f, /* SMSC LAN8700 */
1679055f895SYoshihiro Shimoda .phy_interface = PHY_INTERFACE_MODE_MII,
168acf3cc28SKuninori Morimoto .ether_link_active_low = 1
16935a35408SKuninori Morimoto };
17035a35408SKuninori Morimoto
17135a35408SKuninori Morimoto static struct platform_device sh_eth_device = {
1729c3beaabSSergei Shtylyov .name = "sh7724-ether",
17335a35408SKuninori Morimoto .id = 0,
17435a35408SKuninori Morimoto .dev = {
17535a35408SKuninori Morimoto .platform_data = &sh_eth_plat,
17635a35408SKuninori Morimoto },
17735a35408SKuninori Morimoto .num_resources = ARRAY_SIZE(sh_eth_resources),
17835a35408SKuninori Morimoto .resource = sh_eth_resources,
17935a35408SKuninori Morimoto };
18035a35408SKuninori Morimoto
181907050a3SKuninori Morimoto /* USB0 host */
usb0_port_power(int port,int power)1823ce09334SKuninori Morimoto static void usb0_port_power(int port, int power)
183907050a3SKuninori Morimoto {
184907050a3SKuninori Morimoto gpio_set_value(GPIO_PTB4, power);
185907050a3SKuninori Morimoto }
186907050a3SKuninori Morimoto
187907050a3SKuninori Morimoto static struct r8a66597_platdata usb0_host_data = {
188907050a3SKuninori Morimoto .on_chip = 1,
189907050a3SKuninori Morimoto .port_power = usb0_port_power,
190907050a3SKuninori Morimoto };
191907050a3SKuninori Morimoto
192907050a3SKuninori Morimoto static struct resource usb0_host_resources[] = {
193907050a3SKuninori Morimoto [0] = {
194907050a3SKuninori Morimoto .start = 0xa4d80000,
195907050a3SKuninori Morimoto .end = 0xa4d80124 - 1,
196907050a3SKuninori Morimoto .flags = IORESOURCE_MEM,
197907050a3SKuninori Morimoto },
198907050a3SKuninori Morimoto [1] = {
1999307d115SPaul Mundt .start = evt2irq(0xa20),
2009307d115SPaul Mundt .end = evt2irq(0xa20),
201907050a3SKuninori Morimoto .flags = IORESOURCE_IRQ | IRQF_TRIGGER_LOW,
202907050a3SKuninori Morimoto },
203907050a3SKuninori Morimoto };
204907050a3SKuninori Morimoto
205907050a3SKuninori Morimoto static struct platform_device usb0_host_device = {
206907050a3SKuninori Morimoto .name = "r8a66597_hcd",
207907050a3SKuninori Morimoto .id = 0,
208907050a3SKuninori Morimoto .dev = {
209907050a3SKuninori Morimoto .dma_mask = NULL, /* not use dma */
210907050a3SKuninori Morimoto .coherent_dma_mask = 0xffffffff,
211907050a3SKuninori Morimoto .platform_data = &usb0_host_data,
212907050a3SKuninori Morimoto },
213907050a3SKuninori Morimoto .num_resources = ARRAY_SIZE(usb0_host_resources),
214907050a3SKuninori Morimoto .resource = usb0_host_resources,
215907050a3SKuninori Morimoto };
216907050a3SKuninori Morimoto
2173714a9a0SKuninori Morimoto /* USB1 host/function */
usb1_port_power(int port,int power)2183ce09334SKuninori Morimoto static void usb1_port_power(int port, int power)
219907050a3SKuninori Morimoto {
220907050a3SKuninori Morimoto gpio_set_value(GPIO_PTB5, power);
221907050a3SKuninori Morimoto }
222907050a3SKuninori Morimoto
2233714a9a0SKuninori Morimoto static struct r8a66597_platdata usb1_common_data = {
224907050a3SKuninori Morimoto .on_chip = 1,
225907050a3SKuninori Morimoto .port_power = usb1_port_power,
226907050a3SKuninori Morimoto };
227907050a3SKuninori Morimoto
2283714a9a0SKuninori Morimoto static struct resource usb1_common_resources[] = {
229907050a3SKuninori Morimoto [0] = {
230907050a3SKuninori Morimoto .start = 0xa4d90000,
231907050a3SKuninori Morimoto .end = 0xa4d90124 - 1,
232907050a3SKuninori Morimoto .flags = IORESOURCE_MEM,
233907050a3SKuninori Morimoto },
234907050a3SKuninori Morimoto [1] = {
2359307d115SPaul Mundt .start = evt2irq(0xa40),
2369307d115SPaul Mundt .end = evt2irq(0xa40),
237907050a3SKuninori Morimoto .flags = IORESOURCE_IRQ | IRQF_TRIGGER_LOW,
238907050a3SKuninori Morimoto },
239907050a3SKuninori Morimoto };
240907050a3SKuninori Morimoto
2413714a9a0SKuninori Morimoto static struct platform_device usb1_common_device = {
2423714a9a0SKuninori Morimoto /* .name will be added in arch_setup */
243907050a3SKuninori Morimoto .id = 1,
244907050a3SKuninori Morimoto .dev = {
245907050a3SKuninori Morimoto .dma_mask = NULL, /* not use dma */
246907050a3SKuninori Morimoto .coherent_dma_mask = 0xffffffff,
2473714a9a0SKuninori Morimoto .platform_data = &usb1_common_data,
248907050a3SKuninori Morimoto },
2493714a9a0SKuninori Morimoto .num_resources = ARRAY_SIZE(usb1_common_resources),
2503714a9a0SKuninori Morimoto .resource = usb1_common_resources,
251907050a3SKuninori Morimoto };
252907050a3SKuninori Morimoto
253fb2e7394SKuninori Morimoto /*
254fb2e7394SKuninori Morimoto * USBHS
255fb2e7394SKuninori Morimoto */
usbhs_get_id(struct platform_device * pdev)256fb2e7394SKuninori Morimoto static int usbhs_get_id(struct platform_device *pdev)
257fb2e7394SKuninori Morimoto {
258fb2e7394SKuninori Morimoto return gpio_get_value(GPIO_PTB3);
259fb2e7394SKuninori Morimoto }
260fb2e7394SKuninori Morimoto
usbhs_phy_reset(struct platform_device * pdev)261225da3e3SKuninori Morimoto static int usbhs_phy_reset(struct platform_device *pdev)
2621ca8fe38SKuninori Morimoto {
2631ca8fe38SKuninori Morimoto /* enable vbus if HOST */
2641ca8fe38SKuninori Morimoto if (!gpio_get_value(GPIO_PTB3))
2651ca8fe38SKuninori Morimoto gpio_set_value(GPIO_PTB5, 1);
266225da3e3SKuninori Morimoto
267225da3e3SKuninori Morimoto return 0;
2681ca8fe38SKuninori Morimoto }
2691ca8fe38SKuninori Morimoto
270fb2e7394SKuninori Morimoto static struct renesas_usbhs_platform_info usbhs_info = {
271fb2e7394SKuninori Morimoto .platform_callback = {
272fb2e7394SKuninori Morimoto .get_id = usbhs_get_id,
2731ca8fe38SKuninori Morimoto .phy_reset = usbhs_phy_reset,
274fb2e7394SKuninori Morimoto },
275fb2e7394SKuninori Morimoto .driver_param = {
276fb2e7394SKuninori Morimoto .buswait_bwait = 4,
277fb2e7394SKuninori Morimoto .detection_delay = 5,
2789f0fa799SKuninori Morimoto .d0_tx_id = SHDMA_SLAVE_USB1D0_TX,
2799f0fa799SKuninori Morimoto .d0_rx_id = SHDMA_SLAVE_USB1D0_RX,
2809f0fa799SKuninori Morimoto .d1_tx_id = SHDMA_SLAVE_USB1D1_TX,
2819f0fa799SKuninori Morimoto .d1_rx_id = SHDMA_SLAVE_USB1D1_RX,
282fb2e7394SKuninori Morimoto },
283fb2e7394SKuninori Morimoto };
284fb2e7394SKuninori Morimoto
285fb2e7394SKuninori Morimoto static struct resource usbhs_resources[] = {
286fb2e7394SKuninori Morimoto [0] = {
287fb2e7394SKuninori Morimoto .start = 0xa4d90000,
288fb2e7394SKuninori Morimoto .end = 0xa4d90124 - 1,
289fb2e7394SKuninori Morimoto .flags = IORESOURCE_MEM,
290fb2e7394SKuninori Morimoto },
291fb2e7394SKuninori Morimoto [1] = {
2929307d115SPaul Mundt .start = evt2irq(0xa40),
2939307d115SPaul Mundt .end = evt2irq(0xa40),
294fb2e7394SKuninori Morimoto .flags = IORESOURCE_IRQ,
295fb2e7394SKuninori Morimoto },
296fb2e7394SKuninori Morimoto };
297fb2e7394SKuninori Morimoto
298fb2e7394SKuninori Morimoto static struct platform_device usbhs_device = {
299fb2e7394SKuninori Morimoto .name = "renesas_usbhs",
300fb2e7394SKuninori Morimoto .id = 1,
301fb2e7394SKuninori Morimoto .dev = {
302fb2e7394SKuninori Morimoto .dma_mask = NULL, /* not use dma */
303fb2e7394SKuninori Morimoto .coherent_dma_mask = 0xffffffff,
304fb2e7394SKuninori Morimoto .platform_data = &usbhs_info,
305fb2e7394SKuninori Morimoto },
306fb2e7394SKuninori Morimoto .num_resources = ARRAY_SIZE(usbhs_resources),
307fb2e7394SKuninori Morimoto .resource = usbhs_resources,
308fb2e7394SKuninori Morimoto };
309fb2e7394SKuninori Morimoto
310fe79f919SLaurent Pinchart /* LCDC and backlight */
311e04008ebSJesper Juhl static const struct fb_videomode ecovec_lcd_modes[] = {
31244432407SGuennadi Liakhovetski {
31344432407SGuennadi Liakhovetski .name = "Panel",
31444432407SGuennadi Liakhovetski .xres = 800,
31544432407SGuennadi Liakhovetski .yres = 480,
31644432407SGuennadi Liakhovetski .left_margin = 220,
31744432407SGuennadi Liakhovetski .right_margin = 110,
31844432407SGuennadi Liakhovetski .hsync_len = 70,
31944432407SGuennadi Liakhovetski .upper_margin = 20,
32044432407SGuennadi Liakhovetski .lower_margin = 5,
32144432407SGuennadi Liakhovetski .vsync_len = 5,
32244432407SGuennadi Liakhovetski .sync = 0, /* hsync and vsync are active low */
32344432407SGuennadi Liakhovetski },
32444432407SGuennadi Liakhovetski };
32544432407SGuennadi Liakhovetski
326e04008ebSJesper Juhl static const struct fb_videomode ecovec_dvi_modes[] = {
32744432407SGuennadi Liakhovetski {
32844432407SGuennadi Liakhovetski .name = "DVI",
32944432407SGuennadi Liakhovetski .xres = 1280,
33044432407SGuennadi Liakhovetski .yres = 720,
33144432407SGuennadi Liakhovetski .left_margin = 220,
33244432407SGuennadi Liakhovetski .right_margin = 110,
33344432407SGuennadi Liakhovetski .hsync_len = 40,
33444432407SGuennadi Liakhovetski .upper_margin = 20,
33544432407SGuennadi Liakhovetski .lower_margin = 5,
33644432407SGuennadi Liakhovetski .vsync_len = 5,
33744432407SGuennadi Liakhovetski .sync = 0, /* hsync and vsync are active low */
33844432407SGuennadi Liakhovetski },
33944432407SGuennadi Liakhovetski };
34044432407SGuennadi Liakhovetski
341fa3ba51bSKuninori Morimoto static struct sh_mobile_lcdc_info lcdc_info = {
342fa3ba51bSKuninori Morimoto .ch[0] = {
343fa3ba51bSKuninori Morimoto .interface_type = RGB18,
344fa3ba51bSKuninori Morimoto .chan = LCDC_CHAN_MAINLCD,
345edd153a3SLaurent Pinchart .fourcc = V4L2_PIX_FMT_RGB565,
346afaad83bSLaurent Pinchart .panel_cfg = { /* 7.0 inch */
347fa3ba51bSKuninori Morimoto .width = 152,
348fa3ba51bSKuninori Morimoto .height = 91,
349fa3ba51bSKuninori Morimoto },
350fa3ba51bSKuninori Morimoto }
351fa3ba51bSKuninori Morimoto };
352fa3ba51bSKuninori Morimoto
353fa3ba51bSKuninori Morimoto static struct resource lcdc_resources[] = {
354fa3ba51bSKuninori Morimoto [0] = {
355fa3ba51bSKuninori Morimoto .name = "LCDC",
356fa3ba51bSKuninori Morimoto .start = 0xfe940000,
357a6f15adeSPhil Edworthy .end = 0xfe942fff,
358fa3ba51bSKuninori Morimoto .flags = IORESOURCE_MEM,
359fa3ba51bSKuninori Morimoto },
360fa3ba51bSKuninori Morimoto [1] = {
3619307d115SPaul Mundt .start = evt2irq(0xf40),
362fa3ba51bSKuninori Morimoto .flags = IORESOURCE_IRQ,
363fa3ba51bSKuninori Morimoto },
364fa3ba51bSKuninori Morimoto };
365fa3ba51bSKuninori Morimoto
366fa3ba51bSKuninori Morimoto static struct platform_device lcdc_device = {
367fa3ba51bSKuninori Morimoto .name = "sh_mobile_lcdc_fb",
368fa3ba51bSKuninori Morimoto .num_resources = ARRAY_SIZE(lcdc_resources),
369fa3ba51bSKuninori Morimoto .resource = lcdc_resources,
370fa3ba51bSKuninori Morimoto .dev = {
371fa3ba51bSKuninori Morimoto .platform_data = &lcdc_info,
372fa3ba51bSKuninori Morimoto },
373fa3ba51bSKuninori Morimoto };
374fa3ba51bSKuninori Morimoto
375d9e2b6eeSBartosz Golaszewski static struct gpiod_lookup_table gpio_backlight_lookup = {
376d9e2b6eeSBartosz Golaszewski .dev_id = "gpio-backlight.0",
377d9e2b6eeSBartosz Golaszewski .table = {
378d9e2b6eeSBartosz Golaszewski GPIO_LOOKUP("sh7724_pfc", GPIO_PTR1, NULL, GPIO_ACTIVE_HIGH),
379d9e2b6eeSBartosz Golaszewski { }
380d9e2b6eeSBartosz Golaszewski },
381d9e2b6eeSBartosz Golaszewski };
382d9e2b6eeSBartosz Golaszewski
383d9e2b6eeSBartosz Golaszewski static struct property_entry gpio_backlight_props[] = {
384d9e2b6eeSBartosz Golaszewski PROPERTY_ENTRY_BOOL("default-on"),
385d9e2b6eeSBartosz Golaszewski { }
386d9e2b6eeSBartosz Golaszewski };
387d9e2b6eeSBartosz Golaszewski
388fe79f919SLaurent Pinchart static struct gpio_backlight_platform_data gpio_backlight_data = {
389ed369defSThomas Zimmermann .dev = &lcdc_device.dev,
390fe79f919SLaurent Pinchart };
391fe79f919SLaurent Pinchart
392d9e2b6eeSBartosz Golaszewski static const struct platform_device_info gpio_backlight_device_info = {
393fe79f919SLaurent Pinchart .name = "gpio-backlight",
394d9e2b6eeSBartosz Golaszewski .data = &gpio_backlight_data,
395d9e2b6eeSBartosz Golaszewski .size_data = sizeof(gpio_backlight_data),
396d9e2b6eeSBartosz Golaszewski .properties = gpio_backlight_props,
397fe79f919SLaurent Pinchart };
398fe79f919SLaurent Pinchart
399d9e2b6eeSBartosz Golaszewski static struct platform_device *gpio_backlight_device;
400d9e2b6eeSBartosz Golaszewski
4012153ad32SKuninori Morimoto /* CEU0 */
402c2f9b05fSJacopo Mondi static struct ceu_platform_data ceu0_pdata = {
403c2f9b05fSJacopo Mondi .num_subdevs = 2,
404c2f9b05fSJacopo Mondi .subdevs = {
405c2f9b05fSJacopo Mondi { /* [0] = mt9t112 */
406c2f9b05fSJacopo Mondi .flags = 0,
407c2f9b05fSJacopo Mondi .bus_width = 8,
408c2f9b05fSJacopo Mondi .bus_shift = 0,
409c2f9b05fSJacopo Mondi .i2c_adapter_id = 0,
410c2f9b05fSJacopo Mondi .i2c_address = 0x3c,
411c2f9b05fSJacopo Mondi },
412c2f9b05fSJacopo Mondi { /* [1] = tw9910 */
413c2f9b05fSJacopo Mondi .flags = 0,
414c2f9b05fSJacopo Mondi .bus_width = 8,
415c2f9b05fSJacopo Mondi .bus_shift = 0,
416c2f9b05fSJacopo Mondi .i2c_adapter_id = 0,
417c2f9b05fSJacopo Mondi .i2c_address = 0x45,
418c2f9b05fSJacopo Mondi },
419c2f9b05fSJacopo Mondi },
4202153ad32SKuninori Morimoto };
4212153ad32SKuninori Morimoto
4222153ad32SKuninori Morimoto static struct resource ceu0_resources[] = {
4232153ad32SKuninori Morimoto [0] = {
4242153ad32SKuninori Morimoto .name = "CEU0",
4252153ad32SKuninori Morimoto .start = 0xfe910000,
4262153ad32SKuninori Morimoto .end = 0xfe91009f,
4272153ad32SKuninori Morimoto .flags = IORESOURCE_MEM,
4282153ad32SKuninori Morimoto },
4292153ad32SKuninori Morimoto [1] = {
4309307d115SPaul Mundt .start = evt2irq(0x880),
4312153ad32SKuninori Morimoto .flags = IORESOURCE_IRQ,
4322153ad32SKuninori Morimoto },
4332153ad32SKuninori Morimoto };
4342153ad32SKuninori Morimoto
4352153ad32SKuninori Morimoto static struct platform_device ceu0_device = {
436c2f9b05fSJacopo Mondi .name = "renesas-ceu",
437c2f9b05fSJacopo Mondi .id = 0, /* ceu.0 */
4382153ad32SKuninori Morimoto .num_resources = ARRAY_SIZE(ceu0_resources),
4392153ad32SKuninori Morimoto .resource = ceu0_resources,
4402153ad32SKuninori Morimoto .dev = {
441c2f9b05fSJacopo Mondi .platform_data = &ceu0_pdata,
4422153ad32SKuninori Morimoto },
4432153ad32SKuninori Morimoto };
4442153ad32SKuninori Morimoto
4452153ad32SKuninori Morimoto /* CEU1 */
446c2f9b05fSJacopo Mondi static struct ceu_platform_data ceu1_pdata = {
447c2f9b05fSJacopo Mondi .num_subdevs = 1,
448c2f9b05fSJacopo Mondi .subdevs = {
449c2f9b05fSJacopo Mondi { /* [0] = mt9t112 */
450c2f9b05fSJacopo Mondi .flags = 0,
451c2f9b05fSJacopo Mondi .bus_width = 8,
452c2f9b05fSJacopo Mondi .bus_shift = 0,
453c2f9b05fSJacopo Mondi .i2c_adapter_id = 1,
454c2f9b05fSJacopo Mondi .i2c_address = 0x3c,
455c2f9b05fSJacopo Mondi },
456c2f9b05fSJacopo Mondi },
4572153ad32SKuninori Morimoto };
4582153ad32SKuninori Morimoto
4592153ad32SKuninori Morimoto static struct resource ceu1_resources[] = {
4602153ad32SKuninori Morimoto [0] = {
4612153ad32SKuninori Morimoto .name = "CEU1",
4622153ad32SKuninori Morimoto .start = 0xfe914000,
4632153ad32SKuninori Morimoto .end = 0xfe91409f,
4642153ad32SKuninori Morimoto .flags = IORESOURCE_MEM,
4652153ad32SKuninori Morimoto },
4662153ad32SKuninori Morimoto [1] = {
4679307d115SPaul Mundt .start = evt2irq(0x9e0),
4682153ad32SKuninori Morimoto .flags = IORESOURCE_IRQ,
4692153ad32SKuninori Morimoto },
4702153ad32SKuninori Morimoto };
4712153ad32SKuninori Morimoto
4722153ad32SKuninori Morimoto static struct platform_device ceu1_device = {
473c2f9b05fSJacopo Mondi .name = "renesas-ceu",
474c2f9b05fSJacopo Mondi .id = 1, /* ceu.1 */
4752153ad32SKuninori Morimoto .num_resources = ARRAY_SIZE(ceu1_resources),
4762153ad32SKuninori Morimoto .resource = ceu1_resources,
4772153ad32SKuninori Morimoto .dev = {
478c2f9b05fSJacopo Mondi .platform_data = &ceu1_pdata,
479c2f9b05fSJacopo Mondi },
480c2f9b05fSJacopo Mondi };
481c2f9b05fSJacopo Mondi
482c2f9b05fSJacopo Mondi /* Power up/down GPIOs for camera devices and video decoder */
483c2f9b05fSJacopo Mondi static struct gpiod_lookup_table tw9910_gpios = {
484c2f9b05fSJacopo Mondi .dev_id = "0-0045",
485c2f9b05fSJacopo Mondi .table = {
486c2f9b05fSJacopo Mondi GPIO_LOOKUP("sh7724_pfc", GPIO_PTU2, "pdn", GPIO_ACTIVE_HIGH),
487c2f9b05fSJacopo Mondi },
488c2f9b05fSJacopo Mondi };
489c2f9b05fSJacopo Mondi
490c2f9b05fSJacopo Mondi static struct gpiod_lookup_table mt9t112_0_gpios = {
491c2f9b05fSJacopo Mondi .dev_id = "0-003c",
492c2f9b05fSJacopo Mondi .table = {
493c2f9b05fSJacopo Mondi GPIO_LOOKUP("sh7724_pfc", GPIO_PTA3, "standby",
494c2f9b05fSJacopo Mondi GPIO_ACTIVE_HIGH),
495c2f9b05fSJacopo Mondi },
496c2f9b05fSJacopo Mondi };
497c2f9b05fSJacopo Mondi
498c2f9b05fSJacopo Mondi static struct gpiod_lookup_table mt9t112_1_gpios = {
499c2f9b05fSJacopo Mondi .dev_id = "1-003c",
500c2f9b05fSJacopo Mondi .table = {
501c2f9b05fSJacopo Mondi GPIO_LOOKUP("sh7724_pfc", GPIO_PTA4, "standby",
502c2f9b05fSJacopo Mondi GPIO_ACTIVE_HIGH),
5032153ad32SKuninori Morimoto },
5042153ad32SKuninori Morimoto };
5052153ad32SKuninori Morimoto
506125ecce6SKuninori Morimoto /* I2C device */
507c2f9b05fSJacopo Mondi static struct tw9910_video_info tw9910_info = {
508c2f9b05fSJacopo Mondi .buswidth = 8,
509c2f9b05fSJacopo Mondi .mpout = TW9910_MPO_FIELD,
510c2f9b05fSJacopo Mondi };
511c2f9b05fSJacopo Mondi
512c2f9b05fSJacopo Mondi static struct mt9t112_platform_data mt9t112_0_pdata = {
513c2f9b05fSJacopo Mondi .flags = MT9T112_FLAG_PCLK_RISING_EDGE,
514c2f9b05fSJacopo Mondi .divider = { 0x49, 0x6, 0, 6, 0, 9, 9, 6, 0 }, /* for 24MHz */
515c2f9b05fSJacopo Mondi };
516c2f9b05fSJacopo Mondi
517c2f9b05fSJacopo Mondi static struct mt9t112_platform_data mt9t112_1_pdata = {
518c2f9b05fSJacopo Mondi .flags = MT9T112_FLAG_PCLK_RISING_EDGE,
519c2f9b05fSJacopo Mondi .divider = { 0x49, 0x6, 0, 6, 0, 9, 9, 6, 0 }, /* for 24MHz */
520c2f9b05fSJacopo Mondi };
521c2f9b05fSJacopo Mondi
5221980fdc4SKuninori Morimoto static struct i2c_board_info i2c0_devices[] = {
5231980fdc4SKuninori Morimoto {
5241980fdc4SKuninori Morimoto I2C_BOARD_INFO("da7210", 0x1a),
5251980fdc4SKuninori Morimoto },
526c2f9b05fSJacopo Mondi {
527c2f9b05fSJacopo Mondi I2C_BOARD_INFO("tw9910", 0x45),
528c2f9b05fSJacopo Mondi .platform_data = &tw9910_info,
529c2f9b05fSJacopo Mondi },
530c2f9b05fSJacopo Mondi {
531c2f9b05fSJacopo Mondi /* 1st camera */
532c2f9b05fSJacopo Mondi I2C_BOARD_INFO("mt9t112", 0x3c),
533c2f9b05fSJacopo Mondi .platform_data = &mt9t112_0_pdata,
534c2f9b05fSJacopo Mondi },
5351980fdc4SKuninori Morimoto };
5361980fdc4SKuninori Morimoto
537125ecce6SKuninori Morimoto static struct i2c_board_info i2c1_devices[] = {
538125ecce6SKuninori Morimoto {
539125ecce6SKuninori Morimoto I2C_BOARD_INFO("r2025sd", 0x32),
540125ecce6SKuninori Morimoto },
541ea440783SNISHIMOTO Hiroki {
542ea440783SNISHIMOTO Hiroki I2C_BOARD_INFO("lis3lv02d", 0x1c),
5439307d115SPaul Mundt .irq = evt2irq(0x620),
544c2f9b05fSJacopo Mondi },
545c2f9b05fSJacopo Mondi {
546c2f9b05fSJacopo Mondi /* 2nd camera */
547c2f9b05fSJacopo Mondi I2C_BOARD_INFO("mt9t112", 0x3c),
548c2f9b05fSJacopo Mondi .platform_data = &mt9t112_1_pdata,
549c2f9b05fSJacopo Mondi },
550125ecce6SKuninori Morimoto };
551125ecce6SKuninori Morimoto
552e9103e74SKuninori Morimoto /* KEYSC */
553e9103e74SKuninori Morimoto static struct sh_keysc_info keysc_info = {
554e9103e74SKuninori Morimoto .mode = SH_KEYSC_MODE_1,
555e9103e74SKuninori Morimoto .scan_timing = 3,
556e9103e74SKuninori Morimoto .delay = 50,
557e9103e74SKuninori Morimoto .kycr2_delay = 100,
558e9103e74SKuninori Morimoto .keycodes = { KEY_1, 0, 0, 0, 0,
559e9103e74SKuninori Morimoto KEY_2, 0, 0, 0, 0,
560e9103e74SKuninori Morimoto KEY_3, 0, 0, 0, 0,
561e9103e74SKuninori Morimoto KEY_4, 0, 0, 0, 0,
562e9103e74SKuninori Morimoto KEY_5, 0, 0, 0, 0,
563e9103e74SKuninori Morimoto KEY_6, 0, 0, 0, 0, },
564e9103e74SKuninori Morimoto };
565e9103e74SKuninori Morimoto
566e9103e74SKuninori Morimoto static struct resource keysc_resources[] = {
567e9103e74SKuninori Morimoto [0] = {
568e9103e74SKuninori Morimoto .name = "KEYSC",
569e9103e74SKuninori Morimoto .start = 0x044b0000,
570e9103e74SKuninori Morimoto .end = 0x044b000f,
571e9103e74SKuninori Morimoto .flags = IORESOURCE_MEM,
572e9103e74SKuninori Morimoto },
573e9103e74SKuninori Morimoto [1] = {
5749307d115SPaul Mundt .start = evt2irq(0xbe0),
575e9103e74SKuninori Morimoto .flags = IORESOURCE_IRQ,
576e9103e74SKuninori Morimoto },
577e9103e74SKuninori Morimoto };
578e9103e74SKuninori Morimoto
579e9103e74SKuninori Morimoto static struct platform_device keysc_device = {
580e9103e74SKuninori Morimoto .name = "sh_keysc",
581e9103e74SKuninori Morimoto .id = 0, /* keysc0 clock */
582e9103e74SKuninori Morimoto .num_resources = ARRAY_SIZE(keysc_resources),
583e9103e74SKuninori Morimoto .resource = keysc_resources,
584e9103e74SKuninori Morimoto .dev = {
585e9103e74SKuninori Morimoto .platform_data = &keysc_info,
586e9103e74SKuninori Morimoto },
587e9103e74SKuninori Morimoto };
588e9103e74SKuninori Morimoto
5898810e055SKuninori Morimoto /* TouchScreen */
5909307d115SPaul Mundt #define IRQ0 evt2irq(0x600)
5919307d115SPaul Mundt
ts_get_pendown_state(struct device * dev)59207f9e5cfSDenis Carikli static int ts_get_pendown_state(struct device *dev)
5935d75b3a2SPaul Mundt {
5945d75b3a2SPaul Mundt int val = 0;
5955d75b3a2SPaul Mundt gpio_free(GPIO_FN_INTC_IRQ0);
5965d75b3a2SPaul Mundt gpio_request(GPIO_PTZ0, NULL);
5975d75b3a2SPaul Mundt gpio_direction_input(GPIO_PTZ0);
5985d75b3a2SPaul Mundt
5995d75b3a2SPaul Mundt val = gpio_get_value(GPIO_PTZ0);
6005d75b3a2SPaul Mundt
6015d75b3a2SPaul Mundt gpio_free(GPIO_PTZ0);
6025d75b3a2SPaul Mundt gpio_request(GPIO_FN_INTC_IRQ0, NULL);
6035d75b3a2SPaul Mundt
6045d75b3a2SPaul Mundt return val ? 0 : 1;
6055d75b3a2SPaul Mundt }
6065d75b3a2SPaul Mundt
ts_init(void)6075d75b3a2SPaul Mundt static int ts_init(void)
6085d75b3a2SPaul Mundt {
6095d75b3a2SPaul Mundt gpio_request(GPIO_FN_INTC_IRQ0, NULL);
6105d75b3a2SPaul Mundt return 0;
6115d75b3a2SPaul Mundt }
6125d75b3a2SPaul Mundt
6133ce09334SKuninori Morimoto static struct tsc2007_platform_data tsc2007_info = {
6148810e055SKuninori Morimoto .model = 2007,
6155d75b3a2SPaul Mundt .x_plate_ohms = 180,
6165d75b3a2SPaul Mundt .get_pendown_state = ts_get_pendown_state,
6175d75b3a2SPaul Mundt .init_platform_hw = ts_init,
6188810e055SKuninori Morimoto };
6198810e055SKuninori Morimoto
6208810e055SKuninori Morimoto static struct i2c_board_info ts_i2c_clients = {
6218810e055SKuninori Morimoto I2C_BOARD_INFO("tsc2007", 0x48),
6228810e055SKuninori Morimoto .type = "tsc2007",
6238810e055SKuninori Morimoto .platform_data = &tsc2007_info,
6248810e055SKuninori Morimoto .irq = IRQ0,
6258810e055SKuninori Morimoto };
6268810e055SKuninori Morimoto
627d4c191dfSGuennadi Liakhovetski static struct regulator_consumer_supply cn12_power_consumers[] =
628d4c191dfSGuennadi Liakhovetski {
629d4c191dfSGuennadi Liakhovetski REGULATOR_SUPPLY("vmmc", "sh_mmcif.0"),
630d4c191dfSGuennadi Liakhovetski REGULATOR_SUPPLY("vqmmc", "sh_mmcif.0"),
631d4c191dfSGuennadi Liakhovetski REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.1"),
632d4c191dfSGuennadi Liakhovetski REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.1"),
633d4c191dfSGuennadi Liakhovetski };
634d4c191dfSGuennadi Liakhovetski
635d4c191dfSGuennadi Liakhovetski static struct regulator_init_data cn12_power_init_data = {
636d4c191dfSGuennadi Liakhovetski .constraints = {
637d4c191dfSGuennadi Liakhovetski .valid_ops_mask = REGULATOR_CHANGE_STATUS,
638d4c191dfSGuennadi Liakhovetski },
639d4c191dfSGuennadi Liakhovetski .num_consumer_supplies = ARRAY_SIZE(cn12_power_consumers),
640d4c191dfSGuennadi Liakhovetski .consumer_supplies = cn12_power_consumers,
641d4c191dfSGuennadi Liakhovetski };
642d4c191dfSGuennadi Liakhovetski
643d4c191dfSGuennadi Liakhovetski static struct fixed_voltage_config cn12_power_info = {
644d4c191dfSGuennadi Liakhovetski .supply_name = "CN12 SD/MMC Vdd",
645d4c191dfSGuennadi Liakhovetski .microvolts = 3300000,
646d4c191dfSGuennadi Liakhovetski .init_data = &cn12_power_init_data,
647d4c191dfSGuennadi Liakhovetski };
648d4c191dfSGuennadi Liakhovetski
649d4c191dfSGuennadi Liakhovetski static struct platform_device cn12_power = {
650d4c191dfSGuennadi Liakhovetski .name = "reg-fixed-voltage",
651d4c191dfSGuennadi Liakhovetski .id = 0,
652d4c191dfSGuennadi Liakhovetski .dev = {
653d4c191dfSGuennadi Liakhovetski .platform_data = &cn12_power_info,
654d4c191dfSGuennadi Liakhovetski },
655d4c191dfSGuennadi Liakhovetski };
656d4c191dfSGuennadi Liakhovetski
657efdfeb07SLinus Walleij static struct gpiod_lookup_table cn12_power_gpiod_table = {
658efdfeb07SLinus Walleij .dev_id = "reg-fixed-voltage.0",
659efdfeb07SLinus Walleij .table = {
660efdfeb07SLinus Walleij /* Offset 7 on port B */
661efdfeb07SLinus Walleij GPIO_LOOKUP("sh7724_pfc", GPIO_PTB7,
662efdfeb07SLinus Walleij NULL, GPIO_ACTIVE_HIGH),
663efdfeb07SLinus Walleij { },
664efdfeb07SLinus Walleij },
665efdfeb07SLinus Walleij };
666efdfeb07SLinus Walleij
6675744c881SGuennadi Liakhovetski #if defined(CONFIG_MMC_SDHI) || defined(CONFIG_MMC_SDHI_MODULE)
6681238c684SYusuke Goda /* SDHI0 */
669d4c191dfSGuennadi Liakhovetski static struct regulator_consumer_supply sdhi0_power_consumers[] =
670d4c191dfSGuennadi Liakhovetski {
671d4c191dfSGuennadi Liakhovetski REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.0"),
672d4c191dfSGuennadi Liakhovetski REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.0"),
673d4c191dfSGuennadi Liakhovetski };
674d4c191dfSGuennadi Liakhovetski
675d4c191dfSGuennadi Liakhovetski static struct regulator_init_data sdhi0_power_init_data = {
676d4c191dfSGuennadi Liakhovetski .constraints = {
677d4c191dfSGuennadi Liakhovetski .valid_ops_mask = REGULATOR_CHANGE_STATUS,
678d4c191dfSGuennadi Liakhovetski },
679d4c191dfSGuennadi Liakhovetski .num_consumer_supplies = ARRAY_SIZE(sdhi0_power_consumers),
680d4c191dfSGuennadi Liakhovetski .consumer_supplies = sdhi0_power_consumers,
681d4c191dfSGuennadi Liakhovetski };
682d4c191dfSGuennadi Liakhovetski
683d4c191dfSGuennadi Liakhovetski static struct fixed_voltage_config sdhi0_power_info = {
684d4c191dfSGuennadi Liakhovetski .supply_name = "CN11 SD/MMC Vdd",
685d4c191dfSGuennadi Liakhovetski .microvolts = 3300000,
686d4c191dfSGuennadi Liakhovetski .init_data = &sdhi0_power_init_data,
687d4c191dfSGuennadi Liakhovetski };
688d4c191dfSGuennadi Liakhovetski
689d4c191dfSGuennadi Liakhovetski static struct platform_device sdhi0_power = {
690d4c191dfSGuennadi Liakhovetski .name = "reg-fixed-voltage",
691d4c191dfSGuennadi Liakhovetski .id = 1,
692d4c191dfSGuennadi Liakhovetski .dev = {
693d4c191dfSGuennadi Liakhovetski .platform_data = &sdhi0_power_info,
694d4c191dfSGuennadi Liakhovetski },
695d4c191dfSGuennadi Liakhovetski };
696d4c191dfSGuennadi Liakhovetski
697efdfeb07SLinus Walleij static struct gpiod_lookup_table sdhi0_power_gpiod_table = {
698efdfeb07SLinus Walleij .dev_id = "reg-fixed-voltage.1",
699efdfeb07SLinus Walleij .table = {
700efdfeb07SLinus Walleij /* Offset 6 on port B */
701efdfeb07SLinus Walleij GPIO_LOOKUP("sh7724_pfc", GPIO_PTB6,
702efdfeb07SLinus Walleij NULL, GPIO_ACTIVE_HIGH),
703efdfeb07SLinus Walleij { },
704efdfeb07SLinus Walleij },
705efdfeb07SLinus Walleij };
706efdfeb07SLinus Walleij
707faed9303SLinus Walleij static struct gpiod_lookup_table sdhi0_gpio_table = {
708faed9303SLinus Walleij .dev_id = "sh_mobile_sdhi.0",
709faed9303SLinus Walleij .table = {
710faed9303SLinus Walleij /* Card detect */
711faed9303SLinus Walleij GPIO_LOOKUP("sh7724_pfc", GPIO_PTY7, "cd", GPIO_ACTIVE_LOW),
712faed9303SLinus Walleij { },
713faed9303SLinus Walleij },
714faed9303SLinus Walleij };
715faed9303SLinus Walleij
71684f11d5bSKuninori Morimoto static struct tmio_mmc_data sdhi0_info = {
71784f11d5bSKuninori Morimoto .chan_priv_tx = (void *)SHDMA_SLAVE_SDHI0_TX,
71884f11d5bSKuninori Morimoto .chan_priv_rx = (void *)SHDMA_SLAVE_SDHI0_RX,
71984f11d5bSKuninori Morimoto .capabilities = MMC_CAP_SDIO_IRQ | MMC_CAP_POWER_OFF_CARD |
7204eb80146SGuennadi Liakhovetski MMC_CAP_NEEDS_POLL,
72198779ad8SMagnus Damm };
72298779ad8SMagnus Damm
72396987d96SKuninori Morimoto static struct resource sdhi0_resources[] = {
72496987d96SKuninori Morimoto [0] = {
72596987d96SKuninori Morimoto .name = "SDHI0",
72696987d96SKuninori Morimoto .start = 0x04ce0000,
727d80e9221SGuennadi Liakhovetski .end = 0x04ce00ff,
72896987d96SKuninori Morimoto .flags = IORESOURCE_MEM,
72996987d96SKuninori Morimoto },
73096987d96SKuninori Morimoto [1] = {
7319307d115SPaul Mundt .start = evt2irq(0xe80),
73296987d96SKuninori Morimoto .flags = IORESOURCE_IRQ,
73396987d96SKuninori Morimoto },
73496987d96SKuninori Morimoto };
73596987d96SKuninori Morimoto
73696987d96SKuninori Morimoto static struct platform_device sdhi0_device = {
73796987d96SKuninori Morimoto .name = "sh_mobile_sdhi",
73896987d96SKuninori Morimoto .num_resources = ARRAY_SIZE(sdhi0_resources),
73996987d96SKuninori Morimoto .resource = sdhi0_resources,
74096987d96SKuninori Morimoto .id = 0,
74198779ad8SMagnus Damm .dev = {
74298779ad8SMagnus Damm .platform_data = &sdhi0_info,
74398779ad8SMagnus Damm },
74496987d96SKuninori Morimoto };
74596987d96SKuninori Morimoto
746d4c191dfSGuennadi Liakhovetski #if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE)
747d4c191dfSGuennadi Liakhovetski /* SDHI1 */
74884f11d5bSKuninori Morimoto static struct tmio_mmc_data sdhi1_info = {
74984f11d5bSKuninori Morimoto .chan_priv_tx = (void *)SHDMA_SLAVE_SDHI1_TX,
75084f11d5bSKuninori Morimoto .chan_priv_rx = (void *)SHDMA_SLAVE_SDHI1_RX,
75184f11d5bSKuninori Morimoto .capabilities = MMC_CAP_SDIO_IRQ | MMC_CAP_POWER_OFF_CARD |
7524eb80146SGuennadi Liakhovetski MMC_CAP_NEEDS_POLL,
753faed9303SLinus Walleij };
754faed9303SLinus Walleij
755faed9303SLinus Walleij static struct gpiod_lookup_table sdhi1_gpio_table = {
756faed9303SLinus Walleij .dev_id = "sh_mobile_sdhi.1",
757faed9303SLinus Walleij .table = {
758faed9303SLinus Walleij /* Card detect */
759faed9303SLinus Walleij GPIO_LOOKUP("sh7724_pfc", GPIO_PTW7, "cd", GPIO_ACTIVE_LOW),
760faed9303SLinus Walleij { },
761faed9303SLinus Walleij },
76298779ad8SMagnus Damm };
76398779ad8SMagnus Damm
76496987d96SKuninori Morimoto static struct resource sdhi1_resources[] = {
76596987d96SKuninori Morimoto [0] = {
76696987d96SKuninori Morimoto .name = "SDHI1",
76796987d96SKuninori Morimoto .start = 0x04cf0000,
768d80e9221SGuennadi Liakhovetski .end = 0x04cf00ff,
76996987d96SKuninori Morimoto .flags = IORESOURCE_MEM,
77096987d96SKuninori Morimoto },
77196987d96SKuninori Morimoto [1] = {
7729307d115SPaul Mundt .start = evt2irq(0x4e0),
77396987d96SKuninori Morimoto .flags = IORESOURCE_IRQ,
77496987d96SKuninori Morimoto },
77596987d96SKuninori Morimoto };
77696987d96SKuninori Morimoto
77796987d96SKuninori Morimoto static struct platform_device sdhi1_device = {
77896987d96SKuninori Morimoto .name = "sh_mobile_sdhi",
77996987d96SKuninori Morimoto .num_resources = ARRAY_SIZE(sdhi1_resources),
78096987d96SKuninori Morimoto .resource = sdhi1_resources,
78196987d96SKuninori Morimoto .id = 1,
78298779ad8SMagnus Damm .dev = {
78398779ad8SMagnus Damm .platform_data = &sdhi1_info,
78498779ad8SMagnus Damm },
78596987d96SKuninori Morimoto };
7861238c684SYusuke Goda #endif /* CONFIG_MMC_SH_MMCIF */
78796987d96SKuninori Morimoto
7881ce4da7aSMagnus Damm #else
7891ce4da7aSMagnus Damm
7909503e891SKuninori Morimoto /* MMC SPI */
mmc_spi_setpower(struct device * dev,unsigned int maskval)7911ce4da7aSMagnus Damm static void mmc_spi_setpower(struct device *dev, unsigned int maskval)
7921ce4da7aSMagnus Damm {
7931ce4da7aSMagnus Damm gpio_set_value(GPIO_PTB6, maskval ? 1 : 0);
7941ce4da7aSMagnus Damm }
7951ce4da7aSMagnus Damm
7961ce4da7aSMagnus Damm static struct mmc_spi_platform_data mmc_spi_info = {
7971ce4da7aSMagnus Damm .caps = MMC_CAP_NEEDS_POLL,
798afa2c940SLaurent Pinchart .caps2 = MMC_CAP2_RO_ACTIVE_HIGH,
7991ce4da7aSMagnus Damm .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, /* 3.3V only */
8001ce4da7aSMagnus Damm .setpower = mmc_spi_setpower,
8015716fb9bSLinus Walleij };
8025716fb9bSLinus Walleij
8035716fb9bSLinus Walleij static struct gpiod_lookup_table mmc_spi_gpio_table = {
8045716fb9bSLinus Walleij .dev_id = "mmc_spi.0", /* device "mmc_spi" @ CS0 */
8055716fb9bSLinus Walleij .table = {
8065716fb9bSLinus Walleij /* Card detect */
8075716fb9bSLinus Walleij GPIO_LOOKUP_IDX("sh7724_pfc", GPIO_PTY7, NULL, 0,
8085716fb9bSLinus Walleij GPIO_ACTIVE_LOW),
8095716fb9bSLinus Walleij /* Write protect */
8105716fb9bSLinus Walleij GPIO_LOOKUP_IDX("sh7724_pfc", GPIO_PTY6, NULL, 1,
8115716fb9bSLinus Walleij GPIO_ACTIVE_HIGH),
8125716fb9bSLinus Walleij { },
8135716fb9bSLinus Walleij },
8141ce4da7aSMagnus Damm };
8151ce4da7aSMagnus Damm
8161ce4da7aSMagnus Damm static struct spi_board_info spi_bus[] = {
8171ce4da7aSMagnus Damm {
8181ce4da7aSMagnus Damm .modalias = "mmc_spi",
8191ce4da7aSMagnus Damm .platform_data = &mmc_spi_info,
8201ce4da7aSMagnus Damm .max_speed_hz = 5000000,
8211ce4da7aSMagnus Damm .mode = SPI_MODE_0,
8221ce4da7aSMagnus Damm },
8231ce4da7aSMagnus Damm };
8241ce4da7aSMagnus Damm
8259503e891SKuninori Morimoto /* MSIOF0 */
8261ce4da7aSMagnus Damm static struct sh_msiof_spi_info msiof0_data = {
8271ce4da7aSMagnus Damm .num_chipselect = 1,
8281ce4da7aSMagnus Damm };
8291ce4da7aSMagnus Damm
8301ce4da7aSMagnus Damm static struct resource msiof0_resources[] = {
8311ce4da7aSMagnus Damm [0] = {
8321ce4da7aSMagnus Damm .name = "MSIOF0",
8331ce4da7aSMagnus Damm .start = 0xa4c40000,
8341ce4da7aSMagnus Damm .end = 0xa4c40063,
8351ce4da7aSMagnus Damm .flags = IORESOURCE_MEM,
8361ce4da7aSMagnus Damm },
8371ce4da7aSMagnus Damm [1] = {
8389307d115SPaul Mundt .start = evt2irq(0xc80),
8391ce4da7aSMagnus Damm .flags = IORESOURCE_IRQ,
8401ce4da7aSMagnus Damm },
8411ce4da7aSMagnus Damm };
8421ce4da7aSMagnus Damm
8431ce4da7aSMagnus Damm static struct platform_device msiof0_device = {
8441ce4da7aSMagnus Damm .name = "spi_sh_msiof",
8451ce4da7aSMagnus Damm .id = 0, /* MSIOF0 */
8461ce4da7aSMagnus Damm .dev = {
8471ce4da7aSMagnus Damm .platform_data = &msiof0_data,
8481ce4da7aSMagnus Damm },
8491ce4da7aSMagnus Damm .num_resources = ARRAY_SIZE(msiof0_resources),
8501ce4da7aSMagnus Damm .resource = msiof0_resources,
8511ce4da7aSMagnus Damm };
8521ce4da7aSMagnus Damm
8539fda6693SGeert Uytterhoeven static struct gpiod_lookup_table msiof_gpio_table = {
8549fda6693SGeert Uytterhoeven .dev_id = "spi_sh_msiof.0",
8559fda6693SGeert Uytterhoeven .table = {
8569fda6693SGeert Uytterhoeven GPIO_LOOKUP("sh7724_pfc", GPIO_PTM4, "cs", GPIO_ACTIVE_HIGH),
8579fda6693SGeert Uytterhoeven { },
8589fda6693SGeert Uytterhoeven },
8599fda6693SGeert Uytterhoeven };
8609fda6693SGeert Uytterhoeven
8611ce4da7aSMagnus Damm #endif
8621ce4da7aSMagnus Damm
8631980fdc4SKuninori Morimoto /* FSI */
8641980fdc4SKuninori Morimoto static struct resource fsi_resources[] = {
8651980fdc4SKuninori Morimoto [0] = {
8661980fdc4SKuninori Morimoto .name = "FSI",
8671980fdc4SKuninori Morimoto .start = 0xFE3C0000,
8681980fdc4SKuninori Morimoto .end = 0xFE3C021d,
8691980fdc4SKuninori Morimoto .flags = IORESOURCE_MEM,
8701980fdc4SKuninori Morimoto },
8711980fdc4SKuninori Morimoto [1] = {
8729307d115SPaul Mundt .start = evt2irq(0xf80),
8731980fdc4SKuninori Morimoto .flags = IORESOURCE_IRQ,
8741980fdc4SKuninori Morimoto },
8751980fdc4SKuninori Morimoto };
8761980fdc4SKuninori Morimoto
8771980fdc4SKuninori Morimoto static struct platform_device fsi_device = {
8781980fdc4SKuninori Morimoto .name = "sh_fsi",
8791980fdc4SKuninori Morimoto .id = 0,
8801980fdc4SKuninori Morimoto .num_resources = ARRAY_SIZE(fsi_resources),
8811980fdc4SKuninori Morimoto .resource = fsi_resources,
8821980fdc4SKuninori Morimoto };
8831980fdc4SKuninori Morimoto
884064bfadaSKuninori Morimoto static struct asoc_simple_card_info fsi_da7210_info = {
885064bfadaSKuninori Morimoto .name = "DA7210",
886064bfadaSKuninori Morimoto .card = "FSIB-DA7210",
887064bfadaSKuninori Morimoto .codec = "da7210.0-001a",
888064bfadaSKuninori Morimoto .platform = "sh_fsi.0",
88981a13ac7SMark Brown .daifmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBP_CFP,
890a4a2992cSKuninori Morimoto .cpu_dai = {
891a4a2992cSKuninori Morimoto .name = "fsib-dai",
892a4a2992cSKuninori Morimoto },
893a4a2992cSKuninori Morimoto .codec_dai = {
894a4a2992cSKuninori Morimoto .name = "da7210-hifi",
895a4a2992cSKuninori Morimoto },
896064bfadaSKuninori Morimoto };
897064bfadaSKuninori Morimoto
898064bfadaSKuninori Morimoto static struct platform_device fsi_da7210_device = {
899064bfadaSKuninori Morimoto .name = "asoc-simple-card",
900064bfadaSKuninori Morimoto .dev = {
901064bfadaSKuninori Morimoto .platform_data = &fsi_da7210_info,
902ffb83e8cSKuninori Morimoto .coherent_dma_mask = DMA_BIT_MASK(32),
903ffb83e8cSKuninori Morimoto .dma_mask = &fsi_da7210_device.dev.coherent_dma_mask,
904064bfadaSKuninori Morimoto },
905064bfadaSKuninori Morimoto };
906064bfadaSKuninori Morimoto
907064bfadaSKuninori Morimoto
90826365716SKuninori Morimoto /* IrDA */
90926365716SKuninori Morimoto static struct resource irda_resources[] = {
91026365716SKuninori Morimoto [0] = {
91126365716SKuninori Morimoto .name = "IrDA",
91226365716SKuninori Morimoto .start = 0xA45D0000,
91326365716SKuninori Morimoto .end = 0xA45D0049,
91426365716SKuninori Morimoto .flags = IORESOURCE_MEM,
91526365716SKuninori Morimoto },
91626365716SKuninori Morimoto [1] = {
9179307d115SPaul Mundt .start = evt2irq(0x480),
91826365716SKuninori Morimoto .flags = IORESOURCE_IRQ,
91926365716SKuninori Morimoto },
92026365716SKuninori Morimoto };
92126365716SKuninori Morimoto
92226365716SKuninori Morimoto static struct platform_device irda_device = {
92326365716SKuninori Morimoto .name = "sh_sir",
92426365716SKuninori Morimoto .num_resources = ARRAY_SIZE(irda_resources),
92526365716SKuninori Morimoto .resource = irda_resources,
92626365716SKuninori Morimoto };
92726365716SKuninori Morimoto
928b5dcee22SMauro Carvalho Chehab #include <media/i2c/ak881x.h>
929d647f0b7SMauro Carvalho Chehab #include <media/drv-intf/sh_vou.h>
930aee5ab0bSGuennadi Liakhovetski
9313ce09334SKuninori Morimoto static struct ak881x_pdata ak881x_pdata = {
932aee5ab0bSGuennadi Liakhovetski .flags = AK881X_IF_MODE_SLAVE,
933aee5ab0bSGuennadi Liakhovetski };
934aee5ab0bSGuennadi Liakhovetski
935aee5ab0bSGuennadi Liakhovetski static struct i2c_board_info ak8813 = {
936aee5ab0bSGuennadi Liakhovetski I2C_BOARD_INFO("ak8813", 0x20),
937aee5ab0bSGuennadi Liakhovetski .platform_data = &ak881x_pdata,
938aee5ab0bSGuennadi Liakhovetski };
939aee5ab0bSGuennadi Liakhovetski
9403ce09334SKuninori Morimoto static struct sh_vou_pdata sh_vou_pdata = {
941aee5ab0bSGuennadi Liakhovetski .bus_fmt = SH_VOU_BUS_8BIT,
942aee5ab0bSGuennadi Liakhovetski .flags = SH_VOU_HSYNC_LOW | SH_VOU_VSYNC_LOW,
943aee5ab0bSGuennadi Liakhovetski .board_info = &ak8813,
944aee5ab0bSGuennadi Liakhovetski .i2c_adap = 0,
945aee5ab0bSGuennadi Liakhovetski };
946aee5ab0bSGuennadi Liakhovetski
947aee5ab0bSGuennadi Liakhovetski static struct resource sh_vou_resources[] = {
948aee5ab0bSGuennadi Liakhovetski [0] = {
949aee5ab0bSGuennadi Liakhovetski .start = 0xfe960000,
950aee5ab0bSGuennadi Liakhovetski .end = 0xfe962043,
951aee5ab0bSGuennadi Liakhovetski .flags = IORESOURCE_MEM,
952aee5ab0bSGuennadi Liakhovetski },
953aee5ab0bSGuennadi Liakhovetski [1] = {
9549307d115SPaul Mundt .start = evt2irq(0x8e0),
955aee5ab0bSGuennadi Liakhovetski .flags = IORESOURCE_IRQ,
956aee5ab0bSGuennadi Liakhovetski },
957aee5ab0bSGuennadi Liakhovetski };
958aee5ab0bSGuennadi Liakhovetski
959aee5ab0bSGuennadi Liakhovetski static struct platform_device vou_device = {
960aee5ab0bSGuennadi Liakhovetski .name = "sh-vou",
961aee5ab0bSGuennadi Liakhovetski .id = -1,
962aee5ab0bSGuennadi Liakhovetski .num_resources = ARRAY_SIZE(sh_vou_resources),
963aee5ab0bSGuennadi Liakhovetski .resource = sh_vou_resources,
964aee5ab0bSGuennadi Liakhovetski .dev = {
965aee5ab0bSGuennadi Liakhovetski .platform_data = &sh_vou_pdata,
966aee5ab0bSGuennadi Liakhovetski },
967aee5ab0bSGuennadi Liakhovetski };
968aee5ab0bSGuennadi Liakhovetski
9695744c881SGuennadi Liakhovetski #if defined(CONFIG_MMC_SH_MMCIF) || defined(CONFIG_MMC_SH_MMCIF_MODULE)
9701238c684SYusuke Goda /* SH_MMCIF */
9711238c684SYusuke Goda static struct resource sh_mmcif_resources[] = {
9721238c684SYusuke Goda [0] = {
9731238c684SYusuke Goda .name = "SH_MMCIF",
9741238c684SYusuke Goda .start = 0xA4CA0000,
9751238c684SYusuke Goda .end = 0xA4CA00FF,
9761238c684SYusuke Goda .flags = IORESOURCE_MEM,
9771238c684SYusuke Goda },
9781238c684SYusuke Goda [1] = {
9791238c684SYusuke Goda /* MMC2I */
9809307d115SPaul Mundt .start = evt2irq(0x5a0),
9811238c684SYusuke Goda .flags = IORESOURCE_IRQ,
9821238c684SYusuke Goda },
9831238c684SYusuke Goda [2] = {
9841238c684SYusuke Goda /* MMC3I */
9859307d115SPaul Mundt .start = evt2irq(0x5c0),
9861238c684SYusuke Goda .flags = IORESOURCE_IRQ,
9871238c684SYusuke Goda },
9881238c684SYusuke Goda };
9891238c684SYusuke Goda
9903ce09334SKuninori Morimoto static struct sh_mmcif_plat_data sh_mmcif_plat = {
9911238c684SYusuke Goda .sup_pclk = 0, /* SH7724: Max Pclk/2 */
9921238c684SYusuke Goda .caps = MMC_CAP_4_BIT_DATA |
9931238c684SYusuke Goda MMC_CAP_8_BIT_DATA |
9941238c684SYusuke Goda MMC_CAP_NEEDS_POLL,
9951238c684SYusuke Goda .ocr = MMC_VDD_32_33 | MMC_VDD_33_34,
9961238c684SYusuke Goda };
9971238c684SYusuke Goda
9981238c684SYusuke Goda static struct platform_device sh_mmcif_device = {
9991238c684SYusuke Goda .name = "sh_mmcif",
10001238c684SYusuke Goda .id = 0,
10011238c684SYusuke Goda .dev = {
10021238c684SYusuke Goda .platform_data = &sh_mmcif_plat,
10031238c684SYusuke Goda },
10041238c684SYusuke Goda .num_resources = ARRAY_SIZE(sh_mmcif_resources),
10051238c684SYusuke Goda .resource = sh_mmcif_resources,
10061238c684SYusuke Goda };
10071238c684SYusuke Goda #endif
10081238c684SYusuke Goda
1009c2f9b05fSJacopo Mondi static struct platform_device *ecovec_ceu_devices[] __initdata = {
1010c2f9b05fSJacopo Mondi &ceu0_device,
1011c2f9b05fSJacopo Mondi &ceu1_device,
1012c2f9b05fSJacopo Mondi };
1013c2f9b05fSJacopo Mondi
10144138b740SKuninori Morimoto static struct platform_device *ecovec_devices[] __initdata = {
10154138b740SKuninori Morimoto &heartbeat_device,
10164138b740SKuninori Morimoto &nor_flash_device,
101735a35408SKuninori Morimoto &sh_eth_device,
1018907050a3SKuninori Morimoto &usb0_host_device,
10193714a9a0SKuninori Morimoto &usb1_common_device,
1020fb2e7394SKuninori Morimoto &usbhs_device,
1021fa3ba51bSKuninori Morimoto &lcdc_device,
1022e9103e74SKuninori Morimoto &keysc_device,
1023d4c191dfSGuennadi Liakhovetski &cn12_power,
10245744c881SGuennadi Liakhovetski #if defined(CONFIG_MMC_SDHI) || defined(CONFIG_MMC_SDHI_MODULE)
1025d4c191dfSGuennadi Liakhovetski &sdhi0_power,
102696987d96SKuninori Morimoto &sdhi0_device,
10275744c881SGuennadi Liakhovetski #if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE)
102896987d96SKuninori Morimoto &sdhi1_device,
10291238c684SYusuke Goda #endif
10301ce4da7aSMagnus Damm #else
10311ce4da7aSMagnus Damm &msiof0_device,
10321ce4da7aSMagnus Damm #endif
10331980fdc4SKuninori Morimoto &fsi_device,
1034064bfadaSKuninori Morimoto &fsi_da7210_device,
103526365716SKuninori Morimoto &irda_device,
1036aee5ab0bSGuennadi Liakhovetski &vou_device,
10375744c881SGuennadi Liakhovetski #if defined(CONFIG_MMC_SH_MMCIF) || defined(CONFIG_MMC_SH_MMCIF_MODULE)
10381238c684SYusuke Goda &sh_mmcif_device,
10391238c684SYusuke Goda #endif
10404138b740SKuninori Morimoto };
10414138b740SKuninori Morimoto
10426b3b5575SMagnus Damm #ifdef CONFIG_I2C
10434907d57fSKuninori Morimoto #define EEPROM_ADDR 0x50
mac_read(struct i2c_adapter * a,u8 command)10444907d57fSKuninori Morimoto static u8 mac_read(struct i2c_adapter *a, u8 command)
10454907d57fSKuninori Morimoto {
10464907d57fSKuninori Morimoto struct i2c_msg msg[2];
10474907d57fSKuninori Morimoto u8 buf;
10484907d57fSKuninori Morimoto int ret;
10494907d57fSKuninori Morimoto
10504907d57fSKuninori Morimoto msg[0].addr = EEPROM_ADDR;
10514907d57fSKuninori Morimoto msg[0].flags = 0;
10524907d57fSKuninori Morimoto msg[0].len = 1;
10534907d57fSKuninori Morimoto msg[0].buf = &command;
10544907d57fSKuninori Morimoto
10554907d57fSKuninori Morimoto msg[1].addr = EEPROM_ADDR;
10564907d57fSKuninori Morimoto msg[1].flags = I2C_M_RD;
10574907d57fSKuninori Morimoto msg[1].len = 1;
10584907d57fSKuninori Morimoto msg[1].buf = &buf;
10594907d57fSKuninori Morimoto
10604907d57fSKuninori Morimoto ret = i2c_transfer(a, msg, 2);
10614907d57fSKuninori Morimoto if (ret < 0) {
10624907d57fSKuninori Morimoto printk(KERN_ERR "error %d\n", ret);
10634907d57fSKuninori Morimoto buf = 0xff;
10644907d57fSKuninori Morimoto }
10654907d57fSKuninori Morimoto
10664907d57fSKuninori Morimoto return buf;
10674907d57fSKuninori Morimoto }
10684907d57fSKuninori Morimoto
sh_eth_init(struct sh_eth_plat_data * pd)1069376abbb4SMagnus Damm static void __init sh_eth_init(struct sh_eth_plat_data *pd)
10704907d57fSKuninori Morimoto {
10714907d57fSKuninori Morimoto struct i2c_adapter *a = i2c_get_adapter(1);
10724907d57fSKuninori Morimoto int i;
10734907d57fSKuninori Morimoto
10744907d57fSKuninori Morimoto if (!a) {
10754907d57fSKuninori Morimoto pr_err("can not get I2C 1\n");
10764907d57fSKuninori Morimoto return;
10774907d57fSKuninori Morimoto }
10784907d57fSKuninori Morimoto
107925985edcSLucas De Marchi /* read MAC address from EEPROM */
1080376abbb4SMagnus Damm for (i = 0; i < sizeof(pd->mac_addr); i++) {
1081376abbb4SMagnus Damm pd->mac_addr[i] = mac_read(a, 0x10 + i);
10824907d57fSKuninori Morimoto msleep(10);
10834907d57fSKuninori Morimoto }
1084b230eb32SKuninori Morimoto
1085b230eb32SKuninori Morimoto i2c_put_adapter(a);
10864907d57fSKuninori Morimoto }
10876b3b5575SMagnus Damm #else
sh_eth_init(struct sh_eth_plat_data * pd)10886b3b5575SMagnus Damm static void __init sh_eth_init(struct sh_eth_plat_data *pd)
10896b3b5575SMagnus Damm {
10906b3b5575SMagnus Damm pr_err("unable to read sh_eth MAC address\n");
10916b3b5575SMagnus Damm }
10926b3b5575SMagnus Damm #endif
10934907d57fSKuninori Morimoto
1094fa3ba51bSKuninori Morimoto #define PORT_HIZA 0xA4050158
1095ea15edb2SKuninori Morimoto #define IODRIVEA 0xA405018A
1096eb0cd9e8SMagnus Damm
1097eb0cd9e8SMagnus Damm extern char ecovec24_sdram_enter_start;
1098eb0cd9e8SMagnus Damm extern char ecovec24_sdram_enter_end;
1099eb0cd9e8SMagnus Damm extern char ecovec24_sdram_leave_start;
1100eb0cd9e8SMagnus Damm extern char ecovec24_sdram_leave_end;
1101eb0cd9e8SMagnus Damm
arch_setup(void)11024907d57fSKuninori Morimoto static int __init arch_setup(void)
11034138b740SKuninori Morimoto {
11041980fdc4SKuninori Morimoto struct clk *clk;
11054eb80146SGuennadi Liakhovetski bool cn12_enabled = false;
11061980fdc4SKuninori Morimoto
1107eb0cd9e8SMagnus Damm /* register board specific self-refresh code */
11082839bd61SMagnus Damm sh_mobile_register_self_refresh(SUSP_SH_STANDBY | SUSP_SH_SF |
11092839bd61SMagnus Damm SUSP_SH_RSTANDBY,
1110eb0cd9e8SMagnus Damm &ecovec24_sdram_enter_start,
1111eb0cd9e8SMagnus Damm &ecovec24_sdram_enter_end,
1112eb0cd9e8SMagnus Damm &ecovec24_sdram_leave_start,
1113eb0cd9e8SMagnus Damm &ecovec24_sdram_leave_end);
1114eb0cd9e8SMagnus Damm
1115f78bab30SMagnus Damm /* enable STATUS0, STATUS2 and PDSTATUS */
1116f78bab30SMagnus Damm gpio_request(GPIO_FN_STATUS0, NULL);
1117f78bab30SMagnus Damm gpio_request(GPIO_FN_STATUS2, NULL);
1118f78bab30SMagnus Damm gpio_request(GPIO_FN_PDSTATUS, NULL);
1119f78bab30SMagnus Damm
11204138b740SKuninori Morimoto /* enable SCIFA0 */
11214138b740SKuninori Morimoto gpio_request(GPIO_FN_SCIF0_TXD, NULL);
11224138b740SKuninori Morimoto gpio_request(GPIO_FN_SCIF0_RXD, NULL);
11234138b740SKuninori Morimoto
11244138b740SKuninori Morimoto /* enable debug LED */
11254138b740SKuninori Morimoto gpio_request(GPIO_PTG0, NULL);
11264138b740SKuninori Morimoto gpio_request(GPIO_PTG1, NULL);
11274138b740SKuninori Morimoto gpio_request(GPIO_PTG2, NULL);
11284138b740SKuninori Morimoto gpio_request(GPIO_PTG3, NULL);
1129b7056bc1SKuninori Morimoto gpio_direction_output(GPIO_PTG0, 0);
1130b7056bc1SKuninori Morimoto gpio_direction_output(GPIO_PTG1, 0);
1131b7056bc1SKuninori Morimoto gpio_direction_output(GPIO_PTG2, 0);
1132b7056bc1SKuninori Morimoto gpio_direction_output(GPIO_PTG3, 0);
11339d56dd3bSPaul Mundt __raw_writew((__raw_readw(PORT_HIZA) & ~(0x1 << 1)) , PORT_HIZA);
11344138b740SKuninori Morimoto
113535a35408SKuninori Morimoto /* enable SH-Eth */
113635a35408SKuninori Morimoto gpio_request(GPIO_PTA1, NULL);
113735a35408SKuninori Morimoto gpio_direction_output(GPIO_PTA1, 1);
113835a35408SKuninori Morimoto mdelay(20);
113935a35408SKuninori Morimoto
114035a35408SKuninori Morimoto gpio_request(GPIO_FN_RMII_RXD0, NULL);
114135a35408SKuninori Morimoto gpio_request(GPIO_FN_RMII_RXD1, NULL);
114235a35408SKuninori Morimoto gpio_request(GPIO_FN_RMII_TXD0, NULL);
114335a35408SKuninori Morimoto gpio_request(GPIO_FN_RMII_TXD1, NULL);
114435a35408SKuninori Morimoto gpio_request(GPIO_FN_RMII_REF_CLK, NULL);
114535a35408SKuninori Morimoto gpio_request(GPIO_FN_RMII_TX_EN, NULL);
114635a35408SKuninori Morimoto gpio_request(GPIO_FN_RMII_RX_ER, NULL);
114735a35408SKuninori Morimoto gpio_request(GPIO_FN_RMII_CRS_DV, NULL);
114835a35408SKuninori Morimoto gpio_request(GPIO_FN_MDIO, NULL);
114935a35408SKuninori Morimoto gpio_request(GPIO_FN_MDC, NULL);
115035a35408SKuninori Morimoto gpio_request(GPIO_FN_LNKSTA, NULL);
115135a35408SKuninori Morimoto
1152907050a3SKuninori Morimoto /* enable USB */
11539d56dd3bSPaul Mundt __raw_writew(0x0000, 0xA4D80000);
11549d56dd3bSPaul Mundt __raw_writew(0x0000, 0xA4D90000);
1155907050a3SKuninori Morimoto gpio_request(GPIO_PTB3, NULL);
1156907050a3SKuninori Morimoto gpio_request(GPIO_PTB4, NULL);
1157907050a3SKuninori Morimoto gpio_request(GPIO_PTB5, NULL);
1158907050a3SKuninori Morimoto gpio_direction_input(GPIO_PTB3);
1159907050a3SKuninori Morimoto gpio_direction_output(GPIO_PTB4, 0);
1160907050a3SKuninori Morimoto gpio_direction_output(GPIO_PTB5, 0);
11619d56dd3bSPaul Mundt __raw_writew(0x0600, 0xa40501d4);
11629d56dd3bSPaul Mundt __raw_writew(0x0600, 0xa4050192);
1163907050a3SKuninori Morimoto
11643714a9a0SKuninori Morimoto if (gpio_get_value(GPIO_PTB3)) {
11653714a9a0SKuninori Morimoto printk(KERN_INFO "USB1 function is selected\n");
11663714a9a0SKuninori Morimoto usb1_common_device.name = "r8a66597_udc";
11673714a9a0SKuninori Morimoto } else {
11683714a9a0SKuninori Morimoto printk(KERN_INFO "USB1 host is selected\n");
11693714a9a0SKuninori Morimoto usb1_common_device.name = "r8a66597_hcd";
11703714a9a0SKuninori Morimoto }
11713714a9a0SKuninori Morimoto
1172fa3ba51bSKuninori Morimoto /* enable LCDC */
1173fa3ba51bSKuninori Morimoto gpio_request(GPIO_FN_LCDD23, NULL);
1174fa3ba51bSKuninori Morimoto gpio_request(GPIO_FN_LCDD22, NULL);
1175fa3ba51bSKuninori Morimoto gpio_request(GPIO_FN_LCDD21, NULL);
1176fa3ba51bSKuninori Morimoto gpio_request(GPIO_FN_LCDD20, NULL);
1177fa3ba51bSKuninori Morimoto gpio_request(GPIO_FN_LCDD19, NULL);
1178fa3ba51bSKuninori Morimoto gpio_request(GPIO_FN_LCDD18, NULL);
1179fa3ba51bSKuninori Morimoto gpio_request(GPIO_FN_LCDD17, NULL);
1180fa3ba51bSKuninori Morimoto gpio_request(GPIO_FN_LCDD16, NULL);
1181fa3ba51bSKuninori Morimoto gpio_request(GPIO_FN_LCDD15, NULL);
1182fa3ba51bSKuninori Morimoto gpio_request(GPIO_FN_LCDD14, NULL);
1183fa3ba51bSKuninori Morimoto gpio_request(GPIO_FN_LCDD13, NULL);
1184fa3ba51bSKuninori Morimoto gpio_request(GPIO_FN_LCDD12, NULL);
1185fa3ba51bSKuninori Morimoto gpio_request(GPIO_FN_LCDD11, NULL);
1186fa3ba51bSKuninori Morimoto gpio_request(GPIO_FN_LCDD10, NULL);
1187fa3ba51bSKuninori Morimoto gpio_request(GPIO_FN_LCDD9, NULL);
1188fa3ba51bSKuninori Morimoto gpio_request(GPIO_FN_LCDD8, NULL);
1189fa3ba51bSKuninori Morimoto gpio_request(GPIO_FN_LCDD7, NULL);
1190fa3ba51bSKuninori Morimoto gpio_request(GPIO_FN_LCDD6, NULL);
1191fa3ba51bSKuninori Morimoto gpio_request(GPIO_FN_LCDD5, NULL);
1192fa3ba51bSKuninori Morimoto gpio_request(GPIO_FN_LCDD4, NULL);
1193fa3ba51bSKuninori Morimoto gpio_request(GPIO_FN_LCDD3, NULL);
1194fa3ba51bSKuninori Morimoto gpio_request(GPIO_FN_LCDD2, NULL);
1195fa3ba51bSKuninori Morimoto gpio_request(GPIO_FN_LCDD1, NULL);
1196fa3ba51bSKuninori Morimoto gpio_request(GPIO_FN_LCDD0, NULL);
1197fa3ba51bSKuninori Morimoto gpio_request(GPIO_FN_LCDDISP, NULL);
1198fa3ba51bSKuninori Morimoto gpio_request(GPIO_FN_LCDHSYN, NULL);
1199fa3ba51bSKuninori Morimoto gpio_request(GPIO_FN_LCDDCK, NULL);
1200fa3ba51bSKuninori Morimoto gpio_request(GPIO_FN_LCDVSYN, NULL);
1201fa3ba51bSKuninori Morimoto gpio_request(GPIO_FN_LCDDON, NULL);
1202fa3ba51bSKuninori Morimoto gpio_request(GPIO_FN_LCDLCLK, NULL);
12039d56dd3bSPaul Mundt __raw_writew((__raw_readw(PORT_HIZA) & ~0x0001), PORT_HIZA);
1204fa3ba51bSKuninori Morimoto
1205fa3ba51bSKuninori Morimoto gpio_request(GPIO_PTE6, NULL);
1206fa3ba51bSKuninori Morimoto gpio_request(GPIO_PTU1, NULL);
1207fa3ba51bSKuninori Morimoto gpio_request(GPIO_PTA2, NULL);
1208fa3ba51bSKuninori Morimoto gpio_direction_input(GPIO_PTE6);
1209fa3ba51bSKuninori Morimoto gpio_direction_output(GPIO_PTU1, 0);
1210fa3ba51bSKuninori Morimoto gpio_direction_output(GPIO_PTA2, 0);
1211fa3ba51bSKuninori Morimoto
121282b33221SKuninori Morimoto /* I/O buffer drive ability is high */
12139d56dd3bSPaul Mundt __raw_writew((__raw_readw(IODRIVEA) & ~0x00c0) | 0x0080 , IODRIVEA);
1214ea15edb2SKuninori Morimoto
1215fa3ba51bSKuninori Morimoto if (gpio_get_value(GPIO_PTE6)) {
1216fa3ba51bSKuninori Morimoto /* DVI */
1217fa3ba51bSKuninori Morimoto lcdc_info.clock_source = LCDC_CLK_EXTERNAL;
121844432407SGuennadi Liakhovetski lcdc_info.ch[0].clock_divider = 1;
121993ff2598SLaurent Pinchart lcdc_info.ch[0].lcd_modes = ecovec_dvi_modes;
122093ff2598SLaurent Pinchart lcdc_info.ch[0].num_modes = ARRAY_SIZE(ecovec_dvi_modes);
1221fa3ba51bSKuninori Morimoto
1222fe79f919SLaurent Pinchart /* No backlight */
1223*5157319fSGeert Uytterhoeven gpio_backlight_data.dev = NULL;
1224fe79f919SLaurent Pinchart
1225fa3ba51bSKuninori Morimoto gpio_set_value(GPIO_PTA2, 1);
1226fa3ba51bSKuninori Morimoto gpio_set_value(GPIO_PTU1, 1);
1227fa3ba51bSKuninori Morimoto } else {
1228fa3ba51bSKuninori Morimoto /* Panel */
1229ea15edb2SKuninori Morimoto lcdc_info.clock_source = LCDC_CLK_PERIPHERAL;
123044432407SGuennadi Liakhovetski lcdc_info.ch[0].clock_divider = 2;
123193ff2598SLaurent Pinchart lcdc_info.ch[0].lcd_modes = ecovec_lcd_modes;
123293ff2598SLaurent Pinchart lcdc_info.ch[0].num_modes = ARRAY_SIZE(ecovec_lcd_modes);
1233ea15edb2SKuninori Morimoto
1234ea15edb2SKuninori Morimoto /* FIXME
1235ea15edb2SKuninori Morimoto *
1236ea15edb2SKuninori Morimoto * LCDDON control is needed for Panel,
1237ea15edb2SKuninori Morimoto * but current sh_mobile_lcdc driver doesn't control it.
1238ea15edb2SKuninori Morimoto * It is temporary correspondence
1239ea15edb2SKuninori Morimoto */
1240ea15edb2SKuninori Morimoto gpio_request(GPIO_PTF4, NULL);
1241ea15edb2SKuninori Morimoto gpio_direction_output(GPIO_PTF4, 1);
12428810e055SKuninori Morimoto
12438810e055SKuninori Morimoto /* enable TouchScreen */
12448810e055SKuninori Morimoto i2c_register_board_info(0, &ts_i2c_clients, 1);
1245fcb8918fSThomas Gleixner irq_set_irq_type(IRQ0, IRQ_TYPE_LEVEL_LOW);
1246fa3ba51bSKuninori Morimoto }
1247fa3ba51bSKuninori Morimoto
12482153ad32SKuninori Morimoto /* enable CEU0 */
12492153ad32SKuninori Morimoto gpio_request(GPIO_FN_VIO0_D15, NULL);
12502153ad32SKuninori Morimoto gpio_request(GPIO_FN_VIO0_D14, NULL);
12512153ad32SKuninori Morimoto gpio_request(GPIO_FN_VIO0_D13, NULL);
12522153ad32SKuninori Morimoto gpio_request(GPIO_FN_VIO0_D12, NULL);
12532153ad32SKuninori Morimoto gpio_request(GPIO_FN_VIO0_D11, NULL);
12542153ad32SKuninori Morimoto gpio_request(GPIO_FN_VIO0_D10, NULL);
12552153ad32SKuninori Morimoto gpio_request(GPIO_FN_VIO0_D9, NULL);
12562153ad32SKuninori Morimoto gpio_request(GPIO_FN_VIO0_D8, NULL);
12572153ad32SKuninori Morimoto gpio_request(GPIO_FN_VIO0_D7, NULL);
12582153ad32SKuninori Morimoto gpio_request(GPIO_FN_VIO0_D6, NULL);
12592153ad32SKuninori Morimoto gpio_request(GPIO_FN_VIO0_D5, NULL);
12602153ad32SKuninori Morimoto gpio_request(GPIO_FN_VIO0_D4, NULL);
12612153ad32SKuninori Morimoto gpio_request(GPIO_FN_VIO0_D3, NULL);
12622153ad32SKuninori Morimoto gpio_request(GPIO_FN_VIO0_D2, NULL);
12632153ad32SKuninori Morimoto gpio_request(GPIO_FN_VIO0_D1, NULL);
12642153ad32SKuninori Morimoto gpio_request(GPIO_FN_VIO0_D0, NULL);
12652153ad32SKuninori Morimoto gpio_request(GPIO_FN_VIO0_VD, NULL);
12662153ad32SKuninori Morimoto gpio_request(GPIO_FN_VIO0_CLK, NULL);
12672153ad32SKuninori Morimoto gpio_request(GPIO_FN_VIO0_FLD, NULL);
12682153ad32SKuninori Morimoto gpio_request(GPIO_FN_VIO0_HD, NULL);
12692153ad32SKuninori Morimoto
12702153ad32SKuninori Morimoto /* enable CEU1 */
12712153ad32SKuninori Morimoto gpio_request(GPIO_FN_VIO1_D7, NULL);
12722153ad32SKuninori Morimoto gpio_request(GPIO_FN_VIO1_D6, NULL);
12732153ad32SKuninori Morimoto gpio_request(GPIO_FN_VIO1_D5, NULL);
12742153ad32SKuninori Morimoto gpio_request(GPIO_FN_VIO1_D4, NULL);
12752153ad32SKuninori Morimoto gpio_request(GPIO_FN_VIO1_D3, NULL);
12762153ad32SKuninori Morimoto gpio_request(GPIO_FN_VIO1_D2, NULL);
12772153ad32SKuninori Morimoto gpio_request(GPIO_FN_VIO1_D1, NULL);
12782153ad32SKuninori Morimoto gpio_request(GPIO_FN_VIO1_D0, NULL);
12792153ad32SKuninori Morimoto gpio_request(GPIO_FN_VIO1_FLD, NULL);
12802153ad32SKuninori Morimoto gpio_request(GPIO_FN_VIO1_HD, NULL);
12812153ad32SKuninori Morimoto gpio_request(GPIO_FN_VIO1_VD, NULL);
12822153ad32SKuninori Morimoto gpio_request(GPIO_FN_VIO1_CLK, NULL);
12832153ad32SKuninori Morimoto
1284e9103e74SKuninori Morimoto /* enable KEYSC */
1285e9103e74SKuninori Morimoto gpio_request(GPIO_FN_KEYOUT5_IN5, NULL);
1286e9103e74SKuninori Morimoto gpio_request(GPIO_FN_KEYOUT4_IN6, NULL);
1287e9103e74SKuninori Morimoto gpio_request(GPIO_FN_KEYOUT3, NULL);
1288e9103e74SKuninori Morimoto gpio_request(GPIO_FN_KEYOUT2, NULL);
1289e9103e74SKuninori Morimoto gpio_request(GPIO_FN_KEYOUT1, NULL);
1290e9103e74SKuninori Morimoto gpio_request(GPIO_FN_KEYOUT0, NULL);
1291e9103e74SKuninori Morimoto gpio_request(GPIO_FN_KEYIN0, NULL);
1292e9103e74SKuninori Morimoto
1293064a16dcSKuninori Morimoto /* enable user debug switch */
1294064a16dcSKuninori Morimoto gpio_request(GPIO_PTR0, NULL);
1295064a16dcSKuninori Morimoto gpio_request(GPIO_PTR4, NULL);
1296064a16dcSKuninori Morimoto gpio_request(GPIO_PTR5, NULL);
1297064a16dcSKuninori Morimoto gpio_request(GPIO_PTR6, NULL);
1298064a16dcSKuninori Morimoto gpio_direction_input(GPIO_PTR0);
1299064a16dcSKuninori Morimoto gpio_direction_input(GPIO_PTR4);
1300064a16dcSKuninori Morimoto gpio_direction_input(GPIO_PTR5);
1301064a16dcSKuninori Morimoto gpio_direction_input(GPIO_PTR6);
1302064a16dcSKuninori Morimoto
13034eb80146SGuennadi Liakhovetski /* SD-card slot CN11 */
13045744c881SGuennadi Liakhovetski #if defined(CONFIG_MMC_SDHI) || defined(CONFIG_MMC_SDHI_MODULE)
13051ce4da7aSMagnus Damm /* enable SDHI0 on CN11 (needs DS2.4 set to ON) */
130696987d96SKuninori Morimoto gpio_request(GPIO_FN_SDHI0WP, NULL);
130796987d96SKuninori Morimoto gpio_request(GPIO_FN_SDHI0CMD, NULL);
130896987d96SKuninori Morimoto gpio_request(GPIO_FN_SDHI0CLK, NULL);
130996987d96SKuninori Morimoto gpio_request(GPIO_FN_SDHI0D3, NULL);
131096987d96SKuninori Morimoto gpio_request(GPIO_FN_SDHI0D2, NULL);
131196987d96SKuninori Morimoto gpio_request(GPIO_FN_SDHI0D1, NULL);
131296987d96SKuninori Morimoto gpio_request(GPIO_FN_SDHI0D0, NULL);
13131ce4da7aSMagnus Damm #else
13141ce4da7aSMagnus Damm /* enable MSIOF0 on CN11 (needs DS2.4 set to OFF) */
13151ce4da7aSMagnus Damm gpio_request(GPIO_FN_MSIOF0_TXD, NULL);
13161ce4da7aSMagnus Damm gpio_request(GPIO_FN_MSIOF0_RXD, NULL);
13171ce4da7aSMagnus Damm gpio_request(GPIO_FN_MSIOF0_TSCK, NULL);
13181ce4da7aSMagnus Damm gpio_request(GPIO_PTB6, NULL); /* 3.3V power control */
13191ce4da7aSMagnus Damm gpio_direction_output(GPIO_PTB6, 0); /* disable power by default */
13201ce4da7aSMagnus Damm
13215716fb9bSLinus Walleij gpiod_add_lookup_table(&mmc_spi_gpio_table);
13229fda6693SGeert Uytterhoeven gpiod_add_lookup_table(&msiof_gpio_table);
13231ce4da7aSMagnus Damm spi_register_board_info(spi_bus, ARRAY_SIZE(spi_bus));
13241ce4da7aSMagnus Damm #endif
132596987d96SKuninori Morimoto
13264eb80146SGuennadi Liakhovetski /* MMC/SD-card slot CN12 */
13274eb80146SGuennadi Liakhovetski #if defined(CONFIG_MMC_SH_MMCIF) || defined(CONFIG_MMC_SH_MMCIF_MODULE)
13284eb80146SGuennadi Liakhovetski /* enable MMCIF (needs DS2.6,7 set to OFF,ON) */
13294eb80146SGuennadi Liakhovetski gpio_request(GPIO_FN_MMC_D7, NULL);
13304eb80146SGuennadi Liakhovetski gpio_request(GPIO_FN_MMC_D6, NULL);
13314eb80146SGuennadi Liakhovetski gpio_request(GPIO_FN_MMC_D5, NULL);
13324eb80146SGuennadi Liakhovetski gpio_request(GPIO_FN_MMC_D4, NULL);
13334eb80146SGuennadi Liakhovetski gpio_request(GPIO_FN_MMC_D3, NULL);
13344eb80146SGuennadi Liakhovetski gpio_request(GPIO_FN_MMC_D2, NULL);
13354eb80146SGuennadi Liakhovetski gpio_request(GPIO_FN_MMC_D1, NULL);
13364eb80146SGuennadi Liakhovetski gpio_request(GPIO_FN_MMC_D0, NULL);
13374eb80146SGuennadi Liakhovetski gpio_request(GPIO_FN_MMC_CLK, NULL);
13384eb80146SGuennadi Liakhovetski gpio_request(GPIO_FN_MMC_CMD, NULL);
13394eb80146SGuennadi Liakhovetski
13404eb80146SGuennadi Liakhovetski cn12_enabled = true;
13414eb80146SGuennadi Liakhovetski #elif defined(CONFIG_MMC_SDHI) || defined(CONFIG_MMC_SDHI_MODULE)
13424eb80146SGuennadi Liakhovetski /* enable SDHI1 on CN12 (needs DS2.6,7 set to ON,OFF) */
13434eb80146SGuennadi Liakhovetski gpio_request(GPIO_FN_SDHI1WP, NULL);
13444eb80146SGuennadi Liakhovetski gpio_request(GPIO_FN_SDHI1CMD, NULL);
13454eb80146SGuennadi Liakhovetski gpio_request(GPIO_FN_SDHI1CLK, NULL);
13464eb80146SGuennadi Liakhovetski gpio_request(GPIO_FN_SDHI1D3, NULL);
13474eb80146SGuennadi Liakhovetski gpio_request(GPIO_FN_SDHI1D2, NULL);
13484eb80146SGuennadi Liakhovetski gpio_request(GPIO_FN_SDHI1D1, NULL);
13494eb80146SGuennadi Liakhovetski gpio_request(GPIO_FN_SDHI1D0, NULL);
13504eb80146SGuennadi Liakhovetski
13514eb80146SGuennadi Liakhovetski cn12_enabled = true;
13524eb80146SGuennadi Liakhovetski #endif
13534eb80146SGuennadi Liakhovetski
13544eb80146SGuennadi Liakhovetski if (cn12_enabled)
13554eb80146SGuennadi Liakhovetski /* I/O buffer drive ability is high for CN12 */
13564eb80146SGuennadi Liakhovetski __raw_writew((__raw_readw(IODRIVEA) & ~0x3000) | 0x2000,
13574eb80146SGuennadi Liakhovetski IODRIVEA);
13584eb80146SGuennadi Liakhovetski
13591980fdc4SKuninori Morimoto /* enable FSI */
13601980fdc4SKuninori Morimoto gpio_request(GPIO_FN_FSIMCKB, NULL);
13611980fdc4SKuninori Morimoto gpio_request(GPIO_FN_FSIIBSD, NULL);
13621980fdc4SKuninori Morimoto gpio_request(GPIO_FN_FSIOBSD, NULL);
13631980fdc4SKuninori Morimoto gpio_request(GPIO_FN_FSIIBBCK, NULL);
13641980fdc4SKuninori Morimoto gpio_request(GPIO_FN_FSIIBLRCK, NULL);
13651980fdc4SKuninori Morimoto gpio_request(GPIO_FN_FSIOBBCK, NULL);
13661980fdc4SKuninori Morimoto gpio_request(GPIO_FN_FSIOBLRCK, NULL);
13671980fdc4SKuninori Morimoto gpio_request(GPIO_FN_CLKAUDIOBO, NULL);
13681980fdc4SKuninori Morimoto
136916afc9fbSKuninori Morimoto /* set SPU2 clock to 83.4 MHz */
137016afc9fbSKuninori Morimoto clk = clk_get(NULL, "spu_clk");
137156ea5109SGuennadi Liakhovetski if (!IS_ERR(clk)) {
137216afc9fbSKuninori Morimoto clk_set_rate(clk, clk_round_rate(clk, 83333333));
137316afc9fbSKuninori Morimoto clk_put(clk);
137410305853SKuninori Morimoto }
137516afc9fbSKuninori Morimoto
13761980fdc4SKuninori Morimoto /* change parent of FSI B */
13771980fdc4SKuninori Morimoto clk = clk_get(NULL, "fsib_clk");
137856ea5109SGuennadi Liakhovetski if (!IS_ERR(clk)) {
13794bd5d259SKuninori Morimoto /* 48kHz dummy clock was used to make sure 1/1 divide */
13804bd5d259SKuninori Morimoto clk_set_rate(&sh7724_fsimckb_clk, 48000);
13814bd5d259SKuninori Morimoto clk_set_parent(clk, &sh7724_fsimckb_clk);
13824bd5d259SKuninori Morimoto clk_set_rate(clk, 48000);
13831980fdc4SKuninori Morimoto clk_put(clk);
138410305853SKuninori Morimoto }
13851980fdc4SKuninori Morimoto
13861980fdc4SKuninori Morimoto gpio_request(GPIO_PTU0, NULL);
13871980fdc4SKuninori Morimoto gpio_direction_output(GPIO_PTU0, 0);
13881980fdc4SKuninori Morimoto mdelay(20);
13891980fdc4SKuninori Morimoto
1390ea440783SNISHIMOTO Hiroki /* enable motion sensor */
1391ea440783SNISHIMOTO Hiroki gpio_request(GPIO_FN_INTC_IRQ1, NULL);
1392ea440783SNISHIMOTO Hiroki gpio_direction_input(GPIO_FN_INTC_IRQ1);
1393ea440783SNISHIMOTO Hiroki
13946f26d19fSMagnus Damm /* set VPU clock to 166 MHz */
13956f26d19fSMagnus Damm clk = clk_get(NULL, "vpu_clk");
139656ea5109SGuennadi Liakhovetski if (!IS_ERR(clk)) {
13976f26d19fSMagnus Damm clk_set_rate(clk, clk_round_rate(clk, 166000000));
13986f26d19fSMagnus Damm clk_put(clk);
139910305853SKuninori Morimoto }
14006f26d19fSMagnus Damm
140126365716SKuninori Morimoto /* enable IrDA */
140226365716SKuninori Morimoto gpio_request(GPIO_FN_IRDA_OUT, NULL);
140326365716SKuninori Morimoto gpio_request(GPIO_FN_IRDA_IN, NULL);
140426365716SKuninori Morimoto gpio_request(GPIO_PTU5, NULL);
140526365716SKuninori Morimoto gpio_direction_output(GPIO_PTU5, 0);
140626365716SKuninori Morimoto
1407c2f9b05fSJacopo Mondi /* Register gpio lookup tables for cameras and video decoder */
1408c2f9b05fSJacopo Mondi gpiod_add_lookup_table(&tw9910_gpios);
1409c2f9b05fSJacopo Mondi gpiod_add_lookup_table(&mt9t112_0_gpios);
1410c2f9b05fSJacopo Mondi gpiod_add_lookup_table(&mt9t112_1_gpios);
1411c2f9b05fSJacopo Mondi
1412125ecce6SKuninori Morimoto /* enable I2C device */
14131980fdc4SKuninori Morimoto i2c_register_board_info(0, i2c0_devices,
14141980fdc4SKuninori Morimoto ARRAY_SIZE(i2c0_devices));
14151980fdc4SKuninori Morimoto
1416125ecce6SKuninori Morimoto i2c_register_board_info(1, i2c1_devices,
1417125ecce6SKuninori Morimoto ARRAY_SIZE(i2c1_devices));
1418125ecce6SKuninori Morimoto
141992359a70SGuennadi Liakhovetski #if defined(CONFIG_VIDEO_SH_VOU) || defined(CONFIG_VIDEO_SH_VOU_MODULE)
1420aee5ab0bSGuennadi Liakhovetski /* VOU */
1421aee5ab0bSGuennadi Liakhovetski gpio_request(GPIO_FN_DV_D15, NULL);
1422aee5ab0bSGuennadi Liakhovetski gpio_request(GPIO_FN_DV_D14, NULL);
1423aee5ab0bSGuennadi Liakhovetski gpio_request(GPIO_FN_DV_D13, NULL);
1424aee5ab0bSGuennadi Liakhovetski gpio_request(GPIO_FN_DV_D12, NULL);
1425aee5ab0bSGuennadi Liakhovetski gpio_request(GPIO_FN_DV_D11, NULL);
1426aee5ab0bSGuennadi Liakhovetski gpio_request(GPIO_FN_DV_D10, NULL);
1427aee5ab0bSGuennadi Liakhovetski gpio_request(GPIO_FN_DV_D9, NULL);
1428aee5ab0bSGuennadi Liakhovetski gpio_request(GPIO_FN_DV_D8, NULL);
1429aee5ab0bSGuennadi Liakhovetski gpio_request(GPIO_FN_DV_CLKI, NULL);
1430aee5ab0bSGuennadi Liakhovetski gpio_request(GPIO_FN_DV_CLK, NULL);
1431aee5ab0bSGuennadi Liakhovetski gpio_request(GPIO_FN_DV_VSYNC, NULL);
1432aee5ab0bSGuennadi Liakhovetski gpio_request(GPIO_FN_DV_HSYNC, NULL);
1433aee5ab0bSGuennadi Liakhovetski
1434aee5ab0bSGuennadi Liakhovetski /* AK8813 power / reset sequence */
1435aee5ab0bSGuennadi Liakhovetski gpio_request(GPIO_PTG4, NULL);
1436aee5ab0bSGuennadi Liakhovetski gpio_request(GPIO_PTU3, NULL);
1437aee5ab0bSGuennadi Liakhovetski /* Reset */
1438aee5ab0bSGuennadi Liakhovetski gpio_direction_output(GPIO_PTG4, 0);
1439aee5ab0bSGuennadi Liakhovetski /* Power down */
1440aee5ab0bSGuennadi Liakhovetski gpio_direction_output(GPIO_PTU3, 1);
1441aee5ab0bSGuennadi Liakhovetski
1442aee5ab0bSGuennadi Liakhovetski udelay(10);
1443aee5ab0bSGuennadi Liakhovetski
1444aee5ab0bSGuennadi Liakhovetski /* Power up, reset */
1445aee5ab0bSGuennadi Liakhovetski gpio_set_value(GPIO_PTU3, 0);
1446aee5ab0bSGuennadi Liakhovetski
1447aee5ab0bSGuennadi Liakhovetski udelay(10);
1448aee5ab0bSGuennadi Liakhovetski
1449aee5ab0bSGuennadi Liakhovetski /* Remove reset */
1450aee5ab0bSGuennadi Liakhovetski gpio_set_value(GPIO_PTG4, 1);
145192359a70SGuennadi Liakhovetski #endif
1452aee5ab0bSGuennadi Liakhovetski
1453c2f9b05fSJacopo Mondi /* Initialize CEU platform devices separately to map memory first */
1454c2f9b05fSJacopo Mondi device_initialize(&ecovec_ceu_devices[0]->dev);
1455c2f9b05fSJacopo Mondi dma_declare_coherent_memory(&ecovec_ceu_devices[0]->dev,
1456c2f9b05fSJacopo Mondi ceu0_dma_membase, ceu0_dma_membase,
1457fb60211fSPetr Tesarik CEU_BUFFER_MEMORY_SIZE);
1458c2f9b05fSJacopo Mondi platform_device_add(ecovec_ceu_devices[0]);
1459c2f9b05fSJacopo Mondi
1460c2f9b05fSJacopo Mondi device_initialize(&ecovec_ceu_devices[1]->dev);
1461c2f9b05fSJacopo Mondi dma_declare_coherent_memory(&ecovec_ceu_devices[1]->dev,
1462c2f9b05fSJacopo Mondi ceu1_dma_membase, ceu1_dma_membase,
1463fb60211fSPetr Tesarik CEU_BUFFER_MEMORY_SIZE);
1464c2f9b05fSJacopo Mondi platform_device_add(ecovec_ceu_devices[1]);
1465c2f9b05fSJacopo Mondi
1466efdfeb07SLinus Walleij gpiod_add_lookup_table(&cn12_power_gpiod_table);
1467efdfeb07SLinus Walleij #if defined(CONFIG_MMC_SDHI) || defined(CONFIG_MMC_SDHI_MODULE)
1468efdfeb07SLinus Walleij gpiod_add_lookup_table(&sdhi0_power_gpiod_table);
1469faed9303SLinus Walleij gpiod_add_lookup_table(&sdhi0_gpio_table);
1470faed9303SLinus Walleij #if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE)
1471faed9303SLinus Walleij gpiod_add_lookup_table(&sdhi1_gpio_table);
1472efdfeb07SLinus Walleij #endif
1473c4916c24SLinus Walleij #endif
1474efdfeb07SLinus Walleij
1475d9e2b6eeSBartosz Golaszewski gpiod_add_lookup_table(&gpio_backlight_lookup);
1476d9e2b6eeSBartosz Golaszewski gpio_backlight_device = platform_device_register_full(
1477d9e2b6eeSBartosz Golaszewski &gpio_backlight_device_info);
1478d9e2b6eeSBartosz Golaszewski if (IS_ERR(gpio_backlight_device))
1479d9e2b6eeSBartosz Golaszewski return PTR_ERR(gpio_backlight_device);
1480d9e2b6eeSBartosz Golaszewski
14814138b740SKuninori Morimoto return platform_add_devices(ecovec_devices,
14824138b740SKuninori Morimoto ARRAY_SIZE(ecovec_devices));
14834138b740SKuninori Morimoto }
14844907d57fSKuninori Morimoto arch_initcall(arch_setup);
14854907d57fSKuninori Morimoto
devices_setup(void)14864907d57fSKuninori Morimoto static int __init devices_setup(void)
14874907d57fSKuninori Morimoto {
1488376abbb4SMagnus Damm sh_eth_init(&sh_eth_plat);
14894907d57fSKuninori Morimoto return 0;
14904907d57fSKuninori Morimoto }
14914907d57fSKuninori Morimoto device_initcall(devices_setup);
14924907d57fSKuninori Morimoto
1493c2f9b05fSJacopo Mondi /* Reserve a portion of memory for CEU 0 and CEU 1 buffers */
ecovec_mv_mem_reserve(void)1494c2f9b05fSJacopo Mondi static void __init ecovec_mv_mem_reserve(void)
1495c2f9b05fSJacopo Mondi {
1496c2f9b05fSJacopo Mondi phys_addr_t phys;
1497c2f9b05fSJacopo Mondi phys_addr_t size = CEU_BUFFER_MEMORY_SIZE;
1498c2f9b05fSJacopo Mondi
1499f240ec09SMike Rapoport phys = memblock_phys_alloc(size, PAGE_SIZE);
1500ecc3e771SMike Rapoport if (!phys)
1501ecc3e771SMike Rapoport panic("Failed to allocate CEU0 memory\n");
1502ecc3e771SMike Rapoport
15033ecc6834SMike Rapoport memblock_phys_free(phys, size);
1504c2f9b05fSJacopo Mondi memblock_remove(phys, size);
1505c2f9b05fSJacopo Mondi ceu0_dma_membase = phys;
1506c2f9b05fSJacopo Mondi
1507f240ec09SMike Rapoport phys = memblock_phys_alloc(size, PAGE_SIZE);
1508ecc3e771SMike Rapoport if (!phys)
1509ecc3e771SMike Rapoport panic("Failed to allocate CEU1 memory\n");
1510ecc3e771SMike Rapoport
15113ecc6834SMike Rapoport memblock_phys_free(phys, size);
1512c2f9b05fSJacopo Mondi memblock_remove(phys, size);
1513c2f9b05fSJacopo Mondi ceu1_dma_membase = phys;
1514c2f9b05fSJacopo Mondi }
1515c2f9b05fSJacopo Mondi
15164138b740SKuninori Morimoto static struct sh_machine_vector mv_ecovec __initmv = {
15174138b740SKuninori Morimoto .mv_name = "R0P7724 (EcoVec)",
1518c2f9b05fSJacopo Mondi .mv_mem_reserve = ecovec_mv_mem_reserve,
15194138b740SKuninori Morimoto };
1520