Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dts: bindings: base.yaml: Add hw instance id
Durant the process to convert Atmel drivers to use DT_INST_ defines was detected the necessity of a hardware instance identificator. Some drivers need configure port pins, clocks, DMA etc. This will track the hw instance on the DT_INST_x_ independent of the 'x' value. This will keep simple the conversion this add a new non mandatory property called <id>. The driver that need these feature need add 'required=true' on the dts/binding/driver and complement any device tree with proper value. Examples: foo0: foo@1000 { compatible = "man,foo-drv"; id = <0>; status="disabled"; }; foo1: foo@1001 { compatible = "man,foo-drv"; id = <1>; }; barn: bar@2001 { compatible = "man,bar-drv"; id = <10>; }; barm: bar@3001 { compatible = "man,bar-drv"; id = <20>; }; Will generate: DT_INST_0_MAN_FOO_DRV_ID=1 DT_INST_0_MAN_BAR_DRV_ID=10 DT_INST_1_MAN_BAR_DRV_ID=20 It is intent to be used as below to propagate the hardware id on all driver defines. DRV_FOO_DEVICE_INIT(0, DT_INST_0_MAN_FOO_DRV_ID); A good driver example that need this definition: static const struct drv_foo_dev_cfg drv##n##_sam_config = { \ .regs = (Drv *)DT_INST_##n##_MAN_DRV_FOO_BASE_ADDRESS, \ .pin_rx = PIN_FOO##m##_RXD, \ .pin_tx = PIN_FOO##m##_TXD, \ } If 'm' isn't defined the driver will invariably configure the wrong pins and communication won't happen. This can't be derived by node name for many reasons. For instance. the above DT snip defined 'barn' and 'barm' that have a name without number and an unusual value. It represents two instances of bar that shouldn't assume values other than defined on the id property. see zephyrproject-rtos#23107 Signed-off-by: Gerson Fernando Budke <[email protected]>
- Loading branch information