1*5ab5d57cSKuninori 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> 16e5723e0eSPaul Mundt 1728b146c8SMagnus Damm enum { 1828b146c8SMagnus Damm UNUSED = 0, 1928b146c8SMagnus Damm 2028b146c8SMagnus Damm /* interrupt sources */ 2128b146c8SMagnus Damm IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, 2256d604deSPaul Mundt DMAC1, SCIF0, SCIF1, DMAC2, IPSEC, 2328b146c8SMagnus Damm EDMAC0, EDMAC1, EDMAC2, 2456d604deSPaul Mundt SIOF0, SIOF1, 2528b146c8SMagnus Damm 2656d604deSPaul Mundt TMU0, TMU1, TMU2, 2756d604deSPaul Mundt RTC, WDT, REF, 2828b146c8SMagnus Damm }; 2928b146c8SMagnus Damm 305c37e025SMagnus Damm static struct intc_vect vectors[] __initdata = { 31a276e588SMagnus Damm /* IRQ0->5 are handled in setup-sh3.c */ 3256d604deSPaul Mundt INTC_VECT(DMAC1, 0x800), INTC_VECT(DMAC1, 0x820), 3356d604deSPaul Mundt INTC_VECT(DMAC1, 0x840), INTC_VECT(DMAC1, 0x860), 3456d604deSPaul Mundt INTC_VECT(SCIF0, 0x880), INTC_VECT(SCIF0, 0x8a0), 3556d604deSPaul Mundt INTC_VECT(SCIF0, 0x8c0), INTC_VECT(SCIF0, 0x8e0), 3656d604deSPaul Mundt INTC_VECT(SCIF1, 0x900), INTC_VECT(SCIF1, 0x920), 3756d604deSPaul Mundt INTC_VECT(SCIF1, 0x940), INTC_VECT(SCIF1, 0x960), 3856d604deSPaul Mundt INTC_VECT(DMAC2, 0xb80), INTC_VECT(DMAC2, 0xba0), 39ac919986SMagnus Damm #ifdef CONFIG_CPU_SUBTYPE_SH7710 4028b146c8SMagnus Damm INTC_VECT(IPSEC, 0xbe0), 41ac919986SMagnus Damm #endif 4228b146c8SMagnus Damm INTC_VECT(EDMAC0, 0xc00), INTC_VECT(EDMAC1, 0xc20), 4328b146c8SMagnus Damm INTC_VECT(EDMAC2, 0xc40), 4456d604deSPaul Mundt INTC_VECT(SIOF0, 0xe00), INTC_VECT(SIOF0, 0xe20), 4556d604deSPaul Mundt INTC_VECT(SIOF0, 0xe40), INTC_VECT(SIOF0, 0xe60), 4656d604deSPaul Mundt INTC_VECT(SIOF1, 0xe80), INTC_VECT(SIOF1, 0xea0), 4756d604deSPaul Mundt INTC_VECT(SIOF1, 0xec0), INTC_VECT(SIOF1, 0xee0), 4828b146c8SMagnus Damm INTC_VECT(TMU0, 0x400), INTC_VECT(TMU1, 0x420), 4928b146c8SMagnus Damm INTC_VECT(TMU2, 0x440), 5056d604deSPaul Mundt INTC_VECT(RTC, 0x480), INTC_VECT(RTC, 0x4a0), 5156d604deSPaul Mundt INTC_VECT(RTC, 0x4c0), 5228b146c8SMagnus Damm INTC_VECT(WDT, 0x560), 5328b146c8SMagnus Damm INTC_VECT(REF, 0x580), 5428b146c8SMagnus Damm }; 5528b146c8SMagnus Damm 565c37e025SMagnus Damm static struct intc_prio_reg prio_registers[] __initdata = { 576ef5fb2cSMagnus Damm { 0xfffffee2, 0, 16, 4, /* IPRA */ { TMU0, TMU1, TMU2, RTC } }, 586ef5fb2cSMagnus Damm { 0xfffffee4, 0, 16, 4, /* IPRB */ { WDT, REF, 0, 0 } }, 596ef5fb2cSMagnus Damm { 0xa4000016, 0, 16, 4, /* IPRC */ { IRQ3, IRQ2, IRQ1, IRQ0 } }, 606ef5fb2cSMagnus Damm { 0xa4000018, 0, 16, 4, /* IPRD */ { 0, 0, IRQ5, IRQ4 } }, 616ef5fb2cSMagnus Damm { 0xa400001a, 0, 16, 4, /* IPRE */ { DMAC1, SCIF0, SCIF1 } }, 62995d538aSMagnus Damm { 0xa4080000, 0, 16, 4, /* IPRF */ { IPSEC, DMAC2 } }, 636ef5fb2cSMagnus Damm { 0xa4080002, 0, 16, 4, /* IPRG */ { EDMAC0, EDMAC1, EDMAC2 } }, 646ef5fb2cSMagnus Damm { 0xa4080004, 0, 16, 4, /* IPRH */ { 0, 0, 0, SIOF0 } }, 656ef5fb2cSMagnus Damm { 0xa4080006, 0, 16, 4, /* IPRI */ { 0, 0, SIOF1 } }, 6628b146c8SMagnus Damm }; 6728b146c8SMagnus Damm 6856d604deSPaul Mundt static DECLARE_INTC_DESC(intc_desc, "sh7710", vectors, NULL, 697f3edee8SMagnus Damm NULL, prio_registers, NULL); 7028b146c8SMagnus Damm 7128b146c8SMagnus Damm static struct resource rtc_resources[] = { 7228b146c8SMagnus Damm [0] = { 7328b146c8SMagnus Damm .start = 0xa413fec0, 7428b146c8SMagnus Damm .end = 0xa413fec0 + 0x1e, 7528b146c8SMagnus Damm .flags = IORESOURCE_IO, 7628b146c8SMagnus Damm }, 7728b146c8SMagnus Damm [1] = { 785d0af769SPaul Mundt .start = evt2irq(0x480), 7928b146c8SMagnus Damm .flags = IORESOURCE_IRQ, 8028b146c8SMagnus Damm }, 8128b146c8SMagnus Damm }; 8228b146c8SMagnus Damm 83ad89f87aSPaul Mundt static struct sh_rtc_platform_info rtc_info = { 84ad89f87aSPaul Mundt .capabilities = RTC_CAP_4_DIGIT_YEAR, 85ad89f87aSPaul Mundt }; 86ad89f87aSPaul Mundt 8728b146c8SMagnus Damm static struct platform_device rtc_device = { 8828b146c8SMagnus Damm .name = "sh-rtc", 8928b146c8SMagnus Damm .id = -1, 9028b146c8SMagnus Damm .num_resources = ARRAY_SIZE(rtc_resources), 9128b146c8SMagnus Damm .resource = rtc_resources, 92ad89f87aSPaul Mundt .dev = { 93ad89f87aSPaul Mundt .platform_data = &rtc_info, 94ad89f87aSPaul Mundt }, 9528b146c8SMagnus Damm }; 9628b146c8SMagnus Damm 9744658dfbSMagnus Damm static struct plat_sci_port scif0_platform_data = { 98a05ea9e2SLaurent Pinchart .scscr = SCSCR_REIE | SCSCR_CKE1, 99e5723e0eSPaul Mundt .type = PORT_SCIF, 100d850acf9SLaurent Pinchart }; 101d850acf9SLaurent Pinchart 102d850acf9SLaurent Pinchart static struct resource scif0_resources[] = { 103d850acf9SLaurent Pinchart DEFINE_RES_MEM(0xa4400000, 0x100), 104d850acf9SLaurent Pinchart DEFINE_RES_IRQ(evt2irq(0x880)), 10544658dfbSMagnus Damm }; 10644658dfbSMagnus Damm 10744658dfbSMagnus Damm static struct platform_device scif0_device = { 10844658dfbSMagnus Damm .name = "sh-sci", 10944658dfbSMagnus Damm .id = 0, 110d850acf9SLaurent Pinchart .resource = scif0_resources, 111d850acf9SLaurent Pinchart .num_resources = ARRAY_SIZE(scif0_resources), 11244658dfbSMagnus Damm .dev = { 11344658dfbSMagnus Damm .platform_data = &scif0_platform_data, 11444658dfbSMagnus Damm }, 11544658dfbSMagnus Damm }; 11644658dfbSMagnus Damm 11744658dfbSMagnus Damm static struct plat_sci_port scif1_platform_data = { 118a05ea9e2SLaurent Pinchart .scscr = SCSCR_REIE | SCSCR_CKE1, 1199465a54fSNobuhiro Iwamatsu .type = PORT_SCIF, 120d850acf9SLaurent Pinchart }; 121d850acf9SLaurent Pinchart 122d850acf9SLaurent Pinchart static struct resource scif1_resources[] = { 123d850acf9SLaurent Pinchart DEFINE_RES_MEM(0xa4410000, 0x100), 124d850acf9SLaurent Pinchart DEFINE_RES_IRQ(evt2irq(0x900)), 125e5723e0eSPaul Mundt }; 126e5723e0eSPaul Mundt 12744658dfbSMagnus Damm static struct platform_device scif1_device = { 128e5723e0eSPaul Mundt .name = "sh-sci", 12944658dfbSMagnus Damm .id = 1, 130d850acf9SLaurent Pinchart .resource = scif1_resources, 131d850acf9SLaurent Pinchart .num_resources = ARRAY_SIZE(scif1_resources), 132e5723e0eSPaul Mundt .dev = { 13344658dfbSMagnus Damm .platform_data = &scif1_platform_data, 134e5723e0eSPaul Mundt }, 135e5723e0eSPaul Mundt }; 136e5723e0eSPaul Mundt 137e5ad0089SMagnus Damm static struct sh_timer_config tmu0_platform_data = { 1381399c195SLaurent Pinchart .channels_mask = 7, 139e5ad0089SMagnus Damm }; 140e5ad0089SMagnus Damm 141e5ad0089SMagnus Damm static struct resource tmu0_resources[] = { 1421399c195SLaurent Pinchart DEFINE_RES_MEM(0xa412fe90, 0x28), 1431399c195SLaurent Pinchart DEFINE_RES_IRQ(evt2irq(0x400)), 1441399c195SLaurent Pinchart DEFINE_RES_IRQ(evt2irq(0x420)), 1451399c195SLaurent Pinchart DEFINE_RES_IRQ(evt2irq(0x440)), 146e5ad0089SMagnus Damm }; 147e5ad0089SMagnus Damm 148e5ad0089SMagnus Damm static struct platform_device tmu0_device = { 1491399c195SLaurent Pinchart .name = "sh-tmu-sh3", 150e5ad0089SMagnus Damm .id = 0, 151e5ad0089SMagnus Damm .dev = { 152e5ad0089SMagnus Damm .platform_data = &tmu0_platform_data, 153e5ad0089SMagnus Damm }, 154e5ad0089SMagnus Damm .resource = tmu0_resources, 155e5ad0089SMagnus Damm .num_resources = ARRAY_SIZE(tmu0_resources), 156e5ad0089SMagnus Damm }; 157e5ad0089SMagnus Damm 158e5723e0eSPaul Mundt static struct platform_device *sh7710_devices[] __initdata = { 15944658dfbSMagnus Damm &scif0_device, 16044658dfbSMagnus Damm &scif1_device, 161e5ad0089SMagnus Damm &tmu0_device, 16228b146c8SMagnus Damm &rtc_device, 163e5723e0eSPaul Mundt }; 164e5723e0eSPaul Mundt 165e5723e0eSPaul Mundt static int __init sh7710_devices_setup(void) 166e5723e0eSPaul Mundt { 167e5723e0eSPaul Mundt return platform_add_devices(sh7710_devices, 168e5723e0eSPaul Mundt ARRAY_SIZE(sh7710_devices)); 169e5723e0eSPaul Mundt } 170ba9a6337SMagnus Damm arch_initcall(sh7710_devices_setup); 1719465a54fSNobuhiro Iwamatsu 172e5ad0089SMagnus Damm static struct platform_device *sh7710_early_devices[] __initdata = { 17344658dfbSMagnus Damm &scif0_device, 17444658dfbSMagnus Damm &scif1_device, 175e5ad0089SMagnus Damm &tmu0_device, 176e5ad0089SMagnus Damm }; 177e5ad0089SMagnus Damm 178e5ad0089SMagnus Damm void __init plat_early_device_setup(void) 179e5ad0089SMagnus Damm { 180e5ad0089SMagnus Damm early_platform_add_devices(sh7710_early_devices, 181e5ad0089SMagnus Damm ARRAY_SIZE(sh7710_early_devices)); 182e5ad0089SMagnus Damm } 183e5ad0089SMagnus Damm 18490015c89SMagnus Damm void __init plat_irq_setup(void) 1859465a54fSNobuhiro Iwamatsu { 18628b146c8SMagnus Damm register_intc_controller(&intc_desc); 187a276e588SMagnus Damm plat_irq_setup_sh3(); 1889465a54fSNobuhiro Iwamatsu } 189