Path: blob/master/arch/sh/kernel/cpu/sh4a/setup-sh7763.c
17498 views
/*1* SH7763 Setup2*3* Copyright (C) 2006 Paul Mundt4* Copyright (C) 2007 Yoshihiro Shimoda5* Copyright (C) 2008, 2009 Nobuhiro Iwamatsu6*7* This file is subject to the terms and conditions of the GNU General Public8* License. See the file "COPYING" in the main directory of this archive9* for more details.10*/11#include <linux/platform_device.h>12#include <linux/init.h>13#include <linux/serial.h>14#include <linux/sh_timer.h>15#include <linux/io.h>16#include <linux/serial_sci.h>1718static struct plat_sci_port scif0_platform_data = {19.mapbase = 0xffe00000,20.flags = UPF_BOOT_AUTOCONF,21.scscr = SCSCR_RE | SCSCR_TE | SCSCR_REIE,22.scbrr_algo_id = SCBRR_ALGO_2,23.type = PORT_SCIF,24.irqs = { 40, 40, 40, 40 },25};2627static struct platform_device scif0_device = {28.name = "sh-sci",29.id = 0,30.dev = {31.platform_data = &scif0_platform_data,32},33};3435static struct plat_sci_port scif1_platform_data = {36.mapbase = 0xffe08000,37.flags = UPF_BOOT_AUTOCONF,38.scscr = SCSCR_RE | SCSCR_TE | SCSCR_REIE,39.scbrr_algo_id = SCBRR_ALGO_2,40.type = PORT_SCIF,41.irqs = { 76, 76, 76, 76 },42};4344static struct platform_device scif1_device = {45.name = "sh-sci",46.id = 1,47.dev = {48.platform_data = &scif1_platform_data,49},50};5152static struct plat_sci_port scif2_platform_data = {53.mapbase = 0xffe10000,54.flags = UPF_BOOT_AUTOCONF,55.scscr = SCSCR_RE | SCSCR_TE | SCSCR_REIE,56.scbrr_algo_id = SCBRR_ALGO_2,57.type = PORT_SCIF,58.irqs = { 104, 104, 104, 104 },59};6061static struct platform_device scif2_device = {62.name = "sh-sci",63.id = 2,64.dev = {65.platform_data = &scif2_platform_data,66},67};6869static struct resource rtc_resources[] = {70[0] = {71.start = 0xffe80000,72.end = 0xffe80000 + 0x58 - 1,73.flags = IORESOURCE_IO,74},75[1] = {76/* Shared Period/Carry/Alarm IRQ */77.start = 20,78.flags = IORESOURCE_IRQ,79},80};8182static struct platform_device rtc_device = {83.name = "sh-rtc",84.id = -1,85.num_resources = ARRAY_SIZE(rtc_resources),86.resource = rtc_resources,87};8889static struct resource usb_ohci_resources[] = {90[0] = {91.start = 0xffec8000,92.end = 0xffec80ff,93.flags = IORESOURCE_MEM,94},95[1] = {96.start = 83,97.end = 83,98.flags = IORESOURCE_IRQ,99},100};101102static u64 usb_ohci_dma_mask = 0xffffffffUL;103static struct platform_device usb_ohci_device = {104.name = "sh_ohci",105.id = -1,106.dev = {107.dma_mask = &usb_ohci_dma_mask,108.coherent_dma_mask = 0xffffffff,109},110.num_resources = ARRAY_SIZE(usb_ohci_resources),111.resource = usb_ohci_resources,112};113114static struct resource usbf_resources[] = {115[0] = {116.start = 0xffec0000,117.end = 0xffec00ff,118.flags = IORESOURCE_MEM,119},120[1] = {121.start = 84,122.end = 84,123.flags = IORESOURCE_IRQ,124},125};126127static struct platform_device usbf_device = {128.name = "sh_udc",129.id = -1,130.dev = {131.dma_mask = NULL,132.coherent_dma_mask = 0xffffffff,133},134.num_resources = ARRAY_SIZE(usbf_resources),135.resource = usbf_resources,136};137138static struct sh_timer_config tmu0_platform_data = {139.channel_offset = 0x04,140.timer_bit = 0,141.clockevent_rating = 200,142};143144static struct resource tmu0_resources[] = {145[0] = {146.start = 0xffd80008,147.end = 0xffd80013,148.flags = IORESOURCE_MEM,149},150[1] = {151.start = 28,152.flags = IORESOURCE_IRQ,153},154};155156static struct platform_device tmu0_device = {157.name = "sh_tmu",158.id = 0,159.dev = {160.platform_data = &tmu0_platform_data,161},162.resource = tmu0_resources,163.num_resources = ARRAY_SIZE(tmu0_resources),164};165166static struct sh_timer_config tmu1_platform_data = {167.channel_offset = 0x10,168.timer_bit = 1,169.clocksource_rating = 200,170};171172static struct resource tmu1_resources[] = {173[0] = {174.start = 0xffd80014,175.end = 0xffd8001f,176.flags = IORESOURCE_MEM,177},178[1] = {179.start = 29,180.flags = IORESOURCE_IRQ,181},182};183184static struct platform_device tmu1_device = {185.name = "sh_tmu",186.id = 1,187.dev = {188.platform_data = &tmu1_platform_data,189},190.resource = tmu1_resources,191.num_resources = ARRAY_SIZE(tmu1_resources),192};193194static struct sh_timer_config tmu2_platform_data = {195.channel_offset = 0x1c,196.timer_bit = 2,197};198199static struct resource tmu2_resources[] = {200[0] = {201.start = 0xffd80020,202.end = 0xffd8002f,203.flags = IORESOURCE_MEM,204},205[1] = {206.start = 30,207.flags = IORESOURCE_IRQ,208},209};210211static struct platform_device tmu2_device = {212.name = "sh_tmu",213.id = 2,214.dev = {215.platform_data = &tmu2_platform_data,216},217.resource = tmu2_resources,218.num_resources = ARRAY_SIZE(tmu2_resources),219};220221static struct sh_timer_config tmu3_platform_data = {222.channel_offset = 0x04,223.timer_bit = 0,224};225226static struct resource tmu3_resources[] = {227[0] = {228.start = 0xffd88008,229.end = 0xffd88013,230.flags = IORESOURCE_MEM,231},232[1] = {233.start = 96,234.flags = IORESOURCE_IRQ,235},236};237238static struct platform_device tmu3_device = {239.name = "sh_tmu",240.id = 3,241.dev = {242.platform_data = &tmu3_platform_data,243},244.resource = tmu3_resources,245.num_resources = ARRAY_SIZE(tmu3_resources),246};247248static struct sh_timer_config tmu4_platform_data = {249.channel_offset = 0x10,250.timer_bit = 1,251};252253static struct resource tmu4_resources[] = {254[0] = {255.start = 0xffd88014,256.end = 0xffd8801f,257.flags = IORESOURCE_MEM,258},259[1] = {260.start = 97,261.flags = IORESOURCE_IRQ,262},263};264265static struct platform_device tmu4_device = {266.name = "sh_tmu",267.id = 4,268.dev = {269.platform_data = &tmu4_platform_data,270},271.resource = tmu4_resources,272.num_resources = ARRAY_SIZE(tmu4_resources),273};274275static struct sh_timer_config tmu5_platform_data = {276.channel_offset = 0x1c,277.timer_bit = 2,278};279280static struct resource tmu5_resources[] = {281[0] = {282.start = 0xffd88020,283.end = 0xffd8802b,284.flags = IORESOURCE_MEM,285},286[1] = {287.start = 98,288.flags = IORESOURCE_IRQ,289},290};291292static struct platform_device tmu5_device = {293.name = "sh_tmu",294.id = 5,295.dev = {296.platform_data = &tmu5_platform_data,297},298.resource = tmu5_resources,299.num_resources = ARRAY_SIZE(tmu5_resources),300};301302static struct platform_device *sh7763_devices[] __initdata = {303&scif0_device,304&scif1_device,305&scif2_device,306&tmu0_device,307&tmu1_device,308&tmu2_device,309&tmu3_device,310&tmu4_device,311&tmu5_device,312&rtc_device,313&usb_ohci_device,314&usbf_device,315};316317static int __init sh7763_devices_setup(void)318{319return platform_add_devices(sh7763_devices,320ARRAY_SIZE(sh7763_devices));321}322arch_initcall(sh7763_devices_setup);323324static struct platform_device *sh7763_early_devices[] __initdata = {325&scif0_device,326&scif1_device,327&scif2_device,328&tmu0_device,329&tmu1_device,330&tmu2_device,331&tmu3_device,332&tmu4_device,333&tmu5_device,334};335336void __init plat_early_device_setup(void)337{338early_platform_add_devices(sh7763_early_devices,339ARRAY_SIZE(sh7763_early_devices));340}341342enum {343UNUSED = 0,344345/* interrupt sources */346347IRL_LLLL, IRL_LLLH, IRL_LLHL, IRL_LLHH,348IRL_LHLL, IRL_LHLH, IRL_LHHL, IRL_LHHH,349IRL_HLLL, IRL_HLLH, IRL_HLHL, IRL_HLHH,350IRL_HHLL, IRL_HHLH, IRL_HHHL,351352IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7,353RTC, WDT, TMU0, TMU1, TMU2, TMU2_TICPI,354HUDI, LCDC, DMAC, SCIF0, IIC0, IIC1, CMT, GETHER, HAC,355PCISERR, PCIINTA, PCIINTB, PCIINTC, PCIINTD, PCIC5,356STIF0, STIF1, SCIF1, SIOF0, SIOF1, SIOF2,357USBH, USBF, TPU, PCC, MMCIF, SIM,358TMU3, TMU4, TMU5, ADC, SSI0, SSI1, SSI2, SSI3,359SCIF2, GPIO,360361/* interrupt groups */362363TMU012, TMU345,364};365366static struct intc_vect vectors[] __initdata = {367INTC_VECT(RTC, 0x480), INTC_VECT(RTC, 0x4a0),368INTC_VECT(RTC, 0x4c0),369INTC_VECT(WDT, 0x560), INTC_VECT(TMU0, 0x580),370INTC_VECT(TMU1, 0x5a0), INTC_VECT(TMU2, 0x5c0),371INTC_VECT(TMU2_TICPI, 0x5e0), INTC_VECT(HUDI, 0x600),372INTC_VECT(LCDC, 0x620),373INTC_VECT(DMAC, 0x640), INTC_VECT(DMAC, 0x660),374INTC_VECT(DMAC, 0x680), INTC_VECT(DMAC, 0x6a0),375INTC_VECT(DMAC, 0x6c0),376INTC_VECT(SCIF0, 0x700), INTC_VECT(SCIF0, 0x720),377INTC_VECT(SCIF0, 0x740), INTC_VECT(SCIF0, 0x760),378INTC_VECT(DMAC, 0x780), INTC_VECT(DMAC, 0x7a0),379INTC_VECT(IIC0, 0x8A0), INTC_VECT(IIC1, 0x8C0),380INTC_VECT(CMT, 0x900), INTC_VECT(GETHER, 0x920),381INTC_VECT(GETHER, 0x940), INTC_VECT(GETHER, 0x960),382INTC_VECT(HAC, 0x980),383INTC_VECT(PCISERR, 0xa00), INTC_VECT(PCIINTA, 0xa20),384INTC_VECT(PCIINTB, 0xa40), INTC_VECT(PCIINTC, 0xa60),385INTC_VECT(PCIINTD, 0xa80), INTC_VECT(PCIC5, 0xaa0),386INTC_VECT(PCIC5, 0xac0), INTC_VECT(PCIC5, 0xae0),387INTC_VECT(PCIC5, 0xb00), INTC_VECT(PCIC5, 0xb20),388INTC_VECT(STIF0, 0xb40), INTC_VECT(STIF1, 0xb60),389INTC_VECT(SCIF1, 0xb80), INTC_VECT(SCIF1, 0xba0),390INTC_VECT(SCIF1, 0xbc0), INTC_VECT(SCIF1, 0xbe0),391INTC_VECT(SIOF0, 0xc00), INTC_VECT(SIOF1, 0xc20),392INTC_VECT(USBH, 0xc60), INTC_VECT(USBF, 0xc80),393INTC_VECT(USBF, 0xca0),394INTC_VECT(TPU, 0xcc0), INTC_VECT(PCC, 0xce0),395INTC_VECT(MMCIF, 0xd00), INTC_VECT(MMCIF, 0xd20),396INTC_VECT(MMCIF, 0xd40), INTC_VECT(MMCIF, 0xd60),397INTC_VECT(SIM, 0xd80), INTC_VECT(SIM, 0xda0),398INTC_VECT(SIM, 0xdc0), INTC_VECT(SIM, 0xde0),399INTC_VECT(TMU3, 0xe00), INTC_VECT(TMU4, 0xe20),400INTC_VECT(TMU5, 0xe40), INTC_VECT(ADC, 0xe60),401INTC_VECT(SSI0, 0xe80), INTC_VECT(SSI1, 0xea0),402INTC_VECT(SSI2, 0xec0), INTC_VECT(SSI3, 0xee0),403INTC_VECT(SCIF2, 0xf00), INTC_VECT(SCIF2, 0xf20),404INTC_VECT(SCIF2, 0xf40), INTC_VECT(SCIF2, 0xf60),405INTC_VECT(GPIO, 0xf80), INTC_VECT(GPIO, 0xfa0),406INTC_VECT(GPIO, 0xfc0), INTC_VECT(GPIO, 0xfe0),407};408409static struct intc_group groups[] __initdata = {410INTC_GROUP(TMU012, TMU0, TMU1, TMU2, TMU2_TICPI),411INTC_GROUP(TMU345, TMU3, TMU4, TMU5),412};413414static struct intc_mask_reg mask_registers[] __initdata = {415{ 0xffd40038, 0xffd4003c, 32, /* INT2MSKR / INT2MSKCR */416{ 0, 0, 0, 0, 0, 0, GPIO, 0,417SSI0, MMCIF, 0, SIOF0, PCIC5, PCIINTD, PCIINTC, PCIINTB,418PCIINTA, PCISERR, HAC, CMT, 0, 0, 0, DMAC,419HUDI, 0, WDT, SCIF1, SCIF0, RTC, TMU345, TMU012 } },420{ 0xffd400d0, 0xffd400d4, 32, /* INT2MSKR1 / INT2MSKCR1 */421{ 0, 0, 0, 0, 0, 0, SCIF2, USBF,4220, 0, STIF1, STIF0, 0, 0, USBH, GETHER,423PCC, 0, 0, ADC, TPU, SIM, SIOF2, SIOF1,424LCDC, 0, IIC1, IIC0, SSI3, SSI2, SSI1, 0 } },425};426427static struct intc_prio_reg prio_registers[] __initdata = {428{ 0xffd40000, 0, 32, 8, /* INT2PRI0 */ { TMU0, TMU1,429TMU2, TMU2_TICPI } },430{ 0xffd40004, 0, 32, 8, /* INT2PRI1 */ { TMU3, TMU4, TMU5, RTC } },431{ 0xffd40008, 0, 32, 8, /* INT2PRI2 */ { SCIF0, SCIF1, WDT } },432{ 0xffd4000c, 0, 32, 8, /* INT2PRI3 */ { HUDI, DMAC, ADC } },433{ 0xffd40010, 0, 32, 8, /* INT2PRI4 */ { CMT, HAC,434PCISERR, PCIINTA } },435{ 0xffd40014, 0, 32, 8, /* INT2PRI5 */ { PCIINTB, PCIINTC,436PCIINTD, PCIC5 } },437{ 0xffd40018, 0, 32, 8, /* INT2PRI6 */ { SIOF0, USBF, MMCIF, SSI0 } },438{ 0xffd4001c, 0, 32, 8, /* INT2PRI7 */ { SCIF2, GPIO } },439{ 0xffd400a0, 0, 32, 8, /* INT2PRI8 */ { SSI3, SSI2, SSI1, 0 } },440{ 0xffd400a4, 0, 32, 8, /* INT2PRI9 */ { LCDC, 0, IIC1, IIC0 } },441{ 0xffd400a8, 0, 32, 8, /* INT2PRI10 */ { TPU, SIM, SIOF2, SIOF1 } },442{ 0xffd400ac, 0, 32, 8, /* INT2PRI11 */ { PCC } },443{ 0xffd400b0, 0, 32, 8, /* INT2PRI12 */ { 0, 0, USBH, GETHER } },444{ 0xffd400b4, 0, 32, 8, /* INT2PRI13 */ { 0, 0, STIF1, STIF0 } },445};446447static DECLARE_INTC_DESC(intc_desc, "sh7763", vectors, groups,448mask_registers, prio_registers, NULL);449450/* Support for external interrupt pins in IRQ mode */451static struct intc_vect irq_vectors[] __initdata = {452INTC_VECT(IRQ0, 0x240), INTC_VECT(IRQ1, 0x280),453INTC_VECT(IRQ2, 0x2c0), INTC_VECT(IRQ3, 0x300),454INTC_VECT(IRQ4, 0x340), INTC_VECT(IRQ5, 0x380),455INTC_VECT(IRQ6, 0x3c0), INTC_VECT(IRQ7, 0x200),456};457458static struct intc_mask_reg irq_mask_registers[] __initdata = {459{ 0xffd00044, 0xffd00064, 32, /* INTMSK0 / INTMSKCLR0 */460{ IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7 } },461};462463static struct intc_prio_reg irq_prio_registers[] __initdata = {464{ 0xffd00010, 0, 32, 4, /* INTPRI */ { IRQ0, IRQ1, IRQ2, IRQ3,465IRQ4, IRQ5, IRQ6, IRQ7 } },466};467468static struct intc_sense_reg irq_sense_registers[] __initdata = {469{ 0xffd0001c, 32, 2, /* ICR1 */ { IRQ0, IRQ1, IRQ2, IRQ3,470IRQ4, IRQ5, IRQ6, IRQ7 } },471};472473static struct intc_mask_reg irq_ack_registers[] __initdata = {474{ 0xffd00024, 0, 32, /* INTREQ */475{ IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7 } },476};477478static DECLARE_INTC_DESC_ACK(intc_irq_desc, "sh7763-irq", irq_vectors,479NULL, irq_mask_registers, irq_prio_registers,480irq_sense_registers, irq_ack_registers);481482483/* External interrupt pins in IRL mode */484static struct intc_vect irl_vectors[] __initdata = {485INTC_VECT(IRL_LLLL, 0x200), INTC_VECT(IRL_LLLH, 0x220),486INTC_VECT(IRL_LLHL, 0x240), INTC_VECT(IRL_LLHH, 0x260),487INTC_VECT(IRL_LHLL, 0x280), INTC_VECT(IRL_LHLH, 0x2a0),488INTC_VECT(IRL_LHHL, 0x2c0), INTC_VECT(IRL_LHHH, 0x2e0),489INTC_VECT(IRL_HLLL, 0x300), INTC_VECT(IRL_HLLH, 0x320),490INTC_VECT(IRL_HLHL, 0x340), INTC_VECT(IRL_HLHH, 0x360),491INTC_VECT(IRL_HHLL, 0x380), INTC_VECT(IRL_HHLH, 0x3a0),492INTC_VECT(IRL_HHHL, 0x3c0),493};494495static struct intc_mask_reg irl3210_mask_registers[] __initdata = {496{ 0xffd40080, 0xffd40084, 32, /* INTMSK2 / INTMSKCLR2 */497{ IRL_LLLL, IRL_LLLH, IRL_LLHL, IRL_LLHH,498IRL_LHLL, IRL_LHLH, IRL_LHHL, IRL_LHHH,499IRL_HLLL, IRL_HLLH, IRL_HLHL, IRL_HLHH,500IRL_HHLL, IRL_HHLH, IRL_HHHL, } },501};502503static struct intc_mask_reg irl7654_mask_registers[] __initdata = {504{ 0xffd40080, 0xffd40084, 32, /* INTMSK2 / INTMSKCLR2 */505{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,506IRL_LLLL, IRL_LLLH, IRL_LLHL, IRL_LLHH,507IRL_LHLL, IRL_LHLH, IRL_LHHL, IRL_LHHH,508IRL_HLLL, IRL_HLLH, IRL_HLHL, IRL_HLHH,509IRL_HHLL, IRL_HHLH, IRL_HHHL, } },510};511512static DECLARE_INTC_DESC(intc_irl7654_desc, "sh7763-irl7654", irl_vectors,513NULL, irl7654_mask_registers, NULL, NULL);514515static DECLARE_INTC_DESC(intc_irl3210_desc, "sh7763-irl3210", irl_vectors,516NULL, irl3210_mask_registers, NULL, NULL);517518#define INTC_ICR0 0xffd00000519#define INTC_INTMSK0 0xffd00044520#define INTC_INTMSK1 0xffd00048521#define INTC_INTMSK2 0xffd40080522#define INTC_INTMSKCLR1 0xffd00068523#define INTC_INTMSKCLR2 0xffd40084524525void __init plat_irq_setup(void)526{527/* disable IRQ7-0 */528__raw_writel(0xff000000, INTC_INTMSK0);529530/* disable IRL3-0 + IRL7-4 */531__raw_writel(0xc0000000, INTC_INTMSK1);532__raw_writel(0xfffefffe, INTC_INTMSK2);533534register_intc_controller(&intc_desc);535}536537void __init plat_irq_setup_pins(int mode)538{539switch (mode) {540case IRQ_MODE_IRQ:541/* select IRQ mode for IRL3-0 + IRL7-4 */542__raw_writel(__raw_readl(INTC_ICR0) | 0x00c00000, INTC_ICR0);543register_intc_controller(&intc_irq_desc);544break;545case IRQ_MODE_IRL7654:546/* enable IRL7-4 but don't provide any masking */547__raw_writel(0x40000000, INTC_INTMSKCLR1);548__raw_writel(0x0000fffe, INTC_INTMSKCLR2);549break;550case IRQ_MODE_IRL3210:551/* enable IRL0-3 but don't provide any masking */552__raw_writel(0x80000000, INTC_INTMSKCLR1);553__raw_writel(0xfffe0000, INTC_INTMSKCLR2);554break;555case IRQ_MODE_IRL7654_MASK:556/* enable IRL7-4 and mask using cpu intc controller */557__raw_writel(0x40000000, INTC_INTMSKCLR1);558register_intc_controller(&intc_irl7654_desc);559break;560case IRQ_MODE_IRL3210_MASK:561/* enable IRL0-3 and mask using cpu intc controller */562__raw_writel(0x80000000, INTC_INTMSKCLR1);563register_intc_controller(&intc_irl3210_desc);564break;565default:566BUG();567}568}569570571