Hi, the driver was unreliable to detect usb unplug and plug and (re)start charging.
So I did improve it in several areas:
1. detect status flag (REG9/CHRG_FAULT) that tells if the power adapter was unplugged even if the driver wasn't directly immediately VBUS (previously we checked only once a second for VBUS and a quick power drop wasn't recognised by the driver code but made the charger chip change its state) 2. move all status flag detection into single place for interrupt handler/polling (this avoids races and inconsistent reports to /sys) 3. fix presentation of VBUS to /sys if it is detected to be too low and the charger goes into DPM (Dynamic Power Management i.e. self-limit current consumption) mode 4. fix coarse reporting of NTC temperature (don't expect too much: it has only 3 levels -10°C, 22.5°C, 60°C and no real ADC) 5. significant code cleanup to get rid of all static variables
I haven't committed the patches yet, but plan to do so for v4.19-rc6. Or maybe v4.18.11. Whatever will be processed first.
Attached is the full source file if you want to give it a try. It should work with 4.14 to 4.18 as well (I am not aware of API dependencies).
BR, Nikolaus