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