Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp1388936pxb; Fri, 18 Feb 2022 06:53:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJyJ4YyLcqJi7NkTeYfeGqKgKuXrvnsKkCzeNOv3ncxbRHCARcjbFeAjdov3CYa38dzJEr8C X-Received: by 2002:a05:6402:90d:b0:412:d3fe:8460 with SMTP id g13-20020a056402090d00b00412d3fe8460mr579742edz.316.1645196020557; Fri, 18 Feb 2022 06:53:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645196020; cv=none; d=google.com; s=arc-20160816; b=YFi4/Ffpt+8o/zHdFwr4Q/AEjG5Q8XrowBaETg3nVfA8wpT6Fpe/VfnFxcnFjtqjOk 10L97jzE8d9jvMMSxBFSeOj0uSExdIj9XyNNUT7BNkJ482RngX9nrsMa3CUeTOdoZmLc UkW/bX3q3CyEw/+JTt2AKutpQgbw7ILrGQnh+QY+Bk0yDyCSwJ9UE/npP11bwu5b4GTO m1KtpQp68Qv0lHkRx27aej6ioTzXYybMjpy3/tCn+2kzOthsQo//XMDQGzSYSKzg1Yyr OurXGl9fkWmycaHibhFPLdA8Yt12eTBAOSrs7fOkg9hmoaEbLSWvhjLENfKuBP0Lkbid KTcg== 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:cc:to:from; bh=Pla+nbgKCjOFT35iIXOUkcqUOUIN5+r4y2Z6vi0zTK8=; b=B2zsSVAxYWx2XdcYuSN2+XMOqWuokzeidgskl9yFUOzgh9Pw63u9a19dsfXGA76zFi +waFnqhQM/j+biZe7f3OQcwBP4611b9HA0PCvxPr45b4O/Mybmw/lSal5FZZMdOV5mHW kBk/7xb3NfLoPsvvGcFUJjKmg6JcCY2fidDp6ZiZCcy8vqebC5DjCRgLz+C67HJFiQzR TLZhY4fuKwkXzrPZqMh9X0Q3dBLeHa830jjd3SjCMPiNcVmRAAdhkAzG08AN6vC9XxGc 8u+WeUPY3/m5ARp0cgE8Fyujjat146/fxv/FXnmENSAMGfWLiMrVmEjnJoABJrOyBfOD I2fA== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i22si4758063ejw.570.2022.02.18.06.53.16; Fri, 18 Feb 2022 06:53:40 -0800 (PST) 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 S233122AbiBRJGC (ORCPT + 99 others); Fri, 18 Feb 2022 04:06:02 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:46694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233247AbiBRJF6 (ORCPT ); Fri, 18 Feb 2022 04:05:58 -0500 X-Greylist: delayed 457 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Fri, 18 Feb 2022 01:05:40 PST Received: from twspam01.aspeedtech.com (twspam01.aspeedtech.com [211.20.114.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57A2F2B3AE7; Fri, 18 Feb 2022 01:05:39 -0800 (PST) Received: from twspam01.aspeedtech.com (localhost [127.0.0.2] (may be forged)) by twspam01.aspeedtech.com with ESMTP id 21I8nNN3034493; Fri, 18 Feb 2022 16:49:23 +0800 (GMT-8) (envelope-from billy_tsai@aspeedtech.com) Received: from mail.aspeedtech.com ([192.168.0.24]) by twspam01.aspeedtech.com with ESMTP id 21I8lrmY034381; Fri, 18 Feb 2022 16:47:53 +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; Fri, 18 Feb 2022 16:56:33 +0800 From: Billy Tsai To: , , , , , , , , , CC: Konstantin Klubnichkin Subject: [PATCH] iio: adc: aspeed: Add divider flag to fix incorrect voltage reading. Date: Fri, 18 Feb 2022 16:57:08 +0800 Message-ID: <20220218085708.8194-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 21I8lrmY034381 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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: X-Mailing-List: linux-kernel@vger.kernel.org The formula for the ADC sampling period in ast2400/ast2500 is: ADC clock period = PCLK * 2 * (ADC0C[31:17] + 1) * (ADC0C[9:0]) When ADC0C[9:0] is set to 0 the sampling voltage will be lower than expected, because the hardware may not have enough time to charge/discharge to a stable voltage. Reported-by: Konstantin Klubnichkin Signed-off-by: Billy Tsai --- drivers/iio/adc/aspeed_adc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/iio/adc/aspeed_adc.c b/drivers/iio/adc/aspeed_adc.c index a957cad1bfab..ffae64f39221 100644 --- a/drivers/iio/adc/aspeed_adc.c +++ b/drivers/iio/adc/aspeed_adc.c @@ -539,7 +539,9 @@ static int aspeed_adc_probe(struct platform_device *pdev) data->clk_scaler = devm_clk_hw_register_divider( &pdev->dev, clk_name, clk_parent_name, scaler_flags, data->base + ASPEED_REG_CLOCK_CONTROL, 0, - data->model_data->scaler_bit_width, 0, &data->clk_lock); + data->model_data->scaler_bit_width, + data->model_data->need_prescaler ? CLK_DIVIDER_ONE_BASED : 0, + &data->clk_lock); if (IS_ERR(data->clk_scaler)) return PTR_ERR(data->clk_scaler); -- 2.25.1