From patchwork Sat Nov 3 01:51:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Ying-22455 X-Patchwork-Id: 992582 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=nxp.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42n28X6Zc4zB6LJ for ; Sat, 3 Nov 2018 12:55:40 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728356AbeKCLFN (ORCPT ); Sat, 3 Nov 2018 07:05:13 -0400 Received: from inva021.nxp.com ([92.121.34.21]:40406 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728233AbeKCLFN (ORCPT ); Sat, 3 Nov 2018 07:05:13 -0400 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 117E82000C8; Sat, 3 Nov 2018 02:55:38 +0100 (CET) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 293B7200019; Sat, 3 Nov 2018 02:55:36 +0100 (CET) Received: from titan.ap.freescale.net (TITAN.ap.freescale.net [10.192.208.233]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id 5EF1E402DF; Sat, 3 Nov 2018 09:55:33 +0800 (SGT) From: ying.zhang22455@nxp.com To: linux-i2c@vger.kernel.org Cc: leoyang.li@nxp.com, Zhang Ying-22455 Subject: [PATCH v2] i2c: imx: add workaround for erratum ERR010027 Date: Sat, 3 Nov 2018 09:51:32 +0800 Message-Id: <20181103015132.37498-1-ying.zhang22455@nxp.com> X-Mailer: git-send-email 2.14.1 X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org From: Zhang Ying-22455 ERR010027: Attempting a start cycle while the bus is busy may generate a short clock pulse. Software must ensure that the I2C BUS is idle by checking the bus busy before switching to master mode and attempting a Start cycle. Signed-off-by: Zhang Ying-22455 --- drivers/i2c/busses/i2c-imx.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-) diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c index c406700..2ab24bd 100644 --- a/drivers/i2c/busses/i2c-imx.c +++ b/drivers/i2c/busses/i2c-imx.c @@ -890,6 +890,14 @@ static int i2c_imx_xfer(struct i2c_adapter *adapter, dev_dbg(&i2c_imx->adapter.dev, "<%s>\n", __func__); + /* + * workround for ERR010027: ensure that the I2C BUS is idle + * before switching to master mode and attempting a Start cycle + */ + result = i2c_imx_bus_busy(i2c_imx, 0); + if (result) + goto out; + result = pm_runtime_get_sync(i2c_imx->adapter.dev.parent); if (result < 0) goto out;