board-rd88f5182.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * arch/arm/mach-orion5x/rd88f5182-setup.c
  4. *
  5. * Marvell Orion-NAS Reference Design Setup
  6. *
  7. * Maintainer: Ronen Shitrit <[email protected]>
  8. */
  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>
  18. #include "common.h"
  19. #include "orion5x.h"
  20. /*****************************************************************************
  21. * RD-88F5182 Info
  22. ****************************************************************************/
  23. /*
  24. * PCI
  25. */
  26. #define RD88F5182_PCI_SLOT0_OFFS 7
  27. #define RD88F5182_PCI_SLOT0_IRQ_A_PIN 7
  28. #define RD88F5182_PCI_SLOT0_IRQ_B_PIN 6
  29. /*****************************************************************************
  30. * PCI
  31. ****************************************************************************/
  32. static void __init rd88f5182_pci_preinit(void)
  33. {
  34. int pin;
  35. /*
  36. * Configure PCI GPIO IRQ pins
  37. */
  38. pin = RD88F5182_PCI_SLOT0_IRQ_A_PIN;
  39. if (gpio_request(pin, "PCI IntA") == 0) {
  40. if (gpio_direction_input(pin) == 0) {
  41. irq_set_irq_type(gpio_to_irq(pin), IRQ_TYPE_LEVEL_LOW);
  42. } else {
  43. printk(KERN_ERR "rd88f5182_pci_preinit failed to "
  44. "set_irq_type pin %d\n", pin);
  45. gpio_free(pin);
  46. }
  47. } else {
  48. printk(KERN_ERR "rd88f5182_pci_preinit failed to request gpio %d\n", pin);
  49. }
  50. pin = RD88F5182_PCI_SLOT0_IRQ_B_PIN;
  51. if (gpio_request(pin, "PCI IntB") == 0) {
  52. if (gpio_direction_input(pin) == 0) {
  53. irq_set_irq_type(gpio_to_irq(pin), IRQ_TYPE_LEVEL_LOW);
  54. } else {
  55. printk(KERN_ERR "rd88f5182_pci_preinit failed to "
  56. "set_irq_type pin %d\n", pin);
  57. gpio_free(pin);
  58. }
  59. } else {
  60. printk(KERN_ERR "rd88f5182_pci_preinit failed to gpio_request %d\n", pin);
  61. }
  62. }
  63. static int __init rd88f5182_pci_map_irq(const struct pci_dev *dev, u8 slot,
  64. u8 pin)
  65. {
  66. int irq;
  67. /*
  68. * Check for devices with hard-wired IRQs.
  69. */
  70. irq = orion5x_pci_map_irq(dev, slot, pin);
  71. if (irq != -1)
  72. return irq;
  73. /*
  74. * PCI IRQs are connected via GPIOs
  75. */
  76. switch (slot - RD88F5182_PCI_SLOT0_OFFS) {
  77. case 0:
  78. if (pin == 1)
  79. return gpio_to_irq(RD88F5182_PCI_SLOT0_IRQ_A_PIN);
  80. else
  81. return gpio_to_irq(RD88F5182_PCI_SLOT0_IRQ_B_PIN);
  82. default:
  83. return -1;
  84. }
  85. }
  86. static struct hw_pci rd88f5182_pci __initdata = {
  87. .nr_controllers = 2,
  88. .preinit = rd88f5182_pci_preinit,
  89. .setup = orion5x_pci_sys_setup,
  90. .scan = orion5x_pci_sys_scan_bus,
  91. .map_irq = rd88f5182_pci_map_irq,
  92. };
  93. static int __init rd88f5182_pci_init(void)
  94. {
  95. if (of_machine_is_compatible("marvell,rd-88f5182-nas"))
  96. pci_common_init(&rd88f5182_pci);
  97. return 0;
  98. }
  99. subsys_initcall(rd88f5182_pci_init);