1e5723e0eSPaul Mundt /* 2ac919986SMagnus Damm * SH3 Setup code for SH7710, SH7712 3e5723e0eSPaul Mundt * 456d604deSPaul Mundt * Copyright (C) 2006 - 2009 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> 16*e5ad0089SMagnus Damm #include <linux/sh_timer.h> 17ad89f87aSPaul Mundt #include <asm/rtc.h> 18e5723e0eSPaul Mundt 1928b146c8SMagnus Damm enum { 2028b146c8SMagnus Damm UNUSED = 0, 2128b146c8SMagnus Damm 2228b146c8SMagnus Damm /* interrupt sources */ 2328b146c8SMagnus Damm IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, 2456d604deSPaul Mundt DMAC1, SCIF0, SCIF1, DMAC2, IPSEC, 2528b146c8SMagnus Damm EDMAC0, EDMAC1, EDMAC2, 2656d604deSPaul Mundt SIOF0, SIOF1, 2728b146c8SMagnus Damm 2856d604deSPaul Mundt TMU0, TMU1, TMU2, 2956d604deSPaul Mundt RTC, WDT, REF, 3028b146c8SMagnus Damm }; 3128b146c8SMagnus Damm 325c37e025SMagnus Damm static struct intc_vect vectors[] __initdata = { 33a276e588SMagnus Damm /* IRQ0->5 are handled in setup-sh3.c */ 3456d604deSPaul Mundt INTC_VECT(DMAC1, 0x800), INTC_VECT(DMAC1, 0x820), 3556d604deSPaul Mundt INTC_VECT(DMAC1, 0x840), INTC_VECT(DMAC1, 0x860), 3656d604deSPaul Mundt INTC_VECT(SCIF0, 0x880), INTC_VECT(SCIF0, 0x8a0), 3756d604deSPaul Mundt INTC_VECT(SCIF0, 0x8c0), INTC_VECT(SCIF0, 0x8e0), 3856d604deSPaul Mundt INTC_VECT(SCIF1, 0x900), INTC_VECT(SCIF1, 0x920), 3956d604deSPaul Mundt INTC_VECT(SCIF1, 0x940), INTC_VECT(SCIF1, 0x960), 4056d604deSPaul Mundt INTC_VECT(DMAC2, 0xb80), INTC_VECT(DMAC2, 0xba0), 41ac919986SMagnus Damm #ifdef CONFIG_CPU_SUBTYPE_SH7710 4228b146c8SMagnus Damm INTC_VECT(IPSEC, 0xbe0), 43ac919986SMagnus Damm #endif 4428b146c8SMagnus Damm INTC_VECT(EDMAC0, 0xc00), INTC_VECT(EDMAC1, 0xc20), 4528b146c8SMagnus Damm INTC_VECT(EDMAC2, 0xc40), 4656d604deSPaul Mundt INTC_VECT(SIOF0, 0xe00), INTC_VECT(SIOF0, 0xe20), 4756d604deSPaul Mundt INTC_VECT(SIOF0, 0xe40), INTC_VECT(SIOF0, 0xe60), 4856d604deSPaul Mundt INTC_VECT(SIOF1, 0xe80), INTC_VECT(SIOF1, 0xea0), 4956d604deSPaul Mundt INTC_VECT(SIOF1, 0xec0), INTC_VECT(SIOF1, 0xee0), 5028b146c8SMagnus Damm INTC_VECT(TMU0, 0x400), INTC_VECT(TMU1, 0x420), 5128b146c8SMagnus Damm INTC_VECT(TMU2, 0x440), 5256d604deSPaul Mundt INTC_VECT(RTC, 0x480), INTC_VECT(RTC, 0x4a0), 5356d604deSPaul Mundt INTC_VECT(RTC, 0x4c0), 5428b146c8SMagnus Damm INTC_VECT(WDT, 0x560), 5528b146c8SMagnus Damm INTC_VECT(REF, 0x580), 5628b146c8SMagnus Damm }; 5728b146c8SMagnus Damm 585c37e025SMagnus Damm static struct intc_prio_reg prio_registers[] __initdata = { 596ef5fb2cSMagnus Damm { 0xfffffee2, 0, 16, 4, /* IPRA */ { TMU0, TMU1, TMU2, RTC } }, 606ef5fb2cSMagnus Damm { 0xfffffee4, 0, 16, 4, /* IPRB */ { WDT, REF, 0, 0 } }, 616ef5fb2cSMagnus Damm { 0xa4000016, 0, 16, 4, /* IPRC */ { IRQ3, IRQ2, IRQ1, IRQ0 } }, 626ef5fb2cSMagnus Damm { 0xa4000018, 0, 16, 4, /* IPRD */ { 0, 0, IRQ5, IRQ4 } }, 636ef5fb2cSMagnus Damm { 0xa400001a, 0, 16, 4, /* IPRE */ { DMAC1, SCIF0, SCIF1 } }, 64995d538aSMagnus Damm { 0xa4080000, 0, 16, 4, /* IPRF */ { IPSEC, DMAC2 } }, 656ef5fb2cSMagnus Damm { 0xa4080002, 0, 16, 4, /* IPRG */ { EDMAC0, EDMAC1, EDMAC2 } }, 666ef5fb2cSMagnus Damm { 0xa4080004, 0, 16, 4, /* IPRH */ { 0, 0, 0, SIOF0 } }, 676ef5fb2cSMagnus Damm { 0xa4080006, 0, 16, 4, /* IPRI */ { 0, 0, SIOF1 } }, 6828b146c8SMagnus Damm }; 6928b146c8SMagnus Damm 7056d604deSPaul Mundt static DECLARE_INTC_DESC(intc_desc, "sh7710", vectors, NULL, 717f3edee8SMagnus Damm NULL, prio_registers, NULL); 7228b146c8SMagnus Damm 7328b146c8SMagnus Damm static struct resource rtc_resources[] = { 7428b146c8SMagnus Damm [0] = { 7528b146c8SMagnus Damm .start = 0xa413fec0, 7628b146c8SMagnus Damm .end = 0xa413fec0 + 0x1e, 7728b146c8SMagnus Damm .flags = IORESOURCE_IO, 7828b146c8SMagnus Damm }, 7928b146c8SMagnus Damm [1] = { 8028b146c8SMagnus Damm .start = 20, 8128b146c8SMagnus Damm .flags = IORESOURCE_IRQ, 8228b146c8SMagnus Damm }, 8328b146c8SMagnus Damm }; 8428b146c8SMagnus Damm 85ad89f87aSPaul Mundt static struct sh_rtc_platform_info rtc_info = { 86ad89f87aSPaul Mundt .capabilities = RTC_CAP_4_DIGIT_YEAR, 87ad89f87aSPaul Mundt }; 88ad89f87aSPaul Mundt 8928b146c8SMagnus Damm static struct platform_device rtc_device = { 9028b146c8SMagnus Damm .name = "sh-rtc", 9128b146c8SMagnus Damm .id = -1, 9228b146c8SMagnus Damm .num_resources = ARRAY_SIZE(rtc_resources), 9328b146c8SMagnus Damm .resource = rtc_resources, 94ad89f87aSPaul Mundt .dev = { 95ad89f87aSPaul Mundt .platform_data = &rtc_info, 96ad89f87aSPaul Mundt }, 9728b146c8SMagnus Damm }; 9828b146c8SMagnus Damm 99e5723e0eSPaul Mundt static struct plat_sci_port sci_platform_data[] = { 100e5723e0eSPaul Mundt { 101e5723e0eSPaul Mundt .mapbase = 0xa4400000, 102e5723e0eSPaul Mundt .flags = UPF_BOOT_AUTOCONF, 103e5723e0eSPaul Mundt .type = PORT_SCIF, 10456d604deSPaul Mundt .irqs = { 52, 52, 52, 52 }, 105e5723e0eSPaul Mundt }, { 10628b146c8SMagnus Damm .mapbase = 0xa4410000, 1079465a54fSNobuhiro Iwamatsu .flags = UPF_BOOT_AUTOCONF, 1089465a54fSNobuhiro Iwamatsu .type = PORT_SCIF, 10956d604deSPaul Mundt .irqs = { 56, 56, 56, 56 }, 1109465a54fSNobuhiro Iwamatsu }, { 1119465a54fSNobuhiro Iwamatsu 112e5723e0eSPaul Mundt .flags = 0, 113e5723e0eSPaul Mundt } 114e5723e0eSPaul Mundt }; 115e5723e0eSPaul Mundt 116e5723e0eSPaul Mundt static struct platform_device sci_device = { 117e5723e0eSPaul Mundt .name = "sh-sci", 118e5723e0eSPaul Mundt .id = -1, 119e5723e0eSPaul Mundt .dev = { 120e5723e0eSPaul Mundt .platform_data = sci_platform_data, 121e5723e0eSPaul Mundt }, 122e5723e0eSPaul Mundt }; 123e5723e0eSPaul Mundt 124*e5ad0089SMagnus Damm static struct sh_timer_config tmu0_platform_data = { 125*e5ad0089SMagnus Damm .name = "TMU0", 126*e5ad0089SMagnus Damm .channel_offset = 0x02, 127*e5ad0089SMagnus Damm .timer_bit = 0, 128*e5ad0089SMagnus Damm .clk = "module_clk", 129*e5ad0089SMagnus Damm .clockevent_rating = 200, 130*e5ad0089SMagnus Damm }; 131*e5ad0089SMagnus Damm 132*e5ad0089SMagnus Damm static struct resource tmu0_resources[] = { 133*e5ad0089SMagnus Damm [0] = { 134*e5ad0089SMagnus Damm .name = "TMU0", 135*e5ad0089SMagnus Damm .start = 0xa412fe94, 136*e5ad0089SMagnus Damm .end = 0xa412fe9f, 137*e5ad0089SMagnus Damm .flags = IORESOURCE_MEM, 138*e5ad0089SMagnus Damm }, 139*e5ad0089SMagnus Damm [1] = { 140*e5ad0089SMagnus Damm .start = 16, 141*e5ad0089SMagnus Damm .flags = IORESOURCE_IRQ, 142*e5ad0089SMagnus Damm }, 143*e5ad0089SMagnus Damm }; 144*e5ad0089SMagnus Damm 145*e5ad0089SMagnus Damm static struct platform_device tmu0_device = { 146*e5ad0089SMagnus Damm .name = "sh_tmu", 147*e5ad0089SMagnus Damm .id = 0, 148*e5ad0089SMagnus Damm .dev = { 149*e5ad0089SMagnus Damm .platform_data = &tmu0_platform_data, 150*e5ad0089SMagnus Damm }, 151*e5ad0089SMagnus Damm .resource = tmu0_resources, 152*e5ad0089SMagnus Damm .num_resources = ARRAY_SIZE(tmu0_resources), 153*e5ad0089SMagnus Damm }; 154*e5ad0089SMagnus Damm 155*e5ad0089SMagnus Damm static struct sh_timer_config tmu1_platform_data = { 156*e5ad0089SMagnus Damm .name = "TMU1", 157*e5ad0089SMagnus Damm .channel_offset = 0xe, 158*e5ad0089SMagnus Damm .timer_bit = 1, 159*e5ad0089SMagnus Damm .clk = "module_clk", 160*e5ad0089SMagnus Damm .clocksource_rating = 200, 161*e5ad0089SMagnus Damm }; 162*e5ad0089SMagnus Damm 163*e5ad0089SMagnus Damm static struct resource tmu1_resources[] = { 164*e5ad0089SMagnus Damm [0] = { 165*e5ad0089SMagnus Damm .name = "TMU1", 166*e5ad0089SMagnus Damm .start = 0xa412fea0, 167*e5ad0089SMagnus Damm .end = 0xa412feab, 168*e5ad0089SMagnus Damm .flags = IORESOURCE_MEM, 169*e5ad0089SMagnus Damm }, 170*e5ad0089SMagnus Damm [1] = { 171*e5ad0089SMagnus Damm .start = 17, 172*e5ad0089SMagnus Damm .flags = IORESOURCE_IRQ, 173*e5ad0089SMagnus Damm }, 174*e5ad0089SMagnus Damm }; 175*e5ad0089SMagnus Damm 176*e5ad0089SMagnus Damm static struct platform_device tmu1_device = { 177*e5ad0089SMagnus Damm .name = "sh_tmu", 178*e5ad0089SMagnus Damm .id = 1, 179*e5ad0089SMagnus Damm .dev = { 180*e5ad0089SMagnus Damm .platform_data = &tmu1_platform_data, 181*e5ad0089SMagnus Damm }, 182*e5ad0089SMagnus Damm .resource = tmu1_resources, 183*e5ad0089SMagnus Damm .num_resources = ARRAY_SIZE(tmu1_resources), 184*e5ad0089SMagnus Damm }; 185*e5ad0089SMagnus Damm 186*e5ad0089SMagnus Damm static struct sh_timer_config tmu2_platform_data = { 187*e5ad0089SMagnus Damm .name = "TMU2", 188*e5ad0089SMagnus Damm .channel_offset = 0x1a, 189*e5ad0089SMagnus Damm .timer_bit = 2, 190*e5ad0089SMagnus Damm .clk = "module_clk", 191*e5ad0089SMagnus Damm }; 192*e5ad0089SMagnus Damm 193*e5ad0089SMagnus Damm static struct resource tmu2_resources[] = { 194*e5ad0089SMagnus Damm [0] = { 195*e5ad0089SMagnus Damm .name = "TMU2", 196*e5ad0089SMagnus Damm .start = 0xa412feac, 197*e5ad0089SMagnus Damm .end = 0xa412feb5, 198*e5ad0089SMagnus Damm .flags = IORESOURCE_MEM, 199*e5ad0089SMagnus Damm }, 200*e5ad0089SMagnus Damm [1] = { 201*e5ad0089SMagnus Damm .start = 18, 202*e5ad0089SMagnus Damm .flags = IORESOURCE_IRQ, 203*e5ad0089SMagnus Damm }, 204*e5ad0089SMagnus Damm }; 205*e5ad0089SMagnus Damm 206*e5ad0089SMagnus Damm static struct platform_device tmu2_device = { 207*e5ad0089SMagnus Damm .name = "sh_tmu", 208*e5ad0089SMagnus Damm .id = 2, 209*e5ad0089SMagnus Damm .dev = { 210*e5ad0089SMagnus Damm .platform_data = &tmu2_platform_data, 211*e5ad0089SMagnus Damm }, 212*e5ad0089SMagnus Damm .resource = tmu2_resources, 213*e5ad0089SMagnus Damm .num_resources = ARRAY_SIZE(tmu2_resources), 214*e5ad0089SMagnus Damm }; 215*e5ad0089SMagnus Damm 216e5723e0eSPaul Mundt static struct platform_device *sh7710_devices[] __initdata = { 217*e5ad0089SMagnus Damm &tmu0_device, 218*e5ad0089SMagnus Damm &tmu1_device, 219*e5ad0089SMagnus Damm &tmu2_device, 220e5723e0eSPaul Mundt &sci_device, 22128b146c8SMagnus Damm &rtc_device, 222e5723e0eSPaul Mundt }; 223e5723e0eSPaul Mundt 224e5723e0eSPaul Mundt static int __init sh7710_devices_setup(void) 225e5723e0eSPaul Mundt { 226e5723e0eSPaul Mundt return platform_add_devices(sh7710_devices, 227e5723e0eSPaul Mundt ARRAY_SIZE(sh7710_devices)); 228e5723e0eSPaul Mundt } 229e5723e0eSPaul Mundt __initcall(sh7710_devices_setup); 2309465a54fSNobuhiro Iwamatsu 231*e5ad0089SMagnus Damm static struct platform_device *sh7710_early_devices[] __initdata = { 232*e5ad0089SMagnus Damm &tmu0_device, 233*e5ad0089SMagnus Damm &tmu1_device, 234*e5ad0089SMagnus Damm &tmu2_device, 235*e5ad0089SMagnus Damm }; 236*e5ad0089SMagnus Damm 237*e5ad0089SMagnus Damm void __init plat_early_device_setup(void) 238*e5ad0089SMagnus Damm { 239*e5ad0089SMagnus Damm early_platform_add_devices(sh7710_early_devices, 240*e5ad0089SMagnus Damm ARRAY_SIZE(sh7710_early_devices)); 241*e5ad0089SMagnus Damm } 242*e5ad0089SMagnus Damm 24390015c89SMagnus Damm void __init plat_irq_setup(void) 2449465a54fSNobuhiro Iwamatsu { 24528b146c8SMagnus Damm register_intc_controller(&intc_desc); 246a276e588SMagnus Damm plat_irq_setup_sh3(); 2479465a54fSNobuhiro Iwamatsu } 248