public inbox for linux-tegra@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] tps65090-charger: Fix AC detect
@ 2013-06-06 21:12 Andrew Chew
       [not found] ` <1370553163-31804-1-git-send-email-achew-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Chew @ 2013-06-06 21:12 UTC (permalink / raw)
  To: rklein-DDmLM1+adcrQT0dZR+AlfA, cbou-JGs/UdohzUI,
	dwmw2-wEGCiKHe2LqWVfeAwA7xHQ
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA, achew-DDmLM1+adcrQT0dZR+AlfA

The VACG interrupt was not being enabled.  Thus, interrupts were never
generated when AC status changes.  In addition, interrupts were never
cleared after taking and processing the interrupt.

Added the register offset for the INTR_MASK register, since this is needed
to unmask the VACG interrupt.

Enabled the VACG interrupt in tps65090_config_charger().

Cleared interrupts after processing, in tps65090_charger_isr().

Also removed unused variable "enable" in tps65090_enable_charging(),
and fixed a typo in one of the dev_err() prints.

Signed-off-by: Andrew Chew <achew-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
---
 drivers/power/tps65090-charger.c | 35 ++++++++++++++++++++++++++++++-----
 1 file changed, 30 insertions(+), 5 deletions(-)

diff --git a/drivers/power/tps65090-charger.c b/drivers/power/tps65090-charger.c
index 9fbca31..a09f8c4 100644
--- a/drivers/power/tps65090-charger.c
+++ b/drivers/power/tps65090-charger.c
@@ -27,6 +27,7 @@
 #include <linux/mfd/tps65090.h>
 
 #define TPS65090_REG_INTR_STS	0x00
+#define TPS65090_REG_INTR_MASK	0x02
 #define TPS65090_REG_CG_CTRL0	0x04
 #define TPS65090_REG_CG_CTRL1	0x05
 #define TPS65090_REG_CG_CTRL2	0x06
@@ -67,8 +68,7 @@ static int tps65090_low_chrg_current(struct tps65090_charger *charger)
 	return 0;
 }
 
-static int tps65090_enable_charging(struct tps65090_charger *charger,
-	uint8_t enable)
+static int tps65090_enable_charging(struct tps65090_charger *charger)
 {
 	int ret;
 	uint8_t ctrl0 = 0;
@@ -84,7 +84,7 @@ static int tps65090_enable_charging(struct tps65090_charger *charger,
 	ret = tps65090_write(charger->dev->parent, TPS65090_REG_CG_CTRL0,
 				(ctrl0 | TPS65090_CHARGER_ENABLE));
 	if (ret < 0) {
-		dev_err(charger->dev, "%s(): error reading in register 0x%x\n",
+		dev_err(charger->dev, "%s(): error writing in register 0x%x\n",
 				__func__, TPS65090_REG_CG_CTRL0);
 		return ret;
 	}
@@ -93,6 +93,7 @@ static int tps65090_enable_charging(struct tps65090_charger *charger,
 
 static int tps65090_config_charger(struct tps65090_charger *charger)
 {
+	uint8_t intrmask = 0;
 	int ret;
 
 	if (charger->pdata->enable_low_current_chrg) {
@@ -104,6 +105,23 @@ static int tps65090_config_charger(struct tps65090_charger *charger)
 		}
 	}
 
+	/* Enable the VACG interrupt for AC power detect */
+	ret = tps65090_read(charger->dev->parent, TPS65090_REG_INTR_MASK,
+			    &intrmask);
+	if (ret < 0) {
+		dev_err(charger->dev, "%s(): error reading in register 0x%x\n",
+			__func__, TPS65090_REG_INTR_MASK);
+		return ret;
+	}
+
+	ret = tps65090_write(charger->dev->parent, TPS65090_REG_INTR_MASK,
+			     (intrmask | TPS65090_VACG));
+	if (ret < 0) {
+		dev_err(charger->dev, "%s(): error writing in register 0x%x\n",
+			__func__, TPS65090_REG_CG_CTRL0);
+		return ret;
+	}
+
 	return 0;
 }
 
@@ -146,7 +164,7 @@ static irqreturn_t tps65090_charger_isr(int irq, void *dev_id)
 	}
 
 	if (intrsts & TPS65090_VACG) {
-		ret = tps65090_enable_charging(charger, 1);
+		ret = tps65090_enable_charging(charger);
 		if (ret < 0)
 			return IRQ_HANDLED;
 		charger->ac_online = 1;
@@ -154,6 +172,13 @@ static irqreturn_t tps65090_charger_isr(int irq, void *dev_id)
 		charger->ac_online = 0;
 	}
 
+	/* Clear interrupts. */
+	ret = tps65090_write(charger->dev->parent, TPS65090_REG_INTR_STS, 0x00);
+	if (ret < 0) {
+		dev_err(charger->dev, "%s(): Error in writing reg 0x%x\n",
+				__func__, TPS65090_REG_INTR_STS);
+	}
+
 	if (charger->prev_ac_online != charger->ac_online)
 		power_supply_changed(&charger->ac);
 
@@ -270,7 +295,7 @@ static int tps65090_charger_probe(struct platform_device *pdev)
 	}
 
 	if (status1 != 0) {
-		ret = tps65090_enable_charging(cdata, 1);
+		ret = tps65090_enable_charging(cdata);
 		if (ret < 0) {
 			dev_err(cdata->dev, "error enabling charger\n");
 			goto fail_free_irq;
-- 
1.8.1.5

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] tps65090-charger: Fix AC detect
       [not found] ` <1370553163-31804-1-git-send-email-achew-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
@ 2013-06-07 16:07   ` Rhyland Klein
       [not found]     ` <51B2054B.7030609-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Rhyland Klein @ 2013-06-07 16:07 UTC (permalink / raw)
  To: Andrew Chew
  Cc: cbou-JGs/UdohzUI@public.gmane.org,
	dwmw2-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org

On 6/6/2013 5:12 PM, Andrew Chew wrote:
> The VACG interrupt was not being enabled.  Thus, interrupts were never
> generated when AC status changes.  In addition, interrupts were never
> cleared after taking and processing the interrupt.
> 
> Added the register offset for the INTR_MASK register, since this is needed
> to unmask the VACG interrupt.
> 
> Enabled the VACG interrupt in tps65090_config_charger().
> 
> Cleared interrupts after processing, in tps65090_charger_isr().
> 
> Also removed unused variable "enable" in tps65090_enable_charging(),
> and fixed a typo in one of the dev_err() prints.
> 
> Signed-off-by: Andrew Chew <achew-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
> ---

Great! Tested and it works great on my Dalmore.

Tested-by: Rhyland Klein <rklein-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
Acked-by: Rhyland Klein <rklein-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>

-rhyland

-- 
nvpublic

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] tps65090-charger: Fix AC detect
       [not found]     ` <51B2054B.7030609-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
@ 2013-06-09 17:03       ` Anton Vorontsov
  0 siblings, 0 replies; 3+ messages in thread
From: Anton Vorontsov @ 2013-06-09 17:03 UTC (permalink / raw)
  To: Rhyland Klein
  Cc: Andrew Chew, dwmw2-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org

On Fri, Jun 07, 2013 at 12:07:39PM -0400, Rhyland Klein wrote:
> On 6/6/2013 5:12 PM, Andrew Chew wrote:
> > The VACG interrupt was not being enabled.  Thus, interrupts were never
> > generated when AC status changes.  In addition, interrupts were never
> > cleared after taking and processing the interrupt.
> > 
> > Added the register offset for the INTR_MASK register, since this is needed
> > to unmask the VACG interrupt.
> > 
> > Enabled the VACG interrupt in tps65090_config_charger().
> > 
> > Cleared interrupts after processing, in tps65090_charger_isr().
> > 
> > Also removed unused variable "enable" in tps65090_enable_charging(),
> > and fixed a typo in one of the dev_err() prints.
> > 
> > Signed-off-by: Andrew Chew <achew-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
> > ---
> 
> Great! Tested and it works great on my Dalmore.
> 
> Tested-by: Rhyland Klein <rklein-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
> Acked-by: Rhyland Klein <rklein-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>

Applied, thanks!

Anton

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-06-09 17:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-06 21:12 [PATCH 1/1] tps65090-charger: Fix AC detect Andrew Chew
     [not found] ` <1370553163-31804-1-git-send-email-achew-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-06-07 16:07   ` Rhyland Klein
     [not found]     ` <51B2054B.7030609-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-06-09 17:03       ` Anton Vorontsov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox