summaryrefslogtreecommitdiff
path: root/xivovp/base.c
diff options
context:
space:
mode:
authorGuillaume Knispel <gknispel@proformatique.com>2010-10-17 19:11:03 +0200
committerGuillaume Knispel <gknispel@proformatique.com>2010-10-17 19:11:03 +0200
commit65c4b127056ae883dab3c9db1208be95057771a2 (patch)
tree3c4057572497b6cd1c47e5424e346e1eb8a442b2 /xivovp/base.c
parent4a18e3117efddb2a96389607255c355c653fd319 (diff)
activate Ve890 TDM port (#1) with xivo_tdm
Diffstat (limited to 'xivovp/base.c')
-rw-r--r--xivovp/base.c71
1 files changed, 59 insertions, 12 deletions
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 <dahdi/kernel.h>
+#include <tdm/xivo_tdm_api.h>
+
+#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,
- &timeslot);
- 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();
}