Path: blob/master/arch/m32r/platforms/opsput/setup.c
10819 views
/*1* linux/arch/m32r/platforms/opsput/setup.c2*3* Setup routines for Renesas OPSPUT Board4*5* Copyright (c) 2002-20056* Hiroyuki Kondo, Hirokazu Takata,7* Hitoshi Yamamoto, Takeo Takahashi, Mamoru Sakugawa8*9* This file is subject to the terms and conditions of the GNU General10* Public License. See the file "COPYING" in the main directory of this11* archive for more details.12*/1314#include <linux/irq.h>15#include <linux/kernel.h>16#include <linux/init.h>17#include <linux/platform_device.h>1819#include <asm/system.h>20#include <asm/m32r.h>21#include <asm/io.h>2223/*24* OPSP Interrupt Control Unit (Level 1)25*/26#define irq2port(x) (M32R_ICU_CR1_PORTL + ((x - 1) * sizeof(unsigned long)))2728icu_data_t icu_data[OPSPUT_NUM_CPU_IRQ];2930static void disable_opsput_irq(unsigned int irq)31{32unsigned long port, data;3334port = irq2port(irq);35data = icu_data[irq].icucr|M32R_ICUCR_ILEVEL7;36outl(data, port);37}3839static void enable_opsput_irq(unsigned int irq)40{41unsigned long port, data;4243port = irq2port(irq);44data = icu_data[irq].icucr|M32R_ICUCR_IEN|M32R_ICUCR_ILEVEL6;45outl(data, port);46}4748static void mask_opsput(struct irq_data *data)49{50disable_opsput_irq(data->irq);51}5253static void unmask_opsput(struct irq_data *data)54{55enable_opsput_irq(data->irq);56}5758static void shutdown_opsput(struct irq_data *data)59{60unsigned long port;6162port = irq2port(data->irq);63outl(M32R_ICUCR_ILEVEL7, port);64}6566static struct irq_chip opsput_irq_type =67{68.name = "OPSPUT-IRQ",69.irq_shutdown = shutdown_opsput,70.irq_mask = mask_opsput,71.irq_unmask = unmask_opsput,72};7374/*75* Interrupt Control Unit of PLD on OPSPUT (Level 2)76*/77#define irq2pldirq(x) ((x) - OPSPUT_PLD_IRQ_BASE)78#define pldirq2port(x) (unsigned long)((int)PLD_ICUCR1 + \79(((x) - 1) * sizeof(unsigned short)))8081typedef struct {82unsigned short icucr; /* ICU Control Register */83} pld_icu_data_t;8485static pld_icu_data_t pld_icu_data[OPSPUT_NUM_PLD_IRQ];8687static void disable_opsput_pld_irq(unsigned int irq)88{89unsigned long port, data;90unsigned int pldirq;9192pldirq = irq2pldirq(irq);93port = pldirq2port(pldirq);94data = pld_icu_data[pldirq].icucr|PLD_ICUCR_ILEVEL7;95outw(data, port);96}9798static void enable_opsput_pld_irq(unsigned int irq)99{100unsigned long port, data;101unsigned int pldirq;102103pldirq = irq2pldirq(irq);104port = pldirq2port(pldirq);105data = pld_icu_data[pldirq].icucr|PLD_ICUCR_IEN|PLD_ICUCR_ILEVEL6;106outw(data, port);107}108109static void mask_opsput_pld(struct irq_data *data)110{111disable_opsput_pld_irq(data->irq);112}113114static void unmask_opsput_pld(struct irq_data *data)115{116enable_opsput_pld_irq(data->irq);117enable_opsput_irq(M32R_IRQ_INT1);118}119120static void shutdown_opsput_pld(struct irq_data *data)121{122unsigned long port;123unsigned int pldirq;124125pldirq = irq2pldirq(data->irq);126port = pldirq2port(pldirq);127outw(PLD_ICUCR_ILEVEL7, port);128}129130static struct irq_chip opsput_pld_irq_type =131{132.name = "OPSPUT-PLD-IRQ",133.irq_shutdown = shutdown_opsput_pld,134.irq_mask = mask_opsput_pld,135.irq_unmask = unmask_opsput_pld,136};137138/*139* Interrupt Control Unit of PLD on OPSPUT-LAN (Level 2)140*/141#define irq2lanpldirq(x) ((x) - OPSPUT_LAN_PLD_IRQ_BASE)142#define lanpldirq2port(x) (unsigned long)((int)OPSPUT_LAN_ICUCR1 + \143(((x) - 1) * sizeof(unsigned short)))144145static pld_icu_data_t lanpld_icu_data[OPSPUT_NUM_LAN_PLD_IRQ];146147static void disable_opsput_lanpld_irq(unsigned int irq)148{149unsigned long port, data;150unsigned int pldirq;151152pldirq = irq2lanpldirq(irq);153port = lanpldirq2port(pldirq);154data = lanpld_icu_data[pldirq].icucr|PLD_ICUCR_ILEVEL7;155outw(data, port);156}157158static void enable_opsput_lanpld_irq(unsigned int irq)159{160unsigned long port, data;161unsigned int pldirq;162163pldirq = irq2lanpldirq(irq);164port = lanpldirq2port(pldirq);165data = lanpld_icu_data[pldirq].icucr|PLD_ICUCR_IEN|PLD_ICUCR_ILEVEL6;166outw(data, port);167}168169static void mask_opsput_lanpld(struct irq_data *data)170{171disable_opsput_lanpld_irq(data->irq);172}173174static void unmask_opsput_lanpld(struct irq_data *data)175{176enable_opsput_lanpld_irq(data->irq);177enable_opsput_irq(M32R_IRQ_INT0);178}179180static void shutdown_opsput_lanpld(struct irq_data *data)181{182unsigned long port;183unsigned int pldirq;184185pldirq = irq2lanpldirq(data->irq);186port = lanpldirq2port(pldirq);187outw(PLD_ICUCR_ILEVEL7, port);188}189190static struct irq_chip opsput_lanpld_irq_type =191{192.name = "OPSPUT-PLD-LAN-IRQ",193.irq_shutdown = shutdown_opsput_lanpld,194.irq_mask = mask_opsput_lanpld,195.irq_unmask = unmask_opsput_lanpld,196};197198/*199* Interrupt Control Unit of PLD on OPSPUT-LCD (Level 2)200*/201#define irq2lcdpldirq(x) ((x) - OPSPUT_LCD_PLD_IRQ_BASE)202#define lcdpldirq2port(x) (unsigned long)((int)OPSPUT_LCD_ICUCR1 + \203(((x) - 1) * sizeof(unsigned short)))204205static pld_icu_data_t lcdpld_icu_data[OPSPUT_NUM_LCD_PLD_IRQ];206207static void disable_opsput_lcdpld_irq(unsigned int irq)208{209unsigned long port, data;210unsigned int pldirq;211212pldirq = irq2lcdpldirq(irq);213port = lcdpldirq2port(pldirq);214data = lcdpld_icu_data[pldirq].icucr|PLD_ICUCR_ILEVEL7;215outw(data, port);216}217218static void enable_opsput_lcdpld_irq(unsigned int irq)219{220unsigned long port, data;221unsigned int pldirq;222223pldirq = irq2lcdpldirq(irq);224port = lcdpldirq2port(pldirq);225data = lcdpld_icu_data[pldirq].icucr|PLD_ICUCR_IEN|PLD_ICUCR_ILEVEL6;226outw(data, port);227}228229static void mask_opsput_lcdpld(struct irq_data *data)230{231disable_opsput_lcdpld_irq(data->irq);232}233234static void unmask_opsput_lcdpld(struct irq_data *data)235{236enable_opsput_lcdpld_irq(data->irq);237enable_opsput_irq(M32R_IRQ_INT2);238}239240static void shutdown_opsput_lcdpld(struct irq_data *data)241{242unsigned long port;243unsigned int pldirq;244245pldirq = irq2lcdpldirq(data->irq);246port = lcdpldirq2port(pldirq);247outw(PLD_ICUCR_ILEVEL7, port);248}249250static struct irq_chip opsput_lcdpld_irq_type = {251.name = "OPSPUT-PLD-LCD-IRQ",252.irq_shutdown = shutdown_opsput_lcdpld,253.irq_mask = mask_opsput_lcdpld,254.irq_unmask = unmask_opsput_lcdpld,255};256257void __init init_IRQ(void)258{259#if defined(CONFIG_SMC91X)260/* INT#0: LAN controller on OPSPUT-LAN (SMC91C111)*/261irq_set_chip_and_handler(OPSPUT_LAN_IRQ_LAN, &opsput_lanpld_irq_type,262handle_level_irq);263lanpld_icu_data[irq2lanpldirq(OPSPUT_LAN_IRQ_LAN)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD02; /* "H" edge sense */264disable_opsput_lanpld_irq(OPSPUT_LAN_IRQ_LAN);265#endif /* CONFIG_SMC91X */266267/* MFT2 : system timer */268irq_set_chip_and_handler(M32R_IRQ_MFT2, &opsput_irq_type,269handle_level_irq);270icu_data[M32R_IRQ_MFT2].icucr = M32R_ICUCR_IEN;271disable_opsput_irq(M32R_IRQ_MFT2);272273/* SIO0 : receive */274irq_set_chip_and_handler(M32R_IRQ_SIO0_R, &opsput_irq_type,275handle_level_irq);276icu_data[M32R_IRQ_SIO0_R].icucr = 0;277disable_opsput_irq(M32R_IRQ_SIO0_R);278279/* SIO0 : send */280irq_set_chip_and_handler(M32R_IRQ_SIO0_S, &opsput_irq_type,281handle_level_irq);282icu_data[M32R_IRQ_SIO0_S].icucr = 0;283disable_opsput_irq(M32R_IRQ_SIO0_S);284285/* SIO1 : receive */286irq_set_chip_and_handler(M32R_IRQ_SIO1_R, &opsput_irq_type,287handle_level_irq);288icu_data[M32R_IRQ_SIO1_R].icucr = 0;289disable_opsput_irq(M32R_IRQ_SIO1_R);290291/* SIO1 : send */292irq_set_chip_and_handler(M32R_IRQ_SIO1_S, &opsput_irq_type,293handle_level_irq);294icu_data[M32R_IRQ_SIO1_S].icucr = 0;295disable_opsput_irq(M32R_IRQ_SIO1_S);296297/* DMA1 : */298irq_set_chip_and_handler(M32R_IRQ_DMA1, &opsput_irq_type,299handle_level_irq);300icu_data[M32R_IRQ_DMA1].icucr = 0;301disable_opsput_irq(M32R_IRQ_DMA1);302303#ifdef CONFIG_SERIAL_M32R_PLDSIO304/* INT#1: SIO0 Receive on PLD */305irq_set_chip_and_handler(PLD_IRQ_SIO0_RCV, &opsput_pld_irq_type,306handle_level_irq);307pld_icu_data[irq2pldirq(PLD_IRQ_SIO0_RCV)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD03;308disable_opsput_pld_irq(PLD_IRQ_SIO0_RCV);309310/* INT#1: SIO0 Send on PLD */311irq_set_chip_and_handler(PLD_IRQ_SIO0_SND, &opsput_pld_irq_type,312handle_level_irq);313pld_icu_data[irq2pldirq(PLD_IRQ_SIO0_SND)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD03;314disable_opsput_pld_irq(PLD_IRQ_SIO0_SND);315#endif /* CONFIG_SERIAL_M32R_PLDSIO */316317/* INT#1: CFC IREQ on PLD */318irq_set_chip_and_handler(PLD_IRQ_CFIREQ, &opsput_pld_irq_type,319handle_level_irq);320pld_icu_data[irq2pldirq(PLD_IRQ_CFIREQ)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD01; /* 'L' level sense */321disable_opsput_pld_irq(PLD_IRQ_CFIREQ);322323/* INT#1: CFC Insert on PLD */324irq_set_chip_and_handler(PLD_IRQ_CFC_INSERT, &opsput_pld_irq_type,325handle_level_irq);326pld_icu_data[irq2pldirq(PLD_IRQ_CFC_INSERT)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD00; /* 'L' edge sense */327disable_opsput_pld_irq(PLD_IRQ_CFC_INSERT);328329/* INT#1: CFC Eject on PLD */330irq_set_chip_and_handler(PLD_IRQ_CFC_EJECT, &opsput_pld_irq_type,331handle_level_irq);332pld_icu_data[irq2pldirq(PLD_IRQ_CFC_EJECT)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD02; /* 'H' edge sense */333disable_opsput_pld_irq(PLD_IRQ_CFC_EJECT);334335/*336* INT0# is used for LAN, DIO337* We enable it here.338*/339icu_data[M32R_IRQ_INT0].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD11;340enable_opsput_irq(M32R_IRQ_INT0);341342/*343* INT1# is used for UART, MMC, CF Controller in FPGA.344* We enable it here.345*/346icu_data[M32R_IRQ_INT1].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD11;347enable_opsput_irq(M32R_IRQ_INT1);348349#if defined(CONFIG_USB)350outw(USBCR_OTGS, USBCR); /* USBCR: non-OTG */351irq_set_chip_and_handler(OPSPUT_LCD_IRQ_USB_INT1,352&opsput_lcdpld_irq_type, handle_level_irq);353lcdpld_icu_data[irq2lcdpldirq(OPSPUT_LCD_IRQ_USB_INT1)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD01; /* "L" level sense */354disable_opsput_lcdpld_irq(OPSPUT_LCD_IRQ_USB_INT1);355#endif356/*357* INT2# is used for BAT, USB, AUDIO358* We enable it here.359*/360icu_data[M32R_IRQ_INT2].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD01;361enable_opsput_irq(M32R_IRQ_INT2);362363#if defined(CONFIG_VIDEO_M32R_AR)364/*365* INT3# is used for AR366*/367irq_set_chip_and_handler(M32R_IRQ_INT3, &opsput_irq_type,368handle_level_irq);369icu_data[M32R_IRQ_INT3].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD10;370disable_opsput_irq(M32R_IRQ_INT3);371#endif /* CONFIG_VIDEO_M32R_AR */372}373374#if defined(CONFIG_SMC91X)375376#define LAN_IOSTART 0x300377#define LAN_IOEND 0x320378static struct resource smc91x_resources[] = {379[0] = {380.start = (LAN_IOSTART),381.end = (LAN_IOEND),382.flags = IORESOURCE_MEM,383},384[1] = {385.start = OPSPUT_LAN_IRQ_LAN,386.end = OPSPUT_LAN_IRQ_LAN,387.flags = IORESOURCE_IRQ,388}389};390391static struct platform_device smc91x_device = {392.name = "smc91x",393.id = 0,394.num_resources = ARRAY_SIZE(smc91x_resources),395.resource = smc91x_resources,396};397#endif398399#if defined(CONFIG_FB_S1D13XXX)400401#include <video/s1d13xxxfb.h>402#include <asm/s1d13806.h>403404static struct s1d13xxxfb_pdata s1d13xxxfb_data = {405.initregs = s1d13xxxfb_initregs,406.initregssize = ARRAY_SIZE(s1d13xxxfb_initregs),407.platform_init_video = NULL,408#ifdef CONFIG_PM409.platform_suspend_video = NULL,410.platform_resume_video = NULL,411#endif412};413414static struct resource s1d13xxxfb_resources[] = {415[0] = {416.start = 0x10600000UL,417.end = 0x1073FFFFUL,418.flags = IORESOURCE_MEM,419},420[1] = {421.start = 0x10400000UL,422.end = 0x104001FFUL,423.flags = IORESOURCE_MEM,424}425};426427static struct platform_device s1d13xxxfb_device = {428.name = S1D_DEVICENAME,429.id = 0,430.dev = {431.platform_data = &s1d13xxxfb_data,432},433.num_resources = ARRAY_SIZE(s1d13xxxfb_resources),434.resource = s1d13xxxfb_resources,435};436#endif437438static int __init platform_init(void)439{440#if defined(CONFIG_SMC91X)441platform_device_register(&smc91x_device);442#endif443#if defined(CONFIG_FB_S1D13XXX)444platform_device_register(&s1d13xxxfb_device);445#endif446return 0;447}448arch_initcall(platform_init);449450451