From: John Crispin Date: Fri, 10 Oct 2014 08:56:53 +0000 (+0000) Subject: ralink: various i2c related fixes X-Git-Tag: reboot~5681 X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=1bbc5de86eb165c0993779ed7e319b18901da744;p=openwrt%2Fstaging%2Fchunkeey.git ralink: various i2c related fixes Signed-off-by: John Crispin SVN-Revision: 42868 --- diff --git a/target/linux/ramips/patches-3.14/0052-i2c-MIPS-adds-ralink-I2C-driver.patch b/target/linux/ramips/patches-3.14/0052-i2c-MIPS-adds-ralink-I2C-driver.patch index a3b03116e2..29cb52a776 100644 --- a/target/linux/ramips/patches-3.14/0052-i2c-MIPS-adds-ralink-I2C-driver.patch +++ b/target/linux/ramips/patches-3.14/0052-i2c-MIPS-adds-ralink-I2C-driver.patch @@ -75,8 +75,8 @@ Index: linux-3.14.18/drivers/i2c/busses/Makefile Index: linux-3.14.18/drivers/i2c/busses/i2c-ralink.c =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ linux-3.14.18/drivers/i2c/busses/i2c-ralink.c 2014-10-06 15:53:32.416500362 +0200 -@@ -0,0 +1,298 @@ ++++ linux-3.14.18/drivers/i2c/busses/i2c-ralink.c 2014-10-09 19:38:29.242416182 +0200 +@@ -0,0 +1,299 @@ +/* + * drivers/i2c/busses/i2c-ralink.c + * @@ -107,7 +107,6 @@ Index: linux-3.14.18/drivers/i2c/busses/i2c-ralink.c +#include +#include +#include -+#include +#include + +#include @@ -200,7 +199,7 @@ Index: linux-3.14.18/drivers/i2c/busses/i2c-ralink.c + int nblock = msg->len / READ_BLOCK; + int rem = msg->len % READ_BLOCK; + int ret = 0; -+ /*printk("i2c handle msg len:%d\n",msg->len);*/ ++ + if (msg->flags & I2C_M_TEN) { + printk("10 bits addr not supported\n"); + return -EINVAL; @@ -209,14 +208,16 @@ Index: linux-3.14.18/drivers/i2c/busses/i2c-ralink.c + if (msg->flags & I2C_M_RD) { + for (i = 0; i < nblock; i++) { + if (rt_i2c_wait_idle()) { -+ printk("i2c-read line busy\n"); -+ return -ETIMEDOUT; -+ } ++ printk("i2c-read line busy\n"); ++ return -ETIMEDOUT; ++ } + rt_i2c_w32(READ_BLOCK - 1, REG_BYTECNT_REG); + rt_i2c_w32(READ_CMD, REG_STARTXFR_REG); + for (j = 0; j < READ_BLOCK; j++) { -+ if (rt_i2c_wait_rx_done()<0) ret = rt_i2c_wait_rx_done(); -+ if (rt_i2c_get_ack()<0) ret = rt_i2c_get_ack(); ++ if (rt_i2c_wait_rx_done() < 0) ++ ret = rt_i2c_wait_rx_done(); ++ if (rt_i2c_get_ack() < 0) ++ ret = rt_i2c_get_ack(); + msg->buf[pos++] = rt_i2c_r32(REG_DATAIN_REG); + } + } @@ -225,13 +226,15 @@ Index: linux-3.14.18/drivers/i2c/busses/i2c-ralink.c + printk("i2c-read line busy\n"); + return -ETIMEDOUT; + } -+ if (rem){ -+ rt_i2c_w32(rem - 1, REG_BYTECNT_REG); -+ rt_i2c_w32(READ_CMD, REG_STARTXFR_REG); ++ if (rem) { ++ rt_i2c_w32(rem - 1, REG_BYTECNT_REG); ++ rt_i2c_w32(READ_CMD, REG_STARTXFR_REG); + } + for (i = 0; i < rem; i++) { -+ if (rt_i2c_wait_rx_done()<0) ret = rt_i2c_wait_rx_done(); -+ if (rt_i2c_get_ack() <0) ret = rt_i2c_get_ack(); ++ if (rt_i2c_wait_rx_done() < 0) ++ ret = rt_i2c_wait_rx_done(); ++ if (rt_i2c_get_ack() < 0) ++ ret = rt_i2c_get_ack(); + + msg->buf[pos++] = rt_i2c_r32(REG_DATAIN_REG); + } @@ -245,10 +248,10 @@ Index: linux-3.14.18/drivers/i2c/busses/i2c-ralink.c + rt_i2c_w32(msg->buf[i], REG_DATAOUT_REG); + rt_i2c_w32(WRITE_CMD, REG_STARTXFR_REG); + -+ if (rt_i2c_wait_tx_done()<0) ret = rt_i2c_wait_tx_done(); -+ if (rt_i2c_get_ack()<0) ret = rt_i2c_get_ack(); -+ -+ ++ if (rt_i2c_wait_tx_done() < 0) ++ ret = rt_i2c_wait_tx_done(); ++ if (rt_i2c_get_ack() < 0) ++ ret = rt_i2c_get_ack(); + } + } + @@ -325,8 +328,6 @@ Index: linux-3.14.18/drivers/i2c/busses/i2c-ralink.c + if (ret) + return ret; + -+ of_i2c_register_devices(adapter); -+ + platform_set_drvdata(pdev, adapter); + + dev_info(&pdev->dev, "loaded\n");