2011-01-04 23:28:14 +03:00
|
|
|
/*
|
|
|
|
* Atheros AR71xx/AR724x/AR913x specific interrupt handling
|
|
|
|
*
|
2012-03-14 13:45:24 +04:00
|
|
|
* Copyright (C) 2008-2011 Gabor Juhos <juhosg@openwrt.org>
|
2011-01-04 23:28:14 +03:00
|
|
|
* Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
|
|
|
|
*
|
|
|
|
* Parts of this file are based on Atheros' 2.6.15 BSP
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License version 2 as published
|
|
|
|
* by the Free Software Foundation.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/irq.h>
|
|
|
|
|
|
|
|
#include <asm/irq_cpu.h>
|
|
|
|
#include <asm/mipsregs.h>
|
|
|
|
|
|
|
|
#include <asm/mach-ath79/ath79.h>
|
|
|
|
#include <asm/mach-ath79/ar71xx_regs.h>
|
|
|
|
#include "common.h"
|
|
|
|
|
2012-03-14 13:45:24 +04:00
|
|
|
static void (*ath79_ip2_handler)(void);
|
|
|
|
static void (*ath79_ip3_handler)(void);
|
2011-01-04 23:28:14 +03:00
|
|
|
|
|
|
|
static void ath79_misc_irq_handler(unsigned int irq, struct irq_desc *desc)
|
|
|
|
{
|
|
|
|
void __iomem *base = ath79_reset_base;
|
|
|
|
u32 pending;
|
|
|
|
|
|
|
|
pending = __raw_readl(base + AR71XX_RESET_REG_MISC_INT_STATUS) &
|
|
|
|
__raw_readl(base + AR71XX_RESET_REG_MISC_INT_ENABLE);
|
|
|
|
|
|
|
|
if (pending & MISC_INT_UART)
|
|
|
|
generic_handle_irq(ATH79_MISC_IRQ_UART);
|
|
|
|
|
|
|
|
else if (pending & MISC_INT_DMA)
|
|
|
|
generic_handle_irq(ATH79_MISC_IRQ_DMA);
|
|
|
|
|
|
|
|
else if (pending & MISC_INT_PERFC)
|
|
|
|
generic_handle_irq(ATH79_MISC_IRQ_PERFC);
|
|
|
|
|
|
|
|
else if (pending & MISC_INT_TIMER)
|
|
|
|
generic_handle_irq(ATH79_MISC_IRQ_TIMER);
|
|
|
|
|
2011-06-06 01:38:45 +04:00
|
|
|
else if (pending & MISC_INT_TIMER2)
|
|
|
|
generic_handle_irq(ATH79_MISC_IRQ_TIMER2);
|
|
|
|
|
|
|
|
else if (pending & MISC_INT_TIMER3)
|
|
|
|
generic_handle_irq(ATH79_MISC_IRQ_TIMER3);
|
|
|
|
|
|
|
|
else if (pending & MISC_INT_TIMER4)
|
|
|
|
generic_handle_irq(ATH79_MISC_IRQ_TIMER4);
|
|
|
|
|
2011-01-04 23:28:14 +03:00
|
|
|
else if (pending & MISC_INT_OHCI)
|
|
|
|
generic_handle_irq(ATH79_MISC_IRQ_OHCI);
|
|
|
|
|
|
|
|
else if (pending & MISC_INT_ERROR)
|
|
|
|
generic_handle_irq(ATH79_MISC_IRQ_ERROR);
|
|
|
|
|
|
|
|
else if (pending & MISC_INT_GPIO)
|
|
|
|
generic_handle_irq(ATH79_MISC_IRQ_GPIO);
|
|
|
|
|
|
|
|
else if (pending & MISC_INT_WDOG)
|
|
|
|
generic_handle_irq(ATH79_MISC_IRQ_WDOG);
|
|
|
|
|
2011-06-06 01:38:45 +04:00
|
|
|
else if (pending & MISC_INT_ETHSW)
|
|
|
|
generic_handle_irq(ATH79_MISC_IRQ_ETHSW);
|
|
|
|
|
2011-01-04 23:28:14 +03:00
|
|
|
else
|
|
|
|
spurious_interrupt();
|
|
|
|
}
|
|
|
|
|
2011-03-24 00:08:47 +03:00
|
|
|
static void ar71xx_misc_irq_unmask(struct irq_data *d)
|
2011-01-04 23:28:14 +03:00
|
|
|
{
|
2011-03-24 00:08:47 +03:00
|
|
|
unsigned int irq = d->irq - ATH79_MISC_IRQ_BASE;
|
2011-01-04 23:28:14 +03:00
|
|
|
void __iomem *base = ath79_reset_base;
|
|
|
|
u32 t;
|
|
|
|
|
|
|
|
t = __raw_readl(base + AR71XX_RESET_REG_MISC_INT_ENABLE);
|
|
|
|
__raw_writel(t | (1 << irq), base + AR71XX_RESET_REG_MISC_INT_ENABLE);
|
|
|
|
|
|
|
|
/* flush write */
|
|
|
|
__raw_readl(base + AR71XX_RESET_REG_MISC_INT_ENABLE);
|
|
|
|
}
|
|
|
|
|
2011-03-24 00:08:47 +03:00
|
|
|
static void ar71xx_misc_irq_mask(struct irq_data *d)
|
2011-01-04 23:28:14 +03:00
|
|
|
{
|
2011-03-24 00:08:47 +03:00
|
|
|
unsigned int irq = d->irq - ATH79_MISC_IRQ_BASE;
|
2011-01-04 23:28:14 +03:00
|
|
|
void __iomem *base = ath79_reset_base;
|
|
|
|
u32 t;
|
|
|
|
|
|
|
|
t = __raw_readl(base + AR71XX_RESET_REG_MISC_INT_ENABLE);
|
|
|
|
__raw_writel(t & ~(1 << irq), base + AR71XX_RESET_REG_MISC_INT_ENABLE);
|
|
|
|
|
|
|
|
/* flush write */
|
|
|
|
__raw_readl(base + AR71XX_RESET_REG_MISC_INT_ENABLE);
|
|
|
|
}
|
|
|
|
|
2011-03-24 00:08:47 +03:00
|
|
|
static void ar724x_misc_irq_ack(struct irq_data *d)
|
2011-01-04 23:28:14 +03:00
|
|
|
{
|
2011-03-24 00:08:47 +03:00
|
|
|
unsigned int irq = d->irq - ATH79_MISC_IRQ_BASE;
|
2011-01-04 23:28:14 +03:00
|
|
|
void __iomem *base = ath79_reset_base;
|
|
|
|
u32 t;
|
|
|
|
|
|
|
|
t = __raw_readl(base + AR71XX_RESET_REG_MISC_INT_STATUS);
|
|
|
|
__raw_writel(t & ~(1 << irq), base + AR71XX_RESET_REG_MISC_INT_STATUS);
|
|
|
|
|
|
|
|
/* flush write */
|
|
|
|
__raw_readl(base + AR71XX_RESET_REG_MISC_INT_STATUS);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct irq_chip ath79_misc_irq_chip = {
|
|
|
|
.name = "MISC",
|
2011-03-24 00:08:47 +03:00
|
|
|
.irq_unmask = ar71xx_misc_irq_unmask,
|
|
|
|
.irq_mask = ar71xx_misc_irq_mask,
|
2011-01-04 23:28:14 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
static void __init ath79_misc_irq_init(void)
|
|
|
|
{
|
|
|
|
void __iomem *base = ath79_reset_base;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
__raw_writel(0, base + AR71XX_RESET_REG_MISC_INT_ENABLE);
|
|
|
|
__raw_writel(0, base + AR71XX_RESET_REG_MISC_INT_STATUS);
|
|
|
|
|
|
|
|
if (soc_is_ar71xx() || soc_is_ar913x())
|
2011-03-24 00:08:47 +03:00
|
|
|
ath79_misc_irq_chip.irq_mask_ack = ar71xx_misc_irq_mask;
|
2011-06-20 23:26:06 +04:00
|
|
|
else if (soc_is_ar724x() || soc_is_ar933x())
|
2011-03-24 00:08:47 +03:00
|
|
|
ath79_misc_irq_chip.irq_ack = ar724x_misc_irq_ack;
|
2011-01-04 23:28:14 +03:00
|
|
|
else
|
|
|
|
BUG();
|
|
|
|
|
|
|
|
for (i = ATH79_MISC_IRQ_BASE;
|
|
|
|
i < ATH79_MISC_IRQ_BASE + ATH79_MISC_IRQ_COUNT; i++) {
|
2011-03-27 17:19:28 +04:00
|
|
|
irq_set_chip_and_handler(i, &ath79_misc_irq_chip,
|
2011-01-04 23:28:14 +03:00
|
|
|
handle_level_irq);
|
|
|
|
}
|
|
|
|
|
2011-03-27 17:19:28 +04:00
|
|
|
irq_set_chained_handler(ATH79_CPU_IRQ_MISC, ath79_misc_irq_handler);
|
2011-01-04 23:28:14 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
asmlinkage void plat_irq_dispatch(void)
|
|
|
|
{
|
|
|
|
unsigned long pending;
|
|
|
|
|
|
|
|
pending = read_c0_status() & read_c0_cause() & ST0_IM;
|
|
|
|
|
|
|
|
if (pending & STATUSF_IP7)
|
|
|
|
do_IRQ(ATH79_CPU_IRQ_TIMER);
|
|
|
|
|
2012-03-14 13:45:24 +04:00
|
|
|
else if (pending & STATUSF_IP2)
|
|
|
|
ath79_ip2_handler();
|
2011-01-04 23:28:14 +03:00
|
|
|
|
|
|
|
else if (pending & STATUSF_IP4)
|
|
|
|
do_IRQ(ATH79_CPU_IRQ_GE0);
|
|
|
|
|
|
|
|
else if (pending & STATUSF_IP5)
|
|
|
|
do_IRQ(ATH79_CPU_IRQ_GE1);
|
|
|
|
|
2012-03-14 13:45:24 +04:00
|
|
|
else if (pending & STATUSF_IP3)
|
|
|
|
ath79_ip3_handler();
|
2011-01-04 23:28:14 +03:00
|
|
|
|
|
|
|
else if (pending & STATUSF_IP6)
|
|
|
|
do_IRQ(ATH79_CPU_IRQ_MISC);
|
|
|
|
|
|
|
|
else
|
|
|
|
spurious_interrupt();
|
|
|
|
}
|
|
|
|
|
2012-03-14 13:45:24 +04:00
|
|
|
/*
|
|
|
|
* The IP2/IP3 lines are tied to a PCI/WMAC/USB device. Drivers for
|
|
|
|
* these devices typically allocate coherent DMA memory, however the
|
|
|
|
* DMA controller may still have some unsynchronized data in the FIFO.
|
|
|
|
* Issue a flush in the handlers to ensure that the driver sees
|
|
|
|
* the update.
|
|
|
|
*/
|
|
|
|
static void ar71xx_ip2_handler(void)
|
|
|
|
{
|
|
|
|
ath79_ddr_wb_flush(AR71XX_DDR_REG_FLUSH_PCI);
|
|
|
|
do_IRQ(ATH79_CPU_IRQ_IP2);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ar724x_ip2_handler(void)
|
|
|
|
{
|
|
|
|
ath79_ddr_wb_flush(AR724X_DDR_REG_FLUSH_PCIE);
|
|
|
|
do_IRQ(ATH79_CPU_IRQ_IP2);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ar913x_ip2_handler(void)
|
|
|
|
{
|
|
|
|
ath79_ddr_wb_flush(AR913X_DDR_REG_FLUSH_WMAC);
|
|
|
|
do_IRQ(ATH79_CPU_IRQ_IP2);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ar933x_ip2_handler(void)
|
|
|
|
{
|
|
|
|
ath79_ddr_wb_flush(AR933X_DDR_REG_FLUSH_WMAC);
|
|
|
|
do_IRQ(ATH79_CPU_IRQ_IP2);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ar71xx_ip3_handler(void)
|
|
|
|
{
|
|
|
|
ath79_ddr_wb_flush(AR71XX_DDR_REG_FLUSH_USB);
|
|
|
|
do_IRQ(ATH79_CPU_IRQ_USB);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ar724x_ip3_handler(void)
|
|
|
|
{
|
|
|
|
ath79_ddr_wb_flush(AR724X_DDR_REG_FLUSH_USB);
|
|
|
|
do_IRQ(ATH79_CPU_IRQ_USB);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ar913x_ip3_handler(void)
|
|
|
|
{
|
|
|
|
ath79_ddr_wb_flush(AR913X_DDR_REG_FLUSH_USB);
|
|
|
|
do_IRQ(ATH79_CPU_IRQ_USB);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ar933x_ip3_handler(void)
|
|
|
|
{
|
|
|
|
ath79_ddr_wb_flush(AR933X_DDR_REG_FLUSH_USB);
|
|
|
|
do_IRQ(ATH79_CPU_IRQ_USB);
|
|
|
|
}
|
|
|
|
|
2011-01-04 23:28:14 +03:00
|
|
|
void __init arch_init_irq(void)
|
|
|
|
{
|
|
|
|
if (soc_is_ar71xx()) {
|
2012-03-14 13:45:24 +04:00
|
|
|
ath79_ip2_handler = ar71xx_ip2_handler;
|
|
|
|
ath79_ip3_handler = ar71xx_ip3_handler;
|
2011-01-04 23:28:14 +03:00
|
|
|
} else if (soc_is_ar724x()) {
|
2012-03-14 13:45:24 +04:00
|
|
|
ath79_ip2_handler = ar724x_ip2_handler;
|
|
|
|
ath79_ip3_handler = ar724x_ip3_handler;
|
2011-01-04 23:28:14 +03:00
|
|
|
} else if (soc_is_ar913x()) {
|
2012-03-14 13:45:24 +04:00
|
|
|
ath79_ip2_handler = ar913x_ip2_handler;
|
|
|
|
ath79_ip3_handler = ar913x_ip3_handler;
|
2011-06-20 23:26:06 +04:00
|
|
|
} else if (soc_is_ar933x()) {
|
2012-03-14 13:45:24 +04:00
|
|
|
ath79_ip2_handler = ar933x_ip2_handler;
|
|
|
|
ath79_ip3_handler = ar933x_ip3_handler;
|
|
|
|
} else {
|
2011-01-04 23:28:14 +03:00
|
|
|
BUG();
|
2012-03-14 13:45:24 +04:00
|
|
|
}
|
2011-01-04 23:28:14 +03:00
|
|
|
|
|
|
|
cp0_perfcount_irq = ATH79_MISC_IRQ_PERFC;
|
|
|
|
mips_cpu_irq_init();
|
|
|
|
ath79_misc_irq_init();
|
|
|
|
}
|