From patchwork Thu Sep 20 09:12:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 10607185 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-2.web.codeaurora.org (Postfix) with ESMTP id 170896CB for ; Thu, 20 Sep 2018 09:12:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 05DE12CBE7 for ; Thu, 20 Sep 2018 09:12:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EE2CD2CC43; Thu, 20 Sep 2018 09:12:40 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI 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 823012CBE7 for ; Thu, 20 Sep 2018 09:12:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387492AbeITOzH (ORCPT ); Thu, 20 Sep 2018 10:55:07 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:34869 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387441AbeITOzH (ORCPT ); Thu, 20 Sep 2018 10:55:07 -0400 Received: by mail-wm1-f66.google.com with SMTP id o18-v6so10080504wmc.0 for ; Thu, 20 Sep 2018 02:12:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=FxNonfTywGDrcfsW9iBpQWuscO0kRWyqjgRrKkmDuKc=; b=qHTxj/X1iemdxis9kTeOfeo3RbSsy3VOOu7w3m1pYnKnIko8Mt2Id+BKJWvFyzxRZs qzSJ3qP/TJ2yNrHH18G6TheVNqgDnX1+dS3ruBF89qvSjwncMI8bPbU5F7oKM9bNdsqi Yo7jZCeig1BrYE/hpnzgxcUS0BgYxsfwFVqbM8fusbmn/VzGKsIBPSsVirgxXAqC/Uha n197m3IUFbs8uhPJf2089xBvWgklT752zMtHuLf7VxFbevfimcfPnI0GwpPRF4pzNWuZ 7K5Mjso5B2W3k2gj2kxejA/VaTsc91sxh4sKWjUyuRPc8TRXJkNP4h2LvteE8vnORpfP 5c2g== X-Gm-Message-State: APzg51Ag23kNjmPEhiiHY5rwa/R7inoZG0lZ6rN3LDnGOiYiEJp48O+y dRWFzwrNniubAnOHOAW+466oKw== X-Google-Smtp-Source: ANB0VdZM6krSGz8RH/kH+1gUfmOAeFTH0wkMjarFUM05PdJvZpLCQMXKnTeXJLGVXF+gtr3vpJLcsw== X-Received: by 2002:a1c:ba84:: with SMTP id k126-v6mr1574878wmf.96.1537434757701; Thu, 20 Sep 2018 02:12:37 -0700 (PDT) Received: from localhost.localdomain.com (nat-pool-mxp-t.redhat.com. [149.6.153.186]) by smtp.gmail.com with ESMTPSA id 34-v6sm35501691wra.20.2018.09.20.02.12.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 20 Sep 2018 02:12:37 -0700 (PDT) From: Lorenzo Bianconi To: nbd@nbd.name Cc: linux-wireless@vger.kernel.org, sgruszka@redhat.com, linux-mediatek@lists.infradead.org Subject: [PATCH 13/20] mt76x0: unify temperature offset parsing Date: Thu, 20 Sep 2018 11:12:00 +0200 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: 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 Unify temperature offset parsing with mt76x2 driver using eeprom utility routines available in mt76x02-lib module Signed-off-by: Lorenzo Bianconi --- .../net/wireless/mediatek/mt76/mt76x0/debugfs.c | 3 ++- drivers/net/wireless/mediatek/mt76/mt76x0/eeprom.c | 14 +++++++------- drivers/net/wireless/mediatek/mt76/mt76x0/eeprom.h | 3 ++- drivers/net/wireless/mediatek/mt76/mt76x0/phy.c | 2 +- .../net/wireless/mediatek/mt76/mt76x02_eeprom.h | 1 + 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/debugfs.c b/drivers/net/wireless/mediatek/mt76/mt76x0/debugfs.c index b6f467e7ee8c..d138ed3bda17 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x0/debugfs.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/debugfs.c @@ -105,7 +105,8 @@ mt76x0_eeprom_param_read(struct seq_file *file, void *data) seq_printf(file, "RF freq offset: %hhx\n", dev->ee->rf_freq_off); seq_printf(file, "RSSI offset: %hhx %hhx\n", dev->caldata.rssi_offset[0], dev->caldata.rssi_offset[1]); - seq_printf(file, "Temperature offset: %hhx\n", dev->ee->temp_off); + seq_printf(file, "Temperature offset: %hhx\n", + dev->caldata.temp_offset); seq_printf(file, "LNA gain: %x\n", dev->caldata.lna_gain); val = mt76x02_eeprom_get(&dev->mt76, MT_EE_NIC_CONF_0); diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/eeprom.c b/drivers/net/wireless/mediatek/mt76/mt76x0/eeprom.c index 6c24274d23f4..ae7c11519b0a 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x0/eeprom.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/eeprom.c @@ -92,15 +92,15 @@ mt76x0_set_chip_cap(struct mt76x0_dev *dev, u8 *eeprom) "Error: device has more than 1 RX/TX stream!\n"); } -static void -mt76x0_set_temp_offset(struct mt76x0_dev *dev, u8 *eeprom) +static void mt76x0_set_temp_offset(struct mt76x0_dev *dev) { - u8 temp = eeprom[MT_EE_TEMP_OFFSET]; + u8 val; - if (mt76x02_field_valid(temp)) - dev->ee->temp_off = mt76x02_sign_extend(temp, 8); + val = mt76x02_eeprom_get(&dev->mt76, MT_EE_2G_TARGET_POWER) >> 8; + if (mt76x02_field_valid(val)) + dev->caldata.temp_offset = mt76x02_sign_extend(val, 8); else - dev->ee->temp_off = -10; + dev->caldata.temp_offset = -10; } static void @@ -287,7 +287,7 @@ mt76x0_eeprom_init(struct mt76x0_dev *dev) mt76x02_mac_setaddr(&dev->mt76, eeprom + MT_EE_MAC_ADDR); mt76x0_set_chip_cap(dev, eeprom); mt76x0_set_rf_freq_off(dev, eeprom); - mt76x0_set_temp_offset(dev, eeprom); + mt76x0_set_temp_offset(dev); dev->chainmask = 0x0101; mt76x0_set_tx_power_per_rate(dev, eeprom); diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/eeprom.h b/drivers/net/wireless/mediatek/mt76/mt76x0/eeprom.h index dd9cb0d2de41..55e624cf7f2a 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x0/eeprom.h +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/eeprom.h @@ -31,11 +31,12 @@ struct reg_channel_bounds { struct mt76x0_caldata { s8 rssi_offset[2]; s8 lna_gain; + + s16 temp_offset; }; struct mt76x0_eeprom_params { u8 rf_freq_off; - s16 temp_off; /* TX_PWR_CFG_* values from EEPROM for 20 and 40 Mhz bandwidths. */ u32 tx_pwr_cfg_2g[5][2]; diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c b/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c index 72d0ddc381b9..dbe9e2ee5def 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c @@ -836,7 +836,7 @@ static void mt76x0_temp_sensor(struct mt76x0_dev *dev) else sval |= 0xffffff00; /* Negative */ - temp = (35 * (sval - dev->ee->temp_off))/ 10 + 25; + temp = (35 * (sval - dev->caldata.temp_offset)) / 10 + 25; done: rf_wr(dev, MT_RF(7, 73), rf_b7_73); diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_eeprom.h b/drivers/net/wireless/mediatek/mt76/mt76x02_eeprom.h index c22ca507b418..2132af9f8c94 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x02_eeprom.h +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_eeprom.h @@ -72,6 +72,7 @@ enum mt76x02_eeprom_field { MT_EE_TX_POWER_VHT_MCS4 = 0x0bc, MT_EE_TX_POWER_VHT_MCS8 = 0x0be, + MT_EE_2G_TARGET_POWER = 0x0d0, MT_EE_TEMP_OFFSET = 0x0d1, MT_EE_FREQ_OFFSET_COMPENSATION = 0x0db, MT_EE_TX_POWER_BYRATE_BASE = 0x0de,