2 * Sonics Silicon Backplane
3 * Embedded systems support code
5 * Copyright 2005-2008, Broadcom Corporation
6 * Copyright 2006-2008, Michael Buesch <mb@bu3sch.de>
8 * Licensed under the GNU/GPL. See COPYING for details.
11 #include <linux/ssb/ssb.h>
12 #include <linux/ssb/ssb_embedded.h>
13 #include <linux/ssb/ssb_driver_pci.h>
14 #include <linux/ssb/ssb_driver_gige.h>
15 #include <linux/pci.h>
17 #include "ssb_private.h"
20 int ssb_watchdog_timer_set(struct ssb_bus
*bus
, u32 ticks
)
22 if (ssb_chipco_available(&bus
->chipco
)) {
23 ssb_chipco_watchdog_timer_set(&bus
->chipco
, ticks
);
26 if (ssb_extif_available(&bus
->extif
)) {
27 ssb_extif_watchdog_timer_set(&bus
->extif
, ticks
);
33 u32
ssb_gpio_in(struct ssb_bus
*bus
, u32 mask
)
38 spin_lock_irqsave(&bus
->gpio_lock
, flags
);
39 if (ssb_chipco_available(&bus
->chipco
))
40 res
= ssb_chipco_gpio_in(&bus
->chipco
, mask
);
41 else if (ssb_extif_available(&bus
->extif
))
42 res
= ssb_extif_gpio_in(&bus
->extif
, mask
);
45 spin_unlock_irqrestore(&bus
->gpio_lock
, flags
);
49 EXPORT_SYMBOL(ssb_gpio_in
);
51 u32
ssb_gpio_out(struct ssb_bus
*bus
, u32 mask
, u32 value
)
56 spin_lock_irqsave(&bus
->gpio_lock
, flags
);
57 if (ssb_chipco_available(&bus
->chipco
))
58 res
= ssb_chipco_gpio_out(&bus
->chipco
, mask
, value
);
59 else if (ssb_extif_available(&bus
->extif
))
60 res
= ssb_extif_gpio_out(&bus
->extif
, mask
, value
);
63 spin_unlock_irqrestore(&bus
->gpio_lock
, flags
);
67 EXPORT_SYMBOL(ssb_gpio_out
);
69 u32
ssb_gpio_outen(struct ssb_bus
*bus
, u32 mask
, u32 value
)
74 spin_lock_irqsave(&bus
->gpio_lock
, flags
);
75 if (ssb_chipco_available(&bus
->chipco
))
76 res
= ssb_chipco_gpio_outen(&bus
->chipco
, mask
, value
);
77 else if (ssb_extif_available(&bus
->extif
))
78 res
= ssb_extif_gpio_outen(&bus
->extif
, mask
, value
);
81 spin_unlock_irqrestore(&bus
->gpio_lock
, flags
);
85 EXPORT_SYMBOL(ssb_gpio_outen
);
87 u32
ssb_gpio_control(struct ssb_bus
*bus
, u32 mask
, u32 value
)
92 spin_lock_irqsave(&bus
->gpio_lock
, flags
);
93 if (ssb_chipco_available(&bus
->chipco
))
94 res
= ssb_chipco_gpio_control(&bus
->chipco
, mask
, value
);
95 spin_unlock_irqrestore(&bus
->gpio_lock
, flags
);
99 EXPORT_SYMBOL(ssb_gpio_control
);
101 u32
ssb_gpio_intmask(struct ssb_bus
*bus
, u32 mask
, u32 value
)
106 spin_lock_irqsave(&bus
->gpio_lock
, flags
);
107 if (ssb_chipco_available(&bus
->chipco
))
108 res
= ssb_chipco_gpio_intmask(&bus
->chipco
, mask
, value
);
109 else if (ssb_extif_available(&bus
->extif
))
110 res
= ssb_extif_gpio_intmask(&bus
->extif
, mask
, value
);
113 spin_unlock_irqrestore(&bus
->gpio_lock
, flags
);
117 EXPORT_SYMBOL(ssb_gpio_intmask
);
119 u32
ssb_gpio_polarity(struct ssb_bus
*bus
, u32 mask
, u32 value
)
124 spin_lock_irqsave(&bus
->gpio_lock
, flags
);
125 if (ssb_chipco_available(&bus
->chipco
))
126 res
= ssb_chipco_gpio_polarity(&bus
->chipco
, mask
, value
);
127 else if (ssb_extif_available(&bus
->extif
))
128 res
= ssb_extif_gpio_polarity(&bus
->extif
, mask
, value
);
131 spin_unlock_irqrestore(&bus
->gpio_lock
, flags
);
135 EXPORT_SYMBOL(ssb_gpio_polarity
);
137 #ifdef CONFIG_SSB_DRIVER_GIGE
138 static int gige_pci_init_callback(struct ssb_bus
*bus
, unsigned long data
)
140 struct pci_dev
*pdev
= (struct pci_dev
*)data
;
141 struct ssb_device
*dev
;
145 for (i
= 0; i
< bus
->nr_devices
; i
++) {
146 dev
= &(bus
->devices
[i
]);
147 if (dev
->id
.coreid
!= SSB_DEV_ETHERNET_GBIT
)
151 !device_is_registered(dev
->dev
))
153 res
= ssb_gige_pcibios_plat_dev_init(dev
, pdev
);
160 #endif /* CONFIG_SSB_DRIVER_GIGE */
162 int ssb_pcibios_plat_dev_init(struct pci_dev
*dev
)
166 err
= ssb_pcicore_plat_dev_init(dev
);
169 #ifdef CONFIG_SSB_DRIVER_GIGE
170 err
= ssb_for_each_bus_call((unsigned long)dev
, gige_pci_init_callback
);
174 /* This is not a PCI device on any SSB device. */
179 #ifdef CONFIG_SSB_DRIVER_GIGE
180 static int gige_map_irq_callback(struct ssb_bus
*bus
, unsigned long data
)
182 const struct pci_dev
*pdev
= (const struct pci_dev
*)data
;
183 struct ssb_device
*dev
;
187 for (i
= 0; i
< bus
->nr_devices
; i
++) {
188 dev
= &(bus
->devices
[i
]);
189 if (dev
->id
.coreid
!= SSB_DEV_ETHERNET_GBIT
)
193 !device_is_registered(dev
->dev
))
195 res
= ssb_gige_map_irq(dev
, pdev
);
202 #endif /* CONFIG_SSB_DRIVER_GIGE */
204 int ssb_pcibios_map_irq(const struct pci_dev
*dev
, u8 slot
, u8 pin
)
208 /* Check if this PCI device is a device on a SSB bus or device
209 * and return the IRQ number for it. */
211 res
= ssb_pcicore_pcibios_map_irq(dev
, slot
, pin
);
214 #ifdef CONFIG_SSB_DRIVER_GIGE
215 res
= ssb_for_each_bus_call((unsigned long)dev
, gige_map_irq_callback
);
219 /* This is not a PCI device on any SSB device. */