Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp962460iob; Fri, 13 May 2022 17:51:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyvef34gS+xVgAFMwOTTFA/7LrT4IvIeA/f3ax3y2u5O2FwxF/OUxZWkMhtrN7Nle5O3xCW X-Received: by 2002:a5d:4090:0:b0:20c:8b91:3b17 with SMTP id o16-20020a5d4090000000b0020c8b913b17mr5777110wrp.348.1652489502579; Fri, 13 May 2022 17:51:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652489502; cv=none; d=google.com; s=arc-20160816; b=rbvnTyMcDjDnO0DJPj9FfiYwRonhrOqIliZccaDO8avQArAtKCjutix7TKpoM7eJdY EZsix5nPS62Q5vw6xlyYpjJHpJmWE+Q03crQhqGfw86K5lLfyXojMgs66kPWNrBdmzVm jr/y34Vln2NY7jJwN4VNkVemqxdmFosYpqtgVIG3H9sRoG7PA1MGACbCfRNVycm7QxtZ MMcXzgBWY3IuiDlo+pyxLC/Eg0KL8xAGtvvX27uaH3Qmpvir5AuBcCOZ0p4LY5gfkA/a a79c8vAPewK9zLsNGVbbxEoCP9+aqNH44P61k/gqE3zC9+RLWpMjBDiiFuXsvD4ePY7H iP/g== 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=RLQN83VvltxdSATanB/kDolFLpegPPuCVvOhwlfRT+8=; b=wRNZJWauaNVq6qe7VabKioLigahbrCFmmho4flTCvkt9ZjjMvIm//k92xyApclfvcT M9UQxVuRGsCCe5uhHGVsp4u5xPS9iphI+318kioRFQjNvhCXtMV4YJQbhG6SHJwuC0CD w/8xrnt8uEOVOAR/e8tdwanyhRNxKsBEyUNk7QUiRLXFEeDkCgo45mwU8fbIp4bJF3Bj 5x/JaUoXc5jzFtdv1RdZXmugNrS6BLzz+N4s8b58cOR+wEzEhqM8HAu9CnV7Ha2M/HZ7 DXk15JfvKOovJF4txGdoDN2eyKR4sI0dy9ume8kjDpmGXcxbeVldKUDvTU7ACj1vQCb9 XBoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=mZKX+Sjx; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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. [23.128.96.19]) by mx.google.com with ESMTPS id v1-20020a056000162100b0020c5f61dcb1si3866326wrb.358.2022.05.13.17.51.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 17:51:42 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=mZKX+Sjx; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 2FACC33F3C9; Fri, 13 May 2022 16:28:02 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343792AbiELLIo (ORCPT + 99 others); Thu, 12 May 2022 07:08:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352976AbiELLIa (ORCPT ); Thu, 12 May 2022 07:08:30 -0400 Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B876A5C645; Thu, 12 May 2022 04:08:19 -0700 (PDT) Received: by mail-lf1-x129.google.com with SMTP id d19so8402536lfj.4; Thu, 12 May 2022 04:08:19 -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=RLQN83VvltxdSATanB/kDolFLpegPPuCVvOhwlfRT+8=; b=mZKX+SjxOH6UemtZnMDam2zh4o0eCLB8so8IKQqcaT/v+lQaOSyK0I4aqZU0rH1PsI AQY7Z5bMcIcCHiB3FoOarcfppy4bM6E1k3W8Jvon1kHWLMOc2NG65+PD6s/omE1j3+Dp YulAxEOaWGDVoiLiRCKF34qwfA0CYYprz37nMqUXsYO34KAjdMp1drtR2wUucv70iIrh qZDSUsep1SaKn6lR3T18tZNpeDfRYP2+NydR+5y/BH5bkLEPVggSEKs+Go2jVsL7FgEI n0pQDeL7vdZDsUUPAtlmpN91QpLncAKmsdhv2TZoTKo0ZJZfc2i8y9Agccr1+aSmFDDz Y3CA== 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=RLQN83VvltxdSATanB/kDolFLpegPPuCVvOhwlfRT+8=; b=0/xay8dzv9atp4iIGhz2/ox/zfOpZBMv3JlFzbuH94+5qdz7KUHBI9x72YRLCk2hU3 1SOYx30ab3+ZPW6JVje6aDoSiY4WWoyzTnPHpR+XiT3ltirZK6CMIeEL6bqMtBeatbx9 Bnffgx8ysS6JEKEt3Lmh4WOwTu/lIqWUhitkBFSkIE5e6j1rW72tW5vSpH8vH8aKd2rL +dFPvdP/VB5qUpmucKe/6gw5WtMj7CDuizRnPMuyJFOTuC2QxZy+uKBO/qCEx3J/UXTZ keHGSNK+capYysZissAvDP08nuF3zOH513n6vi5P3lNKKfr72dKp5LYwWG8lZusPZLT5 S6yA== X-Gm-Message-State: AOAM530m7UxSMJg+lFlDMrVfcOFF+9fWhjYsEsDQqzCYGJbdQ29+GRtY Iul7F8egnZNkNxyfiKlizCIi+o2Z3EZxYQ== X-Received: by 2002:a05:6512:c03:b0:447:7912:7e6b with SMTP id z3-20020a0565120c0300b0044779127e6bmr23587775lfu.508.1652353697935; Thu, 12 May 2022 04:08:17 -0700 (PDT) Received: from nergzd-desktop.localdomain ([194.39.226.133]) by smtp.gmail.com with ESMTPSA id i25-20020a056512007900b004725b99d2fdsm734883lfo.164.2022.05.12.04.08.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 May 2022 04:08:17 -0700 (PDT) From: Markuss Broks To: linux-kernel@vger.kernel.org Cc: ~postmarketos/upstreaming@lists.sr.ht, phone-devel@vger.kernel.org, Markuss Broks , Konrad Dybcio , Marijn Suijten , AngeloGioacchino Del Regno , Song Qiang , Jonathan Cameron , 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 v3 4/5] proximity: vl53l0x: Handle the reset GPIO Date: Thu, 12 May 2022 14:07:56 +0300 Message-Id: <20220512110757.5297-5-markuss.broks@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220512110757.5297-1-markuss.broks@gmail.com> References: <20220512110757.5297-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 d8523e3981e8..ef099dd174c1 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 = devm_add_action_or_reset(&client->dev, vl53l0x_power_off, data); if (error) return dev_err_probe(&client->dev, error, -- 2.36.1