]> git.karo-electronics.de Git - linux-beck.git/commitdiff
bcma: add helpers bringing PCIe hosted bus up / down
authorRafał Miłecki <zajec5@gmail.com>
Sun, 8 Feb 2015 16:11:47 +0000 (17:11 +0100)
committerKalle Valo <kvalo@codeaurora.org>
Mon, 2 Mar 2015 14:59:45 +0000 (16:59 +0200)
Bringing PCIe hosted bus up requires operating on host-related core.
Since we plan to support PCIe Gen 2 devices we should provide a helper
picking the correct one (PCIE or PCIE2).

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/bcma/bcma_private.h
drivers/bcma/driver_pci.c
drivers/bcma/host_pci.c
drivers/net/wireless/b43/main.c
drivers/net/wireless/brcm80211/brcmsmac/main.c
include/linux/bcma/bcma.h
include/linux/bcma/bcma_driver_pci.h

index ac6c5fca906d015d585f35fd9b57dc6f68d9d70b..351f4afdad25efeb1f53737ee9a1298dea820492 100644 (file)
@@ -101,6 +101,8 @@ static inline void __exit bcma_host_soc_unregister_driver(void)
 
 /* driver_pci.c */
 u32 bcma_pcie_read(struct bcma_drv_pci *pc, u32 address);
+void bcma_core_pci_up(struct bcma_drv_pci *pc);
+void bcma_core_pci_down(struct bcma_drv_pci *pc);
 
 extern int bcma_chipco_watchdog_register(struct bcma_drv_cc *cc);
 
index 786666488a2dc2f7d0d076fa44096656501493a8..cf92bfa7eae0559b753bb3e40cc0013924b7b4a0 100644 (file)
@@ -328,28 +328,12 @@ static void bcma_core_pci_extend_L1timer(struct bcma_drv_pci *pc, bool extend)
        bcma_pcie_read(pc, BCMA_CORE_PCI_DLLP_PMTHRESHREG);
 }
 
-void bcma_core_pci_up(struct bcma_bus *bus)
+void bcma_core_pci_up(struct bcma_drv_pci *pc)
 {
-       struct bcma_drv_pci *pc;
-
-       if (bus->hosttype != BCMA_HOSTTYPE_PCI)
-               return;
-
-       pc = &bus->drv_pci[0];
-
        bcma_core_pci_extend_L1timer(pc, true);
 }
-EXPORT_SYMBOL_GPL(bcma_core_pci_up);
 
-void bcma_core_pci_down(struct bcma_bus *bus)
+void bcma_core_pci_down(struct bcma_drv_pci *pc)
 {
-       struct bcma_drv_pci *pc;
-
-       if (bus->hosttype != BCMA_HOSTTYPE_PCI)
-               return;
-
-       pc = &bus->drv_pci[0];
-
        bcma_core_pci_extend_L1timer(pc, false);
 }
-EXPORT_SYMBOL_GPL(bcma_core_pci_down);
index 53c6a8a58859bb8b252b9921eb2c96935d099f7f..8dd37dc94cae13c0955d49ac90cbdc782703258e 100644 (file)
@@ -310,3 +310,31 @@ void __exit bcma_host_pci_exit(void)
 {
        pci_unregister_driver(&bcma_pci_bridge_driver);
 }
+
+/**************************************************
+ * Runtime ops for drivers.
+ **************************************************/
+
+/* See also pcicore_up */
+void bcma_host_pci_up(struct bcma_bus *bus)
+{
+       if (bus->hosttype != BCMA_HOSTTYPE_PCI)
+               return;
+
+       if (bus->host_is_pcie2)
+               pr_warn("Bringing up bus with PCIe Gen 2 host is unsupported yet\n");
+       else
+               bcma_core_pci_up(&bus->drv_pci[0]);
+}
+EXPORT_SYMBOL_GPL(bcma_host_pci_up);
+
+/* See also pcicore_down */
+void bcma_host_pci_down(struct bcma_bus *bus)
+{
+       if (bus->hosttype != BCMA_HOSTTYPE_PCI)
+               return;
+
+       if (!bus->host_is_pcie2)
+               bcma_core_pci_down(&bus->drv_pci[0]);
+}
+EXPORT_SYMBOL_GPL(bcma_host_pci_down);
index ccbdb05b28cd7e2dc457afe9443e35ac2ca3fc21..34065a6f7725a1093c1a9480c9fe2acb2112f304 100644 (file)
@@ -4819,7 +4819,7 @@ static void b43_wireless_core_exit(struct b43_wldev *dev)
        switch (dev->dev->bus_type) {
 #ifdef CONFIG_B43_BCMA
        case B43_BUS_BCMA:
-               bcma_core_pci_down(dev->dev->bdev->bus);
+               bcma_host_pci_down(dev->dev->bdev->bus);
                break;
 #endif
 #ifdef CONFIG_B43_SSB
@@ -4868,7 +4868,7 @@ static int b43_wireless_core_init(struct b43_wldev *dev)
        case B43_BUS_BCMA:
                bcma_core_pci_irq_ctl(&dev->dev->bdev->bus->drv_pci[0],
                                      dev->dev->bdev, true);
-               bcma_core_pci_up(dev->dev->bdev->bus);
+               bcma_host_pci_up(dev->dev->bdev->bus);
                break;
 #endif
 #ifdef CONFIG_B43_SSB
index eb8584a9c49a84d28a5ec592ce943a6243e3029f..bcbfc6e467e493fadf8f7e4260d6c0271d9703d3 100644 (file)
@@ -4668,7 +4668,7 @@ static int brcms_b_attach(struct brcms_c_info *wlc, struct bcma_device *core,
        brcms_c_coredisable(wlc_hw);
 
        /* Match driver "down" state */
-       bcma_core_pci_down(wlc_hw->d11core->bus);
+       bcma_host_pci_down(wlc_hw->d11core->bus);
 
        /* turn off pll and xtal to match driver "down" state */
        brcms_b_xtal(wlc_hw, OFF);
@@ -4969,12 +4969,12 @@ static int brcms_b_up_prep(struct brcms_hardware *wlc_hw)
         */
        if (brcms_b_radio_read_hwdisabled(wlc_hw)) {
                /* put SB PCI in down state again */
-               bcma_core_pci_down(wlc_hw->d11core->bus);
+               bcma_host_pci_down(wlc_hw->d11core->bus);
                brcms_b_xtal(wlc_hw, OFF);
                return -ENOMEDIUM;
        }
 
-       bcma_core_pci_up(wlc_hw->d11core->bus);
+       bcma_host_pci_up(wlc_hw->d11core->bus);
 
        /* reset the d11 core */
        brcms_b_corereset(wlc_hw, BRCMS_USE_COREFLAGS);
@@ -5171,7 +5171,7 @@ static int brcms_b_down_finish(struct brcms_hardware *wlc_hw)
 
                /* turn off primary xtal and pll */
                if (!wlc_hw->noreset) {
-                       bcma_core_pci_down(wlc_hw->d11core->bus);
+                       bcma_host_pci_down(wlc_hw->d11core->bus);
                        brcms_b_xtal(wlc_hw, OFF);
                }
        }
index 994739da827f26cb574e97411e92b82d3f23d340..037620b3f1134501bfed71364c82f7ec83fd297c 100644 (file)
@@ -434,6 +434,9 @@ static inline struct bcma_device *bcma_find_core(struct bcma_bus *bus,
        return bcma_find_core_unit(bus, coreid, 0);
 }
 
+extern void bcma_host_pci_up(struct bcma_bus *bus);
+extern void bcma_host_pci_down(struct bcma_bus *bus);
+
 extern bool bcma_core_is_enabled(struct bcma_device *core);
 extern void bcma_core_disable(struct bcma_device *core, u32 flags);
 extern int bcma_core_enable(struct bcma_device *core, u32 flags);
index 3f809ae372c4aa702cf13f350840fd80552ee1ca..23af893e9b86a38fd35770d1b6630b3bfd26c056 100644 (file)
@@ -242,8 +242,6 @@ extern void bcma_core_pci_early_init(struct bcma_drv_pci *pc);
 extern void bcma_core_pci_init(struct bcma_drv_pci *pc);
 extern int bcma_core_pci_irq_ctl(struct bcma_drv_pci *pc,
                                 struct bcma_device *core, bool enable);
-extern void bcma_core_pci_up(struct bcma_bus *bus);
-extern void bcma_core_pci_down(struct bcma_bus *bus);
 extern void bcma_core_pci_power_save(struct bcma_bus *bus, bool up);
 
 extern int bcma_core_pci_pcibios_map_irq(const struct pci_dev *dev);