avila-pci.c 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. * arch/arm/mach-ixp4xx/avila-pci.c
  3. *
  4. * Gateworks Avila board-level PCI initialization
  5. *
  6. * Author: Michael-Luke Jones <mlj28@cam.ac.uk>
  7. *
  8. * Based on ixdp-pci.c
  9. * Copyright (C) 2002 Intel Corporation.
  10. * Copyright (C) 2003-2004 MontaVista Software, Inc.
  11. *
  12. * Maintainer: Deepak Saxena <dsaxena@plexity.net>
  13. *
  14. * This program is free software; you can redistribute it and/or modify
  15. * it under the terms of the GNU General Public License version 2 as
  16. * published by the Free Software Foundation.
  17. *
  18. */
  19. #include <linux/kernel.h>
  20. #include <linux/pci.h>
  21. #include <linux/init.h>
  22. #include <linux/irq.h>
  23. #include <linux/delay.h>
  24. #include <asm/mach/pci.h>
  25. #include <asm/irq.h>
  26. #include <mach/hardware.h>
  27. #include <asm/mach-types.h>
  28. #define AVILA_PCI_MAX_DEV 4
  29. #define LOFT_PCI_MAX_DEV 6
  30. #define AVILA_PCI_IRQ_LINES 4
  31. /* PCI controller GPIO to IRQ pin mappings */
  32. #define AVILA_PCI_INTA_PIN 11
  33. #define AVILA_PCI_INTB_PIN 10
  34. #define AVILA_PCI_INTC_PIN 9
  35. #define AVILA_PCI_INTD_PIN 8
  36. #define IRQ_AVILA_PCI_INTA IRQ_IXP4XX_GPIO11
  37. #define IRQ_AVILA_PCI_INTB IRQ_IXP4XX_GPIO10
  38. #define IRQ_AVILA_PCI_INTC IRQ_IXP4XX_GPIO9
  39. #define IRQ_AVILA_PCI_INTD IRQ_IXP4XX_GPIO8
  40. void __init avila_pci_preinit(void)
  41. {
  42. set_irq_type(IRQ_AVILA_PCI_INTA, IRQ_TYPE_LEVEL_LOW);
  43. set_irq_type(IRQ_AVILA_PCI_INTB, IRQ_TYPE_LEVEL_LOW);
  44. set_irq_type(IRQ_AVILA_PCI_INTC, IRQ_TYPE_LEVEL_LOW);
  45. set_irq_type(IRQ_AVILA_PCI_INTD, IRQ_TYPE_LEVEL_LOW);
  46. ixp4xx_pci_preinit();
  47. }
  48. static int __init avila_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
  49. {
  50. static int pci_irq_table[AVILA_PCI_IRQ_LINES] = {
  51. IRQ_AVILA_PCI_INTA,
  52. IRQ_AVILA_PCI_INTB,
  53. IRQ_AVILA_PCI_INTC,
  54. IRQ_AVILA_PCI_INTD
  55. };
  56. int irq = -1;
  57. if (slot >= 1 &&
  58. slot <= (machine_is_loft() ? LOFT_PCI_MAX_DEV : AVILA_PCI_MAX_DEV) &&
  59. pin >= 1 && pin <= AVILA_PCI_IRQ_LINES) {
  60. irq = pci_irq_table[(slot + pin - 2) % 4];
  61. }
  62. return irq;
  63. }
  64. struct hw_pci avila_pci __initdata = {
  65. .nr_controllers = 1,
  66. .preinit = avila_pci_preinit,
  67. .swizzle = pci_std_swizzle,
  68. .setup = ixp4xx_setup,
  69. .scan = ixp4xx_scan_bus,
  70. .map_irq = avila_map_irq,
  71. };
  72. int __init avila_pci_init(void)
  73. {
  74. if (machine_is_avila() || machine_is_loft())
  75. pci_common_init(&avila_pci);
  76. return 0;
  77. }
  78. subsys_initcall(avila_pci_init);