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 <omar.luna@linaro.org>
Acked-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
[s-anna@ti.com: Kconfig fixes for build errors]
Signed-off-by: Suman Anna <s-anna@ti.com>
mailbox: split internal header from API header

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>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Suman Anna <s-anna@ti.com>
mailbox: rename omap_mbox in mailbox

In order to create a generic mailbox framework, functions
and structures should be renamed in mailbox.

Taking care of remoteproc and tidspbridge while at it.

Signed-off-by: Loic Pallardy <loic.pallardy@st.com>
Signed-off-by: Omar Ramirez Luna <omar.ramirez@copitl.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Suman Anna <s-anna@ti.com>
mailbox: create opened message type

Current message type is a u32 to fit HW fifo format.
This should be extended to support any message exchanges
and type of mailbox.

Proposed structure owns the original u32 and an optional
pointer on additional data.

Adaptations made to remoteproc and tidspbridge drivers.

Signed-off-by: Loic Pallardy <loic.pallardy@st.com>
Signed-off-by: Omar Ramirez Luna <omar.ramirez@copitl.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Suman Anna <s-anna@ti.com>
mailbox: change protection mechanisms

TX: replace spin by mutex to release CPU
during wait on mailbox resource.

Signed-off-by: Loic Pallardy <loic.pallardy@st.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Suman Anna <s-anna@ti.com>
mailbox: add shared memory mailbox type

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>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Suman Anna <s-anna@ti.com>
mailbox: add IRQF_NO_SUSPEND flag

Coprocessor must be accessible during suspend transitions.

Signed-off-by: Loic Pallardy <loic.pallardy@st.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Suman Anna <s-anna@ti.com>
mailbox: add no_irq send message

For debug purpose, mailbox must be available when
interrupts are disabled to collect dump information.

Signed-off-by: Loic Pallardy <loic.pallardy@st.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Suman Anna <s-anna@ti.com>
mailbox: create dbx500 mailbox driver

Add STEriccson DBX500 PRCM mailbox support.

Signed-off-by: Loic Pallardy <loic.pallardy@st.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Suman Anna <s-anna@ti.com>
mailbox/omap: check iomem resource before dereferencing it

Add a NULL check for iomem resource in mailbox probe functions.

Signed-off-by: Fernando Guzman Lugo <lugo.fernando@gmail.com>
Signed-off-by: Suman Anna <s-anna@ti.com>
mailbox: check for NULL nb in mailbox_put

The mailbox_put function must check the notifier block for
NULL before trying to unregister it.

Signed-off-by: Fernando Guzman Lugo <lugo.fernando@gmail.com>
Signed-off-by: Suman Anna <s-anna@ti.com>
mailbox: call request_irq after mbox queues are allocated

The mailbox startup code is enabling the interrupt even before
any of the associated mailbox queues are allocated. Any pending
received mailbox message could cause a kernel panic as soon as
the interrupt is enabled due to the dereferencing of non-existing
mailbox queues within the ISR.

Signed-off-by: Fernando Guzman Lugo <lugo.fernando@gmail.com>
Signed-off-by: Suman Anna <s-anna@ti.com>