Re: [PATCH v2 1/2] power: supply: cpcap-battery: Add battery type auto detection for mapphone devices

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> On Apr 24, 2021 08:47, Tony Lindgren <tony@xxxxxxxxxxx> wrote:
> >
> > Hi, 
> >
> > * Carl Philipp Klemm <philipp@xxxxxxxx> [210423 12:55]: 
> > > +static void cpcap_battery_detect_battery_type(struct cpcap_battery_ddata *ddata) 
> > > +{ 
> > > + struct nvmem_device *nvmem; 
> > > + u8 battery_id = 0; 
> > > + 
> > > + ddata->check_nvmem = false; 
> > > + 
> > > + nvmem = nvmem_device_find(NULL, &cpcap_battery_match_nvmem); 
> > > + if (IS_ERR_OR_NULL(nvmem)) { 
> > > + ddata->check_nvmem = true; 
> > > + if (!ddata->no_nvmem_warned) { 
> > > + dev_info(ddata->dev, "Can not find battery nvmem device. Assuming generic lipo battery\n"); 
> > > + ddata->no_nvmem_warned = true; 
> > > + } 
> >
> > Folks are also using the device with no battery at all to have it directly 
> > connected to the power supply. This is handy for remotely power cycling 
> > the device, and also for measuring power consumption with a bench power 
> > supply. So by default I think we should continue assuming no battery is 
> > inserted rather than assume a generic battery is inserted. 
> >
> > How about require configuring the undetected battery parameters via 
> > /sys/class/power_supply to indicate a non-standard battery is inserted? 
> >
> > At least battery type, capacity, and voltage can depend on the generic 
> > battery inserted. 
> >
> > Other than that, the NVRAM changes look nice to me. 
> >
> > Regards, 
> >
> > Tony 
> 
> The battery inserted property is still based on the presence of a thermistor, so I don't see how this patch changes the bevior with regards to this use case at all except for that info print. Previously the battery information struct was simply set to the values expected from eb41 no matter what.

Vefore writing this patch i did use the below on my xt875, which dose what you ask. maybe this is something you would like to see included in addition to the above? if so i can submitt it aswell:

[PATCH] power: supply: cpcap-battery: make charge_full_design writeable, so that different/custom batteries can be used.

Especially usfull on XTT875 where both HW4X and BW8X exsist

---
 drivers/power/supply/cpcap-battery.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/power/supply/cpcap-battery.c b/drivers/power/supply/cpcap-battery.c
index be8d8b746f24..6465cb1b084c 100644
--- a/drivers/power/supply/cpcap-battery.c
+++ b/drivers/power/supply/cpcap-battery.c
@@ -769,6 +769,13 @@ static int cpcap_battery_set_property(struct power_supply *psy,
 
 		ddata->charge_full = val->intval;
 
+		return 0;
+			case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN:
+		if (val->intval < 0)
+			return -EINVAL;
+
+		ddata->config.info.charge_full_design = val->intval;
+
 		return 0;
 	default:
 		return -EINVAL;
@@ -783,6 +790,7 @@ static int cpcap_battery_property_is_writeable(struct power_supply *psy,
 	switch (psp) {
 	case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE:
 	case POWER_SUPPLY_PROP_CHARGE_FULL:
+	case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN:
 		return 1;
 	default:
 		return 0;
-- 
2.31.0



[Index of Archives]     [Linux Arm (vger)]     [ARM Kernel]     [ARM MSM]     [Linux Tegra]     [Linux WPAN Networking]     [Linux Wireless Networking]     [Maemo Users]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux