blob: 9665bb082107b5bc9da56e02daa1ee460278b2b7 [file] [log] [blame]
Alessandro Zummoa7918f32005-11-10 14:05:04 +00001/*
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 Zummoa7918f32005-11-10 14:05:04 +000018#include <linux/pci.h>
19#include <linux/init.h>
Martin Michlmayrf64c2c02006-09-06 19:03:24 +010020#include <linux/irq.h>
Alessandro Zummoa7918f32005-11-10 14:05:04 +000021#include <asm/mach/pci.h>
22#include <asm/mach-types.h>
23
Krzysztof HaƂasac1117c62009-11-16 16:02:02 +010024#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 Zummoa7918f32005-11-10 14:05:04 +000036void __init nslu2_pci_preinit(void)
37{
Dmitry Baryshkov6cab4862008-07-27 04:23:31 +010038 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 Zummoa7918f32005-11-10 14:05:04 +000041
Alessandro Zummoa7918f32005-11-10 14:05:04 +000042 ixp4xx_pci_preinit();
43}
44
45static 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
63struct 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
72int __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
80subsys_initcall(nslu2_pci_init);