summaryrefslogtreecommitdiff
path: root/drivers/power/supply/cpcap-charger.c
AgeCommit message (Collapse)Author
2019-03-23cpcap-charger: generate events for userspacePavel Machek
commit fd10606f93a149a9f3d37574e5385b083b4a7b32 upstream. The driver doesn't generate uevents on charger connect/disconnect. This leads to UPower not detecting when AC is on or off... and that is bad. Reported by Arthur D. on github ( https://github.com/maemo-leste/bugtracker/issues/206 ), thanks to Merlijn Wajer for suggesting a fix. Cc: stable@kernel.org Signed-off-by: Pavel Machek <pavel@ucw.cz> Acked-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-12-05power: supply: cpcap-charger: clean an indentation issue, remove tabColin Ian King
Trivial fix to clean up indentation issue, remove an extraneous tab Signed-off-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2017-11-13power: supply: cpcap-charger: fix incorrect return value checkPan Bian
Function platform_get_irq_byname() returns a negative error code on failure, and a zero or positive number on success. However, in function cpcap_usb_init_irq(), positive IRQ numbers are also taken as error cases. Use "if (irq < 0)" instead of "if (!irq)" to validate the return value of platform_get_irq_byname(). Signed-off-by: Pan Bian <bianpan2016@163.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-06-15power: supply: cpcap-charger: Add missing power_supply_configTony Lindgren
Otherwise cpcap-battery won't probe properly with the power-supplies property configured but will fail with "Not all required supplies found, defer probe". Cc: Marcel Partap <mpartap@gmx.net> Cc: Michael Scott <michael.scott@linaro.org> Signed-off-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-05-14power: supply: cpcap-charger: Fix charger voltages based on ADC valuesTony Lindgren
With the ADC driver working, we can now fix the voltage table based on the values read from the ADC. Note that unlike the ICHRG registers, the VCHRG register bits don't match the MC13783UG.pdf. Cc: Marcel Partap <mpartap@gmx.net> Cc: Michael Scott <michael.scott@linaro.org> Signed-off-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-05-14power: supply: cpcap-charger: Update charge current table and add commentsTony Lindgren
Turns out a similar battery charger hardware is documented for NXP MC13783 PMIC in "MC13783 Power Management and Audio Circuit Users's Guide" named MC13783UG.pdf. Looks like the CPCAP charge current table matches that, so let's start using the nominal values from it. While at it, let's also add comments to some of the mystery CPCAP charger registers based on the MC13783UG.pdf documentation. Note that this patch does not contain any functional changes, the register values being used stay the same. Cc: Marcel Partap <mpartap@gmx.net> Cc: Michael Scott <michael.scott@linaro.org> Signed-off-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-05-04power: supply: cpcap-charger: Keep trickle charger bits disabledTony Lindgren
Android does not seem to set the trickle charger bits, and these seem to be only used by the bootloader when bringing up a completely discharged battery. So let's keep the trickle charging bits disabled and avoid misconfiguring the hardware. Fixes: 0c9888e3c192 ("power: supply: cpcap-charger: Add minimal CPCAP PMIC battery charger") Cc: Marcel Partap <mpartap@gmx.net> Cc: Michael Scott <michael.scott@linaro.org> Signed-off-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-05-04power: supply: cpcap-charger: Fix enable for 3.8V charge settingTony Lindgren
Zero is a valid register value for for 3.8V charging. Fixes: 0c9888e3c192 ("power: supply: cpcap-charger: Add minimal CPCAP PMIC battery charger") Cc: Marcel Partap <mpartap@gmx.net> Cc: Michael Scott <michael.scott@linaro.org> Signed-off-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-05-04power: supply: cpcap-charger: Fix charge voltage configurationTony Lindgren
We have the charge voltage wrong, it should be 4.35V instead of 4.2V. This will cause the battery to never get fully charged. I noticed this when looking at the Andoid kernel battery and charger status for a fully charged battery: POWER_SUPPLY_VOLTAGE_NOW=4351000 Also the battery on droid 4 says "4.35, 1735/1785mAh (min/typ), 6.6/6.8 Wh (min/typ)". Presumably the 4.35 on the battery is the charge voltage. And finally, on Android the CPCAP CRM register is set to 0x03b5 where the b is the charge voltage. Let's fix the charge voltage define and update the charge configuration to use the 4.35V setting. Fixes: 0c9888e3c192 ("power: supply: cpcap-charger: Add minimal CPCAP PMIC battery charger") Cc: Marcel Partap <mpartap@gmx.net> Cc: Michael Scott <michael.scott@linaro.org> Signed-off-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-05-04power: supply: cpcap-charger: Fix charger nameTony Lindgren
I noticed we have a different name from what Android is using. Let's not break the /sys/class/power user space interface here and use the same naming as Android has. On Android we have the following for droid 4: $ ls /sys/class/power_supply/ ac battery usb So let's use the usb naming here for charger too. Fixes: 0c9888e3c192 ("power: supply: cpcap-charger: Add minimal CPCAP PMIC battery charger") Cc: Marcel Partap <mpartap@gmx.net> Cc: Michael Scott <michael.scott@linaro.org> Signed-off-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-04-14power: supply: cpcap-charger: Add minimal CPCAP PMIC battery chargerTony Lindgren
The custom CPCAP PMIC used on Motorola phones such as Droid 4 has a USB battery charger. It can optionally also have a companion chip that is used for wireless charging. The charger on CPCAP also can feed VBUS for the USB host mode. This can be handled by the existing kernel phy_companion interface. Cc: devicetree@vger.kernel.org Cc: Marcel Partap <mpartap@gmx.net> Cc: Michael Scott <michael.scott@linaro.org> Signed-off-by: Tony Lindgren <tony@atomide.com> Acked-by: Rob Herring <robh@kernel.org> Signed-off-by: Sebastian Reichel <sre@kernel.org>