From 869ff02ebeed2f9ee7bfb41cb232aa20949d20ea Mon Sep 17 00:00:00 2001 From: Sam Leffler Date: Tue, 24 Feb 2009 00:12:16 +0000 Subject: [PATCH] 5416 and later parts mux the gpio outputs; extend the api to include a signal type that's used to select the appropriate mux --- sys/dev/ath/ath_hal/ah.h | 19 ++++++++++++++++++- sys/dev/ath/ath_hal/ah_internal.h | 4 ++-- sys/dev/ath/ath_hal/ar5210/ar5210.h | 3 ++- sys/dev/ath/ath_hal/ar5210/ar5210_misc.c | 2 +- sys/dev/ath/ath_hal/ar5211/ar5211.h | 3 ++- sys/dev/ath/ath_hal/ar5211/ar5211_misc.c | 2 +- sys/dev/ath/ath_hal/ar5212/ar5212.h | 3 ++- sys/dev/ath/ath_hal/ar5212/ar5212_gpio.c | 4 ++-- sys/dev/ath/ath_hal/ar5312/ar5312.h | 6 ++++-- sys/dev/ath/ath_hal/ar5312/ar5312_gpio.c | 4 ++-- sys/dev/ath/ath_hal/ar5312/ar5315_gpio.c | 4 ++-- sys/dev/ath/ath_hal/ar5416/ar5416.h | 3 ++- sys/dev/ath/ath_hal/ar5416/ar5416_gpio.c | 4 ++-- sys/dev/ath/if_ath.c | 12 ++++++++---- sys/dev/ath/if_athvar.h | 4 ++-- 15 files changed, 52 insertions(+), 25 deletions(-) diff --git a/sys/dev/ath/ath_hal/ah.h b/sys/dev/ath/ath_hal/ah.h index 8822d7c78564..d12c018c5071 100644 --- a/sys/dev/ath/ath_hal/ah.h +++ b/sys/dev/ath/ath_hal/ah.h @@ -358,6 +358,22 @@ typedef enum { | HAL_INT_GPIO, } HAL_INT; +typedef enum { + HAL_GPIO_MUX_OUTPUT = 0, + HAL_GPIO_MUX_PCIE_ATTENTION_LED = 1, + HAL_GPIO_MUX_PCIE_POWER_LED = 2, + HAL_GPIO_MUX_TX_FRAME = 3, + HAL_GPIO_MUX_RX_CLEAR_EXTERNAL = 4, + HAL_GPIO_MUX_MAC_NETWORK_LED = 5, + HAL_GPIO_MUX_MAC_POWER_LED = 6 +} HAL_GPIO_MUX_TYPE; + +typedef enum { + HAL_GPIO_INTR_LOW = 0, + HAL_GPIO_INTR_HIGH = 1, + HAL_GPIO_INTR_DISABLE = 2 +} HAL_GPIO_INTR_TYPE; + typedef enum { HAL_RFGAIN_INACTIVE = 0, HAL_RFGAIN_READ_REQUESTED = 1, @@ -700,7 +716,8 @@ struct ath_hal { void __ahdecl(*ah_setLedState)(struct ath_hal*, HAL_LED_STATE); void __ahdecl(*ah_writeAssocid)(struct ath_hal*, const uint8_t *bssid, uint16_t assocId); - HAL_BOOL __ahdecl(*ah_gpioCfgOutput)(struct ath_hal *, uint32_t gpio); + HAL_BOOL __ahdecl(*ah_gpioCfgOutput)(struct ath_hal *, + uint32_t gpio, HAL_GPIO_MUX_TYPE); HAL_BOOL __ahdecl(*ah_gpioCfgInput)(struct ath_hal *, uint32_t gpio); uint32_t __ahdecl(*ah_gpioGet)(struct ath_hal *, uint32_t gpio); HAL_BOOL __ahdecl(*ah_gpioSet)(struct ath_hal *, diff --git a/sys/dev/ath/ath_hal/ah_internal.h b/sys/dev/ath/ath_hal/ah_internal.h index 169a28fe0666..32550543dd92 100644 --- a/sys/dev/ath/ath_hal/ah_internal.h +++ b/sys/dev/ath/ath_hal/ah_internal.h @@ -311,8 +311,8 @@ struct ath_hal_private { AH_PRIVATE(_ah)->ah_eepromRead(_ah, _off, _data) #define ath_hal_eepromWrite(_ah, _off, _data) \ AH_PRIVATE(_ah)->ah_eepromWrite(_ah, _off, _data) -#define ath_hal_gpioCfgOutput(_ah, _gpio) \ - (_ah)->ah_gpioCfgOutput(_ah, _gpio) +#define ath_hal_gpioCfgOutput(_ah, _gpio, _type) \ + (_ah)->ah_gpioCfgOutput(_ah, _gpio, _type) #define ath_hal_gpioCfgInput(_ah, _gpio) \ (_ah)->ah_gpioCfgInput(_ah, _gpio) #define ath_hal_gpioGet(_ah, _gpio) \ diff --git a/sys/dev/ath/ath_hal/ar5210/ar5210.h b/sys/dev/ath/ath_hal/ar5210/ar5210.h index 5156e74d6bc8..01c1fdcc1f58 100644 --- a/sys/dev/ath/ath_hal/ar5210/ar5210.h +++ b/sys/dev/ath/ath_hal/ar5210/ar5210.h @@ -207,7 +207,8 @@ extern HAL_BOOL ar5210SetRegulatoryDomain(struct ath_hal *, extern u_int ar5210GetWirelessModes(struct ath_hal *ah); extern void ar5210EnableRfKill(struct ath_hal *); extern HAL_BOOL ar5210GpioCfgInput(struct ath_hal *, uint32_t gpio); -extern HAL_BOOL ar5210GpioCfgOutput(struct ath_hal *, uint32_t gpio); +extern HAL_BOOL ar5210GpioCfgOutput(struct ath_hal *, uint32_t gpio, + HAL_GPIO_MUX_TYPE); extern uint32_t ar5210GpioGet(struct ath_hal *, uint32_t gpio); extern HAL_BOOL ar5210GpioSet(struct ath_hal *, uint32_t gpio, uint32_t); extern void ar5210Gpio0SetIntr(struct ath_hal *, u_int, uint32_t ilevel); diff --git a/sys/dev/ath/ath_hal/ar5210/ar5210_misc.c b/sys/dev/ath/ath_hal/ar5210/ar5210_misc.c index bdd58ac38f53..7339f91c397f 100644 --- a/sys/dev/ath/ath_hal/ar5210/ar5210_misc.c +++ b/sys/dev/ath/ath_hal/ar5210/ar5210_misc.c @@ -158,7 +158,7 @@ ar5210EnableRfKill(struct ath_hal *ah) * Configure GPIO Output lines */ HAL_BOOL -ar5210GpioCfgOutput(struct ath_hal *ah, uint32_t gpio) +ar5210GpioCfgOutput(struct ath_hal *ah, uint32_t gpio, HAL_GPIO_MUX_TYPE type) { HALASSERT(gpio < AR_NUM_GPIO); diff --git a/sys/dev/ath/ath_hal/ar5211/ar5211.h b/sys/dev/ath/ath_hal/ar5211/ar5211.h index 01b80c4335ca..223f95446e30 100644 --- a/sys/dev/ath/ath_hal/ar5211/ar5211.h +++ b/sys/dev/ath/ath_hal/ar5211/ar5211.h @@ -233,7 +233,8 @@ extern u_int ar5211GetWirelessModes(struct ath_hal *); extern void ar5211EnableRfKill(struct ath_hal *); extern uint32_t ar5211GpioGet(struct ath_hal *, uint32_t gpio); extern void ar5211GpioSetIntr(struct ath_hal *, u_int, uint32_t ilevel); -extern HAL_BOOL ar5211GpioCfgOutput(struct ath_hal *, uint32_t gpio); +extern HAL_BOOL ar5211GpioCfgOutput(struct ath_hal *, uint32_t gpio, + HAL_GPIO_MUX_TYPE); extern HAL_BOOL ar5211GpioCfgInput(struct ath_hal *, uint32_t gpio); extern HAL_BOOL ar5211GpioSet(struct ath_hal *, uint32_t gpio, uint32_t val); extern void ar5211SetLedState(struct ath_hal *, HAL_LED_STATE); diff --git a/sys/dev/ath/ath_hal/ar5211/ar5211_misc.c b/sys/dev/ath/ath_hal/ar5211/ar5211_misc.c index 81d29b872bd7..33b9e216824f 100644 --- a/sys/dev/ath/ath_hal/ar5211/ar5211_misc.c +++ b/sys/dev/ath/ath_hal/ar5211/ar5211_misc.c @@ -192,7 +192,7 @@ ar5211EnableRfKill(struct ath_hal *ah) * Configure GPIO Output lines */ HAL_BOOL -ar5211GpioCfgOutput(struct ath_hal *ah, uint32_t gpio) +ar5211GpioCfgOutput(struct ath_hal *ah, uint32_t gpio, HAL_GPIO_MUX_TYPE type) { uint32_t reg; diff --git a/sys/dev/ath/ath_hal/ar5212/ar5212.h b/sys/dev/ath/ath_hal/ar5212/ar5212.h index 86a8674b4c3d..0b682ef36049 100644 --- a/sys/dev/ath/ath_hal/ar5212/ar5212.h +++ b/sys/dev/ath/ath_hal/ar5212/ar5212.h @@ -450,7 +450,8 @@ extern HAL_BOOL ar5212SetRegulatoryDomain(struct ath_hal *ah, uint16_t regDomain, HAL_STATUS *stats); extern u_int ar5212GetWirelessModes(struct ath_hal *ah); extern void ar5212EnableRfKill(struct ath_hal *); -extern HAL_BOOL ar5212GpioCfgOutput(struct ath_hal *, uint32_t gpio); +extern HAL_BOOL ar5212GpioCfgOutput(struct ath_hal *, uint32_t gpio, + HAL_GPIO_MUX_TYPE); extern HAL_BOOL ar5212GpioCfgInput(struct ath_hal *, uint32_t gpio); extern HAL_BOOL ar5212GpioSet(struct ath_hal *, uint32_t gpio, uint32_t val); extern uint32_t ar5212GpioGet(struct ath_hal *ah, uint32_t gpio); diff --git a/sys/dev/ath/ath_hal/ar5212/ar5212_gpio.c b/sys/dev/ath/ath_hal/ar5212/ar5212_gpio.c index eb0022f16e82..b2363af92801 100644 --- a/sys/dev/ath/ath_hal/ar5212/ar5212_gpio.c +++ b/sys/dev/ath/ath_hal/ar5212/ar5212_gpio.c @@ -14,7 +14,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $Id: ar5212_gpio.c,v 1.3 2008/11/10 04:08:03 sam Exp $ + * $FreeBSD$ */ #include "opt_ah.h" @@ -36,7 +36,7 @@ * Configure GPIO Output lines */ HAL_BOOL -ar5212GpioCfgOutput(struct ath_hal *ah, uint32_t gpio) +ar5212GpioCfgOutput(struct ath_hal *ah, uint32_t gpio, HAL_GPIO_MUX_TYPE type) { HALASSERT(gpio < AR_NUM_GPIO); diff --git a/sys/dev/ath/ath_hal/ar5312/ar5312.h b/sys/dev/ath/ath_hal/ar5312/ar5312.h index 210e7449df1d..0fb9b750c3e9 100644 --- a/sys/dev/ath/ath_hal/ar5312/ar5312.h +++ b/sys/dev/ath/ath_hal/ar5312/ar5312.h @@ -41,14 +41,16 @@ extern HAL_BOOL ar5312IsInterruptPending(struct ath_hal *ah); /* AR5312 */ -extern HAL_BOOL ar5312GpioCfgOutput(struct ath_hal *, uint32_t gpio); +extern HAL_BOOL ar5312GpioCfgOutput(struct ath_hal *, uint32_t gpio, + HAL_GPIO_MUX_TYPE); extern HAL_BOOL ar5312GpioCfgInput(struct ath_hal *, uint32_t gpio); extern HAL_BOOL ar5312GpioSet(struct ath_hal *, uint32_t gpio, uint32_t val); extern uint32_t ar5312GpioGet(struct ath_hal *ah, uint32_t gpio); extern void ar5312GpioSetIntr(struct ath_hal *ah, u_int, uint32_t ilevel); /* AR2315+ */ -extern HAL_BOOL ar5315GpioCfgOutput(struct ath_hal *, uint32_t gpio); +extern HAL_BOOL ar5315GpioCfgOutput(struct ath_hal *, uint32_t gpio, + HAL_GPIO_MUX_TYPE); extern HAL_BOOL ar5315GpioCfgInput(struct ath_hal *, uint32_t gpio); extern HAL_BOOL ar5315GpioSet(struct ath_hal *, uint32_t gpio, uint32_t val); extern uint32_t ar5315GpioGet(struct ath_hal *ah, uint32_t gpio); diff --git a/sys/dev/ath/ath_hal/ar5312/ar5312_gpio.c b/sys/dev/ath/ath_hal/ar5312/ar5312_gpio.c index 02ed5651ddac..20a575dd20cb 100644 --- a/sys/dev/ath/ath_hal/ar5312/ar5312_gpio.c +++ b/sys/dev/ath/ath_hal/ar5312/ar5312_gpio.c @@ -14,7 +14,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $Id: ar5312_gpio.c,v 1.3 2008/11/10 04:08:04 sam Exp $ + * $FreeBSD$ */ #include "opt_ah.h" @@ -35,7 +35,7 @@ * Configure GPIO Output lines */ HAL_BOOL -ar5312GpioCfgOutput(struct ath_hal *ah, uint32_t gpio) +ar5312GpioCfgOutput(struct ath_hal *ah, uint32_t gpio, HAL_GPIO_MUX_TYPE type) { uint32_t gpioOffset = (AR5312_GPIO_BASE - ((uint32_t) ah->ah_sh)); diff --git a/sys/dev/ath/ath_hal/ar5312/ar5315_gpio.c b/sys/dev/ath/ath_hal/ar5312/ar5315_gpio.c index 2aca97a2e2a6..4c04c86db07d 100644 --- a/sys/dev/ath/ath_hal/ar5312/ar5315_gpio.c +++ b/sys/dev/ath/ath_hal/ar5312/ar5315_gpio.c @@ -14,7 +14,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $Id: ar5315_gpio.c,v 1.3 2008/11/10 04:08:04 sam Exp $ + * $FreeBSD$ */ #include "opt_ah.h" @@ -35,7 +35,7 @@ * Configure GPIO Output lines */ HAL_BOOL -ar5315GpioCfgOutput(struct ath_hal *ah, uint32_t gpio) +ar5315GpioCfgOutput(struct ath_hal *ah, uint32_t gpio, HAL_GPIO_MUX_TYPE type) { uint32_t gpioOffset = (AR5315_GPIO_BASE - ((uint32_t) ah->ah_sh)); diff --git a/sys/dev/ath/ath_hal/ar5416/ar5416.h b/sys/dev/ath/ath_hal/ar5416/ar5416.h index 12b0c0ba843f..639b22d40c70 100644 --- a/sys/dev/ath/ath_hal/ar5416/ar5416.h +++ b/sys/dev/ath/ath_hal/ar5416/ar5416.h @@ -120,7 +120,8 @@ extern HAL_BOOL ar5416IsInterruptPending(struct ath_hal *ah); extern HAL_BOOL ar5416GetPendingInterrupts(struct ath_hal *, HAL_INT *masked); extern HAL_INT ar5416SetInterrupts(struct ath_hal *ah, HAL_INT ints); -extern HAL_BOOL ar5416GpioCfgOutput(struct ath_hal *, uint32_t gpio); +extern HAL_BOOL ar5416GpioCfgOutput(struct ath_hal *, uint32_t gpio, + HAL_GPIO_MUX_TYPE); extern HAL_BOOL ar5416GpioCfgInput(struct ath_hal *, uint32_t gpio); extern HAL_BOOL ar5416GpioSet(struct ath_hal *, uint32_t gpio, uint32_t val); extern uint32_t ar5416GpioGet(struct ath_hal *ah, uint32_t gpio); diff --git a/sys/dev/ath/ath_hal/ar5416/ar5416_gpio.c b/sys/dev/ath/ath_hal/ar5416/ar5416_gpio.c index 0aa284378da8..16b4ebe71171 100644 --- a/sys/dev/ath/ath_hal/ar5416/ar5416_gpio.c +++ b/sys/dev/ath/ath_hal/ar5416/ar5416_gpio.c @@ -14,7 +14,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $Id: ar5416_gpio.c,v 1.3 2008/11/10 04:08:04 sam Exp $ + * $FreeBSD$ */ #include "opt_ah.h" @@ -36,7 +36,7 @@ * Configure GPIO Output lines */ HAL_BOOL -ar5416GpioCfgOutput(struct ath_hal *ah, uint32_t gpio) +ar5416GpioCfgOutput(struct ath_hal *ah, uint32_t gpio, HAL_GPIO_MUX_TYPE type) { HALASSERT(gpio < AR_NUM_GPIO); OS_REG_CLR_BIT(ah, AR_GPIO_INTR_OUT, AR_GPIO_BIT(gpio)); diff --git a/sys/dev/ath/if_ath.c b/sys/dev/ath/if_ath.c index a0ebb4a055c9..22bbd3ebb939 100644 --- a/sys/dev/ath/if_ath.c +++ b/sys/dev/ath/if_ath.c @@ -559,7 +559,8 @@ ath_attach(u_int16_t devid, struct ath_softc *sc) */ sc->sc_softled = (devid == AR5212_DEVID_IBM || devid == AR5211_DEVID); if (sc->sc_softled) { - ath_hal_gpioCfgOutput(ah, sc->sc_ledpin); + ath_hal_gpioCfgOutput(ah, sc->sc_ledpin, + HAL_GPIO_MUX_MAC_NETWORK_LED); ath_hal_gpioset(ah, sc->sc_ledpin, !sc->sc_ledon); } @@ -1218,7 +1219,8 @@ ath_resume(struct ath_softc *sc) ieee80211_resume_all(ic); } if (sc->sc_softled) { - ath_hal_gpioCfgOutput(ah, sc->sc_ledpin); + ath_hal_gpioCfgOutput(ah, sc->sc_ledpin, + HAL_GPIO_MUX_MAC_NETWORK_LED); ath_hal_gpioset(ah, sc->sc_ledpin, !sc->sc_ledon); } } @@ -6653,7 +6655,8 @@ ath_sysctl_softled(SYSCTL_HANDLER_ARGS) if (softled != sc->sc_softled) { if (softled) { /* NB: handle any sc_ledpin change */ - ath_hal_gpioCfgOutput(sc->sc_ah, sc->sc_ledpin); + ath_hal_gpioCfgOutput(sc->sc_ah, sc->sc_ledpin, + HAL_GPIO_MUX_MAC_NETWORK_LED); ath_hal_gpioset(sc->sc_ah, sc->sc_ledpin, !sc->sc_ledon); } @@ -6675,7 +6678,8 @@ ath_sysctl_ledpin(SYSCTL_HANDLER_ARGS) if (ledpin != sc->sc_ledpin) { sc->sc_ledpin = ledpin; if (sc->sc_softled) { - ath_hal_gpioCfgOutput(sc->sc_ah, sc->sc_ledpin); + ath_hal_gpioCfgOutput(sc->sc_ah, sc->sc_ledpin, + HAL_GPIO_MUX_MAC_NETWORK_LED); ath_hal_gpioset(sc->sc_ah, sc->sc_ledpin, !sc->sc_ledon); } diff --git a/sys/dev/ath/if_athvar.h b/sys/dev/ath/if_athvar.h index 6d5a35df899e..568ad7bc09b2 100644 --- a/sys/dev/ath/if_athvar.h +++ b/sys/dev/ath/if_athvar.h @@ -700,8 +700,8 @@ void ath_intr(void *); #define ath_hal_gettxintrtxqs(_ah, _txqs) \ ((*(_ah)->ah_getTxIntrQueue)((_ah), (_txqs))) -#define ath_hal_gpioCfgOutput(_ah, _gpio) \ - ((*(_ah)->ah_gpioCfgOutput)((_ah), (_gpio))) +#define ath_hal_gpioCfgOutput(_ah, _gpio, _type) \ + ((*(_ah)->ah_gpioCfgOutput)((_ah), (_gpio), (_type))) #define ath_hal_gpioset(_ah, _gpio, _b) \ ((*(_ah)->ah_gpioSet)((_ah), (_gpio), (_b))) #define ath_hal_gpioget(_ah, _gpio) \