Code: Select all
#define NO_CHIP 0x00
#define BASE0 0x200
#define BASE1 0x220
#define BASE2 0x240
#define BASE3 0x260
#define BASE4 0x280
#define BASE5 0x210
#define DSP_RESET 0x06
#define DSP_READ_DATA_PORT 0x0A
unsigned short int check_dsp()
{
unsigned short int val[] =
{ BASE0, BASE1, BASE2, BASE3, BASE4, BASE5, NO_CHIP };
static short int count = sizeof(val) / sizeof(*val) - 1; // don't test no_chip
unsigned short int i = 0;
// for each possible port
for (i = 0; i < count; i++) {
// test it by attempting to reset the DSP
if (reset_dsp(val[i]))
// if found, break now
break;
}
// base io address, or, if not found, NO_CHIP, since i=countS
return val[i];
}
unsigned short int reset_dsp(const unsigned short int base)
{
int loopc;
outportb(base + DSP_RESET, 1);
udelay();
outportb(base + DSP_RESET, 0);
udelay();
udelay();
udelay();
for (loopc = 0; loopc < 1000 && !(inportb(base + DSP_READ_BUFFER_STATUS) & 0x80); loopc++); /* Wait for data
* available status */
if (inportb(base + DSP_READ_DATA_PORT) != 0xAA)
return 0;
return 1;
}