diff options
| author | Gabor Juhos <juhosg@openwrt.org> | 2013-02-07 14:29:38 -0500 |
|---|---|---|
| committer | John Crispin <blogic@openwrt.org> | 2013-02-16 19:25:41 -0500 |
| commit | 326e8d17d73fdf213f6334917ef46b2ba7b1354a (patch) | |
| tree | c26b483da6be3feabac0da03c891a683a50cf60c | |
| parent | 42cb60d1fab4c81ef24876d985e08fc5bb899e41 (diff) | |
MIPS: pci-ar71xx: move irq base to the controller structure
Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Patchwork: http://patchwork.linux-mips.org/patch/4928/
Signed-off-by: John Crispin <blogic@openwrt.org>
| -rw-r--r-- | arch/mips/pci/pci-ar71xx.c | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/arch/mips/pci/pci-ar71xx.c b/arch/mips/pci/pci-ar71xx.c index e48dddbb4919..412ec025cf55 100644 --- a/arch/mips/pci/pci-ar71xx.c +++ b/arch/mips/pci/pci-ar71xx.c | |||
| @@ -52,6 +52,7 @@ struct ar71xx_pci_controller { | |||
| 52 | void __iomem *cfg_base; | 52 | void __iomem *cfg_base; |
| 53 | spinlock_t lock; | 53 | spinlock_t lock; |
| 54 | int irq; | 54 | int irq; |
| 55 | int irq_base; | ||
| 55 | struct pci_controller pci_ctrl; | 56 | struct pci_controller pci_ctrl; |
| 56 | struct resource io_res; | 57 | struct resource io_res; |
| 57 | struct resource mem_res; | 58 | struct resource mem_res; |
| @@ -238,23 +239,26 @@ static struct pci_ops ar71xx_pci_ops = { | |||
| 238 | 239 | ||
| 239 | static void ar71xx_pci_irq_handler(unsigned int irq, struct irq_desc *desc) | 240 | static void ar71xx_pci_irq_handler(unsigned int irq, struct irq_desc *desc) |
| 240 | { | 241 | { |
| 242 | struct ar71xx_pci_controller *apc; | ||
| 241 | void __iomem *base = ath79_reset_base; | 243 | void __iomem *base = ath79_reset_base; |
| 242 | u32 pending; | 244 | u32 pending; |
| 243 | 245 | ||
| 246 | apc = irq_get_handler_data(irq); | ||
| 247 | |||
| 244 | pending = __raw_readl(base + AR71XX_RESET_REG_PCI_INT_STATUS) & | 248 | pending = __raw_readl(base + AR71XX_RESET_REG_PCI_INT_STATUS) & |
| 245 | __raw_readl(base + AR71XX_RESET_REG_PCI_INT_ENABLE); | 249 | __raw_readl(base + AR71XX_RESET_REG_PCI_INT_ENABLE); |
| 246 | 250 | ||
| 247 | if (pending & AR71XX_PCI_INT_DEV0) | 251 | if (pending & AR71XX_PCI_INT_DEV0) |
| 248 | generic_handle_irq(ATH79_PCI_IRQ(0)); | 252 | generic_handle_irq(apc->irq_base + 0); |
| 249 | 253 | ||
| 250 | else if (pending & AR71XX_PCI_INT_DEV1) | 254 | else if (pending & AR71XX_PCI_INT_DEV1) |
| 251 | generic_handle_irq(ATH79_PCI_IRQ(1)); | 255 | generic_handle_irq(apc->irq_base + 1); |
| 252 | 256 | ||
| 253 | else if (pending & AR71XX_PCI_INT_DEV2) | 257 | else if (pending & AR71XX_PCI_INT_DEV2) |
| 254 | generic_handle_irq(ATH79_PCI_IRQ(2)); | 258 | generic_handle_irq(apc->irq_base + 2); |
| 255 | 259 | ||
| 256 | else if (pending & AR71XX_PCI_INT_CORE) | 260 | else if (pending & AR71XX_PCI_INT_CORE) |
| 257 | generic_handle_irq(ATH79_PCI_IRQ(4)); | 261 | generic_handle_irq(apc->irq_base + 4); |
| 258 | 262 | ||
| 259 | else | 263 | else |
| 260 | spurious_interrupt(); | 264 | spurious_interrupt(); |
| @@ -262,10 +266,14 @@ static void ar71xx_pci_irq_handler(unsigned int irq, struct irq_desc *desc) | |||
| 262 | 266 | ||
| 263 | static void ar71xx_pci_irq_unmask(struct irq_data *d) | 267 | static void ar71xx_pci_irq_unmask(struct irq_data *d) |
| 264 | { | 268 | { |
| 265 | unsigned int irq = d->irq - ATH79_PCI_IRQ_BASE; | 269 | struct ar71xx_pci_controller *apc; |
| 270 | unsigned int irq; | ||
| 266 | void __iomem *base = ath79_reset_base; | 271 | void __iomem *base = ath79_reset_base; |
| 267 | u32 t; | 272 | u32 t; |
| 268 | 273 | ||
| 274 | apc = irq_data_get_irq_chip_data(d); | ||
| 275 | irq = d->irq - apc->irq_base; | ||
| 276 | |||
| 269 | t = __raw_readl(base + AR71XX_RESET_REG_PCI_INT_ENABLE); | 277 | t = __raw_readl(base + AR71XX_RESET_REG_PCI_INT_ENABLE); |
| 270 | __raw_writel(t | (1 << irq), base + AR71XX_RESET_REG_PCI_INT_ENABLE); | 278 | __raw_writel(t | (1 << irq), base + AR71XX_RESET_REG_PCI_INT_ENABLE); |
| 271 | 279 | ||
| @@ -275,10 +283,14 @@ static void ar71xx_pci_irq_unmask(struct irq_data *d) | |||
| 275 | 283 | ||
| 276 | static void ar71xx_pci_irq_mask(struct irq_data *d) | 284 | static void ar71xx_pci_irq_mask(struct irq_data *d) |
| 277 | { | 285 | { |
| 278 | unsigned int irq = d->irq - ATH79_PCI_IRQ_BASE; | 286 | struct ar71xx_pci_controller *apc; |
| 287 | unsigned int irq; | ||
| 279 | void __iomem *base = ath79_reset_base; | 288 | void __iomem *base = ath79_reset_base; |
| 280 | u32 t; | 289 | u32 t; |
| 281 | 290 | ||
| 291 | apc = irq_data_get_irq_chip_data(d); | ||
| 292 | irq = d->irq - apc->irq_base; | ||
| 293 | |||
| 282 | t = __raw_readl(base + AR71XX_RESET_REG_PCI_INT_ENABLE); | 294 | t = __raw_readl(base + AR71XX_RESET_REG_PCI_INT_ENABLE); |
| 283 | __raw_writel(t & ~(1 << irq), base + AR71XX_RESET_REG_PCI_INT_ENABLE); | 295 | __raw_writel(t & ~(1 << irq), base + AR71XX_RESET_REG_PCI_INT_ENABLE); |
| 284 | 296 | ||
| @@ -303,11 +315,15 @@ static void ar71xx_pci_irq_init(struct ar71xx_pci_controller *apc) | |||
| 303 | 315 | ||
| 304 | BUILD_BUG_ON(ATH79_PCI_IRQ_COUNT < AR71XX_PCI_IRQ_COUNT); | 316 | BUILD_BUG_ON(ATH79_PCI_IRQ_COUNT < AR71XX_PCI_IRQ_COUNT); |
| 305 | 317 | ||
| 306 | for (i = ATH79_PCI_IRQ_BASE; | 318 | apc->irq_base = ATH79_PCI_IRQ_BASE; |
| 307 | i < ATH79_PCI_IRQ_BASE + AR71XX_PCI_IRQ_COUNT; i++) | 319 | for (i = apc->irq_base; |
| 320 | i < apc->irq_base + AR71XX_PCI_IRQ_COUNT; i++) { | ||
| 308 | irq_set_chip_and_handler(i, &ar71xx_pci_irq_chip, | 321 | irq_set_chip_and_handler(i, &ar71xx_pci_irq_chip, |
| 309 | handle_level_irq); | 322 | handle_level_irq); |
| 323 | irq_set_chip_data(i, apc); | ||
| 324 | } | ||
| 310 | 325 | ||
| 326 | irq_set_handler_data(apc->irq, apc); | ||
| 311 | irq_set_chained_handler(apc->irq, ar71xx_pci_irq_handler); | 327 | irq_set_chained_handler(apc->irq, ar71xx_pci_irq_handler); |
| 312 | } | 328 | } |
| 313 | 329 | ||
