Alessandro Zummo | a7918f3 | 2005-11-10 14:05:04 +0000 | [diff] [blame] | 1 | /* |
| 2 | * arch/arm/mach-ixp4xx/nslu2-pci.c |
| 3 | * |
| 4 | * NSLU2 board-level PCI initialization |
| 5 | * |
| 6 | * based on ixdp425-pci.c: |
| 7 | * Copyright (C) 2002 Intel Corporation. |
| 8 | * Copyright (C) 2003-2004 MontaVista Software, Inc. |
| 9 | * |
| 10 | * Maintainer: http://www.nslu2-linux.org/ |
| 11 | * |
| 12 | * This program is free software; you can redistribute it and/or modify |
| 13 | * it under the terms of the GNU General Public License version 2 as |
| 14 | * published by the Free Software Foundation. |
| 15 | * |
| 16 | */ |
| 17 | |
Alessandro Zummo | a7918f3 | 2005-11-10 14:05:04 +0000 | [diff] [blame] | 18 | #include <linux/pci.h> |
| 19 | #include <linux/init.h> |
Martin Michlmayr | f64c2c0 | 2006-09-06 19:03:24 +0100 | [diff] [blame] | 20 | #include <linux/irq.h> |
Alessandro Zummo | a7918f3 | 2005-11-10 14:05:04 +0000 | [diff] [blame] | 21 | #include <asm/mach/pci.h> |
| 22 | #include <asm/mach-types.h> |
| 23 | |
Krzysztof HaĆasa | c1117c6 | 2009-11-16 16:02:02 +0100 | [diff] [blame^] | 24 | #define NSLU2_PCI_MAX_DEV 3 |
| 25 | #define NSLU2_PCI_IRQ_LINES 3 |
| 26 | |
| 27 | /* PCI controller GPIO to IRQ pin mappings */ |
| 28 | #define NSLU2_PCI_INTA_PIN 11 |
| 29 | #define NSLU2_PCI_INTB_PIN 10 |
| 30 | #define NSLU2_PCI_INTC_PIN 9 |
| 31 | #define NSLU2_PCI_INTD_PIN 8 |
| 32 | #define IRQ_NSLU2_PCI_INTA IRQ_IXP4XX_GPIO11 |
| 33 | #define IRQ_NSLU2_PCI_INTB IRQ_IXP4XX_GPIO10 |
| 34 | #define IRQ_NSLU2_PCI_INTC IRQ_IXP4XX_GPIO9 |
| 35 | |
Alessandro Zummo | a7918f3 | 2005-11-10 14:05:04 +0000 | [diff] [blame] | 36 | void __init nslu2_pci_preinit(void) |
| 37 | { |
Dmitry Baryshkov | 6cab486 | 2008-07-27 04:23:31 +0100 | [diff] [blame] | 38 | set_irq_type(IRQ_NSLU2_PCI_INTA, IRQ_TYPE_LEVEL_LOW); |
| 39 | set_irq_type(IRQ_NSLU2_PCI_INTB, IRQ_TYPE_LEVEL_LOW); |
| 40 | set_irq_type(IRQ_NSLU2_PCI_INTC, IRQ_TYPE_LEVEL_LOW); |
Alessandro Zummo | a7918f3 | 2005-11-10 14:05:04 +0000 | [diff] [blame] | 41 | |
Alessandro Zummo | a7918f3 | 2005-11-10 14:05:04 +0000 | [diff] [blame] | 42 | ixp4xx_pci_preinit(); |
| 43 | } |
| 44 | |
| 45 | static int __init nslu2_map_irq(struct pci_dev *dev, u8 slot, u8 pin) |
| 46 | { |
| 47 | static int pci_irq_table[NSLU2_PCI_IRQ_LINES] = { |
| 48 | IRQ_NSLU2_PCI_INTA, |
| 49 | IRQ_NSLU2_PCI_INTB, |
| 50 | IRQ_NSLU2_PCI_INTC, |
| 51 | }; |
| 52 | |
| 53 | int irq = -1; |
| 54 | |
| 55 | if (slot >= 1 && slot <= NSLU2_PCI_MAX_DEV && |
| 56 | pin >= 1 && pin <= NSLU2_PCI_IRQ_LINES) { |
| 57 | irq = pci_irq_table[(slot + pin - 2) % NSLU2_PCI_IRQ_LINES]; |
| 58 | } |
| 59 | |
| 60 | return irq; |
| 61 | } |
| 62 | |
| 63 | struct hw_pci __initdata nslu2_pci = { |
| 64 | .nr_controllers = 1, |
| 65 | .preinit = nslu2_pci_preinit, |
| 66 | .swizzle = pci_std_swizzle, |
| 67 | .setup = ixp4xx_setup, |
| 68 | .scan = ixp4xx_scan_bus, |
| 69 | .map_irq = nslu2_map_irq, |
| 70 | }; |
| 71 | |
| 72 | int __init nslu2_pci_init(void) /* monkey see, monkey do */ |
| 73 | { |
| 74 | if (machine_is_nslu2()) |
| 75 | pci_common_init(&nslu2_pci); |
| 76 | |
| 77 | return 0; |
| 78 | } |
| 79 | |
| 80 | subsys_initcall(nslu2_pci_init); |