17453645fSAndriy Voskoboinyk /*-
27453645fSAndriy Voskoboinyk * Copyright (c) 2015-2016 Andriy Voskoboinyk <avos@FreeBSD.org>
37453645fSAndriy Voskoboinyk *
47453645fSAndriy Voskoboinyk * Permission to use, copy, modify, and distribute this software for any
57453645fSAndriy Voskoboinyk * purpose with or without fee is hereby granted, provided that the above
67453645fSAndriy Voskoboinyk * copyright notice and this permission notice appear in all copies.
77453645fSAndriy Voskoboinyk *
87453645fSAndriy Voskoboinyk * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
97453645fSAndriy Voskoboinyk * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
107453645fSAndriy Voskoboinyk * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
117453645fSAndriy Voskoboinyk * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
127453645fSAndriy Voskoboinyk * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
137453645fSAndriy Voskoboinyk * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
147453645fSAndriy Voskoboinyk * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
157453645fSAndriy Voskoboinyk */
167453645fSAndriy Voskoboinyk
177453645fSAndriy Voskoboinyk #include <sys/cdefs.h>
187453645fSAndriy Voskoboinyk #include "opt_wlan.h"
197453645fSAndriy Voskoboinyk
207453645fSAndriy Voskoboinyk #include <sys/param.h>
217453645fSAndriy Voskoboinyk #include <sys/lock.h>
227453645fSAndriy Voskoboinyk #include <sys/mutex.h>
237453645fSAndriy Voskoboinyk #include <sys/mbuf.h>
247453645fSAndriy Voskoboinyk #include <sys/kernel.h>
257453645fSAndriy Voskoboinyk #include <sys/socket.h>
267453645fSAndriy Voskoboinyk #include <sys/systm.h>
277453645fSAndriy Voskoboinyk #include <sys/malloc.h>
287453645fSAndriy Voskoboinyk #include <sys/queue.h>
297453645fSAndriy Voskoboinyk #include <sys/taskqueue.h>
307453645fSAndriy Voskoboinyk #include <sys/bus.h>
317453645fSAndriy Voskoboinyk #include <sys/endian.h>
327453645fSAndriy Voskoboinyk #include <sys/linker.h>
337453645fSAndriy Voskoboinyk
347453645fSAndriy Voskoboinyk #include <net/if.h>
357453645fSAndriy Voskoboinyk #include <net/ethernet.h>
367453645fSAndriy Voskoboinyk #include <net/if_media.h>
377453645fSAndriy Voskoboinyk
387453645fSAndriy Voskoboinyk #include <net80211/ieee80211_var.h>
397453645fSAndriy Voskoboinyk #include <net80211/ieee80211_radiotap.h>
407453645fSAndriy Voskoboinyk
417453645fSAndriy Voskoboinyk #include <dev/rtwn/if_rtwnvar.h>
427453645fSAndriy Voskoboinyk #include <dev/rtwn/if_rtwnreg.h>
437453645fSAndriy Voskoboinyk
447453645fSAndriy Voskoboinyk #include <dev/rtwn/if_rtwn_ridx.h>
457453645fSAndriy Voskoboinyk
467453645fSAndriy Voskoboinyk #include <dev/rtwn/rtl8192c/r92c.h>
477453645fSAndriy Voskoboinyk #include <dev/rtwn/rtl8192c/r92c_var.h>
487453645fSAndriy Voskoboinyk #include <dev/rtwn/rtl8192c/r92c_reg.h>
497453645fSAndriy Voskoboinyk #include <dev/rtwn/rtl8192c/r92c_tx_desc.h>
507453645fSAndriy Voskoboinyk
517453645fSAndriy Voskoboinyk void
r92c_beacon_init(struct rtwn_softc * sc,void * buf,int id)527453645fSAndriy Voskoboinyk r92c_beacon_init(struct rtwn_softc *sc, void *buf, int id)
537453645fSAndriy Voskoboinyk {
547453645fSAndriy Voskoboinyk struct r92c_tx_desc *txd = (struct r92c_tx_desc *)buf;
557453645fSAndriy Voskoboinyk
567453645fSAndriy Voskoboinyk /*
577453645fSAndriy Voskoboinyk * NB: there is no need to setup HWSEQ_EN bit;
587453645fSAndriy Voskoboinyk * QSEL_BEACON already implies it.
597453645fSAndriy Voskoboinyk */
607453645fSAndriy Voskoboinyk txd->flags0 |= R92C_FLAGS0_BMCAST | R92C_FLAGS0_FSG | R92C_FLAGS0_LSG;
617453645fSAndriy Voskoboinyk txd->txdw1 |= htole32(
627453645fSAndriy Voskoboinyk SM(R92C_TXDW1_QSEL, R92C_TXDW1_QSEL_BEACON) |
637453645fSAndriy Voskoboinyk SM(R92C_TXDW1_RAID, R92C_RAID_11B));
647453645fSAndriy Voskoboinyk
657453645fSAndriy Voskoboinyk rtwn_r92c_tx_setup_macid(sc, buf, id);
667453645fSAndriy Voskoboinyk txd->txdw4 |= htole32(R92C_TXDW4_DRVRATE);
677453645fSAndriy Voskoboinyk txd->txdw4 |= htole32(SM(R92C_TXDW4_SEQ_SEL, id));
68*d067ef0fSAndriy Voskoboinyk txd->txdw4 |= htole32(SM(R92C_TXDW4_PORT_ID, id));
697453645fSAndriy Voskoboinyk txd->txdw5 |= htole32(SM(R92C_TXDW5_DATARATE, RTWN_RIDX_CCK1));
707453645fSAndriy Voskoboinyk }
717453645fSAndriy Voskoboinyk
727453645fSAndriy Voskoboinyk void
r92c_beacon_enable(struct rtwn_softc * sc,int id,int enable)737453645fSAndriy Voskoboinyk r92c_beacon_enable(struct rtwn_softc *sc, int id, int enable)
747453645fSAndriy Voskoboinyk {
757453645fSAndriy Voskoboinyk
767453645fSAndriy Voskoboinyk if (enable) {
777453645fSAndriy Voskoboinyk rtwn_setbits_1(sc, R92C_BCN_CTRL(id),
787453645fSAndriy Voskoboinyk 0, R92C_BCN_CTRL_EN_BCN);
797453645fSAndriy Voskoboinyk } else {
807453645fSAndriy Voskoboinyk rtwn_setbits_1(sc, R92C_BCN_CTRL(id),
817453645fSAndriy Voskoboinyk R92C_BCN_CTRL_EN_BCN, 0);
827453645fSAndriy Voskoboinyk }
837453645fSAndriy Voskoboinyk }
84