regulator: rk809/817: implement get the switch voltage

If the switch is enabled, it's voltage is same as parent supply.

Signed-off-by: shengfei Xu <xsf@rock-chips.com>
Change-Id: I8fb60bd5aa3bb0a47cac84982113663e2bf5941e
This commit is contained in:
shengfei Xu 2020-03-31 17:20:57 +08:00 committed by Joseph Chen
parent 341631cbfb
commit 68a90c3146
1 changed files with 17 additions and 0 deletions

View File

@ -1135,6 +1135,23 @@ static int switch_get_suspend_enable(struct udevice *dev)
*/
static int switch_get_value(struct udevice *dev)
{
const char *supply_name[] = { "vcc9-supply", "vcc8-supply", };
struct rk8xx_priv *priv = dev_get_priv(dev->parent);
struct udevice *supply;
int id = dev->driver_data - 1;
if (!switch_get_enable(dev))
return 0;
/* note: rk817 only contains switch0 */
if ((priv->variant == RK809_ID) || (priv->variant == RK817_ID)) {
if (!uclass_get_device_by_phandle(UCLASS_REGULATOR,
dev_get_parent(dev),
supply_name[id],
&supply))
return regulator_get_value(supply);
}
return 0;
}