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 29b9dc3917af..6e15e3d7c65e 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 */ |
@@ -334,7 +279,7 @@ static struct omap_mbox mbox_iva_info = { | |||
334 | .priv = &omap2_mbox_iva_priv, | 279 | .priv = &omap2_mbox_iva_priv, |
335 | }; | 280 | }; |
336 | 281 | ||
337 | struct omap_mbox *omap2_mboxes[] = { &mbox_iva_info, &mbox_dsp_info, NULL }; | 282 | struct omap_mbox *omap2_mboxes[] = { &mbox_dsp_info, &mbox_iva_info, NULL }; |
338 | #endif | 283 | #endif |
339 | 284 | ||
340 | #if defined(CONFIG_ARCH_OMAP4) | 285 | #if defined(CONFIG_ARCH_OMAP4) |
@@ -398,14 +343,14 @@ static int __devinit omap2_mbox_probe(struct platform_device *pdev) | |||
398 | else if (cpu_is_omap34xx()) { | 343 | else if (cpu_is_omap34xx()) { |
399 | list = omap3_mboxes; | 344 | list = omap3_mboxes; |
400 | 345 | ||
401 | list[0]->irq = platform_get_irq_byname(pdev, "dsp"); | 346 | list[0]->irq = platform_get_irq(pdev, 0); |
402 | } | 347 | } |
403 | #endif | 348 | #endif |
404 | #if defined(CONFIG_ARCH_OMAP2) | 349 | #if defined(CONFIG_ARCH_OMAP2) |
405 | else if (cpu_is_omap2430()) { | 350 | else if (cpu_is_omap2430()) { |
406 | list = omap2_mboxes; | 351 | list = omap2_mboxes; |
407 | 352 | ||
408 | list[0]->irq = platform_get_irq_byname(pdev, "dsp"); | 353 | list[0]->irq = platform_get_irq(pdev, 0); |
409 | } else if (cpu_is_omap2420()) { | 354 | } else if (cpu_is_omap2420()) { |
410 | list = omap2_mboxes; | 355 | list = omap2_mboxes; |
411 | 356 | ||
@@ -417,8 +362,7 @@ static int __devinit omap2_mbox_probe(struct platform_device *pdev) | |||
417 | else if (cpu_is_omap44xx()) { | 362 | else if (cpu_is_omap44xx()) { |
418 | list = omap4_mboxes; | 363 | list = omap4_mboxes; |
419 | 364 | ||
420 | list[0]->irq = list[1]->irq = | 365 | list[0]->irq = list[1]->irq = platform_get_irq(pdev, 0); |
421 | platform_get_irq_byname(pdev, "mbox"); | ||
422 | } | 366 | } |
423 | #endif | 367 | #endif |
424 | else { | 368 | else { |