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 79BD7C433EF for ; Wed, 2 Feb 2022 19:00:00 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 890BE8340A; Wed, 2 Feb 2022 19:59:58 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=typeblog.net 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=typeblog.net header.i=@typeblog.net header.b="TVPhZ2gl"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id AB2CA83900; Wed, 2 Feb 2022 19:13:38 +0100 (CET) Received: from mail.typeblog.net (mail.typeblog.net [IPv6:2a0b:8bc0:2:13a2::2]) (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 3C974838D5 for ; Wed, 2 Feb 2022 19:13:36 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=typeblog.net Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=peter@typeblog.net Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 75B88FEC48; Wed, 2 Feb 2022 19:13:32 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=typeblog.net; s=mailcow; t=1643825615; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding; bh=R91fchQ8CCfEolZ1MGAbM5cIAI5TWiRuUI2JPdKuypo=; b=TVPhZ2glY6yAk6ikAyRSrYsmn07k7RR3gF10cfKG1gq4JpbBo8GBZPtF/FdqMRmTaj58ru 4AGC5Us8lM5jAMjQFxSJ4vc00oRjLglUGIGD6oH79YRf3YSyPFC3ulVn6YzddHdePT4y/2 IHb+bqfkmYRERlphedA3NaEPQDUDVl8d5Z730ppbotSQp0jRUvgPojgJqaSOcUsqAbTe+2 gaxeHtOdBfc53KEab+4zzUQu3Ipl5IXODBCPCgYD4K++mrJw5ilVTVsq5/2XO0bZWYr+ns URgF6gIbZYRL1M3ZuckotHOuXZP2TVCzw29q+S+WdtP+0LLM1cncSIMU6xL3DA== From: Peter Cai To: u-boot@lists.denx.de Cc: Peter Cai , Simon Glass , Philipp Tomsich , Kever Yang Subject: [PATCH] adc: rockchip-saradc: add support for getting reference voltage value Date: Wed, 2 Feb 2022 13:12:54 -0500 Message-Id: <20220202181254.300829-1-peter@typeblog.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Last-TLS-Session-Version: TLSv1.3 X-Mailman-Approved-At: Wed, 02 Feb 2022 19:59:57 +0100 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 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 --- 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; + 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