ath: Add a driver_info bitmask field
PATCH 1/4 ath: Add a driver_info bitmask field
The driver_info stores the device category information which is used to load appropriate device firmware, select firmware offset and eeprom starting location. The driver_info is accessed across ath9k_htc and ath9k_hw. Hence placed under common structure.
--- drivers/net/wireless/ath/ath.h | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
drivers/net/wireless/ath/ath.h +6 -0
@@ -104,6 +104,11 @@ enum ath_cipher { ATH_CIPHER_MIC = 127 }; +enum ath_drv_info { +AR7010_DEVICE =BIT (0 ), +AR9287_DEVICE =BIT (1 ), +}; +/** * struct ath_ops - Register read/write operations *
@@ -147,6 +152,7 @@ struct ath_common {u8 rx_chainmask;u32 rx_bufsize; +u32 driver_info;u32 keymax;DECLARE_BITMAP (keymap,ATH_KEYMAX );
Signature · 1 line
1.7.3.2
PATCH 2/4 ath9k_htc: Add driver_info in usb device list
Added driver_info to identify AR7010, R9287 HTC devices.
--- drivers/net/wireless/ath/ath9k/hif_usb.c | 20 +++++++++++++++----- 1 files changed, 15 insertions(+), 5 deletions(-)
drivers/net/wireless/ath/ath9k/hif_usb.c +15 -5
@@ -28,10 +28,16 @@ MODULE_FIRMWARE(FIRMWARE_AR9271);static struct usb_device_id ath9k_hif_usb_ids[] = { {USB_DEVICE (0x0cf3 ,0x9271 ) },/* Atheros */ {USB_DEVICE (0x0cf3 ,0x1006 ) },/* Atheros */ - {USB_DEVICE (0x0cf3 ,0x7010 ) },/* Atheros */ - {USB_DEVICE (0x0cf3 ,0x7015 ) },/* Atheros */ + {USB_DEVICE (0x0cf3 ,0x7010 ), + .driver_info =AR7010_DEVICE }, +/* Atheros */ + {USB_DEVICE (0x0cf3 ,0x7015 ), + .driver_info =AR7010_DEVICE |AR9287_DEVICE }, +/* Atheros */ {USB_DEVICE (0x0846 ,0x9030 ) },/* Netgear N150 */ - {USB_DEVICE (0x0846 ,0x9018 ) },/* Netgear WNDA3200 */ + {USB_DEVICE (0x0846 ,0x9018 ), + .driver_info =AR7010_DEVICE }, +/* Netgear WNDA3200 */ {USB_DEVICE (0x07D1 ,0x3A10 ) },/* Dlink Wireless 150 */ {USB_DEVICE (0x13D3 ,0x3327 ) },/* Azurewave */ {USB_DEVICE (0x13D3 ,0x3328 ) },/* Azurewave */
@@ -40,9 +46,13 @@ static struct usb_device_id ath9k_hif_usb_ids[] = { { USB_DEVICE(0x13D3, 0x3349) }, /* Azurewave */ { USB_DEVICE(0x13D3, 0x3350) }, /* Azurewave */ { USB_DEVICE(0x04CA, 0x4605) }, /* Liteon */ - { USB_DEVICE(0x083A, 0xA704) }, /* SMC Networks */ + { USB_DEVICE(0x083A, 0xA704), + .driver_info = AR7010_DEVICE }, +/* SMC Networks */ { USB_DEVICE(0x040D, 0x3801) }, /* VIA */ - { USB_DEVICE(0x1668, 0x1200) }, /* Verizon */ + { USB_DEVICE(0x1668, 0x1200), + .driver_info = AR7010_DEVICE | AR9287_DEVICE }, + /* Verizon */ { }, };
Signature · 1 line
1.7.3.2
PATCH 3/4 ath9k_hw: Fix eeprom offset for AR9287 devices (PCI/USB)
In reply to Rajkumar ManoharanAR9287 devices (PCI/USB) use different eeprom start location to read nvram. New devices might endup with same devid. So use driver_info to set offset, instead of devid. driver_info is valid for HTC devices alone which is filled in usb_device_id.
--- drivers/net/wireless/ath/ath9k/eeprom_9287.c | 6 +++--- drivers/net/wireless/ath/ath9k/reg.h | 4 ---- 2 files changed, 3 insertions(+), 7 deletions(-)
drivers/net/wireless/ath/ath9k/eeprom_9287.c +3 -3
@@ -37,10 +37,10 @@ static bool ath9k_hw_ar9287_fill_eeprom(struct ath_hw *ah)int addr, eep_start_loc; eep_data = (u16 *)eep; -if (AR9287_HTC_DEVID (ah)) - eep_start_loc =AR9287_HTC_EEP_START_LOC ; -else +if (!common->driver_info) eep_start_loc =AR9287_EEP_START_LOC ; +else + eep_start_loc =AR9287_HTC_EEP_START_LOC ;if (!ath9k_hw_use_flash (ah)) { ath_print(common, ATH_DBG_EEPROM,
drivers/net/wireless/ath/ath9k/reg.h +0 -4
@@ -870,10 +870,6 @@ ((_ah)->hw_version.devid == 0xA704) || \ ((_ah)->hw_version.devid == 0x1200)) -#define AR9287_HTC_DEVID (_ah) \ - (((_ah)->hw_version.devid == 0x7015) || \ - ((_ah)->hw_version.devid == 0x1200)) -#define AR_RADIO_SREV_MAJOR 0xf0#define AR_RAD5133_SREV_MAJOR 0xc0#define AR_RAD2133_SREV_MAJOR 0xd0
Signature · 1 line
1.7.3.2
PATCH 4/4 ath9k_htc: Identify devices using driver_info
In reply to Rajkumar ManoharanCategorize AR7010 & AR9287 devices based on driver_info of usb_device_id, instead of PIDs. This avoids per-device cases and minimize code changes for new device addition.
--- drivers/net/wireless/ath/ath9k/hif_usb.c | 41 ++++++++---------------- drivers/net/wireless/ath/ath9k/htc.h | 2 +- drivers/net/wireless/ath/ath9k/htc_drv_init.c | 35 ++++++++++----------- drivers/net/wireless/ath/ath9k/htc_hst.c | 5 ++- drivers/net/wireless/ath/ath9k/htc_hst.h | 3 +- drivers/net/wireless/ath/ath9k/reg.h | 6 +--- 6 files changed, 37 insertions(+), 55 deletions(-)
drivers/net/wireless/ath/ath9k/hif_usb.c +14 -27
@@ -786,7 +786,8 @@ static void ath9k_hif_usb_dealloc_urbs(struct hif_device_usb *hif_dev)ath9k_hif_usb_dealloc_rx_urbs (hif_dev); } -static int ath9k_hif_usb_download_fw (struct hif_device_usb *hif_dev) +static int ath9k_hif_usb_download_fw (struct hif_device_usb *hif_dev, +u32 drv_info) {int transfer, err;const void *data = hif_dev->firmware->data;
@@ -817,18 +818,10 @@ static int ath9k_hif_usb_download_fw(struct hif_device_usb *hif_dev) }kfree (buf); -switch (hif_dev->device_id) { -case 0x7010 : -case 0x7015 : -case 0x9018 : -case 0xA704 : -case 0x1200 : +if (drv_info &AR7010_DEVICE ) firm_offset =AR7010_FIRMWARE_TEXT ; -break ; -default : +else firm_offset =AR9271_FIRMWARE_TEXT ; -break ; - }/* * Issue FW download complete command to firmware.
@@ -846,7 +839,7 @@ static int ath9k_hif_usb_download_fw(struct hif_device_usb *hif_dev)return 0 ; } -static int ath9k_hif_usb_dev_init (struct hif_device_usb *hif_dev) +static int ath9k_hif_usb_dev_init (struct hif_device_usb *hif_dev,u32 drv_info) {int ret, idx;struct usb_host_interface *alt = &hif_dev->interface->altsetting[0 ];
@@ -862,7 +855,7 @@ static int ath9k_hif_usb_dev_init(struct hif_device_usb *hif_dev) }/* Download firmware */ - ret =ath9k_hif_usb_download_fw (hif_dev); + ret =ath9k_hif_usb_download_fw (hif_dev, drv_info);if (ret) { dev_err(&hif_dev->udev->dev, "ath9k_htc: Firmware - %s download failed\n",
@@ -941,23 +934,15 @@ static int ath9k_hif_usb_probe(struct usb_interface *interface,/* Find out which firmware to load */ -switch (hif_dev->device_id) { -case 0x7010 : -case 0x7015 : -case 0x9018 : -case 0xA704 : -case 0x1200 : +if (id->driver_info &AR7010_DEVICE )if (le16_to_cpu (udev->descriptor.bcdDevice) ==0x0202 ) hif_dev->fw_name =FIRMWARE_AR7010_1_1 ;else hif_dev->fw_name =FIRMWARE_AR7010 ; -break ; -default : +else hif_dev->fw_name =FIRMWARE_AR9271 ; -break ; - } - ret =ath9k_hif_usb_dev_init (hif_dev); + ret =ath9k_hif_usb_dev_init (hif_dev, id->driver_info);if (ret) { ret = -EINVAL ; goto err_hif_init_usb;
@@ -965,7 +950,7 @@ static int ath9k_hif_usb_probe(struct usb_interface *interface, ret =ath9k_htc_hw_init (hif_dev->htc_handle, &hif_dev->udev->dev, hif_dev->device_id, - hif_dev->udev->product); + hif_dev->udev->product, id->driver_info);if (ret) { ret = -EINVAL ; goto err_htc_hw_init;
@@ -1043,6 +1028,7 @@ static int ath9k_hif_usb_resume(struct usb_interface *interface) {struct hif_device_usb *hif_dev = (struct hif_device_usb *)usb_get_intfdata (interface); +struct htc_target *htc_handle = hif_dev->htc_handle;int ret; ret =ath9k_hif_usb_alloc_urbs (hif_dev);
@@ -1050,7 +1036,8 @@ static int ath9k_hif_usb_resume(struct usb_interface *interface)return ret;if (hif_dev->firmware) { - ret =ath9k_hif_usb_download_fw (hif_dev); + ret =ath9k_hif_usb_download_fw (hif_dev, + htc_handle->drv_priv->ah->common.driver_info);if (ret) goto fail_resume; }else {
@@ -1060,7 +1047,7 @@ static int ath9k_hif_usb_resume(struct usb_interface *interface)mdelay (100 ); - ret =ath9k_htc_resume (hif_dev->htc_handle); + ret =ath9k_htc_resume (htc_handle);if (ret) goto fail_resume;
drivers/net/wireless/ath/ath9k/htc.h +1 -1
@@ -461,7 +461,7 @@ void ath9k_init_leds(struct ath9k_htc_priv *priv);void ath9k_deinit_leds (struct ath9k_htc_priv *priv);int ath9k_htc_probe_device (struct htc_target *htc_handle,struct device *dev, -u16 devid,char *product); +u16 devid,char *product,u32 drv_info);void ath9k_htc_disconnect_device (struct htc_target *htc_handle,bool hotunplug);#ifdef CONFIG_PM int ath9k_htc_resume (struct htc_target *htc_handle);
drivers/net/wireless/ath/ath9k/htc_drv_init.c +16 -19
@@ -181,7 +181,8 @@ static inline int ath9k_htc_connect_svc(struct ath9k_htc_priv *priv,return htc_connect_service (priv->htc, &req, ep_id); } -static int ath9k_init_htc_services (struct ath9k_htc_priv *priv,u16 devid) +static int ath9k_init_htc_services (struct ath9k_htc_priv *priv,u16 devid, +u32 drv_info) {int ret;
@@ -245,17 +246,10 @@ static int ath9k_init_htc_services(struct ath9k_htc_priv *priv, u16 devid)* the HIF layer, shouldn't matter much. */ -switch (devid) { -case 0x7010 : -case 0x7015 : -case 0x9018 : -case 0xA704 : -case 0x1200 : +if (drv_info &AR7010_DEVICE ) priv->htc->credits =45 ; -break ; -default : +else priv->htc->credits =33 ; - } ret =htc_init (priv->htc);if (ret)
@@ -627,7 +621,8 @@ static void ath9k_init_btcoex(struct ath9k_htc_priv *priv) }static int ath9k_init_priv (struct ath9k_htc_priv *priv, -u16 devid,char *product) +u16 devid,char *product, +u32 drv_info) {struct ath_hw *ah =NULL ;struct ath_common *common;
@@ -650,6 +645,7 @@ static int ath9k_init_priv(struct ath9k_htc_priv *priv, common->hw = priv->hw; common->priv = priv; common->debug_mask = ath9k_debug; + common->driver_info = drv_info;spin_lock_init (&priv->wmi->wmi_lock);spin_lock_init (&priv->beacon_lock);
@@ -762,7 +758,7 @@ static void ath9k_set_hw_capab(struct ath9k_htc_priv *priv, }static int ath9k_init_device (struct ath9k_htc_priv *priv, -u16 devid,char *product) +u16 devid,char *product,u32 drv_info) {struct ieee80211_hw *hw = priv->hw;struct ath_common *common;
@@ -771,7 +767,7 @@ static int ath9k_init_device(struct ath9k_htc_priv *priv,struct ath_regulatory *reg;/* Bring up device */ - error =ath9k_init_priv (priv, devid, product); + error =ath9k_init_priv (priv, devid, product, drv_info);if (error !=0 ) goto err_init;
@@ -829,7 +825,7 @@ err_init: }int ath9k_htc_probe_device (struct htc_target *htc_handle,struct device *dev, -u16 devid,char *product) +u16 devid,char *product,u32 drv_info) {struct ieee80211_hw *hw;struct ath9k_htc_priv *priv;
@@ -856,14 +852,14 @@ int ath9k_htc_probe_device(struct htc_target *htc_handle, struct device *dev, goto err_free; } - ret =ath9k_init_htc_services (priv, devid); + ret =ath9k_init_htc_services (priv, devid, drv_info);if (ret) goto err_init;/* The device may have been unplugged earlier. */ priv->op_flags &= ~OP_UNPLUGGED ; - ret =ath9k_init_device (priv, devid, product); + ret =ath9k_init_device (priv, devid, product, drv_info);if (ret) goto err_init;
@@ -893,14 +889,15 @@ void ath9k_htc_disconnect_device(struct htc_target *htc_handle, bool hotunplug)#ifdef CONFIG_PM int ath9k_htc_resume (struct htc_target *htc_handle) { +struct ath9k_htc_priv *priv = htc_handle->drv_priv;int ret; - ret =ath9k_htc_wait_for_target (htc_handle->drv_priv); + ret =ath9k_htc_wait_for_target (priv);if (ret)return ret; - ret =ath9k_init_htc_services (htc_handle->drv_priv, - htc_handle->drv_priv->ah->hw_version.devid); + ret =ath9k_init_htc_services (priv, priv->ah->hw_version.devid, + priv->ah->common.driver_info);return ret; }#endif
drivers/net/wireless/ath/ath9k/htc_hst.c +3 -2
@@ -462,9 +462,10 @@ void ath9k_htc_hw_free(struct htc_target *htc) }int ath9k_htc_hw_init (struct htc_target *target, -struct device *dev,u16 devid,char *product) +struct device *dev,u16 devid, +char *product,u32 drv_info) { -if (ath9k_htc_probe_device (target, dev, devid, product)) { +if (ath9k_htc_probe_device (target, dev, devid, product, drv_info)) {printk (KERN_ERR "Failed to initialize the device\n" );return -ENODEV ; }
drivers/net/wireless/ath/ath9k/htc_hst.h +2 -1
@@ -239,7 +239,8 @@ struct htc_target *ath9k_htc_hw_alloc(void *hif_handle, struct device *dev);void ath9k_htc_hw_free (struct htc_target *htc);int ath9k_htc_hw_init (struct htc_target *target, -struct device *dev,u16 devid,char *product); +struct device *dev,u16 devid,char *product, +u32 drv_info);void ath9k_htc_hw_deinit (struct htc_target *target,bool hot_unplug);#endif /* HTC_HST_H */
drivers/net/wireless/ath/ath9k/reg.h +1 -5
@@ -864,11 +864,7 @@ ((REG_READ(_ah, AR_AN_SYNTH9) & 0x7) == 0x1))#define AR_DEVID_7010 (_ah) \ - (((_ah)->hw_version.devid == 0x7010) || \ - ((_ah)->hw_version.devid == 0x7015) || \ - ((_ah)->hw_version.devid == 0x9018) || \ - ((_ah)->hw_version.devid == 0xA704) || \ - ((_ah)->hw_version.devid == 0x1200)) + ((_ah)->common.driver_info & AR7010_DEVICE)#define AR_RADIO_SREV_MAJOR 0xf0#define AR_RAD5133_SREV_MAJOR 0xc0
Signature · 1 line
1.7.3.2
drivers/net/wireless/ath/ath.h struct ath_common { · line 155
Quoted 13 lines · Rajkumar Manoharan
The
driver_infostores the device category information which is used to load appropriate device firmware, select firmware offset and eeprom starting location. Thedriver_infois accessed acrossath9k_htcandath9k_hw. Hence placed under common structure./**
* structath_ops- Register read/write operations *drivers/net/wireless/ath/ath.h +1
-0@@ -147,6 +152,7 @@ struct ath_common { u8 rx_chainmask; u32 rx_bufsize; + u32 driver_info;
u32 for 2 bits?
Signature · 1 line
Bob Copeland %% www.bobcopeland.com
Quoted 13 lines · On Monday 22 November 2010 22:23:36 Bob Copeland wrote:
Quoted 11 lines · Rajkumar Manoharan
The
driver_infostores the device category information which is used to load appropriate device firmware, select firmware offset and eeprom starting location. Thedriver_infois accessed acrossath9k_htcandath9k_hw. Hence placed under common structure./**
* structath_ops- Register read/write operations *drivers/net/wireless/ath/ath.h +0
-0@@ -147,6 +152,7 @@ struct ath_common {u8 rx_chainmask;
Quoted 5 lines
drivers/net/wireless/ath/ath.h struct ath_common { · line 155
Quoted 2 lines
drivers/net/wireless/ath/ath.h +1
-0u32 rx_bufsize; +u32 driver_info;u32 for 2 bits?
well, if you take in account that mod_devicetable.h specifies driver_info to be kernel_ulong_t... (to store pointers of course)
I would say we need "even" more.
Best regards,
Chr
Quoted 13 lines · Bob Copeland
Quoted 11 lines · Rajkumar Manoharan
The
driver_infostores the device category information which is used to load appropriate device firmware, select firmware offset and eeprom starting location. Thedriver_infois accessed acrossath9k_htcandath9k_hw. Hence placed under common structure./**
* structath_ops- Register read/write operations *drivers/net/wireless/ath/ath.h +0
-0@@ -147,6 +152,7 @@ struct ath_common { u8 rx_chainmask;
Quoted 5 lines
drivers/net/wireless/ath/ath.h struct ath_common { · line 155
Quoted 2 lines
drivers/net/wireless/ath/ath.h +1
-0u32 rx_bufsize; + u32 driver_info;u32 for 2 bits?
Just to avoid a hole in 4-byte packing. Nothing spl.
--
Rajkumar