OMAP: mailbox: removing static declarations
Subsystems (5)
cover OMAP: mailbox: removing static declarations
Hi,
This is the first attempt in making the omap mailbox framework generic enough to support other mailbox drivers, in this series the way the mailbox are defined and registered is changed to support requests of mailboxes through an id. So far, the mailbox static declarations have been removed allowing a dynamic mailbox configuration.
The next steps would involve removing omap references in the code and omap specific fields (like "type" embedded in the operations structure) along with a trivial cleanup.
The end goal would be moving the mailbox driver into drivers folder and also converting other mailbox drivers to reuse this code, the first candidate being ux-500 mailbox driver (arch/arm/mach-ux500/mbox-db5500.c).
Tested using one patch on top of Kevin Hilman mailbox loopback test, can be found at: https://gitorious.org/~or.rmz/omap-test/mbox-test-clone
If accepted patches 5 to 7 should be a single patch, to avoid compilation issues.
I'll appreciate any comments or suggestions.
Omar Ramirez Luna (7):
OMAP2+: hwmod_data: define number of mailboxes OMAP2+: devices: get the number of supported mailboxes
OMAP: mailbox: use OMAP's naming convention for devices
OMAP: mailbox: move framework functions under header file
OMAP: mailbox: implement dynamic mailbox configuration
OMAP1: mailbox: adapt to dynamic mailbox requests OMAP2+: mailbox: remove mailbox static declarations
arch/arm/mach-omap1/mailbox.c | 94 +++++---- arch/arm/mach-omap2/devices.c | 8 +- arch/arm/mach-omap2/mailbox.c | 212 +++++--------------- arch/arm/mach-omap2/omap_hwmod_2420_data.c | 6 + arch/arm/mach-omap2/omap_hwmod_2430_data.c | 6 + arch/arm/mach-omap2/omap_hwmod_3xxx_data.c | 6 + arch/arm/mach-omap2/omap_hwmod_44xx_data.c | 6 + arch/arm/plat-omap/include/plat/mailbox.h | 62 +++---- arch/arm/plat-omap/mailbox.c | 298 ++++++++++++++++++---------- 9 files changed, 364 insertions(+), 334 deletions(-)
Regards,
Omar
RFC PATCH 1/7 OMAP2+: hwmod_data: define number of mailboxes
Define number of mailboxes available to a specific chip.
--- arch/arm/mach-omap2/omap_hwmod_2420_data.c | 6 ++++++ arch/arm/mach-omap2/omap_hwmod_2430_data.c | 6 ++++++ arch/arm/mach-omap2/omap_hwmod_3xxx_data.c | 6 ++++++ arch/arm/mach-omap2/omap_hwmod_44xx_data.c | 6 ++++++ arch/arm/plat-omap/include/plat/mailbox.h | 8 ++++++++ 5 files changed, 32 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/omap_hwmod_2420_data.c +6 -0
@@ -18,6 +18,7 @@#include <plat/serial.h> #include <plat/i2c.h> #include <plat/gpio.h> +#include <plat/mailbox.h> #include <plat/mcspi.h> #include <plat/dmtimer.h> #include <plat/l3_2xxx.h>
@@ -1855,6 +1856,10 @@ static struct omap_hwmod_class omap2420_mailbox_hwmod_class = { .sysc = &omap2420_mailbox_sysc, }; +static struct omap_mailbox_dev_attr mailbox_dev_attr = { + .nr_mbox =6 , +}; +/* mailbox */ static struct omap_hwmod omap2420_mailbox_hwmod;static struct omap_hwmod_irq_info omap2420_mailbox_irqs[] = {
@@ -1899,6 +1904,7 @@ static struct omap_hwmod omap2420_mailbox_hwmod = { .idlest_idle_bit = OMAP24XX_ST_MAILBOXES_SHIFT, }, }, + .dev_attr = &mailbox_dev_attr, .slaves = omap2420_mailbox_slaves, .slaves_cnt = ARRAY_SIZE(omap2420_mailbox_slaves), .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP2420),
arch/arm/mach-omap2/omap_hwmod_2430_data.c +6 -0
@@ -18,6 +18,7 @@#include <plat/serial.h> #include <plat/i2c.h> #include <plat/gpio.h> +#include <plat/mailbox.h> #include <plat/mcbsp.h> #include <plat/mcspi.h> #include <plat/dmtimer.h>
@@ -1989,6 +1990,10 @@ static struct omap_hwmod_class omap2430_mailbox_hwmod_class = { .sysc = &omap2430_mailbox_sysc, }; +static struct omap_mailbox_dev_attr mailbox_dev_attr = { + .nr_mbox =6 , +}; +/* mailbox */ static struct omap_hwmod omap2430_mailbox_hwmod;static struct omap_hwmod_irq_info omap2430_mailbox_irqs[] = {
@@ -2032,6 +2037,7 @@ static struct omap_hwmod omap2430_mailbox_hwmod = { .idlest_idle_bit = OMAP24XX_ST_MAILBOXES_SHIFT, }, }, + .dev_attr = &mailbox_dev_attr, .slaves = omap2430_mailbox_slaves, .slaves_cnt = ARRAY_SIZE(omap2430_mailbox_slaves), .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP2430),
arch/arm/mach-omap2/omap_hwmod_3xxx_data.c +6 -0
@@ -22,6 +22,7 @@#include <plat/l4_3xxx.h> #include <plat/i2c.h> #include <plat/gpio.h> +#include <plat/mailbox.h> #include <plat/mmc.h> #include <plat/mcbsp.h> #include <plat/mcspi.h>
@@ -3022,6 +3023,10 @@ static struct omap_hwmod_class omap3xxx_mailbox_hwmod_class = { .sysc = &omap3xxx_mailbox_sysc, }; +static struct omap_mailbox_dev_attr mailbox_dev_attr = { + .nr_mbox =6 , +}; +static struct omap_hwmod omap3xxx_mailbox_hwmod;static struct omap_hwmod_irq_info omap3xxx_mailbox_irqs[] = { { .irq =26 },
@@ -3064,6 +3069,7 @@ static struct omap_hwmod omap3xxx_mailbox_hwmod = { .idlest_idle_bit = OMAP3430_ST_MAILBOXES_SHIFT, }, }, + .dev_attr = &mailbox_dev_attr, .slaves = omap3xxx_mailbox_slaves, .slaves_cnt = ARRAY_SIZE(omap3xxx_mailbox_slaves), .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP3430),
arch/arm/mach-omap2/omap_hwmod_44xx_data.c +6 -0
@@ -24,6 +24,7 @@#include <plat/cpu.h> #include <plat/gpio.h> #include <plat/dma.h> +#include <plat/mailbox.h> #include <plat/mcspi.h> #include <plat/mcbsp.h> #include <plat/mmc.h>
@@ -2717,6 +2718,10 @@ static struct omap_hwmod_class omap44xx_mailbox_hwmod_class = { .sysc = &omap44xx_mailbox_sysc, }; +static struct omap_mailbox_dev_attr mailbox_dev_attr = { + .nr_mbox =8 , +}; +/* mailbox */ static struct omap_hwmod omap44xx_mailbox_hwmod;static struct omap_hwmod_irq_info omap44xx_mailbox_irqs[] = {
@@ -2756,6 +2761,7 @@ static struct omap_hwmod omap44xx_mailbox_hwmod = { .clkctrl_reg = OMAP4430_CM_L4CFG_MAILBOX_CLKCTRL, }, }, + .dev_attr = &mailbox_dev_attr, .slaves = omap44xx_mailbox_slaves, .slaves_cnt = ARRAY_SIZE(omap44xx_mailbox_slaves), .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP4430),
arch/arm/plat-omap/include/plat/mailbox.h +8 -0
@@ -41,6 +41,14 @@ struct omap_mbox_ops {void (*restore_ctx)(struct omap_mbox *mbox); }; +struct omap_mailbox_dev_attr { +u16 nr_mbox; +}; + +struct omap_mailbox_platform_data { +u16 nr_mbox; +}; +struct omap_mbox_queue {spinlock_t lock;struct kfifo fifo;
Signature · 1 line
1.7.0.4
RFC PATCH 2/7 OMAP2+: devices: get the number of supported mailboxes
In reply to Omar Ramirez LunaUse hwmod data attributes to get the defined number of mailboxes on our current chip, and pass it through platform data.
--- arch/arm/mach-omap2/devices.c | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-)
arch/arm/mach-omap2/devices.c +7 -1
@@ -25,6 +25,7 @@#include <plat/tc.h> #include <plat/board.h> +#include <plat/mailbox.h> #include <plat/mcbsp.h> #include <mach/gpio.h> #include <plat/mmc.h>
@@ -274,6 +275,8 @@ static inline void omap_init_mbox(void) {struct omap_hwmod *oh;struct omap_device *od; +struct omap_mailbox_dev_attr *mb_attr; +struct omap_mailbox_platform_data pdata; oh =omap_hwmod_lookup ("mailbox" );if (!oh) {
@@ -281,7 +284,10 @@ static inline void omap_init_mbox(void)return ; } - od =omap_device_build ("omap-mailbox" ,-1 , oh,NULL ,0 , + mb_attr = oh->dev_attr; + pdata.nr_mbox = mb_attr->nr_mbox; + + od =omap_device_build ("omap-mailbox" ,-1 , oh, &pdata,sizeof (pdata), mbox_latencies,ARRAY_SIZE (mbox_latencies),0 );WARN (IS_ERR (od),"%s: could not build device, err %ld\n" , __func__,PTR_ERR (od));
Signature · 1 line
1.7.0.4
RFC PATCH 3/7 OMAP: mailbox: use OMAP's naming convention for devices
In reply to Omar Ramirez LunaUse "omap_XXX" as the OMAP device naming convention.
--- arch/arm/mach-omap1/mailbox.c | 2 +- arch/arm/mach-omap2/devices.c | 2 +- arch/arm/mach-omap2/mailbox.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
arch/arm/mach-omap1/mailbox.c +1 -1
@@ -175,7 +175,7 @@ static struct platform_driver omap1_mbox_driver = { .probe = omap1_mbox_probe, .remove = __devexit_p(omap1_mbox_remove), .driver = { - .name = "omap-mailbox", + .name = "omap_mailbox", }, };
arch/arm/mach-omap2/devices.c +1 -1
@@ -287,7 +287,7 @@ static inline void omap_init_mbox(void) mb_attr = oh->dev_attr; pdata.nr_mbox = mb_attr->nr_mbox; - od =omap_device_build ("omap-mailbox" ,-1 , oh, &pdata,sizeof (pdata), + od =omap_device_build ("omap_mailbox" ,-1 , oh, &pdata,sizeof (pdata), mbox_latencies,ARRAY_SIZE (mbox_latencies),0 );WARN (IS_ERR (od),"%s: could not build device, err %ld\n" , __func__,PTR_ERR (od));
arch/arm/mach-omap2/mailbox.c +1 -1
@@ -397,7 +397,7 @@ static struct platform_driver omap2_mbox_driver = { .probe = omap2_mbox_probe, .remove = __devexit_p(omap2_mbox_remove), .driver = { - .name = "omap-mailbox", + .name = "omap_mailbox", }, };
Signature · 1 line
1.7.0.4
RFC PATCH 4/7 OMAP: mailbox: move framework functions under header file
In reply to Omar Ramirez LunaMove API functions to common framework like save/restore_ctx, enable/disable_irq instead of being under a header file. While at it dropping their static inline declarations.
--- arch/arm/plat-omap/include/plat/mailbox.h | 35 +++------------------------- arch/arm/plat-omap/mailbox.c | 35 +++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 31 deletions(-)
arch/arm/plat-omap/include/plat/mailbox.h +4 -31
@@ -78,36 +78,9 @@ 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); -} +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);#endif /* MAILBOX_H */
arch/arm/plat-omap/mailbox.c +35 -0
@@ -60,6 +60,18 @@ static inline int mbox_fifo_full(struct omap_mbox *mbox) }/* Mailbox IRQ handle functions */ +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 inline void ack_mbox_irq (struct omap_mbox *mbox,omap_mbox_irq_t irq) {if (mbox->ops->ack_irq)
@@ -70,6 +82,29 @@ static inline int is_mbox_irq(struct omap_mbox *mbox, omap_mbox_irq_t irq)return mbox->ops->is_irq (mbox, irq); } +/* Mailbox context functions */ +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); +/* * message sender */
Signature · 1 line
1.7.0.4
RFC PATCH 5/7 OMAP: mailbox: implement dynamic mailbox configuration
In reply to Omar Ramirez LunaSo far, mailbox architecture dependent implementations have contained static declarations for its supported mailbox and users, this has affected the framework by extending the requests to match the hardcoded names and only support the known users.
These changes try to provide a more generic mailbox driver which diferentiates from its available queues instead of the name of the users tied to a single pair.
Users of the mailbox need to supply a new struct mbox_info with the common parameters needed by the framework to configure N number of queues.
All requests are made in function of the mailbox id needed, also a request_byname is provided to cover the cases where there are multiple irqs tied to a single mailbox block (i.e. OMAP2420).
--- arch/arm/plat-omap/include/plat/mailbox.h | 19 ++- arch/arm/plat-omap/mailbox.c | 275 +++++++++++++++++----------- 2 files changed, 182 insertions(+), 112 deletions(-)
arch/arm/plat-omap/include/plat/mailbox.h +15 -4
@@ -39,6 +39,9 @@ struct omap_mbox_ops {/* ctx */ void (*save_ctx)(struct omap_mbox *mbox);void (*restore_ctx)(struct omap_mbox *mbox); + +void *(*request)(u16 id,u16 owner); +void (*release)(void *priv); };struct omap_mailbox_dev_attr {
@@ -49,6 +52,14 @@ struct omap_mailbox_platform_data {u16 nr_mbox; }; +struct mbox_info { +struct device *dev; +struct omap_mbox_ops *ops; +u32 kfifo_size; +u32 configured; +u16 nr_mbox; +}; +struct omap_mbox_queue {spinlock_t lock;struct kfifo fifo;
@@ -60,9 +71,9 @@ struct omap_mbox_queue {struct omap_mbox {char *name; +u16 id;unsigned int irq;struct omap_mbox_queue *txq, *rxq; -struct omap_mbox_ops *ops;struct device *dev;void *priv;int use_count;
@@ -72,10 +83,10 @@ struct omap_mbox {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); +void *mbox_request (u16 id,u16 owner,struct notifier_block *nb); +void mbox_release (struct omap_mbox *mbox,struct notifier_block *nb); -int omap_mbox_register (struct device *parent,struct omap_mbox **); +int omap_mbox_register (struct mbox_info *arch_mbi);int omap_mbox_unregister (void );void omap_mbox_save_ctx (struct omap_mbox *mbox);
arch/arm/plat-omap/mailbox.c +167 -108
430 lines not on this page · raw message
Signature · 1 line
1.7.0.4
RFC PATCH 6/7 OMAP1: mailbox: adapt to dynamic mailbox requests
In reply to Omar Ramirez LunaRemove mailbox static declarations, while at it, simplify the macros to be reused in a cleaner way.
New approach configures available mailboxes per request.
--- arch/arm/mach-omap1/mailbox.c | 92 ++++++++++++++++++++++++----------------- 1 files changed, 54 insertions(+), 38 deletions(-)
arch/arm/mach-omap1/mailbox.c +54 -38
@@ -9,20 +9,23 @@* for more details. */ +#include <linux/err.h> #include <linux/interrupt.h> #include <linux/platform_device.h> #include <linux/io.h> +#include <linux/slab.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 +#define MAILBOX_ARM2DSPm (m) (0x24 * (m - 1)) +#define MAILBOX_DSP2ARMm (m) (0x08 + 0x8 * (m - 1)) +#define MAILBOX_ARM2DSPmb (m) (0x04 + 0x24 * (m - 1)) +#define MAILBOX_DSP2ARMmb (m) (0x0c + 0x8 * (m - 1)) +#define MAILBOX_ARM2DSPm_Flag (m) (0x18 + 0x14 * (m - 1)) +#define MAILBOX_DSP2ARMm_Flag (m) (0x1c + 0x4 * (m - 1)) + +static unsigned int mbox_kfifo_size =CONFIG_OMAP_MBOX_KFIFO_SIZE ; +module_param (mbox_kfifo_size, uint,S_IRUGO ); +MODULE_PARM_DESC (mbox_kfifo_size,"Size of omap's mailbox kfifo (bytes)" );static void __iomem *mbox_base;
@@ -106,6 +109,32 @@ omap1_mbox_is_irq(struct omap_mbox *mbox, omap_mbox_type_t irq)return 1 ; } +struct device *mbox_dev; + +static void *omap1_mbox_request (u16 id,u16 owner) +{ +struct omap_mbox1_priv *p; + + p =kzalloc (sizeof (struct omap_mbox1_priv ),GFP_KERNEL ); +if (!p) +return ERR_PTR (-ENOMEM ); + + p->tx_fifo.cmd =MAILBOX_ARM2DSPmb (id); + p->tx_fifo.data =MAILBOX_ARM2DSPm (id); + p->tx_fifo.flag =MAILBOX_ARM2DSPm_Flag (id); + p->rx_fifo.cmd =MAILBOX_DSP2ARMmb (id); + p->rx_fifo.data =MAILBOX_DSP2ARMm (id); + p->rx_fifo.flag =MAILBOX_DSP2ARMm_Flag (id); + +return mbox; +} + +static void omap1_mbox_release (void *priv) +{ +kfree (priv); + priv =NULL ; +} +static struct omap_mbox_ops omap1_mbox_ops = { .type =OMAP_MBOX_TYPE1 , .fifo_read = omap1_mbox_fifo_read,
@@ -115,48 +144,35 @@ static struct omap_mbox_ops omap1_mbox_ops = { .enable_irq = omap1_mbox_enable_irq, .disable_irq = omap1_mbox_disable_irq, .is_irq = omap1_mbox_is_irq, + .request = omap1_mbox_request, + .release = omap1_mbox_release, }; -/* FIXME: the following struct should be created automatically by the user id */ - -/* DSP */ -static struct omap_mbox1_priv omap1_mbox_dsp_priv = { - .tx_fifo = { - .cmd = MAILBOX_ARM2DSP1b, - .data =MAILBOX_ARM2DSP1 , - .flag = MAILBOX_ARM2DSP1_Flag, - }, - .rx_fifo = { - .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, -}; - -static struct omap_mbox *omap1_mboxes[] = { &mbox_dsp_info,NULL }; -static int __devinit omap1_mbox_probe (struct platform_device *pdev) {struct resource *mem; +struct mbox_info *arch_mbi;int ret; -struct omap_mbox **list; - - list = omap1_mboxes; - list[0 ]->irq =platform_get_irq_byname (pdev,"dsp" ); mem =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); mbox_base =ioremap (mem->start,resource_size (mem));if (!mbox_base)return -ENOMEM ; - ret =omap_mbox_register (&pdev->dev, list); + arch_mbi =kzalloc (sizeof (struct mbox_info ),GFP_KERNEL ); +if (!arch_mbi) { +iounmap (mbox_base); +return -ENOMEM ; + } + + arch_mbi->dev = &pdev->dev; + arch_mbi->ops = &omap1_mbox_ops; + arch_mbi->kfifo_size = mbox_kfifo_size; + arch_mbi->nr_mbox =2 ; + + ret =omap_mbox_register (arch_mbi);if (ret) { +kfree (arch_mbi);iounmap (mbox_base);return ret; }
Signature · 1 line
1.7.0.4
RFC PATCH 7/7 OMAP2+: mailbox: remove mailbox static declarations
In reply to Omar Ramirez LunaRemove mailbox static declarations which limit the driver to either work with 1 or 2 predefined mailboxes, even if there are more mailboxes in hardware.
New approach configures available mailboxes per request.
--- arch/arm/mach-omap2/mailbox.c | 210 +++++++++++------------------------------ 1 files changed, 54 insertions(+), 156 deletions(-)
arch/arm/mach-omap2/mailbox.c +54 -156
@@ -15,6 +15,7 @@#include <linux/platform_device.h> #include <linux/io.h> #include <linux/pm_runtime.h> +#include <linux/slab.h> #include <plat/mailbox.h> #include <mach/irqs.h>
@@ -39,6 +40,10 @@#define MBOX_NR_REGS (MBOX_REG_SIZE / sizeof(u32))#define OMAP4_MBOX_NR_REGS (OMAP4_MBOX_REG_SIZE / sizeof(u32)) +static unsigned int mbox_kfifo_size =CONFIG_OMAP_MBOX_KFIFO_SIZE ; +module_param (mbox_kfifo_size, uint,S_IRUGO ); +MODULE_PARM_DESC (mbox_kfifo_size,"Size of omap's mailbox kfifo (bytes)" ); +static void __iomem *mbox_base;struct omap_mbox2_fifo {
@@ -58,9 +63,6 @@ struct omap_mbox2_priv {unsigned long irqdisable; }; -static void omap2_mbox_enable_irq (struct omap_mbox *mbox, -omap_mbox_type_t irq); -static inline unsigned int mbox_read_reg (size_t ofs) {return __raw_readl (mbox_base + ofs);
@@ -76,21 +78,19 @@ static int omap2_mbox_startup(struct omap_mbox *mbox) {u32 l; -pm_runtime_enable (mbox->dev->parent); -pm_runtime_get_sync (mbox->dev->parent); +pm_runtime_enable (mbox->dev); +pm_runtime_get_sync (mbox->dev); l =mbox_read_reg (MAILBOX_REVISION );pr_debug ("omap mailbox rev %d.%d\n" , (l &0xf0 ) >>4 , (l &0x0f )); -omap2_mbox_enable_irq (mbox,IRQ_RX ); -return 0 ; }static void omap2_mbox_shutdown (struct omap_mbox *mbox) { -pm_runtime_put_sync (mbox->dev->parent); -pm_runtime_disable (mbox->dev->parent); +pm_runtime_put_sync (mbox->dev); +pm_runtime_disable (mbox->dev); }/* Mailbox FIFO handle functions */
@@ -203,6 +203,33 @@ static void omap2_mbox_restore_ctx(struct omap_mbox *mbox) } } +static void *omap2_mbox_request (u16 id,u16 owner) +{ +struct omap_mbox2_priv *p; + + p =kzalloc (sizeof (struct omap_mbox2_priv ),GFP_KERNEL ); +if (!p) +return ERR_PTR (-ENOMEM ); + + p->tx_fifo.msg =MAILBOX_MESSAGE (id); + p->tx_fifo.fifo_stat =MAILBOX_FIFOSTATUS (id); + p->notfull_bit =MAILBOX_IRQ_NOTFULL (id); + p->rx_fifo.msg =MAILBOX_MESSAGE (id); + p->rx_fifo.msg_stat =MAILBOX_MSGSTATUS (id); + p->newmsg_bit =MAILBOX_IRQ_NEWMSG (id); + p->irqenable =MAILBOX_IRQENABLE (owner); + p->irqstatus =MAILBOX_IRQSTATUS (owner); + p->irqdisable =MAILBOX_IRQENABLE (owner); + +return p; +} + +static void omap2_mbox_release (void *priv) +{ +kfree (priv); + priv =NULL ; +} +static struct omap_mbox_ops omap2_mbox_ops = { .type =OMAP_MBOX_TYPE2 , .startup = omap2_mbox_startup,
@@ -217,168 +244,39 @@ static struct omap_mbox_ops omap2_mbox_ops = { .is_irq = omap2_mbox_is_irq, .save_ctx = omap2_mbox_save_ctx, .restore_ctx = omap2_mbox_restore_ctx, + .request = omap2_mbox_request, + .release = omap2_mbox_release, }; -/* -* MAILBOX 0: ARM -> DSP, -* MAILBOX 1: ARM <- DSP. -* MAILBOX 2: ARM -> IVA, -* MAILBOX 3: ARM <- IVA. -*/ - -/* FIXME: the following structs should be filled automatically by the user id */ - -#if defined(CONFIG_ARCH_OMAP3 ) || defined(CONFIG_ARCH_OMAP2 ) -/* DSP */ -static struct omap_mbox2_priv omap2_mbox_dsp_priv = { - .tx_fifo = { - .msg =MAILBOX_MESSAGE (0 ), - .fifo_stat =MAILBOX_FIFOSTATUS (0 ), - }, - .rx_fifo = { - .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 ), -}; - -struct omap_mbox mbox_dsp_info = { - .name ="dsp" , - .ops = &omap2_mbox_ops, - .priv = &omap2_mbox_dsp_priv, -}; -#endif - -#if defined(CONFIG_ARCH_OMAP3 ) -struct omap_mbox *omap3_mboxes[] = { &mbox_dsp_info,NULL }; -#endif - -#if defined(CONFIG_SOC_OMAP2420 ) -/* IVA */ -static struct omap_mbox2_priv omap2_mbox_iva_priv = { - .tx_fifo = { - .msg =MAILBOX_MESSAGE (2 ), - .fifo_stat =MAILBOX_FIFOSTATUS (2 ), - }, - .rx_fifo = { - .msg =MAILBOX_MESSAGE (3 ), - .msg_stat =MAILBOX_MSGSTATUS (3 ), - }, - .irqenable =MAILBOX_IRQENABLE (3 ), - .irqstatus =MAILBOX_IRQSTATUS (3 ), - .notfull_bit =MAILBOX_IRQ_NOTFULL (2 ), - .newmsg_bit =MAILBOX_IRQ_NEWMSG (3 ), - .irqdisable =MAILBOX_IRQENABLE (3 ), -}; - -static struct omap_mbox mbox_iva_info = { - .name ="iva" , - .ops = &omap2_mbox_ops, - .priv = &omap2_mbox_iva_priv, -}; - -struct omap_mbox *omap2_mboxes[] = { &mbox_dsp_info, &mbox_iva_info,NULL }; -#endif - -#if defined(CONFIG_ARCH_OMAP4 ) -/* OMAP4 */ -static struct omap_mbox2_priv omap2_mbox_1_priv = { - .tx_fifo = { - .msg =MAILBOX_MESSAGE (0 ), - .fifo_stat =MAILBOX_FIFOSTATUS (0 ), - }, - .rx_fifo = { - .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 ), -}; - -struct omap_mbox mbox_1_info = { - .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 ), - }, - .rx_fifo = { - .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 ), - .irqdisable =OMAP4_MAILBOX_IRQENABLE_CLR (0 ), -}; - -struct omap_mbox 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 }; -#endif -static int __devinit omap2_mbox_probe (struct platform_device *pdev) {struct resource *mem; +struct mbox_info *arch_mbi; +struct omap_mailbox_platform_data *pdata = pdev->dev.platform_data;int ret; -struct omap_mbox **list; -if (false) - ; -#if defined(CONFIG_ARCH_OMAP3 ) - else if (cpu_is_omap34xx()) { - list = omap3_mboxes; - - list[0 ]->irq =platform_get_irq (pdev,0 ); - } -#endif -#if defined(CONFIG_ARCH_OMAP2 ) - else if (cpu_is_omap2430()) { - list = omap2_mboxes; - - list[0 ]->irq =platform_get_irq (pdev,0 ); - } else if (cpu_is_omap2420()) { - list = omap2_mboxes; - - list[0 ]->irq =platform_get_irq_byname (pdev,"dsp" ); - list[1 ]->irq =platform_get_irq_byname (pdev,"iva" ); - } -#endif -#if defined(CONFIG_ARCH_OMAP4 ) - else if (cpu_is_omap44xx()) { - list = omap4_mboxes; - - list[0 ]->irq = list[1 ]->irq =platform_get_irq (pdev,0 ); - } -#endif - else { -pr_err ("%s: platform not supported\n" , __func__); +if (!pdata)return -ENODEV ; - } mem =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); mbox_base =ioremap (mem->start,resource_size (mem));if (!mbox_base)return -ENOMEM ; - ret =omap_mbox_register (&pdev->dev, list); + arch_mbi =kzalloc (sizeof (struct mbox_info ),GFP_KERNEL ); +if (!arch_mbi) { +iounmap (mbox_base); +return -ENOMEM ; + } + + arch_mbi->dev = &pdev->dev; + arch_mbi->ops = &omap2_mbox_ops; + arch_mbi->kfifo_size = mbox_kfifo_size; + arch_mbi->nr_mbox = pdata->nr_mbox; + + ret =omap_mbox_register (arch_mbi);if (ret) { +kfree (arch_mbi);iounmap (mbox_base);return ret; }
Signature · 1 line
1.7.0.4