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
Am 27.09.2018 um 16:52 schrieb H. Nikolaus Schaller hns@goldelico.com:
Hi, the driver was unreliable to detect usb unplug and plug and (re)start charging.
So I did improve it in several areas:
- detect status flag (REG9/CHRG_FAULT) that tells if the power adapter was
unplugged even if the driver wasn't directly immediately VBUS
s/immediately/scanning/
(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).
There is a small bug which makes detection fail again on the latest boards until you plug in and remove an OTG cable... Please:
s/GPIOD_OUT_HIGH/GPIOD_OUT_LOW/
in line 1138.
BR, Nikolaus
<bq2429x_charger.c>_______________________________________________ Kernel mailing list Kernel@pyra-handheld.com http://pyra-handheld.com/cgi-bin/mailman/listinfo/kernel
On 9/27/18 6:32 PM, H. Nikolaus Schaller wrote:
Am 27.09.2018 um 16:52 schrieb H. Nikolaus Schaller hns@goldelico.com:
Hi, the driver was unreliable to detect usb unplug and plug and (re)start charging.
So I did improve it in several areas:
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).
I've packaged a kernel modified with this as linux-image-4.18.4-letux-lpae-pyra-charge on the pyraos repo.
Since my prototype wouldn't charge at all with a 4.18 kernel before, it now seems to at least pull in 0.4A.
Hi,
Am 27.09.2018 um 21:11 schrieb aTc atc@k-n-p.org:
On 9/27/18 6:32 PM, H. Nikolaus Schaller wrote:
Am 27.09.2018 um 16:52 schrieb H. Nikolaus Schaller hns@goldelico.com:
Hi, the driver was unreliable to detect usb unplug and plug and (re)start charging.
So I did improve it in several areas:
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).
I've packaged a kernel modified with this as linux-image-4.18.4-letux-lpae-pyra-charge on the pyraos repo.
Since my prototype wouldn't charge at all with a 4.18 kernel before, it now seems to at least pull in 0.4A.
Fine!
1. does it report VBUS events on the console?
2. what does
cat /sys/class/power_supply/bq24297/input_current_limit
report?
3. can you please try:
echo 2000000 >/sys/class/power_supply/bq24297/input_current_limit
On 9/28/18 8:15 AM, H. Nikolaus Schaller wrote:
Since my prototype wouldn't charge at all with a 4.18 kernel before, it now seems to at least pull in 0.4A.
Fine!
- does it report VBUS events on the console?
unplugging the microusb
[ 351.760651] bq24296_usb_detect: r8=00 r9=10 [ 351.765086] bq24296: VBUS became unavailable [ 352.797410] bq24296_usb_detect: r8=00 r9=00 [ 364.220633] bq24296_usb_detect: r8=04 r9=00 [ 364.225429] bq24296: VBUS became available [ 364.233549] bq24296_update_input_current_limit(6) [ 365.259249] bq24296_usb_detect: r8=2c r9=00
after this the input current limit is set to 0.5A , while before it was 2, manually changing it back to 2000000 upped the input current, although it only seems to pull in 1.0A max.
plugging in an usb otg device: [ 790.298962] bq24296_otg_enable(1) [ 790.805301] bq24296_usb_detect: r8=00 r9=10 [ 790.809831] bq24296: VBUS became unavailable [ 791.844583] bq24296_usb_detect: r8=00 r9=00
and removing it : [ 900.675855] bq24296_otg_disable(1) [ 901.035071] bq24296_usb_detect: r8=04 r9=00 [ 901.039503] bq24296: VBUS became available [ 901.043835] bq24296_update_input_current_limit(6) [ 902.075653] bq24296_usb_detect: r8=6c r9=00
the usb device itself (an usb/otg flash drive) doesn't show up. It works fine when plugging it in the normal usb port, but doesn't generate any vbus events there.
what does
cat /sys/class/power_supply/bq24297/input_current_limit
report?
2000000
- can you please try:
echo 2000000 >/sys/class/power_supply/bq24297/input_current_limit
input current stays the same, at slightly under 1.0A
On a 4.15 kernel (with the old driver) it usually sits at 1.5A on the same charger/cable/power meter setup
setting it to 3000000 seemed to push it slightly closer to 1.0A.
Attached is the full log.