devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] tty: serial: uartlite: Disable changing fixed parameters
@ 2021-07-23 22:31 Sean Anderson
  2021-07-23 22:31 ` [PATCH 1/5] dt-bindings: serial: uartlite: Convert to json-schema Sean Anderson
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Sean Anderson @ 2021-07-23 22:31 UTC (permalink / raw)
  To: Peter Korsgaard, Peter Korsgaard, linux-serial
  Cc: Greg Kroah-Hartman, Alexander Sverdlin, Michal Simek,
	Sean Anderson, Rich Felker, Rob Herring, Yoshinori Sato,
	devicetree

The uartlite device is a "soft" device and certain parameters (such as
data bits, parity, and baud) are configured at synthesis time, and
cannot be discovered at runtime. Fortunately, bindings for this device
typically include some of these parameters (especially baud rate).
Instead of silently letting Linux's termios drift away from what the
hardware is actually doing, make the termios reflect the hardware, and
prevent them from being changed. With this series applied, the user
recieves an error message the first time they try and change these
termios:

    # stty parity
    [    7.221696] uartlite 84000000.serial: only 'n' parity supported
    [    7.222139] uartlite 84000000.serial: only 8 data bits supported
    stty: standard input: cannot perform all requested operations

In addition, the configured baud/parity/bits/etc. are exposed through
the standard termios ioctls, instead of using the default termios for
unconfigured ttys.


Sean Anderson (5):
  dt-bindings: serial: uartlite: Convert to json-schema
  dt-bindings: serial: uartlite: Add properties for synthesis-time
    parameters
  sh: j2: Update uartlite binding with data and parity properties
  tty: serial: uartlite: Initialize termios with fixed synthesis
    parameters
  tty: serial: uartlite: Prevent changing fixed parameters

 .../bindings/serial/xlnx,opb-uartlite.txt     |  23 ----
 .../bindings/serial/xlnx,opb-uartlite.yaml    |  92 ++++++++++++++
 arch/sh/boot/dts/j2_mimas_v2.dts              |   2 +
 drivers/tty/serial/uartlite.c                 | 118 ++++++++++++++++--
 4 files changed, 203 insertions(+), 32 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/serial/xlnx,opb-uartlite.txt
 create mode 100644 Documentation/devicetree/bindings/serial/xlnx,opb-uartlite.yaml

-- 
2.25.1


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

* [PATCH 1/5] dt-bindings: serial: uartlite: Convert to json-schema
  2021-07-23 22:31 [PATCH 0/5] tty: serial: uartlite: Disable changing fixed parameters Sean Anderson
@ 2021-07-23 22:31 ` Sean Anderson
  2021-07-23 22:31 ` [PATCH 2/5] dt-bindings: serial: uartlite: Add properties for synthesis-time parameters Sean Anderson
  2021-07-26 14:19 ` [PATCH 0/5] tty: serial: uartlite: Disable changing fixed parameters Michal Simek
  2 siblings, 0 replies; 6+ messages in thread
From: Sean Anderson @ 2021-07-23 22:31 UTC (permalink / raw)
  To: Peter Korsgaard, Peter Korsgaard, linux-serial
  Cc: Greg Kroah-Hartman, Alexander Sverdlin, Michal Simek,
	Sean Anderson, Rob Herring, devicetree

This converts the existing documentation for the uartlite binding to
json-schema.

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
---

 .../bindings/serial/xlnx,opb-uartlite.txt     | 23 --------
 .../bindings/serial/xlnx,opb-uartlite.yaml    | 53 +++++++++++++++++++
 2 files changed, 53 insertions(+), 23 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/serial/xlnx,opb-uartlite.txt
 create mode 100644 Documentation/devicetree/bindings/serial/xlnx,opb-uartlite.yaml

diff --git a/Documentation/devicetree/bindings/serial/xlnx,opb-uartlite.txt b/Documentation/devicetree/bindings/serial/xlnx,opb-uartlite.txt
deleted file mode 100644
index c37deb44dead..000000000000
--- a/Documentation/devicetree/bindings/serial/xlnx,opb-uartlite.txt
+++ /dev/null
@@ -1,23 +0,0 @@
-Xilinx Axi Uartlite controller Device Tree Bindings
----------------------------------------------------------
-
-Required properties:
-- compatible		: Can be either of
-				"xlnx,xps-uartlite-1.00.a"
-				"xlnx,opb-uartlite-1.00.b"
-- reg			: Physical base address and size of the Axi Uartlite
-			  registers map.
-- interrupts		: Should contain the UART controller interrupt.
-
-Optional properties:
-- port-number		: Set Uart port number
-- clock-names		: Should be "s_axi_aclk"
-- clocks		: Input clock specifier. Refer to common clock bindings.
-
-Example:
-serial@800c0000 {
-	compatible = "xlnx,xps-uartlite-1.00.a";
-	reg = <0x0 0x800c0000 0x10000>;
-	interrupts = <0x0 0x6e 0x1>;
-	port-number = <0>;
-};
diff --git a/Documentation/devicetree/bindings/serial/xlnx,opb-uartlite.yaml b/Documentation/devicetree/bindings/serial/xlnx,opb-uartlite.yaml
new file mode 100644
index 000000000000..4ef29784ae97
--- /dev/null
+++ b/Documentation/devicetree/bindings/serial/xlnx,opb-uartlite.yaml
@@ -0,0 +1,53 @@
+# SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/serial/xlnx,opb-uartlite.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Xilinx Axi Uartlite
+
+maintainers:
+  - Peter Korsgaard <jacmet@sunsite.dk>
+
+properties:
+  compatible:
+    contains:
+      enum:
+        - xlnx,xps-uartlite-1.00.a
+        - xlnx,opb-uartlite-1.00.b
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  port-number:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description: Set Uart port number
+
+  clocks:
+    maxItems: 1
+
+  clock-names:
+    const: s_axi_aclk
+
+required:
+  - compatible
+  - reg
+  - interrupts
+
+allOf:
+  - $ref: /schemas/serial.yaml#
+
+additionalProperties: true
+
+examples:
+  - |
+      serial@800c0000 {
+        compatible = "xlnx,xps-uartlite-1.00.a";
+        reg = <0x800c0000 0x10000>;
+        interrupts = <0x0 0x6e 0x1>;
+        port-number = <0>;
+      };
+...
-- 
2.25.1


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

* [PATCH 2/5] dt-bindings: serial: uartlite: Add properties for synthesis-time parameters
  2021-07-23 22:31 [PATCH 0/5] tty: serial: uartlite: Disable changing fixed parameters Sean Anderson
  2021-07-23 22:31 ` [PATCH 1/5] dt-bindings: serial: uartlite: Convert to json-schema Sean Anderson
@ 2021-07-23 22:31 ` Sean Anderson
  2021-07-26 12:30   ` Michal Simek
  2021-07-26 14:19 ` [PATCH 0/5] tty: serial: uartlite: Disable changing fixed parameters Michal Simek
  2 siblings, 1 reply; 6+ messages in thread
From: Sean Anderson @ 2021-07-23 22:31 UTC (permalink / raw)
  To: Peter Korsgaard, Peter Korsgaard, linux-serial
  Cc: Greg Kroah-Hartman, Alexander Sverdlin, Michal Simek,
	Sean Anderson, Rob Herring, devicetree

The uartlite device is a "soft" device. Many parameters, such as baud
rate, data bits, and the presence of a parity bit are configured before
synthesis and may not be changed (or discovered) at runtime. However, we
must know what these settings are in order to properly calculate the
uart timeout (and to inform the user about the actual baud of the uart).

These properties are present for out-of-tree bindings generated by
Xilinx's tools. However, they are also (mostly) present in in-tree
bindings. I chose current-speed over xlnx,baudrate primarily because it
seemed to be used by more existing bindings.

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
---

 .../bindings/serial/xlnx,opb-uartlite.yaml    | 39 +++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/Documentation/devicetree/bindings/serial/xlnx,opb-uartlite.yaml b/Documentation/devicetree/bindings/serial/xlnx,opb-uartlite.yaml
index 4ef29784ae97..28859e70e60f 100644
--- a/Documentation/devicetree/bindings/serial/xlnx,opb-uartlite.yaml
+++ b/Documentation/devicetree/bindings/serial/xlnx,opb-uartlite.yaml
@@ -32,13 +32,49 @@ properties:
   clock-names:
     const: s_axi_aclk
 
+  current-speed:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description:
+      The fixed baud rate that the device was configured for.
+
+  xlnx,data-bits:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    enum: [5, 6, 7, 8]
+    default: 8
+    description:
+      The fixed number of data bits that the device was configured for.
+
+  xlnx,use-parity:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    enum: [0, 1]
+    default: 0
+    description:
+      Whether parity checking was enabled when the device was configured.
+
+  xlnx,odd-parity:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    enum: [0, 1]
+    description:
+      Whether odd parity was configured.
+
 required:
   - compatible
   - reg
   - interrupts
+  - current-speed
+  - xlnx,data-bits
+  - xlnx,use-parity
 
 allOf:
   - $ref: /schemas/serial.yaml#
+  - if:
+      properties:
+        xlnx,use-parity:
+          contains:
+            const: 1
+    then:
+      required:
+        - xlnx,odd-parity
 
 additionalProperties: true
 
@@ -49,5 +85,8 @@ examples:
         reg = <0x800c0000 0x10000>;
         interrupts = <0x0 0x6e 0x1>;
         port-number = <0>;
+        current-speed = <115200>;
+        xlnx,data-bits = <8>;
+        xlnx,use-parity = <0>;
       };
 ...
-- 
2.25.1


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

* Re: [PATCH 2/5] dt-bindings: serial: uartlite: Add properties for synthesis-time parameters
  2021-07-23 22:31 ` [PATCH 2/5] dt-bindings: serial: uartlite: Add properties for synthesis-time parameters Sean Anderson
@ 2021-07-26 12:30   ` Michal Simek
  2021-07-26 15:16     ` Sean Anderson
  0 siblings, 1 reply; 6+ messages in thread
From: Michal Simek @ 2021-07-26 12:30 UTC (permalink / raw)
  To: Sean Anderson, Peter Korsgaard, Peter Korsgaard, linux-serial
  Cc: Greg Kroah-Hartman, Alexander Sverdlin, Michal Simek,
	Rob Herring, devicetree



On 7/24/21 12:31 AM, Sean Anderson wrote:
> The uartlite device is a "soft" device. Many parameters, such as baud
> rate, data bits, and the presence of a parity bit are configured before
> synthesis and may not be changed (or discovered) at runtime. However, we
> must know what these settings are in order to properly calculate the
> uart timeout (and to inform the user about the actual baud of the uart).
> 
> These properties are present for out-of-tree bindings generated by
> Xilinx's tools. However, they are also (mostly) present in in-tree
> bindings. I chose current-speed over xlnx,baudrate primarily because it
> seemed to be used by more existing bindings.
> 
> Signed-off-by: Sean Anderson <sean.anderson@seco.com>
> ---
> 
>  .../bindings/serial/xlnx,opb-uartlite.yaml    | 39 +++++++++++++++++++
>  1 file changed, 39 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/serial/xlnx,opb-uartlite.yaml b/Documentation/devicetree/bindings/serial/xlnx,opb-uartlite.yaml
> index 4ef29784ae97..28859e70e60f 100644
> --- a/Documentation/devicetree/bindings/serial/xlnx,opb-uartlite.yaml
> +++ b/Documentation/devicetree/bindings/serial/xlnx,opb-uartlite.yaml
> @@ -32,13 +32,49 @@ properties:
>    clock-names:
>      const: s_axi_aclk
>  
> +  current-speed:
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    description:
> +      The fixed baud rate that the device was configured for.
> +
> +  xlnx,data-bits:
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    enum: [5, 6, 7, 8]
> +    default: 8
> +    description:
> +      The fixed number of data bits that the device was configured for.
> +
> +  xlnx,use-parity:
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    enum: [0, 1]
> +    default: 0
> +    description:
> +      Whether parity checking was enabled when the device was configured.
> +
> +  xlnx,odd-parity:
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    enum: [0, 1]
> +    description:
> +      Whether odd parity was configured.
> +
>  required:
>    - compatible
>    - reg
>    - interrupts
> +  - current-speed
> +  - xlnx,data-bits
> +  - xlnx,use-parity

I think all of these should be optional properties because were required
in past. Likely a lot of xilinx dt binding files have them but as it is
visible sh also has it without it.

M

>  
>  allOf:
>    - $ref: /schemas/serial.yaml#
> +  - if:
> +      properties:
> +        xlnx,use-parity:
> +          contains:
> +            const: 1
> +    then:
> +      required:
> +        - xlnx,odd-parity
>  
>  additionalProperties: true
>  
> @@ -49,5 +85,8 @@ examples:
>          reg = <0x800c0000 0x10000>;
>          interrupts = <0x0 0x6e 0x1>;
>          port-number = <0>;
> +        current-speed = <115200>;
> +        xlnx,data-bits = <8>;
> +        xlnx,use-parity = <0>;
>        };
>  ...
> 

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

* Re: [PATCH 0/5] tty: serial: uartlite: Disable changing fixed parameters
  2021-07-23 22:31 [PATCH 0/5] tty: serial: uartlite: Disable changing fixed parameters Sean Anderson
  2021-07-23 22:31 ` [PATCH 1/5] dt-bindings: serial: uartlite: Convert to json-schema Sean Anderson
  2021-07-23 22:31 ` [PATCH 2/5] dt-bindings: serial: uartlite: Add properties for synthesis-time parameters Sean Anderson
@ 2021-07-26 14:19 ` Michal Simek
  2 siblings, 0 replies; 6+ messages in thread
From: Michal Simek @ 2021-07-26 14:19 UTC (permalink / raw)
  To: Sean Anderson, Peter Korsgaard, Peter Korsgaard, linux-serial,
	Shubhrajyoti Datta
  Cc: Greg Kroah-Hartman, Alexander Sverdlin, Michal Simek,
	Rich Felker, Rob Herring, Yoshinori Sato, devicetree

+Shubhrajyoti

On 7/24/21 12:31 AM, Sean Anderson wrote:
> The uartlite device is a "soft" device and certain parameters (such as
> data bits, parity, and baud) are configured at synthesis time, and
> cannot be discovered at runtime. Fortunately, bindings for this device
> typically include some of these parameters (especially baud rate).
> Instead of silently letting Linux's termios drift away from what the
> hardware is actually doing, make the termios reflect the hardware, and
> prevent them from being changed. With this series applied, the user
> recieves an error message the first time they try and change these
> termios:
> 
>     # stty parity
>     [    7.221696] uartlite 84000000.serial: only 'n' parity supported
>     [    7.222139] uartlite 84000000.serial: only 8 data bits supported
>     stty: standard input: cannot perform all requested operations
> 
> In addition, the configured baud/parity/bits/etc. are exposed through
> the standard termios ioctls, instead of using the default termios for
> unconfigured ttys.
> 
> 
> Sean Anderson (5):
>   dt-bindings: serial: uartlite: Convert to json-schema
>   dt-bindings: serial: uartlite: Add properties for synthesis-time
>     parameters
>   sh: j2: Update uartlite binding with data and parity properties
>   tty: serial: uartlite: Initialize termios with fixed synthesis
>     parameters
>   tty: serial: uartlite: Prevent changing fixed parameters
> 
>  .../bindings/serial/xlnx,opb-uartlite.txt     |  23 ----
>  .../bindings/serial/xlnx,opb-uartlite.yaml    |  92 ++++++++++++++
>  arch/sh/boot/dts/j2_mimas_v2.dts              |   2 +
>  drivers/tty/serial/uartlite.c                 | 118 ++++++++++++++++--
>  4 files changed, 203 insertions(+), 32 deletions(-)
>  delete mode 100644 Documentation/devicetree/bindings/serial/xlnx,opb-uartlite.txt
>  create mode 100644 Documentation/devicetree/bindings/serial/xlnx,opb-uartlite.yaml
> 

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

* Re: [PATCH 2/5] dt-bindings: serial: uartlite: Add properties for synthesis-time parameters
  2021-07-26 12:30   ` Michal Simek
@ 2021-07-26 15:16     ` Sean Anderson
  0 siblings, 0 replies; 6+ messages in thread
From: Sean Anderson @ 2021-07-26 15:16 UTC (permalink / raw)
  To: Michal Simek, Peter Korsgaard, Peter Korsgaard, linux-serial
  Cc: Greg Kroah-Hartman, Alexander Sverdlin, Rob Herring, devicetree



On 7/26/21 8:30 AM, Michal Simek wrote:
 >
 >
 > On 7/24/21 12:31 AM, Sean Anderson wrote:
 >> The uartlite device is a "soft" device. Many parameters, such as baud
 >> rate, data bits, and the presence of a parity bit are configured before
 >> synthesis and may not be changed (or discovered) at runtime. However, we
 >> must know what these settings are in order to properly calculate the
 >> uart timeout (and to inform the user about the actual baud of the uart).
 >>
 >> These properties are present for out-of-tree bindings generated by
 >> Xilinx's tools. However, they are also (mostly) present in in-tree
 >> bindings. I chose current-speed over xlnx,baudrate primarily because it
 >> seemed to be used by more existing bindings.
 >>
 >> Signed-off-by: Sean Anderson <sean.anderson@seco.com>
 >> ---
 >>
 >>  .../bindings/serial/xlnx,opb-uartlite.yaml    | 39 +++++++++++++++++++
 >>  1 file changed, 39 insertions(+)
 >>
 >> diff --git a/Documentation/devicetree/bindings/serial/xlnx,opb-uartlite.yaml b/Documentation/devicetree/bindings/serial/xlnx,opb-uartlite.yaml
 >> index 4ef29784ae97..28859e70e60f 100644
 >> --- a/Documentation/devicetree/bindings/serial/xlnx,opb-uartlite.yaml
 >> +++ b/Documentation/devicetree/bindings/serial/xlnx,opb-uartlite.yaml
 >> @@ -32,13 +32,49 @@ properties:
 >>    clock-names:
 >>      const: s_axi_aclk
 >>
 >> +  current-speed:
 >> +    $ref: /schemas/types.yaml#/definitions/uint32
 >> +    description:
 >> +      The fixed baud rate that the device was configured for.
 >> +
 >> +  xlnx,data-bits:
 >> +    $ref: /schemas/types.yaml#/definitions/uint32
 >> +    enum: [5, 6, 7, 8]
 >> +    default: 8
 >> +    description:
 >> +      The fixed number of data bits that the device was configured for.
 >> +
 >> +  xlnx,use-parity:
 >> +    $ref: /schemas/types.yaml#/definitions/uint32
 >> +    enum: [0, 1]
 >> +    default: 0
 >> +    description:
 >> +      Whether parity checking was enabled when the device was configured.
 >> +
 >> +  xlnx,odd-parity:
 >> +    $ref: /schemas/types.yaml#/definitions/uint32
 >> +    enum: [0, 1]
 >> +    description:
 >> +      Whether odd parity was configured.
 >> +
 >>  required:
 >>    - compatible
 >>    - reg
 >>    - interrupts
 >> +  - current-speed
 >> +  - xlnx,data-bits
 >> +  - xlnx,use-parity
 >
 > I think all of these should be optional properties because were required
 > in past. Likely a lot of xilinx dt binding files have them but as it is
 > visible sh also has it without it.

As I understand it, the "required" here covers both properties which the
driver cannot function without and properties which should be set for all
new bindings. That is, the 'required" here is perscriptive. The worst
that happens is that the bindings author gets a warning when doing
dtbs_check, which is exactly what we want to happen.

In the driver itself, only "current-speed" is required. However, I could
make that optional as well (although perhaps with a warning). I feel
much less comfortable guessing the default baud rate than guessing 8n1.

--Sean

 >
 > M
 >
 >>
 >>  allOf:
 >>    - $ref: /schemas/serial.yaml#
 >> +  - if:
 >> +      properties:
 >> +        xlnx,use-parity:
 >> +          contains:
 >> +            const: 1
 >> +    then:
 >> +      required:
 >> +        - xlnx,odd-parity
 >>
 >>  additionalProperties: true
 >>
 >> @@ -49,5 +85,8 @@ examples:
 >>          reg = <0x800c0000 0x10000>;
 >>          interrupts = <0x0 0x6e 0x1>;
 >>          port-number = <0>;
 >> +        current-speed = <115200>;
 >> +        xlnx,data-bits = <8>;
 >> +        xlnx,use-parity = <0>;
 >>        };
 >>  ...
 >>
 >

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

end of thread, other threads:[~2021-07-26 15:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-23 22:31 [PATCH 0/5] tty: serial: uartlite: Disable changing fixed parameters Sean Anderson
2021-07-23 22:31 ` [PATCH 1/5] dt-bindings: serial: uartlite: Convert to json-schema Sean Anderson
2021-07-23 22:31 ` [PATCH 2/5] dt-bindings: serial: uartlite: Add properties for synthesis-time parameters Sean Anderson
2021-07-26 12:30   ` Michal Simek
2021-07-26 15:16     ` Sean Anderson
2021-07-26 14:19 ` [PATCH 0/5] tty: serial: uartlite: Disable changing fixed parameters Michal Simek

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