1/*- 2 * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer, 10 * without modification. 11 * 2. Redistributions in binary form must reproduce at minimum a disclaimer 12 * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any 13 * redistribution must be conditioned upon including a substantially 14 * similar Disclaimer requirement for further binary redistribution. 15 * 16 * NO WARRANTY 17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY 20 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 21 * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, 22 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 25 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 27 * THE POSSIBILITY OF SUCH DAMAGES. 28 */ 29 30#include <sys/cdefs.h>
| 1/*- 2 * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer, 10 * without modification. 11 * 2. Redistributions in binary form must reproduce at minimum a disclaimer 12 * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any 13 * redistribution must be conditioned upon including a substantially 14 * similar Disclaimer requirement for further binary redistribution. 15 * 16 * NO WARRANTY 17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY 20 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 21 * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, 22 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 25 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 27 * THE POSSIBILITY OF SUCH DAMAGES. 28 */ 29 30#include <sys/cdefs.h>
|
31__FBSDID("$FreeBSD: head/sys/dev/ath/if_ath_led.c 228887 2011-12-26 05:37:09Z adrian $");
| 31__FBSDID("$FreeBSD: head/sys/dev/ath/if_ath_led.c 228888 2011-12-26 05:46:22Z adrian $");
|
32 33/* 34 * Driver for the Atheros Wireless LAN controller. 35 * 36 * This software is derived from work of Atsushi Onoe; his contribution 37 * is greatly appreciated. 38 */ 39 40#include "opt_inet.h" 41#include "opt_ath.h" 42/* 43 * This is needed for register operations which are performed 44 * by the driver - eg, calls to ath_hal_gettsf32(). 45 */ 46#include "opt_ah.h" 47#include "opt_wlan.h" 48 49#include <sys/param.h> 50#include <sys/systm.h> 51#include <sys/sysctl.h> 52#include <sys/mbuf.h> 53#include <sys/malloc.h> 54#include <sys/lock.h> 55#include <sys/mutex.h> 56#include <sys/kernel.h> 57#include <sys/socket.h> 58#include <sys/sockio.h> 59#include <sys/errno.h> 60#include <sys/callout.h> 61#include <sys/bus.h> 62#include <sys/endian.h> 63#include <sys/kthread.h> 64#include <sys/taskqueue.h> 65#include <sys/priv.h> 66#include <sys/module.h> 67#include <sys/ktr.h> 68#include <sys/smp.h> /* for mp_ncpus */ 69 70#include <machine/bus.h> 71 72#include <net/if.h> 73#include <net/if_dl.h> 74#include <net/if_media.h> 75#include <net/if_types.h> 76#include <net/if_arp.h> 77#include <net/ethernet.h> 78#include <net/if_llc.h> 79 80#include <net80211/ieee80211_var.h> 81#include <net80211/ieee80211_regdomain.h> 82#ifdef IEEE80211_SUPPORT_SUPERG 83#include <net80211/ieee80211_superg.h> 84#endif 85#ifdef IEEE80211_SUPPORT_TDMA 86#include <net80211/ieee80211_tdma.h> 87#endif 88 89#include <net/bpf.h> 90 91#ifdef INET 92#include <netinet/in.h> 93#include <netinet/if_ether.h> 94#endif 95 96#include <dev/ath/if_athvar.h> 97#include <dev/ath/ath_hal/ah_devid.h> /* XXX for softled */ 98#include <dev/ath/ath_hal/ah_diagcodes.h> 99 100#include <dev/ath/if_ath_debug.h> 101#include <dev/ath/if_ath_misc.h> 102 103#include <dev/ath/if_ath_led.h> 104 105/* 106 * Software LED driver routines. 107 */ 108 109/* 110 * XXX TODO: move the LED sysctls here. 111 */ 112
| 32 33/* 34 * Driver for the Atheros Wireless LAN controller. 35 * 36 * This software is derived from work of Atsushi Onoe; his contribution 37 * is greatly appreciated. 38 */ 39 40#include "opt_inet.h" 41#include "opt_ath.h" 42/* 43 * This is needed for register operations which are performed 44 * by the driver - eg, calls to ath_hal_gettsf32(). 45 */ 46#include "opt_ah.h" 47#include "opt_wlan.h" 48 49#include <sys/param.h> 50#include <sys/systm.h> 51#include <sys/sysctl.h> 52#include <sys/mbuf.h> 53#include <sys/malloc.h> 54#include <sys/lock.h> 55#include <sys/mutex.h> 56#include <sys/kernel.h> 57#include <sys/socket.h> 58#include <sys/sockio.h> 59#include <sys/errno.h> 60#include <sys/callout.h> 61#include <sys/bus.h> 62#include <sys/endian.h> 63#include <sys/kthread.h> 64#include <sys/taskqueue.h> 65#include <sys/priv.h> 66#include <sys/module.h> 67#include <sys/ktr.h> 68#include <sys/smp.h> /* for mp_ncpus */ 69 70#include <machine/bus.h> 71 72#include <net/if.h> 73#include <net/if_dl.h> 74#include <net/if_media.h> 75#include <net/if_types.h> 76#include <net/if_arp.h> 77#include <net/ethernet.h> 78#include <net/if_llc.h> 79 80#include <net80211/ieee80211_var.h> 81#include <net80211/ieee80211_regdomain.h> 82#ifdef IEEE80211_SUPPORT_SUPERG 83#include <net80211/ieee80211_superg.h> 84#endif 85#ifdef IEEE80211_SUPPORT_TDMA 86#include <net80211/ieee80211_tdma.h> 87#endif 88 89#include <net/bpf.h> 90 91#ifdef INET 92#include <netinet/in.h> 93#include <netinet/if_ether.h> 94#endif 95 96#include <dev/ath/if_athvar.h> 97#include <dev/ath/ath_hal/ah_devid.h> /* XXX for softled */ 98#include <dev/ath/ath_hal/ah_diagcodes.h> 99 100#include <dev/ath/if_ath_debug.h> 101#include <dev/ath/if_ath_misc.h> 102 103#include <dev/ath/if_ath_led.h> 104 105/* 106 * Software LED driver routines. 107 */ 108 109/* 110 * XXX TODO: move the LED sysctls here. 111 */ 112
|
| 113 114/* 115 * Configure the hardware for software and/or LED blinking. 116 * 117 * This requires the configuration to be set beforehand. 118 */ 119void 120ath_led_config(struct ath_softc *sc) 121{ 122 /* Software LED blinking - GPIO controlled LED */ 123 if (sc->sc_softled) { 124 ath_hal_gpioCfgOutput(sc->sc_ah, sc->sc_ledpin, 125 HAL_GPIO_MUX_MAC_NETWORK_LED); 126 ath_hal_gpioset(sc->sc_ah, sc->sc_ledpin, !sc->sc_ledon); 127 return; 128 } 129 130 /* Hardware LED blinking - MAC controlled LED */ 131} 132
|
113static void 114ath_led_done(void *arg) 115{ 116 struct ath_softc *sc = arg; 117 118 sc->sc_blinking = 0; 119} 120 121/* 122 * Turn the LED off: flip the pin and then set a timer so no 123 * update will happen for the specified duration. 124 */ 125static void 126ath_led_off(void *arg) 127{ 128 struct ath_softc *sc = arg; 129 130 ath_hal_gpioset(sc->sc_ah, sc->sc_ledpin, !sc->sc_ledon); 131 callout_reset(&sc->sc_ledtimer, sc->sc_ledoff, ath_led_done, sc); 132} 133 134/* 135 * Blink the LED according to the specified on/off times. 136 */ 137static void 138ath_led_blink(struct ath_softc *sc, int on, int off) 139{ 140 DPRINTF(sc, ATH_DEBUG_LED, "%s: on %u off %u\n", __func__, on, off); 141 ath_hal_gpioset(sc->sc_ah, sc->sc_ledpin, sc->sc_ledon); 142 sc->sc_blinking = 1; 143 sc->sc_ledoff = off; 144 callout_reset(&sc->sc_ledtimer, on, ath_led_off, sc); 145} 146 147void 148ath_led_event(struct ath_softc *sc, int rix) 149{ 150 sc->sc_ledevent = ticks; /* time of last event */ 151 if (sc->sc_blinking) /* don't interrupt active blink */ 152 return; 153 ath_led_blink(sc, sc->sc_hwmap[rix].ledon, sc->sc_hwmap[rix].ledoff); 154}
| 133static void 134ath_led_done(void *arg) 135{ 136 struct ath_softc *sc = arg; 137 138 sc->sc_blinking = 0; 139} 140 141/* 142 * Turn the LED off: flip the pin and then set a timer so no 143 * update will happen for the specified duration. 144 */ 145static void 146ath_led_off(void *arg) 147{ 148 struct ath_softc *sc = arg; 149 150 ath_hal_gpioset(sc->sc_ah, sc->sc_ledpin, !sc->sc_ledon); 151 callout_reset(&sc->sc_ledtimer, sc->sc_ledoff, ath_led_done, sc); 152} 153 154/* 155 * Blink the LED according to the specified on/off times. 156 */ 157static void 158ath_led_blink(struct ath_softc *sc, int on, int off) 159{ 160 DPRINTF(sc, ATH_DEBUG_LED, "%s: on %u off %u\n", __func__, on, off); 161 ath_hal_gpioset(sc->sc_ah, sc->sc_ledpin, sc->sc_ledon); 162 sc->sc_blinking = 1; 163 sc->sc_ledoff = off; 164 callout_reset(&sc->sc_ledtimer, on, ath_led_off, sc); 165} 166 167void 168ath_led_event(struct ath_softc *sc, int rix) 169{ 170 sc->sc_ledevent = ticks; /* time of last event */ 171 if (sc->sc_blinking) /* don't interrupt active blink */ 172 return; 173 ath_led_blink(sc, sc->sc_hwmap[rix].ledon, sc->sc_hwmap[rix].ledoff); 174}
|