blob: c77fe0d52d7989856411f85b1bc14f41058f8085 [file] [log] [blame]
Thomas Gleixnerd2912cb2019-06-04 10:11:33 +02001// SPDX-License-Identifier: GPL-2.0-only
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
Krzysztof Hałasa9bf4d672009-11-16 15:24:41 +01003 * arch/arm/mach-ixp4xx/ixdp425-pci.c
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 *
5 * IXDP425 board-level PCI initialization
6 *
7 * Copyright (C) 2002 Intel Corporation.
8 * Copyright (C) 2003-2004 MontaVista Software, Inc.
9 *
10 * Maintainer: Deepak Saxena <dsaxena@plexity.net>
Linus Torvalds1da177e2005-04-16 15:20:36 -070011 */
12
13#include <linux/kernel.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070014#include <linux/pci.h>
15#include <linux/init.h>
Thomas Gleixner698dfe22006-07-01 23:01:49 +010016#include <linux/irq.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070017#include <linux/delay.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070018#include <asm/mach/pci.h>
19#include <asm/irq.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010020#include <mach/hardware.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070021#include <asm/mach-types.h>
22
Linus Walleijdc8ef8cd2018-12-29 15:47:52 +010023#include "irqs.h"
24
Krzysztof Hałasa8d3fdf32009-11-17 18:48:23 +010025#define MAX_DEV 4
26#define IRQ_LINES 4
Krzysztof Hałasa9bf4d672009-11-16 15:24:41 +010027
28/* PCI controller GPIO to IRQ pin mappings */
Krzysztof Hałasa8d3fdf32009-11-17 18:48:23 +010029#define INTA 11
30#define INTB 10
31#define INTC 9
32#define INTD 8
Krzysztof Hałasa9bf4d672009-11-16 15:24:41 +010033
Krzysztof Hałasa9bf4d672009-11-16 15:24:41 +010034
Linus Torvalds1da177e2005-04-16 15:20:36 -070035void __init ixdp425_pci_preinit(void)
36{
Thomas Gleixner6845664a2011-03-24 13:25:22 +010037 irq_set_irq_type(IXP4XX_GPIO_IRQ(INTA), IRQ_TYPE_LEVEL_LOW);
38 irq_set_irq_type(IXP4XX_GPIO_IRQ(INTB), IRQ_TYPE_LEVEL_LOW);
39 irq_set_irq_type(IXP4XX_GPIO_IRQ(INTC), IRQ_TYPE_LEVEL_LOW);
40 irq_set_irq_type(IXP4XX_GPIO_IRQ(INTD), IRQ_TYPE_LEVEL_LOW);
Linus Torvalds1da177e2005-04-16 15:20:36 -070041 ixp4xx_pci_preinit();
42}
43
Ralf Baechled5341942011-06-10 15:30:21 +010044static int __init ixdp425_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
Linus Torvalds1da177e2005-04-16 15:20:36 -070045{
Krzysztof Hałasa8d3fdf32009-11-17 18:48:23 +010046 static int pci_irq_table[IRQ_LINES] = {
47 IXP4XX_GPIO_IRQ(INTA),
48 IXP4XX_GPIO_IRQ(INTB),
49 IXP4XX_GPIO_IRQ(INTC),
50 IXP4XX_GPIO_IRQ(INTD)
Linus Torvalds1da177e2005-04-16 15:20:36 -070051 };
52
Krzysztof Hałasa8d3fdf32009-11-17 18:48:23 +010053 if (slot >= 1 && slot <= MAX_DEV && pin >= 1 && pin <= IRQ_LINES)
54 return pci_irq_table[(slot + pin - 2) % 4];
Linus Torvalds1da177e2005-04-16 15:20:36 -070055
Krzysztof Hałasa8d3fdf32009-11-17 18:48:23 +010056 return -1;
Linus Torvalds1da177e2005-04-16 15:20:36 -070057}
58
59struct hw_pci ixdp425_pci __initdata = {
60 .nr_controllers = 1,
Russell Kingc23bfc32012-03-10 12:49:16 +000061 .ops = &ixp4xx_ops,
Linus Torvalds1da177e2005-04-16 15:20:36 -070062 .preinit = ixdp425_pci_preinit,
Linus Torvalds1da177e2005-04-16 15:20:36 -070063 .setup = ixp4xx_setup,
Linus Torvalds1da177e2005-04-16 15:20:36 -070064 .map_irq = ixdp425_map_irq,
65};
66
67int __init ixdp425_pci_init(void)
68{
69 if (machine_is_ixdp425() || machine_is_ixcdp1100() ||
Ruslan V. Sushko45fba082007-04-06 15:00:31 +010070 machine_is_ixdp465() || machine_is_kixrp435())
Linus Torvalds1da177e2005-04-16 15:20:36 -070071 pci_common_init(&ixdp425_pci);
72 return 0;
73}
74
75subsys_initcall(ixdp425_pci_init);