ARM: 7409/1: Do not call flush_cache_user_range with mmap_sem held
[linux/fpc-iii.git] / drivers / char / mwave / tp3780i.c
blobc68969708068a0f8472b611af2bddb38a3411632
1 /*
3 * tp3780i.c -- board driver for 3780i on ThinkPads
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/interrupt.h>
50 #include <linux/kernel.h>
51 #include <linux/ptrace.h>
52 #include <linux/ioport.h>
53 #include <asm/io.h>
54 #include "smapi.h"
55 #include "mwavedd.h"
56 #include "tp3780i.h"
57 #include "3780i.h"
58 #include "mwavepub.h"
60 static unsigned short s_ausThinkpadIrqToField[16] =
61 { 0xFFFF, 0xFFFF, 0xFFFF, 0x0001, 0x0002, 0x0003, 0xFFFF, 0x0004,
62 0xFFFF, 0xFFFF, 0x0005, 0x0006, 0xFFFF, 0xFFFF, 0xFFFF, 0x0007 };
63 static unsigned short s_ausThinkpadDmaToField[8] =
64 { 0x0001, 0x0002, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x0003, 0x0004 };
65 static unsigned short s_numIrqs = 16, s_numDmas = 8;
68 static void EnableSRAM(THINKPAD_BD_DATA * pBDData)
70 DSP_3780I_CONFIG_SETTINGS *pSettings = &pBDData->rDspSettings;
71 unsigned short usDspBaseIO = pSettings->usDspBaseIO;
72 DSP_GPIO_OUTPUT_DATA_15_8 rGpioOutputData;
73 DSP_GPIO_DRIVER_ENABLE_15_8 rGpioDriverEnable;
74 DSP_GPIO_MODE_15_8 rGpioMode;
76 PRINTK_1(TRACE_TP3780I, "tp3780i::EnableSRAM, entry\n");
78 MKWORD(rGpioMode) = ReadMsaCfg(DSP_GpioModeControl_15_8);
79 rGpioMode.GpioMode10 = 0;
80 WriteMsaCfg(DSP_GpioModeControl_15_8, MKWORD(rGpioMode));
82 MKWORD(rGpioDriverEnable) = 0;
83 rGpioDriverEnable.Enable10 = TRUE;
84 rGpioDriverEnable.Mask10 = TRUE;
85 WriteMsaCfg(DSP_GpioDriverEnable_15_8, MKWORD(rGpioDriverEnable));
87 MKWORD(rGpioOutputData) = 0;
88 rGpioOutputData.Latch10 = 0;
89 rGpioOutputData.Mask10 = TRUE;
90 WriteMsaCfg(DSP_GpioOutputData_15_8, MKWORD(rGpioOutputData));
92 PRINTK_1(TRACE_TP3780I, "tp3780i::EnableSRAM exit\n");
96 static irqreturn_t UartInterrupt(int irq, void *dev_id)
98 PRINTK_3(TRACE_TP3780I,
99 "tp3780i::UartInterrupt entry irq %x dev_id %p\n", irq, dev_id);
100 return IRQ_HANDLED;
103 static irqreturn_t DspInterrupt(int irq, void *dev_id)
105 pMWAVE_DEVICE_DATA pDrvData = &mwave_s_mdd;
106 DSP_3780I_CONFIG_SETTINGS *pSettings = &pDrvData->rBDData.rDspSettings;
107 unsigned short usDspBaseIO = pSettings->usDspBaseIO;
108 unsigned short usIPCSource = 0, usIsolationMask, usPCNum;
110 PRINTK_3(TRACE_TP3780I,
111 "tp3780i::DspInterrupt entry irq %x dev_id %p\n", irq, dev_id);
113 if (dsp3780I_GetIPCSource(usDspBaseIO, &usIPCSource) == 0) {
114 PRINTK_2(TRACE_TP3780I,
115 "tp3780i::DspInterrupt, return from dsp3780i_GetIPCSource, usIPCSource %x\n",
116 usIPCSource);
117 usIsolationMask = 1;
118 for (usPCNum = 1; usPCNum <= 16; usPCNum++) {
119 if (usIPCSource & usIsolationMask) {
120 usIPCSource &= ~usIsolationMask;
121 PRINTK_3(TRACE_TP3780I,
122 "tp3780i::DspInterrupt usPCNum %x usIPCSource %x\n",
123 usPCNum, usIPCSource);
124 if (pDrvData->IPCs[usPCNum - 1].usIntCount == 0) {
125 pDrvData->IPCs[usPCNum - 1].usIntCount = 1;
127 PRINTK_2(TRACE_TP3780I,
128 "tp3780i::DspInterrupt usIntCount %x\n",
129 pDrvData->IPCs[usPCNum - 1].usIntCount);
130 if (pDrvData->IPCs[usPCNum - 1].bIsEnabled == TRUE) {
131 PRINTK_2(TRACE_TP3780I,
132 "tp3780i::DspInterrupt, waking up usPCNum %x\n",
133 usPCNum - 1);
134 wake_up_interruptible(&pDrvData->IPCs[usPCNum - 1].ipc_wait_queue);
135 } else {
136 PRINTK_2(TRACE_TP3780I,
137 "tp3780i::DspInterrupt, no one waiting for IPC %x\n",
138 usPCNum - 1);
141 if (usIPCSource == 0)
142 break;
143 /* try next IPC */
144 usIsolationMask = usIsolationMask << 1;
146 } else {
147 PRINTK_1(TRACE_TP3780I,
148 "tp3780i::DspInterrupt, return false from dsp3780i_GetIPCSource\n");
150 PRINTK_1(TRACE_TP3780I, "tp3780i::DspInterrupt exit\n");
151 return IRQ_HANDLED;
155 int tp3780I_InitializeBoardData(THINKPAD_BD_DATA * pBDData)
157 int retval = 0;
158 DSP_3780I_CONFIG_SETTINGS *pSettings = &pBDData->rDspSettings;
161 PRINTK_2(TRACE_TP3780I, "tp3780i::tp3780I_InitializeBoardData entry pBDData %p\n", pBDData);
163 pBDData->bDSPEnabled = FALSE;
164 pSettings->bInterruptClaimed = FALSE;
166 retval = smapi_init();
167 if (retval) {
168 PRINTK_ERROR(KERN_ERR_MWAVE "tp3780i::tp3780I_InitializeBoardData: Error: SMAPI is not available on this machine\n");
169 } else {
170 if (mwave_3780i_irq || mwave_3780i_io || mwave_uart_irq || mwave_uart_io) {
171 retval = smapi_set_DSP_cfg();
175 PRINTK_2(TRACE_TP3780I, "tp3780i::tp3780I_InitializeBoardData exit retval %x\n", retval);
177 return retval;
180 int tp3780I_Cleanup(THINKPAD_BD_DATA * pBDData)
182 int retval = 0;
184 PRINTK_2(TRACE_TP3780I,
185 "tp3780i::tp3780I_Cleanup entry and exit pBDData %p\n", pBDData);
187 return retval;
190 int tp3780I_CalcResources(THINKPAD_BD_DATA * pBDData)
192 SMAPI_DSP_SETTINGS rSmapiInfo;
193 DSP_3780I_CONFIG_SETTINGS *pSettings = &pBDData->rDspSettings;
195 PRINTK_2(TRACE_TP3780I,
196 "tp3780i::tp3780I_CalcResources entry pBDData %p\n", pBDData);
198 if (smapi_query_DSP_cfg(&rSmapiInfo)) {
199 PRINTK_ERROR(KERN_ERR_MWAVE "tp3780i::tp3780I_CalcResources: Error: Could not query DSP config. Aborting.\n");
200 return -EIO;
203 /* Sanity check */
204 if (
205 ( rSmapiInfo.usDspIRQ == 0 )
206 || ( rSmapiInfo.usDspBaseIO == 0 )
207 || ( rSmapiInfo.usUartIRQ == 0 )
208 || ( rSmapiInfo.usUartBaseIO == 0 )
210 PRINTK_ERROR(KERN_ERR_MWAVE "tp3780i::tp3780I_CalcResources: Error: Illegal resource setting. Aborting.\n");
211 return -EIO;
214 pSettings->bDSPEnabled = (rSmapiInfo.bDSPEnabled && rSmapiInfo.bDSPPresent);
215 pSettings->bModemEnabled = rSmapiInfo.bModemEnabled;
216 pSettings->usDspIrq = rSmapiInfo.usDspIRQ;
217 pSettings->usDspDma = rSmapiInfo.usDspDMA;
218 pSettings->usDspBaseIO = rSmapiInfo.usDspBaseIO;
219 pSettings->usUartIrq = rSmapiInfo.usUartIRQ;
220 pSettings->usUartBaseIO = rSmapiInfo.usUartBaseIO;
222 pSettings->uDStoreSize = TP_ABILITIES_DATA_SIZE;
223 pSettings->uIStoreSize = TP_ABILITIES_INST_SIZE;
224 pSettings->uIps = TP_ABILITIES_INTS_PER_SEC;
226 if (pSettings->bDSPEnabled && pSettings->bModemEnabled && pSettings->usDspIrq == pSettings->usUartIrq) {
227 pBDData->bShareDspIrq = pBDData->bShareUartIrq = 1;
228 } else {
229 pBDData->bShareDspIrq = pBDData->bShareUartIrq = 0;
232 PRINTK_1(TRACE_TP3780I, "tp3780i::tp3780I_CalcResources exit\n");
234 return 0;
238 int tp3780I_ClaimResources(THINKPAD_BD_DATA * pBDData)
240 int retval = 0;
241 DSP_3780I_CONFIG_SETTINGS *pSettings = &pBDData->rDspSettings;
242 struct resource *pres;
244 PRINTK_2(TRACE_TP3780I,
245 "tp3780i::tp3780I_ClaimResources entry pBDData %p\n", pBDData);
247 pres = request_region(pSettings->usDspBaseIO, 16, "mwave_3780i");
248 if ( pres == NULL ) retval = -EIO;
250 if (retval) {
251 PRINTK_ERROR(KERN_ERR_MWAVE "tp3780i::tp3780I_ClaimResources: Error: Could not claim I/O region starting at %x\n", pSettings->usDspBaseIO);
252 retval = -EIO;
255 PRINTK_2(TRACE_TP3780I, "tp3780i::tp3780I_ClaimResources exit retval %x\n", retval);
257 return retval;
260 int tp3780I_ReleaseResources(THINKPAD_BD_DATA * pBDData)
262 int retval = 0;
263 DSP_3780I_CONFIG_SETTINGS *pSettings = &pBDData->rDspSettings;
265 PRINTK_2(TRACE_TP3780I,
266 "tp3780i::tp3780I_ReleaseResources entry pBDData %p\n", pBDData);
268 release_region(pSettings->usDspBaseIO & (~3), 16);
270 if (pSettings->bInterruptClaimed) {
271 free_irq(pSettings->usDspIrq, NULL);
272 pSettings->bInterruptClaimed = FALSE;
275 PRINTK_2(TRACE_TP3780I,
276 "tp3780i::tp3780I_ReleaseResources exit retval %x\n", retval);
278 return retval;
283 int tp3780I_EnableDSP(THINKPAD_BD_DATA * pBDData)
285 DSP_3780I_CONFIG_SETTINGS *pSettings = &pBDData->rDspSettings;
286 BOOLEAN bDSPPoweredUp = FALSE, bInterruptAllocated = FALSE;
288 PRINTK_2(TRACE_TP3780I, "tp3780i::tp3780I_EnableDSP entry pBDData %p\n", pBDData);
290 if (pBDData->bDSPEnabled) {
291 PRINTK_ERROR(KERN_ERR_MWAVE "tp3780i::tp3780I_EnableDSP: Error: DSP already enabled!\n");
292 goto exit_cleanup;
295 if (!pSettings->bDSPEnabled) {
296 PRINTK_ERROR(KERN_ERR_MWAVE "tp3780::tp3780I_EnableDSP: Error: pSettings->bDSPEnabled not set\n");
297 goto exit_cleanup;
300 if (
301 (pSettings->usDspIrq >= s_numIrqs)
302 || (pSettings->usDspDma >= s_numDmas)
303 || (s_ausThinkpadIrqToField[pSettings->usDspIrq] == 0xFFFF)
304 || (s_ausThinkpadDmaToField[pSettings->usDspDma] == 0xFFFF)
306 PRINTK_ERROR(KERN_ERR_MWAVE "tp3780i::tp3780I_EnableDSP: Error: invalid irq %x\n", pSettings->usDspIrq);
307 goto exit_cleanup;
310 if (
311 ((pSettings->usDspBaseIO & 0xF00F) != 0)
312 || (pSettings->usDspBaseIO & 0x0FF0) == 0
314 PRINTK_ERROR(KERN_ERR_MWAVE "tp3780i::tp3780I_EnableDSP: Error: Invalid DSP base I/O address %x\n", pSettings->usDspBaseIO);
315 goto exit_cleanup;
318 if (pSettings->bModemEnabled) {
319 if (
320 pSettings->usUartIrq >= s_numIrqs
321 || s_ausThinkpadIrqToField[pSettings->usUartIrq] == 0xFFFF
323 PRINTK_ERROR(KERN_ERR_MWAVE "tp3780i::tp3780I_EnableDSP: Error: Invalid UART IRQ %x\n", pSettings->usUartIrq);
324 goto exit_cleanup;
326 switch (pSettings->usUartBaseIO) {
327 case 0x03F8:
328 case 0x02F8:
329 case 0x03E8:
330 case 0x02E8:
331 break;
333 default:
334 PRINTK_ERROR("tp3780i::tp3780I_EnableDSP: Error: Invalid UART base I/O address %x\n", pSettings->usUartBaseIO);
335 goto exit_cleanup;
339 pSettings->bDspIrqActiveLow = pSettings->bDspIrqPulse = TRUE;
340 pSettings->bUartIrqActiveLow = pSettings->bUartIrqPulse = TRUE;
342 if (pBDData->bShareDspIrq) {
343 pSettings->bDspIrqActiveLow = FALSE;
345 if (pBDData->bShareUartIrq) {
346 pSettings->bUartIrqActiveLow = FALSE;
349 pSettings->usNumTransfers = TP_CFG_NumTransfers;
350 pSettings->usReRequest = TP_CFG_RerequestTimer;
351 pSettings->bEnableMEMCS16 = TP_CFG_MEMCS16;
352 pSettings->usIsaMemCmdWidth = TP_CFG_IsaMemCmdWidth;
353 pSettings->bGateIOCHRDY = TP_CFG_GateIOCHRDY;
354 pSettings->bEnablePwrMgmt = TP_CFG_EnablePwrMgmt;
355 pSettings->usHBusTimerLoadValue = TP_CFG_HBusTimerValue;
356 pSettings->bDisableLBusTimeout = TP_CFG_DisableLBusTimeout;
357 pSettings->usN_Divisor = TP_CFG_N_Divisor;
358 pSettings->usM_Multiplier = TP_CFG_M_Multiplier;
359 pSettings->bPllBypass = TP_CFG_PllBypass;
360 pSettings->usChipletEnable = TP_CFG_ChipletEnable;
362 if (request_irq(pSettings->usUartIrq, &UartInterrupt, 0, "mwave_uart", NULL)) {
363 PRINTK_ERROR(KERN_ERR_MWAVE "tp3780i::tp3780I_EnableDSP: Error: Could not get UART IRQ %x\n", pSettings->usUartIrq);
364 goto exit_cleanup;
365 } else { /* no conflict just release */
366 free_irq(pSettings->usUartIrq, NULL);
369 if (request_irq(pSettings->usDspIrq, &DspInterrupt, 0, "mwave_3780i", NULL)) {
370 PRINTK_ERROR("tp3780i::tp3780I_EnableDSP: Error: Could not get 3780i IRQ %x\n", pSettings->usDspIrq);
371 goto exit_cleanup;
372 } else {
373 PRINTK_3(TRACE_TP3780I,
374 "tp3780i::tp3780I_EnableDSP, got interrupt %x bShareDspIrq %x\n",
375 pSettings->usDspIrq, pBDData->bShareDspIrq);
376 bInterruptAllocated = TRUE;
377 pSettings->bInterruptClaimed = TRUE;
380 smapi_set_DSP_power_state(FALSE);
381 if (smapi_set_DSP_power_state(TRUE)) {
382 PRINTK_ERROR(KERN_ERR_MWAVE "tp3780i::tp3780I_EnableDSP: Error: smapi_set_DSP_power_state(TRUE) failed\n");
383 goto exit_cleanup;
384 } else {
385 bDSPPoweredUp = TRUE;
388 if (dsp3780I_EnableDSP(pSettings, s_ausThinkpadIrqToField, s_ausThinkpadDmaToField)) {
389 PRINTK_ERROR("tp3780i::tp3780I_EnableDSP: Error: dsp7880I_EnableDSP() failed\n");
390 goto exit_cleanup;
393 EnableSRAM(pBDData);
395 pBDData->bDSPEnabled = TRUE;
397 PRINTK_1(TRACE_TP3780I, "tp3780i::tp3780I_EnableDSP exit\n");
399 return 0;
401 exit_cleanup:
402 PRINTK_ERROR("tp3780i::tp3780I_EnableDSP: Cleaning up\n");
403 if (bDSPPoweredUp)
404 smapi_set_DSP_power_state(FALSE);
405 if (bInterruptAllocated) {
406 free_irq(pSettings->usDspIrq, NULL);
407 pSettings->bInterruptClaimed = FALSE;
409 return -EIO;
413 int tp3780I_DisableDSP(THINKPAD_BD_DATA * pBDData)
415 int retval = 0;
416 DSP_3780I_CONFIG_SETTINGS *pSettings = &pBDData->rDspSettings;
418 PRINTK_2(TRACE_TP3780I, "tp3780i::tp3780I_DisableDSP entry pBDData %p\n", pBDData);
420 if (pBDData->bDSPEnabled) {
421 dsp3780I_DisableDSP(&pBDData->rDspSettings);
422 if (pSettings->bInterruptClaimed) {
423 free_irq(pSettings->usDspIrq, NULL);
424 pSettings->bInterruptClaimed = FALSE;
426 smapi_set_DSP_power_state(FALSE);
427 pBDData->bDSPEnabled = FALSE;
430 PRINTK_2(TRACE_TP3780I, "tp3780i::tp3780I_DisableDSP exit retval %x\n", retval);
432 return retval;
436 int tp3780I_ResetDSP(THINKPAD_BD_DATA * pBDData)
438 int retval = 0;
439 DSP_3780I_CONFIG_SETTINGS *pSettings = &pBDData->rDspSettings;
441 PRINTK_2(TRACE_TP3780I, "tp3780i::tp3780I_ResetDSP entry pBDData %p\n",
442 pBDData);
444 if (dsp3780I_Reset(pSettings) == 0) {
445 EnableSRAM(pBDData);
446 } else {
447 retval = -EIO;
450 PRINTK_2(TRACE_TP3780I, "tp3780i::tp3780I_ResetDSP exit retval %x\n", retval);
452 return retval;
456 int tp3780I_StartDSP(THINKPAD_BD_DATA * pBDData)
458 int retval = 0;
459 DSP_3780I_CONFIG_SETTINGS *pSettings = &pBDData->rDspSettings;
461 PRINTK_2(TRACE_TP3780I, "tp3780i::tp3780I_StartDSP entry pBDData %p\n", pBDData);
463 if (dsp3780I_Run(pSettings) == 0) {
464 // @BUG @TBD EnableSRAM(pBDData);
465 } else {
466 retval = -EIO;
469 PRINTK_2(TRACE_TP3780I, "tp3780i::tp3780I_StartDSP exit retval %x\n", retval);
471 return retval;
475 int tp3780I_QueryAbilities(THINKPAD_BD_DATA * pBDData, MW_ABILITIES * pAbilities)
477 int retval = 0;
479 PRINTK_2(TRACE_TP3780I,
480 "tp3780i::tp3780I_QueryAbilities entry pBDData %p\n", pBDData);
482 /* fill out standard constant fields */
483 pAbilities->instr_per_sec = pBDData->rDspSettings.uIps;
484 pAbilities->data_size = pBDData->rDspSettings.uDStoreSize;
485 pAbilities->inst_size = pBDData->rDspSettings.uIStoreSize;
486 pAbilities->bus_dma_bw = pBDData->rDspSettings.uDmaBandwidth;
488 /* fill out dynamically determined fields */
489 pAbilities->component_list[0] = 0x00010000 | MW_ADC_MASK;
490 pAbilities->component_list[1] = 0x00010000 | MW_ACI_MASK;
491 pAbilities->component_list[2] = 0x00010000 | MW_AIC1_MASK;
492 pAbilities->component_list[3] = 0x00010000 | MW_AIC2_MASK;
493 pAbilities->component_list[4] = 0x00010000 | MW_CDDAC_MASK;
494 pAbilities->component_list[5] = 0x00010000 | MW_MIDI_MASK;
495 pAbilities->component_list[6] = 0x00010000 | MW_UART_MASK;
496 pAbilities->component_count = 7;
498 /* Fill out Mwave OS and BIOS task names */
500 memcpy(pAbilities->mwave_os_name, TP_ABILITIES_MWAVEOS_NAME,
501 sizeof(TP_ABILITIES_MWAVEOS_NAME));
502 memcpy(pAbilities->bios_task_name, TP_ABILITIES_BIOSTASK_NAME,
503 sizeof(TP_ABILITIES_BIOSTASK_NAME));
505 PRINTK_1(TRACE_TP3780I,
506 "tp3780i::tp3780I_QueryAbilities exit retval=SUCCESSFUL\n");
508 return retval;
511 int tp3780I_ReadWriteDspDStore(THINKPAD_BD_DATA * pBDData, unsigned int uOpcode,
512 void __user *pvBuffer, unsigned int uCount,
513 unsigned long ulDSPAddr)
515 int retval = 0;
516 DSP_3780I_CONFIG_SETTINGS *pSettings = &pBDData->rDspSettings;
517 unsigned short usDspBaseIO = pSettings->usDspBaseIO;
518 BOOLEAN bRC = 0;
520 PRINTK_6(TRACE_TP3780I,
521 "tp3780i::tp3780I_ReadWriteDspDStore entry pBDData %p, uOpcode %x, pvBuffer %p, uCount %x, ulDSPAddr %lx\n",
522 pBDData, uOpcode, pvBuffer, uCount, ulDSPAddr);
524 if (pBDData->bDSPEnabled) {
525 switch (uOpcode) {
526 case IOCTL_MW_READ_DATA:
527 bRC = dsp3780I_ReadDStore(usDspBaseIO, pvBuffer, uCount, ulDSPAddr);
528 break;
530 case IOCTL_MW_READCLEAR_DATA:
531 bRC = dsp3780I_ReadAndClearDStore(usDspBaseIO, pvBuffer, uCount, ulDSPAddr);
532 break;
534 case IOCTL_MW_WRITE_DATA:
535 bRC = dsp3780I_WriteDStore(usDspBaseIO, pvBuffer, uCount, ulDSPAddr);
536 break;
540 retval = (bRC) ? -EIO : 0;
541 PRINTK_2(TRACE_TP3780I, "tp3780i::tp3780I_ReadWriteDspDStore exit retval %x\n", retval);
543 return retval;
547 int tp3780I_ReadWriteDspIStore(THINKPAD_BD_DATA * pBDData, unsigned int uOpcode,
548 void __user *pvBuffer, unsigned int uCount,
549 unsigned long ulDSPAddr)
551 int retval = 0;
552 DSP_3780I_CONFIG_SETTINGS *pSettings = &pBDData->rDspSettings;
553 unsigned short usDspBaseIO = pSettings->usDspBaseIO;
554 BOOLEAN bRC = 0;
556 PRINTK_6(TRACE_TP3780I,
557 "tp3780i::tp3780I_ReadWriteDspIStore entry pBDData %p, uOpcode %x, pvBuffer %p, uCount %x, ulDSPAddr %lx\n",
558 pBDData, uOpcode, pvBuffer, uCount, ulDSPAddr);
560 if (pBDData->bDSPEnabled) {
561 switch (uOpcode) {
562 case IOCTL_MW_READ_INST:
563 bRC = dsp3780I_ReadIStore(usDspBaseIO, pvBuffer, uCount, ulDSPAddr);
564 break;
566 case IOCTL_MW_WRITE_INST:
567 bRC = dsp3780I_WriteIStore(usDspBaseIO, pvBuffer, uCount, ulDSPAddr);
568 break;
572 retval = (bRC) ? -EIO : 0;
574 PRINTK_2(TRACE_TP3780I,
575 "tp3780i::tp3780I_ReadWriteDspIStore exit retval %x\n", retval);
577 return retval;