xref: /openbmc/linux/drivers/net/fddi/skfp/smtinit.c (revision 2e0566ae)
12874c5fdSThomas Gleixner // SPDX-License-Identifier: GPL-2.0-or-later
233f810b2SJeff Kirsher /******************************************************************************
333f810b2SJeff Kirsher  *
433f810b2SJeff Kirsher  *	(C)Copyright 1998,1999 SysKonnect,
533f810b2SJeff Kirsher  *	a business unit of Schneider & Koch & Co. Datensysteme GmbH.
633f810b2SJeff Kirsher  *
733f810b2SJeff Kirsher  *	See the file "skfddi.c" for further information.
833f810b2SJeff Kirsher  *
933f810b2SJeff Kirsher  *	The information in this file is provided "AS IS" without warranty.
1033f810b2SJeff Kirsher  *
1133f810b2SJeff Kirsher  ******************************************************************************/
1233f810b2SJeff Kirsher 
1333f810b2SJeff Kirsher /*
1433f810b2SJeff Kirsher 	Init SMT
1533f810b2SJeff Kirsher 	call all module level initialization routines
1633f810b2SJeff Kirsher */
1733f810b2SJeff Kirsher 
1833f810b2SJeff Kirsher #include "h/types.h"
1933f810b2SJeff Kirsher #include "h/fddi.h"
2033f810b2SJeff Kirsher #include "h/smc.h"
2133f810b2SJeff Kirsher 
22*2e0566aeSJakub Kicinski void init_fddi_driver(struct s_smc *smc, const u_char *mac_addr);
2333f810b2SJeff Kirsher 
2433f810b2SJeff Kirsher /* define global debug variable */
2533f810b2SJeff Kirsher #if defined(DEBUG) && !defined(DEBUG_BRD)
2633f810b2SJeff Kirsher struct smt_debug debug;
2733f810b2SJeff Kirsher #endif
2833f810b2SJeff Kirsher 
2933f810b2SJeff Kirsher #ifndef MULT_OEM
3033f810b2SJeff Kirsher #define OEMID(smc,i)	oem_id[i]
3133f810b2SJeff Kirsher 	extern u_char	oem_id[] ;
3233f810b2SJeff Kirsher #else	/* MULT_OEM */
3333f810b2SJeff Kirsher #define OEMID(smc,i)	smc->hw.oem_id->oi_mark[i]
3433f810b2SJeff Kirsher 	extern struct s_oem_ids	oem_ids[] ;
3533f810b2SJeff Kirsher #endif	/* MULT_OEM */
3633f810b2SJeff Kirsher 
3733f810b2SJeff Kirsher /*
3833f810b2SJeff Kirsher  * Set OEM specific values
3933f810b2SJeff Kirsher  *
4033f810b2SJeff Kirsher  * Can not be called in smt_reset_defaults, because it is not sure that
4133f810b2SJeff Kirsher  * the OEM ID is already defined.
4233f810b2SJeff Kirsher  */
set_oem_spec_val(struct s_smc * smc)4333f810b2SJeff Kirsher static void set_oem_spec_val(struct s_smc *smc)
4433f810b2SJeff Kirsher {
4533f810b2SJeff Kirsher 	struct fddi_mib *mib ;
4633f810b2SJeff Kirsher 
4733f810b2SJeff Kirsher 	mib = &smc->mib ;
4833f810b2SJeff Kirsher 
4933f810b2SJeff Kirsher 	/*
5033f810b2SJeff Kirsher 	 * set IBM specific values
5133f810b2SJeff Kirsher 	 */
5233f810b2SJeff Kirsher 	if (OEMID(smc,0) == 'I') {
5333f810b2SJeff Kirsher 		mib->fddiSMTConnectionPolicy = POLICY_MM ;
5433f810b2SJeff Kirsher 	}
5533f810b2SJeff Kirsher }
5633f810b2SJeff Kirsher 
5733f810b2SJeff Kirsher /*
5833f810b2SJeff Kirsher  * Init SMT
5933f810b2SJeff Kirsher  */
init_smt(struct s_smc * smc,const u_char * mac_addr)60*2e0566aeSJakub Kicinski int init_smt(struct s_smc *smc, const u_char *mac_addr)
6133f810b2SJeff Kirsher /* u_char *mac_addr;	canonical address or NULL */
6233f810b2SJeff Kirsher {
6333f810b2SJeff Kirsher 	int	p ;
6433f810b2SJeff Kirsher 
6533f810b2SJeff Kirsher #if defined(DEBUG) && !defined(DEBUG_BRD)
6633f810b2SJeff Kirsher 	debug.d_smt = 0 ;
6733f810b2SJeff Kirsher 	debug.d_smtf = 0 ;
6833f810b2SJeff Kirsher 	debug.d_rmt = 0 ;
6933f810b2SJeff Kirsher 	debug.d_ecm = 0 ;
7033f810b2SJeff Kirsher 	debug.d_pcm = 0 ;
7133f810b2SJeff Kirsher 	debug.d_cfm = 0 ;
7233f810b2SJeff Kirsher 
7333f810b2SJeff Kirsher 	debug.d_plc = 0 ;
7433f810b2SJeff Kirsher #ifdef	ESS
7533f810b2SJeff Kirsher 	debug.d_ess = 0 ;
7633f810b2SJeff Kirsher #endif
7733f810b2SJeff Kirsher #ifdef	SBA
7833f810b2SJeff Kirsher 	debug.d_sba = 0 ;
7933f810b2SJeff Kirsher #endif
8033f810b2SJeff Kirsher #endif	/* DEBUG && !DEBUG_BRD */
8133f810b2SJeff Kirsher 
8233f810b2SJeff Kirsher 	/* First initialize the ports mib->pointers */
8333f810b2SJeff Kirsher 	for ( p = 0; p < NUMPHYS; p ++ ) {
8433f810b2SJeff Kirsher 		smc->y[p].mib = & smc->mib.p[p] ;
8533f810b2SJeff Kirsher 	}
8633f810b2SJeff Kirsher 
8733f810b2SJeff Kirsher 	set_oem_spec_val(smc) ;
8833f810b2SJeff Kirsher 	(void) smt_set_mac_opvalues(smc) ;
8933f810b2SJeff Kirsher 	init_fddi_driver(smc,mac_addr) ;	/* HW driver */
9033f810b2SJeff Kirsher 	smt_fixup_mib(smc) ;		/* update values that depend on s.sas */
9133f810b2SJeff Kirsher 
9233f810b2SJeff Kirsher 	ev_init(smc) ;			/* event queue */
9333f810b2SJeff Kirsher #ifndef	SLIM_SMT
9433f810b2SJeff Kirsher 	smt_init_evc(smc) ;		/* evcs in MIB */
9533f810b2SJeff Kirsher #endif	/* no SLIM_SMT */
9633f810b2SJeff Kirsher 	smt_timer_init(smc) ;		/* timer package */
9733f810b2SJeff Kirsher 	smt_agent_init(smc) ;		/* SMT frame manager */
9833f810b2SJeff Kirsher 
9933f810b2SJeff Kirsher 	pcm_init(smc) ;			/* PCM state machine */
10033f810b2SJeff Kirsher 	ecm_init(smc) ;			/* ECM state machine */
10133f810b2SJeff Kirsher 	cfm_init(smc) ;			/* CFM state machine */
10233f810b2SJeff Kirsher 	rmt_init(smc) ;			/* RMT state machine */
10333f810b2SJeff Kirsher 
10433f810b2SJeff Kirsher 	for (p = 0 ; p < NUMPHYS ; p++) {
10533f810b2SJeff Kirsher 		pcm(smc,p,0) ;		/* PCM A state machine */
10633f810b2SJeff Kirsher 	}
10733f810b2SJeff Kirsher 	ecm(smc,0) ;			/* ECM state machine */
10833f810b2SJeff Kirsher 	cfm(smc,0) ;			/* CFM state machine */
10933f810b2SJeff Kirsher 	rmt(smc,0) ;			/* RMT state machine */
11033f810b2SJeff Kirsher 
11133f810b2SJeff Kirsher 	smt_agent_task(smc) ;		/* NIF FSM etc */
11233f810b2SJeff Kirsher 
11333f810b2SJeff Kirsher         PNMI_INIT(smc) ;                /* PNMI initialization */
11433f810b2SJeff Kirsher 
11533f810b2SJeff Kirsher 	return 0;
11633f810b2SJeff Kirsher }
11733f810b2SJeff Kirsher 
118