From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2C21FC433EF for ; Sat, 18 Sep 2021 17:55:30 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DC6886101B for ; Sat, 18 Sep 2021 17:55:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org DC6886101B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=El7jepcxNoS5qhkTqvqfTYZkk5KDYDtRCG+D7RQWQCY=; b=J4RnRSHAeTjdi4 DSJ8iGWXwPL8lUCMszXh6ICEQ87cu5iKu1XEFVFzsqQwJ8Dd3A1ezGlhvkYKqE1WJPuHfkPz98Uxi kz/lOvkw0dJAeFTSbfGS6zcGi2QzrJ1NdOVZm8afpfY1xPJHJQSoywphEBzLFkpVUkKU3rhsJqxEd qbBfCB7eNSfI32bCMX4c9thznMUr94BxyO7RN1Bb7wk9E9QQuiLyEPcf1r8hi8fTu11rbznKLyfhk lQeQAEHAlZ6zik/1G5uu0M1yseD289fSOSB0qR4ccwbr9TdqrbAgzid25wySvAswLVJyvwakGX1xi 1MTsldoqAi6QDALpGoyg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mReWx-00GBXi-DS; Sat, 18 Sep 2021 17:53:39 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mReWt-00GBWm-70 for linux-arm-kernel@lists.infradead.org; Sat, 18 Sep 2021 17:53:36 +0000 Received: from jic23-huawei (cpc108967-cmbg20-2-0-cust86.5-4.cable.virginm.net [81.101.6.87]) (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 2C0D76101B; Sat, 18 Sep 2021 17:53:30 +0000 (UTC) Date: Sat, 18 Sep 2021 18:57:10 +0100 From: Jonathan Cameron To: Billy Tsai Cc: "lars@metafoo.de" , "pmeerw@pmeerw.net" , "robh+dt@kernel.org" , "joel@jms.id.au" , "andrew@aj.id.au" , "p.zabel@pengutronix.de" , "lgirdwood@gmail.com" , "broonie@kernel.org" , "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 Subject: Re: [v6 07/11] iio: adc: aspeed: Fix the calculate error of clock. Message-ID: <20210918185710.52725301@jic23-huawei> In-Reply-To: <1A7A8472-1AAA-4F51-A9CF-08BF1837F9EB@aspeedtech.com> References: <20210913075337.19991-1-billy_tsai@aspeedtech.com> <20210913075337.19991-8-billy_tsai@aspeedtech.com> <1A7A8472-1AAA-4F51-A9CF-08BF1837F9EB@aspeedtech.com> X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.30; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210918_105335_346251_63A5F643 X-CRM114-Status: GOOD ( 27.65 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, 17 Sep 2021 01:12:13 +0000 Billy Tsai wrote: > On 2021/9/13, 3:51 PM, "Billy Tsai" wrote: > > > The ADC clock formula is > > ast2400/2500: > > ADC clock period = PCLK * 2 * (ADC0C[31:17] + 1) * (ADC0C[9:0] + 1) > > ast2600: > > ADC clock period = PCLK * 2 * (ADC0C[15:0] + 1) > > They all have one fixed divided 2 and the legacy driver didn't handle it. > > This patch register the fixed factory clock device as the parent of ADC > > clock scaler to fix this issue. > > > Signed-off-by: Billy Tsai > > --- > > drivers/iio/adc/aspeed_adc.c | 27 +++++++++++++++++++++++++++ > > 1 file changed, 27 insertions(+) > > > diff --git a/drivers/iio/adc/aspeed_adc.c b/drivers/iio/adc/aspeed_adc.c > > index 3ec4e1a2ddd3..262b5f80c728 100644 > > --- a/drivers/iio/adc/aspeed_adc.c > > +++ b/drivers/iio/adc/aspeed_adc.c > > @@ -4,6 +4,12 @@ > > * > > * Copyright (C) 2017 Google, Inc. > > * Copyright (C) 2021 Aspeed Technology Inc. > > + * > > + * ADC clock formula: > > + * Ast2400/Ast2500: > > + * clock period = period of PCLK * 2 * (ADC0C[31:17] + 1) * (ADC0C[9:0] + 1) > > + * Ast2600: > > + * clock period = period of PCLK * 2 * (ADC0C[15:0] + 1) > > */ > > > #include > > @@ -85,6 +91,7 @@ struct aspeed_adc_data { > > struct regulator *regulator; > > void __iomem *base; > > spinlock_t clk_lock; > > + struct clk_hw *fixed_div_clk; > > struct clk_hw *clk_prescaler; > > struct clk_hw *clk_scaler; > > struct reset_control *rst; > > @@ -197,6 +204,13 @@ static const struct iio_info aspeed_adc_iio_info = { > > .debugfs_reg_access = aspeed_adc_reg_access, > > }; > > > +static void aspeed_adc_unregister_fixed_divider(void *data) > > +{ > > + struct clk_hw *clk = data; > > + > > + clk_hw_unregister_fixed_factor(clk); > > +} > > + > > static void aspeed_adc_reset_assert(void *data) > > { > > struct reset_control *rst = data; > > @@ -321,6 +335,19 @@ static int aspeed_adc_probe(struct platform_device *pdev) > > spin_lock_init(&data->clk_lock); > > snprintf(clk_parent_name, ARRAY_SIZE(clk_parent_name), "%s", > > of_clk_get_parent_name(pdev->dev.of_node, 0)); > > + snprintf(clk_name, ARRAY_SIZE(clk_name), "%s-fixed-div", > > + data->model_data->model_name); > > + data->fixed_div_clk = clk_hw_register_fixed_factor( > > + &pdev->dev, clk_name, clk_parent_name, 0, 1, 2); > > + if (IS_ERR(data->fixed_div_clk)) > > + return PTR_ERR(data->fixed_div_clk); > > + > > + ret = devm_add_action_or_reset(data->dev, > > + aspeed_adc_unregister_fixed_divider, > > + data->clk_prescaler); > > I found that the parameter aspeed_adc_unregister_fixed_divider is wrong. > I will send patch v7 after the other patches are reviewed. I took another look at the series and I'm happy with all of them so will (almost certainly) pick them up at v7 unless other reviews come in. Thanks, Jonathan > > Thanks > > > + if (ret) > > + return ret; > > + snprintf(clk_parent_name, ARRAY_SIZE(clk_parent_name), clk_name); > > > if (data->model_data->need_prescaler) { > > snprintf(clk_name, ARRAY_SIZE(clk_name), "%s-prescaler", > > -- > > 2.25.1 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel