From a1824eaab70f2a5eb7de5f4c6b7f0890bdc7b297 Mon Sep 17 00:00:00 2001 From: Omar Ramirez Luna Date: Tue, 12 Mar 2013 17:55:29 -0500 Subject: [PATCH] mailbox: OMAP: introduce mailbox framework 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. Module names have changed too, instead of mailbox_mach: - OMAP1: mailbox-omap1.ko - OMAP2+: mailbox-omap2.ko Signed-off-by: Omar Ramirez Luna Acked-by: Tony Lindgren Signed-off-by: Linus Walleij [s-anna@ti.com: Kconfig fixes for build errors] Signed-off-by: Suman Anna --- 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/mailbox/Kconfig | 25 +++++++++++++++++++ drivers/mailbox/Makefile | 4 +++ .../mailbox/mailbox-omap1.c | 3 ++- .../mailbox/mailbox-omap2.c | 14 +++++------ .../plat-omap => drivers/mailbox}/mailbox.c | 18 ++++++------- drivers/mailbox/mailbox_internal.h | 14 +++++++++++ drivers/remoteproc/Kconfig | 3 ++- drivers/remoteproc/omap_remoteproc.c | 2 +- drivers/staging/tidspbridge/Kconfig | 3 ++- .../tidspbridge/include/dspbridge/host_os.h | 2 +- .../include/plat => include/linux}/mailbox.h | 10 ++++++-- 17 files changed, 79 insertions(+), 52 deletions(-) rename arch/arm/mach-omap1/mailbox.c => drivers/mailbox/mailbox-omap1.c (99%) rename arch/arm/mach-omap2/mailbox.c => drivers/mailbox/mailbox-omap2.c (98%) rename {arch/arm/plat-omap => drivers/mailbox}/mailbox.c (97%) create mode 100644 drivers/mailbox/mailbox_internal.h rename {arch/arm/plat-omap/include/plat => include/linux}/mailbox.h (90%) diff --git a/arch/arm/configs/omap1_defconfig b/arch/arm/configs/omap1_defconfig index 42eab9a2a0fd..2280d9df753e 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 222d58c0ae76..3889b6cd211e 100644 --- a/arch/arm/mach-omap1/Makefile +++ b/arch/arm/mach-omap1/Makefile @@ -19,10 +19,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 b068b7fe99ef..4098635b22cc 100644 --- a/arch/arm/mach-omap2/Makefile +++ b/arch/arm/mach-omap2/Makefile @@ -203,9 +203,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 - iommu-$(CONFIG_OMAP_IOMMU) := omap-iommu.o obj-y += $(iommu-m) $(iommu-y) diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c index 039f6d717d42..72ba57c69da5 100644 --- a/arch/arm/mach-omap2/devices.c +++ b/arch/arm/mach-omap2/devices.c @@ -328,7 +328,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; @@ -352,7 +352,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 ce66eb9be481..f82bae2171eb 100644 --- a/arch/arm/plat-omap/Kconfig +++ b/arch/arm/plat-omap/Kconfig @@ -86,22 +86,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 && !ARCH_MULTIPLATFORM - 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 31199417b56a..0b01b68fd033 100644 --- a/arch/arm/plat-omap/Makefile +++ b/arch/arm/plat-omap/Makefile @@ -17,6 +17,3 @@ 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 - diff --git a/drivers/mailbox/Kconfig b/drivers/mailbox/Kconfig index 9545c9f03809..22d6f8d1889f 100644 --- a/drivers/mailbox/Kconfig +++ b/drivers/mailbox/Kconfig @@ -16,4 +16,29 @@ config PL320_MBOX Management Engine, primarily for cpufreq. Say Y here if you want to use the PL320 IPCM support. +config OMAP1_MBOX + tristate "OMAP1 Mailbox framework support" + depends on ARCH_OMAP1 + 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_OMAP2PLUS + 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)" + 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 index 543ad6a79505..9ee0fcba6c3d 100644 --- a/drivers/mailbox/Makefile +++ b/drivers/mailbox/Makefile @@ -1 +1,5 @@ obj-$(CONFIG_PL320_MBOX) += pl320-ipc.o + +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 99% rename from arch/arm/mach-omap1/mailbox.c rename to drivers/mailbox/mailbox-omap1.c index efc8f207f6fc..dbf40e26dd81 100644 --- a/arch/arm/mach-omap1/mailbox.c +++ b/drivers/mailbox/mailbox-omap1.c @@ -13,7 +13,8 @@ #include #include #include -#include + +#include "mailbox_internal.h" #define MAILBOX_ARM2DSP1 0x00 #define MAILBOX_ARM2DSP1b 0x04 diff --git a/arch/arm/mach-omap2/mailbox.c b/drivers/mailbox/mailbox-omap2.c similarity index 98% rename from arch/arm/mach-omap2/mailbox.c rename to drivers/mailbox/mailbox-omap2.c index 8f5bcd8ed397..3fe8d7c09107 100644 --- a/arch/arm/mach-omap2/mailbox.c +++ b/drivers/mailbox/mailbox-omap2.c @@ -19,7 +19,7 @@ #include #include -#include +#include "mailbox_internal.h" #define MAILBOX_REVISION 0x000 #define MAILBOX_MESSAGE(m) (0x040 + 4 * (m)) @@ -63,7 +63,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) { @@ -185,7 +185,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]); } } @@ -203,7 +203,7 @@ 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]); } } @@ -325,9 +325,9 @@ static int omap2_mbox_remove(struct platform_device *pdev) } static struct platform_driver omap2_mbox_driver = { - .probe = omap2_mbox_probe, - .remove = omap2_mbox_remove, - .driver = { + .probe = omap2_mbox_probe, + .remove = omap2_mbox_remove, + .driver = { .name = "omap-mailbox", }, }; 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 42377ef9ea3d..6c738aa00b53 100644 --- a/arch/arm/plat-omap/mailbox.c +++ b/drivers/mailbox/mailbox.c @@ -31,7 +31,7 @@ #include #include -#include +#include "mailbox_internal.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/drivers/mailbox/mailbox_internal.h b/drivers/mailbox/mailbox_internal.h new file mode 100644 index 000000000000..b39badbe9cfa --- /dev/null +++ b/drivers/mailbox/mailbox_internal.h @@ -0,0 +1,14 @@ +/* + * mailbox: interprocessor communication module + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#ifndef MAILBOX_INTERNAL_H +#define MAILBOX_INTERNAL_H + +#include + +#endif /* MAILBOX_INTERNAL_H */ diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig index cc1f7bf53fd0..2465c71ae705 100644 --- a/drivers/remoteproc/Kconfig +++ b/drivers/remoteproc/Kconfig @@ -12,8 +12,9 @@ config OMAP_REMOTEPROC depends on HAS_DMA depends on ARCH_OMAP4 depends on OMAP_IOMMU - depends on OMAP_MBOX_FWK select REMOTEPROC + select MAILBOX + select OMAP2PLUS_MBOX select RPMSG help Say y here to support OMAP's remote processors (dual M3 diff --git a/drivers/remoteproc/omap_remoteproc.c b/drivers/remoteproc/omap_remoteproc.c index 0e396c155b3b..49a04d5ba13a 100644 --- a/drivers/remoteproc/omap_remoteproc.c +++ b/drivers/remoteproc/omap_remoteproc.c @@ -27,8 +27,8 @@ #include #include #include +#include -#include #include #include "omap_remoteproc.h" diff --git a/drivers/staging/tidspbridge/Kconfig b/drivers/staging/tidspbridge/Kconfig index 60848f198b48..165b918b8171 100644 --- a/drivers/staging/tidspbridge/Kconfig +++ b/drivers/staging/tidspbridge/Kconfig @@ -5,7 +5,8 @@ menuconfig TIDSPBRIDGE tristate "DSP Bridge driver" depends on ARCH_OMAP3 && !ARCH_MULTIPLATFORM - select OMAP_MBOX_FWK + select MAILBOX + select OMAP2PLUS_MBOX help DSP/BIOS Bridge is designed for platforms that contain a GPP and one or more attached DSPs. The GPP is considered the master or diff --git a/drivers/staging/tidspbridge/include/dspbridge/host_os.h b/drivers/staging/tidspbridge/include/dspbridge/host_os.h index 7f3a1db31619..27f6bd6114bc 100644 --- a/drivers/staging/tidspbridge/include/dspbridge/host_os.h +++ b/drivers/staging/tidspbridge/include/dspbridge/host_os.h @@ -41,7 +41,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/arch/arm/plat-omap/include/plat/mailbox.h b/include/linux/mailbox.h similarity index 90% rename from arch/arm/plat-omap/include/plat/mailbox.h rename to include/linux/mailbox.h index e98f7e234686..5722b93145c7 100644 --- a/arch/arm/plat-omap/include/plat/mailbox.h +++ b/include/linux/mailbox.h @@ -1,4 +1,10 @@ -/* mailbox.h */ +/* + * mailbox: interprocessor communication module + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ #ifndef MAILBOX_H #define MAILBOX_H @@ -58,7 +64,7 @@ struct omap_mbox { struct device *dev; void *priv; int use_count; - struct blocking_notifier_head notifier; + struct blocking_notifier_head notifier; }; int omap_mbox_msg_send(struct omap_mbox *, mbox_msg_t msg); -- 2.39.5