summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShaun Ruffell <sruffell@digium.com>2011-02-16 17:19:53 -0600
committerShaun Ruffell <sruffell@digium.com>2011-04-15 14:19:00 -0500
commit7a3366a637242abb009bf9d3c7b708d80a5f1aee (patch)
tree206ac44ed21f01da210b8cc92b538463790379d7
parentfe07775b1489b7f9645c1b427c547afaf4939a71 (diff)
wctdm24xxp: Cleanup in wctdm_identify_modules.
Trivial reformatting that preps it for some parallelizing the module loads. Signed-off-by: Shaun Ruffell <sruffell@digium.com>
-rw-r--r--drivers/dahdi/wctdm24xxp/base.c183
1 files changed, 100 insertions, 83 deletions
diff --git a/drivers/dahdi/wctdm24xxp/base.c b/drivers/dahdi/wctdm24xxp/base.c
index efce940..b04a908 100644
--- a/drivers/dahdi/wctdm24xxp/base.c
+++ b/drivers/dahdi/wctdm24xxp/base.c
@@ -4097,50 +4097,51 @@ static void wctdm_initialize_vpm(struct wctdm *wc)
wc->ctlreg |= 0x10;
}
-static int wctdm_identify_modules(struct wctdm *wc)
+static void wctdm_identify_modules(struct wctdm *wc)
{
int x;
unsigned long flags;
wc->ctlreg = 0x00;
+ /*
+ * This looks a little weird.
+ *
+ * There are only 8 physical ports on the TDM/AEX800, but the code
+ * immediately below sets 24 modules up. This has to do with the
+ * altcs magic that allows us to have single-port and quad-port
+ * modules on these products. The variable "mods_per_board" is set to
+ * the appropriate value just below the next code block.
+ *
+ * Now why this is important: The FXS modules come out of reset in a
+ * two-byte, non-chainable SPI mode. This is currently incompatible
+ * with how we do things, so we need to set them to a chained, 3-byte
+ * command mode. This is done by setting the module type to FXSINIT
+ * for a little while so that cmd_dequeue will initialize the SLIC
+ * into the appropriate mode.
+ *
+ * This "go to 3-byte chained mode" command, however, wreaks havoc
+ * with HybridBRI.
+ *
+ * The solution: Since HybridBRI is only designed to work in an 8-port
+ * card, and since the single-port modules "show up" in SPI slots >= 8
+ * in these cards, we only set SPI slots 8-23 to FXSINIT. The
+ * HybridBRI will never see the command that causes it to freak out
+ * and the single-port FXS cards get what they need so that when we
+ * probe with altcs we see them.
+ */
+
/* Make sure all units go into daisy chain mode */
spin_lock_irqsave(&wc->reglock, flags);
-
-/*
- * This looks a little weird.
- *
- * There are only 8 physical ports on the TDM/AEX800, but the code immediately
- * below sets 24 modules up. This has to do with the altcs magic that allows us
- * to have single-port and quad-port modules on these products.
- * The variable "mods_per_board" is set to the appropriate value just below the
- * next code block.
- *
- * Now why this is important:
- * The FXS modules come out of reset in a two-byte, non-chainable SPI mode.
- * This is currently incompatible with how we do things, so we need to set
- * them to a chained, 3-byte command mode. This is done by setting the module
- * type to FXSINIT for a little while so that cmd_dequeue will
- * initialize the SLIC into the appropriate mode.
- *
- * This "go to 3-byte chained mode" command, however, wreaks havoc with HybridBRI.
- *
- * The solution:
- * Since HybridBRI is only designed to work in an 8-port card, and since the single-port
- * modules "show up" in SPI slots >= 8 in these cards, we only set SPI slots 8-23 to
- * FXSINIT. The HybridBRI will never see the command that causes it to freak
- * out and the single-port FXS cards get what they need so that when we probe with altcs
- * we see them.
- */
-
- for (x = 0; x < wc->mods_per_board; x++)
+ for (x = 0; x < ARRAY_SIZE(wc->mods); x++)
wc->mods[x].type = FXSINIT;
-
spin_unlock_irqrestore(&wc->reglock, flags);
-/* Wait just a bit; this makes sure that cmd_dequeue is emitting SPI commands in the appropriate mode(s). */
+ /* Wait just a bit; this makes sure that cmd_dequeue is emitting SPI
+ * commands in the appropriate mode(s). */
msleep(20);
-/* Now that all the cards have been reset, we can stop checking them all if there aren't as many */
+ /* Now that all the cards have been reset, we can stop checking them
+ * all if there aren't as many */
spin_lock_irqsave(&wc->reglock, flags);
wc->mods_per_board = wc->desc->ports;
spin_unlock_irqrestore(&wc->reglock, flags);
@@ -4148,12 +4149,14 @@ static int wctdm_identify_modules(struct wctdm *wc)
/* Reset modules */
for (x = 0; x < wc->mods_per_board; x++) {
struct wctdm_module *const mod = &wc->mods[x];
- int sane = 0, ret = 0, readi = 0;
+ enum {SANE = 1, UNKNOWN = 0};
+ int ret = 0, readi = 0;
if (fatal_signal_pending(current))
break;
retry:
- if (!(ret = wctdm_init_proslic(wc, mod, 0, 0, sane))) {
+ ret = wctdm_init_proslic(wc, mod, 0, 0, UNKNOWN);
+ if (!ret) {
if (debug & DEBUG_CARD) {
readi = wctdm_getreg(wc, mod, LOOP_I_LIMIT);
dev_info(&wc->vb.pdev->dev,
@@ -4162,70 +4165,84 @@ retry:
}
dev_info(&wc->vb.pdev->dev,
"Port %d: Installed -- AUTO FXS/DPO\n", x + 1);
- } else {
- if (ret != -2) {
- sane = 1;
- /* Init with Manual Calibration */
- if (!wctdm_init_proslic(wc, mod, 0, 1, sane)) {
-
- if (debug & DEBUG_CARD) {
- readi = wctdm_getreg(wc, mod, LOOP_I_LIMIT);
- dev_info(&wc->vb.pdev->dev, "Proslic module %d loop current is %dmA\n", x, ((readi*3)+20));
- }
+ continue;
+ }
- dev_info(&wc->vb.pdev->dev, "Port %d: Installed -- MANUAL FXS\n",x + 1);
- } else {
- dev_notice(&wc->vb.pdev->dev, "Port %d: FAILED FXS (%s)\n", x + 1, fxshonormode ? fxo_modes[_opermode].name : "FCC");
+ if (ret != -2) {
+ /* Init with Manual Calibration */
+ if (!wctdm_init_proslic(wc, mod, 0, 1, SANE)) {
+
+ if (debug & DEBUG_CARD) {
+ readi = wctdm_getreg(wc, mod,
+ LOOP_I_LIMIT);
+ dev_info(&wc->vb.pdev->dev,
+ "Proslic module %d loop "
+ "current is %dmA\n", x,
+ ((readi*3)+20));
}
- } else if (!(ret = wctdm_init_voicedaa(wc, mod, 0, 0, sane))) {
- dev_info(&wc->vb.pdev->dev,
- "Port %d: Installed -- AUTO FXO "
- "(%s mode)\n", x + 1,
- fxo_modes[_opermode].name);
- } else if (!wctdm_init_qrvdri(wc, x)) {
- dev_info(&wc->vb.pdev->dev,
- "Port %d: Installed -- QRV DRI card\n", x + 1);
- } else if (is_hx8(wc) && !wctdm_init_b400m(wc, x)) {
dev_info(&wc->vb.pdev->dev,
- "Port %d: Installed -- BRI "
- "quad-span module\n", x + 1);
+ "Port %d: Installed -- MANUAL FXS\n",
+ x + 1);
} else {
- if ((wc->desc->ports != 24) &&
- ((x & 0x3) == 1) && !mod->altcs) {
+ dev_notice(&wc->vb.pdev->dev,
+ "Port %d: FAILED FXS (%s)\n",
+ x + 1, fxshonormode ?
+ fxo_modes[_opermode].name : "FCC");
+ }
+ continue;
+ }
- spin_lock_irqsave(&wc->reglock, flags);
- mod->altcs = 2;
+ ret = wctdm_init_voicedaa(wc, mod, 0, 0, UNKNOWN);
+ if (!ret) {
+ dev_info(&wc->vb.pdev->dev, "Port %d: Installed -- "
+ "AUTO FXO (%s mode)\n", x + 1,
+ fxo_modes[_opermode].name);
+ continue;
+ }
- if (wc->desc->ports == 4) {
- wc->mods[x+1].altcs = 3;
- wc->mods[x+2].altcs = 3;
- }
+ if (!wctdm_init_qrvdri(wc, x)) {
+ dev_info(&wc->vb.pdev->dev,
+ "Port %d: Installed -- QRV DRI card\n", x + 1);
+ continue;
+ }
- mod->type = FXSINIT;
- spin_unlock_irqrestore(&wc->reglock, flags);
+ if (is_hx8(wc) && !wctdm_init_b400m(wc, x)) {
+ dev_info(&wc->vb.pdev->dev, "Port %d: Installed -- BRI "
+ "quad-span module\n", x + 1);
+ continue;
+ }
- msleep(20);
+ if ((wc->desc->ports != 24) && ((x&0x3) == 1) && !mod->altcs) {
- spin_lock_irqsave(&wc->reglock, flags);
- mod->type = FXS;
- spin_unlock_irqrestore(&wc->reglock, flags);
+ spin_lock_irqsave(&wc->reglock, flags);
+ mod->altcs = 2;
- if (debug & DEBUG_CARD)
- dev_info(&wc->vb.pdev->dev, "Trying port %d with alternate chip select\n", x + 1);
- goto retry;
+ if (wc->desc->ports == 4) {
+ wc->mods[x+1].altcs = 3;
+ wc->mods[x+2].altcs = 3;
+ }
- } else {
- dev_info(&wc->vb.pdev->dev,
- "Port %d: Not installed\n",
- x + 1);
- mod->type = NONE;
- }
+ mod->type = FXSINIT;
+ spin_unlock_irqrestore(&wc->reglock, flags);
+
+ msleep(20);
+
+ spin_lock_irqsave(&wc->reglock, flags);
+ mod->type = FXS;
+ spin_unlock_irqrestore(&wc->reglock, flags);
+
+ if (debug & DEBUG_CARD) {
+ dev_info(&wc->vb.pdev->dev,
+ "Trying port %d with alternate chip "
+ "select\n", x + 1);
}
+ goto retry;
}
- } /* for (x...) */
- return 0;
+ mod->type = NONE;
+ dev_info(&wc->vb.pdev->dev, "Port %d: Not installed\n", x + 1);
+ } /* for (x...) */
}
static struct pci_driver wctdm_driver;