iq80332-pci.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /*
  2. * arch/arm/mach-iop3xx/iq80332-pci.c
  3. *
  4. * PCI support for the Intel IQ80332 reference board
  5. *
  6. * Author: Dave Jiang <dave.jiang@intel.com>
  7. * Copyright (C) 2004 Intel Corp.
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. */
  13. #include <linux/kernel.h>
  14. #include <linux/pci.h>
  15. #include <linux/init.h>
  16. #include <asm/hardware.h>
  17. #include <asm/irq.h>
  18. #include <asm/mach/pci.h>
  19. #include <asm/mach-types.h>
  20. /*
  21. * The following macro is used to lookup irqs in a standard table
  22. * format for those systems that do not already have PCI
  23. * interrupts properly routed. We assume 1 <= pin <= 4
  24. */
  25. #define PCI_IRQ_TABLE_LOOKUP(minid,maxid) \
  26. ({ int _ctl_ = -1; \
  27. unsigned int _idsel = idsel - minid; \
  28. if (_idsel <= maxid) \
  29. _ctl_ = pci_irq_table[_idsel][pin-1]; \
  30. _ctl_; })
  31. #define INTA IRQ_IQ80332_INTA
  32. #define INTB IRQ_IQ80332_INTB
  33. #define INTC IRQ_IQ80332_INTC
  34. #define INTD IRQ_IQ80332_INTD
  35. //#define INTE IRQ_IQ80332_I82544
  36. static inline int __init
  37. iq80332_map_irq(struct pci_dev *dev, u8 idsel, u8 pin)
  38. {
  39. static int pci_irq_table[][8] = {
  40. /*
  41. * PCI IDSEL/INTPIN->INTLINE
  42. * A B C D
  43. */
  44. {-1, -1, -1, -1},
  45. {-1, -1, -1, -1},
  46. {-1, -1, -1, -1},
  47. {INTA, INTB, INTC, INTD}, /* PCI-X Slot */
  48. {-1, -1, -1, -1},
  49. {INTC, INTC, INTC, INTC}, /* GigE */
  50. {-1, -1, -1, -1},
  51. {-1, -1, -1, -1},
  52. };
  53. BUG_ON(pin < 1 || pin > 4);
  54. return PCI_IRQ_TABLE_LOOKUP(1, 7);
  55. }
  56. static int iq80332_setup(int nr, struct pci_sys_data *sys)
  57. {
  58. struct resource *res;
  59. if(nr != 0)
  60. return 0;
  61. res = kmalloc(sizeof(struct resource) * 2, GFP_KERNEL);
  62. if (!res)
  63. panic("PCI: unable to alloc resources");
  64. memset(res, 0, sizeof(struct resource) * 2);
  65. res[0].start = IOP331_PCI_LOWER_IO_VA;
  66. res[0].end = IOP331_PCI_UPPER_IO_VA;
  67. res[0].name = "IQ80332 PCI I/O Space";
  68. res[0].flags = IORESOURCE_IO;
  69. res[1].start = IOP331_PCI_LOWER_MEM_PA;
  70. res[1].end = IOP331_PCI_UPPER_MEM_PA;
  71. res[1].name = "IQ80332 PCI Memory Space";
  72. res[1].flags = IORESOURCE_MEM;
  73. request_resource(&ioport_resource, &res[0]);
  74. request_resource(&iomem_resource, &res[1]);
  75. sys->mem_offset = IOP331_PCI_MEM_OFFSET;
  76. sys->io_offset = IOP331_PCI_IO_OFFSET;
  77. sys->resource[0] = &res[0];
  78. sys->resource[1] = &res[1];
  79. sys->resource[2] = NULL;
  80. return 1;
  81. }
  82. static void iq80332_preinit(void)
  83. {
  84. iop331_init();
  85. }
  86. static struct hw_pci iq80332_pci __initdata = {
  87. .swizzle = pci_std_swizzle,
  88. .nr_controllers = 1,
  89. .setup = iq80332_setup,
  90. .scan = iop331_scan_bus,
  91. .preinit = iq80332_preinit,
  92. .map_irq = iq80332_map_irq
  93. };
  94. static int __init iq80332_pci_init(void)
  95. {
  96. if (machine_is_iq80332())
  97. pci_common_init(&iq80332_pci);
  98. return 0;
  99. }
  100. subsys_initcall(iq80332_pci_init);