diff options
Diffstat (limited to 'arch/arm/mach-omap2/mailbox.c')
-rw-r--r-- | arch/arm/mach-omap2/mailbox.c | 74 |
1 files changed, 9 insertions, 65 deletions
diff --git a/arch/arm/mach-omap2/mailbox.c b/arch/arm/mach-omap2/mailbox.c index 24b88504df0f..86d564a640bb 100644 --- a/arch/arm/mach-omap2/mailbox.c +++ b/arch/arm/mach-omap2/mailbox.c | |||
@@ -14,12 +14,11 @@ | |||
14 | #include <linux/err.h> | 14 | #include <linux/err.h> |
15 | #include <linux/platform_device.h> | 15 | #include <linux/platform_device.h> |
16 | #include <linux/io.h> | 16 | #include <linux/io.h> |
17 | #include <linux/pm_runtime.h> | ||
17 | #include <plat/mailbox.h> | 18 | #include <plat/mailbox.h> |
18 | #include <mach/irqs.h> | 19 | #include <mach/irqs.h> |
19 | 20 | ||
20 | #define MAILBOX_REVISION 0x000 | 21 | #define MAILBOX_REVISION 0x000 |
21 | #define MAILBOX_SYSCONFIG 0x010 | ||
22 | #define MAILBOX_SYSSTATUS 0x014 | ||
23 | #define MAILBOX_MESSAGE(m) (0x040 + 4 * (m)) | 22 | #define MAILBOX_MESSAGE(m) (0x040 + 4 * (m)) |
24 | #define MAILBOX_FIFOSTATUS(m) (0x080 + 4 * (m)) | 23 | #define MAILBOX_FIFOSTATUS(m) (0x080 + 4 * (m)) |
25 | #define MAILBOX_MSGSTATUS(m) (0x0c0 + 4 * (m)) | 24 | #define MAILBOX_MSGSTATUS(m) (0x0c0 + 4 * (m)) |
@@ -33,17 +32,6 @@ | |||
33 | #define MAILBOX_IRQ_NEWMSG(m) (1 << (2 * (m))) | 32 | #define MAILBOX_IRQ_NEWMSG(m) (1 << (2 * (m))) |
34 | #define MAILBOX_IRQ_NOTFULL(m) (1 << (2 * (m) + 1)) | 33 | #define MAILBOX_IRQ_NOTFULL(m) (1 << (2 * (m) + 1)) |
35 | 34 | ||
36 | /* SYSCONFIG: register bit definition */ | ||
37 | #define AUTOIDLE (1 << 0) | ||
38 | #define SOFTRESET (1 << 1) | ||
39 | #define SMARTIDLE (2 << 3) | ||
40 | #define OMAP4_SOFTRESET (1 << 0) | ||
41 | #define OMAP4_NOIDLE (1 << 2) | ||
42 | #define OMAP4_SMARTIDLE (2 << 2) | ||
43 | |||
44 | /* SYSSTATUS: register bit definition */ | ||
45 | #define RESETDONE (1 << 0) | ||
46 | |||
47 | #define MBOX_REG_SIZE 0x120 | 35 | #define MBOX_REG_SIZE 0x120 |
48 | 36 | ||
49 | #define OMAP4_MBOX_REG_SIZE 0x130 | 37 | #define OMAP4_MBOX_REG_SIZE 0x130 |
@@ -70,8 +58,6 @@ struct omap_mbox2_priv { | |||
70 | unsigned long irqdisable; | 58 | unsigned long irqdisable; |
71 | }; | 59 | }; |
72 | 60 | ||
73 | static struct clk *mbox_ick_handle; | ||
74 | |||
75 | static void omap2_mbox_enable_irq(struct omap_mbox *mbox, | 61 | static void omap2_mbox_enable_irq(struct omap_mbox *mbox, |
76 | omap_mbox_type_t irq); | 62 | omap_mbox_type_t irq); |
77 | 63 | ||
@@ -89,53 +75,13 @@ static inline void mbox_write_reg(u32 val, size_t ofs) | |||
89 | static int omap2_mbox_startup(struct omap_mbox *mbox) | 75 | static int omap2_mbox_startup(struct omap_mbox *mbox) |
90 | { | 76 | { |
91 | u32 l; | 77 | u32 l; |
92 | unsigned long timeout; | ||
93 | 78 | ||
94 | mbox_ick_handle = clk_get(NULL, "mailboxes_ick"); | 79 | pm_runtime_enable(mbox->dev->parent); |
95 | if (IS_ERR(mbox_ick_handle)) { | 80 | pm_runtime_get_sync(mbox->dev->parent); |
96 | printk(KERN_ERR "Could not get mailboxes_ick: %ld\n", | ||
97 | PTR_ERR(mbox_ick_handle)); | ||
98 | return PTR_ERR(mbox_ick_handle); | ||
99 | } | ||
100 | clk_enable(mbox_ick_handle); | ||
101 | |||
102 | if (cpu_is_omap44xx()) { | ||
103 | mbox_write_reg(OMAP4_SOFTRESET, MAILBOX_SYSCONFIG); | ||
104 | timeout = jiffies + msecs_to_jiffies(20); | ||
105 | do { | ||
106 | l = mbox_read_reg(MAILBOX_SYSCONFIG); | ||
107 | if (!(l & OMAP4_SOFTRESET)) | ||
108 | break; | ||
109 | } while (!time_after(jiffies, timeout)); | ||
110 | |||
111 | if (l & OMAP4_SOFTRESET) { | ||
112 | pr_err("Can't take mailbox out of reset\n"); | ||
113 | return -ENODEV; | ||
114 | } | ||
115 | } else { | ||
116 | mbox_write_reg(SOFTRESET, MAILBOX_SYSCONFIG); | ||
117 | timeout = jiffies + msecs_to_jiffies(20); | ||
118 | do { | ||
119 | l = mbox_read_reg(MAILBOX_SYSSTATUS); | ||
120 | if (l & RESETDONE) | ||
121 | break; | ||
122 | } while (!time_after(jiffies, timeout)); | ||
123 | |||
124 | if (!(l & RESETDONE)) { | ||
125 | pr_err("Can't take mailbox out of reset\n"); | ||
126 | return -ENODEV; | ||
127 | } | ||
128 | } | ||
129 | 81 | ||
130 | l = mbox_read_reg(MAILBOX_REVISION); | 82 | l = mbox_read_reg(MAILBOX_REVISION); |
131 | pr_debug("omap mailbox rev %d.%d\n", (l & 0xf0) >> 4, (l & 0x0f)); | 83 | pr_debug("omap mailbox rev %d.%d\n", (l & 0xf0) >> 4, (l & 0x0f)); |
132 | 84 | ||
133 | if (cpu_is_omap44xx()) | ||
134 | l = OMAP4_SMARTIDLE; | ||
135 | else | ||
136 | l = SMARTIDLE | AUTOIDLE; | ||
137 | mbox_write_reg(l, MAILBOX_SYSCONFIG); | ||
138 | |||
139 | omap2_mbox_enable_irq(mbox, IRQ_RX); | 85 | omap2_mbox_enable_irq(mbox, IRQ_RX); |
140 | 86 | ||
141 | return 0; | 87 | return 0; |
@@ -143,9 +89,8 @@ static int omap2_mbox_startup(struct omap_mbox *mbox) | |||
143 | 89 | ||
144 | static void omap2_mbox_shutdown(struct omap_mbox *mbox) | 90 | static void omap2_mbox_shutdown(struct omap_mbox *mbox) |
145 | { | 91 | { |
146 | clk_disable(mbox_ick_handle); | 92 | pm_runtime_put_sync(mbox->dev->parent); |
147 | clk_put(mbox_ick_handle); | 93 | pm_runtime_disable(mbox->dev->parent); |
148 | mbox_ick_handle = NULL; | ||
149 | } | 94 | } |
150 | 95 | ||
151 | /* Mailbox FIFO handle functions */ | 96 | /* Mailbox FIFO handle functions */ |
@@ -312,7 +257,7 @@ struct omap_mbox mbox_dsp_info = { | |||
312 | struct omap_mbox *omap3_mboxes[] = { &mbox_dsp_info, NULL }; | 257 | struct omap_mbox *omap3_mboxes[] = { &mbox_dsp_info, NULL }; |
313 | #endif | 258 | #endif |
314 | 259 | ||
315 | #if defined(CONFIG_ARCH_OMAP2420) | 260 | #if defined(CONFIG_SOC_OMAP2420) |
316 | /* IVA */ | 261 | /* IVA */ |
317 | static struct omap_mbox2_priv omap2_mbox_iva_priv = { | 262 | static struct omap_mbox2_priv omap2_mbox_iva_priv = { |
318 | .tx_fifo = { | 263 | .tx_fifo = { |
@@ -400,14 +345,14 @@ static int __devinit omap2_mbox_probe(struct platform_device *pdev) | |||
400 | else if (cpu_is_omap34xx()) { | 345 | else if (cpu_is_omap34xx()) { |
401 | list = omap3_mboxes; | 346 | list = omap3_mboxes; |
402 | 347 | ||
403 | list[0]->irq = platform_get_irq_byname(pdev, "dsp"); | 348 | list[0]->irq = platform_get_irq(pdev, 0); |
404 | } | 349 | } |
405 | #endif | 350 | #endif |
406 | #if defined(CONFIG_ARCH_OMAP2) | 351 | #if defined(CONFIG_ARCH_OMAP2) |
407 | else if (cpu_is_omap2430()) { | 352 | else if (cpu_is_omap2430()) { |
408 | list = omap2_mboxes; | 353 | list = omap2_mboxes; |
409 | 354 | ||
410 | list[0]->irq = platform_get_irq_byname(pdev, "dsp"); | 355 | list[0]->irq = platform_get_irq(pdev, 0); |
411 | } else if (cpu_is_omap2420()) { | 356 | } else if (cpu_is_omap2420()) { |
412 | list = omap2_mboxes; | 357 | list = omap2_mboxes; |
413 | 358 | ||
@@ -419,8 +364,7 @@ static int __devinit omap2_mbox_probe(struct platform_device *pdev) | |||
419 | else if (cpu_is_omap44xx()) { | 364 | else if (cpu_is_omap44xx()) { |
420 | list = omap4_mboxes; | 365 | list = omap4_mboxes; |
421 | 366 | ||
422 | list[0]->irq = list[1]->irq = | 367 | list[0]->irq = list[1]->irq = platform_get_irq(pdev, 0); |
423 | platform_get_irq_byname(pdev, "mbox"); | ||
424 | } | 368 | } |
425 | #endif | 369 | #endif |
426 | else { | 370 | else { |