Example #1
0
/*
 * 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 before this function
 * is called.
 */
void
ath_led_config(struct ath_softc *sc)
{
	/* Software LED blinking - GPIO controlled LED */
	if (sc->sc_softled) {
		ath_hal_gpioCfgOutput(sc->sc_ah, sc->sc_ledpin,
		    HAL_GPIO_OUTPUT_MUX_AS_OUTPUT);
		ath_hal_gpioset(sc->sc_ah, sc->sc_ledpin, !sc->sc_ledon);
	}

	/* 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_OUTPUT_MUX_MAC_POWER_LED);
		if (sc->sc_led_net_pin > 0)
			ath_hal_gpioCfgOutput(sc->sc_ah, sc->sc_led_net_pin,
			    HAL_GPIO_OUTPUT_MUX_MAC_NETWORK_LED);
	}
}
Example #2
0
/*
 * Turn the LED off: flip the pin and then set a timer so no
 * update will happen for the specified duration.
 */
static void
ath_led_off(void *arg)
{
	struct ath_softc *sc = arg;

	ath_hal_gpioset(sc->sc_ah, sc->sc_ledpin, !sc->sc_ledon);
	callout_reset(&sc->sc_ledtimer, sc->sc_ledoff, ath_led_done, sc);
}
Example #3
0
/*
 * Blink the LED according to the specified on/off times.
 */
static void
ath_led_blink(struct ath_softc *sc, int on, int off)
{
	DPRINTF(sc, ATH_DEBUG_LED, "%s: on %u off %u\n", __func__, on, off);
	ath_hal_gpioset(sc->sc_ah, sc->sc_ledpin, sc->sc_ledon);
	sc->sc_blinking = 1;
	sc->sc_ledoff = off;
	callout_reset(&sc->sc_ledtimer, on, ath_led_off, sc);
}
Example #4
0
/*
 * Turn the LED off: flip the pin and then set a timer so no
 * update will happen for the specified duration.
 */
static void
ath_led_off(void *arg)
{
	struct ath_softc *sc = arg;

	wlan_serialize_enter();
	ath_hal_gpioset(sc->sc_ah, sc->sc_ledpin, !sc->sc_ledon);
	callout_reset(&sc->sc_ledtimer, sc->sc_ledoff, ath_led_done, sc);
	wlan_serialize_exit();
}
Example #5
0
static int
ath_sysctl_ledpin(SYSCTL_HANDLER_ARGS)
{
	struct ath_softc *sc = arg1;
	int ledpin = sc->sc_ledpin;
	int error;

	error = sysctl_handle_int(oidp, &ledpin, 0, req);
	if (error || !req->newptr)
		return error;
	if (ledpin != sc->sc_ledpin) {
		sc->sc_ledpin = ledpin;
		if (sc->sc_softled) {
			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 0;
}
Example #6
0
static int
ath_sysctl_softled(SYSCTL_HANDLER_ARGS)
{
	struct ath_softc *sc = arg1;
	int softled = sc->sc_softled;
	int error;

	error = sysctl_handle_int(oidp, &softled, 0, req);
	if (error || !req->newptr)
		return error;
	softled = (softled != 0);
	if (softled != sc->sc_softled) {
		if (softled) {
			/* NB: handle any sc_ledpin change */
			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);
		}
		sc->sc_softled = softled;
	}
	return 0;
}