2009-01-16 08:27:58

by Hiroshi DOYU

[permalink] [raw]
Subject: [PATCH 00/10] arm: omap mailbox: add omap3 support with some fixes

The following patches add omap3 support and some cleanups.

This "omap mailbox" device driver has been used for the interprocessor
communication between ARM and some co-processors(DSP) inside of omap
SoC, which is a kind of interrupt driven FIFO.

---

Hiroshi DOYU (10):
omap mailbox: remove unnecessary header file inclusion
omap mailbox: convert sequence bit checking to module paramter
omap mailbox: move mailbox.h into mailbox.c
omap mailbox: add save_/restore_ctx() for PM
omap mailbox: fix empty struct device for omap2
omap mailbox: fix empty struct device for omap1
omap mailbox: fix empty struct device for omap_mbox
omap mailbox: print hardware revision at startup
omap mailbox: add initial omap3 support
omap mailbox: cleanup omap2 register definition with macro


arch/arm/mach-omap1/devices.c | 2
arch/arm/mach-omap1/mailbox.c | 31 ++--
arch/arm/mach-omap2/devices.c | 38 ++++-
arch/arm/mach-omap2/mailbox.c | 195 +++++++++++++++++-----------
arch/arm/plat-omap/Kconfig | 8 +
arch/arm/plat-omap/include/mach/mailbox.h | 27 ++++
arch/arm/plat-omap/include/mach/omap34xx.h | 1
arch/arm/plat-omap/mailbox.c | 152 ++++++++++++++++------
arch/arm/plat-omap/mailbox.h | 100 --------------
9 files changed, 311 insertions(+), 243 deletions(-)
delete mode 100644 arch/arm/plat-omap/mailbox.h

--
Hiroshi DOYU


2009-01-16 08:28:30

by Hiroshi DOYU

[permalink] [raw]
Subject: [PATCH 01/10] omap mailbox: cleanup omap2 register definition with macro

Signed-off-by: Hiroshi DOYU <[email protected]>
---

arch/arm/mach-omap2/mailbox.c | 77 +++++++++++++++--------------------------
1 files changed, 29 insertions(+), 48 deletions(-)

diff --git a/arch/arm/mach-omap2/mailbox.c b/arch/arm/mach-omap2/mailbox.c
index 32b7af3..0609e2d 100644
--- a/arch/arm/mach-omap2/mailbox.c
+++ b/arch/arm/mach-omap2/mailbox.c
@@ -1,9 +1,9 @@
/*
- * Mailbox reservation modules for OMAP2
+ * Mailbox reservation modules for OMAP2/3
*
- * Copyright (C) 2006 Nokia Corporation
+ * Copyright (C) 2006-2008 Nokia Corporation
* Written by: Hiroshi DOYU <[email protected]>
- * and Paul Mundt <[email protected]>
+ * and Paul Mundt
*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file "COPYING" in the main directory of this archive
@@ -18,40 +18,19 @@
#include <mach/mailbox.h>
#include <mach/irqs.h>

-#define MAILBOX_REVISION 0x00
-#define MAILBOX_SYSCONFIG 0x10
-#define MAILBOX_SYSSTATUS 0x14
-#define MAILBOX_MESSAGE_0 0x40
-#define MAILBOX_MESSAGE_1 0x44
-#define MAILBOX_MESSAGE_2 0x48
-#define MAILBOX_MESSAGE_3 0x4c
-#define MAILBOX_MESSAGE_4 0x50
-#define MAILBOX_MESSAGE_5 0x54
-#define MAILBOX_FIFOSTATUS_0 0x80
-#define MAILBOX_FIFOSTATUS_1 0x84
-#define MAILBOX_FIFOSTATUS_2 0x88
-#define MAILBOX_FIFOSTATUS_3 0x8c
-#define MAILBOX_FIFOSTATUS_4 0x90
-#define MAILBOX_FIFOSTATUS_5 0x94
-#define MAILBOX_MSGSTATUS_0 0xc0
-#define MAILBOX_MSGSTATUS_1 0xc4
-#define MAILBOX_MSGSTATUS_2 0xc8
-#define MAILBOX_MSGSTATUS_3 0xcc
-#define MAILBOX_MSGSTATUS_4 0xd0
-#define MAILBOX_MSGSTATUS_5 0xd4
-#define MAILBOX_IRQSTATUS_0 0x100
-#define MAILBOX_IRQENABLE_0 0x104
-#define MAILBOX_IRQSTATUS_1 0x108
-#define MAILBOX_IRQENABLE_1 0x10c
-#define MAILBOX_IRQSTATUS_2 0x110
-#define MAILBOX_IRQENABLE_2 0x114
-#define MAILBOX_IRQSTATUS_3 0x118
-#define MAILBOX_IRQENABLE_3 0x11c
+#define MAILBOX_REVISION 0x000
+#define MAILBOX_SYSCONFIG 0x010
+#define MAILBOX_SYSSTATUS 0x014
+#define MAILBOX_MESSAGE(m) (0x040 + 4 * (m))
+#define MAILBOX_FIFOSTATUS(m) (0x080 + 4 * (m))
+#define MAILBOX_MSGSTATUS(m) (0x0c0 + 4 * (m))
+#define MAILBOX_IRQSTATUS(u) (0x100 + 8 * (u))
+#define MAILBOX_IRQENABLE(u) (0x108 + 8 * (u))

-static unsigned long mbox_base;
+#define MAILBOX_IRQ_NEWMSG(u) (1 << (2 * (u)))
+#define MAILBOX_IRQ_NOTFULL(u) (1 << (2 * (u) + 1))

-#define MAILBOX_IRQ_NOTFULL(n) (1 << (2 * (n) + 1))
-#define MAILBOX_IRQ_NEWMSG(n) (1 << (2 * (n)))
+static unsigned long mbox_base;

struct omap_mbox2_fifo {
unsigned long msg;
@@ -209,15 +188,15 @@ static struct omap_mbox_ops omap2_mbox_ops = {
/* DSP */
static struct omap_mbox2_priv omap2_mbox_dsp_priv = {
.tx_fifo = {
- .msg = MAILBOX_MESSAGE_0,
- .fifo_stat = MAILBOX_FIFOSTATUS_0,
+ .msg = MAILBOX_MESSAGE(0),
+ .fifo_stat = MAILBOX_FIFOSTATUS(0),
},
.rx_fifo = {
- .msg = MAILBOX_MESSAGE_1,
- .msg_stat = MAILBOX_MSGSTATUS_1,
+ .msg = MAILBOX_MESSAGE(1),
+ .msg_stat = MAILBOX_MSGSTATUS(1),
},
- .irqenable = MAILBOX_IRQENABLE_0,
- .irqstatus = MAILBOX_IRQSTATUS_0,
+ .irqenable = MAILBOX_IRQENABLE(0),
+ .irqstatus = MAILBOX_IRQSTATUS(0),
.notfull_bit = MAILBOX_IRQ_NOTFULL(0),
.newmsg_bit = MAILBOX_IRQ_NEWMSG(1),
};
@@ -232,15 +211,15 @@ EXPORT_SYMBOL(mbox_dsp_info);
/* IVA */
static struct omap_mbox2_priv omap2_mbox_iva_priv = {
.tx_fifo = {
- .msg = MAILBOX_MESSAGE_2,
- .fifo_stat = MAILBOX_FIFOSTATUS_2,
+ .msg = MAILBOX_MESSAGE(2),
+ .fifo_stat = MAILBOX_FIFOSTATUS(2),
},
.rx_fifo = {
- .msg = MAILBOX_MESSAGE_3,
- .msg_stat = MAILBOX_MSGSTATUS_3,
+ .msg = MAILBOX_MESSAGE(3),
+ .msg_stat = MAILBOX_MSGSTATUS(3),
},
- .irqenable = MAILBOX_IRQENABLE_3,
- .irqstatus = MAILBOX_IRQSTATUS_3,
+ .irqenable = MAILBOX_IRQENABLE(3),
+ .irqstatus = MAILBOX_IRQSTATUS(3),
.notfull_bit = MAILBOX_IRQ_NOTFULL(2),
.newmsg_bit = MAILBOX_IRQ_NEWMSG(3),
};
@@ -320,4 +299,6 @@ static void __exit omap2_mbox_exit(void)
module_init(omap2_mbox_init);
module_exit(omap2_mbox_exit);

-MODULE_LICENSE("GPL");
+MODULE_LICENSE("GPL v2");
+MODULE_DESCRIPTION("omap mailbox: omap2/3 architecture specific functions");
+MODULE_AUTHOR("Hiroshi DOYU <[email protected]>, Paul Mundt");

2009-01-16 08:28:47

by Hiroshi DOYU

[permalink] [raw]
Subject: [PATCH 03/10] omap mailbox: print hardware revision at startup

Signed-off-by: Hiroshi DOYU <[email protected]>
---

arch/arm/mach-omap2/mailbox.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/mailbox.c b/arch/arm/mach-omap2/mailbox.c
index 3176bb7..c73fa89 100644
--- a/arch/arm/mach-omap2/mailbox.c
+++ b/arch/arm/mach-omap2/mailbox.c
@@ -74,6 +74,9 @@ static int omap2_mbox_startup(struct omap_mbox *mbox)
}
clk_enable(mbox_ick_handle);

+ l = mbox_read_reg(MAILBOX_REVISION);
+ pr_info("omap mailbox rev %d.%d\n", (l & 0xf0) >> 4, (l & 0x0f));
+
/* set smart-idle & autoidle */
l = mbox_read_reg(MAILBOX_SYSCONFIG);
l |= 0x00000011;

2009-01-16 08:29:18

by Hiroshi DOYU

[permalink] [raw]
Subject: [PATCH 04/10] omap mailbox: fix empty struct device for omap_mbox

Since "mbox->dev" doesn't exist and isn't created either at
registration, this patch will create "struct device", which belongs to
"omap-mailbox" class and set this pointer for the member of
"struct omap_mbox".

Signed-off-by: Hiroshi DOYU <[email protected]>
---

arch/arm/plat-omap/include/mach/mailbox.h | 4 +-
arch/arm/plat-omap/mailbox.c | 63 ++++++++++++++---------------
2 files changed, 33 insertions(+), 34 deletions(-)

diff --git a/arch/arm/plat-omap/include/mach/mailbox.h b/arch/arm/plat-omap/include/mach/mailbox.h
index 7cbed93..577db68 100644
--- a/arch/arm/plat-omap/include/mach/mailbox.h
+++ b/arch/arm/plat-omap/include/mach/mailbox.h
@@ -53,7 +53,7 @@ struct omap_mbox {

mbox_msg_t seq_snd, seq_rcv;

- struct device dev;
+ struct device *dev;

struct omap_mbox *next;
void *priv;
@@ -67,7 +67,7 @@ void omap_mbox_init_seq(struct omap_mbox *);
struct omap_mbox *omap_mbox_get(const char *);
void omap_mbox_put(struct omap_mbox *);

-int omap_mbox_register(struct omap_mbox *);
+int omap_mbox_register(struct device *parent, struct omap_mbox *);
int omap_mbox_unregister(struct omap_mbox *);

#endif /* MAILBOX_H */
diff --git a/arch/arm/plat-omap/mailbox.c b/arch/arm/plat-omap/mailbox.c
index b52ce05..5e8cd65 100644
--- a/arch/arm/plat-omap/mailbox.c
+++ b/arch/arm/plat-omap/mailbox.c
@@ -1,10 +1,9 @@
/*
* OMAP mailbox driver
*
- * Copyright (C) 2006 Nokia Corporation. All rights reserved.
+ * Copyright (C) 2006-2008 Nokia Corporation. All rights reserved.
*
- * Contact: Toshihiro Kobayashi <[email protected]>
- * Restructured by Hiroshi DOYU <[email protected]>
+ * Contact: Hiroshi DOYU <[email protected]>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -136,7 +135,7 @@ static void mbox_rx_work(struct work_struct *work)
unsigned long flags;

if (mbox->rxq->callback == NULL) {
- sysfs_notify(&mbox->dev.kobj, NULL, "mbox");
+ sysfs_notify(&mbox->dev->kobj, NULL, "mbox");
return;
}

@@ -204,7 +203,7 @@ 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:
+nomem:
schedule_work(&mbox->rxq->work);
}

@@ -286,7 +285,7 @@ static ssize_t mbox_show(struct class *class, char *buf)
static CLASS_ATTR(mbox, S_IRUGO, mbox_show, NULL);

static struct class omap_mbox_class = {
- .name = "omap_mbox",
+ .name = "omap-mailbox",
};

static struct omap_mbox_queue *mbox_queue_alloc(struct omap_mbox *mbox,
@@ -333,21 +332,6 @@ static int omap_mbox_init(struct omap_mbox *mbox)
return ret;
}

- mbox->dev.class = &omap_mbox_class;
- dev_set_name(&mbox->dev, "%s", mbox->name);
- dev_set_drvdata(&mbox->dev, mbox);
-
- ret = device_register(&mbox->dev);
- if (unlikely(ret))
- goto fail_device_reg;
-
- ret = device_create_file(&mbox->dev, &dev_attr_mbox);
- if (unlikely(ret)) {
- printk(KERN_ERR
- "device_create_file failed: %d\n", ret);
- goto fail_create_mbox;
- }
-
ret = request_irq(mbox->irq, mbox_interrupt, IRQF_DISABLED,
mbox->name, mbox);
if (unlikely(ret)) {
@@ -377,10 +361,6 @@ static int omap_mbox_init(struct omap_mbox *mbox)
fail_alloc_txq:
free_irq(mbox->irq, mbox);
fail_request_irq:
- device_remove_file(&mbox->dev, &dev_attr_mbox);
- fail_create_mbox:
- device_unregister(&mbox->dev);
- fail_device_reg:
if (unlikely(mbox->ops->shutdown))
mbox->ops->shutdown(mbox);

@@ -393,8 +373,6 @@ static void omap_mbox_fini(struct omap_mbox *mbox)
mbox_queue_free(mbox->rxq);

free_irq(mbox->irq, mbox);
- device_remove_file(&mbox->dev, &dev_attr_mbox);
- class_unregister(&omap_mbox_class);

if (unlikely(mbox->ops->shutdown))
mbox->ops->shutdown(mbox);
@@ -440,7 +418,7 @@ void omap_mbox_put(struct omap_mbox *mbox)
}
EXPORT_SYMBOL(omap_mbox_put);

-int omap_mbox_register(struct omap_mbox *mbox)
+int omap_mbox_register(struct device *parent, struct omap_mbox *mbox)
{
int ret = 0;
struct omap_mbox **tmp;
@@ -450,14 +428,31 @@ int omap_mbox_register(struct omap_mbox *mbox)
if (mbox->next)
return -EBUSY;

+ mbox->dev = device_create(&omap_mbox_class,
+ parent, 0, mbox, "%s", mbox->name);
+ if (IS_ERR(mbox->dev))
+ return PTR_ERR(mbox->dev);
+
+ ret = device_create_file(mbox->dev, &dev_attr_mbox);
+ if (ret)
+ goto err_sysfs;
+
write_lock(&mboxes_lock);
tmp = find_mboxes(mbox->name);
- if (*tmp)
+ if (*tmp) {
ret = -EBUSY;
- else
- *tmp = mbox;
+ write_unlock(&mboxes_lock);
+ goto err_find;
+ }
+ *tmp = mbox;
write_unlock(&mboxes_lock);

+ return 0;
+
+err_find:
+ device_remove_file(mbox->dev, &dev_attr_mbox);
+err_sysfs:
+ device_unregister(mbox->dev);
return ret;
}
EXPORT_SYMBOL(omap_mbox_register);
@@ -473,6 +468,8 @@ int omap_mbox_unregister(struct omap_mbox *mbox)
*tmp = mbox->next;
mbox->next = NULL;
write_unlock(&mboxes_lock);
+ device_remove_file(mbox->dev, &dev_attr_mbox);
+ device_unregister(mbox->dev);
return 0;
}
tmp = &(*tmp)->next;
@@ -501,4 +498,6 @@ static void __exit omap_mbox_class_exit(void)
subsys_initcall(omap_mbox_class_init);
module_exit(omap_mbox_class_exit);

-MODULE_LICENSE("GPL");
+MODULE_LICENSE("GPL v2");
+MODULE_DESCRIPTION("omap mailbox: interrupt driven messaging");
+MODULE_AUTHOR("Toshihiro Kobayashi and Hiroshi DOYU");

2009-01-16 08:29:41

by Hiroshi DOYU

[permalink] [raw]
Subject: [PATCH 05/10] omap mailbox: fix empty struct device for omap1

Signed-off-by: Hiroshi DOYU <[email protected]>
---

arch/arm/mach-omap1/devices.c | 2 +-
arch/arm/mach-omap1/mailbox.c | 31 +++++++++++++++++--------------
2 files changed, 18 insertions(+), 15 deletions(-)

diff --git a/arch/arm/mach-omap1/devices.c b/arch/arm/mach-omap1/devices.c
index 77382d8..b4b6106 100644
--- a/arch/arm/mach-omap1/devices.c
+++ b/arch/arm/mach-omap1/devices.c
@@ -86,7 +86,7 @@ static struct resource mbox_resources[] = {
};

static struct platform_device mbox_device = {
- .name = "mailbox",
+ .name = "omap1-mailbox",
.id = -1,
.num_resources = ARRAY_SIZE(mbox_resources),
.resource = mbox_resources,
diff --git a/arch/arm/mach-omap1/mailbox.c b/arch/arm/mach-omap1/mailbox.c
index 59abbf3..87539db 100644
--- a/arch/arm/mach-omap1/mailbox.c
+++ b/arch/arm/mach-omap1/mailbox.c
@@ -1,7 +1,7 @@
/*
* Mailbox reservation modules for DSP
*
- * Copyright (C) 2006 Nokia Corporation
+ * Copyright (C) 2006-2008 Nokia Corporation
* Written by: Hiroshi DOYU <[email protected]>
*
* This file is subject to the terms and conditions of the GNU General Public
@@ -17,6 +17,8 @@
#include <mach/mailbox.h>
#include <mach/irqs.h>

+#define DRV_NAME "omap1-mailbox"
+
#define MAILBOX_ARM2DSP1 0x00
#define MAILBOX_ARM2DSP1b 0x04
#define MAILBOX_DSP2ARM1 0x08
@@ -27,7 +29,7 @@
#define MAILBOX_DSP2ARM1_Flag 0x1c
#define MAILBOX_DSP2ARM2_Flag 0x20

-unsigned long mbox_base;
+static void __iomem *mbox_base;

struct omap_mbox1_fifo {
unsigned long cmd;
@@ -40,14 +42,14 @@ struct omap_mbox1_priv {
struct omap_mbox1_fifo rx_fifo;
};

-static inline int mbox_read_reg(unsigned int reg)
+static inline int mbox_read_reg(size_t ofs)
{
- return __raw_readw(mbox_base + reg);
+ return __raw_readw(mbox_base + ofs);
}

-static inline void mbox_write_reg(unsigned int val, unsigned int reg)
+static inline void mbox_write_reg(u32 val, size_t ofs)
{
- __raw_writew(val, mbox_base + reg);
+ __raw_writew(val, mbox_base + ofs);
}

/* msg */
@@ -143,7 +145,7 @@ struct omap_mbox mbox_dsp_info = {
};
EXPORT_SYMBOL(mbox_dsp_info);

-static int __init omap1_mbox_probe(struct platform_device *pdev)
+static int __devinit omap1_mbox_probe(struct platform_device *pdev)
{
struct resource *res;
int ret = 0;
@@ -170,12 +172,10 @@ static int __init omap1_mbox_probe(struct platform_device *pdev)
}
mbox_dsp_info.irq = res->start;

- ret = omap_mbox_register(&mbox_dsp_info);
-
- return ret;
+ return omap_mbox_register(&pdev->dev, &mbox_dsp_info);
}

-static int omap1_mbox_remove(struct platform_device *pdev)
+static int __devexit omap1_mbox_remove(struct platform_device *pdev)
{
omap_mbox_unregister(&mbox_dsp_info);

@@ -184,9 +184,9 @@ static int omap1_mbox_remove(struct platform_device *pdev)

static struct platform_driver omap1_mbox_driver = {
.probe = omap1_mbox_probe,
- .remove = omap1_mbox_remove,
+ .remove = __devexit_p(omap1_mbox_remove),
.driver = {
- .name = "mailbox",
+ .name = DRV_NAME,
},
};

@@ -203,4 +203,7 @@ static void __exit omap1_mbox_exit(void)
module_init(omap1_mbox_init);
module_exit(omap1_mbox_exit);

-MODULE_LICENSE("GPL");
+MODULE_LICENSE("GPL v2");
+MODULE_DESCRIPTION("omap mailbox: omap1 architecture specific functions");
+MODULE_AUTHOR("Hiroshi DOYU" <[email protected]>);
+MODULE_ALIAS("platform:"DRV_NAME);

2009-01-16 08:30:29

by Hiroshi DOYU

[permalink] [raw]
Subject: [PATCH 06/10] omap mailbox: fix empty struct device for omap2

Signed-off-by: Hiroshi DOYU <[email protected]>
---

arch/arm/mach-omap2/devices.c | 2 +-
arch/arm/mach-omap2/mailbox.c | 15 +++++++++------
2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
index 05baccd..698dd13 100644
--- a/arch/arm/mach-omap2/devices.c
+++ b/arch/arm/mach-omap2/devices.c
@@ -61,7 +61,7 @@ static struct resource omap3_mbox_resources[] = {
};

static struct platform_device mbox_device = {
- .name = "mailbox",
+ .name = "omap2-mailbox",
.id = -1,
};

diff --git a/arch/arm/mach-omap2/mailbox.c b/arch/arm/mach-omap2/mailbox.c
index c73fa89..a877305 100644
--- a/arch/arm/mach-omap2/mailbox.c
+++ b/arch/arm/mach-omap2/mailbox.c
@@ -18,6 +18,8 @@
#include <mach/mailbox.h>
#include <mach/irqs.h>

+#define DRV_NAME "omap2-mailbox"
+
#define MAILBOX_REVISION 0x000
#define MAILBOX_SYSCONFIG 0x010
#define MAILBOX_SYSSTATUS 0x014
@@ -234,7 +236,7 @@ static struct omap_mbox mbox_iva_info = {
};
#endif

-static int __init omap2_mbox_probe(struct platform_device *pdev)
+static int __devinit omap2_mbox_probe(struct platform_device *pdev)
{
struct resource *res;
int ret;
@@ -258,7 +260,7 @@ static int __init omap2_mbox_probe(struct platform_device *pdev)
}
mbox_dsp_info.irq = res->start;

- ret = omap_mbox_register(&mbox_dsp_info);
+ ret = omap_mbox_register(&pdev->dev, &mbox_dsp_info);
if (ret)
goto err_dsp;

@@ -272,7 +274,7 @@ static int __init omap2_mbox_probe(struct platform_device *pdev)
goto err_iva1;
}
mbox_iva_info.irq = res->start;
- ret = omap_mbox_register(&mbox_iva_info);
+ ret = omap_mbox_register(&pdev->dev, &mbox_iva_info);
if (ret)
goto err_iva1;
}
@@ -286,7 +288,7 @@ err_dsp:
return ret;
}

-static int 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(&mbox_iva_info);
@@ -298,9 +300,9 @@ static int omap2_mbox_remove(struct platform_device *pdev)

static struct platform_driver omap2_mbox_driver = {
.probe = omap2_mbox_probe,
- .remove = omap2_mbox_remove,
+ .remove = __devexit_p(omap2_mbox_remove),
.driver = {
- .name = "mailbox",
+ .name = DRV_NAME,
},
};

@@ -320,3 +322,4 @@ module_exit(omap2_mbox_exit);
MODULE_LICENSE("GPL v2");
MODULE_DESCRIPTION("omap mailbox: omap2/3 architecture specific functions");
MODULE_AUTHOR("Hiroshi DOYU <[email protected]>, Paul Mundt");
+MODULE_ALIAS("platform:"DRV_NAME);

2009-01-16 08:31:01

by Hiroshi DOYU

[permalink] [raw]
Subject: [PATCH 07/10] omap mailbox: add save_/restore_ctx() for PM

To preserve the registers during off-mode

Signed-off-by: Hiroshi DOYU <[email protected]>
---

arch/arm/mach-omap2/mailbox.c | 35 +++++++++++++++++++++++++++++
arch/arm/plat-omap/include/mach/mailbox.h | 23 +++++++++++++++++++
2 files changed, 58 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/mailbox.c b/arch/arm/mach-omap2/mailbox.c
index a877305..544dde9 100644
--- a/arch/arm/mach-omap2/mailbox.c
+++ b/arch/arm/mach-omap2/mailbox.c
@@ -32,6 +32,8 @@
#define MAILBOX_IRQ_NEWMSG(u) (1 << (2 * (u)))
#define MAILBOX_IRQ_NOTFULL(u) (1 << (2 * (u) + 1))

+#define MBOX_REG_SIZE 0x120
+
static void __iomem *mbox_base;

struct omap_mbox2_fifo {
@@ -47,6 +49,7 @@ struct omap_mbox2_priv {
unsigned long irqstatus;
u32 newmsg_bit;
u32 notfull_bit;
+ char ctx[MBOX_REG_SIZE];
};

static struct clk *mbox_ick_handle;
@@ -167,6 +170,36 @@ static int omap2_mbox_is_irq(struct omap_mbox *mbox,
return (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_REG_SIZE; i += sizeof(u32)) {
+ u32 val;
+
+ val = mbox_read_reg(i);
+ *(u32 *)(p->ctx + i) = val;
+
+ dev_dbg(mbox->dev, "%s\t[%02d] %08x\n", __func__, i, val);
+ }
+}
+
+static void omap2_mbox_restore_ctx(struct omap_mbox *mbox)
+{
+ int i;
+ struct omap_mbox2_priv *p = mbox->priv;
+
+ for (i = 0; i < MBOX_REG_SIZE; i += sizeof(u32)) {
+ u32 val;
+
+ val = *(u32 *)(p->ctx + i);
+ mbox_write_reg(val, i);
+
+ dev_dbg(mbox->dev, "%s\t[%02d] %08x\n", __func__, i, val);
+ }
+}
+
static struct omap_mbox_ops omap2_mbox_ops = {
.type = OMAP_MBOX_TYPE2,
.startup = omap2_mbox_startup,
@@ -179,6 +212,8 @@ static struct omap_mbox_ops omap2_mbox_ops = {
.disable_irq = omap2_mbox_disable_irq,
.ack_irq = omap2_mbox_ack_irq,
.is_irq = omap2_mbox_is_irq,
+ .save_ctx = omap2_mbox_save_ctx,
+ .restore_ctx = omap2_mbox_restore_ctx,
};

/*
diff --git a/arch/arm/plat-omap/include/mach/mailbox.h b/arch/arm/plat-omap/include/mach/mailbox.h
index 577db68..b7a6991 100644
--- a/arch/arm/plat-omap/include/mach/mailbox.h
+++ b/arch/arm/plat-omap/include/mach/mailbox.h
@@ -33,6 +33,9 @@ struct omap_mbox_ops {
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 */
+ void (*save_ctx)(struct omap_mbox *mbox);
+ void (*restore_ctx)(struct omap_mbox *mbox);
};

struct omap_mbox_queue {
@@ -70,4 +73,24 @@ void omap_mbox_put(struct omap_mbox *);
int omap_mbox_register(struct device *parent, struct omap_mbox *);
int omap_mbox_unregister(struct omap_mbox *);

+static inline void omap_mbox_save_ctx(struct omap_mbox *mbox)
+{
+ if (!mbox->ops->save_ctx) {
+ dev_err(mbox->dev, "%s:\tno save\n", __func__);
+ return;
+ }
+
+ mbox->ops->save_ctx(mbox);
+}
+
+static inline void omap_mbox_restore_ctx(struct omap_mbox *mbox)
+{
+ if (!mbox->ops->restore_ctx) {
+ dev_err(mbox->dev, "%s:\tno restore\n", __func__);
+ return;
+ }
+
+ mbox->ops->restore_ctx(mbox);
+}
+
#endif /* MAILBOX_H */

2009-01-16 08:31:42

by Hiroshi DOYU

[permalink] [raw]
Subject: [PATCH 02/10] omap mailbox: add initial omap3 support

Signed-off-by: Hiroshi DOYU <[email protected]>
---

arch/arm/mach-omap2/devices.c | 36 ++++++++++++----
arch/arm/mach-omap2/mailbox.c | 65 +++++++++++++++++-----------
arch/arm/plat-omap/Kconfig | 8 +++
arch/arm/plat-omap/include/mach/omap34xx.h | 1
4 files changed, 77 insertions(+), 33 deletions(-)

diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
index 9d7216f..05baccd 100644
--- a/arch/arm/mach-omap2/devices.c
+++ b/arch/arm/mach-omap2/devices.c
@@ -28,13 +28,14 @@
#include <mach/eac.h>
#include <mach/mmc.h>

-#if defined(CONFIG_OMAP_DSP) || defined(CONFIG_OMAP_DSP_MODULE)
-#define OMAP2_MBOX_BASE IO_ADDRESS(OMAP24XX_MAILBOX_BASE)
+#if defined(CONFIG_OMAP_MBOX_FWK) || defined(CONFIG_OMAP_MBOX_FWK_MODULE)

-static struct resource mbox_resources[] = {
+#define MBOX_REG_SIZE 0x120
+
+static struct resource omap2_mbox_resources[] = {
{
- .start = OMAP2_MBOX_BASE,
- .end = OMAP2_MBOX_BASE + 0x11f,
+ .start = OMAP24XX_MAILBOX_BASE,
+ .end = OMAP24XX_MAILBOX_BASE + MBOX_REG_SIZE - 1,
.flags = IORESOURCE_MEM,
},
{
@@ -47,20 +48,39 @@ static struct resource mbox_resources[] = {
},
};

+static struct resource omap3_mbox_resources[] = {
+ {
+ .start = OMAP34XX_MAILBOX_BASE,
+ .end = OMAP34XX_MAILBOX_BASE + MBOX_REG_SIZE - 1,
+ .flags = IORESOURCE_MEM,
+ },
+ {
+ .start = INT_24XX_MAIL_U0_MPU,
+ .flags = IORESOURCE_IRQ,
+ },
+};
+
static struct platform_device mbox_device = {
.name = "mailbox",
.id = -1,
- .num_resources = ARRAY_SIZE(mbox_resources),
- .resource = mbox_resources,
};

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;
+ } else {
+ return;
+ }
platform_device_register(&mbox_device);
}
#else
static inline void omap_init_mbox(void) { }
-#endif
+#endif /* CONFIG_OMAP_MBOX_FWK */

#if defined(CONFIG_OMAP_STI)

diff --git a/arch/arm/mach-omap2/mailbox.c b/arch/arm/mach-omap2/mailbox.c
index 0609e2d..3176bb7 100644
--- a/arch/arm/mach-omap2/mailbox.c
+++ b/arch/arm/mach-omap2/mailbox.c
@@ -30,7 +30,7 @@
#define MAILBOX_IRQ_NEWMSG(u) (1 << (2 * (u)))
#define MAILBOX_IRQ_NOTFULL(u) (1 << (2 * (u) + 1))

-static unsigned long mbox_base;
+static void __iomem *mbox_base;

struct omap_mbox2_fifo {
unsigned long msg;
@@ -52,14 +52,14 @@ static struct clk *mbox_ick_handle;
static void omap2_mbox_enable_irq(struct omap_mbox *mbox,
omap_mbox_type_t irq);

-static inline unsigned int mbox_read_reg(unsigned int reg)
+static inline unsigned int mbox_read_reg(size_t ofs)
{
- return __raw_readl(mbox_base + reg);
+ return __raw_readl(mbox_base + ofs);
}

-static inline void mbox_write_reg(unsigned int val, unsigned int reg)
+static inline void mbox_write_reg(u32 val, size_t ofs)
{
- __raw_writel(val, mbox_base + reg);
+ __raw_writel(val, mbox_base + ofs);
}

/* Mailbox H/W preparations */
@@ -208,7 +208,7 @@ struct omap_mbox mbox_dsp_info = {
};
EXPORT_SYMBOL(mbox_dsp_info);

-/* IVA */
+#if defined(CONFIG_ARCH_OMAP2420) /* IVA */
static struct omap_mbox2_priv omap2_mbox_iva_priv = {
.tx_fifo = {
.msg = MAILBOX_MESSAGE(2),
@@ -229,17 +229,12 @@ static struct omap_mbox mbox_iva_info = {
.ops = &omap2_mbox_ops,
.priv = &omap2_mbox_iva_priv,
};
+#endif

static int __init omap2_mbox_probe(struct platform_device *pdev)
{
struct resource *res;
- int ret = 0;
-
- if (pdev->num_resources != 3) {
- dev_err(&pdev->dev, "invalid number of resources: %d\n",
- pdev->num_resources);
- return -ENODEV;
- }
+ int ret;

/* MBOX base */
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -247,34 +242,54 @@ static int __init omap2_mbox_probe(struct platform_device *pdev)
dev_err(&pdev->dev, "invalid mem resource\n");
return -ENODEV;
}
- mbox_base = res->start;
+ mbox_base = ioremap(res->start, res->end - res->start);
+ if (!mbox_base)
+ return -ENOMEM;

- /* DSP IRQ */
+ /* DSP or IVA2 IRQ */
res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
if (unlikely(!res)) {
dev_err(&pdev->dev, "invalid irq resource\n");
- return -ENODEV;
+ ret = -ENODEV;
+ goto err_dsp;
}
mbox_dsp_info.irq = res->start;

ret = omap_mbox_register(&mbox_dsp_info);
-
- /* IVA IRQ */
- res = platform_get_resource(pdev, IORESOURCE_IRQ, 1);
- if (unlikely(!res)) {
- dev_err(&pdev->dev, "invalid irq resource\n");
- return -ENODEV;
+ if (ret)
+ goto err_dsp;
+
+#if defined(CONFIG_ARCH_OMAP2420) /* IVA */
+ 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;
+ goto err_iva1;
+ }
+ mbox_iva_info.irq = res->start;
+ ret = omap_mbox_register(&mbox_iva_info);
+ if (ret)
+ goto err_iva1;
}
- mbox_iva_info.irq = res->start;
-
- ret = omap_mbox_register(&mbox_iva_info);
+#endif
+ return 0;

+err_iva1:
+ omap_mbox_unregister(&mbox_dsp_info);
+err_dsp:
+ iounmap(mbox_base);
return ret;
}

static int 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);
+ iounmap(mbox_base);
return 0;
}

diff --git a/arch/arm/plat-omap/Kconfig b/arch/arm/plat-omap/Kconfig
index 46d3b0b..6b1d506 100644
--- a/arch/arm/plat-omap/Kconfig
+++ b/arch/arm/plat-omap/Kconfig
@@ -104,6 +104,14 @@ config OMAP_MCBSP
Say Y here if you want support for the OMAP Multichannel
Buffered Serial Port.

+config OMAP_MBOX_FWK
+ tristate "Mailbox framework support"
+ depends on ARCH_OMAP
+ default n
+ help
+ Say Y here if you want to use OMAP Mailbox framework support for
+ DSP, IVA1.0 and IVA2 in OMAP1/2/3.
+
choice
prompt "System timer"
default OMAP_MPU_TIMER
diff --git a/arch/arm/plat-omap/include/mach/omap34xx.h b/arch/arm/plat-omap/include/mach/omap34xx.h
index 8e0479f..89173f1 100644
--- a/arch/arm/plat-omap/include/mach/omap34xx.h
+++ b/arch/arm/plat-omap/include/mach/omap34xx.h
@@ -61,6 +61,7 @@
#define OMAP2_CM_BASE OMAP3430_CM_BASE
#define OMAP2_PRM_BASE OMAP3430_PRM_BASE
#define OMAP2_VA_IC_BASE IO_ADDRESS(OMAP34XX_IC_BASE)
+#define OMAP34XX_MAILBOX_BASE (L4_34XX_BASE + 0x94000)

#endif

2009-01-16 08:32:10

by Hiroshi DOYU

[permalink] [raw]
Subject: [PATCH 08/10] omap mailbox: move mailbox.h into mailbox.c

no need to keep mailbox.h separately.

Signed-off-by: Hiroshi DOYU <[email protected]>
---

arch/arm/plat-omap/mailbox.c | 86 ++++++++++++++++++++++++++++++++++++
arch/arm/plat-omap/mailbox.h | 100 ------------------------------------------
2 files changed, 85 insertions(+), 101 deletions(-)
delete mode 100644 arch/arm/plat-omap/mailbox.h

diff --git a/arch/arm/plat-omap/mailbox.c b/arch/arm/plat-omap/mailbox.c
index 5e8cd65..db5a0c2 100644
--- a/arch/arm/plat-omap/mailbox.c
+++ b/arch/arm/plat-omap/mailbox.c
@@ -31,11 +31,95 @@
#include <linux/delay.h>
#include <linux/io.h>
#include <mach/mailbox.h>
-#include "mailbox.h"

static struct omap_mbox *mboxes;
static DEFINE_RWLOCK(mboxes_lock);

+/*
+ * Mailbox sequence bit API
+ */
+#if defined(CONFIG_ARCH_OMAP1)
+# define MBOX_USE_SEQ_BIT
+#elif defined(CONFIG_ARCH_OMAP2)
+# define MBOX_USE_SEQ_BIT
+#endif
+
+#ifdef MBOX_USE_SEQ_BIT
+/* 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)
+{
+ /* 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)
+{
+ /* 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 = msg & (1 << 31);
+ if (seq == mbox->seq_rcv)
+ return -1;
+ mbox->seq_rcv = seq;
+ return 0;
+}
+#else
+static inline void mbox_seq_init(struct omap_mbox *mbox)
+{
+}
+static inline void mbox_seq_toggle(struct omap_mbox *mbox, mbox_msg_t * msg)
+{
+}
+static inline int mbox_seq_test(struct omap_mbox *mbox, mbox_msg_t msg)
+{
+ return 0;
+}
+#endif
+
+/* Mailbox FIFO handle functions */
+static inline mbox_msg_t mbox_fifo_read(struct omap_mbox *mbox)
+{
+ return mbox->ops->fifo_read(mbox);
+}
+static inline void mbox_fifo_write(struct omap_mbox *mbox, mbox_msg_t msg)
+{
+ mbox->ops->fifo_write(mbox, msg);
+}
+static inline int mbox_fifo_empty(struct omap_mbox *mbox)
+{
+ return mbox->ops->fifo_empty(mbox);
+}
+static inline int mbox_fifo_full(struct omap_mbox *mbox)
+{
+ return mbox->ops->fifo_full(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)
+ mbox->ops->ack_irq(mbox, irq);
+}
+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)
{
diff --git a/arch/arm/plat-omap/mailbox.h b/arch/arm/plat-omap/mailbox.h
deleted file mode 100644
index 67c6740..0000000
--- a/arch/arm/plat-omap/mailbox.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Mailbox internal functions
- *
- * Copyright (C) 2006 Nokia Corporation
- * Written by: Hiroshi DOYU <[email protected]>
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License. See the file "COPYING" in the main directory of this archive
- * for more details.
- */
-
-#ifndef __ARCH_ARM_PLAT_MAILBOX_H
-#define __ARCH_ARM_PLAT_MAILBOX_H
-
-/*
- * Mailbox sequence bit API
- */
-#if defined(CONFIG_ARCH_OMAP1)
-# define MBOX_USE_SEQ_BIT
-#elif defined(CONFIG_ARCH_OMAP2)
-# define MBOX_USE_SEQ_BIT
-#endif
-
-#ifdef MBOX_USE_SEQ_BIT
-/* 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)
-{
- /* 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)
-{
- /* 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 = msg & (1 << 31);
- if (seq == mbox->seq_rcv)
- return -1;
- mbox->seq_rcv = seq;
- return 0;
-}
-#else
-static inline void mbox_seq_init(struct omap_mbox *mbox)
-{
-}
-static inline void mbox_seq_toggle(struct omap_mbox *mbox, mbox_msg_t * msg)
-{
-}
-static inline int mbox_seq_test(struct omap_mbox *mbox, mbox_msg_t msg)
-{
- return 0;
-}
-#endif
-
-/* Mailbox FIFO handle functions */
-static inline mbox_msg_t mbox_fifo_read(struct omap_mbox *mbox)
-{
- return mbox->ops->fifo_read(mbox);
-}
-static inline void mbox_fifo_write(struct omap_mbox *mbox, mbox_msg_t msg)
-{
- mbox->ops->fifo_write(mbox, msg);
-}
-static inline int mbox_fifo_empty(struct omap_mbox *mbox)
-{
- return mbox->ops->fifo_empty(mbox);
-}
-static inline int mbox_fifo_full(struct omap_mbox *mbox)
-{
- return mbox->ops->fifo_full(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)
- mbox->ops->ack_irq(mbox, irq);
-}
-static inline int is_mbox_irq(struct omap_mbox *mbox, omap_mbox_irq_t irq)
-{
- return mbox->ops->is_irq(mbox, irq);
-}
-
-#endif /* __ARCH_ARM_PLAT_MAILBOX_H */

2009-01-16 08:32:33

by Hiroshi DOYU

[permalink] [raw]
Subject: [PATCH 09/10] omap mailbox: convert sequence bit checking to module paramter

Signed-off-by: Hiroshi DOYU <[email protected]>
---

arch/arm/plat-omap/mailbox.c | 35 ++++++++++++++++-------------------
1 files changed, 16 insertions(+), 19 deletions(-)

diff --git a/arch/arm/plat-omap/mailbox.c b/arch/arm/plat-omap/mailbox.c
index db5a0c2..79f5fb7 100644
--- a/arch/arm/plat-omap/mailbox.c
+++ b/arch/arm/plat-omap/mailbox.c
@@ -32,30 +32,34 @@
#include <linux/io.h>
#include <mach/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
*/
-#if defined(CONFIG_ARCH_OMAP1)
-# define MBOX_USE_SEQ_BIT
-#elif defined(CONFIG_ARCH_OMAP2)
-# define MBOX_USE_SEQ_BIT
-#endif

-#ifdef MBOX_USE_SEQ_BIT
/* 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 */
@@ -64,24 +68,17 @@ static inline void mbox_seq_toggle(struct omap_mbox *mbox, mbox_msg_t * msg)

static inline int mbox_seq_test(struct omap_mbox *mbox, mbox_msg_t msg)
{
- mbox_msg_t seq = msg & (1 << 31);
+ 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;
}
-#else
-static inline void mbox_seq_init(struct omap_mbox *mbox)
-{
-}
-static inline void mbox_seq_toggle(struct omap_mbox *mbox, mbox_msg_t * msg)
-{
-}
-static inline int mbox_seq_test(struct omap_mbox *mbox, mbox_msg_t msg)
-{
- return 0;
-}
-#endif

/* Mailbox FIFO handle functions */
static inline mbox_msg_t mbox_fifo_read(struct omap_mbox *mbox)

2009-01-16 08:32:57

by Hiroshi DOYU

[permalink] [raw]
Subject: [PATCH 10/10] omap mailbox: remove unnecessary header file inclusion

Signed-off-by: Hiroshi DOYU <[email protected]>
---

arch/arm/plat-omap/mailbox.c | 6 +-----
1 files changed, 1 insertions(+), 5 deletions(-)

diff --git a/arch/arm/plat-omap/mailbox.c b/arch/arm/plat-omap/mailbox.c
index 79f5fb7..feb286c 100644
--- a/arch/arm/plat-omap/mailbox.c
+++ b/arch/arm/plat-omap/mailbox.c
@@ -21,15 +21,11 @@
*
*/

-#include <linux/init.h>
#include <linux/module.h>
-#include <linux/sched.h>
#include <linux/interrupt.h>
#include <linux/device.h>
-#include <linux/blkdev.h>
-#include <linux/err.h>
#include <linux/delay.h>
-#include <linux/io.h>
+
#include <mach/mailbox.h>

static int enable_seq_bit;

2009-01-16 09:56:34

by Roel Kluin

[permalink] [raw]
Subject: Re: [PATCH 01/10] omap mailbox: cleanup omap2 register definition with macro

2009/1/16 Hiroshi DOYU <[email protected]>:
> Signed-off-by: Hiroshi DOYU <[email protected]>
> ---
>
> arch/arm/mach-omap2/mailbox.c | 77 +++++++++++++++--------------------------
> 1 files changed, 29 insertions(+), 48 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/mailbox.c b/arch/arm/mach-omap2/mailbox.c
> index 32b7af3..0609e2d 100644
> --- a/arch/arm/mach-omap2/mailbox.c
> +++ b/arch/arm/mach-omap2/mailbox.c

> @@ -18,40 +18,19 @@
> #include <mach/mailbox.h>
> #include <mach/irqs.h>
>
> -#define MAILBOX_REVISION 0x00
> -#define MAILBOX_SYSCONFIG 0x10
> -#define MAILBOX_SYSSTATUS 0x14
> -#define MAILBOX_MESSAGE_0 0x40
> -#define MAILBOX_MESSAGE_1 0x44
> -#define MAILBOX_MESSAGE_2 0x48
> -#define MAILBOX_MESSAGE_3 0x4c
> -#define MAILBOX_MESSAGE_4 0x50
> -#define MAILBOX_MESSAGE_5 0x54
> -#define MAILBOX_FIFOSTATUS_0 0x80
> -#define MAILBOX_FIFOSTATUS_1 0x84
> -#define MAILBOX_FIFOSTATUS_2 0x88
> -#define MAILBOX_FIFOSTATUS_3 0x8c
> -#define MAILBOX_FIFOSTATUS_4 0x90
> -#define MAILBOX_FIFOSTATUS_5 0x94
> -#define MAILBOX_MSGSTATUS_0 0xc0
> -#define MAILBOX_MSGSTATUS_1 0xc4
> -#define MAILBOX_MSGSTATUS_2 0xc8
> -#define MAILBOX_MSGSTATUS_3 0xcc
> -#define MAILBOX_MSGSTATUS_4 0xd0
> -#define MAILBOX_MSGSTATUS_5 0xd4
> -#define MAILBOX_IRQSTATUS_0 0x100
> -#define MAILBOX_IRQENABLE_0 0x104
> -#define MAILBOX_IRQSTATUS_1 0x108
> -#define MAILBOX_IRQENABLE_1 0x10c
> -#define MAILBOX_IRQSTATUS_2 0x110
> -#define MAILBOX_IRQENABLE_2 0x114
> -#define MAILBOX_IRQSTATUS_3 0x118
> -#define MAILBOX_IRQENABLE_3 0x11c
> +#define MAILBOX_REVISION 0x000
> +#define MAILBOX_SYSCONFIG 0x010
> +#define MAILBOX_SYSSTATUS 0x014
> +#define MAILBOX_MESSAGE(m) (0x040 + 4 * (m))
> +#define MAILBOX_FIFOSTATUS(m) (0x080 + 4 * (m))
> +#define MAILBOX_MSGSTATUS(m) (0x0c0 + 4 * (m))
> +#define MAILBOX_IRQSTATUS(u) (0x100 + 8 * (u))
> +#define MAILBOX_IRQENABLE(u) (0x108 + 8 * (u))
^^^^^^^
shouldn't this be
#define MAILBOX_IRQENABLE(u) (0x104 + 8 * (u))

>
> -static unsigned long mbox_base;
> +#define MAILBOX_IRQ_NEWMSG(u) (1 << (2 * (u)))
> +#define MAILBOX_IRQ_NOTFULL(u) (1 << (2 * (u) + 1))
>
> -#define MAILBOX_IRQ_NOTFULL(n) (1 << (2 * (n) + 1))
> -#define MAILBOX_IRQ_NEWMSG(n) (1 << (2 * (n)))
> +static unsigned long mbox_base;
>
> struct omap_mbox2_fifo {
> unsigned long msg;

2009-01-16 12:15:55

by Hiroshi DOYU

[permalink] [raw]
Subject: Re: [PATCH 01/10] omap mailbox: cleanup omap2 register definition with macro

From: "ext roel kluin" <[email protected]>
Subject: Re: [PATCH 01/10] omap mailbox: cleanup omap2 register definition with macro
Date: Fri, 16 Jan 2009 10:56:01 +0100

[...]
> > +#define MAILBOX_SYSCONFIG 0x010
> > +#define MAILBOX_SYSSTATUS 0x014
> > +#define MAILBOX_MESSAGE(m) (0x040 + 4 * (m))
> > +#define MAILBOX_FIFOSTATUS(m) (0x080 + 4 * (m))
> > +#define MAILBOX_MSGSTATUS(m) (0x0c0 + 4 * (m))
> > +#define MAILBOX_IRQSTATUS(u) (0x100 + 8 * (u))
> > +#define MAILBOX_IRQENABLE(u) (0x108 + 8 * (u))
> ^^^^^^^
> shouldn't this be
> #define MAILBOX_IRQENABLE(u) (0x104 + 8 * (u))

Right. I'll fix, thanks.

2009-01-16 13:21:37

by Hiroshi DOYU

[permalink] [raw]
Subject: Re: [PATCH 01/10] omap mailbox: cleanup omap2 register definition with macro

omap mailbox: cleanup omap2 register definition with macro

From: Hiroshi DOYU <[email protected]>

Signed-off-by: Hiroshi DOYU <[email protected]>
---

arch/arm/mach-omap2/mailbox.c | 77 +++++++++++++++--------------------------
1 files changed, 29 insertions(+), 48 deletions(-)


diff --git a/arch/arm/mach-omap2/mailbox.c b/arch/arm/mach-omap2/mailbox.c
index 32b7af3..85c3ab8 100644
--- a/arch/arm/mach-omap2/mailbox.c
+++ b/arch/arm/mach-omap2/mailbox.c
@@ -1,9 +1,9 @@
/*
- * Mailbox reservation modules for OMAP2
+ * Mailbox reservation modules for OMAP2/3
*
- * Copyright (C) 2006 Nokia Corporation
+ * Copyright (C) 2006-2008 Nokia Corporation
* Written by: Hiroshi DOYU <[email protected]>
- * and Paul Mundt <[email protected]>
+ * and Paul Mundt
*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file "COPYING" in the main directory of this archive
@@ -18,40 +18,19 @@
#include <mach/mailbox.h>
#include <mach/irqs.h>

-#define MAILBOX_REVISION 0x00
-#define MAILBOX_SYSCONFIG 0x10
-#define MAILBOX_SYSSTATUS 0x14
-#define MAILBOX_MESSAGE_0 0x40
-#define MAILBOX_MESSAGE_1 0x44
-#define MAILBOX_MESSAGE_2 0x48
-#define MAILBOX_MESSAGE_3 0x4c
-#define MAILBOX_MESSAGE_4 0x50
-#define MAILBOX_MESSAGE_5 0x54
-#define MAILBOX_FIFOSTATUS_0 0x80
-#define MAILBOX_FIFOSTATUS_1 0x84
-#define MAILBOX_FIFOSTATUS_2 0x88
-#define MAILBOX_FIFOSTATUS_3 0x8c
-#define MAILBOX_FIFOSTATUS_4 0x90
-#define MAILBOX_FIFOSTATUS_5 0x94
-#define MAILBOX_MSGSTATUS_0 0xc0
-#define MAILBOX_MSGSTATUS_1 0xc4
-#define MAILBOX_MSGSTATUS_2 0xc8
-#define MAILBOX_MSGSTATUS_3 0xcc
-#define MAILBOX_MSGSTATUS_4 0xd0
-#define MAILBOX_MSGSTATUS_5 0xd4
-#define MAILBOX_IRQSTATUS_0 0x100
-#define MAILBOX_IRQENABLE_0 0x104
-#define MAILBOX_IRQSTATUS_1 0x108
-#define MAILBOX_IRQENABLE_1 0x10c
-#define MAILBOX_IRQSTATUS_2 0x110
-#define MAILBOX_IRQENABLE_2 0x114
-#define MAILBOX_IRQSTATUS_3 0x118
-#define MAILBOX_IRQENABLE_3 0x11c
+#define MAILBOX_REVISION 0x000
+#define MAILBOX_SYSCONFIG 0x010
+#define MAILBOX_SYSSTATUS 0x014
+#define MAILBOX_MESSAGE(m) (0x040 + 4 * (m))
+#define MAILBOX_FIFOSTATUS(m) (0x080 + 4 * (m))
+#define MAILBOX_MSGSTATUS(m) (0x0c0 + 4 * (m))
+#define MAILBOX_IRQSTATUS(u) (0x100 + 8 * (u))
+#define MAILBOX_IRQENABLE(u) (0x104 + 8 * (u))

-static unsigned long mbox_base;
+#define MAILBOX_IRQ_NEWMSG(u) (1 << (2 * (u)))
+#define MAILBOX_IRQ_NOTFULL(u) (1 << (2 * (u) + 1))

-#define MAILBOX_IRQ_NOTFULL(n) (1 << (2 * (n) + 1))
-#define MAILBOX_IRQ_NEWMSG(n) (1 << (2 * (n)))
+static unsigned long mbox_base;

struct omap_mbox2_fifo {
unsigned long msg;
@@ -209,15 +188,15 @@ static struct omap_mbox_ops omap2_mbox_ops = {
/* DSP */
static struct omap_mbox2_priv omap2_mbox_dsp_priv = {
.tx_fifo = {
- .msg = MAILBOX_MESSAGE_0,
- .fifo_stat = MAILBOX_FIFOSTATUS_0,
+ .msg = MAILBOX_MESSAGE(0),
+ .fifo_stat = MAILBOX_FIFOSTATUS(0),
},
.rx_fifo = {
- .msg = MAILBOX_MESSAGE_1,
- .msg_stat = MAILBOX_MSGSTATUS_1,
+ .msg = MAILBOX_MESSAGE(1),
+ .msg_stat = MAILBOX_MSGSTATUS(1),
},
- .irqenable = MAILBOX_IRQENABLE_0,
- .irqstatus = MAILBOX_IRQSTATUS_0,
+ .irqenable = MAILBOX_IRQENABLE(0),
+ .irqstatus = MAILBOX_IRQSTATUS(0),
.notfull_bit = MAILBOX_IRQ_NOTFULL(0),
.newmsg_bit = MAILBOX_IRQ_NEWMSG(1),
};
@@ -232,15 +211,15 @@ EXPORT_SYMBOL(mbox_dsp_info);
/* IVA */
static struct omap_mbox2_priv omap2_mbox_iva_priv = {
.tx_fifo = {
- .msg = MAILBOX_MESSAGE_2,
- .fifo_stat = MAILBOX_FIFOSTATUS_2,
+ .msg = MAILBOX_MESSAGE(2),
+ .fifo_stat = MAILBOX_FIFOSTATUS(2),
},
.rx_fifo = {
- .msg = MAILBOX_MESSAGE_3,
- .msg_stat = MAILBOX_MSGSTATUS_3,
+ .msg = MAILBOX_MESSAGE(3),
+ .msg_stat = MAILBOX_MSGSTATUS(3),
},
- .irqenable = MAILBOX_IRQENABLE_3,
- .irqstatus = MAILBOX_IRQSTATUS_3,
+ .irqenable = MAILBOX_IRQENABLE(3),
+ .irqstatus = MAILBOX_IRQSTATUS(3),
.notfull_bit = MAILBOX_IRQ_NOTFULL(2),
.newmsg_bit = MAILBOX_IRQ_NEWMSG(3),
};
@@ -320,4 +299,6 @@ static void __exit omap2_mbox_exit(void)
module_init(omap2_mbox_init);
module_exit(omap2_mbox_exit);

-MODULE_LICENSE("GPL");
+MODULE_LICENSE("GPL v2");
+MODULE_DESCRIPTION("omap mailbox: omap2/3 architecture specific functions");
+MODULE_AUTHOR("Hiroshi DOYU <[email protected]>, Paul Mundt");


Attachments:
omap-mailbox-cleanup-omap2-reg (4.27 kB)

2009-01-16 15:44:21

by Felipe Balbi

[permalink] [raw]
Subject: Re: [PATCH 02/10] omap mailbox: add initial omap3 support

Hi Hiroshi,

On Fri, Jan 16, 2009 at 10:27:11AM +0200, Hiroshi DOYU wrote:
> 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;
> + } else {

how about a pr_info() or pr_err() here ?? Something like:
pr_err("%s: platform not supported yet\n", __func__);

> + return;
> + }
> platform_device_register(&mbox_device);
> }
> #else
> static inline void omap_init_mbox(void) { }
> -#endif
> +#endif /* CONFIG_OMAP_MBOX_FWK */
>
> #if defined(CONFIG_OMAP_STI)
>
> diff --git a/arch/arm/mach-omap2/mailbox.c b/arch/arm/mach-omap2/mailbox.c
> index 0609e2d..3176bb7 100644
> --- a/arch/arm/mach-omap2/mailbox.c
> +++ b/arch/arm/mach-omap2/mailbox.c
> @@ -30,7 +30,7 @@
> #define MAILBOX_IRQ_NEWMSG(u) (1 << (2 * (u)))
> #define MAILBOX_IRQ_NOTFULL(u) (1 << (2 * (u) + 1))
>
> -static unsigned long mbox_base;
> +static void __iomem *mbox_base;
>
> struct omap_mbox2_fifo {
> unsigned long msg;
> @@ -52,14 +52,14 @@ static struct clk *mbox_ick_handle;
> static void omap2_mbox_enable_irq(struct omap_mbox *mbox,
> omap_mbox_type_t irq);
>
> -static inline unsigned int mbox_read_reg(unsigned int reg)
> +static inline unsigned int mbox_read_reg(size_t ofs)
> {
> - return __raw_readl(mbox_base + reg);
> + return __raw_readl(mbox_base + ofs);
> }
>
> -static inline void mbox_write_reg(unsigned int val, unsigned int reg)
> +static inline void mbox_write_reg(u32 val, size_t ofs)
> {
> - __raw_writel(val, mbox_base + reg);
> + __raw_writel(val, mbox_base + ofs);
> }
>
> /* Mailbox H/W preparations */
> @@ -208,7 +208,7 @@ struct omap_mbox mbox_dsp_info = {
> };
> EXPORT_SYMBOL(mbox_dsp_info);
>
> -/* IVA */
> +#if defined(CONFIG_ARCH_OMAP2420) /* IVA */

would be nice to have something like if (cpu_has_iva()) { ... } and move
this check to a later location e.g. on probe(), but this wouldn't prevent
this patch from going in now. Just a suggestion for later improvements.

> static struct omap_mbox2_priv omap2_mbox_iva_priv = {
> .tx_fifo = {
> .msg = MAILBOX_MESSAGE(2),
> @@ -229,17 +229,12 @@ static struct omap_mbox mbox_iva_info = {
> .ops = &omap2_mbox_ops,
> .priv = &omap2_mbox_iva_priv,
> };
> +#endif

[snip]

> - /* IVA IRQ */
> - res = platform_get_resource(pdev, IORESOURCE_IRQ, 1);
> - if (unlikely(!res)) {
> - dev_err(&pdev->dev, "invalid irq resource\n");
> - return -ENODEV;
> + if (ret)
> + goto err_dsp;
> +
> +#if defined(CONFIG_ARCH_OMAP2420) /* IVA */
> + if (cpu_is_omap2420()) {
> + /* IVA IRQ */
> + res = platform_get_resource(pdev, IORESOURCE_IRQ, 1);

platform_get_irq(pdev, 0) would look more standard, I think.

--
balbi

2009-01-17 17:11:13

by Russell King - ARM Linux

[permalink] [raw]
Subject: Re: [PATCH 07/10] omap mailbox: add save_/restore_ctx() for PM

On Fri, Jan 16, 2009 at 10:27:37AM +0200, Hiroshi DOYU wrote:
> diff --git a/arch/arm/mach-omap2/mailbox.c b/arch/arm/mach-omap2/mailbox.c
> index a877305..544dde9 100644
> --- a/arch/arm/mach-omap2/mailbox.c
> +++ b/arch/arm/mach-omap2/mailbox.c
> @@ -32,6 +32,8 @@
> #define MAILBOX_IRQ_NEWMSG(u) (1 << (2 * (u)))
> #define MAILBOX_IRQ_NOTFULL(u) (1 << (2 * (u) + 1))
>
> +#define MBOX_REG_SIZE 0x120
> +
> static void __iomem *mbox_base;
>
> struct omap_mbox2_fifo {
> @@ -47,6 +49,7 @@ struct omap_mbox2_priv {
> unsigned long irqstatus;
> u32 newmsg_bit;
> u32 notfull_bit;
> + char ctx[MBOX_REG_SIZE];

u32 ctx[MOX_REG_SIZE / sizeof(u32)];

?

> };
>
> static struct clk *mbox_ick_handle;
> @@ -167,6 +170,36 @@ static int omap2_mbox_is_irq(struct omap_mbox *mbox,
> return (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_REG_SIZE; i += sizeof(u32)) {
> + u32 val;
> +
> + val = mbox_read_reg(i);
> + *(u32 *)(p->ctx + i) = val;

p->ctx[i] = mbox_read_reg(i);

?

> +
> + dev_dbg(mbox->dev, "%s\t[%02d] %08x\n", __func__, i, val);

tabs aren't nice in kernel messages.

dev_dbg(mbox->dev, "%s: [%02d] %08x\n", __func__,
i, p->ctx[i]);

also, mixing decimal and octal as bare numbers can be rather confusing.

> + }
> +}
> +
> +static void omap2_mbox_restore_ctx(struct omap_mbox *mbox)
> +{
> + int i;
> + struct omap_mbox2_priv *p = mbox->priv;
> +
> + for (i = 0; i < MBOX_REG_SIZE; i += sizeof(u32)) {
> + u32 val;
> +
> + val = *(u32 *)(p->ctx + i);
> + mbox_write_reg(val, i);

mbox_write_reg(p->ctx[i], i);

> +
> + dev_dbg(mbox->dev, "%s\t[%02d] %08x\n", __func__, i, val);

dev_dbg(mbox->dev, "%s: [%02d] %08x\n@, __func__,
i, p->ctx[i]);

2009-01-17 17:21:01

by Russell King - ARM Linux

[permalink] [raw]
Subject: Re: [PATCH 07/10] omap mailbox: add save_/restore_ctx() for PM

On Sat, Jan 17, 2009 at 05:10:44PM +0000, Russell King - ARM Linux wrote:
> On Fri, Jan 16, 2009 at 10:27:37AM +0200, Hiroshi DOYU wrote:
> > diff --git a/arch/arm/mach-omap2/mailbox.c b/arch/arm/mach-omap2/mailbox.c
> > index a877305..544dde9 100644
> > --- a/arch/arm/mach-omap2/mailbox.c
> > +++ b/arch/arm/mach-omap2/mailbox.c
> > @@ -32,6 +32,8 @@
> > #define MAILBOX_IRQ_NEWMSG(u) (1 << (2 * (u)))
> > #define MAILBOX_IRQ_NOTFULL(u) (1 << (2 * (u) + 1))
> >
> > +#define MBOX_REG_SIZE 0x120
> > +
> > static void __iomem *mbox_base;
> >
> > struct omap_mbox2_fifo {
> > @@ -47,6 +49,7 @@ struct omap_mbox2_priv {
> > unsigned long irqstatus;
> > u32 newmsg_bit;
> > u32 notfull_bit;
> > + char ctx[MBOX_REG_SIZE];
>
> u32 ctx[MOX_REG_SIZE / sizeof(u32)];
>
> ?
>
> > };
> >
> > static struct clk *mbox_ick_handle;
> > @@ -167,6 +170,36 @@ static int omap2_mbox_is_irq(struct omap_mbox *mbox,
> > return (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_REG_SIZE; i += sizeof(u32)) {
> > + u32 val;
> > +
> > + val = mbox_read_reg(i);
> > + *(u32 *)(p->ctx + i) = val;
>
> p->ctx[i] = mbox_read_reg(i);

Hmm, don't forget 'i' is an offset not an index, so...

?define MBOX_NR_REGS (MBOX_REG_SIZE / sizeof(u32))

for (i = 0; i < MBOX_NR_REGS; i++) {
p->ctx[i] = mbox_read_reg(i * sizeof(u32));

(you'll have to excuse the '?' there - my keyboard currently does not have
a 'hash' key for some Fedora 9 post upgrade silly reason.)

2009-01-19 10:37:19

by Hiroshi DOYU

[permalink] [raw]
Subject: Re: [PATCH 07/10] omap mailbox: add save_/restore_ctx() for PM

omap mailbox: add save_/restore_ctx() for PM

From: Hiroshi DOYU <[email protected]>

To preserve the registers during off-mode

Signed-off-by: Hiroshi DOYU <[email protected]>
---

arch/arm/mach-omap2/mailbox.c | 32 +++++++++++++++++++++++++++++
arch/arm/plat-omap/include/mach/mailbox.h | 23 +++++++++++++++++++++
2 files changed, 55 insertions(+), 0 deletions(-)


diff --git a/arch/arm/mach-omap2/mailbox.c b/arch/arm/mach-omap2/mailbox.c
index 5751013..0a88243 100644
--- a/arch/arm/mach-omap2/mailbox.c
+++ b/arch/arm/mach-omap2/mailbox.c
@@ -32,6 +32,9 @@
#define MAILBOX_IRQ_NEWMSG(u) (1 << (2 * (u)))
#define MAILBOX_IRQ_NOTFULL(u) (1 << (2 * (u) + 1))

+#define MBOX_REG_SIZE 0x120
+#define MBOX_NR_REGS (MBOX_REG_SIZE / sizeof(u32))
+
static void __iomem *mbox_base;

struct omap_mbox2_fifo {
@@ -47,6 +50,7 @@ struct omap_mbox2_priv {
unsigned long irqstatus;
u32 newmsg_bit;
u32 notfull_bit;
+ u32 ctx[MBOX_NR_REGS];
};

static struct clk *mbox_ick_handle;
@@ -167,6 +171,32 @@ static int omap2_mbox_is_irq(struct omap_mbox *mbox,
return (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++) {
+ p->ctx[i] = mbox_read_reg(i * sizeof(u32));
+
+ dev_dbg(mbox->dev, "%s: [%02x] %08x\n", __func__,
+ i, p->ctx[i]);
+ }
+}
+
+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++) {
+ mbox_write_reg(p->ctx[i], i * sizeof(u32));
+
+ dev_dbg(mbox->dev, "%s: [%02x] %08x\n", __func__,
+ i, p->ctx[i]);
+ }
+}
+
static struct omap_mbox_ops omap2_mbox_ops = {
.type = OMAP_MBOX_TYPE2,
.startup = omap2_mbox_startup,
@@ -179,6 +209,8 @@ static struct omap_mbox_ops omap2_mbox_ops = {
.disable_irq = omap2_mbox_disable_irq,
.ack_irq = omap2_mbox_ack_irq,
.is_irq = omap2_mbox_is_irq,
+ .save_ctx = omap2_mbox_save_ctx,
+ .restore_ctx = omap2_mbox_restore_ctx,
};

/*
diff --git a/arch/arm/plat-omap/include/mach/mailbox.h b/arch/arm/plat-omap/include/mach/mailbox.h
index 577db68..b7a6991 100644
--- a/arch/arm/plat-omap/include/mach/mailbox.h
+++ b/arch/arm/plat-omap/include/mach/mailbox.h
@@ -33,6 +33,9 @@ struct omap_mbox_ops {
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 */
+ void (*save_ctx)(struct omap_mbox *mbox);
+ void (*restore_ctx)(struct omap_mbox *mbox);
};

struct omap_mbox_queue {
@@ -70,4 +73,24 @@ void omap_mbox_put(struct omap_mbox *);
int omap_mbox_register(struct device *parent, struct omap_mbox *);
int omap_mbox_unregister(struct omap_mbox *);

+static inline void omap_mbox_save_ctx(struct omap_mbox *mbox)
+{
+ if (!mbox->ops->save_ctx) {
+ dev_err(mbox->dev, "%s:\tno save\n", __func__);
+ return;
+ }
+
+ mbox->ops->save_ctx(mbox);
+}
+
+static inline void omap_mbox_restore_ctx(struct omap_mbox *mbox)
+{
+ if (!mbox->ops->restore_ctx) {
+ dev_err(mbox->dev, "%s:\tno restore\n", __func__);
+ return;
+ }
+
+ mbox->ops->restore_ctx(mbox);
+}
+
#endif /* MAILBOX_H */


Attachments:
omap-mailbox-add-save_-restore (3.20 kB)

2009-01-19 22:00:36

by Russell King - ARM Linux

[permalink] [raw]
Subject: Re: [PATCH 07/10] omap mailbox: add save_/restore_ctx() for PM

On Mon, Jan 19, 2009 at 12:36:12PM +0200, Hiroshi DOYU wrote:
> Hi Russell, Thank you for your review.
>
> From: "ext Russell King - ARM Linux" <[email protected]>
> Subject: Re: [PATCH 07/10] omap mailbox: add save_/restore_ctx() for PM
> Date: Sat, 17 Jan 2009 17:20:37 +0000
>
> > On Sat, Jan 17, 2009 at 05:10:44PM +0000, Russell King - ARM Linux wrote:
> > > On Fri, Jan 16, 2009 at 10:27:37AM +0200, Hiroshi DOYU wrote:
> > > > diff --git a/arch/arm/mach-omap2/mailbox.c b/arch/arm/mach-omap2/mailbox.c
> > > > index a877305..544dde9 100644
> > > > --- a/arch/arm/mach-omap2/mailbox.c
> > > > +++ b/arch/arm/mach-omap2/mailbox.c
>
> [...]
>
> > Hmm, don't forget 'i' is an offset not an index, so...
> >
> > ?define MBOX_NR_REGS (MBOX_REG_SIZE / sizeof(u32))
> >
> > for (i = 0; i < MBOX_NR_REGS; i++) {
> > p->ctx[i] = mbox_read_reg(i * sizeof(u32));
>
> The updated one is attached.

... which looks much better, thanks.

2009-01-28 14:50:25

by Russell King - ARM Linux

[permalink] [raw]
Subject: Re: [PATCH 05/10] omap mailbox: fix empty struct device for omap1

On Fri, Jan 16, 2009 at 10:27:27AM +0200, Hiroshi DOYU wrote:
> @@ -17,6 +17,8 @@
> #include <mach/mailbox.h>
> #include <mach/irqs.h>
>
> +#define DRV_NAME "omap1-mailbox"

I don't see any need for this define - it just adds an additional level of
indirection when trying to find out the name of the driver. It's only
used in two places as is, so it's value is rather limited:

> @@ -184,9 +184,9 @@ static int omap1_mbox_remove(struct platform_device *pdev)
>
> static struct platform_driver omap1_mbox_driver = {
> .probe = omap1_mbox_probe,
> - .remove = omap1_mbox_remove,
> + .remove = __devexit_p(omap1_mbox_remove),
> .driver = {
> - .name = "mailbox",
> + .name = DRV_NAME,
> },
> };
>
> @@ -203,4 +203,7 @@ static void __exit omap1_mbox_exit(void)
> module_init(omap1_mbox_init);
> module_exit(omap1_mbox_exit);
>
> -MODULE_LICENSE("GPL");
> +MODULE_LICENSE("GPL v2");
> +MODULE_DESCRIPTION("omap mailbox: omap1 architecture specific functions");
> +MODULE_AUTHOR("Hiroshi DOYU" <[email protected]>);
> +MODULE_ALIAS("platform:"DRV_NAME);

2009-01-28 15:34:33

by Hiroshi DOYU

[permalink] [raw]
Subject: Re: [PATCH 05/10] omap mailbox: fix empty struct device for omap1

>From 6f215301eab1e20c83d4e55e0de5faec62b17ae7 Mon Sep 17 00:00:00 2001
From: Hiroshi DOYU <[email protected]>
Date: Sun, 18 Jan 2009 01:04:07 +0200
Subject: [PATCH 05/10] omap mailbox: fix empty struct device for omap1

Signed-off-by: Hiroshi DOYU <[email protected]>
---
arch/arm/mach-omap1/devices.c | 2 +-
arch/arm/mach-omap1/mailbox.c | 33 ++++++++++++++++++---------------
2 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/arch/arm/mach-omap1/devices.c b/arch/arm/mach-omap1/devices.c
index 77382d8..b4b6106 100644
--- a/arch/arm/mach-omap1/devices.c
+++ b/arch/arm/mach-omap1/devices.c
@@ -86,7 +86,7 @@ static struct resource mbox_resources[] = {
};

static struct platform_device mbox_device = {
- .name = "mailbox",
+ .name = "omap1-mailbox",
.id = -1,
.num_resources = ARRAY_SIZE(mbox_resources),
.resource = mbox_resources,
diff --git a/arch/arm/mach-omap1/mailbox.c b/arch/arm/mach-omap1/mailbox.c
index 59abbf3..92a90be 100644
--- a/arch/arm/mach-omap1/mailbox.c
+++ b/arch/arm/mach-omap1/mailbox.c
@@ -1,7 +1,7 @@
/*
* Mailbox reservation modules for DSP
*
- * Copyright (C) 2006 Nokia Corporation
+ * Copyright (C) 2006-2009 Nokia Corporation
* Written by: Hiroshi DOYU <[email protected]>
*
* This file is subject to the terms and conditions of the GNU General Public
@@ -13,7 +13,9 @@
#include <linux/resource.h>
#include <linux/interrupt.h>
#include <linux/platform_device.h>
-#include <linux/io.h>
+
+#include <asm/io.h>
+
#include <mach/mailbox.h>
#include <mach/irqs.h>

@@ -27,7 +29,7 @@
#define MAILBOX_DSP2ARM1_Flag 0x1c
#define MAILBOX_DSP2ARM2_Flag 0x20

-unsigned long mbox_base;
+static void __iomem *mbox_base;

struct omap_mbox1_fifo {
unsigned long cmd;
@@ -40,14 +42,14 @@ struct omap_mbox1_priv {
struct omap_mbox1_fifo rx_fifo;
};

-static inline int mbox_read_reg(unsigned int reg)
+static inline int mbox_read_reg(size_t ofs)
{
- return __raw_readw(mbox_base + reg);
+ return __raw_readw(mbox_base + ofs);
}

-static inline void mbox_write_reg(unsigned int val, unsigned int reg)
+static inline void mbox_write_reg(u32 val, size_t ofs)
{
- __raw_writew(val, mbox_base + reg);
+ __raw_writew(val, mbox_base + ofs);
}

/* msg */
@@ -143,7 +145,7 @@ struct omap_mbox mbox_dsp_info = {
};
EXPORT_SYMBOL(mbox_dsp_info);

-static int __init omap1_mbox_probe(struct platform_device *pdev)
+static int __devinit omap1_mbox_probe(struct platform_device *pdev)
{
struct resource *res;
int ret = 0;
@@ -170,12 +172,10 @@ static int __init omap1_mbox_probe(struct platform_device *pdev)
}
mbox_dsp_info.irq = res->start;

- ret = omap_mbox_register(&mbox_dsp_info);
-
- return ret;
+ return omap_mbox_register(&pdev->dev, &mbox_dsp_info);
}

-static int omap1_mbox_remove(struct platform_device *pdev)
+static int __devexit omap1_mbox_remove(struct platform_device *pdev)
{
omap_mbox_unregister(&mbox_dsp_info);

@@ -184,9 +184,9 @@ static int omap1_mbox_remove(struct platform_device *pdev)

static struct platform_driver omap1_mbox_driver = {
.probe = omap1_mbox_probe,
- .remove = omap1_mbox_remove,
+ .remove = __devexit_p(omap1_mbox_remove),
.driver = {
- .name = "mailbox",
+ .name = "omap1-mailbox",
},
};

@@ -203,4 +203,7 @@ static void __exit omap1_mbox_exit(void)
module_init(omap1_mbox_init);
module_exit(omap1_mbox_exit);

-MODULE_LICENSE("GPL");
+MODULE_LICENSE("GPL v2");
+MODULE_DESCRIPTION("omap mailbox: omap1 architecture specific functions");
+MODULE_AUTHOR("Hiroshi DOYU" <[email protected]>);
+MODULE_ALIAS("platform:omap1-mailbox");
--
1.6.1.rc4


Attachments:
0006-omap-mailbox-fix-empty-struct-device-for-omap2.patch (2.73 kB)
0005-omap-mailbox-fix-empty-struct-device-for-omap1.patch (3.54 kB)
Download all attachments

2009-01-28 17:51:12

by Russell King - ARM Linux

[permalink] [raw]
Subject: Re: [PATCH 05/10] omap mailbox: fix empty struct device for omap1

On Wed, Jan 28, 2009 at 05:29:51PM +0200, Hiroshi DOYU wrote:
> diff --git a/arch/arm/mach-omap2/mailbox.c b/arch/arm/mach-omap2/mailbox.c
> index 44e9101..af32db0 100644
> --- a/arch/arm/mach-omap2/mailbox.c
> +++ b/arch/arm/mach-omap2/mailbox.c
> @@ -14,7 +14,9 @@
> #include <linux/clk.h>
> #include <linux/err.h>
> #include <linux/platform_device.h>
> -#include <linux/io.h>
> +
> +#include <asm/io.h>
> +

NAK.

> diff --git a/arch/arm/mach-omap1/mailbox.c b/arch/arm/mach-omap1/mailbox.c
> index 59abbf3..92a90be 100644
> --- a/arch/arm/mach-omap1/mailbox.c
> +++ b/arch/arm/mach-omap1/mailbox.c
> @@ -1,7 +1,7 @@
> /*
> * Mailbox reservation modules for DSP
> *
> - * Copyright (C) 2006 Nokia Corporation
> + * Copyright (C) 2006-2009 Nokia Corporation
> * Written by: Hiroshi DOYU <[email protected]>
> *
> * This file is subject to the terms and conditions of the GNU General Public
> @@ -13,7 +13,9 @@
> #include <linux/resource.h>
> #include <linux/interrupt.h>
> #include <linux/platform_device.h>
> -#include <linux/io.h>
> +
> +#include <asm/io.h>
> +

NAK.

See fced80c735941fa518ac67c0b61bbe153fb8c050.

The above can not be explained by a mis-merge - they are not a mere
reversion of the above change. They look like a purposeful change
back to the wrong include file.

Can someone please work out why this has happened and what needs to
be done to prevent it happening in the future.

2009-01-28 19:22:15

by Hiroshi DOYU

[permalink] [raw]
Subject: Re: [PATCH 05/10] omap mailbox: fix empty struct device for omap1

>From f6efca787d09564c0cfd8ad1cb21d29213df8862 Mon Sep 17 00:00:00 2001
From: Hiroshi DOYU <[email protected]>
Date: Wed, 28 Jan 2009 21:18:07 +0200
Subject: [PATCH 05/10] omap mailbox: fix empty struct device for omap1

Signed-off-by: Hiroshi DOYU <[email protected]>
---
arch/arm/mach-omap1/devices.c | 2 +-
arch/arm/mach-omap1/mailbox.c | 29 +++++++++++++++--------------
2 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/arch/arm/mach-omap1/devices.c b/arch/arm/mach-omap1/devices.c
index 77382d8..b4b6106 100644
--- a/arch/arm/mach-omap1/devices.c
+++ b/arch/arm/mach-omap1/devices.c
@@ -86,7 +86,7 @@ static struct resource mbox_resources[] = {
};

static struct platform_device mbox_device = {
- .name = "mailbox",
+ .name = "omap1-mailbox",
.id = -1,
.num_resources = ARRAY_SIZE(mbox_resources),
.resource = mbox_resources,
diff --git a/arch/arm/mach-omap1/mailbox.c b/arch/arm/mach-omap1/mailbox.c
index 59abbf3..0af4d6c 100644
--- a/arch/arm/mach-omap1/mailbox.c
+++ b/arch/arm/mach-omap1/mailbox.c
@@ -1,7 +1,7 @@
/*
* Mailbox reservation modules for DSP
*
- * Copyright (C) 2006 Nokia Corporation
+ * Copyright (C) 2006-2009 Nokia Corporation
* Written by: Hiroshi DOYU <[email protected]>
*
* This file is subject to the terms and conditions of the GNU General Public
@@ -27,7 +27,7 @@
#define MAILBOX_DSP2ARM1_Flag 0x1c
#define MAILBOX_DSP2ARM2_Flag 0x20

-unsigned long mbox_base;
+static void __iomem *mbox_base;

struct omap_mbox1_fifo {
unsigned long cmd;
@@ -40,14 +40,14 @@ struct omap_mbox1_priv {
struct omap_mbox1_fifo rx_fifo;
};

-static inline int mbox_read_reg(unsigned int reg)
+static inline int mbox_read_reg(size_t ofs)
{
- return __raw_readw(mbox_base + reg);
+ return __raw_readw(mbox_base + ofs);
}

-static inline void mbox_write_reg(unsigned int val, unsigned int reg)
+static inline void mbox_write_reg(u32 val, size_t ofs)
{
- __raw_writew(val, mbox_base + reg);
+ __raw_writew(val, mbox_base + ofs);
}

/* msg */
@@ -143,7 +143,7 @@ struct omap_mbox mbox_dsp_info = {
};
EXPORT_SYMBOL(mbox_dsp_info);

-static int __init omap1_mbox_probe(struct platform_device *pdev)
+static int __devinit omap1_mbox_probe(struct platform_device *pdev)
{
struct resource *res;
int ret = 0;
@@ -170,12 +170,10 @@ static int __init omap1_mbox_probe(struct platform_device *pdev)
}
mbox_dsp_info.irq = res->start;

- ret = omap_mbox_register(&mbox_dsp_info);
-
- return ret;
+ return omap_mbox_register(&pdev->dev, &mbox_dsp_info);
}

-static int omap1_mbox_remove(struct platform_device *pdev)
+static int __devexit omap1_mbox_remove(struct platform_device *pdev)
{
omap_mbox_unregister(&mbox_dsp_info);

@@ -184,9 +182,9 @@ static int omap1_mbox_remove(struct platform_device *pdev)

static struct platform_driver omap1_mbox_driver = {
.probe = omap1_mbox_probe,
- .remove = omap1_mbox_remove,
+ .remove = __devexit_p(omap1_mbox_remove),
.driver = {
- .name = "mailbox",
+ .name = "omap1-mailbox",
},
};

@@ -203,4 +201,7 @@ static void __exit omap1_mbox_exit(void)
module_init(omap1_mbox_init);
module_exit(omap1_mbox_exit);

-MODULE_LICENSE("GPL");
+MODULE_LICENSE("GPL v2");
+MODULE_DESCRIPTION("omap mailbox: omap1 architecture specific functions");
+MODULE_AUTHOR("Hiroshi DOYU" <[email protected]>);
+MODULE_ALIAS("platform:omap1-mailbox");
--
1.6.1.rc4


Attachments:
0006-omap-mailbox-fix-empty-struct-device-for-omap2.patch (2.53 kB)
0005-omap-mailbox-fix-empty-struct-device-for-omap1.patch (3.32 kB)
Download all attachments

2009-01-28 19:42:33

by Russell King - ARM Linux

[permalink] [raw]
Subject: Re: [PATCH 05/10] omap mailbox: fix empty struct device for omap1

On Wed, Jan 28, 2009 at 09:21:22PM +0200, Hiroshi DOYU wrote:
> It seems that I misunderstood your comment in the following mail.
>
> http://lkml.indiana.edu/hypermail/linux/kernel/0901.2/00610.html

Ah, that comment was more about that specific include in that specific
file - I couldn't see anything in there which required it.

The general rule is: if both asm/xxx.h and linux/xxx.h exists, then use
the linux/xxx.h version. I stress _general_ rule - there are exceptions.
For example, linux/irq.h and linux/memory.h. A clue would be if linux/xxx.h
doesn't include asm/xxx.h, then the rule above probably doesn't apply.

> Reverted both header file changes. Update attached patches.

Much better, thanks. This I'm happy with.

2009-01-30 18:57:36

by Tony Lindgren

[permalink] [raw]
Subject: Re: [PATCH 00/10] arm: omap mailbox: add omap3 support with some fixes

* Hiroshi DOYU <[email protected]> [090116 00:29]:
> The following patches add omap3 support and some cleanups.
>
> This "omap mailbox" device driver has been used for the interprocessor
> communication between ARM and some co-processors(DSP) inside of omap
> SoC, which is a kind of interrupt driven FIFO.

Adding the mailbox series to the omap for-next branch. Ignoring the
iommu series for now as it still needs some updates.

Tony


> ---
>
> Hiroshi DOYU (10):
> omap mailbox: remove unnecessary header file inclusion
> omap mailbox: convert sequence bit checking to module paramter
> omap mailbox: move mailbox.h into mailbox.c
> omap mailbox: add save_/restore_ctx() for PM
> omap mailbox: fix empty struct device for omap2
> omap mailbox: fix empty struct device for omap1
> omap mailbox: fix empty struct device for omap_mbox
> omap mailbox: print hardware revision at startup
> omap mailbox: add initial omap3 support
> omap mailbox: cleanup omap2 register definition with macro
>
>
> arch/arm/mach-omap1/devices.c | 2
> arch/arm/mach-omap1/mailbox.c | 31 ++--
> arch/arm/mach-omap2/devices.c | 38 ++++-
> arch/arm/mach-omap2/mailbox.c | 195 +++++++++++++++++-----------
> arch/arm/plat-omap/Kconfig | 8 +
> arch/arm/plat-omap/include/mach/mailbox.h | 27 ++++
> arch/arm/plat-omap/include/mach/omap34xx.h | 1
> arch/arm/plat-omap/mailbox.c | 152 ++++++++++++++++------
> arch/arm/plat-omap/mailbox.h | 100 --------------
> 9 files changed, 311 insertions(+), 243 deletions(-)
> delete mode 100644 arch/arm/plat-omap/mailbox.h
>
> --
> Hiroshi DOYU
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html