On Fri, Dec 15, 2023 at 9:24 AM Lukas Wunner <lukas@xxxxxxxxx> wrote: > > On Wed, Dec 13, 2023 at 11:01:21AM -0600, Rob Herring wrote: > > On Wed, Dec 13, 2023 at 10:23AM Lukas Wunner <lukas@xxxxxxxxx> wrote: > > > Ideally the validator would match a regex against the $nodename of the > > > parent and see if it contains "spi" or "i2c". But I think matching > > > against the parent's $nodename isn't possible, is it? > > > > No. I've thought of adding something like that, but haven't. > > Please consider this a feature request. :) > > It would be good if it were possible to define constraints not just > for the $nodename of the parent, but any of its properties. You could write such a schema, but it would have to be applied to the parent node rather than the child node. It would have to be applied to every 'i2c' node and in theory you could have one for every i2c device. We could define something like "$defs/parent-schema" within the child device schema and make the tools apply it to the parent node. > E.g. with i2c, the clock-frequency is set at the host controller's > devicetree node, not at each attached i2c peripheral's node. > For ACPI, i2c_acpi_find_bus_speed() walks the bus to find the > highest clock speed supported by all attached i2c peripherals, > but for OF, the onus is on the devicetree author to manually > determine the clock. > > Thus, for a TPM such as infineon,slb9635tt which only supports 100 kHz, > I want to validate that the parent node's clock-frequency is less than > or equal to that. > > In Documentation/devicetree/bindings/security/tpm/st33zp24-i2c.txt > there's an example showing a clock-frequency property at the > peripheral's node and I mistakenly carried that over to the yaml > schema. A look at the code reveals that's entirely bogus so I'll > drop the clock-frequency property in v3. I will retain textual > hints that infineon,slb9635tt is limited to 100 kHz and > infineon,slb9645tt to 400 kHz, but as it stands I can't define > rules that would allow the validator to check that automatically. We could adapt the bindings to accept that. Makes sense as that's mostly a property of each device. SPI freq is per child, but I guess I2C has to be the minimum of all the child nodes. Rob