xref: /OK3568_Linux_fs/external/rkwifibt/drivers/bcmdhd/siutils_priv.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun  * Include file private to the SOC Interconnect support files.
3*4882a593Smuzhiyun  *
4*4882a593Smuzhiyun  * Copyright (C) 2020, Broadcom.
5*4882a593Smuzhiyun  *
6*4882a593Smuzhiyun  *      Unless you and Broadcom execute a separate written software license
7*4882a593Smuzhiyun  * agreement governing use of this software, this software is licensed to you
8*4882a593Smuzhiyun  * under the terms of the GNU General Public License version 2 (the "GPL"),
9*4882a593Smuzhiyun  * available at http://www.broadcom.com/licenses/GPLv2.php, with the
10*4882a593Smuzhiyun  * following added to such license:
11*4882a593Smuzhiyun  *
12*4882a593Smuzhiyun  *      As a special exception, the copyright holders of this software give you
13*4882a593Smuzhiyun  * permission to link this software with independent modules, and to copy and
14*4882a593Smuzhiyun  * distribute the resulting executable under terms of your choice, provided that
15*4882a593Smuzhiyun  * you also meet, for each linked independent module, the terms and conditions of
16*4882a593Smuzhiyun  * the license of that module.  An independent module is a module which is not
17*4882a593Smuzhiyun  * derived from this software.  The special exception does not apply to any
18*4882a593Smuzhiyun  * modifications of the software.
19*4882a593Smuzhiyun  *
20*4882a593Smuzhiyun  *
21*4882a593Smuzhiyun  * <<Broadcom-WL-IPTag/Dual:>>
22*4882a593Smuzhiyun  */
23*4882a593Smuzhiyun 
24*4882a593Smuzhiyun #ifndef	_siutils_priv_h_
25*4882a593Smuzhiyun #define	_siutils_priv_h_
26*4882a593Smuzhiyun 
27*4882a593Smuzhiyun #if defined(BCMDBG_ERR) && defined(ERR_USE_LOG_EVENT)
28*4882a593Smuzhiyun #define	SI_ERROR(args)	EVENT_LOG_COMPACT_CAST_PAREN_ARGS(EVENT_LOG_TAG_SI_ERROR, args)
29*4882a593Smuzhiyun #elif defined(BCMDBG_ERR) || defined(SI_ERROR_ENFORCE)
30*4882a593Smuzhiyun #define	SI_ERROR(args)	printf args
31*4882a593Smuzhiyun #else
32*4882a593Smuzhiyun #define	SI_ERROR(args)
33*4882a593Smuzhiyun #endif	/* BCMDBG_ERR */
34*4882a593Smuzhiyun 
35*4882a593Smuzhiyun #if defined(ENABLE_CORECAPTURE)
36*4882a593Smuzhiyun 
37*4882a593Smuzhiyun #if !defined(BCMDBG)
38*4882a593Smuzhiyun #define	SI_PRINT(args)	osl_wificc_logDebug args
39*4882a593Smuzhiyun #else
40*4882a593Smuzhiyun #define	SI_PRINT(args)	printf args
41*4882a593Smuzhiyun #endif /* !BCMDBG */
42*4882a593Smuzhiyun 
43*4882a593Smuzhiyun #else
44*4882a593Smuzhiyun 
45*4882a593Smuzhiyun #define	SI_PRINT(args)	printf args
46*4882a593Smuzhiyun 
47*4882a593Smuzhiyun #endif /* ENABLE_CORECAPTURE */
48*4882a593Smuzhiyun 
49*4882a593Smuzhiyun #ifdef BCMDBG
50*4882a593Smuzhiyun #define	SI_MSG(args)	printf args
51*4882a593Smuzhiyun #else
52*4882a593Smuzhiyun #define	SI_MSG(args)
53*4882a593Smuzhiyun #endif	/* BCMDBG */
54*4882a593Smuzhiyun 
55*4882a593Smuzhiyun #ifdef BCMDBG_SI
56*4882a593Smuzhiyun #define	SI_VMSG(args)	printf args
57*4882a593Smuzhiyun #else
58*4882a593Smuzhiyun #define	SI_VMSG(args)
59*4882a593Smuzhiyun #endif
60*4882a593Smuzhiyun 
61*4882a593Smuzhiyun #define	IS_SIM(chippkg)	((chippkg == HDLSIM_PKG_ID) || (chippkg == HWSIM_PKG_ID))
62*4882a593Smuzhiyun 
63*4882a593Smuzhiyun typedef void (*si_intrsoff_t)(void *intr_arg, bcm_int_bitmask_t *mask);
64*4882a593Smuzhiyun typedef void (*si_intrsrestore_t)(void *intr_arg, bcm_int_bitmask_t *mask);
65*4882a593Smuzhiyun typedef bool (*si_intrsenabled_t)(void *intr_arg);
66*4882a593Smuzhiyun 
67*4882a593Smuzhiyun #define SI_GPIO_MAX		16
68*4882a593Smuzhiyun 
69*4882a593Smuzhiyun typedef struct gci_gpio_item {
70*4882a593Smuzhiyun 	void			*arg;
71*4882a593Smuzhiyun 	uint8			gci_gpio;
72*4882a593Smuzhiyun 	uint8			status;
73*4882a593Smuzhiyun 	gci_gpio_handler_t	handler;
74*4882a593Smuzhiyun 	struct gci_gpio_item	*next;
75*4882a593Smuzhiyun } gci_gpio_item_t;
76*4882a593Smuzhiyun 
77*4882a593Smuzhiyun typedef struct wci2_cbs {
78*4882a593Smuzhiyun     void *context;
79*4882a593Smuzhiyun     wci2_handler_t handler;
80*4882a593Smuzhiyun } wci2_cbs_t;
81*4882a593Smuzhiyun 
82*4882a593Smuzhiyun typedef struct wci2_rxfifo_info {
83*4882a593Smuzhiyun 	char *rx_buf;
84*4882a593Smuzhiyun 	int	rx_idx;
85*4882a593Smuzhiyun 	wci2_cbs_t	*cbs;
86*4882a593Smuzhiyun } wci2_rxfifo_info_t;
87*4882a593Smuzhiyun 
88*4882a593Smuzhiyun #define AI_SLAVE_WRAPPER        0
89*4882a593Smuzhiyun #define AI_MASTER_WRAPPER       1
90*4882a593Smuzhiyun 
91*4882a593Smuzhiyun typedef struct axi_wrapper {
92*4882a593Smuzhiyun 	uint32  mfg;
93*4882a593Smuzhiyun 	uint32  cid;
94*4882a593Smuzhiyun 	uint32  rev;
95*4882a593Smuzhiyun 	uint32  wrapper_type;
96*4882a593Smuzhiyun 	uint32  wrapper_addr;
97*4882a593Smuzhiyun 	uint32  wrapper_size;
98*4882a593Smuzhiyun 	uint32  node_type;
99*4882a593Smuzhiyun } axi_wrapper_t;
100*4882a593Smuzhiyun 
101*4882a593Smuzhiyun #ifdef SOCI_NCI_BUS
102*4882a593Smuzhiyun #define SI_MAX_AXI_WRAPPERS		65u
103*4882a593Smuzhiyun #else
104*4882a593Smuzhiyun #define SI_MAX_AXI_WRAPPERS		32u
105*4882a593Smuzhiyun #endif /* SOCI_NCI_BUS */
106*4882a593Smuzhiyun #define AI_REG_READ_TIMEOUT		300u /* in msec */
107*4882a593Smuzhiyun 
108*4882a593Smuzhiyun /* for some combo chips, BT side accesses chipcommon->0x190, as a 16 byte addr */
109*4882a593Smuzhiyun /* register at 0x19C doesn't exist, so error is logged at the slave wrapper */
110*4882a593Smuzhiyun /* Since this can't be fixed in the boot rom, WAR it */
111*4882a593Smuzhiyun #define BT_CC_SPROM_BADREG_LO   0x18000190
112*4882a593Smuzhiyun #define BT_CC_SPROM_BADREG_SIZE 4
113*4882a593Smuzhiyun #define BT_CC_SPROM_BADREG_HI   0
114*4882a593Smuzhiyun 
115*4882a593Smuzhiyun #define BCM4389_BT_AXI_ID	2
116*4882a593Smuzhiyun #define BCM4388_BT_AXI_ID	2
117*4882a593Smuzhiyun #define BCM4369_BT_AXI_ID	4
118*4882a593Smuzhiyun #define BCM4378_BT_AXI_ID	2
119*4882a593Smuzhiyun #define BCM43602_BT_AXI_ID	1
120*4882a593Smuzhiyun #define BCM4378_ARM_PREFETCH_AXI_ID     9
121*4882a593Smuzhiyun 
122*4882a593Smuzhiyun #define BCM4378_BT_ADDR_HI	0
123*4882a593Smuzhiyun #define BCM4378_BT_ADDR_LO	0x19000000	/* BT address space */
124*4882a593Smuzhiyun #define BCM4378_BT_SIZE		0x01000000	/* BT address space size */
125*4882a593Smuzhiyun #define BCM4378_UNUSED_AXI_ID	0xffffffff
126*4882a593Smuzhiyun #define BCM4378_CC_AXI_ID	0
127*4882a593Smuzhiyun #define BCM4378_PCIE_AXI_ID	1
128*4882a593Smuzhiyun 
129*4882a593Smuzhiyun #define BCM4387_BT_ADDR_HI	0
130*4882a593Smuzhiyun #define BCM4387_BT_ADDR_LO	0x19000000	/* BT address space */
131*4882a593Smuzhiyun #define BCM4387_BT_SIZE		0x01000000	/* BT address space size */
132*4882a593Smuzhiyun #define BCM4387_UNUSED_AXI_ID	0xffffffff
133*4882a593Smuzhiyun #define BCM4387_CC_AXI_ID	0
134*4882a593Smuzhiyun #define BCM4387_PCIE_AXI_ID	1
135*4882a593Smuzhiyun 
136*4882a593Smuzhiyun #define BCM_AXI_ID_MASK	0xFu
137*4882a593Smuzhiyun #define BCM_AXI_ACCESS_TYPE_MASK 0xF0u
138*4882a593Smuzhiyun 
139*4882a593Smuzhiyun #define BCM43xx_CR4_AXI_ID	3
140*4882a593Smuzhiyun #define BCM43xx_AXI_ACCESS_TYPE_PREFETCH (1 << 4)
141*4882a593Smuzhiyun 
142*4882a593Smuzhiyun typedef struct si_cores_info {
143*4882a593Smuzhiyun 	volatile void	*regs[SI_MAXCORES];	/* other regs va */
144*4882a593Smuzhiyun 
145*4882a593Smuzhiyun 	uint	coreid[SI_MAXCORES];	/**< id of each core */
146*4882a593Smuzhiyun 	uint32	coresba[SI_MAXCORES];	/**< backplane address of each core */
147*4882a593Smuzhiyun 	void	*regs2[SI_MAXCORES];	/**< va of each core second register set (usbh20) */
148*4882a593Smuzhiyun 	uint32	coresba2[SI_MAXCORES];	/**< address of each core second register set (usbh20) */
149*4882a593Smuzhiyun 	uint32	coresba_size[SI_MAXCORES]; /**< backplane address space size */
150*4882a593Smuzhiyun 	uint32	coresba2_size[SI_MAXCORES]; /**< second address space size */
151*4882a593Smuzhiyun 
152*4882a593Smuzhiyun 	void	*wrappers[SI_MAXCORES];	/**< other cores wrapper va */
153*4882a593Smuzhiyun 	uint32	wrapba[SI_MAXCORES];	/**< address of controlling wrapper */
154*4882a593Smuzhiyun 
155*4882a593Smuzhiyun 	void	*wrappers2[SI_MAXCORES];	/**< other cores wrapper va */
156*4882a593Smuzhiyun 	uint32	wrapba2[SI_MAXCORES];	/**< address of controlling wrapper */
157*4882a593Smuzhiyun 
158*4882a593Smuzhiyun 	void	*wrappers3[SI_MAXCORES];	/**< other cores wrapper va */
159*4882a593Smuzhiyun 	uint32	wrapba3[SI_MAXCORES];	/**< address of controlling wrapper */
160*4882a593Smuzhiyun 
161*4882a593Smuzhiyun 	uint32	cia[SI_MAXCORES];	/**< erom cia entry for each core */
162*4882a593Smuzhiyun 	uint32	cib[SI_MAXCORES];	/**< erom cia entry for each core */
163*4882a593Smuzhiyun 
164*4882a593Smuzhiyun 	uint32  csp2ba[SI_MAXCORES];		/**< Second slave port base addr 0 */
165*4882a593Smuzhiyun 	uint32  csp2ba_size[SI_MAXCORES];	/**< Second slave port addr space size */
166*4882a593Smuzhiyun } si_cores_info_t;
167*4882a593Smuzhiyun 
168*4882a593Smuzhiyun #define RES_PEND_STATS_COUNT	8
169*4882a593Smuzhiyun 
170*4882a593Smuzhiyun typedef struct res_state_info
171*4882a593Smuzhiyun {
172*4882a593Smuzhiyun 	uint32 low;
173*4882a593Smuzhiyun 	uint32 low_time;
174*4882a593Smuzhiyun 	uint32 high;
175*4882a593Smuzhiyun 	uint32 high_time;
176*4882a593Smuzhiyun } si_res_state_info_t;
177*4882a593Smuzhiyun 
178*4882a593Smuzhiyun /** misc si info needed by some of the routines */
179*4882a593Smuzhiyun typedef struct si_info {
180*4882a593Smuzhiyun 	struct si_pub pub;		/**< back plane public state (must be first field) */
181*4882a593Smuzhiyun 
182*4882a593Smuzhiyun 	void	*osh;			/**< osl os handle */
183*4882a593Smuzhiyun 	void	*sdh;			/**< bcmsdh handle */
184*4882a593Smuzhiyun 
185*4882a593Smuzhiyun 	uint	dev_coreid;		/**< the core provides driver functions */
186*4882a593Smuzhiyun 	void	*intr_arg;		/**< interrupt callback function arg */
187*4882a593Smuzhiyun 	si_intrsoff_t intrsoff_fn;	/**< turns chip interrupts off */
188*4882a593Smuzhiyun 	si_intrsrestore_t intrsrestore_fn; /**< restore chip interrupts */
189*4882a593Smuzhiyun 	si_intrsenabled_t intrsenabled_fn; /**< check if interrupts are enabled */
190*4882a593Smuzhiyun 
191*4882a593Smuzhiyun 	void	*pch;			/**< PCI/E core handle */
192*4882a593Smuzhiyun 
193*4882a593Smuzhiyun 	bool	memseg;			/**< flag to toggle MEM_SEG register */
194*4882a593Smuzhiyun 
195*4882a593Smuzhiyun 	char	*vars;
196*4882a593Smuzhiyun 	uint	varsz;
197*4882a593Smuzhiyun 
198*4882a593Smuzhiyun 	volatile void *curmap;		/* current regs va */
199*4882a593Smuzhiyun 
200*4882a593Smuzhiyun 	uint	curidx;			/**< current core index */
201*4882a593Smuzhiyun 	uint	numcores;		/**< # discovered cores */
202*4882a593Smuzhiyun 
203*4882a593Smuzhiyun 	void	*curwrap;		/**< current wrapper va */
204*4882a593Smuzhiyun 
205*4882a593Smuzhiyun 	uint32	oob_router;		/**< oob router registers for axi */
206*4882a593Smuzhiyun 	uint32	oob_router1;		/**< oob router registers for axi */
207*4882a593Smuzhiyun 
208*4882a593Smuzhiyun 	si_cores_info_t *cores_info;
209*4882a593Smuzhiyun #if !defined(BCMDONGLEHOST)
210*4882a593Smuzhiyun 	/* Store NVRAM data so that it is available after reclaim. */
211*4882a593Smuzhiyun 	uint32 nvram_min_mask;
212*4882a593Smuzhiyun 	bool min_mask_valid;
213*4882a593Smuzhiyun 	uint32 nvram_max_mask;
214*4882a593Smuzhiyun 	bool max_mask_valid;
215*4882a593Smuzhiyun #endif /* !BCMDONGLEHOST */
216*4882a593Smuzhiyun 	gci_gpio_item_t	*gci_gpio_head;	/**< gci gpio interrupts head */
217*4882a593Smuzhiyun 	uint	chipnew;		/**< new chip number */
218*4882a593Smuzhiyun 	uint second_bar0win;		/**< Backplane region */
219*4882a593Smuzhiyun 	uint	num_br;			/**< # discovered bridges */
220*4882a593Smuzhiyun 	uint32	br_wrapba[SI_MAXBR];	/**< address of bridge controlling wrapper */
221*4882a593Smuzhiyun 	uint32	xtalfreq;
222*4882a593Smuzhiyun 	uint32	openloop_dco_code;	/**< OPEN loop calibration dco code */
223*4882a593Smuzhiyun 	uint8	spurmode;
224*4882a593Smuzhiyun 	bool	device_removed;
225*4882a593Smuzhiyun 	uint	axi_num_wrappers;
226*4882a593Smuzhiyun 	axi_wrapper_t *axi_wrapper;
227*4882a593Smuzhiyun 	uint8	device_wake_opt;	/* device_wake GPIO number */
228*4882a593Smuzhiyun 	uint8	lhl_ps_mode;
229*4882a593Smuzhiyun 	uint8	hib_ext_wakeup_enab;
230*4882a593Smuzhiyun 	uint32  armpllclkfreq;             /**< arm clock rate from nvram */
231*4882a593Smuzhiyun 	uint32	ccidiv;			/**< arm clock : cci clock ratio
232*4882a593Smuzhiyun 					 * (determines sysmem frequency)
233*4882a593Smuzhiyun 					 */
234*4882a593Smuzhiyun 	wci2_rxfifo_info_t *wci2_info;	/* wci2_rxfifo interrupt info */
235*4882a593Smuzhiyun 	uint8	slice;			/* this instance of the si accesses
236*4882a593Smuzhiyun 					 * the first(0)/second(1)/...
237*4882a593Smuzhiyun 					 * d11 core
238*4882a593Smuzhiyun 					 */
239*4882a593Smuzhiyun 	si_res_state_info_t res_state[RES_PEND_STATS_COUNT];
240*4882a593Smuzhiyun 	uint32	res_pend_count;
241*4882a593Smuzhiyun 	bool    rfldo3p3_war;		/**< singing cap war enable from nvram */
242*4882a593Smuzhiyun 	void    *nci_info;
243*4882a593Smuzhiyun } si_info_t;
244*4882a593Smuzhiyun 
245*4882a593Smuzhiyun #define	SI_INFO(sih)	((si_info_t *)(uintptr)sih)
246*4882a593Smuzhiyun 
247*4882a593Smuzhiyun #define	GOODCOREADDR(x, b) (((x) >= (b)) && ((x) < ((b) + SI_MAXCORES * SI_CORE_SIZE)) && \
248*4882a593Smuzhiyun 		ISALIGNED((x), SI_CORE_SIZE))
249*4882a593Smuzhiyun #define	GOODREGS(regs)	((regs) != NULL && ISALIGNED((uintptr)(regs), SI_CORE_SIZE))
250*4882a593Smuzhiyun #define BADCOREADDR	0
251*4882a593Smuzhiyun #define	GOODIDX(idx, maxcores)	(((uint)idx) < maxcores)
252*4882a593Smuzhiyun #define	NOREV		(int16)-1		/**< Invalid rev */
253*4882a593Smuzhiyun 
254*4882a593Smuzhiyun #define PCI(si)		((BUSTYPE((si)->pub.bustype) == PCI_BUS) &&	\
255*4882a593Smuzhiyun 			 ((si)->pub.buscoretype == PCI_CORE_ID))
256*4882a593Smuzhiyun 
257*4882a593Smuzhiyun #define PCIE_GEN1(si)	((BUSTYPE((si)->pub.bustype) == PCI_BUS) &&	\
258*4882a593Smuzhiyun 			 ((si)->pub.buscoretype == PCIE_CORE_ID))
259*4882a593Smuzhiyun 
260*4882a593Smuzhiyun #define PCIE_GEN2(si)	((BUSTYPE((si)->pub.bustype) == PCI_BUS) &&	\
261*4882a593Smuzhiyun 			 ((si)->pub.buscoretype == PCIE2_CORE_ID))
262*4882a593Smuzhiyun 
263*4882a593Smuzhiyun #define PCIE(si)	(PCIE_GEN1(si) || PCIE_GEN2(si))
264*4882a593Smuzhiyun 
265*4882a593Smuzhiyun /** Newer chips can access PCI/PCIE and CC core without requiring to change PCI BAR0 WIN */
266*4882a593Smuzhiyun #define SI_FAST(si) (PCIE(si) || (PCI(si) && ((si)->pub.buscorerev >= 13)))
267*4882a593Smuzhiyun 
268*4882a593Smuzhiyun #define CCREGS_FAST(si) \
269*4882a593Smuzhiyun 	(((si)->curmap == NULL) ? NULL : \
270*4882a593Smuzhiyun 	    ((volatile char *)((si)->curmap) + PCI_16KB0_CCREGS_OFFSET))
271*4882a593Smuzhiyun #define PCIEREGS(si) (((volatile char *)((si)->curmap) + PCI_16KB0_PCIREGS_OFFSET))
272*4882a593Smuzhiyun 
273*4882a593Smuzhiyun /*
274*4882a593Smuzhiyun  * Macros to disable/restore function core(D11, ENET, ILINE20, etc) interrupts before/
275*4882a593Smuzhiyun  * after core switching to avoid invalid register accesss inside ISR.
276*4882a593Smuzhiyun  * Adding SOCI_NCI_BUS to avoid abandons in the branches that use this MACRO.
277*4882a593Smuzhiyun  */
278*4882a593Smuzhiyun #ifdef SOCI_NCI_BUS
279*4882a593Smuzhiyun #define INTR_OFF(si, intr_val) \
280*4882a593Smuzhiyun 	if ((si)->intrsoff_fn && (si_coreid(&(si)->pub) == (si)->dev_coreid)) { \
281*4882a593Smuzhiyun 		(*(si)->intrsoff_fn)((si)->intr_arg, intr_val); }
282*4882a593Smuzhiyun #define INTR_RESTORE(si, intr_val) \
283*4882a593Smuzhiyun 	if ((si)->intrsrestore_fn && (si_coreid(&(si)->pub) == (si)->dev_coreid)) { \
284*4882a593Smuzhiyun 		(*(si)->intrsrestore_fn)((si)->intr_arg, intr_val); }
285*4882a593Smuzhiyun #else
286*4882a593Smuzhiyun #define INTR_OFF(si, intr_val) \
287*4882a593Smuzhiyun 	if ((si)->intrsoff_fn && (si)->cores_info->coreid[(si)->curidx] == (si)->dev_coreid) { \
288*4882a593Smuzhiyun 		(*(si)->intrsoff_fn)((si)->intr_arg, intr_val); }
289*4882a593Smuzhiyun #define INTR_RESTORE(si, intr_val) \
290*4882a593Smuzhiyun 	if ((si)->intrsrestore_fn && (si)->cores_info->coreid[(si)->curidx] == (si)->dev_coreid) { \
291*4882a593Smuzhiyun 		(*(si)->intrsrestore_fn)((si)->intr_arg, intr_val); }
292*4882a593Smuzhiyun #endif /* SOCI_NCI_BUS */
293*4882a593Smuzhiyun 
294*4882a593Smuzhiyun /* dynamic clock control defines */
295*4882a593Smuzhiyun #define	LPOMINFREQ		25000		/**< low power oscillator min */
296*4882a593Smuzhiyun #define	LPOMAXFREQ		43000		/**< low power oscillator max */
297*4882a593Smuzhiyun #define	XTALMINFREQ		19800000	/**< 20 MHz - 1% */
298*4882a593Smuzhiyun #define	XTALMAXFREQ		20200000	/**< 20 MHz + 1% */
299*4882a593Smuzhiyun #define	PCIMINFREQ		25000000	/**< 25 MHz */
300*4882a593Smuzhiyun #define	PCIMAXFREQ		34000000	/**< 33 MHz + fudge */
301*4882a593Smuzhiyun 
302*4882a593Smuzhiyun #define	ILP_DIV_5MHZ		0		/**< ILP = 5 MHz */
303*4882a593Smuzhiyun #define	ILP_DIV_1MHZ		4		/**< ILP = 1 MHz */
304*4882a593Smuzhiyun 
305*4882a593Smuzhiyun /* GPIO Based LED powersave defines */
306*4882a593Smuzhiyun #define DEFAULT_GPIO_ONTIME	10		/**< Default: 10% on */
307*4882a593Smuzhiyun #define DEFAULT_GPIO_OFFTIME	90		/**< Default: 10% on */
308*4882a593Smuzhiyun 
309*4882a593Smuzhiyun #ifndef DEFAULT_GPIOTIMERVAL
310*4882a593Smuzhiyun #define DEFAULT_GPIOTIMERVAL  ((DEFAULT_GPIO_ONTIME << GPIO_ONTIME_SHIFT) | DEFAULT_GPIO_OFFTIME)
311*4882a593Smuzhiyun #endif
312*4882a593Smuzhiyun 
313*4882a593Smuzhiyun /* Silicon Backplane externs */
314*4882a593Smuzhiyun extern void sb_scan(si_t *sih, volatile void *regs, uint devid);
315*4882a593Smuzhiyun extern uint sb_coreid(const si_t *sih);
316*4882a593Smuzhiyun extern uint sb_intflag(si_t *sih);
317*4882a593Smuzhiyun extern uint sb_flag(const si_t *sih);
318*4882a593Smuzhiyun extern void sb_setint(const si_t *sih, int siflag);
319*4882a593Smuzhiyun extern uint sb_corevendor(const si_t *sih);
320*4882a593Smuzhiyun extern uint sb_corerev(const si_t *sih);
321*4882a593Smuzhiyun extern uint sb_corereg(si_t *sih, uint coreidx, uint regoff, uint mask, uint val);
322*4882a593Smuzhiyun extern volatile uint32 *sb_corereg_addr(const si_t *sih, uint coreidx, uint regoff);
323*4882a593Smuzhiyun extern bool sb_iscoreup(const si_t *sih);
324*4882a593Smuzhiyun extern volatile void *sb_setcoreidx(si_t *sih, uint coreidx);
325*4882a593Smuzhiyun extern uint32 sb_core_cflags(const si_t *sih, uint32 mask, uint32 val);
326*4882a593Smuzhiyun extern void sb_core_cflags_wo(const si_t *sih, uint32 mask, uint32 val);
327*4882a593Smuzhiyun extern uint32 sb_core_sflags(const si_t *sih, uint32 mask, uint32 val);
328*4882a593Smuzhiyun extern void sb_commit(si_t *sih);
329*4882a593Smuzhiyun extern uint32 sb_base(uint32 admatch);
330*4882a593Smuzhiyun extern uint32 sb_size(uint32 admatch);
331*4882a593Smuzhiyun extern void sb_core_reset(const si_t *sih, uint32 bits, uint32 resetbits);
332*4882a593Smuzhiyun extern void sb_core_disable(const si_t *sih, uint32 bits);
333*4882a593Smuzhiyun extern uint32 sb_addrspace(const si_t *sih, uint asidx);
334*4882a593Smuzhiyun extern uint32 sb_addrspacesize(const si_t *sih, uint asidx);
335*4882a593Smuzhiyun extern int sb_numaddrspaces(const si_t *sih);
336*4882a593Smuzhiyun 
337*4882a593Smuzhiyun extern bool sb_taclear(si_t *sih, bool details);
338*4882a593Smuzhiyun 
339*4882a593Smuzhiyun #ifdef BCMDBG
340*4882a593Smuzhiyun extern void sb_view(si_t *sih, bool verbose);
341*4882a593Smuzhiyun extern void sb_viewall(si_t *sih, bool verbose);
342*4882a593Smuzhiyun #endif
343*4882a593Smuzhiyun #if defined(BCMDBG) || defined(BCMDBG_DUMP)
344*4882a593Smuzhiyun extern void sb_dump(si_t *sih, struct bcmstrbuf *b);
345*4882a593Smuzhiyun #endif
346*4882a593Smuzhiyun #if defined(BCMDBG) || defined(BCMDBG_DUMP)|| defined(BCMDBG_PHYDUMP)
347*4882a593Smuzhiyun extern void sb_dumpregs(si_t *sih, struct bcmstrbuf *b);
348*4882a593Smuzhiyun #endif /* BCMDBG || BCMDBG_DUMP|| BCMDBG_PHYDUMP */
349*4882a593Smuzhiyun 
350*4882a593Smuzhiyun /* AMBA Interconnect exported externs */
351*4882a593Smuzhiyun extern si_t *ai_attach(uint pcidev, osl_t *osh, void *regs, uint bustype,
352*4882a593Smuzhiyun                        void *sdh, char **vars, uint *varsz);
353*4882a593Smuzhiyun extern si_t *ai_kattach(osl_t *osh);
354*4882a593Smuzhiyun extern void ai_scan(si_t *sih, void *regs, uint devid);
355*4882a593Smuzhiyun 
356*4882a593Smuzhiyun extern uint ai_flag(si_t *sih);
357*4882a593Smuzhiyun extern uint ai_flag_alt(const si_t *sih);
358*4882a593Smuzhiyun extern void ai_setint(const si_t *sih, int siflag);
359*4882a593Smuzhiyun extern uint ai_corevendor(const si_t *sih);
360*4882a593Smuzhiyun extern uint ai_corerev(const si_t *sih);
361*4882a593Smuzhiyun extern uint ai_corerev_minor(const si_t *sih);
362*4882a593Smuzhiyun extern volatile uint32 *ai_corereg_addr(si_t *sih, uint coreidx, uint regoff);
363*4882a593Smuzhiyun extern bool ai_iscoreup(const si_t *sih);
364*4882a593Smuzhiyun extern volatile void *ai_setcoreidx(si_t *sih, uint coreidx);
365*4882a593Smuzhiyun extern volatile void *ai_setcoreidx_2ndwrap(si_t *sih, uint coreidx);
366*4882a593Smuzhiyun extern volatile void *ai_setcoreidx_3rdwrap(si_t *sih, uint coreidx);
367*4882a593Smuzhiyun extern uint32 ai_core_cflags(const si_t *sih, uint32 mask, uint32 val);
368*4882a593Smuzhiyun extern void ai_core_cflags_wo(const si_t *sih, uint32 mask, uint32 val);
369*4882a593Smuzhiyun extern uint32 ai_core_sflags(const si_t *sih, uint32 mask, uint32 val);
370*4882a593Smuzhiyun extern uint ai_corereg(si_t *sih, uint coreidx, uint regoff, uint mask, uint val);
371*4882a593Smuzhiyun extern uint ai_corereg_writeonly(si_t *sih, uint coreidx, uint regoff, uint mask, uint val);
372*4882a593Smuzhiyun extern void ai_core_reset(si_t *sih, uint32 bits, uint32 resetbits);
373*4882a593Smuzhiyun extern void ai_d11rsdb_core_reset(si_t *sih, uint32 bits,
374*4882a593Smuzhiyun 	uint32 resetbits, void *p, volatile void *s);
375*4882a593Smuzhiyun extern void ai_core_disable(const si_t *sih, uint32 bits);
376*4882a593Smuzhiyun extern void ai_d11rsdb_core_disable(const si_info_t *sii, uint32 bits,
377*4882a593Smuzhiyun 	aidmp_t *pmacai, aidmp_t *smacai);
378*4882a593Smuzhiyun extern int ai_numaddrspaces(const si_t *sih);
379*4882a593Smuzhiyun extern uint32 ai_addrspace(const si_t *sih, uint spidx, uint baidx);
380*4882a593Smuzhiyun extern uint32 ai_addrspacesize(const si_t *sih, uint spidx, uint baidx);
381*4882a593Smuzhiyun extern void ai_coreaddrspaceX(const si_t *sih, uint asidx, uint32 *addr, uint32 *size);
382*4882a593Smuzhiyun extern uint ai_wrap_reg(const si_t *sih, uint32 offset, uint32 mask, uint32 val);
383*4882a593Smuzhiyun extern void ai_update_backplane_timeouts(const si_t *sih, bool enable, uint32 timeout, uint32 cid);
384*4882a593Smuzhiyun extern uint32 ai_clear_backplane_to(si_t *sih);
385*4882a593Smuzhiyun void ai_force_clocks(const si_t *sih, uint clock_state);
386*4882a593Smuzhiyun extern uint ai_num_slaveports(const si_t *sih, uint coreidx);
387*4882a593Smuzhiyun 
388*4882a593Smuzhiyun #ifdef AXI_TIMEOUTS_NIC
389*4882a593Smuzhiyun uint32 ai_clear_backplane_to_fast(si_t *sih, void * addr);
390*4882a593Smuzhiyun #endif /* AXI_TIMEOUTS_NIC */
391*4882a593Smuzhiyun 
392*4882a593Smuzhiyun #ifdef BOOKER_NIC400_INF
393*4882a593Smuzhiyun extern void ai_core_reset_ext(const si_t *sih, uint32 bits, uint32 resetbits);
394*4882a593Smuzhiyun #endif /* BOOKER_NIC400_INF */
395*4882a593Smuzhiyun 
396*4882a593Smuzhiyun #if defined(AXI_TIMEOUTS) || defined(AXI_TIMEOUTS_NIC)
397*4882a593Smuzhiyun extern uint32 ai_clear_backplane_to_per_core(si_t *sih, uint coreid, uint coreunit, void * wrap);
398*4882a593Smuzhiyun #endif /* AXI_TIMEOUTS || AXI_TIMEOUTS_NIC */
399*4882a593Smuzhiyun 
400*4882a593Smuzhiyun #ifdef BCMDBG
401*4882a593Smuzhiyun extern void ai_view(const si_t *sih, bool verbose);
402*4882a593Smuzhiyun extern void ai_viewall(si_t *sih, bool verbose);
403*4882a593Smuzhiyun #endif
404*4882a593Smuzhiyun #if defined(BCMDBG) || defined(BCMDBG_DUMP)|| defined(BCMDBG_PHYDUMP)
405*4882a593Smuzhiyun extern void ai_dumpregs(const si_t *sih, struct bcmstrbuf *b);
406*4882a593Smuzhiyun #endif /* BCMDBG || BCMDBG_DUMP|| BCMDBG_PHYDUMP */
407*4882a593Smuzhiyun 
408*4882a593Smuzhiyun extern uint32 ai_wrapper_dump_buf_size(const si_t *sih);
409*4882a593Smuzhiyun extern uint32 ai_wrapper_dump_binary(const si_t *sih, uchar *p);
410*4882a593Smuzhiyun extern bool ai_check_enable_backplane_log(const si_t *sih);
411*4882a593Smuzhiyun extern uint32 ai_wrapper_dump_last_timeout(const si_t *sih, uint32 *error, uint32 *core,
412*4882a593Smuzhiyun 	uint32 *ba, uchar *p);
413*4882a593Smuzhiyun extern uint32 ai_findcoreidx_by_axiid(const si_t *sih, uint32 axiid);
414*4882a593Smuzhiyun #if defined(AXI_TIMEOUTS_NIC) || defined(AXI_TIMEOUTS)
415*4882a593Smuzhiyun extern void ai_wrapper_get_last_error(const si_t *sih, uint32 *error_status, uint32 *core,
416*4882a593Smuzhiyun 	uint32 *lo, uint32 *hi, uint32 *id);
417*4882a593Smuzhiyun extern uint32 ai_get_axi_timeout_reg(void);
418*4882a593Smuzhiyun #endif /* (AXI_TIMEOUTS_NIC) || (AXI_TIMEOUTS) */
419*4882a593Smuzhiyun 
420*4882a593Smuzhiyun #ifdef UART_TRAP_DBG
421*4882a593Smuzhiyun void ai_dump_APB_Bridge_registers(const si_t *sih);
422*4882a593Smuzhiyun #endif /* UART_TRAP_DBG */
423*4882a593Smuzhiyun void ai_force_clocks(const si_t *sih, uint clock_state);
424*4882a593Smuzhiyun 
425*4882a593Smuzhiyun #define ub_scan(a, b, c) do {} while (0)
426*4882a593Smuzhiyun #define ub_flag(a) (0)
427*4882a593Smuzhiyun #define ub_setint(a, b) do {} while (0)
428*4882a593Smuzhiyun #define ub_coreidx(a) (0)
429*4882a593Smuzhiyun #define ub_corevendor(a) (0)
430*4882a593Smuzhiyun #define ub_corerev(a) (0)
431*4882a593Smuzhiyun #define ub_iscoreup(a) (0)
432*4882a593Smuzhiyun #define ub_setcoreidx(a, b) (0)
433*4882a593Smuzhiyun #define ub_core_cflags(a, b, c) (0)
434*4882a593Smuzhiyun #define ub_core_cflags_wo(a, b, c) do {} while (0)
435*4882a593Smuzhiyun #define ub_core_sflags(a, b, c) (0)
436*4882a593Smuzhiyun #define ub_corereg(a, b, c, d, e) (0)
437*4882a593Smuzhiyun #define ub_core_reset(a, b, c) do {} while (0)
438*4882a593Smuzhiyun #define ub_core_disable(a, b) do {} while (0)
439*4882a593Smuzhiyun #define ub_numaddrspaces(a) (0)
440*4882a593Smuzhiyun #define ub_addrspace(a, b)  (0)
441*4882a593Smuzhiyun #define ub_addrspacesize(a, b) (0)
442*4882a593Smuzhiyun #define ub_view(a, b) do {} while (0)
443*4882a593Smuzhiyun #define ub_dumpregs(a, b) do {} while (0)
444*4882a593Smuzhiyun 
445*4882a593Smuzhiyun #ifndef SOCI_NCI_BUS
446*4882a593Smuzhiyun #define nci_uninit(a) do {} while (0)
447*4882a593Smuzhiyun #define nci_scan(a) (0)
448*4882a593Smuzhiyun #define nci_dump_erom(a) do {} while (0)
449*4882a593Smuzhiyun #define nci_init(a, b, c) (NULL)
450*4882a593Smuzhiyun #define nci_setcore(a, b, c) (NULL)
451*4882a593Smuzhiyun #define nci_setcoreidx(a, b) (NULL)
452*4882a593Smuzhiyun #define nci_findcoreidx(a, b, c) (0)
453*4882a593Smuzhiyun #define nci_corereg_addr(a, b, c) (NULL)
454*4882a593Smuzhiyun #define nci_corereg_writeonly(a, b, c, d, e) (0)
455*4882a593Smuzhiyun #define nci_corereg(a, b, c, d, e) (0)
456*4882a593Smuzhiyun #define nci_corerev_minor(a) (0)
457*4882a593Smuzhiyun #define nci_corerev(a) (0)
458*4882a593Smuzhiyun #define nci_corevendor(a) (0)
459*4882a593Smuzhiyun #define nci_get_wrap_reg(a, b, c, d) (0)
460*4882a593Smuzhiyun #define nci_core_reset(a, b, c) do {} while (0)
461*4882a593Smuzhiyun #define nci_core_disable(a, b) do {} while (0)
462*4882a593Smuzhiyun #define nci_iscoreup(a) (FALSE)
463*4882a593Smuzhiyun #define nci_coreid(a, b) (0)
464*4882a593Smuzhiyun #define nci_numcoreunits(a, b) (0)
465*4882a593Smuzhiyun #define nci_addr_space(a, b, c) (0)
466*4882a593Smuzhiyun #define nci_addr_space_size(a, b, c) (0)
467*4882a593Smuzhiyun #define nci_iscoreup(a) (FALSE)
468*4882a593Smuzhiyun #define nci_intflag(a) (0)
469*4882a593Smuzhiyun #define nci_flag(a) (0)
470*4882a593Smuzhiyun #define nci_flag_alt(a) (0)
471*4882a593Smuzhiyun #define nci_setint(a, b) do {} while (0)
472*4882a593Smuzhiyun #define nci_oobr_baseaddr(a, b) (0)
473*4882a593Smuzhiyun #define nci_coreunit(a) (0)
474*4882a593Smuzhiyun #define nci_corelist(a, b) (0)
475*4882a593Smuzhiyun #define nci_numaddrspaces(a) (0)
476*4882a593Smuzhiyun #define nci_addrspace(a, b, c) (0)
477*4882a593Smuzhiyun #define nci_addrspacesize(a, b, c) (0)
478*4882a593Smuzhiyun #define nci_coreaddrspaceX(a, b, c, d) do {} while (0)
479*4882a593Smuzhiyun #define nci_core_cflags(a, b, c) (0)
480*4882a593Smuzhiyun #define nci_core_cflags_wo(a, b, c) do {} while (0)
481*4882a593Smuzhiyun #define nci_core_sflags(a, b, c) (0)
482*4882a593Smuzhiyun #define nci_wrapperreg(a, b, c, d) (0)
483*4882a593Smuzhiyun #define nci_invalidate_second_bar0win(a) do {} while (0)
484*4882a593Smuzhiyun #define nci_backplane_access(a, b, c, d, e) (0)
485*4882a593Smuzhiyun #define nci_backplane_access_64(a, b, c, d, e) (0)
486*4882a593Smuzhiyun #define nci_num_slaveports(a, b) (0)
487*4882a593Smuzhiyun #if defined(BCMDBG) || defined(BCMDBG_DUMP) || defined(BCMDBG_PHYDUMP)
488*4882a593Smuzhiyun #define nci_dumpregs(a, b) do {} while (0)
489*4882a593Smuzhiyun #endif  /* BCMDBG || BCMDBG_DUMP || BCMDBG_PHYDUMP */
490*4882a593Smuzhiyun #ifdef BCMDBG
491*4882a593Smuzhiyun #define nci_view(a, b) do {} while (0)
492*4882a593Smuzhiyun #define nci_viewall(a, b) do {} while (0)
493*4882a593Smuzhiyun #endif /* BCMDBG */
494*4882a593Smuzhiyun #define nci_get_nth_wrapper(a, b) (0)
495*4882a593Smuzhiyun #define nci_get_axi_addr(a, b) (0)
496*4882a593Smuzhiyun #define nci_wrapper_dump_binary_one(a, b, c) (NULL)
497*4882a593Smuzhiyun #define nci_wrapper_dump_binary(a, b) (0)
498*4882a593Smuzhiyun #define nci_wrapper_dump_last_timeout(a, b, c, d, e) (0)
499*4882a593Smuzhiyun #define nci_check_enable_backplane_log(a) (FALSE)
500*4882a593Smuzhiyun #define nci_get_core_baaddr(a, b, c) (0)
501*4882a593Smuzhiyun #define nci_clear_backplane_to(a) (0)
502*4882a593Smuzhiyun #define nci_clear_backplane_to_per_core(a, b, c, d) (0)
503*4882a593Smuzhiyun #define nci_ignore_errlog(a, b, c, d, e, f) (FALSE)
504*4882a593Smuzhiyun #define nci_wrapper_get_last_error(a, b, c, d, e, f) do {} while (0)
505*4882a593Smuzhiyun #define nci_get_axi_timeout_reg() (0)
506*4882a593Smuzhiyun #define nci_findcoreidx_by_axiid(a, b) (0)
507*4882a593Smuzhiyun #define nci_wrapper_dump_binary_one(a, b, c) (NULL)
508*4882a593Smuzhiyun #define nci_wrapper_dump_binary(a, b) (0)
509*4882a593Smuzhiyun #define nci_wrapper_dump_last_timeout(a, b, c, d, e) (0)
510*4882a593Smuzhiyun #define nci_check_enable_backplane_log(a) (FALSE)
511*4882a593Smuzhiyun #define nci_wrapper_dump_buf_size(a) (0)
512*4882a593Smuzhiyun #endif /* SOCI_NCI_BUS */
513*4882a593Smuzhiyun #endif	/* _siutils_priv_h_ */
514