2009-09-10 19:34:49 +02:00
|
|
|
/*
|
|
|
|
* Broadcom B43 wireless driver
|
|
|
|
*
|
|
|
|
* SDIO over Sonics Silicon Backplane bus glue for b43.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2009 Albert Herranz
|
2011-07-04 20:50:05 +02:00
|
|
|
* Copyright (C) 2009 Michael Buesch <m@bues.ch>
|
2009-09-10 19:34:49 +02:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or (at
|
|
|
|
* your option) any later version.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/mmc/card.h>
|
|
|
|
#include <linux/mmc/sdio_func.h>
|
|
|
|
#include <linux/mmc/sdio_ids.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 09:04:11 +01:00
|
|
|
#include <linux/slab.h>
|
2009-09-10 19:34:49 +02:00
|
|
|
#include <linux/ssb/ssb.h>
|
|
|
|
|
|
|
|
#include "sdio.h"
|
|
|
|
#include "b43.h"
|
|
|
|
|
|
|
|
|
|
|
|
#define HNBU_CHIPID 0x01 /* vendor & device id */
|
|
|
|
|
|
|
|
#define B43_SDIO_BLOCK_SIZE 64 /* rx fifo max size in bytes */
|
|
|
|
|
|
|
|
|
|
|
|
static const struct b43_sdio_quirk {
|
|
|
|
u16 vendor;
|
|
|
|
u16 device;
|
|
|
|
unsigned int quirks;
|
|
|
|
} b43_sdio_quirks[] = {
|
|
|
|
{ 0x14E4, 0x4318, SSB_QUIRK_SDIO_READ_AFTER_WRITE32, },
|
|
|
|
{ },
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static unsigned int b43_sdio_get_quirks(u16 vendor, u16 device)
|
|
|
|
{
|
|
|
|
const struct b43_sdio_quirk *q;
|
|
|
|
|
|
|
|
for (q = b43_sdio_quirks; q->quirks; q++) {
|
|
|
|
if (vendor == q->vendor && device == q->device)
|
|
|
|
return q->quirks;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void b43_sdio_interrupt_dispatcher(struct sdio_func *func)
|
|
|
|
{
|
|
|
|
struct b43_sdio *sdio = sdio_get_drvdata(func);
|
|
|
|
struct b43_wldev *dev = sdio->irq_handler_opaque;
|
|
|
|
|
2009-09-11 16:00:19 +02:00
|
|
|
if (unlikely(b43_status(dev) < B43_STAT_STARTED))
|
|
|
|
return;
|
|
|
|
|
|
|
|
sdio_release_host(func);
|
2009-09-10 19:34:49 +02:00
|
|
|
sdio->irq_handler(dev);
|
2009-09-11 16:00:19 +02:00
|
|
|
sdio_claim_host(func);
|
2009-09-10 19:34:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int b43_sdio_request_irq(struct b43_wldev *dev,
|
|
|
|
void (*handler)(struct b43_wldev *dev))
|
|
|
|
{
|
2011-05-19 15:11:25 +02:00
|
|
|
struct ssb_bus *bus = dev->dev->sdev->bus;
|
2009-09-10 19:34:49 +02:00
|
|
|
struct sdio_func *func = bus->host_sdio;
|
|
|
|
struct b43_sdio *sdio = sdio_get_drvdata(func);
|
|
|
|
int err;
|
|
|
|
|
|
|
|
sdio->irq_handler_opaque = dev;
|
|
|
|
sdio->irq_handler = handler;
|
|
|
|
sdio_claim_host(func);
|
|
|
|
err = sdio_claim_irq(func, b43_sdio_interrupt_dispatcher);
|
|
|
|
sdio_release_host(func);
|
|
|
|
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
void b43_sdio_free_irq(struct b43_wldev *dev)
|
|
|
|
{
|
2011-05-19 15:11:25 +02:00
|
|
|
struct ssb_bus *bus = dev->dev->sdev->bus;
|
2009-09-10 19:34:49 +02:00
|
|
|
struct sdio_func *func = bus->host_sdio;
|
|
|
|
struct b43_sdio *sdio = sdio_get_drvdata(func);
|
|
|
|
|
|
|
|
sdio_claim_host(func);
|
|
|
|
sdio_release_irq(func);
|
|
|
|
sdio_release_host(func);
|
|
|
|
sdio->irq_handler_opaque = NULL;
|
|
|
|
sdio->irq_handler = NULL;
|
|
|
|
}
|
|
|
|
|
2012-12-03 15:56:30 +01:00
|
|
|
static int b43_sdio_probe(struct sdio_func *func,
|
2011-06-21 20:57:16 +02:00
|
|
|
const struct sdio_device_id *id)
|
2009-09-10 19:34:49 +02:00
|
|
|
{
|
|
|
|
struct b43_sdio *sdio;
|
|
|
|
struct sdio_func_tuple *tuple;
|
|
|
|
u16 vendor = 0, device = 0;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
/* Look for the card chip identifier. */
|
|
|
|
tuple = func->tuples;
|
|
|
|
while (tuple) {
|
|
|
|
switch (tuple->code) {
|
|
|
|
case 0x80:
|
|
|
|
switch (tuple->data[0]) {
|
|
|
|
case HNBU_CHIPID:
|
|
|
|
if (tuple->size != 5)
|
|
|
|
break;
|
|
|
|
vendor = tuple->data[1] | (tuple->data[2]<<8);
|
|
|
|
device = tuple->data[3] | (tuple->data[4]<<8);
|
|
|
|
dev_info(&func->dev, "Chip ID %04x:%04x\n",
|
|
|
|
vendor, device);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
tuple = tuple->next;
|
|
|
|
}
|
|
|
|
if (!vendor || !device) {
|
|
|
|
error = -ENODEV;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
sdio_claim_host(func);
|
|
|
|
error = sdio_set_block_size(func, B43_SDIO_BLOCK_SIZE);
|
|
|
|
if (error) {
|
|
|
|
dev_err(&func->dev, "failed to set block size to %u bytes,"
|
|
|
|
" error %d\n", B43_SDIO_BLOCK_SIZE, error);
|
|
|
|
goto err_release_host;
|
|
|
|
}
|
|
|
|
error = sdio_enable_func(func);
|
|
|
|
if (error) {
|
|
|
|
dev_err(&func->dev, "failed to enable func, error %d\n", error);
|
|
|
|
goto err_release_host;
|
|
|
|
}
|
|
|
|
sdio_release_host(func);
|
|
|
|
|
|
|
|
sdio = kzalloc(sizeof(*sdio), GFP_KERNEL);
|
|
|
|
if (!sdio) {
|
|
|
|
error = -ENOMEM;
|
|
|
|
dev_err(&func->dev, "failed to allocate ssb bus\n");
|
|
|
|
goto err_disable_func;
|
|
|
|
}
|
|
|
|
error = ssb_bus_sdiobus_register(&sdio->ssb, func,
|
|
|
|
b43_sdio_get_quirks(vendor, device));
|
|
|
|
if (error) {
|
|
|
|
dev_err(&func->dev, "failed to register ssb sdio bus,"
|
|
|
|
" error %d\n", error);
|
|
|
|
goto err_free_ssb;
|
|
|
|
}
|
|
|
|
sdio_set_drvdata(func, sdio);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
err_free_ssb:
|
|
|
|
kfree(sdio);
|
|
|
|
err_disable_func:
|
2010-11-23 17:10:24 +01:00
|
|
|
sdio_claim_host(func);
|
2009-09-10 19:34:49 +02:00
|
|
|
sdio_disable_func(func);
|
|
|
|
err_release_host:
|
|
|
|
sdio_release_host(func);
|
|
|
|
out:
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2012-12-03 15:56:30 +01:00
|
|
|
static void b43_sdio_remove(struct sdio_func *func)
|
2009-09-10 19:34:49 +02:00
|
|
|
{
|
|
|
|
struct b43_sdio *sdio = sdio_get_drvdata(func);
|
|
|
|
|
|
|
|
ssb_bus_unregister(&sdio->ssb);
|
2010-10-28 17:43:26 +02:00
|
|
|
sdio_claim_host(func);
|
2009-09-10 19:34:49 +02:00
|
|
|
sdio_disable_func(func);
|
2010-10-28 17:43:26 +02:00
|
|
|
sdio_release_host(func);
|
2009-09-10 19:34:49 +02:00
|
|
|
kfree(sdio);
|
|
|
|
sdio_set_drvdata(func, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct sdio_device_id b43_sdio_ids[] = {
|
|
|
|
{ SDIO_DEVICE(0x02d0, 0x044b) }, /* Nintendo Wii WLAN daughter card */
|
b43: Add SDIO_DEVICE() for EW-CG1102GC
This patch enables the EW-CG1102GC SDIO card in the b43 driver.
b43-sdio mmc0:0001:1: Chip ID 14e4:4318
ssb: Core 0 found: ChipCommon (cc 0x800, rev 0x0D, vendor 0x4243)
ssb: Core 1 found: IEEE 802.11 (cc 0x812, rev 0x09, vendor 0x4243)
ssb: Core 2 found: PCI (cc 0x804, rev 0x0C, vendor 0x4243)
ssb: Core 3 found: PCMCIA (cc 0x80D, rev 0x07, vendor 0x4243)
b43-phy0: Broadcom 4318 WLAN found (core revision 9)
b43-phy0 debug: Found PHY: Analog 3, Type 2, Revision 7
b43-phy0 debug: Found Radio: Manuf 0x17F, Version 0x2050, Revision 8
Tested with openfwwf-5.2 using a SuperH SDHI host controller.
Signed-off-by: Magnus Damm <damm@opensource.se>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2010-06-25 11:32:54 +02:00
|
|
|
{ SDIO_DEVICE(0x0092, 0x0004) }, /* C-guys, Inc. EW-CG1102GC */
|
2009-09-10 19:34:49 +02:00
|
|
|
{ },
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct sdio_driver b43_sdio_driver = {
|
|
|
|
.name = "b43-sdio",
|
|
|
|
.id_table = b43_sdio_ids,
|
|
|
|
.probe = b43_sdio_probe,
|
2012-12-03 15:56:30 +01:00
|
|
|
.remove = b43_sdio_remove,
|
2009-09-10 19:34:49 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
int b43_sdio_init(void)
|
|
|
|
{
|
|
|
|
return sdio_register_driver(&b43_sdio_driver);
|
|
|
|
}
|
|
|
|
|
|
|
|
void b43_sdio_exit(void)
|
|
|
|
{
|
|
|
|
sdio_unregister_driver(&b43_sdio_driver);
|
|
|
|
}
|