Last Comment Bug 924607 - Investigate and implement code to disable USB charging circuit via Linux Kernel
: Investigate and implement code to disable USB charging circuit via Linux Kernel
Status: RESOLVED FIXED
[c=power p=4 s= u=]
: perf
Product: Firefox OS
Classification: Client Software
Component: General (show other bugs)
: unspecified
: ARM Gonk (Firefox OS)
: P2 normal (vote)
: ---
Assigned To: Dave Huseby [:huseby]
:
:
Mentors:
Depends on:
Blocks: 890154 910448 915663 1226856
  Show dependency treegraph
 
Reported: 2013-10-08 13:31 PDT by Dave Huseby [:huseby]
Modified: 2015-11-21 13:36 PST (History)
5 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---


Attachments
Charging.png (677.94 KB, image/png)
2013-11-22 17:41 PST, Dave Huseby [:huseby]
no flags Details
No_Charging.png (653.22 KB, image/png)
2013-11-22 17:44 PST, Dave Huseby [:huseby]
no flags Details

Description Dave Huseby [:huseby] 2013-10-08 13:31:27 PDT
The Linux Kernel has drivers for controlling power regulators and the power chips.  This bugs encapsulates the investigation of the hamachi and keon devices to see if they support shutting off the USB charging circuit and then adding to the test driver scripts to shut off USB charging so the power consumption data gathering can work.
Comment 1 Dave Huseby [:huseby] 2013-10-25 10:08:58 PDT
There is an msm_charger kernel module available that looks to be able to disable the charging circuit but it doesn't expose that control to user space.  I'm in the process of writing a small kernel module that does that.
Comment 2 Dave Huseby [:huseby] 2013-11-01 11:37:23 PDT
I'm trying to build a custom kernel for the Hamachi device.  I found the kernel config file and customized it to my liking but I'm struggling to figure out the trick to get ./build.sh to build the kernel from source rather than use the one pulled from qualcomm.

Do you have any suggestions?
Comment 3 Michael Wu [:mwu] 2013-11-04 09:02:52 PST
I believe Jed has successfully built a kernel for hamachi before. We'll want to switch to a proper hamachi kernel build now that we have the source, but things aren't currently configured to easily build hamachi kernels.
Comment 4 Jed Davis [:jld] {⏰UTC-6} 2013-11-04 11:57:23 PST
There was some discussion on IRC the other day.  Our current hamachi manifest pulls CodeAurora's kernel/msm, which I haven't actually tried but I assume it won't work as-is on the device itself.

I have an altered manifest, currently at https://github.com/jld/b2g-manifest/tree/master/hamachi.xml, which will build a boot image and matching WiFi drivers from Alcatel's souce release (+ our seccomp-bpf patch).  Notes on installation are in https://gist.github.com/jld/7270024 (extra complication there because the WiFi drivers created by the build will be overwritten by the ones from backup-hamachi in the system.img staging tree).

WARNING: Some builds seem to have a locked bootloader which won't load an image created this way, in which case the device will be bricked until an acceptable boot.img is flashed (but fastboot will still work for that).
Comment 5 Dave Huseby [:huseby] 2013-11-08 10:36:30 PST
I'm limiting the scope of this bug to be just getting charging under software control on my GP Keon.  There will be follow on bugs to track the work of getting the Hamachi kernel source build up to date and patched.
Comment 6 Dave Huseby [:huseby] 2013-11-19 13:32:01 PST
According to qualcomm, the charging circuit isn't under software control from the application processor.  Only the baseband processor can control it.  That means the Keon and Hamachi are unable to disable charging from the b2g side.  I am now switching to investigating making a source build of the kernel for the Nexus S and Nexus 4 hardware.  Maybe they will support this feature.
Comment 7 Dave Huseby [:huseby] 2013-11-19 13:32:55 PST
I should not that this is really only needed for us to do automated regression testing for power usage.  We are still able to manually execute tests on devices with the ammeter attached and still gather reasonably good data.
Comment 8 Dave Huseby [:huseby] 2013-11-21 10:05:22 PST
I have shifted gears to working on the Nexus S platform.  It uses the max8998_charger kernel module to manage charging of the battery.  I'm currently getting the Nexus S kernel to build from source so that I can make modifications.
Comment 9 Dave Huseby [:huseby] 2013-11-22 17:41:45 PST
Created attachment 8337163 [details]
Charging.png

Screenshot showing dmesg on the Nexus S with "USB charging enabled" messages and the resulting measurements on the ammeter.  Notice that the line on the ammeter is red.  That indicates that current is flowing from the charging circuit INTO the battery (i.e. the battery is charging).
Comment 10 Dave Huseby [:huseby] 2013-11-22 17:44:04 PST
Created attachment 8337165 [details]
No_Charging.png

This is a screenshot of the same kernel as before but with a modified battery driver that disables charging and refuses to enable it when the USB cable is connected.  Notice in the dmesg output it says "REFUSING TO ENABLE CHARGING".  There is also the ammeter output that shows that current is flowing from the battery into the device (i.e. the battery is discharging) even though the USB cable is attached.
Comment 11 Dave Huseby [:huseby] 2013-11-22 17:45:06 PST
My investigation is complete.  Moving on to implementation.  See Bug 942387 and Bug 942386.

Note You need to log in before you can comment on or make changes to this bug.