aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/extcon
diff options
context:
space:
mode:
authorChanwoo Choi <cw00.choi@samsung.com>2012-07-01 20:03:00 -0400
committerSamuel Ortiz <sameo@linux.intel.com>2012-07-08 18:16:13 -0400
commitdca1a71e4108a0a9051a653d885297e9d1cc656c (patch)
tree50f90ec0cae92c063b6de94ee1b71e8fb91cf585 /drivers/extcon
parentb41511f713ccaef666e450fae8cb18909897fe4e (diff)
extcon: Add support irq domain for MAX8997 muic
This patch add support irq domain for Maxim MAX8997 muic instead of irq_base in platform data and max8997 driver private data are instead. It is tested on TRATS board. Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> 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> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/extcon')
-rw-r--r--drivers/extcon/Kconfig2
-rw-r--r--drivers/extcon/extcon-max8997.c29
2 files changed, 19 insertions, 12 deletions
diff --git a/drivers/extcon/Kconfig b/drivers/extcon/Kconfig
index 29c5cf852efc..bf6b2eae5751 100644
--- a/drivers/extcon/Kconfig
+++ b/drivers/extcon/Kconfig
@@ -23,7 +23,7 @@ config EXTCON_GPIO
23 23
24config EXTCON_MAX8997 24config EXTCON_MAX8997
25 tristate "MAX8997 EXTCON Support" 25 tristate "MAX8997 EXTCON Support"
26 depends on MFD_MAX8997 26 depends on MFD_MAX8997 && IRQ_DOMAIN
27 help 27 help
28 If you say yes here you get support for the MUIC device of 28 If you say yes here you get support for the MUIC device of
29 Maxim MAX8997 PMIC. The MAX8997 MUIC is a USB port accessory 29 Maxim MAX8997 PMIC. The MAX8997 MUIC is a USB port accessory
diff --git a/drivers/extcon/extcon-max8997.c b/drivers/extcon/extcon-max8997.c
index a4ed30bd9a41..ef9090a4271d 100644
--- a/drivers/extcon/extcon-max8997.c
+++ b/drivers/extcon/extcon-max8997.c
@@ -26,6 +26,7 @@
26#include <linux/mfd/max8997.h> 26#include <linux/mfd/max8997.h>
27#include <linux/mfd/max8997-private.h> 27#include <linux/mfd/max8997-private.h>
28#include <linux/extcon.h> 28#include <linux/extcon.h>
29#include <linux/irqdomain.h>
29 30
30#define DEV_NAME "max8997-muic" 31#define DEV_NAME "max8997-muic"
31 32
@@ -77,6 +78,7 @@
77struct max8997_muic_irq { 78struct max8997_muic_irq {
78 unsigned int irq; 79 unsigned int irq;
79 const char *name; 80 const char *name;
81 unsigned int virq;
80}; 82};
81 83
82static struct max8997_muic_irq muic_irqs[] = { 84static struct max8997_muic_irq muic_irqs[] = {
@@ -343,12 +345,10 @@ static void max8997_muic_irq_work(struct work_struct *work)
343{ 345{
344 struct max8997_muic_info *info = container_of(work, 346 struct max8997_muic_info *info = container_of(work,
345 struct max8997_muic_info, irq_work); 347 struct max8997_muic_info, irq_work);
346 struct max8997_dev *max8997 = i2c_get_clientdata(info->muic);
347 u8 status[2]; 348 u8 status[2];
348 u8 adc, chg_type; 349 u8 adc, chg_type;
349 350 int irq_type = 0;
350 int irq_type = info->irq - max8997->irq_base; 351 int i, ret;
351 int ret;
352 352
353 mutex_lock(&info->mutex); 353 mutex_lock(&info->mutex);
354 354
@@ -363,6 +363,10 @@ static void max8997_muic_irq_work(struct work_struct *work)
363 dev_dbg(info->dev, "%s: STATUS1:0x%x, 2:0x%x\n", __func__, 363 dev_dbg(info->dev, "%s: STATUS1:0x%x, 2:0x%x\n", __func__,
364 status[0], status[1]); 364 status[0], status[1]);
365 365
366 for (i = 0 ; i < ARRAY_SIZE(muic_irqs) ; i++)
367 if (info->irq == muic_irqs[i].virq)
368 irq_type = muic_irqs[i].irq;
369
366 switch (irq_type) { 370 switch (irq_type) {
367 case MAX8997_MUICIRQ_ADC: 371 case MAX8997_MUICIRQ_ADC:
368 adc = status[0] & STATUS1_ADC_MASK; 372 adc = status[0] & STATUS1_ADC_MASK;
@@ -448,11 +452,15 @@ static int __devinit max8997_muic_probe(struct platform_device *pdev)
448 452
449 for (i = 0; i < ARRAY_SIZE(muic_irqs); i++) { 453 for (i = 0; i < ARRAY_SIZE(muic_irqs); i++) {
450 struct max8997_muic_irq *muic_irq = &muic_irqs[i]; 454 struct max8997_muic_irq *muic_irq = &muic_irqs[i];
455 int virq = 0;
456
457 virq = irq_create_mapping(max8997->irq_domain, muic_irq->irq);
458 if (!virq)
459 goto err_irq;
460 muic_irq->virq = virq;
451 461
452 ret = request_threaded_irq(pdata->irq_base + muic_irq->irq, 462 ret = request_threaded_irq(virq, NULL,max8997_muic_irq_handler,
453 NULL, max8997_muic_irq_handler, 463 0, muic_irq->name, info);
454 0, muic_irq->name,
455 info);
456 if (ret) { 464 if (ret) {
457 dev_err(&pdev->dev, 465 dev_err(&pdev->dev,
458 "failed: irq request (IRQ: %d," 466 "failed: irq request (IRQ: %d,"
@@ -496,7 +504,7 @@ err_extcon:
496 kfree(info->edev); 504 kfree(info->edev);
497err_irq: 505err_irq:
498 while (--i >= 0) 506 while (--i >= 0)
499 free_irq(pdata->irq_base + muic_irqs[i].irq, info); 507 free_irq(muic_irqs[i].virq, info);
500 kfree(info); 508 kfree(info);
501err_kfree: 509err_kfree:
502 return ret; 510 return ret;
@@ -505,11 +513,10 @@ err_kfree:
505static int __devexit max8997_muic_remove(struct platform_device *pdev) 513static int __devexit max8997_muic_remove(struct platform_device *pdev)
506{ 514{
507 struct max8997_muic_info *info = platform_get_drvdata(pdev); 515 struct max8997_muic_info *info = platform_get_drvdata(pdev);
508 struct max8997_dev *max8997 = i2c_get_clientdata(info->muic);
509 int i; 516 int i;
510 517
511 for (i = 0; i < ARRAY_SIZE(muic_irqs); i++) 518 for (i = 0; i < ARRAY_SIZE(muic_irqs); i++)
512 free_irq(max8997->irq_base + muic_irqs[i].irq, info); 519 free_irq(muic_irqs[i].virq, info);
513 cancel_work_sync(&info->irq_work); 520 cancel_work_sync(&info->irq_work);
514 521
515 extcon_dev_unregister(info->edev); 522 extcon_dev_unregister(info->edev);