diff options
author | Vijay Hiremath <vijay.p.hiremath@intel.com> | 2021-09-22 12:02:09 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-10-05 21:11:47 +0000 |
commit | 6dc0328da93692f25e7de35243b0ca62691e2559 (patch) | |
tree | 204b89df427e9a0d95514e2b302f8a91bec4fafb | |
parent | 6c04fcf77da3166983496eadf987d45400fdfef4 (diff) | |
download | chrome-ec-6dc0328da93692f25e7de35243b0ca62691e2559.tar.gz |
main: Add board level Pre-task I2C peripheral initialization
Intel RVP requires GPIOs from few of the IO expanders to configure pins
pre-task, but the current code initializes the IO expanders after the
HOOK task starts. This CL allows board to configure the I2C peripherals
pre-task.
BUG=none
BRANCH=none
TEST=Tested on ADL-RVP, able to initialize IOEX pre-task
Change-Id: I827e22153a98a058d04da0139e302a6ec0276b43
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3183329
Reviewed-by: Keith Short <keithshort@chromium.org>
Commit-Queue: Keith Short <keithshort@chromium.org>
-rw-r--r-- | common/i2c_bitbang.c | 4 | ||||
-rw-r--r-- | common/main.c | 15 | ||||
-rw-r--r-- | include/i2c_bitbang.h | 11 |
3 files changed, 25 insertions, 5 deletions
diff --git a/common/i2c_bitbang.c b/common/i2c_bitbang.c index 9e961d730e..99868b2dc6 100644 --- a/common/i2c_bitbang.c +++ b/common/i2c_bitbang.c @@ -349,6 +349,10 @@ void enable_i2c_raw_mode(bool enable) } } +__overridable void board_pre_task_i2c_peripheral_init(void) +{ +} + const struct i2c_drv bitbang_drv = { .xfer = &i2c_bitbang_xfer }; diff --git a/common/main.c b/common/main.c index 0e18580373..2cc1594eff 100644 --- a/common/main.c +++ b/common/main.c @@ -195,14 +195,19 @@ test_mockable __keep int main(void) */ i2c_init(); - /* - * Enable I2C raw mode for the ports which need pre-task i2c - * transactions. - */ - if (IS_ENABLED(CONFIG_I2C_BITBANG)) + if (IS_ENABLED(CONFIG_I2C_BITBANG)) { + /* + * Enable I2C raw mode for the ports which need + * pre-task i2c transactions. + */ enable_i2c_raw_mode(true); + + /* Board level pre-task I2C peripheral initialization */ + board_pre_task_i2c_peripheral_init(); + } } + #ifdef HAS_TASK_KEYSCAN keyboard_scan_init(); #endif diff --git a/include/i2c_bitbang.h b/include/i2c_bitbang.h index d550f1a582..12486b7ee6 100644 --- a/include/i2c_bitbang.h +++ b/include/i2c_bitbang.h @@ -20,6 +20,17 @@ extern const unsigned int i2c_bitbang_ports_used; */ void enable_i2c_raw_mode(bool enable); +/** + * Board level function to initialize I2C peripherals before task starts. + * + * Note: This requires CONFIG_I2C_BITBANG to be enabled, as the task event + * based I2C transactions can only be done in bitbang mode if accessed pre-task. + * + * Example: I/O expanders can be initialized to utilize GPIOs earlier + * than the HOOK task starts. + */ +__override_proto void board_pre_task_i2c_peripheral_init(void); + /* expose static functions for testing */ #ifdef TEST_BUILD int bitbang_start_cond(const struct i2c_port_t *i2c_port); |