* [PATCH] serial: core: Add option to enable RS485 mode via GPIO @ 2023-11-15 20:07 Tomas Paukrt 2023-11-19 12:48 ` Lino Sanfilippo 0 siblings, 1 reply; 9+ messages in thread From: Tomas Paukrt @ 2023-11-15 20:07 UTC (permalink / raw) To: linux-serial This patch provides an option to enable the RS485 mode at boot time based on the state of a GPIO pin (DIP switch or configuration jumper). The GPIO is defined by the device tree property "rs485-mode-gpio". Signed-off-by: Tomas Paukrt <tomaspaukrt@email.cz> --- drivers/tty/serial/serial_core.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index f1348a5..444d7fd 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -3603,6 +3603,18 @@ int uart_get_rs485_mode(struct uart_port *port) } /* + * Enable the RS485 mode based on the state of a GPIO pin. + */ + desc = devm_gpiod_get_optional(dev, "rs485-mode", GPIOD_IN); + if (IS_ERR(desc)) + return dev_err_probe(dev, PTR_ERR(desc), "Cannot get rs485-mode-gpio\n"); + if (desc) { + if (gpiod_get_value(desc)) + rs485conf->flags |= SER_RS485_ENABLED; + devm_gpiod_put(dev, desc); + } + + /* * Disabling termination by default is the safe choice: Else if many * bus participants enable it, no communication is possible at all. * Works fine for short cables and users may enable for longer cables. -- 2.7.4 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] serial: core: Add option to enable RS485 mode via GPIO 2023-11-15 20:07 [PATCH] serial: core: Add option to enable RS485 mode via GPIO Tomas Paukrt @ 2023-11-19 12:48 ` Lino Sanfilippo 2023-11-20 7:55 ` [PATCH v2] " Tomas Paukrt 0 siblings, 1 reply; 9+ messages in thread From: Lino Sanfilippo @ 2023-11-19 12:48 UTC (permalink / raw) To: Tomas Paukrt, linux-serial Hi, On 15.11.23 at 21:07, Tomas Paukrt wrote: > This patch provides an option to enable the RS485 mode at boot time > based on the state of a GPIO pin (DIP switch or configuration jumper). > The GPIO is defined by the device tree property "rs485-mode-gpio". This needs documentation in rs485.yaml. > > Signed-off-by: Tomas Paukrt <tomaspaukrt@email.cz> > --- > drivers/tty/serial/serial_core.c | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > > diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c > index f1348a5..444d7fd 100644 > --- a/drivers/tty/serial/serial_core.c > +++ b/drivers/tty/serial/serial_core.c > @@ -3603,6 +3603,18 @@ int uart_get_rs485_mode(struct uart_port *port) > } > > /* > + * Enable the RS485 mode based on the state of a GPIO pin. > + */ > + desc = devm_gpiod_get_optional(dev, "rs485-mode", GPIOD_IN); > + if (IS_ERR(desc)) > + return dev_err_probe(dev, PTR_ERR(desc), "Cannot get rs485-mode-gpio\n"); > + if (desc) { > + if (gpiod_get_value(desc)) > + rs485conf->flags |= SER_RS485_ENABLED; > + devm_gpiod_put(dev, desc); > + } So this means RS485 cannot be disabled any more after that. Then we must not allow to unset SER_RS485_ENABLED if userspace tries to do so via TIOCSRS485. Regards, Lino ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2] serial: core: Add option to enable RS485 mode via GPIO 2023-11-19 12:48 ` Lino Sanfilippo @ 2023-11-20 7:55 ` Tomas Paukrt 2023-11-20 18:21 ` Krzysztof Kozlowski 0 siblings, 1 reply; 9+ messages in thread From: Tomas Paukrt @ 2023-11-20 7:55 UTC (permalink / raw) To: Lino Sanfilippo; +Cc: linux-serial This patch provides an option to enable the RS485 mode at boot time based on the state of a GPIO pin (DIP switch or configuration jumper). The GPIO is defined by the device tree property "rs485-mode-gpio". Signed-off-by: Tomas Paukrt <tomaspaukrt@email.cz> --- Documentation/devicetree/bindings/serial/rs485.yaml | 4 ++++ drivers/tty/serial/serial_core.c | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/Documentation/devicetree/bindings/serial/rs485.yaml b/Documentation/devicetree/bindings/serial/rs485.yaml index 9418fd6..7a72f37 100644 --- a/Documentation/devicetree/bindings/serial/rs485.yaml +++ b/Documentation/devicetree/bindings/serial/rs485.yaml @@ -47,6 +47,10 @@ properties: later with proper ioctl. $ref: /schemas/types.yaml#/definitions/flag + rs485-mode-gpio: + description: GPIO pin to enable the RS485 mode at boot time. + maxItems: 1 + rs485-rx-during-tx: description: enables the receiving of data even while sending data. $ref: /schemas/types.yaml#/definitions/flag diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index f1348a5..f1bf0b9 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -3603,6 +3603,18 @@ int uart_get_rs485_mode(struct uart_port *port) } /* + * Enable the RS485 mode based on the state of a GPIO pin. + */ + desc = devm_gpiod_get_optional(dev, "rs485-mode", GPIOD_IN); + if (IS_ERR(desc)) + return dev_err_probe(dev, PTR_ERR(desc), "Cannot get rs485-mode-gpio\n"); + if (desc) { + if (gpiod_get_value(desc)) + rs485conf->flags |= SER_RS485_ENABLED; + devm_gpiod_put(dev, desc); + } + + /* * Disabling termination by default is the safe choice: Else if many * bus participants enable it, no communication is possible at all. * Works fine for short cables and users may enable for longer cables. -- 2.7.4 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v2] serial: core: Add option to enable RS485 mode via GPIO 2023-11-20 7:55 ` [PATCH v2] " Tomas Paukrt @ 2023-11-20 18:21 ` Krzysztof Kozlowski 2023-11-20 21:45 ` [PATCH v3 1/2] " Tomas Paukrt 2023-11-20 21:45 ` [PATCH v3 2/2] dt-bindings: serial: " Tomas Paukrt 0 siblings, 2 replies; 9+ messages in thread From: Krzysztof Kozlowski @ 2023-11-20 18:21 UTC (permalink / raw) To: Tomas Paukrt, Lino Sanfilippo; +Cc: linux-serial On 20/11/2023 08:55, Tomas Paukrt wrote: > This patch provides an option to enable the RS485 mode at boot time Please do not use "This commit/patch", but imperative mood. See longer explanation here: https://elixir.bootlin.com/linux/v5.17.1/source/Documentation/process/submitting-patches.rst#L95 > based on the state of a GPIO pin (DIP switch or configuration jumper). > The GPIO is defined by the device tree property "rs485-mode-gpio". > > Signed-off-by: Tomas Paukrt <tomaspaukrt@email.cz> Please use scripts/get_maintainers.pl to get a list of necessary people and lists to CC. It might happen, that command when run on an older kernel, gives you outdated entries. Therefore please be sure you base your patches on recent Linux kernel. You missed at least devicetree list (maybe more), so this won't be tested by automated tooling. Performing review on untested code might be a waste of time, thus I will skip this patch entirely till you follow the process allowing the patch to be tested. Please kindly resend and include all necessary To/Cc entries. > --- > Documentation/devicetree/bindings/serial/rs485.yaml | 4 ++++ > drivers/tty/serial/serial_core.c | 12 ++++++++++++ > 2 files changed, 16 insertions(+) Please run scripts/checkpatch.pl and fix reported warnings. Some warnings can be ignored, but the code here looks like it needs a fix. Feel free to get in touch if the warning is not clear. Please use subject prefixes matching the subsystem. You can get them for example with `git log --oneline -- DIRECTORY_OR_FILE` on the directory your patch is touching. Best regards, Krzysztof ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v3 1/2] serial: core: Add option to enable RS485 mode via GPIO 2023-11-20 18:21 ` Krzysztof Kozlowski @ 2023-11-20 21:45 ` Tomas Paukrt 2023-11-21 7:02 ` Krzysztof Kozlowski 2023-11-23 14:14 ` Greg Kroah-Hartman 2023-11-20 21:45 ` [PATCH v3 2/2] dt-bindings: serial: " Tomas Paukrt 1 sibling, 2 replies; 9+ messages in thread From: Tomas Paukrt @ 2023-11-20 21:45 UTC (permalink / raw) To: Krzysztof Kozlowski, Rob Herring, Conor Dooley, Greg Kroah-Hartman, Jiri Slaby Cc: linux-serial, Lino Sanfilippo, linux-kernel, devicetree Add an option to enable the RS485 mode at boot time based on the state of a GPIO pin (DIP switch or configuration jumper). The GPIO is defined by the device tree property "rs485-mode-gpio". Signed-off-by: Tomas Paukrt <tomaspaukrt@email.cz> --- drivers/tty/serial/serial_core.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index f1348a5..f1bf0b9 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -3603,6 +3603,18 @@ int uart_get_rs485_mode(struct uart_port *port) } /* + * Enable the RS485 mode based on the state of a GPIO pin. + */ + desc = devm_gpiod_get_optional(dev, "rs485-mode", GPIOD_IN); + if (IS_ERR(desc)) + return dev_err_probe(dev, PTR_ERR(desc), "Cannot get rs485-mode-gpio\n"); + if (desc) { + if (gpiod_get_value(desc)) + rs485conf->flags |= SER_RS485_ENABLED; + devm_gpiod_put(dev, desc); + } + + /* * Disabling termination by default is the safe choice: Else if many * bus participants enable it, no communication is possible at all. * Works fine for short cables and users may enable for longer cables. -- 2.7.4 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v3 1/2] serial: core: Add option to enable RS485 mode via GPIO 2023-11-20 21:45 ` [PATCH v3 1/2] " Tomas Paukrt @ 2023-11-21 7:02 ` Krzysztof Kozlowski 2023-11-23 14:14 ` Greg Kroah-Hartman 1 sibling, 0 replies; 9+ messages in thread From: Krzysztof Kozlowski @ 2023-11-21 7:02 UTC (permalink / raw) To: Tomas Paukrt, Rob Herring, Conor Dooley, Greg Kroah-Hartman, Jiri Slaby Cc: linux-serial, Lino Sanfilippo, linux-kernel, devicetree On 20/11/2023 22:45, Tomas Paukrt wrote: > Add an option to enable the RS485 mode at boot time based on > the state of a GPIO pin (DIP switch or configuration jumper). > The GPIO is defined by the device tree property "rs485-mode-gpio". > > Signed-off-by: Tomas Paukrt <tomaspaukrt@email.cz> > --- > drivers/tty/serial/serial_core.c | 12 ++++++++++++ Why the subject is "Re:"? Please send each patchset as independent thread. Best regards, Krzysztof ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v3 1/2] serial: core: Add option to enable RS485 mode via GPIO 2023-11-20 21:45 ` [PATCH v3 1/2] " Tomas Paukrt 2023-11-21 7:02 ` Krzysztof Kozlowski @ 2023-11-23 14:14 ` Greg Kroah-Hartman 1 sibling, 0 replies; 9+ messages in thread From: Greg Kroah-Hartman @ 2023-11-23 14:14 UTC (permalink / raw) To: Tomas Paukrt Cc: Krzysztof Kozlowski, Rob Herring, Conor Dooley, Jiri Slaby, linux-serial, Lino Sanfilippo, linux-kernel, devicetree On Mon, Nov 20, 2023 at 10:45:20PM +0100, Tomas Paukrt wrote: > Add an option to enable the RS485 mode at boot time based on > the state of a GPIO pin (DIP switch or configuration jumper). > The GPIO is defined by the device tree property "rs485-mode-gpio". > > Signed-off-by: Tomas Paukrt <tomaspaukrt@email.cz> > --- > drivers/tty/serial/serial_core.c | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > > diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c > index f1348a5..f1bf0b9 100644 > --- a/drivers/tty/serial/serial_core.c > +++ b/drivers/tty/serial/serial_core.c > @@ -3603,6 +3603,18 @@ int uart_get_rs485_mode(struct uart_port *port) > } > > /* > + * Enable the RS485 mode based on the state of a GPIO pin. > + */ > + desc = devm_gpiod_get_optional(dev, "rs485-mode", GPIOD_IN); > + if (IS_ERR(desc)) > + return dev_err_probe(dev, PTR_ERR(desc), "Cannot get rs485-mode-gpio\n"); > + if (desc) { > + if (gpiod_get_value(desc)) > + rs485conf->flags |= SER_RS485_ENABLED; > + devm_gpiod_put(dev, desc); > + } > + > + /* > * Disabling termination by default is the safe choice: Else if many > * bus participants enable it, no communication is possible at all. > * Works fine for short cables and users may enable for longer cables. > -- > 2.7.4 > Hi, This is the friendly patch-bot of Greg Kroah-Hartman. You have sent him a patch that has triggered this response. He used to manually respond to these common problems, but in order to save his sanity (he kept writing the same thing over and over, yet to different people), I was created. Hopefully you will not take offence and will fix the problem in your patch and resubmit it so that it can be accepted into the Linux kernel tree. You are receiving this message because of the following common error(s) as indicated below: - This looks like a new version of a previously submitted patch, but you did not list below the --- line any changes from the previous version. Please read the section entitled "The canonical patch format" in the kernel file, Documentation/process/submitting-patches.rst for what needs to be done here to properly describe this. If you wish to discuss this problem further, or you have questions about how to resolve this issue, please feel free to respond to this email and Greg will reply once he has dug out from the pending patches received from other developers. thanks, greg k-h's patch email bot ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v3 2/2] dt-bindings: serial: Add option to enable RS485 mode via GPIO 2023-11-20 18:21 ` Krzysztof Kozlowski 2023-11-20 21:45 ` [PATCH v3 1/2] " Tomas Paukrt @ 2023-11-20 21:45 ` Tomas Paukrt 2023-11-21 7:04 ` Krzysztof Kozlowski 1 sibling, 1 reply; 9+ messages in thread From: Tomas Paukrt @ 2023-11-20 21:45 UTC (permalink / raw) To: Krzysztof Kozlowski, Rob Herring, Conor Dooley, Greg Kroah-Hartman, Jiri Slaby Cc: linux-serial, Lino Sanfilippo, linux-kernel, devicetree Add the device tree property "rs485-mode-gpio". Signed-off-by: Tomas Paukrt <tomaspaukrt@email.cz> --- Documentation/devicetree/bindings/serial/rs485.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Documentation/devicetree/bindings/serial/rs485.yaml b/Documentation/devicetree/bindings/serial/rs485.yaml index 9418fd6..7a72f37 100644 --- a/Documentation/devicetree/bindings/serial/rs485.yaml +++ b/Documentation/devicetree/bindings/serial/rs485.yaml @@ -47,6 +47,10 @@ properties: later with proper ioctl. $ref: /schemas/types.yaml#/definitions/flag + rs485-mode-gpio: + description: GPIO pin to enable RS485 mode at boot time. + maxItems: 1 + rs485-rx-during-tx: description: enables the receiving of data even while sending data. $ref: /schemas/types.yaml#/definitions/flag -- 2.7.4 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v3 2/2] dt-bindings: serial: Add option to enable RS485 mode via GPIO 2023-11-20 21:45 ` [PATCH v3 2/2] dt-bindings: serial: " Tomas Paukrt @ 2023-11-21 7:04 ` Krzysztof Kozlowski 0 siblings, 0 replies; 9+ messages in thread From: Krzysztof Kozlowski @ 2023-11-21 7:04 UTC (permalink / raw) To: Tomas Paukrt, Rob Herring, Conor Dooley, Greg Kroah-Hartman, Jiri Slaby Cc: linux-serial, Lino Sanfilippo, linux-kernel, devicetree On 20/11/2023 22:45, Tomas Paukrt wrote: > Add the device tree property "rs485-mode-gpio". > > Signed-off-by: Tomas Paukrt <tomaspaukrt@email.cz> > --- > Documentation/devicetree/bindings/serial/rs485.yaml | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/Documentation/devicetree/bindings/serial/rs485.yaml b/Documentation/devicetree/bindings/serial/rs485.yaml > index 9418fd6..7a72f37 100644 > --- a/Documentation/devicetree/bindings/serial/rs485.yaml > +++ b/Documentation/devicetree/bindings/serial/rs485.yaml > @@ -47,6 +47,10 @@ properties: > later with proper ioctl. > $ref: /schemas/types.yaml#/definitions/flag > > + rs485-mode-gpio: > + description: GPIO pin to enable RS485 mode at boot time. > + maxItems: 1 > + This does not look like generic RS485 property. Commit msg also does not help to understand the context. Best regards, Krzysztof ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2023-11-23 17:22 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2023-11-15 20:07 [PATCH] serial: core: Add option to enable RS485 mode via GPIO Tomas Paukrt 2023-11-19 12:48 ` Lino Sanfilippo 2023-11-20 7:55 ` [PATCH v2] " Tomas Paukrt 2023-11-20 18:21 ` Krzysztof Kozlowski 2023-11-20 21:45 ` [PATCH v3 1/2] " Tomas Paukrt 2023-11-21 7:02 ` Krzysztof Kozlowski 2023-11-23 14:14 ` Greg Kroah-Hartman 2023-11-20 21:45 ` [PATCH v3 2/2] dt-bindings: serial: " Tomas Paukrt 2023-11-21 7:04 ` Krzysztof Kozlowski
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox