summaryrefslogtreecommitdiff
path: root/drivers/power/bq24257_charger.c
AgeCommit message (Collapse)Author
2015-09-29power: bq24257: Add various device-specific sysfs propertiesAndreas Dannenberg
This patch adds support for enabling/disabling optional device specific features through sysfs properties at runtime. * High-impedance mode enable/disable * Sysoff enable/disable Refer to the respective device datasheets for more information: http://www.ti.com/product/bq24250 http://www.ti.com/product/bq24251 http://www.ti.com/product/bq24257 Signed-off-by: Andreas Dannenberg <dannenberg@ti.com> Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-09-29power: bq24257: Allow input current limit sysfs accessAndreas Dannenberg
This patch allows reading and writing of the input current limit through the power supply's input_current_limit sysfs property. This allows userspace to see what charger was detected (if the D+/D- USB signal- based charger type detection is enabled) and to re-configure the maximum current drawn from the external supply at runtime based on system-level knowledge or user input. Note that upon charger disconnection and re-connection the limit configured through firmware becomes active again (or the D+/D- USB signal-based charger detection will be run again). Signed-off-by: Andreas Dannenberg <dannenberg@ti.com> Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-09-29power: bq24257: Add input DPM voltage threshold setting supportAndreas Dannenberg
A new optional device property called "ti,in-dpm-voltage" is introduced to allow configuring the input voltage threshold for the devices' dynamic power path management (DPM) feature. In short, it can be used to prevent the input voltage from dropping below a certain value as current is drawn to charge the battery or supply the system. Signed-off-by: Andreas Dannenberg <dannenberg@ti.com> Reviewed-by: Laurentiu Palcu <laurentiu.palcu@intel.com> Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-09-29power: bq24257: Add over voltage protection setting supportAndreas Dannenberg
A new optional device property called "ti,ovp-voltage" is introduced to allow configuring the input over voltage protection setting. This commit also adds the basic sysfs support for custom properties which is being used to allow userspace to read the current ovp-voltage setting. Signed-off-by: Andreas Dannenberg <dannenberg@ti.com> Reviewed-by: Laurentiu Palcu <laurentiu.palcu@intel.com> Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-09-29power: bq24257: Add SW-based approach for Power Good determinationAndreas Dannenberg
A software-based approach for determining the charger's input voltage "Power Good" state is introduced for devices like the bq24250 which don't have a dedicated hardware pin for that purpose. This SW-based approach is also used for other devices (with dedicated PG pin) as a fall back solution if that pin is not configured to be used through "pg-gpios". Signed-off-by: Andreas Dannenberg <dannenberg@ti.com> Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-09-29power: bq24257: Allow manual setting of input current limitAndreas Dannenberg
A new optional device property called "ti,current-limit" is introduced to allow disabling the D+/D- USB signal-based charger type auto- detection algorithm used to set the input current limit and instead to use a fixed input current limit. Signed-off-by: Andreas Dannenberg <dannenberg@ti.com> Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-09-29power: bq24257: Add bit definition for temp sense enableAndreas Dannenberg
Adding a missing bit definition for the sake of consistency device model vs. bit field representation. No change in functionality. Signed-off-by: Andreas Dannenberg <dannenberg@ti.com> Reviewed-by: Laurentiu Palcu <laurentiu.palcu@intel.com> Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-09-29power: bq24257: Add basic support for bq24250/bq24251Andreas Dannenberg
This patch adds basic support for bq24250 and bq24251 which are very similar to the bq24257 the driver was originally written for. Basic support means the ability to select a device through Kconfig, DT and ACPI, an instance variable allowing to check which chip is active, and the reporting back of the selected device through the model_name power supply sysfs property. This patch by itself is not sufficient to actually use those two added devices in a real-world setting due to some feature differences which are addressed by other patches in this series. Signed-off-by: Andreas Dannenberg <dannenberg@ti.com> Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-09-29power: bq24257: Simplify bq24257_power_supply_init()Andreas Dannenberg
Eliminate a few lines of code by using the PTR_ERR_OR_ZERO() macro. Signed-off-by: Andreas Dannenberg <dannenberg@ti.com> Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-09-29power: bq24257: Use managed power supply registerAndreas Dannenberg
Use the devm_* managed version of the function to register the power supply and remove the associated unregister function. This will simplify error handling moving forward as it allows the unregister to happen automatically. It also saves a few lines of code. As this changes the order of putting the bq24257 into reset vs. unregistering the power-supply during driver remove re-tested various driver unload scenario to make sure that this doesn't cause any unintended side effects such as erroneous interrupts. Signed-off-by: Andreas Dannenberg <dannenberg@ti.com> Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-09-28power: bq24257: Streamline input current limit setupAndreas Dannenberg
The maximum amount of input current the charger should draw is dependent on the power supply and should only be (re-)configured when the power supply gets connected and disconnected. However the driver was also lowering the bq24257's input current limit setting to 500mA when the battery was removed and restored the previous setting according to the power supply capabilities when the battery was reconnected although these events are not impacting the amount of power that can be drawn from the supply. Furthermore, a re-configuration of the input current limit to 500mA when the battery gets disconnected is actually dangerous if the limit was set higher previously and the system draws more than 500mA in which case the system voltage would be reduced in order to maintain 500mA which could result in the system getting too low of a supply to maintain operation. Last but not least the mechanism itself used for battery re-connection detection did not work in corner cases such as when the device's input current loop becomes active and the bq24257 device clears its battery fault error resulting in incorrectly reporting that the battery got reconnected. This patches removes the impact the battery removal/insertion has on the input current limit configured for the bq24257 and simplifies the associated handler routine. Signed-off-by: Andreas Dannenberg <dannenberg@ti.com> Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-09-28power: bq24257: Remove IRQ config through stat-gpiosAndreas Dannenberg
At the time the driver was written GpioInt resources in ACPI were not passed to the driver in client->irq, as opposed to DT enumeration. To accommodate this use case, a "stat-gpios" property was introduced to allow configuring the IRQ. However this issue with ACPI was fixed in commit "845c877 i2c / ACPI: Assign IRQ for devices that have GpioInt automatically" and makes this workaround no longer necessary, hence we can remove the support for the "stat-gpios" property and the associated code from the bq24257 driver. Signed-off-by: Andreas Dannenberg <dannenberg@ti.com> Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-06-13power_supply: bq24257: use flags argument of devm_gpiod_getUwe Kleine-König
Since 39b2bbe3d715 (gpio: add flags argument to gpiod_get*() functions) which appeared in v3.17-rc1, the gpiod_get* functions take an additional parameter that allows to specify direction and initial value for output. Simplify driver accordingly. Furthermore this is one caller less that stops us making the flags argument to gpiod_get*() mandatory. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-05-23power_supply: Add TI BQ24257 charger driverLaurentiu Palcu
Based on the datasheet found here: http://www.ti.com/lit/ds/symlink/bq24257.pdf Signed-off-by: Laurentiu Palcu <laurentiu.palcu@intel.com> Reviewed-by: Krzysztof Kozlowski <k.kozlowski.k@gmail.com> Signed-off-by: Sebastian Reichel <sre@kernel.org>