1 /******************************************************************************
3 * (C)Copyright 1998,1999 SysKonnect,
4 * a business unit of Schneider & Koch & Co. Datensysteme GmbH.
6 * See the file "skfddi.c" for further information.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * The information in this file is provided "AS IS" without warranty.
15 ******************************************************************************/
18 * FBI board dependent Driver for SMT and LLC
24 #include "h/supern_2.h"
25 #include "h/skfbiinc.h"
28 static const char ID_sccs
[] = "@(#)drvfbi.c 1.63 99/02/11 (C) SK " ;
36 #define LED_Y_ON 0x11 /* Used for ring up/down indication */
37 #define LED_Y_OFF 0x10
40 #define MS2BCLK(x) ((x)*12500L)
43 * valid configuration values are:
46 const int opt_ints
[] = {8, 3, 4, 5, 9, 10, 11, 12, 15} ;
47 const int opt_iops
[] = {8,
48 0x100, 0x120, 0x180, 0x1a0, 0x220, 0x240, 0x320, 0x340};
49 const int opt_dmas
[] = {4, 3, 5, 6, 7} ;
50 const int opt_eproms
[] = {15, 0xc0, 0xc2, 0xc4, 0xc6, 0xc8, 0xca, 0xcc, 0xce,
51 0xd0, 0xd2, 0xd4, 0xd6, 0xd8, 0xda, 0xdc} ;
54 const int opt_ints
[] = {5, 9, 10, 11} ;
55 const int opt_dmas
[] = {0, 5, 6, 7} ;
56 const int opt_eproms
[] = {0xc0, 0xc2, 0xc4, 0xc6, 0xc8, 0xca, 0xcc, 0xce,
57 0xd0, 0xd2, 0xd4, 0xd6, 0xd8, 0xda, 0xdc} ;
61 int opt_ints
[] = {3, 11, 10, 9} ; /* FM1 */
62 int opt_eproms
[] = {0, 0xc4, 0xc8, 0xcc, 0xd0, 0xd4, 0xd8, 0xdc} ;
69 * | --------------------- the patched POS_ID of the Adapter
70 * | xxxx = (Vendor ID low byte,
71 * | Vendor ID high byte,
72 * | Device ID low byte,
73 * | Device ID high byte)
74 * +------------------------------ the patched oem_id must be
75 * 'S' for SK or 'I' for IBM
76 * this is a short id for the driver.
81 const u_char oem_id
[] = "xPOS_ID:xxxx" ;
83 const u_char oem_id
[] = "xPOSID1:xxxx" ; /* FM1 card id. */
85 #else /* OEM_CONCEPT */
87 const u_char oem_id
[] = OEM_ID
;
89 const u_char oem_id
[] = OEM_ID1
; /* FM1 card id. */
91 #endif /* OEM_CONCEPT */
93 #define OEMID(smc,i) oem_id[ID_BYTE0 + i]
95 const struct s_oem_ids oem_ids
[] = {
99 #define OEMID(smc,i) smc->hw.oem_id->oi_id[i]
100 #endif /* MULT_OEM */
102 /* Prototypes of external functions */
104 extern int AIX_vpdReadByte() ;
108 /* Prototype of a local function. */
109 static void smt_stop_watchdog(struct s_smc
*smc
);
112 static int read_card_id() ;
113 static void DisableSlotAccess() ;
114 static void EnableSlotAccess() ;
116 extern int attach_POS_addr() ;
117 extern int detach_POS_addr() ;
118 extern u_char
read_POS() ;
119 extern void write_POS() ;
120 extern int AIX_vpdReadByte() ;
122 #define read_POS(smc,a1,a2) ((u_char) inp(a1))
123 #define write_POS(smc,a1,a2,a3) outp((a1),(a3))
131 static void card_start(struct s_smc
*smc
)
139 smt_stop_watchdog(smc
) ;
142 outpw(CSR_A
,0) ; /* reset for all chips */
143 for (i
= 10 ; i
; i
--) /* delay for PLC's */
145 OUT_82c54_TIMER(3,COUNT(2) | RW_OP(3) | TMODE(2)) ;
146 /* counter 2, mode 2 */
147 OUT_82c54_TIMER(2,97) ; /* LSB */
148 OUT_82c54_TIMER(2,0) ; /* MSB ( 15.6 us ) */
149 outpw(CSR_A
,CS_CRESET
) ;
152 outpw(CSR_A
,0) ; /* reset for all chips */
153 for (i
= 10 ; i
; i
--) /* delay for PLC's */
155 outpw(CSR_A
,CS_CRESET
) ;
156 smc
->hw
.led
= (2<<6) ;
157 outpw(CSR_A
,CS_CRESET
| smc
->hw
.led
) ;
160 outp(ADDR(CARD_DIS
),0) ; /* reset for all chips */
161 for (i
= 10 ; i
; i
--) /* delay for PLC's */
163 outp(ADDR(CARD_EN
),0) ;
164 /* first I/O after reset must not be a access to FORMAC or PLC */
169 OUT_82c54_TIMER(3,COUNT(2) | RW_OP(3) | TMODE(3)) ;
170 /* counter 2, mode 3 */
171 OUT_82c54_TIMER(2,(2*24)) ; /* 3.9 us * 2 square wave */
172 OUT_82c54_TIMER(2,0) ; /* MSB */
174 /* POS 102 indicated an activ Check Line or Buss Error monitoring */
175 if (inpw(CSA_A
) & (POS_EN_CHKINT
| POS_EN_BUS_ERR
)) {
176 outp(ADDR(IRQ_CHCK_EN
),0) ;
179 if (!((i
= inpw(CSR_A
)) & CS_SAS
)) {
180 if (!(i
& CS_BYSTAT
)) {
181 outp(ADDR(BYPASS(STAT_INS
)),0) ;/* insert station */
184 outpw(LEDR_A
,LED_1
) ; /* yellow */
188 * make sure no transfer activity is pending
190 outpw(FM_A(FM_MDREG1
),FM_MINIT
) ;
191 outp(ADDR(B0_CTRL
), CTRL_HPI_SET
) ;
192 hwt_wait_time(smc
,hwt_quick_read(smc
),MS2BCLK(10)) ;
194 * now reset everything
196 outp(ADDR(B0_CTRL
),CTRL_RST_SET
) ; /* reset for all chips */
197 i
= (int) inp(ADDR(B0_CTRL
)) ; /* do dummy read */
198 SK_UNUSED(i
) ; /* Make LINT happy. */
199 outp(ADDR(B0_CTRL
), CTRL_RST_CLR
) ;
202 * Reset all bits in the PCI STATUS register
204 outp(ADDR(B0_TST_CTRL
), TST_CFG_WRITE_ON
) ; /* enable for writes */
205 word
= inpw(PCI_C(PCI_STATUS
)) ;
206 outpw(PCI_C(PCI_STATUS
), word
| PCI_ERRBITS
) ;
207 outp(ADDR(B0_TST_CTRL
), TST_CFG_WRITE_OFF
) ; /* disable writes */
210 * Release the reset of all the State machines
211 * Release Master_Reset
212 * Release HPI_SM_Reset
214 outp(ADDR(B0_CTRL
), CTRL_MRST_CLR
|CTRL_HPI_CLR
) ;
217 * determine the adapter type
218 * Note: Do it here, because some drivers may call card_start() once
219 * at very first before any other initialization functions is
222 rev_id
= inp(PCI_C(PCI_REV_ID
)) ;
223 if ((rev_id
& 0xf0) == SK_ML_ID_1
|| (rev_id
& 0xf0) == SK_ML_ID_2
) {
224 smc
->hw
.hw_is_64bit
= TRUE
;
226 smc
->hw
.hw_is_64bit
= FALSE
;
230 * Watermark initialization
232 if (!smc
->hw
.hw_is_64bit
) {
233 outpd(ADDR(B4_R1_F
), RX_WATERMARK
) ;
234 outpd(ADDR(B5_XA_F
), TX_WATERMARK
) ;
235 outpd(ADDR(B5_XS_F
), TX_WATERMARK
) ;
238 outp(ADDR(B0_CTRL
),CTRL_RST_CLR
) ; /* clear the reset chips */
239 outp(ADDR(B0_LED
),LED_GA_OFF
|LED_MY_ON
|LED_GB_OFF
) ; /* ye LED on */
241 /* init the timer value for the watch dog 2,5 minutes */
242 outpd(ADDR(B2_WDOG_INI
),0x6FC23AC0) ;
244 /* initialize the ISR mask */
245 smc
->hw
.is_imask
= ISR_MASK
;
246 smc
->hw
.hw_state
= STOPPED
;
248 GET_PAGE(0) ; /* necessary for BOOT */
251 void card_stop(struct s_smc
*smc
)
253 smt_stop_watchdog(smc
) ;
254 smc
->hw
.mac_ring_is_up
= 0 ; /* ring down */
256 outpw(CSR_A
,0) ; /* reset for all chips */
259 outpw(CSR_A
,0) ; /* reset for all chips */
262 outp(ADDR(CARD_DIS
),0) ; /* reset for all chips */
266 * make sure no transfer activity is pending
268 outpw(FM_A(FM_MDREG1
),FM_MINIT
) ;
269 outp(ADDR(B0_CTRL
), CTRL_HPI_SET
) ;
270 hwt_wait_time(smc
,hwt_quick_read(smc
),MS2BCLK(10)) ;
272 * now reset everything
274 outp(ADDR(B0_CTRL
),CTRL_RST_SET
) ; /* reset for all chips */
275 outp(ADDR(B0_CTRL
),CTRL_RST_CLR
) ; /* reset for all chips */
276 outp(ADDR(B0_LED
),LED_GA_OFF
|LED_MY_OFF
|LED_GB_OFF
) ; /* all LEDs off */
277 smc
->hw
.hw_state
= STOPPED
;
280 /*--------------------------- ISR handling ----------------------------------*/
282 void mac1_irq(struct s_smc
*smc
, u_short stu
, u_short stl
)
289 * FORMAC+ bug modified the queue pointer if many read/write accesses happens!?
291 if (stl
& (FM_SPCEPDS
| /* parit/coding err. syn.q.*/
292 FM_SPCEPDA0
| /* parit/coding err. a.q.0 */
293 FM_SPCEPDA1
| /* parit/coding err. a.q.1 */
294 FM_SPCEPDA2
)) { /* parit/coding err. a.q.2 */
295 SMT_PANIC(smc
,SMT_E0132
, SMT_E0132_MSG
) ;
297 if (stl
& (FM_STBURS
| /* tx buffer underrun syn.q.*/
298 FM_STBURA0
| /* tx buffer underrun a.q.0 */
299 FM_STBURA1
| /* tx buffer underrun a.q.1 */
300 FM_STBURA2
)) { /* tx buffer underrun a.q.2 */
301 SMT_PANIC(smc
,SMT_E0133
, SMT_E0133_MSG
) ;
304 if ( (stu
& (FM_SXMTABT
| /* transmit abort */
306 FM_STXABRS
| /* syn. tx abort */
308 FM_STXABRA0
)) || /* asyn. tx abort */
309 (stl
& (FM_SQLCKS
| /* lock for syn. q. */
310 FM_SQLCKA0
)) ) { /* lock for asyn. q. */
311 formac_tx_restart(smc
) ; /* init tx */
313 stu
= inpw(FM_A(FM_ST1U
)) ;
314 stl
= inpw(FM_A(FM_ST1L
)) ;
315 stu
&= ~ (FM_STECFRMA0
| FM_STEFRMA0
| FM_STEFRMS
) ;
321 if (stu
& (FM_STECFRMA0
| /* end of chain asyn tx */
322 FM_STEFRMA0
)) { /* end of frame asyn tx */
324 smc
->hw
.n_a_send
= 0 ;
325 if (++smc
->hw
.fp
.tx_free
< smc
->hw
.fp
.tx_max
) {
326 start_next_send(smc
);
331 if (stu
& (FM_STEFRMA0
| /* end of asyn tx */
332 FM_STEFRMS
)) { /* end of sync tx */
337 llc_restart_tx(smc
) ;
342 * parity error: note encoding error is not possible in tag mode
344 if (stl
& (FM_SPCEPDS
| /* parity err. syn.q.*/
345 FM_SPCEPDA0
| /* parity err. a.q.0 */
346 FM_SPCEPDA1
)) { /* parity err. a.q.1 */
347 SMT_PANIC(smc
,SMT_E0134
, SMT_E0134_MSG
) ;
350 * buffer underrun: can only occur if a tx threshold is specified
352 if (stl
& (FM_STBURS
| /* tx buffer underrun syn.q.*/
353 FM_STBURA0
| /* tx buffer underrun a.q.0 */
354 FM_STBURA1
)) { /* tx buffer underrun a.q.2 */
355 SMT_PANIC(smc
,SMT_E0133
, SMT_E0133_MSG
) ;
358 if ( (stu
& (FM_SXMTABT
| /* transmit abort */
359 FM_STXABRS
| /* syn. tx abort */
360 FM_STXABRA0
)) || /* asyn. tx abort */
361 (stl
& (FM_SQLCKS
| /* lock for syn. q. */
362 FM_SQLCKA0
)) ) { /* lock for asyn. q. */
363 formac_tx_restart(smc
) ; /* init tx */
365 stu
= inpw(FM_A(FM_ST1U
)) ;
366 stl
= inpw(FM_A(FM_ST1L
)) ;
367 stu
&= ~ (FM_STECFRMA0
| FM_STEFRMA0
| FM_STEFRMS
) ;
372 if (stu
& (FM_STEFRMA0
| /* end of asyn tx */
373 FM_STEFRMS
)) { /* end of sync tx */
378 llc_restart_tx(smc
) ;
382 * interrupt source= plc1
383 * this function is called in nwfbisr.asm
385 void plc1_irq(struct s_smc
*smc
)
387 u_short st
= inpw(PLC(PB
,PL_INTR_EVENT
)) ;
389 #if (defined(ISA) || defined(EISA))
390 /* reset PLC Int. bits */
391 outpw(PLC1_I
,inpw(PLC1_I
)) ;
397 * interrupt source= plc2
398 * this function is called in nwfbisr.asm
400 void plc2_irq(struct s_smc
*smc
)
402 u_short st
= inpw(PLC(PA
,PL_INTR_EVENT
)) ;
404 #if (defined(ISA) || defined(EISA))
405 /* reset PLC Int. bits */
406 outpw(PLC2_I
,inpw(PLC2_I
)) ;
413 * interrupt source= timer
415 void timer_irq(struct s_smc
*smc
)
418 smc
->hw
.t_stop
= smc
->hw
.t_start
;
419 smt_timer_done(smc
) ;
423 * return S-port (PA or PB)
425 int pcm_get_s_port(struct s_smc
*smc
)
432 * Station Label = "FDDI-XYZ" where
438 #define STATION_LABEL_CONNECTOR_OFFSET 5
439 #define STATION_LABEL_PMD_OFFSET 6
440 #define STATION_LABEL_PORT_OFFSET 7
442 void read_address(struct s_smc
*smc
, u_char
*mac_addr
)
448 extern const u_char canonical
[256] ;
450 #if (defined(ISA) || defined(MCA))
451 for (i
= 0; i
< 4 ;i
++) { /* read mac address from board */
452 smc
->hw
.fddi_phys_addr
.a
[i
] =
453 canonical
[(inpw(PR_A(i
+SA_MAC
))&0xff)] ;
455 for (i
= 4; i
< 6; i
++) {
456 smc
->hw
.fddi_phys_addr
.a
[i
] =
457 canonical
[(inpw(PR_A(i
+SA_MAC
+PRA_OFF
))&0xff)] ;
462 * Note: We get trouble on an Alpha machine if we make a inpw()
465 for (i
= 0; i
< 4 ;i
++) { /* read mac address from board */
466 smc
->hw
.fddi_phys_addr
.a
[i
] =
467 canonical
[inp(PR_A(i
+SA_MAC
))] ;
469 for (i
= 4; i
< 6; i
++) {
470 smc
->hw
.fddi_phys_addr
.a
[i
] =
471 canonical
[inp(PR_A(i
+SA_MAC
+PRA_OFF
))] ;
475 for (i
= 0; i
< 6; i
++) { /* read mac address from board */
476 smc
->hw
.fddi_phys_addr
.a
[i
] =
477 canonical
[inp(ADDR(B2_MAC_0
+i
))] ;
481 ConnectorType
= inpw(PR_A(SA_PMD_TYPE
)) & 0xff ;
482 PmdType
= inpw(PR_A(SA_PMD_TYPE
+1)) & 0xff ;
484 ConnectorType
= inp(ADDR(B2_CONN_TYP
)) ;
485 PmdType
= inp(ADDR(B2_PMD_TYP
)) ;
488 smc
->y
[PA
].pmd_type
[PMD_SK_CONN
] =
489 smc
->y
[PB
].pmd_type
[PMD_SK_CONN
] = ConnectorType
;
490 smc
->y
[PA
].pmd_type
[PMD_SK_PMD
] =
491 smc
->y
[PB
].pmd_type
[PMD_SK_PMD
] = PmdType
;
494 for (i
= 0; i
< 6 ;i
++) {
495 smc
->hw
.fddi_canon_addr
.a
[i
] = mac_addr
[i
] ;
496 smc
->hw
.fddi_home_addr
.a
[i
] = canonical
[mac_addr
[i
]] ;
500 smc
->hw
.fddi_home_addr
= smc
->hw
.fddi_phys_addr
;
502 for (i
= 0; i
< 6 ;i
++) {
503 smc
->hw
.fddi_canon_addr
.a
[i
] =
504 canonical
[smc
->hw
.fddi_phys_addr
.a
[i
]] ;
509 * FDDI card soft reset
511 void init_board(struct s_smc
*smc
, u_char
*mac_addr
)
514 read_address(smc
,mac_addr
) ;
517 if (inpw(CSR_A
) & CS_SAS
)
519 if (!(inp(ADDR(B0_DAS
)) & DAS_AVAIL
))
521 smc
->s
.sas
= SMT_SAS
; /* Single att. station */
523 smc
->s
.sas
= SMT_DAS
; /* Dual att. station */
526 if (inpw(CSR_A
) & CS_BYSTAT
)
528 if (!(inp(ADDR(B0_DAS
)) & DAS_BYP_ST
))
530 smc
->mib
.fddiSMTBypassPresent
= 0 ;
531 /* without opt. bypass */
533 smc
->mib
.fddiSMTBypassPresent
= 1 ;
534 /* with opt. bypass */
538 * insert or deinsert optical bypass (called by ECM)
540 void sm_pm_bypass_req(struct s_smc
*smc
, int mode
)
542 #if (defined(ISA) || defined(EISA))
546 DB_ECMN(1,"ECM : sm_pm_bypass_req(%s)\n",(mode
== BP_INSERT
) ?
547 "BP_INSERT" : "BP_DEINSERT",0) ;
549 if (smc
->s
.sas
!= SMT_DAS
)
552 #if (defined(ISA) || defined(EISA))
554 csra_v
= inpw(CSR_A
) & ~CS_BYPASS
;
556 csra_v
|= smc
->hw
.led
;
561 outpw(CSR_A
,csra_v
| CS_BYPASS
) ;
564 outpw(CSR_A
,csra_v
) ;
567 #endif /* ISA / EISA */
571 outp(ADDR(BYPASS(STAT_INS
)),0) ;/* insert station */
574 outp(ADDR(BYPASS(STAT_BYP
)),0) ; /* bypass station */
581 outp(ADDR(B0_DAS
),DAS_BYP_INS
) ; /* insert station */
584 outp(ADDR(B0_DAS
),DAS_BYP_RMV
) ; /* bypass station */
591 * check if bypass connected
593 int sm_pm_bypass_present(struct s_smc
*smc
)
596 return( (inpw(CSR_A
) & CS_BYSTAT
) ? FALSE
: TRUE
) ;
598 return( (inp(ADDR(B0_DAS
)) & DAS_BYP_ST
) ? TRUE
: FALSE
) ;
602 void plc_clear_irq(struct s_smc
*smc
, int p
)
606 #if (defined(ISA) || defined(EISA))
609 /* reset PLC Int. bits */
610 outpw(PLC2_I
,inpw(PLC2_I
)) ;
613 /* reset PLC Int. bits */
614 outpw(PLC1_I
,inpw(PLC1_I
)) ;
624 * led_indication called by rmt_indication() and
630 * 0 Only switch green LEDs according to their respective PCM state
631 * LED_Y_OFF just switch yellow LED off
632 * LED_Y_ON just switch yello LED on
634 static void led_indication(struct s_smc
*smc
, int led_event
)
636 /* use smc->hw.mac_ring_is_up == TRUE
637 * as indication for Ring Operational
641 struct fddi_mib_p
*mib_a
;
642 struct fddi_mib_p
*mib_b
;
650 /* Ring up = yellow led OFF*/
651 if (led_event
== LED_Y_ON
) {
652 smc
->hw
.led
|= CS_LED_1
;
654 else if (led_event
== LED_Y_OFF
) {
655 smc
->hw
.led
&= ~CS_LED_1
;
658 /* Link at Port A or B = green led ON */
659 if (mib_a
->fddiPORTPCMState
== PC8_ACTIVE
||
660 mib_b
->fddiPORTPCMState
== PC8_ACTIVE
) {
661 smc
->hw
.led
|= CS_LED_0
;
664 smc
->hw
.led
&= ~CS_LED_0
;
669 led_state
= inpw(LEDR_A
) ;
671 /* Ring up = yellow led OFF*/
672 if (led_event
== LED_Y_ON
) {
675 else if (led_event
== LED_Y_OFF
) {
676 led_state
&= ~LED_1
;
679 led_state
&= ~(LED_2
|LED_0
) ;
681 /* Link at Port A = green led A ON */
682 if (mib_a
->fddiPORTPCMState
== PC8_ACTIVE
) {
686 /* Link at Port B/S = green led B ON */
687 if (mib_b
->fddiPORTPCMState
== PC8_ACTIVE
) {
692 outpw(LEDR_A
, led_state
) ;
697 /* Ring up = yellow led OFF*/
698 if (led_event
== LED_Y_ON
) {
699 led_state
|= LED_MY_ON
;
701 else if (led_event
== LED_Y_OFF
) {
702 led_state
|= LED_MY_OFF
;
704 else { /* PCM state changed */
705 /* Link at Port A/S = green led A ON */
706 if (mib_a
->fddiPORTPCMState
== PC8_ACTIVE
) {
707 led_state
|= LED_GA_ON
;
710 led_state
|= LED_GA_OFF
;
713 /* Link at Port B = green led B ON */
714 if (mib_b
->fddiPORTPCMState
== PC8_ACTIVE
) {
715 led_state
|= LED_GB_ON
;
718 led_state
|= LED_GB_OFF
;
722 outp(ADDR(B0_LED
), led_state
) ;
728 void pcm_state_change(struct s_smc
*smc
, int plc
, int p_state
)
731 * the current implementation of pcm_state_change() in the driver
732 * parts must be renamed to drv_pcm_state_change() which will be called
733 * now after led_indication.
735 DRV_PCM_STATE_CHANGE(smc
,plc
,p_state
) ;
737 led_indication(smc
,0) ;
741 void rmt_indication(struct s_smc
*smc
, int i
)
743 /* Call a driver special function if defined */
744 DRV_RMT_INDICATION(smc
,i
) ;
746 led_indication(smc
, i
? LED_Y_OFF
: LED_Y_ON
) ;
751 * llc_recover_tx called by init_tx (fplus.c)
753 void llc_recover_tx(struct s_smc
*smc
)
756 extern int load_gen_flag
;
761 smc
->hw
.n_a_send
= 0 ;
768 static int is_equal_num(char comp1
[], char comp2
[], int num
)
772 for (i
= 0 ; i
< num
; i
++) {
773 if (comp1
[i
] != comp2
[i
])
781 * set the OEM ID defaults, and test the contents of the OEM data base
782 * The default OEM is the first ACTIVE entry in the OEM data base
785 * 1 error in data base
789 int set_oi_id_def(struct s_smc
*smc
)
797 act_entries
= FALSE
;
799 smc
->hw
.oem_min_status
= OI_STAT_ACTIVE
;
801 /* check OEM data base */
802 while (oem_ids
[i
].oi_status
) {
803 switch (oem_ids
[i
].oi_status
) {
805 act_entries
= TRUE
; /* we have active IDs */
807 sel_id
= i
; /* save the first active ID */
809 case OI_STAT_PRESENT
:
811 break ; /* entry ok */
813 return (1) ; /* invalid oi_status */
822 /* ok, we have a valid OEM data base with an active entry */
823 smc
->hw
.oem_id
= (struct s_oem_ids
*) &oem_ids
[sel_id
] ;
826 #endif /* MULT_OEM */
830 /************************
832 * BEGIN_MANUAL_ENTRY()
836 * Check if an MCA board is present in the specified slot.
842 * smc - A pointer to the SMT Context struct.
844 * slot - The number of the slot to inspect.
846 * 0 = No adapter present.
847 * 1 = Found FM1 adapter.
851 * for all valid OEM_IDs
852 * compare with ID read
857 * The smc pointer must be valid now.
861 ************************/
862 #define LONG_CARD_ID(lo, hi) ((((hi) & 0xff) << 8) | ((lo) & 0xff))
863 int exist_board(struct s_smc
*smc
, int slot
)
866 SK_LOC_DECL(u_char
,id
[2]) ;
868 #endif /* MULT_OEM */
870 /* No longer valid. */
875 if (read_card_id(smc
, slot
)
876 == LONG_CARD_ID(OEMID(smc
,0), OEMID(smc
,1)))
877 return (1) ; /* Found FM adapter. */
880 idi
= read_card_id(smc
, slot
) ;
884 smc
->hw
.oem_id
= (struct s_oem_ids
*) &oem_ids
[0] ;
885 for (; smc
->hw
.oem_id
->oi_status
!= OI_STAT_LAST
; smc
->hw
.oem_id
++) {
886 if (smc
->hw
.oem_id
->oi_status
< smc
->hw
.oem_min_status
)
889 if (is_equal_num(&id
[0],&OEMID(smc
,0),2))
892 #endif /* MULT_OEM */
893 return (0) ; /* No adapter found. */
896 /************************
900 * Read the MCA card id from the specified slot.
902 * smc - A pointer to the SMT Context struct.
903 * CAVEAT: This pointer may be NULL and *must not* be used within this
904 * function. It's only purpose is for drivers that need some information
905 * for the inp() and outp() macros.
907 * slot - The number of the slot for which the card id is returned.
909 * Returns the card id read from the specified slot. If an illegal slot
910 * number is specified, the function returns zero.
912 ************************/
913 static int read_card_id(struct s_smc
*smc
, int slot
)
914 /* struct s_smc *smc ; Do not use. */
918 SK_UNUSED(smc
) ; /* Make LINT happy. */
919 if ((slot
< 1) || (slot
> 15)) /* max 16 slots, 0 = motherboard */
920 return (0) ; /* Illegal slot number specified. */
922 EnableSlotAccess(smc
, slot
) ;
924 card_id
= ((read_POS(smc
,POS_ID_HIGH
,slot
- 1) & 0xff) << 8) |
925 (read_POS(smc
,POS_ID_LOW
,slot
- 1) & 0xff) ;
927 DisableSlotAccess(smc
) ;
932 /************************
934 * BEGIN_MANUAL_ENTRY()
938 * Get adapter configuration information. Fill all board specific
939 * parameters within the 'smc' structure.
941 * int get_board_para(
945 * smc - A pointer to the SMT Context struct, to which this function will
946 * write some adapter configuration data.
948 * slot - The number of the slot, in which the adapter is installed.
950 * 0 = No adapter present.
952 * 2 = Adapter present, but card enable bit not set.
956 ************************/
957 int get_board_para(struct s_smc
*smc
, int slot
)
962 /* Check if adapter present & get type of adapter. */
963 switch (exist_board(smc
, slot
)) {
964 case 0: /* Adapter not present. */
966 case 1: /* FM Rev. 1 */
967 smc
->hw
.rev
= FM1_REV
;
968 smc
->hw
.VFullRead
= 0x0a ;
969 smc
->hw
.VFullWrite
= 0x05 ;
970 smc
->hw
.DmaWriteExtraBytes
= 8 ; /* 2 extra words. */
973 smc
->hw
.slot
= slot
;
975 EnableSlotAccess(smc
, slot
) ;
977 if (!(read_POS(smc
,POS_102
, slot
- 1) & POS_CARD_EN
)) {
978 DisableSlotAccess(smc
) ;
979 return (2) ; /* Card enable bit not set. */
982 val
= read_POS(smc
,POS_104
, slot
- 1) ; /* I/O, IRQ */
984 #ifndef MEM_MAPPED_IO /* is defined by the operating system */
985 i
= val
& POS_IOSEL
; /* I/O base addr. (0x0200 .. 0xfe00) */
986 smc
->hw
.iop
= (i
+ 1) * 0x0400 - 0x200 ;
988 i
= ((val
& POS_IRQSEL
) >> 6) & 0x03 ; /* IRQ <0, 1> */
989 smc
->hw
.irq
= opt_ints
[i
] ;
991 /* FPROM base addr. */
992 i
= ((read_POS(smc
,POS_103
, slot
- 1) & POS_MSEL
) >> 4) & 0x07 ;
993 smc
->hw
.eprom
= opt_eproms
[i
] ;
995 DisableSlotAccess(smc
) ;
997 /* before this, the smc->hw.iop must be set !!! */
998 smc
->hw
.slot_32
= inpw(CSF_A
) & SLOT_32
;
1003 /* Enable access to specified MCA slot. */
1004 static void EnableSlotAccess(struct s_smc
*smc
, int slot
)
1012 outp(POS_SYS_SETUP
, POS_SYSTEM
) ;
1015 outp(POS_CHANNEL_POS
, POS_CHANNEL_BIT
| (slot
-1)) ;
1017 attach_POS_addr (smc
) ;
1021 /* Disable access to MCA slot formerly enabled via EnableSlotAccess(). */
1022 static void DisableSlotAccess(struct s_smc
*smc
)
1027 outp(POS_CHANNEL_POS
, 0) ;
1029 detach_POS_addr (smc
) ;
1035 #ifndef MEM_MAPPED_IO
1036 #define SADDR(slot) (((slot)<<12)&0xf000)
1037 #else /* MEM_MAPPED_IO */
1038 #define SADDR(slot) (smc->hw.iop)
1039 #endif /* MEM_MAPPED_IO */
1041 /************************
1043 * BEGIN_MANUAL_ENTRY()
1047 * Check if an EISA board is present in the specified slot.
1050 * struct s_smc *smc,
1053 * smc - A pointer to the SMT Context struct.
1055 * slot - The number of the slot to inspect.
1057 * 0 = No adapter present.
1058 * 1 = Found adapter.
1062 * for all valid OEM_IDs
1063 * compare with ID read
1064 * if equal, return 1
1068 * The smc pointer must be valid now.
1070 ************************/
1071 int exist_board(struct s_smc
*smc
, int slot
)
1075 SK_LOC_DECL(u_char
,id
[4]) ;
1076 #endif /* MULT_OEM */
1078 /* No longer valid. */
1085 for (i
= 0 ; i
< 4 ; i
++) {
1086 if (inp(SADDR(slot
)+PRA(i
)) != OEMID(smc
,i
))
1090 #else /* MULT_OEM */
1091 for (i
= 0 ; i
< 4 ; i
++)
1092 id
[i
] = inp(SADDR(slot
)+PRA(i
)) ;
1094 smc
->hw
.oem_id
= (struct s_oem_ids
*) &oem_ids
[0] ;
1096 for (; smc
->hw
.oem_id
->oi_status
!= OI_STAT_LAST
; smc
->hw
.oem_id
++) {
1097 if (smc
->hw
.oem_id
->oi_status
< smc
->hw
.oem_min_status
)
1100 if (is_equal_num(&id
[0],&OEMID(smc
,0),4))
1103 return (0) ; /* No adapter found. */
1104 #endif /* MULT_OEM */
1108 int get_board_para(struct s_smc
*smc
, int slot
)
1112 if (!exist_board(smc
,slot
))
1115 smc
->hw
.slot
= slot
;
1116 #ifndef MEM_MAPPED_IO /* if defined by the operating system */
1117 smc
->hw
.iop
= SADDR(slot
) ;
1120 if (!(inp(C0_A(0))&CFG_CARD_EN
)) {
1121 return(2) ; /* CFG_CARD_EN bit not set! */
1124 smc
->hw
.irq
= opt_ints
[(inp(C1_A(0)) & CFG_IRQ_SEL
)] ;
1125 smc
->hw
.dma
= opt_dmas
[((inp(C1_A(0)) & CFG_DRQ_SEL
)>>3)] ;
1127 if ((i
= inp(C2_A(0)) & CFG_EPROM_SEL
) != 0x0f)
1128 smc
->hw
.eprom
= opt_eproms
[i
] ;
1132 smc
->hw
.DmaWriteExtraBytes
= 8 ;
1140 const u_char sklogo
[6] = SKLOGO_STR
;
1141 #define SIZE_SKLOGO(smc) sizeof(sklogo)
1142 #define SKLOGO(smc,i) sklogo[i]
1143 #else /* MULT_OEM */
1144 #define SIZE_SKLOGO(smc) smc->hw.oem_id->oi_logo_len
1145 #define SKLOGO(smc,i) smc->hw.oem_id->oi_logo[i]
1146 #endif /* MULT_OEM */
1149 int exist_board(struct s_smc
*smc
, HW_PTR port
)
1154 u_char board_logo
[15] ;
1155 SK_LOC_DECL(u_char
,id
[4]) ;
1156 #endif /* MULT_OEM */
1158 /* No longer valid. */
1164 for (i
= SADDRL
; i
< (signed) (SADDRL
+SIZE_SKLOGO(smc
)) ; i
++) {
1165 if ((u_char
)inpw((PRA(i
)+port
)) != SKLOGO(smc
,i
-SADDRL
)) {
1170 /* check MAC address (S&K or other) */
1171 for (i
= 0 ; i
< 3 ; i
++) {
1172 if ((u_char
)inpw((PRA(i
)+port
)) != OEMID(smc
,i
))
1176 #else /* MULT_OEM */
1177 smc
->hw
.oem_id
= (struct s_oem_ids
*) &oem_ids
[0] ;
1178 board_logo
[0] = (u_char
)inpw((PRA(SADDRL
)+port
)) ;
1181 for (; smc
->hw
.oem_id
->oi_status
!= OI_STAT_LAST
; smc
->hw
.oem_id
++) {
1182 if (smc
->hw
.oem_id
->oi_status
< smc
->hw
.oem_min_status
)
1185 /* Test all read bytes with current OEM_entry */
1186 /* for (i=0; (i<bytes_read) && (i < SIZE_SKLOGO(smc)); i++) { */
1187 for (i
= 0; i
< bytes_read
; i
++) {
1188 if (board_logo
[i
] != SKLOGO(smc
,i
))
1192 /* If mismatch, switch to next OEM entry */
1193 if ((board_logo
[i
] != SKLOGO(smc
,i
)) && (i
< bytes_read
))
1197 while (bytes_read
< SIZE_SKLOGO(smc
)) {
1198 // inpw next byte SK_Logo
1200 board_logo
[i
] = (u_char
)inpw((PRA(SADDRL
+i
)+port
)) ;
1202 if (board_logo
[i
] != SKLOGO(smc
,i
))
1206 for (i
= 0 ; i
< 3 ; i
++)
1207 id
[i
] = (u_char
)inpw((PRA(i
)+port
)) ;
1209 if ((board_logo
[i
] == SKLOGO(smc
,i
))
1210 && (bytes_read
== SIZE_SKLOGO(smc
))) {
1212 if (is_equal_num(&id
[0],&OEMID(smc
,0),3))
1217 #endif /* MULT_OEM */
1220 int get_board_para(struct s_smc
*smc
, int slot
)
1224 return(0) ; /* for ISA not supported */
1230 int exist_board(struct s_smc
*smc
, int slot
)
1237 found
= FALSE
; /* make sure we returned with adatper not found*/
1238 /* if an empty oemids.h was included */
1241 smc
->hw
.oem_id
= (struct s_oem_ids
*) &oem_ids
[0] ;
1242 for (; smc
->hw
.oem_id
->oi_status
!= OI_STAT_LAST
; smc
->hw
.oem_id
++) {
1243 if (smc
->hw
.oem_id
->oi_status
< smc
->hw
.oem_min_status
)
1246 ven_id
= OEMID(smc
,0) + (OEMID(smc
,1) << 8) ;
1247 dev_id
= OEMID(smc
,2) + (OEMID(smc
,3) << 8) ;
1248 for (i
= 0; i
< slot
; i
++) {
1249 if (pci_find_device(i
,&smc
->hw
.pci_handle
,
1250 dev_id
,ven_id
) != 0) {
1258 return(1) ; /* adapter was found */
1263 return(0) ; /* adapter was not found */
1266 #endif /* USE_BIOS_FUNC */
1268 void driver_get_bia(struct s_smc
*smc
, struct fddi_addr
*bia_addr
)
1272 extern const u_char canonical
[256] ;
1274 for (i
= 0 ; i
< 6 ; i
++) {
1275 bia_addr
->a
[i
] = canonical
[smc
->hw
.fddi_phys_addr
.a
[i
]] ;
1279 void smt_start_watchdog(struct s_smc
*smc
)
1281 SK_UNUSED(smc
) ; /* Make LINT happy. */
1286 if (smc
->hw
.wdog_used
) {
1287 outpw(ADDR(B2_WDOG_CRTL
),TIM_START
) ; /* Start timer. */
1294 static void smt_stop_watchdog(struct s_smc
*smc
)
1296 SK_UNUSED(smc
) ; /* Make LINT happy. */
1300 if (smc
->hw
.wdog_used
) {
1301 outpw(ADDR(B2_WDOG_CRTL
),TIM_STOP
) ; /* Stop timer. */
1310 void mac_do_pci_fix(struct s_smc
*smc
)