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 Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E415AC433EF for ; Thu, 3 Feb 2022 17:42:25 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8A430839FB; Thu, 3 Feb 2022 18:42:11 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=metanate.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=metanate.com header.i=@metanate.com header.b="LUdIAu9J"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2637D83904; Thu, 3 Feb 2022 18:42:09 +0100 (CET) Received: from metanate.com (unknown [IPv6:2001:8b0:1628:5005::111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 63EBC836BF for ; Thu, 3 Feb 2022 18:42:06 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=metanate.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=john@metanate.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=metanate.com; s=stronger; h=In-Reply-To:Content-Type:References:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description; bh=qSTZ1QS0Eoe4ba4px8o9DzvD+tajZB1qG6x35xRXuV0=; b=LUdIA u9JdQC68Y6cLh5Ozu9wWVB8QSDkfrJcdugC+1b5CzUKmLdQkEnwewJqf3Lt5ffqRE2eGbMQw6lPwK qI01ni7ikCgO5EQyR+nl2/WIAW/bBXMIj44lCfUkCsmK2U7WIjS6nK/M6y0FgpGlNbVcbW4k+TXQe GxOdHRisdWsZ34zX/ZoF3rytmsVGYoEkp9MPt9MMmY3h5l1btdns1zRBhZkt4xhTnm71rcs6AMBI6 3iMuXYSzDGiUJQyHwkYiZG+drn/3Z0UmzhFHOJTqfvKb8keptTSLRmtAIcvfEJg1jgomKYukjui9/ OOPL0jsv92T+Mh1dWtUsXZDqst9YA==; Received: from [81.174.171.191] (helo=donbot) by email.metanate.com with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1nFg7P-0001Lk-1J; Thu, 03 Feb 2022 17:42:03 +0000 Date: Thu, 3 Feb 2022 17:42:01 +0000 From: John Keeping To: Peter Cai Cc: u-boot@lists.denx.de, Simon Glass , Philipp Tomsich , Kever Yang Subject: Re: [PATCH] adc: rockchip-saradc: add support for getting reference voltage value Message-ID: References: <20220202181254.300829-1-peter@typeblog.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220202181254.300829-1-peter@typeblog.net> X-Authenticated: YES X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean On Wed, Feb 02, 2022 at 01:12:54PM -0500, Peter Cai wrote: > Mirroring commit 97ab802aa36f ("adc: meson-saradc: add support for > getting reference voltage value") for meson-saradc, this adds support > for getting the "vref-supply" regulator and register it as the ADC's > reference voltage regulator, so clients can translate sampled ADC values > to voltage. > > Signed-off-by: Peter Cai > Cc: Simon Glass > Cc: Philipp Tomsich > Cc: Kever Yang One code style nit below, but: Reviewed-by: John Keeping Tested-by: John Keeping The results from this look good on RK3288. > --- > drivers/adc/rockchip-saradc.c | 21 +++++++++++++++++++++ > 1 file changed, 21 insertions(+) > > diff --git a/drivers/adc/rockchip-saradc.c b/drivers/adc/rockchip-saradc.c > index e464d33f2267..67c11d896e8d 100644 > --- a/drivers/adc/rockchip-saradc.c > +++ b/drivers/adc/rockchip-saradc.c > @@ -13,6 +13,7 @@ > #include > #include > #include > +#include > > #define SARADC_CTRL_CHN_MASK GENMASK(2, 0) > #define SARADC_CTRL_POWER_CTRL BIT(3) > @@ -100,8 +101,11 @@ int rockchip_saradc_stop(struct udevice *dev) > > int rockchip_saradc_probe(struct udevice *dev) > { > + struct adc_uclass_plat *uc_pdata = dev_get_uclass_plat(dev); > struct rockchip_saradc_priv *priv = dev_get_priv(dev); > struct clk clk; > + struct udevice *vref; Should vref be above clk to keep the reverse Christmas tree order of decreasing line length? > + int vref_uv; > int ret; > > ret = clk_get_by_index(dev, 0, &clk); > @@ -114,6 +118,23 @@ int rockchip_saradc_probe(struct udevice *dev) > > priv->active_channel = -1; > > + ret = device_get_supply_regulator(dev, "vref-supply", &vref); > + if (ret) { > + printf("can't get vref-supply: %d\n", ret); > + return ret; > + } > + > + vref_uv = regulator_get_value(vref); > + if (vref_uv < 0) { > + printf("can't get vref-supply value: %d\n", vref_uv); > + return vref_uv; > + } > + > + /* VDD supplied by common vref pin */ > + uc_pdata->vdd_supply = vref; > + uc_pdata->vdd_microvolts = vref_uv; > + uc_pdata->vss_microvolts = 0; > + > return 0; > } > > -- > 2.35.0 >