summaryrefslogtreecommitdiffstats
path: root/drivers/power/lp8727_charger.c
Commit message (Collapse)AuthorAgeFilesLines
* lp8727_charger: Support the device tree featureKim, Milo2013-06-061-0/+68
| | | | | | | | | 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>
* lp8727_charger: Small cleanup in namingDan Carpenter2013-02-021-4/+4
| | | | | | | | | | "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>
* power: remove use of __devexitBill Pemberton2012-11-281-1/+1
| | | | | | | | | | | 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>
* power: remove use of __devexit_pBill Pemberton2012-11-281-1/+1
| | | | | | | | | | | 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>
* lp8727_charger: More pure cosmetic improvementsKim, Milo2012-09-201-1/+2
| | | | | | | 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>
* lp8727_charger: Fix checkpatch warningKim, Milo2012-09-201-2/+1
| | | | | | | 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>
* lp8727_charger: Add description in the private dataKim, Milo2012-09-201-4/+8
| | | | | | | Add description and relocate data. Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com> Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
* lp8727_charger: Fix a typo - chg_parm to chg_paramKim, Milo2012-09-201-8/+8
| | | | | Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com> Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
* lp8727_charger: Make some cosmetic changes in lp8727_delayed_func()Kim, Milo2012-09-201-3/+5
| | | | | | | 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>
* lp8727_charger: Clean up lp8727_charger_changed()Kim, Milo2012-09-201-9/+13
| | | | | | | | 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>
* lp8727_charger: Return if the battery is dischargingKim, Milo2012-09-201-6/+7
| | | | | | | | 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>
* lp8727_charger: Make lp8727_charger_get_propery() simplerKim, Milo2012-09-201-3/+4
| | | | | | | | 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>
* lp8727_charger: Make lp8727_ctrl_switch() inlineKim, Milo2012-09-201-1/+1
| | | | | Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com> Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
* lp8727_charger: Make lp8727_init_device() shorterKim, Milo2012-09-201-5/+1
| | | | | | | 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>
* lp8727_charger: Clean up lp8727_is_charger_attached()Kim, Milo2012-09-201-8/+6
| | | | | | | | 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>
* lp8727_charger: Use specific definitionKim, Milo2012-09-201-3/+6
| | | | | | | | 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>
* lp8727_charger: Clean up lp8727 definitionsKim, Milo2012-09-201-66/+64
| | | | | | | | | 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>
* lp8727_charger: Use the definition rather than enumKim, Milo2012-09-201-11/+5
| | | | | | | | | | | 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>
* lp8727_charger: Fix code for getting battery tempKim, Milo2012-09-201-5/+26
| | | | | | | | | | | | 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>
* lp8727_charger: Clear interrrupts at inital timeKim, Milo2012-09-201-0/+8
| | | | | | | | 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>
* lp8727_charger: Clean up the interrupt handlerKim, Milo2012-09-201-9/+28
| | | | | | | | | | | | | | | | 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>
* lp8727_charger: Remove unnecessary workqueue threadKim, Milo2012-09-201-12/+1
| | | | | | | | | | 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>
* lp8727_charger: Add configurable debouce timerKim, Milo2012-09-201-3/+9
| | | | | | | | | | | | 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>
* lp8727_charger: Fix buggy code of NULL pdataKim, Milo2012-09-201-7/+21
| | | | | | | | | | | | | | 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>
* lp8727_charger: Cleanup _probe() and _remove()Kim, Milo2012-09-201-11/+9
| | | | | | | | | | | | | | | | | | | 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>
* lp8727_charger: Use devm_kzalloc()Kim, Milo2012-09-201-6/+2
| | | | | | | | 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>
* lp8727_charger: Use IRQF_ONESHOTFengguang Wu2012-09-201-1/+1
| | | | | | | | | | | | | 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>
* lp8727_charger: Unregister power supply at error path of lp8727_register_psyDevendra Naga2012-08-221-7/+9
| | | | | | | | | | | | | 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>
* lp8727_charger: Move header file into platform_data directoryKim, Milo2012-07-141-1/+1
| | | | | | | | 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>
* power_supply: Convert i2c drivers to module_i2c_driverAxel Lin2012-03-261-13/+1
| | | | | | | | | | | | | | | 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>
* lp8727_charger: Add MODULE_DEVICE_TABLEAxel Lin2012-03-261-0/+1
| | | | | | | | 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>
* lp8727_charger: Correct typos on the commentKim, Milo2012-03-261-1/+1
| | | | | | | | intergrated charger -> integrated charger ^ Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com> Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
* lp8727_charger: Fix wrong code styleKim, Milo2012-03-261-5/+5
| | | | | | | | | | | | | | 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>
* lp8727_charger: Change i2c functionsKim, Milo2012-03-261-28/+20
| | | | | | | | | | | | | | 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>
* lp8727_charger: Add error check routine on probe()Kim, Milo2012-03-261-18/+39
| | | | | | | | | | | | | | | 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>
* lp8727_charger: Add company name and descriptionKim, Milo2012-03-261-1/+2
| | | | | | | | 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>
* lp8727_charger: Add terminating entry for i2c_device_id tableAxel Lin2012-02-011-0/+1
| | | | | | | | 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>
* lp8727_charger: Coding style changesKim, Milo2012-01-041-25/+25
| | | | | | | | | | | | | | 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>
* lp8727_charger: Add supported i2c functionality check routineKim, Milo2012-01-041-0/+3
| | | | | | | | 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>
* power_supply: Add LP8727 charger driverWoogyom Kim2012-01-041-0/+491
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>
OpenPOWER on IntegriCloud