blob: c68969708068a0f8472b611af2bddb38a3411632 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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
Linus Torvalds1da177e2005-04-16 15:20:36 -070049#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
Linus Torvalds1da177e2005-04-16 15:20:36 -070060static unsigned short s_ausThinkpadIrqToField[16] =
61 { 0xFFFF, 0xFFFF, 0xFFFF, 0x0001, 0x0002, 0x0003, 0xFFFF, 0x0004,
62 0xFFFF, 0xFFFF, 0x0005, 0x0006, 0xFFFF, 0xFFFF, 0xFFFF, 0x0007 };
63static unsigned short s_ausThinkpadDmaToField[8] =
64 { 0x0001, 0x0002, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x0003, 0x0004 };
65static unsigned short s_numIrqs = 16, s_numDmas = 8;
66
67
68static void EnableSRAM(THINKPAD_BD_DATA * pBDData)
69{
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;
75
76 PRINTK_1(TRACE_TP3780I, "tp3780i::EnableSRAM, entry\n");
77
78 MKWORD(rGpioMode) = ReadMsaCfg(DSP_GpioModeControl_15_8);
79 rGpioMode.GpioMode10 = 0;
80 WriteMsaCfg(DSP_GpioModeControl_15_8, MKWORD(rGpioMode));
81
82 MKWORD(rGpioDriverEnable) = 0;
83 rGpioDriverEnable.Enable10 = TRUE;
84 rGpioDriverEnable.Mask10 = TRUE;
85 WriteMsaCfg(DSP_GpioDriverEnable_15_8, MKWORD(rGpioDriverEnable));
86
87 MKWORD(rGpioOutputData) = 0;
88 rGpioOutputData.Latch10 = 0;
89 rGpioOutputData.Mask10 = TRUE;
90 WriteMsaCfg(DSP_GpioOutputData_15_8, MKWORD(rGpioOutputData));
91
92 PRINTK_1(TRACE_TP3780I, "tp3780i::EnableSRAM exit\n");
93}
94
95
David Howells7d12e782006-10-05 14:55:46 +010096static irqreturn_t UartInterrupt(int irq, void *dev_id)
Linus Torvalds1da177e2005-04-16 15:20:36 -070097{
98 PRINTK_3(TRACE_TP3780I,
Jeff Garzik0d626232008-04-24 08:35:37 -040099 "tp3780i::UartInterrupt entry irq %x dev_id %p\n", irq, dev_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100 return IRQ_HANDLED;
101}
102
David Howells7d12e782006-10-05 14:55:46 +0100103static irqreturn_t DspInterrupt(int irq, void *dev_id)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104{
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;
109
110 PRINTK_3(TRACE_TP3780I,
Jeff Garzik0d626232008-04-24 08:35:37 -0400111 "tp3780i::DspInterrupt entry irq %x dev_id %p\n", irq, dev_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112
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;
126 }
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);
139 }
140 }
141 if (usIPCSource == 0)
142 break;
143 /* try next IPC */
144 usIsolationMask = usIsolationMask << 1;
145 }
146 } else {
147 PRINTK_1(TRACE_TP3780I,
148 "tp3780i::DspInterrupt, return false from dsp3780i_GetIPCSource\n");
149 }
150 PRINTK_1(TRACE_TP3780I, "tp3780i::DspInterrupt exit\n");
151 return IRQ_HANDLED;
152}
153
154
155int tp3780I_InitializeBoardData(THINKPAD_BD_DATA * pBDData)
156{
157 int retval = 0;
158 DSP_3780I_CONFIG_SETTINGS *pSettings = &pBDData->rDspSettings;
159
160
161 PRINTK_2(TRACE_TP3780I, "tp3780i::tp3780I_InitializeBoardData entry pBDData %p\n", pBDData);
162
163 pBDData->bDSPEnabled = FALSE;
164 pSettings->bInterruptClaimed = FALSE;
165
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();
172 }
173 }
174
175 PRINTK_2(TRACE_TP3780I, "tp3780i::tp3780I_InitializeBoardData exit retval %x\n", retval);
176
177 return retval;
178}
179
180int tp3780I_Cleanup(THINKPAD_BD_DATA * pBDData)
181{
182 int retval = 0;
183
184 PRINTK_2(TRACE_TP3780I,
185 "tp3780i::tp3780I_Cleanup entry and exit pBDData %p\n", pBDData);
186
187 return retval;
188}
189
190int tp3780I_CalcResources(THINKPAD_BD_DATA * pBDData)
191{
192 SMAPI_DSP_SETTINGS rSmapiInfo;
193 DSP_3780I_CONFIG_SETTINGS *pSettings = &pBDData->rDspSettings;
194
195 PRINTK_2(TRACE_TP3780I,
196 "tp3780i::tp3780I_CalcResources entry pBDData %p\n", pBDData);
197
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;
201 }
202
203 /* Sanity check */
204 if (
205 ( rSmapiInfo.usDspIRQ == 0 )
206 || ( rSmapiInfo.usDspBaseIO == 0 )
207 || ( rSmapiInfo.usUartIRQ == 0 )
208 || ( rSmapiInfo.usUartBaseIO == 0 )
209 ) {
210 PRINTK_ERROR(KERN_ERR_MWAVE "tp3780i::tp3780I_CalcResources: Error: Illegal resource setting. Aborting.\n");
211 return -EIO;
212 }
213
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;
221
222 pSettings->uDStoreSize = TP_ABILITIES_DATA_SIZE;
223 pSettings->uIStoreSize = TP_ABILITIES_INST_SIZE;
224 pSettings->uIps = TP_ABILITIES_INTS_PER_SEC;
225
226 if (pSettings->bDSPEnabled && pSettings->bModemEnabled && pSettings->usDspIrq == pSettings->usUartIrq) {
227 pBDData->bShareDspIrq = pBDData->bShareUartIrq = 1;
228 } else {
229 pBDData->bShareDspIrq = pBDData->bShareUartIrq = 0;
230 }
231
232 PRINTK_1(TRACE_TP3780I, "tp3780i::tp3780I_CalcResources exit\n");
233
234 return 0;
235}
236
237
238int tp3780I_ClaimResources(THINKPAD_BD_DATA * pBDData)
239{
240 int retval = 0;
241 DSP_3780I_CONFIG_SETTINGS *pSettings = &pBDData->rDspSettings;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700242 struct resource *pres;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700243
244 PRINTK_2(TRACE_TP3780I,
245 "tp3780i::tp3780I_ClaimResources entry pBDData %p\n", pBDData);
246
Linus Torvalds1da177e2005-04-16 15:20:36 -0700247 pres = request_region(pSettings->usDspBaseIO, 16, "mwave_3780i");
248 if ( pres == NULL ) retval = -EIO;
Adrian Bunkc97f97b2005-06-25 14:58:55 -0700249
Linus Torvalds1da177e2005-04-16 15:20:36 -0700250 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;
253 }
254
255 PRINTK_2(TRACE_TP3780I, "tp3780i::tp3780I_ClaimResources exit retval %x\n", retval);
256
257 return retval;
258}
259
260int tp3780I_ReleaseResources(THINKPAD_BD_DATA * pBDData)
261{
262 int retval = 0;
263 DSP_3780I_CONFIG_SETTINGS *pSettings = &pBDData->rDspSettings;
264
265 PRINTK_2(TRACE_TP3780I,
266 "tp3780i::tp3780I_ReleaseResources entry pBDData %p\n", pBDData);
267
268 release_region(pSettings->usDspBaseIO & (~3), 16);
269
270 if (pSettings->bInterruptClaimed) {
271 free_irq(pSettings->usDspIrq, NULL);
272 pSettings->bInterruptClaimed = FALSE;
273 }
274
275 PRINTK_2(TRACE_TP3780I,
276 "tp3780i::tp3780I_ReleaseResources exit retval %x\n", retval);
277
278 return retval;
279}
280
281
282
283int tp3780I_EnableDSP(THINKPAD_BD_DATA * pBDData)
284{
285 DSP_3780I_CONFIG_SETTINGS *pSettings = &pBDData->rDspSettings;
Adrian Bunke8e1c722005-06-25 14:59:09 -0700286 BOOLEAN bDSPPoweredUp = FALSE, bInterruptAllocated = FALSE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700287
288 PRINTK_2(TRACE_TP3780I, "tp3780i::tp3780I_EnableDSP entry pBDData %p\n", pBDData);
289
290 if (pBDData->bDSPEnabled) {
291 PRINTK_ERROR(KERN_ERR_MWAVE "tp3780i::tp3780I_EnableDSP: Error: DSP already enabled!\n");
292 goto exit_cleanup;
293 }
294
295 if (!pSettings->bDSPEnabled) {
296 PRINTK_ERROR(KERN_ERR_MWAVE "tp3780::tp3780I_EnableDSP: Error: pSettings->bDSPEnabled not set\n");
297 goto exit_cleanup;
298 }
299
300 if (
301 (pSettings->usDspIrq >= s_numIrqs)
302 || (pSettings->usDspDma >= s_numDmas)
303 || (s_ausThinkpadIrqToField[pSettings->usDspIrq] == 0xFFFF)
304 || (s_ausThinkpadDmaToField[pSettings->usDspDma] == 0xFFFF)
305 ) {
306 PRINTK_ERROR(KERN_ERR_MWAVE "tp3780i::tp3780I_EnableDSP: Error: invalid irq %x\n", pSettings->usDspIrq);
307 goto exit_cleanup;
308 }
309
310 if (
311 ((pSettings->usDspBaseIO & 0xF00F) != 0)
312 || (pSettings->usDspBaseIO & 0x0FF0) == 0
313 ) {
314 PRINTK_ERROR(KERN_ERR_MWAVE "tp3780i::tp3780I_EnableDSP: Error: Invalid DSP base I/O address %x\n", pSettings->usDspBaseIO);
315 goto exit_cleanup;
316 }
317
318 if (pSettings->bModemEnabled) {
319 if (
320 pSettings->usUartIrq >= s_numIrqs
321 || s_ausThinkpadIrqToField[pSettings->usUartIrq] == 0xFFFF
322 ) {
323 PRINTK_ERROR(KERN_ERR_MWAVE "tp3780i::tp3780I_EnableDSP: Error: Invalid UART IRQ %x\n", pSettings->usUartIrq);
324 goto exit_cleanup;
325 }
326 switch (pSettings->usUartBaseIO) {
327 case 0x03F8:
328 case 0x02F8:
329 case 0x03E8:
330 case 0x02E8:
331 break;
332
333 default:
334 PRINTK_ERROR("tp3780i::tp3780I_EnableDSP: Error: Invalid UART base I/O address %x\n", pSettings->usUartBaseIO);
335 goto exit_cleanup;
336 }
337 }
338
339 pSettings->bDspIrqActiveLow = pSettings->bDspIrqPulse = TRUE;
340 pSettings->bUartIrqActiveLow = pSettings->bUartIrqPulse = TRUE;
341
342 if (pBDData->bShareDspIrq) {
343 pSettings->bDspIrqActiveLow = FALSE;
344 }
345 if (pBDData->bShareUartIrq) {
346 pSettings->bUartIrqActiveLow = FALSE;
347 }
348
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;
361
Jeff Garzik0d626232008-04-24 08:35:37 -0400362 if (request_irq(pSettings->usUartIrq, &UartInterrupt, 0, "mwave_uart", NULL)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700363 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);
367 }
368
Jeff Garzik0d626232008-04-24 08:35:37 -0400369 if (request_irq(pSettings->usDspIrq, &DspInterrupt, 0, "mwave_3780i", NULL)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700370 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;
378 }
379
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;
386 }
387
388 if (dsp3780I_EnableDSP(pSettings, s_ausThinkpadIrqToField, s_ausThinkpadDmaToField)) {
389 PRINTK_ERROR("tp3780i::tp3780I_EnableDSP: Error: dsp7880I_EnableDSP() failed\n");
390 goto exit_cleanup;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700391 }
392
393 EnableSRAM(pBDData);
394
395 pBDData->bDSPEnabled = TRUE;
396
397 PRINTK_1(TRACE_TP3780I, "tp3780i::tp3780I_EnableDSP exit\n");
398
399 return 0;
400
401exit_cleanup:
402 PRINTK_ERROR("tp3780i::tp3780I_EnableDSP: Cleaning up\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700403 if (bDSPPoweredUp)
404 smapi_set_DSP_power_state(FALSE);
405 if (bInterruptAllocated) {
406 free_irq(pSettings->usDspIrq, NULL);
407 pSettings->bInterruptClaimed = FALSE;
408 }
409 return -EIO;
410}
411
412
413int tp3780I_DisableDSP(THINKPAD_BD_DATA * pBDData)
414{
415 int retval = 0;
416 DSP_3780I_CONFIG_SETTINGS *pSettings = &pBDData->rDspSettings;
417
418 PRINTK_2(TRACE_TP3780I, "tp3780i::tp3780I_DisableDSP entry pBDData %p\n", pBDData);
419
420 if (pBDData->bDSPEnabled) {
421 dsp3780I_DisableDSP(&pBDData->rDspSettings);
422 if (pSettings->bInterruptClaimed) {
423 free_irq(pSettings->usDspIrq, NULL);
424 pSettings->bInterruptClaimed = FALSE;
425 }
426 smapi_set_DSP_power_state(FALSE);
427 pBDData->bDSPEnabled = FALSE;
428 }
429
430 PRINTK_2(TRACE_TP3780I, "tp3780i::tp3780I_DisableDSP exit retval %x\n", retval);
431
432 return retval;
433}
434
435
436int tp3780I_ResetDSP(THINKPAD_BD_DATA * pBDData)
437{
438 int retval = 0;
439 DSP_3780I_CONFIG_SETTINGS *pSettings = &pBDData->rDspSettings;
440
441 PRINTK_2(TRACE_TP3780I, "tp3780i::tp3780I_ResetDSP entry pBDData %p\n",
442 pBDData);
443
444 if (dsp3780I_Reset(pSettings) == 0) {
445 EnableSRAM(pBDData);
446 } else {
447 retval = -EIO;
448 }
449
450 PRINTK_2(TRACE_TP3780I, "tp3780i::tp3780I_ResetDSP exit retval %x\n", retval);
451
452 return retval;
453}
454
455
456int tp3780I_StartDSP(THINKPAD_BD_DATA * pBDData)
457{
458 int retval = 0;
459 DSP_3780I_CONFIG_SETTINGS *pSettings = &pBDData->rDspSettings;
460
461 PRINTK_2(TRACE_TP3780I, "tp3780i::tp3780I_StartDSP entry pBDData %p\n", pBDData);
462
463 if (dsp3780I_Run(pSettings) == 0) {
464 // @BUG @TBD EnableSRAM(pBDData);
465 } else {
466 retval = -EIO;
467 }
468
469 PRINTK_2(TRACE_TP3780I, "tp3780i::tp3780I_StartDSP exit retval %x\n", retval);
470
471 return retval;
472}
473
474
475int tp3780I_QueryAbilities(THINKPAD_BD_DATA * pBDData, MW_ABILITIES * pAbilities)
476{
477 int retval = 0;
478
479 PRINTK_2(TRACE_TP3780I,
480 "tp3780i::tp3780I_QueryAbilities entry pBDData %p\n", pBDData);
481
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;
487
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;
497
498 /* Fill out Mwave OS and BIOS task names */
499
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));
504
505 PRINTK_1(TRACE_TP3780I,
506 "tp3780i::tp3780I_QueryAbilities exit retval=SUCCESSFUL\n");
507
508 return retval;
509}
510
511int tp3780I_ReadWriteDspDStore(THINKPAD_BD_DATA * pBDData, unsigned int uOpcode,
512 void __user *pvBuffer, unsigned int uCount,
513 unsigned long ulDSPAddr)
514{
515 int retval = 0;
516 DSP_3780I_CONFIG_SETTINGS *pSettings = &pBDData->rDspSettings;
517 unsigned short usDspBaseIO = pSettings->usDspBaseIO;
518 BOOLEAN bRC = 0;
519
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);
523
524 if (pBDData->bDSPEnabled) {
525 switch (uOpcode) {
526 case IOCTL_MW_READ_DATA:
527 bRC = dsp3780I_ReadDStore(usDspBaseIO, pvBuffer, uCount, ulDSPAddr);
528 break;
529
530 case IOCTL_MW_READCLEAR_DATA:
531 bRC = dsp3780I_ReadAndClearDStore(usDspBaseIO, pvBuffer, uCount, ulDSPAddr);
532 break;
533
534 case IOCTL_MW_WRITE_DATA:
535 bRC = dsp3780I_WriteDStore(usDspBaseIO, pvBuffer, uCount, ulDSPAddr);
536 break;
537 }
538 }
539
540 retval = (bRC) ? -EIO : 0;
541 PRINTK_2(TRACE_TP3780I, "tp3780i::tp3780I_ReadWriteDspDStore exit retval %x\n", retval);
542
543 return retval;
544}
545
546
547int tp3780I_ReadWriteDspIStore(THINKPAD_BD_DATA * pBDData, unsigned int uOpcode,
548 void __user *pvBuffer, unsigned int uCount,
549 unsigned long ulDSPAddr)
550{
551 int retval = 0;
552 DSP_3780I_CONFIG_SETTINGS *pSettings = &pBDData->rDspSettings;
553 unsigned short usDspBaseIO = pSettings->usDspBaseIO;
554 BOOLEAN bRC = 0;
555
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);
559
560 if (pBDData->bDSPEnabled) {
561 switch (uOpcode) {
562 case IOCTL_MW_READ_INST:
563 bRC = dsp3780I_ReadIStore(usDspBaseIO, pvBuffer, uCount, ulDSPAddr);
564 break;
565
566 case IOCTL_MW_WRITE_INST:
567 bRC = dsp3780I_WriteIStore(usDspBaseIO, pvBuffer, uCount, ulDSPAddr);
568 break;
569 }
570 }
571
572 retval = (bRC) ? -EIO : 0;
573
574 PRINTK_2(TRACE_TP3780I,
575 "tp3780i::tp3780I_ReadWriteDspIStore exit retval %x\n", retval);
576
577 return retval;
578}
579