From patchwork Wed Mar 17 06:53:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Clark Wang X-Patchwork-Id: 12144955 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 99C52C433DB for ; Wed, 17 Mar 2021 06:55:47 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F3D6764F99 for ; Wed, 17 Mar 2021 06:55:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F3D6764F99 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nxp.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=yRHfRTrsAG97lngZqTZEArqJx6dF5STjtmGztnkfmBE=; b=I2djEzcQSsbpNMxOhZXOrE35L BFKylbBxnaOeHaYMiUbtXn8yfvO7m1bclmssfiwUElT99LczfYHCbn28mLcPONz5nOiHrVbS1xlyc 3JVCcfw1xocU62JVVsoQ1WK2Bi+7hRUmiFMjiTP7dRNE95RqGRimhap5AiUbs+XZRH1K589P6fVEg f+Xq3E/6XNjXhVUYURmXyWCgp34TdpTigC2xdwX6bv01GTJjb1iV31KEIlYf3Bg8xwH22+YEes6BO 4UTPTfiSzUULBw+9w5mlP7KMK7Mbb8PbVI3WziIABhp1dnyJ1/DCN2CN5vi5YEEcsh7wbqYe5YJNe 2dDUWkTJQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lMQ4H-002bAx-2p; Wed, 17 Mar 2021 06:54:09 +0000 Received: from mail-eopbgr80048.outbound.protection.outlook.com ([40.107.8.48] helo=EUR04-VI1-obe.outbound.protection.outlook.com) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lMQ43-002b6E-SC for linux-arm-kernel@lists.infradead.org; Wed, 17 Mar 2021 06:53:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JQSijPWpDwbpZ6PRVq9SgzItkUFGzx/0kIJKzV1+TQ3gCeymWvioKWIYFE1cllwMFKh0/hROjQVHXy0NC+/jrsVxGZhGDQnjB/IKLHjQitzEHYb1O1ESHKkH4a0N/SM2zH0K+8Kj6QbnbB2F6S1Jel9NrDQ/kTGWk2NZFXTiZAuWPwtYtiHw8zt1zkem0GRmmIyFhBUfNBAxmA2emb5loiND6MRgZ/akXyL2+Ki9jM9r9j47gt4zjFGjj1kOE1qeblWsLEpGHsjVx0wIMLlep8p6g5WUicxnR4LWt7+BSqAUobVL4rstUsPYusY3oFamiH48YTB3InHnnxDtAqZwmA== 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-SenderADCheck; bh=9Se8hWqGvCo9wJQw1RkitCxcl2pq7EcTPAm1sjr//KQ=; b=JVNAkeXaXwogc7XkHh7euH6pR3lzpWQTovFlbUzgOCyzSjANSM7rUOczedxqMwwO00JthvwCwLyPA9a/5D9rO6V2jkHjevYA0OcZ4eqYZ4PKgM4SVloTPtbeM7S3/PHMFLI58KgXdeEJSIosL6t6Q3HOaWXk2YzNCzyid1ufZiwRF5OfebTQf4GTPs7JAqNIEIP2W6/oGapfnzT4JwIPVOZoL+Mg5IO+bltltWb2I5Koe6swG/2KSZTAYt/OYBBX0oc7XKEe6I2QRohLE5DF4nS24vv/1o/2haNWIx23qWIpLHSx26YEFUtXK922RIO1NCtmmTBnzm8ko2ppZMJnoQ== 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=9Se8hWqGvCo9wJQw1RkitCxcl2pq7EcTPAm1sjr//KQ=; b=NKN+px0ww2+yL5lbRGw46IaJGmIXTWzN8m2ZFbbGpIMturOXc39DCt9u7s+SkbdVYQ9kmnRGaHvmRkK1G6Lfv8lfO15r50iy3K/HJVctPWXoCbtJZq3t4XAKqtr4pRIc2FyhuWFHhOUfQqAtucLg+D4gh10UjGrqxJJp9wboYi4= Authentication-Results: nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB5618.eurprd04.prod.outlook.com (2603:10a6:208:123::11) by AM0PR04MB7091.eurprd04.prod.outlook.com (2603:10a6:208:197::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3933.31; Wed, 17 Mar 2021 06:53:52 +0000 Received: from AM0PR04MB5618.eurprd04.prod.outlook.com ([fe80::69a8:a768:8fa1:7236]) by AM0PR04MB5618.eurprd04.prod.outlook.com ([fe80::69a8:a768:8fa1:7236%7]) with mapi id 15.20.3933.032; Wed, 17 Mar 2021 06:53:52 +0000 From: Clark Wang To: aisheng.dong@nxp.com, shawnguo@kernel.org, s.hauer@pengutronix.de Cc: kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, sumit.semwal@linaro.org, christian.koenig@amd.com, linux-i2c@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 01/11] i2c: imx-lpi2c: directly retrun ISR when detect a NACK Date: Wed, 17 Mar 2021 14:53:49 +0800 Message-Id: <20210317065359.3109394-2-xiaoning.wang@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210317065359.3109394-1-xiaoning.wang@nxp.com> References: <20210317065359.3109394-1-xiaoning.wang@nxp.com> X-Originating-IP: [119.31.174.71] X-ClientProxiedBy: HK2PR02CA0215.apcprd02.prod.outlook.com (2603:1096:201:20::27) To AM0PR04MB5618.eurprd04.prod.outlook.com (2603:10a6:208:123::11) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (119.31.174.71) by HK2PR02CA0215.apcprd02.prod.outlook.com (2603:1096:201:20::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3955.18 via Frontend Transport; Wed, 17 Mar 2021 06:53:48 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 96b3eca0-040d-465b-8662-08d8e9116cac X-MS-TrafficTypeDiagnostic: AM0PR04MB7091: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:741; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IwM31GGqK8BF4WOu2azxXFYhwaGiiTrsM1DRwRKlAczaeZd1auXah5iCRCmXUhWWXGZWevDTsDTTSgx7z3beKqoTawuhj8cgXB1qa+jTf1KUybllT/ws8iNYrnNQvnSShqqaSE/tJBxjAHO8le0NnU2ib5px3TlxDWEq9kaVBrBCs4S8axJ7xL79UMI66KrW/tUVJBpUxnQ6B0M/n8hcqdpTC0qHjCQI//0m1B7k9ajD82M+/g2nFIX88vh8kG4LB/XIwoZiV8eLiXnpOa2uoKWdthyDW3JIvCn3V59qKyVxZUmeb6b1BY0OCnK5uVY9MBM5d3ePOL398WlmcbCFen2gUgfrIIfSsyRtG8kCdUAuySbWAtJ1kTJ0Dh49C3ANk5GU/rWlxAAfvr0SEQqjuk6WpBl0zfdYfRFD1PeSwEhjO3VGzOvyNAb/xap7sxY3c4h/573ZyqzOc9REUXeMNQJM3OSKVqp6M327ZJN1YwwFwcBExzhFrg+AetHRC1Du7D/pmjP75UMRmDzyjewiYWFSq3TY6606BJkkKCsgYD2+orXmcfwUPCcUfrL9z93JYXdM6wropGz0OYzmFEVZJ9V9VYZ4o4KhVt9sTQ5J7PXUggtPA13Na7BMrZEVt673 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB5618.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(376002)(396003)(346002)(39860400002)(136003)(478600001)(66556008)(66476007)(69590400012)(6506007)(66946007)(83380400001)(36756003)(16526019)(5660300002)(2616005)(316002)(2906002)(1076003)(8936002)(26005)(52116002)(186003)(956004)(4326008)(6512007)(6486002)(8676002)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: NjvVRzFk502hwF/Kssyyw4GRVrONJ+v9lJhhtj0GWBhnwEUbKzvSG0THp+Y41DG7wQRbAmWpPh5PUBLfy4ArUDp6f0H78gJfJS/468yrlpU+QNn8BCFxFPH7fwgpvB61CqUx3D9xgsXpXHr1KiobpCUmanUz0HeiZACd/uqcsOblmQVD4W4/o2NlSs/2ITuuFiTd8CTpvLHjCMEabQwZtQCa7bTw0sT0DPK4po/lTCVWB2/r9TK5YaA+U4/PVWw+G8zMyS6jYniPZZOh06J1XH64BMXSi3gIj+gakI5LmEuSyLX2xOVO2u0hgG9RcAjo+WTfgnL0xUg35pG9KUWllBfB1QMwEsYst9CBef0Dtq0yTdTD8Ua4dEgXBAZSW5B+T4R/1aniKckEZgiHg+ONW1tehqNPk8G7jZ6HSf8WLW/7r1iLZCOL95StHFw1Ln86ABsgdngvM7rTSG1ehhC1dSvH2zs48pxRjpKZVPnqjonMEu6mkqiT9Zjkl8CDOWoTrL1z0vjr1sjwZQe/BX0DhXjBvBpD/tMBr+etz+AqYVnr1FVNq71swoW8V5yKaGlTRyQpir4H+vgfPUY0hCkJs89S6oPs+2XVSI462dIrMuH9P171tUq42J6hl2i/wKmfT6HKx4YDh08+AEZi0XCdJvj8lozX64bMFqNlUhRznwEPOIQ+pP3qmB6bg4V0+/lMMm/mpvH8kd/OMo86ra0yk7BcWw5PWQ5l2WnAqeLReRqm3TnjMJjtJq1N0+1qc9fx8kKL1E5STubRgeRDpai+sSxx6Y7UUZ89y/a84LWJlY1ued6aN6LtmRpU9eX5CeE7EUQRrR3VKLDaU7bH33+TNqeVaV/+Mwgy1TK4VVtdkdjeIyyubRJ+LBD2YgrDShGO/mTdt2uWcO1zlxefZ8e/hCfyAjtP6rcvY0Wmg/IBfq/TkBxMAcGw/ghU1GhlgIcFNX1bA5AaQ+nj1ZS5nby/nRiIkDtTc41DYD9S4NYKHS//BT/ZjdaFga0vdflNFccDNFPcf0h0ys66/wOyWzke3gBChLld04SoFrqDbovs3MRBvWyxhqwDHwyLXJCh0/vwRNjG4zPfvH+qYdYgZGaYIeGrwhLHfYbvI6/PW2L6oT2VR25ENPN7t7dJEXkByPjRDTR2hwINSOkVn0tlhdTM63T0YeTIKLdlO+6ucTes0Egs4RnPFj3buBhFIckMYlTBQZ7TFmUbUno98QGgwetsCG0t6YXEMqr5xo8rLZXTdNr42u8rLXEVFwLCqEp/iZVAyn+16JX4Q9mH+WYCI+CpF5at9vgv9fM4lCSKCwMybJt57BECnCXaO/Yt3mwKHwkk X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 96b3eca0-040d-465b-8662-08d8e9116cac X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5618.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Mar 2021 06:53:52.3464 (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: nAYj9Q1EKiKIAOMBMSNuE431/uFlI9RGwimzhYfU7+lb+Fyfh7yuLI5uIVpaom+jEVZey5wZs7nkygDJhvtbww== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB7091 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210317_065356_115284_B84053B7 X-CRM114-Status: GOOD ( 14.04 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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. Signed-off-by: Gao Pan Signed-off-by: Clark Wang Reviewed-by: Dong Aisheng --- drivers/i2c/busses/i2c-imx-lpi2c.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/i2c/busses/i2c-imx-lpi2c.c b/drivers/i2c/busses/i2c-imx-lpi2c.c index 9db6ccded5e9..bbf44ac95021 100644 --- a/drivers/i2c/busses/i2c-imx-lpi2c.c +++ b/drivers/i2c/busses/i2c-imx-lpi2c.c @@ -507,15 +507,17 @@ static irqreturn_t lpi2c_imx_isr(int irq, void *dev_id) lpi2c_imx_intctrl(lpi2c_imx, 0); temp = readl(lpi2c_imx->base + LPI2C_MSR); + if (temp & MSR_NDF) { + complete(&lpi2c_imx->complete); + goto ret; + } + 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); - +ret: return IRQ_HANDLED; } From patchwork Wed Mar 17 06:53:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Clark Wang X-Patchwork-Id: 12144959 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EB967C433E0 for ; Wed, 17 Mar 2021 06:56:10 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EAB3A64DF2 for ; Wed, 17 Mar 2021 06:56:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EAB3A64DF2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nxp.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=dftqGDjB+OiXa3L+6RmHzoFrDyy6UNRBT5o4vhFXcxo=; b=ZYcv29S67/wY79LP1910kV8kZ Y5zi7oVG4+trHSeZ7+OvQSdYd5l1v3fAG1qBi7FKLlpU6p6b+HE+t8dQ5wcRmmje0ywWn7EfkJWYd mvzcmhhqTvVYdXEiAT6oV1Xp4vEELw/kAR5yQIdwDvGW4LKVK/M2x6t1wwG6j3R+OyO1WrzRasbV7 KmrjRQxOw8Ku9TL32Z/kO1FHalMHPvP1oH6hjw89s28MSHGY8ItrOMwVzE4qF2qCTT4rJUqvESdLK gEsygoV19PMkSuzYGIYdsAaqztMcfmu8r9CvsINpLXo2SeR37UWBTeeM21CaGn2kKCh1jRfh+lnz2 l1nNAfPwA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lMQ4R-002bF2-Om; Wed, 17 Mar 2021 06:54:21 +0000 Received: from mail-eopbgr80048.outbound.protection.outlook.com ([40.107.8.48] helo=EUR04-VI1-obe.outbound.protection.outlook.com) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lMQ46-002b6E-VU for linux-arm-kernel@lists.infradead.org; Wed, 17 Mar 2021 06:54:01 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kR9nT/nl2RNm3XfmD6GzqnRYU6pTdzT2X14d1G/hmfcGy/COL4IOfXwqLpjCDsfashESh5ErZb7edSuKp0G7Dlw1jRRGQWVXHKnlODyyAOIFxXkHLatRk3xcokIzoS0mRjiQDonExK2x/Lc683DcMjrQHLAeSU9BKKOEGSvqRbD79zVGFP7dzK8qej9UmMmrs1LkJgmQxIK0A5GLXwja14XIZofCzXBV7Cv7bOlqVVC45bD5BKjXN2/LaerWZsqv0PmmNCWJ+CFY1Ni1UNs+YGH+xdqFaSIuTPmem8F1QP292kaIlLyUYkv8VJkChSngDY7QigTVc74apdu3o1ptNg== 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-SenderADCheck; bh=BscTcRRIafJnpRdk1Tqz0bqx2h7fMG6bMGtJERgWefY=; b=doLSGLi2TM/MoU+Sg5iAE4ULYjN/xEtZGZG4mVPsDmtYj3DIaEAd4U7BFo90bzvMz5mJNR0JZriP0gujS4LPh8gAKRkT+d+ZgvumrcSRetC2Ea39vjDKRbs9cMj/lBXlWfr+Jvb6FVUyAw5YSrSuRHvTvgnYsxvQDhjdg1pZ8ZLn3LzNq4J3BKwASiyx1dhGNNb3hcTbeguJjEfUJd+6PEWg0YVJ3r1qwwypiRwdQ7iLHd5ffRxSkkE4wekFOio91+qm5F/3/yg183yR71t0Jrkta2NLUGiEpQg1t/gClAeKP+tOIkzOvM8BZo6Z2AzrrxkHMAqOhfsnLOxruFBQ8A== 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=BscTcRRIafJnpRdk1Tqz0bqx2h7fMG6bMGtJERgWefY=; b=hBmCMKigyFp65ycrpgZz8S1Uhp/sY7xdlmCSVbP7Jdy1Z8VHmjRFZNtCv6kozI9aSJFAw+rKYxId9o7uU7ZjvBZOtvSX9R8G93Y8tBtO4Q2ubnl07ltGRTzA4vVr5uynQbO/5xYeGZWDNmwMR/bH0JL/c8uFs9VR/b4J3oPEpzU= Authentication-Results: nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB5618.eurprd04.prod.outlook.com (2603:10a6:208:123::11) by AM0PR04MB7091.eurprd04.prod.outlook.com (2603:10a6:208:197::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3933.31; Wed, 17 Mar 2021 06:53:55 +0000 Received: from AM0PR04MB5618.eurprd04.prod.outlook.com ([fe80::69a8:a768:8fa1:7236]) by AM0PR04MB5618.eurprd04.prod.outlook.com ([fe80::69a8:a768:8fa1:7236%7]) with mapi id 15.20.3933.032; Wed, 17 Mar 2021 06:53:55 +0000 From: Clark Wang To: aisheng.dong@nxp.com, shawnguo@kernel.org, s.hauer@pengutronix.de Cc: kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, sumit.semwal@linaro.org, christian.koenig@amd.com, linux-i2c@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 02/11] i2c: imx-lpi2c: add runtime pm support Date: Wed, 17 Mar 2021 14:53:50 +0800 Message-Id: <20210317065359.3109394-3-xiaoning.wang@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210317065359.3109394-1-xiaoning.wang@nxp.com> References: <20210317065359.3109394-1-xiaoning.wang@nxp.com> X-Originating-IP: [119.31.174.71] X-ClientProxiedBy: HK2PR02CA0215.apcprd02.prod.outlook.com (2603:1096:201:20::27) To AM0PR04MB5618.eurprd04.prod.outlook.com (2603:10a6:208:123::11) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (119.31.174.71) by HK2PR02CA0215.apcprd02.prod.outlook.com (2603:1096:201:20::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3955.18 via Frontend Transport; Wed, 17 Mar 2021 06:53:52 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 3ae51b97-5cee-4423-d43e-08d8e9116ee3 X-MS-TrafficTypeDiagnostic: AM0PR04MB7091: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3968; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VCszqoyiTMboUM65c8RsZ9VOiOY/W3mMzYBEvEZp+RqmZyEn+/tgfIo0nDiLtBDPa/P1W8QmRTFoGA36gzRA3svECYnyOxxl086zmU5ICheiXRaEU2YoQnipV9cZ5CxExd8b3Jg6gZH+hGtWpxpAxrxmZ3hUTBEyEEueYbqSLv6NR04N76PO+63Nuzd1hFR19OcX6bYXG/PpdTZVYs9TbpuOL98HzPsEDyqs8OLIUmB5sSIumz8s9iJ9pysq+wfeu5f0yHQqjAQXOhV+SdGfo8LHeQ55cRYWEEuakT6qP8kokv8+S/N6RaMG9Qifn3PwcAUPG5XdurOejfJ8Djp8CnXPvCinuFaapdLwG3J78kjCzN7HPi71YVFm8MG+LTfYPiAjgvCvGtHajO2a+oyxbxDJFCWGgx+/EPDfTCfiiYBDm8PZQ8WuCxCGdpT3YrImwQiV3C6667m3QsGLBKZQzS+HWDyPUiWGI/t98ht3ajlcQ1j4CT6ekS4VENX7Uhv75oGDQZZU+s8EkdjtOEaSLpvOKcfmQP9AAbMSssd3qKp1e5HYUKW16t+O0YzpkSCsYG9y/JSsnGU8a3Kqh5fagwYk32JCO/YCh8HD6xLrMmlsCWiN2+jvgt79gjmBYjK3 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB5618.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(376002)(396003)(346002)(39860400002)(136003)(478600001)(66556008)(66476007)(69590400012)(6506007)(66946007)(83380400001)(36756003)(16526019)(5660300002)(2616005)(316002)(2906002)(1076003)(8936002)(26005)(52116002)(186003)(956004)(4326008)(6512007)(6486002)(8676002)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 53DVdtPLAkgBwKcODnAFhJeqpkxkaT7vc6RTVwuA7euhO1rslLAYJYkpugVdwLaGgHa/ZkFrWE68H0KJCUIYuR17c0QzuaoaY+ZxwUexnnDxPF4kjLncHypRxzNCTYUavCTifWvo9RSv0xQVbKCITENUdpVUcdijFilzDu3sDVok4aUhdlyOi7/iEXmajNivwyTJWm0STJAT9S5BOcys+/GZ4xxQ7LjgK5hIsuHDTWufrhfqB0XS5rR6cQ8H7wZ1z8Ig6YAZ0v/0BxEW4AHX8Z1qGUBTd1baIrhuhjuW5Flo5rC/mHjk5xnt+LcUQGsjZJEtXP++2eGMmxE4EmxqxJubtV5/CdogsT5/KValp5v9QivDgOlbrAnF1WNpnQJxw/bGUWRax9KEmMZ/2SY0iTbelHhx8acFpKtRahONeU7xQlNJffd5bP7cj77eWq4MH0mwM0yXeFVnpSqU6tI+VLA5q0HQbj7hbfSzGVAw6Hzbrf1KMUugdWdvV9gvwzBmA6yjRYTjGJ3fImy/02lGfrAmP8CeE7Z7kvGye80BTmYGdY6ENvTJ+6hdD5/cRb4yAYt257Fn6AYy8Hr+su3QASNSRTDuwOh2UETBXDKLQZwQDaC9yfIW2R1zTkqmimsfe4dGCRf10uoHS1SxL4a2TrzTa7Yr1IcvKG/PAvkR0y0loYrG8Z3jmgAR73vDUEAeEaYCy15SBzve/J8yHy0CiOsacelhV1vTJLDE+We2/xdEWMSMNdhK922MTDd8PrN7VTELfQAsvCSYic3YG5ZJEpjcAidWGgYUDWuzJfG66mBWnOtAO4smhxn1c3GHPLWd7qmRa47+RQlHIJ1y9/P3TEmtnxqw9w5wPK/Zn3T86td8ahCO5sIpDx84TeP2eWvZ1rzJ62EqHjQihu9UfiJr3/i/7uKCJQ3ZJUOiKDSJQsBQ/WDrHM186AaVRQXxBUiIB7hpuyAIgnZMf7rBlL0rcd2mKq6HgM1aRaHeUYD2iP/GPTe+l6mHwZ+945V4lHCYc9Vr3/nn067n/g7EzHzbjOdhuwMsPI3pyFN67R/ozFDeo9+nCY7lp12QRxBMHyIUJpR2sw3gD3WUeBYbaQQVgUSwNhYFw8FPvO3vlUdesY2e5QpZL3rRY33MIJfwddIMot7qkSf90/6HROujqO2oEPbgEgFOaJ2TsIiOh+MqoTcgkHfZi+06r8Wp7kEx3MexJZ/ekcQXurhIlyUDA/19aXMGQ+zjOmmp/aL0F+zwsrRMH5akPjXLNxZYd1Q91MhntvS0lkCrsGgawI/9rnSIyVbEVbweVjfqqL5ZWhYWOJIEO5ylkouA15fwVyB+2Clz X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3ae51b97-5cee-4423-d43e-08d8e9116ee3 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5618.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Mar 2021 06:53:55.8315 (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: wPqxLMQUNk3k3m/NQ/0YWLEwWLVIC3e8zUPoco78lZDH9l1EgHkw3+KEpHY56hAny4jsYmZiEHNMIgBbqUGmKw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB7091 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210317_065359_293855_A83B0ADA X-CRM114-Status: GOOD ( 15.11 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Fugang Duan - Add runtime pm support to dynamicly manage the clock. - Put the suspend to suspend_noirq. - Call .pm_runtime_force_suspend() to force runtime pm suspended in .suspend_noirq(). Signed-off-by: Fugang Duan Signed-off-by: Gao Pan Reviewed-by: Anson Huang --- drivers/i2c/busses/i2c-imx-lpi2c.c | 50 ++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 17 deletions(-) diff --git a/drivers/i2c/busses/i2c-imx-lpi2c.c b/drivers/i2c/busses/i2c-imx-lpi2c.c index bbf44ac95021..1e920e7ac7c1 100644 --- a/drivers/i2c/busses/i2c-imx-lpi2c.c +++ b/drivers/i2c/busses/i2c-imx-lpi2c.c @@ -574,7 +574,8 @@ static int lpi2c_imx_probe(struct platform_device *pdev) if (ret) lpi2c_imx->bitrate = I2C_MAX_STANDARD_MODE_FREQ; - ret = devm_request_irq(&pdev->dev, irq, lpi2c_imx_isr, 0, + ret = devm_request_irq(&pdev->dev, irq, lpi2c_imx_isr, + IRQF_NO_SUSPEND, pdev->name, lpi2c_imx); if (ret) { dev_err(&pdev->dev, "can't claim irq %d\n", irq); @@ -584,35 +585,32 @@ static int lpi2c_imx_probe(struct platform_device *pdev) i2c_set_adapdata(&lpi2c_imx->adapter, lpi2c_imx); platform_set_drvdata(pdev, lpi2c_imx); - ret = clk_prepare_enable(lpi2c_imx->clk); - if (ret) { - dev_err(&pdev->dev, "clk enable failed %d\n", ret); - return ret; - } - pm_runtime_set_autosuspend_delay(&pdev->dev, I2C_PM_TIMEOUT); pm_runtime_use_autosuspend(&pdev->dev); - pm_runtime_get_noresume(&pdev->dev); - pm_runtime_set_active(&pdev->dev); pm_runtime_enable(&pdev->dev); + ret = pm_runtime_get_sync(&pdev->dev); + if (ret < 0) { + pm_runtime_put_noidle(&pdev->dev); + dev_err(&pdev->dev, "failed to enable clock\n"); + return ret; + } + temp = readl(lpi2c_imx->base + LPI2C_PARAM); lpi2c_imx->txfifosize = 1 << (temp & 0x0f); lpi2c_imx->rxfifosize = 1 << ((temp >> 8) & 0x0f); + pm_runtime_put(&pdev->dev); + ret = i2c_add_adapter(&lpi2c_imx->adapter); if (ret) goto rpm_disable; - pm_runtime_mark_last_busy(&pdev->dev); - pm_runtime_put_autosuspend(&pdev->dev); - dev_info(&lpi2c_imx->adapter.dev, "LPI2C adapter registered\n"); return 0; rpm_disable: - pm_runtime_put(&pdev->dev); pm_runtime_disable(&pdev->dev); pm_runtime_dont_use_autosuspend(&pdev->dev); @@ -636,7 +634,7 @@ static int __maybe_unused lpi2c_runtime_suspend(struct device *dev) struct lpi2c_imx_struct *lpi2c_imx = dev_get_drvdata(dev); clk_disable_unprepare(lpi2c_imx->clk); - pinctrl_pm_select_sleep_state(dev); + pinctrl_pm_select_idle_state(dev); return 0; } @@ -649,16 +647,34 @@ static int __maybe_unused lpi2c_runtime_resume(struct device *dev) pinctrl_pm_select_default_state(dev); ret = clk_prepare_enable(lpi2c_imx->clk); if (ret) { - dev_err(dev, "failed to enable I2C clock, ret=%d\n", ret); + dev_err(dev, "can't enable I2C clock, ret=%d\n", ret); return ret; } + return ret; +} + +static int lpi2c_suspend_noirq(struct device *dev) +{ + int ret; + + ret = pm_runtime_force_suspend(dev); + if (ret) + return ret; + + pinctrl_pm_select_sleep_state(dev); + return 0; } +static int lpi2c_resume_noirq(struct device *dev) +{ + return pm_runtime_force_resume(dev); +} + static const struct dev_pm_ops lpi2c_pm_ops = { - SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, - pm_runtime_force_resume) + SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(lpi2c_suspend_noirq, + lpi2c_resume_noirq) SET_RUNTIME_PM_OPS(lpi2c_runtime_suspend, lpi2c_runtime_resume, NULL) }; From patchwork Wed Mar 17 06:53:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Clark Wang X-Patchwork-Id: 12144961 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C8877C433DB for ; Wed, 17 Mar 2021 06:56:24 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 463D564F80 for ; Wed, 17 Mar 2021 06:56:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 463D564F80 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nxp.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=IYBBusJreyq9vdn7LppbQWOI4+o79+xir45+sSsY1Qg=; b=cgP3pQh8T7P22qXJTs9+AVe3X HFmSE/w7CgDBnkPpF0THjqWMyyuI2vh65wbeGTPtQUbmgKqrDjB0G8KQwRHyqLT3T78q/A4zBxq2G zTC0VDJwdRqlDqE6K3Jb4YBsh9DXdAno5slDnUYkAhDa76Y5RF5ln8TluQgU/8HSTsgoXG9YPDMaz 0AxsyqsqcECWNjn21Mwy/DGnvEsYI4uTIWi8RaxhHTQ2XXoEK2cJ05fZ8I5XwR9Dc5Py4vpcZOQTS Ual3JYbvCMrd4WmTGcmH1UIdJTkDOMhh4m/gxnKTYcdhnjrV/qx7E8aolS2QU1Vlv57kejEV8+eyr 7My4/S/pA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lMQ4l-002bLd-Rx; Wed, 17 Mar 2021 06:54:40 +0000 Received: from mail-eopbgr80048.outbound.protection.outlook.com ([40.107.8.48] helo=EUR04-VI1-obe.outbound.protection.outlook.com) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lMQ4A-002b6E-Hj for linux-arm-kernel@lists.infradead.org; Wed, 17 Mar 2021 06:54:05 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gISrt13dCZUFZO4eVbO9ctQn22ruluP0hWiuAaLNRU1943kvzTWYIKlqzGg07jtPFkEz2dCTShqD4g8wgbdAWV7i44nWEDTHGoRTOooV2GOOwIViayaD2JLnT1uHyFRavAyhOJZzmAQO/zGPdOWbtpL2gmY+7RYu+PlvOykjj8gR6ufCYTOKOfCVlRjc8lbzeAyPfksi94g+rDnJYTZnsEhLVBnpAE8MfQj4u1hTHDs7Y0M1IjBM8ZKUxdnGdS3YXkFUnAb/zSyZt6Yr5J32QsGToUpOM57NrpVdJjklSVqLlYG49MAv3iW3lgzHdfX9TyUG7NMyWRPVMaCirZyBVw== 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-SenderADCheck; bh=hJZXvAPB4JFtFYVB8ctM2LZCEtm9/HphDpEZmAwLhbg=; b=ndG+HLvcaDFkv+HJ+2dCJjz0y7Fy63No3zhaO2W0NQ4lIgAW/Phw1AtV6oKdxLB/7aOcF2nRtSFfPY0FYoJK6yhzIVjWDGbH3HMfXxYYnG34U4+hjEwHRgpzcORGBati/gyVCKo58DtcSVi66ApMe7vfnwFhuCedYiOsJSKRT4OthRmuJzHiG0ublAqyEg54xVgM0+o9s+91/BqrthdNd1A0bEr3Z8oK4ak2Grf3x/Riv5WPpFY6YdIG1HTORIadYHWuwM13DHnpLt9wLOARBwXPhGQ7ML9IHbbDKlEpp075VedL7CcdqtbAwhNbu4FLu0DRq+N7k1JKzv9AvZmIQg== 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=hJZXvAPB4JFtFYVB8ctM2LZCEtm9/HphDpEZmAwLhbg=; b=sJJuwST/cIPFabTT8V3aQzMTP5+zSwxS67X1sP1SAVgtLroRPBVIG6gt+f3kJVf0JCc2gmmxN5cUe72UZ7igqJQ79LKNVrrxvab+2ybDijvEDlBa1lXCSCdvhrVqxSUirYJrhOPK5QK8u8wRQz9hmjwCgPKlDHNdV4E7uiKtq5s= Authentication-Results: nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB5618.eurprd04.prod.outlook.com (2603:10a6:208:123::11) by AM0PR04MB7091.eurprd04.prod.outlook.com (2603:10a6:208:197::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3933.31; Wed, 17 Mar 2021 06:53:59 +0000 Received: from AM0PR04MB5618.eurprd04.prod.outlook.com ([fe80::69a8:a768:8fa1:7236]) by AM0PR04MB5618.eurprd04.prod.outlook.com ([fe80::69a8:a768:8fa1:7236%7]) with mapi id 15.20.3933.032; Wed, 17 Mar 2021 06:53:59 +0000 From: Clark Wang To: aisheng.dong@nxp.com, shawnguo@kernel.org, s.hauer@pengutronix.de Cc: kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, sumit.semwal@linaro.org, christian.koenig@amd.com, linux-i2c@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 03/11] i2c: imx-lpi2c: add ipg clk for lpi2c driver Date: Wed, 17 Mar 2021 14:53:51 +0800 Message-Id: <20210317065359.3109394-4-xiaoning.wang@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210317065359.3109394-1-xiaoning.wang@nxp.com> References: <20210317065359.3109394-1-xiaoning.wang@nxp.com> X-Originating-IP: [119.31.174.71] X-ClientProxiedBy: HK2PR02CA0215.apcprd02.prod.outlook.com (2603:1096:201:20::27) To AM0PR04MB5618.eurprd04.prod.outlook.com (2603:10a6:208:123::11) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (119.31.174.71) by HK2PR02CA0215.apcprd02.prod.outlook.com (2603:1096:201:20::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3955.18 via Frontend Transport; Wed, 17 Mar 2021 06:53:56 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: c28b101a-82bf-42e2-315e-08d8e91170fa X-MS-TrafficTypeDiagnostic: AM0PR04MB7091: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:454; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 50+K/JUGsVvZjg7Zw4nTBTiDxkhjOV1Rba0NcB6uXAAeFw0T0VH4ySOKEyNfo1MT3wQZgX5Yz6EYpJZKUkteVnNZi0OgvroHU7Dg0T59uwuHkFs6ooQqrYbFqsk9Bonrukb2ILCQLOvwZLgxpK8ALr3n8sDJt9TDpRyTud4DugpDrPdAVwXCM9hnDwdWouz/ThhovZvZBTF444D3EDPvdmdUj9L9ENkSaLUkKsD2G7TE1OEourYWXoZ39JTrq2C5Tc5I+YkQqrXPWVV68YatiLU8afpGgptgWbBVIq5gTYmMbiZ7lEQw8FbN0uj3pexdLRZ7ax1dK+usj2etc3WzqnbttDauSw4MfuKvvVRrr3b0KThrkwW3nsYczHBfBPiYEp36x4vCjKPU3pwpxVkynfN/qiqZ3zp7ujgTOMyMbqYImRZ+bur5RddkRTRuWskk42xJUyVXdc7RQGh7Il0BC2skhgZp4/a5Q+f10CwuxhKz2rd1XnCAemlv8tzUhpOzfHgBPGkpqGtfwzMUB28V7AzHRBLujSBn0Q5o5ofKv5oCyN8iCG8ZP2RBULWn5DYC/H/l04u2nHrqXbLH2C/J9hU/P+yQB0nzwvpLOTi+UDlu+Kq45AS0ZMkXHp0DhkdR X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB5618.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(376002)(396003)(346002)(39860400002)(136003)(478600001)(66556008)(66476007)(69590400012)(6506007)(66946007)(83380400001)(36756003)(16526019)(5660300002)(2616005)(316002)(2906002)(1076003)(8936002)(26005)(52116002)(186003)(956004)(4326008)(6512007)(6486002)(8676002)(6666004)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: ZpG5FI/QHtWIzUgNOziPaKHVm5cBwW0xK/Za8dtbP1rpYr2qaTKLmakArNvP3atfI7oc8Hj1KeIoNH0EBz+JsEd42iPcySpNYGP2QJVYcZf1K6QbSo7EbnI1eYbNrZdUETOyE5yzzQQlC9KwldmkpmcAB5rTgqdZMCH4kulxE6ic5UCdL/pdh9yGrJDSp1MbQcDoIbX3w0xO2aDYrCFvddX2eSdUReppVBHw6k3yjAOOOkZDynu7fZ6CW0/7m1/oZf/LnfPqYcVA2gKonf9OPjWj+7VV06pksE/AMZU7ATCVpglsCXY62Tvx0lPPW9IxeTu7DaXr0ge/RQi6Lwgw/q8HcNB17d3wuQxN1eUzhbywadpaC7c9hyuvSsaZwpdJ1wl44AMN08e+9L70uYahPSrja6cjYmTXZk6hjKlWeDcNO7NS+vUDGQ2k0p8NAtCmFfl7ptKA/WJTVXVs3HxULnAX8947hUxdN7Io7Hrzj97NFrkG9rXmGSAu4qEfZEb5qSnTA1Fj7m1qhVM+oDBHcdNsfaI8ZXnC+6eULPQVYy6NDh5g9m0oxN1eE3xjnTKEC4ohCsn+Z5v/1Ws+b9M1Crb9uPo4eCXJ/PHSKNfBVTm3L9qHVW51/+DLiviRngFRDSYo+Rb5FylnKrsYNWz+McMm45MdQngp961aR/P4XCZ5y/AKnYk8+z8RuyS/dhXZBk6Tw9t/DtajGr/QWU8eF8Q7noOMqB46iWuELJ2SghEVLp6zGcbWmE3ps7rlIW3k2IOFyGvsu1SH81kB0MJwrtlSVBFvXOGeIip/BgvQEpAXgXS3ZvZXwFf+h/NwVpHgNx0R5sRc1iNm3JyVLh+2l5Zd711DkxHJEBsR6ZUpf64QeWIWv5L4WAIwiBnBoNAyJ6A3LsZ6xhSgxYrkVbu7L21a9o+Pz9INqfCay+7ueZlvXpVEM9p7AX0o5rrJtT3z5Mr/59IHpK4zK9s0Y7FPKpd5j8JzbDniP9HojNUWmLew+SMQYOxH+PBlyFpSrgLoPRfo5y3+O7WRdpLxqyJoplespeb2Nor9hxAEpwrISpwiR2TryeS053vtYczuJytsnDixM9HYjSJeKFS7piy0EJAFU+CpCdslkpRz3/+q/wjiV/LQ+F6L0tPEXcIVTtDFFwnRve7A3VIMZ7BfDpTEg1XOYICqaUFi/KLR1Jb7MuExJAJqfFReQSaS6mLuPVyeLw1XY0AHqZKjew8MhFOPjnzdj7zMXC6BMDppszDrW0xVMRd4l0Rqfyfqtv69hO7d+GHeZnqE1Z8mr68CSH5rFU5RTWCyv+66CwxgEWSxswgCttfp+QvnJakEpW+/emXH X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: c28b101a-82bf-42e2-315e-08d8e91170fa X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5618.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Mar 2021 06:53:59.3425 (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: Hrn4Un24S9o/5ZdNMuzBryaRoiZbQQ8Yi7Qpq1wWinJPNJ768q8r9oPTsSNYJ3io1z7nZ5ozYpCGH9m4cDRAKg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB7091 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210317_065402_882983_984B7394 X-CRM114-Status: GOOD ( 15.32 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The lpi2c IP needs two clks: ipg clk and per clk. The old lpi2c driver missed ipg clk. This patch adds ipg clk for lpi2c driver. Signed-off-by: Gao Pan Signed-off-by: Clark Wang Acked-by: Fugang Duan --- drivers/i2c/busses/i2c-imx-lpi2c.c | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/drivers/i2c/busses/i2c-imx-lpi2c.c b/drivers/i2c/busses/i2c-imx-lpi2c.c index 1e920e7ac7c1..664fcc0dba51 100644 --- a/drivers/i2c/busses/i2c-imx-lpi2c.c +++ b/drivers/i2c/busses/i2c-imx-lpi2c.c @@ -94,7 +94,8 @@ enum lpi2c_imx_pincfg { struct lpi2c_imx_struct { struct i2c_adapter adapter; - struct clk *clk; + struct clk *clk_per; + struct clk *clk_ipg; void __iomem *base; __u8 *rx_buf; __u8 *tx_buf; @@ -563,10 +564,16 @@ static int lpi2c_imx_probe(struct platform_device *pdev) strlcpy(lpi2c_imx->adapter.name, pdev->name, sizeof(lpi2c_imx->adapter.name)); - lpi2c_imx->clk = devm_clk_get(&pdev->dev, NULL); - if (IS_ERR(lpi2c_imx->clk)) { + lpi2c_imx->clk_per = devm_clk_get(&pdev->dev, "per"); + if (IS_ERR(lpi2c_imx->clk_per)) { dev_err(&pdev->dev, "can't get I2C peripheral clock\n"); - return PTR_ERR(lpi2c_imx->clk); + return PTR_ERR(lpi2c_imx->clk_per); + } + + lpi2c_imx->clk_ipg = devm_clk_get(&pdev->dev, "ipg"); + if (IS_ERR(lpi2c_imx->clk_ipg)) { + dev_err(&pdev->dev, "can't get I2C ipg clock\n"); + return PTR_ERR(lpi2c_imx->clk_ipg); } ret = of_property_read_u32(pdev->dev.of_node, @@ -633,7 +640,8 @@ static int __maybe_unused lpi2c_runtime_suspend(struct device *dev) { struct lpi2c_imx_struct *lpi2c_imx = dev_get_drvdata(dev); - clk_disable_unprepare(lpi2c_imx->clk); + clk_disable_unprepare(lpi2c_imx->clk_ipg); + clk_disable_unprepare(lpi2c_imx->clk_per); pinctrl_pm_select_idle_state(dev); return 0; @@ -645,12 +653,18 @@ static int __maybe_unused lpi2c_runtime_resume(struct device *dev) int ret; pinctrl_pm_select_default_state(dev); - ret = clk_prepare_enable(lpi2c_imx->clk); + ret = clk_prepare_enable(lpi2c_imx->clk_per); if (ret) { - dev_err(dev, "can't enable I2C clock, ret=%d\n", ret); + dev_err(dev, "can't enable I2C per clock, ret=%d\n", ret); return ret; } + ret = clk_prepare_enable(lpi2c_imx->clk_ipg); + if (ret) { + clk_disable_unprepare(lpi2c_imx->clk_per); + dev_err(dev, "can't enable I2C ipg clock, ret=%d\n", ret); + } + return ret; } From patchwork Wed Mar 17 06:53:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Clark Wang X-Patchwork-Id: 12144963 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 36799C433DB for ; Wed, 17 Mar 2021 06:56:43 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1CFF064F80 for ; Wed, 17 Mar 2021 06:56:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1CFF064F80 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nxp.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=5OEZ6yYs7VEDXx0Pot+H4VSrrWRPvAsSjM9fCDd26MM=; b=ZuPu4cXxNVRp8bHmtoBNgN4Xv XjoSpO1Hec9mMYlVqaDrPo98qN0aGcJetYwIIOcTBGhmLIRW/jEfgf+SFdP68npqD9UPITbCnQlTY iKChZK/IGP7kmOHg+bX5hTNRaJhu/zSjjHP465Yw+xY5GMY0YlpR5fP6HvkQLDQNGq52+T170/iYx Fw/8ekItA6bTmmEMecSFSFvgL2a69l0Z/FOWeO/zyCpwaY8jhlnzXgqe1B7XNGDnKvoh5HaIsZyck zIF7rIvzhiKSiqQRw7zrzpvDvC6V4Fe6JMpa+zGL6/ZiwXZ10RzUZushkPTgbU5W+36C25y4TStWM 20WYlqwIw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lMQ50-002bQi-Dx; Wed, 17 Mar 2021 06:54:55 +0000 Received: from mail-eopbgr80048.outbound.protection.outlook.com ([40.107.8.48] helo=EUR04-VI1-obe.outbound.protection.outlook.com) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lMQ4D-002b6E-9D for linux-arm-kernel@lists.infradead.org; Wed, 17 Mar 2021 06:54:07 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=L1QOq91E+Hyj4arFROUnMfi5mi1MTbDWD+xsTdwqzOWhUDTQ1iybsLAafEn0yCj5U15FYLebSR3RaJdft3AlEDh8vjKRHDVWi1p+UESiRNgVAvcBM1+FyoN4xKQ0VaQ001vJaKSmhFOICqpjfe034DGTG9+5wG+HfiJLb8CB0SRRxb/Uevc9CD5HIKZoLtV4rqm1kXvhnaE3VQfdRTr23LXEczXJCd5OIiuoVLfuk8sCAHfByt6suBrOZv9K85s9yMjsxO0GUP8irBNIfRwKpNfvsDWOLcUjJaL5OOKdWbl+GPsdy8ryAI73GIVbKINg/SUZtrYihCuINZse7lt1pg== 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-SenderADCheck; bh=nomvi37GOQXre/v0V/gsm69Yx3x51YjooFfhnsICFqg=; b=UfTuKe5fJ36AcHBRMSXpDlJTGxAKVG1gV8jbOnAmQFW3S06rcIVBedZfEcNVqstQzJG9cMIgCbszyl53scZdPI4jCubP7a0AyG6qIKJKGq3+IVTCVwS2wUEUtyA77q/+WMwlS/2iTmEQ+sg0DDla+jZgQAPBtlJUso01rxMaT6phq0QCqRraf8X/RhnVIPHk6RKmJ6/6jlJ/7HRnJNOy+I6J6x1I8CESs40pR5OOR7eAHKwQEHuaQw2btbokaI6q/JLA9LiZlW3gH7mjSB1nqpWJD84++qr+HNBeEwr3RzTtnl9w+Iy+wbsI+ZI2WFDMZX4jLX4RVRKjJsdAyLiU/g== 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=nomvi37GOQXre/v0V/gsm69Yx3x51YjooFfhnsICFqg=; b=PnvKPZLMJH7im9Ul8PQNa/D1L6877h7F2dKCuEBuNdiCRCINY/aTcRD3OtTmcWCaTftw2u7a95IiUIuSZNdvLImRh8QjfaGu5KI011dUFkxsjicgFH3tsYkm0VtabI7ohHqAxHH7F9PUEgwI4613Lopps2DSstMyirr+vJK8i3g= Authentication-Results: nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB5618.eurprd04.prod.outlook.com (2603:10a6:208:123::11) by AM0PR04MB7091.eurprd04.prod.outlook.com (2603:10a6:208:197::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3933.31; Wed, 17 Mar 2021 06:54:02 +0000 Received: from AM0PR04MB5618.eurprd04.prod.outlook.com ([fe80::69a8:a768:8fa1:7236]) by AM0PR04MB5618.eurprd04.prod.outlook.com ([fe80::69a8:a768:8fa1:7236%7]) with mapi id 15.20.3933.032; Wed, 17 Mar 2021 06:54:02 +0000 From: Clark Wang To: aisheng.dong@nxp.com, shawnguo@kernel.org, s.hauer@pengutronix.de Cc: kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, sumit.semwal@linaro.org, christian.koenig@amd.com, linux-i2c@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 04/11] i2c: imx-lpi2c: manage irq resource request/release in runtime pm Date: Wed, 17 Mar 2021 14:53:52 +0800 Message-Id: <20210317065359.3109394-5-xiaoning.wang@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210317065359.3109394-1-xiaoning.wang@nxp.com> References: <20210317065359.3109394-1-xiaoning.wang@nxp.com> X-Originating-IP: [119.31.174.71] X-ClientProxiedBy: HK2PR02CA0215.apcprd02.prod.outlook.com (2603:1096:201:20::27) To AM0PR04MB5618.eurprd04.prod.outlook.com (2603:10a6:208:123::11) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (119.31.174.71) by HK2PR02CA0215.apcprd02.prod.outlook.com (2603:1096:201:20::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3955.18 via Frontend Transport; Wed, 17 Mar 2021 06:53:59 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 9bc4d20a-fa46-4171-dc9f-08d8e9117310 X-MS-TrafficTypeDiagnostic: AM0PR04MB7091: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:792; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: A9Voj86+LFYuVtI8q7sdILA1UrXJXEtrfxo3mtEMcXTt4zMIwb57kJpI2vIRYFUtZtJLiaNI91luWd9t5qc1GSPd117v00FYtbx/Kn9MB40qvZp5t/H3F8heqrhLL1s+d6eFPC3M+Fg6g9+wB6gnhTPO8rImXJ9hgcSr9OgTqpaXZ/HWcFUIwir+wjYa9gRxxu6y7cXeS0FaYeJqsUhRS5nFQEHhQ+kx3bOmvz0PCFN5WjU+EfXFcOk2BcjC9GvG463D/zwB49lqlQVlmcrWQPZMPwRwgaLaV43C+P+4alKBf4by7otJ7aNs1lT4Lu7T/V/yNdZM5p0JEctoH0Tm6CBXC2sBcasAj2/+N22qCrCWqZb+fz0tk3QLgBaj258ua3FZarDO2I+UFj/59ucZpNSMmjjBV1yEnOp3MUS8aaukysMPMzD9SS8Iv1hJqk3rZh9BUpQl1ZCSN6xGp9EHpNZ3/gfl/NDm6YyOSbrQ7RFkAj3GLE93Fj+/HlkHTg72+DtOmNwNpoOYkdhj+YlZOPnF+DPjH/AO79G9iz2hEQXJUE2fAzLY2CqxAKLsTuKbbj4UfXawiPzWoNbinzsBDEZ0iL10jx3XMS5MrpkFvrzeb+YSPCgYvoxMszyOSgnN X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB5618.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(376002)(396003)(346002)(39860400002)(136003)(478600001)(66556008)(66476007)(69590400012)(6506007)(66946007)(83380400001)(36756003)(16526019)(5660300002)(2616005)(316002)(2906002)(1076003)(8936002)(26005)(52116002)(186003)(956004)(4326008)(6512007)(6486002)(8676002)(6666004)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: R79hcwmQQEGgqm4sOrCzouOihvEGFUTpInUqokUeVdRddEAoZeDqC8fGYJBZTho5llgLYjdV71wtH7Ak1A6iUEpSWuWRVTgeWuh0BpWmTd0lRFY8n5+6CNx79wRuQoJZRgTT0ofzOOCXesfRpNlcrfNxhzdl3LqxTZ+zLZyri6ucU39D2HDOlfDh2njrZPUS/REkunRH7Ik3k9lYi9BAYQ6OLfUlkxZhqe8ObNZyxe0kfNkZ3BbcSOLL7hjXeglkMxZ5LmM7EKFNv8ynDhxh9IKQBkHW5mItBpduPUP2o05ukoTN698zxmSf6phzre8XMLAjEHBDUlVOBIp6vnvnmgOyyn+rNkZugDHjdW+r6qTX4Szlp16C3hYMVhGDfIX2y3h+JWKP6RD8PTMd6I8oqChwv8hk+UzfVRYdOpdv7pjxaxwgDqdjaOdhKRi9c8Y2R/Xv2VKieN0RsyXjDQGM++OUqXHWUY7nEqIfhNpcpImx5JI4eg4T1w9kkADjM7bLXsj7tFKgde372vFseDpUJik+uUKIFTERbxk52lbMtTYjp2gnV+a6SFm0SvCtvkYH3Z+z1CseERVrMUkLVtn1uniPkJivcs5fGfKPyDnxJJq+O95z/5FihzY5yybTDnY0YhqxNXQaHjMl5etMyMZCm/NT0l9ccFMm2sTBBfpGJWg+Xg/gF4emPCkYMFp9rhWgzkVNSkcg7diGlgIb72g8C7EHzJaUvmlhNzdp77MqRhwwtZzKVM6T4oDxiZjut6FHWAgG0jfqHWNgxlBTaSpp3oqG7t59/GmS/aifPoY//GNSrxf3kpVSyGNVxP+XsEOOWd0uei+bmuCeUg24i38PXkM4dYcmzsbokGfP5gBrW1o8G0CUZ/IhcesgaHTM5rSjDD2K+IS+gBMsH5Wgkb0jU1RHMK+f71m+H4Uef0YGZFseh6Gn3LPiT0i3jebFIC3xqm4VPpY+W4SLumbIYNEeGy38f+Xe+v6PlEBkAv/9oOerLMAg+9wx8A4GcBFfnW6wpvg/6aSERJEKT4WD5DsLh6GVZyV65ExeTQvqUc9g0THCdJavrWBRQIURdOxK4qcTPNk7V+fHZtzwY7lHKwLbkcNHkiA2L/jE7/TCw+GRrXY9R7OBDV49FAj6CPQEN/zuhOuXdw3dIzw6r8V0QG2oledbh+1IE+/+sRaOKA8OWeoy+i4ORsLHnl6BUPK7oqsRfHRxO8V4rCrUubMUU7p86/H0HsHaHssMNBxr63aLdO6IaF7v/Zoqa2YE2etVsvNK1wLuBESRCnSpp96SF+yAQF8PI3OJzBVwvjRAnaGVte+jFch5sI7vot10MHbQMnAq X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9bc4d20a-fa46-4171-dc9f-08d8e9117310 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5618.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Mar 2021 06:54:02.8295 (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: 8/iJD6JUz0gGmQivJKbucKEjQFBJuMbUVQr9WKuzRiy9Ks4kESbPL6+BtIJtCOZEd6ORfygf6LdBdiM/iVK4JA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB7091 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210317_065405_502642_EF46AC1A X-CRM114-Status: GOOD ( 14.83 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Fugang Duan Manage irq resource request/release in runtime pm to save irq domain's power. Signed-off-by: Frank Li Signed-off-by: Fugang Duan Reviewed-by: Frank Li --- drivers/i2c/busses/i2c-imx-lpi2c.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/drivers/i2c/busses/i2c-imx-lpi2c.c b/drivers/i2c/busses/i2c-imx-lpi2c.c index 664fcc0dba51..e718bb6b2387 100644 --- a/drivers/i2c/busses/i2c-imx-lpi2c.c +++ b/drivers/i2c/busses/i2c-imx-lpi2c.c @@ -94,6 +94,7 @@ enum lpi2c_imx_pincfg { struct lpi2c_imx_struct { struct i2c_adapter adapter; + int irq; struct clk *clk_per; struct clk *clk_ipg; void __iomem *base; @@ -543,7 +544,7 @@ static int lpi2c_imx_probe(struct platform_device *pdev) { struct lpi2c_imx_struct *lpi2c_imx; unsigned int temp; - int irq, ret; + int ret; lpi2c_imx = devm_kzalloc(&pdev->dev, sizeof(*lpi2c_imx), GFP_KERNEL); if (!lpi2c_imx) @@ -553,9 +554,9 @@ static int lpi2c_imx_probe(struct platform_device *pdev) if (IS_ERR(lpi2c_imx->base)) return PTR_ERR(lpi2c_imx->base); - irq = platform_get_irq(pdev, 0); - if (irq < 0) - return irq; + lpi2c_imx->irq = platform_get_irq(pdev, 0); + if (lpi2c_imx->irq < 0) + return lpi2c_imx->irq; lpi2c_imx->adapter.owner = THIS_MODULE; lpi2c_imx->adapter.algo = &lpi2c_imx_algo; @@ -581,14 +582,6 @@ static int lpi2c_imx_probe(struct platform_device *pdev) if (ret) lpi2c_imx->bitrate = I2C_MAX_STANDARD_MODE_FREQ; - ret = devm_request_irq(&pdev->dev, irq, lpi2c_imx_isr, - IRQF_NO_SUSPEND, - pdev->name, lpi2c_imx); - if (ret) { - dev_err(&pdev->dev, "can't claim irq %d\n", irq); - return ret; - } - i2c_set_adapdata(&lpi2c_imx->adapter, lpi2c_imx); platform_set_drvdata(pdev, lpi2c_imx); @@ -640,6 +633,7 @@ static int __maybe_unused lpi2c_runtime_suspend(struct device *dev) { struct lpi2c_imx_struct *lpi2c_imx = dev_get_drvdata(dev); + devm_free_irq(dev, lpi2c_imx->irq, lpi2c_imx); clk_disable_unprepare(lpi2c_imx->clk_ipg); clk_disable_unprepare(lpi2c_imx->clk_per); pinctrl_pm_select_idle_state(dev); @@ -665,6 +659,14 @@ static int __maybe_unused lpi2c_runtime_resume(struct device *dev) dev_err(dev, "can't enable I2C ipg clock, ret=%d\n", ret); } + ret = devm_request_irq(dev, lpi2c_imx->irq, lpi2c_imx_isr, + IRQF_NO_SUSPEND, + dev_name(dev), lpi2c_imx); + if (ret) { + dev_err(dev, "can't claim irq %d\n", lpi2c_imx->irq); + return ret; + } + return ret; } From patchwork Wed Mar 17 06:53:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Clark Wang X-Patchwork-Id: 12144973 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A84C8C433E0 for ; Wed, 17 Mar 2021 06:57:18 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8A0C364F80 for ; Wed, 17 Mar 2021 06:57:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8A0C364F80 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nxp.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=DVltfLxPbRlKIaT0jz4fd5DUKPbTZgfj3w4ZWkg5s+I=; b=BAYkDYMufH58Xca05sO5Kh0tl Qe59poeXkJOioPX7yQiPdfCpXRsgkQ/c+D0WvKcG3WSKZF0vghD1L36my9CpDEwpIvx1aT7u4B4X1 YHWtgKU7yce7+vC4RDs9MUZfDBIEeynjqt0wizmNo6uSL5vsEExt2du90BKso6/iFA8PdEcpVGpz+ 9juQ1FgmuSxsryH6zhysacErC0YAUtSmOcmmEb7fEXViCZO1q09BYOWS3G4KPkLVBzoG1Qd3Lt9Rt JCym6tCGMDkIlY9hHyHSJT81Xow/Bfo0fylTHoCKTlHKF17bGpxyqqBVo9OsM/KJPUg5icgDRud0d K9QfhTsDw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lMQ5M-002bYc-7j; Wed, 17 Mar 2021 06:55:17 +0000 Received: from mail-eopbgr80048.outbound.protection.outlook.com ([40.107.8.48] helo=EUR04-VI1-obe.outbound.protection.outlook.com) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lMQ4G-002b6E-1N for linux-arm-kernel@lists.infradead.org; Wed, 17 Mar 2021 06:54:10 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SPeY8SBnuER2qLiDzt0ixN18MkoIwx5gE/OoE3i+CxtPMl44STFNppqGnZlUEWUggsMMIaAqwxiY9MXdpanTXAapFETAeHkOotWBkh0+UdxTv9J1KQ2PbpWbA7J2qAGFcyCPZJAzvnH7RH5sFhVbxtO1P2ZMzZdJKCLqIp6gexE0UjCVlDfcPNIlTvYB6gw2vVxEgzJiNoZ1DgPg4DGvRzvYo9KGi5onaKumlKKwCj+Na4UbGsRQQdHavUXzJBaI+NE1Bl0If5gk2fWcAclC279eneJbZxMfKGIyBYZUaCidIryWniM/kwXWvwLMtUmEfhFTjraNzZRk5G2+9ate4w== 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-SenderADCheck; bh=xDxjwFrFhj+Xb4ZbEYW9R0HtG+uvExh/1+L0PbKZQgo=; b=XDybOakP7/w69NR4gu/3FJVNnJoq8Z/xukF/t3a6FmjohWkYgToUQ+x6Jsb01lsqiCtZIzfdXIzRTNxpcXlD3K+uEJZYpC8KGHKInfSRLtpAQqAcH3Lwds6079xLFApCHgUN7u2oP9voH+2BPbFuQm/QUdSPdbKFClpIzW/ALNw9F+lFVStp0jDhBm6rxWMHt1kO/Aq1Cew+pgEzuFnJrGOE6QQbwx1h+LFY8Vl6i1wOQZTmwGDS1IVRn28ivL3y71EhZ8HLljkVb3h/kFNX/4MxzngltgES6P79DBcDDARF2siYR69s7vUYD6ldXNoQH0A19SDij39HqWV3tF64VA== 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=xDxjwFrFhj+Xb4ZbEYW9R0HtG+uvExh/1+L0PbKZQgo=; b=keyfHUMtzu6bJSBFR7kC26uJrvtp24tFjezzioe4xMh8asLqYqp/jH3PkVFCrV7O2rHbrLJ5JukJsBEr6e5FAn3HRPYSz9hHxiABSASEnhEfcRK7+Uf6otoXYi9q9Ju/jGuCO9i2j94m7JBMFVdAOE9S+YCepiMZdlIjOK5diU0= Authentication-Results: nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB5618.eurprd04.prod.outlook.com (2603:10a6:208:123::11) by AM0PR04MB7091.eurprd04.prod.outlook.com (2603:10a6:208:197::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3933.31; Wed, 17 Mar 2021 06:54:06 +0000 Received: from AM0PR04MB5618.eurprd04.prod.outlook.com ([fe80::69a8:a768:8fa1:7236]) by AM0PR04MB5618.eurprd04.prod.outlook.com ([fe80::69a8:a768:8fa1:7236%7]) with mapi id 15.20.3933.032; Wed, 17 Mar 2021 06:54:06 +0000 From: Clark Wang To: aisheng.dong@nxp.com, shawnguo@kernel.org, s.hauer@pengutronix.de Cc: kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, sumit.semwal@linaro.org, christian.koenig@amd.com, linux-i2c@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 05/11] i2c: imx-lpi2c: add debug message when i2c peripheral clk doesn't work Date: Wed, 17 Mar 2021 14:53:53 +0800 Message-Id: <20210317065359.3109394-6-xiaoning.wang@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210317065359.3109394-1-xiaoning.wang@nxp.com> References: <20210317065359.3109394-1-xiaoning.wang@nxp.com> X-Originating-IP: [119.31.174.71] X-ClientProxiedBy: HK2PR02CA0215.apcprd02.prod.outlook.com (2603:1096:201:20::27) To AM0PR04MB5618.eurprd04.prod.outlook.com (2603:10a6:208:123::11) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (119.31.174.71) by HK2PR02CA0215.apcprd02.prod.outlook.com (2603:1096:201:20::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3955.18 via Frontend Transport; Wed, 17 Mar 2021 06:54:03 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 27f2fe57-cc8d-4472-b736-08d8e911752c X-MS-TrafficTypeDiagnostic: AM0PR04MB7091: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:346; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XJoAXeGe0TSpeF7+iLiUNJRMnS2nU+Nw+kYl5OVyzz8JymT9s201gSNlLdIzPoPTsTRxewW7F+k6VqRyOMODmZGP3OKxg7VmGk1TKHjAdcgDOlXpJqkqVeNiZygka6p6uxSc+o+eqxJxk3JIReCIroQ0JQKrEO3kOXLhBTTgURpNPYN4UelRxj0ZUI6HAww+xY/D1v3VPXpK9m3e4kI0PJRJUIefkh/S+RLg12NI7BuKKVmuh78iC3KFv3+m9Pyy4FgnUM65cwEAOOhZPMoaaCz2SxkuATHTUzdv8tWCkNYLqSBsXKKYHkp+GcxrM/GQ9l6qlk4gx4yYMY4ogE56yTKSHunrru9PblXhIbBKDT1GhW7cMYpa8s3jXgYhv1KDL1AVUC6n8W3nE/TjVI8Rtn1N0HN3VR7Zg0lBgmxbxKMOtjLvlDNV/uNS9v9WkqSpfp4Nl/1oPQgI7FGMyyVBBQZ2AAhKetsjuoBGzk1iQ01IxU1N6hn3aO60GDlHJmF7nguV5zaBc/3VcHimun1iRypZbk55o0m8rzEKIZ5N4Ma0FgY7kdtIhL4f8aZ15Q+T0qJM1GxenxR0nCOGSU/hXBRkQrOfKFg6A0/k59FlWsqQxsogyWacXVYFRyWDfKHU X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB5618.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(376002)(396003)(346002)(39860400002)(136003)(478600001)(4744005)(66556008)(66476007)(69590400012)(6506007)(66946007)(83380400001)(36756003)(16526019)(5660300002)(2616005)(316002)(15650500001)(2906002)(1076003)(8936002)(26005)(52116002)(186003)(956004)(4326008)(6512007)(6486002)(8676002)(6666004)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: dWa8ln4BD12slHdt5kN9keTtpTN5ciuqxuQqgvmKe7qWC82RdBzaH6rGheum2CXzhZa9gWtOaFmyoSknVHQh0WuFWChzOOyWyZtmSEpcR7C1N72u0YTwe9kUh7pGcDcN+v1VflJyb1W2k5yODtm3j1Jm2Auf/IAU8XmkbqKqIqB23vU1MrFr8wLgGQI/xvMJsD+SlmNniksR8xwpIfE2JBuYA8vwoKL0FzI1XXfViG00hBJS1yt6V8aJi9Qc/8s7FJ+HnmZncQ0DbENaOWJtQig0lZCWNlhYTf3Vk6yb+6SB+UpBWJdZQj3/sNhRRAbqXjLrjiloXLrUsNPOU/JORElpxaHl1OQAmvURIq0v60qHndX9q1A9oShGm7kUjC6XBM6X1JcwMwKrzbLwlnqPlEC9q1jesGgJdaN5RRch/G9fz6zJbZsA3VBpldb36mKb5+yecIFi1XQ49wQRN7hYa6vzvxMvsaCgPWlRtYOdQ5soahTq894KZK55mN9m1uJLP2pen9dV4JaG3FWg5lJbLRwHLew+6KQ6njZuf35cZHRLDTgnB0wPBdbG+4mVlVd4+EW/dB2jHttz/iGE4QlkJTxup4bt1nO5oKyVXLoxe4psSJMN4sWiN6P6qvwZPnpCNVflMbEBhkFbzJTpxf+wZ2vICG7tZAvr1cl3Iy0163cwzv4JHnJrGfaAzIUNkq4mQCKORts9SmcqlwW1hFhaAhHTdq1KAKA1cQmmU0saPj/t73E6W1E6lCKHkU/3inTXdDVWGPl97JaeKM+54td4ImFi58iTYpBPkiRMvS9HAUgeKTupfp4ZPX6qWXWyU6xU1Q810ctUBlt13tvmjabRJLn5K+dL6rwRT4WKxzzGnfuJve0w1fcLq6Di3t2UYSPWGr8wDfhcKNYQ1wApv5ioa6D6RO+55tmGyQNYTP9t+/g9JhGwm7hXq1uSWW6rO+5rdNMnDhyRo3J5Flk78yb3tf2yz3MxOZaUFtvFzUMdoJh7NU81n+rf44H5z4d5nV6bFSolH+mk2KPIEIRx0ia9qoo72m2QKvsFriqL12kTJc6nX0Zw29dhhUicYHOgenFpTIz5DWc11hFy7xPv0jwwHJPkN2OcJq6Sz/6E7XK5ZTl2hNs9YPVjrjOSr7hn4IMXOl3ooAjbNjb4bIHwUOkXgxNY/e49rnMf05C2OIwZqTO/mnQpefc783PQrqrFSaLK6kDqDNqxDvEvhVX8+8uGtXF4O2y/UfjOzFaOfmn9TV14suCuZW2Gu5BlWL6tLVzi9gxQWuOhhbRgoCmHMYAS77uRffCSecZvdB3cEUv6vjAbyBUoyQ20eLRgybjLAGXf X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 27f2fe57-cc8d-4472-b736-08d8e911752c X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5618.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Mar 2021 06:54:06.5524 (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: MrXj7joMJFP7k5cxp6/4Yf6JLv+pYG9owXdqJjj/3iWmXu4MyaWh0iFLcQrycf1BFyX8d6oBdqDhJLbrmWV9kQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB7091 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210317_065408_452956_621CAEE2 X-CRM114-Status: GOOD ( 11.84 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Gao Pan add debug message when i2c peripheral clk rate is 0, then directly return -EINVAL. Signed-off-by: Gao Pan Reviewed-by: Andy Duan --- drivers/i2c/busses/i2c-imx-lpi2c.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-imx-lpi2c.c b/drivers/i2c/busses/i2c-imx-lpi2c.c index e718bb6b2387..8f9dd3dd2951 100644 --- a/drivers/i2c/busses/i2c-imx-lpi2c.c +++ b/drivers/i2c/busses/i2c-imx-lpi2c.c @@ -209,7 +209,12 @@ static int lpi2c_imx_config(struct lpi2c_imx_struct *lpi2c_imx) lpi2c_imx_set_mode(lpi2c_imx); - clk_rate = clk_get_rate(lpi2c_imx->clk); + clk_rate = clk_get_rate(lpi2c_imx->clk_per); + if (!clk_rate) { + dev_dbg(&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 From patchwork Wed Mar 17 06:53:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Clark Wang X-Patchwork-Id: 12144971 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EA846C433E6 for ; Wed, 17 Mar 2021 06:57:13 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C68A864F99 for ; Wed, 17 Mar 2021 06:57:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C68A864F99 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nxp.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=hwVMdWWRAGzJObb/P/rsIOfUsPCT9La41cXzQP2If1A=; b=OEaLA5avuWCf3N3Z/ShCPpgxO THgiVMb77HlGqqk23HmZSPUBZbqxvLn0vXuq5V1FrwYvMAnkQNRfZyD+Zc8Nd89pjrCaJwB9dZcNt 1y/dqESAQ3VYM6Eti+an9cLdeR7dKhSC8OE8RxY/Tzys8sqXRYyIapLfMCtlBMM/sl/RtjV6k0I1t jQQ9ehmywQ4mb9JkqKyohXcZ3MSzR5ILau84T/Pl15S2ZSTbVOsTtOnzk604ULyMxv2fY7a9RxfaM KiEHirzNFMW0oEfNRHQH8DCl2cOX2kN5/5ETkDEXzmHzbzlgreu+z6DftaQt0kHqnt4m3HOFKTwrb wbXEjwuYw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lMQ5h-002bfw-3b; Wed, 17 Mar 2021 06:55:37 +0000 Received: from mail-eopbgr80048.outbound.protection.outlook.com ([40.107.8.48] helo=EUR04-VI1-obe.outbound.protection.outlook.com) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lMQ4J-002b6E-18 for linux-arm-kernel@lists.infradead.org; Wed, 17 Mar 2021 06:54:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bmC6X4EC1lx/7aHzFr1KJpEqbhbqNRNi3UgZFKlUJPg8VjOR71yzR35TFgOMpysJZdG5G+k1ztvOX9S24RC1in/0kpS65AfdaFbLM94iEaGIhojUvEF+bcOLaM+VxJ7LryNooemo/rA4rk4KzuumWcUwylZfaUp01+NxQnHbh0ozBLcUMBOC09AqKQJmR9IJFUnximcpJz23VrDMui+iGO+N2FmEeTGMHc7vGTXa8W5dYgH9u7Cyo/z5F7JEeP54B6zO8hsKEaRjLSIZuCdLEvhgObR6gZp8igdnT0+gT0/B1zKpXiJSzc9HJVEJfUwur6rVwpDEV+frIZiJkkLppQ== 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-SenderADCheck; bh=KzRv8MUSSO9tJB1wBGVQAJWYkqphr96Kj5zqbos6gsE=; b=JPBlJvpYzHtcfSjeN6d29hoiRb14JnZMYuRoVG1HgztD7HKM+VNS4+5/RNCP/cN15BFbPwX8En06Pdl18Xe37LyHwhXzLQfUh4CzDRhRnxJsEJv5hOp2S3B6z85nQGAqYoAjf7RGtsxFX5duY+UeJl60qSJvaZjx950irzK4kcGdngVrX/BwZqn7IbyhjSGAVyAQw5juNabL2HedEslOcmKboIzpilabSXThfP8d47hR2Hf8K7s3ocaPgmF9c9MSZ54Ngfn9RJJiPQvfQHaqj+A8XBHJUbmX4JtfNiqO0N6ecmos8zuJSHrAWZlZOZmOnCZ2p6wVG7FIG88I+sbAKA== 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=KzRv8MUSSO9tJB1wBGVQAJWYkqphr96Kj5zqbos6gsE=; b=azDGliFpiw+Iooaigw41+9umP8oJTxBWIjHYEsrDM4fV2jlofGjihPg8SWhqGlG9jdDKSlKmjacMoRSocywIOyNevdJ7vz3+Zfi6cBBHDtvi/+X49GelNGHw8fasQYqsUldcEyp8h7Rslhj23EKF11RXSywOpEUIozxvmnx1kZI= Authentication-Results: nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB5618.eurprd04.prod.outlook.com (2603:10a6:208:123::11) by AM0PR04MB7091.eurprd04.prod.outlook.com (2603:10a6:208:197::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3933.31; Wed, 17 Mar 2021 06:54:10 +0000 Received: from AM0PR04MB5618.eurprd04.prod.outlook.com ([fe80::69a8:a768:8fa1:7236]) by AM0PR04MB5618.eurprd04.prod.outlook.com ([fe80::69a8:a768:8fa1:7236%7]) with mapi id 15.20.3933.032; Wed, 17 Mar 2021 06:54:10 +0000 From: Clark Wang To: aisheng.dong@nxp.com, shawnguo@kernel.org, s.hauer@pengutronix.de Cc: kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, sumit.semwal@linaro.org, christian.koenig@amd.com, linux-i2c@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 06/11] i2c: imx-lpi2c: improve i2c driver probe priority Date: Wed, 17 Mar 2021 14:53:54 +0800 Message-Id: <20210317065359.3109394-7-xiaoning.wang@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210317065359.3109394-1-xiaoning.wang@nxp.com> References: <20210317065359.3109394-1-xiaoning.wang@nxp.com> X-Originating-IP: [119.31.174.71] X-ClientProxiedBy: HK2PR02CA0215.apcprd02.prod.outlook.com (2603:1096:201:20::27) To AM0PR04MB5618.eurprd04.prod.outlook.com (2603:10a6:208:123::11) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (119.31.174.71) by HK2PR02CA0215.apcprd02.prod.outlook.com (2603:1096:201:20::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3955.18 via Frontend Transport; Wed, 17 Mar 2021 06:54:06 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: e4fc1dc5-99c4-4696-a1e3-08d8e911775b X-MS-TrafficTypeDiagnostic: AM0PR04MB7091: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1388; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dN8DtHG5adnYlIWOKZuc+DXYUFdw6dP6Zs37hMezQ1R0aXBE2GNAPeZLDLxDEL1hQkpO60pUjUv+PwM8EJfMk0YygPUM6eTzRFBmkA539MjvCI3rwAgHD9gr/LSsGbmXjy6tpDt0+eWPXf8iZWAvMKNxLtljAO4wRXCa137/gyz4OuRjTYspErw2Y8M1MkMWW9Utmt2VRMnzoxJpjsZ1GP1ZCOw0KyNVsKnt0rfyxIuFbmA/k/PZ4HWRkyE4T9JIH6YPidMx4dlG4AbewvWUYH4ZvthXmSQkjoD+o3s7DzzseL8huxmGsMjwBz+gM/FjXw07rcwbtg9AxtEWUW/LYXLNYgzbZID3NjElG6VvLQZxPrAqeVmCq51KgjIkgPqUrlJGU1Y5IW1HyAN7zc3+dsUJ1njpk/yJfEnedM5CDaSKK7uSEG9OIkWfbot+9SzX7knw4bFR+sQ/++m1Bl4iJ+RszRJ+HM116S82ow4kNoSqSFW4JXAKiIvdlo6/wuaFeT1w2wUbefK2DlFpY8j6AKTzlofnby6n3cFNEKEF6U85xfED6V228T41vsjit6MKFzN5mkM7cdtQltj6dXM/2sbHEx/Scpkej0IaQ+FHsMsUTjmmrf2QkYW5NYgF/gPi X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB5618.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(376002)(396003)(346002)(39860400002)(136003)(478600001)(4744005)(66556008)(66476007)(69590400012)(6506007)(66946007)(83380400001)(36756003)(16526019)(5660300002)(2616005)(316002)(2906002)(1076003)(8936002)(26005)(52116002)(186003)(956004)(4326008)(6512007)(6486002)(8676002)(6666004)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: LbWkd/LXYTxbazK0ZezkOmZfldghVxtiYhk24kouA+OgW1mj7U3vFXe4rdxOIBUQJunMp75TIpEkuizy7tXku+cJlhQwsuCeHdVDirpsgkA5dwOFEIa/lrJiy+2g5zonIti37DwAnf7c3DeFPX9bMLi9BUHdlje12mf/wMnIsenspLb8HDLMOQZQWHGrm1gw9WXM62hrMntlEaqiSWqqwqj/shK6aaqJfmNCdkPhmnyCv+bkNUXJpl8pe6hlZfWypxenDK1fNeJvfvu2g4f0Z6TZTRx2CPIrcqXU02l0Sb/ATB1NagRnXl+5UCKs5CUOmU0fxJkupEL98tCF+qzYbV45w5vfuj4NZdq+abpBPqFKI9n+tE787IyNH+YCHkKci+EwQJH5ObYbIhNMMu4Cg2hwnbwLTaFvnongNbwLvHkYPtWOwB+Pi7wVTvuts3uy5QUnYV1/C5YeT9DKIsUcUM2h9ZSP7UHtPYYtk7qui6kDKDcVxS7KbGam8n8rAn03B+VE8xpu/YLDGGwBc/pOg3eKdmWfSB97IMme+6v1Bo5AN02LGt0XIfdPCCF7ByhmktATcRPiNCchzJt3KYx11JTIlXYx7P9JggK9h6tIZG9V+lDAGCQK0e0OZTxdywwvcZbZtvwfIJolkv5bOcER+qBE6ymH1lMZFQUk6C/qBU0BUFsdEOLGWNMJIKmrScpI/x25YJOAeR2t3AIjDiFZV2O55gr7ous91NSqJ+TwSrbT/TfEd5z1rrr13g/MHkhaocuFNSuuuoKMopxmVRdWvVS/UCXl0nd0rw6NR5FSkeHoVnAX8njijuasvRrXUOJT2rhG55daeO/KcIWa2czztZ6npKocCAPw1eAJ3hU+MFNlVeQ9BBawypgUGknFnWnfYyreeLF4jwGJ4ylMzKCIfnUNeap0/gfb3tc27SSuhBWSV0Kq0cWputEA+pvn6tNpo3iMnnA3gjIXrAnU87tKVfeu2qtqdBuk5WPRyDRzilNau/mOzuwYf/DVV6qcJ868stsUbyMVDV02OgkzcMEyQlnf4b+ZWl47qWLBZrSu+fKnU97HfsfCBgGlEP7iknaEHIObrZOwUQVbsq90VSvlBnf7wOqVJnAa4Z1YV65NJp6lsVvVMJgTKZcf5r3Z0QknNc0DwMBDPm4vaRVwGyeMlpUr1luo4J0uxiDLhTjnqssWRHiUDnVoJTbU6t1RWH3UnLSefn8+9s9WEiIX22xheK9G1QdvOMHybNpft24bF1JTnPGzKQKw30u9Qgyq7F16CaGI0i/dFxa+zDVSUvcfaHsjoQtbWVWfX0/drH+zJf/mbIuD/57PUQMpqoUNzmrV X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: e4fc1dc5-99c4-4696-a1e3-08d8e911775b X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5618.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Mar 2021 06:54:10.2612 (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: Pgq86uDsZB3a9lpqJ1LN1x0n70/Ww7fu68PtZ8gYiGQUIuV5N8kPqRFWWnxjztuuOIliMPudnGT+5WozPhc/mA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB7091 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210317_065411_276994_363935AA X-CRM114-Status: GOOD ( 12.75 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Gao Pan use subsys_initcall for i2c driver to improve i2c driver probe priority Signed-off-by: Gao Pan --- drivers/i2c/busses/i2c-imx-lpi2c.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-imx-lpi2c.c b/drivers/i2c/busses/i2c-imx-lpi2c.c index 8f9dd3dd2951..86b69852f7be 100644 --- a/drivers/i2c/busses/i2c-imx-lpi2c.c +++ b/drivers/i2c/busses/i2c-imx-lpi2c.c @@ -710,7 +710,17 @@ static struct platform_driver lpi2c_imx_driver = { }, }; -module_platform_driver(lpi2c_imx_driver); +static int __init lpi2c_imx_init(void) +{ + return platform_driver_register(&lpi2c_imx_driver); +} +subsys_initcall(lpi2c_imx_init); + +static void __exit lpi2c_imx_exit(void) +{ + platform_driver_unregister(&lpi2c_imx_driver); +} +module_exit(lpi2c_imx_exit); MODULE_AUTHOR("Gao Pan "); MODULE_DESCRIPTION("I2C adapter driver for LPI2C bus"); From patchwork Wed Mar 17 06:53:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Clark Wang X-Patchwork-Id: 12144975 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C0616C433E0 for ; Wed, 17 Mar 2021 06:57:42 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3A4FC64DF2 for ; Wed, 17 Mar 2021 06:57:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3A4FC64DF2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nxp.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=f3bMqb+njKF4+lSi6aPGrsQC/crR70HLdDJEi1MT9FM=; b=K8yl+tHm5CHfybbWYjJz9/Ly6 R6t9/jZGpUX3/ubk59t3Da++CltaP/0TgFHRMZhcoJ3zxskd6ki6gLiwt1a6W9z1/VPNwvviz2qar bOqKD9/DiEJZ9fOGa2QOuddW51yk7MTPSWLWEgf3PIYlEgS7J+K9PVemi6sdE9yZVf6Rnk3i+YMZ8 UMSvjVsfrXEg7zkShl1l1Yp1I0Zzox44Pikgd//153ncQkmYJAVUekioMAuXvuZlDgqVk1XOWw+ph igw1ZAEFVySrdvc113O6ssKKw2k7F8HYNSCRqi0qKKLCs+q02ynnnKQ6kAp1lS2AoKC3GsUcs1FXZ oWxNw1JBg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lMQ6A-002bsK-Pr; Wed, 17 Mar 2021 06:56:07 +0000 Received: from mail-eopbgr80053.outbound.protection.outlook.com ([40.107.8.53] helo=EUR04-VI1-obe.outbound.protection.outlook.com) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lMQ4P-002bDj-C2 for linux-arm-kernel@lists.infradead.org; Wed, 17 Mar 2021 06:54:21 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HG3GE7YuDacdYmzfLwIhwEvVcW6SgLrwk8GJHPG4bxjeeO9FdPILcJt7kFC2cIS2RlKif05FfOadycWx9/Fjx6UUPTMe3M1dUywQrW3cYZpKAzbDegbMXQRnbVpPBODEBAF44tPcNFMgWUDwo0xNSwroEz9grBaU+VqN6JnXwEPll8Qef5NCIKLdlilcTCbGcss4Zqh+FY1QKYANHm7f67X/2xR4mzWfLkp+jsixSMYWky3GpRNYm2hhDRuU9K/wDUGzXsdsTEiKEA0FAn0yu8Is9yvObCVR067XbHFyHHlOb5xzlNh3qUys22kJgKns0iS40G13FLlLl2At1WnBdg== 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-SenderADCheck; bh=J9i3nQH7+71iMs/WFQuZ/Ffy/uBGsJ8hTRVVtVVxavU=; b=CcCTooiill7ZuhB7SHrFjcqTNx0MtsSde+cTq+S0bciifk4RNimg7RjmpXd0DKzxcqMY9ZiMr5wjTUSg4i1ODudVdDi9qkkDzbvNNEq4Xj9skjryBAQvF4kvlINt01wGchaux+MGaVrZZLw23DT/xGjE0mh0yXnB2d3VZLY0IgCMLeVhEhZGSGojfxc4Mlo+2Yszl/RDxklRblzvPOZZS2NowZQdXJA+i9IZ2LX3Zhao/UYwGj8Rm8vs2b8PWdgsRsr0IkxVse6/wB9hT/90OEIyIVbcIJ4Kt7j1kHkJXTegHwmPUv8HbdJBOXaQU+H+q+mgdpNs6B95iUVlO29NKA== 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=J9i3nQH7+71iMs/WFQuZ/Ffy/uBGsJ8hTRVVtVVxavU=; b=dPJo+vZVd+c5GPDs9LiLG80RswFkOpnaTyYcayiHEcFFyAowSc8FJLirsMFTzr8Poaa5Qxr+w89z4Q45s1a9BEz3rqKw4imsEpBfnz9fMkbVMvS6IzuykiDSeGXQlrrf+TOfvldbpTW7cA66Yl4eUmsqAX9hLqF4UMfE0DeCDyM= Authentication-Results: nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB5618.eurprd04.prod.outlook.com (2603:10a6:208:123::11) by AM0PR04MB7091.eurprd04.prod.outlook.com (2603:10a6:208:197::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3933.31; Wed, 17 Mar 2021 06:54:14 +0000 Received: from AM0PR04MB5618.eurprd04.prod.outlook.com ([fe80::69a8:a768:8fa1:7236]) by AM0PR04MB5618.eurprd04.prod.outlook.com ([fe80::69a8:a768:8fa1:7236%7]) with mapi id 15.20.3933.032; Wed, 17 Mar 2021 06:54:14 +0000 From: Clark Wang To: aisheng.dong@nxp.com, shawnguo@kernel.org, s.hauer@pengutronix.de Cc: kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, sumit.semwal@linaro.org, christian.koenig@amd.com, linux-i2c@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 07/11] i2c: imx-lpi2c: increase PM timeout to avoid operate clk frequently Date: Wed, 17 Mar 2021 14:53:55 +0800 Message-Id: <20210317065359.3109394-8-xiaoning.wang@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210317065359.3109394-1-xiaoning.wang@nxp.com> References: <20210317065359.3109394-1-xiaoning.wang@nxp.com> X-Originating-IP: [119.31.174.71] X-ClientProxiedBy: HK2PR02CA0215.apcprd02.prod.outlook.com (2603:1096:201:20::27) To AM0PR04MB5618.eurprd04.prod.outlook.com (2603:10a6:208:123::11) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (119.31.174.71) by HK2PR02CA0215.apcprd02.prod.outlook.com (2603:1096:201:20::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3955.18 via Frontend Transport; Wed, 17 Mar 2021 06:54:10 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: fad57526-5e49-40e2-82f4-08d8e9117997 X-MS-TrafficTypeDiagnostic: AM0PR04MB7091: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3826; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RJAb/TiLPhiBKsatbnzMcpb8CJg5F1QvmB2VVlNZ28iYqfbF/mgFVRUB4vh4z4vMfZ7e3saGfm/Oh0H9v7VtSwtq5DSdUuXaJx2Fj3RpnGWIO4FuJnW7O0+A8Yis1HttkxdSq8K8tEREiAG+s1s/Y/kZracmzqNsTkDmvw1sLspxLzT9cDGLJ7CRF9JId7ts9suLnsUZVS9PKNFvzoMlhxBXX/u24fd/s9QguDUvfZyWFmEw79WCl/uFikNI4wK/csC9U1cSkq8MKIW8cMTZADrL7CJEkxHqWL3OjMkJqywLFpsAhbhAfBBJEtiabVFwM66bik+DNyaNcHfoA61v5HfKxFYbkWQFHqRa4nktIkHncVxmi0vAsGM5mnz7iEyAQ5ih83s8HG3/lyD+2vPqkgN66OtbQtrlEEmHSTdUMxqohY8vTcbsD3nc/yCm32JKarSm5m21u8VHIzjmhylm0mH6IxN+iVGsMNkhqkLaVVmnmB9BagjXQqG7tpolsQBHpBLFoKEd2IIgaw0YhFsvmRllFeFNvmIDV01NYzUl7aH+L0VCRpGJiIuwfE26KMfUjab3yeQ69PLwxf0oYqCh63l2Tw49YaD5kMU+vUsXxLmgimzQPasUwS/2w9n5hoql X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB5618.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(376002)(396003)(346002)(39860400002)(136003)(478600001)(4744005)(66556008)(66476007)(69590400012)(6506007)(66946007)(83380400001)(36756003)(16526019)(5660300002)(2616005)(316002)(2906002)(1076003)(8936002)(26005)(52116002)(186003)(956004)(4326008)(6512007)(6486002)(8676002)(6666004)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: SIrTMaCTH7QpPtotguuUmr7ov89r9GFBWxEVZmmRokZiDoZKwJ+JdTBffTFreeU0whW4RThmD0WYNK6Wwn2UfoBYcBE2MWr9vsY9J7qQMhwMV1zl+VIaWPvFGuaM5angxekBcobQz+7M8A0ufbXhp+uYOizdf7V9z0stQE6cGcMv8M92EdvrPvklvJMmsbH5si5nZ8biEQynFAUCMebuamtx9HFCVj649l4Jwwmy3YJSGYp87J+70VEEVSqsGqySqfzXizLATN7Wirl5UcqBeqAVyERZNeMRO+Aki5Cszkkl2EUFEuoKDmil9k+6XKVlZlBpZpGg38iuEh4tVl4uDelS6jOQDkZFRkQ76GdAjQ4O6RTzPE+gfL4xFlykRziIcKT+S4pNFm7JjyQ0XKuLGjQ/tjXcZYmNszxodwiOUGZPhA0Q8hHeHB/Ad9lr5WSkupi/WcFwvvrbAn+1N/2Uht9j6GNLES5cf0Pfp/yI3CeJMxnwqviZY7DAnaAyCLVSpgJwstORclLQvvpX3bqf4Yez0QsgsnrSpRRmlq9/jsG/UfHgRtvWB68cRq2hEjXGG1A3r8L1L5jWhcjVQsKHD2X3hJ2ToqnjCSkZTaV2Rcw4k8183H0rRAc+I4sjoPYTUMoUyzSmILvEpehiAy44LqIn9GnyULbc0WvseZu3QGDJbkhfrz2wHVkywfCOmbVwnG5At9rVpcg3+oGeyrEfQ+qlGKDp/SJlIBYsmdm+S3v2KltFJedqwd5MJ2oSDt6jlxmEahTMvOzIZWYlJAjF7Vcg8jJ39t4sKgHfcFkjDAaN+qRqzjRw3JZLe+lX4DsDKs5dYgsvXCgxpQBfLPl8YHejY/pRHUlYIpwcnmXxhGWJaAbThd+R+g0oKh9scf9fcWEgaQ62HkCuo0j7/ZZo9pyKrKSwOYTLzoHwiKGj79+Z2Ox7FWQ9k0/tUSxP/MgjxoPE2CLyqRxlVOpbDgHs9CqhxVkYdYupYA2aJls0JBm6FelFqVqxlS34NLw0B184tq792J1zplANHTufc53odzWix3BIxvw274pNLzzMZuwo0feYCjKkbnbwcX8aDqN2bOk7n+g/SxMqHy+BowT9wa7pi5rELCg5UrW6GqfQ3UEP+pFDO7gWn1FvkRD21xjpuO4VbuKEyGQynQx9VZemnwRJJEYrF+HlV5gki7dDdR/rCHVQsz3PNhw1y804AhkFDoImTkqzsYtgDhsH1vlOeTQHYy5R41cSxo485l1OavBaoTk6dYdt/HbDyXL0QIKBAV4Rio2o+uwm+hKft8Uq6rTj6oQ8LZEMNOyTa98/GNiHNbxC6eSeSjEpOwojHCUq X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: fad57526-5e49-40e2-82f4-08d8e9117997 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5618.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Mar 2021 06:54:14.0021 (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: wXrXRuV+5qPR/4WFqG42AqYrAFUG0maeIiHfCeM52yKIlhTc5KewikV2eCg53wMoNiZEOoq7om7zfp3Q1yIQig== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB7091 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210317_065417_797964_20BEED6D X-CRM114-Status: GOOD ( 12.94 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Switching the clock frequently will affect the data transmission efficiency, and prolong the timeout to reduce autosuspend times for lpi2c. Acked-by: Fugang Duan Signed-off-by: Clark Wang Reviewed-by: Dong Aisheng --- drivers/i2c/busses/i2c-imx-lpi2c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-imx-lpi2c.c b/drivers/i2c/busses/i2c-imx-lpi2c.c index 86b69852f7be..c0cb77c66090 100644 --- a/drivers/i2c/busses/i2c-imx-lpi2c.c +++ b/drivers/i2c/busses/i2c-imx-lpi2c.c @@ -75,7 +75,7 @@ #define I2C_CLK_RATIO 2 #define CHUNK_DATA 256 -#define I2C_PM_TIMEOUT 10 /* ms */ +#define I2C_PM_TIMEOUT 1000 /* ms */ enum lpi2c_imx_mode { STANDARD, /* 100+Kbps */ From patchwork Wed Mar 17 06:53:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Clark Wang X-Patchwork-Id: 12144977 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5C610C433DB for ; Wed, 17 Mar 2021 06:58:15 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 75A5164F9E for ; Wed, 17 Mar 2021 06:58:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 75A5164F9E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nxp.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=1UoExZCDJCh0sul6q65NDl3icK9jv7WQYdvh0L6O308=; b=Qz2yc47sCtAzg5+KX663eQ5VG samtpnQatwihxlfKZsu/CxGGz9zpIjSGlUc9z27pbTPVfpGqoQmSUG0E4fwG6Y1KtmoD4OzlxeiLw 5KEo8LarpU+gpOGzUQZJXAXlcaJBQCZb/5sYb2Mk9zv2sNxQfcFRp1Irx51ie+JosglMnxUme6by0 yXOnphVOo4G7DCjqABJ1InwfKqWDoBwVYyzpZDquKVubDf3kKnvsm0UIHFVRoDJS8awkbh3OIiJ6I J80JTR45G3Mqi8XgN8La/EIF7YJeIipVDGROIOeqoeCRlyQtPvlRxnXm4nSD2JKRBfTsHYa2sI3TW QPozsWo4Q==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lMQ6X-002c3N-V5; Wed, 17 Mar 2021 06:56:30 +0000 Received: from mail-eopbgr80053.outbound.protection.outlook.com ([40.107.8.53] helo=EUR04-VI1-obe.outbound.protection.outlook.com) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lMQ4U-002bDj-Ed for linux-arm-kernel@lists.infradead.org; Wed, 17 Mar 2021 06:54:25 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EaoBmy5g63CmP+i6aX/7izB6XmlkVtW+WvXEbjPS6IF2Bxy0HV5TvvZiteimyv0Yr2aw6glBTGLg4LlxIartvU47hy7adOQu5SBIH9xvgCvtshWqN10VJ5s3HMLfFYWUcj59zAhnMQbZUhzwOCw9qJJ+F9y6iwICoeExhFZUctgz2b/phdOHcZ06Ar3VL6Qd5mLhfIOvz9MfbhZhViTKvgVa5FMyq/F7CnVyhDkfi85CQz4dL5HH20MTCiheE5LInF9ESmoqQNXuqNnoaiaW/c+7wEhYyssgYLnPDuUtFRuFsU3zGZcRAG4ng/ctiyqFdiSwGih+lgVkWfFZweS1QQ== 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-SenderADCheck; bh=hi8vKhwzzve8KiE8O9KrABudw21qglOjFgR+Ra9uaYw=; b=et3koRrdTh7liDZy0IBt5RTttAGuHWcovK2CM2ArK/ezpOCS/nq2oPbFZZ5/vk2DQ+qTqlhbtV/V0cws8LicEZ1dbi+YrXFdrxIm7Kcpsv04kH3lkVhSXZlrJnpGsbU+gIz/BbbAe+95VGm40o+hCptB2yktWZGIJYYitLZrgnaIly0I9w4yLvv0qp8KSlRl2IgfB6ACpGW94JPpNzUwWrnUv4gPEPg7i1mfShL9kKAV5UyAJULCjBsSd0dTTczWDjq8uymgjeV12QVWIKHIa6zVGnocckNmDmNMMMYlS/fxIdKjowaICxz5TaiBB4kI+DJiT+EWAF2Sb4hOdrRrlA== 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=hi8vKhwzzve8KiE8O9KrABudw21qglOjFgR+Ra9uaYw=; b=TfGIM37duGD5gnNFTeb+CZF6Ba/UfxKH9hZlAwhs8f3jgVw74vrcKe+HqrzHG+MIdyoC1LcL86YqD1zAKA2hJsTH/C0wYDIIFejnzk5oF1hgM/T4eQzrsmIXWcRthsKKslGUgrlVuVryy8W/GidIB9dn47UeFKUZINVqm7f8KU0= Authentication-Results: nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB5618.eurprd04.prod.outlook.com (2603:10a6:208:123::11) by AM0PR04MB7091.eurprd04.prod.outlook.com (2603:10a6:208:197::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3933.31; Wed, 17 Mar 2021 06:54:17 +0000 Received: from AM0PR04MB5618.eurprd04.prod.outlook.com ([fe80::69a8:a768:8fa1:7236]) by AM0PR04MB5618.eurprd04.prod.outlook.com ([fe80::69a8:a768:8fa1:7236%7]) with mapi id 15.20.3933.032; Wed, 17 Mar 2021 06:54:17 +0000 From: Clark Wang To: aisheng.dong@nxp.com, shawnguo@kernel.org, s.hauer@pengutronix.de Cc: kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, sumit.semwal@linaro.org, christian.koenig@amd.com, linux-i2c@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 08/11] i2c: imx-lpi2c: add bus recovery feature Date: Wed, 17 Mar 2021 14:53:56 +0800 Message-Id: <20210317065359.3109394-9-xiaoning.wang@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210317065359.3109394-1-xiaoning.wang@nxp.com> References: <20210317065359.3109394-1-xiaoning.wang@nxp.com> X-Originating-IP: [119.31.174.71] X-ClientProxiedBy: HK2PR02CA0215.apcprd02.prod.outlook.com (2603:1096:201:20::27) To AM0PR04MB5618.eurprd04.prod.outlook.com (2603:10a6:208:123::11) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (119.31.174.71) by HK2PR02CA0215.apcprd02.prod.outlook.com (2603:1096:201:20::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3955.18 via Frontend Transport; Wed, 17 Mar 2021 06:54:14 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 3d7be10c-1d2b-4fa2-eee7-08d8e9117bd2 X-MS-TrafficTypeDiagnostic: AM0PR04MB7091: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6108; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UH5KjoP6MO09vrqlQwjyKMAxY42PaKX+UBunvq/7vmkBCwwcw/DiTpj9wg4eatmfXbDoQyjjQghVMu+vz9ZX+QzLMcVzZnjm3k58W5gvAWG5UAsN0/nCwrhPe1MModuyN03JyggH7pesz4Uq9VJYlI4EBs+kojT2ytPkS09rTMcwPOCKo4cbkrdMy/qK238iFxfJN+u3F6umPDulAl6iBoao5ju5RsGoQX39MxU0ds+ZlX56NGdcu+LIRvvasOZ9zfF+iW3rIo2g0+BTap3TWS6CO45UeiyEZ1zX+HbZX4Ybg2O3z9/s147rQ2tqc9EGkB3rlxmMbZ7gVzBi/NGY2t66zi2vXzDCPuHbGyAWGQu6leJ+iJeM5rDK30LplbBujMIcscK0//IaMC3llZPysbRchuu/wqUBED90OvNxj9QHBpm72c/ZDAnRDhubwa2mTK86FFTv1t5a3mBToy9tbE+YPII6EVvYzu5KeQMnOU0mH1xrwF8y63Yyd7cZ47xkbmlPY8ubrEVk3qMb6kvhfv9xwCYihd7gfJjN7wEMkA928Voj0JWGGYa0fjVzdW0WrTFamM2PfVOeH+lVfX8xvJBLsh1XxGjiS2cvON6JWNolmLH2oQD70HjEDtznZpJ9 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB5618.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(376002)(396003)(346002)(39860400002)(136003)(478600001)(66556008)(66476007)(69590400012)(6506007)(66946007)(36756003)(16526019)(5660300002)(2616005)(316002)(2906002)(1076003)(8936002)(26005)(52116002)(186003)(956004)(4326008)(6512007)(6486002)(8676002)(6666004)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: ttG5xb/8aNWiy+XS4eusQVi0M6ukSWNbriLX3eF9cZae1Y9XeUNH3rjbJ55HSgSmL5hc/8JxzFvzsdOge8O3BbRZxfgWAHKJhvMI83Qw3yT1SQ8UXqeb3dqvv8QHWA4u/rFHPghZ7Ojd0PCVsntIe4E9BhZJIvDNWamQmDrWPsdkySCdDtm3PNNmvwnomG6NT3U039BmuBrLkDj8sebwJELzZurLwvJNPlPCQ+Mo3/oJbKLzaSwOyReybqvpBmOcDQ447G5DqC/Cpp9wy7oQ7LXYbvqLCD7eI2UVYLfnGocEMn66fM1fpduUIb+jpyRDbsrhRHlMMnIB9+2r3zYDK61Bp+KbdwGLC8LwvGY4FpfMkYerZKrGTwML7P6bULdfPEMAZgUqDq3Pl81cJZF0zjBYq635oj97cPLJGyMCDvySx0BJ4iUmnFDl+nvFO8gYDcBeDLmONmHZfR1xqR+v3NoxZtsji3sKo4vN23A0/oY96ZpMdNYXXkK6AfKmNNNQjpXWlisKNBejjCNqKUXQcSskxWTiA4uOnPzS+2OJic4yam0F+uB3KSLOh2sCUMg5tVjI5+czHhAoVuSnJMfNJU0FiimQFRvVpxdraWo3zbBxFEjCaQ28WoEYrQXmb5p/4VpJNqHqkDsPAJLJuHJxJzif7LyJcEgSXdMJGGKUbCd/ZS4jvrQ52JzU/Uv7p2C9uHoCQMvmT7waCmJ1vqoevA+LXOqzdcywte1sQMGGZOuhxiclLFr6YhTg485c1WpGy0D3gYb4L5TZIEgh85Bqjra7EqRQrwEdogSy0Yndd46OAlDwBRFSQdCpUKf9VSkCmU+UxMhFUzu8j4R1WHssPvPxs0EdvSpg0ddtyieTFGv6PS6Xg4LG0bQSco/RWNNLYqP8s3zIkL+ZBrhtFqMd+qq3bAwEvzwqPC3mOb9DTzPWKx2jSENzgUH46tJIC48wykcfBh9DdnKROq1+Nvk5OL6A9fZJAsbUQR66RaNiLUnw69qUJnAhTMGtbzkdCXA3mic5iZiUtv1kFk6KqDqZWpZ4HVEi3AKFyGuX0OeLR50NlE9Hg9HMUxBb9+afA8LWfe92n0/fY1kUYKLAFVhjuIdjZRoHpOVD326ZyOr9iZQwoB9CFqXO/rlC5k6ptYJF/JUOAkd6RZIwARjMjn1zRKMXEPgx/3vtE5+nDI8K2U9y25cBp1rIowBqprSfDrzWsh+rgBtP6vh7rD+1gtcRMWR3ed3yj1vdsmGPOW7rzW+XpDYuwz04/ycsyvE5KP4pTzOYsdJZtCcTJKSGmPmIfUDyMIFw/NAHHmaCfu7wfs/WOXEhTgqS18rg1swRgYA6 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3d7be10c-1d2b-4fa2-eee7-08d8e9117bd2 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5618.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Mar 2021 06:54:17.6390 (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: yrnrBRRbl/0mjFxgV6SEhtlI4YLQ/pCgGm0TxKGRl5HOkS/qrJpQnOpJnIObipA0EkfspsaCzZHBSVUHsRUyxg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB7091 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210317_065422_686046_27FD6098 X-CRM114-Status: GOOD ( 20.52 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add bus recovery feature for LPI2C. Need add gpio pinctrl, scl-gpios and sda-gpios configuration in dts. Signed-off-by: Clark Wang --- drivers/i2c/busses/i2c-imx-lpi2c.c | 83 ++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/drivers/i2c/busses/i2c-imx-lpi2c.c b/drivers/i2c/busses/i2c-imx-lpi2c.c index c0cb77c66090..7216a393095d 100644 --- a/drivers/i2c/busses/i2c-imx-lpi2c.c +++ b/drivers/i2c/busses/i2c-imx-lpi2c.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -108,6 +109,11 @@ struct lpi2c_imx_struct { unsigned int txfifosize; unsigned int rxfifosize; enum lpi2c_imx_mode mode; + + struct i2c_bus_recovery_info rinfo; + struct pinctrl *pinctrl; + struct pinctrl_state *pinctrl_pins_default; + struct pinctrl_state *pinctrl_pins_gpio; }; static void lpi2c_imx_intctrl(struct lpi2c_imx_struct *lpi2c_imx, @@ -135,6 +141,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(); @@ -192,6 +200,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(); @@ -329,6 +339,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(); @@ -528,6 +540,71 @@ static irqreturn_t lpi2c_imx_isr(int irq, void *dev_id) return IRQ_HANDLED; } +static void lpi2c_imx_prepare_recovery(struct i2c_adapter *adap) +{ + struct lpi2c_imx_struct *lpi2c_imx; + + lpi2c_imx = container_of(adap, struct lpi2c_imx_struct, adapter); + + pinctrl_select_state(lpi2c_imx->pinctrl, lpi2c_imx->pinctrl_pins_gpio); +} + +static void lpi2c_imx_unprepare_recovery(struct i2c_adapter *adap) +{ + struct lpi2c_imx_struct *lpi2c_imx; + + lpi2c_imx = container_of(adap, struct lpi2c_imx_struct, adapter); + + pinctrl_select_state(lpi2c_imx->pinctrl, lpi2c_imx->pinctrl_pins_default); +} + +/* + * 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; + + lpi2c_imx->pinctrl = devm_pinctrl_get(&pdev->dev); + if (!lpi2c_imx->pinctrl || IS_ERR(lpi2c_imx->pinctrl)) { + dev_info(&pdev->dev, "can't get pinctrl, bus recovery not supported\n"); + return PTR_ERR(lpi2c_imx->pinctrl); + } + + lpi2c_imx->pinctrl_pins_default = pinctrl_lookup_state(lpi2c_imx->pinctrl, + PINCTRL_STATE_DEFAULT); + lpi2c_imx->pinctrl_pins_gpio = pinctrl_lookup_state(lpi2c_imx->pinctrl, + "gpio"); + rinfo->sda_gpiod = devm_gpiod_get(&pdev->dev, "sda", GPIOD_IN); + rinfo->scl_gpiod = devm_gpiod_get(&pdev->dev, "scl", GPIOD_OUT_HIGH_OPEN_DRAIN); + + if (PTR_ERR(rinfo->sda_gpiod) == -EPROBE_DEFER || + PTR_ERR(rinfo->scl_gpiod) == -EPROBE_DEFER) { + return -EPROBE_DEFER; + } else if (IS_ERR(rinfo->sda_gpiod) || + IS_ERR(rinfo->scl_gpiod) || + IS_ERR(lpi2c_imx->pinctrl_pins_default) || + IS_ERR(lpi2c_imx->pinctrl_pins_gpio)) { + dev_dbg(&pdev->dev, "recovery information incomplete\n"); + return 0; + } + + dev_info(&pdev->dev, "using scl%s for recovery\n", + rinfo->sda_gpiod ? ",sda" : ""); + + rinfo->prepare_recovery = lpi2c_imx_prepare_recovery; + rinfo->unprepare_recovery = lpi2c_imx_unprepare_recovery; + rinfo->recover_bus = i2c_generic_scl_recovery; + 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 | @@ -607,6 +684,12 @@ static int lpi2c_imx_probe(struct platform_device *pdev) pm_runtime_put(&pdev->dev); + /* 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 Wed Mar 17 06:53:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Clark Wang X-Patchwork-Id: 12144979 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,UNWANTED_LANGUAGE_BODY,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 16F49C433DB for ; Wed, 17 Mar 2021 06:58:41 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1905764F80 for ; Wed, 17 Mar 2021 06:58:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1905764F80 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nxp.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=+8XW++9Qoslqi15+fX+bObjNGKdTSk6U/uzVcKLAqSk=; b=TyxEBapl9Lb0dgbJEZxPensXE hLyjuSifOG+el5Q/F0gWcnoJ1DiQKF/ZxcR8WKZnSx3Mgv8IyoStb/BM5jKZ68BMie5qr6dPMUhco QX4QukrAdHQed5jrwuhmT5Dg9lRH+I9fZULFqlgiUXUZdy/3Z/qFTcGSrH39KAV7eZKpLmvVBmlz4 heaMq1kSYDvupTn2uJrlKGyS5btgHdtgpJ76IkoqGcstl2eVm15Ohbh78NeAjsTqX6nUQUHDxcIrG Umhc+ADiPXBz9AhgrxmvS52QZ98njFyDufepMh24cfmCF41k87AiMNlCHpAu/DuGQktWqKTYn2ITC YnwP0yFEQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lMQ6t-002cAu-KK; Wed, 17 Mar 2021 06:56:52 +0000 Received: from mail-eopbgr80053.outbound.protection.outlook.com ([40.107.8.53] helo=EUR04-VI1-obe.outbound.protection.outlook.com) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lMQ4Y-002bDj-ET for linux-arm-kernel@lists.infradead.org; Wed, 17 Mar 2021 06:54:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Mr0mgjdGXdawsqtJzlm0KsqHWr4dOJn/ea6bPsnulDGX6+v82H8GJcz3uCXAAZFoS0dp1pSHHyeVmM8iXOBuahI4zBJQRyChWO/pCxbantgQFeAAcvYNogn29Nh6AKD6O5VQUHmnSbgw2Ap+TXD6XDHOM4vLIPH9uUHu2essVGLS3WhnMBBUjAk3EREd+VfOgh8siyUnrHSAUsbj3zao2koCmnlw/fZl7PjuGu2xC8AZ6kGYsn+TrNzb672jqdj+L+/Vy5OB/Zz+tNCy6mhHugHC5Kc87cCZKHLVItmZMd0ryk5Z6oXFWlBLmw7na9sMKJW3gHG2LhAoD1FxGvu1xA== 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-SenderADCheck; bh=dkHcFGkTTlg/KiqKJNNqbc4Xd68IuBwLk65N1EA8VtU=; b=LADxwuEKwldxF0cRtl4nrIiDYsJr+TEN1RdJxu8tm3+0/OVKLPTcQX4emTdwKRAOf+evBVMFWV1O6M8kjEUA4GQjq5PTYkLS1g+J82mloMpoL7Py4ad6yHCfz4sKW/KhCFZeiSDBbL53aueW+dz8HnTje41Fu6yvNjveEXS//TSbKe9+e7X9pxpCTe2csq6kVm02iold96rVsEoZZ18vaxbsV0KIHsgs8DOmUywZi+qsavxpESQAvHzVvDX4CMSz95sb0N7+W0W68MlwF473ngIZUqdMgLbGow+L4lPpHMmpTo84IK6achZeBNeDiu6u/iu0hqRIv9mr+UiCVB/Uiw== 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=dkHcFGkTTlg/KiqKJNNqbc4Xd68IuBwLk65N1EA8VtU=; b=dH6NXslEC4UNw0Hueue96pNKtrKAmaWhBPQt9uSwTJAuIkqQ2wMiR4bagA9JNfxvXTlbNI5dlL7QH9I9qUpi9UD7/9MVEkhrJLuE7m1ggsqpc3lZunKXgJ8WzOLwSKOwp4mCBegoqSC6FAw7IdiNCWrPO/Kuu/SJ9DNIAaHTcaQ= Authentication-Results: nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB5618.eurprd04.prod.outlook.com (2603:10a6:208:123::11) by AM0PR04MB7091.eurprd04.prod.outlook.com (2603:10a6:208:197::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3933.31; Wed, 17 Mar 2021 06:54:22 +0000 Received: from AM0PR04MB5618.eurprd04.prod.outlook.com ([fe80::69a8:a768:8fa1:7236]) by AM0PR04MB5618.eurprd04.prod.outlook.com ([fe80::69a8:a768:8fa1:7236%7]) with mapi id 15.20.3933.032; Wed, 17 Mar 2021 06:54:21 +0000 From: Clark Wang To: aisheng.dong@nxp.com, shawnguo@kernel.org, s.hauer@pengutronix.de Cc: kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, sumit.semwal@linaro.org, christian.koenig@amd.com, linux-i2c@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 09/11] i2c: imx-lpi2c: fix i2c timing issue Date: Wed, 17 Mar 2021 14:53:57 +0800 Message-Id: <20210317065359.3109394-10-xiaoning.wang@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210317065359.3109394-1-xiaoning.wang@nxp.com> References: <20210317065359.3109394-1-xiaoning.wang@nxp.com> X-Originating-IP: [119.31.174.71] X-ClientProxiedBy: HK2PR02CA0215.apcprd02.prod.outlook.com (2603:1096:201:20::27) To AM0PR04MB5618.eurprd04.prod.outlook.com (2603:10a6:208:123::11) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (119.31.174.71) by HK2PR02CA0215.apcprd02.prod.outlook.com (2603:1096:201:20::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3955.18 via Frontend Transport; Wed, 17 Mar 2021 06:54:17 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 9dc97743-6b52-49c2-0a2d-08d8e9117df5 X-MS-TrafficTypeDiagnostic: AM0PR04MB7091: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3968; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AbyI0Gna1m66OV0E7LA6h0SLw2CTViKfvNZJgiJvKNubxvFZzEX+10wRZCKbyquT2FVX4YSsDGxMqPdbgQ0BqwoPMgDdfrnePWxacu3NXWA+DSlLbj04PTHn766jQWMjsUo7cVfxVfn/aG3QvSqVY1CL/yMyTR/FZC+d9auIIeIaES45QPmdhETMNji3WFxT3+1xCU7SuPz52axtk5ajk1Rg/kTu0gkrn5W2jZkfLAZskhdk0UF5x40Eiq63AozsHAj6TvNYB1IIyh83dHV+cERxycFiuPMPjExICulj4B6kv3gj5GRBhI3AmkhXqTWS7tLxgUrsViQ36RdOPf8QMLCeyboehG3lPgYB3fnyU6wdO7m/DgML1sX5hI9CHiOlTVaJwVy38ZO4bYrlc+xECUZ6XikeFxKBWnU4741TmHdCupeSgQrdwGFOXHqPYGI1tOW4bnBYFUwfXu7hrC4XAu8vmdW+oA6J5VO5/mAEGAqNiw1FxkyqguK3Jw7u+rIg1g/8BNZJAF6nr9/pxPJfslC4D6LuCjmf9QFhWRdyFTgxfcGxacvFyzKER4bWtfw5k3kb+YVfGxYiW1O0QTa1Nsj9iJuV5h1dEBFFot+nUfEB0x8i3OcS6d3XuT6NuME2 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB5618.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(376002)(396003)(346002)(39860400002)(136003)(478600001)(66556008)(66476007)(69590400012)(6506007)(66946007)(83380400001)(36756003)(16526019)(5660300002)(2616005)(316002)(2906002)(1076003)(8936002)(26005)(52116002)(186003)(956004)(4326008)(6512007)(6486002)(8676002)(6666004)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 01ClM5sTREFXEU6Nw9F5uuKUZ4WWNsnh3ItPiHBbgoAuLFid+sI5CJMbZSxPs/2oo82EnRveHWuE54EWgm+aDcVH5wikmGZ5WUvf3kqvy9tp4SX4MKUQ/HvZmdP0XCpr9W5Qf4GFEiHbkdcLAA8Q/qB0Zueh0WBTCSUi6wAt+vreG82Kfinncm7OCZHasFgpVW35rVaJijYcE6MUJog2iCtx/S+F3vKy/Vsl3NTocy5JTPXhE/S/qzGD0o8nQPar2QH8c3mO0KSInqiayb8lrQ8C/6vXP9PUrwor/dlgWmEK9ENn+CaEJ8bxSgFB7kGCH5EM48snHZ/XWX2UsVeWN/VIO5C5ZYQTJwWYvjX3qQZCl8p72AXiNni3p5xR6CzR8o1QZ9+OASiCMTmvAipQk6xwGe7RZBxexJtH2n/YT3zpPhMOU6/eUbPvNCytBOyZ6zKV8y3fJPJ4hWLU2wlK29/2VHM51Jvni88vgNRXn/Nr3obTgJpj8Lu+b0uCl+jfuP7/+kRKluroNdPVqMOr2dg2HS0K5xWLNb4Uyfu263KBFktITBSYk3pk46DJqXZEjm5dtUmyN+xkRL1xQ6YyE2SQZhr8BoQjOwWRSPyMTinAoXe6TKCjK/2QqNlWS2FqNam7JsAXJnJdLPDXc3fH/ssLEBH5g8yxP/3zMQRT2+MhN5NlQQonwdrTiiijkOOe1GtXDFuSz0OuLNW2tV8QmvrBLZSYQMqpU/od7m97l+4C4rB5fG3tCQTGyYmJHGXswvK8jyjD4vH41miIpcxFUc7O0GZ/UeJA28hnalhr0xEH/SmLyFll693iADXzmbtSQSr5eD5qBV5ZsgQ6qk6CZ8NJolk/mUF1euse2oc/IyN1oiZQCs74l0T3ek+GXB/oT8IJxFKj093y2YLAXAvnMKkLM/sgfTjVw6853mH8nJfHU9kcoEhbRyoaaymnVA8o64nonM1CR+l+iY1xThcz6CtVvbFxU1h2xE2GqG1AgXbc73LhknsgXACCE5KNbI1gNmyt1FLvC01KElNgVIpxMA2oVZUrSHG2texAOk5naIsbxo7sKbyWXHsBKn4/vIu3EsdilZKon88+r++XXJ/6iF6010qllFfRIBnH9W9zOn7IWJfy4Cdw5RfvsIJEQ/63KDIcNRfqK27Exzj7S2D1ubtXGqW7NjZ3l50W7MeEz4cbneKc+CqPWeuEQYNH/T236aV8emHmHfu9CmxNiriN758ozsHhyNM4sn1DQppToPNki03xA4Wxjzrz7U+RgbEydPtVklYA3fNSRjyxpCmQtzPlzJx6EPOtME6CbdPbpbrQkA5wzTZ/Ip7jVab6qW9R X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9dc97743-6b52-49c2-0a2d-08d8e9117df5 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5618.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Mar 2021 06:54:21.1321 (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: V6zyQvoIu8OMe5DJ2wx7JXICzGNcxhTKvv27ZWzg5oMp5KpPqC6riv9lmWLpyuYPGfaw7zO0GqgbfmKlvIKkVg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB7091 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210317_065426_704304_2FC9CDDB X-CRM114-Status: GOOD ( 13.61 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The clkhi and clklo ratio was not very precise before that can make the time of START/STOP/HIGH LEVEL out of specification. Therefore, the calculation of these times has been modified in this patch. At the same time, the mode rate definition of i2c is corrected. Reviewed-by: Fugang Duan Signed-off-by: Clark Wang --- drivers/i2c/busses/i2c-imx-lpi2c.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/drivers/i2c/busses/i2c-imx-lpi2c.c b/drivers/i2c/busses/i2c-imx-lpi2c.c index 7216a393095d..5dbe85126f24 100644 --- a/drivers/i2c/busses/i2c-imx-lpi2c.c +++ b/drivers/i2c/busses/i2c-imx-lpi2c.c @@ -73,17 +73,17 @@ #define MCFGR1_IGNACK BIT(9) #define MRDR_RXEMPTY BIT(14) -#define I2C_CLK_RATIO 2 +#define I2C_CLK_RATIO 24 / 59 #define CHUNK_DATA 256 #define I2C_PM_TIMEOUT 1000 /* ms */ enum lpi2c_imx_mode { - STANDARD, /* 100+Kbps */ - FAST, /* 400+Kbps */ - FAST_PLUS, /* 1.0+Mbps */ - HS, /* 3.4+Mbps */ - ULTRA_FAST, /* 5.0+Mbps */ + STANDARD, /* <=100Kbps */ + FAST, /* <=400Kbps */ + FAST_PLUS, /* <=1.0Mbps */ + HS, /* <=3.4Mbps */ + ULTRA_FAST, /* <=5.0Mbps */ }; enum lpi2c_imx_pincfg { @@ -156,13 +156,13 @@ static void lpi2c_imx_set_mode(struct lpi2c_imx_struct *lpi2c_imx) unsigned int bitrate = lpi2c_imx->bitrate; enum lpi2c_imx_mode mode; - if (bitrate < I2C_MAX_FAST_MODE_FREQ) + if (bitrate <= I2C_MAX_STANDARD_MODE_FREQ) mode = STANDARD; - else if (bitrate < I2C_MAX_FAST_MODE_PLUS_FREQ) + else if (bitrate <= I2C_MAX_FAST_MODE_FREQ) mode = FAST; - else if (bitrate < I2C_MAX_HIGH_SPEED_MODE_FREQ) + else if (bitrate <= I2C_MAX_FAST_MODE_PLUS_FREQ) mode = FAST_PLUS; - else if (bitrate < I2C_MAX_ULTRA_FAST_MODE_FREQ) + else if (bitrate <= I2C_MAX_HIGH_SPEED_MODE_FREQ) mode = HS; else mode = ULTRA_FAST; @@ -209,7 +209,8 @@ static void lpi2c_imx_stop(struct lpi2c_imx_struct *lpi2c_imx) } while (1); } -/* CLKLO = I2C_CLK_RATIO * CLKHI, SETHOLD = CLKHI, DATAVD = CLKHI/2 */ +/* CLKLO = (1 - I2C_CLK_RATIO) * clk_cycle, SETHOLD = CLKHI, DATAVD = CLKHI/2 + CLKHI = I2C_CLK_RATIO * clk_cycle */ static int lpi2c_imx_config(struct lpi2c_imx_struct *lpi2c_imx) { u8 prescale, filt, sethold, clkhi, clklo, datavd; @@ -232,8 +233,8 @@ static int lpi2c_imx_config(struct lpi2c_imx_struct *lpi2c_imx) for (prescale = 0; prescale <= 7; prescale++) { clk_cycle = clk_rate / ((1 << prescale) * lpi2c_imx->bitrate) - - 3 - (filt >> 1); - clkhi = (clk_cycle + I2C_CLK_RATIO) / (I2C_CLK_RATIO + 1); + - (2 + filt) / (1 << prescale); + clkhi = clk_cycle * I2C_CLK_RATIO; clklo = clk_cycle - clkhi; if (clklo < 64) break; From patchwork Wed Mar 17 06:53:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Clark Wang X-Patchwork-Id: 12144981 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E60E9C433DB for ; Wed, 17 Mar 2021 06:59:00 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 77E1864F01 for ; Wed, 17 Mar 2021 06:58:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 77E1864F01 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nxp.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=wOVd5jq63EoW6uIxByCo15KhtJcdlpjgSHbXuVzEg2s=; b=KWzAZ5AYeDKWXYqL2WIY3XVw9 bkcJ6hhM0qSPBaHYVsSGNalU9rncqBRN/N1DTxAj405wm1gUqlij7wViup9tlVZwakqUZswYI8SGv K2EL6mwUtEs9WvhGWxuU1WJms/SkONLRZBkzOln/59YZtVI3CE5h3jKgO96nl07yt1BPEIAwA0qL5 ub7u0vzJbG31XeugIdqkFckH/8kbkKIhl1GatK4mv00Tqv1rUpDazVwfAfq2IO/I1HA9J66leJYeP fWT4rRDQytN8+J492JXqEpcnhfS/0hPJEHdcGjAu0GzusSgO35L+8kk7WELY+8xzA5NNLLn3wExP0 0o9mpglWA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lMQ7I-002cLK-Um; Wed, 17 Mar 2021 06:57:17 +0000 Received: from mail-vi1eur05on2063.outbound.protection.outlook.com ([40.107.21.63] helo=EUR05-VI1-obe.outbound.protection.outlook.com) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lMQ4Z-002bHt-KG for linux-arm-kernel@lists.infradead.org; Wed, 17 Mar 2021 06:54:31 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hLD72RxoK4tXryKMHmk6gt6Ji3hsuRhoQ9uEHVsQVgguwUZWHo9gHC2gBxhv9Vj0eVDa58CLuDNUqwkoDxjnO6+xBEtfzmybzRlge46i3IfTyp8d5R5LQMs1j+ooo3MwewY2wD0377kc3vfPdm3FFRPrho649z3YO3bDd5g1IgVCGFIUNfEXhSO5HyDHTh8QFXIQZ+wTyPci1lfdZB3FBd3k1h38viXCT/5dnG+Hw64C1yxupHdT1CNzVqzMvLcFWhFpbfT33p9hJ0q8+UKGCg14HBpesOWuCT2pbyZQ2te2KmPQsrO43eegthhwUEbyNKMiO4pRtqdFlEswhFaPcg== 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-SenderADCheck; bh=BagA/Axfg8Zv4aALC4CkXudKzO2dNPuET78QEzdF6Ho=; b=WvcEsM0C1xorAgMRT1apKKqjGnlnUEpbTq8CqpRz970lXmanwS4+dDTTZyuS7BOyx+zT0T58gCqBBM5ctQB3lK7XjT/c0cLFBSQr2ganNpWmIui0X8YC8IIaGerH+pPLuU/5XfihQgxKMTlMQ3bDjwjZBUjsZSYixNoVIz81ghXIXtzUZWJi8idBGxALwuDNZotMmYYC9/4S9zQk6xUc8ET8O+E+HzDBYXqiCiz1zmAllganV6fV4BmdXuNhBE/4xkHkvhtxQRM++vVS3icB2hwVPalFjv3Q/IYxrQ7nNpQ0IwNTl1cL3xukpOxmAGCh+molA0btEIGWCLXyPaw6GQ== 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=BagA/Axfg8Zv4aALC4CkXudKzO2dNPuET78QEzdF6Ho=; b=ELUQf81zZvfuP/deXF8udVPMlBo17mkQbg8op5KUxl6J/5xF1oRrqpxRPxMkSpXd2hXbROI3QWeAPrgRkGF8dL4WzO8E5lvl5n2CMisuXqm2CyE7VL1yWP6aDemaYbpSH97VDgJSSoRVVQplx6vUabj19p74uIyheAKZs2bDCIY= Authentication-Results: nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB5618.eurprd04.prod.outlook.com (2603:10a6:208:123::11) by AM0PR04MB4196.eurprd04.prod.outlook.com (2603:10a6:208:56::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3933.32; Wed, 17 Mar 2021 06:54:24 +0000 Received: from AM0PR04MB5618.eurprd04.prod.outlook.com ([fe80::69a8:a768:8fa1:7236]) by AM0PR04MB5618.eurprd04.prod.outlook.com ([fe80::69a8:a768:8fa1:7236%7]) with mapi id 15.20.3933.032; Wed, 17 Mar 2021 06:54:24 +0000 From: Clark Wang To: aisheng.dong@nxp.com, shawnguo@kernel.org, s.hauer@pengutronix.de Cc: kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, sumit.semwal@linaro.org, christian.koenig@amd.com, linux-i2c@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 10/11] i2c: imx-lpi2c: fix type char overflow issue when calculating the clock cycle Date: Wed, 17 Mar 2021 14:53:58 +0800 Message-Id: <20210317065359.3109394-11-xiaoning.wang@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210317065359.3109394-1-xiaoning.wang@nxp.com> References: <20210317065359.3109394-1-xiaoning.wang@nxp.com> X-Originating-IP: [119.31.174.71] X-ClientProxiedBy: HK2PR02CA0215.apcprd02.prod.outlook.com (2603:1096:201:20::27) To AM0PR04MB5618.eurprd04.prod.outlook.com (2603:10a6:208:123::11) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (119.31.174.71) by HK2PR02CA0215.apcprd02.prod.outlook.com (2603:1096:201:20::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3955.18 via Frontend Transport; Wed, 17 Mar 2021 06:54:21 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: e668afdf-2df3-4371-9b24-08d8e911800e X-MS-TrafficTypeDiagnostic: AM0PR04MB4196: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:331; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NRev2lVsWHr1HrhbLXLdpJWFu3fSOKjyxBfZnkir2RtH7ZsRoF3DibxOOyr0z12JP5ACI+F4E7TYuZa62CkudjfWKnH5inOn2EPuPyISRGD1YHl90ZYxbS+nGZDU7RiEvWijIkY9PrZBuayDa5rrNBhDATZW34MUEYmhlKfL620JPI06HAI4PNk+DCWl11mp6V5YnbLtOHZRImgU+Fvbw+xjseQmWtRCgiZOu7REL0ffJ9R/ieFvSn51/9mJm1huEaMCsPFdPOMwmn6L8pNnmIkeAa2A8irWlXY+i71peFcEHZH9+jAvWKAJMALVru4u6sBSqEkhkY5dod1AFKdz7JYWbIxXh5RKd3NQbKAmxvqHUgEL9sTFo1619hM/i7G/QOrySTwnjI+JUeZ6f2OMRwc0V7ZkGLqCcLjCltri7UZw+IzSMSjs0H8ct0fmGY6CTsbDY8RVFE2Pa7tp0+39lsOJPkR7F2slarTiZwJsFbDKlc3DpE8MWUD1e+e+huaZb8yodAvbnq7F6NSKh/yq7fp/wSWDTeEAqQfZ/tcAE5DXFneKfH8PXb+CijA0Hzzq/BeJb2E18CAXdFrvYNoJHYLpAOxF4xZduXEGNOHvJhNMEj3Mv/jf6AIB2GXgZ2ae X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB5618.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(376002)(346002)(39860400002)(366004)(136003)(66946007)(6512007)(69590400012)(52116002)(26005)(6506007)(2906002)(36756003)(2616005)(8936002)(956004)(86362001)(4326008)(5660300002)(8676002)(66476007)(66556008)(478600001)(1076003)(6486002)(83380400001)(6666004)(316002)(16526019)(186003)(4744005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: +MJpi/7tp5sUcZ86NHY+BvEe+PqHFaCTZ0Vf3lDcQjCL/6J96KrxZ4iZpjzWPJaVWkbPLyb5xnfsmYe6gcsD18Mr6x5cTbMLB6Cv6tFXG0BefE0kpWeJVBnAEC+1m39B0geNy5Zn8KIEaJAnHWGTij6FfpC8eiCNN7t57v9ab6bHeTsRrODOVnbeIda1eAiGRQcyYIGJZJnkDTG/U8lHqKkVWaw2VMwrz3f2JoourIz1HxCMuKNL0KLSd9MoWksi+pA0nJl+rJ/YOV07EkkJ7uKRNo+r2+3k1/+wkXroWxnO/meFaVTeVvqgtFfi04Fk3aNst+wA0a6CVXQ5std8Xx8bPbLxITZOtuO2bLSTT3BDHPC8TYY6z36jDeUTbbV9zG4mK+yFM70CnJ5bGgE3lvWtrdgHSJpnMUioSPTQfDatZFWb9PCuHJ5V/qaz+FH867FYrpF9xcdCGQAmwRW4KZurwpQYLZA7gE4YgENBnKR2c2Y6YhtYwQbQIPxjG9oiLsLDw69QlLKiY/K58nI8dF3gVBaVPRrcfWOoKfY0+KG9KjPXvoMykPuV/aqs/I5J6l4sWO+OMhAIoQ6NsVWqVmR6GyVattogxMdZbo61laKHZnVkRuei3CY1hK7l0MtdKU7oWjWP+FJFlOLERKUcJt9ntLlGW5bLkuQJ1FxKX0H0wiEkls9D4O49zxlNRkx9mkhsAhV6H+aM35cCH2Ho8PER3z/vihv1FYOc/i4sWOYv42LU9gu9nhMA4FKo++xhBEZL3VxsCxL53G12pGQpgcypF/B8bKFvrkO+e1+2n7D/XM7A+SDZWN1TTiwHbhwJNEvTBkeLy+KG9AN2kI8wTgmhX5umjH6SVYzR+rj9ZHCNIWawT6qNqTtLo8GnRoQ7u4/fr5BVmDjU+TGencJcbdCkgB/ntRx/Hd6B9oKI9L4fmNKSuteClrrVKG8+P4EghViySKiOKm6Y72xAu8E1Q3azhLQ7MOobRSvnEH5DeflBvSEOeYDN6qHlJQOU7sBVA4DtXxjwhz83DjGQfw0B7ZgX5MExjw/iVN9zFhXzQka2EGYdBlDn6yPFaNYCvvulphRJNoEv0fFmsCelSw0WNkPKwOdeWr5wVs4COcXkBOzgeVSyC/8WD7DqUj3zziUBeYrYTmNWjm47km/PYIog9DPL7svtC42KZx7+YdzAfi7noO8EFoG7nvgyXbMTRDGErCGmTtEqpLCM9sUap2QlxWbLuo8kJUxrz1Im5393L4eSzWeaxlrwwQ0jzOL82pHhNyVuMAyiNWxllXiplc3x7z+Je1YabOACKmvNnTbIXdsm0LfhT1fWuiwUFYPwALJp X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: e668afdf-2df3-4371-9b24-08d8e911800e X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5618.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Mar 2021 06:54:24.8200 (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: UGJf1H4JNg/EbA4wZPqhAd/bVWNee2oLoenTFnjZcMQRLKeHCzbk/W54gOMYze5RqzYPHOsxWhDDSMudYszlxg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB4196 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210317_065428_062704_C5D45C70 X-CRM114-Status: GOOD ( 13.03 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Claim clkhi and clklo as integer type to avoid possible calculation errors caused by data overflow. Reviewed-by: Fugang Duan Signed-off-by: Clark Wang Reviewed-by: Dong Aisheng --- drivers/i2c/busses/i2c-imx-lpi2c.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/busses/i2c-imx-lpi2c.c b/drivers/i2c/busses/i2c-imx-lpi2c.c index 5dbe85126f24..1e26672d47bf 100644 --- a/drivers/i2c/busses/i2c-imx-lpi2c.c +++ b/drivers/i2c/busses/i2c-imx-lpi2c.c @@ -213,8 +213,8 @@ static void lpi2c_imx_stop(struct lpi2c_imx_struct *lpi2c_imx) CLKHI = I2C_CLK_RATIO * clk_cycle */ static int lpi2c_imx_config(struct lpi2c_imx_struct *lpi2c_imx) { - u8 prescale, filt, sethold, clkhi, clklo, datavd; - unsigned int clk_rate, clk_cycle; + u8 prescale, filt, sethold, datavd; + unsigned int clk_rate, clk_cycle, clkhi, clklo; enum lpi2c_imx_pincfg pincfg; unsigned int temp; From patchwork Wed Mar 17 06:53:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Clark Wang X-Patchwork-Id: 12144983 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,UNWANTED_LANGUAGE_BODY,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 403F1C433E0 for ; Wed, 17 Mar 2021 06:59:26 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 01DE364F89 for ; Wed, 17 Mar 2021 06:59:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 01DE364F89 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nxp.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=v+tad3JRVveytZu+aCJrXZ/rxQ1vUA2LcHna2gbf6dI=; b=MXBhEtyqVZXG1NXoUmjP6tjaF r1MFtgMuepOwaRKWPgtY1cK3UrI4zduFn/xX7lgyQ5+SjmLZN/kaLA5rw89pt5G43fu7zLrbNXoZm eVvOuc6FO8LE/RmNLYI/sUOPPGxvvBvm+iSBaw9MW7hHTxsKQQwCMw7ribNREd5AHO3G/jPQbSsuj 0Ps1hM+3yWOmO0pjjQHZ0mkokgrDwrcCN1aC8+BcQtZYfz58HGq1zPc+kYqLD+2BMUoitFcOLvYdC BqwB5V/J73YAeFUOXg9rDfg5bD+8bX0bTXyE7RhaP8ORvRmY4SDNSIkdxoU5D3aXyZLrUE5fQekRL v1qWqLyeA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lMQ7e-002cU4-T0; Wed, 17 Mar 2021 06:57:39 +0000 Received: from mail-eopbgr80053.outbound.protection.outlook.com ([40.107.8.53] helo=EUR04-VI1-obe.outbound.protection.outlook.com) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lMQ4c-002bDj-AA for linux-arm-kernel@lists.infradead.org; Wed, 17 Mar 2021 06:54:33 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KULyqXTX6EWc8dGvOe5inwA1/K+NGH3FOkTvDZ1MEagNJgWdSodPqai3bRVGDjnX56rZuY6EH0clwFeORANxPm+9+pw+49zQ1IVVlVayN2gn+XrjrVEZf6O++FFFiUTvGQg6n+1kWiAwWM24ymeBmyW2sl7XxdOx2iFaeWI3oKoMZcbymr/muoKYYVe/EIpdwv6ScmUEUrHvFh0lQisG+AJd8/k6eV7SgfXP11Eua0m8dGjUnKpSVZ75hzLDzxAMi9/G+cGTp7+ffU/PMySAN0YpiC1cirsaki7GELhchUHFoVt7Ldn9EmHIw+2LCIBNpwyiJAfJ/YsjcgBYKXS18Q== 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-SenderADCheck; bh=A9oihh89De+wkg6qHpZDyowrtTKj+Q5qfBUPeufKBGI=; b=oSsciypWfA7Wu7ou5z4ahv1/s+vG3NdZNGU6bd7D3RMwDhqMl9UkmMx3dAYlZRkKk9f2Nqy6vId5jqeEUZYcSWhy+F+Dxm5kZCekqfJRJLBZ/N3eP/Tuwvifv1llrE0GDsHS7ZiszCntqC275gLRRf6rtnRX4RDnOHrF17dQ6pXtP1dpHsiVz1m8+a6MSI8JnCDEPV5jcSXEqraS1MMKDK5F/5wzF+SQSuFcEL5SrubNf5wK4gyOjl2Pntwosclo8qOWa+OykcMTOoIlAa3o61GoA301puJ4kEVyK7SeiwMF9ji5JjOuT+KjooEpGg1pMR5JbTd7yNqDiRyW7MsRQQ== 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=A9oihh89De+wkg6qHpZDyowrtTKj+Q5qfBUPeufKBGI=; b=XVLXtVXjGhWqtfQheRHg4Bs4QiVQq77C5ZgO+C7t+KPNaLBFo9q3t+nZ4AMg9cxZHk82Xdpq16QNbl3NN0tL0L2fauMf88WKmbHvY3ZmPM9Qe2lhPhSIg0gL958j5E7I7G26tJg4i5WsoY1sEf3k5HFcLrQwS3EKKk0oYYV+lJM= Authentication-Results: nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB5618.eurprd04.prod.outlook.com (2603:10a6:208:123::11) by AM0PR04MB7091.eurprd04.prod.outlook.com (2603:10a6:208:197::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3933.31; Wed, 17 Mar 2021 06:54:28 +0000 Received: from AM0PR04MB5618.eurprd04.prod.outlook.com ([fe80::69a8:a768:8fa1:7236]) by AM0PR04MB5618.eurprd04.prod.outlook.com ([fe80::69a8:a768:8fa1:7236%7]) with mapi id 15.20.3933.032; Wed, 17 Mar 2021 06:54:28 +0000 From: Clark Wang To: aisheng.dong@nxp.com, shawnguo@kernel.org, s.hauer@pengutronix.de Cc: kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, sumit.semwal@linaro.org, christian.koenig@amd.com, linux-i2c@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 11/11] i2c: imx-lpi2c: add edma mode support Date: Wed, 17 Mar 2021 14:53:59 +0800 Message-Id: <20210317065359.3109394-12-xiaoning.wang@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210317065359.3109394-1-xiaoning.wang@nxp.com> References: <20210317065359.3109394-1-xiaoning.wang@nxp.com> X-Originating-IP: [119.31.174.71] X-ClientProxiedBy: HK2PR02CA0215.apcprd02.prod.outlook.com (2603:1096:201:20::27) To AM0PR04MB5618.eurprd04.prod.outlook.com (2603:10a6:208:123::11) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (119.31.174.71) by HK2PR02CA0215.apcprd02.prod.outlook.com (2603:1096:201:20::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3955.18 via Frontend Transport; Wed, 17 Mar 2021 06:54:25 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: f3a4034f-270f-4243-10b4-08d8e911823d X-MS-TrafficTypeDiagnostic: AM0PR04MB7091: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5797; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WqIN2G/Bt2TWPvS7w5LtLH31A0wgQ4mt8XuVRXBd+YdS9rO1YXf/z7h0W4wuLHbaKV09a8uWkNUzT6X3ouccV7fpcEYzpxmhm6yLQk36fkYpnnK2VYvOfK7VE8UTv+yvsrwYF7XcP7fIPFJ/f8NcDur9IdhbpWOIWkekKZ9p7ECHsLJi+86uoFuCU6/8tn0pxNj5QhYYk/q5m5jJODuEAFCn6PIkgWBOo1irrxlJhXJy+PWdVH1q4kM/vapKXD02XVeGh7ZgBswlOuzl1KBdlfvX+bAZGyv+ppFGghR3Rc/cqCu20AoM0eKZS+JyJq4R+NPgk+7BIyF4n7CeZLDyWhXZy/Cp9rep1oHGKIMUqzbBidZDORskUMBxQFWAW6FKwa63q+sCgV9ODv5Vn3u/cyckySKCBHbxGWOSI6CCz5J+caLzGMpDB917DCCrKdvZ4HgiX0tKLbelfvXM7Qo/SlmIaqLtQtpbt7BiyTix9qyNcAGhDbYsyoOtXDblq6y97JgZ5/yIuoeiU/k8BIPXhAO/BouwRd/pJZ3Yx/zB2RBWB2uMAI/Lxq9PErfbqlaU9hkybMAPsqEz5mkjW9cZeYKbMEEglYtLhkfOMlRommZkaCTs9Y1l8oKdqOMXo6yF X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB5618.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(376002)(396003)(346002)(39860400002)(136003)(478600001)(66556008)(66476007)(69590400012)(6506007)(66946007)(83380400001)(36756003)(16526019)(5660300002)(2616005)(316002)(2906002)(1076003)(8936002)(26005)(52116002)(186003)(956004)(4326008)(6512007)(6486002)(8676002)(6666004)(86362001)(30864003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: ywpKA9YiXbJM2FR+Jp8PSo3EgW46pI6d88sfJ3JxW14SJFPyEkJOkNWUx9qisFxULyGbbXRJHRE4IJYgLozX/AsSuRr/tImYPoqS5wj7xYfdCrPu4Q5tVewq3/KXumD4BS0sBqkIn1XA2nELpVTWbuFnzGtFk9as6mXnDRvXqCMf6Hll0dKMAUOJY7a1r/692OtbTcCNhJJD+hy8ax6TqdtpGAN9bsjG3QGfgi5oB/2jNvSALCgpK0gSd9dOgYWI8cU3ekapJhvj4NdtVtGrNQisIW1vYcIpGyr4EeHvjbysSmw66O98GAZD27QT1ZWj0tgoj/7vvKfcIqDFbmT6bKaVwbE36g/13GxJ84JUTGoJxBdPj7W8iJxjfhdkdzh6kt7XjSmV0IYGPIJRvaAumYeIAghvWopNw5sEOdqZZmEK5mXvmNZR7VjWHYtcUx/BccS6D7kj4+A3my4Lu8V8PHPnMqLau+dW+V+dYupiMwUrIPm1d3WoG8zzu1b7aeZS5xtu03p2vIzd3AOMbUAY0KMJKPUNzAd1/NC6EkwGmxWJ9iPL6qUdhAahliW6CpW2V+p/pUFsyOsoGXHW9C0MqZepiggELjxD7Wrs8oMpWaCZM4HMcChOs9GUofUsmCuVX/b02sW7rlOH0wi8Hc6r8h3xBASVtoSFGqYqatBwWhezHPe5CqlAvwx7atMf7pLH0Qsms7KGhh0LCqe25CX90SRXWqVi/AbHaTgY9KPd5+TBg51nRQaChQUMCc3qxVPVsnqtZFZz5QlkUr0r6ocdplb+AUluP2FU18W/xgm3dK9BqbnOyCcoiz+xx6rXlYRBwBpcdy7f6qRXKo24uPHIyhtqIX6O21f80FnJvTG0x2sGYqTP/5+g4vj+BncHdzJOJ7EfukZAbMtoj3zsszTTAzu2WgdJ2IbxyhJimFWdGylKoKRbmBw41dK5bv1c6AGkuLf/vIb6RwZ54PebL1ImNLaOiOg69y4p+8Tu/Rwf+jmdLhhQA+v1gJNRiPF1caoQ+12w50fvOokJNMA/EC88vKyOHb2mtrZoV73A5rlDGVYXgsMiKFIn5URQud9mNZi8KUyS+jRRLhjg6BvwhQh3F6a2rqI7GKGlSfc4Um0HTMF+5cbUGu4hDUkO5Bg/dxmmedNxn5zAG2Nin4SJK7zOlakfDgYb081TYhJ0vKFNs1SQSeMqGz2wzugKuoIbWBM8MROMiDeTV9D/BCdOb6ZzWBvVkh1Xx4Qe9wrZsXs6ursDjgHQpUzNY3kDkU7WKlS/zFWJrUpjAo8HVAHD1EBOl0aG71vnzVmysZ/6JERblJIizIlMmpEWl7zjqBfwrOdR X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f3a4034f-270f-4243-10b4-08d8e911823d X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5618.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Mar 2021 06:54:28.3749 (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: MQ8/7VbH7+taurY4UfJ4hAt3rIEYEgfTUj8DYOMC9PdUIxzWFD6QBxRzChB2wuRwJtNsy3V0mi7L/vwJl7sshg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB7091 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210317_065430_622075_EFCFCB46 X-CRM114-Status: GOOD ( 22.34 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add eDMA receive and send mode support. Support to read and write data larger than 256 bytes in one frame. Signed-off-by: Clark Wang Reviewed-by: Li Jun --- drivers/i2c/busses/i2c-imx-lpi2c.c | 291 ++++++++++++++++++++++++++++- 1 file changed, 289 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/busses/i2c-imx-lpi2c.c b/drivers/i2c/busses/i2c-imx-lpi2c.c index 1e26672d47bf..6d920bf0dbd4 100644 --- a/drivers/i2c/busses/i2c-imx-lpi2c.c +++ b/drivers/i2c/busses/i2c-imx-lpi2c.c @@ -8,6 +8,8 @@ #include #include #include +#include +#include #include #include #include @@ -31,6 +33,7 @@ #define LPI2C_MCR 0x10 /* i2c contrl register */ #define LPI2C_MSR 0x14 /* i2c status register */ #define LPI2C_MIER 0x18 /* i2c interrupt enable */ +#define LPI2C_MDER 0x1C /* i2c DMA enable */ #define LPI2C_MCFGR0 0x20 /* i2c master configuration */ #define LPI2C_MCFGR1 0x24 /* i2c master configuration */ #define LPI2C_MCFGR2 0x28 /* i2c master configuration */ @@ -72,11 +75,15 @@ #define MCFGR1_AUTOSTOP BIT(8) #define MCFGR1_IGNACK BIT(9) #define MRDR_RXEMPTY BIT(14) +#define MDER_TDDE BIT(0) +#define MDER_RDDE BIT(1) #define I2C_CLK_RATIO 24 / 59 #define CHUNK_DATA 256 #define I2C_PM_TIMEOUT 1000 /* ms */ +#define I2C_DMA_THRESHOLD 16 /* bytes */ +#define I2C_USE_PIO (-150) enum lpi2c_imx_mode { STANDARD, /* <=100Kbps */ @@ -95,6 +102,7 @@ enum lpi2c_imx_pincfg { struct lpi2c_imx_struct { struct i2c_adapter adapter; + resource_size_t phy_addr; int irq; struct clk *clk_per; struct clk *clk_ipg; @@ -114,6 +122,17 @@ struct lpi2c_imx_struct { struct pinctrl *pinctrl; struct pinctrl_state *pinctrl_pins_default; struct pinctrl_state *pinctrl_pins_gpio; + + bool can_use_dma; + bool using_dma; + bool xferred; + struct i2c_msg *msg; + dma_addr_t dma_addr; + struct dma_chan *dma_tx; + struct dma_chan *dma_rx; + enum dma_data_direction dma_direction; + u8 *dma_buf; + unsigned int dma_len; }; static void lpi2c_imx_intctrl(struct lpi2c_imx_struct *lpi2c_imx, @@ -289,6 +308,9 @@ static int lpi2c_imx_master_enable(struct lpi2c_imx_struct *lpi2c_imx) if (ret) goto rpm_put; + if (lpi2c_imx->can_use_dma) + writel(MDER_TDDE | MDER_RDDE, lpi2c_imx->base + LPI2C_MDER); + temp = readl(lpi2c_imx->base + LPI2C_MCR); temp |= MCR_MEN; writel(temp, lpi2c_imx->base + LPI2C_MCR); @@ -462,6 +484,154 @@ static void lpi2c_imx_read(struct lpi2c_imx_struct *lpi2c_imx, lpi2c_imx_intctrl(lpi2c_imx, MIER_RDIE | MIER_NDIE); } +static void lpi2c_dma_unmap(struct lpi2c_imx_struct *lpi2c_imx) +{ + struct dma_chan *chan = lpi2c_imx->dma_direction == DMA_FROM_DEVICE + ? lpi2c_imx->dma_rx : lpi2c_imx->dma_tx; + + dma_unmap_single(chan->device->dev, lpi2c_imx->dma_addr, + lpi2c_imx->dma_len, lpi2c_imx->dma_direction); + + lpi2c_imx->dma_direction = DMA_NONE; +} + +static void lpi2c_cleanup_dma(struct lpi2c_imx_struct *lpi2c_imx) +{ + if (lpi2c_imx->dma_direction == DMA_NONE) + return; + else if (lpi2c_imx->dma_direction == DMA_FROM_DEVICE) + dmaengine_terminate_all(lpi2c_imx->dma_rx); + else if (lpi2c_imx->dma_direction == DMA_TO_DEVICE) + dmaengine_terminate_all(lpi2c_imx->dma_tx); + + lpi2c_dma_unmap(lpi2c_imx); +} + +static void lpi2c_dma_callback(void *data) +{ + struct lpi2c_imx_struct *lpi2c_imx = (struct lpi2c_imx_struct *)data; + + lpi2c_dma_unmap(lpi2c_imx); + writel(GEN_STOP << 8, lpi2c_imx->base + LPI2C_MTDR); + lpi2c_imx->xferred = true; + + complete(&lpi2c_imx->complete); +} + +static int lpi2c_dma_submit(struct lpi2c_imx_struct *lpi2c_imx, + struct i2c_msg *msg) +{ + bool read = msg->flags & I2C_M_RD; + enum dma_data_direction dir = read ? DMA_FROM_DEVICE : DMA_TO_DEVICE; + struct dma_chan *chan = read ? lpi2c_imx->dma_rx : lpi2c_imx->dma_tx; + struct dma_async_tx_descriptor *txdesc; + dma_cookie_t cookie; + + lpi2c_imx->dma_len = read ? msg->len - 1 : msg->len; + lpi2c_imx->msg = msg; + lpi2c_imx->dma_direction = dir; + + if (IS_ERR(chan)) + return PTR_ERR(chan); + + lpi2c_imx->dma_addr = dma_map_single(chan->device->dev, + lpi2c_imx->dma_buf, + lpi2c_imx->dma_len, dir); + if (dma_mapping_error(chan->device->dev, lpi2c_imx->dma_addr)) { + dev_err(&lpi2c_imx->adapter.dev, "dma map failed, use pio\n"); + return -EINVAL; + } + + txdesc = dmaengine_prep_slave_single(chan, lpi2c_imx->dma_addr, + lpi2c_imx->dma_len, read ? + DMA_DEV_TO_MEM : DMA_MEM_TO_DEV, + DMA_PREP_INTERRUPT | DMA_CTRL_ACK); + if (!txdesc) { + dev_err(&lpi2c_imx->adapter.dev, "dma prep slave sg failed, use pio\n"); + lpi2c_cleanup_dma(lpi2c_imx); + return -EINVAL; + } + + reinit_completion(&lpi2c_imx->complete); + txdesc->callback = lpi2c_dma_callback; + txdesc->callback_param = (void *)lpi2c_imx; + + cookie = dmaengine_submit(txdesc); + if (dma_submit_error(cookie)) { + dev_err(&lpi2c_imx->adapter.dev, "submitting dma failed, use pio\n"); + lpi2c_cleanup_dma(lpi2c_imx); + return -EINVAL; + } + + lpi2c_imx_intctrl(lpi2c_imx, MIER_NDIE); + + dma_async_issue_pending(chan); + + return 0; +} + +static bool is_use_dma(struct lpi2c_imx_struct *lpi2c_imx, struct i2c_msg *msg) +{ + if (!lpi2c_imx->can_use_dma) + return false; + + if (msg->len < I2C_DMA_THRESHOLD) + return false; + + return true; +} + +static int lpi2c_imx_push_rx_cmd(struct lpi2c_imx_struct *lpi2c_imx, + struct i2c_msg *msg) +{ + unsigned int temp, rx_remain; + unsigned long orig_jiffies = jiffies; + + if ((msg->flags & I2C_M_RD)) { + rx_remain = msg->len; + do { + temp = rx_remain > CHUNK_DATA ? + CHUNK_DATA - 1 : rx_remain - 1; + temp |= (RECV_DATA << 8); + while ((readl(lpi2c_imx->base + LPI2C_MFSR) & 0xff) > 2) { + if (time_after(jiffies, orig_jiffies + msecs_to_jiffies(1000))) { + 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(); + } + writel(temp, lpi2c_imx->base + LPI2C_MTDR); + rx_remain = rx_remain - (temp & 0xff) - 1; + } while (rx_remain > 0); + } + + return 0; +} + +static int lpi2c_dma_xfer(struct lpi2c_imx_struct *lpi2c_imx, + struct i2c_msg *msg) +{ + int result; + + result = lpi2c_dma_submit(lpi2c_imx, msg); + if (!result) { + result = lpi2c_imx_push_rx_cmd(lpi2c_imx, msg); + if (result) + return result; + result = lpi2c_imx_msg_complete(lpi2c_imx); + return result; + } + + /* DMA xfer failed, try to use PIO, clean up dma things */ + i2c_put_dma_safe_msg_buf(lpi2c_imx->dma_buf, lpi2c_imx->msg, + lpi2c_imx->xferred); + lpi2c_cleanup_dma(lpi2c_imx); + + return I2C_USE_PIO; +} + static int lpi2c_imx_xfer(struct i2c_adapter *adapter, struct i2c_msg *msgs, int num) { @@ -474,6 +644,9 @@ static int lpi2c_imx_xfer(struct i2c_adapter *adapter, return result; for (i = 0; i < num; i++) { + lpi2c_imx->xferred = false; + lpi2c_imx->using_dma = false; + result = lpi2c_imx_start(lpi2c_imx, &msgs[i]); if (result) goto disable; @@ -482,9 +655,24 @@ static int lpi2c_imx_xfer(struct i2c_adapter *adapter, if (num == 1 && msgs[0].len == 0) goto stop; + if (is_use_dma(lpi2c_imx, &msgs[i])) { + lpi2c_imx->using_dma = true; + + writel(0x1, lpi2c_imx->base + LPI2C_MFCR); + + lpi2c_imx->dma_buf = i2c_get_dma_safe_msg_buf(&msgs[i], + I2C_DMA_THRESHOLD); + if (lpi2c_imx->dma_buf) { + result = lpi2c_dma_xfer(lpi2c_imx, &msgs[i]); + if (result != I2C_USE_PIO) + goto stop; + } + } + + lpi2c_imx->using_dma = false; lpi2c_imx->delivered = 0; lpi2c_imx->msglen = msgs[i].len; - init_completion(&lpi2c_imx->complete); + reinit_completion(&lpi2c_imx->complete); if (msgs[i].flags & I2C_M_RD) lpi2c_imx_read(lpi2c_imx, &msgs[i]); @@ -503,7 +691,16 @@ static int lpi2c_imx_xfer(struct i2c_adapter *adapter, } stop: - lpi2c_imx_stop(lpi2c_imx); + if (!lpi2c_imx->using_dma) + lpi2c_imx_stop(lpi2c_imx); + else { + i2c_put_dma_safe_msg_buf(lpi2c_imx->dma_buf, lpi2c_imx->msg, + lpi2c_imx->xferred); + if (result) { + lpi2c_cleanup_dma(lpi2c_imx); + writel(GEN_STOP << 8, lpi2c_imx->base + LPI2C_MTDR); + } + } temp = readl(lpi2c_imx->base + LPI2C_MSR); if ((temp & MSR_NDF) && !result) @@ -528,6 +725,10 @@ static irqreturn_t lpi2c_imx_isr(int irq, void *dev_id) temp = readl(lpi2c_imx->base + LPI2C_MSR); if (temp & MSR_NDF) { + if (lpi2c_imx->using_dma) { + lpi2c_cleanup_dma(lpi2c_imx); + writel(GEN_STOP << 8, lpi2c_imx->base + LPI2C_MTDR); + } complete(&lpi2c_imx->complete); goto ret; } @@ -623,20 +824,94 @@ static const struct of_device_id lpi2c_imx_of_match[] = { }; MODULE_DEVICE_TABLE(of, lpi2c_imx_of_match); +static void lpi2c_dma_exit(struct lpi2c_imx_struct *lpi2c_imx) +{ + if (lpi2c_imx->dma_rx) { + dma_release_channel(lpi2c_imx->dma_rx); + lpi2c_imx->dma_rx = NULL; + } + + if (lpi2c_imx->dma_tx) { + dma_release_channel(lpi2c_imx->dma_tx); + lpi2c_imx->dma_tx = NULL; + } +} + +static int lpi2c_dma_init(struct device *dev, + struct lpi2c_imx_struct *lpi2c_imx) +{ + int ret; + struct dma_slave_config dma_sconfig; + + /* Prepare for TX DMA: */ + lpi2c_imx->dma_tx = dma_request_chan(dev, "tx"); + if (IS_ERR(lpi2c_imx->dma_tx)) { + ret = PTR_ERR(lpi2c_imx->dma_tx); + dev_err(dev, "can't get the TX DMA channel, error %d!\n", ret); + lpi2c_imx->dma_tx = NULL; + goto err; + } + + dma_sconfig.dst_addr = lpi2c_imx->phy_addr + LPI2C_MTDR; + dma_sconfig.dst_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE; + dma_sconfig.dst_maxburst = 1; + dma_sconfig.direction = DMA_MEM_TO_DEV; + ret = dmaengine_slave_config(lpi2c_imx->dma_tx, &dma_sconfig); + if (ret < 0) { + dev_err(dev, "can't configure tx channel (%d)\n", ret); + goto fail_tx; + } + + /* Prepare for RX DMA: */ + lpi2c_imx->dma_rx = dma_request_chan(dev, "rx"); + if (IS_ERR(lpi2c_imx->dma_rx)) { + ret = PTR_ERR(lpi2c_imx->dma_rx); + dev_err(dev, "can't get the RX DMA channel, error %d\n", ret); + lpi2c_imx->dma_rx = NULL; + goto fail_tx; + } + + dma_sconfig.src_addr = lpi2c_imx->phy_addr + LPI2C_MRDR; + dma_sconfig.src_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE; + dma_sconfig.src_maxburst = 1; + dma_sconfig.direction = DMA_DEV_TO_MEM; + ret = dmaengine_slave_config(lpi2c_imx->dma_rx, &dma_sconfig); + if (ret < 0) { + dev_err(dev, "can't configure rx channel (%d)\n", ret); + goto fail_rx; + } + + lpi2c_imx->can_use_dma = true; + lpi2c_imx->using_dma = false; + + return 0; +fail_rx: + dma_release_channel(lpi2c_imx->dma_rx); +fail_tx: + dma_release_channel(lpi2c_imx->dma_tx); +err: + lpi2c_dma_exit(lpi2c_imx); + lpi2c_imx->can_use_dma = false; + return ret; +} + static int lpi2c_imx_probe(struct platform_device *pdev) { struct lpi2c_imx_struct *lpi2c_imx; unsigned int temp; int ret; + struct resource *res; lpi2c_imx = devm_kzalloc(&pdev->dev, sizeof(*lpi2c_imx), GFP_KERNEL); if (!lpi2c_imx) return -ENOMEM; + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); lpi2c_imx->base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(lpi2c_imx->base)) return PTR_ERR(lpi2c_imx->base); + lpi2c_imx->phy_addr = (dma_addr_t)res->start; lpi2c_imx->irq = platform_get_irq(pdev, 0); if (lpi2c_imx->irq < 0) return lpi2c_imx->irq; @@ -691,6 +966,18 @@ static int lpi2c_imx_probe(struct platform_device *pdev) if (ret == -EPROBE_DEFER) goto rpm_disable; + /* Init DMA */ + lpi2c_imx->dma_direction = DMA_NONE; + lpi2c_imx->dma_rx = lpi2c_imx->dma_tx = NULL; + ret = lpi2c_dma_init(&pdev->dev, lpi2c_imx); + if (ret) { + dev_err_probe(&pdev->dev, ret, "dma setup error %d, use pio\n", ret); + if (ret == -EPROBE_DEFER) + goto rpm_disable; + } + + init_completion(&lpi2c_imx->complete); + ret = i2c_add_adapter(&lpi2c_imx->adapter); if (ret) goto rpm_disable;