Lines Matching +full:ld +full:- +full:pulse +full:- +full:delay +full:- +full:us
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * hfcmulti.c low level driver for hfc-4s/hfc-8s/hfc-e1 based cards
7 * Peter Sprenger (sprengermoving-bytes.de)
9 * inspired by existing hfc-pci driver:
10 * Copyright 1999 by Werner Cornelius (werner@isdn-development.de)
22 * Bit 0-7 = 0x00001 = HFC-E1 (1 port)
23 * or Bit 0-7 = 0x00004 = HFC-4S (4 ports)
24 * or Bit 0-7 = 0x00008 = HFC-8S (8 ports)
26 * Bit 9 = 0x00200 = Disable DTMF detect on all B-channels via hardware
38 * example: 0x20204 one HFC-4S with dtmf detection and 128 timeslots on PCM
42 * HFC-4S/HFC-8S only bits:
47 * Bit 2 = 0x004 = Disable E-channel. (No E-channel processing)
48 * example: 0x0001,0x0000,0x0000,0x0000 one HFC-4S with master clock
51 * HFC-E1 only bits:
53 * Bit 1 = 0x0002 = reserved (later for 32 B-channels transparent mode)
58 * Bit 8 = 0x0100 = Turn off CRC-4 Multiframe Mode, use double frame
64 * Bit 12-13 = 0xX000 = elastic jitter buffer (1-3), Set both bits to 0
75 * By default 128 is used. Decrease to reduce delay, increase to
88 * -1 means no support of PCM bus not even.
93 * NOTE: One dmask value must be given for every HFC-E1 card.
94 * If omitted, the E1 card has D-channel on time slot 16, which is default.
98 * value stands for a B-channel. The bmask may not overlap with dmask or
101 * This will create one fragment with D-channel on slot 1 with
102 * B-channels on slots 2..15, and a second fragment with D-channel
103 * on slot 17 with B-channels on slot 18..31. Slot 16 is unused.
104 * If bit 0 is set (dmask=0x00000001) the D-channel is on slot 0 and will
108 * B-channels.
109 * If no bits are set on bmask, no B-channel is created for that fragment.
110 * Example: dmask=0xfffffffe bmask=0,0,0,0.... (31 0-values for bmask)
111 * This will create 31 ports with one D-channel only.
116 * -> See hfc_multi.h for HFC_IO_MODE_* values
138 * Set to card number starting with 1. Set to -1 to disable.
157 #include <linux/delay.h>
242 (hc->HFC_outb(hc, reg, val, __func__, __LINE__))
244 (hc->HFC_outb_nodebug(hc, reg, val, __func__, __LINE__))
246 (hc->HFC_inb(hc, reg, __func__, __LINE__))
248 (hc->HFC_inb_nodebug(hc, reg, __func__, __LINE__))
250 (hc->HFC_inw(hc, reg, __func__, __LINE__))
252 (hc->HFC_inw_nodebug(hc, reg, __func__, __LINE__))
254 (hc->HFC_wait(hc, __func__, __LINE__))
256 (hc->HFC_wait_nodebug(hc, __func__, __LINE__))
258 #define HFC_outb(hc, reg, val) (hc->HFC_outb(hc, reg, val))
259 #define HFC_outb_nodebug(hc, reg, val) (hc->HFC_outb_nodebug(hc, reg, val))
260 #define HFC_inb(hc, reg) (hc->HFC_inb(hc, reg))
261 #define HFC_inb_nodebug(hc, reg) (hc->HFC_inb_nodebug(hc, reg))
262 #define HFC_inw(hc, reg) (hc->HFC_inw(hc, reg))
263 #define HFC_inw_nodebug(hc, reg) (hc->HFC_inw_nodebug(hc, reg))
264 #define HFC_wait(hc) (hc->HFC_wait(hc))
265 #define HFC_wait_nodebug(hc) (hc->HFC_wait_nodebug(hc))
281 writeb(val, hc->pci_membase + reg); in HFC_outb_pcimem()
290 return readb(hc->pci_membase + reg); in HFC_inb_pcimem()
299 return readw(hc->pci_membase + reg); in HFC_inw_pcimem()
308 while (readb(hc->pci_membase + R_STATUS) & V_BUSY) in HFC_wait_pcimem()
321 outb(reg, hc->pci_iobase + 4); in HFC_outb_regio()
322 outb(val, hc->pci_iobase); in HFC_outb_regio()
331 outb(reg, hc->pci_iobase + 4); in HFC_inb_regio()
332 return inb(hc->pci_iobase); in HFC_inb_regio()
341 outb(reg, hc->pci_iobase + 4); in HFC_inw_regio()
342 return inw(hc->pci_iobase); in HFC_inw_regio()
351 outb(R_STATUS, hc->pci_iobase + 4); in HFC_wait_regio()
352 while (inb(hc->pci_iobase) & V_BUSY) in HFC_wait_regio()
364 i = -1; in HFC_outb_debug()
382 hc->id, reg, regname, val, bits, function, line); in HFC_outb_debug()
412 hc->id, reg, regname, val, bits, function, line); in HFC_inb_debug()
434 hc->id, reg, regname, val, function, line); in HFC_inw_debug()
441 hc->id, function, line); in HFC_wait_debug()
450 outb(A_FIFO_DATA0, (hc->pci_iobase) + 4); in write_fifo_regio()
452 outl(cpu_to_le32(*(u32 *)data), hc->pci_iobase); in write_fifo_regio()
454 len -= 4; in write_fifo_regio()
457 outw(cpu_to_le16(*(u16 *)data), hc->pci_iobase); in write_fifo_regio()
459 len -= 2; in write_fifo_regio()
462 outb(*data, hc->pci_iobase); in write_fifo_regio()
464 len--; in write_fifo_regio()
473 hc->pci_membase + A_FIFO_DATA0); in write_fifo_pcimem()
475 len -= 4; in write_fifo_pcimem()
479 hc->pci_membase + A_FIFO_DATA0); in write_fifo_pcimem()
481 len -= 2; in write_fifo_pcimem()
484 writeb(*data, hc->pci_membase + A_FIFO_DATA0); in write_fifo_pcimem()
486 len--; in write_fifo_pcimem()
494 outb(A_FIFO_DATA0, (hc->pci_iobase) + 4); in read_fifo_regio()
496 *(u32 *)data = le32_to_cpu(inl(hc->pci_iobase)); in read_fifo_regio()
498 len -= 4; in read_fifo_regio()
501 *(u16 *)data = le16_to_cpu(inw(hc->pci_iobase)); in read_fifo_regio()
503 len -= 2; in read_fifo_regio()
506 *data = inb(hc->pci_iobase); in read_fifo_regio()
508 len--; in read_fifo_regio()
518 le32_to_cpu(readl(hc->pci_membase + A_FIFO_DATA0)); in read_fifo_pcimem()
520 len -= 4; in read_fifo_pcimem()
524 le16_to_cpu(readw(hc->pci_membase + A_FIFO_DATA0)); in read_fifo_pcimem()
526 len -= 2; in read_fifo_pcimem()
529 *data = readb(hc->pci_membase + A_FIFO_DATA0); in read_fifo_pcimem()
531 len--; in read_fifo_pcimem()
538 hc->hw.r_irq_ctrl |= V_GLOB_IRQ_EN; in enable_hwirq()
539 HFC_outb(hc, R_IRQ_CTRL, hc->hw.r_irq_ctrl); in enable_hwirq()
545 hc->hw.r_irq_ctrl &= ~((u_char)V_GLOB_IRQ_EN); in disable_hwirq()
546 HFC_outb(hc, R_IRQ_CTRL, hc->hw.r_irq_ctrl); in disable_hwirq()
571 if (!hc->pci_iobase) in readpcibridge()
584 outw(cipv, hc->pci_iobase + 4); in readpcibridge()
585 data = inb(hc->pci_iobase); in readpcibridge()
599 if (!hc->pci_iobase) in writepcibridge()
608 outw(cipv, hc->pci_iobase + 4); in writepcibridge()
620 outl(datav, hc->pci_iobase); in writepcibridge()
752 /* Setup TDM path - sets fsync and tdm_clk as inputs */ in vpm_init()
766 vpm_out(wc, x, 0x33 - i, (mask >> (i << 3)) & 0xff); in vpm_init()
769 printk(KERN_DEBUG "VPM: A-law mode\n"); in vpm_init()
788 * reference at link-time. in vpm_init()
844 struct bchannel *bch = hc->chan[ch].bch; in vpm_echocan_on()
846 int txadj = -4; in vpm_echocan_on()
849 if (hc->chan[ch].protocol != ISDN_P_B_RAW) in vpm_echocan_on()
876 struct bchannel *bch = hc->chan[ch].bch; in vpm_echocan_off()
882 if (hc->chan[ch].protocol != ISDN_P_B_RAW) in vpm_echocan_off()
932 if (test_bit(HFC_CHIP_PLXSD, &hc->chip)) { in hfcmulti_resync()
933 if (hc->syncronized) { in hfcmulti_resync()
943 if (test_bit(HFC_CHIP_PLXSD, &hc->chip)) { in hfcmulti_resync()
944 plx_acc_32 = hc->plx_membase + PLX_GPIOC; in hfcmulti_resync()
948 if (test_bit(HFC_CHIP_PCM_MASTER, &hc->chip)) { in hfcmulti_resync()
950 if (hc->ctype == HFC_TYPE_E1) { in hfcmulti_resync()
954 hc->e1_resync |= 1; /* get SYNC_I */ in hfcmulti_resync()
964 "interface.\n", hc->id, hc); in hfcmulti_resync()
966 plx_acc_32 = hc->plx_membase + PLX_GPIOC; in hfcmulti_resync()
971 if (hc->ctype == HFC_TYPE_E1 in hfcmulti_resync()
972 && !test_bit(HFC_CHIP_RX_SYNC, &hc->chip)) { in hfcmulti_resync()
975 hc->e1_resync |= 2; /* switch to jatt */ in hfcmulti_resync()
983 "with QUARTZ\n", hc->id, hc); in hfcmulti_resync()
984 if (hc->ctype == HFC_TYPE_E1) { in hfcmulti_resync()
989 "Schedule QUARTZ for HFC-E1\n"); in hfcmulti_resync()
990 hc->e1_resync |= 4; /* switch quartz */ in hfcmulti_resync()
995 "enabled by HFC-%dS\n", hc->ctype); in hfcmulti_resync()
997 plx_acc_32 = hc->plx_membase + PLX_GPIOC; in hfcmulti_resync()
1016 if (hc->syncronized) { in plxsd_checksync()
1020 " (id=%d)\n", __func__, hc->id + 1, in plxsd_checksync()
1021 hc->id); in plxsd_checksync()
1028 " (id=%d)\n", __func__, hc->id + 1, in plxsd_checksync()
1029 hc->id); in plxsd_checksync()
1050 hc->hw.r_cirm |= V_SRES; in release_io_hfcmulti()
1051 HFC_outb(hc, R_CIRM, hc->hw.r_cirm); in release_io_hfcmulti()
1053 hc->hw.r_cirm &= ~V_SRES; in release_io_hfcmulti()
1054 HFC_outb(hc, R_CIRM, hc->hw.r_cirm); in release_io_hfcmulti()
1058 if (test_bit(HFC_CHIP_PLXSD, &hc->chip) && hc->plx_membase) { in release_io_hfcmulti()
1061 __func__, hc->id + 1); in release_io_hfcmulti()
1063 plx_acc_32 = hc->plx_membase + PLX_GPIOC; in release_io_hfcmulti()
1082 test_and_clear_bit(HFC_CHIP_PLXSD, &hc->chip); /* prevent resync */ in release_io_hfcmulti()
1083 if (hc->pci_dev) in release_io_hfcmulti()
1084 pci_write_config_word(hc->pci_dev, PCI_COMMAND, 0); in release_io_hfcmulti()
1085 if (hc->pci_membase) in release_io_hfcmulti()
1086 iounmap(hc->pci_membase); in release_io_hfcmulti()
1087 if (hc->plx_membase) in release_io_hfcmulti()
1088 iounmap(hc->plx_membase); in release_io_hfcmulti()
1089 if (hc->pci_iobase) in release_io_hfcmulti()
1090 release_region(hc->pci_iobase, 8); in release_io_hfcmulti()
1091 if (hc->xhfc_membase) in release_io_hfcmulti()
1092 iounmap((void *)hc->xhfc_membase); in release_io_hfcmulti()
1094 if (hc->pci_dev) { in release_io_hfcmulti()
1095 pci_disable_device(hc->pci_dev); in release_io_hfcmulti()
1096 pci_set_drvdata(hc->pci_dev, NULL); in release_io_hfcmulti()
1119 spin_lock_irqsave(&hc->lock, flags); in init_chip()
1121 memset(&hc->hw, 0, sizeof(struct hfcm_hw)); in init_chip()
1130 err = -EIO; in init_chip()
1135 "HFC_multi: detected HFC with chip ID=0x%lx revision=%ld%s\n", in init_chip()
1136 val, rev, (rev == 0 && (hc->ctype != HFC_TYPE_XHFC)) ? in init_chip()
1138 if (hc->ctype != HFC_TYPE_XHFC && rev == 0) { in init_chip()
1139 test_and_set_bit(HFC_CHIP_REVISION0, &hc->chip); in init_chip()
1149 "consider chip revision = %ld. The chip / " in init_chip()
1153 /* set s-ram size */ in init_chip()
1154 hc->Flen = 0x10; in init_chip()
1155 hc->Zmin = 0x80; in init_chip()
1156 hc->Zlen = 384; in init_chip()
1157 hc->DTMFbase = 0x1000; in init_chip()
1158 if (test_bit(HFC_CHIP_EXRAM_128, &hc->chip)) { in init_chip()
1162 hc->hw.r_ctrl |= V_EXT_RAM; in init_chip()
1163 hc->hw.r_ram_sz = 1; in init_chip()
1164 hc->Flen = 0x20; in init_chip()
1165 hc->Zmin = 0xc0; in init_chip()
1166 hc->Zlen = 1856; in init_chip()
1167 hc->DTMFbase = 0x2000; in init_chip()
1169 if (test_bit(HFC_CHIP_EXRAM_512, &hc->chip)) { in init_chip()
1173 hc->hw.r_ctrl |= V_EXT_RAM; in init_chip()
1174 hc->hw.r_ram_sz = 2; in init_chip()
1175 hc->Flen = 0x20; in init_chip()
1176 hc->Zmin = 0xc0; in init_chip()
1177 hc->Zlen = 8000; in init_chip()
1178 hc->DTMFbase = 0x2000; in init_chip()
1180 if (hc->ctype == HFC_TYPE_XHFC) { in init_chip()
1181 hc->Flen = 0x8; in init_chip()
1182 hc->Zmin = 0x0; in init_chip()
1183 hc->Zlen = 64; in init_chip()
1184 hc->DTMFbase = 0x0; in init_chip()
1186 hc->max_trans = poll << 1; in init_chip()
1187 if (hc->max_trans > hc->Zlen) in init_chip()
1188 hc->max_trans = hc->Zlen; in init_chip()
1191 if (test_bit(HFC_CHIP_PLXSD, &hc->chip)) { in init_chip()
1194 __func__, hc->id + 1); in init_chip()
1196 plx_acc_32 = hc->plx_membase + PLX_GPIOC; in init_chip()
1220 if (test_bit(HFC_CHIP_PLXSD, &pos->chip)) { in init_chip()
1230 __func__, plx_last_hc->id + 1); in init_chip()
1232 plx_acc_32 = plx_last_hc->plx_membase + PLX_GPIOC; in init_chip()
1243 hc->hw.r_pcm_md0 = V_F0_LEN; /* shift clock for DSP */ in init_chip()
1246 if (test_bit(HFC_CHIP_EMBSD, &hc->chip)) in init_chip()
1247 hc->hw.r_pcm_md0 = V_F0_LEN; /* shift clock for DSP */ in init_chip()
1249 /* we only want the real Z2 read-pointer for revision > 0 */ in init_chip()
1250 if (!test_bit(HFC_CHIP_REVISION0, &hc->chip)) in init_chip()
1251 hc->hw.r_ram_sz |= V_FZ_MD; in init_chip()
1254 if (test_bit(HFC_CHIP_PCM_SLAVE, &hc->chip)) { in init_chip()
1259 if (test_bit(HFC_CHIP_PCM_MASTER, &hc->chip) && !plxsd_master) { in init_chip()
1263 hc->hw.r_pcm_md0 |= V_PCM_MD; in init_chip()
1271 HFC_outb(hc, R_CTRL, hc->hw.r_ctrl); in init_chip()
1272 if (hc->ctype == HFC_TYPE_XHFC) in init_chip()
1276 HFC_outb(hc, R_RAM_SZ, hc->hw.r_ram_sz); in init_chip()
1278 if (hc->ctype == HFC_TYPE_XHFC) in init_chip()
1279 hc->hw.r_cirm = V_SRES | V_HFCRES | V_PCMRES | V_STRES; in init_chip()
1281 hc->hw.r_cirm = V_SRES | V_HFCRES | V_PCMRES | V_STRES in init_chip()
1283 HFC_outb(hc, R_CIRM, hc->hw.r_cirm); in init_chip()
1285 hc->hw.r_cirm = 0; in init_chip()
1286 HFC_outb(hc, R_CIRM, hc->hw.r_cirm); in init_chip()
1288 if (hc->ctype != HFC_TYPE_XHFC) in init_chip()
1289 HFC_outb(hc, R_RAM_SZ, hc->hw.r_ram_sz); in init_chip()
1292 if (test_bit(HFC_CHIP_PLXSD, &hc->chip)) { in init_chip()
1294 plx_acc_32 = hc->plx_membase + PLX_GPIOC; in init_chip()
1297 if (hc->hw.r_pcm_md0 & V_PCM_MD) { in init_chip()
1315 HFC_outb(hc, R_PCM_MD0, hc->hw.r_pcm_md0 | 0x90); in init_chip()
1316 if (hc->slots == 32) in init_chip()
1318 if (hc->slots == 64) in init_chip()
1320 if (hc->slots == 128) in init_chip()
1322 HFC_outb(hc, R_PCM_MD0, hc->hw.r_pcm_md0 | 0xa0); in init_chip()
1323 if (test_bit(HFC_CHIP_PLXSD, &hc->chip)) in init_chip()
1325 else if (test_bit(HFC_CHIP_EMBSD, &hc->chip)) in init_chip()
1329 HFC_outb(hc, R_PCM_MD0, hc->hw.r_pcm_md0 | 0x00); in init_chip()
1333 if (hc->ctype != HFC_TYPE_XHFC) in init_chip()
1335 hc->slot_owner[i] = -1; in init_chip()
1339 if (test_bit(HFC_CHIP_CLOCK2, &hc->chip)) { in init_chip()
1346 if (test_bit(HFC_CHIP_EMBSD, &hc->chip)) in init_chip()
1350 if (test_bit(HFC_CHIP_B410P, &hc->chip)) { in init_chip()
1364 "HFC_multi F0_CNT %ld after reset\n", val); in init_chip()
1365 spin_unlock_irqrestore(&hc->lock, flags); in init_chip()
1368 spin_lock_irqsave(&hc->lock, flags); in init_chip()
1373 "HFC_multi F0_CNT %ld after 10 ms (1st try)\n", in init_chip()
1377 if (test_bit(HFC_CHIP_PCM_MASTER, &hc->chip)) in init_chip()
1380 if (test_bit(HFC_CHIP_PCM_SLAVE, &hc->chip)) in init_chip()
1383 test_and_set_bit(HFC_CHIP_PCM_SLAVE, &hc->chip); in init_chip()
1389 if (test_bit(HFC_CHIP_PCM_MASTER, &hc->chip)) { in init_chip()
1391 printk(KERN_ERR "HFC_multi ERROR, getting no 125us " in init_chip()
1392 "pulse. Seems that controller fails.\n"); in init_chip()
1393 err = -EIO; in init_chip()
1396 if (test_bit(HFC_CHIP_PCM_SLAVE, &hc->chip)) { in init_chip()
1401 if (test_bit(HFC_CHIP_PLXSD, &hc->chip) in init_chip()
1406 err = -EIO; in init_chip()
1410 if (test_bit(HFC_CHIP_PLXSD, &hc->chip)) { in init_chip()
1412 plx_acc_32 = hc->plx_membase + PLX_GPIOC; in init_chip()
1422 hc->hw.r_pcm_md0 |= V_PCM_MD; in init_chip()
1423 HFC_outb(hc, R_PCM_MD0, hc->hw.r_pcm_md0 | 0x00); in init_chip()
1424 spin_unlock_irqrestore(&hc->lock, flags); in init_chip()
1427 spin_lock_irqsave(&hc->lock, flags); in init_chip()
1431 printk(KERN_DEBUG "HFC_multi F0_CNT %ld after " in init_chip()
1435 &hc->chip); in init_chip()
1444 if (test_bit(HFC_CHIP_PLXSD, &hc->chip)) { in init_chip()
1445 if (test_bit(HFC_CHIP_PCM_MASTER, &hc->chip)) in init_chip()
1448 plx_acc_32 = hc->plx_membase + PLX_GPIOC; in init_chip()
1459 if (hc->pcm) in init_chip()
1461 hc->pcm); in init_chip()
1463 if (test_bit(HFC_CHIP_PCM_MASTER, &hc->chip) in init_chip()
1464 || test_bit(HFC_CHIP_PLXSD, &hc->chip)) { in init_chip()
1467 hc->pcm = PCM_cnt; in init_chip()
1469 "(auto selected)\n", hc->pcm); in init_chip()
1474 hc->hw.r_irqmsk_misc |= V_TI_IRQMSK; in init_chip()
1477 if (hc->ctype == HFC_TYPE_E1) in init_chip()
1478 hc->hw.r_irqmsk_misc |= V_STA_IRQMSK; in init_chip()
1481 if (test_bit(HFC_CHIP_DTMF, &hc->chip)) { in init_chip()
1484 "for all B-channel\n", __func__); in init_chip()
1485 hc->hw.r_dtmf = V_DTMF_EN | V_DTMF_STOP; in init_chip()
1486 if (test_bit(HFC_CHIP_ULAW, &hc->chip)) in init_chip()
1487 hc->hw.r_dtmf |= V_ULAW_SEL; in init_chip()
1488 HFC_outb(hc, R_DTMF_N, 102 - 1); in init_chip()
1489 hc->hw.r_irqmsk_misc |= V_DTMF_IRQMSK; in init_chip()
1493 if (test_bit(HFC_CHIP_ULAW, &hc->chip)) in init_chip()
1497 if (hc->ctype != HFC_TYPE_XHFC) in init_chip()
1501 switch (hc->leds) { in init_chip()
1502 case 1: /* HFC-E1 OEM */ in init_chip()
1503 if (test_bit(HFC_CHIP_WATCHDOG, &hc->chip)) in init_chip()
1514 case 2: /* HFC-4S OEM */ in init_chip()
1522 if (test_bit(HFC_CHIP_EMBSD, &hc->chip)) { in init_chip()
1523 hc->hw.r_st_sync = 0x10; /* V_AUTO_SYNCI */ in init_chip()
1524 HFC_outb(hc, R_ST_SYNC, hc->hw.r_st_sync); in init_chip()
1528 if (hc->masterclk >= 0) { in init_chip()
1532 __func__, hc->masterclk, hc->ports - 1); in init_chip()
1533 hc->hw.r_st_sync |= (hc->masterclk | V_AUTO_SYNC); in init_chip()
1534 HFC_outb(hc, R_ST_SYNC, hc->hw.r_st_sync); in init_chip()
1540 HFC_outb(hc, R_IRQMSK_MISC, hc->hw.r_irqmsk_misc); in init_chip()
1543 hc->hw.r_irqmsk_misc); in init_chip()
1565 printk(KERN_DEBUG "aborting - %d RAM access errors\n", err); in init_chip()
1566 err = -EIO; in init_chip()
1573 spin_unlock_irqrestore(&hc->lock, flags); in init_chip()
1584 hc->wdcount++; in hfcmulti_watchdog()
1586 if (hc->wdcount > 10) { in hfcmulti_watchdog()
1587 hc->wdcount = 0; in hfcmulti_watchdog()
1588 hc->wdbyte = hc->wdbyte == V_GPIO_OUT2 ? in hfcmulti_watchdog()
1591 /* printk("Sending Watchdog Kill %x\n",hc->wdbyte); */ in hfcmulti_watchdog()
1593 HFC_outb(hc, R_GPIO_OUT0, hc->wdbyte); in hfcmulti_watchdog()
1611 switch (hc->leds) { in hfcmulti_leds()
1612 case 1: /* HFC-E1 OEM */ in hfcmulti_leds()
1623 dch = hc->chan[hc->dnum[0]].dch; in hfcmulti_leds()
1625 if (hc->chan[hc->dnum[0]].los) in hfcmulti_leds()
1627 if (hc->e1_state != 1) { in hfcmulti_leds()
1629 hc->flash[2] = 0; in hfcmulti_leds()
1630 hc->flash[3] = 0; in hfcmulti_leds()
1634 if (!hc->flash[2] && hc->activity_tx) in hfcmulti_leds()
1635 hc->flash[2] = poll; in hfcmulti_leds()
1636 if (!hc->flash[3] && hc->activity_rx) in hfcmulti_leds()
1637 hc->flash[3] = poll; in hfcmulti_leds()
1638 if (hc->flash[2] && hc->flash[2] < 1024) in hfcmulti_leds()
1640 if (hc->flash[3] && hc->flash[3] < 1024) in hfcmulti_leds()
1642 if (hc->flash[2] >= 2048) in hfcmulti_leds()
1643 hc->flash[2] = 0; in hfcmulti_leds()
1644 if (hc->flash[3] >= 2048) in hfcmulti_leds()
1645 hc->flash[3] = 0; in hfcmulti_leds()
1646 if (hc->flash[2]) in hfcmulti_leds()
1647 hc->flash[2] += poll; in hfcmulti_leds()
1648 if (hc->flash[3]) in hfcmulti_leds()
1649 hc->flash[3] += poll; in hfcmulti_leds()
1654 if (leds != (int)hc->ledstate) { in hfcmulti_leds()
1656 hc->ledstate = leds; in hfcmulti_leds()
1660 case 2: /* HFC-4S OEM */ in hfcmulti_leds()
1667 active = -1; in hfcmulti_leds()
1668 dch = hc->chan[(i << 2) | 2].dch; in hfcmulti_leds()
1670 state = dch->state; in hfcmulti_leds()
1671 if (dch->dev.D.protocol == ISDN_P_NT_S0) in hfcmulti_leds()
1679 hc->activity_tx |= hc->activity_rx; in hfcmulti_leds()
1680 if (!hc->flash[i] && in hfcmulti_leds()
1681 (hc->activity_tx & (1 << i))) in hfcmulti_leds()
1682 hc->flash[i] = poll; in hfcmulti_leds()
1683 if (hc->flash[i] && hc->flash[i] < 1024) in hfcmulti_leds()
1685 if (hc->flash[i] >= 2048) in hfcmulti_leds()
1686 hc->flash[i] = 0; in hfcmulti_leds()
1687 if (hc->flash[i]) in hfcmulti_leds()
1688 hc->flash[i] += poll; in hfcmulti_leds()
1691 hc->flash[i] = 0; in hfcmulti_leds()
1696 if (test_bit(HFC_CHIP_B410P, &hc->chip)) { in hfcmulti_leds()
1707 if (leds != (int)hc->ledstate) { in hfcmulti_leds()
1709 hc->ledstate = leds; in hfcmulti_leds()
1716 if (leds != (int)hc->ledstate) { in hfcmulti_leds()
1719 hc->ledstate = leds; in hfcmulti_leds()
1731 active = -1; in hfcmulti_leds()
1732 dch = hc->chan[(i << 2) | 2].dch; in hfcmulti_leds()
1734 state = dch->state; in hfcmulti_leds()
1735 if (dch->dev.D.protocol == ISDN_P_NT_S0) in hfcmulti_leds()
1743 hc->activity_tx |= hc->activity_rx; in hfcmulti_leds()
1744 if (!hc->flash[i] && in hfcmulti_leds()
1745 (hc->activity_tx & (1 << i))) in hfcmulti_leds()
1746 hc->flash[i] = poll; in hfcmulti_leds()
1747 if (hc->flash[i] < 1024) in hfcmulti_leds()
1749 if (hc->flash[i] >= 2048) in hfcmulti_leds()
1750 hc->flash[i] = 0; in hfcmulti_leds()
1751 if (hc->flash[i]) in hfcmulti_leds()
1752 hc->flash[i] += poll; in hfcmulti_leds()
1755 hc->flash[i] = 0; in hfcmulti_leds()
1762 if (leds != (int)hc->ledstate) { in hfcmulti_leds()
1767 hc->ledstate = leds; in hfcmulti_leds()
1778 active = -1; in hfcmulti_leds()
1779 dch = hc->chan[(i << 2) | 2].dch; in hfcmulti_leds()
1781 state = dch->state; in hfcmulti_leds()
1782 if (dch->dev.D.protocol == ISDN_P_NT_S0) in hfcmulti_leds()
1790 hc->activity_tx |= hc->activity_rx; in hfcmulti_leds()
1791 if (!hc->flash[i] && in hfcmulti_leds()
1792 (hc->activity_tx & (1 << i))) in hfcmulti_leds()
1793 hc->flash[i] = poll; in hfcmulti_leds()
1794 if (hc->flash[i] < 1024) in hfcmulti_leds()
1796 if (hc->flash[i] >= 2048) in hfcmulti_leds()
1797 hc->flash[i] = 0; in hfcmulti_leds()
1798 if (hc->flash[i]) in hfcmulti_leds()
1799 hc->flash[i] += poll; in hfcmulti_leds()
1801 hc->flash[i] = 0; in hfcmulti_leds()
1805 if (leddw != hc->ledstate) { in hfcmulti_leds()
1810 outw(0x4000, hc->pci_iobase + 4); in hfcmulti_leds()
1811 outl(leddw, hc->pci_iobase); in hfcmulti_leds()
1813 hc->ledstate = leddw; in hfcmulti_leds()
1817 hc->activity_tx = 0; in hfcmulti_leds()
1818 hc->activity_rx = 0; in hfcmulti_leds()
1841 /* only process enabled B-channels */ in hfcmulti_dtmf()
1842 bch = hc->chan[ch].bch; in hfcmulti_dtmf()
1845 if (!hc->created[hc->chan[ch].port]) in hfcmulti_dtmf()
1847 if (!test_bit(FLG_TRANSPARENT, &bch->Flags)) in hfcmulti_dtmf()
1852 coeff = &(hc->chan[ch].coeff[hc->chan[ch].coeff_count * 16]); in hfcmulti_dtmf()
1855 /* read W(n-1) coefficient */ in hfcmulti_dtmf()
1856 addr = hc->DTMFbase + ((co << 7) | (ch << 2)); in hfcmulti_dtmf()
1873 mantissa <<= (exponent - 1); in hfcmulti_dtmf()
1892 mantissa <<= (exponent - 1); in hfcmulti_dtmf()
1903 hc->chan[ch].coeff_count++; in hfcmulti_dtmf()
1904 if (hc->chan[ch].coeff_count == 8) { in hfcmulti_dtmf()
1905 hc->chan[ch].coeff_count = 0; in hfcmulti_dtmf()
1913 hh->prim = PH_CONTROL_IND; in hfcmulti_dtmf()
1914 hh->id = DTMF_HFC_COEF; in hfcmulti_dtmf()
1915 skb_put_data(skb, hc->chan[ch].coeff, 512); in hfcmulti_dtmf()
1921 hc->dtmf = dtmf; in hfcmulti_dtmf()
1923 HFC_outb_nodebug(hc, R_DTMF, hc->hw.r_dtmf | V_RST_DTMF); in hfcmulti_dtmf()
1944 bch = hc->chan[ch].bch; in hfcmulti_tx()
1945 dch = hc->chan[ch].dch; in hfcmulti_tx()
1949 txpending = &hc->chan[ch].txpending; in hfcmulti_tx()
1950 slot_tx = hc->chan[ch].slot_tx; in hfcmulti_tx()
1952 if (!test_bit(FLG_ACTIVE, &dch->Flags)) in hfcmulti_tx()
1954 sp = &dch->tx_skb; in hfcmulti_tx()
1955 idxp = &dch->tx_idx; in hfcmulti_tx()
1957 if (!test_bit(FLG_ACTIVE, &bch->Flags)) in hfcmulti_tx()
1959 sp = &bch->tx_skb; in hfcmulti_tx()
1960 idxp = &bch->tx_idx; in hfcmulti_tx()
1963 len = (*sp)->len; in hfcmulti_tx()
1968 if (test_bit(HFC_CHIP_B410P, &hc->chip) && in hfcmulti_tx()
1969 (hc->chan[ch].protocol == ISDN_P_B_RAW) && in hfcmulti_tx()
1970 (hc->chan[ch].slot_rx < 0) && in hfcmulti_tx()
1971 (hc->chan[ch].slot_tx < 0)) in hfcmulti_tx()
1985 if (dch || test_bit(FLG_HDLC, &bch->Flags)) { in hfcmulti_tx()
1992 __func__, hc->id + 1, temp, f2); in hfcmulti_tx()
1995 Fspace = f2 - f1 - 1; in hfcmulti_tx()
1997 Fspace += hc->Flen; in hfcmulti_tx()
1999 * Old FIFO handling doesn't give us the current Z2 read in hfcmulti_tx()
2004 if (test_bit(HFC_CHIP_REVISION0, &hc->chip)) { in hfcmulti_tx()
2010 /* one frame only for ST D-channels, to allow resending */ in hfcmulti_tx()
2011 if (hc->ctype != HFC_TYPE_E1 && dch) { in hfcmulti_tx()
2015 /* F-counter full condition */ in hfcmulti_tx()
2019 z1 = HFC_inw_nodebug(hc, A_Z1) - hc->Zmin; in hfcmulti_tx()
2020 z2 = HFC_inw_nodebug(hc, A_Z2) - hc->Zmin; in hfcmulti_tx()
2021 while (z2 != (temp = (HFC_inw_nodebug(hc, A_Z2) - hc->Zmin))) { in hfcmulti_tx()
2024 "%d!=%d\n", __func__, hc->id + 1, temp, z2); in hfcmulti_tx()
2027 hc->chan[ch].Zfill = z1 - z2; in hfcmulti_tx()
2028 if (hc->chan[ch].Zfill < 0) in hfcmulti_tx()
2029 hc->chan[ch].Zfill += hc->Zlen; in hfcmulti_tx()
2030 Zspace = z2 - z1; in hfcmulti_tx()
2032 Zspace += hc->Zlen; in hfcmulti_tx()
2033 Zspace -= 4; /* keep not too full, so pointers will not overrun */ in hfcmulti_tx()
2035 if (bch && test_bit(FLG_TRANSPARENT, &bch->Flags)) in hfcmulti_tx()
2036 Zspace = Zspace - hc->Zlen + hc->max_trans; in hfcmulti_tx()
2044 if (bch && (!test_bit(FLG_HDLC, &bch->Flags)) && in hfcmulti_tx()
2053 if (hc->ctype == HFC_TYPE_XHFC) in hfcmulti_tx()
2062 if (hc->ctype == HFC_TYPE_XHFC) in hfcmulti_tx()
2078 if (bch && test_bit(FLG_FILLEMPTY, &bch->Flags) in hfcmulti_tx()
2079 && !test_bit(FLG_HDLC, &bch->Flags) && z2 == z1) { in hfcmulti_tx()
2084 hc->write_fifo(hc, hc->silence_data, poll >> 1); in hfcmulti_tx()
2085 Zspace -= (poll >> 1); in hfcmulti_tx()
2089 if (bch && (!test_bit(FLG_HDLC, &bch->Flags)) && (!*txpending) in hfcmulti_tx()
2096 if (hc->ctype == HFC_TYPE_XHFC) in hfcmulti_tx()
2105 if (hc->ctype == HFC_TYPE_XHFC) in hfcmulti_tx()
2119 hc->activity_tx |= 1 << hc->chan[ch].port; in hfcmulti_tx()
2123 if (dch || test_bit(FLG_HDLC, &bch->Flags)) in hfcmulti_tx()
2128 d = (*sp)->data + i; in hfcmulti_tx()
2129 if (ii - i > Zspace) in hfcmulti_tx()
2134 __func__, hc->id + 1, ch, Zspace, z1, z2, ii-i, len-i, in hfcmulti_tx()
2138 hc->write_fifo(hc, d, ii - i); in hfcmulti_tx()
2139 hc->chan[ch].Zfill += ii - i; in hfcmulti_tx()
2149 if (dch || test_bit(FLG_HDLC, &bch->Flags)) { in hfcmulti_tx()
2150 /* increment f-counter */ in hfcmulti_tx()
2158 len = (*sp)->len; in hfcmulti_tx()
2162 len = (*sp)->len; in hfcmulti_tx()
2171 if (bch && test_bit(FLG_TRANSPARENT, &bch->Flags)) in hfcmulti_tx()
2172 HFC_outb_nodebug(hc, A_FIFO_DATA0_NOINC, hc->silence); in hfcmulti_tx()
2189 bch = hc->chan[ch].bch; in hfcmulti_rx()
2191 if (!test_bit(FLG_ACTIVE, &bch->Flags)) in hfcmulti_rx()
2193 } else if (hc->chan[ch].dch) { in hfcmulti_rx()
2194 dch = hc->chan[ch].dch; in hfcmulti_rx()
2195 if (!test_bit(FLG_ACTIVE, &dch->Flags)) in hfcmulti_rx()
2203 if (test_bit(HFC_CHIP_B410P, &hc->chip) && in hfcmulti_rx()
2204 (hc->chan[ch].protocol == ISDN_P_B_RAW) && in hfcmulti_rx()
2205 (hc->chan[ch].slot_rx < 0) && in hfcmulti_rx()
2206 (hc->chan[ch].slot_tx < 0)) in hfcmulti_rx()
2213 if (hc->chan[ch].rx_off) { in hfcmulti_rx()
2215 bch->dropcnt += poll; /* not exact but fair enough */ in hfcmulti_rx()
2219 if (dch || test_bit(FLG_HDLC, &bch->Flags)) { in hfcmulti_rx()
2225 __func__, hc->id + 1, temp, f1); in hfcmulti_rx()
2230 z1 = HFC_inw_nodebug(hc, A_Z1) - hc->Zmin; in hfcmulti_rx()
2231 while (z1 != (temp = (HFC_inw_nodebug(hc, A_Z1) - hc->Zmin))) { in hfcmulti_rx()
2234 "%d!=%d\n", __func__, hc->id + 1, temp, z2); in hfcmulti_rx()
2237 z2 = HFC_inw_nodebug(hc, A_Z2) - hc->Zmin; in hfcmulti_rx()
2238 Zsize = z1 - z2; in hfcmulti_rx()
2239 if ((dch || test_bit(FLG_HDLC, &bch->Flags)) && f1 != f2) in hfcmulti_rx()
2243 Zsize += hc->Zlen; in hfcmulti_rx()
2252 hc->id + 1, bch->nr, Zsize); in hfcmulti_rx()
2255 sp = &bch->rx_skb; in hfcmulti_rx()
2256 maxlen = bch->maxlen; in hfcmulti_rx()
2258 sp = &dch->rx_skb; in hfcmulti_rx()
2259 maxlen = dch->maxlen + 3; in hfcmulti_rx()
2264 hc->id + 1); in hfcmulti_rx()
2271 hc->activity_rx |= 1 << hc->chan[ch].port; in hfcmulti_rx()
2274 if (dch || test_bit(FLG_HDLC, &bch->Flags)) { in hfcmulti_rx()
2278 "got=%d (again %d)\n", __func__, hc->id + 1, ch, in hfcmulti_rx()
2280 f1, f2, Zsize + (*sp)->len, again); in hfcmulti_rx()
2282 if ((Zsize + (*sp)->len) > maxlen) { in hfcmulti_rx()
2285 "%s(card %d): hdlc-frame too large.\n", in hfcmulti_rx()
2286 __func__, hc->id + 1); in hfcmulti_rx()
2293 hc->read_fifo(hc, skb_put(*sp, Zsize), Zsize); in hfcmulti_rx()
2296 /* increment Z2,F2-counter */ in hfcmulti_rx()
2300 if ((*sp)->len < 4) { in hfcmulti_rx()
2304 "size\n", __func__, hc->id + 1); in hfcmulti_rx()
2309 if ((*sp)->data[(*sp)->len - 1]) { in hfcmulti_rx()
2312 "%s: CRC-error\n", __func__); in hfcmulti_rx()
2316 skb_trim(*sp, (*sp)->len - 3); in hfcmulti_rx()
2317 if ((*sp)->len < MISDN_COPY_SIZE) { in hfcmulti_rx()
2319 *sp = mI_alloc_skb(skb->len, GFP_ATOMIC); in hfcmulti_rx()
2321 skb_put_data(*sp, skb->data, skb->len); in hfcmulti_rx()
2334 __func__, hc->id + 1); in hfcmulti_rx()
2336 while (temp < (*sp)->len) in hfcmulti_rx()
2337 printk(" %02x", (*sp)->data[temp++]); in hfcmulti_rx()
2351 hc->read_fifo(hc, skb_put(*sp, Zsize), Zsize); in hfcmulti_rx()
2356 __func__, hc->id + 1, ch, Zsize, z1, z2); in hfcmulti_rx()
2358 recv_Bchannel(bch, hc->chan[ch].Zfill, false); in hfcmulti_rx()
2392 if (hc->e1_resync) { in handle_timer_irq()
2395 if (hc->e1_resync & 1) { in handle_timer_irq()
2400 if (test_bit(HFC_CHIP_RX_SYNC, &hc->chip)) in handle_timer_irq()
2403 if (hc->e1_resync & 2) { in handle_timer_irq()
2408 if (hc->e1_resync & 4) { in handle_timer_irq()
2411 "Enable QUARTZ for HFC-E1\n"); in handle_timer_irq()
2418 hc->e1_resync = 0; in handle_timer_irq()
2422 if (hc->ctype != HFC_TYPE_E1 || hc->e1_state == 1) in handle_timer_irq()
2424 if (hc->created[hc->chan[ch].port]) { in handle_timer_irq()
2426 /* fifo is started when switching to rx-fifo */ in handle_timer_irq()
2428 if (hc->chan[ch].dch && in handle_timer_irq()
2429 hc->chan[ch].nt_timer > -1) { in handle_timer_irq()
2430 dch = hc->chan[ch].dch; in handle_timer_irq()
2431 if (!(--hc->chan[ch].nt_timer)) { in handle_timer_irq()
2440 dch->state); in handle_timer_irq()
2445 if (hc->ctype == HFC_TYPE_E1 && hc->created[0]) { in handle_timer_irq()
2446 dch = hc->chan[hc->dnum[0]].dch; in handle_timer_irq()
2449 hc->chan[hc->dnum[0]].los = temp; in handle_timer_irq()
2450 if (test_bit(HFC_CFG_REPORT_LOS, &hc->chan[hc->dnum[0]].cfg)) { in handle_timer_irq()
2451 if (!temp && hc->chan[hc->dnum[0]].los) in handle_timer_irq()
2454 if (temp && !hc->chan[hc->dnum[0]].los) in handle_timer_irq()
2458 if (test_bit(HFC_CFG_REPORT_AIS, &hc->chan[hc->dnum[0]].cfg)) { in handle_timer_irq()
2461 if (!temp && hc->chan[hc->dnum[0]].ais) in handle_timer_irq()
2464 if (temp && !hc->chan[hc->dnum[0]].ais) in handle_timer_irq()
2467 hc->chan[hc->dnum[0]].ais = temp; in handle_timer_irq()
2469 if (test_bit(HFC_CFG_REPORT_SLIP, &hc->chan[hc->dnum[0]].cfg)) { in handle_timer_irq()
2472 if (!temp && hc->chan[hc->dnum[0]].slip_rx) in handle_timer_irq()
2475 hc->chan[hc->dnum[0]].slip_rx = temp; in handle_timer_irq()
2477 if (!temp && hc->chan[hc->dnum[0]].slip_tx) in handle_timer_irq()
2480 hc->chan[hc->dnum[0]].slip_tx = temp; in handle_timer_irq()
2482 if (test_bit(HFC_CFG_REPORT_RDI, &hc->chan[hc->dnum[0]].cfg)) { in handle_timer_irq()
2485 if (!temp && hc->chan[hc->dnum[0]].rdi) in handle_timer_irq()
2488 if (temp && !hc->chan[hc->dnum[0]].rdi) in handle_timer_irq()
2491 hc->chan[hc->dnum[0]].rdi = temp; in handle_timer_irq()
2494 switch (hc->chan[hc->dnum[0]].sync) { in handle_timer_irq()
2501 __func__, hc->id); in handle_timer_irq()
2503 hc->chan[hc->dnum[0]].jitter | V_RX_INIT); in handle_timer_irq()
2505 hc->chan[hc->dnum[0]].jitter | V_RX_INIT); in handle_timer_irq()
2506 hc->chan[hc->dnum[0]].sync = 1; in handle_timer_irq()
2516 __func__, hc->id); in handle_timer_irq()
2517 hc->chan[hc->dnum[0]].sync = 0; in handle_timer_irq()
2527 __func__, hc->id); in handle_timer_irq()
2528 hc->chan[hc->dnum[0]].sync = 2; in handle_timer_irq()
2537 __func__, hc->id); in handle_timer_irq()
2538 hc->chan[hc->dnum[0]].sync = 0; in handle_timer_irq()
2547 __func__, hc->id); in handle_timer_irq()
2548 hc->chan[hc->dnum[0]].sync = 1; in handle_timer_irq()
2554 if (test_bit(HFC_CHIP_WATCHDOG, &hc->chip)) in handle_timer_irq()
2557 if (hc->leds) in handle_timer_irq()
2571 if (hc->chan[ch].dch) { in ph_state_irq()
2572 dch = hc->chan[ch].dch; in ph_state_irq()
2575 hc->chan[ch].port); in ph_state_irq()
2576 /* undocumented: delay after R_ST_SEL */ in ph_state_irq()
2590 /* Speech Design TE-sync indication */ in ph_state_irq()
2591 if (test_bit(HFC_CHIP_PLXSD, &hc->chip) && in ph_state_irq()
2592 dch->dev.D.protocol == ISDN_P_TE_S0) { in ph_state_irq()
2594 hc->syncronized |= in ph_state_irq()
2595 (1 << hc->chan[ch].port); in ph_state_irq()
2597 hc->syncronized &= in ph_state_irq()
2598 ~(1 << hc->chan[ch].port); in ph_state_irq()
2600 dch->state = st_status & 0x0f; in ph_state_irq()
2601 if (dch->dev.D.protocol == ISDN_P_NT_S0) in ph_state_irq()
2605 if (dch->state == active) { in ph_state_irq()
2612 dch->tx_idx = 0; in ph_state_irq()
2618 __func__, dch->state, in ph_state_irq()
2619 hc->chan[ch].port); in ph_state_irq()
2624 if (test_bit(HFC_CHIP_PLXSD, &hc->chip)) in ph_state_irq()
2640 dch = hc->chan[ch].dch; in fifo_irq()
2641 bch = hc->chan[ch].bch; in fifo_irq()
2642 if (((!dch) && (!bch)) || (!hc->created[hc->chan[ch].port])) { in fifo_irq()
2647 test_bit(FLG_ACTIVE, &dch->Flags)) { in fifo_irq()
2654 test_bit(FLG_ACTIVE, &bch->Flags)) { in fifo_irq()
2662 test_bit(FLG_ACTIVE, &dch->Flags)) { in fifo_irq()
2666 test_bit(FLG_ACTIVE, &bch->Flags)) { in fifo_irq()
2693 printk(KERN_ERR "HFC-multi: Spurious interrupt!\n"); in hfcmulti_interrupt()
2697 spin_lock(&hc->lock); in hfcmulti_interrupt()
2702 "card %d, this is no bug.\n", hc->id + 1, irqsem); in hfcmulti_interrupt()
2703 irqsem = hc->id + 1; in hfcmulti_interrupt()
2706 if (hc->immap->im_cpm.cp_pbdat & hc->pb_irqmsk) in hfcmulti_interrupt()
2709 if (test_bit(HFC_CHIP_PLXSD, &hc->chip)) { in hfcmulti_interrupt()
2711 plx_acc = hc->plx_membase + PLX_INTCSR; in hfcmulti_interrupt()
2743 /* irq is not for us */ in hfcmulti_interrupt()
2746 hc->irqcnt++; in hfcmulti_interrupt()
2748 if (hc->ctype != HFC_TYPE_E1) in hfcmulti_interrupt()
2760 r_irq_misc &= hc->hw.r_irqmsk_misc; /* ignore disabled irqs */ in hfcmulti_interrupt()
2762 if (hc->ctype == HFC_TYPE_E1) { in hfcmulti_interrupt()
2764 dch = hc->chan[hc->dnum[0]].dch; in hfcmulti_interrupt()
2766 if (test_bit(HFC_CHIP_PLXSD, &hc->chip) in hfcmulti_interrupt()
2767 && hc->e1_getclock) { in hfcmulti_interrupt()
2769 hc->syncronized = 1; in hfcmulti_interrupt()
2771 hc->syncronized = 0; in hfcmulti_interrupt()
2787 __func__, hc->id, temp & 0x7); in hfcmulti_interrupt()
2788 for (i = 0; i < hc->ports; i++) { in hfcmulti_interrupt()
2789 dch = hc->chan[hc->dnum[i]].dch; in hfcmulti_interrupt()
2790 dch->state = temp & 0x7; in hfcmulti_interrupt()
2794 if (test_bit(HFC_CHIP_PLXSD, &hc->chip)) in hfcmulti_interrupt()
2799 if (hc->iclock_on) in hfcmulti_interrupt()
2800 mISDN_clock_update(hc->iclock, poll, NULL); in hfcmulti_interrupt()
2810 printk(KERN_DEBUG "%s: got V_IRQ_PROC -" in hfcmulti_interrupt()
2827 spin_unlock(&hc->lock); in hfcmulti_interrupt()
2834 spin_unlock(&hc->lock); in hfcmulti_interrupt()
2840 * timer callback for D-chan busy resolution. Currently no function
2852 * configure B-channel with the given protocol
2853 * ch eqals to the HFC-channel (0-31)
2854 * ch is the number of channel (0-4,4-7,8-11,12-15,16-19,20-23,24-27,28-31
2855 * for S/T, 1-31 for E1)
2867 return -EINVAL; in mode_hfcmulti()
2868 oslot_tx = hc->chan[ch].slot_tx; in mode_hfcmulti()
2869 oslot_rx = hc->chan[ch].slot_rx; in mode_hfcmulti()
2870 conf = hc->chan[ch].conf; in mode_hfcmulti()
2876 __func__, hc->id, ch, protocol, oslot_tx, slot_tx, in mode_hfcmulti()
2884 if (hc->slot_owner[oslot_tx << 1] == ch) { in mode_hfcmulti()
2887 if (hc->ctype != HFC_TYPE_XHFC) in mode_hfcmulti()
2889 hc->slot_owner[oslot_tx << 1] = -1; in mode_hfcmulti()
2895 __func__, hc->slot_owner[oslot_tx << 1]); in mode_hfcmulti()
2905 if (hc->slot_owner[(oslot_rx << 1) | 1] == ch) { in mode_hfcmulti()
2908 hc->slot_owner[(oslot_rx << 1) | 1] = -1; in mode_hfcmulti()
2915 hc->slot_owner[(oslot_rx << 1) | 1]); in mode_hfcmulti()
2920 flow_tx = 0x80; /* FIFO->ST */ in mode_hfcmulti()
2922 hc->chan[ch].slot_tx = -1; in mode_hfcmulti()
2923 hc->chan[ch].bank_tx = 0; in mode_hfcmulti()
2926 if (hc->chan[ch].txpending) in mode_hfcmulti()
2927 flow_tx = 0x80; /* FIFO->ST */ in mode_hfcmulti()
2929 flow_tx = 0xc0; /* PCM->ST */ in mode_hfcmulti()
2941 if (hc->ctype != HFC_TYPE_XHFC) in mode_hfcmulti()
2944 hc->slot_owner[slot_tx << 1] = ch; in mode_hfcmulti()
2945 hc->chan[ch].slot_tx = slot_tx; in mode_hfcmulti()
2946 hc->chan[ch].bank_tx = bank_tx; in mode_hfcmulti()
2950 flow_rx = 0x80; /* ST->FIFO */ in mode_hfcmulti()
2951 hc->chan[ch].slot_rx = -1; in mode_hfcmulti()
2952 hc->chan[ch].bank_rx = 0; in mode_hfcmulti()
2955 if (hc->chan[ch].txpending) in mode_hfcmulti()
2956 flow_rx = 0x80; /* ST->FIFO */ in mode_hfcmulti()
2958 flow_rx = 0xc0; /* ST->(FIFO,PCM) */ in mode_hfcmulti()
2970 hc->slot_owner[(slot_rx << 1) | 1] = ch; in mode_hfcmulti()
2971 hc->chan[ch].slot_rx = slot_rx; in mode_hfcmulti()
2972 hc->chan[ch].bank_rx = bank_rx; in mode_hfcmulti()
2993 if (hc->chan[ch].bch && hc->ctype != HFC_TYPE_E1) { in mode_hfcmulti()
2994 hc->hw.a_st_ctrl0[hc->chan[ch].port] &= in mode_hfcmulti()
2996 HFC_outb(hc, R_ST_SEL, hc->chan[ch].port); in mode_hfcmulti()
2997 /* undocumented: delay after R_ST_SEL */ in mode_hfcmulti()
3000 hc->hw.a_st_ctrl0[hc->chan[ch].port]); in mode_hfcmulti()
3002 if (hc->chan[ch].bch) { in mode_hfcmulti()
3003 test_and_clear_bit(FLG_HDLC, &hc->chan[ch].bch->Flags); in mode_hfcmulti()
3005 &hc->chan[ch].bch->Flags); in mode_hfcmulti()
3008 case (ISDN_P_B_RAW): /* B-channel */ in mode_hfcmulti()
3010 if (test_bit(HFC_CHIP_B410P, &hc->chip) && in mode_hfcmulti()
3011 (hc->chan[ch].slot_rx < 0) && in mode_hfcmulti()
3012 (hc->chan[ch].slot_tx < 0)) { in mode_hfcmulti()
3015 "Setting B-channel %d to echo cancelable " in mode_hfcmulti()
3023 /* S/T -> PCM */ in mode_hfcmulti()
3031 /* PCM -> FIFO */ in mode_hfcmulti()
3037 if (hc->chan[ch].protocol != protocol) { in mode_hfcmulti()
3046 /* PCM -> S/T */ in mode_hfcmulti()
3054 /* FIFO -> PCM */ in mode_hfcmulti()
3060 if (hc->chan[ch].protocol != protocol) { in mode_hfcmulti()
3065 HFC_outb_nodebug(hc, A_FIFO_DATA0_NOINC, hc->silence); in mode_hfcmulti()
3073 if (hc->ctype == HFC_TYPE_XHFC) in mode_hfcmulti()
3082 if (hc->chan[ch].protocol != protocol) { in mode_hfcmulti()
3087 HFC_outb_nodebug(hc, A_FIFO_DATA0_NOINC, hc->silence); in mode_hfcmulti()
3091 if (hc->ctype == HFC_TYPE_XHFC) in mode_hfcmulti()
3100 if (hc->chan[ch].protocol != protocol) { in mode_hfcmulti()
3105 if (hc->ctype != HFC_TYPE_E1) { in mode_hfcmulti()
3106 hc->hw.a_st_ctrl0[hc->chan[ch].port] |= in mode_hfcmulti()
3108 HFC_outb(hc, R_ST_SEL, hc->chan[ch].port); in mode_hfcmulti()
3109 /* undocumented: delay after R_ST_SEL */ in mode_hfcmulti()
3112 hc->hw.a_st_ctrl0[hc->chan[ch].port]); in mode_hfcmulti()
3114 if (hc->chan[ch].bch) in mode_hfcmulti()
3116 &hc->chan[ch].bch->Flags); in mode_hfcmulti()
3118 case (ISDN_P_B_HDLC): /* B-channel */ in mode_hfcmulti()
3119 case (ISDN_P_TE_S0): /* D-channel */ in mode_hfcmulti()
3126 if (hc->ctype == HFC_TYPE_E1 || hc->chan[ch].bch) { in mode_hfcmulti()
3127 /* E1 or B-channel */ in mode_hfcmulti()
3131 /* D-Channel without HDLC fill flags */ in mode_hfcmulti()
3142 if (hc->ctype == HFC_TYPE_E1 || hc->chan[ch].bch) in mode_hfcmulti()
3149 if (hc->chan[ch].bch) { in mode_hfcmulti()
3150 test_and_set_bit(FLG_HDLC, &hc->chan[ch].bch->Flags); in mode_hfcmulti()
3151 if (hc->ctype != HFC_TYPE_E1) { in mode_hfcmulti()
3152 hc->hw.a_st_ctrl0[hc->chan[ch].port] |= in mode_hfcmulti()
3154 HFC_outb(hc, R_ST_SEL, hc->chan[ch].port); in mode_hfcmulti()
3155 /* undocumented: delay after R_ST_SEL */ in mode_hfcmulti()
3158 hc->hw.a_st_ctrl0[hc->chan[ch].port]); in mode_hfcmulti()
3165 hc->chan[ch].protocol = ISDN_P_NONE; in mode_hfcmulti()
3166 return -ENOPROTOOPT; in mode_hfcmulti()
3168 hc->chan[ch].protocol = protocol; in mode_hfcmulti()
3183 mode_hfcmulti(hc, ch, hc->chan[ch].protocol, -1, 0, -1, 0); in hfcmulti_pcm()
3188 mode_hfcmulti(hc, ch, hc->chan[ch].protocol, slot_tx, bank_tx, in hfcmulti_pcm()
3200 hc->chan[ch].conf = num; in hfcmulti_conf()
3202 hc->chan[ch].conf = -1; in hfcmulti_conf()
3203 mode_hfcmulti(hc, ch, hc->chan[ch].protocol, hc->chan[ch].slot_tx, in hfcmulti_conf()
3204 hc->chan[ch].bank_tx, hc->chan[ch].slot_rx, in hfcmulti_conf()
3205 hc->chan[ch].bank_rx); in hfcmulti_conf()
3221 struct hfc_multi *hc = dch->hw; in hfcm_l1callback()
3230 spin_lock_irqsave(&hc->lock, flags); in hfcm_l1callback()
3231 if (hc->ctype == HFC_TYPE_E1) { in hfcm_l1callback()
3237 HFC_outb(hc, R_ST_SEL, hc->chan[dch->slot].port); in hfcm_l1callback()
3238 /* undocumented: delay after R_ST_SEL */ in hfcm_l1callback()
3241 udelay(6); /* wait at least 5,21us */ in hfcm_l1callback()
3246 spin_unlock_irqrestore(&hc->lock, flags); in hfcm_l1callback()
3247 l1_event(dch->l1, HW_POWERUP_IND); in hfcm_l1callback()
3251 spin_lock_irqsave(&hc->lock, flags); in hfcm_l1callback()
3252 if (hc->ctype == HFC_TYPE_E1) { in hfcm_l1callback()
3258 HFC_outb(hc, R_ST_SEL, hc->chan[dch->slot].port); in hfcm_l1callback()
3259 /* undocumented: delay after R_ST_SEL */ in hfcm_l1callback()
3263 if (test_bit(HFC_CHIP_PLXSD, &hc->chip)) { in hfcm_l1callback()
3264 hc->syncronized &= in hfcm_l1callback()
3265 ~(1 << hc->chan[dch->slot].port); in hfcm_l1callback()
3269 skb_queue_purge(&dch->squeue); in hfcm_l1callback()
3270 if (dch->tx_skb) { in hfcm_l1callback()
3271 dev_kfree_skb(dch->tx_skb); in hfcm_l1callback()
3272 dch->tx_skb = NULL; in hfcm_l1callback()
3274 dch->tx_idx = 0; in hfcm_l1callback()
3275 if (dch->rx_skb) { in hfcm_l1callback()
3276 dev_kfree_skb(dch->rx_skb); in hfcm_l1callback()
3277 dch->rx_skb = NULL; in hfcm_l1callback()
3279 test_and_clear_bit(FLG_TX_BUSY, &dch->Flags); in hfcm_l1callback()
3280 if (test_and_clear_bit(FLG_BUSY_TIMER, &dch->Flags)) in hfcm_l1callback()
3281 del_timer(&dch->timer); in hfcm_l1callback()
3282 spin_unlock_irqrestore(&hc->lock, flags); in hfcm_l1callback()
3285 spin_lock_irqsave(&hc->lock, flags); in hfcm_l1callback()
3286 if (hc->ctype == HFC_TYPE_E1) { in hfcm_l1callback()
3292 HFC_outb(hc, R_ST_SEL, hc->chan[dch->slot].port); in hfcm_l1callback()
3293 /* undocumented: delay after R_ST_SEL */ in hfcm_l1callback()
3296 udelay(6); /* wait at least 5,21us */ in hfcm_l1callback()
3299 spin_unlock_irqrestore(&hc->lock, flags); in hfcm_l1callback()
3302 test_and_set_bit(FLG_ACTIVE, &dch->Flags); in hfcm_l1callback()
3303 _queue_data(&dch->dev.D, cmd, MISDN_ID_ANY, 0, NULL, in hfcm_l1callback()
3307 test_and_clear_bit(FLG_ACTIVE, &dch->Flags); in hfcm_l1callback()
3308 _queue_data(&dch->dev.D, cmd, MISDN_ID_ANY, 0, NULL, in hfcm_l1callback()
3312 if (dch->debug & DEBUG_HW) in hfcm_l1callback()
3315 return -1; in hfcm_l1callback()
3321 * Layer2 -> Layer 1 Transfer
3329 struct hfc_multi *hc = dch->hw; in handle_dmsg()
3331 int ret = -EINVAL; in handle_dmsg()
3335 switch (hh->prim) { in handle_dmsg()
3337 if (skb->len < 1) in handle_dmsg()
3339 spin_lock_irqsave(&hc->lock, flags); in handle_dmsg()
3342 id = hh->id; /* skb can be freed */ in handle_dmsg()
3343 hfcmulti_tx(hc, dch->slot); in handle_dmsg()
3348 spin_unlock_irqrestore(&hc->lock, flags); in handle_dmsg()
3351 spin_unlock_irqrestore(&hc->lock, flags); in handle_dmsg()
3354 if (dch->dev.D.protocol != ISDN_P_TE_S0) { in handle_dmsg()
3355 spin_lock_irqsave(&hc->lock, flags); in handle_dmsg()
3360 __func__, hc->chan[dch->slot].port, in handle_dmsg()
3361 hc->ports - 1); in handle_dmsg()
3363 if (hc->ctype == HFC_TYPE_E1) { in handle_dmsg()
3368 __func__, dch->state); in handle_dmsg()
3371 hc->chan[dch->slot].port); in handle_dmsg()
3372 /* undocumented: delay after R_ST_SEL */ in handle_dmsg()
3376 udelay(6); /* wait at least 5,21us */ in handle_dmsg()
3380 dch->state = 1; in handle_dmsg()
3382 spin_unlock_irqrestore(&hc->lock, flags); in handle_dmsg()
3384 ret = l1_event(dch->l1, hh->prim); in handle_dmsg()
3387 test_and_clear_bit(FLG_L2_ACTIVATED, &dch->Flags); in handle_dmsg()
3388 if (dch->dev.D.protocol != ISDN_P_TE_S0) { in handle_dmsg()
3389 spin_lock_irqsave(&hc->lock, flags); in handle_dmsg()
3393 __func__, hc->chan[dch->slot].port, in handle_dmsg()
3394 hc->ports - 1); in handle_dmsg()
3396 if (hc->ctype == HFC_TYPE_E1) { in handle_dmsg()
3403 hc->chan[dch->slot].port); in handle_dmsg()
3404 /* undocumented: delay after R_ST_SEL */ in handle_dmsg()
3408 dch->state = 1; in handle_dmsg()
3410 skb_queue_purge(&dch->squeue); in handle_dmsg()
3411 if (dch->tx_skb) { in handle_dmsg()
3412 dev_kfree_skb(dch->tx_skb); in handle_dmsg()
3413 dch->tx_skb = NULL; in handle_dmsg()
3415 dch->tx_idx = 0; in handle_dmsg()
3416 if (dch->rx_skb) { in handle_dmsg()
3417 dev_kfree_skb(dch->rx_skb); in handle_dmsg()
3418 dch->rx_skb = NULL; in handle_dmsg()
3420 test_and_clear_bit(FLG_TX_BUSY, &dch->Flags); in handle_dmsg()
3421 if (test_and_clear_bit(FLG_BUSY_TIMER, &dch->Flags)) in handle_dmsg()
3422 del_timer(&dch->timer); in handle_dmsg()
3424 if (test_and_clear_bit(FLG_L1_BUSY, &dch->Flags)) in handle_dmsg()
3425 dchannel_sched_event(&hc->dch, D_CLEARBUSY); in handle_dmsg()
3428 spin_unlock_irqrestore(&hc->lock, flags); in handle_dmsg()
3430 ret = l1_event(dch->l1, hh->prim); in handle_dmsg()
3441 struct hfc_multi *hc = bch->hw; in deactivate_bchannel()
3444 spin_lock_irqsave(&hc->lock, flags); in deactivate_bchannel()
3446 hc->chan[bch->slot].coeff_count = 0; in deactivate_bchannel()
3447 hc->chan[bch->slot].rx_off = 0; in deactivate_bchannel()
3448 hc->chan[bch->slot].conf = -1; in deactivate_bchannel()
3449 mode_hfcmulti(hc, bch->slot, ISDN_P_NONE, -1, 0, -1, 0); in deactivate_bchannel()
3450 spin_unlock_irqrestore(&hc->lock, flags); in deactivate_bchannel()
3457 struct hfc_multi *hc = bch->hw; in handle_bmsg()
3458 int ret = -EINVAL; in handle_bmsg()
3462 switch (hh->prim) { in handle_bmsg()
3464 if (!skb->len) in handle_bmsg()
3466 spin_lock_irqsave(&hc->lock, flags); in handle_bmsg()
3469 hfcmulti_tx(hc, bch->slot); in handle_bmsg()
3475 spin_unlock_irqrestore(&hc->lock, flags); in handle_bmsg()
3480 __func__, bch->slot); in handle_bmsg()
3481 spin_lock_irqsave(&hc->lock, flags); in handle_bmsg()
3482 /* activate B-channel if not already activated */ in handle_bmsg()
3483 if (!test_and_set_bit(FLG_ACTIVE, &bch->Flags)) { in handle_bmsg()
3484 hc->chan[bch->slot].txpending = 0; in handle_bmsg()
3485 ret = mode_hfcmulti(hc, bch->slot, in handle_bmsg()
3486 ch->protocol, in handle_bmsg()
3487 hc->chan[bch->slot].slot_tx, in handle_bmsg()
3488 hc->chan[bch->slot].bank_tx, in handle_bmsg()
3489 hc->chan[bch->slot].slot_rx, in handle_bmsg()
3490 hc->chan[bch->slot].bank_rx); in handle_bmsg()
3492 if (ch->protocol == ISDN_P_B_RAW && !hc->dtmf in handle_bmsg()
3493 && test_bit(HFC_CHIP_DTMF, &hc->chip)) { in handle_bmsg()
3495 hc->dtmf = 1; in handle_bmsg()
3500 HFC_outb(hc, R_DTMF, hc->hw.r_dtmf | in handle_bmsg()
3506 spin_unlock_irqrestore(&hc->lock, flags); in handle_bmsg()
3512 spin_lock_irqsave(&hc->lock, flags); in handle_bmsg()
3513 switch (hh->id) { in handle_bmsg()
3518 __func__, skb->len); in handle_bmsg()
3530 __func__, hh->id); in handle_bmsg()
3531 ret = -EINVAL; in handle_bmsg()
3533 spin_unlock_irqrestore(&hc->lock, flags); in handle_bmsg()
3555 (struct dsp_features *)(*((u_long *)&cq->p1)); in channel_bctrl()
3556 struct hfc_multi *hc = bch->hw; in channel_bctrl()
3563 switch (cq->op) { in channel_bctrl()
3566 cq->op |= MISDN_CTRL_HFC_OP | MISDN_CTRL_HW_FEATURES_OP; in channel_bctrl()
3570 hc->chan[bch->slot].rx_off = !!cq->p1; in channel_bctrl()
3571 if (!hc->chan[bch->slot].rx_off) { in channel_bctrl()
3573 HFC_outb_nodebug(hc, R_FIFO, (bch->slot << 1) | 1); in channel_bctrl()
3580 __func__, bch->nr, hc->chan[bch->slot].rx_off); in channel_bctrl()
3584 hc->silence = bch->fill[0]; in channel_bctrl()
3585 memset(hc->silence_data, hc->silence, sizeof(hc->silence_data)); in channel_bctrl()
3592 features->hfc_id = hc->id; in channel_bctrl()
3593 if (test_bit(HFC_CHIP_DTMF, &hc->chip)) in channel_bctrl()
3594 features->hfc_dtmf = 1; in channel_bctrl()
3595 if (test_bit(HFC_CHIP_CONF, &hc->chip)) in channel_bctrl()
3596 features->hfc_conf = 1; in channel_bctrl()
3597 features->hfc_loops = 0; in channel_bctrl()
3598 if (test_bit(HFC_CHIP_B410P, &hc->chip)) { in channel_bctrl()
3599 features->hfc_echocanhw = 1; in channel_bctrl()
3601 features->pcm_id = hc->pcm; in channel_bctrl()
3602 features->pcm_slots = hc->slots; in channel_bctrl()
3603 features->pcm_banks = 2; in channel_bctrl()
3607 slot_tx = cq->p1 & 0xff; in channel_bctrl()
3608 bank_tx = cq->p1 >> 8; in channel_bctrl()
3609 slot_rx = cq->p2 & 0xff; in channel_bctrl()
3610 bank_rx = cq->p2 >> 8; in channel_bctrl()
3617 if (slot_tx < hc->slots && bank_tx <= 2 && in channel_bctrl()
3618 slot_rx < hc->slots && bank_rx <= 2) in channel_bctrl()
3619 hfcmulti_pcm(hc, bch->slot, in channel_bctrl()
3627 ret = -EINVAL; in channel_bctrl()
3634 hfcmulti_pcm(hc, bch->slot, -1, 0, -1, 0); in channel_bctrl()
3637 num = cq->p1 & 0xff; in channel_bctrl()
3642 hfcmulti_conf(hc, bch->slot, num); in channel_bctrl()
3647 ret = -EINVAL; in channel_bctrl()
3653 hfcmulti_conf(hc, bch->slot, -1); in channel_bctrl()
3658 if (test_bit(HFC_CHIP_B410P, &hc->chip)) in channel_bctrl()
3659 vpm_echocan_on(hc, bch->slot, cq->p1); in channel_bctrl()
3661 ret = -EINVAL; in channel_bctrl()
3668 if (test_bit(HFC_CHIP_B410P, &hc->chip)) in channel_bctrl()
3669 vpm_echocan_off(hc, bch->slot); in channel_bctrl()
3671 ret = -EINVAL; in channel_bctrl()
3684 struct hfc_multi *hc = bch->hw; in hfcm_bctrl()
3685 int err = -EINVAL; in hfcm_bctrl()
3688 if (bch->debug & DEBUG_HW) in hfcm_bctrl()
3693 test_and_clear_bit(FLG_OPEN, &bch->Flags); in hfcm_bctrl()
3695 ch->protocol = ISDN_P_NONE; in hfcm_bctrl()
3696 ch->peer = NULL; in hfcm_bctrl()
3701 spin_lock_irqsave(&hc->lock, flags); in hfcm_bctrl()
3703 spin_unlock_irqrestore(&hc->lock, flags); in hfcm_bctrl()
3713 * handle D-channel events
3727 hc = dch->hw; in ph_state_change()
3728 ch = dch->slot; in ph_state_change()
3730 if (hc->ctype == HFC_TYPE_E1) { in ph_state_change()
3731 if (dch->dev.D.protocol == ISDN_P_TE_E1) { in ph_state_change()
3735 __func__, hc->id, dch->state); in ph_state_change()
3740 __func__, hc->id, dch->state); in ph_state_change()
3742 switch (dch->state) { in ph_state_change()
3744 if (hc->e1_state != 1) { in ph_state_change()
3755 test_and_set_bit(FLG_ACTIVE, &dch->Flags); in ph_state_change()
3756 _queue_data(&dch->dev.D, PH_ACTIVATE_IND, in ph_state_change()
3761 if (hc->e1_state != 1) in ph_state_change()
3763 test_and_clear_bit(FLG_ACTIVE, &dch->Flags); in ph_state_change()
3764 _queue_data(&dch->dev.D, PH_DEACTIVATE_IND, in ph_state_change()
3767 hc->e1_state = dch->state; in ph_state_change()
3769 if (dch->dev.D.protocol == ISDN_P_TE_S0) { in ph_state_change()
3773 __func__, dch->state); in ph_state_change()
3774 switch (dch->state) { in ph_state_change()
3776 l1_event(dch->l1, HW_RESET_IND); in ph_state_change()
3779 l1_event(dch->l1, HW_DEACT_IND); in ph_state_change()
3783 l1_event(dch->l1, ANYSIGNAL); in ph_state_change()
3786 l1_event(dch->l1, INFO2); in ph_state_change()
3789 l1_event(dch->l1, INFO4_P8); in ph_state_change()
3795 __func__, dch->state); in ph_state_change()
3796 switch (dch->state) { in ph_state_change()
3798 if (hc->chan[ch].nt_timer == 0) { in ph_state_change()
3799 hc->chan[ch].nt_timer = -1; in ph_state_change()
3801 hc->chan[ch].port); in ph_state_change()
3802 /* undocumented: delay after R_ST_SEL */ in ph_state_change()
3806 udelay(6); /* wait at least 5,21us */ in ph_state_change()
3808 dch->state = 4; in ph_state_change()
3811 hc->chan[ch].nt_timer = in ph_state_change()
3814 hc->chan[ch].port); in ph_state_change()
3815 /* undocumented: delay after R_ST_SEL */ in ph_state_change()
3817 /* allow G2 -> G3 transition */ in ph_state_change()
3823 hc->chan[ch].nt_timer = -1; in ph_state_change()
3824 test_and_clear_bit(FLG_ACTIVE, &dch->Flags); in ph_state_change()
3825 _queue_data(&dch->dev.D, PH_DEACTIVATE_IND, in ph_state_change()
3829 hc->chan[ch].nt_timer = -1; in ph_state_change()
3832 hc->chan[ch].nt_timer = -1; in ph_state_change()
3833 test_and_set_bit(FLG_ACTIVE, &dch->Flags); in ph_state_change()
3834 _queue_data(&dch->dev.D, PH_ACTIVATE_IND, in ph_state_change()
3849 struct hfc_multi *hc = dch->hw; in hfcmulti_initmode()
3856 i = dch->slot; in hfcmulti_initmode()
3857 pt = hc->chan[i].port; in hfcmulti_initmode()
3858 if (hc->ctype == HFC_TYPE_E1) { in hfcmulti_initmode()
3860 hc->chan[hc->dnum[pt]].slot_tx = -1; in hfcmulti_initmode()
3861 hc->chan[hc->dnum[pt]].slot_rx = -1; in hfcmulti_initmode()
3862 hc->chan[hc->dnum[pt]].conf = -1; in hfcmulti_initmode()
3863 if (hc->dnum[pt]) { in hfcmulti_initmode()
3864 mode_hfcmulti(hc, dch->slot, dch->dev.D.protocol, in hfcmulti_initmode()
3865 -1, 0, -1, 0); in hfcmulti_initmode()
3866 timer_setup(&dch->timer, hfcmulti_dbusy_timer, 0); in hfcmulti_initmode()
3869 if (!((1 << i) & hc->bmask[pt])) /* skip unused chan */ in hfcmulti_initmode()
3871 hc->chan[i].slot_tx = -1; in hfcmulti_initmode()
3872 hc->chan[i].slot_rx = -1; in hfcmulti_initmode()
3873 hc->chan[i].conf = -1; in hfcmulti_initmode()
3874 mode_hfcmulti(hc, i, ISDN_P_NONE, -1, 0, -1, 0); in hfcmulti_initmode()
3877 if (hc->ctype == HFC_TYPE_E1 && pt == 0) { in hfcmulti_initmode()
3879 dch = hc->chan[hc->dnum[0]].dch; in hfcmulti_initmode()
3880 if (test_bit(HFC_CFG_REPORT_LOS, &hc->chan[hc->dnum[0]].cfg)) { in hfcmulti_initmode()
3884 if (test_bit(HFC_CFG_OPTICAL, &hc->chan[hc->dnum[0]].cfg)) { in hfcmulti_initmode()
3886 hc->hw.r_tx0 = 0 | V_OUT_EN; in hfcmulti_initmode()
3889 hc->hw.r_tx0 = 1 | V_OUT_EN; in hfcmulti_initmode()
3891 hc->hw.r_tx1 = V_ATX | V_NTRI; in hfcmulti_initmode()
3892 HFC_outb(hc, R_TX0, hc->hw.r_tx0); in hfcmulti_initmode()
3893 HFC_outb(hc, R_TX1, hc->hw.r_tx1); in hfcmulti_initmode()
3897 if (test_bit(HFC_CFG_CRC4, &hc->chan[hc->dnum[0]].cfg)) in hfcmulti_initmode()
3902 if (test_bit(HFC_CFG_CRC4, &hc->chan[hc->dnum[0]].cfg)) in hfcmulti_initmode()
3905 if (dch->dev.D.protocol == ISDN_P_NT_E1) { in hfcmulti_initmode()
3907 printk(KERN_DEBUG "%s: E1 port is NT-mode\n", in hfcmulti_initmode()
3910 hc->e1_getclock = 0; in hfcmulti_initmode()
3913 printk(KERN_DEBUG "%s: E1 port is TE-mode\n", in hfcmulti_initmode()
3916 hc->e1_getclock = 1; in hfcmulti_initmode()
3918 if (test_bit(HFC_CHIP_RX_SYNC, &hc->chip)) in hfcmulti_initmode()
3922 if (test_bit(HFC_CHIP_E1CLOCK_GET, &hc->chip)) in hfcmulti_initmode()
3923 hc->e1_getclock = 1; in hfcmulti_initmode()
3924 if (test_bit(HFC_CHIP_E1CLOCK_PUT, &hc->chip)) in hfcmulti_initmode()
3925 hc->e1_getclock = 0; in hfcmulti_initmode()
3926 if (test_bit(HFC_CHIP_PCM_SLAVE, &hc->chip)) { in hfcmulti_initmode()
3934 if (hc->e1_getclock) { in hfcmulti_initmode()
3959 udelay(6); /* wait at least 5,21us */ in hfcmulti_initmode()
3961 if (test_bit(HFC_CHIP_PLXSD, &hc->chip)) { in hfcmulti_initmode()
3962 hc->syncronized = 0; in hfcmulti_initmode()
3966 if (hc->ctype != HFC_TYPE_E1) { in hfcmulti_initmode()
3968 hc->chan[i].slot_tx = -1; in hfcmulti_initmode()
3969 hc->chan[i].slot_rx = -1; in hfcmulti_initmode()
3970 hc->chan[i].conf = -1; in hfcmulti_initmode()
3971 mode_hfcmulti(hc, i, dch->dev.D.protocol, -1, 0, -1, 0); in hfcmulti_initmode()
3972 timer_setup(&dch->timer, hfcmulti_dbusy_timer, 0); in hfcmulti_initmode()
3973 hc->chan[i - 2].slot_tx = -1; in hfcmulti_initmode()
3974 hc->chan[i - 2].slot_rx = -1; in hfcmulti_initmode()
3975 hc->chan[i - 2].conf = -1; in hfcmulti_initmode()
3976 mode_hfcmulti(hc, i - 2, ISDN_P_NONE, -1, 0, -1, 0); in hfcmulti_initmode()
3977 hc->chan[i - 1].slot_tx = -1; in hfcmulti_initmode()
3978 hc->chan[i - 1].slot_rx = -1; in hfcmulti_initmode()
3979 hc->chan[i - 1].conf = -1; in hfcmulti_initmode()
3980 mode_hfcmulti(hc, i - 1, ISDN_P_NONE, -1, 0, -1, 0); in hfcmulti_initmode()
3983 /* undocumented: delay after R_ST_SEL */ in hfcmulti_initmode()
3985 if (dch->dev.D.protocol == ISDN_P_NT_S0) { in hfcmulti_initmode()
3988 "%s: ST port %d is NT-mode\n", in hfcmulti_initmode()
3990 /* clock delay */ in hfcmulti_initmode()
3993 hc->hw.a_st_ctrl0[pt] = V_ST_MD; in hfcmulti_initmode()
3997 "%s: ST port %d is TE-mode\n", in hfcmulti_initmode()
3999 /* clock delay */ in hfcmulti_initmode()
4002 hc->hw.a_st_ctrl0[pt] = 0; in hfcmulti_initmode()
4004 if (!test_bit(HFC_CFG_NONCAP_TX, &hc->chan[i].cfg)) in hfcmulti_initmode()
4005 hc->hw.a_st_ctrl0[pt] |= V_TX_LI; in hfcmulti_initmode()
4006 if (hc->ctype == HFC_TYPE_XHFC) { in hfcmulti_initmode()
4007 hc->hw.a_st_ctrl0[pt] |= 0x40 /* V_ST_PU_CTRL */; in hfcmulti_initmode()
4012 HFC_outb(hc, A_ST_CTRL0, hc->hw.a_st_ctrl0[pt]); in hfcmulti_initmode()
4013 /* disable E-channel */ in hfcmulti_initmode()
4014 if ((dch->dev.D.protocol == ISDN_P_NT_S0) || in hfcmulti_initmode()
4015 test_bit(HFC_CFG_DIS_ECHANNEL, &hc->chan[i].cfg)) in hfcmulti_initmode()
4019 /* enable B-channel receive */ in hfcmulti_initmode()
4023 udelay(6); /* wait at least 5,21us */ in hfcmulti_initmode()
4025 hc->hw.r_sci_msk |= 1 << pt; in hfcmulti_initmode()
4027 HFC_outb(hc, R_SCI_MSK, hc->hw.r_sci_msk); in hfcmulti_initmode()
4029 if (test_bit(HFC_CHIP_PLXSD, &hc->chip)) { in hfcmulti_initmode()
4030 hc->syncronized &= in hfcmulti_initmode()
4031 ~(1 << hc->chan[dch->slot].port); in hfcmulti_initmode()
4049 dch->dev.id, __builtin_return_address(0)); in open_dchannel()
4050 if (rq->protocol == ISDN_P_NONE) in open_dchannel()
4051 return -EINVAL; in open_dchannel()
4052 if ((dch->dev.D.protocol != ISDN_P_NONE) && in open_dchannel()
4053 (dch->dev.D.protocol != rq->protocol)) { in open_dchannel()
4056 __func__, dch->dev.D.protocol, rq->protocol); in open_dchannel()
4058 if ((dch->dev.D.protocol == ISDN_P_TE_S0) && in open_dchannel()
4059 (rq->protocol != ISDN_P_TE_S0)) in open_dchannel()
4060 l1_event(dch->l1, CLOSE_CHANNEL); in open_dchannel()
4061 if (dch->dev.D.protocol != rq->protocol) { in open_dchannel()
4062 if (rq->protocol == ISDN_P_TE_S0) { in open_dchannel()
4067 dch->dev.D.protocol = rq->protocol; in open_dchannel()
4068 spin_lock_irqsave(&hc->lock, flags); in open_dchannel()
4070 spin_unlock_irqrestore(&hc->lock, flags); in open_dchannel()
4072 if (test_bit(FLG_ACTIVE, &dch->Flags)) in open_dchannel()
4073 _queue_data(&dch->dev.D, PH_ACTIVATE_IND, MISDN_ID_ANY, in open_dchannel()
4075 rq->ch = &dch->dev.D; in open_dchannel()
4088 if (!test_channelmap(rq->adr.channel, dch->dev.channelmap)) in open_bchannel()
4089 return -EINVAL; in open_bchannel()
4090 if (rq->protocol == ISDN_P_NONE) in open_bchannel()
4091 return -EINVAL; in open_bchannel()
4092 if (hc->ctype == HFC_TYPE_E1) in open_bchannel()
4093 ch = rq->adr.channel; in open_bchannel()
4095 ch = (rq->adr.channel - 1) + (dch->slot - 2); in open_bchannel()
4096 bch = hc->chan[ch].bch; in open_bchannel()
4100 return -EINVAL; in open_bchannel()
4102 if (test_and_set_bit(FLG_OPEN, &bch->Flags)) in open_bchannel()
4103 return -EBUSY; /* b-channel can be only open once */ in open_bchannel()
4104 bch->ch.protocol = rq->protocol; in open_bchannel()
4105 hc->chan[ch].rx_off = 0; in open_bchannel()
4106 rq->ch = &bch->ch; in open_bchannel()
4118 struct hfc_multi *hc = dch->hw; in channel_dctrl()
4122 switch (cq->op) { in channel_dctrl()
4124 cq->op = MISDN_CTRL_HFC_OP | MISDN_CTRL_L1_TIMER3; in channel_dctrl()
4127 wd_cnt = cq->p1 & 0xf; in channel_dctrl()
4128 wd_mode = !!(cq->p1 >> 4); in channel_dctrl()
4135 hc->hw.r_bert_wd_md = (wd_mode ? V_AUTO_WD_RES : 0); in channel_dctrl()
4136 if (hc->ctype == HFC_TYPE_XHFC) in channel_dctrl()
4137 hc->hw.r_bert_wd_md |= 0x40 /* V_WD_EN */; in channel_dctrl()
4139 HFC_outb(hc, R_BERT_WD_MD, hc->hw.r_bert_wd_md | V_WD_RES); in channel_dctrl()
4140 if (test_bit(HFC_CHIP_PLXSD, &hc->chip)) { in channel_dctrl()
4141 /* enable the watchdog output for Speech-Design */ in channel_dctrl()
4152 HFC_outb(hc, R_BERT_WD_MD, hc->hw.r_bert_wd_md | V_WD_RES); in channel_dctrl()
4155 ret = l1_event(dch->l1, HW_TIMER3_VALUE | (cq->p1 & 0xff)); in channel_dctrl()
4159 __func__, cq->op); in channel_dctrl()
4160 ret = -EINVAL; in channel_dctrl()
4171 struct hfc_multi *hc = dch->hw; in hfcm_dctrl()
4176 if (dch->debug & DEBUG_HW) in hfcm_dctrl()
4182 switch (rq->protocol) { in hfcm_dctrl()
4185 if (hc->ctype == HFC_TYPE_E1) { in hfcm_dctrl()
4186 err = -EINVAL; in hfcm_dctrl()
4193 if (hc->ctype != HFC_TYPE_E1) { in hfcm_dctrl()
4194 err = -EINVAL; in hfcm_dctrl()
4200 spin_lock_irqsave(&hc->lock, flags); in hfcm_dctrl()
4202 spin_unlock_irqrestore(&hc->lock, flags); in hfcm_dctrl()
4208 __func__, dch->dev.id, in hfcm_dctrl()
4213 spin_lock_irqsave(&hc->lock, flags); in hfcm_dctrl()
4215 spin_unlock_irqrestore(&hc->lock, flags); in hfcm_dctrl()
4218 if (dch->debug & DEBUG_HW) in hfcm_dctrl()
4221 err = -EINVAL; in hfcm_dctrl()
4231 hc->iclock_on = enable; in clockctl()
4246 int err = -EIO; in init_card()
4254 spin_lock_irqsave(&hc->lock, flags); in init_card()
4256 hc->hw.r_irq_ctrl = V_FIFO_IRQ; in init_card()
4258 spin_unlock_irqrestore(&hc->lock, flags); in init_card()
4260 if (request_irq(hc->irq, hfcmulti_interrupt, IRQF_SHARED, in init_card()
4261 "HFC-multi", hc)) { in init_card()
4263 hc->irq); in init_card()
4264 hc->irq = 0; in init_card()
4265 return -EIO; in init_card()
4268 if (test_bit(HFC_CHIP_PLXSD, &hc->chip)) { in init_card()
4270 plx_acc = hc->plx_membase + PLX_INTCSR; in init_card()
4278 __func__, hc->irq, hc->irqcnt); in init_card()
4287 spin_lock_irqsave(&hc->lock, flags); in init_card()
4289 spin_unlock_irqrestore(&hc->lock, flags); in init_card()
4294 spin_lock_irqsave(&hc->lock, flags); in init_card()
4296 spin_unlock_irqrestore(&hc->lock, flags); in init_card()
4299 __func__, hc->irq, hc->irqcnt); in init_card()
4300 if (hc->irqcnt) { in init_card()
4306 if (test_bit(HFC_CHIP_PCM_SLAVE, &hc->chip)) { in init_card()
4312 hc->irq); in init_card()
4314 err = -EIO; in init_card()
4317 if (test_bit(HFC_CHIP_PLXSD, &hc->chip)) { in init_card()
4319 plx_acc = hc->plx_membase + PLX_INTCSR; in init_card()
4325 printk(KERN_DEBUG "%s: free irq %d\n", __func__, hc->irq); in init_card()
4326 if (hc->irq) { in init_card()
4327 free_irq(hc->irq, hc); in init_card()
4328 hc->irq = 0; in init_card()
4344 struct hm_map *m = (struct hm_map *)ent->driver_data; in setup_pci()
4347 "HFC-multi: card manufacturer: '%s' card name: '%s' clock: %s\n", in setup_pci()
4348 m->vendor_name, m->card_name, m->clock2 ? "double" : "normal"); in setup_pci()
4350 hc->pci_dev = pdev; in setup_pci()
4351 if (m->clock2) in setup_pci()
4352 test_and_set_bit(HFC_CHIP_CLOCK2, &hc->chip); in setup_pci()
4354 if (ent->vendor == PCI_VENDOR_ID_DIGIUM && in setup_pci()
4355 ent->device == PCI_DEVICE_ID_DIGIUM_HFC4S) { in setup_pci()
4356 test_and_set_bit(HFC_CHIP_B410P, &hc->chip); in setup_pci()
4357 test_and_set_bit(HFC_CHIP_PCM_MASTER, &hc->chip); in setup_pci()
4358 test_and_clear_bit(HFC_CHIP_PCM_SLAVE, &hc->chip); in setup_pci()
4359 hc->slots = 32; in setup_pci()
4362 if (hc->pci_dev->irq <= 0) { in setup_pci()
4363 printk(KERN_WARNING "HFC-multi: No IRQ for PCI card found.\n"); in setup_pci()
4364 return -EIO; in setup_pci()
4366 if (pci_enable_device(hc->pci_dev)) { in setup_pci()
4367 printk(KERN_WARNING "HFC-multi: Error enabling PCI card.\n"); in setup_pci()
4368 return -EIO; in setup_pci()
4370 hc->leds = m->leds; in setup_pci()
4371 hc->ledstate = 0xAFFEAFFE; in setup_pci()
4372 hc->opticalsupport = m->opticalsupport; in setup_pci()
4374 hc->pci_iobase = 0; in setup_pci()
4375 hc->pci_membase = NULL; in setup_pci()
4376 hc->plx_membase = NULL; in setup_pci()
4379 if (m->io_mode) /* use mode from card config */ in setup_pci()
4380 hc->io_mode = m->io_mode; in setup_pci()
4381 switch (hc->io_mode) { in setup_pci()
4383 test_and_set_bit(HFC_CHIP_PLXSD, &hc->chip); in setup_pci()
4384 hc->slots = 128; /* required */ in setup_pci()
4385 hc->HFC_outb = HFC_outb_pcimem; in setup_pci()
4386 hc->HFC_inb = HFC_inb_pcimem; in setup_pci()
4387 hc->HFC_inw = HFC_inw_pcimem; in setup_pci()
4388 hc->HFC_wait = HFC_wait_pcimem; in setup_pci()
4389 hc->read_fifo = read_fifo_pcimem; in setup_pci()
4390 hc->write_fifo = write_fifo_pcimem; in setup_pci()
4391 hc->plx_origmembase = hc->pci_dev->resource[0].start; in setup_pci()
4394 if (!hc->plx_origmembase) { in setup_pci()
4396 "HFC-multi: No IO-Memory for PCI PLX bridge found\n"); in setup_pci()
4397 pci_disable_device(hc->pci_dev); in setup_pci()
4398 return -EIO; in setup_pci()
4401 hc->plx_membase = ioremap(hc->plx_origmembase, 0x80); in setup_pci()
4402 if (!hc->plx_membase) { in setup_pci()
4404 "HFC-multi: failed to remap plx address space. " in setup_pci()
4406 pci_disable_device(hc->pci_dev); in setup_pci()
4407 return -EIO; in setup_pci()
4410 "HFC-multi: plx_membase:%#lx plx_origmembase:%#lx\n", in setup_pci()
4411 (u_long)hc->plx_membase, hc->plx_origmembase); in setup_pci()
4413 hc->pci_origmembase = hc->pci_dev->resource[2].start; in setup_pci()
4415 if (!hc->pci_origmembase) { in setup_pci()
4417 "HFC-multi: No IO-Memory for PCI card found\n"); in setup_pci()
4418 pci_disable_device(hc->pci_dev); in setup_pci()
4419 return -EIO; in setup_pci()
4422 hc->pci_membase = ioremap(hc->pci_origmembase, 0x400); in setup_pci()
4423 if (!hc->pci_membase) { in setup_pci()
4424 printk(KERN_WARNING "HFC-multi: failed to remap io " in setup_pci()
4426 pci_disable_device(hc->pci_dev); in setup_pci()
4427 return -EIO; in setup_pci()
4432 "leds-type %d\n", in setup_pci()
4433 hc->id, (u_long)hc->pci_membase, hc->pci_origmembase, in setup_pci()
4434 hc->pci_dev->irq, HZ, hc->leds); in setup_pci()
4435 pci_write_config_word(hc->pci_dev, PCI_COMMAND, PCI_ENA_MEMIO); in setup_pci()
4438 hc->HFC_outb = HFC_outb_pcimem; in setup_pci()
4439 hc->HFC_inb = HFC_inb_pcimem; in setup_pci()
4440 hc->HFC_inw = HFC_inw_pcimem; in setup_pci()
4441 hc->HFC_wait = HFC_wait_pcimem; in setup_pci()
4442 hc->read_fifo = read_fifo_pcimem; in setup_pci()
4443 hc->write_fifo = write_fifo_pcimem; in setup_pci()
4444 hc->pci_origmembase = hc->pci_dev->resource[1].start; in setup_pci()
4445 if (!hc->pci_origmembase) { in setup_pci()
4447 "HFC-multi: No IO-Memory for PCI card found\n"); in setup_pci()
4448 pci_disable_device(hc->pci_dev); in setup_pci()
4449 return -EIO; in setup_pci()
4452 hc->pci_membase = ioremap(hc->pci_origmembase, 256); in setup_pci()
4453 if (!hc->pci_membase) { in setup_pci()
4455 "HFC-multi: failed to remap io address space. " in setup_pci()
4457 pci_disable_device(hc->pci_dev); in setup_pci()
4458 return -EIO; in setup_pci()
4461 "%d HZ %d leds-type %d\n", hc->id, (u_long)hc->pci_membase, in setup_pci()
4462 hc->pci_origmembase, hc->pci_dev->irq, HZ, hc->leds); in setup_pci()
4463 pci_write_config_word(hc->pci_dev, PCI_COMMAND, PCI_ENA_MEMIO); in setup_pci()
4466 hc->HFC_outb = HFC_outb_regio; in setup_pci()
4467 hc->HFC_inb = HFC_inb_regio; in setup_pci()
4468 hc->HFC_inw = HFC_inw_regio; in setup_pci()
4469 hc->HFC_wait = HFC_wait_regio; in setup_pci()
4470 hc->read_fifo = read_fifo_regio; in setup_pci()
4471 hc->write_fifo = write_fifo_regio; in setup_pci()
4472 hc->pci_iobase = (u_int) hc->pci_dev->resource[0].start; in setup_pci()
4473 if (!hc->pci_iobase) { in setup_pci()
4475 "HFC-multi: No IO for PCI card found\n"); in setup_pci()
4476 pci_disable_device(hc->pci_dev); in setup_pci()
4477 return -EIO; in setup_pci()
4480 if (!request_region(hc->pci_iobase, 8, "hfcmulti")) { in setup_pci()
4481 printk(KERN_WARNING "HFC-multi: failed to request " in setup_pci()
4483 hc->pci_iobase); in setup_pci()
4484 pci_disable_device(hc->pci_dev); in setup_pci()
4485 return -EIO; in setup_pci()
4489 "%s %s: defined at IOBASE %#x IRQ %d HZ %d leds-type %d\n", in setup_pci()
4490 m->vendor_name, m->card_name, (u_int) hc->pci_iobase, in setup_pci()
4491 hc->pci_dev->irq, HZ, hc->leds); in setup_pci()
4492 pci_write_config_word(hc->pci_dev, PCI_COMMAND, PCI_ENA_REGIO); in setup_pci()
4495 printk(KERN_WARNING "HFC-multi: Invalid IO mode.\n"); in setup_pci()
4496 pci_disable_device(hc->pci_dev); in setup_pci()
4497 return -EIO; in setup_pci()
4500 pci_set_drvdata(hc->pci_dev, hc); in setup_pci()
4519 ci = dch->slot; in release_port()
4520 pt = hc->chan[ci].port; in release_port()
4526 if (pt >= hc->ports) { in release_port()
4536 if (dch->dev.D.protocol == ISDN_P_TE_S0) in release_port()
4537 l1_event(dch->l1, CLOSE_CHANNEL); in release_port()
4539 hc->chan[ci].dch = NULL; in release_port()
4541 if (hc->created[pt]) { in release_port()
4542 hc->created[pt] = 0; in release_port()
4543 mISDN_unregister_device(&dch->dev); in release_port()
4546 spin_lock_irqsave(&hc->lock, flags); in release_port()
4548 if (dch->timer.function) { in release_port()
4549 del_timer(&dch->timer); in release_port()
4550 dch->timer.function = NULL; in release_port()
4553 if (hc->ctype == HFC_TYPE_E1) { /* E1 */ in release_port()
4555 if (test_bit(HFC_CHIP_PLXSD, &hc->chip)) { in release_port()
4556 hc->syncronized = 0; in release_port()
4561 if (!((1 << i) & hc->bmask[pt])) /* skip unused chan */ in release_port()
4563 if (hc->chan[i].bch) { in release_port()
4567 __func__, hc->chan[i].port + 1, i); in release_port()
4568 pb = hc->chan[i].bch; in release_port()
4569 hc->chan[i].bch = NULL; in release_port()
4570 spin_unlock_irqrestore(&hc->lock, flags); in release_port()
4573 kfree(hc->chan[i].coeff); in release_port()
4574 spin_lock_irqsave(&hc->lock, flags); in release_port()
4579 if (test_bit(HFC_CHIP_PLXSD, &hc->chip)) { in release_port()
4580 hc->syncronized &= in release_port()
4581 ~(1 << hc->chan[ci].port); in release_port()
4585 if (hc->chan[ci - 2].bch) { in release_port()
4589 __func__, hc->chan[ci - 2].port + 1, in release_port()
4590 ci - 2); in release_port()
4591 pb = hc->chan[ci - 2].bch; in release_port()
4592 hc->chan[ci - 2].bch = NULL; in release_port()
4593 spin_unlock_irqrestore(&hc->lock, flags); in release_port()
4596 kfree(hc->chan[ci - 2].coeff); in release_port()
4597 spin_lock_irqsave(&hc->lock, flags); in release_port()
4599 if (hc->chan[ci - 1].bch) { in release_port()
4603 __func__, hc->chan[ci - 1].port + 1, in release_port()
4604 ci - 1); in release_port()
4605 pb = hc->chan[ci - 1].bch; in release_port()
4606 hc->chan[ci - 1].bch = NULL; in release_port()
4607 spin_unlock_irqrestore(&hc->lock, flags); in release_port()
4610 kfree(hc->chan[ci - 1].coeff); in release_port()
4611 spin_lock_irqsave(&hc->lock, flags); in release_port()
4615 spin_unlock_irqrestore(&hc->lock, flags); in release_port()
4635 __func__, hc->id); in release_card()
4638 if (hc->iclock) in release_card()
4639 mISDN_unregister_clock(hc->iclock); in release_card()
4642 spin_lock_irqsave(&hc->lock, flags); in release_card()
4644 spin_unlock_irqrestore(&hc->lock, flags); in release_card()
4646 if (hc->irq) { in release_card()
4649 __func__, hc->irq, hc); in release_card()
4650 free_irq(hc->irq, hc); in release_card()
4651 hc->irq = 0; in release_card()
4655 /* disable D-channels & B-channels */ in release_card()
4660 if (hc->chan[ch].dch) in release_card()
4661 release_port(hc, hc->chan[ch].dch); in release_card()
4665 if (hc->leds) in release_card()
4674 list_del(&hc->list); in release_card()
4691 if (!m->opticalsupport) { in init_e1_port_hw()
4704 &hc->chan[hc->dnum[0]].cfg); in init_e1_port_hw()
4714 &hc->chan[hc->dnum[0]].cfg); in init_e1_port_hw()
4723 &hc->chan[hc->dnum[0]].cfg); in init_e1_port_hw()
4733 &hc->chan[hc->dnum[0]].cfg); in init_e1_port_hw()
4743 &hc->chan[hc->dnum[0]].cfg); in init_e1_port_hw()
4745 /* set CRC-4 Mode */ in init_e1_port_hw()
4752 &hc->chan[hc->dnum[0]].cfg); in init_e1_port_hw()
4765 test_and_set_bit(HFC_CHIP_E1CLOCK_GET, &hc->chip); in init_e1_port_hw()
4772 test_and_set_bit(HFC_CHIP_E1CLOCK_PUT, &hc->chip); in init_e1_port_hw()
4780 test_and_set_bit(HFC_CHIP_RX_SYNC, &hc->chip); in init_e1_port_hw()
4784 hc->chan[hc->dnum[0]].jitter = (port[Port_cnt]>>12) & 0x3; in init_e1_port_hw()
4789 __func__, hc->chan[hc->dnum[0]].jitter, in init_e1_port_hw()
4792 hc->chan[hc->dnum[0]].jitter = 2; /* default */ in init_e1_port_hw()
4806 return -ENOMEM; in init_e1_port()
4807 dch->debug = debug; in init_e1_port()
4809 dch->hw = hc; in init_e1_port()
4810 dch->dev.Dprotocols = (1 << ISDN_P_TE_E1) | (1 << ISDN_P_NT_E1); in init_e1_port()
4811 dch->dev.Bprotocols = (1 << (ISDN_P_B_RAW & ISDN_P_B_MASK)) | in init_e1_port()
4813 dch->dev.D.send = handle_dmsg; in init_e1_port()
4814 dch->dev.D.ctrl = hfcm_dctrl; in init_e1_port()
4815 dch->slot = hc->dnum[pt]; in init_e1_port()
4816 hc->chan[hc->dnum[pt]].dch = dch; in init_e1_port()
4817 hc->chan[hc->dnum[pt]].port = pt; in init_e1_port()
4818 hc->chan[hc->dnum[pt]].nt_timer = -1; in init_e1_port()
4820 if (!((1 << ch) & hc->bmask[pt])) /* skip unused channel */ in init_e1_port()
4826 ret = -ENOMEM; in init_e1_port()
4829 hc->chan[ch].coeff = kzalloc(512, GFP_KERNEL); in init_e1_port()
4830 if (!hc->chan[ch].coeff) { in init_e1_port()
4833 ret = -ENOMEM; in init_e1_port()
4837 bch->nr = ch; in init_e1_port()
4838 bch->slot = ch; in init_e1_port()
4839 bch->debug = debug; in init_e1_port()
4841 bch->hw = hc; in init_e1_port()
4842 bch->ch.send = handle_bmsg; in init_e1_port()
4843 bch->ch.ctrl = hfcm_bctrl; in init_e1_port()
4844 bch->ch.nr = ch; in init_e1_port()
4845 list_add(&bch->ch.list, &dch->dev.bchannels); in init_e1_port()
4846 hc->chan[ch].bch = bch; in init_e1_port()
4847 hc->chan[ch].port = pt; in init_e1_port()
4848 set_channelmap(bch->nr, dch->dev.channelmap); in init_e1_port()
4851 dch->dev.nrbchan = bcount; in init_e1_port()
4854 if (hc->ports > 1) in init_e1_port()
4855 snprintf(name, MISDN_MAX_IDLEN - 1, "hfc-e1.%d-%d", in init_e1_port()
4858 snprintf(name, MISDN_MAX_IDLEN - 1, "hfc-e1.%d", HFC_cnt + 1); in init_e1_port()
4859 ret = mISDN_register_device(&dch->dev, &hc->pci_dev->dev, name); in init_e1_port()
4862 hc->created[pt] = 1; in init_e1_port()
4879 return -ENOMEM; in init_multi_port()
4880 dch->debug = debug; in init_multi_port()
4882 dch->hw = hc; in init_multi_port()
4883 dch->dev.Dprotocols = (1 << ISDN_P_TE_S0) | (1 << ISDN_P_NT_S0); in init_multi_port()
4884 dch->dev.Bprotocols = (1 << (ISDN_P_B_RAW & ISDN_P_B_MASK)) | in init_multi_port()
4886 dch->dev.D.send = handle_dmsg; in init_multi_port()
4887 dch->dev.D.ctrl = hfcm_dctrl; in init_multi_port()
4888 dch->dev.nrbchan = 2; in init_multi_port()
4890 dch->slot = i + 2; in init_multi_port()
4891 hc->chan[i + 2].dch = dch; in init_multi_port()
4892 hc->chan[i + 2].port = pt; in init_multi_port()
4893 hc->chan[i + 2].nt_timer = -1; in init_multi_port()
4894 for (ch = 0; ch < dch->dev.nrbchan; ch++) { in init_multi_port()
4899 ret = -ENOMEM; in init_multi_port()
4902 hc->chan[i + ch].coeff = kzalloc(512, GFP_KERNEL); in init_multi_port()
4903 if (!hc->chan[i + ch].coeff) { in init_multi_port()
4906 ret = -ENOMEM; in init_multi_port()
4910 bch->nr = ch + 1; in init_multi_port()
4911 bch->slot = i + ch; in init_multi_port()
4912 bch->debug = debug; in init_multi_port()
4914 bch->hw = hc; in init_multi_port()
4915 bch->ch.send = handle_bmsg; in init_multi_port()
4916 bch->ch.ctrl = hfcm_bctrl; in init_multi_port()
4917 bch->ch.nr = ch + 1; in init_multi_port()
4918 list_add(&bch->ch.list, &dch->dev.bchannels); in init_multi_port()
4919 hc->chan[i + ch].bch = bch; in init_multi_port()
4920 hc->chan[i + ch].port = pt; in init_multi_port()
4921 set_channelmap(bch->nr, dch->dev.channelmap); in init_multi_port()
4930 if (dch->dev.D.protocol != ISDN_P_TE_S0) { in init_multi_port()
4933 " possible with TE-mode\n", in init_multi_port()
4935 ret = -EINVAL; in init_multi_port()
4938 if (hc->masterclk >= 0) { in init_multi_port()
4942 pt + 1, HFC_cnt + 1, hc->masterclk + 1); in init_multi_port()
4943 ret = -EINVAL; in init_multi_port()
4946 hc->masterclk = pt; in init_multi_port()
4956 &hc->chan[i + 2].cfg); in init_multi_port()
4958 /* disable E-channel */ in init_multi_port()
4962 "%s: PROTOCOL disable E-channel: " in init_multi_port()
4966 &hc->chan[i + 2].cfg); in init_multi_port()
4968 if (hc->ctype == HFC_TYPE_XHFC) { in init_multi_port()
4969 snprintf(name, MISDN_MAX_IDLEN - 1, "xhfc.%d-%d", in init_multi_port()
4971 ret = mISDN_register_device(&dch->dev, NULL, name); in init_multi_port()
4973 snprintf(name, MISDN_MAX_IDLEN - 1, "hfc-%ds.%d-%d", in init_multi_port()
4974 hc->ctype, HFC_cnt + 1, pt + 1); in init_multi_port()
4975 ret = mISDN_register_device(&dch->dev, &hc->pci_dev->dev, name); in init_multi_port()
4979 hc->created[pt] = 1; in init_multi_port()
5001 return -EINVAL; in hfcmulti_init()
5003 if ((type[HFC_cnt] & 0xff) && (type[HFC_cnt] & 0xff) != m->type) { in hfcmulti_init()
5004 printk(KERN_WARNING "HFC-MULTI: Card '%s:%s' type %d found but " in hfcmulti_init()
5006 m->vendor_name, m->card_name, m->type, HFC_cnt, in hfcmulti_init()
5008 printk(KERN_WARNING "HFC-MULTI: Load module without parameters " in hfcmulti_init()
5010 return -EINVAL; in hfcmulti_init()
5014 __func__, m->vendor_name, m->card_name, m->type, in hfcmulti_init()
5020 printk(KERN_ERR "No kmem for HFC-Multi card\n"); in hfcmulti_init()
5021 return -ENOMEM; in hfcmulti_init()
5023 spin_lock_init(&hc->lock); in hfcmulti_init()
5024 hc->mtyp = m; in hfcmulti_init()
5025 hc->ctype = m->type; in hfcmulti_init()
5026 hc->ports = m->ports; in hfcmulti_init()
5027 hc->id = HFC_cnt; in hfcmulti_init()
5028 hc->pcm = pcm[HFC_cnt]; in hfcmulti_init()
5029 hc->io_mode = iomode[HFC_cnt]; in hfcmulti_init()
5030 if (hc->ctype == HFC_TYPE_E1 && dmask[E1_cnt]) { in hfcmulti_init()
5037 hc->dnum[pt] = ch; in hfcmulti_init()
5038 hc->bmask[pt] = bmask[bmask_cnt++]; in hfcmulti_init()
5039 if ((maskcheck & hc->bmask[pt]) in hfcmulti_init()
5040 || (dmask[E1_cnt] & hc->bmask[pt])) { in hfcmulti_init()
5042 "HFC-E1 #%d has overlapping B-channels on fragment #%d\n", in hfcmulti_init()
5045 return -EINVAL; in hfcmulti_init()
5047 maskcheck |= hc->bmask[pt]; in hfcmulti_init()
5049 "HFC-E1 #%d uses D-channel on slot %d and a B-channel map of 0x%08x\n", in hfcmulti_init()
5050 E1_cnt + 1, ch, hc->bmask[pt]); in hfcmulti_init()
5053 hc->ports = pt; in hfcmulti_init()
5055 if (hc->ctype == HFC_TYPE_E1 && !dmask[E1_cnt]) { in hfcmulti_init()
5057 hc->dnum[0] = 16; in hfcmulti_init()
5058 hc->bmask[0] = 0xfffefffe; in hfcmulti_init()
5059 hc->ports = 1; in hfcmulti_init()
5063 hc->masterclk = -1; in hfcmulti_init()
5065 test_and_set_bit(HFC_CHIP_ULAW, &hc->chip); in hfcmulti_init()
5066 hc->silence = 0xff; /* ulaw silence */ in hfcmulti_init()
5068 hc->silence = 0x2a; /* alaw silence */ in hfcmulti_init()
5069 if ((poll >> 1) > sizeof(hc->silence_data)) { in hfcmulti_init()
5073 return -EINVAL; in hfcmulti_init()
5076 hc->silence_data[i] = hc->silence; in hfcmulti_init()
5078 if (hc->ctype != HFC_TYPE_XHFC) { in hfcmulti_init()
5080 test_and_set_bit(HFC_CHIP_DTMF, &hc->chip); in hfcmulti_init()
5081 test_and_set_bit(HFC_CHIP_CONF, &hc->chip); in hfcmulti_init()
5085 test_and_set_bit(HFC_CHIP_PCM_SLAVE, &hc->chip); in hfcmulti_init()
5087 test_and_set_bit(HFC_CHIP_PCM_MASTER, &hc->chip); in hfcmulti_init()
5088 test_and_clear_bit(HFC_CHIP_PCM_SLAVE, &hc->chip); in hfcmulti_init()
5091 test_and_set_bit(HFC_CHIP_EXRAM_128, &hc->chip); in hfcmulti_init()
5093 test_and_set_bit(HFC_CHIP_EXRAM_512, &hc->chip); in hfcmulti_init()
5094 hc->slots = 32; in hfcmulti_init()
5096 hc->slots = 64; in hfcmulti_init()
5098 hc->slots = 128; in hfcmulti_init()
5100 test_and_set_bit(HFC_CHIP_WATCHDOG, &hc->chip); in hfcmulti_init()
5101 hc->wdcount = 0; in hfcmulti_init()
5102 hc->wdbyte = V_GPIO_OUT2; in hfcmulti_init()
5107 /* setup pci, hc->slots may change due to PLXSD */ in hfcmulti_init()
5115 ret_err = -EIO; in hfcmulti_init()
5125 hc->HFC_outb_nodebug = hc->HFC_outb; in hfcmulti_init()
5126 hc->HFC_inb_nodebug = hc->HFC_inb; in hfcmulti_init()
5127 hc->HFC_inw_nodebug = hc->HFC_inw; in hfcmulti_init()
5128 hc->HFC_wait_nodebug = hc->HFC_wait; in hfcmulti_init()
5130 hc->HFC_outb = HFC_outb_debug; in hfcmulti_init()
5131 hc->HFC_inb = HFC_inb_debug; in hfcmulti_init()
5132 hc->HFC_inw = HFC_inw_debug; in hfcmulti_init()
5133 hc->HFC_wait = HFC_wait_debug; in hfcmulti_init()
5136 for (pt = 0; pt < hc->ports; pt++) { in hfcmulti_init()
5140 ret_err = -EINVAL; in hfcmulti_init()
5143 if (hc->ctype == HFC_TYPE_E1) in hfcmulti_init()
5149 "%s: Registering D-channel, card(%d) port(%d) " in hfcmulti_init()
5155 pt--; in hfcmulti_init()
5156 if (hc->ctype == HFC_TYPE_E1) in hfcmulti_init()
5158 hc->chan[hc->dnum[pt]].dch); in hfcmulti_init()
5161 hc->chan[(pt << 2) + 2].dch); in hfcmulti_init()
5165 if (hc->ctype != HFC_TYPE_E1) in hfcmulti_init()
5168 if (hc->ctype == HFC_TYPE_E1) { in hfcmulti_init()
5174 switch (m->dip_type) { in hfcmulti_init()
5188 if (test_bit(HFC_CHIP_B410P, &hc->chip)) in hfcmulti_init()
5192 m->vendor_name, m->card_name, dips, pmj); in hfcmulti_init()
5201 outw(0x4000, hc->pci_iobase + 4); in hfcmulti_init()
5206 dips = inb(hc->pci_iobase); in hfcmulti_init()
5207 dips = inb(hc->pci_iobase); in hfcmulti_init()
5208 dips = inb(hc->pci_iobase); in hfcmulti_init()
5209 dips = ~inb(hc->pci_iobase) & 0x3F; in hfcmulti_init()
5210 outw(0x0, hc->pci_iobase + 4); in hfcmulti_init()
5214 m->vendor_name, m->card_name, dips); in hfcmulti_init()
5223 m->vendor_name, m->card_name, dips); in hfcmulti_init()
5229 list_add_tail(&hc->list, &HFClist); in hfcmulti_init()
5234 hc->iclock = mISDN_register_clock("HFCMulti", 0, clockctl, hc); in hfcmulti_init()
5237 hc->irq = (m->irq) ? : hc->pci_dev->irq; in hfcmulti_init()
5246 spin_lock_irqsave(&hc->lock, flags); in hfcmulti_init()
5248 spin_unlock_irqrestore(&hc->lock, flags); in hfcmulti_init()
5267 pdev->vendor, pdev->device, in hfc_remove_pci()
5268 pdev->subsystem_vendor, pdev->subsystem_device); in hfc_remove_pci()
5288 /*0*/ {VENDOR_BN, "HFC-1S Card (mini PCI)", 4, 1, 1, 3, 0, DIP_4S, 0, 0},
5289 /*1*/ {VENDOR_BN, "HFC-2S Card", 4, 2, 1, 3, 0, DIP_4S, 0, 0},
5290 /*2*/ {VENDOR_BN, "HFC-2S Card (mini PCI)", 4, 2, 1, 3, 0, DIP_4S, 0, 0},
5291 /*3*/ {VENDOR_BN, "HFC-4S Card", 4, 4, 1, 2, 0, DIP_4S, 0, 0},
5292 /*4*/ {VENDOR_BN, "HFC-4S Card (mini PCI)", 4, 4, 1, 2, 0, 0, 0, 0},
5293 /*5*/ {VENDOR_CCD, "HFC-4S Eval (old)", 4, 4, 0, 0, 0, 0, 0, 0},
5294 /*6*/ {VENDOR_CCD, "HFC-4S IOB4ST", 4, 4, 1, 2, 0, DIP_4S, 0, 0},
5295 /*7*/ {VENDOR_CCD, "HFC-4S", 4, 4, 1, 2, 0, 0, 0, 0},
5296 /*8*/ {VENDOR_DIG, "HFC-4S Card", 4, 4, 0, 2, 0, 0, HFC_IO_MODE_REGIO, 0},
5297 /*9*/ {VENDOR_CCD, "HFC-4S Swyx 4xS0 SX2 QuadBri", 4, 4, 1, 2, 0, 0, 0, 0},
5298 /*10*/ {VENDOR_JH, "HFC-4S (junghanns 2.0)", 4, 4, 1, 2, 0, 0, 0, 0},
5299 /*11*/ {VENDOR_PRIM, "HFC-2S Primux Card", 4, 2, 0, 0, 0, 0, 0, 0},
5301 /*12*/ {VENDOR_BN, "HFC-8S Card", 8, 8, 1, 0, 0, 0, 0, 0},
5302 /*13*/ {VENDOR_BN, "HFC-8S Card (+)", 8, 8, 1, 8, 0, DIP_8S,
5304 /*14*/ {VENDOR_CCD, "HFC-8S Eval (old)", 8, 8, 0, 0, 0, 0, 0, 0},
5305 /*15*/ {VENDOR_CCD, "HFC-8S IOB4ST Recording", 8, 8, 1, 0, 0, 0, 0, 0},
5307 /*16*/ {VENDOR_CCD, "HFC-8S IOB8ST", 8, 8, 1, 0, 0, 0, 0, 0},
5308 /*17*/ {VENDOR_CCD, "HFC-8S", 8, 8, 1, 0, 0, 0, 0, 0},
5309 /*18*/ {VENDOR_CCD, "HFC-8S", 8, 8, 1, 0, 0, 0, 0, 0},
5311 /*19*/ {VENDOR_BN, "HFC-E1 Card", 1, 1, 0, 1, 0, DIP_E1, 0, 0},
5312 /*20*/ {VENDOR_BN, "HFC-E1 Card (mini PCI)", 1, 1, 0, 1, 0, 0, 0, 0},
5313 /*21*/ {VENDOR_BN, "HFC-E1+ Card (Dual)", 1, 1, 0, 1, 0, DIP_E1, 0, 0},
5314 /*22*/ {VENDOR_BN, "HFC-E1 Card (Dual)", 1, 1, 0, 1, 0, DIP_E1, 0, 0},
5316 /*23*/ {VENDOR_CCD, "HFC-E1 Eval (old)", 1, 1, 0, 0, 0, 0, 0, 0},
5317 /*24*/ {VENDOR_CCD, "HFC-E1 IOB1E1", 1, 1, 0, 1, 0, 0, 0, 0},
5318 /*25*/ {VENDOR_CCD, "HFC-E1", 1, 1, 0, 1, 0, 0, 0, 0},
5320 /*26*/ {VENDOR_CCD, "HFC-4S Speech Design", 4, 4, 0, 0, 0, 0,
5322 /*27*/ {VENDOR_CCD, "HFC-E1 Speech Design", 1, 1, 0, 0, 0, 0,
5324 /*28*/ {VENDOR_CCD, "HFC-4S OpenVox", 4, 4, 1, 0, 0, 0, 0, 0},
5325 /*29*/ {VENDOR_CCD, "HFC-2S OpenVox", 4, 2, 1, 0, 0, 0, 0, 0},
5326 /*30*/ {VENDOR_CCD, "HFC-8S OpenVox", 8, 8, 1, 0, 0, 0, 0, 0},
5327 /*31*/ {VENDOR_CCD, "XHFC-4S Speech Design", 5, 4, 0, 0, 0, 0,
5329 /*32*/ {VENDOR_JH, "HFC-8S (junghanns)", 8, 8, 1, 0, 0, 0, 0, 0},
5330 /*33*/ {VENDOR_BN, "HFC-2S Beronet Card PCIe", 4, 2, 1, 3, 0, DIP_4S, 0, 0},
5331 /*34*/ {VENDOR_BN, "HFC-4S Beronet Card PCIe", 4, 4, 1, 2, 0, DIP_4S, 0, 0},
5338 /* Cards with HFC-4S Chip */
5372 /* Cards with HFC-8S Chip */
5393 /* Cards with HFC-E1 Chip */
5430 struct hm_map *m = (struct hm_map *)ent->driver_data; in hfcmulti_probe()
5433 if (m == NULL && ent->vendor == PCI_VENDOR_ID_CCD && ( in hfcmulti_probe()
5434 ent->device == PCI_DEVICE_ID_CCD_HFC4S || in hfcmulti_probe()
5435 ent->device == PCI_DEVICE_ID_CCD_HFC8S || in hfcmulti_probe()
5436 ent->device == PCI_DEVICE_ID_CCD_HFCE1)) { in hfcmulti_probe()
5439 "subvendor:%04x subdevice:%04x)\n", pdev->vendor, in hfcmulti_probe()
5440 pdev->device, pdev->subsystem_vendor, in hfcmulti_probe()
5441 pdev->subsystem_device); in hfcmulti_probe()
5444 return -ENODEV; in hfcmulti_probe()
5479 printk(KERN_INFO "mISDN: HFC-multi driver %s\n", HFC_MULTI_VERSION); in HFCmulti_init()
5517 err = -EINVAL; in HFCmulti_init()