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: 2337551 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id D47DA3FC54 for ; Tue, 26 Mar 2013 14:23:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934461Ab3CZOX2 (ORCPT ); Tue, 26 Mar 2013 10:23:28 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:36896 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933449Ab3CZOX1 (ORCPT ); Tue, 26 Mar 2013 10:23:27 -0400 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>; Tue, 26 Mar 2013 23:23:26 +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 Cc: Jaemin Yoo 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 Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.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 */