linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] tty: serial: max310x: Add optional reset gpio
@ 2019-06-14 14:11 Mylène Josserand
  2019-07-02 14:44 ` Jan Kundrát
  0 siblings, 1 reply; 2+ messages in thread
From: Mylène Josserand @ 2019-06-14 14:11 UTC (permalink / raw)
  To: gregkh, robh+dt, mark.rutland
  Cc: linux-serial, devicetree, linux-kernel, mylene.josserand,
	thomas.petazzoni

Add the possibility to use a gpio as reset.

Signed-off-by: Mylène Josserand <mylene.josserand@bootlin.com>
---
 Documentation/devicetree/bindings/serial/maxim,max310x.txt | 1 +
 drivers/tty/serial/max310x.c                               | 7 +++++++
 2 files changed, 8 insertions(+)

diff --git a/Documentation/devicetree/bindings/serial/maxim,max310x.txt b/Documentation/devicetree/bindings/serial/maxim,max310x.txt
index 79e10a05a96a..1d7d8a0b4260 100644
--- a/Documentation/devicetree/bindings/serial/maxim,max310x.txt
+++ b/Documentation/devicetree/bindings/serial/maxim,max310x.txt
@@ -15,6 +15,7 @@ Required properties:
   "osc" if an external clock source is used.
 
 Optional properties:
+- reset-gpios: Gpio to use for reset.
 - gpio-controller: Marks the device node as a GPIO controller.
 - #gpio-cells: Should be two. The first cell is the GPIO number and
   the second cell is used to specify the GPIO polarity:
diff --git a/drivers/tty/serial/max310x.c b/drivers/tty/serial/max310x.c
index e5aebbf5f302..d056fa2eed1b 100644
--- a/drivers/tty/serial/max310x.c
+++ b/drivers/tty/serial/max310x.c
@@ -14,6 +14,7 @@
 #include <linux/delay.h>
 #include <linux/device.h>
 #include <linux/gpio/driver.h>
+#include <linux/gpio/consumer.h>
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
@@ -1413,12 +1414,18 @@ static int max310x_spi_probe(struct spi_device *spi)
 		return ret;
 
 	if (spi->dev.of_node) {
+		struct gpio_desc *reset_gpio;
 		const struct of_device_id *of_id =
 			of_match_device(max310x_dt_ids, &spi->dev);
 		if (!of_id)
 			return -ENODEV;
 
 		devtype = (struct max310x_devtype *)of_id->data;
+		reset_gpio = devm_gpiod_get_optional(&spi->dev, "reset",
+						     GPIOD_OUT_HIGH);
+		if (IS_ERR(reset_gpio))
+			return PTR_ERR(reset_gpio);
+		gpiod_set_value_cansleep(reset_gpio, 0);
 	} else {
 		const struct spi_device_id *id_entry = spi_get_device_id(spi);
 
-- 
2.11.0


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

* Re: [PATCH v1] tty: serial: max310x: Add optional reset gpio
  2019-06-14 14:11 [PATCH v1] tty: serial: max310x: Add optional reset gpio Mylène Josserand
@ 2019-07-02 14:44 ` Jan Kundrát
  0 siblings, 0 replies; 2+ messages in thread
From: Jan Kundrát @ 2019-07-02 14:44 UTC (permalink / raw)
  To: Mylène Josserand
  Cc: gregkh, robh+dt, mark.rutland, linux-serial, devicetree,
	linux-kernel, thomas.petazzoni

On pátek 14. června 2019 16:11:12 CEST, Mylène Josserand wrote:
> --- a/Documentation/devicetree/bindings/serial/maxim,max310x.txt
> +++ b/Documentation/devicetree/bindings/serial/maxim,max310x.txt
> @@ -15,6 +15,7 @@ Required properties:
>    "osc" if an external clock source is used.
>  
>  Optional properties:
> +- reset-gpios: Gpio to use for reset.

"GPIO", not "Gpio", for consistency.

>  	if (spi->dev.of_node) {
> +		struct gpio_desc *reset_gpio;
>  		const struct of_device_id *of_id =
>  			of_match_device(max310x_dt_ids, &spi->dev);
>  		if (!of_id)
>  			return -ENODEV;
>  
>  		devtype = (struct max310x_devtype *)of_id->data;
> +		reset_gpio = devm_gpiod_get_optional(&spi->dev, "reset",
> +						     GPIOD_OUT_HIGH);
> +		if (IS_ERR(reset_gpio))
> +			return PTR_ERR(reset_gpio);
> +		gpiod_set_value_cansleep(reset_gpio, 0);
>  	} else {

The RST signal is active-low on the chip, but the code initializes the 
output to GPIOD_OUT_HIGH. Are you perhaps relying on a DT binding setting 
an ACTIVE_LOW flag on the reset GPIO lane? This should be documented.

Assuming that this polarity inversion works, the code first asserts the 
reset, then it performs no explicit waiting, and then it clears the RST 
signal. I checked MAX14830's datasheet, and there's no minimal reset 
duration, so perhaps this is safe, but it looks a bit odd to me.

With kind regards,
Jan

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

end of thread, other threads:[~2019-07-02 14:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-14 14:11 [PATCH v1] tty: serial: max310x: Add optional reset gpio Mylène Josserand
2019-07-02 14:44 ` Jan Kundrát

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).