/*1* Copyright (C) 2008 Aurelien Jarno <[email protected]>2*3* This program is free software; you can redistribute it and/or modify it4* under the terms of the GNU General Public License as published by the5* Free Software Foundation; either version 2 of the License, or (at your6* option) any later version.7*8* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED9* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF10* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN11* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,12* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT13* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF14* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON15* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT16* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF17* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.18*19* You should have received a copy of the GNU General Public License along20* with this program; if not, write to the Free Software Foundation, Inc.,21* 675 Mass Ave, Cambridge, MA 02139, USA.22*/2324#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>2930int pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)31{32return 0;33}3435#ifdef CONFIG_BCM47XX_SSB36static int bcm47xx_pcibios_plat_dev_init_ssb(struct pci_dev *dev)37{38int res;39u8 slot, pin;4041res = ssb_pcibios_plat_dev_init(dev);42if (res < 0) {43pci_alert(dev, "PCI: Failed to init device\n");44return res;45}4647pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin);48slot = PCI_SLOT(dev->devfn);49res = ssb_pcibios_map_irq(dev, slot, pin);5051/* IRQ-0 and IRQ-1 are software interrupts. */52if (res < 2) {53pci_alert(dev, "PCI: Failed to map IRQ of device\n");54return res;55}5657dev->irq = res;58return 0;59}60#endif6162#ifdef CONFIG_BCM47XX_BCMA63static int bcm47xx_pcibios_plat_dev_init_bcma(struct pci_dev *dev)64{65int res;6667res = bcma_core_pci_plat_dev_init(dev);68if (res < 0) {69pci_alert(dev, "PCI: Failed to init device\n");70return res;71}7273res = bcma_core_pci_pcibios_map_irq(dev);7475/* IRQ-0 and IRQ-1 are software interrupts. */76if (res < 2) {77pci_alert(dev, "PCI: Failed to map IRQ of device\n");78return res;79}8081dev->irq = res;82return 0;83}84#endif8586int pcibios_plat_dev_init(struct pci_dev *dev)87{88#ifdef CONFIG_BCM47XX_SSB89if (bcm47xx_bus_type == BCM47XX_BUS_TYPE_SSB)90return bcm47xx_pcibios_plat_dev_init_ssb(dev);91#endif92#ifdef CONFIG_BCM47XX_BCMA93if (bcm47xx_bus_type == BCM47XX_BUS_TYPE_BCMA)94return bcm47xx_pcibios_plat_dev_init_bcma(dev);95#endif96return 0;97}9899100