Skip to content

Commit

Permalink
staging: r8187se: Change to use common eeprom routines in EEPROM_93CX
Browse files Browse the repository at this point in the history
The TODO list includes switching this driver to use the common EEPROM
routines in EEPROM_93CX.

Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Tested by: Bernhard Schiffner <bernhard@schiffner-limbach.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Larry Finger authored and Greg Kroah-Hartman committed Mar 4, 2010
1 parent 13a21ad commit 742821c
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 173 deletions.
1 change: 1 addition & 0 deletions drivers/staging/rtl8187se/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ config R8187SE
depends on PCI && WLAN
select WIRELESS_EXT
select WEXT_PRIV
select EEPROM_93CX6
default N
---help---
If built as a module, it will be called r8187se.ko.
1 change: 0 additions & 1 deletion drivers/staging/rtl8187se/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ EXTRA_CFLAGS += -DENABLE_LPS

r8187se-objs := \
r8180_core.o \
r8180_93cx6.o \
r8180_wx.o \
r8180_rtl8225z2.o \
r8185b_init.o \
Expand Down
1 change: 0 additions & 1 deletion drivers/staging/rtl8187se/TODO
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ TODO:
- switch to use shared "librtl" instead of private ieee80211 stack
- switch to use LIB80211
- switch to use MAC80211
- switch to use EEPROM_93CX6
- use kernel coding style
- checkpatch.pl fixes
- sparse fixes
Expand Down
146 changes: 0 additions & 146 deletions drivers/staging/rtl8187se/r8180_93cx6.c

This file was deleted.

17 changes: 7 additions & 10 deletions drivers/staging/rtl8187se/r8180_93cx6.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,10 @@

#define EPROM_TXPW_OFDM_CH1_2 0x20

//#define EPROM_TXPW_CH1_2 0x10
#define EPROM_TXPW_CH1_2 0x30
#define EPROM_TXPW_CH3_4 0x11
#define EPROM_TXPW_CH5_6 0x12
#define EPROM_TXPW_CH7_8 0x13
#define EPROM_TXPW_CH9_10 0x14
#define EPROM_TXPW_CH11_12 0x15
#define EPROM_TXPW_CH13_14 0x16

u32 eprom_read(struct net_device *dev,u32 addr); //reads a 16 bits word
#define EPROM_TXPW_CH1_2 0x30

#define RTL818X_EEPROM_CMD_READ (1 << 0)
#define RTL818X_EEPROM_CMD_WRITE (1 << 1)
#define RTL818X_EEPROM_CMD_CK (1 << 2)
#define RTL818X_EEPROM_CMD_CS (1 << 3)

68 changes: 53 additions & 15 deletions drivers/staging/rtl8187se/r8180_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#undef DUMMY_RX

#include <linux/syscalls.h>
#include <linux/eeprom_93cx6.h>

#include "r8180_hw.h"
#include "r8180.h"
Expand Down Expand Up @@ -2642,6 +2643,36 @@ static void rtl8180_link_detect_init(plink_detect_t plink_detect)
}
//YJ,add,080828,end

static void rtl8187se_eeprom_register_read(struct eeprom_93cx6 *eeprom)
{
struct net_device *dev = eeprom->data;
u8 reg = read_nic_byte(dev, EPROM_CMD);

eeprom->reg_data_in = reg & RTL818X_EEPROM_CMD_WRITE;
eeprom->reg_data_out = reg & RTL818X_EEPROM_CMD_READ;
eeprom->reg_data_clock = reg & RTL818X_EEPROM_CMD_CK;
eeprom->reg_chip_select = reg & RTL818X_EEPROM_CMD_CS;
}

static void rtl8187se_eeprom_register_write(struct eeprom_93cx6 *eeprom)
{
struct net_device *dev = eeprom->data;
u8 reg = 2 << 6;

if (eeprom->reg_data_in)
reg |= RTL818X_EEPROM_CMD_WRITE;
if (eeprom->reg_data_out)
reg |= RTL818X_EEPROM_CMD_READ;
if (eeprom->reg_data_clock)
reg |= RTL818X_EEPROM_CMD_CK;
if (eeprom->reg_chip_select)
reg |= RTL818X_EEPROM_CMD_CS;

write_nic_byte(dev, EPROM_CMD, reg);
read_nic_byte(dev, EPROM_CMD);
udelay(10);
}

short rtl8180_init(struct net_device *dev)
{
struct r8180_priv *priv = ieee80211_priv(dev);
Expand All @@ -2650,8 +2681,16 @@ short rtl8180_init(struct net_device *dev)
u32 usValue;
u16 tmpu16;
int i, j;
struct eeprom_93cx6 eeprom;
u16 eeprom_val;

eeprom.data = dev;
eeprom.register_read = rtl8187se_eeprom_register_read;
eeprom.register_write = rtl8187se_eeprom_register_write;
eeprom.width = PCI_EEPROM_WIDTH_93C46;

priv->channel_plan = eprom_read(dev, EEPROM_COUNTRY_CODE>>1) & 0xFF;
eeprom_93cx6_read(&eeprom, EEPROM_COUNTRY_CODE>>1, &eeprom_val);
priv->channel_plan = eeprom_val & 0xFF;
if(priv->channel_plan > COUNTRY_CODE_GLOBAL_DOMAIN){
printk("rtl8180_init:Error channel plan! Set to default.\n");
priv->channel_plan = 0;
Expand Down Expand Up @@ -2879,7 +2918,8 @@ short rtl8180_init(struct net_device *dev)
// just for sync 85
priv->enable_gpio0 = 0;

usValue = eprom_read(dev, EEPROM_SW_REVD_OFFSET);
eeprom_93cx6_read(&eeprom, EEPROM_SW_REVD_OFFSET, &eeprom_val);
usValue = eeprom_val;
DMESG("usValue is 0x%x\n",usValue);
//3Read AntennaDiversity

Expand Down Expand Up @@ -2919,27 +2959,23 @@ short rtl8180_init(struct net_device *dev)
else
priv->epromtype=EPROM_93c46;

dev->dev_addr[0]=eprom_read(dev,MAC_ADR) & 0xff;
dev->dev_addr[1]=(eprom_read(dev,MAC_ADR) & 0xff00)>>8;
dev->dev_addr[2]=eprom_read(dev,MAC_ADR+1) & 0xff;
dev->dev_addr[3]=(eprom_read(dev,MAC_ADR+1) & 0xff00)>>8;
dev->dev_addr[4]=eprom_read(dev,MAC_ADR+2) & 0xff;
dev->dev_addr[5]=(eprom_read(dev,MAC_ADR+2) & 0xff00)>>8;
eeprom_93cx6_multiread(&eeprom, 0x7, (__le16 *)
dev->dev_addr, 3);

for(i=1,j=0; i<14; i+=2,j++){
word = eprom_read(dev,EPROM_TXPW_CH1_2 + j);
eeprom_93cx6_read(&eeprom, EPROM_TXPW_CH1_2 + j, &word);
priv->chtxpwr[i]=word & 0xff;
priv->chtxpwr[i+1]=(word & 0xff00)>>8;
}
for (i = 1, j = 0; i < 14; i += 2, j++) {
word = eprom_read(dev, EPROM_TXPW_OFDM_CH1_2 + j);
eeprom_93cx6_read(&eeprom, EPROM_TXPW_OFDM_CH1_2 + j, &word);
priv->chtxpwr_ofdm[i] = word & 0xff;
priv->chtxpwr_ofdm[i+1] = (word & 0xff00) >> 8;
}

/* 3Read crystal calibtration and thermal meter indication on 87SE. */
eeprom_93cx6_read(&eeprom, EEPROM_RSV>>1, &tmpu16);

tmpu16 = eprom_read(dev, EEPROM_RSV >> 1);
/* Crystal calibration for Xin and Xout resp. */
priv->XtalCal_Xout = tmpu16 & EEPROM_XTAL_CAL_XOUT_MASK;
priv->XtalCal_Xin = (tmpu16 & EEPROM_XTAL_CAL_XIN_MASK) >> 4;
Expand All @@ -2951,17 +2987,19 @@ short rtl8180_init(struct net_device *dev)
if ((tmpu16 & EEPROM_THERMAL_METER_ENABLE) >> 13)
priv->bTxPowerTrack = true;

word = eprom_read(dev,EPROM_TXPW_BASE);
eeprom_93cx6_read(&eeprom, EPROM_TXPW_BASE, &word);
priv->cck_txpwr_base = word & 0xf;
priv->ofdm_txpwr_base = (word>>4) & 0xf;

version = eprom_read(dev,EPROM_VERSION);
eeprom_93cx6_read(&eeprom, EPROM_VERSION, &version);
DMESG("EEPROM version %x",version);
priv->rcr_csense = 3;

priv->cs_treshold = (eprom_read(dev, ENERGY_TRESHOLD) & 0xff00) >> 8;
eeprom_93cx6_read(&eeprom, ENERGY_TRESHOLD, &eeprom_val);
priv->cs_treshold = (eeprom_val & 0xff00) >> 8;

priv->rf_chip = 0xff & eprom_read(dev, RFCHIPID);
eeprom_93cx6_read(&eeprom, RFCHIPID, &eeprom_val);
priv->rf_chip = 0xff & eeprom_val;

priv->rf_chip = RF_ZEBRA4;
priv->rf_sleep = rtl8225z4_rf_sleep;
Expand Down

0 comments on commit 742821c

Please sign in to comment.