Skip to contentSkip to conversation

RETU fetch IRQ via struct resource

PATCH In review Felipe Balbi 2 participants 8 messages Feb 10, 2011 – Feb 15, 2011

lore
Share & tools
lore
#0 lore raw

cover RETU fetch IRQ via struct resource

Hi Tony,

here are 4 very quick patches to grab IRQ via struct resource. Now all these changes need to be ported to Tahvo. I'm not sure I'll have any time to look at that for a while, though.

Felipe Balbi (4):
cbus: retu: pass IRQ via struct resource
cbus: retu: headset: grab IRQ via struct resource
cbus: retu: pwrbutton: grab IRQ via struct resource
cbus: retu: rtc: grab IRQ via struct resource

 drivers/cbus/retu-headset.c   |   11 +++++++--
 drivers/cbus/retu-pwrbutton.c |    2 +-
 drivers/cbus/retu-rtc.c       |   23 +++++++++++++++------
 drivers/cbus/retu.c           |   42 ++++++++++++++++++++++++++++++++++------
 4 files changed, 60 insertions(+), 18 deletions(-)
Signature · 1 line
1.7.4.rc2
#1 lore raw

PATCH 1/4 cbus: retu: pass IRQ via struct resource

that's the preferred way to pass resources
to drivers anyway.

---
 drivers/cbus/retu.c |   42 +++++++++++++++++++++++++++++++++++-------
 1 files changed, 35 insertions(+), 7 deletions(-)
drivers/cbus/retu.c +35 -7
index fa666fe..6134781 100644
@@ -306,12 +306,24 @@ static void retu_power_off(void)
 	for (;;);
 }
 
+static struct resource generic_resources[] = {
+	{
+		.start	= -EINVAL,	/* fixed later */
+		.flags	= IORESOURCE_IRQ,
+	},
+	{
+		.start	= -EINVAL,	/* fixed later */
+		.flags	= IORESOURCE_IRQ,
+	},
+};
+
 /**
  * retu_allocate_child - Allocates one Retu child
  * @name: name of new child
  * @parent: parent device for this child
  */
-static struct device *retu_allocate_child(char *name, struct device *parent)
+static struct device *retu_allocate_child(char *name, struct device *parent,
+		int irq_base, int irq1, int irq2, int num)
 {
 	struct platform_device		*pdev;
 	int				status;
@@ -324,6 +336,18 @@ static struct device *retu_allocate_child(char *name, struct device *parent)
 
 	pdev->dev.parent = parent;
 
+	if (num) {
+		generic_resources[0].start = irq_base + irq1;
+		generic_resources[1].start = irq_base + irq2;
+
+		status = platform_device_add_resources(pdev,
+				generic_resources, num);
+		if (status < 0) {
+			dev_dbg(parent, "can't add resources to %s\n", name);
+			goto err;
+		}
+	}
+
 	status = platform_device_add(pdev);
 	if (status < 0) {
 		dev_dbg(parent, "can't add %s\n", name);
@@ -334,29 +358,33 @@ static struct device *retu_allocate_child(char *name, struct device *parent)
 
 err:
 	platform_device_put(pdev);
+
 	return NULL;
 }
 
 /**
  * retu_allocate_children - Allocates Retu's children
  */
-static int retu_allocate_children(struct device *parent)
+static int retu_allocate_children(struct device *parent, int irq_base)
 {
 	struct device	*child;
 
-	child = retu_allocate_child("retu-pwrbutton", parent);
+	child = retu_allocate_child("retu-pwrbutton", parent, irq_base,
+			RETU_INT_PWR, -1, 1);
 	if (!child)
 		return -ENOMEM;
 
-	child = retu_allocate_child("retu-headset", parent);
+	child = retu_allocate_child("retu-headset", parent, irq_base,
+			RETU_INT_HOOK, -1, 1);
 	if (!child)
 		return -ENOMEM;
 
-	child = retu_allocate_child("retu-rtc", parent);
+	child = retu_allocate_child("retu-rtc", parent, irq_base,
+			RETU_INT_RTCS, RETU_INT_RTCA, 2);
 	if (!child)
 		return -ENOMEM;
 
-	child = retu_allocate_child("retu-wdt", parent);
+	child = retu_allocate_child("retu-wdt", parent, -1, -1, -1, 0);
 	if (!child)
 		return -ENOMEM;
 
@@ -423,7 +451,7 @@ static int __init retu_probe(struct platform_device *pdev)
 	/* Register power off function */
 	pm_power_off = retu_power_off;
 
-	ret = retu_allocate_children(&pdev->dev);
+	ret = retu_allocate_children(&pdev->dev, retu->irq_base);
 	if (ret < 0) {
 		dev_err(&pdev->dev, "Unable to allocate Retu children\n");
 		goto err2;
Signature · 1 line
1.7.4.rc2
#2 lore raw

PATCH 2/4 cbus: retu: headset: grab IRQ via struct resource

In reply to Felipe Balbi

now that we pass IRQ via struct resource, we can
simply use it.

---
 drivers/cbus/retu-headset.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)
drivers/cbus/retu-headset.c +8 -3
index 661534c..acf5cbe7 100644
@@ -45,6 +45,7 @@ struct retu_headset {
 	unsigned			pressed;
 	struct timer_list		enable_timer;
 	struct timer_list		detect_timer;
+	int				irq;
 };
 
 static void retu_headset_set_bias(int enable)
@@ -219,6 +220,7 @@ static void retu_headset_detect_timer(unsigned long arg)
 static int __init retu_headset_probe(struct platform_device *pdev)
 {
 	struct retu_headset *hs;
+	int irq;
 	int r;
 
 	hs = kzalloc(sizeof(*hs), GFP_KERNEL);
@@ -258,8 +260,11 @@ static int __init retu_headset_probe(struct platform_device *pdev)
 	setup_timer(&hs->detect_timer, retu_headset_detect_timer,
 		    (unsigned long) hs);
 
-	r = request_threaded_irq(CBUS_RETU_IRQ_BASE + RETU_INT_HOOK, NULL,
-			retu_headset_hook_interrupt, 0, "hookdet", hs);
+	irq = platform_get_irq(pdev, 0);
+	hs->irq = irq;
+
+	r = request_threaded_irq(irq, NULL, retu_headset_hook_interrupt, 0,
+			"hookdet", hs);
 	if (r != 0) {
 		dev_err(&pdev->dev, "hookdet IRQ not available\n");
 		goto err6;
@@ -290,7 +295,7 @@ static int retu_headset_remove(struct platform_device *pdev)
 	device_remove_file(&pdev->dev, &dev_attr_enable_det);
 	retu_headset_disable(hs);
 	retu_headset_det_disable(hs);
-	free_irq(CBUS_RETU_IRQ_BASE + RETU_INT_HOOK, hs);
+	free_irq(hs->irq, hs);
 	input_unregister_device(hs->idev);
 	input_free_device(hs->idev);
 
Signature · 1 line
1.7.4.rc2
#3 lore raw

PATCH 3/4 cbus: retu: pwrbutton: grab IRQ via struct resource

In reply to Felipe Balbi

now that we pass IRQ via struct resource, we can
simply use it.

---
 drivers/cbus/retu-pwrbutton.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/cbus/retu-pwrbutton.c +1 -1
index 24efdee..593a73a 100644
@@ -83,7 +83,7 @@ static int __init retubutton_probe(struct platform_device *pdev)
 		goto err0;
 	}
 
-	pwr->irq = CBUS_RETU_IRQ_BASE + RETU_INT_PWR;
+	pwr->irq = platform_get_irq(pdev, 0);
 	platform_set_drvdata(pdev, pwr);
 
 	ret = request_threaded_irq(pwr->irq, NULL, retubutton_irq, 0,
Signature · 1 line
1.7.4.rc2
#4 lore raw

PATCH 4/4 cbus: retu: rtc: grab IRQ via struct resource

In reply to Felipe Balbi

now that we pass IRQ via struct resource, we can
simply use it.

---
 drivers/cbus/retu-rtc.c |   23 ++++++++++++++++-------
 1 files changed, 16 insertions(+), 7 deletions(-)
drivers/cbus/retu-rtc.c +16 -7
index a011ba7..5f52edf 100644
@@ -52,6 +52,8 @@ struct retu_rtc {
 	struct rtc_device	*rtc;
 
 	u16			alarm_expired;
+	int			irq_rtcs;
+	int			irq_rtca;
 };
 
 static void retu_rtc_do_reset(struct retu_rtc *rtc)
@@ -86,17 +88,24 @@ static irqreturn_t retu_rtc_interrupt(int irq, void *_rtc)
 
 static int retu_rtc_init_irq(struct retu_rtc *rtc)
 {
+	int irq;
 	int ret;
 
-	ret = request_threaded_irq(CBUS_RETU_IRQ_BASE + RETU_INT_RTCS, NULL, retu_rtc_interrupt,
+	irq = platform_get_irq(to_platform_device(rtc->dev), 0);
+	rtc->irq_rtcs = irq;
+
+	irq = platform_get_irq(to_platform_device(rtc->dev), 1);
+	rtc->irq_rtca = irq;
+
+	ret = request_threaded_irq(rtc->irq_rtcs, NULL, retu_rtc_interrupt,
 			0, "RTCS", rtc);
 	if (ret != 0)
 		return ret;
 
-	ret = request_threaded_irq(CBUS_RETU_IRQ_BASE + RETU_INT_RTCA, NULL, retu_rtc_interrupt,
+	ret = request_threaded_irq(rtc->irq_rtca, NULL, retu_rtc_interrupt,
 			0, "RTCA", rtc);
 	if (ret != 0) {
-		free_irq(CBUS_RETU_IRQ_BASE + RETU_INT_RTCS, rtc);
+		free_irq(rtc->irq_rtcs, rtc);
 		return ret;
 	}
 
@@ -235,8 +244,8 @@ static int __init retu_rtc_probe(struct platform_device *pdev)
 	return 0;
 
 err2:
-	free_irq(CBUS_RETU_IRQ_BASE + RETU_INT_RTCS, rtc);
-	free_irq(CBUS_RETU_IRQ_BASE + RETU_INT_RTCA, rtc);
+	free_irq(rtc->irq_rtcs, rtc);
+	free_irq(rtc->irq_rtca, rtc);
 
 err1:
 	kfree(rtc);
@@ -249,8 +258,8 @@ static int __devexit retu_rtc_remove(struct platform_device *pdev)
 {
 	struct retu_rtc		*rtc = platform_get_drvdata(pdev);
 
-	free_irq(CBUS_RETU_IRQ_BASE + RETU_INT_RTCS, rtc);
-	free_irq(CBUS_RETU_IRQ_BASE + RETU_INT_RTCA, rtc);
+	free_irq(rtc->irq_rtcs, rtc);
+	free_irq(rtc->irq_rtca, rtc);
 	rtc_device_unregister(rtc->rtc);
 	kfree(rtc);
 
Signature · 1 line
1.7.4.rc2
#5 lore raw
In reply to Felipe Balbi

Hi,

Quoted 5 lines · Felipe Balbi

here are 4 very quick patches to grab IRQ via struct resource. Now all these changes need to be ported to Tahvo. I'm not sure I'll have any time to look at that for a while, though.

I have put together a few more patches which are now available at [1], here's the diffstat against tony/master:

 arch/arm/mach-omap1/board-nokia770.c   |    1 +
 arch/arm/mach-omap2/board-n8x0.c       |    1 +
 arch/arm/plat-omap/include/plat/cbus.h |    4 +
 drivers/cbus/retu-headset.c            |   46 +++++---
 drivers/cbus/retu-pwrbutton.c          |    6 +-
 drivers/cbus/retu-rtc.c                |   57 +++++-----
 drivers/cbus/retu-wdt.c                |   15 +--
 drivers/cbus/retu.c                    |  202 ++++++++++++++++++++-----------
 drivers/cbus/retu.h                    |   10 +-
 9 files changed, 206 insertions(+), 136 deletions(-)

and here's the new shortlog:

Felipe Balbi (19):
cbus: retu: pass IRQ via struct resource
cbus: retu: headset: grab IRQ via struct resource
cbus: retu: pwrbutton: grab IRQ via struct resource
cbus: retu: rtc: grab IRQ via struct resource
cbus: retu: drop retu_get_status
cbus: retu: replace BUG_ON with WARN
cbus: retu: drop the unnecessary spinlock_t
cbus: retu: drop unused PFX macro
arm: omap: cbus: add IDs for Retu and Tahvo
arm: omap: pass Retu ID via platform_data
cbus: retu: use the devid from platform_data
cbus: retu: introduce internal read/write functions
cbus: retu: search and replace
cbus: retu: pwrbutton: save device pointer on our structure
cbus: retu: pass the child device pointer to all retu functions
cbus: retu: headset: don't save pdev pointer
cbus: retu: replace EXPORT_SYMBOL with EXPORT_SYMBOL_GPL
cbus: retu: tabify retu initialization
cbus: retu: set pm_power_off to NULL when removing retu

Want me to re-send all patches or you can pull from my cbus branch to test ?

Any taker for fixing tahvo ? All you have to do is port the changes done in retu to tahvo. Tahvo is a lot simpler than retu though.

Signature · 1 line
balbi
#6 lore raw
Quoted 8 lines · Felipe Balbi

Hi,

Quoted 5 lines · Felipe Balbi

here are 4 very quick patches to grab IRQ via struct resource. Now all these changes need to be ported to Tahvo. I'm not sure I'll have any time to look at that for a while, though.

OK, great those four are working. I've applied them to the cbus branch.

Quoted 2 lines

Want me to re-send all patches or you can pull from my cbus branch to test ?

Hmm well maybe send the new ones? Then I can pull assuming you rebase on the cbus branch. That's usable now too and up to v2.6.38-rc4.

Quoted 2 lines

Any taker for fixing tahvo ? All you have to do is port the changes done in retu to tahvo. Tahvo is a lot simpler than retu though.

It will be at least few weeks before I can do anything except look and merge patches..

Tony

#7 lore raw

Hi,

Quoted 2 lines · Tony Lindgren

Hmm well maybe send the new ones? Then I can pull assuming you rebase on the cbus branch. That's usable now too and up to v2.6.38-rc4.

Will do that later on today.

Signature · 1 line
balbi