diff options
author | Marcin Niestroj <m.niestroj@grinn-global.com> | 2016-06-20 12:50:54 +0200 |
---|---|---|
committer | Sebastian Reichel <sre@kernel.org> | 2016-08-15 21:25:02 +0200 |
commit | 47d7d5ed68d877269003a392b7008905d65650bb (patch) | |
tree | 8bdf1dcd6fad7fa52cf20029ffb7c9ddfbbbd1a6 /drivers/power | |
parent | f3332532463fef7d56507c08b33993db398d7a91 (diff) | |
download | linux-47d7d5ed68d877269003a392b7008905d65650bb.tar.bz2 |
power_supply: tps65217-charger: Add support for IRQs
Make use of IRQ resources defined in tps65217 mfd code. If they are valid
we use them instead separate poll task, in order to define AC power state.
Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
Diffstat (limited to 'drivers/power')
-rw-r--r-- | drivers/power/supply/tps65217_charger.c | 40 |
1 files changed, 33 insertions, 7 deletions
diff --git a/drivers/power/supply/tps65217_charger.c b/drivers/power/supply/tps65217_charger.c index 73dfae41def8..c8c4a0c1dca5 100644 --- a/drivers/power/supply/tps65217_charger.c +++ b/drivers/power/supply/tps65217_charger.c @@ -46,6 +46,8 @@ struct tps65217_charger { int prev_ac_online; struct task_struct *poll_task; + + int irq; }; static enum power_supply_property tps65217_ac_props[] = { @@ -198,6 +200,7 @@ static int tps65217_charger_probe(struct platform_device *pdev) struct tps65217 *tps = dev_get_drvdata(pdev->dev.parent); struct tps65217_charger *charger; struct power_supply_config cfg = {}; + int irq; int ret; dev_dbg(&pdev->dev, "%s\n", __func__); @@ -220,18 +223,40 @@ static int tps65217_charger_probe(struct platform_device *pdev) return PTR_ERR(charger->ac); } + irq = platform_get_irq_byname(pdev, "AC"); + if (irq < 0) + irq = -ENXIO; + charger->irq = irq; + ret = tps65217_config_charger(charger); if (ret < 0) { dev_err(charger->dev, "charger config failed, err %d\n", ret); return ret; } - charger->poll_task = kthread_run(tps65217_charger_poll_task, - charger, "ktps65217charger"); - if (IS_ERR(charger->poll_task)) { - ret = PTR_ERR(charger->poll_task); - dev_err(charger->dev, "Unable to run kthread err %d\n", ret); - return ret; + if (irq != -ENXIO) { + ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, + tps65217_charger_irq, + 0, "tps65217-charger", + charger); + if (ret) { + dev_err(charger->dev, + "Unable to register irq %d err %d\n", irq, + ret); + return ret; + } + + /* Check current state */ + tps65217_charger_irq(irq, charger); + } else { + charger->poll_task = kthread_run(tps65217_charger_poll_task, + charger, "ktps65217charger"); + if (IS_ERR(charger->poll_task)) { + ret = PTR_ERR(charger->poll_task); + dev_err(charger->dev, + "Unable to run kthread err %d\n", ret); + return ret; + } } return 0; @@ -241,7 +266,8 @@ static int tps65217_charger_remove(struct platform_device *pdev) { struct tps65217_charger *charger = platform_get_drvdata(pdev); - kthread_stop(charger->poll_task); + if (charger->irq == -ENXIO) + kthread_stop(charger->poll_task); return 0; } |