diff options
Diffstat (limited to 'sys/arm/ti/ti_hwmods.c')
-rw-r--r-- | sys/arm/ti/ti_hwmods.c | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/sys/arm/ti/ti_hwmods.c b/sys/arm/ti/ti_hwmods.c index 4da5f74..1488e55 100644 --- a/sys/arm/ti/ti_hwmods.c +++ b/sys/arm/ti/ti_hwmods.c @@ -129,7 +129,7 @@ ti_hwmods_get_clock(device_t dev) } if (len > 0) - device_printf(dev, "WARNING: more then one ti,hwmod \n"); + device_printf(dev, "WARNING: more than one ti,hwmod \n"); free(buf, M_OFWPROP); return (clk); @@ -168,3 +168,35 @@ int ti_hwmods_contains(device_t dev, const char *hwmod) return (result); } + +int +ti_hwmods_get_unit(device_t dev, const char *hwmod) +{ + phandle_t node; + int l, len, hwmodlen, result; + char *name; + char *buf; + + if ((node = ofw_bus_get_node(dev)) == 0) + return (0); + + if ((len = OF_getprop_alloc(node, "ti,hwmods", 1, (void**)&name)) <= 0) + return (0); + + buf = name; + hwmodlen = strlen(hwmod); + result = 0; + while (len > 0) { + if (strncmp(name, hwmod, hwmodlen) == 0) { + result = (int)strtoul(name + hwmodlen, NULL, 10); + break; + } + /* Slide to the next sub-string. */ + l = strlen(name) + 1; + name += l; + len -= l; + } + + free(buf, M_OFWPROP); + return (result); +} |