ath5k: led, cleanup and prepare macros
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 2/3 ath5k: led, cleanup and prepare macros
From: Jiri Slaby <[email protected]>
We need to use driver_data for more than pin and polaroty data. Remove driver_data designator from ATH_LED definition and write it explicitly.
--- drivers/net/wireless/ath/ath5k/led.c | 33 +++++++++++++++++++++------------ 1 files changed, 21 insertions(+), 12 deletions(-)
drivers/net/wireless/ath/ath5k/led.c +21 -12
@@ -47,30 +47,39 @@ .vendor = PCI_ANY_ID, .device = PCI_ANY_ID, \ .subvendor = (subv), .subdevice = (subd) -#define ATH_LED (pin,polarity) .driver_data = (((pin) << 8) | (polarity)) -#define ATH_PIN (data) ((data) >> 8) -#define ATH_POLARITY (data) ((data) & 0xff) +#define ATH_LED (pin, polarity) (((pin) << 8) | (polarity)) +#define ATH_PIN (data) (((data) >> 8) & 0xffff) +#define ATH_POLARITY (data) ((data) & 0xff)/* Devices we match on for LED config info (typically laptops) */ static const struct pci_device_id ath5k_led_devices[] = {/* AR5211 */ - {PCI_VDEVICE (ATHEROS ,PCI_DEVICE_ID_ATHEROS_AR5211 ),ATH_LED (0 ,0 ) }, + {PCI_VDEVICE (ATHEROS ,PCI_DEVICE_ID_ATHEROS_AR5211 ), + .driver_data =ATH_LED (0 ,0 ) },/* HP Compaq nc6xx, nc4000, nx6000 */ - {ATH_SDEVICE (PCI_VENDOR_ID_COMPAQ ,PCI_ANY_ID ),ATH_LED (1 ,1 ) }, + {ATH_SDEVICE (PCI_VENDOR_ID_COMPAQ ,PCI_ANY_ID ), + .driver_data =ATH_LED (1 ,1 ) },/* Acer Aspire One A150 ([email protected]) */ - {ATH_SDEVICE (PCI_VENDOR_ID_FOXCONN ,0xe008 ),ATH_LED (3 ,0 ) }, + {ATH_SDEVICE (PCI_VENDOR_ID_FOXCONN ,0xe008 ), + .driver_data =ATH_LED (3 ,0 ) },/* Acer Ferrari 5000 ([email protected]) */ - {ATH_SDEVICE (PCI_VENDOR_ID_AMBIT ,0x0422 ),ATH_LED (1 ,1 ) }, + {ATH_SDEVICE (PCI_VENDOR_ID_AMBIT ,0x0422 ), + .driver_data =ATH_LED (1 ,1 ) },/* E-machines E510 ([email protected]) */ - {ATH_SDEVICE (PCI_VENDOR_ID_AMBIT ,0x0428 ),ATH_LED (3 ,0 ) }, + {ATH_SDEVICE (PCI_VENDOR_ID_AMBIT ,0x0428 ), + .driver_data =ATH_LED (3 ,0 ) },/* Acer Extensa 5620z ([email protected]) */ - {ATH_SDEVICE (PCI_VENDOR_ID_QMI ,0x0105 ),ATH_LED (3 ,0 ) }, + {ATH_SDEVICE (PCI_VENDOR_ID_QMI ,0x0105 ), + .driver_data =ATH_LED (3 ,0 ) },/* Fukato Datacask Jupiter 1014a ([email protected]) */ - {ATH_SDEVICE (PCI_VENDOR_ID_AZWAVE ,0x1026 ),ATH_LED (3 ,0 ) }, + {ATH_SDEVICE (PCI_VENDOR_ID_AZWAVE ,0x1026 ), + .driver_data =ATH_LED (3 ,0 ) },/* IBM ThinkPad AR5BXB6 ([email protected]) */ - {ATH_SDEVICE (PCI_VENDOR_ID_IBM ,0x058a ),ATH_LED (1 ,0 ) }, + {ATH_SDEVICE (PCI_VENDOR_ID_IBM ,0x058a ), + .driver_data =ATH_LED (1 ,0 ) },/* IBM-specific AR5212 (all others) */ - {PCI_VDEVICE (ATHEROS ,PCI_DEVICE_ID_ATHEROS_AR5212_IBM ),ATH_LED (0 ,0 ) }, + {PCI_VDEVICE (ATHEROS ,PCI_DEVICE_ID_ATHEROS_AR5212_IBM ), + .driver_data =ATH_LED (0 ,0 ) }, { } };
Signature · 1 line
1.6.3
Re: [PATCH 1/3] ath5k: add support for radio LED
In reply to a message not in the archiveHi,
Am Mittwoch, 20. Mai 2009 22:08:57 schrieb Jiri Slaby:
Quoted 4 lines
From: Tobias Doerffel <[email protected]>
I found these patches on the web not being merged since Jan. Was there any reason why they shouldn't be accepted?
Yes - they needed further work. The approach was wrong because the GPIO does not control the LED rather than some internal rfkill mechanism (which itself controls the LED). I therefore reworked things to have general RFKILL support in ath5k and proposed the patches. They were reviewed by Bob Copeland and I addressed most of the issues so far but didn't come up with a new patch yet, as there're still minor things to be worked out. If there's interest, I'll prepare a new patch which represents the current state.
Toby
Re: [PATCH 1/3] ath5k: add support for radio LED
Quoted 7 lines · Tobias Doerffel
Hi,
Am Mittwoch, 20. Mai 2009 22:08:57 schrieb Jiri Slaby:
Quoted 4 lines
From: Tobias Doerffel <[email protected]>
I found these patches on the web not being merged since Jan. Was there any reason why they shouldn't be accepted?
Quoted 7 lines
Yes - they needed further work. The approach was wrong because the GPIO does not control the LED rather than some internal rfkill mechanism (which itself controls the LED). I therefore reworked things to have general RFKILL support in ath5k and proposed the patches. They were reviewed by Bob Copeland and I addressed most of the issues so far but didn't come up with a new patch yet, as there're still minor things to be worked out. If there's interest, I'll prepare a new patch which represents the current state.
I think we are definitely interested. Please send an updated patch.
Thanks.
Re: [PATCH 1/3] ath5k: add support for radio LED
In reply to Tobias DoerffelOn Wed, 20 May 2009 22:16:42 +0200, Tobias Doerffel wrote
Quoted 2 lines
If there's interest, I'll prepare a new patch which represents the current state.
I'm definitely interested in seeing rfkill gpio support getting in, it's overdue. So I say repost it and we can fasttrack that. Digging up your last patchset was already on my todo list.
As for patch 2/3 it might be a good idea to have support for which-led-does-what encoded into the driver data anyway; other people have asked for that and the "solution" of adding various echos to sysfs LED trigger files is rather sad. OTOH it could eventually be a lot of data to carry around.
Signature · 1 line
Bob Copeland %% www.bobcopeland.com
Re: [PATCH 1/3] ath5k: add support for radio LED
Am Mittwoch, 20. Mai 2009 22:29:42 schrieb Bob Copeland:
Quoted 7 lines
On Wed, 20 May 2009 22:16:42 +0200, Tobias Doerffel wrote
Quoted 2 lines
If there's interest, I'll prepare a new patch which represents the current state.
I'm definitely interested in seeing rfkill gpio support getting in, it's overdue. So I say repost it and we can fasttrack that.
Should be rebased against wireless-testing branch (with the changed directory structure), right?
Toby
Re: [ath5k-devel] [PATCH 1/3] ath5k: add support for radio LED
Quoted 2 lines · Tobias Doerffel
Should be rebased against wireless-testing branch (with the changed directory structure), right?
That would be ideal (if it still applies somewhat cleanly, you can just edit the patch paths directly).
Signature · 1 line
Bob Copeland %% www.bobcopeland.com
Re: [PATCH 1/3] ath5k: add support for radio LED
In reply to Tobias DoerffelQuoted 8 lines · Tobias Doerffel
Am Mittwoch, 20. Mai 2009 22:29:42 schrieb Bob Copeland:
Quoted 7 lines
On Wed, 20 May 2009 22:16:42 +0200, Tobias Doerffel wrote
Quoted 2 lines
If there's interest, I'll prepare a new patch which represents the current state.
I'm definitely interested in seeing rfkill gpio support getting in, it's overdue. So I say repost it and we can fasttrack that.
By the way, it's a good idea to work against Johannes Berg's new patchset for rfkill which should simplify a lot of the details in the driver. Patches are at:
http://johannes.sipsolutions.net/patches/kernel/all/LATEST/
Signature · 1 line
Bob Copeland %% www.bobcopeland.com
PATCH 1/1 ath5k: added initial RFKILL support
In reply to Bob CopelandHi,
Am Mittwoch, 20. Mai 2009 22:29:42 schrieb Bob Copeland:
Quoted 3 lines
I'm definitely interested in seeing rfkill gpio support getting in, it's overdue. So I say repost it and we can fasttrack that. Digging up your last patchset was already on my todo list.
Here we go. I attached a patch (against wireless-testing) which represents my latest work on RFKILL support for ath5k. It still lacks testing with a real physical rfkill switch (for I don't have one with my NC10) but everything else (SW rfkill) works fine after testing various scenarios. Furthermore I think I addressed all remarks in the last review by Bob Copeland.
Regards,
Toby
From 0dfab8fbd3223747e2a7948296606e661899630b Mon Sep 17 00:00:00 2001
From: Tobias Doerffel <[email protected]>
Date: Tue, 26 May 2009 00:52:20 +0200
Subject: [PATCH] ath5k: added initial RFKILL support
This patch introduces initial RFKILL support for the ath5k driver. All RFKILL related code is separated into newly created rfkill.c.
Changes to existing code are minimal:
- added a new data structure ath5k_rfkill to the ath5k_softc structure
- new function ath5k_eeprom_read_rfkill() for retrieving RFKILL related parameters from EEPROM
- inserted calls to init/deinit routines for both the SW and HW part of RFKILL support
- ath5k_intr() has been extended to handle AR5K_INT_GPIO interrupts
--- drivers/net/wireless/ath/ath5k/Kconfig | 9 + drivers/net/wireless/ath/ath5k/Makefile | 1 + drivers/net/wireless/ath/ath5k/ath5k.h | 22 +++ drivers/net/wireless/ath/ath5k/base.c | 20 ++- drivers/net/wireless/ath/ath5k/base.h | 26 +++ drivers/net/wireless/ath/ath5k/eeprom.c | 16 ++ drivers/net/wireless/ath/ath5k/reset.c | 17 -- drivers/net/wireless/ath/ath5k/rfkill.c | 268 +++++++++++++++++++++++++++++++ 8 files changed, 358 insertions(+), 21 deletions(-) create mode 100644 drivers/net/wireless/ath/ath5k/rfkill.c
drivers/net/wireless/ath/ath5k/Kconfig +9 -0
@@ -39,3 +39,12 @@ config ATH5K_DEBUG modprobe ath5k debug=0x00000400 +config ATH5K_RFKILL + bool "Atheros 5xxx rfkill support" + select RFKILL + depends on ATH5K + default y + ---help--- + Include support for enabling/disabling WiFi via rfkill switch + with Atheros 5xxx cards +
drivers/net/wireless/ath/ath5k/Makefile +1 -0
@@ -12,4 +12,5 @@ ath5k-y += attach.o ath5k-y += base.o ath5k-y += led.o ath5k-$(CONFIG_ATH5K_DEBUG) += debug.o +ath5k-$(CONFIG_ATH5K_RFKILL) += rfkill.o obj-$(CONFIG_ATH5K) += ath5k.o
drivers/net/wireless/ath/ath5k/ath5k.h +22 -0
@@ -1162,6 +1162,10 @@ extern void ath5k_led_enable(struct ath5k_softc *sc);extern void ath5k_led_off (struct ath5k_softc *sc);extern void ath5k_unregister_leds (struct ath5k_softc *sc); +/* Start/Stop Functions */ +extern int ath5k_init (struct ath5k_softc *sc); +extern int ath5k_stop_hw (struct ath5k_softc *sc); +/* Reset Functions */ extern int ath5k_hw_nic_wakeup (struct ath5k_hw *ah,int flags,bool initial);extern int ath5k_hw_reset (struct ath5k_hw *ah,enum nl80211_iftype op_mode,struct ieee80211_channel *channel,bool change_channel);
@@ -1190,6 +1194,7 @@ extern void ath5k_hw_update_mib_counters(struct ath5k_hw *ah, struct ieee80211_lextern int ath5k_eeprom_init (struct ath5k_hw *ah);extern void ath5k_eeprom_detach (struct ath5k_hw *ah);extern int ath5k_eeprom_read_mac (struct ath5k_hw *ah,u8 *mac); +extern void ath5k_eeprom_read_rfkill (struct ath5k_hw *ah,u16 *gpio,u8 *polarity);extern bool ath5k_eeprom_is_hb63 (struct ath5k_hw *ah);/* Protocol Control Unit Functions */
@@ -1256,6 +1261,23 @@ extern u32 ath5k_hw_get_gpio(struct ath5k_hw *ah, u32 gpio);extern int ath5k_hw_set_gpio (struct ath5k_hw *ah,u32 gpio,u32 val);extern void ath5k_hw_set_gpio_intr (struct ath5k_hw *ah,unsigned int gpio,u32 interrupt_level); +/* rfkill Functions */ +#ifdef CONFIG_ATH5K_RFKILL +extern int ath5k_rfkill_init (struct ath5k_softc *sc); +extern void ath5k_rfkill_deinit (struct ath5k_softc *sc); +extern void ath5k_rfkill_hw_start (struct ath5k_hw *ah); +extern void ath5k_rfkill_hw_stop (struct ath5k_hw *ah); +#else +static inline int ath5k_rfkill_init (struct ath5k_softc *sc) +{ +return 0 ; +} + +static inline void ath5k_rfkill_deinit (struct ath5k_softc *sc) {} +static inline void ath5k_rfkill_hw_start (struct ath5k_hw *ah) {} +static inline void ath5k_rfkill_hw_stop (struct ath5k_hw *ah) {} +#endif +/* Misc functions */ int ath5k_hw_set_capabilities (struct ath5k_hw *ah);extern int ath5k_hw_get_capability (struct ath5k_hw *ah,enum ath5k_capability_type cap_type,u32 capability,u32 *result);
drivers/net/wireless/ath/ath5k/base.c +16 -4
@@ -363,9 +363,7 @@ static inline u64 ath5k_extend_tsf(struct ath5k_hw *ah, u32 rstamp) }/* Interrupt handling */ -static int ath5k_init (struct ath5k_softc *sc);static int ath5k_stop_locked (struct ath5k_softc *sc); -static int ath5k_stop_hw (struct ath5k_softc *sc);static irqreturn_t ath5k_intr (int irq,void *dev_id);static void ath5k_tasklet_reset (unsigned long data);
@@ -822,6 +820,9 @@ ath5k_attach(struct pci_dev *pdev, struct ieee80211_hw *hw)ath5k_init_leds (sc); +/* Initialize rfkill subsystem */ +ath5k_rfkill_init (sc); +return 0 ; err_queues:ath5k_txq_release (sc);
@@ -856,6 +857,7 @@ ath5k_detach(struct pci_dev *pdev, struct ieee80211_hw *hw)ath5k_txq_release (sc);ath5k_hw_release_tx_queue (sc->ah, sc->bhalq);ath5k_unregister_leds (sc); +ath5k_rfkill_deinit (sc);/* * NB: can't reclaim these until after ieee80211_ifdetach
@@ -2321,7 +2323,7 @@ static void ath5k_tasklet_beacon(unsigned long data)* Interrupt handling * \********************/ -static int +int ath5k_init (struct ath5k_softc *sc) {struct ath5k_hw *ah = sc->ah;
@@ -2353,6 +2355,8 @@ ath5k_init(struct ath5k_softc *sc)if (ret) goto done; +ath5k_rfkill_hw_start (ah); +/* * Reset the key cache since some parts do not reset the * contents on initial power up or resume from suspend.
@@ -2419,7 +2423,7 @@ ath5k_stop_locked(struct ath5k_softc *sc)* if another thread does a system call and the thread doing the * stop is preempted). */ -static int +int ath5k_stop_hw (struct ath5k_softc *sc) {int ret;
@@ -2461,6 +2465,8 @@ ath5k_stop_hw(struct ath5k_softc *sc)tasklet_kill (&sc->restq);tasklet_kill (&sc->beacontq); +ath5k_rfkill_hw_stop (sc->ah); +return ret; }
@@ -2519,6 +2525,12 @@ ath5k_intr(int irq, void *dev_id)*/ ath5k_hw_update_mib_counters (ah, &sc->ll_stats); } +#ifdef CONFIG_ATH5K_RFKILL +if (status &AR5K_INT_GPIO ) + { +tasklet_schedule (&sc->rf_kill.toggleq); + } +#endif } }while (ath5k_hw_is_intr_pending (ah) && --counter >0 );
drivers/net/wireless/ath/ath5k/base.h +26 -0
@@ -46,6 +46,7 @@#include <linux/wireless.h> #include <linux/if_ether.h> #include <linux/leds.h> +#include <linux/rfkill.h> #include "ath5k.h" #include "debug.h"
@@ -91,6 +92,27 @@ struct ath5k_ledstruct led_classdev led_dev;/* led classdev */ }; +/* Rfkill */ +#define ATH5K_RFKILL_FLAG_HW_STARTED BIT(0) +#define ATH5K_RFKILL_FLAG_SW_BLOCKED BIT(1) +#define ATH5K_RFKILL_FLAG_HW_BLOCKED BIT(2) + +struct ath5k_rfkill { +/* GPIO PIN for rfkill */ +u16 gpio; +/* polarity of rfkill GPIO PIN */ +u8 polarity; +/* The RFKILL subsystem data structure */ +struct rfkill *rfkill; +/* The unique name of this rfkill switch */ +char rfkill_name[32 ]; +/* Flags indicating SW RFKILL status */ +u32 flags; +/* RFKILL toggle tasklet */ +struct tasklet_struct toggleq; +/* mutex for RFKILL related operations */ +struct mutex lock; +};#if CHAN_DEBUG #define ATH_CHAN_MAX (26+26+26+200+200)
@@ -167,6 +189,10 @@ struct ath5k_softc {struct tasklet_struct txtq;/* tx intr tasklet */ struct ath5k_led tx_led;/* tx led */ +#ifdef CONFIG_ATH5K_RFKILL +struct ath5k_rfkill rf_kill; +#endif +spinlock_t block;/* protects beacon */ struct tasklet_struct beacontq;/* beacon intr tasklet */ struct ath5k_buf *bbuf;/* beacon buffer */
drivers/net/wireless/ath/ath5k/eeprom.c +16 -0
@@ -1800,3 +1800,19 @@ int ath5k_eeprom_read_mac(struct ath5k_hw *ah, u8 *mac)return 0 ; } + + +/* +* Read RFKILL GPIO configuration from eeprom +*/ +void ath5k_eeprom_read_rfkill (struct ath5k_hw *ah,u16 *gpio,u8 *polarity) +{ +u16 data; + +ath5k_hw_eeprom_read (ah,AR5K_EEPROM_RFKILL_GPIO_SEL , &data); + *gpio =AR5K_REG_MS (data,AR5K_EEPROM_RFKILL_GPIO_SEL ); + +ath5k_hw_eeprom_read (ah,AR5K_EEPROM_RFKILL_POLARITY , &data); + *polarity =AR5K_REG_MS (data,AR5K_EEPROM_RFKILL_POLARITY ); +} +
drivers/net/wireless/ath/ath5k/reset.c +0 -17
@@ -1305,23 +1305,6 @@ int ath5k_hw_reset(struct ath5k_hw *ah, enum nl80211_iftype op_mode,if (ah->ah_version !=AR5K_AR5210 )ath5k_hw_set_imr (ah, ah->ah_imr); -/* -* Setup RFKill interrupt if rfkill flag is set on eeprom. -* TODO: Use gpio pin and polarity infos from eeprom -* TODO: Handle this in ath5k_intr because it'll result -* a nasty interrupt storm. -*/ -#if 0 -if (AR5K_EEPROM_HDR_RFKILL (ah->ah_capabilities.cap_eeprom.ee_header)) { -ath5k_hw_set_gpio_input (ah,0 ); - ah->ah_gpio[0 ] =ath5k_hw_get_gpio (ah,0 ); -if (ah->ah_gpio[0 ] ==0 ) -ath5k_hw_set_gpio_intr (ah,0 ,1 ); -else -ath5k_hw_set_gpio_intr (ah,0 ,0 ); - } -#endif -/* Enable 32KHz clock function for AR5212+ chips * Set clocks to 32KHz operation and use an * external 32KHz crystal when sleeping if one
drivers/net/wireless/ath/ath5k/rfkill.c new file +268 -0
268 lines not on this page · raw message
Signature · 1 line
1.6.3.1
Re: [PATCH] ath5k: added initial RFKILL support
drivers/net/wireless/ath/ath5k/rfkill.c line 204
Quoted 5 lines · Tobias Doerffel
drivers/net/wireless/ath/ath5k/rfkill.c new file +5
-0+ err =rfkill_register (sc->rf_kill.rfkill); +if (err) { + sc->rf_kill.rfkill =NULL ; +return -1 ; + }
Missing rfkill_free, and why -EPERM? Could you try to work against v11 of my rfkill patch, or better even against the cfg80211 rfkill instead?
johannes
Re: [PATCH] ath5k: added initial RFKILL support
Hi,
Am Dienstag, 26. Mai 2009 01:32:46 schrieb Johannes Berg:
Quoted 8 lines · Tobias Doerffel
drivers/net/wireless/ath/ath5k/rfkill.c line 204
Quoted 5 lines
drivers/net/wireless/ath/ath5k/rfkill.c new file +5
-0+ err =rfkill_register (sc->rf_kill.rfkill); +if (err) { + sc->rf_kill.rfkill =NULL ; +return -1 ; + }Missing
rfkill_free, and why-EPERM?
Thanks for this remark. I fixed the code and will post an updated patch soon.
Any other comments on the patch? If not, any chance to get it merged into wireless-testing branch?
Quoted 2 lines
Could you try to work against v11
of my rfkill patch, or better even against the cfg80211 rfkill instead?
I didn't look at both of them yet. However I think we first should try to get current rfkill support into mainline as fast as possible. Improvements and adaptations to reworked rfkill framework can follow.
Regards,
Toby
Re: [PATCH] ath5k: added initial RFKILL support
Quoted 5 lines · Tobias Doerffel
Quoted 2 lines
Could you try to work against v11
of my rfkill patch, or better even against the cfg80211 rfkill instead?I didn't look at both of them yet. However I think we first should try to get current rfkill support into mainline as fast as possible. Improvements and adaptations to reworked rfkill framework can follow.
No other comments from me -- but since the v11 of the rfkill rewrite will certainly hit the tree before your patch (it's almost in) you _will_ have to work against it. I'll also try to make the cfg80211 rfkill hit the tree very soon for reasons I'll explain elsewhere -- you would be better off working against that because then your rfkill code is very very very simple and doesn't need to do much at all.
johannes
Re: [ath5k-devel] [PATCH] ath5k: added initial RFKILL support
Quoted 10 lines · Johannes Berg
Quoted 7 lines · Tobias Doerffel
Quoted 2 lines
Could you try to work against v11
of my rfkill patch, or better even against the cfg80211 rfkill instead?I didn't look at both of them yet. However I think we first should try to get
current rfkill support into mainline as fast as possible. Improvements andadaptations to reworked rfkill framework can follow.
Quoted 8 lines
No other comments from me -- but since the v11 of the rfkill rewrite will certainly hit the tree before your patch (it's almost in) you _will_ have to work against it. I'll also try to make the cfg80211 rfkill hit the tree very soon for reasons I'll explain elsewhere -- you would be better off working against that because then your rfkill code is very very very simple and doesn't need to do much at all.
johannes
Btw, I believe the new rfkill core behaviour should avoid the concern I raised about the EeePC.
Reminder: the eeepc-laptop implements platform rfkill on the original model(s) by hotplugging the entire ath5k device. If you boot with it in the blocked state, the old rfkill core would "lock in" that state as the default. If you then hotplug the ath5k device _and it comes up with an rfkill device of it's own_, my concern is that the new rfkill device would be initialized to a blocked state. It would be impossible to enable the wireless.
The new core removes this idea of a separate "default" state, so it can't have this problem.
Regards
Alan