From owner-svn-src-all@freebsd.org Tue May 17 07:11:13 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 610D2B3EE0D; Tue, 17 May 2016 07:11:13 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 38D6C14B8; Tue, 17 May 2016 07:11:13 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u4H7BCML028429; Tue, 17 May 2016 07:11:12 GMT (envelope-from adrian@FreeBSD.org) Received: (from adrian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u4H7BCY8028427; Tue, 17 May 2016 07:11:12 GMT (envelope-from adrian@FreeBSD.org) Message-Id: <201605170711.u4H7BCY8028427@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: adrian set sender to adrian@FreeBSD.org using -f From: Adrian Chadd Date: Tue, 17 May 2016 07:11:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r300018 - head/sys/dev/bwn X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 May 2016 07:11:13 -0000 Author: adrian Date: Tue May 17 07:11:12 2016 New Revision: 300018 URL: https://svnweb.freebsd.org/changeset/base/300018 Log: [bwn] add PHY-N glue. It defaults to stubbing out PHY-N bindings, but it can be flipped to call into the b43 PHY-N port. Added: head/sys/dev/bwn/if_bwn_phy_n.c (contents, props changed) head/sys/dev/bwn/if_bwn_phy_n.h (contents, props changed) Added: head/sys/dev/bwn/if_bwn_phy_n.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/bwn/if_bwn_phy_n.c Tue May 17 07:11:12 2016 (r300018) @@ -0,0 +1,281 @@ +/*- + * Copyright (c) 2016 Adrian Chadd + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any + * redistribution must be conditioned upon including a substantially + * similar Disclaimer requirement for further binary redistribution. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, + * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGES. + */ + +#include +__FBSDID("$FreeBSD$"); + +/* + * This is the top-level N-PHY support for the Broadcom softmac driver. + */ + +#include "opt_bwn.h" +#include "opt_wlan.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include + +#ifdef BWN_GPL_PHY +#include +#include +#include +#endif + +/* + * This module is always compiled into the kernel, regardless of + * whether the GPL PHY is enabled. If the GPL PHY isn't enabled + * then it'll just be stubs that will fail to attach. + */ + +int +bwn_phy_n_attach(struct bwn_mac *mac) +{ + +#ifdef BWN_GPL_PHY + return bwn_nphy_op_allocate(mac); +#else + return (ENXIO); +#endif +} + +void +bwn_phy_n_detach(struct bwn_mac *mac) +{ + +#ifdef BWN_GPL_PHY + return bwn_nphy_op_free(mac); +#endif +} + +int +bwn_phy_n_prepare_hw(struct bwn_mac *mac) +{ + +#ifdef BWN_GPL_PHY + bwn_nphy_op_prepare_structs(mac); + return (0); +#else + return (ENXIO); +#endif +} + +void +bwn_phy_n_init_pre(struct bwn_mac *mac) +{ + + /* XXX TODO */ +} + +int +bwn_phy_n_init(struct bwn_mac *mac) +{ +#ifdef BWN_GPL_PHY + return bwn_nphy_op_init(mac); +#else + return (ENXIO); +#endif +} + +void +bwn_phy_n_exit(struct bwn_mac *mac) +{ + + /* XXX TODO */ +} + +uint16_t +bwn_phy_n_read(struct bwn_mac *mac, uint16_t reg) +{ + + BWN_WRITE_2(mac, BWN_PHYCTL, reg); + return BWN_READ_2(mac, BWN_PHYDATA); +} + +void +bwn_phy_n_write(struct bwn_mac *mac, uint16_t reg, uint16_t value) +{ + + BWN_WRITE_2(mac, BWN_PHYCTL, reg); + BWN_WRITE_2(mac, BWN_PHYDATA, value); +} + +uint16_t +bwn_phy_n_rf_read(struct bwn_mac *mac, uint16_t reg) +{ + + /* Register 1 is a 32-bit register. */ + if (mac->mac_phy.rev < 7 && reg == 1) { + BWN_ERRPRINTF(mac->mac_sc, "%s: bad reg access\n", __func__); + } + + if (mac->mac_phy.rev >= 7) + reg |= 0x200; /* radio 0x2057 */ + else + reg |= 0x100; + + BWN_WRITE_2(mac, BWN_RFCTL, reg); + return BWN_READ_2(mac, BWN_RFDATALO); +} + +void +bwn_phy_n_rf_write(struct bwn_mac *mac, uint16_t reg, uint16_t value) +{ + + /* Register 1 is a 32-bit register. */ + if (mac->mac_phy.rev < 7 && reg == 1) { + BWN_ERRPRINTF(mac->mac_sc, "%s: bad reg access\n", __func__); + } + + BWN_WRITE_2(mac, BWN_RFCTL, reg); + BWN_WRITE_2(mac, BWN_RFDATALO, value); +} + +int +bwn_phy_n_hwpctl(struct bwn_mac *mac) +{ + + return (0); +} + +void +bwn_phy_n_rf_onoff(struct bwn_mac *mac, int on) +{ +#ifdef BWN_GPL_PHY + bwn_nphy_op_software_rfkill(mac, on); +#endif +} + +void +bwn_phy_n_switch_analog(struct bwn_mac *mac, int on) +{ +#ifdef BWN_GPL_PHY + bwn_nphy_op_switch_analog(mac, on); +#endif +} + +int +bwn_phy_n_switch_channel(struct bwn_mac *mac, uint32_t newchan) +{ +#ifdef BWN_GPL_PHY + return bwn_nphy_op_switch_channel(mac, newchan); +#else + return (ENXIO); +#endif +} + +uint32_t +bwn_phy_n_get_default_chan(struct bwn_mac *mac) +{ + + if (bwn_current_band(mac) == BWN_BAND_2G) + return (1); + return (36); +} + +void +bwn_phy_n_set_antenna(struct bwn_mac *mac, int antenna) +{ + /* XXX TODO */ +} + +int +bwn_phy_n_im(struct bwn_mac *mac, int mode) +{ + /* XXX TODO */ + return (0); +} + +bwn_txpwr_result_t +bwn_phy_n_recalc_txpwr(struct bwn_mac *mac, int ignore_tssi) +{ +#ifdef BWN_GPL_PHY + return bwn_nphy_op_recalc_txpower(mac, ignore_tssi); +#else + return (BWN_TXPWR_RES_DONE); +#endif +} + +void +bwn_phy_n_set_txpwr(struct bwn_mac *mac) +{ + +} + +void +bwn_phy_n_task_15s(struct bwn_mac *mac) +{ + +} + +void +bwn_phy_n_task_60s(struct bwn_mac *mac) +{ + +} Added: head/sys/dev/bwn/if_bwn_phy_n.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/bwn/if_bwn_phy_n.h Tue May 17 07:11:12 2016 (r300018) @@ -0,0 +1,57 @@ +/*- + * Copyright (c) 2016 Adrian Chadd . + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any + * redistribution must be conditioned upon including a substantially + * similar Disclaimer requirement for further binary redistribution. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, + * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGES. + * + * $FreeBSD$ + */ + +#ifndef __IF_BWN_PHY_N_H__ +#define __IF_BWN_PHY_N_H__ + +extern int bwn_phy_n_attach(struct bwn_mac *mac); +extern void bwn_phy_n_detach(struct bwn_mac *mac); +extern int bwn_phy_n_prepare_hw(struct bwn_mac *mac); +extern void bwn_phy_n_init_pre(struct bwn_mac *mac); +extern int bwn_phy_n_init(struct bwn_mac *mac); +extern void bwn_phy_n_exit(struct bwn_mac *mac); +extern uint16_t bwn_phy_n_read(struct bwn_mac *mac, uint16_t reg); +extern void bwn_phy_n_write(struct bwn_mac *mac, uint16_t reg, uint16_t value); +extern uint16_t bwn_phy_n_rf_read(struct bwn_mac *mac, uint16_t reg); +extern void bwn_phy_n_rf_write(struct bwn_mac *mac, uint16_t reg, uint16_t value); +extern int bwn_phy_n_hwpctl(struct bwn_mac *mac); +extern void bwn_phy_n_rf_onoff(struct bwn_mac *mac, int on); +extern void bwn_phy_n_switch_analog(struct bwn_mac *mac, int on); +extern int bwn_phy_n_switch_channel(struct bwn_mac *mac, uint32_t newchan); +extern uint32_t bwn_phy_n_get_default_chan(struct bwn_mac *mac); +extern void bwn_phy_n_set_antenna(struct bwn_mac *mac, int antenna); +extern int bwn_phy_n_im(struct bwn_mac *mac, int mode); +extern bwn_txpwr_result_t bwn_phy_n_recalc_txpwr(struct bwn_mac *mac, int ignore_tssi); +extern void bwn_phy_n_set_txpwr(struct bwn_mac *mac); +extern void bwn_phy_n_task_15s(struct bwn_mac *mac); +extern void bwn_phy_n_task_60s(struct bwn_mac *mac); + +#endif /* __IF_BWN_PHY_N_H__ */