From patchwork Thu Apr 13 18:07:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Larry Finger X-Patchwork-Id: 9679805 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 06971601C3 for ; Thu, 13 Apr 2017 18:08:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F09612869E for ; Thu, 13 Apr 2017 18:08:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E44E1286AC; Thu, 13 Apr 2017 18:08:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 284222869E for ; Thu, 13 Apr 2017 18:08:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755225AbdDMSHd (ORCPT ); Thu, 13 Apr 2017 14:07:33 -0400 Received: from mail-oi0-f65.google.com ([209.85.218.65]:36738 "EHLO mail-oi0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755320AbdDMSHZ (ORCPT ); Thu, 13 Apr 2017 14:07:25 -0400 Received: by mail-oi0-f65.google.com with SMTP id b187so13576439oif.3 for ; Thu, 13 Apr 2017 11:07:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=DuBiUcow1oYDkIaCtyU0OWnPqxXBLWa+P/skLkYl2zQ=; b=QoP14WePvXkD7ilr3ZqwxYVCyd79plFslNm1f6y1AaaslN5BqaOEG3BIbCg0/hBURX qbHTe5vOe+5s7bwKpQrzhPgzRPmW2ZqIegMGbhOSkC578kExVsUrQb3ljSDKbeajTgpP OWCBqoa/3eOpy1KVc//Xt7Y/v21ylRr0+r7pFRWXhD9z7zcEZANMKtm3GpN2XpUPUmQJ SHS1qk/FWGZlOKwNS3Kly8GSZVRFpU9Hi+1fFhIy1PsIuFNyKWZd99LWhm9LF437Ud03 4NROtUtRyhvv9kR+hNgzpubD5r3ijPR4GSioTXcudfBVx/iaiCNIwCDHxDE/7lPbM84w Zvxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=DuBiUcow1oYDkIaCtyU0OWnPqxXBLWa+P/skLkYl2zQ=; b=VrKToUXx6Mnaj/p7GYzQMYkLpzB9nkR5DTLLZ4aMStDJUOGo8+tHNVFZzGI3PImM3F qfvLx1+XZuy01DxbJDtSvZGdTt2eYuRH6u43cB6Bx3ojtqvlvov77IuVztiD8fITR/nh W8bFPLVftkabalR44Axcw4sKmH5dd2RhM5wY9YYI5h53l6brLeFPIs1A0GsUOvQ2j3e3 v6N7fYEl2MUpDSGRObdojaVO4vB5UFEUZxfOaoziw7BcBsFL1DVAkiP58Y/ZD2abOcpS b3Xhx80lyy05AA2rQw/Dc6z3nEsJRKl6NODbfsA/cW+K8EaZF5Shh4LISDtAEZsgEBwR 3CPw== X-Gm-Message-State: AN3rC/5uS8LXWmzUb79gIPhJygYWFekGxUTZJAHLwV/wF/OASaG/JG9q NBcx1q1G1SgBSg== X-Received: by 10.157.27.226 with SMTP id v31mr3181018otv.83.1492106844599; Thu, 13 Apr 2017 11:07:24 -0700 (PDT) Received: from linux-4v1g.suse (cpe-24-31-249-175.kc.res.rr.com. [24.31.249.175]) by smtp.gmail.com with ESMTPSA id x54sm10897996otd.11.2017.04.13.11.07.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 13 Apr 2017 11:07:24 -0700 (PDT) From: Larry Finger To: kvalo@codeaurora.org Cc: linux-wireless@vger.kernel.org, Yan-Hsuan Chuang , Larry Finger , Pkshih , Birming Chiu , Shaofu , Steven Ting Subject: [PATCH 10/19] rtlwifi: btcoex: 21a 2ant: centralized control of coex table Date: Thu, 13 Apr 2017 13:07:01 -0500 Message-Id: <20170413180710.19953-11-Larry.Finger@lwfinger.net> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20170413180710.19953-1-Larry.Finger@lwfinger.net> References: <20170413180710.19953-1-Larry.Finger@lwfinger.net> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Yan-Hsuan Chuang Gather multiple coex table settings into a function coex_table_with_type() and control the coex table according the type value as put in switch-case expression. Signed-off-by: Yan-Hsuan Chuang Signed-off-by: Larry Finger Cc: Pkshih Cc: Birming Chiu Cc: Shaofu Cc: Steven Ting --- .../realtek/rtlwifi/btcoexist/halbtc8821a2ant.c | 116 +++++++++++++++++---- .../realtek/rtlwifi/btcoexist/halbtc8821a2ant.h | 2 + 2 files changed, 99 insertions(+), 19 deletions(-) diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a2ant.c b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a2ant.c index 77916ae3d043..4d69955fbebc 100644 --- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a2ant.c +++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a2ant.c @@ -856,6 +856,89 @@ static void btc8821a2ant_coex_table(struct btc_coexist *btcoexist, coex_dm->pre_val0x6cc = coex_dm->cur_val0x6cc; } +static void btc8821a2ant_coex_table_with_type(struct btc_coexist *btcoexist, + bool force_exec, u8 type) +{ + coex_sta->coex_table_type = type; + + switch (type) { + case 0: + btc8821a2ant_coex_table(btcoexist, force_exec, 0x55555555, + 0x55555555, 0xffffff, 0x3); + break; + case 1: + btc8821a2ant_coex_table(btcoexist, force_exec, 0x55555555, + 0x5afa5afa, 0xffffff, 0x3); + break; + case 2: + btc8821a2ant_coex_table(btcoexist, force_exec, 0x5ada5ada, + 0x5ada5ada, 0xffffff, 0x3); + break; + case 3: + btc8821a2ant_coex_table(btcoexist, force_exec, 0xaaaaaaaa, + 0xaaaaaaaa, 0xffffff, 0x3); + break; + case 4: + btc8821a2ant_coex_table(btcoexist, force_exec, 0xffffffff, + 0xffffffff, 0xffffff, 0x3); + break; + case 5: + btc8821a2ant_coex_table(btcoexist, force_exec, 0x5fff5fff, + 0x5fff5fff, 0xffffff, 0x3); + break; + case 6: + btc8821a2ant_coex_table(btcoexist, force_exec, 0x55ff55ff, + 0x5a5a5a5a, 0xffffff, 0x3); + break; + case 7: + btc8821a2ant_coex_table(btcoexist, force_exec, 0x55dd55dd, + 0x5ada5ada, 0xffffff, 0x3); + break; + case 8: + btc8821a2ant_coex_table(btcoexist, force_exec, 0x55dd55dd, + 0x5ada5ada, 0xffffff, 0x3); + break; + case 9: + btc8821a2ant_coex_table(btcoexist, force_exec, 0x55dd55dd, + 0x5ada5ada, 0xffffff, 0x3); + break; + case 10: + btc8821a2ant_coex_table(btcoexist, force_exec, 0x55dd55dd, + 0x5ada5ada, 0xffffff, 0x3); + break; + case 11: + btc8821a2ant_coex_table(btcoexist, force_exec, 0x55dd55dd, + 0x5ada5ada, 0xffffff, 0x3); + break; + case 12: + btc8821a2ant_coex_table(btcoexist, force_exec, 0x55dd55dd, + 0x5ada5ada, 0xffffff, 0x3); + break; + case 13: + btc8821a2ant_coex_table(btcoexist, force_exec, 0x5fff5fff, + 0xaaaaaaaa, 0xffffff, 0x3); + break; + case 14: + btc8821a2ant_coex_table(btcoexist, force_exec, 0x5fff5fff, + 0x5ada5ada, 0xffffff, 0x3); + break; + case 15: + btc8821a2ant_coex_table(btcoexist, force_exec, 0x55dd55dd, + 0xaaaaaaaa, 0xffffff, 0x3); + break; + case 16: + btc8821a2ant_coex_table(btcoexist, force_exec, 0x5fdf5fdf, + 0x5fdb5fdb, 0xffffff, 0x3); + break; + case 17: + btc8821a2ant_coex_table(btcoexist, force_exec, 0xfafafafa, + 0xfafafafa, 0xffffff, 0x3); + break; + default: + break; + } +} + static void btc8821a2ant_set_fw_ignore_wlan_act(struct btc_coexist *btcoex, bool enable) { @@ -1234,8 +1317,7 @@ static void btc8821a2ant_coex_all_off(struct btc_coexist *btcoexist) btc8821a2ant_sw_mechanism2(btcoexist, false, false, false, 0x18); /* hw all off */ - btc8821a2ant_coex_table(btcoexist, NORMAL_EXEC, - 0x55555555, 0x55555555, 0xffff, 0x3); + btc8821a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 0); } static void btc8821a2ant_coex_under_5g(struct btc_coexist *btcoexist) @@ -1246,8 +1328,7 @@ static void btc8821a2ant_coex_under_5g(struct btc_coexist *btcoexist) static void btc8821a2ant_init_coex_dm(struct btc_coexist *btcoexist) { /* force to reset coex mechanism */ - btc8821a2ant_coex_table(btcoexist, FORCE_EXEC, 0x55555555, - 0x55555555, 0xffff, 0x3); + btc8821a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 0); btc8821a2ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); btc8821a2ant_ps_tdma(btcoexist, FORCE_EXEC, false, 1); @@ -1736,12 +1817,10 @@ static void btc8821a2ant_action_hid(struct btc_coexist *btcoexist) if (wifi_bw == BTC_WIFI_BW_LEGACY) { /* for HID at 11b/g mode */ - btc8821a2ant_coex_table(btcoexist, NORMAL_EXEC, 0x55ff55ff, - 0x5a5a5a5a, 0xffff, 0x3); + btc8821a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 7); } else { /* for HID quality & wifi performance balance at 11n mode */ - btc8821a2ant_coex_table(btcoexist, NORMAL_EXEC, 0x55ff55ff, - 0x5aea5aea, 0xffff, 0x3); + btc8821a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 2); } btc8821a2ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); @@ -1933,9 +2012,9 @@ static void btc8821a2ant_action_pan_edr(struct btc_coexist *btcoexist) btc8821a2ant_coex_table(btcoexist, NORMAL_EXEC, 0x55ff55ff, 0x5aff5aff, 0xffff, 0x3); } else { - /* for HID quality & wifi performance balance at 11n mode */ - btc8821a2ant_coex_table(btcoexist, NORMAL_EXEC, 0x55ff55ff, - 0x5aff5aff, 0xffff, 0x3); + btc8821a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 13); + btc8821a2ant_power_save_state(btcoexist, BTC_PS_LPS_ON, 0x50, + 0x4); } if (BTC_WIFI_BW_HT40 == wifi_bw) { @@ -2317,13 +2396,13 @@ static void btc8821a2ant_action_hid_a2dp(struct btc_coexist *btcoexist) btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw); if (wifi_bw == BTC_WIFI_BW_LEGACY) { - /* for HID at 11b/g mode */ - btc8821a2ant_coex_table(btcoexist, NORMAL_EXEC, 0x55ff55ff, - 0x5f5b5f5b, 0xffffff, 0x3); + btc8821a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 7); + btc8821a2ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, + 0x0, 0x0); } else { - /* for HID quality & wifi performance balance at 11n mode */ - btc8821a2ant_coex_table(btcoexist, NORMAL_EXEC, 0x55ff55ff, - 0x5f5b5f5b, 0xffffff, 0x3); + btc8821a2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 14); + btc8821a2ant_power_save_state(btcoexist, BTC_PS_LPS_ON, 0x50, + 0x4); } if (BTC_WIFI_BW_HT40 == wifi_bw) { @@ -2496,8 +2575,7 @@ void ex_btc8821a2ant_init_hwconfig(struct btc_coexist *btcoexist) btc8821a2ant_set_ant_path(btcoexist, BTC_ANT_WIFI_AT_MAIN, true, false); /* PTA parameter */ - btc8821a2ant_coex_table(btcoexist, FORCE_EXEC, 0x55555555, 0x55555555, - 0xffff, 0x3); + btc8821a2ant_coex_table_with_type(btcoexist, FORCE_EXEC, 0); /* Enable counter statistics */ /*0x76e[3] = 1, WLAN_Act control by PTA*/ diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a2ant.h b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a2ant.h index 804b5b95cab0..6db96cf44034 100644 --- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a2ant.h +++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a2ant.h @@ -155,6 +155,8 @@ struct coex_sta_8821a_2ant { u32 crc_err_11g; u32 crc_err_11n; u32 crc_err_11n_agg; + + u8 coex_table_type; bool force_lps_on; };