Commit 85052e90 authored by Marek Vasut's avatar Marek Vasut Committed by Sebastian Reichel

power: supply: bq25890: Add get_voltage support to Vbus regulator

The chip is capable of reporting Vbus voltage, add .get_voltage
implementation to Vbus regulator to report current Vbus voltage.
This requires for the Vbus regulator to be registered always
instead of the current state where the regulator is registered
only in case USB PHY is not found.

Do not provide Vbus regulator enable/disable ops in case USB PHY
is present, as they would race with USB PHY notifier which is also
used to toggle OTG boost mode.
Signed-off-by: default avatarMarek Vasut <marex@denx.de>
Reviewed-by: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarSebastian Reichel <sebastian.reichel@collabora.com>
parent 5f5c10ec
...@@ -1095,10 +1095,18 @@ static int bq25890_vbus_is_enabled(struct regulator_dev *rdev) ...@@ -1095,10 +1095,18 @@ static int bq25890_vbus_is_enabled(struct regulator_dev *rdev)
return bq25890_field_read(bq, F_OTG_CFG); return bq25890_field_read(bq, F_OTG_CFG);
} }
static int bq25890_vbus_get_voltage(struct regulator_dev *rdev)
{
struct bq25890_device *bq = rdev_get_drvdata(rdev);
return bq25890_get_vbus_voltage(bq);
}
static const struct regulator_ops bq25890_vbus_ops = { static const struct regulator_ops bq25890_vbus_ops = {
.enable = bq25890_vbus_enable, .enable = bq25890_vbus_enable,
.disable = bq25890_vbus_disable, .disable = bq25890_vbus_disable,
.is_enabled = bq25890_vbus_is_enabled, .is_enabled = bq25890_vbus_is_enabled,
.get_voltage = bq25890_vbus_get_voltage,
}; };
static const struct regulator_desc bq25890_vbus_desc = { static const struct regulator_desc bq25890_vbus_desc = {
...@@ -1107,8 +1115,6 @@ static const struct regulator_desc bq25890_vbus_desc = { ...@@ -1107,8 +1115,6 @@ static const struct regulator_desc bq25890_vbus_desc = {
.type = REGULATOR_VOLTAGE, .type = REGULATOR_VOLTAGE,
.owner = THIS_MODULE, .owner = THIS_MODULE,
.ops = &bq25890_vbus_ops, .ops = &bq25890_vbus_ops,
.fixed_uV = 5000000,
.n_voltages = 1,
}; };
static int bq25890_register_regulator(struct bq25890_device *bq) static int bq25890_register_regulator(struct bq25890_device *bq)
...@@ -1120,9 +1126,6 @@ static int bq25890_register_regulator(struct bq25890_device *bq) ...@@ -1120,9 +1126,6 @@ static int bq25890_register_regulator(struct bq25890_device *bq)
}; };
struct regulator_dev *reg; struct regulator_dev *reg;
if (!IS_ERR_OR_NULL(bq->usb_phy))
return 0;
if (pdata) if (pdata)
cfg.init_data = pdata->regulator_init_data; cfg.init_data = pdata->regulator_init_data;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment