Path: blob/master/arch/mn10300/unit-asb2364/irq-fpga.c
10817 views
/* ASB2364 FPGA interrupt multiplexing1*2* Copyright (C) 2010 Red Hat, Inc. All Rights Reserved.3* Written by David Howells ([email protected])4*5* This program is free software; you can redistribute it and/or6* modify it under the terms of the GNU General Public Licence7* as published by the Free Software Foundation; either version8* 2 of the Licence, or (at your option) any later version.9*/1011#include <linux/interrupt.h>12#include <linux/init.h>13#include <linux/irq.h>14#include <unit/fpga-regs.h>1516/*17* FPGA PIC operations18*/19static void asb2364_fpga_mask(struct irq_data *d)20{21ASB2364_FPGA_REG_MASK(d->irq - NR_CPU_IRQS) = 0x0001;22SyncExBus();23}2425static void asb2364_fpga_ack(struct irq_data *d)26{27ASB2364_FPGA_REG_IRQ(d->irq - NR_CPU_IRQS) = 0x0001;28SyncExBus();29}3031static void asb2364_fpga_mask_ack(struct irq_data *d)32{33ASB2364_FPGA_REG_MASK(d->irq - NR_CPU_IRQS) = 0x0001;34SyncExBus();35ASB2364_FPGA_REG_IRQ(d->irq - NR_CPU_IRQS) = 0x0001;36SyncExBus();37}3839static void asb2364_fpga_unmask(struct irq_data *d)40{41ASB2364_FPGA_REG_MASK(d->irq - NR_CPU_IRQS) = 0x0000;42SyncExBus();43}4445static struct irq_chip asb2364_fpga_pic = {46.name = "fpga",47.irq_ack = asb2364_fpga_ack,48.irq_mask = asb2364_fpga_mask,49.irq_mask_ack = asb2364_fpga_mask_ack,50.irq_unmask = asb2364_fpga_unmask,51};5253/*54* FPGA PIC interrupt handler55*/56static irqreturn_t fpga_interrupt(int irq, void *_mask)57{58if ((ASB2364_FPGA_REG_IRQ_LAN & 0x0001) != 0x0001)59generic_handle_irq(FPGA_LAN_IRQ);60if ((ASB2364_FPGA_REG_IRQ_UART & 0x0001) != 0x0001)61generic_handle_irq(FPGA_UART_IRQ);62if ((ASB2364_FPGA_REG_IRQ_I2C & 0x0001) != 0x0001)63generic_handle_irq(FPGA_I2C_IRQ);64if ((ASB2364_FPGA_REG_IRQ_USB & 0x0001) != 0x0001)65generic_handle_irq(FPGA_USB_IRQ);66if ((ASB2364_FPGA_REG_IRQ_FPGA & 0x0001) != 0x0001)67generic_handle_irq(FPGA_FPGA_IRQ);6869return IRQ_HANDLED;70}7172/*73* Define an interrupt action for each FPGA PIC output74*/75static struct irqaction fpga_irq[] = {76[0] = {77.handler = fpga_interrupt,78.flags = IRQF_DISABLED | IRQF_SHARED,79.name = "fpga",80},81};8283/*84* Initialise the FPGA's PIC85*/86void __init irq_fpga_init(void)87{88int irq;8990ASB2364_FPGA_REG_MASK_LAN = 0x0001;91SyncExBus();92ASB2364_FPGA_REG_MASK_UART = 0x0001;93SyncExBus();94ASB2364_FPGA_REG_MASK_I2C = 0x0001;95SyncExBus();96ASB2364_FPGA_REG_MASK_USB = 0x0001;97SyncExBus();98ASB2364_FPGA_REG_MASK_FPGA = 0x0001;99SyncExBus();100101for (irq = NR_CPU_IRQS; irq < NR_IRQS; irq++)102irq_set_chip_and_handler(irq, &asb2364_fpga_pic,103handle_level_irq);104105/* the FPGA drives the XIRQ1 input on the CPU PIC */106setup_irq(XIRQ1, &fpga_irq[0]);107}108109110