blob: 4c43b1fdffddbf864e2ed62d18dd16cd68714cae [file] [log] [blame]
Angel Ponsae593872020-04-04 18:50:57 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Martin Roth5c354b92019-04-22 14:55:16 -06002
Martin Roth5f672632019-04-22 16:04:13 -06003#ifndef __PICASSO_CHIP_H__
4#define __PICASSO_CHIP_H__
Martin Roth5c354b92019-04-22 14:55:16 -06005
Furquan Shaikh033aa0d2020-05-09 14:26:37 -07006#include <amdblocks/chip.h>
Martin Roth5c354b92019-04-22 14:55:16 -06007#include <commonlib/helpers.h>
8#include <drivers/i2c/designware/dw_i2c.h>
9#include <soc/i2c.h>
Martin Roth7e78e562019-11-03 23:29:02 -070010#include <soc/iomap.h>
Furquan Shaikh69c28112020-04-28 18:57:52 -070011#include <soc/southbridge.h>
Martin Rothc7acf162020-05-28 00:44:50 -060012#include <arch/x86/include/arch/smp/mpspec.h> /* point from top level */
Felix Held78903802021-04-20 22:37:35 +020013#include <types.h>
Martin Roth5c354b92019-04-22 14:55:16 -060014
Chris Wang04dfc262020-05-19 14:46:35 +080015/*
16 USB 2.0 PHY Parameters
17*/
Felix Held0b5a6142020-07-23 19:37:17 +020018struct __packed usb2_phy_tune {
Chris Wang04dfc262020-05-19 14:46:35 +080019 /* Disconnect Threshold Adjustment. Range 0 - 0x7 */
20 uint8_t com_pds_tune;
21 /* Squelch Threshold Adjustment. Range 0 - 0x7 */
22 uint8_t sq_rx_tune;
23 /* FS/LS Source Impedance Adjustment. Range 0 - 0xF */
24 uint8_t tx_fsls_tune;
25 /* HS Transmitter Pre-Emphasis Curent Control. Range 0 - 0x3 */
26 uint8_t tx_pre_emp_amp_tune;
27 /* HS Transmitter Pre-Emphasis Duration Control. Range: 0 - 0x1 */
28 uint8_t tx_pre_emp_pulse_tune;
29 /* HS Transmitter Rise/Fall Time Adjustment. Range: 0 - 0x3 */
30 uint8_t tx_rise_tune;
31 /* HS DC Voltage Level Adjustment. Range 0 - 0xF */
Kevin Chiude20b282020-11-19 14:09:47 +080032 uint8_t tx_vref_tune;
Chris Wang04dfc262020-05-19 14:46:35 +080033 /* Transmitter High-Speed Crossover Adjustment. Range 0 - 0x3 */
34 uint8_t tx_hsxv_tune;
35 /* USB Source Impedance Adjustment. Range 0 - 0x3. */
36 uint8_t tx_res_tune;
37};
38
Chris Wang3f929022020-09-14 17:03:06 +080039/* force USB3 port to gen1, bit0 - controller0 Port0, bit1 - Port1, etc */
40union __packed usb3_force_gen1 {
41 struct {
42 uint8_t xhci0_port0:1;
43 uint8_t xhci0_port1:1;
44 uint8_t xhci0_port2:1;
45 uint8_t xhci0_port3:1;
46 } ports;
47 uint8_t usb3_port_force_gen1_en;
48};
49
Chris Wangad4f6d72021-01-26 20:09:34 +080050enum rfmux_configuration_setting {
51 USB_PD_RFMUX_SAFE_STATE = 0x0,
52 USB_PD_RFMUX_USB31_MODE = 0x1,
53 USB_PD_RFMUX_USB31_MODE_FLIP = 0x2,
54 USB_PD_RFMUX_ATE_MODE = 0x3,
55 USB_PD_RFMUX_DP_X2_MODE = 0x4,
56 USB_PD_RFMUX_MF_MODE_ALT_D_F = 0x6,
57 USB_PD_RFMUX_DP_X2_MODE_FLIP = 0x8,
58 USB_PD_RFMUX_MF_MODE_ALT_D_F_FLIP = 0x9,
59 USB_PD_RFMUX_DP_X4_MODE = 0xc,
60};
61
62struct usb_pd_control {
63 uint8_t rfmux_override_en;
64 uint32_t rfmux_config;
65};
66
Felix Held3a7389e2020-07-23 18:22:30 +020067#define USB_PORT_COUNT 6
Chris Wang68d68f12021-02-03 04:32:06 +080068
69struct __packed usb3_phy_tune {
70 uint8_t rx_eq_delta_iq_ovrd_val;
71 uint8_t rx_eq_delta_iq_ovrd_en;
72};
73/* the RV2 USB3 port count */
74#define RV2_USB3_PORT_COUNT 4
Chris Wangad4f6d72021-01-26 20:09:34 +080075#define USB_PD_PORT_COUNT 2
Felix Held3a7389e2020-07-23 18:22:30 +020076
Raul E Rangel5590d9a2020-09-03 15:41:58 -060077enum sd_emmc_driver_strength {
78 SD_EMMC_DRIVE_STRENGTH_B,
79 SD_EMMC_DRIVE_STRENGTH_A,
80 SD_EMMC_DRIVE_STRENGTH_C,
81 SD_EMMC_DRIVE_STRENGTH_D,
82};
83
Chris Wang4e66d932020-12-18 14:58:56 +080084/* dpphy_override */
85enum sysinfo_dpphy_override {
86 ENABLE_DVI_TUNINGSET = 0x01,
87 ENABLE_HDMI_TUNINGSET = 0x02,
88 ENABLE_HDMI6G_TUNINGSET = 0x04,
89 ENABLE_DP_TUNINGSET = 0x08,
90 ENABLE_DP_HBR3_TUNINGSET = 0x10,
91 ENABLE_DP_HBR_TUNINGSET = 0x20,
92 ENABLE_DP_HBR2_TUNINGSET = 0x40,
93 ENABLE_EDP_TUNINGSET = 0x80,
94};
95
Marshall Dawsonbc4c9032019-06-11 12:18:20 -060096struct soc_amd_picasso_config {
Furquan Shaikh033aa0d2020-05-09 14:26:37 -070097 struct soc_amd_common_config common_config;
Martin Roth5c354b92019-04-22 14:55:16 -060098 /*
Karthikeyan Ramasubramanian0dbea482021-03-08 23:23:50 -070099 * If sb_reset_i2c_peripherals() is called, this devicetree register
Martin Roth5c354b92019-04-22 14:55:16 -0600100 * defines which I2C SCL will be toggled 9 times at 100 KHz.
Karthikeyan Ramasubramanian0dbea482021-03-08 23:23:50 -0700101 * For example, should we need I2C0 and I2C3 have their peripheral
Martin Roth5c354b92019-04-22 14:55:16 -0600102 * devices reseted by toggling SCL, use:
103 *
104 * register i2c_scl_reset = (GPIO_I2C0_SCL | GPIO_I2C3_SCL)
105 */
106 u8 i2c_scl_reset;
Karthikeyan Ramasubramanian4f87ae12021-03-18 23:16:29 -0600107 struct dw_i2c_bus_config i2c[I2C_CTRLR_COUNT];
Akshu Agrawal42d4a572019-12-16 15:13:17 +0530108
Marshall Dawson8df01272020-01-21 22:06:57 -0700109 /* System config index */
110 uint8_t system_config;
111
112 /* STAPM Configuration */
Zheng Bao795d73c2020-10-27 15:36:55 +0800113 uint32_t fast_ppt_limit_mW;
114 uint32_t slow_ppt_limit_mW;
115 uint32_t slow_ppt_time_constant_s;
116 uint32_t stapm_time_constant_s;
117 uint32_t sustained_power_limit_mW;
Marshall Dawson8df01272020-01-21 22:06:57 -0700118
Chris Wang4735b1c2020-07-13 23:29:29 +0800119 /* Enable dptc for tablet mode (0 = disable, 1 = enable) */
120 uint8_t dptc_enable;
121
122 /* STAPM Configuration for tablet mode (need enable dptc_enable first) */
Zheng Bao795d73c2020-10-27 15:36:55 +0800123 uint32_t fast_ppt_limit_tablet_mode_mW;
124 uint32_t slow_ppt_limit_tablet_mode_mW;
125 uint32_t sustained_power_limit_tablet_mode_mW;
Chris Wang4735b1c2020-07-13 23:29:29 +0800126
Marshall Dawson8df01272020-01-21 22:06:57 -0700127 /* PROCHOT_L de-assertion Ramp Time */
Zheng Bao795d73c2020-10-27 15:36:55 +0800128 uint32_t prochot_l_deassertion_ramp_time_ms;
Marshall Dawson8df01272020-01-21 22:06:57 -0700129
Marshall Dawson8079c5c2020-07-08 08:18:16 -0600130 enum {
131 DOWNCORE_AUTO = 0,
Felix Held5dea8272021-04-20 22:38:50 +0200132 DOWNCORE_1 = 1, /* Run with 1 physical core */
133 DOWNCORE_2 = 3, /* Run with 2 physical cores */
134 DOWNCORE_3 = 4, /* Run with 3 physical cores */
Marshall Dawson8079c5c2020-07-08 08:18:16 -0600135 } downcore_mode;
Felix Heldb5c23502021-04-20 22:40:25 +0200136 bool smt_disable; /* true=disable SMT on all physical cores */
Marshall Dawson8079c5c2020-07-08 08:18:16 -0600137
Marshall Dawson8df01272020-01-21 22:06:57 -0700138 /* Lower die temperature limit */
Zheng Bao795d73c2020-10-27 15:36:55 +0800139 uint32_t thermctl_limit_degreeC;
140 uint32_t thermctl_limit_tablet_mode_degreeC;
Marshall Dawson8df01272020-01-21 22:06:57 -0700141
142 /* FP5 Processor Voltage Supply PSI Currents. 0 indicates use SOC default */
Zheng Bao795d73c2020-10-27 15:36:55 +0800143 uint32_t psi0_current_limit_mA;
144 uint32_t psi0_soc_current_limit_mA;
145 uint32_t vddcr_soc_voltage_margin_mV;
146 uint32_t vddcr_vdd_voltage_margin_mV;
Marshall Dawson8df01272020-01-21 22:06:57 -0700147
148 /* VRM Limits. 0 indicates use SOC default */
Zheng Bao795d73c2020-10-27 15:36:55 +0800149 uint32_t vrm_maximum_current_limit_mA;
150 uint32_t vrm_soc_maximum_current_limit_mA;
151 uint32_t vrm_current_limit_mA;
152 uint32_t vrm_soc_current_limit_mA;
Marshall Dawson8df01272020-01-21 22:06:57 -0700153
154 /* Misc SMU settings */
155 uint8_t sb_tsi_alert_comparator_mode_en;
156 uint8_t core_dldo_bypass;
157 uint8_t min_soc_vid_offset;
158 uint8_t aclk_dpm0_freq_400MHz;
Zheng Bao795d73c2020-10-27 15:36:55 +0800159 uint32_t telemetry_vddcr_vdd_slope_mA;
Chris Wanged033712020-02-14 18:24:54 +0800160 uint32_t telemetry_vddcr_vdd_offset;
Zheng Bao795d73c2020-10-27 15:36:55 +0800161 uint32_t telemetry_vddcr_soc_slope_mA;
Chris Wanged033712020-02-14 18:24:54 +0800162 uint32_t telemetry_vddcr_soc_offset;
Furquan Shaikh69c28112020-04-28 18:57:52 -0700163
Patrick Huanged1592b2021-04-20 20:40:09 +0800164 /*
165 * HDMI 2.0 disable setting
166 * bit0~3: disable HDMI 2.0 DDI0~3
167 */
168 uint8_t hdmi2_disable;
169
Raul E Rangel7c79d832020-09-03 14:30:33 -0600170 struct {
171 /*
172 * SDHCI doesn't directly support eMMC. There is an implicit mapping between
173 * eMMC timing modes and SDHCI UHS-I timing modes defined in the linux
174 * kernel.
175 *
176 * HS -> UHS_SDR12 (0x00)
177 * DDR52 -> UHS_DDR50 (0x04)
178 * HS200 -> UHS_SDR104 (0x03)
179 * HS400 -> NONE (0x05)
180 *
181 * The kernel driver uses a heuristic to determine if HS400 is supported.
182 */
183 enum {
184 SD_EMMC_DISABLE,
185 SD_EMMC_SD_LOW_SPEED,
186 SD_EMMC_SD_HIGH_SPEED,
187 SD_EMMC_SD_UHS_I_SDR_50,
188 SD_EMMC_SD_UHS_I_DDR_50,
189 SD_EMMC_SD_UHS_I_SDR_104,
190 SD_EMMC_EMMC_SDR_26,
191 SD_EMMC_EMMC_SDR_52,
Raul E Rangelf56b7842020-12-04 10:29:56 -0700192 SD_EMMC_EMMC_DDR_104,
Raul E Rangel7c79d832020-09-03 14:30:33 -0600193 SD_EMMC_EMMC_HS200,
194 SD_EMMC_EMMC_HS400,
195 SD_EMMC_EMMC_HS300,
196 } timing;
Raul E Rangel5590d9a2020-09-03 15:41:58 -0600197
198 /*
199 * Sets the driver strength reflected in the SDHCI Preset Value Registers.
200 *
201 * According to the SDHCI spec:
202 * The host should select the weakest drive strength that meets rise /
203 * fall time requirement at system operating frequency.
204 */
205 enum sd_emmc_driver_strength sdr104_hs400_driver_strength;
206 enum sd_emmc_driver_strength ddr50_driver_strength;
207 enum sd_emmc_driver_strength sdr50_driver_strength;
208
209 /*
210 * Sets the frequency in kHz reflected in the Initialization Preset Value
211 * Register.
212 *
213 * This value is used while in open-drain mode, and has a maximum value of
214 * 400 kHz.
215 */
216 uint16_t init_khz_preset;
Raul E Rangel7c79d832020-09-03 14:30:33 -0600217 } emmc_config;
Chris Wang5ec975e2020-10-05 13:39:14 +0800218
Chris Wang3f929022020-09-14 17:03:06 +0800219 /* Force USB3 port to gen1, bit0 - controller0 Port0, bit1 - Port1 */
220 union usb3_force_gen1 usb3_port_force_gen1;
Chris Wang04dfc262020-05-19 14:46:35 +0800221
Felix Held1d0154c2020-07-23 19:37:42 +0200222 uint8_t has_usb2_phy_tune_params;
Felix Held3a7389e2020-07-23 18:22:30 +0200223 struct usb2_phy_tune usb_2_port_tune_params[USB_PORT_COUNT];
Felix Heldbcb3d032020-07-24 19:10:03 +0200224 enum {
225 USB_OC_PIN_0 = 0x0,
226 USB_OC_PIN_1 = 0x1,
227 USB_OC_PIN_2 = 0x2,
228 USB_OC_PIN_3 = 0x3,
229 USB_OC_PIN_4 = 0x4,
230 USB_OC_PIN_5 = 0x5,
231 USB_OC_NONE = 0xf,
232 } usb_port_overcurrent_pin[USB_PORT_COUNT];
Felix Held82a0a632020-08-28 01:40:20 +0200233
Chris Wang68d68f12021-02-03 04:32:06 +0800234 /* RV2 SOC Usb 3.1 PHY Parameters */
235 uint8_t usb3_phy_override;
236 /*
237 * 1,RX_EQ_DELTA_IQ_OVRD_VAL- Override value for rx_eq_delta_iq. Range 0-0xF
238 * 2,RX_EQ_DELTA_IQ_OVRD_EN - Enable override value for rx_eq_delta_iq. Range 0-0x1
239 */
240 struct usb3_phy_tune usb3_phy_tune_params[RV2_USB3_PORT_COUNT];
241 /* Override value for rx_vref_ctrl. Range 0 - 0x1F */
242 uint8_t usb3_rx_vref_ctrl;
243 /* Enable override value for rx_vref_ctrl. Range 0 - 0x1 */
244 uint8_t usb3_rx_vref_ctrl_en;
245 /* Override value for tx_vboost_lvl: 0 - 0x7. */
246 uint8_t usb_3_tx_vboost_lvl;
247 /* Enable override value for tx_vboost_lvl. Range: 0 - 0x1 */
248 uint8_t usb_3_tx_vboost_lvl_en;
249 /* Override value for rx_vref_ctrl. Range 0 - 0x1F.*/
250 uint8_t usb_3_rx_vref_ctrl_x;
251 /* Enable override value for rx_vref_ctrl. Range 0 - 0x1. */
252 uint8_t usb_3_rx_vref_ctrl_en_x;
253 /* Override value for tx_vboost_lvl: 0 - 0x7. */
254 uint8_t usb_3_tx_vboost_lvl_x;
255 /* Enable override value for tx_vboost_lvl. Range: 0 - 0x1. */
256 uint8_t usb_3_tx_vboost_lvl_en_x;
257
Felix Held0e099ea2021-05-18 01:34:06 +0200258 /* The array index is the general purpose PCIe clock output number. Values in here
259 aren't the values written to the register to have the default to be always on. */
260 enum {
261 GPP_CLK_ON, /* GPP clock always on; default */
262 GPP_CLK_REQ, /* GPP clock controlled by corresponding #CLK_REQx pin */
263 GPP_CLK_OFF, /* GPP clk off */
264 } gpp_clk_config[GPP_CLK_OUTPUT_COUNT];
265
Felix Held0fec8672021-05-25 21:07:23 +0200266 /* performance policy for the PCIe links: power consumption vs. link speed */
267 enum {
268 DXIO_PSPP_PERFORMANCE = 0,
269 DXIO_PSPP_BALANCED,
270 DXIO_PSPP_POWERSAVE,
271 } pspp_policy;
272
Karthikeyan Ramasubramanian39b7afa2021-04-29 16:50:51 -0600273 /* If using an external 48MHz OSC for codec, will disable internal X48M_OSC */
274 bool acp_i2s_use_external_48mhz_osc;
Chris Wang4e66d932020-12-18 14:58:56 +0800275
276 /* eDP phy tuning settings */
Chris Wang4c4a3602021-02-02 13:04:33 +0800277 uint16_t edp_phy_override;
278 /* bit vector of phy, bit0=1: DP0, bit1=1: DP1, bit2=1: DP2 bit3=1: DP3 */
279 uint8_t edp_physel;
Chris Wang4e66d932020-12-18 14:58:56 +0800280
281 struct {
282 uint8_t dp_vs_pemph_level;
283 uint8_t deemph_6db4;
284 uint8_t boostadj;
285 uint16_t margin_deemph;
286 } edp_tuningset;
Chris Wang3ec3cb82020-12-23 04:29:57 +0800287
288 /*
289 * eDP panel power sequence control
290 * all pwr sequence numbers below are in uint of 4ms and "0" as default value
291 */
292 uint8_t edp_pwr_adjust_enable;
293 uint8_t pwron_digon_to_de;
294 uint8_t pwron_de_to_varybl;
295 uint8_t pwrdown_varybloff_to_de;
296 uint8_t pwrdown_de_to_digoff;
297 uint8_t pwroff_delay;
298 uint8_t pwron_varybl_to_blon;
299 uint8_t pwrdown_bloff_to_varybloff;
300 uint8_t min_allowed_bl_level;
Chris Wangad4f6d72021-01-26 20:09:34 +0800301
302 /* allow USB PD port setting override */
303 struct usb_pd_control usb_pd_config_override[USB_PD_PORT_COUNT];
Martin Roth5c354b92019-04-22 14:55:16 -0600304};
305
Martin Roth5f672632019-04-22 16:04:13 -0600306#endif /* __PICASSO_CHIP_H__ */