fet: implemented magic table for FW ver. 20404000

This commit is contained in:
Daniel Beer 2010-04-28 18:50:18 +12:00
parent 731a1e8b39
commit 6fa975277b
1 changed files with 113 additions and 53 deletions

166
fet.c
View File

@ -777,68 +777,128 @@ const static struct device fet_device = {
.writemem = fet_writemem .writemem = fet_writemem
}; };
static const u_int8_t rf2500_29_magic[] = { #define MAGIC_DATA_SIZE 0x4a
0x00, 0x80, 0xff, 0xff, 0x00, 0x00, 0x00, 0x10, #define MAGIC_PARAM_COUNT 3
0xff, 0x10, 0x40, 0x00, 0x00, 0x02, 0xff, 0x05,
0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x01, 0x00, #define MAGIC_SEND_29 0x01
0x01, 0x00, 0xd7, 0x60, 0x00, 0x00, 0x00, 0x00, #define MAGIC_SEND_2B 0x02
0x08, 0x07, 0x10, 0x0e, 0xc4, 0x09, 0x70, 0x17,
0x58, 0x1b, 0x01, 0x00, 0x03, 0x00, 0x00, 0x00, struct magic_record {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, int min_version;
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, int flags;
0x00, 0x00, 0x00, 0x00, 0x33, 0x0f, 0x1f, 0x0f, u_int32_t param_29[MAGIC_PARAM_COUNT];
0xff, 0xff const u_int8_t data_29[MAGIC_DATA_SIZE];
const u_int8_t data_2b[MAGIC_DATA_SIZE];
}; };
static const u_int8_t chronos_2b_magic[] = { /* The first entry in this table whose version exceeds the version
0x00, 0x10, 0xff, 0x17, 0x00, 0x02, 0x01, 0x00, * reported by the FET is used. Therefore, it must be kept in descending
0x04, 0x00, 0x40, 0x00, 0x0a, 0x91, 0x8e, 0x00, * order of version.
0x00, 0xb0, 0x28, 0x29, 0x2a, 0x2b, 0x80, 0xd8, */
0xa8, 0x60, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, const static struct magic_record magic_table[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, { /* TI Chronos */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, .min_version = 30001000,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, .flags = MAGIC_SEND_29 | MAGIC_SEND_2B,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, .param_29 = {0x77, 0x6f, 0x4a},
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, .data_29 = {
0x00, 0x00 0x00, 0x80, 0xff, 0xff, 0x00, 0x00, 0x00, 0x18,
}; 0xff, 0x19, 0x80, 0x00, 0x00, 0x1c, 0xff, 0x2b,
0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x02, 0x00,
static const u_int8_t chronos_29_magic[] = { 0x02, 0x00, 0x07, 0x24, 0x00, 0x00, 0x00, 0x00,
0x00, 0x80, 0xff, 0xff, 0x00, 0x00, 0x00, 0x18, 0x08, 0x07, 0x10, 0x0e, 0xc4, 0x09, 0x70, 0x17,
0xff, 0x19, 0x80, 0x00, 0x00, 0x1c, 0xff, 0x2b, 0x58, 0x1b, 0x01, 0x00, 0x03, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00,
0x02, 0x00, 0x07, 0x24, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x08, 0x07, 0x10, 0x0e, 0xc4, 0x09, 0x70, 0x17, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
0x58, 0x1b, 0x01, 0x00, 0x03, 0x00, 0x00, 0x00, 0xff, 0xff
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, },
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, .data_2b = {
0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x10, 0xff, 0x17, 0x00, 0x02, 0x01, 0x00,
0xff, 0xff 0x04, 0x00, 0x40, 0x00, 0x0a, 0x91, 0x8e, 0x00,
0x00, 0xb0, 0x28, 0x29, 0x2a, 0x2b, 0x80, 0xd8,
0xa8, 0x60, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00
}
},
{ /* RF2500 */
.min_version = 30000000,
.flags = MAGIC_SEND_29,
.param_29 = {0, 0x39, 0x31},
.data_29 = {
0x00, 0x80, 0xff, 0xff, 0x00, 0x00, 0x00, 0x10,
0xff, 0x10, 0x40, 0x00, 0x00, 0x02, 0xff, 0x05,
0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x01, 0x00,
0x01, 0x00, 0xd7, 0x60, 0x00, 0x00, 0x00, 0x00,
0x08, 0x07, 0x10, 0x0e, 0xc4, 0x09, 0x70, 0x17,
0x58, 0x1b, 0x01, 0x00, 0x03, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x33, 0x0f, 0x1f, 0x0f,
0xff, 0xff
}
},
{ /* FET430UIF */
.min_version = 20404000,
.flags = MAGIC_SEND_29 | MAGIC_SEND_2B,
.param_29 = {0, 7, 7},
.data_29 = {
0x00, 0x11, 0xff, 0xff, 0x00, 0x00, 0x00, 0x10,
0xff, 0x10, 0x80, 0x00, 0x00, 0x02, 0xff, 0x09,
0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x02, 0x00,
0x00, 0x00, 0xd7, 0x60, 0x00, 0x00, 0x00, 0x00,
0x08, 0x07, 0x10, 0x0e, 0xc4, 0x09, 0x70, 0x17,
0x58, 0x1b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xf3, 0x30, 0xd3, 0x30,
0xc0, 0x30
},
.data_2b = {
0x00, 0x0c, 0xff, 0x0f, 0x00, 0x02, 0x00, 0x00,
0x03, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00
}
}
}; };
static int do_magic(void) static int do_magic(void)
{ {
if (fet_version >= 30001000) { int i;
printf("Sending Chronos init messages...\n");
if (xfer(0x2b, chronos_2b_magic, for (i = 0; i < ARRAY_LEN(magic_table); i++) {
sizeof(chronos_2b_magic), 0) < 0) { const struct magic_record *r = &magic_table[i];
fprintf(stderr, "fet: command 0x2b failed\n");
return -1;
}
if (xfer(0x29, chronos_29_magic, if (fet_version >= r->min_version) {
sizeof(chronos_29_magic), 3, 0x77, 0x6f, 0x4a) < 0) { printf("Sending magic messages for >= %d\n",
fprintf(stderr, "fet: command 0x29 failed\n"); r->min_version);
return -1;
}
} else if (fet_version >= 30000000) {
printf("Sending RF2500 init messages...\n");
if (xfer(0x29, rf2500_29_magic, if ((r->flags & MAGIC_SEND_2B) &&
sizeof(rf2500_29_magic), 3, 0, 0x39, 0x31) < 0) { xfer(0x2b, r->data_2b, MAGIC_DATA_SIZE, 0) < 0) {
fprintf(stderr, "fet: command 0x29 failed\n"); fprintf(stderr, "fet: command 0x2b failed\n");
return -1; return -1;
}
if ((r->flags & MAGIC_SEND_29) &&
xfer(0x29, r->data_29, MAGIC_DATA_SIZE,
3, r->param_29[0], r->param_29[1],
r->param_29[2]) < 0) {
fprintf(stderr, "fet: command 0x29 failed\n");
return -1;
}
return 0;
} }
} }