Message ID | 1521044326-22526-2-git-send-email-jjhiblot@ti.com |
---|---|
State | Superseded |
Delegated to: | Marek Vasut |
Headers | show |
Series | Add support for DM_USB for TI's DRA7 EVMs and AM57 EVMs platforms | expand |
Hi Jean-Jacques, On 14 March 2018 at 10:18, Jean-Jacques Hiblot <jjhiblot@ti.com> wrote: > syscon_regmap_lookup_by_phandle() can be used to 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> > --- > > Changes in v2: None > > drivers/core/syscon-uclass.c | 23 +++++++++++++++++++++++ > include/syscon.h | 13 +++++++++++++ > 2 files changed, 36 insertions(+) > > diff --git a/drivers/core/syscon-uclass.c b/drivers/core/syscon-uclass.c > index a69937e..0c76bfc 100644 > --- a/drivers/core/syscon-uclass.c > +++ b/drivers/core/syscon-uclass.c > @@ -45,6 +45,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) { > + printf("unable to find syscon device\n"); Can you please make these debug()? > + return ERR_PTR(err); > + } > + > + r = syscon_get_regmap(syscon); > + if (!r) { > + printf("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; > diff --git a/include/syscon.h b/include/syscon.h > index 5d52b1c..23d257a 100644 > --- a/include/syscon.h > +++ b/include/syscon.h > @@ -74,6 +74,19 @@ int syscon_get_by_driver_data(ulong driver_data, struct udevice **devp); > struct regmap *syscon_get_regmap_by_driver_data(ulong driver_data); > > /** > + * syscon_regmap_lookup_by_phandle() - Look up a controller by a phandle > + * > + * This operates by looking up the given name in the device (device > + * tree property) of the device using the system controller. > + * > + * @dev: Device using the system controller > + * @name: Name of property referring to the system controller > + * @return A pointer to the regmap if found, ERR_PTR(-ve) on error > + */ > +struct regmap *syscon_regmap_lookup_by_phandle(struct udevice *dev, > + const char *name); At some point we should have a test which calls this. > + > +/** > * syscon_get_first_range() - get the first memory range from a syscon regmap > * > * @driver_data: Driver data value to look up > -- > 2.7.4 > Regards, Simon
diff --git a/drivers/core/syscon-uclass.c b/drivers/core/syscon-uclass.c index a69937e..0c76bfc 100644 --- a/drivers/core/syscon-uclass.c +++ b/drivers/core/syscon-uclass.c @@ -45,6 +45,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) { + printf("unable to find syscon device\n"); + return ERR_PTR(err); + } + + r = syscon_get_regmap(syscon); + if (!r) { + printf("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; diff --git a/include/syscon.h b/include/syscon.h index 5d52b1c..23d257a 100644 --- a/include/syscon.h +++ b/include/syscon.h @@ -74,6 +74,19 @@ int syscon_get_by_driver_data(ulong driver_data, struct udevice **devp); struct regmap *syscon_get_regmap_by_driver_data(ulong driver_data); /** + * syscon_regmap_lookup_by_phandle() - Look up a controller by a phandle + * + * This operates by looking up the given name in the device (device + * tree property) of the device using the system controller. + * + * @dev: Device using the system controller + * @name: Name of property referring to the system controller + * @return A pointer to the regmap if found, ERR_PTR(-ve) on error + */ +struct regmap *syscon_regmap_lookup_by_phandle(struct udevice *dev, + const char *name); + +/** * syscon_get_first_range() - get the first memory range from a syscon regmap * * @driver_data: Driver data value to look up
syscon_regmap_lookup_by_phandle() can be used to 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> --- Changes in v2: None drivers/core/syscon-uclass.c | 23 +++++++++++++++++++++++ include/syscon.h | 13 +++++++++++++ 2 files changed, 36 insertions(+)