blob: 2a1701bb3671d3c7c8c70949ce15c940fe1e0727 [file] [log] [blame]
Rod Whitby7e36e2f2008-04-01 10:53:23 +01001/*
2 * arch/arch/mach-ixp4xx/fsg-pci.c
3 *
4 * FSG board-level PCI initialization
5 *
6 * Author: Rod Whitby <rod@whitby.id.au>
7 * Maintainer: http://www.nslu2-linux.org/
8 *
9 * based on ixdp425-pci.c:
10 * Copyright (C) 2002 Intel Corporation.
11 * Copyright (C) 2003-2004 MontaVista Software, Inc.
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License version 2 as
15 * published by the Free Software Foundation.
16 *
17 */
18
19#include <linux/pci.h>
20#include <linux/init.h>
21#include <linux/irq.h>
Rod Whitby7e36e2f2008-04-01 10:53:23 +010022#include <asm/mach/pci.h>
23#include <asm/mach-types.h>
24
Krzysztof HaƂasa914e7bc2009-11-16 22:53:53 +010025#define FSG_PCI_MAX_DEV 3
26#define FSG_PCI_IRQ_LINES 3
27
28/* PCI controller GPIO to IRQ pin mappings */
29#define FSG_PCI_INTA_PIN 6
30#define FSG_PCI_INTB_PIN 7
31#define FSG_PCI_INTC_PIN 5
32#define IRQ_FSG_PCI_INTA IRQ_IXP4XX_GPIO6
33#define IRQ_FSG_PCI_INTB IRQ_IXP4XX_GPIO7
34#define IRQ_FSG_PCI_INTC IRQ_IXP4XX_GPIO5
35
Rod Whitby7e36e2f2008-04-01 10:53:23 +010036void __init fsg_pci_preinit(void)
37{
Dmitry Baryshkov6cab4862008-07-27 04:23:31 +010038 set_irq_type(IRQ_FSG_PCI_INTA, IRQ_TYPE_LEVEL_LOW);
39 set_irq_type(IRQ_FSG_PCI_INTB, IRQ_TYPE_LEVEL_LOW);
40 set_irq_type(IRQ_FSG_PCI_INTC, IRQ_TYPE_LEVEL_LOW);
Rod Whitby7e36e2f2008-04-01 10:53:23 +010041
42 ixp4xx_pci_preinit();
43}
44
45static int __init fsg_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
46{
47 static int pci_irq_table[FSG_PCI_IRQ_LINES] = {
48 IRQ_FSG_PCI_INTC,
49 IRQ_FSG_PCI_INTB,
50 IRQ_FSG_PCI_INTA,
51 };
52
53 int irq = -1;
54 slot = slot - 11;
55
56 if (slot >= 1 && slot <= FSG_PCI_MAX_DEV &&
57 pin >= 1 && pin <= FSG_PCI_IRQ_LINES)
58 irq = pci_irq_table[(slot - 1)];
59 printk(KERN_INFO "%s: Mapped slot %d pin %d to IRQ %d\n",
60 __func__, slot, pin, irq);
61
62 return irq;
63}
64
65struct hw_pci fsg_pci __initdata = {
66 .nr_controllers = 1,
67 .preinit = fsg_pci_preinit,
68 .swizzle = pci_std_swizzle,
69 .setup = ixp4xx_setup,
70 .scan = ixp4xx_scan_bus,
71 .map_irq = fsg_map_irq,
72};
73
74int __init fsg_pci_init(void)
75{
76 if (machine_is_fsg())
77 pci_common_init(&fsg_pci);
78 return 0;
79}
80
81subsys_initcall(fsg_pci_init);