Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[ARM] locomo: allow cascaded IRQ base to be specified by platforms

Signed-off-by: Eric Miao <eric.y.miao@gmail.com>

Eric Miao ac609d26 00dd8027

+48 -39
+30 -23
arch/arm/common/locomo.c
··· 32 32 33 33 #include <asm/hardware/locomo.h> 34 34 35 + /* LoCoMo Interrupts */ 36 + #define IRQ_LOCOMO_KEY (0) 37 + #define IRQ_LOCOMO_GPIO (1) 38 + #define IRQ_LOCOMO_LT (2) 39 + #define IRQ_LOCOMO_SPI (3) 40 + 35 41 /* M62332 output channel selection */ 36 42 #define M62332_EVR_CH 1 /* M62332 volume channel number */ 37 43 /* 0 : CH.1 , 1 : CH. 2 */ ··· 64 58 struct device *dev; 65 59 unsigned long phys; 66 60 unsigned int irq; 61 + int irq_base; 67 62 spinlock_t lock; 68 63 void __iomem *base; 69 64 #ifdef CONFIG_PM ··· 88 81 static struct locomo_dev_info locomo_devices[] = { 89 82 { 90 83 .devid = LOCOMO_DEVID_KEYBOARD, 91 - .irq = { 92 - IRQ_LOCOMO_KEY, 93 - }, 84 + .irq = { IRQ_LOCOMO_KEY }, 94 85 .name = "locomo-keyboard", 95 86 .offset = LOCOMO_KEYBOARD, 96 87 .length = 16, ··· 140 135 141 136 static void locomo_handler(unsigned int irq, struct irq_desc *desc) 142 137 { 138 + struct locomo *lchip = get_irq_chip_data(irq); 143 139 int req, i; 144 - void __iomem *mapbase = get_irq_chip_data(irq); 145 140 146 141 /* Acknowledge the parent IRQ */ 147 142 desc->chip->ack(irq); 148 143 149 144 /* check why this interrupt was generated */ 150 - req = locomo_readl(mapbase + LOCOMO_ICR) & 0x0f00; 145 + req = locomo_readl(lchip->base + LOCOMO_ICR) & 0x0f00; 151 146 152 147 if (req) { 153 148 /* generate the next interrupt(s) */ 154 - irq = IRQ_LOCOMO_KEY; 149 + irq = lchip->irq_base; 155 150 for (i = 0; i <= 3; i++, irq++) { 156 151 if (req & (0x0100 << i)) { 157 152 generic_handle_irq(irq); ··· 167 162 168 163 static void locomo_mask_irq(unsigned int irq) 169 164 { 170 - void __iomem *mapbase = get_irq_chip_data(irq); 165 + struct locomo *lchip = get_irq_chip_data(irq); 171 166 unsigned int r; 172 - r = locomo_readl(mapbase + LOCOMO_ICR); 173 - r &= ~(0x0010 << (irq - IRQ_LOCOMO_KEY)); 174 - locomo_writel(r, mapbase + LOCOMO_ICR); 167 + r = locomo_readl(lchip->base + LOCOMO_ICR); 168 + r &= ~(0x0010 << (irq - lchip->irq_base)); 169 + locomo_writel(r, lchip->base + LOCOMO_ICR); 175 170 } 176 171 177 172 static void locomo_unmask_irq(unsigned int irq) 178 173 { 179 - void __iomem *mapbase = get_irq_chip_data(irq); 174 + struct locomo *lchip = get_irq_chip_data(irq); 180 175 unsigned int r; 181 - r = locomo_readl(mapbase + LOCOMO_ICR); 182 - r |= (0x0010 << (irq - IRQ_LOCOMO_KEY)); 183 - locomo_writel(r, mapbase + LOCOMO_ICR); 176 + r = locomo_readl(lchip->base + LOCOMO_ICR); 177 + r |= (0x0010 << (irq - lchip->irq_base)); 178 + locomo_writel(r, lchip->base + LOCOMO_ICR); 184 179 } 185 180 186 181 static struct irq_chip locomo_chip = { ··· 192 187 193 188 static void locomo_setup_irq(struct locomo *lchip) 194 189 { 195 - int irq; 196 - void __iomem *irqbase = lchip->base; 190 + int irq = lchip->irq_base; 197 191 198 192 /* 199 193 * Install handler for IRQ_LOCOMO_HW. 200 194 */ 201 195 set_irq_type(lchip->irq, IRQ_TYPE_EDGE_FALLING); 202 - set_irq_chip_data(lchip->irq, irqbase); 196 + set_irq_chip_data(lchip->irq, lchip); 203 197 set_irq_chained_handler(lchip->irq, locomo_handler); 204 198 205 - /* install handlers for IRQ_LOCOMO_* */ 206 - for (irq = IRQ_LOCOMO_KEY; irq < IRQ_LOCOMO_KEY + 4; irq++) { 199 + /* Install handlers for IRQ_LOCOMO_* */ 200 + for ( ; irq <= lchip->irq_base + 3; irq++) { 207 201 set_irq_chip(irq, &locomo_chip); 208 - set_irq_chip_data(irq, irqbase); 209 - set_irq_handler(irq, handle_edge_irq); 202 + set_irq_chip_data(irq, lchip); 203 + set_irq_handler(irq, handle_level_irq); 210 204 set_irq_flags(irq, IRQF_VALID | IRQF_PROBE); 211 205 } 212 206 } ··· 252 248 dev->mapbase = 0; 253 249 dev->length = info->length; 254 250 255 - memmove(dev->irq, info->irq, sizeof(dev->irq)); 251 + dev->irq[0] = (lchip->irq_base == NO_IRQ) ? 252 + NO_IRQ : lchip->irq_base + info->irq[0]; 256 253 257 254 ret = device_register(&dev->dev); 258 255 if (ret) { ··· 370 365 static int 371 366 __locomo_probe(struct device *me, struct resource *mem, int irq) 372 367 { 368 + struct locomo_platform_data *pdata = me->platform_data; 373 369 struct locomo *lchip; 374 370 unsigned long r; 375 371 int i, ret = -ENODEV; ··· 386 380 387 381 lchip->phys = mem->start; 388 382 lchip->irq = irq; 383 + lchip->irq_base = (pdata) ? pdata->irq_base : NO_IRQ; 389 384 390 385 /* 391 386 * Map the whole region. This also maps the ··· 453 446 * The interrupt controller must be initialised before any 454 447 * other device to ensure that the interrupts are available. 455 448 */ 456 - if (lchip->irq != NO_IRQ) 449 + if (lchip->irq != NO_IRQ && lchip->irq_base != NO_IRQ) 457 450 locomo_setup_irq(lchip); 458 451 459 452 for (i = 0; i < ARRAY_SIZE(locomo_devices); i++)
+4
arch/arm/include/asm/hardware/locomo.h
··· 214 214 /* Frontlight control */ 215 215 void locomo_frontlight_set(struct locomo_dev *dev, int duty, int vr, int bpwf); 216 216 217 + struct locomo_platform_data { 218 + int irq_base; /* IRQ base for cascaded on-chip IRQs */ 219 + }; 220 + 217 221 #endif
-6
arch/arm/mach-pxa/include/mach/irqs.h
··· 247 247 #define BALLOON3_CODEC_IRQ IRQ_GPIO(BALLOON3_GPIO_CODEC_IRQ) 248 248 #define BALLOON3_S0_CD_IRQ IRQ_GPIO(BALLOON3_GPIO_S0_CD) 249 249 250 - /* LoCoMo Interrupts (CONFIG_SHARP_LOCOMO) */ 251 - #define IRQ_LOCOMO_KEY (IRQ_BOARD_START + 0) 252 - #define IRQ_LOCOMO_GPIO (IRQ_BOARD_START + 1) 253 - #define IRQ_LOCOMO_LT (IRQ_BOARD_START + 2) 254 - #define IRQ_LOCOMO_SPI (IRQ_BOARD_START + 3) 255 - 256 250 /* phyCORE-PXA270 (PCM027) Interrupts */ 257 251 #define PCM027_IRQ(x) (IRQ_BOARD_START + (x)) 258 252 #define PCM027_BTDET_IRQ PCM027_IRQ(0)
+7
arch/arm/mach-pxa/poodle.c
··· 174 174 }, 175 175 }; 176 176 177 + static struct locomo_platform_data locomo_info = { 178 + .irq_base = IRQ_BOARD_START, 179 + }; 180 + 177 181 struct platform_device poodle_locomo_device = { 178 182 .name = "locomo", 179 183 .id = 0, 180 184 .num_resources = ARRAY_SIZE(locomo_resources), 181 185 .resource = locomo_resources, 186 + .dev = { 187 + .platform_data = &locomo_info, 188 + }, 182 189 }; 183 190 184 191 EXPORT_SYMBOL(poodle_locomo_device);
+4
arch/arm/mach-sa1100/collie.c
··· 234 234 }, 235 235 }; 236 236 237 + static struct locomo_platform_data locomo_info = { 238 + .irq_base = IRQ_BOARD_START, 239 + }; 240 + 237 241 struct platform_device collie_locomo_device = { 238 242 .name = "locomo", 239 243 .id = 0,
+3 -10
arch/arm/mach-sa1100/include/mach/irqs.h
··· 124 124 * Figure out the MAX IRQ number. 125 125 * 126 126 * If we have an SA1111, the max IRQ is S1_BVD1_STSCHG+1. 127 - * If we have an LoCoMo, the max IRQ is IRQ_LOCOMO_SPI_TEND+1 127 + * If we have an LoCoMo, the max IRQ is IRQ_BOARD_START + 4 128 128 * Otherwise, we have the standard IRQs only. 129 129 */ 130 130 #ifdef CONFIG_SA1111 131 131 #define NR_IRQS (IRQ_S1_BVD1_STSCHG + 1) 132 - #elif defined(CONFIG_SHARP_LOCOMO) 133 - #define NR_IRQS (IRQ_LOCOMO_SPI + 1) 132 + #elif defined(CONFIG_SHARPSL_LOCOMO) 133 + #define NR_IRQS (IRQ_BOARD_START + 4) 134 134 #else 135 135 #define NR_IRQS (IRQ_BOARD_START) 136 136 #endif ··· 142 142 #define IRQ_NEPONSET_SMC9196 (IRQ_BOARD_START + 0) 143 143 #define IRQ_NEPONSET_USAR (IRQ_BOARD_START + 1) 144 144 #define IRQ_NEPONSET_SA1111 (IRQ_BOARD_START + 2) 145 - 146 - /* LoCoMo Interrupts (CONFIG_SHARP_LOCOMO) */ 147 - #define IRQ_LOCOMO_KEY (IRQ_BOARD_START + 0) 148 - #define IRQ_LOCOMO_GPIO_BASE (IRQ_BOARD_START + 1) 149 - #define IRQ_LOCOMO_LT_BASE (IRQ_BOARD_START + 2) 150 - #define IRQ_LOCOMO_SPI_BASE (IRQ_BOARD_START + 3) 151 -