-- -*- Mode: LUA; tab-width: 2 -*-

peripheral {
   name = "WR Core Diagnostics";
   description = "Diagnostics information accessible via WR";
   prefix = "wrc_diags";
   hdl_entity = "wrc_diags_wb";
   version = 1;

  reg {
    name = "Ctrl";
    prefix = "CTRL";
    field {
      name        = "WR DIAG data valid";
      prefix      = "DATA_VALID";
      description = "0: valid\
                     1:transcient";
      type        = BIT;
      access_bus  = READ_ONLY;
      access_dev  = WRITE_ONLY;
    };
    field {
      name        = "WR DIAG data snapshot";
      prefix      = "DATA_SNAPSHOT";
      description = "1: snapshot data (data in registers will not change aveter VALID becomes true)";
      type        = BIT;
      access_bus  = WRITE_READ;
      access_dev  = READ_ONLY;
      align       = 8;
    };
  };
  reg {
    name = "WRPC Diag: servo status";
    prefix = "WDIAG_SSTAT";
    field {
      name        = "WR valid";
      prefix      = "wr_mode";
      description = "0: not valid\
                     1:valid";
      type        = BIT;
      access_bus  = READ_ONLY;
      access_dev  = WRITE_ONLY;
    };
    field {
      name        = "Servo State";
      prefix      = "servostate";
      description = "0: Uninitialized\
                     1: SYNC_NSEC\
                     2: SYNC_TAI\
                     3: SYNC_PHASE\
                     4: TRACK_PHASE\
                     5: WAIT_OFFSET_STABLE";
      type        = SLV;
      size        = 4;
      align       = 8;
      access_bus  = READ_ONLY;
      access_dev  = WRITE_ONLY;
    };
  };
  reg {
    name = "WRPC Diag: Port status";
    prefix = "WDIAG_PSTAT";
    field {
      name        = "Link Status";
      prefix      = "link";
      description = "0: link down\
                     1: link up";
      type        = BIT;
      access_bus  = READ_ONLY;
      access_dev  = WRITE_ONLY;
    };
    field {
      name        = "PLL Locked";
      prefix      = "locked";
      description = "0: not locked\
                     1: locked";
      type        = BIT;
      access_bus  = READ_ONLY;
      access_dev  = WRITE_ONLY;
    };
  };
  reg {
    name = "WRPC Diag: PTP state";
    prefix = "WDIAG_PTPSTAT";

    field {
      name        = "PTP State";
      prefix      = "ptpstate";
      description = "0: NONE\
                     1: PPS_INITIALIZING\
                     2: PPS_FAULTY\
                     3: disabled\
                     4: PPS_LISTENING\
                     5: PPS_PRE_MASTER\
                     6: PPS_MASTER\
                     7: PPS_PASSIVE\
                     8: PPS_UNCALIBRATED\
                     9: PPS_SLAVE\
                     100-116: WR STATES\
                     see: ppsi/proto-ext-whiterabbit/wr-constants.h\
                          ppsi/include/ppsi/ieee1588_types.h";
      type        = SLV;
      size        = 8;
      access_bus  = READ_ONLY;
      access_dev  = WRITE_ONLY;
    };
  };
  reg {
    name = "WRPC Diag: AUX state";
    prefix = "WDIAG_ASTAT";

    field {
      name        = "AUX channel";
      prefix      = "aux";
      description = "A vector of bits, one bit per channel\
                     0: not valid\
                     1:valid";
      type        = SLV;
      size        = 8;
      access_bus  = READ_ONLY;
      access_dev  = WRITE_ONLY;
    };
  };
  reg {
    name = "WRPC Diag: Tx PTP Frame cnts";
    prefix = "WDIAG_TXFCNT";
    description = "Number of transmitted PTP Frames";
    field {
      name = "Data";
      size = 32;
      type = SLV;
      access_bus  = READ_ONLY;
      access_dev  = WRITE_ONLY;
    };
  };
  reg {
    name = "WRPC Diag: Rx PTP Frame cnts";
    description = "Number of received PTP Frames";
    prefix = "WDIAG_RXFCNT";
    field {
      name = "Data";
      size = 32;
      type = SLV;
      access_bus  = READ_ONLY;
      access_dev  = WRITE_ONLY;
    };
  };
  reg {
    name = "WRPC Diag:local time [msb of s]";
    prefix = "WDIAG_SEC_MSB";
    description = "Local Time expressed in seconds since epoch (TAI)";
    field {
      name = "Data";
      size = 32;
      type = SLV;
      access_bus  = READ_ONLY;
      access_dev  = WRITE_ONLY;
    };
  };
  reg {
    name = "WRPC Diag: local time [lsb of s]";
    description = "Local Time expressed in seconds since epoch (TAI)";
    prefix = "WDIAG_SEC_LSB";
    field {
      name = "Data";
      size = 32;
      type = SLV;
      access_bus  = READ_ONLY;
      access_dev  = WRITE_ONLY;
    };
  };
  reg {
    name = "WRPC Diag: local time [ns]";
    description = "Nanoseconds part of the Local Time expressed in seconds since epoch (TAI)";
    prefix = "WDIAG_NS";
    field {
      name = "Data";
      size = 32;
      type = SLV;
      access_bus  = READ_ONLY;
      access_dev  = WRITE_ONLY;
    };
  };
  reg {
    name = "WRPC Diag: Round trip (mu) [msb of ps]";
    prefix = "WDIAG_MU_MSB";
    field {
      name = "Data";
      size = 32;
      type = SLV;
      access_bus  = READ_ONLY;
      access_dev  = WRITE_ONLY;
    };
  };
  reg {
    name = "WRPC Diag: Round trip (mu) [lsb of ps]";
    prefix = "WDIAG_MU_LSB";
    field {
      name = "Data";
      size = 32;
      type = SLV;
      access_bus  = READ_ONLY;
      access_dev  = WRITE_ONLY;
    };
  };
  reg {
    name = "WRPC Diag: Master-slave delay (dms) [msb of ps]";
    prefix = "WDIAG_DMS_MSB";
    field {
      name = "Data";
      size = 32;
      type = SLV;
      access_bus  = READ_ONLY;
      access_dev  = WRITE_ONLY;
    };
  };
  reg {
    name = "WRPC Diag: Master-slave delay (dms) [lsb of ps]";
    prefix = "WDIAG_DMS_LSB";
    field {
      name = "Data";
      size = 32;
      type = SLV;
      access_bus  = READ_ONLY;
      access_dev  = WRITE_ONLY;
    };
  };
  reg {
    name = "WRPC Diag: Total link asymmetry [ps]";
    prefix = "WDIAG_ASYM";
    field {
      name = "Data";
      size = 32;
      type = SLV;
      access_bus  = READ_ONLY;
      access_dev  = WRITE_ONLY;
    };
  };
  reg {
    name = "WRPC Diag: Clock offset (cko) [ps]";
    prefix = "WDIAG_CKO";
    field {
      name = "Data";
      size = 32;
      type = SLV;
      access_bus  = READ_ONLY;
      access_dev  = WRITE_ONLY;
    };
  };
  reg {
    name = "WRPC Diag: Phase setpoint (setp) [ps]";
    prefix = "WDIAG_SETP";
    field {
      name = "Data";
      size = 32;
      type = SLV;
      access_bus  = READ_ONLY;
      access_dev  = WRITE_ONLY;
    };
  };
  reg {
    name = "WRPC Diag: Update counter (ucnt)";
    prefix = "WDIAG_UCNT";
    field {
      name = "Data";
      size = 32;
      type = SLV;
      access_bus  = READ_ONLY;
      access_dev  = WRITE_ONLY;
    };
  };
  reg {
    name = "WRPC Diag: Board temperature [C degree]";
    prefix = "WDIAG_TEMP";
    field {
      name = "Data";
      size = 32;
      type = SLV;
      access_bus  = READ_ONLY;
      access_dev  = WRITE_ONLY;
    };
  };
};
