| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
| |
Change-Id: Ied641d29a7258a069811e51383cdbf7be06bc0e7
|
|
|
|
|
|
|
|
|
| |
Change-Id: I3e93b502452811cbfc4d904202b4f1d94edc143d
Signed-off-by: Todd Poynor <toddpoynor@google.com>
Conflicts:
drivers/power/power_supply_sysfs.c
include/linux/power_supply.h
|
|
|
|
| |
Change-Id: I7a05757b875bbab57f043d0afa364d475df7771d
|
| |
|
|
|
|
|
|
|
|
|
|
| |
FG module takes voltage, current and coulomb counter
readings from the PMIC, executes fuel gauging algorithms,
and outputs estimated battery state of charge to the
sysfs interface.
Change-Id: I182acbdb0bb69380a7452c1b3a99f198031fdf64
Signed-off-by: Max Herman <mherman@fsisys.com>
|
|
|
|
|
|
|
|
| |
Change-Id: I7564fb0c3eb617c1beba2dc0162db25b5799a8e5
Signed-off-by: Max Herman <mherman@fsisys.com>
Conflicts:
drivers/power/twl6030_bci_battery.c
|
|
|
|
|
|
|
|
|
|
|
| |
TWL6032 has 12-bit ADC, TWL6030 has 10-bit ADC, battery temperature
table is calculated for the TWL6030. So battery temperature measured
correctly only for OMAP4430 and OMAP4460. Patch rejects two lower
bits of ADC channel for TWL6032 and temperature measured correctly
for all OMAP controllers.
Change-Id: I88b6f2e6fbde11fa05642d1772c797b61b2fd1ce
Signed-off-by: Oleksandr Dmytryshyn <oleksandr.dmytryshyn@ti.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Battery driver reads ADC channel 1 to wich NTC resistor
is connected to detect battery temperature.
There is a table that matches ADC value to temperature.
The driver, for looking corresponding temperature uses
ADC value converted to millivolts, instead of ADC value,
which is incorrect.
Use ADC value for temperature conversion.
Change-Id: I25812a4f3d94ce971475546145803513e346dd9a
Signed-off-by: Oleksandr Kozaruk <oleksandr.kozaruk@ti.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Previously temperature of the battery was refreshed only if adc ch1 value
was in range from 100 to 950. Now the temperature of the battery measured
correctly. If the temperature is less then -2 degrees Celsius then
-2 degrees Celsius returned and if the temperature is more then +62 degrees
Celsius then +62 degrees Celsius returned.
Change-Id: I8f91b88e76fc3c00e0d7a22267de16f096584e13
Signed-off-by: Oleksandr Dmytryshyn <oleksandr.dmytryshyn@ti.com>
Conflicts:
drivers/power/twl6030_bci_battery.c
|
|
|
|
|
|
|
|
|
| |
If platform data does not pass down the nominal battery capacity,
then assume a sane default value.
Change-Id: Icba698fb0d2f14cc778740734ed8f2c573e67f0d
Signed-off-by: Sivakumar Pothireddy <sivakumar.pothireddy@ti.com>
Signed-off-by: Anand Gadiyar <gadiyar@ti.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Pass the nominal battery capacity from the board file instead of
hardcoding it in the driver.
TODO: This needs to be done for the blaze as well, although it's
rarely run off the battery
Change-Id: I15cba65f062c70f3b1e26f3c03db59e3af0d6ea9
Signed-off-by: Sivakumar Pothireddy <sivakumar.pothireddy@ti.com>
Signed-off-by: Anand Gadiyar <gadiyar@ti.com>
Conflicts:
arch/arm/mach-omap2/board-44xx-power.c
|
|
|
|
|
|
|
|
|
|
|
| |
We now update capacity estimates using the gas gauge. No need to
schedule voltage-based estimates except when voltage is critically low.
(This reconciliation based on voltages will be done in a later patch).
So remove this code.
Change-Id: I46706c954e32667a84a4e64c9a0831a706755da8
Signed-off-by: Sivakumar Pothireddy <sivakumar.pothireddy@ti.com>
Signed-off-by: Anand Gadiyar <gadiyar@ti.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Use the gas gauge in twl6030 to estimate the remaining battery
capacity.
At bootup, we use an estimate of initial capacity using the measured
battery voltage at bootup. From that point on, all future battery
capacity estimations are done by using the gas gauge to measure
all addition/removal of charge from the battery.
Clamp battery value to 99% if the measured value exceeds 99%.
A later patch will add the code to update the initial estimate
once the battery is fully charged.
TODO: Minimum safe battery voltage reporting needs to be worked on
Change-Id: Iab157b559f9de432a93664e8d78c003af3c75b67
Signed-off-by: Sivakumar Pothireddy <sivakumar.pothireddy@ti.com>
Signed-off-by: Anand Gadiyar <gadiyar@ti.com>
|
|
|
|
|
|
|
|
|
| |
Otherwise previous register values (from bootloader, or warm reboot)
will distort our calculations.
Change-Id: I302eb3f05cacdc9136c937556dd5a9d5d8baf4d4
Signed-off-by: Sivakumar Pothireddy <sivakumar.pothireddy@ti.com>
Signed-off-by: Anand Gadiyar <gadiyar@ti.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Add a lookup table for estimating battery capacity at bootup
using the battery voltage measrued at that time.
The table was constructed using actual measured values for Blaze
Tablets. The values don't correspond to the arbitrary values currently
used in the driver.
This table is something that a board file should pass to the
driver. This will be introduced in a later patch - for now, we
keep the values in the driver just like the current design.
Change-Id: I78b35b68c7a41b67d67925dae8015405efb44b0d
Signed-off-by: Sivakumar Pothireddy <sivakumar.pothireddy@ti.com>
Signed-off-by: Anand Gadiyar <gadiyar@ti.com>
|
|
|
|
|
|
|
|
|
| |
We need the gas gauge to continue measuring power drain in suspend.
Keep it always enabled.
Change-Id: I5b6dd4d8f63e3269dacf8d8dfb814670bfa8937a
Signed-off-by: Sivakumar Pothireddy <sivakumar.pothireddy@ti.com>
Signed-off-by: Anand Gadiyar <gadiyar@ti.com>
|
|
|
|
|
|
|
|
|
|
|
| |
Capacity could be detected when it is not charging.
If charge status set to POWER_SUPPLY_STATUS_NOT_CHARGING
capacity detection path is omitted.
Add this state to let capacity detection happen.
Change-Id: I34a8295470457423d25cc2ec42e2498682339dcc
Signed-off-by: Oleksandr Kozaruk <oleksandr.kozaruk@ti.com>
|
|
|
|
|
|
|
|
| |
Lets gpacd module will be detect the twl6030 or twl6032 chip and
use appropriate software conversion method.
Change-Id: I2eac6e0b9e97b37e13cfa2bfbc9a0956fc68d1a9
Signed-off-by: Oleksandr Dmytryshyn <oleksandr.dmytryshyn@ti.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This errata affects only TWL6030 ES2.1. Each time a charge is
enabled via SW, a THMREG interrupt triggers (Internal USB charger
fault interrupt line).
Workaround: Interrupt (the bit #1 of CHARGERUSB_INT_MASK) has to be
masked before enabling the charge, and unmasked after charge is
enabled.
Change-Id: I14074e384a863c82ba61af9ea9434afe75cc2bc8
Signed-off-by: Oleksandr Dmytryshyn <oleksandr.dmytryshyn@ti.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This errata affects only TWL6030 ES2.1. The usage of the CIN_LIMIT
codes above 600mA (CHARGERUSB_CINLIMIT Register, codes
650mA/700mA/750mA) may lead to an unlimited input current in
case VBUS < 4.1V.
Workaround: The anti-collapse feature needs to be enabled before
usage of the CIN_LIMIT. All CIN_LIMIT codes will be functional at
all anti-collapse levels.
Change-Id: I4fc0eb64cc96b692f4761a27098df307e1f5cd54
Signed-off-by: Oleksandr Dmytryshyn <oleksandr.dmytryshyn@ti.com>
|
|
|
|
|
|
|
|
|
|
|
| |
The logic in the autogate function was causing a storm of events causing
I2C transactions as fast as the bus could run. Add an extra check in
the if statement and correctly set the charger source to stop this
happening. This stops the monitor function being scheduled thousands
of times when USB cable is inserted.
Change-Id: Ib783b684c3b3913e2afb9aa6fd607683c9d555ec
Signed-off-by: Graeme Gregory <gg@slimlogic.co.uk>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In Active state the omap does not update the CHRG_DET_N signal so to
change the current limits based on the information of USB stack in
HW mode the CINLIMIT register needs to be written. This does not
take the charger out of HW mode.
Because the new logic started to make start fuction messy I have split
into seperate hw/sw start functions.
Change-Id: I647d2934a9b8e39e0d00049444c79ca196e8820b
Signed-off-by: Graeme Gregory <gg@slimlogic.co.uk>
|
|
|
|
|
|
|
|
|
|
| |
In use_hw_charger mode the charger should not be started or stopped
by disabling/enabled the DCDC/Linear charger. It should rather be
paused by setting HZ_MODE. This prevents the charger switching from
HW to SW mode.
Change-Id: I521b094a0fa4835466142219f1a1eef1ef4578b1
Signed-off-by: Graeme Gregory <gg@slimlogic.co.uk>
|
|
|
|
|
|
|
|
|
| |
Now that hardware charging mode has seperate IRQs remove the hardware
mode handling from the software mode IRQs as it is not required here
anymore.
Change-Id: Ib2cd7ae43157014b9111a5bdd5da36e1caeb6602
Signed-off-by: Graeme Gregory <gg@slimlogic.co.uk>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Correct the current reading functions for current_now and current_avg.
This was done with advice on the correct algorithm from the design team
and application engineers.
Also by default twl6030 and twl6032 use different sense resistors and
according to design team these resistors may be tuned for certain boards.
So allow the resistor value to be passed as platform data but select
sensible defaults if it is not.
Change-Id: Ib60742ec5779708d7156a4c6b4acd16b84cc8f0c
Signed-off-by: Graeme Gregory <gg@slimlogic.co.uk>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
For the twl6032 read the charger mode and power path usage from a register
on the chip.
Because of this change these parameters no longer need to be provided by
platform data so move these variable to the private structure.
This change also means that these variables being set also implies
twl6032 is the chip type so simplify the code by removing checks
for this from features at each usage of one of these variables.
Change-Id: If371db6270e40edf2ee315696300cf29bd9e8ea8
Signed-off-by: Graeme Gregory <gg@slimlogic.co.uk>
|
|
|
|
|
|
|
|
| |
In all sensible use cases use_eeprom_config and use_hw_charger are
actually synonymous so simplify the code and remove the use_eeprom_config.
Change-Id: Ibf473ea8106a72038f646e9163665caa91de9e06
Signed-off-by: Graeme Gregory <gg@slimlogic.co.uk>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Counter was used for capacity debounce, that counted
how many times capacity was different from currently
reported to the kernel.
Make debounce procedure more aggressive, count how many
times capacity stays the _same_ after it changed, not
just different. If it is the same after N times,
update it.
Change-Id: Iece0f9afe58007c14ad787051280f8ba0337f3bb
Signed-off-by: Oleksandr Kozaruk <oleksandr.kozaruk@ti.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When probe is called battery capacity is set to 100%.
If battery is charging, capacity will be updated after
10 minutes. If real capacity is 5% it will suddenly
jump from 100% to 5% (after 40 seconds), when power
source is removed.
Update capacity immediately when battery monitor work
started. Use legacy linux time_after() API for coping
with time intervals.
Change-Id: Ib3e7d5b8ccd95d19cf92acb2c87de8858b66d0ef
Signed-off-by: Oleksandr Kozaruk <oleksandr.kozaruk@ti.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
There were two different ways of battery detection: one for
TWL6030 and second for TWL6032. ADC returned resistance for
TWL6030 but voltage for TWL6032 (channel 0). The threshold 5000
in function is_battery_present() was not correct for TWL6032. But
threshold was used for both ways of battery detection and we
couldn't change it.
The next changes were implemented:
ADC returns voltage from channel 0 for TWL6030.
The same way of battery detection was implemented for TWL6030
and TWL6032.
Threshold was changed.
Change-Id: I30a5282c95947edb06a33388d195fc4d17fbd96c
Signed-off-by: Sergii Postulga <x0153364@ti.com>
Signed-off-by: Eugen Mandrenko <ievgen.mandrenko@ti.com>
|
|
|
|
|
|
|
|
|
|
| |
This functionality is needed for battery detection logic.
GPADC driver for TWL6030 return resistance of battery
detection sensor, but for TWL6032 - voltage. It should be
converted to resistance value before using.
Change-Id: Ic721aa36ef119c23bc3e79c79d145970aac13418
Signed-off-by: Sergii Postulga <x0153364@ti.com>
|
|
|
|
|
|
|
|
|
|
| |
When channels for GPADC read was selected, by mistake
battery channel 7 for twl6030 was omitted. That lead
to incorrect battery voltage readings and battery
capacity indication.
Change-Id: I84e0b04ef10d7e5aafd5bd376438f8fdae1fd37b
Signed-off-by: Oleksandr Kozaruk <oleksandr.kozaruk@ti.com>
|
|
|
|
|
|
|
|
|
|
| |
Battery voltage was reported at boot message before
actual measurement was made having some random value.
Measure battery voltage before reporting.
Change-Id: I0ffc6aa6fca8d1c9c86d61620fd14c3d7a36faab
Signed-off-by: Oleksandr Kozaruk <oleksandr.kozaruk@ti.com>
|
|
|
|
|
|
|
|
|
|
|
| |
Initial capacity is set to 100% in probe, which does not reflect
real capacity.
Set initial capacity value to -1, so when battery work starts
it will update actual capacity.
Change-Id: I8dd97b57921d4d14827d1164760327cf83690877
Signed-off-by: Oleksandr Kozaruk <oleksandr.kozaruk@ti.com>
|
|
|
|
|
|
|
|
| |
Removed state from state machine that was preventing the processing
of VAC insert events.
Change-Id: I6f9f24bbd787c84bc5ea2f44edcbd4b1bef261bd
Signed-off-by: Graeme Gregory <gg@slimlogic.co.uk>
|
|
|
|
|
|
|
|
|
| |
Due to code being re-organised the code to set the charge_status
to POWER_SUPPLY_STATUS_CHARGING is missing. This was leading to the
watchdog not being kicked and charging effectively disabled.
Change-Id: If7c401e1dbe01c52e7557571c9bf48fa6da94274
Signed-off-by: Graeme Gregory <gg@slimlogic.co.uk>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
For some reason some versions of the CSL compiler mis-compile the code
in twl6030_start_usb_charger. Re-order the code to make compiler
happier. In original the compiler ends up generating code which sends
a zero to the write function in all cases. Assigning to a variable
and using the new form the correct value gets written. The new version
is also easier to read. This issue was reported by a customer
and seen locally.
The conditional was also wrong, the correct conditional is use_power_path
not just the fact this is TWL6032.
Change-Id: I175335eec8df4f9fb9660ce0430441c5737d8e07
Signed-off-by: Graeme Gregory <gg@slimlogic.co.uk>
|
|
|
|
|
|
|
|
| |
Previously the measured temperature was returned in tenths of
degree Celsius. Now it returned in degrees Celsius.
Change-Id: Ic7cb46d49f32e728a23c685d78d44d7453a39739
Signed-off-by: Oleksandr Dmytryshyn <oleksandr.dmytryshyn@ti.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This patch adds ability to set VBUS limit (via sysfs node).
If VBUS below this limit, device stops charging from USB
(and start charging if device VBUS is above this limit).
New sysfs node has been added:
/sys/bus/platform/devices/twl6030_bci/vbus_charge_thres
This node holds VBUS limit value in mV.
Writing to this file cause setting vbus_charge_thres field in
twl6030_bci_device_info structure.
Main work is done by twl6030_usb_autogate_charger() function,
which reads GPADC channel 10 value (VBUS voltage), compare it
with limit value and tunrns on/off USB charger.
This function is called from twl6030_bci_battery_work()
function (also known as twl6030_bci_monitor_work workqueue).
There is also additional check in twl6030_start_usb_charger()
function, to prevent charging from low voltage USB source.
Change-Id: I5b9fb557cf60d69588f8d1234cffb606f185e207
Signed-off-by: Mykola Oleksiienko <x0174904@ti.com>
|
|
|
|
|
|
|
|
|
| |
As HW/Auto mode for the charger just wants to read status and convert
this to power supply class statuses. It is easier and cleaner to seperate
the handling of HW mode into seperate IRQ handlers.
Change-Id: Ic80fa0ff6b77a77e8c10b63027876bb8f613e0f8
Signed-off-by: Graeme Gregory <gg@slimlogic.co.uk>
|
|
|
|
|
|
|
|
|
| |
Change the method to detect the charging state on boot. The
_STS bits used previously did not contain the complete charging
state so in some situations state was incorrectly indicated.
Change-Id: I6e276765d36f41df263ef5588aef4c792c8cbb7e
Signed-off-by: Graeme Gregory <gg@slimlogic.co.uk>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Works were scheduled in the middle of the probe function,
before initialization of all struct twl6030_bci_device_info
data members, and twl6030/twl6032 was completed.
It was possible that work started before probe completed,
and uninitialized data was accessed.
Defer works till the end of the probe.
Change-Id: Ie930346669b478c9c5dd837f2f655e2b430fd557
Signed-off-by: Oleksandr Kozaruk <oleksandr.kozaruk@ti.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The TWL6030 battery works have to be canceled synchronously
before continue suspending, because of:
- they may sleep while accessing to I2C bus and, as result, WFI may be
reached in the middle of its execution and that may prevent system
from entering to OFF state.
- the device suspend handler may switch TWL6030 device to sleep
state while their works are still active.
Change-Id: Ie3ef579e05bded049e39f9186acb01b116283c87
Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
|
|
|
|
|
|
|
|
|
|
|
|
| |
TWL6030 driver registers two battery type devices,
but there is no way to mark one battery as main for Android.
So Android may use backup battery attibutes instead of main battery.
To workaround this issue /sys/class/power_supply/ should have only one
Battery type device with battery attributes.
Change-Id: I63df13f9847eeeaf8b4efd2fbe2558030caea7c8
Signed-off-by: Taras Kondratiuk <taras@ti.com>
|
|
|
|
|
|
|
|
|
|
| |
Residual voltage may be present on VBUS when USB cable is unplugged.
Workaround: Increase the VBUS anticollapse loop threshold to 4.44 V.
This errata affects only TWL6032 ES1.1
Change-Id: I7533fa7e3caa98e9e326f0c30cfb31d813303be8
Signed-off-by: Oleksandr Dmytryshyn <oleksandr.dmytryshyn@ti.com>
|
|
|
|
|
|
|
|
| |
This patch adds for the kernel code ability to the errata
implementation for the TWL6030/TWL6032 chips.
Change-Id: Ieb2329ec3cf1e0300decc2908fba28aa471854e5
Signed-off-by: Oleksandr Dmytryshyn <oleksandr.dmytryshyn@ti.com>
|
|
|
|
|
|
|
|
| |
This patch allow to initialize charger parameters from
values stored in TWL EEPROM.
Change-Id: Iaa1fd4337d7df4922983c38838248e6f15e9c5a8
Signed-off-by: Volodymyr Riazantsev <v.riazantsev@ti.com>
|
|
|
|
|
|
|
|
|
|
| |
The TWL6032 supports two different mode of operation for its
charger. One is very similar to twl6030 with only a couple of tweaks.
The other the charger control is moved to hardware and the driver
becomes just a monitor for hardware state.
Change-Id: I5920c3b042017da5ae8a72a0bb12854e2f7c342e
Signed-off-by: Volodymyr Riazantsev <v.riazantsev@ti.com>
|
|
|
|
|
|
|
|
| |
This patch added handling for charger watchdog during
battery charging process.
Change-Id: Ica69bbf56159501ac14b341b42e39ba066271a81
Signed-off-by: Volodymyr Riazantsev <v.riazantsev@ti.com>
|
|
|
|
|
|
|
|
|
| |
This patch corrects the uV/mV confusion in the driver. All
values are stored in mV and returned to userspace in uV to
maintain alignment with the regulator framework voltages.
Change-Id: Id3ebccfb5a83b2f28e4f0795107921efb5cca4a1
Signed-off-by: Volodymyr Riazantsev <v.riazantsev@ti.com>
|