net: wifi: rockchip: update broadcom drivers for kernel4.4
[firefly-linux-kernel-4.4.55.git] / drivers / net / wireless / rockchip_wlan / rkwifi / bcmdhd / bcmwifi_channels.c
index 4a848d2674de14626b8f84c2b08537be0a139510..be884cc33cc127aac205c361b6be5291e68c82a6 100755 (executable)
@@ -3,8 +3,30 @@
  * Contents are wifi-specific, used by any kernel or app-level
  * software that might want wifi things as it grows.
  *
- * $Copyright Open Broadcom Corporation$
- * $Id: bcmwifi_channels.c 309193 2012-01-19 00:03:57Z $
+ * Copyright (C) 1999-2016, Broadcom Corporation
+ * 
+ *      Unless you and Broadcom execute a separate written software license
+ * agreement governing use of this software, this software is licensed to you
+ * under the terms of the GNU General Public License version 2 (the "GPL"),
+ * available at http://www.broadcom.com/licenses/GPLv2.php, with the
+ * following added to such license:
+ * 
+ *      As a special exception, the copyright holders of this software give you
+ * permission to link this software with independent modules, and to copy and
+ * distribute the resulting executable under terms of your choice, provided that
+ * you also meet, for each linked independent module, the terms and conditions of
+ * the license of that module.  An independent module is a module which is not
+ * derived from this software.  The special exception does not apply to any
+ * modifications of the software.
+ * 
+ *      Notwithstanding the above, under no circumstances may you combine this
+ * software in any way with any other Broadcom software provided under a license
+ * other than the GPL, without Broadcom's express prior written consent.
+ *
+ *
+ * <<Broadcom-WL-IPTag/Open:>>
+ *
+ * $Id: bcmwifi_channels.c 591285 2015-10-07 11:56:29Z $
  */
 
 #include <bcm_cfg.h>
@@ -107,7 +129,11 @@ static const char *wf_chspec_bw_str[] =
        "80",
        "160",
        "80+80",
+#ifdef WL11ULB
+       "2.5"
+#else /* WL11ULB */
        "na"
+#endif /* WL11ULB */
 };
 
 static const uint8 wf_chspec_bw_mhz[] =
@@ -331,11 +357,10 @@ wf_chspec_aton(const char *a)
        /* parse channel num or band */
        if (!read_uint(&a, &num))
                return 0;
-
        /* if we are looking at a 'g', then the first number was a band */
        c = tolower((int)a[0]);
        if (c == 'g') {
-               a ++; /* consume the char */
+               a++; /* consume the char */
 
                /* band must be "2" or "5" */
                if (num == 2)
@@ -382,7 +407,13 @@ wf_chspec_aton(const char *a)
                return 0;
 
        /* convert to chspec value */
-       if (bw == 20) {
+       if (bw == 2) {
+               chspec_bw = WL_CHANSPEC_BW_2P5;
+       } else if (bw == 5) {
+               chspec_bw = WL_CHANSPEC_BW_5;
+       } else if (bw == 10) {
+               chspec_bw = WL_CHANSPEC_BW_10;
+       } else if (bw == 20) {
                chspec_bw = WL_CHANSPEC_BW_20;
        } else if (bw == 40) {
                chspec_bw = WL_CHANSPEC_BW_40;
@@ -396,7 +427,8 @@ wf_chspec_aton(const char *a)
 
        /* So far we have <band>g<chan>/<bw>
         * Can now be followed by u/l if bw = 40,
-        * or '+80' if bw = 80, to make '80+80' bw.
+        * or '+80' if bw = 80, to make '80+80' bw,
+        * or '.5' if bw = 2.5 to make '2.5' bw .
         */
 
        c = tolower((int)a[0]);
@@ -413,7 +445,7 @@ wf_chspec_aton(const char *a)
        /* check for 80+80 */
        if (c == '+') {
                /* 80+80 */
-               static const char *plus80 = "80/";
+               const char plus80[] = "80/";
 
                /* must be looking at '+80/'
                 * check and consume this string.
@@ -424,7 +456,7 @@ wf_chspec_aton(const char *a)
 
                /* consume the '80/' string */
                for (i = 0; i < 3; i++) {
-                       if (*a++ != *plus80++) {
+                       if (*a++ != plus80[i]) {
                                return 0;
                        }
                }
@@ -441,6 +473,19 @@ wf_chspec_aton(const char *a)
                /* read secondary 80MHz channel */
                if (!read_uint(&a, &ch2))
                        return 0;
+       } else if (c == '.') {
+               /* 2.5 */
+               /* must be looking at '.5'
+                * check and consume this string.
+                */
+               chspec_bw = WL_CHANSPEC_BW_2P5;
+
+               a ++; /* consume the char '.' */
+
+               /* consume the '5' string */
+               if (*a++ != '5') {
+                       return 0;
+               }
        }
 
 done_read:
@@ -473,7 +518,7 @@ done_read:
                }
        }
        /* if the bw is 20, center and sideband are trivial */
-       else if (chspec_bw == WL_CHANSPEC_BW_20) {
+       else if (BW_LE20(chspec_bw)) {
                chspec_ch = ctl_ch;
                chspec_sb = WL_CHANSPEC_CTL_SB_NONE;
        }
@@ -565,8 +610,7 @@ wf_chspec_malformed(chanspec_t chanspec)
        /* must be 2G or 5G band */
        if (CHSPEC_IS2G(chanspec)) {
                /* must be valid bandwidth */
-               if (chspec_bw != WL_CHANSPEC_BW_20 &&
-                   chspec_bw != WL_CHANSPEC_BW_40) {
+               if (!BW_LE40(chspec_bw)) {
                        return TRUE;
                }
        } else if (CHSPEC_IS5G(chanspec)) {
@@ -579,9 +623,7 @@ wf_chspec_malformed(chanspec_t chanspec)
                        if (ch1_id >= WF_NUM_5G_80M_CHANS || ch2_id >= WF_NUM_5G_80M_CHANS)
                                return TRUE;
 
-               } else if (chspec_bw == WL_CHANSPEC_BW_20 || chspec_bw == WL_CHANSPEC_BW_40 ||
-                          chspec_bw == WL_CHANSPEC_BW_80 || chspec_bw == WL_CHANSPEC_BW_160) {
-
+               } else if (BW_LE160(chspec_bw)) {
                        if (chspec_ch > MAXCHANNEL) {
                                return TRUE;
                        }
@@ -595,7 +637,7 @@ wf_chspec_malformed(chanspec_t chanspec)
        }
 
        /* side band needs to be consistent with bandwidth */
-       if (chspec_bw == WL_CHANSPEC_BW_20) {
+       if (BW_LE20(chspec_bw)) {
                if (CHSPEC_CTL_SB(chanspec) != WL_CHANSPEC_CTL_SB_LLL)
                        return TRUE;
        } else if (chspec_bw == WL_CHANSPEC_BW_40) {
@@ -627,7 +669,7 @@ wf_chspec_valid(chanspec_t chanspec)
 
        if (CHSPEC_IS2G(chanspec)) {
                /* must be valid bandwidth and channel range */
-               if (chspec_bw == WL_CHANSPEC_BW_20) {
+               if (BW_LE20(chspec_bw)) {
                        if (chspec_ch >= 1 && chspec_ch <= 14)
                                return TRUE;
                } else if (chspec_bw == WL_CHANSPEC_BW_40) {
@@ -649,7 +691,7 @@ wf_chspec_valid(chanspec_t chanspec)
                        const uint8 *center_ch;
                        uint num_ch, i;
 
-                       if (chspec_bw == WL_CHANSPEC_BW_20 || chspec_bw == WL_CHANSPEC_BW_40) {
+                       if (BW_LE40(chspec_bw)) {
                                center_ch = wf_5g_40m_chans;
                                num_ch = WF_NUM_5G_40M_CHANS;
                        } else if (chspec_bw == WL_CHANSPEC_BW_80) {
@@ -664,7 +706,7 @@ wf_chspec_valid(chanspec_t chanspec)
                        }
 
                        /* check for a valid center channel */
-                       if (chspec_bw == WL_CHANSPEC_BW_20) {
+                       if (BW_LE20(chspec_bw)) {
                                /* We don't have an array of legal 20MHz 5G channels, but they are
                                 * each side of the legal 40MHz channels.  Check the chanspec
                                 * channel against either side of the 40MHz channels.
@@ -720,7 +762,7 @@ wf_chspec_ctlchan(chanspec_t chspec)
        ASSERT(!wf_chspec_malformed(chspec));
 
        /* Is there a sideband ? */
-       if (CHSPEC_IS20(chspec)) {
+       if (CHSPEC_BW_LE20(chspec)) {
                return CHSPEC_CHANNEL(chspec);
        } else {
                sb = CHSPEC_CTL_SB(chspec) >> WL_CHANSPEC_CTL_SB_SHIFT;
@@ -749,7 +791,7 @@ wf_chspec_ctlchan(chanspec_t chspec)
 char *
 wf_chspec_to_bw_str(chanspec_t chspec)
 {
-       return (char *)wf_chspec_bw_str[(CHSPEC_BW(chspec) >> WL_CHANSPEC_BW_SHIFT)];
+               return (char *)wf_chspec_bw_str[(CHSPEC_BW(chspec) >> WL_CHANSPEC_BW_SHIFT)];
 }
 
 /*
@@ -764,7 +806,7 @@ wf_chspec_ctlchspec(chanspec_t chspec)
        ASSERT(!wf_chspec_malformed(chspec));
 
        /* Is there a sideband ? */
-       if (!CHSPEC_IS20(chspec)) {
+       if (!CHSPEC_BW_LE20(chspec)) {
                ctl_chan = wf_chspec_ctlchan(chspec);
                ctl_chspec = ctl_chan | WL_CHANSPEC_BW_20;
                ctl_chspec |= CHSPEC_BAND(chspec);
@@ -800,7 +842,7 @@ wf_channel2chspec(uint ctl_ch, uint bw)
                center_ch = wf_5g_160m_chans;
                num_ch = WF_NUM_5G_160M_CHANS;
                bw = 160;
-       } else if (bw == WL_CHANSPEC_BW_20) {
+       } else if (BW_LE20(bw)) {
                chspec |= ctl_ch;
                return chspec;
        } else {