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 <tzafrir.cohen@xorcom.com>
This commit is contained in:
Dima Stoliarov
2016-01-25 16:52:14 +02:00
committed by Tzafrir Cohen
parent 14d9a53162
commit 609114c0a9
6 changed files with 29 additions and 13 deletions

View File

@@ -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;
}

View File

@@ -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 ----------------------------------*/

View File

@@ -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)

View File

@@ -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) {

View File

@@ -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,

View File

@@ -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 */
);
}