pci-bcm47xx.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. * Copyright (C) 2008 Aurelien Jarno <aurelien@aurel32.net>
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms of the GNU General Public License as published by the
  6. * Free Software Foundation; either version 2 of the License, or (at your
  7. * option) any later version.
  8. *
  9. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
  10. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  11. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
  12. * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  13. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  14. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  15. * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  16. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  17. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  18. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  19. *
  20. * You should have received a copy of the GNU General Public License along
  21. * with this program; if not, write to the Free Software Foundation, Inc.,
  22. * 675 Mass Ave, Cambridge, MA 02139, USA.
  23. */
  24. #include <linux/types.h>
  25. #include <linux/pci.h>
  26. #include <linux/ssb/ssb.h>
  27. #include <linux/bcma/bcma.h>
  28. #include <bcm47xx.h>
  29. int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
  30. {
  31. return 0;
  32. }
  33. #ifdef CONFIG_BCM47XX_SSB
  34. static int bcm47xx_pcibios_plat_dev_init_ssb(struct pci_dev *dev)
  35. {
  36. int res;
  37. u8 slot, pin;
  38. res = ssb_pcibios_plat_dev_init(dev);
  39. if (res < 0) {
  40. printk(KERN_ALERT "PCI: Failed to init device %s\n",
  41. pci_name(dev));
  42. return res;
  43. }
  44. pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin);
  45. slot = PCI_SLOT(dev->devfn);
  46. res = ssb_pcibios_map_irq(dev, slot, pin);
  47. /* IRQ-0 and IRQ-1 are software interrupts. */
  48. if (res < 2) {
  49. printk(KERN_ALERT "PCI: Failed to map IRQ of device %s\n",
  50. pci_name(dev));
  51. return res;
  52. }
  53. dev->irq = res;
  54. return 0;
  55. }
  56. #endif
  57. #ifdef CONFIG_BCM47XX_BCMA
  58. static int bcm47xx_pcibios_plat_dev_init_bcma(struct pci_dev *dev)
  59. {
  60. int res;
  61. res = bcma_core_pci_plat_dev_init(dev);
  62. if (res < 0) {
  63. printk(KERN_ALERT "PCI: Failed to init device %s\n",
  64. pci_name(dev));
  65. return res;
  66. }
  67. res = bcma_core_pci_pcibios_map_irq(dev);
  68. /* IRQ-0 and IRQ-1 are software interrupts. */
  69. if (res < 2) {
  70. printk(KERN_ALERT "PCI: Failed to map IRQ of device %s\n",
  71. pci_name(dev));
  72. return res;
  73. }
  74. dev->irq = res;
  75. return 0;
  76. }
  77. #endif
  78. int pcibios_plat_dev_init(struct pci_dev *dev)
  79. {
  80. #ifdef CONFIG_BCM47XX_SSB
  81. if (bcm47xx_bus_type == BCM47XX_BUS_TYPE_SSB)
  82. return bcm47xx_pcibios_plat_dev_init_ssb(dev);
  83. else
  84. #endif
  85. #ifdef CONFIG_BCM47XX_BCMA
  86. if (bcm47xx_bus_type == BCM47XX_BUS_TYPE_BCMA)
  87. return bcm47xx_pcibios_plat_dev_init_bcma(dev);
  88. else
  89. #endif
  90. return 0;
  91. }