diff options
author | Tom Rini <trini@konsulko.com> | 2019-09-03 07:16:05 -0400 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2019-09-03 07:16:05 -0400 |
commit | f65fb411ed6576e08a22b9d236deba66ef957c31 (patch) | |
tree | c84d3fed3442cbaf1f12212b0c7a935b2730a5dc /drivers | |
parent | 83a5df42614c566c3c642871f683e66a53d228ae (diff) | |
parent | 6dba0864ece3f4006abae8ff9e2ad74f4374359d (diff) | |
download | u-boot-f65fb411ed6576e08a22b9d236deba66ef957c31.tar.gz u-boot-f65fb411ed6576e08a22b9d236deba66ef957c31.tar.xz u-boot-f65fb411ed6576e08a22b9d236deba66ef957c31.zip |
Merge tag 'for-v2019.10-v2' of https://gitlab.denx.de/u-boot/custodians/u-boot-i2c
i2c bugfixes for 2019.10 take 2
- i2c: mxc: add CONFIG_CLK support
If CONFIG_CLK is enabled use clk framework for clock settings.
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/i2c/mxc_i2c.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/drivers/i2c/mxc_i2c.c b/drivers/i2c/mxc_i2c.c index 20f6dc4ecb..786b5a2226 100644 --- a/drivers/i2c/mxc_i2c.c +++ b/drivers/i2c/mxc_i2c.c @@ -149,7 +149,12 @@ static uint8_t i2c_imx_get_clk(struct mxc_i2c_bus *i2c_bus, unsigned int rate) #endif /* Divider value calculation */ +#if CONFIG_IS_ENABLED(CLK) + i2c_clk_rate = clk_get_rate(&i2c_bus->per_clk); +#else i2c_clk_rate = mxc_get_clock(MXC_I2C_CLK); +#endif + div = (i2c_clk_rate + rate - 1) / rate; if (div < i2c_clk_div[0][0]) clk_div = 0; @@ -891,9 +896,22 @@ static int mxc_i2c_probe(struct udevice *bus) i2c_bus->bus = bus; /* Enable clk */ +#if CONFIG_IS_ENABLED(CLK) + ret = clk_get_by_index(bus, 0, &i2c_bus->per_clk); + if (ret) { + printf("Failed to get i2c clk\n"); + return ret; + } + ret = clk_enable(&i2c_bus->per_clk); + if (ret) { + printf("Failed to enable i2c clk\n"); + return ret; + } +#else ret = enable_i2c_clk(1, bus->seq); if (ret < 0) return ret; +#endif /* * See Documentation/devicetree/bindings/i2c/i2c-imx.txt |