15ab5d57cSKuninori Morimoto // SPDX-License-Identifier: GPL-2.0
2e5723e0eSPaul Mundt /*
3ac919986SMagnus Damm * SH3 Setup code for SH7710, SH7712
4e5723e0eSPaul Mundt *
556d604deSPaul Mundt * Copyright (C) 2006 - 2009 Paul Mundt
69465a54fSNobuhiro Iwamatsu * Copyright (C) 2007 Nobuhiro Iwamatsu
7e5723e0eSPaul Mundt */
8e5723e0eSPaul Mundt #include <linux/platform_device.h>
9e5723e0eSPaul Mundt #include <linux/init.h>
1028b146c8SMagnus Damm #include <linux/irq.h>
11e5723e0eSPaul Mundt #include <linux/serial.h>
1296de1a8fSPaul Mundt #include <linux/serial_sci.h>
13e5ad0089SMagnus Damm #include <linux/sh_timer.h>
145d0af769SPaul Mundt #include <linux/sh_intc.h>
15ad89f87aSPaul Mundt #include <asm/rtc.h>
16507fd01dSBartosz Golaszewski #include <asm/platform_early.h>
17e5723e0eSPaul Mundt
1828b146c8SMagnus Damm enum {
1928b146c8SMagnus Damm UNUSED = 0,
2028b146c8SMagnus Damm
2128b146c8SMagnus Damm /* interrupt sources */
2228b146c8SMagnus Damm IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5,
2356d604deSPaul Mundt DMAC1, SCIF0, SCIF1, DMAC2, IPSEC,
2428b146c8SMagnus Damm EDMAC0, EDMAC1, EDMAC2,
2556d604deSPaul Mundt SIOF0, SIOF1,
2628b146c8SMagnus Damm
2756d604deSPaul Mundt TMU0, TMU1, TMU2,
2856d604deSPaul Mundt RTC, WDT, REF,
2928b146c8SMagnus Damm };
3028b146c8SMagnus Damm
315c37e025SMagnus Damm static struct intc_vect vectors[] __initdata = {
32a276e588SMagnus Damm /* IRQ0->5 are handled in setup-sh3.c */
3356d604deSPaul Mundt INTC_VECT(DMAC1, 0x800), INTC_VECT(DMAC1, 0x820),
3456d604deSPaul Mundt INTC_VECT(DMAC1, 0x840), INTC_VECT(DMAC1, 0x860),
3556d604deSPaul Mundt INTC_VECT(SCIF0, 0x880), INTC_VECT(SCIF0, 0x8a0),
3656d604deSPaul Mundt INTC_VECT(SCIF0, 0x8c0), INTC_VECT(SCIF0, 0x8e0),
3756d604deSPaul Mundt INTC_VECT(SCIF1, 0x900), INTC_VECT(SCIF1, 0x920),
3856d604deSPaul Mundt INTC_VECT(SCIF1, 0x940), INTC_VECT(SCIF1, 0x960),
3956d604deSPaul Mundt INTC_VECT(DMAC2, 0xb80), INTC_VECT(DMAC2, 0xba0),
40ac919986SMagnus Damm #ifdef CONFIG_CPU_SUBTYPE_SH7710
4128b146c8SMagnus Damm INTC_VECT(IPSEC, 0xbe0),
42ac919986SMagnus Damm #endif
4328b146c8SMagnus Damm INTC_VECT(EDMAC0, 0xc00), INTC_VECT(EDMAC1, 0xc20),
4428b146c8SMagnus Damm INTC_VECT(EDMAC2, 0xc40),
4556d604deSPaul Mundt INTC_VECT(SIOF0, 0xe00), INTC_VECT(SIOF0, 0xe20),
4656d604deSPaul Mundt INTC_VECT(SIOF0, 0xe40), INTC_VECT(SIOF0, 0xe60),
4756d604deSPaul Mundt INTC_VECT(SIOF1, 0xe80), INTC_VECT(SIOF1, 0xea0),
4856d604deSPaul Mundt INTC_VECT(SIOF1, 0xec0), INTC_VECT(SIOF1, 0xee0),
4928b146c8SMagnus Damm INTC_VECT(TMU0, 0x400), INTC_VECT(TMU1, 0x420),
5028b146c8SMagnus Damm INTC_VECT(TMU2, 0x440),
5156d604deSPaul Mundt INTC_VECT(RTC, 0x480), INTC_VECT(RTC, 0x4a0),
5256d604deSPaul Mundt INTC_VECT(RTC, 0x4c0),
5328b146c8SMagnus Damm INTC_VECT(WDT, 0x560),
5428b146c8SMagnus Damm INTC_VECT(REF, 0x580),
5528b146c8SMagnus Damm };
5628b146c8SMagnus Damm
575c37e025SMagnus Damm static struct intc_prio_reg prio_registers[] __initdata = {
586ef5fb2cSMagnus Damm { 0xfffffee2, 0, 16, 4, /* IPRA */ { TMU0, TMU1, TMU2, RTC } },
596ef5fb2cSMagnus Damm { 0xfffffee4, 0, 16, 4, /* IPRB */ { WDT, REF, 0, 0 } },
606ef5fb2cSMagnus Damm { 0xa4000016, 0, 16, 4, /* IPRC */ { IRQ3, IRQ2, IRQ1, IRQ0 } },
616ef5fb2cSMagnus Damm { 0xa4000018, 0, 16, 4, /* IPRD */ { 0, 0, IRQ5, IRQ4 } },
626ef5fb2cSMagnus Damm { 0xa400001a, 0, 16, 4, /* IPRE */ { DMAC1, SCIF0, SCIF1 } },
63995d538aSMagnus Damm { 0xa4080000, 0, 16, 4, /* IPRF */ { IPSEC, DMAC2 } },
646ef5fb2cSMagnus Damm { 0xa4080002, 0, 16, 4, /* IPRG */ { EDMAC0, EDMAC1, EDMAC2 } },
656ef5fb2cSMagnus Damm { 0xa4080004, 0, 16, 4, /* IPRH */ { 0, 0, 0, SIOF0 } },
666ef5fb2cSMagnus Damm { 0xa4080006, 0, 16, 4, /* IPRI */ { 0, 0, SIOF1 } },
6728b146c8SMagnus Damm };
6828b146c8SMagnus Damm
6956d604deSPaul Mundt static DECLARE_INTC_DESC(intc_desc, "sh7710", vectors, NULL,
707f3edee8SMagnus Damm NULL, prio_registers, NULL);
7128b146c8SMagnus Damm
7228b146c8SMagnus Damm static struct resource rtc_resources[] = {
7328b146c8SMagnus Damm [0] = {
7428b146c8SMagnus Damm .start = 0xa413fec0,
7528b146c8SMagnus Damm .end = 0xa413fec0 + 0x1e,
7628b146c8SMagnus Damm .flags = IORESOURCE_IO,
7728b146c8SMagnus Damm },
7828b146c8SMagnus Damm [1] = {
795d0af769SPaul Mundt .start = evt2irq(0x480),
8028b146c8SMagnus Damm .flags = IORESOURCE_IRQ,
8128b146c8SMagnus Damm },
8228b146c8SMagnus Damm };
8328b146c8SMagnus Damm
84ad89f87aSPaul Mundt static struct sh_rtc_platform_info rtc_info = {
85ad89f87aSPaul Mundt .capabilities = RTC_CAP_4_DIGIT_YEAR,
86ad89f87aSPaul Mundt };
87ad89f87aSPaul Mundt
8828b146c8SMagnus Damm static struct platform_device rtc_device = {
8928b146c8SMagnus Damm .name = "sh-rtc",
9028b146c8SMagnus Damm .id = -1,
9128b146c8SMagnus Damm .num_resources = ARRAY_SIZE(rtc_resources),
9228b146c8SMagnus Damm .resource = rtc_resources,
93ad89f87aSPaul Mundt .dev = {
94ad89f87aSPaul Mundt .platform_data = &rtc_info,
95ad89f87aSPaul Mundt },
9628b146c8SMagnus Damm };
9728b146c8SMagnus Damm
9844658dfbSMagnus Damm static struct plat_sci_port scif0_platform_data = {
99a05ea9e2SLaurent Pinchart .scscr = SCSCR_REIE | SCSCR_CKE1,
100e5723e0eSPaul Mundt .type = PORT_SCIF,
101d850acf9SLaurent Pinchart };
102d850acf9SLaurent Pinchart
103d850acf9SLaurent Pinchart static struct resource scif0_resources[] = {
104d850acf9SLaurent Pinchart DEFINE_RES_MEM(0xa4400000, 0x100),
105d850acf9SLaurent Pinchart DEFINE_RES_IRQ(evt2irq(0x880)),
10644658dfbSMagnus Damm };
10744658dfbSMagnus Damm
10844658dfbSMagnus Damm static struct platform_device scif0_device = {
10944658dfbSMagnus Damm .name = "sh-sci",
11044658dfbSMagnus Damm .id = 0,
111d850acf9SLaurent Pinchart .resource = scif0_resources,
112d850acf9SLaurent Pinchart .num_resources = ARRAY_SIZE(scif0_resources),
11344658dfbSMagnus Damm .dev = {
11444658dfbSMagnus Damm .platform_data = &scif0_platform_data,
11544658dfbSMagnus Damm },
11644658dfbSMagnus Damm };
11744658dfbSMagnus Damm
11844658dfbSMagnus Damm static struct plat_sci_port scif1_platform_data = {
119a05ea9e2SLaurent Pinchart .scscr = SCSCR_REIE | SCSCR_CKE1,
1209465a54fSNobuhiro Iwamatsu .type = PORT_SCIF,
121d850acf9SLaurent Pinchart };
122d850acf9SLaurent Pinchart
123d850acf9SLaurent Pinchart static struct resource scif1_resources[] = {
124d850acf9SLaurent Pinchart DEFINE_RES_MEM(0xa4410000, 0x100),
125d850acf9SLaurent Pinchart DEFINE_RES_IRQ(evt2irq(0x900)),
126e5723e0eSPaul Mundt };
127e5723e0eSPaul Mundt
12844658dfbSMagnus Damm static struct platform_device scif1_device = {
129e5723e0eSPaul Mundt .name = "sh-sci",
13044658dfbSMagnus Damm .id = 1,
131d850acf9SLaurent Pinchart .resource = scif1_resources,
132d850acf9SLaurent Pinchart .num_resources = ARRAY_SIZE(scif1_resources),
133e5723e0eSPaul Mundt .dev = {
13444658dfbSMagnus Damm .platform_data = &scif1_platform_data,
135e5723e0eSPaul Mundt },
136e5723e0eSPaul Mundt };
137e5723e0eSPaul Mundt
138e5ad0089SMagnus Damm static struct sh_timer_config tmu0_platform_data = {
1391399c195SLaurent Pinchart .channels_mask = 7,
140e5ad0089SMagnus Damm };
141e5ad0089SMagnus Damm
142e5ad0089SMagnus Damm static struct resource tmu0_resources[] = {
1431399c195SLaurent Pinchart DEFINE_RES_MEM(0xa412fe90, 0x28),
1441399c195SLaurent Pinchart DEFINE_RES_IRQ(evt2irq(0x400)),
1451399c195SLaurent Pinchart DEFINE_RES_IRQ(evt2irq(0x420)),
1461399c195SLaurent Pinchart DEFINE_RES_IRQ(evt2irq(0x440)),
147e5ad0089SMagnus Damm };
148e5ad0089SMagnus Damm
149e5ad0089SMagnus Damm static struct platform_device tmu0_device = {
1501399c195SLaurent Pinchart .name = "sh-tmu-sh3",
151e5ad0089SMagnus Damm .id = 0,
152e5ad0089SMagnus Damm .dev = {
153e5ad0089SMagnus Damm .platform_data = &tmu0_platform_data,
154e5ad0089SMagnus Damm },
155e5ad0089SMagnus Damm .resource = tmu0_resources,
156e5ad0089SMagnus Damm .num_resources = ARRAY_SIZE(tmu0_resources),
157e5ad0089SMagnus Damm };
158e5ad0089SMagnus Damm
159e5723e0eSPaul Mundt static struct platform_device *sh7710_devices[] __initdata = {
16044658dfbSMagnus Damm &scif0_device,
16144658dfbSMagnus Damm &scif1_device,
162e5ad0089SMagnus Damm &tmu0_device,
16328b146c8SMagnus Damm &rtc_device,
164e5723e0eSPaul Mundt };
165e5723e0eSPaul Mundt
sh7710_devices_setup(void)166e5723e0eSPaul Mundt static int __init sh7710_devices_setup(void)
167e5723e0eSPaul Mundt {
168e5723e0eSPaul Mundt return platform_add_devices(sh7710_devices,
169e5723e0eSPaul Mundt ARRAY_SIZE(sh7710_devices));
170e5723e0eSPaul Mundt }
171ba9a6337SMagnus Damm arch_initcall(sh7710_devices_setup);
1729465a54fSNobuhiro Iwamatsu
173e5ad0089SMagnus Damm static struct platform_device *sh7710_early_devices[] __initdata = {
17444658dfbSMagnus Damm &scif0_device,
17544658dfbSMagnus Damm &scif1_device,
176e5ad0089SMagnus Damm &tmu0_device,
177e5ad0089SMagnus Damm };
178e5ad0089SMagnus Damm
plat_early_device_setup(void)179e5ad0089SMagnus Damm void __init plat_early_device_setup(void)
180e5ad0089SMagnus Damm {
181*201e9109SBartosz Golaszewski sh_early_platform_add_devices(sh7710_early_devices,
182e5ad0089SMagnus Damm ARRAY_SIZE(sh7710_early_devices));
183e5ad0089SMagnus Damm }
184e5ad0089SMagnus Damm
plat_irq_setup(void)18590015c89SMagnus Damm void __init plat_irq_setup(void)
1869465a54fSNobuhiro Iwamatsu {
18728b146c8SMagnus Damm register_intc_controller(&intc_desc);
188a276e588SMagnus Damm plat_irq_setup_sh3();
1899465a54fSNobuhiro Iwamatsu }
190