/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Copyright (c) 2008 by Ben Taylor <bentaylor.solx86@gmail.com>
* Copyright (c) 2007 by Lukas Turek <turek@ksvi.mff.cuni.cz>
* Copyright (c) 2007 by Jiri Svoboda <jirik.svoboda@seznam.cz>
* Copyright (c) 2007 by Martin Krulis <martin.krulis@matfyz.cz>
* Copyright (c) 2006 by Damien Bergamini <damien.bergamini@free.fr>
* Copyright (c) 2006 by Florian Stoehr <ich@florian-stoehr.de>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
/*
* ZD1211 wLAN driver
* Device hardware control
*
* Control the ZD1211 chip and the RF chip.
*/
#include <sys/byteorder.h>
#include "zyd.h"
#include "zyd_reg.h"
/* io write sequences to initialize RF-independent PHY registers */
{
static const char *const zyd_rfs[] = {
"unknown", "unknown", "UW2451", "UCHIP", "AL2230",
"AL7230B", "THETA", "AL2210", "MAXIM_NEW", "GCT",
"PV2000", "RALINK", "INTERSIL", "RFMD", "MAXIM_NEW2",
"PHILIPS"
};
}
/*
* Read a 32-bit I/O register.
*
* sc soft state
* reg register number
* *val place to store the value
*/
{
if (result != USB_SUCCESS)
return (ZYD_FAILURE);
ZYD_WARN("ioread response doesn't match request\n");
ZYD_WARN("requested regs %04x, %04x; got %04x, %04x\n",
return (ZYD_FAILURE);
}
return (ZYD_SUCCESS);
}
/*
* Write a 32-bit I/O register.
*
* sc soft state
* reg register number
* val value to write
*/
{
return (result);
}
/*
* Read a 16-bit I/O register.
*
* sc soft state
* reg register number
* *val place to store the value
*/
{
if (result != USB_SUCCESS)
return (ZYD_FAILURE);
ZYD_WARN("ioread response doesn't match request\n");
ZYD_WARN("requested reg %04x; got %04x\n",
return (ZYD_FAILURE);
}
if (result != USB_SUCCESS)
return (ZYD_FAILURE);
return (ZYD_SUCCESS);
}
/*
* Write a 16-bit I/O register.
*
* sc soft state
* reg register number
* val value to write
*/
{
return (result);
}
/*
* Write an array of 16-bit registers.
*
* sc soft state
* *reqa array of register-value pairs
* n number of registers
*/
{
int i;
for (i = 0; i < n; i++) {
if (res != ZYD_SUCCESS)
return (ZYD_FAILURE);
}
return (ZYD_SUCCESS);
}
/*
* Lock PHY registers.
*/
static void
{
tmp &= ~ZYD_UNLOCK_PHY_REGS;
}
/*
* Unlock PHY registers.
*/
static void
{
}
/*
* Read MAC address from EEPROM.
*/
static zyd_res
{
return (ZYD_FAILURE);
return (ZYD_FAILURE);
return (ZYD_SUCCESS);
}
/*
* Write bits to RF configuration register.
*/
static zyd_res
{
int bit;
int i;
return (ZYD_FAILURE);
for (i = 0; i < bits; i++) {
}
if (res != ZYD_SUCCESS) {
ZYD_WARN("failed configuring rf register\n");
return (ZYD_FAILURE);
}
return (ZYD_SUCCESS);
}
/*
* Control the LEDs.
*/
static void
{
}
/*
* Set MAC address.
*/
static void
{
}
/*
* Read data from EEPROM.
*/
static void
{
int i;
/* read RF chip type */
/* read regulatory domain (currently unused) */
/* read Tx power calibration tables */
for (i = 0; i < 7; i++) {
}
}
{
int ures;
} else {
}
if (res != ZYD_SUCCESS) {
ZYD_WARN("failed to load firmware\n");
goto fail1;
}
/* set configuration 1 - required for later communication */
if (ures != USB_SUCCESS) {
goto fail1;
}
ZYD_WARN("failed to open pipes\n");
goto fail1;
}
ZYD_WARN("failed to start command IN polling\n");
goto fail2;
}
ZYD_WARN("failed to read MAC address\n");
goto fail3;
}
case ZYD_RF_AL2230:
case ZYD_RF_RFMD:
break;
default:
ZYD_WARN("unsupported RF %s, chip type 0x%x\n",
goto fail3;
}
ZYD_WARN("failed to configure hardware\n");
goto fail3;
}
/* RF chip init */
case ZYD_RF_AL2230:
} else {
}
break;
case ZYD_RF_RFMD:
break;
default:
ZYD_WARN("unsupported Radio %s, code = 0x%x\n",
res = ZYD_FAILURE;
break;
}
if (res != ZYD_SUCCESS) {
ZYD_WARN("failed to configure RF chip\n");
goto fail3;
}
return (ZYD_SUCCESS);
return (ZYD_FAILURE);
}
void
{
}
/*
* Finish ZD chip initialization.
*/
static zyd_res
{
/* specify that the plug and play is finished */
/* retrieve firmware revision number */
/* disable interrupts */
/* Init RF chip-independent PHY registers */
} else {
}
}
if (res != ZYD_SUCCESS)
return (ZYD_FAILURE);
/* HMAC initialization magic */
} else {
}
return (ZYD_SUCCESS);
}
/*
* Set active channel number.
*/
void
{
case ZYD_RF_AL2230:
break;
case ZYD_RF_RFMD:
break;
}
/* update Tx power */
}
/* set CCK baseband gain from EEPROM */
}
}
/*
* Activate the device.
*/
{
ZYD_WARN("error starting rx transfer\n");
goto fail1;
}
/* we'll do software WEP decryption for now */
if (res != ZYD_SUCCESS)
goto fail2;
/* promiscuous mode */
/* try to catch all packets */
/* switch radio transmitter ON */
case ZYD_RF_AL2230:
break;
case ZYD_RF_RFMD:
break;
}
/* set basic rates */
else /* assumes 802.11b/g */
/* set mandatory rates */
else /* assumes 802.11b/g */
/* enable interrupts */
return (ZYD_SUCCESS);
return (ZYD_FAILURE);
}
/*
* Deactivate the device.
*/
void
{
/* switch radio transmitter OFF */
case ZYD_RF_AL2230:
break;
case ZYD_RF_RFMD:
break;
}
/* disable reception */
/* disable interrupts */
} else {
}
}
/*
* ZD1211 AL2230 Radio control
* Init the AL2230 RF chip.
*/
static zyd_res
{
int i;
/* init RF-dependent PHY registers */
if (res != ZYD_SUCCESS) {
return (ZYD_FAILURE);
}
/* init AL2230 radio */
for (i = 0; i < ZYD_ARRAY_LENGTH(rfini); i++) {
if (res != ZYD_SUCCESS) {
return (ZYD_FAILURE);
}
}
return (ZYD_SUCCESS);
}
/*
* Init the AL2230B RF chip (11b).
*/
static zyd_res
{
int i;
/* init RF-dependent PHY registers */
if (res != ZYD_SUCCESS) {
return (ZYD_FAILURE);
}
/* init AL2230 radio */
for (i = 0; i < ZYD_ARRAY_LENGTH(rfini); i++) {
if (res != ZYD_SUCCESS) {
return (ZYD_FAILURE);
}
}
return (ZYD_SUCCESS);
}
/*
* Tune RF chip to a specified channel.
*/
static zyd_res
{
static const struct {
return (ZYD_SUCCESS);
}
/*
*/
static zyd_res
{
return (ZYD_SUCCESS);
}
/*
* RFMD RF methods.
*/
static zyd_res
{
int i;
/* init RF-dependent PHY registers */
if (res != ZYD_SUCCESS) {
return (ZYD_FAILURE);
}
/* init RFMD radio */
for (i = 0; i < ZYD_ARRAY_LENGTH(rfini); i++) {
if (res != ZYD_SUCCESS) {
return (ZYD_FAILURE);
}
}
return (ZYD_SUCCESS);
}
static zyd_res
{
return (ZYD_SUCCESS);
}
static zyd_res
{
static const struct {
return (ZYD_SUCCESS);
}