yamldevice-treezephyr-rtos

Zephyr DT_PHA_BY_NAME API returns error that the macro does not exist in devicetree_generated.h


Hi I have a device tree node which has a property of type string-array. This is supposed to work in combination with another phandle-array type property. here is the dts node:

#address-cells = <1>;
#size-cells = <0>;

padctrl: pad-controller@0xA0111000 {

    compatible = "rapidsi,pads";
    reg = <0xA0111000>;
    #pad-cells = <3>;
    pad-controller;
    status = "okay";
};

fpga_cfg: cfg-ctrl@0xA0710000 {

    #address-cells = <1>;
    #size-cells = <0>;
    status = "okay";

    ofe: ofe {
        compatible = "rapidsi,ofe";
        pads = <&padctrl 0 0x2 3>, <&padctrl 1 0x2 3>;
        pad-line-names = "CONFIG_DONE", "CONFIG_ERROR";
        status = "okay";
    };
};

here is the yaml bindings

compatible: "rapidsi,pads"
include: [pad-controller.yaml, base.yaml]

properties:

"#pad-cells":
    const: 3

pad-cells:
    - pad
    - function
    - config_mode

compatible: "rapidsi,ofe"
include: [base.yaml]

properties:

    pads:
        type: phandle-array
        required: true

    pad-line-names:
        type: string-array

This is supposed to generate the Macro DT_N_S_soc_S_cfg_ctrl_0xa0710000_S_ofe_0xa0710000_P_pads_NAME_config_done_VAL_config_mode and other macros related to pad and function cells. however, when i use the devicetree api DT_PHA_BY_NAME(DT_NODELABEL(ofe), pads, config_done, config_mode), it returns the error:

error: 'DT_N_S_soc_S_cfg_ctrl_0xa0710000_S_ofe_0xa0710000_P_pads_NAME_config_done_VAL_config_mode' undeclared (first use in this function);

I do see the Macros by IDX, but i was hoping to also have the Macros by NAME

enter image description here

Am I missing anything related to specifying bindings or dts file... Any leads, help will be highly appreciated. Thanks.


Solution

  • Apparently if we are specifying a phandle-array property whose values we want to extract using DT_PHA_BY_NAME then we need to have a specific format for the property listing its names. For example, in my case the

    pads = <&padctrl 0 0x2 3>, <&padctrl 1 0x2 3>;
    

    should have a corresponding name string-array defined only like this:

    pad-names = "CONFIG_DONE", "CONFIG_ERROR";
    

    Even an extra 's' in pad-names = "CONFIG_DONE", "CONFIG_ERROR"; like pads-names = "CONFIG_DONE", "CONFIG_ERROR"; will not let the correct macro to be generated.

    I fixed the error by hit and trial... apparently if we are specifying a phandle-array property whose values we want to extract using DT_PHA_BY_NAME then we need to have a specific format for the property listing its names. For example, in my case the

    pads = <&padctrl 0 0x2 3>, <&padctrl 1 0x2 3>; should have a corresponding name string-array defined only like this: pad-names = "CONFIG_DONE", "CONFIG_ERROR";

    Even an extra 's' in pad-names = "CONFIG_DONE", "CONFIG_ERROR"; like pads-names = "CONFIG_DONE", "CONFIG_ERROR"; will not let the correct macro to be generated.

    The rule to specify the names of property cells is mentioned here:

    https://docs.zephyrproject.org/latest/build/dts/bindings-syntax.html#specifier-cell-names-cells

    Now I see all the required macros.

    enter image description here