165 #define HFC_MULTI_VERSION "2.03"
168 #include <linux/module.h>
169 #include <linux/slab.h>
170 #include <linux/pci.h>
186 #define MAX_PORTS (8 * MAX_CARDS)
187 #define MAX_FRAGS (32 * MAX_CARDS)
192 static void ph_state_change(
struct dchannel *);
195 static int plxsd_master;
202 static int poll_timer = 6;
204 static int nt_t1_count[] = { 3840, 1920, 960, 480, 240, 120, 60, 30 };
205 #define CLKDEL_TE 0x0f
206 #define CLKDEL_NT 0x6c
230 #define HWID_MINIP4 1
231 #define HWID_MINIP8 2
232 #define HWID_MINIP16 3
235 static int HFC_cnt, E1_cnt, bmask_cnt, Port_cnt, PCM_cnt = 99;
254 #ifdef HFC_REGISTER_DEBUG
255 #define HFC_outb(hc, reg, val) \
256 (hc->HFC_outb(hc, reg, val, __func__, __LINE__))
257 #define HFC_outb_nodebug(hc, reg, val) \
258 (hc->HFC_outb_nodebug(hc, reg, val, __func__, __LINE__))
259 #define HFC_inb(hc, reg) \
260 (hc->HFC_inb(hc, reg, __func__, __LINE__))
261 #define HFC_inb_nodebug(hc, reg) \
262 (hc->HFC_inb_nodebug(hc, reg, __func__, __LINE__))
263 #define HFC_inw(hc, reg) \
264 (hc->HFC_inw(hc, reg, __func__, __LINE__))
265 #define HFC_inw_nodebug(hc, reg) \
266 (hc->HFC_inw_nodebug(hc, reg, __func__, __LINE__))
267 #define HFC_wait(hc) \
268 (hc->HFC_wait(hc, __func__, __LINE__))
269 #define HFC_wait_nodebug(hc) \
270 (hc->HFC_wait_nodebug(hc, __func__, __LINE__))
272 #define HFC_outb(hc, reg, val) (hc->HFC_outb(hc, reg, val))
273 #define HFC_outb_nodebug(hc, reg, val) (hc->HFC_outb_nodebug(hc, reg, val))
274 #define HFC_inb(hc, reg) (hc->HFC_inb(hc, reg))
275 #define HFC_inb_nodebug(hc, reg) (hc->HFC_inb_nodebug(hc, reg))
276 #define HFC_inw(hc, reg) (hc->HFC_inw(hc, reg))
277 #define HFC_inw_nodebug(hc, reg) (hc->HFC_inw_nodebug(hc, reg))
278 #define HFC_wait(hc) (hc->HFC_wait(hc))
279 #define HFC_wait_nodebug(hc) (hc->HFC_wait_nodebug(hc))
282 #ifdef CONFIG_MISDN_HFCMULTI_8xx
288 #ifdef HFC_REGISTER_DEBUG
290 const char *
function,
int line)
298 #ifdef HFC_REGISTER_DEBUG
299 HFC_inb_pcimem(
struct hfc_multi *hc,
u_char reg,
const char *
function,
int line)
307 #ifdef HFC_REGISTER_DEBUG
308 HFC_inw_pcimem(
struct hfc_multi *hc,
u_char reg,
const char *
function,
int line)
316 #ifdef HFC_REGISTER_DEBUG
317 HFC_wait_pcimem(
struct hfc_multi *hc,
const char *
function,
int line)
328 #ifdef HFC_REGISTER_DEBUG
330 const char *
function,
int line)
339 #ifdef HFC_REGISTER_DEBUG
340 HFC_inb_regio(
struct hfc_multi *hc,
u_char reg,
const char *
function,
int line)
349 #ifdef HFC_REGISTER_DEBUG
350 HFC_inw_regio(
struct hfc_multi *hc,
u_char reg,
const char *
function,
int line)
359 #ifdef HFC_REGISTER_DEBUG
360 HFC_wait_regio(
struct hfc_multi *hc,
const char *
function,
int line)
370 #ifdef HFC_REGISTER_DEBUG
373 const char *
function,
int line)
375 char regname[256] =
"",
bits[9] =
"xxxxxxxx";
379 while (hfc_register_names[++i].
name) {
380 if (hfc_register_names[i].reg == reg)
381 strcat(regname, hfc_register_names[i].name);
383 if (regname[0] ==
'\0')
384 strcpy(regname,
"register");
386 bits[7] =
'0' + (!!(val & 1));
387 bits[6] =
'0' + (!!(val & 2));
388 bits[5] =
'0' + (!!(val & 4));
389 bits[4] =
'0' + (!!(val & 8));
390 bits[3] =
'0' + (!!(val & 16));
391 bits[2] =
'0' + (!!(val & 32));
392 bits[1] =
'0' + (!!(val & 64));
393 bits[0] =
'0' + (!!(val & 128));
395 "HFC_outb(chip %d, %02x=%s, 0x%02x=%s); in %s() line %d\n",
396 hc->
id, reg, regname, val,
bits,
function, line);
400 HFC_inb_debug(
struct hfc_multi *hc,
u_char reg,
const char *
function,
int line)
402 char regname[256] =
"",
bits[9] =
"xxxxxxxx";
407 while (hfc_register_names[i++].name)
409 while (hfc_register_names[++i].name) {
410 if (hfc_register_names[i].reg == reg)
411 strcat(regname, hfc_register_names[i].name);
413 if (regname[0] ==
'\0')
414 strcpy(regname,
"register");
416 bits[7] =
'0' + (!!(val & 1));
417 bits[6] =
'0' + (!!(val & 2));
418 bits[5] =
'0' + (!!(val & 4));
419 bits[4] =
'0' + (!!(val & 8));
420 bits[3] =
'0' + (!!(val & 16));
421 bits[2] =
'0' + (!!(val & 32));
422 bits[1] =
'0' + (!!(val & 64));
423 bits[0] =
'0' + (!!(val & 128));
425 "HFC_inb(chip %d, %02x=%s) = 0x%02x=%s; in %s() line %d\n",
426 hc->
id, reg, regname, val,
bits,
function, line);
430 HFC_inw_debug(
struct hfc_multi *hc,
u_char reg,
const char *
function,
int line)
432 char regname[256] =
"";
437 while (hfc_register_names[i++].name)
439 while (hfc_register_names[++i].name) {
440 if (hfc_register_names[i].reg == reg)
441 strcat(regname, hfc_register_names[i].name);
443 if (regname[0] ==
'\0')
444 strcpy(regname,
"register");
447 "HFC_inw(chip %d, %02x=%s) = 0x%04x; in %s() line %d\n",
448 hc->
id, reg, regname, val,
function, line);
452 HFC_wait_debug(
struct hfc_multi *hc,
const char *
function,
int line)
455 hc->
id,
function, line);
564 #define MAX_TDM_CHAN 32
624 datav = data | ((
__u32) data << 8) | ((
__u32) data << 16) |
625 ((
__u32) data << 24);
680 inline unsigned short
684 unsigned short highbit;
689 addr = addr | (highbit << 8);
736 regin =
vpm_in(c, which, addr);
739 "0x%x\n", data, addr, regin);
750 unsigned int i,
x,
y;
753 for (x = 0; x <
NUM_EC; x++) {
756 ver =
vpm_in(wc, x, 0x1a0);
760 for (y = 0; y < 4; y++) {
761 vpm_out(wc, x, 0x1a8 + y, 0x00);
762 vpm_out(wc, x, 0x1ac + y, 0x00);
763 vpm_out(wc, x, 0x1b0 + y, 0x00);
767 reg =
vpm_in(wc, x, 0x1a3);
768 vpm_out(wc, x, 0x1a3, reg & ~2);
776 mask = 0x02020202 << (x * 4);
779 for (i = 0; i < 4; i++)
780 vpm_out(wc, x, 0x33 - i, (mask >> (i << 3)) & 0xff);
784 reg = 0x00 | 0x10 | 0x01;
790 reg =
vpm_in(wc, x, 0x24);
795 if (mask & (0x00000001 << i))
815 if (mask & (0x00000001 << i))
821 if (mask & (0x00000001 << i))
822 vpm_out(wc, x, 0x78 + i, 0x01);
836 if ((gpi2 & 0x3) != 0x3)
854 vpm_echocan_on(
struct hfc_multi *hc,
int ch,
int taps)
856 unsigned int timeslot;
876 timeslot = ((ch / 4) * 8) + ((ch % 4) * 4) + 1;
882 vpm_out(hc, unit, timeslot, 0x7e);
886 vpm_echocan_off(
struct hfc_multi *hc,
int ch)
888 unsigned int timeslot;
909 timeslot = ((ch / 4) * 8) + ((ch % 4) * 4) + 1;
915 vpm_out(hc, unit, timeslot, 0x01);
934 spin_lock(&plx_lock);
938 __func__, syncmaster);
942 if (
debug & DEBUG_HFCMULTI_PLXSD)
959 pv =
readl(plx_acc_32);
965 if (
debug & DEBUG_HFCMULTI_PLXSD)
967 "Schedule SYNC_I\n");
976 if (
debug & DEBUG_HFCMULTI_PLXSD)
978 "interface.\n", hc->
id, hc);
981 pv =
readl(plx_acc_32);
987 if (
debug & DEBUG_HFCMULTI_PLXSD)
994 if (
debug & DEBUG_HFCMULTI_PLXSD)
996 "id=%d (0x%p) = PCM master syncronized "
997 "with QUARTZ\n", hc->
id, hc);
1001 if (
debug & DEBUG_HFCMULTI_PLXSD)
1003 "Schedule QUARTZ for HFC-E1\n");
1006 if (
debug & DEBUG_HFCMULTI_PLXSD)
1008 "QUARTZ is automatically "
1009 "enabled by HFC-%dS\n", hc->
ctype);
1012 pv =
readl(plx_acc_32);
1018 "not happen!\n", __func__);
1020 syncmaster = newmaster;
1022 spin_unlock(&plx_lock);
1023 spin_unlock_irqrestore(&HFClock, flags);
1031 if (syncmaster ==
NULL) {
1032 if (
debug & DEBUG_HFCMULTI_PLXSD)
1034 " (id=%d)\n", __func__, hc->
id + 1,
1036 hfcmulti_resync(hc, hc, rm);
1039 if (syncmaster == hc) {
1040 if (
debug & DEBUG_HFCMULTI_PLXSD)
1042 " (id=%d)\n", __func__, hc->
id + 1,
1044 hfcmulti_resync(hc,
NULL, rm);
1054 release_io_hfcmulti(
struct hfc_multi *hc)
1073 if (
debug & DEBUG_HFCMULTI_PLXSD)
1075 __func__, hc->
id + 1);
1079 pv =
readl(plx_acc_32);
1089 if (
debug & DEBUG_HFCMULTI_INIT)
1092 spin_unlock_irqrestore(&plx_lock, plx_flags);
1112 if (
debug & DEBUG_HFCMULTI_INIT)
1129 u_long plx_flags, hfc_flags;
1138 if (
debug & DEBUG_HFCMULTI_INIT)
1141 if ((val >> 4) != 0x8 && (val >> 4) != 0
xc && (val >> 4) != 0
xe &&
1142 (val >> 1) != 0x31) {
1149 "HFC_multi: detected HFC with chip ID=0x%lx revision=%ld%s\n",
1151 " (old FIFO handling)" :
"");
1155 "HFC_multi: NOTE: Your chip is revision 0, "
1156 "ask Cologne Chip for update. Newer chips "
1157 "have a better FIFO handling. Old chips "
1158 "still work but may have slightly lower "
1159 "HDLC transmit performance.\n");
1163 "consider chip revision = %ld. The chip / "
1164 "bridge may not work.\n",
rev);
1173 if (
debug & DEBUG_HFCMULTI_INIT)
1177 hc->
hw.r_ram_sz = 1;
1184 if (
debug & DEBUG_HFCMULTI_INIT)
1188 hc->
hw.r_ram_sz = 2;
1206 if (
debug & DEBUG_HFCMULTI_PLXSD)
1208 __func__, hc->
id + 1);
1212 pv =
readl(plx_acc_32);
1222 spin_unlock_irqrestore(&plx_lock, plx_flags);
1223 if (
debug & DEBUG_HFCMULTI_INIT)
1240 if (plx_count >= 3) {
1241 if (
debug & DEBUG_HFCMULTI_PLXSD)
1243 "we disable termination\n",
1244 __func__, plx_last_hc->
id + 1);
1247 pv =
readl(plx_acc_32);
1250 spin_unlock_irqrestore(&plx_lock, plx_flags);
1251 if (
debug & DEBUG_HFCMULTI_INIT)
1253 "%s: term off: PLX_GPIO=%x\n",
1256 spin_unlock_irqrestore(&HFClock, hfc_flags);
1269 if (
debug & DEBUG_HFCMULTI_INIT)
1274 if (
debug & DEBUG_HFCMULTI_INIT)
1279 if (
debug & DEBUG_HFCMULTI_INIT)
1309 pv =
readl(plx_acc_32);
1314 if (
debug & DEBUG_HFCMULTI_INIT)
1320 if (
debug & DEBUG_HFCMULTI_INIT)
1325 spin_unlock_irqrestore(&plx_lock, plx_flags);
1330 if (hc->
slots == 32)
1332 if (hc->
slots == 64)
1334 if (hc->
slots == 128)
1344 for (i = 0; i < 256; i++) {
1354 if (
debug & DEBUG_HFCMULTI_INIT)
1356 "%s: setting double clock\n", __func__);
1376 if (
debug & DEBUG_HFCMULTI_INIT)
1378 "HFC_multi F0_CNT %ld after reset\n", val);
1379 spin_unlock_irqrestore(&hc->
lock, flags);
1385 if (
debug & DEBUG_HFCMULTI_INIT)
1387 "HFC_multi F0_CNT %ld after 10 ms (1st try)\n",
1389 if (val2 >= val + 8) {
1399 "(auto detected)\n");
1406 "pulse. Seems that controller fails.\n");
1412 "(ignoring missing PCM clock)\n");
1418 "on another Speech Design card found. "
1419 "Please be sure to connect PCM cable.\n");
1427 pv =
readl(plx_acc_32);
1431 spin_unlock_irqrestore(&plx_lock, plx_flags);
1432 if (
debug & DEBUG_HFCMULTI_INIT)
1434 "PLX_GPIO=%x\n", __func__, pv);
1438 spin_unlock_irqrestore(&hc->
lock, flags);
1444 if (
debug & DEBUG_HFCMULTI_INIT)
1446 "10 ms (2nd try)\n", val2);
1447 if (val2 >= val + 8) {
1451 "(auto detected)\n");
1453 goto controller_fail;
1463 pv =
readl(plx_acc_32);
1466 spin_unlock_irqrestore(&plx_lock, plx_flags);
1467 if (
debug & DEBUG_HFCMULTI_INIT)
1483 "(auto selected)\n", hc->
pcm);
1496 if (
debug & DEBUG_HFCMULTI_INIT)
1498 "for all B-channel\n", __func__);
1537 hc->
hw.r_st_sync = 0x10;
1543 if (
debug & DEBUG_HFCMULTI_INIT)
1545 "to port %d (0..%d)\n",
1555 if (
debug & DEBUG_HFCMULTI_INIT)
1557 hc->
hw.r_irqmsk_misc);
1563 for (i = 0; i < 256; i++) {
1567 for (i = 0; i < 256; i++) {
1571 if (rval != ((i * 3) & 0xff)) {
1573 "addr:%x val:%x should:%x\n", i, rval,
1584 if (
debug & DEBUG_HFCMULTI_INIT)
1587 spin_unlock_irqrestore(&hc->
lock, flags);
1620 unsigned long leddw;
1656 if (hc->
flash[2] >= 2048)
1658 if (hc->
flash[3] >= 2048)
1666 leds = (led[0] | (led[1]<<2) | (led[2]<<1) | (led[3]<<3))^0xF;
1679 for (i = 0; i < 4; i++) {
1682 dch = hc->
chan[(i << 2) | 2].dch;
1691 if (state == active) {
1694 if (!hc->
flash[i] &&
1699 if (hc->
flash[i] >= 2048)
1712 for (i = 0; i < 4; i++) {
1715 leds |= (0x2 << (i * 2));
1716 }
else if (led[i] == 2) {
1718 leds |= (0x1 << (i * 2));
1722 vpm_out(hc, 0, 0x1a8 + 3, leds);
1726 leds = ((led[3] > 0) << 0) | ((led[1] > 0) << 1) |
1727 ((led[0] > 0) << 2) | ((led[2] > 0) << 3) |
1728 ((led[3] & 1) << 4) | ((led[1] & 1) << 5) |
1729 ((led[0] & 1) << 6) | ((led[2] & 1) << 7);
1743 for (i = 0; i < 2; i++) {
1746 dch = hc->
chan[(i << 2) | 2].dch;
1755 if (state == active) {
1758 if (!hc->
flash[i] &&
1763 if (hc->
flash[i] >= 2048)
1774 leds = (led[0] > 0) | ((led[1] > 0) << 1) | ((led[0]&1) << 2)
1775 | ((led[1]&1) << 3);
1778 ((led[0] > 0) << 2) | ((led[1] > 0) << 3));
1780 ((led[0] & 1) << 2) | ((led[1] & 1) << 3));
1790 for (i = 0; i < 8; i++) {
1793 dch = hc->
chan[(i << 2) | 2].dch;
1802 if (state == active) {
1805 if (!hc->
flash[i] &&
1808 if (hc->
flash[i] < 1024)
1810 if (hc->
flash[i] >= 2048)
1818 leddw = lled << 24 | lled << 16 | lled << 8 | lled;
1854 for (ch = 0; ch <= 31; ch++) {
1856 bch = hc->
chan[ch].bch;
1863 if (
debug & DEBUG_HFCMULTI_DTMF)
1866 coeff = &(hc->
chan[ch].coeff[hc->
chan[ch].coeff_count * 16]);
1868 for (co = 0; co < 8; co++) {
1870 addr = hc->
DTMFbase + ((co << 7) | (ch << 2));
1877 if (
debug & DEBUG_HFCMULTI_DTMF)
1878 printk(
" %04x", w_float);
1881 mantissa = w_float & 0x0fff;
1882 if (w_float & 0x8000)
1883 mantissa |= 0xfffff000;
1884 exponent = (w_float >> 12) & 0x7;
1887 mantissa <<= (exponent - 1);
1891 coeff[co << 1] = mantissa;
1896 if (
debug & DEBUG_HFCMULTI_DTMF)
1897 printk(
" %04x", w_float);
1900 mantissa = w_float & 0x0fff;
1901 if (w_float & 0x8000)
1902 mantissa |= 0xfffff000;
1903 exponent = (w_float >> 12) & 0x7;
1906 mantissa <<= (exponent - 1);
1910 coeff[(co << 1) | 1] = mantissa;
1912 if (
debug & DEBUG_HFCMULTI_DTMF)
1913 printk(
" DTMF ready %08x %08x %08x %08x "
1914 "%08x %08x %08x %08x\n",
1915 coeff[0], coeff[1], coeff[2], coeff[3],
1916 coeff[4], coeff[5], coeff[6], coeff[7]);
1917 hc->
chan[ch].coeff_count++;
1918 if (hc->
chan[ch].coeff_count == 8) {
1919 hc->
chan[ch].coeff_count = 0;
1926 hh = mISDN_HEAD_P(skb);
1946 hfcmulti_tx(
struct hfc_multi *hc,
int ch)
1948 int i, ii,
temp, len = 0;
1952 int *txpending, slot_tx;
1958 bch = hc->
chan[ch].bch;
1959 dch = hc->
chan[ch].dch;
1960 if ((!dch) && (!bch))
1963 txpending = &hc->
chan[ch].txpending;
1964 slot_tx = hc->
chan[ch].slot_tx;
1979 if ((!len) && *txpending != 1)
1984 (hc->
chan[ch].slot_rx < 0) &&
1985 (hc->
chan[ch].slot_tx < 0))
1991 if (*txpending == 2) {
2005 "%s(card %d): reread f2 because %d!=%d\n",
2006 __func__, hc->
id + 1, temp, f2);
2009 Fspace = f2 - f1 - 1;
2038 "%d!=%d\n", __func__, hc->
id + 1, temp, z2);
2041 hc->
chan[ch].Zfill = z1 - z2;
2042 if (hc->
chan[ch].Zfill < 0)
2059 *txpending && slot_tx >= 0) {
2062 "%s: reconnecting PCM due to no "
2063 "more FIFO data: channel %d "
2065 __func__, ch, slot_tx);
2096 "underrun\n", __func__);
2099 Zspace -= (
poll >> 1);
2107 "FIFO data: channel %d slot_tx %d\n",
2108 __func__, ch, slot_tx);
2142 d = (*sp)->data +
i;
2143 if (ii - i > Zspace)
2147 "left (z1=%04x, z2=%04x) sending %d of %d bytes %s\n",
2148 __func__, hc->
id + 1, ch, Zspace, z1, z2, ii-i, len-i,
2149 temp ?
"HDLC" :
"TRANS");
2153 hc->
chan[ch].Zfill += ii -
i;
2192 hfcmulti_rx(
struct hfc_multi *hc,
int ch)
2195 int Zsize, z1, z2 = 0;
2203 bch = hc->
chan[ch].bch;
2207 }
else if (hc->
chan[ch].dch) {
2208 dch = hc->
chan[ch].dch;
2219 (hc->
chan[ch].slot_rx < 0) &&
2220 (hc->
chan[ch].slot_tx < 0))
2227 if (hc->
chan[ch].rx_off) {
2236 if (
debug & DEBUG_HFCMULTI_FIFO)
2238 "%s(card %d): reread f1 because %d!=%d\n",
2239 __func__, hc->
id + 1, temp, f1);
2246 if (
debug & DEBUG_HFCMULTI_FIFO)
2248 "%d!=%d\n", __func__, hc->
id + 1, temp, z2);
2265 pr_warning(
"card%d.B%d: No bufferspace for %d bytes\n",
2266 hc->
id + 1, bch->
nr, Zsize);
2273 maxlen = dch->
maxlen + 3;
2277 pr_warning(
"card%d: No mem for dch rx_skb\n",
2289 if (
debug & DEBUG_HFCMULTI_FIFO)
2291 "bytes (z1=%04x, z2=%04x) HDLC %s (f1=%d, f2=%d) "
2292 "got=%d (again %d)\n", __func__, hc->
id + 1, ch,
2293 Zsize, z1, z2, (f1 == f2) ?
"fragment" :
"COMPLETE",
2294 f1, f2, Zsize + (*sp)->len, again);
2296 if ((Zsize + (*sp)->len) > maxlen) {
2297 if (
debug & DEBUG_HFCMULTI_FIFO)
2299 "%s(card %d): hdlc-frame too large.\n",
2300 __func__, hc->
id + 1);
2314 if ((*sp)->len < 4) {
2315 if (
debug & DEBUG_HFCMULTI_FIFO)
2317 "%s(card %d): Frame below minimum "
2318 "size\n", __func__, hc->
id + 1);
2323 if ((*sp)->data[(*sp)->len - 1]) {
2326 "%s: CRC-error\n", __func__);
2347 if (
debug & DEBUG_HFCMULTI_FIFO) {
2349 __func__, hc->
id + 1);
2351 while (temp < (*sp)->len)
2352 printk(
" %02x", (*sp)->data[temp++]);
2367 if (
debug & DEBUG_HFCMULTI_FIFO)
2369 "%s(card %d): fifo(%d) reading %d bytes "
2370 "(z1=%04x, z2=%04x) TRANS\n",
2371 __func__, hc->
id + 1, ch, Zsize, z1, z2);
2411 if (
debug & DEBUG_HFCMULTI_PLXSD)
2419 if (
debug & DEBUG_HFCMULTI_PLXSD)
2424 if (
debug & DEBUG_HFCMULTI_PLXSD)
2426 "Enable QUARTZ for HFC-E1\n");
2434 spin_unlock_irqrestore(&HFClock, flags);
2438 for (ch = 0; ch <= 31; ch++) {
2440 hfcmulti_tx(hc, ch);
2442 hfcmulti_rx(hc, ch);
2443 if (hc->
chan[ch].dch &&
2444 hc->
chan[ch].nt_timer > -1) {
2445 dch = hc->
chan[ch].dch;
2446 if (!(--hc->
chan[ch].nt_timer)) {
2450 DEBUG_HFCMULTI_STATE)
2466 if (!temp && hc->
chan[hc->
dnum[0]].los)
2469 if (temp && !hc->
chan[hc->
dnum[0]].los)
2476 if (!temp && hc->
chan[hc->
dnum[0]].ais)
2479 if (temp && !hc->
chan[hc->
dnum[0]].ais)
2487 if (!temp && hc->
chan[hc->
dnum[0]].slip_rx)
2489 " bit SLIP detected RX");
2492 if (!temp && hc->
chan[hc->
dnum[0]].slip_tx)
2494 " bit SLIP detected TX");
2500 if (!temp && hc->
chan[hc->
dnum[0]].rdi)
2503 if (temp && !hc->
chan[hc->
dnum[0]].rdi)
2509 switch (hc->
chan[hc->
dnum[0]].sync) {
2511 if ((temp & 0x60) == 0x60) {
2514 "%s: (id=%d) E1 now "
2522 goto check_framesync;
2526 if ((temp & 0x60) != 0x60) {
2530 "lost clock sync\n",
2541 "now in frame sync\n",
2547 if ((temp & 0x60) != 0x60) {
2550 "%s: (id=%d) E1 lost "
2551 "clock & frame sync\n",
2561 "lost frame sync\n",
2570 hfcmulti_watchdog(hc);
2585 for (ch = 0; ch <= 31; ch++) {
2586 if (hc->
chan[ch].dch) {
2587 dch = hc->
chan[ch].dch;
2588 if (r_irq_statech & 1) {
2595 while (st_status != (temp =
2597 if (
debug & DEBUG_HFCMULTI_STATE)
2599 "STATE because %d!=%d\n",
2610 (1 << hc->
chan[ch].port);
2613 ~(1 << hc->
chan[ch].port);
2615 dch->
state = st_status & 0x0f;
2620 if (dch->
state == active) {
2630 if (
debug & DEBUG_HFCMULTI_STATE)
2632 "%s: S/T newstate %x port %d\n",
2633 __func__, dch->
state,
2636 r_irq_statech >>= 1;
2657 if (((!dch) && (!bch)) || (!hc->
created[hc->
chan[
ch].port])) {
2661 if (dch && (r_irq_fifo_bl & (1 << j)) &&
2663 hfcmulti_tx(hc, ch);
2668 if (bch && (r_irq_fifo_bl & (1 << j)) &&
2670 hfcmulti_tx(hc, ch);
2676 if (dch && (r_irq_fifo_bl & (1 << j)) &&
2678 hfcmulti_rx(hc, ch);
2680 if (bch && (r_irq_fifo_bl & (1 << j)) &&
2682 hfcmulti_rx(hc, ch);
2692 hfcmulti_interrupt(
int intno,
void *
dev_id)
2694 #ifdef IRQCOUNT_DEBUG
2695 static int iq1 = 0, iq2 = 0, iq3 = 0, iq4 = 0,
2696 iq5 = 0, iq6 = 0, iqcnt = 0;
2712 spin_lock(&hc->
lock);
2717 "card %d, this is no bug.\n", hc->
id + 1, irqsem);
2718 irqsem = hc->
id + 1;
2720 #ifdef CONFIG_MISDN_HFCMULTI_8xx
2721 if (hc->immap->im_cpm.cp_pbdat & hc->
pb_irqmsk)
2727 wval =
readw(plx_acc);
2728 spin_unlock_irqrestore(&plx_lock, flags);
2735 #ifdef IRQCOUNT_DEBUG
2748 if (iqcnt++ > 5000) {
2750 iq1, iq2, iq3, iq4, iq5, iq6);
2755 if (!r_irq_statech &&
2756 !(status & (V_DTMF_STA | V_LOST_STA | V_EXT_IRQSTA |
2757 V_MISC_IRQSTA | V_FR_IRQSTA))) {
2762 if (r_irq_statech) {
2764 ph_state_irq(hc, r_irq_statech);
2766 if (status & V_EXT_IRQSTA)
2768 if (status & V_LOST_STA) {
2772 if (status & V_MISC_IRQSTA) {
2775 r_irq_misc &= hc->
hw.r_irqmsk_misc;
2790 while (temp != (temp2 =
2792 if (
debug & DEBUG_HFCMULTI_STATE)
2794 "STATE because %d!=%d\n",
2795 __func__, temp, temp2);
2799 if (
debug & DEBUG_HFCMULTI_STATE)
2801 "%s: E1 (id=%d) newstate %x\n",
2802 __func__, hc->
id, temp & 0x7);
2803 for (i = 0; i < hc->
ports; i++) {
2805 dch->
state = temp & 0x7;
2816 handle_timer_irq(hc);
2823 static int irq_proc_cnt;
2824 if (!irq_proc_cnt++)
2826 " this should not happen\n", __func__);
2830 if (status & V_FR_IRQSTA) {
2833 for (i = 0; i < 8; i++) {
2834 if (r_irq_oview & (1 << i))
2842 spin_unlock(&hc->
lock);
2849 spin_unlock(&hc->
lock);
2859 hfcmulti_dbusy_timer(
struct hfc_multi *hc)
2875 int bank_tx,
int slot_rx,
int bank_rx)
2877 int flow_tx = 0, flow_rx = 0, routing = 0;
2878 int oslot_tx, oslot_rx;
2881 if (ch < 0 || ch > 31)
2883 oslot_tx = hc->
chan[ch].slot_tx;
2884 oslot_rx = hc->
chan[ch].slot_rx;
2885 conf = hc->
chan[ch].conf;
2887 if (
debug & DEBUG_HFCMULTI_MODE)
2889 "%s: card %d channel %d protocol %x slot old=%d new=%d "
2890 "bank new=%d (TX) slot old=%d new=%d bank new=%d (RX)\n",
2891 __func__, hc->
id, ch, protocol, oslot_tx, slot_tx,
2892 bank_tx, oslot_rx, slot_rx, bank_rx);
2894 if (oslot_tx >= 0 && slot_tx != oslot_tx) {
2896 if (
debug & DEBUG_HFCMULTI_MODE)
2898 __func__, oslot_tx);
2906 if (
debug & DEBUG_HFCMULTI_MODE)
2908 "%s: we are not owner of this tx slot "
2909 "anymore, channel %d is.\n",
2914 if (oslot_rx >= 0 && slot_rx != oslot_rx) {
2916 if (
debug & DEBUG_HFCMULTI_MODE)
2918 "%s: remove from slot %d (RX)\n",
2919 __func__, oslot_rx);
2920 if (hc->
slot_owner[(oslot_rx << 1) | 1] == ch) {
2925 if (
debug & DEBUG_HFCMULTI_MODE)
2927 "%s: we are not owner of this rx slot "
2928 "anymore, channel %d is.\n",
2937 hc->
chan[ch].slot_tx = -1;
2938 hc->
chan[ch].bank_tx = 0;
2941 if (hc->
chan[ch].txpending)
2946 routing = bank_tx ? 0xc0 : 0x80;
2947 if (conf >= 0 || bank_tx > 1)
2949 if (
debug & DEBUG_HFCMULTI_MODE)
2951 " %d flow %02x routing %02x conf %d (TX)\n",
2952 __func__, ch, slot_tx, bank_tx,
2953 flow_tx, routing, conf);
2960 hc->
chan[ch].slot_tx = slot_tx;
2961 hc->
chan[ch].bank_tx = bank_tx;
2966 hc->
chan[ch].slot_rx = -1;
2967 hc->
chan[ch].bank_rx = 0;
2970 if (hc->
chan[ch].txpending)
2975 routing = bank_rx ? 0x80 : 0xc0;
2976 if (conf >= 0 || bank_rx > 1)
2978 if (
debug & DEBUG_HFCMULTI_MODE)
2980 " %d flow %02x routing %02x conf %d (RX)\n",
2981 __func__, ch, slot_rx, bank_rx,
2982 flow_rx, routing, conf);
2986 hc->
chan[ch].slot_rx = slot_rx;
2987 hc->
chan[ch].bank_rx = bank_rx;
3009 hc->
hw.a_st_ctrl0[hc->
chan[ch].port] &=
3015 hc->
hw.a_st_ctrl0[hc->
chan[ch].port]);
3017 if (hc->
chan[ch].bch) {
3020 &hc->
chan[ch].bch->Flags);
3026 (hc->
chan[ch].slot_rx < 0) &&
3027 (hc->
chan[ch].slot_tx < 0)) {
3030 "Setting B-channel %d to echo cancelable "
3031 "state on PCM slot %d\n", ch,
3032 ((ch / 4) * 8) + ((ch % 4) * 4) + 1);
3034 "Enabling pass through for channel\n");
3035 vpm_out(hc, ch, ((ch / 4) * 8) +
3036 ((ch % 4) * 4) + 1, 0x01);
3043 ((ch % 4) * 4) + 1) << 1);
3052 if (hc->
chan[ch].protocol != protocol) {
3057 ((ch % 4) * 4) + 1) << 1) | 1);
3066 ((ch % 4) * 4)) << 1) | 1);
3075 if (hc->
chan[ch].protocol != protocol) {
3082 ((ch % 4) * 4)) << 1);
3097 if (hc->
chan[ch].protocol != protocol) {
3115 if (hc->
chan[ch].protocol != protocol) {
3121 hc->
hw.a_st_ctrl0[hc->
chan[ch].port] |=
3127 hc->
hw.a_st_ctrl0[hc->
chan[ch].port]);
3129 if (hc->
chan[ch].bch)
3131 &hc->
chan[ch].bch->Flags);
3164 if (hc->
chan[ch].bch) {
3167 hc->
hw.a_st_ctrl0[hc->
chan[ch].port] |=
3173 hc->
hw.a_st_ctrl0[hc->
chan[ch].port]);
3179 __func__, protocol);
3193 hfcmulti_pcm(
struct hfc_multi *hc,
int ch,
int slot_tx,
int bank_tx,
3194 int slot_rx,
int bank_rx)
3196 if (slot_tx < 0 || slot_rx < 0 || bank_tx < 0 || bank_rx < 0) {
3198 mode_hfcmulti(hc, ch, hc->
chan[ch].protocol, -1, 0, -1, 0);
3203 mode_hfcmulti(hc, ch, hc->
chan[ch].protocol, slot_tx, bank_tx,
3212 hfcmulti_conf(
struct hfc_multi *hc,
int ch,
int num)
3214 if (num >= 0 && num <= 7)
3215 hc->
chan[ch].conf = num;
3217 hc->
chan[ch].conf = -1;
3218 mode_hfcmulti(hc, ch, hc->
chan[ch].protocol, hc->
chan[ch].slot_tx,
3219 hc->
chan[ch].bank_tx, hc->
chan[ch].slot_rx,
3220 hc->
chan[ch].bank_rx);
3249 "%s: HW_RESET_REQ no BRI\n",
3261 spin_unlock_irqrestore(&hc->
lock, flags);
3270 "%s: HW_DEACT_REQ no BRI\n",
3286 dev_kfree_skb(dch->
tx_skb);
3291 dev_kfree_skb(dch->
rx_skb);
3297 spin_unlock_irqrestore(&hc->
lock, flags);
3304 "%s: HW_POWERUP_REQ no BRI\n",
3314 spin_unlock_irqrestore(&hc->
lock, flags);
3340 handle_dmsg(
struct mISDNchannel *ch,
struct sk_buff *skb)
3345 struct mISDNhead *hh = mISDN_HEAD_P(skb);
3358 hfcmulti_tx(hc, dch->
slot);
3363 spin_unlock_irqrestore(&hc->
lock, flags);
3366 spin_unlock_irqrestore(&hc->
lock, flags);
3374 "%s: PH_ACTIVATE port %d (0..%d)\n",
3375 __func__, hc->
chan[dch->
slot].port,
3379 ph_state_change(dch);
3380 if (
debug & DEBUG_HFCMULTI_STATE)
3382 "%s: E1 report state %x \n",
3383 __func__, dch->
state);
3397 spin_unlock_irqrestore(&hc->
lock, flags);
3405 if (
debug & DEBUG_HFCMULTI_MSG)
3407 "%s: PH_DEACTIVATE port %d (0..%d)\n",
3408 __func__, hc->
chan[dch->
slot].port,
3412 if (
debug & DEBUG_HFCMULTI_MSG)
3414 "%s: PH_DEACTIVATE no BRI\n",
3427 dev_kfree_skb(dch->
tx_skb);
3432 dev_kfree_skb(dch->
rx_skb);
3443 spin_unlock_irqrestore(&hc->
lock, flags);
3454 deactivate_bchannel(
struct bchannel *bch)
3461 hc->
chan[bch->
slot].coeff_count = 0;
3465 spin_unlock_irqrestore(&hc->
lock, flags);
3469 handle_bmsg(
struct mISDNchannel *ch,
struct sk_buff *skb)
3474 struct mISDNhead *hh = mISDN_HEAD_P(skb);
3475 unsigned long flags;
3484 hfcmulti_tx(hc, bch->
slot);
3490 spin_unlock_irqrestore(&hc->
lock, flags);
3493 if (
debug & DEBUG_HFCMULTI_MSG)
3495 __func__, bch->
slot);
3500 ret = mode_hfcmulti(hc, bch->
slot,
3511 if (
debug & DEBUG_HFCMULTI_DTMF)
3513 "%s: start dtmf decoder\n",
3521 spin_unlock_irqrestore(&hc->
lock, flags);
3530 if (
debug & DEBUG_HFCMULTI_MSG)
3532 "%s: HFC_SPL_LOOP_ON (len = %d)\n",
3533 __func__, skb->
len);
3537 if (
debug & DEBUG_HFCMULTI_MSG)
3544 "%s: unknown PH_CONTROL_REQ info %x\n",
3548 spin_unlock_irqrestore(&hc->
lock, flags);
3551 deactivate_bchannel(bch);
3593 if (
debug & DEBUG_HFCMULTI_MSG)
3595 __func__, bch->
nr, hc->
chan[bch->
slot].rx_off);
3603 if (
debug & DEBUG_HFCMULTI_MSG)
3622 slot_tx = cq->
p1 & 0xff;
3623 bank_tx = cq->
p1 >> 8;
3624 slot_rx = cq->
p2 & 0xff;
3625 bank_rx = cq->
p2 >> 8;
3626 if (
debug & DEBUG_HFCMULTI_MSG)
3628 "%s: HFC_PCM_CONN slot %d bank %d (TX) "
3629 "slot %d bank %d (RX)\n",
3630 __func__, slot_tx, bank_tx,
3632 if (slot_tx < hc->
slots && bank_tx <= 2 &&
3633 slot_rx < hc->
slots && bank_rx <= 2)
3634 hfcmulti_pcm(hc, bch->
slot,
3635 slot_tx, bank_tx, slot_rx, bank_rx);
3638 "%s: HFC_PCM_CONN slot %d bank %d (TX) "
3639 "slot %d bank %d (RX) out of range\n",
3640 __func__, slot_tx, bank_tx,
3646 if (
debug & DEBUG_HFCMULTI_MSG)
3649 hfcmulti_pcm(hc, bch->
slot, -1, 0, -1, 0);
3652 num = cq->
p1 & 0xff;
3653 if (
debug & DEBUG_HFCMULTI_MSG)
3657 hfcmulti_conf(hc, bch->
slot, num);
3660 "%s: HW_CONF_JOIN conf %d out of range\n",
3666 if (
debug & DEBUG_HFCMULTI_MSG)
3668 hfcmulti_conf(hc, bch->
slot, -1);
3671 if (
debug & DEBUG_HFCMULTI_MSG)
3674 vpm_echocan_on(hc, bch->
slot, cq->
p1);
3680 if (
debug & DEBUG_HFCMULTI_MSG)
3684 vpm_echocan_off(hc, bch->
slot);
3696 hfcm_bctrl(
struct mISDNchannel *ch,
u_int cmd,
void *
arg)
3705 __func__, cmd, arg);
3709 deactivate_bchannel(bch);
3717 err = channel_bctrl(bch, arg);
3718 spin_unlock_irqrestore(&hc->
lock, flags);
3733 ph_state_change(
struct dchannel *dch)
3747 if (
debug & DEBUG_HFCMULTI_STATE)
3749 "%s: E1 TE (id=%d) newstate %x\n",
3750 __func__, hc->
id, dch->
state);
3752 if (
debug & DEBUG_HFCMULTI_STATE)
3754 "%s: E1 NT (id=%d) newstate %x\n",
3755 __func__, hc->
id, dch->
state);
3757 switch (dch->
state) {
3760 for (i = 1; i <= 31; i++) {
3785 if (
debug & DEBUG_HFCMULTI_STATE)
3787 "%s: S/T TE newstate %x\n",
3788 __func__, dch->
state);
3789 switch (dch->
state) {
3808 if (
debug & DEBUG_HFCMULTI_STATE)
3810 __func__, dch->
state);
3811 switch (dch->
state) {
3813 if (hc->
chan[ch].nt_timer == 0) {
3814 hc->
chan[ch].nt_timer = -1;
3826 hc->
chan[ch].nt_timer =
3827 nt_t1_count[poll_timer] + 1;
3838 hc->
chan[ch].nt_timer = -1;
3844 hc->
chan[ch].nt_timer = -1;
3847 hc->
chan[ch].nt_timer = -1;
3862 hfcmulti_initmode(
struct dchannel *dch)
3865 u_char a_st_wr_state, r_e1_wr_sta;
3868 if (
debug & DEBUG_HFCMULTI_INIT)
3872 pt = hc->
chan[
i].port;
3875 hc->
chan[hc->
dnum[pt]].slot_tx = -1;
3876 hc->
chan[hc->
dnum[pt]].slot_rx = -1;
3879 mode_hfcmulti(hc, dch->
slot, dch->
dev.D.protocol,
3881 dch->
timer.function = (
void *) hfcmulti_dbusy_timer;
3885 for (i = 1; i <= 31; i++) {
3886 if (!((1 << i) & hc->
bmask[pt]))
3888 hc->
chan[
i].slot_tx = -1;
3889 hc->
chan[
i].slot_rx = -1;
3890 hc->
chan[
i].conf = -1;
3923 if (
debug & DEBUG_HFCMULTI_INIT)
3929 if (
debug & DEBUG_HFCMULTI_INIT)
3945 if (
debug & DEBUG_HFCMULTI_INIT)
3947 "%s: E1 port is clock master "
3948 "(clock from PCM)\n", __func__);
3953 if (
debug & DEBUG_HFCMULTI_INIT)
3955 "%s: E1 port is clock slave "
3956 "(clock to PCM)\n", __func__);
3960 if (
debug & DEBUG_HFCMULTI_INIT)
3963 "(clock from QUARTZ)\n",
3985 hc->
chan[
i].slot_tx = -1;
3986 hc->
chan[
i].slot_rx = -1;
3987 hc->
chan[
i].conf = -1;
3988 mode_hfcmulti(hc, i, dch->
dev.D.protocol, -1, 0, -1, 0);
3989 dch->
timer.function = (
void *) hfcmulti_dbusy_timer;
3992 hc->
chan[i - 2].slot_tx = -1;
3993 hc->
chan[i - 2].slot_rx = -1;
3994 hc->
chan[i - 2].conf = -1;
3995 mode_hfcmulti(hc, i - 2,
ISDN_P_NONE, -1, 0, -1, 0);
3996 hc->
chan[i - 1].slot_tx = -1;
3997 hc->
chan[i - 1].slot_rx = -1;
3998 hc->
chan[i - 1].conf = -1;
3999 mode_hfcmulti(hc, i - 1,
ISDN_P_NONE, -1, 0, -1, 0);
4005 if (
debug & DEBUG_HFCMULTI_INIT)
4007 "%s: ST port %d is NT-mode\n",
4014 if (
debug & DEBUG_HFCMULTI_INIT)
4016 "%s: ST port %d is TE-mode\n",
4021 hc->
hw.a_st_ctrl0[pt] = 0;
4026 hc->
hw.a_st_ctrl0[pt] |= 0x40 ;
4044 hc->
hw.r_sci_msk |= 1 << pt;
4054 if (
debug & DEBUG_HFCMULTI_INIT)
4055 printk(
"%s: done\n", __func__);
4061 struct channel_req *
rq)
4068 dch->
dev.id, __builtin_return_address(0));
4072 (dch->
dev.D.protocol != rq->protocol)) {
4073 if (
debug & DEBUG_HFCMULTI_MODE)
4075 __func__, dch->
dev.D.protocol, rq->protocol);
4080 if (dch->
dev.D.protocol != rq->protocol) {
4086 dch->
dev.D.protocol = rq->protocol;
4088 hfcmulti_initmode(dch);
4089 spin_unlock_irqrestore(&hc->
lock, flags);
4094 rq->ch = &dch->
dev.D;
4102 struct channel_req *rq)
4107 if (!test_channelmap(rq->adr.channel, dch->
dev.channelmap))
4112 ch = rq->adr.channel;
4114 ch = (rq->adr.channel - 1) + (dch->
slot - 2);
4123 bch->
ch.protocol = rq->protocol;
4139 int wd_mode, wd_cnt;
4146 wd_cnt = cq->
p1 & 0xf;
4147 wd_mode = !!(cq->
p1 >> 4);
4148 if (
debug & DEBUG_HFCMULTI_MSG)
4150 ", counter 0x%x\n", __func__,
4151 wd_mode ?
"AUTO" :
"MANUAL", wd_cnt);
4156 hc->
hw.r_bert_wd_md |= 0x40 ;
4168 if (
debug & DEBUG_HFCMULTI_MSG)
4186 hfcm_dctrl(
struct mISDNchannel *ch,
u_int cmd,
void *arg)
4188 struct mISDNdevice *dev =
container_of(ch,
struct mISDNdevice,
D);
4191 struct channel_req *
rq;
4197 __func__, cmd, arg);
4201 switch (rq->protocol) {
4208 err = open_dchannel(hc, dch, rq);
4216 err = open_dchannel(hc, dch, rq);
4220 err = open_bchannel(hc, dch, rq);
4221 spin_unlock_irqrestore(&hc->
lock, flags);
4225 if (
debug & DEBUG_HW_OPEN)
4227 __func__, dch->
dev.id,
4228 __builtin_return_address(0));
4233 err = channel_dctrl(dch, arg);
4234 spin_unlock_irqrestore(&hc->
lock, flags);
4270 if (
debug & DEBUG_HFCMULTI_INIT)
4277 spin_unlock_irqrestore(&hc->
lock, flags);
4292 spin_unlock_irqrestore(&plx_lock, plx_flags);
4295 if (
debug & DEBUG_HFCMULTI_INIT)
4298 err = init_chip(hc);
4308 spin_unlock_irqrestore(&hc->
lock, flags);
4315 spin_unlock_irqrestore(&hc->
lock, flags);
4316 if (
debug & DEBUG_HFCMULTI_INIT)
4320 if (
debug & DEBUG_HFCMULTI_INIT)
4330 printk(
KERN_ERR "HFC PCI: IRQ(%d) getting no interrupts during init.\n",
4340 spin_unlock_irqrestore(&plx_lock, plx_flags);
4343 if (
debug & DEBUG_HFCMULTI_INIT)
4350 if (
debug & DEBUG_HFCMULTI_INIT)
4366 "HFC-multi: card manufacturer: '%s' card name: '%s' clock: %s\n",
4373 if (ent->
device == 0xB410) {
4414 "HFC-multi: No IO-Memory for PCI PLX bridge found\n");
4422 "HFC-multi: failed to remap plx address space. "
4423 "(internal error)\n");
4428 "HFC-multi: plx_membase:%#lx plx_origmembase:%#lx\n",
4435 "HFC-multi: No IO-Memory for PCI card found\n");
4443 "address space. (internal error)\n");
4449 "card %d: defined at MEMBASE %#lx (%#lx) IRQ %d HZ %d "
4465 "HFC-multi: No IO-Memory for PCI card found\n");
4473 "HFC-multi: failed to remap io address space. "
4474 "(internal error)\n");
4493 "HFC-multi: No IO for PCI card found\n");
4500 "address space at 0x%08lx (internal error)\n",
4507 "%s %s: defined at IOBASE %#x IRQ %d HZ %d leds-type %d\n",
4518 pci_set_drvdata(hc->
pci_dev, hc);
4538 pt = hc->
chan[ci].port;
4540 if (
debug & DEBUG_HFCMULTI_INIT)
4544 if (pt >= hc->
ports) {
4550 if (
debug & DEBUG_HFCMULTI_INIT)
4566 if (dch->
timer.function) {
4578 for (i = 0; i <= 31; i++) {
4579 if (!((1 << i) & hc->
bmask[pt]))
4581 if (hc->
chan[i].bch) {
4582 if (
debug & DEBUG_HFCMULTI_INIT)
4584 "%s: free port %d channel %d\n",
4585 __func__, hc->
chan[i].port + 1, i);
4586 pb = hc->
chan[
i].bch;
4588 spin_unlock_irqrestore(&hc->
lock, flags);
4599 ~(1 << hc->
chan[ci].port);
4603 if (hc->
chan[ci - 2].bch) {
4604 if (
debug & DEBUG_HFCMULTI_INIT)
4606 "%s: free port %d channel %d\n",
4607 __func__, hc->
chan[ci - 2].port + 1,
4609 pb = hc->
chan[ci - 2].bch;
4611 spin_unlock_irqrestore(&hc->
lock, flags);
4617 if (hc->
chan[ci - 1].bch) {
4618 if (
debug & DEBUG_HFCMULTI_INIT)
4620 "%s: free port %d channel %d\n",
4621 __func__, hc->
chan[ci - 1].port + 1,
4623 pb = hc->
chan[ci - 1].bch;
4625 spin_unlock_irqrestore(&hc->
lock, flags);
4633 spin_unlock_irqrestore(&hc->
lock, flags);
4635 if (
debug & DEBUG_HFCMULTI_INIT)
4641 if (
debug & DEBUG_HFCMULTI_INIT)
4651 if (
debug & DEBUG_HFCMULTI_INIT)
4662 spin_unlock_irqrestore(&hc->
lock, flags);
4665 if (
debug & DEBUG_HFCMULTI_INIT)
4667 __func__, hc->
irq, hc);
4674 if (
debug & DEBUG_HFCMULTI_INIT)
4677 for (ch = 0; ch <= 31; ch++) {
4678 if (hc->
chan[ch].dch)
4679 release_port(hc, hc->
chan[ch].dch);
4687 release_io_hfcmulti(hc);
4689 if (
debug & DEBUG_HFCMULTI_INIT)
4694 if (
debug & DEBUG_HFCMULTI_INIT)
4696 if (hc == syncmaster)
4699 if (
debug & DEBUG_HFCMULTI_INIT)
4708 if (
port[Port_cnt] & 0x001) {
4711 "This board has no optical "
4714 if (
debug & DEBUG_HFCMULTI_INIT)
4716 "%s: PORT set optical "
4717 "interfacs: card(%d) "
4726 if (
port[Port_cnt] & 0x004) {
4727 if (
debug & DEBUG_HFCMULTI_INIT)
4729 "LOS report: card(%d) port(%d)\n",
4730 __func__, HFC_cnt + 1, 1);
4735 if (
port[Port_cnt] & 0x008) {
4736 if (
debug & DEBUG_HFCMULTI_INIT)
4738 "AIS report: card(%d) port(%d)\n",
4739 __func__, HFC_cnt + 1, 1);
4744 if (
port[Port_cnt] & 0x010) {
4745 if (
debug & DEBUG_HFCMULTI_INIT)
4747 "%s: PORT set SLIP report: "
4748 "card(%d) port(%d)\n",
4749 __func__, HFC_cnt + 1, 1);
4754 if (
port[Port_cnt] & 0x020) {
4755 if (
debug & DEBUG_HFCMULTI_INIT)
4757 "%s: PORT set RDI report: "
4758 "card(%d) port(%d)\n",
4759 __func__, HFC_cnt + 1, 1);
4764 if (!(
port[Port_cnt] & 0x100)) {
4765 if (
debug & DEBUG_HFCMULTI_INIT)
4767 " card(%d) port(%d)\n",
4768 __func__, HFC_cnt + 1, 1);
4772 if (
debug & DEBUG_HFCMULTI_INIT)
4774 " report: card(%d) port(%d)\n",
4775 __func__, HFC_cnt + 1, 1);
4778 if (
port[Port_cnt] & 0x0200) {
4779 if (
debug & DEBUG_HFCMULTI_INIT)
4781 "E1: card(%d) port(%d)\n",
4782 __func__, HFC_cnt + 1, 1);
4785 if (
port[Port_cnt] & 0x0400) {
4786 if (
debug & DEBUG_HFCMULTI_INIT)
4788 "E1: card(%d) port(%d)\n",
4789 __func__, HFC_cnt + 1, 1);
4793 if (
port[Port_cnt] & 0x0800) {
4794 if (
debug & DEBUG_HFCMULTI_INIT)
4796 "E1: card(%d) port(%d)\n",
4797 __func__, HFC_cnt + 1, 1);
4801 if (
port[Port_cnt] & 0x3000) {
4802 hc->
chan[hc->
dnum[0]].jitter = (
port[Port_cnt]>>12) & 0x3;
4803 if (
debug & DEBUG_HFCMULTI_INIT)
4805 "%s: PORT set elastic "
4806 "buffer to %d: card(%d) port(%d)\n",
4807 __func__, hc->
chan[hc->
dnum[0]].jitter,
4831 dch->
dev.D.send = handle_dmsg;
4832 dch->
dev.D.ctrl = hfcm_dctrl;
4836 hc->
chan[hc->
dnum[pt]].nt_timer = -1;
4837 for (ch = 1; ch <= 31; ch++) {
4838 if (!((1 << ch) & hc->
bmask[pt]))
4848 if (!hc->
chan[ch].coeff) {
4860 bch->
ch.send = handle_bmsg;
4861 bch->
ch.ctrl = hfcm_bctrl;
4863 list_add(&bch->
ch.list, &dch->
dev.bchannels);
4866 set_channelmap(bch->
nr, dch->
dev.channelmap);
4871 init_e1_port_hw(hc, m);
4883 release_port(hc, dch);
4888 init_multi_port(
struct hfc_multi *hc,
int pt)
4904 dch->
dev.D.send = handle_dmsg;
4905 dch->
dev.D.ctrl = hfcm_dctrl;
4906 dch->
dev.nrbchan = 2;
4909 hc->
chan[i + 2].dch = dch;
4910 hc->
chan[i + 2].port = pt;
4911 hc->
chan[i + 2].nt_timer = -1;
4912 for (ch = 0; ch < dch->
dev.nrbchan; ch++) {
4921 if (!hc->
chan[i + ch].coeff) {
4933 bch->
ch.send = handle_bmsg;
4934 bch->
ch.ctrl = hfcm_bctrl;
4935 bch->
ch.nr = ch + 1;
4936 list_add(&bch->
ch.list, &dch->
dev.bchannels);
4937 hc->
chan[i +
ch].bch = bch;
4938 hc->
chan[i +
ch].port = pt;
4939 set_channelmap(bch->
nr, dch->
dev.channelmap);
4942 if (
port[Port_cnt] & 0x001) {
4943 if (
debug & DEBUG_HFCMULTI_INIT)
4945 "%s: PROTOCOL set master clock: "
4946 "card(%d) port(%d)\n",
4947 __func__, HFC_cnt + 1, pt + 1);
4950 "for port(%d) of card(%d) is only"
4951 " possible with TE-mode\n",
4952 pt + 1, HFC_cnt + 1);
4958 "for port(%d) of card(%d) already "
4959 "defined for port(%d)\n",
4960 pt + 1, HFC_cnt + 1, hc->
masterclk + 1);
4967 if (
port[Port_cnt] & 0x002) {
4968 if (
debug & DEBUG_HFCMULTI_INIT)
4970 "%s: PROTOCOL set non capacitive "
4971 "transmitter: card(%d) port(%d)\n",
4972 __func__, HFC_cnt + 1, pt + 1);
4974 &hc->
chan[i + 2].cfg);
4977 if (
port[Port_cnt] & 0x004) {
4978 if (
debug & DEBUG_HFCMULTI_INIT)
4980 "%s: PROTOCOL disable E-channel: "
4981 "card(%d) port(%d)\n",
4982 __func__, HFC_cnt + 1, pt + 1);
4984 &hc->
chan[i + 2].cfg);
4988 HFC_cnt + 1, pt + 1);
4992 hc->
ctype, HFC_cnt + 1, pt + 1);
5000 release_port(hc, dch);
5012 u_char dips = 0, pmj = 0;
5021 if ((
type[HFC_cnt] & 0xff) && (
type[HFC_cnt] & 0xff) != m->
type) {
5023 "type[%d] %d was supplied as module parameter\n",
5025 type[HFC_cnt] & 0xff);
5027 "first, to see cards and their types.");
5030 if (
debug & DEBUG_HFCMULTI_INIT)
5047 hc->
io_mode = iomode[HFC_cnt];
5052 for (ch = 0; ch <= 31; ch++) {
5053 if (!((1 << ch) & dmask[E1_cnt]))
5057 if ((maskcheck & hc->
bmask[pt])
5058 || (dmask[E1_cnt] & hc->
bmask[pt])) {
5060 "HFC-E1 #%d has overlapping B-channels on fragment #%d\n",
5065 maskcheck |= hc->
bmask[pt];
5067 "HFC-E1 #%d uses D-channel on slot %d and a B-channel map of 0x%08x\n",
5068 E1_cnt + 1, ch, hc->
bmask[pt]);
5076 hc->
bmask[0] = 0xfffefffe;
5082 if (
type[HFC_cnt] & 0x100) {
5093 for (i = 0; i < (poll >> 1); i++)
5097 if (!(
type[HFC_cnt] & 0x200))
5102 if (
type[HFC_cnt] & 0x800)
5104 if (
type[HFC_cnt] & 0x1000) {
5108 if (
type[HFC_cnt] & 0x4000)
5110 if (
type[HFC_cnt] & 0x8000)
5113 if (
type[HFC_cnt] & 0x10000)
5115 if (
type[HFC_cnt] & 0x20000)
5117 if (
type[HFC_cnt] & 0x80000) {
5126 ret_err = setup_pci(hc, pdev, ent);
5128 #ifdef CONFIG_MISDN_HFCMULTI_8xx
5129 ret_err = setup_embedded(hc, m);
5137 if (hc == syncmaster)
5147 #ifdef HFC_REGISTER_DEBUG
5154 for (pt = 0; pt < hc->
ports; pt++) {
5162 ret_err = init_e1_port(hc, m, pt);
5164 ret_err = init_multi_port(hc, pt);
5165 if (
debug & DEBUG_HFCMULTI_INIT)
5167 "%s: Registering D-channel, card(%d) port(%d) "
5169 __func__, HFC_cnt + 1, pt + 1, ret_err);
5179 hc->
chan[(pt << 2) + 2].dch);
5248 spin_unlock_irqrestore(&HFClock, flags);
5251 if (
clock == HFC_cnt + 1)
5256 ret_err = init_card(hc);
5266 spin_unlock_irqrestore(&hc->
lock, flags);
5270 release_io_hfcmulti(hc);
5271 if (hc == syncmaster)
5284 "device:%x subvendor:%x subdevice:%x\n",
5291 spin_unlock_irqrestore(&HFClock, flags);
5299 #define VENDOR_CCD "Cologne Chip AG"
5300 #define VENDOR_BN "beroNet GmbH"
5301 #define VENDOR_DIG "Digium Inc."
5302 #define VENDOR_JH "Junghanns.NET GmbH"
5303 #define VENDOR_PRIM "PrimuX"
5305 static const struct hm_map hfcm_map[] = {
5306 {
VENDOR_BN,
"HFC-1S Card (mini PCI)", 4, 1, 1, 3, 0,
DIP_4S, 0, 0},
5307 {
VENDOR_BN,
"HFC-2S Card", 4, 2, 1, 3, 0,
DIP_4S, 0, 0},
5308 {
VENDOR_BN,
"HFC-2S Card (mini PCI)", 4, 2, 1, 3, 0,
DIP_4S, 0, 0},
5309 {
VENDOR_BN,
"HFC-4S Card", 4, 4, 1, 2, 0,
DIP_4S, 0, 0},
5310 {
VENDOR_BN,
"HFC-4S Card (mini PCI)", 4, 4, 1, 2, 0, 0, 0, 0},
5311 {
VENDOR_CCD,
"HFC-4S Eval (old)", 4, 4, 0, 0, 0, 0, 0, 0},
5312 {
VENDOR_CCD,
"HFC-4S IOB4ST", 4, 4, 1, 2, 0,
DIP_4S, 0, 0},
5313 {
VENDOR_CCD,
"HFC-4S", 4, 4, 1, 2, 0, 0, 0, 0},
5314 {
VENDOR_DIG,
"HFC-4S Card", 4, 4, 0, 2, 0, 0,
HFC_IO_MODE_REGIO, 0},
5315 {
VENDOR_CCD,
"HFC-4S Swyx 4xS0 SX2 QuadBri", 4, 4, 1, 2, 0, 0, 0, 0},
5316 {
VENDOR_JH,
"HFC-4S (junghanns 2.0)", 4, 4, 1, 2, 0, 0, 0, 0},
5317 {
VENDOR_PRIM,
"HFC-2S Primux Card", 4, 2, 0, 0, 0, 0, 0, 0},
5319 {
VENDOR_BN,
"HFC-8S Card", 8, 8, 1, 0, 0, 0, 0, 0},
5322 {
VENDOR_CCD,
"HFC-8S Eval (old)", 8, 8, 0, 0, 0, 0, 0, 0},
5323 {
VENDOR_CCD,
"HFC-8S IOB4ST Recording", 8, 8, 1, 0, 0, 0, 0, 0},
5325 {
VENDOR_CCD,
"HFC-8S IOB8ST", 8, 8, 1, 0, 0, 0, 0, 0},
5326 {
VENDOR_CCD,
"HFC-8S", 8, 8, 1, 0, 0, 0, 0, 0},
5327 {
VENDOR_CCD,
"HFC-8S", 8, 8, 1, 0, 0, 0, 0, 0},
5329 {
VENDOR_BN,
"HFC-E1 Card", 1, 1, 0, 1, 0,
DIP_E1, 0, 0},
5330 {
VENDOR_BN,
"HFC-E1 Card (mini PCI)", 1, 1, 0, 1, 0, 0, 0, 0},
5331 {
VENDOR_BN,
"HFC-E1+ Card (Dual)", 1, 1, 0, 1, 0,
DIP_E1, 0, 0},
5332 {
VENDOR_BN,
"HFC-E1 Card (Dual)", 1, 1, 0, 1, 0,
DIP_E1, 0, 0},
5334 {
VENDOR_CCD,
"HFC-E1 Eval (old)", 1, 1, 0, 0, 0, 0, 0, 0},
5335 {
VENDOR_CCD,
"HFC-E1 IOB1E1", 1, 1, 0, 1, 0, 0, 0, 0},
5336 {
VENDOR_CCD,
"HFC-E1", 1, 1, 0, 1, 0, 0, 0, 0},
5338 {
VENDOR_CCD,
"HFC-4S Speech Design", 4, 4, 0, 0, 0, 0,
5340 {
VENDOR_CCD,
"HFC-E1 Speech Design", 1, 1, 0, 0, 0, 0,
5342 {
VENDOR_CCD,
"HFC-4S OpenVox", 4, 4, 1, 0, 0, 0, 0, 0},
5343 {
VENDOR_CCD,
"HFC-2S OpenVox", 4, 2, 1, 0, 0, 0, 0, 0},
5344 {
VENDOR_CCD,
"HFC-8S OpenVox", 8, 8, 1, 0, 0, 0, 0, 0},
5345 {
VENDOR_CCD,
"XHFC-4S Speech Design", 5, 4, 0, 0, 0, 0,
5347 {
VENDOR_JH,
"HFC-8S (junghanns)", 8, 8, 1, 0, 0, 0, 0, 0},
5348 {
VENDOR_BN,
"HFC-2S Beronet Card PCIe", 4, 2, 1, 3, 0,
DIP_4S, 0, 0},
5349 {
VENDOR_BN,
"HFC-4S Beronet Card PCIe", 4, 4, 1, 2, 0,
DIP_4S, 0, 0},
5353 #define H(x) ((unsigned long)&hfcm_map[x])
5386 0xb761, 0, 0,
H(33)},
5388 0xb762, 0, 0,
H(34)},
5456 "Unknown HFC multiport controller (vendor:%04x device:%04x "
5457 "subvendor:%04x subdevice:%04x)\n", pdev->
vendor,
5461 "Please contact the driver maintainer for support.\n");
5464 ret = hfcmulti_init(m, pdev, ent);
5472 static struct pci_driver hfcmultipci_driver = {
5473 .name =
"hfc_multi",
5474 .probe = hfcmulti_probe,
5476 .id_table = hfmultipci_ids,
5480 HFCmulti_cleanup(
void)
5506 if (
debug & DEBUG_HFCMULTI_INIT)
5534 "%s: Wrong poll value (%d).\n", __func__,
poll);
5562 for (i = 0; i < xhfc; ++
i) {
5563 err = hfcmulti_init(&m,
NULL,
NULL);
5574 err = pci_register_driver(&hfcmultipci_driver);