PabloPL / linux

Linux kernel source tree
Other
17 stars 0 forks source link

Max8998 charger #15

Open PabloPL opened 6 years ago

PabloPL commented 6 years ago

Without this it's impossible to charge batter, when using mainline kernel.

Prepared v2 version of patchset and send to LKML.

xc-racer99 commented 4 years ago

Charger-manager support created at https://github.com/PabloPL/linux/tree/for-upstream/charger-manager

Appears to work just fine on Fascinate4G. i9000 has slightly different thermal values.

xc-racer99 commented 4 years ago

Alright, I've spent a lot of work on this lately trying to figure out how best to implement charging. The best documentation I've found is:

Edit: There's also the low bat alarms, two are supported. Config is in the older kernel header max8998_function.h Important struct is

// LBCNFG
typedef enum {
    LBHYST_100mV,
    LBHYST_200mV,
    LBHYST_300mV,
    LBHYST_400mV,
    LBTH_2p9V,
    LBTH_3p0V,
    LBTH_3p1V,
    LBTH_3p2V,
    LBTH_3p3V,
    LBTH_3p4V,
    LBTH_3p5V,
    LBTH_3p57V
} lbcnfg_type;

I've noticed a few things:

I've submitted a few things to mainline (none of which are currently merged):

It might be worthwhile to create a proper max8998 charging function if the CHARGER regulator patches are denied. We would lose the custom temperature shutoff value, but otherwise I think everything would work.

Edit: BATTMON doesn't appear to be providing the temperature as it can be disabled and temperature still read (ie we have an external resistor). ENVICHG is related to the charge current, disabling it makes ADC channel 2 read 0, plus goes to 0 when not charging.

Edit 2: TOPOFF values are percentage of fast charging current, RESTART values are voltage drops (in mV) before restarting charging.