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 26 #ifdef __cplusplus 27 extern "C" { 28 #endif 29 30 /* 31 * This struct encodes enough information to later be used to compose and 32 * decompose a fabric ID and component ID. A fabric ID is broken into its node 33 * and component IDs and then a node ID is further decomposed into a socket and 34 * die ID. 35 */ 36 typedef struct { 37 uint32_t dfd_sock_mask; 38 uint32_t dfd_die_mask; 39 uint32_t dfd_node_mask; 40 uint32_t dfd_comp_mask; 41 uint8_t dfd_sock_shift; 42 uint8_t dfd_die_shift; 43 uint8_t dfd_node_shift; 44 uint8_t dfd_comp_shift; 45 } df_fabric_decomp_t; 46 47 extern uint_t amdzen_c_df_count(void); 48 extern df_rev_t amdzen_c_df_rev(void); 49 extern int amdzen_c_df_fabric_decomp(df_fabric_decomp_t *); 50 51 /* 52 * SMN and DF access routines. 53 */ 54 extern int amdzen_c_smn_read32(uint_t, uint32_t, uint32_t *); 55 extern int amdzen_c_smn_write32(uint_t, uint32_t, uint32_t); 56 extern int amdzen_c_df_read32(uint_t, uint8_t, const df_reg_def_t, uint32_t *); 57 extern int amdzen_c_df_read64(uint_t, uint8_t, const df_reg_def_t, uint64_t *); 58 59 /* 60 * The following are logical types that we can iterate over. Note, that these 61 * are a combination of a DF type and subtype. This is used to smooth over the 62 * differences between different DF revisions and how they indicate these types. 63 */ 64 typedef enum { 65 /* 66 * Iterate over only DDR memory controllers. 67 */ 68 ZEN_DF_TYPE_CS_UMC, 69 /* 70 * Iterate only over CPU based CCMs. 71 */ 72 ZEN_DF_TYPE_CCM_CPU 73 } zen_df_type_t; 74 75 typedef int (*amdzen_c_iter_f)(uint_t, uint32_t, uint32_t, void *); 76 extern int amdzen_c_df_iter(uint_t, zen_df_type_t, amdzen_c_iter_f, void *); 77 78 #ifdef __cplusplus 79 } 80 #endif 81 82 #endif /* _AMDZEN_CLIENT_H */ 83