From patchwork Tue Jan 26 09:50:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 370590 Delivered-To: patch@linaro.org Received: by 2002:a02:a60d:0:0:0:0:0 with SMTP id c13csp4802452jam; Tue, 26 Jan 2021 01:52:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJxorgHWpHjFi6S9g8ngaCmwe2z8APX4Ci42w+F3OThBH+ltI7tfPAeU3H3c4n+6fqxwCl9v X-Received: by 2002:a17:906:6846:: with SMTP id a6mr2899264ejs.470.1611654728276; Tue, 26 Jan 2021 01:52:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611654728; cv=none; d=google.com; s=arc-20160816; b=Li0KkVeCBIyHmIa1bkYk0vHnH1kTw/EmO6KwV8BRX00Hx41tZcFH/HT/i4WWHKoYxZ YWzw+F7/yASoAev6+64DSt9tBwgfNAG0t2kttBPCkHMWpJMfWlVHzVWv6OCyyydQu15v zxd2+mSplDIE0i2vc1uUWnQ0+Mpdp5C06Nlp//2iVC31/YQ2D36RyXAKFLxoKKihJL41 3HFLnwZUkVuYJUnNHY3MntvI9cH8h4R4hNWPiysMJPRvKjYxICafZ3T30DEwxxPYdUQ/ 1TJ4RLIsc8L16BVDoH/s7Fd3/h3znakRwJ+dmf0f53fvwo/2+vFb0mPwHYLfJcsORf4f F8sA== 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=txv+bFh9xDbqQOiyvI95mIA15L7JnhrzXb1RhxQZZts=; b=DOY6OloBVUT4JdSR8TMkFbQKkRo8N1LBgpUKH8o9xHrNXaQsgKYSkVCKDOPvbvzwMi U1jjCjz2lPsKXgIU5m05jiTtdaZPoZix2NnK4oY4ehBU01kt/QQ55wmqahRzM6zizDee ZUrmodUBHhhX4Hke+lssJfw8XrL0MWj5akOWHGSBMGr5r2+bDhR7cXjtwdyC3bbd401g Xxm8jFaMamNWMske9q3Xkjng4W5Aq5IqMPZNWiJQQ3BugiTZ8dtMWu3O7VdMc6WLFjrN QOhi6bKRkDDNo1yaESyhOtOGhXf8hM8ucTyWjBRH1lN8ssBeHBYQxnAY2QUfngsYADa0 KKzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=fmshGJp9; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 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. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id n8si3438529edy.77.2021.01.26.01.52.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jan 2021 01:52:08 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=fmshGJp9; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 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 C3AA882674; Tue, 26 Jan 2021 10:51: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=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="fmshGJp9"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E1260825D9; Tue, 26 Jan 2021 10:51:28 +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.3 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 5D855825B6 for ; Tue, 26 Jan 2021 10:51:14 +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 eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20210126095113euoutp028a4095169f5ad7c956d849b414286067~dv2MV3uQn3202732027euoutp02F for ; Tue, 26 Jan 2021 09:51:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20210126095113euoutp028a4095169f5ad7c956d849b414286067~dv2MV3uQn3202732027euoutp02F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1611654673; bh=txv+bFh9xDbqQOiyvI95mIA15L7JnhrzXb1RhxQZZts=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fmshGJp9fdJLLzojuu80syQEjqlFixoIYUVydAOi6dvZSTXfTMBfAj4SLWbPYzDaB Rn9pKT7wvEbG5hYzgb5EHUv658EbTtLBuUrHg7XiVwd5TFS88Nbx8gqbI1Xe1WBVX2 qzuYMV7L2x5jYZs50ZZitUj4a58cVXSwMIe7GE/M= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20210126095113eucas1p1035112566647076f7f7801b9b7f7dd23~dv2L3Oxbp0759307593eucas1p1t; Tue, 26 Jan 2021 09:51:13 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 5C.D2.45488.116EF006; Tue, 26 Jan 2021 09:51:13 +0000 (GMT) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20210126095113eucas1p1cbd41e98d0d5f454fe45a4c5e4bb5e2f~dv2LhetK80760807608eucas1p1w; Tue, 26 Jan 2021 09:51:13 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20210126095113eusmtrp24c4abf583bd3e5835724849358028a98~dv2Lg4mpA0431304313eusmtrp2d; Tue, 26 Jan 2021 09:51:13 +0000 (GMT) X-AuditID: cbfec7f5-c77ff7000000b1b0-6e-600fe611769c Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 5C.E7.16282.016EF006; Tue, 26 Jan 2021 09:51:12 +0000 (GMT) Received: from AMDC2765.digital.local (unknown [106.120.51.73]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20210126095112eusmtip2928838765a09e3bfd7853a225e364516~dv2K_I2bx0454904549eusmtip2R; Tue, 26 Jan 2021 09:51:12 +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 v5 3/4] adc: meson-saradc: add support for getting reference voltage value Date: Tue, 26 Jan 2021 10:50:35 +0100 Message-Id: <20210126095036.6429-4-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210126095036.6429-1-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupmleLIzCtJLcpLzFFi42LZduznOV3BZ/wJBu/PilpsnLGe1eLGrzZW i+fvLjNZrD1yl93iUF+0RcdhZYtvW7YxWkya8IvN4u3eTnaLw1M/MDpweby/0cruMbvhIovH vFknWDw+fIzzmN/5ncnj7J0djB59W1YxemxcdoA5gCOKyyYlNSezLLVI3y6BK+P63X62gpm8 FTs3bWFsYPzA1cXIySEhYCJxZctB9i5GLg4hgRWMEq29LxghnC+MEluPzWUBqRIS+MwoMe0b O0xH/7tTTBBFyxkl5i54wgbXsfzAcrAqNgFDia63XWwgtoiAkcSlph0sIEXMAneYJLomN4CN FRaIkeie9pMZxGYRUJV4v/UTWAOvgI3E8vcdjBDr5CVWbzgAVsMpYCux6PYKZpBBEgJHOCTa znxlhihykWj+e4MVwhaWeHV8C9StMhL/d85ngmhoZpR4eG4tO4TTwyhxuWkG1ApriTvnfgGt 5gC6T1Ni/S59EFNCwFHi09QKCJNP4sZbQZBiZiBz0rbpzBBhXomONiGIGWoSs46vg9t68MIl qMs8JLaeWAEN0gmMEovvrmOcwCg/C2HXAkbGVYziqaXFuempxcZ5qeV6xYm5xaV56XrJ+bmb GIHp5fS/4193MK549VHvECMTB+MhRgkOZiUR3t16PAlCvCmJlVWpRfnxRaU5qcWHGKU5WJTE eXdtXRMvJJCeWJKanZpakFoEk2Xi4JRqYCqNTz/Wzv3g0K9vs24EB6gxlc6S11ukekDDdIbS ni/PmxJ3bMg4/d067f0O0xC9m6ctH/OdFdsg/SzOwLL+5bkFFikvhJXVPgUryd94Y7c1uGSv xe4TxRsu5MdvOK7z69pPhuRTr3/uSz22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GWVs1d6340Xz5pa21xd/fjLcv77bO+Mwlbf9d/vRBn2lC LC7dHRs0EiNMVOpDIjcveLRtokj/832SIV7/MivW60p/C5hgcXDm5uucFgumnLpzPUyPY7JH VfRjiZnc8+3amV/+Vfo1ITQqu4mnpSrDVeM93yr1X6tjVho+OPbKSm9/zCfDPdI6SizFGYmG WsxFxYkATeSS8P4CAAA= X-CMS-MailID: 20210126095113eucas1p1cbd41e98d0d5f454fe45a4c5e4bb5e2f X-Msg-Generator: CA X-RootMTR: 20210126095113eucas1p1cbd41e98d0d5f454fe45a4c5e4bb5e2f X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20210126095113eucas1p1cbd41e98d0d5f454fe45a4c5e4bb5e2f References: <20210126095036.6429-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 --- drivers/adc/meson-saradc.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) -- 2.17.1 Reviewed-by: Simon Glass 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; }