ath5k_rfkill.c
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 FILE_LICENCE ( MIT );
00038
00039 #include "base.h"
00040
00041
00042 static inline void ath5k_rfkill_disable(struct ath5k_softc *sc)
00043 {
00044 DBG("ath5k: rfkill disable (gpio:%d polarity:%d)\n",
00045 sc->rf_kill.gpio, sc->rf_kill.polarity);
00046 ath5k_hw_set_gpio_output(sc->ah, sc->rf_kill.gpio);
00047 ath5k_hw_set_gpio(sc->ah, sc->rf_kill.gpio, !sc->rf_kill.polarity);
00048 }
00049
00050
00051 static inline void ath5k_rfkill_enable(struct ath5k_softc *sc)
00052 {
00053 DBG("ath5k: rfkill enable (gpio:%d polarity:%d)\n",
00054 sc->rf_kill.gpio, sc->rf_kill.polarity);
00055 ath5k_hw_set_gpio_output(sc->ah, sc->rf_kill.gpio);
00056 ath5k_hw_set_gpio(sc->ah, sc->rf_kill.gpio, sc->rf_kill.polarity);
00057 }
00058
00059 static inline void ath5k_rfkill_set_intr(struct ath5k_softc *sc, int enable)
00060 {
00061 struct ath5k_hw *ah = sc->ah;
00062 u32 curval;
00063
00064 ath5k_hw_set_gpio_input(ah, sc->rf_kill.gpio);
00065 curval = ath5k_hw_get_gpio(ah, sc->rf_kill.gpio);
00066 ath5k_hw_set_gpio_intr(ah, sc->rf_kill.gpio, enable ?
00067 !!curval : !curval);
00068 }
00069
00070 static int __unused
00071 ath5k_is_rfkill_set(struct ath5k_softc *sc)
00072 {
00073
00074
00075 return (ath5k_hw_get_gpio(sc->ah, sc->rf_kill.gpio) ==
00076 sc->rf_kill.polarity);
00077 }
00078
00079 void
00080 ath5k_rfkill_hw_start(struct ath5k_hw *ah)
00081 {
00082 struct ath5k_softc *sc = ah->ah_sc;
00083
00084
00085 sc->rf_kill.gpio = ah->ah_capabilities.cap_eeprom.ee_rfkill_pin;
00086 sc->rf_kill.polarity = ah->ah_capabilities.cap_eeprom.ee_rfkill_pol;
00087
00088 ath5k_rfkill_disable(sc);
00089
00090
00091 if (AR5K_EEPROM_HDR_RFKILL(ah->ah_capabilities.cap_eeprom.ee_header))
00092 ath5k_rfkill_set_intr(sc, 1);
00093 }
00094
00095
00096 void
00097 ath5k_rfkill_hw_stop(struct ath5k_hw *ah)
00098 {
00099 struct ath5k_softc *sc = ah->ah_sc;
00100
00101
00102 if (AR5K_EEPROM_HDR_RFKILL(ah->ah_capabilities.cap_eeprom.ee_header))
00103 ath5k_rfkill_set_intr(sc, 0);
00104
00105
00106 ath5k_rfkill_enable(sc);
00107 }