User Tools

Site Tools


zephyr:device_drivers

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
zephyr:device_drivers [2025/07/08 10:42] – [DT Macros] utedasszephyr:device_drivers [2025/07/08 19:08] (current) utedass
Line 68: Line 68:
  
 So the instance nubmer is an index of all nodes with a particular compatible. Node identifier, I assume, is an index over ALL device tree nodes. So like a local vs global index. So the instance nubmer is an index of all nodes with a particular compatible. Node identifier, I assume, is an index over ALL device tree nodes. So like a local vs global index.
 +
 +By checking the build folder and the generated include files, one can observe that
 +
 +<code c>
 +// An instance number is a number 0 through n
 +// But the node identifier will be something along the lines of DT_N_S_soc_S_i2c_40005400_S_si5351_60
 +// The macro DT_INST(0, skyworks_si5351) would retrieve this define from the generated source
 +#define DT_N_INST_0_skyworks_si5351 DT_N_S_soc_S_i2c_40005400_S_si5351_60
 +
 +// The DT_DRV_COMPAT that you define to something along the lines skyworks_si5351 will be just that, a token. Not anything magical.
 +// But it will be used by the zephyr provided helper macros to construct the names for the defines generated by the build system to the devicetree_generated.h so that you can retrieve them
 +
 +// For example, the macro used to retrieve a property
 +DT_INST_PROP(inst, plla_p1)
 +// would expand to DT_N_S_soc_S_i2c_40005400_S_si5351_60_P_plla_p1
 +
 +// According to the generated header:
 +/*
 + * Devicetree node: /soc/i2c@40005400/si5351@60
 + *
 + * Node identifier: DT_N_S_soc_S_i2c_40005400_S_si5351_60
 + *
 + * Binding (compatible = skyworks,si5351):
 +   /workspace/modules/si5351/dts/bindings/clock/skyworks,si5351.yaml
 + *
 + * (Descriptions have moved to the Devicetree Bindings Index
 + * in the documentation.)
 + */
 +
 +// Some of the generated properties looks like this
 +/* Generic property macros: */
 +#define DT_N_S_soc_S_i2c_40005400_S_si5351_60_P_clkin_div 1
 +#define DT_N_S_soc_S_i2c_40005400_S_si5351_60_P_clkin_div_IDX_0_ENUM_IDX 0
 +#define DT_N_S_soc_S_i2c_40005400_S_si5351_60_P_clkin_div_IDX_0_EXISTS 1
 +#define DT_N_S_soc_S_i2c_40005400_S_si5351_60_P_clkin_div_IDX_0_ENUM_VAL_1_EXISTS 1
 +#define DT_N_S_soc_S_i2c_40005400_S_si5351_60_P_clkin_div_EXISTS 1
 +#define DT_N_S_soc_S_i2c_40005400_S_si5351_60_P_plla_p1 1638
 +#define DT_N_S_soc_S_i2c_40005400_S_si5351_60_P_plla_p1_EXISTS 1
 +
 +// For things like string enum there are a whole bunch of lines generated
 +#define DT_N_S_soc_S_i2c_40005400_S_si5351_60_P_pllb_clock_source "XTAL"
 +#define DT_N_S_soc_S_i2c_40005400_S_si5351_60_P_pllb_clock_source_STRING_UNQUOTED XTAL
 +#define DT_N_S_soc_S_i2c_40005400_S_si5351_60_P_pllb_clock_source_STRING_TOKEN XTAL
 +#define DT_N_S_soc_S_i2c_40005400_S_si5351_60_P_pllb_clock_source_STRING_UPPER_TOKEN XTAL
 +#define DT_N_S_soc_S_i2c_40005400_S_si5351_60_P_pllb_clock_source_IDX_0 "XTAL"
 +#define DT_N_S_soc_S_i2c_40005400_S_si5351_60_P_pllb_clock_source_IDX_0_EXISTS 1
 +#define DT_N_S_soc_S_i2c_40005400_S_si5351_60_P_pllb_clock_source_IDX_0_ENUM_IDX 0
 +#define DT_N_S_soc_S_i2c_40005400_S_si5351_60_P_pllb_clock_source_IDX_0_ENUM_VAL_XTAL_EXISTS 1
 +#define DT_N_S_soc_S_i2c_40005400_S_si5351_60_P_pllb_clock_source_FOREACH_PROP_ELEM(fn) fn(DT_N_S_soc_S_i2c_40005400_S_si5351_60, pllb_clock_source, 0)
 +#define DT_N_S_soc_S_i2c_40005400_S_si5351_60_P_pllb_clock_source_FOREACH_PROP_ELEM_SEP(fn, sep) fn(DT_N_S_soc_S_i2c_40005400_S_si5351_60, pllb_clock_source, 0)
 +#define DT_N_S_soc_S_i2c_40005400_S_si5351_60_P_pllb_clock_source_FOREACH_PROP_ELEM_VARGS(fn, ...) fn(DT_N_S_soc_S_i2c_40005400_S_si5351_60, pllb_clock_source, 0, __VA_ARGS__)
 +#define DT_N_S_soc_S_i2c_40005400_S_si5351_60_P_pllb_clock_source_FOREACH_PROP_ELEM_SEP_VARGS(fn, sep, ...) fn(DT_N_S_soc_S_i2c_40005400_S_si5351_60, pllb_clock_source, 0, __VA_ARGS__)
 +#define DT_N_S_soc_S_i2c_40005400_S_si5351_60_P_pllb_clock_source_LEN 1
 +#define DT_N_S_soc_S_i2c_40005400_S_si5351_60_P_pllb_clock_source_EXISTS 1
 +</code>
  
zephyr/device_drivers.1751971355.txt.gz · Last modified: 2025/07/08 10:42 by utedass

Except where otherwise noted, content on this wiki is licensed under the following license: CC0 1.0 Universal
CC0 1.0 Universal Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki