Skip to content

Commit

Permalink
i2c: meson: Fix wrong speed use from probe
Browse files Browse the repository at this point in the history
[ Upstream commit cb13aa1 ]

Having meson_i2c_set_clk_div after i2c_add_adapter
causes issues for client drivers that try to use
the bus before the requested speed is applied.

The bus can be used just after i2c_add_adapter, so
move i2c_add_adapter to the final step as
meson_i2c_set_clk_div needs to be called before
the bus is used.

Fixes: 09af1c2 ("i2c: meson: set clock divider in probe instead of setting it for each transfer")
Signed-off-by: Lucas Tanure <[email protected]>
Reviewed-by: Neil Armstrong <[email protected]>
Signed-off-by: Wolfram Sang <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
  • Loading branch information
lucastanure authored and gregkh committed Apr 8, 2022
1 parent e23e1e9 commit 2e67ec3
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions drivers/i2c/busses/i2c-meson.c
Original file line number Diff line number Diff line change
Expand Up @@ -465,18 +465,18 @@ static int meson_i2c_probe(struct platform_device *pdev)
*/
meson_i2c_set_mask(i2c, REG_CTRL, REG_CTRL_START, 0);

ret = i2c_add_adapter(&i2c->adap);
if (ret < 0) {
clk_disable_unprepare(i2c->clk);
return ret;
}

/* Disable filtering */
meson_i2c_set_mask(i2c, REG_SLAVE_ADDR,
REG_SLV_SDA_FILTER | REG_SLV_SCL_FILTER, 0);

meson_i2c_set_clk_div(i2c, timings.bus_freq_hz);

ret = i2c_add_adapter(&i2c->adap);
if (ret < 0) {
clk_disable_unprepare(i2c->clk);
return ret;
}

return 0;
}

Expand Down

0 comments on commit 2e67ec3

Please sign in to comment.