pci-bcm47xx.c 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. * Copyright (C) 2008 Aurelien Jarno <[email protected]>
  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 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. pci_alert(dev, "PCI: Failed to init device\n");
  41. return res;
  42. }
  43. pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin);
  44. slot = PCI_SLOT(dev->devfn);
  45. res = ssb_pcibios_map_irq(dev, slot, pin);
  46. /* IRQ-0 and IRQ-1 are software interrupts. */
  47. if (res < 2) {
  48. pci_alert(dev, "PCI: Failed to map IRQ of device\n");
  49. return res;
  50. }
  51. dev->irq = res;
  52. return 0;
  53. }
  54. #endif
  55. #ifdef CONFIG_BCM47XX_BCMA
  56. static int bcm47xx_pcibios_plat_dev_init_bcma(struct pci_dev *dev)
  57. {
  58. int res;
  59. res = bcma_core_pci_plat_dev_init(dev);
  60. if (res < 0) {
  61. pci_alert(dev, "PCI: Failed to init device\n");
  62. return res;
  63. }
  64. res = bcma_core_pci_pcibios_map_irq(dev);
  65. /* IRQ-0 and IRQ-1 are software interrupts. */
  66. if (res < 2) {
  67. pci_alert(dev, "PCI: Failed to map IRQ of device\n");
  68. return res;
  69. }
  70. dev->irq = res;
  71. return 0;
  72. }
  73. #endif
  74. int pcibios_plat_dev_init(struct pci_dev *dev)
  75. {
  76. #ifdef CONFIG_BCM47XX_SSB
  77. if (bcm47xx_bus_type == BCM47XX_BUS_TYPE_SSB)
  78. return bcm47xx_pcibios_plat_dev_init_ssb(dev);
  79. #endif
  80. #ifdef CONFIG_BCM47XX_BCMA
  81. if (bcm47xx_bus_type == BCM47XX_BUS_TYPE_BCMA)
  82. return bcm47xx_pcibios_plat_dev_init_bcma(dev);
  83. #endif
  84. return 0;
  85. }