Commit d21872b3 authored by Tony Lindgren's avatar Tony Lindgren

Merge branch 'v2.6.35-omap-mailbox-for-next' of...

Merge branch 'v2.6.35-omap-mailbox-for-next' of git://gitorious.org/~doyu/lk/mainline into omap-for-linus

Conflicts:
	arch/arm/mach-omap1/devices.c
parents 80690ccc b3e69146
/* /*
* Mailbox reservation modules for DSP * Mailbox reservation modules for OMAP1
* *
* Copyright (C) 2006-2009 Nokia Corporation * Copyright (C) 2006-2009 Nokia Corporation
* Written by: Hiroshi DOYU <Hiroshi.DOYU@nokia.com> * Written by: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
...@@ -9,13 +9,10 @@ ...@@ -9,13 +9,10 @@
* for more details. * for more details.
*/ */
#include <linux/kernel.h>
#include <linux/resource.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/io.h> #include <linux/io.h>
#include <plat/mailbox.h> #include <plat/mailbox.h>
#include <mach/irqs.h>
#define MAILBOX_ARM2DSP1 0x00 #define MAILBOX_ARM2DSP1 0x00
#define MAILBOX_ARM2DSP1b 0x04 #define MAILBOX_ARM2DSP1b 0x04
...@@ -83,7 +80,7 @@ static int omap1_mbox_fifo_full(struct omap_mbox *mbox) ...@@ -83,7 +80,7 @@ static int omap1_mbox_fifo_full(struct omap_mbox *mbox)
struct omap_mbox1_fifo *fifo = struct omap_mbox1_fifo *fifo =
&((struct omap_mbox1_priv *)mbox->priv)->rx_fifo; &((struct omap_mbox1_priv *)mbox->priv)->rx_fifo;
return (mbox_read_reg(fifo->flag)); return mbox_read_reg(fifo->flag);
} }
/* irq */ /* irq */
...@@ -141,47 +138,37 @@ struct omap_mbox mbox_dsp_info = { ...@@ -141,47 +138,37 @@ struct omap_mbox mbox_dsp_info = {
.ops = &omap1_mbox_ops, .ops = &omap1_mbox_ops,
.priv = &omap1_mbox_dsp_priv, .priv = &omap1_mbox_dsp_priv,
}; };
EXPORT_SYMBOL(mbox_dsp_info);
struct omap_mbox *omap1_mboxes[] = { &mbox_dsp_info, NULL };
static int __devinit omap1_mbox_probe(struct platform_device *pdev) static int __devinit omap1_mbox_probe(struct platform_device *pdev)
{ {
struct resource *res; struct resource *mem;
int ret;
int i;
struct omap_mbox **list;
if (pdev->num_resources != 2) { list = omap1_mboxes;
dev_err(&pdev->dev, "invalid number of resources: %d\n", list[0]->irq = platform_get_irq_byname(pdev, "dsp");
pdev->num_resources);
return -ENODEV;
}
/* MBOX base */ mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); mbox_base = ioremap(mem->start, resource_size(mem));
if (unlikely(!res)) { if (!mbox_base)
dev_err(&pdev->dev, "invalid mem resource\n"); return -ENOMEM;
return -ENODEV;
}
mbox_base = ioremap(res->start, resource_size(res)); ret = omap_mbox_register(&pdev->dev, list);
if (!mbox_base) { if (ret) {
dev_err(&pdev->dev, "ioremap failed\n");
return -ENODEV;
}
/* DSP IRQ */
res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
if (unlikely(!res)) {
dev_err(&pdev->dev, "invalid irq resource\n");
iounmap(mbox_base); iounmap(mbox_base);
return -ENODEV; return ret;
} }
mbox_dsp_info.irq = res->start;
return omap_mbox_register(&pdev->dev, &mbox_dsp_info); return 0;
} }
static int __devexit omap1_mbox_remove(struct platform_device *pdev) static int __devexit omap1_mbox_remove(struct platform_device *pdev)
{ {
omap_mbox_unregister(&mbox_dsp_info); omap_mbox_unregister();
iounmap(mbox_base);
return 0; return 0;
} }
...@@ -189,7 +176,7 @@ static struct platform_driver omap1_mbox_driver = { ...@@ -189,7 +176,7 @@ static struct platform_driver omap1_mbox_driver = {
.probe = omap1_mbox_probe, .probe = omap1_mbox_probe,
.remove = __devexit_p(omap1_mbox_remove), .remove = __devexit_p(omap1_mbox_remove),
.driver = { .driver = {
.name = "omap1-mailbox", .name = "omap-mailbox",
}, },
}; };
......
...@@ -152,10 +152,12 @@ static struct resource omap2_mbox_resources[] = { ...@@ -152,10 +152,12 @@ static struct resource omap2_mbox_resources[] = {
{ {
.start = INT_24XX_MAIL_U0_MPU, .start = INT_24XX_MAIL_U0_MPU,
.flags = IORESOURCE_IRQ, .flags = IORESOURCE_IRQ,
.name = "dsp",
}, },
{ {
.start = INT_24XX_MAIL_U3_MPU, .start = INT_24XX_MAIL_U3_MPU,
.flags = IORESOURCE_IRQ, .flags = IORESOURCE_IRQ,
.name = "iva",
}, },
}; };
static int omap2_mbox_resources_sz = ARRAY_SIZE(omap2_mbox_resources); static int omap2_mbox_resources_sz = ARRAY_SIZE(omap2_mbox_resources);
...@@ -174,6 +176,7 @@ static struct resource omap3_mbox_resources[] = { ...@@ -174,6 +176,7 @@ static struct resource omap3_mbox_resources[] = {
{ {
.start = INT_24XX_MAIL_U0_MPU, .start = INT_24XX_MAIL_U0_MPU,
.flags = IORESOURCE_IRQ, .flags = IORESOURCE_IRQ,
.name = "dsp",
}, },
}; };
static int omap3_mbox_resources_sz = ARRAY_SIZE(omap3_mbox_resources); static int omap3_mbox_resources_sz = ARRAY_SIZE(omap3_mbox_resources);
...@@ -195,6 +198,7 @@ static struct resource omap4_mbox_resources[] = { ...@@ -195,6 +198,7 @@ static struct resource omap4_mbox_resources[] = {
{ {
.start = OMAP44XX_IRQ_MAIL_U0, .start = OMAP44XX_IRQ_MAIL_U0,
.flags = IORESOURCE_IRQ, .flags = IORESOURCE_IRQ,
.name = "mbox",
}, },
}; };
static int omap4_mbox_resources_sz = ARRAY_SIZE(omap4_mbox_resources); static int omap4_mbox_resources_sz = ARRAY_SIZE(omap4_mbox_resources);
...@@ -204,7 +208,7 @@ static int omap4_mbox_resources_sz = ARRAY_SIZE(omap4_mbox_resources); ...@@ -204,7 +208,7 @@ static int omap4_mbox_resources_sz = ARRAY_SIZE(omap4_mbox_resources);
#endif #endif
static struct platform_device mbox_device = { static struct platform_device mbox_device = {
.name = "omap2-mailbox", .name = "omap-mailbox",
.id = -1, .id = -1,
}; };
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
* for more details. * for more details.
*/ */
#include <linux/kernel.h>
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/err.h> #include <linux/err.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
...@@ -18,8 +17,6 @@ ...@@ -18,8 +17,6 @@
#include <plat/mailbox.h> #include <plat/mailbox.h>
#include <mach/irqs.h> #include <mach/irqs.h>
#define DRV_NAME "omap2-mailbox"
#define MAILBOX_REVISION 0x000 #define MAILBOX_REVISION 0x000
#define MAILBOX_SYSCONFIG 0x010 #define MAILBOX_SYSCONFIG 0x010
#define MAILBOX_SYSSTATUS 0x014 #define MAILBOX_SYSSTATUS 0x014
...@@ -131,7 +128,7 @@ static int omap2_mbox_startup(struct omap_mbox *mbox) ...@@ -131,7 +128,7 @@ static int omap2_mbox_startup(struct omap_mbox *mbox)
} }
l = mbox_read_reg(MAILBOX_REVISION); l = mbox_read_reg(MAILBOX_REVISION);
pr_info("omap mailbox rev %d.%d\n", (l & 0xf0) >> 4, (l & 0x0f)); pr_debug("omap mailbox rev %d.%d\n", (l & 0xf0) >> 4, (l & 0x0f));
if (cpu_is_omap44xx()) if (cpu_is_omap44xx())
l = OMAP4_SMARTIDLE; l = OMAP4_SMARTIDLE;
...@@ -283,6 +280,8 @@ static struct omap_mbox_ops omap2_mbox_ops = { ...@@ -283,6 +280,8 @@ static struct omap_mbox_ops omap2_mbox_ops = {
*/ */
/* FIXME: the following structs should be filled automatically by the user id */ /* FIXME: the following structs should be filled automatically by the user id */
#if defined(CONFIG_ARCH_OMAP3430) || defined(CONFIG_ARCH_OMAP2420)
/* DSP */ /* DSP */
static struct omap_mbox2_priv omap2_mbox_dsp_priv = { static struct omap_mbox2_priv omap2_mbox_dsp_priv = {
.tx_fifo = { .tx_fifo = {
...@@ -300,10 +299,46 @@ static struct omap_mbox2_priv omap2_mbox_dsp_priv = { ...@@ -300,10 +299,46 @@ static struct omap_mbox2_priv omap2_mbox_dsp_priv = {
.irqdisable = MAILBOX_IRQENABLE(0), .irqdisable = MAILBOX_IRQENABLE(0),
}; };
struct omap_mbox mbox_dsp_info = {
.name = "dsp",
.ops = &omap2_mbox_ops,
.priv = &omap2_mbox_dsp_priv,
};
#endif
#if defined(CONFIG_ARCH_OMAP3430)
struct omap_mbox *omap3_mboxes[] = { &mbox_dsp_info, NULL };
#endif
#if defined(CONFIG_ARCH_OMAP2420)
/* IVA */
static struct omap_mbox2_priv omap2_mbox_iva_priv = {
.tx_fifo = {
.msg = MAILBOX_MESSAGE(2),
.fifo_stat = MAILBOX_FIFOSTATUS(2),
},
.rx_fifo = {
.msg = MAILBOX_MESSAGE(3),
.msg_stat = MAILBOX_MSGSTATUS(3),
},
.irqenable = MAILBOX_IRQENABLE(3),
.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 = {
.name = "iva",
.ops = &omap2_mbox_ops,
.priv = &omap2_mbox_iva_priv,
};
struct omap_mbox *omap2_mboxes[] = { &mbox_iva_info, &mbox_dsp_info, NULL };
#endif
/* OMAP4 specific data structure. Use the cpu_is_omap4xxx() #if defined(CONFIG_ARCH_OMAP4)
to use this*/ /* OMAP4 */
static struct omap_mbox2_priv omap2_mbox_1_priv = { static struct omap_mbox2_priv omap2_mbox_1_priv = {
.tx_fifo = { .tx_fifo = {
.msg = MAILBOX_MESSAGE(0), .msg = MAILBOX_MESSAGE(0),
...@@ -325,14 +360,6 @@ struct omap_mbox mbox_1_info = { ...@@ -325,14 +360,6 @@ struct omap_mbox mbox_1_info = {
.ops = &omap2_mbox_ops, .ops = &omap2_mbox_ops,
.priv = &omap2_mbox_1_priv, .priv = &omap2_mbox_1_priv,
}; };
EXPORT_SYMBOL(mbox_1_info);
struct omap_mbox mbox_dsp_info = {
.name = "dsp",
.ops = &omap2_mbox_ops,
.priv = &omap2_mbox_dsp_priv,
};
EXPORT_SYMBOL(mbox_dsp_info);
static struct omap_mbox2_priv omap2_mbox_2_priv = { static struct omap_mbox2_priv omap2_mbox_2_priv = {
.tx_fifo = { .tx_fifo = {
...@@ -355,110 +382,64 @@ struct omap_mbox mbox_2_info = { ...@@ -355,110 +382,64 @@ struct omap_mbox mbox_2_info = {
.ops = &omap2_mbox_ops, .ops = &omap2_mbox_ops,
.priv = &omap2_mbox_2_priv, .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 = {
.msg = MAILBOX_MESSAGE(2),
.fifo_stat = MAILBOX_FIFOSTATUS(2),
},
.rx_fifo = {
.msg = MAILBOX_MESSAGE(3),
.msg_stat = MAILBOX_MSGSTATUS(3),
},
.irqenable = MAILBOX_IRQENABLE(3),
.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 = { struct omap_mbox *omap4_mboxes[] = { &mbox_1_info, &mbox_2_info, NULL };
.name = "iva",
.ops = &omap2_mbox_ops,
.priv = &omap2_mbox_iva_priv,
};
#endif #endif
static int __devinit omap2_mbox_probe(struct platform_device *pdev) static int __devinit omap2_mbox_probe(struct platform_device *pdev)
{ {
struct resource *res; struct resource *mem;
int ret; int ret;
struct omap_mbox **list;
/* MBOX base */ if (false)
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); ;
if (unlikely(!res)) { #if defined(CONFIG_ARCH_OMAP3430)
dev_err(&pdev->dev, "invalid mem resource\n"); else if (cpu_is_omap3430()) {
return -ENODEV; list = omap3_mboxes;
list[0]->irq = platform_get_irq_byname(pdev, "dsp");
} }
mbox_base = ioremap(res->start, resource_size(res)); #endif
if (!mbox_base) #if defined(CONFIG_ARCH_OMAP2420)
return -ENOMEM; else if (cpu_is_omap2420()) {
list = omap2_mboxes;
/* DSP or IVA2 IRQ */ list[0]->irq = platform_get_irq_byname(pdev, "dsp");
res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); list[1]->irq = platform_get_irq_byname(pdev, "iva");
}
#endif
#if defined(CONFIG_ARCH_OMAP4)
else if (cpu_is_omap44xx()) {
list = omap4_mboxes;
if (unlikely(!res)) { list[0]->irq = list[1]->irq =
dev_err(&pdev->dev, "invalid irq resource\n"); platform_get_irq_byname(pdev, "mbox");
ret = -ENODEV;
goto err_dsp;
} }
if (cpu_is_omap44xx()) { #endif
mbox_1_info.irq = res->start; else {
ret = omap_mbox_register(&pdev->dev, &mbox_1_info); pr_err("%s: platform not supported\n", __func__);
} else { return -ENODEV;
mbox_dsp_info.irq = res->start;
ret = omap_mbox_register(&pdev->dev, &mbox_dsp_info);
} }
if (ret)
goto err_dsp;
if (cpu_is_omap44xx()) { mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
mbox_2_info.irq = res->start; mbox_base = ioremap(mem->start, resource_size(mem));
ret = omap_mbox_register(&pdev->dev, &mbox_2_info); if (!mbox_base)
if (ret) { return -ENOMEM;
omap_mbox_unregister(&mbox_1_info);
goto err_dsp; ret = omap_mbox_register(&pdev->dev, list);
} if (ret) {
} iounmap(mbox_base);
#if defined(CONFIG_ARCH_OMAP2420) /* IVA */ return ret;
if (cpu_is_omap2420()) {
/* IVA IRQ */
res = platform_get_resource(pdev, IORESOURCE_IRQ, 1);
if (unlikely(!res)) {
dev_err(&pdev->dev, "invalid irq resource\n");
ret = -ENODEV;
omap_mbox_unregister(&mbox_dsp_info);
goto err_dsp;
}
mbox_iva_info.irq = res->start;
ret = omap_mbox_register(&pdev->dev, &mbox_iva_info);
if (ret) {
omap_mbox_unregister(&mbox_dsp_info);
goto err_dsp;
}
} }
#endif
return 0; return 0;
err_dsp:
iounmap(mbox_base);
return ret; return ret;
} }
static int __devexit omap2_mbox_remove(struct platform_device *pdev) static int __devexit omap2_mbox_remove(struct platform_device *pdev)
{ {
#if defined(CONFIG_ARCH_OMAP2420) omap_mbox_unregister();
omap_mbox_unregister(&mbox_iva_info);
#endif
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); iounmap(mbox_base);
return 0; return 0;
} }
...@@ -467,7 +448,7 @@ static struct platform_driver omap2_mbox_driver = { ...@@ -467,7 +448,7 @@ static struct platform_driver omap2_mbox_driver = {
.probe = omap2_mbox_probe, .probe = omap2_mbox_probe,
.remove = __devexit_p(omap2_mbox_remove), .remove = __devexit_p(omap2_mbox_remove),
.driver = { .driver = {
.name = DRV_NAME, .name = "omap-mailbox",
}, },
}; };
...@@ -486,5 +467,6 @@ module_exit(omap2_mbox_exit); ...@@ -486,5 +467,6 @@ module_exit(omap2_mbox_exit);
MODULE_LICENSE("GPL v2"); MODULE_LICENSE("GPL v2");
MODULE_DESCRIPTION("omap mailbox: omap2/3/4 architecture specific functions"); MODULE_DESCRIPTION("omap mailbox: omap2/3/4 architecture specific functions");
MODULE_AUTHOR("Hiroshi DOYU <Hiroshi.DOYU@nokia.com>, Paul Mundt"); MODULE_AUTHOR("Hiroshi DOYU <Hiroshi.DOYU@nokia.com>");
MODULE_ALIAS("platform:"DRV_NAME); MODULE_AUTHOR("Paul Mundt");
MODULE_ALIAS("platform:omap2-mailbox");
...@@ -88,6 +88,15 @@ config OMAP_MBOX_FWK ...@@ -88,6 +88,15 @@ config OMAP_MBOX_FWK
Say Y here if you want to use OMAP Mailbox framework support for Say Y here if you want to use OMAP Mailbox framework support for
DSP, IVA1.0 and IVA2 in OMAP1/2/3. DSP, IVA1.0 and IVA2 in OMAP1/2/3.
config OMAP_MBOX_KFIFO_SIZE
int "Mailbox kfifo default buffer size (bytes)"
depends on OMAP_MBOX_FWK
default 256
help
Specify the default size of mailbox's kfifo buffers (bytes).
This can also be changed at runtime (via the mbox_kfifo_size
module parameter).
config OMAP_IOMMU config OMAP_IOMMU
tristate tristate
......
...@@ -3,10 +3,11 @@ ...@@ -3,10 +3,11 @@
#ifndef MAILBOX_H #ifndef MAILBOX_H
#define MAILBOX_H #define MAILBOX_H
#include <linux/wait.h> #include <linux/spinlock.h>
#include <linux/workqueue.h> #include <linux/workqueue.h>
#include <linux/blkdev.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/device.h>
#include <linux/kfifo.h>
typedef u32 mbox_msg_t; typedef u32 mbox_msg_t;
struct omap_mbox; struct omap_mbox;
...@@ -42,7 +43,7 @@ struct omap_mbox_ops { ...@@ -42,7 +43,7 @@ struct omap_mbox_ops {
struct omap_mbox_queue { struct omap_mbox_queue {
spinlock_t lock; spinlock_t lock;
struct request_queue *queue; struct kfifo fifo;
struct work_struct work; struct work_struct work;
struct tasklet_struct tasklet; struct tasklet_struct tasklet;
int (*callback)(void *); int (*callback)(void *);
...@@ -52,19 +53,10 @@ struct omap_mbox_queue { ...@@ -52,19 +53,10 @@ struct omap_mbox_queue {
struct omap_mbox { struct omap_mbox {
char *name; char *name;
unsigned int irq; unsigned int irq;
struct omap_mbox_queue *txq, *rxq; struct omap_mbox_queue *txq, *rxq;
struct omap_mbox_ops *ops; struct omap_mbox_ops *ops;
mbox_msg_t seq_snd, seq_rcv;
struct device *dev; struct device *dev;
struct omap_mbox *next;
void *priv; void *priv;
void (*err_notify)(void);
}; };
int omap_mbox_msg_send(struct omap_mbox *, mbox_msg_t msg); int omap_mbox_msg_send(struct omap_mbox *, mbox_msg_t msg);
...@@ -73,8 +65,8 @@ void omap_mbox_init_seq(struct omap_mbox *); ...@@ -73,8 +65,8 @@ void omap_mbox_init_seq(struct omap_mbox *);
struct omap_mbox *omap_mbox_get(const char *); struct omap_mbox *omap_mbox_get(const char *);
void omap_mbox_put(struct omap_mbox *); void omap_mbox_put(struct omap_mbox *);
int omap_mbox_register(struct device *parent, struct omap_mbox *); int omap_mbox_register(struct device *parent, struct omap_mbox **);
int omap_mbox_unregister(struct omap_mbox *); int omap_mbox_unregister(void);
static inline void omap_mbox_save_ctx(struct omap_mbox *mbox) static inline void omap_mbox_save_ctx(struct omap_mbox *mbox)
{ {
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment