linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/5] iio: imu: bmi160: added regulator and mount-matrix support
@ 2020-05-20 19:46 Jonathan Albrieux
  2020-05-20 19:46 ` [PATCH v3 1/5] dt-bindings: iio: imu: bmi160: convert txt format to yaml Jonathan Albrieux
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Jonathan Albrieux @ 2020-05-20 19:46 UTC (permalink / raw)
  To: linux-kernel
  Cc: ~postmarketos/upstreaming, daniel.baluta, Jonathan Albrieux,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Hartmut Knaack, Lars-Peter Clausen,
	open list:IIO SUBSYSTEM AND DRIVERS, Peter Meerwald-Stadler

v3: 
 - separate typo fix into another patch
 - clean up of documentation
 - clean up of patch messages

v2: 
 - fixed missing description for iio: imu: bmi160: added regulator
   support
https://lore.kernel.org/linux-iio/20200519075111.6356-1-jonathan.albrieux@gmail.com/

v1:
 - initial patch submission
https://lore.kernel.org/linux-iio/20200518133358.18978-1-jonathan.albrieux@gmail.com/

Convert txt format documentation to yaml.
Add documentation about vdd-supply, vddio-supply and mount-matrix.

Add vdd-supply and vddio-supply support.

Add mount-matrix binding support. As chip could have different
orientations a mount matrix support is needed to correctly translate
these differences.

Jonathan Albrieux (5):
  dt-bindings: iio: imu: bmi160: convert txt format to yaml
  dt-bindings: iio: imu: bmi160: add regulators and mount-matrix
  iio: imu: bmi160: fix typo
  iio: imu: bmi160: added regulator support
  iio: imu: bmi160: added mount-matrix support

 .../devicetree/bindings/iio/imu/bmi160.txt    | 37 --------
 .../bindings/iio/imu/bosch,bmi160.yaml        | 92 +++++++++++++++++++
 drivers/iio/imu/bmi160/bmi160.h               |  3 +
 drivers/iio/imu/bmi160/bmi160_core.c          | 46 +++++++++-
 4 files changed, 140 insertions(+), 38 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/iio/imu/bmi160.txt
 create mode 100644 Documentation/devicetree/bindings/iio/imu/bosch,bmi160.yaml

-- 
2.17.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v3 1/5] dt-bindings: iio: imu: bmi160: convert txt format to yaml
  2020-05-20 19:46 [PATCH v3 0/5] iio: imu: bmi160: added regulator and mount-matrix support Jonathan Albrieux
@ 2020-05-20 19:46 ` Jonathan Albrieux
  2020-05-24 11:41   ` Jonathan Cameron
  2020-05-20 19:46 ` [PATCH v3 2/5] dt-bindings: iio: imu: bmi160: add regulators and mount-matrix Jonathan Albrieux
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 9+ messages in thread
From: Jonathan Albrieux @ 2020-05-20 19:46 UTC (permalink / raw)
  To: linux-kernel
  Cc: ~postmarketos/upstreaming, daniel.baluta, Jonathan Albrieux,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Hartmut Knaack, Lars-Peter Clausen,
	open list:IIO SUBSYSTEM AND DRIVERS, Peter Meerwald-Stadler,
	Jonathan Cameron, Rob Herring

Converts documentation from txt format to yaml.

Signed-off-by: Jonathan Albrieux <jonathan.albrieux@gmail.com>
---
 .../devicetree/bindings/iio/imu/bmi160.txt    | 37 ---------
 .../bindings/iio/imu/bosch,bmi160.yaml        | 76 +++++++++++++++++++
 2 files changed, 76 insertions(+), 37 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/iio/imu/bmi160.txt
 create mode 100644 Documentation/devicetree/bindings/iio/imu/bosch,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/bosch,bmi160.yaml b/Documentation/devicetree/bindings/iio/imu/bosch,bmi160.yaml
new file mode 100644
index 000000000000..46cb4fde1165
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/imu/bosch,bmi160.yaml
@@ -0,0 +1,76 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/iio/imu/bosch,bmi160.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Bosch BMI160
+
+maintainers:
+  - Daniel Baluta <daniel.baluta@nxp.com> (?)
+
+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
+
+  spi-max-frequency:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  interrupt-names:
+    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 {
+        #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 {
+        #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";
+        };
+    };
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v3 2/5] dt-bindings: iio: imu: bmi160: add regulators and mount-matrix
  2020-05-20 19:46 [PATCH v3 0/5] iio: imu: bmi160: added regulator and mount-matrix support Jonathan Albrieux
  2020-05-20 19:46 ` [PATCH v3 1/5] dt-bindings: iio: imu: bmi160: convert txt format to yaml Jonathan Albrieux
@ 2020-05-20 19:46 ` Jonathan Albrieux
  2020-05-20 19:46 ` [PATCH v3 3/5] iio: imu: bmi160: fix typo Jonathan Albrieux
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Jonathan Albrieux @ 2020-05-20 19:46 UTC (permalink / raw)
  To: linux-kernel
  Cc: ~postmarketos/upstreaming, daniel.baluta, Jonathan Albrieux,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Hartmut Knaack, Lars-Peter Clausen,
	open list:IIO SUBSYSTEM AND DRIVERS, Peter Meerwald-Stadler,
	Jonathan Cameron, Rob Herring

Add vdd-supply and vddio-supply support.
Add mount-matrix support.

Signed-off-by: Jonathan Albrieux <jonathan.albrieux@gmail.com>
---
 .../bindings/iio/imu/bosch,bmi160.yaml           | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/Documentation/devicetree/bindings/iio/imu/bosch,bmi160.yaml b/Documentation/devicetree/bindings/iio/imu/bosch,bmi160.yaml
index 46cb4fde1165..1a1b1a14aa2e 100644
--- a/Documentation/devicetree/bindings/iio/imu/bosch,bmi160.yaml
+++ b/Documentation/devicetree/bindings/iio/imu/bosch,bmi160.yaml
@@ -40,6 +40,17 @@ 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: provide VDD power to the sensor.
+
+  vddio-supply:
+    maxItems: 1
+    description: provide VDD IO power to the sensor.
+
+  mount-matrix:
+    description: an optional 3x3 mounting rotation matrix
+
 required:
   - compatible
   - reg
@@ -54,9 +65,14 @@ 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";
         };
     };
   - |
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v3 3/5] iio: imu: bmi160: fix typo
  2020-05-20 19:46 [PATCH v3 0/5] iio: imu: bmi160: added regulator and mount-matrix support Jonathan Albrieux
  2020-05-20 19:46 ` [PATCH v3 1/5] dt-bindings: iio: imu: bmi160: convert txt format to yaml Jonathan Albrieux
  2020-05-20 19:46 ` [PATCH v3 2/5] dt-bindings: iio: imu: bmi160: add regulators and mount-matrix Jonathan Albrieux
@ 2020-05-20 19:46 ` Jonathan Albrieux
  2020-05-20 19:46 ` [PATCH v3 4/5] iio: imu: bmi160: added regulator support Jonathan Albrieux
  2020-05-20 19:46 ` [PATCH v3 5/5] iio: imu: bmi160: added mount-matrix support Jonathan Albrieux
  4 siblings, 0 replies; 9+ messages in thread
From: Jonathan Albrieux @ 2020-05-20 19:46 UTC (permalink / raw)
  To: linux-kernel
  Cc: ~postmarketos/upstreaming, daniel.baluta, Jonathan Albrieux,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Hartmut Knaack, Lars-Peter Clausen,
	open list:IIO SUBSYSTEM AND DRIVERS, Peter Meerwald-Stadler,
	Jonathan Cameron

Fix a typo in MODULE_AUTHOR() argument.

Signed-off-by: Jonathan Albrieux <jonathan.albrieux@gmail.com>
---
 drivers/iio/imu/bmi160/bmi160_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/imu/bmi160/bmi160_core.c b/drivers/iio/imu/bmi160/bmi160_core.c
index 6af65d6f1d28..77b05bd4a2b2 100644
--- a/drivers/iio/imu/bmi160/bmi160_core.c
+++ b/drivers/iio/imu/bmi160/bmi160_core.c
@@ -853,6 +853,6 @@ int bmi160_core_probe(struct device *dev, struct regmap *regmap,
 }
 EXPORT_SYMBOL_GPL(bmi160_core_probe);
 
-MODULE_AUTHOR("Daniel Baluta <daniel.baluta@intel.com");
+MODULE_AUTHOR("Daniel Baluta <daniel.baluta@intel.com>");
 MODULE_DESCRIPTION("Bosch BMI160 driver");
 MODULE_LICENSE("GPL v2");
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v3 4/5] iio: imu: bmi160: added regulator support
  2020-05-20 19:46 [PATCH v3 0/5] iio: imu: bmi160: added regulator and mount-matrix support Jonathan Albrieux
                   ` (2 preceding siblings ...)
  2020-05-20 19:46 ` [PATCH v3 3/5] iio: imu: bmi160: fix typo Jonathan Albrieux
@ 2020-05-20 19:46 ` Jonathan Albrieux
  2020-05-20 19:46 ` [PATCH v3 5/5] iio: imu: bmi160: added mount-matrix support Jonathan Albrieux
  4 siblings, 0 replies; 9+ messages in thread
From: Jonathan Albrieux @ 2020-05-20 19:46 UTC (permalink / raw)
  To: linux-kernel
  Cc: ~postmarketos/upstreaming, daniel.baluta, Jonathan Albrieux,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Hartmut Knaack, Lars-Peter Clausen,
	open list:IIO SUBSYSTEM AND DRIVERS, Peter Meerwald-Stadler,
	Jonathan Cameron

Add vdd-supply and vddio-supply support.

Signed-off-by: Jonathan Albrieux <jonathan.albrieux@gmail.com>
---
 drivers/iio/imu/bmi160/bmi160.h      |  2 ++
 drivers/iio/imu/bmi160/bmi160_core.c | 24 ++++++++++++++++++++++++
 2 files changed, 26 insertions(+)

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 <linux/iio/iio.h>
+#include <linux/regulator/consumer.h>
 
 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 77b05bd4a2b2..d3316ca02fbd 100644
--- a/drivers/iio/imu/bmi160/bmi160_core.c
+++ b/drivers/iio/imu/bmi160/bmi160_core.c
@@ -15,6 +15,7 @@
 #include <linux/delay.h>
 #include <linux/irq.h>
 #include <linux/of_irq.h>
+#include <linux/regulator/consumer.h>
 
 #include <linux/iio/iio.h>
 #include <linux/iio/triggered_buffer.h>
@@ -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,16 @@ 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 +829,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;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v3 5/5] iio: imu: bmi160: added mount-matrix support
  2020-05-20 19:46 [PATCH v3 0/5] iio: imu: bmi160: added regulator and mount-matrix support Jonathan Albrieux
                   ` (3 preceding siblings ...)
  2020-05-20 19:46 ` [PATCH v3 4/5] iio: imu: bmi160: added regulator support Jonathan Albrieux
@ 2020-05-20 19:46 ` Jonathan Albrieux
  2020-05-24 11:43   ` Jonathan Cameron
  4 siblings, 1 reply; 9+ messages in thread
From: Jonathan Albrieux @ 2020-05-20 19:46 UTC (permalink / raw)
  To: linux-kernel
  Cc: ~postmarketos/upstreaming, daniel.baluta, Jonathan Albrieux,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Hartmut Knaack, Lars-Peter Clausen,
	open list:IIO SUBSYSTEM AND DRIVERS, Peter Meerwald-Stadler,
	Jonathan Cameron

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 <jonathan.albrieux@gmail.com>
---
 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 d3316ca02fbd..26d586daee26 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),
@@ -839,6 +854,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;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v3 1/5] dt-bindings: iio: imu: bmi160: convert txt format to yaml
  2020-05-20 19:46 ` [PATCH v3 1/5] dt-bindings: iio: imu: bmi160: convert txt format to yaml Jonathan Albrieux
@ 2020-05-24 11:41   ` Jonathan Cameron
  2020-05-25  7:27     ` Jonathan Albrieux
  0 siblings, 1 reply; 9+ messages in thread
From: Jonathan Cameron @ 2020-05-24 11:41 UTC (permalink / raw)
  To: Jonathan Albrieux
  Cc: linux-kernel, ~postmarketos/upstreaming, daniel.baluta,
	open list:OPEN FIRMWARE AND FLATTENED  DEVICE TREE BINDINGS,
	Hartmut Knaack, Lars-Peter Clausen,
	open list:IIO SUBSYSTEM AND DRIVERS, Peter Meerwald-Stadler,
	Rob Herring

On Wed, 20 May 2020 21:46:40 +0200
Jonathan Albrieux <jonathan.albrieux@gmail.com> wrote:

> Converts documentation from txt format to yaml.
> 
> Signed-off-by: Jonathan Albrieux <jonathan.albrieux@gmail.com>

A reminder on the maintainer bit as that thread crossed with
this one.  Also, drop the spi-max-frequency as we don't need
to mention it explicitly for this device.

Thanks,

Jonathan


> ---
>  .../devicetree/bindings/iio/imu/bmi160.txt    | 37 ---------
>  .../bindings/iio/imu/bosch,bmi160.yaml        | 76 +++++++++++++++++++
>  2 files changed, 76 insertions(+), 37 deletions(-)
>  delete mode 100644 Documentation/devicetree/bindings/iio/imu/bmi160.txt
>  create mode 100644 Documentation/devicetree/bindings/iio/imu/bosch,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/bosch,bmi160.yaml b/Documentation/devicetree/bindings/iio/imu/bosch,bmi160.yaml
> new file mode 100644
> index 000000000000..46cb4fde1165
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/iio/imu/bosch,bmi160.yaml
> @@ -0,0 +1,76 @@
> +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/iio/imu/bosch,bmi160.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Bosch BMI160
> +
> +maintainers:
> +  - Daniel Baluta <daniel.baluta@nxp.com> (?)

Daniel's reply crossed with this.  Given he's moved on to other things
he's not happy to be listed as maintainer here.

Given other threads, either put yourself here if you are happy to maintain
the binding, or fall back to me but use my kernel.org address.

Jonathan Cameron <jic23@kernel.org>

I don't mind either way.


> +
> +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
> +
> +  spi-max-frequency:
> +    maxItems: 1

spi-max-frequency doesn't need to be here at all.   We aren't trying to list
all of the properties that might be present - but rather those that
are either required or that are part of the description of the device.
This one is a generic spi binding that may or may not be present.

> +
> +  interrupts:
> +    maxItems: 1
> +
> +  interrupt-names:
> +    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 {
> +        #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 {
> +        #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";
> +        };
> +    };


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v3 5/5] iio: imu: bmi160: added mount-matrix support
  2020-05-20 19:46 ` [PATCH v3 5/5] iio: imu: bmi160: added mount-matrix support Jonathan Albrieux
@ 2020-05-24 11:43   ` Jonathan Cameron
  0 siblings, 0 replies; 9+ messages in thread
From: Jonathan Cameron @ 2020-05-24 11:43 UTC (permalink / raw)
  To: Jonathan Albrieux
  Cc: linux-kernel, ~postmarketos/upstreaming, daniel.baluta,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Hartmut Knaack, Lars-Peter Clausen,
	open list:IIO SUBSYSTEM AND DRIVERS, Peter Meerwald-Stadler

On Wed, 20 May 2020 21:46:44 +0200
Jonathan Albrieux <jonathan.albrieux@gmail.com> wrote:

> 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 <jonathan.albrieux@gmail.com>

Other than those bits for the binding doc, the rest of the series
looks good to me.   Given timing this will only go into mainline in the
next cycle now anyway so we have plenty of time to tidy up the corners.

Thanks,

Jonathan

> ---
>  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 d3316ca02fbd..26d586daee26 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),
> @@ -839,6 +854,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;


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v3 1/5] dt-bindings: iio: imu: bmi160: convert txt format to yaml
  2020-05-24 11:41   ` Jonathan Cameron
@ 2020-05-25  7:27     ` Jonathan Albrieux
  0 siblings, 0 replies; 9+ messages in thread
From: Jonathan Albrieux @ 2020-05-25  7:27 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: linux-kernel, ~postmarketos/upstreaming, daniel.baluta,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Hartmut Knaack, Lars-Peter Clausen,
	open list:IIO SUBSYSTEM AND DRIVERS, Peter Meerwald-Stadler,
	Rob Herring

On Sun, May 24, 2020 at 12:41:14PM +0100, Jonathan Cameron wrote:
> On Wed, 20 May 2020 21:46:40 +0200
> Jonathan Albrieux <jonathan.albrieux@gmail.com> wrote:
> 
> > Converts documentation from txt format to yaml.
> > 
> > Signed-off-by: Jonathan Albrieux <jonathan.albrieux@gmail.com>
> 
> A reminder on the maintainer bit as that thread crossed with
> this one.  Also, drop the spi-max-frequency as we don't need
> to mention it explicitly for this device.
> 
> Thanks,
> 
> Jonathan
> 

Thank you, I'll remove it today.

> 
> > ---
> >  .../devicetree/bindings/iio/imu/bmi160.txt    | 37 ---------
> >  .../bindings/iio/imu/bosch,bmi160.yaml        | 76 +++++++++++++++++++
> >  2 files changed, 76 insertions(+), 37 deletions(-)
> >  delete mode 100644 Documentation/devicetree/bindings/iio/imu/bmi160.txt
> >  create mode 100644 Documentation/devicetree/bindings/iio/imu/bosch,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/bosch,bmi160.yaml b/Documentation/devicetree/bindings/iio/imu/bosch,bmi160.yaml
> > new file mode 100644
> > index 000000000000..46cb4fde1165
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/iio/imu/bosch,bmi160.yaml
> > @@ -0,0 +1,76 @@
> > +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
> > +%YAML 1.2
> > +---
> > +$id: http://devicetree.org/schemas/iio/imu/bosch,bmi160.yaml#
> > +$schema: http://devicetree.org/meta-schemas/core.yaml#
> > +
> > +title: Bosch BMI160
> > +
> > +maintainers:
> > +  - Daniel Baluta <daniel.baluta@nxp.com> (?)
> 
> Daniel's reply crossed with this.  Given he's moved on to other things
> he's not happy to be listed as maintainer here.
> 
> Given other threads, either put yourself here if you are happy to maintain
> the binding, or fall back to me but use my kernel.org address.
> 
> Jonathan Cameron <jic23@kernel.org>
> 
> I don't mind either way.
> 

Thank you, I'll add you then for this binding.

Thank for your help,

Best regards,
Jonathan Albrieux

> 
> > +
> > +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
> > +
> > +  spi-max-frequency:
> > +    maxItems: 1
> 
> spi-max-frequency doesn't need to be here at all.   We aren't trying to list
> all of the properties that might be present - but rather those that
> are either required or that are part of the description of the device.
> This one is a generic spi binding that may or may not be present.
> 
> > +
> > +  interrupts:
> > +    maxItems: 1
> > +
> > +  interrupt-names:
> > +    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 {
> > +        #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 {
> > +        #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";
> > +        };
> > +    };
> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2020-05-25  7:27 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-20 19:46 [PATCH v3 0/5] iio: imu: bmi160: added regulator and mount-matrix support Jonathan Albrieux
2020-05-20 19:46 ` [PATCH v3 1/5] dt-bindings: iio: imu: bmi160: convert txt format to yaml Jonathan Albrieux
2020-05-24 11:41   ` Jonathan Cameron
2020-05-25  7:27     ` Jonathan Albrieux
2020-05-20 19:46 ` [PATCH v3 2/5] dt-bindings: iio: imu: bmi160: add regulators and mount-matrix Jonathan Albrieux
2020-05-20 19:46 ` [PATCH v3 3/5] iio: imu: bmi160: fix typo Jonathan Albrieux
2020-05-20 19:46 ` [PATCH v3 4/5] iio: imu: bmi160: added regulator support Jonathan Albrieux
2020-05-20 19:46 ` [PATCH v3 5/5] iio: imu: bmi160: added mount-matrix support Jonathan Albrieux
2020-05-24 11:43   ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).