From patchwork Fri May 19 16:02:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 9737611 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AA208601A1 for ; Fri, 19 May 2017 16:03:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A292528934 for ; Fri, 19 May 2017 16:03:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 93F862893A; Fri, 19 May 2017 16:03:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EC0B428934 for ; Fri, 19 May 2017 16:03:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752265AbdESQDT (ORCPT ); Fri, 19 May 2017 12:03:19 -0400 Received: from relay4-d.mail.gandi.net ([217.70.183.196]:47576 "EHLO relay4-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752018AbdESQDT (ORCPT ); Fri, 19 May 2017 12:03:19 -0400 Received: from mfilter17-d.gandi.net (mfilter17-d.gandi.net [217.70.178.145]) by relay4-d.mail.gandi.net (Postfix) with ESMTP id ECCC71720F1; Fri, 19 May 2017 18:03:17 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mfilter17-d.gandi.net Received: from relay4-d.mail.gandi.net ([IPv6:::ffff:217.70.183.196]) by mfilter17-d.gandi.net (mfilter17-d.gandi.net [::ffff:10.0.15.180]) (amavisd-new, port 10024) with ESMTP id 4sPv7RpCqY-K; Fri, 19 May 2017 18:03:16 +0200 (CEST) X-Originating-IP: 158.255.198.50 Received: from w540.lan (host-50-static-198-255-158.hosts-appwifi.wifix.org [158.255.198.50]) (Authenticated sender: jacopo@jmondi.org) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id E6123172095; Fri, 19 May 2017 18:03:15 +0200 (CEST) From: Jacopo Mondi To: laurent.pinchart@ideasonboard.com, magnus.damm@gmail.com Cc: linux-renesas-soc@vger.kernel.org Subject: [RFC v4 5/8] media: i2c: ov772x: Force use of SCCB protocol Date: Fri, 19 May 2017 18:02:57 +0200 Message-Id: <1495209780-27342-6-git-send-email-jacopo@jmondi.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1495209780-27342-1-git-send-email-jacopo@jmondi.org> References: <1495209780-27342-1-git-send-email-jacopo@jmondi.org> Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Commit e78902976150 ("i2c: sh_mobile: don't send a stop condition by default inside transfers") makes the i2c_sh_mobile I2C-adapter emit a stop/start sequence between messages in a single transfer only when explicitly requested with I2C_M_STOP. This breaks the ov772x driver in the SH4 Migo-R board as the Omnivision sensor uses the I2C-like SCCB protocol that doesn't support repeated starts: i2c-sh_mobile i2c-sh_mobile.0: Transfer request timed out ov772x 0-0021: Product ID error 92:92 Fix it by marking the client as SCCB, forcing the emission of a stop/start sequence between all messages. As I2C_M_STOP requires the I2C adapter to support protocol mangling, ensure that the I2C_FUNC_PROTOCOL_MANGLING functionality is available. Tested on SH4 Migo-R board, with OV772x now successfully probing soc-camera-pdrv soc-camera-pdrv.0: Probing soc-camera-pdrv.0 ov772x 0-0021: ov7725 Product ID 77:21 Manufacturer ID 7f:a2 Signed-off-by: Jacopo Mondi Suggested-by: Laurent Pinchart Acked-by: Wolfram Sang Reviewed-by: Laurent Pinchart --- drivers/media/i2c/soc_camera/ov772x.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/media/i2c/soc_camera/ov772x.c b/drivers/media/i2c/soc_camera/ov772x.c index 985a367..351abec 100644 --- a/drivers/media/i2c/soc_camera/ov772x.c +++ b/drivers/media/i2c/soc_camera/ov772x.c @@ -1062,11 +1062,13 @@ static int ov772x_probe(struct i2c_client *client, return -EINVAL; } - if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { + if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA | + I2C_FUNC_PROTOCOL_MANGLING)) { dev_err(&adapter->dev, - "I2C-Adapter doesn't support I2C_FUNC_SMBUS_BYTE_DATA\n"); + "I2C-Adapter doesn't support SMBUS_BYTE_DATA or PROTOCOL_MANGLING\n"); return -EIO; } + client->flags |= I2C_CLIENT_SCCB; priv = devm_kzalloc(&client->dev, sizeof(*priv), GFP_KERNEL); if (!priv)