Skyrim: Apply MP2845A workaround
Apply a workaround for a MP2845A problem.
BRANCH=None
TEST=on skyrim, dump register in S0 to ensure the bit is cleared
*/
#include "ap_power/ap_power.h"
+#include "charger.h"
#include "chipset.h"
#include "config.h"
+#include "cros_board_info.h"
#include "gpio_signal.h"
#include "gpio/gpio_int.h"
#include "hooks.h"
+#include "i2c.h"
#include "ioexpander.h"
#include "power.h"
#include "power/amd_x86.h"
@@ -126,12 +129,36 @@ void baseboard_set_soc_pwr_pgood(enum gpio_signal unused)
gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_s0_pgood)));
}
+/* TODO: Remove when board versions are no longer supported */
+#define MP2845A_I2C_ADDR_FLAGS 0x20
+#define MP2854A_MFR_VOUT_CMPS_MAX_REG 0x69
+#define MP2854A_MFR_LOW_PWR_SEL BIT(12)
+
+static void setup_mp2845(void)
+{
+ int version;
+
+ /* TODO: Remove when board versions are no longer supported */
+ if ((cbi_get_board_version(&version) == EC_SUCCESS) && version > 3)
+ return;
+
+ if (i2c_update16(chg_chips[CHARGER_SOLO].i2c_port,
+ MP2845A_I2C_ADDR_FLAGS, MP2854A_MFR_VOUT_CMPS_MAX_REG,
+ MP2854A_MFR_LOW_PWR_SEL, MASK_CLR))
+ ccprints("Failed to send mp2845 workaround");
+}
+DECLARE_DEFERRED(setup_mp2845);
+
void baseboard_s0_pgood(enum gpio_signal signal)
{
baseboard_set_soc_pwr_pgood(signal);
/* Chain off power signal interrupt handler for PG_PCORE_S0_R_OD */
power_signal_interrupt(signal);
+
+ /* Set up the MP2845, which is powered in S0 */
+ if (gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_s0_pgood)))
+ hook_call_deferred(&setup_mp2845_data, 50 * MSEC);
}
/* Note: signal parameter unused */
