rt2x00: Further cleanups and fixes.
cover rt2x00: Further cleanups and fixes.
The next set up cleanups and fixes for rt2x00. Highlights of the patch series include:
- Fixes to the HT40 operation of rt2x00. This works now!!
- Cleanup of rt2800lib.c. Now no bus details (USB or PCI specifics) are part of rt2800lib.c anymore.
- Further preparations for the inclusion of support for RT3572 devices.
Patches are on top of all the previous patch series I sent out, and are relative to wireless-next-2.6.
There are no critical bug-fixes in here that need to be merged into 2.6.35.
Gertjan van Wingerde (7):
rt2x00: Remove RT2870 chipset identification.
rt2x00: Move all register definitions for rt2800 to rt2800.h.
rt2x00: Introduce separate interface type for PCI-express.
rt2x00: Simplify check for external LNA in rt2800_init_rfcsr.
rt2x00: Move PCI/USB specific register initializations to rt2800{pci,usb}.
rt2x00: Sync rt2800 MCU boot signal with Ralink driver.
rt2x00: Fix HT40 operation in rt2800.
drivers/net/wireless/rt2x00/rt2800.h | 49 +++++++++++++++++- drivers/net/wireless/rt2x00/rt2800lib.c | 80 ++++------------------------ drivers/net/wireless/rt2x00/rt2800lib.h | 9 +++ drivers/net/wireless/rt2x00/rt2800pci.c | 36 ++++++++++++- drivers/net/wireless/rt2x00/rt2800pci.h | 19 ------- drivers/net/wireless/rt2x00/rt2800usb.c | 42 ++++++++++++++- drivers/net/wireless/rt2x00/rt2800usb.h | 37 ------------- drivers/net/wireless/rt2x00/rt2x00.h | 12 +++- drivers/net/wireless/rt2x00/rt2x00config.c | 12 +++-- drivers/net/wireless/rt2x00/rt2x00ht.c | 27 +++++++++ drivers/net/wireless/rt2x00/rt2x00lib.h | 9 +++ drivers/net/wireless/rt2x00/rt2x00pci.c | 5 ++- 12 files changed, 200 insertions(+), 137 deletions(-)
PATCH 1/7 rt2x00: Remove RT2870 chipset identification.
There is no evidence, either in adapters or in the Ralink code, that such a device actually exists. All so-call RT2870 adapter identify themselves as RT2860.
--- drivers/net/wireless/rt2x00/rt2800.h | 1 - drivers/net/wireless/rt2x00/rt2800lib.c | 5 +---- drivers/net/wireless/rt2x00/rt2x00.h | 3 +-- 3 files changed, 2 insertions(+), 7 deletions(-)
drivers/net/wireless/rt2x00/rt2800.h +0 -1
@@ -63,7 +63,6 @@*/ #define REV_RT2860C 0x0100#define REV_RT2860D 0x0101 -#define REV_RT2870D 0x0101#define REV_RT2872E 0x0200#define REV_RT3070E 0x0200#define REV_RT3070F 0x0201
drivers/net/wireless/rt2x00/rt2800lib.c +1 -4
@@ -1765,8 +1765,7 @@ int rt2800_init_bbp(struct rt2x00_dev *rt2x00dev)rt2800_bbp_write (rt2x00dev,82 ,0x62 );rt2800_bbp_write (rt2x00dev,83 ,0x6a ); -if (rt2x00_rt_rev (rt2x00dev,RT2860 ,REV_RT2860D ) || -rt2x00_rt_rev (rt2x00dev,RT2870 ,REV_RT2870D )) +if (rt2x00_rt_rev (rt2x00dev,RT2860 ,REV_RT2860D ))rt2800_bbp_write (rt2x00dev,84 ,0x19 );else rt2800_bbp_write (rt2x00dev,84 ,0x99 );
@@ -2206,7 +2205,6 @@ int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev)rt2x00_eeprom_write (rt2x00dev,EEPROM_ANTENNA , word);EEPROM (rt2x00dev,"Antenna: 0x%04x\n" , word); }else if (rt2x00_rt (rt2x00dev,RT2860 ) || -rt2x00_rt (rt2x00dev,RT2870 ) ||rt2x00_rt (rt2x00dev,RT2872 )) {/* * There is a max of 2 RX streams for RT28x0 series
@@ -2310,7 +2308,6 @@ int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev) value, rt2x00_get_field32(reg, MAC_CSR0_REVISION)); if (!rt2x00_rt(rt2x00dev, RT2860) && - !rt2x00_rt(rt2x00dev, RT2870) && !rt2x00_rt(rt2x00dev, RT2872) && !rt2x00_rt(rt2x00dev, RT2883) && !rt2x00_rt(rt2x00dev, RT3070) &&
drivers/net/wireless/rt2x00/rt2x00.h +1 -2
@@ -176,8 +176,7 @@ struct rt2x00_chip {#define RT2570 0x2570#define RT2661 0x2661#define RT2573 0x2573 -#define RT2860 0x2860/* 2.4GHz PCI/CB */ -#define RT2870 0x2870 +#define RT2860 0x2860/* 2.4GHz */ #define RT2872 0x2872/* WSOC */ #define RT2883 0x2883/* WSOC */ #define RT3070 0x3070
Signature · 1 line
1.7.1
Re: [PATCH 1/7] rt2x00: Remove RT2870 chipset identification.
Quoted 5 lines · Gertjan van Wingerde
There is no evidence, either in adapters or in the Ralink code, that such a device actually exists. All so-call RT2870 adapter identify themselves as RT2860.
Signed-off-by Gertjan van Wingerde <[email protected]>
PATCH 2/7 rt2x00: Move all register definitions for rt2800 to rt2800.h.
In reply to Gertjan van WingerdeThere is no point on having them separated across 3 files. At the same time rename USB_CYC_CFG to its proper name US_CYC_CNT (as per the datasheet).
--- drivers/net/wireless/rt2x00/rt2800.h | 48 +++++++++++++++++++++++++++++++ drivers/net/wireless/rt2x00/rt2800lib.c | 6 ++-- drivers/net/wireless/rt2x00/rt2800pci.h | 19 ------------ drivers/net/wireless/rt2x00/rt2800usb.h | 37 ----------------------- 4 files changed, 51 insertions(+), 59 deletions(-)
drivers/net/wireless/rt2x00/rt2800.h +48 -0
@@ -98,6 +98,21 @@*/ /* +* E2PROM_CSR: PCI EEPROM control register. +* RELOAD: Write 1 to reload eeprom content. +* TYPE: 0: 93c46, 1:93c66. +* LOAD_STATUS: 1:loading, 0:done. +*/ +#define E2PROM_CSR 0x0004 +#define E2PROM_CSR_DATA_CLOCK FIELD32(0x00000001) +#define E2PROM_CSR_CHIP_SELECT FIELD32(0x00000002) +#define E2PROM_CSR_DATA_IN FIELD32(0x00000004) +#define E2PROM_CSR_DATA_OUT FIELD32(0x00000008) +#define E2PROM_CSR_TYPE FIELD32(0x00000030) +#define E2PROM_CSR_LOAD_STATUS FIELD32(0x00000040) +#define E2PROM_CSR_RELOAD FIELD32(0x00000080) + +/* * OPT_14: Unknown register used by rt3xxx devices. */ #define OPT_14_CSR 0x0114
@@ -321,6 +336,39 @@#define RX_DRX_IDX 0x029c/* +* USB_DMA_CFG +* RX_BULK_AGG_TIMEOUT: Rx Bulk Aggregation TimeOut in unit of 33ns. +* RX_BULK_AGG_LIMIT: Rx Bulk Aggregation Limit in unit of 256 bytes. +* PHY_CLEAR: phy watch dog enable. +* TX_CLEAR: Clear USB DMA TX path. +* TXOP_HALT: Halt TXOP count down when TX buffer is full. +* RX_BULK_AGG_EN: Enable Rx Bulk Aggregation. +* RX_BULK_EN: Enable USB DMA Rx. +* TX_BULK_EN: Enable USB DMA Tx. +* EP_OUT_VALID: OUT endpoint data valid. +* RX_BUSY: USB DMA RX FSM busy. +* TX_BUSY: USB DMA TX FSM busy. +*/ +#define USB_DMA_CFG 0x02a0 +#define USB_DMA_CFG_RX_BULK_AGG_TIMEOUT FIELD32(0x000000ff) +#define USB_DMA_CFG_RX_BULK_AGG_LIMIT FIELD32(0x0000ff00) +#define USB_DMA_CFG_PHY_CLEAR FIELD32(0x00010000) +#define USB_DMA_CFG_TX_CLEAR FIELD32(0x00080000) +#define USB_DMA_CFG_TXOP_HALT FIELD32(0x00100000) +#define USB_DMA_CFG_RX_BULK_AGG_EN FIELD32(0x00200000) +#define USB_DMA_CFG_RX_BULK_EN FIELD32(0x00400000) +#define USB_DMA_CFG_TX_BULK_EN FIELD32(0x00800000) +#define USB_DMA_CFG_EP_OUT_VALID FIELD32(0x3f000000) +#define USB_DMA_CFG_RX_BUSY FIELD32(0x40000000) +#define USB_DMA_CFG_TX_BUSY FIELD32(0x80000000) + +/* +* US_CYC_CNT +*/ +#define US_CYC_CNT 0x02a4 +#define US_CYC_CNT_CLOCK_CYCLE FIELD32(0x000000ff) + +/* * PBF_SYS_CTRL * HOST_RAM_WRITE: enable Host program ram write selection */
drivers/net/wireless/rt2x00/rt2800lib.c +3 -3
@@ -1619,9 +1619,9 @@ int rt2800_init_registers(struct rt2x00_dev *rt2x00dev)rt2800_register_write (rt2x00dev,HW_BEACON_BASE7 ,0 );if (rt2x00_is_usb (rt2x00dev)) { -rt2800_register_read (rt2x00dev,USB_CYC_CFG , ®); -rt2x00_set_field32 (®,USB_CYC_CFG_CLOCK_CYCLE ,30 ); -rt2800_register_write (rt2x00dev,USB_CYC_CFG , reg); +rt2800_register_read (rt2x00dev,US_CYC_CNT , ®); +rt2x00_set_field32 (®,US_CYC_CNT_CLOCK_CYCLE ,30 ); +rt2800_register_write (rt2x00dev,US_CYC_CNT , reg); }rt2800_register_read (rt2x00dev,HT_FBK_CFG0 , ®);
drivers/net/wireless/rt2x00/rt2800pci.h +0 -19
@@ -35,25 +35,6 @@#define RT2800PCI_H /* -* PCI registers. -*/ - -/* -* E2PROM_CSR: EEPROM control register. -* RELOAD: Write 1 to reload eeprom content. -* TYPE: 0: 93c46, 1:93c66. -* LOAD_STATUS: 1:loading, 0:done. -*/ -#define E2PROM_CSR 0x0004 -#define E2PROM_CSR_DATA_CLOCK FIELD32(0x00000001) -#define E2PROM_CSR_CHIP_SELECT FIELD32(0x00000002) -#define E2PROM_CSR_DATA_IN FIELD32(0x00000004) -#define E2PROM_CSR_DATA_OUT FIELD32(0x00000008) -#define E2PROM_CSR_TYPE FIELD32(0x00000030) -#define E2PROM_CSR_LOAD_STATUS FIELD32(0x00000040) -#define E2PROM_CSR_RELOAD FIELD32(0x00000080) - -/* * Queue register offset macros */ #define TX_QUEUE_REG_OFFSET 0x10
drivers/net/wireless/rt2x00/rt2800usb.h +0 -37
@@ -32,43 +32,6 @@#define RT2800USB_H /* -* USB registers. -*/ - -/* -* USB_DMA_CFG -* RX_BULK_AGG_TIMEOUT: Rx Bulk Aggregation TimeOut in unit of 33ns. -* RX_BULK_AGG_LIMIT: Rx Bulk Aggregation Limit in unit of 256 bytes. -* PHY_CLEAR: phy watch dog enable. -* TX_CLEAR: Clear USB DMA TX path. -* TXOP_HALT: Halt TXOP count down when TX buffer is full. -* RX_BULK_AGG_EN: Enable Rx Bulk Aggregation. -* RX_BULK_EN: Enable USB DMA Rx. -* TX_BULK_EN: Enable USB DMA Tx. -* EP_OUT_VALID: OUT endpoint data valid. -* RX_BUSY: USB DMA RX FSM busy. -* TX_BUSY: USB DMA TX FSM busy. -*/ -#define USB_DMA_CFG 0x02a0 -#define USB_DMA_CFG_RX_BULK_AGG_TIMEOUT FIELD32(0x000000ff) -#define USB_DMA_CFG_RX_BULK_AGG_LIMIT FIELD32(0x0000ff00) -#define USB_DMA_CFG_PHY_CLEAR FIELD32(0x00010000) -#define USB_DMA_CFG_TX_CLEAR FIELD32(0x00080000) -#define USB_DMA_CFG_TXOP_HALT FIELD32(0x00100000) -#define USB_DMA_CFG_RX_BULK_AGG_EN FIELD32(0x00200000) -#define USB_DMA_CFG_RX_BULK_EN FIELD32(0x00400000) -#define USB_DMA_CFG_TX_BULK_EN FIELD32(0x00800000) -#define USB_DMA_CFG_EP_OUT_VALID FIELD32(0x3f000000) -#define USB_DMA_CFG_RX_BUSY FIELD32(0x40000000) -#define USB_DMA_CFG_TX_BUSY FIELD32(0x80000000) - -/* -* USB_CYC_CFG -*/ -#define USB_CYC_CFG 0x02a4 -#define USB_CYC_CFG_CLOCK_CYCLE FIELD32(0x000000ff) - -/* * 8051 firmware image. */ #define FIRMWARE_RT2870 "rt2870.bin"
Signature · 1 line
1.7.1
Re: [PATCH 2/7] rt2x00: Move all register definitions for rt2800 to rt2800.h.
Quoted 5 lines · Gertjan van Wingerde
There is no point on having them separated across 3 files. At the same time rename
USB_CYC_CFGto its proper nameUS_CYC_CNT(as per the datasheet).Signed-off-by Gertjan van Wingerde <[email protected]>
PATCH 3/7 rt2x00: Introduce separate interface type for PCI-express.
In reply to Gertjan van WingerdeNeeded later for PCI-express specific code in rt2800pci.
--- drivers/net/wireless/rt2x00/rt2x00.h | 9 ++++++++- drivers/net/wireless/rt2x00/rt2x00pci.c | 5 ++++- 2 files changed, 12 insertions(+), 2 deletions(-)
drivers/net/wireless/rt2x00/rt2x00.h +8 -1
@@ -160,6 +160,7 @@ struct avg_val {enum rt2x00_chip_intf {RT2X00_CHIP_INTF_PCI , +RT2X00_CHIP_INTF_PCIE ,RT2X00_CHIP_INTF_USB ,RT2X00_CHIP_INTF_SOC , };
@@ -980,7 +981,13 @@ static inline bool rt2x00_intf(struct rt2x00_dev *rt2x00dev,static inline bool rt2x00_is_pci (struct rt2x00_dev *rt2x00dev) { -return rt2x00_intf (rt2x00dev,RT2X00_CHIP_INTF_PCI ); +return rt2x00_intf (rt2x00dev,RT2X00_CHIP_INTF_PCI ) || +rt2x00_intf (rt2x00dev,RT2X00_CHIP_INTF_PCIE ); +} + +static inline bool rt2x00_is_pcie (struct rt2x00_dev *rt2x00dev) +{ +return rt2x00_intf (rt2x00dev,RT2X00_CHIP_INTF_PCIE ); }static inline bool rt2x00_is_usb (struct rt2x00_dev *rt2x00dev)
drivers/net/wireless/rt2x00/rt2x00pci.c +4 -1
@@ -350,7 +350,10 @@ int rt2x00pci_probe(struct pci_dev *pci_dev, const struct pci_device_id *id) rt2x00dev->irq = pci_dev->irq; rt2x00dev->name =pci_name (pci_dev); -rt2x00_set_chip_intf (rt2x00dev,RT2X00_CHIP_INTF_PCI ); +if (pci_dev->is_pcie) +rt2x00_set_chip_intf (rt2x00dev,RT2X00_CHIP_INTF_PCIE ); +else +rt2x00_set_chip_intf (rt2x00dev,RT2X00_CHIP_INTF_PCI ); retval =rt2x00pci_alloc_reg (rt2x00dev);if (retval)
Signature · 1 line
1.7.1
Re: [PATCH 3/7] rt2x00: Introduce separate interface type for PCI-express.
Quoted 3 lines · Gertjan van Wingerde
Needed later for PCI-express specific code in rt2800pci.
Signed-off-by Gertjan van Wingerde <[email protected]>
PATCH 4/7 rt2x00: Simplify check for external LNA in rt2800_init_rfcsr.
In reply to Gertjan van WingerdeInstead of parsing the EEPROM information, use the flag that was set during device initialization.
--- drivers/net/wireless/rt2x00/rt2800lib.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-)
drivers/net/wireless/rt2x00/rt2800lib.c +1 -2
@@ -2071,8 +2071,7 @@ int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev)if (rt2x00_rt_rev_lt (rt2x00dev,RT3071 ,REV_RT3071E ) ||rt2x00_rt_rev_lt (rt2x00dev,RT3090 ,REV_RT3090E ) ||rt2x00_rt_rev_lt (rt2x00dev,RT3390 ,REV_RT3390E )) { -rt2x00_eeprom_read (rt2x00dev,EEPROM_NIC , &eeprom); -if (rt2x00_get_field16 (eeprom,EEPROM_NIC_EXTERNAL_LNA_BG )) +if (test_bit (CONFIG_EXTERNAL_LNA_BG , &rt2x00dev->flags))rt2x00_set_field8 (&rfcsr,RFCSR17_R ,1 ); }rt2x00_eeprom_read (rt2x00dev,EEPROM_TXMIXER_GAIN_BG , &eeprom);
Signature · 1 line
1.7.1
Re: [PATCH 4/7] rt2x00: Simplify check for external LNA in rt2800_init_rfcsr.
Quoted 4 lines · Gertjan van Wingerde
Instead of parsing the EEPROM information, use the flag that was set during device initialization.
Signed-off-by Gertjan van Wingerde <[email protected]>
PATCH 5/7 rt2x00: Move PCI/USB specific register initializations to rt2800{pci,usb}.
In reply to Gertjan van WingerdeThis prevents us having common code depend on PCI or USB specific code.
--- drivers/net/wireless/rt2x00/rt2800lib.c | 61 ++----------------------------- drivers/net/wireless/rt2x00/rt2800lib.h | 9 +++++ drivers/net/wireless/rt2x00/rt2800pci.c | 34 +++++++++++++++++ drivers/net/wireless/rt2x00/rt2800usb.c | 40 ++++++++++++++++++++ 4 files changed, 87 insertions(+), 57 deletions(-)
drivers/net/wireless/rt2x00/rt2800lib.c +4 -57
@@ -37,12 +37,8 @@#include <linux/module.h> #include "rt2x00.h" -#if defined(CONFIG_RT2X00_LIB_USB ) || defined(CONFIG_RT2X00_LIB_USB_MODULE ) -#include "rt2x00usb.h" -#endif #include "rt2800lib.h" #include "rt2800.h" -#include "rt2800usb.h" MODULE_AUTHOR ("Bartlomiej Zolnierkiewicz" );MODULE_DESCRIPTION ("rt2800 library" );
@@ -1271,6 +1267,7 @@ int rt2800_init_registers(struct rt2x00_dev *rt2x00dev)u32 reg;u16 eeprom;unsigned int i; +int ret;rt2800_register_read (rt2x00dev,WPDMA_GLO_CFG , ®);rt2x00_set_field32 (®,WPDMA_GLO_CFG_ENABLE_TX_DMA ,0 );
@@ -1280,59 +1277,9 @@ int rt2800_init_registers(struct rt2x00_dev *rt2x00dev)rt2x00_set_field32 (®,WPDMA_GLO_CFG_TX_WRITEBACK_DONE ,1 );rt2800_register_write (rt2x00dev,WPDMA_GLO_CFG , reg); -if (rt2x00_is_usb (rt2x00dev)) { -/* -* Wait until BBP and RF are ready. -*/ -for (i =0 ; i <REGISTER_BUSY_COUNT ; i++) { -rt2800_register_read (rt2x00dev,MAC_CSR0 , ®); -if (reg && reg != ~0 ) -break ; -msleep (1 ); - } - -if (i ==REGISTER_BUSY_COUNT ) { -ERROR (rt2x00dev,"Unstable hardware.\n" ); -return -EBUSY ; - } - -rt2800_register_read (rt2x00dev,PBF_SYS_CTRL , ®); -rt2800_register_write (rt2x00dev,PBF_SYS_CTRL , - reg & ~0x00002000 ); - }else if (rt2x00_is_pci (rt2x00dev) ||rt2x00_is_soc (rt2x00dev)) { -/* -* Reset DMA indexes -*/ -rt2800_register_read (rt2x00dev,WPDMA_RST_IDX , ®); -rt2x00_set_field32 (®,WPDMA_RST_IDX_DTX_IDX0 ,1 ); -rt2x00_set_field32 (®,WPDMA_RST_IDX_DTX_IDX1 ,1 ); -rt2x00_set_field32 (®,WPDMA_RST_IDX_DTX_IDX2 ,1 ); -rt2x00_set_field32 (®,WPDMA_RST_IDX_DTX_IDX3 ,1 ); -rt2x00_set_field32 (®,WPDMA_RST_IDX_DTX_IDX4 ,1 ); -rt2x00_set_field32 (®,WPDMA_RST_IDX_DTX_IDX5 ,1 ); -rt2x00_set_field32 (®,WPDMA_RST_IDX_DRX_IDX0 ,1 ); -rt2800_register_write (rt2x00dev,WPDMA_RST_IDX , reg); - -rt2800_register_write (rt2x00dev,PBF_SYS_CTRL ,0x00000e1f ); -rt2800_register_write (rt2x00dev,PBF_SYS_CTRL ,0x00000e00 ); - -rt2800_register_write (rt2x00dev,PWR_PIN_CFG ,0x00000003 ); - } - -rt2800_register_read (rt2x00dev,MAC_SYS_CTRL , ®); -rt2x00_set_field32 (®,MAC_SYS_CTRL_RESET_CSR ,1 ); -rt2x00_set_field32 (®,MAC_SYS_CTRL_RESET_BBP ,1 ); -rt2800_register_write (rt2x00dev,MAC_SYS_CTRL , reg); - -if (rt2x00_is_usb (rt2x00dev)) { -rt2800_register_write (rt2x00dev,USB_DMA_CFG ,0x00000000 ); -#if defined(CONFIG_RT2X00_LIB_USB ) || defined(CONFIG_RT2X00_LIB_USB_MODULE ) -rt2x00usb_vendor_request_sw (rt2x00dev,USB_DEVICE_MODE ,0 , -USB_MODE_RESET ,REGISTER_TIMEOUT ); -#endif - } - -rt2800_register_write (rt2x00dev,MAC_SYS_CTRL ,0x00000000 ); + ret =rt2800_drv_init_registers (rt2x00dev); +if (ret) +return ret;rt2800_register_read (rt2x00dev,BCN_OFFSET0 , ®);rt2x00_set_field32 (®,BCN_OFFSET0_BCN0 ,0xe0 );/* 0x3800 */
drivers/net/wireless/rt2x00/rt2800lib.h +9 -0
@@ -40,6 +40,8 @@ struct rt2800_ops {int (*regbusy_read)(struct rt2x00_dev *rt2x00dev,const unsigned int offset,const struct rt2x00_field32 field,u32 *reg); + +int (*drv_init_registers)(struct rt2x00_dev *rt2x00dev); }; static inline void rt2800_register_read(struct rt2x00_dev *rt2x00dev,
@@ -107,6 +109,13 @@ static inline int rt2800_regbusy_read(struct rt2x00_dev *rt2x00dev,return rt2800ops->regbusy_read (rt2x00dev, offset, field, reg); } +static inline int rt2800_drv_init_registers (struct rt2x00_dev *rt2x00dev) +{ +const struct rt2800_ops *rt2800ops = rt2x00dev->priv; + +return rt2800ops->drv_init_registers (rt2x00dev); +} +void rt2800_mcu_request (struct rt2x00_dev *rt2x00dev,const u8 command,const u8 token,const u8 arg0,const u8 arg1);
drivers/net/wireless/rt2x00/rt2800pci.c +34 -0
@@ -446,6 +446,38 @@ static void rt2800pci_toggle_irq(struct rt2x00_dev *rt2x00dev,rt2800_register_write (rt2x00dev,INT_MASK_CSR , reg); } +static int rt2800pci_init_registers (struct rt2x00_dev *rt2x00dev) +{ +u32 reg; + +/* +* Reset DMA indexes +*/ +rt2800_register_read (rt2x00dev,WPDMA_RST_IDX , ®); +rt2x00_set_field32 (®,WPDMA_RST_IDX_DTX_IDX0 ,1 ); +rt2x00_set_field32 (®,WPDMA_RST_IDX_DTX_IDX1 ,1 ); +rt2x00_set_field32 (®,WPDMA_RST_IDX_DTX_IDX2 ,1 ); +rt2x00_set_field32 (®,WPDMA_RST_IDX_DTX_IDX3 ,1 ); +rt2x00_set_field32 (®,WPDMA_RST_IDX_DTX_IDX4 ,1 ); +rt2x00_set_field32 (®,WPDMA_RST_IDX_DTX_IDX5 ,1 ); +rt2x00_set_field32 (®,WPDMA_RST_IDX_DRX_IDX0 ,1 ); +rt2800_register_write (rt2x00dev,WPDMA_RST_IDX , reg); + +rt2800_register_write (rt2x00dev,PBF_SYS_CTRL ,0x00000e1f ); +rt2800_register_write (rt2x00dev,PBF_SYS_CTRL ,0x00000e00 ); + +rt2800_register_write (rt2x00dev,PWR_PIN_CFG ,0x00000003 ); + +rt2800_register_read (rt2x00dev,MAC_SYS_CTRL , ®); +rt2x00_set_field32 (®,MAC_SYS_CTRL_RESET_CSR ,1 ); +rt2x00_set_field32 (®,MAC_SYS_CTRL_RESET_BBP ,1 ); +rt2800_register_write (rt2x00dev,MAC_SYS_CTRL , reg); + +rt2800_register_write (rt2x00dev,MAC_SYS_CTRL ,0x00000000 ); + +return 0 ; +} +static int rt2800pci_enable_radio (struct rt2x00_dev *rt2x00dev) {u32 reg;
@@ -944,6 +976,8 @@ static const struct rt2800_ops rt2800pci_rt2800_ops = { .register_multiwrite = rt2x00pci_register_multiwrite, .regbusy_read = rt2x00pci_regbusy_read, + + .drv_init_registers = rt2800pci_init_registers, };static int rt2800pci_probe_hw (struct rt2x00_dev *rt2x00dev)
drivers/net/wireless/rt2x00/rt2800usb.c +40 -0
@@ -243,6 +243,44 @@ static void rt2800usb_toggle_rx(struct rt2x00_dev *rt2x00dev,rt2800_register_write (rt2x00dev,MAC_SYS_CTRL , reg); } +static int rt2800usb_init_registers (struct rt2x00_dev *rt2x00dev) +{ +u32 reg; +int i; + +/* +* Wait until BBP and RF are ready. +*/ +for (i =0 ; i <REGISTER_BUSY_COUNT ; i++) { +rt2800_register_read (rt2x00dev,MAC_CSR0 , ®); +if (reg && reg != ~0 ) +break ; +msleep (1 ); + } + +if (i ==REGISTER_BUSY_COUNT ) { +ERROR (rt2x00dev,"Unstable hardware.\n" ); +return -EBUSY ; + } + +rt2800_register_read (rt2x00dev,PBF_SYS_CTRL , ®); +rt2800_register_write (rt2x00dev,PBF_SYS_CTRL , reg & ~0x00002000 ); + +rt2800_register_read (rt2x00dev,MAC_SYS_CTRL , ®); +rt2x00_set_field32 (®,MAC_SYS_CTRL_RESET_CSR ,1 ); +rt2x00_set_field32 (®,MAC_SYS_CTRL_RESET_BBP ,1 ); +rt2800_register_write (rt2x00dev,MAC_SYS_CTRL , reg); + +rt2800_register_write (rt2x00dev,USB_DMA_CFG ,0x00000000 ); + +rt2x00usb_vendor_request_sw (rt2x00dev,USB_DEVICE_MODE ,0 , +USB_MODE_RESET ,REGISTER_TIMEOUT ); + +rt2800_register_write (rt2x00dev,MAC_SYS_CTRL ,0x00000000 ); + +return 0 ; +} +static int rt2800usb_enable_radio (struct rt2x00_dev *rt2x00dev) {u32 reg;
@@ -549,6 +587,8 @@ static const struct rt2800_ops rt2800usb_rt2800_ops = { .register_multiwrite = rt2x00usb_register_multiwrite, .regbusy_read = rt2x00usb_regbusy_read, + + .drv_init_registers = rt2800usb_init_registers, };static int rt2800usb_probe_hw (struct rt2x00_dev *rt2x00dev)
Signature · 1 line
1.7.1
Re: [PATCH 5/7] rt2x00: Move PCI/USB specific register initializations to rt2800{pci,usb}.
Quoted 3 lines · Gertjan van Wingerde
This prevents us having common code depend on PCI or USB specific code.
Signed-off-by Gertjan van Wingerde <[email protected]>
Re: [PATCH 5/7] rt2x00: Move PCI/USB specific register initializations to rt2800{pci,usb}.
In reply to Gertjan van WingerdeQuoted 4 lines · On Wednesday 19 May 2010 17:26:07 Gertjan van Wingerde wrote:
This prevents us having common code depend on PCI or USB specific code.
Signed-off-by Gertjan van Wingerde <[email protected]>---
To which tree are you creating your diffs?
This one doesn't apply to latest wireless-testing.git or rt2x00,git
Ivo
Re: [PATCH 5/7] rt2x00: Move PCI/USB specific register initializations to rt2800{pci,usb}.
Quoted 9 lines · Ivo van Doorn
Quoted 4 lines · On Wednesday 19 May 2010 17:26:07 Gertjan van Wingerde wrote:
This prevents us having common code depend on PCI or USB specific code.
Signed-off-by Gertjan van Wingerde <[email protected]>---
To which tree are you creating your diffs?
This one doesn't apply to latest wireless-testing.git or rt2x00,git
All my patches are against wireless-next-2.6.git, as that is the tree John will use to merge patches in.
I believe there indeed is a slight difference between that tree and wireless-testing.git with respect to the <linux/slab.h> inclusion, causing applying errors against wireless-testing.
---
Gertjan.
PATCH 6/7 rt2x00: Sync rt2800 MCU boot signal with Ralink driver.
In reply to Gertjan van WingerdeLatest versions of the Ralink rt2800 family drivers use 0 as the token value, not 0xff.
--- drivers/net/wireless/rt2x00/rt2800pci.c | 2 +- drivers/net/wireless/rt2x00/rt2800usb.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/rt2x00/rt2800pci.c +1 -1
@@ -497,7 +497,7 @@ static int rt2800pci_enable_radio(struct rt2x00_dev *rt2x00dev)/* * Send signal to firmware during boot time. */ -rt2800_mcu_request (rt2x00dev,MCU_BOOT_SIGNAL ,0xff ,0 ,0 ); +rt2800_mcu_request (rt2x00dev,MCU_BOOT_SIGNAL ,0 ,0 ,0 );/* * Enable RX.
drivers/net/wireless/rt2x00/rt2800usb.c +1 -1
@@ -193,7 +193,7 @@ static int rt2800usb_load_firmware(struct rt2x00_dev *rt2x00dev,/* * Send signal to firmware during boot time. */ -rt2800_mcu_request (rt2x00dev,MCU_BOOT_SIGNAL ,0xff ,0 ,0 ); +rt2800_mcu_request (rt2x00dev,MCU_BOOT_SIGNAL ,0 ,0 ,0 ); if (rt2x00_rt(rt2x00dev, RT3070) || rt2x00_rt(rt2x00dev, RT3071) ||
Signature · 1 line
1.7.1
Re: [PATCH 6/7] rt2x00: Sync rt2800 MCU boot signal with Ralink driver.
Quoted 4 lines · Gertjan van Wingerde
Latest versions of the Ralink rt2800 family drivers use 0 as the token value, not
0xff.Signed-off-by Gertjan van Wingerde <[email protected]>
PATCH 7/7 rt2x00: Fix HT40 operation in rt2800.
In reply to Gertjan van WingerdeCloser inspection of the legacy Ralink driver reveals that in case of HT40+ or HT40- we must adjust the frequency settings that we program to the device. Implement the same adjustment in the rt2x00 code.
With this HT40 seems to work for all devices supported by rt2800pci and rt2800usb.
--- drivers/net/wireless/rt2x00/rt2800lib.c | 5 +---- drivers/net/wireless/rt2x00/rt2x00config.c | 12 ++++++++---- drivers/net/wireless/rt2x00/rt2x00ht.c | 27 +++++++++++++++++++++++++++ drivers/net/wireless/rt2x00/rt2x00lib.h | 9 +++++++++ 4 files changed, 45 insertions(+), 8 deletions(-)
drivers/net/wireless/rt2x00/rt2800lib.c +1 -4
@@ -2530,11 +2530,8 @@ int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev)else spec->ht.ht_supported = false; -/* -* Don't set IEEE80211_HT_CAP_SUP_WIDTH_20_40 for now as it causes -* reception problems with HT40 capable 11n APs -*/ spec->ht.cap = +IEEE80211_HT_CAP_SUP_WIDTH_20_40 |IEEE80211_HT_CAP_GRN_FLD |IEEE80211_HT_CAP_SGI_20 | IEEE80211_HT_CAP_SGI_40 |
drivers/net/wireless/rt2x00/rt2x00config.c +8 -4
@@ -170,23 +170,27 @@ void rt2x00lib_config(struct rt2x00_dev *rt2x00dev, unsigned int ieee80211_flags) {struct rt2x00lib_conf libconf; +u16 hw_value;memset (&libconf,0 ,sizeof (libconf)); libconf.conf = conf;if (ieee80211_flags &IEEE80211_CONF_CHANGE_CHANNEL ) { -if (conf_is_ht40 (conf)) +if (conf_is_ht40 (conf)) {__set_bit (CONFIG_CHANNEL_HT40 , &rt2x00dev->flags); -else + hw_value =rt2x00ht_center_channel (rt2x00dev, conf); + }else {__clear_bit (CONFIG_CHANNEL_HT40 , &rt2x00dev->flags); + hw_value = conf->channel->hw_value; + }memcpy (&libconf.rf, - &rt2x00dev->spec.channels[conf->channel->hw_value], + &rt2x00dev->spec.channels[hw_value],sizeof (libconf.rf));memcpy (&libconf.channel, - &rt2x00dev->spec.channels_info[conf->channel->hw_value], + &rt2x00dev->spec.channels_info[hw_value],sizeof (libconf.channel)); }
drivers/net/wireless/rt2x00/rt2x00ht.c +27 -0
@@ -84,3 +84,30 @@ void rt2x00ht_create_tx_descriptor(struct queue_entry *entry,else txdesc->txop =TXOP_HTTXOP ; } + +u16 rt2x00ht_center_channel (struct rt2x00_dev *rt2x00dev, +struct ieee80211_conf *conf) +{ +struct hw_mode_spec *spec = &rt2x00dev->spec; +int center_channel; +u16 i; + +/* +* Initialize center channel to current channel. +*/ + center_channel = spec->channels[conf->channel->hw_value].channel; + +/* +* Adjust center channel to HT40+ and HT40- operation. +*/ +if (conf_is_ht40_plus (conf)) + center_channel +=2 ; +else if (conf_is_ht40_minus (conf)) + center_channel -= (center_channel ==14 ) ?1 :2 ; + +for (i =0 ; i < spec->num_channels; i++) +if (spec->channels[i].channel == center_channel) +return i; + +BUG (); +}
drivers/net/wireless/rt2x00/rt2x00lib.h +9 -0
@@ -367,12 +367,21 @@ static inline void rt2x00crypto_rx_insert_iv(struct sk_buff *skb,void rt2x00ht_create_tx_descriptor (struct queue_entry *entry,struct txentry_desc *txdesc,const struct rt2x00_rate *hwrate); + +u16 rt2x00ht_center_channel (struct rt2x00_dev *rt2x00dev, +struct ieee80211_conf *conf);#else static inline void rt2x00ht_create_tx_descriptor (struct queue_entry *entry,struct txentry_desc *txdesc,const struct rt2x00_rate *hwrate) { } + +static inline u16 rt2x00ht_center_channel (struct rt2x00_dev *rt2x00dev, +struct ieee80211_conf *conf) +{ +return conf->channel->hw_value; +}#endif /* CONFIG_RT2X00_LIB_HT */ /*
Signature · 1 line
1.7.1
Re: [PATCH 7/7] rt2x00: Fix HT40 operation in rt2800.
Am Mittwoch 19 Mai 2010 schrieb Gertjan van Wingerde:
Quoted 6 lines
Closer inspection of the legacy Ralink driver reveals that in case of HT40+ or HT40- we must adjust the frequency settings that we program to the device. Implement the same adjustment in the rt2x00 code.
With this HT40 seems to work for all devices supported by rt2800pci and rt2800usb.
Awesome, I'll give it a shot tomorrow.
Helmut
Quoted 123 lines
Signed-off-by Gertjan van Wingerde <[email protected]>--- drivers/net/wireless/rt2x00/rt2800lib.c | 5 +---- drivers/net/wireless/rt2x00/rt2x00config.c | 12 ++++++++---- drivers/net/wireless/rt2x00/rt2x00ht.c | 27 +++++++++++++++++++++++++++ drivers/net/wireless/rt2x00/rt2x00lib.h | 9 +++++++++ 4 files changed, 45 insertions(+), 8 deletions(-)drivers/net/wireless/rt2x00/rt2800lib.c +1
-4@@ -2530,11 +2530,8 @@ int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev)else spec->ht.ht_supported = false; -/* -* Don't set IEEE80211_HT_CAP_SUP_WIDTH_20_40 for now as it causes -* reception problems with HT40 capable 11n APs -*/ spec->ht.cap = +IEEE80211_HT_CAP_SUP_WIDTH_20_40 |IEEE80211_HT_CAP_GRN_FLD |IEEE80211_HT_CAP_SGI_20 | IEEE80211_HT_CAP_SGI_40 |drivers/net/wireless/rt2x00/rt2x00config.c +8
-4@@ -170,23 +170,27 @@ void rt2x00lib_config(struct rt2x00_dev *rt2x00dev, unsigned int ieee80211_flags) {struct rt2x00lib_conf libconf; +u16 hw_value;memset (&libconf,0 ,sizeof (libconf)); libconf.conf = conf;if (ieee80211_flags &IEEE80211_CONF_CHANGE_CHANNEL ) { -if (conf_is_ht40 (conf)) +if (conf_is_ht40 (conf)) {__set_bit (CONFIG_CHANNEL_HT40 , &rt2x00dev->flags); -else + hw_value =rt2x00ht_center_channel (rt2x00dev, conf); + }else {__clear_bit (CONFIG_CHANNEL_HT40 , &rt2x00dev->flags); + hw_value = conf->channel->hw_value; + }memcpy (&libconf.rf, - &rt2x00dev->spec.channels[conf->channel->hw_value], + &rt2x00dev->spec.channels[hw_value],sizeof (libconf.rf));memcpy (&libconf.channel, - &rt2x00dev->spec.channels_info[conf->channel->hw_value], + &rt2x00dev->spec.channels_info[hw_value],sizeof (libconf.channel)); }drivers/net/wireless/rt2x00/rt2x00ht.c +27
-0@@ -84,3 +84,30 @@ void rt2x00ht_create_tx_descriptor(struct queue_entry *entry,else txdesc->txop =TXOP_HTTXOP ; } + +u16 rt2x00ht_center_channel (struct rt2x00_dev *rt2x00dev, +struct ieee80211_conf *conf) +{ +struct hw_mode_spec *spec = &rt2x00dev->spec; +int center_channel; +u16 i; + +/* +* Initialize center channel to current channel. +*/ + center_channel = spec->channels[conf->channel->hw_value].channel; + +/* +* Adjust center channel to HT40+ and HT40- operation. +*/ +if (conf_is_ht40_plus (conf)) + center_channel +=2 ; +else if (conf_is_ht40_minus (conf)) + center_channel -= (center_channel ==14 ) ?1 :2 ; + +for (i =0 ; i < spec->num_channels; i++) +if (spec->channels[i].channel == center_channel) +return i; + +BUG (); +}drivers/net/wireless/rt2x00/rt2x00lib.h +9
-0@@ -367,12 +367,21 @@ static inline void rt2x00crypto_rx_insert_iv(struct sk_buff *skb,void rt2x00ht_create_tx_descriptor (struct queue_entry *entry,struct txentry_desc *txdesc,const struct rt2x00_rate *hwrate); + +u16 rt2x00ht_center_channel (struct rt2x00_dev *rt2x00dev, +struct ieee80211_conf *conf);#else static inline void rt2x00ht_create_tx_descriptor (struct queue_entry *entry,struct txentry_desc *txdesc,const struct rt2x00_rate *hwrate) { } + +static inline u16 rt2x00ht_center_channel (struct rt2x00_dev *rt2x00dev, +struct ieee80211_conf *conf) +{ +return conf->channel->hw_value; +}#endif /* CONFIG_RT2X00_LIB_HT */ /*
Re: [PATCH 7/7] rt2x00: Fix HT40 operation in rt2800.
In reply to Gertjan van WingerdeQuoted 16 lines
drivers/net/wireless/rt2x00/rt2x00ht.c +16
-0+u16 rt2x00ht_center_channel (struct rt2x00_dev *rt2x00dev, + struct ieee80211_conf *conf) +{ + struct hw_mode_spec *spec = &rt2x00dev->spec; + int center_channel; + u16 i; + + /* + * Initialize center channel to current channel. + */ + center_channel = spec->channels[conf->channel->hw_value].channel; + + /* + * Adjust center channel to HT40+ and HT40- operation. + */ + if (conf_is_ht40_plus(conf))
drivers/net/wireless/rt2x00/rt2x00ht.c void rt2x00ht_create_tx_descriptor(struct queue_entry *entry, · line 113
Quoted 10 lines
drivers/net/wireless/rt2x00/rt2x00ht.c +10
-0+ center_channel += 2; + else if (conf_is_ht40_minus(conf)) + center_channel -= (center_channel == 14) ? 1 : 2; + + for (i = 0; i < spec->num_channels; i++) + if (spec->channels[i].channel == center_channel) + return i; + + BUG(); +}
This isn't worth a BUG(), perhaps a debug message or WARN(), I would say a debug message and retuning the hw_value.
Ivo
Re: [PATCH 7/7] rt2x00: Fix HT40 operation in rt2800.
Quoted 21 lines · Ivo Van Doorn
Quoted 21 lines
drivers/net/wireless/rt2x00/rt2x00ht.c +21
-0+u16 rt2x00ht_center_channel (struct rt2x00_dev *rt2x00dev, +struct ieee80211_conf *conf) +{ +struct hw_mode_spec *spec = &rt2x00dev->spec; +int center_channel; +u16 i; + +/* +* Initialize center channel to current channel. +*/ + center_channel = spec->channels[conf->channel->hw_value].channel; + +/* +* Adjust center channel to HT40+ and HT40- operation. +*/ +if (conf_is_ht40_plus (conf)) + center_channel +=2 ; +else if (conf_is_ht40_minus (conf)) + center_channel -= (center_channel ==14 ) ?1 :2 ; + +for (i =0 ; i < spec->num_channels; i++)
Quoted 9 lines
drivers/net/wireless/rt2x00/rt2x00ht.c void rt2x00ht_create_tx_descriptor(struct queue_entry *entry, · line 113
Quoted 5 lines
drivers/net/wireless/rt2x00/rt2x00ht.c +5
-0+if (spec->channels[i].channel == center_channel) +return i; + +BUG (); +}This isn't worth a
BUG(), perhaps a debug message orWARN(), I would say a debug message and retuning thehw_value.
Oops, yes. BUG() is a bit too much here. This is simply left-over from testing. Personally I think WARN() should be more appropriate, as it signifies an error situation that really should not happen, and we want to atract a bit more attention to it than a simple debug message.
v2 is on its way.
---
Gertjan.