Page MenuHomeFreeBSD

fdt: Add fdt_reg_by_name
AbandonedPublic

Authored by manu on Sep 11 2017, 8:12 PM.
Tags
None
Referenced Files
Unknown Object (File)
May 20 2024, 8:38 PM
Unknown Object (File)
Apr 23 2024, 7:17 PM
Unknown Object (File)
Feb 28 2024, 6:20 PM
Unknown Object (File)
Jan 28 2024, 12:21 AM
Unknown Object (File)
Jan 16 2024, 11:05 PM
Unknown Object (File)
Jan 9 2024, 4:10 AM
Unknown Object (File)
Sep 25 2023, 12:35 AM
Unknown Object (File)
Aug 30 2023, 9:55 AM
Subscribers

Details

Reviewers
None
Group Reviewers
ARM
Summary

fdt_get_by_name can be used to get some of the content of the 'reg' property
based on one of the 'reg-names' values.
When the 'reg' property have multiple values, sometimes a 'reg-names'
property is also present to represent the values.

Test Plan

Tested on Pine64 with the usbphy node having reg-names for the different phys.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

I'm confused about how this function might be used. Device drivers don't directly access reg= properties in freebsd; the properties are managed by the bus and rman code. That is, if you have

reg-names = "phy_ctrl", "pmu0", "pmu1"

and you need the pmu0 registers in a driver, then you would need code something like:

int rid;
if (ofw_bus_find_string_index(node, "reg-names", name, &rid) != 0)
  return (EINVAL);
res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE);
In D12323#255710, @ian wrote:

I'm confused about how this function might be used. Device drivers don't directly access reg= properties in freebsd; the properties are managed by the bus and rman code. That is, if you have

reg-names = "phy_ctrl", "pmu0", "pmu1"

and you need the pmu0 registers in a driver, then you would need code something like:

int rid;
if (ofw_bus_find_string_index(node, "reg-names", name, &rid) != 0)
  return (EINVAL);
res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE);

I didn't know that you could use rid for that. The man page isn't really clear on how it work for FDT system but now that you pointed that out it make sense.
I don't need my code now. Thanks Ian.