Commit db8b59ce authored by Tristan Gingold's avatar Tristan Gingold

fip_urv: rework i2c

avoid replication of i2c commands

And reorder commands in mfip_urv
parent 1ac2c208
This diff is collapsed.
This diff is collapsed.
......@@ -41,8 +41,6 @@ extern "C" {
#define CMD_WRITE_ECC 0x0D
#define CMD_WAIT 0x0E
#define CMD_WRITE_BLOCK 0x0F
#define CMD_FAN_OFF 0x10
#define CMD_FAN_ON 0x11
#define CMD_ALRM_FLAG 0x40
#define CMD_APP_FLAG 0x80
......
......@@ -717,12 +717,15 @@ static int cb_i2c_scan_en (struct urv_cmd *cmd, unsigned char *rep)
{
unsigned val = word_unpack(&rep[4]);
fprintf (out, "i2c-scan-en: 0x%x ", val);
fprintf (out, "adc: %u, ",
(unsigned)(val & FIP_URV_REGS_I2C_SCAN_EN_ADC));
fprintf (out, "fantray: %u, ",
(unsigned)(val & FIP_URV_REGS_I2C_SCAN_EN_FANTRAY));
fprintf (out, "ratopus: %u\n",
(unsigned)(val & FIP_URV_REGS_I2C_SCAN_EN_RADTOPUS));
fprintf (out, "adc: %u/%u, ",
(unsigned)(val & FIP_URV_REGS_I2C_SCAN_EN_ADC),
(unsigned)FIP_URV_REGS_I2C_SCAN_EN_ADC);
fprintf (out, "fantray: %u/%u, ",
(unsigned)(val & FIP_URV_REGS_I2C_SCAN_EN_FANTRAY),
(unsigned)FIP_URV_REGS_I2C_SCAN_EN_FANTRAY);
fprintf (out, "ratopus: %u/%u\n",
(unsigned)(val & FIP_URV_REGS_I2C_SCAN_EN_RADTOPUS),
(unsigned)FIP_URV_REGS_I2C_SCAN_EN_RADTOPUS);
return 0;
}
......@@ -4082,7 +4085,7 @@ static int do_write_monimod (int argc, char *argv[]) {
}
static int do_i2c (int argc, char *argv[]) {
static int do_i2c_bus (int argc, char *argv[]) {
struct urv_cmd cmd;
unsigned oargc = argc;
......@@ -4993,8 +4996,7 @@ static int do_fantray (int argc, char *argv[])
struct cb_system_data {
/* Length of the buffer. */
unsigned char len;
/* i2c bus scanned. */
unsigned char bus;
unsigned char cycle;
/* Start address of each slave (0 when not present). */
unsigned mon_off;
unsigned ft_off;
......@@ -5012,33 +5014,31 @@ static int cb_system_read (struct urv_cmd *cmd, unsigned char *rep) {
}
if (cmd->args[0] == 0) {
/* First packet */
unsigned off;
unsigned bus;
data->len = rep[4];
bus = rep[5];
data->cycle = rep[7];
fprintf (out, "Cycle: 0x%02x\n", rep[7]);
#if DEBUG
fprintf (out, "DEBUG --- Buffer-Length: 0x%02x\n", rep[4]);
fprintf (out, "DEBUG --- Buses: %02x (ADC:%x, FT:%x, RTP:%x)\n", rep[5],
(rep[5] & I2C_SLV_ADC),
(rep[5] & I2C_SLV_FT) >> 1,
(rep[5] & I2C_SLV_RTP) >> 2
);
#endif
fprintf (out, "Buffer length: 0x%02x\n", rep[4]);
fprintf (out, "Buses: 0x%02x (adc:%x, ft:%x rtp:%x)\n", bus,
(bus & I2C_SLV_ADC), (bus & I2C_SLV_FT), (bus & I2C_SLV_RTP));
data->len = rep[4];
data->bus = rep[5];
off = 1;
data->mon_off = off;
if ((data->bus & I2C_SLV_ADC) == I2C_SLV_ADC) {
off += 9;
if ((bus & I2C_SLV_ADC) == I2C_SLV_ADC) {
off += ADC_SB_I2C_BYTES / 2;
}
data->ft_off = off;
if ((data->bus & I2C_SLV_FT) == I2C_SLV_FT) {
off += 7;
if ((bus & I2C_SLV_FT) == I2C_SLV_FT) {
off += FANTRAY_I2C_BYTES / 2;
}
data->rtp_off = off;
if ((data->bus & I2C_SLV_RTP) == I2C_SLV_RTP) {
off += 5;
if ((bus & I2C_SLV_RTP) == I2C_SLV_RTP) {
off += RAD7291_I2C_BYTES / 2;
}
data->max_off = off;
......@@ -5167,6 +5167,8 @@ static int cb_system_read (struct urv_cmd *cmd, unsigned char *rep) {
return 1;
}
fprintf (out, "Cycle-end: 0x%02x (%s)\n",
rep[7], rep[7] != data->cycle ? "data have changed" : "ok");
free(data);
return 0;
......@@ -5391,7 +5393,24 @@ static const struct menu_t menu [] =
{
{ "help", do_help, "print this help" },
{ "close", do_close, "close the connection" },
{ "ping", do_ping, "ping (send/recv data)" },
{ "supervisor", do_supervisor, "disp supervisor registers" },
{ "plc-supervisor", do_plc_supervisor, "disp PLC supervisor registers" },
{ "shmem-supervisor", do_shmem_supervisor, "disp shmem supervisor regs" },
{ "system-read", do_system_read, "read all scan value" },
{ "stat-regs", do_stat_regs, "disp stat registers" },
{ "config", do_config, "disp version and config regs" },
{ "data", do_data, "send data to app cpu" },
{ "last-data", do_last_data, "print last received data from app cpu" },
{ "plc", do_plc, "start/stop plc cpu" },
{ "load", do_load, "load image for plc cpu" },
{ "restart-cfg", do_restart_cfg, "get/set restart config" },
{ "restart", do_restart, "restart the cpus (reload ram)" },
{ "monimod-scan", do_monimod_scan, "monimod scan on/off" },
{ "i2c-scan-en", do_i2c_scan_en, "display/set devices scanned" },
{ "date", do_date, "print current date" },
{ "slots", do_slots, "disp slots state" },
{ "set-leds", do_set_leds, "set leds" },
{ "get-leds", do_get_leds, "read leds value" },
{ "read", do_read, "read a word" },
......@@ -5400,41 +5419,26 @@ static const struct menu_t menu [] =
{ "write-ecc", do_write_ecc, "write a word with ecc (to force error)" },
{ "write-plc-ecc", do_write_plc_ecc, "write a word in plc iram with ecc" },
{ "set-wd", do_set_wd, "set watchdog period" },
{ "ping", do_ping, "ping (send/recv data)" },
{ "data", do_data, "send data to app cpu" },
{ "last-data", do_last_data, "print last received data from app cpu" },
{ "plc", do_plc, "start/stop plc cpu" },
{ "load", do_load, "load image for plc cpu" },
{ "mbox", do_mbox, "read/write plc mailbox" },
{ "slots", do_slots, "disp slots state" },
{ "supervisor", do_supervisor, "disp supervisor registers" },
{ "plc-supervisor", do_plc_supervisor, "disp PLC supervisor registers" },
{ "shmem-supervisor", do_shmem_supervisor, "disp shmem supervisor regs" },
{ "shmem-scrubber", do_shmem_scrubber, "enable shmem scrubber"},
{ "shmem-ecc", do_shmem_ecc, "read/write shmem ecc register"},
{ "plc-last-iaddr", do_plc_last_iaddr, "disp PLC last iaddr"},
{ "config", do_config, "disp version and config regs" },
{ "stat-regs", do_stat_regs, "disp stat registers" },
{ "fip-err", do_fip_err, "display number of FIP errors" },
{ "fip-reset", do_fip_reset, "do a board reset through fip" },
{ "scrubber", do_scrubber, "enable scrubber" },
{ "mon-vout", do_mon_vout, "display voltage" },
{ "read-monimod", do_read_monimod, "monimod read command" },
{ "write-monimod", do_write_monimod, "monimod write command" },
{ "i2c", do_i2c, "select i2c channel" },
{ "i2c-bus", do_i2c_bus, "select i2c bus" },
{ "i2c-id", do_i2c_id, "read board id using i2c gpio" },
{ "i2c-eeprom", do_i2c_eeprom, "read board id using i2c eeprom" },
{ "i2c-stat", do_i2c_stat, "display i2c fsm status" },
{ "i2c-off", do_i2c_off, "tie i2c lines to 0 register" },
{ "i2c-scan-en", do_i2c_scan_en, "display/set devices scanned" },
{ "psu", do_psu, "PSU state" },
{ "pwr-cyc", do_pwr_cyc, "power cycle the crate" },
{ "cpu-fault", do_cpu_fault, "force a cpu divergence" },
{ "restart-cfg", do_restart_cfg, "get/set restart config" },
{ "restart", do_restart, "restart the cpus (reload ram)" },
{ "wait", do_wait, "busy waiting loop" },
{ "monimod-power", do_monimod_power, "power on/off monimod" },
{ "monimod-scan", do_monimod_scan, "monimod scan on/off" },
{ "spi-init", do_spi_init, "init SPI periph" },
{ "spi-read", do_spi_read, "read a word from SPI flash" },
{ "spi-dump", do_spi_dump, "dump SPI flash memory" },
......@@ -5446,7 +5450,6 @@ static const struct menu_t menu [] =
{ "read-ratopus", do_ratopus_read, "Read Ratopus Registers"},
{ "write-ratopus", do_ratopus_write, "Write Ratopus Registers"},
{ "fantray", do_fantray, "switch off/on fantray"},
{ "system-read", do_system_read, "read all scan value" },
{ "read-adc", do_adc_read, "Read ADC Registers"},
{ "write-adc", do_adc_write, "Write ADC Registers"},
{ NULL, NULL, NULL }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment