Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp817297ybl; Thu, 22 Aug 2019 05:27:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqwMRo9NtvuP+Ry8gDi0MMxTxDwPDb03cmwxZCSptHLpO93fXuE8y1UXRUIxo6pZLA08+HCh X-Received: by 2002:a17:90b:911:: with SMTP id bo17mr5000571pjb.40.1566476850335; Thu, 22 Aug 2019 05:27:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566476850; cv=none; d=google.com; s=arc-20160816; b=t0WOT6jZjX/GT9uTepFmcUa1cM8R08A5x4fqqScoTdV2kny5s1Z/ihG9DV9MBw35G6 j+T4sXfX/6rkiB8Q8Ho08aHa4OCOwjAXy44hn/QbQcn2sPZU2w3O8SyAyvollR8TpyNR gdAVlYNP6I2m95CxEG31ALgyPFJVwRD7OnE91mnv3JgCr8U7HM93TNqZm/PixpmCdkG0 LHLw+J2Z7oO968KFXW9FZ6V1ZRr6JKVC0oZjKMgqQIp8RIC5XMZqZJF+PdC3kJJIMecv gsJ7qg8wFAnXNLdttbKzUuzTYtShSNRtnmtBxfrN8XpniWSdILMjJTMP25ubB06CGDaK zFCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=b2E71/oOmpEHvUWHaE6me8EU5C8/Xac9yEJeFHOfIAE=; b=M0S9OHNXiG8coacyv973G5DusmKhYwEae+D1yzTiI5drsFjfex2Z0/QqJlKP4yEcsk Cj03eRRkVadocDdLavEkh5JHT79r9ub5QMLWxLXikDkhdtGeT44wuowEtKFeUAelgVhX 4sp7opwIAyGGChVSW4u75Mg3RTObc/Vu9zBdANhEEOitaqb6YDAc5Pv2bvilOYB6xWes xXsUrf2cLo3XzAikwHMBzPqpwTAb2t+3Jss8vqxtn/tsUQBuTSeEUjS91ccb6yKXHiDy vsQcbHuzsU67YdyyfVRFb9nWEz++3zheNSg2JhfFvaE2qZCiwo/B7C6LrC7l56eiwLZV PVww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gGUr2xCU; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b6si18379262pfa.76.2019.08.22.05.27.15; Thu, 22 Aug 2019 05:27:30 -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=pass header.i=@kernel.org header.s=default header.b=gGUr2xCU; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729854AbfHVKCm (ORCPT + 99 others); Thu, 22 Aug 2019 06:02:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:54030 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729321AbfHVKCm (ORCPT ); Thu, 22 Aug 2019 06:02:42 -0400 Received: from localhost.localdomain (nat-pool-mxp-t.redhat.com [149.6.153.186]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 05B2F205C9; Thu, 22 Aug 2019 10:02:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1566468160; bh=bpAle+yqyoDF2QC+HgJHvIWAHCDrhP8MPIO2TGu3K8Y=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=gGUr2xCUDyZUyOmEh63XgKU6auhi8Yn+sRm3T5wWYmmEUkAjOe81kKX2WK3q+ALfA y4z9DLnwFjAY7+lfGGeKTjj8qsXYXygPRb/UDY7Y1cB2efQyhWOD/uYGWSS6Zx9stt WxzJm2EbEBTh4NipYMd4bGijiouM/0Uu8mUBAIIs= Date: Thu, 22 Aug 2019 12:02:36 +0200 From: Lorenzo Bianconi To: Felix Fietkau Cc: linux-wireless@vger.kernel.org Subject: Re: [PATCH] mt76: mt7615: apply calibration-free data from OTP Message-ID: <20190822100236.GB3350@localhost.localdomain> References: <20190821191443.36764-1-nbd@nbd.name> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="dTy3Mrz/UPE2dbVg" Content-Disposition: inline In-Reply-To: <20190821191443.36764-1-nbd@nbd.name> User-Agent: Mutt/1.12.1 (2019-06-15) Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org --dTy3Mrz/UPE2dbVg Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable > MT7615 chips usually come pre-calibrated, even when used on embedded boar= ds. > 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 fie= lds. >=20 Tested-by: Lorenzo Bianconi > Signed-off-by: Felix Fietkau > --- > .../wireless/mediatek/mt76/mt7615/eeprom.c | 38 +++++++++++++++++++ > 1 file changed, 38 insertions(+) >=20 > 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; > } > =20 > +static void mt7615_apply_cal_free_data(struct mt7615_dev *dev) > +{ > + static const u16 ical[] =3D { > + 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[] =3D { > + 0x110, 0x111, 0x112, 0x113, 0x114, 0x115, 0x116, 0x117, 0x118, > + 0x1b5, 0x1b6, 0x1b7, 0x3ac, 0x3ad, 0x3ae, 0x3af, 0x3b0, 0x3b1, > + 0x3b2 > + }; > + u8 *eeprom =3D dev->mt76.eeprom.data; > + u8 *otp =3D dev->mt76.otp.data; > + int i; > + > + if (!otp) > + return; > + > + for (i =3D 0; i < ARRAY_SIZE(ical); i++) > + if (!otp[ical[i]]) > + return; > + > + for (i =3D 0; i < ARRAY_SIZE(ical); i++) > + eeprom[ical[i]] =3D otp[ical[i]]; > + > + for (i =3D 0; i < ARRAY_SIZE(ical_nocheck); i++) > + eeprom[ical_nocheck[i]] =3D 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); > =20 > mt7615_eeprom_parse_hw_cap(dev); > memcpy(dev->mt76.macaddr, dev->mt76.eeprom.data + MT_EE_MAC_ADDR, > --=20 > 2.17.0 >=20 --dTy3Mrz/UPE2dbVg Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQTquNwa3Txd3rGGn7Y6cBh0uS2trAUCXV5oOQAKCRA6cBh0uS2t rGWeAP9spRwBTXlt6UfgbXkTDNrSthUgdem7Ov5m9yfEosYlBQEAvhXPfPSJf6QU hOyf4phmCTC+N16n6F8ogzP00OBAAQU= =M5Fz -----END PGP SIGNATURE----- --dTy3Mrz/UPE2dbVg--