From 65c4b127056ae883dab3c9db1208be95057771a2 Mon Sep 17 00:00:00 2001 From: Guillaume Knispel Date: Sun, 17 Oct 2010 19:11:03 +0200 Subject: activate Ve890 TDM port (#1) with xivo_tdm --- xivovp/base.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 59 insertions(+), 12 deletions(-) (limited to 'xivovp/base.c') diff --git a/xivovp/base.c b/xivovp/base.c index 59a4b0d..cce68f0 100644 --- a/xivovp/base.c +++ b/xivovp/base.c @@ -7,6 +7,10 @@ #include +#include + +#define XIVO_VE890_TDM_PORT 1 + #include "vp_api.h" #include "EVB_Le71HR8921G_rev_E_2M048.h" @@ -43,6 +47,9 @@ MODULE_PARM_DESC(traces_vanish, enum xivovp_line_type { FXS_LINE = 0, FXO_LINE = 1 }; +#define FXS_TIMESLOT 1 +#define FXO_TIMESLOT 3 + struct xivovp_line { enum xivovp_line_type type; @@ -69,6 +76,8 @@ static struct xivovp { Vp890DeviceObjectType ve890_dev_obj; VpDevCtxType dev_ctx; + + struct xivo_tdm_port *tdm_port; } xivovp; struct timer_list rxtx_timer; @@ -218,10 +227,14 @@ static void vp_post_init(VpEventType *event) { VpStatusType vpst; - VpOptionTimeslotType timeslot = { - .tx = 12, - .rx = 12, + VpOptionTimeslotType fxs_timeslot = { + .tx = FXS_TIMESLOT, + .rx = FXS_TIMESLOT, }; + VpOptionTimeslotType fxo_timeslot = { + .tx = FXO_TIMESLOT, + .rx = FXO_TIMESLOT, + } VpOptionEventMaskType event_mask = { .faults = 0, .signaling = 0, @@ -239,15 +252,16 @@ static void vp_post_init(VpEventType *event) printk(KERN_ERR DRV_NAME ": VpSetOption VP_OPTION_ID_EVENT_MASK returned %d\n", (int)vpst); } - vpst = VpSetOption(NULL, event->pDevCtx, + + /* FXS */ + vpst = VpSetOption(&xivovp.line[FXS_LINE].vp_ctx, NULL, VP_OPTION_ID_TIMESLOT, - ×lot); - if (vpst != VP_STATUS_SUCCESS) { - printk(KERN_ERR DRV_NAME ": VpSetOption VP_OPTION_ID_TIMESLOT returned %d\n", + &fxs_timeslot); +// if (vpst != VP_STATUS_SUCCESS) { + printk(KERN_ERR DRV_NAME ": XXXXXXXXXXXXXXXXX VpSetOption FXS VP_OPTION_ID_TIMESLOT returned %d\n", (int)vpst); - } +// } - /* FXS */ vpst = VpSetLineState(&xivovp.line[FXS_LINE].vp_ctx, VP_LINE_OHT); if (vpst != VP_STATUS_SUCCESS) { @@ -262,6 +276,14 @@ static void vp_post_init(VpEventType *event) } /* FXO */ + vpst = VpSetOption(&xivovp.line[FXO_LINE].vp_ctx, NULL, + VP_OPTION_ID_TIMESLOT, + &fxo_timeslot); +// if (vpst != VP_STATUS_SUCCESS) { + printk(KERN_ERR DRV_NAME ": XXXXXXXXXXXXXXXXX VpSetOption FXO VP_OPTION_ID_TIMESLOT returned %d\n", + (int)vpst); +// } + vpst = VpSetLineState(&xivovp.line[FXO_LINE].vp_ctx, VP_LINE_FXO_OHT); if (vpst != VP_STATUS_SUCCESS) { @@ -516,7 +538,7 @@ span_init(void) static int xivovp_init(void) { - /* this is simple because no dynamic alloc */ + int rc; init_timer(&xivovp.vp_tick_timer); xivovp.vp_tick_timer.function = vp_tick; @@ -529,9 +551,33 @@ xivovp_init(void) xivovp.line[FXS_LINE].type = FXS_LINE; xivovp.line[FXO_LINE].type = FXO_LINE; + xivovp.tdm_port = xivo_tdm_get_port(XIVO_VE890_TDM_PORT); + if (!xivovp.tdm_port) { + printk(KERN_ERR "%s: could not get Ve890 TDM port\n", __func__); + return -EIO; + } + + if ((rc = xivo_tdm_config_port(xivovp.tdm_port, + LE89316_MEGREZ_PROTO_XIVO_CONFIG)) < 0) { + printk(KERN_ERR "%s: xivo_tdm_config_port returned %d\n", + __func__, rc); + xivo_tdm_put_port(xivovp.tdm_port); + xivovp.tdm_port = NULL; + return rc; + } + return 0; } +static void +xivovp_cleanup(void) +{ + if (xivovp.tdm_port) { + xivo_tdm_put_port(xivovp.tdm_port); + xivovp.tdm_port = NULL; + } +} + static int vp_init(void) { @@ -635,9 +681,9 @@ test_evb_ve890_init(void) err_dahdi_init: /* nothing */ - err_xivovp_init: - /* nothing */ err_vp_init: + xivovp_cleanup(); + err_xivovp_init: tlp_spidev_exit(); err_spidev_init: return rc; @@ -654,6 +700,7 @@ test_evb_ve890_exit(void) del_timer_sync(&rxtx_timer); /* XXX : TODO update upstream Linux doc of del_timer_sync */ + xivovp_cleanup(); tlp_spidev_exit(); } -- cgit v1.2.3