Skip to contentSkip to conversation

bq2415x_charger: Use power_supply notifier for automode

PATCH Ивайло Димитров 4 participants 5 messages Nov 25, 2013 – Nov 28, 2013

lore
Share & tools
lore
#0 lore raw
Quoted 3 lines

-------- Оригинално писмо --------
От: Sebastian Reichel
Относно: Re: [PATCH v2 2/3] bq2415x_charger: Use power_supply notifier for

automode

Quoted 23 lines

До: Ивайло Димитров
Изпратено на: Понеделник, 2013, Ноември 25 19:14:21 EET

Quoted 10 lines · Ивайло Димитров
Quoted 10 lines

Now.. Imagine phone left in car in charger (on sun). Likely temperature will reach high values, kernel is charging, dsme will reboot the system, but kernel will start charging again, dsme will reboot again, ...

And it is not only high temperatures that are problem for li-ion charging; battery should not be fast charged below 5C and should not be charged below 0C. (Again, both are likely to happen if you leave your phone in car).

Quoted 4 lines
Quoted 1 line

AFAICT, we should simply disable charging below 5C or above 45C.

AFAIK dsme will not restart it, but power it off, so the above scenario won't happen.

Just assume what happens, when dsme does not start (e.g. system boot hangs).

Quoted 8 lines

If everything is controlled from userspace, charger would not start (-> safe!). If everything is controlled by the kernel, temperature safety checks are taken (-> safe!). But in the currently proposed
variant: No safety checks.

-- Sebastian

Hmm, you have a point here :)

So, AIUI there are 2 options:

1. charger driver polls the battery driver every n (60?) seconds.
2. battery driver sends PSY_EVENT_PROP_CHANGED on every degree up or down

In both cases if the temperature is outside of the safe margins, the charging should be stopped.

2 seems more generic to me, but as rx51-battery is missing the functionality to send events on temperature change, I guess 1 will be easier to implement.

And I think there should be some method (sysfs entry?, /dev/bqxxx opened?) to tell the charger driver to stop polling the battery driver once (and if) the userspace has started to take care of the battery temperature - makes no sense to duplicate the checks IMO.

#1 lore raw

Hi,

Quoted 8 lines · Ивайло Димитров

So, AIUI there are 2 options:

1. charger driver polls the battery driver every n (60?) seconds.
2. battery driver sends PSY_EVENT_PROP_CHANGED on every degree up or down.

In both cases if the temperature is outside of the safe margins, the charging should be stopped.

ACK.

Quoted 3 lines

2 seems more generic to me, but as rx51-battery is missing the functionality to send events on temperature change, I guess 1 will be easier to implement.

The temperature must be polled anyway, if the ADC does not support interrupts.

Quoted 4 lines

And I think there should be some method (sysfs entry?, /dev/bqxxx opened?) to tell the charger driver to stop polling the battery driver once (and if) the userspace has started to take care of the battery temperature - makes no sense to duplicate the checks IMO.

I would just cache the temperature value in the battery driver for a couple of seconds. Then userspace can check for very high temperatures (-> system shutdown) and the charging driver can check for temperatures, which are critical for charging.

-- Sebastian

#2 lore raw
Quoted 7 lines · On Monday 25 November 2013 22:50:01 Sebastian Reichel wrote:
Quoted 3 lines

2 seems more generic to me, but as rx51-battery is missing the functionality to send events on temperature change, I guess 1 will be easier to implement.

The temperature must be polled anyway, if the ADC does not support interrupts.

Yes, ADC does not support interrupts, temperature must be polled. Also bq27200 chip does not support interrupts, but bq27x00_battery driver using delayed work which every 60s poll all values (timeout can be configured via modprobe param). So similar code can be added to rx51_battery.ko too.

Signature · 2 lines
Pali Rohár
[email protected]
#3 lore raw
Quoted 9 lines · Pali Rohár
Quoted 7 lines · On Monday 25 November 2013 22:50:01 Sebastian Reichel wrote:
Quoted 3 lines

2 seems more generic to me, but as rx51-battery is missing the functionality to send events on temperature change, I guess 1 will be easier to implement.

The temperature must be polled anyway, if the ADC does not support interrupts.

Quoted 5 lines

Yes, ADC does not support interrupts, temperature must be polled. Also bq27200 chip does not support interrupts, but bq27x00_battery driver using delayed work which every 60s poll all values (timeout can be configured via modprobe param). So similar code can be added to rx51_battery.ko too.

I think the safest implementation would be:

bq2415x polls the temperature from rx51-battery in the bq2415x watchdog handler. That way discontinuation of the charge process is guaranteed.

To avoid useless ADC conversion the rx51-battery driver caches the converted temperature value for a reasonable time (e.g. 10 seconds). This helps if multiple users want to read the battery temperature (e.g. userspace).

This also means, that the kernel stuff can handle charging autonomously and the userland daemon checks the battery temperature only for emergency shutdown (I guess the temperatures for stopping the charging and emergency shutdown are different).

IMHO it makes sense to move the emergency shutdown also into the kernel (but different driver!) in the future, but that's another topic :)

-- Sebastian

#4 lore raw
Quoted 33 lines · On Thursday 28 November 2013 01:25:50 Sebastian Reichel wrote:
Quoted 8 lines · Pali Rohár
Quoted 6 lines · On Monday 25 November 2013 22:50:01 Sebastian Reichel wrote:
Quoted 3 lines

2 seems more generic to me, but as rx51-battery is missing the functionality to send events on temperature change, I guess 1 will be easier to implement.

The temperature must be polled anyway, if the ADC does not support interrupts.

Quoted 6 lines

Yes, ADC does not support interrupts, temperature must be polled. Also bq27200 chip does not support interrupts, but bq27x00_battery driver using delayed work which every 60s poll all values (timeout can be configured via modprobe param). So similar code can be added to rx51_battery.ko too.

I think the safest implementation would be:

bq2415x polls the temperature from rx51-battery in the bq2415x watchdog handler. That way discontinuation of the charge process is guaranteed.

To avoid useless ADC conversion the rx51-battery driver caches the converted temperature value for a reasonable time (e.g. 10 seconds). This helps if multiple users want to read the battery temperature (e.g. userspace).

This also means, that the kernel stuff can handle charging autonomously and the userland daemon checks the battery temperature only for emergency shutdown (I guess the temperatures for stopping the charging and emergency shutdown are different).

Quoted 5 lines

IMHO it makes sense to move the emergency shutdown also into the kernel (but different driver!) in the future, but that's another topic :)

-- Sebastian

Just to note, here is original nokia table of temperature limits:

https://gitorious.org/rx51-bme-replacement/dsme-thermalobject-surface/source/master:modules/thermalobject_surface.c#L40

Signature · 2 lines
Pali Rohár
[email protected]