From patchwork Thu Feb 11 08:47:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 380888 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp1884884jah; Thu, 11 Feb 2021 00:48:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJwj1dYblWQ6dh24ur1Jd44iRmAVbg22GBAt43rHsiHDHAULSlQFf1WhS7m8xGgt96ukVkxd X-Received: by 2002:a17:906:b055:: with SMTP id bj21mr7471301ejb.355.1613033300293; Thu, 11 Feb 2021 00:48:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613033300; cv=none; d=google.com; s=arc-20160816; b=Qya0F9XiC4rHFaZ4vsdM5zSmCJ/BWcSq8hHmjzAec3DfaaX7K/KYaMTJfE9OXcDNQ2 IOiiDYebRbWOju+GTN36DTY+xP1NGKClo4di1zuapJak/dOZTK+syo7nHGfi/+STx7DL s7hMT6CzJ/+aFw3jOiTGnbU8nsXJlNwqvQj6gerAK3nRoxawCP4cxYVf2RvH0EgAS5Zo FieovBC6oIQsyhinP9yTlDzKiAZsgN/37IMKDQrqlZQHOt5EaYPnrjzgF/oVFySaNYPd gSbOiUD9hTV83Motr0PsMPQuNDI7CQFufaZMeSDBpfDMZUG0+MpOqd7iv5gXc73w+b2x Ghcg== 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=PSFO66c1CVc4qpsujE28LJTtDNADCMTx+mC4KhSiYEaf5utxscMCGL6l4DcmxQyyeI JiQGPODV//NaJU95pm551Hn9RsHy6tZvAQc0nOjz40qN5skiWPlGoWymqqTg9vgOWwXr OHPTg1Jnh4wUIyTzLnuaxQjL2hTc/fl1zY41hwYXpdzH7mZ6ITEpsIS4Fvz95fLSeC+J p+qx4kue8gUR/S8sj0m79fCwCZ6jPR4FyF0FvQb2Ej8VahikvvbDweiFugn1F52bHkcv rspHSKIK5pTms7Nbd4+WCpskf9P/nkn+xoBMtvg1qP/BSUlarRUwhXxh0460b+a7Lmd7 wK4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=CTxZsrUt; 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 g24si3389091edu.329.2021.02.11.00.48.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Feb 2021 00:48:20 -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=CTxZsrUt; 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 CE59F82657; Thu, 11 Feb 2021 09:48:12 +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="CTxZsrUt"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4B79082675; Thu, 11 Feb 2021 09:48:11 +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=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 9AD5882627 for ; Thu, 11 Feb 2021 09:48:07 +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 mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20210211084807euoutp020ddf35ab1e6e771839663de111a70fc2~ipTp8Wh_R2343623436euoutp02c for ; Thu, 11 Feb 2021 08:48:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20210211084807euoutp020ddf35ab1e6e771839663de111a70fc2~ipTp8Wh_R2343623436euoutp02c DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1613033287; bh=+mQOJRUfPEgamOlpRSpMQF1NyKixEJUJ0c4gNG61Ouo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CTxZsrUtr+59s8xluXoH6FaRjvuC2dHCZXrfbOp+l+NcL24PfIPd8Lw4t/CuzK2WY mDxDVqNCzfDyJTrVBQ9GsY2AFTOOkbdMFEoWsEwVugyj7CtLBZ87QuS1kZzUcAzlEl QO4/k7BWurguU09T3GvOxsr8IwfD64ATEjJlzUNc= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20210211084806eucas1p236fd3ccc0e7fb7ba6f27b29547b8dc7e~ipTphn7x21131511315eucas1p2d; Thu, 11 Feb 2021 08:48:06 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id CE.94.45488.64FE4206; Thu, 11 Feb 2021 08:48:06 +0000 (GMT) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20210211084806eucas1p1ddadaa9bf4eb0f0b4f0acd1dd06113d7~ipTpJmwVa1432314323eucas1p1x; Thu, 11 Feb 2021 08:48:06 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20210211084806eusmtrp139c3e371bb90b570b1aa930773fa430c~ipTpIyaIr3224632246eusmtrp1V; Thu, 11 Feb 2021 08:48:06 +0000 (GMT) X-AuditID: cbfec7f5-c5fff7000000b1b0-88-6024ef46d926 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 1F.56.16282.64FE4206; Thu, 11 Feb 2021 08:48:06 +0000 (GMT) Received: from AMDC2765.digital.local (unknown [106.120.51.73]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20210211084805eusmtip186c1fe5498e473b593b66cf69e2d46c7~ipTokhg4p2072020720eusmtip1t; Thu, 11 Feb 2021 08:48:05 +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 v6 3/5] adc: meson-saradc: add support for getting reference voltage value Date: Thu, 11 Feb 2021 09:47:55 +0100 Message-Id: <20210211084757.22759-4-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210211084757.22759-1-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA0VSe0hTURzu3Hu3XWebtxl4UDNYWmZor4G3l9iDuj2goCAty628ONPN3N16 +E/qUHTW0lRcK5Ya2rKHWkvMR8wpU1qZVuoqpSJCsqxJ2WiB5fX2+O/7ft/3+75zDgdHJQZe MJ6m1tIatSJDyhdizc4ffdFbv4TLV7z+FE42mRp4pNtXwCPHPj9DyFvdowLSYTxIFnYtIr/b mgF5ocTHJyc6igRkV4UHxAupL+58AXUpZwCjLOZejPJMHqauFHkR6vFIC6CMtnpANdXZ0T34 AeH6FDoj7QStWR4nFyqNnV+R407RqYL2T/wcYPI3AByHhAza7582ACEuIawAGqueowbgN0O+ AVhhPcIJXwF0tlkwVmAX6jpeCzjhGoBd014+R2Y2vD0uwLr4xEpomDDwWTyfWAWf5rVgrAkl RhBoKMuZjQokkmBN97lZE0ZEwHfTRQIWi4gN0O17Ari6hfBGo332TH5EHHzQPsJjgyBhx+HU g0mEu8QWOHae5vyBcLzHJuBwKHSVncU4vx7At323BBw5C+CzPNOfhnVwpM/HZ4NQYilsaF3O jTfCttwBPpcvhu6JeewYnYEXmitRbiyChQUSzr0Ymntu/6vt7H+KcpiCZSX1KPdApQD29/ei JWCh+X9ZFQD1IIjWMapUmlmtpk/GMAoVo1OnxhzNVN0BM9/FNd0z1QKs45MxDoDgwAEgjkrn iwLyw+USUYridDatyUzW6DJoxgFCcEwaJGq9dzNZQqQqtHQ6TR+nNX9VBPcLzkFEl+8dSnrf dlf5LTq310++7JduNKK7OE+1ZPBlsDOs1OKzzH2kfiycU5ycth65Eq/Rpock5NsZT+3a9KtZ +pCIga7E2NgzHtPgD5nVYh+ufBl/swbqpxZEZpqrEjxDD4ts6SD0jj7oREdA/dVk23kxkDpD d/hra5OUjDL3xU/ZGlmg0bvX0Tc8rhIn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REionYFUTydS5L6nTL8jpW9aRSv4mk/OWtXWLCf0LfI H/EH3zypK3yXzrfmbvzGZXHfDod80ddaOdv67ENTqa5fEckhEXpe0jvvX9Xap8RSnJFoqMVc VJwIADMHwCkAAwAA X-CMS-MailID: 20210211084806eucas1p1ddadaa9bf4eb0f0b4f0acd1dd06113d7 X-Msg-Generator: CA X-RootMTR: 20210211084806eucas1p1ddadaa9bf4eb0f0b4f0acd1dd06113d7 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20210211084806eucas1p1ddadaa9bf4eb0f0b4f0acd1dd06113d7 References: <20210211084757.22759-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; }