All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mfd: MAX77693: Fix bug of interrupt handlding for MAX77693 devices
@ 2012-07-16  9:41 Chanwoo Choi
  2012-07-16 13:36 ` Mark Brown
  0 siblings, 1 reply; 5+ messages in thread
From: Chanwoo Choi @ 2012-07-16  9:41 UTC (permalink / raw)
  To: sameo; +Cc: myungjoo.ham, kyungmin.park, linux-kernel, Chanwoo Choi

This patch fix bug related to interrupt handling for MAX77693 devices.
- Unmask interrupt masking bit for charger/flash/muic to revolve
that interrupt isn't happened when external connector is attached.
- Fix wrong regmap instance when muic interrupt is happened.

Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Myungjoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
 drivers/mfd/max77693-irq.c |   36 +++++++++++++++++++++++++++++++-----
 1 files changed, 31 insertions(+), 5 deletions(-)

diff --git a/drivers/mfd/max77693-irq.c b/drivers/mfd/max77693-irq.c
index 2b40356..1029d01 100644
--- a/drivers/mfd/max77693-irq.c
+++ b/drivers/mfd/max77693-irq.c
@@ -137,6 +137,9 @@ static void max77693_irq_mask(struct irq_data *data)
 	const struct max77693_irq_data *irq_data =
 				irq_to_max77693_irq(max77693, data->irq);
 
+	if (irq_data->group >= MAX77693_IRQ_GROUP_NR)
+		return;
+
 	if (irq_data->group >= MUIC_INT1 && irq_data->group <= MUIC_INT3)
 		max77693->irq_masks_cur[irq_data->group] &= ~irq_data->mask;
 	else
@@ -149,6 +152,9 @@ static void max77693_irq_unmask(struct irq_data *data)
 	const struct max77693_irq_data *irq_data =
 	    irq_to_max77693_irq(max77693, data->irq);
 
+	if (irq_data->group >= MAX77693_IRQ_GROUP_NR)
+		return;
+
 	if (irq_data->group >= MUIC_INT1 && irq_data->group <= MUIC_INT3)
 		max77693->irq_masks_cur[irq_data->group] |= irq_data->mask;
 	else
@@ -200,7 +206,7 @@ static irqreturn_t max77693_irq_thread(int irq, void *data)
 
 	if (irq_src & MAX77693_IRQSRC_MUIC)
 		/* MUIC INT1 ~ INT3 */
-		max77693_bulk_read(max77693->regmap, MAX77693_MUIC_REG_INT1,
+		max77693_bulk_read(max77693->regmap_muic, MAX77693_MUIC_REG_INT1,
 			MAX77693_NUM_IRQ_MUIC_REGS, &irq_reg[MUIC_INT1]);
 
 	/* Apply masking */
@@ -255,7 +261,8 @@ int max77693_irq_init(struct max77693_dev *max77693)
 {
 	struct irq_domain *domain;
 	int i;
-	int ret;
+	int ret = 0;
+	u8 intsrc_mask;
 
 	mutex_init(&max77693->irqlock);
 
@@ -287,19 +294,38 @@ int max77693_irq_init(struct max77693_dev *max77693)
 					&max77693_irq_domain_ops, max77693);
 	if (!domain) {
 		dev_err(max77693->dev, "could not create irq domain\n");
-		return -ENODEV;
+		ret = -ENODEV;
+		goto err_irq;
 	}
 	max77693->irq_domain = domain;
 
+	/* Unmask max77693 interrupt */
+	ret = max77693_read_reg(max77693->regmap,
+			MAX77693_PMIC_REG_INTSRC_MASK, &intsrc_mask);
+	if (ret < 0) {
+		dev_err(max77693->dev, "fail to read PMIC register\n");
+		goto err_irq;
+	}
+
+	intsrc_mask &= ~(MAX77693_IRQSRC_CHG);
+	intsrc_mask &= ~(MAX77693_IRQSRC_FLASH);
+	intsrc_mask &= ~(MAX77693_IRQSRC_MUIC);
+	ret = max77693_write_reg(max77693->regmap,
+			MAX77693_PMIC_REG_INTSRC_MASK, intsrc_mask);
+	if (ret < 0) {
+		dev_err(max77693->dev, "fail to write PMIC register\n");
+		goto err_irq;
+	}
+
 	ret = request_threaded_irq(max77693->irq, NULL, max77693_irq_thread,
 				   IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
 				   "max77693-irq", max77693);
-
 	if (ret)
 		dev_err(max77693->dev, "Failed to request IRQ %d: %d\n",
 			max77693->irq, ret);
 
-	return 0;
+err_irq:
+	return ret;
 }
 
 void max77693_irq_exit(struct max77693_dev *max77693)
-- 
1.7.0.4


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

* Re: [PATCH] mfd: MAX77693: Fix bug of interrupt handlding for MAX77693 devices
  2012-07-16  9:41 [PATCH] mfd: MAX77693: Fix bug of interrupt handlding for MAX77693 devices Chanwoo Choi
@ 2012-07-16 13:36 ` Mark Brown
  2012-07-16 23:30   ` Chanwoo Choi
  0 siblings, 1 reply; 5+ messages in thread
From: Mark Brown @ 2012-07-16 13:36 UTC (permalink / raw)
  To: Chanwoo Choi; +Cc: sameo, myungjoo.ham, kyungmin.park, linux-kernel

On Mon, Jul 16, 2012 at 06:41:05PM +0900, Chanwoo Choi wrote:
> This patch fix bug related to interrupt handling for MAX77693 devices.
> - Unmask interrupt masking bit for charger/flash/muic to revolve
> that interrupt isn't happened when external connector is attached.

Shouldn't this be happening when the IRQ is requested?

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

* Re: [PATCH] mfd: MAX77693: Fix bug of interrupt handlding for MAX77693 devices
  2012-07-16 13:36 ` Mark Brown
@ 2012-07-16 23:30   ` Chanwoo Choi
  2012-07-17 19:14     ` Mark Brown
  0 siblings, 1 reply; 5+ messages in thread
From: Chanwoo Choi @ 2012-07-16 23:30 UTC (permalink / raw)
  To: Mark Brown; +Cc: sameo, myungjoo.ham, kyungmin.park, linux-kernel

On 07/16/2012 10:36 PM, Mark Brown wrote:

> On Mon, Jul 16, 2012 at 06:41:05PM +0900, Chanwoo Choi wrote:
>> This patch fix bug related to interrupt handling for MAX77693 devices.
>> - Unmask interrupt masking bit for charger/flash/muic to revolve
>> that interrupt isn't happened when external connector is attached.
> 
> Shouldn't this be happening when the IRQ is requested?
> 


The interrupt isn't happened when external connector is attached
because muic interrupt of MAX77693 is masked on INTSRC_MASK(
Interrupt Source Mask) register. So, I should set zero to muic interrupt
masking bit of INTSRC_MASK before requesting IRQ.

Thank you,
Chanwoo Choi

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

* Re: [PATCH] mfd: MAX77693: Fix bug of interrupt handlding for MAX77693 devices
  2012-07-16 23:30   ` Chanwoo Choi
@ 2012-07-17 19:14     ` Mark Brown
  2012-07-18  0:50       ` Chanwoo Choi
  0 siblings, 1 reply; 5+ messages in thread
From: Mark Brown @ 2012-07-17 19:14 UTC (permalink / raw)
  To: Chanwoo Choi; +Cc: sameo, myungjoo.ham, kyungmin.park, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 873 bytes --]

On Tue, Jul 17, 2012 at 08:30:17AM +0900, Chanwoo Choi wrote:
> On 07/16/2012 10:36 PM, Mark Brown wrote:
> > On Mon, Jul 16, 2012 at 06:41:05PM +0900, Chanwoo Choi wrote:

> >> This patch fix bug related to interrupt handling for MAX77693 devices.
> >> - Unmask interrupt masking bit for charger/flash/muic to revolve
> >> that interrupt isn't happened when external connector is attached.

> > Shouldn't this be happening when the IRQ is requested?

> The interrupt isn't happened when external connector is attached
> because muic interrupt of MAX77693 is masked on INTSRC_MASK(
> Interrupt Source Mask) register. So, I should set zero to muic interrupt
> masking bit of INTSRC_MASK before requesting IRQ.

Right, but normally that unmasking happens in the unmask() callback of
the irq_chip which is called when the interrupt is requested.  Why isn't
that working here?

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* Re: [PATCH] mfd: MAX77693: Fix bug of interrupt handlding for MAX77693 devices
  2012-07-17 19:14     ` Mark Brown
@ 2012-07-18  0:50       ` Chanwoo Choi
  0 siblings, 0 replies; 5+ messages in thread
From: Chanwoo Choi @ 2012-07-18  0:50 UTC (permalink / raw)
  To: Mark Brown; +Cc: sameo, myungjoo.ham, kyungmin.park, linux-kernel

On 07/18/2012 04:14 AM, Mark Brown wrote:

> On Tue, Jul 17, 2012 at 08:30:17AM +0900, Chanwoo Choi wrote:
>> On 07/16/2012 10:36 PM, Mark Brown wrote:
>>> On Mon, Jul 16, 2012 at 06:41:05PM +0900, Chanwoo Choi wrote:
> 
>>>> This patch fix bug related to interrupt handling for MAX77693 devices.
>>>> - Unmask interrupt masking bit for charger/flash/muic to revolve
>>>> that interrupt isn't happened when external connector is attached.
> 
>>> Shouldn't this be happening when the IRQ is requested?
> 
>> The interrupt isn't happened when external connector is attached
>> because muic interrupt of MAX77693 is masked on INTSRC_MASK(
>> Interrupt Source Mask) register. So, I should set zero to muic interrupt
>> masking bit of INTSRC_MASK before requesting IRQ.
> 
> Right, but normally that unmasking happens in the unmask() callback of
> the irq_chip which is called when the interrupt is requested.  Why isn't
> that working here?


As previous reply, Maxim MAX77693 has INTSRC_MASK(Interrput Source Mask,
0x23)
which mask or unmask Charger/Top/Flash/MUIC interrupt. And MAX77693 has
additional 'Interrupt Source Mask' for sub interrupt of each
Charger/Top/Flash/MUIC device.
In case of MUIC device, MUIC device has 16 sub interrupts and then MUIC
device need
separate Interrupt Source Mask(0x1,0x2,0x3) which is included in
register map of
MUIC i2c device and isn't equal to INTSRC_MASK(0x23). As you said,
unmasking sub interrupt of MUIC is happened in unmask() callback using
separate Interrupt Source Mask(0x1, 0x2, 0x3).

The MAX77693 mfd driver handle only INTSRC_MASK(0x23) to activate
Charger/Top/Flash/MUIC interrupt which isn't equal to sub interrupt of
each device before requesting
IRQ. If mfd driver wouldn't unmask Charger/Top/Flash/MUIC interrupt of
INTSRC_MASK(0x23),
it mean that Charger/Top/Flash/MUIC interrupt is inactive state and mfd
driver can't get the any interrupt.

Thank you,
Chanwoo Choi






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

end of thread, other threads:[~2012-07-18  0:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-16  9:41 [PATCH] mfd: MAX77693: Fix bug of interrupt handlding for MAX77693 devices Chanwoo Choi
2012-07-16 13:36 ` Mark Brown
2012-07-16 23:30   ` Chanwoo Choi
2012-07-17 19:14     ` Mark Brown
2012-07-18  0:50       ` Chanwoo Choi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.