Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1034436iob; Fri, 13 May 2022 20:27:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx1Sx4cg5DntCa5MRb41ylDXuiH2cJ9yHao6ao5q2TFYlRe6WOUCyagmJdUHWDZJI7mn6AE X-Received: by 2002:a05:6000:18ab:b0:20c:8d82:52c3 with SMTP id b11-20020a05600018ab00b0020c8d8252c3mr6060389wri.701.1652498851078; Fri, 13 May 2022 20:27:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652498851; cv=none; d=google.com; s=arc-20160816; b=z0CVkPMFafaUyyBgbQ+Ev+M4vB+2XKR4bG+794q7CggYV4mflWgCkCTby7FDUYQ9H2 EFymVzEYKIRy9JG5iAIdTMxgIkSUzqHrVe/X9sMdWZb36cQ8w28WoagYPlkYKmOzib3c ZTd65tfQJungLt4cEZcOkSIZTFvzMdjCmA6CLYPmH5stSQh14Ln6NoWbwtpktfs6QS1u M2K4Z6iyLJ+q7E4/ubvD3rjUDPqQvvI8RYN2hoJItOxH1piYqo2usW04auIYS+pysWkx y0S64Nhua2C/yL6QNG1S8WidPCP4yCZJlW17aryc0teZc1jenRqcHxwi0eH7diEfKwVN vFIg== 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=NBwjBAjLmyyb61HAFn6uQh2uqKVzaEjVLl9vH6ELw+E=; b=Smdxoz9CqfbekaqgSnCIOpNMoMCVUWikIrt2cvS47BJ8HultNsLrRMU4sLg7/BZ5UN oI4SsjzBjejXKfjzly6ayh2mLPmdOAd4Cj1/X1UtR9Y6OD9aoYhPYpGJWkrbByN5g3iP 02fUopnx8NL1fQaEX46Ctm6cu4A5U5Xcbh9XIGQ2CXl7DHBDqLXzpe3wnlSkzahLDBPd AeVMrrmEC8eOoyEJ0Jk4hY4lcJChMIfeo1rOFTQWH2n8/C2HqO9wUn0yyvLTOExiwXM3 TbfquZE9V3RwJsodcNH0wFNGj3tM+d1DJCvPPaURy1enkisPKVIlbjjkOpjC8xluICNt 2gHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=mOi4Dfi9; 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 o34-20020a05600c512200b0038c77be9cddsi4628407wms.165.2022.05.13.20.27.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 20:27:31 -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=mOi4Dfi9; 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 2EE69416D3D; Fri, 13 May 2022 17:04:33 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348355AbiEKVs3 (ORCPT + 99 others); Wed, 11 May 2022 17:48:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348390AbiEKVsL (ORCPT ); Wed, 11 May 2022 17:48:11 -0400 Received: from mail-lj1-x234.google.com (mail-lj1-x234.google.com [IPv6:2a00:1450:4864:20::234]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9D7D443E9; Wed, 11 May 2022 14:48:06 -0700 (PDT) Received: by mail-lj1-x234.google.com with SMTP id 4so4227209ljw.11; Wed, 11 May 2022 14:48:06 -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=NBwjBAjLmyyb61HAFn6uQh2uqKVzaEjVLl9vH6ELw+E=; b=mOi4Dfi99gDfBK3ToAmlb5QrQRONhoKohrWOS9c2HiM4BhUSyr29iX0z/t5Ydp+WES W0XlU8Fk6U4kqDbKtk7Vca8Ey9eAaMexZHe2p6ktCPnX3GSZMC/2syypz8i7prAvwpLg N3KO1IsL3HRqt3KD2oBwOMNuP0609LXl0ZHJDBxuoXS2WduHkR5rCbqJNxkeAw0Ila5S 0eCrfjPaXZVxUN9dseKkgGpkdRuCM4wkJlV5mq0AIy6uEgDSUxxhkwqvbMzcaPuWIi3G co8EgTvVUUC0TkxTN84UHl0g6vB3Uq9iZHrpGa4MKofWl9pdwPjQfI4Lp/cnBsRIFjnQ vN5Q== 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=NBwjBAjLmyyb61HAFn6uQh2uqKVzaEjVLl9vH6ELw+E=; b=Od7Q6UnilOl4pG/rsl9eNNgzuPtkspwCCg4FXXqxaBYltoP+PV6/tXQ7Xy6TiNnIJB VrCR4WJpmmXmhc+UVWHHZc20LN7ZcTuCMwzinKIcufYvkloiK6amvyaom9gf/r1YXzrO rIHFei1paHJnvy3HCD1xO2XYMGFi+k9QR/foQFu8O2QSGaiOxv8FpFstQsD+DTitRIR4 ZJ0faPzltoG1WWsTcCx7fHwOoZlVmV+lvN5vT4usC11c+gHFFEwSsdfE/hH5VRt9JDeO 2AhZI8m/tx/boQW/VpOES+37x3V3/UBz3gYTUhfIQuR8nnCJYamzpvvZN2NepDFdvB1c 5P+g== X-Gm-Message-State: AOAM532gHrLT1OCCWDT7h7rF4mr0okxsjTC+xQAO/9Ai/zf4BQpU3Sbc ZLDKq7eXIuiaWIz4sDqch5Ygo02nn//JGQ== X-Received: by 2002:a2e:351a:0:b0:24f:c3b:c2d5 with SMTP id z26-20020a2e351a000000b0024f0c3bc2d5mr17529744ljz.505.1652305685206; Wed, 11 May 2022 14:48:05 -0700 (PDT) Received: from nergzd-desktop.localdomain ([194.39.226.133]) by smtp.gmail.com with ESMTPSA id 7-20020ac25687000000b0047255d211afsm458891lfr.222.2022.05.11.14.48.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 May 2022 14:48:04 -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 v2 4/5] proximity: vl53l0x: Handle the reset GPIO Date: Thu, 12 May 2022 00:47:16 +0300 Message-Id: <20220511214718.50879-5-markuss.broks@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220511214718.50879-1-markuss.broks@gmail.com> References: <20220511214718.50879-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 e65c4fcd32d6..7aa9c1e95006 100644 --- a/drivers/iio/proximity/vl53l0x-i2c.c +++ b/drivers/iio/proximity/vl53l0x-i2c.c @@ -15,6 +15,7 @@ */ #include +#include #include #include #include @@ -43,6 +44,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) @@ -196,6 +198,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); } @@ -207,6 +211,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; @@ -236,6 +242,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