source: rtems-libbsd/freebsd/sys/dev/rtwn/rtl8192e/r92e_rf.c @ 658f9b8

55-freebsd-126-freebsd-12
Last change on this file since 658f9b8 was 658f9b8, checked in by Christian Mauderer <Christian.Mauderer@…>, on 07/17/17 at 13:32:52

dev/rtwn: Import new files from FreeBSD.

  • Property mode set to 100644
File size: 3.0 KB
Line 
1#include <machine/rtems-bsd-kernel-space.h>
2
3/*-
4 * Copyright (c) 2017 Kevin Lo <kevlo@FreeBSD.org>
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 *    notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 *    notice, this list of conditions and the following disclaimer in the
14 *    documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29#include <sys/cdefs.h>
30__FBSDID("$FreeBSD$");
31
32#include <rtems/bsd/local/opt_wlan.h>
33
34#include <sys/param.h>
35#include <sys/lock.h>
36#include <sys/mutex.h>
37#include <sys/mbuf.h>
38#include <sys/kernel.h>
39#include <sys/socket.h>
40#include <sys/systm.h>
41#include <sys/malloc.h>
42#include <sys/queue.h>
43#include <sys/taskqueue.h>
44#include <sys/bus.h>
45#include <sys/endian.h>
46#include <sys/linker.h>
47
48#include <net/if.h>
49#include <net/ethernet.h>
50#include <net/if_media.h>
51
52#include <net80211/ieee80211_var.h>
53#include <net80211/ieee80211_radiotap.h>
54
55#include <dev/rtwn/if_rtwnreg.h>
56#include <dev/rtwn/if_rtwnvar.h>
57
58#include <dev/rtwn/rtl8192e/r92e.h>
59#include <dev/rtwn/rtl8192e/r92e_reg.h>
60
61uint32_t
62r92e_rf_read(struct rtwn_softc *sc, int chain, uint8_t addr)
63{
64        uint32_t val;
65
66        val = rtwn_bb_read(sc, R92C_HSSI_PARAM2(chain));
67        rtwn_bb_write(sc, R92C_HSSI_PARAM2(chain),
68            RW(val, R92C_HSSI_PARAM2_READ_ADDR, addr) &
69            ~R92C_HSSI_PARAM2_READ_EDGE);
70
71        rtwn_bb_setbits(sc, R92C_HSSI_PARAM2(0), R92C_HSSI_PARAM2_READ_EDGE, 0);
72        rtwn_bb_setbits(sc, R92C_HSSI_PARAM2(0), 0, R92C_HSSI_PARAM2_READ_EDGE);
73        rtwn_delay(sc, 20);
74
75        if (rtwn_bb_read(sc, R92C_HSSI_PARAM1(chain)) & R92C_HSSI_PARAM1_PI)
76                val = rtwn_bb_read(sc, R92C_HSPI_READBACK(chain));
77        else
78                val = rtwn_bb_read(sc, R92C_LSSI_READBACK(chain));
79        return (MS(val, R92C_LSSI_READBACK_DATA));
80}
81
82void
83r92e_rf_write(struct rtwn_softc *sc, int chain, uint8_t addr, uint32_t val)
84{
85
86        rtwn_bb_setbits(sc, 0x818, 0x20000, 0);
87        rtwn_bb_write(sc, R92C_LSSI_PARAM(chain),
88            SM(R88E_LSSI_PARAM_ADDR, addr) | SM(R92C_LSSI_PARAM_DATA, val));
89        rtwn_bb_setbits(sc, 0x818, 0, 0x20000);
90}
Note: See TracBrowser for help on using the repository browser.