diff options
| author | Chanwoo Choi <cw00.choi@samsung.com> | 2012-08-21 02:15:52 -0400 |
|---|---|---|
| committer | Samuel Ortiz <sameo@linux.intel.com> | 2012-09-15 18:32:57 -0400 |
| commit | d51f42d2c5b7e11b47876b8b5c53f0ac317fef24 (patch) | |
| tree | c017d042d4246b2a5ade7e526f17c3671ef08d11 | |
| parent | 0848c94fb4a5cc213a7fb0fb3a5721ad6e16f096 (diff) | |
mfd: MAX77693: Fix interrupt handling bug
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.
This patch were discussed and confirm discussion about this patch on below url:
http://lkml.org/lkml/2012/7/16/118
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>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
| -rw-r--r-- | 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 2b403569e0a6..1029d018c739 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) | |||
| 137 | const struct max77693_irq_data *irq_data = | 137 | const struct max77693_irq_data *irq_data = |
| 138 | irq_to_max77693_irq(max77693, data->irq); | 138 | irq_to_max77693_irq(max77693, data->irq); |
| 139 | 139 | ||
| 140 | if (irq_data->group >= MAX77693_IRQ_GROUP_NR) | ||
| 141 | return; | ||
| 142 | |||
| 140 | if (irq_data->group >= MUIC_INT1 && irq_data->group <= MUIC_INT3) | 143 | if (irq_data->group >= MUIC_INT1 && irq_data->group <= MUIC_INT3) |
| 141 | max77693->irq_masks_cur[irq_data->group] &= ~irq_data->mask; | 144 | max77693->irq_masks_cur[irq_data->group] &= ~irq_data->mask; |
| 142 | else | 145 | else |
| @@ -149,6 +152,9 @@ static void max77693_irq_unmask(struct irq_data *data) | |||
| 149 | const struct max77693_irq_data *irq_data = | 152 | const struct max77693_irq_data *irq_data = |
| 150 | irq_to_max77693_irq(max77693, data->irq); | 153 | irq_to_max77693_irq(max77693, data->irq); |
| 151 | 154 | ||
| 155 | if (irq_data->group >= MAX77693_IRQ_GROUP_NR) | ||
| 156 | return; | ||
| 157 | |||
| 152 | if (irq_data->group >= MUIC_INT1 && irq_data->group <= MUIC_INT3) | 158 | if (irq_data->group >= MUIC_INT1 && irq_data->group <= MUIC_INT3) |
| 153 | max77693->irq_masks_cur[irq_data->group] |= irq_data->mask; | 159 | max77693->irq_masks_cur[irq_data->group] |= irq_data->mask; |
| 154 | else | 160 | else |
| @@ -200,7 +206,7 @@ static irqreturn_t max77693_irq_thread(int irq, void *data) | |||
| 200 | 206 | ||
| 201 | if (irq_src & MAX77693_IRQSRC_MUIC) | 207 | if (irq_src & MAX77693_IRQSRC_MUIC) |
| 202 | /* MUIC INT1 ~ INT3 */ | 208 | /* MUIC INT1 ~ INT3 */ |
| 203 | max77693_bulk_read(max77693->regmap, MAX77693_MUIC_REG_INT1, | 209 | max77693_bulk_read(max77693->regmap_muic, MAX77693_MUIC_REG_INT1, |
| 204 | MAX77693_NUM_IRQ_MUIC_REGS, &irq_reg[MUIC_INT1]); | 210 | MAX77693_NUM_IRQ_MUIC_REGS, &irq_reg[MUIC_INT1]); |
| 205 | 211 | ||
| 206 | /* Apply masking */ | 212 | /* Apply masking */ |
| @@ -255,7 +261,8 @@ int max77693_irq_init(struct max77693_dev *max77693) | |||
| 255 | { | 261 | { |
| 256 | struct irq_domain *domain; | 262 | struct irq_domain *domain; |
| 257 | int i; | 263 | int i; |
| 258 | int ret; | 264 | int ret = 0; |
| 265 | u8 intsrc_mask; | ||
| 259 | 266 | ||
| 260 | mutex_init(&max77693->irqlock); | 267 | mutex_init(&max77693->irqlock); |
| 261 | 268 | ||
| @@ -287,19 +294,38 @@ int max77693_irq_init(struct max77693_dev *max77693) | |||
| 287 | &max77693_irq_domain_ops, max77693); | 294 | &max77693_irq_domain_ops, max77693); |
| 288 | if (!domain) { | 295 | if (!domain) { |
| 289 | dev_err(max77693->dev, "could not create irq domain\n"); | 296 | dev_err(max77693->dev, "could not create irq domain\n"); |
| 290 | return -ENODEV; | 297 | ret = -ENODEV; |
| 298 | goto err_irq; | ||
| 291 | } | 299 | } |
| 292 | max77693->irq_domain = domain; | 300 | max77693->irq_domain = domain; |
| 293 | 301 | ||
| 302 | /* Unmask max77693 interrupt */ | ||
| 303 | ret = max77693_read_reg(max77693->regmap, | ||
| 304 | MAX77693_PMIC_REG_INTSRC_MASK, &intsrc_mask); | ||
| 305 | if (ret < 0) { | ||
| 306 | dev_err(max77693->dev, "fail to read PMIC register\n"); | ||
| 307 | goto err_irq; | ||
| 308 | } | ||
| 309 | |||
| 310 | intsrc_mask &= ~(MAX77693_IRQSRC_CHG); | ||
| 311 | intsrc_mask &= ~(MAX77693_IRQSRC_FLASH); | ||
| 312 | intsrc_mask &= ~(MAX77693_IRQSRC_MUIC); | ||
| 313 | ret = max77693_write_reg(max77693->regmap, | ||
| 314 | MAX77693_PMIC_REG_INTSRC_MASK, intsrc_mask); | ||
| 315 | if (ret < 0) { | ||
| 316 | dev_err(max77693->dev, "fail to write PMIC register\n"); | ||
| 317 | goto err_irq; | ||
| 318 | } | ||
| 319 | |||
| 294 | ret = request_threaded_irq(max77693->irq, NULL, max77693_irq_thread, | 320 | ret = request_threaded_irq(max77693->irq, NULL, max77693_irq_thread, |
| 295 | IRQF_TRIGGER_FALLING | IRQF_ONESHOT, | 321 | IRQF_TRIGGER_FALLING | IRQF_ONESHOT, |
| 296 | "max77693-irq", max77693); | 322 | "max77693-irq", max77693); |
| 297 | |||
| 298 | if (ret) | 323 | if (ret) |
| 299 | dev_err(max77693->dev, "Failed to request IRQ %d: %d\n", | 324 | dev_err(max77693->dev, "Failed to request IRQ %d: %d\n", |
| 300 | max77693->irq, ret); | 325 | max77693->irq, ret); |
| 301 | 326 | ||
| 302 | return 0; | 327 | err_irq: |
| 328 | return ret; | ||
| 303 | } | 329 | } |
| 304 | 330 | ||
| 305 | void max77693_irq_exit(struct max77693_dev *max77693) | 331 | void max77693_irq_exit(struct max77693_dev *max77693) |
