diff options
author | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-05-12 18:11:33 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-05-12 18:11:33 -0700 |
commit | f7d02ae76ebbf5b8a9531fe150c49e126a397704 (patch) | |
tree | bcfdcab6e70658d55a3c843694e04e938bf9168f /arch/arm/mach-iop13xx/msi.c | |
parent | 78db2ad6f4df9145bfd6aab1c0f1c56d615288ec (diff) | |
parent | 158304ef09a28c7f2dd37d78f536a4e09ba084a1 (diff) |
Merge branch 'for-linus' of master.kernel.org:/home/rmk/linux-2.6-arm
* 'for-linus' of master.kernel.org:/home/rmk/linux-2.6-arm: (30 commits)
[ARM] Use new get_irqnr_preamble
[ARM] Ensure machine class menu is sorted alphabetically
[ARM] 4333/2: KS8695: Micrel Development board
[ARM] 4332/2: KS8695: Serial driver
[ARM] 4331/3: Support for Micrel/Kendin KS8695 processor
[ARM] 4371/1: AT91: Support for Atmel AT91SAM9RL-EK development board
[ARM] 4372/1: Define byte sizes in asm-arm/sizes.h
[ARM] 4370/3: AT91: Support for Atmel AT91SAM9RL processors.
[ARM] Update mach-types
[ARM] export symbol csum_partial_copy_from_user
[ARM] iop13xx: msi support
[ARM] stacktrace fix
[ARM] Spinlock initializer cleanup
[ARM] remove useless config option GENERIC_BUST_SPINLOCK
[ARM] 4303/3: base kernel support for TI DaVinci
[ARM] 4369/1: AT91: Fix circular dependency in header files
[ARM] 4368/1: S3C24xx: build fix
[ARM] 4364/1: AT91: LEDS on AT91SAM9261-EK
[ARM] Fix iop32x/iop33x build
[ARM] EBSA110: fix build errors caused by missing "const"
...
Diffstat (limited to 'arch/arm/mach-iop13xx/msi.c')
-rw-r--r-- | arch/arm/mach-iop13xx/msi.c | 194 |
1 files changed, 194 insertions, 0 deletions
diff --git a/arch/arm/mach-iop13xx/msi.c b/arch/arm/mach-iop13xx/msi.c new file mode 100644 index 00000000000..2d236930222 --- /dev/null +++ b/arch/arm/mach-iop13xx/msi.c @@ -0,0 +1,194 @@ +/* + * arch/arm/mach-iop13xx/msi.c + * + * PCI MSI support for the iop13xx processor + * + * Copyright (c) 2006, Intel Corporation. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., 59 Temple + * Place - Suite 330, Boston, MA 02111-1307 USA. + * + */ +#include <linux/pci.h> +#include <linux/msi.h> +#include <asm/mach/irq.h> +#include <asm/irq.h> + + +#define IOP13XX_NUM_MSI_IRQS 128 +static DECLARE_BITMAP(msi_irq_in_use, IOP13XX_NUM_MSI_IRQS); + +/* IMIPR0 CP6 R8 Page 1 + */ +static inline u32 read_imipr_0(void) +{ + u32 val; + asm volatile("mrc p6, 0, %0, c8, c1, 0":"=r" (val)); + return val; +} +static inline void write_imipr_0(u32 val) +{ + asm volatile("mcr p6, 0, %0, c8, c1, 0"::"r" (val)); +} + +/* IMIPR1 CP6 R9 Page 1 + */ +static inline u32 read_imipr_1(void) +{ + u32 val; + asm volatile("mrc p6, 0, %0, c9, c1, 0":"=r" (val)); + return val; +} +static inline void write_imipr_1(u32 val) +{ + asm volatile("mcr p6, 0, %0, c9, c1, 0"::"r" (val)); +} + +/* IMIPR2 CP6 R10 Page 1 + */ +static inline u32 read_imipr_2(void) +{ + u32 val; + asm volatile("mrc p6, 0, %0, c10, c1, 0":"=r" (val)); + return val; +} +static inline void write_imipr_2(u32 val) +{ + asm volatile("mcr p6, 0, %0, c10, c1, 0"::"r" (val)); +} + +/* IMIPR3 CP6 R11 Page 1 + */ +static inline u32 read_imipr_3(void) +{ + u32 val; + asm volatile("mrc p6, 0, %0, c11, c1, 0":"=r" (val)); + return val; +} +static inline void write_imipr_3(u32 val) +{ + asm volatile("mcr p6, 0, %0, c11, c1, 0"::"r" (val)); +} + +static u32 (*read_imipr[])(void) = { + read_imipr_0, + read_imipr_1, + read_imipr_2, + read_imipr_3, +}; + +static void (*write_imipr[])(u32) = { + write_imipr_0, + write_imipr_1, + write_imipr_2, + write_imipr_3, +}; + +static void iop13xx_msi_handler(unsigned int irq, struct irq_desc *desc) +{ + int i, j; + unsigned long status; + + /* read IMIPR registers and find any active interrupts, + * then call ISR for each active interrupt + */ + for (i = 0; i < ARRAY_SIZE(read_imipr); i++) { + status = (read_imipr[i])(); + if (!status) + continue; + + do { + j = find_first_bit(&status, 32); + (write_imipr[i])(1 << j); /* write back to clear bit */ + desc = irq_desc + IRQ_IOP13XX_MSI_0 + j + (32*i); + desc_handle_irq(IRQ_IOP13XX_MSI_0 + j + (32*i), desc); + status = (read_imipr[i])(); + } while (status); + } +} + +void __init iop13xx_msi_init(void) +{ + set_irq_chained_handler(IRQ_IOP13XX_INBD_MSI, iop13xx_msi_handler); +} + +/* + * Dynamic irq allocate and deallocation + */ +int create_irq(void) +{ + int irq, pos; + +again: + pos = find_first_zero_bit(msi_irq_in_use, IOP13XX_NUM_MSI_IRQS); + irq = IRQ_IOP13XX_MSI_0 + pos; + if (irq > NR_IRQS) + return -ENOSPC; + /* test_and_set_bit operates on 32-bits at a time */ + if (test_and_set_bit(pos, msi_irq_in_use)) + goto again; + + dynamic_irq_init(irq); + + return irq; +} + +void destroy_irq(unsigned int irq) +{ + int pos = irq - IRQ_IOP13XX_MSI_0; + + dynamic_irq_cleanup(irq); + + clear_bit(pos, msi_irq_in_use); +} + +void arch_teardown_msi_irq(unsigned int irq) +{ + destroy_irq(irq); +} + +static void iop13xx_msi_nop(unsigned int irq) +{ + return; +} + +static struct irq_chip iop13xx_msi_chip = { + .name = "PCI-MSI", + .ack = iop13xx_msi_nop, + .enable = unmask_msi_irq, + .disable = mask_msi_irq, + .mask = mask_msi_irq, + .unmask = unmask_msi_irq, +}; + +int arch_setup_msi_irq(struct pci_dev *pdev, struct msi_desc *desc) +{ + int id, irq = create_irq(); + struct msi_msg msg; + + if (irq < 0) + return irq; + + set_irq_msi(irq, desc); + + msg.address_hi = 0x0; + msg.address_lo = IOP13XX_MU_MIMR_PCI; + + id = iop13xx_cpu_id(); + msg.data = (id << IOP13XX_MU_MIMR_CORE_SELECT) | (irq & 0x7f); + + write_msi_msg(irq, &msg); + set_irq_chip_and_handler(irq, &iop13xx_msi_chip, handle_simple_irq); + + return irq; +} |