forked from Minki/linux
[PATCH] wireless: import bcm43xx sources
Import the bcm43xx driver from the upstream sources here: ftp://ftp.berlios.de/pub/bcm43xx/snapshots/bcm43xx/bcm43xx-20060123.tar.bz2 Signed-off-by: John W. Linville <linville@tuxdriver.com>
This commit is contained in:
parent
5d5d7727a8
commit
f222313a61
340
drivers/net/wireless/bcm43xx/COPYING
Normal file
340
drivers/net/wireless/bcm43xx/COPYING
Normal file
@ -0,0 +1,340 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Library General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
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.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Library General
|
||||
Public License instead of this License.
|
87
drivers/net/wireless/bcm43xx/Makefile
Normal file
87
drivers/net/wireless/bcm43xx/Makefile
Normal file
@ -0,0 +1,87 @@
|
||||
# Makefile for bcm43xx driver
|
||||
|
||||
VERSION := 0.0.1
|
||||
RELEASE_NAME := bcm43xx-$(VERSION)
|
||||
|
||||
# Optional path, where the SoftMAC subsystem is located.
|
||||
# You may set SOFTMAC_DIR in your bashrc, for example.
|
||||
SOFTMAC_DIR ?=
|
||||
|
||||
KVER := $(shell uname -r)
|
||||
KDIR ?= /lib/modules/$(KVER)/build
|
||||
PWD := $(shell pwd)
|
||||
MODPATH := $(DESTDIR)/lib/modules/$(KVER)/kernel/drivers/net/bcm43xx
|
||||
|
||||
# Comment/uncomment to enable/disable debugging
|
||||
DEBUG = y
|
||||
|
||||
|
||||
ifeq ($(DEBUG),y)
|
||||
DEBUGFS_OBJ = bcm43xx_debugfs.o
|
||||
CFLAGS += -O2 -DCONFIG_BCM43XX_DEBUG
|
||||
else
|
||||
DEBUGFS_OBJ =
|
||||
CFLAGS += -O2
|
||||
endif
|
||||
|
||||
CFLAGS += -DBCM43xx_VERSION=$(VERSION) -I/lib/modules/$(KVER)/include
|
||||
ifneq ($(SOFTMAC_DIR),)
|
||||
CPPFLAGS := -I$(SOFTMAC_DIR) $(CPPFLAGS)
|
||||
endif
|
||||
|
||||
ifneq ($(KERNELRELEASE),)
|
||||
# call from kernel build system
|
||||
|
||||
obj-m := bcm43xx.o
|
||||
bcm43xx-objs := bcm43xx_main.o bcm43xx_dma.o $(DEBUGFS_OBJ) \
|
||||
bcm43xx_radio.o bcm43xx_phy.o \
|
||||
bcm43xx_power.o bcm43xx_wx.o \
|
||||
bcm43xx_pio.o bcm43xx_ilt.o \
|
||||
bcm43xx_leds.o
|
||||
|
||||
else
|
||||
|
||||
default: modules
|
||||
|
||||
modules:
|
||||
$(MAKE) -C $(KDIR) M=$(PWD) modules
|
||||
|
||||
install: bcm43xx.ko
|
||||
install -d $(MODPATH)
|
||||
install -m 644 -c bcm43xx.ko $(MODPATH)
|
||||
/sbin/depmod -a
|
||||
|
||||
uninstall:
|
||||
rm -rf $(MODPATH)
|
||||
/sbin/depmod -a
|
||||
|
||||
endif
|
||||
|
||||
clean:
|
||||
find . \( -name '*.ko' -o -name '*.o' -o -name '.tmp_versions' -o -name '*~' -o -name '.*.cmd' \
|
||||
-o -name '*.mod.c' -o -name '*.tar.bz2' -o -name '*.rej' -o -name '*.orig' \)\
|
||||
-print | xargs rm -Rf
|
||||
|
||||
depend .depend dep:
|
||||
$(CC) $(CFLAGS) -M *.c > .depend
|
||||
|
||||
ifeq (.depend,$(wildcard .depend))
|
||||
include .depend
|
||||
endif
|
||||
|
||||
DISTFILES = $(shell find . \( -not -name '.' \) -print | grep -v "\.tar\.bz2" | grep -v "\/\." )
|
||||
DISTDIR = $(RELEASE_NAME)
|
||||
|
||||
release: clean
|
||||
@rm -rf $(DISTDIR)
|
||||
@mkdir $(DISTDIR)
|
||||
@chmod 777 $(DISTDIR)
|
||||
@for file in $(DISTFILES); do \
|
||||
if test -d $$file; then \
|
||||
mkdir $(DISTDIR)/$$file; \
|
||||
else \
|
||||
cp -p $$file $(DISTDIR)/$$file; \
|
||||
fi; \
|
||||
done
|
||||
@tar -c $(DISTDIR) | bzip2 -9 > $(RELEASE_NAME).tar.bz2
|
||||
@rm -rf $(DISTDIR)
|
36
drivers/net/wireless/bcm43xx/README
Normal file
36
drivers/net/wireless/bcm43xx/README
Normal file
@ -0,0 +1,36 @@
|
||||
|
||||
BCM43xx Linux Driver Project
|
||||
============================
|
||||
|
||||
About this software
|
||||
-------------------
|
||||
|
||||
The goal of this project is to develop a linux driver for Broadcom
|
||||
BCM43xx chips, based on the specification at
|
||||
http://bcm-specs.sipsolutions.net/
|
||||
|
||||
The project page is http://bcm43xx.berlios.de/
|
||||
|
||||
|
||||
Requirements
|
||||
------------
|
||||
|
||||
1) Linux Kernel 2.6.15 or later
|
||||
http://www.kernel.org/
|
||||
|
||||
You may want to configure your kernel with:
|
||||
|
||||
CONFIG_DEBUG_FS (optional):
|
||||
-> Kernel hacking
|
||||
-> Debug Filesystem
|
||||
|
||||
2) SoftMAC IEEE 802.11 Networking Stack extension and patched ieee80211
|
||||
modules:
|
||||
http://softmac.sipsolutions.net/
|
||||
|
||||
3) Firmware Files
|
||||
|
||||
Please try fwcutter. Fwcutter can extract the firmware from various
|
||||
binary driver files. It supports driver files from Windows, MacOS and
|
||||
Linux. You can get fwcutter from http://bcm43xx.berlios.de/.
|
||||
Also, fwcutter comes with a README file for further instructions.
|
961
drivers/net/wireless/bcm43xx/bcm43xx.h
Normal file
961
drivers/net/wireless/bcm43xx/bcm43xx.h
Normal file
@ -0,0 +1,961 @@
|
||||
#ifndef BCM43xx_H_
|
||||
#define BCM43xx_H_
|
||||
|
||||
#include <linux/version.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/spinlock.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/stringify.h>
|
||||
#include <linux/pci.h>
|
||||
#include <net/ieee80211.h>
|
||||
#include <net/ieee80211softmac.h>
|
||||
#include <asm/atomic.h>
|
||||
#include <asm/io.h>
|
||||
|
||||
|
||||
#include "bcm43xx_debugfs.h"
|
||||
#include "bcm43xx_leds.h"
|
||||
|
||||
|
||||
#define DRV_NAME __stringify(KBUILD_MODNAME)
|
||||
#define DRV_VERSION __stringify(BCM43xx_VERSION)
|
||||
#define BCM43xx_DRIVER_NAME DRV_NAME " driver " DRV_VERSION
|
||||
#define PFX DRV_NAME ": "
|
||||
|
||||
#define BCM43xx_SWITCH_CORE_MAX_RETRIES 10
|
||||
#define BCM43xx_IRQWAIT_MAX_RETRIES 50
|
||||
#define BCM43xx_TX_TIMEOUT (10 * HZ)
|
||||
|
||||
#define BCM43xx_IO_SIZE 8192
|
||||
#define BCM43xx_REG_ACTIVE_CORE 0x80
|
||||
|
||||
/* Interrupt Control PCI Configuration Register. (Only on PCI cores with rev >= 6) */
|
||||
#define BCM43xx_PCICFG_ICR 0x94
|
||||
/* SPROM control register. */
|
||||
#define BCM43xx_PCICFG_SPROMCTL 0x88
|
||||
|
||||
/* MMIO offsets */
|
||||
#define BCM43xx_MMIO_DMA1_REASON 0x20
|
||||
#define BCM43xx_MMIO_DMA1_IRQ_MASK 0x24
|
||||
#define BCM43xx_MMIO_DMA2_REASON 0x28
|
||||
#define BCM43xx_MMIO_DMA2_IRQ_MASK 0x2C
|
||||
#define BCM43xx_MMIO_DMA3_REASON 0x30
|
||||
#define BCM43xx_MMIO_DMA3_IRQ_MASK 0x34
|
||||
#define BCM43xx_MMIO_DMA4_REASON 0x38
|
||||
#define BCM43xx_MMIO_DMA4_IRQ_MASK 0x3C
|
||||
#define BCM43xx_MMIO_STATUS_BITFIELD 0x120
|
||||
#define BCM43xx_MMIO_STATUS2_BITFIELD 0x124
|
||||
#define BCM43xx_MMIO_GEN_IRQ_REASON 0x128
|
||||
#define BCM43xx_MMIO_GEN_IRQ_MASK 0x12C
|
||||
#define BCM43xx_MMIO_RAM_CONTROL 0x130
|
||||
#define BCM43xx_MMIO_RAM_DATA 0x134
|
||||
#define BCM43xx_MMIO_PS_STATUS 0x140
|
||||
#define BCM43xx_MMIO_RADIO_HWENABLED_HI 0x158
|
||||
#define BCM43xx_MMIO_SHM_CONTROL 0x160
|
||||
#define BCM43xx_MMIO_SHM_DATA 0x164
|
||||
#define BCM43xx_MMIO_SHM_DATA_UNALIGNED 0x166
|
||||
#define BCM43xx_MMIO_XMITSTAT_0 0x170
|
||||
#define BCM43xx_MMIO_XMITSTAT_1 0x174
|
||||
#define BCM43xx_MMIO_REV3PLUS_TSF_LOW 0x180 /* core rev >= 3 only */
|
||||
#define BCM43xx_MMIO_REV3PLUS_TSF_HIGH 0x184 /* core rev >= 3 only */
|
||||
#define BCM43xx_MMIO_DMA1_BASE 0x200
|
||||
#define BCM43xx_MMIO_DMA2_BASE 0x220
|
||||
#define BCM43xx_MMIO_DMA3_BASE 0x240
|
||||
#define BCM43xx_MMIO_DMA4_BASE 0x260
|
||||
#define BCM43xx_MMIO_PIO1_BASE 0x300
|
||||
#define BCM43xx_MMIO_PIO2_BASE 0x310
|
||||
#define BCM43xx_MMIO_PIO3_BASE 0x320
|
||||
#define BCM43xx_MMIO_PIO4_BASE 0x330
|
||||
#define BCM43xx_MMIO_PHY_VER 0x3E0
|
||||
#define BCM43xx_MMIO_PHY_RADIO 0x3E2
|
||||
#define BCM43xx_MMIO_ANTENNA 0x3E8
|
||||
#define BCM43xx_MMIO_CHANNEL 0x3F0
|
||||
#define BCM43xx_MMIO_CHANNEL_EXT 0x3F4
|
||||
#define BCM43xx_MMIO_RADIO_CONTROL 0x3F6
|
||||
#define BCM43xx_MMIO_RADIO_DATA_HIGH 0x3F8
|
||||
#define BCM43xx_MMIO_RADIO_DATA_LOW 0x3FA
|
||||
#define BCM43xx_MMIO_PHY_CONTROL 0x3FC
|
||||
#define BCM43xx_MMIO_PHY_DATA 0x3FE
|
||||
#define BCM43xx_MMIO_MACFILTER_CONTROL 0x420
|
||||
#define BCM43xx_MMIO_MACFILTER_DATA 0x422
|
||||
#define BCM43xx_MMIO_RADIO_HWENABLED_LO 0x49A
|
||||
#define BCM43xx_MMIO_GPIO_CONTROL 0x49C
|
||||
#define BCM43xx_MMIO_GPIO_MASK 0x49E
|
||||
#define BCM43xx_MMIO_TSF_0 0x632 /* core rev < 3 only */
|
||||
#define BCM43xx_MMIO_TSF_1 0x634 /* core rev < 3 only */
|
||||
#define BCM43xx_MMIO_TSF_2 0x636 /* core rev < 3 only */
|
||||
#define BCM43xx_MMIO_TSF_3 0x638 /* core rev < 3 only */
|
||||
#define BCM43xx_MMIO_POWERUP_DELAY 0x6A8
|
||||
|
||||
/* SPROM offsets. */
|
||||
#define BCM43xx_SPROM_BASE 0x1000
|
||||
#define BCM43xx_SPROM_BOARDFLAGS2 0x1c
|
||||
#define BCM43xx_SPROM_IL0MACADDR 0x24
|
||||
#define BCM43xx_SPROM_ET0MACADDR 0x27
|
||||
#define BCM43xx_SPROM_ET1MACADDR 0x2a
|
||||
#define BCM43xx_SPROM_ETHPHY 0x2d
|
||||
#define BCM43xx_SPROM_BOARDREV 0x2e
|
||||
#define BCM43xx_SPROM_PA0B0 0x2f
|
||||
#define BCM43xx_SPROM_PA0B1 0x30
|
||||
#define BCM43xx_SPROM_PA0B2 0x31
|
||||
#define BCM43xx_SPROM_WL0GPIO0 0x32
|
||||
#define BCM43xx_SPROM_WL0GPIO2 0x33
|
||||
#define BCM43xx_SPROM_MAXPWR 0x34
|
||||
#define BCM43xx_SPROM_PA1B0 0x35
|
||||
#define BCM43xx_SPROM_PA1B1 0x36
|
||||
#define BCM43xx_SPROM_PA1B2 0x37
|
||||
#define BCM43xx_SPROM_IDL_TSSI_TGT 0x38
|
||||
#define BCM43xx_SPROM_BOARDFLAGS 0x39
|
||||
#define BCM43xx_SPROM_ANTENNA_GAIN 0x3a
|
||||
#define BCM43xx_SPROM_VERSION 0x3f
|
||||
|
||||
/* BCM43xx_SPROM_BOARDFLAGS values */
|
||||
#define BCM43xx_BFL_BTCOEXIST 0x0001 /* implements Bluetooth coexistance */
|
||||
#define BCM43xx_BFL_PACTRL 0x0002 /* GPIO 9 controlling the PA */
|
||||
#define BCM43xx_BFL_AIRLINEMODE 0x0004 /* implements GPIO 13 radio disable indication */
|
||||
#define BCM43xx_BFL_RSSI 0x0008 /* software calculates nrssi slope. */
|
||||
#define BCM43xx_BFL_ENETSPI 0x0010 /* has ephy roboswitch spi */
|
||||
#define BCM43xx_BFL_XTAL_NOSLOW 0x0020 /* no slow clock available */
|
||||
#define BCM43xx_BFL_CCKHIPWR 0x0040 /* can do high power CCK transmission */
|
||||
#define BCM43xx_BFL_ENETADM 0x0080 /* has ADMtek switch */
|
||||
#define BCM43xx_BFL_ENETVLAN 0x0100 /* can do vlan */
|
||||
#define BCM43xx_BFL_AFTERBURNER 0x0200 /* supports Afterburner mode */
|
||||
#define BCM43xx_BFL_NOPCI 0x0400 /* leaves PCI floating */
|
||||
#define BCM43xx_BFL_FEM 0x0800 /* supports the Front End Module */
|
||||
|
||||
/* GPIO register offset, in both ChipCommon and PCI core. */
|
||||
#define BCM43xx_GPIO_CONTROL 0x6c
|
||||
|
||||
/* SHM Routing */
|
||||
#define BCM43xx_SHM_SHARED 0x0001
|
||||
#define BCM43xx_SHM_WIRELESS 0x0002
|
||||
#define BCM43xx_SHM_PCM 0x0003
|
||||
#define BCM43xx_SHM_HWMAC 0x0004
|
||||
#define BCM43xx_SHM_UCODE 0x0300
|
||||
|
||||
/* MacFilter offsets. */
|
||||
#define BCM43xx_MACFILTER_SELF 0x0000
|
||||
#define BCM43xx_MACFILTER_ASSOC 0x0003
|
||||
|
||||
/* Chipcommon registers. */
|
||||
#define BCM43xx_CHIPCOMMON_CAPABILITIES 0x04
|
||||
#define BCM43xx_CHIPCOMMON_PLLONDELAY 0xB0
|
||||
#define BCM43xx_CHIPCOMMON_FREFSELDELAY 0xB4
|
||||
#define BCM43xx_CHIPCOMMON_SLOWCLKCTL 0xB8
|
||||
#define BCM43xx_CHIPCOMMON_SYSCLKCTL 0xC0
|
||||
|
||||
/* PCI core specific registers. */
|
||||
#define BCM43xx_PCICORE_BCAST_ADDR 0x50
|
||||
#define BCM43xx_PCICORE_BCAST_DATA 0x54
|
||||
#define BCM43xx_PCICORE_SBTOPCI2 0x108
|
||||
|
||||
/* SBTOPCI2 values. */
|
||||
#define BCM43xx_SBTOPCI2_PREFETCH 0x4
|
||||
#define BCM43xx_SBTOPCI2_BURST 0x8
|
||||
|
||||
/* Chipcommon capabilities. */
|
||||
#define BCM43xx_CAPABILITIES_PCTL 0x00040000
|
||||
#define BCM43xx_CAPABILITIES_PLLMASK 0x00030000
|
||||
#define BCM43xx_CAPABILITIES_PLLSHIFT 16
|
||||
#define BCM43xx_CAPABILITIES_FLASHMASK 0x00000700
|
||||
#define BCM43xx_CAPABILITIES_FLASHSHIFT 8
|
||||
#define BCM43xx_CAPABILITIES_EXTBUSPRESENT 0x00000040
|
||||
#define BCM43xx_CAPABILITIES_UARTGPIO 0x00000020
|
||||
#define BCM43xx_CAPABILITIES_UARTCLOCKMASK 0x00000018
|
||||
#define BCM43xx_CAPABILITIES_UARTCLOCKSHIFT 3
|
||||
#define BCM43xx_CAPABILITIES_MIPSBIGENDIAN 0x00000004
|
||||
#define BCM43xx_CAPABILITIES_NRUARTSMASK 0x00000003
|
||||
|
||||
/* PowerControl */
|
||||
#define BCM43xx_PCTL_IN 0xB0
|
||||
#define BCM43xx_PCTL_OUT 0xB4
|
||||
#define BCM43xx_PCTL_OUTENABLE 0xB8
|
||||
#define BCM43xx_PCTL_XTAL_POWERUP 0x40
|
||||
#define BCM43xx_PCTL_PLL_POWERDOWN 0x80
|
||||
|
||||
/* PowerControl Clock Modes */
|
||||
#define BCM43xx_PCTL_CLK_FAST 0x00
|
||||
#define BCM43xx_PCTL_CLK_SLOW 0x01
|
||||
#define BCM43xx_PCTL_CLK_DYNAMIC 0x02
|
||||
|
||||
#define BCM43xx_PCTL_FORCE_SLOW 0x0800
|
||||
#define BCM43xx_PCTL_FORCE_PLL 0x1000
|
||||
#define BCM43xx_PCTL_DYN_XTAL 0x2000
|
||||
|
||||
/* COREIDs */
|
||||
#define BCM43xx_COREID_CHIPCOMMON 0x800
|
||||
#define BCM43xx_COREID_ILINE20 0x801
|
||||
#define BCM43xx_COREID_SDRAM 0x803
|
||||
#define BCM43xx_COREID_PCI 0x804
|
||||
#define BCM43xx_COREID_MIPS 0x805
|
||||
#define BCM43xx_COREID_ETHERNET 0x806
|
||||
#define BCM43xx_COREID_V90 0x807
|
||||
#define BCM43xx_COREID_USB11_HOSTDEV 0x80a
|
||||
#define BCM43xx_COREID_IPSEC 0x80b
|
||||
#define BCM43xx_COREID_PCMCIA 0x80d
|
||||
#define BCM43xx_COREID_EXT_IF 0x80f
|
||||
#define BCM43xx_COREID_80211 0x812
|
||||
#define BCM43xx_COREID_MIPS_3302 0x816
|
||||
#define BCM43xx_COREID_USB11_HOST 0x817
|
||||
#define BCM43xx_COREID_USB11_DEV 0x818
|
||||
#define BCM43xx_COREID_USB20_HOST 0x819
|
||||
#define BCM43xx_COREID_USB20_DEV 0x81a
|
||||
#define BCM43xx_COREID_SDIO_HOST 0x81b
|
||||
|
||||
/* Core Information Registers */
|
||||
#define BCM43xx_CIR_BASE 0xf00
|
||||
#define BCM43xx_CIR_SBTPSFLAG (BCM43xx_CIR_BASE + 0x18)
|
||||
#define BCM43xx_CIR_SBIMSTATE (BCM43xx_CIR_BASE + 0x90)
|
||||
#define BCM43xx_CIR_SBINTVEC (BCM43xx_CIR_BASE + 0x94)
|
||||
#define BCM43xx_CIR_SBTMSTATELOW (BCM43xx_CIR_BASE + 0x98)
|
||||
#define BCM43xx_CIR_SBTMSTATEHIGH (BCM43xx_CIR_BASE + 0x9c)
|
||||
#define BCM43xx_CIR_SBIMCONFIGLOW (BCM43xx_CIR_BASE + 0xa8)
|
||||
#define BCM43xx_CIR_SB_ID_HI (BCM43xx_CIR_BASE + 0xfc)
|
||||
|
||||
/* Mask to get the Backplane Flag Number from SBTPSFLAG. */
|
||||
#define BCM43xx_BACKPLANE_FLAG_NR_MASK 0x3f
|
||||
|
||||
/* SBIMCONFIGLOW values/masks. */
|
||||
#define BCM43xx_SBIMCONFIGLOW_SERVICE_TOUT_MASK 0x00000007
|
||||
#define BCM43xx_SBIMCONFIGLOW_SERVICE_TOUT_SHIFT 0
|
||||
#define BCM43xx_SBIMCONFIGLOW_REQUEST_TOUT_MASK 0x00000070
|
||||
#define BCM43xx_SBIMCONFIGLOW_REQUEST_TOUT_SHIFT 4
|
||||
#define BCM43xx_SBIMCONFIGLOW_CONNID_MASK 0x00ff0000
|
||||
#define BCM43xx_SBIMCONFIGLOW_CONNID_SHIFT 16
|
||||
|
||||
/* sbtmstatelow state flags */
|
||||
#define BCM43xx_SBTMSTATELOW_RESET 0x01
|
||||
#define BCM43xx_SBTMSTATELOW_REJECT 0x02
|
||||
#define BCM43xx_SBTMSTATELOW_CLOCK 0x10000
|
||||
#define BCM43xx_SBTMSTATELOW_FORCE_GATE_CLOCK 0x20000
|
||||
|
||||
/* sbtmstatehigh state flags */
|
||||
#define BCM43xx_SBTMSTATEHIGH_SERROR 0x1
|
||||
#define BCM43xx_SBTMSTATEHIGH_BUSY 0x4
|
||||
|
||||
/* sbimstate flags */
|
||||
#define BCM43xx_SBIMSTATE_IB_ERROR 0x20000
|
||||
#define BCM43xx_SBIMSTATE_TIMEOUT 0x40000
|
||||
|
||||
/* PHYVersioning */
|
||||
#define BCM43xx_PHYTYPE_A 0x00
|
||||
#define BCM43xx_PHYTYPE_B 0x01
|
||||
#define BCM43xx_PHYTYPE_G 0x02
|
||||
|
||||
/* PHYRegisters */
|
||||
#define BCM43xx_PHY_ILT_A_CTRL 0x0072
|
||||
#define BCM43xx_PHY_ILT_A_DATA1 0x0073
|
||||
#define BCM43xx_PHY_ILT_A_DATA2 0x0074
|
||||
#define BCM43xx_PHY_G_LO_CONTROL 0x0810
|
||||
#define BCM43xx_PHY_ILT_G_CTRL 0x0472
|
||||
#define BCM43xx_PHY_ILT_G_DATA1 0x0473
|
||||
#define BCM43xx_PHY_ILT_G_DATA2 0x0474
|
||||
#define BCM43xx_PHY_A_PCTL 0x007B
|
||||
#define BCM43xx_PHY_G_PCTL 0x0029
|
||||
#define BCM43xx_PHY_A_CRS 0x0029
|
||||
#define BCM43xx_PHY_RADIO_BITFIELD 0x0401
|
||||
#define BCM43xx_PHY_G_CRS 0x0429
|
||||
#define BCM43xx_PHY_NRSSILT_CTRL 0x0803
|
||||
#define BCM43xx_PHY_NRSSILT_DATA 0x0804
|
||||
|
||||
/* RadioRegisters */
|
||||
#define BCM43xx_RADIOCTL_ID 0x01
|
||||
|
||||
/* StatusBitField */
|
||||
#define BCM43xx_SBF_MAC_ENABLED 0x00000001
|
||||
#define BCM43xx_SBF_2 0x00000002 /*FIXME: fix name*/
|
||||
#define BCM43xx_SBF_CORE_READY 0x00000004
|
||||
#define BCM43xx_SBF_400 0x00000400 /*FIXME: fix name*/
|
||||
#define BCM43xx_SBF_4000 0x00004000 /*FIXME: fix name*/
|
||||
#define BCM43xx_SBF_8000 0x00008000 /*FIXME: fix name*/
|
||||
#define BCM43xx_SBF_XFER_REG_BYTESWAP 0x00010000
|
||||
#define BCM43xx_SBF_MODE_NOTADHOC 0x00020000
|
||||
#define BCM43xx_SBF_MODE_AP 0x00040000
|
||||
#define BCM43xx_SBF_RADIOREG_LOCK 0x00080000
|
||||
#define BCM43xx_SBF_MODE_MONITOR 0x00400000
|
||||
#define BCM43xx_SBF_MODE_PROMISC 0x01000000
|
||||
#define BCM43xx_SBF_PS1 0x02000000
|
||||
#define BCM43xx_SBF_PS2 0x04000000
|
||||
#define BCM43xx_SBF_NO_SSID_BCAST 0x08000000
|
||||
#define BCM43xx_SBF_TIME_UPDATE 0x10000000
|
||||
#define BCM43xx_SBF_80000000 0x80000000 /*FIXME: fix name*/
|
||||
|
||||
/* MicrocodeFlagsBitfield (addr + lo-word values?)*/
|
||||
#define BCM43xx_UCODEFLAGS_OFFSET 0x005E
|
||||
|
||||
#define BCM43xx_UCODEFLAG_AUTODIV 0x0001
|
||||
#define BCM43xx_UCODEFLAG_UNKBGPHY 0x0002
|
||||
#define BCM43xx_UCODEFLAG_UNKBPHY 0x0004
|
||||
#define BCM43xx_UCODEFLAG_UNKGPHY 0x0020
|
||||
#define BCM43xx_UCODEFLAG_UNKPACTRL 0x0040
|
||||
#define BCM43xx_UCODEFLAG_JAPAN 0x0080
|
||||
|
||||
/* Generic-Interrupt reasons. */
|
||||
#define BCM43xx_IRQ_READY (1 << 0)
|
||||
#define BCM43xx_IRQ_BEACON (1 << 1)
|
||||
#define BCM43xx_IRQ_PS (1 << 2)
|
||||
#define BCM43xx_IRQ_REG124 (1 << 5)
|
||||
#define BCM43xx_IRQ_PMQ (1 << 6)
|
||||
#define BCM43xx_IRQ_PIO_WORKAROUND (1 << 8)
|
||||
#define BCM43xx_IRQ_XMIT_ERROR (1 << 11)
|
||||
#define BCM43xx_IRQ_RX (1 << 15)
|
||||
#define BCM43xx_IRQ_SCAN (1 << 16)
|
||||
#define BCM43xx_IRQ_NOISE (1 << 18)
|
||||
#define BCM43xx_IRQ_XMIT_STATUS (1 << 29)
|
||||
|
||||
#define BCM43xx_IRQ_ALL 0xffffffff
|
||||
#define BCM43xx_IRQ_INITIAL (BCM43xx_IRQ_PS | \
|
||||
BCM43xx_IRQ_REG124 | \
|
||||
BCM43xx_IRQ_PMQ | \
|
||||
BCM43xx_IRQ_XMIT_ERROR | \
|
||||
BCM43xx_IRQ_RX | \
|
||||
BCM43xx_IRQ_SCAN | \
|
||||
BCM43xx_IRQ_NOISE | \
|
||||
BCM43xx_IRQ_XMIT_STATUS)
|
||||
|
||||
|
||||
/* Initial default iw_mode */
|
||||
#define BCM43xx_INITIAL_IWMODE IW_MODE_INFRA
|
||||
|
||||
/* Values/Masks for the device TX header */
|
||||
#define BCM43xx_TXHDRFLAG_EXPECTACK 0x0001
|
||||
#define BCM43xx_TXHDRFLAG_FIRSTFRAGMENT 0x0008
|
||||
#define BCM43xx_TXHDRFLAG_DESTPSMODE 0x0020
|
||||
#define BCM43xx_TXHDRFLAG_FALLBACKOFDM 0x0100
|
||||
#define BCM43xx_TXHDRFLAG_FRAMEBURST 0x0800
|
||||
|
||||
#define BCM43xx_TXHDRCTL_OFDM 0x0001
|
||||
#define BCM43xx_TXHDRCTL_SHORT_PREAMBLE 0x0010
|
||||
#define BCM43xx_TXHDRCTL_ANTENNADIV_MASK 0x0030
|
||||
#define BCM43xx_TXHDRCTL_ANTENNADIV_SHIFT 8
|
||||
|
||||
#define BCM43xx_TXHDR_WSEC_KEYINDEX_MASK 0x00F0
|
||||
#define BCM43xx_TXHDR_WSEC_KEYINDEX_SHIFT 4
|
||||
#define BCM43xx_TXHDR_WSEC_ALGO_MASK 0x0003
|
||||
#define BCM43xx_TXHDR_WSEC_ALGO_SHIFT 0
|
||||
|
||||
/* Bus type PCI. */
|
||||
#define BCM43xx_BUSTYPE_PCI 0
|
||||
/* Bus type Silicone Backplane Bus. */
|
||||
#define BCM43xx_BUSTYPE_SB 1
|
||||
/* Bus type PCMCIA. */
|
||||
#define BCM43xx_BUSTYPE_PCMCIA 2
|
||||
|
||||
/* Threshold values. */
|
||||
#define BCM43xx_MIN_RTS_THRESHOLD 1U
|
||||
#define BCM43xx_MAX_RTS_THRESHOLD 2304U
|
||||
#define BCM43xx_DEFAULT_RTS_THRESHOLD BCM43xx_MAX_RTS_THRESHOLD
|
||||
|
||||
#define BCM43xx_DEFAULT_SHORT_RETRY_LIMIT 7
|
||||
#define BCM43xx_DEFAULT_LONG_RETRY_LIMIT 4
|
||||
|
||||
/* Max size of a security key */
|
||||
#define BCM43xx_SEC_KEYSIZE 16
|
||||
/* Security algorithms. */
|
||||
enum {
|
||||
BCM43xx_SEC_ALGO_NONE = 0, /* unencrypted, as of TX header. */
|
||||
BCM43xx_SEC_ALGO_WEP,
|
||||
BCM43xx_SEC_ALGO_UNKNOWN,
|
||||
BCM43xx_SEC_ALGO_AES,
|
||||
BCM43xx_SEC_ALGO_WEP104,
|
||||
BCM43xx_SEC_ALGO_TKIP,
|
||||
};
|
||||
|
||||
#ifdef assert
|
||||
# undef assert
|
||||
#endif
|
||||
#ifdef CONFIG_BCM43XX_DEBUG
|
||||
#define assert(expr) \
|
||||
do { \
|
||||
if (unlikely(!(expr))) { \
|
||||
printk(KERN_ERR PFX "ASSERTION FAILED (%s) at: %s:%d:%s()\n", \
|
||||
#expr, __FILE__, __LINE__, __FUNCTION__); \
|
||||
} \
|
||||
} while (0)
|
||||
#else
|
||||
#define assert(expr) do { /* nothing */ } while (0)
|
||||
#endif
|
||||
|
||||
/* rate limited printk(). */
|
||||
#ifdef printkl
|
||||
# undef printkl
|
||||
#endif
|
||||
#define printkl(f, x...) do { if (printk_ratelimit()) printk(f ,##x); } while (0)
|
||||
/* rate limited printk() for debugging */
|
||||
#ifdef dprintkl
|
||||
# undef dprintkl
|
||||
#endif
|
||||
#ifdef CONFIG_BCM43XX_DEBUG
|
||||
# define dprintkl printkl
|
||||
#else
|
||||
# define dprintkl(f, x...) do { /* nothing */ } while (0)
|
||||
#endif
|
||||
|
||||
/* Helper macro for if branches.
|
||||
* An if branch marked with this macro is only taken in DEBUG mode.
|
||||
* Example:
|
||||
* if (DEBUG_ONLY(foo == bar)) {
|
||||
* do something
|
||||
* }
|
||||
* In DEBUG mode, the branch will be taken if (foo == bar).
|
||||
* In non-DEBUG mode, the branch will never be taken.
|
||||
*/
|
||||
#ifdef DEBUG_ONLY
|
||||
# undef DEBUG_ONLY
|
||||
#endif
|
||||
#ifdef CONFIG_BCM43XX_DEBUG
|
||||
# define DEBUG_ONLY(x) (x)
|
||||
#else
|
||||
# define DEBUG_ONLY(x) 0
|
||||
#endif
|
||||
|
||||
/* debugging printk() */
|
||||
#ifdef dprintk
|
||||
# undef dprintk
|
||||
#endif
|
||||
#ifdef CONFIG_BCM43XX_DEBUG
|
||||
# define dprintk(f, x...) do { printk(f ,##x); } while (0)
|
||||
#else
|
||||
# define dprintk(f, x...) do { /* nothing */ } while (0)
|
||||
#endif
|
||||
|
||||
|
||||
struct net_device;
|
||||
struct pci_dev;
|
||||
struct workqueue_struct;
|
||||
struct bcm43xx_dmaring;
|
||||
struct bcm43xx_pioqueue;
|
||||
|
||||
struct bcm43xx_initval {
|
||||
u16 offset;
|
||||
u16 size;
|
||||
u32 value;
|
||||
} __attribute__((__packed__));
|
||||
|
||||
/* Values for bcm430x_sprominfo.locale */
|
||||
enum {
|
||||
BCM43xx_LOCALE_WORLD = 0,
|
||||
BCM43xx_LOCALE_THAILAND,
|
||||
BCM43xx_LOCALE_ISRAEL,
|
||||
BCM43xx_LOCALE_JORDAN,
|
||||
BCM43xx_LOCALE_CHINA,
|
||||
BCM43xx_LOCALE_JAPAN,
|
||||
BCM43xx_LOCALE_USA_CANADA_ANZ,
|
||||
BCM43xx_LOCALE_EUROPE,
|
||||
BCM43xx_LOCALE_USA_LOW,
|
||||
BCM43xx_LOCALE_JAPAN_HIGH,
|
||||
BCM43xx_LOCALE_ALL,
|
||||
BCM43xx_LOCALE_NONE,
|
||||
};
|
||||
|
||||
#define BCM43xx_SPROM_SIZE 64 /* in 16-bit words. */
|
||||
struct bcm43xx_sprominfo {
|
||||
u16 boardflags2;
|
||||
u8 il0macaddr[6];
|
||||
u8 et0macaddr[6];
|
||||
u8 et1macaddr[6];
|
||||
u8 et0phyaddr:5;
|
||||
u8 et1phyaddr:5;
|
||||
u8 et0mdcport:1;
|
||||
u8 et1mdcport:1;
|
||||
u8 boardrev;
|
||||
u8 locale:4;
|
||||
u8 antennas_aphy:2;
|
||||
u8 antennas_bgphy:2;
|
||||
u16 pa0b0;
|
||||
u16 pa0b1;
|
||||
u16 pa0b2;
|
||||
u8 wl0gpio0;
|
||||
u8 wl0gpio1;
|
||||
u8 wl0gpio2;
|
||||
u8 wl0gpio3;
|
||||
u8 maxpower_aphy;
|
||||
u8 maxpower_bgphy;
|
||||
u16 pa1b0;
|
||||
u16 pa1b1;
|
||||
u16 pa1b2;
|
||||
u8 idle_tssi_tgt_aphy;
|
||||
u8 idle_tssi_tgt_bgphy;
|
||||
u16 boardflags;
|
||||
u16 antennagain_aphy;
|
||||
u16 antennagain_bgphy;
|
||||
};
|
||||
|
||||
/* Value pair to measure the LocalOscillator. */
|
||||
struct bcm43xx_lopair {
|
||||
s8 low;
|
||||
s8 high;
|
||||
u8 used:1;
|
||||
};
|
||||
#define BCM43xx_LO_COUNT (14*4)
|
||||
|
||||
struct bcm43xx_phyinfo {
|
||||
/* Hardware Data */
|
||||
u8 version;
|
||||
u8 type;
|
||||
u8 rev;
|
||||
u16 antenna_diversity;
|
||||
u16 savedpctlreg;
|
||||
u16 minlowsig[2];
|
||||
u16 minlowsigpos[2];
|
||||
u8 connected:1,
|
||||
calibrated:1,
|
||||
is_locked:1, /* used in bcm43xx_phy_{un}lock() */
|
||||
dyn_tssi_tbl:1; /* used in bcm43xx_phy_init_tssi2dbm_table() */
|
||||
/* LO Measurement Data.
|
||||
* Use bcm43xx_get_lopair() to get a value.
|
||||
*/
|
||||
struct bcm43xx_lopair *_lo_pairs;
|
||||
|
||||
/* TSSI to dBm table in use */
|
||||
const s8 *tssi2dbm;
|
||||
/* idle TSSI value */
|
||||
s8 idle_tssi;
|
||||
/* PHY lock for core.rev < 3
|
||||
* This lock is only used by bcm43xx_phy_{un}lock()
|
||||
*/
|
||||
spinlock_t lock;
|
||||
};
|
||||
|
||||
|
||||
struct bcm43xx_radioinfo {
|
||||
u16 manufact;
|
||||
u16 version;
|
||||
u8 revision;
|
||||
|
||||
/* 0: baseband attenuation,
|
||||
* 1: radio attenuation,
|
||||
* 2: tx_CTL1
|
||||
* 3: tx_CTL2
|
||||
*/
|
||||
u16 txpower[4];
|
||||
/* Current Interference Mitigation mode */
|
||||
int interfmode;
|
||||
/* Stack of saved values from the Interference Mitigation code */
|
||||
u16 interfstack[20];
|
||||
/* Saved values from the NRSSI Slope calculation */
|
||||
s16 nrssi[2];
|
||||
s32 nrssislope;
|
||||
/* In memory nrssi lookup table. */
|
||||
s8 nrssi_lt[64];
|
||||
|
||||
/* current channel */
|
||||
u8 channel;
|
||||
u8 initial_channel;
|
||||
|
||||
u16 lofcal;
|
||||
|
||||
u16 initval;
|
||||
|
||||
u8 enabled:1;
|
||||
/* ACI (adjacent channel interference) flags. */
|
||||
u8 aci_enable:1,
|
||||
aci_wlan_automatic:1,
|
||||
aci_hw_rssi:1;
|
||||
};
|
||||
|
||||
/* Data structures for DMA transmission, per 80211 core. */
|
||||
struct bcm43xx_dma {
|
||||
struct bcm43xx_dmaring *tx_ring0;
|
||||
struct bcm43xx_dmaring *tx_ring1;
|
||||
struct bcm43xx_dmaring *tx_ring2;
|
||||
struct bcm43xx_dmaring *tx_ring3;
|
||||
struct bcm43xx_dmaring *rx_ring0;
|
||||
struct bcm43xx_dmaring *rx_ring1; /* only available on core.rev < 5 */
|
||||
};
|
||||
|
||||
/* Data structures for PIO transmission, per 80211 core. */
|
||||
struct bcm43xx_pio {
|
||||
struct bcm43xx_pioqueue *queue0;
|
||||
struct bcm43xx_pioqueue *queue1;
|
||||
struct bcm43xx_pioqueue *queue2;
|
||||
struct bcm43xx_pioqueue *queue3;
|
||||
};
|
||||
|
||||
#define BCM43xx_MAX_80211_CORES 2
|
||||
|
||||
#define BCM43xx_COREFLAG_AVAILABLE (1 << 0)
|
||||
#define BCM43xx_COREFLAG_ENABLED (1 << 1)
|
||||
#define BCM43xx_COREFLAG_INITIALIZED (1 << 2)
|
||||
|
||||
#ifdef CONFIG_BCM947XX
|
||||
#define core_offset(bcm) (bcm)->current_core_offset
|
||||
#else
|
||||
#define core_offset(bcm) 0
|
||||
#endif
|
||||
|
||||
struct bcm43xx_coreinfo {
|
||||
/** Driver internal flags. See BCM43xx_COREFLAG_* */
|
||||
u32 flags;
|
||||
/** core_id ID number */
|
||||
u16 id;
|
||||
/** core_rev revision number */
|
||||
u8 rev;
|
||||
/** Index number for _switch_core() */
|
||||
u8 index;
|
||||
/* Pointer to the PHYinfo, which belongs to this core (if 80211 core) */
|
||||
struct bcm43xx_phyinfo *phy;
|
||||
/* Pointer to the RadioInfo, which belongs to this core (if 80211 core) */
|
||||
struct bcm43xx_radioinfo *radio;
|
||||
/* Pointer to the DMA rings, which belong to this core (if 80211 core) */
|
||||
struct bcm43xx_dma *dma;
|
||||
/* Pointer to the PIO queues, which belong to this core (if 80211 core) */
|
||||
struct bcm43xx_pio *pio;
|
||||
};
|
||||
|
||||
/* Context information for a noise calculation (Link Quality). */
|
||||
struct bcm43xx_noise_calculation {
|
||||
struct bcm43xx_coreinfo *core_at_start;
|
||||
u8 channel_at_start;
|
||||
u8 calculation_running:1;
|
||||
u8 nr_samples;
|
||||
s8 samples[8][4];
|
||||
};
|
||||
|
||||
struct bcm43xx_stats {
|
||||
u8 link_quality;
|
||||
/* Store the last TX/RX times here for updating the leds. */
|
||||
unsigned long last_tx;
|
||||
unsigned long last_rx;
|
||||
};
|
||||
|
||||
struct bcm43xx_key {
|
||||
u8 enabled:1;
|
||||
u8 algorithm;
|
||||
};
|
||||
|
||||
struct bcm43xx_private {
|
||||
struct ieee80211_device *ieee;
|
||||
struct ieee80211softmac_device *softmac;
|
||||
|
||||
struct net_device *net_dev;
|
||||
struct pci_dev *pci_dev;
|
||||
unsigned int irq;
|
||||
|
||||
void __iomem *mmio_addr;
|
||||
unsigned int mmio_len;
|
||||
|
||||
spinlock_t lock;
|
||||
|
||||
/* Driver status flags. */
|
||||
u32 initialized:1, /* init_board() succeed */
|
||||
was_initialized:1, /* for PCI suspend/resume. */
|
||||
shutting_down:1, /* free_board() in progress */
|
||||
pio_mode:1, /* PIO (if true), or DMA (if false) used. */
|
||||
bad_frames_preempt:1, /* Use "Bad Frames Preemption" (default off) */
|
||||
reg124_set_0x4:1, /* Some variable to keep track of IRQ stuff. */
|
||||
powersaving:1, /* TRUE if we are in PowerSaving mode. FALSE otherwise. */
|
||||
short_preamble:1, /* TRUE, if short preamble is enabled. */
|
||||
firmware_norelease:1; /* Do not release the firmware. Used on suspend. */
|
||||
|
||||
struct bcm43xx_stats stats;
|
||||
|
||||
/* Bus type we are connected to.
|
||||
* This is currently always BCM43xx_BUSTYPE_PCI
|
||||
*/
|
||||
u8 bustype;
|
||||
|
||||
u16 board_vendor;
|
||||
u16 board_type;
|
||||
u16 board_revision;
|
||||
|
||||
u16 chip_id;
|
||||
u8 chip_rev;
|
||||
|
||||
struct bcm43xx_sprominfo sprom;
|
||||
#define BCM43xx_NR_LEDS 4
|
||||
struct bcm43xx_led leds[BCM43xx_NR_LEDS];
|
||||
|
||||
/* The currently active core. NULL if not initialized, yet. */
|
||||
struct bcm43xx_coreinfo *current_core;
|
||||
#ifdef CONFIG_BCM947XX
|
||||
/** current core memory offset */
|
||||
u32 current_core_offset;
|
||||
#endif
|
||||
struct bcm43xx_coreinfo *active_80211_core;
|
||||
/* coreinfo structs for all possible cores follow.
|
||||
* Note that a core might not exist.
|
||||
* So check the coreinfo flags before using it.
|
||||
*/
|
||||
struct bcm43xx_coreinfo core_chipcommon;
|
||||
struct bcm43xx_coreinfo core_pci;
|
||||
struct bcm43xx_coreinfo core_v90;
|
||||
struct bcm43xx_coreinfo core_pcmcia;
|
||||
struct bcm43xx_coreinfo core_ethernet;
|
||||
struct bcm43xx_coreinfo core_80211[ BCM43xx_MAX_80211_CORES ];
|
||||
/* Info about the PHY for each 80211 core. */
|
||||
struct bcm43xx_phyinfo phy[ BCM43xx_MAX_80211_CORES ];
|
||||
/* Info about the Radio for each 80211 core. */
|
||||
struct bcm43xx_radioinfo radio[ BCM43xx_MAX_80211_CORES ];
|
||||
/* DMA */
|
||||
struct bcm43xx_dma dma[ BCM43xx_MAX_80211_CORES ];
|
||||
/* PIO */
|
||||
struct bcm43xx_pio pio[ BCM43xx_MAX_80211_CORES ];
|
||||
|
||||
u32 chipcommon_capabilities;
|
||||
|
||||
/* Reason code of the last interrupt. */
|
||||
u32 irq_reason;
|
||||
u32 dma_reason[4];
|
||||
/* saved irq enable/disable state bitfield. */
|
||||
u32 irq_savedstate;
|
||||
/* Link Quality calculation context. */
|
||||
struct bcm43xx_noise_calculation noisecalc;
|
||||
|
||||
/* Threshold values. */
|
||||
//TODO: The RTS thr has to be _used_. Currently, it is only set via WX.
|
||||
u32 rts_threshold;
|
||||
|
||||
/* Interrupt Service Routine tasklet (bottom-half) */
|
||||
struct tasklet_struct isr_tasklet;
|
||||
/* Custom driver work queue. */
|
||||
struct workqueue_struct *workqueue;
|
||||
|
||||
/* Periodic tasks */
|
||||
struct work_struct periodic_work0;
|
||||
#define BCM43xx_PERIODIC_0_DELAY (HZ * 15)
|
||||
struct work_struct periodic_work1;
|
||||
#define BCM43xx_PERIODIC_1_DELAY ((HZ * 60) + HZ / 2)
|
||||
struct work_struct periodic_work2;
|
||||
#define BCM43xx_PERIODIC_2_DELAY ((HZ * 120) + HZ)
|
||||
struct work_struct periodic_work3;
|
||||
#define BCM43xx_PERIODIC_3_DELAY ((HZ * 30) + HZ / 5)
|
||||
|
||||
struct work_struct restart_work;
|
||||
|
||||
/* Informational stuff. */
|
||||
char nick[IW_ESSID_MAX_SIZE + 1];
|
||||
|
||||
/* encryption/decryption */
|
||||
u16 security_offset;
|
||||
struct bcm43xx_key key[54];
|
||||
u8 default_key_idx;
|
||||
|
||||
/* Firmware. */
|
||||
const struct firmware *ucode;
|
||||
const struct firmware *pcm;
|
||||
const struct firmware *initvals0;
|
||||
const struct firmware *initvals1;
|
||||
|
||||
/* Debugging stuff follows. */
|
||||
#ifdef CONFIG_BCM43XX_DEBUG
|
||||
struct bcm43xx_dfsentry *dfsentry;
|
||||
atomic_t mmio_print_cnt;
|
||||
atomic_t pcicfg_print_cnt;
|
||||
#endif
|
||||
};
|
||||
|
||||
static inline
|
||||
struct bcm43xx_private * bcm43xx_priv(struct net_device *dev)
|
||||
{
|
||||
return ieee80211softmac_priv(dev);
|
||||
}
|
||||
|
||||
static inline
|
||||
int bcm43xx_num_80211_cores(struct bcm43xx_private *bcm)
|
||||
{
|
||||
int i, cnt = 0;
|
||||
|
||||
for (i = 0; i < BCM43xx_MAX_80211_CORES; i++) {
|
||||
if (bcm->core_80211[i].flags & BCM43xx_COREFLAG_AVAILABLE)
|
||||
cnt++;
|
||||
}
|
||||
|
||||
return cnt;
|
||||
}
|
||||
|
||||
/* Are we running in init_board() context? */
|
||||
static inline
|
||||
int bcm43xx_is_initializing(struct bcm43xx_private *bcm)
|
||||
{
|
||||
if (bcm->initialized)
|
||||
return 0;
|
||||
if (bcm->shutting_down)
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static inline
|
||||
struct bcm43xx_lopair * bcm43xx_get_lopair(struct bcm43xx_phyinfo *phy,
|
||||
u16 radio_attenuation,
|
||||
u16 baseband_attenuation)
|
||||
{
|
||||
return phy->_lo_pairs + (radio_attenuation + 14 * (baseband_attenuation / 2));
|
||||
}
|
||||
|
||||
|
||||
/* MMIO read/write functions. Debug and non-debug variants. */
|
||||
#ifdef CONFIG_BCM43XX_DEBUG
|
||||
|
||||
static inline
|
||||
u16 bcm43xx_read16(struct bcm43xx_private *bcm, u16 offset)
|
||||
{
|
||||
u16 value;
|
||||
|
||||
value = ioread16(bcm->mmio_addr + core_offset(bcm) + offset);
|
||||
if (unlikely(atomic_read(&bcm->mmio_print_cnt) > 0)) {
|
||||
printk(KERN_INFO PFX "ioread16 offset: 0x%04x, value: 0x%04x\n",
|
||||
offset, value);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
static inline
|
||||
void bcm43xx_write16(struct bcm43xx_private *bcm, u16 offset, u16 value)
|
||||
{
|
||||
iowrite16(value, bcm->mmio_addr + core_offset(bcm) + offset);
|
||||
if (unlikely(atomic_read(&bcm->mmio_print_cnt) > 0)) {
|
||||
printk(KERN_INFO PFX "iowrite16 offset: 0x%04x, value: 0x%04x\n",
|
||||
offset, value);
|
||||
}
|
||||
}
|
||||
|
||||
static inline
|
||||
u32 bcm43xx_read32(struct bcm43xx_private *bcm, u16 offset)
|
||||
{
|
||||
u32 value;
|
||||
|
||||
value = ioread32(bcm->mmio_addr + core_offset(bcm) + offset);
|
||||
if (unlikely(atomic_read(&bcm->mmio_print_cnt) > 0)) {
|
||||
printk(KERN_INFO PFX "ioread32 offset: 0x%04x, value: 0x%08x\n",
|
||||
offset, value);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
static inline
|
||||
void bcm43xx_write32(struct bcm43xx_private *bcm, u16 offset, u32 value)
|
||||
{
|
||||
iowrite32(value, bcm->mmio_addr + core_offset(bcm) + offset);
|
||||
if (unlikely(atomic_read(&bcm->mmio_print_cnt) > 0)) {
|
||||
printk(KERN_INFO PFX "iowrite32 offset: 0x%04x, value: 0x%08x\n",
|
||||
offset, value);
|
||||
}
|
||||
}
|
||||
|
||||
static inline
|
||||
int bcm43xx_pci_read_config16(struct bcm43xx_private *bcm, int offset, u16 *value)
|
||||
{
|
||||
int err;
|
||||
|
||||
err = pci_read_config_word(bcm->pci_dev, offset, value);
|
||||
if (unlikely(atomic_read(&bcm->pcicfg_print_cnt) > 0)) {
|
||||
printk(KERN_INFO PFX "pciread16 offset: 0x%08x, value: 0x%04x, err: %d\n",
|
||||
offset, *value, err);
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
static inline
|
||||
int bcm43xx_pci_read_config32(struct bcm43xx_private *bcm, int offset, u32 *value)
|
||||
{
|
||||
int err;
|
||||
|
||||
err = pci_read_config_dword(bcm->pci_dev, offset, value);
|
||||
if (unlikely(atomic_read(&bcm->pcicfg_print_cnt) > 0)) {
|
||||
printk(KERN_INFO PFX "pciread32 offset: 0x%08x, value: 0x%08x, err: %d\n",
|
||||
offset, *value, err);
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
static inline
|
||||
int bcm43xx_pci_write_config16(struct bcm43xx_private *bcm, int offset, u16 value)
|
||||
{
|
||||
int err;
|
||||
|
||||
err = pci_write_config_word(bcm->pci_dev, offset, value);
|
||||
if (unlikely(atomic_read(&bcm->pcicfg_print_cnt) > 0)) {
|
||||
printk(KERN_INFO PFX "pciwrite16 offset: 0x%08x, value: 0x%04x, err: %d\n",
|
||||
offset, value, err);
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
static inline
|
||||
int bcm43xx_pci_write_config32(struct bcm43xx_private *bcm, int offset, u32 value)
|
||||
{
|
||||
int err;
|
||||
|
||||
err = pci_write_config_dword(bcm->pci_dev, offset, value);
|
||||
if (unlikely(atomic_read(&bcm->pcicfg_print_cnt) > 0)) {
|
||||
printk(KERN_INFO PFX "pciwrite32 offset: 0x%08x, value: 0x%08x, err: %d\n",
|
||||
offset, value, err);
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
#define bcm43xx_mmioprint_initial(bcm, value) atomic_set(&(bcm)->mmio_print_cnt, (value))
|
||||
#define bcm43xx_mmioprint_enable(bcm) atomic_inc(&(bcm)->mmio_print_cnt)
|
||||
#define bcm43xx_mmioprint_disable(bcm) atomic_dec(&(bcm)->mmio_print_cnt)
|
||||
#define bcm43xx_pciprint_initial(bcm, value) atomic_set(&(bcm)->pcicfg_print_cnt, (value))
|
||||
#define bcm43xx_pciprint_enable(bcm) atomic_inc(&(bcm)->pcicfg_print_cnt)
|
||||
#define bcm43xx_pciprint_disable(bcm) atomic_dec(&(bcm)->pcicfg_print_cnt)
|
||||
|
||||
#else /* CONFIG_BCM43XX_DEBUG*/
|
||||
|
||||
#define bcm43xx_read16(bcm, offset) ioread16((bcm)->mmio_addr + core_offset(bcm) + (offset))
|
||||
#define bcm43xx_write16(bcm, offset, value) iowrite16((value), (bcm)->mmio_addr + core_offset(bcm) + (offset))
|
||||
#define bcm43xx_read32(bcm, offset) ioread32((bcm)->mmio_addr + core_offset(bcm) + (offset))
|
||||
#define bcm43xx_write32(bcm, offset, value) iowrite32((value), (bcm)->mmio_addr + core_offset(bcm) + (offset))
|
||||
#define bcm43xx_pci_read_config16(bcm, o, v) pci_read_config_word((bcm)->pci_dev, (o), (v))
|
||||
#define bcm43xx_pci_read_config32(bcm, o, v) pci_read_config_dword((bcm)->pci_dev, (o), (v))
|
||||
#define bcm43xx_pci_write_config16(bcm, o, v) pci_write_config_word((bcm)->pci_dev, (o), (v))
|
||||
#define bcm43xx_pci_write_config32(bcm, o, v) pci_write_config_dword((bcm)->pci_dev, (o), (v))
|
||||
|
||||
#define bcm43xx_mmioprint_initial(x, y) do { /* nothing */ } while (0)
|
||||
#define bcm43xx_mmioprint_enable(x) do { /* nothing */ } while (0)
|
||||
#define bcm43xx_mmioprint_disable(x) do { /* nothing */ } while (0)
|
||||
#define bcm43xx_pciprint_initial(bcm, value) do { /* nothing */ } while (0)
|
||||
#define bcm43xx_pciprint_enable(bcm) do { /* nothing */ } while (0)
|
||||
#define bcm43xx_pciprint_disable(bcm) do { /* nothing */ } while (0)
|
||||
|
||||
#endif /* CONFIG_BCM43XX_DEBUG*/
|
||||
|
||||
|
||||
/** Limit a value between two limits */
|
||||
#ifdef limit_value
|
||||
# undef limit_value
|
||||
#endif
|
||||
#define limit_value(value, min, max) \
|
||||
({ \
|
||||
typeof(value) __value = (value); \
|
||||
typeof(value) __min = (min); \
|
||||
typeof(value) __max = (max); \
|
||||
if (__value < __min) \
|
||||
__value = __min; \
|
||||
else if (__value > __max) \
|
||||
__value = __max; \
|
||||
__value; \
|
||||
})
|
||||
|
||||
|
||||
/*
|
||||
* Compatibility stuff follows
|
||||
*/
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 15)
|
||||
# error "The bcm43xx driver does not support kernels < 2.6.15"
|
||||
# error "The driver will _NOT_ compile on your kernel. Please upgrade to the latest 2.6 kernel."
|
||||
# error "DO NOT COMPLAIN ABOUT BUGS. UPDATE FIRST AND TRY AGAIN."
|
||||
#else
|
||||
# if !defined(CONFIG_IEEE80211_MODULE) && !defined(CONFIG_IEEE80211)
|
||||
# error "Generic IEEE 802.11 Networking Stack (CONFIG_IEEE80211) not available."
|
||||
# endif
|
||||
#endif
|
||||
#ifdef IEEE80211SOFTMAC_API
|
||||
# if IEEE80211SOFTMAC_API != 0
|
||||
# warning "Incompatible SoftMAC subsystem installed."
|
||||
# endif
|
||||
#else
|
||||
# error "The bcm43xx driver requires the SoftMAC subsystem."
|
||||
# error "SEE >>>>>> http://softmac.sipsolutions.net/ <<<<<<"
|
||||
#endif
|
||||
|
||||
#endif /* BCM43xx_H_ */
|
503
drivers/net/wireless/bcm43xx/bcm43xx_debugfs.c
Normal file
503
drivers/net/wireless/bcm43xx/bcm43xx_debugfs.c
Normal file
@ -0,0 +1,503 @@
|
||||
/*
|
||||
|
||||
Broadcom BCM43xx wireless driver
|
||||
|
||||
debugfs driver debugging code
|
||||
|
||||
Copyright (c) 2005 Michael Buesch <mbuesch@freenet.de>
|
||||
|
||||
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.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <linux/fs.h>
|
||||
#include <linux/debugfs.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/netdevice.h>
|
||||
#include <linux/pci.h>
|
||||
#include <asm/io.h>
|
||||
|
||||
#include "bcm43xx.h"
|
||||
#include "bcm43xx_main.h"
|
||||
#include "bcm43xx_debugfs.h"
|
||||
#include "bcm43xx_dma.h"
|
||||
#include "bcm43xx_pio.h"
|
||||
|
||||
#define REALLY_BIG_BUFFER_SIZE (1024*256)
|
||||
|
||||
static struct bcm43xx_debugfs fs;
|
||||
static char really_big_buffer[REALLY_BIG_BUFFER_SIZE];
|
||||
static DECLARE_MUTEX(big_buffer_sem);
|
||||
|
||||
|
||||
static ssize_t write_file_dummy(struct file *file, const char __user *buf,
|
||||
size_t count, loff_t *ppos)
|
||||
{
|
||||
return count;
|
||||
}
|
||||
|
||||
static int open_file_generic(struct inode *inode, struct file *file)
|
||||
{
|
||||
file->private_data = inode->u.generic_ip;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define fappend(fmt, x...) pos += snprintf(buf + pos, len - pos, fmt , ##x)
|
||||
|
||||
static ssize_t devinfo_read_file(struct file *file, char __user *userbuf,
|
||||
size_t count, loff_t *ppos)
|
||||
{
|
||||
const size_t len = REALLY_BIG_BUFFER_SIZE;
|
||||
|
||||
struct bcm43xx_private *bcm = file->private_data;
|
||||
char *buf = really_big_buffer;
|
||||
size_t pos = 0;
|
||||
ssize_t res;
|
||||
struct net_device *net_dev;
|
||||
struct pci_dev *pci_dev;
|
||||
unsigned long flags;
|
||||
u16 tmp16;
|
||||
int i;
|
||||
|
||||
down(&big_buffer_sem);
|
||||
|
||||
spin_lock_irqsave(&bcm->lock, flags);
|
||||
if (!bcm->initialized) {
|
||||
fappend("Board not initialized.\n");
|
||||
goto out;
|
||||
}
|
||||
net_dev = bcm->net_dev;
|
||||
pci_dev = bcm->pci_dev;
|
||||
|
||||
/* This is where the information is written to the "devinfo" file */
|
||||
fappend("*** %s devinfo ***\n", net_dev->name);
|
||||
fappend("vendor: 0x%04x device: 0x%04x\n",
|
||||
pci_dev->vendor, pci_dev->device);
|
||||
fappend("subsystem_vendor: 0x%04x subsystem_device: 0x%04x\n",
|
||||
pci_dev->subsystem_vendor, pci_dev->subsystem_device);
|
||||
fappend("IRQ: %d\n", bcm->irq);
|
||||
fappend("mmio_addr: 0x%p mmio_len: %u\n", bcm->mmio_addr, bcm->mmio_len);
|
||||
fappend("chip_id: 0x%04x chip_rev: 0x%02x\n", bcm->chip_id, bcm->chip_rev);
|
||||
if ((bcm->core_80211[0].rev >= 3) && (bcm43xx_read32(bcm, 0x0158) & (1 << 16)))
|
||||
fappend("Radio disabled by hardware!\n");
|
||||
if ((bcm->core_80211[0].rev < 3) && !(bcm43xx_read16(bcm, 0x049A) & (1 << 4)))
|
||||
fappend("Radio disabled by hardware!\n");
|
||||
fappend("board_vendor: 0x%04x board_type: 0x%04x\n", bcm->board_vendor,
|
||||
bcm->board_type);
|
||||
|
||||
fappend("\nCores:\n");
|
||||
#define fappend_core(name, info) fappend("core \"" name "\" %s, %s, id: 0x%04x, " \
|
||||
"rev: 0x%02x, index: 0x%02x\n", \
|
||||
(info).flags & BCM43xx_COREFLAG_AVAILABLE \
|
||||
? "available" : "nonavailable", \
|
||||
(info).flags & BCM43xx_COREFLAG_ENABLED \
|
||||
? "enabled" : "disabled", \
|
||||
(info).id, (info).rev, (info).index)
|
||||
fappend_core("CHIPCOMMON", bcm->core_chipcommon);
|
||||
fappend_core("PCI", bcm->core_pci);
|
||||
fappend_core("V90", bcm->core_v90);
|
||||
fappend_core("PCMCIA", bcm->core_pcmcia);
|
||||
fappend_core("ETHERNET", bcm->core_ethernet);
|
||||
fappend_core("first 80211", bcm->core_80211[0]);
|
||||
fappend_core("second 80211", bcm->core_80211[1]);
|
||||
#undef fappend_core
|
||||
tmp16 = bcm43xx_read16(bcm, BCM43xx_MMIO_GPIO_CONTROL);
|
||||
fappend("LEDs: ");
|
||||
for (i = 0; i < BCM43xx_NR_LEDS; i++)
|
||||
fappend("%d ", !!(tmp16 & (1 << i)));
|
||||
fappend("\n");
|
||||
|
||||
out:
|
||||
spin_unlock_irqrestore(&bcm->lock, flags);
|
||||
res = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
|
||||
up(&big_buffer_sem);
|
||||
return res;
|
||||
}
|
||||
|
||||
static ssize_t drvinfo_read_file(struct file *file, char __user *userbuf,
|
||||
size_t count, loff_t *ppos)
|
||||
{
|
||||
const size_t len = REALLY_BIG_BUFFER_SIZE;
|
||||
|
||||
char *buf = really_big_buffer;
|
||||
size_t pos = 0;
|
||||
ssize_t res;
|
||||
|
||||
down(&big_buffer_sem);
|
||||
|
||||
/* This is where the information is written to the "driver" file */
|
||||
fappend(BCM43xx_DRIVER_NAME "\n");
|
||||
fappend("Compiled at: %s %s\n", __DATE__, __TIME__);
|
||||
|
||||
res = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
|
||||
up(&big_buffer_sem);
|
||||
return res;
|
||||
}
|
||||
|
||||
static ssize_t spromdump_read_file(struct file *file, char __user *userbuf,
|
||||
size_t count, loff_t *ppos)
|
||||
{
|
||||
const size_t len = REALLY_BIG_BUFFER_SIZE;
|
||||
|
||||
struct bcm43xx_private *bcm = file->private_data;
|
||||
char *buf = really_big_buffer;
|
||||
size_t pos = 0;
|
||||
ssize_t res;
|
||||
unsigned long flags;
|
||||
|
||||
down(&big_buffer_sem);
|
||||
spin_lock_irqsave(&bcm->lock, flags);
|
||||
if (!bcm->initialized) {
|
||||
fappend("Board not initialized.\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* This is where the information is written to the "sprom_dump" file */
|
||||
fappend("boardflags: 0x%04x\n", bcm->sprom.boardflags);
|
||||
|
||||
out:
|
||||
spin_unlock_irqrestore(&bcm->lock, flags);
|
||||
res = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
|
||||
up(&big_buffer_sem);
|
||||
return res;
|
||||
}
|
||||
|
||||
static ssize_t tsf_read_file(struct file *file, char __user *userbuf,
|
||||
size_t count, loff_t *ppos)
|
||||
{
|
||||
const size_t len = REALLY_BIG_BUFFER_SIZE;
|
||||
|
||||
struct bcm43xx_private *bcm = file->private_data;
|
||||
char *buf = really_big_buffer;
|
||||
size_t pos = 0;
|
||||
ssize_t res;
|
||||
unsigned long flags;
|
||||
u64 tsf;
|
||||
|
||||
down(&big_buffer_sem);
|
||||
spin_lock_irqsave(&bcm->lock, flags);
|
||||
if (!bcm->initialized) {
|
||||
fappend("Board not initialized.\n");
|
||||
goto out;
|
||||
}
|
||||
bcm43xx_tsf_read(bcm, &tsf);
|
||||
fappend("0x%08x%08x\n",
|
||||
(unsigned int)((tsf & 0xFFFFFFFF00000000ULL) >> 32),
|
||||
(unsigned int)(tsf & 0xFFFFFFFFULL));
|
||||
|
||||
out:
|
||||
spin_unlock_irqrestore(&bcm->lock, flags);
|
||||
res = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
|
||||
up(&big_buffer_sem);
|
||||
return res;
|
||||
}
|
||||
|
||||
static ssize_t tsf_write_file(struct file *file, const char __user *user_buf,
|
||||
size_t count, loff_t *ppos)
|
||||
{
|
||||
struct bcm43xx_private *bcm = file->private_data;
|
||||
char *buf = really_big_buffer;
|
||||
ssize_t buf_size;
|
||||
ssize_t res;
|
||||
unsigned long flags;
|
||||
u64 tsf;
|
||||
|
||||
buf_size = min(count, sizeof (really_big_buffer) - 1);
|
||||
down(&big_buffer_sem);
|
||||
if (copy_from_user(buf, user_buf, buf_size)) {
|
||||
res = -EFAULT;
|
||||
goto out_up;
|
||||
}
|
||||
spin_lock_irqsave(&bcm->lock, flags);
|
||||
if (!bcm->initialized) {
|
||||
printk(KERN_INFO PFX "debugfs: Board not initialized.\n");
|
||||
res = -EFAULT;
|
||||
goto out_unlock;
|
||||
}
|
||||
if (sscanf(buf, "%lli", &tsf) != 1) {
|
||||
printk(KERN_INFO PFX "debugfs: invalid values for \"tsf\"\n");
|
||||
res = -EINVAL;
|
||||
goto out_unlock;
|
||||
}
|
||||
bcm43xx_tsf_write(bcm, tsf);
|
||||
res = buf_size;
|
||||
|
||||
out_unlock:
|
||||
spin_unlock_irqrestore(&bcm->lock, flags);
|
||||
out_up:
|
||||
up(&big_buffer_sem);
|
||||
return res;
|
||||
}
|
||||
|
||||
static ssize_t txstat_read_file(struct file *file, char __user *userbuf,
|
||||
size_t count, loff_t *ppos)
|
||||
{
|
||||
const size_t len = REALLY_BIG_BUFFER_SIZE;
|
||||
|
||||
struct bcm43xx_private *bcm = file->private_data;
|
||||
char *buf = really_big_buffer;
|
||||
size_t pos = 0;
|
||||
ssize_t res;
|
||||
unsigned long flags;
|
||||
struct bcm43xx_dfsentry *e;
|
||||
struct bcm43xx_xmitstatus *status;
|
||||
int i, cnt, j = 0;
|
||||
|
||||
down(&big_buffer_sem);
|
||||
spin_lock_irqsave(&bcm->lock, flags);
|
||||
|
||||
fappend("Last %d logged xmitstatus blobs (Latest first):\n\n",
|
||||
BCM43xx_NR_LOGGED_XMITSTATUS);
|
||||
e = bcm->dfsentry;
|
||||
if (e->xmitstatus_printing == 0) {
|
||||
/* At the beginning, make a copy of all data to avoid
|
||||
* concurrency, as this function is called multiple
|
||||
* times for big logs. Without copying, the data might
|
||||
* change between reads. This would result in total trash.
|
||||
*/
|
||||
e->xmitstatus_printing = 1;
|
||||
e->saved_xmitstatus_ptr = e->xmitstatus_ptr;
|
||||
e->saved_xmitstatus_cnt = e->xmitstatus_cnt;
|
||||
memcpy(e->xmitstatus_print_buffer, e->xmitstatus_buffer,
|
||||
BCM43xx_NR_LOGGED_XMITSTATUS * sizeof(*(e->xmitstatus_buffer)));
|
||||
}
|
||||
i = e->saved_xmitstatus_ptr - 1;
|
||||
if (i < 0)
|
||||
i = BCM43xx_NR_LOGGED_XMITSTATUS - 1;
|
||||
cnt = e->saved_xmitstatus_cnt;
|
||||
while (cnt) {
|
||||
status = e->xmitstatus_print_buffer + i;
|
||||
fappend("0x%02x: cookie: 0x%04x, flags: 0x%02x, "
|
||||
"cnt1: 0x%02x, cnt2: 0x%02x, seq: 0x%04x, "
|
||||
"unk: 0x%04x\n", j,
|
||||
status->cookie, status->flags,
|
||||
status->cnt1, status->cnt2, status->seq,
|
||||
status->unknown);
|
||||
j++;
|
||||
cnt--;
|
||||
i--;
|
||||
if (i < 0)
|
||||
i = BCM43xx_NR_LOGGED_XMITSTATUS - 1;
|
||||
}
|
||||
|
||||
spin_unlock_irqrestore(&bcm->lock, flags);
|
||||
res = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
|
||||
spin_lock_irqsave(&bcm->lock, flags);
|
||||
if (*ppos == pos) {
|
||||
/* Done. Drop the copied data. */
|
||||
e->xmitstatus_printing = 0;
|
||||
}
|
||||
spin_unlock_irqrestore(&bcm->lock, flags);
|
||||
up(&big_buffer_sem);
|
||||
return res;
|
||||
}
|
||||
|
||||
#undef fappend
|
||||
|
||||
|
||||
static struct file_operations devinfo_fops = {
|
||||
.read = devinfo_read_file,
|
||||
.write = write_file_dummy,
|
||||
.open = open_file_generic,
|
||||
};
|
||||
|
||||
static struct file_operations spromdump_fops = {
|
||||
.read = spromdump_read_file,
|
||||
.write = write_file_dummy,
|
||||
.open = open_file_generic,
|
||||
};
|
||||
|
||||
static struct file_operations drvinfo_fops = {
|
||||
.read = drvinfo_read_file,
|
||||
.write = write_file_dummy,
|
||||
.open = open_file_generic,
|
||||
};
|
||||
|
||||
static struct file_operations tsf_fops = {
|
||||
.read = tsf_read_file,
|
||||
.write = tsf_write_file,
|
||||
.open = open_file_generic,
|
||||
};
|
||||
|
||||
static struct file_operations txstat_fops = {
|
||||
.read = txstat_read_file,
|
||||
.write = write_file_dummy,
|
||||
.open = open_file_generic,
|
||||
};
|
||||
|
||||
|
||||
void bcm43xx_debugfs_add_device(struct bcm43xx_private *bcm)
|
||||
{
|
||||
struct bcm43xx_dfsentry *e;
|
||||
char devdir[IFNAMSIZ];
|
||||
|
||||
assert(bcm);
|
||||
e = kzalloc(sizeof(*e), GFP_KERNEL);
|
||||
if (!e) {
|
||||
printk(KERN_ERR PFX "out of memory\n");
|
||||
return;
|
||||
}
|
||||
e->bcm = bcm;
|
||||
e->xmitstatus_buffer = kzalloc(BCM43xx_NR_LOGGED_XMITSTATUS
|
||||
* sizeof(*(e->xmitstatus_buffer)),
|
||||
GFP_KERNEL);
|
||||
if (!e->xmitstatus_buffer) {
|
||||
printk(KERN_ERR PFX "out of memory\n");
|
||||
kfree(e);
|
||||
return;
|
||||
}
|
||||
e->xmitstatus_print_buffer = kzalloc(BCM43xx_NR_LOGGED_XMITSTATUS
|
||||
* sizeof(*(e->xmitstatus_buffer)),
|
||||
GFP_KERNEL);
|
||||
if (!e->xmitstatus_print_buffer) {
|
||||
printk(KERN_ERR PFX "out of memory\n");
|
||||
kfree(e);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
bcm->dfsentry = e;
|
||||
|
||||
strncpy(devdir, bcm->net_dev->name, ARRAY_SIZE(devdir));
|
||||
e->subdir = debugfs_create_dir(devdir, fs.root);
|
||||
e->dentry_devinfo = debugfs_create_file("devinfo", 0444, e->subdir,
|
||||
bcm, &devinfo_fops);
|
||||
if (!e->dentry_devinfo)
|
||||
printk(KERN_ERR PFX "debugfs: creating \"devinfo\" for \"%s\" failed!\n", devdir);
|
||||
e->dentry_spromdump = debugfs_create_file("sprom_dump", 0444, e->subdir,
|
||||
bcm, &spromdump_fops);
|
||||
if (!e->dentry_spromdump)
|
||||
printk(KERN_ERR PFX "debugfs: creating \"sprom_dump\" for \"%s\" failed!\n", devdir);
|
||||
e->dentry_tsf = debugfs_create_file("tsf", 0666, e->subdir,
|
||||
bcm, &tsf_fops);
|
||||
if (!e->dentry_tsf)
|
||||
printk(KERN_ERR PFX "debugfs: creating \"tsf\" for \"%s\" failed!\n", devdir);
|
||||
e->dentry_txstat = debugfs_create_file("tx_status", 0444, e->subdir,
|
||||
bcm, &txstat_fops);
|
||||
if (!e->dentry_txstat)
|
||||
printk(KERN_ERR PFX "debugfs: creating \"tx_status\" for \"%s\" failed!\n", devdir);
|
||||
}
|
||||
|
||||
void bcm43xx_debugfs_remove_device(struct bcm43xx_private *bcm)
|
||||
{
|
||||
struct bcm43xx_dfsentry *e;
|
||||
|
||||
if (!bcm)
|
||||
return;
|
||||
|
||||
e = bcm->dfsentry;
|
||||
assert(e);
|
||||
debugfs_remove(e->dentry_spromdump);
|
||||
debugfs_remove(e->dentry_devinfo);
|
||||
debugfs_remove(e->dentry_tsf);
|
||||
debugfs_remove(e->dentry_txstat);
|
||||
debugfs_remove(e->subdir);
|
||||
kfree(e->xmitstatus_buffer);
|
||||
kfree(e->xmitstatus_print_buffer);
|
||||
kfree(e);
|
||||
}
|
||||
|
||||
void bcm43xx_debugfs_log_txstat(struct bcm43xx_private *bcm,
|
||||
struct bcm43xx_xmitstatus *status)
|
||||
{
|
||||
struct bcm43xx_dfsentry *e;
|
||||
struct bcm43xx_xmitstatus *savedstatus;
|
||||
|
||||
/* This is protected by bcm->lock */
|
||||
e = bcm->dfsentry;
|
||||
assert(e);
|
||||
savedstatus = e->xmitstatus_buffer + e->xmitstatus_ptr;
|
||||
memcpy(savedstatus, status, sizeof(*status));
|
||||
e->xmitstatus_ptr++;
|
||||
if (e->xmitstatus_ptr >= BCM43xx_NR_LOGGED_XMITSTATUS)
|
||||
e->xmitstatus_ptr = 0;
|
||||
if (e->xmitstatus_cnt < BCM43xx_NR_LOGGED_XMITSTATUS)
|
||||
e->xmitstatus_cnt++;
|
||||
}
|
||||
|
||||
void bcm43xx_debugfs_init(void)
|
||||
{
|
||||
memset(&fs, 0, sizeof(fs));
|
||||
fs.root = debugfs_create_dir(DRV_NAME, NULL);
|
||||
if (!fs.root)
|
||||
printk(KERN_ERR PFX "debugfs: creating \"" DRV_NAME "\" subdir failed!\n");
|
||||
fs.dentry_driverinfo = debugfs_create_file("driver", 0444, fs.root, NULL, &drvinfo_fops);
|
||||
if (!fs.dentry_driverinfo)
|
||||
printk(KERN_ERR PFX "debugfs: creating \"" DRV_NAME "/driver\" failed!\n");
|
||||
}
|
||||
|
||||
void bcm43xx_debugfs_exit(void)
|
||||
{
|
||||
debugfs_remove(fs.dentry_driverinfo);
|
||||
debugfs_remove(fs.root);
|
||||
}
|
||||
|
||||
void bcm43xx_printk_dump(const char *data,
|
||||
size_t size,
|
||||
const char *description)
|
||||
{
|
||||
size_t i;
|
||||
char c;
|
||||
|
||||
printk(KERN_INFO PFX "Data dump (%s, %u bytes):",
|
||||
description, size);
|
||||
for (i = 0; i < size; i++) {
|
||||
c = data[i];
|
||||
if (i % 8 == 0)
|
||||
printk("\n" KERN_INFO PFX "0x%08x: 0x%02x, ", i, c & 0xff);
|
||||
else
|
||||
printk("0x%02x, ", c & 0xff);
|
||||
}
|
||||
printk("\n");
|
||||
}
|
||||
|
||||
void bcm43xx_printk_bitdump(const unsigned char *data,
|
||||
size_t bytes, int msb_to_lsb,
|
||||
const char *description)
|
||||
{
|
||||
size_t i;
|
||||
int j;
|
||||
const unsigned char *d;
|
||||
|
||||
printk(KERN_INFO PFX "*** Bitdump (%s, %u bytes, %s) ***",
|
||||
description, bytes, msb_to_lsb ? "MSB to LSB" : "LSB to MSB");
|
||||
for (i = 0; i < bytes; i++) {
|
||||
d = data + i;
|
||||
if (i % 8 == 0)
|
||||
printk("\n" KERN_INFO PFX "0x%08x: ", i);
|
||||
if (msb_to_lsb) {
|
||||
for (j = 7; j >= 0; j--) {
|
||||
if (*d & (1 << j))
|
||||
printk("1");
|
||||
else
|
||||
printk("0");
|
||||
}
|
||||
} else {
|
||||
for (j = 0; j < 8; j++) {
|
||||
if (*d & (1 << j))
|
||||
printk("1");
|
||||
else
|
||||
printk("0");
|
||||
}
|
||||
}
|
||||
printk(" ");
|
||||
}
|
||||
printk("\n");
|
||||
}
|
||||
|
||||
/* vim: set ts=8 sw=8 sts=8: */
|
117
drivers/net/wireless/bcm43xx/bcm43xx_debugfs.h
Normal file
117
drivers/net/wireless/bcm43xx/bcm43xx_debugfs.h
Normal file
@ -0,0 +1,117 @@
|
||||
#ifndef BCM43xx_DEBUGFS_H_
|
||||
#define BCM43xx_DEBUGFS_H_
|
||||
|
||||
struct bcm43xx_private;
|
||||
struct bcm43xx_xmitstatus;
|
||||
|
||||
#ifdef CONFIG_BCM43XX_DEBUG
|
||||
|
||||
#include <linux/list.h>
|
||||
#include <asm/semaphore.h>
|
||||
|
||||
struct dentry;
|
||||
|
||||
/* limited by the size of the "really_big_buffer" */
|
||||
#define BCM43xx_NR_LOGGED_XMITSTATUS 100
|
||||
|
||||
struct bcm43xx_dfsentry {
|
||||
struct dentry *subdir;
|
||||
struct dentry *dentry_devinfo;
|
||||
struct dentry *dentry_spromdump;
|
||||
struct dentry *dentry_tsf;
|
||||
struct dentry *dentry_txstat;
|
||||
|
||||
struct bcm43xx_private *bcm;
|
||||
|
||||
/* saved xmitstatus. */
|
||||
struct bcm43xx_xmitstatus *xmitstatus_buffer;
|
||||
int xmitstatus_ptr;
|
||||
int xmitstatus_cnt;
|
||||
/* We need a seperate buffer while printing to avoid
|
||||
* concurrency issues. (New xmitstatus can arrive
|
||||
* while we are printing).
|
||||
*/
|
||||
struct bcm43xx_xmitstatus *xmitstatus_print_buffer;
|
||||
int saved_xmitstatus_ptr;
|
||||
int saved_xmitstatus_cnt;
|
||||
int xmitstatus_printing;
|
||||
};
|
||||
|
||||
struct bcm43xx_debugfs {
|
||||
struct dentry *root;
|
||||
struct dentry *dentry_driverinfo;
|
||||
};
|
||||
|
||||
void bcm43xx_debugfs_init(void);
|
||||
void bcm43xx_debugfs_exit(void);
|
||||
void bcm43xx_debugfs_add_device(struct bcm43xx_private *bcm);
|
||||
void bcm43xx_debugfs_remove_device(struct bcm43xx_private *bcm);
|
||||
void bcm43xx_debugfs_log_txstat(struct bcm43xx_private *bcm,
|
||||
struct bcm43xx_xmitstatus *status);
|
||||
|
||||
/* Debug helper: Dump binary data through printk. */
|
||||
void bcm43xx_printk_dump(const char *data,
|
||||
size_t size,
|
||||
const char *description);
|
||||
/* Debug helper: Dump bitwise binary data through printk. */
|
||||
void bcm43xx_printk_bitdump(const unsigned char *data,
|
||||
size_t bytes, int msb_to_lsb,
|
||||
const char *description);
|
||||
#define bcm43xx_printk_bitdumpt(pointer, msb_to_lsb, description) \
|
||||
do { \
|
||||
bcm43xx_printk_bitdump((const unsigned char *)(pointer), \
|
||||
sizeof(*(pointer)), \
|
||||
(msb_to_lsb), \
|
||||
(description)); \
|
||||
} while (0)
|
||||
|
||||
#else /* CONFIG_BCM43XX_DEBUG*/
|
||||
|
||||
static inline
|
||||
void bcm43xx_debugfs_init(void) { }
|
||||
static inline
|
||||
void bcm43xx_debugfs_exit(void) { }
|
||||
static inline
|
||||
void bcm43xx_debugfs_add_device(struct bcm43xx_private *bcm) { }
|
||||
static inline
|
||||
void bcm43xx_debugfs_remove_device(struct bcm43xx_private *bcm) { }
|
||||
static inline
|
||||
void bcm43xx_debugfs_log_txstat(struct bcm43xx_private *bcm,
|
||||
struct bcm43xx_xmitstatus *status) { }
|
||||
|
||||
static inline
|
||||
void bcm43xx_printk_dump(const char *data,
|
||||
size_t size,
|
||||
const char *description)
|
||||
{
|
||||
}
|
||||
static inline
|
||||
void bcm43xx_printk_bitdump(const unsigned char *data,
|
||||
size_t bytes, int msb_to_lsb,
|
||||
const char *description)
|
||||
{
|
||||
}
|
||||
#define bcm43xx_printk_bitdumpt(pointer, msb_to_lsb, description) do { /* nothing */ } while (0)
|
||||
|
||||
#endif /* CONFIG_BCM43XX_DEBUG*/
|
||||
|
||||
/* Ugly helper macros to make incomplete code more verbose on runtime */
|
||||
#ifdef TODO
|
||||
# undef TODO
|
||||
#endif
|
||||
#define TODO() \
|
||||
do { \
|
||||
printk(KERN_INFO PFX "TODO: Incomplete code in %s() at %s:%d\n", \
|
||||
__FUNCTION__, __FILE__, __LINE__); \
|
||||
} while (0)
|
||||
|
||||
#ifdef FIXME
|
||||
# undef FIXME
|
||||
#endif
|
||||
#define FIXME() \
|
||||
do { \
|
||||
printk(KERN_INFO PFX "FIXME: Possibly broken code in %s() at %s:%d\n", \
|
||||
__FUNCTION__, __FILE__, __LINE__); \
|
||||
} while (0)
|
||||
|
||||
#endif /* BCM43xx_DEBUGFS_H_ */
|
1009
drivers/net/wireless/bcm43xx/bcm43xx_dma.c
Normal file
1009
drivers/net/wireless/bcm43xx/bcm43xx_dma.c
Normal file
File diff suppressed because it is too large
Load Diff
176
drivers/net/wireless/bcm43xx/bcm43xx_dma.h
Normal file
176
drivers/net/wireless/bcm43xx/bcm43xx_dma.h
Normal file
@ -0,0 +1,176 @@
|
||||
#ifndef BCM43xx_DMA_H_
|
||||
#define BCM43xx_DMA_H_
|
||||
|
||||
#include <linux/list.h>
|
||||
#include <linux/spinlock.h>
|
||||
#include <linux/workqueue.h>
|
||||
#include <linux/linkage.h>
|
||||
#include <asm/atomic.h>
|
||||
|
||||
|
||||
/* DMA-Interrupt reasons. */
|
||||
/*TODO: add the missing ones. */
|
||||
#define BCM43xx_DMAIRQ_ERR0 (1 << 10)
|
||||
#define BCM43xx_DMAIRQ_ERR1 (1 << 11)
|
||||
#define BCM43xx_DMAIRQ_ERR2 (1 << 12)
|
||||
#define BCM43xx_DMAIRQ_ERR3 (1 << 13)
|
||||
#define BCM43xx_DMAIRQ_ERR4 (1 << 14)
|
||||
#define BCM43xx_DMAIRQ_ERR5 (1 << 15)
|
||||
#define BCM43xx_DMAIRQ_RX_DONE (1 << 16)
|
||||
/* helpers */
|
||||
#define BCM43xx_DMAIRQ_ANYERR (BCM43xx_DMAIRQ_ERR0 | \
|
||||
BCM43xx_DMAIRQ_ERR1 | \
|
||||
BCM43xx_DMAIRQ_ERR2 | \
|
||||
BCM43xx_DMAIRQ_ERR3 | \
|
||||
BCM43xx_DMAIRQ_ERR4 | \
|
||||
BCM43xx_DMAIRQ_ERR5)
|
||||
#define BCM43xx_DMAIRQ_FATALERR (BCM43xx_DMAIRQ_ERR0 | \
|
||||
BCM43xx_DMAIRQ_ERR1 | \
|
||||
BCM43xx_DMAIRQ_ERR2 | \
|
||||
BCM43xx_DMAIRQ_ERR4 | \
|
||||
BCM43xx_DMAIRQ_ERR5)
|
||||
#define BCM43xx_DMAIRQ_NONFATALERR BCM43xx_DMAIRQ_ERR3
|
||||
|
||||
/* DMA controller register offsets. (relative to BCM43xx_DMA#_BASE) */
|
||||
#define BCM43xx_DMA_TX_CONTROL 0x00
|
||||
#define BCM43xx_DMA_TX_DESC_RING 0x04
|
||||
#define BCM43xx_DMA_TX_DESC_INDEX 0x08
|
||||
#define BCM43xx_DMA_TX_STATUS 0x0c
|
||||
#define BCM43xx_DMA_RX_CONTROL 0x10
|
||||
#define BCM43xx_DMA_RX_DESC_RING 0x14
|
||||
#define BCM43xx_DMA_RX_DESC_INDEX 0x18
|
||||
#define BCM43xx_DMA_RX_STATUS 0x1c
|
||||
|
||||
/* DMA controller channel control word values. */
|
||||
#define BCM43xx_DMA_TXCTRL_ENABLE (1 << 0)
|
||||
#define BCM43xx_DMA_TXCTRL_SUSPEND (1 << 1)
|
||||
#define BCM43xx_DMA_TXCTRL_LOOPBACK (1 << 2)
|
||||
#define BCM43xx_DMA_TXCTRL_FLUSH (1 << 4)
|
||||
#define BCM43xx_DMA_RXCTRL_ENABLE (1 << 0)
|
||||
#define BCM43xx_DMA_RXCTRL_FRAMEOFF_MASK 0x000000fe
|
||||
#define BCM43xx_DMA_RXCTRL_FRAMEOFF_SHIFT 1
|
||||
#define BCM43xx_DMA_RXCTRL_PIO (1 << 8)
|
||||
/* DMA controller channel status word values. */
|
||||
#define BCM43xx_DMA_TXSTAT_DPTR_MASK 0x00000fff
|
||||
#define BCM43xx_DMA_TXSTAT_STAT_MASK 0x0000f000
|
||||
#define BCM43xx_DMA_TXSTAT_STAT_DISABLED 0x00000000
|
||||
#define BCM43xx_DMA_TXSTAT_STAT_ACTIVE 0x00001000
|
||||
#define BCM43xx_DMA_TXSTAT_STAT_IDLEWAIT 0x00002000
|
||||
#define BCM43xx_DMA_TXSTAT_STAT_STOPPED 0x00003000
|
||||
#define BCM43xx_DMA_TXSTAT_STAT_SUSP 0x00004000
|
||||
#define BCM43xx_DMA_TXSTAT_ERROR_MASK 0x000f0000
|
||||
#define BCM43xx_DMA_TXSTAT_FLUSHED (1 << 20)
|
||||
#define BCM43xx_DMA_RXSTAT_DPTR_MASK 0x00000fff
|
||||
#define BCM43xx_DMA_RXSTAT_STAT_MASK 0x0000f000
|
||||
#define BCM43xx_DMA_RXSTAT_STAT_DISABLED 0x00000000
|
||||
#define BCM43xx_DMA_RXSTAT_STAT_ACTIVE 0x00001000
|
||||
#define BCM43xx_DMA_RXSTAT_STAT_IDLEWAIT 0x00002000
|
||||
#define BCM43xx_DMA_RXSTAT_STAT_RESERVED 0x00003000
|
||||
#define BCM43xx_DMA_RXSTAT_STAT_ERRORS 0x00004000
|
||||
#define BCM43xx_DMA_RXSTAT_ERROR_MASK 0x000f0000
|
||||
|
||||
/* DMA descriptor control field values. */
|
||||
#define BCM43xx_DMADTOR_BYTECNT_MASK 0x00001fff
|
||||
#define BCM43xx_DMADTOR_DTABLEEND (1 << 28) /* End of descriptor table */
|
||||
#define BCM43xx_DMADTOR_COMPIRQ (1 << 29) /* IRQ on completion request */
|
||||
#define BCM43xx_DMADTOR_FRAMEEND (1 << 30)
|
||||
#define BCM43xx_DMADTOR_FRAMESTART (1 << 31)
|
||||
|
||||
/* Misc DMA constants */
|
||||
#define BCM43xx_DMA_RINGMEMSIZE PAGE_SIZE
|
||||
#define BCM43xx_DMA_BUSADDRMAX 0x3FFFFFFF
|
||||
#define BCM43xx_DMA_DMABUSADDROFFSET (1 << 30)
|
||||
#define BCM43xx_DMA1_RX_FRAMEOFFSET 30
|
||||
#define BCM43xx_DMA4_RX_FRAMEOFFSET 0
|
||||
|
||||
/* DMA engine tuning knobs */
|
||||
#define BCM43xx_TXRING_SLOTS 512
|
||||
#define BCM43xx_RXRING_SLOTS 64
|
||||
#define BCM43xx_DMA1_RXBUFFERSIZE (2304 + 100)
|
||||
#define BCM43xx_DMA4_RXBUFFERSIZE 16
|
||||
/* Suspend the tx queue, if less than this percent slots are free. */
|
||||
#define BCM43xx_TXSUSPEND_PERCENT 20
|
||||
/* Resume the tx queue, if more than this percent slots are free. */
|
||||
#define BCM43xx_TXRESUME_PERCENT 50
|
||||
|
||||
|
||||
struct sk_buff;
|
||||
struct bcm43xx_private;
|
||||
struct bcm43xx_xmitstatus;
|
||||
|
||||
|
||||
struct bcm43xx_dmadesc {
|
||||
__le32 _control;
|
||||
__le32 _address;
|
||||
} __attribute__((__packed__));
|
||||
|
||||
/* Macros to access the bcm43xx_dmadesc struct */
|
||||
#define get_desc_ctl(desc) le32_to_cpu((desc)->_control)
|
||||
#define set_desc_ctl(desc, ctl) do { (desc)->_control = cpu_to_le32(ctl); } while (0)
|
||||
#define get_desc_addr(desc) le32_to_cpu((desc)->_address)
|
||||
#define set_desc_addr(desc, addr) do { (desc)->_address = cpu_to_le32(addr); } while (0)
|
||||
|
||||
struct bcm43xx_dmadesc_meta {
|
||||
/* The kernel DMA-able buffer. */
|
||||
struct sk_buff *skb;
|
||||
/* DMA base bus-address of the descriptor buffer. */
|
||||
dma_addr_t dmaaddr;
|
||||
/* Pointer to our txb (can be NULL).
|
||||
* This should be freed in completion IRQ.
|
||||
*/
|
||||
struct ieee80211_txb *txb;
|
||||
};
|
||||
|
||||
struct bcm43xx_dmaring {
|
||||
spinlock_t lock;
|
||||
struct bcm43xx_private *bcm;
|
||||
/* Kernel virtual base address of the ring memory. */
|
||||
struct bcm43xx_dmadesc *vbase;
|
||||
/* DMA memory offset */
|
||||
dma_addr_t memoffset;
|
||||
/* (Unadjusted) DMA base bus-address of the ring memory. */
|
||||
dma_addr_t dmabase;
|
||||
/* Meta data about all descriptors. */
|
||||
struct bcm43xx_dmadesc_meta *meta;
|
||||
/* Number of descriptor slots in the ring. */
|
||||
int nr_slots;
|
||||
/* Number of used descriptor slots. */
|
||||
int used_slots;
|
||||
/* Currently used slot in the ring. */
|
||||
int current_slot;
|
||||
/* Marks to suspend/resume the queue. */
|
||||
int suspend_mark;
|
||||
int resume_mark;
|
||||
/* Frameoffset in octets. */
|
||||
u32 frameoffset;
|
||||
/* Descriptor buffer size. */
|
||||
u16 rx_buffersize;
|
||||
/* The MMIO base register of the DMA controller, this
|
||||
* ring is posted to.
|
||||
*/
|
||||
u16 mmio_base;
|
||||
u8 tx:1, /* TRUE, if this is a TX ring. */
|
||||
suspended:1; /* TRUE, if transfers are suspended on this ring. */
|
||||
#ifdef CONFIG_BCM43XX_DEBUG
|
||||
/* Maximum number of used slots. */
|
||||
int max_used_slots;
|
||||
#endif /* CONFIG_BCM43XX_DEBUG*/
|
||||
};
|
||||
|
||||
|
||||
int bcm43xx_dma_init(struct bcm43xx_private *bcm);
|
||||
void bcm43xx_dma_free(struct bcm43xx_private *bcm);
|
||||
|
||||
int bcm43xx_dmacontroller_rx_reset(struct bcm43xx_private *bcm,
|
||||
u16 dmacontroller_mmio_base);
|
||||
int bcm43xx_dmacontroller_tx_reset(struct bcm43xx_private *bcm,
|
||||
u16 dmacontroller_mmio_base);
|
||||
|
||||
int FASTCALL(bcm43xx_dma_transfer_txb(struct bcm43xx_private *bcm,
|
||||
struct ieee80211_txb *txb));
|
||||
void FASTCALL(bcm43xx_dma_handle_xmitstatus(struct bcm43xx_private *bcm,
|
||||
struct bcm43xx_xmitstatus *status));
|
||||
|
||||
void FASTCALL(bcm43xx_dma_rx(struct bcm43xx_dmaring *ring));
|
||||
|
||||
#endif /* BCM43xx_DMA_H_ */
|
367
drivers/net/wireless/bcm43xx/bcm43xx_ilt.c
Normal file
367
drivers/net/wireless/bcm43xx/bcm43xx_ilt.c
Normal file
@ -0,0 +1,367 @@
|
||||
/*
|
||||
|
||||
Broadcom BCM43xx wireless driver
|
||||
|
||||
Copyright (c) 2005 Martin Langer <martin-langer@gmx.de>,
|
||||
Stefano Brivio <st3@riseup.net>
|
||||
Michael Buesch <mbuesch@freenet.de>
|
||||
Danny van Dyk <kugelfang@gentoo.org>
|
||||
Andreas Jaggi <andreas.jaggi@waterwave.ch>
|
||||
|
||||
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.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
|
||||
*/
|
||||
|
||||
#include "bcm43xx.h"
|
||||
#include "bcm43xx_ilt.h"
|
||||
#include "bcm43xx_phy.h"
|
||||
|
||||
|
||||
/**** Initial Internal Lookup Tables ****/
|
||||
|
||||
const u32 bcm43xx_ilt_rotor[BCM43xx_ILT_ROTOR_SIZE] = {
|
||||
0xFEB93FFD, 0xFEC63FFD, /* 0 */
|
||||
0xFED23FFD, 0xFEDF3FFD,
|
||||
0xFEEC3FFE, 0xFEF83FFE,
|
||||
0xFF053FFE, 0xFF113FFE,
|
||||
0xFF1E3FFE, 0xFF2A3FFF, /* 8 */
|
||||
0xFF373FFF, 0xFF443FFF,
|
||||
0xFF503FFF, 0xFF5D3FFF,
|
||||
0xFF693FFF, 0xFF763FFF,
|
||||
0xFF824000, 0xFF8F4000, /* 16 */
|
||||
0xFF9B4000, 0xFFA84000,
|
||||
0xFFB54000, 0xFFC14000,
|
||||
0xFFCE4000, 0xFFDA4000,
|
||||
0xFFE74000, 0xFFF34000, /* 24 */
|
||||
0x00004000, 0x000D4000,
|
||||
0x00194000, 0x00264000,
|
||||
0x00324000, 0x003F4000,
|
||||
0x004B4000, 0x00584000, /* 32 */
|
||||
0x00654000, 0x00714000,
|
||||
0x007E4000, 0x008A3FFF,
|
||||
0x00973FFF, 0x00A33FFF,
|
||||
0x00B03FFF, 0x00BC3FFF, /* 40 */
|
||||
0x00C93FFF, 0x00D63FFF,
|
||||
0x00E23FFE, 0x00EF3FFE,
|
||||
0x00FB3FFE, 0x01083FFE,
|
||||
0x01143FFE, 0x01213FFD, /* 48 */
|
||||
0x012E3FFD, 0x013A3FFD,
|
||||
0x01473FFD,
|
||||
};
|
||||
|
||||
const u32 bcm43xx_ilt_retard[BCM43xx_ILT_RETARD_SIZE] = {
|
||||
0xDB93CB87, 0xD666CF64, /* 0 */
|
||||
0xD1FDD358, 0xCDA6D826,
|
||||
0xCA38DD9F, 0xC729E2B4,
|
||||
0xC469E88E, 0xC26AEE2B,
|
||||
0xC0DEF46C, 0xC073FA62, /* 8 */
|
||||
0xC01D00D5, 0xC0760743,
|
||||
0xC1560D1E, 0xC2E51369,
|
||||
0xC4ED18FF, 0xC7AC1ED7,
|
||||
0xCB2823B2, 0xCEFA28D9, /* 16 */
|
||||
0xD2F62D3F, 0xD7BB3197,
|
||||
0xDCE53568, 0xE1FE3875,
|
||||
0xE7D13B35, 0xED663D35,
|
||||
0xF39B3EC4, 0xF98E3FA7, /* 24 */
|
||||
0x00004000, 0x06723FA7,
|
||||
0x0C653EC4, 0x129A3D35,
|
||||
0x182F3B35, 0x1E023875,
|
||||
0x231B3568, 0x28453197, /* 32 */
|
||||
0x2D0A2D3F, 0x310628D9,
|
||||
0x34D823B2, 0x38541ED7,
|
||||
0x3B1318FF, 0x3D1B1369,
|
||||
0x3EAA0D1E, 0x3F8A0743, /* 40 */
|
||||
0x3FE300D5, 0x3F8DFA62,
|
||||
0x3F22F46C, 0x3D96EE2B,
|
||||
0x3B97E88E, 0x38D7E2B4,
|
||||
0x35C8DD9F, 0x325AD826, /* 48 */
|
||||
0x2E03D358, 0x299ACF64,
|
||||
0x246DCB87,
|
||||
};
|
||||
|
||||
const u16 bcm43xx_ilt_finefreqa[BCM43xx_ILT_FINEFREQA_SIZE] = {
|
||||
0x0082, 0x0082, 0x0102, 0x0182, /* 0 */
|
||||
0x0202, 0x0282, 0x0302, 0x0382,
|
||||
0x0402, 0x0482, 0x0502, 0x0582,
|
||||
0x05E2, 0x0662, 0x06E2, 0x0762,
|
||||
0x07E2, 0x0842, 0x08C2, 0x0942, /* 16 */
|
||||
0x09C2, 0x0A22, 0x0AA2, 0x0B02,
|
||||
0x0B82, 0x0BE2, 0x0C62, 0x0CC2,
|
||||
0x0D42, 0x0DA2, 0x0E02, 0x0E62,
|
||||
0x0EE2, 0x0F42, 0x0FA2, 0x1002, /* 32 */
|
||||
0x1062, 0x10C2, 0x1122, 0x1182,
|
||||
0x11E2, 0x1242, 0x12A2, 0x12E2,
|
||||
0x1342, 0x13A2, 0x1402, 0x1442,
|
||||
0x14A2, 0x14E2, 0x1542, 0x1582, /* 48 */
|
||||
0x15E2, 0x1622, 0x1662, 0x16C1,
|
||||
0x1701, 0x1741, 0x1781, 0x17E1,
|
||||
0x1821, 0x1861, 0x18A1, 0x18E1,
|
||||
0x1921, 0x1961, 0x19A1, 0x19E1, /* 64 */
|
||||
0x1A21, 0x1A61, 0x1AA1, 0x1AC1,
|
||||
0x1B01, 0x1B41, 0x1B81, 0x1BA1,
|
||||
0x1BE1, 0x1C21, 0x1C41, 0x1C81,
|
||||
0x1CA1, 0x1CE1, 0x1D01, 0x1D41, /* 80 */
|
||||
0x1D61, 0x1DA1, 0x1DC1, 0x1E01,
|
||||
0x1E21, 0x1E61, 0x1E81, 0x1EA1,
|
||||
0x1EE1, 0x1F01, 0x1F21, 0x1F41,
|
||||
0x1F81, 0x1FA1, 0x1FC1, 0x1FE1, /* 96 */
|
||||
0x2001, 0x2041, 0x2061, 0x2081,
|
||||
0x20A1, 0x20C1, 0x20E1, 0x2101,
|
||||
0x2121, 0x2141, 0x2161, 0x2181,
|
||||
0x21A1, 0x21C1, 0x21E1, 0x2201, /* 112 */
|
||||
0x2221, 0x2241, 0x2261, 0x2281,
|
||||
0x22A1, 0x22C1, 0x22C1, 0x22E1,
|
||||
0x2301, 0x2321, 0x2341, 0x2361,
|
||||
0x2361, 0x2381, 0x23A1, 0x23C1, /* 128 */
|
||||
0x23E1, 0x23E1, 0x2401, 0x2421,
|
||||
0x2441, 0x2441, 0x2461, 0x2481,
|
||||
0x2481, 0x24A1, 0x24C1, 0x24C1,
|
||||
0x24E1, 0x2501, 0x2501, 0x2521, /* 144 */
|
||||
0x2541, 0x2541, 0x2561, 0x2561,
|
||||
0x2581, 0x25A1, 0x25A1, 0x25C1,
|
||||
0x25C1, 0x25E1, 0x2601, 0x2601,
|
||||
0x2621, 0x2621, 0x2641, 0x2641, /* 160 */
|
||||
0x2661, 0x2661, 0x2681, 0x2681,
|
||||
0x26A1, 0x26A1, 0x26C1, 0x26C1,
|
||||
0x26E1, 0x26E1, 0x2701, 0x2701,
|
||||
0x2721, 0x2721, 0x2740, 0x2740, /* 176 */
|
||||
0x2760, 0x2760, 0x2780, 0x2780,
|
||||
0x2780, 0x27A0, 0x27A0, 0x27C0,
|
||||
0x27C0, 0x27E0, 0x27E0, 0x27E0,
|
||||
0x2800, 0x2800, 0x2820, 0x2820, /* 192 */
|
||||
0x2820, 0x2840, 0x2840, 0x2840,
|
||||
0x2860, 0x2860, 0x2880, 0x2880,
|
||||
0x2880, 0x28A0, 0x28A0, 0x28A0,
|
||||
0x28C0, 0x28C0, 0x28C0, 0x28E0, /* 208 */
|
||||
0x28E0, 0x28E0, 0x2900, 0x2900,
|
||||
0x2900, 0x2920, 0x2920, 0x2920,
|
||||
0x2940, 0x2940, 0x2940, 0x2960,
|
||||
0x2960, 0x2960, 0x2960, 0x2980, /* 224 */
|
||||
0x2980, 0x2980, 0x29A0, 0x29A0,
|
||||
0x29A0, 0x29A0, 0x29C0, 0x29C0,
|
||||
0x29C0, 0x29E0, 0x29E0, 0x29E0,
|
||||
0x29E0, 0x2A00, 0x2A00, 0x2A00, /* 240 */
|
||||
0x2A00, 0x2A20, 0x2A20, 0x2A20,
|
||||
0x2A20, 0x2A40, 0x2A40, 0x2A40,
|
||||
0x2A40, 0x2A60, 0x2A60, 0x2A60,
|
||||
};
|
||||
|
||||
const u16 bcm43xx_ilt_finefreqg[BCM43xx_ILT_FINEFREQG_SIZE] = {
|
||||
0x0089, 0x02E9, 0x0409, 0x04E9, /* 0 */
|
||||
0x05A9, 0x0669, 0x0709, 0x0789,
|
||||
0x0829, 0x08A9, 0x0929, 0x0989,
|
||||
0x0A09, 0x0A69, 0x0AC9, 0x0B29,
|
||||
0x0BA9, 0x0BE9, 0x0C49, 0x0CA9, /* 16 */
|
||||
0x0D09, 0x0D69, 0x0DA9, 0x0E09,
|
||||
0x0E69, 0x0EA9, 0x0F09, 0x0F49,
|
||||
0x0FA9, 0x0FE9, 0x1029, 0x1089,
|
||||
0x10C9, 0x1109, 0x1169, 0x11A9, /* 32 */
|
||||
0x11E9, 0x1229, 0x1289, 0x12C9,
|
||||
0x1309, 0x1349, 0x1389, 0x13C9,
|
||||
0x1409, 0x1449, 0x14A9, 0x14E9,
|
||||
0x1529, 0x1569, 0x15A9, 0x15E9, /* 48 */
|
||||
0x1629, 0x1669, 0x16A9, 0x16E8,
|
||||
0x1728, 0x1768, 0x17A8, 0x17E8,
|
||||
0x1828, 0x1868, 0x18A8, 0x18E8,
|
||||
0x1928, 0x1968, 0x19A8, 0x19E8, /* 64 */
|
||||
0x1A28, 0x1A68, 0x1AA8, 0x1AE8,
|
||||
0x1B28, 0x1B68, 0x1BA8, 0x1BE8,
|
||||
0x1C28, 0x1C68, 0x1CA8, 0x1CE8,
|
||||
0x1D28, 0x1D68, 0x1DC8, 0x1E08, /* 80 */
|
||||
0x1E48, 0x1E88, 0x1EC8, 0x1F08,
|
||||
0x1F48, 0x1F88, 0x1FE8, 0x2028,
|
||||
0x2068, 0x20A8, 0x2108, 0x2148,
|
||||
0x2188, 0x21C8, 0x2228, 0x2268, /* 96 */
|
||||
0x22C8, 0x2308, 0x2348, 0x23A8,
|
||||
0x23E8, 0x2448, 0x24A8, 0x24E8,
|
||||
0x2548, 0x25A8, 0x2608, 0x2668,
|
||||
0x26C8, 0x2728, 0x2787, 0x27E7, /* 112 */
|
||||
0x2847, 0x28C7, 0x2947, 0x29A7,
|
||||
0x2A27, 0x2AC7, 0x2B47, 0x2BE7,
|
||||
0x2CA7, 0x2D67, 0x2E47, 0x2F67,
|
||||
0x3247, 0x3526, 0x3646, 0x3726, /* 128 */
|
||||
0x3806, 0x38A6, 0x3946, 0x39E6,
|
||||
0x3A66, 0x3AE6, 0x3B66, 0x3BC6,
|
||||
0x3C45, 0x3CA5, 0x3D05, 0x3D85,
|
||||
0x3DE5, 0x3E45, 0x3EA5, 0x3EE5, /* 144 */
|
||||
0x3F45, 0x3FA5, 0x4005, 0x4045,
|
||||
0x40A5, 0x40E5, 0x4145, 0x4185,
|
||||
0x41E5, 0x4225, 0x4265, 0x42C5,
|
||||
0x4305, 0x4345, 0x43A5, 0x43E5, /* 160 */
|
||||
0x4424, 0x4464, 0x44C4, 0x4504,
|
||||
0x4544, 0x4584, 0x45C4, 0x4604,
|
||||
0x4644, 0x46A4, 0x46E4, 0x4724,
|
||||
0x4764, 0x47A4, 0x47E4, 0x4824, /* 176 */
|
||||
0x4864, 0x48A4, 0x48E4, 0x4924,
|
||||
0x4964, 0x49A4, 0x49E4, 0x4A24,
|
||||
0x4A64, 0x4AA4, 0x4AE4, 0x4B23,
|
||||
0x4B63, 0x4BA3, 0x4BE3, 0x4C23, /* 192 */
|
||||
0x4C63, 0x4CA3, 0x4CE3, 0x4D23,
|
||||
0x4D63, 0x4DA3, 0x4DE3, 0x4E23,
|
||||
0x4E63, 0x4EA3, 0x4EE3, 0x4F23,
|
||||
0x4F63, 0x4FC3, 0x5003, 0x5043, /* 208 */
|
||||
0x5083, 0x50C3, 0x5103, 0x5143,
|
||||
0x5183, 0x51E2, 0x5222, 0x5262,
|
||||
0x52A2, 0x52E2, 0x5342, 0x5382,
|
||||
0x53C2, 0x5402, 0x5462, 0x54A2, /* 224 */
|
||||
0x5502, 0x5542, 0x55A2, 0x55E2,
|
||||
0x5642, 0x5682, 0x56E2, 0x5722,
|
||||
0x5782, 0x57E1, 0x5841, 0x58A1,
|
||||
0x5901, 0x5961, 0x59C1, 0x5A21, /* 240 */
|
||||
0x5AA1, 0x5B01, 0x5B81, 0x5BE1,
|
||||
0x5C61, 0x5D01, 0x5D80, 0x5E20,
|
||||
0x5EE0, 0x5FA0, 0x6080, 0x61C0,
|
||||
};
|
||||
|
||||
const u16 bcm43xx_ilt_noisea2[BCM43xx_ILT_NOISEA2_SIZE] = {
|
||||
0x0001, 0x0001, 0x0001, 0xFFFE,
|
||||
0xFFFE, 0x3FFF, 0x1000, 0x0393,
|
||||
};
|
||||
|
||||
const u16 bcm43xx_ilt_noisea3[BCM43xx_ILT_NOISEA3_SIZE] = {
|
||||
0x4C4C, 0x4C4C, 0x4C4C, 0x2D36,
|
||||
0x4C4C, 0x4C4C, 0x4C4C, 0x2D36,
|
||||
};
|
||||
|
||||
const u16 bcm43xx_ilt_noiseg1[BCM43xx_ILT_NOISEG1_SIZE] = {
|
||||
0x013C, 0x01F5, 0x031A, 0x0631,
|
||||
0x0001, 0x0001, 0x0001, 0x0001,
|
||||
};
|
||||
|
||||
const u16 bcm43xx_ilt_noiseg2[BCM43xx_ILT_NOISEG2_SIZE] = {
|
||||
0x5484, 0x3C40, 0x0000, 0x0000,
|
||||
0x0000, 0x0000, 0x0000, 0x0000,
|
||||
};
|
||||
|
||||
const u16 bcm43xx_ilt_noisescaleg1[BCM43xx_ILT_NOISESCALEG_SIZE] = {
|
||||
0x6C77, 0x5162, 0x3B40, 0x3335, /* 0 */
|
||||
0x2F2D, 0x2A2A, 0x2527, 0x1F21,
|
||||
0x1A1D, 0x1719, 0x1616, 0x1414,
|
||||
0x1414, 0x1400, 0x1414, 0x1614,
|
||||
0x1716, 0x1A19, 0x1F1D, 0x2521, /* 16 */
|
||||
0x2A27, 0x2F2A, 0x332D, 0x3B35,
|
||||
0x5140, 0x6C62, 0x0077,
|
||||
};
|
||||
|
||||
const u16 bcm43xx_ilt_noisescaleg2[BCM43xx_ILT_NOISESCALEG_SIZE] = {
|
||||
0xD8DD, 0xCBD4, 0xBCC0, 0XB6B7, /* 0 */
|
||||
0xB2B0, 0xADAD, 0xA7A9, 0x9FA1,
|
||||
0x969B, 0x9195, 0x8F8F, 0x8A8A,
|
||||
0x8A8A, 0x8A00, 0x8A8A, 0x8F8A,
|
||||
0x918F, 0x9695, 0x9F9B, 0xA7A1, /* 16 */
|
||||
0xADA9, 0xB2AD, 0xB6B0, 0xBCB7,
|
||||
0xCBC0, 0xD8D4, 0x00DD,
|
||||
};
|
||||
|
||||
const u16 bcm43xx_ilt_noisescaleg3[BCM43xx_ILT_NOISESCALEG_SIZE] = {
|
||||
0xA4A4, 0xA4A4, 0xA4A4, 0xA4A4, /* 0 */
|
||||
0xA4A4, 0xA4A4, 0xA4A4, 0xA4A4,
|
||||
0xA4A4, 0xA4A4, 0xA4A4, 0xA4A4,
|
||||
0xA4A4, 0xA400, 0xA4A4, 0xA4A4,
|
||||
0xA4A4, 0xA4A4, 0xA4A4, 0xA4A4, /* 16 */
|
||||
0xA4A4, 0xA4A4, 0xA4A4, 0xA4A4,
|
||||
0xA4A4, 0xA4A4, 0x00A4,
|
||||
};
|
||||
|
||||
const u16 bcm43xx_ilt_sigmasqr1[BCM43xx_ILT_SIGMASQR_SIZE] = {
|
||||
0x007A, 0x0075, 0x0071, 0x006C, /* 0 */
|
||||
0x0067, 0x0063, 0x005E, 0x0059,
|
||||
0x0054, 0x0050, 0x004B, 0x0046,
|
||||
0x0042, 0x003D, 0x003D, 0x003D,
|
||||
0x003D, 0x003D, 0x003D, 0x003D, /* 16 */
|
||||
0x003D, 0x003D, 0x003D, 0x003D,
|
||||
0x003D, 0x003D, 0x0000, 0x003D,
|
||||
0x003D, 0x003D, 0x003D, 0x003D,
|
||||
0x003D, 0x003D, 0x003D, 0x003D, /* 32 */
|
||||
0x003D, 0x003D, 0x003D, 0x003D,
|
||||
0x0042, 0x0046, 0x004B, 0x0050,
|
||||
0x0054, 0x0059, 0x005E, 0x0063,
|
||||
0x0067, 0x006C, 0x0071, 0x0075, /* 48 */
|
||||
0x007A,
|
||||
};
|
||||
|
||||
const u16 bcm43xx_ilt_sigmasqr2[BCM43xx_ILT_SIGMASQR_SIZE] = {
|
||||
0x00DE, 0x00DC, 0x00DA, 0x00D8, /* 0 */
|
||||
0x00D6, 0x00D4, 0x00D2, 0x00CF,
|
||||
0x00CD, 0x00CA, 0x00C7, 0x00C4,
|
||||
0x00C1, 0x00BE, 0x00BE, 0x00BE,
|
||||
0x00BE, 0x00BE, 0x00BE, 0x00BE, /* 16 */
|
||||
0x00BE, 0x00BE, 0x00BE, 0x00BE,
|
||||
0x00BE, 0x00BE, 0x0000, 0x00BE,
|
||||
0x00BE, 0x00BE, 0x00BE, 0x00BE,
|
||||
0x00BE, 0x00BE, 0x00BE, 0x00BE, /* 32 */
|
||||
0x00BE, 0x00BE, 0x00BE, 0x00BE,
|
||||
0x00C1, 0x00C4, 0x00C7, 0x00CA,
|
||||
0x00CD, 0x00CF, 0x00D2, 0x00D4,
|
||||
0x00D6, 0x00D8, 0x00DA, 0x00DC, /* 48 */
|
||||
0x00DE,
|
||||
};
|
||||
|
||||
/**** Helper functions to access the device Internal Lookup Tables ****/
|
||||
|
||||
void bcm43xx_ilt_write16(struct bcm43xx_private *bcm, u16 offset, u16 val)
|
||||
{
|
||||
if ( bcm->current_core->phy->type == BCM43xx_PHYTYPE_A ) {
|
||||
bcm43xx_phy_write(bcm, BCM43xx_PHY_ILT_A_CTRL, offset);
|
||||
bcm43xx_phy_write(bcm, BCM43xx_PHY_ILT_A_DATA1, val);
|
||||
} else {
|
||||
bcm43xx_phy_write(bcm, BCM43xx_PHY_ILT_G_CTRL, offset);
|
||||
bcm43xx_phy_write(bcm, BCM43xx_PHY_ILT_G_DATA1, val);
|
||||
}
|
||||
}
|
||||
|
||||
u16 bcm43xx_ilt_read16(struct bcm43xx_private *bcm, u16 offset)
|
||||
{
|
||||
if ( bcm->current_core->phy->type == BCM43xx_PHYTYPE_A ) {
|
||||
bcm43xx_phy_write(bcm, BCM43xx_PHY_ILT_A_CTRL, offset);
|
||||
return bcm43xx_phy_read(bcm, BCM43xx_PHY_ILT_A_DATA1);
|
||||
} else {
|
||||
bcm43xx_phy_write(bcm, BCM43xx_PHY_ILT_G_CTRL, offset);
|
||||
return bcm43xx_phy_read(bcm, BCM43xx_PHY_ILT_G_DATA1);
|
||||
}
|
||||
}
|
||||
|
||||
void bcm43xx_ilt_write32(struct bcm43xx_private *bcm, u16 offset, u32 val)
|
||||
{
|
||||
if ( bcm->current_core->phy->type == BCM43xx_PHYTYPE_A ) {
|
||||
bcm43xx_phy_write(bcm, BCM43xx_PHY_ILT_A_CTRL, offset);
|
||||
bcm43xx_phy_write(bcm, BCM43xx_PHY_ILT_A_DATA2, (u16)(val >> 16));
|
||||
bcm43xx_phy_write(bcm, BCM43xx_PHY_ILT_A_DATA1, (u16)(val & 0x0000FFFF));
|
||||
} else {
|
||||
bcm43xx_phy_write(bcm, BCM43xx_PHY_ILT_G_CTRL, offset);
|
||||
bcm43xx_phy_write(bcm, BCM43xx_PHY_ILT_G_DATA2, (u16)(val >> 16));
|
||||
bcm43xx_phy_write(bcm, BCM43xx_PHY_ILT_G_DATA1, (u16)(val & 0x0000FFFF));
|
||||
}
|
||||
}
|
||||
|
||||
u32 bcm43xx_ilt_read32(struct bcm43xx_private *bcm, u16 offset)
|
||||
{
|
||||
u32 ret;
|
||||
|
||||
if ( bcm->current_core->phy->type == BCM43xx_PHYTYPE_A ) {
|
||||
bcm43xx_phy_write(bcm, BCM43xx_PHY_ILT_A_CTRL, offset);
|
||||
ret = bcm43xx_phy_read(bcm, BCM43xx_PHY_ILT_A_DATA2);
|
||||
ret <<= 16;
|
||||
ret |= bcm43xx_phy_read(bcm, BCM43xx_PHY_ILT_A_DATA1);
|
||||
} else {
|
||||
bcm43xx_phy_write(bcm, BCM43xx_PHY_ILT_G_CTRL, offset);
|
||||
ret = bcm43xx_phy_read(bcm, BCM43xx_PHY_ILT_G_DATA2);
|
||||
ret <<= 16;
|
||||
ret |= bcm43xx_phy_read(bcm, BCM43xx_PHY_ILT_G_DATA1);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
34
drivers/net/wireless/bcm43xx/bcm43xx_ilt.h
Normal file
34
drivers/net/wireless/bcm43xx/bcm43xx_ilt.h
Normal file
@ -0,0 +1,34 @@
|
||||
#ifndef BCM43xx_ILT_H_
|
||||
#define BCM43xx_ILT_H_
|
||||
|
||||
#define BCM43xx_ILT_ROTOR_SIZE 53
|
||||
extern const u32 bcm43xx_ilt_rotor[BCM43xx_ILT_ROTOR_SIZE];
|
||||
#define BCM43xx_ILT_RETARD_SIZE 53
|
||||
extern const u32 bcm43xx_ilt_retard[BCM43xx_ILT_RETARD_SIZE];
|
||||
#define BCM43xx_ILT_FINEFREQA_SIZE 256
|
||||
extern const u16 bcm43xx_ilt_finefreqa[BCM43xx_ILT_FINEFREQA_SIZE];
|
||||
#define BCM43xx_ILT_FINEFREQG_SIZE 256
|
||||
extern const u16 bcm43xx_ilt_finefreqg[BCM43xx_ILT_FINEFREQG_SIZE];
|
||||
#define BCM43xx_ILT_NOISEA2_SIZE 8
|
||||
extern const u16 bcm43xx_ilt_noisea2[BCM43xx_ILT_NOISEA2_SIZE];
|
||||
#define BCM43xx_ILT_NOISEA3_SIZE 8
|
||||
extern const u16 bcm43xx_ilt_noisea3[BCM43xx_ILT_NOISEA3_SIZE];
|
||||
#define BCM43xx_ILT_NOISEG1_SIZE 8
|
||||
extern const u16 bcm43xx_ilt_noiseg1[BCM43xx_ILT_NOISEG1_SIZE];
|
||||
#define BCM43xx_ILT_NOISEG2_SIZE 8
|
||||
extern const u16 bcm43xx_ilt_noiseg2[BCM43xx_ILT_NOISEG2_SIZE];
|
||||
#define BCM43xx_ILT_NOISESCALEG_SIZE 27
|
||||
extern const u16 bcm43xx_ilt_noisescaleg1[BCM43xx_ILT_NOISESCALEG_SIZE];
|
||||
extern const u16 bcm43xx_ilt_noisescaleg2[BCM43xx_ILT_NOISESCALEG_SIZE];
|
||||
extern const u16 bcm43xx_ilt_noisescaleg3[BCM43xx_ILT_NOISESCALEG_SIZE];
|
||||
#define BCM43xx_ILT_SIGMASQR_SIZE 53
|
||||
extern const u16 bcm43xx_ilt_sigmasqr1[BCM43xx_ILT_SIGMASQR_SIZE];
|
||||
extern const u16 bcm43xx_ilt_sigmasqr2[BCM43xx_ILT_SIGMASQR_SIZE];
|
||||
|
||||
|
||||
void bcm43xx_ilt_write16(struct bcm43xx_private *bcm, u16 offset, u16 val);
|
||||
u16 bcm43xx_ilt_read16(struct bcm43xx_private *bcm, u16 offset);
|
||||
void bcm43xx_ilt_write32(struct bcm43xx_private *bcm, u16 offset, u32 val);
|
||||
u32 bcm43xx_ilt_read32(struct bcm43xx_private *bcm, u16 offset);
|
||||
|
||||
#endif /* BCM43xx_ILT_H_ */
|
261
drivers/net/wireless/bcm43xx/bcm43xx_leds.c
Normal file
261
drivers/net/wireless/bcm43xx/bcm43xx_leds.c
Normal file
@ -0,0 +1,261 @@
|
||||
/*
|
||||
|
||||
Broadcom BCM43xx wireless driver
|
||||
|
||||
Copyright (c) 2005 Martin Langer <martin-langer@gmx.de>,
|
||||
Stefano Brivio <st3@riseup.net>
|
||||
Michael Buesch <mbuesch@freenet.de>
|
||||
Danny van Dyk <kugelfang@gentoo.org>
|
||||
Andreas Jaggi <andreas.jaggi@waterwave.ch>
|
||||
|
||||
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.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
|
||||
*/
|
||||
|
||||
#include "bcm43xx_leds.h"
|
||||
#include "bcm43xx.h"
|
||||
|
||||
#include <asm/bitops.h>
|
||||
|
||||
|
||||
static void bcm43xx_led_changestate(struct bcm43xx_led *led)
|
||||
{
|
||||
struct bcm43xx_private *bcm = led->bcm;
|
||||
const int index = bcm43xx_led_index(led);
|
||||
u16 ledctl;
|
||||
|
||||
assert(index >= 0 && index < BCM43xx_NR_LEDS);
|
||||
assert(led->blink_interval);
|
||||
ledctl = bcm43xx_read16(bcm, BCM43xx_MMIO_GPIO_CONTROL);
|
||||
__change_bit(index, (unsigned long *)(&ledctl));
|
||||
bcm43xx_write16(bcm, BCM43xx_MMIO_GPIO_CONTROL, ledctl);
|
||||
}
|
||||
|
||||
static void bcm43xx_led_blink(unsigned long d)
|
||||
{
|
||||
struct bcm43xx_led *led = (struct bcm43xx_led *)d;
|
||||
struct bcm43xx_private *bcm = led->bcm;
|
||||
unsigned long flags;
|
||||
|
||||
spin_lock_irqsave(&bcm->lock, flags);
|
||||
if (led->blink_interval) {
|
||||
bcm43xx_led_changestate(led);
|
||||
mod_timer(&led->blink_timer, jiffies + led->blink_interval);
|
||||
}
|
||||
spin_unlock_irqrestore(&bcm->lock, flags);
|
||||
}
|
||||
|
||||
static void bcm43xx_led_blink_start(struct bcm43xx_led *led,
|
||||
unsigned long interval)
|
||||
{
|
||||
led->blink_interval = interval;
|
||||
bcm43xx_led_changestate(led);
|
||||
led->blink_timer.expires = jiffies + interval;
|
||||
add_timer(&led->blink_timer);
|
||||
}
|
||||
|
||||
static void bcm43xx_led_blink_stop(struct bcm43xx_led *led, int sync)
|
||||
{
|
||||
struct bcm43xx_private *bcm = led->bcm;
|
||||
const int index = bcm43xx_led_index(led);
|
||||
u16 ledctl;
|
||||
|
||||
if (!led->blink_interval)
|
||||
return;
|
||||
if (unlikely(sync))
|
||||
del_timer_sync(&led->blink_timer);
|
||||
else
|
||||
del_timer(&led->blink_timer);
|
||||
led->blink_interval = 0;
|
||||
|
||||
/* Make sure the LED is turned off. */
|
||||
assert(index >= 0 && index < BCM43xx_NR_LEDS);
|
||||
ledctl = bcm43xx_read16(bcm, BCM43xx_MMIO_GPIO_CONTROL);
|
||||
if (led->activelow)
|
||||
ledctl |= (1 << index);
|
||||
else
|
||||
ledctl &= ~(1 << index);
|
||||
bcm43xx_write16(bcm, BCM43xx_MMIO_GPIO_CONTROL, ledctl);
|
||||
}
|
||||
|
||||
int bcm43xx_leds_init(struct bcm43xx_private *bcm)
|
||||
{
|
||||
struct bcm43xx_led *led;
|
||||
u8 sprom[4];
|
||||
int i;
|
||||
|
||||
sprom[0] = bcm->sprom.wl0gpio0;
|
||||
sprom[1] = bcm->sprom.wl0gpio1;
|
||||
sprom[2] = bcm->sprom.wl0gpio2;
|
||||
sprom[3] = bcm->sprom.wl0gpio3;
|
||||
|
||||
for (i = 0; i < BCM43xx_NR_LEDS; i++) {
|
||||
led = &(bcm->leds[i]);
|
||||
led->bcm = bcm;
|
||||
init_timer(&led->blink_timer);
|
||||
led->blink_timer.data = (unsigned long)led;
|
||||
led->blink_timer.function = bcm43xx_led_blink;
|
||||
|
||||
if (sprom[i] == 0xFF) {
|
||||
/* SPROM information not set. */
|
||||
switch (i) {
|
||||
case 0:
|
||||
if (bcm->board_vendor == PCI_VENDOR_ID_COMPAQ)
|
||||
led->behaviour = BCM43xx_LED_RADIO_ALL;
|
||||
else
|
||||
led->behaviour = BCM43xx_LED_ACTIVITY;
|
||||
break;
|
||||
case 1:
|
||||
led->behaviour = BCM43xx_LED_RADIO_B;
|
||||
break;
|
||||
case 2:
|
||||
led->behaviour = BCM43xx_LED_RADIO_A;
|
||||
break;
|
||||
case 3:
|
||||
led->behaviour = BCM43xx_LED_OFF;
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
} else {
|
||||
led->behaviour = sprom[i] & BCM43xx_LED_BEHAVIOUR;
|
||||
led->activelow = !!(sprom[i] & BCM43xx_LED_ACTIVELOW);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void bcm43xx_leds_exit(struct bcm43xx_private *bcm)
|
||||
{
|
||||
struct bcm43xx_led *led;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < BCM43xx_NR_LEDS; i++) {
|
||||
led = &(bcm->leds[i]);
|
||||
bcm43xx_led_blink_stop(led, 1);
|
||||
}
|
||||
bcm43xx_leds_turn_off(bcm);
|
||||
}
|
||||
|
||||
void bcm43xx_leds_update(struct bcm43xx_private *bcm, int activity)
|
||||
{
|
||||
struct bcm43xx_led *led;
|
||||
struct bcm43xx_radioinfo *radio = bcm->current_core->radio;
|
||||
struct bcm43xx_phyinfo *phy = bcm->current_core->phy;
|
||||
const int transferring = (jiffies - bcm->stats.last_tx) < BCM43xx_LED_XFER_THRES;
|
||||
int i, turn_on = 0;
|
||||
unsigned long interval = 0;
|
||||
u16 ledctl;
|
||||
|
||||
ledctl = bcm43xx_read16(bcm, BCM43xx_MMIO_GPIO_CONTROL);
|
||||
for (i = 0; i < BCM43xx_NR_LEDS; i++) {
|
||||
led = &(bcm->leds[i]);
|
||||
if (led->behaviour == BCM43xx_LED_INACTIVE)
|
||||
continue;
|
||||
|
||||
switch (led->behaviour) {
|
||||
case BCM43xx_LED_OFF:
|
||||
turn_on = 0;
|
||||
break;
|
||||
case BCM43xx_LED_ON:
|
||||
turn_on = 1;
|
||||
break;
|
||||
case BCM43xx_LED_ACTIVITY:
|
||||
turn_on = activity;
|
||||
break;
|
||||
case BCM43xx_LED_RADIO_ALL:
|
||||
turn_on = radio->enabled;
|
||||
break;
|
||||
case BCM43xx_LED_RADIO_A:
|
||||
turn_on = (radio->enabled && phy->type == BCM43xx_PHYTYPE_A);
|
||||
break;
|
||||
case BCM43xx_LED_RADIO_B:
|
||||
turn_on = (radio->enabled &&
|
||||
(phy->type == BCM43xx_PHYTYPE_B ||
|
||||
phy->type == BCM43xx_PHYTYPE_G));
|
||||
break;
|
||||
case BCM43xx_LED_MODE_BG:
|
||||
turn_on = 0;
|
||||
if (phy->type == BCM43xx_PHYTYPE_G &&
|
||||
1/*FIXME: using G rates.*/)
|
||||
turn_on = 1;
|
||||
break;
|
||||
case BCM43xx_LED_TRANSFER:
|
||||
if (transferring)
|
||||
bcm43xx_led_blink_start(led, BCM43xx_LEDBLINK_MEDIUM);
|
||||
else
|
||||
bcm43xx_led_blink_stop(led, 0);
|
||||
continue;
|
||||
case BCM43xx_LED_APTRANSFER:
|
||||
if (bcm->ieee->iw_mode == IW_MODE_MASTER) {
|
||||
if (transferring) {
|
||||
interval = BCM43xx_LEDBLINK_FAST;
|
||||
turn_on = 1;
|
||||
}
|
||||
} else {
|
||||
turn_on = 1;
|
||||
if (0/*TODO: not assoc*/)
|
||||
interval = BCM43xx_LEDBLINK_SLOW;
|
||||
else if (transferring)
|
||||
interval = BCM43xx_LEDBLINK_FAST;
|
||||
else
|
||||
turn_on = 0;
|
||||
}
|
||||
if (turn_on)
|
||||
bcm43xx_led_blink_start(led, interval);
|
||||
else
|
||||
bcm43xx_led_blink_stop(led, 0);
|
||||
continue;
|
||||
case BCM43xx_LED_WEIRD:
|
||||
//TODO
|
||||
turn_on = 0;
|
||||
break;
|
||||
case BCM43xx_LED_ASSOC:
|
||||
if (1/*TODO: associated*/)
|
||||
turn_on = 1;
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
};
|
||||
|
||||
if (led->activelow)
|
||||
turn_on = !turn_on;
|
||||
if (turn_on)
|
||||
ledctl |= (1 << i);
|
||||
else
|
||||
ledctl &= ~(1 << i);
|
||||
}
|
||||
bcm43xx_write16(bcm, BCM43xx_MMIO_GPIO_CONTROL, ledctl);
|
||||
}
|
||||
|
||||
void bcm43xx_leds_turn_off(struct bcm43xx_private *bcm)
|
||||
{
|
||||
struct bcm43xx_led *led;
|
||||
u16 ledctl = 0;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < BCM43xx_NR_LEDS; i++) {
|
||||
led = &(bcm->leds[i]);
|
||||
if (led->behaviour == BCM43xx_LED_INACTIVE)
|
||||
continue;
|
||||
if (led->activelow)
|
||||
ledctl |= (1 << i);
|
||||
}
|
||||
bcm43xx_write16(bcm, BCM43xx_MMIO_GPIO_CONTROL, ledctl);
|
||||
}
|
||||
|
||||
/* vim: set ts=8 sw=8 sts=8: */
|
47
drivers/net/wireless/bcm43xx/bcm43xx_leds.h
Normal file
47
drivers/net/wireless/bcm43xx/bcm43xx_leds.h
Normal file
@ -0,0 +1,47 @@
|
||||
#ifndef BCM43xx_LEDS_H_
|
||||
#define BCM43xx_LEDS_H_
|
||||
|
||||
#include <linux/types.h>
|
||||
#include <linux/timer.h>
|
||||
|
||||
|
||||
struct bcm43xx_led {
|
||||
u8 behaviour:7;
|
||||
u8 activelow:1;
|
||||
|
||||
struct bcm43xx_private *bcm;
|
||||
struct timer_list blink_timer;
|
||||
unsigned long blink_interval;
|
||||
};
|
||||
#define bcm43xx_led_index(led) ((int)((led) - (led)->bcm->leds))
|
||||
|
||||
/* Delay between state changes when blinking in jiffies */
|
||||
#define BCM43xx_LEDBLINK_SLOW (HZ / 2)
|
||||
#define BCM43xx_LEDBLINK_MEDIUM (HZ / 4)
|
||||
#define BCM43xx_LEDBLINK_FAST (HZ / 8)
|
||||
|
||||
#define BCM43xx_LED_XFER_THRES (HZ / 100)
|
||||
|
||||
#define BCM43xx_LED_BEHAVIOUR 0x7F
|
||||
#define BCM43xx_LED_ACTIVELOW 0x80
|
||||
enum { /* LED behaviour values */
|
||||
BCM43xx_LED_OFF,
|
||||
BCM43xx_LED_ON,
|
||||
BCM43xx_LED_ACTIVITY,
|
||||
BCM43xx_LED_RADIO_ALL,
|
||||
BCM43xx_LED_RADIO_A,
|
||||
BCM43xx_LED_RADIO_B,
|
||||
BCM43xx_LED_MODE_BG,
|
||||
BCM43xx_LED_TRANSFER,
|
||||
BCM43xx_LED_APTRANSFER,
|
||||
BCM43xx_LED_WEIRD,//FIXME
|
||||
BCM43xx_LED_ASSOC,
|
||||
BCM43xx_LED_INACTIVE,
|
||||
};
|
||||
|
||||
int bcm43xx_leds_init(struct bcm43xx_private *bcm);
|
||||
void bcm43xx_leds_exit(struct bcm43xx_private *bcm);
|
||||
void bcm43xx_leds_update(struct bcm43xx_private *bcm, int activity);
|
||||
void bcm43xx_leds_turn_off(struct bcm43xx_private *bcm);
|
||||
|
||||
#endif /* BCM43xx_LEDS_H_ */
|
4597
drivers/net/wireless/bcm43xx/bcm43xx_main.c
Normal file
4597
drivers/net/wireless/bcm43xx/bcm43xx_main.c
Normal file
File diff suppressed because it is too large
Load Diff
283
drivers/net/wireless/bcm43xx/bcm43xx_main.h
Normal file
283
drivers/net/wireless/bcm43xx/bcm43xx_main.h
Normal file
@ -0,0 +1,283 @@
|
||||
/*
|
||||
|
||||
Broadcom BCM43xx wireless driver
|
||||
|
||||
Copyright (c) 2005 Martin Langer <martin-langer@gmx.de>,
|
||||
Stefano Brivio <st3@riseup.net>
|
||||
Michael Buesch <mbuesch@freenet.de>
|
||||
Danny van Dyk <kugelfang@gentoo.org>
|
||||
Andreas Jaggi <andreas.jaggi@waterwave.ch>
|
||||
|
||||
Some parts of the code in this file are derived from the ipw2200
|
||||
driver Copyright(c) 2003 - 2004 Intel Corporation.
|
||||
|
||||
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.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef BCM43xx_MAIN_H_
|
||||
#define BCM43xx_MAIN_H_
|
||||
|
||||
#include "bcm43xx.h"
|
||||
|
||||
#ifdef CONFIG_BCM947XX
|
||||
#define atoi(str) simple_strtoul(((str != NULL) ? str : ""), NULL, 0)
|
||||
|
||||
static inline void e_aton(char *str, char *dest)
|
||||
{
|
||||
int i = 0;
|
||||
u16 *d = (u16 *) dest;
|
||||
|
||||
for (;;) {
|
||||
dest[i++] = (char) simple_strtoul(str, NULL, 16);
|
||||
str += 2;
|
||||
if (!*str++ || i == 6)
|
||||
break;
|
||||
}
|
||||
for (i = 0; i < 3; i++)
|
||||
d[i] = cpu_to_be16(d[i]);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#define _bcm43xx_declare_plcp_hdr(size) \
|
||||
struct bcm43xx_plcp_hdr##size { \
|
||||
union { \
|
||||
__le32 data; \
|
||||
__u8 raw[size]; \
|
||||
} __attribute__((__packed__)); \
|
||||
} __attribute__((__packed__))
|
||||
|
||||
/* struct bcm43xx_plcp_hdr4 */
|
||||
_bcm43xx_declare_plcp_hdr(4);
|
||||
/* struct bcm430c_plcp_hdr6 */
|
||||
_bcm43xx_declare_plcp_hdr(6);
|
||||
|
||||
#undef _bcm43xx_declare_plcp_hdr
|
||||
|
||||
|
||||
#define P4D_BYT3S(magic, nr_bytes) u8 __p4dding##magic[nr_bytes]
|
||||
#define P4D_BYTES(line, nr_bytes) P4D_BYT3S(line, nr_bytes)
|
||||
/* Magic helper macro to pad structures. Ignore those above. It's magic. */
|
||||
#define PAD_BYTES(nr_bytes) P4D_BYTES( __LINE__ , (nr_bytes))
|
||||
|
||||
|
||||
/* Device specific TX header. To be prepended to TX frames. */
|
||||
struct bcm43xx_txhdr {
|
||||
union {
|
||||
struct {
|
||||
u16 flags;
|
||||
u16 wsec_rate;
|
||||
u16 frame_control;
|
||||
u16 unknown_zeroed_0;
|
||||
u16 control;
|
||||
unsigned char wep_iv[10];
|
||||
unsigned char unknown_wsec_tkip_data[3]; //FIXME
|
||||
PAD_BYTES(3);
|
||||
unsigned char mac1[6];
|
||||
u16 unknown_zeroed_1;
|
||||
struct bcm43xx_plcp_hdr4 rts_cts_fallback_plcp;
|
||||
u16 rts_cts_dur_fallback;
|
||||
struct bcm43xx_plcp_hdr4 fallback_plcp;
|
||||
u16 fallback_dur_id;
|
||||
PAD_BYTES(2);
|
||||
u16 cookie;
|
||||
u16 unknown_scb_stuff; //FIXME
|
||||
struct bcm43xx_plcp_hdr6 rts_cts_plcp;
|
||||
u16 rts_cts_frame_type;
|
||||
u16 rts_cts_dur;
|
||||
unsigned char rts_cts_mac1[6];
|
||||
unsigned char rts_cts_mac2[6];
|
||||
PAD_BYTES(2);
|
||||
struct bcm43xx_plcp_hdr6 plcp;
|
||||
} __attribute__((__packed__));
|
||||
|
||||
unsigned char raw[82];
|
||||
} __attribute__((__packed__));
|
||||
} __attribute__((__packed__));
|
||||
|
||||
struct sk_buff;
|
||||
|
||||
void FASTCALL(bcm43xx_generate_txhdr(struct bcm43xx_private *bcm,
|
||||
struct bcm43xx_txhdr *txhdr,
|
||||
const unsigned char *fragment_data,
|
||||
const unsigned int fragment_len,
|
||||
const int is_first_fragment,
|
||||
const u16 cookie));
|
||||
|
||||
/* RX header as received from the hardware. */
|
||||
struct bcm43xx_rxhdr {
|
||||
/* Frame Length. Must be generated explicitely in PIO mode. */
|
||||
__le16 frame_length;
|
||||
PAD_BYTES(2);
|
||||
/* Flags field 1 */
|
||||
__le16 flags1;
|
||||
u8 rssi;
|
||||
u8 signal_quality;
|
||||
PAD_BYTES(2);
|
||||
/* Flags field 3 */
|
||||
__le16 flags3;
|
||||
/* Flags field 2 */
|
||||
__le16 flags2;
|
||||
/* Lower 16bits of the TSF at the time the frame started. */
|
||||
__le16 mactime;
|
||||
PAD_BYTES(14);
|
||||
} __attribute__((__packed__));
|
||||
|
||||
#define BCM43xx_RXHDR_FLAGS1_OFDM (1 << 0)
|
||||
/*#define BCM43xx_RXHDR_FLAGS1_SIGNAL??? (1 << 3) FIXME */
|
||||
#define BCM43xx_RXHDR_FLAGS1_SHORTPREAMBLE (1 << 7)
|
||||
#define BCM43xx_RXHDR_FLAGS1_2053RSSIADJ (1 << 14)
|
||||
|
||||
#define BCM43xx_RXHDR_FLAGS2_INVALIDFRAME (1 << 0)
|
||||
#define BCM43xx_RXHDR_FLAGS2_TYPE2FRAME (1 << 2)
|
||||
/*FIXME: WEP related flags */
|
||||
|
||||
#define BCM43xx_RXHDR_FLAGS3_2050RSSIADJ (1 << 10)
|
||||
|
||||
/* Transmit Status as received from the hardware. */
|
||||
struct bcm43xx_hwxmitstatus {
|
||||
PAD_BYTES(4);
|
||||
__le16 cookie;
|
||||
u8 flags;
|
||||
u8 cnt1:4,
|
||||
cnt2:4;
|
||||
PAD_BYTES(2);
|
||||
__le16 seq;
|
||||
__le16 unknown; //FIXME
|
||||
} __attribute__((__packed__));
|
||||
|
||||
/* Transmit Status in CPU byteorder. */
|
||||
struct bcm43xx_xmitstatus {
|
||||
u16 cookie;
|
||||
u8 flags;
|
||||
u8 cnt1:4,
|
||||
cnt2:4;
|
||||
u16 seq;
|
||||
u16 unknown; //FIXME
|
||||
};
|
||||
|
||||
#define BCM43xx_TXSTAT_FLAG_ACK 0x01
|
||||
//TODO #define BCM43xx_TXSTAT_FLAG_??? 0x02
|
||||
//TODO #define BCM43xx_TXSTAT_FLAG_??? 0x04
|
||||
//TODO #define BCM43xx_TXSTAT_FLAG_??? 0x08
|
||||
//TODO #define BCM43xx_TXSTAT_FLAG_??? 0x10
|
||||
#define BCM43xx_TXSTAT_FLAG_IGNORE 0x20
|
||||
//TODO #define BCM43xx_TXSTAT_FLAG_??? 0x40
|
||||
//TODO #define BCM43xx_TXSTAT_FLAG_??? 0x80
|
||||
|
||||
struct bcm43xx_xmitstatus_queue {
|
||||
struct list_head list;
|
||||
struct bcm43xx_hwxmitstatus status;
|
||||
};
|
||||
|
||||
|
||||
/* Lightweight function to convert a frequency (in Mhz) to a channel number. */
|
||||
static inline
|
||||
u8 bcm43xx_freq_to_channel(struct bcm43xx_private *bcm,
|
||||
int freq)
|
||||
{
|
||||
u8 channel;
|
||||
|
||||
if (bcm->current_core->phy->type == BCM43xx_PHYTYPE_A) {
|
||||
channel = (freq - 5000) / 5;
|
||||
} else {
|
||||
if (freq == 2484)
|
||||
channel = 14;
|
||||
else
|
||||
channel = (freq - 2407) / 5;
|
||||
}
|
||||
|
||||
return channel;
|
||||
}
|
||||
|
||||
/* Lightweight function to convert a channel number to a frequency (in Mhz). */
|
||||
static inline
|
||||
int bcm43xx_channel_to_freq(struct bcm43xx_private *bcm,
|
||||
u8 channel)
|
||||
{
|
||||
int freq;
|
||||
|
||||
if (bcm->current_core->phy->type == BCM43xx_PHYTYPE_A) {
|
||||
freq = 5000 + (5 * channel);
|
||||
} else {
|
||||
if (channel == 14)
|
||||
freq = 2484;
|
||||
else
|
||||
freq = 2407 + (5 * channel);
|
||||
}
|
||||
|
||||
return freq;
|
||||
}
|
||||
|
||||
/* Lightweight function to check if a channel number is valid.
|
||||
* Note that this does _NOT_ check for geographical restrictions!
|
||||
*/
|
||||
static inline
|
||||
int bcm43xx_is_valid_channel(struct bcm43xx_private *bcm,
|
||||
u8 channel)
|
||||
{
|
||||
if (bcm->current_core->phy->type == BCM43xx_PHYTYPE_A) {
|
||||
if (channel <= 200)
|
||||
return 1;
|
||||
} else {
|
||||
if (channel >= 1 && channel <= 14)
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void bcm43xx_tsf_read(struct bcm43xx_private *bcm, u64 *tsf);
|
||||
void bcm43xx_tsf_write(struct bcm43xx_private *bcm, u64 tsf);
|
||||
|
||||
int FASTCALL(bcm43xx_rx(struct bcm43xx_private *bcm,
|
||||
struct sk_buff *skb,
|
||||
struct bcm43xx_rxhdr *rxhdr));
|
||||
|
||||
void bcm43xx_set_iwmode(struct bcm43xx_private *bcm,
|
||||
int iw_mode);
|
||||
|
||||
u32 bcm43xx_shm_read32(struct bcm43xx_private *bcm,
|
||||
u16 routing, u16 offset);
|
||||
u16 bcm43xx_shm_read16(struct bcm43xx_private *bcm,
|
||||
u16 routing, u16 offset);
|
||||
void bcm43xx_shm_write32(struct bcm43xx_private *bcm,
|
||||
u16 routing, u16 offset,
|
||||
u32 value);
|
||||
void bcm43xx_shm_write16(struct bcm43xx_private *bcm,
|
||||
u16 routing, u16 offset,
|
||||
u16 value);
|
||||
|
||||
void bcm43xx_dummy_transmission(struct bcm43xx_private *bcm);
|
||||
|
||||
int bcm43xx_switch_core(struct bcm43xx_private *bcm, struct bcm43xx_coreinfo *new_core);
|
||||
|
||||
void bcm43xx_wireless_core_reset(struct bcm43xx_private *bcm, int connect_phy);
|
||||
|
||||
int bcm43xx_pci_read_config_16(struct pci_dev *pdev, u16 offset, u16 *val);
|
||||
int bcm43xx_pci_read_config_32(struct pci_dev *pdev, u16 offset, u32 *val);
|
||||
int bcm43xx_pci_write_config_16(struct pci_dev *pdev, int offset, u16 val);
|
||||
int bcm43xx_pci_write_config_32(struct pci_dev *pdev, int offset, u32 val);
|
||||
|
||||
void bcm43xx_mac_suspend(struct bcm43xx_private *bcm);
|
||||
void bcm43xx_mac_enable(struct bcm43xx_private *bcm);
|
||||
|
||||
u8 bcm43xx_sprom_crc(const u16 *sprom);
|
||||
|
||||
void bcm43xx_controller_restart(struct bcm43xx_private *bcm, const char *reason);
|
||||
|
||||
#endif /* BCM43xx_MAIN_H_ */
|
2122
drivers/net/wireless/bcm43xx/bcm43xx_phy.c
Normal file
2122
drivers/net/wireless/bcm43xx/bcm43xx_phy.c
Normal file
File diff suppressed because it is too large
Load Diff
74
drivers/net/wireless/bcm43xx/bcm43xx_phy.h
Normal file
74
drivers/net/wireless/bcm43xx/bcm43xx_phy.h
Normal file
@ -0,0 +1,74 @@
|
||||
/*
|
||||
|
||||
Broadcom BCM43xx wireless driver
|
||||
|
||||
Copyright (c) 2005 Martin Langer <martin-langer@gmx.de>,
|
||||
Stefano Brivio <st3@riseup.net>
|
||||
Michael Buesch <mbuesch@freenet.de>
|
||||
Danny van Dyk <kugelfang@gentoo.org>
|
||||
Andreas Jaggi <andreas.jaggi@waterwave.ch>
|
||||
|
||||
Some parts of the code in this file are derived from the ipw2200
|
||||
driver Copyright(c) 2003 - 2004 Intel Corporation.
|
||||
|
||||
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.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef BCM43xx_PHY_H_
|
||||
#define BCM43xx_PHY_H_
|
||||
|
||||
#include <linux/types.h>
|
||||
|
||||
struct bcm43xx_private;
|
||||
|
||||
void bcm43xx_raw_phy_lock(struct bcm43xx_private *bcm);
|
||||
#define bcm43xx_phy_lock(bcm, flags) \
|
||||
do { \
|
||||
local_irq_save(flags); \
|
||||
bcm43xx_raw_phy_lock(bcm); \
|
||||
} while (0)
|
||||
void bcm43xx_raw_phy_unlock(struct bcm43xx_private *bcm);
|
||||
#define bcm43xx_phy_unlock(bcm, flags) \
|
||||
do { \
|
||||
bcm43xx_raw_phy_unlock(bcm); \
|
||||
local_irq_restore(flags); \
|
||||
} while (0)
|
||||
|
||||
u16 bcm43xx_phy_read(struct bcm43xx_private *bcm, u16 offset);
|
||||
void bcm43xx_phy_write(struct bcm43xx_private *bcm, u16 offset, u16 val);
|
||||
|
||||
int bcm43xx_phy_init_tssi2dbm_table(struct bcm43xx_private *bcm);
|
||||
int bcm43xx_phy_init(struct bcm43xx_private *bcm);
|
||||
|
||||
void bcm43xx_phy_set_antenna_diversity(struct bcm43xx_private *bcm);
|
||||
void bcm43xx_phy_calibrate(struct bcm43xx_private *bcm);
|
||||
int bcm43xx_phy_connect(struct bcm43xx_private *bcm, int connect);
|
||||
|
||||
void bcm43xx_phy_lo_b_measure(struct bcm43xx_private *bcm);
|
||||
void bcm43xx_phy_lo_g_measure(struct bcm43xx_private *bcm);
|
||||
void bcm43xx_phy_xmitpower(struct bcm43xx_private *bcm);
|
||||
|
||||
/* Adjust the LocalOscillator to the saved values.
|
||||
* "fixed" is only set to 1 once in initialization. Set to 0 otherwise.
|
||||
*/
|
||||
void bcm43xx_phy_lo_adjust(struct bcm43xx_private *bcm, int fixed);
|
||||
void bcm43xx_phy_lo_mark_all_unused(struct bcm43xx_private *bcm);
|
||||
|
||||
void bcm43xx_phy_set_baseband_attenuation(struct bcm43xx_private *bcm,
|
||||
u16 baseband_attenuation);
|
||||
|
||||
#endif /* BCM43xx_PHY_H_ */
|
592
drivers/net/wireless/bcm43xx/bcm43xx_pio.c
Normal file
592
drivers/net/wireless/bcm43xx/bcm43xx_pio.c
Normal file
@ -0,0 +1,592 @@
|
||||
/*
|
||||
|
||||
Broadcom BCM43xx wireless driver
|
||||
|
||||
PIO Transmission
|
||||
|
||||
Copyright (c) 2005 Michael Buesch <mbuesch@freenet.de>
|
||||
|
||||
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.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
|
||||
*/
|
||||
|
||||
#include "bcm43xx.h"
|
||||
#include "bcm43xx_pio.h"
|
||||
#include "bcm43xx_main.h"
|
||||
|
||||
#include <linux/delay.h>
|
||||
|
||||
|
||||
static inline
|
||||
u16 bcm43xx_pio_read(struct bcm43xx_pioqueue *queue,
|
||||
u16 offset)
|
||||
{
|
||||
return bcm43xx_read16(queue->bcm, queue->mmio_base + offset);
|
||||
}
|
||||
|
||||
static inline
|
||||
void bcm43xx_pio_write(struct bcm43xx_pioqueue *queue,
|
||||
u16 offset, u16 value)
|
||||
{
|
||||
bcm43xx_write16(queue->bcm, queue->mmio_base + offset, value);
|
||||
}
|
||||
|
||||
static inline
|
||||
void tx_start(struct bcm43xx_pioqueue *queue)
|
||||
{
|
||||
bcm43xx_pio_write(queue, BCM43xx_PIO_TXCTL, BCM43xx_PIO_TXCTL_INIT);
|
||||
}
|
||||
|
||||
static inline
|
||||
void tx_octet(struct bcm43xx_pioqueue *queue,
|
||||
u8 octet)
|
||||
{
|
||||
if (queue->bcm->current_core->rev < 3) {
|
||||
bcm43xx_pio_write(queue, BCM43xx_PIO_TXDATA, octet);
|
||||
bcm43xx_pio_write(queue, BCM43xx_PIO_TXCTL, BCM43xx_PIO_TXCTL_WRITEHI);
|
||||
} else {
|
||||
bcm43xx_pio_write(queue, BCM43xx_PIO_TXCTL, BCM43xx_PIO_TXCTL_WRITEHI);
|
||||
bcm43xx_pio_write(queue, BCM43xx_PIO_TXDATA, octet);
|
||||
}
|
||||
}
|
||||
|
||||
static inline
|
||||
void tx_data(struct bcm43xx_pioqueue *queue,
|
||||
u8 *packet,
|
||||
unsigned int octets)
|
||||
{
|
||||
u16 data;
|
||||
unsigned int i = 0;
|
||||
|
||||
if (queue->bcm->current_core->rev < 3) {
|
||||
data = be16_to_cpu( *((u16 *)packet) );
|
||||
bcm43xx_pio_write(queue, BCM43xx_PIO_TXDATA, data);
|
||||
i += 2;
|
||||
}
|
||||
bcm43xx_pio_write(queue, BCM43xx_PIO_TXCTL,
|
||||
BCM43xx_PIO_TXCTL_WRITELO | BCM43xx_PIO_TXCTL_WRITEHI);
|
||||
for ( ; i < octets - 1; i += 2) {
|
||||
data = be16_to_cpu( *((u16 *)(packet + i)) );
|
||||
bcm43xx_pio_write(queue, BCM43xx_PIO_TXDATA, data);
|
||||
}
|
||||
if (octets % 2)
|
||||
tx_octet(queue, packet[octets - 1]);
|
||||
}
|
||||
|
||||
static inline
|
||||
void tx_complete(struct bcm43xx_pioqueue *queue,
|
||||
struct sk_buff *skb)
|
||||
{
|
||||
u16 data;
|
||||
|
||||
if (queue->bcm->current_core->rev < 3) {
|
||||
data = be16_to_cpu( *((u16 *)(skb->data + skb->len - 2)) );
|
||||
bcm43xx_pio_write(queue, BCM43xx_PIO_TXDATA, data);
|
||||
bcm43xx_pio_write(queue, BCM43xx_PIO_TXCTL,
|
||||
BCM43xx_PIO_TXCTL_WRITEHI | BCM43xx_PIO_TXCTL_COMPLETE);
|
||||
} else {
|
||||
bcm43xx_pio_write(queue, BCM43xx_PIO_TXCTL, BCM43xx_PIO_TXCTL_COMPLETE);
|
||||
}
|
||||
}
|
||||
|
||||
static inline
|
||||
u16 generate_cookie(struct bcm43xx_pioqueue *queue,
|
||||
int packetindex)
|
||||
{
|
||||
u16 cookie = 0x0000;
|
||||
|
||||
/* We use the upper 4 bits for the PIO
|
||||
* controller ID and the lower 12 bits
|
||||
* for the packet index (in the cache).
|
||||
*/
|
||||
switch (queue->mmio_base) {
|
||||
default:
|
||||
assert(0);
|
||||
case BCM43xx_MMIO_PIO1_BASE:
|
||||
break;
|
||||
case BCM43xx_MMIO_PIO2_BASE:
|
||||
cookie = 0x1000;
|
||||
break;
|
||||
case BCM43xx_MMIO_PIO3_BASE:
|
||||
cookie = 0x2000;
|
||||
break;
|
||||
case BCM43xx_MMIO_PIO4_BASE:
|
||||
cookie = 0x3000;
|
||||
break;
|
||||
}
|
||||
assert(((u16)packetindex & 0xF000) == 0x0000);
|
||||
cookie |= (u16)packetindex;
|
||||
|
||||
return cookie;
|
||||
}
|
||||
|
||||
static inline
|
||||
struct bcm43xx_pioqueue * parse_cookie(struct bcm43xx_private *bcm,
|
||||
u16 cookie,
|
||||
struct bcm43xx_pio_txpacket **packet)
|
||||
{
|
||||
struct bcm43xx_pioqueue *queue = NULL;
|
||||
int packetindex;
|
||||
|
||||
switch (cookie & 0xF000) {
|
||||
case 0x0000:
|
||||
queue = bcm->current_core->pio->queue0;
|
||||
break;
|
||||
case 0x1000:
|
||||
queue = bcm->current_core->pio->queue1;
|
||||
break;
|
||||
case 0x2000:
|
||||
queue = bcm->current_core->pio->queue2;
|
||||
break;
|
||||
case 0x3000:
|
||||
queue = bcm->current_core->pio->queue3;
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
|
||||
packetindex = (cookie & 0x0FFF);
|
||||
assert(packetindex >= 0 && packetindex < BCM43xx_PIO_MAXTXPACKETS);
|
||||
*packet = queue->__tx_packets_cache + packetindex;
|
||||
|
||||
return queue;
|
||||
}
|
||||
|
||||
static inline
|
||||
void pio_tx_write_fragment(struct bcm43xx_pioqueue *queue,
|
||||
struct sk_buff *skb,
|
||||
struct bcm43xx_pio_txpacket *packet)
|
||||
{
|
||||
unsigned int octets;
|
||||
|
||||
assert(skb_shinfo(skb)->nr_frags == 0);
|
||||
assert(skb_headroom(skb) >= sizeof(struct bcm43xx_txhdr));
|
||||
|
||||
__skb_push(skb, sizeof(struct bcm43xx_txhdr));
|
||||
bcm43xx_generate_txhdr(queue->bcm,
|
||||
(struct bcm43xx_txhdr *)skb->data,
|
||||
skb->data + sizeof(struct bcm43xx_txhdr),
|
||||
skb->len - sizeof(struct bcm43xx_txhdr),
|
||||
(packet->xmitted_frags == 0),
|
||||
generate_cookie(queue, pio_txpacket_getindex(packet)));
|
||||
|
||||
tx_start(queue);
|
||||
octets = skb->len;
|
||||
if (queue->bcm->current_core->rev < 3) //FIXME: && this is the last packet in the queue.
|
||||
octets -= 2;
|
||||
tx_data(queue, (u8 *)skb->data, octets);
|
||||
tx_complete(queue, skb);
|
||||
}
|
||||
|
||||
static inline
|
||||
int pio_tx_packet(struct bcm43xx_pio_txpacket *packet)
|
||||
{
|
||||
struct bcm43xx_pioqueue *queue = packet->queue;
|
||||
struct ieee80211_txb *txb = packet->txb;
|
||||
struct sk_buff *skb;
|
||||
u16 octets;
|
||||
int i;
|
||||
|
||||
for (i = packet->xmitted_frags; i < txb->nr_frags; i++) {
|
||||
skb = txb->fragments[i];
|
||||
|
||||
octets = (u16)skb->len + sizeof(struct bcm43xx_txhdr);
|
||||
|
||||
assert(queue->tx_devq_size >= octets);
|
||||
assert(queue->tx_devq_packets <= BCM43xx_PIO_MAXTXDEVQPACKETS);
|
||||
assert(queue->tx_devq_used <= queue->tx_devq_size);
|
||||
/* Check if there is sufficient free space on the device
|
||||
* TX queue. If not, return and let the TX-work-handler
|
||||
* retry later.
|
||||
*/
|
||||
if (queue->tx_devq_packets == BCM43xx_PIO_MAXTXDEVQPACKETS)
|
||||
return -EBUSY;
|
||||
if (queue->tx_devq_used + octets > queue->tx_devq_size)
|
||||
return -EBUSY;
|
||||
/* Now poke the device. */
|
||||
pio_tx_write_fragment(queue, skb, packet);
|
||||
|
||||
/* Account for the packet size.
|
||||
* (We must not overflow the device TX queue)
|
||||
*/
|
||||
queue->tx_devq_packets++;
|
||||
queue->tx_devq_used += octets;
|
||||
|
||||
assert(packet->xmitted_frags <= packet->txb->nr_frags);
|
||||
packet->xmitted_frags++;
|
||||
packet->xmitted_octets += octets;
|
||||
}
|
||||
list_move_tail(&packet->list, &queue->txrunning);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void free_txpacket(struct bcm43xx_pio_txpacket *packet)
|
||||
{
|
||||
struct bcm43xx_pioqueue *queue = packet->queue;
|
||||
|
||||
ieee80211_txb_free(packet->txb);
|
||||
|
||||
list_move(&packet->list, &packet->queue->txfree);
|
||||
|
||||
assert(queue->tx_devq_used >= packet->xmitted_octets);
|
||||
queue->tx_devq_used -= packet->xmitted_octets;
|
||||
assert(queue->tx_devq_packets >= packet->xmitted_frags);
|
||||
queue->tx_devq_packets -= packet->xmitted_frags;
|
||||
}
|
||||
|
||||
static void txwork_handler(void *d)
|
||||
{
|
||||
struct bcm43xx_pioqueue *queue = d;
|
||||
unsigned long flags;
|
||||
struct bcm43xx_pio_txpacket *packet, *tmp_packet;
|
||||
int err;
|
||||
|
||||
spin_lock_irqsave(&queue->txlock, flags);
|
||||
list_for_each_entry_safe(packet, tmp_packet, &queue->txqueue, list) {
|
||||
assert(packet->xmitted_frags < packet->txb->nr_frags);
|
||||
if (packet->xmitted_frags == 0) {
|
||||
int i;
|
||||
struct sk_buff *skb;
|
||||
|
||||
/* Check if the device queue is big
|
||||
* enough for every fragment. If not, drop the
|
||||
* whole packet.
|
||||
*/
|
||||
for (i = 0; i < packet->txb->nr_frags; i++) {
|
||||
skb = packet->txb->fragments[i];
|
||||
if (unlikely(skb->len > queue->tx_devq_size)) {
|
||||
dprintkl(KERN_ERR PFX "PIO TX device queue too small. "
|
||||
"Dropping packet...\n");
|
||||
free_txpacket(packet);
|
||||
goto next_packet;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Now try to transmit the packet.
|
||||
* This may not completely succeed.
|
||||
*/
|
||||
err = pio_tx_packet(packet);
|
||||
if (err)
|
||||
break;
|
||||
next_packet:
|
||||
continue;
|
||||
}
|
||||
spin_unlock_irqrestore(&queue->txlock, flags);
|
||||
}
|
||||
|
||||
static void setup_txqueues(struct bcm43xx_pioqueue *queue)
|
||||
{
|
||||
struct bcm43xx_pio_txpacket *packet;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < BCM43xx_PIO_MAXTXPACKETS; i++) {
|
||||
packet = queue->__tx_packets_cache + i;
|
||||
|
||||
packet->queue = queue;
|
||||
INIT_LIST_HEAD(&packet->list);
|
||||
|
||||
list_add(&packet->list, &queue->txfree);
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
struct bcm43xx_pioqueue * bcm43xx_setup_pioqueue(struct bcm43xx_private *bcm,
|
||||
u16 pio_mmio_base)
|
||||
{
|
||||
struct bcm43xx_pioqueue *queue;
|
||||
u32 value;
|
||||
u16 qsize;
|
||||
|
||||
queue = kmalloc(sizeof(*queue), GFP_KERNEL);
|
||||
if (!queue)
|
||||
goto out;
|
||||
memset(queue, 0, sizeof(*queue));
|
||||
|
||||
queue->bcm = bcm;
|
||||
queue->mmio_base = pio_mmio_base;
|
||||
|
||||
INIT_LIST_HEAD(&queue->txfree);
|
||||
INIT_LIST_HEAD(&queue->txqueue);
|
||||
INIT_LIST_HEAD(&queue->txrunning);
|
||||
spin_lock_init(&queue->txlock);
|
||||
INIT_WORK(&queue->txwork, txwork_handler, queue);
|
||||
|
||||
value = bcm43xx_read32(bcm, BCM43xx_MMIO_STATUS_BITFIELD);
|
||||
value |= BCM43xx_SBF_XFER_REG_BYTESWAP;
|
||||
bcm43xx_write32(bcm, BCM43xx_MMIO_STATUS_BITFIELD, value);
|
||||
|
||||
qsize = bcm43xx_read16(bcm, queue->mmio_base + BCM43xx_PIO_TXQBUFSIZE);
|
||||
if (qsize <= BCM43xx_PIO_TXQADJUST) {
|
||||
printk(KERN_ERR PFX "PIO tx queue too small (%u)\n", qsize);
|
||||
goto err_freequeue;
|
||||
}
|
||||
qsize -= BCM43xx_PIO_TXQADJUST;
|
||||
queue->tx_devq_size = qsize;
|
||||
|
||||
setup_txqueues(queue);
|
||||
|
||||
out:
|
||||
return queue;
|
||||
|
||||
err_freequeue:
|
||||
kfree(queue);
|
||||
queue = NULL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
static void cancel_transfers(struct bcm43xx_pioqueue *queue)
|
||||
{
|
||||
struct bcm43xx_pio_txpacket *packet, *tmp_packet;
|
||||
|
||||
netif_tx_disable(queue->bcm->net_dev);
|
||||
assert(queue->bcm->shutting_down);
|
||||
cancel_delayed_work(&queue->txwork);
|
||||
flush_workqueue(queue->bcm->workqueue);
|
||||
|
||||
list_for_each_entry_safe(packet, tmp_packet, &queue->txrunning, list)
|
||||
free_txpacket(packet);
|
||||
list_for_each_entry_safe(packet, tmp_packet, &queue->txqueue, list)
|
||||
free_txpacket(packet);
|
||||
}
|
||||
|
||||
static void bcm43xx_destroy_pioqueue(struct bcm43xx_pioqueue *queue)
|
||||
{
|
||||
if (!queue)
|
||||
return;
|
||||
|
||||
cancel_transfers(queue);
|
||||
kfree(queue);
|
||||
}
|
||||
|
||||
void bcm43xx_pio_free(struct bcm43xx_private *bcm)
|
||||
{
|
||||
bcm43xx_destroy_pioqueue(bcm->current_core->pio->queue3);
|
||||
bcm->current_core->pio->queue3 = NULL;
|
||||
bcm43xx_destroy_pioqueue(bcm->current_core->pio->queue2);
|
||||
bcm->current_core->pio->queue2 = NULL;
|
||||
bcm43xx_destroy_pioqueue(bcm->current_core->pio->queue1);
|
||||
bcm->current_core->pio->queue1 = NULL;
|
||||
bcm43xx_destroy_pioqueue(bcm->current_core->pio->queue0);
|
||||
bcm->current_core->pio->queue0 = NULL;
|
||||
}
|
||||
|
||||
int bcm43xx_pio_init(struct bcm43xx_private *bcm)
|
||||
{
|
||||
struct bcm43xx_pioqueue *queue;
|
||||
int err = -ENOMEM;
|
||||
|
||||
queue = bcm43xx_setup_pioqueue(bcm, BCM43xx_MMIO_PIO1_BASE);
|
||||
if (!queue)
|
||||
goto out;
|
||||
bcm->current_core->pio->queue0 = queue;
|
||||
|
||||
queue = bcm43xx_setup_pioqueue(bcm, BCM43xx_MMIO_PIO2_BASE);
|
||||
if (!queue)
|
||||
goto err_destroy0;
|
||||
bcm->current_core->pio->queue1 = queue;
|
||||
|
||||
queue = bcm43xx_setup_pioqueue(bcm, BCM43xx_MMIO_PIO3_BASE);
|
||||
if (!queue)
|
||||
goto err_destroy1;
|
||||
bcm->current_core->pio->queue2 = queue;
|
||||
|
||||
queue = bcm43xx_setup_pioqueue(bcm, BCM43xx_MMIO_PIO4_BASE);
|
||||
if (!queue)
|
||||
goto err_destroy2;
|
||||
bcm->current_core->pio->queue3 = queue;
|
||||
|
||||
if (bcm->current_core->rev < 3)
|
||||
bcm->irq_savedstate |= BCM43xx_IRQ_PIO_WORKAROUND;
|
||||
|
||||
dprintk(KERN_INFO PFX "PIO initialized\n");
|
||||
err = 0;
|
||||
out:
|
||||
return err;
|
||||
|
||||
err_destroy2:
|
||||
bcm43xx_destroy_pioqueue(bcm->current_core->pio->queue2);
|
||||
bcm->current_core->pio->queue2 = NULL;
|
||||
err_destroy1:
|
||||
bcm43xx_destroy_pioqueue(bcm->current_core->pio->queue1);
|
||||
bcm->current_core->pio->queue1 = NULL;
|
||||
err_destroy0:
|
||||
bcm43xx_destroy_pioqueue(bcm->current_core->pio->queue0);
|
||||
bcm->current_core->pio->queue0 = NULL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
static inline
|
||||
int pio_transfer_txb(struct bcm43xx_pioqueue *queue,
|
||||
struct ieee80211_txb *txb)
|
||||
{
|
||||
struct bcm43xx_pio_txpacket *packet;
|
||||
unsigned long flags;
|
||||
u16 tmp;
|
||||
|
||||
spin_lock_irqsave(&queue->txlock, flags);
|
||||
assert(!queue->tx_suspended);
|
||||
assert(!list_empty(&queue->txfree));
|
||||
|
||||
tmp = bcm43xx_pio_read(queue, BCM43xx_PIO_TXCTL);
|
||||
if (tmp & BCM43xx_PIO_TXCTL_SUSPEND) {
|
||||
spin_unlock_irqrestore(&queue->txlock, flags);
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
packet = list_entry(queue->txfree.next, struct bcm43xx_pio_txpacket, list);
|
||||
|
||||
packet->txb = txb;
|
||||
list_move_tail(&packet->list, &queue->txqueue);
|
||||
packet->xmitted_octets = 0;
|
||||
packet->xmitted_frags = 0;
|
||||
|
||||
/* Suspend TX, if we are out of packets in the "free" queue. */
|
||||
if (unlikely(list_empty(&queue->txfree))) {
|
||||
netif_stop_queue(queue->bcm->net_dev);
|
||||
queue->tx_suspended = 1;
|
||||
}
|
||||
|
||||
spin_unlock_irqrestore(&queue->txlock, flags);
|
||||
queue_work(queue->bcm->workqueue, &queue->txwork);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fastcall bcm43xx_pio_transfer_txb(struct bcm43xx_private *bcm,
|
||||
struct ieee80211_txb *txb)
|
||||
{
|
||||
return pio_transfer_txb(bcm->current_core->pio->queue1, txb);
|
||||
}
|
||||
|
||||
void fastcall
|
||||
bcm43xx_pio_handle_xmitstatus(struct bcm43xx_private *bcm,
|
||||
struct bcm43xx_xmitstatus *status)
|
||||
{
|
||||
struct bcm43xx_pioqueue *queue;
|
||||
struct bcm43xx_pio_txpacket *packet;
|
||||
unsigned long flags;
|
||||
|
||||
queue = parse_cookie(bcm, status->cookie, &packet);
|
||||
assert(queue);
|
||||
spin_lock_irqsave(&queue->txlock, flags);
|
||||
free_txpacket(packet);
|
||||
if (unlikely(queue->tx_suspended)) {
|
||||
queue->tx_suspended = 0;
|
||||
netif_wake_queue(queue->bcm->net_dev);
|
||||
}
|
||||
|
||||
/* If there are packets on the txqueue,
|
||||
* start the work handler again.
|
||||
*/
|
||||
if (!list_empty(&queue->txqueue)) {
|
||||
queue_work(queue->bcm->workqueue,
|
||||
&queue->txwork);
|
||||
}
|
||||
spin_unlock_irqrestore(&queue->txlock, flags);
|
||||
}
|
||||
|
||||
static void pio_rx_error(struct bcm43xx_pioqueue *queue,
|
||||
const char *error)
|
||||
{
|
||||
printk("PIO RX error: %s\n", error);
|
||||
bcm43xx_pio_write(queue, BCM43xx_PIO_RXCTL, BCM43xx_PIO_RXCTL_READY);
|
||||
}
|
||||
|
||||
void fastcall
|
||||
bcm43xx_pio_rx(struct bcm43xx_pioqueue *queue)
|
||||
{
|
||||
u16 preamble[21] = { 0 };
|
||||
struct bcm43xx_rxhdr *rxhdr;
|
||||
u16 tmp;
|
||||
u16 len;
|
||||
int i, err;
|
||||
int preamble_readwords;
|
||||
struct sk_buff *skb;
|
||||
|
||||
tmp = bcm43xx_pio_read(queue, BCM43xx_PIO_RXCTL);
|
||||
if (!(tmp & BCM43xx_PIO_RXCTL_DATAAVAILABLE)) {
|
||||
dprintkl(KERN_ERR PFX "PIO RX: No data available\n");
|
||||
return;
|
||||
}
|
||||
bcm43xx_pio_write(queue, BCM43xx_PIO_RXCTL, BCM43xx_PIO_RXCTL_DATAAVAILABLE);
|
||||
|
||||
for (i = 0; i < 10; i++) {
|
||||
tmp = bcm43xx_pio_read(queue, BCM43xx_PIO_RXCTL);
|
||||
if (tmp & BCM43xx_PIO_RXCTL_READY)
|
||||
goto data_ready;
|
||||
udelay(10);
|
||||
}
|
||||
dprintkl(KERN_ERR PFX "PIO RX timed out\n");
|
||||
return;
|
||||
data_ready:
|
||||
|
||||
len = le16_to_cpu(bcm43xx_pio_read(queue, BCM43xx_PIO_RXDATA));
|
||||
if (unlikely(len > 0x700)) {
|
||||
pio_rx_error(queue, "len > 0x700");
|
||||
return;
|
||||
}
|
||||
if (unlikely(len == 0 && queue->mmio_base != BCM43xx_MMIO_PIO4_BASE)) {
|
||||
pio_rx_error(queue, "len == 0");
|
||||
return;
|
||||
}
|
||||
preamble[0] = cpu_to_le16(len);
|
||||
if (queue->mmio_base == BCM43xx_MMIO_PIO4_BASE)
|
||||
preamble_readwords = 14 / sizeof(u16);
|
||||
else
|
||||
preamble_readwords = 18 / sizeof(u16);
|
||||
for (i = 0; i < preamble_readwords; i++) {
|
||||
tmp = bcm43xx_pio_read(queue, BCM43xx_PIO_RXDATA);
|
||||
preamble[i + 1] = cpu_to_be16(tmp);
|
||||
}
|
||||
rxhdr = (struct bcm43xx_rxhdr *)preamble;
|
||||
if (unlikely(rxhdr->flags2 & BCM43xx_RXHDR_FLAGS2_INVALIDFRAME)) {
|
||||
pio_rx_error(queue, "invalid frame");
|
||||
if (queue->mmio_base == BCM43xx_MMIO_PIO1_BASE) {
|
||||
for (i = 0; i < 15; i++)
|
||||
bcm43xx_pio_read(queue, BCM43xx_PIO_RXDATA); /* dummy read. */
|
||||
}
|
||||
return;
|
||||
}
|
||||
//FIXME
|
||||
#if 0
|
||||
if (queue->mmio_base == BCM43xx_MMIO_PIO4_BASE) {
|
||||
bcm43xx_rx_transmitstatus(queue->bcm,
|
||||
(const struct bcm43xx_hwxmitstatus *)(preamble + 1));
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
skb = dev_alloc_skb(len);
|
||||
if (unlikely(!skb)) {
|
||||
pio_rx_error(queue, "out of memory");
|
||||
return;
|
||||
}
|
||||
skb_put(skb, len);
|
||||
for (i = 0; i < len - 1; i += 2) {
|
||||
tmp = cpu_to_be16(bcm43xx_pio_read(queue, BCM43xx_PIO_RXDATA));
|
||||
*((u16 *)(skb->data + i)) = tmp;
|
||||
}
|
||||
if (len % 2) {
|
||||
tmp = cpu_to_be16(bcm43xx_pio_read(queue, BCM43xx_PIO_RXDATA));
|
||||
skb->data[len - 1] = (tmp & 0x00FF);
|
||||
skb->data[0] = (tmp & 0xFF00) >> 8;
|
||||
}
|
||||
err = bcm43xx_rx(queue->bcm, skb, rxhdr);
|
||||
if (unlikely(err))
|
||||
dev_kfree_skb_irq(skb);
|
||||
}
|
||||
|
||||
/* vim: set ts=8 sw=8 sts=8: */
|
88
drivers/net/wireless/bcm43xx/bcm43xx_pio.h
Normal file
88
drivers/net/wireless/bcm43xx/bcm43xx_pio.h
Normal file
@ -0,0 +1,88 @@
|
||||
#ifndef BCM43xx_PIO_H_
|
||||
#define BCM43xx_PIO_H_
|
||||
|
||||
#include "bcm43xx.h"
|
||||
|
||||
#include <linux/list.h>
|
||||
#include <linux/spinlock.h>
|
||||
#include <linux/workqueue.h>
|
||||
#include <linux/skbuff.h>
|
||||
|
||||
|
||||
#define BCM43xx_PIO_TXCTL 0x00
|
||||
#define BCM43xx_PIO_TXDATA 0x02
|
||||
#define BCM43xx_PIO_TXQBUFSIZE 0x04
|
||||
#define BCM43xx_PIO_RXCTL 0x08
|
||||
#define BCM43xx_PIO_RXDATA 0x0A
|
||||
|
||||
#define BCM43xx_PIO_TXCTL_WRITEHI (1 << 0)
|
||||
#define BCM43xx_PIO_TXCTL_WRITELO (1 << 1)
|
||||
#define BCM43xx_PIO_TXCTL_COMPLETE (1 << 2)
|
||||
#define BCM43xx_PIO_TXCTL_INIT (1 << 3)
|
||||
#define BCM43xx_PIO_TXCTL_SUSPEND (1 << 7)
|
||||
|
||||
#define BCM43xx_PIO_RXCTL_DATAAVAILABLE (1 << 0)
|
||||
#define BCM43xx_PIO_RXCTL_READY (1 << 1)
|
||||
|
||||
/* PIO constants */
|
||||
#define BCM43xx_PIO_MAXTXDEVQPACKETS 31
|
||||
#define BCM43xx_PIO_TXQADJUST 80
|
||||
|
||||
/* PIO tuning knobs */
|
||||
#define BCM43xx_PIO_MAXTXPACKETS 256
|
||||
|
||||
|
||||
struct bcm43xx_pioqueue;
|
||||
struct bcm43xx_xmitstatus;
|
||||
|
||||
struct bcm43xx_pio_txpacket {
|
||||
struct bcm43xx_pioqueue *queue;
|
||||
struct ieee80211_txb *txb;
|
||||
struct list_head list;
|
||||
|
||||
u8 xmitted_frags;
|
||||
u16 xmitted_octets;
|
||||
};
|
||||
|
||||
#define pio_txpacket_getindex(packet) ((int)((packet) - (packet)->queue->__tx_packets_cache))
|
||||
|
||||
struct bcm43xx_pioqueue {
|
||||
struct bcm43xx_private *bcm;
|
||||
u16 mmio_base;
|
||||
|
||||
u8 tx_suspended:1;
|
||||
|
||||
/* Adjusted size of the device internal TX buffer. */
|
||||
u16 tx_devq_size;
|
||||
/* Used octets of the device internal TX buffer. */
|
||||
u16 tx_devq_used;
|
||||
/* Used packet slots in the device internal TX buffer. */
|
||||
u8 tx_devq_packets;
|
||||
/* Packets from the txfree list can
|
||||
* be taken on incoming TX requests.
|
||||
*/
|
||||
struct list_head txfree;
|
||||
/* Packets on the txqueue are queued,
|
||||
* but not completely written to the chip, yet.
|
||||
*/
|
||||
struct list_head txqueue;
|
||||
/* Packets on the txrunning queue are completely
|
||||
* posted to the device. We are waiting for the txstatus.
|
||||
*/
|
||||
struct list_head txrunning;
|
||||
/* Locking of the TX queues and the accounting. */
|
||||
spinlock_t txlock;
|
||||
struct work_struct txwork;
|
||||
struct bcm43xx_pio_txpacket __tx_packets_cache[BCM43xx_PIO_MAXTXPACKETS];
|
||||
};
|
||||
|
||||
int bcm43xx_pio_init(struct bcm43xx_private *bcm);
|
||||
void bcm43xx_pio_free(struct bcm43xx_private *bcm);
|
||||
|
||||
int FASTCALL(bcm43xx_pio_transfer_txb(struct bcm43xx_private *bcm,
|
||||
struct ieee80211_txb *txb));
|
||||
void FASTCALL(bcm43xx_pio_handle_xmitstatus(struct bcm43xx_private *bcm,
|
||||
struct bcm43xx_xmitstatus *status));
|
||||
|
||||
void FASTCALL(bcm43xx_pio_rx(struct bcm43xx_pioqueue *queue));
|
||||
#endif /* BCM43xx_PIO_H_ */
|
358
drivers/net/wireless/bcm43xx/bcm43xx_power.c
Normal file
358
drivers/net/wireless/bcm43xx/bcm43xx_power.c
Normal file
@ -0,0 +1,358 @@
|
||||
/*
|
||||
|
||||
Broadcom BCM43xx wireless driver
|
||||
|
||||
Copyright (c) 2005 Martin Langer <martin-langer@gmx.de>,
|
||||
Stefano Brivio <st3@riseup.net>
|
||||
Michael Buesch <mbuesch@freenet.de>
|
||||
Danny van Dyk <kugelfang@gentoo.org>
|
||||
Andreas Jaggi <andreas.jaggi@waterwave.ch>
|
||||
|
||||
Some parts of the code in this file are derived from the ipw2200
|
||||
driver Copyright(c) 2003 - 2004 Intel Corporation.
|
||||
|
||||
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.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
|
||||
*/
|
||||
|
||||
#include <linux/delay.h>
|
||||
|
||||
#include "bcm43xx.h"
|
||||
#include "bcm43xx_power.h"
|
||||
#include "bcm43xx_main.h"
|
||||
|
||||
|
||||
/* Get max/min slowclock frequency
|
||||
* as described in http://bcm-specs.sipsolutions.net/PowerControl
|
||||
*/
|
||||
static int bcm43xx_pctl_clockfreqlimit(struct bcm43xx_private *bcm,
|
||||
int get_max)
|
||||
{
|
||||
int limit = 0;
|
||||
int divisor;
|
||||
int selection;
|
||||
int err;
|
||||
u32 tmp;
|
||||
struct bcm43xx_coreinfo *old_core;
|
||||
|
||||
if (!(bcm->chipcommon_capabilities & BCM43xx_CAPABILITIES_PCTL))
|
||||
goto out;
|
||||
old_core = bcm->current_core;
|
||||
err = bcm43xx_switch_core(bcm, &bcm->core_chipcommon);
|
||||
if (err)
|
||||
goto out;
|
||||
|
||||
if (bcm->current_core->rev < 6) {
|
||||
if ((bcm->bustype == BCM43xx_BUSTYPE_PCMCIA) ||
|
||||
(bcm->bustype == BCM43xx_BUSTYPE_SB)) {
|
||||
selection = 1;
|
||||
divisor = 32;
|
||||
} else {
|
||||
err = bcm43xx_pci_read_config32(bcm, BCM43xx_PCTL_OUT, &tmp);
|
||||
if (err) {
|
||||
printk(KERN_ERR PFX "clockfreqlimit pcicfg read failure\n");
|
||||
goto out_switchback;
|
||||
}
|
||||
if (tmp & 0x10) {
|
||||
/* PCI */
|
||||
selection = 2;
|
||||
divisor = 64;
|
||||
} else {
|
||||
/* XTAL */
|
||||
selection = 1;
|
||||
divisor = 32;
|
||||
}
|
||||
}
|
||||
} else if (bcm->current_core->rev < 10) {
|
||||
selection = (tmp & 0x07);
|
||||
if (selection) {
|
||||
tmp = bcm43xx_read32(bcm, BCM43xx_CHIPCOMMON_SLOWCLKCTL);
|
||||
divisor = 4 * (1 + ((tmp & 0xFFFF0000) >> 16));
|
||||
} else
|
||||
divisor = 1;
|
||||
} else {
|
||||
tmp = bcm43xx_read32(bcm, BCM43xx_CHIPCOMMON_SYSCLKCTL);
|
||||
divisor = 4 * (1 + ((tmp & 0xFFFF0000) >> 16));
|
||||
selection = 1;
|
||||
}
|
||||
|
||||
switch (selection) {
|
||||
case 0:
|
||||
/* LPO */
|
||||
if (get_max)
|
||||
limit = 43000;
|
||||
else
|
||||
limit = 25000;
|
||||
break;
|
||||
case 1:
|
||||
/* XTAL */
|
||||
if (get_max)
|
||||
limit = 20200000;
|
||||
else
|
||||
limit = 19800000;
|
||||
break;
|
||||
case 2:
|
||||
/* PCI */
|
||||
if (get_max)
|
||||
limit = 34000000;
|
||||
else
|
||||
limit = 25000000;
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
limit /= divisor;
|
||||
|
||||
out_switchback:
|
||||
err = bcm43xx_switch_core(bcm, old_core);
|
||||
assert(err == 0);
|
||||
|
||||
out:
|
||||
return limit;
|
||||
}
|
||||
|
||||
/* init power control
|
||||
* as described in http://bcm-specs.sipsolutions.net/PowerControl
|
||||
*/
|
||||
int bcm43xx_pctl_init(struct bcm43xx_private *bcm)
|
||||
{
|
||||
int err, maxfreq;
|
||||
struct bcm43xx_coreinfo *old_core;
|
||||
|
||||
if (!(bcm->chipcommon_capabilities & BCM43xx_CAPABILITIES_PCTL))
|
||||
return 0;
|
||||
old_core = bcm->current_core;
|
||||
err = bcm43xx_switch_core(bcm, &bcm->core_chipcommon);
|
||||
if (err == -ENODEV)
|
||||
return 0;
|
||||
if (err)
|
||||
goto out;
|
||||
|
||||
maxfreq = bcm43xx_pctl_clockfreqlimit(bcm, 1);
|
||||
bcm43xx_write32(bcm, BCM43xx_CHIPCOMMON_PLLONDELAY,
|
||||
(maxfreq * 150 + 999999) / 1000000);
|
||||
bcm43xx_write32(bcm, BCM43xx_CHIPCOMMON_FREFSELDELAY,
|
||||
(maxfreq * 15 + 999999) / 1000000);
|
||||
|
||||
err = bcm43xx_switch_core(bcm, old_core);
|
||||
assert(err == 0);
|
||||
|
||||
out:
|
||||
return err;
|
||||
}
|
||||
|
||||
u16 bcm43xx_pctl_powerup_delay(struct bcm43xx_private *bcm)
|
||||
{
|
||||
u16 delay = 0;
|
||||
int err;
|
||||
u32 pll_on_delay;
|
||||
struct bcm43xx_coreinfo *old_core;
|
||||
int minfreq;
|
||||
|
||||
if (bcm->bustype != BCM43xx_BUSTYPE_PCI)
|
||||
goto out;
|
||||
if (!(bcm->chipcommon_capabilities & BCM43xx_CAPABILITIES_PCTL))
|
||||
goto out;
|
||||
old_core = bcm->current_core;
|
||||
err = bcm43xx_switch_core(bcm, &bcm->core_chipcommon);
|
||||
if (err == -ENODEV)
|
||||
goto out;
|
||||
|
||||
minfreq = bcm43xx_pctl_clockfreqlimit(bcm, 0);
|
||||
pll_on_delay = bcm43xx_read32(bcm, BCM43xx_CHIPCOMMON_PLLONDELAY);
|
||||
delay = (((pll_on_delay + 2) * 1000000) + (minfreq - 1)) / minfreq;
|
||||
|
||||
err = bcm43xx_switch_core(bcm, old_core);
|
||||
assert(err == 0);
|
||||
|
||||
out:
|
||||
return delay;
|
||||
}
|
||||
|
||||
/* set the powercontrol clock
|
||||
* as described in http://bcm-specs.sipsolutions.net/PowerControl
|
||||
*/
|
||||
int bcm43xx_pctl_set_clock(struct bcm43xx_private *bcm, u16 mode)
|
||||
{
|
||||
int err;
|
||||
struct bcm43xx_coreinfo *old_core;
|
||||
u32 tmp;
|
||||
|
||||
old_core = bcm->current_core;
|
||||
err = bcm43xx_switch_core(bcm, &bcm->core_chipcommon);
|
||||
if (err == -ENODEV)
|
||||
return 0;
|
||||
if (err)
|
||||
goto out;
|
||||
|
||||
if (bcm->core_chipcommon.rev < 6) {
|
||||
if (mode == BCM43xx_PCTL_CLK_FAST) {
|
||||
err = bcm43xx_pctl_set_crystal(bcm, 1);
|
||||
if (err)
|
||||
goto out;
|
||||
}
|
||||
} else {
|
||||
if ((bcm->chipcommon_capabilities & BCM43xx_CAPABILITIES_PCTL) &&
|
||||
(bcm->core_chipcommon.rev < 10)) {
|
||||
switch (mode) {
|
||||
case BCM43xx_PCTL_CLK_FAST:
|
||||
tmp = bcm43xx_read32(bcm, BCM43xx_CHIPCOMMON_SLOWCLKCTL);
|
||||
tmp = (tmp & ~BCM43xx_PCTL_FORCE_SLOW) | BCM43xx_PCTL_FORCE_PLL;
|
||||
bcm43xx_write32(bcm, BCM43xx_CHIPCOMMON_SLOWCLKCTL, tmp);
|
||||
break;
|
||||
case BCM43xx_PCTL_CLK_SLOW:
|
||||
tmp = bcm43xx_read32(bcm, BCM43xx_CHIPCOMMON_SLOWCLKCTL);
|
||||
tmp |= BCM43xx_PCTL_FORCE_SLOW;
|
||||
bcm43xx_write32(bcm, BCM43xx_CHIPCOMMON_SLOWCLKCTL, tmp);
|
||||
break;
|
||||
case BCM43xx_PCTL_CLK_DYNAMIC:
|
||||
tmp = bcm43xx_read32(bcm, BCM43xx_CHIPCOMMON_SLOWCLKCTL);
|
||||
tmp &= ~BCM43xx_PCTL_FORCE_SLOW;
|
||||
tmp |= BCM43xx_PCTL_FORCE_PLL;
|
||||
tmp &= ~BCM43xx_PCTL_DYN_XTAL;
|
||||
bcm43xx_write32(bcm, BCM43xx_CHIPCOMMON_SLOWCLKCTL, tmp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
err = bcm43xx_switch_core(bcm, old_core);
|
||||
assert(err == 0);
|
||||
|
||||
out:
|
||||
return err;
|
||||
}
|
||||
|
||||
int bcm43xx_pctl_set_crystal(struct bcm43xx_private *bcm, int on)
|
||||
{
|
||||
int err;
|
||||
u32 in, out, outenable;
|
||||
|
||||
err = bcm43xx_pci_read_config32(bcm, BCM43xx_PCTL_IN, &in);
|
||||
if (err)
|
||||
goto err_pci;
|
||||
err = bcm43xx_pci_read_config32(bcm, BCM43xx_PCTL_OUT, &out);
|
||||
if (err)
|
||||
goto err_pci;
|
||||
err = bcm43xx_pci_read_config32(bcm, BCM43xx_PCTL_OUTENABLE, &outenable);
|
||||
if (err)
|
||||
goto err_pci;
|
||||
|
||||
outenable |= (BCM43xx_PCTL_XTAL_POWERUP | BCM43xx_PCTL_PLL_POWERDOWN);
|
||||
|
||||
if (on) {
|
||||
if (in & 0x40)
|
||||
return 0;
|
||||
|
||||
out |= (BCM43xx_PCTL_XTAL_POWERUP | BCM43xx_PCTL_PLL_POWERDOWN);
|
||||
|
||||
err = bcm43xx_pci_write_config32(bcm, BCM43xx_PCTL_OUT, out);
|
||||
if (err)
|
||||
goto err_pci;
|
||||
err = bcm43xx_pci_write_config32(bcm, BCM43xx_PCTL_OUTENABLE, outenable);
|
||||
if (err)
|
||||
goto err_pci;
|
||||
udelay(1000);
|
||||
|
||||
out &= ~BCM43xx_PCTL_PLL_POWERDOWN;
|
||||
err = bcm43xx_pci_write_config32(bcm, BCM43xx_PCTL_OUT, out);
|
||||
if (err)
|
||||
goto err_pci;
|
||||
udelay(5000);
|
||||
} else {
|
||||
if (bcm->current_core->rev < 5)
|
||||
return 0;
|
||||
if (bcm->sprom.boardflags & BCM43xx_BFL_XTAL_NOSLOW)
|
||||
return 0;
|
||||
|
||||
/* XXX: Why BCM43xx_MMIO_RADIO_HWENABLED_xx can't be read at this time?
|
||||
* err = bcm43xx_switch_core(bcm, bcm->active_80211_core);
|
||||
* if (err)
|
||||
* return err;
|
||||
* if (((bcm->current_core->rev >= 3) &&
|
||||
* (bcm43xx_read32(bcm, BCM43xx_MMIO_RADIO_HWENABLED_HI) & (1 << 16))) ||
|
||||
* ((bcm->current_core->rev < 3) &&
|
||||
* !(bcm43xx_read16(bcm, BCM43xx_MMIO_RADIO_HWENABLED_LO) & (1 << 4))))
|
||||
* return 0;
|
||||
* err = bcm43xx_switch_core(bcm, &bcm->core_chipcommon);
|
||||
* if (err)
|
||||
* return err;
|
||||
*/
|
||||
|
||||
err = bcm43xx_pctl_set_clock(bcm, BCM43xx_PCTL_CLK_SLOW);
|
||||
if (err)
|
||||
goto out;
|
||||
out &= ~BCM43xx_PCTL_XTAL_POWERUP;
|
||||
out |= BCM43xx_PCTL_PLL_POWERDOWN;
|
||||
err = bcm43xx_pci_write_config32(bcm, BCM43xx_PCTL_OUT, out);
|
||||
if (err)
|
||||
goto err_pci;
|
||||
err = bcm43xx_pci_write_config32(bcm, BCM43xx_PCTL_OUTENABLE, outenable);
|
||||
if (err)
|
||||
goto err_pci;
|
||||
}
|
||||
|
||||
out:
|
||||
return err;
|
||||
|
||||
err_pci:
|
||||
printk(KERN_ERR PFX "Error: pctl_set_clock() could not access PCI config space!\n");
|
||||
err = -EBUSY;
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Set the PowerSavingControlBits.
|
||||
* Bitvalues:
|
||||
* 0 => unset the bit
|
||||
* 1 => set the bit
|
||||
* -1 => calculate the bit
|
||||
*/
|
||||
void bcm43xx_power_saving_ctl_bits(struct bcm43xx_private *bcm,
|
||||
int bit25, int bit26)
|
||||
{
|
||||
int i;
|
||||
u32 status;
|
||||
|
||||
//FIXME: Force 25 to off and 26 to on for now:
|
||||
bit25 = 0;
|
||||
bit26 = 1;
|
||||
|
||||
if (bit25 == -1) {
|
||||
//TODO: If powersave is not off and FIXME is not set and we are not in adhoc
|
||||
// and thus is not an AP and we are associated, set bit 25
|
||||
}
|
||||
if (bit26 == -1) {
|
||||
//TODO: If the device is awake or this is an AP, or we are scanning, or FIXME,
|
||||
// or we are associated, or FIXME, or the latest PS-Poll packet sent was
|
||||
// successful, set bit26
|
||||
}
|
||||
status = bcm43xx_read32(bcm, BCM43xx_MMIO_STATUS_BITFIELD);
|
||||
if (bit25)
|
||||
status |= BCM43xx_SBF_PS1;
|
||||
else
|
||||
status &= ~BCM43xx_SBF_PS1;
|
||||
if (bit26)
|
||||
status |= BCM43xx_SBF_PS2;
|
||||
else
|
||||
status &= ~BCM43xx_SBF_PS2;
|
||||
bcm43xx_write32(bcm, BCM43xx_MMIO_STATUS_BITFIELD, status);
|
||||
if (bit26 && bcm->current_core->rev >= 5) {
|
||||
for (i = 0; i < 100; i++) {
|
||||
if (bcm43xx_shm_read32(bcm, BCM43xx_SHM_SHARED, 0x0040) != 4)
|
||||
break;
|
||||
udelay(10);
|
||||
}
|
||||
}
|
||||
}
|
47
drivers/net/wireless/bcm43xx/bcm43xx_power.h
Normal file
47
drivers/net/wireless/bcm43xx/bcm43xx_power.h
Normal file
@ -0,0 +1,47 @@
|
||||
/*
|
||||
|
||||
Broadcom BCM43xx wireless driver
|
||||
|
||||
Copyright (c) 2005 Martin Langer <martin-langer@gmx.de>,
|
||||
Stefano Brivio <st3@riseup.net>
|
||||
Michael Buesch <mbuesch@freenet.de>
|
||||
Danny van Dyk <kugelfang@gentoo.org>
|
||||
Andreas Jaggi <andreas.jaggi@waterwave.ch>
|
||||
|
||||
Some parts of the code in this file are derived from the ipw2200
|
||||
driver Copyright(c) 2003 - 2004 Intel Corporation.
|
||||
|
||||
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.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef BCM43xx_POWER_H_
|
||||
#define BCM43xx_POWER_H_
|
||||
|
||||
#include <linux/types.h>
|
||||
|
||||
|
||||
struct bcm43xx_private;
|
||||
|
||||
int bcm43xx_pctl_init(struct bcm43xx_private *bcm);
|
||||
int bcm43xx_pctl_set_clock(struct bcm43xx_private *bcm, u16 mode);
|
||||
int bcm43xx_pctl_set_crystal(struct bcm43xx_private *bcm, int on);
|
||||
u16 bcm43xx_pctl_powerup_delay(struct bcm43xx_private *bcm);
|
||||
|
||||
void bcm43xx_power_saving_ctl_bits(struct bcm43xx_private *bcm,
|
||||
int bit25, int bit26);
|
||||
|
||||
#endif /* BCM43xx_POWER_H_ */
|
1766
drivers/net/wireless/bcm43xx/bcm43xx_radio.c
Normal file
1766
drivers/net/wireless/bcm43xx/bcm43xx_radio.c
Normal file
File diff suppressed because it is too large
Load Diff
93
drivers/net/wireless/bcm43xx/bcm43xx_radio.h
Normal file
93
drivers/net/wireless/bcm43xx/bcm43xx_radio.h
Normal file
@ -0,0 +1,93 @@
|
||||
/*
|
||||
|
||||
Broadcom BCM43xx wireless driver
|
||||
|
||||
Copyright (c) 2005 Martin Langer <martin-langer@gmx.de>,
|
||||
Stefano Brivio <st3@riseup.net>
|
||||
Michael Buesch <mbuesch@freenet.de>
|
||||
Danny van Dyk <kugelfang@gentoo.org>
|
||||
Andreas Jaggi <andreas.jaggi@waterwave.ch>
|
||||
|
||||
Some parts of the code in this file are derived from the ipw2200
|
||||
driver Copyright(c) 2003 - 2004 Intel Corporation.
|
||||
|
||||
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.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef BCM43xx_RADIO_H_
|
||||
#define BCM43xx_RADIO_H_
|
||||
|
||||
#include "bcm43xx.h"
|
||||
|
||||
|
||||
#define BCM43xx_RADIO_DEFAULT_CHANNEL_A 36
|
||||
#define BCM43xx_RADIO_DEFAULT_CHANNEL_BG 6
|
||||
|
||||
/* Force antenna 0. */
|
||||
#define BCM43xx_RADIO_TXANTENNA_0 0
|
||||
/* Force antenna 1. */
|
||||
#define BCM43xx_RADIO_TXANTENNA_1 1
|
||||
/* Use the RX antenna, that was selected for the most recently
|
||||
* received good PLCP header.
|
||||
*/
|
||||
#define BCM43xx_RADIO_TXANTENNA_LASTPLCP 3
|
||||
#define BCM43xx_RADIO_TXANTENNA_DEFAULT BCM43xx_RADIO_TXANTENNA_LASTPLCP
|
||||
|
||||
#define BCM43xx_RADIO_INTERFMODE_NONE 0
|
||||
#define BCM43xx_RADIO_INTERFMODE_NONWLAN 1
|
||||
#define BCM43xx_RADIO_INTERFMODE_MANUALWLAN 2
|
||||
#define BCM43xx_RADIO_INTERFMODE_AUTOWLAN 3
|
||||
|
||||
|
||||
void bcm43xx_radio_lock(struct bcm43xx_private *bcm);
|
||||
void bcm43xx_radio_unlock(struct bcm43xx_private *bcm);
|
||||
|
||||
u16 bcm43xx_radio_read16(struct bcm43xx_private *bcm, u16 offset);
|
||||
void bcm43xx_radio_write16(struct bcm43xx_private *bcm, u16 offset, u16 val);
|
||||
|
||||
u16 bcm43xx_radio_init2050(struct bcm43xx_private *bcm);
|
||||
void bcm43xx_radio_init2060(struct bcm43xx_private *bcm);
|
||||
|
||||
void bcm43xx_radio_turn_on(struct bcm43xx_private *bcm);
|
||||
void bcm43xx_radio_turn_off(struct bcm43xx_private *bcm);
|
||||
|
||||
int bcm43xx_radio_selectchannel(struct bcm43xx_private *bcm, u8 channel,
|
||||
int synthetic_pu_workaround);
|
||||
|
||||
void bcm43xx_radio_set_txpower_a(struct bcm43xx_private *bcm, u16 txpower);
|
||||
void bcm43xx_radio_set_txpower_bg(struct bcm43xx_private *bcm,
|
||||
u16 baseband_attenuation, u16 attenuation,
|
||||
u16 txpower);
|
||||
void bcm43xx_radio_set_txantenna(struct bcm43xx_private *bcm, u32 val);
|
||||
|
||||
void bcm43xx_radio_clear_tssi(struct bcm43xx_private *bcm);
|
||||
|
||||
u8 bcm43xx_radio_aci_detect(struct bcm43xx_private *bcm, u8 channel);
|
||||
u8 bcm43xx_radio_aci_scan(struct bcm43xx_private *bcm);
|
||||
|
||||
int bcm43xx_radio_set_interference_mitigation(struct bcm43xx_private *bcm, int mode);
|
||||
|
||||
void bcm43xx_calc_nrssi_slope(struct bcm43xx_private *bcm);
|
||||
void bcm43xx_calc_nrssi_threshold(struct bcm43xx_private *bcm);
|
||||
s16 bcm43xx_nrssi_hw_read(struct bcm43xx_private *bcm, u16 offset);
|
||||
void bcm43xx_nrssi_hw_write(struct bcm43xx_private *bcm, u16 offset, s16 val);
|
||||
void bcm43xx_nrssi_hw_update(struct bcm43xx_private *bcm, u16 val);
|
||||
void bcm43xx_nrssi_mem_update(struct bcm43xx_private *bcm);
|
||||
|
||||
void bcm43xx_radio_set_tx_iq(struct bcm43xx_private *bcm);
|
||||
|
||||
#endif /* BCM43xx_RADIO_H_ */
|
1099
drivers/net/wireless/bcm43xx/bcm43xx_wx.c
Normal file
1099
drivers/net/wireless/bcm43xx/bcm43xx_wx.c
Normal file
File diff suppressed because it is too large
Load Diff
36
drivers/net/wireless/bcm43xx/bcm43xx_wx.h
Normal file
36
drivers/net/wireless/bcm43xx/bcm43xx_wx.h
Normal file
@ -0,0 +1,36 @@
|
||||
/*
|
||||
|
||||
Broadcom BCM43xx wireless driver
|
||||
|
||||
Copyright (c) 2005 Martin Langer <martin-langer@gmx.de>,
|
||||
Stefano Brivio <st3@riseup.net>
|
||||
Michael Buesch <mbuesch@freenet.de>
|
||||
Danny van Dyk <kugelfang@gentoo.org>
|
||||
Andreas Jaggi <andreas.jaggi@waterwave.ch>
|
||||
|
||||
Some parts of the code in this file are derived from the ipw2200
|
||||
driver Copyright(c) 2003 - 2004 Intel Corporation.
|
||||
|
||||
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.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef BCM43xx_WX_H_
|
||||
#define BCM43xx_WX_H_
|
||||
|
||||
extern const struct iw_handler_def bcm43xx_wx_handlers_def;
|
||||
|
||||
#endif /* BCM43xx_WX_H_ */
|
Loading…
Reference in New Issue
Block a user