summaryrefslogtreecommitdiffstats
path: root/drivers/power/lp8727_charger.c
AgeCommit message (Collapse)Author
2013-06-06lp8727_charger: Support the device tree featureKim, Milo
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>
2013-02-02lp8727_charger: Small cleanup in namingDan Carpenter
"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>
2012-11-28power: remove use of __devexitBill Pemberton
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>
2012-11-28power: remove use of __devexit_pBill Pemberton
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>
2012-09-20lp8727_charger: More pure cosmetic improvementsKim, Milo
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>
2012-09-20lp8727_charger: Fix checkpatch warningKim, Milo
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>
2012-09-20lp8727_charger: Add description in the private dataKim, Milo
Add description and relocate data. Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com> Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
2012-09-20lp8727_charger: Fix a typo - chg_parm to chg_paramKim, Milo
Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com> Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
2012-09-20lp8727_charger: Make some cosmetic changes in lp8727_delayed_func()Kim, Milo
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>
2012-09-20lp8727_charger: Clean up lp8727_charger_changed()Kim, Milo
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>
2012-09-20lp8727_charger: Return if the battery is dischargingKim, Milo
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>
2012-09-20lp8727_charger: Make lp8727_charger_get_propery() simplerKim, Milo
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>
2012-09-20lp8727_charger: Make lp8727_ctrl_switch() inlineKim, Milo
Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com> Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
2012-09-20lp8727_charger: Make lp8727_init_device() shorterKim, Milo
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>
2012-09-20lp8727_charger: Clean up lp8727_is_charger_attached()Kim, Milo
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>
2012-09-20lp8727_charger: Use specific definitionKim, Milo
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>
2012-09-20lp8727_charger: Clean up lp8727 definitionsKim, Milo
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>
2012-09-20lp8727_charger: Use the definition rather than enumKim, Milo
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>
2012-09-20lp8727_charger: Fix code for getting battery tempKim, Milo
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>
2012-09-20lp8727_charger: Clear interrrupts at inital timeKim, Milo
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>
2012-09-20lp8727_charger: Clean up the interrupt handlerKim, Milo
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>
2012-09-20lp8727_charger: Remove unnecessary workqueue threadKim, Milo
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>
2012-09-20lp8727_charger: Add configurable debouce timerKim, Milo
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>
2012-09-20lp8727_charger: Fix buggy code of NULL pdataKim, Milo
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>
2012-09-20lp8727_charger: Cleanup _probe() and _remove()Kim, Milo
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>
2012-09-20lp8727_charger: Use devm_kzalloc()Kim, Milo
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>
2012-09-20lp8727_charger: Use IRQF_ONESHOTFengguang Wu
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>
2012-08-22lp8727_charger: Unregister power supply at error path of lp8727_register_psyDevendra Naga
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>
2012-07-14lp8727_charger: Move header file into platform_data directoryKim, Milo
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>
2012-03-26power_supply: Convert i2c drivers to module_i2c_driverAxel Lin
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>
2012-03-26lp8727_charger: Add MODULE_DEVICE_TABLEAxel Lin
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>
2012-03-26lp8727_charger: Correct typos on the commentKim, Milo
intergrated charger -> integrated charger ^ Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com> Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
2012-03-26lp8727_charger: Fix wrong code styleKim, Milo
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>
2012-03-26lp8727_charger: Change i2c functionsKim, Milo
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>
2012-03-26lp8727_charger: Add error check routine on probe()Kim, Milo
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>
2012-03-26lp8727_charger: Add company name and descriptionKim, Milo
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>
2012-02-01lp8727_charger: Add terminating entry for i2c_device_id tableAxel Lin
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>
2012-01-04lp8727_charger: Coding style changesKim, Milo
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>
2012-01-04lp8727_charger: Add supported i2c functionality check routineKim, Milo
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>
2012-01-04power_supply: Add LP8727 charger driverWoogyom Kim
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>