History log of /drivers/power/lp8727_charger.c
Revision Date Author Comments
17b4565b308ed31fa20b59842c75e685a101dc8a 10-May-2013 Kim, Milo <Milo.Kim@ti.com> lp8727_charger: Support the device tree feature

The interrupt and charging parameters are configurable in the device tree
structure. In the board test, a GPIO is used for handling LP8727
interrupts. The device tree binding documentation is added also.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Anton Vorontsov <anton@enomsg.org>
f96b3074ecfedf74b137dc2cc00dccbf479d2713 25-Jan-2013 Dan Carpenter <dan.carpenter@oracle.com> lp8727_charger: Small cleanup in naming

"pdata" and "pchg->pdata" are the same. Changing the function call to
pdata->get_batt_present() makes it match the check and it's a little
cleaner.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Milo Kim <milo.kim@ti.com>
Signed-off-by: Anton Vorontsov <anton@enomsg.org>
415ec69fb1861fc377c65cb30ddc76999891b8e1 19-Nov-2012 Bill Pemberton <wfp5p@virginia.edu> power: remove use of __devexit

CONFIG_HOTPLUG is going away as an option so __devexit is no
longer needed.

Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
Cc: Anton Vorontsov <cbou@mail.ru>
Cc: David Woodhouse <dwmw2@infradead.org>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
28ea73f4c67cb3dd8c972b21d9fdf84ea78d6daa 19-Nov-2012 Bill Pemberton <wfp5p@virginia.edu> power: remove use of __devexit_p

CONFIG_HOTPLUG is going away as an option so __devexit_p is no longer
needed.

Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
Cc: Anton Vorontsov <cbou@mail.ru>
Cc: David Woodhouse <dwmw2@infradead.org>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
b9633ef1a9cdf4317d8c4a8db977485e2a8e1cb8 31-Aug-2012 Kim, Milo <Milo.Kim@ti.com> lp8727_charger: More pure cosmetic improvements

This is really minor, but it improves the readability.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
18259cac98884522a46c24a73ef8d4879d824607 31-Aug-2012 Kim, Milo <Milo.Kim@ti.com> lp8727_charger: Fix checkpatch warning

Fix the warning on MODULE_AUTHOR.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
1ae9df7d49e964b53f72254b20ab7eb713306396 31-Aug-2012 Kim, Milo <Milo.Kim@ti.com> lp8727_charger: Add description in the private data

Add description and relocate data.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
56d99ed93a52489da3c0f84424489390b6cb0312 31-Aug-2012 Kim, Milo <Milo.Kim@ti.com> lp8727_charger: Fix a typo - chg_parm to chg_param

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
5e00b9761b6e56096da8276a51484e5c53df72c6 31-Aug-2012 Kim, Milo <Milo.Kim@ti.com> lp8727_charger: Make some cosmetic changes in lp8727_delayed_func()

Declare a variable at one line and align lines.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
20414e2e0e10c2152e44784599e6d66fae39d77c 31-Aug-2012 Kim, Milo <Milo.Kim@ti.com> lp8727_charger: Clean up lp8727_charger_changed()

Declare a variable at one line. Just return when no charger exists to make
code simpler.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
e06374b0d6055ef21e49d14d955eb9fc5088f707 31-Aug-2012 Kim, Milo <Milo.Kim@ti.com> lp8727_charger: Return if the battery is discharging

If the charger is pulled out, just return as DISCHARGING. Then no need for
additional 'else' statement.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
b59c93c0090d14556d988607e5bdb297d6e380a7 31-Aug-2012 Kim, Milo <Milo.Kim@ti.com> lp8727_charger: Make lp8727_charger_get_propery() simpler

Charger has only one valid property - ONLINE. If the property is not
ONLINE, then just return quickly.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
91a696330ce4137eef7ad5712c9269a52dc261d4 31-Aug-2012 Kim, Milo <Milo.Kim@ti.com> lp8727_charger: Make lp8727_ctrl_switch() inline

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
70be1305294ad50a45a8f4134152d5d6e79c922e 31-Aug-2012 Kim, Milo <Milo.Kim@ti.com> lp8727_charger: Make lp8727_init_device() shorter

Just return with lp8727_write_byte(), no need to check its value.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
65272bac3a24162b7362eccf9a30a481f2139266 31-Aug-2012 Kim, Milo <Milo.Kim@ti.com> lp8727_charger: Clean up lp8727_is_charger_attached()

Change return type to boolean. Remove unnecessary check routine for NULL
string. (Power supply name is always valid when the function is executed.)

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
18763a36d0bae11a916ffe8fa58a26fd0b5eb115 31-Aug-2012 Kim, Milo <Milo.Kim@ti.com> lp8727_charger: Use specific definition

Add new LP8727_ICHG_SHIFT definition and replace a magic number. Reuse
definition for the size of interrupt register buffer.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
6029719f08d2d21624504e326f50c68f89731353 31-Aug-2012 Kim, Milo <Milo.Kim@ti.com> lp8727_charger: Clean up lp8727 definitions

All definitions should be unique, since they're in the gloabl namespace.
So the prefix LP8727_ are added. Additionally, use BIT() macro for bit
masks. Remove unnecessary definitions such as SW_DM1_U1 and SW_DP2_U2.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
faaae9bbb1f91f8bcd03bd9976620ac08d8b4454 31-Aug-2012 Kim, Milo <Milo.Kim@ti.com> lp8727_charger: Use the definition rather than enum

Enum lp8727_chg_state can be removed because only one charger status is
used - EOC(End Of Charge).

To check whether the EOC is reached or not, use simple comparison rather
than shift-operation.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
b1ad079680b24386d12aa99dd9afd4eb7093bbee 31-Aug-2012 Kim, Milo <Milo.Kim@ti.com> lp8727_charger: Fix code for getting battery temp

For better understanding, use specific function and definitions rather
than magic numbers. New enum type for die temperature is matched with hex
codes. Specific temperature names are better than 0x1, 0x2 and 0x3.

And lp8727_is_high_temperature() function has better readability than
comparing raw register values.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
638555d2769b7dfb8654bae513cff295ea9a3837 31-Aug-2012 Kim, Milo <Milo.Kim@ti.com> lp8727_charger: Clear interrrupts at inital time

To initialize the device, previous interrupts need to be cleared while
loading the driver.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
d71fda01610269e3aaedd451f8d3e34cdf550036 31-Aug-2012 Kim, Milo <Milo.Kim@ti.com> lp8727_charger: Clean up the interrupt handler

For better understanding, function name is changed. (lp8727_intr_config()
is replaced with lp8727_setup_irq().)

The private IRQ number is set when the IRQ is allocated successfully. This
data is used for releasing the IRQ on unloading the driver. Even the IRQ
number is not defined, the driver should be operated. In this case, just
return as 0.

In additional function lp8727_release_irq(), the workqueue is canceled and
the allocated IRQ is released.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
2a0925827be53db6252afadc79c657b14638ff4a 31-Aug-2012 Kim, Milo <Milo.Kim@ti.com> lp8727_charger: Remove unnecessary workqueue thread

LP8727 has two IRQ threads. One is the I2C HW IRQ pin, the other is for
delayed interrupt processing. But this delayed processing can be handled
without additional single thread by using schedule_delayed_work() with
jiffies time value.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
60fd57e06ed7ea13bc0bdf4cb5324d47039105ab 31-Aug-2012 Kim, Milo <Milo.Kim@ti.com> lp8727_charger: Add configurable debouce timer

Debounce time is configurable in the platform side. If it is not defined,
the default value is 270ms.

Platform data is msec unit, and this time is converted to jiffies
internally. The workqueue uses this jiffies time in the interrupt
handling. So debounce_jiffies is added in the private data.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
318cb389d020e3107979d7d794ab992e4bcd6665 31-Aug-2012 Kim, Milo <Milo.Kim@ti.com> lp8727_charger: Fix buggy code of NULL pdata

LP8727 platform data is optional, so the driver should work even the
platform data is NULL.

To check the platform data, charging parameter data should be changed to
the pointer type.

Fix NULL point access problem when getting the battery properties. When
the data is NULL, just return as invalid value.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
fb9adc5190d7605506ebc0e05351baa57365cc90 31-Aug-2012 Kim, Milo <Milo.Kim@ti.com> lp8727_charger: Cleanup _probe() and _remove()

If the lp8727_register_psy() gets failed, registered interrupt handler
should be freed, but this is not complete solution. It has still problem.
Assume that the IRQ occurs while unregistering power supply devices. Then
the ISR will access to freed IRQ.

From Anton's opinion, it can be resolved if re-ordering the call sequence.

Register power supplies first, then create interrupt handler. Then no need
to free the IRQ in _probe(). Additionally goto statements can be removed
because those can be replaced with return statements.

The _remove() should be changed the sequence - in reverse order of
_probe()

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
74727c571517692ae24d0562676f2c61a86b9090 31-Aug-2012 Kim, Milo <Milo.Kim@ti.com> lp8727_charger: Use devm_kzalloc()

Use devm_kzalloc() rather than kzalloc()/kfree() to make
allocating/freeing the private data simpler.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
7c577c0d1ebed58648afb26e7c03f023fa82098e 23-Aug-2012 Fengguang Wu <fengguang.wu@intel.com> lp8727_charger: Use IRQF_ONESHOT

Generated by: scripts/coccinelle/misc/irqf_oneshot.cocci

ERROR: Threaded IRQ with no primary handler requested without IRQF_ONESHOT

Make sure threaded IRQs without a primary handler are always request
with IRQF_ONESHOT

Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
Acked-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
6297b5e54b5511d4e72e8d5fc3b139650adc74d8 29-Jul-2012 Devendra Naga <develkernel412222@gmail.com> lp8727_charger: Unregister power supply at error path of lp8727_register_psy

if usb power supply registration fails,
we wont unregister the ac power supply
if battery power supply registration fails,
we wont unregister the usb, and ac supply,

take care of those things and also no need of goto -err_mem: at the fail case of
kzalloc simply can have return -ENOMEM

Signed-off-by: Devendra Naga <develkernel412222@gmail.com>
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
1aebb0973160570e1df4c95c2e43a60993f71087 03-Jul-2012 Kim, Milo <Milo.Kim@ti.com> lp8727_charger: Move header file into platform_data directory

The lp8727 header can be used only in the platform side, so it can be
moved to the platform_data directory.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
5ff92e7ab3591299089cfba440acb4d2ba8ab92f 21-Jan-2012 Axel Lin <axel.lin@gmail.com> power_supply: Convert i2c drivers to module_i2c_driver

Factor out some boilerplate code for i2c driver registration
into module_i2c_driver.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Cc: Woogyom Kim <milo.kim@ti.com>
Cc: Daniel Jeong <daniel.jeong@ti.com>
Cc: Minkyu Kang <mk7.kang@samsung.com>
Cc: Peter Edwards <sweetlilmre@gmail.com>
Acked-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Acked-by: Rhyland Klein <rklein@nvidia.com>
Acked-by: Ryan Mallon <rmallon@gmail.com>
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
e2c5f7db789a5be8ba131e9fe3e87b66bc606e3b 12-Jan-2012 Axel Lin <axel.lin@gmail.com> lp8727_charger: Add MODULE_DEVICE_TABLE

Add MODULE_DEVICE_TABLE to setup modalias for lp8727. Allows auto
modprobing.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
f7bae49aa1247a195a3fe4235edf6811c175bb7b 27-Jan-2012 Kim, Milo <Milo.Kim@ti.com> lp8727_charger: Correct typos on the comment

intergrated charger -> integrated charger
^

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
7336880e3d73ee38b0c2bb99674e7e79d87dd43e 27-Jan-2012 Kim, Milo <Milo.Kim@ti.com> lp8727_charger: Fix wrong code style

Definition of STATUS2
: remove space before tabs.

Return code of lp8727_is_dedicated_charger(), lp8727_is_usb_charger()
: remove parentheses when return is not a function.

MODULE_AUTHOR section
: remove space at the start of a line.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
27aefa3b7d8b1c37e0bc21cbd0ce3c93bdf163ca 27-Jan-2012 Kim, Milo <Milo.Kim@ti.com> lp8727_charger: Change i2c functions

On writing single byte via i2c, use i2c_smbus_write_byte_data()
rather than i2c_smbus_write_i2c_block_data().

Name changes :
lp8727_i2c_read() -> lp8727_read_bytes()
lp8727_i2c_write() -> removed
lp8727_i2c_read_byte() -> lp8727_read_byte()
lp8727_i2c_write_byte() -> lp8727_write_byte()

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
7da6334e73fe3c0579d8c6a56001336a430a5d99 27-Jan-2012 Kim, Milo <Milo.Kim@ti.com> lp8727_charger: Add error check routine on probe()

Add error checking on initializing registers and interrupt handler.

Initializing registers - lp8727_init_device()
: check i2c error during probing the driver.

Initializing interrupt handler - lp8727_intr_config()
: check an error on creating the irq thread.

If an error occurs on probing lp8727 driver, allocated lp8727 driver memory is freed.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
e39b828f5355e41a8fd24f413fb9dfb81d808397 30-Jan-2012 Kim, Milo <Milo.Kim@ti.com> lp8727_charger: Add company name and description

Add 'Texas Instruments' because TI acquired National semiconductor at 2011.
And the driver information is added in the header file.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
455a0e2cd80f7a2849b2e6d3be85c053ee44446b 16-Jan-2012 Axel Lin <axel.lin@gmail.com> lp8727_charger: Add terminating entry for i2c_device_id table

The i2c_device_id table is supposed to be zero-terminated.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Acked-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
ce09affc59bca2a1ac1f77b75915fd914fab1f70 04-Jan-2012 Kim, Milo <Milo.Kim@ti.com> lp8727_charger: Coding style changes

1. Useless braces were omitted
2. Useless void casts were omitted
3. module exit name changed
lp8727_chg_exit -> lp8727_exit
4. Pointer coding style changes
no space between pointer('*') and pointer name
ex) u8 * data -> u8 *data
5. Author information change : email and additional author

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
998a8e7a72f6a81f540d3a3774d8e8aae6c7f9f2 18-Nov-2011 Kim, Milo <Milo.Kim@ti.com> lp8727_charger: Add supported i2c functionality check routine

lp8727 i2c r/w functions are based on SMBUS I2C BLOCK. So the driver needs to
check whether i2c bus supports this functionality or not.

Signed-off-by: Woogyom Kim <milo.kim@ti.com>
Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
2165c8a45bf2fba49f54fb81a50914f883bd14df 04-Jan-2012 Woogyom Kim <milo.kim@nsc.com> power_supply: Add LP8727 charger driver

National Semiconductor LP8727 is the battery charger with Micro/Mini
USB interface. This IC includes below functions:

- I2C interface for accessing user registers
- Single input Li-Ion battery charger
- Charger input ID detection from Micro/Mini USB
- Multiplexing switches on USB, UART

Signed-off-by: Woogyom Kim <milo.kim@ti.com>
Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>