xpp: Add info to astribank_tool -Q

* In MPP serial protocol add support for SER_STAT_GET command
* Use it to query firmware for:
  - FPGA build configuration number (1 - old main, 2 - new main)
  - Watchdog timer state bit (ready/expired)
  - XPD Alive timer state bit (yes/no)
* Also cleanup the code in mpps_card_info():
  - In all MPP serial commands the send/recive buffers must
    have identical size
  - No need to alias struct pointers to byte-buffers, just use
    the structs themselves as buffers.


Signed-off-by: Oron Peled <oron.peled@xorcom.com>
Acked-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>

git-svn-id: http://svn.astersk.org/svn/dahdi/tools/trunk@10501 17933a7a-c749-41c5-a318-cba88f637d49
This commit is contained in:
Oron Peled 2012-03-15 20:43:18 +00:00 committed by Tzafrir Cohen
parent 273230b044
commit d8213d2adf
4 changed files with 64 additions and 23 deletions

View File

@ -79,9 +79,6 @@ static int reset_kind(const char *arg)
static int show_hardware(struct astribank_device *astribank) static int show_hardware(struct astribank_device *astribank)
{ {
uint8_t unit;
uint8_t card_status;
uint8_t card_type;
int ret; int ret;
struct eeprom_table eeprom_table; struct eeprom_table eeprom_table;
struct capabilities capabilities; struct capabilities capabilities;
@ -95,6 +92,12 @@ static int show_hardware(struct astribank_device *astribank)
if(astribank->eeprom_type == EEPROM_TYPE_LARGE) { if(astribank->eeprom_type == EEPROM_TYPE_LARGE) {
show_capabilities(&capabilities, stdout); show_capabilities(&capabilities, stdout);
if(STATUS_FPGA_LOADED(astribank->status)) { if(STATUS_FPGA_LOADED(astribank->status)) {
uint8_t unit;
uint8_t card_status;
uint8_t card_type;
uint8_t fpga_configuration;
uint8_t status;
for(unit = 0; unit < 5; unit++) { for(unit = 0; unit < 5; unit++) {
ret = mpps_card_info(astribank, unit, &card_type, &card_status); ret = mpps_card_info(astribank, unit, &card_type, &card_status);
if(ret < 0) if(ret < 0)
@ -103,6 +106,14 @@ static int show_hardware(struct astribank_device *astribank)
((card_type >> 4) & 0xF), (card_type & 0xF), ((card_type >> 4) & 0xF), (card_type & 0xF),
((card_status & 0x1) ? "PIC" : "NOPIC")); ((card_status & 0x1) ? "PIC" : "NOPIC"));
} }
ret = mpps_stat(astribank, unit, &fpga_configuration, &status);
if (ret < 0)
return ret;
printf("FPGA: %-17s: %d\n", "Configuration num", fpga_configuration);
printf("FPGA: %-17s: %s\n", "Watchdog Timer",
(SER_STAT_WATCHDOG_READY(status)) ? "ready" : "expired");
printf("FPGA: %-17s: %s\n", "XPD Alive",
(SER_STAT_XPD_ALIVE(status)) ? "yes" : "no");
} }
ret = mpp_extrainfo_get(astribank, &extrainfo); ret = mpp_extrainfo_get(astribank, &extrainfo);
if(ret < 0) if(ret < 0)

View File

@ -95,6 +95,9 @@ struct mpp_header {
enum mpp_ser_op { enum mpp_ser_op {
SER_CARD_INFO_GET = 0x1, SER_CARD_INFO_GET = 0x1,
SER_STAT_GET = 0x3, SER_STAT_GET = 0x3,
/* Status bits */
#define SER_STAT_WATCHDOG_READY(s) ((s) & 0x01)
#define SER_STAT_XPD_ALIVE(s) ((s) & 0x02)
}; };
/* Individual commands structure */ /* Individual commands structure */

View File

@ -599,33 +599,59 @@ int mpp_serial_cmd(struct astribank_device *astribank, const uint8_t *in, uint8_
int mpps_card_info(struct astribank_device *astribank, int unit, uint8_t *card_type, uint8_t *card_status) int mpps_card_info(struct astribank_device *astribank, int unit, uint8_t *card_type, uint8_t *card_status)
{ {
struct card_info_send { /*
* Serial commands must have equal send/receive size
*/
struct card_info_command {
uint8_t ser_op; uint8_t ser_op;
uint8_t addr; uint8_t addr;
} *card_info_send;
struct card_info_recv {
uint8_t ser_op_undef; /* invalid data */
uint8_t addr;
uint8_t card_full_type; /* (type << 4 | subtype) */ uint8_t card_full_type; /* (type << 4 | subtype) */
uint8_t card_status; /* BIT(0) - PIC burned */ uint8_t card_status; /* BIT(0) - PIC burned */
} *card_info_recv; } PACKED;
uint8_t in[sizeof(struct card_info_recv)]; struct card_info_command ci_send;
uint8_t out[sizeof(struct card_info_recv)]; struct card_info_command ci_recv;
int len; int ret;
int ret;
len = sizeof(struct card_info_recv); memset(&ci_send, 0, sizeof(ci_send));
memset(in, 0, len); memset(&ci_recv, 0, sizeof(ci_recv));
memset(out, 0, len); ci_send.ser_op = SER_CARD_INFO_GET;
card_info_send = (struct card_info_send *)&in; ci_send.addr = (unit << 4); /* low nibble is subunit */
card_info_recv = (struct card_info_recv *)&out; ret = mpp_serial_cmd(astribank,
card_info_send->ser_op = SER_CARD_INFO_GET; (uint8_t *)&ci_send,
card_info_send->addr = (unit << 4); /* low nibble is subunit */ (uint8_t *)&ci_recv,
ret = mpp_serial_cmd(astribank, in, out, len); sizeof(struct card_info_command));
if (ret < 0)
return ret;
*card_type = ci_recv.card_full_type;
*card_status = ci_recv.card_status;
return 0;
}
int mpps_stat(struct astribank_device *astribank, int unit, uint8_t *fpga_configuration, uint8_t *status)
{
/*
* Serial commands must have equal send/receive size
*/
struct fpga_stat_command {
uint8_t ser_op;
uint8_t fpga_configuration;
uint8_t status; /* BIT(0) - Watchdog timer status */
} PACKED;
struct fpga_stat_command fs_send;
struct fpga_stat_command fs_recv;
int ret;
memset(&fs_send, 0, sizeof(fs_send));
memset(&fs_recv, 0, sizeof(fs_recv));
fs_send.ser_op = SER_STAT_GET;
ret = mpp_serial_cmd(astribank,
(uint8_t *)&fs_send,
(uint8_t *)&fs_recv,
sizeof(struct fpga_stat_command));
if(ret < 0) if(ret < 0)
return ret; return ret;
*card_type = card_info_recv->card_full_type; *fpga_configuration = fs_recv.fpga_configuration;
*card_status = card_info_recv->card_status; *status = fs_recv.status;
return 0; return 0;
} }

View File

@ -69,6 +69,7 @@ int twinstar_show(struct astribank_device *astribank, FILE *fp);
* Serial commands to FPGA * Serial commands to FPGA
*/ */
int mpps_card_info(struct astribank_device *astribank, int unit, uint8_t *card_type, uint8_t *card_status); int mpps_card_info(struct astribank_device *astribank, int unit, uint8_t *card_type, uint8_t *card_status);
int mpps_stat(struct astribank_device *astribank, int unit, uint8_t *maincard_version, uint8_t *status);
/* /*
* Twinstar * Twinstar