xpp: reset Astribank SPI busses

* A driver reload should reset Astribank hardware
* This patch send an SPI reset after we get AB_DESCRIPTION reply from Astribank

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/linux/trunk@10474 a0bf4364-ded3-4de4-8d8a-66a801d63aff
This commit is contained in:
Oron Peled 2012-03-15 12:49:55 +00:00 committed by Tzafrir Cohen
parent e07a70f403
commit ee8bc184da
2 changed files with 26 additions and 6 deletions

View File

@ -437,19 +437,37 @@ EXPORT_SYMBOL(xpp_register_request);
return 0; return 0;
} }
/* 0x23 */ HOSTCMD(GLOBAL, RESET_SYNC_COUNTERS) /*
* Wrapper for different types of xbus reset
*/
static int send_xbus_reset(xbus_t *xbus, uint8_t reset_mask)
{ {
xframe_t *xframe; xframe_t *xframe;
xpacket_t *pack; xpacket_t *pack;
BUG_ON(!xbus); BUG_ON(!xbus);
//XBUS_DBG(SYNC, xbus, "\n"); XFRAME_NEW_CMD(xframe, pack, xbus, GLOBAL, XBUS_RESET, 0);
XFRAME_NEW_CMD(xframe, pack, xbus, GLOBAL, RESET_SYNC_COUNTERS, 0); RPACKET_FIELD(pack, GLOBAL, XBUS_RESET, mask) = reset_mask;
RPACKET_FIELD(pack, GLOBAL, RESET_SYNC_COUNTERS, mask) = 0x10;
send_cmd_frame(xbus, xframe); send_cmd_frame(xbus, xframe);
return 0; return 0;
} }
/* 0x23 */ HOSTCMD(GLOBAL, RESET_SPI)
{
XBUS_DBG(DEVICES, xbus, "Sending SPI reset\n");
/* toggle reset line */
send_xbus_reset(xbus, 0x04);
send_xbus_reset(xbus, 0x00);
return 0;
}
/* 0x23 */ HOSTCMD(GLOBAL, RESET_SYNC_COUNTERS)
{
//XBUS_DBG(SYNC, xbus, "\n");
return send_xbus_reset(xbus, 0x10);
}
/*---------------- GLOBAL: Astribank Reply Handlers -----------------------*/ /*---------------- GLOBAL: Astribank Reply Handlers -----------------------*/
HANDLER_DEF(GLOBAL, NULL_REPLY) HANDLER_DEF(GLOBAL, NULL_REPLY)
@ -542,6 +560,7 @@ HANDLER_DEF(GLOBAL, AB_DESCRIPTION)
list_add_tail(&card_desc->card_list, &worker->card_list); list_add_tail(&card_desc->card_list, &worker->card_list);
spin_unlock_irqrestore(&worker->worker_lock, flags); spin_unlock_irqrestore(&worker->worker_lock, flags);
} }
CALL_PROTO(GLOBAL, RESET_SPI, xbus, NULL);
if (!xbus_process_worker(xbus)) { if (!xbus_process_worker(xbus)) {
ret = -ENODEV; ret = -ENODEV;
goto out; goto out;

View File

@ -35,7 +35,7 @@ enum global_opcodes {
/**/ XPROTO_NAME(GLOBAL, SYNC_SOURCE) = 0x19, /**/ XPROTO_NAME(GLOBAL, SYNC_SOURCE) = 0x19,
XPROTO_NAME(GLOBAL, SYNC_REPLY) = 0x1A, XPROTO_NAME(GLOBAL, SYNC_REPLY) = 0x1A,
/**/ XPROTO_NAME(GLOBAL, ERROR_CODE) = 0x22, /**/ XPROTO_NAME(GLOBAL, ERROR_CODE) = 0x22,
XPROTO_NAME(GLOBAL, RESET_SYNC_COUNTERS) = 0x23, XPROTO_NAME(GLOBAL, XBUS_RESET) = 0x23,
XPROTO_NAME(GLOBAL, NULL_REPLY) = 0xFE, XPROTO_NAME(GLOBAL, NULL_REPLY) = 0xFE,
}; };
@ -62,12 +62,13 @@ DEF_RPACKET_DATA(GLOBAL, PCM_READ, xpp_line_t lines; __u8 pcm[PCM_CHUNKSIZE];);
DEF_RPACKET_DATA(GLOBAL, SYNC_SOURCE, __u8 sync_mode; __u8 drift;); DEF_RPACKET_DATA(GLOBAL, SYNC_SOURCE, __u8 sync_mode; __u8 drift;);
DEF_RPACKET_DATA(GLOBAL, SYNC_REPLY, __u8 sync_mode; __u8 drift;); DEF_RPACKET_DATA(GLOBAL, SYNC_REPLY, __u8 sync_mode; __u8 drift;);
DEF_RPACKET_DATA(GLOBAL, REGISTER_REPLY, reg_cmd_t regcmd;); DEF_RPACKET_DATA(GLOBAL, REGISTER_REPLY, reg_cmd_t regcmd;);
DEF_RPACKET_DATA(GLOBAL, RESET_SYNC_COUNTERS, __u8 mask;); DEF_RPACKET_DATA(GLOBAL, XBUS_RESET, __u8 mask;);
DEF_RPACKET_DATA(GLOBAL, ERROR_CODE, __u8 category_code; __u8 errorbits; DEF_RPACKET_DATA(GLOBAL, ERROR_CODE, __u8 category_code; __u8 errorbits;
__u8 bad_packet[0];); __u8 bad_packet[0];);
/* 0x07 */ DECLARE_CMD(GLOBAL, AB_REQUEST); /* 0x07 */ DECLARE_CMD(GLOBAL, AB_REQUEST);
/* 0x19 */ DECLARE_CMD(GLOBAL, SYNC_SOURCE, enum sync_mode mode, int drift); /* 0x19 */ DECLARE_CMD(GLOBAL, SYNC_SOURCE, enum sync_mode mode, int drift);
/* 0x23 */ DECLARE_CMD(GLOBAL, RESET_SPI);
/* 0x23 */ DECLARE_CMD(GLOBAL, RESET_SYNC_COUNTERS); /* 0x23 */ DECLARE_CMD(GLOBAL, RESET_SYNC_COUNTERS);
int xpp_register_request(xbus_t *xbus, xpd_t *xpd, xportno_t portno, int xpp_register_request(xbus_t *xbus, xpd_t *xpd, xportno_t portno,