Re: [PATCH 2/6] dt-bindings: i2c: convert i2c-mpc to json-schema
From: Chris Packham <Chris.Packham@alliedtelesis.co.nz>
Date: 2021-03-24 03:37:22
Also in:
linux-i2c, lkml
On 24/03/21 10:59 am, Chris Packham wrote:
On 24/03/21 10:15 am, Rob Herring wrote:quoted
On Tue, Mar 23, 2021 at 05:33:27PM +1300, Chris Packham wrote:quoted
Convert i2c-mpc to YAML. Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz> ---
<snip>
quoted
quoted
--- /dev/null +++ b/Documentation/devicetree/bindings/i2c/i2c-mpc.yaml@@ -0,0 +1,99 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/i2c/i2c-mpc.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: I2C-Bus adapter for MPC824x/83xx/85xx/86xx/512x/52xx SoCs + +maintainers: + - Chris Packham <chris.packham@alliedtelesis.co.nz> + +allOf: + - $ref: /schemas/i2c/i2c-controller.yaml# + +properties: + compatible: + anyOf: + - items: + - enum: + - mpc5200-i2c + - fsl,mpc5200b-i2c + - fsl,mpc5200-i2c + - fsl,mpc5121-i2c + - fsl,mpc8313-i2c + - fsl,mpc8543-i2c + - fsl,mpc8544-i2c + + - const: fsl-i2c + + - contains: + const: fsl-i2c + minItems: 1 + maxItems: 4Can't we drop this and list out any other compatibles?I'm struggling a little bit with how to get the schema right to allow one or more of a set of compatible values. Basically I want to allow 'compatible = "fsl-i2c";' or 'compatible = "fsl,mpc8544-i2c", "fsl-i2c";' but disallow 'compatible = "foobar", "fsl-i2c";'
This is what I've ended up with properties: compatible: oneOf: - items: - enum: - mpc5200-i2c - fsl,mpc5200-i2c - fsl,mpc5121-i2c - fsl,mpc8313-i2c - fsl,mpc8543-i2c - fsl,mpc8544-i2c - fsl-i2c - const: fsl-i2c - items: - const: fsl,mpc5200b-i2c - const: fsl,mpc5200-i2c - const: fsl-i2c It passes `make dt_binding_check` and rejects things when I add other non-documented values to the compatible property. I did struggle with it so I'm not confident it's the best approach but it seems to work.