Message ID | 20221031113208.19194-1-billy_tsai@aspeedtech.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2260224wru; Mon, 31 Oct 2022 04:41:44 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4UnD6oS5t1b39/Uhf9hXm++aNIs4cVaWiStr1DGaHDI8Fqdb0GzSz1w/mew3yNX9gyfcUC X-Received: by 2002:a05:6402:517c:b0:461:e7e7:c0b9 with SMTP id d28-20020a056402517c00b00461e7e7c0b9mr12685072ede.73.1667216504008; Mon, 31 Oct 2022 04:41:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667216504; cv=none; d=google.com; s=arc-20160816; b=gwfBeptBMgfO0ZJph3G1Z1+uM7wD60GOYwnEDP4VlTir/ReN6kuWP1opvcPzccBnUF HPPeOOvBKixk4KfDZ8EkkxtAHEaUzcwhGzM1zwvPi0rSBatl5prkp37HO9VLK3NEXUwM w5NiKHAnwfPl0jPUA3j3wLALlIvSsb6KP7iNdvZVhKF+GRBybdmYIDqALEfzhD0cw15z lctHJkwDvfQI2ltDs8Wvqbu/ukBPngTU4XN++2IskhH4S3tpN2QE6W7RTcp2eu9JHMY+ YpTGplriS3W+RGZ3S8aXEuMGvLL7HGcKEPEPXstV1cIZK5SNAwW6l1HVSjei8yP6NlBe axew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:to:from; bh=WhkvwDY8l+K2R8SVWQEMlCb5Ppu2j2EDEEjR8vUOliI=; b=r/KSQxlE7qr7wfm5xjnAkxWem9z0qgggQ+XRw0gjxZDrK4IlzdXVUMdEuV3piJcHlp UiUDLbKowEC5GdiNRM80q3HWgy7Yk2hAGzbdHSYqtxX5huVtCO2ugs8XREZtHqV0o7wY D88cZvKzeWZGsWDpQPImMu13Hm6b0E9gS860Hd9sFUPtCNgYT1glm4UlUFc7Wumx+MmP 2ich3qzZ4chHRM4RUZ44//Zy7+UfTIAGG6vPsrqkMe7VsHq5clwsX8VCxYjXF+27J31/ r9bdMGdkD5bJP5ndU2WoKrZGDUKarM/yi1OTQaS9BAUKTARqS2xQYH6rsh9rtIAAwurL cXEQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m14-20020a056402430e00b0046335076fdfsi466665edc.341.2022.10.31.04.41.17; Mon, 31 Oct 2022 04:41:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230266AbiJaLch (ORCPT <rfc822;kartikey406@gmail.com> + 99 others); Mon, 31 Oct 2022 07:32:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229918AbiJaLcf (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 31 Oct 2022 07:32:35 -0400 Received: from twspam01.aspeedtech.com (twspam01.aspeedtech.com [211.20.114.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE205DFBE; Mon, 31 Oct 2022 04:32:34 -0700 (PDT) Received: from mail.aspeedtech.com ([192.168.0.24]) by twspam01.aspeedtech.com with ESMTP id 29VB7WjM080106; Mon, 31 Oct 2022 19:07:32 +0800 (GMT-8) (envelope-from billy_tsai@aspeedtech.com) Received: from BillyTsai-pc.aspeed.com (192.168.2.149) by TWMBX02.aspeed.com (192.168.0.24) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 31 Oct 2022 19:30:39 +0800 From: Billy Tsai <billy_tsai@aspeedtech.com> To: <jic23@kernel.org>, <lars@metafoo.de>, <robh+dt@kernel.org>, <joel@jms.id.au>, <andrew@aj.id.au>, <billy_tsai@aspeedtech.com>, <colin.king@canonical.com>, <linux-iio@vger.kernel.org>, <devicetree@vger.kernel.org>, <linux-arm-kernel@lists.infradead.org>, <linux-aspeed@lists.ozlabs.org>, <linux-kernel@vger.kernel.org>, <BMC-SW@aspeedtech.com> Subject: [PATCH 1/2] iio: adc: aspeed: Remove the trim valid dts property. Date: Mon, 31 Oct 2022 19:32:07 +0800 Message-ID: <20221031113208.19194-1-billy_tsai@aspeedtech.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [192.168.2.149] X-ClientProxiedBy: TWMBX02.aspeed.com (192.168.0.24) To TWMBX02.aspeed.com (192.168.0.24) X-DNSRBL: X-MAIL: twspam01.aspeedtech.com 29VB7WjM080106 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748203213104513607?= X-GMAIL-MSGID: =?utf-8?q?1748203213104513607?= |
Series |
[1/2] iio: adc: aspeed: Remove the trim valid dts property.
|
|
Commit Message
Billy Tsai
Oct. 31, 2022, 11:32 a.m. UTC
The dts property "aspeed,trim-data-valid" is used to determin whether to
read the OTP register. If the image with the aspeed,trim-data-vali
install to the chip without valid trimming data the adc controller will
become confused. This patch use the default otp value 0 as a criterion
for determining whether trimming data is valid instead of the dts
property. The chip with actually trimming value is 0 should be filter out.
Signed-off-by: Billy Tsai <billy_tsai@aspeedtech.com>
---
drivers/iio/adc/aspeed_adc.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
Comments
On Mon, 31 Oct 2022 19:32:07 +0800 Billy Tsai <billy_tsai@aspeedtech.com> wrote: > The dts property "aspeed,trim-data-valid" is used to determin whether to > read the OTP register. If the image with the aspeed,trim-data-vali > install to the chip without valid trimming data the adc controller will > become confused. This patch use the default otp value 0 as a criterion > for determining whether trimming data is valid instead of the dts > property. The chip with actually trimming value is 0 should be filter out. Hi Billy, I'm not sure I correctly follow the patch description. Would the following be an accurate description? The dts property "aspeed,trim-data-valid" is currently used to determine whether to read trimming data from the OTP register. If this is set on a device without valid trimming data in the OTP the ADC will not function correctly. This patch drops he use of this property and instead uses the default (unprogrammed) OTP value of 0 to detect when a fallback value of 0x8 should be used rather then the value read from the OTP. Also, is this a bug fix we need to backport? If so please provide a fixes tag. Thanks, Jonathan > > Signed-off-by: Billy Tsai <billy_tsai@aspeedtech.com> > --- > drivers/iio/adc/aspeed_adc.c | 11 +++++------ > 1 file changed, 5 insertions(+), 6 deletions(-) > > diff --git a/drivers/iio/adc/aspeed_adc.c b/drivers/iio/adc/aspeed_adc.c > index ffae64f39221..0f065f0bb8e7 100644 > --- a/drivers/iio/adc/aspeed_adc.c > +++ b/drivers/iio/adc/aspeed_adc.c > @@ -201,6 +201,8 @@ static int aspeed_adc_set_trim_data(struct iio_dev *indio_dev) > ((scu_otp) & > (data->model_data->trim_locate->field)) >> > __ffs(data->model_data->trim_locate->field); > + if (!trimming_val) > + trimming_val = 0x8; > } > dev_dbg(data->dev, > "trimming val = %d, offset = %08x, fields = %08x\n", > @@ -562,12 +564,9 @@ static int aspeed_adc_probe(struct platform_device *pdev) > if (ret) > return ret; > > - if (of_find_property(data->dev->of_node, "aspeed,trim-data-valid", > - NULL)) { > - ret = aspeed_adc_set_trim_data(indio_dev); > - if (ret) > - return ret; > - } > + ret = aspeed_adc_set_trim_data(indio_dev); > + if (ret) > + return ret; > > if (of_find_property(data->dev->of_node, "aspeed,battery-sensing", > NULL)) {
On 2022/11/6, 10:50 PM, "Jonathan Cameron" <jic23@kernel.org> wrote: On Mon, 31 Oct 2022 19:32:07 +0800 Billy Tsai <billy_tsai@aspeedtech.com> wrote: > > The dts property "aspeed,trim-data-valid" is used to determin whether to > > read the OTP register. If the image with the aspeed,trim-data-vali > > install to the chip without valid trimming data the adc controller will > > become confused. This patch use the default otp value 0 as a criterion > > for determining whether trimming data is valid instead of the dts > > property. The chip with actually trimming value is 0 should be filter out. > Hi Billy, > I'm not sure I correctly follow the patch description. Would the following > be an accurate description? > The dts property "aspeed,trim-data-valid" is currently used to determine > whether to read trimming data from the OTP register. If this is set on > a device without valid trimming data in the OTP the ADC will not function > correctly. This patch drops he use of this property and instead uses the > default (unprogrammed) OTP value of 0 to detect when a fallback value of > 0x8 should be used rather then the value read from the OTP. Hi Jonathan, Yes, it's correct. > Also, is this a bug fix we need to backport? If so please provide a fixes > tag. I will provide the fixes tag in next version of patch. Thanks Best Regards, Billy Tsai
diff --git a/drivers/iio/adc/aspeed_adc.c b/drivers/iio/adc/aspeed_adc.c index ffae64f39221..0f065f0bb8e7 100644 --- a/drivers/iio/adc/aspeed_adc.c +++ b/drivers/iio/adc/aspeed_adc.c @@ -201,6 +201,8 @@ static int aspeed_adc_set_trim_data(struct iio_dev *indio_dev) ((scu_otp) & (data->model_data->trim_locate->field)) >> __ffs(data->model_data->trim_locate->field); + if (!trimming_val) + trimming_val = 0x8; } dev_dbg(data->dev, "trimming val = %d, offset = %08x, fields = %08x\n", @@ -562,12 +564,9 @@ static int aspeed_adc_probe(struct platform_device *pdev) if (ret) return ret; - if (of_find_property(data->dev->of_node, "aspeed,trim-data-valid", - NULL)) { - ret = aspeed_adc_set_trim_data(indio_dev); - if (ret) - return ret; - } + ret = aspeed_adc_set_trim_data(indio_dev); + if (ret) + return ret; if (of_find_property(data->dev->of_node, "aspeed,battery-sensing", NULL)) {