diff options
author | adrian <adrian@FreeBSD.org> | 2011-12-26 07:47:05 +0000 |
---|---|---|
committer | adrian <adrian@FreeBSD.org> | 2011-12-26 07:47:05 +0000 |
commit | 41ae7c33b3c6dc7f60f749f91f4a05c4c5297d60 (patch) | |
tree | 0ea8a28467939bb27aa82fd557ed5777d22353c7 /sys/dev/ath | |
parent | 122e4872cc81f926fd37e041becea69984548a14 (diff) | |
download | FreeBSD-src-41ae7c33b3c6dc7f60f749f91f4a05c4c5297d60.zip FreeBSD-src-41ae7c33b3c6dc7f60f749f91f4a05c4c5297d60.tar.gz |
Flesh out configurable hardware based LED blinking.
The hardware (MAC) LED blinking involves a few things:
* Selecting which GPIO pins map to the MAC "power" and "network" lines;
* Configuring the MAC LED state (associated, scanning, idle);
* Configuring the MAC LED blinking type and speed.
The AR5416 HAL configures the normal blinking setup - ie, blink rate based
on TX/RX throughput. The default AR5212 HAL doesn't program in any
specific blinking type, but the default of 0 is the same.
This code introduces a few things:
* The hardware led override is configured via sysctl 'hardled';
* The MAC network and power LED GPIO lines can be set, or left at -1
if needed. This is intended to allow only one of the hardware MUX
entries to be configured (eg for PCIe cards which only have one LED
exposed.)
TODO:
* For AR2417, the software LED blinking involves software blinking the
Network LED. For the AR5416 and later, this can just be configured
as a GPIO output line. I'll chase that up with a subsequent commit.
* Add another software LED blink for "Link", separate from "activity",
which blinks based on the association state. This would make my
D-Link DWA-552 have consistent and useful LED behaviour (as they're
marked "Link" and "Activity."
* Don't expose the hardware LED override unless it's an AR5416 or later,
as the previous generation hardware doesn't have this multiplexing
setup.
Diffstat (limited to 'sys/dev/ath')
-rw-r--r-- | sys/dev/ath/if_ath.c | 16 | ||||
-rw-r--r-- | sys/dev/ath/if_ath_led.c | 22 | ||||
-rw-r--r-- | sys/dev/ath/if_ath_sysctl.c | 34 | ||||
-rw-r--r-- | sys/dev/ath/if_athvar.h | 10 |
4 files changed, 79 insertions, 3 deletions
diff --git a/sys/dev/ath/if_ath.c b/sys/dev/ath/if_ath.c index e4d7976..ae785b2 100644 --- a/sys/dev/ath/if_ath.c +++ b/sys/dev/ath/if_ath.c @@ -479,11 +479,27 @@ ath_attach(u_int16_t devid, struct ath_softc *sc) /* Start DFS processing tasklet */ TASK_INIT(&sc->sc_dfstask, 0, ath_dfs_tasklet, sc); + /* Configure LED state */ sc->sc_blinking = 0; sc->sc_ledstate = 1; sc->sc_ledon = 0; /* low true */ sc->sc_ledidle = (2700*hz)/1000; /* 2.7sec */ callout_init(&sc->sc_ledtimer, CALLOUT_MPSAFE); + + /* + * Don't setup hardware-based blinking. + * + * Although some NICs may have this configured in the + * default reset register values, the user may wish + * to alter which pins have which function. + * + * The reference driver attaches the MAC network LED to GPIO1 and + * the MAC power LED to GPIO2. However, the DWA-552 cardbus + * NIC has these reversed. + */ + sc->sc_hardled = (1 == 0); + sc->sc_led_net_pin = -1; + sc->sc_led_pwr_pin = -1; /* * Auto-enable soft led processing for IBM cards and for * 5211 minipci cards. Users can also manually enable/disable diff --git a/sys/dev/ath/if_ath_led.c b/sys/dev/ath/if_ath_led.c index e81e542..ac9d8d7 100644 --- a/sys/dev/ath/if_ath_led.c +++ b/sys/dev/ath/if_ath_led.c @@ -112,9 +112,12 @@ __FBSDID("$FreeBSD$"); /* - * Configure the hardware for software and/or LED blinking. + * Configure the hardware for software and LED blinking. + * The user may choose to configure part of each, depending upon the + * NIC being used. * - * This requires the configuration to be set beforehand. + * This requires the configuration to be set before this function + * is called. */ void ath_led_config(struct ath_softc *sc) @@ -124,10 +127,23 @@ ath_led_config(struct ath_softc *sc) 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); - return; } /* Hardware LED blinking - MAC controlled LED */ + if (sc->sc_hardled) { + /* + * Only enable each LED if required. + * + * Some NICs only have one LED connected; others may + * have GPIO1/GPIO2 connected to other hardware. + */ + if (sc->sc_led_pwr_pin > 0) + ath_hal_gpioCfgOutput(sc->sc_ah, sc->sc_led_pwr_pin, + HAL_GPIO_MUX_MAC_POWER_LED); + if (sc->sc_led_net_pin > 0) + ath_hal_gpioCfgOutput(sc->sc_ah, sc->sc_led_net_pin, + HAL_GPIO_MUX_MAC_NETWORK_LED); + } } static void diff --git a/sys/dev/ath/if_ath_sysctl.c b/sys/dev/ath/if_ath_sysctl.c index 22d378b..57781f5 100644 --- a/sys/dev/ath/if_ath_sysctl.c +++ b/sys/dev/ath/if_ath_sysctl.c @@ -179,6 +179,27 @@ ath_sysctl_ledpin(SYSCTL_HANDLER_ARGS) } static int +ath_sysctl_hardled(SYSCTL_HANDLER_ARGS) +{ + struct ath_softc *sc = arg1; + int hardled = sc->sc_hardled; + int error; + + error = sysctl_handle_int(oidp, &hardled, 0, req); + if (error || !req->newptr) + return error; + hardled = (hardled != 0); + if (hardled != sc->sc_hardled) { + if (hardled) { + /* NB: handle any sc_ledpin change */ + ath_led_config(sc); + } + sc->sc_hardled = hardled; + } + return 0; +} + +static int ath_sysctl_txantenna(SYSCTL_HANDLER_ARGS) { struct ath_softc *sc = arg1; @@ -491,6 +512,7 @@ ath_sysctlattach(struct ath_softc *sc) SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, "ctstimeout", CTLTYPE_INT | CTLFLAG_RW, sc, 0, ath_sysctl_ctstimeout, "I", "802.11 CTS timeout (us)"); + SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, "softled", CTLTYPE_INT | CTLFLAG_RW, sc, 0, ath_sysctl_softled, "I", "enable/disable software LED support"); @@ -503,6 +525,18 @@ ath_sysctlattach(struct ath_softc *sc) SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, "ledidle", CTLFLAG_RW, &sc->sc_ledidle, 0, "idle time for inactivity LED (ticks)"); + + SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, + "hardled", CTLTYPE_INT | CTLFLAG_RW, sc, 0, + ath_sysctl_hardled, "I", "enable/disable hardware LED support"); + /* XXX Laziness - configure pins, then flip hardled off/on */ + SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, + "led_net_pin", CTLFLAG_RW, &sc->sc_led_net_pin, 0, + "MAC Network LED pin, or -1 to disable"); + SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, + "led_pwr_pin", CTLFLAG_RW, &sc->sc_led_pwr_pin, 0, + "MAC Power LED pin, or -1 to disable"); + SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, "txantenna", CTLTYPE_INT | CTLFLAG_RW, sc, 0, ath_sysctl_txantenna, "I", "antenna switch"); diff --git a/sys/dev/ath/if_athvar.h b/sys/dev/ath/if_athvar.h index 331bea4..8491fe1 100644 --- a/sys/dev/ath/if_athvar.h +++ b/sys/dev/ath/if_athvar.h @@ -371,6 +371,7 @@ struct ath_softc { unsigned int sc_invalid : 1,/* disable hardware accesses */ sc_mrretry : 1,/* multi-rate retry support */ sc_softled : 1,/* enable LED gpio status */ + sc_hardled : 1,/* enable MAC LED status */ sc_splitmic : 1,/* split TKIP MIC keys */ sc_needmib : 1,/* enable MIB stats intr */ sc_diversity: 1,/* enable rx diversity */ @@ -445,6 +446,9 @@ struct ath_softc { u_int sc_keymax; /* size of key cache */ u_int8_t sc_keymap[ATH_KEYBYTES];/* key use bit map */ + /* + * Software based LED blinking + */ u_int sc_ledpin; /* GPIO pin for driving LED */ u_int sc_ledon; /* pin setting for LED on */ u_int sc_ledidle; /* idle polling interval */ @@ -453,6 +457,12 @@ struct ath_softc { u_int16_t sc_ledoff; /* off time for current blink */ struct callout sc_ledtimer; /* led off timer */ + /* + * Hardware based LED blinking + */ + int sc_led_pwr_pin; /* MAC power LED GPIO pin */ + int sc_led_net_pin; /* MAC network LED GPIO pin */ + u_int sc_rfsilentpin; /* GPIO pin for rfkill int */ u_int sc_rfsilentpol; /* pin setting for rfkill on */ |