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.
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/kernel.h>
50 #include <linux/unistd.h>
51 #include <linux/delay.h>
52 #include <linux/ioport.h>
53 #include <linux/init.h>
54 #include <linux/bitops.h>
55 #include <linux/sched.h> /* cond_resched() */
58 #include <asm/uaccess.h>
64 static DEFINE_SPINLOCK(dsp_lock
);
66 static void PaceMsaAccess(unsigned short usDspBaseIO
)
73 unsigned short dsp3780I_ReadMsaCfg(unsigned short usDspBaseIO
,
74 unsigned long ulMsaAddr
)
80 "3780i::dsp3780I_ReadMsaCfg entry usDspBaseIO %x ulMsaAddr %lx\n",
81 usDspBaseIO
, ulMsaAddr
);
83 spin_lock_irqsave(&dsp_lock
, flags
);
84 OutWordDsp(DSP_MsaAddrLow
, (unsigned short) ulMsaAddr
);
85 OutWordDsp(DSP_MsaAddrHigh
, (unsigned short) (ulMsaAddr
>> 16));
86 val
= InWordDsp(DSP_MsaDataDSISHigh
);
87 spin_unlock_irqrestore(&dsp_lock
, flags
);
89 PRINTK_2(TRACE_3780I
, "3780i::dsp3780I_ReadMsaCfg exit val %x\n", val
);
94 void dsp3780I_WriteMsaCfg(unsigned short usDspBaseIO
,
95 unsigned long ulMsaAddr
, unsigned short usValue
)
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");
145 unsigned char dsp3780I_ReadGenCfg(unsigned short usDspBaseIO
,
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
);
173 int dsp3780I_EnableDSP(DSP_3780I_CONFIG_SETTINGS
* pSettings
,
174 unsigned short *pIrqMap
,
175 unsigned short *pDmaMap
)
178 unsigned short usDspBaseIO
= pSettings
->usDspBaseIO
;
180 DSP_UART_CFG_1 rUartCfg1
;
181 DSP_UART_CFG_2 rUartCfg2
;
182 DSP_HBRIDGE_CFG_1 rHBridgeCfg1
;
183 DSP_HBRIDGE_CFG_2 rHBridgeCfg2
;
184 DSP_BUSMASTER_CFG_1 rBusmasterCfg1
;
185 DSP_BUSMASTER_CFG_2 rBusmasterCfg2
;
186 DSP_ISA_PROT_CFG rIsaProtCfg
;
187 DSP_POWER_MGMT_CFG rPowerMgmtCfg
;
188 DSP_HBUS_TIMER_CFG rHBusTimerCfg
;
189 DSP_LBUS_TIMEOUT_DISABLE rLBusTimeoutDisable
;
190 DSP_CHIP_RESET rChipReset
;
191 DSP_CLOCK_CONTROL_1 rClockControl1
;
192 DSP_CLOCK_CONTROL_2 rClockControl2
;
193 DSP_ISA_SLAVE_CONTROL rSlaveControl
;
194 DSP_HBRIDGE_CONTROL rHBridgeControl
;
195 unsigned short ChipID
= 0;
199 PRINTK_2(TRACE_3780I
,
200 "3780i::dsp3780I_EnableDSP entry pSettings->bDSPEnabled %x\n",
201 pSettings
->bDSPEnabled
);
204 if (!pSettings
->bDSPEnabled
) {
205 PRINTK_ERROR( KERN_ERR
"3780i::dsp3780I_EnableDSP: Error: DSP not enabled. Aborting.\n" );
210 PRINTK_2(TRACE_3780I
,
211 "3780i::dsp3780i_EnableDSP entry pSettings->bModemEnabled %x\n",
212 pSettings
->bModemEnabled
);
214 if (pSettings
->bModemEnabled
) {
215 rUartCfg1
.Reserved
= rUartCfg2
.Reserved
= 0;
216 rUartCfg1
.IrqActiveLow
= pSettings
->bUartIrqActiveLow
;
217 rUartCfg1
.IrqPulse
= pSettings
->bUartIrqPulse
;
219 (unsigned char) pIrqMap
[pSettings
->usUartIrq
];
220 switch (pSettings
->usUartBaseIO
) {
222 rUartCfg1
.BaseIO
= 0;
225 rUartCfg1
.BaseIO
= 1;
228 rUartCfg1
.BaseIO
= 2;
231 rUartCfg1
.BaseIO
= 3;
234 rUartCfg2
.Enable
= TRUE
;
237 rHBridgeCfg1
.Reserved
= rHBridgeCfg2
.Reserved
= 0;
238 rHBridgeCfg1
.IrqActiveLow
= pSettings
->bDspIrqActiveLow
;
239 rHBridgeCfg1
.IrqPulse
= pSettings
->bDspIrqPulse
;
240 rHBridgeCfg1
.Irq
= (unsigned char) pIrqMap
[pSettings
->usDspIrq
];
241 rHBridgeCfg1
.AccessMode
= 1;
242 rHBridgeCfg2
.Enable
= TRUE
;
245 rBusmasterCfg2
.Reserved
= 0;
246 rBusmasterCfg1
.Dma
= (unsigned char) pDmaMap
[pSettings
->usDspDma
];
247 rBusmasterCfg1
.NumTransfers
=
248 (unsigned char) pSettings
->usNumTransfers
;
249 rBusmasterCfg1
.ReRequest
= (unsigned char) pSettings
->usReRequest
;
250 rBusmasterCfg1
.MEMCS16
= pSettings
->bEnableMEMCS16
;
251 rBusmasterCfg2
.IsaMemCmdWidth
=
252 (unsigned char) pSettings
->usIsaMemCmdWidth
;
255 rIsaProtCfg
.Reserved
= 0;
256 rIsaProtCfg
.GateIOCHRDY
= pSettings
->bGateIOCHRDY
;
258 rPowerMgmtCfg
.Reserved
= 0;
259 rPowerMgmtCfg
.Enable
= pSettings
->bEnablePwrMgmt
;
261 rHBusTimerCfg
.LoadValue
=
262 (unsigned char) pSettings
->usHBusTimerLoadValue
;
264 rLBusTimeoutDisable
.Reserved
= 0;
265 rLBusTimeoutDisable
.DisableTimeout
=
266 pSettings
->bDisableLBusTimeout
;
268 MKWORD(rChipReset
) = ~pSettings
->usChipletEnable
;
270 rClockControl1
.Reserved1
= rClockControl1
.Reserved2
= 0;
271 rClockControl1
.N_Divisor
= pSettings
->usN_Divisor
;
272 rClockControl1
.M_Multiplier
= pSettings
->usM_Multiplier
;
274 rClockControl2
.Reserved
= 0;
275 rClockControl2
.PllBypass
= pSettings
->bPllBypass
;
277 /* Issue a soft reset to the chip */
278 /* Note: Since we may be coming in with 3780i clocks suspended, we must keep
279 * soft-reset active for 10ms.
281 rSlaveControl
.ClockControl
= 0;
282 rSlaveControl
.SoftReset
= TRUE
;
283 rSlaveControl
.ConfigMode
= FALSE
;
284 rSlaveControl
.Reserved
= 0;
286 PRINTK_4(TRACE_3780I
,
287 "3780i::dsp3780i_EnableDSP usDspBaseIO %x index %x taddr %x\n",
288 usDspBaseIO
, DSP_IsaSlaveControl
,
289 usDspBaseIO
+ DSP_IsaSlaveControl
);
291 PRINTK_2(TRACE_3780I
,
292 "3780i::dsp3780i_EnableDSP rSlaveContrl %x\n",
293 MKWORD(rSlaveControl
));
295 spin_lock_irqsave(&dsp_lock
, flags
);
296 OutWordDsp(DSP_IsaSlaveControl
, MKWORD(rSlaveControl
));
297 MKWORD(tval
) = InWordDsp(DSP_IsaSlaveControl
);
299 PRINTK_2(TRACE_3780I
,
300 "3780i::dsp3780i_EnableDSP rSlaveControl 2 %x\n", tval
);
303 for (i
= 0; i
< 11; i
++)
306 rSlaveControl
.SoftReset
= FALSE
;
307 OutWordDsp(DSP_IsaSlaveControl
, MKWORD(rSlaveControl
));
309 MKWORD(tval
) = InWordDsp(DSP_IsaSlaveControl
);
311 PRINTK_2(TRACE_3780I
,
312 "3780i::dsp3780i_EnableDSP rSlaveControl 3 %x\n", tval
);
315 /* Program our general configuration registers */
316 WriteGenCfg(DSP_HBridgeCfg1Index
, MKBYTE(rHBridgeCfg1
));
317 WriteGenCfg(DSP_HBridgeCfg2Index
, MKBYTE(rHBridgeCfg2
));
318 WriteGenCfg(DSP_BusMasterCfg1Index
, MKBYTE(rBusmasterCfg1
));
319 WriteGenCfg(DSP_BusMasterCfg2Index
, MKBYTE(rBusmasterCfg2
));
320 WriteGenCfg(DSP_IsaProtCfgIndex
, MKBYTE(rIsaProtCfg
));
321 WriteGenCfg(DSP_PowerMgCfgIndex
, MKBYTE(rPowerMgmtCfg
));
322 WriteGenCfg(DSP_HBusTimerCfgIndex
, MKBYTE(rHBusTimerCfg
));
324 if (pSettings
->bModemEnabled
) {
325 WriteGenCfg(DSP_UartCfg1Index
, MKBYTE(rUartCfg1
));
326 WriteGenCfg(DSP_UartCfg2Index
, MKBYTE(rUartCfg2
));
330 rHBridgeControl
.EnableDspInt
= FALSE
;
331 rHBridgeControl
.MemAutoInc
= TRUE
;
332 rHBridgeControl
.IoAutoInc
= FALSE
;
333 rHBridgeControl
.DiagnosticMode
= FALSE
;
335 PRINTK_3(TRACE_3780I
,
336 "3780i::dsp3780i_EnableDSP DSP_HBridgeControl %x rHBridgeControl %x\n",
337 DSP_HBridgeControl
, MKWORD(rHBridgeControl
));
339 OutWordDsp(DSP_HBridgeControl
, MKWORD(rHBridgeControl
));
340 spin_unlock_irqrestore(&dsp_lock
, flags
);
341 WriteMsaCfg(DSP_LBusTimeoutDisable
, MKWORD(rLBusTimeoutDisable
));
342 WriteMsaCfg(DSP_ClockControl_1
, MKWORD(rClockControl1
));
343 WriteMsaCfg(DSP_ClockControl_2
, MKWORD(rClockControl2
));
344 WriteMsaCfg(DSP_ChipReset
, MKWORD(rChipReset
));
346 ChipID
= ReadMsaCfg(DSP_ChipID
);
348 PRINTK_2(TRACE_3780I
,
349 "3780i::dsp3780I_EnableDSP exiting bRC=TRUE, ChipID %x\n",
355 int dsp3780I_DisableDSP(DSP_3780I_CONFIG_SETTINGS
* pSettings
)
358 unsigned short usDspBaseIO
= pSettings
->usDspBaseIO
;
359 DSP_ISA_SLAVE_CONTROL rSlaveControl
;
362 PRINTK_1(TRACE_3780I
, "3780i::dsp3780i_DisableDSP entry\n");
364 rSlaveControl
.ClockControl
= 0;
365 rSlaveControl
.SoftReset
= TRUE
;
366 rSlaveControl
.ConfigMode
= FALSE
;
367 rSlaveControl
.Reserved
= 0;
368 spin_lock_irqsave(&dsp_lock
, flags
);
369 OutWordDsp(DSP_IsaSlaveControl
, MKWORD(rSlaveControl
));
373 rSlaveControl
.ClockControl
= 1;
374 OutWordDsp(DSP_IsaSlaveControl
, MKWORD(rSlaveControl
));
375 spin_unlock_irqrestore(&dsp_lock
, flags
);
380 PRINTK_1(TRACE_3780I
, "3780i::dsp3780i_DisableDSP exit\n");
385 int dsp3780I_Reset(DSP_3780I_CONFIG_SETTINGS
* pSettings
)
388 unsigned short usDspBaseIO
= pSettings
->usDspBaseIO
;
389 DSP_BOOT_DOMAIN rBootDomain
;
390 DSP_HBRIDGE_CONTROL rHBridgeControl
;
393 PRINTK_1(TRACE_3780I
, "3780i::dsp3780i_Reset entry\n");
395 spin_lock_irqsave(&dsp_lock
, flags
);
396 /* Mask DSP to PC interrupt */
397 MKWORD(rHBridgeControl
) = InWordDsp(DSP_HBridgeControl
);
399 PRINTK_2(TRACE_3780I
, "3780i::dsp3780i_Reset rHBridgeControl %x\n",
400 MKWORD(rHBridgeControl
));
402 rHBridgeControl
.EnableDspInt
= FALSE
;
403 OutWordDsp(DSP_HBridgeControl
, MKWORD(rHBridgeControl
));
404 spin_unlock_irqrestore(&dsp_lock
, flags
);
406 /* Reset the core via the boot domain register */
407 rBootDomain
.ResetCore
= TRUE
;
408 rBootDomain
.Halt
= TRUE
;
409 rBootDomain
.NMI
= TRUE
;
410 rBootDomain
.Reserved
= 0;
412 PRINTK_2(TRACE_3780I
, "3780i::dsp3780i_Reset rBootDomain %x\n",
413 MKWORD(rBootDomain
));
415 WriteMsaCfg(DSP_MspBootDomain
, MKWORD(rBootDomain
));
417 /* Reset all the chiplets and then reactivate them */
418 WriteMsaCfg(DSP_ChipReset
, 0xFFFF);
420 WriteMsaCfg(DSP_ChipReset
,
421 (unsigned short) (~pSettings
->usChipletEnable
));
424 PRINTK_1(TRACE_3780I
, "3780i::dsp3780i_Reset exit bRC=0\n");
430 int dsp3780I_Run(DSP_3780I_CONFIG_SETTINGS
* pSettings
)
433 unsigned short usDspBaseIO
= pSettings
->usDspBaseIO
;
434 DSP_BOOT_DOMAIN rBootDomain
;
435 DSP_HBRIDGE_CONTROL rHBridgeControl
;
438 PRINTK_1(TRACE_3780I
, "3780i::dsp3780i_Run entry\n");
441 /* Transition the core to a running state */
442 rBootDomain
.ResetCore
= TRUE
;
443 rBootDomain
.Halt
= FALSE
;
444 rBootDomain
.NMI
= TRUE
;
445 rBootDomain
.Reserved
= 0;
446 WriteMsaCfg(DSP_MspBootDomain
, MKWORD(rBootDomain
));
450 rBootDomain
.ResetCore
= FALSE
;
451 WriteMsaCfg(DSP_MspBootDomain
, MKWORD(rBootDomain
));
454 rBootDomain
.NMI
= FALSE
;
455 WriteMsaCfg(DSP_MspBootDomain
, MKWORD(rBootDomain
));
458 /* Enable DSP to PC interrupt */
459 spin_lock_irqsave(&dsp_lock
, flags
);
460 MKWORD(rHBridgeControl
) = InWordDsp(DSP_HBridgeControl
);
461 rHBridgeControl
.EnableDspInt
= TRUE
;
463 PRINTK_2(TRACE_3780I
, "3780i::dsp3780i_Run rHBridgeControl %x\n",
464 MKWORD(rHBridgeControl
));
466 OutWordDsp(DSP_HBridgeControl
, MKWORD(rHBridgeControl
));
467 spin_unlock_irqrestore(&dsp_lock
, flags
);
470 PRINTK_1(TRACE_3780I
, "3780i::dsp3780i_Run exit bRC=TRUE\n");
476 int dsp3780I_ReadDStore(unsigned short usDspBaseIO
, void __user
*pvBuffer
,
477 unsigned uCount
, unsigned long ulDSPAddr
)
480 unsigned short __user
*pusBuffer
= pvBuffer
;
484 PRINTK_5(TRACE_3780I
,
485 "3780i::dsp3780I_ReadDStore entry usDspBaseIO %x, pusBuffer %p, uCount %x, ulDSPAddr %lx\n",
486 usDspBaseIO
, pusBuffer
, uCount
, ulDSPAddr
);
489 /* Set the initial MSA address. No adjustments need to be made to data store addresses */
490 spin_lock_irqsave(&dsp_lock
, flags
);
491 OutWordDsp(DSP_MsaAddrLow
, (unsigned short) ulDSPAddr
);
492 OutWordDsp(DSP_MsaAddrHigh
, (unsigned short) (ulDSPAddr
>> 16));
493 spin_unlock_irqrestore(&dsp_lock
, flags
);
495 /* Transfer the memory block */
496 while (uCount
-- != 0) {
497 spin_lock_irqsave(&dsp_lock
, flags
);
498 val
= InWordDsp(DSP_MsaDataDSISHigh
);
499 spin_unlock_irqrestore(&dsp_lock
, flags
);
500 if(put_user(val
, pusBuffer
++))
503 PRINTK_3(TRACE_3780I
,
504 "3780I::dsp3780I_ReadDStore uCount %x val %x\n",
507 PaceMsaAccess(usDspBaseIO
);
511 PRINTK_1(TRACE_3780I
,
512 "3780I::dsp3780I_ReadDStore exit bRC=TRUE\n");
517 int dsp3780I_ReadAndClearDStore(unsigned short usDspBaseIO
,
518 void __user
*pvBuffer
, unsigned uCount
,
519 unsigned long ulDSPAddr
)
522 unsigned short __user
*pusBuffer
= pvBuffer
;
526 PRINTK_5(TRACE_3780I
,
527 "3780i::dsp3780I_ReadAndDStore entry usDspBaseIO %x, pusBuffer %p, uCount %x, ulDSPAddr %lx\n",
528 usDspBaseIO
, pusBuffer
, uCount
, ulDSPAddr
);
531 /* Set the initial MSA address. No adjustments need to be made to data store addresses */
532 spin_lock_irqsave(&dsp_lock
, flags
);
533 OutWordDsp(DSP_MsaAddrLow
, (unsigned short) ulDSPAddr
);
534 OutWordDsp(DSP_MsaAddrHigh
, (unsigned short) (ulDSPAddr
>> 16));
535 spin_unlock_irqrestore(&dsp_lock
, flags
);
537 /* Transfer the memory block */
538 while (uCount
-- != 0) {
539 spin_lock_irqsave(&dsp_lock
, flags
);
540 val
= InWordDsp(DSP_ReadAndClear
);
541 spin_unlock_irqrestore(&dsp_lock
, flags
);
542 if(put_user(val
, pusBuffer
++))
545 PRINTK_3(TRACE_3780I
,
546 "3780I::dsp3780I_ReadAndCleanDStore uCount %x val %x\n",
549 PaceMsaAccess(usDspBaseIO
);
553 PRINTK_1(TRACE_3780I
,
554 "3780I::dsp3780I_ReadAndClearDStore exit bRC=TRUE\n");
560 int dsp3780I_WriteDStore(unsigned short usDspBaseIO
, void __user
*pvBuffer
,
561 unsigned uCount
, unsigned long ulDSPAddr
)
564 unsigned short __user
*pusBuffer
= pvBuffer
;
567 PRINTK_5(TRACE_3780I
,
568 "3780i::dsp3780D_WriteDStore entry usDspBaseIO %x, pusBuffer %p, uCount %x, ulDSPAddr %lx\n",
569 usDspBaseIO
, pusBuffer
, uCount
, ulDSPAddr
);
572 /* Set the initial MSA address. No adjustments need to be made to data store addresses */
573 spin_lock_irqsave(&dsp_lock
, flags
);
574 OutWordDsp(DSP_MsaAddrLow
, (unsigned short) ulDSPAddr
);
575 OutWordDsp(DSP_MsaAddrHigh
, (unsigned short) (ulDSPAddr
>> 16));
576 spin_unlock_irqrestore(&dsp_lock
, flags
);
578 /* Transfer the memory block */
579 while (uCount
-- != 0) {
581 if(get_user(val
, pusBuffer
++))
583 spin_lock_irqsave(&dsp_lock
, flags
);
584 OutWordDsp(DSP_MsaDataDSISHigh
, val
);
585 spin_unlock_irqrestore(&dsp_lock
, flags
);
587 PRINTK_3(TRACE_3780I
,
588 "3780I::dsp3780I_WriteDStore uCount %x val %x\n",
591 PaceMsaAccess(usDspBaseIO
);
595 PRINTK_1(TRACE_3780I
,
596 "3780I::dsp3780D_WriteDStore exit bRC=TRUE\n");
602 int dsp3780I_ReadIStore(unsigned short usDspBaseIO
, void __user
*pvBuffer
,
603 unsigned uCount
, unsigned long ulDSPAddr
)
606 unsigned short __user
*pusBuffer
= pvBuffer
;
608 PRINTK_5(TRACE_3780I
,
609 "3780i::dsp3780I_ReadIStore entry usDspBaseIO %x, pusBuffer %p, uCount %x, ulDSPAddr %lx\n",
610 usDspBaseIO
, pusBuffer
, uCount
, ulDSPAddr
);
613 * Set the initial MSA address. To convert from an instruction store
614 * address to an MSA address
615 * shift the address two bits to the left and set bit 22
617 ulDSPAddr
= (ulDSPAddr
<< 2) | (1 << 22);
618 spin_lock_irqsave(&dsp_lock
, flags
);
619 OutWordDsp(DSP_MsaAddrLow
, (unsigned short) ulDSPAddr
);
620 OutWordDsp(DSP_MsaAddrHigh
, (unsigned short) (ulDSPAddr
>> 16));
621 spin_unlock_irqrestore(&dsp_lock
, flags
);
623 /* Transfer the memory block */
624 while (uCount
-- != 0) {
625 unsigned short val_lo
, val_hi
;
626 spin_lock_irqsave(&dsp_lock
, flags
);
627 val_lo
= InWordDsp(DSP_MsaDataISLow
);
628 val_hi
= InWordDsp(DSP_MsaDataDSISHigh
);
629 spin_unlock_irqrestore(&dsp_lock
, flags
);
630 if(put_user(val_lo
, pusBuffer
++))
632 if(put_user(val_hi
, pusBuffer
++))
635 PRINTK_4(TRACE_3780I
,
636 "3780I::dsp3780I_ReadIStore uCount %x val_lo %x val_hi %x\n",
637 uCount
, val_lo
, val_hi
);
639 PaceMsaAccess(usDspBaseIO
);
643 PRINTK_1(TRACE_3780I
,
644 "3780I::dsp3780I_ReadIStore exit bRC=TRUE\n");
650 int dsp3780I_WriteIStore(unsigned short usDspBaseIO
, void __user
*pvBuffer
,
651 unsigned uCount
, unsigned long ulDSPAddr
)
654 unsigned short __user
*pusBuffer
= pvBuffer
;
656 PRINTK_5(TRACE_3780I
,
657 "3780i::dsp3780I_WriteIStore entry usDspBaseIO %x, pusBuffer %p, uCount %x, ulDSPAddr %lx\n",
658 usDspBaseIO
, pusBuffer
, uCount
, ulDSPAddr
);
662 * Set the initial MSA address. To convert from an instruction store
663 * address to an MSA address
664 * shift the address two bits to the left and set bit 22
666 ulDSPAddr
= (ulDSPAddr
<< 2) | (1 << 22);
667 spin_lock_irqsave(&dsp_lock
, flags
);
668 OutWordDsp(DSP_MsaAddrLow
, (unsigned short) ulDSPAddr
);
669 OutWordDsp(DSP_MsaAddrHigh
, (unsigned short) (ulDSPAddr
>> 16));
670 spin_unlock_irqrestore(&dsp_lock
, flags
);
672 /* Transfer the memory block */
673 while (uCount
-- != 0) {
674 unsigned short val_lo
, val_hi
;
675 if(get_user(val_lo
, pusBuffer
++))
677 if(get_user(val_hi
, pusBuffer
++))
679 spin_lock_irqsave(&dsp_lock
, flags
);
680 OutWordDsp(DSP_MsaDataISLow
, val_lo
);
681 OutWordDsp(DSP_MsaDataDSISHigh
, val_hi
);
682 spin_unlock_irqrestore(&dsp_lock
, flags
);
684 PRINTK_4(TRACE_3780I
,
685 "3780I::dsp3780I_WriteIStore uCount %x val_lo %x val_hi %x\n",
686 uCount
, val_lo
, val_hi
);
688 PaceMsaAccess(usDspBaseIO
);
692 PRINTK_1(TRACE_3780I
,
693 "3780I::dsp3780I_WriteIStore exit bRC=TRUE\n");
699 int dsp3780I_GetIPCSource(unsigned short usDspBaseIO
,
700 unsigned short *pusIPCSource
)
703 DSP_HBRIDGE_CONTROL rHBridgeControl
;
707 PRINTK_3(TRACE_3780I
,
708 "3780i::dsp3780I_GetIPCSource entry usDspBaseIO %x pusIPCSource %p\n",
709 usDspBaseIO
, pusIPCSource
);
712 * Disable DSP to PC interrupts, read the interrupt register,
713 * clear the pending IPC bits, and reenable DSP to PC interrupts
715 spin_lock_irqsave(&dsp_lock
, flags
);
716 MKWORD(rHBridgeControl
) = InWordDsp(DSP_HBridgeControl
);
717 rHBridgeControl
.EnableDspInt
= FALSE
;
718 OutWordDsp(DSP_HBridgeControl
, MKWORD(rHBridgeControl
));
720 *pusIPCSource
= InWordDsp(DSP_Interrupt
);
721 temp
= (unsigned short) ~(*pusIPCSource
);
723 PRINTK_3(TRACE_3780I
,
724 "3780i::dsp3780I_GetIPCSource, usIPCSource %x ~ %x\n",
725 *pusIPCSource
, temp
);
727 OutWordDsp(DSP_Interrupt
, (unsigned short) ~(*pusIPCSource
));
729 rHBridgeControl
.EnableDspInt
= TRUE
;
730 OutWordDsp(DSP_HBridgeControl
, MKWORD(rHBridgeControl
));
731 spin_unlock_irqrestore(&dsp_lock
, flags
);
734 PRINTK_2(TRACE_3780I
,
735 "3780i::dsp3780I_GetIPCSource exit usIPCSource %x\n",