This wouldn't work on the DT-based ARM platform. Let's read the EC version
directly from the EC driver instead.
This removes x86 specific bits that would prevent this driver from being
used with the EC of ARM-based OLPC XO 1.75.
Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
The global variables for private data are not too nice. I'd like some
more, and that would clutter the global name space even further.
Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Avoid using the x86 OLPC platform specific call to get the board
version. That wouldn't work on FDT-based ARM MMP2 platform.
Add the XO 1.5 compatible string too. This is actually not completely
necessary as the battery nodes on XO 1.5 claim to be compatible with
"olpc,xo1-battery", but there are, in fact, differencies.
Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
The work which is scheduled on a POR boot is potentially left
pending or running until after the device module is removed,
which could result in a use-after-free.
Fix by registering a cancel/sync callback, which gets executed as
part of standard resource unwinding.
This issue was detected with the help of Coccinelle.
Signed-off-by: Sven Van Asbroeck <TheSven73@gmail.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Add a field for "voltage_max_design_uv" to present fully charged
battery voltage.
Signed-off-by: Artur Rojek <contact@artur-rojek.eu>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
The flags were just read by bq27xxx_battery_update(),
no need to read them again.
Signed-off-by: Arthur Demchenkov <spinal.by@gmail.com>
Reviewed-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
In remove(), use cancel_delayed_work_sync() to cancel the
delayed work. Otherwise there's a chance that this work
will continue to run until after the device has been removed.
While we're here, fix the deallocation order in remove(),
to correspond to the inverse of the probe() allocation
order. This guarantees that any remaining work can run
to completion with all driver structures still intact.
This issue was detected with the help of Coccinelle.
Signed-off-by: Sven Van Asbroeck <TheSven73@gmail.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Use firmware-provided limits for POWER_SUPPLY_*_MAX properties instead
of chip max values. This will reflect the battery limits as those are
the important ones.
Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
We found sometimes we can not get the saving capacity to initialize the
battery capacity, the reason is the user area registers are put on power
always-on region, so we need delay some time to wait until values are
updated successfully.
Moreover we also should clear the USER_AREA_CLEAR register after setting
the USER_AREA_SET register, otherwise we can not save the values in the
USER_AREA_SET register.
Signed-off-by: Yuanjiang Yu <yuanjiang.yu@unisoc.com>
Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
We should multiply the calibrated current data (cur_1000ma_adc) when
converting current capacity (mAh) to coulomb counter, which can get
an accurate coulomb counter from the fuel gauge controller.
Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Add POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE property to get charge
voltage sampling by ADC controller, which is used to validate if the
charge voltage is in normal range or not in charger manager.
Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
To comply with tests we need to support more power supply properties:
POWER_SUPPLY_PROP_VOLTAGE_NOW
POWER_SUPPLY_PROP_TEMP
POWER_SUPPLY_PROP_CHARGE_COUNTER
POWER_SUPPLY_PROP_CURRENT_NOW
POWER_SUPPLY_PROP_CURRENT_AVG
POWER_SUPPLY_PROP_CHARGE_FULL
POWER_SUPPLY_PROP_CYCLE_COUNT
POWER_SUPPLY_PROP_VOLTAGE_MAX
POWER_SUPPLY_PROP_CURRENT_MAX
Signed-off-by: Roman Kiryanov <rkir@google.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Fix few trivial language typos.
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
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>
We include of.h twice. It's unnecessary,so
just remove them.
Signed-off-by: Yangtao Li <tiny.windzz@gmail.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
If twl4030_bci_read() fails, the read data in "s" is incorrect,
which is however used in the following execution. The fix checks
the return value of twl4030_bci_read() and returns an error code
upstream upon the failure of twl4030_bci_read().
Signed-off-by: Kangjie Lu <kjlu@umn.edu>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Align two values as other values below.
Signed-off-by: Roman Kiryanov <rkir@google.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
The battery_data static variable was not used.
Signed-off-by: Roman Kiryanov <rkir@google.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
There was a line longer than 80 characters.
Signed-off-by: Roman Kiryanov <rkir@google.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
There was a checkpatch complain:
"Missing or malformed SPDX-License-Identifier tag".
Signed-off-by: Roman Kiryanov <rkir@google.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code.
Signed-off-by: Yangtao Li <tiny.windzz@gmail.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
This migrates isp1704 driver from old GPIO API to new descriptor
based GPIO API and drops useless platform data as a side-effect.
Migration is simple, since all mainline users are DT based and
DT API does not change. Out of tree users of the platform data
need to migrate to gpiod_lookup_table as described here:
Documentation/driver-api/gpio/board.rst
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
According to datasheet, BAT_COMP field spans bits 5-7. The rest of the
code seems to assume this already.
Fixes: 4aeae9cb0d ("power_supply: Add support for TI BQ25890 charger chip")
Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Simplify/Cleanup the driver by switching to devm_power_supply_register
and dropping the driver's remove function.
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Simplify/Cleanup the driver by switching to devm_power_supply_register
and dropping the driver's remove function.
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
This is a follow-up patch to the previous one, which fixed a
race-condition during registration of the attribute group.
This fixes the same issue for the binary attributes by adding
them to the properly registered group. As a side effect the
code is further cleaned up.
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
This is a follow-up patch to the previous one, which fixed a
race-condition during registration of the attribute group.
This fixes the same issue for the binary attributes by adding
them to the properly registered group. As a side effect the
code is further cleaned up.
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
This registers custom sysfs properties using the native functionality
of the power-supply framework, which cleans up the code a bit and
fixes a race-condition. Before this patch the sysfs attributes were
not properly registered to udev.
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
This registers custom sysfs properties using the native functionality
of the power-supply framework, which cleans up the code a bit and
fixes a race-condition. Before this patch the sysfs attributes were
not properly registered to udev.
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
This registers custom sysfs properties using the native functionality
of the power-supply framework, which cleans up the code a bit and
fixes a race-condition. Before this patch the sysfs attributes were
not properly registered to udev.
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
This registers custom sysfs properties using the native functionality
of the power-supply framework, which cleans up the code a bit and
fixes a race-condition. Before this patch the sysfs attributes were
not properly registered to udev.
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
This registers custom sysfs properties using the native functionality
of the power-supply framework, which cleans up the code a bit and
fixes a race-condition. Before this patch the sysfs attributes were
not properly registered to udev.
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
This registers custom sysfs properties using the native functionality
of the power-supply framework, which cleans up the code a bit and
fixes a race-condition. Before this patch the sysfs attributes were
not properly registered to udev.
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
This registers custom sysfs properties using the native functionality
of the power-supply framework, which cleans up the code a bit and
fixes a race-condition. Before this patch the sysfs attributes were
not properly registered to udev.
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
This registers custom sysfs properties using the native functionality
of the power-supply framework, which cleans up the code a bit and
fixes a race-condition. Before this patch the sysfs attributes were
not properly registered to udev.
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Add functionality to setup device specific sysfs attributes
in a race condition free manner
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Our charger manager can optimize the battery capacity periodically, so
we can save last battery capacity into registers. Then next system
power-on, we can read the last saved battery capacity as the initial
battery capacity, which can make the battery capacity more accurate.
Signed-off-by: Yuanjiang Yu <yuanjiang.yu@unisoc.com>
Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Add fuel gauge platform suspend and resume interfaces. In suspend state,
we should enable the low voltage and coulomb counter threshold interrupts
to wake up system to calibrate the battery capacity in lower voltage stage.
Signed-off-by: Yuanjiang Yu <yuanjiang.yu@unisoc.com>
Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Add low voltage alarm support to make sure the battery capacity
more accurate in lower voltage stage.
Signed-off-by: Yuanjiang Yu <yuanjiang.yu@unisoc.com>
Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
This patch adds support to read calibration values from the eFuse controller
to calibrate the ADC values corresponding to current and voltage, which can
make the current and voltage data more accurate.
Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Free battery information in case of adding battery OCV tables.
Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Add info->charging validation to avoid repeated charge or discharge
operation.
Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
The USB charger status can be notified before the charger driver registers
the USB phy notifier, so we should check the charger status in probe() in
case we missed the USB charger notification.
Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Since the USB notifier context is atomic, we can not start or stop charging
in atomic context. Thus this patch adds one work to help to charge or
discharge.
Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
The bq24196 is another variant of the bq24190 charger ic.
Its register set is identical to the bq24192 and it even reuses
the same part number (0x5).
Signed-off-by: Heiko Stuebner <heiko.stuebner@bq.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Add extcon support so that we can notify USB drivers of cable state
changes. Based on work from Jonathan Marek. USB OTG was tested on a LG
Nexus 5 (hammerhead) phone.
Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>