/* get SB1000 PIDs */ static int sb1000_get_PIDs(const int ioaddr[], const char* name, short PID[]) { static const unsigned char Command0[6] = {0x80, 0x40, 0x00, 0x00, 0x00, 0x00}; static const unsigned char Command1[6] = {0x80, 0x41, 0x00, 0x00, 0x00, 0x00}; static const unsigned char Command2[6] = {0x80, 0x42, 0x00, 0x00, 0x00, 0x00}; static const unsigned char Command3[6] = {0x80, 0x43, 0x00, 0x00, 0x00, 0x00}; unsigned char st[7]; int status; udelay(1000); if ((status = sb1000_start_get_set_command(ioaddr, name))) return status; if ((status = card_send_command(ioaddr, name, Command0, st))) return status; PID[0] = st[1] << 8 | st[2]; if ((status = card_send_command(ioaddr, name, Command1, st))) return status; PID[1] = st[1] << 8 | st[2]; if ((status = card_send_command(ioaddr, name, Command2, st))) return status; PID[2] = st[1] << 8 | st[2]; if ((status = card_send_command(ioaddr, name, Command3, st))) return status; PID[3] = st[1] << 8 | st[2]; return sb1000_end_get_set_command(ioaddr, name); }
/* set SB1000 PIDs */ static int sb1000_set_PIDs(const int ioaddr[], const char* name, const short PID[]) { static const unsigned char Command4[6] = {0x80, 0x2e, 0x00, 0x00, 0x00, 0x00}; unsigned char st[7]; short p; int status; unsigned char Command0[6] = {0x80, 0x31, 0x00, 0x00, 0x00, 0x00}; unsigned char Command1[6] = {0x80, 0x32, 0x00, 0x00, 0x00, 0x00}; unsigned char Command2[6] = {0x80, 0x33, 0x00, 0x00, 0x00, 0x00}; unsigned char Command3[6] = {0x80, 0x34, 0x00, 0x00, 0x00, 0x00}; udelay(1000); if ((status = sb1000_start_get_set_command(ioaddr, name))) return status; p = PID[0]; Command0[3] = p & 0xff; p >>= 8; Command0[2] = p & 0xff; if ((status = card_send_command(ioaddr, name, Command0, st))) return status; p = PID[1]; Command1[3] = p & 0xff; p >>= 8; Command1[2] = p & 0xff; if ((status = card_send_command(ioaddr, name, Command1, st))) return status; p = PID[2]; Command2[3] = p & 0xff; p >>= 8; Command2[2] = p & 0xff; if ((status = card_send_command(ioaddr, name, Command2, st))) return status; p = PID[3]; Command3[3] = p & 0xff; p >>= 8; Command3[2] = p & 0xff; if ((status = card_send_command(ioaddr, name, Command3, st))) return status; if ((status = card_send_command(ioaddr, name, Command4, st))) return status; return sb1000_end_get_set_command(ioaddr, name); }
/* get SB1000 frequency */ static int sb1000_get_frequency(const int ioaddr[], const char* name, int* frequency) { unsigned char st[7]; int status; const unsigned char Command0[6] = {0x80, 0x44, 0x00, 0x00, 0x00, 0x00}; udelay(1000); if ((status = sb1000_start_get_set_command(ioaddr, name))) return status; if ((status = card_send_command(ioaddr, name, Command0, st))) return status; *frequency = ((st[1] << 8 | st[2]) << 8 | st[3]) << 8 | st[4]; return sb1000_end_get_set_command(ioaddr, name); }
/* get SB1000 firmware version */ static int sb1000_get_firmware_version(const int ioaddr[], const char* name, unsigned char version[], int do_end) { unsigned char st[7]; int status; const unsigned char Command0[6] = {0x80, 0x23, 0x00, 0x00, 0x00, 0x00}; if ((status = sb1000_start_get_set_command(ioaddr, name))) return status; if ((status = card_send_command(ioaddr, name, Command0, st))) return status; if (st[0] != 0xa3) return -EIO; version[0] = st[1]; version[1] = st[2]; if (do_end) return sb1000_end_get_set_command(ioaddr, name); else return 0; }