From patchwork Tue May 19 07:50:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Albrieux X-Patchwork-Id: 11557153 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 0F32390 for ; Tue, 19 May 2020 07:51:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E67A72075F for ; Tue, 19 May 2020 07:51:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="afDBTXdV" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728374AbgESHv6 (ORCPT ); Tue, 19 May 2020 03:51:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726892AbgESHv5 (ORCPT ); Tue, 19 May 2020 03:51:57 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 534C6C061A0C; Tue, 19 May 2020 00:51:56 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id u188so2307952wmu.1; Tue, 19 May 2020 00:51:56 -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=afDBTXdVkIaS0Jh4uTRhUhaav27upBE5ZgSJ8qVeFA5EmHbOelxEJW1raIen3J9Jja 6A8Db77ULrxBx6nRzJKpYZgOHHEsZdiOAlNY5nMejusIX9Pz7heZhdMxNHsnOTf7c2mp iEUKPFj5E4U1JWGdKNFacRqlewyyAh3uncTsJc6zM4TKvmTuJPsjJ6bxUmK4cwE18q42 9fUTyBp/jFv3LLwRk9ftSbuKRUK/XtWX+DNVVXjjmyW5kqUh/SnhBJmwX4h4J023z0/v NiM1ltErl2etOCambA5cVaRAb8b3L5ivoECwXMYimPgJEg1M0wQzk8HkVRPHVsxgbf00 TQ5Q== 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=MR/nqjgVNy2SiFvOWFABUMp61iXdjketGZFAiNqoCaz2n5fAkazFRoWOWgD4lmXXXO u6eEAv53VZKLw275NoHkBSfxFehvf/iACWRWzxjA12NH2xmiJNO3SkT3I2BZDUdrexQc 2h61me8bZYgrTs0SlCjmkvdgQ7a0LjXjAgzY9VZdKuJLuPagoCIeXc3LEHnjuXPy7+5O PNtDqoACXScR3cBe0ZTPzR/RuSXspbpqzpBFH3RN0gY20CDHWGVg2U1o92goQ3uICjOb friQVScXos70RuJKGOtCvdpTT5NKigbS69aWiPb2QozU26xyWz6CR6A6YeCbHjFixC6A Eabw== X-Gm-Message-State: AOAM532FP5azNVSaWJdsOnTciwz0OCAqvUAqD3JvimKDsbB+J1ZG3t3Z JHNTu3uUdOmQ4gjEfoXeHTbc5hL0ecs= X-Google-Smtp-Source: ABdhPJwTzc1wazYnIQwgBVGvzyYXxFBP+pNKLJ/5+5Z3ROPzayYdlv33R1Lm5OW9qfTy7EgFqyOuog== X-Received: by 2002:a1c:2e46:: with SMTP id u67mr3789884wmu.156.1589874714499; Tue, 19 May 2020 00:51:54 -0700 (PDT) Received: from ict14-OptiPlex-980.kataweb.it ([178.23.248.46]) by smtp.googlemail.com with ESMTPSA id w18sm20019697wro.33.2020.05.19.00.51.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 May 2020 00:51:53 -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 v2 1/4] dt-bindings: iio: imu: bmi160: convert txt format to yaml Date: Tue, 19 May 2020 09:50:57 +0200 Message-Id: <20200519075111.6356-2-jonathan.albrieux@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200519075111.6356-1-jonathan.albrieux@gmail.com> References: <20200519075111.6356-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 Tue May 19 07:50:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Albrieux X-Patchwork-Id: 11557155 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 2AE2190 for ; Tue, 19 May 2020 07:52:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 113FE2075F for ; Tue, 19 May 2020 07:52:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="no/jebZA" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728481AbgESHwB (ORCPT ); Tue, 19 May 2020 03:52:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726892AbgESHv7 (ORCPT ); Tue, 19 May 2020 03:51:59 -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 5E547C061A0C; Tue, 19 May 2020 00:51:59 -0700 (PDT) Received: by mail-wm1-x341.google.com with SMTP id f134so2007860wmf.1; Tue, 19 May 2020 00:51:59 -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=no/jebZAVylj/0ygMm+1Pw8/fW3BIzgnqv80UN/+fhFsIG7OF7iMmpq4qg8UhGyVCD 0eZNeeRrfsMNwvztPGs/fTp6WhLUVTtgNRQgEYMWXi0AxQyVQTWV+RT5QXMYEGNgYoqI tzqEqfXDe1rapnkemHJ8bjzJW1C2TRGEEVdczbWKbLxZVBqWqyWUwLnlBAiaIDtKyzsB NSrLC+z3r78PFMAi9/NA5LB/lZM4AyMtUlVKOZkl8lmdBjEBbmcEzEA7EMN5WPyf9K+8 Z5sg4kec0uNZamitnjdj8M7G1Tz9bG7A1BBH/CE4/lM/S89rkq5QEX2jM5kuHyrQsIju UegA== 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=Woov5chXqsOzLcBmxqDILrhstPS3wSH2YXp0RG0hRAu9l0YwmYbQbKrkvbH9obeGUm Jg5XPRbjy0e9CR/+UiqM1I4TKK9HG7wxwAi3qTFFI5d8PlBcUSid1XkZrhtYAIgJ7iV2 98U5I6/cDLgR6yZvjon/vt6nS9qGjooiR4b0RLwVimazUN7ouuPa/52fm1gBOZ9ANTcp tuzNvVhemPR2UIWXlxXLWWS3+EkNm4oB3Tnu+Nlbbl1KWICD7L/Wlgnlli+egUfbq2ch bD+pN9Tr4xIQ+x4cvG3tn13bQL9+vHYNIDMfR14Mdj49CNBsZMirqYuyVkskkaKyYyU6 5Qaw== X-Gm-Message-State: AOAM532+GDRTg8jTWoluaOnNw6hAe96Gu5/bw9SOhExFLR0rRLjTS5K3 AbEKFDCwMmKJrLyKYEwGVYUUSaFcyS0= X-Google-Smtp-Source: ABdhPJzu5XcgOCcXEn2F/H45Ds7AkoAlpYhNJt7hsh6w13fOqzbbOSR0RRPezBF8FVLlQ3QMnsLOog== X-Received: by 2002:a1c:7914:: with SMTP id l20mr3816014wme.120.1589874717602; Tue, 19 May 2020 00:51:57 -0700 (PDT) Received: from ict14-OptiPlex-980.kataweb.it ([178.23.248.46]) by smtp.googlemail.com with ESMTPSA id w18sm20019697wro.33.2020.05.19.00.51.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 May 2020 00:51:56 -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 v2 2/4] dt-bindings: iio: imu: bmi160: add regulators and mount-matrix Date: Tue, 19 May 2020 09:50:58 +0200 Message-Id: <20200519075111.6356-3-jonathan.albrieux@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200519075111.6356-1-jonathan.albrieux@gmail.com> References: <20200519075111.6356-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 Tue May 19 07:50:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Albrieux X-Patchwork-Id: 11557157 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 8E89290 for ; Tue, 19 May 2020 07:52:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7724820826 for ; Tue, 19 May 2020 07:52:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VFppNQKO" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728565AbgESHwE (ORCPT ); Tue, 19 May 2020 03:52:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726892AbgESHwD (ORCPT ); Tue, 19 May 2020 03:52:03 -0400 Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1ACCFC061A0C; Tue, 19 May 2020 00:52:03 -0700 (PDT) Received: by mail-wr1-x443.google.com with SMTP id 50so14663949wrc.11; Tue, 19 May 2020 00:52: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=+9q/lrH8Rz1lWaiznxolgZJjw54jdIA13oGlCCkqVWE=; b=VFppNQKOwslJ52Bhq5aKyGSXmyfKM+y2ofM/uTjfNjFGd9ihqxIKnPgbhGXVPF6/hZ GhtvBF3u3B2SfohsCfVczsf+2vu1p+xwr3VHtEm4PRoP4/B6f4jH26u2V7nujIfF30EN DMjXrIHUTpSO3eRw099p5Bz35WAzW048regqgbVMt4t3IYCk1GGLnjFrmHjr+1wh85xM nexPtzQ3AQThkprrL7lJ+fN4YiYup+IdCDaU4YESO7BmKAcciJT367yVWvbQ3oG7x2Xs H6pR4ULWy9Q6ctuX5W65BKRCQb/2APLvqGTNYF5Q3S1CPWM5QZF+o00ATmALRK00LPRY MPiw== 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=+9q/lrH8Rz1lWaiznxolgZJjw54jdIA13oGlCCkqVWE=; b=IPjic6i5EdzMJ1jlOIRuOid7hMygLaHcZkDm55NdJeB6dE7R6POmKE/sfFBPCFjmPz yMEOpedHoKApO1z2T2dm/acp79JYbyRY/7XI82SBaIHQJLIbgQukNGwOuEZ8BjjAgHT3 L9S0UqDdK88gFadcdH2/isSxP6ZHxCSvFLiHaAOJgJGdZ+3tuh16fr6iP0RgEvPwxHH0 kXuPV37R5Gcv0xOhMWCnwRknZlkK97Zr2ba55hAQoQ/CLxWn8SmW/wjDCVzkmJUEvzG5 2AXqdOWg7c4jqILTX/SdniWpFWzeDnQtOf9hjpAcAozLa1QYakgHeOBzsGc6GxWtqVYn OJtg== X-Gm-Message-State: AOAM531liISiLThYrcFiswkycW8X1dleqswCI3dm+mLUSYkU3iNTQE88 Gj9vDjOZn3d7TT7sIIKf8LnPR8VcLhQ= X-Google-Smtp-Source: ABdhPJxIz2vOS+zMIvTdjRmEANZlTkljXpVaVGC6bSoPaePYn8jUR2aXIUq24cRHqc3d0fbDP9vtIA== X-Received: by 2002:adf:e985:: with SMTP id h5mr25204106wrm.239.1589874721123; Tue, 19 May 2020 00:52:01 -0700 (PDT) Received: from ict14-OptiPlex-980.kataweb.it ([178.23.248.46]) by smtp.googlemail.com with ESMTPSA id w18sm20019697wro.33.2020.05.19.00.52.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 May 2020 00:52:00 -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 v2 3/4] iio: imu: bmi160: added regulator support Date: Tue, 19 May 2020 09:50:59 +0200 Message-Id: <20200519075111.6356-4-jonathan.albrieux@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200519075111.6356-1-jonathan.albrieux@gmail.com> References: <20200519075111.6356-1-jonathan.albrieux@gmail.com> Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org v2: fixed missing description Add vdd-supply and vddio-supply support. Without this support vdd and vddio should be set to always-on in device tree Signed-off-by: Jonathan Albrieux --- 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 Tue May 19 07:51:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Albrieux X-Patchwork-Id: 11557159 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 7A32390 for ; Tue, 19 May 2020 07:52:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 61AC5207E8 for ; Tue, 19 May 2020 07:52:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XEAU79mZ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728591AbgESHwI (ORCPT ); Tue, 19 May 2020 03:52:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726892AbgESHwG (ORCPT ); Tue, 19 May 2020 03:52:06 -0400 Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7BAFCC061A0C; Tue, 19 May 2020 00:52:06 -0700 (PDT) Received: by mail-wm1-x343.google.com with SMTP id u188so2308564wmu.1; Tue, 19 May 2020 00:52:06 -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=XEAU79mZXQfRvTzivvj9o5mW0XISfJr+VlP/k89iTZp3M2LILtWn/cpe9VuWcMtRDI JtbzVAsUQwzFHQpap+7eSOB48Y8U/zWEXAzdecTqWICRSi4QYTrzch82hze1o9OE/ufy GLTcfNMZh6b/OWy5/wVDZFamRZ3p9991plplToXbjwlwcxaO8xedJDzKqLhbJjv/DA8D ESN8Nf3p+lAWqDdbLiVha0d0XUlvj66KA3yNUzxLB+2uJpV4s20sq5RcxPcjmCLsvzjO zh4fCbUpUHR1HpcbDPIv4RFD6ZESmrVgh9O5cKx+14JI9c+MsxiwdPqvZE6w9wxefRCP Yu3A== 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=ZqCqM91fJyrs10TuMNNdhTDErIQZ/82Z30jzSyYNpqwwjEdY+2iNX4+NqOrkF+wC0f x0721bSqlkhjWv2zCzZcxSBytvbX8YCgJMevpVnmuDQrzr/V1PCjNCRWxaYyYhXCfwQW TL8J0FzaNdx6LaY7nwfnkQjT/xSljVj7GFnxcPuL8gIJidSkHkpvW1eZIC6/rolowhbX yuD6lZXmMhCLwm+eX5JAbVkn1prpJ723128AbzU9fb+9qSss8jg7lFgWV1jDxbrFCqTu 4Qw0Sq7+3h+Q10MUX14ANztFZkds/I2SS1Tgo7VxDb1aYCUlQhBkBAZsBYcw5nIMlrhS ks4A== X-Gm-Message-State: AOAM5335JrcX8BqzxZtMcBqasZbS3Q7y3pWPK2tvD4mTKlUH+U41y6eV l4+IyhtKqqWplzFVc3apMek8s4FtDB4= X-Google-Smtp-Source: ABdhPJyWKQkQVV8QWYuBtxkoXnBwAtWQhLa5GCVcyxRYI/z/Cb4GqcUUbx1v5l09cnCmSiDunxJHMg== X-Received: by 2002:a1c:2087:: with SMTP id g129mr3764710wmg.126.1589874724562; Tue, 19 May 2020 00:52:04 -0700 (PDT) Received: from ict14-OptiPlex-980.kataweb.it ([178.23.248.46]) by smtp.googlemail.com with ESMTPSA id w18sm20019697wro.33.2020.05.19.00.52.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 May 2020 00:52:03 -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 v2 4/4] iio: imu: bmi160: added mount-matrix support Date: Tue, 19 May 2020 09:51:00 +0200 Message-Id: <20200519075111.6356-5-jonathan.albrieux@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200519075111.6356-1-jonathan.albrieux@gmail.com> References: <20200519075111.6356-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;