Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1244525ybl; Wed, 21 Aug 2019 12:16:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqx3AJ+zHeZsS42hB8qMt5XUiesQ8YqU4QVhgWiAeD0Qv4eYIpZRsKJAL6bCexH+gKSE/DAm X-Received: by 2002:a17:902:d917:: with SMTP id c23mr35437316plz.248.1566414966355; Wed, 21 Aug 2019 12:16:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566414966; cv=none; d=google.com; s=arc-20160816; b=IHNSEmP7/LAut07kDLoxHYT2b6+VJKyVtNL7tzemsnUuxO0vnr3B/Tctd55z63RJLE 9If3vun539zttkXNERhaivN/vyjgVfNT+hEIf+QC3sDr+LYQDr4PM7u9kY2VAoExW+UP y9GukzOVVsfCNn5T0R160AmNwbaVrDsDW7cnwz6Br4hDV1gMMh5cnZe0yQ5xS1rMH/09 HIrBv+s/HNP8LZjaXSsAy0JsEtIUpcY2z4fPPjcuam0U4RfykhQbW0fO3foPKWF3UJTY n5JL+by3wMqWrnkqT1/YLnqs71PHdc2LMTpWcBKg7zpjvKvmFWYwhrmQrGNVCmtir/iB 64CA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:to:from :dkim-signature; bh=TWWXZiaLLh61AqE6SYqCDUJTsdFYOBVH5suvDm8J1cQ=; b=yK2VAHITwQDssMBkNIMZ1wI0hJOUMZJDocaWp0v6fMEjlePHY9gESTzs54K9MfHrK8 WPSQf/UZztMnxoXDnKcfGxAoJsc20fp47eV0WTw4p1LT32pfFHuDWnXpLr5mb32zav/Y mEWZo/WAFm6MEfwlAIUwSK06AJ6pQdGhBZtRMoBq4+zG+hazNAnGXzwoI5t9K22pbmOX 8yhodikDUBaLSAuYwykYHgSnbTX3gerxMDOjDhbgzSNJFdq6GynXJiSm6r2kjvVq/1EZ nqYCY1GnwjKvTrYvphD2+KfR6DTq4tfraCR1mGWVbw96+MOVSCpHwM0gF9gs0BI3fwlN Fisg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=HdPVQew2; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s21si15041961pgg.168.2019.08.21.12.15.40; Wed, 21 Aug 2019 12:16:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=HdPVQew2; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727998AbfHUTOs (ORCPT + 99 others); Wed, 21 Aug 2019 15:14:48 -0400 Received: from nbd.name ([46.4.11.11]:39506 "EHLO nbd.name" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726741AbfHUTOr (ORCPT ); Wed, 21 Aug 2019 15:14:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nbd.name; s=20160729; h=Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc: MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=TWWXZiaLLh61AqE6SYqCDUJTsdFYOBVH5suvDm8J1cQ=; b=HdPVQew22vAVj4iqe9k5m82y9q O4y/z5g+JvofNJYnHwIHZyH63tqYjbvoXDbKNalqOM7AjUHGvW0Pbe0VVAtuE5vhsdYbyo0suONW7 NGY/IlNghgntHYMES2F97u7iie85Wzc0nTd/nwIhWCacT2vOS1Ef2iZfJN6DIH+FWwUM=; Received: from p54ae9443.dip0.t-ipconnect.de ([84.174.148.67] helo=maeck.local) by ds12 with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1i0W4D-0002e2-0K for linux-wireless@vger.kernel.org; Wed, 21 Aug 2019 21:14:46 +0200 Received: by maeck.local (Postfix, from userid 501) id A0A7863FB68B; Wed, 21 Aug 2019 21:14:43 +0200 (CEST) From: Felix Fietkau To: linux-wireless@vger.kernel.org Subject: [PATCH] mt76: mt7615: apply calibration-free data from OTP Date: Wed, 21 Aug 2019 21:14:43 +0200 Message-Id: <20190821191443.36764-1-nbd@nbd.name> X-Mailer: git-send-email 2.17.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org MT7615 chips usually come pre-calibrated, even when used on embedded boards. In that case, the on-flash EEPROM data needs to be merged with some data from OTP ROM. Run this merge if the external EEPROM data is valid and OTP has valid fields. Signed-off-by: Felix Fietkau --- .../wireless/mediatek/mt76/mt7615/eeprom.c | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/eeprom.c b/drivers/net/wireless/mediatek/mt76/mt7615/eeprom.c index dc94f52e6e8b..515bb58e19fd 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/eeprom.c +++ b/drivers/net/wireless/mediatek/mt76/mt7615/eeprom.c @@ -154,6 +154,42 @@ int mt7615_eeprom_get_power_index(struct mt7615_dev *dev, return index; } +static void mt7615_apply_cal_free_data(struct mt7615_dev *dev) +{ + static const u16 ical[] = { + 0x53, 0x54, 0x55, 0x56, 0x57, 0x5c, 0x5d, 0x62, 0x63, 0x68, + 0x69, 0x6e, 0x6f, 0x73, 0x74, 0x78, 0x79, 0x82, 0x83, 0x87, + 0x88, 0x8c, 0x8d, 0x91, 0x92, 0x96, 0x97, 0x9b, 0x9c, 0xa0, + 0xa1, 0xaa, 0xab, 0xaf, 0xb0, 0xb4, 0xb5, 0xb9, 0xba, 0xf4, + 0xf7, 0xff, + 0x140, 0x141, 0x145, 0x146, 0x14a, 0x14b, 0x154, 0x155, 0x159, + 0x15a, 0x15e, 0x15f, 0x163, 0x164, 0x168, 0x169, 0x16d, 0x16e, + 0x172, 0x173, 0x17c, 0x17d, 0x181, 0x182, 0x186, 0x187, 0x18b, + 0x18c + }; + static const u16 ical_nocheck[] = { + 0x110, 0x111, 0x112, 0x113, 0x114, 0x115, 0x116, 0x117, 0x118, + 0x1b5, 0x1b6, 0x1b7, 0x3ac, 0x3ad, 0x3ae, 0x3af, 0x3b0, 0x3b1, + 0x3b2 + }; + u8 *eeprom = dev->mt76.eeprom.data; + u8 *otp = dev->mt76.otp.data; + int i; + + if (!otp) + return; + + for (i = 0; i < ARRAY_SIZE(ical); i++) + if (!otp[ical[i]]) + return; + + for (i = 0; i < ARRAY_SIZE(ical); i++) + eeprom[ical[i]] = otp[ical[i]]; + + for (i = 0; i < ARRAY_SIZE(ical_nocheck); i++) + eeprom[ical_nocheck[i]] = otp[ical_nocheck[i]]; +} + int mt7615_eeprom_init(struct mt7615_dev *dev) { int ret; @@ -166,6 +202,8 @@ int mt7615_eeprom_init(struct mt7615_dev *dev) if (ret && dev->mt76.otp.data) memcpy(dev->mt76.eeprom.data, dev->mt76.otp.data, MT7615_EEPROM_SIZE); + else + mt7615_apply_cal_free_data(dev); mt7615_eeprom_parse_hw_cap(dev); memcpy(dev->mt76.macaddr, dev->mt76.eeprom.data + MT_EE_MAC_ADDR, -- 2.17.0