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>
12 #include <linux/platform_device.h>
13 #include <linux/pci.h>
14 #include <linux/irq.h>
15 #include <asm/mach-types.h>
16 #include <asm/mach/arch.h>
17 #include <asm/mach/pci.h>
21 /*****************************************************************************
23 ****************************************************************************/
29 #define RD88F5182_PCI_SLOT0_OFFS 7
30 #define RD88F5182_PCI_SLOT0_IRQ_A_PIN 7
31 #define RD88F5182_PCI_SLOT0_IRQ_B_PIN 6
33 /*****************************************************************************
35 ****************************************************************************/
37 static void __init rd88f5182_pci_preinit(void)
42 * Configure PCI GPIO IRQ pins
44 pin = RD88F5182_PCI_SLOT0_IRQ_A_PIN;
45 if (gpio_request(pin, "PCI IntA") == 0) {
46 if (gpio_direction_input(pin) == 0) {
47 irq_set_irq_type(gpio_to_irq(pin), IRQ_TYPE_LEVEL_LOW);
49 printk(KERN_ERR "rd88f5182_pci_preinit failed to "
50 "set_irq_type pin %d\n", pin);
54 printk(KERN_ERR "rd88f5182_pci_preinit failed to request gpio %d\n", pin);
57 pin = RD88F5182_PCI_SLOT0_IRQ_B_PIN;
58 if (gpio_request(pin, "PCI IntB") == 0) {
59 if (gpio_direction_input(pin) == 0) {
60 irq_set_irq_type(gpio_to_irq(pin), IRQ_TYPE_LEVEL_LOW);
62 printk(KERN_ERR "rd88f5182_pci_preinit failed to "
63 "set_irq_type pin %d\n", pin);
67 printk(KERN_ERR "rd88f5182_pci_preinit failed to gpio_request %d\n", pin);
71 static int __init rd88f5182_pci_map_irq(const struct pci_dev *dev, u8 slot,
77 * Check for devices with hard-wired IRQs.
79 irq = orion5x_pci_map_irq(dev, slot, pin);
84 * PCI IRQs are connected via GPIOs
86 switch (slot - RD88F5182_PCI_SLOT0_OFFS) {
89 return gpio_to_irq(RD88F5182_PCI_SLOT0_IRQ_A_PIN);
91 return gpio_to_irq(RD88F5182_PCI_SLOT0_IRQ_B_PIN);
97 static struct hw_pci rd88f5182_pci __initdata = {
99 .preinit = rd88f5182_pci_preinit,
100 .setup = orion5x_pci_sys_setup,
101 .scan = orion5x_pci_sys_scan_bus,
102 .map_irq = rd88f5182_pci_map_irq,
105 static int __init rd88f5182_pci_init(void)
107 if (of_machine_is_compatible("marvell,rd-88f5182-nas"))
108 pci_common_init(&rd88f5182_pci);
113 subsys_initcall(rd88f5182_pci_init);