nslu2-pci.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * arch/arm/mach-ixp4xx/nslu2-pci.c
  3. *
  4. * NSLU2 board-level PCI initialization
  5. *
  6. * based on ixdp425-pci.c:
  7. * Copyright (C) 2002 Intel Corporation.
  8. * Copyright (C) 2003-2004 MontaVista Software, Inc.
  9. *
  10. * Maintainer: http://www.nslu2-linux.org/
  11. *
  12. * This program is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License version 2 as
  14. * published by the Free Software Foundation.
  15. *
  16. */
  17. #include <linux/pci.h>
  18. #include <linux/init.h>
  19. #include <linux/irq.h>
  20. #include <asm/mach/pci.h>
  21. #include <asm/mach-types.h>
  22. void __init nslu2_pci_preinit(void)
  23. {
  24. set_irq_type(IRQ_NSLU2_PCI_INTA, IRQ_TYPE_LEVEL_LOW);
  25. set_irq_type(IRQ_NSLU2_PCI_INTB, IRQ_TYPE_LEVEL_LOW);
  26. set_irq_type(IRQ_NSLU2_PCI_INTC, IRQ_TYPE_LEVEL_LOW);
  27. ixp4xx_pci_preinit();
  28. }
  29. static int __init nslu2_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
  30. {
  31. static int pci_irq_table[NSLU2_PCI_IRQ_LINES] = {
  32. IRQ_NSLU2_PCI_INTA,
  33. IRQ_NSLU2_PCI_INTB,
  34. IRQ_NSLU2_PCI_INTC,
  35. };
  36. int irq = -1;
  37. if (slot >= 1 && slot <= NSLU2_PCI_MAX_DEV &&
  38. pin >= 1 && pin <= NSLU2_PCI_IRQ_LINES) {
  39. irq = pci_irq_table[(slot + pin - 2) % NSLU2_PCI_IRQ_LINES];
  40. }
  41. return irq;
  42. }
  43. struct hw_pci __initdata nslu2_pci = {
  44. .nr_controllers = 1,
  45. .preinit = nslu2_pci_preinit,
  46. .swizzle = pci_std_swizzle,
  47. .setup = ixp4xx_setup,
  48. .scan = ixp4xx_scan_bus,
  49. .map_irq = nslu2_map_irq,
  50. };
  51. int __init nslu2_pci_init(void) /* monkey see, monkey do */
  52. {
  53. if (machine_is_nslu2())
  54. pci_common_init(&nslu2_pci);
  55. return 0;
  56. }
  57. subsys_initcall(nslu2_pci_init);