mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-19 03:15:00 +00:00
i2c: mvtwsi: Add support for DM clocks and resets
The controller may need to have clocks/resets enabled for it to work. Add support for this. Since the clocks/resets are optional on some platforms (per the device tree binding), do not prevent probing the controller if they are missing. Signed-off-by: Samuel Holland <samuel@sholland.org> Reviewed-by: Heiko Schocher <hs@denx.de>
This commit is contained in:
parent
e53979cd34
commit
06cec894a5
1 changed files with 13 additions and 0 deletions
|
@ -17,7 +17,9 @@
|
||||||
#include <linux/bitops.h>
|
#include <linux/bitops.h>
|
||||||
#include <linux/compat.h>
|
#include <linux/compat.h>
|
||||||
#if CONFIG_IS_ENABLED(DM_I2C)
|
#if CONFIG_IS_ENABLED(DM_I2C)
|
||||||
|
#include <clk.h>
|
||||||
#include <dm.h>
|
#include <dm.h>
|
||||||
|
#include <reset.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
DECLARE_GLOBAL_DATA_PTR;
|
DECLARE_GLOBAL_DATA_PTR;
|
||||||
|
@ -835,7 +837,18 @@ static int mvtwsi_i2c_bind(struct udevice *bus)
|
||||||
static int mvtwsi_i2c_probe(struct udevice *bus)
|
static int mvtwsi_i2c_probe(struct udevice *bus)
|
||||||
{
|
{
|
||||||
struct mvtwsi_i2c_dev *dev = dev_get_priv(bus);
|
struct mvtwsi_i2c_dev *dev = dev_get_priv(bus);
|
||||||
|
struct reset_ctl reset;
|
||||||
|
struct clk clk;
|
||||||
uint actual_speed;
|
uint actual_speed;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = reset_get_by_index(bus, 0, &reset);
|
||||||
|
if (!ret)
|
||||||
|
reset_deassert(&reset);
|
||||||
|
|
||||||
|
ret = clk_get_by_index(bus, 0, &clk);
|
||||||
|
if (!ret)
|
||||||
|
clk_enable(&clk);
|
||||||
|
|
||||||
__twsi_i2c_init(dev->base, dev->speed, dev->slaveadd, &actual_speed);
|
__twsi_i2c_init(dev->base, dev->speed, dev->slaveadd, &actual_speed);
|
||||||
dev->speed = actual_speed;
|
dev->speed = actual_speed;
|
||||||
|
|
Loading…
Add table
Reference in a new issue