コード例 #1
0
ファイル: sb1000.c プロジェクト: 325116067/semc-qsd8x50
/* 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);
}
コード例 #2
0
ファイル: sb1000.c プロジェクト: 325116067/semc-qsd8x50
/* set SB1000 frequency */
static int
sb1000_set_frequency(const int ioaddr[], const char* name, int frequency)
{
	unsigned char st[7];
	int status;
	unsigned char Command0[6] = {0x80, 0x29, 0x00, 0x00, 0x00, 0x00};

	const int FrequencyLowerLimit = 57000;
	const int FrequencyUpperLimit = 804000;

	if (frequency < FrequencyLowerLimit || frequency > FrequencyUpperLimit) {
		printk(KERN_ERR "%s: frequency chosen (%d kHz) is not in the range "
			"[%d,%d] kHz\n", name, frequency, FrequencyLowerLimit,
			FrequencyUpperLimit);
		return -EINVAL;
	}
	udelay(1000);
	if ((status = sb1000_start_get_set_command(ioaddr, name)))
		return status;
	Command0[5] = frequency & 0xff;
	frequency >>= 8;
	Command0[4] = frequency & 0xff;
	frequency >>= 8;
	Command0[3] = frequency & 0xff;
	frequency >>= 8;
	Command0[2] = frequency & 0xff;
	return card_send_command(ioaddr, name, Command0, st);
}
コード例 #3
0
ファイル: sb1000.c プロジェクト: 3sOx/asuswrt-merlin
static inline int
sb1000_activate(const int ioaddr[], const char* name)
{
	unsigned char st[7];
	int status;
	const unsigned char Command0[6] = {0x80, 0x11, 0x00, 0x00, 0x00, 0x00};
	const unsigned char Command1[6] = {0x80, 0x16, 0x00, 0x00, 0x00, 0x00};

	ssleep(1);
	if ((status = card_send_command(ioaddr, name, Command0, st)))
		return status;
	if ((status = card_send_command(ioaddr, name, Command1, st)))
		return status;
	if (st[3] != 0xf1) {
    	if ((status = sb1000_start_get_set_command(ioaddr, name)))
			return status;
		return -EIO;
	}
	udelay(1000);
    return sb1000_start_get_set_command(ioaddr, name);
}
コード例 #4
0
ファイル: sb1000.c プロジェクト: 325116067/semc-qsd8x50
/* 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);
}
コード例 #5
0
ファイル: sb1000.c プロジェクト: 3sOx/asuswrt-merlin
/* 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);
}
コード例 #6
0
ファイル: sb1000.c プロジェクト: 3sOx/asuswrt-merlin
/* 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;
}