diff mbox

[02/15] ARM: OMAP2+: mailbox: Add support for AM33XX

Message ID 1351859566-24818-3-git-send-email-vaibhav.bedia@ti.com (mailing list archive)
State New, archived
Headers show

Commit Message

Vaibhav Bedia Nov. 2, 2012, 12:32 p.m. UTC
Mailbox IP on AM33XX, is the same as that present
in OMAP4. The single instance of Mailbox module
contains 8 sub-modules and facilitates communication
between MPU, PRUs and WKUP_M3.

The first mailbox sub-module is assigned for
communication between MPU and WKUP-M3.

Signed-off-by: Vaibhav Bedia <vaibhav.bedia@ti.com>
---
 arch/arm/mach-omap2/mailbox.c |   35 ++++++++++++++++++++++++++++++++++-
 1 files changed, 34 insertions(+), 1 deletions(-)

Comments

Russ Dill Nov. 3, 2012, 12:14 a.m. UTC | #1
On Fri, Nov 2, 2012 at 5:32 AM, Vaibhav Bedia <vaibhav.bedia@ti.com> wrote:
> Mailbox IP on AM33XX, is the same as that present
> in OMAP4. The single instance of Mailbox module
> contains 8 sub-modules and facilitates communication
> between MPU, PRUs and WKUP_M3.
>
> The first mailbox sub-module is assigned for
> communication between MPU and WKUP-M3.
>
> Signed-off-by: Vaibhav Bedia <vaibhav.bedia@ti.com>
> ---
>  arch/arm/mach-omap2/mailbox.c |   35 ++++++++++++++++++++++++++++++++++-
>  1 files changed, 34 insertions(+), 1 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/mailbox.c b/arch/arm/mach-omap2/mailbox.c
> index f38b4fa..7a343aa 100644
> --- a/arch/arm/mach-omap2/mailbox.c
> +++ b/arch/arm/mach-omap2/mailbox.c
> @@ -155,7 +155,7 @@ static void omap2_mbox_disable_irq(struct omap_mbox *mbox,
>         struct omap_mbox2_priv *p = mbox->priv;
>         u32 bit = (irq == IRQ_TX) ? p->notfull_bit : p->newmsg_bit;
>
> -       if (!cpu_is_omap44xx())
> +       if (!cpu_is_omap44xx() || !soc_is_am33xx())
>                 bit = mbox_read_reg(p->irqdisable) & ~bit;

Do you mean &&?

>         mbox_write_reg(bit, p->irqdisable);
> @@ -358,6 +358,32 @@ struct omap_mbox mbox_2_info = {
>  struct omap_mbox *omap4_mboxes[] = { &mbox_1_info, &mbox_2_info, NULL };
>  #endif
>
> +#if defined(CONFIG_SOC_AM33XX)
> +static struct omap_mbox2_priv omap2_mbox_wkup_m3_priv = {
> +       .tx_fifo = {
> +               .msg            = MAILBOX_MESSAGE(0),
> +               .fifo_stat      = MAILBOX_FIFOSTATUS(0),
> +               .msg_stat       = MAILBOX_MSGSTATUS(0),
> +       },
> +       .rx_fifo = {
> +               .msg            = MAILBOX_MESSAGE(1),
> +               .msg_stat       = MAILBOX_MSGSTATUS(1),
> +       },
> +       .irqenable      = OMAP4_MAILBOX_IRQENABLE(3),
> +       .irqstatus      = OMAP4_MAILBOX_IRQSTATUS(3),
> +       .irqdisable     = OMAP4_MAILBOX_IRQENABLE_CLR(3),
> +       .notfull_bit    = MAILBOX_IRQ_NOTFULL(0),
> +       .newmsg_bit     = MAILBOX_IRQ_NEWMSG(0),
> +};
> +
> +struct omap_mbox mbox_wkup_m3_info = {
> +       .name   = "wkup_m3",
> +       .ops    = &omap2_mbox_ops,
> +       .priv   = &omap2_mbox_wkup_m3_priv,
> +};
> +struct omap_mbox *am33xx_mboxes[] = { &mbox_wkup_m3_info, NULL };
> +#endif
> +
>  static int __devinit omap2_mbox_probe(struct platform_device *pdev)
>  {
>         struct resource *mem;
> @@ -392,6 +418,13 @@ static int __devinit omap2_mbox_probe(struct platform_device *pdev)
>                 list[0]->irq = list[1]->irq = platform_get_irq(pdev, 0);
>         }
>  #endif
> +#if defined(CONFIG_SOC_AM33XX)
> +       else if (soc_is_am33xx()) {
> +               list = am33xx_mboxes;
> +
> +               list[0]->irq = platform_get_irq(pdev, 0);
> +       }
> +#endif
>         else {
>                 pr_err("%s: platform not supported\n", __func__);
>                 return -ENODEV;
> --
> 1.7.0.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
Vaibhav Bedia Nov. 3, 2012, 8:39 a.m. UTC | #2
Hi Russ,

On Sat, Nov 03, 2012 at 05:44:21, Russ Dill wrote:
[...]
> > -       if (!cpu_is_omap44xx())
> > +       if (!cpu_is_omap44xx() || !soc_is_am33xx())
> >                 bit = mbox_read_reg(p->irqdisable) & ~bit;
> 
> Do you mean &&?
> 

I didn't change that line but it looks ok to me :)

Regards,
Vaibhav
Vaibhav Bedia Nov. 3, 2012, 1:48 p.m. UTC | #3
On Sat, Nov 03, 2012 at 14:06:38, Bedia, Vaibhav wrote:
> Hi Russ,
> 
> On Sat, Nov 03, 2012 at 05:44:21, Russ Dill wrote:
> [...]
> > > -       if (!cpu_is_omap44xx())
> > > +       if (!cpu_is_omap44xx() || !soc_is_am33xx())
> > >                 bit = mbox_read_reg(p->irqdisable) & ~bit;
> > 
> > Do you mean &&?
> > 
> 

Ok I understood what you meant. Will fix it in next rev.

Regards,
Vaibhav
Santosh Shilimkar Nov. 3, 2012, 4:10 p.m. UTC | #4
On Friday 02 November 2012 06:02 PM, Vaibhav Bedia wrote:
> Mailbox IP on AM33XX, is the same as that present
> in OMAP4. The single instance of Mailbox module
> contains 8 sub-modules and facilitates communication
> between MPU, PRUs and WKUP_M3.
>
> The first mailbox sub-module is assigned for
> communication between MPU and WKUP-M3.
>
> Signed-off-by: Vaibhav Bedia <vaibhav.bedia@ti.com>
> ---
>   arch/arm/mach-omap2/mailbox.c |   35 ++++++++++++++++++++++++++++++++++-
>   1 files changed, 34 insertions(+), 1 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/mailbox.c b/arch/arm/mach-omap2/mailbox.c
> index f38b4fa..7a343aa 100644
> --- a/arch/arm/mach-omap2/mailbox.c
> +++ b/arch/arm/mach-omap2/mailbox.c
> @@ -155,7 +155,7 @@ static void omap2_mbox_disable_irq(struct omap_mbox *mbox,
>   	struct omap_mbox2_priv *p = mbox->priv;
>   	u32 bit = (irq == IRQ_TX) ? p->notfull_bit : p->newmsg_bit;
>
> -	if (!cpu_is_omap44xx())
> +	if (!cpu_is_omap44xx() || !soc_is_am33xx())
>   		bit = mbox_read_reg(p->irqdisable) & ~bit;
>
>   	mbox_write_reg(bit, p->irqdisable);
> @@ -358,6 +358,32 @@ struct omap_mbox mbox_2_info = {
>   struct omap_mbox *omap4_mboxes[] = { &mbox_1_info, &mbox_2_info, NULL };
>   #endif
>
> +#if defined(CONFIG_SOC_AM33XX)
> +static struct omap_mbox2_priv omap2_mbox_wkup_m3_priv = {
> +	.tx_fifo = {
> +		.msg		= MAILBOX_MESSAGE(0),
> +		.fifo_stat	= MAILBOX_FIFOSTATUS(0),
> +		.msg_stat	= MAILBOX_MSGSTATUS(0),
> +	},
> +	.rx_fifo = {
> +		.msg		= MAILBOX_MESSAGE(1),
> +		.msg_stat	= MAILBOX_MSGSTATUS(1),
> +	},
> +	.irqenable	= OMAP4_MAILBOX_IRQENABLE(3),
> +	.irqstatus	= OMAP4_MAILBOX_IRQSTATUS(3),
> +	.irqdisable	= OMAP4_MAILBOX_IRQENABLE_CLR(3),
> +	.notfull_bit	= MAILBOX_IRQ_NOTFULL(0),
> +	.newmsg_bit	= MAILBOX_IRQ_NEWMSG(0),
> +};
> +
> +struct omap_mbox mbox_wkup_m3_info = {
> +	.name	= "wkup_m3",
> +	.ops	= &omap2_mbox_ops,
> +	.priv	= &omap2_mbox_wkup_m3_priv,
> +};
> +struct omap_mbox *am33xx_mboxes[] = { &mbox_wkup_m3_info, NULL };
> +#endif
> +
>   static int __devinit omap2_mbox_probe(struct platform_device *pdev)
>   {
>   	struct resource *mem;
> @@ -392,6 +418,13 @@ static int __devinit omap2_mbox_probe(struct platform_device *pdev)
>   		list[0]->irq = list[1]->irq = platform_get_irq(pdev, 0);
>   	}
>   #endif
> +#if defined(CONFIG_SOC_AM33XX)
> +	else if (soc_is_am33xx()) {
> +		list = am33xx_mboxes;
> +
> +		list[0]->irq = platform_get_irq(pdev, 0);
> +	}
> +#endif
#ifdef in middle of the function looks really ugly. But I can't complain
just for your patch because looks like rest of the mailbox code is
flooded with #ifdeffery.

Mailbox needs cleanup. and probably can be moved out of
arch/arm/*omap*/ to some driver directory.

Regards
santosh


inside arch/arm/mach-omap2/* directory.
Vaibhav Bedia Nov. 4, 2012, 3:26 p.m. UTC | #5
On Sat, Nov 03, 2012 at 21:40:37, Shilimkar, Santosh wrote:
[...]

> > +#if defined(CONFIG_SOC_AM33XX)
> > +	else if (soc_is_am33xx()) {
> > +		list = am33xx_mboxes;
> > +
> > +		list[0]->irq = platform_get_irq(pdev, 0);
> > +	}
> > +#endif
> #ifdef in middle of the function looks really ugly. But I can't complain
> just for your patch because looks like rest of the mailbox code is
> flooded with #ifdeffery.
> 
> Mailbox needs cleanup. and probably can be moved out of
> arch/arm/*omap*/ to some driver directory.
> 

Tony pointed out that the movement to drivers directory
is underway [1]. Getting rid of the #ifdeffery could be next.

Regards,
Vaibhav

[1] http://www.spinics.net/lists/linux-omap/msg80702.html
Santosh Shilimkar Nov. 5, 2012, 3 p.m. UTC | #6
On Sunday 04 November 2012 08:56 PM, Bedia, Vaibhav wrote:
> On Sat, Nov 03, 2012 at 21:40:37, Shilimkar, Santosh wrote:
> [...]
>
>>> +#if defined(CONFIG_SOC_AM33XX)
>>> +	else if (soc_is_am33xx()) {
>>> +		list = am33xx_mboxes;
>>> +
>>> +		list[0]->irq = platform_get_irq(pdev, 0);
>>> +	}
>>> +#endif
>> #ifdef in middle of the function looks really ugly. But I can't complain
>> just for your patch because looks like rest of the mailbox code is
>> flooded with #ifdeffery.
>>
>> Mailbox needs cleanup. and probably can be moved out of
>> arch/arm/*omap*/ to some driver directory.
>>
>
> Tony pointed out that the movement to drivers directory
> is underway [1]. Getting rid of the #ifdeffery could be next.
>
Thanks for the pointer. Nice to see mailbox is getting moved
to drivers directory.

Regards
Santosh
diff mbox

Patch

diff --git a/arch/arm/mach-omap2/mailbox.c b/arch/arm/mach-omap2/mailbox.c
index f38b4fa..7a343aa 100644
--- a/arch/arm/mach-omap2/mailbox.c
+++ b/arch/arm/mach-omap2/mailbox.c
@@ -155,7 +155,7 @@  static void omap2_mbox_disable_irq(struct omap_mbox *mbox,
 	struct omap_mbox2_priv *p = mbox->priv;
 	u32 bit = (irq == IRQ_TX) ? p->notfull_bit : p->newmsg_bit;
 
-	if (!cpu_is_omap44xx())
+	if (!cpu_is_omap44xx() || !soc_is_am33xx())
 		bit = mbox_read_reg(p->irqdisable) & ~bit;
 
 	mbox_write_reg(bit, p->irqdisable);
@@ -358,6 +358,32 @@  struct omap_mbox mbox_2_info = {
 struct omap_mbox *omap4_mboxes[] = { &mbox_1_info, &mbox_2_info, NULL };
 #endif
 
+#if defined(CONFIG_SOC_AM33XX)
+static struct omap_mbox2_priv omap2_mbox_wkup_m3_priv = {
+	.tx_fifo = {
+		.msg		= MAILBOX_MESSAGE(0),
+		.fifo_stat	= MAILBOX_FIFOSTATUS(0),
+		.msg_stat	= MAILBOX_MSGSTATUS(0),
+	},
+	.rx_fifo = {
+		.msg		= MAILBOX_MESSAGE(1),
+		.msg_stat	= MAILBOX_MSGSTATUS(1),
+	},
+	.irqenable	= OMAP4_MAILBOX_IRQENABLE(3),
+	.irqstatus	= OMAP4_MAILBOX_IRQSTATUS(3),
+	.irqdisable	= OMAP4_MAILBOX_IRQENABLE_CLR(3),
+	.notfull_bit	= MAILBOX_IRQ_NOTFULL(0),
+	.newmsg_bit	= MAILBOX_IRQ_NEWMSG(0),
+};
+
+struct omap_mbox mbox_wkup_m3_info = {
+	.name	= "wkup_m3",
+	.ops	= &omap2_mbox_ops,
+	.priv	= &omap2_mbox_wkup_m3_priv,
+};
+struct omap_mbox *am33xx_mboxes[] = { &mbox_wkup_m3_info, NULL };
+#endif
+
 static int __devinit omap2_mbox_probe(struct platform_device *pdev)
 {
 	struct resource *mem;
@@ -392,6 +418,13 @@  static int __devinit omap2_mbox_probe(struct platform_device *pdev)
 		list[0]->irq = list[1]->irq = platform_get_irq(pdev, 0);
 	}
 #endif
+#if defined(CONFIG_SOC_AM33XX)
+	else if (soc_is_am33xx()) {
+		list = am33xx_mboxes;
+
+		list[0]->irq = platform_get_irq(pdev, 0);
+	}
+#endif
 	else {
 		pr_err("%s: platform not supported\n", __func__);
 		return -ENODEV;