Path: blob/master/arch/sh/kernel/cpu/sh4a/setup-sh7780.c
17498 views
/*1* SH7780 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/io.h>13#include <linux/serial_sci.h>14#include <linux/sh_dma.h>15#include <linux/sh_timer.h>1617#include <cpu/dma-register.h>1819static struct plat_sci_port scif0_platform_data = {20.mapbase = 0xffe00000,21.flags = UPF_BOOT_AUTOCONF,22.scscr = SCSCR_RE | SCSCR_TE | SCSCR_REIE | SCSCR_CKE1,23.scbrr_algo_id = SCBRR_ALGO_1,24.type = PORT_SCIF,25.irqs = { 40, 40, 40, 40 },26};2728static struct platform_device scif0_device = {29.name = "sh-sci",30.id = 0,31.dev = {32.platform_data = &scif0_platform_data,33},34};3536static struct plat_sci_port scif1_platform_data = {37.mapbase = 0xffe10000,38.flags = UPF_BOOT_AUTOCONF,39.scscr = SCSCR_RE | SCSCR_TE | SCSCR_REIE | SCSCR_CKE1,40.scbrr_algo_id = SCBRR_ALGO_1,41.type = PORT_SCIF,42.irqs = { 76, 76, 76, 76 },43};4445static struct platform_device scif1_device = {46.name = "sh-sci",47.id = 1,48.dev = {49.platform_data = &scif1_platform_data,50},51};5253static struct sh_timer_config tmu0_platform_data = {54.channel_offset = 0x04,55.timer_bit = 0,56.clockevent_rating = 200,57};5859static struct resource tmu0_resources[] = {60[0] = {61.start = 0xffd80008,62.end = 0xffd80013,63.flags = IORESOURCE_MEM,64},65[1] = {66.start = 28,67.flags = IORESOURCE_IRQ,68},69};7071static struct platform_device tmu0_device = {72.name = "sh_tmu",73.id = 0,74.dev = {75.platform_data = &tmu0_platform_data,76},77.resource = tmu0_resources,78.num_resources = ARRAY_SIZE(tmu0_resources),79};8081static struct sh_timer_config tmu1_platform_data = {82.channel_offset = 0x10,83.timer_bit = 1,84.clocksource_rating = 200,85};8687static struct resource tmu1_resources[] = {88[0] = {89.start = 0xffd80014,90.end = 0xffd8001f,91.flags = IORESOURCE_MEM,92},93[1] = {94.start = 29,95.flags = IORESOURCE_IRQ,96},97};9899static struct platform_device tmu1_device = {100.name = "sh_tmu",101.id = 1,102.dev = {103.platform_data = &tmu1_platform_data,104},105.resource = tmu1_resources,106.num_resources = ARRAY_SIZE(tmu1_resources),107};108109static struct sh_timer_config tmu2_platform_data = {110.channel_offset = 0x1c,111.timer_bit = 2,112};113114static struct resource tmu2_resources[] = {115[0] = {116.start = 0xffd80020,117.end = 0xffd8002f,118.flags = IORESOURCE_MEM,119},120[1] = {121.start = 30,122.flags = IORESOURCE_IRQ,123},124};125126static struct platform_device tmu2_device = {127.name = "sh_tmu",128.id = 2,129.dev = {130.platform_data = &tmu2_platform_data,131},132.resource = tmu2_resources,133.num_resources = ARRAY_SIZE(tmu2_resources),134};135136static struct sh_timer_config tmu3_platform_data = {137.channel_offset = 0x04,138.timer_bit = 0,139};140141static struct resource tmu3_resources[] = {142[0] = {143.start = 0xffdc0008,144.end = 0xffdc0013,145.flags = IORESOURCE_MEM,146},147[1] = {148.start = 96,149.flags = IORESOURCE_IRQ,150},151};152153static struct platform_device tmu3_device = {154.name = "sh_tmu",155.id = 3,156.dev = {157.platform_data = &tmu3_platform_data,158},159.resource = tmu3_resources,160.num_resources = ARRAY_SIZE(tmu3_resources),161};162163static struct sh_timer_config tmu4_platform_data = {164.channel_offset = 0x10,165.timer_bit = 1,166};167168static struct resource tmu4_resources[] = {169[0] = {170.start = 0xffdc0014,171.end = 0xffdc001f,172.flags = IORESOURCE_MEM,173},174[1] = {175.start = 97,176.flags = IORESOURCE_IRQ,177},178};179180static struct platform_device tmu4_device = {181.name = "sh_tmu",182.id = 4,183.dev = {184.platform_data = &tmu4_platform_data,185},186.resource = tmu4_resources,187.num_resources = ARRAY_SIZE(tmu4_resources),188};189190static struct sh_timer_config tmu5_platform_data = {191.channel_offset = 0x1c,192.timer_bit = 2,193};194195static struct resource tmu5_resources[] = {196[0] = {197.start = 0xffdc0020,198.end = 0xffdc002b,199.flags = IORESOURCE_MEM,200},201[1] = {202.start = 98,203.flags = IORESOURCE_IRQ,204},205};206207static struct platform_device tmu5_device = {208.name = "sh_tmu",209.id = 5,210.dev = {211.platform_data = &tmu5_platform_data,212},213.resource = tmu5_resources,214.num_resources = ARRAY_SIZE(tmu5_resources),215};216217static struct resource rtc_resources[] = {218[0] = {219.start = 0xffe80000,220.end = 0xffe80000 + 0x58 - 1,221.flags = IORESOURCE_IO,222},223[1] = {224/* Shared Period/Carry/Alarm IRQ */225.start = 20,226.flags = IORESOURCE_IRQ,227},228};229230static struct platform_device rtc_device = {231.name = "sh-rtc",232.id = -1,233.num_resources = ARRAY_SIZE(rtc_resources),234.resource = rtc_resources,235};236237/* DMA */238static const struct sh_dmae_channel sh7780_dmae0_channels[] = {239{240.offset = 0,241.dmars = 0,242.dmars_bit = 0,243}, {244.offset = 0x10,245.dmars = 0,246.dmars_bit = 8,247}, {248.offset = 0x20,249.dmars = 4,250.dmars_bit = 0,251}, {252.offset = 0x30,253.dmars = 4,254.dmars_bit = 8,255}, {256.offset = 0x50,257.dmars = 8,258.dmars_bit = 0,259}, {260.offset = 0x60,261.dmars = 8,262.dmars_bit = 8,263}264};265266static const struct sh_dmae_channel sh7780_dmae1_channels[] = {267{268.offset = 0,269}, {270.offset = 0x10,271}, {272.offset = 0x20,273}, {274.offset = 0x30,275}, {276.offset = 0x50,277}, {278.offset = 0x60,279}280};281282static const unsigned int ts_shift[] = TS_SHIFT;283284static struct sh_dmae_pdata dma0_platform_data = {285.channel = sh7780_dmae0_channels,286.channel_num = ARRAY_SIZE(sh7780_dmae0_channels),287.ts_low_shift = CHCR_TS_LOW_SHIFT,288.ts_low_mask = CHCR_TS_LOW_MASK,289.ts_high_shift = CHCR_TS_HIGH_SHIFT,290.ts_high_mask = CHCR_TS_HIGH_MASK,291.ts_shift = ts_shift,292.ts_shift_num = ARRAY_SIZE(ts_shift),293.dmaor_init = DMAOR_INIT,294};295296static struct sh_dmae_pdata dma1_platform_data = {297.channel = sh7780_dmae1_channels,298.channel_num = ARRAY_SIZE(sh7780_dmae1_channels),299.ts_low_shift = CHCR_TS_LOW_SHIFT,300.ts_low_mask = CHCR_TS_LOW_MASK,301.ts_high_shift = CHCR_TS_HIGH_SHIFT,302.ts_high_mask = CHCR_TS_HIGH_MASK,303.ts_shift = ts_shift,304.ts_shift_num = ARRAY_SIZE(ts_shift),305.dmaor_init = DMAOR_INIT,306};307308static struct resource sh7780_dmae0_resources[] = {309[0] = {310/* Channel registers and DMAOR */311.start = 0xfc808020,312.end = 0xfc80808f,313.flags = IORESOURCE_MEM,314},315[1] = {316/* DMARSx */317.start = 0xfc809000,318.end = 0xfc80900b,319.flags = IORESOURCE_MEM,320},321{322/* Real DMA error IRQ is 38, and channel IRQs are 34-37, 44-45 */323.start = 34,324.end = 34,325.flags = IORESOURCE_IRQ | IORESOURCE_IRQ_SHAREABLE,326},327};328329static struct resource sh7780_dmae1_resources[] = {330[0] = {331/* Channel registers and DMAOR */332.start = 0xfc818020,333.end = 0xfc81808f,334.flags = IORESOURCE_MEM,335},336/* DMAC1 has no DMARS */337{338/* Real DMA error IRQ is 38, and channel IRQs are 46-47, 92-95 */339.start = 46,340.end = 46,341.flags = IORESOURCE_IRQ | IORESOURCE_IRQ_SHAREABLE,342},343};344345static struct platform_device dma0_device = {346.name = "sh-dma-engine",347.id = 0,348.resource = sh7780_dmae0_resources,349.num_resources = ARRAY_SIZE(sh7780_dmae0_resources),350.dev = {351.platform_data = &dma0_platform_data,352},353};354355static struct platform_device dma1_device = {356.name = "sh-dma-engine",357.id = 1,358.resource = sh7780_dmae1_resources,359.num_resources = ARRAY_SIZE(sh7780_dmae1_resources),360.dev = {361.platform_data = &dma1_platform_data,362},363};364365static struct platform_device *sh7780_devices[] __initdata = {366&scif0_device,367&scif1_device,368&tmu0_device,369&tmu1_device,370&tmu2_device,371&tmu3_device,372&tmu4_device,373&tmu5_device,374&rtc_device,375&dma0_device,376&dma1_device,377};378379static int __init sh7780_devices_setup(void)380{381return platform_add_devices(sh7780_devices,382ARRAY_SIZE(sh7780_devices));383}384arch_initcall(sh7780_devices_setup);385386static struct platform_device *sh7780_early_devices[] __initdata = {387&scif0_device,388&scif1_device,389&tmu0_device,390&tmu1_device,391&tmu2_device,392&tmu3_device,393&tmu4_device,394&tmu5_device,395};396397void __init plat_early_device_setup(void)398{399if (mach_is_sh2007()) {400scif0_platform_data.scscr &= ~SCSCR_CKE1;401scif0_platform_data.scbrr_algo_id = SCBRR_ALGO_2;402scif1_platform_data.scscr &= ~SCSCR_CKE1;403scif1_platform_data.scbrr_algo_id = SCBRR_ALGO_2;404}405406early_platform_add_devices(sh7780_early_devices,407ARRAY_SIZE(sh7780_early_devices));408}409410enum {411UNUSED = 0,412413/* interrupt sources */414415IRL_LLLL, IRL_LLLH, IRL_LLHL, IRL_LLHH,416IRL_LHLL, IRL_LHLH, IRL_LHHL, IRL_LHHH,417IRL_HLLL, IRL_HLLH, IRL_HLHL, IRL_HLHH,418IRL_HHLL, IRL_HHLH, IRL_HHHL,419420IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7,421RTC, WDT, TMU0, TMU1, TMU2, TMU2_TICPI,422HUDI, DMAC0, SCIF0, DMAC1, CMT, HAC,423PCISERR, PCIINTA, PCIINTB, PCIINTC, PCIINTD, PCIC5,424SCIF1, SIOF, HSPI, MMCIF, TMU3, TMU4, TMU5, SSI, FLCTL, GPIO,425426/* interrupt groups */427428TMU012, TMU345,429};430431static struct intc_vect vectors[] __initdata = {432INTC_VECT(RTC, 0x480), INTC_VECT(RTC, 0x4a0),433INTC_VECT(RTC, 0x4c0),434INTC_VECT(WDT, 0x560),435INTC_VECT(TMU0, 0x580), INTC_VECT(TMU1, 0x5a0),436INTC_VECT(TMU2, 0x5c0), INTC_VECT(TMU2_TICPI, 0x5e0),437INTC_VECT(HUDI, 0x600),438INTC_VECT(DMAC0, 0x640), INTC_VECT(DMAC0, 0x660),439INTC_VECT(DMAC0, 0x680), INTC_VECT(DMAC0, 0x6a0),440INTC_VECT(DMAC0, 0x6c0),441INTC_VECT(SCIF0, 0x700), INTC_VECT(SCIF0, 0x720),442INTC_VECT(SCIF0, 0x740), INTC_VECT(SCIF0, 0x760),443INTC_VECT(DMAC0, 0x780), INTC_VECT(DMAC0, 0x7a0),444INTC_VECT(DMAC1, 0x7c0), INTC_VECT(DMAC1, 0x7e0),445INTC_VECT(CMT, 0x900), INTC_VECT(HAC, 0x980),446INTC_VECT(PCISERR, 0xa00), INTC_VECT(PCIINTA, 0xa20),447INTC_VECT(PCIINTB, 0xa40), INTC_VECT(PCIINTC, 0xa60),448INTC_VECT(PCIINTD, 0xa80), INTC_VECT(PCIC5, 0xaa0),449INTC_VECT(PCIC5, 0xac0), INTC_VECT(PCIC5, 0xae0),450INTC_VECT(PCIC5, 0xb00), INTC_VECT(PCIC5, 0xb20),451INTC_VECT(SCIF1, 0xb80), INTC_VECT(SCIF1, 0xba0),452INTC_VECT(SCIF1, 0xbc0), INTC_VECT(SCIF1, 0xbe0),453INTC_VECT(SIOF, 0xc00), INTC_VECT(HSPI, 0xc80),454INTC_VECT(MMCIF, 0xd00), INTC_VECT(MMCIF, 0xd20),455INTC_VECT(MMCIF, 0xd40), INTC_VECT(MMCIF, 0xd60),456INTC_VECT(DMAC1, 0xd80), INTC_VECT(DMAC1, 0xda0),457INTC_VECT(DMAC1, 0xdc0), INTC_VECT(DMAC1, 0xde0),458INTC_VECT(TMU3, 0xe00), INTC_VECT(TMU4, 0xe20),459INTC_VECT(TMU5, 0xe40),460INTC_VECT(SSI, 0xe80),461INTC_VECT(FLCTL, 0xf00), INTC_VECT(FLCTL, 0xf20),462INTC_VECT(FLCTL, 0xf40), INTC_VECT(FLCTL, 0xf60),463INTC_VECT(GPIO, 0xf80), INTC_VECT(GPIO, 0xfa0),464INTC_VECT(GPIO, 0xfc0), INTC_VECT(GPIO, 0xfe0),465};466467static struct intc_group groups[] __initdata = {468INTC_GROUP(TMU012, TMU0, TMU1, TMU2, TMU2_TICPI),469INTC_GROUP(TMU345, TMU3, TMU4, TMU5),470};471472static struct intc_mask_reg mask_registers[] __initdata = {473{ 0xffd40038, 0xffd4003c, 32, /* INT2MSKR / INT2MSKCR */474{ 0, 0, 0, 0, 0, 0, GPIO, FLCTL,475SSI, MMCIF, HSPI, SIOF, PCIC5, PCIINTD, PCIINTC, PCIINTB,476PCIINTA, PCISERR, HAC, CMT, 0, 0, DMAC1, DMAC0,477HUDI, 0, WDT, SCIF1, SCIF0, RTC, TMU345, TMU012 } },478};479480static struct intc_prio_reg prio_registers[] __initdata = {481{ 0xffd40000, 0, 32, 8, /* INT2PRI0 */ { TMU0, TMU1,482TMU2, TMU2_TICPI } },483{ 0xffd40004, 0, 32, 8, /* INT2PRI1 */ { TMU3, TMU4, TMU5, RTC } },484{ 0xffd40008, 0, 32, 8, /* INT2PRI2 */ { SCIF0, SCIF1, WDT } },485{ 0xffd4000c, 0, 32, 8, /* INT2PRI3 */ { HUDI, DMAC0, DMAC1 } },486{ 0xffd40010, 0, 32, 8, /* INT2PRI4 */ { CMT, HAC,487PCISERR, PCIINTA, } },488{ 0xffd40014, 0, 32, 8, /* INT2PRI5 */ { PCIINTB, PCIINTC,489PCIINTD, PCIC5 } },490{ 0xffd40018, 0, 32, 8, /* INT2PRI6 */ { SIOF, HSPI, MMCIF, SSI } },491{ 0xffd4001c, 0, 32, 8, /* INT2PRI7 */ { FLCTL, GPIO } },492};493494static DECLARE_INTC_DESC(intc_desc, "sh7780", vectors, groups,495mask_registers, prio_registers, NULL);496497/* Support for external interrupt pins in IRQ mode */498499static struct intc_vect irq_vectors[] __initdata = {500INTC_VECT(IRQ0, 0x240), INTC_VECT(IRQ1, 0x280),501INTC_VECT(IRQ2, 0x2c0), INTC_VECT(IRQ3, 0x300),502INTC_VECT(IRQ4, 0x340), INTC_VECT(IRQ5, 0x380),503INTC_VECT(IRQ6, 0x3c0), INTC_VECT(IRQ7, 0x200),504};505506static struct intc_mask_reg irq_mask_registers[] __initdata = {507{ 0xffd00044, 0xffd00064, 32, /* INTMSK0 / INTMSKCLR0 */508{ IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7 } },509};510511static struct intc_prio_reg irq_prio_registers[] __initdata = {512{ 0xffd00010, 0, 32, 4, /* INTPRI */ { IRQ0, IRQ1, IRQ2, IRQ3,513IRQ4, IRQ5, IRQ6, IRQ7 } },514};515516static struct intc_sense_reg irq_sense_registers[] __initdata = {517{ 0xffd0001c, 32, 2, /* ICR1 */ { IRQ0, IRQ1, IRQ2, IRQ3,518IRQ4, IRQ5, IRQ6, IRQ7 } },519};520521static struct intc_mask_reg irq_ack_registers[] __initdata = {522{ 0xffd00024, 0, 32, /* INTREQ */523{ IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7 } },524};525526static DECLARE_INTC_DESC_ACK(intc_irq_desc, "sh7780-irq", irq_vectors,527NULL, irq_mask_registers, irq_prio_registers,528irq_sense_registers, irq_ack_registers);529530/* External interrupt pins in IRL mode */531532static struct intc_vect irl_vectors[] __initdata = {533INTC_VECT(IRL_LLLL, 0x200), INTC_VECT(IRL_LLLH, 0x220),534INTC_VECT(IRL_LLHL, 0x240), INTC_VECT(IRL_LLHH, 0x260),535INTC_VECT(IRL_LHLL, 0x280), INTC_VECT(IRL_LHLH, 0x2a0),536INTC_VECT(IRL_LHHL, 0x2c0), INTC_VECT(IRL_LHHH, 0x2e0),537INTC_VECT(IRL_HLLL, 0x300), INTC_VECT(IRL_HLLH, 0x320),538INTC_VECT(IRL_HLHL, 0x340), INTC_VECT(IRL_HLHH, 0x360),539INTC_VECT(IRL_HHLL, 0x380), INTC_VECT(IRL_HHLH, 0x3a0),540INTC_VECT(IRL_HHHL, 0x3c0),541};542543static struct intc_mask_reg irl3210_mask_registers[] __initdata = {544{ 0xffd40080, 0xffd40084, 32, /* INTMSK2 / INTMSKCLR2 */545{ IRL_LLLL, IRL_LLLH, IRL_LLHL, IRL_LLHH,546IRL_LHLL, IRL_LHLH, IRL_LHHL, IRL_LHHH,547IRL_HLLL, IRL_HLLH, IRL_HLHL, IRL_HLHH,548IRL_HHLL, IRL_HHLH, IRL_HHHL, } },549};550551static struct intc_mask_reg irl7654_mask_registers[] __initdata = {552{ 0xffd40080, 0xffd40084, 32, /* INTMSK2 / INTMSKCLR2 */553{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,554IRL_LLLL, IRL_LLLH, IRL_LLHL, IRL_LLHH,555IRL_LHLL, IRL_LHLH, IRL_LHHL, IRL_LHHH,556IRL_HLLL, IRL_HLLH, IRL_HLHL, IRL_HLHH,557IRL_HHLL, IRL_HHLH, IRL_HHHL, } },558};559560static DECLARE_INTC_DESC(intc_irl7654_desc, "sh7780-irl7654", irl_vectors,561NULL, irl7654_mask_registers, NULL, NULL);562563static DECLARE_INTC_DESC(intc_irl3210_desc, "sh7780-irl3210", irl_vectors,564NULL, irl3210_mask_registers, NULL, NULL);565566#define INTC_ICR0 0xffd00000567#define INTC_INTMSK0 0xffd00044568#define INTC_INTMSK1 0xffd00048569#define INTC_INTMSK2 0xffd40080570#define INTC_INTMSKCLR1 0xffd00068571#define INTC_INTMSKCLR2 0xffd40084572573void __init plat_irq_setup(void)574{575/* disable IRQ7-0 */576__raw_writel(0xff000000, INTC_INTMSK0);577578/* disable IRL3-0 + IRL7-4 */579__raw_writel(0xc0000000, INTC_INTMSK1);580__raw_writel(0xfffefffe, INTC_INTMSK2);581582/* select IRL mode for IRL3-0 + IRL7-4 */583__raw_writel(__raw_readl(INTC_ICR0) & ~0x00c00000, INTC_ICR0);584585/* disable holding function, ie enable "SH-4 Mode" */586__raw_writel(__raw_readl(INTC_ICR0) | 0x00200000, INTC_ICR0);587588register_intc_controller(&intc_desc);589}590591void __init plat_irq_setup_pins(int mode)592{593switch (mode) {594case IRQ_MODE_IRQ:595/* select IRQ mode for IRL3-0 + IRL7-4 */596__raw_writel(__raw_readl(INTC_ICR0) | 0x00c00000, INTC_ICR0);597register_intc_controller(&intc_irq_desc);598break;599case IRQ_MODE_IRL7654:600/* enable IRL7-4 but don't provide any masking */601__raw_writel(0x40000000, INTC_INTMSKCLR1);602__raw_writel(0x0000fffe, INTC_INTMSKCLR2);603break;604case IRQ_MODE_IRL3210:605/* enable IRL0-3 but don't provide any masking */606__raw_writel(0x80000000, INTC_INTMSKCLR1);607__raw_writel(0xfffe0000, INTC_INTMSKCLR2);608break;609case IRQ_MODE_IRL7654_MASK:610/* enable IRL7-4 and mask using cpu intc controller */611__raw_writel(0x40000000, INTC_INTMSKCLR1);612register_intc_controller(&intc_irl7654_desc);613break;614case IRQ_MODE_IRL3210_MASK:615/* enable IRL0-3 and mask using cpu intc controller */616__raw_writel(0x80000000, INTC_INTMSKCLR1);617register_intc_controller(&intc_irl3210_desc);618break;619default:620BUG();621}622}623624625