Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * arch/arm/mach-orion5x/rd88f5182-setup.c
0004  *
0005  * Marvell Orion-NAS Reference Design Setup
0006  *
0007  * Maintainer: Ronen Shitrit <rshitrit@marvell.com>
0008  */
0009 #include <linux/gpio.h>
0010 #include <linux/kernel.h>
0011 #include <linux/init.h>
0012 #include <linux/platform_device.h>
0013 #include <linux/pci.h>
0014 #include <linux/irq.h>
0015 #include <asm/mach-types.h>
0016 #include <asm/mach/arch.h>
0017 #include <asm/mach/pci.h>
0018 #include "common.h"
0019 #include "orion5x.h"
0020 
0021 /*****************************************************************************
0022  * RD-88F5182 Info
0023  ****************************************************************************/
0024 
0025 /*
0026  * PCI
0027  */
0028 
0029 #define RD88F5182_PCI_SLOT0_OFFS    7
0030 #define RD88F5182_PCI_SLOT0_IRQ_A_PIN   7
0031 #define RD88F5182_PCI_SLOT0_IRQ_B_PIN   6
0032 
0033 /*****************************************************************************
0034  * PCI
0035  ****************************************************************************/
0036 
0037 static void __init rd88f5182_pci_preinit(void)
0038 {
0039     int pin;
0040 
0041     /*
0042      * Configure PCI GPIO IRQ pins
0043      */
0044     pin = RD88F5182_PCI_SLOT0_IRQ_A_PIN;
0045     if (gpio_request(pin, "PCI IntA") == 0) {
0046         if (gpio_direction_input(pin) == 0) {
0047             irq_set_irq_type(gpio_to_irq(pin), IRQ_TYPE_LEVEL_LOW);
0048         } else {
0049             printk(KERN_ERR "rd88f5182_pci_preinit failed to "
0050                     "set_irq_type pin %d\n", pin);
0051             gpio_free(pin);
0052         }
0053     } else {
0054         printk(KERN_ERR "rd88f5182_pci_preinit failed to request gpio %d\n", pin);
0055     }
0056 
0057     pin = RD88F5182_PCI_SLOT0_IRQ_B_PIN;
0058     if (gpio_request(pin, "PCI IntB") == 0) {
0059         if (gpio_direction_input(pin) == 0) {
0060             irq_set_irq_type(gpio_to_irq(pin), IRQ_TYPE_LEVEL_LOW);
0061         } else {
0062             printk(KERN_ERR "rd88f5182_pci_preinit failed to "
0063                     "set_irq_type pin %d\n", pin);
0064             gpio_free(pin);
0065         }
0066     } else {
0067         printk(KERN_ERR "rd88f5182_pci_preinit failed to gpio_request %d\n", pin);
0068     }
0069 }
0070 
0071 static int __init rd88f5182_pci_map_irq(const struct pci_dev *dev, u8 slot,
0072     u8 pin)
0073 {
0074     int irq;
0075 
0076     /*
0077      * Check for devices with hard-wired IRQs.
0078      */
0079     irq = orion5x_pci_map_irq(dev, slot, pin);
0080     if (irq != -1)
0081         return irq;
0082 
0083     /*
0084      * PCI IRQs are connected via GPIOs
0085      */
0086     switch (slot - RD88F5182_PCI_SLOT0_OFFS) {
0087     case 0:
0088         if (pin == 1)
0089             return gpio_to_irq(RD88F5182_PCI_SLOT0_IRQ_A_PIN);
0090         else
0091             return gpio_to_irq(RD88F5182_PCI_SLOT0_IRQ_B_PIN);
0092     default:
0093         return -1;
0094     }
0095 }
0096 
0097 static struct hw_pci rd88f5182_pci __initdata = {
0098     .nr_controllers = 2,
0099     .preinit    = rd88f5182_pci_preinit,
0100     .setup      = orion5x_pci_sys_setup,
0101     .scan       = orion5x_pci_sys_scan_bus,
0102     .map_irq    = rd88f5182_pci_map_irq,
0103 };
0104 
0105 static int __init rd88f5182_pci_init(void)
0106 {
0107     if (of_machine_is_compatible("marvell,rd-88f5182-nas"))
0108         pci_common_init(&rd88f5182_pci);
0109 
0110     return 0;
0111 }
0112 
0113 subsys_initcall(rd88f5182_pci_init);