summaryrefslogtreecommitdiff
path: root/drivers/dahdi/voicebus
diff options
context:
space:
mode:
authorShaun Ruffell <sruffell@digium.com>2011-06-02 20:02:28 +0000
committerShaun Ruffell <sruffell@digium.com>2011-06-02 20:02:28 +0000
commitb7fc6dac6f4931514221a5ee75e5db28851d08fe (patch)
treea94bcbcda3abb709659fe9a75b6d8600978f0d33 /drivers/dahdi/voicebus
parent87c911c8248a41c5e57bd7c19dad106a1b30d531 (diff)
wcte12xp, wctdm24xxp: Separate test for VPMADT032 and initialization.
Part of increasing system startup speed. Splitting these two operations facilitate checking if there is a module present synchronously on driver load from the actual load of the firmware and configuration of the channels. This will allow the presence of the VPM module to be flagged on the span before registration, but load and configuration can happen in the background. When the modules are eventually loaded via udev, there will be enough time from the time the drivers are loaded to when dahdi_cfg will run to complete the firmware load, eliminating the need to block the driver here. Signed-off-by: Shaun Ruffell <sruffell@digium.com> git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@9951 a0bf4364-ded3-4de4-8d8a-66a801d63aff
Diffstat (limited to 'drivers/dahdi/voicebus')
-rw-r--r--drivers/dahdi/voicebus/GpakCust.c81
-rw-r--r--drivers/dahdi/voicebus/GpakCust.h3
2 files changed, 54 insertions, 30 deletions
diff --git a/drivers/dahdi/voicebus/GpakCust.c b/drivers/dahdi/voicebus/GpakCust.c
index 9a36a2f..ebd60da 100644
--- a/drivers/dahdi/voicebus/GpakCust.c
+++ b/drivers/dahdi/voicebus/GpakCust.c
@@ -513,6 +513,11 @@ vpmadt032_alloc(struct vpmadt032_options *options)
sema_init(&vpm->sem, 1);
vpm->curpage = 0x80;
vpm->dspid = -1;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
+ INIT_WORK(&vpm->work, vpmadt032_bh, vpm);
+#else
+ INIT_WORK(&vpm->work, vpmadt032_bh);
+#endif
/* Do not use the global workqueue for processing these events. Some of
* the operations can take 100s of ms, most of that time spent sleeping.
@@ -605,36 +610,26 @@ int vpmadt032_reset(struct vpmadt032 *vpm)
}
EXPORT_SYMBOL(vpmadt032_reset);
-int
-vpmadt032_init(struct vpmadt032 *vpm, struct voicebus *vb)
+/**
+ * vpmadt032_test - Check if there is a VPMADT032 present on voicebus device.
+ * @vpm: Allocated with vpmadt032_alloc previously.
+ * @vb: Voicebus structure to test on.
+ *
+ * Returns 0 if there is a device, otherwise -ENODEV.
+ *
+ */
+int vpmadt032_test(struct vpmadt032 *vpm, struct voicebus *vb)
{
- int i;
- u16 reg;
- int res = -EFAULT;
- unsigned long stoptime;
- struct device *dev;
- gpakPingDspStat_t pingstatus;
-
- BUG_ON(!vpm->setchanconfig_from_state);
- BUG_ON(!vpm->wq);
- BUG_ON(!vb);
+ u8 reg;
+ int i, x;
+ struct device *dev = &vb->pdev->dev;
vpm->vb = vb;
- might_sleep();
-
- dev = &vpm->vb->pdev->dev;
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
- INIT_WORK(&vpm->work, vpmadt032_bh, vpm);
-#else
- INIT_WORK(&vpm->work, vpmadt032_bh);
-#endif
if (vpm->options.debug & DEBUG_VPMADT032_ECHOCAN)
dev_info(dev, "VPMADT032 Testing page access: ");
for (i = 0; i < 0xf; i++) {
- int x;
for (x = 0; x < 3; x++) {
vpmadt032_setpage(vpm, i);
reg = vpmadt032_getpage(vpm);
@@ -645,14 +640,42 @@ vpmadt032_init(struct vpmadt032 *vpm, struct voicebus *vb)
"VPMADT032 Failed HI page " \
"test\n", i, reg);
}
- res = -ENODEV;
- goto failed_exit;
+ return -ENODEV;
}
}
}
if (vpm->options.debug & DEBUG_VPMADT032_ECHOCAN)
- dev_info(&vpm->vb->pdev->dev, "Passed\n");
+ dev_info(dev, "Passed\n");
+
+ return 0;
+}
+EXPORT_SYMBOL(vpmadt032_test);
+
+/**
+ * vpmadt032_init - Initialize and load VPMADT032 firmware.
+ * @vpm: Allocated with vpmadt032_alloc previously.
+ *
+ * Returns 0 on success. This must be called after vpmadt032_test already
+ * checked if there appears to be a VPMADT032 installed on the board.
+ *
+ */
+int vpmadt032_init(struct vpmadt032 *vpm)
+{
+ int i;
+ u16 reg;
+ int res = -EFAULT;
+ unsigned long stoptime;
+ struct device *dev;
+ gpakPingDspStat_t pingstatus;
+
+ BUG_ON(!vpm->setchanconfig_from_state);
+ BUG_ON(!vpm->wq);
+ BUG_ON(!vpm->vb);
+
+ might_sleep();
+
+ dev = &vpm->vb->pdev->dev;
stoptime = jiffies + 3*HZ;
set_bit(VPM150M_HPIRESET, &vpm->control);
@@ -699,14 +722,14 @@ vpmadt032_init(struct vpmadt032 *vpm, struct voicebus *vb)
goto failed_exit;
}
- res = vpmadtreg_loadfirmware(vb);
+ res = vpmadtreg_loadfirmware(vpm->vb);
if (res) {
- dev_info(&vb->pdev->dev, "Failed to load the firmware.\n");
+ dev_info(&vpm->vb->pdev->dev, "Failed to load the firmware.\n");
return res;
}
vpm->curpage = -1;
- dev_info(&vb->pdev->dev, "Booting VPMADT032\n");
+ dev_info(&vpm->vb->pdev->dev, "Booting VPMADT032\n");
stoptime = jiffies + 3*HZ;
set_bit(VPM150M_SWRESET, &vpm->control);
@@ -723,7 +746,7 @@ vpmadt032_init(struct vpmadt032 *vpm, struct voicebus *vb)
pingstatus = gpakPingDsp(vpm->dspid, &vpm->version);
if (!pingstatus) {
- dev_info(&vb->pdev->dev, "VPM present and operational "
+ dev_info(&vpm->vb->pdev->dev, "VPM present and operational "
"(Firmware version %x)\n", vpm->version);
} else {
dev_notice(&vpm->vb->pdev->dev, "VPMADT032 Failed! Unable to ping the DSP (%d)!\n", pingstatus);
diff --git a/drivers/dahdi/voicebus/GpakCust.h b/drivers/dahdi/voicebus/GpakCust.h
index bd3308e..758bc28 100644
--- a/drivers/dahdi/voicebus/GpakCust.h
+++ b/drivers/dahdi/voicebus/GpakCust.h
@@ -137,7 +137,8 @@ struct dahdi_echocanparam;
struct dahdi_echocan_state;
char vpmadt032tone_to_zaptone(GpakToneCodes_t tone);
-int vpmadt032_init(struct vpmadt032 *vpm, struct voicebus *vb);
+int vpmadt032_test(struct vpmadt032 *vpm, struct voicebus *vb);
+int vpmadt032_init(struct vpmadt032 *vpm);
int vpmadt032_reset(struct vpmadt032 *vpm);
struct vpmadt032 *vpmadt032_alloc(struct vpmadt032_options *options);
void vpmadt032_free(struct vpmadt032 *vpm);