Commit 7c816e24a4e980e2717e5c83090dec73bc4eac57

Authored by Przemyslaw Marczak
Committed by Minkyu Kang
1 parent 35d460fbc8

dm: regulator: add function device_get_supply_regulator()

Some devices are supplied by configurable regulator's output.
But there was no function for getting it. This commit adds
function, that allows for getting the supply device by it's phandle.

The returned regulator device can be used with regulator uclass's API.

Signed-off-by: Przemyslaw Marczak <p.marczak@samsung.com>
Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Minkyu Kang <mk7.kang@samsung.com>

Showing 2 changed files with 23 additions and 0 deletions Side-by-side Diff

drivers/power/regulator/regulator-uclass.c
... ... @@ -138,6 +138,13 @@
138 138 return uclass_get_device_by_name(UCLASS_REGULATOR, devname, devp);
139 139 }
140 140  
  141 +int device_get_supply_regulator(struct udevice *dev, const char *supply_name,
  142 + struct udevice **devp)
  143 +{
  144 + return uclass_get_device_by_phandle(UCLASS_REGULATOR, dev,
  145 + supply_name, devp);
  146 +}
  147 +
141 148 int regulator_autoset(struct udevice *dev)
142 149 {
143 150 struct dm_regulator_uclass_platdata *uc_pdata;
include/power/regulator.h
... ... @@ -419,5 +419,21 @@
419 419 */
420 420 int regulator_get_by_platname(const char *platname, struct udevice **devp);
421 421  
  422 +/**
  423 + * device_get_supply_regulator: returns the pointer to the supply regulator.
  424 + * Search by phandle, found in device's node.
  425 + *
  426 + * Note: Please pay attention to proper order of device bind sequence.
  427 + * The regulator device searched by the phandle, must be binded before
  428 + * this function call.
  429 + *
  430 + * @dev - device with supply phandle
  431 + * @supply_name - phandle name of regulator
  432 + * @devp - returned pointer to the supply device
  433 + * @return 0 on success or negative value of errno.
  434 + */
  435 +int device_get_supply_regulator(struct udevice *dev, const char *supply_name,
  436 + struct udevice **devp);
  437 +
422 438 #endif /* _INCLUDE_REGULATOR_H_ */