power: supply: sc8886: fixed otg_voltage formula

OTG voltage is Reg0x07/0x06 bit<2-13> by 8mV per step,
<bit0-1> are 0 for reserved.
OTG voltage = 1.28V + (Reg0x07/0x06 bit<2-13>) * 8mV.
And OTG voltage would be ignored if it's not in
4.28V-20.8V.

In order to keep same to bq25703, it can be expressed as
1280000uV + (Reg0x07/0x06 bit<6-13>) * 128mV

Signed-off-by: Zain Wang <wzz@rock-chips.com>
Change-Id: I0275eeded4cf86a208bf46d7a3f1dbd6d0e37b63
This commit is contained in:
Zain Wang
2022-06-14 15:17:54 +08:00
committed by Tao Huang
parent 77de161fde
commit c2cb19bf1e

View File

@@ -47,6 +47,7 @@ module_param_named(dbg_level, dbg_enable, int, 0644);
#define MAX_CHARGEVOLTAGE 16800000
#define MAX_CHARGECURRETNT 8128000
#define MAX_OTGVOLTAGE 20800000
#define MIN_OTGVOLTAGE 4280000
#define MAX_OTGCURRENT 6350000
enum bq25700_fields {
@@ -506,7 +507,13 @@ struct bq25700_lookup {
u32 size;
};
static const union {
static const struct bq25700_range sc8886_otg_range = {
.min = 1280000,
.max = 20800000,
.step = 128000,
};
static union {
struct bq25700_range rt;
struct bq25700_lookup lt;
} bq25700_tables[] = {
@@ -935,12 +942,25 @@ static int bq25700_fw_read_u32_props(struct bq25700_device *charger)
dev_err(charger->dev, "ti,input-current is error\n");
return -ENODEV;
}
if ((props[i].tbl_id == TBL_OTGVOL) &&
(property > MAX_OTGVOLTAGE)) {
dev_err(charger->dev, "ti,ti,otg-voltage is error\n");
return -ENODEV;
if (props[i].tbl_id == TBL_OTGVOL) {
if (of_device_is_compatible(charger->dev->of_node,
"southchip,sc8886")) {
bq25700_tables[TBL_OTGVOL].rt = sc8886_otg_range;
if (property < MIN_OTGVOLTAGE) {
dev_err(charger->dev,
"ti,otg-voltage is error");
return -ENODEV;
}
}
if (property > MAX_OTGVOLTAGE) {
dev_err(charger->dev, "ti,otg-voltage is error\n");
return -ENODEV;
};
}
if ((props[i].tbl_id == TBL_OTGVOL) &&
if ((props[i].tbl_id == TBL_OTGCUR) &&
(property > MAX_OTGCURRENT)) {
dev_err(charger->dev, "ti,otg-current is error\n");
return -ENODEV;