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: 10607261 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 8D74114BD for ; Thu, 20 Sep 2018 09:34:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 772BB2CDCB for ; Thu, 20 Sep 2018 09:34:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6B9E42CECD; Thu, 20 Sep 2018 09:34:45 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EEA762CDCB for ; Thu, 20 Sep 2018 09:34:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=gD6xggOTzuZQ6ZxcKu/OTE2fCmP3ktVoTci9fFXbdLE=; b=CLfDXShSgjqMz132hUMZbP1Uit TOnkw7CDr4U2w6eqzBOQp9HIxPeomVMPR2huJFhXkbzQB2y2ErfzEafdj45ybPMXbySUn8Vy/GmHP WghBq9Bi04HOPU8TeQ94Yw2bB9o8kO5B5zNwa3Pu85rORa2QvLecknLForCzfMbyXipuDArimfl0m mnDtw7qVjU4L2EUD5dFK8A2EwTRDLjX0DqCYtJzVWtioDX2QTu1xPGx/IjlceDFUFM/KVFDNl7CjP nCJhluoUBNNbZCaRtXYxdowelyr6L6F5LesZyysBJNcbCE41dOvDrvf8/bM9yzIU8PYu1YOz6eAH9 bvdPUokQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1g2vM8-0004EY-Ae; Thu, 20 Sep 2018 09:34:40 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g2vEA-0007yC-5T for linux-mediatek@bombadil.infradead.org; Thu, 20 Sep 2018 09:26:26 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=FxNonfTywGDrcfsW9iBpQWuscO0kRWyqjgRrKkmDuKc=; b=X8AtBYn3409q+RYTIGm6nNQ4b i3KE8e1F86Ms/yQ6J9gQokbJLVa2lYJKx0zagXEWLLMIfFwoINC3VCb4rx1uyo2S4ECm7zwlCpPPV OTVhJ04tAmTbkvebD43wlKTHjKmcuEogr9uAGMs0tifZI/uVvqwMNt+LXPsX2kjj8D4SYsKYGQgrg NNkPNRUYvHczf7E3mjSCGIg4QGA0H5MGlfsSiqG4agFPLtjmY0MvRJ1n6zPKQsG8lMF8+R6NaqKF4 f5+YElsCm6hJcKYmzS6sBVIuIo+azY5p76YKJautbYXjdcxWQw7IA2b8qTy16nyf0+02IVZhMftLH xl/VSXqYg==; Received: from mail-wm1-f67.google.com ([209.85.128.67]) by merlin.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g2v0x-0000We-Qz for linux-mediatek@lists.infradead.org; Thu, 20 Sep 2018 09:12:48 +0000 Received: by mail-wm1-f67.google.com with SMTP id q8-v6so10069494wmq.4 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=T0P3cuNkQfxwjFbDtUv71PsT9RZjb6/IggWQLg6yTlcu4fkAVu+mFN/BitY7Idcc1Z MyHumAFZwPCR9Zw1ox5l7fYmPoVDjzuoveg5h85DNGh09u5qHAMrUDMLeoSzILi5Rba1 aGZLo6ktfqMkTV5tPwBYs69FHTv/YaF0v04HrY3sq6T0/QMP9K3+D1k8s5t2GUwiXUeG uZvqA2vXLBYmJykZuPPECPt17eV9VS9MiNj1im9umQ1GuXBwcICpLzdglTjkI6Zp+SM8 Tdj4RYqumlIKAGAZfUkhGadbHB0wPjuXI0vHgTudwMmtaV0AitGglWZMPqhD6JkQ6Hlh VMbg== X-Gm-Message-State: APzg51DvXRnVkJwb4yhu5QwRf4JTQiK3e4sx7Z+BTbjo+ThUzskgq03l DA8Mbe/lv6SPSKFidZXTGWe/Qw== 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 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: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180920_051247_942065_473532CB X-CRM114-Status: GOOD ( 12.18 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: sgruszka@redhat.com, linux-mediatek@lists.infradead.org, linux-wireless@vger.kernel.org MIME-Version: 1.0 Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.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,