* [PATCH 00/22] Tahvo cleanups and Retu optimization
@ 2011-07-11 11:17 Felipe Balbi
2011-07-11 11:17 ` [PATCH 01/22] cbus: tahvo: convert spinlock into mutex Felipe Balbi
` (22 more replies)
0 siblings, 23 replies; 30+ messages in thread
From: Felipe Balbi @ 2011-07-11 11:17 UTC (permalink / raw)
To: Tony Lindgren; +Cc: Linux OMAP Mailing List, Michael Büsch, Felipe Balbi
Hi Tony,
here's the complete series... I'll stop playing
with these for a while. If you have some free time
to boot test on n8x0, I'd be really glad ;-)
Maybe Michael could test too ??
Felipe Balbi (22):
cbus: tahvo: convert spinlock into mutex
cbus: tahvo: move to __devinit/__devexit sections
cbus: tahvo: a switch looks better
cbus: tahvo: don't go over 80 columns
cbus: tahvo: drop the tasklet
cbus: retu: set IRQF_ONESHOT flag
cbus: tahvo: git it a context structure
cbus: tahvo: pass tahvo to IRQ handler
cbus: tahvo: introduce __tahvo_(read/write)_reg
cbus: tahvo: drop some unneded defines
cbus: retu: IRQ demux optimization
cbus: tahvo: give it an irq_chip
cbus: tahvo: start using irq_chip
cbus: tahvo: usb: fix up to use threaded irqs
cbus: tahvo drop the legacy interfaces
cbus: tahvo: usb: drop unused variable
cbus: tahvo: no need to mask interrupts on exit
cbus: tahvo: drop the get_status hack
cbus: tahvo: drop more unused interfaces
cbus: tahvo: pass child device pointer
cbus: tahvo: drop backlight interfaces
cbus: tahvo: drop static global pointer
arch/arm/mach-omap1/board-nokia770.c | 6 -
arch/arm/mach-omap2/board-n8x0.c | 6 -
drivers/cbus/retu.c | 18 +-
drivers/cbus/tahvo-usb.c | 58 ++---
drivers/cbus/tahvo.c | 462 ++++++++++++++++++----------------
drivers/cbus/tahvo.h | 16 +-
6 files changed, 283 insertions(+), 283 deletions(-)
--
1.7.6
^ permalink raw reply [flat|nested] 30+ messages in thread
* [PATCH 01/22] cbus: tahvo: convert spinlock into mutex
2011-07-11 11:17 [PATCH 00/22] Tahvo cleanups and Retu optimization Felipe Balbi
@ 2011-07-11 11:17 ` Felipe Balbi
2011-07-11 11:17 ` [PATCH 02/22] cbus: tahvo: move to __devinit/__devexit sections Felipe Balbi
` (21 subsequent siblings)
22 siblings, 0 replies; 30+ messages in thread
From: Felipe Balbi @ 2011-07-11 11:17 UTC (permalink / raw)
To: Tony Lindgren; +Cc: Linux OMAP Mailing List, Michael Büsch, Felipe Balbi
GPIO operations can sleep, so move to a
mutex.
Signed-off-by: Felipe Balbi <balbi@ti.com>
---
drivers/cbus/tahvo.c | 19 +++++++++----------
1 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/drivers/cbus/tahvo.c b/drivers/cbus/tahvo.c
index d4a89a6..bc3ca6d 100644
--- a/drivers/cbus/tahvo.c
+++ b/drivers/cbus/tahvo.c
@@ -32,6 +32,7 @@
#include <linux/irq.h>
#include <linux/interrupt.h>
#include <linux/platform_device.h>
+#include <linux/mutex.h>
#include "cbus.h"
#include "tahvo.h"
@@ -43,7 +44,7 @@ static int tahvo_initialized;
static int tahvo_is_betty;
static struct tasklet_struct tahvo_tasklet;
-static DEFINE_SPINLOCK(tahvo_lock);
+static struct mutex tahvo_lock;
static struct device *the_dev;
@@ -97,15 +98,14 @@ EXPORT_SYMBOL(tahvo_write_reg);
*/
void tahvo_set_clear_reg_bits(unsigned reg, u16 set, u16 clear)
{
- unsigned long flags;
u16 w;
- spin_lock_irqsave(&tahvo_lock, flags);
+ mutex_lock(&tahvo_lock);
w = tahvo_read_reg(reg);
w &= ~clear;
w |= set;
tahvo_write_reg(reg, w);
- spin_unlock_irqrestore(&tahvo_lock, flags);
+ mutex_unlock(&tahvo_lock);
}
/*
@@ -113,14 +113,13 @@ void tahvo_set_clear_reg_bits(unsigned reg, u16 set, u16 clear)
*/
void tahvo_disable_irq(int id)
{
- unsigned long flags;
u16 mask;
- spin_lock_irqsave(&tahvo_lock, flags);
+ mutex_lock(&tahvo_lock);
mask = tahvo_read_reg(TAHVO_REG_IMR);
mask |= 1 << id;
tahvo_write_reg(TAHVO_REG_IMR, mask);
- spin_unlock_irqrestore(&tahvo_lock, flags);
+ mutex_unlock(&tahvo_lock);
}
EXPORT_SYMBOL(tahvo_disable_irq);
@@ -129,14 +128,13 @@ EXPORT_SYMBOL(tahvo_disable_irq);
*/
void tahvo_enable_irq(int id)
{
- unsigned long flags;
u16 mask;
- spin_lock_irqsave(&tahvo_lock, flags);
+ mutex_lock(&tahvo_lock);
mask = tahvo_read_reg(TAHVO_REG_IMR);
mask &= ~(1 << id);
tahvo_write_reg(TAHVO_REG_IMR, mask);
- spin_unlock_irqrestore(&tahvo_lock, flags);
+ mutex_unlock(&tahvo_lock);
}
EXPORT_SYMBOL(tahvo_enable_irq);
@@ -297,6 +295,7 @@ static int __init tahvo_probe(struct platform_device *pdev)
int rev, id, ret;
int irq;
+ mutex_init(&tahvo_lock);
the_dev = &pdev->dev;
/* Prepare tasklet */
--
1.7.6
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 02/22] cbus: tahvo: move to __devinit/__devexit sections
2011-07-11 11:17 [PATCH 00/22] Tahvo cleanups and Retu optimization Felipe Balbi
2011-07-11 11:17 ` [PATCH 01/22] cbus: tahvo: convert spinlock into mutex Felipe Balbi
@ 2011-07-11 11:17 ` Felipe Balbi
2011-07-11 11:17 ` [PATCH 03/22] cbus: tahvo: a switch looks better Felipe Balbi
` (20 subsequent siblings)
22 siblings, 0 replies; 30+ messages in thread
From: Felipe Balbi @ 2011-07-11 11:17 UTC (permalink / raw)
To: Tony Lindgren; +Cc: Linux OMAP Mailing List, Michael Büsch, Felipe Balbi
while at that, also remove a few annoying and pretty
much useless comments.
Signed-off-by: Felipe Balbi <balbi@ti.com>
---
drivers/cbus/tahvo.c | 36 +++---------------------------------
1 files changed, 3 insertions(+), 33 deletions(-)
diff --git a/drivers/cbus/tahvo.c b/drivers/cbus/tahvo.c
index bc3ca6d..0da156e 100644
--- a/drivers/cbus/tahvo.c
+++ b/drivers/cbus/tahvo.c
@@ -108,9 +108,6 @@ void tahvo_set_clear_reg_bits(unsigned reg, u16 set, u16 clear)
mutex_unlock(&tahvo_lock);
}
-/*
- * Disable given TAHVO interrupt
- */
void tahvo_disable_irq(int id)
{
u16 mask;
@@ -123,9 +120,6 @@ void tahvo_disable_irq(int id)
}
EXPORT_SYMBOL(tahvo_disable_irq);
-/*
- * Enable given TAHVO interrupt
- */
void tahvo_enable_irq(int id)
{
u16 mask;
@@ -138,9 +132,6 @@ void tahvo_enable_irq(int id)
}
EXPORT_SYMBOL(tahvo_enable_irq);
-/*
- * Acknowledge given TAHVO interrupt
- */
void tahvo_ack_irq(int id)
{
tahvo_write_reg(TAHVO_REG_IDR, 1 << id);
@@ -181,18 +172,12 @@ void tahvo_set_backlight_level(int level)
}
EXPORT_SYMBOL(tahvo_set_backlight_level);
-/*
- * TAHVO interrupt handler. Only schedules the tasklet.
- */
static irqreturn_t tahvo_irq_handler(int irq, void *dev_id)
{
tasklet_schedule(&tahvo_tasklet);
return IRQ_HANDLED;
}
-/*
- * Tasklet handler
- */
static void tahvo_tasklet_handler(unsigned long data)
{
struct tahvo_irq_handler_desc *hnd;
@@ -283,14 +268,7 @@ void tahvo_free_irq(int id)
}
EXPORT_SYMBOL(tahvo_free_irq);
-/**
- * tahvo_probe - Probe for Tahvo ASIC
- * @dev: the Tahvo device
- *
- * Probe for the Tahvo ASIC and allocate memory
- * for its device-struct if found
- */
-static int __init tahvo_probe(struct platform_device *pdev)
+static int __devinit tahvo_probe(struct platform_device *pdev)
{
int rev, id, ret;
int irq;
@@ -334,7 +312,7 @@ static int __init tahvo_probe(struct platform_device *pdev)
return 0;
}
-static int __exit tahvo_remove(struct platform_device *pdev)
+static int __devexit tahvo_remove(struct platform_device *pdev)
{
int irq;
@@ -350,25 +328,17 @@ static int __exit tahvo_remove(struct platform_device *pdev)
}
static struct platform_driver tahvo_driver = {
- .remove = __exit_p(tahvo_remove),
+ .remove = __devexit_p(tahvo_remove),
.driver = {
.name = "tahvo",
},
};
-/**
- * tahvo_init - initialise Tahvo driver
- *
- * Initialise the Tahvo driver and return 0 if everything worked ok
- */
static int __init tahvo_init(void)
{
return platform_driver_probe(&tahvo_driver, tahvo_probe);
}
-/*
- * Cleanup
- */
static void __exit tahvo_exit(void)
{
platform_driver_unregister(&tahvo_driver);
--
1.7.6
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 03/22] cbus: tahvo: a switch looks better
2011-07-11 11:17 [PATCH 00/22] Tahvo cleanups and Retu optimization Felipe Balbi
2011-07-11 11:17 ` [PATCH 01/22] cbus: tahvo: convert spinlock into mutex Felipe Balbi
2011-07-11 11:17 ` [PATCH 02/22] cbus: tahvo: move to __devinit/__devexit sections Felipe Balbi
@ 2011-07-11 11:17 ` Felipe Balbi
2011-07-11 11:17 ` [PATCH 04/22] cbus: tahvo: don't go over 80 columns Felipe Balbi
` (19 subsequent siblings)
22 siblings, 0 replies; 30+ messages in thread
From: Felipe Balbi @ 2011-07-11 11:17 UTC (permalink / raw)
To: Tony Lindgren; +Cc: Linux OMAP Mailing List, Michael Büsch, Felipe Balbi
cleanup only, no functional changes.
Signed-off-by: Felipe Balbi <balbi@ti.com>
---
drivers/cbus/tahvo.c | 10 +++++++---
1 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/cbus/tahvo.c b/drivers/cbus/tahvo.c
index 0da156e..647d263 100644
--- a/drivers/cbus/tahvo.c
+++ b/drivers/cbus/tahvo.c
@@ -284,13 +284,17 @@ static int __devinit tahvo_probe(struct platform_device *pdev)
rev = tahvo_read_reg(TAHVO_REG_ASICR);
id = (rev >> 8) & 0xff;
- if (id == 0x03) {
+
+ switch (id) {
+ case 0x03:
if ((rev & 0xff) >= 0x50)
tahvo_7bit_backlight = 1;
- } else if (id == 0x0b) {
+ break;
+ case 0x0b:
tahvo_is_betty = 1;
tahvo_7bit_backlight = 1;
- } else {
+ break;
+ default:
dev_err(&pdev->dev, "Tahvo/Betty chip not found");
return -ENODEV;
}
--
1.7.6
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 04/22] cbus: tahvo: don't go over 80 columns
2011-07-11 11:17 [PATCH 00/22] Tahvo cleanups and Retu optimization Felipe Balbi
` (2 preceding siblings ...)
2011-07-11 11:17 ` [PATCH 03/22] cbus: tahvo: a switch looks better Felipe Balbi
@ 2011-07-11 11:17 ` Felipe Balbi
2011-07-11 11:17 ` [PATCH 05/22] cbus: tahvo: drop the tasklet Felipe Balbi
` (18 subsequent siblings)
22 siblings, 0 replies; 30+ messages in thread
From: Felipe Balbi @ 2011-07-11 11:17 UTC (permalink / raw)
To: Tony Lindgren; +Cc: Linux OMAP Mailing List, Michael Büsch, Felipe Balbi
cleanup only, no functional changes.
Signed-off-by: Felipe Balbi <balbi@ti.com>
---
drivers/cbus/tahvo.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/cbus/tahvo.c b/drivers/cbus/tahvo.c
index 647d263..0e28208 100644
--- a/drivers/cbus/tahvo.c
+++ b/drivers/cbus/tahvo.c
@@ -299,8 +299,9 @@ static int __devinit tahvo_probe(struct platform_device *pdev)
return -ENODEV;
}
- dev_err(&pdev->dev, "%s v%d.%d found\n", tahvo_is_betty ? "Betty" : "Tahvo",
- (rev >> 4) & 0x0f, rev & 0x0f);
+ dev_err(&pdev->dev, "%s v%d.%d found\n",
+ tahvo_is_betty ? "Betty" : "Tahvo",
+ (rev >> 4) & 0x0f, rev & 0x0f);
irq = platform_get_irq(pdev, 0);
--
1.7.6
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 05/22] cbus: tahvo: drop the tasklet
2011-07-11 11:17 [PATCH 00/22] Tahvo cleanups and Retu optimization Felipe Balbi
` (3 preceding siblings ...)
2011-07-11 11:17 ` [PATCH 04/22] cbus: tahvo: don't go over 80 columns Felipe Balbi
@ 2011-07-11 11:17 ` Felipe Balbi
2011-07-11 11:17 ` [PATCH 06/22] cbus: retu: set IRQF_ONESHOT flag Felipe Balbi
` (17 subsequent siblings)
22 siblings, 0 replies; 30+ messages in thread
From: Felipe Balbi @ 2011-07-11 11:17 UTC (permalink / raw)
To: Tony Lindgren; +Cc: Linux OMAP Mailing List, Michael Büsch, Felipe Balbi
by moving to threaded IRQ.
Signed-off-by: Felipe Balbi <balbi@ti.com>
---
drivers/cbus/tahvo.c | 16 ++++------------
1 files changed, 4 insertions(+), 12 deletions(-)
diff --git a/drivers/cbus/tahvo.c b/drivers/cbus/tahvo.c
index 0e28208..4b062de 100644
--- a/drivers/cbus/tahvo.c
+++ b/drivers/cbus/tahvo.c
@@ -43,7 +43,6 @@
static int tahvo_initialized;
static int tahvo_is_betty;
-static struct tasklet_struct tahvo_tasklet;
static struct mutex tahvo_lock;
static struct device *the_dev;
@@ -174,12 +173,6 @@ EXPORT_SYMBOL(tahvo_set_backlight_level);
static irqreturn_t tahvo_irq_handler(int irq, void *dev_id)
{
- tasklet_schedule(&tahvo_tasklet);
- return IRQ_HANDLED;
-}
-
-static void tahvo_tasklet_handler(unsigned long data)
-{
struct tahvo_irq_handler_desc *hnd;
u16 id;
u16 im;
@@ -212,6 +205,8 @@ static void tahvo_tasklet_handler(unsigned long data)
*/
}
}
+
+ return IRQ_HANDLED;
}
/*
@@ -276,9 +271,6 @@ static int __devinit tahvo_probe(struct platform_device *pdev)
mutex_init(&tahvo_lock);
the_dev = &pdev->dev;
- /* Prepare tasklet */
- tasklet_init(&tahvo_tasklet, tahvo_tasklet_handler, 0);
-
tahvo_initialized = 1;
rev = tahvo_read_reg(TAHVO_REG_ASICR);
@@ -308,7 +300,8 @@ static int __devinit tahvo_probe(struct platform_device *pdev)
/* Mask all TAHVO interrupts */
tahvo_write_reg(TAHVO_REG_IMR, 0xffff);
- ret = request_irq(irq, tahvo_irq_handler, IRQF_TRIGGER_RISING,
+ ret = request_threaded_irq(irq, NULL, tahvo_irq_handler,
+ IRQF_TRIGGER_RISING | IRQF_ONESHOT,
"tahvo", 0);
if (ret < 0) {
dev_err(&pdev->dev, "Unable to register IRQ handler\n");
@@ -326,7 +319,6 @@ static int __devexit tahvo_remove(struct platform_device *pdev)
/* Mask all TAHVO interrupts */
tahvo_write_reg(TAHVO_REG_IMR, 0xffff);
free_irq(irq, 0);
- tasklet_kill(&tahvo_tasklet);
the_dev = NULL;
return 0;
--
1.7.6
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 06/22] cbus: retu: set IRQF_ONESHOT flag
2011-07-11 11:17 [PATCH 00/22] Tahvo cleanups and Retu optimization Felipe Balbi
` (4 preceding siblings ...)
2011-07-11 11:17 ` [PATCH 05/22] cbus: tahvo: drop the tasklet Felipe Balbi
@ 2011-07-11 11:17 ` Felipe Balbi
2011-07-11 11:17 ` [PATCH 07/22] cbus: tahvo: git it a context structure Felipe Balbi
` (16 subsequent siblings)
22 siblings, 0 replies; 30+ messages in thread
From: Felipe Balbi @ 2011-07-11 11:17 UTC (permalink / raw)
To: Tony Lindgren; +Cc: Linux OMAP Mailing List, Michael Büsch, Felipe Balbi
for handlers which don't have top half, it's
necessary to IRQF_ONESHOT.
Signed-off-by: Felipe Balbi <balbi@ti.com>
---
drivers/cbus/retu.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/cbus/retu.c b/drivers/cbus/retu.c
index b58c6e5..b7fbd18 100644
--- a/drivers/cbus/retu.c
+++ b/drivers/cbus/retu.c
@@ -469,8 +469,8 @@ static int __init retu_probe(struct platform_device *pdev)
/* Mask all RETU interrupts */
__retu_write_reg(retu, RETU_REG_IMR, 0xffff);
- ret = request_threaded_irq(retu->irq, NULL, retu_irq_handler, 0,
- "retu", retu);
+ ret = request_threaded_irq(retu->irq, NULL, retu_irq_handler,
+ IRQF_ONESHOT, "retu", retu);
if (ret < 0) {
dev_err(&pdev->dev, "Unable to register IRQ handler\n");
goto err2;
--
1.7.6
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 07/22] cbus: tahvo: git it a context structure
2011-07-11 11:17 [PATCH 00/22] Tahvo cleanups and Retu optimization Felipe Balbi
` (5 preceding siblings ...)
2011-07-11 11:17 ` [PATCH 06/22] cbus: retu: set IRQF_ONESHOT flag Felipe Balbi
@ 2011-07-11 11:17 ` Felipe Balbi
2011-07-11 11:17 ` [PATCH 08/22] cbus: tahvo: pass tahvo to IRQ handler Felipe Balbi
` (15 subsequent siblings)
22 siblings, 0 replies; 30+ messages in thread
From: Felipe Balbi @ 2011-07-11 11:17 UTC (permalink / raw)
To: Tony Lindgren; +Cc: Linux OMAP Mailing List, Michael Büsch, Felipe Balbi
just moving things around. It's a lot easier
to handle a dynamically allocated structure
as it allows for multiple instances of the
same device.
Signed-off-by: Felipe Balbi <balbi@ti.com>
---
drivers/cbus/tahvo.c | 128 ++++++++++++++++++++++++++++++++------------------
1 files changed, 82 insertions(+), 46 deletions(-)
diff --git a/drivers/cbus/tahvo.c b/drivers/cbus/tahvo.c
index 4b062de..3a77d12 100644
--- a/drivers/cbus/tahvo.c
+++ b/drivers/cbus/tahvo.c
@@ -26,6 +26,7 @@
#include <linux/module.h>
#include <linux/init.h>
+#include <linux/slab.h>
#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/device.h>
@@ -40,12 +41,16 @@
#define TAHVO_ID 0x02
#define PFX "tahvo: "
-static int tahvo_initialized;
-static int tahvo_is_betty;
+struct tahvo {
+ /* device lock */
+ struct mutex mutex;
+ struct device *dev;
-static struct mutex tahvo_lock;
+ unsigned int is_betty;
+ unsigned int wide_backlight;
+};
-static struct device *the_dev;
+static struct tahvo *the_tahvo;
struct tahvo_irq_handler_desc {
int (*func)(unsigned long);
@@ -57,7 +62,7 @@ static struct tahvo_irq_handler_desc tahvo_irq_handlers[MAX_TAHVO_IRQ_HANDLERS];
int tahvo_get_status(void)
{
- return tahvo_initialized;
+ return the_tahvo != NULL;
}
EXPORT_SYMBOL(tahvo_get_status);
@@ -69,8 +74,9 @@ EXPORT_SYMBOL(tahvo_get_status);
*/
int tahvo_read_reg(unsigned reg)
{
- BUG_ON(!tahvo_initialized);
- return cbus_read_reg(the_dev, TAHVO_ID, reg);
+ struct tahvo *tahvo = the_tahvo;
+
+ return cbus_read_reg(tahvo->dev, TAHVO_ID, reg);
}
EXPORT_SYMBOL(tahvo_read_reg);
@@ -83,8 +89,9 @@ EXPORT_SYMBOL(tahvo_read_reg);
*/
void tahvo_write_reg(unsigned reg, u16 val)
{
- BUG_ON(!tahvo_initialized);
- cbus_write_reg(the_dev, TAHVO_ID, reg, val);
+ struct tahvo *tahvo = the_tahvo;
+
+ cbus_write_reg(tahvo->dev, TAHVO_ID, reg, val);
}
EXPORT_SYMBOL(tahvo_write_reg);
@@ -97,37 +104,40 @@ EXPORT_SYMBOL(tahvo_write_reg);
*/
void tahvo_set_clear_reg_bits(unsigned reg, u16 set, u16 clear)
{
- u16 w;
+ struct tahvo *tahvo = the_tahvo;
+ u16 w;
- mutex_lock(&tahvo_lock);
+ mutex_lock(&tahvo->mutex);
w = tahvo_read_reg(reg);
w &= ~clear;
w |= set;
tahvo_write_reg(reg, w);
- mutex_unlock(&tahvo_lock);
+ mutex_unlock(&tahvo->mutex);
}
void tahvo_disable_irq(int id)
{
- u16 mask;
+ struct tahvo *tahvo = the_tahvo;
+ u16 mask;
- mutex_lock(&tahvo_lock);
+ mutex_lock(&tahvo->mutex);
mask = tahvo_read_reg(TAHVO_REG_IMR);
mask |= 1 << id;
tahvo_write_reg(TAHVO_REG_IMR, mask);
- mutex_unlock(&tahvo_lock);
+ mutex_unlock(&tahvo->mutex);
}
EXPORT_SYMBOL(tahvo_disable_irq);
void tahvo_enable_irq(int id)
{
- u16 mask;
+ struct tahvo *tahvo = the_tahvo;
+ u16 mask;
- mutex_lock(&tahvo_lock);
+ mutex_lock(&tahvo->mutex);
mask = tahvo_read_reg(TAHVO_REG_IMR);
mask &= ~(1 << id);
tahvo_write_reg(TAHVO_REG_IMR, mask);
- mutex_unlock(&tahvo_lock);
+ mutex_unlock(&tahvo->mutex);
}
EXPORT_SYMBOL(tahvo_enable_irq);
@@ -137,13 +147,12 @@ void tahvo_ack_irq(int id)
}
EXPORT_SYMBOL(tahvo_ack_irq);
-static int tahvo_7bit_backlight;
-
int tahvo_get_backlight_level(void)
{
- int mask;
+ struct tahvo *tahvo = the_tahvo;
+ int mask;
- if (tahvo_7bit_backlight)
+ if (tahvo->wide_backlight)
mask = 0x7f;
else
mask = 0x0f;
@@ -153,7 +162,9 @@ EXPORT_SYMBOL(tahvo_get_backlight_level);
int tahvo_get_max_backlight_level(void)
{
- if (tahvo_7bit_backlight)
+ struct tahvo *tahvo = the_tahvo;
+
+ if (tahvo->wide_backlight)
return 0x7f;
else
return 0x0f;
@@ -162,7 +173,7 @@ EXPORT_SYMBOL(tahvo_get_max_backlight_level);
void tahvo_set_backlight_level(int level)
{
- int max_level;
+ int max_level;
max_level = tahvo_get_max_backlight_level();
if (level > max_level)
@@ -174,9 +185,11 @@ EXPORT_SYMBOL(tahvo_set_backlight_level);
static irqreturn_t tahvo_irq_handler(int irq, void *dev_id)
{
struct tahvo_irq_handler_desc *hnd;
- u16 id;
- u16 im;
- int i;
+
+ struct tahvo *tahvo = the_tahvo;
+ u16 id;
+ u16 im;
+ int i;
for (;;) {
id = tahvo_read_reg(TAHVO_REG_IDR);
@@ -192,7 +205,7 @@ static irqreturn_t tahvo_irq_handler(int irq, void *dev_id)
hnd = &tahvo_irq_handlers[i];
if (hnd->func == NULL) {
/* Spurious tahvo interrupt - just ack it */
- printk(KERN_INFO "Spurious Tahvo interrupt "
+ dev_err(tahvo->dev, "Spurious interrupt "
"(id %d)\n", i);
tahvo_disable_irq(i);
tahvo_ack_irq(i);
@@ -215,19 +228,20 @@ static irqreturn_t tahvo_irq_handler(int irq, void *dev_id)
int tahvo_request_irq(int id, void *irq_handler, unsigned long arg, char *name)
{
struct tahvo_irq_handler_desc *hnd;
+ struct tahvo *tahvo = the_tahvo;
if (irq_handler == NULL || id >= MAX_TAHVO_IRQ_HANDLERS ||
name == NULL) {
- printk(KERN_ERR PFX "Invalid arguments to %s\n",
+ dev_err(tahvo->dev, "Invalid arguments to %s\n",
__FUNCTION__);
return -EINVAL;
}
hnd = &tahvo_irq_handlers[id];
if (hnd->func != NULL) {
- printk(KERN_ERR PFX "IRQ %d already reserved\n", id);
+ dev_err(tahvo->dev, "IRQ %d already reserved\n", id);
return -EBUSY;
}
- printk(KERN_INFO PFX "Registering interrupt %d for device %s\n",
+ dev_dbg(tahvo->dev, "Registering interrupt %d for device %s\n",
id, name);
hnd->func = irq_handler;
hnd->arg = arg;
@@ -246,15 +260,16 @@ EXPORT_SYMBOL(tahvo_request_irq);
void tahvo_free_irq(int id)
{
struct tahvo_irq_handler_desc *hnd;
+ struct tahvo *tahvo = the_tahvo;
if (id >= MAX_TAHVO_IRQ_HANDLERS) {
- printk(KERN_ERR PFX "Invalid argument to %s\n",
+ dev_err(tahvo->dev, "Invalid argument to %s\n",
__FUNCTION__);
return;
}
hnd = &tahvo_irq_handlers[id];
if (hnd->func == NULL) {
- printk(KERN_ERR PFX "IRQ %d already freed\n", id);
+ dev_err(tahvo->dev, "IRQ %d already freed\n", id);
return;
}
@@ -265,13 +280,24 @@ EXPORT_SYMBOL(tahvo_free_irq);
static int __devinit tahvo_probe(struct platform_device *pdev)
{
- int rev, id, ret;
- int irq;
+ struct tahvo *tahvo;
+ int rev;
+ int ret;
+ int irq;
+ int id;
+
+ tahvo = kzalloc(sizeof(*tahvo), GFP_KERNEL);
+ if (!tahvo) {
+ dev_err(&pdev->dev, "not enough memory\n");
+ ret = -ENOMEM;
+ goto err0;
+ }
- mutex_init(&tahvo_lock);
- the_dev = &pdev->dev;
+ the_tahvo = tahvo;
+ platform_set_drvdata(pdev, tahvo);
- tahvo_initialized = 1;
+ mutex_init(&tahvo->mutex);
+ tahvo->dev = &pdev->dev;
rev = tahvo_read_reg(TAHVO_REG_ASICR);
@@ -280,19 +306,20 @@ static int __devinit tahvo_probe(struct platform_device *pdev)
switch (id) {
case 0x03:
if ((rev & 0xff) >= 0x50)
- tahvo_7bit_backlight = 1;
+ tahvo->wide_backlight = true;
break;
case 0x0b:
- tahvo_is_betty = 1;
- tahvo_7bit_backlight = 1;
+ tahvo->is_betty = true;
+ tahvo->wide_backlight = true;
break;
default:
dev_err(&pdev->dev, "Tahvo/Betty chip not found");
- return -ENODEV;
+ ret = -ENODEV;
+ goto err1;
}
dev_err(&pdev->dev, "%s v%d.%d found\n",
- tahvo_is_betty ? "Betty" : "Tahvo",
+ tahvo->is_betty ? "Betty" : "Tahvo",
(rev >> 4) & 0x0f, rev & 0x0f);
irq = platform_get_irq(pdev, 0);
@@ -305,21 +332,30 @@ static int __devinit tahvo_probe(struct platform_device *pdev)
"tahvo", 0);
if (ret < 0) {
dev_err(&pdev->dev, "Unable to register IRQ handler\n");
- return ret;
+ goto err1;
}
+
return 0;
+
+err1:
+ kfree(tahvo);
+
+err0:
+ return ret;
}
static int __devexit tahvo_remove(struct platform_device *pdev)
{
- int irq;
+ struct tahvo *tahvo = platform_get_drvdata(pdev);
+ int irq;
irq = platform_get_irq(pdev, 0);
/* Mask all TAHVO interrupts */
tahvo_write_reg(TAHVO_REG_IMR, 0xffff);
free_irq(irq, 0);
- the_dev = NULL;
+ kfree(tahvo);
+ the_tahvo = NULL;
return 0;
}
--
1.7.6
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 08/22] cbus: tahvo: pass tahvo to IRQ handler
2011-07-11 11:17 [PATCH 00/22] Tahvo cleanups and Retu optimization Felipe Balbi
` (6 preceding siblings ...)
2011-07-11 11:17 ` [PATCH 07/22] cbus: tahvo: git it a context structure Felipe Balbi
@ 2011-07-11 11:17 ` Felipe Balbi
2011-07-11 11:17 ` [PATCH 09/22] cbus: tahvo: introduce __tahvo_(read/write)_reg Felipe Balbi
` (14 subsequent siblings)
22 siblings, 0 replies; 30+ messages in thread
From: Felipe Balbi @ 2011-07-11 11:17 UTC (permalink / raw)
To: Tony Lindgren; +Cc: Linux OMAP Mailing List, Michael Büsch, Felipe Balbi
that way we don't need to access the global
pointer
Signed-off-by: Felipe Balbi <balbi@ti.com>
---
drivers/cbus/tahvo.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/cbus/tahvo.c b/drivers/cbus/tahvo.c
index 3a77d12..740bb05 100644
--- a/drivers/cbus/tahvo.c
+++ b/drivers/cbus/tahvo.c
@@ -182,11 +182,11 @@ void tahvo_set_backlight_level(int level)
}
EXPORT_SYMBOL(tahvo_set_backlight_level);
-static irqreturn_t tahvo_irq_handler(int irq, void *dev_id)
+static irqreturn_t tahvo_irq_handler(int irq, void *_tahvo)
{
struct tahvo_irq_handler_desc *hnd;
- struct tahvo *tahvo = the_tahvo;
+ struct tahvo *tahvo = _tahvo;
u16 id;
u16 im;
int i;
@@ -329,7 +329,7 @@ static int __devinit tahvo_probe(struct platform_device *pdev)
ret = request_threaded_irq(irq, NULL, tahvo_irq_handler,
IRQF_TRIGGER_RISING | IRQF_ONESHOT,
- "tahvo", 0);
+ "tahvo", tahvo);
if (ret < 0) {
dev_err(&pdev->dev, "Unable to register IRQ handler\n");
goto err1;
--
1.7.6
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 09/22] cbus: tahvo: introduce __tahvo_(read/write)_reg
2011-07-11 11:17 [PATCH 00/22] Tahvo cleanups and Retu optimization Felipe Balbi
` (7 preceding siblings ...)
2011-07-11 11:17 ` [PATCH 08/22] cbus: tahvo: pass tahvo to IRQ handler Felipe Balbi
@ 2011-07-11 11:17 ` Felipe Balbi
2011-07-11 11:17 ` [PATCH 10/22] cbus: tahvo: drop some unneded defines Felipe Balbi
` (13 subsequent siblings)
22 siblings, 0 replies; 30+ messages in thread
From: Felipe Balbi @ 2011-07-11 11:17 UTC (permalink / raw)
To: Tony Lindgren; +Cc: Linux OMAP Mailing List, Michael Büsch, Felipe Balbi
those two functions are local to tahvo.c and
should be used to read/write Tahvo's registers.
Signed-off-by: Felipe Balbi <balbi@ti.com>
---
drivers/cbus/tahvo.c | 56 +++++++++++++++++++++++++++++++++++--------------
1 files changed, 40 insertions(+), 16 deletions(-)
diff --git a/drivers/cbus/tahvo.c b/drivers/cbus/tahvo.c
index 740bb05..04b8203 100644
--- a/drivers/cbus/tahvo.c
+++ b/drivers/cbus/tahvo.c
@@ -67,6 +67,27 @@ int tahvo_get_status(void)
EXPORT_SYMBOL(tahvo_get_status);
/**
+ * __tahvo_read_reg - Reads a value from a register in Tahvo
+ * @tahvo: pointer to tahvo structure
+ * @reg: the register address to read from
+ */
+static int __tahvo_read_reg(struct tahvo *tahvo, unsigned reg)
+{
+ return cbus_read_reg(tahvo->dev, TAHVO_ID, reg);
+}
+
+/**
+ * __tahvo_write_reg - Writes a value to a register in Tahvo
+ * @tahvo: pointer to tahvo structure
+ * @reg: register address to write to
+ * @val: the value to be written to @reg
+ */
+static void __tahvo_write_reg(struct tahvo *tahvo, unsigned reg, u16 val)
+{
+ cbus_write_reg(tahvo->dev, TAHVO_ID, reg, val);
+}
+
+/**
* tahvo_read_reg - Read a value from a register in Tahvo
* @reg: the register to read from
*
@@ -76,7 +97,7 @@ int tahvo_read_reg(unsigned reg)
{
struct tahvo *tahvo = the_tahvo;
- return cbus_read_reg(tahvo->dev, TAHVO_ID, reg);
+ return __tahvo_read_reg(tahvo, reg);
}
EXPORT_SYMBOL(tahvo_read_reg);
@@ -91,7 +112,7 @@ void tahvo_write_reg(unsigned reg, u16 val)
{
struct tahvo *tahvo = the_tahvo;
- cbus_write_reg(tahvo->dev, TAHVO_ID, reg, val);
+ __tahvo_write_reg(tahvo, reg, val);
}
EXPORT_SYMBOL(tahvo_write_reg);
@@ -108,10 +129,10 @@ void tahvo_set_clear_reg_bits(unsigned reg, u16 set, u16 clear)
u16 w;
mutex_lock(&tahvo->mutex);
- w = tahvo_read_reg(reg);
+ w = __tahvo_read_reg(tahvo, reg);
w &= ~clear;
w |= set;
- tahvo_write_reg(reg, w);
+ __tahvo_write_reg(tahvo, reg, w);
mutex_unlock(&tahvo->mutex);
}
@@ -121,9 +142,9 @@ void tahvo_disable_irq(int id)
u16 mask;
mutex_lock(&tahvo->mutex);
- mask = tahvo_read_reg(TAHVO_REG_IMR);
+ mask = __tahvo_read_reg(tahvo, TAHVO_REG_IMR);
mask |= 1 << id;
- tahvo_write_reg(TAHVO_REG_IMR, mask);
+ __tahvo_write_reg(tahvo, TAHVO_REG_IMR, mask);
mutex_unlock(&tahvo->mutex);
}
EXPORT_SYMBOL(tahvo_disable_irq);
@@ -134,16 +155,18 @@ void tahvo_enable_irq(int id)
u16 mask;
mutex_lock(&tahvo->mutex);
- mask = tahvo_read_reg(TAHVO_REG_IMR);
+ mask = __tahvo_read_reg(tahvo, TAHVO_REG_IMR);
mask &= ~(1 << id);
- tahvo_write_reg(TAHVO_REG_IMR, mask);
+ __tahvo_write_reg(tahvo, TAHVO_REG_IMR, mask);
mutex_unlock(&tahvo->mutex);
}
EXPORT_SYMBOL(tahvo_enable_irq);
void tahvo_ack_irq(int id)
{
- tahvo_write_reg(TAHVO_REG_IDR, 1 << id);
+ struct tahvo *tahvo = the_tahvo;
+
+ __tahvo_write_reg(tahvo, TAHVO_REG_IDR, 1 << id);
}
EXPORT_SYMBOL(tahvo_ack_irq);
@@ -156,7 +179,7 @@ int tahvo_get_backlight_level(void)
mask = 0x7f;
else
mask = 0x0f;
- return tahvo_read_reg(TAHVO_REG_LEDPWMR) & mask;
+ return __tahvo_read_reg(tahvo, TAHVO_REG_LEDPWMR) & mask;
}
EXPORT_SYMBOL(tahvo_get_backlight_level);
@@ -173,12 +196,13 @@ EXPORT_SYMBOL(tahvo_get_max_backlight_level);
void tahvo_set_backlight_level(int level)
{
+ struct tahvo *tahvo = the_tahvo;
int max_level;
max_level = tahvo_get_max_backlight_level();
if (level > max_level)
level = max_level;
- tahvo_write_reg(TAHVO_REG_LEDPWMR, level);
+ __tahvo_write_reg(tahvo, TAHVO_REG_LEDPWMR, level);
}
EXPORT_SYMBOL(tahvo_set_backlight_level);
@@ -192,8 +216,8 @@ static irqreturn_t tahvo_irq_handler(int irq, void *_tahvo)
int i;
for (;;) {
- id = tahvo_read_reg(TAHVO_REG_IDR);
- im = ~tahvo_read_reg(TAHVO_REG_IMR);
+ id = __tahvo_read_reg(tahvo, TAHVO_REG_IDR);
+ im = ~__tahvo_read_reg(tahvo, TAHVO_REG_IMR);
id &= im;
if (!id)
@@ -299,7 +323,7 @@ static int __devinit tahvo_probe(struct platform_device *pdev)
mutex_init(&tahvo->mutex);
tahvo->dev = &pdev->dev;
- rev = tahvo_read_reg(TAHVO_REG_ASICR);
+ rev = __tahvo_read_reg(tahvo, TAHVO_REG_ASICR);
id = (rev >> 8) & 0xff;
@@ -325,7 +349,7 @@ static int __devinit tahvo_probe(struct platform_device *pdev)
irq = platform_get_irq(pdev, 0);
/* Mask all TAHVO interrupts */
- tahvo_write_reg(TAHVO_REG_IMR, 0xffff);
+ __tahvo_write_reg(tahvo, TAHVO_REG_IMR, 0xffff);
ret = request_threaded_irq(irq, NULL, tahvo_irq_handler,
IRQF_TRIGGER_RISING | IRQF_ONESHOT,
@@ -352,7 +376,7 @@ static int __devexit tahvo_remove(struct platform_device *pdev)
irq = platform_get_irq(pdev, 0);
/* Mask all TAHVO interrupts */
- tahvo_write_reg(TAHVO_REG_IMR, 0xffff);
+ __tahvo_write_reg(tahvo, TAHVO_REG_IMR, 0xffff);
free_irq(irq, 0);
kfree(tahvo);
the_tahvo = NULL;
--
1.7.6
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 10/22] cbus: tahvo: drop some unneded defines
2011-07-11 11:17 [PATCH 00/22] Tahvo cleanups and Retu optimization Felipe Balbi
` (8 preceding siblings ...)
2011-07-11 11:17 ` [PATCH 09/22] cbus: tahvo: introduce __tahvo_(read/write)_reg Felipe Balbi
@ 2011-07-11 11:17 ` Felipe Balbi
2011-07-11 11:17 ` [PATCH 11/22] cbus: retu: IRQ demux optimization Felipe Balbi
` (12 subsequent siblings)
22 siblings, 0 replies; 30+ messages in thread
From: Felipe Balbi @ 2011-07-11 11:17 UTC (permalink / raw)
To: Tony Lindgren; +Cc: Linux OMAP Mailing List, Michael Büsch, Felipe Balbi
no functional changes.
Signed-off-by: Felipe Balbi <balbi@ti.com>
---
drivers/cbus/tahvo.c | 8 +++-----
1 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/drivers/cbus/tahvo.c b/drivers/cbus/tahvo.c
index 04b8203..a538f13 100644
--- a/drivers/cbus/tahvo.c
+++ b/drivers/cbus/tahvo.c
@@ -33,14 +33,12 @@
#include <linux/irq.h>
#include <linux/interrupt.h>
#include <linux/platform_device.h>
+#include <linux/platform_data/cbus.h>
#include <linux/mutex.h>
#include "cbus.h"
#include "tahvo.h"
-#define TAHVO_ID 0x02
-#define PFX "tahvo: "
-
struct tahvo {
/* device lock */
struct mutex mutex;
@@ -73,7 +71,7 @@ EXPORT_SYMBOL(tahvo_get_status);
*/
static int __tahvo_read_reg(struct tahvo *tahvo, unsigned reg)
{
- return cbus_read_reg(tahvo->dev, TAHVO_ID, reg);
+ return cbus_read_reg(tahvo->dev, CBUS_TAHVO_DEVICE_ID, reg);
}
/**
@@ -84,7 +82,7 @@ static int __tahvo_read_reg(struct tahvo *tahvo, unsigned reg)
*/
static void __tahvo_write_reg(struct tahvo *tahvo, unsigned reg, u16 val)
{
- cbus_write_reg(tahvo->dev, TAHVO_ID, reg, val);
+ cbus_write_reg(tahvo->dev, CBUS_TAHVO_DEVICE_ID, reg, val);
}
/**
--
1.7.6
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 11/22] cbus: retu: IRQ demux optimization
2011-07-11 11:17 [PATCH 00/22] Tahvo cleanups and Retu optimization Felipe Balbi
` (9 preceding siblings ...)
2011-07-11 11:17 ` [PATCH 10/22] cbus: tahvo: drop some unneded defines Felipe Balbi
@ 2011-07-11 11:17 ` Felipe Balbi
2011-07-11 11:17 ` [PATCH 12/22] cbus: tahvo: give it an irq_chip Felipe Balbi
` (11 subsequent siblings)
22 siblings, 0 replies; 30+ messages in thread
From: Felipe Balbi @ 2011-07-11 11:17 UTC (permalink / raw)
To: Tony Lindgren; +Cc: Linux OMAP Mailing List, Michael Büsch, Felipe Balbi
it's definitely not always that we will have
all 16 interrupts fired at the same time, so
in order to avoid looping so many times, we
are now using ffs() which is implemented
(on ARM) using the far better clz instruction.
This will save us quite some loops and could
improve IRQ latency on Retu significantly
(no actual measurements were made, though)
Signed-off-by: Felipe Balbi <balbi@ti.com>
---
drivers/cbus/retu.c | 14 ++++++++------
1 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/drivers/cbus/retu.c b/drivers/cbus/retu.c
index b7fbd18..e749c0e 100644
--- a/drivers/cbus/retu.c
+++ b/drivers/cbus/retu.c
@@ -36,6 +36,8 @@
#include <linux/platform_device.h>
#include <linux/platform_data/cbus.h>
+#include <asm/bitops.h>
+
#include "cbus.h"
#include "retu.h"
@@ -183,8 +185,6 @@ static irqreturn_t retu_irq_handler(int irq, void *_retu)
{
struct retu *retu = _retu;
- int i;
-
u16 idr;
u16 imr;
@@ -199,11 +199,13 @@ static irqreturn_t retu_irq_handler(int irq, void *_retu)
return IRQ_NONE;
}
- for (i = retu->irq_base; idr != 0; i++, idr >>= 1) {
- if (!(idr & 1))
- continue;
+ while (idr) {
+ unsigned long pending = __ffs(idr);
+ unsigned int irq;
- handle_nested_irq(i);
+ idr &= ~BIT(pending);
+ irq = pending + retu->irq_base;
+ handle_nested_irq(irq);
}
return IRQ_HANDLED;
--
1.7.6
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 12/22] cbus: tahvo: give it an irq_chip
2011-07-11 11:17 [PATCH 00/22] Tahvo cleanups and Retu optimization Felipe Balbi
` (10 preceding siblings ...)
2011-07-11 11:17 ` [PATCH 11/22] cbus: retu: IRQ demux optimization Felipe Balbi
@ 2011-07-11 11:17 ` Felipe Balbi
2011-07-11 11:17 ` [PATCH 13/22] cbus: tahvo: start using irq_chip Felipe Balbi
` (10 subsequent siblings)
22 siblings, 0 replies; 30+ messages in thread
From: Felipe Balbi @ 2011-07-11 11:17 UTC (permalink / raw)
To: Tony Lindgren; +Cc: Linux OMAP Mailing List, Michael Büsch, Felipe Balbi
tahvo also has IRQs to demux to its children,
so lets give it a struct irq_chip so that child
drivers can use standard request_threaded_irq().
This is still an unused irq_chip, later patches
will come to make proper use of it.
Signed-off-by: Felipe Balbi <balbi@ti.com>
---
drivers/cbus/tahvo.c | 128 ++++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 120 insertions(+), 8 deletions(-)
diff --git a/drivers/cbus/tahvo.c b/drivers/cbus/tahvo.c
index a538f13..3aaf0eb 100644
--- a/drivers/cbus/tahvo.c
+++ b/drivers/cbus/tahvo.c
@@ -44,8 +44,17 @@ struct tahvo {
struct mutex mutex;
struct device *dev;
- unsigned int is_betty;
- unsigned int wide_backlight;
+ int irq_base;
+ int irq_end;
+ int irq;
+
+ int ack;
+ int mask;
+
+ unsigned int wide_backlight:1;
+ unsigned int mask_pending:1;
+ unsigned int ack_pending:1;
+ unsigned int is_betty:1;
};
static struct tahvo *the_tahvo;
@@ -300,6 +309,94 @@ void tahvo_free_irq(int id)
}
EXPORT_SYMBOL(tahvo_free_irq);
+/* -------------------------------------------------------------------------- */
+
+static void tahvo_irq_bus_lock(struct irq_data *data)
+{
+ struct tahvo *tahvo = irq_data_get_irq_chip_data(data);
+
+ mutex_lock(&tahvo->mutex);
+}
+
+static void tahvo_irq_bus_sync_unlock(struct irq_data *data)
+{
+ struct tahvo *tahvo = irq_data_get_irq_chip_data(data);
+
+ if (tahvo->mask_pending) {
+ __tahvo_write_reg(tahvo, TAHVO_REG_IMR, tahvo->mask);
+ tahvo->mask_pending = false;
+ }
+
+ if (tahvo->ack_pending) {
+ __tahvo_write_reg(tahvo, TAHVO_REG_IDR, tahvo->ack);
+ tahvo->ack_pending = false;
+ }
+
+ mutex_unlock(&tahvo->mutex);
+}
+
+static void tahvo_irq_mask(struct irq_data *data)
+{
+ struct tahvo *tahvo = irq_data_get_irq_chip_data(data);
+ int irq = data->irq;
+
+ tahvo->mask |= (1 << (irq - tahvo->irq_base));
+ tahvo->mask_pending = true;
+}
+
+static void tahvo_irq_unmask(struct irq_data *data)
+{
+ struct tahvo *tahvo = irq_data_get_irq_chip_data(data);
+ int irq = data->irq;
+
+ tahvo->mask &= ~(1 << (irq - tahvo->irq_base));
+ tahvo->mask_pending = true;
+}
+
+static void tahvo_irq_ack(struct irq_data *data)
+{
+ struct tahvo *tahvo = irq_data_get_irq_chip_data(data);
+ int irq = data->irq;
+
+ tahvo->ack |= (1 << (irq - tahvo->irq_base));
+ tahvo->ack_pending = true;
+}
+
+static struct irq_chip tahvo_irq_chip = {
+ .name = "tahvo",
+ .irq_bus_lock = tahvo_irq_bus_lock,
+ .irq_bus_sync_unlock = tahvo_irq_bus_sync_unlock,
+ .irq_mask = tahvo_irq_mask,
+ .irq_unmask = tahvo_irq_unmask,
+ .irq_ack = tahvo_irq_ack,
+};
+
+static inline void tahvo_irq_setup(int irq)
+{
+#ifdef CONFIG_ARM
+ set_irq_flags(irq, IRQF_VALID);
+#else
+ set_irq_noprobe(irq);
+#endif
+}
+
+static void tahvo_irq_init(struct tahvo *tahvo)
+{
+ int base = tahvo->irq_base;
+ int end = tahvo->irq_end;
+ int irq;
+
+ for (irq = base; irq < end; irq++) {
+ irq_set_chip_data(irq, tahvo);
+ irq_set_chip_and_handler(irq, &tahvo_irq_chip,
+ handle_simple_irq);
+ irq_set_nested_thread(irq, 1);
+ tahvo_irq_setup(irq);
+ }
+}
+
+/* -------------------------------------------------------------------------- */
+
static int __devinit tahvo_probe(struct platform_device *pdev)
{
struct tahvo *tahvo;
@@ -315,11 +412,24 @@ static int __devinit tahvo_probe(struct platform_device *pdev)
goto err0;
}
- the_tahvo = tahvo;
+ irq = platform_get_irq(pdev, 0);
platform_set_drvdata(pdev, tahvo);
mutex_init(&tahvo->mutex);
- tahvo->dev = &pdev->dev;
+
+ ret = irq_alloc_descs(-1, 0, MAX_TAHVO_IRQ_HANDLERS, 0);
+ if (ret < 0) {
+ dev_err(&pdev->dev, "failed to allocate IRQ descs\n");
+ goto err1;
+ }
+
+ tahvo->irq_base = ret;
+ tahvo->irq_end = ret + MAX_TAHVO_IRQ_HANDLERS;
+ tahvo->dev = &pdev->dev;
+ tahvo->irq = irq;
+ the_tahvo = tahvo;
+
+ tahvo_irq_init(tahvo);
rev = __tahvo_read_reg(tahvo, TAHVO_REG_ASICR);
@@ -337,15 +447,13 @@ static int __devinit tahvo_probe(struct platform_device *pdev)
default:
dev_err(&pdev->dev, "Tahvo/Betty chip not found");
ret = -ENODEV;
- goto err1;
+ goto err2;
}
dev_err(&pdev->dev, "%s v%d.%d found\n",
tahvo->is_betty ? "Betty" : "Tahvo",
(rev >> 4) & 0x0f, rev & 0x0f);
- irq = platform_get_irq(pdev, 0);
-
/* Mask all TAHVO interrupts */
__tahvo_write_reg(tahvo, TAHVO_REG_IMR, 0xffff);
@@ -354,11 +462,14 @@ static int __devinit tahvo_probe(struct platform_device *pdev)
"tahvo", tahvo);
if (ret < 0) {
dev_err(&pdev->dev, "Unable to register IRQ handler\n");
- goto err1;
+ goto err2;
}
return 0;
+err2:
+ irq_free_descs(tahvo->irq_base, MAX_TAHVO_IRQ_HANDLERS);
+
err1:
kfree(tahvo);
@@ -376,6 +487,7 @@ static int __devexit tahvo_remove(struct platform_device *pdev)
/* Mask all TAHVO interrupts */
__tahvo_write_reg(tahvo, TAHVO_REG_IMR, 0xffff);
free_irq(irq, 0);
+ irq_free_descs(tahvo->irq_base, MAX_TAHVO_IRQ_HANDLERS);
kfree(tahvo);
the_tahvo = NULL;
--
1.7.6
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 13/22] cbus: tahvo: start using irq_chip
2011-07-11 11:17 [PATCH 00/22] Tahvo cleanups and Retu optimization Felipe Balbi
` (11 preceding siblings ...)
2011-07-11 11:17 ` [PATCH 12/22] cbus: tahvo: give it an irq_chip Felipe Balbi
@ 2011-07-11 11:17 ` Felipe Balbi
2011-07-11 11:17 ` [PATCH 14/22] cbus: tahvo: usb: fix up to use threaded irqs Felipe Balbi
` (9 subsequent siblings)
22 siblings, 0 replies; 30+ messages in thread
From: Felipe Balbi @ 2011-07-11 11:17 UTC (permalink / raw)
To: Tony Lindgren; +Cc: Linux OMAP Mailing List, Michael Büsch, Felipe Balbi
in order to chieve that, we needed to allocate
our children devices (currently only one) and
fix up the irq handler.
Signed-off-by: Felipe Balbi <balbi@ti.com>
---
arch/arm/mach-omap1/board-nokia770.c | 6 --
arch/arm/mach-omap2/board-n8x0.c | 6 --
drivers/cbus/tahvo.c | 110 ++++++++++++++++++++++++---------
3 files changed, 80 insertions(+), 42 deletions(-)
diff --git a/arch/arm/mach-omap1/board-nokia770.c b/arch/arm/mach-omap1/board-nokia770.c
index 5eb1a7f..ecdf77b 100644
--- a/arch/arm/mach-omap1/board-nokia770.c
+++ b/arch/arm/mach-omap1/board-nokia770.c
@@ -155,11 +155,6 @@ static struct platform_device tahvo_device = {
},
};
-static struct platform_device tahvo_usb_device = {
- .name = "tahvo-usb",
- .id = -1,
-};
-
static void __init nokia770_cbus_init(void)
{
int ret;
@@ -200,7 +195,6 @@ static void __init nokia770_cbus_init(void)
tahvo_resource[0].start = gpio_to_irq(40);
platform_device_register(&tahvo_device);
- platform_device_register(&tahvo_usb_device);
}
#else
diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c
index f7548e4..295b4d7 100644
--- a/arch/arm/mach-omap2/board-n8x0.c
+++ b/arch/arm/mach-omap2/board-n8x0.c
@@ -251,11 +251,6 @@ static struct platform_device tahvo_device = {
},
};
-static struct platform_device tahvo_usb_device = {
- .name = "tahvo-usb",
- .id = -1,
-};
-
static void __init n8x0_cbus_init(void)
{
int ret;
@@ -297,7 +292,6 @@ static void __init n8x0_cbus_init(void)
tahvo_resource[0].start = gpio_to_irq(111);
platform_device_register(&tahvo_device);
- platform_device_register(&tahvo_usb_device);
}
#else
diff --git a/drivers/cbus/tahvo.c b/drivers/cbus/tahvo.c
index 3aaf0eb..f01defc 100644
--- a/drivers/cbus/tahvo.c
+++ b/drivers/cbus/tahvo.c
@@ -215,39 +215,26 @@ EXPORT_SYMBOL(tahvo_set_backlight_level);
static irqreturn_t tahvo_irq_handler(int irq, void *_tahvo)
{
- struct tahvo_irq_handler_desc *hnd;
-
struct tahvo *tahvo = _tahvo;
u16 id;
u16 im;
- int i;
-
- for (;;) {
- id = __tahvo_read_reg(tahvo, TAHVO_REG_IDR);
- im = ~__tahvo_read_reg(tahvo, TAHVO_REG_IMR);
- id &= im;
-
- if (!id)
- break;
-
- for (i = 0; id != 0; i++, id >>= 1) {
- if (!(id & 1))
- continue;
- hnd = &tahvo_irq_handlers[i];
- if (hnd->func == NULL) {
- /* Spurious tahvo interrupt - just ack it */
- dev_err(tahvo->dev, "Spurious interrupt "
- "(id %d)\n", i);
- tahvo_disable_irq(i);
- tahvo_ack_irq(i);
- continue;
- }
- hnd->func(hnd->arg);
- /*
- * Don't acknowledge the interrupt here
- * It must be done explicitly
- */
- }
+
+ id = __tahvo_read_reg(tahvo, TAHVO_REG_IDR);
+ im = __tahvo_read_reg(tahvo, TAHVO_REG_IMR);
+ id &= ~im;
+
+ if (!id) {
+ dev_vdbg(tahvo->dev, "No IRQ, spurious ?\n");
+ return IRQ_NONE;
+ }
+
+ while (id) {
+ unsigned long pending = __ffs(id);
+ unsigned int irq;
+
+ id &= ~BIT(pending);
+ irq = pending + tahvo->irq_base;
+ handle_nested_irq(irq);
}
return IRQ_HANDLED;
@@ -397,6 +384,63 @@ static void tahvo_irq_init(struct tahvo *tahvo)
/* -------------------------------------------------------------------------- */
+static struct resource generic_resources[] = {
+ {
+ .start = -EINVAL, /* fixed later */
+ .flags = IORESOURCE_IRQ,
+ },
+};
+
+static struct device *tahvo_allocate_child(const char *name,
+ struct device *parent, int irq)
+{
+ struct platform_device *pdev;
+ int ret;
+
+ pdev = platform_device_alloc(name, -1);
+ if (!pdev) {
+ dev_dbg(parent, "can't allocate %s\n", name);
+ goto err0;
+ }
+
+ pdev->dev.parent = parent;
+
+ generic_resources[0].start = irq;
+
+ ret = platform_device_add_resources(pdev,
+ generic_resources, ARRAY_SIZE(generic_resources));
+ if (ret < 0) {
+ dev_dbg(parent, "can't add resources to %s\n", name);
+ goto err1;
+ }
+
+ ret = platform_device_add(pdev);
+ if (ret < 0) {
+ dev_dbg(parent, "can't add %s\n", name);
+ goto err1;
+ }
+
+ return &pdev->dev;
+
+err1:
+ platform_device_put(pdev);
+
+err0:
+ return NULL;
+}
+
+static int tahvo_allocate_children(struct device *parent, int irq_base)
+{
+ struct device *child;
+
+ child = tahvo_allocate_child("tahvo-usb", parent,
+ irq_base + TAHVO_INT_VBUSON);
+ if (!child)
+ return -ENOMEM;
+
+ return 0;
+}
+
static int __devinit tahvo_probe(struct platform_device *pdev)
{
struct tahvo *tahvo;
@@ -450,6 +494,12 @@ static int __devinit tahvo_probe(struct platform_device *pdev)
goto err2;
}
+ ret = tahvo_allocate_children(&pdev->dev, tahvo->irq_base);
+ if (ret < 0) {
+ dev_err(&pdev->dev, "failed to allocate children\n");
+ goto err2;
+ }
+
dev_err(&pdev->dev, "%s v%d.%d found\n",
tahvo->is_betty ? "Betty" : "Tahvo",
(rev >> 4) & 0x0f, rev & 0x0f);
--
1.7.6
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 14/22] cbus: tahvo: usb: fix up to use threaded irqs
2011-07-11 11:17 [PATCH 00/22] Tahvo cleanups and Retu optimization Felipe Balbi
` (12 preceding siblings ...)
2011-07-11 11:17 ` [PATCH 13/22] cbus: tahvo: start using irq_chip Felipe Balbi
@ 2011-07-11 11:17 ` Felipe Balbi
2011-07-11 11:17 ` [PATCH 15/22] cbus: tahvo drop the legacy interfaces Felipe Balbi
` (8 subsequent siblings)
22 siblings, 0 replies; 30+ messages in thread
From: Felipe Balbi @ 2011-07-11 11:17 UTC (permalink / raw)
To: Tony Lindgren; +Cc: Linux OMAP Mailing List, Michael Büsch, Felipe Balbi
fix up tahvo-usb to use threaded irqs and the
new IRQ chip.
Signed-off-by: Felipe Balbi <balbi@ti.com>
---
drivers/cbus/tahvo-usb.c | 35 +++++++++++++----------------------
1 files changed, 13 insertions(+), 22 deletions(-)
diff --git a/drivers/cbus/tahvo-usb.c b/drivers/cbus/tahvo-usb.c
index be0333f..10619a8 100644
--- a/drivers/cbus/tahvo-usb.c
+++ b/drivers/cbus/tahvo-usb.c
@@ -93,12 +93,13 @@ struct tahvo_usb {
struct platform_device *pt_dev;
struct otg_transceiver otg;
int vbus_state;
- struct work_struct irq_work;
struct mutex serialize;
#ifdef CONFIG_USB_OTG
int tahvo_mode;
#endif
struct clk *ick;
+
+ int irq;
};
static struct tahvo_usb *tahvo_usb_device;
@@ -523,23 +524,13 @@ static int tahvo_usb_set_peripheral(struct otg_transceiver *otg, struct usb_gadg
return 0;
}
-static void tahvo_usb_irq_work(struct work_struct *work)
+static irqreturn_t tahvo_usb_vbus_interrupt(int irq, void *_tu)
{
- struct tahvo_usb *tu = container_of(work, struct tahvo_usb, irq_work);
+ struct tahvo_usb *tu = _tu;
- mutex_lock(&tu->serialize);
check_vbus_state(tu);
- mutex_unlock(&tu->serialize);
-}
-static void tahvo_usb_vbus_interrupt(unsigned long arg)
-{
- struct tahvo_usb *tu = (struct tahvo_usb *) arg;
-
- tahvo_ack_irq(TAHVO_INT_VBUSON);
- /* Seems we need this to acknowledge the interrupt */
- tahvo_read_reg(TAHVO_REG_IDSR);
- schedule_work(&tu->irq_work);
+ return IRQ_HANDLED;
}
#ifdef CONFIG_USB_OTG
@@ -602,6 +593,7 @@ static int __init tahvo_usb_probe(struct platform_device *pdev)
struct tahvo_usb *tu;
struct device *dev = &pdev->dev;
int ret;
+ int irq;
ret = tahvo_get_status();
if (!ret)
@@ -625,7 +617,6 @@ static int __init tahvo_usb_probe(struct platform_device *pdev)
#endif
#endif
- INIT_WORK(&tu->irq_work, tahvo_usb_irq_work);
mutex_init(&tu->serialize);
tu->ick = clk_get(NULL, "usb_l4_ick");
@@ -640,9 +631,12 @@ static int __init tahvo_usb_probe(struct platform_device *pdev)
* state changes */
tu->vbus_state = tahvo_read_reg(TAHVO_REG_IDSR) & 0x01;
+ irq = platform_get_irq(pdev, 0);
+ tu->irq = irq;
+
/* We cannot enable interrupt until omap_udc is initialized */
- ret = tahvo_request_irq(TAHVO_INT_VBUSON, tahvo_usb_vbus_interrupt,
- (unsigned long) tu, "vbus_interrupt");
+ ret = request_threaded_irq(irq, NULL, tahvo_usb_vbus_interrupt,
+ IRQF_ONESHOT, "tahvo-vbus", tu);
if (ret != 0) {
printk(KERN_ERR "Could not register Tahvo interrupt for VBUS\n");
goto err_release_clk;
@@ -675,13 +669,10 @@ static int __init tahvo_usb_probe(struct platform_device *pdev)
dev_set_drvdata(dev, tu);
- /* Act upon current vbus state once at startup. A vbus state irq may or
- * may not be generated in addition to this. */
- schedule_work(&tu->irq_work);
return 0;
err_free_irq:
- tahvo_free_irq(TAHVO_INT_VBUSON);
+ free_irq(tu->irq, tu);
err_release_clk:
clk_disable(tu->ick);
clk_put(tu->ick);
@@ -698,7 +689,7 @@ static int __exit tahvo_usb_remove(struct platform_device *pdev)
dev_dbg(&pdev->dev, "remove\n");
- tahvo_free_irq(TAHVO_INT_VBUSON);
+ free_irq(tu->irq, tu);
flush_scheduled_work();
otg_set_transceiver(0);
device_remove_file(&pdev->dev, &dev_attr_vbus_state);
--
1.7.6
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 15/22] cbus: tahvo drop the legacy interfaces
2011-07-11 11:17 [PATCH 00/22] Tahvo cleanups and Retu optimization Felipe Balbi
` (13 preceding siblings ...)
2011-07-11 11:17 ` [PATCH 14/22] cbus: tahvo: usb: fix up to use threaded irqs Felipe Balbi
@ 2011-07-11 11:17 ` Felipe Balbi
2011-07-11 11:17 ` [PATCH 16/22] cbus: tahvo: usb: drop unused variable Felipe Balbi
` (7 subsequent siblings)
22 siblings, 0 replies; 30+ messages in thread
From: Felipe Balbi @ 2011-07-11 11:17 UTC (permalink / raw)
To: Tony Lindgren; +Cc: Linux OMAP Mailing List, Michael Büsch, Felipe Balbi
those tahvo-specific IRQ handling routines
aren't needed anymore. Drop'em.
Signed-off-by: Felipe Balbi <balbi@ti.com>
---
drivers/cbus/tahvo.c | 64 --------------------------------------------------
drivers/cbus/tahvo.h | 5 ----
2 files changed, 0 insertions(+), 69 deletions(-)
diff --git a/drivers/cbus/tahvo.c b/drivers/cbus/tahvo.c
index f01defc..d92a05d 100644
--- a/drivers/cbus/tahvo.c
+++ b/drivers/cbus/tahvo.c
@@ -59,14 +59,6 @@ struct tahvo {
static struct tahvo *the_tahvo;
-struct tahvo_irq_handler_desc {
- int (*func)(unsigned long);
- unsigned long arg;
- char name[8];
-};
-
-static struct tahvo_irq_handler_desc tahvo_irq_handlers[MAX_TAHVO_IRQ_HANDLERS];
-
int tahvo_get_status(void)
{
return the_tahvo != NULL;
@@ -240,62 +232,6 @@ static irqreturn_t tahvo_irq_handler(int irq, void *_tahvo)
return IRQ_HANDLED;
}
-/*
- * Register the handler for a given TAHVO interrupt source.
- */
-int tahvo_request_irq(int id, void *irq_handler, unsigned long arg, char *name)
-{
- struct tahvo_irq_handler_desc *hnd;
- struct tahvo *tahvo = the_tahvo;
-
- if (irq_handler == NULL || id >= MAX_TAHVO_IRQ_HANDLERS ||
- name == NULL) {
- dev_err(tahvo->dev, "Invalid arguments to %s\n",
- __FUNCTION__);
- return -EINVAL;
- }
- hnd = &tahvo_irq_handlers[id];
- if (hnd->func != NULL) {
- dev_err(tahvo->dev, "IRQ %d already reserved\n", id);
- return -EBUSY;
- }
- dev_dbg(tahvo->dev, "Registering interrupt %d for device %s\n",
- id, name);
- hnd->func = irq_handler;
- hnd->arg = arg;
- strlcpy(hnd->name, name, sizeof(hnd->name));
-
- tahvo_ack_irq(id);
- tahvo_enable_irq(id);
-
- return 0;
-}
-EXPORT_SYMBOL(tahvo_request_irq);
-
-/*
- * Unregister the handler for a given TAHVO interrupt source.
- */
-void tahvo_free_irq(int id)
-{
- struct tahvo_irq_handler_desc *hnd;
- struct tahvo *tahvo = the_tahvo;
-
- if (id >= MAX_TAHVO_IRQ_HANDLERS) {
- dev_err(tahvo->dev, "Invalid argument to %s\n",
- __FUNCTION__);
- return;
- }
- hnd = &tahvo_irq_handlers[id];
- if (hnd->func == NULL) {
- dev_err(tahvo->dev, "IRQ %d already freed\n", id);
- return;
- }
-
- tahvo_disable_irq(id);
- hnd->func = NULL;
-}
-EXPORT_SYMBOL(tahvo_free_irq);
-
/* -------------------------------------------------------------------------- */
static void tahvo_irq_bus_lock(struct irq_data *data)
diff --git a/drivers/cbus/tahvo.h b/drivers/cbus/tahvo.h
index e5ed990..b2f195f 100644
--- a/drivers/cbus/tahvo.h
+++ b/drivers/cbus/tahvo.h
@@ -54,11 +54,6 @@ int tahvo_get_status(void);
int tahvo_read_reg(unsigned reg);
void tahvo_write_reg(unsigned reg, u16 val);
void tahvo_set_clear_reg_bits(unsigned reg, u16 set, u16 clear);
-int tahvo_request_irq(int id, void *irq_handler, unsigned long arg, char *name);
-void tahvo_free_irq(int id);
-void tahvo_enable_irq(int id);
-void tahvo_disable_irq(int id);
-void tahvo_ack_irq(int id);
int tahvo_get_backlight_level(void);
int tahvo_get_max_backlight_level(void);
void tahvo_set_backlight_level(int level);
--
1.7.6
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 16/22] cbus: tahvo: usb: drop unused variable
2011-07-11 11:17 [PATCH 00/22] Tahvo cleanups and Retu optimization Felipe Balbi
` (14 preceding siblings ...)
2011-07-11 11:17 ` [PATCH 15/22] cbus: tahvo drop the legacy interfaces Felipe Balbi
@ 2011-07-11 11:17 ` Felipe Balbi
2011-07-11 11:17 ` [PATCH 17/22] cbus: tahvo: no need to mask interrupts on exit Felipe Balbi
` (6 subsequent siblings)
22 siblings, 0 replies; 30+ messages in thread
From: Felipe Balbi @ 2011-07-11 11:17 UTC (permalink / raw)
To: Tony Lindgren; +Cc: Linux OMAP Mailing List, Michael Büsch, Felipe Balbi
no functional changes.
Signed-off-by: Felipe Balbi <balbi@ti.com>
---
drivers/cbus/tahvo-usb.c | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/drivers/cbus/tahvo-usb.c b/drivers/cbus/tahvo-usb.c
index 10619a8..e078440 100644
--- a/drivers/cbus/tahvo-usb.c
+++ b/drivers/cbus/tahvo-usb.c
@@ -116,7 +116,6 @@ static struct platform_device *tahvo_otg_dev;
static irqreturn_t omap_otg_irq(int irq, void *arg)
{
- struct tahvo_usb *tu = arg;
u16 otg_irq;
otg_irq = omap_readw(OTG_IRQ_SRC);
--
1.7.6
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 17/22] cbus: tahvo: no need to mask interrupts on exit
2011-07-11 11:17 [PATCH 00/22] Tahvo cleanups and Retu optimization Felipe Balbi
` (15 preceding siblings ...)
2011-07-11 11:17 ` [PATCH 16/22] cbus: tahvo: usb: drop unused variable Felipe Balbi
@ 2011-07-11 11:17 ` Felipe Balbi
2011-07-11 11:17 ` [PATCH 18/22] cbus: tahvo: drop the get_status hack Felipe Balbi
` (5 subsequent siblings)
22 siblings, 0 replies; 30+ messages in thread
From: Felipe Balbi @ 2011-07-11 11:17 UTC (permalink / raw)
To: Tony Lindgren; +Cc: Linux OMAP Mailing List, Michael Büsch, Felipe Balbi
the children will be unloaded first and they
will make sure to mask their own IRQ.
While at that, also move subsys_init_call()
close to tahvo_init().
Signed-off-by: Felipe Balbi <balbi@ti.com>
---
drivers/cbus/tahvo.c | 5 +----
1 files changed, 1 insertions(+), 4 deletions(-)
diff --git a/drivers/cbus/tahvo.c b/drivers/cbus/tahvo.c
index d92a05d..ab6e7ea 100644
--- a/drivers/cbus/tahvo.c
+++ b/drivers/cbus/tahvo.c
@@ -470,8 +470,6 @@ static int __devexit tahvo_remove(struct platform_device *pdev)
irq = platform_get_irq(pdev, 0);
- /* Mask all TAHVO interrupts */
- __tahvo_write_reg(tahvo, TAHVO_REG_IMR, 0xffff);
free_irq(irq, 0);
irq_free_descs(tahvo->irq_base, MAX_TAHVO_IRQ_HANDLERS);
kfree(tahvo);
@@ -491,13 +489,12 @@ static int __init tahvo_init(void)
{
return platform_driver_probe(&tahvo_driver, tahvo_probe);
}
+subsys_initcall(tahvo_init);
static void __exit tahvo_exit(void)
{
platform_driver_unregister(&tahvo_driver);
}
-
-subsys_initcall(tahvo_init);
module_exit(tahvo_exit);
MODULE_DESCRIPTION("Tahvo ASIC control");
--
1.7.6
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 18/22] cbus: tahvo: drop the get_status hack
2011-07-11 11:17 [PATCH 00/22] Tahvo cleanups and Retu optimization Felipe Balbi
` (16 preceding siblings ...)
2011-07-11 11:17 ` [PATCH 17/22] cbus: tahvo: no need to mask interrupts on exit Felipe Balbi
@ 2011-07-11 11:17 ` Felipe Balbi
2011-07-11 11:17 ` [PATCH 19/22] cbus: tahvo: drop more unused interfaces Felipe Balbi
` (4 subsequent siblings)
22 siblings, 0 replies; 30+ messages in thread
From: Felipe Balbi @ 2011-07-11 11:17 UTC (permalink / raw)
To: Tony Lindgren; +Cc: Linux OMAP Mailing List, Michael Büsch, Felipe Balbi
that's really not needed.
Signed-off-by: Felipe Balbi <balbi@ti.com>
---
drivers/cbus/tahvo-usb.c | 4 ----
drivers/cbus/tahvo.c | 6 ------
drivers/cbus/tahvo.h | 1 -
3 files changed, 0 insertions(+), 11 deletions(-)
diff --git a/drivers/cbus/tahvo-usb.c b/drivers/cbus/tahvo-usb.c
index e078440..04fe770 100644
--- a/drivers/cbus/tahvo-usb.c
+++ b/drivers/cbus/tahvo-usb.c
@@ -594,10 +594,6 @@ static int __init tahvo_usb_probe(struct platform_device *pdev)
int ret;
int irq;
- ret = tahvo_get_status();
- if (!ret)
- return -ENODEV;
-
dev_dbg(dev, "probe\n");
/* Create driver data */
diff --git a/drivers/cbus/tahvo.c b/drivers/cbus/tahvo.c
index ab6e7ea..2597672 100644
--- a/drivers/cbus/tahvo.c
+++ b/drivers/cbus/tahvo.c
@@ -59,12 +59,6 @@ struct tahvo {
static struct tahvo *the_tahvo;
-int tahvo_get_status(void)
-{
- return the_tahvo != NULL;
-}
-EXPORT_SYMBOL(tahvo_get_status);
-
/**
* __tahvo_read_reg - Reads a value from a register in Tahvo
* @tahvo: pointer to tahvo structure
diff --git a/drivers/cbus/tahvo.h b/drivers/cbus/tahvo.h
index b2f195f..3c0b381 100644
--- a/drivers/cbus/tahvo.h
+++ b/drivers/cbus/tahvo.h
@@ -50,7 +50,6 @@
#define MAX_TAHVO_IRQ_HANDLERS 8
-int tahvo_get_status(void);
int tahvo_read_reg(unsigned reg);
void tahvo_write_reg(unsigned reg, u16 val);
void tahvo_set_clear_reg_bits(unsigned reg, u16 set, u16 clear);
--
1.7.6
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 19/22] cbus: tahvo: drop more unused interfaces
2011-07-11 11:17 [PATCH 00/22] Tahvo cleanups and Retu optimization Felipe Balbi
` (17 preceding siblings ...)
2011-07-11 11:17 ` [PATCH 18/22] cbus: tahvo: drop the get_status hack Felipe Balbi
@ 2011-07-11 11:17 ` Felipe Balbi
2011-07-11 11:17 ` [PATCH 20/22] cbus: tahvo: pass child device pointer Felipe Balbi
` (3 subsequent siblings)
22 siblings, 0 replies; 30+ messages in thread
From: Felipe Balbi @ 2011-07-11 11:17 UTC (permalink / raw)
To: Tony Lindgren; +Cc: Linux OMAP Mailing List, Michael Büsch, Felipe Balbi
we have the IRQ chip which is the standard
way of handling IRQs.
Signed-off-by: Felipe Balbi <balbi@ti.com>
---
drivers/cbus/tahvo.c | 34 ----------------------------------
1 files changed, 0 insertions(+), 34 deletions(-)
diff --git a/drivers/cbus/tahvo.c b/drivers/cbus/tahvo.c
index 2597672..8192a24 100644
--- a/drivers/cbus/tahvo.c
+++ b/drivers/cbus/tahvo.c
@@ -129,40 +129,6 @@ void tahvo_set_clear_reg_bits(unsigned reg, u16 set, u16 clear)
mutex_unlock(&tahvo->mutex);
}
-void tahvo_disable_irq(int id)
-{
- struct tahvo *tahvo = the_tahvo;
- u16 mask;
-
- mutex_lock(&tahvo->mutex);
- mask = __tahvo_read_reg(tahvo, TAHVO_REG_IMR);
- mask |= 1 << id;
- __tahvo_write_reg(tahvo, TAHVO_REG_IMR, mask);
- mutex_unlock(&tahvo->mutex);
-}
-EXPORT_SYMBOL(tahvo_disable_irq);
-
-void tahvo_enable_irq(int id)
-{
- struct tahvo *tahvo = the_tahvo;
- u16 mask;
-
- mutex_lock(&tahvo->mutex);
- mask = __tahvo_read_reg(tahvo, TAHVO_REG_IMR);
- mask &= ~(1 << id);
- __tahvo_write_reg(tahvo, TAHVO_REG_IMR, mask);
- mutex_unlock(&tahvo->mutex);
-}
-EXPORT_SYMBOL(tahvo_enable_irq);
-
-void tahvo_ack_irq(int id)
-{
- struct tahvo *tahvo = the_tahvo;
-
- __tahvo_write_reg(tahvo, TAHVO_REG_IDR, 1 << id);
-}
-EXPORT_SYMBOL(tahvo_ack_irq);
-
int tahvo_get_backlight_level(void)
{
struct tahvo *tahvo = the_tahvo;
--
1.7.6
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 20/22] cbus: tahvo: pass child device pointer
2011-07-11 11:17 [PATCH 00/22] Tahvo cleanups and Retu optimization Felipe Balbi
` (18 preceding siblings ...)
2011-07-11 11:17 ` [PATCH 19/22] cbus: tahvo: drop more unused interfaces Felipe Balbi
@ 2011-07-11 11:17 ` Felipe Balbi
2011-07-11 11:17 ` [PATCH 21/22] cbus: tahvo: drop backlight interfaces Felipe Balbi
` (2 subsequent siblings)
22 siblings, 0 replies; 30+ messages in thread
From: Felipe Balbi @ 2011-07-11 11:17 UTC (permalink / raw)
To: Tony Lindgren; +Cc: Linux OMAP Mailing List, Michael Büsch, Felipe Balbi
on read/write register operations, if we pass
the child device pointer, it becomes really easy
to access our device structure. Let's do so.
Signed-off-by: Felipe Balbi <balbi@ti.com>
---
drivers/cbus/tahvo-usb.c | 18 ++++++++++--------
drivers/cbus/tahvo.c | 18 +++++++++++-------
drivers/cbus/tahvo.h | 7 ++++---
3 files changed, 25 insertions(+), 18 deletions(-)
diff --git a/drivers/cbus/tahvo-usb.c b/drivers/cbus/tahvo-usb.c
index 04fe770..41e39ca 100644
--- a/drivers/cbus/tahvo-usb.c
+++ b/drivers/cbus/tahvo-usb.c
@@ -90,6 +90,7 @@
#endif
struct tahvo_usb {
+ struct device *dev;
struct platform_device *pt_dev;
struct otg_transceiver otg;
int vbus_state;
@@ -240,7 +241,7 @@ static void check_vbus_state(struct tahvo_usb *tu)
{
int reg, prev_state;
- reg = tahvo_read_reg(TAHVO_REG_IDSR);
+ reg = tahvo_read_reg(tu->dev, TAHVO_REG_IDSR);
if (reg & 0x01) {
u32 l;
@@ -304,7 +305,7 @@ static void tahvo_usb_become_host(struct tahvo_usb *tu)
omap_writel(l, OTG_CTRL);
/* Power up the transceiver in USB host mode */
- tahvo_write_reg(TAHVO_REG_USBR, USBR_REGOUT | USBR_NSUSPEND |
+ tahvo_write_reg(tu->dev, TAHVO_REG_USBR, USBR_REGOUT | USBR_NSUSPEND |
USBR_MASTER_SW2 | USBR_MASTER_SW1);
tu->otg.state = OTG_STATE_A_IDLE;
@@ -330,7 +331,7 @@ static void tahvo_usb_become_peripheral(struct tahvo_usb *tu)
omap_writel(l, OTG_CTRL);
/* Power up transceiver and set it in USB perhiperal mode */
- tahvo_write_reg(TAHVO_REG_USBR, USBR_SLAVE_CONTROL | USBR_REGOUT | USBR_NSUSPEND | USBR_SLAVE_SW);
+ tahvo_write_reg(tu->dev, TAHVO_REG_USBR, USBR_SLAVE_CONTROL | USBR_REGOUT | USBR_NSUSPEND | USBR_SLAVE_SW);
tu->otg.state = OTG_STATE_B_IDLE;
check_vbus_state(tu);
@@ -380,7 +381,7 @@ static void tahvo_usb_power_off(struct tahvo_usb *tu)
omap_writel(l, OTG_SYSCON_1);
/* Power off transceiver */
- tahvo_write_reg(TAHVO_REG_USBR, 0);
+ tahvo_write_reg(tu->dev, TAHVO_REG_USBR, 0);
tu->otg.state = OTG_STATE_UNDEFINED;
}
@@ -404,12 +405,12 @@ static int tahvo_usb_set_suspend(struct otg_transceiver *dev, int suspend)
dev_dbg(&tu->pt_dev->dev, "set_suspend\n");
- w = tahvo_read_reg(TAHVO_REG_USBR);
+ w = tahvo_read_reg(tu->dev, TAHVO_REG_USBR);
if (suspend)
w &= ~USBR_NSUSPEND;
else
w |= USBR_NSUSPEND;
- tahvo_write_reg(TAHVO_REG_USBR, w);
+ tahvo_write_reg(tu->dev, TAHVO_REG_USBR, w);
return 0;
}
@@ -602,7 +603,8 @@ static int __init tahvo_usb_probe(struct platform_device *pdev)
return -ENOMEM;
tahvo_usb_device = tu;
- tu->pt_dev = container_of(dev, struct platform_device, dev);
+ tu->dev = dev;
+ tu->pt_dev = pdev;
#ifdef CONFIG_USB_OTG
/* Default mode */
#ifdef CONFIG_CBUS_TAHVO_USB_HOST_BY_DEFAULT
@@ -624,7 +626,7 @@ static int __init tahvo_usb_probe(struct platform_device *pdev)
/* Set initial state, so that we generate kevents only on
* state changes */
- tu->vbus_state = tahvo_read_reg(TAHVO_REG_IDSR) & 0x01;
+ tu->vbus_state = tahvo_read_reg(tu->dev, TAHVO_REG_IDSR) & 0x01;
irq = platform_get_irq(pdev, 0);
tu->irq = irq;
diff --git a/drivers/cbus/tahvo.c b/drivers/cbus/tahvo.c
index 8192a24..12d95ac 100644
--- a/drivers/cbus/tahvo.c
+++ b/drivers/cbus/tahvo.c
@@ -82,13 +82,14 @@ static void __tahvo_write_reg(struct tahvo *tahvo, unsigned reg, u16 val)
/**
* tahvo_read_reg - Read a value from a register in Tahvo
+ * @child: device pointer from the calling child
* @reg: the register to read from
*
* This function returns the contents of the specified register
*/
-int tahvo_read_reg(unsigned reg)
+int tahvo_read_reg(struct device *child, unsigned reg)
{
- struct tahvo *tahvo = the_tahvo;
+ struct tahvo *tahvo = dev_get_drvdata(child->parent);
return __tahvo_read_reg(tahvo, reg);
}
@@ -96,14 +97,15 @@ EXPORT_SYMBOL(tahvo_read_reg);
/**
* tahvo_write_reg - Write a value to a register in Tahvo
+ * @child: device pointer from the calling child
* @reg: the register to write to
- * @reg: the value to write to the register
+ * @val : the value to write to the register
*
* This function writes a value to the specified register
*/
-void tahvo_write_reg(unsigned reg, u16 val)
+void tahvo_write_reg(struct device *child, unsigned reg, u16 val)
{
- struct tahvo *tahvo = the_tahvo;
+ struct tahvo *tahvo = dev_get_drvdata(child->parent);
__tahvo_write_reg(tahvo, reg, val);
}
@@ -111,14 +113,16 @@ EXPORT_SYMBOL(tahvo_write_reg);
/**
* tahvo_set_clear_reg_bits - set and clear register bits atomically
+ * @child: device pointer from the calling child
* @reg: the register to write to
* @bits: the bits to set
*
* This function sets and clears the specified Tahvo register bits atomically
*/
-void tahvo_set_clear_reg_bits(unsigned reg, u16 set, u16 clear)
+void tahvo_set_clear_reg_bits(struct device *child, unsigned reg, u16 set,
+ u16 clear)
{
- struct tahvo *tahvo = the_tahvo;
+ struct tahvo *tahvo = dev_get_drvdata(child->parent);
u16 w;
mutex_lock(&tahvo->mutex);
diff --git a/drivers/cbus/tahvo.h b/drivers/cbus/tahvo.h
index 3c0b381..1281710 100644
--- a/drivers/cbus/tahvo.h
+++ b/drivers/cbus/tahvo.h
@@ -50,9 +50,10 @@
#define MAX_TAHVO_IRQ_HANDLERS 8
-int tahvo_read_reg(unsigned reg);
-void tahvo_write_reg(unsigned reg, u16 val);
-void tahvo_set_clear_reg_bits(unsigned reg, u16 set, u16 clear);
+int tahvo_read_reg(struct device *child, unsigned reg);
+void tahvo_write_reg(struct device *child, unsigned reg, u16 val);
+void tahvo_set_clear_reg_bits(struct device *child, unsigned reg, u16 set,
+ u16 clear);
int tahvo_get_backlight_level(void);
int tahvo_get_max_backlight_level(void);
void tahvo_set_backlight_level(int level);
--
1.7.6
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 21/22] cbus: tahvo: drop backlight interfaces
2011-07-11 11:17 [PATCH 00/22] Tahvo cleanups and Retu optimization Felipe Balbi
` (19 preceding siblings ...)
2011-07-11 11:17 ` [PATCH 20/22] cbus: tahvo: pass child device pointer Felipe Balbi
@ 2011-07-11 11:17 ` Felipe Balbi
2011-07-11 11:17 ` [PATCH 22/22] cbus: tahvo: drop static global pointer Felipe Balbi
2011-07-11 11:28 ` [PATCH 00/22] Tahvo cleanups and Retu optimization Michael Büsch
22 siblings, 0 replies; 30+ messages in thread
From: Felipe Balbi @ 2011-07-11 11:17 UTC (permalink / raw)
To: Tony Lindgren; +Cc: Linux OMAP Mailing List, Michael Büsch, Felipe Balbi
they aren't used by anyone and they should
be, anyways, on a child LED driver not on
core Tahvo.
Signed-off-by: Felipe Balbi <balbi@ti.com>
---
drivers/cbus/tahvo.c | 51 +-------------------------------------------------
drivers/cbus/tahvo.h | 3 --
2 files changed, 1 insertions(+), 53 deletions(-)
diff --git a/drivers/cbus/tahvo.c b/drivers/cbus/tahvo.c
index 12d95ac..784431c 100644
--- a/drivers/cbus/tahvo.c
+++ b/drivers/cbus/tahvo.c
@@ -51,7 +51,6 @@ struct tahvo {
int ack;
int mask;
- unsigned int wide_backlight:1;
unsigned int mask_pending:1;
unsigned int ack_pending:1;
unsigned int is_betty:1;
@@ -133,42 +132,6 @@ void tahvo_set_clear_reg_bits(struct device *child, unsigned reg, u16 set,
mutex_unlock(&tahvo->mutex);
}
-int tahvo_get_backlight_level(void)
-{
- struct tahvo *tahvo = the_tahvo;
- int mask;
-
- if (tahvo->wide_backlight)
- mask = 0x7f;
- else
- mask = 0x0f;
- return __tahvo_read_reg(tahvo, TAHVO_REG_LEDPWMR) & mask;
-}
-EXPORT_SYMBOL(tahvo_get_backlight_level);
-
-int tahvo_get_max_backlight_level(void)
-{
- struct tahvo *tahvo = the_tahvo;
-
- if (tahvo->wide_backlight)
- return 0x7f;
- else
- return 0x0f;
-}
-EXPORT_SYMBOL(tahvo_get_max_backlight_level);
-
-void tahvo_set_backlight_level(int level)
-{
- struct tahvo *tahvo = the_tahvo;
- int max_level;
-
- max_level = tahvo_get_max_backlight_level();
- if (level > max_level)
- level = max_level;
- __tahvo_write_reg(tahvo, TAHVO_REG_LEDPWMR, level);
-}
-EXPORT_SYMBOL(tahvo_set_backlight_level);
-
static irqreturn_t tahvo_irq_handler(int irq, void *_tahvo)
{
struct tahvo *tahvo = _tahvo;
@@ -379,20 +342,8 @@ static int __devinit tahvo_probe(struct platform_device *pdev)
id = (rev >> 8) & 0xff;
- switch (id) {
- case 0x03:
- if ((rev & 0xff) >= 0x50)
- tahvo->wide_backlight = true;
- break;
- case 0x0b:
+ if (id == 0x0b)
tahvo->is_betty = true;
- tahvo->wide_backlight = true;
- break;
- default:
- dev_err(&pdev->dev, "Tahvo/Betty chip not found");
- ret = -ENODEV;
- goto err2;
- }
ret = tahvo_allocate_children(&pdev->dev, tahvo->irq_base);
if (ret < 0) {
diff --git a/drivers/cbus/tahvo.h b/drivers/cbus/tahvo.h
index 1281710..f151a43 100644
--- a/drivers/cbus/tahvo.h
+++ b/drivers/cbus/tahvo.h
@@ -54,8 +54,5 @@ int tahvo_read_reg(struct device *child, unsigned reg);
void tahvo_write_reg(struct device *child, unsigned reg, u16 val);
void tahvo_set_clear_reg_bits(struct device *child, unsigned reg, u16 set,
u16 clear);
-int tahvo_get_backlight_level(void);
-int tahvo_get_max_backlight_level(void);
-void tahvo_set_backlight_level(int level);
#endif /* __DRIVERS_CBUS_TAHVO_H */
--
1.7.6
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 22/22] cbus: tahvo: drop static global pointer
2011-07-11 11:17 [PATCH 00/22] Tahvo cleanups and Retu optimization Felipe Balbi
` (20 preceding siblings ...)
2011-07-11 11:17 ` [PATCH 21/22] cbus: tahvo: drop backlight interfaces Felipe Balbi
@ 2011-07-11 11:17 ` Felipe Balbi
2011-07-11 11:28 ` [PATCH 00/22] Tahvo cleanups and Retu optimization Michael Büsch
22 siblings, 0 replies; 30+ messages in thread
From: Felipe Balbi @ 2011-07-11 11:17 UTC (permalink / raw)
To: Tony Lindgren; +Cc: Linux OMAP Mailing List, Michael Büsch, Felipe Balbi
that's not used anywhere anymore. We can
safely drop it.
Signed-off-by: Felipe Balbi <balbi@ti.com>
---
drivers/cbus/tahvo.c | 4 ----
1 files changed, 0 insertions(+), 4 deletions(-)
diff --git a/drivers/cbus/tahvo.c b/drivers/cbus/tahvo.c
index 784431c..43f6d6a 100644
--- a/drivers/cbus/tahvo.c
+++ b/drivers/cbus/tahvo.c
@@ -56,8 +56,6 @@ struct tahvo {
unsigned int is_betty:1;
};
-static struct tahvo *the_tahvo;
-
/**
* __tahvo_read_reg - Reads a value from a register in Tahvo
* @tahvo: pointer to tahvo structure
@@ -334,7 +332,6 @@ static int __devinit tahvo_probe(struct platform_device *pdev)
tahvo->irq_end = ret + MAX_TAHVO_IRQ_HANDLERS;
tahvo->dev = &pdev->dev;
tahvo->irq = irq;
- the_tahvo = tahvo;
tahvo_irq_init(tahvo);
@@ -388,7 +385,6 @@ static int __devexit tahvo_remove(struct platform_device *pdev)
free_irq(irq, 0);
irq_free_descs(tahvo->irq_base, MAX_TAHVO_IRQ_HANDLERS);
kfree(tahvo);
- the_tahvo = NULL;
return 0;
}
--
1.7.6
^ permalink raw reply related [flat|nested] 30+ messages in thread
* Re: [PATCH 00/22] Tahvo cleanups and Retu optimization
2011-07-11 11:17 [PATCH 00/22] Tahvo cleanups and Retu optimization Felipe Balbi
` (21 preceding siblings ...)
2011-07-11 11:17 ` [PATCH 22/22] cbus: tahvo: drop static global pointer Felipe Balbi
@ 2011-07-11 11:28 ` Michael Büsch
2011-07-11 13:12 ` Felipe Balbi
22 siblings, 1 reply; 30+ messages in thread
From: Michael Büsch @ 2011-07-11 11:28 UTC (permalink / raw)
To: Felipe Balbi; +Cc: Tony Lindgren, Linux OMAP Mailing List, Michael Büsch
On Mon, 11 Jul 2011 14:17:13 +0300
Felipe Balbi <balbi@ti.com> wrote:
> Hi Tony,
>
> here's the complete series... I'll stop playing
> with these for a while. If you have some free time
> to boot test on n8x0, I'd be really glad ;-)
>
> Maybe Michael could test too ??
>
> Felipe Balbi (22):
> cbus: tahvo: convert spinlock into mutex
> cbus: tahvo: move to __devinit/__devexit sections
> cbus: tahvo: a switch looks better
> cbus: tahvo: don't go over 80 columns
> cbus: tahvo: drop the tasklet
> cbus: retu: set IRQF_ONESHOT flag
> cbus: tahvo: git it a context structure
> cbus: tahvo: pass tahvo to IRQ handler
> cbus: tahvo: introduce __tahvo_(read/write)_reg
> cbus: tahvo: drop some unneded defines
> cbus: retu: IRQ demux optimization
> cbus: tahvo: give it an irq_chip
> cbus: tahvo: start using irq_chip
> cbus: tahvo: usb: fix up to use threaded irqs
> cbus: tahvo drop the legacy interfaces
> cbus: tahvo: usb: drop unused variable
> cbus: tahvo: no need to mask interrupts on exit
> cbus: tahvo: drop the get_status hack
> cbus: tahvo: drop more unused interfaces
> cbus: tahvo: pass child device pointer
> cbus: tahvo: drop backlight interfaces
> cbus: tahvo: drop static global pointer
>
> arch/arm/mach-omap1/board-nokia770.c | 6 -
> arch/arm/mach-omap2/board-n8x0.c | 6 -
> drivers/cbus/retu.c | 18 +-
> drivers/cbus/tahvo-usb.c | 58 ++---
> drivers/cbus/tahvo.c | 462 ++++++++++++++++++----------------
> drivers/cbus/tahvo.h | 16 +-
> 6 files changed, 283 insertions(+), 283 deletions(-)
>
I currently lack a bit of time for testing, however I'll check it
I can test them at some point. Don't hold your breath, though.
Are you planning to implement a backlight driver for tahvo? I'm actually
using the functionality that you removed in this patchset in the OpenWRT
distribution.
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 00/22] Tahvo cleanups and Retu optimization
2011-07-11 11:28 ` [PATCH 00/22] Tahvo cleanups and Retu optimization Michael Büsch
@ 2011-07-11 13:12 ` Felipe Balbi
2011-07-11 13:41 ` Michael Büsch
0 siblings, 1 reply; 30+ messages in thread
From: Felipe Balbi @ 2011-07-11 13:12 UTC (permalink / raw)
To: Michael Büsch
Cc: Felipe Balbi, Tony Lindgren, Linux OMAP Mailing List,
Michael Büsch
[-- Attachment #1: Type: text/plain, Size: 2392 bytes --]
Hi,
On Mon, Jul 11, 2011 at 01:28:42PM +0200, Michael Büsch wrote:
> On Mon, 11 Jul 2011 14:17:13 +0300
> Felipe Balbi <balbi@ti.com> wrote:
>
> > Hi Tony,
> >
> > here's the complete series... I'll stop playing
> > with these for a while. If you have some free time
> > to boot test on n8x0, I'd be really glad ;-)
> >
> > Maybe Michael could test too ??
> >
> > Felipe Balbi (22):
> > cbus: tahvo: convert spinlock into mutex
> > cbus: tahvo: move to __devinit/__devexit sections
> > cbus: tahvo: a switch looks better
> > cbus: tahvo: don't go over 80 columns
> > cbus: tahvo: drop the tasklet
> > cbus: retu: set IRQF_ONESHOT flag
> > cbus: tahvo: git it a context structure
> > cbus: tahvo: pass tahvo to IRQ handler
> > cbus: tahvo: introduce __tahvo_(read/write)_reg
> > cbus: tahvo: drop some unneded defines
> > cbus: retu: IRQ demux optimization
> > cbus: tahvo: give it an irq_chip
> > cbus: tahvo: start using irq_chip
> > cbus: tahvo: usb: fix up to use threaded irqs
> > cbus: tahvo drop the legacy interfaces
> > cbus: tahvo: usb: drop unused variable
> > cbus: tahvo: no need to mask interrupts on exit
> > cbus: tahvo: drop the get_status hack
> > cbus: tahvo: drop more unused interfaces
> > cbus: tahvo: pass child device pointer
> > cbus: tahvo: drop backlight interfaces
> > cbus: tahvo: drop static global pointer
> >
> > arch/arm/mach-omap1/board-nokia770.c | 6 -
> > arch/arm/mach-omap2/board-n8x0.c | 6 -
> > drivers/cbus/retu.c | 18 +-
> > drivers/cbus/tahvo-usb.c | 58 ++---
> > drivers/cbus/tahvo.c | 462 ++++++++++++++++++----------------
> > drivers/cbus/tahvo.h | 16 +-
> > 6 files changed, 283 insertions(+), 283 deletions(-)
> >
>
> I currently lack a bit of time for testing, however I'll check it
> I can test them at some point. Don't hold your breath, though.
>
> Are you planning to implement a backlight driver for tahvo? I'm actually
> using the functionality that you removed in this patchset in the OpenWRT
> distribution.
if you have some extra documentation available, I could implement it
whenever I have some extra couple hours to play with this again... I
have no docs at all, but a led-tahvo.c would be really simple to get
done :-)
--
balbi
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 490 bytes --]
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 00/22] Tahvo cleanups and Retu optimization
2011-07-11 13:12 ` Felipe Balbi
@ 2011-07-11 13:41 ` Michael Büsch
2011-07-11 13:45 ` Felipe Balbi
0 siblings, 1 reply; 30+ messages in thread
From: Michael Büsch @ 2011-07-11 13:41 UTC (permalink / raw)
To: balbi; +Cc: Tony Lindgren, Linux OMAP Mailing List, Michael Büsch
On Mon, 11 Jul 2011 16:12:32 +0300
Felipe Balbi <balbi@ti.com> wrote:
> > Are you planning to implement a backlight driver for tahvo? I'm actually
> > using the functionality that you removed in this patchset in the OpenWRT
> > distribution.
>
> if you have some extra documentation available, I could implement it
> whenever I have some extra couple hours to play with this again... I
> have no docs at all, but a led-tahvo.c would be really simple to get
> done :-)
All I have is the old code. No docs. It seems rather simple, though.
Only a PWM register. That's pretty straightforward.
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 00/22] Tahvo cleanups and Retu optimization
2011-07-11 13:41 ` Michael Büsch
@ 2011-07-11 13:45 ` Felipe Balbi
2011-07-11 13:51 ` Michael Büsch
0 siblings, 1 reply; 30+ messages in thread
From: Felipe Balbi @ 2011-07-11 13:45 UTC (permalink / raw)
To: Michael Büsch
Cc: balbi, Tony Lindgren, Linux OMAP Mailing List, Michael Büsch
[-- Attachment #1: Type: text/plain, Size: 748 bytes --]
On Mon, Jul 11, 2011 at 03:41:26PM +0200, Michael Büsch wrote:
> On Mon, 11 Jul 2011 16:12:32 +0300
> Felipe Balbi <balbi@ti.com> wrote:
> > > Are you planning to implement a backlight driver for tahvo? I'm actually
> > > using the functionality that you removed in this patchset in the OpenWRT
> > > distribution.
> >
> > if you have some extra documentation available, I could implement it
> > whenever I have some extra couple hours to play with this again... I
> > have no docs at all, but a led-tahvo.c would be really simple to get
> > done :-)
>
> All I have is the old code. No docs. It seems rather simple, though.
> Only a PWM register. That's pretty straightforward.
cool, any pointers would be good ;-)
--
balbi
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 490 bytes --]
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 00/22] Tahvo cleanups and Retu optimization
2011-07-11 13:45 ` Felipe Balbi
@ 2011-07-11 13:51 ` Michael Büsch
2011-07-11 14:03 ` Felipe Balbi
0 siblings, 1 reply; 30+ messages in thread
From: Michael Büsch @ 2011-07-11 13:51 UTC (permalink / raw)
To: balbi; +Cc: Tony Lindgren, Linux OMAP Mailing List
On Mon, 11 Jul 2011 16:45:53 +0300
Felipe Balbi <balbi@ti.com> wrote:
> On Mon, Jul 11, 2011 at 03:41:26PM +0200, Michael Büsch wrote:
> > On Mon, 11 Jul 2011 16:12:32 +0300
> > Felipe Balbi <balbi@ti.com> wrote:
> > > > Are you planning to implement a backlight driver for tahvo? I'm actually
> > > > using the functionality that you removed in this patchset in the OpenWRT
> > > > distribution.
> > >
> > > if you have some extra documentation available, I could implement it
> > > whenever I have some extra couple hours to play with this again... I
> > > have no docs at all, but a led-tahvo.c would be really simple to get
> > > done :-)
> >
> > All I have is the old code. No docs. It seems rather simple, though.
> > Only a PWM register. That's pretty straightforward.
>
> cool, any pointers would be good ;-)
Pointers to what? How PWM works?
http://en.wikipedia.org/wiki/Pulse_width_modulation
You probably don't need to know the details, though.
Just write a 0 to the register to turn the LED off. And write
a 0xF (or 0x7F depending on tahvo revision) to the register to
turn it fully on. Any value in between to dim the LED.
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 00/22] Tahvo cleanups and Retu optimization
2011-07-11 13:51 ` Michael Büsch
@ 2011-07-11 14:03 ` Felipe Balbi
2011-07-11 14:19 ` Michael Büsch
0 siblings, 1 reply; 30+ messages in thread
From: Felipe Balbi @ 2011-07-11 14:03 UTC (permalink / raw)
To: Michael Büsch; +Cc: balbi, Tony Lindgren, Linux OMAP Mailing List
[-- Attachment #1: Type: text/plain, Size: 1377 bytes --]
Hi,
On Mon, Jul 11, 2011 at 03:51:23PM +0200, Michael Büsch wrote:
> On Mon, 11 Jul 2011 16:45:53 +0300
> Felipe Balbi <balbi@ti.com> wrote:
>
> > On Mon, Jul 11, 2011 at 03:41:26PM +0200, Michael Büsch wrote:
> > > On Mon, 11 Jul 2011 16:12:32 +0300
> > > Felipe Balbi <balbi@ti.com> wrote:
> > > > > Are you planning to implement a backlight driver for tahvo? I'm actually
> > > > > using the functionality that you removed in this patchset in the OpenWRT
> > > > > distribution.
> > > >
> > > > if you have some extra documentation available, I could implement it
> > > > whenever I have some extra couple hours to play with this again... I
> > > > have no docs at all, but a led-tahvo.c would be really simple to get
> > > > done :-)
> > >
> > > All I have is the old code. No docs. It seems rather simple, though.
> > > Only a PWM register. That's pretty straightforward.
> >
> > cool, any pointers would be good ;-)
>
> Pointers to what? How PWM works?
> http://en.wikipedia.org/wiki/Pulse_width_modulation
>
> You probably don't need to know the details, though.
> Just write a 0 to the register to turn the LED off. And write
> a 0xF (or 0x7F depending on tahvo revision) to the register to
> turn it fully on. Any value in between to dim the LED.
no, not to PWM... pointers to the code using the old interface ;-)
--
balbi
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 490 bytes --]
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 00/22] Tahvo cleanups and Retu optimization
2011-07-11 14:03 ` Felipe Balbi
@ 2011-07-11 14:19 ` Michael Büsch
0 siblings, 0 replies; 30+ messages in thread
From: Michael Büsch @ 2011-07-11 14:19 UTC (permalink / raw)
To: balbi; +Cc: Tony Lindgren, Linux OMAP Mailing List
On Mon, 11 Jul 2011 17:03:28 +0300
Felipe Balbi <balbi@ti.com> wrote:
> Hi,
>
> On Mon, Jul 11, 2011 at 03:51:23PM +0200, Michael Büsch wrote:
> > On Mon, 11 Jul 2011 16:45:53 +0300
> > Felipe Balbi <balbi@ti.com> wrote:
> >
> > > On Mon, Jul 11, 2011 at 03:41:26PM +0200, Michael Büsch wrote:
> > > > On Mon, 11 Jul 2011 16:12:32 +0300
> > > > Felipe Balbi <balbi@ti.com> wrote:
> > > > > > Are you planning to implement a backlight driver for tahvo? I'm actually
> > > > > > using the functionality that you removed in this patchset in the OpenWRT
> > > > > > distribution.
> > > > >
> > > > > if you have some extra documentation available, I could implement it
> > > > > whenever I have some extra couple hours to play with this again... I
> > > > > have no docs at all, but a led-tahvo.c would be really simple to get
> > > > > done :-)
> > > >
> > > > All I have is the old code. No docs. It seems rather simple, though.
> > > > Only a PWM register. That's pretty straightforward.
> > >
> > > cool, any pointers would be good ;-)
> >
> > Pointers to what? How PWM works?
> > http://en.wikipedia.org/wiki/Pulse_width_modulation
> >
> > You probably don't need to know the details, though.
> > Just write a 0 to the register to turn the LED off. And write
> > a 0xF (or 0x7F depending on tahvo revision) to the register to
> > turn it fully on. Any value in between to dim the LED.
>
> no, not to PWM... pointers to the code using the old interface ;-)
Oh, got it now. :D
This patch connects the tahvo backlight API to the MIPID/omapfb backlight API:
https://dev.openwrt.org/browser/trunk/target/linux/omap24xx/patches-2.6.38/820-backlight-fixes.patch
The actual backlight control is done in userspace:
http://bues.ch/gitweb?p=pwrtray.git;a=summary
http://bues.ch/gitweb?p=pwrtray.git;a=blob;f=backend/backlight_omapfb.c;hb=HEAD
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 30+ messages in thread
end of thread, other threads:[~2011-07-11 14:19 UTC | newest]
Thread overview: 30+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-11 11:17 [PATCH 00/22] Tahvo cleanups and Retu optimization Felipe Balbi
2011-07-11 11:17 ` [PATCH 01/22] cbus: tahvo: convert spinlock into mutex Felipe Balbi
2011-07-11 11:17 ` [PATCH 02/22] cbus: tahvo: move to __devinit/__devexit sections Felipe Balbi
2011-07-11 11:17 ` [PATCH 03/22] cbus: tahvo: a switch looks better Felipe Balbi
2011-07-11 11:17 ` [PATCH 04/22] cbus: tahvo: don't go over 80 columns Felipe Balbi
2011-07-11 11:17 ` [PATCH 05/22] cbus: tahvo: drop the tasklet Felipe Balbi
2011-07-11 11:17 ` [PATCH 06/22] cbus: retu: set IRQF_ONESHOT flag Felipe Balbi
2011-07-11 11:17 ` [PATCH 07/22] cbus: tahvo: git it a context structure Felipe Balbi
2011-07-11 11:17 ` [PATCH 08/22] cbus: tahvo: pass tahvo to IRQ handler Felipe Balbi
2011-07-11 11:17 ` [PATCH 09/22] cbus: tahvo: introduce __tahvo_(read/write)_reg Felipe Balbi
2011-07-11 11:17 ` [PATCH 10/22] cbus: tahvo: drop some unneded defines Felipe Balbi
2011-07-11 11:17 ` [PATCH 11/22] cbus: retu: IRQ demux optimization Felipe Balbi
2011-07-11 11:17 ` [PATCH 12/22] cbus: tahvo: give it an irq_chip Felipe Balbi
2011-07-11 11:17 ` [PATCH 13/22] cbus: tahvo: start using irq_chip Felipe Balbi
2011-07-11 11:17 ` [PATCH 14/22] cbus: tahvo: usb: fix up to use threaded irqs Felipe Balbi
2011-07-11 11:17 ` [PATCH 15/22] cbus: tahvo drop the legacy interfaces Felipe Balbi
2011-07-11 11:17 ` [PATCH 16/22] cbus: tahvo: usb: drop unused variable Felipe Balbi
2011-07-11 11:17 ` [PATCH 17/22] cbus: tahvo: no need to mask interrupts on exit Felipe Balbi
2011-07-11 11:17 ` [PATCH 18/22] cbus: tahvo: drop the get_status hack Felipe Balbi
2011-07-11 11:17 ` [PATCH 19/22] cbus: tahvo: drop more unused interfaces Felipe Balbi
2011-07-11 11:17 ` [PATCH 20/22] cbus: tahvo: pass child device pointer Felipe Balbi
2011-07-11 11:17 ` [PATCH 21/22] cbus: tahvo: drop backlight interfaces Felipe Balbi
2011-07-11 11:17 ` [PATCH 22/22] cbus: tahvo: drop static global pointer Felipe Balbi
2011-07-11 11:28 ` [PATCH 00/22] Tahvo cleanups and Retu optimization Michael Büsch
2011-07-11 13:12 ` Felipe Balbi
2011-07-11 13:41 ` Michael Büsch
2011-07-11 13:45 ` Felipe Balbi
2011-07-11 13:51 ` Michael Büsch
2011-07-11 14:03 ` Felipe Balbi
2011-07-11 14:19 ` Michael Büsch
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox