aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-omap2/mailbox.c
diff options
context:
space:
mode:
authorC A Subramaniam <subramaniam.ca@ti.com>2009-11-22 13:11:22 -0500
committerTony Lindgren <tony@atomide.com>2009-11-22 13:24:33 -0500
commit5f00ec64a38563f1e5d8a852f2279047edecd0b8 (patch)
treeb3b336c5e6c91bbc81f4d78e04329629e4b338e2 /arch/arm/mach-omap2/mailbox.c
parenteb18858ebda7f4ef3d7de33e1b9bf11ac4cc137b (diff)
omap: mailbox: Adds code changes to support OMAP4 mailbox
This patch adds code changes in the mailbox driver module to add support for OMAP4 mailbox. Signed-off-by: Hari Kanigeri <h-kanigeri2@ti.com> Signed-off-by: C A Subramaniam <subramaniam.ca@ti.com> Signed-off-by: Ramesh Gupta G <grgupta@ti.com> Signed-off-by: Hiroshi DOYU <Hiroshi.DOYU@nokia.com> Signed-off-by: Tony Lindgren <tony@atomide.com>
Diffstat (limited to 'arch/arm/mach-omap2/mailbox.c')
-rw-r--r--arch/arm/mach-omap2/mailbox.c140
1 files changed, 116 insertions, 24 deletions
diff --git a/arch/arm/mach-omap2/mailbox.c b/arch/arm/mach-omap2/mailbox.c
index 5ba3aa69465e..281ab6342448 100644
--- a/arch/arm/mach-omap2/mailbox.c
+++ b/arch/arm/mach-omap2/mailbox.c
@@ -18,6 +18,8 @@
18#include <plat/mailbox.h> 18#include <plat/mailbox.h>
19#include <mach/irqs.h> 19#include <mach/irqs.h>
20 20
21#define DRV_NAME "omap2-mailbox"
22
21#define MAILBOX_REVISION 0x000 23#define MAILBOX_REVISION 0x000
22#define MAILBOX_SYSCONFIG 0x010 24#define MAILBOX_SYSCONFIG 0x010
23#define MAILBOX_SYSSTATUS 0x014 25#define MAILBOX_SYSSTATUS 0x014
@@ -27,8 +29,12 @@
27#define MAILBOX_IRQSTATUS(u) (0x100 + 8 * (u)) 29#define MAILBOX_IRQSTATUS(u) (0x100 + 8 * (u))
28#define MAILBOX_IRQENABLE(u) (0x104 + 8 * (u)) 30#define MAILBOX_IRQENABLE(u) (0x104 + 8 * (u))
29 31
30#define MAILBOX_IRQ_NEWMSG(u) (1 << (2 * (u))) 32#define OMAP4_MAILBOX_IRQSTATUS(u) (0x104 + 10 * (u))
31#define MAILBOX_IRQ_NOTFULL(u) (1 << (2 * (u) + 1)) 33#define OMAP4_MAILBOX_IRQENABLE(u) (0x108 + 10 * (u))
34#define OMAP4_MAILBOX_IRQENABLE_CLR(u) (0x10c + 10 * (u))
35
36#define MAILBOX_IRQ_NEWMSG(m) (1 << (2 * (m)))
37#define MAILBOX_IRQ_NOTFULL(m) (1 << (2 * (m) + 1))
32 38
33/* SYSCONFIG: register bit definition */ 39/* SYSCONFIG: register bit definition */
34#define AUTOIDLE (1 << 0) 40#define AUTOIDLE (1 << 0)
@@ -39,7 +45,11 @@
39#define RESETDONE (1 << 0) 45#define RESETDONE (1 << 0)
40 46
41#define MBOX_REG_SIZE 0x120 47#define MBOX_REG_SIZE 0x120
48
49#define OMAP4_MBOX_REG_SIZE 0x130
50
42#define MBOX_NR_REGS (MBOX_REG_SIZE / sizeof(u32)) 51#define MBOX_NR_REGS (MBOX_REG_SIZE / sizeof(u32))
52#define OMAP4_MBOX_NR_REGS (OMAP4_MBOX_REG_SIZE / sizeof(u32))
43 53
44static void __iomem *mbox_base; 54static void __iomem *mbox_base;
45 55
@@ -56,7 +66,8 @@ struct omap_mbox2_priv {
56 unsigned long irqstatus; 66 unsigned long irqstatus;
57 u32 newmsg_bit; 67 u32 newmsg_bit;
58 u32 notfull_bit; 68 u32 notfull_bit;
59 u32 ctx[MBOX_NR_REGS]; 69 u32 ctx[OMAP4_MBOX_NR_REGS];
70 unsigned long irqdisable;
60}; 71};
61 72
62static struct clk *mbox_ick_handle; 73static struct clk *mbox_ick_handle;
@@ -82,8 +93,9 @@ static int omap2_mbox_startup(struct omap_mbox *mbox)
82 93
83 mbox_ick_handle = clk_get(NULL, "mailboxes_ick"); 94 mbox_ick_handle = clk_get(NULL, "mailboxes_ick");
84 if (IS_ERR(mbox_ick_handle)) { 95 if (IS_ERR(mbox_ick_handle)) {
85 pr_err("Can't get mailboxes_ick\n"); 96 printk(KERN_ERR "Could not get mailboxes_ick: %d\n",
86 return -ENODEV; 97 PTR_ERR(mbox_ick_handle));
98 return PTR_ERR(mbox_ick_handle);
87 } 99 }
88 clk_enable(mbox_ick_handle); 100 clk_enable(mbox_ick_handle);
89 101
@@ -115,6 +127,7 @@ static void omap2_mbox_shutdown(struct omap_mbox *mbox)
115{ 127{
116 clk_disable(mbox_ick_handle); 128 clk_disable(mbox_ick_handle);
117 clk_put(mbox_ick_handle); 129 clk_put(mbox_ick_handle);
130 mbox_ick_handle = NULL;
118} 131}
119 132
120/* Mailbox FIFO handle functions */ 133/* Mailbox FIFO handle functions */
@@ -143,7 +156,7 @@ static int omap2_mbox_fifo_full(struct omap_mbox *mbox)
143{ 156{
144 struct omap_mbox2_fifo *fifo = 157 struct omap_mbox2_fifo *fifo =
145 &((struct omap_mbox2_priv *)mbox->priv)->tx_fifo; 158 &((struct omap_mbox2_priv *)mbox->priv)->tx_fifo;
146 return (mbox_read_reg(fifo->fifo_stat)); 159 return mbox_read_reg(fifo->fifo_stat);
147} 160}
148 161
149/* Mailbox IRQ handle functions */ 162/* Mailbox IRQ handle functions */
@@ -163,10 +176,9 @@ static void omap2_mbox_disable_irq(struct omap_mbox *mbox,
163{ 176{
164 struct omap_mbox2_priv *p = (struct omap_mbox2_priv *)mbox->priv; 177 struct omap_mbox2_priv *p = (struct omap_mbox2_priv *)mbox->priv;
165 u32 l, bit = (irq == IRQ_TX) ? p->notfull_bit : p->newmsg_bit; 178 u32 l, bit = (irq == IRQ_TX) ? p->notfull_bit : p->newmsg_bit;
166 179 l = mbox_read_reg(p->irqdisable);
167 l = mbox_read_reg(p->irqenable);
168 l &= ~bit; 180 l &= ~bit;
169 mbox_write_reg(l, p->irqenable); 181 mbox_write_reg(l, p->irqdisable);
170} 182}
171 183
172static void omap2_mbox_ack_irq(struct omap_mbox *mbox, 184static void omap2_mbox_ack_irq(struct omap_mbox *mbox,
@@ -189,15 +201,19 @@ static int omap2_mbox_is_irq(struct omap_mbox *mbox,
189 u32 enable = mbox_read_reg(p->irqenable); 201 u32 enable = mbox_read_reg(p->irqenable);
190 u32 status = mbox_read_reg(p->irqstatus); 202 u32 status = mbox_read_reg(p->irqstatus);
191 203
192 return (enable & status & bit); 204 return (int)(enable & status & bit);
193} 205}
194 206
195static void omap2_mbox_save_ctx(struct omap_mbox *mbox) 207static void omap2_mbox_save_ctx(struct omap_mbox *mbox)
196{ 208{
197 int i; 209 int i;
198 struct omap_mbox2_priv *p = mbox->priv; 210 struct omap_mbox2_priv *p = mbox->priv;
199 211 int nr_regs;
200 for (i = 0; i < MBOX_NR_REGS; i++) { 212 if (cpu_is_omap44xx())
213 nr_regs = OMAP4_MBOX_NR_REGS;
214 else
215 nr_regs = MBOX_NR_REGS;
216 for (i = 0; i < nr_regs; i++) {
201 p->ctx[i] = mbox_read_reg(i * sizeof(u32)); 217 p->ctx[i] = mbox_read_reg(i * sizeof(u32));
202 218
203 dev_dbg(mbox->dev, "%s: [%02x] %08x\n", __func__, 219 dev_dbg(mbox->dev, "%s: [%02x] %08x\n", __func__,
@@ -209,8 +225,12 @@ static void omap2_mbox_restore_ctx(struct omap_mbox *mbox)
209{ 225{
210 int i; 226 int i;
211 struct omap_mbox2_priv *p = mbox->priv; 227 struct omap_mbox2_priv *p = mbox->priv;
212 228 int nr_regs;
213 for (i = 0; i < MBOX_NR_REGS; i++) { 229 if (cpu_is_omap44xx())
230 nr_regs = OMAP4_MBOX_NR_REGS;
231 else
232 nr_regs = MBOX_NR_REGS;
233 for (i = 0; i < nr_regs; i++) {
214 mbox_write_reg(p->ctx[i], i * sizeof(u32)); 234 mbox_write_reg(p->ctx[i], i * sizeof(u32));
215 235
216 dev_dbg(mbox->dev, "%s: [%02x] %08x\n", __func__, 236 dev_dbg(mbox->dev, "%s: [%02x] %08x\n", __func__,
@@ -242,7 +262,6 @@ static struct omap_mbox_ops omap2_mbox_ops = {
242 */ 262 */
243 263
244/* FIXME: the following structs should be filled automatically by the user id */ 264/* FIXME: the following structs should be filled automatically by the user id */
245
246/* DSP */ 265/* DSP */
247static struct omap_mbox2_priv omap2_mbox_dsp_priv = { 266static struct omap_mbox2_priv omap2_mbox_dsp_priv = {
248 .tx_fifo = { 267 .tx_fifo = {
@@ -257,8 +276,36 @@ static struct omap_mbox2_priv omap2_mbox_dsp_priv = {
257 .irqstatus = MAILBOX_IRQSTATUS(0), 276 .irqstatus = MAILBOX_IRQSTATUS(0),
258 .notfull_bit = MAILBOX_IRQ_NOTFULL(0), 277 .notfull_bit = MAILBOX_IRQ_NOTFULL(0),
259 .newmsg_bit = MAILBOX_IRQ_NEWMSG(1), 278 .newmsg_bit = MAILBOX_IRQ_NEWMSG(1),
279 .irqdisable = MAILBOX_IRQENABLE(0),
280};
281
282
283
284/* OMAP4 specific data structure. Use the cpu_is_omap4xxx()
285to use this*/
286static struct omap_mbox2_priv omap2_mbox_1_priv = {
287 .tx_fifo = {
288 .msg = MAILBOX_MESSAGE(0),
289 .fifo_stat = MAILBOX_FIFOSTATUS(0),
290 },
291 .rx_fifo = {
292 .msg = MAILBOX_MESSAGE(1),
293 .msg_stat = MAILBOX_MSGSTATUS(1),
294 },
295 .irqenable = OMAP4_MAILBOX_IRQENABLE(0),
296 .irqstatus = OMAP4_MAILBOX_IRQSTATUS(0),
297 .notfull_bit = MAILBOX_IRQ_NOTFULL(0),
298 .newmsg_bit = MAILBOX_IRQ_NEWMSG(1),
299 .irqdisable = OMAP4_MAILBOX_IRQENABLE_CLR(0),
260}; 300};
261 301
302struct omap_mbox mbox_1_info = {
303 .name = "mailbox-1",
304 .ops = &omap2_mbox_ops,
305 .priv = &omap2_mbox_1_priv,
306};
307EXPORT_SYMBOL(mbox_1_info);
308
262struct omap_mbox mbox_dsp_info = { 309struct omap_mbox mbox_dsp_info = {
263 .name = "dsp", 310 .name = "dsp",
264 .ops = &omap2_mbox_ops, 311 .ops = &omap2_mbox_ops,
@@ -266,6 +313,30 @@ struct omap_mbox mbox_dsp_info = {
266}; 313};
267EXPORT_SYMBOL(mbox_dsp_info); 314EXPORT_SYMBOL(mbox_dsp_info);
268 315
316static struct omap_mbox2_priv omap2_mbox_2_priv = {
317 .tx_fifo = {
318 .msg = MAILBOX_MESSAGE(3),
319 .fifo_stat = MAILBOX_FIFOSTATUS(3),
320 },
321 .rx_fifo = {
322 .msg = MAILBOX_MESSAGE(2),
323 .msg_stat = MAILBOX_MSGSTATUS(2),
324 },
325 .irqenable = OMAP4_MAILBOX_IRQENABLE(0),
326 .irqstatus = OMAP4_MAILBOX_IRQSTATUS(0),
327 .notfull_bit = MAILBOX_IRQ_NOTFULL(3),
328 .newmsg_bit = MAILBOX_IRQ_NEWMSG(2),
329 .irqdisable = OMAP4_MAILBOX_IRQENABLE_CLR(0),
330};
331
332struct omap_mbox mbox_2_info = {
333 .name = "mailbox-2",
334 .ops = &omap2_mbox_ops,
335 .priv = &omap2_mbox_2_priv,
336};
337EXPORT_SYMBOL(mbox_2_info);
338
339
269#if defined(CONFIG_ARCH_OMAP2420) /* IVA */ 340#if defined(CONFIG_ARCH_OMAP2420) /* IVA */
270static struct omap_mbox2_priv omap2_mbox_iva_priv = { 341static struct omap_mbox2_priv omap2_mbox_iva_priv = {
271 .tx_fifo = { 342 .tx_fifo = {
@@ -280,6 +351,7 @@ static struct omap_mbox2_priv omap2_mbox_iva_priv = {
280 .irqstatus = MAILBOX_IRQSTATUS(3), 351 .irqstatus = MAILBOX_IRQSTATUS(3),
281 .notfull_bit = MAILBOX_IRQ_NOTFULL(2), 352 .notfull_bit = MAILBOX_IRQ_NOTFULL(2),
282 .newmsg_bit = MAILBOX_IRQ_NEWMSG(3), 353 .newmsg_bit = MAILBOX_IRQ_NEWMSG(3),
354 .irqdisable = MAILBOX_IRQENABLE(3),
283}; 355};
284 356
285static struct omap_mbox mbox_iva_info = { 357static struct omap_mbox mbox_iva_info = {
@@ -305,17 +377,31 @@ static int __devinit omap2_mbox_probe(struct platform_device *pdev)
305 return -ENOMEM; 377 return -ENOMEM;
306 378
307 /* DSP or IVA2 IRQ */ 379 /* DSP or IVA2 IRQ */
308 ret = platform_get_irq(pdev, 0); 380 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
309 if (ret < 0) { 381
382 if (unlikely(!res)) {
310 dev_err(&pdev->dev, "invalid irq resource\n"); 383 dev_err(&pdev->dev, "invalid irq resource\n");
384 ret = -ENODEV;
311 goto err_dsp; 385 goto err_dsp;
312 } 386 }
313 mbox_dsp_info.irq = ret; 387 if (cpu_is_omap44xx()) {
314 388 mbox_1_info.irq = res->start;
315 ret = omap_mbox_register(&pdev->dev, &mbox_dsp_info); 389 ret = omap_mbox_register(&pdev->dev, &mbox_1_info);
390 } else {
391 mbox_dsp_info.irq = res->start;
392 ret = omap_mbox_register(&pdev->dev, &mbox_dsp_info);
393 }
316 if (ret) 394 if (ret)
317 goto err_dsp; 395 goto err_dsp;
318 396
397 if (cpu_is_omap44xx()) {
398 mbox_2_info.irq = res->start;
399 ret = omap_mbox_register(&pdev->dev, &mbox_2_info);
400 if (ret) {
401 omap_mbox_unregister(&mbox_1_info);
402 goto err_dsp;
403 }
404 }
319#if defined(CONFIG_ARCH_OMAP2420) /* IVA */ 405#if defined(CONFIG_ARCH_OMAP2420) /* IVA */
320 if (cpu_is_omap2420()) { 406 if (cpu_is_omap2420()) {
321 /* IVA IRQ */ 407 /* IVA IRQ */
@@ -335,6 +421,7 @@ static int __devinit omap2_mbox_probe(struct platform_device *pdev)
335 421
336err_iva1: 422err_iva1:
337 omap_mbox_unregister(&mbox_dsp_info); 423 omap_mbox_unregister(&mbox_dsp_info);
424
338err_dsp: 425err_dsp:
339 iounmap(mbox_base); 426 iounmap(mbox_base);
340 return ret; 427 return ret;
@@ -345,7 +432,12 @@ static int __devexit omap2_mbox_remove(struct platform_device *pdev)
345#if defined(CONFIG_ARCH_OMAP2420) 432#if defined(CONFIG_ARCH_OMAP2420)
346 omap_mbox_unregister(&mbox_iva_info); 433 omap_mbox_unregister(&mbox_iva_info);
347#endif 434#endif
348 omap_mbox_unregister(&mbox_dsp_info); 435
436 if (cpu_is_omap44xx()) {
437 omap_mbox_unregister(&mbox_2_info);
438 omap_mbox_unregister(&mbox_1_info);
439 } else
440 omap_mbox_unregister(&mbox_dsp_info);
349 iounmap(mbox_base); 441 iounmap(mbox_base);
350 return 0; 442 return 0;
351} 443}
@@ -354,7 +446,7 @@ static struct platform_driver omap2_mbox_driver = {
354 .probe = omap2_mbox_probe, 446 .probe = omap2_mbox_probe,
355 .remove = __devexit_p(omap2_mbox_remove), 447 .remove = __devexit_p(omap2_mbox_remove),
356 .driver = { 448 .driver = {
357 .name = "omap2-mailbox", 449 .name = DRV_NAME,
358 }, 450 },
359}; 451};
360 452
@@ -372,6 +464,6 @@ module_init(omap2_mbox_init);
372module_exit(omap2_mbox_exit); 464module_exit(omap2_mbox_exit);
373 465
374MODULE_LICENSE("GPL v2"); 466MODULE_LICENSE("GPL v2");
375MODULE_DESCRIPTION("omap mailbox: omap2/3 architecture specific functions"); 467MODULE_DESCRIPTION("omap mailbox: omap2/3/4 architecture specific functions");
376MODULE_AUTHOR("Hiroshi DOYU <Hiroshi.DOYU@nokia.com>, Paul Mundt"); 468MODULE_AUTHOR("Hiroshi DOYU <Hiroshi.DOYU@nokia.com>, Paul Mundt");
377MODULE_ALIAS("platform:omap2-mailbox"); 469MODULE_ALIAS("platform:"DRV_NAME);