2 * linux/arch/arm/mach-omap/dsp/error.c
4 * OMAP DSP error detection I/F device driver
6 * Copyright (C) 2002-2005 Nokia Corporation
8 * Written by Toshihiro Kobayashi <toshihiro.kobayashi@nokia.com>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 * 2005/03/11: DSP Gateway version 3.3
27 #include <linux/module.h>
28 #include <linux/init.h>
29 #include <linux/major.h>
31 #include <linux/poll.h>
32 #include <linux/sched.h>
33 #include <linux/interrupt.h>
34 #include <asm/uaccess.h>
36 #include <asm/ioctls.h>
37 #include <asm/arch/dsp.h>
40 static DECLARE_WAIT_QUEUE_HEAD(err_wait_q);
41 static unsigned long errcode;
43 static unsigned short wdtval; /* FIXME: read through ioctl */
44 static unsigned long mmu_fadr; /* FIXME: read through ioctl */
47 * DSP error detection device file operations
49 static ssize_t dsp_err_read(struct file *file, char *buf, size_t count,
60 DECLARE_WAITQUEUE(wait, current);
62 add_wait_queue(&err_wait_q, &wait);
63 current_state = current->state;
64 set_current_state(TASK_INTERRUPTIBLE);
65 if (errcnt == 0) /* last check */
67 set_current_state(current_state);
68 remove_wait_queue(&err_wait_q, &wait);
69 if (signal_pending(current))
73 local_irq_save(flags);
74 status = copy_to_user(buf, &errcode, 4);
76 local_irq_restore(flags);
80 local_irq_restore(flags);
85 static unsigned int dsp_err_poll(struct file *file, poll_table *wait)
87 unsigned int mask = 0;
89 poll_wait(file, &err_wait_q, wait);
91 mask |= POLLIN | POLLRDNORM;
96 struct file_operations dsp_err_fops = {
105 void dsp_err_mmu_set(unsigned long adr)
107 disable_irq(INT_DSP_MMU);
108 errcode |= OMAP_DSP_ERRDT_MMU;
111 wake_up_interruptible(&err_wait_q);
114 void dsp_err_mmu_clear(void)
116 errcode &= ~OMAP_DSP_ERRDT_MMU;
117 enable_irq(INT_DSP_MMU);
120 int dsp_err_mmu_isset(void)
122 return (errcode & OMAP_DSP_ERRDT_MMU) ? 1 : 0;
128 void dsp_err_wdt_clear(void)
130 errcode &= ~OMAP_DSP_ERRDT_WDT;
133 int dsp_err_wdt_isset(void)
135 return (errcode & OMAP_DSP_ERRDT_WDT) ? 1 : 0;
139 * functions called from mailbox1 interrupt routine
141 static void mbx1_err_wdt(unsigned short data)
143 errcode |= OMAP_DSP_ERRDT_WDT;
146 wake_up_interruptible(&err_wait_q);
149 #ifdef OLD_BINARY_SUPPORT
151 void mbx1_wdt(struct mbcmd *mb)
153 mbx1_err_wdt(mb->data);
157 extern void mbx1_err_ipbfull(void);
158 extern void mbx1_err_fatal(unsigned char tid);
160 void mbx1_err(struct mbcmd *mb)
162 unsigned char eid = mb->cmd_l;
163 char *eidnm = subcmd_name(mb);
168 "mbx: ERR from DSP (%s): 0x%04x\n", eidnm, mb->data);
171 "mbx: ERR from DSP (unknown EID=%02x): %04x\n",
176 case OMAP_DSP_EID_IPBFULL:
180 case OMAP_DSP_EID_FATAL:
181 tid = mb->data & 0x00ff;
185 case OMAP_DSP_EID_WDT:
186 mbx1_err_wdt(mb->data);
194 void dsp_err_start(void)
197 if (dsp_err_wdt_isset())
199 if (dsp_err_mmu_isset())
203 void dsp_err_stop(void)
205 wake_up_interruptible(&err_wait_q);