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 DE4C2C433F5 for ; Sat, 5 Feb 2022 13:49:39 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CDABE83B4D; Sat, 5 Feb 2022 14:49: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=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="raJLz2sh"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C2E2C83A08; Fri, 4 Feb 2022 21:16:49 +0100 (CET) Received: from mail.typeblog.net (mail.typeblog.net [185.213.175.99]) (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 A36E5836C1 for ; Fri, 4 Feb 2022 21:16:46 +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 388EE62AD; Fri, 4 Feb 2022 21:16:41 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=typeblog.net; s=mailcow; t=1644005805; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding; bh=yERvmZOZAJDiIqh/+0HW1SU57VgrpXyI4WM2VjPF548=; b=raJLz2shjf1K2hi1HpXKhykV98MzHw1LVW8bSp2RINHy0ISjHYgsPKQgvC55kvkAD8oIY4 uDeqW2LtCJK/ziATCWY7rWB18fIJKC8mUA2PB0mHJ3riOt7TuDaehtQIdztLgNsiyWVjP5 r88GGmj8AR7y8mlK67Yux1271d2yPSMj2vSjVplNtfDYob/ibFts26WcXlTfXuNmg6p++o Y8mQTW8ytx/I7Yur7h6iYa0mWGFFOaiGRfczujbyW4GE57K+N+kFkRpu0uVd4K4fp1pcWC PpXZPzTMAchQ9QmibXg8Sr2/o/k/28Vo5LVG/dnxAjadyYvTUb8UswJrY/OSRA== From: Peter Cai To: u-boot@lists.denx.de Cc: Peter Cai , John Keeping , Simon Glass , Philipp Tomsich , Kever Yang Subject: [PATCH v2] adc: rockchip-saradc: add support for getting reference voltage value Date: Fri, 4 Feb 2022 15:16:06 -0500 Message-Id: <20220204201606.762236-1-peter@typeblog.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Last-TLS-Session-Version: TLSv1.3 X-Mailman-Approved-At: Sat, 05 Feb 2022 14:49:34 +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 Reviewed-by: John Keeping Tested-by: John Keeping Cc: Simon Glass Cc: Philipp Tomsich Cc: Kever Yang --- Changes in v2: - Reordered local variables in `rockchip_saradc_probe`. --- 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..4007188133c8 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 udevice *vref; struct clk clk; + 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.1