summaryrefslogtreecommitdiffstats
path: root/drivers/power/supply/ucs1002_power.c
AgeCommit message (Collapse)Author
2020-10-01power: supply: ucs1002: fix some health status issuesLucas Stach
Some fault events like the over-current condition will get resolved by the hardware, by e.g. disabling the port. As the status in the interrupt status register is cleared on read when the fault is resolved, the sysfs health property will only contain the correct health status for the first time it is read after such an event, even if the actual fault condition (like a VBUS short) still persists. To reflect this properly in the property we cache the last health status and only update the cache when a actual change happens, i.e. the ERR bit in the status register flips, as this one properly reflects a continued fault condition. The ALERT pin however, is not driven by the ERR status, but by the actual fault status, so the pin will change back to it's default state when the hardware has automatically resolved the fault by cutting the power. Thus we never get an IRQ when the actual fault condition has been resolved and the ERR status bit has been cleared in auto-recovery mode. To get this information we need to poll the interrupt status register after some time to see if the fault is gone and update our cache in that case. To avoid any additional locking, we handle both paths (IRQ firing and delayed polling) through the same single-threaded delayed work. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-01-15power: suppy: ucs1002: Make the symbol 'ucs1002_regulator_enable' staticChen Wandun
Fix the following sparse warning: drivers/power/supply/ucs1002_power.c:492:5: warning: symbol 'ucs1002_regulator_enable' was not declared. Should it be static? Fixes: a3d70dacc727 ("power: suppy: ucs1002: disable power when max current is 0") Signed-off-by: Chen Wandun <chenwandun@huawei.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-12-19power: suppy: ucs1002: disable power when max current is 0Lucas Stach
For some devices userspace needs the ability to completely cut the power to the USB devices connected to the charge controller. An easy way to achieve this is by allowing 0 as a valid max current and forcibly disable the output in that case, as well as enable it again if the regulator is in use and a non-0 max current is set. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Tested-by: Chris Healy <cphealy@gmail.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-06-26power: supply: fix semicolon.cocci warningskbuild test robot
drivers/power/supply/ucs1002_power.c:339:2-3: Unneeded semicolon Remove unneeded semicolon. Generated by: scripts/coccinelle/misc/semicolon.cocci Fixes: 9a2688e42638 ("power: supply: Add driver for Microchip UCS1002") CC: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: kbuild test robot <lkp@intel.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-05-09power: supply: ucs1002: Fix wrong return value checkingAxel Lin
Fix wrong return value checking for devm_regulator_register and devm_regmap_init_i2c. This looks like a copy-n-paste mistake. Fixes: 9a2688e42638 ("power: supply: Add driver for Microchip UCS1002") Signed-off-by: Axel Lin <axel.lin@ingics.com> Reviewed-by: Enric Balletbo i Serra <enric.balletbo@collabora.com> Reviewed-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-05-03power: supply: Add driver for Microchip UCS1002Andrey Smirnov
Add driver for Microchip UCS1002 Programmable USB Port Power Controller with Charger Emulation. The driver exposed a power supply device to control/monitor various parameter of the device as well as a regulator to allow controlling VBUS line. Signed-off-by: Enric Balletbo Serra <enric.balletbo@collabora.com> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Cc: Chris Healy <cphealy@gmail.com> Cc: Lucas Stach <l.stach@pengutronix.de> Cc: Fabio Estevam <festevam@gmail.com> Cc: Guenter Roeck <linux@roeck-us.net> Cc: linux-kernel@vger.kernel.org Cc: linux-pm@vger.kernel.org Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>