drivers/char: minor irq handler cleanups
[linux-2.6.git] / drivers / char / mwave / tp3780i.c
1 /*
2 *
3 * tp3780i.c -- board driver for 3780i on ThinkPads
4 *
5 *
6 * Written By: Mike Sullivan IBM Corporation
7 *
8 * Copyright (C) 1999 IBM Corporation
9 *
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.
14 *
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.
19 *
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.
30 *
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
39 *
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
43 *
44 *
45 * 10/23/2000 - Alpha Release
46 *       First release to the public
47 */
48
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"
59
60 extern MWAVE_DEVICE_DATA mwave_s_mdd;
61
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;
68
69
70 static void EnableSRAM(THINKPAD_BD_DATA * pBDData)
71 {
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;
77
78         PRINTK_1(TRACE_TP3780I, "tp3780i::EnableSRAM, entry\n");
79
80         MKWORD(rGpioMode) = ReadMsaCfg(DSP_GpioModeControl_15_8);
81         rGpioMode.GpioMode10 = 0;
82         WriteMsaCfg(DSP_GpioModeControl_15_8, MKWORD(rGpioMode));
83
84         MKWORD(rGpioDriverEnable) = 0;
85         rGpioDriverEnable.Enable10 = TRUE;
86         rGpioDriverEnable.Mask10 = TRUE;
87         WriteMsaCfg(DSP_GpioDriverEnable_15_8, MKWORD(rGpioDriverEnable));
88
89         MKWORD(rGpioOutputData) = 0;
90         rGpioOutputData.Latch10 = 0;
91         rGpioOutputData.Mask10 = TRUE;
92         WriteMsaCfg(DSP_GpioOutputData_15_8, MKWORD(rGpioOutputData));
93
94         PRINTK_1(TRACE_TP3780I, "tp3780i::EnableSRAM exit\n");
95 }
96
97
98 static irqreturn_t UartInterrupt(int irq, void *dev_id)
99 {
100         int irqno = (int)(unsigned long) dev_id;
101
102         PRINTK_3(TRACE_TP3780I,
103                 "tp3780i::UartInterrupt entry irq %x dev_id %p\n", irqno, dev_id);
104         return IRQ_HANDLED;
105 }
106
107 static irqreturn_t DspInterrupt(int irq, void *dev_id)
108 {
109         int irqno = (int)(unsigned long) dev_id;
110
111         pMWAVE_DEVICE_DATA pDrvData = &mwave_s_mdd;
112         DSP_3780I_CONFIG_SETTINGS *pSettings = &pDrvData->rBDData.rDspSettings;
113         unsigned short usDspBaseIO = pSettings->usDspBaseIO;
114         unsigned short usIPCSource = 0, usIsolationMask, usPCNum;
115
116         PRINTK_3(TRACE_TP3780I,
117                 "tp3780i::DspInterrupt entry irq %x dev_id %p\n", irqno, dev_id);
118
119         if (dsp3780I_GetIPCSource(usDspBaseIO, &usIPCSource) == 0) {
120                 PRINTK_2(TRACE_TP3780I,
121                         "tp3780i::DspInterrupt, return from dsp3780i_GetIPCSource, usIPCSource %x\n",
122                         usIPCSource);
123                 usIsolationMask = 1;
124                 for (usPCNum = 1; usPCNum <= 16; usPCNum++) {
125                         if (usIPCSource & usIsolationMask) {
126                                 usIPCSource &= ~usIsolationMask;
127                                 PRINTK_3(TRACE_TP3780I,
128                                         "tp3780i::DspInterrupt usPCNum %x usIPCSource %x\n",
129                                         usPCNum, usIPCSource);
130                                 if (pDrvData->IPCs[usPCNum - 1].usIntCount == 0) {
131                                         pDrvData->IPCs[usPCNum - 1].usIntCount = 1;
132                                 }
133                                 PRINTK_2(TRACE_TP3780I,
134                                         "tp3780i::DspInterrupt usIntCount %x\n",
135                                         pDrvData->IPCs[usPCNum - 1].usIntCount);
136                                 if (pDrvData->IPCs[usPCNum - 1].bIsEnabled == TRUE) {
137                                         PRINTK_2(TRACE_TP3780I,
138                                                 "tp3780i::DspInterrupt, waking up usPCNum %x\n",
139                                                 usPCNum - 1);
140                                         wake_up_interruptible(&pDrvData->IPCs[usPCNum - 1].ipc_wait_queue);
141                                 } else {
142                                         PRINTK_2(TRACE_TP3780I,
143                                                 "tp3780i::DspInterrupt, no one waiting for IPC %x\n",
144                                                 usPCNum - 1);
145                                 }
146                         }
147                         if (usIPCSource == 0)
148                                 break;
149                         /* try next IPC */
150                         usIsolationMask = usIsolationMask << 1;
151                 }
152         } else {
153                 PRINTK_1(TRACE_TP3780I,
154                         "tp3780i::DspInterrupt, return false from dsp3780i_GetIPCSource\n");
155         }
156         PRINTK_1(TRACE_TP3780I, "tp3780i::DspInterrupt exit\n");
157         return IRQ_HANDLED;
158 }
159
160
161 int tp3780I_InitializeBoardData(THINKPAD_BD_DATA * pBDData)
162 {
163         int retval = 0;
164         DSP_3780I_CONFIG_SETTINGS *pSettings = &pBDData->rDspSettings;
165
166
167         PRINTK_2(TRACE_TP3780I, "tp3780i::tp3780I_InitializeBoardData entry pBDData %p\n", pBDData);
168
169         pBDData->bDSPEnabled = FALSE;
170         pSettings->bInterruptClaimed = FALSE;
171
172         retval = smapi_init();
173         if (retval) {
174                 PRINTK_ERROR(KERN_ERR_MWAVE "tp3780i::tp3780I_InitializeBoardData: Error: SMAPI is not available on this machine\n");
175         } else {
176                 if (mwave_3780i_irq || mwave_3780i_io || mwave_uart_irq || mwave_uart_io) {
177                         retval = smapi_set_DSP_cfg();
178                 }
179         }
180
181         PRINTK_2(TRACE_TP3780I, "tp3780i::tp3780I_InitializeBoardData exit retval %x\n", retval);
182
183         return retval;
184 }
185
186 int tp3780I_Cleanup(THINKPAD_BD_DATA * pBDData)
187 {
188         int retval = 0;
189
190         PRINTK_2(TRACE_TP3780I,
191                 "tp3780i::tp3780I_Cleanup entry and exit pBDData %p\n", pBDData);
192
193         return retval;
194 }
195
196 int tp3780I_CalcResources(THINKPAD_BD_DATA * pBDData)
197 {
198         SMAPI_DSP_SETTINGS rSmapiInfo;
199         DSP_3780I_CONFIG_SETTINGS *pSettings = &pBDData->rDspSettings;
200
201         PRINTK_2(TRACE_TP3780I,
202                 "tp3780i::tp3780I_CalcResources entry pBDData %p\n", pBDData);
203
204         if (smapi_query_DSP_cfg(&rSmapiInfo)) {
205                 PRINTK_ERROR(KERN_ERR_MWAVE "tp3780i::tp3780I_CalcResources: Error: Could not query DSP config. Aborting.\n");
206                 return -EIO;
207         }
208
209         /* Sanity check */
210         if (
211                 ( rSmapiInfo.usDspIRQ == 0 )
212                 || ( rSmapiInfo.usDspBaseIO ==  0 )
213                 || ( rSmapiInfo.usUartIRQ ==  0 )
214                 || ( rSmapiInfo.usUartBaseIO ==  0 )
215         ) {
216                 PRINTK_ERROR(KERN_ERR_MWAVE "tp3780i::tp3780I_CalcResources: Error: Illegal resource setting. Aborting.\n");
217                 return -EIO;
218         }
219
220         pSettings->bDSPEnabled = (rSmapiInfo.bDSPEnabled && rSmapiInfo.bDSPPresent);
221         pSettings->bModemEnabled = rSmapiInfo.bModemEnabled;
222         pSettings->usDspIrq = rSmapiInfo.usDspIRQ;
223         pSettings->usDspDma = rSmapiInfo.usDspDMA;
224         pSettings->usDspBaseIO = rSmapiInfo.usDspBaseIO;
225         pSettings->usUartIrq = rSmapiInfo.usUartIRQ;
226         pSettings->usUartBaseIO = rSmapiInfo.usUartBaseIO;
227
228         pSettings->uDStoreSize = TP_ABILITIES_DATA_SIZE;
229         pSettings->uIStoreSize = TP_ABILITIES_INST_SIZE;
230         pSettings->uIps = TP_ABILITIES_INTS_PER_SEC;
231
232         if (pSettings->bDSPEnabled && pSettings->bModemEnabled && pSettings->usDspIrq == pSettings->usUartIrq) {
233                 pBDData->bShareDspIrq = pBDData->bShareUartIrq = 1;
234         } else {
235                 pBDData->bShareDspIrq = pBDData->bShareUartIrq = 0;
236         }
237
238         PRINTK_1(TRACE_TP3780I, "tp3780i::tp3780I_CalcResources exit\n");
239
240         return 0;
241 }
242
243
244 int tp3780I_ClaimResources(THINKPAD_BD_DATA * pBDData)
245 {
246         int retval = 0;
247         DSP_3780I_CONFIG_SETTINGS *pSettings = &pBDData->rDspSettings;
248         struct resource *pres;
249
250         PRINTK_2(TRACE_TP3780I,
251                 "tp3780i::tp3780I_ClaimResources entry pBDData %p\n", pBDData);
252
253         pres = request_region(pSettings->usDspBaseIO, 16, "mwave_3780i");
254         if ( pres == NULL ) retval = -EIO;
255
256         if (retval) {
257                 PRINTK_ERROR(KERN_ERR_MWAVE "tp3780i::tp3780I_ClaimResources: Error: Could not claim I/O region starting at %x\n", pSettings->usDspBaseIO);
258                 retval = -EIO;
259         }
260
261         PRINTK_2(TRACE_TP3780I, "tp3780i::tp3780I_ClaimResources exit retval %x\n", retval);
262
263         return retval;
264 }
265
266 int tp3780I_ReleaseResources(THINKPAD_BD_DATA * pBDData)
267 {
268         int retval = 0;
269         DSP_3780I_CONFIG_SETTINGS *pSettings = &pBDData->rDspSettings;
270
271         PRINTK_2(TRACE_TP3780I,
272                 "tp3780i::tp3780I_ReleaseResources entry pBDData %p\n", pBDData);
273
274         release_region(pSettings->usDspBaseIO & (~3), 16);
275
276         if (pSettings->bInterruptClaimed) {
277                 free_irq(pSettings->usDspIrq, NULL);
278                 pSettings->bInterruptClaimed = FALSE;
279         }
280
281         PRINTK_2(TRACE_TP3780I,
282                 "tp3780i::tp3780I_ReleaseResources exit retval %x\n", retval);
283
284         return retval;
285 }
286
287
288
289 int tp3780I_EnableDSP(THINKPAD_BD_DATA * pBDData)
290 {
291         DSP_3780I_CONFIG_SETTINGS *pSettings = &pBDData->rDspSettings;
292         BOOLEAN bDSPPoweredUp = FALSE, bInterruptAllocated = FALSE;
293
294         PRINTK_2(TRACE_TP3780I, "tp3780i::tp3780I_EnableDSP entry pBDData %p\n", pBDData);
295
296         if (pBDData->bDSPEnabled) {
297                 PRINTK_ERROR(KERN_ERR_MWAVE "tp3780i::tp3780I_EnableDSP: Error: DSP already enabled!\n");
298                 goto exit_cleanup;
299         }
300
301         if (!pSettings->bDSPEnabled) {
302                 PRINTK_ERROR(KERN_ERR_MWAVE "tp3780::tp3780I_EnableDSP: Error: pSettings->bDSPEnabled not set\n");
303                 goto exit_cleanup;
304         }
305
306         if (
307                 (pSettings->usDspIrq >= s_numIrqs)
308                 || (pSettings->usDspDma >= s_numDmas)
309                 || (s_ausThinkpadIrqToField[pSettings->usDspIrq] == 0xFFFF)
310                 || (s_ausThinkpadDmaToField[pSettings->usDspDma] == 0xFFFF)
311         ) {
312                 PRINTK_ERROR(KERN_ERR_MWAVE "tp3780i::tp3780I_EnableDSP: Error: invalid irq %x\n", pSettings->usDspIrq);
313                 goto exit_cleanup;
314         }
315
316         if (
317                 ((pSettings->usDspBaseIO & 0xF00F) != 0)
318                 || (pSettings->usDspBaseIO & 0x0FF0) == 0
319         ) {
320                 PRINTK_ERROR(KERN_ERR_MWAVE "tp3780i::tp3780I_EnableDSP: Error: Invalid DSP base I/O address %x\n", pSettings->usDspBaseIO);
321                 goto exit_cleanup;
322         }
323
324         if (pSettings->bModemEnabled) {
325                 if (
326                         pSettings->usUartIrq >= s_numIrqs
327                         || s_ausThinkpadIrqToField[pSettings->usUartIrq] == 0xFFFF
328                 ) {
329                         PRINTK_ERROR(KERN_ERR_MWAVE "tp3780i::tp3780I_EnableDSP: Error: Invalid UART IRQ %x\n", pSettings->usUartIrq);
330                         goto exit_cleanup;
331                 }
332                 switch (pSettings->usUartBaseIO) {
333                         case 0x03F8:
334                         case 0x02F8:
335                         case 0x03E8:
336                         case 0x02E8:
337                                 break;
338
339                         default:
340                                 PRINTK_ERROR("tp3780i::tp3780I_EnableDSP: Error: Invalid UART base I/O address %x\n", pSettings->usUartBaseIO);
341                                 goto exit_cleanup;
342                 }
343         }
344
345         pSettings->bDspIrqActiveLow = pSettings->bDspIrqPulse = TRUE;
346         pSettings->bUartIrqActiveLow = pSettings->bUartIrqPulse = TRUE;
347
348         if (pBDData->bShareDspIrq) {
349                 pSettings->bDspIrqActiveLow = FALSE;
350         }
351         if (pBDData->bShareUartIrq) {
352                 pSettings->bUartIrqActiveLow = FALSE;
353         }
354
355         pSettings->usNumTransfers = TP_CFG_NumTransfers;
356         pSettings->usReRequest = TP_CFG_RerequestTimer;
357         pSettings->bEnableMEMCS16 = TP_CFG_MEMCS16;
358         pSettings->usIsaMemCmdWidth = TP_CFG_IsaMemCmdWidth;
359         pSettings->bGateIOCHRDY = TP_CFG_GateIOCHRDY;
360         pSettings->bEnablePwrMgmt = TP_CFG_EnablePwrMgmt;
361         pSettings->usHBusTimerLoadValue = TP_CFG_HBusTimerValue;
362         pSettings->bDisableLBusTimeout = TP_CFG_DisableLBusTimeout;
363         pSettings->usN_Divisor = TP_CFG_N_Divisor;
364         pSettings->usM_Multiplier = TP_CFG_M_Multiplier;
365         pSettings->bPllBypass = TP_CFG_PllBypass;
366         pSettings->usChipletEnable = TP_CFG_ChipletEnable;
367
368         if (request_irq(pSettings->usUartIrq, &UartInterrupt, 0, "mwave_uart",
369                         (void *)(unsigned long) pSettings->usUartIrq)) {
370                 PRINTK_ERROR(KERN_ERR_MWAVE "tp3780i::tp3780I_EnableDSP: Error: Could not get UART IRQ %x\n", pSettings->usUartIrq);
371                 goto exit_cleanup;
372         } else {                /* no conflict just release */
373                 free_irq(pSettings->usUartIrq, NULL);
374         }
375
376         if (request_irq(pSettings->usDspIrq, &DspInterrupt, 0, "mwave_3780i",
377                         (void *)(unsigned long) pSettings->usDspIrq)) {
378                 PRINTK_ERROR("tp3780i::tp3780I_EnableDSP: Error: Could not get 3780i IRQ %x\n", pSettings->usDspIrq);
379                 goto exit_cleanup;
380         } else {
381                 PRINTK_3(TRACE_TP3780I,
382                         "tp3780i::tp3780I_EnableDSP, got interrupt %x bShareDspIrq %x\n",
383                         pSettings->usDspIrq, pBDData->bShareDspIrq);
384                 bInterruptAllocated = TRUE;
385                 pSettings->bInterruptClaimed = TRUE;
386         }
387
388         smapi_set_DSP_power_state(FALSE);
389         if (smapi_set_DSP_power_state(TRUE)) {
390                 PRINTK_ERROR(KERN_ERR_MWAVE "tp3780i::tp3780I_EnableDSP: Error: smapi_set_DSP_power_state(TRUE) failed\n");
391                 goto exit_cleanup;
392         } else {
393                 bDSPPoweredUp = TRUE;
394         }
395
396         if (dsp3780I_EnableDSP(pSettings, s_ausThinkpadIrqToField, s_ausThinkpadDmaToField)) {
397                 PRINTK_ERROR("tp3780i::tp3780I_EnableDSP: Error: dsp7880I_EnableDSP() failed\n");
398                 goto exit_cleanup;
399         }
400
401         EnableSRAM(pBDData);
402
403         pBDData->bDSPEnabled = TRUE;
404
405         PRINTK_1(TRACE_TP3780I, "tp3780i::tp3780I_EnableDSP exit\n");
406
407         return 0;
408
409 exit_cleanup:
410         PRINTK_ERROR("tp3780i::tp3780I_EnableDSP: Cleaning up\n");
411         if (bDSPPoweredUp)
412                 smapi_set_DSP_power_state(FALSE);
413         if (bInterruptAllocated) {
414                 free_irq(pSettings->usDspIrq, NULL);
415                 pSettings->bInterruptClaimed = FALSE;
416         }
417         return -EIO;
418 }
419
420
421 int tp3780I_DisableDSP(THINKPAD_BD_DATA * pBDData)
422 {
423         int retval = 0;
424         DSP_3780I_CONFIG_SETTINGS *pSettings = &pBDData->rDspSettings;
425
426         PRINTK_2(TRACE_TP3780I, "tp3780i::tp3780I_DisableDSP entry pBDData %p\n", pBDData);
427
428         if (pBDData->bDSPEnabled) {
429                 dsp3780I_DisableDSP(&pBDData->rDspSettings);
430                 if (pSettings->bInterruptClaimed) {
431                         free_irq(pSettings->usDspIrq, NULL);
432                         pSettings->bInterruptClaimed = FALSE;
433                 }
434                 smapi_set_DSP_power_state(FALSE);
435                 pBDData->bDSPEnabled = FALSE;
436         }
437
438         PRINTK_2(TRACE_TP3780I, "tp3780i::tp3780I_DisableDSP exit retval %x\n", retval);
439
440         return retval;
441 }
442
443
444 int tp3780I_ResetDSP(THINKPAD_BD_DATA * pBDData)
445 {
446         int retval = 0;
447         DSP_3780I_CONFIG_SETTINGS *pSettings = &pBDData->rDspSettings;
448
449         PRINTK_2(TRACE_TP3780I, "tp3780i::tp3780I_ResetDSP entry pBDData %p\n",
450                 pBDData);
451
452         if (dsp3780I_Reset(pSettings) == 0) {
453                 EnableSRAM(pBDData);
454         } else {
455                 retval = -EIO;
456         }
457
458         PRINTK_2(TRACE_TP3780I, "tp3780i::tp3780I_ResetDSP exit retval %x\n", retval);
459
460         return retval;
461 }
462
463
464 int tp3780I_StartDSP(THINKPAD_BD_DATA * pBDData)
465 {
466         int retval = 0;
467         DSP_3780I_CONFIG_SETTINGS *pSettings = &pBDData->rDspSettings;
468
469         PRINTK_2(TRACE_TP3780I, "tp3780i::tp3780I_StartDSP entry pBDData %p\n", pBDData);
470
471         if (dsp3780I_Run(pSettings) == 0) {
472                 // @BUG @TBD EnableSRAM(pBDData);
473         } else {
474                 retval = -EIO;
475         }
476
477         PRINTK_2(TRACE_TP3780I, "tp3780i::tp3780I_StartDSP exit retval %x\n", retval);
478
479         return retval;
480 }
481
482
483 int tp3780I_QueryAbilities(THINKPAD_BD_DATA * pBDData, MW_ABILITIES * pAbilities)
484 {
485         int retval = 0;
486
487         PRINTK_2(TRACE_TP3780I,
488                 "tp3780i::tp3780I_QueryAbilities entry pBDData %p\n", pBDData);
489
490         /* fill out standard constant fields */
491         pAbilities->instr_per_sec = pBDData->rDspSettings.uIps;
492         pAbilities->data_size = pBDData->rDspSettings.uDStoreSize;
493         pAbilities->inst_size = pBDData->rDspSettings.uIStoreSize;
494         pAbilities->bus_dma_bw = pBDData->rDspSettings.uDmaBandwidth;
495
496         /* fill out dynamically determined fields */
497         pAbilities->component_list[0] = 0x00010000 | MW_ADC_MASK;
498         pAbilities->component_list[1] = 0x00010000 | MW_ACI_MASK;
499         pAbilities->component_list[2] = 0x00010000 | MW_AIC1_MASK;
500         pAbilities->component_list[3] = 0x00010000 | MW_AIC2_MASK;
501         pAbilities->component_list[4] = 0x00010000 | MW_CDDAC_MASK;
502         pAbilities->component_list[5] = 0x00010000 | MW_MIDI_MASK;
503         pAbilities->component_list[6] = 0x00010000 | MW_UART_MASK;
504         pAbilities->component_count = 7;
505
506         /* Fill out Mwave OS and BIOS task names */
507
508         memcpy(pAbilities->mwave_os_name, TP_ABILITIES_MWAVEOS_NAME,
509                 sizeof(TP_ABILITIES_MWAVEOS_NAME));
510         memcpy(pAbilities->bios_task_name, TP_ABILITIES_BIOSTASK_NAME,
511                 sizeof(TP_ABILITIES_BIOSTASK_NAME));
512
513         PRINTK_1(TRACE_TP3780I,
514                 "tp3780i::tp3780I_QueryAbilities exit retval=SUCCESSFUL\n");
515
516         return retval;
517 }
518
519 int tp3780I_ReadWriteDspDStore(THINKPAD_BD_DATA * pBDData, unsigned int uOpcode,
520                                void __user *pvBuffer, unsigned int uCount,
521                                unsigned long ulDSPAddr)
522 {
523         int retval = 0;
524         DSP_3780I_CONFIG_SETTINGS *pSettings = &pBDData->rDspSettings;
525         unsigned short usDspBaseIO = pSettings->usDspBaseIO;
526         BOOLEAN bRC = 0;
527
528         PRINTK_6(TRACE_TP3780I,
529                 "tp3780i::tp3780I_ReadWriteDspDStore entry pBDData %p, uOpcode %x, pvBuffer %p, uCount %x, ulDSPAddr %lx\n",
530                 pBDData, uOpcode, pvBuffer, uCount, ulDSPAddr);
531
532         if (pBDData->bDSPEnabled) {
533                 switch (uOpcode) {
534                 case IOCTL_MW_READ_DATA:
535                         bRC = dsp3780I_ReadDStore(usDspBaseIO, pvBuffer, uCount, ulDSPAddr);
536                         break;
537
538                 case IOCTL_MW_READCLEAR_DATA:
539                         bRC = dsp3780I_ReadAndClearDStore(usDspBaseIO, pvBuffer, uCount, ulDSPAddr);
540                         break;
541
542                 case IOCTL_MW_WRITE_DATA:
543                         bRC = dsp3780I_WriteDStore(usDspBaseIO, pvBuffer, uCount, ulDSPAddr);
544                         break;
545                 }
546         }
547
548         retval = (bRC) ? -EIO : 0;
549         PRINTK_2(TRACE_TP3780I, "tp3780i::tp3780I_ReadWriteDspDStore exit retval %x\n", retval);
550
551         return retval;
552 }
553
554
555 int tp3780I_ReadWriteDspIStore(THINKPAD_BD_DATA * pBDData, unsigned int uOpcode,
556                                void __user *pvBuffer, unsigned int uCount,
557                                unsigned long ulDSPAddr)
558 {
559         int retval = 0;
560         DSP_3780I_CONFIG_SETTINGS *pSettings = &pBDData->rDspSettings;
561         unsigned short usDspBaseIO = pSettings->usDspBaseIO;
562         BOOLEAN bRC = 0;
563
564         PRINTK_6(TRACE_TP3780I,
565                 "tp3780i::tp3780I_ReadWriteDspIStore entry pBDData %p, uOpcode %x, pvBuffer %p, uCount %x, ulDSPAddr %lx\n",
566                 pBDData, uOpcode, pvBuffer, uCount, ulDSPAddr);
567
568         if (pBDData->bDSPEnabled) {
569                 switch (uOpcode) {
570                 case IOCTL_MW_READ_INST:
571                         bRC = dsp3780I_ReadIStore(usDspBaseIO, pvBuffer, uCount, ulDSPAddr);
572                         break;
573
574                 case IOCTL_MW_WRITE_INST:
575                         bRC = dsp3780I_WriteIStore(usDspBaseIO, pvBuffer, uCount, ulDSPAddr);
576                         break;
577                 }
578         }
579
580         retval = (bRC) ? -EIO : 0;
581
582         PRINTK_2(TRACE_TP3780I,
583                 "tp3780i::tp3780I_ReadWriteDspIStore exit retval %x\n", retval);
584
585         return retval;
586 }
587