From: Magnus D. <mag...@gm...> - 2007-08-03 04:34:16
|
sh: intc - convert board specific r2d code This patch converts the board specific interrupt code for r2d to make use of intc. While at it we remove CONFIG_RTS7751R2D_REV11 to avoid confusion and to support both R2D-1 and R2D-PLUS boards using the same binary. - Two sets of interrupt tables exist - one for R2D-1 and one for R2D-PLUS. - R2D-1 and R2D-PLUS use the same irq constants. - R2D-1 has AX88796 support, R2D-PLUS does not hook up that IRQ. - R2D-PLUS has KEY support, R2D-1 does not hook up that IRQ. - The number and order of IRQ values are disconnected from register bits. - Interrupt sources now start from IRQ 100. - The machvec demux function converts from irlm IRQ 0-14 to IRQ 100++. Tested on R2D-1 and R2D-PLUS boards. Signed-off-by: Magnus Damm <da...@ig...> --- Needs single bitmap register support in intc plus new voyagergx code. arch/sh/Kconfig | 1 arch/sh/boards/renesas/rts7751r2d/Kconfig | 12 -- arch/sh/boards/renesas/rts7751r2d/irq.c | 155 ++++++++++++++++++++--------- arch/sh/boards/renesas/rts7751r2d/setup.c | 8 - arch/sh/drivers/pci/ops-rts7751r2d.c | 8 - include/asm-sh/rts7751r2d.h | 65 +++++------- 6 files changed, 144 insertions(+), 105 deletions(-) --- 0001/arch/sh/Kconfig +++ work/arch/sh/Kconfig 2007-08-02 20:50:10.000000000 +0900 @@ -397,7 +397,6 @@ config SH_LBOX_RE2 endmenu source "arch/sh/boards/renesas/hs7751rvoip/Kconfig" -source "arch/sh/boards/renesas/rts7751r2d/Kconfig" source "arch/sh/boards/renesas/r7780rp/Kconfig" menu "Timer and clock configuration" --- 0001/arch/sh/boards/renesas/rts7751r2d/Kconfig +++ /dev/null 2007-07-30 10:04:31.554482719 +0900 @@ -1,12 +0,0 @@ -if SH_RTS7751R2D - -menu "RTS7751R2D options" - -config RTS7751R2D_REV11 - bool "RTS7751R2D Rev. 1.1 board support" - help - Selecting this option will support version rev. 1.1. -endmenu - -endif - --- 0005/arch/sh/boards/renesas/rts7751r2d/irq.c +++ work/arch/sh/boards/renesas/rts7751r2d/irq.c 2007-08-02 20:50:10.000000000 +0900 @@ -16,67 +16,128 @@ #include <asm/voyagergx.h> #include <asm/rts7751r2d.h> -#if defined(CONFIG_RTS7751R2D_REV11) -static int mask_pos[] = {11, 9, 8, 12, 10, 6, 5, 4, 7, 14, 13, 0, 0, 0, 0}; -#else -static int mask_pos[] = {6, 11, 9, 8, 12, 10, 5, 4, 7, 14, 13, 0, 0, 0, 0}; -#endif +#define R2D_NR_IRL 13 -static void enable_rts7751r2d_irq(unsigned int irq) -{ - /* Set priority in IPR back to original value */ - ctrl_outw(ctrl_inw(IRLCNTR1) | (1 << mask_pos[irq]), IRLCNTR1); -} +enum { + UNUSED = 0, -static void disable_rts7751r2d_irq(unsigned int irq) -{ - /* Set the priority in IPR to 0 */ - ctrl_outw(ctrl_inw(IRLCNTR1) & (0xffff ^ (1 << mask_pos[irq])), - IRLCNTR1); -} + /* board specific interrupt sources (R2D-1 and R2D-PLUS) */ + EXT, /* EXT_INT0-3 */ + RTC_T, RTC_A, /* Real Time Clock */ + AX88796, /* Ethernet controller (R2D-1 board) */ + KEY, /* Key input (R2D-PLUS board) */ + SDCARD, /* SD Card */ + CF_CD, CF_IDE, /* CF Card Detect + CF IDE */ + SM501, /* SM501 aka Voyager */ + PCI_INTD_RTL8139, /* Ethernet controller */ + PCI_INTC_PCI1520, /* Cardbus/PCMCIA bridge */ + PCI_INTB_RTL8139, /* Ethernet controller with HUB (R2D-PLUS board) */ + PCI_INTB_SLOT, /* PCI Slot 3.3v (R2D-1 board) */ + PCI_INTA_SLOT, /* PCI Slot 3.3v */ + TP, /* Touch Panel */ +}; + +/* Vectors for R2D-1 */ +static struct intc_vect vectors_r2d_1[] = { + INTC_IRQ(EXT, IRQ_EXT), + INTC_IRQ(RTC_T, IRQ_RTC_T), INTC_IRQ(RTC_A, IRQ_RTC_A), + INTC_IRQ(AX88796, IRQ_AX88796), INTC_IRQ(SDCARD, IRQ_SDCARD), + INTC_IRQ(CF_CD, IRQ_CF_CD), INTC_IRQ(CF_IDE, IRQ_CF_IDE), /* ng */ + INTC_IRQ(SM501, IRQ_VOYAGER), + INTC_IRQ(PCI_INTD_RTL8139, IRQ_PCI_INTD), + INTC_IRQ(PCI_INTC_PCI1520, IRQ_PCI_INTC), + INTC_IRQ(PCI_INTB_SLOT, IRQ_PCI_INTB), + INTC_IRQ(PCI_INTA_SLOT, IRQ_PCI_INTA), + INTC_IRQ(TP, IRQ_TP), +}; + +/* IRLMSK mask register layout for R2D-1 */ +static struct intc_mask_reg mask_registers_r2d_1[] = { + { 0xa4000000, 1, 16, /* IRLMSK */ + { TP, PCI_INTA_SLOT, PCI_INTB_SLOT, + PCI_INTC_PCI1520, PCI_INTD_RTL8139, + SM501, CF_IDE, CF_CD, SDCARD, AX88796, + RTC_A, RTC_T, 0, 0, 0, EXT } }, +}; + +/* IRLn to IRQ table for R2D-1 */ +static unsigned char irl2irq_r2d_1[R2D_NR_IRL] = { + IRQ_PCI_INTD, IRQ_CF_IDE, IRQ_CF_CD, IRQ_PCI_INTC, + IRQ_VOYAGER, IRQ_AX88796, IRQ_RTC_A, IRQ_RTC_T, + IRQ_SDCARD, IRQ_PCI_INTA, IRQ_PCI_INTB, IRQ_EXT, + IRQ_TP, +}; + +static DECLARE_INTC_DESC(intc_desc_r2d_1, "r2d-1", vectors_r2d_1, + NULL, NULL, mask_registers_r2d_1, NULL, NULL); + +/* Vectors for R2D-PLUS */ +static struct intc_vect vectors_r2d_plus[] = { + INTC_IRQ(EXT, IRQ_EXT), + INTC_IRQ(RTC_T, IRQ_RTC_T), INTC_IRQ(RTC_A, IRQ_RTC_A), + INTC_IRQ(KEY, IRQ_KEY), INTC_IRQ(SDCARD, IRQ_SDCARD), + INTC_IRQ(CF_CD, IRQ_CF_CD), INTC_IRQ(CF_IDE, IRQ_CF_IDE), + INTC_IRQ(SM501, IRQ_VOYAGER), + INTC_IRQ(PCI_INTD_RTL8139, IRQ_PCI_INTD), + INTC_IRQ(PCI_INTC_PCI1520, IRQ_PCI_INTC), + INTC_IRQ(PCI_INTB_RTL8139, IRQ_PCI_INTB), + INTC_IRQ(PCI_INTA_SLOT, IRQ_PCI_INTA), + INTC_IRQ(TP, IRQ_TP), +}; + +/* IRLMSK mask register layout for R2D-PLUS */ +static struct intc_mask_reg mask_registers_r2d_plus[] = { + { 0xa4000000, 1, 16, /* IRLMSK */ + { TP, PCI_INTA_SLOT, PCI_INTB_RTL8139, + PCI_INTC_PCI1520, PCI_INTD_RTL8139, + SM501, CF_IDE, CF_CD, SDCARD, KEY, + RTC_A, RTC_T, 0, 0, 0, EXT } }, +}; + +/* IRLn to IRQ table for R2D-PLUS */ +static unsigned char irl2irq_r2d_plus[R2D_NR_IRL] = { + IRQ_PCI_INTD, IRQ_CF_IDE, IRQ_CF_CD, IRQ_PCI_INTC, + IRQ_VOYAGER, IRQ_KEY, IRQ_RTC_A, IRQ_RTC_T, + IRQ_SDCARD, IRQ_PCI_INTA, IRQ_PCI_INTB, IRQ_EXT, + IRQ_TP, +}; + +static DECLARE_INTC_DESC(intc_desc_r2d_plus, "r2d-plus", vectors_r2d_plus, + NULL, NULL, mask_registers_r2d_plus, NULL, NULL); + +static unsigned char *irl2irq; int rts7751r2d_irq_demux(int irq) { - return irq; -} + if (!irl2irq || irq >= R2D_NR_IRL) + return irq; -static struct irq_chip rts7751r2d_irq_chip __read_mostly = { - .name = "rts7751r2d", - .mask = disable_rts7751r2d_irq, - .unmask = enable_rts7751r2d_irq, - .mask_ack = disable_rts7751r2d_irq, -}; + return irl2irq[irq]; +} /* * Initialize IRQ setting */ void __init init_rts7751r2d_IRQ(void) { - int i; + struct intc_desc *d; - /* IRL0=KEY Input - * IRL1=Ethernet - * IRL2=CF Card - * IRL3=CF Card Insert - * IRL4=PCMCIA - * IRL5=VOYAGER - * IRL6=RTC Alarm - * IRL7=RTC Timer - * IRL8=SD Card - * IRL9=PCI Slot #1 - * IRL10=PCI Slot #2 - * IRL11=Extention #0 - * IRL12=Extention #1 - * IRL13=Extention #2 - * IRL14=Extention #3 - */ - - for (i=0; i<15; i++) { - disable_irq_nosync(i); - set_irq_chip_and_handler_name(i, &rts7751r2d_irq_chip, - handle_level_irq, "level"); - enable_rts7751r2d_irq(i); + switch (ctrl_inw(PA_BVERREG)) { + case 0x10: + printk(KERN_INFO "Using R2D-PLUS interrupt controller.\n"); + d = &intc_desc_r2d_plus; + irl2irq = irl2irq_r2d_plus; + break; + + case 0x11: + printk(KERN_INFO "Using R2D-1 interrupt controller.\n"); + d = &intc_desc_r2d_1; + irl2irq = irl2irq_r2d_1; + break; + default: + return; } + register_intc_controller(d); setup_voyagergx_irq(); } --- 0005/arch/sh/boards/renesas/rts7751r2d/setup.c +++ work/arch/sh/boards/renesas/rts7751r2d/setup.c 2007-08-02 20:50:10.000000000 +0900 @@ -54,11 +54,7 @@ static struct resource cf_ide_resources[ .flags = IORESOURCE_MEM, }, [2] = { -#ifdef CONFIG_RTS7751R2D_REV11 - .start = 1, -#else - .start = 2, -#endif + .start = IRQ_CF_IDE, .flags = IORESOURCE_IRQ, }, }; @@ -147,7 +143,7 @@ static int __init rts7751r2d_devices_set { int ret; - if (ctrl_inw(PA_BVERREG) == 0x10) { /* only working on R2D-PLUS */ + if (ctrl_inw(PA_BVERREG) == 0x10) { /* R2D-PLUS */ ret = platform_device_register(&cf_ide_device); if (ret) return ret; --- 0001/arch/sh/drivers/pci/ops-rts7751r2d.c +++ work/arch/sh/drivers/pci/ops-rts7751r2d.c 2007-08-02 20:50:10.000000000 +0900 @@ -19,10 +19,10 @@ #include "pci-sh4.h" static u8 rts7751r2d_irq_tab[] __initdata = { - IRQ_PCISLOT1, - IRQ_PCISLOT2, - IRQ_PCMCIA, - IRQ_PCIETH, + IRQ_PCI_INTA, + IRQ_PCI_INTB, + IRQ_PCI_INTC, + IRQ_PCI_INTD, }; int __init pcibios_map_platform_irq(struct pci_dev *pdev, u8 slot, u8 pin) --- 0002/include/asm-sh/rts7751r2d.h +++ work/include/asm-sh/rts7751r2d.h 2007-08-02 20:50:10.000000000 +0900 @@ -9,7 +9,7 @@ * Renesas Technology Sales RTS7751R2D support */ -/* Box specific addresses. */ +/* Board specific addresses. */ #define PA_BCR 0xa4000000 /* FPGA */ #define PA_IRLMON 0xa4000002 /* Interrupt Status control */ @@ -20,19 +20,19 @@ #define PA_RTCCE 0xa400000c /* RTC(9701) Enable control */ #define PA_PCICD 0xa400000e /* PCI Extention detect control */ #define PA_VOYAGERRTS 0xa4000020 /* VOYAGER Reset control */ -#if defined(CONFIG_RTS7751R2D_REV11) -#define PA_AXRST 0xa4000022 /* AX_LAN Reset control */ -#define PA_CFRST 0xa4000024 /* CF Reset control */ -#define PA_ADMRTS 0xa4000026 /* SD Reset control */ -#define PA_EXTRST 0xa4000028 /* Extention Reset control */ -#define PA_CFCDINTCLR 0xa400002a /* CF Insert Interrupt clear */ -#else -#define PA_CFRST 0xa4000022 /* CF Reset control */ -#define PA_ADMRTS 0xa4000024 /* SD Reset control */ -#define PA_EXTRST 0xa4000026 /* Extention Reset control */ -#define PA_CFCDINTCLR 0xa4000028 /* CF Insert Interrupt clear */ -#define PA_KEYCTLCLR 0xa400002a /* Key Interrupt clear */ -#endif + +#define PA_R2D1_AXRST 0xa4000022 /* AX_LAN Reset control */ +#define PA_R2D1_CFRST 0xa4000024 /* CF Reset control */ +#define PA_R2D1_ADMRTS 0xa4000026 /* SD Reset control */ +#define PA_R2D1_EXTRST 0xa4000028 /* Extention Reset control */ +#define PA_R2D1_CFCDINTCLR 0xa400002a /* CF Insert Interrupt clear */ + +#define PA_R2DPLUS_CFRST 0xa4000022 /* CF Reset control */ +#define PA_R2DPLUS_ADMRTS 0xa4000024 /* SD Reset control */ +#define PA_R2DPLUS_EXTRST 0xa4000026 /* Extention Reset control */ +#define PA_R2DPLUS_CFCDINTCLR 0xa4000028 /* CF Insert Interrupt clear */ +#define PA_R2DPLUS_KEYCTLCLR 0xa400002a /* Key Interrupt clear */ + #define PA_POWOFF 0xa4000030 /* Board Power OFF control */ #define PA_VERREG 0xa4000032 /* FPGA Version Register */ #define PA_INPORT 0xa4000034 /* KEY Input Port control */ @@ -46,27 +46,22 @@ #define IRLCNTR1 (PA_BCR + 0) /* Interrupt Control Register1 */ -#if defined(CONFIG_RTS7751R2D_REV11) -#define IRQ_PCIETH 0 /* PCI Ethernet IRQ */ -#define IRQ_CFCARD 1 /* CF Card IRQ */ -#define IRQ_CFINST 2 /* CF Card Insert IRQ */ -#define IRQ_PCMCIA 3 /* PCMCIA IRQ */ -#define IRQ_VOYAGER 4 /* VOYAGER IRQ */ -#define IRQ_ONETH 5 /* On board Ethernet IRQ */ -#else -#define IRQ_KEYIN 0 /* Key Input IRQ */ -#define IRQ_PCIETH 1 /* PCI Ethernet IRQ */ -#define IRQ_CFCARD 2 /* CF Card IRQ */ -#define IRQ_CFINST 3 /* CF Card Insert IRQ */ -#define IRQ_PCMCIA 4 /* PCMCIA IRQ */ -#define IRQ_VOYAGER 5 /* VOYAGER IRQ */ -#endif -#define IRQ_RTCALM 6 /* RTC Alarm IRQ */ -#define IRQ_RTCTIME 7 /* RTC Timer IRQ */ -#define IRQ_SDCARD 8 /* SD Card IRQ */ -#define IRQ_PCISLOT1 9 /* PCI Slot #1 IRQ */ -#define IRQ_PCISLOT2 10 /* PCI Slot #2 IRQ */ -#define IRQ_EXTENTION 11 /* EXTn IRQ */ +#define R2D_FPGA_IRQ_BASE 100 + +#define IRQ_VOYAGER (R2D_FPGA_IRQ_BASE + 0) +#define IRQ_EXT (R2D_FPGA_IRQ_BASE + 1) +#define IRQ_TP (R2D_FPGA_IRQ_BASE + 2) +#define IRQ_RTC_T (R2D_FPGA_IRQ_BASE + 3) +#define IRQ_RTC_A (R2D_FPGA_IRQ_BASE + 4) +#define IRQ_SDCARD (R2D_FPGA_IRQ_BASE + 5) +#define IRQ_CF_CD (R2D_FPGA_IRQ_BASE + 6) +#define IRQ_CF_IDE (R2D_FPGA_IRQ_BASE + 7) +#define IRQ_AX88796 (R2D_FPGA_IRQ_BASE + 8) +#define IRQ_KEY (R2D_FPGA_IRQ_BASE + 9) +#define IRQ_PCI_INTA (R2D_FPGA_IRQ_BASE + 10) +#define IRQ_PCI_INTB (R2D_FPGA_IRQ_BASE + 11) +#define IRQ_PCI_INTC (R2D_FPGA_IRQ_BASE + 12) +#define IRQ_PCI_INTD (R2D_FPGA_IRQ_BASE + 13) /* arch/sh/boards/renesas/rts7751r2d/irq.c */ void init_rts7751r2d_IRQ(void); |
From: Paul M. <le...@li...> - 2007-08-03 05:07:09
|
On Fri, Aug 03, 2007 at 01:32:58PM +0900, Magnus Damm wrote: > sh: intc - convert board specific r2d code > > This patch converts the board specific interrupt code for r2d to make use of > intc. While at it we remove CONFIG_RTS7751R2D_REV11 to avoid confusion and > to support both R2D-1 and R2D-PLUS boards using the same binary. > > - Two sets of interrupt tables exist - one for R2D-1 and one for R2D-PLUS. > - R2D-1 and R2D-PLUS use the same irq constants. > - R2D-1 has AX88796 support, R2D-PLUS does not hook up that IRQ. > - R2D-PLUS has KEY support, R2D-1 does not hook up that IRQ. > - The number and order of IRQ values are disconnected from register bits. > - Interrupt sources now start from IRQ 100. > - The machvec demux function converts from irlm IRQ 0-14 to IRQ 100++. > > Tested on R2D-1 and R2D-PLUS boards. > Hmm.. While it's an interesting approach, not having these as initdata is worrying. We only require one set of IRL<->IRQ mappings, vector/mask information, etc. and as these are quite weighty to begin with, we do not want to be making this an exponential thing when there are board revisions. I can live with having the tables present and discarding the unused ones, but not having all of the unused tables resident (you'll just have to flag them all as initdata and copy out the tables you care about, as per the version register). The kernel is bloated enough without adding to it. |
From: Magnus D. <mag...@gm...> - 2007-08-03 08:02:38
|
On 8/3/07, Paul Mundt <le...@li...> wrote: > On Fri, Aug 03, 2007 at 01:32:58PM +0900, Magnus Damm wrote: > > sh: intc - convert board specific r2d code > > > > This patch converts the board specific interrupt code for r2d to make use of > > intc. While at it we remove CONFIG_RTS7751R2D_REV11 to avoid confusion and > > to support both R2D-1 and R2D-PLUS boards using the same binary. > > > > - Two sets of interrupt tables exist - one for R2D-1 and one for R2D-PLUS. > > - R2D-1 and R2D-PLUS use the same irq constants. > > - R2D-1 has AX88796 support, R2D-PLUS does not hook up that IRQ. > > - R2D-PLUS has KEY support, R2D-1 does not hook up that IRQ. > > - The number and order of IRQ values are disconnected from register bits. > > - Interrupt sources now start from IRQ 100. > > - The machvec demux function converts from irlm IRQ 0-14 to IRQ 100++. > > > > Tested on R2D-1 and R2D-PLUS boards. > > > Hmm.. While it's an interesting approach, not having these as initdata is > worrying. We only require one set of IRL<->IRQ mappings, vector/mask > information, etc. and as these are quite weighty to begin with, we do not > want to be making this an exponential thing when there are board > revisions. I can live with having the tables present and discarding the > unused ones, but not having all of the unused tables resident (you'll > just have to flag them all as initdata and copy out the tables you care > about, as per the version register). The kernel is bloated enough without > adding to it. One side of me agrees with you that this approach doesn't scale and we should be concerned about the memory footprint. Another side thinks that this a development platform and if we use a few kilobytes more memory it's not the end of the world. Especially if it is makes maintaining these boards an easier task. And regarding the scalability - that we can fix that when it becomes a problem. OTOH, I do think you are right that having the tables as initdata would make sense. Maybe converting the intc code to copy out the needed tables would be nice... That way we can mark all intc tables as initdata. Regarding R2D-1 and R2D-PLUS support - after thinking a bit I must say that this is most likely exactly what we should use multiple machvecs for. If we could combine multiple machvecs with a probe() or something that can detect boards, then we could just have two separate boards - one for R2D-1 and one for R2D-PLUS. That would make sense for highlander as well... / magnus |