diff options
author | tzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2006-11-06 21:18:42 +0000 |
---|---|---|
committer | tzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2006-11-06 21:18:42 +0000 |
commit | 4953605453a7f7f1da8c70c4c12a4b557cfc2c24 (patch) | |
tree | 0d1bd64cb09f75bf0c7aca3b17820738965a0f77 /xpp/xproto.c | |
parent | 1148b31f800c4a280c9a26592a18d4478afc1a82 (diff) |
r1557@boole: tzafrir | 2006-11-06 20:12:16 +0200
Merging xpp driver release 1.2 (rev. 2569), originally team/tzafrir/xpp_1.2
* Should build well. Almost final.
* genzaptelconf: Also work when zap_autoreg=0
* README.Astribank updated for rev. 1.2.
* xpp/utils/Makefile: Use $< with cc -c
* Get xpp/utils configuration from autoconf (without changesin top dir)
git-svn-id: http://svn.digium.com/svn/zaptel/trunk@1563 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'xpp/xproto.c')
-rw-r--r-- | xpp/xproto.c | 46 |
1 files changed, 40 insertions, 6 deletions
diff --git a/xpp/xproto.c b/xpp/xproto.c index ff91c58..ebd9bba 100644 --- a/xpp/xproto.c +++ b/xpp/xproto.c @@ -26,6 +26,7 @@ #include "xbus-core.h" #include "zap_debug.h" #include <linux/module.h> +#include <linux/delay.h> static const char rcsid[] = "$Id$"; @@ -40,19 +41,19 @@ static const xproto_table_t *xprotocol_tables[XPD_TYPE_NOMODULE]; bool valid_xpd_addr(const xpd_addr_t *addr) { - return ((addr->subunit & ~0x1) == 0) && ((addr->unit & ~0x3) == 0); + return ((addr->subunit & ~BITMASK(SUBUNIT_BITS)) == 0) && ((addr->unit & ~BITMASK(UNIT_BITS)) == 0); } int xpd_addr2num(const xpd_addr_t *addr) { BUG_ON(!valid_xpd_addr(addr)); - return addr->unit + addr->subunit * MAX_UNIT; + return addr->unit | (addr->subunit << UNIT_BITS); } void xpd_set_addr(xpd_addr_t *addr, int xpd_num) { - addr->unit = xpd_num % MAX_UNIT; - addr->subunit = xpd_num / MAX_UNIT; + addr->unit = xpd_num & BITMASK(UNIT_BITS); + addr->subunit = (xpd_num >> UNIT_BITS) & BITMASK(SUBUNIT_BITS); } @@ -224,13 +225,15 @@ out: void dump_packet(const char *msg, xpacket_t *packet, bool print_dbg) { byte op = packet->content.opcode; + byte *addr = (byte *)&packet->content.addr; if(!print_dbg) return; - DBG("%s: U=0x%1X S=0x%1X OP=0x%02X LEN=%d\n", + DBG("%s: XPD=%1X-%1X (0x%X) OP=0x%02X LEN=%d\n", msg, packet->content.addr.unit, packet->content.addr.subunit, + *addr, op, (byte)packet->datalen); #if VERBOSE_DEBUG @@ -258,6 +261,36 @@ void dump_packet(const char *msg, xpacket_t *packet, bool print_dbg) #endif } +void dump_reg_cmd(const char msg[], reg_cmd_t *regcmd) +{ + char action; + char mode; + byte chipsel; + byte regnum; + byte data_low; + byte data_high; + + if(regcmd->bytes != sizeof(*regcmd) - 1) { /* The size byte is not included */ + NOTICE("%s: Wrong size: regcmd->bytes = %d\n", __FUNCTION__, regcmd->bytes); + return; + } + action = (REG_FIELD(regcmd, chipsel) & 0x80) ? 'R' : 'W'; + chipsel = REG_FIELD(regcmd, chipsel) & ~0x80; + if(REG_FIELD(regcmd, regnum) == 0x1E) { + mode = 'I'; + regnum = REG_FIELD(regcmd, subreg); + data_low = REG_FIELD(regcmd, data_low); + data_high = REG_FIELD(regcmd, data_high); + } else { + mode = 'D'; + regnum = REG_FIELD(regcmd, regnum); + data_low = REG_FIELD(regcmd, data_low); + data_high = 0; + } + DBG("%d %c%c %02X %02X %02X # m=%d eof=%d\n", chipsel, action, mode, regnum, + data_low, data_high, regcmd->multibyte, regcmd->eoframe); +} + const char *xproto_name(xpd_type_t xpd_type) { const xproto_table_t *proto_table; @@ -302,7 +335,7 @@ int xproto_register(const xproto_table_t *proto_table) // CHECK_XOP(card_ioctl); // optional method -- call after testing CHECK_XOP(SYNC_SOURCE); CHECK_XOP(PCM_WRITE); - CHECK_XOP(CHAN_ENABLE); + CHECK_XOP(XPD_STATE); CHECK_XOP(CHAN_CID); CHECK_XOP(RING); CHECK_XOP(RELAY_OUT); @@ -330,6 +363,7 @@ void xproto_unregister(const xproto_table_t *proto_table) } EXPORT_SYMBOL(dump_packet); +EXPORT_SYMBOL(dump_reg_cmd); EXPORT_SYMBOL(packet_receive); EXPORT_SYMBOL(valid_xpd_addr); EXPORT_SYMBOL(xpd_addr2num); |