Deleted Added
full compact
if_run.c (258732) if_run.c (258733)
1/*-
2 * Copyright (c) 2008,2010 Damien Bergamini <damien.bergamini@free.fr>
3 * ported to FreeBSD by Akinori Furukoshi <moonlightakkiy@yahoo.ca>
4 * USB Consulting, Hans Petter Selasky <hselasky@freebsd.org>
5 *
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18
19#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2008,2010 Damien Bergamini <damien.bergamini@free.fr>
3 * ported to FreeBSD by Akinori Furukoshi <moonlightakkiy@yahoo.ca>
4 * USB Consulting, Hans Petter Selasky <hselasky@freebsd.org>
5 *
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18
19#include <sys/cdefs.h>
20__FBSDID("$FreeBSD: head/sys/dev/usb/wlan/if_run.c 258732 2013-11-29 06:10:44Z kevlo $");
20__FBSDID("$FreeBSD: head/sys/dev/usb/wlan/if_run.c 258733 2013-11-29 07:08:17Z kevlo $");
21
22/*-
23 * Ralink Technology RT2700U/RT2800U/RT3000U/RT3900E chipset driver.
24 * http://www.ralinktech.com/
25 */
26
27#include <sys/param.h>
28#include <sys/sockio.h>

--- 310 unchanged lines hidden (view full) ---

339static int run_read_region_1(struct run_softc *, uint16_t, uint8_t *, int);
340static int run_write_2(struct run_softc *, uint16_t, uint16_t);
341static int run_write(struct run_softc *, uint16_t, uint32_t);
342static int run_write_region_1(struct run_softc *, uint16_t,
343 const uint8_t *, int);
344static int run_set_region_4(struct run_softc *, uint16_t, uint32_t, int);
345static int run_efuse_read_2(struct run_softc *, uint16_t, uint16_t *);
346static int run_eeprom_read_2(struct run_softc *, uint16_t, uint16_t *);
21
22/*-
23 * Ralink Technology RT2700U/RT2800U/RT3000U/RT3900E chipset driver.
24 * http://www.ralinktech.com/
25 */
26
27#include <sys/param.h>
28#include <sys/sockio.h>

--- 310 unchanged lines hidden (view full) ---

339static int run_read_region_1(struct run_softc *, uint16_t, uint8_t *, int);
340static int run_write_2(struct run_softc *, uint16_t, uint16_t);
341static int run_write(struct run_softc *, uint16_t, uint32_t);
342static int run_write_region_1(struct run_softc *, uint16_t,
343 const uint8_t *, int);
344static int run_set_region_4(struct run_softc *, uint16_t, uint32_t, int);
345static int run_efuse_read_2(struct run_softc *, uint16_t, uint16_t *);
346static int run_eeprom_read_2(struct run_softc *, uint16_t, uint16_t *);
347static int run_rt2870_rf_write(struct run_softc *, uint8_t, uint32_t);
347static int run_rt2870_rf_write(struct run_softc *, uint32_t);
348static int run_rt3070_rf_read(struct run_softc *, uint8_t, uint8_t *);
349static int run_rt3070_rf_write(struct run_softc *, uint8_t, uint8_t);
350static int run_bbp_read(struct run_softc *, uint8_t, uint8_t *);
351static int run_bbp_write(struct run_softc *, uint8_t, uint8_t);
352static int run_mcu_cmd(struct run_softc *, uint8_t, uint16_t);
353static const char *run_get_rf(uint16_t);
354static int run_read_eeprom(struct run_softc *);
355static struct ieee80211_node *run_node_alloc(struct ieee80211vap *,

--- 918 unchanged lines hidden (view full) ---

1274static __inline int
1275run_srom_read(struct run_softc *sc, uint16_t addr, uint16_t *val)
1276{
1277 /* either eFUSE ROM or EEPROM */
1278 return sc->sc_srom_read(sc, addr, val);
1279}
1280
1281static int
348static int run_rt3070_rf_read(struct run_softc *, uint8_t, uint8_t *);
349static int run_rt3070_rf_write(struct run_softc *, uint8_t, uint8_t);
350static int run_bbp_read(struct run_softc *, uint8_t, uint8_t *);
351static int run_bbp_write(struct run_softc *, uint8_t, uint8_t);
352static int run_mcu_cmd(struct run_softc *, uint8_t, uint16_t);
353static const char *run_get_rf(uint16_t);
354static int run_read_eeprom(struct run_softc *);
355static struct ieee80211_node *run_node_alloc(struct ieee80211vap *,

--- 918 unchanged lines hidden (view full) ---

1274static __inline int
1275run_srom_read(struct run_softc *sc, uint16_t addr, uint16_t *val)
1276{
1277 /* either eFUSE ROM or EEPROM */
1278 return sc->sc_srom_read(sc, addr, val);
1279}
1280
1281static int
1282run_rt2870_rf_write(struct run_softc *sc, uint8_t reg, uint32_t val)
1282run_rt2870_rf_write(struct run_softc *sc, uint32_t val)
1283{
1284 uint32_t tmp;
1285 int error, ntries;
1286
1287 for (ntries = 0; ntries < 10; ntries++) {
1288 if ((error = run_read(sc, RT2860_RF_CSR_CFG0, &tmp)) != 0)
1289 return (error);
1290 if (!(tmp & RT2860_RF_REG_CTRL))

--- 2388 unchanged lines hidden (view full) ---

3679 } else {
3680 /* Set Tx0 power. */
3681 r3 |= (txpow1 << 9);
3682
3683 /* Set frequency offset and Tx1 power. */
3684 r4 |= (txpow2 << 6);
3685 }
3686
1283{
1284 uint32_t tmp;
1285 int error, ntries;
1286
1287 for (ntries = 0; ntries < 10; ntries++) {
1288 if ((error = run_read(sc, RT2860_RF_CSR_CFG0, &tmp)) != 0)
1289 return (error);
1290 if (!(tmp & RT2860_RF_REG_CTRL))

--- 2388 unchanged lines hidden (view full) ---

3679 } else {
3680 /* Set Tx0 power. */
3681 r3 |= (txpow1 << 9);
3682
3683 /* Set frequency offset and Tx1 power. */
3684 r4 |= (txpow2 << 6);
3685 }
3686
3687 run_rt2870_rf_write(sc, RT2860_RF1, rfprog[i].r1);
3688 run_rt2870_rf_write(sc, RT2860_RF2, r2);
3689 run_rt2870_rf_write(sc, RT2860_RF3, r3 & ~(1 << 2));
3690 run_rt2870_rf_write(sc, RT2860_RF4, r4);
3687 run_rt2870_rf_write(sc, rfprog[i].r1);
3688 run_rt2870_rf_write(sc, r2);
3689 run_rt2870_rf_write(sc, r3 & ~(1 << 2));
3690 run_rt2870_rf_write(sc, r4);
3691
3692 run_delay(sc, 10);
3693
3691
3692 run_delay(sc, 10);
3693
3694 run_rt2870_rf_write(sc, RT2860_RF1, rfprog[i].r1);
3695 run_rt2870_rf_write(sc, RT2860_RF2, r2);
3696 run_rt2870_rf_write(sc, RT2860_RF3, r3 | (1 << 2));
3697 run_rt2870_rf_write(sc, RT2860_RF4, r4);
3694 run_rt2870_rf_write(sc, rfprog[i].r1);
3695 run_rt2870_rf_write(sc, r2);
3696 run_rt2870_rf_write(sc, r3 | (1 << 2));
3697 run_rt2870_rf_write(sc, r4);
3698
3699 run_delay(sc, 10);
3700
3698
3699 run_delay(sc, 10);
3700
3701 run_rt2870_rf_write(sc, RT2860_RF1, rfprog[i].r1);
3702 run_rt2870_rf_write(sc, RT2860_RF2, r2);
3703 run_rt2870_rf_write(sc, RT2860_RF3, r3 & ~(1 << 2));
3704 run_rt2870_rf_write(sc, RT2860_RF4, r4);
3701 run_rt2870_rf_write(sc, rfprog[i].r1);
3702 run_rt2870_rf_write(sc, r2);
3703 run_rt2870_rf_write(sc, r3 & ~(1 << 2));
3704 run_rt2870_rf_write(sc, r4);
3705}
3706
3707static void
3708run_rt3070_set_chan(struct run_softc *sc, u_int chan)
3709{
3710 int8_t txpow1, txpow2;
3711 uint8_t rf;
3712 int i;

--- 1659 unchanged lines hidden ---
3705}
3706
3707static void
3708run_rt3070_set_chan(struct run_softc *sc, u_int chan)
3709{
3710 int8_t txpow1, txpow2;
3711 uint8_t rf;
3712 int i;

--- 1659 unchanged lines hidden ---