summaryrefslogtreecommitdiff
path: root/xpp/mpptalk.c
diff options
context:
space:
mode:
authorTzafrir Cohen <tzafrir.cohen@xorcom.com>2012-03-15 20:43:18 +0000
committerTzafrir Cohen <tzafrir.cohen@xorcom.com>2012-03-15 20:43:18 +0000
commit4f5d4f0b197b12f93a839c3d706d1e58fc764500 (patch)
treeebc616adef51092e3b03627566779ac539ef30e4 /xpp/mpptalk.c
parent5a21f60998533b80e220e8c660f0f1b1387e736a (diff)
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.asterisk.org/svn/dahdi/tools/trunk@10501 a0bf4364-ded3-4de4-8d8a-66a801d63aff
Diffstat (limited to 'xpp/mpptalk.c')
-rw-r--r--xpp/mpptalk.c68
1 files changed, 47 insertions, 21 deletions
diff --git a/xpp/mpptalk.c b/xpp/mpptalk.c
index 6b33743..14de689 100644
--- a/xpp/mpptalk.c
+++ b/xpp/mpptalk.c
@@ -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;
-
- 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);
+ } PACKED;
+ struct card_info_command ci_send;
+ struct card_info_command ci_recv;
+ int ret;
+
+ 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;
}