Skip to content

lopper: assists: resolve /chosen overlay labels for Zephyr - #878

Open
dbingi-amd wants to merge 2 commits into
devicetree-org:masterfrom
dbingi-amd:lopper-lable-path-resol
Open

dbingi-amd wants to merge 2 commits into
devicetree-org:masterfrom
dbingi-amd:lopper-lable-path-resol

Conversation

@dbingi-amd

Copy link
Copy Markdown
Contributor

Follow up to #873

A Zephyr board overlay can set a /chosen property to a label on the domain tree, such as
zephyr,entropy = &pmcbridge_0_pmcl_trng_0 in scu200.dts. Zephyr needs that property as a node path so DT_CHOSEN(zephyr_entropy) resolves. dtc rejects the bare &label during the standalone overlay compile, because the label is not in the overlay. After the phandle form merges, lopper keeps a phandle and the board DTS prints <&label>, which DT_CHOSEN() does not accept. The entropy sample then fails to build.
This series fixes that in the Zephyr assist, on top of current master (including bb6de63).

  • zephyr_board_dt: rewrite /chosen "name = &label;" to "<&label>" before
    compile when the label is on the domain tree, and after the merge write
    single-phandle /chosen properties as node paths (/amba_pl/ becomes
    /soc/).
  • zephyr_domain_dts: run that path conversion after the board overlay
    merge.
  • tests: merge both &trng_0 and <&trng_0> and check that zephyr,entropy
    becomes /soc/trng@f1240000.
    Testing:
  • pytest tests/test_zephyr_board_overlay.py: 17 passed.
  • west lopper-command for SCU200 MBV32 writes
    zephyr,entropy = "/soc/pmcbridge-0-pmcl-trng-0@4120000" and keeps
    eeprom-0 = "/soc/i2c@40800000/eeprom@50".
  • west build -b mbv32 samples/drivers/entropy/amd_trngpsx succeeds.

A Zephyr board overlay can point a /chosen property at a label that
already exists on the domain tree, for example:
    / {
        chosen {
            zephyr,entropy = &pmcbridge_0_pmcl_trng_0;
        };
     };
Two things stop that from reaching Zephyr.
dtc treats a bare &label as a path reference. The standalone overlay
compile has no base tree, so the label is reported as missing and the
merge stops.
After a phandle form (<&label>) does merge, lopper keeps the value as a
phandle and the board DTS prints <&label>. Zephyr's DT_CHOSEN() only
accepts a node path, so the entropy sample fails with
DT_CHOSEN(zephyr_entropy) undeclared.

Before the overlay is compiled, rewrite a /chosen "name = &label;" to
"<&label>" when that label is on the domain tree. A label that is not
on the domain tree is left as written, so the compile still fails.
After the overlay is merged, write each /chosen property that holds one
node phandle as that node's path. /amba_pl/ is rewritten to /soc/, the
same mapping zephyr_domain_dts already uses when it fills an empty
zephyr,entropy.
zephyr_domain_dts calls this after the board overlay merge.

Signed-off-by: Bingi Dinesh kumar <[email protected]>
The Zephyr assist now turns a /chosen label into the node path that
DT_CHOSEN() reads. Cover both spellings a board overlay can use.
Add a test that merges zephyr,entropy = &trng_0 and
zephyr,entropy = <&trng_0> onto a domain tree that has trng_0. After
chosen_phandles_to_paths(), /chosen/zephyr,entropy is the path
/soc/trng@f1240000.

Signed-off-by: Bingi Dinesh kumar <[email protected]>
@dbingi-amd

Copy link
Copy Markdown
Contributor Author

@kedareswararao please review the changes

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant