Commit dca1a71e authored by Chanwoo Choi's avatar Chanwoo Choi Committed by Samuel Ortiz

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: default avatarChanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: default avatarMyungjoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: default avatarKyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: default avatarSamuel Ortiz <sameo@linux.intel.com>
parent b41511f7
...@@ -23,7 +23,7 @@ config EXTCON_GPIO ...@@ -23,7 +23,7 @@ config EXTCON_GPIO
config EXTCON_MAX8997 config EXTCON_MAX8997
tristate "MAX8997 EXTCON Support" tristate "MAX8997 EXTCON Support"
depends on MFD_MAX8997 depends on MFD_MAX8997 && IRQ_DOMAIN
help help
If you say yes here you get support for the MUIC device of If you say yes here you get support for the MUIC device of
Maxim MAX8997 PMIC. The MAX8997 MUIC is a USB port accessory Maxim MAX8997 PMIC. The MAX8997 MUIC is a USB port accessory
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include <linux/mfd/max8997.h> #include <linux/mfd/max8997.h>
#include <linux/mfd/max8997-private.h> #include <linux/mfd/max8997-private.h>
#include <linux/extcon.h> #include <linux/extcon.h>
#include <linux/irqdomain.h>
#define DEV_NAME "max8997-muic" #define DEV_NAME "max8997-muic"
...@@ -77,6 +78,7 @@ ...@@ -77,6 +78,7 @@
struct max8997_muic_irq { struct max8997_muic_irq {
unsigned int irq; unsigned int irq;
const char *name; const char *name;
unsigned int virq;
}; };
static struct max8997_muic_irq muic_irqs[] = { static struct max8997_muic_irq muic_irqs[] = {
...@@ -343,12 +345,10 @@ static void max8997_muic_irq_work(struct work_struct *work) ...@@ -343,12 +345,10 @@ static void max8997_muic_irq_work(struct work_struct *work)
{ {
struct max8997_muic_info *info = container_of(work, struct max8997_muic_info *info = container_of(work,
struct max8997_muic_info, irq_work); struct max8997_muic_info, irq_work);
struct max8997_dev *max8997 = i2c_get_clientdata(info->muic);
u8 status[2]; u8 status[2];
u8 adc, chg_type; u8 adc, chg_type;
int irq_type = 0;
int irq_type = info->irq - max8997->irq_base; int i, ret;
int ret;
mutex_lock(&info->mutex); mutex_lock(&info->mutex);
...@@ -363,6 +363,10 @@ static void max8997_muic_irq_work(struct work_struct *work) ...@@ -363,6 +363,10 @@ static void max8997_muic_irq_work(struct work_struct *work)
dev_dbg(info->dev, "%s: STATUS1:0x%x, 2:0x%x\n", __func__, dev_dbg(info->dev, "%s: STATUS1:0x%x, 2:0x%x\n", __func__,
status[0], status[1]); status[0], status[1]);
for (i = 0 ; i < ARRAY_SIZE(muic_irqs) ; i++)
if (info->irq == muic_irqs[i].virq)
irq_type = muic_irqs[i].irq;
switch (irq_type) { switch (irq_type) {
case MAX8997_MUICIRQ_ADC: case MAX8997_MUICIRQ_ADC:
adc = status[0] & STATUS1_ADC_MASK; adc = status[0] & STATUS1_ADC_MASK;
...@@ -448,11 +452,15 @@ static int __devinit max8997_muic_probe(struct platform_device *pdev) ...@@ -448,11 +452,15 @@ static int __devinit max8997_muic_probe(struct platform_device *pdev)
for (i = 0; i < ARRAY_SIZE(muic_irqs); i++) { for (i = 0; i < ARRAY_SIZE(muic_irqs); i++) {
struct max8997_muic_irq *muic_irq = &muic_irqs[i]; struct max8997_muic_irq *muic_irq = &muic_irqs[i];
int virq = 0;
virq = irq_create_mapping(max8997->irq_domain, muic_irq->irq);
if (!virq)
goto err_irq;
muic_irq->virq = virq;
ret = request_threaded_irq(pdata->irq_base + muic_irq->irq, ret = request_threaded_irq(virq, NULL,max8997_muic_irq_handler,
NULL, max8997_muic_irq_handler, 0, muic_irq->name, info);
0, muic_irq->name,
info);
if (ret) { if (ret) {
dev_err(&pdev->dev, dev_err(&pdev->dev,
"failed: irq request (IRQ: %d," "failed: irq request (IRQ: %d,"
...@@ -496,7 +504,7 @@ static int __devinit max8997_muic_probe(struct platform_device *pdev) ...@@ -496,7 +504,7 @@ static int __devinit max8997_muic_probe(struct platform_device *pdev)
kfree(info->edev); kfree(info->edev);
err_irq: err_irq:
while (--i >= 0) while (--i >= 0)
free_irq(pdata->irq_base + muic_irqs[i].irq, info); free_irq(muic_irqs[i].virq, info);
kfree(info); kfree(info);
err_kfree: err_kfree:
return ret; return ret;
...@@ -505,11 +513,10 @@ static int __devinit max8997_muic_probe(struct platform_device *pdev) ...@@ -505,11 +513,10 @@ static int __devinit max8997_muic_probe(struct platform_device *pdev)
static int __devexit max8997_muic_remove(struct platform_device *pdev) static int __devexit max8997_muic_remove(struct platform_device *pdev)
{ {
struct max8997_muic_info *info = platform_get_drvdata(pdev); struct max8997_muic_info *info = platform_get_drvdata(pdev);
struct max8997_dev *max8997 = i2c_get_clientdata(info->muic);
int i; int i;
for (i = 0; i < ARRAY_SIZE(muic_irqs); i++) for (i = 0; i < ARRAY_SIZE(muic_irqs); i++)
free_irq(max8997->irq_base + muic_irqs[i].irq, info); free_irq(muic_irqs[i].virq, info);
cancel_work_sync(&info->irq_work); cancel_work_sync(&info->irq_work);
extcon_dev_unregister(info->edev); extcon_dev_unregister(info->edev);
......
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