CBUS meets GENIRQ
Subsystems (4)
cover CBUS meets GENIRQ
Hi Tony,
When you have some extra time, could you run these on N810 to check whether I'm on the right path ? After these patches all CBUS drivers are using standard request_threaded_irq() calls. It's one step closer into getting those in mainline.
Felipe Balbi (13):
cbus: retu: get rid of retu-user.c
cbus: retu: give it a context structure
cbus: retu: move module_* close to the matching symbol
cbus: retu: cleanup error path
arm: omap: irqs: add CBUS_RETU_IRQ_BASE and CBUS_RETU_IRQ_END
arm: omap: cbus: pass irq_base and irq_end via platform_data
cbus: retu: move to threaded IRQ and GENIRQ
cbus: retu: headset: convert to threaded_irq
cbus: retu-pwrbutton: convert to threaded irq
cbus: retu-rtc: move to threaded irq
cbus: retu-rtc: drop the reset_occurred flag
cbus: Makefile: re-enable retu-wdt
cbus: tahvo: drop tahvo-user
arch/arm/mach-omap1/board-nokia770.c | 8 + arch/arm/mach-omap2/board-n8x0.c | 8 + arch/arm/plat-omap/include/plat/cbus.h | 5 + arch/arm/plat-omap/include/plat/irqs.h | 10 +- drivers/cbus/Kconfig | 14 - drivers/cbus/Makefile | 3 +- drivers/cbus/retu-headset.c | 22 +- drivers/cbus/retu-pwrbutton.c | 37 +-- drivers/cbus/retu-rtc.c | 130 ++--------- drivers/cbus/retu-user.c | 424 -------------------------------- drivers/cbus/retu.c | 394 ++++++++++++++---------------- drivers/cbus/retu.h | 12 - drivers/cbus/tahvo-user.c | 406 ------------------------------ drivers/cbus/tahvo.c | 11 - drivers/cbus/tahvo.h | 5 - 15 files changed, 258 insertions(+), 1231 deletions(-) delete mode 100644 drivers/cbus/retu-user.c delete mode 100644 drivers/cbus/tahvo-user.c
Signature · 1 line
1.7.4.rc2
PATCH 1/13 cbus: retu: get rid of retu-user.c
Drop that non-standard of accessing Retu
as it's bypassing all the correct layers.
--- drivers/cbus/Kconfig | 7 - drivers/cbus/Makefile | 1 - drivers/cbus/retu-user.c | 424 ---------------------------------------------- drivers/cbus/retu.c | 19 -- drivers/cbus/retu.h | 5 - 5 files changed, 0 insertions(+), 456 deletions(-) delete mode 100644 drivers/cbus/retu-user.c
drivers/cbus/Kconfig +0 -7
@@ -49,13 +49,6 @@ config CBUS_RETU If you want Retu support, you should say Y here. -config CBUS_RETU_USER - depends on CBUS_RETU - bool "Support for Retu user space functions" - ---help--- - If you want support for Retu's user space read/write etc. functions, - you should say Y here. - config CBUS_RETU_POWERBUTTON depends on CBUS_RETU bool "Support for Retu power button"
drivers/cbus/Makefile +0 -1
@@ -10,5 +10,4 @@ obj-$(CONFIG_CBUS_RETU_POWERBUTTON) += retu-pwrbutton.o obj-$(CONFIG_CBUS_RETU_RTC) += retu-rtc.o obj-$(CONFIG_CBUS_RETU_WDT) += retu-wdt.o obj-$(CONFIG_CBUS_TAHVO_USER) += tahvo-user.o -obj-$(CONFIG_CBUS_RETU_USER) += retu-user.o obj-$(CONFIG_CBUS_RETU_HEADSET) += retu-headset.o
drivers/cbus/retu-user.c deleted +0 -424
424 lines not on this page · raw message
drivers/cbus/retu.c +0 -19
@@ -376,10 +376,6 @@ static int retu_allocate_children(struct device *parent)if (!child)return -ENOMEM ; - child =retu_allocate_child ("retu-user" , parent); -if (!child) -return -ENOMEM ; - child =retu_allocate_child ("retu-wdt" , parent);if (!child)return -ENOMEM ;
@@ -428,21 +424,9 @@ static int __init retu_probe(struct platform_device *pdev)/* Register power off function */ pm_power_off = retu_power_off; -#ifdef CONFIG_CBUS_RETU_USER -/* Initialize user-space interface */ -if (retu_user_init () <0 ) { -dev_err (&pdev->dev,"Unable to initialize driver\n" ); -free_irq (irq,0 ); -return ret; - } -#endif - ret =retu_allocate_children (&pdev->dev);if (ret <0 ) {dev_err (&pdev->dev,"Unable to allocate Retu children\n" ); -#ifdef CONFIG_CBUS_RETU_USER -retu_user_cleanup (); -#endif retu_write_reg (RETU_REG_IMR ,0xffff );free_irq (irq,0 );tasklet_kill (&retu_tasklet);
@@ -458,9 +442,6 @@ static int __exit retu_remove(struct platform_device *pdev) irq =platform_get_irq (pdev,0 ); -#ifdef CONFIG_CBUS_RETU_USER -retu_user_cleanup (); -#endif /* Mask all RETU interrupts */ retu_write_reg (RETU_REG_IMR ,0xffff );free_irq (irq,0 );
drivers/cbus/retu.h +0 -5
@@ -68,11 +68,6 @@ void retu_enable_irq(int id);void retu_disable_irq (int id);void retu_ack_irq (int id); -#ifdef CONFIG_CBUS_RETU_USER -int retu_user_init (void ); -void retu_user_cleanup (void ); -#endif -extern spinlock_t retu_lock;#endif /* __DRIVERS_CBUS_RETU_H */
Signature · 1 line
1.7.4.rc2
PATCH 2/13 cbus: retu: give it a context structure
In reply to Felipe BalbiThis is pretty much a cleanup patch just adding a context structure for Retu, to avoid all the globals it had.
Note that this breaks retu-user.c due to moving the lock around, but that retu-user.c has to go anyway as it's completely non-standard way of accessing Retu children.
--- drivers/cbus/retu.c | 123 ++++++++++++++++++++++++++++++++++----------------- drivers/cbus/retu.h | 2 - 2 files changed, 82 insertions(+), 43 deletions(-)
drivers/cbus/retu.c +82 -41
@@ -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>
@@ -49,11 +50,18 @@#define RETU_ID 0x01#define PFX "retu: " -static int retu_initialized; -static int retu_is_vilma; +struct retu { +/* Device lock */ +spinlock_t lock; +struct tasklet_struct tasklet; +struct device *dev; -static struct tasklet_struct retu_tasklet; -spinlock_t retu_lock =SPIN_LOCK_UNLOCKED ; +int irq; + +bool is_vilma; +}; + +static struct retu *the_retu;struct retu_irq_handler_desc {int (*func)(unsigned long );
@@ -65,7 +73,7 @@ static struct retu_irq_handler_desc retu_irq_handlers[MAX_RETU_IRQ_HANDLERS];int retu_get_status (void ) { -return retu_initialized; +return the_retu ?1 :0 ; }EXPORT_SYMBOL (retu_get_status);
@@ -77,7 +85,7 @@ EXPORT_SYMBOL(retu_get_status);*/ int retu_read_reg (unsigned reg) { -BUG_ON (!retu_initialized); +BUG_ON (!the_retu);return cbus_read_reg (RETU_ID , reg); }EXPORT_SYMBOL (retu_read_reg);
@@ -91,22 +99,23 @@ EXPORT_SYMBOL(retu_read_reg);*/ void retu_write_reg (unsigned reg,u16 val) { -BUG_ON (!retu_initialized); +BUG_ON (!the_retu);cbus_write_reg (RETU_ID , reg, val); }EXPORT_SYMBOL (retu_write_reg);void retu_set_clear_reg_bits (unsigned reg,u16 set,u16 clear) { -unsigned long flags; -u16 w; +struct retu *retu = the_retu; +unsigned long flags; +u16 w; -spin_lock_irqsave (&retu_lock, flags); +spin_lock_irqsave (&retu->lock, flags); w =retu_read_reg (reg); w &= ~clear; w |= set;retu_write_reg (reg, w); -spin_unlock_irqrestore (&retu_lock, flags); +spin_unlock_irqrestore (&retu->lock, flags); }EXPORT_SYMBOL_GPL (retu_set_clear_reg_bits);
@@ -114,15 +123,19 @@ EXPORT_SYMBOL_GPL(retu_set_clear_reg_bits);int retu_read_adc (int channel) { -unsigned long flags; -int res; +struct retu *retu = the_retu; +unsigned long flags; +int res; + +if (!retu) +return -ENODEV ;if (channel <0 || channel >ADC_MAX_CHAN_NUMBER )return -EINVAL ; -spin_lock_irqsave (&retu_lock, flags); +spin_lock_irqsave (&retu->lock, flags); -if ((channel ==8 ) && retu_is_vilma) { +if ((channel ==8 ) && retu->is_vilma) {int scr =retu_read_reg (RETU_REG_ADCSCR );int ch = (retu_read_reg (RETU_REG_ADCR ) >>10 ) &0xf ;if (((scr &0xff ) !=0 ) && (ch !=8 ))
@@ -133,11 +146,11 @@ int retu_read_adc(int channel)retu_write_reg (RETU_REG_ADCR , channel <<10 ); res =retu_read_reg (RETU_REG_ADCR ) &0x3ff ; -if (retu_is_vilma) +if (retu->is_vilma)retu_write_reg (RETU_REG_ADCR , (1 <<13 ));/* Unlock retu */ -spin_unlock_irqrestore (&retu_lock, flags); +spin_unlock_irqrestore (&retu->lock, flags);return res; }
@@ -164,15 +177,16 @@ static u16 retu_disable_bogus_irqs(u16 mask)*/ void retu_disable_irq (int id) { -unsigned long flags; -u16 mask; +struct retu *retu = the_retu; +unsigned long flags; +u16 mask; -spin_lock_irqsave (&retu_lock, flags); +spin_lock_irqsave (&retu->lock, flags); mask =retu_read_reg (RETU_REG_IMR ); mask |=1 << id; mask =retu_disable_bogus_irqs (mask);retu_write_reg (RETU_REG_IMR , mask); -spin_unlock_irqrestore (&retu_lock, flags); +spin_unlock_irqrestore (&retu->lock, flags); }EXPORT_SYMBOL (retu_disable_irq);
@@ -181,19 +195,21 @@ EXPORT_SYMBOL(retu_disable_irq);*/ void retu_enable_irq (int id) { -unsigned long flags; -u16 mask; +struct retu *retu = the_retu; +unsigned long flags; +u16 mask;if (id ==3 ) {printk ("Enabling Retu IRQ %d\n" , id);dump_stack (); } -spin_lock_irqsave (&retu_lock, flags); + +spin_lock_irqsave (&retu->lock, flags); mask =retu_read_reg (RETU_REG_IMR ); mask &= ~(1 << id); mask =retu_disable_bogus_irqs (mask);retu_write_reg (RETU_REG_IMR , mask); -spin_unlock_irqrestore (&retu_lock, flags); +spin_unlock_irqrestore (&retu->lock, flags); }EXPORT_SYMBOL (retu_enable_irq);
@@ -209,9 +225,12 @@ EXPORT_SYMBOL(retu_ack_irq);/* * RETU interrupt handler. Only schedules the tasklet. */ -static irqreturn_t retu_irq_handler (int irq,void *dev_id) +static irqreturn_t retu_irq_handler (int irq,void *_retu) { -tasklet_schedule (&retu_tasklet); +struct retu *retu = _retu; + +tasklet_schedule (&retu->tasklet); +return IRQ_HANDLED ; }
@@ -259,9 +278,10 @@ static void retu_tasklet_handler(unsigned long data)*/ int retu_request_irq (int id,void *irq_handler,unsigned long arg,char *name) { -struct retu_irq_handler_desc *hnd; +struct retu *retu = the_retu; +struct retu_irq_handler_desc *hnd; -if (!retu_initialized) +if (!retu)return -ENODEV ; if (irq_handler == NULL || id >= MAX_RETU_IRQ_HANDLERS ||
@@ -392,30 +412,46 @@ static int retu_allocate_children(struct device *parent)*/ static int __init retu_probe (struct platform_device *pdev) { -int rev, ret; -int irq; +struct retu *retu; +int rev; +int ret; +int irq; + + retu =kzalloc (sizeof (*retu),GFP_KERNEL ); +if (!retu) { +dev_err (&pdev->dev,"not enough memory\n" ); +return -ENOMEM ; + } + +platform_set_drvdata (pdev, retu); + the_retu = retu;/* Prepare tasklet */ -tasklet_init (&retu_tasklet, retu_tasklet_handler,0 ); +tasklet_init (&retu->tasklet, retu_tasklet_handler,0 ); +spin_lock_init (&retu->lock); irq =platform_get_irq (pdev,0 ); - retu_initialized =1 ; + retu->irq = irq; rev =retu_read_reg (RETU_REG_ASICR ) &0xff ;if (rev & (1 <<7 )) - retu_is_vilma =1 ; + retu->is_vilma = true; -dev_info (&pdev->dev,"%s v%d.%d found\n" , retu_is_vilma ?"Vilma" :"Retu" , - (rev >>4 ) &0x07 , rev &0x0f ); +dev_info (&pdev->dev,"%s v%d.%d found\n" , + retu->is_vilma ?"Vilma" :"Retu" , + (rev >>4 ) &0x07 , rev &0x0f );/* Mask all RETU interrupts */ retu_write_reg (RETU_REG_IMR ,0xffff ); ret =request_irq (irq, retu_irq_handler,0 , -"retu" ,0 ); +"retu" , retu);if (ret <0 ) {dev_err (&pdev->dev,"Unable to register IRQ handler\n" ); +tasklet_kill (&retu->tasklet); +kfree (retu); + the_retu =NULL ;return ret; }
@@ -429,7 +465,9 @@ static int __init retu_probe(struct platform_device *pdev)dev_err (&pdev->dev,"Unable to allocate Retu children\n" );retu_write_reg (RETU_REG_IMR ,0xffff );free_irq (irq,0 ); -tasklet_kill (&retu_tasklet); +tasklet_kill (&retu->tasklet); +kfree (retu); + the_retu =NULL ;return ret; }
@@ -438,14 +476,17 @@ static int __init retu_probe(struct platform_device *pdev) static int __exit retu_remove(struct platform_device *pdev) { -int irq; +struct retu *retu =platform_get_drvdata (pdev); +int irq; irq =platform_get_irq (pdev,0 );/* Mask all RETU interrupts */ retu_write_reg (RETU_REG_IMR ,0xffff ); -free_irq (irq,0 ); -tasklet_kill (&retu_tasklet); +free_irq (irq, retu); +tasklet_kill (&retu->tasklet); +kfree (retu); + the_retu =NULL ;return 0 ; }
drivers/cbus/retu.h +0 -2
@@ -68,6 +68,4 @@ void retu_enable_irq(int id);void retu_disable_irq (int id);void retu_ack_irq (int id); -extern spinlock_t retu_lock; -#endif /* __DRIVERS_CBUS_RETU_H */
Signature · 1 line
1.7.4.rc2
PATCH 3/13 cbus: retu: move module_* close to the matching symbol
In reply to Felipe BalbiJust to make checkpatch.pl a bit happier, movesubsys_initcall() and module_exit() closer to
the init and exit functions of the driver.
--- drivers/cbus/retu.c | 11 +---------- 1 files changed, 1 insertions(+), 10 deletions(-)
drivers/cbus/retu.c +1 -10
@@ -498,25 +498,16 @@ static struct platform_driver retu_driver = { }, }; -/** -* retu_init - initialise Retu driver -* -* Initialise the Retu driver and return 0 if everything worked ok -*/ static int __init retu_init (void ) {return platform_driver_probe (&retu_driver, retu_probe); } +subsys_initcall (retu_init); -/* -* Cleanup -*/ static void __exit retu_exit(void) {platform_driver_unregister (&retu_driver); } - -subsys_initcall (retu_init);module_exit (retu_exit);MODULE_DESCRIPTION ("Retu ASIC control" );
Signature · 1 line
1.7.4.rc2
PATCH 4/13 cbus: retu: cleanup error path
In reply to Felipe BalbiTrivial cleanup patch shuffling error path
around.
--- drivers/cbus/retu.c | 29 +++++++++++++++++------------ 1 files changed, 17 insertions(+), 12 deletions(-)
drivers/cbus/retu.c +17 -12
@@ -413,14 +413,15 @@ static int retu_allocate_children(struct device *parent)static int __init retu_probe (struct platform_device *pdev) {struct retu *retu; + +int ret = -ENOMEM ;int rev; -int ret;int irq; retu =kzalloc (sizeof (*retu),GFP_KERNEL );if (!retu) {dev_err (&pdev->dev,"not enough memory\n" ); -return -ENOMEM ; + goto err0; }platform_set_drvdata (pdev, retu);
@@ -449,10 +450,7 @@ static int __init retu_probe(struct platform_device *pdev) "retu", retu);if (ret <0 ) {dev_err (&pdev->dev,"Unable to register IRQ handler\n" ); -tasklet_kill (&retu->tasklet); -kfree (retu); - the_retu =NULL ; -return ret; + goto err1; }set_irq_wake (irq,1 );
@@ -463,15 +461,22 @@ static int __init retu_probe(struct platform_device *pdev) ret =retu_allocate_children (&pdev->dev);if (ret <0 ) {dev_err (&pdev->dev,"Unable to allocate Retu children\n" ); -retu_write_reg (RETU_REG_IMR ,0xffff ); -free_irq (irq,0 ); -tasklet_kill (&retu->tasklet); -kfree (retu); - the_retu =NULL ; -return ret; + goto err2; }return 0 ; + +err2: +retu_write_reg (RETU_REG_IMR ,0xffff ); +free_irq (irq, retu); + +err1: +tasklet_kill (&retu->tasklet); +kfree (retu); + the_retu =NULL ; + +err0: +return ret; } static int __exit retu_remove(struct platform_device *pdev)
Signature · 1 line
1.7.4.rc2
PATCH 5/13 arm: omap: irqs: add CBUS_RETU_IRQ_BASE and CBUS_RETU_IRQ_END
In reply to Felipe Balbithose two will be used to pass down irq_base and irq_end to retu platform_driver.
--- arch/arm/plat-omap/include/plat/irqs.h | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletions(-)
arch/arm/plat-omap/include/plat/irqs.h +9 -1
@@ -411,7 +411,15 @@#define TWL_IRQ_END TWL6030_IRQ_END#endif -#define NR_IRQS TWL_IRQ_END +#define CBUS_RETU_IRQ_BASE TWL_IRQ_END +#ifdef CONFIG_CBUS_RETU +#define CBUS_RETU_NR_IRQS 16 +#else +#define CBUS_RETU_NR_IRQS 0 +#endif +#define CBUS_RETU_IRQ_END (CBUS_RETU_IRQ_BASE + CBUS_RETU_NR_IRQS) + +#define NR_IRQS CBUS_RETU_IRQ_END#define OMAP_IRQ_BIT (irq) (1 << ((irq) % 32))
Signature · 1 line
1.7.4.rc2
PATCH 6/13 arm: omap: cbus: pass irq_base and irq_end via platform_data
In reply to Felipe BalbiPass CBUS_RETU_IRQ_BASE and CBUS_RETU_IRQ_END viaplatform_data to retu platform_driver.
--- arch/arm/mach-omap1/board-nokia770.c | 8 ++++++++ arch/arm/mach-omap2/board-n8x0.c | 8 ++++++++ arch/arm/plat-omap/include/plat/cbus.h | 5 +++++ 3 files changed, 21 insertions(+), 0 deletions(-)
arch/arm/mach-omap1/board-nokia770.c +8 -0
@@ -123,11 +123,19 @@ static struct resource retu_resource[] = { }, }; +static struct cbus_retu_platform_data nokia770_retu_data = { + .irq_base =CBUS_RETU_IRQ_BASE , + .irq_end =CBUS_RETU_IRQ_END , +}; +static struct platform_device retu_device = { .name ="retu" , .id =-1 , .resource = retu_resource, .num_resources =ARRAY_SIZE (retu_resource), + .dev = { + .platform_data = &nokia770_retu_data, + }, };static struct resource tahvo_resource[] = {
arch/arm/mach-omap2/board-n8x0.c +8 -0
@@ -220,11 +220,19 @@ static struct resource retu_resource[] = { }, }; +static struct cbus_retu_platform_data n8x0_retu_data = { + .irq_base =CBUS_RETU_IRQ_BASE , + .irq_end =CBUS_RETU_IRQ_END , +}; +static struct platform_device retu_device = { .name ="retu" , .id =-1 , .resource = retu_resource, .num_resources =ARRAY_SIZE (retu_resource), + .dev = { + .platform_data = &n8x0_retu_data, + }, };static struct resource tahvo_resource[] = {
arch/arm/plat-omap/include/plat/cbus.h +5 -0
@@ -28,4 +28,9 @@ struct cbus_host_platform_data { int sel_gpio; }; +struct cbus_retu_platform_data { +int irq_base; +int irq_end; +}; +#endif /* __PLAT_CBUS_H */
Signature · 1 line
1.7.4.rc2
PATCH 7/13 cbus: retu: move to threaded IRQ and GENIRQ
In reply to Felipe BalbiStart moving retu to threaded IRQ and while
at that also give retu an irq_chip so children
can use generic request_threaded_irq() calls.
--- drivers/cbus/Makefile | 10 +- drivers/cbus/retu.c | 270 +++++++++++++++++++++---------------------------- drivers/cbus/retu.h | 5 - 3 files changed, 123 insertions(+), 162 deletions(-)
drivers/cbus/Makefile +6 -4
@@ -6,8 +6,10 @@ obj-$(CONFIG_CBUS) += cbus.o obj-$(CONFIG_CBUS_TAHVO) += tahvo.o obj-$(CONFIG_CBUS_RETU) += retu.o obj-$(CONFIG_CBUS_TAHVO_USB) += tahvo-usb.o -obj-$(CONFIG_CBUS_RETU_POWERBUTTON) += retu-pwrbutton.o -obj-$(CONFIG_CBUS_RETU_RTC) += retu-rtc.o -obj-$(CONFIG_CBUS_RETU_WDT) += retu-wdt.o obj-$(CONFIG_CBUS_TAHVO_USER) += tahvo-user.o -obj-$(CONFIG_CBUS_RETU_HEADSET) += retu-headset.o + +## Disable Retu children until converted to threaded IRQ +#obj-$(CONFIG_CBUS_RETU_POWERBUTTON) += retu-pwrbutton.o +#obj-$(CONFIG_CBUS_RETU_RTC) += retu-rtc.o +#obj-$(CONFIG_CBUS_RETU_WDT) += retu-wdt.o +#obj-$(CONFIG_CBUS_RETU_HEADSET) += retu-headset.o
drivers/cbus/retu.c +117 -153
371 lines not on this page · raw message
drivers/cbus/retu.h +0 -5
@@ -62,10 +62,5 @@ int retu_read_reg(unsigned reg);void retu_write_reg (unsigned reg,u16 val);void retu_set_clear_reg_bits (unsigned reg,u16 set,u16 clear);int retu_read_adc (int channel); -int retu_request_irq (int id,void *irq_handler,unsigned long arg,char *name); -void retu_free_irq (int id); -void retu_enable_irq (int id); -void retu_disable_irq (int id); -void retu_ack_irq (int id);#endif /* __DRIVERS_CBUS_RETU_H */
Signature · 1 line
1.7.4.rc2
PATCH 8/13 cbus: retu: headset: convert to threaded_irq
In reply to Felipe Balbiuse the new irq_chip added to retu.c.
--- drivers/cbus/Makefile | 2 +- drivers/cbus/retu-headset.c | 22 ++++++++++++---------- 2 files changed, 13 insertions(+), 11 deletions(-)
drivers/cbus/Makefile +1 -1
@@ -12,4 +12,4 @@ obj-$(CONFIG_CBUS_TAHVO_USER) += tahvo-user.o #obj-$(CONFIG_CBUS_RETU_POWERBUTTON) += retu-pwrbutton.o #obj-$(CONFIG_CBUS_RETU_RTC) += retu-rtc.o #obj-$(CONFIG_CBUS_RETU_WDT) += retu-wdt.o -#obj-$(CONFIG_CBUS_RETU_HEADSET) += retu-headset.o +obj-$(CONFIG_CBUS_RETU_HEADSET) += retu-headset.o
drivers/cbus/retu-headset.c +12 -10
@@ -22,6 +22,8 @@#include <linux/module.h> #include <linux/init.h> #include <linux/kernel.h> +#include <linux/irq.h> +#include <linux/interrupt.h> #include <linux/slab.h> #include <linux/delay.h> #include <linux/input.h>
@@ -84,7 +86,6 @@ static void retu_headset_det_enable(struct retu_headset *hs)if (!hs->detection_enabled) { hs->detection_enabled =1 ;retu_set_clear_reg_bits (RETU_REG_CC1 , (1 <<10 ) | (1 <<8 ),0 ); -retu_enable_irq (RETU_INT_HOOK ); }mutex_unlock (&hs->mutex); }
@@ -96,7 +97,6 @@ static void retu_headset_det_disable(struct retu_headset *hs)mutex_lock (&hs->mutex);if (hs->detection_enabled) { hs->detection_enabled =0 ; -retu_disable_irq (RETU_INT_HOOK );del_timer_sync (&hs->enable_timer);del_timer_sync (&hs->detect_timer);spin_lock_irqsave (&hs->lock, flags);
@@ -177,12 +177,11 @@ static DEVICE_ATTR(enable_det, S_IRUGO | S_IWUSR | S_IWGRP, retu_headset_enable_det_show, retu_headset_enable_det_store); -static void retu_headset_hook_interrupt (unsigned long arg) +static irqreturn_t retu_headset_hook_interrupt (int irq,void *_hs) { -struct retu_headset *hs = (struct retu_headset *) arg; -unsigned long flags; +struct retu_headset *hs = _hs; +unsigned long flags; -retu_ack_irq (RETU_INT_HOOK );spin_lock_irqsave (&hs->lock, flags);if (!hs->pressed) {/* Headset button was just pressed down. */
@@ -192,6 +191,8 @@ static void retu_headset_hook_interrupt(unsigned long arg)spin_unlock_irqrestore (&hs->lock, flags);retu_set_clear_reg_bits (RETU_REG_CC1 ,0 , (1 <<10 ) | (1 <<8 ));mod_timer (&hs->enable_timer, jiffies +msecs_to_jiffies (50 )); + +return IRQ_HANDLED ; }static void retu_headset_enable_timer (unsigned long arg)
@@ -257,13 +258,13 @@ static int __init retu_headset_probe(struct platform_device *pdev)setup_timer (&hs->detect_timer, retu_headset_detect_timer, (unsigned long ) hs); - r =retu_request_irq (RETU_INT_HOOK , retu_headset_hook_interrupt, - (unsigned long ) hs,"hookdet" ); + r =request_threaded_irq (RETU_INT_HOOK ,NULL , + retu_headset_hook_interrupt,0 ,"hookdet" , hs);if (r !=0 ) {dev_err (&pdev->dev,"hookdet IRQ not available\n" ); goto err6; } -retu_disable_irq (RETU_INT_HOOK ); +return 0 ; err6:device_remove_file (&pdev->dev, &dev_attr_enable_det);
@@ -289,9 +290,10 @@ 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); -retu_free_irq (RETU_INT_HOOK ); +free_irq (RETU_INT_HOOK , hs);input_unregister_device (hs->idev);input_free_device (hs->idev); +return 0 ; }
Signature · 1 line
1.7.4.rc2
PATCH 9/13 cbus: retu-pwrbutton: convert to threaded irq
In reply to Felipe BalbiDrop the timer function and move to threaded
irq infrastructure.
--- drivers/cbus/Makefile | 2 +- drivers/cbus/retu-pwrbutton.c | 37 +++++++++---------------------------- 2 files changed, 10 insertions(+), 29 deletions(-)
drivers/cbus/Makefile +1 -1
@@ -9,7 +9,7 @@ obj-$(CONFIG_CBUS_TAHVO_USB) += tahvo-usb.o obj-$(CONFIG_CBUS_TAHVO_USER) += tahvo-user.o ## Disable Retu children until converted to threaded IRQ -#obj-$(CONFIG_CBUS_RETU_POWERBUTTON) += retu-pwrbutton.o +obj-$(CONFIG_CBUS_RETU_POWERBUTTON) += retu-pwrbutton.o #obj-$(CONFIG_CBUS_RETU_RTC) += retu-rtc.o #obj-$(CONFIG_CBUS_RETU_WDT) += retu-wdt.o obj-$(CONFIG_CBUS_RETU_HEADSET) += retu-headset.o
drivers/cbus/retu-pwrbutton.c +9 -28
@@ -30,9 +30,10 @@#include <linux/kernel.h> #include <linux/errno.h> #include <linux/input.h> -#include <linux/timer.h> #include <linux/jiffies.h> #include <linux/bitops.h> +#include <linux/irq.h> +#include <linux/interrupt.h> #include <linux/platform_device.h> #include <linux/slab.h>
@@ -46,15 +47,14 @@struct retu_pwrbutton {struct input_dev *idev; -struct timer_list timer;int state;int irq; }; -static void retubutton_timer_func (unsigned long arg) +static irqreturn_t retubutton_irq (int irq,void *_pwr) { -struct retu_pwrbutton *pwr = (struct retu_pwrbutton *) arg; +struct retu_pwrbutton *pwr = _pwr;int state;if (retu_read_reg (RETU_REG_STATUS ) &RETU_STATUS_PWRONX )
@@ -67,24 +67,10 @@ static void retubutton_timer_func(unsigned long arg)input_sync (pwr->idev); pwr->state = state; } -} - -/** -* Interrupt function is called whenever power button key is pressed -* or released. -*/ -static void retubutton_irq (unsigned long arg) -{ -struct retu_pwrbutton *pwr = (struct retu_pwrbutton *) arg; -retu_ack_irq (RETU_INT_PWR ); -mod_timer (&pwr->timer, jiffies +msecs_to_jiffies (PWRBTN_DELAY )); +return IRQ_HANDLED ; } -/** -* Init function. -* Allocates interrupt for power button and registers itself to input layer. -*/ static int __init retubutton_probe (struct platform_device *pdev) {struct retu_pwrbutton *pwr;
@@ -99,10 +85,9 @@ static int __init retubutton_probe(struct platform_device *pdev) pwr->irq =RETU_INT_PWR ;platform_set_drvdata (pdev, pwr); -setup_timer (&pwr->timer, retubutton_timer_func, (unsigned long ) pwr); - ret =retu_request_irq (pwr->irq, retubutton_irq, (unsigned long ) pwr, -"PwrOnX" ); + ret =request_threaded_irq (pwr->irq,NULL , retubutton_irq,0 , +"retu-pwrbutton" , pwr);if (ret <0 ) {dev_err (&pdev->dev,"Cannot allocate irq\n" ); goto err1;
@@ -131,7 +116,7 @@ err3:input_free_device (pwr->idev); err2: -retu_free_irq (pwr->irq); +free_irq (pwr->irq, pwr); err1:kfree (pwr);
@@ -140,15 +125,11 @@ err0:return ret; } -/** -* Cleanup function which is called when driver is unloaded -*/ static int __exit retubutton_remove(struct platform_device *pdev) {struct retu_pwrbutton *pwr =platform_get_drvdata (pdev); -retu_free_irq (pwr->irq); -del_timer_sync (&pwr->timer); +free_irq (pwr->irq, pwr);input_unregister_device (pwr->idev);input_free_device (pwr->idev);kfree (pwr);
Signature · 1 line
1.7.4.rc2
PATCH 10/13 cbus: retu-rtc: move to threaded irq
In reply to Felipe BalbiMove to the generic threaded irq infrastructure and drop all the retu-specific magic.
Unfortunately, due to the conversion and lack of docs, retu_rtc_ioctl() had to be dropped, someone else with access to docs is free to implement it later considering the new style of the driver.
--- drivers/cbus/Makefile | 2 +- drivers/cbus/retu-rtc.c | 120 ++++++---------------------------------------- 2 files changed, 17 insertions(+), 105 deletions(-)
drivers/cbus/Makefile +1 -1
@@ -10,6 +10,6 @@ obj-$(CONFIG_CBUS_TAHVO_USER) += tahvo-user.o ## Disable Retu children until converted to threaded IRQ obj-$(CONFIG_CBUS_RETU_POWERBUTTON) += retu-pwrbutton.o -#obj-$(CONFIG_CBUS_RETU_RTC) += retu-rtc.o +obj-$(CONFIG_CBUS_RETU_RTC) += retu-rtc.o #obj-$(CONFIG_CBUS_RETU_WDT) += retu-wdt.o obj-$(CONFIG_CBUS_RETU_HEADSET) += retu-headset.o
drivers/cbus/retu-rtc.c +16 -104
206 lines not on this page · raw message
Signature · 1 line
1.7.4.rc2
PATCH 11/13 cbus: retu-rtc: drop the reset_occurred flag
In reply to Felipe Balbithat flag is never read anyway, only written,
so we can drop it.
--- drivers/cbus/retu-rtc.c | 10 ++-------- 1 files changed, 2 insertions(+), 8 deletions(-)
drivers/cbus/retu-rtc.c +2 -8
@@ -52,7 +52,6 @@ struct retu_rtc {struct rtc_device *rtc;u16 alarm_expired; -u16 reset_occurred; };static void retu_rtc_do_reset (struct retu_rtc *rtc)
@@ -71,7 +70,6 @@ static void retu_rtc_do_reset(struct retu_rtc *rtc)retu_write_reg (RETU_REG_RTCCALR ,0x00c0 ); rtc->alarm_expired =0 ; - rtc->reset_occurred =1 ; }static irqreturn_t retu_rtc_interrupt (int irq,void *_rtc)
@@ -223,14 +221,10 @@ static int __init retu_rtc_probe(struct platform_device *pdev) goto err1; } -/* If the calibration register is zero, we've probably lost -* power */ -if (retu_read_reg (RETU_REG_RTCCALR ) &0x00ff ) - rtc->reset_occurred =0 ; -else +/* If the calibration register is zero, we've probably lost power */ +if (!(retu_read_reg (RETU_REG_RTCCALR ) &0x00ff ))retu_rtc_do_reset (rtc); - rtc->rtc =rtc_device_register (pdev->name, &pdev->dev, & retu_rtc_ops,THIS_MODULE );if (IS_ERR (rtc->rtc)) {
Signature · 1 line
1.7.4.rc2
PATCH 12/13 cbus: Makefile: re-enable retu-wdt
In reply to Felipe BalbiNow that all conversions have been made,
reenable retu-wdt driver.
--- drivers/cbus/Makefile | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-)
drivers/cbus/Makefile +1 -2
@@ -8,8 +8,7 @@ obj-$(CONFIG_CBUS_RETU) += retu.o obj-$(CONFIG_CBUS_TAHVO_USB) += tahvo-usb.o obj-$(CONFIG_CBUS_TAHVO_USER) += tahvo-user.o -## Disable Retu children until converted to threaded IRQ obj-$(CONFIG_CBUS_RETU_POWERBUTTON) += retu-pwrbutton.o obj-$(CONFIG_CBUS_RETU_RTC) += retu-rtc.o -#obj-$(CONFIG_CBUS_RETU_WDT) += retu-wdt.o +obj-$(CONFIG_CBUS_RETU_WDT) += retu-wdt.o obj-$(CONFIG_CBUS_RETU_HEADSET) += retu-headset.o
Signature · 1 line
1.7.4.rc2
PATCH 13/13 cbus: tahvo: drop tahvo-user
In reply to Felipe Balbiget rid of the non-standard way of accessing
the chip.
--- drivers/cbus/Kconfig | 7 - drivers/cbus/Makefile | 1 - drivers/cbus/tahvo-user.c | 406 --------------------------------------------- drivers/cbus/tahvo.c | 11 -- drivers/cbus/tahvo.h | 5 - 5 files changed, 0 insertions(+), 430 deletions(-) delete mode 100644 drivers/cbus/tahvo-user.c
drivers/cbus/Kconfig +0 -7
@@ -21,13 +21,6 @@ config CBUS_TAHVO If you want Tahvo support, you should say Y here. -config CBUS_TAHVO_USER - depends on CBUS_TAHVO - bool "Support for Tahvo user space functions" - ---help--- - If you want support for Tahvo's user space read/write etc. functions, - you should say Y here. - config CBUS_TAHVO_USB depends on CBUS_TAHVO && USB tristate "Support for Tahvo USB transceiver"
drivers/cbus/Makefile +0 -1
@@ -6,7 +6,6 @@ obj-$(CONFIG_CBUS) += cbus.o obj-$(CONFIG_CBUS_TAHVO) += tahvo.o obj-$(CONFIG_CBUS_RETU) += retu.o obj-$(CONFIG_CBUS_TAHVO_USB) += tahvo-usb.o -obj-$(CONFIG_CBUS_TAHVO_USER) += tahvo-user.o obj-$(CONFIG_CBUS_RETU_POWERBUTTON) += retu-pwrbutton.o obj-$(CONFIG_CBUS_RETU_RTC) += retu-rtc.o
drivers/cbus/tahvo-user.c deleted +0 -406
406 lines not on this page · raw message
drivers/cbus/tahvo.c +0 -11
@@ -338,14 +338,6 @@ static int __init tahvo_probe(struct platform_device *pdev)dev_err (&pdev->dev,"Unable to register IRQ handler\n" );return ret; } -#ifdef CONFIG_CBUS_TAHVO_USER -/* Initialize user-space interface */ -if (tahvo_user_init () <0 ) { -dev_err (&pdev->dev,"Unable to initialize driver\n" ); -free_irq (irq,0 ); -return ret; - } -#endif return 0 ; }
@@ -355,9 +347,6 @@ static int __exit tahvo_remove(struct platform_device *pdev) irq =platform_get_irq (pdev,0 ); -#ifdef CONFIG_CBUS_TAHVO_USER -tahvo_user_cleanup (); -#endif /* Mask all TAHVO interrupts */ tahvo_write_reg (TAHVO_REG_IMR ,0xffff );free_irq (irq,0 );
drivers/cbus/tahvo.h +0 -5
@@ -52,11 +52,6 @@ int tahvo_get_backlight_level(void);int tahvo_get_max_backlight_level (void );void tahvo_set_backlight_level (int level); -#ifdef CONFIG_CBUS_TAHVO_USER -int tahvo_user_init (void ); -void tahvo_user_cleanup (void ); -#endif -extern spinlock_t tahvo_lock;#endif /* __DRIVERS_CBUS_TAHVO_H */
Signature · 1 line
1.7.4.rc2
Tony Lindgren
maintainerQuoted 6 lines · Felipe Balbi
Hi Tony,
When you have some extra time, could you run these on N810 to check whether I'm on the right path ? After these patches all CBUS drivers are using standard
request_threaded_irq()calls. It's one step closer into getting those in mainline.
Cool sorry it took a while, this is starting to look like it will be pretty close to be posted for merging :)
I guess we should move files around to have:
drivers/mfd/cbus-retu.cdrivers/mfd/cbus-tahvo.c
drivers/rtc/rtc-cbus-retu.c
...
Anything else remaining to do?
Also the following patch was needed to get this to boot with interrupts working. Maybe you have a better plan for getting the retu irq_base?
Anyways, since n8x0 boots and stays up, we know it's working, so I've pushed them all to the cbus branch.
Regards,
Tony
From: Tony Lindgren <[email protected]>
Date: Wed, 9 Feb 2011 18:36:16 -0800
Subject: [PATCH] cbus: Fix nested interrupts for retu
We need to add the retu irq base number to the interrupt number for children.
This could be done by passing the interrupt base for children in platform_data also I guess.
drivers/cbus/retu-headset.c +2 -2
@@ -258,7 +258,7 @@ 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 (RETU_INT_HOOK ,NULL , + r =request_threaded_irq (CBUS_RETU_IRQ_BASE +RETU_INT_HOOK ,NULL , retu_headset_hook_interrupt,0 ,"hookdet" , hs);if (r !=0 ) {dev_err (&pdev->dev,"hookdet IRQ not available\n" );
@@ -290,7 +290,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 (RETU_INT_HOOK , hs); +free_irq (CBUS_RETU_IRQ_BASE +RETU_INT_HOOK , hs);input_unregister_device (hs->idev);input_free_device (hs->idev);
drivers/cbus/retu-pwrbutton.c +1 -1
@@ -83,7 +83,7 @@ static int __init retubutton_probe(struct platform_device *pdev) goto err0; } - pwr->irq =RETU_INT_PWR ; + pwr->irq =CBUS_RETU_IRQ_BASE +RETU_INT_PWR ;platform_set_drvdata (pdev, pwr); ret = request_threaded_irq(pwr->irq, NULL, retubutton_irq, 0,
drivers/cbus/retu-rtc.c +7 -7
@@ -88,15 +88,15 @@ static int retu_rtc_init_irq(struct retu_rtc *rtc) {int ret; - ret =request_threaded_irq (RETU_INT_RTCS ,NULL , retu_rtc_interrupt, + ret =request_threaded_irq (CBUS_RETU_IRQ_BASE +RETU_INT_RTCS ,NULL , retu_rtc_interrupt,0 ,"RTCS" , rtc);if (ret !=0 )return ret; - ret =request_threaded_irq (RETU_INT_RTCA ,NULL , retu_rtc_interrupt, + ret =request_threaded_irq (CBUS_RETU_IRQ_BASE +RETU_INT_RTCA ,NULL , retu_rtc_interrupt,0 ,"RTCA" , rtc);if (ret !=0 ) { -free_irq (RETU_INT_RTCS , rtc); +free_irq (CBUS_RETU_IRQ_BASE +RETU_INT_RTCS , rtc);return ret; }
@@ -235,8 +235,8 @@ static int __init retu_rtc_probe(struct platform_device *pdev)return 0 ; err2: -free_irq (RETU_INT_RTCS , rtc); -free_irq (RETU_INT_RTCA , rtc); +free_irq (CBUS_RETU_IRQ_BASE +RETU_INT_RTCS , rtc); +free_irq (CBUS_RETU_IRQ_BASE +RETU_INT_RTCA , rtc); err1:kfree (rtc);
@@ -249,8 +249,8 @@ static int __devexit retu_rtc_remove(struct platform_device *pdev) {struct retu_rtc *rtc =platform_get_drvdata (pdev); -free_irq (RETU_INT_RTCS , rtc); -free_irq (RETU_INT_RTCA , rtc); +free_irq (CBUS_RETU_IRQ_BASE +RETU_INT_RTCS , rtc); +free_irq (CBUS_RETU_IRQ_BASE +RETU_INT_RTCA , rtc);rtc_device_unregister (rtc->rtc);kfree (rtc);
Hi,
Quoted 9 lines · Tony Lindgren
Quoted 6 lines · Felipe Balbi
Hi Tony,
When you have some extra time, could you run these on N810 to check whether I'm on the right path ? After these patches all CBUS drivers are using standard
request_threaded_irq()calls. It's one step closer into getting those in mainline.Cool sorry it took a while, this is starting to look like
no problem ;-)
Quoted 1 line
it will be pretty close to be posted for merging :)
yeah, I guess so too.
Quoted 6 lines
I guess we should move files around to have:
drivers/mfd/cbus-retu.cdrivers/mfd/cbus-tahvo.c
drivers/rtc/rtc-cbus-retu.c
sure we gotta do that.
Quoted 1 line
Anything else remaining to do?
there are a few things remaining still. The drivers aren't as good as I'd like them to be yet.
Quoted 3 lines
Also the following patch was needed to get this to boot with interrupts working. Maybe you have a better plan for getting the retu
irq_base?
That's on my TODO list, I need to pass IRQ number via pdata.
Quoted 2 lines
Anyways, since n8x0 boots and stays up, we know it's working, so I've pushed them all to the cbus branch.
Cool thanks. I'll update my local cbus branch based on yours and try to find some time to play with the last few stuff. Maybe I'll have some small time during the weekend which I could use to play with it.
Signature · 1 line
balbi