dm: regulator: add function device_get_supply_regulator()
authorPrzemyslaw Marczak <p.marczak@samsung.com>
Tue, 27 Oct 2015 12:07:59 +0000 (13:07 +0100)
committerMinkyu Kang <mk7.kang@samsung.com>
Mon, 2 Nov 2015 01:38:00 +0000 (10:38 +0900)
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>
drivers/power/regulator/regulator-uclass.c
include/power/regulator.h

index a5170df9165152f81eda9c6f6dec0839ba0fbb74..4241a4c7f2bd1fbeec6df8ceee7c128f3c2db228 100644 (file)
@@ -138,6 +138,13 @@ int regulator_get_by_devname(const char *devname, struct udevice **devp)
        return uclass_get_device_by_name(UCLASS_REGULATOR, devname, devp);
 }
 
+int device_get_supply_regulator(struct udevice *dev, const char *supply_name,
+                               struct udevice **devp)
+{
+       return uclass_get_device_by_phandle(UCLASS_REGULATOR, dev,
+                                           supply_name, devp);
+}
+
 int regulator_autoset(struct udevice *dev)
 {
        struct dm_regulator_uclass_platdata *uc_pdata;
index 1a51c3f07bc80aa0911db796bfdbc12140916266..63c0814fe83cea2be9bb800940971c7f420395de 100644 (file)
@@ -419,4 +419,20 @@ int regulator_get_by_devname(const char *devname, struct udevice **devp);
  */
 int regulator_get_by_platname(const char *platname, struct udevice **devp);
 
+/**
+ * device_get_supply_regulator: returns the pointer to the supply regulator.
+ * Search by phandle, found in device's node.
+ *
+ * Note: Please pay attention to proper order of device bind sequence.
+ * The regulator device searched by the phandle, must be binded before
+ * this function call.
+ *
+ * @dev         - device with supply phandle
+ * @supply_name - phandle name of regulator
+ * @devp        - returned pointer to the supply device
+ * @return 0 on success or negative value of errno.
+ */
+int device_get_supply_regulator(struct udevice *dev, const char *supply_name,
+                               struct udevice **devp);
+
 #endif /* _INCLUDE_REGULATOR_H_ */