diff mbox series

ASoC: dt-bindings: realtek,rt5677: Convert to dtschema

Message ID 20240625092214.88005-1-animeshagarwal28@gmail.com (mailing list archive)
State Superseded
Headers show
Series ASoC: dt-bindings: realtek,rt5677: Convert to dtschema | expand

Commit Message

Animesh Agarwal June 25, 2024, 9:22 a.m. UTC
Convert the RT5677 audio CODEC bindings to DT schema.

Signed-off-by: Animesh Agarwal <animeshagarwal28@gmail.com>
Cc: Daniel Baluta <daniel.baluta@nxp.com>
---
 .../bindings/sound/realtek,rt5677.yaml        | 117 ++++++++++++++++++
 .../devicetree/bindings/sound/rt5677.txt      |  78 ------------
 2 files changed, 117 insertions(+), 78 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/sound/realtek,rt5677.yaml
 delete mode 100644 Documentation/devicetree/bindings/sound/rt5677.txt

Comments

Krzysztof Kozlowski June 26, 2024, 9:05 a.m. UTC | #1
On 25/06/2024 11:22, Animesh Agarwal wrote:
> Convert the RT5677 audio CODEC bindings to DT schema.
> 
> Signed-off-by: Animesh Agarwal <animeshagarwal28@gmail.com>
> Cc: Daniel Baluta <daniel.baluta@nxp.com>

Thank you for your patch. There is something to discuss/improve.

> +  realtek,gpio-config:
> +    description: |
> +      Array of six 8bit elements that configures GPIO.
> +      0 - floating (reset value)
> +      1 - pull down
> +      2 - pull up
> +    $ref: /schemas/types.yaml#/definitions/uint32-array
> +    minItems: 6
> +    maxItems: 6
> +    items:
> +      maximum: 2
> +
> +patternProperties:
> +  "^realtek,in[1-2]-differential$":

In the future, please use consistent quotes, so either ' or ".

> +    type: boolean
> +    description: Indicate MIC1/2 input are differential, rather than
> +      single-ended.
> +
> +  "^realtek,lout[1-3]-differential$":
> +    type: boolean
> +    description: Indicate LOUT1/2/3 outputs are differential, rather than
> +      single-ended.
> +
> +  "^realtek,jd[1-3]-gpio$":
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    enum:
> +      - 0 # OFF
> +      - 1 # GPIO1 for jd1 and GPIO4 for jd2.
> +      - 2 # GPIO2 for jd1 and GPIO5 for jd2.
> +      - 3 # GPIO3 for jd1 and GPIO6 for jd2.


I don't quite get it. What about jd3? I think it would be clearer if
these were listed as properties, not pattern properties.

> +    description: Configures GPIO Mic Jack detection 1, 2 and 3.
> +
> +required:
> +  - compatible
> +  - reg
> +  - interrupts
> +  - gpio-controller
> +  - '#gpio-cells'
> +
> +unevaluatedProperties: false

Best regards,
Krzysztof
Animesh Agarwal June 27, 2024, 5:55 a.m. UTC | #2
On Wed, Jun 26, 2024 at 2:35 PM Krzysztof Kozlowski <krzk@kernel.org> wrote:
>
> On 25/06/2024 11:22, Animesh Agarwal wrote:
> > Convert the RT5677 audio CODEC bindings to DT schema.
> >
> > Signed-off-by: Animesh Agarwal <animeshagarwal28@gmail.com>
> > Cc: Daniel Baluta <daniel.baluta@nxp.com>
>
> Thank you for your patch. There is something to discuss/improve.
>
> > +  realtek,gpio-config:
> > +    description: |
> > +      Array of six 8bit elements that configures GPIO.
> > +      0 - floating (reset value)
> > +      1 - pull down
> > +      2 - pull up
> > +    $ref: /schemas/types.yaml#/definitions/uint32-array
> > +    minItems: 6
> > +    maxItems: 6
> > +    items:
> > +      maximum: 2
> > +
> > +patternProperties:
> > +  "^realtek,in[1-2]-differential$":
>
> In the future, please use consistent quotes, so either ' or ".
>
Sure.
> > +    type: boolean
> > +    description: Indicate MIC1/2 input are differential, rather than
> > +      single-ended.
> > +
> > +  "^realtek,lout[1-3]-differential$":
> > +    type: boolean
> > +    description: Indicate LOUT1/2/3 outputs are differential, rather than
> > +      single-ended.
> > +
> > +  "^realtek,jd[1-3]-gpio$":
> > +    $ref: /schemas/types.yaml#/definitions/uint32
> > +    enum:
> > +      - 0 # OFF
> > +      - 1 # GPIO1 for jd1 and GPIO4 for jd2.
> > +      - 2 # GPIO2 for jd1 and GPIO5 for jd2.
> > +      - 3 # GPIO3 for jd1 and GPIO6 for jd2.
>
>
> I don't quite get it. What about jd3? I think it would be clearer if
> these were listed as properties, not pattern properties.
>
Ok, I'll list them as separate properties.
> > +    description: Configures GPIO Mic Jack detection 1, 2 and 3.
> > +
> > +required:
> > +  - compatible
> > +  - reg
> > +  - interrupts
> > +  - gpio-controller
> > +  - '#gpio-cells'
> > +
> > +unevaluatedProperties: false
>
> Best regards,
> Krzysztof
>
diff mbox series

Patch

diff --git a/Documentation/devicetree/bindings/sound/realtek,rt5677.yaml b/Documentation/devicetree/bindings/sound/realtek,rt5677.yaml
new file mode 100644
index 000000000000..598495dbe7fc
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/realtek,rt5677.yaml
@@ -0,0 +1,117 @@ 
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/realtek,rt5677.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: RT5677 audio CODEC
+
+maintainers:
+  - Animesh Agarwal <animeshagarwal28@gmail.com>
+
+description: |
+  This device supports I2C only.
+
+  Pins on the device (for linking into audio routes):
+    * IN1P
+    * IN1N
+    * IN2P
+    * IN2N
+    * MICBIAS1
+    * DMIC1
+    * DMIC2
+    * DMIC3
+    * DMIC4
+    * LOUT1
+    * LOUT2
+    * LOUT3
+
+allOf:
+  - $ref: dai-common.yaml#
+
+properties:
+  compatible:
+    const: realtek,rt5677
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  gpio-controller: true
+
+  '#gpio-cells':
+    const: 2
+
+  realtek,pow-ldo2-gpio:
+    maxItems: 1
+    description: CODEC's POW_LDO2 pin.
+
+  realtek,reset-gpio:
+    maxItems: 1
+    description: CODEC's RESET pin. Active low.
+
+  realtek,gpio-config:
+    description: |
+      Array of six 8bit elements that configures GPIO.
+      0 - floating (reset value)
+      1 - pull down
+      2 - pull up
+    $ref: /schemas/types.yaml#/definitions/uint32-array
+    minItems: 6
+    maxItems: 6
+    items:
+      maximum: 2
+
+patternProperties:
+  "^realtek,in[1-2]-differential$":
+    type: boolean
+    description: Indicate MIC1/2 input are differential, rather than
+      single-ended.
+
+  "^realtek,lout[1-3]-differential$":
+    type: boolean
+    description: Indicate LOUT1/2/3 outputs are differential, rather than
+      single-ended.
+
+  "^realtek,jd[1-3]-gpio$":
+    $ref: /schemas/types.yaml#/definitions/uint32
+    enum:
+      - 0 # OFF
+      - 1 # GPIO1 for jd1 and GPIO4 for jd2.
+      - 2 # GPIO2 for jd1 and GPIO5 for jd2.
+      - 3 # GPIO3 for jd1 and GPIO6 for jd2.
+    description: Configures GPIO Mic Jack detection 1, 2 and 3.
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - gpio-controller
+  - '#gpio-cells'
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+    #include <dt-bindings/interrupt-controller/irq.h>
+
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        codec@2c {
+            compatible = "realtek,rt5677";
+            reg = <0x2c>;
+            interrupt-parent = <&gpio>;
+            interrupts = <3 IRQ_TYPE_LEVEL_HIGH>;
+            gpio-controller;
+            #gpio-cells = <2>;
+            realtek,pow-ldo2-gpio = <&gpio 3 GPIO_ACTIVE_HIGH>;
+            realtek,reset-gpio = <&gpio 3 GPIO_ACTIVE_LOW>;
+            realtek,in1-differential;
+            realtek,gpio-config = <0 0 0 0 0 2>;
+        };
+    };
diff --git a/Documentation/devicetree/bindings/sound/rt5677.txt b/Documentation/devicetree/bindings/sound/rt5677.txt
deleted file mode 100644
index da2430099181..000000000000
--- a/Documentation/devicetree/bindings/sound/rt5677.txt
+++ /dev/null
@@ -1,78 +0,0 @@ 
-RT5677 audio CODEC
-
-This device supports I2C only.
-
-Required properties:
-
-- compatible : "realtek,rt5677".
-
-- reg : The I2C address of the device.
-
-- interrupts : The CODEC's interrupt output.
-
-- gpio-controller : Indicates this device is a GPIO controller.
-
-- #gpio-cells : Should be two. The first cell is the pin number and the
-  second cell is used to specify optional parameters (currently unused).
-
-Optional properties:
-
-- realtek,pow-ldo2-gpio : The GPIO that controls the CODEC's POW_LDO2 pin.
-- realtek,reset-gpio : The GPIO that controls the CODEC's RESET pin. Active low.
-
-- realtek,in1-differential
-- realtek,in2-differential
-- realtek,lout1-differential
-- realtek,lout2-differential
-- realtek,lout3-differential
-  Boolean. Indicate MIC1/2 input and LOUT1/2/3 outputs are differential,
-  rather than single-ended.
-
-- realtek,gpio-config
-  Array of six 8bit elements that configures GPIO.
-    0 - floating (reset value)
-    1 - pull down
-    2 - pull up
-
-- realtek,jd1-gpio
-  Configures GPIO Mic Jack detection 1.
-  Select 0 ~ 3 as OFF, GPIO1, GPIO2 and GPIO3 respectively.
-
-- realtek,jd2-gpio
-- realtek,jd3-gpio
-  Configures GPIO Mic Jack detection 2 and 3.
-  Select 0 ~ 3 as OFF, GPIO4, GPIO5 and GPIO6 respectively.
-
-Pins on the device (for linking into audio routes):
-
-  * IN1P
-  * IN1N
-  * IN2P
-  * IN2N
-  * MICBIAS1
-  * DMIC1
-  * DMIC2
-  * DMIC3
-  * DMIC4
-  * LOUT1
-  * LOUT2
-  * LOUT3
-
-Example:
-
-rt5677 {
-	compatible = "realtek,rt5677";
-	reg = <0x2c>;
-	interrupt-parent = <&gpio>;
-	interrupts = <TEGRA_GPIO(W, 3) IRQ_TYPE_LEVEL_HIGH>;
-
-	gpio-controller;
-	#gpio-cells = <2>;
-
-	realtek,pow-ldo2-gpio =
-		<&gpio TEGRA_GPIO(V, 3) GPIO_ACTIVE_HIGH>;
-	realtek,reset-gpio = <&gpio TEGRA_GPIO(BB, 3) GPIO_ACTIVE_LOW>;
-	realtek,in1-differential = "true";
-	realtek,gpio-config = /bits/ 8  <0 0 0 0 0 2>;   /* pull up GPIO6 */
-	realtek,jd2-gpio = <3>;  /* Enables Jack detection for GPIO6 */
-};