board-rd88f5182.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /*
  2. * arch/arm/mach-orion5x/rd88f5182-setup.c
  3. *
  4. * Marvell Orion-NAS Reference Design Setup
  5. *
  6. * Maintainer: Ronen Shitrit <rshitrit@marvell.com>
  7. *
  8. * This file is licensed under the terms of the GNU General Public
  9. * License version 2. This program is licensed "as is" without any
  10. * warranty of any kind, whether express or implied.
  11. */
  12. #include <linux/gpio.h>
  13. #include <linux/kernel.h>
  14. #include <linux/init.h>
  15. #include <linux/platform_device.h>
  16. #include <linux/pci.h>
  17. #include <linux/irq.h>
  18. #include <asm/mach-types.h>
  19. #include <asm/mach/arch.h>
  20. #include <asm/mach/pci.h>
  21. #include "common.h"
  22. #include "orion5x.h"
  23. /*****************************************************************************
  24. * RD-88F5182 Info
  25. ****************************************************************************/
  26. /*
  27. * PCI
  28. */
  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
  32. /*****************************************************************************
  33. * PCI
  34. ****************************************************************************/
  35. static void __init rd88f5182_pci_preinit(void)
  36. {
  37. int pin;
  38. /*
  39. * Configure PCI GPIO IRQ pins
  40. */
  41. pin = RD88F5182_PCI_SLOT0_IRQ_A_PIN;
  42. if (gpio_request(pin, "PCI IntA") == 0) {
  43. if (gpio_direction_input(pin) == 0) {
  44. irq_set_irq_type(gpio_to_irq(pin), IRQ_TYPE_LEVEL_LOW);
  45. } else {
  46. printk(KERN_ERR "rd88f5182_pci_preinit failed to "
  47. "set_irq_type pin %d\n", pin);
  48. gpio_free(pin);
  49. }
  50. } else {
  51. printk(KERN_ERR "rd88f5182_pci_preinit failed to request gpio %d\n", pin);
  52. }
  53. pin = RD88F5182_PCI_SLOT0_IRQ_B_PIN;
  54. if (gpio_request(pin, "PCI IntB") == 0) {
  55. if (gpio_direction_input(pin) == 0) {
  56. irq_set_irq_type(gpio_to_irq(pin), IRQ_TYPE_LEVEL_LOW);
  57. } else {
  58. printk(KERN_ERR "rd88f5182_pci_preinit failed to "
  59. "set_irq_type pin %d\n", pin);
  60. gpio_free(pin);
  61. }
  62. } else {
  63. printk(KERN_ERR "rd88f5182_pci_preinit failed to gpio_request %d\n", pin);
  64. }
  65. }
  66. static int __init rd88f5182_pci_map_irq(const struct pci_dev *dev, u8 slot,
  67. u8 pin)
  68. {
  69. int irq;
  70. /*
  71. * Check for devices with hard-wired IRQs.
  72. */
  73. irq = orion5x_pci_map_irq(dev, slot, pin);
  74. if (irq != -1)
  75. return irq;
  76. /*
  77. * PCI IRQs are connected via GPIOs
  78. */
  79. switch (slot - RD88F5182_PCI_SLOT0_OFFS) {
  80. case 0:
  81. if (pin == 1)
  82. return gpio_to_irq(RD88F5182_PCI_SLOT0_IRQ_A_PIN);
  83. else
  84. return gpio_to_irq(RD88F5182_PCI_SLOT0_IRQ_B_PIN);
  85. default:
  86. return -1;
  87. }
  88. }
  89. static struct hw_pci rd88f5182_pci __initdata = {
  90. .nr_controllers = 2,
  91. .preinit = rd88f5182_pci_preinit,
  92. .setup = orion5x_pci_sys_setup,
  93. .scan = orion5x_pci_sys_scan_bus,
  94. .map_irq = rd88f5182_pci_map_irq,
  95. };
  96. static int __init rd88f5182_pci_init(void)
  97. {
  98. if (of_machine_is_compatible("marvell,rd-88f5182-nas"))
  99. pci_common_init(&rd88f5182_pci);
  100. return 0;
  101. }
  102. subsys_initcall(rd88f5182_pci_init);