From patchwork Mon May 18 13:33:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Albrieux X-Patchwork-Id: 11555437 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 65CDE13B4 for ; Mon, 18 May 2020 13:35:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 44F9B206D4 for ; Mon, 18 May 2020 13:35:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="eMjfb8BK" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728028AbgERNfy (ORCPT ); Mon, 18 May 2020 09:35:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727020AbgERNfy (ORCPT ); Mon, 18 May 2020 09:35:54 -0400 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF4D3C061A0C; Mon, 18 May 2020 06:35:53 -0700 (PDT) Received: by mail-wr1-x434.google.com with SMTP id h17so11869818wrc.8; Mon, 18 May 2020 06:35:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=g2sU/s3ZSgjmLzLMit0zw8xym5bMpksqrVvGb7EuMnM=; b=eMjfb8BKGAZ1UmdHEm8O/cSaVyhnsH/i8E9JMXEmCfcyGud9ZXHioRN7RNFmlryNtV p5UV1Mupf+Qwo1Ifq3mKuIX1IRSaJ2CW78Sdy32L7+Uw1Vme7b/rdbPEJWg52q7dpZXa zsENe+BhhE4wSNT9kqQ6Z/LXG5Zh2WTcEOD70t/WrqlhdENVtO993DbLnt9hbTY7Syy3 YLu/JpeqQB86hJ6qJp5gzUBYTwvbJ9HzGFHzSHSaFHEmFrXaTKEJ59rnbAqZjavO+dDQ U7mpevRGmDB7fCcW3kEFyo57eZDZK2+n4GnV3XxNQS5dRLOJpr2aIENhZnLdMNvxC1gd KavQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=g2sU/s3ZSgjmLzLMit0zw8xym5bMpksqrVvGb7EuMnM=; b=kRSSt5urvYF6nEkGiM9Gm3fY3lDJ/ZQaFk5c8UJW7H9xphTHX7APtSN+Pw/NNwh063 C9/wHWt4tYAD2QdB8oH5Xca9qtJYi/bsZ3TY4s/9qrJ+c/KBHFko0zi4BUgOaZNPG97t UJZq5+hyyG5TTqUJqX38c0D6x0jx5pAVj0pdfD0zLOXfzEkPK67u3gAM8ZhfoCmfzYdy PMyf9Hdg9vYwJnfWiWMEgDi5audjR29CZeyvIrFbslbngZ2+c3MjIIHgPCzyxzhIRLFO q1UKl7P51S3+k463GVQy1YPZAuQepw+pWsalQtfUWaZxWAc27LfIpjuRgWK47Zwa5BGk Zmdw== X-Gm-Message-State: AOAM530zf8QCSx7y4XG1U84RzEDK0HPs0idVYy/GlrUrViKbP6dw3fRq ubMQmc+9hvJVcGbvA7ZCFeIXS4naAuc= X-Google-Smtp-Source: ABdhPJzNYw5WdYgdi00rZYY4RzTlzfhOnaEdN+KwkegHscxy/wtw06vVgm1+CrAPBJ8YcK37bCsbFQ== X-Received: by 2002:adf:df12:: with SMTP id y18mr19055474wrl.94.1589808952095; Mon, 18 May 2020 06:35:52 -0700 (PDT) Received: from ict14-OptiPlex-980.kataweb.it ([178.23.248.46]) by smtp.googlemail.com with ESMTPSA id l19sm17086772wmj.14.2020.05.18.06.35.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2020 06:35:51 -0700 (PDT) From: Jonathan Albrieux To: linux-kernel@vger.kernel.org Cc: Jonathan Albrieux , devicetree@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS), Hartmut Knaack , Lars-Peter Clausen , linux-iio@vger.kernel.org (open list:IIO SUBSYSTEM AND DRIVERS), Peter Meerwald-Stadler , Jonathan Cameron , Rob Herring Subject: [PATCH 1/4] dt-bindings: iio: imu: bmi160: convert txt format to yaml Date: Mon, 18 May 2020 15:33:45 +0200 Message-Id: <20200518133358.18978-2-jonathan.albrieux@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200518133358.18978-1-jonathan.albrieux@gmail.com> References: <20200518133358.18978-1-jonathan.albrieux@gmail.com> Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Converts documentation from txt format to yaml Signed-off-by: Jonathan Albrieux --- .../devicetree/bindings/iio/imu/bmi160.txt | 37 -------- .../devicetree/bindings/iio/imu/bmi160.yaml | 84 +++++++++++++++++++ 2 files changed, 84 insertions(+), 37 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/imu/bmi160.txt create mode 100644 Documentation/devicetree/bindings/iio/imu/bmi160.yaml diff --git a/Documentation/devicetree/bindings/iio/imu/bmi160.txt b/Documentation/devicetree/bindings/iio/imu/bmi160.txt deleted file mode 100644 index 900c169de00f..000000000000 --- a/Documentation/devicetree/bindings/iio/imu/bmi160.txt +++ /dev/null @@ -1,37 +0,0 @@ -Bosch BMI160 - Inertial Measurement Unit with Accelerometer, Gyroscope -and externally connectable Magnetometer - -https://www.bosch-sensortec.com/bst/products/all_products/bmi160 - -Required properties: - - compatible : should be "bosch,bmi160" - - reg : the I2C address or SPI chip select number of the sensor - - spi-max-frequency : set maximum clock frequency (only for SPI) - -Optional properties: - - interrupts : interrupt mapping for IRQ - - interrupt-names : set to "INT1" if INT1 pin should be used as interrupt - input, set to "INT2" if INT2 pin should be used instead - - drive-open-drain : set if the specified interrupt pin should be configured as - open drain. If not set, defaults to push-pull. - -Examples: - -bmi160@68 { - compatible = "bosch,bmi160"; - reg = <0x68>; - - interrupt-parent = <&gpio4>; - interrupts = <12 IRQ_TYPE_EDGE_RISING>; - interrupt-names = "INT1"; -}; - -bmi160@0 { - compatible = "bosch,bmi160"; - reg = <0>; - spi-max-frequency = <10000000>; - - interrupt-parent = <&gpio2>; - interrupts = <12 IRQ_TYPE_LEVEL_LOW>; - interrupt-names = "INT2"; -}; diff --git a/Documentation/devicetree/bindings/iio/imu/bmi160.yaml b/Documentation/devicetree/bindings/iio/imu/bmi160.yaml new file mode 100644 index 000000000000..6b464ce5ed0b --- /dev/null +++ b/Documentation/devicetree/bindings/iio/imu/bmi160.yaml @@ -0,0 +1,84 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/imu/bmi160.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Bosch BMI160 + +maintainers: + - can't find a mantainer, author is Daniel Baluta + +description: | + Inertial Measurement Unit with Accelerometer, Gyroscope and externally + connectable Magnetometer + https://www.bosch-sensortec.com/bst/products/all_products/bmi160 + +properties: + compatible: + const: bosch,bmi160 + + reg: + maxItems: 1 + description: the I2C address or SPI chip select number of the sensor + + spi-max-frequency: + maxItems: 1 + description: set maximum clock frequency (required only for SPI) + + interrupts: + maxItems: 1 + description: interrupt mapping for IRQ + + interrupt-names: + minItems: 1 + maxItems: 1 + items: + enum: + - INT1 + - INT2 + description: | + set to "INT1" if INT1 pin should be used as interrupt input, set + to "INT2" if INT2 pin should be used instead + + drive-open-drain: + description: | + set if the specified interrupt pin should be configured as + open drain. If not set, defaults to push-pull. + +required: + - compatible + - reg + +examples: + - | + // Example for I2C + i2c@78b7000 { + reg = <0x78b6000 0x600>; + #address-cells = <1>; + #size-cells = <0>; + + bmi160@68 { + compatible = "bosch,bmi160"; + reg = <0x68>; + interrupt-parent = <&gpio4>; + interrupts = <12 1>; + interrupt-names = "INT1"; + }; + - | + // Example for SPI + spi@78b7000 { + reg = <0x78b7000 0x600>, + <0x7884000 0x23000>; + #address-cells = <1>; + #size-cells = <0>; + + bmi160@0 { + compatible = "bosch,bmi160"; + reg = <0>; + spi-max-frequency = <10000000>; + interrupt-parent = <&gpio2>; + interrupts = <12 1>; + interrupt-names = "INT2"; + }; + }; From patchwork Mon May 18 13:33:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Albrieux X-Patchwork-Id: 11555439 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 22C3213B4 for ; Mon, 18 May 2020 13:35:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0B505206D4 for ; Mon, 18 May 2020 13:35:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="S+Ml6WrR" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728054AbgERNf6 (ORCPT ); Mon, 18 May 2020 09:35:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727020AbgERNf5 (ORCPT ); Mon, 18 May 2020 09:35:57 -0400 Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 40BB6C061A0C; Mon, 18 May 2020 06:35:57 -0700 (PDT) Received: by mail-wm1-x341.google.com with SMTP id m185so5555614wme.3; Mon, 18 May 2020 06:35:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=PioGi4Hba7haqtg57rWfjXP/P5pE/B0GcbWPRGco23Y=; b=S+Ml6WrRLqg6BM1/mDF4puVQrVbH8Y5rpjUv8HITzdMUF+KqbmNzkWGIupu3FTkGxx p16PZGgVD333x/6pIqSt9Ia7pq7U2VazHhU+yDww+QzGzCdXIbaaLh6S1oKbTZTebc8J C5MpWIh2Zlw8IxEBHf6JjftTM9jejh7mVlu5ALTi6oXKlycAapdEyd7NSRpyG/iBWpqk /DBlX8hFhOdFY4j7tKagGkDJH1sbUdKNOtCe3Z5OpGaOXQF4J+fns71mNwnm0aEIIgBR HkfJDvkOtM5KEt4PKl+WSUgAap28oyH2K0ebqQ4xu0zzL6p6HoV76MFxa/8wPm3uSK80 KrmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=PioGi4Hba7haqtg57rWfjXP/P5pE/B0GcbWPRGco23Y=; b=rHZJKgfNXd9NN9Hiwp7/QSsLeMRIB4fsPtlvJaQxUZkorlJkhxoGviaiJQooiQ3HWL qw+lsebOQpJE0w4ktqyoYDpad8ggv9FGEpo9cxseTxnBNfXheL9W87tr2MzQrGeNDb/q 55qje/qsh5wkuknjT/WVQHUp5gV94XLVQMZxbtth9r/Y/Mcs7ZDfuYxWXmzlx9yWNW6r FNQCLgmS8BSRxN0lXbKslP4PmYUcZm5ViXJ03da5Fp+x9FqB1GcK72MEArrGRTzsime6 TtkLY5K2kFRJsqbxAU9vBrr+cOa0QvAjkSFhmc1nzdbIJTn8s4nha14h/YRzzomgcpYx EdeQ== X-Gm-Message-State: AOAM532LrqzBihrZprZmuf7wTWMCvexl5OlcHTBNJQFjA6DXDLwmuu38 rts6Nt65W3BX7fFjMdZTPCa0aBdyRvs= X-Google-Smtp-Source: ABdhPJyd4EZlt8dwOJxsGSLXim8mpRadmCh2WrANQCKWgJg9pdQrrPR+PaKf8P2kfm0qQcCLTO7mnw== X-Received: by 2002:a1c:1d12:: with SMTP id d18mr18829700wmd.109.1589808955111; Mon, 18 May 2020 06:35:55 -0700 (PDT) Received: from ict14-OptiPlex-980.kataweb.it ([178.23.248.46]) by smtp.googlemail.com with ESMTPSA id l19sm17086772wmj.14.2020.05.18.06.35.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2020 06:35:54 -0700 (PDT) From: Jonathan Albrieux To: linux-kernel@vger.kernel.org Cc: Jonathan Albrieux , devicetree@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS), Hartmut Knaack , Lars-Peter Clausen , linux-iio@vger.kernel.org (open list:IIO SUBSYSTEM AND DRIVERS), Peter Meerwald-Stadler , Jonathan Cameron , Rob Herring Subject: [PATCH 2/4] dt-bindings: iio: imu: bmi160: add regulators and mount-matrix Date: Mon, 18 May 2020 15:33:46 +0200 Message-Id: <20200518133358.18978-3-jonathan.albrieux@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200518133358.18978-1-jonathan.albrieux@gmail.com> References: <20200518133358.18978-1-jonathan.albrieux@gmail.com> Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Add vdd-supply and vddio-supply support. Add mount-matrix support. Signed-off-by: Jonathan Albrieux --- .../devicetree/bindings/iio/imu/bmi160.yaml | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Documentation/devicetree/bindings/iio/imu/bmi160.yaml b/Documentation/devicetree/bindings/iio/imu/bmi160.yaml index 6b464ce5ed0b..5b13af7a209f 100644 --- a/Documentation/devicetree/bindings/iio/imu/bmi160.yaml +++ b/Documentation/devicetree/bindings/iio/imu/bmi160.yaml @@ -46,6 +46,21 @@ properties: set if the specified interrupt pin should be configured as open drain. If not set, defaults to push-pull. + vdd-supply: + maxItems: 1 + description: | + an optional regulator that needs to be on to provide VDD power to + the sensor. + + vddio-supply: + maxItems: 1 + description: | + an optional regulator that needs to be on to provide the VDD IO power to + the sensor. + + mount-matrix: + description: an optional 3x3 mounting rotation matrix + required: - compatible - reg @@ -61,9 +76,15 @@ examples: bmi160@68 { compatible = "bosch,bmi160"; reg = <0x68>; + vdd-supply = <&pm8916_l17>; + vddio-supply = <&pm8916_l6>; interrupt-parent = <&gpio4>; interrupts = <12 1>; interrupt-names = "INT1"; + mount-matrix = "0", "1", "0", + "-1", "0", "0", + "0", "0", "1"; + }; }; - | // Example for SPI From patchwork Mon May 18 13:33:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Albrieux X-Patchwork-Id: 11555441 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EDCAB16BC for ; Mon, 18 May 2020 13:36:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D4BD220853 for ; Mon, 18 May 2020 13:36:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Rak24Qph" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728084AbgERNgB (ORCPT ); Mon, 18 May 2020 09:36:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727020AbgERNgA (ORCPT ); Mon, 18 May 2020 09:36:00 -0400 Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 505A1C061A0C; Mon, 18 May 2020 06:36:00 -0700 (PDT) Received: by mail-wm1-x341.google.com with SMTP id k12so9326848wmj.3; Mon, 18 May 2020 06:36:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Kpmmawvu7m53+G2z+U2iQBPta6NzjZNKXgNes+IuTFU=; b=Rak24QphoCQrzPOtrnitJI0RNmLhe1FbEuKmfPJZc4xaywZ2FVHVQFMsiozNgp+unJ xN7j2We97V0SkkQW5/FQfa2tFdw90EFUTAWcdD2VTLeHY/s0iSeWkp6bjpx2pCMd40lR SOjWJGo4QBKu4FaOMjud13/wk5yOk4Jxjpn47VrytvsxJIx+WXAQKPcOTQYeHLEDIbYh 7wlzYe+P2/XuGzr61vlYdQIAvK8JadTszbCjQMIagpt4CXi+agt8EkVzMC2SwU/SNUkT +7SpKNXSXEdYdTlv1ZI1GjtKUTfsFieZIpZly1exPiCP+sAc5LBIoEYkuQWJOsEol9Ta c2mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Kpmmawvu7m53+G2z+U2iQBPta6NzjZNKXgNes+IuTFU=; b=c7FLqYfI7Xxj1KOQjirFWBPpgUAgWXjFUihX6x0m1DCbKRBZN8Xt1iy1zT9h7z1F44 L+HOP70+ZEMyLFcu01ff5qKLUQaRr6PsCsT29JGYO5AkVspygBDItOrMi+wMVoOAfFYJ vyHLErdKJ8tQ90ganzjwyZgVEC902LOrGOkRtFvXxfR2GKHbLc82bRyNuuB/dfwFoSnz t3e5Hit6jaOp1GFMEFMbqNJvCV3FHf4yDoY59dqFwNpFl2JB+cPTwXeuKyW1kKoPGYfy /+2nCbNBx9RrAdkijKkgo2U9FqmSeDLnGYjI0PTV2JIkvZ5eI9IQ7m0D1QkqnkdJc6an h5oQ== X-Gm-Message-State: AOAM5308Pm60P0uJlLjlRvAsg1B8m07nboCHRjoqGbJLMfZL0OJIgQy/ JU6n6eE9r9vfvYPW9eKdV80A9ZLwmEg= X-Google-Smtp-Source: ABdhPJxpm6LSkW/8+hxU16SHx/5L0dEjWgGKnpJaEhUiklN+ijyH4WOU4JkSEJE7yslKcKNVo0WINQ== X-Received: by 2002:a1c:40c6:: with SMTP id n189mr19506256wma.15.1589808958572; Mon, 18 May 2020 06:35:58 -0700 (PDT) Received: from ict14-OptiPlex-980.kataweb.it ([178.23.248.46]) by smtp.googlemail.com with ESMTPSA id l19sm17086772wmj.14.2020.05.18.06.35.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2020 06:35:57 -0700 (PDT) From: Jonathan Albrieux To: linux-kernel@vger.kernel.org Cc: Jonathan Albrieux , devicetree@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS), Hartmut Knaack , Lars-Peter Clausen , linux-iio@vger.kernel.org (open list:IIO SUBSYSTEM AND DRIVERS), Peter Meerwald-Stadler , Jonathan Cameron Subject: [PATCH 3/4] iio: imu: bmi160: added regulator support Date: Mon, 18 May 2020 15:33:47 +0200 Message-Id: <20200518133358.18978-4-jonathan.albrieux@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200518133358.18978-1-jonathan.albrieux@gmail.com> References: <20200518133358.18978-1-jonathan.albrieux@gmail.com> Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org --- drivers/iio/imu/bmi160/bmi160.h | 2 ++ drivers/iio/imu/bmi160/bmi160_core.c | 27 ++++++++++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/drivers/iio/imu/bmi160/bmi160.h b/drivers/iio/imu/bmi160/bmi160.h index 621f5309d735..923c3b274fde 100644 --- a/drivers/iio/imu/bmi160/bmi160.h +++ b/drivers/iio/imu/bmi160/bmi160.h @@ -3,10 +3,12 @@ #define BMI160_H_ #include +#include struct bmi160_data { struct regmap *regmap; struct iio_trigger *trig; + struct regulator_bulk_data supplies[2]; }; extern const struct regmap_config bmi160_regmap_config; diff --git a/drivers/iio/imu/bmi160/bmi160_core.c b/drivers/iio/imu/bmi160/bmi160_core.c index 6af65d6f1d28..9bbe0d8e6720 100644 --- a/drivers/iio/imu/bmi160/bmi160_core.c +++ b/drivers/iio/imu/bmi160/bmi160_core.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -709,6 +710,12 @@ static int bmi160_chip_init(struct bmi160_data *data, bool use_spi) unsigned int val; struct device *dev = regmap_get_device(data->regmap); + ret = regulator_bulk_enable(ARRAY_SIZE(data->supplies), data->supplies); + if (ret) { + dev_err(dev, "Failed to enable regulators: %d\n", ret); + return ret; + } + ret = regmap_write(data->regmap, BMI160_REG_CMD, BMI160_CMD_SOFTRESET); if (ret) return ret; @@ -793,9 +800,17 @@ int bmi160_probe_trigger(struct iio_dev *indio_dev, int irq, u32 irq_type) static void bmi160_chip_uninit(void *data) { struct bmi160_data *bmi_data = data; + struct device *dev = regmap_get_device(bmi_data->regmap); + int ret; bmi160_set_mode(bmi_data, BMI160_GYRO, false); bmi160_set_mode(bmi_data, BMI160_ACCEL, false); + + ret = regulator_bulk_disable(ARRAY_SIZE(bmi_data->supplies), + bmi_data->supplies); + if (ret) { + dev_err(dev, "Failed to disable regulators: %d\n", ret); + } } int bmi160_core_probe(struct device *dev, struct regmap *regmap, @@ -815,6 +830,16 @@ int bmi160_core_probe(struct device *dev, struct regmap *regmap, dev_set_drvdata(dev, indio_dev); data->regmap = regmap; + data->supplies[0].supply = "vdd"; + data->supplies[1].supply = "vddio"; + ret = devm_regulator_bulk_get(dev, + ARRAY_SIZE(data->supplies), + data->supplies); + if (ret) { + dev_err(dev, "Failed to get regulators: %d\n", ret); + return ret; + } + ret = bmi160_chip_init(data, use_spi); if (ret) return ret; @@ -853,6 +878,6 @@ int bmi160_core_probe(struct device *dev, struct regmap *regmap, } EXPORT_SYMBOL_GPL(bmi160_core_probe); -MODULE_AUTHOR("Daniel Baluta "); MODULE_DESCRIPTION("Bosch BMI160 driver"); MODULE_LICENSE("GPL v2"); From patchwork Mon May 18 13:33:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Albrieux X-Patchwork-Id: 11555443 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 34F091668 for ; Mon, 18 May 2020 13:36:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1DF2A206D4 for ; Mon, 18 May 2020 13:36:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZwMrnn+t" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727035AbgERNgF (ORCPT ); Mon, 18 May 2020 09:36:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727020AbgERNgE (ORCPT ); Mon, 18 May 2020 09:36:04 -0400 Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F28AFC061A0C; Mon, 18 May 2020 06:36:03 -0700 (PDT) Received: by mail-wm1-x341.google.com with SMTP id z72so10464856wmc.2; Mon, 18 May 2020 06:36:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=EeNFiJ1FC5DZjuSZh9hyKMC8Zinmtds/VmAwu1z5abo=; b=ZwMrnn+to6VQMkNjzZOwmfTwwkBqR7cX5q6nH+k6TuYBxihJ93+aqwF9C2LSPaVxcD 1dpP9uOp5g30ttImSR5urNvNejLoJ5+HH69IYD58CI5jeWLR/RWRlVqGn4WC1rpofCtl x8cbxbGT0nSGSnCDXF3BgvysqAlQc1dM5JWG9l10bUFvdc/SxphI+WNyl65Lw4dDkA+W ho3ZU04ZRPe9pkmJJjKbL8+VwixocTfKkMbOjkBeYGU1mMZJ2EDAmtDiU1HQtBUc6fPf jxPlHdqMRH6Q7wN7+sAlEZbSD9xq8ZKZGQB9h1QeAffqEO59jHzXH/AmJcKbCLs14EYp Mp7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=EeNFiJ1FC5DZjuSZh9hyKMC8Zinmtds/VmAwu1z5abo=; b=e8euYzWSEcTzWo6qmaAAmV8dRdahdQ1ZlYVMAf8YztAe2b1pNEn5N6T9IJ56BFjG56 lxi3eyMBsgdHTbDtrr7WzJYUvxnYWKJFFm8L/oXEkQZUB9Obtxbj0EeJAYG3sz4Bk2b9 RvbvJZcj30k8TnUeL6+9XOlSv8BTpOevQd0jf2mh+6o3iGp4WXcnF6XZx4vQlg++FlKA 8ESBBGvFwvWO/11q9yACKg3ikx2xJEXVYpJSJljp2BWlGWtrbP32lfDYOeArOawnmEpx wvqvnX2q6Yun6/gipGU+fvrnQFqeYI4OyjtIYbOliWoui0KMq7mHal/itkHPSXgFZhCS Zo/w== X-Gm-Message-State: AOAM5308V6p2hhppXVtCUQeH4SYOaWoK++A65BuKT25wNQlJtUM2kSHW glWLp+jE0X9PHzlPYpBxChS7Ypc1bCQ= X-Google-Smtp-Source: ABdhPJzewy/2r3VFYMjprFF3FTgffZFTtGs+QntmBmtQsjKWVhSkrgTScldbQh2bVXN3KBi0R1OTbA== X-Received: by 2002:a1c:7f4e:: with SMTP id a75mr19045184wmd.94.1589808962216; Mon, 18 May 2020 06:36:02 -0700 (PDT) Received: from ict14-OptiPlex-980.kataweb.it ([178.23.248.46]) by smtp.googlemail.com with ESMTPSA id l19sm17086772wmj.14.2020.05.18.06.36.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2020 06:36:01 -0700 (PDT) From: Jonathan Albrieux To: linux-kernel@vger.kernel.org Cc: Jonathan Albrieux , devicetree@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS), Hartmut Knaack , Lars-Peter Clausen , linux-iio@vger.kernel.org (open list:IIO SUBSYSTEM AND DRIVERS), Peter Meerwald-Stadler , Jonathan Cameron Subject: [PATCH 4/4] iio: imu: bmi160: added mount-matrix support Date: Mon, 18 May 2020 15:33:48 +0200 Message-Id: <20200518133358.18978-5-jonathan.albrieux@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200518133358.18978-1-jonathan.albrieux@gmail.com> References: <20200518133358.18978-1-jonathan.albrieux@gmail.com> Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Add mount-matrix binding support. As chip could have different orientations a mount matrix support is needed to correctly translate these differences Signed-off-by: Jonathan Albrieux --- drivers/iio/imu/bmi160/bmi160.h | 1 + drivers/iio/imu/bmi160/bmi160_core.c | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/drivers/iio/imu/bmi160/bmi160.h b/drivers/iio/imu/bmi160/bmi160.h index 923c3b274fde..a82e040bd109 100644 --- a/drivers/iio/imu/bmi160/bmi160.h +++ b/drivers/iio/imu/bmi160/bmi160.h @@ -9,6 +9,7 @@ struct bmi160_data { struct regmap *regmap; struct iio_trigger *trig; struct regulator_bulk_data supplies[2]; + struct iio_mount_matrix orientation; }; extern const struct regmap_config bmi160_regmap_config; diff --git a/drivers/iio/imu/bmi160/bmi160_core.c b/drivers/iio/imu/bmi160/bmi160_core.c index 9bbe0d8e6720..78c8ca962359 100644 --- a/drivers/iio/imu/bmi160/bmi160_core.c +++ b/drivers/iio/imu/bmi160/bmi160_core.c @@ -110,6 +110,7 @@ .storagebits = 16, \ .endianness = IIO_LE, \ }, \ + .ext_info = bmi160_ext_info, \ } /* scan indexes follow DATA register order */ @@ -265,6 +266,20 @@ static const struct bmi160_odr_item bmi160_odr_table[] = { }, }; +static const struct iio_mount_matrix * +bmi160_get_mount_matrix(const struct iio_dev *indio_dev, + const struct iio_chan_spec *chan) +{ + struct bmi160_data *data = iio_priv(indio_dev); + + return &data->orientation; +} + +static const struct iio_chan_spec_ext_info bmi160_ext_info[] = { + IIO_MOUNT_MATRIX(IIO_SHARED_BY_DIR, bmi160_get_mount_matrix), + { } +}; + static const struct iio_chan_spec bmi160_channels[] = { BMI160_CHANNEL(IIO_ACCEL, X, BMI160_SCAN_ACCEL_X), BMI160_CHANNEL(IIO_ACCEL, Y, BMI160_SCAN_ACCEL_Y), @@ -840,6 +855,11 @@ int bmi160_core_probe(struct device *dev, struct regmap *regmap, return ret; } + ret = iio_read_mount_matrix(dev, "mount-matrix", + &data->orientation); + if (ret) + return ret; + ret = bmi160_chip_init(data, use_spi); if (ret) return ret;