Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp2162697ioo; Mon, 23 May 2022 11:34:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy3DwnH3k2GGShVOQNkVJqVO49leF0f1sltdtz/UPRyB7Tx4cQsEW3H+YbwssC3kDn5FoBH X-Received: by 2002:a17:90b:4d8b:b0:1dc:a9c0:3d53 with SMTP id oj11-20020a17090b4d8b00b001dca9c03d53mr329366pjb.29.1653330873518; Mon, 23 May 2022 11:34:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653330873; cv=none; d=google.com; s=arc-20160816; b=hiWAiZXIV8U0qfARZySpT8D2vSwaMfm6rzpEXWcs/+u/ZbpRV9Bnz9/kmwuk0TLKla GujCMTOSUfSZlMbxDLJIMe0lyGW0hD9KqZC2iTuApR021gAMBI/Cucmr5WAlj6zZUoRI yVifXKcvr3aZNH3zDLTQx992nOZ+IJI/lyh2veza9OD6mwhdplDPi3+Ft0UybImOoHI7 nqcrdY6gesSv7iqKKn3B/rr1JhcaoO/mvrhQovE+K0W+SIdDIlok+UbNgx2mVcHwcZdo w/SXvRShLtpgUnenL3otIzJUoOWUiIgBfMl8dejClyk7n/mAHKOJtTnNgc7qJ8Ic4TOv 4QIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=X00UxJiG29OHM/sXI3MtHY1xp0KAlUMcsiInYqLUawo=; b=oXmjH0QwQ3BxKaQ3Hac4rOYLBc6f6wGLtLYcfOAgew8+LV+Wrmw4+qlZYiiqThUClN EYUCIBMjkS9cGzV72c32mp7wA1peTQ2sAx+9cJTbcBAqQjCBSZ/B7IyXWkg+eGaP56RC xxxRH9BKIvAnmsVOwI+7FPCDcATQFqF32V3vuBVFBg3OyN4a9lNVWAQ+GSc6syyw0wwI 4WS1m9SvmM9mdWiRQFrwyg/J/9vTEv+HToJHZX9acyksqjmJvIr/syiOKUxLyA8i/+QI 3zcX3UkhVOfxdS1CZhH4It69mfhwh3azdUh1K1xPZ4No6NpnE/Tl6qwBRKPPIiylvwRh uGmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=n5V1x8nf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id d2-20020a056a0024c200b00512e6ab7b80si16993338pfv.33.2022.05.23.11.34.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 May 2022 11:34:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=n5V1x8nf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CAD151A35B7; Mon, 23 May 2022 11:32:59 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243146AbiEWS1k (ORCPT + 99 others); Mon, 23 May 2022 14:27:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245494AbiEWS1I (ORCPT ); Mon, 23 May 2022 14:27:08 -0400 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3ADCD4105; Mon, 23 May 2022 11:02:38 -0700 (PDT) Received: by mail-ej1-x636.google.com with SMTP id gi33so21973406ejc.3; Mon, 23 May 2022 11:02:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=X00UxJiG29OHM/sXI3MtHY1xp0KAlUMcsiInYqLUawo=; b=n5V1x8nfknwiuZ01vBCWBJp2SDBg3zi23hvJdOeG1ukUA5q0CI/AGiNS1Aw76smWTR i0m0FQVyyc4hFwDPIg5ElEbnyUp5Ei/cAjCU9hY1/V0ytPv8h4VZexApyqWhBUvX2SCc qjC9pB3PR1dE5B952JAsq13Z5EUHKPBulwhFBbYP4M7Il7td63xkuXPTMHgXxxrDN9Vy 4SGaUQxOHHFeiFjA8KdbSMkFpjud0qeHvQEY/6MXBUinCtXkIT3QmWpV3u2Zc2kgo9/0 7TxD+0oacgozB26oHS53DHBnk8Y65gXwdJHJo0IaTnN5mBorkhprNt2OFIJrxzZtAL1o Jhxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=X00UxJiG29OHM/sXI3MtHY1xp0KAlUMcsiInYqLUawo=; b=veHGgUDPAexLTuWrrUkEkHx6KRKtPxPec8C7yjUhn+j2PRt+04TrgxEm60U3w/vApz zHYleAeE9HCnnVQmS7bh+F9Cf6NWZwrfAF0FOfb9hUpros9BJ6BqIg39i5+UOiRyzMrK oWYuMn/V7Qt44r4HvFAT4ZJWtuo8YzXlxjyhc/lylYS0axA3YYW/8r8hLvcOpwKRbxpS ZNfMqkpg27sec1FTlcYJhYkcxNTM59Y/CjSePQN3ZOQu64z+uMkrAAXZ4VrhZZQchqjf 09QfiUTkg47AomKcSSoHabbZbyQ0ltW6U3Dv4NoMn++pa0Lg/OC50paas0WOjSJOTsZ7 nkwA== X-Gm-Message-State: AOAM533xe/pBEqkWtqEkulxdI66Y/tJPmRnH/00jlBFtdjctgOmQnR3C 4dS2xSyfjqysXKJGcbY9h40UcxitiLRxAA== X-Received: by 2002:a2e:b88a:0:b0:253:e7f5:c0e9 with SMTP id r10-20020a2eb88a000000b00253e7f5c0e9mr5076231ljp.38.1653328478170; Mon, 23 May 2022 10:54:38 -0700 (PDT) Received: from nergzd-desktop.localdomain ([194.39.226.133]) by smtp.gmail.com with ESMTPSA id x9-20020a056512078900b0047255d211f9sm2087743lfr.296.2022.05.23.10.54.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 May 2022 10:54:37 -0700 (PDT) From: Markuss Broks To: linux-kernel@vger.kernel.org, jic23@kernel.org Cc: ~postmarketos/upstreaming@lists.sr.ht, phone-devel@vger.kernel.org, Markuss Broks , Konrad Dybcio , Marijn Suijten , AngeloGioacchino Del Regno , Song Qiang , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Andy Gross , Bjorn Andersson , Liam Girdwood , Mark Brown , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH 4/5] proximity: vl53l0x: Handle the reset GPIO Date: Mon, 23 May 2022 20:53:43 +0300 Message-Id: <20220523175344.5845-5-markuss.broks@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220523175344.5845-1-markuss.broks@gmail.com> References: <20220523175344.5845-1-markuss.broks@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Handle the GPIO connected to the XSHUT/RST_N pin of VL53L0X. Signed-off-by: Markuss Broks --- drivers/iio/proximity/vl53l0x-i2c.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/iio/proximity/vl53l0x-i2c.c b/drivers/iio/proximity/vl53l0x-i2c.c index 8581a873919f..36c48a824725 100644 --- a/drivers/iio/proximity/vl53l0x-i2c.c +++ b/drivers/iio/proximity/vl53l0x-i2c.c @@ -15,6 +15,7 @@ */ #include +#include #include #include #include @@ -44,6 +45,7 @@ struct vl53l0x_data { struct i2c_client *client; struct completion completion; struct regulator *vdd_supply; + struct gpio_desc *reset_gpio; }; static irqreturn_t vl53l0x_handle_irq(int irq, void *priv) @@ -197,6 +199,8 @@ static void vl53l0x_power_off(void *_data) { struct vl53l0x_data *data = _data; + gpiod_set_value_cansleep(data->reset_gpio, 1); + regulator_disable(data->vdd_supply); } @@ -208,6 +212,8 @@ static int vl53l0x_power_on(struct vl53l0x_data *data) if (ret) return ret; + gpiod_set_value_cansleep(data->reset_gpio, 0); + usleep_range(3200, 5000); return 0; @@ -237,6 +243,11 @@ static int vl53l0x_probe(struct i2c_client *client) return dev_err_probe(&client->dev, PTR_ERR(data->vdd_supply), "Unable to get VDD regulator\n"); + data->reset_gpio = devm_gpiod_get_optional(&client->dev, "reset", GPIOD_OUT_HIGH); + if (IS_ERR(data->reset_gpio)) + return dev_err_probe(&client->dev, PTR_ERR(data->reset_gpio), + "Cannot get reset GPIO\n"); + error = vl53l0x_power_on(data); if (error) return dev_err_probe(&client->dev, error, -- 2.36.1