All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] mfd: add irq domain support for max8997 interrupts
@ 2012-06-21  1:10 Chanwoo Choi
  2012-06-21  9:54 ` Mark Brown
  0 siblings, 1 reply; 22+ messages in thread
From: Chanwoo Choi @ 2012-06-21  1:10 UTC (permalink / raw)
  To: gregkh
  Cc: thomas.abraham, broonie, grant.likely, sameo, myungjoo.ham,
	kyungmin.park, linux-kernel, Chanwoo Choi

From: Thomas Abraham <thomas.abraham@linaro.org>

Add irq domain support for max8997 interrupts. The reverse mapping method
used is linear mapping since the sub-drivers of max8997 such as regulator
and charger drivers can use the max8997 irq_domain to get the linux irq
number for max8997 interrupts. All uses of irq_base in platform data and
max8997 driver private data are removed.

Signed-off-by: Thomas Abraham <thomas.abraham@linaro.org>
Acked-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Acked-by: Grant Likely <grant.likely@secretlab.ca>
Acked-by: Samuel Ortiz <sameo@linux.intel.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
	[Fix two bug which set max8997->irq_domain and correct wrong parameter]
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
 arch/arm/mach-exynos/mach-nuri.c    |    4 --
 arch/arm/mach-exynos/mach-origen.c  |    1 -
 drivers/mfd/Kconfig                 |    1 +
 drivers/mfd/max8997-irq.c           |   62 +++++++++++++++++++++--------------
 drivers/mfd/max8997.c               |    1 -
 include/linux/mfd/max8997-private.h |    4 ++-
 include/linux/mfd/max8997.h         |    1 -
 7 files changed, 41 insertions(+), 33 deletions(-)

diff --git a/arch/arm/mach-exynos/mach-nuri.c b/arch/arm/mach-exynos/mach-nuri.c
index 656f8fc..acb58f5 100644
--- a/arch/arm/mach-exynos/mach-nuri.c
+++ b/arch/arm/mach-exynos/mach-nuri.c
@@ -1067,12 +1067,8 @@ static struct platform_device nuri_max8903_device = {
 static void __init nuri_power_init(void)
 {
 	int gpio;
-	int irq_base = IRQ_GPIO_END + 1;
 	int ta_en = 0;
 
-	nuri_max8997_pdata.irq_base = irq_base;
-	irq_base += MAX8997_IRQ_NR;
-
 	gpio = EXYNOS4_GPX0(7);
 	gpio_request(gpio, "AP_PMIC_IRQ");
 	s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf));
diff --git a/arch/arm/mach-exynos/mach-origen.c b/arch/arm/mach-exynos/mach-origen.c
index f5572be..3ce403d 100644
--- a/arch/arm/mach-exynos/mach-origen.c
+++ b/arch/arm/mach-exynos/mach-origen.c
@@ -425,7 +425,6 @@ static struct max8997_platform_data __initdata origen_max8997_pdata = {
 	.buck1_gpiodvs	= false,
 	.buck2_gpiodvs	= false,
 	.buck5_gpiodvs	= false,
-	.irq_base	= IRQ_GPIO_END + 1,
 
 	.ignore_gpiodvs_side_effect = true,
 	.buck125_default_idx = 0x0,
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index e129c82..295941b 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -449,6 +449,7 @@ config MFD_MAX8997
 	bool "Maxim Semiconductor MAX8997/8966 PMIC Support"
 	depends on I2C=y && GENERIC_HARDIRQS
 	select MFD_CORE
+	select IRQ_DOMAIN
 	help
 	  Say yes here to support for Maxim Semiconductor MAX8997/8966.
 	  This is a Power Management IC with RTC, Flash, Fuel Gauge, Haptic,
diff --git a/drivers/mfd/max8997-irq.c b/drivers/mfd/max8997-irq.c
index 09274cf..43fa614 100644
--- a/drivers/mfd/max8997-irq.c
+++ b/drivers/mfd/max8997-irq.c
@@ -142,7 +142,8 @@ static void max8997_irq_sync_unlock(struct irq_data *data)
 static const inline struct max8997_irq_data *
 irq_to_max8997_irq(struct max8997_dev *max8997, int irq)
 {
-	return &max8997_irqs[irq - max8997->irq_base];
+	struct irq_data *data = irq_get_irq_data(irq);
+	return &max8997_irqs[data->hwirq];
 }
 
 static void max8997_irq_mask(struct irq_data *data)
@@ -182,7 +183,7 @@ static irqreturn_t max8997_irq_thread(int irq, void *data)
 	u8 irq_reg[MAX8997_IRQ_GROUP_NR] = {};
 	u8 irq_src;
 	int ret;
-	int i;
+	int i, cur_irq;
 
 	ret = max8997_read_reg(max8997->i2c, MAX8997_REG_INTSRC, &irq_src);
 	if (ret < 0) {
@@ -269,8 +270,11 @@ static irqreturn_t max8997_irq_thread(int irq, void *data)
 
 	/* Report */
 	for (i = 0; i < MAX8997_IRQ_NR; i++) {
-		if (irq_reg[max8997_irqs[i].group] & max8997_irqs[i].mask)
-			handle_nested_irq(max8997->irq_base + i);
+		if (irq_reg[max8997_irqs[i].group] & max8997_irqs[i].mask) {
+			cur_irq = irq_find_mapping(max8997->irq_domain, i);
+			if (cur_irq)
+				handle_nested_irq(cur_irq);
+		}
 	}
 
 	return IRQ_HANDLED;
@@ -278,26 +282,40 @@ static irqreturn_t max8997_irq_thread(int irq, void *data)
 
 int max8997_irq_resume(struct max8997_dev *max8997)
 {
-	if (max8997->irq && max8997->irq_base)
-		max8997_irq_thread(max8997->irq_base, max8997);
+	if (max8997->irq && max8997->irq_domain)
+		max8997_irq_thread(0, max8997);
+	return 0;
+}
+
+static int max8997_irq_domain_map(struct irq_domain *d, unsigned int irq,
+					irq_hw_number_t hw)
+{
+	struct max8997_dev *max8997 = d->host_data;
+
+	irq_set_chip_data(irq, max8997);
+	irq_set_chip_and_handler(irq, &max8997_irq_chip, handle_edge_irq);
+	irq_set_nested_thread(irq, 1);
+#ifdef CONFIG_ARM
+	set_irq_flags(irq, IRQF_VALID);
+#else
+	irq_set_noprobe(irq);
+#endif
 	return 0;
 }
 
+static struct irq_domain_ops max8997_irq_domain_ops = {
+	.map = max8997_irq_domain_map,
+};
+
 int max8997_irq_init(struct max8997_dev *max8997)
 {
+	struct irq_domain *domain;
 	int i;
-	int cur_irq;
 	int ret;
 	u8 val;
 
 	if (!max8997->irq) {
 		dev_warn(max8997->dev, "No interrupt specified.\n");
-		max8997->irq_base = 0;
-		return 0;
-	}
-
-	if (!max8997->irq_base) {
-		dev_err(max8997->dev, "No interrupt base specified.\n");
 		return 0;
 	}
 
@@ -327,19 +345,13 @@ int max8997_irq_init(struct max8997_dev *max8997)
 					true : false;
 	}
 
-	/* Register with genirq */
-	for (i = 0; i < MAX8997_IRQ_NR; i++) {
-		cur_irq = i + max8997->irq_base;
-		irq_set_chip_data(cur_irq, max8997);
-		irq_set_chip_and_handler(cur_irq, &max8997_irq_chip,
-				handle_edge_irq);
-		irq_set_nested_thread(cur_irq, 1);
-#ifdef CONFIG_ARM
-		set_irq_flags(cur_irq, IRQF_VALID);
-#else
-		irq_set_noprobe(cur_irq);
-#endif
+	domain = irq_domain_add_linear(NULL, MAX8997_IRQ_NR,
+					&max8997_irq_domain_ops, max8997);
+	if (!domain) {
+		dev_err(max8997->dev, "could not create irq domain\n");
+		return -ENODEV;
 	}
+	max8997->irq_domain = domain;
 
 	ret = request_threaded_irq(max8997->irq, NULL, max8997_irq_thread,
 			IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
diff --git a/drivers/mfd/max8997.c b/drivers/mfd/max8997.c
index cb83a7a..20ecad3 100644
--- a/drivers/mfd/max8997.c
+++ b/drivers/mfd/max8997.c
@@ -143,7 +143,6 @@ static int max8997_i2c_probe(struct i2c_client *i2c,
 	if (!pdata)
 		goto err;
 
-	max8997->irq_base = pdata->irq_base;
 	max8997->ono = pdata->ono;
 
 	mutex_init(&max8997->iolock);
diff --git a/include/linux/mfd/max8997-private.h b/include/linux/mfd/max8997-private.h
index 3f4deb6..830152c 100644
--- a/include/linux/mfd/max8997-private.h
+++ b/include/linux/mfd/max8997-private.h
@@ -23,6 +23,8 @@
 #define __LINUX_MFD_MAX8997_PRIV_H
 
 #include <linux/i2c.h>
+#include <linux/export.h>
+#include <linux/irqdomain.h>
 
 #define MAX8997_REG_INVALID	(0xff)
 
@@ -325,7 +327,7 @@ struct max8997_dev {
 
 	int irq;
 	int ono;
-	int irq_base;
+	struct irq_domain *irq_domain;
 	struct mutex irqlock;
 	int irq_masks_cur[MAX8997_IRQ_GROUP_NR];
 	int irq_masks_cache[MAX8997_IRQ_GROUP_NR];
diff --git a/include/linux/mfd/max8997.h b/include/linux/mfd/max8997.h
index b40c08c..328d8e2 100644
--- a/include/linux/mfd/max8997.h
+++ b/include/linux/mfd/max8997.h
@@ -181,7 +181,6 @@ struct max8997_led_platform_data {
 
 struct max8997_platform_data {
 	/* IRQ */
-	int irq_base;
 	int ono;
 	int wakeup;
 
-- 
1.7.0.4


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

* Re: [PATCH 1/2] mfd: add irq domain support for max8997 interrupts
  2012-06-21  1:10 [PATCH 1/2] mfd: add irq domain support for max8997 interrupts Chanwoo Choi
@ 2012-06-21  9:54 ` Mark Brown
  2012-06-22  0:30   ` Chanwoo Choi
  0 siblings, 1 reply; 22+ messages in thread
From: Mark Brown @ 2012-06-21  9:54 UTC (permalink / raw)
  To: Chanwoo Choi
  Cc: gregkh, thomas.abraham, grant.likely, sameo, myungjoo.ham,
	kyungmin.park, linux-kernel

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

On Thu, Jun 21, 2012 at 10:10:40AM +0900, Chanwoo Choi wrote:

> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

Small procedural thing: it's not Signed-off-by as I didn't write or
forward the patch, I'll have sent a Reviwed-by or something.

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

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

* Re: [PATCH 1/2] mfd: add irq domain support for max8997 interrupts
  2012-06-21  9:54 ` Mark Brown
@ 2012-06-22  0:30   ` Chanwoo Choi
  0 siblings, 0 replies; 22+ messages in thread
From: Chanwoo Choi @ 2012-06-22  0:30 UTC (permalink / raw)
  To: Mark Brown
  Cc: gregkh, thomas.abraham, grant.likely, sameo, myungjoo.ham,
	kyungmin.park, linux-kernel

On 06/21/2012 06:54 PM, Mark Brown wrote:

> On Thu, Jun 21, 2012 at 10:10:40AM +0900, Chanwoo Choi wrote:
> 
>> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
> 
> Small procedural thing: it's not Signed-off-by as I didn't write or
> forward the patch, I'll have sent a Reviwed-by or something.


This patch based on below patch was modified, I should remove your
Signed-off-by.
I will resend it without your Signed-off-by. Sorry.

http://git.kernel.org/?p=linux/kernel/git/broonie/regulator.git;a=commit;h=98d8618af37728f6e18e84110ddb99987b47dd12

Thank you,
Chanwoo Choi


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

* [PATCH 1/2] mfd: add irq domain support for max8997 interrupts
@ 2012-05-10 10:55 Chanwoo Choi
  0 siblings, 0 replies; 22+ messages in thread
From: Chanwoo Choi @ 2012-05-10 10:55 UTC (permalink / raw)
  To: gregkh, broonie, thomas.abraham
  Cc: myungjoo.ham, kyungmin.park, jonghwa3.lee, linux-kernel, Chanwoo Choi

From: Thomas Abraham <thomas.abraham@linaro.org>

From: Thomas Abraham <thomas.abraham@linaro.org>

Add irq domain support for max8997 interrupts. The reverse mapping method
used is linear mapping since the sub-drivers of max8997 such as regulator
and charger drivers can use the max8997 irq_domain to get the linux irq
number for max8997 interrupts. All uses of irq_base in platform data and
max8997 driver private data are removed.

Signed-off-by: Thomas Abraham <thomas.abraham@linaro.org>
Acked-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Acked-by: Grant Likely <grant.likely@secretlab.ca>
Acked-by: Samuel Ortiz <sameo@linux.intel.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
	[Fix two bug which set max8997->irq_domain and correct wrong parameter]
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
 arch/arm/mach-exynos/mach-nuri.c    |    4 --
 arch/arm/mach-exynos/mach-origen.c  |    1 -
 drivers/mfd/max8997-irq.c           |   62 +++++++++++++++++++++--------------
 drivers/mfd/max8997.c               |    1 -
 include/linux/mfd/max8997-private.h |    4 ++-
 include/linux/mfd/max8997.h         |    1 -
 6 files changed, 40 insertions(+), 33 deletions(-)

diff --git a/arch/arm/mach-exynos/mach-nuri.c b/arch/arm/mach-exynos/mach-nuri.c
index 23d2254..0a53849 100644
--- a/arch/arm/mach-exynos/mach-nuri.c
+++ b/arch/arm/mach-exynos/mach-nuri.c
@@ -1064,12 +1064,8 @@ static struct platform_device nuri_max8903_device = {
 static void __init nuri_power_init(void)
 {
 	int gpio;
-	int irq_base = IRQ_GPIO_END + 1;
 	int ta_en = 0;
 
-	nuri_max8997_pdata.irq_base = irq_base;
-	irq_base += MAX8997_IRQ_NR;
-
 	gpio = EXYNOS4_GPX0(7);
 	gpio_request(gpio, "AP_PMIC_IRQ");
 	s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf));
diff --git a/arch/arm/mach-exynos/mach-origen.c b/arch/arm/mach-exynos/mach-origen.c
index 827cb99..d3b2e9d 100644
--- a/arch/arm/mach-exynos/mach-origen.c
+++ b/arch/arm/mach-exynos/mach-origen.c
@@ -424,7 +424,6 @@ static struct max8997_platform_data __initdata origen_max8997_pdata = {
 	.buck1_gpiodvs	= false,
 	.buck2_gpiodvs	= false,
 	.buck5_gpiodvs	= false,
-	.irq_base	= IRQ_GPIO_END + 1,
 
 	.ignore_gpiodvs_side_effect = true,
 	.buck125_default_idx = 0x0,
diff --git a/drivers/mfd/max8997-irq.c b/drivers/mfd/max8997-irq.c
index 87cdfbd..3454855 100644
--- a/drivers/mfd/max8997-irq.c
+++ b/drivers/mfd/max8997-irq.c
@@ -142,7 +142,8 @@ static void max8997_irq_sync_unlock(struct irq_data *data)
 static const inline struct max8997_irq_data *
 irq_to_max8997_irq(struct max8997_dev *max8997, int irq)
 {
-	return &max8997_irqs[irq - max8997->irq_base];
+	struct irq_data *data = irq_get_irq_data(irq);
+	return &max8997_irqs[data->hwirq];
 }
 
 static void max8997_irq_mask(struct irq_data *data)
@@ -182,7 +183,7 @@ static irqreturn_t max8997_irq_thread(int irq, void *data)
 	u8 irq_reg[MAX8997_IRQ_GROUP_NR] = {};
 	u8 irq_src;
 	int ret;
-	int i;
+	int i, cur_irq;
 
 	ret = max8997_read_reg(max8997->i2c, MAX8997_REG_INTSRC, &irq_src);
 	if (ret < 0) {
@@ -269,8 +270,11 @@ static irqreturn_t max8997_irq_thread(int irq, void *data)
 
 	/* Report */
 	for (i = 0; i < MAX8997_IRQ_NR; i++) {
-		if (irq_reg[max8997_irqs[i].group] & max8997_irqs[i].mask)
-			handle_nested_irq(max8997->irq_base + i);
+		if (irq_reg[max8997_irqs[i].group] & max8997_irqs[i].mask) {
+			cur_irq = irq_find_mapping(max8997->irq_domain, i);
+			if (cur_irq)
+				handle_nested_irq(cur_irq);
+		}
 	}
 
 	return IRQ_HANDLED;
@@ -278,26 +282,40 @@ static irqreturn_t max8997_irq_thread(int irq, void *data)
 
 int max8997_irq_resume(struct max8997_dev *max8997)
 {
-	if (max8997->irq && max8997->irq_base)
-		max8997_irq_thread(max8997->irq_base, max8997);
+	if (max8997->irq && max8997->irq_domain)
+		max8997_irq_thread(0, max8997);
+	return 0;
+}
+
+static int max8997_irq_domain_map(struct irq_domain *d, unsigned int irq,
+					irq_hw_number_t hw)
+{
+	struct max8997_dev *max8997 = d->host_data;
+
+	irq_set_chip_data(irq, max8997);
+	irq_set_chip_and_handler(irq, &max8997_irq_chip, handle_edge_irq);
+	irq_set_nested_thread(irq, 1);
+#ifdef CONFIG_ARM
+	set_irq_flags(irq, IRQF_VALID);
+#else
+	irq_set_noprobe(irq);
+#endif
 	return 0;
 }
 
+static struct irq_domain_ops max8997_irq_domain_ops = {
+	.map = max8997_irq_domain_map,
+};
+
 int max8997_irq_init(struct max8997_dev *max8997)
 {
+	struct irq_domain *domain;
 	int i;
-	int cur_irq;
 	int ret;
 	u8 val;
 
 	if (!max8997->irq) {
 		dev_warn(max8997->dev, "No interrupt specified.\n");
-		max8997->irq_base = 0;
-		return 0;
-	}
-
-	if (!max8997->irq_base) {
-		dev_err(max8997->dev, "No interrupt base specified.\n");
 		return 0;
 	}
 
@@ -327,19 +345,13 @@ int max8997_irq_init(struct max8997_dev *max8997)
 					true : false;
 	}
 
-	/* Register with genirq */
-	for (i = 0; i < MAX8997_IRQ_NR; i++) {
-		cur_irq = i + max8997->irq_base;
-		irq_set_chip_data(cur_irq, max8997);
-		irq_set_chip_and_handler(cur_irq, &max8997_irq_chip,
-				handle_edge_irq);
-		irq_set_nested_thread(cur_irq, 1);
-#ifdef CONFIG_ARM
-		set_irq_flags(cur_irq, IRQF_VALID);
-#else
-		irq_set_noprobe(cur_irq);
-#endif
+	domain = irq_domain_add_linear(NULL, MAX8997_IRQ_NR,
+					&max8997_irq_domain_ops, max8997);
+	if (!domain) {
+		dev_err(max8997->dev, "could not create irq domain\n");
+		return -ENODEV;
 	}
+	max8997->irq_domain = domain;
 
 	ret = request_threaded_irq(max8997->irq, NULL, max8997_irq_thread,
 			IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
diff --git a/drivers/mfd/max8997.c b/drivers/mfd/max8997.c
index cb83a7a..20ecad3 100644
--- a/drivers/mfd/max8997.c
+++ b/drivers/mfd/max8997.c
@@ -143,7 +143,6 @@ static int max8997_i2c_probe(struct i2c_client *i2c,
 	if (!pdata)
 		goto err;
 
-	max8997->irq_base = pdata->irq_base;
 	max8997->ono = pdata->ono;
 
 	mutex_init(&max8997->iolock);
diff --git a/include/linux/mfd/max8997-private.h b/include/linux/mfd/max8997-private.h
index 3f4deb6..830152c 100644
--- a/include/linux/mfd/max8997-private.h
+++ b/include/linux/mfd/max8997-private.h
@@ -23,6 +23,8 @@
 #define __LINUX_MFD_MAX8997_PRIV_H
 
 #include <linux/i2c.h>
+#include <linux/export.h>
+#include <linux/irqdomain.h>
 
 #define MAX8997_REG_INVALID	(0xff)
 
@@ -325,7 +327,7 @@ struct max8997_dev {
 
 	int irq;
 	int ono;
-	int irq_base;
+	struct irq_domain *irq_domain;
 	struct mutex irqlock;
 	int irq_masks_cur[MAX8997_IRQ_GROUP_NR];
 	int irq_masks_cache[MAX8997_IRQ_GROUP_NR];
diff --git a/include/linux/mfd/max8997.h b/include/linux/mfd/max8997.h
index b40c08c..328d8e2 100644
--- a/include/linux/mfd/max8997.h
+++ b/include/linux/mfd/max8997.h
@@ -181,7 +181,6 @@ struct max8997_led_platform_data {
 
 struct max8997_platform_data {
 	/* IRQ */
-	int irq_base;
 	int ono;
 	int wakeup;
 
-- 
1.7.0.4


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

* Re: [PATCH 1/2] mfd: add irq domain support for max8997 interrupts
  2011-12-09  7:19               ` Thomas Abraham
@ 2011-12-09  8:15                 ` Mark Brown
  -1 siblings, 0 replies; 22+ messages in thread
From: Mark Brown @ 2011-12-09  8:15 UTC (permalink / raw)
  To: Thomas Abraham
  Cc: linux-kernel, rpurdie, rob.herring, grant.likely, kgene.kim,
	myungjoo.ham, kyungmin.park, dg77.kim, linux-arm-kernel,
	linux-samsung-soc

On Fri, Dec 09, 2011 at 12:49:49PM +0530, Thomas Abraham wrote:
> On 9 December 2011 12:09, Mark Brown

> > How would you provide this interrupt to the device using it in a non-DT
> > systemm without passing the irq_base into the device as platform data?

> In non-DT system, the linux irq number that is used to register the
> gpio interrupt notifier would belong to the irq domain of the host
> interrupt controller (gic). For Exynos, the linux irq numbers that
> belong to the gic irq domain are statically assigned to specific
> interrupt notifiers and known to the entire system.

This seems like it's going to be a bit of a usability issue at best as
users will have to figure out the relevant domain and the offset we end
up with within it, and you appear to be making assumptions about the
system you're running on here.  The way this has been handled for other
drivers is by using irq_alloc_descs with platform data to provide a
default, preserving the old behaviour on non-OF systems.

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

* [PATCH 1/2] mfd: add irq domain support for max8997 interrupts
@ 2011-12-09  8:15                 ` Mark Brown
  0 siblings, 0 replies; 22+ messages in thread
From: Mark Brown @ 2011-12-09  8:15 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Dec 09, 2011 at 12:49:49PM +0530, Thomas Abraham wrote:
> On 9 December 2011 12:09, Mark Brown

> > How would you provide this interrupt to the device using it in a non-DT
> > systemm without passing the irq_base into the device as platform data?

> In non-DT system, the linux irq number that is used to register the
> gpio interrupt notifier would belong to the irq domain of the host
> interrupt controller (gic). For Exynos, the linux irq numbers that
> belong to the gic irq domain are statically assigned to specific
> interrupt notifiers and known to the entire system.

This seems like it's going to be a bit of a usability issue at best as
users will have to figure out the relevant domain and the offset we end
up with within it, and you appear to be making assumptions about the
system you're running on here.  The way this has been handled for other
drivers is by using irq_alloc_descs with platform data to provide a
default, preserving the old behaviour on non-OF systems.

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

* Re: [PATCH 1/2] mfd: add irq domain support for max8997 interrupts
  2011-12-09  6:39             ` Mark Brown
@ 2011-12-09  7:19               ` Thomas Abraham
  -1 siblings, 0 replies; 22+ messages in thread
From: Thomas Abraham @ 2011-12-09  7:19 UTC (permalink / raw)
  To: Mark Brown
  Cc: linux-kernel, rpurdie, rob.herring, grant.likely, kgene.kim,
	myungjoo.ham, kyungmin.park, dg77.kim, linux-arm-kernel,
	linux-samsung-soc

On 9 December 2011 12:09, Mark Brown
<broonie@opensource.wolfsonmicro.com> wrote:
> On Fri, Dec 09, 2011 at 12:00:07PM +0530, Thomas Abraham wrote:
>
>> If these gpio's are connected to the host system, and host system sets
>> up gpio interrupt notification for these gpio lines, the linux irq
>> number for the gpio interrupt would belong to the irq domain of the
>> host interrupt controller (gic irq domain in case of exynos).
>> Consumers of this interrupt would use the gpio interrupt independent
>> of the max8997 irq domain. So irq_base can be maintained private to
>> the max8997 mfd driver and its sub-block drivers.
>
> How would you provide this interrupt to the device using it in a non-DT
> systemm without passing the irq_base into the device as platform data?

In non-DT system, the linux irq number that is used to register the
gpio interrupt notifier would belong to the irq domain of the host
interrupt controller (gic). For Exynos, the linux irq numbers that
belong to the gic irq domain are statically assigned to specific
interrupt notifiers and known to the entire system.

For instance, the linux virq number for gpio interrupt for the gpio
connected from max8997 to Exynos GPIO (hypothetical case) would be
statically defined as GPIO_EINT_MAX8997_GPIO0. The device that
requires to be notified of this interrupt would request_irq or
setup_irq using this macro and hence needs no knowledge of the
irq_base of the max8997 irq domain.

If the system uses sparse irqs, or if static mapping of linux virq's
are not possible in a system, that is a problem that this patch does
not address. irq_domain of max8997 is self contained to provide all
max8997 linux irq numbers required by the sub-block drivers of
max8997.

Thanks,
Thomas.

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

* [PATCH 1/2] mfd: add irq domain support for max8997 interrupts
@ 2011-12-09  7:19               ` Thomas Abraham
  0 siblings, 0 replies; 22+ messages in thread
From: Thomas Abraham @ 2011-12-09  7:19 UTC (permalink / raw)
  To: linux-arm-kernel

On 9 December 2011 12:09, Mark Brown
<broonie@opensource.wolfsonmicro.com> wrote:
> On Fri, Dec 09, 2011 at 12:00:07PM +0530, Thomas Abraham wrote:
>
>> If these gpio's are connected to the host system, and host system sets
>> up gpio interrupt notification for these gpio lines, the linux irq
>> number for the gpio interrupt would belong to the irq domain of the
>> host interrupt controller (gic irq domain in case of exynos).
>> Consumers of this interrupt would use the gpio interrupt independent
>> of the max8997 irq domain. So irq_base can be maintained private to
>> the max8997 mfd driver and its sub-block drivers.
>
> How would you provide this interrupt to the device using it in a non-DT
> systemm without passing the irq_base into the device as platform data?

In non-DT system, the linux irq number that is used to register the
gpio interrupt notifier would belong to the irq domain of the host
interrupt controller (gic). For Exynos, the linux irq numbers that
belong to the gic irq domain are statically assigned to specific
interrupt notifiers and known to the entire system.

For instance, the linux virq number for gpio interrupt for the gpio
connected from max8997 to Exynos GPIO (hypothetical case) would be
statically defined as GPIO_EINT_MAX8997_GPIO0. The device that
requires to be notified of this interrupt would request_irq or
setup_irq using this macro and hence needs no knowledge of the
irq_base of the max8997 irq domain.

If the system uses sparse irqs, or if static mapping of linux virq's
are not possible in a system, that is a problem that this patch does
not address. irq_domain of max8997 is self contained to provide all
max8997 linux irq numbers required by the sub-block drivers of
max8997.

Thanks,
Thomas.

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

* Re: [PATCH 1/2] mfd: add irq domain support for max8997 interrupts
  2011-12-09  6:30           ` Thomas Abraham
@ 2011-12-09  6:39             ` Mark Brown
  -1 siblings, 0 replies; 22+ messages in thread
From: Mark Brown @ 2011-12-09  6:39 UTC (permalink / raw)
  To: Thomas Abraham
  Cc: linux-kernel, rpurdie, rob.herring, grant.likely, kgene.kim,
	myungjoo.ham, kyungmin.park, dg77.kim, linux-arm-kernel,
	linux-samsung-soc

On Fri, Dec 09, 2011 at 12:00:07PM +0530, Thomas Abraham wrote:

> If these gpio's are connected to the host system, and host system sets
> up gpio interrupt notification for these gpio lines, the linux irq
> number for the gpio interrupt would belong to the irq domain of the
> host interrupt controller (gic irq domain in case of exynos).
> Consumers of this interrupt would use the gpio interrupt independent
> of the max8997 irq domain. So irq_base can be maintained private to
> the max8997 mfd driver and its sub-block drivers.

How would you provide this interrupt to the device using it in a non-DT
systemm without passing the irq_base into the device as platform data?

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

* [PATCH 1/2] mfd: add irq domain support for max8997 interrupts
@ 2011-12-09  6:39             ` Mark Brown
  0 siblings, 0 replies; 22+ messages in thread
From: Mark Brown @ 2011-12-09  6:39 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Dec 09, 2011 at 12:00:07PM +0530, Thomas Abraham wrote:

> If these gpio's are connected to the host system, and host system sets
> up gpio interrupt notification for these gpio lines, the linux irq
> number for the gpio interrupt would belong to the irq domain of the
> host interrupt controller (gic irq domain in case of exynos).
> Consumers of this interrupt would use the gpio interrupt independent
> of the max8997 irq domain. So irq_base can be maintained private to
> the max8997 mfd driver and its sub-block drivers.

How would you provide this interrupt to the device using it in a non-DT
systemm without passing the irq_base into the device as platform data?

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

* Re: [PATCH 1/2] mfd: add irq domain support for max8997 interrupts
  2011-12-09  6:02         ` Mark Brown
@ 2011-12-09  6:30           ` Thomas Abraham
  -1 siblings, 0 replies; 22+ messages in thread
From: Thomas Abraham @ 2011-12-09  6:30 UTC (permalink / raw)
  To: Mark Brown
  Cc: linux-kernel, rpurdie, rob.herring, grant.likely, kgene.kim,
	myungjoo.ham, kyungmin.park, dg77.kim, linux-arm-kernel,
	linux-samsung-soc

On 9 December 2011 11:32, Mark Brown
<broonie@opensource.wolfsonmicro.com> wrote:
> On Fri, Dec 09, 2011 at 10:55:10AM +0530, Thomas Abraham wrote:
>> On 9 December 2011 10:11, Mark Brown
>
>> > Removing irq_base from platform data isn't going to be helpful for
>> > anyone using the driver on non-DT platforms as it's going to make it
>> > impossible to find the interrupts.
>
>> All the consumers of the max8997 interrupts are the drivers for the
>> sub-blocks of max8997. These drivers have access to 'irq_domain'
>> member of 'struct max8997_dev', From irq_domain, the sub-block driver
>> can get the irq_base and add one of the 'enum max8997_irq' offset when
>> registering for interrupt notifications.
>
> There's no GPIOs with interrupt support (even if they're not implemented
> yet)?

Ok. There does seem to be 12 gpios supported by max8997, but not used
on the origen board.

If these gpio's are connected to the host system, and host system sets
up gpio interrupt notification for these gpio lines, the linux irq
number for the gpio interrupt would belong to the irq domain of the
host interrupt controller (gic irq domain in case of exynos).
Consumers of this interrupt would use the gpio interrupt independent
of the max8997 irq domain. So irq_base can be maintained private to
the max8997 mfd driver and its sub-block drivers.

Thanks,
Thomas.

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

* [PATCH 1/2] mfd: add irq domain support for max8997 interrupts
@ 2011-12-09  6:30           ` Thomas Abraham
  0 siblings, 0 replies; 22+ messages in thread
From: Thomas Abraham @ 2011-12-09  6:30 UTC (permalink / raw)
  To: linux-arm-kernel

On 9 December 2011 11:32, Mark Brown
<broonie@opensource.wolfsonmicro.com> wrote:
> On Fri, Dec 09, 2011 at 10:55:10AM +0530, Thomas Abraham wrote:
>> On 9 December 2011 10:11, Mark Brown
>
>> > Removing irq_base from platform data isn't going to be helpful for
>> > anyone using the driver on non-DT platforms as it's going to make it
>> > impossible to find the interrupts.
>
>> All the consumers of the max8997 interrupts are the drivers for the
>> sub-blocks of max8997. These drivers have access to 'irq_domain'
>> member of 'struct max8997_dev', From irq_domain, the sub-block driver
>> can get the irq_base and add one of the 'enum max8997_irq' offset when
>> registering for interrupt notifications.
>
> There's no GPIOs with interrupt support (even if they're not implemented
> yet)?

Ok. There does seem to be 12 gpios supported by max8997, but not used
on the origen board.

If these gpio's are connected to the host system, and host system sets
up gpio interrupt notification for these gpio lines, the linux irq
number for the gpio interrupt would belong to the irq domain of the
host interrupt controller (gic irq domain in case of exynos).
Consumers of this interrupt would use the gpio interrupt independent
of the max8997 irq domain. So irq_base can be maintained private to
the max8997 mfd driver and its sub-block drivers.

Thanks,
Thomas.

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

* Re: [PATCH 1/2] mfd: add irq domain support for max8997 interrupts
  2011-12-09  5:25       ` Thomas Abraham
@ 2011-12-09  6:02         ` Mark Brown
  -1 siblings, 0 replies; 22+ messages in thread
From: Mark Brown @ 2011-12-09  6:02 UTC (permalink / raw)
  To: Thomas Abraham
  Cc: linux-kernel, rpurdie, rob.herring, grant.likely, kgene.kim,
	myungjoo.ham, kyungmin.park, dg77.kim, linux-arm-kernel,
	linux-samsung-soc

On Fri, Dec 09, 2011 at 10:55:10AM +0530, Thomas Abraham wrote:
> On 9 December 2011 10:11, Mark Brown

> > Removing irq_base from platform data isn't going to be helpful for
> > anyone using the driver on non-DT platforms as it's going to make it
> > impossible to find the interrupts.

> All the consumers of the max8997 interrupts are the drivers for the
> sub-blocks of max8997. These drivers have access to 'irq_domain'
> member of 'struct max8997_dev', From irq_domain, the sub-block driver
> can get the irq_base and add one of the 'enum max8997_irq' offset when
> registering for interrupt notifications.

There's no GPIOs with interrupt support (even if they're not implemented
yet)?

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

* [PATCH 1/2] mfd: add irq domain support for max8997 interrupts
@ 2011-12-09  6:02         ` Mark Brown
  0 siblings, 0 replies; 22+ messages in thread
From: Mark Brown @ 2011-12-09  6:02 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Dec 09, 2011 at 10:55:10AM +0530, Thomas Abraham wrote:
> On 9 December 2011 10:11, Mark Brown

> > Removing irq_base from platform data isn't going to be helpful for
> > anyone using the driver on non-DT platforms as it's going to make it
> > impossible to find the interrupts.

> All the consumers of the max8997 interrupts are the drivers for the
> sub-blocks of max8997. These drivers have access to 'irq_domain'
> member of 'struct max8997_dev', From irq_domain, the sub-block driver
> can get the irq_base and add one of the 'enum max8997_irq' offset when
> registering for interrupt notifications.

There's no GPIOs with interrupt support (even if they're not implemented
yet)?

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

* Re: [PATCH 1/2] mfd: add irq domain support for max8997 interrupts
  2011-12-09  4:41     ` Mark Brown
@ 2011-12-09  5:25       ` Thomas Abraham
  -1 siblings, 0 replies; 22+ messages in thread
From: Thomas Abraham @ 2011-12-09  5:25 UTC (permalink / raw)
  To: Mark Brown
  Cc: linux-kernel, rpurdie, rob.herring, grant.likely, kgene.kim,
	myungjoo.ham, kyungmin.park, dg77.kim, linux-arm-kernel,
	linux-samsung-soc

Hi Mark,

On 9 December 2011 10:11, Mark Brown
<broonie@opensource.wolfsonmicro.com> wrote:
> On Thu, Dec 08, 2011 at 09:57:38PM +0530, Thomas Abraham wrote:
>
> You should be sending this to Samuel for review as it's a MFD patch.

Ok. I will Cc Samuel for the v2 of this patchset.

>
>> Add irq domain support for max8997 interrupts. All uses of irq_base in platform
>> data and max8997 driver private data are removed.
>
> Removing irq_base from platform data isn't going to be helpful for
> anyone using the driver on non-DT platforms as it's going to make it
> impossible to find the interrupts.

All the consumers of the max8997 interrupts are the drivers for the
sub-blocks of max8997. These drivers have access to 'irq_domain'
member of 'struct max8997_dev', From irq_domain, the sub-block driver
can get the irq_base and add one of the 'enum max8997_irq' offset when
registering for interrupt notifications.

So irq_base from platform data and all uses of it was removed. All
max8997 sub-block drivers should use the irq_base of the irq_domain.

Thanks for your review.

Regards,
Thomas.

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

* [PATCH 1/2] mfd: add irq domain support for max8997 interrupts
@ 2011-12-09  5:25       ` Thomas Abraham
  0 siblings, 0 replies; 22+ messages in thread
From: Thomas Abraham @ 2011-12-09  5:25 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Mark,

On 9 December 2011 10:11, Mark Brown
<broonie@opensource.wolfsonmicro.com> wrote:
> On Thu, Dec 08, 2011 at 09:57:38PM +0530, Thomas Abraham wrote:
>
> You should be sending this to Samuel for review as it's a MFD patch.

Ok. I will Cc Samuel for the v2 of this patchset.

>
>> Add irq domain support for max8997 interrupts. All uses of irq_base in platform
>> data and max8997 driver private data are removed.
>
> Removing irq_base from platform data isn't going to be helpful for
> anyone using the driver on non-DT platforms as it's going to make it
> impossible to find the interrupts.

All the consumers of the max8997 interrupts are the drivers for the
sub-blocks of max8997. These drivers have access to 'irq_domain'
member of 'struct max8997_dev', From irq_domain, the sub-block driver
can get the irq_base and add one of the 'enum max8997_irq' offset when
registering for interrupt notifications.

So irq_base from platform data and all uses of it was removed. All
max8997 sub-block drivers should use the irq_base of the irq_domain.

Thanks for your review.

Regards,
Thomas.

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

* Re: [PATCH 1/2] mfd: add irq domain support for max8997 interrupts
  2011-12-08 16:27   ` Thomas Abraham
@ 2011-12-09  4:41     ` Mark Brown
  -1 siblings, 0 replies; 22+ messages in thread
From: Mark Brown @ 2011-12-09  4:41 UTC (permalink / raw)
  To: Thomas Abraham
  Cc: linux-kernel, rpurdie, rob.herring, grant.likely, kgene.kim,
	myungjoo.ham, kyungmin.park, dg77.kim, linux-arm-kernel,
	linux-samsung-soc

On Thu, Dec 08, 2011 at 09:57:38PM +0530, Thomas Abraham wrote:

You should be sending this to Samuel for review as it's a MFD patch.

> Add irq domain support for max8997 interrupts. All uses of irq_base in platform
> data and max8997 driver private data are removed.

Removing irq_base from platform data isn't going to be helpful for
anyone using the driver on non-DT platforms as it's going to make it
impossible to find the interrupts.

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

* [PATCH 1/2] mfd: add irq domain support for max8997 interrupts
@ 2011-12-09  4:41     ` Mark Brown
  0 siblings, 0 replies; 22+ messages in thread
From: Mark Brown @ 2011-12-09  4:41 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Dec 08, 2011 at 09:57:38PM +0530, Thomas Abraham wrote:

You should be sending this to Samuel for review as it's a MFD patch.

> Add irq domain support for max8997 interrupts. All uses of irq_base in platform
> data and max8997 driver private data are removed.

Removing irq_base from platform data isn't going to be helpful for
anyone using the driver on non-DT platforms as it's going to make it
impossible to find the interrupts.

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

* Re: [PATCH 1/2] mfd: add irq domain support for max8997 interrupts
  2011-12-08 16:27   ` Thomas Abraham
@ 2011-12-09  4:00     ` MyungJoo Ham
  -1 siblings, 0 replies; 22+ messages in thread
From: MyungJoo Ham @ 2011-12-09  4:00 UTC (permalink / raw)
  To: Thomas Abraham
  Cc: linux-kernel, rpurdie, rob.herring, grant.likely, kgene.kim,
	broonie, kyungmin.park, dg77.kim, linux-arm-kernel,
	linux-samsung-soc

On Fri, Dec 9, 2011 at 1:27 AM, Thomas Abraham
<thomas.abraham@linaro.org> wrote:
> Add irq domain support for max8997 interrupts. All uses of irq_base in platform
> data and max8997 driver private data are removed.
>
> Cc: MyungJoo Ham <myungjoo.ham@samsung.com>
> Signed-off-by: Thomas Abraham <thomas.abraham@linaro.org>

Looks good to me.

Acked-by: MyungJoo Ham <myungjoo.ham@samsung.com>

> ---
>  arch/arm/mach-exynos/mach-nuri.c    |    4 ----
>  arch/arm/mach-exynos/mach-origen.c  |    1 -
>  drivers/mfd/max8997-irq.c           |   33 +++++++++++++++++++--------------
>  drivers/mfd/max8997.c               |    1 -
>  include/linux/mfd/max8997-private.h |    4 +++-
>  include/linux/mfd/max8997.h         |    1 -
>  6 files changed, 22 insertions(+), 22 deletions(-)
>
> diff --git a/arch/arm/mach-exynos/mach-nuri.c b/arch/arm/mach-exynos/mach-nuri.c
> index 236bbe1..ae333e5 100644
> --- a/arch/arm/mach-exynos/mach-nuri.c
> +++ b/arch/arm/mach-exynos/mach-nuri.c
> @@ -1077,12 +1077,8 @@ static struct platform_device nuri_max8903_device = {
>  static void __init nuri_power_init(void)
>  {
>        int gpio;
> -       int irq_base = IRQ_GPIO_END + 1;
>        int ta_en = 0;
>
> -       nuri_max8997_pdata.irq_base = irq_base;
> -       irq_base += MAX8997_IRQ_NR;
> -
>        gpio = EXYNOS4_GPX0(7);
>        gpio_request(gpio, "AP_PMIC_IRQ");
>        s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf));
> diff --git a/arch/arm/mach-exynos/mach-origen.c b/arch/arm/mach-exynos/mach-origen.c
> index f56d027..588b0a8 100644
> --- a/arch/arm/mach-exynos/mach-origen.c
> +++ b/arch/arm/mach-exynos/mach-origen.c
> @@ -421,7 +421,6 @@ struct max8997_platform_data __initdata origen_max8997_pdata = {
>        .buck1_gpiodvs  = false,
>        .buck2_gpiodvs  = false,
>        .buck5_gpiodvs  = false,
> -       .irq_base       = IRQ_GPIO_END + 1,
>
>        .ignore_gpiodvs_side_effect = true,
>        .buck125_default_idx = 0x0,
> diff --git a/drivers/mfd/max8997-irq.c b/drivers/mfd/max8997-irq.c
> index 09274cf..eb9cad5 100644
> --- a/drivers/mfd/max8997-irq.c
> +++ b/drivers/mfd/max8997-irq.c
> @@ -142,7 +142,8 @@ static void max8997_irq_sync_unlock(struct irq_data *data)
>  static const inline struct max8997_irq_data *
>  irq_to_max8997_irq(struct max8997_dev *max8997, int irq)
>  {
> -       return &max8997_irqs[irq - max8997->irq_base];
> +       struct irq_data *data = irq_get_irq_data(irq);
> +       return &max8997_irqs[data->hwirq];
>  }
>
>  static void max8997_irq_mask(struct irq_data *data)
> @@ -179,10 +180,11 @@ static struct irq_chip max8997_irq_chip = {
>  static irqreturn_t max8997_irq_thread(int irq, void *data)
>  {
>        struct max8997_dev *max8997 = data;
> +       struct irq_domain *domain = &max8997->irq_domain;
>        u8 irq_reg[MAX8997_IRQ_GROUP_NR] = {};
>        u8 irq_src;
>        int ret;
> -       int i;
> +       int i, cur_irq;
>
>        ret = max8997_read_reg(max8997->i2c, MAX8997_REG_INTSRC, &irq_src);
>        if (ret < 0) {
> @@ -268,9 +270,9 @@ static irqreturn_t max8997_irq_thread(int irq, void *data)
>                irq_reg[i] &= ~max8997->irq_masks_cur[i];
>
>        /* Report */
> -       for (i = 0; i < MAX8997_IRQ_NR; i++) {
> +       irq_domain_for_each_irq(domain, i, cur_irq) {
>                if (irq_reg[max8997_irqs[i].group] & max8997_irqs[i].mask)
> -                       handle_nested_irq(max8997->irq_base + i);
> +                       handle_nested_irq(cur_irq);
>        }
>
>        return IRQ_HANDLED;
> @@ -278,13 +280,14 @@ static irqreturn_t max8997_irq_thread(int irq, void *data)
>
>  int max8997_irq_resume(struct max8997_dev *max8997)
>  {
> -       if (max8997->irq && max8997->irq_base)
> -               max8997_irq_thread(max8997->irq_base, max8997);
> +       if (max8997->irq && max8997->irq_domain.irq_base)
> +               max8997_irq_thread(max8997->irq_domain.irq_base, max8997);
>        return 0;
>  }
>
>  int max8997_irq_init(struct max8997_dev *max8997)
>  {
> +       struct irq_domain *domain = &max8997->irq_domain;
>        int i;
>        int cur_irq;
>        int ret;
> @@ -292,12 +295,6 @@ int max8997_irq_init(struct max8997_dev *max8997)
>
>        if (!max8997->irq) {
>                dev_warn(max8997->dev, "No interrupt specified.\n");
> -               max8997->irq_base = 0;
> -               return 0;
> -       }
> -
> -       if (!max8997->irq_base) {
> -               dev_err(max8997->dev, "No interrupt base specified.\n");
>                return 0;
>        }
>
> @@ -327,9 +324,17 @@ int max8997_irq_init(struct max8997_dev *max8997)
>                                        true : false;
>        }
>
> +       domain->irq_base = irq_alloc_descs(-1, 0, MAX8997_IRQ_NR, 0);
> +       if (domain->irq_base < 0) {
> +               dev_err(max8997->dev, "failed to alloc irq descs\n");
> +               return 0;
> +       }
> +       domain->nr_irq = MAX8997_IRQ_NR;
> +       domain->ops = &irq_domain_simple_ops;
> +       irq_domain_add(domain);
> +
>        /* Register with genirq */
> -       for (i = 0; i < MAX8997_IRQ_NR; i++) {
> -               cur_irq = i + max8997->irq_base;
> +       irq_domain_for_each_irq(domain, i, cur_irq) {
>                irq_set_chip_data(cur_irq, max8997);
>                irq_set_chip_and_handler(cur_irq, &max8997_irq_chip,
>                                handle_edge_irq);
> diff --git a/drivers/mfd/max8997.c b/drivers/mfd/max8997.c
> index 5be53ae..b996c6e 100644
> --- a/drivers/mfd/max8997.c
> +++ b/drivers/mfd/max8997.c
> @@ -142,7 +142,6 @@ static int max8997_i2c_probe(struct i2c_client *i2c,
>        if (!pdata)
>                goto err;
>
> -       max8997->irq_base = pdata->irq_base;
>        max8997->ono = pdata->ono;
>
>        mutex_init(&max8997->iolock);
> diff --git a/include/linux/mfd/max8997-private.h b/include/linux/mfd/max8997-private.h
> index 3f4deb6..04c5779 100644
> --- a/include/linux/mfd/max8997-private.h
> +++ b/include/linux/mfd/max8997-private.h
> @@ -23,6 +23,8 @@
>  #define __LINUX_MFD_MAX8997_PRIV_H
>
>  #include <linux/i2c.h>
> +#include <linux/export.h>
> +#include <linux/irqdomain.h>
>
>  #define MAX8997_REG_INVALID    (0xff)
>
> @@ -325,7 +327,7 @@ struct max8997_dev {
>
>        int irq;
>        int ono;
> -       int irq_base;
> +       struct irq_domain irq_domain;
>        struct mutex irqlock;
>        int irq_masks_cur[MAX8997_IRQ_GROUP_NR];
>        int irq_masks_cache[MAX8997_IRQ_GROUP_NR];
> diff --git a/include/linux/mfd/max8997.h b/include/linux/mfd/max8997.h
> index 0bbd13d..1e0b9cc 100644
> --- a/include/linux/mfd/max8997.h
> +++ b/include/linux/mfd/max8997.h
> @@ -79,7 +79,6 @@ struct max8997_regulator_data {
>
>  struct max8997_platform_data {
>        /* IRQ */
> -       int irq_base;
>        int ono;
>        int wakeup;
>
> --
> 1.6.6.rc2
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
MyungJoo Ham, Ph.D.
Mobile Software Platform Lab, DMC Business, Samsung Electronics

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

* [PATCH 1/2] mfd: add irq domain support for max8997 interrupts
@ 2011-12-09  4:00     ` MyungJoo Ham
  0 siblings, 0 replies; 22+ messages in thread
From: MyungJoo Ham @ 2011-12-09  4:00 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Dec 9, 2011 at 1:27 AM, Thomas Abraham
<thomas.abraham@linaro.org> wrote:
> Add irq domain support for max8997 interrupts. All uses of irq_base in platform
> data and max8997 driver private data are removed.
>
> Cc: MyungJoo Ham <myungjoo.ham@samsung.com>
> Signed-off-by: Thomas Abraham <thomas.abraham@linaro.org>

Looks good to me.

Acked-by: MyungJoo Ham <myungjoo.ham@samsung.com>

> ---
> ?arch/arm/mach-exynos/mach-nuri.c ? ?| ? ?4 ----
> ?arch/arm/mach-exynos/mach-origen.c ?| ? ?1 -
> ?drivers/mfd/max8997-irq.c ? ? ? ? ? | ? 33 +++++++++++++++++++--------------
> ?drivers/mfd/max8997.c ? ? ? ? ? ? ? | ? ?1 -
> ?include/linux/mfd/max8997-private.h | ? ?4 +++-
> ?include/linux/mfd/max8997.h ? ? ? ? | ? ?1 -
> ?6 files changed, 22 insertions(+), 22 deletions(-)
>
> diff --git a/arch/arm/mach-exynos/mach-nuri.c b/arch/arm/mach-exynos/mach-nuri.c
> index 236bbe1..ae333e5 100644
> --- a/arch/arm/mach-exynos/mach-nuri.c
> +++ b/arch/arm/mach-exynos/mach-nuri.c
> @@ -1077,12 +1077,8 @@ static struct platform_device nuri_max8903_device = {
> ?static void __init nuri_power_init(void)
> ?{
> ? ? ? ?int gpio;
> - ? ? ? int irq_base = IRQ_GPIO_END + 1;
> ? ? ? ?int ta_en = 0;
>
> - ? ? ? nuri_max8997_pdata.irq_base = irq_base;
> - ? ? ? irq_base += MAX8997_IRQ_NR;
> -
> ? ? ? ?gpio = EXYNOS4_GPX0(7);
> ? ? ? ?gpio_request(gpio, "AP_PMIC_IRQ");
> ? ? ? ?s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf));
> diff --git a/arch/arm/mach-exynos/mach-origen.c b/arch/arm/mach-exynos/mach-origen.c
> index f56d027..588b0a8 100644
> --- a/arch/arm/mach-exynos/mach-origen.c
> +++ b/arch/arm/mach-exynos/mach-origen.c
> @@ -421,7 +421,6 @@ struct max8997_platform_data __initdata origen_max8997_pdata = {
> ? ? ? ?.buck1_gpiodvs ?= false,
> ? ? ? ?.buck2_gpiodvs ?= false,
> ? ? ? ?.buck5_gpiodvs ?= false,
> - ? ? ? .irq_base ? ? ? = IRQ_GPIO_END + 1,
>
> ? ? ? ?.ignore_gpiodvs_side_effect = true,
> ? ? ? ?.buck125_default_idx = 0x0,
> diff --git a/drivers/mfd/max8997-irq.c b/drivers/mfd/max8997-irq.c
> index 09274cf..eb9cad5 100644
> --- a/drivers/mfd/max8997-irq.c
> +++ b/drivers/mfd/max8997-irq.c
> @@ -142,7 +142,8 @@ static void max8997_irq_sync_unlock(struct irq_data *data)
> ?static const inline struct max8997_irq_data *
> ?irq_to_max8997_irq(struct max8997_dev *max8997, int irq)
> ?{
> - ? ? ? return &max8997_irqs[irq - max8997->irq_base];
> + ? ? ? struct irq_data *data = irq_get_irq_data(irq);
> + ? ? ? return &max8997_irqs[data->hwirq];
> ?}
>
> ?static void max8997_irq_mask(struct irq_data *data)
> @@ -179,10 +180,11 @@ static struct irq_chip max8997_irq_chip = {
> ?static irqreturn_t max8997_irq_thread(int irq, void *data)
> ?{
> ? ? ? ?struct max8997_dev *max8997 = data;
> + ? ? ? struct irq_domain *domain = &max8997->irq_domain;
> ? ? ? ?u8 irq_reg[MAX8997_IRQ_GROUP_NR] = {};
> ? ? ? ?u8 irq_src;
> ? ? ? ?int ret;
> - ? ? ? int i;
> + ? ? ? int i, cur_irq;
>
> ? ? ? ?ret = max8997_read_reg(max8997->i2c, MAX8997_REG_INTSRC, &irq_src);
> ? ? ? ?if (ret < 0) {
> @@ -268,9 +270,9 @@ static irqreturn_t max8997_irq_thread(int irq, void *data)
> ? ? ? ? ? ? ? ?irq_reg[i] &= ~max8997->irq_masks_cur[i];
>
> ? ? ? ?/* Report */
> - ? ? ? for (i = 0; i < MAX8997_IRQ_NR; i++) {
> + ? ? ? irq_domain_for_each_irq(domain, i, cur_irq) {
> ? ? ? ? ? ? ? ?if (irq_reg[max8997_irqs[i].group] & max8997_irqs[i].mask)
> - ? ? ? ? ? ? ? ? ? ? ? handle_nested_irq(max8997->irq_base + i);
> + ? ? ? ? ? ? ? ? ? ? ? handle_nested_irq(cur_irq);
> ? ? ? ?}
>
> ? ? ? ?return IRQ_HANDLED;
> @@ -278,13 +280,14 @@ static irqreturn_t max8997_irq_thread(int irq, void *data)
>
> ?int max8997_irq_resume(struct max8997_dev *max8997)
> ?{
> - ? ? ? if (max8997->irq && max8997->irq_base)
> - ? ? ? ? ? ? ? max8997_irq_thread(max8997->irq_base, max8997);
> + ? ? ? if (max8997->irq && max8997->irq_domain.irq_base)
> + ? ? ? ? ? ? ? max8997_irq_thread(max8997->irq_domain.irq_base, max8997);
> ? ? ? ?return 0;
> ?}
>
> ?int max8997_irq_init(struct max8997_dev *max8997)
> ?{
> + ? ? ? struct irq_domain *domain = &max8997->irq_domain;
> ? ? ? ?int i;
> ? ? ? ?int cur_irq;
> ? ? ? ?int ret;
> @@ -292,12 +295,6 @@ int max8997_irq_init(struct max8997_dev *max8997)
>
> ? ? ? ?if (!max8997->irq) {
> ? ? ? ? ? ? ? ?dev_warn(max8997->dev, "No interrupt specified.\n");
> - ? ? ? ? ? ? ? max8997->irq_base = 0;
> - ? ? ? ? ? ? ? return 0;
> - ? ? ? }
> -
> - ? ? ? if (!max8997->irq_base) {
> - ? ? ? ? ? ? ? dev_err(max8997->dev, "No interrupt base specified.\n");
> ? ? ? ? ? ? ? ?return 0;
> ? ? ? ?}
>
> @@ -327,9 +324,17 @@ int max8997_irq_init(struct max8997_dev *max8997)
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?true : false;
> ? ? ? ?}
>
> + ? ? ? domain->irq_base = irq_alloc_descs(-1, 0, MAX8997_IRQ_NR, 0);
> + ? ? ? if (domain->irq_base < 0) {
> + ? ? ? ? ? ? ? dev_err(max8997->dev, "failed to alloc irq descs\n");
> + ? ? ? ? ? ? ? return 0;
> + ? ? ? }
> + ? ? ? domain->nr_irq = MAX8997_IRQ_NR;
> + ? ? ? domain->ops = &irq_domain_simple_ops;
> + ? ? ? irq_domain_add(domain);
> +
> ? ? ? ?/* Register with genirq */
> - ? ? ? for (i = 0; i < MAX8997_IRQ_NR; i++) {
> - ? ? ? ? ? ? ? cur_irq = i + max8997->irq_base;
> + ? ? ? irq_domain_for_each_irq(domain, i, cur_irq) {
> ? ? ? ? ? ? ? ?irq_set_chip_data(cur_irq, max8997);
> ? ? ? ? ? ? ? ?irq_set_chip_and_handler(cur_irq, &max8997_irq_chip,
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?handle_edge_irq);
> diff --git a/drivers/mfd/max8997.c b/drivers/mfd/max8997.c
> index 5be53ae..b996c6e 100644
> --- a/drivers/mfd/max8997.c
> +++ b/drivers/mfd/max8997.c
> @@ -142,7 +142,6 @@ static int max8997_i2c_probe(struct i2c_client *i2c,
> ? ? ? ?if (!pdata)
> ? ? ? ? ? ? ? ?goto err;
>
> - ? ? ? max8997->irq_base = pdata->irq_base;
> ? ? ? ?max8997->ono = pdata->ono;
>
> ? ? ? ?mutex_init(&max8997->iolock);
> diff --git a/include/linux/mfd/max8997-private.h b/include/linux/mfd/max8997-private.h
> index 3f4deb6..04c5779 100644
> --- a/include/linux/mfd/max8997-private.h
> +++ b/include/linux/mfd/max8997-private.h
> @@ -23,6 +23,8 @@
> ?#define __LINUX_MFD_MAX8997_PRIV_H
>
> ?#include <linux/i2c.h>
> +#include <linux/export.h>
> +#include <linux/irqdomain.h>
>
> ?#define MAX8997_REG_INVALID ? ?(0xff)
>
> @@ -325,7 +327,7 @@ struct max8997_dev {
>
> ? ? ? ?int irq;
> ? ? ? ?int ono;
> - ? ? ? int irq_base;
> + ? ? ? struct irq_domain irq_domain;
> ? ? ? ?struct mutex irqlock;
> ? ? ? ?int irq_masks_cur[MAX8997_IRQ_GROUP_NR];
> ? ? ? ?int irq_masks_cache[MAX8997_IRQ_GROUP_NR];
> diff --git a/include/linux/mfd/max8997.h b/include/linux/mfd/max8997.h
> index 0bbd13d..1e0b9cc 100644
> --- a/include/linux/mfd/max8997.h
> +++ b/include/linux/mfd/max8997.h
> @@ -79,7 +79,6 @@ struct max8997_regulator_data {
>
> ?struct max8997_platform_data {
> ? ? ? ?/* IRQ */
> - ? ? ? int irq_base;
> ? ? ? ?int ono;
> ? ? ? ?int wakeup;
>
> --
> 1.6.6.rc2
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at ?http://vger.kernel.org/majordomo-info.html



-- 
MyungJoo Ham, Ph.D.
Mobile Software Platform Lab, DMC Business, Samsung Electronics

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

* [PATCH 1/2] mfd: add irq domain support for max8997 interrupts
  2011-12-08 16:27 [PATCH 0/2] Add device tree support for MAX8997 Thomas Abraham
@ 2011-12-08 16:27   ` Thomas Abraham
  0 siblings, 0 replies; 22+ messages in thread
From: Thomas Abraham @ 2011-12-08 16:27 UTC (permalink / raw)
  To: linux-kernel
  Cc: rpurdie, rob.herring, grant.likely, kgene.kim, broonie,
	myungjoo.ham, kyungmin.park, dg77.kim, linux-arm-kernel,
	linux-samsung-soc

Add irq domain support for max8997 interrupts. All uses of irq_base in platform
data and max8997 driver private data are removed.

Cc: MyungJoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: Thomas Abraham <thomas.abraham@linaro.org>
---
 arch/arm/mach-exynos/mach-nuri.c    |    4 ----
 arch/arm/mach-exynos/mach-origen.c  |    1 -
 drivers/mfd/max8997-irq.c           |   33 +++++++++++++++++++--------------
 drivers/mfd/max8997.c               |    1 -
 include/linux/mfd/max8997-private.h |    4 +++-
 include/linux/mfd/max8997.h         |    1 -
 6 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/arch/arm/mach-exynos/mach-nuri.c b/arch/arm/mach-exynos/mach-nuri.c
index 236bbe1..ae333e5 100644
--- a/arch/arm/mach-exynos/mach-nuri.c
+++ b/arch/arm/mach-exynos/mach-nuri.c
@@ -1077,12 +1077,8 @@ static struct platform_device nuri_max8903_device = {
 static void __init nuri_power_init(void)
 {
 	int gpio;
-	int irq_base = IRQ_GPIO_END + 1;
 	int ta_en = 0;
 
-	nuri_max8997_pdata.irq_base = irq_base;
-	irq_base += MAX8997_IRQ_NR;
-
 	gpio = EXYNOS4_GPX0(7);
 	gpio_request(gpio, "AP_PMIC_IRQ");
 	s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf));
diff --git a/arch/arm/mach-exynos/mach-origen.c b/arch/arm/mach-exynos/mach-origen.c
index f56d027..588b0a8 100644
--- a/arch/arm/mach-exynos/mach-origen.c
+++ b/arch/arm/mach-exynos/mach-origen.c
@@ -421,7 +421,6 @@ struct max8997_platform_data __initdata origen_max8997_pdata = {
 	.buck1_gpiodvs	= false,
 	.buck2_gpiodvs	= false,
 	.buck5_gpiodvs	= false,
-	.irq_base	= IRQ_GPIO_END + 1,
 
 	.ignore_gpiodvs_side_effect = true,
 	.buck125_default_idx = 0x0,
diff --git a/drivers/mfd/max8997-irq.c b/drivers/mfd/max8997-irq.c
index 09274cf..eb9cad5 100644
--- a/drivers/mfd/max8997-irq.c
+++ b/drivers/mfd/max8997-irq.c
@@ -142,7 +142,8 @@ static void max8997_irq_sync_unlock(struct irq_data *data)
 static const inline struct max8997_irq_data *
 irq_to_max8997_irq(struct max8997_dev *max8997, int irq)
 {
-	return &max8997_irqs[irq - max8997->irq_base];
+	struct irq_data *data = irq_get_irq_data(irq);
+	return &max8997_irqs[data->hwirq];
 }
 
 static void max8997_irq_mask(struct irq_data *data)
@@ -179,10 +180,11 @@ static struct irq_chip max8997_irq_chip = {
 static irqreturn_t max8997_irq_thread(int irq, void *data)
 {
 	struct max8997_dev *max8997 = data;
+	struct irq_domain *domain = &max8997->irq_domain;
 	u8 irq_reg[MAX8997_IRQ_GROUP_NR] = {};
 	u8 irq_src;
 	int ret;
-	int i;
+	int i, cur_irq;
 
 	ret = max8997_read_reg(max8997->i2c, MAX8997_REG_INTSRC, &irq_src);
 	if (ret < 0) {
@@ -268,9 +270,9 @@ static irqreturn_t max8997_irq_thread(int irq, void *data)
 		irq_reg[i] &= ~max8997->irq_masks_cur[i];
 
 	/* Report */
-	for (i = 0; i < MAX8997_IRQ_NR; i++) {
+	irq_domain_for_each_irq(domain, i, cur_irq) {
 		if (irq_reg[max8997_irqs[i].group] & max8997_irqs[i].mask)
-			handle_nested_irq(max8997->irq_base + i);
+			handle_nested_irq(cur_irq);
 	}
 
 	return IRQ_HANDLED;
@@ -278,13 +280,14 @@ static irqreturn_t max8997_irq_thread(int irq, void *data)
 
 int max8997_irq_resume(struct max8997_dev *max8997)
 {
-	if (max8997->irq && max8997->irq_base)
-		max8997_irq_thread(max8997->irq_base, max8997);
+	if (max8997->irq && max8997->irq_domain.irq_base)
+		max8997_irq_thread(max8997->irq_domain.irq_base, max8997);
 	return 0;
 }
 
 int max8997_irq_init(struct max8997_dev *max8997)
 {
+	struct irq_domain *domain = &max8997->irq_domain;
 	int i;
 	int cur_irq;
 	int ret;
@@ -292,12 +295,6 @@ int max8997_irq_init(struct max8997_dev *max8997)
 
 	if (!max8997->irq) {
 		dev_warn(max8997->dev, "No interrupt specified.\n");
-		max8997->irq_base = 0;
-		return 0;
-	}
-
-	if (!max8997->irq_base) {
-		dev_err(max8997->dev, "No interrupt base specified.\n");
 		return 0;
 	}
 
@@ -327,9 +324,17 @@ int max8997_irq_init(struct max8997_dev *max8997)
 					true : false;
 	}
 
+	domain->irq_base = irq_alloc_descs(-1, 0, MAX8997_IRQ_NR, 0);
+	if (domain->irq_base < 0) {
+		dev_err(max8997->dev, "failed to alloc irq descs\n");
+		return 0;
+	}
+	domain->nr_irq = MAX8997_IRQ_NR;
+	domain->ops = &irq_domain_simple_ops;
+	irq_domain_add(domain);
+
 	/* Register with genirq */
-	for (i = 0; i < MAX8997_IRQ_NR; i++) {
-		cur_irq = i + max8997->irq_base;
+	irq_domain_for_each_irq(domain, i, cur_irq) {
 		irq_set_chip_data(cur_irq, max8997);
 		irq_set_chip_and_handler(cur_irq, &max8997_irq_chip,
 				handle_edge_irq);
diff --git a/drivers/mfd/max8997.c b/drivers/mfd/max8997.c
index 5be53ae..b996c6e 100644
--- a/drivers/mfd/max8997.c
+++ b/drivers/mfd/max8997.c
@@ -142,7 +142,6 @@ static int max8997_i2c_probe(struct i2c_client *i2c,
 	if (!pdata)
 		goto err;
 
-	max8997->irq_base = pdata->irq_base;
 	max8997->ono = pdata->ono;
 
 	mutex_init(&max8997->iolock);
diff --git a/include/linux/mfd/max8997-private.h b/include/linux/mfd/max8997-private.h
index 3f4deb6..04c5779 100644
--- a/include/linux/mfd/max8997-private.h
+++ b/include/linux/mfd/max8997-private.h
@@ -23,6 +23,8 @@
 #define __LINUX_MFD_MAX8997_PRIV_H
 
 #include <linux/i2c.h>
+#include <linux/export.h>
+#include <linux/irqdomain.h>
 
 #define MAX8997_REG_INVALID	(0xff)
 
@@ -325,7 +327,7 @@ struct max8997_dev {
 
 	int irq;
 	int ono;
-	int irq_base;
+	struct irq_domain irq_domain;
 	struct mutex irqlock;
 	int irq_masks_cur[MAX8997_IRQ_GROUP_NR];
 	int irq_masks_cache[MAX8997_IRQ_GROUP_NR];
diff --git a/include/linux/mfd/max8997.h b/include/linux/mfd/max8997.h
index 0bbd13d..1e0b9cc 100644
--- a/include/linux/mfd/max8997.h
+++ b/include/linux/mfd/max8997.h
@@ -79,7 +79,6 @@ struct max8997_regulator_data {
 
 struct max8997_platform_data {
 	/* IRQ */
-	int irq_base;
 	int ono;
 	int wakeup;
 
-- 
1.6.6.rc2


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

* [PATCH 1/2] mfd: add irq domain support for max8997 interrupts
@ 2011-12-08 16:27   ` Thomas Abraham
  0 siblings, 0 replies; 22+ messages in thread
From: Thomas Abraham @ 2011-12-08 16:27 UTC (permalink / raw)
  To: linux-arm-kernel

Add irq domain support for max8997 interrupts. All uses of irq_base in platform
data and max8997 driver private data are removed.

Cc: MyungJoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: Thomas Abraham <thomas.abraham@linaro.org>
---
 arch/arm/mach-exynos/mach-nuri.c    |    4 ----
 arch/arm/mach-exynos/mach-origen.c  |    1 -
 drivers/mfd/max8997-irq.c           |   33 +++++++++++++++++++--------------
 drivers/mfd/max8997.c               |    1 -
 include/linux/mfd/max8997-private.h |    4 +++-
 include/linux/mfd/max8997.h         |    1 -
 6 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/arch/arm/mach-exynos/mach-nuri.c b/arch/arm/mach-exynos/mach-nuri.c
index 236bbe1..ae333e5 100644
--- a/arch/arm/mach-exynos/mach-nuri.c
+++ b/arch/arm/mach-exynos/mach-nuri.c
@@ -1077,12 +1077,8 @@ static struct platform_device nuri_max8903_device = {
 static void __init nuri_power_init(void)
 {
 	int gpio;
-	int irq_base = IRQ_GPIO_END + 1;
 	int ta_en = 0;
 
-	nuri_max8997_pdata.irq_base = irq_base;
-	irq_base += MAX8997_IRQ_NR;
-
 	gpio = EXYNOS4_GPX0(7);
 	gpio_request(gpio, "AP_PMIC_IRQ");
 	s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf));
diff --git a/arch/arm/mach-exynos/mach-origen.c b/arch/arm/mach-exynos/mach-origen.c
index f56d027..588b0a8 100644
--- a/arch/arm/mach-exynos/mach-origen.c
+++ b/arch/arm/mach-exynos/mach-origen.c
@@ -421,7 +421,6 @@ struct max8997_platform_data __initdata origen_max8997_pdata = {
 	.buck1_gpiodvs	= false,
 	.buck2_gpiodvs	= false,
 	.buck5_gpiodvs	= false,
-	.irq_base	= IRQ_GPIO_END + 1,
 
 	.ignore_gpiodvs_side_effect = true,
 	.buck125_default_idx = 0x0,
diff --git a/drivers/mfd/max8997-irq.c b/drivers/mfd/max8997-irq.c
index 09274cf..eb9cad5 100644
--- a/drivers/mfd/max8997-irq.c
+++ b/drivers/mfd/max8997-irq.c
@@ -142,7 +142,8 @@ static void max8997_irq_sync_unlock(struct irq_data *data)
 static const inline struct max8997_irq_data *
 irq_to_max8997_irq(struct max8997_dev *max8997, int irq)
 {
-	return &max8997_irqs[irq - max8997->irq_base];
+	struct irq_data *data = irq_get_irq_data(irq);
+	return &max8997_irqs[data->hwirq];
 }
 
 static void max8997_irq_mask(struct irq_data *data)
@@ -179,10 +180,11 @@ static struct irq_chip max8997_irq_chip = {
 static irqreturn_t max8997_irq_thread(int irq, void *data)
 {
 	struct max8997_dev *max8997 = data;
+	struct irq_domain *domain = &max8997->irq_domain;
 	u8 irq_reg[MAX8997_IRQ_GROUP_NR] = {};
 	u8 irq_src;
 	int ret;
-	int i;
+	int i, cur_irq;
 
 	ret = max8997_read_reg(max8997->i2c, MAX8997_REG_INTSRC, &irq_src);
 	if (ret < 0) {
@@ -268,9 +270,9 @@ static irqreturn_t max8997_irq_thread(int irq, void *data)
 		irq_reg[i] &= ~max8997->irq_masks_cur[i];
 
 	/* Report */
-	for (i = 0; i < MAX8997_IRQ_NR; i++) {
+	irq_domain_for_each_irq(domain, i, cur_irq) {
 		if (irq_reg[max8997_irqs[i].group] & max8997_irqs[i].mask)
-			handle_nested_irq(max8997->irq_base + i);
+			handle_nested_irq(cur_irq);
 	}
 
 	return IRQ_HANDLED;
@@ -278,13 +280,14 @@ static irqreturn_t max8997_irq_thread(int irq, void *data)
 
 int max8997_irq_resume(struct max8997_dev *max8997)
 {
-	if (max8997->irq && max8997->irq_base)
-		max8997_irq_thread(max8997->irq_base, max8997);
+	if (max8997->irq && max8997->irq_domain.irq_base)
+		max8997_irq_thread(max8997->irq_domain.irq_base, max8997);
 	return 0;
 }
 
 int max8997_irq_init(struct max8997_dev *max8997)
 {
+	struct irq_domain *domain = &max8997->irq_domain;
 	int i;
 	int cur_irq;
 	int ret;
@@ -292,12 +295,6 @@ int max8997_irq_init(struct max8997_dev *max8997)
 
 	if (!max8997->irq) {
 		dev_warn(max8997->dev, "No interrupt specified.\n");
-		max8997->irq_base = 0;
-		return 0;
-	}
-
-	if (!max8997->irq_base) {
-		dev_err(max8997->dev, "No interrupt base specified.\n");
 		return 0;
 	}
 
@@ -327,9 +324,17 @@ int max8997_irq_init(struct max8997_dev *max8997)
 					true : false;
 	}
 
+	domain->irq_base = irq_alloc_descs(-1, 0, MAX8997_IRQ_NR, 0);
+	if (domain->irq_base < 0) {
+		dev_err(max8997->dev, "failed to alloc irq descs\n");
+		return 0;
+	}
+	domain->nr_irq = MAX8997_IRQ_NR;
+	domain->ops = &irq_domain_simple_ops;
+	irq_domain_add(domain);
+
 	/* Register with genirq */
-	for (i = 0; i < MAX8997_IRQ_NR; i++) {
-		cur_irq = i + max8997->irq_base;
+	irq_domain_for_each_irq(domain, i, cur_irq) {
 		irq_set_chip_data(cur_irq, max8997);
 		irq_set_chip_and_handler(cur_irq, &max8997_irq_chip,
 				handle_edge_irq);
diff --git a/drivers/mfd/max8997.c b/drivers/mfd/max8997.c
index 5be53ae..b996c6e 100644
--- a/drivers/mfd/max8997.c
+++ b/drivers/mfd/max8997.c
@@ -142,7 +142,6 @@ static int max8997_i2c_probe(struct i2c_client *i2c,
 	if (!pdata)
 		goto err;
 
-	max8997->irq_base = pdata->irq_base;
 	max8997->ono = pdata->ono;
 
 	mutex_init(&max8997->iolock);
diff --git a/include/linux/mfd/max8997-private.h b/include/linux/mfd/max8997-private.h
index 3f4deb6..04c5779 100644
--- a/include/linux/mfd/max8997-private.h
+++ b/include/linux/mfd/max8997-private.h
@@ -23,6 +23,8 @@
 #define __LINUX_MFD_MAX8997_PRIV_H
 
 #include <linux/i2c.h>
+#include <linux/export.h>
+#include <linux/irqdomain.h>
 
 #define MAX8997_REG_INVALID	(0xff)
 
@@ -325,7 +327,7 @@ struct max8997_dev {
 
 	int irq;
 	int ono;
-	int irq_base;
+	struct irq_domain irq_domain;
 	struct mutex irqlock;
 	int irq_masks_cur[MAX8997_IRQ_GROUP_NR];
 	int irq_masks_cache[MAX8997_IRQ_GROUP_NR];
diff --git a/include/linux/mfd/max8997.h b/include/linux/mfd/max8997.h
index 0bbd13d..1e0b9cc 100644
--- a/include/linux/mfd/max8997.h
+++ b/include/linux/mfd/max8997.h
@@ -79,7 +79,6 @@ struct max8997_regulator_data {
 
 struct max8997_platform_data {
 	/* IRQ */
-	int irq_base;
 	int ono;
 	int wakeup;
 
-- 
1.6.6.rc2

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

end of thread, other threads:[~2012-06-22  0:30 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-21  1:10 [PATCH 1/2] mfd: add irq domain support for max8997 interrupts Chanwoo Choi
2012-06-21  9:54 ` Mark Brown
2012-06-22  0:30   ` Chanwoo Choi
  -- strict thread matches above, loose matches on Subject: below --
2012-05-10 10:55 Chanwoo Choi
2011-12-08 16:27 [PATCH 0/2] Add device tree support for MAX8997 Thomas Abraham
2011-12-08 16:27 ` [PATCH 1/2] mfd: add irq domain support for max8997 interrupts Thomas Abraham
2011-12-08 16:27   ` Thomas Abraham
2011-12-09  4:00   ` MyungJoo Ham
2011-12-09  4:00     ` MyungJoo Ham
2011-12-09  4:41   ` Mark Brown
2011-12-09  4:41     ` Mark Brown
2011-12-09  5:25     ` Thomas Abraham
2011-12-09  5:25       ` Thomas Abraham
2011-12-09  6:02       ` Mark Brown
2011-12-09  6:02         ` Mark Brown
2011-12-09  6:30         ` Thomas Abraham
2011-12-09  6:30           ` Thomas Abraham
2011-12-09  6:39           ` Mark Brown
2011-12-09  6:39             ` Mark Brown
2011-12-09  7:19             ` Thomas Abraham
2011-12-09  7:19               ` Thomas Abraham
2011-12-09  8:15               ` Mark Brown
2011-12-09  8:15                 ` Mark Brown

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.