Skip to content

Commit

Permalink
Merge branch 'upstream' of git://git.kernel.org/pub/scm/linux/kernel/…
Browse files Browse the repository at this point in the history
…git/linville/wireless-2.6 into upstream
  • Loading branch information
Jeff Garzik committed Aug 19, 2006
2 parents fd6746d + 113b898 commit a513c31
Show file tree
Hide file tree
Showing 13 changed files with 575 additions and 77 deletions.
2 changes: 1 addition & 1 deletion drivers/net/wireless/ray_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@
#include <pcmcia/ds.h>
#include <pcmcia/mem_op.h>

#include <net/ieee80211.h>
#include <linux/wireless.h>
#include <net/iw_handler.h>

#include <asm/io.h>
#include <asm/system.h>
Expand Down
1 change: 1 addition & 0 deletions drivers/net/wireless/zd1211rw/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ obj-$(CONFIG_ZD1211RW) += zd1211rw.o
zd1211rw-objs := zd_chip.o zd_ieee80211.o \
zd_mac.o zd_netdev.o \
zd_rf_al2230.o zd_rf_rf2959.o \
zd_rf_al7230b.o \
zd_rf.o zd_usb.o zd_util.o

ifeq ($(CONFIG_ZD1211RW_DEBUG),y)
Expand Down
62 changes: 49 additions & 13 deletions drivers/net/wireless/zd1211rw/zd_chip.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,11 @@ void zd_chip_init(struct zd_chip *chip,

void zd_chip_clear(struct zd_chip *chip)
{
mutex_lock(&chip->mutex);
ZD_ASSERT(!mutex_is_locked(&chip->mutex));
zd_usb_clear(&chip->usb);
zd_rf_clear(&chip->rf);
mutex_unlock(&chip->mutex);
mutex_destroy(&chip->mutex);
memset(chip, 0, sizeof(*chip));
ZD_MEMCLEAR(chip, sizeof(*chip));
}

static int scnprint_mac_oui(const u8 *addr, char *buffer, size_t size)
Expand All @@ -68,10 +67,11 @@ static int scnprint_id(struct zd_chip *chip, char *buffer, size_t size)
i += scnprint_mac_oui(chip->e2p_mac, buffer+i, size-i);
i += scnprintf(buffer+i, size-i, " ");
i += zd_rf_scnprint_id(&chip->rf, buffer+i, size-i);
i += scnprintf(buffer+i, size-i, " pa%1x %c%c%c", chip->pa_type,
i += scnprintf(buffer+i, size-i, " pa%1x %c%c%c%c", chip->pa_type,
chip->patch_cck_gain ? 'g' : '-',
chip->patch_cr157 ? '7' : '-',
chip->patch_6m_band_edge ? '6' : '-');
chip->patch_6m_band_edge ? '6' : '-',
chip->new_phy_layout ? 'N' : '-');
return i;
}

Expand Down Expand Up @@ -330,20 +330,22 @@ static int read_pod(struct zd_chip *chip, u8 *rf_type)
chip->patch_cck_gain = (value >> 8) & 0x1;
chip->patch_cr157 = (value >> 13) & 0x1;
chip->patch_6m_band_edge = (value >> 21) & 0x1;
chip->new_phy_layout = (value >> 31) & 0x1;

dev_dbg_f(zd_chip_dev(chip),
"RF %s %#01x PA type %#01x patch CCK %d patch CR157 %d "
"patch 6M %d\n",
"patch 6M %d new PHY %d\n",
zd_rf_name(*rf_type), *rf_type,
chip->pa_type, chip->patch_cck_gain,
chip->patch_cr157, chip->patch_6m_band_edge);
chip->patch_cr157, chip->patch_6m_band_edge, chip->new_phy_layout);
return 0;
error:
*rf_type = 0;
chip->pa_type = 0;
chip->patch_cck_gain = 0;
chip->patch_cr157 = 0;
chip->patch_6m_band_edge = 0;
chip->new_phy_layout = 0;
return r;
}

Expand Down Expand Up @@ -717,7 +719,7 @@ static int zd1211b_hw_reset_phy(struct zd_chip *chip)
{ CR21, 0x0e }, { CR22, 0x23 }, { CR23, 0x90 },
{ CR24, 0x14 }, { CR25, 0x40 }, { CR26, 0x10 },
{ CR27, 0x10 }, { CR28, 0x7f }, { CR29, 0x80 },
{ CR30, 0x49 }, /* jointly decoder, no ASIC */
{ CR30, 0x4b }, /* ASIC/FWT, no jointly decoder */
{ CR31, 0x60 }, { CR32, 0x43 }, { CR33, 0x08 },
{ CR34, 0x06 }, { CR35, 0x0a }, { CR36, 0x00 },
{ CR37, 0x00 }, { CR38, 0x38 }, { CR39, 0x0c },
Expand Down Expand Up @@ -807,7 +809,6 @@ static int zd1211_hw_init_hmac(struct zd_chip *chip)
{ CR_ACK_TIMEOUT_EXT, 0x80 },
{ CR_ADDA_PWR_DWN, 0x00 },
{ CR_ACK_TIME_80211, 0x100 },
{ CR_IFS_VALUE, 0x547c032 },
{ CR_RX_PE_DELAY, 0x70 },
{ CR_PS_CTRL, 0x10000000 },
{ CR_RTS_CTS_RATE, 0x02030203 },
Expand Down Expand Up @@ -854,11 +855,10 @@ static int zd1211b_hw_init_hmac(struct zd_chip *chip)
{ CR_ACK_TIMEOUT_EXT, 0x80 },
{ CR_ADDA_PWR_DWN, 0x00 },
{ CR_ACK_TIME_80211, 0x100 },
{ CR_IFS_VALUE, 0x547c032 },
{ CR_RX_PE_DELAY, 0x70 },
{ CR_PS_CTRL, 0x10000000 },
{ CR_RTS_CTS_RATE, 0x02030203 },
{ CR_RX_THRESHOLD, 0x000c0640 },
{ CR_RX_THRESHOLD, 0x000c0eff, },
{ CR_AFTER_PNP, 0x1 },
{ CR_WEP_PROTECT, 0x114 },
};
Expand Down Expand Up @@ -970,10 +970,15 @@ static int hw_init(struct zd_chip *chip)
r = hw_init_hmac(chip);
if (r)
return r;
r = set_beacon_interval(chip, 100);

/* Although the vendor driver defaults to a different value during
* init, it overwrites the IFS value with the following every time
* the channel changes. We should aim to be more intelligent... */
r = zd_iowrite32_locked(chip, IFS_VALUE_DEFAULT, CR_IFS_VALUE);
if (r)
return r;
return 0;

return set_beacon_interval(chip, 100);
}

#ifdef DEBUG
Expand Down Expand Up @@ -1613,3 +1618,34 @@ int zd_rfwritev_locked(struct zd_chip *chip,

return 0;
}

/*
* We can optionally program the RF directly through CR regs, if supported by
* the hardware. This is much faster than the older method.
*/
int zd_rfwrite_cr_locked(struct zd_chip *chip, u32 value)
{
struct zd_ioreq16 ioreqs[] = {
{ CR244, (value >> 16) & 0xff },
{ CR243, (value >> 8) & 0xff },
{ CR242, value & 0xff },
};
ZD_ASSERT(mutex_is_locked(&chip->mutex));
return zd_iowrite16a_locked(chip, ioreqs, ARRAY_SIZE(ioreqs));
}

int zd_rfwritev_cr_locked(struct zd_chip *chip,
const u32 *values, unsigned int count)
{
int r;
unsigned int i;

for (i = 0; i < count; i++) {
r = zd_rfwrite_cr_locked(chip, values[i]);
if (r)
return r;
}

return 0;
}

15 changes: 14 additions & 1 deletion drivers/net/wireless/zd1211rw/zd_chip.h
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,15 @@

#define CR_ACK_TIMEOUT_EXT CTL_REG(0x0690)
#define CR_BCN_FIFO_SEMAPHORE CTL_REG(0x0694)

#define CR_IFS_VALUE CTL_REG(0x0698)
#define IFS_VALUE_DIFS_SH 0
#define IFS_VALUE_EIFS_SH 12
#define IFS_VALUE_SIFS_SH 24
#define IFS_VALUE_DEFAULT (( 50 << IFS_VALUE_DIFS_SH) | \
(1148 << IFS_VALUE_EIFS_SH) | \
( 10 << IFS_VALUE_SIFS_SH))

#define CR_RX_TIME_OUT CTL_REG(0x069C)
#define CR_TOTAL_RX_FRM CTL_REG(0x06A0)
#define CR_CRC32_CNT CTL_REG(0x06A4)
Expand Down Expand Up @@ -630,6 +638,7 @@ enum {
LOAD_CODE_SIZE = 0xe, /* words */
LOAD_VECT_SIZE = 0x10000 - 0xfff7, /* words */
EEPROM_REGS_OFFSET = LOAD_CODE_SIZE + LOAD_VECT_SIZE,
EEPROM_REGS_SIZE = 0x7e, /* words */
E2P_BASE_OFFSET = EEPROM_START_OFFSET +
EEPROM_REGS_OFFSET,
};
Expand All @@ -655,7 +664,7 @@ struct zd_chip {
/* SetPointOFDM in the vendor driver */
u8 ofdm_cal_values[3][E2P_CHANNEL_COUNT];
u8 pa_type:4, patch_cck_gain:1, patch_cr157:1, patch_6m_band_edge:1,
is_zd1211b:1;
new_phy_layout:1, is_zd1211b:1;
};

static inline struct zd_chip *zd_usb_to_chip(struct zd_usb *usb)
Expand Down Expand Up @@ -739,8 +748,12 @@ static inline int zd_rfwrite_locked(struct zd_chip *chip, u32 value, u8 bits)
return zd_usb_rfwrite(&chip->usb, value, bits);
}

int zd_rfwrite_cr_locked(struct zd_chip *chip, u32 value);

int zd_rfwritev_locked(struct zd_chip *chip,
const u32* values, unsigned int count, u8 bits);
int zd_rfwritev_cr_locked(struct zd_chip *chip,
const u32* values, unsigned int count);

/* Locking functions for reading and writing registers.
* The different parameters are intentional.
Expand Down
6 changes: 6 additions & 0 deletions drivers/net/wireless/zd1211rw/zd_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,10 @@ do { \
# define ZD_ASSERT(x) do { } while (0)
#endif

#ifdef DEBUG
# define ZD_MEMCLEAR(pointer, size) memset((pointer), 0xff, (size))
#else
# define ZD_MEMCLEAR(pointer, size) do { } while (0)
#endif

#endif /* _ZD_DEF_H */
6 changes: 2 additions & 4 deletions drivers/net/wireless/zd1211rw/zd_mac.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,9 @@ int zd_mac_init_hw(struct zd_mac *mac, u8 device_type)

void zd_mac_clear(struct zd_mac *mac)
{
/* Aquire the lock. */
spin_lock(&mac->lock);
spin_unlock(&mac->lock);
zd_chip_clear(&mac->chip);
memset(mac, 0, sizeof(*mac));
ZD_ASSERT(!spin_is_locked(&mac->lock));
ZD_MEMCLEAR(mac, sizeof(struct zd_mac));
}

static int reset_mode(struct zd_mac *mac)
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/wireless/zd1211rw/zd_mac.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ enum mac_flags {
};

struct zd_mac {
struct net_device *netdev;
struct zd_chip chip;
spinlock_t lock;
struct net_device *netdev;
/* Unlocked reading possible */
struct iw_statistics iw_stats;
u8 qual_average;
Expand Down
7 changes: 6 additions & 1 deletion drivers/net/wireless/zd1211rw/zd_rf.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void zd_rf_init(struct zd_rf *rf)

void zd_rf_clear(struct zd_rf *rf)
{
memset(rf, 0, sizeof(*rf));
ZD_MEMCLEAR(rf, sizeof(*rf));
}

int zd_rf_init_hw(struct zd_rf *rf, u8 type)
Expand All @@ -76,6 +76,11 @@ int zd_rf_init_hw(struct zd_rf *rf, u8 type)
if (r)
return r;
break;
case AL7230B_RF:
r = zd_rf_init_al7230b(rf);
if (r)
return r;
break;
default:
dev_err(zd_chip_dev(chip),
"RF %s %#x is not supported\n", zd_rf_name(type), type);
Expand Down
1 change: 1 addition & 0 deletions drivers/net/wireless/zd1211rw/zd_rf.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,6 @@ int zd_switch_radio_off(struct zd_rf *rf);

int zd_rf_init_rf2959(struct zd_rf *rf);
int zd_rf_init_al2230(struct zd_rf *rf);
int zd_rf_init_al7230b(struct zd_rf *rf);

#endif /* _ZD_RF_H */
Loading

0 comments on commit a513c31

Please sign in to comment.