mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-28 00:11:32 +00:00
rockchip: i2c: Update the driver to use the new clock ID
We can use the new clk_get_by_index() function to get the correct clock. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
64b7faa7f9
commit
930bc37423
1 changed files with 22 additions and 16 deletions
|
@ -30,10 +30,9 @@ DECLARE_GLOBAL_DATA_PTR;
|
||||||
|
|
||||||
struct rk_i2c {
|
struct rk_i2c {
|
||||||
struct udevice *clk;
|
struct udevice *clk;
|
||||||
struct udevice *pinctrl;
|
|
||||||
struct i2c_regs *regs;
|
struct i2c_regs *regs;
|
||||||
unsigned int speed;
|
unsigned int speed;
|
||||||
enum periph_id id;
|
int clk_id;
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline void rk_i2c_get_div(int div, int *divh, int *divl)
|
static inline void rk_i2c_get_div(int div, int *divh, int *divl)
|
||||||
|
@ -56,7 +55,7 @@ static void rk_i2c_set_clk(struct rk_i2c *i2c, uint32_t scl_rate)
|
||||||
int div, divl, divh;
|
int div, divl, divh;
|
||||||
|
|
||||||
/* First get i2c rate from pclk */
|
/* First get i2c rate from pclk */
|
||||||
i2c_rate = clk_get_periph_rate(i2c->clk, i2c->id);
|
i2c_rate = clk_get_periph_rate(i2c->clk, i2c->clk_id);
|
||||||
|
|
||||||
div = DIV_ROUND_UP(i2c_rate, scl_rate * 8) - 2;
|
div = DIV_ROUND_UP(i2c_rate, scl_rate * 8) - 2;
|
||||||
divh = 0;
|
divh = 0;
|
||||||
|
@ -352,23 +351,29 @@ int rockchip_i2c_set_bus_speed(struct udevice *bus, unsigned int speed)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int rockchip_i2c_probe(struct udevice *bus)
|
static int rockchip_i2c_ofdata_to_platdata(struct udevice *bus)
|
||||||
{
|
{
|
||||||
struct rk_i2c *i2c = dev_get_priv(bus);
|
struct rk_i2c *priv = dev_get_priv(bus);
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = uclass_get_device(UCLASS_PINCTRL, 0, &i2c->pinctrl);
|
ret = clk_get_by_index(bus, 0, &priv->clk);
|
||||||
if (ret)
|
if (ret < 0) {
|
||||||
|
debug("%s: Could not get clock for %s: %d\n", __func__,
|
||||||
|
bus->name, ret);
|
||||||
return ret;
|
return ret;
|
||||||
ret = uclass_get_device(UCLASS_CLK, 0, &i2c->clk);
|
}
|
||||||
if (ret)
|
priv->clk_id = ret;
|
||||||
return ret;
|
|
||||||
ret = pinctrl_get_periph_id(i2c->pinctrl, bus);
|
return 0;
|
||||||
if (ret < 0)
|
}
|
||||||
return ret;
|
|
||||||
i2c->id = ret;
|
static int rockchip_i2c_probe(struct udevice *bus)
|
||||||
i2c->regs = (void *)dev_get_addr(bus);
|
{
|
||||||
return pinctrl_request(i2c->pinctrl, i2c->id, 0);
|
struct rk_i2c *priv = dev_get_priv(bus);
|
||||||
|
|
||||||
|
priv->regs = (void *)dev_get_addr(bus);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct dm_i2c_ops rockchip_i2c_ops = {
|
static const struct dm_i2c_ops rockchip_i2c_ops = {
|
||||||
|
@ -385,6 +390,7 @@ U_BOOT_DRIVER(i2c_rockchip) = {
|
||||||
.name = "i2c_rockchip",
|
.name = "i2c_rockchip",
|
||||||
.id = UCLASS_I2C,
|
.id = UCLASS_I2C,
|
||||||
.of_match = rockchip_i2c_ids,
|
.of_match = rockchip_i2c_ids,
|
||||||
|
.ofdata_to_platdata = rockchip_i2c_ofdata_to_platdata,
|
||||||
.probe = rockchip_i2c_probe,
|
.probe = rockchip_i2c_probe,
|
||||||
.priv_auto_alloc_size = sizeof(struct rk_i2c),
|
.priv_auto_alloc_size = sizeof(struct rk_i2c),
|
||||||
.ops = &rockchip_i2c_ops,
|
.ops = &rockchip_i2c_ops,
|
||||||
|
|
Loading…
Add table
Reference in a new issue