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)
{
uint8_t unit;
uint8_t card_status;
uint8_t card_type;
int ret;
struct eeprom_table eeprom_table;
struct capabilities capabilities;
@ -95,6 +92,12 @@ static int show_hardware(struct astribank_device *astribank)
if(astribank->eeprom_type == EEPROM_TYPE_LARGE) {
show_capabilities(&capabilities, stdout);
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++) {
ret = mpps_card_info(astribank, unit, &card_type, &card_status);
if(ret < 0)
@ -103,6 +106,14 @@ static int show_hardware(struct astribank_device *astribank)
((card_type >> 4) & 0xF), (card_type & 0xF),
((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);
if(ret < 0)

View File

@ -95,6 +95,9 @@ struct mpp_header {
enum mpp_ser_op {
SER_CARD_INFO_GET = 0x1,
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 */

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)
{
struct card_info_send {
/*
* Serial commands must have equal send/receive size
*/
struct card_info_command {
uint8_t ser_op;
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_status; /* BIT(0) - PIC burned */
} *card_info_recv;
uint8_t in[sizeof(struct card_info_recv)];
uint8_t out[sizeof(struct card_info_recv)];
int len;
int ret;
} PACKED;
struct card_info_command ci_send;
struct card_info_command ci_recv;
int ret;
len = sizeof(struct card_info_recv);
memset(in, 0, len);
memset(out, 0, len);
card_info_send = (struct card_info_send *)&in;
card_info_recv = (struct card_info_recv *)&out;
card_info_send->ser_op = SER_CARD_INFO_GET;
card_info_send->addr = (unit << 4); /* low nibble is subunit */
ret = mpp_serial_cmd(astribank, in, out, len);
memset(&ci_send, 0, sizeof(ci_send));
memset(&ci_recv, 0, sizeof(ci_recv));
ci_send.ser_op = SER_CARD_INFO_GET;
ci_send.addr = (unit << 4); /* low nibble is subunit */
ret = mpp_serial_cmd(astribank,
(uint8_t *)&ci_send,
(uint8_t *)&ci_recv,
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)
return ret;
*card_type = card_info_recv->card_full_type;
*card_status = card_info_recv->card_status;
*fpga_configuration = fs_recv.fpga_configuration;
*status = fs_recv.status;
return 0;
}

View File

@ -69,6 +69,7 @@ int twinstar_show(struct astribank_device *astribank, FILE *fp);
* Serial commands to FPGA
*/
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