diff options
author | Jean-Jacques Hiblot <jjhiblot@ti.com> | 2018-11-29 12:57:37 +0300 |
---|---|---|
committer | Marek Vasut <marex@denx.de> | 2018-12-07 18:31:45 +0300 |
commit | 6c3af1f24e4b8ccbef20bc00b9529f4a325583f2 (patch) | |
tree | 534081dec42ca033d3e9737965804d6d1ebe02e4 /drivers/core/syscon-uclass.c | |
parent | 4d3825c1915e1649c4be0320e74be158e4698655 (diff) | |
download | u-boot-6c3af1f24e4b8ccbef20bc00b9529f4a325583f2.tar.xz |
syscon: dm: Add a new method to get a regmap from DTS
syscon_regmap_lookup_by_phandle() can be used to get the regmap of a syscon
device from a reference in the DTS. It operates similarly to the linux
version of the namesake function.
Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/core/syscon-uclass.c')
-rw-r--r-- | drivers/core/syscon-uclass.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/drivers/core/syscon-uclass.c b/drivers/core/syscon-uclass.c index 303e166a69..661cf61d62 100644 --- a/drivers/core/syscon-uclass.c +++ b/drivers/core/syscon-uclass.c @@ -53,6 +53,29 @@ static int syscon_pre_probe(struct udevice *dev) #endif } +struct regmap *syscon_regmap_lookup_by_phandle(struct udevice *dev, + const char *name) +{ + struct udevice *syscon; + struct regmap *r; + int err; + + err = uclass_get_device_by_phandle(UCLASS_SYSCON, dev, + name, &syscon); + if (err) { + dev_dbg(dev, "unable to find syscon device\n"); + return ERR_PTR(err); + } + + r = syscon_get_regmap(syscon); + if (!r) { + dev_dbg(dev, "unable to find regmap\n"); + return ERR_PTR(-ENODEV); + } + + return r; +} + int syscon_get_by_driver_data(ulong driver_data, struct udevice **devp) { struct udevice *dev; |