1e5723e0eSPaul Mundt /* 2ac919986SMagnus Damm * SH3 Setup code for SH7710, SH7712 3e5723e0eSPaul Mundt * 4ad89f87aSPaul Mundt * Copyright (C) 2006, 2007 Paul Mundt 59465a54fSNobuhiro Iwamatsu * Copyright (C) 2007 Nobuhiro Iwamatsu 6e5723e0eSPaul Mundt * 7e5723e0eSPaul Mundt * This file is subject to the terms and conditions of the GNU General Public 8e5723e0eSPaul Mundt * License. See the file "COPYING" in the main directory of this archive 9e5723e0eSPaul Mundt * for more details. 10e5723e0eSPaul Mundt */ 11e5723e0eSPaul Mundt #include <linux/platform_device.h> 12e5723e0eSPaul Mundt #include <linux/init.h> 1328b146c8SMagnus Damm #include <linux/irq.h> 14e5723e0eSPaul Mundt #include <linux/serial.h> 1596de1a8fSPaul Mundt #include <linux/serial_sci.h> 16ad89f87aSPaul Mundt #include <asm/rtc.h> 17e5723e0eSPaul Mundt 1828b146c8SMagnus Damm enum { 1928b146c8SMagnus Damm UNUSED = 0, 2028b146c8SMagnus Damm 2128b146c8SMagnus Damm /* interrupt sources */ 2228b146c8SMagnus Damm IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, 2328b146c8SMagnus Damm DMAC_DEI0, DMAC_DEI1, DMAC_DEI2, DMAC_DEI3, 2428b146c8SMagnus Damm SCIF0_ERI, SCIF0_RXI, SCIF0_BRI, SCIF0_TXI, 2528b146c8SMagnus Damm SCIF1_ERI, SCIF1_RXI, SCIF1_BRI, SCIF1_TXI, 2628b146c8SMagnus Damm DMAC_DEI4, DMAC_DEI5, 2728b146c8SMagnus Damm IPSEC, 2828b146c8SMagnus Damm EDMAC0, EDMAC1, EDMAC2, 2928b146c8SMagnus Damm SIOF0_ERI, SIOF0_TXI, SIOF0_RXI, SIOF0_CCI, 3028b146c8SMagnus Damm SIOF1_ERI, SIOF1_TXI, SIOF1_RXI, SIOF1_CCI, 3128b146c8SMagnus Damm TMU0, TMU1, TMU2, 3228b146c8SMagnus Damm RTC_ATI, RTC_PRI, RTC_CUI, 3328b146c8SMagnus Damm WDT, 3428b146c8SMagnus Damm REF, 3528b146c8SMagnus Damm 3628b146c8SMagnus Damm /* interrupt groups */ 3728b146c8SMagnus Damm RTC, DMAC1, SCIF0, SCIF1, DMAC2, SIOF0, SIOF1, 3828b146c8SMagnus Damm }; 3928b146c8SMagnus Damm 405c37e025SMagnus Damm static struct intc_vect vectors[] __initdata = { 41*a276e588SMagnus Damm /* IRQ0->5 are handled in setup-sh3.c */ 4228b146c8SMagnus Damm INTC_VECT(DMAC_DEI0, 0x800), INTC_VECT(DMAC_DEI1, 0x820), 4328b146c8SMagnus Damm INTC_VECT(DMAC_DEI2, 0x840), INTC_VECT(DMAC_DEI3, 0x860), 4428b146c8SMagnus Damm INTC_VECT(SCIF0_ERI, 0x880), INTC_VECT(SCIF0_RXI, 0x8a0), 4528b146c8SMagnus Damm INTC_VECT(SCIF0_BRI, 0x8c0), INTC_VECT(SCIF0_TXI, 0x8e0), 4628b146c8SMagnus Damm INTC_VECT(SCIF1_ERI, 0x900), INTC_VECT(SCIF1_RXI, 0x920), 4728b146c8SMagnus Damm INTC_VECT(SCIF1_BRI, 0x940), INTC_VECT(SCIF1_TXI, 0x960), 4828b146c8SMagnus Damm INTC_VECT(DMAC_DEI4, 0xb80), INTC_VECT(DMAC_DEI5, 0xba0), 49ac919986SMagnus Damm #ifdef CONFIG_CPU_SUBTYPE_SH7710 5028b146c8SMagnus Damm INTC_VECT(IPSEC, 0xbe0), 51ac919986SMagnus Damm #endif 5228b146c8SMagnus Damm INTC_VECT(EDMAC0, 0xc00), INTC_VECT(EDMAC1, 0xc20), 5328b146c8SMagnus Damm INTC_VECT(EDMAC2, 0xc40), 5428b146c8SMagnus Damm INTC_VECT(SIOF0_ERI, 0xe00), INTC_VECT(SIOF0_TXI, 0xe20), 5528b146c8SMagnus Damm INTC_VECT(SIOF0_RXI, 0xe40), INTC_VECT(SIOF0_CCI, 0xe60), 5628b146c8SMagnus Damm INTC_VECT(SIOF1_ERI, 0xe80), INTC_VECT(SIOF1_TXI, 0xea0), 5728b146c8SMagnus Damm INTC_VECT(SIOF1_RXI, 0xec0), INTC_VECT(SIOF1_CCI, 0xee0), 5828b146c8SMagnus Damm INTC_VECT(TMU0, 0x400), INTC_VECT(TMU1, 0x420), 5928b146c8SMagnus Damm INTC_VECT(TMU2, 0x440), 6028b146c8SMagnus Damm INTC_VECT(RTC_ATI, 0x480), INTC_VECT(RTC_PRI, 0x4a0), 6128b146c8SMagnus Damm INTC_VECT(RTC_CUI, 0x4c0), 6228b146c8SMagnus Damm INTC_VECT(WDT, 0x560), 6328b146c8SMagnus Damm INTC_VECT(REF, 0x580), 6428b146c8SMagnus Damm }; 6528b146c8SMagnus Damm 665c37e025SMagnus Damm static struct intc_group groups[] __initdata = { 6728b146c8SMagnus Damm INTC_GROUP(RTC, RTC_ATI, RTC_PRI, RTC_CUI), 6828b146c8SMagnus Damm INTC_GROUP(DMAC1, DMAC_DEI0, DMAC_DEI1, DMAC_DEI2, DMAC_DEI3), 6928b146c8SMagnus Damm INTC_GROUP(SCIF0, SCIF0_ERI, SCIF0_RXI, SCIF0_BRI, SCIF0_TXI), 7028b146c8SMagnus Damm INTC_GROUP(SCIF1, SCIF1_ERI, SCIF1_RXI, SCIF1_BRI, SCIF1_TXI), 7128b146c8SMagnus Damm INTC_GROUP(DMAC2, DMAC_DEI4, DMAC_DEI5), 7228b146c8SMagnus Damm INTC_GROUP(SIOF0, SIOF0_ERI, SIOF0_TXI, SIOF0_RXI, SIOF0_CCI), 7328b146c8SMagnus Damm INTC_GROUP(SIOF1, SIOF1_ERI, SIOF1_TXI, SIOF1_RXI, SIOF1_CCI), 7428b146c8SMagnus Damm }; 7528b146c8SMagnus Damm 765c37e025SMagnus Damm static struct intc_prio_reg prio_registers[] __initdata = { 776ef5fb2cSMagnus Damm { 0xfffffee2, 0, 16, 4, /* IPRA */ { TMU0, TMU1, TMU2, RTC } }, 786ef5fb2cSMagnus Damm { 0xfffffee4, 0, 16, 4, /* IPRB */ { WDT, REF, 0, 0 } }, 796ef5fb2cSMagnus Damm { 0xa4000016, 0, 16, 4, /* IPRC */ { IRQ3, IRQ2, IRQ1, IRQ0 } }, 806ef5fb2cSMagnus Damm { 0xa4000018, 0, 16, 4, /* IPRD */ { 0, 0, IRQ5, IRQ4 } }, 816ef5fb2cSMagnus Damm { 0xa400001a, 0, 16, 4, /* IPRE */ { DMAC1, SCIF0, SCIF1 } }, 826ef5fb2cSMagnus Damm { 0xa4080000, 0, 16, 4, /* IPRF */ { 0, DMAC2 } }, 83ac919986SMagnus Damm #ifdef CONFIG_CPU_SUBTYPE_SH7710 846ef5fb2cSMagnus Damm { 0xa4080000, 0, 16, 4, /* IPRF */ { IPSEC } }, 85ac919986SMagnus Damm #endif 866ef5fb2cSMagnus Damm { 0xa4080002, 0, 16, 4, /* IPRG */ { EDMAC0, EDMAC1, EDMAC2 } }, 876ef5fb2cSMagnus Damm { 0xa4080004, 0, 16, 4, /* IPRH */ { 0, 0, 0, SIOF0 } }, 886ef5fb2cSMagnus Damm { 0xa4080006, 0, 16, 4, /* IPRI */ { 0, 0, SIOF1 } }, 8928b146c8SMagnus Damm }; 9028b146c8SMagnus Damm 9128b146c8SMagnus Damm static DECLARE_INTC_DESC(intc_desc, "sh7710", vectors, groups, 927f3edee8SMagnus Damm NULL, prio_registers, NULL); 9328b146c8SMagnus Damm 9428b146c8SMagnus Damm static struct resource rtc_resources[] = { 9528b146c8SMagnus Damm [0] = { 9628b146c8SMagnus Damm .start = 0xa413fec0, 9728b146c8SMagnus Damm .end = 0xa413fec0 + 0x1e, 9828b146c8SMagnus Damm .flags = IORESOURCE_IO, 9928b146c8SMagnus Damm }, 10028b146c8SMagnus Damm [1] = { 10128b146c8SMagnus Damm .start = 20, 10228b146c8SMagnus Damm .flags = IORESOURCE_IRQ, 10328b146c8SMagnus Damm }, 10428b146c8SMagnus Damm [2] = { 10528b146c8SMagnus Damm .start = 21, 10628b146c8SMagnus Damm .flags = IORESOURCE_IRQ, 10728b146c8SMagnus Damm }, 10828b146c8SMagnus Damm [3] = { 10928b146c8SMagnus Damm .start = 22, 11028b146c8SMagnus Damm .flags = IORESOURCE_IRQ, 11128b146c8SMagnus Damm }, 11228b146c8SMagnus Damm }; 11328b146c8SMagnus Damm 114ad89f87aSPaul Mundt static struct sh_rtc_platform_info rtc_info = { 115ad89f87aSPaul Mundt .capabilities = RTC_CAP_4_DIGIT_YEAR, 116ad89f87aSPaul Mundt }; 117ad89f87aSPaul Mundt 11828b146c8SMagnus Damm static struct platform_device rtc_device = { 11928b146c8SMagnus Damm .name = "sh-rtc", 12028b146c8SMagnus Damm .id = -1, 12128b146c8SMagnus Damm .num_resources = ARRAY_SIZE(rtc_resources), 12228b146c8SMagnus Damm .resource = rtc_resources, 123ad89f87aSPaul Mundt .dev = { 124ad89f87aSPaul Mundt .platform_data = &rtc_info, 125ad89f87aSPaul Mundt }, 12628b146c8SMagnus Damm }; 12728b146c8SMagnus Damm 128e5723e0eSPaul Mundt static struct plat_sci_port sci_platform_data[] = { 129e5723e0eSPaul Mundt { 130e5723e0eSPaul Mundt .mapbase = 0xa4400000, 131e5723e0eSPaul Mundt .flags = UPF_BOOT_AUTOCONF, 132e5723e0eSPaul Mundt .type = PORT_SCIF, 133e5723e0eSPaul Mundt .irqs = { 52, 53, 55, 54 }, 134e5723e0eSPaul Mundt }, { 13528b146c8SMagnus Damm .mapbase = 0xa4410000, 1369465a54fSNobuhiro Iwamatsu .flags = UPF_BOOT_AUTOCONF, 1379465a54fSNobuhiro Iwamatsu .type = PORT_SCIF, 1389465a54fSNobuhiro Iwamatsu .irqs = { 56, 57, 59, 58 }, 1399465a54fSNobuhiro Iwamatsu }, { 1409465a54fSNobuhiro Iwamatsu 141e5723e0eSPaul Mundt .flags = 0, 142e5723e0eSPaul Mundt } 143e5723e0eSPaul Mundt }; 144e5723e0eSPaul Mundt 145e5723e0eSPaul Mundt static struct platform_device sci_device = { 146e5723e0eSPaul Mundt .name = "sh-sci", 147e5723e0eSPaul Mundt .id = -1, 148e5723e0eSPaul Mundt .dev = { 149e5723e0eSPaul Mundt .platform_data = sci_platform_data, 150e5723e0eSPaul Mundt }, 151e5723e0eSPaul Mundt }; 152e5723e0eSPaul Mundt 153e5723e0eSPaul Mundt static struct platform_device *sh7710_devices[] __initdata = { 154e5723e0eSPaul Mundt &sci_device, 15528b146c8SMagnus Damm &rtc_device, 156e5723e0eSPaul Mundt }; 157e5723e0eSPaul Mundt 158e5723e0eSPaul Mundt static int __init sh7710_devices_setup(void) 159e5723e0eSPaul Mundt { 160e5723e0eSPaul Mundt return platform_add_devices(sh7710_devices, 161e5723e0eSPaul Mundt ARRAY_SIZE(sh7710_devices)); 162e5723e0eSPaul Mundt } 163e5723e0eSPaul Mundt __initcall(sh7710_devices_setup); 1649465a54fSNobuhiro Iwamatsu 16590015c89SMagnus Damm void __init plat_irq_setup(void) 1669465a54fSNobuhiro Iwamatsu { 16728b146c8SMagnus Damm register_intc_controller(&intc_desc); 168*a276e588SMagnus Damm plat_irq_setup_sh3(); 1699465a54fSNobuhiro Iwamatsu } 170