xref: /titanic_44/usr/src/uts/sun4u/serengeti/sys/sbdp_priv.h (revision 4a634bb80136cc001d14ab96addd9915105e5223)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _SBDP_PRIV_H
28 #define	_SBDP_PRIV_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 #include <sys/sbd.h>
37 #include <sys/sbdp_mbox.h>
38 #include <sys/conf.h>
39 #include <sys/ddi_impldefs.h>
40 #include <sys/serengeti.h>
41 
42 #ifdef DEBUG
43 #define	SBDPDBG_STATE	0x00000001
44 #define	SBDPDBG_QR	0x00000002
45 #define	SBDPDBG_CPU	0x00000004
46 #define	SBDPDBG_MEM	0x00000008
47 #define	SBDPDBG_IO	0x00000010
48 #define	SBDPDBG_MBOX	0x00000020
49 #define	SBDPDBG_ERR	0x00000040
50 #define	SBDPDBG_MISC	0x00000080
51 #define	SBDPDBG_FUNC	0x00000100
52 
53 extern uint_t sbdp_debug;
54 
55 #define	SBDP_DBG_ALL	if (sbdp_debug)				prom_printf
56 #define	SBDP_DBG_STATE	if (sbdp_debug & SBDPDBG_STATE)		prom_printf
57 #define	SBDP_DBG_QR	if (sbdp_debug & SBDPDBG_QR)		prom_printf
58 #define	SBDP_DBG_CPU	if (sbdp_debug & SBDPDBG_CPU)		prom_printf
59 #define	SBDP_DBG_MEM	if (sbdp_debug & SBDPDBG_MEM)		prom_printf
60 #define	SBDP_DBG_IO	if (sbdp_debug & SBDPDBG_IO)		prom_printf
61 #define	SBDP_DBG_MBOX	if (sbdp_debug & SBDPDBG_MBOX)		prom_printf
62 #define	SBDP_DBG_ERR	if (sbdp_debug & SBDPDBG_ERR)		prom_printf
63 #define	SBDP_DBG_MISC	if (sbdp_debug & SBDPDBG_MISC)		prom_printf
64 #define	SBDP_DBG_FUNC	if (sbdp_debug & SBDPDBG_FUNC)		prom_printf
65 
66 #else /* DEBUG */
67 
68 #define	SBDP_DBG_ALL
69 #define	SBDP_DBG_STATE
70 #define	SBDP_DBG_QR
71 #define	SBDP_DBG_CPU
72 #define	SBDP_DBG_MEM
73 #define	SBDP_DBG_IO
74 #define	SBDP_DBG_MBOX
75 #define	SBDP_DBG_ERR
76 #define	SBDP_DBG_MISC
77 #define	SBDP_DBG_FUNC
78 #endif /* DEBUG */
79 
80 #define	PORTID_BAD	-1
81 #define	OBP_PORTID	"portid"
82 #define	SBDP_MAX_BOARDS  plat_max_boards()
83 #define	SBDP_MAX_MEM_NODES_PER_BOARD	4
84 #define	SBDP_MAX_NODES	32
85 #define	SBDP_MAX_WNODES	16
86 
87 /*
88  * CPU present macros
89  */
90 #define	SBDP_SET_CPU_PRESENT(bdp, unit)\
91 			((bdp)->cpus_present |= (1 << (unit)))
92 
93 #define	SBDP_IS_CPU_PRESENT(bdp, unit)\
94 			(((bdp)->cpus_present & (1 << (unit))) != 0)
95 
96 /*
97  * CPU reset macros
98  */
99 #define	SBDP_SET_CPU_IN_RESET(bdp, unit)\
100 			((bdp)->cpus_in_reset |= (1 << (unit)))
101 #define	SBDP_UNSET_CPU_IN_RESET(bdp, unit)\
102 			((bdp)->cpus_in_reset &= ~(1 << (unit)))
103 #define	SBDP_IS_CPU_IN_RESET(bdp, unit)\
104 			(((bdp)->cpus_in_reset & (1 << (unit))) != 0)
105 #define	SBDP_SET_ALL_CPUS_IN_RESET(bdp)\
106 			((bdp)->cpus_in_reset |= 0xf)
107 #define	SBDP_UNSET_ALL_CPUS_IN_RESET(bdp)\
108 			((bdp)->cpus_in_reset = 0x0)
109 #define	SBDP_ALL_CPUS	-1
110 
111 /*
112  * These definitions come from the SC. Should the SC change them
113  * then we need to changed them
114  */
115 #define	SBDP_DIAG_OFF		0x00
116 #define	SBDP_DIAG_INIT		0x07
117 #define	SBDP_DIAG_QUICK		0x10
118 #define	SBDP_DIAG_MIN		0x20
119 #define	SBDP_DIAG_DEFAULT	0x40
120 #define	SBDP_DIAG_MEM1		0x60
121 #define	SBDP_DIAG_MEM2		0x7f
122 #define	SBDP_DIAG_NVCI		0xffff	/* Use stored value in nvci */
123 
124 int		*slices;
125 
126 #define	SBDP_INIT_PLATOPTS	(uint_t)-1
127 #define	SBDP_PLATFORM_OPTS(s_platopts)  ((s_platopts) = SBDP_INIT_PLATOPTS, \
128 		SBD_SET_PLATOPTS(SBD_CMD_TEST, (s_platopts)), \
129 		SBD_SET_PLATOPTS(SBD_CMD_PASSTHRU, (s_platopts)))
130 
131 typedef struct sbdp_bank {
132 	int			id;
133 	ushort_t		valid;
134 	ushort_t		uk;
135 	uint_t			um;
136 	uchar_t			lk;
137 	uchar_t			lm;
138 	struct sbdp_bank	*bd_next;	/* in the board */
139 	struct sbdp_bank	*seg_next;	/* in the segment */
140 } sbdp_bank_t;
141 
142 typedef struct sbdp_segs {
143 	int			id;
144 	int			intlv;	/* interleave for this segment */
145 	uint64_t		base;	/* base address for this segment */
146 	uint64_t		size;	/* size of this segment */
147 	int			nbanks;	/* number of banks in this segment */
148 	sbdp_bank_t		*banks;	/* pointer to the banks of this seg */
149 	struct sbdp_segs	*next;
150 } sbdp_seg_t;
151 
152 typedef struct {
153 	int		bd;
154 	int		wnode;
155 	uint64_t	bpa;	/* base physical addr for this board */
156 	int		nnum;	/* number of nodes */
157 	struct memlist	*ml;	/* memlist for this board */
158 	pnode_t		nodes[SBDP_MAX_MEM_NODES_PER_BOARD];
159 	kmutex_t	bd_mutex; /* mutex for this board */
160 	show_board_t	*bd_sc;	/* info obtained from the SC */
161 	int		valid_cp; /* Is this a valid copy of show_board */
162 	sbdp_bank_t	*banks;	/* Banks for this board */
163 	int		cpus_in_reset;
164 	int		cpus_present;
165 } sbdp_bd_t;
166 
167 typedef struct sbdp_wnode {
168 	int			wnode;	/* wildcat node */
169 	int			nbds;	/* number of bds for this node */
170 	sbdp_bd_t		*bds;	/* pointer to the list of bds */
171 	struct sbdp_wnode	*next;	/* ptr to nex wnode */
172 	struct sbdp_wnode	*prev;	/* ptr to prev node */
173 } sbdp_wnode_t;
174 
175 typedef struct {
176 	uint_t  regspec_addr_hi;
177 	uint_t  regspec_addr_lo;
178 	uint_t  regspec_size_hi;
179 	uint_t  regspec_size_lo;
180 } regspace_t;
181 
182 /*
183  * Suspend states used internally by sbdp_suspend and
184  * sbdp_resume
185  */
186 typedef enum sbd_suspend_state {
187 	SBDP_SRSTATE_BEGIN = 0,
188 	SBDP_SRSTATE_USER,
189 	SBDP_SRSTATE_DRIVER,
190 	SBDP_SRSTATE_FULL
191 } suspend_state_t;
192 
193 /*
194  * specific suspend/resume interface handle
195  */
196 typedef struct {
197 	sbd_error_t		sep;
198 	dev_info_t		*sr_failed_dip;
199 	suspend_state_t		sr_suspend_state;
200 	uint_t			sr_flags;
201 	uint_t			sh_ndi;
202 } sbdp_sr_handle_t;
203 
204 typedef struct sbdp_shutdown {
205 	uint64_t	estack;
206 	uint64_t	flushaddr;
207 	uint32_t	size;
208 	uint32_t	linesize;
209 	uint64_t	physaddr;
210 } sbdp_shutdown_t;
211 
212 extern int plat_max_boards();
213 
214 typedef struct {
215 	int		node;		/* wildcat node */
216 	int		board;
217 	pnode_t		nodes[SBDP_MAX_NODES];
218 	int		num_of_nodes;
219 	int		flags;
220 	int		error;
221 	dev_info_t	*top_node;
222 	char		*errstr;
223 } attach_pkt_t;
224 
225 extern uint64_t *sbdp_valp;
226 
227 sbdp_sr_handle_t *sbdp_get_sr_handle(void);
228 void sbdp_release_sr_handle(sbdp_sr_handle_t *);
229 int sbdp_suspend(sbdp_sr_handle_t *);
230 void sbdp_resume(sbdp_sr_handle_t *);
231 void sbdp_set_err(sbd_error_t *ep, int ecode, char *rsc);
232 int sbdp_is_node_bad(pnode_t);
233 void sbdp_walk_prom_tree(pnode_t, int(*)(pnode_t, void *, uint_t), void *);
234 int sbdp_detach_bd(int node, int board, sbd_error_t *sep);
235 void sbdp_attach_bd(int, int);
236 int sbdp_get_bd_and_wnode_num(pnode_t, int *, int *);
237 void sbdp_update_bd_info(sbdp_bd_t *);
238 sbdp_bd_t *sbdp_get_bd_info(int, int);
239 int sbdp_make_bd_mem_contigous(int);
240 sbd_cond_t sbdp_get_comp_status(pnode_t);
241 void sbdp_init_bd_banks(sbdp_bd_t *);
242 void sbdp_swap_list_of_banks(sbdp_bd_t *, sbdp_bd_t *);
243 void sbdp_fini_bd_banks(sbdp_bd_t *);
244 void sbdp_print_bd_banks(sbdp_bd_t *);
245 void sbdp_add_new_bd_info(int, int);
246 void sbdp_cleanup_bd(int, int);
247 void sbdp_cpu_in_reset(int, int, int, int);
248 int sbdp_is_cpu_in_reset(int, int, int);
249 int sbdp_set_cpu_present(int, int, int);
250 int sbdp_is_cpu_present(int, int, int);
251 int sbdp_swap_slices(int, int);
252 #ifdef DEBUG
253 void sbdp_print_all_segs(void);
254 int sbdp_passthru_test_quiesce(sbdp_handle_t *hp, void *);
255 #endif
256 int sbdp_select_top_nodes(pnode_t, void *, uint_t);
257 pnode_t sbdp_find_nearby_cpu_by_portid(pnode_t, processorid_t);
258 int sbdp_board_non_panther_cpus(int, int);
259 
260 #ifdef	__cplusplus
261 }
262 #endif
263 
264 #endif	/* _SBDP_PRIV_H */
265