diff options
author | Jes B. Klinke <jbk@chromium.org> | 2023-05-05 11:22:42 -0700 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2023-05-05 20:20:27 +0000 |
commit | 4a933541c9efd86a0899dfadfc7be33ead92d5e5 (patch) | |
tree | a8775982bc7ac26bb821e41996b8f45a63016b42 | |
parent | 69004202ef54a678e151b402febba2a81bf7eff2 (diff) | |
download | chrome-ec-4a933541c9efd86a0899dfadfc7be33ead92d5e5.tar.gz |
chip/stm32: Support dynamic I2C speed on L4/L5 series
The file i2c-stm32l4.c practically already had support for changing I2C
speed. This CL renames and exports the function for setting speed, such
that i2c_controller.c can call it.
BUG=none
TEST=Observe HyperDebug I2C still working, and now able to change speed
Change-Id: I2fbe674795f9e8ed0b8d324cc1ff68f4df4174a4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4506619
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Commit-Queue: Jes Klinke <jbk@chromium.org>
Tested-by: Jes Klinke <jbk@chromium.org>
-rw-r--r-- | chip/stm32/i2c-stm32l4.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/chip/stm32/i2c-stm32l4.c b/chip/stm32/i2c-stm32l4.c index db0077c275..a4b9452379 100644 --- a/chip/stm32/i2c-stm32l4.c +++ b/chip/stm32/i2c-stm32l4.c @@ -116,10 +116,9 @@ static const uint32_t timingr_regs[I2C_CLK_SRC_COUNT][I2C_FREQ_COUNT] = { }, }; -static void i2c_set_freq_port(const struct i2c_port_t *p, - enum stm32_i2c_clk_src src, enum i2c_freq freq) +int chip_i2c_set_freq(int port, enum i2c_freq freq) { - int port = p->port; + enum stm32_i2c_clk_src src = I2C_CLK_SRC_16MHZ; /* Disable port */ STM32_I2C_CR1(port) = 0; @@ -130,6 +129,13 @@ static void i2c_set_freq_port(const struct i2c_port_t *p, STM32_I2C_CR1(port) = STM32_I2C_CR1_PE; pdata[port].freq = freq; + + return EC_SUCCESS; +} + +enum i2c_freq chip_i2c_get_freq(int port) +{ + return pdata[port].freq; } /** @@ -142,7 +148,6 @@ static void i2c_init_port(const struct i2c_port_t *p) int port = p->port; uint32_t val; enum i2c_freq freq; - enum stm32_i2c_clk_src src = I2C_CLK_SRC_16MHZ; /* Enable I2C clock */ if (!(STM32_RCC_APB1ENR1 & (1 << (21 + port)))) @@ -176,7 +181,7 @@ static void i2c_init_port(const struct i2c_port_t *p) } /* Set up initial bus frequencies */ - i2c_set_freq_port(p, src, freq); + chip_i2c_set_freq(p->port, freq); /* Set up default timeout */ i2c_set_timeout(port, 0); |