2 * This file is part of OMAP DSP driver (DSP Gateway version 3.3.1)
4 * Copyright (C) 2002-2006 Nokia Corporation. All rights reserved.
6 * Contact: Toshihiro Kobayashi <toshihiro.kobayashi@nokia.com>
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * version 2 as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
24 #include <linux/module.h>
26 #include <linux/poll.h>
27 #include <linux/sched.h>
28 #include <linux/interrupt.h>
29 #include <mach/mailbox.h>
30 #include <asm/uaccess.h>
31 #include "dsp_mbcmd.h"
35 * value seen through read()
37 #define DSP_ERR_WDT 0x00000001
38 #define DSP_ERR_MMU 0x00000002
39 static unsigned long errval;
41 static DECLARE_WAIT_QUEUE_HEAD(err_wait_q);
43 static u16 wdtval; /* FIXME: read through ioctl */
44 static u32 mmu_fadr; /* FIXME: read through ioctl */
47 * DSP error detection device file operations
49 static ssize_t dsp_err_read(struct file *file, char __user *buf, size_t count,
59 prepare_to_wait(&err_wait_q, &wait, TASK_INTERRUPTIBLE);
62 finish_wait(&err_wait_q, &wait);
63 if (signal_pending(current))
66 local_irq_save(flags);
67 status = copy_to_user(buf, &errval, 4);
69 local_irq_restore(flags);
73 local_irq_restore(flags);
78 static unsigned int dsp_err_poll(struct file *file, poll_table *wait)
80 unsigned int mask = 0;
82 poll_wait(file, &err_wait_q, wait);
84 mask |= POLLIN | POLLRDNORM;
89 struct file_operations dsp_err_fops = {
96 * set / clear functions
100 static void dsp_err_mmu_set(unsigned long arg)
102 disable_irq(omap_dsp->mmu->irq);
106 static void dsp_err_mmu_clr(void)
108 enable_irq(omap_dsp->mmu->irq);
112 static void dsp_err_wdt_set(unsigned long arg)
122 void (*set)(unsigned long arg);
124 } dsp_err_desc[ERRCODE_MAX] = {
125 [ERRCODE_MMU] = { DSP_ERR_MMU, dsp_err_mmu_set, dsp_err_mmu_clr },
126 [ERRCODE_WDT] = { DSP_ERR_WDT, dsp_err_wdt_set, NULL },
129 void dsp_err_set(enum errcode_e code, unsigned long arg)
131 if (dsp_err_desc[code].set != NULL)
132 dsp_err_desc[code].set(arg);
134 errval |= dsp_err_desc[code].val;
136 wake_up_interruptible(&err_wait_q);
139 void dsp_err_clear(enum errcode_e code)
141 errval &= ~dsp_err_desc[code].val;
143 if (dsp_err_desc[code].clr != NULL)
144 dsp_err_desc[code].clr();
147 int dsp_err_isset(enum errcode_e code)
149 return (errval & dsp_err_desc[code].val) ? 1 : 0;
152 void dsp_err_notify(void)
154 /* new error code should be assigned */
155 dsp_err_set(DSP_ERR_WDT, 0);
159 * functions called from mailbox interrupt routine
161 static void mbox_err_wdt(u16 data)
163 dsp_err_set(DSP_ERR_WDT, (unsigned long)data);
166 #ifdef OLD_BINARY_SUPPORT
168 void mbox_wdt(struct mbcmd *mb)
170 mbox_err_wdt(mb->data);
174 extern void mbox_err_ipbfull(void);
175 extern void mbox_err_fatal(u8 tid);
177 void mbox_err(struct mbcmd *mb)
180 char *eidnm = subcmd_name(mb);
185 "mbox: ERR from DSP (%s): 0x%04x\n", eidnm, mb->data);
188 "mbox: ERR from DSP (unknown EID=%02x): %04x\n",
198 tid = mb->data & 0x00ff;
203 mbox_err_wdt(mb->data);
211 void dsp_err_start(void)
215 for (i = 0; i < ERRCODE_MAX; i++) {
216 if (dsp_err_isset(i))
219 omap_dsp->mbox->err_notify = dsp_err_notify;
223 void dsp_err_stop(void)
225 wake_up_interruptible(&err_wait_q);
226 omap_dsp->mbox->err_notify = NULL;