diff options
author | Alexandru M Stan <amstan@chromium.org> | 2019-08-27 17:15:56 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-10-24 02:25:54 +0000 |
commit | 56662a29b010870338c4338c32a3f6afd9912cb7 (patch) | |
tree | 24c7921a8008a0da499146349c308254b6094682 /include | |
parent | 5f683e3de7f605302ec8af791044cff23b0920ee (diff) | |
download | chrome-ec-56662a29b010870338c4338c32a3f6afd9912cb7.tar.gz |
main: Initialize I2C pretty early
Some devices (like the keyboard, CBI) need I2C access pretty early.
Until now I2C would get initialized pretty late in a hook, which was far
too late for some stuff.
As a result from this change, CONFIG_I2C_MASTER now implies the i2c_init()
function will be called at board boot. Some chips (cr50, host tests)
needed a stub i2c_init in order to compile cleanly.
BUG=b/138384267
TEST=EFS doesn't happen significantly later than it used to
TEST=Recovery keys now work with I2C keyboard on jacuzzi
TEST=make buildall
TEST=Sanity check i2c behavior (booting, "i2scan", "battery") on a variety
of ECs:
* ampton (ite EC, x86 AP)
* bobba (npcx EC, x86 AP)
* jacuzzi (stm32f0 EC, ARM AP)
* cheza (npcx EC, ARM AP)
BRANCH=master
Change-Id: Ifa830e8e509ff16b36b4dcc86617869b1cb86ac3
Signed-off-by: Alexandru M Stan <amstan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1772490
Reviewed-by: Jett Rink <jettrink@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/config.h | 6 | ||||
-rw-r--r-- | include/hooks.h | 7 | ||||
-rw-r--r-- | include/i2c.h | 8 |
3 files changed, 18 insertions, 3 deletions
diff --git a/include/config.h b/include/config.h index c9754bc649..a0a5bf6f47 100644 --- a/include/config.h +++ b/include/config.h @@ -2237,7 +2237,11 @@ */ #undef CONFIG_I2C_XFER_BOARD_CALLBACK -/* EC uses an I2C master interface */ +/* + * EC uses an I2C master interface. + * Note: if this is defined, i2c_init() will be called + * automatically at board boot. + */ #undef CONFIG_I2C_MASTER /* EC uses an I2C slave interface */ diff --git a/include/hooks.h b/include/hooks.h index c28e2e58d8..e30c420fbb 100644 --- a/include/hooks.h +++ b/include/hooks.h @@ -21,7 +21,12 @@ enum hook_priority { HOOK_PRIO_INIT_DMA = HOOK_PRIO_FIRST + 1, /* LPC inits before modules which need memory-mapped I/O */ HOOK_PRIO_INIT_LPC = HOOK_PRIO_FIRST + 1, - /* I2C is needed before chipset inits (battery communications). */ + /* + * I2C dependents (battery, sensors, etc), everything but the + * controllers. I2C controller is now initialized in main.c + * TODO(b/138384267): Split this hook up and name the resulting + * ones more semantically. + */ HOOK_PRIO_INIT_I2C = HOOK_PRIO_FIRST + 2, /* Chipset inits before modules which need to know its initial state. */ HOOK_PRIO_INIT_CHIPSET = HOOK_PRIO_FIRST + 3, diff --git a/include/i2c.h b/include/i2c.h index dd237e5354..0d68b5bc90 100644 --- a/include/i2c.h +++ b/include/i2c.h @@ -447,9 +447,15 @@ enum ec_status i2c_get_protocol_info(struct host_cmd_handler_args *args); void i2c_data_received(int port, uint8_t *buf, int len); int i2c_set_response(int port, uint8_t *buf, int len); +/* + * Initialize i2c master controller. Automatically called at board boot + * if CONFIG_I2C_MASTER is defined. + */ +void i2c_init(void); + /** * Initialize i2c master ports. This function can be called for cases where i2c - * ports are not initialized by default via a hook call. + * ports are not initialized by default from main.c. */ void i2cm_init(void); |