Browse Source

linux-firmware: add carl9170 firmware

GPLv2 firmware for carl9170, Atheros AR9170 802.11 draft-n USB driver.

Cc: Christian Lamparter <chunkeey@googlemail.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
master
Xose Vazquez Perez 8 years ago
parent
commit
32eb7c7307
100 changed files with 22793 additions and 0 deletions
  1. 12
    0
      WHENCE
  2. BIN
      carl9170-1.fw
  3. 19
    0
      carl9170fw/CMakeLists.txt
  4. 19
    0
      carl9170fw/COPYRIGHT
  5. 339
    0
      carl9170fw/GPL
  6. 5
    0
      carl9170fw/Kconfig
  7. 43
    0
      carl9170fw/README
  8. 47
    0
      carl9170fw/autogen.sh
  9. 67
    0
      carl9170fw/carlfw/CMakeLists.txt
  10. 233
    0
      carl9170fw/carlfw/Kconfig
  11. 59
    0
      carl9170fw/carlfw/carl9170.lds
  12. 49
    0
      carl9170fw/carlfw/include/cam.h
  13. 222
    0
      carl9170fw/carlfw/include/carl9170.h
  14. 55
    0
      carl9170fw/carlfw/include/cmd.h
  15. 64
    0
      carl9170fw/carlfw/include/config.h
  16. 349
    0
      carl9170fw/carlfw/include/dma.h
  17. 50
    0
      carl9170fw/carlfw/include/fwdsc.h
  18. 45
    0
      carl9170fw/carlfw/include/gpio.h
  19. 47
    0
      carl9170fw/carlfw/include/hostif.h
  20. 153
    0
      carl9170fw/carlfw/include/io.h
  21. 107
    0
      carl9170fw/carlfw/include/printf.h
  22. 37
    0
      carl9170fw/carlfw/include/rf.h
  23. 82
    0
      carl9170fw/carlfw/include/rom.h
  24. 88
    0
      carl9170fw/carlfw/include/timer.h
  25. 37
    0
      carl9170fw/carlfw/include/uart.h
  26. 191
    0
      carl9170fw/carlfw/include/usb.h
  27. 244
    0
      carl9170fw/carlfw/include/usb_fifo.h
  28. 296
    0
      carl9170fw/carlfw/include/wl.h
  29. 67
    0
      carl9170fw/carlfw/include/wol.h
  30. 193
    0
      carl9170fw/carlfw/src/ashlsi3.S
  31. 161
    0
      carl9170fw/carlfw/src/cam.c
  32. 154
    0
      carl9170fw/carlfw/src/cmd.c
  33. 255
    0
      carl9170fw/carlfw/src/dma.c
  34. 116
    0
      carl9170fw/carlfw/src/fw.c
  35. 52
    0
      carl9170fw/carlfw/src/gpio.c
  36. 165
    0
      carl9170fw/carlfw/src/hostif.c
  37. 256
    0
      carl9170fw/carlfw/src/main.c
  38. 228
    0
      carl9170fw/carlfw/src/memcpy.S
  39. 58
    0
      carl9170fw/carlfw/src/memset.S
  40. 161
    0
      carl9170fw/carlfw/src/printf.c
  41. 11
    0
      carl9170fw/carlfw/src/reboot.S
  42. 277
    0
      carl9170fw/carlfw/src/rf.c
  43. 76
    0
      carl9170fw/carlfw/src/uart.c
  44. 149
    0
      carl9170fw/carlfw/src/udivsi3_i4i-Os.S
  45. 1211
    0
      carl9170fw/carlfw/src/wlan.c
  46. 287
    0
      carl9170fw/carlfw/src/wol.c
  47. 37
    0
      carl9170fw/carlfw/usb/Kconfig
  48. 206
    0
      carl9170fw/carlfw/usb/fifo.c
  49. 432
    0
      carl9170fw/carlfw/usb/main.c
  50. 758
    0
      carl9170fw/carlfw/usb/usb.c
  51. 27
    0
      carl9170fw/config/CMakeLists.txt
  52. 646
    0
      carl9170fw/config/conf.c
  53. 1170
    0
      carl9170fw/config/confdata.c
  54. 1168
    0
      carl9170fw/config/expr.c
  55. 225
    0
      carl9170fw/config/expr.h
  56. 190
    0
      carl9170fw/config/lkc.h
  57. 54
    0
      carl9170fw/config/lkc_proto.h
  58. 607
    0
      carl9170fw/config/menu.c
  59. 1310
    0
      carl9170fw/config/symbol.c
  60. 140
    0
      carl9170fw/config/util.c
  61. 47
    0
      carl9170fw/config/zconf.gperf
  62. 364
    0
      carl9170fw/config/zconf.l
  63. 740
    0
      carl9170fw/config/zconf.y
  64. 140
    0
      carl9170fw/extra/FindGPERF.cmake
  65. 260
    0
      carl9170fw/extra/FindPackageHandleStandardArgs.cmake
  66. 93
    0
      carl9170fw/extra/FindUSB-1.0.cmake
  67. 42
    0
      carl9170fw/extra/GCCVersion.cmake
  68. 38
    0
      carl9170fw/extra/libusb-zeropacket.diff
  69. 21
    0
      carl9170fw/extra/sh-elf-linux.cmake
  70. 11
    0
      carl9170fw/genapi.sh
  71. 803
    0
      carl9170fw/include/linux/ch9.h
  72. 107
    0
      carl9170fw/include/linux/compiler.h
  73. 1918
    0
      carl9170fw/include/linux/ieee80211.h
  74. 61
    0
      carl9170fw/include/linux/types.h
  75. 216
    0
      carl9170fw/include/shared/eeprom.h
  76. 318
    0
      carl9170fw/include/shared/fwcmd.h
  77. 277
    0
      carl9170fw/include/shared/fwdesc.h
  78. 817
    0
      carl9170fw/include/shared/hw.h
  79. 564
    0
      carl9170fw/include/shared/phy.h
  80. 7
    0
      carl9170fw/include/shared/version.h
  81. 435
    0
      carl9170fw/include/shared/wlan.h
  82. 20
    0
      carl9170fw/minifw/CMakeLists.txt
  83. 3
    0
      carl9170fw/minifw/Kconfig
  84. 7
    0
      carl9170fw/minifw/miniboot.S
  85. 20
    0
      carl9170fw/minifw/miniboot.lds
  86. 55
    0
      carl9170fw/toolchain/Makefile
  87. 38
    0
      carl9170fw/tools/CMakeLists.txt
  88. 12
    0
      carl9170fw/tools/Kconfig
  89. 18
    0
      carl9170fw/tools/carlu/CMakeLists.txt
  90. 147
    0
      carl9170fw/tools/carlu/src/carlu.h
  91. 189
    0
      carl9170fw/tools/carlu/src/cmd.c
  92. 135
    0
      carl9170fw/tools/carlu/src/cmd.h
  93. 101
    0
      carl9170fw/tools/carlu/src/debug.c
  94. 72
    0
      carl9170fw/tools/carlu/src/debug.h
  95. 131
    0
      carl9170fw/tools/carlu/src/fw.c
  96. 307
    0
      carl9170fw/tools/carlu/src/main.c
  97. 181
    0
      carl9170fw/tools/carlu/src/rx.c
  98. 237
    0
      carl9170fw/tools/carlu/src/test.c
  99. 35
    0
      carl9170fw/tools/carlu/src/test.h
  100. 0
    0
      carl9170fw/tools/carlu/src/tx.c

+ 12
- 0
WHENCE View File

@@ -2034,3 +2034,15 @@ useful, but WITHOUT ANY WARRANTY; without even the implied warranty
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

--------------------------------------------------------------------------

Driver: carl9170 -- Atheros AR9170 802.11 draft-n USB driver

File: carl9170-1.fw
Version: 1.9.6
Source: carl9170fw/

Downloaded from http://linuxwireless.org/en/users/Drivers/carl9170

Licence: GPLv2

--------------------------------------------------------------------------

BIN
carl9170-1.fw View File


+ 19
- 0
carl9170fw/CMakeLists.txt View File

@@ -0,0 +1,19 @@
cmake_minimum_required(VERSION 2.8)

project(carl9170)

#if you don't want the full compiler output, remove the following line
#set(CMAKE_VERBOSE_MAKEFILE ON)

include("config.cmake")

add_subdirectory(carlfw)

if (CONFIG_CARL9170FW_BUILD_MINIBOOT)
add_subdirectory(minifw)
endif (CONFIG_CARL9170FW_BUILD_MINIBOOT)

if (CONFIG_CARL9170FW_BUILD_TOOLS)
add_subdirectory(tools)
endif (CONFIG_CARL9170FW_BUILD_TOOLS)


+ 19
- 0
carl9170fw/COPYRIGHT View File

@@ -0,0 +1,19 @@
Atheros carl9170 firmware - used by the ar9170 wireless device

Copyright (c) 2000-2005 ZyDAS Technology Corporation
Copyright (c) 2007-2009 Atheros Communications, Inc.
Copyright (c) 2009-2011 Christian Lamparter <chunkeey@googlemail.com>

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.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

+ 339
- 0
carl9170fw/GPL View File

@@ -0,0 +1,339 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991

Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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 Lesser 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.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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 Lesser General
Public License instead of this License.

+ 5
- 0
carl9170fw/Kconfig View File

@@ -0,0 +1,5 @@
mainmenu "CARL9170 Firmware Configuration"

source "carlfw/Kconfig"
source "minifw/Kconfig"
source "tools/Kconfig"

+ 43
- 0
carl9170fw/README View File

@@ -0,0 +1,43 @@
Community AR9170 Linux firmware
-----------------------

This is the firmware for the Atheros ar9170 802.11n devices.

To build the firmware you will need an SH-2 toolchain.
You can build your own toolchain:

make -C toolchain

but be aware that this will take some time and requires
about 1.2 GiB disk space.

The resulting firmware, carl9170.fw, can be used only
with the carl9170 Linux driver.

After getting a toolchain, you will need to get more
tools & libs:

* gcc 4.4+

* gperf, bison/flex

* cmake 2.8.0+

* libusb 1.0+

* SDL SDK 1.2.13+

afterwards, simply execute:

autogen.sh

to start the configuration and build process.

if you want to "install" your own firmware, you can either
do this manually, or by executing:
autogen.sh install

This will place a copy with the right filename [adds API rev]
into /lib/firmware/[the default path on most Distributions].


+ 47
- 0
carl9170fw/autogen.sh View File

@@ -0,0 +1,47 @@
#!/bin/bash

set -e

case "$1" in
config)
echo "Configuring..."
pushd config
cmake .
make
popd
config/conf Kconfig
cmake .
;;

compile)
echo "Compile time..."
make
;;

install)
if [ ! -e .config ]; then
exit 1
fi

. ./.config
make

echo -n "Installing firmware..."
if [ "$CONFIG_CARL9170FW_BUILD_TOOLS" = "y" ] &&
[ "$CONFIG_CARL9170FW_BUILD_MINIBOOT" = "y" ]; then
echo -n "Apply miniboot..."
tools/src/miniboot a carlfw/carl9170.fw minifw/miniboot.fw
fi

sudo install -m 644 carlfw/carl9170.fw \
/lib/firmware/carl9170-$CONFIG_CARL9170FW_RELEASE_VERSION.fw
echo "done."
;;

*)
$0 config
$0 compile
;;


esac

+ 67
- 0
carl9170fw/carlfw/CMakeLists.txt View File

@@ -0,0 +1,67 @@
cmake_minimum_required(VERSION 2.8)

project(carl9170.fw)

include("../extra/sh-elf-linux.cmake")
include("../config.cmake")

set(CARLFW_CFLAGS_WARNING "-W -Wall -Wextra -Wunreachable-code -Winline -Wlogical-op -Wno-packed-bitfield-compat -Winit-self -Wshadow -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wformat=2 -Wcast-align -Wmissing-format-attribute -Wmissing-prototypes -Wtype-limits -Wmissing-declarations -Wmissing-noreturn -Wredundant-decls -Wnested-externs -Wdisabled-optimization -Wpointer-arith -Wvolatile-register-var -Waddress -Wbad-function-cast -Wunsafe-loop-optimizations")
set(CARLFW_CFLAGS_EXTRA "-mbitops -std=gnu99 -ffunction-sections -Wframe-larger-than=128 -Werror")
set(CARLFW_CFLAGS_DEF "-D__CARL9170FW__")
if (CONFIG_CARL9170FW_AGGRESSIVE_CFLAGS)
set(CARLFW_CFLAGS_AGGRESSIVE "-fomit-frame-pointer -fsee -frename-registers -ftree-vectorize -flto -fstrict-volatile-bitfields -fmodulo-sched")
endif (CONFIG_CARL9170FW_AGGRESSIVE_CFLAGS)

include_directories (../include/linux ../include/shared ../include include)

set(carl9170_main_src src/main.c src/wlan.c src/fw.c src/gpio.c
src/cmd.c src/uart.c src/dma.c src/hostif.c src/reboot.S
src/printf.c src/rf.c src/cam.c src/wol.c)

set(carl9170_lib_src src/ashlsi3.S src/memcpy.S src/memset.S src/udivsi3_i4i-Os.S)
set(carl9170_usb_src usb/main.c usb/usb.c usb/fifo.c)

set(carl9170_src ${carl9170_main_src} ${carl9170_lib_src} ${carl9170_usb_src})

set_source_files_properties(src/ashlsi3.S PROPERTIES LANGUAGE C)
set_source_files_properties(src/memcpy.S PROPERTIES LANGUAGE C)
set_source_files_properties(src/memset.S PROPERTIES LANGUAGE C)
set_source_files_properties(src/reboot.S PROPERTIES LANGUAGE C)
set_source_files_properties(src/udivsi3_i4i-Os.S PROPERTIES LANGUAGE C)

add_executable(carl9170.elf ${carl9170_src})

set_target_properties(carl9170.elf PROPERTIES LINKER_LANGUAGE C)

set_target_properties(carl9170.elf PROPERTIES COMPILE_FLAGS
" ${CARLFW_CFLAGS_DEF} ${CARLFW_CFLAGS_EXTRA} ${CARLFW_CFLAGS_AGGRESSIVE} ${CARLFW_CFLAGS_WARNING}")
set_target_properties(carl9170.elf PROPERTIES LINK_FLAGS "-Tcarl9170.lds")



add_custom_target(firmware ALL)

add_custom_command(
SOURCE carl9170.elf
COMMAND ${OBJCOPY}
ARGS --strip-unneeded -O binary -R .sram -R .eeprom -R .fwdsc carl9170.elf carl9170.bin
TARGET firmware
OUTPUTS carl9170.bin)

add_custom_command(
SOURCE carl9170.elf
COMMAND ${OBJCOPY}
ARGS --strip-unneeded -O binary -j .fwdsc carl9170.elf carl9170.dsc
TARGET firmware
OUTPUTS carl9170.dsc)

add_custom_command(
SOURCE firmware
TARGET firmware
COMMAND cat
ARGS "carl9170.bin" "carl9170.dsc" > "carl9170.fw"
DEPENDS carl9170.elf carl9170.bin carl9170.dsc
OUTPUTS carl9170.fw)

SET_DIRECTORY_PROPERTIES(
PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "carl9170.fw")

+ 233
- 0
carl9170fw/carlfw/Kconfig View File

@@ -0,0 +1,233 @@
menu "General"

config CARL9170FW_RELEASE_VERSION
int
default 1

menu "Selectable Hardware Options"

choice
prompt "Receiver Max. Frame Length"
default CARL9170FW_RX_FRAME_LEN_8192

config CARL9170FW_RX_FRAME_LEN_4096
bool "4096"

config CARL9170FW_RX_FRAME_LEN_8192
bool "8192"

config CARL9170FW_RX_FRAME_LEN_16384
bool "16384"

config CARL9170FW_RX_FRAME_LEN_32768
bool "32768"

endchoice

config CARL9170FW_RX_FRAME_LEN
int
default 4096 if CARL9170FW_RX_FRAME_LEN_4096
default 8192 if CARL9170FW_RX_FRAME_LEN_8192
default 16384 if CARL9170FW_RX_FRAME_LEN_16384
default 32768 if CARL9170FW_RX_FRAME_LEN_32768

config CARL9170FW_GPIO_INTERRUPT
def_bool y
prompt "GPIO Software Interrupt"
---help---
When this option is enabled, the firmware will poll the GPIO
registers and reports to the driver whenever the GPIO state
has changed from a previous state.

Note: This feature is necessary to monitor the WPS button,
if you have one on your device, then say Y.

config CARL9170FW_SECURITY_ENGINE
def_bool y
prompt "Support Hardware Crypto Engine"
---help---
This options controls if the firmware will allow the driver
to program the security engine / CAM through a firmware
interface.

Say Y. Unless you want to do the en- and decryption for
CCMP(AES), TKIP/WEP(RC4) in the application anyway.

config CARL9170FW_RADIO_FUNCTIONS
def_bool y
prompt "Enable Firmware-supported Radio/RF functions"
---help---
Some PHY/RF functions (e.g.: AGC and Noise calibration) need
to be done in the firmware.

Say Y, unless you really don't need the Radio/RF for
your project.

endmenu

menu "802.11 Firmware Features"

config CARL9170FW_CAB_QUEUE
def_bool y
prompt "Support software-based Content after Beacon Queue"
---help---
This (software) queue is used to send any broad-/multi-cast buffered
frames after the next DTIM beacon.

This feature is required for Accesspoint mode operation.

Say Y.

endmenu

source "carlfw/usb/Kconfig"

menu "Experimental, Unstable & Testing Extensions"

config CARL9170FW_PRINTF
def_bool y
prompt "Advanced printf"
depends on CARL9170FW_DEBUG_UART || CARL9170FW_DEBUG_USB
---help---
Advanced printf (very useful for debugging purposes)
The formats supported by this implementation are:
'd' 'u' 'c' 's' 'x' 'X' 'p'.

Note: If this option is disabled, the firmware will be only
capable of reported _preformated_ string.

config CARL9170FW_EXPERIMENTAL
def_bool y
prompt "Experimental Features"

config CARL9170FW_WOL_OPTION
def_bool n
prompt "Wakeup on WLAN"
depends on CARL9170FW_EXPERIMENTAL
---help---
With this option enabled, the firmware can wake-up
suspended hosts... As long as they fully support
USB remote wakeup.

config CARL9170FW_WOL
def_bool n
depends on CARL9170FW_WOL_OPTION

config CARL9170FW_WOL_NL80211_TRIGGERS
def_bool n
prompt "Standard NL80211 wakeup triggers"
depends on CARL9170FW_WOL_OPTION
select CARL9170FW_WOL
---help---
Available triggers:
* Magic Packet(tm) pattern
* disconnect event

config CARL9170FW_WOL_PROBE_REQUEST
def_bool n
prompt "Probe Request"
depends on CARL9170FW_WOL_OPTION
select CARL9170FW_WOL
---help---
Scan probe requests for a given SSID.

config CARL9170FW_WOL_PROBE_REQUEST_SSID
string
prompt "Wakeup on WLAN SSID"
default "CARL9170_WAKEUP"
depends on CARL9170FW_WOL_PROBE_REQUEST

config CARL9170FW_VIFS_NUM
default 1
int
prompt "Number of additional pseudo virtual interfaces"
depends on CARL9170FW_EXPERIMENTAL

config CARL9170FW_FW_MAC_RESET
def_bool y
prompt "Firmware MAC Chip recovery"
depends on CARL9170FW_EXPERIMENTAL

config CARL9170FW_NOISY_MAC_RESET
def_bool n
prompt "Notify MAC RESET events"
depends on CARL9170FW_FW_MAC_RESET

config CARL9170FW_BROKEN_FEATURES
def_bool n
prompt "Broken Featurs"

config CARL9170FW_DEBUG
def_bool n
depends on CARL9170FW_BROKEN_FEATURES && CARL9170FW_PRINTF
prompt "Enable verbose debugging messages"

config CARL9170FW_DEBUG_LED_HEARTBEAT
def_bool n
prompt "LED Heartbeat"
depends on CARL9170FW_BROKEN_FEATURES
---help---
This option conflicts with the application's LED code.
Also, it assumes that you have two LEDs, which is not
necessarily true.

config CARL9170FW_DEBUG_UART
def_bool n
prompt "Pass debug messages through Highspeed UART"
depends on CARL9170FW_BROKEN_FEATURES
---help---
This option allows the firmware to send BUG/ERR/INFO/DBG and
hexdumps through the UART _as well_. However, first: you must
connect a working logger.

config CARL9170FW_WATCHDOG_BUTTON
def_bool n
depends on CARL9170FW_BROKEN && CARL9170FW_GPIO_INTERRUPT
prompt "Trigger Watchdog by pressing the WPS button"

choice CARL9170FW_UART_CLOCK
prompt "UART Clock"
depends on CARL9170FW_DEBUG_UART
default CARL9170FW_UART_CLOCK_40M

config CARL9170FW_UART_CLOCK_25M
bool "25"

config CARL9170FW_UART_CLOCK_40M
bool "40"

endchoice

config CARL9170FW_UNUSABLE
def_bool y
depends on CARL9170FW_BROKEN || CARL9170FW_DEBUG

config CARL9170FW_USB_MODESWITCH
def_bool n
prompt "USB 1.1 / 2.0 switching support"
depends on CARL9170FW_BROKEN_FEATURES
---help---
Mostly implemented, but untested and some serious
doubts remain.

config CARL9170FW_DMA_QUEUE_BUMP
def_bool n
prompt "Bump a stuck TX queue before doing a MAC reset"
depends on CARL9170FW_BROKEN_FEATURES

menu "Build Options"
config CARL9170FW_AGGRESSIVE_CFLAGS
def_bool y
prompt "Enable aggressive size optimization"
---help---
This option adds several more optimization compiler flags,
which can greatly reduce the firmware size... at the expense
of machine-code readability.

Say Y. Else the firmware might not fit onto the device!

endmenu

endmenu

endmenu

+ 59
- 0
carl9170fw/carlfw/carl9170.lds View File

@@ -0,0 +1,59 @@
/*
* The carl9170 firwmare gets copied into the device's
* Program RAM (pram), which has a size of 16K, but
* also has to accomodate the stack the device uses,
* which starts at the top of the 16k, so we pretend
* that we just have 16256 (16k - 128) of pram.
*
* This section documents some of the other areas
* mapped into the firmware processor's address space
* as well.
*/

ENTRY(_start);

MEMORY
{
eeprom : ORIGIN = 0x000000, LENGTH = 1024k
sram : ORIGIN = 0x100000, LENGTH = 96k
uart : ORIGIN = 0x1c0000, LENGTH = 4k
timer : ORIGIN = 0x1c1000, LENGTH = 4k
vflash : ORIGIN = 0x1c2000, LENGTH = 4k
wlan : ORIGIN = 0x1c3000, LENGTH = 4k
pci2ahb : ORIGIN = 0x1c4000, LENGTH = 4k
security : ORIGIN = 0x1c5000, LENGTH = 4k
gpio : ORIGIN = 0x1d0000, LENGTH = 4k
memctl : ORIGIN = 0x1d1000, LENGTH = 4k
irqctl : ORIGIN = 0x1d2000, LENGTH = 4k
usb : ORIGIN = 0x1e1000, LENGTH = 4k
pta : ORIGIN = 0x1e2000, LENGTH = 4k
pram : ORIGIN = 0x200000, LENGTH = 16256
bogus : ORIGIN = 0x300000, LENGTH = 8k
}

SECTIONS
{
.eeprom : { *(.eeprom*) } > eeprom
.sram : { *(.sram*) } > sram

/*
* The ar9170 boot code will execute the code
* at address 0x04 from the loaded firmware as
* such we must ensure our starting routine
* is kept at that address.
*/
.padding : {
/* NOP NOP just in case */
LONG(0x00090009)
} > pram

.boot : { *(.boot) } > pram
/* anything else can be anywhere */

.text : { *(.text*) } > pram
.rodata : { *(.rodata*) } > pram
.bss : { *(.bss) } > pram
.data : { *(.data*) } > pram

.fwdsc : { KEEP(*(.fwdsc)) } > bogus
}

+ 49
- 0
carl9170fw/carlfw/include/cam.h View File

@@ -0,0 +1,49 @@
/*
* carl9170 firmware - used by the ar9170 wireless device
*
* CAM (Security Engine) definitions
*
* Copyright (c) 2000-2005 ZyDAS Technology Corporation
* Copyright (c) 2007-2009 Atheros Communications, Inc.
* Copyright 2009 Johannes Berg <johannes@sipsolutions.net>
* Copyright 2009-2011 Christian Lamparter <chunkeey@googlemail.com>
*
* 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.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#ifndef __CARL9170FW_CAM_H
#define __CARL9170FW_CAM_H

#include "config.h"
#include "cmd.h"

#ifdef CONFIG_CARL9170FW_SECURITY_ENGINE

#define ENCRY_TYPE_START_ADDR 24
#define DEFAULT_ENCRY_TYPE 26
#define KEY_START_ADDR 27
#define STA_KEY_START_ADDR 155
#define COUNTER_START_ADDR 163
#define STA_COUNTER_START_ADDR 165

/* CAM */
#define MIC_FINISH 0x1

void set_key(const struct carl9170_set_key_cmd *key);
void disable_key(const struct carl9170_disable_key_cmd *key);

#endif /* CONFIG_CARL9170FW_SECURITY_ENGINE */

#endif /* __CARL9170FW_CAM_H */

+ 222
- 0
carl9170fw/carlfw/include/carl9170.h View File

@@ -0,0 +1,222 @@
/*
* carl9170 firmware - used by the ar9170 wireless device
*
* Firmware context definition
*
* Copyright 2009-2011 Christian Lamparter <chunkeey@googlemail.com>
*
* 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.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#ifndef __CARL9170FW_CARL9170_H
#define __CARL9170FW_CARL9170_H

#include "generated/autoconf.h"
#include "version.h"
#include "config.h"
#include "types.h"
#include "compiler.h"
#include "fwcmd.h"
#include "hw.h"
#include "dma.h"
#include "usb.h"
#include "cmd.h"

struct carl9170_bar_ctx {
uint8_t ta[6];
uint8_t ra[6];
__le16 start_seq_num;
__le16 control;
};

#ifdef CONFIG_CARL9170FW_CAB_QUEUE
enum carl9170_cab_trigger {
CARL9170_CAB_TRIGGER_EMPTY = 0,
CARL9170_CAB_TRIGGER_ARMED = BIT(0),
CARL9170_CAB_TRIGGER_DEFER = BIT(1),
};
#endif /* CONFIG_CARL9170FW_CAB_QUEUE */

enum carl9170_ep0_action {
CARL9170_EP0_NO_ACTION = 0,
CARL9170_EP0_STALL = BIT(0),
CARL9170_EP0_TRIGGER = BIT(1),
};

enum carl9170_mac_reset_state {
CARL9170_MAC_RESET_OFF = 0,
CARL9170_MAC_RESET_ARMED,
CARL9170_MAC_RESET_RESET,
CARL9170_MAC_RESET_FORCE,
};

enum carl9170_suspend_mode {
CARL9170_HOST_AWAKE = 0,
CARL9170_HOST_SUSPENDED,
CARL9170_AWAKE_HOST,
};

enum carl9170_phy_state {
CARL9170_PHY_OFF = 0,
CARL9170_PHY_ON
};

typedef void (*fw_desc_callback_t)(void *, const bool);

/*
* This platform - being an odd 32-bit architecture - prefers to
* have 32-Bit variables.
*/

struct firmware_context_struct {
/* timer / clocks */
unsigned int ticks_per_usec;
unsigned int counter; /* main() cycles */

/* misc */
unsigned int watchdog_enable;
unsigned int reboot;
unsigned int suspend_mode;

struct {
/* Host Interface DMA queues */
struct dma_queue up_queue; /* used to send frames to the host */
struct dma_queue down_queue; /* stores incoming frames from the host */
} pta;

struct {
/* Hardware DMA queues */
struct dma_queue tx_queue[__AR9170_NUM_TX_QUEUES]; /* wlan tx queue */
struct dma_queue tx_retry;
struct dma_queue rx_queue; /* wlan rx queue */

/* tx aggregate scheduling */
struct carl9170_tx_superframe *ampdu_prev[__AR9170_NUM_TX_QUEUES];

/* Hardware DMA queue unstuck/fix detection */
unsigned int last_super_num[__AR9170_NUM_TX_QUEUES];
struct carl9170_tx_superframe *last_super[__AR9170_NUM_TX_QUEUES];
unsigned int mac_reset;
unsigned int soft_int;

/* rx filter */
unsigned int rx_filter;

/* tx sequence control counters */
unsigned int sequence[CARL9170_INTF_NUM];

#ifdef CONFIG_CARL9170FW_CAB_QUEUE
/* CAB */
struct dma_queue cab_queue[CARL9170_INTF_NUM];
unsigned int cab_queue_len[CARL9170_INTF_NUM];
unsigned int cab_flush_time;
enum carl9170_cab_trigger cab_flush_trigger[CARL9170_INTF_NUM];
#endif /* CONFIG_CARL9170FW_CAB_QUEUE */

/* tx status */
unsigned int tx_status_pending,
tx_status_head_idx,
tx_status_tail_idx;
struct carl9170_tx_status tx_status_cache[CARL9170_TX_STATUS_NUM];

/* internal descriptor for use within the service routines */
struct dma_desc *fw_desc;
unsigned int fw_desc_available;
void *fw_desc_data;
fw_desc_callback_t fw_desc_callback;

/* BA(R) Request Handler */
struct carl9170_bar_ctx ba_cache[CONFIG_CARL9170FW_BACK_REQS_NUM];
unsigned int ba_tail_idx,
ba_head_idx,
queued_ba;

unsigned int queued_bar;
} wlan;

struct {
unsigned int config,
interface_setting,
alternate_interface_setting,
device_feature;
enum carl9170_ep0_action ep0_action;

void *ep0_txrx_buffer;
unsigned int ep0_txrx_len,
ep0_txrx_pos;

struct ar9170_usb_config *cfg_desc;
struct ar9170_usb_config *os_cfg_desc;

/*
* special buffers for command & response handling
*
* the firmware uses a sort of ring-buffer to communicate
* to the host.
*/
unsigned int int_pending,
int_desc_available,
int_head_index,
int_tail_index;
struct dma_desc *int_desc;
struct carl9170_rsp int_buf[CARL9170_INT_RQ_CACHES];

#ifdef CONFIG_CARL9170FW_DEBUG_USB
/* USB printf */
unsigned int put_index;
uint8_t put_buffer[CARL9170_MAX_CMD_PAYLOAD_LEN];
#endif /* CONFIG_CARL9170FW_DEBUG_USB */

} usb;

struct {
#ifdef CONFIG_CARL9170FW_RADIO_FUNCTIONS
/* (cached) ar9170_rf_init */

/* PHY/RF state */
unsigned int frequency;
unsigned int ht_settings;

enum carl9170_phy_state state;
struct carl9170_psm psm;
#endif /* CONFIG_CARL9170FW_RADIO_FUNCTIONS */
} phy;

unsigned int tally_clock;
struct carl9170_tally_rsp tally;
unsigned int tx_time;

#ifdef CONFIG_CARL9170FW_WOL
struct {
struct carl9170_wol_cmd cmd;
unsigned int last_beacon;
unsigned int lost_null;
unsigned int last_null;
bool wake_up;
} wol;
#endif /* CONFIG_CARL9170FW_WOL */

#ifdef CONFIG_CARL9170FW_GPIO_INTERRUPT
struct carl9170_gpio cached_gpio_state;
#endif /*CONFIG_CARL9170FW_GPIO_INTERRUPT */
};

/*
* global firmware context struct.
*
* NOTE: This struct will zeroed out in start()
*/
extern struct firmware_context_struct fw;
#endif /* __CARL9170FW_CARL9170_H */

+ 55
- 0
carl9170fw/carlfw/include/cmd.h View File

@@ -0,0 +1,55 @@
/*
* carl9170 firmware - used by the ar9170 wireless device
*
* Firmware command interface definition
*
* Copyright (c) 2000-2005 ZyDAS Technology Corporation
* Copyright (c) 2007-2009 Atheros Communications, Inc.
* Copyright 2009 Johannes Berg <johannes@sipsolutions.net>
* Copyright 2009-2011 Christian Lamparter <chunkeey@googlemail.com>
*
* 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.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#ifndef __CARL9170FW_CMD_H
#define __CARL9170FW_CMD_H

#include "config.h"
#include "compiler.h"
#include "types.h"

#include "fwcmd.h"

static inline void __check(void)
{
BUILD_BUG_ON(sizeof(struct carl9170_cmd) != CARL9170_MAX_CMD_LEN);
BUILD_BUG_ON(sizeof(struct carl9170_rsp) != CARL9170_MAX_CMD_LEN);
BUILD_BUG_ON(sizeof(struct carl9170_set_key_cmd) != CARL9170_SET_KEY_CMD_SIZE);
BUILD_BUG_ON(sizeof(struct carl9170_disable_key_cmd) != CARL9170_DISABLE_KEY_CMD_SIZE);
BUILD_BUG_ON(sizeof(struct carl9170_rf_init) != CARL9170_RF_INIT_SIZE);
BUILD_BUG_ON(sizeof(struct carl9170_rf_init_result) != CARL9170_RF_INIT_RESULT_SIZE);
BUILD_BUG_ON(sizeof(struct carl9170_psm) != CARL9170_PSM_SIZE);
BUILD_BUG_ON(sizeof(struct carl9170_tsf_rsp) != CARL9170_TSF_RSP_SIZE);
BUILD_BUG_ON(sizeof(struct carl9170_bcn_ctrl_cmd) != CARL9170_BCN_CTRL_CMD_SIZE);
BUILD_BUG_ON(sizeof(struct carl9170_tx_status) != CARL9170_TX_STATUS_SIZE);
BUILD_BUG_ON(sizeof(struct _carl9170_tx_status) != CARL9170_TX_STATUS_SIZE);
BUILD_BUG_ON(sizeof(struct carl9170_gpio) != CARL9170_GPIO_SIZE);
BUILD_BUG_ON(sizeof(struct carl9170_rx_filter_cmd) != CARL9170_RX_FILTER_CMD_SIZE);
BUILD_BUG_ON(sizeof(struct carl9170_wol_cmd) != CARL9170_WOL_CMD_SIZE);
}

void handle_cmd(struct carl9170_rsp *resp);

#endif /* __CARL9170FW_CMD_H */

+ 64
- 0
carl9170fw/carlfw/include/config.h View File

@@ -0,0 +1,64 @@
/*
* 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.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#include "generated/autoconf.h"
#include "version.h"
#include "types.h"
#include "compiler.h"
#include "fwcmd.h"
#include "hw.h"

#ifndef __CARL9170FW_CONFIG_H
#define __CARL9170FW_CONFIG_H

#define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)

#if GCC_VERSION < 40400
# error "This firmware will not work if it is compiled with gcc versions < 4.4"
# error "See: http://gcc.gnu.org/gcc-4.4/changes.html / Caveats No. 4"
#endif

#if ((defined CONFIG_CARL9170FW_PRINTF) && \
(!defined CONFIG_CARL9170FW_DEBUG_USB) && \
(!defined CONFIG_CARL9170FW_DEBUG_UART))
# warning "You have disabled all debug message transports."
# warning "However CONFIG_CARL9170FW_PRINTF is still set..."
# warning "Which is a waste of firmware space, if you ask me."
#endif

#define CARL9170_TX_STATUS_NUM (CARL9170_RSP_TX_STATUS_NUM)
#define CARL9170_INT_RQ_CACHES 16
#define AR9170_INT_MAGIC_HEADER_SIZE 12
#define CARL9170_TBTT_DELTA (CARL9170_PRETBTT_KUS + 1)

#define CARL9170_GPIO_MASK (AR9170_GPIO_PORT_WPS_BUTTON_PRESSED)

#ifdef CONFIG_CARL9170FW_VIFS_NUM
#define CARL9170_INTF_NUM (1 + CONFIG_CARL9170FW_VIFS_NUM)
#else
#define CARL9170_INTF_NUM (1)
#endif /* CONFIG_CARL9170FW_VIFS_NUM */

#define CONFIG_CARL9170FW_BACK_REQS_NUM 4

static inline void __config_check(void)
{
BUILD_BUG_ON(!CARL9170_TX_STATUS_NUM);
BUILD_BUG_ON(CARL9170_INTF_NUM < 1);
BUILD_BUG_ON(CARL9170_INTF_NUM >= AR9170_MAX_VIRTUAL_MAC);
}

#endif /* __CARL9170FW_CONFIG_H */

+ 349
- 0
carl9170fw/carlfw/include/dma.h View File

@@ -0,0 +1,349 @@
/*
* carl9170 firmware - used by the ar9170 wireless device
*
* This module contains DMA descriptor related definitions.
*
* Copyright (c) 2000-2005 ZyDAS Technology Corporation
* Copyright (c) 2007-2009 Atheros Communications, Inc.
* Copyright 2009 Johannes Berg <johannes@sipsolutions.net>
* Copyright 2009-2011 Christian Lamparter <chunkeey@googlemail.com>
*
* 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.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#ifndef __CARL9170FW_DMA_H
#define __CARL9170FW_DMA_H

#include "config.h"
#include "types.h"
#include "compiler.h"
#include "hw.h"
#include "ieee80211.h"
#include "wlan.h"

struct dma_desc {
volatile uint16_t status; /* Descriptor status */
volatile uint16_t ctrl; /* Descriptor control */
volatile uint16_t dataSize; /* Data size */
volatile uint16_t totalLen; /* Total length */
struct dma_desc *lastAddr; /* Last address of this chain */
union {
uint8_t *_dataAddr; /* Data buffer address */
void *dataAddr;
} __packed;
struct dma_desc *nextAddr; /* Next TD address */
} __packed __aligned(4);

/* Up, Dn, 5x Tx, retry, Rx, [USB Int], (CAB), FW */
#define AR9170_TERMINATOR_NUMBER_B 10

#define AR9170_TERMINATOR_NUMBER_INT 1

#ifdef CONFIG_CARL9170FW_CAB_QUEUE
#define AR9170_TERMINATOR_NUMBER_CAB CARL9170_INTF_NUM
#else
#define AR9170_TERMINATOR_NUMBER_CAB 0
#endif /* CONFIG_CARL9170FW_CAB_QUEUE */

#define AR9170_TERMINATOR_NUMBER (AR9170_TERMINATOR_NUMBER_B + \
AR9170_TERMINATOR_NUMBER_INT + \
AR9170_TERMINATOR_NUMBER_CAB)

#define AR9170_BLOCK_SIZE (256 + 64)

#define AR9170_DESCRIPTOR_SIZE (sizeof(struct dma_desc))

struct ar9170_tx_ba_frame {
struct ar9170_tx_hwdesc hdr;
struct ieee80211_ba ba;
} __packed;

struct carl9170_tx_ba_superframe {
struct carl9170_tx_superdesc s;
struct ar9170_tx_ba_frame f;
} __packed;

struct ar9170_tx_null_frame {
struct ar9170_tx_hwdesc hdr;
struct ieee80211_hdr null;
} __packed;

struct carl9170_tx_null_superframe {
struct carl9170_tx_superdesc s;
struct ar9170_tx_null_frame f;
} __packed;

#define CARL9170_BA_BUFFER_LEN (__roundup(sizeof(struct carl9170_tx_ba_superframe), 16))
#define CARL9170_RSP_BUFFER_LEN AR9170_BLOCK_SIZE

struct carl9170_sram_reserved {
union {
uint32_t buf[CARL9170_BA_BUFFER_LEN / sizeof(uint32_t)];
struct carl9170_tx_ba_superframe ba;
} ba;

union {
uint32_t buf[CARL9170_MAX_CMD_LEN / sizeof(uint32_t)];
struct carl9170_cmd cmd;

#ifdef CONFIG_CARL9170FW_WOL
struct carl9170_tx_null_superframe null;
#endif /* CONFIG_CARL9170FW_WOL */
} cmd;

union {
uint32_t buf[CARL9170_RSP_BUFFER_LEN / sizeof(uint32_t)];
struct carl9170_rsp rsp;
} rsp;

union {
uint32_t buf[CARL9170_INTF_NUM][AR9170_MAC_BCN_LENGTH_MAX / sizeof(uint32_t)];
} bcn;
};

/*
* Memory layout in RAM:
*
* 0x100000 +--
* | terminator descriptors (dma_desc)
* | - Up (to USB host)
* | - Down (from USB host)
* | - TX (5x, to wifi)
* | - AMPDU TX retry
* | - RX (from wifi)
* | - CAB Queue
* | - FW cmd & req descriptor
* | - BlockAck descriptor
* | total: AR9170_TERMINATOR_NUMBER
* +--
* | block descriptors (dma_desc)
* | (AR9170_BLOCK_NUMBER)
* AR9170_BLOCK_BUFFER_BASE +-- align to multiple of 64
* | block buffers (AR9170_BLOCK_SIZE each)
* | (AR9170_BLOCK_NUMBER)
* approx. 0x117c00 +--
* | BA buffer (128 bytes)
* +--
* | CMD buffer (128 bytes)
* | - used as NULLFRAME buffer (128 bytes) for WOL
* +--
* | RSP buffer (320 bytes)
* +--
* | BEACON buffer (256 bytes)
* +--
* | unaccounted space / padding
* +--
* 0x18000
*/

#define CARL9170_SRAM_RESERVED (sizeof(struct carl9170_sram_reserved))

#define AR9170_FRAME_MEMORY_SIZE (AR9170_SRAM_SIZE - CARL9170_SRAM_RESERVED)

#define BLOCK_ALIGNMENT 64

#define NONBLOCK_DESCRIPTORS_SIZE \
(AR9170_DESCRIPTOR_SIZE * (AR9170_TERMINATOR_NUMBER))

#define NONBLOCK_DESCRIPTORS_SIZE_ALIGNED \
(ALIGN(NONBLOCK_DESCRIPTORS_SIZE, BLOCK_ALIGNMENT))

#define AR9170_BLOCK_NUMBER ((AR9170_FRAME_MEMORY_SIZE - NONBLOCK_DESCRIPTORS_SIZE_ALIGNED) / \
(AR9170_BLOCK_SIZE + AR9170_DESCRIPTOR_SIZE))

struct ar9170_data_block {
uint8_t data[AR9170_BLOCK_SIZE];
};

struct ar9170_dma_memory {
struct dma_desc terminator[AR9170_TERMINATOR_NUMBER];
struct dma_desc block[AR9170_BLOCK_NUMBER];
struct ar9170_data_block data[AR9170_BLOCK_NUMBER] __aligned(BLOCK_ALIGNMENT);
struct carl9170_sram_reserved reserved __aligned(BLOCK_ALIGNMENT);
};

extern struct ar9170_dma_memory dma_mem;

#define AR9170_DOWN_BLOCK_RATIO 2
#define AR9170_RX_BLOCK_RATIO 1
/* Tx 16*2 = 32 packets => 32*(5*320) */
#define AR9170_TX_BLOCK_NUMBER (AR9170_BLOCK_NUMBER * AR9170_DOWN_BLOCK_RATIO / \
(AR9170_RX_BLOCK_RATIO + AR9170_DOWN_BLOCK_RATIO))
#define AR9170_RX_BLOCK_NUMBER (AR9170_BLOCK_NUMBER - AR9170_TX_BLOCK_NUMBER)

/* Error code */
#define AR9170_ERR_FS_BIT 1
#define AR9170_ERR_LS_BIT 2
#define AR9170_ERR_OWN_BITS 3
#define AR9170_ERR_DATA_SIZE 4
#define AR9170_ERR_TOTAL_LEN 5
#define AR9170_ERR_DATA 6
#define AR9170_ERR_SEQ 7
#define AR9170_ERR_LEN 8

/* Status bits definitions */
/* Own bits definitions */
#define AR9170_OWN_BITS 0x3
#define AR9170_OWN_BITS_S 0
#define AR9170_OWN_BITS_SW 0x0
#define AR9170_OWN_BITS_HW 0x1
#define AR9170_OWN_BITS_SE 0x2

/* Control bits definitions */
#define AR9170_CTRL_TXFAIL 1
#define AR9170_CTRL_BAFAIL 2
#define AR9170_CTRL_FAIL (AR9170_CTRL_TXFAIL | AR9170_CTRL_BAFAIL)

/* First segament bit */
#define AR9170_CTRL_LS_BIT 0x100
/* Last segament bit */
#define AR9170_CTRL_FS_BIT 0x200

struct dma_queue {
struct dma_desc *head;
struct dma_desc *terminator;
};

#define DESC_PAYLOAD(a) ((void *)a->dataAddr)
#define DESC_PAYLOAD_OFF(a, offset) ((void *)((unsigned long)(a->_dataAddr) + offset))

struct dma_desc *dma_unlink_head(struct dma_queue *queue);
void dma_init_descriptors(void);
void dma_reclaim(struct dma_queue *q, struct dma_desc *desc);
void dma_put(struct dma_queue *q, struct dma_desc *desc);

static inline __inline bool is_terminator(struct dma_queue *q, struct dma_desc *desc)
{
return q->terminator == desc;
}

static inline __inline bool queue_empty(struct dma_queue *q)
{
return q->head == q->terminator;
}

/*
* Get a completed packet with # descriptors. Return the first
* descriptor and pointer the head directly by lastAddr->nextAddr
*/
static inline __inline struct dma_desc *dma_dequeue_bits(struct dma_queue *q,
uint16_t bits)
{
struct dma_desc *desc = NULL;

if ((q->head->status & AR9170_OWN_BITS) == bits)
desc = dma_unlink_head(q);

return desc;
}

static inline __inline struct dma_desc *dma_dequeue_not_bits(struct dma_queue *q,
uint16_t bits)
{
struct dma_desc *desc = NULL;

/* AR9170_OWN_BITS_HW will be filtered out here too. */
if ((q->head->status & AR9170_OWN_BITS) != bits)
desc = dma_unlink_head(q);

return desc;
}

#define for_each_desc_bits(desc, queue, bits) \
while ((desc = dma_dequeue_bits(queue, bits)))

#define for_each_desc_not_bits(desc, queue, bits) \
while ((desc = dma_dequeue_not_bits(queue, bits)))

#define for_each_desc(desc, queue) \
while ((desc = dma_unlink_head(queue)))

#define __for_each_desc_bits(desc, queue, bits) \
for (desc = (queue)->head; \
(desc != (queue)->terminator && \
(desc->status & AR9170_OWN_BITS) == bits); \
desc = desc->lastAddr->nextAddr)

#define __while_desc_bits(desc, queue, bits) \
for (desc = (queue)->head; \
(!queue_empty(queue) && \
(desc->status & AR9170_OWN_BITS) == bits); \
desc = (queue)->head)

#define __for_each_desc_continue(desc, queue) \
for (; desc != (queue)->terminator; \
desc = (desc)->lastAddr->nextAddr)

#define __for_each_desc(desc, queue) \
for (desc = (queue)->head; \
desc != (queue)->terminator; \
desc = (desc)->lastAddr->nextAddr)

#define __for_each_desc_safe(desc, tmp, queue) \
for (desc = (queue)->head, tmp = desc->lastAddr->nextAddr; \
desc != (queue)->terminator; \
desc = tmp, tmp = tmp->lastAddr->nextAddr)

#define __while_subdesc(desc, queue) \
for (desc = (queue)->head; \
desc != (queue)->terminator; \
desc = (desc)->nextAddr)

static inline __inline unsigned int queue_len(struct dma_queue *q)
{
struct dma_desc *desc;
unsigned int i = 0;

__while_subdesc(desc, q)
i++;

return i;
}

/*
* rearm a completed packet, so it will be processed agian.
*/
static inline __inline void dma_rearm(struct dma_desc *desc)
{
/* Set OWN bit to HW */
desc->status = ((desc->status & (~AR9170_OWN_BITS)) |
AR9170_OWN_BITS_HW);
}

static inline __inline void dma_fix_downqueue(struct dma_desc *desc)
{
desc->status = AR9170_OWN_BITS_HW;
desc->ctrl = 0;
desc->dataSize = 0;
desc->totalLen = AR9170_BLOCK_SIZE;
desc->lastAddr = desc;
}

static inline void __check_desc(void)
{
struct ar9170_dma_memory mem;
BUILD_BUG_ON(sizeof(struct ar9170_data_block) != AR9170_BLOCK_SIZE);
BUILD_BUG_ON(sizeof(struct dma_desc) != 20);

BUILD_BUG_ON(sizeof(mem) > AR9170_SRAM_SIZE);

BUILD_BUG_ON(offsetof(struct carl9170_sram_reserved, ba.buf) & (BLOCK_ALIGNMENT - 1));
BUILD_BUG_ON(offsetof(struct carl9170_sram_reserved, cmd.buf) & (BLOCK_ALIGNMENT - 1));
BUILD_BUG_ON(offsetof(struct carl9170_sram_reserved, rsp.buf) & (BLOCK_ALIGNMENT - 1));
BUILD_BUG_ON(offsetof(struct carl9170_sram_reserved, bcn.buf) & (BLOCK_ALIGNMENT - 1));
BUILD_BUG_ON(sizeof(struct carl9170_tx_null_superframe) > CARL9170_MAX_CMD_LEN);
}

#endif /* __CARL9170FW_DMA_H */

+ 50
- 0
carl9170fw/carlfw/include/fwdsc.h View File

@@ -0,0 +1,50 @@
/*
* carl9170 firmware - used by the ar9170 wireless device
*
* Firmware definition
*
* Copyright 2009-2011 Christian Lamparter <chunkeey@googlemail.com>
*
* 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.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#ifndef __CARL9170FW_FWDSC_H
#define __CARL9170FW_FWDSC_H

#include "config.h"
#include "compiler.h"
#include "types.h"
#include "fwdesc.h"

struct carl9170_firmware_descriptor {
struct carl9170fw_otus_desc otus;
struct carl9170fw_txsq_desc txsq;
#ifdef CONFIG_CARL9170FW_WOL
struct carl9170fw_wol_desc wol;
#endif /* CONFIG_CARL9170FW_WOL */
struct carl9170fw_motd_desc motd;
struct carl9170fw_dbg_desc dbg;
struct carl9170fw_last_desc last;
} __packed;

extern const struct carl9170_firmware_descriptor carl9170fw_desc;

static inline void __check_fw(void)
{
BUILD_BUG_ON(sizeof(carl9170fw_desc) & 0x3);
BUILD_BUG_ON(sizeof(carl9170fw_desc) > CARL9170FW_DESC_MAX_LENGTH);
}

#endif /* __CARL9170FW_FWDSC_H */

+ 45
- 0
carl9170fw/carlfw/include/gpio.h View File

@@ -0,0 +1,45 @@
/*
* carl9170 firmware - used by the ar9170 wireless device
*
* GPIO definitions
*
* Copyright 2009-2011 Christian Lamparter <chunkeey@googlemail.com>
*
* 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.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#ifndef __CARL9170FW_GPIO_H
#define __CARL9170FW_GPIO_H

#include "config.h"
#include "hw.h"
#include "io.h"

static inline __inline void led_init(void)
{
set(AR9170_GPIO_REG_PORT_TYPE, 3);
}

static inline __inline void led_set(const unsigned int ledstate)
{
set(AR9170_GPIO_REG_PORT_DATA, ledstate);
}

#ifdef CONFIG_CARL9170FW_GPIO_INTERRUPT

void gpio_timer(void);

#endif /* CONFIG_CARL9170FW_GPIO_INTERRUPT */
#endif /* __CARL9170FW_GPIO_H */

+ 47
- 0
carl9170fw/carlfw/include/hostif.h View File

@@ -0,0 +1,47 @@
/*
* carl9170 firmware - used by the ar9170 wireless device
*
* HostIF definition
*
* Copyright (c) 2000-2005 ZyDAS Technology Corporation
* Copyright (c) 2007-2009 Atheros Communications, Inc.
* Copyright 2009 Johannes Berg <johannes@sipsolutions.net>
* Copyright 2009-2011 Christian Lamparter <chunkeey@googlemail.com>
*
* 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.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#ifndef __CARL9170FW_HOSTIF_H
#define __CARL9170FW_HOSTIF_H

#include "config.h"
#include "compiler.h"
#include "types.h"
#include "hw.h"
#include "io.h"

static inline __inline void down_trigger(void)
{
set(AR9170_PTA_REG_DN_DMA_TRIGGER, 1);
}

static inline __inline void up_trigger(void)
{
set(AR9170_PTA_REG_UP_DMA_TRIGGER, 1);
}

void handle_host_interface(void);

#endif /* __CARL9170FW_HOSTIF_H */

+ 153
- 0
carl9170fw/carlfw/include/io.h View File

@@ -0,0 +1,153 @@
/*
* 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.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#ifndef __CARL9170FW_IO_H
#define __CARL9170FW_IO_H

#include "config.h"
#include "types.h"
#include "compiler.h"

static inline __inline uint8_t readb(const volatile void *addr)
{
return *(const volatile uint8_t *) addr;
}

static inline __inline uint16_t readw(const volatile void *addr)
{
return *(const volatile uint16_t *) addr;
}

static inline __inline volatile void *readp(const volatile void *addr)
{
return *(volatile void **) addr;
}

static inline __inline uint32_t readl(const volatile void *addr)
{
return *(const volatile unsigned int *) addr;
}

static inline __inline void writeb(volatile void *addr, const volatile uint8_t val)
{
*(volatile uint8_t *) addr = val;
}

static inline __inline void writew(volatile void *addr, const volatile uint16_t val)
{
*(volatile uint16_t *) addr = val;
}

static inline __inline void writel(volatile void *addr, const volatile uint32_t val)
{
*(volatile uint32_t *) addr = val;
}

static inline __inline void __orl(volatile void *addr, const volatile uint32_t val)
{
*(volatile uint32_t *) addr |= val;
}

static inline __inline void __andl(volatile void *addr, const volatile uint32_t val)
{
*(volatile uint32_t *) addr &= val;
}

static inline __inline void __xorl(volatile void *addr, const volatile uint32_t val)
{
*(volatile uint32_t *) addr ^= val;
}

static inline __inline void __incl(volatile void *addr)
{
(*(volatile uint32_t *)addr)++;
}

static inline __inline uint32_t readl_async(const volatile void *addr)
{
uint32_t i = 0, read, tmp;

read = readl(addr);
do {
tmp = read;
tmp = readl(addr);
i++;
} while (tmp != read && i <= 10);

return read;
}

static inline __inline void set(const volatile uint32_t addr, const volatile uint32_t val)
{
writel((volatile void *) addr, val);
}

static inline __inline void orl(volatile uint32_t addr, const volatile uint32_t val)
{
__orl((volatile void *) addr, val);
}

static inline __inline void xorl(const volatile uint32_t addr, const volatile uint32_t val)
{
__xorl((volatile void *) addr, val);
}

static inline __inline void andl(const volatile uint32_t addr, const volatile uint32_t val)
{
__andl((volatile void *) addr, val);
}

static inline __inline void incl(const volatile uint32_t addr)
{
__incl((volatile void *) addr);
}

static inline __inline uint32_t get(const volatile uint32_t addr)
{
return readl((volatile void *) addr);
}

static inline __inline volatile void *getp(const volatile uint32_t addr)
{
return readp((const volatile void *) addr);
}

static inline __inline uint32_t get_async(const volatile uint32_t addr)
{
return readl_async((const volatile void *) addr);
}

static inline __inline void setb(const volatile uint32_t addr, const volatile uint8_t val)
{
writeb((volatile void *) addr, val);
}

static inline __inline uint8_t getb(const volatile uint32_t addr)
{
return readb((const volatile void *) addr);
}

static inline __inline void andb(const volatile uint32_t addr, const volatile uint8_t val)
{
setb(addr, getb(addr) & val);
}

static inline __inline void orb(const volatile uint32_t addr, const volatile uint32_t val)
{
setb(addr, getb(addr) | val);
}

#endif /* __CARL9170FW_IO_H */

+ 107
- 0
carl9170fw/carlfw/include/printf.h View File

@@ -0,0 +1,107 @@
/*
* carl9170 firmware - used by the ar9170 wireless device
*
* printf and his friends...
*
* Copyright (c) 2000-2005 ZyDAS Technology Corporation
* Copyright (c) 2007-2009 Atheros Communications, Inc.
* Copyright 2009 Johannes Berg <johannes@sipsolutions.net>
* Copyright 2009-2011 Christian Lamparter <chunkeey@googlemail.com>
*
* 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.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#ifndef __CARL9170FW_PRINTF_H
#define __CARL9170FW_PRINTF_H

#include <stdarg.h>
#include <string.h>
#include "config.h"
#include "carl9170.h"
#include "uart.h"
#include "fwcmd.h"

#ifdef CONFIG_CARL9170FW_PRINTF
void __attribute__((format (printf, 1, 2))) tfp_printf(const char *fmt, ...);

#define printf tfp_printf

#else
void __attribute__((format (printf, 1, 2))) min_printf(const char *fmt, ...);

#define printf min_printf
#endif /* CONFIG_CARL9170FW_PRINTF */

#define PRINT(fmt, args...) \
do { \
printf(fmt, ## args); \
} while (0)

#define INFO(fmt, args...) PRINT(fmt, ## args)

#define ERR(fmt, args...) PRINT(CARL9170_ERR_MAGIC fmt, ## args)

#ifdef CONFIG_CARL9170FW_DEBUG
#define DBG(fmt, args...) PRINT(fmt, ## args)
#else
#define DBG(...) do { } while (0);
#endif

/*
* NB: even though the MACRO is called "stall". It isn't supposed
* to stall since this will render the device unresponsive, until
* someone pulls the plug.
*/
#define STALL()

#define BUG(fmt, args...) \
do { \
PRINT(CARL9170_BUG_MAGIC" %s()@%d \"" fmt "\"" , \
__func__, __LINE__, ## args); \
STALL() \
} while (0);

#define BUG_ON(condition) \
({ \
int __ret = !!(condition); \
if (unlikely(!!(__ret))) \
BUG(#condition); \
(__ret); \
})

static inline __inline void putcharacter(const char c __unused)
{
#ifdef CONFIG_CARL9170FW_DEBUG_USB
usb_putc(c);
#endif /* CONFIG_CARL9170FW_DEBUG_USB */

#ifdef CONFIG_CARL9170FW_DEBUG_UART
uart_putc(c);
#endif /* CONFIG_CARL9170FW_DEBUG_UART */
}

static inline __inline void print_hex_dump(const void *buf __unused, int len __unused)
{
#ifdef CONFIG_CARL9170FW_DEBUG_USB
usb_print_hex_dump(buf, len);
#endif /* CONFIG_CARL9170FW_DEBUG_USB */

#ifdef CONFIG_CARL9170FW_DEBUG_UART
uart_print_hex_dump(buf, len);
#endif /* CONFIG_CARL9170FW_DEBUG_UART */
}

#endif /* __CARL9170FW_PRINTF_H */


+ 37
- 0
carl9170fw/carlfw/include/rf.h View File

@@ -0,0 +1,37 @@
/*
* carl9170 firmware - used by the ar9170 wireless device
*
* RF routine definitions
*
* Copyright (c) 2000-2005 ZyDAS Technology Corporation
* Copyright (c) 2007-2009 Atheros Communications, Inc.
* Copyright 2009 Johannes Berg <johannes@sipsolutions.net>
* Copyright 2009-2011 Christian Lamparter <chunkeey@googlemail.com>
*
* 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.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#ifndef __CARL9170FW_RF_H
#define __CARL9170FW_RF_H

#include "config.h"

#ifdef CONFIG_CARL9170FW_RADIO_FUNCTIONS
void rf_notify_set_channel(void);
void rf_cmd(const struct carl9170_cmd *cmd, struct carl9170_rsp *resp);
void rf_psm(void);
#endif /* CONFIG_CARL9170FW_RADIO_FUNCTIONS */

#endif /* __CARL9170FW_RF_H */

+ 82
- 0
carl9170fw/carlfw/include/rom.h View File

@@ -0,0 +1,82 @@
/*
* carl9170 firmware - used by the ar9170 wireless device
*
* ROM layout