Commit 47d7d5ed authored by Marcin Niestroj's avatar Marcin Niestroj Committed by Sebastian Reichel

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: default avatarMarcin Niestroj <m.niestroj@grinn-global.com>
Signed-off-by: default avatarSebastian Reichel <sre@kernel.org>
parent f3332532
......@@ -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,19 +223,41 @@ 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;
}
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);
dev_err(charger->dev,
"Unable to run kthread err %d\n", ret);
return ret;
}
}
return 0;
}
......@@ -241,6 +266,7 @@ static int tps65217_charger_remove(struct platform_device *pdev)
{
struct tps65217_charger *charger = platform_get_drvdata(pdev);
if (charger->irq == -ENXIO)
kthread_stop(charger->poll_task);
return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment