avila-pci.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * arch/arm/mach-ixp4xx/avila-pci.c
  4. *
  5. * Gateworks Avila board-level PCI initialization
  6. *
  7. * Author: Michael-Luke Jones <mlj28@cam.ac.uk>
  8. *
  9. * Based on ixdp-pci.c
  10. * Copyright (C) 2002 Intel Corporation.
  11. * Copyright (C) 2003-2004 MontaVista Software, Inc.
  12. *
  13. * Maintainer: Deepak Saxena <dsaxena@plexity.net>
  14. */
  15. #include <linux/kernel.h>
  16. #include <linux/pci.h>
  17. #include <linux/init.h>
  18. #include <linux/irq.h>
  19. #include <linux/delay.h>
  20. #include <asm/mach/pci.h>
  21. #include <asm/irq.h>
  22. #include <mach/hardware.h>
  23. #include <asm/mach-types.h>
  24. #include "irqs.h"
  25. #define AVILA_MAX_DEV 4
  26. #define LOFT_MAX_DEV 6
  27. #define IRQ_LINES 4
  28. /* PCI controller GPIO to IRQ pin mappings */
  29. #define INTA 11
  30. #define INTB 10
  31. #define INTC 9
  32. #define INTD 8
  33. void __init avila_pci_preinit(void)
  34. {
  35. irq_set_irq_type(IXP4XX_GPIO_IRQ(INTA), IRQ_TYPE_LEVEL_LOW);
  36. irq_set_irq_type(IXP4XX_GPIO_IRQ(INTB), IRQ_TYPE_LEVEL_LOW);
  37. irq_set_irq_type(IXP4XX_GPIO_IRQ(INTC), IRQ_TYPE_LEVEL_LOW);
  38. irq_set_irq_type(IXP4XX_GPIO_IRQ(INTD), IRQ_TYPE_LEVEL_LOW);
  39. ixp4xx_pci_preinit();
  40. }
  41. static int __init avila_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
  42. {
  43. static int pci_irq_table[IRQ_LINES] = {
  44. IXP4XX_GPIO_IRQ(INTA),
  45. IXP4XX_GPIO_IRQ(INTB),
  46. IXP4XX_GPIO_IRQ(INTC),
  47. IXP4XX_GPIO_IRQ(INTD)
  48. };
  49. if (slot >= 1 &&
  50. slot <= (machine_is_loft() ? LOFT_MAX_DEV : AVILA_MAX_DEV) &&
  51. pin >= 1 && pin <= IRQ_LINES)
  52. return pci_irq_table[(slot + pin - 2) % 4];
  53. return -1;
  54. }
  55. struct hw_pci avila_pci __initdata = {
  56. .nr_controllers = 1,
  57. .ops = &ixp4xx_ops,
  58. .preinit = avila_pci_preinit,
  59. .setup = ixp4xx_setup,
  60. .map_irq = avila_map_irq,
  61. };
  62. int __init avila_pci_init(void)
  63. {
  64. if (machine_is_avila() || machine_is_loft())
  65. pci_common_init(&avila_pci);
  66. return 0;
  67. }
  68. subsys_initcall(avila_pci_init);