blob: d7e2edbb74b35aaa792e454c520e97361adfe09b [file] [log] [blame]
Robert Mustacchi047043c2020-04-08 21:35:09 -07001/*
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/*
Robert Mustacchi71815ce2022-02-28 09:46:53 +000013 * Copyright 2022 Oxide Computer Company
Robert Mustacchi047043c2020-04-08 21:35:09 -070014 */
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>
Robert Mustacchi71815ce2022-02-28 09:46:53 +000024#include <sys/amdzen/df.h>
Keith M Wesolowskiba215ef2022-07-21 06:57:54 -070025#include <sys/amdzen/smn.h>
Robert Mustacchi047043c2020-04-08 21:35:09 -070026
27#ifdef __cplusplus
28extern "C" {
29#endif
30
Robert Mustacchi71815ce2022-02-28 09:46:53 +000031/*
Robert Mustacchi71815ce2022-02-28 09:46:53 +000032 * 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 */
37typedef 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
Robert Mustacchi71815ce2022-02-28 09:46:53 +000048extern uint_t amdzen_c_df_count(void);
49extern df_rev_t amdzen_c_df_rev(void);
50extern int amdzen_c_df_fabric_decomp(df_fabric_decomp_t *);
51
52/*
53 * SMN and DF access routines.
54 */
Keith M Wesolowski4adf43b2022-11-09 07:00:30 +000055extern int amdzen_c_smn_read(uint_t, const smn_reg_t, uint32_t *);
56extern int amdzen_c_smn_write(uint_t, const smn_reg_t, const uint32_t);
Robert Mustacchi71815ce2022-02-28 09:46:53 +000057extern int amdzen_c_df_read32(uint_t, uint8_t, const df_reg_def_t, uint32_t *);
58extern 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 */
65typedef 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
76typedef int (*amdzen_c_iter_f)(uint_t, uint32_t, uint32_t, void *);
77extern int amdzen_c_df_iter(uint_t, zen_df_type_t, amdzen_c_iter_f, void *);
Robert Mustacchi047043c2020-04-08 21:35:09 -070078
79#ifdef __cplusplus
80}
81#endif
82
83#endif /* _AMDZEN_CLIENT_H */