Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp3854171ybx; Sat, 9 Nov 2019 04:41:23 -0800 (PST) X-Google-Smtp-Source: APXvYqzXL2Jalu0LyfPwcR1wUMsNS4HDEejixX9cK0wn05Su5YJGCJmjfe+r7W5AmPg1etWdvyns X-Received: by 2002:aa7:cad0:: with SMTP id l16mr16017853edt.82.1573303283473; Sat, 09 Nov 2019 04:41:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573303283; cv=none; d=google.com; s=arc-20160816; b=tbWB9mwOTW1VT8xrgcsoB9h6u6bDuk+easXkNGfbF8Rbo43ZMNlcAlMIftI+DuPni4 36tP6acAtN5Ah6HFePBX21JYBeBPby7KKSFBmoQtHarqVA3HnW+TWYQPu6pEnUfcuxVb dpZ6cXFuaOll3D4LsR3hODX2cCEbflwCHYIavhJVjZp/tBFlQMjwVJEq+3vxW6Ujn+z6 bdm3UJRR0hwvSFa+2oSRl0vqBZRC9tD4pCPJTO7tqQRLrhuqF2dcaQ4k5mngTXbNiUw+ nCTCnFoi4qLdtAOx8qzeK01SGT4tlF+nfAphPYb6Y3sXkDNzjjKpEwgJzdxkITKpHPyN LKvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=hL4cSD6y+iiE+pk66covXBwBoPDDflUyOZevvfQmK2o=; b=dMeW44iyhQytFK2LGz3yas+D4VDY/TAq9OE0dx0FjSrN3DJMCT8wjTvpQpCmT+V9y2 +zZjnQJ5VJv9MbNV4EYM0mKSNzPIeLSJiIgTWON/9RAiTtRsDIC6LUaO2AmCzXU1TV4C GQeuChrJ7B5Sgp25UCqMtIXcmg7R5QD1xL58o+WVH/7JkUQDWvz5/JWANZf3/QsMqh3i hX4AHkRw2YZGyo/i5e5gHHwAzgxsfpjTJxA1akoV0XyzsBjolvVnvFIGp/YEJB6ke3oG YgLynF6oSUY593pKKQExPDik8znAWzLsY1/08ALkc7fOdT0FKPqlo3cU2It1KQo8rFVB 9Bvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=tFShlZ+M; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 s22si5546669ejz.245.2019.11.09.04.41.00; Sat, 09 Nov 2019 04:41:23 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=tFShlZ+M; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 S1726520AbfKIMiK (ORCPT + 99 others); Sat, 9 Nov 2019 07:38:10 -0500 Received: from mail.kernel.org ([198.145.29.99]:44636 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726301AbfKIMiK (ORCPT ); Sat, 9 Nov 2019 07:38:10 -0500 Received: from archlinux (cpc149474-cmbg20-2-0-cust94.5-4.cable.virginm.net [82.4.196.95]) (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 06D64207FF; Sat, 9 Nov 2019 12:38:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573303088; bh=XVnSugf5yeS7ju3H3HrhT5xXtiTNx1q/s0jgoUAsGv4=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=tFShlZ+MHSIVtUdT/SQsfFhOLvjUaLYC7RK2W+lkTkUSFHnZKDgN5BkhXbb4zm/vC KlWym7bieROGF/+wAlY0jO6KGCaLezuUph1781ZrIq2YCngy2YHPAcDwFNCXLiyHYq GuwZKBAM3s9CwEVBj/yeAmqpx4P9gr8C0O/VW7FU= Date: Sat, 9 Nov 2019 12:38:03 +0000 From: Jonathan Cameron To: Fabrice Gasnier Cc: , , , , , , , , , , , Subject: Re: [PATCH 2/2] iio: adc: stm32: allow to tune analog clock Message-ID: <20191109123803.3c002877@archlinux> In-Reply-To: <20191103123042.54c82559@archlinux> References: <1572279108-25916-1-git-send-email-fabrice.gasnier@st.com> <1572279108-25916-3-git-send-email-fabrice.gasnier@st.com> <20191103123042.54c82559@archlinux> X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 3 Nov 2019 12:30:42 +0000 Jonathan Cameron wrote: > On Mon, 28 Oct 2019 17:11:48 +0100 > Fabrice Gasnier wrote: > > > Add new optional dt property to tune analog clock prescaler. > > Driver looks for optional "st,max-clk-rate-hz", then computes > > best approximation below that rate, using ADC internal prescaler. > > > > Signed-off-by: Fabrice Gasnier > If the previous email I wrote on this got to anyone before I hit > cancel, please ignore. Had completely failed to read the code correctly. > > Anyhow this seems fine to me, but given there are a lot of existing > clk related bindings I'd like to give a little longer for Rob to > have a chance to take a look at the binding. > > Give me a poke if I seem to have lost this in a week or so. Applied to the togreg branch of iio.git. Shortly to be pushed out as testing for the autobuilders to poke at it. Thanks, Jonathan > > Thanks, > > Jonathan > > > > > --- > > drivers/iio/adc/stm32-adc-core.c | 16 +++++++++++++--- > > 1 file changed, 13 insertions(+), 3 deletions(-) > > > > diff --git a/drivers/iio/adc/stm32-adc-core.c b/drivers/iio/adc/stm32-adc-core.c > > index 20c626c..6537f4f 100644 > > --- a/drivers/iio/adc/stm32-adc-core.c > > +++ b/drivers/iio/adc/stm32-adc-core.c > > @@ -79,6 +79,7 @@ struct stm32_adc_priv_cfg { > > * @domain: irq domain reference > > * @aclk: clock reference for the analog circuitry > > * @bclk: bus clock common for all ADCs, depends on part used > > + * @max_clk_rate: desired maximum clock rate > > * @booster: booster supply reference > > * @vdd: vdd supply reference > > * @vdda: vdda analog supply reference > > @@ -95,6 +96,7 @@ struct stm32_adc_priv { > > struct irq_domain *domain; > > struct clk *aclk; > > struct clk *bclk; > > + u32 max_clk_rate; > > struct regulator *booster; > > struct regulator *vdd; > > struct regulator *vdda; > > @@ -141,7 +143,7 @@ static int stm32f4_adc_clk_sel(struct platform_device *pdev, > > } > > > > for (i = 0; i < ARRAY_SIZE(stm32f4_pclk_div); i++) { > > - if ((rate / stm32f4_pclk_div[i]) <= priv->cfg->max_clk_rate_hz) > > + if ((rate / stm32f4_pclk_div[i]) <= priv->max_clk_rate) > > break; > > } > > if (i >= ARRAY_SIZE(stm32f4_pclk_div)) { > > @@ -230,7 +232,7 @@ static int stm32h7_adc_clk_sel(struct platform_device *pdev, > > if (ckmode) > > continue; > > > > - if ((rate / div) <= priv->cfg->max_clk_rate_hz) > > + if ((rate / div) <= priv->max_clk_rate) > > goto out; > > } > > } > > @@ -250,7 +252,7 @@ static int stm32h7_adc_clk_sel(struct platform_device *pdev, > > if (!ckmode) > > continue; > > > > - if ((rate / div) <= priv->cfg->max_clk_rate_hz) > > + if ((rate / div) <= priv->max_clk_rate) > > goto out; > > } > > > > @@ -655,6 +657,7 @@ static int stm32_adc_probe(struct platform_device *pdev) > > struct device *dev = &pdev->dev; > > struct device_node *np = pdev->dev.of_node; > > struct resource *res; > > + u32 max_rate; > > int ret; > > > > if (!pdev->dev.of_node) > > @@ -731,6 +734,13 @@ static int stm32_adc_probe(struct platform_device *pdev) > > priv->common.vref_mv = ret / 1000; > > dev_dbg(&pdev->dev, "vref+=%dmV\n", priv->common.vref_mv); > > > > + ret = of_property_read_u32(pdev->dev.of_node, "st,max-clk-rate-hz", > > + &max_rate); > > + if (!ret) > > + priv->max_clk_rate = min(max_rate, priv->cfg->max_clk_rate_hz); > > + else > > + priv->max_clk_rate = priv->cfg->max_clk_rate_hz; > > + > > ret = priv->cfg->clk_sel(pdev, priv); > > if (ret < 0) > > goto err_hw_stop; >