pcmcia: CompactFlash driver for PA Semi Electra boards
[pv_ops_mirror.git] / drivers / char / mwave / tp3780i.c
blobf282976daaacfe8e6da245071757c9d552f0fbad
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 extern MWAVE_DEVICE_DATA mwave_s_mdd;
62 static unsigned short s_ausThinkpadIrqToField[16] =
63 { 0xFFFF, 0xFFFF, 0xFFFF, 0x0001, 0x0002, 0x0003, 0xFFFF, 0x0004,
64 0xFFFF, 0xFFFF, 0x0005, 0x0006, 0xFFFF, 0xFFFF, 0xFFFF, 0x0007 };
65 static unsigned short s_ausThinkpadDmaToField[8] =
66 { 0x0001, 0x0002, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x0003, 0x0004 };
67 static unsigned short s_numIrqs = 16, s_numDmas = 8;
70 static void EnableSRAM(THINKPAD_BD_DATA * pBDData)
72 DSP_3780I_CONFIG_SETTINGS *pSettings = &pBDData->rDspSettings;
73 unsigned short usDspBaseIO = pSettings->usDspBaseIO;
74 DSP_GPIO_OUTPUT_DATA_15_8 rGpioOutputData;
75 DSP_GPIO_DRIVER_ENABLE_15_8 rGpioDriverEnable;
76 DSP_GPIO_MODE_15_8 rGpioMode;
78 PRINTK_1(TRACE_TP3780I, "tp3780i::EnableSRAM, entry\n");
80 MKWORD(rGpioMode) = ReadMsaCfg(DSP_GpioModeControl_15_8);
81 rGpioMode.GpioMode10 = 0;
82 WriteMsaCfg(DSP_GpioModeControl_15_8, MKWORD(rGpioMode));
84 MKWORD(rGpioDriverEnable) = 0;
85 rGpioDriverEnable.Enable10 = TRUE;
86 rGpioDriverEnable.Mask10 = TRUE;
87 WriteMsaCfg(DSP_GpioDriverEnable_15_8, MKWORD(rGpioDriverEnable));
89 MKWORD(rGpioOutputData) = 0;
90 rGpioOutputData.Latch10 = 0;
91 rGpioOutputData.Mask10 = TRUE;
92 WriteMsaCfg(DSP_GpioOutputData_15_8, MKWORD(rGpioOutputData));
94 PRINTK_1(TRACE_TP3780I, "tp3780i::EnableSRAM exit\n");
98 static irqreturn_t UartInterrupt(int irq, void *dev_id)
100 PRINTK_3(TRACE_TP3780I,
101 "tp3780i::UartInterrupt entry irq %x dev_id %p\n", irq, dev_id);
102 return IRQ_HANDLED;
105 static irqreturn_t DspInterrupt(int irq, void *dev_id)
107 pMWAVE_DEVICE_DATA pDrvData = &mwave_s_mdd;
108 DSP_3780I_CONFIG_SETTINGS *pSettings = &pDrvData->rBDData.rDspSettings;
109 unsigned short usDspBaseIO = pSettings->usDspBaseIO;
110 unsigned short usIPCSource = 0, usIsolationMask, usPCNum;
112 PRINTK_3(TRACE_TP3780I,
113 "tp3780i::DspInterrupt entry irq %x dev_id %p\n", irq, dev_id);
115 if (dsp3780I_GetIPCSource(usDspBaseIO, &usIPCSource) == 0) {
116 PRINTK_2(TRACE_TP3780I,
117 "tp3780i::DspInterrupt, return from dsp3780i_GetIPCSource, usIPCSource %x\n",
118 usIPCSource);
119 usIsolationMask = 1;
120 for (usPCNum = 1; usPCNum <= 16; usPCNum++) {
121 if (usIPCSource & usIsolationMask) {
122 usIPCSource &= ~usIsolationMask;
123 PRINTK_3(TRACE_TP3780I,
124 "tp3780i::DspInterrupt usPCNum %x usIPCSource %x\n",
125 usPCNum, usIPCSource);
126 if (pDrvData->IPCs[usPCNum - 1].usIntCount == 0) {
127 pDrvData->IPCs[usPCNum - 1].usIntCount = 1;
129 PRINTK_2(TRACE_TP3780I,
130 "tp3780i::DspInterrupt usIntCount %x\n",
131 pDrvData->IPCs[usPCNum - 1].usIntCount);
132 if (pDrvData->IPCs[usPCNum - 1].bIsEnabled == TRUE) {
133 PRINTK_2(TRACE_TP3780I,
134 "tp3780i::DspInterrupt, waking up usPCNum %x\n",
135 usPCNum - 1);
136 wake_up_interruptible(&pDrvData->IPCs[usPCNum - 1].ipc_wait_queue);
137 } else {
138 PRINTK_2(TRACE_TP3780I,
139 "tp3780i::DspInterrupt, no one waiting for IPC %x\n",
140 usPCNum - 1);
143 if (usIPCSource == 0)
144 break;
145 /* try next IPC */
146 usIsolationMask = usIsolationMask << 1;
148 } else {
149 PRINTK_1(TRACE_TP3780I,
150 "tp3780i::DspInterrupt, return false from dsp3780i_GetIPCSource\n");
152 PRINTK_1(TRACE_TP3780I, "tp3780i::DspInterrupt exit\n");
153 return IRQ_HANDLED;
157 int tp3780I_InitializeBoardData(THINKPAD_BD_DATA * pBDData)
159 int retval = 0;
160 DSP_3780I_CONFIG_SETTINGS *pSettings = &pBDData->rDspSettings;
163 PRINTK_2(TRACE_TP3780I, "tp3780i::tp3780I_InitializeBoardData entry pBDData %p\n", pBDData);
165 pBDData->bDSPEnabled = FALSE;
166 pSettings->bInterruptClaimed = FALSE;
168 retval = smapi_init();
169 if (retval) {
170 PRINTK_ERROR(KERN_ERR_MWAVE "tp3780i::tp3780I_InitializeBoardData: Error: SMAPI is not available on this machine\n");
171 } else {
172 if (mwave_3780i_irq || mwave_3780i_io || mwave_uart_irq || mwave_uart_io) {
173 retval = smapi_set_DSP_cfg();
177 PRINTK_2(TRACE_TP3780I, "tp3780i::tp3780I_InitializeBoardData exit retval %x\n", retval);
179 return retval;
182 int tp3780I_Cleanup(THINKPAD_BD_DATA * pBDData)
184 int retval = 0;
186 PRINTK_2(TRACE_TP3780I,
187 "tp3780i::tp3780I_Cleanup entry and exit pBDData %p\n", pBDData);
189 return retval;
192 int tp3780I_CalcResources(THINKPAD_BD_DATA * pBDData)
194 SMAPI_DSP_SETTINGS rSmapiInfo;
195 DSP_3780I_CONFIG_SETTINGS *pSettings = &pBDData->rDspSettings;
197 PRINTK_2(TRACE_TP3780I,
198 "tp3780i::tp3780I_CalcResources entry pBDData %p\n", pBDData);
200 if (smapi_query_DSP_cfg(&rSmapiInfo)) {
201 PRINTK_ERROR(KERN_ERR_MWAVE "tp3780i::tp3780I_CalcResources: Error: Could not query DSP config. Aborting.\n");
202 return -EIO;
205 /* Sanity check */
206 if (
207 ( rSmapiInfo.usDspIRQ == 0 )
208 || ( rSmapiInfo.usDspBaseIO == 0 )
209 || ( rSmapiInfo.usUartIRQ == 0 )
210 || ( rSmapiInfo.usUartBaseIO == 0 )
212 PRINTK_ERROR(KERN_ERR_MWAVE "tp3780i::tp3780I_CalcResources: Error: Illegal resource setting. Aborting.\n");
213 return -EIO;
216 pSettings->bDSPEnabled = (rSmapiInfo.bDSPEnabled && rSmapiInfo.bDSPPresent);
217 pSettings->bModemEnabled = rSmapiInfo.bModemEnabled;
218 pSettings->usDspIrq = rSmapiInfo.usDspIRQ;
219 pSettings->usDspDma = rSmapiInfo.usDspDMA;
220 pSettings->usDspBaseIO = rSmapiInfo.usDspBaseIO;
221 pSettings->usUartIrq = rSmapiInfo.usUartIRQ;
222 pSettings->usUartBaseIO = rSmapiInfo.usUartBaseIO;
224 pSettings->uDStoreSize = TP_ABILITIES_DATA_SIZE;
225 pSettings->uIStoreSize = TP_ABILITIES_INST_SIZE;
226 pSettings->uIps = TP_ABILITIES_INTS_PER_SEC;
228 if (pSettings->bDSPEnabled && pSettings->bModemEnabled && pSettings->usDspIrq == pSettings->usUartIrq) {
229 pBDData->bShareDspIrq = pBDData->bShareUartIrq = 1;
230 } else {
231 pBDData->bShareDspIrq = pBDData->bShareUartIrq = 0;
234 PRINTK_1(TRACE_TP3780I, "tp3780i::tp3780I_CalcResources exit\n");
236 return 0;
240 int tp3780I_ClaimResources(THINKPAD_BD_DATA * pBDData)
242 int retval = 0;
243 DSP_3780I_CONFIG_SETTINGS *pSettings = &pBDData->rDspSettings;
244 struct resource *pres;
246 PRINTK_2(TRACE_TP3780I,
247 "tp3780i::tp3780I_ClaimResources entry pBDData %p\n", pBDData);
249 pres = request_region(pSettings->usDspBaseIO, 16, "mwave_3780i");
250 if ( pres == NULL ) retval = -EIO;
252 if (retval) {
253 PRINTK_ERROR(KERN_ERR_MWAVE "tp3780i::tp3780I_ClaimResources: Error: Could not claim I/O region starting at %x\n", pSettings->usDspBaseIO);
254 retval = -EIO;
257 PRINTK_2(TRACE_TP3780I, "tp3780i::tp3780I_ClaimResources exit retval %x\n", retval);
259 return retval;
262 int tp3780I_ReleaseResources(THINKPAD_BD_DATA * pBDData)
264 int retval = 0;
265 DSP_3780I_CONFIG_SETTINGS *pSettings = &pBDData->rDspSettings;
267 PRINTK_2(TRACE_TP3780I,
268 "tp3780i::tp3780I_ReleaseResources entry pBDData %p\n", pBDData);
270 release_region(pSettings->usDspBaseIO & (~3), 16);
272 if (pSettings->bInterruptClaimed) {
273 free_irq(pSettings->usDspIrq, NULL);
274 pSettings->bInterruptClaimed = FALSE;
277 PRINTK_2(TRACE_TP3780I,
278 "tp3780i::tp3780I_ReleaseResources exit retval %x\n", retval);
280 return retval;
285 int tp3780I_EnableDSP(THINKPAD_BD_DATA * pBDData)
287 DSP_3780I_CONFIG_SETTINGS *pSettings = &pBDData->rDspSettings;
288 BOOLEAN bDSPPoweredUp = FALSE, bInterruptAllocated = FALSE;
290 PRINTK_2(TRACE_TP3780I, "tp3780i::tp3780I_EnableDSP entry pBDData %p\n", pBDData);
292 if (pBDData->bDSPEnabled) {
293 PRINTK_ERROR(KERN_ERR_MWAVE "tp3780i::tp3780I_EnableDSP: Error: DSP already enabled!\n");
294 goto exit_cleanup;
297 if (!pSettings->bDSPEnabled) {
298 PRINTK_ERROR(KERN_ERR_MWAVE "tp3780::tp3780I_EnableDSP: Error: pSettings->bDSPEnabled not set\n");
299 goto exit_cleanup;
302 if (
303 (pSettings->usDspIrq >= s_numIrqs)
304 || (pSettings->usDspDma >= s_numDmas)
305 || (s_ausThinkpadIrqToField[pSettings->usDspIrq] == 0xFFFF)
306 || (s_ausThinkpadDmaToField[pSettings->usDspDma] == 0xFFFF)
308 PRINTK_ERROR(KERN_ERR_MWAVE "tp3780i::tp3780I_EnableDSP: Error: invalid irq %x\n", pSettings->usDspIrq);
309 goto exit_cleanup;
312 if (
313 ((pSettings->usDspBaseIO & 0xF00F) != 0)
314 || (pSettings->usDspBaseIO & 0x0FF0) == 0
316 PRINTK_ERROR(KERN_ERR_MWAVE "tp3780i::tp3780I_EnableDSP: Error: Invalid DSP base I/O address %x\n", pSettings->usDspBaseIO);
317 goto exit_cleanup;
320 if (pSettings->bModemEnabled) {
321 if (
322 pSettings->usUartIrq >= s_numIrqs
323 || s_ausThinkpadIrqToField[pSettings->usUartIrq] == 0xFFFF
325 PRINTK_ERROR(KERN_ERR_MWAVE "tp3780i::tp3780I_EnableDSP: Error: Invalid UART IRQ %x\n", pSettings->usUartIrq);
326 goto exit_cleanup;
328 switch (pSettings->usUartBaseIO) {
329 case 0x03F8:
330 case 0x02F8:
331 case 0x03E8:
332 case 0x02E8:
333 break;
335 default:
336 PRINTK_ERROR("tp3780i::tp3780I_EnableDSP: Error: Invalid UART base I/O address %x\n", pSettings->usUartBaseIO);
337 goto exit_cleanup;
341 pSettings->bDspIrqActiveLow = pSettings->bDspIrqPulse = TRUE;
342 pSettings->bUartIrqActiveLow = pSettings->bUartIrqPulse = TRUE;
344 if (pBDData->bShareDspIrq) {
345 pSettings->bDspIrqActiveLow = FALSE;
347 if (pBDData->bShareUartIrq) {
348 pSettings->bUartIrqActiveLow = FALSE;
351 pSettings->usNumTransfers = TP_CFG_NumTransfers;
352 pSettings->usReRequest = TP_CFG_RerequestTimer;
353 pSettings->bEnableMEMCS16 = TP_CFG_MEMCS16;
354 pSettings->usIsaMemCmdWidth = TP_CFG_IsaMemCmdWidth;
355 pSettings->bGateIOCHRDY = TP_CFG_GateIOCHRDY;
356 pSettings->bEnablePwrMgmt = TP_CFG_EnablePwrMgmt;
357 pSettings->usHBusTimerLoadValue = TP_CFG_HBusTimerValue;
358 pSettings->bDisableLBusTimeout = TP_CFG_DisableLBusTimeout;
359 pSettings->usN_Divisor = TP_CFG_N_Divisor;
360 pSettings->usM_Multiplier = TP_CFG_M_Multiplier;
361 pSettings->bPllBypass = TP_CFG_PllBypass;
362 pSettings->usChipletEnable = TP_CFG_ChipletEnable;
364 if (request_irq(pSettings->usUartIrq, &UartInterrupt, 0, "mwave_uart", NULL)) {
365 PRINTK_ERROR(KERN_ERR_MWAVE "tp3780i::tp3780I_EnableDSP: Error: Could not get UART IRQ %x\n", pSettings->usUartIrq);
366 goto exit_cleanup;
367 } else { /* no conflict just release */
368 free_irq(pSettings->usUartIrq, NULL);
371 if (request_irq(pSettings->usDspIrq, &DspInterrupt, 0, "mwave_3780i", NULL)) {
372 PRINTK_ERROR("tp3780i::tp3780I_EnableDSP: Error: Could not get 3780i IRQ %x\n", pSettings->usDspIrq);
373 goto exit_cleanup;
374 } else {
375 PRINTK_3(TRACE_TP3780I,
376 "tp3780i::tp3780I_EnableDSP, got interrupt %x bShareDspIrq %x\n",
377 pSettings->usDspIrq, pBDData->bShareDspIrq);
378 bInterruptAllocated = TRUE;
379 pSettings->bInterruptClaimed = TRUE;
382 smapi_set_DSP_power_state(FALSE);
383 if (smapi_set_DSP_power_state(TRUE)) {
384 PRINTK_ERROR(KERN_ERR_MWAVE "tp3780i::tp3780I_EnableDSP: Error: smapi_set_DSP_power_state(TRUE) failed\n");
385 goto exit_cleanup;
386 } else {
387 bDSPPoweredUp = TRUE;
390 if (dsp3780I_EnableDSP(pSettings, s_ausThinkpadIrqToField, s_ausThinkpadDmaToField)) {
391 PRINTK_ERROR("tp3780i::tp3780I_EnableDSP: Error: dsp7880I_EnableDSP() failed\n");
392 goto exit_cleanup;
395 EnableSRAM(pBDData);
397 pBDData->bDSPEnabled = TRUE;
399 PRINTK_1(TRACE_TP3780I, "tp3780i::tp3780I_EnableDSP exit\n");
401 return 0;
403 exit_cleanup:
404 PRINTK_ERROR("tp3780i::tp3780I_EnableDSP: Cleaning up\n");
405 if (bDSPPoweredUp)
406 smapi_set_DSP_power_state(FALSE);
407 if (bInterruptAllocated) {
408 free_irq(pSettings->usDspIrq, NULL);
409 pSettings->bInterruptClaimed = FALSE;
411 return -EIO;
415 int tp3780I_DisableDSP(THINKPAD_BD_DATA * pBDData)
417 int retval = 0;
418 DSP_3780I_CONFIG_SETTINGS *pSettings = &pBDData->rDspSettings;
420 PRINTK_2(TRACE_TP3780I, "tp3780i::tp3780I_DisableDSP entry pBDData %p\n", pBDData);
422 if (pBDData->bDSPEnabled) {
423 dsp3780I_DisableDSP(&pBDData->rDspSettings);
424 if (pSettings->bInterruptClaimed) {
425 free_irq(pSettings->usDspIrq, NULL);
426 pSettings->bInterruptClaimed = FALSE;
428 smapi_set_DSP_power_state(FALSE);
429 pBDData->bDSPEnabled = FALSE;
432 PRINTK_2(TRACE_TP3780I, "tp3780i::tp3780I_DisableDSP exit retval %x\n", retval);
434 return retval;
438 int tp3780I_ResetDSP(THINKPAD_BD_DATA * pBDData)
440 int retval = 0;
441 DSP_3780I_CONFIG_SETTINGS *pSettings = &pBDData->rDspSettings;
443 PRINTK_2(TRACE_TP3780I, "tp3780i::tp3780I_ResetDSP entry pBDData %p\n",
444 pBDData);
446 if (dsp3780I_Reset(pSettings) == 0) {
447 EnableSRAM(pBDData);
448 } else {
449 retval = -EIO;
452 PRINTK_2(TRACE_TP3780I, "tp3780i::tp3780I_ResetDSP exit retval %x\n", retval);
454 return retval;
458 int tp3780I_StartDSP(THINKPAD_BD_DATA * pBDData)
460 int retval = 0;
461 DSP_3780I_CONFIG_SETTINGS *pSettings = &pBDData->rDspSettings;
463 PRINTK_2(TRACE_TP3780I, "tp3780i::tp3780I_StartDSP entry pBDData %p\n", pBDData);
465 if (dsp3780I_Run(pSettings) == 0) {
466 // @BUG @TBD EnableSRAM(pBDData);
467 } else {
468 retval = -EIO;
471 PRINTK_2(TRACE_TP3780I, "tp3780i::tp3780I_StartDSP exit retval %x\n", retval);
473 return retval;
477 int tp3780I_QueryAbilities(THINKPAD_BD_DATA * pBDData, MW_ABILITIES * pAbilities)
479 int retval = 0;
481 PRINTK_2(TRACE_TP3780I,
482 "tp3780i::tp3780I_QueryAbilities entry pBDData %p\n", pBDData);
484 /* fill out standard constant fields */
485 pAbilities->instr_per_sec = pBDData->rDspSettings.uIps;
486 pAbilities->data_size = pBDData->rDspSettings.uDStoreSize;
487 pAbilities->inst_size = pBDData->rDspSettings.uIStoreSize;
488 pAbilities->bus_dma_bw = pBDData->rDspSettings.uDmaBandwidth;
490 /* fill out dynamically determined fields */
491 pAbilities->component_list[0] = 0x00010000 | MW_ADC_MASK;
492 pAbilities->component_list[1] = 0x00010000 | MW_ACI_MASK;
493 pAbilities->component_list[2] = 0x00010000 | MW_AIC1_MASK;
494 pAbilities->component_list[3] = 0x00010000 | MW_AIC2_MASK;
495 pAbilities->component_list[4] = 0x00010000 | MW_CDDAC_MASK;
496 pAbilities->component_list[5] = 0x00010000 | MW_MIDI_MASK;
497 pAbilities->component_list[6] = 0x00010000 | MW_UART_MASK;
498 pAbilities->component_count = 7;
500 /* Fill out Mwave OS and BIOS task names */
502 memcpy(pAbilities->mwave_os_name, TP_ABILITIES_MWAVEOS_NAME,
503 sizeof(TP_ABILITIES_MWAVEOS_NAME));
504 memcpy(pAbilities->bios_task_name, TP_ABILITIES_BIOSTASK_NAME,
505 sizeof(TP_ABILITIES_BIOSTASK_NAME));
507 PRINTK_1(TRACE_TP3780I,
508 "tp3780i::tp3780I_QueryAbilities exit retval=SUCCESSFUL\n");
510 return retval;
513 int tp3780I_ReadWriteDspDStore(THINKPAD_BD_DATA * pBDData, unsigned int uOpcode,
514 void __user *pvBuffer, unsigned int uCount,
515 unsigned long ulDSPAddr)
517 int retval = 0;
518 DSP_3780I_CONFIG_SETTINGS *pSettings = &pBDData->rDspSettings;
519 unsigned short usDspBaseIO = pSettings->usDspBaseIO;
520 BOOLEAN bRC = 0;
522 PRINTK_6(TRACE_TP3780I,
523 "tp3780i::tp3780I_ReadWriteDspDStore entry pBDData %p, uOpcode %x, pvBuffer %p, uCount %x, ulDSPAddr %lx\n",
524 pBDData, uOpcode, pvBuffer, uCount, ulDSPAddr);
526 if (pBDData->bDSPEnabled) {
527 switch (uOpcode) {
528 case IOCTL_MW_READ_DATA:
529 bRC = dsp3780I_ReadDStore(usDspBaseIO, pvBuffer, uCount, ulDSPAddr);
530 break;
532 case IOCTL_MW_READCLEAR_DATA:
533 bRC = dsp3780I_ReadAndClearDStore(usDspBaseIO, pvBuffer, uCount, ulDSPAddr);
534 break;
536 case IOCTL_MW_WRITE_DATA:
537 bRC = dsp3780I_WriteDStore(usDspBaseIO, pvBuffer, uCount, ulDSPAddr);
538 break;
542 retval = (bRC) ? -EIO : 0;
543 PRINTK_2(TRACE_TP3780I, "tp3780i::tp3780I_ReadWriteDspDStore exit retval %x\n", retval);
545 return retval;
549 int tp3780I_ReadWriteDspIStore(THINKPAD_BD_DATA * pBDData, unsigned int uOpcode,
550 void __user *pvBuffer, unsigned int uCount,
551 unsigned long ulDSPAddr)
553 int retval = 0;
554 DSP_3780I_CONFIG_SETTINGS *pSettings = &pBDData->rDspSettings;
555 unsigned short usDspBaseIO = pSettings->usDspBaseIO;
556 BOOLEAN bRC = 0;
558 PRINTK_6(TRACE_TP3780I,
559 "tp3780i::tp3780I_ReadWriteDspIStore entry pBDData %p, uOpcode %x, pvBuffer %p, uCount %x, ulDSPAddr %lx\n",
560 pBDData, uOpcode, pvBuffer, uCount, ulDSPAddr);
562 if (pBDData->bDSPEnabled) {
563 switch (uOpcode) {
564 case IOCTL_MW_READ_INST:
565 bRC = dsp3780I_ReadIStore(usDspBaseIO, pvBuffer, uCount, ulDSPAddr);
566 break;
568 case IOCTL_MW_WRITE_INST:
569 bRC = dsp3780I_WriteIStore(usDspBaseIO, pvBuffer, uCount, ulDSPAddr);
570 break;
574 retval = (bRC) ? -EIO : 0;
576 PRINTK_2(TRACE_TP3780I,
577 "tp3780i::tp3780I_ReadWriteDspIStore exit retval %x\n", retval);
579 return retval;