1191762Simp/* 2191762Simp * Copyright (c) 2007 The DragonFly Project. All rights reserved. 3191762Simp * 4191762Simp * This code is derived from software contributed to The DragonFly Project 5191762Simp * by Sepherosa Ziehau <sepherosa@gmail.com> 6191762Simp * 7191762Simp * Redistribution and use in source and binary forms, with or without 8191762Simp * modification, are permitted provided that the following conditions 9191762Simp * are met: 10191762Simp * 11191762Simp * 1. Redistributions of source code must retain the above copyright 12191762Simp * notice, this list of conditions and the following disclaimer. 13191762Simp * 2. Redistributions in binary form must reproduce the above copyright 14191762Simp * notice, this list of conditions and the following disclaimer in 15191762Simp * the documentation and/or other materials provided with the 16191762Simp * distribution. 17191762Simp * 3. Neither the name of The DragonFly Project nor the names of its 18191762Simp * contributors may be used to endorse or promote products derived 19191762Simp * from this software without specific, prior written permission. 20191762Simp * 21191762Simp * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22191762Simp * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23191762Simp * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 24191762Simp * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 25191762Simp * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 26191762Simp * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, 27191762Simp * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28191762Simp * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 29191762Simp * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30191762Simp * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 31191762Simp * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32191762Simp * SUCH DAMAGE. 33191762Simp * 34191762Simp * $DragonFly: src/sys/dev/netif/bwi/bwiphy.h,v 1.1 2007/09/08 06:15:54 sephe Exp $ 35191762Simp * $FreeBSD: releng/11.0/sys/dev/bwi/bwiphy.h 191762 2009-05-03 04:01:43Z imp $ 36191762Simp */ 37191762Simp 38191762Simp#ifndef _BWI_PHY_H 39191762Simp#define _BWI_PHY_H 40191762Simp 41191762Simpstruct bwi_gains { 42191762Simp int16_t tbl_gain1; 43191762Simp int16_t tbl_gain2; 44191762Simp int16_t phy_gain; 45191762Simp}; 46191762Simp 47191762Simpint bwi_phy_attach(struct bwi_mac *); 48191762Simpvoid bwi_phy_clear_state(struct bwi_phy *); 49191762Simp 50191762Simpint bwi_phy_calibrate(struct bwi_mac *); 51191762Simpvoid bwi_phy_set_bbp_atten(struct bwi_mac *, uint16_t); 52191762Simp 53191762Simpvoid bwi_set_gains(struct bwi_mac *, const struct bwi_gains *); 54191762Simpint16_t bwi_nrssi_read(struct bwi_mac *, uint16_t); 55191762Simpvoid bwi_nrssi_write(struct bwi_mac *, uint16_t, int16_t); 56191762Simp 57191762Simpuint16_t bwi_phy_read(struct bwi_mac *, uint16_t); 58191762Simpvoid bwi_phy_write(struct bwi_mac *, uint16_t, uint16_t); 59191762Simp 60191762Simpstatic __inline void 61191762Simpbwi_phy_init(struct bwi_mac *_mac) 62191762Simp{ 63191762Simp _mac->mac_phy.phy_init(_mac); 64191762Simp} 65191762Simp 66191762Simp#define PHY_WRITE(mac, ctrl, val) bwi_phy_write((mac), (ctrl), (val)) 67191762Simp#define PHY_READ(mac, ctrl) bwi_phy_read((mac), (ctrl)) 68191762Simp 69191762Simp#define PHY_SETBITS(mac, ctrl, bits) \ 70191762Simp PHY_WRITE((mac), (ctrl), PHY_READ((mac), (ctrl)) | (bits)) 71191762Simp#define PHY_CLRBITS(mac, ctrl, bits) \ 72191762Simp PHY_WRITE((mac), (ctrl), PHY_READ((mac), (ctrl)) & ~(bits)) 73191762Simp#define PHY_FILT_SETBITS(mac, ctrl, filt, bits) \ 74191762Simp PHY_WRITE((mac), (ctrl), (PHY_READ((mac), (ctrl)) & (filt)) | (bits)) 75191762Simp 76191762Simp#define BWI_PHYR_NRSSI_THR_11B 0x020 77191762Simp#define BWI_PHYR_BBP_ATTEN 0x060 78191762Simp#define BWI_PHYR_TBL_CTRL_11A 0x072 79191762Simp#define BWI_PHYR_TBL_DATA_LO_11A 0x073 80191762Simp#define BWI_PHYR_TBL_DATA_HI_11A 0x074 81191762Simp#define BWI_PHYR_TBL_CTRL_11G 0x472 82191762Simp#define BWI_PHYR_TBL_DATA_LO_11G 0x473 83191762Simp#define BWI_PHYR_TBL_DATA_HI_11G 0x474 84191762Simp#define BWI_PHYR_NRSSI_THR_11G 0x48a 85191762Simp#define BWI_PHYR_NRSSI_CTRL 0x803 86191762Simp#define BWI_PHYR_NRSSI_DATA 0x804 87191762Simp#define BWI_PHYR_RF_LO 0x810 88191762Simp 89191762Simp/* 90191762Simp * PHY Tables 91191762Simp */ 92191762Simp/* 93191762Simp * http://bcm-specs.sipsolutions.net/APHYSetup/FineFrequency 94191762Simp * G PHY 95191762Simp */ 96191762Simp#define BWI_PHY_FREQ_11G_REV1 \ 97191762Simp 0x0089, 0x02e9, 0x0409, 0x04e9, 0x05a9, 0x0669, 0x0709, 0x0789, \ 98191762Simp 0x0829, 0x08a9, 0x0929, 0x0989, 0x0a09, 0x0a69, 0x0ac9, 0x0b29, \ 99191762Simp 0x0ba9, 0x0be9, 0x0c49, 0x0ca9, 0x0d09, 0x0d69, 0x0da9, 0x0e09, \ 100191762Simp 0x0e69, 0x0ea9, 0x0f09, 0x0f49, 0x0fa9, 0x0fe9, 0x1029, 0x1089, \ 101191762Simp 0x10c9, 0x1109, 0x1169, 0x11a9, 0x11e9, 0x1229, 0x1289, 0x12c9, \ 102191762Simp 0x1309, 0x1349, 0x1389, 0x13c9, 0x1409, 0x1449, 0x14a9, 0x14e9, \ 103191762Simp 0x1529, 0x1569, 0x15a9, 0x15e9, 0x1629, 0x1669, 0x16a9, 0x16e8, \ 104191762Simp 0x1728, 0x1768, 0x17a8, 0x17e8, 0x1828, 0x1868, 0x18a8, 0x18e8, \ 105191762Simp 0x1928, 0x1968, 0x19a8, 0x19e8, 0x1a28, 0x1a68, 0x1aa8, 0x1ae8, \ 106191762Simp 0x1b28, 0x1b68, 0x1ba8, 0x1be8, 0x1c28, 0x1c68, 0x1ca8, 0x1ce8, \ 107191762Simp 0x1d28, 0x1d68, 0x1dc8, 0x1e08, 0x1e48, 0x1e88, 0x1ec8, 0x1f08, \ 108191762Simp 0x1f48, 0x1f88, 0x1fe8, 0x2028, 0x2068, 0x20a8, 0x2108, 0x2148, \ 109191762Simp 0x2188, 0x21c8, 0x2228, 0x2268, 0x22c8, 0x2308, 0x2348, 0x23a8, \ 110191762Simp 0x23e8, 0x2448, 0x24a8, 0x24e8, 0x2548, 0x25a8, 0x2608, 0x2668, \ 111191762Simp 0x26c8, 0x2728, 0x2787, 0x27e7, 0x2847, 0x28c7, 0x2947, 0x29a7, \ 112191762Simp 0x2a27, 0x2ac7, 0x2b47, 0x2be7, 0x2ca7, 0x2d67, 0x2e47, 0x2f67, \ 113191762Simp 0x3247, 0x3526, 0x3646, 0x3726, 0x3806, 0x38a6, 0x3946, 0x39e6, \ 114191762Simp 0x3a66, 0x3ae6, 0x3b66, 0x3bc6, 0x3c45, 0x3ca5, 0x3d05, 0x3d85, \ 115191762Simp 0x3de5, 0x3e45, 0x3ea5, 0x3ee5, 0x3f45, 0x3fa5, 0x4005, 0x4045, \ 116191762Simp 0x40a5, 0x40e5, 0x4145, 0x4185, 0x41e5, 0x4225, 0x4265, 0x42c5, \ 117191762Simp 0x4305, 0x4345, 0x43a5, 0x43e5, 0x4424, 0x4464, 0x44c4, 0x4504, \ 118191762Simp 0x4544, 0x4584, 0x45c4, 0x4604, 0x4644, 0x46a4, 0x46e4, 0x4724, \ 119191762Simp 0x4764, 0x47a4, 0x47e4, 0x4824, 0x4864, 0x48a4, 0x48e4, 0x4924, \ 120191762Simp 0x4964, 0x49a4, 0x49e4, 0x4a24, 0x4a64, 0x4aa4, 0x4ae4, 0x4b23, \ 121191762Simp 0x4b63, 0x4ba3, 0x4be3, 0x4c23, 0x4c63, 0x4ca3, 0x4ce3, 0x4d23, \ 122191762Simp 0x4d63, 0x4da3, 0x4de3, 0x4e23, 0x4e63, 0x4ea3, 0x4ee3, 0x4f23, \ 123191762Simp 0x4f63, 0x4fc3, 0x5003, 0x5043, 0x5083, 0x50c3, 0x5103, 0x5143, \ 124191762Simp 0x5183, 0x51e2, 0x5222, 0x5262, 0x52a2, 0x52e2, 0x5342, 0x5382, \ 125191762Simp 0x53c2, 0x5402, 0x5462, 0x54a2, 0x5502, 0x5542, 0x55a2, 0x55e2, \ 126191762Simp 0x5642, 0x5682, 0x56e2, 0x5722, 0x5782, 0x57e1, 0x5841, 0x58a1, \ 127191762Simp 0x5901, 0x5961, 0x59c1, 0x5a21, 0x5aa1, 0x5b01, 0x5b81, 0x5be1, \ 128191762Simp 0x5c61, 0x5d01, 0x5d80, 0x5e20, 0x5ee0, 0x5fa0, 0x6080, 0x61c0 129191762Simp 130191762Simp/* 131191762Simp * http://bcm-specs.sipsolutions.net/APHYSetup/noise_table 132191762Simp */ 133191762Simp/* G PHY Revision 1 */ 134191762Simp#define BWI_PHY_NOISE_11G_REV1 \ 135191762Simp 0x013c, 0x01f5, 0x031a, 0x0631, 0x0001, 0x0001, 0x0001, 0x0001 136191762Simp/* G PHY generic */ 137191762Simp#define BWI_PHY_NOISE_11G \ 138191762Simp 0x5484, 0x3c40, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 139191762Simp 140191762Simp/* 141191762Simp * http://bcm-specs.sipsolutions.net/APHYSetup/rotor_table 142191762Simp * G PHY Revision 1 143191762Simp */ 144191762Simp#define BWI_PHY_ROTOR_11G_REV1 \ 145191762Simp 0xfeb93ffd, 0xfec63ffd, 0xfed23ffd, 0xfedf3ffd, \ 146191762Simp 0xfeec3ffe, 0xfef83ffe, 0xff053ffe, 0xff113ffe, \ 147191762Simp 0xff1e3ffe, 0xff2a3fff, 0xff373fff, 0xff443fff, \ 148191762Simp 0xff503fff, 0xff5d3fff, 0xff693fff, 0xff763fff, \ 149191762Simp 0xff824000, 0xff8f4000, 0xff9b4000, 0xffa84000, \ 150191762Simp 0xffb54000, 0xffc14000, 0xffce4000, 0xffda4000, \ 151191762Simp 0xffe74000, 0xfff34000, 0x00004000, 0x000d4000, \ 152191762Simp 0x00194000, 0x00264000, 0x00324000, 0x003f4000, \ 153191762Simp 0x004b4000, 0x00584000, 0x00654000, 0x00714000, \ 154191762Simp 0x007e4000, 0x008a3fff, 0x00973fff, 0x00a33fff, \ 155191762Simp 0x00b03fff, 0x00bc3fff, 0x00c93fff, 0x00d63fff, \ 156191762Simp 0x00e23ffe, 0x00ef3ffe, 0x00fb3ffe, 0x01083ffe, \ 157191762Simp 0x01143ffe, 0x01213ffd, 0x012e3ffd, 0x013a3ffd, \ 158191762Simp 0x01473ffd 159191762Simp 160191762Simp/* 161191762Simp * http://bcm-specs.sipsolutions.net/APHYSetup/noise_scale_table 162191762Simp */ 163191762Simp/* G PHY Revision [0,2] */ 164191762Simp#define BWI_PHY_NOISE_SCALE_11G_REV2 \ 165191762Simp 0x6c77, 0x5162, 0x3b40, 0x3335, 0x2f2d, 0x2a2a, 0x2527, 0x1f21, \ 166191762Simp 0x1a1d, 0x1719, 0x1616, 0x1414, 0x1414, 0x1400, 0x1414, 0x1614, \ 167191762Simp 0x1716, 0x1a19, 0x1f1d, 0x2521, 0x2a27, 0x2f2a, 0x332d, 0x3b35, \ 168191762Simp 0x5140, 0x6c62, 0x0077 169191762Simp/* G PHY Revsion 7 */ 170191762Simp#define BWI_PHY_NOISE_SCALE_11G_REV7 \ 171191762Simp 0xa4a4, 0xa4a4, 0xa4a4, 0xa4a4, 0xa4a4, 0xa4a4, 0xa4a4, 0xa4a4, \ 172191762Simp 0xa4a4, 0xa4a4, 0xa4a4, 0xa4a4, 0xa4a4, 0xa400, 0xa4a4, 0xa4a4, \ 173191762Simp 0xa4a4, 0xa4a4, 0xa4a4, 0xa4a4, 0xa4a4, 0xa4a4, 0xa4a4, 0xa4a4, \ 174191762Simp 0xa4a4, 0xa4a4, 0x00a4 175191762Simp/* G PHY generic */ 176191762Simp#define BWI_PHY_NOISE_SCALE_11G \ 177191762Simp 0xd8dd, 0xcbd4, 0xbcc0, 0xb6b7, 0xb2b0, 0xadad, 0xa7a9, 0x9fa1, \ 178191762Simp 0x969b, 0x9195, 0x8f8f, 0x8a8a, 0x8a8a, 0x8a00, 0x8a8a, 0x8f8a, \ 179191762Simp 0x918f, 0x9695, 0x9f9b, 0xa7a1, 0xada9, 0xb2ad, 0xb6b0, 0xbcb7, \ 180191762Simp 0xcbc0, 0xd8d4, 0x00dd 181191762Simp 182191762Simp/* 183191762Simp * http://bcm-specs.sipsolutions.net/APHYSetup/sigma_square_table 184191762Simp */ 185191762Simp/* G PHY Revision 2 */ 186191762Simp#define BWI_PHY_SIGMA_SQ_11G_REV2 \ 187191762Simp 0x007a, 0x0075, 0x0071, 0x006c, 0x0067, 0x0063, 0x005e, 0x0059, \ 188191762Simp 0x0054, 0x0050, 0x004b, 0x0046, 0x0042, 0x003d, 0x003d, 0x003d, \ 189191762Simp 0x003d, 0x003d, 0x003d, 0x003d, 0x003d, 0x003d, 0x003d, 0x003d, \ 190191762Simp 0x003d, 0x003d, 0x0000, 0x003d, 0x003d, 0x003d, 0x003d, 0x003d, \ 191191762Simp 0x003d, 0x003d, 0x003d, 0x003d, 0x003d, 0x003d, 0x003d, 0x003d, \ 192191762Simp 0x0042, 0x0046, 0x004b, 0x0050, 0x0054, 0x0059, 0x005e, 0x0063, \ 193191762Simp 0x0067, 0x006c, 0x0071, 0x0075, 0x007a 194191762Simp/* G PHY Revision (2,7] */ 195191762Simp#define BWI_PHY_SIGMA_SQ_11G_REV7 \ 196191762Simp 0x00de, 0x00dc, 0x00da, 0x00d8, 0x00d6, 0x00d4, 0x00d2, 0x00cf, \ 197191762Simp 0x00cd, 0x00ca, 0x00c7, 0x00c4, 0x00c1, 0x00be, 0x00be, 0x00be, \ 198191762Simp 0x00be, 0x00be, 0x00be, 0x00be, 0x00be, 0x00be, 0x00be, 0x00be, \ 199191762Simp 0x00be, 0x00be, 0x0000, 0x00be, 0x00be, 0x00be, 0x00be, 0x00be, \ 200191762Simp 0x00be, 0x00be, 0x00be, 0x00be, 0x00be, 0x00be, 0x00be, 0x00be, \ 201191762Simp 0x00c1, 0x00c4, 0x00c7, 0x00ca, 0x00cd, 0x00cf, 0x00d2, 0x00d4, \ 202191762Simp 0x00d6, 0x00d8, 0x00da, 0x00dc, 0x00de 203191762Simp 204191762Simp/* 205191762Simp * http://bcm-specs.sipsolutions.net/APHYSetup/retard_table 206191762Simp * G PHY 207191762Simp */ 208191762Simp#define BWI_PHY_DELAY_11G_REV1 \ 209191762Simp 0xdb93cb87, 0xd666cf64, 0xd1fdd358, 0xcda6d826, \ 210191762Simp 0xca38dd9f, 0xc729e2b4, 0xc469e88e, 0xc26aee2b, \ 211191762Simp 0xc0def46c, 0xc073fa62, 0xc01d00d5, 0xc0760743, \ 212191762Simp 0xc1560d1e, 0xc2e51369, 0xc4ed18ff, 0xc7ac1ed7, \ 213191762Simp 0xcb2823b2, 0xcefa28d9, 0xd2f62d3f, 0xd7bb3197, \ 214191762Simp 0xdce53568, 0xe1fe3875, 0xe7d13b35, 0xed663d35, \ 215191762Simp 0xf39b3ec4, 0xf98e3fa7, 0x00004000, 0x06723fa7, \ 216191762Simp 0x0c653ec4, 0x129a3d35, 0x182f3b35, 0x1e023875, \ 217191762Simp 0x231b3568, 0x28453197, 0x2d0a2d3f, 0x310628d9, \ 218191762Simp 0x34d823b2, 0x38541ed7, 0x3b1318ff, 0x3d1b1369, \ 219191762Simp 0x3eaa0d1e, 0x3f8a0743, 0x3fe300d5, 0x3f8dfa62, \ 220191762Simp 0x3f22f46c, 0x3d96ee2b, 0x3b97e88e, 0x38d7e2b4, \ 221191762Simp 0x35c8dd9f, 0x325ad826, 0x2e03d358, 0x299acf64, \ 222191762Simp 0x246dcb87 223191762Simp 224191762Simp#endif /* !_BWI_PHY_H */ 225