From patchwork Mon Jul 24 10:55:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Song X-Patchwork-Id: 705932 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4EE48C0015E for ; Mon, 24 Jul 2023 10:52:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232715AbjGXKwS (ORCPT ); Mon, 24 Jul 2023 06:52:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230162AbjGXKwR (ORCPT ); Mon, 24 Jul 2023 06:52:17 -0400 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2061.outbound.protection.outlook.com [40.107.20.61]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17FE0114; Mon, 24 Jul 2023 03:52:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LIDUXLIS+Z8roHuO/psqNtBjxnaoZ0LSwU/UVsdN7qqWRXq6RndauSdd+a4LZBtL2WM/h1zB6934VHvUAutEZEIma9gskIwD7w0cEgIyju38dyDUGpQ82K9dBdGp4XNoH4DD9TXFeXEwCEacr9gReetNs3h1fbb76YIwWZW1WT47NWy3TvHJwmkoeagOhBBpa/31oH5Q5Kc6QFLrfzh7ZMeHq2hLmm0HQzBuBDU3lIgqbad0UywNi7cNYpE8g63HuhI/baBpUgy8HK6awu1wvGlx/TQ+Mv5qMTEQzKXfWRv4j1sjAGUSGjolwwuNqgCc9MPsKbaKj83oPLai62O2Ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=6B52Xpi9DWPuNoI6324N8OwegJ6KPde7ZbNqimD6I+E=; b=lB5MN5JDjUKHadk7s7upEhXU9hkRg2fEmSNQEsgLX2aHn28dJJY90pUO76lwws0afMTOkd9mXy4dJ2i6OMZCgcCjvbqYqIOQkyc9RCuoOliW/yxCkvlwHvXy9LXMj9YE/rAdAHpF281ggCBce7H01b8e1lpFV4fwxXl86oPZA/uZn3BB74IfYgr6G4qdb26xoj2GUbI18XR4fL+EKuQMb2vXwHST9c4E8flwf48Pc9C6qYMlvozmaLsrLZ754EsJbhT31CsZ5mtzLLzrzT4zA4lIejjj9pFunG2NMsRRj8skD4DWz/Rg9E85SUsmxbowoFJKEbn1dH/KSd+hXK00BQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6B52Xpi9DWPuNoI6324N8OwegJ6KPde7ZbNqimD6I+E=; b=L6NkzNU8wUR0x6iVzy5KnCdVDqFE11yJx6J+Gzlsa1MCCB3+gIN55sGPfFOziiX2cvnv+PSgj3rN6ZhWe78czOlS5ehM+0ERV0yi0UIARgzau9gMkJokFTbnwra6eGXcY/sPS9olaRP2GINNGxyMPklEWNLRTteJVyf9hqVQdqs= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5005.eurprd04.prod.outlook.com (2603:10a6:803:57::30) by DBAPR04MB7288.eurprd04.prod.outlook.com (2603:10a6:10:1a3::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.32; Mon, 24 Jul 2023 10:52:06 +0000 Received: from VI1PR04MB5005.eurprd04.prod.outlook.com ([fe80::7f26:a98a:b8c5:f620]) by VI1PR04MB5005.eurprd04.prod.outlook.com ([fe80::7f26:a98a:b8c5:f620%4]) with mapi id 15.20.6609.031; Mon, 24 Jul 2023 10:52:06 +0000 From: carlos.song@nxp.com To: andi.shyti@kernel.org, aisheng.dong@nxp.com, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com Cc: carlos.song@nxp.com, xiaoning.wang@nxp.com, haibo.chen@nxp.com, linux-imx@nxp.com, linux-i2c@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/3] i2c: imx-lpi2c: directly return ISR when detect a NACK Date: Mon, 24 Jul 2023 18:55:44 +0800 Message-Id: <20230724105546.1964059-1-carlos.song@nxp.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: SI2PR01CA0032.apcprd01.prod.exchangelabs.com (2603:1096:4:192::18) To VI1PR04MB5005.eurprd04.prod.outlook.com (2603:10a6:803:57::30) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5005:EE_|DBAPR04MB7288:EE_ X-MS-Office365-Filtering-Correlation-Id: 5185faa0-f32c-4894-2a95-08db8c34057a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: klHiqSx9tAgwVuzsrqOR4qmUsMGRBRkfNZzTiCg4FjoBobrIg00zr2yq0eSGtvrsQafe99fNmRJ0VCnRo5uujkyhjGNGXRn/WzFIMQK2X3OzLubSOvO6HOWugtrPjzWv2qBi4TmbRDcqWjQMQKJUo1sUbwAjBDSptiVQLRRcOomUZvV4gBCSGuQjQyKKsLiFVJqCkv+TMZ159NGNKEY82nAmNFcbh2EdbvWg6r1zpPR7Ra1qvnKTkp1M+X3GCDgYeqNBl8M69bC54F28/eDoVPtMYcYyJhOYL4k/TSf7PHlMxUOUk6qgFQhAjlcpinh5bIZAsc+pONnPBPBLmSqXq+RN2zQ+1PiBkexjic+dGhqVAyvEQwhnM/SZaYR/D2tg1Z82vBTEgAiN3+cUtxtykzaaAcaVIlBCpb3MuOMv1sRPPk/51wIbC7uvVbuXr0rqRS2CASWjk/lKc6IeP0iWEi7bf1JR5v+K45XJPOTOR0B+GxTGDdgoWfSte7pPJHDmVIRQIeQzg1b9A6zPaH7J8DGofUivO6VRUz+s8iPpFzeENFnEvjS5lI4wZVxhqZX3KnUHn2bkKwybysOiRHE+O9VJhah9Vw5FmuwIZspmLqWn9oTsPycBx5DuTrWN+mzA X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5005.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(39860400002)(346002)(376002)(136003)(366004)(396003)(451199021)(41300700001)(8936002)(8676002)(316002)(66556008)(66476007)(66946007)(4326008)(2906002)(478600001)(86362001)(5660300002)(2616005)(6666004)(9686003)(6512007)(6486002)(52116002)(38350700002)(38100700002)(36756003)(83380400001)(26005)(186003)(1076003)(6506007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: BJSeWJNc1SekrAVCPr7jVMKgsWeVNbQh+3XsGa9dwM+3BUir8+flYCu78ndxoewM0qQrtlBERX99lVgnuNf5vuQW3WRtnBfQQ8C+Q83appOy5ZpbtvG5a24fDqpQ/GIQTz9PydFRHJ9dde3sP45JUycu7W7AG5jqzP4tDBIM9xfk7QJnjbvQ8+AVSzd07ZzBainCpi67hpwoH8D458bXWOp4FhdJWAT/Uy9278Yw4EHnWcXf+ZJUafh7SIeQ2y3gGzZKKhKfmuJq9oF7kVNqvukyLRD72C/oHVBVmz9OJIVImL0K3Bp4NlESEZb5SwdqM8KZKHJOdKRChTiNTAXvhxPN+fX+p48ZyC64uO3B1tTM+f8lqyb0uzV9sCGR4uuQh7aWKThCHh39uk5Y3UkjYpOYal6hAUj4NP+Z0Vdf1hKZ+Q8yV4AG9lvoICjqmQFqaPg48bwZpg9nW+E/d/dAM4FvI8CuViVa2m21g7fwbJGI4jWmMFvG/PFnG/1xTkwACC3Kn5YGTTA2d8SiXsnSCCB+M+mYhCtkfa27uH5G4G8bNH25wsWgR8mniwcohcBGm61VsJ4XB3A0Ge8VKR0NsZgpikGrVSmm4DlfEqnVA6bRKICT2Y/9CNSrp5zQPIUXdiiipHwNNuwex7D2f+ypAtt9fHg4UoxyJVEg1b85kxiGjm+lljQqAXH7ZXe2zqg1gcOztG7tel9UR+HPyxxKLI+u6qWJf6bkdSI6XPujynuDZiJh/fsatMx52SIokSrpYe0idI+z44ZsfYylDl9+9vMZzElLrq7Ktc9Rk6T5Myvaqruki+2b3iFF7l6hwvCVopZ+Kej0pw1FaFQ8pDFfV4Lrj2sBUXIO8MoNMmVGauUkXdxctRgyzYfi8zRZc4PxgwqLxIFsvdeD56YZ1Pq36ZwRGmZyCteR/5mrqm/eD9AZm0j6a6kWb3AIKojcie1L1/YBiAXNWREIK0eUXO9mrmNyX8t2FAGT/AQ59NJQ16xObwC/0bUxKZFGXyDv55FL7za3/pym/s4d+94tN7o4/u/3c8W/xcjyEU9V91iYHwsGNJG2g4wIVIKF3u12XHUkkvsBVLHmpyfgbBImTUDs05HstDaXVAgnTiX2yZAB4SqxO8UeQ3EMwv154OO93NkrB5OZahyIDisqlFeWXekJII3tll7aDlr7z5EPwi5oUB8BD/WRZQOFiYC9qqBoesoiNrQr4LqJJGpwXT4z6tsS71Qn6Yp08es5kw9UdSZhUY/RQnWLUyKTaBYEB99QCm1erdDnHhimAeSCF5BXUkrzdreexveQGJrAv8O6JTqMhsSvaHAbvqraUUCikOJj1lx6KcJHoMUnmp+QsR4W7LK/hML9/JaRxbeFa6TSCu1UNEaRkNdPuvDu90bD7QX5WBwslY9dcKikeffyeSjISS3OfeY42iVaEPsgmb8xsETMxPONNiNw3hBft9OJY6ZAiOMSY+svZZrQL0Es9jZ3QnNNsHxySZlz2MlheT11VYsZUdTg+1uOcGeJE8w25x7CoEa+Oq2Dzv7RtWl3f/lAyeEQAgtwTNCosh+UAf1a2pdMsJYMQ6WJ6b0alUqq3zN3KTnO X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5185faa0-f32c-4894-2a95-08db8c34057a X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5005.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2023 10:52:06.4582 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: uSIry2RRLxWv1Jvyq54WQzYtkNSgV4jVuIMB0ArdV9G+VpSCQ890efRaC2SxGggK2hcv1OEdPrYydsWxGwtfcQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR04MB7288 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org From: Gao Pan A NACK flag in ISR means i2c bus error. In such codition, there is no need to do read/write operation. It's better to return ISR directly and then stop i2c transfer. Fixes: a55fa9d0e42e ("i2c: imx-lpi2c: add low power i2c bus driver") Signed-off-by: Gao Pan Signed-off-by: Carlos Song --- drivers/i2c/busses/i2c-imx-lpi2c.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/i2c/busses/i2c-imx-lpi2c.c b/drivers/i2c/busses/i2c-imx-lpi2c.c index c3287c887c6f..158de0b7f030 100644 --- a/drivers/i2c/busses/i2c-imx-lpi2c.c +++ b/drivers/i2c/busses/i2c-imx-lpi2c.c @@ -514,15 +514,14 @@ static irqreturn_t lpi2c_imx_isr(int irq, void *dev_id) temp = readl(lpi2c_imx->base + LPI2C_MSR); temp &= enabled; - if (temp & MSR_RDF) + if (temp & MSR_NDF) { + complete(&lpi2c_imx->complete); + return IRQ_HANDLED; + } else if (temp & MSR_RDF) lpi2c_imx_read_rxfifo(lpi2c_imx); - - if (temp & MSR_TDF) + else if (temp & MSR_TDF) lpi2c_imx_write_txfifo(lpi2c_imx); - if (temp & MSR_NDF) - complete(&lpi2c_imx->complete); - return IRQ_HANDLED; } From patchwork Mon Jul 24 10:55:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Song X-Patchwork-Id: 706775 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 720B1C0015E for ; Mon, 24 Jul 2023 10:52:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230162AbjGXKwf (ORCPT ); Mon, 24 Jul 2023 06:52:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232761AbjGXKwe (ORCPT ); Mon, 24 Jul 2023 06:52:34 -0400 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2060.outbound.protection.outlook.com [40.107.20.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9EC1312E; Mon, 24 Jul 2023 03:52:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HSY+Y+kPvG7/U6zDfvuD9mLuLTTlpuQiR7y8UxaOE1T5klSRIOYSlt1VVHxOJDpaG8PJh5SYhLPfuHLcOeHb++/gaFHUuWQV3NCui8lBY/5cCWGR8uk5hobhjl43odiJwT/hdbTGS4QiRMd4x4K5TITwj8c1ZVu9D8v/Yy3aGlSWq1H8MXqI3C6Rdrj/8xJspcUwvrdMT5Cxa2DOu+iQ+UDuDQ1iTuaxUfNvlCDl97ZLF1FGREKj67hAvPym5vRZOLCHukOTsaFx4L7o4gpI4KSTUjEdIg/h0pruDNSc1pWYqhJmFg9AK/laBjXINSQKn6SR5Bka0+zLKK6OiKU03g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=wntYVC5Q7KVWl/KgJZBaPOWfuvVclZdV1Z0J8n0AwcI=; b=aIAoVq/bgnOLaL9L06Ed2L0UfwpcsOQ5Qx+PkwFNemNAXkk6HkUyaGBOyJlUa6UkSoWUeQeoHeztJaliVS8s2VA1fQdOy3uQD6R1VjVUNUxRYkaQjOi86mbaU86kODBULCGOqQDP9fON6r9GGC5GevllkvFMfBr7OfeVA5JRfedqThBrqmi/SFXECljnhPF81v9SipeirEKwknos4EPFtXsnZ355yYQEYa9h+J2dcmZvg+HtGoCgsYqWKNErqHpjCjNrn6cik7awtK5rIVdPii/x85PSO8S6rs4QGw+Xi+tIGhH4BthOU/gUdwP2IAtV+X+ZbphQry1JV+vzU5/bbw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wntYVC5Q7KVWl/KgJZBaPOWfuvVclZdV1Z0J8n0AwcI=; b=RMZyih0iBd2+JbTseddKNo4I2O8egxwrEP6PTenpA9XwewiaAeq+DEQAX16ksL0o5oWLnnSFL+MaGoX5rcXiLOw8/1C53vdYalc7Yvkp9Hf8Hxv5g0kaTisjCs6jzxkbsbxK1cO7SL2X12jfIbVxT6KPiku3FMWR4GpKmQC/Its= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5005.eurprd04.prod.outlook.com (2603:10a6:803:57::30) by DBAPR04MB7288.eurprd04.prod.outlook.com (2603:10a6:10:1a3::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.32; Mon, 24 Jul 2023 10:52:22 +0000 Received: from VI1PR04MB5005.eurprd04.prod.outlook.com ([fe80::7f26:a98a:b8c5:f620]) by VI1PR04MB5005.eurprd04.prod.outlook.com ([fe80::7f26:a98a:b8c5:f620%4]) with mapi id 15.20.6609.031; Mon, 24 Jul 2023 10:52:22 +0000 From: carlos.song@nxp.com To: andi.shyti@kernel.org, aisheng.dong@nxp.com, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com Cc: carlos.song@nxp.com, xiaoning.wang@nxp.com, haibo.chen@nxp.com, linux-imx@nxp.com, linux-i2c@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/3] i2c: imx-lpi2c: add bus recovery feature Date: Mon, 24 Jul 2023 18:55:45 +0800 Message-Id: <20230724105546.1964059-2-carlos.song@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230724105546.1964059-1-carlos.song@nxp.com> References: <20230724105546.1964059-1-carlos.song@nxp.com> X-ClientProxiedBy: SI2PR01CA0032.apcprd01.prod.exchangelabs.com (2603:1096:4:192::18) To VI1PR04MB5005.eurprd04.prod.outlook.com (2603:10a6:803:57::30) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5005:EE_|DBAPR04MB7288:EE_ X-MS-Office365-Filtering-Correlation-Id: aa24b017-e4fb-4a9f-4d8b-08db8c340f4d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: iCPTj7SAQvnaHFAjBwjotsWoTYhEhojcv5xmCi6FH2ZgXbvunjq+Q7n3kTDS0AKvI71fcQOoiIWqLIsJWxud0d0nP1lCK5hFULcVTTWfiHz3z5RpvNqO9XjzC9tZQqrzbTVfVbgN/Q7phTYQVU1TLpFGwbDQNJRZfxroy50+7FJvz5VG8IRB/6zex9aPZRUakTzn4zrVydrAm5Sp9cKsRTbhuLThDuywMj5nycLyukdGqQvrRzZah9J//ZoXpMIimIjDi522/ln+wmqI3fDMgzeHfsH6ntijO3o2ubvz1e1n3e2pbO2egaNs93jqHWPbhJhC1jxkebgKwJCQc7IQ8q88Y0L4BxHiZ2XmPHVjxE2FrPCSRme3FPWArI8gtVNFcFFQRvPwzfMCOzrYJKWjEI4UIqU64m7FkpT3/p2uGrvpusPC+VPfA6xHLe027FUiQLwBcGTaDlVuaPkmPicjnTshpHv23zR4/ytSf/VglS0sz87XkLU6uy0bjfQrPqZKvMg6VPQ70X4phykBc1fm5cYIH9D3bAVIp5Hh35bGwP2UCZCFigKSawzkd179lZpl8VI9KyNZyC0/ITysmMBnub0V4BOB3aL/YTUVQB0ENYf03Y5I/adVpSFJdY9Rj9Gt X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5005.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(39860400002)(346002)(376002)(136003)(366004)(396003)(451199021)(41300700001)(8936002)(8676002)(316002)(66556008)(66476007)(66946007)(4326008)(2906002)(478600001)(86362001)(5660300002)(2616005)(6666004)(9686003)(6512007)(6486002)(52116002)(38350700002)(38100700002)(36756003)(26005)(186003)(1076003)(6506007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: SCP2LAwzqgykFTGrdjnkFv1J60EaBu7Mjlo7igNCZYU5seC0ItwQQlbMoFIxIOCtHfL8CyM0gHMzRiNXP8NAwY8/7+WhtzG4DaUco0PMsgP2VP8a+VlUhfN1sW/irXXENDQG5dtck9vARObjTiw1ocylVj7hd/FTNxaW1WFrAbSGkyy+dFqVzFShGdH+VTAYn4SeVUvgnWOFFUclHa3mKX8qEIASJW8cOrVUM5IOmDVnFtezLcR7/CBRrhvPhL/Y9e6PV9LfX44p0Jx1goX+rM1kPNMGdsIiId2LnbO3GA0dxDP0ec/5PBvPnG2fUzoSCfR0iXrV9AX3dGzAMC1+AVMMi1tSC9vCSPvjX6R7/FYF9RUqHIjfDsFlHjGdFnY99g3mGNtoSet0ViJN4eklKnK6o0ufCP/WNEndEdutFJwNSSCFEZfx33oCmH0Io/uUHZGbEa+nJh4xPh7bQx9Kwp+zSpUfIBX3g8tiOayXyTIxtkE1CoYbTS1RDKxcy0BC774TSaUXiRADxtQbrWZtSrdlegblS6l0+vHa2K+bi7KTYspWexFKNCvGmCoXT7Gnu4OWQjbicMUUkDJgXtiBzisBGQwa6RVvyvWH+mqqs9E5ZZFJm1Obz5ooQ8P1gCtsEXh6H2IxXq79K3zcqIchCJ2LHYBh8rom+1lg0ulCm76y7ifG8v2nUH7Kbl5mXl6hFlZR7HUbvWe0vZVUinDSLkF9UGVvEEd6Wm7M8J2E2SNTk+sVRQjibfeLSPWIzVrN5qyckOrRbY1ecT/XYLOrWLivKe/rAZOVq+cZ9mPhhu4bID7Nw5UW5NCPv24+WQ+X+5e8p+MR1K0XIzVzkDDlwG2IoN4BVLSPQSB30IIDt8MbiBkuwNjOiYGHBoPmkv1EZGYleOuqg3lgKlWD+FUbLEjg0SK6j5wVgZkjfT1eysxGeb7Skr+tDe5OzFidoG48OX7N5F+T/RikjescR9zafpEK/u8E+iD8a+++nRHJ7n7P/mi3bG7kwDv9mn6fgodgS2PJAiZQlclnxbGj1Ms4bdkCsQT+YrKZFl/n1kgzIE7Dft7+sg7uldKarvS3JNaGl8T8lRniX6Nuo/Df1PSdjnrUcUF1vNl1VS1o0a3ZlY9Bi/+KBCMnCXhh8x/K4rG2VTZoi/1L4fxvFQvHCDz6TmzM/xPzsZBQM4b5EGQhsuQ6VdfEjIaDY4DJRv/rFeyzKF6TilqBV13jB1Wcjl6TuEhYgTHYxlkq7GqslnFnHilxRNoCO5SUx07seeFO0WO41ATLMv5zvpxQnornTD0y3vlM5jUMRjIAycchLjX4yubOXc93cwwiTPCTb69RkBcJS5ht3g5rgBzsLOyofTWBw9bBqIipz195AcvXP1Am3NR2VwL0AU6ggYsoVbxhow9BKQxLQ2kshhL6c/XMYpA/hOLwvLumimRXXk9ZABYH2eil3UihuvQjz2xWguLQyzoB14YqM5z2haKOl6qPQrCHzqkrGcBneLZ0+upDVtQ8D9wcg7bV9o6lWjrQNA13jXQw2OMfFCQwJN7cOo8tDkkRysqk45/k4geibBMaXfhMkBmy25z6Bl+zbB5HMUuSbUkh X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: aa24b017-e4fb-4a9f-4d8b-08db8c340f4d X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5005.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2023 10:52:22.8162 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: gKKuvaK9TP5H5cYISlEw/nQRLkpYiLHDQc9BmxA5DyV9KcKwXF/y6WwyEFPhuYeemgRT9aXruS66KSDV9l/Zmg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR04MB7288 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org From: Carlos Song Add bus recovery feature for LPI2C. Need add gpio pinctrl, scl-gpios and sda-gpios configuration in dts. Signed-off-by: Clark Wang Signed-off-by: Carlos Song --- drivers/i2c/busses/i2c-imx-lpi2c.c | 51 ++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/drivers/i2c/busses/i2c-imx-lpi2c.c b/drivers/i2c/busses/i2c-imx-lpi2c.c index 158de0b7f030..e93ff3b5373c 100644 --- a/drivers/i2c/busses/i2c-imx-lpi2c.c +++ b/drivers/i2c/busses/i2c-imx-lpi2c.c @@ -107,6 +107,7 @@ struct lpi2c_imx_struct { unsigned int txfifosize; unsigned int rxfifosize; enum lpi2c_imx_mode mode; + struct i2c_bus_recovery_info rinfo; }; static void lpi2c_imx_intctrl(struct lpi2c_imx_struct *lpi2c_imx, @@ -134,6 +135,8 @@ static int lpi2c_imx_bus_busy(struct lpi2c_imx_struct *lpi2c_imx) if (time_after(jiffies, orig_jiffies + msecs_to_jiffies(500))) { dev_dbg(&lpi2c_imx->adapter.dev, "bus not work\n"); + if (lpi2c_imx->adapter.bus_recovery_info) + i2c_recover_bus(&lpi2c_imx->adapter); return -ETIMEDOUT; } schedule(); @@ -191,6 +194,8 @@ static void lpi2c_imx_stop(struct lpi2c_imx_struct *lpi2c_imx) if (time_after(jiffies, orig_jiffies + msecs_to_jiffies(500))) { dev_dbg(&lpi2c_imx->adapter.dev, "stop timeout\n"); + if (lpi2c_imx->adapter.bus_recovery_info) + i2c_recover_bus(&lpi2c_imx->adapter); break; } schedule(); @@ -323,6 +328,8 @@ static int lpi2c_imx_txfifo_empty(struct lpi2c_imx_struct *lpi2c_imx) if (time_after(jiffies, orig_jiffies + msecs_to_jiffies(500))) { dev_dbg(&lpi2c_imx->adapter.dev, "txfifo empty timeout\n"); + if (lpi2c_imx->adapter.bus_recovery_info) + i2c_recover_bus(&lpi2c_imx->adapter); return -ETIMEDOUT; } schedule(); @@ -525,6 +532,44 @@ static irqreturn_t lpi2c_imx_isr(int irq, void *dev_id) return IRQ_HANDLED; } +/* + * We switch SCL and SDA to their GPIO function and do some bitbanging + * for bus recovery. These alternative pinmux settings can be + * described in the device tree by a separate pinctrl state "gpio". If + * this is missing this is not a big problem, the only implication is + * that we can't do bus recovery. + */ +static int lpi2c_imx_init_recovery_info(struct lpi2c_imx_struct *lpi2c_imx, + struct platform_device *pdev) +{ + struct i2c_bus_recovery_info *rinfo = &lpi2c_imx->rinfo; + + /* + * When there is no pinctrl state "gpio" in device tree, it means i2c + * recovery function is not needed, so it is not a problem even if + * pinctrl state "gpio" is missing. Just do not initialize the I2C bus + * recovery information. + */ + rinfo->pinctrl = devm_pinctrl_get(&pdev->dev); + if (IS_ERR(rinfo->pinctrl)) { + if (PTR_ERR(rinfo->pinctrl) == -EPROBE_DEFER) + return -EPROBE_DEFER; + dev_info(&pdev->dev, "can't get pinctrl, bus recovery not supported\n"); + return PTR_ERR(rinfo->pinctrl); + } else if (!rinfo->pinctrl) { + return -ENODEV; + } + + if (IS_ERR(pinctrl_lookup_state(rinfo->pinctrl, "gpio"))) { + dev_dbg(&pdev->dev, "recovery information incomplete\n"); + return 0; + } + + lpi2c_imx->adapter.bus_recovery_info = rinfo; + + return 0; +} + static u32 lpi2c_imx_func(struct i2c_adapter *adapter) { return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL | @@ -603,6 +648,12 @@ static int lpi2c_imx_probe(struct platform_device *pdev) lpi2c_imx->txfifosize = 1 << (temp & 0x0f); lpi2c_imx->rxfifosize = 1 << ((temp >> 8) & 0x0f); + /* Init optional bus recovery function */ + ret = lpi2c_imx_init_recovery_info(lpi2c_imx, pdev); + /* Give it another chance if pinctrl used is not ready yet */ + if (ret == -EPROBE_DEFER) + goto rpm_disable; + ret = i2c_add_adapter(&lpi2c_imx->adapter); if (ret) goto rpm_disable; From patchwork Mon Jul 24 10:55:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Song X-Patchwork-Id: 705931 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CF966C0015E for ; Mon, 24 Jul 2023 10:52:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232804AbjGXKws (ORCPT ); Mon, 24 Jul 2023 06:52:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232789AbjGXKwq (ORCPT ); Mon, 24 Jul 2023 06:52:46 -0400 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2060.outbound.protection.outlook.com [40.107.20.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51BBB137; Mon, 24 Jul 2023 03:52:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=laNZv9UYGAkNUlY6igyjL9HEhNHjEtpz4gTT8y8/ikciN+DKMD//8KMAObxtb5hYz78pXQ5zkIDSbsTGlbQbyjpP19lVrN+t9JLzISVqyRrIZFoiC35C+d7wGtRvaf8IX90Tux2P+3STLWxd3rkaHbEReroIZNOSXD/gxzXyBlj1CeJydI9dWxYiM7qZiScedPmdhrDSjcNDJ4zSTrIdYI/YEGWk68vIk+kvc36t0qWI8vc2ZFFv4GMmjgOqHTu/Uj+dITxLRBfzOmwty7jU+fe0g42X5UXtB3WrM63/gtB5nbbrUs1zYjWT/FPUOeOOKekiPFHCSBXS1oUIwQayUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Tt13Gr4lkfhyfyHS3/RmyHaHEyl3PBdolcUbDX0pLh8=; b=RAOH9bRGPCI8puSchAPBCrzeVCKTX45dTTdYLDh6LyaEsmvZ8LIydW6zay+yooR3ybJgFzJptsCzQIsjNe4Yun08YmUNEGAA0XFD1W2X4RRyVh6SvmFr/EesgMmAdjTbGe0OXwScbtKt6CH/bLlQQALbbrXu/k+lkw9qjVkBdV+ukrqTk1AfPODMBbDbvookhEcXMy7+/mKxArIgDu3tQe13KF6bColY3UPxyfuGdW8nHm0XFRRHUUPxNh0ji7Z/vxni2MKGHLRj0/c+rMj+Hm/IeLjKRsdl5AoROxrun5BIcd8GFWjFRhP9boP9gRESl0Pa3L1lkBnqYuK0YkE5zQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Tt13Gr4lkfhyfyHS3/RmyHaHEyl3PBdolcUbDX0pLh8=; b=JhsW9BXqHWrvDrfbuzmLSmmuNYj67hpxOhlr4tUvnSzuHkGOSDDANQh+Qq4NGGvYGFYsIoJhWbuP+7M0uY0Nov1rT73dlpjLN1PKk69ugSPa5EbPP1sCQt1t52OAWvcQu0ooel9albfbTOWoNanRU7t/uZVs5X04AeD0dHiu/YQ= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5005.eurprd04.prod.outlook.com (2603:10a6:803:57::30) by DBAPR04MB7288.eurprd04.prod.outlook.com (2603:10a6:10:1a3::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.32; Mon, 24 Jul 2023 10:52:27 +0000 Received: from VI1PR04MB5005.eurprd04.prod.outlook.com ([fe80::7f26:a98a:b8c5:f620]) by VI1PR04MB5005.eurprd04.prod.outlook.com ([fe80::7f26:a98a:b8c5:f620%4]) with mapi id 15.20.6609.031; Mon, 24 Jul 2023 10:52:27 +0000 From: carlos.song@nxp.com To: andi.shyti@kernel.org, aisheng.dong@nxp.com, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com Cc: carlos.song@nxp.com, xiaoning.wang@nxp.com, haibo.chen@nxp.com, linux-imx@nxp.com, linux-i2c@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 3/3] i2c: imx-lpi2c: add debug message when i2c peripheral clk doesn't work Date: Mon, 24 Jul 2023 18:55:46 +0800 Message-Id: <20230724105546.1964059-3-carlos.song@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230724105546.1964059-1-carlos.song@nxp.com> References: <20230724105546.1964059-1-carlos.song@nxp.com> X-ClientProxiedBy: SI2PR01CA0032.apcprd01.prod.exchangelabs.com (2603:1096:4:192::18) To VI1PR04MB5005.eurprd04.prod.outlook.com (2603:10a6:803:57::30) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5005:EE_|DBAPR04MB7288:EE_ X-MS-Office365-Filtering-Correlation-Id: aac45896-638d-4a2a-2598-08db8c3411b9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: iVx7HcqIeC/HIk07G31r6qsNBxakyZG7McaC+JwnlQyBPyxPo6mlR8q8+T6eKyphlj2QgxbIokxfgocrS9HisqExAF2t7NWVfMAdgpPQdQwaqlioY/9ySR4YfNN72/1BrFOTCAs8RFGWG466pLwmMpdA3XscA7OovigaA8ID7rPnkdFwHkR0UprGZtsX/d7erXX2Xg1tL6TodGXPQ2Lv8tUAM1aduIwBwesr39VG4oaQLGZQSX+gPcwkP1+BzwGHZNdQramDmM/SzCK4sym94Razl8GRhSZ4og9wyHUmT0uJbES0nzxWVEVnPHzvBX9oRmaZFswl690FxK+UEjW0G29WSxWcSDVrLf0rh7DxLM9kJvnDpBC8OOuPZDSTLb2+CJBfeimnKj/8wjgvhWgl+DBy8oEGa4OVVnGtGK0v0Fx/yK0IdoORQxLlh0SFNb1AulzMt3YGlwsKsxa4w1I/wSJNJDI16gQ5RsjlPaHN8UBf+1PXa+mBO0QfN2loIAe595tMygDFuzXM5kdX8yRWgopsP/KqhekIhT5y+RlBMhcSzMpGQhg7tzGTeN282SwEFqHPRoWtGESCuTwGfsvJ58wPfkIB2pP4cUrrYVKL1kVED5chA8wmPV8loJgTxhbP X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5005.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(39860400002)(346002)(376002)(136003)(366004)(396003)(451199021)(41300700001)(8936002)(8676002)(316002)(66556008)(66476007)(66946007)(4326008)(2906002)(4744005)(478600001)(86362001)(5660300002)(2616005)(6666004)(9686003)(6512007)(6486002)(52116002)(38350700002)(38100700002)(36756003)(26005)(186003)(1076003)(6506007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: n2cKOuDipS8LF+MlJuDSt6JLMbpn5Tml37NGeVL9axtE8skKrqZ/Ar5R/5CaV9xopMsCCAJNdPQLET7MEkfG9bNdjhk2WomIw5vNScs72yQPUyO1SKFW86MIb5p0J/Fnaip9wo6bUguL0lIF8ljBxgpnmzzq37q7ENHRNdnSZSPk4SvprIAiXDkYYtBVxeZ9vk8+EyRjMiXNsoccKdrM24qsZ3USChk42Wqgw+ZvUVCfSMJEbWTvCiQr+cYqKZydzW1t/8qREC7taPNCzeGi3zVx+Pf4SyFmPWSPRCk3nM0A/iTiCSZjlUeke3FP2knLrODhF6Qt18BZxP1lk35BN00xNhLtBwtt2M56d/OCo0oNU5Hatt7qKQ2QrJUywWBzXszvxv5KRO7W/JZVmilSXIoq2/NtfNtwVwZq5DCpVvd8PUsRntL1T0SS7KXuSXyMarfxbLp1NJyX8bu7UzpCMnAy+3as4wKAjWu6NYk+KB2UqhPIzppHEJnTp4Mpmq1HGGR4jlun7oVsa/uK387wUowFOadS7BcIEu41t4Mvld7MGP7JooLTQd8GLFKVHv1zvRAcPLaTthNS7w4eKONoB7F38ZP1uPTQyt/Of0Mg4IKXLhVds1xs3fvfGwoxHoeN8YWSkStK/KmmhA5okZKlmbUQHnfVCdDe9qPcKHuOEydX/ElXMI+i0uM+EnsQBoCGIEKC+GYCO3mE480fRYlE0b5mIkvbGcM6RbfWrFzNaaVJwrCMw+6khcc5DuI3sE6P1uiUAIZKSxxeD8VelOrzpZofL0xYTvQvh35Ft8Ti8E0XB17n0fk+4JmmZlbvyTSoyjmwZafdZKurqmbfT4/xH/VCik/pfRy6ziJPlRlWG5evXp8lanGhu9MSTfjZtVhEFDa5qIdzCUUuonjY2r/8B8/B5lDb0JzwTxn6umbfLx8ZdbnI+1Ei7JCIsh+3Q/9LsqB1nhiE+COLV2mAKZSQVLbI/UvgDpKE5AYw0GZK2/Dd7c1U/IRWabUbgefdIoYDR3nZYfDGICz1BAYR701coUej9Gc98JUNzy9dksqW/mFkOGBimF/8jiSfFSfBwP1HXiTroCptGZ1r37NogzCnNBJh6sJrNBfZ3rNfV2KXr/7DbZJEhnzoF9CBVJuUUphjQILgzxOvOF65aWVauhLSrb3dN0fqAZnXdY5x5h7z41DLH11DJqWTKflyB9s5UUo8vzSzEQDrZzPk/mRpt36TfUAOvbw7cvIEWFx02/KWc1m42cwBys3JUMI2f7eWVndtZckj4I+cXpajIwE4PIVFPHODhdf3lq5CsrI/Ts4GNBlv+R6m6WEkBpN77rDbhiSD/F/DDrGgq2osd/OLxeQxoac8mINW+S4zsi5pg/BakzI/0Ht85xt4g1lzB8BuGE4uiPMk5xgNP1ABGItam3xdxyQ3ptyWPHB1oTk5fShylDZ2yzljJZcX8oLeWIF14llu2Vngoeo0lDSqK6J4jARfH4DQPpeqmFUWdkjslbuwvJYQSRvcgNPBAKG21Xb5KOIKlHGbZNNminj0D7UWVG6vmvKfvnqrwoGJSJMJaxCUzIF4fX4gKsMRqsmzI64HjYrs X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: aac45896-638d-4a2a-2598-08db8c3411b9 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5005.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2023 10:52:26.9813 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: vQ2AeugJc0pM6TKSJSjHw4YhzV/jwPPdf0Ttu7/XfQ7isysN2VAJmrw6dX+0ly/6Vu+nHq0IO1cnrzmocNYuAA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR04MB7288 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org From: Gao Pan Output error log when i2c peripheral clk rate is 0, then directly return -EINVAL. Fixes: a55fa9d0e42e ("i2c: imx-lpi2c: add low power i2c bus driver") Signed-off-by: Gao Pan Signed-off-by: Carlos Song --- drivers/i2c/busses/i2c-imx-lpi2c.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/i2c/busses/i2c-imx-lpi2c.c b/drivers/i2c/busses/i2c-imx-lpi2c.c index e93ff3b5373c..12b4f2a89343 100644 --- a/drivers/i2c/busses/i2c-imx-lpi2c.c +++ b/drivers/i2c/busses/i2c-imx-lpi2c.c @@ -214,6 +214,11 @@ static int lpi2c_imx_config(struct lpi2c_imx_struct *lpi2c_imx) lpi2c_imx_set_mode(lpi2c_imx); clk_rate = clk_get_rate(lpi2c_imx->clks[0].clk); + if (!clk_rate) { + dev_err(&lpi2c_imx->adapter.dev, "clk_per rate is 0\n"); + return -EINVAL; + } + if (lpi2c_imx->mode == HS || lpi2c_imx->mode == ULTRA_FAST) filt = 0; else