Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp745094pxb; Tue, 5 Apr 2022 21:27:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx1cQCfJOCXcx4kvOwi9n5JGg/NMnjHNriLhMh+HpP5t5l+H3/R90Vg8IARyqod+B6tvYb0 X-Received: by 2002:a17:902:c401:b0:154:3b8a:5e6e with SMTP id k1-20020a170902c40100b001543b8a5e6emr6706985plk.18.1649219247845; Tue, 05 Apr 2022 21:27:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649219247; cv=none; d=google.com; s=arc-20160816; b=P9CPwT5DiQPoYHUn+ZZjud1wdvrTHbMLwyvuHvxtxrnxAI/bfjD/mHiyZakv0NoMea MQdAHcuMj6Ng+n0IVZENIV1PxEWq6CA9b0OsY84hgJbepHJtIGM/CSQSYxY7Gn/qkCKd +eaLyCJkh8Cd2Ly6UzHiG5SWRRl+HGBU+oLKABrDnhtSP+IQY3Tc3E+ew+PNIlOIKj2w 5D0k6GgigcWHrjHiW6uVix4m8v0yBaZzSzYou44W6+9teqlQdpGKUz854el8gWye5H1N 5hs4pfxXy3aw0cFZcYtQTGehRjPC7oizAcm5qAZgJESch/+PujZoLhkXKDpAUQY4k6Ed CjLw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=WIvvp4dq0oEDyJKbS9X1benhf2texH0T1t+Zp0rjn6w=; b=u7GY1F7JUXCHegx1nEyu3G+MJBjuU6fBHsFor3sCWojGPPZtLdwHLiLwRVX+R5+79C YkpgdF5IdOC4F8IQopfpli0nlK+i1z996WfmGUy2HRfYVbFYvcU9XyFr+0lzLOwgMQxT eBep3wbQrKtwXa0D8dmkj+rYhiBp6k/1zP7H/1g5hQyTZUZOeu2zbvk+9rZPe5tXgisv STFEFELtBG9766L9/J9lYeiGoPQTDfnK/0rWPzzAHjM6KaDic6Ui8jrl0N6TrDUI6xog sop3R5rgmlqxWSULoYGQUPfhn/J9raWNcf9VnQxzNbsCb492WMWD9h3S8jNdMXPd4xAM Iwqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=aAgEL+VL; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id s17-20020a056a00179100b004fa3a8e005csi15980563pfg.275.2022.04.05.21.27.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Apr 2022 21:27:27 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=aAgEL+VL; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 67A22293E4A; Tue, 5 Apr 2022 19:47:37 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345155AbiDELAZ (ORCPT + 99 others); Tue, 5 Apr 2022 07:00:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58522 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234124AbiDEIjT (ORCPT ); Tue, 5 Apr 2022 04:39:19 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4DB2A1FA68; Tue, 5 Apr 2022 01:32:56 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id DE3C960FFC; Tue, 5 Apr 2022 08:32:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EFFD7C385A1; Tue, 5 Apr 2022 08:32:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649147575; bh=y4HzoPUx0g/Wg4u5UKwImFP7XoKjSKux0f3xg0dQGf0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aAgEL+VLvNLPk+0tFHVheKoyAYLh2Joc9mCIi7nm5w7nEC5PDlB5wReM2qZWTsoqL Zp7Tgdf3HvdCDYrb+KLJq0pIHstOFUC7gdtWy7+P31etuSbxDpfuaMWDCcD77TkT8c 9Ebo7s+T/3Fe3cJRdeX/erM+slxn2ncuAw5FYQw8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Konstantin Klubnichkin , Billy Tsai , Joel Stanley , Stable@vger.kernel.org, Jonathan Cameron Subject: [PATCH 5.16 0046/1017] iio: adc: aspeed: Add divider flag to fix incorrect voltage reading. Date: Tue, 5 Apr 2022 09:15:59 +0200 Message-Id: <20220405070355.549917210@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070354.155796697@linuxfoundation.org> References: <20220405070354.155796697@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 From: Billy Tsai commit 571426631acf46e2999c7ecd1e9d048172969a43 upstream. 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. This patch use the flag CLK_DIVIDER_ONE_BASED which will use the raw value read from the register, with the value of zero considered invalid to conform to the corrected formula. Fixes: 573803234e72 ("iio: Aspeed ADC") Reported-by: Konstantin Klubnichkin Signed-off-by: Billy Tsai Reviewed-by: Joel Stanley Link: https://lore.kernel.org/r/20220221012705.22008-1-billy_tsai@aspeedtech.com Cc: Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/iio/adc/aspeed_adc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/drivers/iio/adc/aspeed_adc.c +++ b/drivers/iio/adc/aspeed_adc.c @@ -539,7 +539,9 @@ static int aspeed_adc_probe(struct platf 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);