| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
| |
After GPADC conversion is started, we wait for finish it with
a busy flag polling in twl6030_gpadc_wait_conversion_ready().
Actually the GPADC busy loop finishes immediately, but for the
worst case condition the sleep is added.
modified: drivers/mfd/twl6030-gpadc.c
Change-Id: If20a9bfe6943814bcce98e591fd876d66f986e44
Signed-off-by: x0169938 <vasyl.yushchyshen@ti.com>
|
|
|
|
|
|
|
|
|
| |
In case we want to use software gpadc conversion with sample type
TWL6030_GPADC_IRQ_ONESHOT, maximum one adc channel can be converted
at a time due to the hardware restrictions of the twl6032.
Change-Id: Iacc4a56eea7a06528513cbc93b2c40feef290ea7
Signed-off-by: Oleksandr Dmytryshyn <oleksandr.dmytryshyn@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>
|
|
|
|
|
|
|
|
|
|
|
| |
Previously was not possible to read the corrected and converted values
of the gpadc conversion in the call back function. Now pointer
to the twl6030_gpadc_request returned to the call back function
and we can read all adc channel values: raw without correction
and convertation, corrected and converted, raw values etc.
Change-Id: I4a3699952ddf9cacc4cca5e205b93e28502f291d
Signed-off-by: Oleksandr Dmytryshyn <oleksandr.dmytryshyn@ti.com>
|
|
|
|
|
|
|
|
| |
This patch adds a possibility to read corrected and converted ADC
ch (command TWL6030_GPADC_IOCX_ADC_READ) to the ioctl.
Change-Id: Ia896bf9224a876083815aa5a0d172e08b77141cb
Signed-off-by: Oleksandr Dmytryshyn <oleksandr.dmytryshyn@ti.com>
|
|
|
|
|
|
|
|
|
| |
Function twl6030_gpadc_ioctl returns calibrated and corrected adc ch
values instead raw code values (command TWL6030_GPADC_IOCX_ADC_RAW_READ).
This patch fixes it.
Change-Id: I2709e378b764ee1f8c2786ed5fec5741d440c9e6
Signed-off-by: Oleksandr Dmytryshyn <oleksandr.dmytryshyn@ti.com>
|
|
|
|
|
|
|
| |
This patch adds raw code ADC inputs values to the sysfs.
Change-Id: I498a2171a2a08abc157b929cec3a5c5ad398a4df
Signed-off-by: Oleksandr Dmytryshyn <oleksandr.dmytryshyn@ti.com>
|
|
|
|
|
|
|
|
|
|
|
| |
Function twl6030_gpadc_read_channels reads raw_code and
raw_channel_value correctly for the TWL6030. For the TWL6032
raw_code was not updated and raw_channel_value was with
raw_code channel value. Now function twl6030_gpadc_read_channels
works correctly for both chips.
Change-Id: I689a5095e33878a99d6970aec08cad3b21aa222f
Signed-off-by: Oleksandr Dmytryshyn <oleksandr.dmytryshyn@ti.com>
|
|
|
|
|
|
|
|
|
| |
For the twl6032 was no possible to read channels 17 and 18 because
for the twl6032 channel number was compared with TWL6030_GPADC_MAX_CHANNELS.
This patch fix it.
Change-Id: Ie3b96586d58d8938b6e46649735cb26fa43540cb
Signed-off-by: Oleksandr Dmytryshyn <oleksandr.dmytryshyn@ti.com>
|
|
|
|
|
|
|
|
|
|
|
|
| |
For converting data from GPADC incorrect coefficients where used
for some channels.
All channels except 0 return millivolts, which is confusing. Make
it uniform, so, all channels return millivolts.
For channel 0 further conversion should be done in place.
Change-Id: I8b9db495ab9b9c7f18a4906306c20e0d777f292d
Signed-off-by: Oleksandr Kozaruk <oleksandr.kozaruk@ti.com>
|
|
|
|
|
|
|
|
|
|
| |
Sample type of the conversion was not set in the ioctl function
and it was with random value. As result - many attempts to start
GPADC conversion via ioctl function were ended with the EINVAL
error. This patch fixes it.
Change-Id: Id8dc13f9cb7f8b828bc6f74bcac4a47b269bb83c
Signed-off-by: Oleksandr Dmytryshyn <oleksandr.dmytryshyn@ti.com>
|
|
|
|
|
|
|
|
| |
This patch corrects GPADC calibration for the TWL6032 due to the
TWL6032 data manual.
Change-Id: I15fb4148bf94a5123467e8b7a316e7edcdb55ebc
Signed-off-by: Oleksandr Dmytryshyn <oleksandr.dmytryshyn@ti.com>
|
|
|
|
|
|
|
|
|
| |
In the latest iteration of the data sheet the TRIM information was
changed from 2s complement to magnitude + sign. And the codes for
channel 10 were updated. Update code to reflect this change.
Change-Id: Ibaa3cbbe2241e1ce844e1249f0ab6389a1ed9b93
Signed-off-by: Graeme Gregory <gg@slimlogic.co.uk>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When scheduler preempts just started GPADC conversion,
the timeout appears because a time is exhausted
but actual status register value is not updated yet.
Simple scenario:
1. GPADC convertion is started before this function starts to run.
2. reg = twl6030_gpadc_read(gpadc, status_reg);
3. if (!(reg & TWL6030_GPADC_BUSY) && (reg & TWL6030_GPADC_EOC_SW))
return 0;
GPADC is not yet ready, so function does not return.
4. This moment the context is switched to another thread(s)
----------------------------------------------------------------------->
5. thread(s) work(s) for timeout_ms or more time.
GPADC convertion is finished.
6. <-----------------------------------------------------------------------
The context is switched back.
7. } while (!time_after(jiffies, timeout))
Next cycle pass does not start, even if GPADC is yet ready.
8. The Timeout Error is returned.
Additional GPADC status register reading is added for such cases.
modified: drivers/mfd/twl6030-gpadc.c
Change-Id: I94b61bb8318c6a03972ad057ab3fd026d1b4c13f
Signed-off-by: x0169938 <vasyl.yushchyshen@ti.com>
|
|
|
|
|
|
|
| |
This patch adds interrupt mapping table for the twl6032.
Change-Id: Iee641e3fbbbc6506e28ac5bab66313686fcb7606
Signed-off-by: Oleksandr Dmytryshyn <oleksandr.dmytryshyn@ti.com>
|
|
|
|
|
|
|
|
| |
There was an typo in the regulator registration in the twl-core.c.
This patch corrects it.
Change-Id: Iea35b635806281ebc7473181d62c828e3e7a586c
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 chip has a different but similar GPADC. The resolution
has been increased to 12bits and there are more channels. The method
correction values are stored in EPROM is also changed.
Change-Id: Iec060638ebecab50fb6562b0fae592f807554a42
Signed-off-by: Graeme Gregory <gg@slimlogic.co.uk>
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>
|
|
|
|
|
|
|
|
| |
Some code cleanup was made.
Functionality didn't changed.
Change-Id: I57b5f629869dd1e59c30fa7245639347fa858cdc
Signed-off-by: Volodymyr Riazantsev <v.riazantsev@ti.com>
|