wl1251 sdio interface
RFC PATCH v2 1/8 wl1251: remove fixed address support from spi commands
In reply to Kalle ValoFrom: Kalle Valo <[email protected]>
The fixed addresses are not used in wl1251, only in wl1271. So it can be safely removed.
---
drivers/net/wireless/wl12xx/wl1251_spi.c | 26 ++++++++------------------ drivers/net/wireless/wl12xx/wl1251_spi.h | 18 ++++++------------ 2 files changed, 14 insertions(+), 30 deletions(-)
drivers/net/wireless/wl12xx/wl1251_spi.c +8 -18
@@ -255,8 +255,7 @@ int wl1251_set_partition(struct wl1251 *wl,return 0 ; } -void wl1251_spi_read (struct wl1251 *wl,int addr,void *buf, -size_t len,bool fixed) +void wl1251_spi_read (struct wl1251 *wl,int addr,void *buf,size_t len) {struct spi_transfer t[3 ];struct spi_message m;
@@ -271,9 +270,6 @@ void wl1251_spi_read(struct wl1251 *wl, int addr, void *buf, *cmd |= (len <<WSPI_CMD_BYTE_LENGTH_OFFSET ) &WSPI_CMD_BYTE_LENGTH ; *cmd |= addr &WSPI_CMD_BYTE_ADDR ; -if (fixed) - *cmd |=WSPI_CMD_FIXED ; -spi_message_init (&m);memset (t,0 ,sizeof (t));
@@ -298,8 +294,7 @@ void wl1251_spi_read(struct wl1251 *wl, int addr, void *buf,wl1251_dump (DEBUG_SPI ,"spi_read buf <- " , buf, len); } -void wl1251_spi_write (struct wl1251 *wl,int addr,void *buf, -size_t len,bool fixed) +void wl1251_spi_write (struct wl1251 *wl,int addr,void *buf,size_t len) {struct spi_transfer t[2 ];struct spi_message m;
@@ -312,9 +307,6 @@ void wl1251_spi_write(struct wl1251 *wl, int addr, void *buf, *cmd |= (len <<WSPI_CMD_BYTE_LENGTH_OFFSET ) &WSPI_CMD_BYTE_LENGTH ; *cmd |= addr &WSPI_CMD_BYTE_ADDR ; -if (fixed) - *cmd |=WSPI_CMD_FIXED ; -spi_message_init (&m);memset (t,0 ,sizeof (t));
@@ -339,7 +331,7 @@ void wl1251_spi_mem_read(struct wl1251 *wl, int addr, void *buf, physical =wl1251_translate_mem_addr (wl, addr); -wl1251_spi_read (wl, physical, buf, len, false); +wl1251_spi_read (wl, physical, buf, len); } void wl1251_spi_mem_write(struct wl1251 *wl, int addr, void *buf,
@@ -349,27 +341,25 @@ void wl1251_spi_mem_write(struct wl1251 *wl, int addr, void *buf, physical =wl1251_translate_mem_addr (wl, addr); -wl1251_spi_write (wl, physical, buf, len, false); +wl1251_spi_write (wl, physical, buf, len); } -void wl1251_spi_reg_read (struct wl1251 *wl,int addr,void *buf,size_t len, -bool fixed) +void wl1251_spi_reg_read (struct wl1251 *wl,int addr,void *buf,size_t len) {int physical; physical =wl1251_translate_reg_addr (wl, addr); -wl1251_spi_read (wl, physical, buf, len, fixed); +wl1251_spi_read (wl, physical, buf, len); } -void wl1251_spi_reg_write (struct wl1251 *wl,int addr,void *buf,size_t len, -bool fixed) +void wl1251_spi_reg_write (struct wl1251 *wl,int addr,void *buf,size_t len) {int physical; physical =wl1251_translate_reg_addr (wl, addr); -wl1251_spi_write (wl, physical, buf, len, fixed); +wl1251_spi_write (wl, physical, buf, len); }u32 wl1251_mem_read32 (struct wl1251 *wl,int addr)
drivers/net/wireless/wl12xx/wl1251_spi.h +6 -12
@@ -71,10 +71,8 @@/* Raw target IO, address is not translated */ -void wl1251_spi_write (struct wl1251 *wl,int addr,void *buf, -size_t len,bool fixed); -void wl1251_spi_read (struct wl1251 *wl,int addr,void *buf, -size_t len,bool fixed); +void wl1251_spi_write (struct wl1251 *wl,int addr,void *buf,size_t len); +void wl1251_spi_read (struct wl1251 *wl,int addr,void *buf,size_t len);/* Memory target IO, address is tranlated to partition 0 */ void wl1251_spi_mem_read (struct wl1251 *wl,int addr,void *buf,size_t len);
@@ -83,10 +81,8 @@ u32 wl1251_mem_read32(struct wl1251 *wl, int addr);void wl1251_mem_write32 (struct wl1251 *wl,int addr,u32 val);/* Registers IO */ -void wl1251_spi_reg_read (struct wl1251 *wl,int addr,void *buf,size_t len, -bool fixed); -void wl1251_spi_reg_write (struct wl1251 *wl,int addr,void *buf,size_t len, -bool fixed); +void wl1251_spi_reg_read (struct wl1251 *wl,int addr,void *buf,size_t len); +void wl1251_spi_reg_write (struct wl1251 *wl,int addr,void *buf,size_t len);u32 wl1251_reg_read32 (struct wl1251 *wl,int addr);void wl1251_reg_write32 (struct wl1251 *wl,int addr,u32 val);
@@ -99,8 +95,7 @@ int wl1251_set_partition(struct wl1251 *wl,static inline u32 wl1251_read32 (struct wl1251 *wl,int addr) { -wl1251_spi_read (wl, addr, &wl->buffer_32, -sizeof (wl->buffer_32), false); +wl1251_spi_read (wl, addr, &wl->buffer_32,sizeof (wl->buffer_32));return wl->buffer_32; }
@@ -108,8 +103,7 @@ static inline u32 wl1251_read32(struct wl1251 *wl, int addr)static inline void wl1251_write32 (struct wl1251 *wl,int addr,u32 val) { wl->buffer_32 = val; -wl1251_spi_write (wl, addr, &wl->buffer_32, -sizeof (wl->buffer_32), false); +wl1251_spi_write (wl, addr, &wl->buffer_32,sizeof (wl->buffer_32)); }#endif /* __WL1251_SPI_H__ */
RFC PATCH v2 5/8 wl1251: make wl1251_set_partition bus agnostic
In reply to Kalle ValoFrom: Bob Copeland <[email protected]>
The same partition setting code can be used for both SPI and SDIO modes, if we remove the spi-specific commands and use the more generic buffer write routines. Do that and move it to io.c since it deals with register/memory address offsets.
---
drivers/net/wireless/wl12xx/wl1251_io.c | 95 +++++++++++++++++++++++ drivers/net/wireless/wl12xx/wl1251_io.h | 15 ++++ drivers/net/wireless/wl12xx/wl1251_spi.c | 124 ------------------------------ drivers/net/wireless/wl12xx/wl1251_spi.h | 15 ---- 4 files changed, 110 insertions(+), 139 deletions(-)
drivers/net/wireless/wl12xx/wl1251_io.c +95 -0
@@ -84,3 +84,98 @@ void wl1251_reg_write32(struct wl1251 *wl, int addr, u32 val) {wl1251_write32 (wl,wl1251_translate_reg_addr (wl, addr), val); } + +/* Set the partitions to access the chip addresses. +* +* There are two VIRTUAL partitions (the memory partition and the +* registers partition), which are mapped to two different areas of the +* PHYSICAL (hardware) memory. This function also makes other checks to +* ensure that the partitions are not overlapping. In the diagram below, the +* memory partition comes before the register partition, but the opposite is +* also supported. +* +* PHYSICAL address +* space +* +* | | +* ...+----+--> mem_start +* VIRTUAL address ... | | +* space ... | | [PART_0] +* ... | | +* 0x00000000 <--+----+... ...+----+--> mem_start + mem_size +* | | ... | | +* |MEM | ... | | +* | | ... | | +* part_size <--+----+... | | {unused area) +* | | ... | | +* |REG | ... | | +* part_size | | ... | | +* + <--+----+... ...+----+--> reg_start +* reg_size ... | | +* ... | | [PART_1] +* ... | | +* ...+----+--> reg_start + reg_size +* | | +* +*/ +void wl1251_set_partition (struct wl1251 *wl, +u32 mem_start,u32 mem_size, +u32 reg_start,u32 reg_size) +{ +struct wl1251_partition partition[2 ]; + +wl1251_debug (DEBUG_SPI ,"mem_start %08X mem_size %08X" , + mem_start, mem_size); +wl1251_debug (DEBUG_SPI ,"reg_start %08X reg_size %08X" , + reg_start, reg_size); + +/* Make sure that the two partitions together don't exceed the +* address range */ +if ((mem_size + reg_size) >HW_ACCESS_MEMORY_MAX_RANGE ) { +wl1251_debug (DEBUG_SPI ,"Total size exceeds maximum virtual" +" address range. Truncating partition[0]." ); + mem_size =HW_ACCESS_MEMORY_MAX_RANGE - reg_size; +wl1251_debug (DEBUG_SPI ,"mem_start %08X mem_size %08X" , + mem_start, mem_size); +wl1251_debug (DEBUG_SPI ,"reg_start %08X reg_size %08X" , + reg_start, reg_size); + } + +if ((mem_start < reg_start) && + ((mem_start + mem_size) > reg_start)) { +/* Guarantee that the memory partition doesn't overlap the +* registers partition */ +wl1251_debug (DEBUG_SPI ,"End of partition[0] is " +"overlapping partition[1]. Adjusted." ); + mem_size = reg_start - mem_start; +wl1251_debug (DEBUG_SPI ,"mem_start %08X mem_size %08X" , + mem_start, mem_size); +wl1251_debug (DEBUG_SPI ,"reg_start %08X reg_size %08X" , + reg_start, reg_size); + }else if ((reg_start < mem_start) && + ((reg_start + reg_size) > mem_start)) { +/* Guarantee that the register partition doesn't overlap the +* memory partition */ +wl1251_debug (DEBUG_SPI ,"End of partition[1] is" +" overlapping partition[0]. Adjusted." ); + reg_size = mem_start - reg_start; +wl1251_debug (DEBUG_SPI ,"mem_start %08X mem_size %08X" , + mem_start, mem_size); +wl1251_debug (DEBUG_SPI ,"reg_start %08X reg_size %08X" , + reg_start, reg_size); + } + + partition[0 ].start = mem_start; + partition[0 ].size = mem_size; + partition[1 ].start = reg_start; + partition[1 ].size = reg_size; + + wl->physical_mem_addr = mem_start; + wl->physical_reg_addr = reg_start; + + wl->virtual_mem_addr =0 ; + wl->virtual_reg_addr = mem_size; + + wl->if_ops->write (wl,HW_ACCESS_PART0_SIZE_ADDR , partition, +sizeof (partition)); +}
drivers/net/wireless/wl12xx/wl1251_io.h +15 -0
@@ -23,6 +23,17 @@#include "wl1251.h" +#define HW_ACCESS_MEMORY_MAX_RANGE 0x1FFC0 + +#define HW_ACCESS_PART0_SIZE_ADDR 0x1FFC0 +#define HW_ACCESS_PART0_START_ADDR 0x1FFC4 +#define HW_ACCESS_PART1_SIZE_ADDR 0x1FFC8 +#define HW_ACCESS_PART1_START_ADDR 0x1FFCC + +#define HW_ACCESS_REGISTER_SIZE 4 + +#define HW_ACCESS_PRAM_MAX_RANGE 0x3c000 +static inline u32 wl1251_read32 (struct wl1251 *wl,int addr) {u32 response;
@@ -46,4 +57,8 @@ void wl1251_mem_write32(struct wl1251 *wl, int addr, u32 val);u32 wl1251_reg_read32 (struct wl1251 *wl,int addr);void wl1251_reg_write32 (struct wl1251 *wl,int addr,u32 val); +void wl1251_set_partition (struct wl1251 *wl, +u32 part_start,u32 part_size, +u32 reg_start,u32 reg_size); +#endif
drivers/net/wireless/wl12xx/wl1251_spi.c +0 -124
130 lines not on this page · raw message
drivers/net/wireless/wl12xx/wl1251_spi.h +0 -15
@@ -29,17 +29,6 @@#include "wl1251_acx.h" #include "reg.h" -#define HW_ACCESS_MEMORY_MAX_RANGE 0x1FFC0 - -#define HW_ACCESS_PART0_SIZE_ADDR 0x1FFC0 -#define HW_ACCESS_PART0_START_ADDR 0x1FFC4 -#define HW_ACCESS_PART1_SIZE_ADDR 0x1FFC8 -#define HW_ACCESS_PART1_START_ADDR 0x1FFCC - -#define HW_ACCESS_REGISTER_SIZE 4 - -#define HW_ACCESS_PRAM_MAX_RANGE 0x3c000 -#define WSPI_CMD_READ 0x40000000#define WSPI_CMD_WRITE 0x00000000#define WSPI_CMD_FIXED 0x20000000
@@ -69,8 +58,4 @@ ((WL1251_BUSY_WORD_LEN - 4) / sizeof(u32))#define HW_ACCESS_WSPI_INIT_CMD_MASK 0 -int wl1251_set_partition (struct wl1251 *wl, -u32 part_start,u32 part_size, -u32 reg_start,u32 reg_size); -#endif /* __WL1251_SPI_H__ */
RFC PATCH v2 8/8 wl1251: add sdio support
In reply to Kalle ValoFrom: Bob Copeland <[email protected]>
This adds the wl1251_sdio module, enabling the SDIO interface for wl1251, as used by the Google G1 phone and others.
---
drivers/net/wireless/wl12xx/Kconfig | 11 ++ drivers/net/wireless/wl12xx/Makefile | 1 drivers/net/wireless/wl12xx/wl1251_sdio.c | 188 +++++++++++++++++++++++++++++ 3 files changed, 200 insertions(+), 0 deletions(-) create mode 100644 drivers/net/wireless/wl12xx/wl1251_sdio.c
drivers/net/wireless/wl12xx/Kconfig +11 -0
@@ -27,3 +27,14 @@ config WL1251_SPI If you choose to build a module, it'll be called wl1251_spi. Say N if unsure. + +config WL1251_SDIO + tristate "TI wl1251 SDIO support" + depends on WL1251 && MMC + ---help--- + This module adds support for the SDIO interface of adapters using + TI wl1251 chipset. Select this if your platform is using + the SDIO bus. + + If you choose to build a module, it'll be called + wl1251_sdio. Say N if unsure.
drivers/net/wireless/wl12xx/Makefile +1 -0
@@ -5,3 +5,4 @@ wl1251-objs = wl1251_main.o wl1251_spi.o wl1251_event.o \ obj-$(CONFIG_WL1251) += wl1251.o obj-$(CONFIG_WL1251_SPI) += wl1251_spi.o +obj-$(CONFIG_WL1251_SDIO) += wl1251_sdio.o
drivers/net/wireless/wl12xx/wl1251_sdio.c new file +188 -0
188 lines not on this page · raw message
RFC PATCH v2 3/8 wl1251: use wiphy_dev instead of wl->spi->dev
In reply to Kalle ValoFrom: Bob Copeland <[email protected]>
Remove a dependency on the bus-specific struct device by using wiphy_dev when requesting firmware.
---
drivers/net/wireless/wl12xx/wl1251_main.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-)
drivers/net/wireless/wl12xx/wl1251_main.c +4 -2
@@ -75,9 +75,10 @@ static irqreturn_t wl1251_irq(int irq, void *cookie)static int wl1251_fetch_firmware (struct wl1251 *wl) {const struct firmware *fw; +struct device *dev =wiphy_dev (wl->hw->wiphy);int ret; - ret =request_firmware (&fw, wl->chip.fw_filename, &wl->spi->dev); + ret =request_firmware (&fw, wl->chip.fw_filename, dev);if (ret <0 ) {wl1251_error ("could not get firmware: %d" , ret);
@@ -113,9 +114,10 @@ out:static int wl1251_fetch_nvs (struct wl1251 *wl) {const struct firmware *fw; +struct device *dev =wiphy_dev (wl->hw->wiphy);int ret; - ret =request_firmware (&fw, wl->chip.nvs_filename, &wl->spi->dev); + ret =request_firmware (&fw, wl->chip.nvs_filename, dev);if (ret <0 ) {wl1251_error ("could not get nvs file: %d" , ret);
RFC PATCH v2 6/8 wl1251: move module probe methods into spi.c
In reply to Kalle ValoFrom: Bob Copeland <[email protected]>
This change moves all of the spi specific code from main.c into spi.c. The module initialization code also moves, but common code for initializing mac80211 etc. stays in main.c, as this will eventually form a common library module also used by wl1251_sdio.
---
drivers/net/wireless/wl12xx/wl1251.h | 7 + drivers/net/wireless/wl12xx/wl1251_acx.c | 1 drivers/net/wireless/wl12xx/wl1251_cmd.c | 1 drivers/net/wireless/wl12xx/wl1251_main.c | 148 ++++------------------------- drivers/net/wireless/wl12xx/wl1251_spi.c | 125 ++++++++++++++++++++++++ drivers/net/wireless/wl12xx/wl1251_tx.c | 1 6 files changed, 151 insertions(+), 132 deletions(-)
drivers/net/wireless/wl12xx/wl1251.h +6 -1
@@ -292,7 +292,7 @@ struct wl1251 {bool mac80211_registered;struct spi_device *spi; -struct wl1251_if_operations *if_ops; +const struct wl1251_if_operations *if_ops;void (*set_power)(bool enable);int irq;
@@ -404,6 +404,11 @@ struct wl1251 {int wl1251_plt_start (struct wl1251 *wl);int wl1251_plt_stop (struct wl1251 *wl); +irqreturn_t wl1251_irq (int irq,void *cookie); +struct ieee80211_hw *wl1251_alloc_hw (void ); +int wl1251_free_hw (struct wl1251 *wl); +int wl1251_init_ieee80211 (struct wl1251 *wl); +#define DEFAULT_HW_GEN_MODULATION_TYPE CCK_LONG/* Long Preamble */ #define DEFAULT_HW_GEN_TX_RATE RATE_2MBPS#define JOIN_TIMEOUT 5000/* 5000 milliseconds to join */
drivers/net/wireless/wl12xx/wl1251_acx.c +0 -1
@@ -2,7 +2,6 @@#include <linux/module.h> #include <linux/crc7.h> -#include <linux/spi/spi.h> #include "wl1251.h" #include "reg.h"
drivers/net/wireless/wl12xx/wl1251_cmd.c +0 -1
@@ -2,7 +2,6 @@#include <linux/module.h> #include <linux/crc7.h> -#include <linux/spi/spi.h> #include "wl1251.h" #include "reg.h"
drivers/net/wireless/wl12xx/wl1251_main.c +22 -126
213 lines not on this page · raw message
drivers/net/wireless/wl12xx/wl1251_spi.c +123 -2
149 lines not on this page · raw message
drivers/net/wireless/wl12xx/wl1251_tx.c +0 -1
@@ -27,7 +27,6 @@#include "wl1251.h" #include "reg.h" -#include "wl1251_spi.h" #include "wl1251_tx.h" #include "wl1251_ps.h" #include "wl1251_io.h"
RFC PATCH v2 7/8 wl1251: split spi interface into separate module
In reply to Kalle ValoFrom: Bob Copeland <[email protected]>
This creates a module called wl1251_spi.ko which contains just the SPI-specific code. The core remains in the module wl1251.ko.
---
drivers/net/wireless/wl12xx/Kconfig | 17 ++++++++++++++--- drivers/net/wireless/wl12xx/Makefile | 2 ++ drivers/net/wireless/wl12xx/wl1251.h | 2 +- drivers/net/wireless/wl12xx/wl1251_main.c | 9 +++++++++ drivers/net/wireless/wl12xx/wl1251_spi.c | 15 ++++++++++----- 5 files changed, 36 insertions(+), 9 deletions(-)
drivers/net/wireless/wl12xx/Kconfig +14 -3
@@ -7,12 +7,23 @@ menuconfig WL12XX config WL1251 tristate "TI wl1251 support" - depends on WL12XX && SPI_MASTER && GENERIC_HARDIRQS + depends on WL12XX && GENERIC_HARDIRQS select FW_LOADER select CRC7 ---help--- This module adds support for wireless adapters based on TI wl1251 chipset. - If you choose to build a module, it'll be called wl1251. Say N if - unsure. + If you choose to build a module, it'll be called wl1251. Say + N if unsure. + +config WL1251_SPI + tristate "TI wl1251 SPI support" + depends on WL1251 && SPI_MASTER + ---help--- + This module adds support for the SPI interface of adapters using + TI wl1251 chipset. Select this if your platform is using + the SPI bus. + + If you choose to build a module, it'll be called wl1251_spi. + Say N if unsure.
drivers/net/wireless/wl12xx/Makefile +2 -0
@@ -2,4 +2,6 @@ wl1251-objs = wl1251_main.o wl1251_spi.o wl1251_event.o \ wl1251_tx.o wl1251_rx.o wl1251_ps.o wl1251_cmd.o \ wl1251_acx.o wl1251_boot.o wl1251_init.o \ wl1251_ops.o wl1251_debugfs.o wl1251_io.o + obj-$(CONFIG_WL1251) += wl1251.o +obj-$(CONFIG_WL1251_SPI) += wl1251_spi.o
drivers/net/wireless/wl12xx/wl1251.h +1 -1
@@ -291,7 +291,7 @@ struct wl1251 {struct ieee80211_hw *hw;bool mac80211_registered; -struct spi_device *spi; +void *if_priv;const struct wl1251_if_operations *if_ops;void (*set_power)(bool enable);
drivers/net/wireless/wl12xx/wl1251_main.c +9 -0
@@ -69,6 +69,7 @@ irqreturn_t wl1251_irq(int irq, void *cookie)return IRQ_HANDLED ; } +EXPORT_SYMBOL_GPL (wl1251_irq);static int wl1251_fetch_firmware (struct wl1251 *wl) {
@@ -1253,6 +1254,7 @@ int wl1251_init_ieee80211(struct wl1251 *wl) out:return ret; } +EXPORT_SYMBOL_GPL (wl1251_init_ieee80211);#define WL1251_DEFAULT_CHANNEL 1struct ieee80211_hw *wl1251_alloc_hw (void )
@@ -1325,6 +1327,7 @@ struct ieee80211_hw *wl1251_alloc_hw(void)return hw; } +EXPORT_SYMBOL_GPL (wl1251_alloc_hw);int wl1251_free_hw (struct wl1251 *wl) {
@@ -1347,3 +1350,9 @@ int wl1251_free_hw(struct wl1251 *wl)return 0 ; } +EXPORT_SYMBOL_GPL (wl1251_free_hw); + +MODULE_DESCRIPTION ("TI wl1251 Wireles LAN Driver Core" ); +MODULE_LICENSE ("GPL" ); +MODULE_AUTHOR ("Kalle Valo <[email protected]>" ); +MODULE_AUTHOR ("Luciano Coelho <[email protected]>" );
drivers/net/wireless/wl12xx/wl1251_spi.c +10 -5
@@ -31,6 +31,11 @@#include "reg.h" #include "wl1251_spi.h" +static struct spi_device *wl_to_spi (struct wl1251 *wl) +{ +return wl->if_priv; +} +static void wl1251_spi_reset (struct wl1251 *wl) {u8 *cmd;
@@ -52,7 +57,7 @@ static void wl1251_spi_reset(struct wl1251 *wl) t.len =WSPI_INIT_CMD_LEN ;spi_message_add_tail (&t, &m); -spi_sync (wl->spi, &m); +spi_sync (wl_to_spi (wl), &m);wl1251_dump (DEBUG_SPI ,"spi reset -> " , cmd,WSPI_INIT_CMD_LEN ); }
@@ -106,7 +111,7 @@ static void wl1251_spi_wake(struct wl1251 *wl) t.len =WSPI_INIT_CMD_LEN ;spi_message_add_tail (&t, &m); -spi_sync (wl->spi, &m); +spi_sync (wl_to_spi (wl), &m);wl1251_dump (DEBUG_SPI ,"spi init -> " , cmd,WSPI_INIT_CMD_LEN ); }
@@ -149,7 +154,7 @@ static void wl1251_spi_read(struct wl1251 *wl, int addr, void *buf, t[2 ].len = len;spi_message_add_tail (&t[2 ], &m); -spi_sync (wl->spi, &m); +spi_sync (wl_to_spi (wl), &m);/* FIXME: check busy words */
@@ -182,7 +187,7 @@ static void wl1251_spi_write(struct wl1251 *wl, int addr, void *buf, t[1 ].len = len;spi_message_add_tail (&t[1 ], &m); -spi_sync (wl->spi, &m); +spi_sync (wl_to_spi (wl), &m);wl1251_dump (DEBUG_SPI ,"spi_write cmd -> " , cmd,sizeof (*cmd));wl1251_dump (DEBUG_SPI ,"spi_write buf -> " , buf, len);
@@ -215,7 +220,7 @@ static int __devinit wl1251_spi_probe(struct spi_device *spi)SET_IEEE80211_DEV (hw, &spi->dev);dev_set_drvdata (&spi->dev, wl); - wl->spi = spi; + wl->if_priv = spi; wl->if_ops = &wl1251_spi_ops;/* This is the only SPI value that we need to set here, the rest
v2 cover wl1251 sdio interface
Here is v2 of Bob's wl1251 sdio patches. I have now rebased them on top of wl1251/wl1271 split patches. Only compile-tested because I don't have working test setup right now (neither spi or sdio), but I should have access to one in two weeks.
We should get the patches into wireless-testing soon because there is quite a lot of interest for wl1251 sdio support, sdio is more widely used than spi. I would like to get the patches into 2.6.32 if at all possible.
v2:
o rebase to current wireless-testing (after wl1251/wl1271 split)
---
Bob Copeland (7):
wl1251: add sdio support
wl1251: split spi interface into separate module
wl1251: move module probe methods into spi.c
wl1251: make wl1251_set_partition bus agnostic
wl1251: introduce wl1251_if_operations struct
wl1251: use wiphy_dev instead of wl->spi->dev
wl1251: separate bus i/o code into io.c
Kalle Valo (1):
wl1251: remove fixed address support from spi commands
drivers/net/wireless/wl12xx/Kconfig | 28 ++- drivers/net/wireless/wl12xx/Makefile | 5 drivers/net/wireless/wl12xx/wl1251.h | 14 + drivers/net/wireless/wl12xx/wl1251_acx.c | 3 drivers/net/wireless/wl12xx/wl1251_boot.c | 1 drivers/net/wireless/wl12xx/wl1251_cmd.c | 11 - drivers/net/wireless/wl12xx/wl1251_event.c | 4 drivers/net/wireless/wl12xx/wl1251_io.c | 181 ++++++++++++++++ drivers/net/wireless/wl12xx/wl1251_io.h | 64 ++++++ drivers/net/wireless/wl12xx/wl1251_main.c | 162 +++------------ drivers/net/wireless/wl12xx/wl1251_ops.c | 5 drivers/net/wireless/wl12xx/wl1251_ps.c | 3 drivers/net/wireless/wl12xx/wl1251_rx.c | 7 - drivers/net/wireless/wl12xx/wl1251_sdio.c | 188 +++++++++++++++++ drivers/net/wireless/wl12xx/wl1251_spi.c | 310 +++++++++++----------------- drivers/net/wireless/wl12xx/wl1251_spi.h | 54 ----- drivers/net/wireless/wl12xx/wl1251_tx.c | 62 +++--- 17 files changed, 678 insertions(+), 424 deletions(-) create mode 100644 drivers/net/wireless/wl12xx/wl1251_io.c create mode 100644 drivers/net/wireless/wl12xx/wl1251_io.h create mode 100644 drivers/net/wireless/wl12xx/wl1251_sdio.c
RFC PATCH v2 4/8 wl1251: introduce wl1251_if_operations struct
From: Bob Copeland <[email protected]>
Introduce an ops struct with read, write, and reset functions to abstract away the details of the wl1251 bus interface. Doing this will allow SDIO to coexist with SPI by supplying its own I/O routines.
---
drivers/net/wireless/wl12xx/wl1251.h | 7 +++++++ drivers/net/wireless/wl12xx/wl1251_boot.c | 1 + drivers/net/wireless/wl12xx/wl1251_io.c | 4 ++-- drivers/net/wireless/wl12xx/wl1251_io.h | 9 ++------- drivers/net/wireless/wl12xx/wl1251_main.c | 6 ++++-- drivers/net/wireless/wl12xx/wl1251_ops.c | 1 + drivers/net/wireless/wl12xx/wl1251_spi.c | 23 +++++++++++++++++++---- drivers/net/wireless/wl12xx/wl1251_spi.h | 3 --- 8 files changed, 36 insertions(+), 18 deletions(-)
drivers/net/wireless/wl12xx/wl1251.h +7 -0
@@ -281,11 +281,18 @@ struct wl1251_debugfs {struct dentry *excessive_retries; }; +struct wl1251_if_operations { +void (*read)(struct wl1251 *wl,int addr,void *buf,size_t len); +void (*write)(struct wl1251 *wl,int addr,void *buf,size_t len); +void (*reset)(struct wl1251 *wl); +}; +struct wl1251 {struct ieee80211_hw *hw;bool mac80211_registered;struct spi_device *spi; +struct wl1251_if_operations *if_ops;void (*set_power)(bool enable);int irq;
drivers/net/wireless/wl12xx/wl1251_boot.c +1 -0
@@ -26,6 +26,7 @@#include "reg.h" #include "wl1251_boot.h" #include "wl1251_io.h" +#include "wl1251_spi.h" #include "wl1251_event.h" static void wl1251_boot_enable_interrupts (struct wl1251 *wl)
drivers/net/wireless/wl12xx/wl1251_io.c +2 -2
@@ -53,7 +53,7 @@ void wl1251_mem_read(struct wl1251 *wl, int addr, void *buf, size_t len) physical =wl1251_translate_mem_addr (wl, addr); -wl1251_spi_read (wl, physical, buf, len); + wl->if_ops->read (wl, physical, buf, len); }void wl1251_mem_write (struct wl1251 *wl,int addr,void *buf,size_t len)
@@ -62,7 +62,7 @@ void wl1251_mem_write(struct wl1251 *wl, int addr, void *buf, size_t len) physical =wl1251_translate_mem_addr (wl, addr); -wl1251_spi_write (wl, physical, buf, len); + wl->if_ops->write (wl, physical, buf, len); }u32 wl1251_mem_read32 (struct wl1251 *wl,int addr)
drivers/net/wireless/wl12xx/wl1251_io.h +2 -7
@@ -22,24 +22,19 @@#define __WL1251_IO_H__#include "wl1251.h" -#include "wl1251_spi.h" - -/* Raw target IO, address is not translated */ -void wl1251_spi_read (struct wl1251 *wl,int addr,void *buf,size_t len); -void wl1251_spi_write (struct wl1251 *wl,int addr,void *buf,size_t len);static inline u32 wl1251_read32 (struct wl1251 *wl,int addr) {u32 response; -wl1251_spi_read (wl, addr, &response,sizeof (u32)); + wl->if_ops->read (wl, addr, &response,sizeof (u32));return response; }static inline void wl1251_write32 (struct wl1251 *wl,int addr,u32 val) { -wl1251_spi_write (wl, addr, &val,sizeof (u32)); + wl->if_ops->write (wl, addr, &val,sizeof (u32)); }/* Memory target IO, address is translated to partition 0 */
drivers/net/wireless/wl12xx/wl1251_main.c +4 -2
@@ -168,8 +168,7 @@ static int wl1251_chip_wakeup(struct wl1251 *wl)wl1251_power_on (wl);msleep (wl->chip.power_on_sleep); -wl1251_spi_reset (wl); -wl1251_spi_init (wl); + wl->if_ops->reset (wl);/* We don't need a real memory partition here, because we only want * to use the registers at this point. */
@@ -1247,6 +1246,8 @@ static int wl1251_init_ieee80211(struct wl1251 *wl)return 0 ; } +extern struct wl1251_if_operations wl1251_spi_ops; +#define WL1251_DEFAULT_CHANNEL 1static int __devinit wl1251_probe (struct spi_device *spi) {
@@ -1274,6 +1275,7 @@ static int __devinit wl1251_probe(struct spi_device *spi) wl->hw = hw;dev_set_drvdata (&spi->dev, wl); wl->spi = spi; + wl->if_ops = &wl1251_spi_ops; wl->data_in_count =0 ;
drivers/net/wireless/wl12xx/wl1251_ops.c +1 -0
@@ -27,6 +27,7 @@#include "wl1251_ops.h" #include "reg.h" #include "wl1251_io.h" +#include "wl1251_spi.h" #include "wl1251_boot.h" #include "wl1251_event.h" #include "wl1251_acx.h"
drivers/net/wireless/wl12xx/wl1251_spi.c +19 -4
@@ -29,7 +29,7 @@#include "reg.h" #include "wl1251_spi.h" -void wl1251_spi_reset (struct wl1251 *wl) +static void wl1251_spi_reset (struct wl1251 *wl) {u8 *cmd;struct spi_transfer t;
@@ -55,7 +55,7 @@ void wl1251_spi_reset(struct wl1251 *wl)wl1251_dump (DEBUG_SPI ,"spi reset -> " , cmd,WSPI_INIT_CMD_LEN ); } -void wl1251_spi_init (struct wl1251 *wl) +static void wl1251_spi_init (struct wl1251 *wl) {u8 crc[WSPI_INIT_CMD_CRC_LEN ], *cmd;struct spi_transfer t;
@@ -109,6 +109,13 @@ void wl1251_spi_init(struct wl1251 *wl)wl1251_dump (DEBUG_SPI ,"spi init -> " , cmd,WSPI_INIT_CMD_LEN ); } +static void wl1251_spi_reset_wake (struct wl1251 *wl) +{ +wl1251_spi_reset (wl); +wl1251_spi_init (wl); +} + +/* Set the SPI partitions to access the chip addresses * * There are two VIRTUAL (SPI) partitions (the memory partition and the
@@ -232,7 +239,8 @@ int wl1251_set_partition(struct wl1251 *wl,return 0 ; } -void wl1251_spi_read (struct wl1251 *wl,int addr,void *buf,size_t len) +static void wl1251_spi_read (struct wl1251 *wl,int addr,void *buf, +size_t len) {struct spi_transfer t[3 ];struct spi_message m;
@@ -271,7 +279,8 @@ void wl1251_spi_read(struct wl1251 *wl, int addr, void *buf, size_t len)wl1251_dump (DEBUG_SPI ,"spi_read buf <- " , buf, len); } -void wl1251_spi_write (struct wl1251 *wl,int addr,void *buf,size_t len) +static void wl1251_spi_write (struct wl1251 *wl,int addr,void *buf, +size_t len) {struct spi_transfer t[2 ];struct spi_message m;
@@ -300,3 +309,9 @@ void wl1251_spi_write(struct wl1251 *wl, int addr, void *buf, size_t len)wl1251_dump (DEBUG_SPI ,"spi_write cmd -> " , cmd,sizeof (*cmd));wl1251_dump (DEBUG_SPI ,"spi_write buf -> " , buf, len); } + +const struct wl1251_if_operations wl1251_spi_ops = { + .read = wl1251_spi_read, + .write = wl1251_spi_write, + .reset = wl1251_spi_reset_wake, +};
drivers/net/wireless/wl12xx/wl1251_spi.h +0 -3
@@ -69,9 +69,6 @@ ((WL1251_BUSY_WORD_LEN - 4) / sizeof(u32))#define HW_ACCESS_WSPI_INIT_CMD_MASK 0 -/* INIT and RESET words */ -void wl1251_spi_reset (struct wl1251 *wl); -void wl1251_spi_init (struct wl1251 *wl);int wl1251_set_partition (struct wl1251 *wl,u32 part_start,u32 part_size,u32 reg_start,u32 reg_size);
RFC PATCH v2 2/8 wl1251: separate bus i/o code into io.c
In reply to Kalle ValoFrom: Bob Copeland <[email protected]>
In order to eventually support wl1251 spi and sdio interfaces, move the register and memory transfer functions to a common file. Also rename wl1251_spi_mem_{read,write} to indicate its common usage. We still use spi_read internally until SDIO interface is introduced so nothing functional should change here.
---
drivers/net/wireless/wl12xx/Makefile | 2 - drivers/net/wireless/wl12xx/wl1251_acx.c | 2 - drivers/net/wireless/wl12xx/wl1251_boot.c | 2 - drivers/net/wireless/wl12xx/wl1251_cmd.c | 10 ++- drivers/net/wireless/wl12xx/wl1251_event.c | 4 + drivers/net/wireless/wl12xx/wl1251_io.c | 86 ++++++++++++++++++++++++++++ drivers/net/wireless/wl12xx/wl1251_io.h | 54 ++++++++++++++++++ drivers/net/wireless/wl12xx/wl1251_main.c | 3 + drivers/net/wireless/wl12xx/wl1251_ops.c | 6 +- drivers/net/wireless/wl12xx/wl1251_ps.c | 3 + drivers/net/wireless/wl12xx/wl1251_rx.c | 7 +- drivers/net/wireless/wl12xx/wl1251_spi.c | 81 -------------------------- drivers/net/wireless/wl12xx/wl1251_spi.h | 30 ---------- drivers/net/wireless/wl12xx/wl1251_tx.c | 61 ++++++++++---------- 14 files changed, 192 insertions(+), 159 deletions(-) create mode 100644 drivers/net/wireless/wl12xx/wl1251_io.c create mode 100644 drivers/net/wireless/wl12xx/wl1251_io.h
drivers/net/wireless/wl12xx/Makefile +1 -1
@@ -1,5 +1,5 @@ wl1251-objs = wl1251_main.o wl1251_spi.o wl1251_event.o \ wl1251_tx.o wl1251_rx.o wl1251_ps.o wl1251_cmd.o \ wl1251_acx.o wl1251_boot.o wl1251_init.o \ - wl1251_ops.o wl1251_debugfs.o + wl1251_ops.o wl1251_debugfs.o wl1251_io.o obj-$(CONFIG_WL1251) += wl1251.o
drivers/net/wireless/wl12xx/wl1251_acx.c +1 -1
@@ -6,7 +6,7 @@#include "wl1251.h" #include "reg.h" -#include "wl1251_spi.h" +#include "wl1251_cmd.h" #include "wl1251_ps.h" int wl1251_acx_frame_rates(struct wl1251 *wl, u8 ctrl_rate, u8 ctrl_mod,
drivers/net/wireless/wl12xx/wl1251_boot.c +1 -1
@@ -25,7 +25,7 @@#include "reg.h" #include "wl1251_boot.h" -#include "wl1251_spi.h" +#include "wl1251_io.h" #include "wl1251_event.h" static void wl1251_boot_enable_interrupts (struct wl1251 *wl)
drivers/net/wireless/wl12xx/wl1251_cmd.c +5 -5
@@ -6,7 +6,7 @@#include "wl1251.h" #include "reg.h" -#include "wl1251_spi.h" +#include "wl1251_io.h" #include "wl1251_ps.h" #include "wl1251_acx.h"
@@ -31,7 +31,7 @@ int wl1251_cmd_send(struct wl1251 *wl, u16 id, void *buf, size_t len)WARN_ON (len %4 !=0 ); -wl1251_spi_mem_write (wl, wl->cmd_box_addr, buf, len); +wl1251_mem_write (wl, wl->cmd_box_addr, buf, len);wl1251_reg_write32 (wl,ACX_REG_INTERRUPT_TRIG ,INTR_TRIG_CMD );
@@ -86,7 +86,7 @@ int wl1251_cmd_test(struct wl1251 *wl, void *buf, size_t buf_len, u8 answer)* The answer would be a wl1251_command, where the * parameter array contains the actual answer. */ -wl1251_spi_mem_read (wl, wl->cmd_box_addr, buf, buf_len); +wl1251_mem_read (wl, wl->cmd_box_addr, buf, buf_len); cmd_answer = buf;
@@ -125,7 +125,7 @@ int wl1251_cmd_interrogate(struct wl1251 *wl, u16 id, void *buf, size_t len) }/* the interrogate command got in, we can read the answer */ -wl1251_spi_mem_read (wl, wl->cmd_box_addr, buf, len); +wl1251_mem_read (wl, wl->cmd_box_addr, buf, len); acx = buf;if (acx->cmd.status !=CMD_STATUS_SUCCESS )
@@ -379,7 +379,7 @@ int wl1251_cmd_read_memory(struct wl1251 *wl, u32 addr, void *answer, }/* the read command got in, we can now read the answer */ -wl1251_spi_mem_read (wl, wl->cmd_box_addr, cmd,sizeof (*cmd)); +wl1251_mem_read (wl, wl->cmd_box_addr, cmd,sizeof (*cmd));if (cmd->header.status !=CMD_STATUS_SUCCESS ) wl1251_error("error in read command result: %d",
drivers/net/wireless/wl12xx/wl1251_event.c +2 -2
@@ -24,7 +24,7 @@#include "wl1251.h" #include "reg.h" -#include "wl1251_spi.h" +#include "wl1251_io.h" #include "wl1251_event.h" #include "wl1251_ps.h"
@@ -112,7 +112,7 @@ int wl1251_event_handle(struct wl1251 *wl, u8 mbox_num)return -EINVAL ;/* first we read the mbox descriptor */ -wl1251_spi_mem_read (wl, wl->mbox_ptr[mbox_num], &mbox, +wl1251_mem_read (wl, wl->mbox_ptr[mbox_num], &mbox,sizeof (struct event_mailbox ));/* process the descriptor */
drivers/net/wireless/wl12xx/wl1251_io.c new file +86 -0
86 lines not on this page · raw message
drivers/net/wireless/wl12xx/wl1251_io.h new file +54 -0
54 lines not on this page · raw message
drivers/net/wireless/wl12xx/wl1251_main.c +2 -1
@@ -35,6 +35,7 @@#include "wl12xx_80211.h" #include "reg.h" #include "wl1251_ops.h" +#include "wl1251_io.h" #include "wl1251_spi.h" #include "wl1251_event.h" #include "wl1251_tx.h"
@@ -932,7 +933,7 @@ static int wl1251_hw_scan(struct wl1251 *wl, u8 *ssid, size_t len,if (ret <0 )wl1251_error ("SCAN failed" ); -wl1251_spi_mem_read (wl, wl->cmd_box_addr, params,sizeof (*params)); +wl1251_mem_read (wl, wl->cmd_box_addr, params,sizeof (*params));if (params->header.status !=CMD_STATUS_SUCCESS ) { wl1251_error("TEST command answer error: %d",
drivers/net/wireless/wl12xx/wl1251_ops.c +3 -3
@@ -26,7 +26,7 @@#include "wl1251_ops.h" #include "reg.h" -#include "wl1251_spi.h" +#include "wl1251_io.h" #include "wl1251_boot.h" #include "wl1251_event.h" #include "wl1251_acx.h"
@@ -130,7 +130,7 @@ static int wl1251_upload_firmware(struct wl1251 *wl) p = wl->fw +FW_HDR_SIZE + chunk_num *CHUNK_SIZE ;wl1251_debug (DEBUG_BOOT ,"uploading fw chunk 0x%p to 0x%x" , p, addr); -wl1251_spi_mem_write (wl, addr, p,CHUNK_SIZE ); +wl1251_mem_write (wl, addr, p,CHUNK_SIZE ); chunk_num++; }
@@ -140,7 +140,7 @@ static int wl1251_upload_firmware(struct wl1251 *wl) p = wl->fw +FW_HDR_SIZE + chunk_num *CHUNK_SIZE ;wl1251_debug (DEBUG_BOOT ,"uploading fw last chunk (%zu B) 0x%p to 0x%x" , fw_data_len %CHUNK_SIZE , p, addr); -wl1251_spi_mem_write (wl, addr, p, fw_data_len %CHUNK_SIZE ); +wl1251_mem_write (wl, addr, p, fw_data_len %CHUNK_SIZE );return 0 ; }
drivers/net/wireless/wl12xx/wl1251_ps.c +2 -1
@@ -23,7 +23,8 @@#include "reg.h" #include "wl1251_ps.h" -#include "wl1251_spi.h" +#include "wl1251_cmd.h" +#include "wl1251_io.h" #define WL1251_WAKEUP_TIMEOUT 2000
drivers/net/wireless/wl12xx/wl1251_rx.c +4 -3
@@ -27,8 +27,9 @@#include "wl1251.h" #include "reg.h" -#include "wl1251_spi.h" +#include "wl1251_io.h" #include "wl1251_rx.h" +#include "wl1251_cmd.h" #include "wl1251_acx.h" static void wl1251_rx_header(struct wl1251 *wl,
@@ -40,7 +41,7 @@ static void wl1251_rx_header(struct wl1251 *wl,if (wl->rx_current_buffer) rx_packet_ring_addr += wl->data_path->rx_packet_ring_chunk_size; -wl1251_spi_mem_read (wl, rx_packet_ring_addr, desc,sizeof (*desc)); +wl1251_mem_read (wl, rx_packet_ring_addr, desc,sizeof (*desc)); } static void wl1251_rx_status(struct wl1251 *wl,
@@ -136,7 +137,7 @@ static void wl1251_rx_body(struct wl1251 *wl, } rx_buffer =skb_put (skb, length); -wl1251_spi_mem_read (wl, rx_packet_ring_addr, rx_buffer, length); +wl1251_mem_read (wl, rx_packet_ring_addr, rx_buffer, length);/* The actual lenght doesn't include the target's alignment */ skb->len = desc->length -PLCP_HEADER_LENGTH ;
drivers/net/wireless/wl12xx/wl1251_spi.c +0 -81
90 lines not on this page · raw message
drivers/net/wireless/wl12xx/wl1251_spi.h +0 -30
@@ -69,23 +69,6 @@ ((WL1251_BUSY_WORD_LEN - 4) / sizeof(u32))#define HW_ACCESS_WSPI_INIT_CMD_MASK 0 - -/* Raw target IO, address is not translated */ -void wl1251_spi_write (struct wl1251 *wl,int addr,void *buf,size_t len); -void wl1251_spi_read (struct wl1251 *wl,int addr,void *buf,size_t len); - -/* Memory target IO, address is tranlated to partition 0 */ -void wl1251_spi_mem_read (struct wl1251 *wl,int addr,void *buf,size_t len); -void wl1251_spi_mem_write (struct wl1251 *wl,int addr,void *buf,size_t len); -u32 wl1251_mem_read32 (struct wl1251 *wl,int addr); -void wl1251_mem_write32 (struct wl1251 *wl,int addr,u32 val); - -/* Registers IO */ -void wl1251_spi_reg_read (struct wl1251 *wl,int addr,void *buf,size_t len); -void wl1251_spi_reg_write (struct wl1251 *wl,int addr,void *buf,size_t len); -u32 wl1251_reg_read32 (struct wl1251 *wl,int addr); -void wl1251_reg_write32 (struct wl1251 *wl,int addr,u32 val); -/* INIT and RESET words */ void wl1251_spi_reset (struct wl1251 *wl);void wl1251_spi_init (struct wl1251 *wl);
@@ -93,17 +76,4 @@ int wl1251_set_partition(struct wl1251 *wl, u32 part_start, u32 part_size, u32 reg_start, u32 reg_size); -static inline u32 wl1251_read32 (struct wl1251 *wl,int addr) -{ -wl1251_spi_read (wl, addr, &wl->buffer_32,sizeof (wl->buffer_32)); - -return wl->buffer_32; -} - -static inline void wl1251_write32 (struct wl1251 *wl,int addr,u32 val) -{ - wl->buffer_32 = val; -wl1251_spi_write (wl, addr, &wl->buffer_32,sizeof (wl->buffer_32)); -} -#endif /* __WL1251_SPI_H__ */
drivers/net/wireless/wl12xx/wl1251_tx.c +31 -30
92 lines not on this page · raw message
Quoted 4 lines · Kalle Valo
Here is v2 of Bob's wl1251 sdio patches. I have now rebased them on top of wl1251/wl1271 split patches. Only compile-tested because I don't have working test setup right now (neither spi or sdio), but I should have access to one in two weeks.
I forgot to mention that wl1251 most probably is still broken regards to bssid handling. I will fix this after my (current) vacation, unless someone else is faster. To get wl1251 temporarily working, this patch must be reverted:
commit cc3ec8cb518534c1c593e5f2682710d33c903627
Author: Johannes Berg <[email protected]>
Date: Thu May 14 13:10:14 2009 +0200
mac80211: fix managed mode BSSID handling
Currently, we will ask the driver to configure right away when somebody changes the desired BSSID. That's totally strange because then we will configure the driver without even knowing whether the BSS exists. Change this to only configure the BSSID when associated, and configure a zero BSSID when not associated.
Oddly enough I can't find this patch anymore in wireless-testing, I could only find a revert. I don't know what happened to it.
Signature · 1 line
Kalle Valo
On Fri, 17 Jul 2009 22:04:47 +0300, Kalle Valo wrote
Quoted 5 lines
Kalle Valo <[email protected]> writes:
I forgot to mention that wl1251 most probably is still broken regards to bssid handling. I will fix this after my (current) vacation, unless someone else is faster. To get wl1251 temporarily working, this patch must be reverted:
Thanks Kalle,
I'll take a look at doing this conversion too.
Signature · 1 line
Bob Copeland %% www.bobcopeland.com
Quoted 6 lines · Kalle Valo
Quoted 4 lines · Kalle Valo
Here is v2 of Bob's wl1251 sdio patches. I have now rebased them on top of wl1251/wl1271 split patches. Only compile-tested because I don't have working test setup right now (neither spi or sdio), but I should have access to one in two weeks.
Ok, my first tests with this have mixed results -- wpa_supplicant didn't associate, but I could do a scan. There were a few sdio transfer errors. So I'll try going back to the earlier version and see how they compare.
Meanwhile, this patch (or something like it) would be good:
Quoted 1 line
From
742f257a955fa9e637f7bcb62a73a110718fb247Mon Sep 17 00:00:00 2001
From: Bob Copeland <[email protected]>
Date: Fri, 17 Jul 2009 23:53:15 -0400
Subject: [PATCH] wl12xx: make irq handling interface specific
Due to the differences in interrupt handling between SPI and SDIO, the relevant code needs to be interface specific. This patch pushes the irq code down into _spi.c and _sdio.c, and adds enable/disable callbacks (no-ops for the SDIO case, but not needed there).
This fixes the following warning:
[ 566.343887] ------------[ cut here ]------------ [ 566.349105] WARNING: at kernel/irq/manage.c:222 __enable_irq+0x3c/0x6c() [ 566.356735] Unbalanced enable for IRQ 0 [ 566.361099] Modules linked in: msm_wifi wl12xx_sdio wl12xx mac80211 cfg80211 rfkill_backport lib80211_crypt_ccmp lib80211_crypt_wep lib80211_crypt_tkip lib80211 [ 566.381240] [<c025acec>] (dump_stack+0x0/0x14) from [<c004b610>] (warn_slowpath+0x70/0x8c) [ 566.391860] [<c004b5a0>] (warn_slowpath+0x0/0x8c) from [<c0077c10>] (__enable_irq+0x3c/0x6c) [ 566.402572] r3:00000000 r2:c02cad13 [ 566.407516] r7:00001002 r6:00000000 r5:c0310be4 r4:c0310be4 [ 566.415786] [<c0077bd4>] (__enable_irq+0x0/0x6c) from [<c0077fd0>] (enable_irq+0x38/0x64) [ 566.425826] r5:c0310be4 r4:a0000013 [ 566.430709] [<c0077f98>] (enable_irq+0x0/0x64) from [<bf0dfa78>] (wl12xx_boot_run_firmware+0xfc/0x170 [wl12xx]) [ 566.442947] r7:00001002 r6:c440a9fc r5:00000072 r4:c440a9e0 [ 566.450851] [<bf0df97c>] (wl12xx_boot_run_firmware+0x0/0x170 [wl12xx]) from [<bf0e05f0>] (wl1251_boot+0xd4/0x108 [wl12xx]) [ 566.464492] r5:00000000 r4:c440a9e0 [ 566.469466] [<bf0e051c>] (wl1251_boot+0x0/0x108 [wl12xx]) from [<bf0dd27c>] (wl12xx_op_start+0x54/0xb8 [wl12xx]) [ 566.482162] r5:00000000 r4:c440a9e0 [ 566.487472] [<bf0dd228>] (wl12xx_op_start+0x0/0xb8 [wl12xx]) from [<bf0b96dc>] (ieee80211_open+0x2dc/0x720 [mac80211]) [ 566.500594] r7:00001002 r6:c4950800 r5:c440a220 r4:00000000 [ 566.508865] [<bf0b9400>] (ieee80211_open+0x0/0x720 [mac80211]) from [<c01f1edc>] (dev_open+0x9c/0xfc) [ 566.520705] [<c01f1e40>] (dev_open+0x0/0xfc) from [<c01f17dc>] (dev_change_flags+0x98/0x170) [ 566.531417] r5:00000041 r4:c4950800 [ 566.536330] [<c01f1744>] (dev_change_flags+0x0/0x170) from [<c023041c>] (devinet_ioctl+0x3a8/0x784) [ 566.547683] r7:c128e380 r6:00000001 r5:00008914 r4:00000000 [ 566.555587] [<c0230074>] (devinet_ioctl+0x0/0x784) from [<c02318cc>] (inet_ioctl+0xdc/0x114) [ 566.566299] [<c02317f0>] (inet_ioctl+0x0/0x114) from [<c01e1a60>] (sock_ioctl+0x1f0/0x248) [ 566.576827] r5:00008914 r4:c572c1a0 [ 566.581771] [<c01e1870>] (sock_ioctl+0x0/0x248) from [<c00b23a0>] (vfs_ioctl+0x34/0x94) [ 566.592086] r7:c572c1a0 r6:bee497e8 r5:00008914 r4:c572c1a0 [ 566.599990] [<c00b236c>] (vfs_ioctl+0x0/0x94) from [<c00b2a28>] (do_vfs_ioctl+0x52c/0x584) [ 566.610549] r7:c572c1a0 r6:00008914 r5:c572c1a0 r4:c3201228 [ 566.618453] [<c00b24fc>] (do_vfs_ioctl+0x0/0x584) from [<c00b2ac0>] (sys_ioctl+0x40/0x64) [ 566.628890] [<c00b2a80>] (sys_ioctl+0x0/0x64) from [<c0021da0>] (ret_fast_syscall+0x0/0x2c) [ 566.639541] r7:00000036 r6:00000000 r5:00000004 r4:001a11f3 [ 566.647445] ---[ end trace 15c26ef7dd5e7b03 ]---
--- drivers/net/wireless/wl12xx/wl1251.h | 5 ++++- drivers/net/wireless/wl12xx/wl1251_boot.c | 7 +------ drivers/net/wireless/wl12xx/wl1251_main.c | 26 +++++++++----------------- drivers/net/wireless/wl12xx/wl1251_sdio.c | 7 ++++++- drivers/net/wireless/wl12xx/wl1251_spi.c | 17 +++++++++++++++++ 5 files changed, 37 insertions(+), 25 deletions(-)
drivers/net/wireless/wl12xx/wl1251.h +4 -1
@@ -295,6 +295,8 @@ struct wl1251 {const struct wl1251_if_operations *if_ops;void (*set_power)(bool enable); +void (*enable_irq)(int irq); +void (*disable_irq)(int irq);int irq;enum wl1251_state state;
@@ -404,10 +406,11 @@ struct wl1251 {int wl1251_plt_start (struct wl1251 *wl);int wl1251_plt_stop (struct wl1251 *wl); -irqreturn_t wl1251_irq (int irq,void *cookie);struct ieee80211_hw *wl1251_alloc_hw (void );int wl1251_free_hw (struct wl1251 *wl);int wl1251_init_ieee80211 (struct wl1251 *wl); +void wl1251_enable_interrupts (struct wl1251 *wl); +void wl1251_disable_interrupts (struct wl1251 *wl);#define DEFAULT_HW_GEN_MODULATION_TYPE CCK_LONG/* Long Preamble */ #define DEFAULT_HW_GEN_TX_RATE RATE_2MBPS
drivers/net/wireless/wl12xx/wl1251_boot.c +1 -6
@@ -29,11 +29,6 @@#include "wl1251_spi.h" #include "wl1251_event.h" -static void wl1251_boot_enable_interrupts (struct wl1251 *wl) -{ -enable_irq (wl->irq); -} -void wl1251_boot_target_enable_interrupts (struct wl1251 *wl) {wl1251_reg_write32 (wl,ACX_REG_INTERRUPT_MASK , ~(wl->intr_mask));
@@ -278,7 +273,7 @@ int wl1251_boot_run_firmware(struct wl1251 *wl)*/ /* enable gpio interrupts */ -wl1251_boot_enable_interrupts (wl); +wl1251_enable_interrupts (wl); wl->chip.op_target_enable_interrupts (wl);
drivers/net/wireless/wl12xx/wl1251_main.c +9 -17
@@ -42,9 +42,16 @@#include "wl1251_init.h" #include "wl1251_debugfs.h" -static void wl1251_disable_interrupts (struct wl1251 *wl) +void wl1251_enable_interrupts (struct wl1251 *wl) { -disable_irq (wl->irq); +if (wl->enable_irq) + wl->enable_irq (wl->irq); +} + +void wl1251_disable_interrupts (struct wl1251 *wl) +{ +if (wl->disable_irq) + wl->disable_irq (wl->irq); }static void wl1251_power_off (struct wl1251 *wl)
@@ -57,20 +64,6 @@ static void wl1251_power_on(struct wl1251 *wl) wl->set_power (true); } -irqreturn_t wl1251_irq (int irq,void *cookie) -{ -struct wl1251 *wl; - -wl1251_debug (DEBUG_IRQ ,"IRQ" ); - - wl = cookie; - -schedule_work (&wl->irq_work); - -return IRQ_HANDLED ; -} -EXPORT_SYMBOL_GPL (wl1251_irq); -static int wl1251_fetch_firmware (struct wl1251 *wl) {const struct firmware *fw;
@@ -1335,7 +1328,6 @@ int wl1251_free_hw(struct wl1251 *wl)wl1251_debugfs_exit (wl); -free_irq (wl->irq, wl);kfree (wl->target_mem_map);kfree (wl->data_path);kfree (wl->fw);
drivers/net/wireless/wl12xx/wl1251_sdio.c +6 -1
@@ -50,7 +50,12 @@ static struct sdio_func *wl_to_func(struct wl1251 *wl)static void wl1251_sdio_interrupt (struct sdio_func *func) { -wl1251_irq (0 ,sdio_get_drvdata (func)); +struct wl1251 *wl =sdio_get_drvdata (func); + +wl1251_debug (DEBUG_IRQ ,"IRQ" ); + +/* FIXME should be synchronous for sdio */ +schedule_work (&wl->irq_work); }static const struct sdio_device_id wl1251_devices[] = {
drivers/net/wireless/wl12xx/wl1251_spi.c +17 -0
@@ -31,6 +31,19 @@#include "reg.h" #include "wl1251_spi.h" +static irqreturn_t wl1251_irq (int irq,void *cookie) +{ +struct wl1251 *wl; + +wl1251_debug (DEBUG_IRQ ,"IRQ" ); + + wl = cookie; + +schedule_work (&wl->irq_work); + +return IRQ_HANDLED ; +} +static struct spi_device *wl_to_spi (struct wl1251 *wl) {return wl->if_priv;
@@ -255,6 +268,9 @@ static int __devinit wl1251_spi_probe(struct spi_device *spi)disable_irq (wl->irq); + wl->enable_irq = enable_irq; + wl->disable_irq = disable_irq; + ret =wl1251_init_ieee80211 (wl);if (ret) goto out_irq;
@@ -274,6 +290,7 @@ static int __devexit wl1251_spi_remove(struct spi_device *spi) {struct wl1251 *wl =dev_get_drvdata (&spi->dev); +free_irq (wl->irq, wl);wl1251_free_hw (wl);return 0 ;
Signature · 5 lines
1.6.2.5 -- Bob Copeland %% www.bobcopeland.com
Quoted 9 lines · ext Kalle Valo
Quoted 5 lines · Kalle Valo
Here is v2 of Bob's wl1251 sdio patches. I have now rebased them on top of wl1251/wl1271 split patches. Only compile-tested because I don't have working test setup right now (neither spi or sdio), but I should have access to one in two weeks.
Quoted 5 lines
I forgot to mention that wl1251 most probably is still broken regards to bssid handling. I will fix this after my (current) vacation, unless someone else is faster. To get wl1251 temporarily working, this patch must be reverted:
Wow! This is just what I needed to know. I have been struggling the whole of last week trying to figure out why the wl1271 driver that I'm planning to submit doesn't work with the latest wireless-testing. I've been using the wl1251 from wireless-testing as a reference and I was running out of ideas as to why wl1251 was working and my version of the wl1271 wasn't. So, it's very good to know that wl1251 isn't working either :)
This is the only thing that is currently preventing me from submitting the wl1271 code. Obviously I want to make sure that it works before sending it for inclusion in wireless-testing...
Quoted 13 lines
commit
cc3ec8cb518534c1c593e5f2682710d33c903627
Author: Johannes Berg <[email protected]>
Date: Thu May 14 13:10:14 2009 +0200mac80211: fix managed mode BSSID handling
Currently, we will ask the driver to configure right away when somebody changes the desired BSSID. That's totally strange because then we will configure the driver without even knowing whether the BSS exists. Change this to only configure the BSSID when associated, and configure a zero BSSID when not associated.
Quoted 3 lines
Oddly enough I can't find this patch anymore in wireless-testing, I could only find a revert. I don't know what happened to it.
The original patch *is* there, but it has been reverted. In any case, I noticed that the change introduced by this patch is there, so I guess some other patch has replaced it later.
Now I need to read the archives of the linux-wireless mailing list to figure out exactly what has changed and what I need to do to get wl1271 to work with the new API. Or is anyone willing to give me a brief summary of what the driver is expected to do with the new API? (yeah, it's a sunny Sunday and I'm a bit lazy today :P)
Signature · 2 lines
Cheers, Luca.