• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 /* VR Settings for each domain */
4 
5 #ifndef _SOC_VR_CONFIG_H_
6 #define _SOC_VR_CONFIG_H_
7 
8 #include <fsp/api.h>
9 
10 struct vr_config {
11 #if CONFIG(SOC_INTEL_RAPTORLAKE) || CONFIG(FSP_USE_REPO)
12 	/*
13 	 * When enabled, this feature makes the SoC throttle when the power
14 	 * consumption exceeds the I_TRIP threshold.
15 	 *
16 	 * FSPs sets a by default I_TRIP threshold adapted to the current SoC
17 	 * and assuming a Voltage Regulator error accuracy of 6.5%.
18 	 */
19 	bool enable_fast_vmode;
20 
21 	/*
22 	 * VR Fast Vmode I_TRIP threshold.
23 	 * 0-255A in 1/4 A units. Example: 400 = 100A
24 
25 	 * This setting overrides the default value set by FSPs when Fast VMode
26 	 * is enabled.
27 	 */
28 	uint16_t fast_vmode_i_trip;
29 #endif
30 
31 	/* The below settings will take effect when this is set to 1 for that domain. */
32 	bool vr_config_enable;
33 
34 	/* AC and DC Loadline.
35 	   They are in 1/100 mOhms (ie. 1250 = 12.50 mOhms) and range is 0-6249. */
36 	uint16_t ac_loadline;
37 	uint16_t dc_loadline;
38 
39 	/* VR Icc Max limit.
40 	   Range is from 0-255A in 1/4 A units (400 = 100A). */
41 	uint16_t icc_max;
42 
43 	/* Thermal Design Current time window.
44 	   Defined in milli seconds and range 1ms to 448s. */
45 	uint32_t tdc_timewindow;
46 
47 	/* Thermal Design Current current limit.
48 	   Defined in 1/8A units and range is 0-4095. 1000 = 125A. */
49 	uint16_t tdc_currentlimit;
50 
51 	/* Power State 1/2/3 Threshold Current.
52 	   Defined in 1/4A units and range is 0-128A */
53 	uint16_t psi1threshold;
54 	uint16_t psi2threshold;
55 	uint16_t psi3threshold;
56 };
57 
58 #define VR_CFG_AMP(i) (uint16_t)((i) * 4)
59 #define VR_CFG_MOHMS(i) (uint16_t)((i) * 100)
60 #define VR_CFG_TDC_AMP(i) (uint16_t)((i) * 8)
61 
62 /* VrConfig Settings for 4 domains
63  * 0 = IA core, 1 = GT
64  */
65 enum vr_domain {
66 	VR_DOMAIN_IA,
67 	VR_DOMAIN_GT,
68 	NUM_VR_DOMAINS
69 };
70 
71 #define VR_CFG_ALL_DOMAINS_LOADLINE(ia, gt)		\
72 	{						\
73 		[VR_DOMAIN_IA] = VR_CFG_MOHMS(ia),	\
74 		[VR_DOMAIN_GT] = VR_CFG_MOHMS(gt),	\
75 	}
76 
77 #define VR_CFG_ALL_DOMAINS_ICC(ia, gt)			\
78 	{						\
79 		[VR_DOMAIN_IA] = VR_CFG_AMP(ia),	\
80 		[VR_DOMAIN_GT] = VR_CFG_AMP(gt),	\
81 	}
82 
83 #define VR_CFG_ALL_DOMAINS_TDC(ia, gt)	\
84 	{				\
85 		[VR_DOMAIN_IA] = ia,	\
86 		[VR_DOMAIN_GT] = gt,	\
87 	}
88 
89 #define VR_CFG_ALL_DOMAINS_TDC_CURRENT(ia, gt)		\
90 	{						\
91 		[VR_DOMAIN_IA] = VR_CFG_TDC_AMP(ia),	\
92 		[VR_DOMAIN_GT] = VR_CFG_TDC_AMP(gt),	\
93 	}
94 
95 void fill_vr_domain_config(FSP_S_CONFIG *s_cfg, int domain, const struct vr_config *cfg);
96 #endif
97