From patchwork Tue Mar 26 14:29:56 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prasanna Kumar X-Patchwork-Id: 2337561 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id E9B663FC54 for ; Tue, 26 Mar 2013 14:26:49 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UKUn6-0006cN-B9; Tue, 26 Mar 2013 14:23:56 +0000 Received: from mailout3.samsung.com ([203.254.224.33]) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UKUme-0006MV-Nz for linux-arm-kernel@lists.infradead.org; Tue, 26 Mar 2013 14:23:30 +0000 Received: from epcpsbgr4.samsung.com (u144.gpu120.samsung.co.kr [203.254.230.144]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MK9005SFUN1ZU30@mailout3.samsung.com> for linux-arm-kernel@lists.infradead.org; Tue, 26 Mar 2013 23:23:25 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [172.20.52.123]) by epcpsbgr4.samsung.com (EPCPMTA) with SMTP id EC.D3.02019.D5FA1515; Tue, 26 Mar 2013 23:23:25 +0900 (KST) X-AuditID: cbfee690-b7f656d0000007e3-a6-5151af5d5395 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 07.70.17838.D5FA1515; Tue, 26 Mar 2013 23:23:25 +0900 (KST) Received: from user-ubuntu.sisodomain.com ([107.108.83.235]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MK90074QUMHLQ30@mmp2.samsung.com>; Tue, 26 Mar 2013 23:23:25 +0900 (KST) From: Prasanna Kumar To: Wolfram Sang , Kukjin Kim , linux-samsung-soc@vger.kernel.org, linux-i2c@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH] i2c: s3c2410: Add SMBus emulation for block read Date: Tue, 26 Mar 2013 19:59:56 +0530 Message-id: <1364308196-10101-1-git-send-email-prasanna.ps@samsung.com> X-Mailer: git-send-email 1.7.5.4 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrMLMWRmVeSWpSXmKPExsWyRsSkWjd2fWCgwbaT5hZ3Vm5nsehdcJXN YtPja6wWHX+/MFrMOL+PyWLliVnMDmwem5fUe/RtWcXocfLUExaPz5vkAliiuGxSUnMyy1KL 9O0SuDJOfnUruMRf0TRtNnMD40WeLkYODgkBE4mjWw27GDmBTDGJC/fWs3UxcnEICSxllJh/ 7TULRMJEYsGvM0wQiemMEpf/noWq6maSuPVnLytIFZuAnsT8GcvZQRIiAhsYJV7PWQ+WYBZQ ldj/upkJxBYWcJTYsOYUWJwFJH6ymQ3E5hVwl7h1fBs7xDoFiV9HVrGCDJIQeM8mcfHNaWaI BgGJb5MPsUDcLSux6QAzRL2kxMEVN1gmMAouYGRYxSiaWpBcUJyUXmSiV5yYW1yal66XnJ+7 iREYoKf/PZuwg/HeAetDjMlA4yYyS4km5wMDPK8k3tDYzMjC1MTU2Mjc0ow0YSVxXvUW60Ah gfTEktTs1NSC1KL4otKc1OJDjEwcnFINjPrPv0RnXkkWrPrw6ouRdr2T2sTzojPfLTn2ZseF 1yZuDaLNddwdn5OW/fsiIXtkgtC1p8L6jcf1l78M/rYyUXnOR80YRhuZqlc7+ld7yYjm3dJO 3fLlu82au6vnGN3co29Vs8JlSnXLgmaXb2dy9s6xmRp6xeFJdKjWP8n9259X9iQ5VibPVVNi Kc5INNRiLipOBABNVX7gZgIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrIIsWRmVeSWpSXmKPExsVy+t9jQd3Y9YGBBt+W6lvcWbmdxaJ3wVU2 i02Pr7FadPz9wmgx4/w+JouVJ2YxO7B5bF5S79G3ZRWjx8lTT1g8Pm+SC2CJamC0yUhNTEkt UkjNS85PycxLt1XyDo53jjc1MzDUNbS0MFdSyEvMTbVVcvEJ0HXLzAFarqRQlphTChQKSCwu VtK3wzQhNMRN1wKmMULXNyQIrsfIAA0krGHMOPnVreASf0XTtNnMDYwXeboYOTkkBEwkFvw6 wwRhi0lcuLeerYuRi0NIYDqjxOW/Z6GcbiaJW3/2soJUsQnoScyfsZwdJCEisIFR4vWc9WAJ ZgFVif2vm8FGCQs4SmxYcwoszgISP9nMBmLzCrhL3Dq+jR1inYLEryOrWCcwci9gZFjFKJpa kFxQnJSea6hXnJhbXJqXrpecn7uJERwBz6R2MK5ssDjEKMDBqMTDuyE4IFCINbGsuDL3EKME B7OSCG/NwsBAId6UxMqq1KL8+KLSnNTiQ4zJQNsnMkuJJucDozOvJN7Q2MTc1NjU0sTCxMyS NGElcd4DrdaBQgLpiSWp2ampBalFMFuYODilGhj1P8jnfZUPtp0/+bT6wsL96174vli6Pd/0 jYqs8/59QUu1pjHWTCphOZD/6wu/3/9492JGUdfCvokFF1miDEIrZUtnpV8LW/s5K/jEwncx U3/5TOKybl/+oE3L9Fq57gbhi0yyd3X54p7IPbj+cHUbo7BAwtefoaf/arFwrTk92yx1QUx3 lK8SS3FGoqEWc1FxIgAOCUXixAIAAA== DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130326_102329_021122_2ED5D9DF X-CRM114-Status: GOOD ( 11.20 ) X-Spam-Score: -8.1 (--------) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-8.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [203.254.224.33 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -1.3 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.1 HDRS_LCASE Odd capitalization of message header Cc: Jaemin Yoo X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Jaemin Yoo SMBus read and write are supported by the emulation layer of i2c framework if the controller doesn't have SMBus features. I2C_M_RECV_LEN flag is used to let i2c drivers know rx length is not yet determined but will be read to the first byte in rx buffer. s3c2410 doesn't handle this flag. So only one byte is read from slave. There fore following two features are added to the driver code. 1. skip rx length check if I2C_M_RECV_LEN is set and the length is 1. 2. add actual bytes to the rx length after reading first bytes if I2C_M_RECV_LEN. I2C_M_RECV_LEN is only set for SMBus command. So this code does not affect legacy codes which only use i2c command for s3c2410. Signed-off-by: Jaemin Yoo Tested-by: Prasanna Kumar --- drivers/i2c/busses/i2c-s3c2410.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c index 17c5c37..e4ab9ea 100644 --- a/drivers/i2c/busses/i2c-s3c2410.c +++ b/drivers/i2c/busses/i2c-s3c2410.c @@ -309,6 +309,12 @@ static inline int is_lastmsg(struct s3c24xx_i2c *i2c) static inline int is_msglast(struct s3c24xx_i2c *i2c) { + /* msg->len is always 1 for the first byte of smbus block read. + * Actual length will be read from slave. More bytes will be + * read according to the length then. */ + if (i2c->msg->flags & I2C_M_RECV_LEN && i2c->msg->len == 1) + return 0; + return i2c->msg_ptr == i2c->msg->len-1; } @@ -448,6 +454,9 @@ static int i2c_s3c_irq_nextbyte(struct s3c24xx_i2c *i2c, unsigned long iicstat) byte = readb(i2c->regs + S3C2410_IICDS); i2c->msg->buf[i2c->msg_ptr++] = byte; + /* Add actual length to read for smbus block read */ + if (i2c->msg->flags & I2C_M_RECV_LEN && i2c->msg->len == 1) + i2c->msg->len += byte; prepare_read: if (is_msglast(i2c)) { /* last byte of buffer */