{"id":797174,"url":"http://patchwork.ozlabs.org/api/patches/797174/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/patch/1501760891-13982-1-git-send-email-w.egorov@phytec.de/","project":{"id":18,"url":"http://patchwork.ozlabs.org/api/projects/18/?format=json","name":"U-Boot","link_name":"uboot","list_id":"u-boot.lists.denx.de","list_email":"u-boot@lists.denx.de","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<1501760891-13982-1-git-send-email-w.egorov@phytec.de>","list_archive_url":null,"date":"2017-08-03T11:48:11","name":"[U-Boot] rockchip: i2c: fix >32 byte reads","commit_ref":"5deaa530280fda91b8fef632c62c94e7bfd89561","pull_url":null,"state":"accepted","archived":false,"hash":"cb759d99421c5afffa938fdc3312de245ab3c94f","submitter":{"id":68736,"url":"http://patchwork.ozlabs.org/api/people/68736/?format=json","name":"Wadim Egorov","email":"w.egorov@phytec.de"},"delegate":{"id":69486,"url":"http://patchwork.ozlabs.org/api/users/69486/?format=json","username":"ptomsich","first_name":"Philipp","last_name":"Tomsich","email":"philipp.tomsich@theobroma-systems.com"},"mbox":"http://patchwork.ozlabs.org/project/uboot/patch/1501760891-13982-1-git-send-email-w.egorov@phytec.de/mbox/","series":[],"comments":"http://patchwork.ozlabs.org/api/patches/797174/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/797174/checks/","tags":{},"related":[],"headers":{"Return-Path":"<u-boot-bounces@lists.denx.de>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":"ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.denx.de\n\t(client-ip=81.169.180.215; helo=lists.denx.de;\n\tenvelope-from=u-boot-bounces@lists.denx.de;\n\treceiver=<UNKNOWN>)","Received":["from lists.denx.de (dione.denx.de [81.169.180.215])\n\tby ozlabs.org (Postfix) with ESMTP id 3xNSxM5CZZz9s82\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu,  3 Aug 2017 21:48:23 +1000 (AEST)","by lists.denx.de (Postfix, from userid 105)\n\tid 6A4DDC21D93; Thu,  3 Aug 2017 11:48:16 +0000 (UTC)","from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id 4B609C21C73;\n\tThu,  3 Aug 2017 11:48:14 +0000 (UTC)","by lists.denx.de (Postfix, from userid 105)\n\tid 27AC4C21C73; Thu,  3 Aug 2017 11:48:13 +0000 (UTC)","from root.phytec.de (mail.x-arc.de [217.6.246.34])\n\tby lists.denx.de (Postfix) with ESMTP id BC65DC21C72\n\tfor <u-boot@lists.denx.de>; Thu,  3 Aug 2017 11:48:12 +0000 (UTC)","from idefix.phytec.de (idefix.phytec.de [172.16.0.10])\n\tby root.phytec.de (Postfix) with ESMTP id D8C49A0030A;\n\tThu,  3 Aug 2017 13:49:33 +0200 (CEST)","from augenblix.phytec.de ([172.16.0.56])\n\tby idefix.phytec.de (IBM Domino Release 9.0.1FP7)\n\twith ESMTP id 2017080313481178-257273 ;\n\tThu, 3 Aug 2017 13:48:11 +0200 "],"X-Spam-Checker-Version":"SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de","X-Spam-Level":"","X-Spam-Status":"No, score=0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE\n\tautolearn=unavailable autolearn_force=no version=3.4.0","From":"Wadim Egorov <w.egorov@phytec.de>","To":"u-boot@lists.denx.de, sjg@chromium.org, hs@denx.de","Date":"Thu, 3 Aug 2017 13:48:11 +0200","Message-Id":"<1501760891-13982-1-git-send-email-w.egorov@phytec.de>","X-Mailer":"git-send-email 1.9.1","X-MIMETrack":"Itemize by SMTP Server on Idefix/Phytec(Release 9.0.1FP7|August\n\t17, 2016) at 03.08.2017 13:48:11,\n\tSerialize by Router on Idefix/Phytec(Release 9.0.1FP7|August  17,\n\t2016) at\n\t03.08.2017 13:48:11, Serialize complete at 03.08.2017 13:48:11","X-TNEFEvaluated":"1","Subject":"[U-Boot] [PATCH] rockchip: i2c: fix >32 byte reads","X-BeenThere":"u-boot@lists.denx.de","X-Mailman-Version":"2.1.18","Precedence":"list","List-Id":"U-Boot discussion <u-boot.lists.denx.de>","List-Unsubscribe":"<https://lists.denx.de/options/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=unsubscribe>","List-Archive":"<http://lists.denx.de/pipermail/u-boot/>","List-Post":"<mailto:u-boot@lists.denx.de>","List-Help":"<mailto:u-boot-request@lists.denx.de?subject=help>","List-Subscribe":"<https://lists.denx.de/listinfo/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=subscribe>","MIME-Version":"1.0","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"u-boot-bounces@lists.denx.de","Sender":"\"U-Boot\" <u-boot-bounces@lists.denx.de>"},"content":"The hw can read up to 32 bytes at a time. If we need\nmore than one chunk, we have to enter the plain RX mode.\n\nSigned-off-by: Wadim Egorov <w.egorov@phytec.de>\n---\n drivers/i2c/rk_i2c.c | 19 ++++++++++++++++---\n 1 file changed, 16 insertions(+), 3 deletions(-)","diff":"diff --git a/drivers/i2c/rk_i2c.c b/drivers/i2c/rk_i2c.c\nindex 8bc045a..68e6653 100644\n--- a/drivers/i2c/rk_i2c.c\n+++ b/drivers/i2c/rk_i2c.c\n@@ -164,6 +164,7 @@ static int rk_i2c_read(struct rk_i2c *i2c, uchar chip, uint reg, uint r_len,\n \tuint rxdata;\n \tuint i, j;\n \tint err;\n+\tbool snd_chunk = false;\n \n \tdebug(\"rk_i2c_read: chip = %d, reg = %d, r_len = %d, b_len = %d\\n\",\n \t      chip, reg, r_len, b_len);\n@@ -184,15 +185,26 @@ static int rk_i2c_read(struct rk_i2c *i2c, uchar chip, uint reg, uint r_len,\n \n \twhile (bytes_remain_len) {\n \t\tif (bytes_remain_len > RK_I2C_FIFO_SIZE) {\n-\t\t\tcon = I2C_CON_EN | I2C_CON_MOD(I2C_MODE_TRX);\n+\t\t\tcon = I2C_CON_EN;\n \t\t\tbytes_xferred = 32;\n \t\t} else {\n-\t\t\tcon = I2C_CON_EN | I2C_CON_MOD(I2C_MODE_TRX) |\n-\t\t\t\tI2C_CON_LASTACK;\n+\t\t\t/*\n+\t\t\t * The hw can read up to 32 bytes at a time. If we need\n+\t\t\t * more than one chunk, send an ACK after the last byte.\n+\t\t\t */\n+\t\t\tcon = I2C_CON_EN | I2C_CON_LASTACK;\n \t\t\tbytes_xferred = bytes_remain_len;\n \t\t}\n \t\twords_xferred = DIV_ROUND_UP(bytes_xferred, 4);\n \n+\t\t/*\n+\t\t * make sure we are in plain RX mode if we read a second chunk\n+\t\t */\n+\t\tif (snd_chunk)\n+\t\t\tcon |= I2C_CON_MOD(I2C_MODE_RX);\n+\t\telse\n+\t\t\tcon |= I2C_CON_MOD(I2C_MODE_TRX);\n+\n \t\twritel(con, &regs->con);\n \t\twritel(bytes_xferred, &regs->mrxcnt);\n \t\twritel(I2C_MBRFIEN | I2C_NAKRCVIEN, &regs->ien);\n@@ -227,6 +239,7 @@ static int rk_i2c_read(struct rk_i2c *i2c, uchar chip, uint reg, uint r_len,\n \t\t}\n \n \t\tbytes_remain_len -= bytes_xferred;\n+\t\tsnd_chunk = true;\n \t\tdebug(\"I2C Read bytes_remain_len %d\\n\", bytes_remain_len);\n \t}\n \n","prefixes":["U-Boot"]}