NFS: Optimise inode attribute cache updates
[linux-2.6/mini2440.git] / drivers / char / mwave / 3780i.c
blob613aed9e1840a15e4843e396591dc205a5ceecf1
1 /*
3 * 3780i.c -- helper routines for the 3780i DSP
6 * Written By: Mike Sullivan IBM Corporation
8 * Copyright (C) 1999 IBM Corporation
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 * NO WARRANTY
21 * THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
22 * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
23 * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
24 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
25 * solely responsible for determining the appropriateness of using and
26 * distributing the Program and assumes all risks associated with its
27 * exercise of rights under this Agreement, including but not limited to
28 * the risks and costs of program errors, damage to or loss of data,
29 * programs or equipment, and unavailability or interruption of operations.
31 * DISCLAIMER OF LIABILITY
32 * NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
33 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
34 * DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
35 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
36 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
37 * USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
38 * HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
40 * You should have received a copy of the GNU General Public License
41 * along with this program; if not, write to the Free Software
42 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
45 * 10/23/2000 - Alpha Release
46 * First release to the public
49 #include <linux/config.h>
50 #include <linux/kernel.h>
51 #include <linux/unistd.h>
52 #include <linux/delay.h>
53 #include <linux/ioport.h>
54 #include <linux/init.h>
55 #include <linux/bitops.h>
56 #include <asm/io.h>
57 #include <asm/uaccess.h>
58 #include <asm/system.h>
59 #include <asm/irq.h>
60 #include "smapi.h"
61 #include "mwavedd.h"
62 #include "3780i.h"
64 static DEFINE_SPINLOCK(dsp_lock);
65 static unsigned long flags;
68 static void PaceMsaAccess(unsigned short usDspBaseIO)
70 cond_resched();
71 udelay(100);
72 cond_resched();
75 unsigned short dsp3780I_ReadMsaCfg(unsigned short usDspBaseIO,
76 unsigned long ulMsaAddr)
78 unsigned short val;
80 PRINTK_3(TRACE_3780I,
81 "3780i::dsp3780I_ReadMsaCfg entry usDspBaseIO %x ulMsaAddr %lx\n",
82 usDspBaseIO, ulMsaAddr);
84 spin_lock_irqsave(&dsp_lock, flags);
85 OutWordDsp(DSP_MsaAddrLow, (unsigned short) ulMsaAddr);
86 OutWordDsp(DSP_MsaAddrHigh, (unsigned short) (ulMsaAddr >> 16));
87 val = InWordDsp(DSP_MsaDataDSISHigh);
88 spin_unlock_irqrestore(&dsp_lock, flags);
90 PRINTK_2(TRACE_3780I, "3780i::dsp3780I_ReadMsaCfg exit val %x\n", val);
92 return val;
95 void dsp3780I_WriteMsaCfg(unsigned short usDspBaseIO,
96 unsigned long ulMsaAddr, unsigned short usValue)
99 PRINTK_4(TRACE_3780I,
100 "3780i::dsp3780i_WriteMsaCfg entry usDspBaseIO %x ulMsaAddr %lx usValue %x\n",
101 usDspBaseIO, ulMsaAddr, usValue);
103 spin_lock_irqsave(&dsp_lock, flags);
104 OutWordDsp(DSP_MsaAddrLow, (unsigned short) ulMsaAddr);
105 OutWordDsp(DSP_MsaAddrHigh, (unsigned short) (ulMsaAddr >> 16));
106 OutWordDsp(DSP_MsaDataDSISHigh, usValue);
107 spin_unlock_irqrestore(&dsp_lock, flags);
110 static void dsp3780I_WriteGenCfg(unsigned short usDspBaseIO, unsigned uIndex,
111 unsigned char ucValue)
113 DSP_ISA_SLAVE_CONTROL rSlaveControl;
114 DSP_ISA_SLAVE_CONTROL rSlaveControl_Save;
117 PRINTK_4(TRACE_3780I,
118 "3780i::dsp3780i_WriteGenCfg entry usDspBaseIO %x uIndex %x ucValue %x\n",
119 usDspBaseIO, uIndex, ucValue);
121 MKBYTE(rSlaveControl) = InByteDsp(DSP_IsaSlaveControl);
123 PRINTK_2(TRACE_3780I,
124 "3780i::dsp3780i_WriteGenCfg rSlaveControl %x\n",
125 MKBYTE(rSlaveControl));
127 rSlaveControl_Save = rSlaveControl;
128 rSlaveControl.ConfigMode = TRUE;
130 PRINTK_2(TRACE_3780I,
131 "3780i::dsp3780i_WriteGenCfg entry rSlaveControl+ConfigMode %x\n",
132 MKBYTE(rSlaveControl));
134 OutByteDsp(DSP_IsaSlaveControl, MKBYTE(rSlaveControl));
135 OutByteDsp(DSP_ConfigAddress, (unsigned char) uIndex);
136 OutByteDsp(DSP_ConfigData, ucValue);
137 OutByteDsp(DSP_IsaSlaveControl, MKBYTE(rSlaveControl_Save));
139 PRINTK_1(TRACE_3780I, "3780i::dsp3780i_WriteGenCfg exit\n");
144 #if 0
145 unsigned char dsp3780I_ReadGenCfg(unsigned short usDspBaseIO,
146 unsigned uIndex)
148 DSP_ISA_SLAVE_CONTROL rSlaveControl;
149 DSP_ISA_SLAVE_CONTROL rSlaveControl_Save;
150 unsigned char ucValue;
153 PRINTK_3(TRACE_3780I,
154 "3780i::dsp3780i_ReadGenCfg entry usDspBaseIO %x uIndex %x\n",
155 usDspBaseIO, uIndex);
157 MKBYTE(rSlaveControl) = InByteDsp(DSP_IsaSlaveControl);
158 rSlaveControl_Save = rSlaveControl;
159 rSlaveControl.ConfigMode = TRUE;
160 OutByteDsp(DSP_IsaSlaveControl, MKBYTE(rSlaveControl));
161 OutByteDsp(DSP_ConfigAddress, (unsigned char) uIndex);
162 ucValue = InByteDsp(DSP_ConfigData);
163 OutByteDsp(DSP_IsaSlaveControl, MKBYTE(rSlaveControl_Save));
165 PRINTK_2(TRACE_3780I,
166 "3780i::dsp3780i_ReadGenCfg exit ucValue %x\n", ucValue);
169 return ucValue;
171 #endif /* 0 */
173 int dsp3780I_EnableDSP(DSP_3780I_CONFIG_SETTINGS * pSettings,
174 unsigned short *pIrqMap,
175 unsigned short *pDmaMap)
177 unsigned short usDspBaseIO = pSettings->usDspBaseIO;
178 int i;
179 DSP_UART_CFG_1 rUartCfg1;
180 DSP_UART_CFG_2 rUartCfg2;
181 DSP_HBRIDGE_CFG_1 rHBridgeCfg1;
182 DSP_HBRIDGE_CFG_2 rHBridgeCfg2;
183 DSP_BUSMASTER_CFG_1 rBusmasterCfg1;
184 DSP_BUSMASTER_CFG_2 rBusmasterCfg2;
185 DSP_ISA_PROT_CFG rIsaProtCfg;
186 DSP_POWER_MGMT_CFG rPowerMgmtCfg;
187 DSP_HBUS_TIMER_CFG rHBusTimerCfg;
188 DSP_LBUS_TIMEOUT_DISABLE rLBusTimeoutDisable;
189 DSP_CHIP_RESET rChipReset;
190 DSP_CLOCK_CONTROL_1 rClockControl1;
191 DSP_CLOCK_CONTROL_2 rClockControl2;
192 DSP_ISA_SLAVE_CONTROL rSlaveControl;
193 DSP_HBRIDGE_CONTROL rHBridgeControl;
194 unsigned short ChipID = 0;
195 unsigned short tval;
198 PRINTK_2(TRACE_3780I,
199 "3780i::dsp3780I_EnableDSP entry pSettings->bDSPEnabled %x\n",
200 pSettings->bDSPEnabled);
203 if (!pSettings->bDSPEnabled) {
204 PRINTK_ERROR( KERN_ERR "3780i::dsp3780I_EnableDSP: Error: DSP not enabled. Aborting.\n" );
205 return -EIO;
209 PRINTK_2(TRACE_3780I,
210 "3780i::dsp3780i_EnableDSP entry pSettings->bModemEnabled %x\n",
211 pSettings->bModemEnabled);
213 if (pSettings->bModemEnabled) {
214 rUartCfg1.Reserved = rUartCfg2.Reserved = 0;
215 rUartCfg1.IrqActiveLow = pSettings->bUartIrqActiveLow;
216 rUartCfg1.IrqPulse = pSettings->bUartIrqPulse;
217 rUartCfg1.Irq =
218 (unsigned char) pIrqMap[pSettings->usUartIrq];
219 switch (pSettings->usUartBaseIO) {
220 case 0x03F8:
221 rUartCfg1.BaseIO = 0;
222 break;
223 case 0x02F8:
224 rUartCfg1.BaseIO = 1;
225 break;
226 case 0x03E8:
227 rUartCfg1.BaseIO = 2;
228 break;
229 case 0x02E8:
230 rUartCfg1.BaseIO = 3;
231 break;
233 rUartCfg2.Enable = TRUE;
236 rHBridgeCfg1.Reserved = rHBridgeCfg2.Reserved = 0;
237 rHBridgeCfg1.IrqActiveLow = pSettings->bDspIrqActiveLow;
238 rHBridgeCfg1.IrqPulse = pSettings->bDspIrqPulse;
239 rHBridgeCfg1.Irq = (unsigned char) pIrqMap[pSettings->usDspIrq];
240 rHBridgeCfg1.AccessMode = 1;
241 rHBridgeCfg2.Enable = TRUE;
244 rBusmasterCfg2.Reserved = 0;
245 rBusmasterCfg1.Dma = (unsigned char) pDmaMap[pSettings->usDspDma];
246 rBusmasterCfg1.NumTransfers =
247 (unsigned char) pSettings->usNumTransfers;
248 rBusmasterCfg1.ReRequest = (unsigned char) pSettings->usReRequest;
249 rBusmasterCfg1.MEMCS16 = pSettings->bEnableMEMCS16;
250 rBusmasterCfg2.IsaMemCmdWidth =
251 (unsigned char) pSettings->usIsaMemCmdWidth;
254 rIsaProtCfg.Reserved = 0;
255 rIsaProtCfg.GateIOCHRDY = pSettings->bGateIOCHRDY;
257 rPowerMgmtCfg.Reserved = 0;
258 rPowerMgmtCfg.Enable = pSettings->bEnablePwrMgmt;
260 rHBusTimerCfg.LoadValue =
261 (unsigned char) pSettings->usHBusTimerLoadValue;
263 rLBusTimeoutDisable.Reserved = 0;
264 rLBusTimeoutDisable.DisableTimeout =
265 pSettings->bDisableLBusTimeout;
267 MKWORD(rChipReset) = ~pSettings->usChipletEnable;
269 rClockControl1.Reserved1 = rClockControl1.Reserved2 = 0;
270 rClockControl1.N_Divisor = pSettings->usN_Divisor;
271 rClockControl1.M_Multiplier = pSettings->usM_Multiplier;
273 rClockControl2.Reserved = 0;
274 rClockControl2.PllBypass = pSettings->bPllBypass;
276 /* Issue a soft reset to the chip */
277 /* Note: Since we may be coming in with 3780i clocks suspended, we must keep
278 * soft-reset active for 10ms.
280 rSlaveControl.ClockControl = 0;
281 rSlaveControl.SoftReset = TRUE;
282 rSlaveControl.ConfigMode = FALSE;
283 rSlaveControl.Reserved = 0;
285 PRINTK_4(TRACE_3780I,
286 "3780i::dsp3780i_EnableDSP usDspBaseIO %x index %x taddr %x\n",
287 usDspBaseIO, DSP_IsaSlaveControl,
288 usDspBaseIO + DSP_IsaSlaveControl);
290 PRINTK_2(TRACE_3780I,
291 "3780i::dsp3780i_EnableDSP rSlaveContrl %x\n",
292 MKWORD(rSlaveControl));
294 spin_lock_irqsave(&dsp_lock, flags);
295 OutWordDsp(DSP_IsaSlaveControl, MKWORD(rSlaveControl));
296 MKWORD(tval) = InWordDsp(DSP_IsaSlaveControl);
298 PRINTK_2(TRACE_3780I,
299 "3780i::dsp3780i_EnableDSP rSlaveControl 2 %x\n", tval);
302 for (i = 0; i < 11; i++)
303 udelay(2000);
305 rSlaveControl.SoftReset = FALSE;
306 OutWordDsp(DSP_IsaSlaveControl, MKWORD(rSlaveControl));
308 MKWORD(tval) = InWordDsp(DSP_IsaSlaveControl);
310 PRINTK_2(TRACE_3780I,
311 "3780i::dsp3780i_EnableDSP rSlaveControl 3 %x\n", tval);
314 /* Program our general configuration registers */
315 WriteGenCfg(DSP_HBridgeCfg1Index, MKBYTE(rHBridgeCfg1));
316 WriteGenCfg(DSP_HBridgeCfg2Index, MKBYTE(rHBridgeCfg2));
317 WriteGenCfg(DSP_BusMasterCfg1Index, MKBYTE(rBusmasterCfg1));
318 WriteGenCfg(DSP_BusMasterCfg2Index, MKBYTE(rBusmasterCfg2));
319 WriteGenCfg(DSP_IsaProtCfgIndex, MKBYTE(rIsaProtCfg));
320 WriteGenCfg(DSP_PowerMgCfgIndex, MKBYTE(rPowerMgmtCfg));
321 WriteGenCfg(DSP_HBusTimerCfgIndex, MKBYTE(rHBusTimerCfg));
323 if (pSettings->bModemEnabled) {
324 WriteGenCfg(DSP_UartCfg1Index, MKBYTE(rUartCfg1));
325 WriteGenCfg(DSP_UartCfg2Index, MKBYTE(rUartCfg2));
329 rHBridgeControl.EnableDspInt = FALSE;
330 rHBridgeControl.MemAutoInc = TRUE;
331 rHBridgeControl.IoAutoInc = FALSE;
332 rHBridgeControl.DiagnosticMode = FALSE;
334 PRINTK_3(TRACE_3780I,
335 "3780i::dsp3780i_EnableDSP DSP_HBridgeControl %x rHBridgeControl %x\n",
336 DSP_HBridgeControl, MKWORD(rHBridgeControl));
338 OutWordDsp(DSP_HBridgeControl, MKWORD(rHBridgeControl));
339 spin_unlock_irqrestore(&dsp_lock, flags);
340 WriteMsaCfg(DSP_LBusTimeoutDisable, MKWORD(rLBusTimeoutDisable));
341 WriteMsaCfg(DSP_ClockControl_1, MKWORD(rClockControl1));
342 WriteMsaCfg(DSP_ClockControl_2, MKWORD(rClockControl2));
343 WriteMsaCfg(DSP_ChipReset, MKWORD(rChipReset));
345 ChipID = ReadMsaCfg(DSP_ChipID);
347 PRINTK_2(TRACE_3780I,
348 "3780i::dsp3780I_EnableDSP exiting bRC=TRUE, ChipID %x\n",
349 ChipID);
351 return 0;
354 int dsp3780I_DisableDSP(DSP_3780I_CONFIG_SETTINGS * pSettings)
356 unsigned short usDspBaseIO = pSettings->usDspBaseIO;
357 DSP_ISA_SLAVE_CONTROL rSlaveControl;
360 PRINTK_1(TRACE_3780I, "3780i::dsp3780i_DisableDSP entry\n");
362 rSlaveControl.ClockControl = 0;
363 rSlaveControl.SoftReset = TRUE;
364 rSlaveControl.ConfigMode = FALSE;
365 rSlaveControl.Reserved = 0;
366 spin_lock_irqsave(&dsp_lock, flags);
367 OutWordDsp(DSP_IsaSlaveControl, MKWORD(rSlaveControl));
369 udelay(5);
371 rSlaveControl.ClockControl = 1;
372 OutWordDsp(DSP_IsaSlaveControl, MKWORD(rSlaveControl));
373 spin_unlock_irqrestore(&dsp_lock, flags);
375 udelay(5);
378 PRINTK_1(TRACE_3780I, "3780i::dsp3780i_DisableDSP exit\n");
380 return 0;
383 int dsp3780I_Reset(DSP_3780I_CONFIG_SETTINGS * pSettings)
385 unsigned short usDspBaseIO = pSettings->usDspBaseIO;
386 DSP_BOOT_DOMAIN rBootDomain;
387 DSP_HBRIDGE_CONTROL rHBridgeControl;
390 PRINTK_1(TRACE_3780I, "3780i::dsp3780i_Reset entry\n");
392 spin_lock_irqsave(&dsp_lock, flags);
393 /* Mask DSP to PC interrupt */
394 MKWORD(rHBridgeControl) = InWordDsp(DSP_HBridgeControl);
396 PRINTK_2(TRACE_3780I, "3780i::dsp3780i_Reset rHBridgeControl %x\n",
397 MKWORD(rHBridgeControl));
399 rHBridgeControl.EnableDspInt = FALSE;
400 OutWordDsp(DSP_HBridgeControl, MKWORD(rHBridgeControl));
401 spin_unlock_irqrestore(&dsp_lock, flags);
403 /* Reset the core via the boot domain register */
404 rBootDomain.ResetCore = TRUE;
405 rBootDomain.Halt = TRUE;
406 rBootDomain.NMI = TRUE;
407 rBootDomain.Reserved = 0;
409 PRINTK_2(TRACE_3780I, "3780i::dsp3780i_Reset rBootDomain %x\n",
410 MKWORD(rBootDomain));
412 WriteMsaCfg(DSP_MspBootDomain, MKWORD(rBootDomain));
414 /* Reset all the chiplets and then reactivate them */
415 WriteMsaCfg(DSP_ChipReset, 0xFFFF);
416 udelay(5);
417 WriteMsaCfg(DSP_ChipReset,
418 (unsigned short) (~pSettings->usChipletEnable));
421 PRINTK_1(TRACE_3780I, "3780i::dsp3780i_Reset exit bRC=0\n");
423 return 0;
427 int dsp3780I_Run(DSP_3780I_CONFIG_SETTINGS * pSettings)
429 unsigned short usDspBaseIO = pSettings->usDspBaseIO;
430 DSP_BOOT_DOMAIN rBootDomain;
431 DSP_HBRIDGE_CONTROL rHBridgeControl;
434 PRINTK_1(TRACE_3780I, "3780i::dsp3780i_Run entry\n");
437 /* Transition the core to a running state */
438 rBootDomain.ResetCore = TRUE;
439 rBootDomain.Halt = FALSE;
440 rBootDomain.NMI = TRUE;
441 rBootDomain.Reserved = 0;
442 WriteMsaCfg(DSP_MspBootDomain, MKWORD(rBootDomain));
444 udelay(5);
446 rBootDomain.ResetCore = FALSE;
447 WriteMsaCfg(DSP_MspBootDomain, MKWORD(rBootDomain));
448 udelay(5);
450 rBootDomain.NMI = FALSE;
451 WriteMsaCfg(DSP_MspBootDomain, MKWORD(rBootDomain));
452 udelay(5);
454 /* Enable DSP to PC interrupt */
455 spin_lock_irqsave(&dsp_lock, flags);
456 MKWORD(rHBridgeControl) = InWordDsp(DSP_HBridgeControl);
457 rHBridgeControl.EnableDspInt = TRUE;
459 PRINTK_2(TRACE_3780I, "3780i::dsp3780i_Run rHBridgeControl %x\n",
460 MKWORD(rHBridgeControl));
462 OutWordDsp(DSP_HBridgeControl, MKWORD(rHBridgeControl));
463 spin_unlock_irqrestore(&dsp_lock, flags);
466 PRINTK_1(TRACE_3780I, "3780i::dsp3780i_Run exit bRC=TRUE\n");
468 return 0;
472 int dsp3780I_ReadDStore(unsigned short usDspBaseIO, void __user *pvBuffer,
473 unsigned uCount, unsigned long ulDSPAddr)
475 unsigned short __user *pusBuffer = pvBuffer;
476 unsigned short val;
479 PRINTK_5(TRACE_3780I,
480 "3780i::dsp3780I_ReadDStore entry usDspBaseIO %x, pusBuffer %p, uCount %x, ulDSPAddr %lx\n",
481 usDspBaseIO, pusBuffer, uCount, ulDSPAddr);
484 /* Set the initial MSA address. No adjustments need to be made to data store addresses */
485 spin_lock_irqsave(&dsp_lock, flags);
486 OutWordDsp(DSP_MsaAddrLow, (unsigned short) ulDSPAddr);
487 OutWordDsp(DSP_MsaAddrHigh, (unsigned short) (ulDSPAddr >> 16));
488 spin_unlock_irqrestore(&dsp_lock, flags);
490 /* Transfer the memory block */
491 while (uCount-- != 0) {
492 spin_lock_irqsave(&dsp_lock, flags);
493 val = InWordDsp(DSP_MsaDataDSISHigh);
494 spin_unlock_irqrestore(&dsp_lock, flags);
495 if(put_user(val, pusBuffer++))
496 return -EFAULT;
498 PRINTK_3(TRACE_3780I,
499 "3780I::dsp3780I_ReadDStore uCount %x val %x\n",
500 uCount, val);
502 PaceMsaAccess(usDspBaseIO);
506 PRINTK_1(TRACE_3780I,
507 "3780I::dsp3780I_ReadDStore exit bRC=TRUE\n");
509 return 0;
512 int dsp3780I_ReadAndClearDStore(unsigned short usDspBaseIO,
513 void __user *pvBuffer, unsigned uCount,
514 unsigned long ulDSPAddr)
516 unsigned short __user *pusBuffer = pvBuffer;
517 unsigned short val;
520 PRINTK_5(TRACE_3780I,
521 "3780i::dsp3780I_ReadAndDStore entry usDspBaseIO %x, pusBuffer %p, uCount %x, ulDSPAddr %lx\n",
522 usDspBaseIO, pusBuffer, uCount, ulDSPAddr);
525 /* Set the initial MSA address. No adjustments need to be made to data store addresses */
526 spin_lock_irqsave(&dsp_lock, flags);
527 OutWordDsp(DSP_MsaAddrLow, (unsigned short) ulDSPAddr);
528 OutWordDsp(DSP_MsaAddrHigh, (unsigned short) (ulDSPAddr >> 16));
529 spin_unlock_irqrestore(&dsp_lock, flags);
531 /* Transfer the memory block */
532 while (uCount-- != 0) {
533 spin_lock_irqsave(&dsp_lock, flags);
534 val = InWordDsp(DSP_ReadAndClear);
535 spin_unlock_irqrestore(&dsp_lock, flags);
536 if(put_user(val, pusBuffer++))
537 return -EFAULT;
539 PRINTK_3(TRACE_3780I,
540 "3780I::dsp3780I_ReadAndCleanDStore uCount %x val %x\n",
541 uCount, val);
543 PaceMsaAccess(usDspBaseIO);
547 PRINTK_1(TRACE_3780I,
548 "3780I::dsp3780I_ReadAndClearDStore exit bRC=TRUE\n");
550 return 0;
554 int dsp3780I_WriteDStore(unsigned short usDspBaseIO, void __user *pvBuffer,
555 unsigned uCount, unsigned long ulDSPAddr)
557 unsigned short __user *pusBuffer = pvBuffer;
560 PRINTK_5(TRACE_3780I,
561 "3780i::dsp3780D_WriteDStore entry usDspBaseIO %x, pusBuffer %p, uCount %x, ulDSPAddr %lx\n",
562 usDspBaseIO, pusBuffer, uCount, ulDSPAddr);
565 /* Set the initial MSA address. No adjustments need to be made to data store addresses */
566 spin_lock_irqsave(&dsp_lock, flags);
567 OutWordDsp(DSP_MsaAddrLow, (unsigned short) ulDSPAddr);
568 OutWordDsp(DSP_MsaAddrHigh, (unsigned short) (ulDSPAddr >> 16));
569 spin_unlock_irqrestore(&dsp_lock, flags);
571 /* Transfer the memory block */
572 while (uCount-- != 0) {
573 unsigned short val;
574 if(get_user(val, pusBuffer++))
575 return -EFAULT;
576 spin_lock_irqsave(&dsp_lock, flags);
577 OutWordDsp(DSP_MsaDataDSISHigh, val);
578 spin_unlock_irqrestore(&dsp_lock, flags);
580 PRINTK_3(TRACE_3780I,
581 "3780I::dsp3780I_WriteDStore uCount %x val %x\n",
582 uCount, val);
584 PaceMsaAccess(usDspBaseIO);
588 PRINTK_1(TRACE_3780I,
589 "3780I::dsp3780D_WriteDStore exit bRC=TRUE\n");
591 return 0;
595 int dsp3780I_ReadIStore(unsigned short usDspBaseIO, void __user *pvBuffer,
596 unsigned uCount, unsigned long ulDSPAddr)
598 unsigned short __user *pusBuffer = pvBuffer;
600 PRINTK_5(TRACE_3780I,
601 "3780i::dsp3780I_ReadIStore entry usDspBaseIO %x, pusBuffer %p, uCount %x, ulDSPAddr %lx\n",
602 usDspBaseIO, pusBuffer, uCount, ulDSPAddr);
605 * Set the initial MSA address. To convert from an instruction store
606 * address to an MSA address
607 * shift the address two bits to the left and set bit 22
609 ulDSPAddr = (ulDSPAddr << 2) | (1 << 22);
610 spin_lock_irqsave(&dsp_lock, flags);
611 OutWordDsp(DSP_MsaAddrLow, (unsigned short) ulDSPAddr);
612 OutWordDsp(DSP_MsaAddrHigh, (unsigned short) (ulDSPAddr >> 16));
613 spin_unlock_irqrestore(&dsp_lock, flags);
615 /* Transfer the memory block */
616 while (uCount-- != 0) {
617 unsigned short val_lo, val_hi;
618 spin_lock_irqsave(&dsp_lock, flags);
619 val_lo = InWordDsp(DSP_MsaDataISLow);
620 val_hi = InWordDsp(DSP_MsaDataDSISHigh);
621 spin_unlock_irqrestore(&dsp_lock, flags);
622 if(put_user(val_lo, pusBuffer++))
623 return -EFAULT;
624 if(put_user(val_hi, pusBuffer++))
625 return -EFAULT;
627 PRINTK_4(TRACE_3780I,
628 "3780I::dsp3780I_ReadIStore uCount %x val_lo %x val_hi %x\n",
629 uCount, val_lo, val_hi);
631 PaceMsaAccess(usDspBaseIO);
635 PRINTK_1(TRACE_3780I,
636 "3780I::dsp3780I_ReadIStore exit bRC=TRUE\n");
638 return 0;
642 int dsp3780I_WriteIStore(unsigned short usDspBaseIO, void __user *pvBuffer,
643 unsigned uCount, unsigned long ulDSPAddr)
645 unsigned short __user *pusBuffer = pvBuffer;
647 PRINTK_5(TRACE_3780I,
648 "3780i::dsp3780I_WriteIStore entry usDspBaseIO %x, pusBuffer %p, uCount %x, ulDSPAddr %lx\n",
649 usDspBaseIO, pusBuffer, uCount, ulDSPAddr);
653 * Set the initial MSA address. To convert from an instruction store
654 * address to an MSA address
655 * shift the address two bits to the left and set bit 22
657 ulDSPAddr = (ulDSPAddr << 2) | (1 << 22);
658 spin_lock_irqsave(&dsp_lock, flags);
659 OutWordDsp(DSP_MsaAddrLow, (unsigned short) ulDSPAddr);
660 OutWordDsp(DSP_MsaAddrHigh, (unsigned short) (ulDSPAddr >> 16));
661 spin_unlock_irqrestore(&dsp_lock, flags);
663 /* Transfer the memory block */
664 while (uCount-- != 0) {
665 unsigned short val_lo, val_hi;
666 if(get_user(val_lo, pusBuffer++))
667 return -EFAULT;
668 if(get_user(val_hi, pusBuffer++))
669 return -EFAULT;
670 spin_lock_irqsave(&dsp_lock, flags);
671 OutWordDsp(DSP_MsaDataISLow, val_lo);
672 OutWordDsp(DSP_MsaDataDSISHigh, val_hi);
673 spin_unlock_irqrestore(&dsp_lock, flags);
675 PRINTK_4(TRACE_3780I,
676 "3780I::dsp3780I_WriteIStore uCount %x val_lo %x val_hi %x\n",
677 uCount, val_lo, val_hi);
679 PaceMsaAccess(usDspBaseIO);
683 PRINTK_1(TRACE_3780I,
684 "3780I::dsp3780I_WriteIStore exit bRC=TRUE\n");
686 return 0;
690 int dsp3780I_GetIPCSource(unsigned short usDspBaseIO,
691 unsigned short *pusIPCSource)
693 DSP_HBRIDGE_CONTROL rHBridgeControl;
694 unsigned short temp;
697 PRINTK_3(TRACE_3780I,
698 "3780i::dsp3780I_GetIPCSource entry usDspBaseIO %x pusIPCSource %p\n",
699 usDspBaseIO, pusIPCSource);
702 * Disable DSP to PC interrupts, read the interrupt register,
703 * clear the pending IPC bits, and reenable DSP to PC interrupts
705 spin_lock_irqsave(&dsp_lock, flags);
706 MKWORD(rHBridgeControl) = InWordDsp(DSP_HBridgeControl);
707 rHBridgeControl.EnableDspInt = FALSE;
708 OutWordDsp(DSP_HBridgeControl, MKWORD(rHBridgeControl));
710 *pusIPCSource = InWordDsp(DSP_Interrupt);
711 temp = (unsigned short) ~(*pusIPCSource);
713 PRINTK_3(TRACE_3780I,
714 "3780i::dsp3780I_GetIPCSource, usIPCSource %x ~ %x\n",
715 *pusIPCSource, temp);
717 OutWordDsp(DSP_Interrupt, (unsigned short) ~(*pusIPCSource));
719 rHBridgeControl.EnableDspInt = TRUE;
720 OutWordDsp(DSP_HBridgeControl, MKWORD(rHBridgeControl));
721 spin_unlock_irqrestore(&dsp_lock, flags);
724 PRINTK_2(TRACE_3780I,
725 "3780i::dsp3780I_GetIPCSource exit usIPCSource %x\n",
726 *pusIPCSource);
728 return 0;