xref: /freebsd/sys/dev/rtwn/rtl8188e/r88e_led.c (revision 685dc743dc3b5645e34836464128e1c0558b404b)
1*7453645fSAndriy Voskoboinyk /*	$OpenBSD: if_urtwn.c,v 1.16 2011/02/10 17:26:40 jakemsr Exp $	*/
2*7453645fSAndriy Voskoboinyk 
3*7453645fSAndriy Voskoboinyk /*-
4*7453645fSAndriy Voskoboinyk  * Copyright (c) 2010 Damien Bergamini <damien.bergamini@free.fr>
5*7453645fSAndriy Voskoboinyk  * Copyright (c) 2014 Kevin Lo <kevlo@FreeBSD.org>
6*7453645fSAndriy Voskoboinyk  * Copyright (c) 2016 Andriy Voskoboinyk <avos@FreeBSD.org>
7*7453645fSAndriy Voskoboinyk  *
8*7453645fSAndriy Voskoboinyk  * Permission to use, copy, modify, and distribute this software for any
9*7453645fSAndriy Voskoboinyk  * purpose with or without fee is hereby granted, provided that the above
10*7453645fSAndriy Voskoboinyk  * copyright notice and this permission notice appear in all copies.
11*7453645fSAndriy Voskoboinyk  *
12*7453645fSAndriy Voskoboinyk  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13*7453645fSAndriy Voskoboinyk  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14*7453645fSAndriy Voskoboinyk  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15*7453645fSAndriy Voskoboinyk  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16*7453645fSAndriy Voskoboinyk  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17*7453645fSAndriy Voskoboinyk  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18*7453645fSAndriy Voskoboinyk  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19*7453645fSAndriy Voskoboinyk  */
20*7453645fSAndriy Voskoboinyk 
21*7453645fSAndriy Voskoboinyk #include <sys/cdefs.h>
22*7453645fSAndriy Voskoboinyk #include "opt_wlan.h"
23*7453645fSAndriy Voskoboinyk 
24*7453645fSAndriy Voskoboinyk #include <sys/param.h>
25*7453645fSAndriy Voskoboinyk #include <sys/lock.h>
26*7453645fSAndriy Voskoboinyk #include <sys/mutex.h>
27*7453645fSAndriy Voskoboinyk #include <sys/mbuf.h>
28*7453645fSAndriy Voskoboinyk #include <sys/kernel.h>
29*7453645fSAndriy Voskoboinyk #include <sys/socket.h>
30*7453645fSAndriy Voskoboinyk #include <sys/systm.h>
31*7453645fSAndriy Voskoboinyk #include <sys/malloc.h>
32*7453645fSAndriy Voskoboinyk #include <sys/queue.h>
33*7453645fSAndriy Voskoboinyk #include <sys/taskqueue.h>
34*7453645fSAndriy Voskoboinyk #include <sys/bus.h>
35*7453645fSAndriy Voskoboinyk #include <sys/endian.h>
36*7453645fSAndriy Voskoboinyk #include <sys/linker.h>
37*7453645fSAndriy Voskoboinyk 
38*7453645fSAndriy Voskoboinyk #include <net/if.h>
39*7453645fSAndriy Voskoboinyk #include <net/ethernet.h>
40*7453645fSAndriy Voskoboinyk #include <net/if_media.h>
41*7453645fSAndriy Voskoboinyk 
42*7453645fSAndriy Voskoboinyk #include <net80211/ieee80211_var.h>
43*7453645fSAndriy Voskoboinyk #include <net80211/ieee80211_radiotap.h>
44*7453645fSAndriy Voskoboinyk 
45*7453645fSAndriy Voskoboinyk #include <dev/rtwn/if_rtwnvar.h>
46*7453645fSAndriy Voskoboinyk 
47*7453645fSAndriy Voskoboinyk #include <dev/rtwn/rtl8188e/r88e.h>
48*7453645fSAndriy Voskoboinyk #include <dev/rtwn/rtl8188e/r88e_reg.h>
49*7453645fSAndriy Voskoboinyk 
50*7453645fSAndriy Voskoboinyk void
r88e_set_led(struct rtwn_softc * sc,int led,int on)51*7453645fSAndriy Voskoboinyk r88e_set_led(struct rtwn_softc *sc, int led, int on)
52*7453645fSAndriy Voskoboinyk {
53*7453645fSAndriy Voskoboinyk 
54*7453645fSAndriy Voskoboinyk 	if (led == RTWN_LED_LINK) {
55*7453645fSAndriy Voskoboinyk 		if (!on) {
56*7453645fSAndriy Voskoboinyk 			rtwn_setbits_1(sc, R92C_LEDCFG2, 0x6f,
57*7453645fSAndriy Voskoboinyk 			    R92C_LEDCFG0_DIS);
58*7453645fSAndriy Voskoboinyk 			rtwn_setbits_1(sc, R92C_MAC_PINMUX_CFG, 0x01, 0);
59*7453645fSAndriy Voskoboinyk 		} else
60*7453645fSAndriy Voskoboinyk 			rtwn_setbits_1(sc, R92C_LEDCFG2, 0x0f, 0x60);
61*7453645fSAndriy Voskoboinyk 		sc->ledlink = on;	/* Save LED state. */
62*7453645fSAndriy Voskoboinyk 	}
63*7453645fSAndriy Voskoboinyk 
64*7453645fSAndriy Voskoboinyk 	/* XXX led #1? */
65*7453645fSAndriy Voskoboinyk }
66