147d11326SKuninori Morimoto // SPDX-License-Identifier: GPL-2.0
29d4436a6SYoshinori Sato /*
39d4436a6SYoshinori Sato * SH7619 Setup
49d4436a6SYoshinori Sato *
59d4436a6SYoshinori Sato * Copyright (C) 2006 Yoshinori Sato
65dece2bbSPaul Mundt * Copyright (C) 2009 Paul Mundt
79d4436a6SYoshinori Sato */
89d4436a6SYoshinori Sato #include <linux/platform_device.h>
99d4436a6SYoshinori Sato #include <linux/init.h>
109d4436a6SYoshinori Sato #include <linux/serial.h>
1196de1a8fSPaul Mundt #include <linux/serial_sci.h>
1206a64f91SSergei Shtylyov #include <linux/sh_eth.h>
1346a12f74SPaul Mundt #include <linux/sh_timer.h>
14698aa99dSMagnus Damm #include <linux/io.h>
15507fd01dSBartosz Golaszewski #include <asm/platform_early.h>
169d4436a6SYoshinori Sato
170dc3fc04SMagnus Damm enum {
180dc3fc04SMagnus Damm UNUSED = 0,
190dc3fc04SMagnus Damm
200dc3fc04SMagnus Damm /* interrupt sources */
210dc3fc04SMagnus Damm IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7,
220dc3fc04SMagnus Damm WDT, EDMAC, CMT0, CMT1,
235dece2bbSPaul Mundt SCIF0, SCIF1, SCIF2,
240dc3fc04SMagnus Damm HIF_HIFI, HIF_HIFBI,
250dc3fc04SMagnus Damm DMAC0, DMAC1, DMAC2, DMAC3,
260dc3fc04SMagnus Damm SIOF,
270dc3fc04SMagnus Damm };
280dc3fc04SMagnus Damm
290dc3fc04SMagnus Damm static struct intc_vect vectors[] __initdata = {
300dc3fc04SMagnus Damm INTC_IRQ(IRQ0, 64), INTC_IRQ(IRQ1, 65),
310dc3fc04SMagnus Damm INTC_IRQ(IRQ2, 66), INTC_IRQ(IRQ3, 67),
320dc3fc04SMagnus Damm INTC_IRQ(IRQ4, 80), INTC_IRQ(IRQ5, 81),
330dc3fc04SMagnus Damm INTC_IRQ(IRQ6, 82), INTC_IRQ(IRQ7, 83),
340dc3fc04SMagnus Damm INTC_IRQ(WDT, 84), INTC_IRQ(EDMAC, 85),
350dc3fc04SMagnus Damm INTC_IRQ(CMT0, 86), INTC_IRQ(CMT1, 87),
365dece2bbSPaul Mundt INTC_IRQ(SCIF0, 88), INTC_IRQ(SCIF0, 89),
375dece2bbSPaul Mundt INTC_IRQ(SCIF0, 90), INTC_IRQ(SCIF0, 91),
385dece2bbSPaul Mundt INTC_IRQ(SCIF1, 92), INTC_IRQ(SCIF1, 93),
395dece2bbSPaul Mundt INTC_IRQ(SCIF1, 94), INTC_IRQ(SCIF1, 95),
405dece2bbSPaul Mundt INTC_IRQ(SCIF2, 96), INTC_IRQ(SCIF2, 97),
415dece2bbSPaul Mundt INTC_IRQ(SCIF2, 98), INTC_IRQ(SCIF2, 99),
420dc3fc04SMagnus Damm INTC_IRQ(HIF_HIFI, 100), INTC_IRQ(HIF_HIFBI, 101),
430dc3fc04SMagnus Damm INTC_IRQ(DMAC0, 104), INTC_IRQ(DMAC1, 105),
440dc3fc04SMagnus Damm INTC_IRQ(DMAC2, 106), INTC_IRQ(DMAC3, 107),
450dc3fc04SMagnus Damm INTC_IRQ(SIOF, 108),
460dc3fc04SMagnus Damm };
470dc3fc04SMagnus Damm
480dc3fc04SMagnus Damm static struct intc_prio_reg prio_registers[] __initdata = {
490dc3fc04SMagnus Damm { 0xf8140006, 0, 16, 4, /* IPRA */ { IRQ0, IRQ1, IRQ2, IRQ3 } },
500dc3fc04SMagnus Damm { 0xf8140008, 0, 16, 4, /* IPRB */ { IRQ4, IRQ5, IRQ6, IRQ7 } },
510dc3fc04SMagnus Damm { 0xf8080000, 0, 16, 4, /* IPRC */ { WDT, EDMAC, CMT0, CMT1 } },
520dc3fc04SMagnus Damm { 0xf8080002, 0, 16, 4, /* IPRD */ { SCIF0, SCIF1, SCIF2 } },
530dc3fc04SMagnus Damm { 0xf8080004, 0, 16, 4, /* IPRE */ { HIF_HIFI, HIF_HIFBI } },
540dc3fc04SMagnus Damm { 0xf8080006, 0, 16, 4, /* IPRF */ { DMAC0, DMAC1, DMAC2, DMAC3 } },
550dc3fc04SMagnus Damm { 0xf8080008, 0, 16, 4, /* IPRG */ { SIOF } },
560dc3fc04SMagnus Damm };
570dc3fc04SMagnus Damm
585dece2bbSPaul Mundt static DECLARE_INTC_DESC(intc_desc, "sh7619", vectors, NULL,
597f3edee8SMagnus Damm NULL, prio_registers, NULL);
600dc3fc04SMagnus Damm
61632fd800SMagnus Damm static struct plat_sci_port scif0_platform_data = {
62c3fa400bSLaurent Pinchart .scscr = SCSCR_REIE,
639d4436a6SYoshinori Sato .type = PORT_SCIF,
64d850acf9SLaurent Pinchart };
65d850acf9SLaurent Pinchart
66d850acf9SLaurent Pinchart static struct resource scif0_resources[] = {
67d850acf9SLaurent Pinchart DEFINE_RES_MEM(0xf8400000, 0x100),
68d850acf9SLaurent Pinchart DEFINE_RES_IRQ(88),
69632fd800SMagnus Damm };
70632fd800SMagnus Damm
71632fd800SMagnus Damm static struct platform_device scif0_device = {
72632fd800SMagnus Damm .name = "sh-sci",
73632fd800SMagnus Damm .id = 0,
74d850acf9SLaurent Pinchart .resource = scif0_resources,
75d850acf9SLaurent Pinchart .num_resources = ARRAY_SIZE(scif0_resources),
76632fd800SMagnus Damm .dev = {
77632fd800SMagnus Damm .platform_data = &scif0_platform_data,
78632fd800SMagnus Damm },
79632fd800SMagnus Damm };
80632fd800SMagnus Damm
81632fd800SMagnus Damm static struct plat_sci_port scif1_platform_data = {
82c3fa400bSLaurent Pinchart .scscr = SCSCR_REIE,
839d4436a6SYoshinori Sato .type = PORT_SCIF,
84d850acf9SLaurent Pinchart };
85d850acf9SLaurent Pinchart
86d850acf9SLaurent Pinchart static struct resource scif1_resources[] = {
87d850acf9SLaurent Pinchart DEFINE_RES_MEM(0xf8410000, 0x100),
88d850acf9SLaurent Pinchart DEFINE_RES_IRQ(92),
89632fd800SMagnus Damm };
90632fd800SMagnus Damm
91632fd800SMagnus Damm static struct platform_device scif1_device = {
92632fd800SMagnus Damm .name = "sh-sci",
93632fd800SMagnus Damm .id = 1,
94d850acf9SLaurent Pinchart .resource = scif1_resources,
95d850acf9SLaurent Pinchart .num_resources = ARRAY_SIZE(scif1_resources),
96632fd800SMagnus Damm .dev = {
97632fd800SMagnus Damm .platform_data = &scif1_platform_data,
98632fd800SMagnus Damm },
99632fd800SMagnus Damm };
100632fd800SMagnus Damm
101632fd800SMagnus Damm static struct plat_sci_port scif2_platform_data = {
102c3fa400bSLaurent Pinchart .scscr = SCSCR_REIE,
1039d4436a6SYoshinori Sato .type = PORT_SCIF,
104d850acf9SLaurent Pinchart };
105d850acf9SLaurent Pinchart
106d850acf9SLaurent Pinchart static struct resource scif2_resources[] = {
107d850acf9SLaurent Pinchart DEFINE_RES_MEM(0xf8420000, 0x100),
108d850acf9SLaurent Pinchart DEFINE_RES_IRQ(96),
1099d4436a6SYoshinori Sato };
1109d4436a6SYoshinori Sato
111632fd800SMagnus Damm static struct platform_device scif2_device = {
1129d4436a6SYoshinori Sato .name = "sh-sci",
113632fd800SMagnus Damm .id = 2,
114d850acf9SLaurent Pinchart .resource = scif2_resources,
115d850acf9SLaurent Pinchart .num_resources = ARRAY_SIZE(scif2_resources),
1169d4436a6SYoshinori Sato .dev = {
117632fd800SMagnus Damm .platform_data = &scif2_platform_data,
1189d4436a6SYoshinori Sato },
1199d4436a6SYoshinori Sato };
1209d4436a6SYoshinori Sato
12106a64f91SSergei Shtylyov static struct sh_eth_plat_data eth_platform_data = {
12206a64f91SSergei Shtylyov .phy = 1,
1230bf2bbd2SSergei Shtylyov .phy_interface = PHY_INTERFACE_MODE_MII,
12406a64f91SSergei Shtylyov };
12506a64f91SSergei Shtylyov
126d88a3ea6SYoshinori Sato static struct resource eth_resources[] = {
127d88a3ea6SYoshinori Sato [0] = {
128d88a3ea6SYoshinori Sato .start = 0xfb000000,
12906a64f91SSergei Shtylyov .end = 0xfb0001c7,
130d88a3ea6SYoshinori Sato .flags = IORESOURCE_MEM,
131d88a3ea6SYoshinori Sato },
132d88a3ea6SYoshinori Sato [1] = {
133d88a3ea6SYoshinori Sato .start = 85,
134d88a3ea6SYoshinori Sato .end = 85,
135d88a3ea6SYoshinori Sato .flags = IORESOURCE_IRQ,
136d88a3ea6SYoshinori Sato },
137d88a3ea6SYoshinori Sato };
138d88a3ea6SYoshinori Sato
139d88a3ea6SYoshinori Sato static struct platform_device eth_device = {
140c18a79abSSergei Shtylyov .name = "sh7619-ether",
141d88a3ea6SYoshinori Sato .id = -1,
142d88a3ea6SYoshinori Sato .dev = {
14306a64f91SSergei Shtylyov .platform_data = ð_platform_data,
144d88a3ea6SYoshinori Sato },
145d88a3ea6SYoshinori Sato .num_resources = ARRAY_SIZE(eth_resources),
146d88a3ea6SYoshinori Sato .resource = eth_resources,
147d88a3ea6SYoshinori Sato };
148d88a3ea6SYoshinori Sato
1499b17e48cSLaurent Pinchart static struct sh_timer_config cmt_platform_data = {
1509b17e48cSLaurent Pinchart .channels_mask = 3,
151698aa99dSMagnus Damm };
152698aa99dSMagnus Damm
1539b17e48cSLaurent Pinchart static struct resource cmt_resources[] = {
1549b17e48cSLaurent Pinchart DEFINE_RES_MEM(0xf84a0070, 0x10),
1559b17e48cSLaurent Pinchart DEFINE_RES_IRQ(86),
1569b17e48cSLaurent Pinchart DEFINE_RES_IRQ(87),
157698aa99dSMagnus Damm };
158698aa99dSMagnus Damm
1599b17e48cSLaurent Pinchart static struct platform_device cmt_device = {
1609b17e48cSLaurent Pinchart .name = "sh-cmt-16",
161698aa99dSMagnus Damm .id = 0,
162698aa99dSMagnus Damm .dev = {
1639b17e48cSLaurent Pinchart .platform_data = &cmt_platform_data,
164698aa99dSMagnus Damm },
1659b17e48cSLaurent Pinchart .resource = cmt_resources,
1669b17e48cSLaurent Pinchart .num_resources = ARRAY_SIZE(cmt_resources),
167698aa99dSMagnus Damm };
168698aa99dSMagnus Damm
1699d4436a6SYoshinori Sato static struct platform_device *sh7619_devices[] __initdata = {
170632fd800SMagnus Damm &scif0_device,
171632fd800SMagnus Damm &scif1_device,
172632fd800SMagnus Damm &scif2_device,
173d88a3ea6SYoshinori Sato ð_device,
1749b17e48cSLaurent Pinchart &cmt_device,
1759d4436a6SYoshinori Sato };
1769d4436a6SYoshinori Sato
sh7619_devices_setup(void)1779d4436a6SYoshinori Sato static int __init sh7619_devices_setup(void)
1789d4436a6SYoshinori Sato {
1799d4436a6SYoshinori Sato return platform_add_devices(sh7619_devices,
1809d4436a6SYoshinori Sato ARRAY_SIZE(sh7619_devices));
1819d4436a6SYoshinori Sato }
182ba9a6337SMagnus Damm arch_initcall(sh7619_devices_setup);
183780a1568SYoshinori Sato
plat_irq_setup(void)18490015c89SMagnus Damm void __init plat_irq_setup(void)
185780a1568SYoshinori Sato {
1860dc3fc04SMagnus Damm register_intc_controller(&intc_desc);
187780a1568SYoshinori Sato }
188698aa99dSMagnus Damm
189698aa99dSMagnus Damm static struct platform_device *sh7619_early_devices[] __initdata = {
190632fd800SMagnus Damm &scif0_device,
191632fd800SMagnus Damm &scif1_device,
192632fd800SMagnus Damm &scif2_device,
1939b17e48cSLaurent Pinchart &cmt_device,
194698aa99dSMagnus Damm };
195698aa99dSMagnus Damm
196698aa99dSMagnus Damm #define STBCR3 0xf80a0000
197698aa99dSMagnus Damm
plat_early_device_setup(void)198698aa99dSMagnus Damm void __init plat_early_device_setup(void)
199698aa99dSMagnus Damm {
200698aa99dSMagnus Damm /* enable CMT clock */
201698aa99dSMagnus Damm __raw_writeb(__raw_readb(STBCR3) & ~0x10, STBCR3);
202698aa99dSMagnus Damm
203*201e9109SBartosz Golaszewski sh_early_platform_add_devices(sh7619_early_devices,
204698aa99dSMagnus Damm ARRAY_SIZE(sh7619_early_devices));
205698aa99dSMagnus Damm }
206