Omap mailbox updates for omap4 for 2.6.33
Subsystems (3)
Tony Lindgren
maintainercover Omap mailbox updates for omap4 for 2.6.33
Hi all,
Here are omap4 related mailbox changes for review.
Regards,
Tony
---
C A Subramaniam (6):
omap: mailbox: Add build specific changes to support omap mailbox
omap: mailbox: Add resources and mailbox register base address for OMAP4 mailbox
omap: mailbox: remove unnecessary arg for omap_mbox_msg_send
omap: mailbox: Adds code changes to support OMAP4 mailbox
omap: mailbox: OMAP4 Mailbox Patch to change the IRQ flag from IRQF_DISABLED to IRQF_SHARED
omap: mailbox: OMAP4 Mailbox-driver Patch to support tasklet implementation
Hiroshi DOYU (4):
omap: mailbox: remove sequence bit checking
omap: mailbox: remove class interface
omap: mailbox: remove disable_/enable_mbox_irq in isr
omap: mailbox: Expose omap_mbox_enable()/disable_irq()
arch/arm/mach-omap2/Makefile | 3 arch/arm/mach-omap2/devices.c | 36 +++- arch/arm/mach-omap2/mailbox.c | 140 ++++++++++++-- arch/arm/plat-omap/include/plat/mailbox.h | 23 ++ arch/arm/plat-omap/include/plat/omap44xx.h | 2 arch/arm/plat-omap/mailbox.c | 282 +++++----------------------- 6 files changed, 217 insertions(+), 269 deletions(-)
Signature · 1 line
Signature
Tony Lindgren
maintainerPATCH 1/10 omap: mailbox: Add build specific changes to support omap mailbox
From: C A Subramaniam <[email protected]>
This patch adds changes to the build related files of mailbox driver
--- arch/arm/mach-omap2/Makefile | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/Makefile +3 -0
@@ -44,6 +44,9 @@ obj-$(CONFIG_ARCH_OMAP4) += cm4xxx.o obj-$(CONFIG_ARCH_OMAP2) += clock24xx.o obj-$(CONFIG_ARCH_OMAP3) += clock34xx.o +obj-$(CONFIG_OMAP_MBOX_FWK) += mailbox_mach.o +mailbox_mach-objs := mailbox.o + iommu-y += iommu2.o iommu-$(CONFIG_ARCH_OMAP3) += omap3-iommu.o
Tony Lindgren
maintainerPATCH 2/10 omap: mailbox: Add resources and mailbox register base address for OMAP4 mailbox
In reply to Tony LindgrenFrom: C A Subramaniam <[email protected]>
This patch adds resource information of mailbox driver for OMAP4 mailbox module. Register base address also added
--- arch/arm/mach-omap2/devices.c | 36 +++++++++++++++++++++------- arch/arm/plat-omap/include/plat/omap44xx.h | 2 ++ 2 files changed, 29 insertions(+), 9 deletions(-)
arch/arm/mach-omap2/devices.c +27 -9
@@ -136,9 +136,10 @@ static inline void omap_init_camera(void) #if defined(CONFIG_OMAP_MBOX_FWK) || defined(CONFIG_OMAP_MBOX_FWK_MODULE) -#define MBOX_REG_SIZE 0x120 +#define MBOX_REG_SIZE 0x120 -static struct resource omap2_mbox_resources[] = { +#ifdef CONFIG_ARCH_OMAP2 +static struct resource omap_mbox_resources[] = { { .start = OMAP24XX_MAILBOX_BASE, .end = OMAP24XX_MAILBOX_BASE + MBOX_REG_SIZE - 1,
@@ -153,8 +154,10 @@ static struct resource omap2_mbox_resources[] = { .flags = IORESOURCE_IRQ, }, }; +#endif -static struct resource omap3_mbox_resources[] = { +#ifdef CONFIG_ARCH_OMAP3 +static struct resource omap_mbox_resources[] = { { .start = OMAP34XX_MAILBOX_BASE, .end = OMAP34XX_MAILBOX_BASE + MBOX_REG_SIZE - 1,
@@ -165,6 +168,24 @@ static struct resource omap3_mbox_resources[] = { .flags = IORESOURCE_IRQ, }, }; +#endif + +#ifdef CONFIG_ARCH_OMAP4 + +#define OMAP4_MBOX_REG_SIZE 0x130 +static struct resource omap_mbox_resources[] = { + { + .start =OMAP44XX_MAILBOX_BASE , + .end =OMAP44XX_MAILBOX_BASE + +OMAP4_MBOX_REG_SIZE -1 , + .flags =IORESOURCE_MEM , + }, + { + .start =INT_44XX_MAIL_U0_MPU , + .flags =IORESOURCE_IRQ , + }, +}; +#endif static struct platform_device mbox_device = { .name ="omap2-mailbox" ,
@@ -173,12 +194,9 @@ static struct platform_device mbox_device = {static inline void omap_init_mbox (void ) { -if (cpu_is_omap2420 ()) { - mbox_device.num_resources =ARRAY_SIZE (omap2_mbox_resources); - mbox_device.resource = omap2_mbox_resources; - }else if (cpu_is_omap3430 ()) { - mbox_device.num_resources =ARRAY_SIZE (omap3_mbox_resources); - mbox_device.resource = omap3_mbox_resources; +if (cpu_is_omap2420 () ||cpu_is_omap3430 () ||cpu_is_omap44xx ()) { + mbox_device.num_resources =ARRAY_SIZE (omap_mbox_resources); + mbox_device.resource = omap_mbox_resources; }else {pr_err ("%s: platform not supported\n" , __func__);return ;
arch/arm/plat-omap/include/plat/omap44xx.h +2 -0
@@ -40,5 +40,7 @@#define OMAP44XX_LOCAL_TWD_BASE 0x48240600#define OMAP44XX_WKUPGEN_BASE 0x48281000 +#define OMAP44XX_MAILBOX_BASE (L4_44XX_BASE + 0xF4000) +#endif /* __ASM_ARCH_OMAP44XX_H */
Tony Lindgren
maintainerPATCH 3/10 omap: mailbox: remove sequence bit checking
In reply to Tony LindgrenFrom: Hiroshi DOYU <[email protected]>
Any protocol should be handled in the upper layer and mailbox driver shouldn't care about the contents of messages.
--- arch/arm/plat-omap/mailbox.c | 70 ++---------------------------------------- 1 files changed, 4 insertions(+), 66 deletions(-)
arch/arm/plat-omap/mailbox.c +4 -66
@@ -28,54 +28,9 @@#include <plat/mailbox.h> -static int enable_seq_bit; -module_param (enable_seq_bit, bool,0 ); -MODULE_PARM_DESC (enable_seq_bit,"Enable sequence bit checking." ); -static struct omap_mbox *mboxes;static DEFINE_RWLOCK (mboxes_lock); -/* -* Mailbox sequence bit API -*/ - -/* seq_rcv should be initialized with any value other than -* 0 and 1 << 31, to allow either value for the first -* message. */ -static inline void mbox_seq_init (struct omap_mbox *mbox) -{ -if (!enable_seq_bit) -return ; - -/* any value other than 0 and 1 << 31 */ - mbox->seq_rcv =0xffffffff ; -} - -static inline void mbox_seq_toggle (struct omap_mbox *mbox,mbox_msg_t * msg) -{ -if (!enable_seq_bit) -return ; - -/* add seq_snd to msg */ - *msg = (*msg &0x7fffffff ) | mbox->seq_snd; -/* flip seq_snd */ - mbox->seq_snd ^=1 <<31 ; -} - -static inline int mbox_seq_test (struct omap_mbox *mbox,mbox_msg_t msg) -{ -mbox_msg_t seq; - -if (!enable_seq_bit) -return 0 ; - - seq = msg & (1 <<31 ); -if (seq == mbox->seq_rcv) -return -1 ; - mbox->seq_rcv = seq; -return 0 ; -} -/* Mailbox FIFO handle functions */ static inline mbox_msg_t mbox_fifo_read (struct omap_mbox *mbox) {
@@ -113,13 +68,6 @@ static inline int is_mbox_irq(struct omap_mbox *mbox, omap_mbox_irq_t irq)return mbox->ops->is_irq (mbox, irq); } -/* Mailbox Sequence Bit function */ -void omap_mbox_init_seq (struct omap_mbox *mbox) -{ -mbox_seq_init (mbox); -} -EXPORT_SYMBOL (omap_mbox_init_seq); -/* * message sender */
@@ -141,7 +89,6 @@ static int __mbox_msg_send(struct omap_mbox *mbox, mbox_msg_t msg, void *arg) goto out; } -mbox_seq_toggle (mbox, &msg);mbox_fifo_write (mbox, msg); out:return ret;
@@ -254,11 +201,11 @@ static void mbox_rx_work(struct work_struct *work)/* * Mailbox interrupt handler */ -static void mbox_txq_fn (struct request_queue * q) +static void mbox_txq_fn (struct request_queue *q) { } -static void mbox_rxq_fn (struct request_queue * q) +static void mbox_rxq_fn (struct request_queue *q) { }
@@ -284,11 +231,6 @@ static void __mbox_rx_interrupt(struct omap_mbox *mbox) msg =mbox_fifo_read (mbox); -if (unlikely (mbox_seq_test (mbox, msg))) { -pr_info ("mbox: Illegal seq bit!(%08x)\n" , msg); -if (mbox->err_notify) - mbox->err_notify (); - }blk_insert_request (q, rq,0 , (void *)msg);if (mbox->ops->type ==OMAP_MBOX_TYPE1 )
@@ -320,7 +262,7 @@ static irqreturn_t mbox_interrupt(int irq, void *p)*/ static ssize_t omap_mbox_write (struct device *dev,struct device_attribute *attr, -const char * buf,size_t count) +const char *buf,size_t count) {int ret;mbox_msg_t *p = (mbox_msg_t *)buf;
@@ -357,10 +299,6 @@ omap_mbox_read(struct device *dev, struct device_attribute *attr, char *buf)blk_end_request_all (rq,0 ); -if (unlikely (mbox_seq_test (mbox, *p))) { -pr_info ("mbox: Illegal seq bit!(%08x) ignored\n" , *p); -continue ; - } p++; }
@@ -383,7 +321,7 @@ static struct class omap_mbox_class = { };static struct omap_mbox_queue *mbox_queue_alloc (struct omap_mbox *mbox, -request_fn_proc * proc, +request_fn_proc *proc,void (*work) (struct work_struct *)) {struct request_queue *q;
Tony Lindgren
maintainerPATCH 4/10 omap: mailbox: remove class interface
In reply to Tony LindgrenFrom: Hiroshi DOYU <[email protected]>
It's not used at present.
--- arch/arm/plat-omap/include/plat/mailbox.h | 1 arch/arm/plat-omap/mailbox.c | 115 ++--------------------------- 2 files changed, 9 insertions(+), 107 deletions(-)
arch/arm/plat-omap/include/plat/mailbox.h +0 -1
@@ -8,7 +8,6 @@#include <linux/blkdev.h> typedef u32 mbox_msg_t ; -typedef void (mbox_receiver_t )(mbox_msg_t msg);struct omap_mbox ;typedef int __bitwise omap_mbox_irq_t ;
arch/arm/plat-omap/mailbox.c +9 -106
187 lines not on this page · raw message
Tony Lindgren
maintainerPATCH 5/10 omap: mailbox: remove disable_/enable_mbox_irq in isr
In reply to Tony LindgrenFrom: Hiroshi DOYU <[email protected]>
No need to handle it in isr, since irq won't happen during isr.
--- arch/arm/plat-omap/mailbox.c | 3 --- 1 files changed, 0 insertions(+), 3 deletions(-)
arch/arm/plat-omap/mailbox.c +0 -3
@@ -209,8 +209,6 @@ static void __mbox_rx_interrupt(struct omap_mbox *mbox)mbox_msg_t msg;struct request_queue *q = mbox->rxq->queue; -disable_mbox_irq (mbox,IRQ_RX ); -while (!mbox_fifo_empty (mbox)) { rq =blk_get_request (q,WRITE ,GFP_ATOMIC );if (unlikely (!rq))
@@ -226,7 +224,6 @@ static void __mbox_rx_interrupt(struct omap_mbox *mbox)/* no more messages in the fifo. clear IRQ source. */ ack_mbox_irq (mbox,IRQ_RX ); -enable_mbox_irq (mbox,IRQ_RX ); nomem:schedule_work (&mbox->rxq->work); }
Tony Lindgren
maintainerPATCH 6/10 omap: mailbox: remove unnecessary arg for omap_mbox_msg_send
In reply to Tony LindgrenFrom: C A Subramaniam <[email protected]>
Also removed from tx_data
--- arch/arm/plat-omap/include/plat/mailbox.h | 2 +- arch/arm/plat-omap/mailbox.c | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-)
arch/arm/plat-omap/include/plat/mailbox.h +1 -1
@@ -63,7 +63,7 @@ struct omap_mbox {void (*err_notify)(void ); }; -int omap_mbox_msg_send (struct omap_mbox *,mbox_msg_t msg,void *); +int omap_mbox_msg_send (struct omap_mbox *,mbox_msg_t msg);void omap_mbox_init_seq (struct omap_mbox *);struct omap_mbox *omap_mbox_get (const char *);
arch/arm/plat-omap/mailbox.c +1 -3
@@ -88,7 +88,6 @@ static int __mbox_msg_send(struct omap_mbox *mbox, mbox_msg_t msg)struct omap_msg_tx_data {mbox_msg_t msg; -void *arg; };static void omap_msg_tx_end_io (struct request *rq,int error)
@@ -97,7 +96,7 @@ static void omap_msg_tx_end_io(struct request *rq, int error)__blk_put_request (rq->q, rq); } -int omap_mbox_msg_send (struct omap_mbox *mbox,mbox_msg_t msg,void * arg) +int omap_mbox_msg_send (struct omap_mbox *mbox,mbox_msg_t msg) {struct omap_msg_tx_data *tx_data;struct request *rq;
@@ -114,7 +113,6 @@ int omap_mbox_msg_send(struct omap_mbox *mbox, mbox_msg_t msg, void* arg) } tx_data->msg = msg; - tx_data->arg = arg; rq->end_io = omap_msg_tx_end_io;blk_insert_request (q, rq,0 , tx_data);
Tony Lindgren
maintainerPATCH 7/10 omap: mailbox: Expose omap_mbox_enable()/disable_irq()
In reply to Tony LindgrenFrom: Hiroshi DOYU <[email protected]>
Expose omap_mbox_enable()/disable_irq()
--- arch/arm/plat-omap/include/plat/mailbox.h | 12 ++++++++++++ arch/arm/plat-omap/mailbox.c | 12 ++---------- 2 files changed, 14 insertions(+), 10 deletions(-)
arch/arm/plat-omap/include/plat/mailbox.h +12 -0
@@ -92,4 +92,16 @@ static inline void omap_mbox_restore_ctx(struct omap_mbox *mbox) mbox->ops->restore_ctx(mbox); } +static inline void omap_mbox_enable_irq (struct omap_mbox *mbox, +omap_mbox_irq_t irq) +{ + mbox->ops->enable_irq (mbox, irq); +} + +static inline void omap_mbox_disable_irq (struct omap_mbox *mbox, +omap_mbox_irq_t irq) +{ + mbox->ops->disable_irq (mbox, irq); +} +#endif /* MAILBOX_H */
arch/arm/plat-omap/mailbox.c +2 -10
@@ -50,14 +50,6 @@ static inline int mbox_fifo_full(struct omap_mbox *mbox) }/* Mailbox IRQ handle functions */ -static inline void enable_mbox_irq (struct omap_mbox *mbox,omap_mbox_irq_t irq) -{ - mbox->ops->enable_irq (mbox, irq); -} -static inline void disable_mbox_irq (struct omap_mbox *mbox,omap_mbox_irq_t irq) -{ - mbox->ops->disable_irq (mbox, irq); -}static inline void ack_mbox_irq (struct omap_mbox *mbox,omap_mbox_irq_t irq) {if (mbox->ops->ack_irq)
@@ -144,7 +136,7 @@ static void mbox_tx_work(struct work_struct *work) ret =__mbox_msg_send (mbox, tx_data->msg);if (ret) { -enable_mbox_irq (mbox,IRQ_TX ); +omap_mbox_enable_irq (mbox,IRQ_TX );spin_lock (q->queue_lock);blk_requeue_request (q, rq);spin_unlock (q->queue_lock);
@@ -196,7 +188,7 @@ static void mbox_rxq_fn(struct request_queue *q)static void __mbox_tx_interrupt (struct omap_mbox *mbox) { -disable_mbox_irq (mbox,IRQ_TX ); +omap_mbox_disable_irq (mbox,IRQ_TX );ack_mbox_irq (mbox,IRQ_TX );schedule_work (&mbox->txq->work); }
Tony Lindgren
maintainerPATCH 8/10 omap: mailbox: Adds code changes to support OMAP4 mailbox
In reply to Tony LindgrenFrom: C A Subramaniam <[email protected]>
This patch adds code changes in the mailbox driver module to add support for OMAP4 mailbox.
--- arch/arm/mach-omap2/mailbox.c | 140 ++++++++++++++++++++++++++++++++++------- arch/arm/plat-omap/mailbox.c | 25 ++++++- 2 files changed, 136 insertions(+), 29 deletions(-)
arch/arm/mach-omap2/mailbox.c +116 -24
@@ -18,6 +18,8 @@#include <plat/mailbox.h> #include <mach/irqs.h> +#define DRV_NAME "omap2-mailbox" +#define MAILBOX_REVISION 0x000#define MAILBOX_SYSCONFIG 0x010#define MAILBOX_SYSSTATUS 0x014
@@ -27,8 +29,12 @@#define MAILBOX_IRQSTATUS (u) (0x100 + 8 * (u))#define MAILBOX_IRQENABLE (u) (0x104 + 8 * (u)) -#define MAILBOX_IRQ_NEWMSG (u) (1 << (2 * (u))) -#define MAILBOX_IRQ_NOTFULL (u) (1 << (2 * (u) + 1)) +#define OMAP4_MAILBOX_IRQSTATUS (u) (0x104 + 10 * (u)) +#define OMAP4_MAILBOX_IRQENABLE (u) (0x108 + 10 * (u)) +#define OMAP4_MAILBOX_IRQENABLE_CLR (u) (0x10c + 10 * (u)) + +#define MAILBOX_IRQ_NEWMSG (m) (1 << (2 * (m))) +#define MAILBOX_IRQ_NOTFULL (m) (1 << (2 * (m) + 1))/* SYSCONFIG: register bit definition */ #define AUTOIDLE (1 << 0)
@@ -39,7 +45,11 @@#define RESETDONE (1 << 0)#define MBOX_REG_SIZE 0x120 + +#define OMAP4_MBOX_REG_SIZE 0x130 +#define MBOX_NR_REGS (MBOX_REG_SIZE / sizeof(u32)) +#define OMAP4_MBOX_NR_REGS (OMAP4_MBOX_REG_SIZE / sizeof(u32))static void __iomem *mbox_base;
@@ -56,7 +66,8 @@ struct omap_mbox2_priv {unsigned long irqstatus;u32 newmsg_bit;u32 notfull_bit; -u32 ctx[MBOX_NR_REGS ]; +u32 ctx[OMAP4_MBOX_NR_REGS ]; +unsigned long irqdisable; };static struct clk *mbox_ick_handle;
@@ -82,8 +93,9 @@ static int omap2_mbox_startup(struct omap_mbox *mbox) mbox_ick_handle =clk_get (NULL ,"mailboxes_ick" );if (IS_ERR (mbox_ick_handle)) { -pr_err ("Can't get mailboxes_ick\n" ); -return -ENODEV ; +printk (KERN_ERR "Could not get mailboxes_ick: %d\n" , +PTR_ERR (mbox_ick_handle)); +return PTR_ERR (mbox_ick_handle); }clk_enable (mbox_ick_handle);
@@ -115,6 +127,7 @@ static void omap2_mbox_shutdown(struct omap_mbox *mbox) {clk_disable (mbox_ick_handle);clk_put (mbox_ick_handle); + mbox_ick_handle =NULL ; }/* Mailbox FIFO handle functions */
@@ -143,7 +156,7 @@ static int omap2_mbox_fifo_full(struct omap_mbox *mbox) {struct omap_mbox2_fifo *fifo = &((struct omap_mbox2_priv *)mbox->priv)->tx_fifo; -return (mbox_read_reg (fifo->fifo_stat)); +return mbox_read_reg (fifo->fifo_stat); }/* Mailbox IRQ handle functions */
@@ -163,10 +176,9 @@ static void omap2_mbox_disable_irq(struct omap_mbox *mbox, {struct omap_mbox2_priv *p = (struct omap_mbox2_priv *)mbox->priv;u32 l, bit = (irq ==IRQ_TX ) ? p->notfull_bit : p->newmsg_bit; - - l =mbox_read_reg (p->irqenable); + l =mbox_read_reg (p->irqdisable); l &= ~bit; -mbox_write_reg (l, p->irqenable); +mbox_write_reg (l, p->irqdisable); } static void omap2_mbox_ack_irq(struct omap_mbox *mbox,
@@ -189,15 +201,19 @@ static int omap2_mbox_is_irq(struct omap_mbox *mbox,u32 enable =mbox_read_reg (p->irqenable);u32 status =mbox_read_reg (p->irqstatus); -return (enable & status & bit); +return (int )(enable & status & bit); }static void omap2_mbox_save_ctx (struct omap_mbox *mbox) {int i;struct omap_mbox2_priv *p = mbox->priv; - -for (i =0 ; i <MBOX_NR_REGS ; i++) { +int nr_regs; +if (cpu_is_omap44xx ()) + nr_regs =OMAP4_MBOX_NR_REGS ; +else + nr_regs =MBOX_NR_REGS ; +for (i =0 ; i < nr_regs; i++) { p->ctx[i] =mbox_read_reg (i *sizeof (u32)); dev_dbg(mbox->dev, "%s: [%02x] %08x\n", __func__,
@@ -209,8 +225,12 @@ static void omap2_mbox_restore_ctx(struct omap_mbox *mbox) {int i;struct omap_mbox2_priv *p = mbox->priv; - -for (i =0 ; i <MBOX_NR_REGS ; i++) { +int nr_regs; +if (cpu_is_omap44xx ()) + nr_regs =OMAP4_MBOX_NR_REGS ; +else + nr_regs =MBOX_NR_REGS ; +for (i =0 ; i < nr_regs; i++) {mbox_write_reg (p->ctx[i], i *sizeof (u32)); dev_dbg(mbox->dev, "%s: [%02x] %08x\n", __func__,
@@ -242,7 +262,6 @@ static struct omap_mbox_ops omap2_mbox_ops = {*/ /* FIXME: the following structs should be filled automatically by the user id */ -/* DSP */ static struct omap_mbox2_priv omap2_mbox_dsp_priv = { .tx_fifo = {
@@ -257,8 +276,36 @@ static struct omap_mbox2_priv omap2_mbox_dsp_priv = { .irqstatus = MAILBOX_IRQSTATUS(0), .notfull_bit = MAILBOX_IRQ_NOTFULL(0), .newmsg_bit = MAILBOX_IRQ_NEWMSG(1), + .irqdisable = MAILBOX_IRQENABLE(0), +}; + + + +/* OMAP4 specific data structure. Use the cpu_is_omap4xxx() +to use this*/ +static struct omap_mbox2_priv omap2_mbox_1_priv = { + .tx_fifo = { + .msg =MAILBOX_MESSAGE (0 ), + .fifo_stat =MAILBOX_FIFOSTATUS (0 ), + }, + .rx_fifo = { + .msg =MAILBOX_MESSAGE (1 ), + .msg_stat =MAILBOX_MSGSTATUS (1 ), + }, + .irqenable =OMAP4_MAILBOX_IRQENABLE (0 ), + .irqstatus =OMAP4_MAILBOX_IRQSTATUS (0 ), + .notfull_bit =MAILBOX_IRQ_NOTFULL (0 ), + .newmsg_bit =MAILBOX_IRQ_NEWMSG (1 ), + .irqdisable =OMAP4_MAILBOX_IRQENABLE_CLR (0 ), }; +struct omap_mbox mbox_1_info = { + .name ="mailbox-1" , + .ops = &omap2_mbox_ops, + .priv = &omap2_mbox_1_priv, +}; +EXPORT_SYMBOL (mbox_1_info); +struct omap_mbox mbox_dsp_info = { .name ="dsp" , .ops = &omap2_mbox_ops,
@@ -266,6 +313,30 @@ struct omap_mbox mbox_dsp_info = { };EXPORT_SYMBOL (mbox_dsp_info); +static struct omap_mbox2_priv omap2_mbox_2_priv = { + .tx_fifo = { + .msg =MAILBOX_MESSAGE (3 ), + .fifo_stat =MAILBOX_FIFOSTATUS (3 ), + }, + .rx_fifo = { + .msg =MAILBOX_MESSAGE (2 ), + .msg_stat =MAILBOX_MSGSTATUS (2 ), + }, + .irqenable =OMAP4_MAILBOX_IRQENABLE (0 ), + .irqstatus =OMAP4_MAILBOX_IRQSTATUS (0 ), + .notfull_bit =MAILBOX_IRQ_NOTFULL (3 ), + .newmsg_bit =MAILBOX_IRQ_NEWMSG (2 ), + .irqdisable =OMAP4_MAILBOX_IRQENABLE_CLR (0 ), +}; + +struct omap_mbox mbox_2_info = { + .name ="mailbox-2" , + .ops = &omap2_mbox_ops, + .priv = &omap2_mbox_2_priv, +}; +EXPORT_SYMBOL (mbox_2_info); + + #if defined(CONFIG_ARCH_OMAP2420) /* IVA */ static struct omap_mbox2_priv omap2_mbox_iva_priv = { .tx_fifo = {
@@ -280,6 +351,7 @@ static struct omap_mbox2_priv omap2_mbox_iva_priv = { .irqstatus = MAILBOX_IRQSTATUS(3), .notfull_bit = MAILBOX_IRQ_NOTFULL(2), .newmsg_bit = MAILBOX_IRQ_NEWMSG(3), + .irqdisable = MAILBOX_IRQENABLE(3), };static struct omap_mbox mbox_iva_info = {
@@ -305,17 +377,31 @@ static int __devinit omap2_mbox_probe(struct platform_device *pdev)return -ENOMEM ;/* DSP or IVA2 IRQ */ - ret =platform_get_irq (pdev,0 ); -if (ret <0 ) { + res =platform_get_resource (pdev,IORESOURCE_IRQ ,0 ); + +if (unlikely (!res)) {dev_err (&pdev->dev,"invalid irq resource\n" ); + ret = -ENODEV ; goto err_dsp; } - mbox_dsp_info.irq = ret; - - ret =omap_mbox_register (&pdev->dev, &mbox_dsp_info); +if (cpu_is_omap44xx ()) { + mbox_1_info.irq = res->start; + ret =omap_mbox_register (&pdev->dev, &mbox_1_info); + }else { + mbox_dsp_info.irq = res->start; + ret =omap_mbox_register (&pdev->dev, &mbox_dsp_info); + }if (ret) goto err_dsp; +if (cpu_is_omap44xx ()) { + mbox_2_info.irq = res->start; + ret =omap_mbox_register (&pdev->dev, &mbox_2_info); +if (ret) { +omap_mbox_unregister (&mbox_1_info); + goto err_dsp; + } + }#if defined(CONFIG_ARCH_OMAP2420 )/* IVA */ if (cpu_is_omap2420 ()) {/* IVA IRQ */
@@ -335,6 +421,7 @@ static int __devinit omap2_mbox_probe(struct platform_device *pdev) err_iva1:omap_mbox_unregister (&mbox_dsp_info); + err_dsp:iounmap (mbox_base);return ret;
@@ -345,7 +432,12 @@ static int __devexit omap2_mbox_remove(struct platform_device *pdev)#if defined(CONFIG_ARCH_OMAP2420 )omap_mbox_unregister (&mbox_iva_info);#endif -omap_mbox_unregister (&mbox_dsp_info); + +if (cpu_is_omap44xx ()) { +omap_mbox_unregister (&mbox_2_info); +omap_mbox_unregister (&mbox_1_info); + }else +omap_mbox_unregister (&mbox_dsp_info);iounmap (mbox_base);return 0 ; }
@@ -354,7 +446,7 @@ static struct platform_driver omap2_mbox_driver = { .probe = omap2_mbox_probe, .remove = __devexit_p(omap2_mbox_remove), .driver = { - .name = "omap2-mailbox", + .name = DRV_NAME, }, };
@@ -372,6 +464,6 @@ module_init(omap2_mbox_init);module_exit (omap2_mbox_exit);MODULE_LICENSE ("GPL v2" ); -MODULE_DESCRIPTION ("omap mailbox: omap2/3 architecture specific functions" ); +MODULE_DESCRIPTION ("omap mailbox: omap2/3/4 architecture specific functions" );MODULE_AUTHOR ("Hiroshi DOYU <[email protected]>, Paul Mundt" ); -MODULE_ALIAS ("platform:omap2-mailbox" ); +MODULE_ALIAS ("platform:" DRV_NAME );
arch/arm/plat-omap/mailbox.c +20 -5
@@ -31,6 +31,8 @@static struct omap_mbox *mboxes;static DEFINE_RWLOCK (mboxes_lock); +static int mbox_configured; +/* Mailbox FIFO handle functions */ static inline mbox_msg_t mbox_fifo_read (struct omap_mbox *mbox) {
@@ -266,13 +268,20 @@ static void mbox_queue_free(struct omap_mbox_queue *q)static int omap_mbox_startup (struct omap_mbox *mbox) { -int ret; +int ret =0 ;struct omap_mbox_queue *mq;if (likely (mbox->ops->startup)) { - ret = mbox->ops->startup (mbox); -if (unlikely (ret)) +write_lock (&mboxes_lock); +if (!mbox_configured) + ret = mbox->ops->startup (mbox); + +if (unlikely (ret)) { +write_unlock (&mboxes_lock);return ret; + } + mbox_configured++; +write_unlock (&mboxes_lock); } ret = request_irq(mbox->irq, mbox_interrupt, IRQF_DISABLED,
@@ -317,8 +326,14 @@ static void omap_mbox_fini(struct omap_mbox *mbox)free_irq (mbox->irq, mbox); -if (unlikely (mbox->ops->shutdown)) - mbox->ops->shutdown (mbox); +if (unlikely (mbox->ops->shutdown)) { +write_lock (&mboxes_lock); +if (mbox_configured >0 ) + mbox_configured--; +if (!mbox_configured) + mbox->ops->shutdown (mbox); +write_unlock (&mboxes_lock); + } }static struct omap_mbox **find_mboxes (const char *name)
Tony Lindgren
maintainerPATCH 9/10 omap: mailbox: OMAP4 Mailbox Patch to change the IRQ flag from IRQF_DISABLED to IRQF_SHARED
In reply to Tony LindgrenFrom: C A Subramaniam <[email protected]>
Currently, this facilitates both the tesla and ducati sides to request for the same irq through an omap_mbox_get() call.
--- arch/arm/plat-omap/mailbox.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
arch/arm/plat-omap/mailbox.c +1 -1
@@ -284,7 +284,7 @@ static int omap_mbox_startup(struct omap_mbox *mbox)write_unlock (&mboxes_lock); } - ret =request_irq (mbox->irq, mbox_interrupt,IRQF_DISABLED , + ret =request_irq (mbox->irq, mbox_interrupt,IRQF_SHARED , mbox->name, mbox);if (unlikely (ret)) { printk(KERN_ERR
Tony Lindgren
maintainerPATCH 10/10 omap: mailbox: OMAP4 Mailbox-driver Patch to support tasklet implementation
In reply to Tony LindgrenFrom: C A Subramaniam <[email protected]>
This patch uses a tasklet implementation for sending mailbox messages.
--- arch/arm/plat-omap/include/plat/mailbox.h | 8 +++- arch/arm/plat-omap/mailbox.c | 59 ++++++++--------------------- 2 files changed, 23 insertions(+), 44 deletions(-)
arch/arm/plat-omap/include/plat/mailbox.h +6 -2
@@ -6,6 +6,7 @@#include <linux/wait.h> #include <linux/workqueue.h> #include <linux/blkdev.h> +#include <linux/interrupt.h> typedef u32 mbox_msg_t ;struct omap_mbox ;
@@ -28,8 +29,10 @@ struct omap_mbox_ops {int (*fifo_empty)(struct omap_mbox *mbox);int (*fifo_full)(struct omap_mbox *mbox);/* irq */ -void (*enable_irq)(struct omap_mbox *mbox,omap_mbox_irq_t irq); -void (*disable_irq)(struct omap_mbox *mbox,omap_mbox_irq_t irq); +void (*enable_irq)(struct omap_mbox *mbox, +omap_mbox_irq_t irq); +void (*disable_irq)(struct omap_mbox *mbox, +omap_mbox_irq_t irq);void (*ack_irq)(struct omap_mbox *mbox,omap_mbox_irq_t irq);int (*is_irq)(struct omap_mbox *mbox,omap_mbox_irq_t irq);/* ctx */
@@ -41,6 +44,7 @@ struct omap_mbox_queue {spinlock_t lock;struct request_queue *queue;struct work_struct work; +struct tasklet_struct tasklet;int (*callback)(void *);struct omap_mbox *mbox; };
arch/arm/plat-omap/mailbox.c +17 -42
127 lines not on this page · raw message