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 <asm/uaccess.h>
30 #include "dsp_mbcmd.h"
34 * value seen through read()
36 #define DSP_ERR_WDT 0x00000001
37 #define DSP_ERR_MMU 0x00000002
38 static unsigned long errval;
40 static DECLARE_WAIT_QUEUE_HEAD(err_wait_q);
42 static u16 wdtval; /* FIXME: read through ioctl */
43 static u32 mmu_fadr; /* FIXME: read through ioctl */
46 * DSP error detection device file operations
48 static ssize_t dsp_err_read(struct file *file, char __user *buf, size_t count,
59 DECLARE_WAITQUEUE(wait, current);
61 add_wait_queue(&err_wait_q, &wait);
62 current_state = current->state;
63 set_current_state(TASK_INTERRUPTIBLE);
64 if (errcnt == 0) /* last check */
66 set_current_state(current_state);
67 remove_wait_queue(&err_wait_q, &wait);
68 if (signal_pending(current))
72 local_irq_save(flags);
73 status = copy_to_user(buf, &errval, 4);
75 local_irq_restore(flags);
79 local_irq_restore(flags);
84 static unsigned int dsp_err_poll(struct file *file, poll_table *wait)
86 unsigned int mask = 0;
88 poll_wait(file, &err_wait_q, wait);
90 mask |= POLLIN | POLLRDNORM;
95 struct file_operations dsp_err_fops = {
102 * set / clear functions
106 static void dsp_err_mmu_set(unsigned long arg)
108 disable_irq(INT_DSP_MMU);
112 static void dsp_err_mmu_clr(void)
114 enable_irq(INT_DSP_MMU);
118 static void dsp_err_wdt_set(unsigned long arg)
128 void (*set)(unsigned long arg);
130 } dsp_err_desc[ERRCODE_MAX] = {
131 [ERRCODE_MMU] = { DSP_ERR_MMU, dsp_err_mmu_set, dsp_err_mmu_clr },
132 [ERRCODE_WDT] = { DSP_ERR_WDT, dsp_err_wdt_set, NULL },
135 void dsp_err_set(enum errcode_e code, unsigned long arg)
137 if (dsp_err_desc[code].set != NULL)
138 dsp_err_desc[code].set(arg);
140 errval |= dsp_err_desc[code].val;
142 wake_up_interruptible(&err_wait_q);
145 void dsp_err_clear(enum errcode_e code)
147 errval &= ~dsp_err_desc[code].val;
149 if (dsp_err_desc[code].clr != NULL)
150 dsp_err_desc[code].clr();
153 int dsp_err_isset(enum errcode_e code)
155 return (errval & dsp_err_desc[code].val) ? 1 : 0;
159 * functions called from mailbox interrupt routine
161 static void mbx_err_wdt(u16 data)
163 dsp_err_set(DSP_ERR_WDT, (unsigned long)data);
166 #ifdef OLD_BINARY_SUPPORT
168 void mbx_wdt(struct mbcmd *mb)
170 mbx_err_wdt(mb->data);
174 extern void mbx_err_ipbfull(void);
175 extern void mbx_err_fatal(u8 tid);
177 void mbx_err(struct mbcmd *mb)
180 char *eidnm = subcmd_name(mb);
185 "mbx: ERR from DSP (%s): 0x%04x\n", eidnm, mb->data);
188 "mbx: ERR from DSP (unknown EID=%02x): %04x\n",
198 tid = mb->data & 0x00ff;
203 mbx_err_wdt(mb->data);
211 void dsp_err_start(void)
215 for (i = 0; i < ERRCODE_MAX; i++) {
216 if (dsp_err_isset(i))
223 void dsp_err_stop(void)
225 wake_up_interruptible(&err_wait_q);