* [PATCH 1/9] mailbox: OMAP: introduce mailbox framework
2012-12-18 13:10 [PATCH 0/9] drivers: mailbox: framework creation Loic Pallardy
@ 2012-12-18 13:10 ` Loic Pallardy
2012-12-18 16:59 ` Tony Lindgren
2012-12-18 13:10 ` [PATCH 2/9] mailbox: split internal header from API header Loic Pallardy
` (8 subsequent siblings)
9 siblings, 1 reply; 31+ messages in thread
From: Loic Pallardy @ 2012-12-18 13:10 UTC (permalink / raw)
To: linux-arm-kernel
Actually moving it from plat-omap, as this framework/driver code is
supposed to be under drivers/ folder. The framework should work with
the current supported OMAP processors (OMAP1+) that have mailbox and
can be used as a method of interprocessor communication.
The mailbox hardware (in OMAP) uses a queued mailbox-interrupt mechanism
that provides a communication channel between processors through a set of
registers and their associated interrupt signals by sending and receiving
messages.
As part of the migration from plat and mach code:
- Kconfig symbols have been renamed to build OMAP1 or OMAP2+ drivers.
- mailbox.h has been changed from plat to a dedicated drivers/ folder.
- soc.h has been changed for plat/cpu.h, since there are dependencies in
the cpu_is_XXXX() macro.
Module names have changed too, instead of mailbox_mach:
- OMAP1: mailbox-omap1.ko
- OMAP2+: mailbox-omap2.ko
Signed-off-by: Omar Ramirez Luna <omar.luna@linaro.org>
---
arch/arm/configs/omap1_defconfig | 3 +-
arch/arm/mach-omap1/Makefile | 4 -
arch/arm/mach-omap2/Makefile | 3 -
arch/arm/mach-omap2/devices.c | 4 +-
arch/arm/plat-omap/Kconfig | 16 ---
arch/arm/plat-omap/Makefile | 3 -
drivers/Kconfig | 2 +
drivers/Makefile | 1 +
drivers/mailbox/Kconfig | 37 +++++
drivers/mailbox/Makefile | 4 +
.../mailbox.c => drivers/mailbox/mailbox-omap1.c | 65 ++++-----
.../mailbox.c => drivers/mailbox/mailbox-omap2.c | 160 ++++++++++-----------
{arch/arm/plat-omap => drivers/mailbox}/mailbox.c | 18 +--
.../include/plat => drivers/mailbox}/mailbox.h | 58 ++++----
14 files changed, 199 insertions(+), 179 deletions(-)
create mode 100644 drivers/mailbox/Kconfig
create mode 100644 drivers/mailbox/Makefile
rename arch/arm/mach-omap1/mailbox.c => drivers/mailbox/mailbox-omap1.c (75%)
rename arch/arm/mach-omap2/mailbox.c => drivers/mailbox/mailbox-omap2.c (69%)
rename {arch/arm/plat-omap => drivers/mailbox}/mailbox.c (97%)
rename {arch/arm/plat-omap/include/plat => drivers/mailbox}/mailbox.h (57%)
diff --git a/arch/arm/configs/omap1_defconfig b/arch/arm/configs/omap1_defconfig
index dde2a1a..37894db 100644
--- a/arch/arm/configs/omap1_defconfig
+++ b/arch/arm/configs/omap1_defconfig
@@ -26,7 +26,8 @@ CONFIG_ARCH_OMAP=y
CONFIG_ARCH_OMAP1=y
CONFIG_OMAP_RESET_CLOCKS=y
# CONFIG_OMAP_MUX is not set
-CONFIG_OMAP_MBOX_FWK=y
+CONFIG_MAILBOX=y
+CONFIG_OMAP1_MBOX=y
CONFIG_OMAP_32K_TIMER=y
CONFIG_OMAP_DM_TIMER=y
CONFIG_ARCH_OMAP730=y
diff --git a/arch/arm/mach-omap1/Makefile b/arch/arm/mach-omap1/Makefile
index cd169c3..48275f8 100644
--- a/arch/arm/mach-omap1/Makefile
+++ b/arch/arm/mach-omap1/Makefile
@@ -18,10 +18,6 @@ obj-$(CONFIG_ARCH_OMAP16XX) += ocpi.o
# Power Management
obj-$(CONFIG_PM) += pm.o sleep.o
-# DSP
-obj-$(CONFIG_OMAP_MBOX_FWK) += mailbox_mach.o
-mailbox_mach-objs := mailbox.o
-
i2c-omap-$(CONFIG_I2C_OMAP) := i2c.o
obj-y += $(i2c-omap-m) $(i2c-omap-y)
diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index fe40d9e..3907fc5 100644
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -181,9 +181,6 @@ obj-$(CONFIG_ARCH_OMAP4) += omap_hwmod_44xx_data.o
obj-$(CONFIG_OMAP3_EMU) += emu.o
obj-$(CONFIG_HW_PERF_EVENTS) += pmu.o
-obj-$(CONFIG_OMAP_MBOX_FWK) += mailbox_mach.o
-mailbox_mach-objs := mailbox.o
-
obj-$(CONFIG_OMAP_IOMMU) += iommu2.o
iommu-$(CONFIG_OMAP_IOMMU) := omap-iommu.o
diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
index c72b5a7..5ef4004 100644
--- a/arch/arm/mach-omap2/devices.c
+++ b/arch/arm/mach-omap2/devices.c
@@ -273,7 +273,7 @@ int __init omap4_keyboard_init(struct omap4_keypad_platform_data
return 0;
}
-#if defined(CONFIG_OMAP_MBOX_FWK) || defined(CONFIG_OMAP_MBOX_FWK_MODULE)
+#if defined(CONFIG_OMAP2PLUS_MBOX) || defined(CONFIG_OMAP2PLUS_MBOX_MODULE)
static inline void __init omap_init_mbox(void)
{
struct omap_hwmod *oh;
@@ -291,7 +291,7 @@ static inline void __init omap_init_mbox(void)
}
#else
static inline void omap_init_mbox(void) { }
-#endif /* CONFIG_OMAP_MBOX_FWK */
+#endif /* CONFIG_OMAP2PLUS_MBOX */
static inline void omap_init_sti(void) {}
diff --git a/arch/arm/plat-omap/Kconfig b/arch/arm/plat-omap/Kconfig
index 82fcb20..419648f 100644
--- a/arch/arm/plat-omap/Kconfig
+++ b/arch/arm/plat-omap/Kconfig
@@ -116,22 +116,6 @@ config OMAP_MUX_WARNINGS
to change the pin multiplexing setup. When there are no warnings
printed, it's safe to deselect OMAP_MUX for your product.
-config OMAP_MBOX_FWK
- tristate "Mailbox framework support"
- depends on ARCH_OMAP
- help
- Say Y here if you want to use OMAP Mailbox framework support for
- 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_IVA2
bool
diff --git a/arch/arm/plat-omap/Makefile b/arch/arm/plat-omap/Makefile
index dacaee0..304fa78 100644
--- a/arch/arm/plat-omap/Makefile
+++ b/arch/arm/plat-omap/Makefile
@@ -17,7 +17,4 @@ obj-$(CONFIG_OMAP_DEBUG_LEDS) += debug-leds.o
i2c-omap-$(CONFIG_I2C_OMAP) := i2c.o
obj-y += $(i2c-omap-m) $(i2c-omap-y)
-# OMAP mailbox framework
-obj-$(CONFIG_OMAP_MBOX_FWK) += mailbox.o
-
obj-$(CONFIG_OMAP_PM_NOOP) += omap-pm-noop.o
diff --git a/drivers/Kconfig b/drivers/Kconfig
index dbdefa3..7a4fb98 100644
--- a/drivers/Kconfig
+++ b/drivers/Kconfig
@@ -134,6 +134,8 @@ source "drivers/hwspinlock/Kconfig"
source "drivers/clocksource/Kconfig"
+source "drivers/mailbox/Kconfig"
+
source "drivers/iommu/Kconfig"
source "drivers/remoteproc/Kconfig"
diff --git a/drivers/Makefile b/drivers/Makefile
index a16a8d0..78f2bf0 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -132,6 +132,7 @@ obj-y += clk/
obj-$(CONFIG_HWSPINLOCK) += hwspinlock/
obj-$(CONFIG_NFC) += nfc/
+obj-$(CONFIG_MAILBOX) += mailbox/
obj-$(CONFIG_IOMMU_SUPPORT) += iommu/
obj-$(CONFIG_REMOTEPROC) += remoteproc/
obj-$(CONFIG_RPMSG) += rpmsg/
diff --git a/drivers/mailbox/Kconfig b/drivers/mailbox/Kconfig
new file mode 100644
index 0000000..e98ca6c
--- /dev/null
+++ b/drivers/mailbox/Kconfig
@@ -0,0 +1,37 @@
+menuconfig MAILBOX
+ bool "Mailbox Hardware Support"
+ help
+ Mailbox is a framework to control hardware communication between
+ on-chip processors through queued messages and interrupt driven
+ signals. Say Y if your platform supports hardware mailboxes.
+
+if MAILBOX
+
+config OMAP1_MBOX
+ tristate "OMAP1 Mailbox framework support"
+ depends on ARCH_OMAP
+ help
+ Mailbox implementation for OMAP chips with hardware for
+ interprocessor communication involving DSP in OMAP1. Say Y here
+ if you want to use OMAP1 Mailbox framework support.
+
+config OMAP2PLUS_MBOX
+ tristate "OMAP2+ Mailbox framework support"
+ depends on ARCH_OMAP
+ help
+ Mailbox implementation for OMAP family chips with hardware for
+ interprocessor communication involving DSP, IVA1.0 and IVA2 in
+ OMAP2/3; or IPU, IVA HD and DSP in OMAP4. Say Y here if you want
+ to use OMAP2+ Mailbox framework support.
+
+
+config OMAP_MBOX_KFIFO_SIZE
+ int "Mailbox kfifo default buffer size (bytes)"
+ depends on OMAP1_MBOX || OMAP2PLUS_MBOX
+ 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).
+
+endif
diff --git a/drivers/mailbox/Makefile b/drivers/mailbox/Makefile
new file mode 100644
index 0000000..4085b71
--- /dev/null
+++ b/drivers/mailbox/Makefile
@@ -0,0 +1,4 @@
+obj-$(CONFIG_MAILBOX) += mailbox.o
+
+obj-$(CONFIG_OMAP1_MBOX) += mailbox-omap1.o
+obj-$(CONFIG_OMAP2PLUS_MBOX) += mailbox-omap2.o
diff --git a/arch/arm/mach-omap1/mailbox.c b/drivers/mailbox/mailbox-omap1.c
similarity index 75%
rename from arch/arm/mach-omap1/mailbox.c
rename to drivers/mailbox/mailbox-omap1.c
index e962926..d681d4e 100644
--- a/arch/arm/mach-omap1/mailbox.c
+++ b/drivers/mailbox/mailbox-omap1.c
@@ -13,17 +13,18 @@
#include <linux/interrupt.h>
#include <linux/platform_device.h>
#include <linux/io.h>
-#include <plat/mailbox.h>
-
-#define MAILBOX_ARM2DSP1 0x00
-#define MAILBOX_ARM2DSP1b 0x04
-#define MAILBOX_DSP2ARM1 0x08
-#define MAILBOX_DSP2ARM1b 0x0c
-#define MAILBOX_DSP2ARM2 0x10
-#define MAILBOX_DSP2ARM2b 0x14
-#define MAILBOX_ARM2DSP1_Flag 0x18
-#define MAILBOX_DSP2ARM1_Flag 0x1c
-#define MAILBOX_DSP2ARM2_Flag 0x20
+
+#include "mailbox.h"
+
+#define MAILBOX_ARM2DSP1 0x00
+#define MAILBOX_ARM2DSP1b 0x04
+#define MAILBOX_DSP2ARM1 0x08
+#define MAILBOX_DSP2ARM1b 0x0c
+#define MAILBOX_DSP2ARM2 0x10
+#define MAILBOX_DSP2ARM2b 0x14
+#define MAILBOX_ARM2DSP1_Flag 0x18
+#define MAILBOX_DSP2ARM1_Flag 0x1c
+#define MAILBOX_DSP2ARM2_Flag 0x20
static void __iomem *mbox_base;
@@ -108,14 +109,14 @@ omap1_mbox_is_irq(struct omap_mbox *mbox, omap_mbox_type_t irq)
}
static struct omap_mbox_ops omap1_mbox_ops = {
- .type = OMAP_MBOX_TYPE1,
- .fifo_read = omap1_mbox_fifo_read,
- .fifo_write = omap1_mbox_fifo_write,
- .fifo_empty = omap1_mbox_fifo_empty,
- .fifo_full = omap1_mbox_fifo_full,
- .enable_irq = omap1_mbox_enable_irq,
- .disable_irq = omap1_mbox_disable_irq,
- .is_irq = omap1_mbox_is_irq,
+ .type = OMAP_MBOX_TYPE1,
+ .fifo_read = omap1_mbox_fifo_read,
+ .fifo_write = omap1_mbox_fifo_write,
+ .fifo_empty = omap1_mbox_fifo_empty,
+ .fifo_full = omap1_mbox_fifo_full,
+ .enable_irq = omap1_mbox_enable_irq,
+ .disable_irq = omap1_mbox_disable_irq,
+ .is_irq = omap1_mbox_is_irq,
};
/* FIXME: the following struct should be created automatically by the user id */
@@ -123,21 +124,21 @@ static struct omap_mbox_ops omap1_mbox_ops = {
/* DSP */
static struct omap_mbox1_priv omap1_mbox_dsp_priv = {
.tx_fifo = {
- .cmd = MAILBOX_ARM2DSP1b,
- .data = MAILBOX_ARM2DSP1,
- .flag = MAILBOX_ARM2DSP1_Flag,
+ .cmd = MAILBOX_ARM2DSP1b,
+ .data = MAILBOX_ARM2DSP1,
+ .flag = MAILBOX_ARM2DSP1_Flag,
},
.rx_fifo = {
- .cmd = MAILBOX_DSP2ARM1b,
- .data = MAILBOX_DSP2ARM1,
- .flag = MAILBOX_DSP2ARM1_Flag,
+ .cmd = MAILBOX_DSP2ARM1b,
+ .data = MAILBOX_DSP2ARM1,
+ .flag = MAILBOX_DSP2ARM1_Flag,
},
};
static struct omap_mbox mbox_dsp_info = {
- .name = "dsp",
- .ops = &omap1_mbox_ops,
- .priv = &omap1_mbox_dsp_priv,
+ .name = "dsp",
+ .ops = &omap1_mbox_ops,
+ .priv = &omap1_mbox_dsp_priv,
};
static struct omap_mbox *omap1_mboxes[] = { &mbox_dsp_info, NULL };
@@ -173,10 +174,10 @@ static int __devexit omap1_mbox_remove(struct platform_device *pdev)
}
static struct platform_driver omap1_mbox_driver = {
- .probe = omap1_mbox_probe,
- .remove = __devexit_p(omap1_mbox_remove),
- .driver = {
- .name = "omap-mailbox",
+ .probe = omap1_mbox_probe,
+ .remove = __devexit_p(omap1_mbox_remove),
+ .driver = {
+ .name = "omap-mailbox",
},
};
diff --git a/arch/arm/mach-omap2/mailbox.c b/drivers/mailbox/mailbox-omap2.c
similarity index 69%
rename from arch/arm/mach-omap2/mailbox.c
rename to drivers/mailbox/mailbox-omap2.c
index 0d97456..7dcffa8 100644
--- a/arch/arm/mach-omap2/mailbox.c
+++ b/drivers/mailbox/mailbox-omap2.c
@@ -17,30 +17,30 @@
#include <linux/io.h>
#include <linux/pm_runtime.h>
-#include <plat/mailbox.h>
+#include <plat/cpu.h>
-#include "soc.h"
+#include "mailbox.h"
-#define MAILBOX_REVISION 0x000
-#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))
+#define MAILBOX_REVISION 0x000
+#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))
-#define OMAP4_MAILBOX_IRQSTATUS(u) (0x104 + 0x10 * (u))
-#define OMAP4_MAILBOX_IRQENABLE(u) (0x108 + 0x10 * (u))
-#define OMAP4_MAILBOX_IRQENABLE_CLR(u) (0x10c + 0x10 * (u))
+#define OMAP4_MAILBOX_IRQSTATUS(u) (0x104 + 0x10 * (u))
+#define OMAP4_MAILBOX_IRQENABLE(u) (0x108 + 0x10 * (u))
+#define OMAP4_MAILBOX_IRQENABLE_CLR(u) (0x10c + 0x10 * (u))
-#define MAILBOX_IRQ_NEWMSG(m) (1 << (2 * (m)))
-#define MAILBOX_IRQ_NOTFULL(m) (1 << (2 * (m) + 1))
+#define MAILBOX_IRQ_NEWMSG(m) (1 << (2 * (m)))
+#define MAILBOX_IRQ_NOTFULL(m) (1 << (2 * (m) + 1))
-#define MBOX_REG_SIZE 0x120
+#define MBOX_REG_SIZE 0x120
-#define OMAP4_MBOX_REG_SIZE 0x130
+#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))
+#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;
@@ -62,7 +62,7 @@ struct omap_mbox2_priv {
};
static void omap2_mbox_enable_irq(struct omap_mbox *mbox,
- omap_mbox_type_t irq);
+ omap_mbox_type_t irq);
static inline unsigned int mbox_read_reg(size_t ofs)
{
@@ -183,7 +183,7 @@ static void omap2_mbox_save_ctx(struct omap_mbox *mbox)
p->ctx[i] = mbox_read_reg(i * sizeof(u32));
dev_dbg(mbox->dev, "%s: [%02x] %08x\n", __func__,
- i, p->ctx[i]);
+ i, p->ctx[i]);
}
}
@@ -200,24 +200,24 @@ static void omap2_mbox_restore_ctx(struct omap_mbox *mbox)
mbox_write_reg(p->ctx[i], i * sizeof(u32));
dev_dbg(mbox->dev, "%s: [%02x] %08x\n", __func__,
- i, p->ctx[i]);
+ i, p->ctx[i]);
}
}
static struct omap_mbox_ops omap2_mbox_ops = {
- .type = OMAP_MBOX_TYPE2,
- .startup = omap2_mbox_startup,
- .shutdown = omap2_mbox_shutdown,
- .fifo_read = omap2_mbox_fifo_read,
- .fifo_write = omap2_mbox_fifo_write,
- .fifo_empty = omap2_mbox_fifo_empty,
- .fifo_full = omap2_mbox_fifo_full,
- .enable_irq = omap2_mbox_enable_irq,
- .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,
+ .type = OMAP_MBOX_TYPE2,
+ .startup = omap2_mbox_startup,
+ .shutdown = omap2_mbox_shutdown,
+ .fifo_read = omap2_mbox_fifo_read,
+ .fifo_write = omap2_mbox_fifo_write,
+ .fifo_empty = omap2_mbox_fifo_empty,
+ .fifo_full = omap2_mbox_fifo_full,
+ .enable_irq = omap2_mbox_enable_irq,
+ .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,
};
/*
@@ -233,24 +233,24 @@ 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),
- .notfull_bit = MAILBOX_IRQ_NOTFULL(0),
- .newmsg_bit = MAILBOX_IRQ_NEWMSG(1),
- .irqdisable = MAILBOX_IRQENABLE(0),
+ .irqenable = MAILBOX_IRQENABLE(0),
+ .irqstatus = MAILBOX_IRQSTATUS(0),
+ .notfull_bit = MAILBOX_IRQ_NOTFULL(0),
+ .newmsg_bit = MAILBOX_IRQ_NEWMSG(1),
+ .irqdisable = MAILBOX_IRQENABLE(0),
};
struct omap_mbox mbox_dsp_info = {
- .name = "dsp",
- .ops = &omap2_mbox_ops,
- .priv = &omap2_mbox_dsp_priv,
+ .name = "dsp",
+ .ops = &omap2_mbox_ops,
+ .priv = &omap2_mbox_dsp_priv,
};
#endif
@@ -262,24 +262,24 @@ struct omap_mbox *omap3_mboxes[] = { &mbox_dsp_info, NULL };
/* 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),
- .notfull_bit = MAILBOX_IRQ_NOTFULL(2),
- .newmsg_bit = MAILBOX_IRQ_NEWMSG(3),
- .irqdisable = MAILBOX_IRQENABLE(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,
+ .name = "iva",
+ .ops = &omap2_mbox_ops,
+ .priv = &omap2_mbox_iva_priv,
};
#endif
@@ -297,46 +297,46 @@ struct omap_mbox *omap2_mboxes[] = {
/* OMAP4 */
static struct omap_mbox2_priv omap2_mbox_1_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 = 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),
+ .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,
+ .name = "mailbox-1",
+ .ops = &omap2_mbox_ops,
+ .priv = &omap2_mbox_1_priv,
};
static struct omap_mbox2_priv omap2_mbox_2_priv = {
.tx_fifo = {
- .msg = MAILBOX_MESSAGE(3),
- .fifo_stat = MAILBOX_FIFOSTATUS(3),
+ .msg = MAILBOX_MESSAGE(3),
+ .fifo_stat = MAILBOX_FIFOSTATUS(3),
},
.rx_fifo = {
- .msg = MAILBOX_MESSAGE(2),
- .msg_stat = MAILBOX_MSGSTATUS(2),
+ .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),
+ .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,
+ .name = "mailbox-2",
+ .ops = &omap2_mbox_ops,
+ .priv = &omap2_mbox_2_priv,
};
struct omap_mbox *omap4_mboxes[] = { &mbox_1_info, &mbox_2_info, NULL };
diff --git a/arch/arm/plat-omap/mailbox.c b/drivers/mailbox/mailbox.c
similarity index 97%
rename from arch/arm/plat-omap/mailbox.c
rename to drivers/mailbox/mailbox.c
index 42377ef..aec291d0 100644
--- a/arch/arm/plat-omap/mailbox.c
+++ b/drivers/mailbox/mailbox.c
@@ -31,7 +31,7 @@
#include <linux/notifier.h>
#include <linux/module.h>
-#include <plat/mailbox.h>
+#include "mailbox.h"
static struct omap_mbox **mboxes;
@@ -130,7 +130,7 @@ static void mbox_tx_tasklet(unsigned long tx_data)
}
ret = kfifo_out(&mq->fifo, (unsigned char *)&msg,
- sizeof(msg));
+ sizeof(msg));
WARN_ON(ret != sizeof(msg));
mbox_fifo_write(mbox, msg);
@@ -143,7 +143,7 @@ static void mbox_tx_tasklet(unsigned long tx_data)
static void mbox_rx_work(struct work_struct *work)
{
struct omap_mbox_queue *mq =
- container_of(work, struct omap_mbox_queue, work);
+ container_of(work, struct omap_mbox_queue, work);
mbox_msg_t msg;
int len;
@@ -152,7 +152,7 @@ static void mbox_rx_work(struct work_struct *work)
WARN_ON(len != sizeof(msg));
blocking_notifier_call_chain(&mq->mbox->notifier, len,
- (void *)msg);
+ (void *)msg);
spin_lock_irq(&mq->lock);
if (mq->full) {
mq->full = false;
@@ -214,8 +214,8 @@ static irqreturn_t mbox_interrupt(int irq, void *p)
}
static struct omap_mbox_queue *mbox_queue_alloc(struct omap_mbox *mbox,
- void (*work) (struct work_struct *),
- void (*tasklet)(unsigned long))
+ void (*work) (struct work_struct *),
+ void (*tasklet)(unsigned long))
{
struct omap_mbox_queue *mq;
@@ -262,10 +262,10 @@ static int omap_mbox_startup(struct omap_mbox *mbox)
if (!mbox->use_count++) {
ret = request_irq(mbox->irq, mbox_interrupt, IRQF_SHARED,
- mbox->name, mbox);
+ mbox->name, mbox);
if (unlikely(ret)) {
pr_err("failed to register mailbox interrupt:%d\n",
- ret);
+ ret);
goto fail_request_irq;
}
mq = mbox_queue_alloc(mbox, NULL, mbox_tx_tasklet);
@@ -417,7 +417,7 @@ static int __init omap_mbox_init(void)
/* kfifo size sanity check: alignment and minimal size */
mbox_kfifo_size = ALIGN(mbox_kfifo_size, sizeof(mbox_msg_t));
mbox_kfifo_size = max_t(unsigned int, mbox_kfifo_size,
- sizeof(mbox_msg_t));
+ sizeof(mbox_msg_t));
return 0;
}
diff --git a/arch/arm/plat-omap/include/plat/mailbox.h b/drivers/mailbox/mailbox.h
similarity index 57%
rename from arch/arm/plat-omap/include/plat/mailbox.h
rename to drivers/mailbox/mailbox.h
index cc3921e..88a9f6a 100644
--- a/arch/arm/plat-omap/include/plat/mailbox.h
+++ b/drivers/mailbox/mailbox.h
@@ -21,43 +21,43 @@ typedef int __bitwise omap_mbox_type_t;
#define OMAP_MBOX_TYPE2 ((__force omap_mbox_type_t) 2)
struct omap_mbox_ops {
- omap_mbox_type_t type;
- int (*startup)(struct omap_mbox *mbox);
- void (*shutdown)(struct omap_mbox *mbox);
+ omap_mbox_type_t type;
+ int (*startup)(struct omap_mbox *mbox);
+ void (*shutdown)(struct omap_mbox *mbox);
/* fifo */
- mbox_msg_t (*fifo_read)(struct omap_mbox *mbox);
- void (*fifo_write)(struct omap_mbox *mbox, mbox_msg_t msg);
- int (*fifo_empty)(struct omap_mbox *mbox);
- int (*fifo_full)(struct omap_mbox *mbox);
+ mbox_msg_t (*fifo_read)(struct omap_mbox *mbox);
+ void (*fifo_write)(struct omap_mbox *mbox, mbox_msg_t msg);
+ 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 (*ack_irq)(struct omap_mbox *mbox, omap_mbox_irq_t irq);
- int (*is_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 */
- void (*save_ctx)(struct omap_mbox *mbox);
- void (*restore_ctx)(struct omap_mbox *mbox);
+ void (*save_ctx)(struct omap_mbox *mbox);
+ void (*restore_ctx)(struct omap_mbox *mbox);
};
struct omap_mbox_queue {
- spinlock_t lock;
- struct kfifo fifo;
- struct work_struct work;
- struct tasklet_struct tasklet;
- struct omap_mbox *mbox;
+ spinlock_t lock;
+ struct kfifo fifo;
+ struct work_struct work;
+ struct tasklet_struct tasklet;
+ struct omap_mbox *mbox;
bool full;
};
struct omap_mbox {
- char *name;
- unsigned int irq;
- struct omap_mbox_queue *txq, *rxq;
- struct omap_mbox_ops *ops;
- struct device *dev;
- void *priv;
- int use_count;
+ char *name;
+ unsigned int irq;
+ struct omap_mbox_queue *txq, *rxq;
+ struct omap_mbox_ops *ops;
+ struct device *dev;
+ void *priv;
+ int use_count;
struct blocking_notifier_head notifier;
};
@@ -91,13 +91,13 @@ static inline void omap_mbox_restore_ctx(struct omap_mbox *mbox)
}
static inline void omap_mbox_enable_irq(struct omap_mbox *mbox,
- omap_mbox_irq_t irq)
+ 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)
+ omap_mbox_irq_t irq)
{
mbox->ops->disable_irq(mbox, irq);
}
--
1.7.11.1
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH 1/9] mailbox: OMAP: introduce mailbox framework
2012-12-18 13:10 ` [PATCH 1/9] mailbox: OMAP: introduce mailbox framework Loic Pallardy
@ 2012-12-18 16:59 ` Tony Lindgren
2012-12-21 8:54 ` Loic PALLARDY
0 siblings, 1 reply; 31+ messages in thread
From: Tony Lindgren @ 2012-12-18 16:59 UTC (permalink / raw)
To: linux-arm-kernel
* Loic Pallardy <loic.pallardy-ext@stericsson.com> [121218 05:15]:
> Actually moving it from plat-omap, as this framework/driver code is
> supposed to be under drivers/ folder. The framework should work with
> the current supported OMAP processors (OMAP1+) that have mailbox and
> can be used as a method of interprocessor communication.
>
> The mailbox hardware (in OMAP) uses a queued mailbox-interrupt mechanism
> that provides a communication channel between processors through a set of
> registers and their associated interrupt signals by sending and receiving
> messages.
>
> As part of the migration from plat and mach code:
> - Kconfig symbols have been renamed to build OMAP1 or OMAP2+ drivers.
> - mailbox.h has been changed from plat to a dedicated drivers/ folder.
> - soc.h has been changed for plat/cpu.h, since there are dependencies in
> the cpu_is_XXXX() macro.
>
> Module names have changed too, instead of mailbox_mach:
> - OMAP1: mailbox-omap1.ko
> - OMAP2+: mailbox-omap2.ko
>
> Signed-off-by: Omar Ramirez Luna <omar.luna@linaro.org>
AFAIK the first two patches should have:
From: Omar Ramirez Luna <omar.luna@linaro.org>
Once that's fixed, for arch/arm/*omap*/* parts:
Acked-by: Tony Lindgren <tony@atomide.com>
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH 1/9] mailbox: OMAP: introduce mailbox framework
2012-12-18 16:59 ` Tony Lindgren
@ 2012-12-21 8:54 ` Loic PALLARDY
2012-12-21 10:49 ` Bedia, Vaibhav
0 siblings, 1 reply; 31+ messages in thread
From: Loic PALLARDY @ 2012-12-21 8:54 UTC (permalink / raw)
To: linux-arm-kernel
On 12/18/2012 05:59 PM, Tony Lindgren wrote:
> * Loic Pallardy<loic.pallardy-ext@stericsson.com> [121218 05:15]:
>>
>> Signed-off-by: Omar Ramirez Luna<omar.luna@linaro.org>
>
> AFAIK the first two patches should have:
> From: Omar Ramirez Luna<omar.luna@linaro.org>
Yes right, my mistake.
I'll fix that on next version.
/Loic
>
> Once that's fixed, for arch/arm/*omap*/* parts:
>
> Acked-by: Tony Lindgren<tony@atomide.com>
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH 1/9] mailbox: OMAP: introduce mailbox framework
2012-12-21 8:54 ` Loic PALLARDY
@ 2012-12-21 10:49 ` Bedia, Vaibhav
2012-12-21 10:53 ` Loic PALLARDY
0 siblings, 1 reply; 31+ messages in thread
From: Bedia, Vaibhav @ 2012-12-21 10:49 UTC (permalink / raw)
To: linux-arm-kernel
On Fri, Dec 21, 2012 at 14:24:26, Loic PALLARDY wrote:
>
>
> On 12/18/2012 05:59 PM, Tony Lindgren wrote:
> > * Loic Pallardy<loic.pallardy-ext@stericsson.com> [121218 05:15]:
> >>
> >> Signed-off-by: Omar Ramirez Luna<omar.luna@linaro.org>
> >
> > AFAIK the first two patches should have:
> > From: Omar Ramirez Luna<omar.luna@linaro.org>
> Yes right, my mistake.
> I'll fix that on next version.
> /Loic
I have a few patches which are dependent on this patch series.
Could you please keep me in cc for the future versions.
Thanks,
Vaibhav
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH 1/9] mailbox: OMAP: introduce mailbox framework
2012-12-21 10:49 ` Bedia, Vaibhav
@ 2012-12-21 10:53 ` Loic PALLARDY
2013-01-09 12:11 ` Bedia, Vaibhav
0 siblings, 1 reply; 31+ messages in thread
From: Loic PALLARDY @ 2012-12-21 10:53 UTC (permalink / raw)
To: linux-arm-kernel
On 12/21/2012 11:49 AM, Bedia, Vaibhav wrote:
> On Fri, Dec 21, 2012 at 14:24:26, Loic PALLARDY wrote:
>>
> I have a few patches which are dependent on this patch series.
> Could you please keep me in cc for the future versions.
>
Sure, I'll.
/Loic
> Thanks,
> Vaibhav
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH 1/9] mailbox: OMAP: introduce mailbox framework
2012-12-21 10:53 ` Loic PALLARDY
@ 2013-01-09 12:11 ` Bedia, Vaibhav
2013-01-09 12:29 ` Loic PALLARDY
0 siblings, 1 reply; 31+ messages in thread
From: Bedia, Vaibhav @ 2013-01-09 12:11 UTC (permalink / raw)
To: linux-arm-kernel
Hi Loic,
On Fri, Dec 21, 2012 at 16:23:24, Loic PALLARDY wrote:
>
>
> On 12/21/2012 11:49 AM, Bedia, Vaibhav wrote:
> > On Fri, Dec 21, 2012 at 14:24:26, Loic PALLARDY wrote:
> >>
> > I have a few patches which are dependent on this patch series.
> > Could you please keep me in cc for the future versions.
> >
> Sure, I'll.
>
When do you plan to post an updated version of these patches?
Regards,
Vaibhav
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH 1/9] mailbox: OMAP: introduce mailbox framework
2013-01-09 12:11 ` Bedia, Vaibhav
@ 2013-01-09 12:29 ` Loic PALLARDY
2013-01-09 12:34 ` Bedia, Vaibhav
2013-01-11 13:34 ` Omar Ramirez Luna
0 siblings, 2 replies; 31+ messages in thread
From: Loic PALLARDY @ 2013-01-09 12:29 UTC (permalink / raw)
To: linux-arm-kernel
Hi Vaibhav,
On 01/09/2013 01:11 PM, Bedia, Vaibhav wrote:
> Hi Loic,
>
> On Fri, Dec 21, 2012 at 16:23:24, Loic PALLARDY wrote:
>>
>>
>> On 12/21/2012 11:49 AM, Bedia, Vaibhav wrote:
>>> On Fri, Dec 21, 2012 at 14:24:26, Loic PALLARDY wrote:
>>>>
>>> I have a few patches which are dependent on this patch series.
>>> Could you please keep me in cc for the future versions.
>>>
>> Sure, I'll.
>>
>
> When do you plan to post an updated version of these patches?
I'm synchronizing with Omar to include TI RPMsg and tidspbridge patches
in next update.
So I plan update for end of the week, beginning of next week.
Regards,
Loic
>
> Regards,
> Vaibhav
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH 1/9] mailbox: OMAP: introduce mailbox framework
2013-01-09 12:29 ` Loic PALLARDY
@ 2013-01-09 12:34 ` Bedia, Vaibhav
2013-01-11 13:34 ` Omar Ramirez Luna
1 sibling, 0 replies; 31+ messages in thread
From: Bedia, Vaibhav @ 2013-01-09 12:34 UTC (permalink / raw)
To: linux-arm-kernel
On Wed, Jan 09, 2013 at 17:59:39, Loic PALLARDY wrote:
> Hi Vaibhav,
>
> On 01/09/2013 01:11 PM, Bedia, Vaibhav wrote:
> > Hi Loic,
> >
> > On Fri, Dec 21, 2012 at 16:23:24, Loic PALLARDY wrote:
> >>
> >>
> >> On 12/21/2012 11:49 AM, Bedia, Vaibhav wrote:
> >>> On Fri, Dec 21, 2012 at 14:24:26, Loic PALLARDY wrote:
> >>>>
> >>> I have a few patches which are dependent on this patch series.
> >>> Could you please keep me in cc for the future versions.
> >>>
> >> Sure, I'll.
> >>
> >
> > When do you plan to post an updated version of these patches?
> I'm synchronizing with Omar to include TI RPMsg and tidspbridge patches
> in next update.
> So I plan update for end of the week, beginning of next week.
>
Ok. Thanks.
Regards,
Vaibhav
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH 1/9] mailbox: OMAP: introduce mailbox framework
2013-01-09 12:29 ` Loic PALLARDY
2013-01-09 12:34 ` Bedia, Vaibhav
@ 2013-01-11 13:34 ` Omar Ramirez Luna
1 sibling, 0 replies; 31+ messages in thread
From: Omar Ramirez Luna @ 2013-01-11 13:34 UTC (permalink / raw)
To: linux-arm-kernel
On Wed, Jan 9, 2013 at 6:29 AM, Loic PALLARDY <loic.pallardy@st.com> wrote:
> Hi Vaibhav,
>
> On 01/09/2013 01:11 PM, Bedia, Vaibhav wrote:
>> Hi Loic,
>>
>> On Fri, Dec 21, 2012 at 16:23:24, Loic PALLARDY wrote:
>>>
>>>
>>> On 12/21/2012 11:49 AM, Bedia, Vaibhav wrote:
>>>> On Fri, Dec 21, 2012 at 14:24:26, Loic PALLARDY wrote:
>>>>>
>>>> I have a few patches which are dependent on this patch series.
>>>> Could you please keep me in cc for the future versions.
>>>>
>>> Sure, I'll.
>>>
>>
>> When do you plan to post an updated version of these patches?
> I'm synchronizing with Omar to include TI RPMsg and tidspbridge patches
> in next update.
> So I plan update for end of the week, beginning of next week.
Here are my patches, I didn't post them to the list since they are
meant to be squashed, I also prepared a squashed version of the
original set, in case it is easier to take that one, all rebased into
3.8-rc1. Branches: mailbox-3.8-rc1-separate-changes and
mailbox-3.8-rc1, respectively.
>From tree: https://github.com/omarrmz/upstream-wip
Cheers,
Omar
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH 2/9] mailbox: split internal header from API header
2012-12-18 13:10 [PATCH 0/9] drivers: mailbox: framework creation Loic Pallardy
2012-12-18 13:10 ` [PATCH 1/9] mailbox: OMAP: introduce mailbox framework Loic Pallardy
@ 2012-12-18 13:10 ` Loic Pallardy
2012-12-18 13:10 ` [PATCH 3/9] mailbox: rename omap_mbox in mailbox Loic Pallardy
` (7 subsequent siblings)
9 siblings, 0 replies; 31+ messages in thread
From: Loic Pallardy @ 2012-12-18 13:10 UTC (permalink / raw)
To: linux-arm-kernel
Now internal structures can remain hidden to the user and just API
related functions and defines are made available.
Signed-off-by: Omar Ramirez Luna <omar.luna@linaro.org>
---
drivers/mailbox/mailbox.c | 34 ++++++++++++++++++++++++++++++++++
drivers/mailbox/mailbox.h | 44 +-------------------------------------------
include/linux/mailbox.h | 18 ++++++++++++++++++
3 files changed, 53 insertions(+), 43 deletions(-)
create mode 100644 include/linux/mailbox.h
diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c
index aec291d0..8cb3b15 100644
--- a/drivers/mailbox/mailbox.c
+++ b/drivers/mailbox/mailbox.c
@@ -116,6 +116,40 @@ out:
}
EXPORT_SYMBOL(omap_mbox_msg_send);
+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);
+}
+EXPORT_SYMBOL(omap_mbox_save_ctx);
+
+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);
+}
+EXPORT_SYMBOL(omap_mbox_restore_ctx);
+
+void omap_mbox_enable_irq(struct omap_mbox *mbox, omap_mbox_irq_t irq)
+{
+ mbox->ops->enable_irq(mbox, irq);
+}
+EXPORT_SYMBOL(omap_mbox_enable_irq);
+
+void omap_mbox_disable_irq(struct omap_mbox *mbox, omap_mbox_irq_t irq)
+{
+ mbox->ops->disable_irq(mbox, irq);
+}
+EXPORT_SYMBOL(omap_mbox_disable_irq);
+
static void mbox_tx_tasklet(unsigned long tx_data)
{
struct omap_mbox *mbox = (struct omap_mbox *)tx_data;
diff --git a/drivers/mailbox/mailbox.h b/drivers/mailbox/mailbox.h
index 88a9f6a..bf3c1b4 100644
--- a/drivers/mailbox/mailbox.h
+++ b/drivers/mailbox/mailbox.h
@@ -8,13 +8,7 @@
#include <linux/interrupt.h>
#include <linux/device.h>
#include <linux/kfifo.h>
-
-typedef u32 mbox_msg_t;
-struct omap_mbox;
-
-typedef int __bitwise omap_mbox_irq_t;
-#define IRQ_TX ((__force omap_mbox_irq_t) 1)
-#define IRQ_RX ((__force omap_mbox_irq_t) 2)
+#include <linux/mailbox.h>
typedef int __bitwise omap_mbox_type_t;
#define OMAP_MBOX_TYPE1 ((__force omap_mbox_type_t) 1)
@@ -61,45 +55,9 @@ struct omap_mbox {
struct blocking_notifier_head notifier;
};
-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 *, struct notifier_block *nb);
-void omap_mbox_put(struct omap_mbox *mbox, struct notifier_block *nb);
-
int omap_mbox_register(struct device *parent, struct omap_mbox **);
int omap_mbox_unregister(void);
-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);
-}
-
-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 */
diff --git a/include/linux/mailbox.h b/include/linux/mailbox.h
new file mode 100644
index 0000000..78ef848
--- /dev/null
+++ b/include/linux/mailbox.h
@@ -0,0 +1,18 @@
+/* mailbox.h */
+
+typedef u32 mbox_msg_t;
+struct omap_mbox;
+
+typedef int __bitwise omap_mbox_irq_t;
+#define IRQ_TX ((__force omap_mbox_irq_t) 1)
+#define IRQ_RX ((__force omap_mbox_irq_t) 2)
+
+int omap_mbox_msg_send(struct omap_mbox *, mbox_msg_t msg);
+
+struct omap_mbox *omap_mbox_get(const char *, struct notifier_block *nb);
+void omap_mbox_put(struct omap_mbox *mbox, struct notifier_block *nb);
+
+void omap_mbox_save_ctx(struct omap_mbox *mbox);
+void omap_mbox_restore_ctx(struct omap_mbox *mbox);
+void omap_mbox_enable_irq(struct omap_mbox *mbox, omap_mbox_irq_t irq);
+void omap_mbox_disable_irq(struct omap_mbox *mbox, omap_mbox_irq_t irq);
--
1.7.11.1
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH 3/9] mailbox: rename omap_mbox in mailbox
2012-12-18 13:10 [PATCH 0/9] drivers: mailbox: framework creation Loic Pallardy
2012-12-18 13:10 ` [PATCH 1/9] mailbox: OMAP: introduce mailbox framework Loic Pallardy
2012-12-18 13:10 ` [PATCH 2/9] mailbox: split internal header from API header Loic Pallardy
@ 2012-12-18 13:10 ` Loic Pallardy
2012-12-20 21:29 ` Ohad Ben-Cohen
2012-12-18 13:10 ` [PATCH 4/9] mailbox: create opened message type Loic Pallardy
` (6 subsequent siblings)
9 siblings, 1 reply; 31+ messages in thread
From: Loic Pallardy @ 2012-12-18 13:10 UTC (permalink / raw)
To: linux-arm-kernel
In order to create a generic mailbox framework, functions
and structures should be renamed in mailbox.
Signed-off-by: Loic Pallardy <loic.pallardy@st.com>
---
drivers/mailbox/Kconfig | 3 +-
drivers/mailbox/mailbox-omap1.c | 28 ++++-----
drivers/mailbox/mailbox-omap2.c | 60 +++++++++---------
drivers/mailbox/mailbox.c | 133 ++++++++++++++++++++--------------------
drivers/mailbox/mailbox.h | 56 ++++++++---------
include/linux/mailbox.h | 22 +++----
6 files changed, 151 insertions(+), 151 deletions(-)
diff --git a/drivers/mailbox/Kconfig b/drivers/mailbox/Kconfig
index e98ca6c..d1e7d74 100644
--- a/drivers/mailbox/Kconfig
+++ b/drivers/mailbox/Kconfig
@@ -25,9 +25,8 @@ config OMAP2PLUS_MBOX
to use OMAP2+ Mailbox framework support.
-config OMAP_MBOX_KFIFO_SIZE
+config MBOX_KFIFO_SIZE
int "Mailbox kfifo default buffer size (bytes)"
- depends on OMAP1_MBOX || OMAP2PLUS_MBOX
default 256
help
Specify the default size of mailbox's kfifo buffers (bytes).
diff --git a/drivers/mailbox/mailbox-omap1.c b/drivers/mailbox/mailbox-omap1.c
index d681d4e..31cb70a 100644
--- a/drivers/mailbox/mailbox-omap1.c
+++ b/drivers/mailbox/mailbox-omap1.c
@@ -50,7 +50,7 @@ static inline void mbox_write_reg(u32 val, size_t ofs)
}
/* msg */
-static mbox_msg_t omap1_mbox_fifo_read(struct omap_mbox *mbox)
+static mbox_msg_t omap1_mbox_fifo_read(struct mailbox *mbox)
{
struct omap_mbox1_fifo *fifo =
&((struct omap_mbox1_priv *)mbox->priv)->rx_fifo;
@@ -63,7 +63,7 @@ static mbox_msg_t omap1_mbox_fifo_read(struct omap_mbox *mbox)
}
static void
-omap1_mbox_fifo_write(struct omap_mbox *mbox, mbox_msg_t msg)
+omap1_mbox_fifo_write(struct mailbox *mbox, mbox_msg_t msg)
{
struct omap_mbox1_fifo *fifo =
&((struct omap_mbox1_priv *)mbox->priv)->tx_fifo;
@@ -72,12 +72,12 @@ omap1_mbox_fifo_write(struct omap_mbox *mbox, mbox_msg_t msg)
mbox_write_reg(msg >> 16, fifo->cmd);
}
-static int omap1_mbox_fifo_empty(struct omap_mbox *mbox)
+static int omap1_mbox_fifo_empty(struct mailbox *mbox)
{
return 0;
}
-static int omap1_mbox_fifo_full(struct omap_mbox *mbox)
+static int omap1_mbox_fifo_full(struct mailbox *mbox)
{
struct omap_mbox1_fifo *fifo =
&((struct omap_mbox1_priv *)mbox->priv)->rx_fifo;
@@ -87,29 +87,29 @@ static int omap1_mbox_fifo_full(struct omap_mbox *mbox)
/* irq */
static void
-omap1_mbox_enable_irq(struct omap_mbox *mbox, omap_mbox_type_t irq)
+omap1_mbox_enable_irq(struct mailbox *mbox, mailbox_type_t irq)
{
if (irq == IRQ_RX)
enable_irq(mbox->irq);
}
static void
-omap1_mbox_disable_irq(struct omap_mbox *mbox, omap_mbox_type_t irq)
+omap1_mbox_disable_irq(struct mailbox *mbox, mailbox_type_t irq)
{
if (irq == IRQ_RX)
disable_irq(mbox->irq);
}
static int
-omap1_mbox_is_irq(struct omap_mbox *mbox, omap_mbox_type_t irq)
+omap1_mbox_is_irq(struct mailbox *mbox, mailbox_type_t irq)
{
if (irq == IRQ_TX)
return 0;
return 1;
}
-static struct omap_mbox_ops omap1_mbox_ops = {
- .type = OMAP_MBOX_TYPE1,
+static struct mailbox_ops omap1_mbox_ops = {
+ .type = MBOX_HW_FIFO1_TYPE,
.fifo_read = omap1_mbox_fifo_read,
.fifo_write = omap1_mbox_fifo_write,
.fifo_empty = omap1_mbox_fifo_empty,
@@ -135,19 +135,19 @@ static struct omap_mbox1_priv omap1_mbox_dsp_priv = {
},
};
-static struct omap_mbox mbox_dsp_info = {
+static struct mailbox mbox_dsp_info = {
.name = "dsp",
.ops = &omap1_mbox_ops,
.priv = &omap1_mbox_dsp_priv,
};
-static struct omap_mbox *omap1_mboxes[] = { &mbox_dsp_info, NULL };
+static struct mailbox *omap1_mboxes[] = { &mbox_dsp_info, NULL };
static int __devinit omap1_mbox_probe(struct platform_device *pdev)
{
struct resource *mem;
int ret;
- struct omap_mbox **list;
+ struct mailbox **list;
list = omap1_mboxes;
list[0]->irq = platform_get_irq_byname(pdev, "dsp");
@@ -157,7 +157,7 @@ static int __devinit omap1_mbox_probe(struct platform_device *pdev)
if (!mbox_base)
return -ENOMEM;
- ret = omap_mbox_register(&pdev->dev, list);
+ ret = mailbox_register(&pdev->dev, list);
if (ret) {
iounmap(mbox_base);
return ret;
@@ -168,7 +168,7 @@ static int __devinit omap1_mbox_probe(struct platform_device *pdev)
static int __devexit omap1_mbox_remove(struct platform_device *pdev)
{
- omap_mbox_unregister();
+ mailbox_unregister();
iounmap(mbox_base);
return 0;
}
diff --git a/drivers/mailbox/mailbox-omap2.c b/drivers/mailbox/mailbox-omap2.c
index 7dcffa8..230d9d3 100644
--- a/drivers/mailbox/mailbox-omap2.c
+++ b/drivers/mailbox/mailbox-omap2.c
@@ -61,8 +61,8 @@ struct omap_mbox2_priv {
unsigned long irqdisable;
};
-static void omap2_mbox_enable_irq(struct omap_mbox *mbox,
- omap_mbox_type_t irq);
+static void omap2_mbox_enable_irq(struct mailbox *mbox,
+ mailbox_type_t irq);
static inline unsigned int mbox_read_reg(size_t ofs)
{
@@ -75,7 +75,7 @@ static inline void mbox_write_reg(u32 val, size_t ofs)
}
/* Mailbox H/W preparations */
-static int omap2_mbox_startup(struct omap_mbox *mbox)
+static int omap2_mbox_startup(struct mailbox *mbox)
{
u32 l;
@@ -88,35 +88,35 @@ static int omap2_mbox_startup(struct omap_mbox *mbox)
return 0;
}
-static void omap2_mbox_shutdown(struct omap_mbox *mbox)
+static void omap2_mbox_shutdown(struct mailbox *mbox)
{
pm_runtime_put_sync(mbox->dev->parent);
pm_runtime_disable(mbox->dev->parent);
}
/* Mailbox FIFO handle functions */
-static mbox_msg_t omap2_mbox_fifo_read(struct omap_mbox *mbox)
+static mbox_msg_t omap2_mbox_fifo_read(struct mailbox *mbox)
{
struct omap_mbox2_fifo *fifo =
&((struct omap_mbox2_priv *)mbox->priv)->rx_fifo;
return (mbox_msg_t) mbox_read_reg(fifo->msg);
}
-static void omap2_mbox_fifo_write(struct omap_mbox *mbox, mbox_msg_t msg)
+static void omap2_mbox_fifo_write(struct mailbox *mbox, mbox_msg_t msg)
{
struct omap_mbox2_fifo *fifo =
&((struct omap_mbox2_priv *)mbox->priv)->tx_fifo;
mbox_write_reg(msg, fifo->msg);
}
-static int omap2_mbox_fifo_empty(struct omap_mbox *mbox)
+static int omap2_mbox_fifo_empty(struct mailbox *mbox)
{
struct omap_mbox2_fifo *fifo =
&((struct omap_mbox2_priv *)mbox->priv)->rx_fifo;
return (mbox_read_reg(fifo->msg_stat) == 0);
}
-static int omap2_mbox_fifo_full(struct omap_mbox *mbox)
+static int omap2_mbox_fifo_full(struct mailbox *mbox)
{
struct omap_mbox2_fifo *fifo =
&((struct omap_mbox2_priv *)mbox->priv)->tx_fifo;
@@ -124,8 +124,8 @@ static int omap2_mbox_fifo_full(struct omap_mbox *mbox)
}
/* Mailbox IRQ handle functions */
-static void omap2_mbox_enable_irq(struct omap_mbox *mbox,
- omap_mbox_type_t irq)
+static void omap2_mbox_enable_irq(struct mailbox *mbox,
+ mailbox_type_t irq)
{
struct omap_mbox2_priv *p = mbox->priv;
u32 l, bit = (irq == IRQ_TX) ? p->notfull_bit : p->newmsg_bit;
@@ -135,8 +135,8 @@ static void omap2_mbox_enable_irq(struct omap_mbox *mbox,
mbox_write_reg(l, p->irqenable);
}
-static void omap2_mbox_disable_irq(struct omap_mbox *mbox,
- omap_mbox_type_t irq)
+static void omap2_mbox_disable_irq(struct mailbox *mbox,
+ mailbox_type_t irq)
{
struct omap_mbox2_priv *p = mbox->priv;
u32 bit = (irq == IRQ_TX) ? p->notfull_bit : p->newmsg_bit;
@@ -147,8 +147,8 @@ static void omap2_mbox_disable_irq(struct omap_mbox *mbox,
mbox_write_reg(bit, p->irqdisable);
}
-static void omap2_mbox_ack_irq(struct omap_mbox *mbox,
- omap_mbox_type_t irq)
+static void omap2_mbox_ack_irq(struct mailbox *mbox,
+ mailbox_type_t irq)
{
struct omap_mbox2_priv *p = mbox->priv;
u32 bit = (irq == IRQ_TX) ? p->notfull_bit : p->newmsg_bit;
@@ -159,8 +159,8 @@ static void omap2_mbox_ack_irq(struct omap_mbox *mbox,
mbox_read_reg(p->irqstatus);
}
-static int omap2_mbox_is_irq(struct omap_mbox *mbox,
- omap_mbox_type_t irq)
+static int omap2_mbox_is_irq(struct mailbox *mbox,
+ mailbox_type_t irq)
{
struct omap_mbox2_priv *p = mbox->priv;
u32 bit = (irq == IRQ_TX) ? p->notfull_bit : p->newmsg_bit;
@@ -170,7 +170,7 @@ static int omap2_mbox_is_irq(struct omap_mbox *mbox,
return (int)(enable & status & bit);
}
-static void omap2_mbox_save_ctx(struct omap_mbox *mbox)
+static void omap2_mbox_save_ctx(struct mailbox *mbox)
{
int i;
struct omap_mbox2_priv *p = mbox->priv;
@@ -187,7 +187,7 @@ static void omap2_mbox_save_ctx(struct omap_mbox *mbox)
}
}
-static void omap2_mbox_restore_ctx(struct omap_mbox *mbox)
+static void omap2_mbox_restore_ctx(struct mailbox *mbox)
{
int i;
struct omap_mbox2_priv *p = mbox->priv;
@@ -204,8 +204,8 @@ static void omap2_mbox_restore_ctx(struct omap_mbox *mbox)
}
}
-static struct omap_mbox_ops omap2_mbox_ops = {
- .type = OMAP_MBOX_TYPE2,
+static struct mailbox_ops omap2_mbox_ops = {
+ .type = MBOX_HW_FIFO2_TYPE,
.startup = omap2_mbox_startup,
.shutdown = omap2_mbox_shutdown,
.fifo_read = omap2_mbox_fifo_read,
@@ -247,7 +247,7 @@ static struct omap_mbox2_priv omap2_mbox_dsp_priv = {
.irqdisable = MAILBOX_IRQENABLE(0),
};
-struct omap_mbox mbox_dsp_info = {
+struct mailbox mbox_dsp_info = {
.name = "dsp",
.ops = &omap2_mbox_ops,
.priv = &omap2_mbox_dsp_priv,
@@ -255,7 +255,7 @@ struct omap_mbox mbox_dsp_info = {
#endif
#if defined(CONFIG_ARCH_OMAP3)
-struct omap_mbox *omap3_mboxes[] = { &mbox_dsp_info, NULL };
+struct mailbox *omap3_mboxes[] = { &mbox_dsp_info, NULL };
#endif
#if defined(CONFIG_SOC_OMAP2420)
@@ -276,7 +276,7 @@ static struct omap_mbox2_priv omap2_mbox_iva_priv = {
.irqdisable = MAILBOX_IRQENABLE(3),
};
-static struct omap_mbox mbox_iva_info = {
+static struct mailbox mbox_iva_info = {
.name = "iva",
.ops = &omap2_mbox_ops,
.priv = &omap2_mbox_iva_priv,
@@ -284,7 +284,7 @@ static struct omap_mbox mbox_iva_info = {
#endif
#ifdef CONFIG_ARCH_OMAP2
-struct omap_mbox *omap2_mboxes[] = {
+struct mailbox *omap2_mboxes[] = {
&mbox_dsp_info,
#ifdef CONFIG_SOC_OMAP2420
&mbox_iva_info,
@@ -311,7 +311,7 @@ static struct omap_mbox2_priv omap2_mbox_1_priv = {
.irqdisable = OMAP4_MAILBOX_IRQENABLE_CLR(0),
};
-struct omap_mbox mbox_1_info = {
+struct mailbox mbox_1_info = {
.name = "mailbox-1",
.ops = &omap2_mbox_ops,
.priv = &omap2_mbox_1_priv,
@@ -333,20 +333,20 @@ static struct omap_mbox2_priv omap2_mbox_2_priv = {
.irqdisable = OMAP4_MAILBOX_IRQENABLE_CLR(0),
};
-struct omap_mbox mbox_2_info = {
+struct mailbox mbox_2_info = {
.name = "mailbox-2",
.ops = &omap2_mbox_ops,
.priv = &omap2_mbox_2_priv,
};
-struct omap_mbox *omap4_mboxes[] = { &mbox_1_info, &mbox_2_info, NULL };
+struct mailbox *omap4_mboxes[] = { &mbox_1_info, &mbox_2_info, NULL };
#endif
static int __devinit omap2_mbox_probe(struct platform_device *pdev)
{
struct resource *mem;
int ret;
- struct omap_mbox **list;
+ struct mailbox **list;
if (false)
;
@@ -386,7 +386,7 @@ static int __devinit omap2_mbox_probe(struct platform_device *pdev)
if (!mbox_base)
return -ENOMEM;
- ret = omap_mbox_register(&pdev->dev, list);
+ ret = mailbox_register(&pdev->dev, list);
if (ret) {
iounmap(mbox_base);
return ret;
@@ -397,7 +397,7 @@ static int __devinit omap2_mbox_probe(struct platform_device *pdev)
static int __devexit omap2_mbox_remove(struct platform_device *pdev)
{
- omap_mbox_unregister();
+ mailbox_unregister();
iounmap(mbox_base);
return 0;
}
diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c
index 8cb3b15..b9389c6 100644
--- a/drivers/mailbox/mailbox.c
+++ b/drivers/mailbox/mailbox.c
@@ -1,9 +1,10 @@
/*
- * OMAP mailbox driver
+ * Mailbox framework
*
* Copyright (C) 2006-2009 Nokia Corporation. All rights reserved.
*
* Contact: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
+ * Author: Loic Pallardy <loic.pallardy@st.com> for ST-Ericsson
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -33,40 +34,40 @@
#include "mailbox.h"
-static struct omap_mbox **mboxes;
+static struct mailbox **mboxes;
static int mbox_configured;
static DEFINE_MUTEX(mbox_configured_lock);
-static unsigned int mbox_kfifo_size = CONFIG_OMAP_MBOX_KFIFO_SIZE;
+static unsigned int mbox_kfifo_size = CONFIG_MBOX_KFIFO_SIZE;
module_param(mbox_kfifo_size, uint, S_IRUGO);
-MODULE_PARM_DESC(mbox_kfifo_size, "Size of omap's mailbox kfifo (bytes)");
+MODULE_PARM_DESC(mbox_kfifo_size, "Size of mailbox kfifo (bytes)");
/* Mailbox FIFO handle functions */
-static inline mbox_msg_t mbox_fifo_read(struct omap_mbox *mbox)
+static inline mbox_msg_t mbox_fifo_read(struct mailbox *mbox)
{
return mbox->ops->fifo_read(mbox);
}
-static inline void mbox_fifo_write(struct omap_mbox *mbox, mbox_msg_t msg)
+static inline void mbox_fifo_write(struct mailbox *mbox, mbox_msg_t msg)
{
mbox->ops->fifo_write(mbox, msg);
}
-static inline int mbox_fifo_empty(struct omap_mbox *mbox)
+static inline int mbox_fifo_empty(struct mailbox *mbox)
{
return mbox->ops->fifo_empty(mbox);
}
-static inline int mbox_fifo_full(struct omap_mbox *mbox)
+static inline int mbox_fifo_full(struct mailbox *mbox)
{
return mbox->ops->fifo_full(mbox);
}
/* Mailbox IRQ handle functions */
-static inline void ack_mbox_irq(struct omap_mbox *mbox, omap_mbox_irq_t irq)
+static inline void ack_mbox_irq(struct mailbox *mbox, mailbox_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)
+static inline int is_mbox_irq(struct mailbox *mbox, mailbox_irq_t irq)
{
return mbox->ops->is_irq(mbox, irq);
}
@@ -74,12 +75,12 @@ static inline int is_mbox_irq(struct omap_mbox *mbox, omap_mbox_irq_t irq)
/*
* message sender
*/
-static int __mbox_poll_for_space(struct omap_mbox *mbox)
+static int __mbox_poll_for_space(struct mailbox *mbox)
{
int ret = 0, i = 1000;
while (mbox_fifo_full(mbox)) {
- if (mbox->ops->type == OMAP_MBOX_TYPE2)
+ if (mbox->ops->type == MBOX_HW_FIFO2_TYPE)
return -1;
if (--i == 0)
return -1;
@@ -88,9 +89,9 @@ static int __mbox_poll_for_space(struct omap_mbox *mbox)
return ret;
}
-int omap_mbox_msg_send(struct omap_mbox *mbox, mbox_msg_t msg)
+int mailbox_msg_send(struct mailbox *mbox, mbox_msg_t msg)
{
- struct omap_mbox_queue *mq = mbox->txq;
+ struct mailbox_queue *mq = mbox->txq;
int ret = 0, len;
spin_lock_bh(&mq->lock);
@@ -114,9 +115,9 @@ out:
spin_unlock_bh(&mq->lock);
return ret;
}
-EXPORT_SYMBOL(omap_mbox_msg_send);
+EXPORT_SYMBOL(mailbox_msg_send);
-void omap_mbox_save_ctx(struct omap_mbox *mbox)
+void mailbox_save_ctx(struct mailbox *mbox)
{
if (!mbox->ops->save_ctx) {
dev_err(mbox->dev, "%s:\tno save\n", __func__);
@@ -125,9 +126,9 @@ void omap_mbox_save_ctx(struct omap_mbox *mbox)
mbox->ops->save_ctx(mbox);
}
-EXPORT_SYMBOL(omap_mbox_save_ctx);
+EXPORT_SYMBOL(mailbox_save_ctx);
-void omap_mbox_restore_ctx(struct omap_mbox *mbox)
+void mailbox_restore_ctx(struct mailbox *mbox)
{
if (!mbox->ops->restore_ctx) {
dev_err(mbox->dev, "%s:\tno restore\n", __func__);
@@ -136,30 +137,30 @@ void omap_mbox_restore_ctx(struct omap_mbox *mbox)
mbox->ops->restore_ctx(mbox);
}
-EXPORT_SYMBOL(omap_mbox_restore_ctx);
+EXPORT_SYMBOL(mailbox_restore_ctx);
-void omap_mbox_enable_irq(struct omap_mbox *mbox, omap_mbox_irq_t irq)
+void mailbox_enable_irq(struct mailbox *mbox, mailbox_irq_t irq)
{
mbox->ops->enable_irq(mbox, irq);
}
-EXPORT_SYMBOL(omap_mbox_enable_irq);
+EXPORT_SYMBOL(mailbox_enable_irq);
-void omap_mbox_disable_irq(struct omap_mbox *mbox, omap_mbox_irq_t irq)
+void mailbox_disable_irq(struct mailbox *mbox, mailbox_irq_t irq)
{
mbox->ops->disable_irq(mbox, irq);
}
-EXPORT_SYMBOL(omap_mbox_disable_irq);
+EXPORT_SYMBOL(mailbox_disable_irq);
static void mbox_tx_tasklet(unsigned long tx_data)
{
- struct omap_mbox *mbox = (struct omap_mbox *)tx_data;
- struct omap_mbox_queue *mq = mbox->txq;
+ struct mailbox *mbox = (struct mailbox *)tx_data;
+ struct mailbox_queue *mq = mbox->txq;
mbox_msg_t msg;
int ret;
while (kfifo_len(&mq->fifo)) {
if (__mbox_poll_for_space(mbox)) {
- omap_mbox_enable_irq(mbox, IRQ_TX);
+ mailbox_enable_irq(mbox, IRQ_TX);
break;
}
@@ -176,8 +177,8 @@ static void mbox_tx_tasklet(unsigned long tx_data)
*/
static void mbox_rx_work(struct work_struct *work)
{
- struct omap_mbox_queue *mq =
- container_of(work, struct omap_mbox_queue, work);
+ struct mailbox_queue *mq =
+ container_of(work, struct mailbox_queue, work);
mbox_msg_t msg;
int len;
@@ -190,7 +191,7 @@ static void mbox_rx_work(struct work_struct *work)
spin_lock_irq(&mq->lock);
if (mq->full) {
mq->full = false;
- omap_mbox_enable_irq(mq->mbox, IRQ_RX);
+ mailbox_enable_irq(mq->mbox, IRQ_RX);
}
spin_unlock_irq(&mq->lock);
}
@@ -199,22 +200,22 @@ static void mbox_rx_work(struct work_struct *work)
/*
* Mailbox interrupt handler
*/
-static void __mbox_tx_interrupt(struct omap_mbox *mbox)
+static void __mbox_tx_interrupt(struct mailbox *mbox)
{
- omap_mbox_disable_irq(mbox, IRQ_TX);
+ mailbox_disable_irq(mbox, IRQ_TX);
ack_mbox_irq(mbox, IRQ_TX);
tasklet_schedule(&mbox->txq->tasklet);
}
-static void __mbox_rx_interrupt(struct omap_mbox *mbox)
+static void __mbox_rx_interrupt(struct mailbox *mbox)
{
- struct omap_mbox_queue *mq = mbox->rxq;
+ struct mailbox_queue *mq = mbox->rxq;
mbox_msg_t msg;
int len;
while (!mbox_fifo_empty(mbox)) {
if (unlikely(kfifo_avail(&mq->fifo) < sizeof(msg))) {
- omap_mbox_disable_irq(mbox, IRQ_RX);
+ mailbox_disable_irq(mbox, IRQ_RX);
mq->full = true;
goto nomem;
}
@@ -224,7 +225,7 @@ static void __mbox_rx_interrupt(struct omap_mbox *mbox)
len = kfifo_in(&mq->fifo, (unsigned char *)&msg, sizeof(msg));
WARN_ON(len != sizeof(msg));
- if (mbox->ops->type == OMAP_MBOX_TYPE1)
+ if (mbox->ops->type == MBOX_HW_FIFO1_TYPE)
break;
}
@@ -236,7 +237,7 @@ nomem:
static irqreturn_t mbox_interrupt(int irq, void *p)
{
- struct omap_mbox *mbox = p;
+ struct mailbox *mbox = p;
if (is_mbox_irq(mbox, IRQ_TX))
__mbox_tx_interrupt(mbox);
@@ -247,13 +248,13 @@ static irqreturn_t mbox_interrupt(int irq, void *p)
return IRQ_HANDLED;
}
-static struct omap_mbox_queue *mbox_queue_alloc(struct omap_mbox *mbox,
+static struct mailbox_queue *mbox_queue_alloc(struct mailbox *mbox,
void (*work) (struct work_struct *),
void (*tasklet)(unsigned long))
{
- struct omap_mbox_queue *mq;
+ struct mailbox_queue *mq;
- mq = kzalloc(sizeof(struct omap_mbox_queue), GFP_KERNEL);
+ mq = kzalloc(sizeof(struct mailbox_queue), GFP_KERNEL);
if (!mq)
return NULL;
@@ -273,16 +274,16 @@ error:
return NULL;
}
-static void mbox_queue_free(struct omap_mbox_queue *q)
+static void mbox_queue_free(struct mailbox_queue *q)
{
kfifo_free(&q->fifo);
kfree(q);
}
-static int omap_mbox_startup(struct omap_mbox *mbox)
+static int mailbox_startup(struct mailbox *mbox)
{
int ret = 0;
- struct omap_mbox_queue *mq;
+ struct mailbox_queue *mq;
mutex_lock(&mbox_configured_lock);
if (!mbox_configured++) {
@@ -317,7 +318,7 @@ static int omap_mbox_startup(struct omap_mbox *mbox)
mbox->rxq = mq;
mq->mbox = mbox;
- omap_mbox_enable_irq(mbox, IRQ_RX);
+ mailbox_enable_irq(mbox, IRQ_RX);
}
mutex_unlock(&mbox_configured_lock);
return 0;
@@ -336,12 +337,12 @@ fail_startup:
return ret;
}
-static void omap_mbox_fini(struct omap_mbox *mbox)
+static void mailbox_fini(struct mailbox *mbox)
{
mutex_lock(&mbox_configured_lock);
if (!--mbox->use_count) {
- omap_mbox_disable_irq(mbox, IRQ_RX);
+ mailbox_disable_irq(mbox, IRQ_RX);
free_irq(mbox->irq, mbox);
tasklet_kill(&mbox->txq->tasklet);
flush_work(&mbox->rxq->work);
@@ -357,9 +358,9 @@ static void omap_mbox_fini(struct omap_mbox *mbox)
mutex_unlock(&mbox_configured_lock);
}
-struct omap_mbox *omap_mbox_get(const char *name, struct notifier_block *nb)
+struct mailbox *mailbox_get(const char *name, struct notifier_block *nb)
{
- struct omap_mbox *_mbox, *mbox = NULL;
+ struct mailbox *_mbox, *mbox = NULL;
int i, ret;
if (!mboxes)
@@ -378,7 +379,7 @@ struct omap_mbox *omap_mbox_get(const char *name, struct notifier_block *nb)
if (nb)
blocking_notifier_chain_register(&mbox->notifier, nb);
- ret = omap_mbox_startup(mbox);
+ ret = mailbox_startup(mbox);
if (ret) {
blocking_notifier_chain_unregister(&mbox->notifier, nb);
return ERR_PTR(-ENODEV);
@@ -386,18 +387,18 @@ struct omap_mbox *omap_mbox_get(const char *name, struct notifier_block *nb)
return mbox;
}
-EXPORT_SYMBOL(omap_mbox_get);
+EXPORT_SYMBOL(mailbox_get);
-void omap_mbox_put(struct omap_mbox *mbox, struct notifier_block *nb)
+void mailbox_put(struct mailbox *mbox, struct notifier_block *nb)
{
blocking_notifier_chain_unregister(&mbox->notifier, nb);
- omap_mbox_fini(mbox);
+ mailbox_fini(mbox);
}
-EXPORT_SYMBOL(omap_mbox_put);
+EXPORT_SYMBOL(mailbox_put);
-static struct class omap_mbox_class = { .name = "mbox", };
+static struct class mailbox_class = { .name = "mbox", };
-int omap_mbox_register(struct device *parent, struct omap_mbox **list)
+int mailbox_register(struct device *parent, struct mailbox **list)
{
int ret;
int i;
@@ -407,8 +408,8 @@ int omap_mbox_register(struct device *parent, struct omap_mbox **list)
return -EINVAL;
for (i = 0; mboxes[i]; i++) {
- struct omap_mbox *mbox = mboxes[i];
- mbox->dev = device_create(&omap_mbox_class,
+ struct mailbox *mbox = mboxes[i];
+ mbox->dev = device_create(&mailbox_class,
parent, 0, mbox, "%s", mbox->name);
if (IS_ERR(mbox->dev)) {
ret = PTR_ERR(mbox->dev);
@@ -424,9 +425,9 @@ err_out:
device_unregister(mboxes[i]->dev);
return ret;
}
-EXPORT_SYMBOL(omap_mbox_register);
+EXPORT_SYMBOL(mailbox_register);
-int omap_mbox_unregister(void)
+int mailbox_unregister(void)
{
int i;
@@ -438,13 +439,13 @@ int omap_mbox_unregister(void)
mboxes = NULL;
return 0;
}
-EXPORT_SYMBOL(omap_mbox_unregister);
+EXPORT_SYMBOL(mailbox_unregister);
-static int __init omap_mbox_init(void)
+static int __init mailbox_init(void)
{
int err;
- err = class_register(&omap_mbox_class);
+ err = class_register(&mailbox_class);
if (err)
return err;
@@ -455,15 +456,15 @@ static int __init omap_mbox_init(void)
return 0;
}
-subsys_initcall(omap_mbox_init);
+subsys_initcall(mailbox_init);
-static void __exit omap_mbox_exit(void)
+static void __exit mailbox_exit(void)
{
- class_unregister(&omap_mbox_class);
+ class_unregister(&mailbox_class);
}
-module_exit(omap_mbox_exit);
+module_exit(mailbox_exit);
MODULE_LICENSE("GPL v2");
-MODULE_DESCRIPTION("omap mailbox: interrupt driven messaging");
+MODULE_DESCRIPTION("mailbox framework: interrupt driven messaging");
MODULE_AUTHOR("Toshihiro Kobayashi");
MODULE_AUTHOR("Hiroshi DOYU");
diff --git a/drivers/mailbox/mailbox.h b/drivers/mailbox/mailbox.h
index bf3c1b4..530f191 100644
--- a/drivers/mailbox/mailbox.h
+++ b/drivers/mailbox/mailbox.h
@@ -10,54 +10,54 @@
#include <linux/kfifo.h>
#include <linux/mailbox.h>
-typedef int __bitwise omap_mbox_type_t;
-#define OMAP_MBOX_TYPE1 ((__force omap_mbox_type_t) 1)
-#define OMAP_MBOX_TYPE2 ((__force omap_mbox_type_t) 2)
-
-struct omap_mbox_ops {
- omap_mbox_type_t type;
- int (*startup)(struct omap_mbox *mbox);
- void (*shutdown)(struct omap_mbox *mbox);
+typedef int __bitwise mailbox_type_t;
+#define MBOX_HW_FIFO1_TYPE ((__force mailbox_type_t) 1)
+#define MBOX_HW_FIFO2_TYPE ((__force mailbox_type_t) 2)
+
+struct mailbox_ops {
+ mailbox_type_t type;
+ int (*startup)(struct mailbox *mbox);
+ void (*shutdown)(struct mailbox *mbox);
/* fifo */
- mbox_msg_t (*fifo_read)(struct omap_mbox *mbox);
- void (*fifo_write)(struct omap_mbox *mbox, mbox_msg_t msg);
- int (*fifo_empty)(struct omap_mbox *mbox);
- int (*fifo_full)(struct omap_mbox *mbox);
+ mbox_msg_t (*fifo_read)(struct mailbox *mbox);
+ void (*fifo_write)(struct mailbox *mbox, mbox_msg_t msg);
+ int (*fifo_empty)(struct mailbox *mbox);
+ int (*fifo_full)(struct mailbox *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 (*ack_irq)(struct omap_mbox *mbox, omap_mbox_irq_t irq);
- int (*is_irq)(struct omap_mbox *mbox, omap_mbox_irq_t irq);
+ void (*enable_irq)(struct mailbox *mbox,
+ mailbox_irq_t irq);
+ void (*disable_irq)(struct mailbox *mbox,
+ mailbox_irq_t irq);
+ void (*ack_irq)(struct mailbox *mbox, mailbox_irq_t irq);
+ int (*is_irq)(struct mailbox *mbox, mailbox_irq_t irq);
/* ctx */
- void (*save_ctx)(struct omap_mbox *mbox);
- void (*restore_ctx)(struct omap_mbox *mbox);
+ void (*save_ctx)(struct mailbox *mbox);
+ void (*restore_ctx)(struct mailbox *mbox);
};
-struct omap_mbox_queue {
+struct mailbox_queue {
spinlock_t lock;
struct kfifo fifo;
struct work_struct work;
struct tasklet_struct tasklet;
- struct omap_mbox *mbox;
+ struct mailbox *mbox;
bool full;
};
-struct omap_mbox {
+struct mailbox {
char *name;
unsigned int irq;
- struct omap_mbox_queue *txq, *rxq;
- struct omap_mbox_ops *ops;
+ struct mailbox_queue *txq, *rxq;
+ struct mailbox_ops *ops;
struct device *dev;
void *priv;
int use_count;
struct blocking_notifier_head notifier;
};
-void omap_mbox_init_seq(struct omap_mbox *);
+void mailbox_init_seq(struct mailbox *);
-int omap_mbox_register(struct device *parent, struct omap_mbox **);
-int omap_mbox_unregister(void);
+int mailbox_register(struct device *parent, struct mailbox **);
+int mailbox_unregister(void);
#endif /* MAILBOX_H */
diff --git a/include/linux/mailbox.h b/include/linux/mailbox.h
index 78ef848..18c9502 100644
--- a/include/linux/mailbox.h
+++ b/include/linux/mailbox.h
@@ -1,18 +1,18 @@
/* mailbox.h */
typedef u32 mbox_msg_t;
-struct omap_mbox;
+struct mailbox;
-typedef int __bitwise omap_mbox_irq_t;
-#define IRQ_TX ((__force omap_mbox_irq_t) 1)
-#define IRQ_RX ((__force omap_mbox_irq_t) 2)
+typedef int __bitwise mailbox_irq_t;
+#define IRQ_TX ((__force mailbox_irq_t) 1)
+#define IRQ_RX ((__force mailbox_irq_t) 2)
-int omap_mbox_msg_send(struct omap_mbox *, mbox_msg_t msg);
+int mailbox_msg_send(struct mailbox *, mbox_msg_t msg);
-struct omap_mbox *omap_mbox_get(const char *, struct notifier_block *nb);
-void omap_mbox_put(struct omap_mbox *mbox, struct notifier_block *nb);
+struct mailbox *mailbox_get(const char *, struct notifier_block *nb);
+void mailbox_put(struct mailbox *mbox, struct notifier_block *nb);
-void omap_mbox_save_ctx(struct omap_mbox *mbox);
-void omap_mbox_restore_ctx(struct omap_mbox *mbox);
-void omap_mbox_enable_irq(struct omap_mbox *mbox, omap_mbox_irq_t irq);
-void omap_mbox_disable_irq(struct omap_mbox *mbox, omap_mbox_irq_t irq);
+void mailbox_save_ctx(struct mailbox *mbox);
+void mailbox_restore_ctx(struct mailbox *mbox);
+void mailbox_enable_irq(struct mailbox *mbox, mailbox_irq_t irq);
+void mailbox_disable_irq(struct mailbox *mbox, mailbox_irq_t irq);
--
1.7.11.1
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH 4/9] mailbox: create opened message type
2012-12-18 13:10 [PATCH 0/9] drivers: mailbox: framework creation Loic Pallardy
` (2 preceding siblings ...)
2012-12-18 13:10 ` [PATCH 3/9] mailbox: rename omap_mbox in mailbox Loic Pallardy
@ 2012-12-18 13:10 ` Loic Pallardy
2012-12-21 10:28 ` Bedia, Vaibhav
2012-12-18 13:10 ` [PATCH 5/9] mailbox: change protection mechanisms Loic Pallardy
` (5 subsequent siblings)
9 siblings, 1 reply; 31+ messages in thread
From: Loic Pallardy @ 2012-12-18 13:10 UTC (permalink / raw)
To: linux-arm-kernel
Current message type is a u32 to fit HW fifo format.
This should be extended to support any message exchanges
and type of mailbox.
Propose structure owns the original u32 and an optional
pointer on additional data.
Signed-off-by: Loic Pallardy <loic.pallardy@st.com>
---
drivers/mailbox/Kconfig | 9 ++++++
drivers/mailbox/mailbox-omap1.c | 18 ++++++------
drivers/mailbox/mailbox-omap2.c | 10 ++++---
drivers/mailbox/mailbox.c | 64 +++++++++++++++++++++++++++++------------
drivers/mailbox/mailbox.h | 6 ++--
include/linux/mailbox.h | 17 ++++++++++-
6 files changed, 89 insertions(+), 35 deletions(-)
diff --git a/drivers/mailbox/Kconfig b/drivers/mailbox/Kconfig
index d1e7d74..efb766f 100644
--- a/drivers/mailbox/Kconfig
+++ b/drivers/mailbox/Kconfig
@@ -33,4 +33,13 @@ config MBOX_KFIFO_SIZE
This can also be changed at runtime (via the mbox_kfifo_size
module parameter).
+config MBOX_DATA_SIZE
+ int "Mailbox associated data max size (bytes)"
+ default 64
+ help
+ Specify the default size of mailbox's associated data buffer
+ (bytes)
+ This can also be changed at runtime (via the mbox_kfifo_size
+ module parameter).
+
endif
diff --git a/drivers/mailbox/mailbox-omap1.c b/drivers/mailbox/mailbox-omap1.c
index 31cb70a..94e90af 100644
--- a/drivers/mailbox/mailbox-omap1.c
+++ b/drivers/mailbox/mailbox-omap1.c
@@ -50,26 +50,26 @@ static inline void mbox_write_reg(u32 val, size_t ofs)
}
/* msg */
-static mbox_msg_t omap1_mbox_fifo_read(struct mailbox *mbox)
+static int omap1_mbox_fifo_read(struct mailbox *mbox, struct mailbox_msg *msg)
{
struct omap_mbox1_fifo *fifo =
&((struct omap_mbox1_priv *)mbox->priv)->rx_fifo;
- mbox_msg_t msg;
- msg = mbox_read_reg(fifo->data);
- msg |= ((mbox_msg_t) mbox_read_reg(fifo->cmd)) << 16;
+ msg->header = mbox_read_reg(fifo->data);
+ msg->header |= ((mbox_msg_t) mbox_read_reg(fifo->cmd)) << 16;
- return msg;
+ return 0;
}
-static void
-omap1_mbox_fifo_write(struct mailbox *mbox, mbox_msg_t msg)
+static int
+omap1_mbox_fifo_write(struct mailbox *mbox, struct mailbox_msg *msg)
{
struct omap_mbox1_fifo *fifo =
&((struct omap_mbox1_priv *)mbox->priv)->tx_fifo;
- mbox_write_reg(msg & 0xffff, fifo->data);
- mbox_write_reg(msg >> 16, fifo->cmd);
+ mbox_write_reg(msg->header & 0xffff, fifo->data);
+ mbox_write_reg(msg->header >> 16, fifo->cmd);
+ return 0
}
static int omap1_mbox_fifo_empty(struct mailbox *mbox)
diff --git a/drivers/mailbox/mailbox-omap2.c b/drivers/mailbox/mailbox-omap2.c
index 230d9d3..2299674 100644
--- a/drivers/mailbox/mailbox-omap2.c
+++ b/drivers/mailbox/mailbox-omap2.c
@@ -95,18 +95,20 @@ static void omap2_mbox_shutdown(struct mailbox *mbox)
}
/* Mailbox FIFO handle functions */
-static mbox_msg_t omap2_mbox_fifo_read(struct mailbox *mbox)
+static int omap2_mbox_fifo_read(struct mailbox *mbox, struct mailbox_msg *msg)
{
struct omap_mbox2_fifo *fifo =
&((struct omap_mbox2_priv *)mbox->priv)->rx_fifo;
- return (mbox_msg_t) mbox_read_reg(fifo->msg);
+ msg->header = mbox_read_reg(fifo->msg);
+ return 0;
}
-static void omap2_mbox_fifo_write(struct mailbox *mbox, mbox_msg_t msg)
+static int omap2_mbox_fifo_write(struct mailbox *mbox, struct mailbox_msg *msg)
{
struct omap_mbox2_fifo *fifo =
&((struct omap_mbox2_priv *)mbox->priv)->tx_fifo;
- mbox_write_reg(msg, fifo->msg);
+ mbox_write_reg(msg->header, fifo->msg);
+ return 0;
}
static int omap2_mbox_fifo_empty(struct mailbox *mbox)
diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c
index b9389c6..727e67e 100644
--- a/drivers/mailbox/mailbox.c
+++ b/drivers/mailbox/mailbox.c
@@ -43,12 +43,13 @@ static unsigned int mbox_kfifo_size = CONFIG_MBOX_KFIFO_SIZE;
module_param(mbox_kfifo_size, uint, S_IRUGO);
MODULE_PARM_DESC(mbox_kfifo_size, "Size of mailbox kfifo (bytes)");
+
/* Mailbox FIFO handle functions */
-static inline mbox_msg_t mbox_fifo_read(struct mailbox *mbox)
+static inline mbox_msg_t mbox_fifo_read(struct mailbox *mbox, struct mailbox_msg *msg)
{
- return mbox->ops->fifo_read(mbox);
+ return mbox->ops->fifo_read(mbox, msg);
}
-static inline void mbox_fifo_write(struct mailbox *mbox, mbox_msg_t msg)
+static inline void mbox_fifo_write(struct mailbox *mbox, struct mailbox_msg *msg)
{
mbox->ops->fifo_write(mbox, msg);
}
@@ -89,14 +90,14 @@ static int __mbox_poll_for_space(struct mailbox *mbox)
return ret;
}
-int mailbox_msg_send(struct mailbox *mbox, mbox_msg_t msg)
+int mailbox_msg_send(struct mailbox *mbox, struct mailbox_msg *msg)
{
struct mailbox_queue *mq = mbox->txq;
int ret = 0, len;
spin_lock_bh(&mq->lock);
- if (kfifo_avail(&mq->fifo) < sizeof(msg)) {
+ if (kfifo_avail(&mq->fifo) < (sizeof(msg) + msg->size)) {
ret = -ENOMEM;
goto out;
}
@@ -106,9 +107,14 @@ int mailbox_msg_send(struct mailbox *mbox, mbox_msg_t msg)
goto out;
}
- len = kfifo_in(&mq->fifo, (unsigned char *)&msg, sizeof(msg));
+ len = kfifo_in(&mq->fifo, (unsigned char *)msg, sizeof(msg));
WARN_ON(len != sizeof(msg));
+ if (msg->size && msg->pdata) {
+ len = kfifo_in(&mq->fifo, (unsigned char *)msg->pdata, msg->size);
+ WARN_ON(len != msg->size);
+ }
+
tasklet_schedule(&mbox->txq->tasklet);
out:
@@ -151,11 +157,13 @@ void mailbox_disable_irq(struct mailbox *mbox, mailbox_irq_t irq)
}
EXPORT_SYMBOL(mailbox_disable_irq);
+static unsigned char tx_data_buf[CONFIG_MBOX_DATA_SIZE];
+
static void mbox_tx_tasklet(unsigned long tx_data)
{
struct mailbox *mbox = (struct mailbox *)tx_data;
struct mailbox_queue *mq = mbox->txq;
- mbox_msg_t msg;
+ struct mailbox_msg msg;
int ret;
while (kfifo_len(&mq->fifo)) {
@@ -168,30 +176,44 @@ static void mbox_tx_tasklet(unsigned long tx_data)
sizeof(msg));
WARN_ON(ret != sizeof(msg));
- mbox_fifo_write(mbox, msg);
+ if (msg.size) {
+ ret = kfifo_out(&mq->fifo, tx_data_buf, sizeof(msg.size));
+ WARN_ON(ret != msg.size);
+ msg.pdata = tx_data_buf;
+ }
+
+ mbox_fifo_write(mbox, &msg);
}
}
/*
* Message receiver(workqueue)
*/
+static unsigned char rx_work_data[CONFIG_MBOX_DATA_SIZE];
+
static void mbox_rx_work(struct work_struct *work)
{
struct mailbox_queue *mq =
container_of(work, struct mailbox_queue, work);
- mbox_msg_t msg;
int len;
+ struct mailbox *mbox = mq->mbox;
+ struct mailbox_msg msg;
while (kfifo_len(&mq->fifo) >= sizeof(msg)) {
len = kfifo_out(&mq->fifo, (unsigned char *)&msg, sizeof(msg));
WARN_ON(len != sizeof(msg));
- blocking_notifier_call_chain(&mq->mbox->notifier, len,
- (void *)msg);
+ if (msg.size) {
+ len = kfifo_out(&mq->fifo, rx_work_data, msg.size);
+ WARN_ON(len != msg.size);
+ msg.pdata = rx_work_data;
+ }
+
+ blocking_notifier_call_chain(&mbox->notifier, len, (void *)&msg);
spin_lock_irq(&mq->lock);
if (mq->full) {
mq->full = false;
- mailbox_enable_irq(mq->mbox, IRQ_RX);
+ mailbox_enable_irq(mbox, IRQ_RX);
}
spin_unlock_irq(&mq->lock);
}
@@ -210,21 +232,28 @@ static void __mbox_tx_interrupt(struct mailbox *mbox)
static void __mbox_rx_interrupt(struct mailbox *mbox)
{
struct mailbox_queue *mq = mbox->rxq;
- mbox_msg_t msg;
+ struct mailbox_msg msg;
int len;
while (!mbox_fifo_empty(mbox)) {
- if (unlikely(kfifo_avail(&mq->fifo) < sizeof(msg))) {
+ if (unlikely(kfifo_avail(&mq->fifo) <
+ (sizeof(msg) + CONFIG_MBOX_DATA_SIZE))) {
mailbox_disable_irq(mbox, IRQ_RX);
mq->full = true;
goto nomem;
}
- msg = mbox_fifo_read(mbox);
+ mbox_fifo_read(mbox, &msg);
len = kfifo_in(&mq->fifo, (unsigned char *)&msg, sizeof(msg));
WARN_ON(len != sizeof(msg));
+ if (msg.pdata && msg.size) {
+ len = kfifo_in(&mq->fifo, (unsigned char *)msg.pdata,
+ msg.size);
+ WARN_ON(len != msg.size);
+ }
+
if (mbox->ops->type == MBOX_HW_FIFO1_TYPE)
break;
}
@@ -450,10 +479,9 @@ static int __init mailbox_init(void)
return err;
/* kfifo size sanity check: alignment and minimal size */
- mbox_kfifo_size = ALIGN(mbox_kfifo_size, sizeof(mbox_msg_t));
+ mbox_kfifo_size = ALIGN(mbox_kfifo_size, sizeof(struct mailbox_msg));
mbox_kfifo_size = max_t(unsigned int, mbox_kfifo_size,
- sizeof(mbox_msg_t));
-
+ sizeof(struct mailbox_msg) + CONFIG_MBOX_DATA_SIZE);
return 0;
}
subsys_initcall(mailbox_init);
diff --git a/drivers/mailbox/mailbox.h b/drivers/mailbox/mailbox.h
index 530f191..23ac551 100644
--- a/drivers/mailbox/mailbox.h
+++ b/drivers/mailbox/mailbox.h
@@ -19,8 +19,8 @@ struct mailbox_ops {
int (*startup)(struct mailbox *mbox);
void (*shutdown)(struct mailbox *mbox);
/* fifo */
- mbox_msg_t (*fifo_read)(struct mailbox *mbox);
- void (*fifo_write)(struct mailbox *mbox, mbox_msg_t msg);
+ mbox_msg_t (*fifo_read)(struct mailbox *mbox, struct mailbox_msg *msg);
+ int (*fifo_write)(struct mailbox *mbox, struct mailbox_msg *msg);
int (*fifo_empty)(struct mailbox *mbox);
int (*fifo_full)(struct mailbox *mbox);
/* irq */
@@ -40,7 +40,7 @@ struct mailbox_queue {
struct kfifo fifo;
struct work_struct work;
struct tasklet_struct tasklet;
- struct mailbox *mbox;
+ struct mailbox *mbox;
bool full;
};
diff --git a/include/linux/mailbox.h b/include/linux/mailbox.h
index 18c9502..d256e1a 100644
--- a/include/linux/mailbox.h
+++ b/include/linux/mailbox.h
@@ -7,7 +7,22 @@ typedef int __bitwise mailbox_irq_t;
#define IRQ_TX ((__force mailbox_irq_t) 1)
#define IRQ_RX ((__force mailbox_irq_t) 2)
-int mailbox_msg_send(struct mailbox *, mbox_msg_t msg);
+struct mailbox_msg {
+ int size;
+ u32 header;
+ void *pdata;
+};
+
+#define MAILBOX_FILL_MSG(_msg, _header, _pdata, _size) { \
+ _msg.header = _header; \
+ _msg.pdata = (void *)_pdata; \
+ _msg.size = _size; \
+}
+
+#define MAILBOX_FILL_HEADER_MSG(_msg, _header) \
+ MAILBOX_FILL_MSG(_msg, _header, NULL, 0);
+
+int mailbox_msg_send(struct mailbox *, struct mailbox_msg *msg);
struct mailbox *mailbox_get(const char *, struct notifier_block *nb);
void mailbox_put(struct mailbox *mbox, struct notifier_block *nb);
--
1.7.11.1
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH 4/9] mailbox: create opened message type
2012-12-18 13:10 ` [PATCH 4/9] mailbox: create opened message type Loic Pallardy
@ 2012-12-21 10:28 ` Bedia, Vaibhav
2012-12-21 10:50 ` Loic PALLARDY
0 siblings, 1 reply; 31+ messages in thread
From: Bedia, Vaibhav @ 2012-12-21 10:28 UTC (permalink / raw)
To: linux-arm-kernel
On Tue, Dec 18, 2012 at 18:40:07, Loic Pallardy wrote:
> Current message type is a u32 to fit HW fifo format.
> This should be extended to support any message exchanges
> and type of mailbox.
> Propose structure owns the original u32 and an optional
> pointer on additional data.
>
> Signed-off-by: Loic Pallardy <loic.pallardy@st.com>
> ---
> drivers/mailbox/Kconfig | 9 ++++++
> drivers/mailbox/mailbox-omap1.c | 18 ++++++------
> drivers/mailbox/mailbox-omap2.c | 10 ++++---
> drivers/mailbox/mailbox.c | 64 +++++++++++++++++++++++++++++------------
> drivers/mailbox/mailbox.h | 6 ++--
> include/linux/mailbox.h | 17 ++++++++++-
> 6 files changed, 89 insertions(+), 35 deletions(-)
>
> diff --git a/drivers/mailbox/Kconfig b/drivers/mailbox/Kconfig
> index d1e7d74..efb766f 100644
> --- a/drivers/mailbox/Kconfig
> +++ b/drivers/mailbox/Kconfig
> @@ -33,4 +33,13 @@ config MBOX_KFIFO_SIZE
> This can also be changed at runtime (via the mbox_kfifo_size
> module parameter).
>
> +config MBOX_DATA_SIZE
> + int "Mailbox associated data max size (bytes)"
> + default 64
> + help
> + Specify the default size of mailbox's associated data buffer
> + (bytes)
> + This can also be changed at runtime (via the mbox_kfifo_size
> + module parameter).
> +
> endif
> diff --git a/drivers/mailbox/mailbox-omap1.c b/drivers/mailbox/mailbox-omap1.c
> index 31cb70a..94e90af 100644
> --- a/drivers/mailbox/mailbox-omap1.c
> +++ b/drivers/mailbox/mailbox-omap1.c
> @@ -50,26 +50,26 @@ static inline void mbox_write_reg(u32 val, size_t ofs)
> }
>
> /* msg */
> -static mbox_msg_t omap1_mbox_fifo_read(struct mailbox *mbox)
> +static int omap1_mbox_fifo_read(struct mailbox *mbox, struct mailbox_msg *msg)
> {
> struct omap_mbox1_fifo *fifo =
> &((struct omap_mbox1_priv *)mbox->priv)->rx_fifo;
> - mbox_msg_t msg;
>
> - msg = mbox_read_reg(fifo->data);
> - msg |= ((mbox_msg_t) mbox_read_reg(fifo->cmd)) << 16;
> + msg->header = mbox_read_reg(fifo->data);
> + msg->header |= ((mbox_msg_t) mbox_read_reg(fifo->cmd)) << 16;
Now that struct mailbox_msg encapsulates the data, you can
get rid of the mbox_msg_t typedef completely. Having the data
as part of the mailbox_msg along with the functions with mbox_msg_t
as the return type just creates confusion IMHO.
>
> - return msg;
> + return 0;
> }
Convert all return 0 functions to void?
[...]
>
> diff --git a/include/linux/mailbox.h b/include/linux/mailbox.h
> index 18c9502..d256e1a 100644
> --- a/include/linux/mailbox.h
> +++ b/include/linux/mailbox.h
> @@ -7,7 +7,22 @@ typedef int __bitwise mailbox_irq_t;
> #define IRQ_TX ((__force mailbox_irq_t) 1)
> #define IRQ_RX ((__force mailbox_irq_t) 2)
>
> -int mailbox_msg_send(struct mailbox *, mbox_msg_t msg);
> +struct mailbox_msg {
> + int size;
> + u32 header;
> + void *pdata;
> +};
> +
> +#define MAILBOX_FILL_MSG(_msg, _header, _pdata, _size) { \
> + _msg.header = _header; \
> + _msg.pdata = (void *)_pdata; \
> + _msg.size = _size; \
> +}
> +
> +#define MAILBOX_FILL_HEADER_MSG(_msg, _header) \
> + MAILBOX_FILL_MSG(_msg, _header, NULL, 0);
> +
I used these patches as part of the suspend-resume support for AM335x
which has the same mailbox IP as OMAP4. I used the MAILBOX_FILL_HEADER_MSG
helper and things work as expected.
However, I found the 'header' part to be very confusing. Why not treat the
OMAP case as a special case of the new MAILBOX_FILL_MSG where the data size
is set to 1?
Regards,
Vaibhav
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH 4/9] mailbox: create opened message type
2012-12-21 10:28 ` Bedia, Vaibhav
@ 2012-12-21 10:50 ` Loic PALLARDY
0 siblings, 0 replies; 31+ messages in thread
From: Loic PALLARDY @ 2012-12-21 10:50 UTC (permalink / raw)
To: linux-arm-kernel
On 12/21/2012 11:28 AM, Bedia, Vaibhav wrote:
> On Tue, Dec 18, 2012 at 18:40:07, Loic Pallardy wrote:
>> - msg = mbox_read_reg(fifo->data);
>> - msg |= ((mbox_msg_t) mbox_read_reg(fifo->cmd))<< 16;
>> + msg->header = mbox_read_reg(fifo->data);
>> + msg->header |= ((mbox_msg_t) mbox_read_reg(fifo->cmd))<< 16;
>
> Now that struct mailbox_msg encapsulates the data, you can
> get rid of the mbox_msg_t typedef completely. Having the data
> as part of the mailbox_msg along with the functions with mbox_msg_t
> as the return type just creates confusion IMHO.
>
OK I'll clean up mbox_msg_t typedef.
>>
>> - return msg;
>> + return 0;
>> }
>
> Convert all return 0 functions to void?
>
> [...]
>
Yes, agree I'll change the prototype.
>>
>> +
>> +#define MAILBOX_FILL_HEADER_MSG(_msg, _header) \
>> + MAILBOX_FILL_MSG(_msg, _header, NULL, 0);
>> +
>
> I used these patches as part of the suspend-resume support for AM335x
> which has the same mailbox IP as OMAP4. I used the MAILBOX_FILL_HEADER_MSG
> helper and things work as expected.
Nice.
>
> However, I found the 'header' part to be very confusing. Why not treat the
> OMAP case as a special case of the new MAILBOX_FILL_MSG where the data size
> is set to 1?
Yes it is another possibility. Changes are not big.
Omar, what's your view on this point?
Regards,
Loic
>
> Regards,
> Vaibhav
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH 5/9] mailbox: change protection mechanisms
2012-12-18 13:10 [PATCH 0/9] drivers: mailbox: framework creation Loic Pallardy
` (3 preceding siblings ...)
2012-12-18 13:10 ` [PATCH 4/9] mailbox: create opened message type Loic Pallardy
@ 2012-12-18 13:10 ` Loic Pallardy
2012-12-21 10:28 ` Bedia, Vaibhav
2012-12-18 13:10 ` [PATCH 6/9] mailbox: add shared memory mailbox type Loic Pallardy
` (4 subsequent siblings)
9 siblings, 1 reply; 31+ messages in thread
From: Loic Pallardy @ 2012-12-18 13:10 UTC (permalink / raw)
To: linux-arm-kernel
TX: replace spin by mutex
RX: replace spin_lock_irq by spin_lock_irqsave
Signed-off-by: Loic Pallardy <loic.pallardy@st.com>
---
drivers/mailbox/mailbox.c | 10 ++++++----
drivers/mailbox/mailbox.h | 1 +
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c
index 727e67e..8b7d7bd 100644
--- a/drivers/mailbox/mailbox.c
+++ b/drivers/mailbox/mailbox.c
@@ -95,7 +95,7 @@ int mailbox_msg_send(struct mailbox *mbox, struct mailbox_msg *msg)
struct mailbox_queue *mq = mbox->txq;
int ret = 0, len;
- spin_lock_bh(&mq->lock);
+ mutex_lock(&mq->mlock);
if (kfifo_avail(&mq->fifo) < (sizeof(msg) + msg->size)) {
ret = -ENOMEM;
@@ -118,7 +118,7 @@ int mailbox_msg_send(struct mailbox *mbox, struct mailbox_msg *msg)
tasklet_schedule(&mbox->txq->tasklet);
out:
- spin_unlock_bh(&mq->lock);
+ mutex_unlock(&mq->mlock);
return ret;
}
EXPORT_SYMBOL(mailbox_msg_send);
@@ -198,6 +198,7 @@ static void mbox_rx_work(struct work_struct *work)
int len;
struct mailbox *mbox = mq->mbox;
struct mailbox_msg msg;
+ unsigned long flags;
while (kfifo_len(&mq->fifo) >= sizeof(msg)) {
len = kfifo_out(&mq->fifo, (unsigned char *)&msg, sizeof(msg));
@@ -210,12 +211,12 @@ static void mbox_rx_work(struct work_struct *work)
}
blocking_notifier_call_chain(&mbox->notifier, len, (void *)&msg);
- spin_lock_irq(&mq->lock);
+ spin_lock_irqsave(&mq->lock, flags);
if (mq->full) {
mq->full = false;
mailbox_enable_irq(mbox, IRQ_RX);
}
- spin_unlock_irq(&mq->lock);
+ spin_unlock_irqrestore(&mq->lock, flags);
}
}
@@ -288,6 +289,7 @@ static struct mailbox_queue *mbox_queue_alloc(struct mailbox *mbox,
return NULL;
spin_lock_init(&mq->lock);
+ mutex_init(&mq->mlock);
if (kfifo_alloc(&mq->fifo, mbox_kfifo_size, GFP_KERNEL))
goto error;
diff --git a/drivers/mailbox/mailbox.h b/drivers/mailbox/mailbox.h
index 23ac551..0a31c99 100644
--- a/drivers/mailbox/mailbox.h
+++ b/drivers/mailbox/mailbox.h
@@ -37,6 +37,7 @@ struct mailbox_ops {
struct mailbox_queue {
spinlock_t lock;
+ struct mutex mlock;
struct kfifo fifo;
struct work_struct work;
struct tasklet_struct tasklet;
--
1.7.11.1
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH 6/9] mailbox: add shared memory mailbox type
2012-12-18 13:10 [PATCH 0/9] drivers: mailbox: framework creation Loic Pallardy
` (4 preceding siblings ...)
2012-12-18 13:10 ` [PATCH 5/9] mailbox: change protection mechanisms Loic Pallardy
@ 2012-12-18 13:10 ` Loic Pallardy
2012-12-18 13:10 ` [PATCH 7/9] mailbox: add IRQF_NO_SUSPEND flag Loic Pallardy
` (3 subsequent siblings)
9 siblings, 0 replies; 31+ messages in thread
From: Loic Pallardy @ 2012-12-18 13:10 UTC (permalink / raw)
To: linux-arm-kernel
Some mailboxes are made up of cross interrupts
and associated shared memory.
Shared memory mapping is fixed and cross interrupt/shared
memory relation make impossible the use of virtio.
Mailbox framework must be enough opened to support
any kind of mailbox.
Signed-off-by: Loic Pallardy <loic.pallardy@st.com>
---
drivers/mailbox/mailbox-omap1.c | 40 +++++++++++++++++++++++++++++++---------
drivers/mailbox/mailbox-omap2.c | 16 ++++++++++++----
drivers/mailbox/mailbox.c | 38 +++++++++++---------------------------
drivers/mailbox/mailbox.h | 14 ++++++++------
4 files changed, 62 insertions(+), 46 deletions(-)
diff --git a/drivers/mailbox/mailbox-omap1.c b/drivers/mailbox/mailbox-omap1.c
index 94e90af..0097342 100644
--- a/drivers/mailbox/mailbox-omap1.c
+++ b/drivers/mailbox/mailbox-omap1.c
@@ -37,6 +37,7 @@ struct omap_mbox1_fifo {
struct omap_mbox1_priv {
struct omap_mbox1_fifo tx_fifo;
struct omap_mbox1_fifo rx_fifo;
+ bool empty_flag;
};
static inline int mbox_read_reg(size_t ofs)
@@ -52,12 +53,12 @@ static inline void mbox_write_reg(u32 val, size_t ofs)
/* msg */
static int omap1_mbox_fifo_read(struct mailbox *mbox, struct mailbox_msg *msg)
{
- struct omap_mbox1_fifo *fifo =
- &((struct omap_mbox1_priv *)mbox->priv)->rx_fifo;
+ struct omap_mbox1_priv *priv = (struct omap_mbox1_priv *)mbox->priv;
+ struct omap_mbox1_fifo *fifo = &priv->rx_fifo;
msg->header = mbox_read_reg(fifo->data);
msg->header |= ((mbox_msg_t) mbox_read_reg(fifo->cmd)) << 16;
-
+ priv->empty_flag = false;
return 0;
}
@@ -69,12 +70,16 @@ omap1_mbox_fifo_write(struct mailbox *mbox, struct mailbox_msg *msg)
mbox_write_reg(msg->header & 0xffff, fifo->data);
mbox_write_reg(msg->header >> 16, fifo->cmd);
- return 0
+ return 0;
}
static int omap1_mbox_fifo_empty(struct mailbox *mbox)
{
- return 0;
+ struct omap_mbox1_priv *priv = (struct omap_mbox1_priv *)mbox->priv;
+ if (priv->empty_flag)
+ return 0;
+ else
+ return 1;
}
static int omap1_mbox_fifo_full(struct mailbox *mbox)
@@ -85,6 +90,18 @@ static int omap1_mbox_fifo_full(struct mailbox *mbox)
return mbox_read_reg(fifo->flag);
}
+static int ompa1_mbox_poll_for_space(struct mailbox *mbox)
+{
+ int ret = 0, i = 1000;
+
+ while (omap1_mbox_fifo_full(mbox)) {
+ if (--i == 0)
+ return -1;
+ udelay(1);
+ }
+ return ret;
+}
+
/* irq */
static void
omap1_mbox_enable_irq(struct mailbox *mbox, mailbox_type_t irq)
@@ -103,17 +120,22 @@ omap1_mbox_disable_irq(struct mailbox *mbox, mailbox_type_t irq)
static int
omap1_mbox_is_irq(struct mailbox *mbox, mailbox_type_t irq)
{
+ struct omap_mbox1_priv *priv = (struct omap_mbox1_priv *)mbox->priv;
+
if (irq == IRQ_TX)
return 0;
+ if (irq == IRQ_RX)
+ priv->empty_flag = true;
+
return 1;
}
static struct mailbox_ops omap1_mbox_ops = {
.type = MBOX_HW_FIFO1_TYPE,
- .fifo_read = omap1_mbox_fifo_read,
- .fifo_write = omap1_mbox_fifo_write,
- .fifo_empty = omap1_mbox_fifo_empty,
- .fifo_full = omap1_mbox_fifo_full,
+ .read = omap1_mbox_fifo_read,
+ .write = omap1_mbox_fifo_write,
+ .empty = omap1_mbox_fifo_empty,
+ .poll_for_space = ompa1_mbox_poll_for_space,
.enable_irq = omap1_mbox_enable_irq,
.disable_irq = omap1_mbox_disable_irq,
.is_irq = omap1_mbox_is_irq,
diff --git a/drivers/mailbox/mailbox-omap2.c b/drivers/mailbox/mailbox-omap2.c
index 2299674..7c26bed 100644
--- a/drivers/mailbox/mailbox-omap2.c
+++ b/drivers/mailbox/mailbox-omap2.c
@@ -125,6 +125,14 @@ static int omap2_mbox_fifo_full(struct mailbox *mbox)
return mbox_read_reg(fifo->fifo_stat);
}
+static int ompa2_mbox_poll_for_space(struct mailbox *mbox)
+{
+ if (omap2_mbox_fifo_full(mbox))
+ return -1;
+
+ return 0;
+}
+
/* Mailbox IRQ handle functions */
static void omap2_mbox_enable_irq(struct mailbox *mbox,
mailbox_type_t irq)
@@ -210,10 +218,10 @@ static struct mailbox_ops omap2_mbox_ops = {
.type = MBOX_HW_FIFO2_TYPE,
.startup = omap2_mbox_startup,
.shutdown = omap2_mbox_shutdown,
- .fifo_read = omap2_mbox_fifo_read,
- .fifo_write = omap2_mbox_fifo_write,
- .fifo_empty = omap2_mbox_fifo_empty,
- .fifo_full = omap2_mbox_fifo_full,
+ .read = omap2_mbox_fifo_read,
+ .write = omap2_mbox_fifo_write,
+ .empty = omap2_mbox_fifo_empty,
+ .poll_for_space = ompa2_mbox_poll_for_space,
.enable_irq = omap2_mbox_enable_irq,
.disable_irq = omap2_mbox_disable_irq,
.ack_irq = omap2_mbox_ack_irq,
diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c
index 8b7d7bd..c0a8e49 100644
--- a/drivers/mailbox/mailbox.c
+++ b/drivers/mailbox/mailbox.c
@@ -45,21 +45,17 @@ MODULE_PARM_DESC(mbox_kfifo_size, "Size of mailbox kfifo (bytes)");
/* Mailbox FIFO handle functions */
-static inline mbox_msg_t mbox_fifo_read(struct mailbox *mbox, struct mailbox_msg *msg)
+static inline mbox_msg_t mbox_read(struct mailbox *mbox, struct mailbox_msg *msg)
{
- return mbox->ops->fifo_read(mbox, msg);
+ return mbox->ops->read(mbox, msg);
}
-static inline void mbox_fifo_write(struct mailbox *mbox, struct mailbox_msg *msg)
+static inline void mbox_write(struct mailbox *mbox, struct mailbox_msg *msg)
{
- mbox->ops->fifo_write(mbox, msg);
+ mbox->ops->write(mbox, msg);
}
-static inline int mbox_fifo_empty(struct mailbox *mbox)
+static inline int mbox_empty(struct mailbox *mbox)
{
- return mbox->ops->fifo_empty(mbox);
-}
-static inline int mbox_fifo_full(struct mailbox *mbox)
-{
- return mbox->ops->fifo_full(mbox);
+ return mbox->ops->empty(mbox);
}
/* Mailbox IRQ handle functions */
@@ -78,16 +74,7 @@ static inline int is_mbox_irq(struct mailbox *mbox, mailbox_irq_t irq)
*/
static int __mbox_poll_for_space(struct mailbox *mbox)
{
- int ret = 0, i = 1000;
-
- while (mbox_fifo_full(mbox)) {
- if (mbox->ops->type == MBOX_HW_FIFO2_TYPE)
- return -1;
- if (--i == 0)
- return -1;
- udelay(1);
- }
- return ret;
+ return mbox->ops->poll_for_space(mbox);
}
int mailbox_msg_send(struct mailbox *mbox, struct mailbox_msg *msg)
@@ -103,7 +90,7 @@ int mailbox_msg_send(struct mailbox *mbox, struct mailbox_msg *msg)
}
if (kfifo_is_empty(&mq->fifo) && !__mbox_poll_for_space(mbox)) {
- mbox_fifo_write(mbox, msg);
+ mbox_write(mbox, msg);
goto out;
}
@@ -182,7 +169,7 @@ static void mbox_tx_tasklet(unsigned long tx_data)
msg.pdata = tx_data_buf;
}
- mbox_fifo_write(mbox, &msg);
+ mbox_write(mbox, &msg);
}
}
@@ -236,7 +223,7 @@ static void __mbox_rx_interrupt(struct mailbox *mbox)
struct mailbox_msg msg;
int len;
- while (!mbox_fifo_empty(mbox)) {
+ while (!mbox_empty(mbox)) {
if (unlikely(kfifo_avail(&mq->fifo) <
(sizeof(msg) + CONFIG_MBOX_DATA_SIZE))) {
mailbox_disable_irq(mbox, IRQ_RX);
@@ -244,7 +231,7 @@ static void __mbox_rx_interrupt(struct mailbox *mbox)
goto nomem;
}
- mbox_fifo_read(mbox, &msg);
+ mbox_read(mbox, &msg);
len = kfifo_in(&mq->fifo, (unsigned char *)&msg, sizeof(msg));
WARN_ON(len != sizeof(msg));
@@ -254,9 +241,6 @@ static void __mbox_rx_interrupt(struct mailbox *mbox)
msg.size);
WARN_ON(len != msg.size);
}
-
- if (mbox->ops->type == MBOX_HW_FIFO1_TYPE)
- break;
}
/* no more messages in the fifo. clear IRQ source. */
diff --git a/drivers/mailbox/mailbox.h b/drivers/mailbox/mailbox.h
index 0a31c99..f103194 100644
--- a/drivers/mailbox/mailbox.h
+++ b/drivers/mailbox/mailbox.h
@@ -11,18 +11,19 @@
#include <linux/mailbox.h>
typedef int __bitwise mailbox_type_t;
-#define MBOX_HW_FIFO1_TYPE ((__force mailbox_type_t) 1)
-#define MBOX_HW_FIFO2_TYPE ((__force mailbox_type_t) 2)
+#define MBOX_HW_FIFO1_TYPE ((__force mailbox_type_t) 1)
+#define MBOX_HW_FIFO2_TYPE ((__force mailbox_type_t) 2)
+#define MBOX_SHARED_MEM_TYPE ((__force mailbox_type_t) 3)
struct mailbox_ops {
mailbox_type_t type;
int (*startup)(struct mailbox *mbox);
void (*shutdown)(struct mailbox *mbox);
/* fifo */
- mbox_msg_t (*fifo_read)(struct mailbox *mbox, struct mailbox_msg *msg);
- int (*fifo_write)(struct mailbox *mbox, struct mailbox_msg *msg);
- int (*fifo_empty)(struct mailbox *mbox);
- int (*fifo_full)(struct mailbox *mbox);
+ int (*read)(struct mailbox *mbox, struct mailbox_msg *msg);
+ int (*write)(struct mailbox *mbox, struct mailbox_msg *msg);
+ int (*empty)(struct mailbox *mbox);
+ int (*poll_for_space)(struct mailbox *mbox);
/* irq */
void (*enable_irq)(struct mailbox *mbox,
mailbox_irq_t irq);
@@ -47,6 +48,7 @@ struct mailbox_queue {
struct mailbox {
char *name;
+ unsigned int id;
unsigned int irq;
struct mailbox_queue *txq, *rxq;
struct mailbox_ops *ops;
--
1.7.11.1
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH 7/9] mailbox: add IRQF_NO_SUSPEND flag
2012-12-18 13:10 [PATCH 0/9] drivers: mailbox: framework creation Loic Pallardy
` (5 preceding siblings ...)
2012-12-18 13:10 ` [PATCH 6/9] mailbox: add shared memory mailbox type Loic Pallardy
@ 2012-12-18 13:10 ` Loic Pallardy
2012-12-18 13:10 ` [PATCH 8/9] mailbox: add no_irq send message Loic Pallardy
` (2 subsequent siblings)
9 siblings, 0 replies; 31+ messages in thread
From: Loic Pallardy @ 2012-12-18 13:10 UTC (permalink / raw)
To: linux-arm-kernel
Coprocessor must be accessible during suspend transitions.
Signed-off-by: Loic Pallardy <loic.pallardy@st.com>
---
drivers/mailbox/mailbox.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c
index c0a8e49..57cb566 100644
--- a/drivers/mailbox/mailbox.c
+++ b/drivers/mailbox/mailbox.c
@@ -311,7 +311,8 @@ static int mailbox_startup(struct mailbox *mbox)
}
if (!mbox->use_count++) {
- ret = request_irq(mbox->irq, mbox_interrupt, IRQF_SHARED,
+ ret = request_irq(mbox->irq, mbox_interrupt,
+ IRQF_SHARED | IRQF_NO_SUSPEND,
mbox->name, mbox);
if (unlikely(ret)) {
pr_err("failed to register mailbox interrupt:%d\n",
--
1.7.11.1
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH 8/9] mailbox: add no_irq send message
2012-12-18 13:10 [PATCH 0/9] drivers: mailbox: framework creation Loic Pallardy
` (6 preceding siblings ...)
2012-12-18 13:10 ` [PATCH 7/9] mailbox: add IRQF_NO_SUSPEND flag Loic Pallardy
@ 2012-12-18 13:10 ` Loic Pallardy
2012-12-18 13:10 ` [PATCH 9/9] mailbox: create dbx500 mailbox driver Loic Pallardy
2012-12-20 18:16 ` [PATCH 0/9] drivers: mailbox: framework creation Linus Walleij
9 siblings, 0 replies; 31+ messages in thread
From: Loic Pallardy @ 2012-12-18 13:10 UTC (permalink / raw)
To: linux-arm-kernel
For debug purpose, mailbox must be available when
interrupts are disabled to collect dump information.
Signed-off-by: Loic Pallardy <loic.pallardy@st.com>
---
drivers/mailbox/mailbox.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++
include/linux/mailbox.h | 3 +++
2 files changed, 69 insertions(+)
diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c
index 57cb566..2f50226 100644
--- a/drivers/mailbox/mailbox.c
+++ b/drivers/mailbox/mailbox.c
@@ -110,6 +110,72 @@ out:
}
EXPORT_SYMBOL(mailbox_msg_send);
+#define TRANSFER_TIMEOUT 30000 /* Becomes ~3s timeout */
+
+static struct mailbox_msg no_irq_msg_res;
+
+struct mailbox_msg *mailbox_msg_send_receive_no_irq(struct mailbox *mbox,
+ struct mailbox_msg *msg)
+{
+ int ret = 0;
+ int count = 0;
+
+ BUG_ON(!irqs_disabled());
+
+ if (likely(mbox->ops->write && mbox->ops->read)) {
+ if (__mbox_poll_for_space(mbox)) {
+ ret = -EBUSY;
+ goto out;
+ }
+ mbox->ops->write(mbox, msg);
+ while (!is_mbox_irq(mbox, IRQ_RX)) {
+ udelay(100);
+ cpu_relax();
+ count++;
+ if (count > TRANSFER_TIMEOUT) {
+ pr_err("%s: Error: transfer timed out\n",
+ __func__);
+ ret = -EINVAL;
+ goto out;
+ }
+ }
+ mbox->ops->read(mbox, &no_irq_msg_res);
+ ack_mbox_irq(mbox, IRQ_RX);
+ } else {
+ ret = -EINVAL;
+ }
+
+out:
+ BUG_ON(ret < 0);
+
+ return &no_irq_msg_res;
+}
+EXPORT_SYMBOL(mailbox_msg_send_receive_no_irq);
+
+int mailbox_msg_send_no_irq(struct mailbox *mbox,
+ struct mailbox_msg *msg)
+{
+ int ret = 0;
+
+ BUG_ON(!irqs_disabled());
+
+ if (likely(mbox->ops->write)) {
+ if (__mbox_poll_for_space(mbox)) {
+ ret = -EBUSY;
+ goto out;
+ }
+ mbox->ops->write(mbox, msg);
+ } else {
+ ret = -EINVAL;
+ }
+
+out:
+ WARN_ON(ret < 0);
+
+ return ret;
+}
+EXPORT_SYMBOL(mailbox_msg_send_no_irq);
+
void mailbox_save_ctx(struct mailbox *mbox)
{
if (!mbox->ops->save_ctx) {
diff --git a/include/linux/mailbox.h b/include/linux/mailbox.h
index d256e1a..3f9ec1e 100644
--- a/include/linux/mailbox.h
+++ b/include/linux/mailbox.h
@@ -23,6 +23,9 @@ struct mailbox_msg {
MAILBOX_FILL_MSG(_msg, _header, NULL, 0);
int mailbox_msg_send(struct mailbox *, struct mailbox_msg *msg);
+struct mailbox_msg *mailbox_msg_send_receive_no_irq(struct mailbox *,
+ struct mailbox_msg *msg);
+int mailbox_msg_send_no_irq(struct mailbox *, struct mailbox_msg *msg);
struct mailbox *mailbox_get(const char *, struct notifier_block *nb);
void mailbox_put(struct mailbox *mbox, struct notifier_block *nb);
--
1.7.11.1
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH 9/9] mailbox: create dbx500 mailbox driver
2012-12-18 13:10 [PATCH 0/9] drivers: mailbox: framework creation Loic Pallardy
` (7 preceding siblings ...)
2012-12-18 13:10 ` [PATCH 8/9] mailbox: add no_irq send message Loic Pallardy
@ 2012-12-18 13:10 ` Loic Pallardy
2012-12-20 18:16 ` [PATCH 0/9] drivers: mailbox: framework creation Linus Walleij
9 siblings, 0 replies; 31+ messages in thread
From: Loic Pallardy @ 2012-12-18 13:10 UTC (permalink / raw)
To: linux-arm-kernel
Add STEriccson DBX500 PRCM mailbox support.
Signed-off-by: Loic Pallardy <loic.pallardy@st.com>
---
drivers/mailbox/Kconfig | 18 +-
drivers/mailbox/Makefile | 1 +
drivers/mailbox/mailbox-dbx500.c | 601 +++++++++++++++++++++++++++
include/linux/platform_data/mailbox-dbx500.h | 13 +
4 files changed, 627 insertions(+), 6 deletions(-)
create mode 100644 drivers/mailbox/mailbox-dbx500.c
create mode 100644 include/linux/platform_data/mailbox-dbx500.h
diff --git a/drivers/mailbox/Kconfig b/drivers/mailbox/Kconfig
index efb766f..9246e67 100644
--- a/drivers/mailbox/Kconfig
+++ b/drivers/mailbox/Kconfig
@@ -24,14 +24,20 @@ config OMAP2PLUS_MBOX
OMAP2/3; or IPU, IVA HD and DSP in OMAP4. Say Y here if you want
to use OMAP2+ Mailbox framework support.
+config DBX500_MBOX
+ tristate "DBx500 Mailbox driver support"
+ depends on ARCH_U8500
+ help
+ Say Y here if you want to use DBx500 Mailbox driver support for
+ power coprocessor access on Ux500 and Ux540 families
config MBOX_KFIFO_SIZE
- int "Mailbox kfifo default buffer size (bytes)"
- 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).
+ int "Mailbox kfifo default buffer size (bytes)"
+ 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 MBOX_DATA_SIZE
int "Mailbox associated data max size (bytes)"
diff --git a/drivers/mailbox/Makefile b/drivers/mailbox/Makefile
index 4085b71..c04ce79 100644
--- a/drivers/mailbox/Makefile
+++ b/drivers/mailbox/Makefile
@@ -2,3 +2,4 @@ obj-$(CONFIG_MAILBOX) += mailbox.o
obj-$(CONFIG_OMAP1_MBOX) += mailbox-omap1.o
obj-$(CONFIG_OMAP2PLUS_MBOX) += mailbox-omap2.o
+obj-$(CONFIG_DBX500_MBOX) += mailbox-dbx500.o
diff --git a/drivers/mailbox/mailbox-dbx500.c b/drivers/mailbox/mailbox-dbx500.c
new file mode 100644
index 0000000..030e1eb
--- /dev/null
+++ b/drivers/mailbox/mailbox-dbx500.c
@@ -0,0 +1,601 @@
+/*
+ * Copyright (C) ST-Ericsson SA 2012
+ *
+ * License Terms: GNU General Public License v2
+ * Author: Loic Pallardy <loic.pallardy@st.com> for ST-Ericsson
+ * DBX500 PRCM Mailbox driver
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/err.h>
+#include <linux/platform_device.h>
+#include <linux/irq.h>
+#include <linux/io.h>
+#include <linux/platform_data/mailbox-dbx500.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+
+#include "mailbox.h"
+
+#define MAILBOX_LEGACY 0
+#define MAILBOX_UPAP 1
+
+enum {
+ MAILBOX_BLOCKING,
+ MAILBOX_ATOMIC,
+};
+
+/* CPU mailbox registers */
+#define PRCM_MBOX_CPU_VAL 0x0fc
+#define PRCM_MBOX_CPU_SET 0x100
+#define PRCM_MBOX_CPU_CLR 0x104
+
+#define PRCM_ARM_IT1_CLR 0x48C
+#define PRCM_ARM_IT1_VAL 0x494
+
+#define NUM_MB 8
+#define MBOX_BIT BIT
+#define ALL_MBOX_BITS (MBOX_BIT(NUM_MB) - 1)
+
+/* CPU mailbox share memory */
+#define _PRCM_MBOX_HEADER 0x214 /* 16 bytes */
+#define PRCM_MBOX_HEADER_REQ_MB0 (_PRCM_MBOX_HEADER + 0x0)
+#define PRCM_MBOX_HEADER_REQ_MB1 (_PRCM_MBOX_HEADER + 0x1)
+#define PRCM_MBOX_HEADER_REQ_MB2 (_PRCM_MBOX_HEADER + 0x2)
+#define PRCM_MBOX_HEADER_REQ_MB3 (_PRCM_MBOX_HEADER + 0x3)
+#define PRCM_MBOX_HEADER_REQ_MB4 (_PRCM_MBOX_HEADER + 0x4)
+#define PRCM_MBOX_HEADER_REQ_MB5 (_PRCM_MBOX_HEADER + 0x5)
+#define PRCM_MBOX_HEADER_ACK_MB0 (_PRCM_MBOX_HEADER + 0x8)
+
+/* Req Mailboxes */
+#define PRCM_REQ_MB0 0x208 /* 12 bytes */
+#define PRCM_REQ_MB1 0x1FC /* 12 bytes */
+#define PRCM_REQ_MB2 0x1EC /* 16 bytes */
+#define PRCM_REQ_MB3 0x78 /* 372 bytes */
+#define PRCM_REQ_MB4 0x74 /* 4 bytes */
+#define PRCM_REQ_MB5 0x70 /* 4 bytes */
+#define PRCM_REQ_PASR 0x30 /* 4 bytes */
+
+/* Ack Mailboxes */
+#define PRCM_ACK_MB0 0x34 /* 52 bytes */
+#define PRCM_ACK_MB1 0x30 /* 4 bytes */
+#define PRCM_ACK_MB2 0x2C /* 4 bytes */
+#define PRCM_ACK_MB3 0x28 /* 4 bytes */
+#define PRCM_ACK_MB4 0x24 /* 4 bytes */
+#define PRCM_ACK_MB5 0x20 /* 4 bytes */
+
+/* Ack Mailboxe sizes */
+#define PRCM_ACK_MB0_SIZE 0x24 /* 52 bytes */
+#define PRCM_ACK_MB1_SIZE 0x4 /* 4 bytes */
+#define PRCM_ACK_MB2_SIZE 0x1 /* 1 bytes */
+#define PRCM_ACK_MB3_SIZE 0x2 /* 2 bytes */
+#define PRCM_ACK_MB4_SIZE 0x0 /* 0 bytes */
+#define PRCM_ACK_MB5_SIZE 0x4 /* 4 bytes */
+
+static void __iomem *mbox_base;
+static void __iomem *tdcm_mem_base;
+static int mbox_irq_base;
+
+static u8 prcm_mbox_irq_mask; /* masked by default */
+static DEFINE_SPINLOCK(prcm_mbox_irqs_lock);
+
+#define ACK_MAX_SIZE 0x40
+
+struct dbx500_mbox_priv {
+ int access_mode;
+ int type;
+ int header_size;
+ unsigned int tx_header_offset;
+ unsigned int rx_header_offset;
+ unsigned int tx_offset;
+ unsigned int rx_offset;
+ unsigned int rx_size;
+ bool empty_flag;
+};
+
+static inline unsigned int mbox_read_reg(size_t ofs)
+{
+ return __raw_readl(mbox_base + ofs);
+}
+
+static inline void mbox_write_reg(u32 val, size_t ofs)
+{
+ __raw_writel(val, mbox_base + ofs);
+}
+
+/* Mailbox H/W preparations */
+static struct irq_chip dbx500_mbox_irq_chip;
+
+static int dbx500_mbox_startup(struct mailbox *mbox)
+{
+ unsigned int i;
+
+ /* Initalize irqs. */
+ for (i = 0; i < NUM_MB; i++) {
+ unsigned int irq;
+
+ irq = mbox_irq_base + i;
+ irq_set_chip_and_handler(irq, &dbx500_mbox_irq_chip,
+ handle_simple_irq);
+ set_irq_flags(irq, IRQF_VALID);
+ }
+ return 0;
+}
+
+/* Mailbox IRQ handle functions */
+
+static void dbx500_mbox_enable_irq(struct mailbox *mbox, mailbox_irq_t irq)
+{
+ unsigned long flags;
+
+ spin_lock_irqsave(&prcm_mbox_irqs_lock, flags);
+
+ prcm_mbox_irq_mask |= MBOX_BIT(mbox->id);
+
+ spin_unlock_irqrestore(&prcm_mbox_irqs_lock, flags);
+
+}
+
+static void dbx500_mbox_disable_irq(struct mailbox *mbox, mailbox_irq_t irq)
+{
+ unsigned long flags;
+
+ spin_lock_irqsave(&prcm_mbox_irqs_lock, flags);
+
+ prcm_mbox_irq_mask &= ~MBOX_BIT(mbox->id);
+
+ spin_unlock_irqrestore(&prcm_mbox_irqs_lock, flags);
+
+}
+
+static void dbx500_mbox_ack_irq(struct mailbox *mbox, mailbox_irq_t irq)
+{
+ if (irq == IRQ_RX)
+ mbox_write_reg(MBOX_BIT(mbox->id), PRCM_ARM_IT1_CLR);
+}
+
+static int dbx500_mbox_is_irq(struct mailbox *mbox, mailbox_irq_t irq)
+{
+ struct dbx500_mbox_priv *priv = (struct dbx500_mbox_priv *)mbox->priv;
+ if (irq == IRQ_RX) {
+ if (mbox_read_reg(PRCM_ARM_IT1_VAL) & MBOX_BIT(mbox->id)) {
+ priv->empty_flag = true;
+ return 1;
+ } else {
+ return 0;
+ }
+ } else {
+ return 0;
+ }
+}
+
+/* message management */
+
+static int dbx500_mbox_is_ready(struct mailbox *mbox)
+{
+ return mbox_read_reg(PRCM_MBOX_CPU_VAL) & MBOX_BIT(mbox->id);
+}
+
+static int dbx500_mbox_write(struct mailbox *mbox,
+ struct mailbox_msg *msg)
+{
+ int j;
+ struct dbx500_mbox_priv *priv = (struct dbx500_mbox_priv *)mbox->priv;
+
+ if (msg->size && !msg->pdata)
+ return -EINVAL;
+
+ while (dbx500_mbox_is_ready(mbox))
+ cpu_relax();
+
+ /* write header */
+ if (priv->header_size)
+ writeb(msg->header, tdcm_mem_base + priv->tx_header_offset);
+
+ /* write data */
+ for (j = 0; j < msg->size; j++)
+ writeb(((unsigned char *)msg->pdata)[j],
+ tdcm_mem_base + priv->tx_offset + j);
+
+ /* send event */
+ mbox_write_reg(MBOX_BIT(mbox->id), PRCM_MBOX_CPU_SET);
+
+ return 0;
+}
+
+static int dbx500_mbox_read(struct mailbox *mbox, struct mailbox_msg *msg)
+{
+ struct dbx500_mbox_priv *priv = (struct dbx500_mbox_priv *)mbox->priv;
+
+ msg->header = readb(tdcm_mem_base + priv->rx_header_offset);
+ msg->pdata = (unsigned char *)(tdcm_mem_base + priv->rx_offset);
+
+ msg->size = priv->rx_size;
+ priv->empty_flag = false;
+ return 0;
+}
+
+static int dbx500_mbox_empty(struct mailbox *mbox)
+{
+ struct dbx500_mbox_priv *priv = (struct dbx500_mbox_priv *)mbox->priv;
+ if (priv->empty_flag)
+ return 0;
+ else
+ return 1;
+}
+
+static int dbx500_mbox_poll_for_space(struct mailbox *mbox)
+{
+ return 0;
+}
+/* interrupt management */
+
+/* mask/unmask must be managed by SW */
+
+static void mbox_irq_mask(struct irq_data *d)
+{
+ unsigned long flags;
+
+ spin_lock_irqsave(&prcm_mbox_irqs_lock, flags);
+
+ prcm_mbox_irq_mask &= ~MBOX_BIT(d->irq - mbox_irq_base);
+
+ spin_unlock_irqrestore(&prcm_mbox_irqs_lock, flags);
+}
+
+static void mbox_irq_unmask(struct irq_data *d)
+{
+ unsigned long flags;
+
+ spin_lock_irqsave(&prcm_mbox_irqs_lock, flags);
+
+ prcm_mbox_irq_mask |= MBOX_BIT(d->irq - mbox_irq_base);
+
+ spin_unlock_irqrestore(&prcm_mbox_irqs_lock, flags);
+}
+
+static void mbox_irq_ack(struct irq_data *d)
+{
+ mbox_write_reg(MBOX_BIT(d->irq - mbox_irq_base), PRCM_ARM_IT1_CLR);
+}
+
+static struct irq_chip dbx500_mbox_irq_chip = {
+ .name = "dbx500_mbox",
+ .irq_disable = mbox_irq_unmask,
+ .irq_ack = mbox_irq_ack,
+ .irq_mask = mbox_irq_mask,
+ .irq_unmask = mbox_irq_unmask,
+};
+
+static irqreturn_t dbx500_mbox_irq_handler(int irq, void *data)
+{
+ u32 bits;
+ u8 n;
+
+ bits = (mbox_read_reg(PRCM_ARM_IT1_VAL) & ALL_MBOX_BITS);
+ if (unlikely(!bits))
+ return IRQ_NONE;
+
+ bits &= prcm_mbox_irq_mask;
+
+ for (n = 0; bits; n++) {
+ if (bits & MBOX_BIT(n)) {
+ bits -= MBOX_BIT(n);
+ generic_handle_irq(mbox_irq_base + n);
+ }
+ }
+ return IRQ_HANDLED;
+}
+
+/* 5 mailboxes AP <--> PRCMU */
+static struct mailbox_ops dbx500_mbox_ops = {
+ .type = MBOX_SHARED_MEM_TYPE,
+ .startup = dbx500_mbox_startup,
+ .enable_irq = dbx500_mbox_enable_irq,
+ .disable_irq = dbx500_mbox_disable_irq,
+ .ack_irq = dbx500_mbox_ack_irq,
+ .is_irq = dbx500_mbox_is_irq,
+ .read = dbx500_mbox_read,
+ .write = dbx500_mbox_write,
+ .empty = dbx500_mbox_empty,
+ .poll_for_space = dbx500_mbox_poll_for_space,
+};
+
+struct dbx500_mbox_priv mbox0_priv = {
+ .access_mode = MAILBOX_ATOMIC,
+ .type = MAILBOX_LEGACY,
+ .tx_header_offset = PRCM_MBOX_HEADER_REQ_MB0,
+ .header_size = 1,
+ .tx_offset = PRCM_REQ_MB0,
+ .rx_header_offset = PRCM_MBOX_HEADER_ACK_MB0,
+ .rx_offset = PRCM_ACK_MB0,
+ .rx_size = PRCM_ACK_MB0_SIZE,
+};
+
+struct mailbox mbox0_info = {
+ .name = "mbox0",
+ .id = 0,
+ .ops = &dbx500_mbox_ops,
+ .priv = &mbox0_priv,
+};
+
+struct dbx500_mbox_priv mbox1_priv = {
+ .access_mode = MAILBOX_BLOCKING,
+ .type = MAILBOX_LEGACY,
+ .tx_header_offset = PRCM_MBOX_HEADER_REQ_MB1,
+ .header_size = 1,
+ .tx_offset = PRCM_REQ_MB1,
+ .rx_header_offset = PRCM_MBOX_HEADER_REQ_MB1,
+ .rx_offset = PRCM_ACK_MB1,
+ .rx_size = PRCM_ACK_MB1_SIZE,
+};
+
+struct mailbox mbox1_info = {
+ .name = "mbox1",
+ .id = 1,
+ .ops = &dbx500_mbox_ops,
+ .priv = &mbox1_priv,
+};
+
+struct dbx500_mbox_priv mbox2_priv = {
+ .access_mode = MAILBOX_BLOCKING,
+ .type = MAILBOX_LEGACY,
+ .tx_header_offset = PRCM_MBOX_HEADER_REQ_MB2,
+ .header_size = 1,
+ .tx_offset = PRCM_REQ_MB2,
+ .rx_header_offset = PRCM_MBOX_HEADER_REQ_MB2,
+ .rx_offset = PRCM_ACK_MB2,
+ .rx_size = PRCM_ACK_MB2_SIZE,
+};
+
+struct mailbox mbox2_info = {
+ .name = "mbox2",
+ .id = 2,
+ .ops = &dbx500_mbox_ops,
+ .priv = &mbox2_priv,
+};
+
+struct dbx500_mbox_priv mbox3_priv = {
+ .access_mode = MAILBOX_BLOCKING,
+ .type = MAILBOX_LEGACY,
+ .tx_header_offset = PRCM_MBOX_HEADER_REQ_MB3,
+ .header_size = 1,
+ .tx_offset = PRCM_REQ_MB3,
+ .rx_header_offset = PRCM_MBOX_HEADER_REQ_MB3,
+ .rx_offset = PRCM_ACK_MB3,
+ .rx_size = PRCM_ACK_MB3_SIZE,
+};
+
+struct mailbox mbox3_info = {
+ .name = "mbox3",
+ .id = 3,
+ .ops = &dbx500_mbox_ops,
+ .priv = &mbox3_priv,
+};
+
+struct dbx500_mbox_priv mbox4_priv = {
+ .access_mode = MAILBOX_BLOCKING,
+ .type = MAILBOX_LEGACY,
+ .tx_header_offset = PRCM_MBOX_HEADER_REQ_MB4,
+ .header_size = 1,
+ .tx_offset = PRCM_REQ_MB4,
+ .rx_header_offset = PRCM_MBOX_HEADER_REQ_MB4,
+ .rx_offset = PRCM_ACK_MB4,
+ .rx_size = PRCM_ACK_MB4_SIZE,
+};
+
+struct mailbox mbox4_info = {
+ .name = "mbox4",
+ .id = 4,
+ .ops = &dbx500_mbox_ops,
+ .priv = &mbox4_priv,
+};
+
+struct dbx500_mbox_priv mbox5_priv = {
+ .access_mode = MAILBOX_BLOCKING,
+ .type = MAILBOX_LEGACY,
+ .tx_header_offset = PRCM_MBOX_HEADER_REQ_MB5,
+ .header_size = 1,
+ .tx_offset = PRCM_REQ_MB5,
+ .rx_header_offset = PRCM_MBOX_HEADER_REQ_MB5,
+ .rx_offset = PRCM_ACK_MB5,
+ .rx_size = PRCM_ACK_MB5_SIZE,
+};
+
+struct mailbox mbox5_info = {
+ .name = "mbox5",
+ .id = 5,
+ .ops = &dbx500_mbox_ops,
+ .priv = &mbox5_priv,
+};
+
+struct mailbox mbox6_info = {
+ .name = "mbox6",
+ .id = 6,
+ .ops = &dbx500_mbox_ops,
+};
+
+struct mailbox mbox7_info = {
+ .name = "mbox7",
+ .id = 7,
+ .ops = &dbx500_mbox_ops,
+};
+
+/* x540 mailbox definition */
+struct dbx500_mbox_priv mbox1_upap_priv = {
+ .access_mode = MAILBOX_BLOCKING,
+ .type = MAILBOX_UPAP,
+ .tx_header_offset = 0,
+ .header_size = 0,
+ .tx_offset = 0,
+ .rx_offset = 0, /* TODO to be replaced by dynamic detection */
+ .rx_size = 0x40,
+};
+
+struct mailbox mbox1_upap_info = {
+ .name = "mbox1_upap",
+ .id = 1,
+ .ops = &dbx500_mbox_ops,
+ .priv = &mbox1_upap_priv,
+};
+
+struct mailbox *db8500_mboxes[] = { &mbox0_info, &mbox1_info, &mbox2_info,
+ &mbox3_info, &mbox4_info, &mbox5_info, &mbox6_info, &mbox7_info,
+ NULL };
+
+struct mailbox *db9540_mboxes[] = { &mbox0_info, &mbox2_info,
+ &mbox3_info, &mbox4_info, &mbox5_info, &mbox6_info, &mbox7_info,
+ &mbox1_upap_info, NULL };
+
+static const struct of_device_id dbx500_mailbox_match[] = {
+ { .compatible = "stericsson,db8500-mailbox",
+ .data = (void *)db8500_mboxes,
+ },
+ { .compatible = "stericsson,db9540-mailbox",
+ .data = (void *)db9540_mboxes,
+ },
+ { /* sentinel */}
+};
+
+static int __devinit dbx500_mbox_probe(struct platform_device *pdev)
+{
+ const struct platform_device_id *platid = platform_get_device_id(pdev);
+ struct resource *mem;
+ int ret, i, legacy_offset = 0, upap_offset;
+ struct mailbox **list;
+ int irq;
+ struct dbx500_plat_data *pdata = dev_get_platdata(&pdev->dev);
+ struct device_node *np = pdev->dev.of_node;
+
+ if (!pdata) {
+ if (np) {
+ of_property_read_u32(np, "legacy-offset", &legacy_offset);
+ of_property_read_u32(np, "upap-offset", &upap_offset);
+ list = (struct mailbox **)of_match_device(
+ dbx500_mailbox_match, &pdev->dev)->data;
+ if (!list) {
+ /* No mailbox configuration */
+ dev_err(&pdev->dev, "No configuration found\n");
+ return -ENODEV;
+ }
+ } else {
+ /* No mailbox configuration */
+ dev_err(&pdev->dev, "No configuration found\n");
+ return -ENODEV;
+ }
+ } else {
+ list = (struct mailbox **)platid->driver_data;
+ legacy_offset = pdata->legacy_offset;
+ upap_offset = pdata->upap_offset;
+ }
+
+ mem = platform_get_resource_byname(pdev, IORESOURCE_MEM, "prcm_reg");
+ mbox_base = devm_ioremap(&pdev->dev, mem->start, resource_size(mem));
+ if (!mbox_base) {
+ ret = -ENOMEM;
+ goto out;
+ }
+
+ mem = platform_get_resource_byname(pdev, IORESOURCE_MEM, "prcmu_tdcm");
+ tdcm_mem_base = devm_ioremap(&pdev->dev, mem->start, resource_size(mem));
+ if (!tdcm_mem_base) {
+ ret = -ENOMEM;
+ goto out;
+ }
+
+ irq = platform_get_irq(pdev, 0);
+ /* clean all mailboxes */
+ mbox_write_reg(ALL_MBOX_BITS, PRCM_ARM_IT1_CLR);
+ ret = request_irq(irq, dbx500_mbox_irq_handler,
+ IRQF_NO_SUSPEND, "db8500_mbox", NULL);
+ if (ret) {
+ ret = -EINVAL;
+ goto out;
+ }
+
+ /* get mbox irq base */
+ mbox_irq_base = irq_alloc_descs(-1, 0, 8, -1);
+ if (mbox_irq_base < 0) {
+ dev_err(&pdev->dev, "Impossible to get mbox irq base\n");
+ ret = -ENODEV;
+ goto irq_free;
+ }
+
+ /*
+ * Update mailbox shared memory buffer offset according to mailbox
+ * type
+ */
+ for (i = 0; list[i]; i++) {
+ struct mailbox *mbox = list[i];
+ struct dbx500_mbox_priv *priv =
+ (struct dbx500_mbox_priv *)mbox->priv;
+ if (!priv)
+ continue;
+ if (priv->type == MAILBOX_LEGACY) {
+ priv->rx_offset += legacy_offset;
+ priv->rx_header_offset += legacy_offset;
+ priv->tx_offset += legacy_offset;
+ priv->tx_header_offset += legacy_offset;
+ } else if (priv->type == MAILBOX_UPAP) {
+ priv->tx_offset += upap_offset;
+ priv->rx_offset += upap_offset;
+ }
+ mbox->irq = mbox_irq_base + mbox->id;
+ }
+
+ ret = mailbox_register(&pdev->dev, list);
+irq_free:
+ if (ret)
+ free_irq(irq, NULL);
+
+out:
+ return ret;
+}
+
+static int __devexit dbx500_mbox_remove(struct platform_device *pdev)
+{
+ mailbox_unregister();
+ iounmap(mbox_base);
+ return 0;
+}
+
+static const struct platform_device_id dbx500_mbox_id[] = {
+ {
+ .name = "db8500-mailbox",
+ .driver_data = (unsigned long) db8500_mboxes,
+ }, {
+ .name = "db9540-mailbox",
+ .driver_data = (unsigned long) db9540_mboxes,
+ }, {
+ /* sentinel */
+ }
+};
+
+static struct platform_driver dbx500_mbox_driver = {
+ .probe = dbx500_mbox_probe,
+ .remove = __devexit_p(dbx500_mbox_remove),
+ .driver = {
+ .name = "dbx500-mailbox",
+ .of_match_table = dbx500_mailbox_match,
+ },
+ .id_table = dbx500_mbox_id,
+};
+
+static int __init dbx500_mbox_init(void)
+{
+ return platform_driver_register(&dbx500_mbox_driver);
+}
+
+static void __exit dbx500_mbox_exit(void)
+{
+ platform_driver_unregister(&dbx500_mbox_driver);
+}
+
+postcore_initcall(dbx500_mbox_init);
+module_exit(dbx500_mbox_exit);
+
+MODULE_LICENSE("GPL v2");
+MODULE_DESCRIPTION("ST-Ericsson mailbox: dbx500 architecture specific functions");
+MODULE_AUTHOR("Loic Pallardy <loic.pallardy@st.com>");
+MODULE_ALIAS("platform:dbx500-mailbox");
diff --git a/include/linux/platform_data/mailbox-dbx500.h b/include/linux/platform_data/mailbox-dbx500.h
new file mode 100644
index 0000000..bf8789c
--- /dev/null
+++ b/include/linux/platform_data/mailbox-dbx500.h
@@ -0,0 +1,13 @@
+/*
+ * mailbox-dbx500.h
+ *
+ * Copyright (C) ST-Ericsson SA 2012
+ * Author: <loic.pallardy@st.com> for ST-Ericsson.
+ * License terms: GNU General Public License (GPL), version 2
+ */
+
+struct dbx500_plat_data {
+ unsigned int legacy_offset;
+ unsigned int upap_offset;
+};
+
--
1.7.11.1
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH 0/9] drivers: mailbox: framework creation
2012-12-18 13:10 [PATCH 0/9] drivers: mailbox: framework creation Loic Pallardy
` (8 preceding siblings ...)
2012-12-18 13:10 ` [PATCH 9/9] mailbox: create dbx500 mailbox driver Loic Pallardy
@ 2012-12-20 18:16 ` Linus Walleij
2012-12-20 18:28 ` Tony Lindgren
9 siblings, 1 reply; 31+ messages in thread
From: Linus Walleij @ 2012-12-20 18:16 UTC (permalink / raw)
To: linux-arm-kernel
On Tue, Dec 18, 2012 at 2:10 PM, Loic Pallardy
<loic.pallardy-ext@stericsson.com> wrote:
> OMAP and ST-Ericsson platforms are both using mailbox to communicate
> with some coprocessors.
> Based on OMAP existing mailbox framework, this series proposes a
> generic framework, living under drivers/mailbox.
I like this patch series so you have my Acked-by.
Since it's a new subsystem and affects a few ARM architectures can
we merge this into the ARM SoC tree once we have consensus,
so we get some rotation in linux-next that way?
Olof/Arnd?
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH 0/9] drivers: mailbox: framework creation
2012-12-20 18:16 ` [PATCH 0/9] drivers: mailbox: framework creation Linus Walleij
@ 2012-12-20 18:28 ` Tony Lindgren
2012-12-20 19:19 ` Olof Johansson
0 siblings, 1 reply; 31+ messages in thread
From: Tony Lindgren @ 2012-12-20 18:28 UTC (permalink / raw)
To: linux-arm-kernel
* Linus Walleij <linus.walleij@linaro.org> [121220 10:19]:
> On Tue, Dec 18, 2012 at 2:10 PM, Loic Pallardy
> <loic.pallardy-ext@stericsson.com> wrote:
>
> > OMAP and ST-Ericsson platforms are both using mailbox to communicate
> > with some coprocessors.
> > Based on OMAP existing mailbox framework, this series proposes a
> > generic framework, living under drivers/mailbox.
>
> I like this patch series so you have my Acked-by.
>
> Since it's a new subsystem and affects a few ARM architectures can
> we merge this into the ARM SoC tree once we have consensus,
> so we get some rotation in linux-next that way?
Yes good idea.
> Olof/Arnd?
I suggest we set up an immutable branch against
v3.8-rc1 when it's out with only these patches in it.
Then we can all merge it in as needed. Maybe Arnd or
Olof can set up the branch?
FYI, looks like I need to merge in this branch too to
avoid build errors with remoteproc enabled once I flip
on the multiplatform support for omap2+.
Regards,
Tony
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH 0/9] drivers: mailbox: framework creation
2012-12-20 18:28 ` Tony Lindgren
@ 2012-12-20 19:19 ` Olof Johansson
2012-12-20 19:33 ` Tony Lindgren
2012-12-21 7:31 ` Ohad Ben-Cohen
0 siblings, 2 replies; 31+ messages in thread
From: Olof Johansson @ 2012-12-20 19:19 UTC (permalink / raw)
To: linux-arm-kernel
On Thu, Dec 20, 2012 at 10:28 AM, Tony Lindgren <tony@atomide.com> wrote:
> * Linus Walleij <linus.walleij@linaro.org> [121220 10:19]:
>> On Tue, Dec 18, 2012 at 2:10 PM, Loic Pallardy
>> <loic.pallardy-ext@stericsson.com> wrote:
>>
>> > OMAP and ST-Ericsson platforms are both using mailbox to communicate
>> > with some coprocessors.
>> > Based on OMAP existing mailbox framework, this series proposes a
>> > generic framework, living under drivers/mailbox.
>>
>> I like this patch series so you have my Acked-by.
>>
>> Since it's a new subsystem and affects a few ARM architectures can
>> we merge this into the ARM SoC tree once we have consensus,
>> so we get some rotation in linux-next that way?
>
> Yes good idea.
>
>> Olof/Arnd?
>
> I suggest we set up an immutable branch against
> v3.8-rc1 when it's out with only these patches in it.
> Then we can all merge it in as needed. Maybe Arnd or
> Olof can set up the branch?
I haven't reviewed the patches yet, but this flow sounds reasonable to me.
> FYI, looks like I need to merge in this branch too to
> avoid build errors with remoteproc enabled once I flip
> on the multiplatform support for omap2+.
While we can make the branch stable, would it make sense to make
remoteproc for omap depend on !multiplatform during the transition, to
reduce dependencies a little? Either way works, but it'd be nice to
keep them independent if we can.
-Olof
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH 0/9] drivers: mailbox: framework creation
2012-12-20 19:19 ` Olof Johansson
@ 2012-12-20 19:33 ` Tony Lindgren
2012-12-21 7:31 ` Ohad Ben-Cohen
1 sibling, 0 replies; 31+ messages in thread
From: Tony Lindgren @ 2012-12-20 19:33 UTC (permalink / raw)
To: linux-arm-kernel
* Olof Johansson <olof@lixom.net> [121220 11:22]:
> On Thu, Dec 20, 2012 at 10:28 AM, Tony Lindgren <tony@atomide.com> wrote:
> > * Linus Walleij <linus.walleij@linaro.org> [121220 10:19]:
> >> On Tue, Dec 18, 2012 at 2:10 PM, Loic Pallardy
> >> <loic.pallardy-ext@stericsson.com> wrote:
> >>
> >> > OMAP and ST-Ericsson platforms are both using mailbox to communicate
> >> > with some coprocessors.
> >> > Based on OMAP existing mailbox framework, this series proposes a
> >> > generic framework, living under drivers/mailbox.
> >>
> >> I like this patch series so you have my Acked-by.
> >>
> >> Since it's a new subsystem and affects a few ARM architectures can
> >> we merge this into the ARM SoC tree once we have consensus,
> >> so we get some rotation in linux-next that way?
> >
> > Yes good idea.
> >
> >> Olof/Arnd?
> >
> > I suggest we set up an immutable branch against
> > v3.8-rc1 when it's out with only these patches in it.
> > Then we can all merge it in as needed. Maybe Arnd or
> > Olof can set up the branch?
>
> I haven't reviewed the patches yet, but this flow sounds reasonable to me.
OK cool.
> > FYI, looks like I need to merge in this branch too to
> > avoid build errors with remoteproc enabled once I flip
> > on the multiplatform support for omap2+.
>
> While we can make the branch stable, would it make sense to make
> remoteproc for omap depend on !multiplatform during the transition, to
> reduce dependencies a little? Either way works, but it'd be nice to
> keep them independent if we can.
Yes I'll update the omap multiplat fixups patch I posted yesterday.
I noticed it only after running make randconfig for a while.
Regards,
Tony
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH 0/9] drivers: mailbox: framework creation
2012-12-20 19:19 ` Olof Johansson
2012-12-20 19:33 ` Tony Lindgren
@ 2012-12-21 7:31 ` Ohad Ben-Cohen
2012-12-21 8:52 ` Loic PALLARDY
1 sibling, 1 reply; 31+ messages in thread
From: Ohad Ben-Cohen @ 2012-12-21 7:31 UTC (permalink / raw)
To: linux-arm-kernel
On Thu, Dec 20, 2012 at 9:19 PM, Olof Johansson <olof@lixom.net> wrote:
> While we can make the branch stable, would it make sense to make
> remoteproc for omap depend on !multiplatform during the transition, to
> reduce dependencies a little? Either way works, but it'd be nice to
> keep them independent if we can.
I'm not sure multiplatform is the culprit; OMAP's remoteproc driver
heavily depends on this mailbox code, and obviously breaks with this
patch-set if only for the the naming changes. We'll need this patch
set to update omap's remoteproc as well so at least we don't break
bisectibility, though running a sanity test before merging would be
even nicer (Loic I can help if you don't have a panda board).
BTW - grep shows that tidspbridge is using the mailbox code too, but
it's in staging and I'm not sure it gets much love. Nevertheless, as
long as it's there we should at least update it with the new API as
well.
Thanks,
Ohad.
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH 0/9] drivers: mailbox: framework creation
2012-12-21 7:31 ` Ohad Ben-Cohen
@ 2012-12-21 8:52 ` Loic PALLARDY
2012-12-21 19:33 ` Omar Ramirez Luna
0 siblings, 1 reply; 31+ messages in thread
From: Loic PALLARDY @ 2012-12-21 8:52 UTC (permalink / raw)
To: linux-arm-kernel
On 12/21/2012 08:31 AM, Ohad Ben-Cohen wrote:
> On Thu, Dec 20, 2012 at 9:19 PM, Olof Johansson<olof@lixom.net> wrote:
>> While we can make the branch stable, would it make sense to make
>> remoteproc for omap depend on !multiplatform during the transition, to
>> reduce dependencies a little? Either way works, but it'd be nice to
>> keep them independent if we can.
>
> I'm not sure multiplatform is the culprit; OMAP's remoteproc driver
> heavily depends on this mailbox code, and obviously breaks with this
> patch-set if only for the the naming changes. We'll need this patch
> set to update omap's remoteproc as well so at least we don't break
> bisectibility, though running a sanity test before merging would be
> even nicer (Loic I can help if you don't have a panda board).
Hi Ohad,
Yes tidspbridge and remoteproc must be adapted.
This new mailbox fw has been tested on TI environment by Omar, who did
adaptation at least for tidspbridge.
Omar, do you have patch series ready for TI adaptations to new mailbox
framework?
Else I can do it, but I won't be able to test it (no panda board)
Regards,
Loic
>
> BTW - grep shows that tidspbridge is using the mailbox code too, but
> it's in staging and I'm not sure it gets much love. Nevertheless, as
> long as it's there we should at least update it with the new API as
> well.
>
> Thanks,
> Ohad.
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH 0/9] drivers: mailbox: framework creation
2012-12-21 8:52 ` Loic PALLARDY
@ 2012-12-21 19:33 ` Omar Ramirez Luna
2012-12-24 15:17 ` Ohad Ben-Cohen
0 siblings, 1 reply; 31+ messages in thread
From: Omar Ramirez Luna @ 2012-12-21 19:33 UTC (permalink / raw)
To: linux-arm-kernel
Hi Loic/Ohad,
On Fri, Dec 21, 2012 at 2:52 AM, Loic PALLARDY <loic.pallardy@st.com> wrote:
>
>
> On 12/21/2012 08:31 AM, Ohad Ben-Cohen wrote:
>> On Thu, Dec 20, 2012 at 9:19 PM, Olof Johansson<olof@lixom.net> wrote:
>>> While we can make the branch stable, would it make sense to make
>>> remoteproc for omap depend on !multiplatform during the transition, to
>>> reduce dependencies a little? Either way works, but it'd be nice to
>>> keep them independent if we can.
>>
>> I'm not sure multiplatform is the culprit; OMAP's remoteproc driver
>> heavily depends on this mailbox code, and obviously breaks with this
>> patch-set if only for the the naming changes. We'll need this patch
>> set to update omap's remoteproc as well so at least we don't break
>> bisectibility, though running a sanity test before merging would be
>> even nicer (Loic I can help if you don't have a panda board).
>
> Hi Ohad,
> Yes tidspbridge and remoteproc must be adapted.
> This new mailbox fw has been tested on TI environment by Omar, who did
> adaptation at least for tidspbridge.
>
> Omar, do you have patch series ready for TI adaptations to new mailbox
> framework?
> Else I can do it, but I won't be able to test it (no panda board)
Yes, I made the changes, for tidspbridge and remoteproc, I will submit
both for review, based on this series.
Cheers,
Omar
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH 0/9] drivers: mailbox: framework creation
2012-12-21 19:33 ` Omar Ramirez Luna
@ 2012-12-24 15:17 ` Ohad Ben-Cohen
0 siblings, 0 replies; 31+ messages in thread
From: Ohad Ben-Cohen @ 2012-12-24 15:17 UTC (permalink / raw)
To: linux-arm-kernel
Hi Omar,
On Fri, Dec 21, 2012 at 9:33 PM, Omar Ramirez Luna
<omar.ramirez@copitl.com> wrote:
> Yes, I made the changes, for tidspbridge and remoteproc, I will submit
> both for review, based on this series.
Great, thanks.
Please note that when we do eventually merge this, we need your
updates to be squashed into Loic's patches so we don't break
bisectibility.
Thanks,
Ohad.
^ permalink raw reply [flat|nested] 31+ messages in thread