Path: blob/master/arch/sh/kernel/cpu/sh4a/setup-shx3.c
17498 views
/*1* SH-X3 Prototype Setup2*3* Copyright (C) 2007 - 2010 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/serial_sci.h>13#include <linux/io.h>14#include <linux/gpio.h>15#include <linux/sh_timer.h>16#include <cpu/shx3.h>17#include <asm/mmzone.h>1819/*20* This intentionally only registers SCIF ports 0, 1, and 3. SCIF 221* INTEVT values overlap with the FPU EXPEVT ones, requiring special22* demuxing in the exception dispatch path.23*24* As this overlap is something that never should have made it in to25* silicon in the first place, we just refuse to deal with the port at26* all rather than adding infrastructure to hack around it.27*/28static struct plat_sci_port scif0_platform_data = {29.mapbase = 0xffc30000,30.flags = UPF_BOOT_AUTOCONF,31.scscr = SCSCR_RE | SCSCR_TE | SCSCR_REIE,32.scbrr_algo_id = SCBRR_ALGO_2,33.type = PORT_SCIF,34.irqs = { 40, 41, 43, 42 },35};3637static struct platform_device scif0_device = {38.name = "sh-sci",39.id = 0,40.dev = {41.platform_data = &scif0_platform_data,42},43};4445static struct plat_sci_port scif1_platform_data = {46.mapbase = 0xffc40000,47.flags = UPF_BOOT_AUTOCONF,48.scscr = SCSCR_RE | SCSCR_TE | SCSCR_REIE,49.scbrr_algo_id = SCBRR_ALGO_2,50.type = PORT_SCIF,51.irqs = { 44, 45, 47, 46 },52};5354static struct platform_device scif1_device = {55.name = "sh-sci",56.id = 1,57.dev = {58.platform_data = &scif1_platform_data,59},60};6162static struct plat_sci_port scif2_platform_data = {63.mapbase = 0xffc60000,64.flags = UPF_BOOT_AUTOCONF,65.scscr = SCSCR_RE | SCSCR_TE | SCSCR_REIE,66.scbrr_algo_id = SCBRR_ALGO_2,67.type = PORT_SCIF,68.irqs = { 52, 53, 55, 54 },69};7071static struct platform_device scif2_device = {72.name = "sh-sci",73.id = 2,74.dev = {75.platform_data = &scif2_platform_data,76},77};7879static struct sh_timer_config tmu0_platform_data = {80.channel_offset = 0x04,81.timer_bit = 0,82.clockevent_rating = 200,83};8485static struct resource tmu0_resources[] = {86[0] = {87.start = 0xffc10008,88.end = 0xffc10013,89.flags = IORESOURCE_MEM,90},91[1] = {92.start = 16,93.flags = IORESOURCE_IRQ,94},95};9697static struct platform_device tmu0_device = {98.name = "sh_tmu",99.id = 0,100.dev = {101.platform_data = &tmu0_platform_data,102},103.resource = tmu0_resources,104.num_resources = ARRAY_SIZE(tmu0_resources),105};106107static struct sh_timer_config tmu1_platform_data = {108.channel_offset = 0x10,109.timer_bit = 1,110.clocksource_rating = 200,111};112113static struct resource tmu1_resources[] = {114[0] = {115.start = 0xffc10014,116.end = 0xffc1001f,117.flags = IORESOURCE_MEM,118},119[1] = {120.start = 17,121.flags = IORESOURCE_IRQ,122},123};124125static struct platform_device tmu1_device = {126.name = "sh_tmu",127.id = 1,128.dev = {129.platform_data = &tmu1_platform_data,130},131.resource = tmu1_resources,132.num_resources = ARRAY_SIZE(tmu1_resources),133};134135static struct sh_timer_config tmu2_platform_data = {136.channel_offset = 0x1c,137.timer_bit = 2,138};139140static struct resource tmu2_resources[] = {141[0] = {142.start = 0xffc10020,143.end = 0xffc1002f,144.flags = IORESOURCE_MEM,145},146[1] = {147.start = 18,148.flags = IORESOURCE_IRQ,149},150};151152static struct platform_device tmu2_device = {153.name = "sh_tmu",154.id = 2,155.dev = {156.platform_data = &tmu2_platform_data,157},158.resource = tmu2_resources,159.num_resources = ARRAY_SIZE(tmu2_resources),160};161162static struct sh_timer_config tmu3_platform_data = {163.channel_offset = 0x04,164.timer_bit = 0,165};166167static struct resource tmu3_resources[] = {168[0] = {169.start = 0xffc20008,170.end = 0xffc20013,171.flags = IORESOURCE_MEM,172},173[1] = {174.start = 19,175.flags = IORESOURCE_IRQ,176},177};178179static struct platform_device tmu3_device = {180.name = "sh_tmu",181.id = 3,182.dev = {183.platform_data = &tmu3_platform_data,184},185.resource = tmu3_resources,186.num_resources = ARRAY_SIZE(tmu3_resources),187};188189static struct sh_timer_config tmu4_platform_data = {190.channel_offset = 0x10,191.timer_bit = 1,192};193194static struct resource tmu4_resources[] = {195[0] = {196.start = 0xffc20014,197.end = 0xffc2001f,198.flags = IORESOURCE_MEM,199},200[1] = {201.start = 20,202.flags = IORESOURCE_IRQ,203},204};205206static struct platform_device tmu4_device = {207.name = "sh_tmu",208.id = 4,209.dev = {210.platform_data = &tmu4_platform_data,211},212.resource = tmu4_resources,213.num_resources = ARRAY_SIZE(tmu4_resources),214};215216static struct sh_timer_config tmu5_platform_data = {217.channel_offset = 0x1c,218.timer_bit = 2,219};220221static struct resource tmu5_resources[] = {222[0] = {223.start = 0xffc20020,224.end = 0xffc2002b,225.flags = IORESOURCE_MEM,226},227[1] = {228.start = 21,229.flags = IORESOURCE_IRQ,230},231};232233static struct platform_device tmu5_device = {234.name = "sh_tmu",235.id = 5,236.dev = {237.platform_data = &tmu5_platform_data,238},239.resource = tmu5_resources,240.num_resources = ARRAY_SIZE(tmu5_resources),241};242243static struct platform_device *shx3_early_devices[] __initdata = {244&scif0_device,245&scif1_device,246&scif2_device,247&tmu0_device,248&tmu1_device,249&tmu2_device,250&tmu3_device,251&tmu4_device,252&tmu5_device,253};254255static int __init shx3_devices_setup(void)256{257return platform_add_devices(shx3_early_devices,258ARRAY_SIZE(shx3_early_devices));259}260arch_initcall(shx3_devices_setup);261262void __init plat_early_device_setup(void)263{264early_platform_add_devices(shx3_early_devices,265ARRAY_SIZE(shx3_early_devices));266}267268enum {269UNUSED = 0,270271/* interrupt sources */272IRL_LLLL, IRL_LLLH, IRL_LLHL, IRL_LLHH,273IRL_LHLL, IRL_LHLH, IRL_LHHL, IRL_LHHH,274IRL_HLLL, IRL_HLLH, IRL_HLHL, IRL_HLHH,275IRL_HHLL, IRL_HHLH, IRL_HHHL,276IRQ0, IRQ1, IRQ2, IRQ3,277HUDII,278TMU0, TMU1, TMU2, TMU3, TMU4, TMU5,279PCII0, PCII1, PCII2, PCII3, PCII4,280PCII5, PCII6, PCII7, PCII8, PCII9,281SCIF0_ERI, SCIF0_RXI, SCIF0_BRI, SCIF0_TXI,282SCIF1_ERI, SCIF1_RXI, SCIF1_BRI, SCIF1_TXI,283SCIF2_ERI, SCIF2_RXI, SCIF2_BRI, SCIF2_TXI,284SCIF3_ERI, SCIF3_RXI, SCIF3_BRI, SCIF3_TXI,285DMAC0_DMINT0, DMAC0_DMINT1, DMAC0_DMINT2, DMAC0_DMINT3,286DMAC0_DMINT4, DMAC0_DMINT5, DMAC0_DMAE,287DU,288DMAC1_DMINT6, DMAC1_DMINT7, DMAC1_DMINT8, DMAC1_DMINT9,289DMAC1_DMINT10, DMAC1_DMINT11, DMAC1_DMAE,290IIC, VIN0, VIN1, VCORE0, ATAPI,291DTU0, DTU1, DTU2, DTU3,292FE0, FE1,293GPIO0, GPIO1, GPIO2, GPIO3,294PAM, IRM,295INTICI0, INTICI1, INTICI2, INTICI3,296INTICI4, INTICI5, INTICI6, INTICI7,297298/* interrupt groups */299IRL, PCII56789, SCIF0, SCIF1, SCIF2, SCIF3,300DMAC0, DMAC1,301};302303static struct intc_vect vectors[] __initdata = {304INTC_VECT(HUDII, 0x3e0),305INTC_VECT(TMU0, 0x400), INTC_VECT(TMU1, 0x420),306INTC_VECT(TMU2, 0x440), INTC_VECT(TMU3, 0x460),307INTC_VECT(TMU4, 0x480), INTC_VECT(TMU5, 0x4a0),308INTC_VECT(PCII0, 0x500), INTC_VECT(PCII1, 0x520),309INTC_VECT(PCII2, 0x540), INTC_VECT(PCII3, 0x560),310INTC_VECT(PCII4, 0x580), INTC_VECT(PCII5, 0x5a0),311INTC_VECT(PCII6, 0x5c0), INTC_VECT(PCII7, 0x5e0),312INTC_VECT(PCII8, 0x600), INTC_VECT(PCII9, 0x620),313INTC_VECT(SCIF0_ERI, 0x700), INTC_VECT(SCIF0_RXI, 0x720),314INTC_VECT(SCIF0_BRI, 0x740), INTC_VECT(SCIF0_TXI, 0x760),315INTC_VECT(SCIF1_ERI, 0x780), INTC_VECT(SCIF1_RXI, 0x7a0),316INTC_VECT(SCIF1_BRI, 0x7c0), INTC_VECT(SCIF1_TXI, 0x7e0),317INTC_VECT(SCIF3_ERI, 0x880), INTC_VECT(SCIF3_RXI, 0x8a0),318INTC_VECT(SCIF3_BRI, 0x8c0), INTC_VECT(SCIF3_TXI, 0x8e0),319INTC_VECT(DMAC0_DMINT0, 0x900), INTC_VECT(DMAC0_DMINT1, 0x920),320INTC_VECT(DMAC0_DMINT2, 0x940), INTC_VECT(DMAC0_DMINT3, 0x960),321INTC_VECT(DMAC0_DMINT4, 0x980), INTC_VECT(DMAC0_DMINT5, 0x9a0),322INTC_VECT(DMAC0_DMAE, 0x9c0),323INTC_VECT(DU, 0x9e0),324INTC_VECT(DMAC1_DMINT6, 0xa00), INTC_VECT(DMAC1_DMINT7, 0xa20),325INTC_VECT(DMAC1_DMINT8, 0xa40), INTC_VECT(DMAC1_DMINT9, 0xa60),326INTC_VECT(DMAC1_DMINT10, 0xa80), INTC_VECT(DMAC1_DMINT11, 0xaa0),327INTC_VECT(DMAC1_DMAE, 0xac0),328INTC_VECT(IIC, 0xae0),329INTC_VECT(VIN0, 0xb00), INTC_VECT(VIN1, 0xb20),330INTC_VECT(VCORE0, 0xb00), INTC_VECT(ATAPI, 0xb60),331INTC_VECT(DTU0, 0xc00), INTC_VECT(DTU0, 0xc20),332INTC_VECT(DTU0, 0xc40),333INTC_VECT(DTU1, 0xc60), INTC_VECT(DTU1, 0xc80),334INTC_VECT(DTU1, 0xca0),335INTC_VECT(DTU2, 0xcc0), INTC_VECT(DTU2, 0xce0),336INTC_VECT(DTU2, 0xd00),337INTC_VECT(DTU3, 0xd20), INTC_VECT(DTU3, 0xd40),338INTC_VECT(DTU3, 0xd60),339INTC_VECT(FE0, 0xe00), INTC_VECT(FE1, 0xe20),340INTC_VECT(GPIO0, 0xe40), INTC_VECT(GPIO1, 0xe60),341INTC_VECT(GPIO2, 0xe80), INTC_VECT(GPIO3, 0xea0),342INTC_VECT(PAM, 0xec0), INTC_VECT(IRM, 0xee0),343INTC_VECT(INTICI0, 0xf00), INTC_VECT(INTICI1, 0xf20),344INTC_VECT(INTICI2, 0xf40), INTC_VECT(INTICI3, 0xf60),345INTC_VECT(INTICI4, 0xf80), INTC_VECT(INTICI5, 0xfa0),346INTC_VECT(INTICI6, 0xfc0), INTC_VECT(INTICI7, 0xfe0),347};348349static struct intc_group groups[] __initdata = {350INTC_GROUP(IRL, IRL_LLLL, IRL_LLLH, IRL_LLHL, IRL_LLHH,351IRL_LHLL, IRL_LHLH, IRL_LHHL, IRL_LHHH,352IRL_HLLL, IRL_HLLH, IRL_HLHL, IRL_HLHH,353IRL_HHLL, IRL_HHLH, IRL_HHHL),354INTC_GROUP(PCII56789, PCII5, PCII6, PCII7, PCII8, PCII9),355INTC_GROUP(SCIF0, SCIF0_ERI, SCIF0_RXI, SCIF0_BRI, SCIF0_TXI),356INTC_GROUP(SCIF1, SCIF1_ERI, SCIF1_RXI, SCIF1_BRI, SCIF1_TXI),357INTC_GROUP(SCIF3, SCIF3_ERI, SCIF3_RXI, SCIF3_BRI, SCIF3_TXI),358INTC_GROUP(DMAC0, DMAC0_DMINT0, DMAC0_DMINT1, DMAC0_DMINT2,359DMAC0_DMINT3, DMAC0_DMINT4, DMAC0_DMINT5, DMAC0_DMAE),360INTC_GROUP(DMAC1, DMAC1_DMINT6, DMAC1_DMINT7, DMAC1_DMINT8,361DMAC1_DMINT9, DMAC1_DMINT10, DMAC1_DMINT11),362};363364#define INT2DISTCR0 0xfe4108a0365#define INT2DISTCR1 0xfe4108a4366#define INT2DISTCR2 0xfe4108a8367368static struct intc_mask_reg mask_registers[] __initdata = {369{ 0xfe410030, 0xfe410050, 32, /* CnINTMSK0 / CnINTMSKCLR0 */370{ IRQ0, IRQ1, IRQ2, IRQ3 } },371{ 0xfe410040, 0xfe410060, 32, /* CnINTMSK1 / CnINTMSKCLR1 */372{ IRL } },373{ 0xfe410820, 0xfe410850, 32, /* CnINT2MSK0 / CnINT2MSKCLR0 */374{ FE1, FE0, 0, ATAPI, VCORE0, VIN1, VIN0, IIC,375DU, GPIO3, GPIO2, GPIO1, GPIO0, PAM, 0, 0,3760, 0, 0, 0, 0, 0, 0, 0, /* HUDI bits ignored */3770, TMU5, TMU4, TMU3, TMU2, TMU1, TMU0, 0, },378INTC_SMP_BALANCING(INT2DISTCR0) },379{ 0xfe410830, 0xfe410860, 32, /* CnINT2MSK1 / CnINT2MSKCLR1 */380{ 0, 0, 0, 0, DTU3, DTU2, DTU1, DTU0, /* IRM bits ignored */381PCII9, PCII8, PCII7, PCII6, PCII5, PCII4, PCII3, PCII2,382PCII1, PCII0, DMAC1_DMAE, DMAC1_DMINT11,383DMAC1_DMINT10, DMAC1_DMINT9, DMAC1_DMINT8, DMAC1_DMINT7,384DMAC1_DMINT6, DMAC0_DMAE, DMAC0_DMINT5, DMAC0_DMINT4,385DMAC0_DMINT3, DMAC0_DMINT2, DMAC0_DMINT1, DMAC0_DMINT0 },386INTC_SMP_BALANCING(INT2DISTCR1) },387{ 0xfe410840, 0xfe410870, 32, /* CnINT2MSK2 / CnINT2MSKCLR2 */388{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,389SCIF3_TXI, SCIF3_BRI, SCIF3_RXI, SCIF3_ERI,390SCIF2_TXI, SCIF2_BRI, SCIF2_RXI, SCIF2_ERI,391SCIF1_TXI, SCIF1_BRI, SCIF1_RXI, SCIF1_ERI,392SCIF0_TXI, SCIF0_BRI, SCIF0_RXI, SCIF0_ERI },393INTC_SMP_BALANCING(INT2DISTCR2) },394};395396static struct intc_prio_reg prio_registers[] __initdata = {397{ 0xfe410010, 0, 32, 4, /* INTPRI */ { IRQ0, IRQ1, IRQ2, IRQ3 } },398399{ 0xfe410800, 0, 32, 4, /* INT2PRI0 */ { 0, HUDII, TMU5, TMU4,400TMU3, TMU2, TMU1, TMU0 } },401{ 0xfe410804, 0, 32, 4, /* INT2PRI1 */ { DTU3, DTU2, DTU1, DTU0,402SCIF3, SCIF2,403SCIF1, SCIF0 } },404{ 0xfe410808, 0, 32, 4, /* INT2PRI2 */ { DMAC1, DMAC0,405PCII56789, PCII4,406PCII3, PCII2,407PCII1, PCII0 } },408{ 0xfe41080c, 0, 32, 4, /* INT2PRI3 */ { FE1, FE0, ATAPI, VCORE0,409VIN1, VIN0, IIC, DU} },410{ 0xfe410810, 0, 32, 4, /* INT2PRI4 */ { 0, 0, PAM, GPIO3,411GPIO2, GPIO1, GPIO0, IRM } },412{ 0xfe410090, 0xfe4100a0, 32, 4, /* CnICIPRI / CnICIPRICLR */413{ INTICI7, INTICI6, INTICI5, INTICI4,414INTICI3, INTICI2, INTICI1, INTICI0 }, INTC_SMP(4, 4) },415};416417static DECLARE_INTC_DESC(intc_desc, "shx3", vectors, groups,418mask_registers, prio_registers, NULL);419420/* Support for external interrupt pins in IRQ mode */421static struct intc_vect vectors_irq[] __initdata = {422INTC_VECT(IRQ0, 0x240), INTC_VECT(IRQ1, 0x280),423INTC_VECT(IRQ2, 0x2c0), INTC_VECT(IRQ3, 0x300),424};425426static struct intc_sense_reg sense_registers[] __initdata = {427{ 0xfe41001c, 32, 2, /* ICR1 */ { IRQ0, IRQ1, IRQ2, IRQ3 } },428};429430static DECLARE_INTC_DESC(intc_desc_irq, "shx3-irq", vectors_irq, groups,431mask_registers, prio_registers, sense_registers);432433/* External interrupt pins in IRL mode */434static struct intc_vect vectors_irl[] __initdata = {435INTC_VECT(IRL_LLLL, 0x200), INTC_VECT(IRL_LLLH, 0x220),436INTC_VECT(IRL_LLHL, 0x240), INTC_VECT(IRL_LLHH, 0x260),437INTC_VECT(IRL_LHLL, 0x280), INTC_VECT(IRL_LHLH, 0x2a0),438INTC_VECT(IRL_LHHL, 0x2c0), INTC_VECT(IRL_LHHH, 0x2e0),439INTC_VECT(IRL_HLLL, 0x300), INTC_VECT(IRL_HLLH, 0x320),440INTC_VECT(IRL_HLHL, 0x340), INTC_VECT(IRL_HLHH, 0x360),441INTC_VECT(IRL_HHLL, 0x380), INTC_VECT(IRL_HHLH, 0x3a0),442INTC_VECT(IRL_HHHL, 0x3c0),443};444445static DECLARE_INTC_DESC(intc_desc_irl, "shx3-irl", vectors_irl, groups,446mask_registers, prio_registers, NULL);447448void __init plat_irq_setup_pins(int mode)449{450int ret = 0;451452switch (mode) {453case IRQ_MODE_IRQ:454ret |= gpio_request(GPIO_FN_IRQ3, intc_desc_irq.name);455ret |= gpio_request(GPIO_FN_IRQ2, intc_desc_irq.name);456ret |= gpio_request(GPIO_FN_IRQ1, intc_desc_irq.name);457ret |= gpio_request(GPIO_FN_IRQ0, intc_desc_irq.name);458459if (unlikely(ret)) {460pr_err("Failed to set IRQ mode\n");461return;462}463464register_intc_controller(&intc_desc_irq);465break;466case IRQ_MODE_IRL3210:467ret |= gpio_request(GPIO_FN_IRL3, intc_desc_irl.name);468ret |= gpio_request(GPIO_FN_IRL2, intc_desc_irl.name);469ret |= gpio_request(GPIO_FN_IRL1, intc_desc_irl.name);470ret |= gpio_request(GPIO_FN_IRL0, intc_desc_irl.name);471472if (unlikely(ret)) {473pr_err("Failed to set IRL mode\n");474return;475}476477register_intc_controller(&intc_desc_irl);478break;479default:480BUG();481}482}483484void __init plat_irq_setup(void)485{486reserve_intc_vectors(vectors_irq, ARRAY_SIZE(vectors_irq));487reserve_intc_vectors(vectors_irl, ARRAY_SIZE(vectors_irl));488489register_intc_controller(&intc_desc);490}491492void __init plat_mem_setup(void)493{494unsigned int nid = 1;495496/* Register CPU#0 URAM space as Node 1 */497setup_bootmem_node(nid++, 0x145f0000, 0x14610000); /* CPU0 */498499#if 0500/* XXX: Not yet.. */501setup_bootmem_node(nid++, 0x14df0000, 0x14e10000); /* CPU1 */502setup_bootmem_node(nid++, 0x155f0000, 0x15610000); /* CPU2 */503setup_bootmem_node(nid++, 0x15df0000, 0x15e10000); /* CPU3 */504#endif505506setup_bootmem_node(nid++, 0x16000000, 0x16020000); /* CSM */507}508509510