diff options
Diffstat (limited to 'zephyr/program/skyrim/frostflow/src')
-rw-r--r-- | zephyr/program/skyrim/frostflow/src/thermal.c | 12 | ||||
-rw-r--r-- | zephyr/program/skyrim/frostflow/src/usb_mux_config.c | 119 |
2 files changed, 125 insertions, 6 deletions
diff --git a/zephyr/program/skyrim/frostflow/src/thermal.c b/zephyr/program/skyrim/frostflow/src/thermal.c index 59110dd35e..101823cc26 100644 --- a/zephyr/program/skyrim/frostflow/src/thermal.c +++ b/zephyr/program/skyrim/frostflow/src/thermal.c @@ -12,7 +12,7 @@ #include "thermal.h" #include "util.h" -#define TEMP_AMB TEMP_SENSOR_ID(DT_NODELABEL(temp_amb)) +#define TEMP_MEM TEMP_SENSOR_ID(DT_NODELABEL(temp_sensor_memory)) struct fan_step { /* @@ -68,17 +68,17 @@ int fan_table_to_rpm(int fan, int *temp) * 3. invariant path. (return the current RPM) */ - if (temp[TEMP_AMB] < prev_tmp[TEMP_AMB]) { + if (temp[TEMP_MEM] < prev_tmp[TEMP_MEM]) { for (i = current_level; i > 0; i--) { - if (temp[TEMP_AMB] < fan_step_table[i].off[TEMP_AMB]) + if (temp[TEMP_MEM] <= fan_step_table[i].off[TEMP_MEM]) current_level = i - 1; else break; } - } else if (temp[TEMP_AMB] > prev_tmp[TEMP_AMB]) { + } else if (temp[TEMP_MEM] > prev_tmp[TEMP_MEM]) { for (i = current_level; i < NUM_FAN_LEVELS; i++) { - if (temp[TEMP_AMB] > fan_step_table[i].on[TEMP_AMB]) - current_level = i + 1; + if (temp[TEMP_MEM] >= fan_step_table[i].on[TEMP_MEM]) + current_level = i; else break; } diff --git a/zephyr/program/skyrim/frostflow/src/usb_mux_config.c b/zephyr/program/skyrim/frostflow/src/usb_mux_config.c index 2ec1dda0be..f2c5bd2444 100644 --- a/zephyr/program/skyrim/frostflow/src/usb_mux_config.c +++ b/zephyr/program/skyrim/frostflow/src/usb_mux_config.c @@ -5,12 +5,26 @@ /* Frostflow board-specific USB-C mux configuration */ +#include "chipset.h" +#include "common.h" +#include "console.h" +#include "driver/retimer/ps8811.h" +#include "hooks.h" +#include "i2c.h" #include "ioexpander.h" +#include "timer.h" +#include "usb_mux.h" #include "usbc/usb_muxes.h" +#include "util.h" #define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) #define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) +struct ps8811_reg_val { + uint8_t reg; + uint16_t val; +}; + /* * USB C0 (general) and C1 (just ps8815 DB) use IOEX pins to * indicate flipped polarity to a protection switch. @@ -60,3 +74,108 @@ int board_c1_ps8818_mux_set(const struct usb_mux *me, mux_state_t mux_state) return 0; } + +const static struct ps8811_reg_val equalizer_wwan_table[] = { + { + /* Set channel A EQ setting */ + .reg = PS8811_REG1_USB_AEQ_LEVEL, + .val = (PS8811_AEQ_I2C_LEVEL_UP_13DB + << PS8811_AEQ_I2C_LEVEL_UP_SHIFT) | + (PS8811_AEQ_PIN_LEVEL_UP_18DB + << PS8811_AEQ_PIN_LEVEL_UP_SHIFT), + }, + { + /* Set ADE pin setting */ + .reg = PS8811_REG1_USB_ADE_CONFIG, + .val = (PS8811_ADE_PIN_MID_LEVEL_3DB + << PS8811_ADE_PIN_MID_LEVEL_SHIFT) | + PS8811_AEQ_CONFIG_REG_ENABLE, + }, + { + /* Set channel B EQ setting */ + .reg = PS8811_REG1_USB_BEQ_LEVEL, + .val = (PS8811_BEQ_I2C_LEVEL_UP_10P5DB + << PS8811_BEQ_I2C_LEVEL_UP_SHIFT) | + (PS8811_BEQ_PIN_LEVEL_UP_18DB + << PS8811_BEQ_PIN_LEVEL_UP_SHIFT), + }, + { + /* Set BDE pin setting */ + .reg = PS8811_REG1_USB_BDE_CONFIG, + .val = (PS8811_BDE_PIN_MID_LEVEL_3DB + << PS8811_BDE_PIN_MID_LEVEL_SHIFT) | + PS8811_BEQ_CONFIG_REG_ENABLE, + }, +}; + +#define NUM_EQ_WWAN_ARRAY ARRAY_SIZE(equalizer_wwan_table) + +const static struct ps8811_reg_val equalizer_wlan_table[] = { + { + /* Set 50ohm adjust for B channel */ + .reg = PS8811_REG1_50OHM_ADJUST_CHAN_B, + .val = (PS8811_50OHM_ADJUST_CHAN_B_MINUS_14PCT + << PS8811_50OHM_ADJUST_CHAN_B_SHIFT), + }, +}; + +#define NUM_EQ_WLAN_ARRAY ARRAY_SIZE(equalizer_wlan_table) +/* USB-A ports */ +enum usba_port { USBA_PORT_A1, USBA_PORT_COUNT }; +const struct usb_mux usba_ps8811[] = { + [USBA_PORT_A1] = { + .usb_port = USBA_PORT_A1, + .i2c_port = I2C_PORT_NODELABEL(i2c1_0), + .i2c_addr_flags = PS8811_I2C_ADDR_FLAGS3, + }, +}; + +static int usba_retimer_init(int port) +{ + int rv; + int val; + int i; + const struct usb_mux *me = &usba_ps8811[port]; + + rv = ps8811_i2c_read(me, PS8811_REG_PAGE1, PS8811_REG1_USB_BEQ_LEVEL, + &val); + + if (rv) { + CPRINTSUSB("A1: PS8811 retimer response fail!"); + return rv; + } + CPRINTSUSB("A1: PS8811 retimer detected"); + + if (chipset_in_state(CHIPSET_STATE_ON)) { + /* Set channel A output swing */ + rv = ps8811_i2c_field_update(me, PS8811_REG_PAGE1, + PS8811_REG1_USB_CHAN_A_SWING, + PS8811_CHAN_A_SWING_MASK, + 0x3 << PS8811_CHAN_A_SWING_SHIFT); + + for (i = 0; i < NUM_EQ_WWAN_ARRAY; i++) + rv |= ps8811_i2c_write(me, PS8811_REG_PAGE1, + equalizer_wwan_table[i].reg, + equalizer_wwan_table[i].val); + for (i = 0; i < NUM_EQ_WLAN_ARRAY; i++) + rv |= ps8811_i2c_write(me, PS8811_REG_PAGE1, + equalizer_wlan_table[i].reg, + equalizer_wlan_table[i].val); + } + return rv; +} + +void baseboard_a1_retimer_setup(void) +{ + int i; + + for (i = 0; i < USBA_PORT_COUNT; ++i) + usba_retimer_init(i); +} +DECLARE_DEFERRED(baseboard_a1_retimer_setup); + +void board_chipset_startup(void) +{ + hook_call_deferred(&baseboard_a1_retimer_setup_data, 500 * MSEC); +} +DECLARE_HOOK(HOOK_INIT, board_chipset_startup, HOOK_PRIO_DEFAULT); |