49 #include <linux/kernel.h>
54 static unsigned short g_usSmapiPort = 0;
57 static int smapi_request(
unsigned short inBX,
unsigned short inCX,
58 unsigned short inDI,
unsigned short inSI,
59 unsigned short *outAX,
unsigned short *outBX,
60 unsigned short *outCX,
unsigned short *outDX,
61 unsigned short *outDI,
unsigned short *outSI)
63 unsigned short myoutAX = 2, *pmyoutAX = &myoutAX;
64 unsigned short myoutBX = 3, *pmyoutBX = &myoutBX;
65 unsigned short myoutCX = 4, *pmyoutCX = &myoutCX;
66 unsigned short myoutDX = 5, *pmyoutDX = &myoutDX;
67 unsigned short myoutDI = 6, *pmyoutDI = &myoutDI;
68 unsigned short myoutSI = 7, *pmyoutSI = &myoutSI;
69 unsigned short usSmapiOK = -
EIO, *pusSmapiOK = &usSmapiOK;
70 unsigned int inBXCX = (inBX << 16) | inCX;
71 unsigned int inDISI = (inDI << 16) | inSI;
75 inBX, inCX, inDI, inSI);
77 __asm__ __volatile__(
"movw $0x5380,%%ax\n\t"
99 "2:\n\t":
"=m"(*(
unsigned short *) pmyoutAX),
100 "=m"(*(
unsigned short *) pmyoutBX),
101 "=m"(*(
unsigned short *) pmyoutCX),
102 "=m"(*(
unsigned short *) pmyoutDX),
103 "=m"(*(
unsigned short *) pmyoutDI),
104 "=m"(*(
unsigned short *) pmyoutSI),
105 "=m"(*(
unsigned short *) pusSmapiOK)
106 :
"m"(inBXCX),
"m"(inDISI),
"m"(g_usSmapiPort)
107 :
"%eax",
"%ebx",
"%ecx",
"%edx",
"%edi",
111 "myoutAX %x myoutBX %x myoutCX %x myoutDX %x myoutDI %x myoutSI %x usSmapiOK %x\n",
112 myoutAX, myoutBX, myoutCX, myoutDX, myoutDI, myoutSI,
121 retval = (usSmapiOK == 1) ? 0 : -
EIO;
130 unsigned short usAX, usBX, usCX, usDX, usDI, usSI;
131 unsigned short ausDspBases[] = { 0x0030, 0x4E30, 0x8E30, 0xCE30, 0x0130, 0x0350, 0x0070, 0x0DB0 };
132 unsigned short ausUartBases[] = { 0x03F8, 0x02F8, 0x03E8, 0x02E8 };
133 unsigned short numDspBases = 8;
134 unsigned short numUartBases = 4;
138 bRC = smapi_request(0x1802, 0x0000, 0, 0,
139 &usAX, &usBX, &usCX, &usDX, &usDI, &usSI);
149 pSettings->
usDspIRQ = usSI & 0x00FF;
150 pSettings->
usDspDMA = (usSI & 0xFF00) >> 8;
151 if ((usDI & 0x00FF) < numDspBases) {
152 pSettings->
usDspBaseIO = ausDspBases[usDI & 0x00FF];
157 "smapi::smapi_query_DSP_cfg get DSP Settings bDSPPresent %x bDSPEnabled %x usDspIRQ %x usDspDMA %x usDspBaseIO %x\n",
168 bRC = smapi_request(0x1804, 0x0000, 0, 0,
169 &usAX, &usBX, &usCX, &usDX, &usDI, &usSI);
171 PRINTK_ERROR(
"smapi::smapi_query_DSP_cfg: Error: Could not get DSP modem settings. Aborting.\n");
179 if (((usSI & 0xFF00) >> 8) < numUartBases) {
180 pSettings->
usUartBaseIO = ausUartBases[(usSI & 0xFF00) >> 8];
186 "smapi::smapi_query_DSP_cfg get DSP modem settings bModemEnabled %x usUartIRQ %x usUartBaseIO %x\n",
207 unsigned short usAX, usBX, usCX, usDX, usDI, usSI;
208 unsigned short ausDspBases[] = { 0x0030, 0x4E30, 0x8E30, 0xCE30, 0x0130, 0x0350, 0x0070, 0x0DB0 };
209 unsigned short ausUartBases[] = { 0x03F8, 0x02F8, 0x03E8, 0x02E8 };
210 unsigned short ausDspIrqs[] = { 5, 7, 10, 11, 15 };
211 unsigned short ausUartIrqs[] = { 3, 4 };
213 unsigned short numDspBases = 8;
214 unsigned short numUartBases = 4;
215 unsigned short numDspIrqs = 5;
216 unsigned short numUartIrqs = 2;
217 unsigned short dspio_index = 0, uartio_index = 0;
220 "smapi::smapi_set_DSP_cfg entry mwave_3780i_irq %x mwave_3780i_io %x mwave_uart_irq %x mwave_uart_io %x\n",
224 for (i = 0; i < numDspBases; i++) {
228 if (i == numDspBases) {
236 for (i = 0; i < numDspIrqs; i++) {
240 if (i == numDspIrqs) {
247 for (i = 0; i < numUartBases; i++) {
251 if (i == numUartBases) {
260 for (i = 0; i < numUartIrqs; i++) {
264 if (i == numUartIrqs) {
273 bRC = smapi_request(0x1402, 0x0000, 0, 0,
274 &usAX, &usBX, &usCX, &usDX, &usDI, &usSI);
275 if (bRC)
goto exit_smapi_request_error;
280 #ifndef MWAVE_FUTZ_WITH_OTHER_DEVICES
282 "smapi::smapi_set_DSP_cfg: Serial port A irq %x conflicts with mwave_uart_irq %x\n", usSI & 0xFF,
mwave_uart_irq);
285 "smapi::smapi_set_DSP_cfg: Serial port A irq %x conflicts with mwave_uart_irq %x\n", usSI & 0xFF,
mwave_uart_irq);
287 #ifdef MWAVE_FUTZ_WITH_OTHER_DEVICES
289 "smapi::smapi_set_DSP_cfg Disabling conflicting serial port\n");
290 bRC = smapi_request(0x1403, 0x0100, 0, usSI,
291 &usAX, &usBX, &usCX, &usDX, &usDI, &usSI);
292 if (bRC)
goto exit_smapi_request_error;
293 bRC = smapi_request(0x1402, 0x0000, 0, 0,
294 &usAX, &usBX, &usCX, &usDX, &usDI, &usSI);
295 if (bRC)
goto exit_smapi_request_error;
300 if ((usSI >> 8) == uartio_index) {
301 #ifndef MWAVE_FUTZ_WITH_OTHER_DEVICES
303 "smapi::smapi_set_DSP_cfg: Serial port A base I/O address %x conflicts with mwave uart I/O %x\n", ausUartBases[usSI >> 8], ausUartBases[uartio_index]);
306 "smapi::smapi_set_DSP_cfg: Serial port A base I/O address %x conflicts with mwave uart I/O %x\n", ausUartBases[usSI >> 8], ausUartBases[uartio_index]);
308 #ifdef MWAVE_FUTZ_WITH_OTHER_DEVICES
310 "smapi::smapi_set_DSP_cfg Disabling conflicting serial port A\n");
311 bRC = smapi_request (0x1403, 0x0100, 0, usSI,
312 &usAX, &usBX, &usCX, &usDX, &usDI, &usSI);
313 if (bRC)
goto exit_smapi_request_error;
314 bRC = smapi_request (0x1402, 0x0000, 0, 0,
315 &usAX, &usBX, &usCX, &usDX, &usDI, &usSI);
316 if (bRC)
goto exit_smapi_request_error;
326 bRC = smapi_request(0x1404, 0x0000, 0, 0,
327 &usAX, &usBX, &usCX, &usDX, &usDI, &usSI);
328 if (bRC)
goto exit_smapi_request_error;
333 #ifndef MWAVE_FUTZ_WITH_OTHER_DEVICES
335 "smapi::smapi_set_DSP_cfg: Serial port B irq %x conflicts with mwave_uart_irq %x\n", usSI & 0xFF,
mwave_uart_irq);
338 "smapi::smapi_set_DSP_cfg: Serial port B irq %x conflicts with mwave_uart_irq %x\n", usSI & 0xFF,
mwave_uart_irq);
340 #ifdef MWAVE_FUTZ_WITH_OTHER_DEVICES
342 "smapi::smapi_set_DSP_cfg Disabling conflicting serial port B\n");
343 bRC = smapi_request(0x1405, 0x0100, 0, usSI,
344 &usAX, &usBX, &usCX, &usDX, &usDI, &usSI);
345 if (bRC)
goto exit_smapi_request_error;
346 bRC = smapi_request(0x1404, 0x0000, 0, 0,
347 &usAX, &usBX, &usCX, &usDX, &usDI, &usSI);
348 if (bRC)
goto exit_smapi_request_error;
353 if ((usSI >> 8) == uartio_index) {
354 #ifndef MWAVE_FUTZ_WITH_OTHER_DEVICES
356 "smapi::smapi_set_DSP_cfg: Serial port B base I/O address %x conflicts with mwave uart I/O %x\n", ausUartBases[usSI >> 8], ausUartBases[uartio_index]);
359 "smapi::smapi_set_DSP_cfg: Serial port B base I/O address %x conflicts with mwave uart I/O %x\n", ausUartBases[usSI >> 8], ausUartBases[uartio_index]);
361 #ifdef MWAVE_FUTZ_WITH_OTHER_DEVICES
363 "smapi::smapi_set_DSP_cfg Disabling conflicting serial port B\n");
364 bRC = smapi_request (0x1405, 0x0100, 0, usSI,
365 &usAX, &usBX, &usCX, &usDX, &usDI, &usSI);
366 if (bRC)
goto exit_smapi_request_error;
367 bRC = smapi_request (0x1404, 0x0000, 0, 0,
368 &usAX, &usBX, &usCX, &usDX, &usDI, &usSI);
369 if (bRC)
goto exit_smapi_request_error;
379 bRC = smapi_request(0x1700, 0x0000, 0, 0,
380 &usAX, &usBX, &usCX, &usDX, &usDI, &usSI);
381 if (bRC)
goto exit_smapi_request_error;
382 bRC = smapi_request(0x1704, 0x0000, 0, 0,
383 &usAX, &usBX, &usCX, &usDX, &usDI, &usSI);
384 if (bRC)
goto exit_smapi_request_error;
386 if ((usCX & 0xff) != 0xff) {
388 #ifndef MWAVE_FUTZ_WITH_OTHER_DEVICES
390 "smapi::smapi_set_DSP_cfg: IR port irq %x conflicts with mwave_uart_irq %x\n", usCX & 0xff,
mwave_uart_irq);
393 "smapi::smapi_set_DSP_cfg: IR port irq %x conflicts with mwave_uart_irq %x\n", usCX & 0xff,
mwave_uart_irq);
395 #ifdef MWAVE_FUTZ_WITH_OTHER_DEVICES
397 "smapi::smapi_set_DSP_cfg Disabling conflicting IR port\n");
398 bRC = smapi_request(0x1701, 0x0100, 0, 0,
399 &usAX, &usBX, &usCX, &usDX, &usDI, &usSI);
400 if (bRC)
goto exit_smapi_request_error;
401 bRC = smapi_request(0x1700, 0, 0, 0,
402 &usAX, &usBX, &usCX, &usDX, &usDI, &usSI);
403 if (bRC)
goto exit_smapi_request_error;
404 bRC = smapi_request(0x1705, 0x01ff, 0, usSI,
405 &usAX, &usBX, &usCX, &usDX, &usDI, &usSI);
406 if (bRC)
goto exit_smapi_request_error;
407 bRC = smapi_request(0x1704, 0x0000, 0, 0,
408 &usAX, &usBX, &usCX, &usDX, &usDI, &usSI);
409 if (bRC)
goto exit_smapi_request_error;
414 if ((usSI & 0xff) == uartio_index) {
415 #ifndef MWAVE_FUTZ_WITH_OTHER_DEVICES
417 "smapi::smapi_set_DSP_cfg: IR port base I/O address %x conflicts with mwave uart I/O %x\n", ausUartBases[usSI & 0xff], ausUartBases[uartio_index]);
420 "smapi::smapi_set_DSP_cfg: IR port base I/O address %x conflicts with mwave uart I/O %x\n", ausUartBases[usSI & 0xff], ausUartBases[uartio_index]);
422 #ifdef MWAVE_FUTZ_WITH_OTHER_DEVICES
424 "smapi::smapi_set_DSP_cfg Disabling conflicting IR port\n");
425 bRC = smapi_request(0x1701, 0x0100, 0, 0,
426 &usAX, &usBX, &usCX, &usDX, &usDI, &usSI);
427 if (bRC)
goto exit_smapi_request_error;
428 bRC = smapi_request(0x1700, 0, 0, 0,
429 &usAX, &usBX, &usCX, &usDX, &usDI, &usSI);
430 if (bRC)
goto exit_smapi_request_error;
431 bRC = smapi_request(0x1705, 0x01ff, 0, usSI,
432 &usAX, &usBX, &usCX, &usDX, &usDI, &usSI);
433 if (bRC)
goto exit_smapi_request_error;
434 bRC = smapi_request(0x1704, 0x0000, 0, 0,
435 &usAX, &usBX, &usCX, &usDX, &usDI, &usSI);
436 if (bRC)
goto exit_smapi_request_error;
445 bRC = smapi_request(0x1802, 0x0000, 0, 0,
446 &usAX, &usBX, &usCX, &usDX, &usDI, &usSI);
447 if (bRC)
goto exit_smapi_request_error;
456 bRC = smapi_request(0x1803, 0x0101, usDI, usSI,
457 &usAX, &usBX, &usCX, &usDX, &usDI, &usSI);
458 if (bRC)
goto exit_smapi_request_error;
460 bRC = smapi_request(0x1804, 0x0000, 0, 0,
461 &usAX, &usBX, &usCX, &usDX, &usDI, &usSI);
462 if (bRC)
goto exit_smapi_request_error;
465 usSI = (usSI & 0x00ff) | (uartio_index << 8);
470 bRC = smapi_request(0x1805, 0x0101, 0, usSI,
471 &usAX, &usBX, &usCX, &usDX, &usDI, &usSI);
472 if (bRC)
goto exit_smapi_request_error;
474 bRC = smapi_request(0x1802, 0x0000, 0, 0,
475 &usAX, &usBX, &usCX, &usDX, &usDI, &usSI);
476 if (bRC)
goto exit_smapi_request_error;
478 bRC = smapi_request(0x1804, 0x0000, 0, 0,
479 &usAX, &usBX, &usCX, &usDX, &usDI, &usSI);
480 if (bRC)
goto exit_smapi_request_error;
490 exit_smapi_request_error:
499 unsigned short usAX, usBX, usCX, usDX, usDI, usSI;
500 unsigned short usPowerFunction;
504 usPowerFunction = (bOn) ? 1 : 0;
506 bRC = smapi_request(0x4901, 0x0000, 0, usPowerFunction,
507 &usAX, &usBX, &usCX, &usDX, &usDI, &usSI);
515 static int SmapiQuerySystemID(
void)
518 unsigned short usAX = 0xffff, usBX = 0xffff, usCX = 0xffff,
519 usDX = 0xffff, usDI = 0xffff, usSI = 0xffff;
521 printk(
"smapi::SmapiQUerySystemID entry\n");
522 bRC = smapi_request(0x0000, 0, 0, 0,
523 &usAX, &usBX, &usCX, &usDX, &usDI, &usSI);
526 printk(
"AX=%x, BX=%x, CX=%x, DX=%x, DI=%x, SI=%x\n",
527 usAX, usBX, usCX, usDX, usDI, usSI);
529 printk(
"smapi::SmapiQuerySystemID smapi_request error\n");
539 unsigned short usSmapiID = 0;
547 spin_unlock_irqrestore(&
rtc_lock, flags);
550 if (usSmapiID == 0x5349) {
554 spin_unlock_irqrestore(&
rtc_lock, flags);
555 if (g_usSmapiPort == 0) {
556 PRINTK_ERROR(
"smapi::smapi_init, ERROR unable to read from SMAPI port\n");
559 "smapi::smapi_init, exit TRUE g_usSmapiPort %x\n",
565 PRINTK_ERROR(
"smapi::smapi_init, ERROR invalid usSmapiID\n");