Skip to content

Commit

Permalink
ssb: pick PCMCIA host code support from b43 driver
Browse files Browse the repository at this point in the history
ssb bus can be found on various "host" devices like PCI/PCMCIA/SDIO.
Every ssb bus contains cores AKA devices.
The main idea is to have ssb driver scan/initialize bus and register
ready-to-use cores. This way ssb drivers can operate on a single core
mostly ignoring underlaying details.

For some reason PCMCIA support was split between ssb and b43. We got
PCMCIA host device probing in b43, then bus scanning in ssb and then
wireless core probing back in b43. The truth is it's very unlikely we
will ever see PCMCIA ssb device with no 802.11 core but I still don't
see any advantage of the current architecture.

With proposed change we get the same functionality with a simpler
architecture, less Kconfig symbols, one killed EXPORT and hopefully
cleaner b43. Since b43 supports both: ssb & bcma I prefer to keep ssb
specific code in ssb driver.

This mostly moves code from b43's pcmcia.c to bridge_pcmcia_80211.c. We
already use similar solution with b43_pci_bridge.c. I didn't use "b43"
in name of this new file as in theory any driver can operate on wireless
core.

Signed-off-by: Rafał Miłecki <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>
  • Loading branch information
rmilecki authored and Kalle Valo committed Oct 28, 2015
1 parent 0117e78 commit 399500d
Show file tree
Hide file tree
Showing 9 changed files with 146 additions and 196 deletions.
20 changes: 0 additions & 20 deletions drivers/net/wireless/b43/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -71,26 +71,6 @@ config B43_PCICORE_AUTOSELECT
select SSB_DRIVER_PCICORE
default y

config B43_PCMCIA
bool "Broadcom 43xx PCMCIA device support"
depends on B43 && B43_SSB && SSB_PCMCIAHOST_POSSIBLE
select SSB_PCMCIAHOST
---help---
Broadcom 43xx PCMCIA device support.

Support for 16bit PCMCIA devices.
Please note that most PC-CARD devices are _NOT_ 16bit PCMCIA
devices, but 32bit CardBUS devices. CardBUS devices are supported
out of the box by b43.

With this config option you can drive b43 cards in
CompactFlash formfactor in a PCMCIA adaptor.
CF b43 cards can sometimes be found in handheld PCs.

It's safe to select Y here, even if you don't have a B43 PCMCIA device.

If unsure, say N.

config B43_SDIO
bool "Broadcom 43xx SDIO device support"
depends on B43 && B43_SSB && SSB_SDIOHOST_POSSIBLE
Expand Down
1 change: 0 additions & 1 deletion drivers/net/wireless/b43/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ b43-y += pio.o
b43-y += rfkill.o
b43-y += ppr.o
b43-$(CONFIG_B43_LEDS) += leds.o
b43-$(CONFIG_B43_PCMCIA) += pcmcia.o
b43-$(CONFIG_B43_SDIO) += sdio.o
b43-$(CONFIG_B43_DEBUG) += debugfs.o

Expand Down
9 changes: 1 addition & 8 deletions drivers/net/wireless/b43/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
#include "sysfs.h"
#include "xmit.h"
#include "lo.h"
#include "pcmcia.h"
#include "sdio.h"
#include <linux/mmc/sdio_func.h>

Expand Down Expand Up @@ -5850,12 +5849,9 @@ static int __init b43_init(void)
int err;

b43_debugfs_init();
err = b43_pcmcia_init();
if (err)
goto err_dfs_exit;
err = b43_sdio_init();
if (err)
goto err_pcmcia_exit;
goto err_dfs_exit;
#ifdef CONFIG_B43_BCMA
err = bcma_driver_register(&b43_bcma_driver);
if (err)
Expand All @@ -5878,8 +5874,6 @@ static int __init b43_init(void)
err_sdio_exit:
#endif
b43_sdio_exit();
err_pcmcia_exit:
b43_pcmcia_exit();
err_dfs_exit:
b43_debugfs_exit();
return err;
Expand All @@ -5894,7 +5888,6 @@ static void __exit b43_exit(void)
bcma_driver_unregister(&b43_bcma_driver);
#endif
b43_sdio_exit();
b43_pcmcia_exit();
b43_debugfs_exit();
}

Expand Down
145 changes: 0 additions & 145 deletions drivers/net/wireless/b43/pcmcia.c

This file was deleted.

20 changes: 0 additions & 20 deletions drivers/net/wireless/b43/pcmcia.h

This file was deleted.

2 changes: 1 addition & 1 deletion drivers/ssb/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ssb-$(CONFIG_SSB_SPROM) += sprom.o

# host support
ssb-$(CONFIG_SSB_PCIHOST) += pci.o pcihost_wrapper.o
ssb-$(CONFIG_SSB_PCMCIAHOST) += pcmcia.o
ssb-$(CONFIG_SSB_PCMCIAHOST) += pcmcia.o bridge_pcmcia_80211.o
ssb-$(CONFIG_SSB_SDIOHOST) += sdio.o

# built-in drivers
Expand Down
128 changes: 128 additions & 0 deletions drivers/ssb/bridge_pcmcia_80211.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
/*
* Broadcom 43xx PCMCIA-SSB bridge module
*
* Copyright (c) 2007 Michael Buesch <[email protected]>
*
* Licensed under the GNU/GPL. See COPYING for details.
*/

#include <linux/ssb/ssb.h>
#include <linux/slab.h>
#include <linux/module.h>

#include <pcmcia/cistpl.h>
#include <pcmcia/ciscode.h>
#include <pcmcia/ds.h>
#include <pcmcia/cisreg.h>

#include "ssb_private.h"

static const struct pcmcia_device_id ssb_host_pcmcia_tbl[] = {
PCMCIA_DEVICE_MANF_CARD(0x2D0, 0x448),
PCMCIA_DEVICE_MANF_CARD(0x2D0, 0x476),
PCMCIA_DEVICE_NULL,
};

MODULE_DEVICE_TABLE(pcmcia, ssb_host_pcmcia_tbl);

static int ssb_host_pcmcia_probe(struct pcmcia_device *dev)
{
struct ssb_bus *ssb;
int err = -ENOMEM;
int res = 0;

ssb = kzalloc(sizeof(*ssb), GFP_KERNEL);
if (!ssb)
goto out_error;

err = -ENODEV;

dev->config_flags |= CONF_ENABLE_IRQ;

dev->resource[2]->flags |= WIN_ENABLE | WIN_DATA_WIDTH_16 |
WIN_USE_WAIT;
dev->resource[2]->start = 0;
dev->resource[2]->end = SSB_CORE_SIZE;
res = pcmcia_request_window(dev, dev->resource[2], 250);
if (res != 0)
goto err_kfree_ssb;

res = pcmcia_map_mem_page(dev, dev->resource[2], 0);
if (res != 0)
goto err_disable;

if (!dev->irq)
goto err_disable;

res = pcmcia_enable_device(dev);
if (res != 0)
goto err_disable;

err = ssb_bus_pcmciabus_register(ssb, dev, dev->resource[2]->start);
if (err)
goto err_disable;
dev->priv = ssb;

return 0;

err_disable:
pcmcia_disable_device(dev);
err_kfree_ssb:
kfree(ssb);
out_error:
ssb_err("Initialization failed (%d, %d)\n", res, err);
return err;
}

static void ssb_host_pcmcia_remove(struct pcmcia_device *dev)
{
struct ssb_bus *ssb = dev->priv;

ssb_bus_unregister(ssb);
pcmcia_disable_device(dev);
kfree(ssb);
dev->priv = NULL;
}

#ifdef CONFIG_PM
static int ssb_host_pcmcia_suspend(struct pcmcia_device *dev)
{
struct ssb_bus *ssb = dev->priv;

return ssb_bus_suspend(ssb);
}

static int ssb_host_pcmcia_resume(struct pcmcia_device *dev)
{
struct ssb_bus *ssb = dev->priv;

return ssb_bus_resume(ssb);
}
#else /* CONFIG_PM */
# define ssb_host_pcmcia_suspend NULL
# define ssb_host_pcmcia_resume NULL
#endif /* CONFIG_PM */

static struct pcmcia_driver ssb_host_pcmcia_driver = {
.owner = THIS_MODULE,
.name = "ssb-pcmcia",
.id_table = ssb_host_pcmcia_tbl,
.probe = ssb_host_pcmcia_probe,
.remove = ssb_host_pcmcia_remove,
.suspend = ssb_host_pcmcia_suspend,
.resume = ssb_host_pcmcia_resume,
};

/*
* These are not module init/exit functions!
* The module_pcmcia_driver() helper cannot be used here.
*/
int ssb_host_pcmcia_init(void)
{
return pcmcia_register_driver(&ssb_host_pcmcia_driver);
}

void ssb_host_pcmcia_exit(void)
{
pcmcia_unregister_driver(&ssb_host_pcmcia_driver);
}
Loading

0 comments on commit 399500d

Please sign in to comment.