Path: blob/master/arch/sh/kernel/cpu/sh3/setup-sh770x.c
17498 views
/*1* SH3 Setup code for SH7706, SH7707, SH7708, SH77092*3* Copyright (C) 2007 Magnus Damm4* Copyright (C) 2009 Paul Mundt5*6* Based on setup-sh7709.c7*8* Copyright (C) 2006 Paul Mundt9*10* This file is subject to the terms and conditions of the GNU General Public11* License. See the file "COPYING" in the main directory of this archive12* for more details.13*/14#include <linux/init.h>15#include <linux/io.h>16#include <linux/irq.h>17#include <linux/platform_device.h>18#include <linux/serial.h>19#include <linux/serial_sci.h>20#include <linux/sh_timer.h>2122enum {23UNUSED = 0,2425/* interrupt sources */26IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5,27PINT07, PINT815,28DMAC, SCIF0, SCIF2, SCI, ADC_ADI,29LCDC, PCC0, PCC1,30TMU0, TMU1, TMU2,31RTC, WDT, REF,32};3334static struct intc_vect vectors[] __initdata = {35INTC_VECT(TMU0, 0x400), INTC_VECT(TMU1, 0x420),36INTC_VECT(TMU2, 0x440), INTC_VECT(TMU2, 0x460),37INTC_VECT(RTC, 0x480), INTC_VECT(RTC, 0x4a0),38INTC_VECT(RTC, 0x4c0),39INTC_VECT(SCI, 0x4e0), INTC_VECT(SCI, 0x500),40INTC_VECT(SCI, 0x520), INTC_VECT(SCI, 0x540),41INTC_VECT(WDT, 0x560),42INTC_VECT(REF, 0x580),43INTC_VECT(REF, 0x5a0),44#if defined(CONFIG_CPU_SUBTYPE_SH7706) || \45defined(CONFIG_CPU_SUBTYPE_SH7707) || \46defined(CONFIG_CPU_SUBTYPE_SH7709)47/* IRQ0->5 are handled in setup-sh3.c */48INTC_VECT(DMAC, 0x800), INTC_VECT(DMAC, 0x820),49INTC_VECT(DMAC, 0x840), INTC_VECT(DMAC, 0x860),50INTC_VECT(ADC_ADI, 0x980),51INTC_VECT(SCIF2, 0x900), INTC_VECT(SCIF2, 0x920),52INTC_VECT(SCIF2, 0x940), INTC_VECT(SCIF2, 0x960),53#endif54#if defined(CONFIG_CPU_SUBTYPE_SH7707) || \55defined(CONFIG_CPU_SUBTYPE_SH7709)56INTC_VECT(PINT07, 0x700), INTC_VECT(PINT815, 0x720),57INTC_VECT(SCIF0, 0x880), INTC_VECT(SCIF0, 0x8a0),58INTC_VECT(SCIF0, 0x8c0), INTC_VECT(SCIF0, 0x8e0),59#endif60#if defined(CONFIG_CPU_SUBTYPE_SH7707)61INTC_VECT(LCDC, 0x9a0),62INTC_VECT(PCC0, 0x9c0), INTC_VECT(PCC1, 0x9e0),63#endif64};6566static struct intc_prio_reg prio_registers[] __initdata = {67{ 0xfffffee2, 0, 16, 4, /* IPRA */ { TMU0, TMU1, TMU2, RTC } },68{ 0xfffffee4, 0, 16, 4, /* IPRB */ { WDT, REF, SCI, 0 } },69#if defined(CONFIG_CPU_SUBTYPE_SH7706) || \70defined(CONFIG_CPU_SUBTYPE_SH7707) || \71defined(CONFIG_CPU_SUBTYPE_SH7709)72{ 0xa4000016, 0, 16, 4, /* IPRC */ { IRQ3, IRQ2, IRQ1, IRQ0 } },73{ 0xa4000018, 0, 16, 4, /* IPRD */ { 0, 0, IRQ5, IRQ4 } },74{ 0xa400001a, 0, 16, 4, /* IPRE */ { DMAC, 0, SCIF2, ADC_ADI } },75#endif76#if defined(CONFIG_CPU_SUBTYPE_SH7707) || \77defined(CONFIG_CPU_SUBTYPE_SH7709)78{ 0xa4000018, 0, 16, 4, /* IPRD */ { PINT07, PINT815, } },79{ 0xa400001a, 0, 16, 4, /* IPRE */ { 0, SCIF0 } },80#endif81#if defined(CONFIG_CPU_SUBTYPE_SH7707)82{ 0xa400001c, 0, 16, 4, /* IPRF */ { 0, LCDC, PCC0, PCC1, } },83#endif84};8586static DECLARE_INTC_DESC(intc_desc, "sh770x", vectors, NULL,87NULL, prio_registers, NULL);8889static struct resource rtc_resources[] = {90[0] = {91.start = 0xfffffec0,92.end = 0xfffffec0 + 0x1e,93.flags = IORESOURCE_IO,94},95[1] = {96.start = 20,97.flags = IORESOURCE_IRQ,98},99};100101static struct platform_device rtc_device = {102.name = "sh-rtc",103.id = -1,104.num_resources = ARRAY_SIZE(rtc_resources),105.resource = rtc_resources,106};107108static struct plat_sci_port scif0_platform_data = {109.mapbase = 0xfffffe80,110.flags = UPF_BOOT_AUTOCONF,111.scscr = SCSCR_TE | SCSCR_RE,112.scbrr_algo_id = SCBRR_ALGO_2,113.type = PORT_SCI,114.irqs = { 23, 23, 23, 0 },115};116117static struct platform_device scif0_device = {118.name = "sh-sci",119.id = 0,120.dev = {121.platform_data = &scif0_platform_data,122},123};124#if defined(CONFIG_CPU_SUBTYPE_SH7706) || \125defined(CONFIG_CPU_SUBTYPE_SH7707) || \126defined(CONFIG_CPU_SUBTYPE_SH7709)127static struct plat_sci_port scif1_platform_data = {128.mapbase = 0xa4000150,129.flags = UPF_BOOT_AUTOCONF,130.scscr = SCSCR_TE | SCSCR_RE,131.scbrr_algo_id = SCBRR_ALGO_2,132.type = PORT_SCIF,133.irqs = { 56, 56, 56, 56 },134};135136static struct platform_device scif1_device = {137.name = "sh-sci",138.id = 1,139.dev = {140.platform_data = &scif1_platform_data,141},142};143#endif144#if defined(CONFIG_CPU_SUBTYPE_SH7707) || \145defined(CONFIG_CPU_SUBTYPE_SH7709)146static struct plat_sci_port scif2_platform_data = {147.mapbase = 0xa4000140,148.flags = UPF_BOOT_AUTOCONF,149.scscr = SCSCR_TE | SCSCR_RE,150.scbrr_algo_id = SCBRR_ALGO_2,151.type = PORT_IRDA,152.irqs = { 52, 52, 52, 52 },153};154155static struct platform_device scif2_device = {156.name = "sh-sci",157.id = 2,158.dev = {159.platform_data = &scif2_platform_data,160},161};162#endif163164static struct sh_timer_config tmu0_platform_data = {165.channel_offset = 0x02,166.timer_bit = 0,167.clockevent_rating = 200,168};169170static struct resource tmu0_resources[] = {171[0] = {172.start = 0xfffffe94,173.end = 0xfffffe9f,174.flags = IORESOURCE_MEM,175},176[1] = {177.start = 16,178.flags = IORESOURCE_IRQ,179},180};181182static struct platform_device tmu0_device = {183.name = "sh_tmu",184.id = 0,185.dev = {186.platform_data = &tmu0_platform_data,187},188.resource = tmu0_resources,189.num_resources = ARRAY_SIZE(tmu0_resources),190};191192static struct sh_timer_config tmu1_platform_data = {193.channel_offset = 0xe,194.timer_bit = 1,195.clocksource_rating = 200,196};197198static struct resource tmu1_resources[] = {199[0] = {200.start = 0xfffffea0,201.end = 0xfffffeab,202.flags = IORESOURCE_MEM,203},204[1] = {205.start = 17,206.flags = IORESOURCE_IRQ,207},208};209210static struct platform_device tmu1_device = {211.name = "sh_tmu",212.id = 1,213.dev = {214.platform_data = &tmu1_platform_data,215},216.resource = tmu1_resources,217.num_resources = ARRAY_SIZE(tmu1_resources),218};219220static struct sh_timer_config tmu2_platform_data = {221.channel_offset = 0x1a,222.timer_bit = 2,223};224225static struct resource tmu2_resources[] = {226[0] = {227.start = 0xfffffeac,228.end = 0xfffffebb,229.flags = IORESOURCE_MEM,230},231[1] = {232.start = 18,233.flags = IORESOURCE_IRQ,234},235};236237static struct platform_device tmu2_device = {238.name = "sh_tmu",239.id = 2,240.dev = {241.platform_data = &tmu2_platform_data,242},243.resource = tmu2_resources,244.num_resources = ARRAY_SIZE(tmu2_resources),245};246247static struct platform_device *sh770x_devices[] __initdata = {248&scif0_device,249#if defined(CONFIG_CPU_SUBTYPE_SH7706) || \250defined(CONFIG_CPU_SUBTYPE_SH7707) || \251defined(CONFIG_CPU_SUBTYPE_SH7709)252&scif1_device,253#endif254#if defined(CONFIG_CPU_SUBTYPE_SH7707) || \255defined(CONFIG_CPU_SUBTYPE_SH7709)256&scif2_device,257#endif258&tmu0_device,259&tmu1_device,260&tmu2_device,261&rtc_device,262};263264static int __init sh770x_devices_setup(void)265{266return platform_add_devices(sh770x_devices,267ARRAY_SIZE(sh770x_devices));268}269arch_initcall(sh770x_devices_setup);270271static struct platform_device *sh770x_early_devices[] __initdata = {272&scif0_device,273#if defined(CONFIG_CPU_SUBTYPE_SH7706) || \274defined(CONFIG_CPU_SUBTYPE_SH7707) || \275defined(CONFIG_CPU_SUBTYPE_SH7709)276&scif1_device,277#endif278#if defined(CONFIG_CPU_SUBTYPE_SH7707) || \279defined(CONFIG_CPU_SUBTYPE_SH7709)280&scif2_device,281#endif282&tmu0_device,283&tmu1_device,284&tmu2_device,285};286287void __init plat_early_device_setup(void)288{289early_platform_add_devices(sh770x_early_devices,290ARRAY_SIZE(sh770x_early_devices));291}292293void __init plat_irq_setup(void)294{295register_intc_controller(&intc_desc);296#if defined(CONFIG_CPU_SUBTYPE_SH7706) || \297defined(CONFIG_CPU_SUBTYPE_SH7707) || \298defined(CONFIG_CPU_SUBTYPE_SH7709)299plat_irq_setup_sh3();300#endif301}302303304