Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  *  Copyright (C) 2008 Aurelien Jarno <aurelien@aurel32.net>
0003  *
0004  *  This program is free software; you can redistribute  it and/or modify it
0005  *  under  the terms of  the GNU General  Public License as published by the
0006  *  Free Software Foundation;  either version 2 of the  License, or (at your
0007  *  option) any later version.
0008  *
0009  *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
0010  *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
0011  *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
0012  *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
0013  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
0014  *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
0015  *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
0016  *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
0017  *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
0018  *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0019  *
0020  *  You should have received a copy of the  GNU General Public License along
0021  *  with this program; if not, write  to the Free Software Foundation, Inc.,
0022  *  675 Mass Ave, Cambridge, MA 02139, USA.
0023  */
0024 
0025 #include <linux/types.h>
0026 #include <linux/pci.h>
0027 #include <linux/ssb/ssb.h>
0028 #include <linux/bcma/bcma.h>
0029 #include <bcm47xx.h>
0030 
0031 int pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
0032 {
0033     return 0;
0034 }
0035 
0036 #ifdef CONFIG_BCM47XX_SSB
0037 static int bcm47xx_pcibios_plat_dev_init_ssb(struct pci_dev *dev)
0038 {
0039     int res;
0040     u8 slot, pin;
0041 
0042     res = ssb_pcibios_plat_dev_init(dev);
0043     if (res < 0) {
0044         pci_alert(dev, "PCI: Failed to init device\n");
0045         return res;
0046     }
0047 
0048     pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin);
0049     slot = PCI_SLOT(dev->devfn);
0050     res = ssb_pcibios_map_irq(dev, slot, pin);
0051 
0052     /* IRQ-0 and IRQ-1 are software interrupts. */
0053     if (res < 2) {
0054         pci_alert(dev, "PCI: Failed to map IRQ of device\n");
0055         return res;
0056     }
0057 
0058     dev->irq = res;
0059     return 0;
0060 }
0061 #endif
0062 
0063 #ifdef CONFIG_BCM47XX_BCMA
0064 static int bcm47xx_pcibios_plat_dev_init_bcma(struct pci_dev *dev)
0065 {
0066     int res;
0067 
0068     res = bcma_core_pci_plat_dev_init(dev);
0069     if (res < 0) {
0070         pci_alert(dev, "PCI: Failed to init device\n");
0071         return res;
0072     }
0073 
0074     res = bcma_core_pci_pcibios_map_irq(dev);
0075 
0076     /* IRQ-0 and IRQ-1 are software interrupts. */
0077     if (res < 2) {
0078         pci_alert(dev, "PCI: Failed to map IRQ of device\n");
0079         return res;
0080     }
0081 
0082     dev->irq = res;
0083     return 0;
0084 }
0085 #endif
0086 
0087 int pcibios_plat_dev_init(struct pci_dev *dev)
0088 {
0089 #ifdef CONFIG_BCM47XX_SSB
0090     if (bcm47xx_bus_type ==  BCM47XX_BUS_TYPE_SSB)
0091         return bcm47xx_pcibios_plat_dev_init_ssb(dev);
0092 #endif
0093 #ifdef CONFIG_BCM47XX_BCMA
0094     if  (bcm47xx_bus_type ==  BCM47XX_BUS_TYPE_BCMA)
0095         return bcm47xx_pcibios_plat_dev_init_bcma(dev);
0096 #endif
0097     return 0;
0098 }