[PATCH v2 01/13] ARM: OMAP2+: mbox: remove dependencies with soc.h

2013-02-11 Thread Suman Anna
The OMAP mailbox platform driver code has been cleaned up to
remove the dependencies with soc.h in preparation for moving
the mailbox code to drivers folder.

The code relied on cpu_is_xxx/soc_is_xxx macros previously to
pick the the right set of mailbox devices and register with the
mailbox driver. This data is now represented in a concise format
and moved to the respective omap_hwmod data files and published
to the driver through the platform data.

Signed-off-by: Suman Anna 
---
 arch/arm/mach-omap2/devices.c  |  13 +-
 arch/arm/mach-omap2/mailbox.c  | 234 ++---
 arch/arm/mach-omap2/omap_hwmod_2420_data.c |  12 ++
 arch/arm/mach-omap2/omap_hwmod_2430_data.c |  11 ++
 arch/arm/mach-omap2/omap_hwmod_3xxx_data.c |  11 ++
 arch/arm/mach-omap2/omap_hwmod_44xx_data.c |  13 ++
 include/linux/platform_data/mailbox-omap.h |  53 +++
 7 files changed, 189 insertions(+), 158 deletions(-)
 create mode 100644 include/linux/platform_data/mailbox-omap.h

diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
index 626f3ea..4b6a88e 100644
--- a/arch/arm/mach-omap2/devices.c
+++ b/arch/arm/mach-omap2/devices.c
@@ -20,6 +20,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -290,14 +291,24 @@ static inline void __init omap_init_mbox(void)
 {
struct omap_hwmod *oh;
struct platform_device *pdev;
+   struct omap_mbox_pdata *pdata;
+   u32 pdata_len;
 
oh = omap_hwmod_lookup("mailbox");
if (!oh) {
pr_err("%s: unable to find hwmod\n", __func__);
return;
}
+   if (!oh->dev_attr) {
+   pr_err("%s: hwmod doesn't have valid attrs\n", __func__);
+   return;
+   }
 
-   pdev = omap_device_build("omap-mailbox", -1, oh, NULL, 0, NULL, 0, 0);
+   pdata = (struct omap_mbox_pdata *)oh->dev_attr;
+   pdata_len = (pdata->info_cnt * (sizeof(struct omap_mbox_dev_info))) +
+   (2 * sizeof(u32));
+   pdev = omap_device_build("omap-mailbox", -1, oh, pdata, pdata_len,
+   NULL, 0, 0);
WARN(IS_ERR(pdev), "%s: could not build device, err %ld\n",
__func__, PTR_ERR(pdev));
 }
diff --git a/arch/arm/mach-omap2/mailbox.c b/arch/arm/mach-omap2/mailbox.c
index 0b08026..114d818 100644
--- a/arch/arm/mach-omap2/mailbox.c
+++ b/arch/arm/mach-omap2/mailbox.c
@@ -11,16 +11,16 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
-#include "soc.h"
-
 #define MAILBOX_REVISION   0x000
 #define MAILBOX_MESSAGE(m) (0x040 + 4 * (m))
 #define MAILBOX_FIFOSTATUS(m)  (0x080 + 4 * (m))
@@ -59,6 +59,7 @@ struct omap_mbox2_priv {
u32 notfull_bit;
u32 ctx[OMAP4_MBOX_NR_REGS];
unsigned long irqdisable;
+   u32 intr_type;
 };
 
 static void omap2_mbox_enable_irq(struct omap_mbox *mbox,
@@ -141,7 +142,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 (!p->intr_type)
bit = mbox_read_reg(p->irqdisable) & ~bit;
 
mbox_write_reg(bit, p->irqdisable);
@@ -175,7 +176,8 @@ static void omap2_mbox_save_ctx(struct omap_mbox *mbox)
int i;
struct omap_mbox2_priv *p = mbox->priv;
int nr_regs;
-   if (cpu_is_omap44xx())
+
+   if (p->intr_type)
nr_regs = OMAP4_MBOX_NR_REGS;
else
nr_regs = MBOX_NR_REGS;
@@ -192,7 +194,8 @@ static void omap2_mbox_restore_ctx(struct omap_mbox *mbox)
int i;
struct omap_mbox2_priv *p = mbox->priv;
int nr_regs;
-   if (cpu_is_omap44xx())
+
+   if (p->intr_type)
nr_regs = OMAP4_MBOX_NR_REGS;
else
nr_regs = MBOX_NR_REGS;
@@ -220,185 +223,102 @@ static struct omap_mbox_ops omap2_mbox_ops = {
.restore_ctx= omap2_mbox_restore_ctx,
 };
 
-/*
- * 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),
-   

[PATCH v2 01/13] ARM: OMAP2+: mbox: remove dependencies with soc.h

2013-02-11 Thread Suman Anna
The OMAP mailbox platform driver code has been cleaned up to
remove the dependencies with soc.h in preparation for moving
the mailbox code to drivers folder.

The code relied on cpu_is_xxx/soc_is_xxx macros previously to
pick the the right set of mailbox devices and register with the
mailbox driver. This data is now represented in a concise format
and moved to the respective omap_hwmod data files and published
to the driver through the platform data.

Signed-off-by: Suman Anna s-a...@ti.com
---
 arch/arm/mach-omap2/devices.c  |  13 +-
 arch/arm/mach-omap2/mailbox.c  | 234 ++---
 arch/arm/mach-omap2/omap_hwmod_2420_data.c |  12 ++
 arch/arm/mach-omap2/omap_hwmod_2430_data.c |  11 ++
 arch/arm/mach-omap2/omap_hwmod_3xxx_data.c |  11 ++
 arch/arm/mach-omap2/omap_hwmod_44xx_data.c |  13 ++
 include/linux/platform_data/mailbox-omap.h |  53 +++
 7 files changed, 189 insertions(+), 158 deletions(-)
 create mode 100644 include/linux/platform_data/mailbox-omap.h

diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
index 626f3ea..4b6a88e 100644
--- a/arch/arm/mach-omap2/devices.c
+++ b/arch/arm/mach-omap2/devices.c
@@ -20,6 +20,7 @@
 #include linux/pinctrl/machine.h
 #include linux/platform_data/omap4-keypad.h
 #include linux/platform_data/omap_ocp2scp.h
+#include linux/platform_data/mailbox-omap.h
 
 #include asm/mach-types.h
 #include asm/mach/map.h
@@ -290,14 +291,24 @@ static inline void __init omap_init_mbox(void)
 {
struct omap_hwmod *oh;
struct platform_device *pdev;
+   struct omap_mbox_pdata *pdata;
+   u32 pdata_len;
 
oh = omap_hwmod_lookup(mailbox);
if (!oh) {
pr_err(%s: unable to find hwmod\n, __func__);
return;
}
+   if (!oh-dev_attr) {
+   pr_err(%s: hwmod doesn't have valid attrs\n, __func__);
+   return;
+   }
 
-   pdev = omap_device_build(omap-mailbox, -1, oh, NULL, 0, NULL, 0, 0);
+   pdata = (struct omap_mbox_pdata *)oh-dev_attr;
+   pdata_len = (pdata-info_cnt * (sizeof(struct omap_mbox_dev_info))) +
+   (2 * sizeof(u32));
+   pdev = omap_device_build(omap-mailbox, -1, oh, pdata, pdata_len,
+   NULL, 0, 0);
WARN(IS_ERR(pdev), %s: could not build device, err %ld\n,
__func__, PTR_ERR(pdev));
 }
diff --git a/arch/arm/mach-omap2/mailbox.c b/arch/arm/mach-omap2/mailbox.c
index 0b08026..114d818 100644
--- a/arch/arm/mach-omap2/mailbox.c
+++ b/arch/arm/mach-omap2/mailbox.c
@@ -11,16 +11,16 @@
  */
 
 #include linux/module.h
+#include linux/slab.h
 #include linux/clk.h
 #include linux/err.h
 #include linux/platform_device.h
 #include linux/io.h
 #include linux/pm_runtime.h
+#include linux/platform_data/mailbox-omap.h
 
 #include plat/mailbox.h
 
-#include soc.h
-
 #define MAILBOX_REVISION   0x000
 #define MAILBOX_MESSAGE(m) (0x040 + 4 * (m))
 #define MAILBOX_FIFOSTATUS(m)  (0x080 + 4 * (m))
@@ -59,6 +59,7 @@ struct omap_mbox2_priv {
u32 notfull_bit;
u32 ctx[OMAP4_MBOX_NR_REGS];
unsigned long irqdisable;
+   u32 intr_type;
 };
 
 static void omap2_mbox_enable_irq(struct omap_mbox *mbox,
@@ -141,7 +142,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 (!p-intr_type)
bit = mbox_read_reg(p-irqdisable)  ~bit;
 
mbox_write_reg(bit, p-irqdisable);
@@ -175,7 +176,8 @@ static void omap2_mbox_save_ctx(struct omap_mbox *mbox)
int i;
struct omap_mbox2_priv *p = mbox-priv;
int nr_regs;
-   if (cpu_is_omap44xx())
+
+   if (p-intr_type)
nr_regs = OMAP4_MBOX_NR_REGS;
else
nr_regs = MBOX_NR_REGS;
@@ -192,7 +194,8 @@ static void omap2_mbox_restore_ctx(struct omap_mbox *mbox)
int i;
struct omap_mbox2_priv *p = mbox-priv;
int nr_regs;
-   if (cpu_is_omap44xx())
+
+   if (p-intr_type)
nr_regs = OMAP4_MBOX_NR_REGS;
else
nr_regs = MBOX_NR_REGS;
@@ -220,185 +223,102 @@ static struct omap_mbox_ops omap2_mbox_ops = {
.restore_ctx= omap2_mbox_restore_ctx,
 };
 
-/*
- * 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=