linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
To: Sergiu Moga <sergiu.moga@microchip.com>,
	lee@kernel.org, robh+dt@kernel.org,
	krzysztof.kozlowski+dt@linaro.org, nicolas.ferre@microchip.com,
	alexandre.belloni@bootlin.com, claudiu.beznea@microchip.com,
	richard.genoud@gmail.com, radu_nicolae.pirea@upb.ro,
	gregkh@linuxfoundation.org, broonie@kernel.org,
	mturquette@baylibre.com, sboyd@kernel.org, jirislaby@kernel.org,
	admin@hifiphile.com, kavyasree.kotagiri@microchip.com,
	tudor.ambarus@microchip.com
Cc: devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org,
	linux-serial@vger.kernel.org, linux-clk@vger.kernel.org
Subject: Re: [PATCH v2 05/13] dt-bindings: serial: atmel,at91-usart: convert to json-schema
Date: Thu, 8 Sep 2022 14:29:21 +0200	[thread overview]
Message-ID: <e799ca9e-acb0-1bea-1c1a-b2ab79089381@linaro.org> (raw)
In-Reply-To: <20220906135511.144725-6-sergiu.moga@microchip.com>

On 06/09/2022 15:55, Sergiu Moga wrote:
> Convert at91 USART DT Binding for Atmel/Microchip SoCs to
> json-schema format. Furthermore, move this binding to the
> serial directory, since binding directories match hardware,
> unlike the driver subsystems which match Linux convention.
> 
> Signed-off-by: Sergiu Moga <sergiu.moga@microchip.com>
> ---
> 
> 
> 
> v1 -> v2:
> - only do what the commit says, split the addition of other compatibles and
> properties in other patches
> - remove unnecessary "|"'s
> - mention header in `atmel,usart-mode`'s description
> - place `if:` under `allOf:`
> - respect order of spi0's DT properties: compatible, then reg then the reset of properties
> 
> 
> 
> 
> 
>  .../devicetree/bindings/mfd/atmel-usart.txt   |  98 ----------
>  .../bindings/serial/atmel,at91-usart.yaml     | 183 ++++++++++++++++++
>  2 files changed, 183 insertions(+), 98 deletions(-)
>  delete mode 100644 Documentation/devicetree/bindings/mfd/atmel-usart.txt
>  create mode 100644 Documentation/devicetree/bindings/serial/atmel,at91-usart.yaml
> 
> diff --git a/Documentation/devicetree/bindings/mfd/atmel-usart.txt b/Documentation/devicetree/bindings/mfd/atmel-usart.txt
> deleted file mode 100644
> index a09133066aff..000000000000
> --- a/Documentation/devicetree/bindings/mfd/atmel-usart.txt
> +++ /dev/null
> @@ -1,98 +0,0 @@
> -* Atmel Universal Synchronous Asynchronous Receiver/Transmitter (USART)
> -
> -Required properties for USART:
> -- compatible: Should be one of the following:
> -	- "atmel,at91rm9200-usart"
> -	- "atmel,at91sam9260-usart"
> -	- "microchip,sam9x60-usart"
> -	- "atmel,at91rm9200-dbgu", "atmel,at91rm9200-usart"
> -	- "atmel,at91sam9260-dbgu", "atmel,at91sam9260-usart"
> -	- "microchip,sam9x60-dbgu", "microchip,sam9x60-usart"
> -- reg: Should contain registers location and length
> -- interrupts: Should contain interrupt
> -- clock-names: tuple listing input clock names.
> -	Required elements: "usart"
> -- clocks: phandles to input clocks.
> -
> -Required properties for USART in SPI mode:
> -- #size-cells      : Must be <0>
> -- #address-cells   : Must be <1>
> -- cs-gpios: chipselects (internal cs not supported)
> -- atmel,usart-mode : Must be <AT91_USART_MODE_SPI> (found in dt-bindings/mfd/at91-usart.h)
> -
> -Optional properties in serial and SPI mode:
> -- dma bindings for dma transfer:
> -	- dmas: DMA specifier, consisting of a phandle to DMA controller node,
> -		memory peripheral interface and USART DMA channel ID, FIFO configuration.
> -		The order of DMA channels is fixed. The first DMA channel must be TX
> -		associated channel and the second one must be RX associated channel.
> -		Refer to dma.txt and atmel-dma.txt for details.
> -	- dma-names: "tx" for TX channel.
> -		     "rx" for RX channel.
> -		     The order of dma-names is also fixed. The first name must be "tx"
> -		     and the second one must be "rx" as in the examples below.
> -
> -Optional properties in serial mode:
> -- atmel,use-dma-rx: use of PDC or DMA for receiving data
> -- atmel,use-dma-tx: use of PDC or DMA for transmitting data
> -- {rts,cts,dtr,dsr,rng,dcd}-gpios: specify a GPIO for RTS/CTS/DTR/DSR/RI/DCD line respectively.
> -  It will use specified PIO instead of the peripheral function pin for the USART feature.
> -  If unsure, don't specify this property.
> -- atmel,fifo-size: maximum number of data the RX and TX FIFOs can store for FIFO
> -  capable USARTs.
> -- rs485-rts-delay, rs485-rx-during-tx, linux,rs485-enabled-at-boot-time: see rs485.txt
> -
> -<chip> compatible description:
> -- at91rm9200:  legacy USART support
> -- at91sam9260: generic USART implementation for SAM9 SoCs
> -
> -Example:
> -- use PDC:
> -	usart0: serial@fff8c000 {
> -		compatible = "atmel,at91sam9260-usart";
> -		reg = <0xfff8c000 0x4000>;
> -		interrupts = <7>;
> -		clocks = <&usart0_clk>;
> -		clock-names = "usart";
> -		atmel,use-dma-rx;
> -		atmel,use-dma-tx;
> -		rts-gpios = <&pioD 15 GPIO_ACTIVE_LOW>;
> -		cts-gpios = <&pioD 16 GPIO_ACTIVE_LOW>;
> -		dtr-gpios = <&pioD 17 GPIO_ACTIVE_LOW>;
> -		dsr-gpios = <&pioD 18 GPIO_ACTIVE_LOW>;
> -		dcd-gpios = <&pioD 20 GPIO_ACTIVE_LOW>;
> -		rng-gpios = <&pioD 19 GPIO_ACTIVE_LOW>;
> -	};
> -
> -- use DMA:
> -	usart0: serial@f001c000 {
> -		compatible = "atmel,at91sam9260-usart";
> -		reg = <0xf001c000 0x100>;
> -		interrupts = <12 4 5>;
> -		clocks = <&usart0_clk>;
> -		clock-names = "usart";
> -		atmel,use-dma-rx;
> -		atmel,use-dma-tx;
> -		dmas = <&dma0 2 0x3>,
> -		       <&dma0 2 0x204>;
> -		dma-names = "tx", "rx";
> -		atmel,fifo-size = <32>;
> -	};
> -
> -- SPI mode:
> -	#include <dt-bindings/mfd/at91-usart.h>
> -
> -	spi0: spi@f001c000 {
> -		#address-cells = <1>;
> -		#size-cells = <0>;
> -		compatible = "atmel,at91rm9200-usart", "atmel,at91sam9260-usart";
> -		atmel,usart-mode = <AT91_USART_MODE_SPI>;
> -		reg = <0xf001c000 0x100>;
> -		interrupts = <12 IRQ_TYPE_LEVEL_HIGH 5>;
> -		clocks = <&usart0_clk>;
> -		clock-names = "usart";
> -		dmas = <&dma0 2 AT91_DMA_CFG_PER_ID(3)>,
> -		       <&dma0 2 (AT91_DMA_CFG_PER_ID(4) | AT91_DMA_CFG_FIFOCFG_ASAP)>;
> -		dma-names = "tx", "rx";
> -		cs-gpios = <&pioB 3 0>;
> -	};
> diff --git a/Documentation/devicetree/bindings/serial/atmel,at91-usart.yaml b/Documentation/devicetree/bindings/serial/atmel,at91-usart.yaml
> new file mode 100644
> index 000000000000..b25535b7a4d2
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/serial/atmel,at91-usart.yaml
> @@ -0,0 +1,183 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +# Copyright (C) 2022 Microchip Technology, Inc. and its subsidiaries
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/serial/atmel,at91-usart.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Atmel Universal Synchronous Asynchronous Receiver/Transmitter (USART)
> +
> +maintainers:
> +  - Richard Genoud <richard.genoud@gmail.com>
> +
> +properties:
> +  compatible:
> +    oneOf:
> +      - enum:
> +          - atmel,at91rm9200-usart
> +          - atmel,at91sam9260-usart
> +          - microchip,sam9x60-usart
> +      - items:
> +          - const: atmel,at91rm9200-dbgu
> +          - const: atmel,at91rm9200-usart
> +      - items:
> +          - const: atmel,at91sam9260-dbgu
> +          - const: atmel,at91sam9260-usart
> +      - items:
> +          - const: microchip,sam9x60-dbgu
> +          - const: microchip,sam9x60-usart
> +
> +  reg:
> +    maxItems: 1
> +
> +  interrupts:
> +    maxItems: 1
> +
> +  clock-names:
> +    const: usart
> +
> +  clocks:
> +    maxItems: 1
> +
> +  dmas:
> +    items:
> +      - description: TX DMA Channel
> +      - description: RX DMA Channel
> +
> +  dma-names:
> +    items:
> +      - const: tx
> +      - const: rx
> +
> +  atmel,usart-mode:
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    description:
> +      Must be either <AT91_USART_MODE_SPI> for SPI or
> +      <AT91_USART_MODE_SERIAL> for USART (found in dt-bindings/mfd/at91-usart.h).
> +    enum: [ 0, 1 ]
> +
> +required:
> +  - compatible
> +  - reg
> +  - interrupts
> +  - clock-names
> +  - clocks
> +
> +allOf:
> +  - if:
> +      properties:
> +        $nodename:
> +          pattern: "^serial@[0-9a-f]+$"

You should rather check value of atmel,usart-mode, because now you won't
properly match device nodes called "foobar". Since usart-mode has only
two possible values, this will nicely simplify you if-else.


> +    then:
> +      allOf:
> +        - $ref: /schemas/serial/serial.yaml#
> +        - $ref: /schemas/serial/rs485.yaml#
> +
> +      properties:
> +        atmel,use-dma-rx:
> +          type: boolean
> +          description: use of PDC or DMA for receiving data
> +
> +        atmel,use-dma-tx:
> +          type: boolean
> +          description: use of PDC or DMA for transmitting data
> +
> +        atmel,fifo-size:
> +          $ref: /schemas/types.yaml#/definitions/uint32
> +          description:
> +            Maximum number of data the RX and TX FIFOs can store for FIFO
> +            capable USARTS.
> +          enum: [ 16, 32 ]

I did not mention it last time, but I think it should follow generic
practice, so define all properties top-level and disallow them for other
type. This allows you to simply use additionalProperties:false at the end.

> +
> +    else:
> +      if:
> +        properties:
> +          $nodename:
> +            pattern: "^spi@[0-9a-f]+$"
> +      then:
> +        allOf:
> +          - $ref: /schemas/spi/spi-controller.yaml#
> +
> +        properties:
> +          atmel,usart-mode:
> +            const: 1
> +
> +          "#size-cells":
> +            const: 0
> +
> +          "#address-cells":
> +            const: 1

The same - top level and disallow them for uart.

> +
> +        required:
> +          - atmel,usart-mode
> +          - "#size-cells"
> +          - "#address-cells"

End else in this branch is what?

> +
> +unevaluatedProperties: false
> +

Best regards,
Krzysztof

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2022-09-08 12:30 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-06 13:54 [PATCH v2 00/13] Make atmel serial driver aware of GCLK Sergiu Moga
2022-09-06 13:55 ` [PATCH v2 01/13] spi: dt-bindings: atmel,at91rm9200-spi: Add DMA related properties Sergiu Moga
2022-09-06 15:12   ` Mark Brown
2022-09-06 21:41   ` Rob Herring
2022-09-07  7:54     ` Sergiu.Moga
2022-09-08 12:23   ` Krzysztof Kozlowski
2022-09-06 13:55 ` [PATCH v2 02/13] ARM: dts: at91: sama7g5: Swap rx and tx for spi11 Sergiu Moga
2022-09-06 13:55 ` [PATCH v2 03/13] dt-bindings: mfd: atmel,sama5d2-flexcom: Add SPI child node ref binding Sergiu Moga
2022-09-08 12:23   ` Krzysztof Kozlowski
2022-09-06 13:55 ` [PATCH v2 04/13] ARM: dts: at91: sam9x60ek: Add DBGU compatibles to uart1 Sergiu Moga
2022-09-06 13:55 ` [PATCH v2 05/13] dt-bindings: serial: atmel,at91-usart: convert to json-schema Sergiu Moga
2022-09-08 12:29   ` Krzysztof Kozlowski [this message]
2022-09-08 15:06     ` Sergiu.Moga
2022-09-08 15:10       ` Krzysztof Kozlowski
2022-09-08 15:27         ` Sergiu.Moga
2022-09-08 16:05           ` Krzysztof Kozlowski
2022-09-06 13:55 ` [PATCH v2 06/13] dt-bindings: serial: atmel,at91-usart: Add SAM9260 compatibles to SAM9x60 Sergiu Moga
2022-09-08 12:30   ` Krzysztof Kozlowski
2022-09-08 15:15     ` Sergiu.Moga
2022-09-09  1:36       ` Rob Herring
2022-09-12  7:45         ` Sergiu.Moga
2022-09-12 10:44           ` Krzysztof Kozlowski
2022-09-12 13:09             ` Sergiu.Moga
2022-09-13  8:58               ` Krzysztof Kozlowski
2022-09-13  9:19                 ` Sergiu.Moga
2022-09-13  9:30                   ` Krzysztof Kozlowski
2022-09-13  9:35                     ` Sergiu.Moga
2022-09-06 13:55 ` [PATCH v2 07/13] dt-bindings: mfd: atmel,sama5d2-flexcom: Add USART child node ref binding Sergiu Moga
2022-09-08 12:33   ` Krzysztof Kozlowski
2022-09-06 13:55 ` [PATCH v2 08/13] tty: serial: atmel: Define GCLK as USART baudrate source clock Sergiu Moga
2022-09-07  9:21   ` Ilpo Järvinen
2022-09-07  9:37     ` Sergiu.Moga
2022-09-06 13:55 ` [PATCH v2 09/13] tty: serial: atmel: Define BRSRCCK bitmask of UART IP's Mode Register Sergiu Moga
2022-09-07  9:24   ` Ilpo Järvinen
2022-09-06 13:55 ` [PATCH v2 10/13] tty: serial: atmel: Only divide Clock Divisor if the IP is USART Sergiu Moga
2022-09-07  9:23   ` Ilpo Järvinen
2022-09-07  9:34     ` Sergiu.Moga
2022-09-06 13:55 ` [PATCH v2 11/13] clk: at91: sama5d2: Add Generic Clocks for UART/USART Sergiu Moga
2022-09-06 13:55 ` [PATCH v2 12/13] tty: serial: atmel: Make the driver aware of the existence of GCLK Sergiu Moga
2022-09-07  9:36   ` Ilpo Järvinen
2022-09-07 11:11     ` Sergiu.Moga
2022-09-07 11:29       ` Ilpo Järvinen
2022-09-12  8:06   ` Claudiu.Beznea
2022-09-06 13:55 ` [PATCH v2 13/13] dt-bindings: serial: atmel,at91-usart: Add gclk as a possible USART clock Sergiu Moga
2022-09-08 12:35   ` Krzysztof Kozlowski
2022-09-08 15:33     ` Sergiu.Moga

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e799ca9e-acb0-1bea-1c1a-b2ab79089381@linaro.org \
    --to=krzysztof.kozlowski@linaro.org \
    --cc=admin@hifiphile.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=broonie@kernel.org \
    --cc=claudiu.beznea@microchip.com \
    --cc=devicetree@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jirislaby@kernel.org \
    --cc=kavyasree.kotagiri@microchip.com \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=lee@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=nicolas.ferre@microchip.com \
    --cc=radu_nicolae.pirea@upb.ro \
    --cc=richard.genoud@gmail.com \
    --cc=robh+dt@kernel.org \
    --cc=sboyd@kernel.org \
    --cc=sergiu.moga@microchip.com \
    --cc=tudor.ambarus@microchip.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).