drivers: power: update sc89890

This commit is contained in:
leeboby 2024-08-02 10:28:02 +08:00
parent c074246461
commit fb85003c91
2 changed files with 28 additions and 59 deletions

View File

@ -664,32 +664,25 @@
pinctrl-names = "default";
pinctrl-0 = <&i2c6m3_xfer>;
sy6970: sy6970_charge@6a {
compatible = "ti,bq25895", "ti,bq25890";
sc89890: sc89890@6a {
compatible = "sc,sc89890";
reg = <0x6a>;
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <&charger_ok>;
interrupt-parent = <&gpio1>;
interrupts = <RK_PC0 IRQ_TYPE_EDGE_FALLING>;
otg-mode-en-gpios = <&gpio1 RK_PC1 GPIO_ACTIVE_HIGH>;
//ti,usb-charger-detection = <&usbc0>;
//otg-mode-en-gpios = <&gpio1 RK_PC1 GPIO_ACTIVE_HIGH>;
ti,battery-regulation-voltage = <4400000>; /* 4.4V */
ti,charge-current = <1600000>; /* 1.6A */
ti,termination-current = <66000>; /* 66mA */
ti,precharge-current = <130000>; /* 130mA */
ti,minimum-sys-voltage = <3000000>; /* 3V */
ti,boost-voltage = <5000000>; /* 5V */
ti,boost-max-current = <1600000>; /* 1600mA */
//regulators {
// vbus5v0_typec: vbus5v0-typec {
// regulator-compatible = "otg-vbus";
// regulator-name = "vbus5v0_typec";
// };
//};
//status = "okay";
status = "disabled";
sc,battery-regulation-voltage = <4350000>; /* 4.4V */
sc,charge-current = <4000000>; /* 4.0A */
sc,termination-current = <100000>; /* 100mA */
sc,precharge-current = <500000>; /* 130mA */
sc,minimum-sys-voltage = <3400000>; /* 3V */
sc,thermal-regulation-threshold = <4000000>;
sc,ibatcomp-clamp-microvolt = <100000>;
sc,ibatcomp-micro-ohms = <20>;
};
usbc0: fusb302@22 {
@ -757,26 +750,6 @@
};
};
};
sgm41542: sgm41542@3b {
compatible = "sgm,sgm41542";
reg = <0x3b>;
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <&charger_ok>;
interrupt-parent = <&gpio1>;
interrupts = <RK_PC0 IRQ_TYPE_EDGE_FALLING>;
input-voltage-limit-microvolt = <4500000>;
input-current-limit-microamp = <3000000>;
regulators {
vbus5v0_typecc: vbus5v0-typec {
regulator-compatible = "otg-vbus";
regulator-name = "vbus5v0_typecc";
};
};
};
};
&i2c7 {
@ -823,12 +796,6 @@
};
&pinctrl {
charger {
charger_ok: charger_ok {
rockchip,pins = <1 RK_PC0 RK_FUNC_GPIO &pcfg_pull_up>;
};
};
usb-typec {
usbc0_int: usbc0-int {
rockchip,pins = <4 RK_PA3 RK_FUNC_GPIO &pcfg_pull_up>;

View File

@ -431,12 +431,13 @@ static irqreturn_t __sc89890_handle_irq(struct sc89890_device *sc89890)
return IRQ_NONE;
if (!new_state.online && sc89890->state.online) { /* power removed */
regmap_write(sc89890->rmap, 3, 0x0e);
/* disable ADC */
ret = sc89890_field_write(sc89890, F_CONV_START, 0);
if (ret < 0)
goto error;
} else if (new_state.online && !sc89890->state.online) { /* power inserted */
regmap_write(sc89890->rmap, 3, 0x1e);
/* enable ADC, to have control of charge current/voltage */
ret = sc89890_field_write(sc89890, F_CONV_START, 1);
if (ret < 0)
@ -680,11 +681,11 @@ static int sc89890_hw_init(struct sc89890_device *sc89890)
{F_VCLAMP, sc89890->init_data.vclamp},
};
ret = sc89890_chip_reset(sc89890);
if (ret < 0) {
dev_dbg(sc89890->dev, "Reset failed %d\n", ret);
return ret;
}
//ret = sc89890_chip_reset(sc89890);
//if (ret < 0) {
// dev_dbg(sc89890->dev, "Reset failed %d\n", ret);
// return ret;
//}
/* disable watchdog */
ret = sc89890_field_write(sc89890, F_WD, 0);
@ -750,7 +751,7 @@ static const enum power_supply_property sc89890_power_supply_props[] = {
};
static char *sc89890_charger_supplied_to[] = {
"usb",
"charger",
};
static const struct power_supply_desc sc89890_power_supply_desc = {
@ -795,7 +796,7 @@ static int sc89890_get_chip_version(struct sc89890_device *sc89890)
return -ENODEV;
}
DBG("charge IC: SC89890\n");
printk("charge IC: SC89890\n");
return 0;
}
@ -985,8 +986,8 @@ static int sc89890_fw_read_u32_props(struct sc89890_device *sc89890)
{"sc,termination-current", false, TBL_ITERM, &init->iterm},
{"sc,precharge-current", false, TBL_ITERM, &init->iprechg},
{"sc,minimum-sys-voltage", false, TBL_SYSVMIN, &init->sysvmin},
{"sc,boost-voltage", false, TBL_BOOSTV, &init->boostv},
{"sc,boost-max-current", false, TBL_BOOSTI, &init->boosti},
//{"sc,boost-voltage", false, TBL_BOOSTV, &init->boostv},
//{"sc,boost-max-current", false, TBL_BOOSTI, &init->boosti},
/* optional properties */
{"sc,thermal-regulation-threshold", true, TBL_TREG, &init->treg},
@ -1001,8 +1002,8 @@ static int sc89890_fw_read_u32_props(struct sc89890_device *sc89890)
for (i = 0; i < ARRAY_SIZE(props); i++) {
ret = device_property_read_u32(sc89890->dev,
props[i].name,
&property);
props[i].name,
&property);
if (ret < 0) {
if (props[i].optional)
continue;
@ -1099,7 +1100,6 @@ static int sc89890_probe(struct i2c_client *client,
return ret;
}
if (client->irq < 0) {
dev_err(dev, "No irq resource found.\n");
return client->irq;
@ -1115,6 +1115,8 @@ static int sc89890_probe(struct i2c_client *client,
sc89890_register_otg_vbus_regulator(sc89890);
sc89890_create_device_node(sc89890->dev);
regmap_write(sc89890->rmap, 3, 0x0e);
return 0;
irq_fail: