From e54c3e1728cc4648e2c489770bcad678e985b129 Mon Sep 17 00:00:00 2001 From: Furquan Shaikh Date: Wed, 18 Apr 2018 18:44:25 -0700 Subject: [PATCH] chipset: Add callback for chipset pre-initialization This change adds a callback for chipset_pre_init_callback which is made by x86 common power state machine when in G3S5 state. Until now, there was a hook CHIPSET_PRE_INIT_CALLBACK that was notified by chipset task when in G3S5 state. However, there are at least following reasons why this should be a callback and not a hook notification: 1. The initialization that is done as part of pre-init could be essential for the power state machine to make progress. Though the chipset task goes to sleep waiting for power signals after the hook notification, pre-initialization can all be done as part of a callback since it is mostly board-specific code that is doing work to initialize PMIC. 2. Typically, boards use I2C transactions to setup PMIC on getting chipset pre-init notification. However, since i2c transfers are not encouraged in hook task, they have to be deferred anyways. 3. Since the initialization is being done as part of hook task, use of any constructs e.g. pwr_5v_en_req which allows multiple consumers to enable/disable power rails will use task id for hook task. Instead it is better to provide correct information about the task by letting chipset task perform this request. Thus, this change adds a callback chipset_pre_init_callback in G3S5 state for x86 power state machine. This callback is guarded by CONFIG_CHIPSET_HAS_PRE_INIT_CALLBACK. The hook notification is left as is for now until all x86 boards are moved over to using the newly added callback. BUG=b:78259506 BRANCH=None TEST=None Change-Id: I2e1d73e5308759fef41680ae715ef71268b61780 Signed-off-by: Furquan Shaikh Reviewed-on: https://chromium-review.googlesource.com/1018733 Commit-Ready: Furquan Shaikh Tested-by: Furquan Shaikh Reviewed-by: Jett Rink --- include/chipset.h | 5 +++++ include/config.h | 4 +++- power/intel_x86.c | 8 ++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/include/chipset.h b/include/chipset.h index 775428ed9f..ba78c45397 100644 --- a/include/chipset.h +++ b/include/chipset.h @@ -87,6 +87,11 @@ void power_interrupt(enum gpio_signal signal); */ void chipset_handle_espi_reset_assert(void); +/** + * Perform chipset pre-initialization work within the context of chipset task. + */ +void chipset_pre_init_callback(void); + #else /* !HAS_TASK_CHIPSET */ /* When no chipset is present, assume it is always off. */ diff --git a/include/config.h b/include/config.h index c32c68faf3..0562575a71 100644 --- a/include/config.h +++ b/include/config.h @@ -750,6 +750,9 @@ /* Support PMIC reset(using LDO_EN) in chipset */ #undef CONFIG_CHIPSET_HAS_PLATFORM_PMIC_RESET +/* Board requires chipset pre-init callback */ +#undef CONFIG_CHIPSET_HAS_PRE_INIT_CALLBACK + /* Redefine when we need a different power-on sequence on the same chipset. */ #define CONFIG_CHIPSET_POWER_SEQ_VERSION 0 @@ -3533,7 +3536,6 @@ #define CONFIG_CHIPSET_APL_GLK #endif - /*****************************************************************************/ /* * Apply test config overrides last, since tests need to override some of the diff --git a/power/intel_x86.c b/power/intel_x86.c index bc58d26711..df76dac8f8 100644 --- a/power/intel_x86.c +++ b/power/intel_x86.c @@ -308,6 +308,14 @@ enum power_state common_intel_x86_power_handle_state(enum power_state state) msleep(200); #endif +#ifdef CONFIG_CHIPSET_HAS_PRE_INIT_CALLBACK + /* + * Callback to do pre-initialization within the context of + * chipset task. + */ + chipset_pre_init_callback(); +#endif + /* Call hooks to initialize PMIC */ hook_notify(HOOK_CHIPSET_PRE_INIT);