Path: blob/master/arch/sh/kernel/cpu/sh4/setup-sh7750.c
26495 views
// SPDX-License-Identifier: GPL-2.01/*2* SH7091/SH7750/SH7750S/SH7750R/SH7751/SH7751R Setup3*4* Copyright (C) 2006 Paul Mundt5* Copyright (C) 2006 Jamie Lenehan6*/7#include <linux/platform_device.h>8#include <linux/init.h>9#include <linux/serial.h>10#include <linux/io.h>11#include <linux/sh_timer.h>12#include <linux/sh_intc.h>13#include <linux/serial_sci.h>14#include <generated/machtypes.h>15#include <asm/platform_early.h>1617static struct resource rtc_resources[] = {18[0] = {19.start = 0xffc80000,20.end = 0xffc80000 + 0x58 - 1,21.flags = IORESOURCE_IO,22},23[1] = {24/* Shared Period/Carry/Alarm IRQ */25.start = evt2irq(0x480),26.flags = IORESOURCE_IRQ,27},28};2930static struct platform_device rtc_device = {31.name = "sh-rtc",32.id = -1,33.num_resources = ARRAY_SIZE(rtc_resources),34.resource = rtc_resources,35};3637static struct plat_sci_port sci_platform_data = {38.type = PORT_SCI,39};4041static struct resource sci_resources[] = {42DEFINE_RES_MEM(0xffe00000, 0x20),43DEFINE_RES_IRQ(evt2irq(0x4e0)),44};4546static struct platform_device sci_device = {47.name = "sh-sci",48.id = 0,49.resource = sci_resources,50.num_resources = ARRAY_SIZE(sci_resources),51.dev = {52.platform_data = &sci_platform_data,53},54};5556static struct plat_sci_port scif_platform_data = {57.scscr = SCSCR_REIE,58.type = PORT_SCIF,59};6061static struct resource scif_resources[] = {62DEFINE_RES_MEM(0xffe80000, 0x100),63DEFINE_RES_IRQ(evt2irq(0x700)),64};6566static struct platform_device scif_device = {67.name = "sh-sci",68.id = 1,69.resource = scif_resources,70.num_resources = ARRAY_SIZE(scif_resources),71.dev = {72.platform_data = &scif_platform_data,73},74};7576static struct sh_timer_config tmu0_platform_data = {77.channels_mask = 7,78};7980static struct resource tmu0_resources[] = {81DEFINE_RES_MEM(0xffd80000, 0x30),82DEFINE_RES_IRQ(evt2irq(0x400)),83DEFINE_RES_IRQ(evt2irq(0x420)),84DEFINE_RES_IRQ(evt2irq(0x440)),85};8687static struct platform_device tmu0_device = {88.name = "sh-tmu",89.id = 0,90.dev = {91.platform_data = &tmu0_platform_data,92},93.resource = tmu0_resources,94.num_resources = ARRAY_SIZE(tmu0_resources),95};9697/* SH7750R, SH7751 and SH7751R all have two extra timer channels */98#if defined(CONFIG_CPU_SUBTYPE_SH7750R) || \99defined(CONFIG_CPU_SUBTYPE_SH7751) || \100defined(CONFIG_CPU_SUBTYPE_SH7751R)101102static struct sh_timer_config tmu1_platform_data = {103.channels_mask = 3,104};105106static struct resource tmu1_resources[] = {107DEFINE_RES_MEM(0xfe100000, 0x20),108DEFINE_RES_IRQ(evt2irq(0xb00)),109DEFINE_RES_IRQ(evt2irq(0xb80)),110};111112static struct platform_device tmu1_device = {113.name = "sh-tmu",114.id = 1,115.dev = {116.platform_data = &tmu1_platform_data,117},118.resource = tmu1_resources,119.num_resources = ARRAY_SIZE(tmu1_resources),120};121122#endif123124static struct platform_device *sh7750_devices[] __initdata = {125&rtc_device,126&tmu0_device,127#if defined(CONFIG_CPU_SUBTYPE_SH7750R) || \128defined(CONFIG_CPU_SUBTYPE_SH7751) || \129defined(CONFIG_CPU_SUBTYPE_SH7751R)130&tmu1_device,131#endif132};133134static int __init sh7750_devices_setup(void)135{136if (mach_is_rts7751r2d()) {137platform_device_register(&scif_device);138} else {139platform_device_register(&sci_device);140platform_device_register(&scif_device);141}142143return platform_add_devices(sh7750_devices,144ARRAY_SIZE(sh7750_devices));145}146arch_initcall(sh7750_devices_setup);147148static struct platform_device *sh7750_early_devices[] __initdata = {149&tmu0_device,150#if defined(CONFIG_CPU_SUBTYPE_SH7750R) || \151defined(CONFIG_CPU_SUBTYPE_SH7751) || \152defined(CONFIG_CPU_SUBTYPE_SH7751R)153&tmu1_device,154#endif155};156157void __init plat_early_device_setup(void)158{159struct platform_device *dev[1];160161if (mach_is_rts7751r2d()) {162scif_platform_data.scscr |= SCSCR_CKE1;163dev[0] = &scif_device;164sh_early_platform_add_devices(dev, 1);165} else {166dev[0] = &sci_device;167sh_early_platform_add_devices(dev, 1);168dev[0] = &scif_device;169sh_early_platform_add_devices(dev, 1);170}171172sh_early_platform_add_devices(sh7750_early_devices,173ARRAY_SIZE(sh7750_early_devices));174}175176enum {177UNUSED = 0,178179/* interrupt sources */180IRL0, IRL1, IRL2, IRL3, /* only IRLM mode supported */181HUDI, GPIOI, DMAC,182PCIC0_PCISERR, PCIC1_PCIERR, PCIC1_PCIPWDWN, PCIC1_PCIPWON,183PCIC1_PCIDMA0, PCIC1_PCIDMA1, PCIC1_PCIDMA2, PCIC1_PCIDMA3,184TMU3, TMU4, TMU0, TMU1, TMU2, RTC, SCI1, SCIF, WDT, REF,185186/* interrupt groups */187PCIC1,188};189190static struct intc_vect vectors[] __initdata = {191INTC_VECT(HUDI, 0x600), INTC_VECT(GPIOI, 0x620),192INTC_VECT(TMU0, 0x400), INTC_VECT(TMU1, 0x420),193INTC_VECT(TMU2, 0x440), INTC_VECT(TMU2, 0x460),194INTC_VECT(RTC, 0x480), INTC_VECT(RTC, 0x4a0),195INTC_VECT(RTC, 0x4c0),196INTC_VECT(SCI1, 0x4e0), INTC_VECT(SCI1, 0x500),197INTC_VECT(SCI1, 0x520), INTC_VECT(SCI1, 0x540),198INTC_VECT(SCIF, 0x700), INTC_VECT(SCIF, 0x720),199INTC_VECT(SCIF, 0x740), INTC_VECT(SCIF, 0x760),200INTC_VECT(WDT, 0x560),201INTC_VECT(REF, 0x580), INTC_VECT(REF, 0x5a0),202};203204static struct intc_prio_reg prio_registers[] __initdata = {205{ 0xffd00004, 0, 16, 4, /* IPRA */ { TMU0, TMU1, TMU2, RTC } },206{ 0xffd00008, 0, 16, 4, /* IPRB */ { WDT, REF, SCI1, 0 } },207{ 0xffd0000c, 0, 16, 4, /* IPRC */ { GPIOI, DMAC, SCIF, HUDI } },208{ 0xffd00010, 0, 16, 4, /* IPRD */ { IRL0, IRL1, IRL2, IRL3 } },209{ 0xfe080000, 0, 32, 4, /* INTPRI00 */ { 0, 0, 0, 0,210TMU4, TMU3,211PCIC1, PCIC0_PCISERR } },212};213214static DECLARE_INTC_DESC(intc_desc, "sh7750", vectors, NULL,215NULL, prio_registers, NULL);216217/* SH7750, SH7750S, SH7751 and SH7091 all have 4-channel DMA controllers */218#if defined(CONFIG_CPU_SUBTYPE_SH7750) || \219defined(CONFIG_CPU_SUBTYPE_SH7750S) || \220defined(CONFIG_CPU_SUBTYPE_SH7751) || \221defined(CONFIG_CPU_SUBTYPE_SH7091)222static struct intc_vect vectors_dma4[] __initdata = {223INTC_VECT(DMAC, 0x640), INTC_VECT(DMAC, 0x660),224INTC_VECT(DMAC, 0x680), INTC_VECT(DMAC, 0x6a0),225INTC_VECT(DMAC, 0x6c0),226};227228static DECLARE_INTC_DESC(intc_desc_dma4, "sh7750_dma4",229vectors_dma4, NULL,230NULL, prio_registers, NULL);231#endif232233/* SH7750R and SH7751R both have 8-channel DMA controllers */234#if defined(CONFIG_CPU_SUBTYPE_SH7750R) || defined(CONFIG_CPU_SUBTYPE_SH7751R)235static struct intc_vect vectors_dma8[] __initdata = {236INTC_VECT(DMAC, 0x640), INTC_VECT(DMAC, 0x660),237INTC_VECT(DMAC, 0x680), INTC_VECT(DMAC, 0x6a0),238INTC_VECT(DMAC, 0x780), INTC_VECT(DMAC, 0x7a0),239INTC_VECT(DMAC, 0x7c0), INTC_VECT(DMAC, 0x7e0),240INTC_VECT(DMAC, 0x6c0),241};242243static DECLARE_INTC_DESC(intc_desc_dma8, "sh7750_dma8",244vectors_dma8, NULL,245NULL, prio_registers, NULL);246#endif247248/* SH7750R, SH7751 and SH7751R all have two extra timer channels */249#if defined(CONFIG_CPU_SUBTYPE_SH7750R) || \250defined(CONFIG_CPU_SUBTYPE_SH7751) || \251defined(CONFIG_CPU_SUBTYPE_SH7751R)252static struct intc_vect vectors_tmu34[] __initdata = {253INTC_VECT(TMU3, 0xb00), INTC_VECT(TMU4, 0xb80),254};255256static struct intc_mask_reg mask_registers[] __initdata = {257{ 0xfe080040, 0xfe080060, 32, /* INTMSK00 / INTMSKCLR00 */258{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,2590, 0, 0, 0, 0, 0, TMU4, TMU3,260PCIC1_PCIERR, PCIC1_PCIPWDWN, PCIC1_PCIPWON,261PCIC1_PCIDMA0, PCIC1_PCIDMA1, PCIC1_PCIDMA2,262PCIC1_PCIDMA3, PCIC0_PCISERR } },263};264265static DECLARE_INTC_DESC(intc_desc_tmu34, "sh7750_tmu34",266vectors_tmu34, NULL,267mask_registers, prio_registers, NULL);268#endif269270/* SH7750S, SH7750R, SH7751 and SH7751R all have IRLM priority registers */271static struct intc_vect vectors_irlm[] __initdata = {272INTC_VECT(IRL0, 0x240), INTC_VECT(IRL1, 0x2a0),273INTC_VECT(IRL2, 0x300), INTC_VECT(IRL3, 0x360),274};275276static DECLARE_INTC_DESC(intc_desc_irlm, "sh7750_irlm", vectors_irlm, NULL,277NULL, prio_registers, NULL);278279/* SH7751 and SH7751R both have PCI */280#if defined(CONFIG_CPU_SUBTYPE_SH7751) || defined(CONFIG_CPU_SUBTYPE_SH7751R)281static struct intc_vect vectors_pci[] __initdata = {282INTC_VECT(PCIC0_PCISERR, 0xa00), INTC_VECT(PCIC1_PCIERR, 0xae0),283INTC_VECT(PCIC1_PCIPWDWN, 0xac0), INTC_VECT(PCIC1_PCIPWON, 0xaa0),284INTC_VECT(PCIC1_PCIDMA0, 0xa80), INTC_VECT(PCIC1_PCIDMA1, 0xa60),285INTC_VECT(PCIC1_PCIDMA2, 0xa40), INTC_VECT(PCIC1_PCIDMA3, 0xa20),286};287288static struct intc_group groups_pci[] __initdata = {289INTC_GROUP(PCIC1, PCIC1_PCIERR, PCIC1_PCIPWDWN, PCIC1_PCIPWON,290PCIC1_PCIDMA0, PCIC1_PCIDMA1, PCIC1_PCIDMA2, PCIC1_PCIDMA3),291};292293static DECLARE_INTC_DESC(intc_desc_pci, "sh7750_pci", vectors_pci, groups_pci,294mask_registers, prio_registers, NULL);295#endif296297#if defined(CONFIG_CPU_SUBTYPE_SH7750) || \298defined(CONFIG_CPU_SUBTYPE_SH7750S) || \299defined(CONFIG_CPU_SUBTYPE_SH7091)300void __init plat_irq_setup(void)301{302/*303* same vectors for SH7750, SH7750S and SH7091 except for IRLM,304* see below..305*/306register_intc_controller(&intc_desc);307register_intc_controller(&intc_desc_dma4);308}309#endif310311#if defined(CONFIG_CPU_SUBTYPE_SH7750R)312void __init plat_irq_setup(void)313{314register_intc_controller(&intc_desc);315register_intc_controller(&intc_desc_dma8);316register_intc_controller(&intc_desc_tmu34);317}318#endif319320#if defined(CONFIG_CPU_SUBTYPE_SH7751)321void __init plat_irq_setup(void)322{323register_intc_controller(&intc_desc);324register_intc_controller(&intc_desc_dma4);325register_intc_controller(&intc_desc_tmu34);326register_intc_controller(&intc_desc_pci);327}328#endif329330#if defined(CONFIG_CPU_SUBTYPE_SH7751R)331void __init plat_irq_setup(void)332{333register_intc_controller(&intc_desc);334register_intc_controller(&intc_desc_dma8);335register_intc_controller(&intc_desc_tmu34);336register_intc_controller(&intc_desc_pci);337}338#endif339340#define INTC_ICR 0xffd00000UL341#define INTC_ICR_IRLM (1<<7)342343void __init plat_irq_setup_pins(int mode)344{345#if defined(CONFIG_CPU_SUBTYPE_SH7750) || defined(CONFIG_CPU_SUBTYPE_SH7091)346BUG(); /* impossible to mask interrupts on SH7750 and SH7091 */347return;348#endif349350switch (mode) {351case IRQ_MODE_IRQ: /* individual interrupt mode for IRL3-0 */352__raw_writew(__raw_readw(INTC_ICR) | INTC_ICR_IRLM, INTC_ICR);353register_intc_controller(&intc_desc_irlm);354break;355default:356BUG();357}358}359360361