From patchwork Fri Dec 11 18:38:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephan Gerhold X-Patchwork-Id: 11969285 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6E4F0C4361B for ; Fri, 11 Dec 2020 20:12:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2C8542311A for ; Fri, 11 Dec 2020 20:12:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727324AbgLKSmX (ORCPT ); Fri, 11 Dec 2020 13:42:23 -0500 Received: from mo4-p01-ob.smtp.rzone.de ([81.169.146.167]:33289 "EHLO mo4-p01-ob.smtp.rzone.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728198AbgLKSmD (ORCPT ); Fri, 11 Dec 2020 13:42:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1607711951; s=strato-dkim-0002; d=gerhold.net; h=Message-Id:Date:Subject:Cc:To:From:From:Subject:Sender; bh=lntMdrL2vzHYJajzbCu4672DSUcaxlayS8rnWeVRSw0=; b=oLgJkq1lewSEdRLXc3b9xfnapBTT6u+/OFJLi8JxVmt5qbBVy5hGIV0kGnMIK4G2B8 4cWdxrxGstvt601Rs+AsSSHsgfK14NNWMtBu0ER26FxDpFSDpZEBuCFrF7lYcneKKL02 Oe4Bk/moQmKpzRWXvAENbMCuppfY3srbXazzIxl2TgdGo1s6fU4ESCpAF8gWAGkOyGNr KlbTDOarYZnaU+tUi8RsRlO7Efc54EUPzn69ogpgj+IOpIN1+iGwODVwq0elrtbrQemK 8a/vyDPdYL+iA64ZCLuzALSW+2we5r3Y/BP/GcBEs9DERLjtn2JLTD/c0a0n2FoS9IH4 1G1w== X-RZG-AUTH: ":P3gBZUipdd93FF5ZZvYFPugejmSTVR2nRPhVORvLd4SsytBXS7IYBkLahKxB626OARkI" X-RZG-CLASS-ID: mo00 Received: from droid.. by smtp.strato.de (RZmta 47.7.1 DYNA|AUTH) with ESMTPSA id 409b08wBBId34ec (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate); Fri, 11 Dec 2020 19:39:03 +0100 (CET) From: Stephan Gerhold To: Jonathan Cameron Cc: Lars-Peter Clausen , Peter Meerwald-Stadler , Rob Herring , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, "H . Nikolaus Schaller" , Linus Walleij , Stephan Gerhold , Rob Herring Subject: [PATCH v2 1/2] dt-bindings: iio: gyroscope: bmg160: Document regulator supplies Date: Fri, 11 Dec 2020 19:38:14 +0100 Message-Id: <20201211183815.51269-1-stephan@gerhold.net> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org BMG160 needs VDD and VDDIO regulators that might need to be explicitly enabled. Document support for vdd/vddio-supply to implement this. Reviewed-by: Linus Walleij Reviewed-by: Rob Herring Signed-off-by: Stephan Gerhold --- Changes in v2: - Split from patches for bmc150 - Add Reviewed-by: --- .../devicetree/bindings/iio/gyroscope/bosch,bmg160.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Documentation/devicetree/bindings/iio/gyroscope/bosch,bmg160.yaml b/Documentation/devicetree/bindings/iio/gyroscope/bosch,bmg160.yaml index 0466483be6bb..b6bbc312a7cf 100644 --- a/Documentation/devicetree/bindings/iio/gyroscope/bosch,bmg160.yaml +++ b/Documentation/devicetree/bindings/iio/gyroscope/bosch,bmg160.yaml @@ -19,6 +19,9 @@ properties: reg: maxItems: 1 + vdd-supply: true + vddio-supply: true + interrupts: minItems: 1 description: From patchwork Fri Dec 11 18:38:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephan Gerhold X-Patchwork-Id: 11969283 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3355DC4361B for ; Fri, 11 Dec 2020 20:11:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DD01F2311A for ; Fri, 11 Dec 2020 20:11:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732238AbgLKSmS (ORCPT ); Fri, 11 Dec 2020 13:42:18 -0500 Received: from mo4-p02-ob.smtp.rzone.de ([85.215.255.80]:32073 "EHLO mo4-p02-ob.smtp.rzone.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732504AbgLKSmD (ORCPT ); Fri, 11 Dec 2020 13:42:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1607711951; s=strato-dkim-0002; d=gerhold.net; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:From: Subject:Sender; bh=R9fci6EiMxdHKTGC3N1/vvheHR3a4vfxhujqbG75lBQ=; b=XpNnvlBI8lH7VY9OYgNGLzECpyLRoWm2Emyddd/lwuTDIvllIMYcH6EcTYQRIszCF5 pfps2waYv/ZbV8BAYSrcYmUmR8aCfigGF2htDRRsMrn6bz0iiDdskiGJY9fck2QYWjF6 o/480jsgmTe9pQSkE5m2TOWQZfAeXWEZgiRRiGiygZQljGfAQdzGMDhO+/pzViLtc4W6 lRWd6Nu4dmj3PolVwU8Mjm0oyE9zPSIjG+wukVNIam/jZEbR4B4HXY0um8FqU60+YJEN 4qLd4fTFZxxa5ZUqjeTphIPDQs49XCRyPe+uUKVoL8kWlvfFhKc0qU6RYLqg0O6tOsH7 W41w== X-RZG-AUTH: ":P3gBZUipdd93FF5ZZvYFPugejmSTVR2nRPhVORvLd4SsytBXS7IYBkLahKxB626OARkI" X-RZG-CLASS-ID: mo00 Received: from droid.. by smtp.strato.de (RZmta 47.7.1 DYNA|AUTH) with ESMTPSA id 409b08wBBId34ed (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate); Fri, 11 Dec 2020 19:39:03 +0100 (CET) From: Stephan Gerhold To: Jonathan Cameron Cc: Lars-Peter Clausen , Peter Meerwald-Stadler , Rob Herring , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, "H . Nikolaus Schaller" , Linus Walleij , Stephan Gerhold Subject: [PATCH v2 2/2] iio: gyro: bmg160: Add rudimentary regulator support Date: Fri, 11 Dec 2020 19:38:15 +0100 Message-Id: <20201211183815.51269-2-stephan@gerhold.net> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201211183815.51269-1-stephan@gerhold.net> References: <20201211183815.51269-1-stephan@gerhold.net> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org BMG160 needs VDD and VDDIO regulators that might need to be explicitly enabled. Add some rudimentary support to obtain and enable these regulators during probe() and disable them using a devm action. Signed-off-by: Stephan Gerhold Reviewed-by: Linus Walleij --- Changes in v2: - Do regulator_bulk_enable() immediately after devm_regulator_bulk_get() - Simplify error handling using devm_add_action_or_reset() --- drivers/iio/gyro/bmg160_core.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/iio/gyro/bmg160_core.c b/drivers/iio/gyro/bmg160_core.c index 2d5015801a75..029ef4c34604 100644 --- a/drivers/iio/gyro/bmg160_core.c +++ b/drivers/iio/gyro/bmg160_core.c @@ -19,6 +19,7 @@ #include #include #include +#include #include "bmg160.h" #define BMG160_IRQ_NAME "bmg160_event" @@ -92,6 +93,7 @@ struct bmg160_data { struct regmap *regmap; + struct regulator_bulk_data regulators[2]; struct iio_trigger *dready_trig; struct iio_trigger *motion_trig; struct iio_mount_matrix orientation; @@ -1061,6 +1063,13 @@ static const char *bmg160_match_acpi_device(struct device *dev) return dev_name(dev); } +static void bmg160_disable_regulators(void *d) +{ + struct bmg160_data *data = d; + + regulator_bulk_disable(ARRAY_SIZE(data->regulators), data->regulators); +} + int bmg160_core_probe(struct device *dev, struct regmap *regmap, int irq, const char *name) { @@ -1077,6 +1086,22 @@ int bmg160_core_probe(struct device *dev, struct regmap *regmap, int irq, data->irq = irq; data->regmap = regmap; + data->regulators[0].supply = "vdd"; + data->regulators[1].supply = "vddio"; + ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(data->regulators), + data->regulators); + if (ret) + return dev_err_probe(dev, ret, "Failed to get regulators\n"); + + ret = regulator_bulk_enable(ARRAY_SIZE(data->regulators), + data->regulators); + if (ret) + return ret; + + ret = devm_add_action_or_reset(dev, bmg160_disable_regulators, data); + if (ret) + return ret; + ret = iio_read_mount_matrix(dev, "mount-matrix", &data->orientation); if (ret)