From patchwork Tue May 26 17:18:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?SsOpcsO0bWUgUG91aWxsZXI=?= X-Patchwork-Id: 215519 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.7 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 84112C433E0 for ; Tue, 26 May 2020 17:19:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5759D207FB for ; Tue, 26 May 2020 17:19:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=silabs.onmicrosoft.com header.i=@silabs.onmicrosoft.com header.b="ckgVC8Xa" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388767AbgEZRS5 (ORCPT ); Tue, 26 May 2020 13:18:57 -0400 Received: from mail-bn8nam11on2083.outbound.protection.outlook.com ([40.107.236.83]:48578 "EHLO NAM11-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2388339AbgEZRS4 (ORCPT ); Tue, 26 May 2020 13:18:56 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MrYOHgfdVKHyTl9NFjKajBjJvts/yek5ccUDxkDOr9OwJc7uu2fEfA7bAV5G89qQ4GPpIF4EteKT3PQPH1KQCifZBb90s9if0pUHLz5WiNtaGA7MtPhMhojUvyykQq+p9IIIV39fsYyeldiI3jLFQBNalaJBjCaM8+d2TsPwSqxaCa/xsiWc4nD+HgsLP8JHI9OyE5WiW9JbWgrmI2MY8w1/KfIVBVyIpPW8/3poqT8HHzYTjDot/dC6tTiK0KdL7sH94kGqmkv0Um1TLq1zNQ6m528S8tEFbOFrSLeQTVrcYD++SL6qOHMLdpd/ntb2h7rP6/PN3I6hq6u5QlWQPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mmQSSAdCRES6wt7JUzUpJrFphugSWi39g4LXP/uhpZ0=; b=LdFvWZeCaPAzt7KGeIV7fDd4IYZIMxdRleEzMicohf0Jgl5Qg6xKLwQoj67f+t7rSXioaMEQF+YPd5XdSsDdiR/v8A8EjVma5g9mcVndGnxv+anZJasRA114CzbRdKsBAqYY5mg3NeCAg6J3+oA4sPEqQiYFRr3ewB0JGIaRGDOvy+L4Xz4eRhhCDEvl8uNe+r7YxM/Fls+2kEm3xCWrsVSAnobz1DiQsbgl+Xa11+w9fdj+Pd1Ey6soB7Z60oKmJzqddjkqNDoQj7azqaeuV54l8zNKwxz2t8IB1nDnUgPZGt94yEfCQYLLTRRxnmzzGjtcTbKySqE5Go9fSUduUA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=silabs.com; dmarc=pass action=none header.from=silabs.com; dkim=pass header.d=silabs.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=silabs.onmicrosoft.com; s=selector2-silabs-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mmQSSAdCRES6wt7JUzUpJrFphugSWi39g4LXP/uhpZ0=; b=ckgVC8XaNPMgGWRN6QyO6dzfT4iONCEiUhqzDRvTJyw7w2TxY0LwWzdiR+Gtq341ikNTD3qF5XRXWxYLWTYZ/T4L2r7M2axxL3gGTBGhsPiipnO3dzIheLxWgYu+3iTVOQm6X7t0VA9VmCNy29csCb0fELX1D1lIYkttfuYB4lM= Authentication-Results: driverdev.osuosl.org; dkim=none (message not signed) header.d=none; driverdev.osuosl.org; dmarc=none action=none header.from=silabs.com; Received: from SN6PR11MB2718.namprd11.prod.outlook.com (2603:10b6:805:63::18) by SN6PR11MB2750.namprd11.prod.outlook.com (2603:10b6:805:54::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3021.25; Tue, 26 May 2020 17:18:47 +0000 Received: from SN6PR11MB2718.namprd11.prod.outlook.com ([fe80::c504:2d66:a8f7:2336]) by SN6PR11MB2718.namprd11.prod.outlook.com ([fe80::c504:2d66:a8f7:2336%7]) with mapi id 15.20.3021.029; Tue, 26 May 2020 17:18:47 +0000 From: Jerome Pouiller To: devel@driverdev.osuosl.org, linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Kalle Valo , "David S . Miller" , =?utf-8?b?SsOpcsO0bWUgUG91aWxsZXI=?= Subject: [PATCH 04/10] staging: wfx: add support for tx_power_loop Date: Tue, 26 May 2020 19:18:15 +0200 Message-Id: <20200526171821.934581-5-Jerome.Pouiller@silabs.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200526171821.934581-1-Jerome.Pouiller@silabs.com> References: <20200526171821.934581-1-Jerome.Pouiller@silabs.com> X-ClientProxiedBy: PR1PR01CA0007.eurprd01.prod.exchangelabs.com (2603:10a6:102::20) To SN6PR11MB2718.namprd11.prod.outlook.com (2603:10b6:805:63::18) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from pc-42.home (2a01:e35:2435:66a0:544b:f17b:7ae8:fb7) by PR1PR01CA0007.eurprd01.prod.exchangelabs.com (2603:10a6:102::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3045.17 via Frontend Transport; Tue, 26 May 2020 17:18:45 +0000 X-Mailer: git-send-email 2.26.2 X-Originating-IP: [2a01:e35:2435:66a0:544b:f17b:7ae8:fb7] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9b4a99fc-b02c-41e7-0366-08d80198d9a2 X-MS-TrafficTypeDiagnostic: SN6PR11MB2750: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5236; X-Forefront-PRVS: 041517DFAB X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: F4HGAkPqDXxHaDWi4gsbalIPOEg5fn9XRqBAAS1kdD2j2Nmb1J0B6pe7D4aAehxigZVxpYy+cfAlt318kWqXKdmo0rFBN8IaoRn4Lvy5vwbMHbjsIH8YDUc07uUriPdpnJxRPq/rNY+VQHgr5BqZrQBvq57xrVAJ7VCtjwWSH6Bogq2ToJ4uPJRTpKTDDUQ/fyYe09HXQqB+6jwVXNONoZy6rvPmAQ60znG3JXwq40xuvNxVM7lDSDDvWEFCoFmZOR+QR+GpIeugmodRIFL3jsEQYjbPVNmW4jwZrirRm44ZAdx3qK8aqCcJewf24W2/dXsg6wmDZD1mEB1zPYV/3A== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN6PR11MB2718.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(396003)(376002)(366004)(39860400002)(136003)(346002)(4326008)(6512007)(316002)(8676002)(8936002)(2616005)(6486002)(2906002)(107886003)(1076003)(86362001)(6666004)(186003)(16526019)(5660300002)(66574014)(36756003)(54906003)(66556008)(478600001)(8886007)(6506007)(66946007)(66476007)(52116002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 3lRm9V8wlfaYx9dHzPSU0omD7rrlArlkdFaOGLnsSIt36YUaXH1NRlF0zsR7eWmNGbW9HHRUig0a/W1CYDzCiQ/WnvbuHQN13NYIt1C8za2N/YwIQ6DPqKB2zTnb/Rv+/HEgfhXxZKD8wmYn6rRZ8b308/WUp3S3DZZb5hgz6/ImboOSEf41cCxWrBBub+7geGLhYJNrefS9iQO7UO8yyZH465fiuz0zrb1AKTcoww7LM9d2oIFdPPXudTl+7CWsVUgp0hRjYwQ8s2PbNi25q8fogdP/2BVgT8+DUlFR7p2iqKgOhiBZoqJdvxJJ+qNcpAIonO67iocyUcZGR4XqmqV/RrRdTmA5WWP7+Ry9kqXomXwplzQevvWbxU9eFaiC9hq1SwFia+T6lvrpSUjP667R8R7kc8TYis1A0DgQ3UdJTaguhGzw2GM/QSCqEcQ4+pdeDcjAqHfr9MDKEFqFJIO0T05D7cWSB04GSIEnhvErCxu8BGoBrZijjek7FeuKeLtsevDcyfKbihTXionyhBAr6MkEhAr2oJnIMj+sk9o= X-OriginatorOrg: silabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9b4a99fc-b02c-41e7-0366-08d80198d9a2 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 May 2020 17:18:47.3384 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 54dbd822-5231-4b20-944d-6f4abcd541fb X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: v0gXdEPNn9XKzlwTDOpTTTWuF+ItAKckr633qzBYHATMi7gBWzcBlYtA9l2GzfMM4j1qXf1K8MXtPRQYNFyEXQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR11MB2750 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Jérôme Pouiller During the calibration of the RF amplifier, the device is able to provide some data about the status of the amplifier. Record these data and expose them in debugfs. Signed-off-by: Jérôme Pouiller --- drivers/staging/wfx/debug.c | 26 ++++++++++++++++++++++++++ drivers/staging/wfx/hif_api_general.h | 18 +++++++++++++++--- drivers/staging/wfx/hif_rx.c | 7 +++++++ drivers/staging/wfx/main.c | 2 ++ drivers/staging/wfx/wfx.h | 2 ++ 5 files changed, 52 insertions(+), 3 deletions(-) diff --git a/drivers/staging/wfx/debug.c b/drivers/staging/wfx/debug.c index f52e7cf885cba..10d649985696a 100644 --- a/drivers/staging/wfx/debug.c +++ b/drivers/staging/wfx/debug.c @@ -178,6 +178,30 @@ static int wfx_rx_stats_show(struct seq_file *seq, void *v) } DEFINE_SHOW_ATTRIBUTE(wfx_rx_stats); +static int wfx_tx_power_loop_show(struct seq_file *seq, void *v) +{ + struct wfx_dev *wdev = seq->private; + struct hif_tx_power_loop_info *st = &wdev->tx_power_loop_info; + int tmp; + + mutex_lock(&wdev->tx_power_loop_info_lock); + tmp = le16_to_cpu(st->tx_gain_dig); + seq_printf(seq, "Tx gain digital: %d\n", tmp); + tmp = le16_to_cpu(st->tx_gain_pa); + seq_printf(seq, "Tx gain PA: %d\n", tmp); + tmp = (s16)le16_to_cpu(st->target_pout); + seq_printf(seq, "Target Pout: %d.%02d dBm\n", tmp / 4, (tmp % 4) * 25); + tmp = (s16)le16_to_cpu(st->p_estimation); + seq_printf(seq, "FEM Pout: %d.%02d dBm\n", tmp / 4, (tmp % 4) * 25); + tmp = le16_to_cpu(st->vpdet); + seq_printf(seq, "Vpdet: %d mV\n", tmp); + seq_printf(seq, "Measure index: %d\n", st->measurement_index); + mutex_unlock(&wdev->tx_power_loop_info_lock); + + return 0; +} +DEFINE_SHOW_ATTRIBUTE(wfx_tx_power_loop); + static ssize_t wfx_send_pds_write(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos) @@ -317,6 +341,8 @@ int wfx_debug_init(struct wfx_dev *wdev) d = debugfs_create_dir("wfx", wdev->hw->wiphy->debugfsdir); debugfs_create_file("counters", 0444, d, wdev, &wfx_counters_fops); debugfs_create_file("rx_stats", 0444, d, wdev, &wfx_rx_stats_fops); + debugfs_create_file("tx_power_loop", 0444, d, wdev, + &wfx_tx_power_loop_fops); debugfs_create_file("send_pds", 0200, d, wdev, &wfx_send_pds_fops); debugfs_create_file("burn_slk_key", 0200, d, wdev, &wfx_burn_slk_key_fops); diff --git a/drivers/staging/wfx/hif_api_general.h b/drivers/staging/wfx/hif_api_general.h index f5abd81747069..dba18a7ae9194 100644 --- a/drivers/staging/wfx/hif_api_general.h +++ b/drivers/staging/wfx/hif_api_general.h @@ -201,9 +201,10 @@ struct hif_cnf_control_gpio { } __packed; enum hif_generic_indication_type { - HIF_GENERIC_INDICATION_TYPE_RAW = 0x0, - HIF_GENERIC_INDICATION_TYPE_STRING = 0x1, - HIF_GENERIC_INDICATION_TYPE_RX_STATS = 0x2 + HIF_GENERIC_INDICATION_TYPE_RAW = 0x0, + HIF_GENERIC_INDICATION_TYPE_STRING = 0x1, + HIF_GENERIC_INDICATION_TYPE_RX_STATS = 0x2, + HIF_GENERIC_INDICATION_TYPE_TX_POWER_LOOP_INFO = 0x3, }; struct hif_rx_stats { @@ -222,8 +223,19 @@ struct hif_rx_stats { s8 current_temp; } __packed; +struct hif_tx_power_loop_info { + __le16 tx_gain_dig; + __le16 tx_gain_pa; + __le16 target_pout; // signed value + __le16 p_estimation; // signed value + __le16 vpdet; + u8 measurement_index; + u8 reserved; +} __packed; + union hif_indication_data { struct hif_rx_stats rx_stats; + struct hif_tx_power_loop_info tx_power_loop_info; u8 raw_data[1]; }; diff --git a/drivers/staging/wfx/hif_rx.c b/drivers/staging/wfx/hif_rx.c index 88466063cc427..bb156033d1e16 100644 --- a/drivers/staging/wfx/hif_rx.c +++ b/drivers/staging/wfx/hif_rx.c @@ -278,6 +278,13 @@ static int hif_generic_indication(struct wfx_dev *wdev, sizeof(wdev->rx_stats)); mutex_unlock(&wdev->rx_stats_lock); return 0; + case HIF_GENERIC_INDICATION_TYPE_TX_POWER_LOOP_INFO: + mutex_lock(&wdev->tx_power_loop_info_lock); + memcpy(&wdev->tx_power_loop_info, + &body->indication_data.tx_power_loop_info, + sizeof(wdev->tx_power_loop_info)); + mutex_unlock(&wdev->tx_power_loop_info_lock); + return 0; default: dev_err(wdev->dev, "generic_indication: unknown indication type: %#.8x\n", type); diff --git a/drivers/staging/wfx/main.c b/drivers/staging/wfx/main.c index ae23a56f50e05..6bd96f4763884 100644 --- a/drivers/staging/wfx/main.c +++ b/drivers/staging/wfx/main.c @@ -274,6 +274,7 @@ static void wfx_free_common(void *data) { struct wfx_dev *wdev = data; + mutex_destroy(&wdev->tx_power_loop_info_lock); mutex_destroy(&wdev->rx_stats_lock); mutex_destroy(&wdev->conf_mutex); ieee80211_free_hw(wdev->hw); @@ -344,6 +345,7 @@ struct wfx_dev *wfx_init_common(struct device *dev, mutex_init(&wdev->conf_mutex); mutex_init(&wdev->rx_stats_lock); + mutex_init(&wdev->tx_power_loop_info_lock); init_completion(&wdev->firmware_ready); INIT_DELAYED_WORK(&wdev->cooling_timeout_work, wfx_cooling_timeout_work); diff --git a/drivers/staging/wfx/wfx.h b/drivers/staging/wfx/wfx.h index cc9f7d16ee8b7..73e216733ce4f 100644 --- a/drivers/staging/wfx/wfx.h +++ b/drivers/staging/wfx/wfx.h @@ -58,6 +58,8 @@ struct wfx_dev { struct hif_rx_stats rx_stats; struct mutex rx_stats_lock; + struct hif_tx_power_loop_info tx_power_loop_info; + struct mutex tx_power_loop_info_lock; }; struct wfx_vif {