From patchwork Thu May 12 19:13:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markuss Broks X-Patchwork-Id: 12848046 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 00539C433F5 for ; Thu, 12 May 2022 19:13:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237536AbiELTNv (ORCPT ); Thu, 12 May 2022 15:13:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357944AbiELTNt (ORCPT ); Thu, 12 May 2022 15:13:49 -0400 Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7206F4B1D4; Thu, 12 May 2022 12:13:48 -0700 (PDT) Received: by mail-lf1-x131.google.com with SMTP id u23so10797237lfc.1; Thu, 12 May 2022 12:13:48 -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=ot1LRa7lM+k3YsGeal4v34AufyNdy0MxZF/OmP8vaTY=; b=fl7m+Sy2q51zLDj9YOdvZlDg3KGb+wnKtsRPRIj2/t4UMfva6opF5tXqFIRV3FOyGR vbLYz10hfDvS4aYSy+ysUF7AXXPQ4IJfGzxDhHon1F3YvtyPm5JQWIvoXwfWZYbz+U2N GItLg/8DKK2aK4fmQ8XQ/dEOx/ZRxPYMy2BQAGi99kd1zPFfu2rw1kW+Vz76qRAdscwa yNcrZKAU0onDKO6sd+617sp3WRMXMYOiiziHPZMoOCP2olDl8vvsYVhyHmvBlckLJSHA 8OpkrDw3kKkT5mi/A9SegIWQH29XL2k28r02YAThWbMkM6KIsQu6f1uuj40A/QP+FL/s vbzA== 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=ot1LRa7lM+k3YsGeal4v34AufyNdy0MxZF/OmP8vaTY=; b=Ki9OTMHibjNNUdTV01jMeykw9aLKdEBKMHW0Tl+gDYeiQ7bnIGS1FeMQ0QoMH6Rgc+ I6bs6Z6g8P34RF5orr2jUElyPjPOnYUcKMnvg/FiNzB0Vck1e5Vv36KvYYsKuKFxWXSc jeexhl7Kn3oJFS8204MEcaI9ZLMW3ixSNCCcSIQjfPrSI7wNS3QRHoLjXE5PSbmTymQM f4ZdCSywZf6cKJ9ag5qDBz/IEcH1yml+1M+a+RJIFHHmWzwRJGzOZwDPzic54/oVzLMC OJtFQNtDLsoWPRoDBtufkNjR1+8FSjwJYKPYoWqpeOR0Kl6d63mzgF/CoAbAAouqUv4G z7Tg== X-Gm-Message-State: AOAM530loty2U3KWFe2bXIvvf8tjdmkrnMHkaxGWfnM+buGixMo3okby kj2ZiHtEle/SUq1LWAgAGegw5VhRQKkdEQ== X-Google-Smtp-Source: ABdhPJzYkz+yR4pFKrfCDy4hRzreNMuY/Afvmgz7zMl8qBIZJxlrbdgdT9MtoAsxUPbIHiEjs5zvTg== X-Received: by 2002:ac2:5cdb:0:b0:471:fd36:fa56 with SMTP id f27-20020ac25cdb000000b00471fd36fa56mr829030lfq.501.1652382826649; Thu, 12 May 2022 12:13:46 -0700 (PDT) Received: from nergzd-desktop.localdomain ([194.39.226.133]) by smtp.gmail.com with ESMTPSA id y26-20020ac255ba000000b0047255d210f4sm62146lfg.35.2022.05.12.12.13.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 May 2022 12:13:46 -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 v4 1/5] dt-bindings: proximity: vl53l0x: Document optional supply and GPIO properties Date: Thu, 12 May 2022 22:13:29 +0300 Message-Id: <20220512191334.61804-2-markuss.broks@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220512191334.61804-1-markuss.broks@gmail.com> References: <20220512191334.61804-1-markuss.broks@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org This patch adds the optional properties for the VL53L0X ToF sensor to the device-tree binding. Signed-off-by: Markuss Broks --- .../devicetree/bindings/iio/proximity/st,vl53l0x.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Documentation/devicetree/bindings/iio/proximity/st,vl53l0x.yaml b/Documentation/devicetree/bindings/iio/proximity/st,vl53l0x.yaml index 656460d9d8c8..322befc41de6 100644 --- a/Documentation/devicetree/bindings/iio/proximity/st,vl53l0x.yaml +++ b/Documentation/devicetree/bindings/iio/proximity/st,vl53l0x.yaml @@ -19,6 +19,11 @@ properties: interrupts: maxItems: 1 + reset-gpios: + maxItems: 1 + + vdd-supply: true + required: - compatible - reg From patchwork Thu May 12 19:13:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markuss Broks X-Patchwork-Id: 12848047 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E871DC433EF for ; Thu, 12 May 2022 19:13:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357968AbiELTNy (ORCPT ); Thu, 12 May 2022 15:13:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357953AbiELTNw (ORCPT ); Thu, 12 May 2022 15:13:52 -0400 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 379F54B1D4; Thu, 12 May 2022 12:13:51 -0700 (PDT) Received: by mail-lf1-x134.google.com with SMTP id d15so10790201lfk.5; Thu, 12 May 2022 12:13:51 -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=rHLHpItlazo+UaJMdlnAGs/zpbzJsdOOF257QRYRuhY=; b=NH89gipF5eTmxoW+StfsmD2/O6lE2BaP0uBaIgqeKWkQBIoPwVXTQolZjdHRx/r6aa FemUPRihV8Iu+dVJECCQaSVo5ubXpWbc9rVHZl6jUSgREavQxQELiHgMlcfp0+iq/lJq zV045HoOEFrBlAyCC6s5cHTbP+mWYRSkjmFWX4e78mVgFLo1qttmJsY1vAZGzAWcCYb8 T0IRxNzcqypA3QPIx2If1LZ5pSR+WaLfUlnB8KnKYU8jLQrMyhHcI3GnSmK1lfyAKyur Gxf+Yh3Zvwk8fpFmwWWwpsRYZDo8VgT7/x9a/9w3bLMnLlcgdH4AUknj5crqnaOmCn/R KrQg== 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=rHLHpItlazo+UaJMdlnAGs/zpbzJsdOOF257QRYRuhY=; b=Afz/1c3WdPwpmuIKdc6JUU6xtgDirtltHKx4KOcdvTB6/0J3R4XsC9dUJlHQXzzoK7 bveKUiKsZajp/INGVTI2ERrBYxvOiaATPKBFD0aWx/Xg0dZYWfsk/6B7FKNw495vn1Z4 u5jfNCBQ03zoTSCfc1DeZuHZIEpEyBMjeZS2SdgRH+7N63cRgZ90k/d20Q65KlL8H/qJ Xk52tyn96x9FwIff6KUExtHiWxx6rRyCs3Ziu/y5APUXrrJ2JrUlz1ixvHQ5WJ6KDuru EF6pG8CegXlyVZ2ZLV0SFzcN3LoJIy7GqSQty9w7Y4TpnnrgcE57rv5MQD/wWWdlf63i wnMw== X-Gm-Message-State: AOAM530Ts9h5QzWlDOOaaA5n8SWnMv9KwJi8yY0JyFdLfOfNFt1hp38K koD3ghZP/Mn8d+Rp2R9w3wvY8pZXHS7l3w== X-Google-Smtp-Source: ABdhPJwmFB+UuC9r4IsHO2t8oPyUzj7SRTIVM9vbEjm4FX0nARw1s6EVNBgJTBrvrL3MgfZCM0RPcg== X-Received: by 2002:a05:6512:169a:b0:44a:fea7:50a5 with SMTP id bu26-20020a056512169a00b0044afea750a5mr882075lfb.498.1652382829415; Thu, 12 May 2022 12:13:49 -0700 (PDT) Received: from nergzd-desktop.localdomain ([194.39.226.133]) by smtp.gmail.com with ESMTPSA id y26-20020ac255ba000000b0047255d210f4sm62146lfg.35.2022.05.12.12.13.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 May 2022 12:13:49 -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 v4 2/5] proximity: vl53l0x: Prefer pre-initialized interrupt flags Date: Thu, 12 May 2022 22:13:30 +0300 Message-Id: <20220512191334.61804-3-markuss.broks@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220512191334.61804-1-markuss.broks@gmail.com> References: <20220512191334.61804-1-markuss.broks@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org On some boards interrupt type might be different than falling edge, like hardcoded in driver. Leave interrupt flags as they were pre-configured from the device-tree. If they're not provided, default to falling edge interrupts. Signed-off-by: Markuss Broks --- drivers/iio/proximity/vl53l0x-i2c.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/iio/proximity/vl53l0x-i2c.c b/drivers/iio/proximity/vl53l0x-i2c.c index 661a79ea200d..12a3e2eff464 100644 --- a/drivers/iio/proximity/vl53l0x-i2c.c +++ b/drivers/iio/proximity/vl53l0x-i2c.c @@ -16,6 +16,7 @@ #include #include +#include #include #include @@ -57,11 +58,15 @@ static irqreturn_t vl53l0x_handle_irq(int irq, void *priv) static int vl53l0x_configure_irq(struct i2c_client *client, struct iio_dev *indio_dev) { + int irq_flags = irq_get_trigger_type(client->irq); struct vl53l0x_data *data = iio_priv(indio_dev); int ret; + if (!irq_flags) + irq_flags = IRQF_TRIGGER_FALLING; + ret = devm_request_irq(&client->dev, client->irq, vl53l0x_handle_irq, - IRQF_TRIGGER_FALLING, indio_dev->name, indio_dev); + irq_flags, indio_dev->name, indio_dev); if (ret) { dev_err(&client->dev, "devm_request_irq error: %d\n", ret); return ret; From patchwork Thu May 12 19:13:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markuss Broks X-Patchwork-Id: 12848048 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 85577C433F5 for ; Thu, 12 May 2022 19:14:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357985AbiELTOS (ORCPT ); Thu, 12 May 2022 15:14:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357961AbiELTNy (ORCPT ); Thu, 12 May 2022 15:13:54 -0400 Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 784E02764DC; Thu, 12 May 2022 12:13:52 -0700 (PDT) Received: by mail-lf1-x131.google.com with SMTP id u23so10797237lfc.1; Thu, 12 May 2022 12:13:52 -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=Y6hTyWxvALgSndQqmiLi+9G4p6MJh+4j+g2xm+AL/rQ=; b=PysoZzwNMfsEcuiter0OSCiPRt4Ho8EYePnl4pJqPmAonr4+tAlQcrGFBSFe7IeX4g aRFxmEnXrpO4NhWPqDWoZAvc4Xjkw6XlOpDuSZDQsJDZRF93R5tP6dFXsMtRc7GpNYlu l2fGDHCj/CgiiYE7Auez0HBUwzw3RHSCUafL0EJlhLcB8gYa6Z2I/S7jsRuAKWlQ8Afr ++1R8C7P99xDg1XA3uzKJwb7yt5YAChecZVuV1sRftSsKZp7nFfv4zY6y8DnRXWj7vLK lGPbktAjFQWSQPe0qSn6amEAhMhy43NGsTQ8ZAQdzACHgTUPrmxE2zDjdJeu/Neq/8uI +hFA== 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=Y6hTyWxvALgSndQqmiLi+9G4p6MJh+4j+g2xm+AL/rQ=; b=IxgFnfK2n+QCKSPHQj4tZsXn1GKzCMkU81JPUSrFDCy8/Uo0lK8RxvMNJQvvvOuv/9 va3FXJErRVDk+A2AcMCNb9TJu+jSB3O/NqrR3IGWyIhg6w1SPCeFOftmRZ53gASqGnmT nE4Xw8KKa6xZuBFKgbbv643/2Kjk96uIRE/fvPpTijKf8yT4nX/ePaEVMxH777u9OZA4 NabHB6RU/pkFl71QvFGy/y2aBffD0NCRN0+rA0xCP5tKDMO4k5lnM4SFeytPHtWvlZNY fbWjzTNrE7bVtHQ6yqKEd5KfVbn+ModstSD3CoqlIGgagoZLYg/vjAmIuxr8F+6Jm4OK yZZg== X-Gm-Message-State: AOAM531xIG2hffFUapAQmmnlS0vPelh0CztGJKEarrRQirJaRjoIKP6n 8rSJ/JEzeEH9J1iKYy3gDaZSPqPWquEH7w== X-Google-Smtp-Source: ABdhPJxezMskd742DMYln9aEmh78sXgfMEsMgpKa1dItrQ1qSxFU8SVH5RR7d57wBs+UShJjU8+DYQ== X-Received: by 2002:a05:6512:332d:b0:472:9a2:6e27 with SMTP id l13-20020a056512332d00b0047209a26e27mr847024lfe.611.1652382831889; Thu, 12 May 2022 12:13:51 -0700 (PDT) Received: from nergzd-desktop.localdomain ([194.39.226.133]) by smtp.gmail.com with ESMTPSA id y26-20020ac255ba000000b0047255d210f4sm62146lfg.35.2022.05.12.12.13.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 May 2022 12:13:51 -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 v4 3/5] proximity: vl53l0x: Handle the VDD regulator Date: Thu, 12 May 2022 22:13:31 +0300 Message-Id: <20220512191334.61804-4-markuss.broks@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220512191334.61804-1-markuss.broks@gmail.com> References: <20220512191334.61804-1-markuss.broks@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Handle the regulator supplying the VDD pin of VL53L0X. Signed-off-by: Markuss Broks --- drivers/iio/proximity/vl53l0x-i2c.c | 37 +++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/drivers/iio/proximity/vl53l0x-i2c.c b/drivers/iio/proximity/vl53l0x-i2c.c index 12a3e2eff464..8581a873919f 100644 --- a/drivers/iio/proximity/vl53l0x-i2c.c +++ b/drivers/iio/proximity/vl53l0x-i2c.c @@ -43,6 +43,7 @@ struct vl53l0x_data { struct i2c_client *client; struct completion completion; + struct regulator *vdd_supply; }; static irqreturn_t vl53l0x_handle_irq(int irq, void *priv) @@ -192,10 +193,31 @@ static const struct iio_info vl53l0x_info = { .read_raw = vl53l0x_read_raw, }; +static void vl53l0x_power_off(void *_data) +{ + struct vl53l0x_data *data = _data; + + regulator_disable(data->vdd_supply); +} + +static int vl53l0x_power_on(struct vl53l0x_data *data) +{ + int ret; + + ret = regulator_enable(data->vdd_supply); + if (ret) + return ret; + + usleep_range(3200, 5000); + + return 0; +} + static int vl53l0x_probe(struct i2c_client *client) { struct vl53l0x_data *data; struct iio_dev *indio_dev; + int error; indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data)); if (!indio_dev) @@ -210,6 +232,21 @@ static int vl53l0x_probe(struct i2c_client *client) I2C_FUNC_SMBUS_BYTE_DATA)) return -EOPNOTSUPP; + data->vdd_supply = devm_regulator_get_optional(&client->dev, "vdd"); + if (IS_ERR(data->vdd_supply)) + return dev_err_probe(&client->dev, PTR_ERR(data->vdd_supply), + "Unable to get VDD regulator\n"); + + error = vl53l0x_power_on(data); + if (error) + return dev_err_probe(&client->dev, error, + "Failed to power on the chip\n"); + + error = devm_add_action_or_reset(&client->dev, vl53l0x_power_off, data); + if (error) + return dev_err_probe(&client->dev, error, + "Failed to install poweroff action\n"); + indio_dev->name = "vl53l0x"; indio_dev->info = &vl53l0x_info; indio_dev->channels = vl53l0x_channels; From patchwork Thu May 12 19:13:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markuss Broks X-Patchwork-Id: 12848050 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 85133C4332F for ; Thu, 12 May 2022 19:14:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357979AbiELTO3 (ORCPT ); Thu, 12 May 2022 15:14:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357957AbiELTOD (ORCPT ); Thu, 12 May 2022 15:14:03 -0400 Received: from mail-lf1-x136.google.com (mail-lf1-x136.google.com [IPv6:2a00:1450:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FE0E2764F8; Thu, 12 May 2022 12:13:56 -0700 (PDT) Received: by mail-lf1-x136.google.com with SMTP id y32so10771408lfa.6; Thu, 12 May 2022 12:13:56 -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=BIKhjkc/C+VlfYqtLCW9ohNhtcCKeCQweZnR2uH0wugGjxrsFSJrs/FjI+W6x3LX2E 3ivLWd6Zs+MInoXNgFYJ10yBVZvp/yJjVFe7vh9DcR1Wkyy1hlT4/OzFMItwuvmmg2Pg eQ6biVBl6ql72Ws9Y6RKy6+Y0hFlMFSa9z9Vdsc7usd7CiXZEMSGQA2Gc2NpPqcBrkAS NasDtBrKDTu4rJRAXAF2y5lsCwJ311qyhiXv/1a9cf+1asrI7sph7KrPztrafa/je2KH s2QhY4lgBPU2H7InDDI5lYAiGIipvvAUJjrsD+J0yH9TRBYPNwMrWizW+HeLA6t6Wxd/ KoMA== 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=3FeedqigRfU+OC8Bz6U7Imq/dpB6PKxeyJM7J2lrWJXYF80n6jFIx5VQ5q5R2iedN+ Y82Kegbc6pB1RcaQc/eBHeH8lvbaSjw4CrSVNfJyEbroACUYX6hhiMF4bR/kEXpatdD/ cmDZxHdol3eyOllOpjJnYQ//xs69KD5nOkoPLvpbcNNVZbGUmvfMJt8NmfKPH30r4VwN kxALPA+vJcGgJb1xaivBZ1FCBIzV/AvMdeqdCCpD7TzQxDFbPOFZmXQLMgbe50Ix9glJ 6RW4vIHetqsFsPQ8VQy6LO8+jzYkCxKGcHybUIkKbk/oT42bNKXR5mhI8GdNXNDPGt9o pSRw== X-Gm-Message-State: AOAM533Gt9vfWi/PcS6Zei01o1kFldqw7icUZ671/JjnqjQ674QOY24c o2TEBeXhDVneOFPhYgc1ABO6sndqDx1Vfw== X-Google-Smtp-Source: ABdhPJzbLYaREDLCv/6XHTqaOAnSDI2vNV6DtnXOAyj3WhVSEfhl+++h6q1bPxZIxDG79hKpdh2s/Q== X-Received: by 2002:a05:6512:2988:b0:473:f41d:567d with SMTP id du8-20020a056512298800b00473f41d567dmr865986lfb.384.1652382834237; Thu, 12 May 2022 12:13:54 -0700 (PDT) Received: from nergzd-desktop.localdomain ([194.39.226.133]) by smtp.gmail.com with ESMTPSA id y26-20020ac255ba000000b0047255d210f4sm62146lfg.35.2022.05.12.12.13.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 May 2022 12:13:53 -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 v4 4/5] proximity: vl53l0x: Handle the reset GPIO Date: Thu, 12 May 2022 22:13:32 +0300 Message-Id: <20220512191334.61804-5-markuss.broks@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220512191334.61804-1-markuss.broks@gmail.com> References: <20220512191334.61804-1-markuss.broks@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@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, From patchwork Thu May 12 19:13:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markuss Broks X-Patchwork-Id: 12848049 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 60448C43219 for ; Thu, 12 May 2022 19:14:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358014AbiELTOT (ORCPT ); Thu, 12 May 2022 15:14:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229503AbiELTOR (ORCPT ); Thu, 12 May 2022 15:14:17 -0400 Received: from mail-lj1-x236.google.com (mail-lj1-x236.google.com [IPv6:2a00:1450:4864:20::236]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EAE4C277351; Thu, 12 May 2022 12:13:57 -0700 (PDT) Received: by mail-lj1-x236.google.com with SMTP id m23so7751058ljc.0; Thu, 12 May 2022 12:13:57 -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=eqvqGq9Z82oEF1qEGh1yx9lmGGvEQADLPFEeVY8PIpY=; b=Oj3EvGQ34k0DXRehSN9t1u1RTrvzp3dcB9qCIlXz1cW2niVqP5a63GgQF5/aNeqM5V xoT6L/8vaOo4Lz3a1SsVe2anShZJQv9Z0SjEicTWN4EcRF2TLNpHGMEk7+2BP+gItAUo Ub4tYlAWxCxhk0RHcpw1PJO15S4gAWkxDb080GUWzMoXIph/+ZoOCfJpTu7hRrF9TKvz Zrn6dhFtELmFnOmpZ7mRwXCmrQQdg1TbCBuARRaqzjWXLxh91yeSuGp+D6TNOwXXtKuy PeJaqC21aiOJN+Nw9W8MBuzjnkRSZZpqarH4MEvHfQPqBAdTMQysjPCeJptDMGvlW+d9 27ug== 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=eqvqGq9Z82oEF1qEGh1yx9lmGGvEQADLPFEeVY8PIpY=; b=FGUlQaGuw7E8khxKMLW+0ZgAMYseptgyZK31bMkKngrZ5/j0jgL6WMx5yBvu0CZvmT 2vinrPifKMdfAJPc0bDpPgqhO8xvCHacB7zs1fo2yvMgrjNc6DNZ0M0arEu0a3Dczf1B JdtUBo7N/zpRs4n/pey8PXGcI9FNY1pmmvF6h8L4MiZBgTYgF6tW8AOakt4h4vUQDHnz qYNzpnytdJt5udNVOcCPq2tMMSDwFmb/xDq3G65ba6iecgOlvgddbHH96WORDw975gy6 ZWOsKpPHP/iwh771+jI288u8xttwARzhYOlZ/pUgQ68+OBN0XkYE4TnzUMyn9kw7NQTH 4FjA== X-Gm-Message-State: AOAM531prM26cwo/LFsKLnKm+a6zwSqyNwCQjFDYTzkR4NKNAjP2rLz1 ADVBxFvS1rT5f9GvuhwJxZLOUTbu+HPvOQ== X-Google-Smtp-Source: ABdhPJzbF9eSPF1hlns9LPLPwVQf7Gmlrayz0fVOYafs+7dUkKjowsD5O/7A4Gi3HIEVF0B5CkiAFQ== X-Received: by 2002:a2e:9188:0:b0:24f:1a0d:6bbd with SMTP id f8-20020a2e9188000000b0024f1a0d6bbdmr878261ljg.226.1652382836208; Thu, 12 May 2022 12:13:56 -0700 (PDT) Received: from nergzd-desktop.localdomain ([194.39.226.133]) by smtp.gmail.com with ESMTPSA id y26-20020ac255ba000000b0047255d210f4sm62146lfg.35.2022.05.12.12.13.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 May 2022 12:13:55 -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 v4 5/5] arm64: dts: qcom: msm8998-xperia: Introduce ToF sensor support Date: Thu, 12 May 2022 22:13:33 +0300 Message-Id: <20220512191334.61804-6-markuss.broks@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220512191334.61804-1-markuss.broks@gmail.com> References: <20220512191334.61804-1-markuss.broks@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org This patch adds device tree support for the VL53L0X ToF sensor found on all Yoshino devices. Signed-off-by: Markuss Broks --- .../dts/qcom/msm8998-sony-xperia-yoshino.dtsi | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/arch/arm64/boot/dts/qcom/msm8998-sony-xperia-yoshino.dtsi b/arch/arm64/boot/dts/qcom/msm8998-sony-xperia-yoshino.dtsi index 47488a1aecae..4bd1039d983d 100644 --- a/arch/arm64/boot/dts/qcom/msm8998-sony-xperia-yoshino.dtsi +++ b/arch/arm64/boot/dts/qcom/msm8998-sony-xperia-yoshino.dtsi @@ -245,6 +245,24 @@ &blsp2_uart1 { status = "okay"; }; +&blsp2_i2c2 { + status = "okay"; + + proximity@29 { + compatible = "st,vl53l0x"; + reg = <0x29>; + + interrupt-parent = <&tlmm>; + interrupts = <22 IRQ_TYPE_EDGE_FALLING>; + + reset-gpios = <&tlmm 27 GPIO_ACTIVE_LOW>; + vdd-supply = <&cam_vio_vreg>; + + pinctrl-names = "default"; + pinctrl-0 = <&tof_int &tof_reset>; + }; +}; + &ibb { regulator-min-microamp = <800000>; regulator-max-microamp = <800000>; @@ -606,6 +624,14 @@ cam0_vdig_default: cam0-vdig-default { drive-strength = <2>; }; + tof_int: tof-int { + pins = "gpio22"; + function = "gpio"; + bias-pull-up; + drive-strength = <2>; + input-enable; + }; + cam1_vdig_default: cam1-vdig-default { pins = "gpio25"; function = "gpio"; @@ -613,6 +639,13 @@ cam1_vdig_default: cam1-vdig-default { drive-strength = <2>; }; + tof_reset: tof-reset { + pins = "gpio27"; + function = "gpio"; + bias-disable; + drive-strength = <2>; + }; + hall_sensor0_default: acc-cover-open { pins = "gpio124"; function = "gpio";