i2c2: i2c@20055000 {
compatible = "rockchip,rk30-i2c";
- reg = <0x20055000 0x1000>;
+ reg = <0x20056000 0x1000>;
interrupts = <GIC_SPI 42 IRQ_TYPE_LEVEL_HIGH>;
#address-cells = <1>;
#size-cells = <0>;
i2c3: i2c@20059000 {
compatible = "rockchip,rk30-i2c";
- reg = <0x20059000 0x1000>;
+ reg = <0x2005a000 0x1000>;
interrupts = <GIC_SPI 43 IRQ_TYPE_LEVEL_HIGH>;
#address-cells = <1>;
#size-cells = <0>;
i2c4: i2c@2005d000 {
compatible = "rockchip,rk30-i2c";
- reg = <0x2005d000 0x1000>;
+ reg = <0x2005c000 0x1000>;
interrupts = <GIC_SPI 52 IRQ_TYPE_LEVEL_HIGH>;
#address-cells = <1>;
#size-cells = <0>;
*/
static void rockchip_i2c_set_clk(struct rockchip_i2c *i2c, unsigned long scl_rate)
{
- unsigned long i2c_rate = clk_get_rate(i2c->clk);
+ unsigned long i2c_rate = i2c->i2c_rate;
int div, divl, divh;
- if ((scl_rate == i2c->scl_rate) && (i2c_rate == i2c->i2c_rate))
+ if (scl_rate == i2c->scl_rate)
return;
- i2c->i2c_rate = i2c_rate;
i2c->scl_rate = scl_rate;
div = rockchip_ceil(i2c_rate, (scl_rate * 8)) - 2;
if (unlikely(div < 0)) {
static void rockchip_i2c_init_hw(struct rockchip_i2c *i2c, unsigned long scl_rate)
{
i2c->scl_rate = 0;
- clk_prepare_enable(i2c->clk);
+// clk_prepare_enable(i2c->clk);
rockchip_i2c_set_clk(i2c, scl_rate);
- clk_disable_unprepare(i2c->clk);
+// clk_disable_unprepare(i2c->clk);
}
/* returns TRUE if we this is the last byte in the current message */
struct rockchip_i2c *i2c = i2c_get_adapdata(adap);
unsigned long scl_rate = i2c->scl_rate;
- clk_prepare_enable(i2c->clk);
+// clk_prepare_enable(i2c->clk);
if (i2c->check_idle) {
int state, retry = 10;
while (retry--) {
ret = rockchip_i2c_doxfer(i2c, msgs, num);
i2c_dbg(i2c->dev, "i2c transfer stop: addr: 0x%04x, state: %d, ret: %d\n", msgs[0].addr, ret, i2c->state);
- clk_disable_unprepare(i2c->clk);
+// clk_disable_unprepare(i2c->clk);
return (ret < 0) ? ret : num;
}
dev_err(&pdev->dev, "no gpio pinctrl state\n");
return PTR_ERR(i2c->gpio_state);
}
+ pinctrl_select_state(i2c->dev->pins->p, i2c->gpio_state);
gpio_direction_input(i2c->sda_gpio);
gpio_direction_input(i2c->scl_gpio);
pinctrl_select_state(i2c->dev->pins->p, i2c->dev->pins->default_state);
}
clk_prepare_enable(i2c->clk); // FIXME: enable i2c clock temporarily
+ i2c->i2c_rate = clk_get_rate(i2c->clk);
+
rockchip_i2c_init_hw(i2c, 100 * 1000);
dev_info(&pdev->dev, "%s: Rockchip I2C adapter\n", dev_name(&i2c->adap.dev));