From 609114c0a989276d1a63bfcba4e696d537453fc7 Mon Sep 17 00:00:00 2001 From: Dima Stoliarov Date: Mon, 25 Jan 2016 16:52:14 +0200 Subject: [PATCH] xpp: FXS: support of I/O Expander. Added do_expander field to SPI commands, in order to support an I/O Expander on FXS. Signed-off-by: Tzafrir Cohen --- drivers/dahdi/xpp/card_bri.c | 6 ++++-- drivers/dahdi/xpp/card_fxo.c | 2 +- drivers/dahdi/xpp/card_fxs.c | 7 +++++-- drivers/dahdi/xpp/card_global.c | 16 ++++++++++++---- drivers/dahdi/xpp/card_global.h | 2 +- drivers/dahdi/xpp/card_pri.c | 9 ++++++--- 6 files changed, 29 insertions(+), 13 deletions(-) diff --git a/drivers/dahdi/xpp/card_bri.c b/drivers/dahdi/xpp/card_bri.c index 027b20f..302e741 100644 --- a/drivers/dahdi/xpp/card_bri.c +++ b/drivers/dahdi/xpp/card_bri.c @@ -977,7 +977,8 @@ static int BRI_card_tick(xbus_t *xbus, xpd_t *xpd) 0, /* data_low */ 0, /* do_datah */ 0, /* data_high */ - 0 /* should_reply */ + 0, /* should_reply */ + 0 /* do_expander */ ); if (IS_NT(xpd) && nt_keepalive @@ -1426,7 +1427,8 @@ static int write_state_register(xpd_t *xpd, __u8 value) value, /* data_low */ 0, /* do_datah */ 0, /* data_high */ - 0 /* should_reply */ + 0, /* should_reply */ + 0 /* do_expander */ ); return ret; } diff --git a/drivers/dahdi/xpp/card_fxo.c b/drivers/dahdi/xpp/card_fxo.c index c386730..e100b79 100644 --- a/drivers/dahdi/xpp/card_fxo.c +++ b/drivers/dahdi/xpp/card_fxo.c @@ -100,7 +100,7 @@ enum fxo_leds { #define DAA_READ 0 #define DAA_DIRECT_REQUEST(xbus, xpd, port, writing, reg, dL) \ xpp_register_request((xbus), (xpd), (port), \ - (writing), (reg), 0, 0, (dL), 0, 0, 0) + (writing), (reg), 0, 0, (dL), 0, 0, 0, 0) /*---------------- FXO Protocol Commands ----------------------------------*/ diff --git a/drivers/dahdi/xpp/card_fxs.c b/drivers/dahdi/xpp/card_fxs.c index fc5a9af..c0b06d9 100644 --- a/drivers/dahdi/xpp/card_fxs.c +++ b/drivers/dahdi/xpp/card_fxs.c @@ -77,10 +77,13 @@ enum fxs_leds { #define SLIC_READ 0 #define SLIC_DIRECT_REQUEST(xbus, xpd, port, writing, reg, dL) \ xpp_register_request((xbus), (xpd), (port), \ - (writing), (reg), 0, 0, (dL), 0, 0, 0) + (writing), (reg), 0, 0, (dL), 0, 0, 0, 0) #define SLIC_INDIRECT_REQUEST(xbus, xpd, port, writing, reg, dL, dH) \ xpp_register_request((xbus), (xpd), (port), \ - (writing), 0x1E, 1, (reg), (dL), 1, (dH), 0) + (writing), 0x1E, 1, (reg), (dL), 1, (dH), 0, 0) +#define EXP_REQUEST(xbus, xpd, writing, reg, dL, dH) \ + xpp_register_request((xbus), (xpd), 0, \ + (writing), (reg), 1, 0, (dL), 1, (dH), 0, 1) #define RAM_REQUEST(xbus, xpd, port, writing, addr, data) \ xpp_ram_request((xbus), (xpd), (port), \ (writing), (__u8)(addr), (__u8)((addr) >> 8), (__u8)(data), (__u8)((data) >> 8), (__u8)((data) >> 16), (__u8)((data) >> 24), 0) diff --git a/drivers/dahdi/xpp/card_global.c b/drivers/dahdi/xpp/card_global.c index c5f9f1c..3828c49 100644 --- a/drivers/dahdi/xpp/card_global.c +++ b/drivers/dahdi/xpp/card_global.c @@ -97,6 +97,7 @@ static int execute_chip_command(xpd_t *xpd, const int argc, char *argv[]) int data_low; bool do_datah; int data_high; + bool do_expander = 0; int ret = -EBADR; num_args = 2; /* port + operation */ @@ -158,6 +159,12 @@ static int execute_chip_command(xpd_t *xpd, const int argc, char *argv[]) num_args++; /* register */ //XPD_DBG(REGS, xpd, "DIRECT\n"); break; + case 'X': + do_subreg = 0; + do_expander = 1; + num_args++; /* register */ + //XPD_DBG(REGS, xpd, "EXPANDER\n"); + break; case 'M': case 'm': if (op != 'W') { @@ -299,17 +306,17 @@ static int execute_chip_command(xpd_t *xpd, const int argc, char *argv[]) #if 0 XPD_DBG(REGS, xpd, "portno=%d writing=%d regnum=%d do_subreg=%d subreg=%d " - "dataL=%d do_datah=%d dataH=%d\n", + "dataL=%d do_datah=%d dataH=%d do_expander=%d\n", portno, /* portno */ writing, /* writing */ regnum, do_subreg, /* use subreg */ subreg, /* subreg */ data_low, do_datah, /* use data_high */ - data_high); + data_high, do_expander); #endif ret = xpp_register_request(xpd->xbus, xpd, portno, writing, regnum, do_subreg, subreg, - data_low, do_datah, data_high, 1); + data_low, do_datah, data_high, 1, do_expander); out: return ret; } @@ -397,7 +404,7 @@ static void global_packet_dump(const char *msg, xpacket_t *pack); int xpp_register_request(xbus_t *xbus, xpd_t *xpd, xportno_t portno, bool writing, __u8 regnum, bool do_subreg, __u8 subreg, __u8 data_low, bool do_datah, __u8 data_high, - bool should_reply) + bool should_reply, bool do_expander) { int ret = 0; xframe_t *xframe; @@ -432,6 +439,7 @@ int xpp_register_request(xbus_t *xbus, xpd_t *xpd, xportno_t portno, REG_FIELD(reg_cmd, do_datah) = do_datah; REG_FIELD(reg_cmd, data_low) = data_low; REG_FIELD(reg_cmd, data_high) = data_high; + REG_FIELD(reg_cmd, do_expander) = do_expander; if (should_reply) xpd->requested_reply = *reg_cmd; if (debug & DBG_REGS) { diff --git a/drivers/dahdi/xpp/card_global.h b/drivers/dahdi/xpp/card_global.h index 86d4431..bdd1b62 100644 --- a/drivers/dahdi/xpp/card_global.h +++ b/drivers/dahdi/xpp/card_global.h @@ -74,7 +74,7 @@ DEF_RPACKET_DATA(GLOBAL, ERROR_CODE, __u8 category_code; __u8 errorbits; int xpp_register_request(xbus_t *xbus, xpd_t *xpd, xportno_t portno, bool writing, __u8 regnum, bool do_subreg, __u8 subreg, __u8 data_low, bool do_datah, __u8 data_high, - bool should_reply); + bool should_reply, bool do_expander); int send_multibyte_request(xbus_t *xbus, unsigned unit, xportno_t portno, bool eoftx, __u8 *buf, unsigned len); int xpp_ram_request(xbus_t *xbus, xpd_t *xpd, xportno_t portno, diff --git a/drivers/dahdi/xpp/card_pri.c b/drivers/dahdi/xpp/card_pri.c index 61260db..3393f44 100644 --- a/drivers/dahdi/xpp/card_pri.c +++ b/drivers/dahdi/xpp/card_pri.c @@ -388,7 +388,8 @@ static int query_subunit(xpd_t *xpd, __u8 regnum) 0, /* data_L */ 0, /* do_datah */ 0, /* data_H */ - 0 /* should_reply */ + 0, /* should_reply */ + 0 /* do_expander */ ); } @@ -404,7 +405,8 @@ static int write_subunit(xpd_t *xpd, __u8 regnum, __u8 val) val, /* data_L */ 0, /* do_datah */ 0, /* data_H */ - 0 /* should_reply */ + 0, /* should_reply */ + 0 /* do_expander */ ); } @@ -419,7 +421,8 @@ static int pri_write_reg(xpd_t *xpd, int regnum, __u8 val) val, /* data_L */ 0, /* do_datah */ 0, /* data_H */ - 0 /* should_reply */ + 0, /* should_reply */ + 0 /* do_expander */ ); }