1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
23
24#include <linux/types.h>
25#include "pmcc4_sysdep.h"
26#include <linux/errno.h>
27#include <linux/kernel.h>
28#include <linux/sched.h>
29#include <linux/timer.h>
30#include <linux/hdlc.h>
31#include <asm/io.h>
32
33#include "sbecom_inline_linux.h"
34#include "libsbew.h"
35#include "pmcc4_private.h"
36#include "pmcc4.h"
37#include "pmcc4_ioctls.h"
38#include "musycc.h"
39#include "comet.h"
40#include "sbe_bid.h"
41
42#ifdef SBE_INCLUDE_SYMBOLS
43#define STATIC
44#else
45#define STATIC static
46#endif
47
48
49#define KERN_WARN KERN_WARNING
50
51
52status_t c4_wk_chan_init (mpi_t *, mch_t *);
53void c4_wq_port_cleanup (mpi_t *);
54status_t c4_wq_port_init (mpi_t *);
55
56int c4_loop_port (ci_t *, int, u_int8_t);
57status_t c4_set_port (ci_t *, int);
58status_t musycc_chan_down (ci_t *, int);
59
60u_int32_t musycc_chan_proto (int);
61status_t musycc_dump_ring (ci_t *, unsigned int);
62status_t __init musycc_init (ci_t *);
63void musycc_init_mdt (mpi_t *);
64void musycc_serv_req (mpi_t *, u_int32_t);
65void musycc_update_timeslots (mpi_t *);
66
67extern void musycc_update_tx_thp (mch_t *);
68extern int cxt1e1_log_level;
69extern int cxt1e1_max_mru;
70extern int cxt1e1_max_mtu;
71extern int max_rxdesc_used, max_rxdesc_default;
72extern int max_txdesc_used, max_txdesc_default;
73
74#if defined (__powerpc__)
75extern void *memset (void *s, int c, size_t n);
76
77#endif
78
79int drvr_state = SBE_DRVR_INIT;
80ci_t *c4_list = 0;
81ci_t *CI;
82
83
84
85void
86sbecom_set_loglevel (int d)
87{
88
89
90
91
92 if (d > LOG_DEBUG)
93 {
94 unsigned int channum = d - (LOG_DEBUG + 1);
95
96
97 (void) musycc_dump_ring ((ci_t *) CI, channum);
98
99 } else
100 {
101 if (cxt1e1_log_level != d)
102 {
103 pr_info("log level changed from %d to %d\n", cxt1e1_log_level, d);
104 cxt1e1_log_level = d;
105 } else
106 pr_info("log level is %d\n", cxt1e1_log_level);
107 }
108}
109
110
111mch_t *
112c4_find_chan (int channum)
113{
114 ci_t *ci;
115 mch_t *ch;
116 int portnum, gchan;
117
118 for (ci = c4_list; ci; ci = ci->next)
119 for (portnum = 0; portnum < ci->max_port; portnum++)
120 for (gchan = 0; gchan < MUSYCC_NCHANS; gchan++)
121 {
122 if ((ch = ci->port[portnum].chan[gchan]))
123 {
124 if ((ch->state != UNASSIGNED) &&
125 (ch->channum == channum))
126 return (ch);
127 }
128 }
129 return 0;
130}
131
132
133ci_t *__init
134c4_new (void *hi)
135{
136 ci_t *ci;
137
138#ifdef SBE_MAP_DEBUG
139 pr_warning("c4_new() entered, ci needs %u.\n",
140 (unsigned int) sizeof (ci_t));
141#endif
142
143 ci = (ci_t *) OS_kmalloc (sizeof (ci_t));
144 if (ci)
145 {
146 ci->hdw_info = hi;
147 ci->state = C_INIT;
148 ci->next = c4_list;
149 c4_list = ci;
150 ci->brdno = ci->next ? ci->next->brdno + 1 : 0;
151 } else
152 pr_warning("failed CI malloc, size %u.\n",
153 (unsigned int) sizeof (ci_t));
154
155 if (CI == 0)
156 CI = ci;
157 return ci;
158}
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186#define sbeLinkMask 0x41
187
188#define sbeLinkChange 0x40
189#define sbeLinkDown 0x01
190#define sbeAlarmsMask 0x07
191#define sbeE1AlarmsMask 0x107
192
193#define COMET_LBCMD_READ 0x80
194
195void
196checkPorts (ci_t * ci)
197{
198#ifndef CONFIG_SBE_PMCC4_NCOMM
199
200
201
202
203
204 comet_t *comet;
205 volatile u_int32_t value;
206 u_int32_t copyVal, LEDval;
207
208 u_int8_t portnum;
209
210 LEDval = 0;
211 for (portnum = 0; portnum < ci->max_port; portnum++)
212 {
213 copyVal = 0x12f & (ci->alarmed[portnum]);
214 comet = ci->port[portnum].cometbase;
215 value = pci_read_32 ((u_int32_t *) &comet->cdrc_ists) & sbeLinkMask;
216
217 if (value & sbeLinkChange)
218 {
219
220 if (!(((copyVal >> 3) & sbeLinkDown) ^ (value & sbeLinkDown)))
221 {
222 if (value & sbeLinkDown)
223 pr_warning("%s: Port %d momentarily recovered.\n",
224 ci->devname, portnum);
225 else
226 pr_warning("%s: Warning: Port %d link was briefly down.\n",
227 ci->devname, portnum);
228 } else if (value & sbeLinkDown)
229 pr_warning("%s: Warning: Port %d link is down.\n",
230 ci->devname, portnum);
231 else
232 {
233 pr_warning("%s: Port %d link has recovered.\n",
234 ci->devname, portnum);
235 copyVal |= 0x20;
236 }
237 copyVal |= 0x10;
238 }
239 copyVal &= 0x137;
240
241 if (value & sbeLinkDown)
242 copyVal |= 0x08;
243 else
244 {
245 copyVal |= 0x40;
246
247 if (IS_FRAME_ANY_E1 (ci->port[portnum].p.port_mode))
248 {
249
250
251
252
253
254
255
256
257 value = pci_read_32 ((u_int32_t *) &comet->e1_frmr_nat_ists);
258 if (value & 0x1f)
259 {
260 if (value & 0x10)
261 pr_warning("%s: E1 Port %d Codeword Sa4 change detected.\n",
262 ci->devname, portnum);
263 if (value & 0x08)
264 pr_warning("%s: E1 Port %d Codeword Sa5 change detected.\n",
265 ci->devname, portnum);
266 if (value & 0x04)
267 pr_warning("%s: E1 Port %d Codeword Sa6 change detected.\n",
268 ci->devname, portnum);
269 if (value & 0x02)
270 pr_warning("%s: E1 Port %d Codeword Sa7 change detected.\n",
271 ci->devname, portnum);
272 if (value & 0x01)
273 pr_warning("%s: E1 Port %d Codeword Sa8 change detected.\n",
274 ci->devname, portnum);
275 }
276 value = pci_read_32 ((u_int32_t *) &comet->e1_frmr_mists);
277 if (value & 0x3)
278 {
279 if (value & sbeE1CRC)
280 pr_warning("%s: E1 Port %d CRC-4 error(s) detected.\n",
281 ci->devname, portnum);
282 if (value & sbeE1errSMF)
283 pr_warning("%s: E1 Port %d received errored SMF.\n",
284 ci->devname, portnum);
285 }
286 value = pci_read_32 ((u_int32_t *) &comet->e1_frmr_masts) & 0xcc;
287
288
289
290
291
292
293 value = (value >> 2);
294 if (value & 0x30)
295 {
296 if (value & 0x20)
297 value |= 0x40;
298 if (value & 0x10)
299 value |= 0x100;
300 value &= ~0x30;
301 }
302 if (value != (copyVal & sbeE1AlarmsMask))
303 {
304 copyVal |= 0x10;
305 if ((copyVal & sbeRedAlm) && !(value & sbeRedAlm))
306 {
307 copyVal &= ~sbeRedAlm;
308 pr_warning("%s: E1 Port %d LOF alarm ended.\n",
309 ci->devname, portnum);
310 } else if (!(copyVal & sbeRedAlm) && (value & sbeRedAlm))
311 {
312 copyVal |= sbeRedAlm;
313 pr_warning("%s: E1 Warning: Port %d LOF alarm.\n",
314 ci->devname, portnum);
315 } else if ((copyVal & sbeYelAlm) && !(value & sbeYelAlm))
316 {
317 copyVal &= ~sbeYelAlm;
318 pr_warning("%s: E1 Port %d RAI alarm ended.\n",
319 ci->devname, portnum);
320 } else if (!(copyVal & sbeYelAlm) && (value & sbeYelAlm))
321 {
322 copyVal |= sbeYelAlm;
323 pr_warning("%s: E1 Warning: Port %d RAI alarm.\n",
324 ci->devname, portnum);
325 } else if ((copyVal & sbeE1RMAI) && !(value & sbeE1RMAI))
326 {
327 copyVal &= ~sbeE1RMAI;
328 pr_warning("%s: E1 Port %d RMAI alarm ended.\n",
329 ci->devname, portnum);
330 } else if (!(copyVal & sbeE1RMAI) && (value & sbeE1RMAI))
331 {
332 copyVal |= sbeE1RMAI;
333 pr_warning("%s: E1 Warning: Port %d RMAI alarm.\n",
334 ci->devname, portnum);
335 } else if ((copyVal & sbeAISAlm) && !(value & sbeAISAlm))
336 {
337 copyVal &= ~sbeAISAlm;
338 pr_warning("%s: E1 Port %d AIS alarm ended.\n",
339 ci->devname, portnum);
340 } else if (!(copyVal & sbeAISAlm) && (value & sbeAISAlm))
341 {
342 copyVal |= sbeAISAlm;
343 pr_warning("%s: E1 Warning: Port %d AIS alarm.\n",
344 ci->devname, portnum);
345 }
346 }
347
348 } else
349 {
350 value = pci_read_32 ((u_int32_t *) &comet->t1_almi_ists);
351 value &= sbeAlarmsMask;
352 if (value != (copyVal & sbeAlarmsMask))
353 {
354 copyVal |= 0x10;
355 if ((copyVal & sbeRedAlm) && !(value & sbeRedAlm))
356 {
357 copyVal &= ~sbeRedAlm;
358 pr_warning("%s: Port %d red alarm ended.\n",
359 ci->devname, portnum);
360 } else if (!(copyVal & sbeRedAlm) && (value & sbeRedAlm))
361 {
362 copyVal |= sbeRedAlm;
363 pr_warning("%s: Warning: Port %d red alarm.\n",
364 ci->devname, portnum);
365 } else if ((copyVal & sbeYelAlm) && !(value & sbeYelAlm))
366 {
367 copyVal &= ~sbeYelAlm;
368 pr_warning("%s: Port %d yellow (RAI) alarm ended.\n",
369 ci->devname, portnum);
370 } else if (!(copyVal & sbeYelAlm) && (value & sbeYelAlm))
371 {
372 copyVal |= sbeYelAlm;
373 pr_warning("%s: Warning: Port %d yellow (RAI) alarm.\n",
374 ci->devname, portnum);
375 } else if ((copyVal & sbeAISAlm) && !(value & sbeAISAlm))
376 {
377 copyVal &= ~sbeAISAlm;
378 pr_warning("%s: Port %d blue (AIS) alarm ended.\n",
379 ci->devname, portnum);
380 } else if (!(copyVal & sbeAISAlm) && (value & sbeAISAlm))
381 {
382 copyVal |= sbeAISAlm;
383 pr_warning("%s: Warning: Port %d blue (AIS) alarm.\n",
384 ci->devname, portnum);
385 }
386 }
387 }
388 }
389 if (copyVal & sbeAlarmsMask)
390 copyVal |= 0x80;
391 if (copyVal & 0x10)
392 LEDval |= 0x100;
393 LEDval |= ((copyVal & 0xc0) >> (6 - (portnum * 2)));
394
395 ci->alarmed[portnum] &= 0xfffff000;
396
397 ci->alarmed[portnum] |= (copyVal);
398
399
400
401
402
403
404 if (IS_FRAME_ANY_T1 (ci->port[portnum].p.port_mode))
405 {
406
407
408
409
410 value = pci_read_32 ((u_int32_t *) &comet->ibcd_ies);
411 value &= 0x3;
412 if (value & 0x2)
413 {
414
415 copyVal = c4_loop_port (ci, portnum, COMET_LBCMD_READ);
416
417 if (copyVal != COMET_MDIAG_LINELB)
418
419 c4_loop_port (ci, portnum, COMET_MDIAG_LINELB);
420
421 }
422 if (value & 0x1)
423 {
424
425 copyVal = c4_loop_port (ci, portnum, COMET_LBCMD_READ);
426
427 if (copyVal != COMET_MDIAG_LBOFF)
428
429 c4_loop_port (ci, portnum, COMET_MDIAG_LBOFF);
430
431 }
432 }
433 if (IS_FRAME_ANY_T1ESF (ci->port[portnum].p.port_mode))
434 {
435
436 value = pci_read_32 ((u_int32_t *) &comet->t1_rboc_sts) & 0x3f;
437 if (value == 0x07)
438 c4_loop_port (ci, portnum, COMET_MDIAG_LINELB);
439
440 if (value == 0x0a)
441 c4_loop_port (ci, portnum, COMET_MDIAG_PAYLB);
442
443 if ((value == 0x1c) || (value == 0x19) || (value == 0x12))
444 c4_loop_port (ci, portnum, COMET_MDIAG_LBOFF);
445
446 if (cxt1e1_log_level >= LOG_DEBUG)
447 if (value != 0x3f)
448 pr_warning("%s: BOC value = %x on Port %d\n",
449 ci->devname, value, portnum);
450
451 }
452 }
453
454
455 if (LEDval & 0x100)
456 pci_write_32 ((u_int32_t *) &ci->cpldbase->leds, LEDval & 0xff);
457#endif
458}
459
460
461STATIC void
462c4_watchdog (ci_t * ci)
463{
464 if (drvr_state != SBE_DRVR_AVAILABLE)
465 {
466 if (cxt1e1_log_level >= LOG_MONITOR)
467 pr_info("drvr not available (%x)\n", drvr_state);
468 return;
469 }
470 ci->wdcount++;
471 checkPorts (ci);
472 ci->wd_notify = 0;
473}
474
475
476void
477c4_cleanup (void)
478{
479 ci_t *ci, *next;
480 mpi_t *pi;
481 int portnum, j;
482
483 ci = c4_list;
484 while (ci)
485 {
486 next = ci->next;
487 pci_write_32 ((u_int32_t *) &ci->cpldbase->leds, PMCC4_CPLD_LED_OFF);
488 for (portnum = 0; portnum < ci->max_port; portnum++)
489 {
490 pi = &ci->port[portnum];
491 c4_wq_port_cleanup (pi);
492 for (j = 0; j < MUSYCC_NCHANS; j++)
493 {
494 if (pi->chan[j])
495 OS_kfree (pi->chan[j]);
496 }
497 OS_kfree (pi->regram_saved);
498 }
499 OS_kfree (ci->iqd_p_saved);
500 OS_kfree (ci);
501 ci = next;
502 }
503}
504
505
506
507
508
509
510
511
512
513
514int
515c4_get_portcfg (ci_t * ci)
516{
517 comet_t *comet;
518 int portnum, mask;
519 u_int32_t wdata, rdata;
520
521 wdata = COMET_MDIAG_LBOFF;
522
523 mask = 0;
524 for (portnum = 0; portnum < MUSYCC_NPORTS; portnum++)
525 {
526 comet = ci->port[portnum].cometbase;
527 pci_write_32 ((u_int32_t *) &comet->mdiag, wdata);
528 rdata = pci_read_32 ((u_int32_t *) &comet->mdiag) & COMET_MDIAG_LBMASK;
529 if (wdata == rdata)
530 mask |= 1 << portnum;
531 }
532 return mask;
533}
534
535
536
537
538status_t __init
539c4_init (ci_t * ci, u_char *func0, u_char *func1)
540{
541 mpi_t *pi;
542 mch_t *ch;
543 static u_int32_t count = 0;
544 int portnum, j;
545
546 ci->state = C_INIT;
547 ci->brdno = count++;
548 ci->intlog.this_status_new = 0;
549 atomic_set (&ci->bh_pending, 0);
550
551 ci->reg = (struct musycc_globalr *) func0;
552 ci->eeprombase = (u_int32_t *) (func1 + EEPROM_OFFSET);
553 ci->cpldbase = (c4cpld_t *) ((u_int32_t *) (func1 + ISPLD_OFFSET));
554
555
556#ifdef CONFIG_SBE_PMCC4_NCOMM
557
558 pci_write_32 ((u_int32_t *) &ci->reg->glcd, GCD_MAGIC);
559#else
560
561 pci_write_32 ((u_int32_t *) &ci->reg->glcd, GCD_MAGIC | MUSYCC_GCD_INTB_DISABLE);
562#endif
563
564 {
565 int pmsk;
566
567
568 for (portnum = 0; portnum < MUSYCC_NPORTS; portnum++)
569 {
570 pi = &ci->port[portnum];
571 pi->cometbase = (comet_t *) ((u_int32_t *) (func1 + COMET_OFFSET (portnum)));
572 pi->reg = (struct musycc_globalr *) ((u_char *) ci->reg + (portnum * 0x800));
573 pi->portnum = portnum;
574 pi->p.portnum = portnum;
575 pi->openchans = 0;
576#ifdef SBE_MAP_DEBUG
577 pr_info("Comet-%d: addr = %p\n", portnum, pi->cometbase);
578#endif
579 }
580 pmsk = c4_get_portcfg (ci);
581 switch (pmsk)
582 {
583 case 0x1:
584 ci->max_port = 1;
585 break;
586 case 0x3:
587 ci->max_port = 2;
588 break;
589#if 0
590 case 0x7:
591 ci->max_port = 3;
592 break;
593#endif
594 case 0xf:
595 ci->max_port = 4;
596 break;
597 default:
598 ci->max_port = 0;
599 pr_warning("%s: illegal port configuration (%x)\n",
600 ci->devname, pmsk);
601 return SBE_DRVR_FAIL;
602 }
603#ifdef SBE_MAP_DEBUG
604 pr_info(">> %s: c4_get_build - pmsk %x max_port %x\n",
605 ci->devname, pmsk, ci->max_port);
606#endif
607 }
608
609 for (portnum = 0; portnum < ci->max_port; portnum++)
610 {
611 pi = &ci->port[portnum];
612 pi->up = ci;
613 pi->sr_last = 0xffffffff;
614 pi->p.port_mode = CFG_FRAME_SF;
615 pi->p.portP = (CFG_CLK_PORT_EXTERNAL | CFG_LBO_LH0);
616
617 OS_sem_init (&pi->sr_sem_busy, SEM_AVAILABLE);
618 OS_sem_init (&pi->sr_sem_wait, SEM_TAKEN);
619
620 for (j = 0; j < 32; j++)
621 {
622 pi->fifomap[j] = -1;
623 pi->tsm[j] = 0;
624 }
625
626
627 for (j = 0; j < MUSYCC_NCHANS; j++)
628 {
629 ch = OS_kmalloc (sizeof (mch_t));
630 if (ch)
631 {
632 pi->chan[j] = ch;
633 ch->state = UNASSIGNED;
634 ch->up = pi;
635 ch->gchan = (-1);
636 ch->channum = (-1);
637 ch->p.card = ci->brdno;
638 ch->p.port = portnum;
639 ch->p.channum = (-1);
640 ch->p.mode_56k = 0;
641 } else
642 {
643 pr_warning("failed mch_t malloc, port %d channel %d size %u.\n",
644 portnum, j, (unsigned int) sizeof (mch_t));
645 break;
646 }
647 }
648 }
649
650
651 {
652
653
654
655
656
657
658
659 pci_write_32 ((u_int32_t *) &ci->cpldbase->leds,
660 PMCC4_CPLD_LED_GREEN | PMCC4_CPLD_LED_YELLOW);
661 OS_uwait (750000, "leds");
662 pci_write_32 ((u_int32_t *) &ci->cpldbase->leds, PMCC4_CPLD_LED_OFF);
663 }
664
665 OS_init_watchdog (&ci->wd, (void (*) (void *)) c4_watchdog, ci, WATCHDOG_TIMEOUT);
666 return SBE_DRVR_SUCCESS;
667}
668
669
670
671
672status_t __init
673c4_init2 (ci_t * ci)
674{
675 status_t ret;
676
677
678 if ((ret = musycc_init (ci)) != SBE_DRVR_SUCCESS)
679 return ret;
680
681#if 0
682 ci->p.framing_type = FRAMING_CBP;
683 ci->p.h110enable = 1;
684#if 0
685 ci->p.hypersize = 0;
686#else
687 hyperdummy = 0;
688#endif
689 ci->p.clock = 0;
690
691 c4_card_set_params (ci, &ci->p);
692#endif
693 OS_start_watchdog (&ci->wd);
694 return SBE_DRVR_SUCCESS;
695}
696
697
698
699
700int
701c4_loop_port (ci_t * ci, int portnum, u_int8_t cmd)
702{
703 comet_t *comet;
704 volatile u_int32_t loopValue;
705
706 comet = ci->port[portnum].cometbase;
707 loopValue = pci_read_32 ((u_int32_t *) &comet->mdiag) & COMET_MDIAG_LBMASK;
708
709 if (cmd & COMET_LBCMD_READ)
710 return loopValue;
711
712 if (loopValue != cmd)
713 {
714 switch (cmd)
715 {
716 case COMET_MDIAG_LINELB:
717
718 pci_write_32 ((u_int32_t *) &comet->ibcd_cfg, 0x05);
719 break;
720 case COMET_MDIAG_LBOFF:
721
722 pci_write_32 ((u_int32_t *) &comet->ibcd_cfg, 0x00);
723 break;
724 }
725
726 pci_write_32 ((u_int32_t *) &comet->mdiag, cmd);
727 if (cxt1e1_log_level >= LOG_WARN)
728 pr_info("%s: loopback mode changed to %2x from %2x on Port %d\n",
729 ci->devname, cmd, loopValue, portnum);
730 loopValue = pci_read_32 ((u_int32_t *) &comet->mdiag) & COMET_MDIAG_LBMASK;
731 if (loopValue != cmd)
732 {
733 if (cxt1e1_log_level >= LOG_ERROR)
734 pr_info("%s: write to loop register failed, unknown state for Port %d\n",
735 ci->devname, portnum);
736 }
737 } else
738 {
739 if (cxt1e1_log_level >= LOG_WARN)
740 pr_info("%s: loopback already in that mode (%2x)\n",
741 ci->devname, loopValue);
742 }
743 return 0;
744}
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759status_t
760c4_frame_rw (ci_t * ci, struct sbecom_port_param * pp)
761{
762 comet_t *comet;
763 volatile u_int32_t data;
764
765 if (pp->portnum >= ci->max_port)
766 return ENXIO;
767
768 comet = ci->port[pp->portnum].cometbase;
769 data = pci_read_32 ((u_int32_t *) comet + pp->port_mode) & 0xff;
770
771 if (pp->portP)
772 {
773
774 if (pp->portStatus == data)
775 pr_info("%s: Port %d already that value! Writing again anyhow.\n",
776 ci->devname, pp->portnum);
777 pp->portP = (u_int8_t) data;
778 pci_write_32 ((u_int32_t *) comet + pp->port_mode,
779 pp->portStatus);
780 data = pci_read_32 ((u_int32_t *) comet + pp->port_mode) & 0xff;
781 }
782 pp->portStatus = (u_int8_t) data;
783 return 0;
784}
785
786
787
788
789
790
791
792
793
794
795
796
797
798status_t
799c4_pld_rw (ci_t * ci, struct sbecom_port_param * pp)
800{
801 volatile u_int32_t *regaddr;
802 volatile u_int32_t data;
803 int regnum = pp->port_mode;
804
805 regaddr = (u_int32_t *) ci->cpldbase + regnum;
806 data = pci_read_32 ((u_int32_t *) regaddr) & 0xff;
807
808 if (pp->portP)
809 {
810
811 pp->portP = (u_int8_t) data;
812 pci_write_32 ((u_int32_t *) regaddr, pp->portStatus);
813 data = pci_read_32 ((u_int32_t *) regaddr) & 0xff;
814 }
815 pp->portStatus = (u_int8_t) data;
816 return 0;
817}
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836status_t
837c4_musycc_rw (ci_t * ci, struct c4_musycc_param * mcp)
838{
839 mpi_t *pi;
840 volatile u_int32_t *dph;
841 u_int32_t *dpr = 0;
842
843 int offset = mcp->offset % 0x800;
844
845
846 int portnum, ramread = 0;
847 volatile u_int32_t data;
848
849
850
851
852
853 portnum = (mcp->offset % 0x6000) / 0x800;
854 if (portnum >= ci->max_port)
855 return ENXIO;
856 pi = &ci->port[portnum];
857 if (mcp->offset >= 0x6000)
858 offset += 0x6000;
859 dph = (u_int32_t *) ((u_long) pi->reg + offset);
860
861
862 dpr = (u_int32_t *) ((u_long) pi->regram + offset);
863 if (mcp->offset < 0x6000)
864
865 {
866 if (offset >= 0x200 && offset < 0x380)
867 ramread = 1;
868 if (offset >= 0x10 && offset < 0x200)
869 ramread = 1;
870 }
871
872 if (ramread)
873 {
874 data = *dpr;
875
876 } else
877 {
878 data = pci_read_32 ((u_int32_t *) dph);
879
880 }
881
882
883 if (mcp->RWportnum & 0x80)
884 {
885
886 if (mcp->value == data)
887 pr_info("%s: musycc grp%d already that value! writing again anyhow.\n",
888 ci->devname, (mcp->RWportnum & 0x7));
889
890 if (ramread)
891 *dpr = mcp->value;
892
893 pci_write_32 ((u_int32_t *) dph, mcp->value);
894 }
895 mcp->value = data;
896
897 return 0;
898}
899
900status_t
901c4_get_port (ci_t * ci, int portnum)
902{
903 if (portnum >= ci->max_port)
904 return ENXIO;
905
906 SD_SEM_TAKE (&ci->sem_wdbusy, "_wd_");
907
908 checkPorts (ci);
909 ci->port[portnum].p.portStatus = (u_int8_t) ci->alarmed[portnum];
910 ci->alarmed[portnum] &= 0xdf;
911 SD_SEM_GIVE (&ci->sem_wdbusy);
912 return 0;
913}
914
915status_t
916c4_set_port (ci_t * ci, int portnum)
917{
918 mpi_t *pi;
919 struct sbecom_port_param *pp;
920 int e1mode;
921 u_int8_t clck;
922 int i;
923
924 if (portnum >= ci->max_port)
925 return ENXIO;
926
927 pi = &ci->port[portnum];
928 pp = &ci->port[portnum].p;
929 e1mode = IS_FRAME_ANY_E1 (pp->port_mode);
930 if (cxt1e1_log_level >= LOG_MONITOR2)
931 {
932 pr_info("%s: c4_set_port[%d]: entered, e1mode = %x, openchans %d.\n",
933 ci->devname,
934 portnum, e1mode, pi->openchans);
935 }
936 if (pi->openchans)
937 return EBUSY;
938
939
940 {
941 status_t ret;
942
943 if ((ret = c4_wq_port_init (pi)))
944
945 return (ret);
946 }
947
948 init_comet (ci, pi->cometbase, pp->port_mode, 1 , pp->portP);
949 clck = pci_read_32 ((u_int32_t *) &ci->cpldbase->mclk) & PMCC4_CPLD_MCLK_MASK;
950 if (e1mode)
951 clck |= 1 << portnum;
952 else
953 clck &= 0xf ^ (1 << portnum);
954
955 pci_write_32 ((u_int32_t *) &ci->cpldbase->mclk, clck);
956 pci_write_32 ((u_int32_t *) &ci->cpldbase->mcsr, PMCC4_CPLD_MCSR_IND);
957 pci_write_32 ((u_int32_t *) &pi->reg->gbp, OS_vtophys (pi->regram));
958
959
960
961
962
963 pi->regram->grcd =
964 __constant_cpu_to_le32 (MUSYCC_GRCD_RX_ENABLE |
965 MUSYCC_GRCD_TX_ENABLE |
966 MUSYCC_GRCD_OOFMP_DISABLE |
967 MUSYCC_GRCD_SF_ALIGN |
968
969 MUSYCC_GRCD_COFAIRQ_DISABLE |
970 MUSYCC_GRCD_MC_ENABLE |
971 (MUSYCC_GRCD_POLLTH_32 << MUSYCC_GRCD_POLLTH_SHIFT));
972
973 pi->regram->pcd =
974 __constant_cpu_to_le32 ((e1mode ? 1 : 0) |
975 MUSYCC_PCD_TXSYNC_RISING |
976 MUSYCC_PCD_RXSYNC_RISING |
977 MUSYCC_PCD_RXDATA_RISING);
978
979
980 pi->regram->mld = __constant_cpu_to_le32 (cxt1e1_max_mru | (cxt1e1_max_mru << 16));
981
982
983 for (i = 0; i < 32; i++)
984 {
985
986
987
988
989
990
991 if (((i == 0) && e1mode) ||
992 ((i == 16) && ((pp->port_mode == CFG_FRAME_E1CRC_CAS) || (pp->port_mode == CFG_FRAME_E1CRC_CAS_AMI)))
993 || ((i > 23) && (!e1mode)))
994 {
995 pi->tsm[i] = 0xff;
996 } else
997 {
998 pi->tsm[i] = 0x00;
999 }
1000 }
1001 for (i = 0; i < MUSYCC_NCHANS; i++)
1002 {
1003 pi->regram->ttsm[i] = 0;
1004 pi->regram->rtsm[i] = 0;
1005 }
1006 FLUSH_MEM_WRITE ();
1007 musycc_serv_req (pi, SR_GROUP_INIT | SR_RX_DIRECTION);
1008 musycc_serv_req (pi, SR_GROUP_INIT | SR_TX_DIRECTION);
1009
1010 musycc_init_mdt (pi);
1011
1012 pi->group_is_set = 1;
1013 pi->p = *pp;
1014 return 0;
1015}
1016
1017
1018unsigned int max_int = 0;
1019
1020status_t
1021c4_new_chan (ci_t * ci, int portnum, int channum, void *user)
1022{
1023 mpi_t *pi;
1024 mch_t *ch;
1025 int gchan;
1026
1027 if (c4_find_chan (channum))
1028 return EEXIST;
1029
1030 if (portnum >= ci->max_port)
1031 return ENXIO;
1032
1033 pi = &(ci->port[portnum]);
1034
1035 for (gchan = 0; gchan < MUSYCC_NCHANS; gchan++)
1036 {
1037 ch = pi->chan[gchan];
1038 if (ch && ch->state == UNASSIGNED)
1039 break;
1040 }
1041 if (gchan == MUSYCC_NCHANS)
1042 return ENFILE;
1043
1044 ch->up = pi;
1045
1046
1047 ch->state = DOWN;
1048 ch->user = user;
1049 ch->gchan = gchan;
1050 ch->channum = channum;
1051 ch->p.channum = channum;
1052#if 1
1053 ch->p.card = ci->brdno;
1054 ch->p.port = portnum;
1055#endif
1056 ch->p.chan_mode = CFG_CH_PROTO_HDLC_FCS16;
1057 ch->p.idlecode = CFG_CH_FLAG_7E;
1058 ch->p.pad_fill_count = 2;
1059 spin_lock_init (&ch->ch_rxlock);
1060 spin_lock_init (&ch->ch_txlock);
1061
1062 {
1063 status_t ret;
1064
1065 if ((ret = c4_wk_chan_init (pi, ch)))
1066 return ret;
1067 }
1068
1069
1070 if (ci->first_if == 0)
1071
1072 {
1073 ci->first_if = ci->last_if = user;
1074 ci->first_channum = ci->last_channum = channum;
1075 } else
1076 {
1077 ci->last_if = user;
1078 if (ci->last_channum < channum)
1079 ci->last_channum = channum;
1080 }
1081 return 0;
1082}
1083
1084status_t
1085c4_del_chan (int channum)
1086{
1087 mch_t *ch;
1088
1089 if (!(ch = c4_find_chan (channum)))
1090 return ENOENT;
1091 if (ch->state == UP)
1092 musycc_chan_down ((ci_t *) 0, channum);
1093 ch->state = UNASSIGNED;
1094 ch->gchan = (-1);
1095 ch->channum = (-1);
1096 ch->p.channum = (-1);
1097 return 0;
1098}
1099
1100status_t
1101c4_del_chan_stats (int channum)
1102{
1103 mch_t *ch;
1104
1105 if (!(ch = c4_find_chan (channum)))
1106 return ENOENT;
1107
1108 memset (&ch->s, 0, sizeof (struct sbecom_chan_stats));
1109 return 0;
1110}
1111
1112
1113status_t
1114c4_set_chan (int channum, struct sbecom_chan_param * p)
1115{
1116 mch_t *ch;
1117 int i, x = 0;
1118
1119 if (!(ch = c4_find_chan (channum)))
1120 return ENOENT;
1121
1122#if 1
1123 if (ch->p.card != p->card ||
1124 ch->p.port != p->port ||
1125 ch->p.channum != p->channum)
1126 return EINVAL;
1127#endif
1128
1129 if (!(ch->up->group_is_set))
1130 {
1131 return EIO;
1132
1133
1134 }
1135
1136
1137
1138
1139
1140 if (ch->p.status != p->status || ch->p.chan_mode != p->chan_mode ||
1141 ch->p.data_inv != p->data_inv || ch->p.intr_mask != p->intr_mask ||
1142 ch->txd_free < ch->txd_num)
1143 x = 1;
1144 for (i = 0; i < 32; i++)
1145 if (ch->p.bitmask[i] != p->bitmask[i])
1146 x = 1;
1147 ch->p = *p;
1148 if (x && (ch->state == UP))
1149
1150 {
1151 status_t ret;
1152
1153 if ((ret = musycc_chan_down ((ci_t *) 0, channum)))
1154 return ret;
1155 if ((ret = c4_chan_up (ch->up->up, channum)))
1156 return ret;
1157 sd_enable_xmit (ch->user);
1158
1159 }
1160 return 0;
1161}
1162
1163
1164status_t
1165c4_get_chan (int channum, struct sbecom_chan_param * p)
1166{
1167 mch_t *ch;
1168
1169 if (!(ch = c4_find_chan (channum)))
1170 return ENOENT;
1171 *p = ch->p;
1172 return 0;
1173}
1174
1175status_t
1176c4_get_chan_stats (int channum, struct sbecom_chan_stats * p)
1177{
1178 mch_t *ch;
1179
1180 if (!(ch = c4_find_chan (channum)))
1181 return ENOENT;
1182 *p = ch->s;
1183 p->tx_pending = atomic_read (&ch->tx_pending);
1184 return 0;
1185}
1186
1187STATIC int
1188c4_fifo_alloc (mpi_t * pi, int chan, int *len)
1189{
1190 int i, l = 0, start = 0, max = 0, maxstart = 0;
1191
1192 for (i = 0; i < 32; i++)
1193 {
1194 if (pi->fifomap[i] != -1)
1195 {
1196 l = 0;
1197 start = i + 1;
1198 continue;
1199 }
1200 ++l;
1201 if (l > max)
1202 {
1203 max = l;
1204 maxstart = start;
1205 }
1206 if (max == *len)
1207 break;
1208 }
1209 if (max != *len)
1210 {
1211 if (cxt1e1_log_level >= LOG_WARN)
1212 pr_info("%s: wanted to allocate %d fifo space, but got only %d\n",
1213 pi->up->devname, *len, max);
1214 *len = max;
1215 }
1216 if (cxt1e1_log_level >= LOG_DEBUG)
1217 pr_info("%s: allocated %d fifo at %d for channel %d/%d\n",
1218 pi->up->devname, max, start, chan, pi->p.portnum);
1219 for (i = maxstart; i < (maxstart + max); i++)
1220 pi->fifomap[i] = chan;
1221 return start;
1222}
1223
1224void
1225c4_fifo_free (mpi_t * pi, int chan)
1226{
1227 int i;
1228
1229 if (cxt1e1_log_level >= LOG_DEBUG)
1230 pr_info("%s: deallocated fifo for channel %d/%d\n",
1231 pi->up->devname, chan, pi->p.portnum);
1232 for (i = 0; i < 32; i++)
1233 if (pi->fifomap[i] == chan)
1234 pi->fifomap[i] = -1;
1235}
1236
1237
1238status_t
1239c4_chan_up (ci_t * ci, int channum)
1240{
1241 mpi_t *pi;
1242 mch_t *ch;
1243 struct mbuf *m;
1244 struct mdesc *md;
1245 int nts, nbuf, txnum, rxnum;
1246 int addr, i, j, gchan;
1247 u_int32_t tmp;
1248
1249
1250 if (!(ch = c4_find_chan (channum)))
1251 return ENOENT;
1252 if (ch->state == UP)
1253 {
1254 if (cxt1e1_log_level >= LOG_MONITOR)
1255 pr_info("%s: channel already UP, graceful early exit\n",
1256 ci->devname);
1257 return 0;
1258 }
1259 pi = ch->up;
1260 gchan = ch->gchan;
1261
1262 nts = 0;
1263 for (i = 0; i < 32; i++)
1264 {
1265 if (ch->p.bitmask[i] & pi->tsm[i])
1266 {
1267 if (1 || cxt1e1_log_level >= LOG_WARN)
1268 {
1269 pr_info("%s: c4_chan_up[%d] EINVAL (attempt to cfg in-use or unavailable TimeSlot[%d])\n",
1270 ci->devname, channum, i);
1271 pr_info("+ ask4 %x, currently %x\n",
1272 ch->p.bitmask[i], pi->tsm[i]);
1273 }
1274 return EINVAL;
1275 }
1276 for (j = 0; j < 8; j++)
1277 if (ch->p.bitmask[i] & (1 << j))
1278 nts++;
1279 }
1280
1281 nbuf = nts / 8 ? nts / 8 : 1;
1282 if (!nbuf)
1283 {
1284
1285 pr_info("%s: c4_chan_up[%d] ENOBUFS (no TimeSlots assigned)\n",
1286 ci->devname, channum);
1287 return ENOBUFS;
1288 }
1289 addr = c4_fifo_alloc (pi, gchan, &nbuf);
1290 ch->state = UP;
1291
1292
1293 musycc_update_timeslots (pi);
1294
1295
1296 ch->s.tx_pending = 0;
1297
1298
1299 {
1300 u_int32_t ccd;
1301
1302 ccd = musycc_chan_proto (ch->p.chan_mode) << MUSYCC_CCD_PROTO_SHIFT;
1303 if ((ch->p.chan_mode == CFG_CH_PROTO_ISLP_MODE) ||
1304 (ch->p.chan_mode == CFG_CH_PROTO_TRANS))
1305 {
1306 ccd |= MUSYCC_CCD_FCS_XFER;
1307 }
1308 ccd |= 2 << MUSYCC_CCD_MAX_LENGTH;
1309 ccd |= ch->p.intr_mask;
1310 ccd |= addr << MUSYCC_CCD_BUFFER_LOC;
1311 if (ch->p.chan_mode == CFG_CH_PROTO_TRANS)
1312 ccd |= (nbuf) << MUSYCC_CCD_BUFFER_LENGTH;
1313 else
1314 ccd |= (nbuf - 1) << MUSYCC_CCD_BUFFER_LENGTH;
1315
1316 if (ch->p.data_inv & CFG_CH_DINV_TX)
1317 ccd |= MUSYCC_CCD_INVERT_DATA;
1318 pi->regram->tcct[gchan] = cpu_to_le32 (ccd);
1319
1320 if (ch->p.data_inv & CFG_CH_DINV_RX)
1321 ccd |= MUSYCC_CCD_INVERT_DATA;
1322 else
1323 ccd &= ~MUSYCC_CCD_INVERT_DATA;
1324 pi->regram->rcct[gchan] = cpu_to_le32 (ccd);
1325 FLUSH_MEM_WRITE ();
1326 }
1327
1328
1329 musycc_serv_req (pi, SR_CHANNEL_CONFIG | SR_RX_DIRECTION | gchan);
1330 musycc_serv_req (pi, SR_CHANNEL_CONFIG | SR_TX_DIRECTION | gchan);
1331
1332
1333
1334
1335
1336
1337 if (ch->p.chan_mode == CFG_CH_PROTO_TRANS)
1338 {
1339 if (max_rxdesc_used == max_rxdesc_default)
1340 max_rxdesc_used = MUSYCC_RXDESC_TRANS;
1341 if (max_txdesc_used == max_txdesc_default)
1342 max_txdesc_used = MUSYCC_TXDESC_TRANS;
1343 }
1344
1345
1346
1347
1348 rxnum = max_rxdesc_used + (nts / 4);
1349 txnum = max_txdesc_used + (nts / 4);
1350
1351#if 0
1352
1353 if (cxt1e1_log_level >= LOG_MONITOR)
1354 pr_info("%s: mode %x rxnum %d (rxused %d def %d) txnum %d (txused %d def %d)\n",
1355 ci->devname, ch->p.chan_mode,
1356 rxnum, max_rxdesc_used, max_rxdesc_default,
1357 txnum, max_txdesc_used, max_txdesc_default);
1358#endif
1359
1360 ch->rxd_num = rxnum;
1361 ch->txd_num = txnum;
1362 ch->rxix_irq_srv = 0;
1363
1364 ch->mdr = OS_kmalloc (sizeof (struct mdesc) * rxnum);
1365 ch->mdt = OS_kmalloc (sizeof (struct mdesc) * txnum);
1366 if (ch->p.chan_mode == CFG_CH_PROTO_TRANS)
1367 tmp = __constant_cpu_to_le32 (cxt1e1_max_mru | EOBIRQ_ENABLE);
1368 else
1369 tmp = __constant_cpu_to_le32 (cxt1e1_max_mru);
1370
1371 for (i = 0, md = ch->mdr; i < rxnum; i++, md++)
1372 {
1373 if (i == (rxnum - 1))
1374 {
1375 md->snext = &ch->mdr[0];
1376 } else
1377 {
1378 md->snext = &ch->mdr[i + 1];
1379 }
1380 md->next = cpu_to_le32 (OS_vtophys (md->snext));
1381
1382 if (!(m = OS_mem_token_alloc (cxt1e1_max_mru)))
1383 {
1384 if (cxt1e1_log_level >= LOG_MONITOR)
1385 pr_info("%s: c4_chan_up[%d] - token alloc failure, size = %d.\n",
1386 ci->devname, channum, cxt1e1_max_mru);
1387 goto errfree;
1388 }
1389 md->mem_token = m;
1390 md->data = cpu_to_le32 (OS_vtophys (OS_mem_token_data (m)));
1391 md->status = tmp | MUSYCC_RX_OWNED;
1392
1393
1394
1395 }
1396
1397 for (i = 0, md = ch->mdt; i < txnum; i++, md++)
1398 {
1399 md->status = HOST_TX_OWNED;
1400
1401
1402 md->mem_token = 0;
1403 md->data = 0;
1404 if (i == (txnum - 1))
1405 {
1406 md->snext = &ch->mdt[0];
1407 } else
1408 {
1409 md->snext = &ch->mdt[i + 1];
1410 }
1411 md->next = cpu_to_le32 (OS_vtophys (md->snext));
1412 }
1413 ch->txd_irq_srv = ch->txd_usr_add = &ch->mdt[0];
1414 ch->txd_free = txnum;
1415 ch->tx_full = 0;
1416 ch->txd_required = 0;
1417
1418
1419 tmp = cpu_to_le32 (OS_vtophys (&ch->mdt[0]));
1420 pi->regram->thp[gchan] = tmp;
1421 pi->regram->tmp[gchan] = tmp;
1422
1423 tmp = cpu_to_le32 (OS_vtophys (&ch->mdr[0]));
1424 pi->regram->rhp[gchan] = tmp;
1425 pi->regram->rmp[gchan] = tmp;
1426
1427
1428 FLUSH_MEM_WRITE ();
1429 if (ch->p.status & RX_ENABLED)
1430 {
1431#ifdef RLD_TRANS_DEBUG
1432 pr_info("++ c4_chan_up() CHAN RX ACTIVATE: chan %d\n", ch->channum);
1433#endif
1434 ch->ch_start_rx = 0;
1435 musycc_serv_req (pi, SR_CHANNEL_ACTIVATE | SR_RX_DIRECTION | gchan);
1436 }
1437 if (ch->p.status & TX_ENABLED)
1438 {
1439#ifdef RLD_TRANS_DEBUG
1440 pr_info("++ c4_chan_up() CHAN TX ACTIVATE: chan %d <delayed>\n", ch->channum);
1441#endif
1442 ch->ch_start_tx = CH_START_TX_1ST;
1443
1444
1445 }
1446 ch->status = ch->p.status;
1447 pi->openchans++;
1448 return 0;
1449
1450errfree:
1451 while (i > 0)
1452 {
1453
1454 i--;
1455 OS_mem_token_free (ch->mdr[i].mem_token);
1456 }
1457 OS_kfree (ch->mdt);
1458 ch->mdt = 0;
1459 ch->txd_num = 0;
1460 OS_kfree (ch->mdr);
1461 ch->mdr = 0;
1462 ch->rxd_num = 0;
1463 ch->state = DOWN;
1464 return ENOBUFS;
1465}
1466
1467
1468
1469void
1470c4_stopwd (ci_t * ci)
1471{
1472 OS_stop_watchdog (&ci->wd);
1473 SD_SEM_TAKE (&ci->sem_wdbusy, "_stop_");
1474 SD_SEM_GIVE (&ci->sem_wdbusy);
1475}
1476
1477
1478void
1479sbecom_get_brdinfo (ci_t * ci, struct sbe_brd_info * bip, u_int8_t *bsn)
1480{
1481 char *np;
1482 u_int32_t sn = 0;
1483 int i;
1484
1485 bip->brdno = ci->brdno;
1486 bip->brd_id = ci->brd_id;
1487 bip->brd_hdw_id = ci->hdw_bid;
1488 bip->brd_chan_cnt = MUSYCC_NCHANS * ci->max_port;
1489
1490 bip->brd_port_cnt = ci->max_port;
1491 bip->brd_pci_speed = BINFO_PCI_SPEED_unk;
1492
1493
1494 if (ci->first_if)
1495 {
1496 {
1497 struct net_device *dev;
1498
1499 dev = (struct net_device *) ci->first_if;
1500 np = (char *) dev->name;
1501 }
1502 strncpy (bip->first_iname, np, CHNM_STRLEN - 1);
1503 } else
1504 strcpy (bip->first_iname, "<NULL>");
1505 if (ci->last_if)
1506 {
1507 {
1508 struct net_device *dev;
1509
1510 dev = (struct net_device *) ci->last_if;
1511 np = (char *) dev->name;
1512 }
1513 strncpy (bip->last_iname, np, CHNM_STRLEN - 1);
1514 } else
1515 strcpy (bip->last_iname, "<NULL>");
1516
1517 if (bsn)
1518 {
1519 for (i = 0; i < 3; i++)
1520 {
1521 bip->brd_mac_addr[i] = *bsn++;
1522 }
1523 for (; i < 6; i++)
1524 {
1525 bip->brd_mac_addr[i] = *bsn;
1526 sn = (sn << 8) | *bsn++;
1527 }
1528 } else
1529 {
1530 for (i = 0; i < 6; i++)
1531 bip->brd_mac_addr[i] = 0;
1532 }
1533 bip->brd_sn = sn;
1534}
1535
1536
1537status_t
1538c4_get_iidinfo (ci_t * ci, struct sbe_iid_info * iip)
1539{
1540 struct net_device *dev;
1541 char *np;
1542
1543 if (!(dev = getuserbychan (iip->channum)))
1544 return ENOENT;
1545
1546 np = dev->name;
1547 strncpy (iip->iname, np, CHNM_STRLEN - 1);
1548 iip->iname[CHNM_STRLEN - 1] = '\0';
1549 return 0;
1550}
1551
1552
1553#ifdef CONFIG_SBE_PMCC4_NCOMM
1554void (*nciInterrupt[MAX_BOARDS][4]) (void);
1555extern void wanpmcC4T1E1_hookInterrupt (int cardID, int deviceID, void *handler);
1556
1557void
1558wanpmcC4T1E1_hookInterrupt (int cardID, int deviceID, void *handler)
1559{
1560 if (cardID < MAX_BOARDS)
1561 nciInterrupt[cardID][deviceID] = handler;
1562}
1563
1564irqreturn_t
1565c4_ebus_intr_th_handler (void *devp)
1566{
1567 ci_t *ci = (ci_t *) devp;
1568 volatile u_int32_t ists;
1569 int handled = 0;
1570 int brdno;
1571
1572
1573 brdno = ci->brdno;
1574 ists = pci_read_32 ((u_int32_t *) &ci->cpldbase->intr);
1575 if (ists & PMCC4_CPLD_INTR_CMT_1)
1576 {
1577 handled = 0x1;
1578 if (nciInterrupt[brdno][0] != NULL)
1579 (*nciInterrupt[brdno][0]) ();
1580 }
1581 if (ists & PMCC4_CPLD_INTR_CMT_2)
1582 {
1583 handled |= 0x2;
1584 if (nciInterrupt[brdno][1] != NULL)
1585 (*nciInterrupt[brdno][1]) ();
1586 }
1587 if (ists & PMCC4_CPLD_INTR_CMT_3)
1588 {
1589 handled |= 0x4;
1590 if (nciInterrupt[brdno][2] != NULL)
1591 (*nciInterrupt[brdno][2]) ();
1592 }
1593 if (ists & PMCC4_CPLD_INTR_CMT_4)
1594 {
1595 handled |= 0x8;
1596 if (nciInterrupt[brdno][3] != NULL)
1597 (*nciInterrupt[brdno][3]) ();
1598 }
1599#if 0
1600
1601
1602
1603 pci_write_32 ((u_int32_t *) &ci->reg->glcd, GCD_MAGIC | MUSYCC_GCD_INTB_DISABLE);
1604#endif
1605
1606 return IRQ_RETVAL (handled);
1607}
1608
1609
1610unsigned long
1611wanpmcC4T1E1_getBaseAddress (int cardID, int deviceID)
1612{
1613 ci_t *ci;
1614 unsigned long base = 0;
1615
1616 ci = c4_list;
1617 while (ci)
1618 {
1619 if (ci->brdno == cardID)
1620 {
1621 if (deviceID < ci->max_port)
1622 base = ((unsigned long) ci->port[deviceID].cometbase);
1623 break;
1624 }
1625 ci = ci->next;
1626 }
1627 return (base);
1628}
1629
1630#endif
1631
1632
1633
1634