Skip to contentSkip to conversation

iio: sx9500: add final devicetree support

PATCH Superseded Christoph Fritz 5 participants 13 messages Sep 2, 2016 – Sep 12, 2016 10 messages not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iio: sx9500: add final devicetree support

This makes sx9500 driver usable on devicetree based platforms too.

---
 .../devicetree/bindings/iio/proximity/sx9500.txt   | 22 ++++++++++++++++++++++
 drivers/iio/proximity/sx9500.c                     |  7 +++++++
 2 files changed, 29 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/proximity/sx9500.txt
Documentation/devicetree/bindings/iio/proximity/sx9500.txt new file +22 -0
new file mode 100644
index 0000000..90ede53
@@ -0,0 +1,22 @@
+Semtech's SX9500 capacitive proximity button device driver
+
+Required properties:
+	- compatible: must be "semtech,sx9500"
+	- reg: i2c address where to find the device
+	- interrupt-parent : should be the phandle for the interrupt controller
+	- interrupts : the sole interrupt generated by the device
+
+	Refer to interrupt-controller/interrupts.txt for generic
+	interrupt client node bindings.
+
+Example:
+
+sx9500@28 {
+	compatible = "semtech,sx9500";
+	reg = <0x28>;
+	pinctrl-names = "default";
+	pinctrl-0 = <&pinctrl_sx9500>;
+	interrupt-parent = <&gpio2>;
+	interrupts = <16 IRQ_TYPE_LEVEL_LOW>;
+	reset-gpios = <&gpio2 10 GPIO_ACTIVE_HIGH>;
+};
drivers/iio/proximity/sx9500.c +7 -0
index 66cd09a..a136b34 100644
@@ -1025,6 +1025,12 @@ static const struct acpi_device_id sx9500_acpi_match[] = {
 };
 MODULE_DEVICE_TABLE(acpi, sx9500_acpi_match);
 
+static const struct of_device_id sx9500_of_match[] = {
+	{ .compatible = "semtech,sx9500", },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, sx9500_of_match);
+
 static const struct i2c_device_id sx9500_id[] = {
 	{"sx9500", 0},
 	{ },
@@ -1035,6 +1041,7 @@ static struct i2c_driver sx9500_driver = {
 	.driver = {
 		.name	= SX9500_DRIVER_NAME,
 		.acpi_match_table = ACPI_PTR(sx9500_acpi_match),
+		.of_match_table = of_match_ptr(sx9500_of_match),
 		.pm = &sx9500_pm_ops,
 	},
 	.probe		= sx9500_probe,
Signature · 1 line
2.1.4

A message that is not in the archive (sent off-list or not yet received): 1472827740.1929.26.camel-gM/[email protected]

#2 lore raw

Documentation/devicetree/bindings/iio/proximity/sx9500.txt line 21

Quoted 8 lines · Christoph Fritz
Documentation/devicetree/bindings/iio/proximity/sx9500.txt new file +8 -0
+sx9500@28 {
+       compatible = "semtech,sx9500";
+       reg = <0x28>;
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_sx9500>;
+       interrupt-parent = <&gpio2>;
+       interrupts = <16 IRQ_TYPE_LEVEL_LOW>;
+       reset-gpios = <&gpio2 10 GPIO_ACTIVE_HIGH>;

Datasheet says the reset is active low.

A message that is not in the archive (sent off-list or not yet received): CAOMZO5BeL1EKOQvZQoXXObttHSKxL7UQ1s2r8H4EOuROOb_YnQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#4 lore raw
Quoted 12 lines · Fabio Estevam

Documentation/devicetree/bindings/iio/proximity/sx9500.txt line 21

Quoted 8 lines · Christoph Fritz
Documentation/devicetree/bindings/iio/proximity/sx9500.txt new file +8 -0
+sx9500@28 {
+       compatible = "semtech,sx9500";
+       reg = <0x28>;
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_sx9500>;
+       interrupt-parent = <&gpio2>;
+       interrupts = <16 IRQ_TYPE_LEVEL_LOW>;
+       reset-gpios = <&gpio2 10 GPIO_ACTIVE_HIGH>;
Quoted 1 line

Datasheet says the reset is active low.

Here on my board I'm using the reset pin as an open-drain with external pullup, so GPIO_ACTIVE_HIGH is valid.

As this is an example, I don't care if it says _HIGH or _LOW.

A message that is not in the archive (sent off-list or not yet received): 1472828671.1929.32.camel-gM/[email protected]

#6 lore raw
Quoted 4 lines · Christoph Fritz

Here on my board I'm using the reset pin as an open-drain with external pullup, so GPIO_ACTIVE_HIGH is valid.

As this is an example, I don't care if it says _HIGH or _LOW.

Then probably it is better to remove "reset-gpios" from the example.

The driver does not parse this dt property and the reset is being done via software command as far as I can see.
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): CAOMZO5BVDS=AaSyRS0ELBiEKx3RxdstXgA_xJ6ANUzKDxdyBxg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#8 lore raw
Quoted 6 lines · Fabio Estevam
Quoted 3 lines · Christoph Fritz

Here on my board I'm using the reset pin as an open-drain with external pullup, so GPIO_ACTIVE_HIGH is valid.

Quoted 6 lines
Quoted 1 line

As this is an example, I don't care if it says _HIGH or _LOW.

Then probably it is better to remove "reset-gpios" from the example.

The driver does not parse this dt property and the reset is being done via software command as far as I can see.

What do you mean by "software command", to send a reset command by i2c?

The reset GPIO is fetched in sx9500 here:

See sx9500_gpio_probe():
...

        data->gpiod_rst = devm_gpiod_get_index(dev, SX9500_GPIO_RESET,
                                               0, GPIOD_OUT_HIGH);

...

A message that is not in the archive (sent off-list or not yet received): 1472829819.12668.3.camel-gM/[email protected]

#10 lore raw
Quoted 1 line · Christoph Fritz

What do you mean by "software command", to send a reset command by i2c?

Yes, by writing 0xDE into RegReset register.

Quoted 7 lines

The reset GPIO is fetched in sx9500 here:

See sx9500_gpio_probe():
...

        data->gpiod_rst = devm_gpiod_get_index(dev, SX9500_GPIO_RESET,
                                               0, GPIOD_OUT_HIGH);

but there is no code that actually reads the "reset-gpios" dt property.

Does your board work well without passing "reset-gpios" property? --
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): CAOMZO5DbJLnH1wm2KuML+O36O-eSYWeGwrxE5pdKSRtB-Js-yA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#12 lore raw
Quoted 8 lines · Fabio Estevam
Quoted 1 line · Christoph Fritz

What do you mean by "software command", to send a reset command by i2c?

Yes, by writing 0xDE into RegReset register.

Quoted 1 line
Quoted 8 lines
Quoted 6 lines

The reset GPIO is fetched in sx9500 here:

See sx9500_gpio_probe():
...

        data->gpiod_rst = devm_gpiod_get_index(dev, SX9500_GPIO_RESET,
                                               0, GPIOD_OUT_HIGH);

but there is no code that actually reads the "reset-gpios" dt property.

But there is: devm_gpiod_get_index() calls gpiod_get_index() which calls of_find_gpio() for of-string "reset-gpios".

Quoted 2 lines

Does your board work well without passing "reset-gpios" property?

I don't know, the driver looks that way. I'll check that. If so, I'll fix the docu and add the reset-gpios property as optional. Okay?

Thanks
-- Christoph

A message that is not in the archive (sent off-list or not yet received): 1472834833.12668.11.camel-gM/[email protected]

#14 lore raw
Quoted 2 lines · Christoph Fritz

But there is: devm_gpiod_get_index() calls gpiod_get_index() which calls of_find_gpio() for of-string "reset-gpios".

Ok, great.

Quoted 5 lines
Quoted 2 lines

Does your board work well without passing "reset-gpios" property?

I don't know, the driver looks that way. I'll check that. If so, I'll fix the docu and add the reset-gpios property as optional. Okay?

My main concern was the gpio reset polarity. Not sure why active high works in your case.
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): CAOMZO5B8ttBvf-zimO5R_kgpzR2bxF73Ur0vZpBKUX8Ytbs8uQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#16 lore raw

PATCH v2 1/1 iio: sx9500: add final devicetree support

This makes sx9500 driver usable on devicetree based platforms too.

---

Changes in v2:

- fix docu: add optional property reset-gpios
- adapt docu: change example "reset-gpios"

 .../devicetree/bindings/iio/proximity/sx9500.txt   | 24 ++++++++++++++++++++++
 drivers/iio/proximity/sx9500.c                     |  7 +++++++
 2 files changed, 31 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/proximity/sx9500.txt
Documentation/devicetree/bindings/iio/proximity/sx9500.txt new file +24 -0
new file mode 100644
index 0000000..b301dd2
@@ -0,0 +1,24 @@
+Semtech's SX9500 capacitive proximity button device driver
+
+Required properties:
+	- compatible: must be "semtech,sx9500"
+	- reg: i2c address where to find the device
+	- interrupt-parent : should be the phandle for the interrupt controller
+	- interrupts : the sole interrupt generated by the device
+
+	Refer to interrupt-controller/interrupts.txt for generic
+	interrupt client node bindings.
+
+Optional properties:
+	- reset-gpios: Reference to the GPIO connected to the device's active
+	  low reset pin.
+
+Example:
+
+sx9500@28 {
+	compatible = "semtech,sx9500";
+	reg = <0x28>;
+	interrupt-parent = <&gpio2>;
+	interrupts = <16 IRQ_TYPE_LEVEL_LOW>;
+	reset-gpios = <&gpio2 10 GPIO_ACTIVE_LOW>;
+};
drivers/iio/proximity/sx9500.c +7 -0
index 66cd09a..a136b34 100644
@@ -1025,6 +1025,12 @@ static const struct acpi_device_id sx9500_acpi_match[] = {
 };
 MODULE_DEVICE_TABLE(acpi, sx9500_acpi_match);
 
+static const struct of_device_id sx9500_of_match[] = {
+	{ .compatible = "semtech,sx9500", },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, sx9500_of_match);
+
 static const struct i2c_device_id sx9500_id[] = {
 	{"sx9500", 0},
 	{ },
@@ -1035,6 +1041,7 @@ static struct i2c_driver sx9500_driver = {
 	.driver = {
 		.name	= SX9500_DRIVER_NAME,
 		.acpi_match_table = ACPI_PTR(sx9500_acpi_match),
+		.of_match_table = of_match_ptr(sx9500_of_match),
 		.pm = &sx9500_pm_ops,
 	},
 	.probe		= sx9500_probe,
Signature · 6 lines
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 1472898600.1918.4.camel-gM/[email protected]

Reviewed-by
#19 lore raw
In reply to a message not in the archive
Quoted 3 lines · Christoph Fritz

This makes sx9500 driver usable on devicetree based platforms too.

Quoted 68 lines

---

Changes in v2:

- fix docu: add optional property reset-gpios
- adapt docu: change example "reset-gpios"

 .../devicetree/bindings/iio/proximity/sx9500.txt   | 24 ++++++++++++++++++++++
 drivers/iio/proximity/sx9500.c                     |  7 +++++++
 2 files changed, 31 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/proximity/sx9500.txt
Documentation/devicetree/bindings/iio/proximity/sx9500.txt new file +24 -0
new file mode 100644
index 0000000..b301dd2
@@ -0,0 +1,24 @@
+Semtech's SX9500 capacitive proximity button device driver
+
+Required properties:
+       - compatible: must be "semtech,sx9500"
+       - reg: i2c address where to find the device
+       - interrupt-parent : should be the phandle for the interrupt controller
+       - interrupts : the sole interrupt generated by the device
+
+       Refer to interrupt-controller/interrupts.txt for generic
+       interrupt client node bindings.
+
+Optional properties:
+       - reset-gpios: Reference to the GPIO connected to the device's active
+         low reset pin.
+
+Example:
+
+sx9500@28 {
+       compatible = "semtech,sx9500";
+       reg = <0x28>;
+       interrupt-parent = <&gpio2>;
+       interrupts = <16 IRQ_TYPE_LEVEL_LOW>;
+       reset-gpios = <&gpio2 10 GPIO_ACTIVE_LOW>;
+};
drivers/iio/proximity/sx9500.c +7 -1
index 66cd09a..a136b34 100644
@@ -1025,6 +1025,12 @@ static const struct acpi_device_id sx9500_acpi_match[] = {
 };
 MODULE_DEVICE_TABLE(acpi, sx9500_acpi_match);
 
+static const struct of_device_id sx9500_of_match[] = {
+       { .compatible = "semtech,sx9500", },
+       { }
+};
+MODULE_DEVICE_TABLE(of, sx9500_of_match);
+
 static const struct i2c_device_id sx9500_id[] = {
        {"sx9500", 0},
        { },
@@ -1035,6 +1041,7 @@ static struct i2c_driver sx9500_driver = {
        .driver = {
                .name   = SX9500_DRIVER_NAME,
                .acpi_match_table = ACPI_PTR(sx9500_acpi_match),
+               .of_match_table = of_match_ptr(sx9500_of_match),
                .pm = &sx9500_pm_ops,
        },
        .probe          = sx9500_probe,
--
Quoted 2 lines

2.1.4

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): CAA+rx9Th84nt8RQpXX8MhcN9ghhdJN1KBuGfd2oY59_77BiBGA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#21 lore raw
Quoted 7 lines · Vlad Dogaru
Quoted 3 lines · Christoph Fritz

This makes sx9500 driver usable on devicetree based platforms too.

This is simple enough I'm taking it without a device tree ack.

Applied to the togreg branch of iio.git - initially pushed out as testing for the autobuilders to play with it.

Thanks,

Jonathan

Quoted 71 lines
Quoted 71 lines

---

Changes in v2:

- fix docu: add optional property reset-gpios
- adapt docu: change example "reset-gpios"

 .../devicetree/bindings/iio/proximity/sx9500.txt   | 24 ++++++++++++++++++++++
 drivers/iio/proximity/sx9500.c                     |  7 +++++++
 2 files changed, 31 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/proximity/sx9500.txt
Documentation/devicetree/bindings/iio/proximity/sx9500.txt new file +24 -0
new file mode 100644
index 0000000..b301dd2
@@ -0,0 +1,24 @@
+Semtech's SX9500 capacitive proximity button device driver
+
+Required properties:
+       - compatible: must be "semtech,sx9500"
+       - reg: i2c address where to find the device
+       - interrupt-parent : should be the phandle for the interrupt controller
+       - interrupts : the sole interrupt generated by the device
+
+       Refer to interrupt-controller/interrupts.txt for generic
+       interrupt client node bindings.
+
+Optional properties:
+       - reset-gpios: Reference to the GPIO connected to the device's active
+         low reset pin.
+
+Example:
+
+sx9500@28 {
+       compatible = "semtech,sx9500";
+       reg = <0x28>;
+       interrupt-parent = <&gpio2>;
+       interrupts = <16 IRQ_TYPE_LEVEL_LOW>;
+       reset-gpios = <&gpio2 10 GPIO_ACTIVE_LOW>;
+};
drivers/iio/proximity/sx9500.c +7 -1
index 66cd09a..a136b34 100644
@@ -1025,6 +1025,12 @@ static const struct acpi_device_id sx9500_acpi_match[] = {
 };
 MODULE_DEVICE_TABLE(acpi, sx9500_acpi_match);
 
+static const struct of_device_id sx9500_of_match[] = {
+       { .compatible = "semtech,sx9500", },
+       { }
+};
+MODULE_DEVICE_TABLE(of, sx9500_of_match);
+
 static const struct i2c_device_id sx9500_id[] = {
        {"sx9500", 0},
        { },
@@ -1035,6 +1041,7 @@ static struct i2c_driver sx9500_driver = {
        .driver = {
                .name   = SX9500_DRIVER_NAME,
                .acpi_match_table = ACPI_PTR(sx9500_acpi_match),
+               .of_match_table = of_match_ptr(sx9500_of_match),
                .pm = &sx9500_pm_ops,
        },
        .probe          = sx9500_probe,
--

2.1.4

Acked-by
#22 lore raw
In reply to a message not in the archive
Quoted 7 lines · Christoph Fritz

This makes sx9500 driver usable on devicetree based platforms too.

---

Changes in v2:

Quoted 7 lines

- fix docu: add optional property reset-gpios
- adapt docu: change example "reset-gpios"

 .../devicetree/bindings/iio/proximity/sx9500.txt   | 24 ++++++++++++++++++++++
 drivers/iio/proximity/sx9500.c                     |  7 +++++++
 2 files changed, 31 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/proximity/sx9500.txt