Path: blob/master/arch/sh/kernel/cpu/sh4/setup-sh7760.c
37217 views
/*1* SH7760 Setup2*3* Copyright (C) 2006 Paul Mundt4*5* This file is subject to the terms and conditions of the GNU General Public6* License. See the file "COPYING" in the main directory of this archive7* for more details.8*/9#include <linux/platform_device.h>10#include <linux/init.h>11#include <linux/serial.h>12#include <linux/sh_timer.h>13#include <linux/serial_sci.h>14#include <linux/io.h>1516enum {17UNUSED = 0,1819/* interrupt sources */20IRL0, IRL1, IRL2, IRL3,21HUDI, GPIOI, DMAC,22IRQ4, IRQ5, IRQ6, IRQ7,23HCAN20, HCAN21,24SSI0, SSI1,25HAC0, HAC1,26I2C0, I2C1,27USB, LCDC,28DMABRG0, DMABRG1, DMABRG2,29SCIF0_ERI, SCIF0_RXI, SCIF0_BRI, SCIF0_TXI,30SCIF1_ERI, SCIF1_RXI, SCIF1_BRI, SCIF1_TXI,31SCIF2_ERI, SCIF2_RXI, SCIF2_BRI, SCIF2_TXI,32SIM_ERI, SIM_RXI, SIM_TXI, SIM_TEI,33HSPI,34MMCIF0, MMCIF1, MMCIF2, MMCIF3,35MFI, ADC, CMT,36TMU0, TMU1, TMU2,37WDT, REF,3839/* interrupt groups */40DMABRG, SCIF0, SCIF1, SCIF2, SIM, MMCIF,41};4243static struct intc_vect vectors[] __initdata = {44INTC_VECT(HUDI, 0x600), INTC_VECT(GPIOI, 0x620),45INTC_VECT(DMAC, 0x640), INTC_VECT(DMAC, 0x660),46INTC_VECT(DMAC, 0x680), INTC_VECT(DMAC, 0x6a0),47INTC_VECT(DMAC, 0x780), INTC_VECT(DMAC, 0x7a0),48INTC_VECT(DMAC, 0x7c0), INTC_VECT(DMAC, 0x7e0),49INTC_VECT(DMAC, 0x6c0),50INTC_VECT(IRQ4, 0x800), INTC_VECT(IRQ5, 0x820),51INTC_VECT(IRQ6, 0x840), INTC_VECT(IRQ6, 0x860),52INTC_VECT(HCAN20, 0x900), INTC_VECT(HCAN21, 0x920),53INTC_VECT(SSI0, 0x940), INTC_VECT(SSI1, 0x960),54INTC_VECT(HAC0, 0x980), INTC_VECT(HAC1, 0x9a0),55INTC_VECT(I2C0, 0x9c0), INTC_VECT(I2C1, 0x9e0),56INTC_VECT(USB, 0xa00), INTC_VECT(LCDC, 0xa20),57INTC_VECT(DMABRG0, 0xa80), INTC_VECT(DMABRG1, 0xaa0),58INTC_VECT(DMABRG2, 0xac0),59INTC_VECT(SCIF0_ERI, 0x880), INTC_VECT(SCIF0_RXI, 0x8a0),60INTC_VECT(SCIF0_BRI, 0x8c0), INTC_VECT(SCIF0_TXI, 0x8e0),61INTC_VECT(SCIF1_ERI, 0xb00), INTC_VECT(SCIF1_RXI, 0xb20),62INTC_VECT(SCIF1_BRI, 0xb40), INTC_VECT(SCIF1_TXI, 0xb60),63INTC_VECT(SCIF2_ERI, 0xb80), INTC_VECT(SCIF2_RXI, 0xba0),64INTC_VECT(SCIF2_BRI, 0xbc0), INTC_VECT(SCIF2_TXI, 0xbe0),65INTC_VECT(SIM_ERI, 0xc00), INTC_VECT(SIM_RXI, 0xc20),66INTC_VECT(SIM_TXI, 0xc40), INTC_VECT(SIM_TEI, 0xc60),67INTC_VECT(HSPI, 0xc80),68INTC_VECT(MMCIF0, 0xd00), INTC_VECT(MMCIF1, 0xd20),69INTC_VECT(MMCIF2, 0xd40), INTC_VECT(MMCIF3, 0xd60),70INTC_VECT(MFI, 0xe80), /* 0xf80 according to data sheet */71INTC_VECT(ADC, 0xf80), INTC_VECT(CMT, 0xfa0),72INTC_VECT(TMU0, 0x400), INTC_VECT(TMU1, 0x420),73INTC_VECT(TMU2, 0x440), INTC_VECT(TMU2, 0x460),74INTC_VECT(WDT, 0x560),75INTC_VECT(REF, 0x580), INTC_VECT(REF, 0x5a0),76};7778static struct intc_group groups[] __initdata = {79INTC_GROUP(DMABRG, DMABRG0, DMABRG1, DMABRG2),80INTC_GROUP(SCIF0, SCIF0_ERI, SCIF0_RXI, SCIF0_BRI, SCIF0_TXI),81INTC_GROUP(SCIF1, SCIF1_ERI, SCIF1_RXI, SCIF1_BRI, SCIF1_TXI),82INTC_GROUP(SCIF2, SCIF2_ERI, SCIF2_RXI, SCIF2_BRI, SCIF2_TXI),83INTC_GROUP(SIM, SIM_ERI, SIM_RXI, SIM_TXI, SIM_TEI),84INTC_GROUP(MMCIF, MMCIF0, MMCIF1, MMCIF2, MMCIF3),85};8687static struct intc_mask_reg mask_registers[] __initdata = {88{ 0xfe080040, 0xfe080060, 32, /* INTMSK00 / INTMSKCLR00 */89{ IRQ4, IRQ5, IRQ6, IRQ7, 0, 0, HCAN20, HCAN21,90SSI0, SSI1, HAC0, HAC1, I2C0, I2C1, USB, LCDC,910, DMABRG0, DMABRG1, DMABRG2,92SCIF0_ERI, SCIF0_RXI, SCIF0_BRI, SCIF0_TXI,93SCIF1_ERI, SCIF1_RXI, SCIF1_BRI, SCIF1_TXI,94SCIF2_ERI, SCIF2_RXI, SCIF2_BRI, SCIF2_TXI, } },95{ 0xfe080044, 0xfe080064, 32, /* INTMSK04 / INTMSKCLR04 */96{ 0, 0, 0, 0, 0, 0, 0, 0,97SIM_ERI, SIM_RXI, SIM_TXI, SIM_TEI,98HSPI, MMCIF0, MMCIF1, MMCIF2,99MMCIF3, 0, 0, 0, 0, 0, 0, 0,1000, MFI, 0, 0, 0, 0, ADC, CMT, } },101};102103static struct intc_prio_reg prio_registers[] __initdata = {104{ 0xffd00004, 0, 16, 4, /* IPRA */ { TMU0, TMU1, TMU2 } },105{ 0xffd00008, 0, 16, 4, /* IPRB */ { WDT, REF, 0, 0 } },106{ 0xffd0000c, 0, 16, 4, /* IPRC */ { GPIOI, DMAC, 0, HUDI } },107{ 0xffd00010, 0, 16, 4, /* IPRD */ { IRL0, IRL1, IRL2, IRL3 } },108{ 0xfe080000, 0, 32, 4, /* INTPRI00 */ { IRQ4, IRQ5, IRQ6, IRQ7 } },109{ 0xfe080004, 0, 32, 4, /* INTPRI04 */ { HCAN20, HCAN21, SSI0, SSI1,110HAC0, HAC1, I2C0, I2C1 } },111{ 0xfe080008, 0, 32, 4, /* INTPRI08 */ { USB, LCDC, DMABRG, SCIF0,112SCIF1, SCIF2, SIM, HSPI } },113{ 0xfe08000c, 0, 32, 4, /* INTPRI0C */ { 0, 0, MMCIF, 0,114MFI, 0, ADC, CMT } },115};116117static DECLARE_INTC_DESC(intc_desc, "sh7760", vectors, groups,118mask_registers, prio_registers, NULL);119120static struct intc_vect vectors_irq[] __initdata = {121INTC_VECT(IRL0, 0x240), INTC_VECT(IRL1, 0x2a0),122INTC_VECT(IRL2, 0x300), INTC_VECT(IRL3, 0x360),123};124125static DECLARE_INTC_DESC(intc_desc_irq, "sh7760-irq", vectors_irq, groups,126mask_registers, prio_registers, NULL);127128static struct plat_sci_port scif0_platform_data = {129.mapbase = 0xfe600000,130.flags = UPF_BOOT_AUTOCONF,131.scscr = SCSCR_RE | SCSCR_TE | SCSCR_REIE,132.scbrr_algo_id = SCBRR_ALGO_2,133.type = PORT_SCIF,134.irqs = { 52, 53, 55, 54 },135};136137static struct platform_device scif0_device = {138.name = "sh-sci",139.id = 0,140.dev = {141.platform_data = &scif0_platform_data,142},143};144145static struct plat_sci_port scif1_platform_data = {146.mapbase = 0xfe610000,147.flags = UPF_BOOT_AUTOCONF,148.type = PORT_SCIF,149.scscr = SCSCR_RE | SCSCR_TE | SCSCR_REIE,150.scbrr_algo_id = SCBRR_ALGO_2,151.irqs = { 72, 73, 75, 74 },152};153154static struct platform_device scif1_device = {155.name = "sh-sci",156.id = 1,157.dev = {158.platform_data = &scif1_platform_data,159},160};161162static struct plat_sci_port scif2_platform_data = {163.mapbase = 0xfe620000,164.flags = UPF_BOOT_AUTOCONF,165.scscr = SCSCR_RE | SCSCR_TE | SCSCR_REIE,166.scbrr_algo_id = SCBRR_ALGO_2,167.type = PORT_SCIF,168.irqs = { 76, 77, 79, 78 },169};170171static struct platform_device scif2_device = {172.name = "sh-sci",173.id = 2,174.dev = {175.platform_data = &scif2_platform_data,176},177};178179static struct plat_sci_port scif3_platform_data = {180.mapbase = 0xfe480000,181.flags = UPF_BOOT_AUTOCONF,182.scscr = SCSCR_RE | SCSCR_TE | SCSCR_REIE,183.scbrr_algo_id = SCBRR_ALGO_2,184.type = PORT_SCI,185.irqs = { 80, 81, 82, 0 },186};187188static struct platform_device scif3_device = {189.name = "sh-sci",190.id = 3,191.dev = {192.platform_data = &scif3_platform_data,193},194};195196static struct sh_timer_config tmu0_platform_data = {197.channel_offset = 0x04,198.timer_bit = 0,199.clockevent_rating = 200,200};201202static struct resource tmu0_resources[] = {203[0] = {204.start = 0xffd80008,205.end = 0xffd80013,206.flags = IORESOURCE_MEM,207},208[1] = {209.start = 16,210.flags = IORESOURCE_IRQ,211},212};213214static struct platform_device tmu0_device = {215.name = "sh_tmu",216.id = 0,217.dev = {218.platform_data = &tmu0_platform_data,219},220.resource = tmu0_resources,221.num_resources = ARRAY_SIZE(tmu0_resources),222};223224static struct sh_timer_config tmu1_platform_data = {225.channel_offset = 0x10,226.timer_bit = 1,227.clocksource_rating = 200,228};229230static struct resource tmu1_resources[] = {231[0] = {232.start = 0xffd80014,233.end = 0xffd8001f,234.flags = IORESOURCE_MEM,235},236[1] = {237.start = 17,238.flags = IORESOURCE_IRQ,239},240};241242static struct platform_device tmu1_device = {243.name = "sh_tmu",244.id = 1,245.dev = {246.platform_data = &tmu1_platform_data,247},248.resource = tmu1_resources,249.num_resources = ARRAY_SIZE(tmu1_resources),250};251252static struct sh_timer_config tmu2_platform_data = {253.channel_offset = 0x1c,254.timer_bit = 2,255};256257static struct resource tmu2_resources[] = {258[0] = {259.start = 0xffd80020,260.end = 0xffd8002f,261.flags = IORESOURCE_MEM,262},263[1] = {264.start = 18,265.flags = IORESOURCE_IRQ,266},267};268269static struct platform_device tmu2_device = {270.name = "sh_tmu",271.id = 2,272.dev = {273.platform_data = &tmu2_platform_data,274},275.resource = tmu2_resources,276.num_resources = ARRAY_SIZE(tmu2_resources),277};278279280static struct platform_device *sh7760_devices[] __initdata = {281&scif0_device,282&scif1_device,283&scif2_device,284&scif3_device,285&tmu0_device,286&tmu1_device,287&tmu2_device,288};289290static int __init sh7760_devices_setup(void)291{292return platform_add_devices(sh7760_devices,293ARRAY_SIZE(sh7760_devices));294}295arch_initcall(sh7760_devices_setup);296297static struct platform_device *sh7760_early_devices[] __initdata = {298&scif0_device,299&scif1_device,300&scif2_device,301&scif3_device,302&tmu0_device,303&tmu1_device,304&tmu2_device,305};306307void __init plat_early_device_setup(void)308{309early_platform_add_devices(sh7760_early_devices,310ARRAY_SIZE(sh7760_early_devices));311}312313#define INTC_ICR 0xffd00000UL314#define INTC_ICR_IRLM (1 << 7)315316void __init plat_irq_setup_pins(int mode)317{318switch (mode) {319case IRQ_MODE_IRQ:320__raw_writew(__raw_readw(INTC_ICR) | INTC_ICR_IRLM, INTC_ICR);321register_intc_controller(&intc_desc_irq);322break;323default:324BUG();325}326}327328void __init plat_irq_setup(void)329{330register_intc_controller(&intc_desc);331}332333334