avila-pci.c 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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_MAX_DEV 4
  29. #define LOFT_MAX_DEV 6
  30. #define IRQ_LINES 4
  31. /* PCI controller GPIO to IRQ pin mappings */
  32. #define INTA 11
  33. #define INTB 10
  34. #define INTC 9
  35. #define INTD 8
  36. void __init avila_pci_preinit(void)
  37. {
  38. irq_set_irq_type(IXP4XX_GPIO_IRQ(INTA), IRQ_TYPE_LEVEL_LOW);
  39. irq_set_irq_type(IXP4XX_GPIO_IRQ(INTB), IRQ_TYPE_LEVEL_LOW);
  40. irq_set_irq_type(IXP4XX_GPIO_IRQ(INTC), IRQ_TYPE_LEVEL_LOW);
  41. irq_set_irq_type(IXP4XX_GPIO_IRQ(INTD), IRQ_TYPE_LEVEL_LOW);
  42. ixp4xx_pci_preinit();
  43. }
  44. static int __init avila_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
  45. {
  46. static int pci_irq_table[IRQ_LINES] = {
  47. IXP4XX_GPIO_IRQ(INTA),
  48. IXP4XX_GPIO_IRQ(INTB),
  49. IXP4XX_GPIO_IRQ(INTC),
  50. IXP4XX_GPIO_IRQ(INTD)
  51. };
  52. if (slot >= 1 &&
  53. slot <= (machine_is_loft() ? LOFT_MAX_DEV : AVILA_MAX_DEV) &&
  54. pin >= 1 && pin <= IRQ_LINES)
  55. return pci_irq_table[(slot + pin - 2) % 4];
  56. return -1;
  57. }
  58. struct hw_pci avila_pci __initdata = {
  59. .nr_controllers = 1,
  60. .preinit = avila_pci_preinit,
  61. .swizzle = pci_std_swizzle,
  62. .setup = ixp4xx_setup,
  63. .scan = ixp4xx_scan_bus,
  64. .map_irq = avila_map_irq,
  65. };
  66. int __init avila_pci_init(void)
  67. {
  68. if (machine_is_avila() || machine_is_loft())
  69. pci_common_init(&avila_pci);
  70. return 0;
  71. }
  72. subsys_initcall(avila_pci_init);