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