1 // SPDX-License-Identifier: GPL-2.0-only
3 * arch/arm/mach-orion5x/rd88f5182-setup.c
5 * Marvell Orion-NAS Reference Design Setup
7 * Maintainer: Ronen Shitrit <rshitrit@marvell.com>
9 #include <linux/gpio.h>
10 #include <linux/kernel.h>
11 #include <linux/init.h>
13 #include <linux/platform_device.h>
14 #include <linux/pci.h>
15 #include <linux/irq.h>
16 #include <asm/mach-types.h>
17 #include <asm/mach/arch.h>
18 #include <asm/mach/pci.h>
22 /*****************************************************************************
24 ****************************************************************************/
30 #define RD88F5182_PCI_SLOT0_OFFS 7
31 #define RD88F5182_PCI_SLOT0_IRQ_A_PIN 7
32 #define RD88F5182_PCI_SLOT0_IRQ_B_PIN 6
34 /*****************************************************************************
36 ****************************************************************************/
38 static void __init
rd88f5182_pci_preinit(void)
43 * Configure PCI GPIO IRQ pins
45 pin
= RD88F5182_PCI_SLOT0_IRQ_A_PIN
;
46 if (gpio_request(pin
, "PCI IntA") == 0) {
47 if (gpio_direction_input(pin
) == 0) {
48 irq_set_irq_type(gpio_to_irq(pin
), IRQ_TYPE_LEVEL_LOW
);
50 printk(KERN_ERR
"rd88f5182_pci_preinit failed to "
51 "set_irq_type pin %d\n", pin
);
55 printk(KERN_ERR
"rd88f5182_pci_preinit failed to request gpio %d\n", pin
);
58 pin
= RD88F5182_PCI_SLOT0_IRQ_B_PIN
;
59 if (gpio_request(pin
, "PCI IntB") == 0) {
60 if (gpio_direction_input(pin
) == 0) {
61 irq_set_irq_type(gpio_to_irq(pin
), IRQ_TYPE_LEVEL_LOW
);
63 printk(KERN_ERR
"rd88f5182_pci_preinit failed to "
64 "set_irq_type pin %d\n", pin
);
68 printk(KERN_ERR
"rd88f5182_pci_preinit failed to gpio_request %d\n", pin
);
72 static int __init
rd88f5182_pci_map_irq(const struct pci_dev
*dev
, u8 slot
,
78 * Check for devices with hard-wired IRQs.
80 irq
= orion5x_pci_map_irq(dev
, slot
, pin
);
85 * PCI IRQs are connected via GPIOs
87 switch (slot
- RD88F5182_PCI_SLOT0_OFFS
) {
90 return gpio_to_irq(RD88F5182_PCI_SLOT0_IRQ_A_PIN
);
92 return gpio_to_irq(RD88F5182_PCI_SLOT0_IRQ_B_PIN
);
98 static struct hw_pci rd88f5182_pci __initdata
= {
100 .preinit
= rd88f5182_pci_preinit
,
101 .setup
= orion5x_pci_sys_setup
,
102 .scan
= orion5x_pci_sys_scan_bus
,
103 .map_irq
= rd88f5182_pci_map_irq
,
106 static int __init
rd88f5182_pci_init(void)
108 if (of_machine_is_compatible("marvell,rd-88f5182-nas"))
109 pci_common_init(&rd88f5182_pci
);
114 subsys_initcall(rd88f5182_pci_init
);