blob: 3320350ee1c59ea42feea78975fdf3ea03d2b85c [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>
Felix Heldd8bcad52022-01-10 22:27:29 +01009#include <gpio.h>
Martin Roth5c354b92019-04-22 14:55:16 -060010#include <soc/i2c.h>
Martin Roth7e78e562019-11-03 23:29:02 -070011#include <soc/iomap.h>
Furquan Shaikh69c28112020-04-28 18:57:52 -070012#include <soc/southbridge.h>
Martin Rothc7acf162020-05-28 00:44:50 -060013#include <arch/x86/include/arch/smp/mpspec.h> /* point from top level */
Felix Held78903802021-04-20 22:37:35 +020014#include <types.h>
Martin Roth5c354b92019-04-22 14:55:16 -060015
Chris Wang04dfc262020-05-19 14:46:35 +080016/*
17 USB 2.0 PHY Parameters
18*/
Felix Held0b5a6142020-07-23 19:37:17 +020019struct __packed usb2_phy_tune {
Chris Wang04dfc262020-05-19 14:46:35 +080020 /* Disconnect Threshold Adjustment. Range 0 - 0x7 */
21 uint8_t com_pds_tune;
22 /* Squelch Threshold Adjustment. Range 0 - 0x7 */
23 uint8_t sq_rx_tune;
24 /* FS/LS Source Impedance Adjustment. Range 0 - 0xF */
25 uint8_t tx_fsls_tune;
Martin Roth26f97f92021-10-01 14:53:22 -060026 /* HS Transmitter Pre-Emphasis Current Control. Range 0 - 0x3 */
Chris Wang04dfc262020-05-19 14:46:35 +080027 uint8_t tx_pre_emp_amp_tune;
28 /* HS Transmitter Pre-Emphasis Duration Control. Range: 0 - 0x1 */
29 uint8_t tx_pre_emp_pulse_tune;
30 /* HS Transmitter Rise/Fall Time Adjustment. Range: 0 - 0x3 */
31 uint8_t tx_rise_tune;
32 /* HS DC Voltage Level Adjustment. Range 0 - 0xF */
Kevin Chiude20b282020-11-19 14:09:47 +080033 uint8_t tx_vref_tune;
Chris Wang04dfc262020-05-19 14:46:35 +080034 /* Transmitter High-Speed Crossover Adjustment. Range 0 - 0x3 */
35 uint8_t tx_hsxv_tune;
36 /* USB Source Impedance Adjustment. Range 0 - 0x3. */
37 uint8_t tx_res_tune;
38};
39
Chris Wang3f929022020-09-14 17:03:06 +080040/* force USB3 port to gen1, bit0 - controller0 Port0, bit1 - Port1, etc */
41union __packed usb3_force_gen1 {
42 struct {
43 uint8_t xhci0_port0:1;
44 uint8_t xhci0_port1:1;
45 uint8_t xhci0_port2:1;
46 uint8_t xhci0_port3:1;
47 } ports;
48 uint8_t usb3_port_force_gen1_en;
49};
50
Chris Wangad4f6d72021-01-26 20:09:34 +080051enum rfmux_configuration_setting {
52 USB_PD_RFMUX_SAFE_STATE = 0x0,
53 USB_PD_RFMUX_USB31_MODE = 0x1,
54 USB_PD_RFMUX_USB31_MODE_FLIP = 0x2,
55 USB_PD_RFMUX_ATE_MODE = 0x3,
56 USB_PD_RFMUX_DP_X2_MODE = 0x4,
57 USB_PD_RFMUX_MF_MODE_ALT_D_F = 0x6,
58 USB_PD_RFMUX_DP_X2_MODE_FLIP = 0x8,
59 USB_PD_RFMUX_MF_MODE_ALT_D_F_FLIP = 0x9,
60 USB_PD_RFMUX_DP_X4_MODE = 0xc,
61};
62
63struct usb_pd_control {
64 uint8_t rfmux_override_en;
65 uint32_t rfmux_config;
66};
67
Felix Held3a7389e2020-07-23 18:22:30 +020068#define USB_PORT_COUNT 6
Chris Wang68d68f12021-02-03 04:32:06 +080069
70struct __packed usb3_phy_tune {
71 uint8_t rx_eq_delta_iq_ovrd_val;
72 uint8_t rx_eq_delta_iq_ovrd_en;
73};
74/* the RV2 USB3 port count */
75#define RV2_USB3_PORT_COUNT 4
Chris Wangad4f6d72021-01-26 20:09:34 +080076#define USB_PD_PORT_COUNT 2
Felix Held3a7389e2020-07-23 18:22:30 +020077
Raul E Rangel5590d9a2020-09-03 15:41:58 -060078enum sd_emmc_driver_strength {
79 SD_EMMC_DRIVE_STRENGTH_B,
80 SD_EMMC_DRIVE_STRENGTH_A,
81 SD_EMMC_DRIVE_STRENGTH_C,
82 SD_EMMC_DRIVE_STRENGTH_D,
83};
84
Chris Wang4e66d932020-12-18 14:58:56 +080085/* dpphy_override */
86enum sysinfo_dpphy_override {
87 ENABLE_DVI_TUNINGSET = 0x01,
88 ENABLE_HDMI_TUNINGSET = 0x02,
89 ENABLE_HDMI6G_TUNINGSET = 0x04,
90 ENABLE_DP_TUNINGSET = 0x08,
91 ENABLE_DP_HBR3_TUNINGSET = 0x10,
92 ENABLE_DP_HBR_TUNINGSET = 0x20,
93 ENABLE_DP_HBR2_TUNINGSET = 0x40,
94 ENABLE_EDP_TUNINGSET = 0x80,
95};
96
Marshall Dawsonbc4c9032019-06-11 12:18:20 -060097struct soc_amd_picasso_config {
Furquan Shaikh033aa0d2020-05-09 14:26:37 -070098 struct soc_amd_common_config common_config;
Martin Roth5c354b92019-04-22 14:55:16 -060099 /*
Karthikeyan Ramasubramanian0dbea482021-03-08 23:23:50 -0700100 * If sb_reset_i2c_peripherals() is called, this devicetree register
Martin Roth5c354b92019-04-22 14:55:16 -0600101 * defines which I2C SCL will be toggled 9 times at 100 KHz.
Karthikeyan Ramasubramanian0dbea482021-03-08 23:23:50 -0700102 * For example, should we need I2C0 and I2C3 have their peripheral
Martin Roth26f97f92021-10-01 14:53:22 -0600103 * devices reset by toggling SCL, use:
Martin Roth5c354b92019-04-22 14:55:16 -0600104 *
105 * register i2c_scl_reset = (GPIO_I2C0_SCL | GPIO_I2C3_SCL)
106 */
107 u8 i2c_scl_reset;
Karthikeyan Ramasubramanian4f87ae12021-03-18 23:16:29 -0600108 struct dw_i2c_bus_config i2c[I2C_CTRLR_COUNT];
Akshu Agrawal42d4a572019-12-16 15:13:17 +0530109
Marshall Dawson8df01272020-01-21 22:06:57 -0700110 /* System config index */
111 uint8_t system_config;
112
113 /* STAPM Configuration */
Zheng Bao795d73c2020-10-27 15:36:55 +0800114 uint32_t fast_ppt_limit_mW;
115 uint32_t slow_ppt_limit_mW;
116 uint32_t slow_ppt_time_constant_s;
117 uint32_t stapm_time_constant_s;
118 uint32_t sustained_power_limit_mW;
Marshall Dawson8df01272020-01-21 22:06:57 -0700119
Tim Van Patten92443582022-08-23 16:06:33 -0600120 /* STAPM Configuration for tablet mode */
Zheng Bao795d73c2020-10-27 15:36:55 +0800121 uint32_t fast_ppt_limit_tablet_mode_mW;
122 uint32_t slow_ppt_limit_tablet_mode_mW;
123 uint32_t sustained_power_limit_tablet_mode_mW;
Chris Wang4735b1c2020-07-13 23:29:29 +0800124
Marshall Dawson8df01272020-01-21 22:06:57 -0700125 /* PROCHOT_L de-assertion Ramp Time */
Zheng Bao795d73c2020-10-27 15:36:55 +0800126 uint32_t prochot_l_deassertion_ramp_time_ms;
Marshall Dawson8df01272020-01-21 22:06:57 -0700127
Marshall Dawson8079c5c2020-07-08 08:18:16 -0600128 enum {
129 DOWNCORE_AUTO = 0,
Felix Held5dea8272021-04-20 22:38:50 +0200130 DOWNCORE_1 = 1, /* Run with 1 physical core */
131 DOWNCORE_2 = 3, /* Run with 2 physical cores */
132 DOWNCORE_3 = 4, /* Run with 3 physical cores */
Marshall Dawson8079c5c2020-07-08 08:18:16 -0600133 } downcore_mode;
Felix Heldb5c23502021-04-20 22:40:25 +0200134 bool smt_disable; /* true=disable SMT on all physical cores */
Marshall Dawson8079c5c2020-07-08 08:18:16 -0600135
Marshall Dawson8df01272020-01-21 22:06:57 -0700136 /* Lower die temperature limit */
Zheng Bao795d73c2020-10-27 15:36:55 +0800137 uint32_t thermctl_limit_degreeC;
138 uint32_t thermctl_limit_tablet_mode_degreeC;
Marshall Dawson8df01272020-01-21 22:06:57 -0700139
140 /* FP5 Processor Voltage Supply PSI Currents. 0 indicates use SOC default */
Zheng Bao795d73c2020-10-27 15:36:55 +0800141 uint32_t psi0_current_limit_mA;
142 uint32_t psi0_soc_current_limit_mA;
143 uint32_t vddcr_soc_voltage_margin_mV;
144 uint32_t vddcr_vdd_voltage_margin_mV;
Marshall Dawson8df01272020-01-21 22:06:57 -0700145
146 /* VRM Limits. 0 indicates use SOC default */
Zheng Bao795d73c2020-10-27 15:36:55 +0800147 uint32_t vrm_maximum_current_limit_mA;
148 uint32_t vrm_soc_maximum_current_limit_mA;
149 uint32_t vrm_current_limit_mA;
150 uint32_t vrm_soc_current_limit_mA;
Marshall Dawson8df01272020-01-21 22:06:57 -0700151
152 /* Misc SMU settings */
153 uint8_t sb_tsi_alert_comparator_mode_en;
154 uint8_t core_dldo_bypass;
155 uint8_t min_soc_vid_offset;
156 uint8_t aclk_dpm0_freq_400MHz;
Zheng Bao795d73c2020-10-27 15:36:55 +0800157 uint32_t telemetry_vddcr_vdd_slope_mA;
Chris Wanged033712020-02-14 18:24:54 +0800158 uint32_t telemetry_vddcr_vdd_offset;
Zheng Bao795d73c2020-10-27 15:36:55 +0800159 uint32_t telemetry_vddcr_soc_slope_mA;
Chris Wanged033712020-02-14 18:24:54 +0800160 uint32_t telemetry_vddcr_soc_offset;
Furquan Shaikh69c28112020-04-28 18:57:52 -0700161
Patrick Huanged1592b2021-04-20 20:40:09 +0800162 /*
163 * HDMI 2.0 disable setting
164 * bit0~3: disable HDMI 2.0 DDI0~3
165 */
166 uint8_t hdmi2_disable;
167
Raul E Rangel7c79d832020-09-03 14:30:33 -0600168 struct {
169 /*
170 * SDHCI doesn't directly support eMMC. There is an implicit mapping between
171 * eMMC timing modes and SDHCI UHS-I timing modes defined in the linux
172 * kernel.
173 *
174 * HS -> UHS_SDR12 (0x00)
175 * DDR52 -> UHS_DDR50 (0x04)
176 * HS200 -> UHS_SDR104 (0x03)
177 * HS400 -> NONE (0x05)
178 *
179 * The kernel driver uses a heuristic to determine if HS400 is supported.
180 */
181 enum {
182 SD_EMMC_DISABLE,
183 SD_EMMC_SD_LOW_SPEED,
184 SD_EMMC_SD_HIGH_SPEED,
185 SD_EMMC_SD_UHS_I_SDR_50,
186 SD_EMMC_SD_UHS_I_DDR_50,
187 SD_EMMC_SD_UHS_I_SDR_104,
188 SD_EMMC_EMMC_SDR_26,
189 SD_EMMC_EMMC_SDR_52,
Raul E Rangelf56b7842020-12-04 10:29:56 -0700190 SD_EMMC_EMMC_DDR_104,
Raul E Rangel7c79d832020-09-03 14:30:33 -0600191 SD_EMMC_EMMC_HS200,
192 SD_EMMC_EMMC_HS400,
193 SD_EMMC_EMMC_HS300,
194 } timing;
Raul E Rangel5590d9a2020-09-03 15:41:58 -0600195
196 /*
197 * Sets the driver strength reflected in the SDHCI Preset Value Registers.
198 *
199 * According to the SDHCI spec:
200 * The host should select the weakest drive strength that meets rise /
201 * fall time requirement at system operating frequency.
202 */
203 enum sd_emmc_driver_strength sdr104_hs400_driver_strength;
204 enum sd_emmc_driver_strength ddr50_driver_strength;
205 enum sd_emmc_driver_strength sdr50_driver_strength;
206
207 /*
208 * Sets the frequency in kHz reflected in the Initialization Preset Value
209 * Register.
210 *
211 * This value is used while in open-drain mode, and has a maximum value of
212 * 400 kHz.
213 */
214 uint16_t init_khz_preset;
Raul E Rangel7c79d832020-09-03 14:30:33 -0600215 } emmc_config;
Chris Wang5ec975e2020-10-05 13:39:14 +0800216
Chris Wang3f929022020-09-14 17:03:06 +0800217 /* Force USB3 port to gen1, bit0 - controller0 Port0, bit1 - Port1 */
218 union usb3_force_gen1 usb3_port_force_gen1;
Chris Wang04dfc262020-05-19 14:46:35 +0800219
Felix Held1d0154c2020-07-23 19:37:42 +0200220 uint8_t has_usb2_phy_tune_params;
Felix Held3a7389e2020-07-23 18:22:30 +0200221 struct usb2_phy_tune usb_2_port_tune_params[USB_PORT_COUNT];
Felix Heldbcb3d032020-07-24 19:10:03 +0200222 enum {
223 USB_OC_PIN_0 = 0x0,
224 USB_OC_PIN_1 = 0x1,
225 USB_OC_PIN_2 = 0x2,
226 USB_OC_PIN_3 = 0x3,
227 USB_OC_PIN_4 = 0x4,
228 USB_OC_PIN_5 = 0x5,
229 USB_OC_NONE = 0xf,
230 } usb_port_overcurrent_pin[USB_PORT_COUNT];
Felix Held82a0a632020-08-28 01:40:20 +0200231
Chris Wang68d68f12021-02-03 04:32:06 +0800232 /* RV2 SOC Usb 3.1 PHY Parameters */
233 uint8_t usb3_phy_override;
234 /*
235 * 1,RX_EQ_DELTA_IQ_OVRD_VAL- Override value for rx_eq_delta_iq. Range 0-0xF
236 * 2,RX_EQ_DELTA_IQ_OVRD_EN - Enable override value for rx_eq_delta_iq. Range 0-0x1
237 */
238 struct usb3_phy_tune usb3_phy_tune_params[RV2_USB3_PORT_COUNT];
239 /* Override value for rx_vref_ctrl. Range 0 - 0x1F */
240 uint8_t usb3_rx_vref_ctrl;
241 /* Enable override value for rx_vref_ctrl. Range 0 - 0x1 */
242 uint8_t usb3_rx_vref_ctrl_en;
243 /* Override value for tx_vboost_lvl: 0 - 0x7. */
244 uint8_t usb_3_tx_vboost_lvl;
245 /* Enable override value for tx_vboost_lvl. Range: 0 - 0x1 */
246 uint8_t usb_3_tx_vboost_lvl_en;
247 /* Override value for rx_vref_ctrl. Range 0 - 0x1F.*/
248 uint8_t usb_3_rx_vref_ctrl_x;
249 /* Enable override value for rx_vref_ctrl. Range 0 - 0x1. */
250 uint8_t usb_3_rx_vref_ctrl_en_x;
251 /* Override value for tx_vboost_lvl: 0 - 0x7. */
252 uint8_t usb_3_tx_vboost_lvl_x;
253 /* Enable override value for tx_vboost_lvl. Range: 0 - 0x1. */
254 uint8_t usb_3_tx_vboost_lvl_en_x;
255
Felix Held0e099ea2021-05-18 01:34:06 +0200256 /* The array index is the general purpose PCIe clock output number. Values in here
257 aren't the values written to the register to have the default to be always on. */
258 enum {
259 GPP_CLK_ON, /* GPP clock always on; default */
260 GPP_CLK_REQ, /* GPP clock controlled by corresponding #CLK_REQx pin */
261 GPP_CLK_OFF, /* GPP clk off */
262 } gpp_clk_config[GPP_CLK_OUTPUT_COUNT];
263
Felix Held0fec8672021-05-25 21:07:23 +0200264 /* performance policy for the PCIe links: power consumption vs. link speed */
265 enum {
Matt Papageorge5a2feed2021-07-20 15:09:46 -0500266 DXIO_PSPP_DISABLED = 0,
267 DXIO_PSPP_PERFORMANCE,
Felix Held0fec8672021-05-25 21:07:23 +0200268 DXIO_PSPP_BALANCED,
269 DXIO_PSPP_POWERSAVE,
270 } pspp_policy;
271
Karthikeyan Ramasubramanian39b7afa2021-04-29 16:50:51 -0600272 /* If using an external 48MHz OSC for codec, will disable internal X48M_OSC */
273 bool acp_i2s_use_external_48mhz_osc;
Chris Wang4e66d932020-12-18 14:58:56 +0800274
275 /* eDP phy tuning settings */
Chris Wang4c4a3602021-02-02 13:04:33 +0800276 uint16_t edp_phy_override;
277 /* bit vector of phy, bit0=1: DP0, bit1=1: DP1, bit2=1: DP2 bit3=1: DP3 */
278 uint8_t edp_physel;
Chris Wang4e66d932020-12-18 14:58:56 +0800279
280 struct {
281 uint8_t dp_vs_pemph_level;
282 uint8_t deemph_6db4;
283 uint8_t boostadj;
284 uint16_t margin_deemph;
285 } edp_tuningset;
Chris Wang3ec3cb82020-12-23 04:29:57 +0800286
287 /*
288 * eDP panel power sequence control
289 * all pwr sequence numbers below are in uint of 4ms and "0" as default value
290 */
291 uint8_t edp_pwr_adjust_enable;
292 uint8_t pwron_digon_to_de;
293 uint8_t pwron_de_to_varybl;
294 uint8_t pwrdown_varybloff_to_de;
295 uint8_t pwrdown_de_to_digoff;
296 uint8_t pwroff_delay;
297 uint8_t pwron_varybl_to_blon;
298 uint8_t pwrdown_bloff_to_varybloff;
299 uint8_t min_allowed_bl_level;
Chris Wangad4f6d72021-01-26 20:09:34 +0800300
301 /* allow USB PD port setting override */
302 struct usb_pd_control usb_pd_config_override[USB_PD_PORT_COUNT];
Martin Roth5c354b92019-04-22 14:55:16 -0600303};
304
Martin Roth5f672632019-04-22 16:04:13 -0600305#endif /* __PICASSO_CHIP_H__ */