Skip to content

Commit 399500d

Browse files
rmileckiKalle Valo
authored andcommitted
ssb: pick PCMCIA host code support from b43 driver
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]>
1 parent 0117e78 commit 399500d

File tree

9 files changed

+146
-196
lines changed

9 files changed

+146
-196
lines changed

drivers/net/wireless/b43/Kconfig

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -71,26 +71,6 @@ config B43_PCICORE_AUTOSELECT
7171
select SSB_DRIVER_PCICORE
7272
default y
7373

74-
config B43_PCMCIA
75-
bool "Broadcom 43xx PCMCIA device support"
76-
depends on B43 && B43_SSB && SSB_PCMCIAHOST_POSSIBLE
77-
select SSB_PCMCIAHOST
78-
---help---
79-
Broadcom 43xx PCMCIA device support.
80-
81-
Support for 16bit PCMCIA devices.
82-
Please note that most PC-CARD devices are _NOT_ 16bit PCMCIA
83-
devices, but 32bit CardBUS devices. CardBUS devices are supported
84-
out of the box by b43.
85-
86-
With this config option you can drive b43 cards in
87-
CompactFlash formfactor in a PCMCIA adaptor.
88-
CF b43 cards can sometimes be found in handheld PCs.
89-
90-
It's safe to select Y here, even if you don't have a B43 PCMCIA device.
91-
92-
If unsure, say N.
93-
9474
config B43_SDIO
9575
bool "Broadcom 43xx SDIO device support"
9676
depends on B43 && B43_SSB && SSB_SDIOHOST_POSSIBLE

drivers/net/wireless/b43/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ b43-y += pio.o
2121
b43-y += rfkill.o
2222
b43-y += ppr.o
2323
b43-$(CONFIG_B43_LEDS) += leds.o
24-
b43-$(CONFIG_B43_PCMCIA) += pcmcia.o
2524
b43-$(CONFIG_B43_SDIO) += sdio.o
2625
b43-$(CONFIG_B43_DEBUG) += debugfs.o
2726

drivers/net/wireless/b43/main.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
#include "sysfs.h"
5757
#include "xmit.h"
5858
#include "lo.h"
59-
#include "pcmcia.h"
6059
#include "sdio.h"
6160
#include <linux/mmc/sdio_func.h>
6261

@@ -5850,12 +5849,9 @@ static int __init b43_init(void)
58505849
int err;
58515850

58525851
b43_debugfs_init();
5853-
err = b43_pcmcia_init();
5854-
if (err)
5855-
goto err_dfs_exit;
58565852
err = b43_sdio_init();
58575853
if (err)
5858-
goto err_pcmcia_exit;
5854+
goto err_dfs_exit;
58595855
#ifdef CONFIG_B43_BCMA
58605856
err = bcma_driver_register(&b43_bcma_driver);
58615857
if (err)
@@ -5878,8 +5874,6 @@ static int __init b43_init(void)
58785874
err_sdio_exit:
58795875
#endif
58805876
b43_sdio_exit();
5881-
err_pcmcia_exit:
5882-
b43_pcmcia_exit();
58835877
err_dfs_exit:
58845878
b43_debugfs_exit();
58855879
return err;
@@ -5894,7 +5888,6 @@ static void __exit b43_exit(void)
58945888
bcma_driver_unregister(&b43_bcma_driver);
58955889
#endif
58965890
b43_sdio_exit();
5897-
b43_pcmcia_exit();
58985891
b43_debugfs_exit();
58995892
}
59005893

drivers/net/wireless/b43/pcmcia.c

Lines changed: 0 additions & 145 deletions
This file was deleted.

drivers/net/wireless/b43/pcmcia.h

Lines changed: 0 additions & 20 deletions
This file was deleted.

drivers/ssb/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ ssb-$(CONFIG_SSB_SPROM) += sprom.o
55

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

1111
# built-in drivers

drivers/ssb/bridge_pcmcia_80211.c

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
/*
2+
* Broadcom 43xx PCMCIA-SSB bridge module
3+
*
4+
* Copyright (c) 2007 Michael Buesch <[email protected]>
5+
*
6+
* Licensed under the GNU/GPL. See COPYING for details.
7+
*/
8+
9+
#include <linux/ssb/ssb.h>
10+
#include <linux/slab.h>
11+
#include <linux/module.h>
12+
13+
#include <pcmcia/cistpl.h>
14+
#include <pcmcia/ciscode.h>
15+
#include <pcmcia/ds.h>
16+
#include <pcmcia/cisreg.h>
17+
18+
#include "ssb_private.h"
19+
20+
static const struct pcmcia_device_id ssb_host_pcmcia_tbl[] = {
21+
PCMCIA_DEVICE_MANF_CARD(0x2D0, 0x448),
22+
PCMCIA_DEVICE_MANF_CARD(0x2D0, 0x476),
23+
PCMCIA_DEVICE_NULL,
24+
};
25+
26+
MODULE_DEVICE_TABLE(pcmcia, ssb_host_pcmcia_tbl);
27+
28+
static int ssb_host_pcmcia_probe(struct pcmcia_device *dev)
29+
{
30+
struct ssb_bus *ssb;
31+
int err = -ENOMEM;
32+
int res = 0;
33+
34+
ssb = kzalloc(sizeof(*ssb), GFP_KERNEL);
35+
if (!ssb)
36+
goto out_error;
37+
38+
err = -ENODEV;
39+
40+
dev->config_flags |= CONF_ENABLE_IRQ;
41+
42+
dev->resource[2]->flags |= WIN_ENABLE | WIN_DATA_WIDTH_16 |
43+
WIN_USE_WAIT;
44+
dev->resource[2]->start = 0;
45+
dev->resource[2]->end = SSB_CORE_SIZE;
46+
res = pcmcia_request_window(dev, dev->resource[2], 250);
47+
if (res != 0)
48+
goto err_kfree_ssb;
49+
50+
res = pcmcia_map_mem_page(dev, dev->resource[2], 0);
51+
if (res != 0)
52+
goto err_disable;
53+
54+
if (!dev->irq)
55+
goto err_disable;
56+
57+
res = pcmcia_enable_device(dev);
58+
if (res != 0)
59+
goto err_disable;
60+
61+
err = ssb_bus_pcmciabus_register(ssb, dev, dev->resource[2]->start);
62+
if (err)
63+
goto err_disable;
64+
dev->priv = ssb;
65+
66+
return 0;
67+
68+
err_disable:
69+
pcmcia_disable_device(dev);
70+
err_kfree_ssb:
71+
kfree(ssb);
72+
out_error:
73+
ssb_err("Initialization failed (%d, %d)\n", res, err);
74+
return err;
75+
}
76+
77+
static void ssb_host_pcmcia_remove(struct pcmcia_device *dev)
78+
{
79+
struct ssb_bus *ssb = dev->priv;
80+
81+
ssb_bus_unregister(ssb);
82+
pcmcia_disable_device(dev);
83+
kfree(ssb);
84+
dev->priv = NULL;
85+
}
86+
87+
#ifdef CONFIG_PM
88+
static int ssb_host_pcmcia_suspend(struct pcmcia_device *dev)
89+
{
90+
struct ssb_bus *ssb = dev->priv;
91+
92+
return ssb_bus_suspend(ssb);
93+
}
94+
95+
static int ssb_host_pcmcia_resume(struct pcmcia_device *dev)
96+
{
97+
struct ssb_bus *ssb = dev->priv;
98+
99+
return ssb_bus_resume(ssb);
100+
}
101+
#else /* CONFIG_PM */
102+
# define ssb_host_pcmcia_suspend NULL
103+
# define ssb_host_pcmcia_resume NULL
104+
#endif /* CONFIG_PM */
105+
106+
static struct pcmcia_driver ssb_host_pcmcia_driver = {
107+
.owner = THIS_MODULE,
108+
.name = "ssb-pcmcia",
109+
.id_table = ssb_host_pcmcia_tbl,
110+
.probe = ssb_host_pcmcia_probe,
111+
.remove = ssb_host_pcmcia_remove,
112+
.suspend = ssb_host_pcmcia_suspend,
113+
.resume = ssb_host_pcmcia_resume,
114+
};
115+
116+
/*
117+
* These are not module init/exit functions!
118+
* The module_pcmcia_driver() helper cannot be used here.
119+
*/
120+
int ssb_host_pcmcia_init(void)
121+
{
122+
return pcmcia_register_driver(&ssb_host_pcmcia_driver);
123+
}
124+
125+
void ssb_host_pcmcia_exit(void)
126+
{
127+
pcmcia_unregister_driver(&ssb_host_pcmcia_driver);
128+
}

0 commit comments

Comments
 (0)