From patchwork Tue May 10 20:42:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markuss Broks X-Patchwork-Id: 571582 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 245B0C4167B for ; Tue, 10 May 2022 20:43:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231899AbiEJUnb (ORCPT ); Tue, 10 May 2022 16:43:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231634AbiEJUna (ORCPT ); Tue, 10 May 2022 16:43:30 -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 8BE5728C9C8; Tue, 10 May 2022 13:43:29 -0700 (PDT) Received: by mail-lf1-x136.google.com with SMTP id d19so134585lfj.4; Tue, 10 May 2022 13:43:29 -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=9G++WF8LonnHZDYny2HgBv8zpOOV1ZfhnXecCxIdB/c=; b=oC1nDZJUIcoxmeJuf46XKLCdKsFVbv14mRDQ4TCbWRRZ/2T/blqq/pVinPV1MpNFRs Um1zTgcqa2xMflirwhsM0Qyk1k42MLQ6cgey3SEWNUppejuFdx5nMx2+NXuP0TlTg9dH qfqttfMMFg+eN/2I7aPeGYh1D+rdO2bgTt2aLhpYLLkJULM1XbGE+ilKZbnvEeMdSp8q 9dUNZo/woa+ChY6rQXCvA5hUAnqLqHxeKFN1XQ+pdzFqPGfkOz8ofMwh9IYJBF6J8FT0 H7n1QYqPAvtCCPVuU78xu/RQhGTacUyYqVpk/QzjS+Rb0Py6ir/RDSRYsxaa8aguH0kl b+RQ== 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=9G++WF8LonnHZDYny2HgBv8zpOOV1ZfhnXecCxIdB/c=; b=MspUPSbYxvzyiBKxyZDae8QtRJzjmZd7MjpAxLXu3nXqBwpH+BPekc4K1i13U7RYF+ byAxkn2YSyRO+hQR++Hq2wiV2AkwzBN+3JY6quaTnIGXlVIPlktI4qzpSjIeA9dKs2XS yNbHspvNdBu2snCbNRmofF13pEunN6hHiz3DFJT8HbRua/RXbC3QLBuQt25GTF2/h74i DKwFMx+Z1B/kTogEjbh6izQedaSdZX17irT3/5t3AmTqtatxV75K0lYzHf08Mg1J7fWR 43sXneFdd/qTtjS9hLwbfC1SBxF9yVIfa792byt4Z8pBm8tEtvEbnKnhoF8GpY7e9pWe Zq/g== X-Gm-Message-State: AOAM5305oS/kKEIpmVMFk+O2PziBmYPOMrApsCYehhm2I8n+I7TYRagv WvQDJD+itCAFeZJFjmFc1hviGJ3l0g0= X-Google-Smtp-Source: ABdhPJxKnWdhAbmEYBGFyTemRsJT1LJ2+kqjGBTzjHFMadp54oVMMqLucP1KgHZ5gnSqoem9VPazxg== X-Received: by 2002:a05:6512:21ce:b0:473:d8ac:6c74 with SMTP id d14-20020a05651221ce00b00473d8ac6c74mr17768519lft.63.1652215407629; Tue, 10 May 2022 13:43:27 -0700 (PDT) Received: from nergzd-desktop.localdomain ([194.39.226.133]) by smtp.gmail.com with ESMTPSA id 10-20020ac25f4a000000b0047255d210f0sm12318lfz.31.2022.05.10.13.43.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 May 2022 13:43:27 -0700 (PDT) From: Markuss Broks To: linux-kernel@vger.kernel.org Cc: ~postmarketos/upstreaming@lists.sr.ht, phone-devel@vger.kernel.org, Markuss Broks , 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 1/5] dt-bindings: proximity: vl53l0x: Document optional supply and GPIO properties Date: Tue, 10 May 2022 23:42:52 +0300 Message-Id: <20220510204256.8874-2-markuss.broks@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510204256.8874-1-markuss.broks@gmail.com> References: <20220510204256.8874-1-markuss.broks@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@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 Tue May 10 20:42:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markuss Broks X-Patchwork-Id: 571255 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 83651C433F5 for ; Tue, 10 May 2022 20:43:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232383AbiEJUnf (ORCPT ); Tue, 10 May 2022 16:43:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232153AbiEJUnd (ORCPT ); Tue, 10 May 2022 16:43:33 -0400 Received: from mail-lj1-x22f.google.com (mail-lj1-x22f.google.com [IPv6:2a00:1450:4864:20::22f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4CB52992C4; Tue, 10 May 2022 13:43:31 -0700 (PDT) Received: by mail-lj1-x22f.google.com with SMTP id m23so145051ljc.0; Tue, 10 May 2022 13:43:31 -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=eXCPt/BCWQaVDD9rbV4hb7V0FE0WUZ7GvSMXBVR120c=; b=pxzgFvp6acwOvgNddOLFZRG1lxSrrLCe99/hYdEaFl1c8+6qLdaza+X0MIAlK3BIwf gfIYx3vDyqctNQwMr7/tmZ8U/Mb2G0YcXVD0PWvSszaM5YZ5HgtvaHGm4Nhhn6SmOS8v h70U7st6uusAPkAbkwpan5yOiJcvy9+f1iz2hV1PPJiK6i6k8wEzXgkELqK19WFI0SnO Yc3S5YrK8OKqJqWAsOGbIF+JgR611y54OR96Qzxnhtml/nFgQSG/aPwNCpVmGCejkLCu k7p7i+tUboOkmWWqR3xyw53AdQLBW4AEdOTFXBF5PN813ChnUfmQ1GtjnjM/uJCMKa8y 4JsA== 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=eXCPt/BCWQaVDD9rbV4hb7V0FE0WUZ7GvSMXBVR120c=; b=ibPROZt/TUQ/CvEj5KLXGZNFzIHuzRa/6ij+20ARUCzkKhNO1xd7uzzpyA184AxD6Q FxnZ+6XNA7HinFCOLVVUvoWsDsIjunVd06PhEdD++FMXU9DOLTyy5cIM0NkdxmiCyYk2 UIWa+kS4Clbo/gqs/jIkMNSFUJM16Z3CXm0pArNvdyTvIQikpichhzDBlmE+yOs8YLtg uoo2uTUB7ZknJEFft2xzRImQL9tBjBUYg+e3C1f1fBb47GvWf4YDtyPUf9+g6li58rW1 pa8EY7gIhwLpRV7/Cy52/ae3mW2YlalgSY9Ki7ZYJyAtCKVxxqcwPeTzRDUHtt0ghgK/ fROw== X-Gm-Message-State: AOAM533QT7Q2b5IpCHjzCNFRGtfUUsXAXqEDzPNIsrBUGGC2TMmojBUP KvGN2zlTa+A5w1gQGtoloerBhvM/M6M= X-Google-Smtp-Source: ABdhPJx9V6wKlWDNYvW6dRNPYyeqSRxTsXBfCqNQ5UddIxk/sEEaqrHlndS1k/gqRBnjTrBhL2Bo6w== X-Received: by 2002:a2e:9943:0:b0:24f:fe4:4326 with SMTP id r3-20020a2e9943000000b0024f0fe44326mr15043420ljj.18.1652215410026; Tue, 10 May 2022 13:43:30 -0700 (PDT) Received: from nergzd-desktop.localdomain ([194.39.226.133]) by smtp.gmail.com with ESMTPSA id 10-20020ac25f4a000000b0047255d210f0sm12318lfz.31.2022.05.10.13.43.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 May 2022 13:43:29 -0700 (PDT) From: Markuss Broks To: linux-kernel@vger.kernel.org Cc: ~postmarketos/upstreaming@lists.sr.ht, phone-devel@vger.kernel.org, Markuss Broks , 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 2/5] proximity: vl53l0x: Get interrupt type from DT Date: Tue, 10 May 2022 23:42:53 +0300 Message-Id: <20220510204256.8874-3-markuss.broks@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510204256.8874-1-markuss.broks@gmail.com> References: <20220510204256.8874-1-markuss.broks@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org On some boards interrupt type might be different than TRIGGER_FALLING, like hardcoded in driver. Leave interrupt flags as they were pre-configured from the device-tree. Signed-off-by: Markuss Broks --- drivers/iio/proximity/vl53l0x-i2c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/proximity/vl53l0x-i2c.c b/drivers/iio/proximity/vl53l0x-i2c.c index 661a79ea200d..16f809c479cb 100644 --- a/drivers/iio/proximity/vl53l0x-i2c.c +++ b/drivers/iio/proximity/vl53l0x-i2c.c @@ -61,7 +61,7 @@ static int vl53l0x_configure_irq(struct i2c_client *client, int ret; ret = devm_request_irq(&client->dev, client->irq, vl53l0x_handle_irq, - IRQF_TRIGGER_FALLING, indio_dev->name, indio_dev); + 0, indio_dev->name, indio_dev); if (ret) { dev_err(&client->dev, "devm_request_irq error: %d\n", ret); return ret; From patchwork Tue May 10 20:42:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markuss Broks X-Patchwork-Id: 571581 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 90883C433EF for ; Tue, 10 May 2022 20:43:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234015AbiEJUnj (ORCPT ); Tue, 10 May 2022 16:43:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233561AbiEJUni (ORCPT ); Tue, 10 May 2022 16:43:38 -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 3158829ED0B; Tue, 10 May 2022 13:43:35 -0700 (PDT) Received: by mail-lf1-x131.google.com with SMTP id t25so112737lfg.7; Tue, 10 May 2022 13:43:35 -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=YT/2zj6suok1QDPY2bNDHH8fszKu/6jV8dkbTQl6UTo=; b=qLjQHVz7SB6ayG/YauYW+iRkvnUbR1G3ZSxQTY3sDPoHZXzrYzRghU0Vbpq4+rTKMa /dKKmGAvCtf6JnOomM5ZxTVgOSdRk5nE7Aurh70Xeqdr1jt+0qvQwOGJxODrd1/9zICl 2RugQBpjY2JN8DKkIVtIPOsoOsFpQhwyI64thQW8OIX9s35UcxZOQVz7O2Inqw35bNXL GKzMFcN+R5wjwl9JFIWcyWJ5t9MAoB8Dwrh0C0T3z0+Ea6UE8oTK/AyIUFu6Ol+qV5aA AfQ4lO0MaB/C5BZxnJai8lLEnhGTorzpk2zM9f8GNIzQSGL6tz2cyNrUEyd+hTVSTu7i 3eUA== 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=YT/2zj6suok1QDPY2bNDHH8fszKu/6jV8dkbTQl6UTo=; b=xp8RlcDl0ArEfovlC/Kwq9rcK0IIJYl87Hrr6DvzhrVUJi1Ziu5bdRtWjKu3EaeGSQ R8E/T4/NiCugBELgKDss4DCWkAna+dmyV32In+jikx0zBcVshjogFpd6RQn9o7Xn49eV XiKOgdECxYCdgE/JWLeUaWl+lmpfSzkPbkezfu3WIC/z31bNl1Zu1PpIGcyfnqPAgckP xvrEh1gYE09TrII5E4rLM6+HQsTQZB+L69GnZiUNiH7K1hCoRvFVKJJgGCv5tBpH7FIP AgS6Lpn2Qrkbc797MjTFQ6JltugGVRhWJA5/xZ3t/q5IZGv7OHworPWfiwafVef+i+Io huNQ== X-Gm-Message-State: AOAM533GOLY+tNWLfRXVp6nHX7qmNgdBEx8yrdLtQq6mc0zCsjEtzgtv gKzt6AgyMwe5bwWD1jyP21K4r/P0wtc= X-Google-Smtp-Source: ABdhPJyk4e6hgqMSDo7OtbvC1MxjCu5xhbhE59OA6EsLjixjjRU3Y9S90Cg1BgaOto5W62qaKYru6A== X-Received: by 2002:ac2:5f84:0:b0:471:fd0f:a6e7 with SMTP id r4-20020ac25f84000000b00471fd0fa6e7mr17285738lfe.41.1652215414042; Tue, 10 May 2022 13:43:34 -0700 (PDT) Received: from nergzd-desktop.localdomain ([194.39.226.133]) by smtp.gmail.com with ESMTPSA id 10-20020ac25f4a000000b0047255d210f0sm12318lfz.31.2022.05.10.13.43.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 May 2022 13:43:33 -0700 (PDT) From: Markuss Broks To: linux-kernel@vger.kernel.org Cc: ~postmarketos/upstreaming@lists.sr.ht, phone-devel@vger.kernel.org, Markuss Broks , 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 3/5] proximity: vl53l0x: Handle the VDD regulator Date: Tue, 10 May 2022 23:42:54 +0300 Message-Id: <20220510204256.8874-4-markuss.broks@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510204256.8874-1-markuss.broks@gmail.com> References: <20220510204256.8874-1-markuss.broks@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@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 16f809c479cb..74aeb2548ef6 100644 --- a/drivers/iio/proximity/vl53l0x-i2c.c +++ b/drivers/iio/proximity/vl53l0x-i2c.c @@ -42,6 +42,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) @@ -187,10 +188,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) @@ -205,6 +227,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 = 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"); + + error = vl53l0x_power_on(data); + if (error) + return dev_err_probe(&client->dev, error, + "Failed to power on the chip\n"); + indio_dev->name = "vl53l0x"; indio_dev->info = &vl53l0x_info; indio_dev->channels = vl53l0x_channels; From patchwork Tue May 10 20:42:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markuss Broks X-Patchwork-Id: 571580 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 6AEEEC4332F for ; Tue, 10 May 2022 20:43:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234696AbiEJUns (ORCPT ); Tue, 10 May 2022 16:43:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234304AbiEJUnk (ORCPT ); Tue, 10 May 2022 16:43:40 -0400 Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [IPv6:2a00:1450:4864:20::12f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80D152A0A63; Tue, 10 May 2022 13:43:38 -0700 (PDT) Received: by mail-lf1-x12f.google.com with SMTP id i10so66143lfg.13; Tue, 10 May 2022 13:43: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=vjdss2nDLwTNuuaVgZiKsX3zSboMMew4d/2NFU3vAvY=; b=dNSTjHEou78efjVQDZSF5xKhdufKPu0FPhaijaVB6PNcvXextvCJazQhEaa+Sr7dvK stcTpMC0bqq7DCIIMPQJR6LUZjI4f8FVT9fajtdbdtmFC8dyVCAhKl1DnDfhJoL+6vAP X8obXslZQTwoP4Fj+rKcHBa3AAMOoFL99htU7HD8cCO2/Ytx+CaZxGeBq2XH/++5jQPi u964htH01eIC8ayJE8r3Abr6KHZT8zr6tjaEcdZs07yragttLOswLRPBVZcrJXk7VwE1 1FvvhyXt+NbmPmc+XyRraSBZHrzKuH93ZnybcxUlq0bgDO0Fb/fdgVKkbVMgcTJXv/Bk AxYw== 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=vjdss2nDLwTNuuaVgZiKsX3zSboMMew4d/2NFU3vAvY=; b=AxjXXAhb2Bvb/QNWhRIVLmPsK80eaNs8g2pOCS7oB/Jyq2V/r9YW2KYB2FqobuK/HQ IdQV/J8FflywsB2vcr8bYXqVCMjG7cuSjk8X7Nupke5fz3+U5366MUyCsdCQ6vkhAZbB XV3SMNIdirrr7tNoXdE68gkzN6e3UANK+GxdUu2Uwl2+/PCQC339lIV62T9JKvNCso3m nt4P9xQKRbsV5KOq5anJdkVRc7j3IJSJk1tACtloB7eQS3GKrFuaey2dvhymO8QIcMD8 plgOS2GhhPEcWFkSsLAUnmNx6foniUAxShbmRXR3vZVxXvARkSS9r1qQ5OKgdlXliuUT u6mw== X-Gm-Message-State: AOAM53338BWP81anVu+qb0NCUGZRsT5LP07No81SSBBK6N8UMGJ5sMG8 BNbeQht8a8zqioWTxiI5VDM4Q1osdhY= X-Google-Smtp-Source: ABdhPJwLOJTxRIuT+ffLy8rAJ16AGYPcZ4VaS2+jMJIGEtDE+09rH7E3kdOnw1mneeYjtGnTGbjfXw== X-Received: by 2002:a05:6512:3390:b0:472:1a4d:ad14 with SMTP id h16-20020a056512339000b004721a4dad14mr17763054lfg.521.1652215416724; Tue, 10 May 2022 13:43:36 -0700 (PDT) Received: from nergzd-desktop.localdomain ([194.39.226.133]) by smtp.gmail.com with ESMTPSA id 10-20020ac25f4a000000b0047255d210f0sm12318lfz.31.2022.05.10.13.43.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 May 2022 13:43:36 -0700 (PDT) From: Markuss Broks To: linux-kernel@vger.kernel.org Cc: ~postmarketos/upstreaming@lists.sr.ht, phone-devel@vger.kernel.org, Markuss Broks , 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 4/5] proximity: vl53l0x: Handle the reset GPIO Date: Tue, 10 May 2022 23:42:55 +0300 Message-Id: <20220510204256.8874-5-markuss.broks@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510204256.8874-1-markuss.broks@gmail.com> References: <20220510204256.8874-1-markuss.broks@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@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 74aeb2548ef6..47022bc1504e 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) @@ -192,6 +194,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); } @@ -203,6 +207,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; @@ -232,6 +238,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, From patchwork Tue May 10 20:42:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markuss Broks X-Patchwork-Id: 571254 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 CE0EAC433FE for ; Tue, 10 May 2022 20:43:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234506AbiEJUno (ORCPT ); Tue, 10 May 2022 16:43:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232300AbiEJUnn (ORCPT ); Tue, 10 May 2022 16:43:43 -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 A9B312A18BC; Tue, 10 May 2022 13:43:40 -0700 (PDT) Received: by mail-lf1-x131.google.com with SMTP id j4so105643lfh.8; Tue, 10 May 2022 13:43:40 -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=kNyzKurbPrxNPFTdAAgyBjoxC65yJEaBohozFWfbO8U=; b=MkivjYRzDuzS2/9WoTfim0TKZksKggjcT/NnEsxlY0gcvVmkScTZ9D00cHiAZtwY9L C4MEimAE5OFAMg2xtboztW08BPfZYX7Yh3pu0gswb/Gh5EwKvZ4PN+JsvsE4ddhmwUmC vVcHYqcMMT0u0C3N6tIUAOZfYxCBcDviSqXktA8e0jZ6l47ua77GWLQrW90bPeG5zPDY +Zzge3QipIDNhgzCIILJtZNYbp/VK2giQ6cl6txIge9Z0qUqFUKs5v0+2w/KW9XC5Xd6 2MGmJJ7LUGno3dMt1jqnHHFGRG8mDzW0AI7vKD3LQz8461gZfJDjGaMB99tS4AgMaqyu BGCw== 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=kNyzKurbPrxNPFTdAAgyBjoxC65yJEaBohozFWfbO8U=; b=bfEELkBAHHashUH/joWgYZ4vGBj6ZtnF4dzyUJZdf6UwGJzQPtYzR9Al7ZH0fzw+xt 4JsaMUNu4qY22qKPGLovrAnoNDqhaMPEgawNLWN/4i7sA5ffxBM2qPQO1F/eFG82V5ie r3muZQxrLSIXxljTVva3fz1tUvlGjL1DqA9oYwYhkD+p8RWPVrONue0ZbS1npzZiTPDb 3d8RaYJ81JE77CtbH0aDUq4Sv5tqSdjrQ0RJ6AoXeqaUKtYxehHOSKMQwef9HzkU/ndV e5R5etu7ZpTLDsDOkE7XGikCzXJ5wUFGHR/pM6fokX5491Y8G9OMG7hcY+zwB1hHL+e/ PrmA== X-Gm-Message-State: AOAM532eSVqCzJXXIR1M+x82A+prU8z+wSRQ91XV4LrLwvqDN1RSSOL2 gGW8ioRUZM4Q0q/iqtgMhab6MvUMB2E= X-Google-Smtp-Source: ABdhPJzo8xn+gwcZMe/h9a6hbjpdTPWX9/w09OOLktAb5Wge6VMamsyXgosvvAti605Jo2aTxpP3nA== X-Received: by 2002:ac2:48a4:0:b0:471:fc7f:b54d with SMTP id u4-20020ac248a4000000b00471fc7fb54dmr17933084lfg.538.1652215418812; Tue, 10 May 2022 13:43:38 -0700 (PDT) Received: from nergzd-desktop.localdomain ([194.39.226.133]) by smtp.gmail.com with ESMTPSA id 10-20020ac25f4a000000b0047255d210f0sm12318lfz.31.2022.05.10.13.43.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 May 2022 13:43:38 -0700 (PDT) From: Markuss Broks To: linux-kernel@vger.kernel.org Cc: ~postmarketos/upstreaming@lists.sr.ht, phone-devel@vger.kernel.org, Markuss Broks , 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 5/5] arm64: dts: qcom: msm8998-xperia: Introduce ToF sensor support Date: Tue, 10 May 2022 23:42:56 +0300 Message-Id: <20220510204256.8874-6-markuss.broks@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510204256.8874-1-markuss.broks@gmail.com> References: <20220510204256.8874-1-markuss.broks@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@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..ba85177bdb1c 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,23 @@ &blsp2_uart1 { status = "okay"; }; +&blsp2_i2c2 { + status = "okay"; + + proximity@29 { + compatible = "st,vl53l0x"; + reg = <0x29>; + + interrupt-parent = <&tlmm>; + interrupts = <22 IRQ_TYPE_LEVEL_LOW>; + + reset-gpios = <&tlmm 27 GPIO_ACTIVE_LOW>; + vdd-supply = <&cam_vio_vreg>; + + pinctrl-0 = <&tof_default>; + }; +}; + &ibb { regulator-min-microamp = <800000>; regulator-max-microamp = <800000>; @@ -621,6 +638,22 @@ hall_sensor0_default: acc-cover-open { input-enable; }; + tof_default: tof-default { + tof-int { + pins = "gpio22"; + function = "gpio"; + bias-pull-up; + drive-strength = <2>; + input-enable; + }; + tof-reset { + pins = "gpio27"; + function = "gpio"; + bias-disable; + drive-strength = <2>; + }; + }; + ts_int_n: ts-int-n { pins = "gpio125"; function = "gpio";