From patchwork Thu Feb 18 10:33:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 384386 Delivered-To: patch@linaro.org Received: by 2002:a02:c80e:0:0:0:0:0 with SMTP id p14csp3559352jao; Thu, 18 Feb 2021 02:34:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJzIEvjC74PEdVz2j+BfoBWJLpueTFVxXBayotaumgYeDB8nMQWPPqoD/l4v+oIP0CvoGP+X X-Received: by 2002:a05:6402:17b6:: with SMTP id j22mr3358986edy.325.1613644473775; Thu, 18 Feb 2021 02:34:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613644473; cv=none; d=google.com; s=arc-20160816; b=TzEEZCauB8eTZgQJvzYQS3gUkw9WHHvW6ilbZ+JbvIPMXrx65lCg7JY4vGhGkWrj5a 1Ph5Uy3FcXmF3m2bz2yjG80T899q1pfZwlX0LBcmcPvGI5t3KlsxCHPG9X5qCgHSnfQs vL39H2tJ9KTsttJsIPidR/nNzjoO3SymJGaPjVstGPXqEZhFSnAej+FKu46ko5SorWKM GGRXI58WVo0psIVsE+NqO/USHTTLV/gtOw3bEjV4XLUMbtlSUbijoMpN6iyK+T+LtAfF l/ROekIOgAiSkAiB7/jq5xsbsFJ9tw/oGLwCZRkESGa98ZEA3gLZ0HH695j2xJZOP058 HKyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:references:cms-type:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature:dkim-filter; bh=+mQOJRUfPEgamOlpRSpMQF1NyKixEJUJ0c4gNG61Ouo=; b=sANhULPmpE4aip3F1UvdbIVuvxEOqimn2weUXyeZpZdOplrf6F0LgpwtcYE/tRihxS S+nUo4B0aE66Rv8TVEEc5PrD7sXatoRDztXS7QT0IopO6CVViU+GHuXgNae7BvyzN8Q6 v5jFKya6VW9pWo+DixeFJOnwCU9Gyc9xyGVjmxxPyO/ck7e7e5t0Sm5Ar38pJCF5xHbL iBr0+qOJR9ZsuvUsvaK9UVZJubTEXH1IY9erIA4JaoKI339nB4A2AXsOenPv0SLYaMS7 b/oQl8p6n1+Iz6wTQgt0oX4HP7sLg0DRTeJuTRSLivx+eLyyhXlqv0x79534HagJ9IxD ShpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=Fmayxpe9; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id a20si3671986ejg.257.2021.02.18.02.34.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Feb 2021 02:34:33 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=Fmayxpe9; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6A40282764; Thu, 18 Feb 2021 11:34:16 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=samsung.com header.i=@samsung.com header.b="Fmayxpe9"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7B784826F2; Thu, 18 Feb 2021 11:33:53 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 7613182675 for ; Thu, 18 Feb 2021 11:33:45 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=m.szyprowski@samsung.com Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20210218103335euoutp015819ad614d45d3c393b3e29b7bd5e602~k0QvPH5hh1511415114euoutp01o for ; Thu, 18 Feb 2021 10:33:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20210218103335euoutp015819ad614d45d3c393b3e29b7bd5e602~k0QvPH5hh1511415114euoutp01o DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1613644415; bh=+mQOJRUfPEgamOlpRSpMQF1NyKixEJUJ0c4gNG61Ouo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Fmayxpe9qhSp9zWggLsqZ9B/W2KGl+48ebxSI2EYbxIu9TLBMTki8ceVb/I/p/Nb/ ehIqZsUl2hDDBAzMm2m0iVCpxTnMM7cjR+1VPC2nUi9+F5rYCiqId1/4pV20Vn7Q2s i7DL0I9eR9hRCkHz/xgHQX2U7xEs98GWd5hbO1Gc= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20210218103329eucas1p2516a793cc2b0f706b797eae4b1b83af5~k0QqDgijG2030720307eucas1p24; Thu, 18 Feb 2021 10:33:29 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 77.6A.45488.9724E206; Thu, 18 Feb 2021 10:33:29 +0000 (GMT) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20210218103328eucas1p1f330ac7505f755e8ed903c060d31a178~k0QpextZw2707327073eucas1p1N; Thu, 18 Feb 2021 10:33:28 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20210218103328eusmtrp2ca90e1cb11c418ac8cf13d8a640bd265~k0QpeF3_U2025120251eusmtrp2q; Thu, 18 Feb 2021 10:33:28 +0000 (GMT) X-AuditID: cbfec7f5-c5fff7000000b1b0-e9-602e42792ea1 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 96.73.21957.8724E206; Thu, 18 Feb 2021 10:33:28 +0000 (GMT) Received: from AMDC2765.digital.local (unknown [106.120.51.73]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20210218103328eusmtip27c1d3f020332a8461d6df1d193a1b295~k0Qo-3aWU0440504405eusmtip2R; Thu, 18 Feb 2021 10:33:28 +0000 (GMT) From: Marek Szyprowski To: u-boot@lists.denx.de, u-boot-amlogic@groups.io Cc: Marek Szyprowski , Neil Armstrong , Lukasz Majewski , Philippe Reynes , Simon Glass , Heinrich Schuchardt , Jaehoon Chung , Bartlomiej Zolnierkiewicz Subject: [PATCH v7 3/5] adc: meson-saradc: add support for getting reference voltage value Date: Thu, 18 Feb 2021 11:33:16 +0100 Message-Id: <20210218103318.18915-4-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210218103318.18915-1-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFuplleLIzCtJLcpLzFFi42LZduznOd1KJ70Eg01rFSw2zljPanHjVxur xfN3l5ks1h65y25xqC/aouOwssW3LdsYLSZN+MVm8XZvJ7vF4akfGB24PN7faGX3mN1wkcVj 3qwTLB4fPsZ5zO/8zuRx9s4ORo++LasYPTYuO8AcwBHFZZOSmpNZllqkb5fAldF38DNTwTHe irY9b9gaGGdwdzFyckgImEisnT+FtYuRi0NIYAWjRNPNZ1DOF0aJf3M2MkI4nxkl1i7oY4Zp aZzxkAkisZxR4vjKPoSWYw/WMIFUsQkYSnS97WIDsUUEjCQuNe1gASliFrjDJNE1uYEFJCEs ECPRffg5I4jNIqAqseDMUlYQm1fAVuLv6Q4miHXyEqs3HABbzSlgJ/Hk7HywQRICRzgk2nev hbrJReLC3MksELawxKvjW9ghbBmJ/zvnM0E0NDNKPDy3lh3C6WGUuNw0gxGiylrizrlfQLdy AN2nKbF+lz5E2FHi3/1vYGEJAT6JG28FQcLMQOakbdOZIcK8Eh1tQhDVahKzjq+DW3vwwiWo 0zwkLt9dzA4JoYmMEpf2P2GfwCg/C2HZAkbGVYziqaXFuempxcZ5qeV6xYm5xaV56XrJ+bmb GIEp5vS/4193MK549VHvECMTB+MhRgkOZiURXvbPWglCvCmJlVWpRfnxRaU5qcWHGKU5WJTE eXdtXRMvJJCeWJKanZpakFoEk2Xi4JRqYJITc1nx19OsaLUyj55dJJfLochHdcrL7QX9lXXt mPRvOi8wlxH5sK4ggWvWsojwznWTw02mOkzLVnvDuktr8cb7SuXxcqu+2Cq7lR1QFrz51WJi VNCNfTbPt7Ee+hafzMrQq3ol+9vTrqSvS49oXNl48WCge42r5GXn+5FdkWc7lzB/anlTvHf3 r9bAjRvUvb7131t/IewUY+o6uxOlsQ33VZ5MP7/p2bQ1osdEW9wCOlzaBR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O2U3DdZyu9jgZGont5XKwvl9YrX RKu9p8z02R/DMDGkRqs7sXiJfLLbOu19emFy8eWFi9eKs0ZM3XhOUuqznNvcH0uUWIozEg21 mIuKEwFj2yROAAMAAA== X-CMS-MailID: 20210218103328eucas1p1f330ac7505f755e8ed903c060d31a178 X-Msg-Generator: CA X-RootMTR: 20210218103328eucas1p1f330ac7505f755e8ed903c060d31a178 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20210218103328eucas1p1f330ac7505f755e8ed903c060d31a178 References: <20210218103318.18915-1-m.szyprowski@samsung.com> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.102.3 at phobos.denx.de X-Virus-Status: Clean Add support for getting the 'vref-supply' regulator and register it as ADC's reference voltage regulator, so clients can translate sampled ADC values to the voltage. Signed-off-by: Marek Szyprowski Reviewed-by: Simon Glass --- drivers/adc/meson-saradc.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) -- 2.17.1 diff --git a/drivers/adc/meson-saradc.c b/drivers/adc/meson-saradc.c index 21db55831d..1a45a3a265 100644 --- a/drivers/adc/meson-saradc.c +++ b/drivers/adc/meson-saradc.c @@ -18,6 +18,7 @@ #include #include #include +#include #define MESON_SAR_ADC_REG0 0x00 #define MESON_SAR_ADC_REG0_PANEL_DETECT BIT(31) @@ -656,7 +657,10 @@ static int meson_saradc_stop(struct udevice *dev) static int meson_saradc_probe(struct udevice *dev) { + struct adc_uclass_plat *uc_pdata = dev_get_uclass_plat(dev); struct meson_saradc_priv *priv = dev_get_priv(dev); + struct udevice *vref; + int vref_uv; int ret; ret = regmap_init_mem(dev_ofnode(dev), &priv->regmap); @@ -675,6 +679,23 @@ static int meson_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; }