xref: /illumos-gate/usr/src/uts/intel/io/amdzen/amdzen_client.h (revision 20a7641f9918de8574b8b3b47dbe35c4bfc78df1)
1 /*
2  * This file and its contents are supplied under the terms of the
3  * Common Development and Distribution License ("CDDL"), version 1.0.
4  * You may only use this file in accordance with the terms of version
5  * 1.0 of the CDDL.
6  *
7  * A full copy of the text of the CDDL should have accompanied this
8  * source.  A copy of the CDDL is also available via the Internet at
9  * http://www.illumos.org/license/CDDL.
10  */
11 
12 /*
13  * Copyright 2022 Oxide Computer Company
14  */
15 
16 #ifndef _AMDZEN_CLIENT_H
17 #define	_AMDZEN_CLIENT_H
18 
19 /*
20  * This header provides client routines to clients of the amdzen nexus driver.
21  */
22 
23 #include <sys/types.h>
24 #include <sys/amdzen/df.h>
25 #include <sys/amdzen/smn.h>
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
31 /*
32  * This struct encodes enough information to later be used to compose and
33  * decompose a fabric ID and component ID. A fabric ID is broken into its node
34  * and component IDs and then a node ID is further decomposed into a socket and
35  * die ID.
36  */
37 typedef struct {
38 	uint32_t	dfd_sock_mask;
39 	uint32_t	dfd_die_mask;
40 	uint32_t	dfd_node_mask;
41 	uint32_t	dfd_comp_mask;
42 	uint8_t		dfd_sock_shift;
43 	uint8_t		dfd_die_shift;
44 	uint8_t		dfd_node_shift;
45 	uint8_t		dfd_comp_shift;
46 } df_fabric_decomp_t;
47 
48 extern uint_t amdzen_c_df_count(void);
49 extern df_rev_t amdzen_c_df_rev(void);
50 extern int amdzen_c_df_fabric_decomp(df_fabric_decomp_t *);
51 
52 /*
53  * SMN and DF access routines.
54  */
55 extern int amdzen_c_smn_read(uint_t, const smn_reg_t, uint32_t *);
56 extern int amdzen_c_smn_write(uint_t, const smn_reg_t, const uint32_t);
57 extern int amdzen_c_df_read32(uint_t, uint8_t, const df_reg_def_t, uint32_t *);
58 extern int amdzen_c_df_read64(uint_t, uint8_t, const df_reg_def_t, uint64_t *);
59 
60 /*
61  * The following are logical types that we can iterate over. Note, that these
62  * are a combination of a DF type and subtype. This is used to smooth over the
63  * differences between different DF revisions and how they indicate these types.
64  */
65 typedef enum {
66 	/*
67 	 * Iterate over only DDR memory controllers.
68 	 */
69 	ZEN_DF_TYPE_CS_UMC,
70 	/*
71 	 * Iterate only over CPU based CCMs.
72 	 */
73 	ZEN_DF_TYPE_CCM_CPU
74 } zen_df_type_t;
75 
76 typedef int (*amdzen_c_iter_f)(uint_t, uint32_t, uint32_t, void *);
77 extern int amdzen_c_df_iter(uint_t, zen_df_type_t, amdzen_c_iter_f, void *);
78 
79 #ifdef __cplusplus
80 }
81 #endif
82 
83 #endif /* _AMDZEN_CLIENT_H */
84