From patchwork Thu May 12 11:07: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: 12847556 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 14B77C4332F for ; Thu, 12 May 2022 11:08:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352933AbiELLIN (ORCPT ); Thu, 12 May 2022 07:08:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352932AbiELLIN (ORCPT ); Thu, 12 May 2022 07:08:13 -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 1B05D5909E; Thu, 12 May 2022 04:08:12 -0700 (PDT) Received: by mail-lj1-x22f.google.com with SMTP id bx33so5995070ljb.12; Thu, 12 May 2022 04:08:12 -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=c4V9o+Jxv+zOb/F7gW91hyqUvtudfaiPoXkKadxAX84vmRi1fbwpFL5snNXjF7Yqvl pKauhetWIR4Ytczc8H1urVflXo8ZQycYZ+URx1cvCgv0liGoahgzwqWYPh56LwJG21QN 1xZSF0ZmkhI96gMkmZU2y7KHFYspnbLGhmcFEifKntdIdSeiADmlK4dbEjk3995mFtvd 9NQ6AigabDHU0n7XI0hjWXgi4YU0k/L7Q2eNWrDlhZbxaEyJ08OO3P1RNaP1vgsXMll6 m9AUAngt9bZZ77KgOYjGSOUqRnTbigQdViUK5sAD9fEbARvtFpLsG9c4Fbdyd5+3pyYH t5nA== 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=CHQRnY+nFyy5+PzdAe4y757+K5SmpwamJi7moggD6uQhV1zz0a/dgYKkw+XyNdNEkd NZdOlxsDBIXk28vYZXHY+ecOrdjLLj6RK8F30ubg8T1iRIXg0tUAVLGOg9r1Qo/oHVse r6qooNukMnG49ZU3UA6pn9yTpNhuObTaPvrf0lcjfwU5P4X3VUjVbzyf3dhveBhbxVII nRs3bCFMfetUQHuCLeQ9suWCjudqaCeKA9qnPbAAZ1G2eG+aC6IW5pMwBF8kP/sg+XhM VvqX672XN3r8aSc/jQCahJoQqYERMRHiiSBq4jK7/0xCrkv6/R8kEcyFPAbH8t5bF8SC a6uQ== X-Gm-Message-State: AOAM530gK7QbLAwMT8KWy2BwW7Ruk6tf5/2T7vsXf+f01LaBYx1Q0kQe ztyRzLDQxO17vVQhIGmbrzwX/W7smIXZmQ== X-Google-Smtp-Source: ABdhPJy18TGMOg+yPftQxJW3NaDDQItQcGQToqnlWJYapGphiv325b7X9LdAqaINS7qGigPpAUC6Qg== X-Received: by 2002:a2e:a23b:0:b0:24f:b6f:6fe7 with SMTP id i27-20020a2ea23b000000b0024f0b6f6fe7mr19978763ljm.67.1652353690196; Thu, 12 May 2022 04:08:10 -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.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 May 2022 04:08:09 -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 1/5] dt-bindings: proximity: vl53l0x: Document optional supply and GPIO properties Date: Thu, 12 May 2022 14:07:53 +0300 Message-Id: <20220512110757.5297-2-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 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 11:07: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: 12847558 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 AFAFEC4332F for ; Thu, 12 May 2022 11:08:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352951AbiELLIR (ORCPT ); Thu, 12 May 2022 07:08:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352949AbiELLIQ (ORCPT ); Thu, 12 May 2022 07:08:16 -0400 Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91A125A149; Thu, 12 May 2022 04:08:14 -0700 (PDT) Received: by mail-lf1-x12d.google.com with SMTP id j4so8385883lfh.8; Thu, 12 May 2022 04:08:14 -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=mPqiMrXeK4HnnnYLILMVdVz6G+KLueUOtuBBRc8khXWG+VWTgokg2wmRpxEonf7fXj RaAO5LkIr3zSkwWZm/1NRClO29iKUaBiuPX8VqQ/nKB1rdDo3UZyBT/KUVL8OJ6SqeAO ctR3fT9GnBPiISnLEjEklkrOMXPGX0NgfgGC/15I18HyE0Tz6cVeeeCNRZOu+h9sqzTu 8Nhh6Fxt8WkugIdGBr8x9EtlC6jfjRLvA9ZDYED+jMHVDnRmG3onW98keh4xWx4VAsva YtlonFN5CfNNg0rnjzkZ4NWZ2wT/SBtaMLmBuGxABitF1imb1IzgTEfSV5iXh+y8/v5w FTzg== 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=kWf3Dn+C6+sFXx6PmzPdclABJ01TEupCWmVzB+qc2SaGL0bf4iYvS9+VfLPfjbHRUS N5vrQ9Kl7YJwyxD72/xMhDSwX3oclw3ETcPH8P51q2ukAErWm4F9Myj76VaJN/DZJvxZ XTSYxgGLiOvb3z+x9LQSePfY5XYJ6WUyv60L3UeroCub9jnxrltO4bu+9/ytBJsywMbH zLLMJJ+oHW2kMSyueaYV97+3fCF5uFe1lVnpzWrNkg5f68L05pRQaiabNI+2qh1BEpPM r0x//pRNEy3BmG5nVG2TTIfnipyGgqJaZWJ+u8hQUyFoBcZIDNRmxHFD5QU+buRncPhF TGFQ== X-Gm-Message-State: AOAM531gD9s7gj53GzfXNUqEhYHXLO4xrG8/IEHtnKbXmv5NthaoTIcy KwWGuVAg4P8vz052BPWRSOtZaWZu2BkOEw== X-Google-Smtp-Source: ABdhPJxHj4PJYumxcThltMWUtADbZwvzyluCMLfWyn7BXJRkEDqHJ2KLchQwfXmhmSkcO4+2tSOK4A== X-Received: by 2002:a05:6512:33a7:b0:473:ea35:e1d6 with SMTP id i7-20020a05651233a700b00473ea35e1d6mr24496586lfg.369.1652353692831; Thu, 12 May 2022 04:08:12 -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.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 May 2022 04:08:12 -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 2/5] proximity: vl53l0x: Prefer pre-initialized interrupt flags Date: Thu, 12 May 2022 14:07:54 +0300 Message-Id: <20220512110757.5297-3-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 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 11:07: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: 12847561 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 58639C433FE for ; Thu, 12 May 2022 11:08:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353012AbiELLIb (ORCPT ); Thu, 12 May 2022 07:08:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352975AbiELLIa (ORCPT ); Thu, 12 May 2022 07:08:30 -0400 Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23F795AA66; Thu, 12 May 2022 04:08:16 -0700 (PDT) Received: by mail-lf1-x12e.google.com with SMTP id d15so8413239lfk.5; Thu, 12 May 2022 04:08:16 -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=Rn+hZ1SORWL9uzL+yqm22z/NAwpZAv/juhns1YUGhh8=; b=ajU/1KslDh5E/JvduAifp/STGz5uzWKx00qJ8v53ttzKhbo9OG3iAW8XCQ+nAxTqzd ObDea9lIRsmxwKOXsIMP66Yn6U+ir+TM4Sw9TWaHTHVkfxN4BC5L0PI6JPVUKV1Z6oKf a/fIv2yTNeSqMgk8CNEBbkqEag6f2sa4BV5zj5LT9gQ+mzqJcz1p597Op10gRczAymH6 7bA3+DYGB8baVyqOGzlnSTNSmmHa9aex1za0ujck3B1c5QkN5C3c8K7kJKwEbOta4KAt Abxlk3XfUP5hAusIpx3qweO7sZcvk8jQI/6RscwjcXixXBqEMX1YQ1BiARkaC51R9IcK lZhA== 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=Rn+hZ1SORWL9uzL+yqm22z/NAwpZAv/juhns1YUGhh8=; b=pxVqao5/5kNTe2oa7d2Z/2lQMytftfMZ2ZNM8x48Lep40OwkrSOlKRqNZ2jVFKpUrr YqoMHPwYjHQduGoJFvpRRsr8mb9FcUSyQveM+g0AOiBFOXmOWtkZA4ZvWcqdKK+L+cMH oolwuKAgrL+SxCkW+OAmY9QrOrkPO52DiE0vtmXCiBSUreQ496XBMnXaFLAKem6MwN1I 9bAbkt6NxUam0Po2Ut78j93D3C0zeKseu4PQcFcFDU46+Fhm/A3n7W+JnPPIB+l8A4u3 2xU+/RgQEMAJUUWxU9r3Kbyaqz7qd+YcD06jfovJRoKAiHrZAkMqTCybYehqgq+C89Iu mkuQ== X-Gm-Message-State: AOAM532nEYgIZqF9LuM6KyMOJj9ZdzFpsY8EYo0AAFkxyKvawI8pBlv9 oi7Hzfei9UPq3cBrGH1gHn05j/MKBiexqA== X-Google-Smtp-Source: ABdhPJzenfz08JbIBgzG3TB5G7pZLDp9lLFOqPJZCCjMTNdZga3+bPCbT4u8p3xtmKlv/5XCyKf+/Q== X-Received: by 2002:a05:6512:3d1d:b0:472:625d:b21e with SMTP id d29-20020a0565123d1d00b00472625db21emr23991992lfv.366.1652353695101; Thu, 12 May 2022 04:08:15 -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.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 May 2022 04:08:14 -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 3/5] proximity: vl53l0x: Handle the VDD regulator Date: Thu, 12 May 2022 14:07:55 +0300 Message-Id: <20220512110757.5297-4-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 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..d8523e3981e8 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 = 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 Thu May 12 11:07: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: 12847559 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 188B1C433FE for ; Thu, 12 May 2022 11:08:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353024AbiELLIc (ORCPT ); Thu, 12 May 2022 07:08:32 -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-Google-Smtp-Source: ABdhPJzJ6moCcfNylhZKc150gNUcy3ILRU+95Eo3tbpylNCKdRplmHXnaNaT730MloGNdz/49Derow== 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 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 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, From patchwork Thu May 12 11:07:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markuss Broks X-Patchwork-Id: 12847560 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 07E8AC433EF for ; Thu, 12 May 2022 11:08:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353034AbiELLId (ORCPT ); Thu, 12 May 2022 07:08:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352979AbiELLIa (ORCPT ); Thu, 12 May 2022 07:08:30 -0400 Received: from mail-lf1-x132.google.com (mail-lf1-x132.google.com [IPv6:2a00:1450:4864:20::132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C30145D199; Thu, 12 May 2022 04:08:21 -0700 (PDT) Received: by mail-lf1-x132.google.com with SMTP id d15so8413609lfk.5; Thu, 12 May 2022 04:08:21 -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=qjFTO1D1EZDKKiJccbHJv6i5BuHy5bt8K51ddMuen78=; b=h9FmGSg4bI11T8kP5bLEDH1qqYkFrt3qTZmcdAjTGFQYt9wQXbDKgOqXfC+JYpujXu FvdC96vgRZ1QQoyFPFGTqC5H7q5SEqo/pxrG35EEu7sw1THgssiDtIfZddVWlppwATMF DQEcV7Ttr4YPAcbRZ5hP+XQc3FGqFBe6NMMZIDdYjkxfj/p7nriaquFmDWv2jZtJpE4o GLokkOOzk241QdGAVo2xcwKTQmkWPpLL7IzNrzLdWUMJPyE3HkIsduyM9x2hUfak6k2t GFpyRdam+7vpsdR41RAjGuTgycZ+SJJBSwxeO+luDitt0YnUk+GGn4sZhPnX5FdWHt/B wORw== 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=qjFTO1D1EZDKKiJccbHJv6i5BuHy5bt8K51ddMuen78=; b=EN01Dir/xyhAvpyvCYtXjza1Pz+sX6AWShnVNPryberhQCEgo7eBC6j0SBNa8cwIWF UTewxjsPGJ9gJBiLPbRuRp+oVxmM2qcR35F/aA3qsLnYliMZ2OYILfQ+FkIQxuouu54E eaPqsKX/9QLRgqzWl5akU2lMOiYhZkzwAW3cmIKfbkxlGW8mb7oG67KPEBStuBUaR/Cx j+3+w1Jmk8XV0ZUWAzml6Yi8pQZYoaW7eqCQpyDK3W1cnn8Ke0yU9O0bsvGfZ8a5osoO 9edDiIFOnsTZud/leJ1GcKG+eLZYatqyQwH4DyhNE+kZ4kGZujed/KynkgiZD5tKqJqS 3jvg== X-Gm-Message-State: AOAM531TVkfVbnQ5wyR9xtghk9ueN/4Nc2XoVY5CNr4IWEaZhpSQrYNJ r9+PBcXtdxuTpicolpiC9j72QbgewD0dUg== X-Google-Smtp-Source: ABdhPJzV29F8YQmt876AcPMunxt7RvQwAWEqhPI/M867EYQL1xSd6Z1fcha4gXmGoRf9vbMonoSd1Q== X-Received: by 2002:a05:6512:3a84:b0:473:de2d:ae1 with SMTP id q4-20020a0565123a8400b00473de2d0ae1mr23442455lfu.371.1652353700039; Thu, 12 May 2022 04:08:20 -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.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 May 2022 04:08:19 -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 5/5] arm64: dts: qcom: msm8998-xperia: Introduce ToF sensor support Date: Thu, 12 May 2022 14:07:57 +0300 Message-Id: <20220512110757.5297-6-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 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..a95fa29aa18b 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>; @@ -621,6 +639,21 @@ hall_sensor0_default: acc-cover-open { input-enable; }; + tof_int: tof-int { + pins = "gpio22"; + function = "gpio"; + bias-pull-up; + drive-strength = <2>; + input-enable; + }; + + tof_reset: tof-reset { + pins = "gpio27"; + function = "gpio"; + bias-disable; + drive-strength = <2>; + }; + ts_int_n: ts-int-n { pins = "gpio125"; function = "gpio";