From patchwork Fri Jul 16 07:37:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Clark Wang X-Patchwork-Id: 12381551 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.4 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,URIBL_BLOCKED,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 60683C07E95 for ; Fri, 16 Jul 2021 07:36:21 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 23E6B613F2 for ; Fri, 16 Jul 2021 07:36:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 23E6B613F2 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-i3c-bounces+linux-i3c=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; 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=bn/PiOWOPI+FsOwNlro4ZCGhxkF8BN1Gb5xYMMQNfik=; b=K6BoduWAXBIkTS rawZ56ktNFPst2nLC6Crdm6oPb+1tCrxbWMm3HC4/WEdPppHIfa8PGlF5/faDHJwf3Mz+xlnRc3am f7HAy8cZN0x0/1uJSZJ8Itand9Eib1ce9/M21feAoDTiuYwKRXkXnaBXKRNaFc+sIc5g5YFmbT6MX 9E1oRlYJUlfCNf3mTElN9bLaIrAjF2kWTJaXY1Bim0c7IewWNlGSAacgratfAl0S3ErMPuyH3784A Y4hfXPl74R24HjJt7Ni1iGcws6qQPAKHSu5X+KVsb5XYTGSM68XHmKQLZ61gXsvZfmd2VaNd4XEWd jbPxlwMTadq1rvKvzMng==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m4IOS-003Xqa-Lj; Fri, 16 Jul 2021 07:36:20 +0000 Received: from mail-db8eur05on2078.outbound.protection.outlook.com ([40.107.20.78] helo=EUR05-DB8-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m4IOP-003Xof-Gb for linux-i3c@lists.infradead.org; Fri, 16 Jul 2021 07:36:18 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oXGeOafYwGbQPZ6sFW0uK5nmS76uW3rm1P/equV1HKRxX80O4mVGeXtjL2Oiq+6HNV4x2obnQ9gu9oaV8YiI7cMrIh8MCz5ExQB3mkcetD4y4Tx/9W1IfVa1cpQM8WN4EovUJDx0zcl89vQ8nRpGSMh/cVq7cA+seXgUq7a+r9up44XlvsD9K1rtD9e6aMsJZuFhk4Ld00AKniXYUJpNC5vtW25xRgByR1BcWlyKB4UnR7zJ6yHYxrkIvBj5+q6LM1dpm1blY3TxtwmX0rcwY9jgKDGedyzEPV3bjC3QBMA/YS+llRDLFNNTc3skedILXC26Mg7ZRW8TtdRnhT/Vmw== 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=4Yk8hrRAIbCocDf+HCEtdZ6+HOTrKPE878c/SGfwEk8=; b=JeH25rEjRLLXIu+n9MMD6Pnl9qYcHmak+I1p1ShEg4Wo8Px/55+e9KMMY/0PXMYa8lPuGmFd2P2dKzwDtKjTvkKcnNOIoZDux0bjT5LPf0sSgVwM3MVWFp1Zbh4L9n+O5lgk22SeYyR7kGenG3O1MNaQJQ4l1NtrIfElFMcG+uIuJMkIBJiWNuXJlaiDXag3xNmX40lTUKZmqvsCghWzkYLzb+zxxZNNwjQX4FWG/cTPzvH77KjRfnmPJNLevKhhbV8kAe3eeJpPcQ5pmFtctSFHgS6KI0DmNxiCF+6egnrPsCa1/Ps+KyjbbYoC15WpI1nrcz3v9ksDYy8QFd2Hiw== 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=4Yk8hrRAIbCocDf+HCEtdZ6+HOTrKPE878c/SGfwEk8=; b=AF6hA2TDlnMIBb0NYDloTFDqfF9iaa3esMnLJouhnjJV/hhdY/rR8KoP9d9JxnKTSdr48V1ISrmtsn8vQASse0hnaq0x5YReNpyOUwcjOuHKqyjCG91l09eeD76nl+Q9RuojFGt9Lkf+KpAcwP8Sfv0aOBRX34IbyqR4VsH834A= Authentication-Results: bootlin.com; dkim=none (message not signed) header.d=none;bootlin.com; dmarc=none action=none header.from=nxp.com; Received: from AM6PR04MB5623.eurprd04.prod.outlook.com (2603:10a6:20b:a9::13) by AM7PR04MB6997.eurprd04.prod.outlook.com (2603:10a6:20b:10d::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21; Fri, 16 Jul 2021 07:36:14 +0000 Received: from AM6PR04MB5623.eurprd04.prod.outlook.com ([fe80::74f8:10b:8efd:b265]) by AM6PR04MB5623.eurprd04.prod.outlook.com ([fe80::74f8:10b:8efd:b265%5]) with mapi id 15.20.4308.027; Fri, 16 Jul 2021 07:36:14 +0000 From: Clark Wang To: miquel.raynal@bootlin.com, conor.culhane@silvaco.com, alexandre.belloni@bootlin.com Cc: linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org, xiaoning.wang@nxp.com Subject: [PATCH V2 1/5] i3c: master: svc: move module reset behind clk enable Date: Fri, 16 Jul 2021 15:37:19 +0800 Message-Id: <20210716073723.3490180-2-xiaoning.wang@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210716073723.3490180-1-xiaoning.wang@nxp.com> References: <20210716073723.3490180-1-xiaoning.wang@nxp.com> X-ClientProxiedBy: SG2PR02CA0005.apcprd02.prod.outlook.com (2603:1096:3:17::17) To AM6PR04MB5623.eurprd04.prod.outlook.com (2603:10a6:20b:a9::13) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (119.31.174.71) by SG2PR02CA0005.apcprd02.prod.outlook.com (2603:1096:3:17::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21 via Frontend Transport; Fri, 16 Jul 2021 07:36:12 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b6ed5084-ce66-421c-bce4-08d9482c63e2 X-MS-TrafficTypeDiagnostic: AM7PR04MB6997: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:813; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: A8FJ0xvIxzE3wKmql0lxgNY5DeOLIWl2P98ysGnRZB2hMJHDe4LhJ6jxU5saa6nN3Wisya+rEQQcWUMwhmoz3BDHuhUz7WMK0kpck1TOAZFdFTFdifYNSedv4lh4hSELnsCGN5hWTZHG/YyeCrSAU9rZuY739ZpunRMccvqMefaDerLxnGGyUn1oFoyFsN6SK9X6HxdwcBwpUq55Qmj795dBGrnyetb9o+Pt7ftAZ7/rXlCKRkpKTKi/acCHTuJkYe6knN3XxodBx9KdVq1gf1cuBaIGPkLqsoShZdQHdsh5pZ0uExLWQeMw7WP4CrixFLX4zk1sbDRkNLJew6ilGfIqTB1iXGd3yuofm6cBKJTRisPB4y/jm8eIE3JJ/T+ZoFNAzcTHY9GVIUMyGspm8nVVeQCBUJFDaYAnOCia98VRrjQPazG5hzzPOspGs6hwSj12C1Zmg2FkrVsjsAd+moECCOCR6ijZ7rnWPpnmeFNW158UhEpsW9oR/inP1Zt2eMUpUm5H5DL3pE5v2D80dLMxTU7wtU7ym2JmAahAg7eJhdI/B+EIPd5t64qyATnsvSgi8T2C7lBHtK0si0zVA3v2gTyUOO2OZVKfD0m1QxZF6acJ3MBGmortmLZN6YInOR7ex8TSslgw8Hbj+v+Vtz7kqttGuJ06umUeHVDEFqhaGmd336Bjo096jvEq6hLd7aDBK1iEbE6lX00DP2hQ8g== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR04MB5623.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(136003)(376002)(366004)(346002)(396003)(39850400004)(316002)(83380400001)(2616005)(26005)(956004)(38100700002)(2906002)(6506007)(38350700002)(52116002)(5660300002)(4744005)(86362001)(66946007)(66476007)(66556008)(6486002)(4326008)(36756003)(8936002)(186003)(8676002)(1076003)(478600001)(6512007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: l/rrzlwPHKtUNPap2oaO78xtBP/S+SEsUfVMDTNHw5p3n4E1CVdyh1s0YP7uKHhmD2cQn2IOCv961OO8OInu1skFOMcPB1JFH7vIzxmXH8Vi53enkHvPYBQkQtvhdTOKyX8/cNuybWJKV+/hCZMpDA8h2aJ0VMZnsBFlnxNDdHc84gokapNRi45xv9scV6QaYeS9YRuj0F9gJcBD7ChF67dv6O3AKJsVEU4Qeg/dDb/aBYA626vl+vpYm39t64jcpfpRpFVs+PmqdmD1ho5970pfxrdUJkVfYJkLdyDVyOEAkrbGF6V8Y3nqS1JMADV82Pr0H+gwMNJyP61bhFBb16JULnQCCQbsvTxnlaeZuybHUXLv8ezgzyOls31BzrOPEP+GjJXNbWSVVymyv0zteA0JaTL1RR+YeMtbVbFr2Rn0oaPxgbHhQkDfCdvdgdmWvbECpU6InpCtTXEl62MaozJkSwE67wwNjKnsRJJE4tNaZESCUfnUB7XCRw/7M4KERbeltj/d73SxhhWNUClC+x9yUnwwxw7SEZyxSPoIY8XiqjO6VX49xLGN6CnRtG82HlrffazyJrPYZvdhtN3hnZMx4YkndiV1iumX+5GIeAjsvgPgghp/jTOICxyQJHHjwNFjpaVwEnacsF99656SQEphBDlvxpVIJoKQ5nUkuyuZ0Zz6vnVPwy39+yfp3ZKsf4JALliBGC+ruVZjtNCmivxi06AJ5VKH9cgSY14RSR1+lHa90D4PPRGy40neU7AFh1WgriwupBqlUGfEhCcU05Hkc2rpquWArwdK/27dVsGiSCb5I6Q9UumZF/kxl0LkHg6AIlSQWX3KOGmKQNN9DXtOJDYNBgMLflct0QXxLb2G2jfZXG7D/ZJgT7TNdcqIO6+k9dbJS9cl1BWp9r39fQgZ0hspEKNVeFP7c5HBX4834lu8cu/YYhQXiaw0MgbiXkYIv59BUtzR45+7FKTWufbGy1UxFh8g8yn9Xtf3XLdmGotbVdF2EeSdCJ+R2+Z63l45qosI7OS5A3Mk+VlTGn1le8mBpY2mIenL9SGclRDjrE4FVQQAhNRB5qo4MD3d+0Wmh5DY6Ye7FgUbs2pyUOEdiNmllX8LFzZngFzKlMu4UvFemIe184fTCkNTvkVg2/oHxC0E1vU7uefjWL7MLfcw0rn5V524NVwTjkMJN9FJ4QIxRNaIg+iptGj87lGyhAab28imtO6yfPDNoRfsegleJeiNEcREIjQIU0niSHuXelKJUUvOER+Yu7iSP9XBZZPA/pIQmTBxjElG6dobb/h0VL643WtPblbcZk1WUgcTpHNCI2dvZZbrQgjlVlsS X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b6ed5084-ce66-421c-bce4-08d9482c63e2 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB5623.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jul 2021 07:36:14.3939 (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: 6KM3T1fIYGQHORQWkAtu+vbtekHPNi9DLPb+8tbgNXiBviEJJwCeb8lFz6OE85qF7ql7WmidzR/FHHRTSil6NA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR04MB6997 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210716_003617_575000_53E9F618 X-CRM114-Status: GOOD ( 10.28 ) X-BeenThere: linux-i3c@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-i3c" Errors-To: linux-i3c-bounces+linux-i3c=archiver.kernel.org@lists.infradead.org Reset I3C module will R/W its regs, so enable its clocks first. Signed-off-by: Clark Wang Reviewed-by: Miquel Raynal --- V2: No change. --- drivers/i3c/master/svc-i3c-master.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c index 879e5a64acaf..c25a372f6820 100644 --- a/drivers/i3c/master/svc-i3c-master.c +++ b/drivers/i3c/master/svc-i3c-master.c @@ -1381,8 +1381,6 @@ static int svc_i3c_master_probe(struct platform_device *pdev) master->dev = dev; - svc_i3c_master_reset(master); - ret = clk_prepare_enable(master->pclk); if (ret) return ret; @@ -1419,6 +1417,8 @@ static int svc_i3c_master_probe(struct platform_device *pdev) platform_set_drvdata(pdev, master); + svc_i3c_master_reset(master); + /* Register the master */ ret = i3c_master_register(&master->base, &pdev->dev, &svc_i3c_master_ops, false); From patchwork Fri Jul 16 07:37:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Clark Wang X-Patchwork-Id: 12381553 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.4 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,URIBL_BLOCKED,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 81B1BC6377C for ; Fri, 16 Jul 2021 07:36:22 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 4A475613DF for ; Fri, 16 Jul 2021 07:36:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4A475613DF 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-i3c-bounces+linux-i3c=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; 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=r3vW2LWizz8o7o5t8F+tngoSt/U86VMTjk7FoSkgs+0=; b=II2bv6/5YIlo5D uJL5dyOVDfbP7LFuH+qkc2XVXStPIL9p64qSZQnERfK48y+aQNlUTAsZkwSBg3jMwEXwt5iQ/RlUk aznaCYFwxN0kbzu5daYxChy6Qn2dhN0+8+91A9/0Pr3xoHb3xw30PndpsseO+sCXtdTSgxysdVHUF jW0XOow3G6TRseFZ5mAXwSfRwrOIs76FbdtqGZSZtzVTaRP3JHTiN0ZM+32A6vGyLk2lLJIOJ9prd xBRn7rHpukWhe9DFJWy3nCQy/zDRC9TfOSvzS1dM92pHyWdTxGSUbszxURUj9+StqOT166KArp7mV kJMiLS5vyYV4tk0l0UFw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m4IOT-003XrK-Qw; Fri, 16 Jul 2021 07:36:21 +0000 Received: from mail-db8eur05on2078.outbound.protection.outlook.com ([40.107.20.78] helo=EUR05-DB8-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m4IOR-003Xof-3c for linux-i3c@lists.infradead.org; Fri, 16 Jul 2021 07:36:20 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bVf4YLHSVY3NNzXttHCUo2YKSAvuEbdxQl2VvyFvmi1CtdbJRL4NsCI9QybSpLyRTBXeMv+8mR4m06Xib5WhNoHza+nevkg2Nk6gkWPfuHv3KcqmEnWYlg2PyvEBMc1hST8k3XPTbtnoA28XT+LzjMBO9540fgOw1B6rVAqGJn7oLJFKHSmTZBC2oZMDieaurUjzuV+6OQTCitDDQ9ffnaUdnGQfQzTuUjmc97NXwLDr7aA9iZTq/I8gAkgKBX5Nt0+oyzJ3hLAXPaQ1+IVWXhucv2rxO2MOhY8rGcckuCL8uz+Iy/Gfi7WW748nijnQGlv4bwTE9sS6kjZ6NqWFHw== 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=ZV565itl71k/JX1Rjy1rKPFPig8Fjh0EGUEid+lA/iA=; b=j7gOELOvq2V1tmxAJvOgG1V5tEx0vCsd3Kq6K8kSCKXr8lLtXLniUnmLQUTluaSJ+oupq+Dyraz6ZqTr9mVpjTQQWpADh4W+/mnKQQyIBG9vjG/jpxEH5NVyTd2lzoKiP6szTuHtPA1QPIZQroAx6Z0v7Jt3FPV6tCOpqOj2Gp0KQ+bZ8BeMpvkdsNFzrqp9sViI9sMlXwn7WMrjOdNycrBCABGHdCQzAPBc273YOFm8Xub6/saNQzZdw2zq31V6RBjQ5Jc2Cck1bbwODSSVh7eNy9wgIJQlyt9wRInefUYZkEvvJlBIf2vnG0Ob6C3KeXJiXlZMCy8kI8FEWIcMXA== 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=ZV565itl71k/JX1Rjy1rKPFPig8Fjh0EGUEid+lA/iA=; b=gLmIKK9wxYBSy+PKZGIv7IIX/UqdyiXTcN3ETeSq83bAGqwMTU8+eRnC9nucXZTA7/cnFw3focw94PR3mInD1w6a+OK6XqT3JHTqApz03M+EZ8hHcEv4pGo5e78YcYbKEUv5DmUx+PpC+Ihs3pTVKhQrPRdT2BwvuSPCqbfA78Y= Authentication-Results: bootlin.com; dkim=none (message not signed) header.d=none;bootlin.com; dmarc=none action=none header.from=nxp.com; Received: from AM6PR04MB5623.eurprd04.prod.outlook.com (2603:10a6:20b:a9::13) by AM7PR04MB6997.eurprd04.prod.outlook.com (2603:10a6:20b:10d::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21; Fri, 16 Jul 2021 07:36:17 +0000 Received: from AM6PR04MB5623.eurprd04.prod.outlook.com ([fe80::74f8:10b:8efd:b265]) by AM6PR04MB5623.eurprd04.prod.outlook.com ([fe80::74f8:10b:8efd:b265%5]) with mapi id 15.20.4308.027; Fri, 16 Jul 2021 07:36:17 +0000 From: Clark Wang To: miquel.raynal@bootlin.com, conor.culhane@silvaco.com, alexandre.belloni@bootlin.com Cc: linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org, xiaoning.wang@nxp.com Subject: [PATCH V2 2/5] i3c: master: svc: fix atomic issue Date: Fri, 16 Jul 2021 15:37:20 +0800 Message-Id: <20210716073723.3490180-3-xiaoning.wang@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210716073723.3490180-1-xiaoning.wang@nxp.com> References: <20210716073723.3490180-1-xiaoning.wang@nxp.com> X-ClientProxiedBy: SG2PR02CA0005.apcprd02.prod.outlook.com (2603:1096:3:17::17) To AM6PR04MB5623.eurprd04.prod.outlook.com (2603:10a6:20b:a9::13) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (119.31.174.71) by SG2PR02CA0005.apcprd02.prod.outlook.com (2603:1096:3:17::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21 via Frontend Transport; Fri, 16 Jul 2021 07:36:14 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a5334e41-5321-4573-4e16-08d9482c6579 X-MS-TrafficTypeDiagnostic: AM7PR04MB6997: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4714; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CoGJq3/IN81+UCgg/0RKxxu2HTxoSck3j7sJ7KIG795jN7T5EIVXEwLx8ugSm1V0Q9jxMp5H/EQSi5JUcrabC4oYgQPaeem9HW2AIdxy/Cl1cFHG3IS74frUVT/eZICT/ONLTDRU97m745o6wi0kwd2UlAmbIt3upX1TQFmVe8yzIftK9GdumIcA6ZfS6mYBk99W5gENFxXCVDxTV/v2J1G4lpyZDQfO6xLi/4D2G+0HPNt/fc5sC00Vc8TSrcQxVxawjDCY7EM+UtZqgeRlEJjMwUAcOZ3VzoI3IiWQju+5Fk+qLe3pQ82XG+dzrimxOjKMYxvinyjStjrLuYitJIxYdU+6awPlrXOyhPzsMF1JguyFdVJwM4IBDrFB0jTbWtfi7+aQ3ZlHiZoyjav2X3hdYOgEM4UAUSYnog5w08NwuGAxfQYjoj62kGt4XMF6fc2AtcMfpZ5h4R3wvJWxAG0XbaVV1r6evdyo9y1yG3R/VC3zIeekVN1Bqh+MxLarsg7KHAwqV9q/g1B3mKez2tlVCjLg6ew14e9Yz/R72AxvBjmheN3wfQaQeTqV6eADCbKb+YX5J3ifWA/XUkHZXMJDL5zyaCiV1pJYj8Vw6xphdTfgaBuwMI5Hrb2s3abRIueKT1axfFWkWdeZyJaJsea/76AqcyQyjyVcNzSwg+2mriwVXTuQU077OGmcQ3AD2vHtGEfIkeHjdfDNt6Nciw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR04MB5623.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(136003)(376002)(366004)(346002)(396003)(39850400004)(316002)(83380400001)(2616005)(26005)(956004)(38100700002)(2906002)(6666004)(6506007)(38350700002)(52116002)(5660300002)(86362001)(66946007)(66476007)(66556008)(6486002)(4326008)(36756003)(8936002)(186003)(8676002)(1076003)(478600001)(6512007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: APQGJCY6N16yFK0O+ZtUiwXZ/Bz+w0suPliNR2QUfZunZ68jj5LFbLSc0VVoKZVylRU9FHGpOKeBFQuIRjxaobLRHFEIBzd3zaApuB9J/jYQ2cV8dknbITC8jmMvNOHcIAY3mI6zdaE4utwMYXMj+N05qa3D1eHnDEYEUWV8VnzNPfxyxAPy+O99XunoSJ3+aMQoWU0bBaKDd9m6l7vmti5XguWuVabpcV81k9Osx1Yxyk6Bs33POSdSk9EoKXHKcP0nSm9tTS4JB2xjKASM6zF2zY89n6jQa8EmLJ28Q5unlMZid34sfd5354AGd68zO83QL5RSUwOobD+CgB7nXHPcyxlZnwLk0P9k1QFI+SnAojv6FDAl857HVVgdx00ZBxGztURRVgbtS06azCVoI56z15eLYUEJAz2ZcFdkYCN0MmA2LZFj9ihRfK2M0aKLVU1Z8QiVIvySTxeIVOrAZrgjp9snA1VQEAo33IZaktToTyJJbhgMsMUQs/O43PN31tmCQsNaOPFNJw1kdjrpoOMP2Z6qSnG8IT+90uyJU45HXKeXxw2Dvj1TW9RscLQWO6KSczG1LKA1eEcb2rDXbI3zNdXTVZ6XMmOhK9IVK6UBCAv8snTiD2W6bAos6ERk4gIs2sHmHSrj7QvvoPHNWkWIjzF9oPfSh3Ee0QrNBSoAYD7vC5lQaxYQ/PHpI8lWjx9sqG5zjis47YTOs+iTYZNUdrAeT2x8OmmwfdC6Ri1pGgfjG51soGX3kxFUdS/RDfP1RoXEfh9uBM58+u7XGkCPYKa79V5JKcWgp7BiGKGqJLmPnj+ZdUnh2Ntp6BTRctIcwPljlj5AbIONAzmnPoc7NRnF0klVcS8INH+WB6XRrdwBTTzX93HNtSn3AXMXuYgeluFW3LvXDx4EXzQAZ/FXncq/NFY38ABjqnKYKztoDSuqTCLyeKtTGMl0p3zzE6FC8VIAy3g2cx4zP9sLqFUdamU1UNplrA/knHN4tfA2TeZfc0XDiYhd5wQutoHqsXl5jE4iz2Hvokix7r4+T2ArC6Bk/TBNSLZHcUy+6WYSwq1Fg9M5kYzndSHZRr7TjGjZKEfgRL5A2UdVR6maa6M26KJf0gq1IEYDzSECjJ9l3qKNI/c2khh8OTl12Wn6lEJ60l6Vpy4wb6Et/CxT6trjOqweJAdOIOAHZIBeZkC1TYTfNyn8TX82RU7BaQBWtHUTTuyxXkUkZOKBaFllDiAC01onj+9NhXnzKUZYvZKoTUgBk1CnrqeH4FRPd82TMFaTZ6T9hUgQTf7OfEIur1rB/7B2xgNh1nNsf9PVHHtQrEYma1mUE+HNj+qhxNAo X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: a5334e41-5321-4573-4e16-08d9482c6579 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB5623.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jul 2021 07:36:17.0553 (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: nMr4dx6SbRLIeF57kQguOEnMDBFWE2hL7LwB1BzhSVCMXHsFI3Nq3aSGtLL6S1i3PGjoLxEy1Ab9Fsr3ch6/8w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR04MB6997 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210716_003619_172916_3E04B34B X-CRM114-Status: GOOD ( 11.60 ) X-BeenThere: linux-i3c@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-i3c" Errors-To: linux-i3c-bounces+linux-i3c=archiver.kernel.org@lists.infradead.org do_daa_locked() function is in a spin lock environment, use readl_poll_timeout_atomic() to replace the origin readl_poll_timeout(). Signed-off-by: Clark Wang Reviewed-by: Miquel Raynal --- V2: align the parameters of the function. --- drivers/i3c/master/svc-i3c-master.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c index c25a372f6820..47c02a60cf62 100644 --- a/drivers/i3c/master/svc-i3c-master.c +++ b/drivers/i3c/master/svc-i3c-master.c @@ -656,8 +656,10 @@ static int svc_i3c_master_readb(struct svc_i3c_master *master, u8 *dst, u32 reg; for (i = 0; i < len; i++) { - ret = readl_poll_timeout(master->regs + SVC_I3C_MSTATUS, reg, - SVC_I3C_MSTATUS_RXPEND(reg), 0, 1000); + ret = readl_poll_timeout_atomic(master->regs + SVC_I3C_MSTATUS, + reg, + SVC_I3C_MSTATUS_RXPEND(reg), + 0, 1000); if (ret) return ret; @@ -687,10 +689,11 @@ static int svc_i3c_master_do_daa_locked(struct svc_i3c_master *master, * Either one slave will send its ID, or the assignment process * is done. */ - ret = readl_poll_timeout(master->regs + SVC_I3C_MSTATUS, reg, - SVC_I3C_MSTATUS_RXPEND(reg) | - SVC_I3C_MSTATUS_MCTRLDONE(reg), - 1, 1000); + ret = readl_poll_timeout_atomic(master->regs + SVC_I3C_MSTATUS, + reg, + SVC_I3C_MSTATUS_RXPEND(reg) | + SVC_I3C_MSTATUS_MCTRLDONE(reg), + 1, 1000); if (ret) return ret; @@ -744,11 +747,12 @@ static int svc_i3c_master_do_daa_locked(struct svc_i3c_master *master, } /* Wait for the slave to be ready to receive its address */ - ret = readl_poll_timeout(master->regs + SVC_I3C_MSTATUS, reg, - SVC_I3C_MSTATUS_MCTRLDONE(reg) && - SVC_I3C_MSTATUS_STATE_DAA(reg) && - SVC_I3C_MSTATUS_BETWEEN(reg), - 0, 1000); + ret = readl_poll_timeout_atomic(master->regs + SVC_I3C_MSTATUS, + reg, + SVC_I3C_MSTATUS_MCTRLDONE(reg) && + SVC_I3C_MSTATUS_STATE_DAA(reg) && + SVC_I3C_MSTATUS_BETWEEN(reg), + 0, 1000); if (ret) return ret; From patchwork Fri Jul 16 07:37:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Clark Wang X-Patchwork-Id: 12381555 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.4 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,URIBL_BLOCKED,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 AF550C636CD for ; Fri, 16 Jul 2021 07:36:24 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 75895613F9 for ; Fri, 16 Jul 2021 07:36:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 75895613F9 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-i3c-bounces+linux-i3c=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; 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=AjwpmyUlMvbZ0HvFdfPnerPlnnUKjawnis8MKeKg1oY=; b=BcgfuVIIwo3oTs NvKfAqn1Ft0nBC2MUjEDxkdAVNKWb5hOVHY4nvjxY8cd9uDPlAaeL/oTWipsCnWk1h9PLb3jGQE7s olkme/YxPokMrvFcg6AcjYzIRtY6EmfZ36DzAYVaBzxLx/UZJ3uM96sck3BNbpR3KPDfMRt0tLjgh noxIQQwlqkDCJVDL2zUjD67ahnV7eXGvSKN+v7cMSBq6QEoRm5Ss9slDo0WMbbAbUEyphD26jetR2 jZQGlmY+3ekKY/lcCoHZkFYlQxAbitOHxrVyiV+/xfcblkTkIQwMdWRiAX6FA+Iy8fwI2uW61EOI6 1zH/CQCdrKk4pOjq+qJQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m4IOW-003XsL-0i; Fri, 16 Jul 2021 07:36:24 +0000 Received: from mail-db8eur05on2078.outbound.protection.outlook.com ([40.107.20.78] helo=EUR05-DB8-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m4IOT-003Xof-9W for linux-i3c@lists.infradead.org; Fri, 16 Jul 2021 07:36:22 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WoQi6avqTnnznxfpmEQE7qPIelabvTH2ojnqgZ08moZrJ2DhjNx3cpH3EqrSWuCvCQ8D517iuBCZNCmSWRmNopQOrK9966Ib/+L+ILp1iU+sf3sXBCpKTgHFQZCWKRzqN2XGHUSh+hrP3Eil38rKHcUa99vKFQvdysU/UKrIpZfkJYe8o/qimTjFjvGsMrN6S+eaySWFePd1QrBVIxSBGUtbPQt3HrCc14DLD+ghYvI0GFLTGyg+Sh2VgN6sdKONhR48tcmAwhq4KRIUOuN35sZGfMy/TWJ6GlLePqkTgLZyCQvsVsQJg5oD2vJucT6nE5AUAjGOZeSbXfIRYjcK4g== 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=XG1vCIvh3AbDj8o9jWKgtcTwX74OTGKA6WiUff0kLYc=; b=IV4sokShU20Be8xTba5DZRO4I03AQdMiDi3aHtas8Gb0mh9xmQXRDnmrUGayocsPApdfSikF3tS7/v6/QESOFt3sy1NjxIjTXX+XmpXtZjn4c2BRWNawy8rZ+HG5oBi046NUOqpO3/sL5cZE7OLTGeqgTXJsFKMU9GPsjvBvJ4RiAk3P/hCO0+V08/sBW1SZnhZO9Iq0nh5hiWejM00roIcsIDg8o/Vn6T2M2YhCH3WkOULHlXO1J+NIJXDLw42+WP2HoNrMaDXc1UZu5xWxtm9Ss0jVYwVqNgza9hI0HwylBQJB+zb23dt6FlDqHPHBwQt+QBa9toPNfHanb1XP8g== 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=XG1vCIvh3AbDj8o9jWKgtcTwX74OTGKA6WiUff0kLYc=; b=cgC+oUp85h+gVO4mV36vXiIoEzKIh6g+gqO1FooWxVZZTG8u8eEA/VZjrubaQh07YwWQBCYnOQMv7IOMo8Gt9txkBYHnZDLVFTvYrsRiM7ZUvczlfNdJEgHq+Aq0LzwgIsnoi6GWACx4tcwgtuaBZf3TFsNYOw2/Q3/dHRWRZh4= Authentication-Results: bootlin.com; dkim=none (message not signed) header.d=none;bootlin.com; dmarc=none action=none header.from=nxp.com; Received: from AM6PR04MB5623.eurprd04.prod.outlook.com (2603:10a6:20b:a9::13) by AM7PR04MB6997.eurprd04.prod.outlook.com (2603:10a6:20b:10d::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21; Fri, 16 Jul 2021 07:36:19 +0000 Received: from AM6PR04MB5623.eurprd04.prod.outlook.com ([fe80::74f8:10b:8efd:b265]) by AM6PR04MB5623.eurprd04.prod.outlook.com ([fe80::74f8:10b:8efd:b265%5]) with mapi id 15.20.4308.027; Fri, 16 Jul 2021 07:36:19 +0000 From: Clark Wang To: miquel.raynal@bootlin.com, conor.culhane@silvaco.com, alexandre.belloni@bootlin.com Cc: linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org, xiaoning.wang@nxp.com Subject: [PATCH V2 3/5] i3c: master: svc: add support for slave to stop returning data Date: Fri, 16 Jul 2021 15:37:21 +0800 Message-Id: <20210716073723.3490180-4-xiaoning.wang@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210716073723.3490180-1-xiaoning.wang@nxp.com> References: <20210716073723.3490180-1-xiaoning.wang@nxp.com> X-ClientProxiedBy: SG2PR02CA0005.apcprd02.prod.outlook.com (2603:1096:3:17::17) To AM6PR04MB5623.eurprd04.prod.outlook.com (2603:10a6:20b:a9::13) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (119.31.174.71) by SG2PR02CA0005.apcprd02.prod.outlook.com (2603:1096:3:17::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21 via Frontend Transport; Fri, 16 Jul 2021 07:36:17 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6b8ee3d9-6deb-4b22-f99a-08d9482c670c X-MS-TrafficTypeDiagnostic: AM7PR04MB6997: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4714; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LlnfU57Tvz2qpj3h+N/Clxaugwj4wgK+52STtzFsxsRV8eldv+D4E/amvZ6S98K66i7i2GahUf5JU8Hx1rgrC0okjxh6MUGUrcbQAxREbPT4xq8tgE4W4ijModdRcc7udQoICfVRS3dBtKX/U0soBmwI2Tc7TcMc5+n3vdHXj2rAnsp4732FKCS1OhWcxexaVapHuu19zSC893cMCELNFFVOz/zU076nfczZmTpSHAkR4qhkEfN0PkLIOKsmPeuOKWKfbCunLu1YuY5m520nZUxo7xFTLnf6+SOBTQgboD2+YEbyHVAgY/KTupZL+OGrElGwfgbebhkPKS4Jz+96CxJhXzDC4HEYxLzZwrscDkVtAeUl4HIPpyIeuVoTYQlEkT6pDTYBfIqhrnLSHBG5mDfQuJ9CdNKMR8qgk2jAJ3ACCmYAm2ne5kSSK+TYW7r4ISZiKNf1LSmq07C1235DbYyXAKiqzkJ0H5caevBG5g3l7VpmmRHK5v+6urLVTgVggYZxHEz1lhk/aF4W3AMUYOPZLecAGavL29MDgweoWRmvY5nDBymY2R+hjmDuoxJWCSopV/cwKeu21MoLDF8f2UhC2nQsVnG7xPAnXk/rQ/QmIaj+yWP/zKYSh1TxLuvJUtXtCr24MJKJh+oEeiETDzawb14GgoXwaJZVmyxI27Zn2/2O6rUCtWA8ztQ1rMKQ07qKzXE35p/8L20C38S9xg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR04MB5623.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(136003)(376002)(366004)(346002)(396003)(39850400004)(316002)(83380400001)(2616005)(26005)(956004)(38100700002)(2906002)(6666004)(6506007)(38350700002)(52116002)(5660300002)(86362001)(66946007)(66476007)(66556008)(6486002)(4326008)(36756003)(8936002)(186003)(8676002)(1076003)(478600001)(6512007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: EwXVrtAvm77+aC6K2ze0Tx0V1eHDKP7r7Str9WRdaFzzMmfJrbIQ33BPvAIaygFxfH4PaHFRRMjstvpspfLsqFpKEvrSW4QdWSDEAkz1TRa34a/maZOTe9cBpRobkgh29EVeY0mjmJmIWRWoptAzASMbFcGBtIaA8fg5LBkPPNAm0oXXrbev/3e4WbZA8EL0w9MddXfvwHxdHrQxkSBzR6vGBEafa8UqC29LmtKjwF92zm1eeAzRpfNW2BeNdAtogFI8hta019/DKxaHAGAW8BI/KOl/jRlfbcrv2vAL1qNT53UmlmiAWh4lcwi5QizytP5MseXT5TtpJJYgIE4QNI8yOFJzVMOZYS6L681l8JtV1ZkpJ6aZh/LpePpPYPQK2ANGdPo23nzOxO3G7KdviBP/MNNtJl2GKiGjD5lOJnnc/fkyrI/EUm3eVzJaV8KC7K/fqwkSW01uOCTVbAzVldra0R7Vty8VicDg8Mr0dOMNNJG49GPVloPMxBDS45tZPz2tmOxurmRcR2HeYR/l8G/tgHolHptT2V66jxmYbiCACMwb/WT1FmEMZCFTCLd47EoN0zTRaCQWcqBAz75YoaG3gxvOoqmEa/wsjvLPOavFus9/iLGpEJrWNaoKwuXgSY/MhclPdYEldDJkXrzHkxvRuTAHQ/vrbd3ZDWa0HE3sHVGgr0DmVD6/hiXdHQyvvKe2H8YCR5UXJz8iLi+9KMKYHQu6eqWpkNGIqAwn4Ira1Ky4OcyQ0LtJvjCsCCvGFSJseFz2fY3uDh9RDHXvI+ptlkE2hsEFRm8I4+ss0LDYX7H61aW+c9bkXRCENbQ/pYJZ0VciiIaLdbmMJvQn01f20U+KctgMMHr0CeShB53649J4xR76RLJ0rZi3Xal5xF3nSTnB7OdFPw8e3YR4zyqRt6D9d0nfNMvLBfI6pSdM6qjUPCUwKDBiKE2gbSRxdIYn3Ge34Uf89/mXRQyVf4x5iZ6lEZGdVDSV6O6Gtj5scsuoTWgksqattQhhTpWG802EJU7GDaEtnLDBOHsvSheKs3238XpjMhmItNb2ZFoAbaftv2lX4gV0EuwZ7Mf8uX+pX2K6KZdlPVMpUPtPL/SjBZHelkUwKxM88DJuvq1ZFkfu2MatgaXLZLmg8PYl6JKQ05kVAqcTwIgMvUxi2ZAvZTtzcCE18gVtLwhlavlYJOhLWZNqtMLi9lqCZSfydyr+F0KnNfLvYgaBsxjvAFPTA5Bz6/KLceVLQ0ie3BOctcxzpWlDRCvTwPaE8R9aS3HQnv9Yz/+xk5XMEOk6wGAcQ+Vp6LSUIqsKE3KB1NgscI//nu5CEJ/tHIMZnZSu X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6b8ee3d9-6deb-4b22-f99a-08d9482c670c X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB5623.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jul 2021 07:36:19.6029 (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: 4z9q0MzDfMNrhqPDM8pzM72j/A0UXRVXuFxd8eO1xhaGGYuyEpqpWNWNdAyeNe2MIhLjiVSMHYKr4oxaMr4dIQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR04MB6997 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210716_003621_365334_2DB11B30 X-CRM114-Status: GOOD ( 15.28 ) X-BeenThere: linux-i3c@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-i3c" Errors-To: linux-i3c-bounces+linux-i3c=archiver.kernel.org@lists.infradead.org When i3c controller reads data from slave device, slave device can stop returning data with an ACK after any byte. Add this support for svc i3c controller. Otherwise, it will go TIMEOUT error path when the slave device ends the read operation early. Signed-off-by: Clark Wang --- V2: No change. --- drivers/i3c/master/svc-i3c-master.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c index 47c02a60cf62..91358cc5ca07 100644 --- a/drivers/i3c/master/svc-i3c-master.c +++ b/drivers/i3c/master/svc-i3c-master.c @@ -869,7 +869,7 @@ static int svc_i3c_master_read(struct svc_i3c_master *master, u8 *in, unsigned int len) { int offset = 0, i, ret; - u32 mdctrl; + u32 mdctrl, mstatus; while (offset < len) { unsigned int count; @@ -878,8 +878,15 @@ static int svc_i3c_master_read(struct svc_i3c_master *master, mdctrl, !(mdctrl & SVC_I3C_MDATACTRL_RXEMPTY), 0, 1000); - if (ret) - return ret; + if (ret) { + ret = readl_poll_timeout(master->regs + SVC_I3C_MSTATUS, + mstatus, SVC_I3C_MSTATUS_COMPLETE(mstatus), + 0, 1000); + if (ret) + return ret; + else + return offset; + } count = SVC_I3C_MDATACTRL_RXCOUNT(mdctrl); for (i = 0; i < count; i++) @@ -888,7 +895,7 @@ static int svc_i3c_master_read(struct svc_i3c_master *master, offset += count; } - return 0; + return offset; } static int svc_i3c_master_write(struct svc_i3c_master *master, @@ -921,7 +928,7 @@ static int svc_i3c_master_write(struct svc_i3c_master *master, static int svc_i3c_master_xfer(struct svc_i3c_master *master, bool rnw, unsigned int xfer_type, u8 addr, u8 *in, const u8 *out, unsigned int xfer_len, - unsigned int read_len, bool continued) + unsigned int *read_len, bool continued) { u32 reg; int ret; @@ -931,7 +938,7 @@ static int svc_i3c_master_xfer(struct svc_i3c_master *master, SVC_I3C_MCTRL_IBIRESP_NACK | SVC_I3C_MCTRL_DIR(rnw) | SVC_I3C_MCTRL_ADDR(addr) | - SVC_I3C_MCTRL_RDTERM(read_len), + SVC_I3C_MCTRL_RDTERM(*read_len), master->regs + SVC_I3C_MCTRL); ret = readl_poll_timeout(master->regs + SVC_I3C_MSTATUS, reg, @@ -943,8 +950,10 @@ static int svc_i3c_master_xfer(struct svc_i3c_master *master, ret = svc_i3c_master_read(master, in, xfer_len); else ret = svc_i3c_master_write(master, out, xfer_len); - if (ret) + if (ret < 0) goto emit_stop; + if (rnw) + *read_len = ret; ret = readl_poll_timeout(master->regs + SVC_I3C_MSTATUS, reg, SVC_I3C_MSTATUS_COMPLETE(reg), 0, 1000); @@ -1016,7 +1025,7 @@ static void svc_i3c_master_start_xfer_locked(struct svc_i3c_master *master) ret = svc_i3c_master_xfer(master, cmd->rnw, xfer->type, cmd->addr, cmd->in, cmd->out, - cmd->len, cmd->read_len, + cmd->len, &cmd->read_len, cmd->continued); if (ret) break; @@ -1145,6 +1154,9 @@ static int svc_i3c_master_send_direct_ccc_cmd(struct svc_i3c_master *master, if (!wait_for_completion_timeout(&xfer->comp, msecs_to_jiffies(1000))) svc_i3c_master_dequeue_xfer(master, xfer); + if (cmd->read_len != xfer_len) + ccc->dests[0].payload.len = cmd->read_len; + ret = xfer->ret; svc_i3c_master_free_xfer(xfer); From patchwork Fri Jul 16 07:37:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Clark Wang X-Patchwork-Id: 12381557 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.4 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,URIBL_BLOCKED,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 E7005C12002 for ; Fri, 16 Jul 2021 07:36:28 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 AFF2F613F0 for ; Fri, 16 Jul 2021 07:36:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AFF2F613F0 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-i3c-bounces+linux-i3c=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; 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=k3+Lv+6z3LZZXZBQIWZGhw9l5+pHKdyov9fRa1vJGeM=; b=ACZvqFE2EOJZNY s1Cj2KVllrbR6IZNABeG62SJ/Zx2ULqkW3Y8leAs4/Fm+6ajORTA5q4YV5z1tjGvvltC1OGf6bZ9k xCsCZ63+DMw5an6UNUdajNJ6z58GDwSGlm4D0hNawY2ZG07Js/JHiuvdwyC7AsWE/N9Qej0MtVDki ufH4JtTqoGh7ajzuX6FXnb0ZphoeOrXkzOWFNgbQGHO/fTPfnIzHs0lKf3ZbiuE3ByM+yyMPgpXD8 sZMlemQONXPbWuLokibQEsn91l7ymZGT85xhuSy3utLj6bhx6/oUUwJb1dPfwPh6avKmrxz9R4mVj Z9ZNr8y2352st79geRJg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m4IOa-003XuI-8E; Fri, 16 Jul 2021 07:36:28 +0000 Received: from mail-eopbgr60089.outbound.protection.outlook.com ([40.107.6.89] helo=EUR04-DB3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m4IOX-003XsB-SN for linux-i3c@lists.infradead.org; Fri, 16 Jul 2021 07:36:27 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=H1NDRf5zuEU9W9DPWW71dkcfrbRB9GakA/fzmDPacZxZ0GfB0RmC1VymtIXvV+wPHFGKQrJWMRa1FrgB4Yx8ybQseR5CfVpUo6MCX4PHJP2jDaOeQnt547ndMlfyP+F4Wwk0od9zqQ6eXwT3Hv47QfiU8ceZikjHCo7nnwuTvkp2SLy6i1W8ogbeSsXIE0qzqmzVhoHcUk9OGWAwDfEBOBX9Fs+0ek1ZZH76Hw9tWewwhhX6wbNJBGJkW/rQV9XIsz87aFm4lJp3JtAqbINgXIW6tLGsEDgXFfSNIQEuG6Mx89AaSzMv3IJi+K+5wqOusd11xzCv4ADF37xY8qxIqg== 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=51AyBAN9vBpW76g8MjCYD5e6O+JsF6fl375MG0evAac=; b=BV3iKK9fl5n0Nc894DfIBV9O01UAVLF7Pi1AEErfUFii+7sK/NadXuz3tf6rr15G1Z6PWcnDcewvNHCyqO0pkH/XNqUSL0j7q/YkD7URficPnaeK39lyE8oU1WShnj4sg6lvnlGPs3IJNk2gllgz/AtH9RMEUTwBp9Nhr3sod93KQHAg7eF0sCDkwnLDYVnHR1NK81e3WJ1CEo0Cn2dxqtaU4Mg4v4VmARCinA4jPnSlHZQB3f2ksVsQJa/E2gXDho5pWFlx4GIbDOmf9fBsjVInXsUSvLmG4QKhvGhmhxIyKWYJMtY0ceKlWfVREyuK3SccqYxm11C2IybE4UHbOQ== 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=51AyBAN9vBpW76g8MjCYD5e6O+JsF6fl375MG0evAac=; b=K8VqzrOIjWk83Bg7ylttG5a92Td6Q0FudZiSjOt8XEMVhpycCp8lcRCAvH+c6cA241EdXD0+qQHKSUai7C/JTCYtPSzGJoN/0udhP3/8+S2muv2eQrLQRYvKWE+4M5TzmUPwQ+5NB+XLYJng51NBEdCdXQrytY8Ju5fCDd9kf0s= Authentication-Results: bootlin.com; dkim=none (message not signed) header.d=none;bootlin.com; dmarc=none action=none header.from=nxp.com; Received: from AM6PR04MB5623.eurprd04.prod.outlook.com (2603:10a6:20b:a9::13) by AM6PR04MB4759.eurprd04.prod.outlook.com (2603:10a6:20b:9::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.23; Fri, 16 Jul 2021 07:36:22 +0000 Received: from AM6PR04MB5623.eurprd04.prod.outlook.com ([fe80::74f8:10b:8efd:b265]) by AM6PR04MB5623.eurprd04.prod.outlook.com ([fe80::74f8:10b:8efd:b265%5]) with mapi id 15.20.4308.027; Fri, 16 Jul 2021 07:36:22 +0000 From: Clark Wang To: miquel.raynal@bootlin.com, conor.culhane@silvaco.com, alexandre.belloni@bootlin.com Cc: linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org, xiaoning.wang@nxp.com Subject: [PATCH V2 4/5] i3c: master: svc: set ODSTOP to let I2C device see the STOP signal Date: Fri, 16 Jul 2021 15:37:22 +0800 Message-Id: <20210716073723.3490180-5-xiaoning.wang@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210716073723.3490180-1-xiaoning.wang@nxp.com> References: <20210716073723.3490180-1-xiaoning.wang@nxp.com> X-ClientProxiedBy: SG2PR02CA0005.apcprd02.prod.outlook.com (2603:1096:3:17::17) To AM6PR04MB5623.eurprd04.prod.outlook.com (2603:10a6:20b:a9::13) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (119.31.174.71) by SG2PR02CA0005.apcprd02.prod.outlook.com (2603:1096:3:17::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21 via Frontend Transport; Fri, 16 Jul 2021 07:36:20 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 92cc5143-a929-48b4-bad6-08d9482c689f X-MS-TrafficTypeDiagnostic: AM6PR04MB4759: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1148; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yGYzIIBwoM46dvNBM7xBpcSFsjRQywWW+ZrnqTRbr7Wk7M7Ub1Bc6huZhV4R5W2TJH47FhRDjAGTE7AL8o+Hc/4FqV+9i4x70hSX1wnW0UWwIDrnFQHQLzm3y/yNWQmt2YjXbEm7O6BF0+V60LLor3X5EHK7LZBaUkUKU421aDbXzbOthkJh2hr4ZxobQP9y4cc+tSWqIGJq5M0bjnXNV7gszqIqnYZE79h9Wy2r9BBfkBe8S7IMMMv6ie10+xnAD4kMs9xrsUyJcAMW3l/RnKsCNM4wCvwSJfRusK9y4L3JECEB8cbbhKR4KqJKeRSGBBo7lbaLx6Ji0bjKtqk1ED82cYbSlElm2ISXS6zxNfzO8OLfj5VyNH/uhB3L5gLFpck/mTKXlDXIiFn4jccLXJDOdmXUsZ3bB7DxPkgRZi3pzd8Y/ex/Kqm80XjU9WFFY06Ls0NktoF7ABjlS6qOq5jI2VbkcU0xEsFmeTWFSJ3uE+smj1btbioQK2Eg74eWGlqvezUSkLUa/VQU90m0FShSTYYSghr8P6j6rvqtaEnYXQ+hW7mmqljTHvWIPLYmEl7oBkPChNoh7Q9JJs7gykFTyhyHBwXzJZVmgU7NjboQb/7buW0td1d+hoMuOO+URjf1IctGK23uv1c2pRHvdEZMIWToKlSHOVvP9mYKeE40SMhL82rX4QTsA+2IlXHsfDUhohmOKYa47ccPjgk7sg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR04MB5623.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(346002)(366004)(136003)(39860400002)(376002)(396003)(2906002)(478600001)(2616005)(26005)(956004)(38100700002)(83380400001)(38350700002)(6512007)(4326008)(86362001)(52116002)(66946007)(5660300002)(6506007)(36756003)(316002)(186003)(1076003)(8936002)(66556008)(66476007)(8676002)(6486002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: WGxlZgSKCy4/9HkobHkgvvFnKVu+03W3NXC0PcmqNFib2w/DRsuecle1fTCcJOfdQVDW9PojwFu8FAwFNZYu6K8UY6HrVepJO6a6w4EUt7DWRFIl3g1WZ06La2HUDa2MfxQYA5IrjZvey4jdMC1R5Uc/ubV98FgOn9Zo9hEIWvtljZCJnAAMXyMH2/GxvngONMdU6m+FLHWgd+xfBHs+D12QvXZ0RcrQuEqneP/r4K4577LXb51lIniZJP6ozlbNpRoJJ+92uaqUd6lawkjaoy4nA0pU7FWwoThYEtRXE+NDjHnaJIp3iei+FUIMR5vxBk9kohbzOt6Bw6StsHWr1phh2JZOI7AJa9Q8UKDPY3RdrRAYT8Rur7eOUd7drJ6QyLlQH6Pr4BbaF0feXuljxLruqJ0GMh1oJk6bhwVzcYxmsytMtZ5mvdSVRnS2Uh5MV4xPBBmJNiZN/9FdQVld6aCnCnAmRqaCrERbGN4ClZ5rKBp/KWCl7y0viVmdbS2cbCLsKkTvGDzbuwUFQlPkVx5OhxLU+tmamBlDDkhSov5JD2ZnigzHf/0So8jN9ELS6OEAI8t+XxcTRTuUgCkF1x6c0KwAZJ8EHxQPFx91wIrgOS0VXmeNztcZtCvEcHztC4xN+Fbyzi5LvDYfjqUH2q9Flm0o0d7ZSBND8RfA8bxLefwdtRdQdTiGooDiSaGNkxhQxqwwBaxu4RapNOKxiAzbJR7BE8VWmGokVXhxM5FJp5o/B1eFN6vWFmiX717uTXoMK0dBhxnfLOLmgWvR3jBvHVQzHiWEVemRPedRHpUiCmAsT32VYjqLIai91iWDOQX8+jvMzddF6u9b7M35hpGCcAfhMd9lMK3aSPdeBOEf+zhbwrCCXgoOs1BaVz+1e0JKJKm/Py2rHhqUkv9eqnRk9Vt7q9IzFq50kD7TtrO/6Aw7eRnqK1no9mXltpk2rm8vRpe4OyHGpB+b9y0Dga/4oGmbAfBmQiSiaZbjsJnlAsyToi7NBzrG3vQtlUaug/TCDcyD8aeBQH02hF1R6yWd5QB41O/N35M8Hjn2JHdkI7UIjIQFkO6/hiQNfCrTc8pJsIi7oCaVoACYWJdwE0IjFG3YuJDDYL0hXZbXcsIvt7QfYi7vfp5AUo9K9UlymUtTDonF9i6U1/g+m1kZaFxEY3zWB1gIRqYoGZpKpAUVMSKQRfEdo7ejv5J69b6w3CwPTUnIRxCP86S34EkEh3CDJ6ZDmFqhzuW0NH8jHY6brkBCaqpgz0e8J4eVexmWoJ8h7PD8slBSrxwnHsg+PAeO6dJLgsPqlQJ2pX0Vups5ZPeIn50qrcjIC/iARfSc X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 92cc5143-a929-48b4-bad6-08d9482c689f X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB5623.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jul 2021 07:36:22.2754 (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: 4RWMX7I2/Ba9FiCbZ6ZN6lmEPlHKj2PvGjl+aOt0vbB4orizArGoxDasrFyBq0cYJqn3QStelneZEOwvWzVQ4w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR04MB4759 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210716_003625_959636_8813E1BB X-CRM114-Status: GOOD ( 11.87 ) X-BeenThere: linux-i3c@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-i3c" Errors-To: linux-i3c-bounces+linux-i3c=archiver.kernel.org@lists.infradead.org If using I2C/I3C mixed mode, need to set ODSTOP. Otherwise, the I2C devices cannot see the stop signal. It may cause message sending errors. Signed-off-by: Clark Wang Reviewed-by: Miquel Raynal --- V2: No change. --- drivers/i3c/master/svc-i3c-master.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c index 91358cc5ca07..5677b5b31a86 100644 --- a/drivers/i3c/master/svc-i3c-master.c +++ b/drivers/i3c/master/svc-i3c-master.c @@ -449,7 +449,7 @@ static int svc_i3c_master_bus_init(struct i3c_master_controller *m) struct i3c_device_info info = {}; unsigned long fclk_rate, fclk_period_ns; unsigned int high_period_ns, od_low_period_ns; - u32 ppbaud, pplow, odhpp, odbaud, i2cbaud, reg; + u32 ppbaud, pplow, odhpp, odbaud, odstop, i2cbaud, reg; int ret; /* Timings derivation */ @@ -479,6 +479,7 @@ static int svc_i3c_master_bus_init(struct i3c_master_controller *m) switch (bus->mode) { case I3C_BUS_MODE_PURE: i2cbaud = 0; + odstop = 0; break; case I3C_BUS_MODE_MIXED_FAST: case I3C_BUS_MODE_MIXED_LIMITED: @@ -487,6 +488,7 @@ static int svc_i3c_master_bus_init(struct i3c_master_controller *m) * between the high and low period does not really matter. */ i2cbaud = DIV_ROUND_UP(1000, od_low_period_ns) - 2; + odstop = 1; break; case I3C_BUS_MODE_MIXED_SLOW: /* @@ -494,6 +496,7 @@ static int svc_i3c_master_bus_init(struct i3c_master_controller *m) * constraints as the FM+ mode. */ i2cbaud = DIV_ROUND_UP(2500, od_low_period_ns) - 2; + odstop = 1; break; default: return -EINVAL; @@ -502,7 +505,7 @@ static int svc_i3c_master_bus_init(struct i3c_master_controller *m) reg = SVC_I3C_MCONFIG_MASTER_EN | SVC_I3C_MCONFIG_DISTO(0) | SVC_I3C_MCONFIG_HKEEP(0) | - SVC_I3C_MCONFIG_ODSTOP(0) | + SVC_I3C_MCONFIG_ODSTOP(odstop) | SVC_I3C_MCONFIG_PPBAUD(ppbaud) | SVC_I3C_MCONFIG_PPLOW(pplow) | SVC_I3C_MCONFIG_ODBAUD(odbaud) | From patchwork Fri Jul 16 07:37:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Clark Wang X-Patchwork-Id: 12381559 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.4 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,URIBL_BLOCKED,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 37755C636CB for ; Fri, 16 Jul 2021 07:36:32 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 F1EF2613F0 for ; Fri, 16 Jul 2021 07:36:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F1EF2613F0 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-i3c-bounces+linux-i3c=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; 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=XAzQHB0hN1NMmoiC96S1rrKFcHx6sDRQYRDbXjbeaV0=; b=PavFHSybWYqo9g YAhnYDidNF2P0JM+Mzrg6zt9gBkVTwFg/ZQOC4niHgv3PKNp+1qF2Cengsaiguoat68pNSx594deL 33Jfo1d103RnsmOPlY3ODh0CFQltjFaN/dR1X5w9pvAlc2OKsCdURtzcYRW6LhD0l1jxPjgt43iQu kN9h+qM18CU9MNxk9TE07Tmi2xwB8hRje5LivF74y33PqmNUPhvq+M1svfR3DpWf0DYW2VTYeWCav EVfUHoxQQtZSVbFk/0y9tK/RNyg2mWE/5Ir7QAZuVw/OwuBQCASiw0UYwOeqR96aoLiZvKIEPzWJu JFyBrp71/E89M4pzsyVg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m4IOd-003Xvh-H3; Fri, 16 Jul 2021 07:36:31 +0000 Received: from mail-eopbgr60089.outbound.protection.outlook.com ([40.107.6.89] helo=EUR04-DB3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m4IOZ-003XsB-Lc for linux-i3c@lists.infradead.org; Fri, 16 Jul 2021 07:36:29 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Aw1TggkVTQrB4chzA9NQLPwOZLmqLn/VxW/v5Y9FYW1MoR2bU8+3r0vtBNjt0Gh1YxiVIqJ/+Eg+NRAdxQ0qXwPOhTSWJPmv/y3WtIBRy1jNtNfKC5FJjVimDxN6HB6HMpH/vVGcBJCHU4g3SJhZCTbgEj8rnjSVqV+pJZIKAYISk41armm7gRgUvvr2xKw0s2sMMi1Ur23O717tcJ2ogC4Qb7fPwTcjkqjxppk/Mrg/T1weTYxv9e8ladWDY4hqYEvPdXQrQnBt8wz1EU6rXNbd9thPu4UbahmEA5dJh9tPq4CnzpWIl523QpjYMGHJAgzoVd6wifZLWWwu2BWqrQ== 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=ex61z4+dS/EYPkf2zLPzijY3av/+xdkbW5k5C6OiFP8=; b=g5rybxWPiFrlfNKKrfmU8Q9N067/TvsSFyL2KJpLuqU2/vSPj8hi0gUDLp3HaEze6aJ0+ZjvJKIDRd0RxY3u3BHVPv0+qX3aeBBZi+zE3F5NUXyVTqCn0UBrQGSRj3Q75w5DqG/38ojd4glxiti6v420DMkBzyTsbiJF0YLPf1TVYhTd+ynimhq54ChzVsBNlj14WFAX7WjV//L2yHd+ZbMZDtYCPOeV0PyVWOGWqxX5nWod4o1KDWWdGqSFLGED5RkrjodTOfS/bgv3c7cSJNngAbN4bC4lvGQJgI3mRLySGfui200kOR9eTYXy8vF8Pvg8R3hveupLc5p9ttxGDw== 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=ex61z4+dS/EYPkf2zLPzijY3av/+xdkbW5k5C6OiFP8=; b=kXtCBC2Way6Iu0Qql8oAtIqHJnx9vs98X0hsFdHvM//Pum5cWloAB/ELFnxqab186tXFAB1WHGtKvSBOndpO7WPQKfw/G7Tvn7WElqMpifU6G0aEwIjhKh1MkFMmXRyu+JuTQ036YckjDHI2nhYTLQZXqS83TpL56xiHm7mmVkY= Authentication-Results: bootlin.com; dkim=none (message not signed) header.d=none;bootlin.com; dmarc=none action=none header.from=nxp.com; Received: from AM6PR04MB5623.eurprd04.prod.outlook.com (2603:10a6:20b:a9::13) by AM6PR04MB4759.eurprd04.prod.outlook.com (2603:10a6:20b:9::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.23; Fri, 16 Jul 2021 07:36:25 +0000 Received: from AM6PR04MB5623.eurprd04.prod.outlook.com ([fe80::74f8:10b:8efd:b265]) by AM6PR04MB5623.eurprd04.prod.outlook.com ([fe80::74f8:10b:8efd:b265%5]) with mapi id 15.20.4308.027; Fri, 16 Jul 2021 07:36:25 +0000 From: Clark Wang To: miquel.raynal@bootlin.com, conor.culhane@silvaco.com, alexandre.belloni@bootlin.com Cc: linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org, xiaoning.wang@nxp.com Subject: [PATCH V2 5/5] i3c: master: svc: add runtime pm support Date: Fri, 16 Jul 2021 15:37:23 +0800 Message-Id: <20210716073723.3490180-6-xiaoning.wang@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210716073723.3490180-1-xiaoning.wang@nxp.com> References: <20210716073723.3490180-1-xiaoning.wang@nxp.com> X-ClientProxiedBy: SG2PR02CA0005.apcprd02.prod.outlook.com (2603:1096:3:17::17) To AM6PR04MB5623.eurprd04.prod.outlook.com (2603:10a6:20b:a9::13) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (119.31.174.71) by SG2PR02CA0005.apcprd02.prod.outlook.com (2603:1096:3:17::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21 via Frontend Transport; Fri, 16 Jul 2021 07:36:22 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4925ac8f-7575-45f8-a791-08d9482c6a30 X-MS-TrafficTypeDiagnostic: AM6PR04MB4759: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:324; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lFmcC7w9/cdg3jGsTY3qU+OaspeYAw1RsPX5gM5gkbh2mHHZUTLiEsdF9/SRV6g6o54yOU2zjaXX+0DVsM/XRIoTiUtP/KSbBqY34WFJX0Vazn8uB/wuoXPoUwL67a2RBOnQ7uk8tGp2WQiw9PbXnYnNWLNpVlpHj9fhAIzvsb6hwtzrL6U0QtTfkYaViNQDwF0PLH6zYEPq1hPo3hlECbuzxp2KrHHkZhNVFizVC8eW5T/XhEHpItSyOh4/CrUWB51klZ4whHVhfg1b1Lk9eKSiAQ6l0YJr120Aktyo17opWoJvt1NuEu+7uOyAO5wY1AUR72Y2jYaiTogOw7tQbhQtbkcn0lMu/d5R8bHBy0KfcfTK/wnOnNivLzuFY6U/Qpsaip1+dCbuy9fsmUqR3Zc1Hs6QqdO6KAdo/YWOtrJxaILzLotLyUdEaWJfCb71Q5FIrXfM/5a11PagQV+PZos0RJml5xXk69EyLS/XKUgEpGhfZyYo1MDLvd8Gkls0AyMwfD0BAHK8HHEV3hwkVSZw8GQMCPi1Lt2jslfv1nq7q/Sl7En810C6iAROssAF88A+qgVfDasF6ibe5+HGC8umGNnhrqs53TfPG86Q0i5CYM9Cr7VISOwcK9LnJuWWPqgqX9MqYmRnAYRDpVT1HLzZbab2mttlYMiUWA1icp1/Da85Fo1vdnnePPR08nj/vWUEELUFFsu0JoyeQ1DojA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR04MB5623.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(346002)(366004)(136003)(39860400002)(376002)(396003)(2906002)(478600001)(2616005)(26005)(956004)(38100700002)(83380400001)(38350700002)(6512007)(4326008)(86362001)(52116002)(66946007)(5660300002)(6506007)(36756003)(316002)(186003)(1076003)(8936002)(66556008)(66476007)(8676002)(6486002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: GPusDYmPlAHAeS+K7XZpMrvx/4OMAFVlKxTvlKeJHKeMeLloR1UWAMSSEIbrKuQTSFGaJTaiZ23PUCBwuL3lUXIL8EBxBFs1Q4/X7pftAx73TPiEVtvrusKQuj5RvyyZoa/cz90SpkVJUfKDZ+TZiPcMeO746oCAOjgevJVijGuu/2MxovihoUQk6eguU5RMuRsdF2x287GhRctn1znz/NNXC+Fxn7TfW3YzhsK5V7iCs61DtvEPYlkTdt5ij//ry5IZxXGFavugKbdLrCd7U4Ih+/OswKWfyW1V4SQpVQUg2EGTwegfQsEEFs/qCdUutTo6+1dobF3DXmst6aBICojYIA8zO1SfVjXLJn7kioAmNol6B49T5Qap+YpCoApPzZWYrht44Ec1fJYt5Sxzg+zpP/nB3vZUd//Hb3VtzRjxS/Iw3ObPBSr//jzxLtZiM9bJAm2EX0LPorqUpCKb+ZgrH1v9+HsWTD1SqzktchfUDJQWHu1pyqdbq43aCsiBf0HHGhHr63rn9C3cPwbTIuzKHt5GIaWmPlnr5DJ2qV1tI+bOCP6JXTQt5c9y2jg9aND4pD3+cyRsDEJ456CRUtfIznJdOMWsvFk0bzCCXNE+8hB59Mjk/DPBNJ/K0RAdwTaJ3rICIdV7rosd96qjGiS5soMCYXSMxWMd/b88ZEuHyGwY+fZ9fBLg4phFRNAZYgA+9HTkSWw4Iwb7avninu3Pq0A/yqXYQyOUBJm1bbrQ3nZwKJUmf4Nrlorgg+Q01DDBzzlATQyjXJbwdW0T+1V+6NmHdSirAPJFjdXMCmIZynygduDRxjYRBi0Z56nVGK5Uc0nkZuJvG4nFkB8gnIQXpQWjCyLG2zL3S0DWzsXEULTwbEpIfzXA6SSWYlojwecThJlBZ1B87w6DwsRJiOuKBKDr3FSPKNv4cf5ZpaQFDHQyfPY1vZDmUBMWqbIemHiolxxSMPiQnJMoMtwpGIKnLJpF9eLH+h7kZYEKEVqiegZhb8QJSEHPXkvwvqWvr7b8bBRSAuYa1+yuvcvUhSAu3m6bq2RXXVw5/y1191rxFV1NZVCyRiFoR2dkuQIlupeCoSezOAckMhGd87NbeOIKyAF22nqjM7pZHKJLo7K0SHldNM8x3xsVE6v4snc+kHxWcnYSyPvvUBDf9tFexB/GeN8rKoT5O/20sSJwJEdvc6pb/LD6KHGdXrcDRBkEzAs0K2N5QvTbwkytqpNl5An3/8WI4BEDb3ZjMRQYrYl8GUD1gNSsYYxacS2mqvKkGbbAD0RuFqPZn/cGw6/Dviu9rVZZDky4/7ZMad/G/ck6yJFjqS9ZVQ7D5dqOeJya X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4925ac8f-7575-45f8-a791-08d9482c6a30 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB5623.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jul 2021 07:36:24.9838 (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: Gq0+dgXpdz8bRQ7PKz6n05FiiB0Xt+UTHA9iaJP0oh7GFI12xttxrDahL+1U/dhDf7j7XAhizo9WkQCqDBduvg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR04MB4759 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210716_003627_884878_D55A42D8 X-CRM114-Status: GOOD ( 18.48 ) X-BeenThere: linux-i3c@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-i3c" Errors-To: linux-i3c-bounces+linux-i3c=archiver.kernel.org@lists.infradead.org Add runtime pm support to dynamically manage the clock. Signed-off-by: Clark Wang --- V2: New patch in V2. --- drivers/i3c/master/svc-i3c-master.c | 169 +++++++++++++++++++++++----- 1 file changed, 142 insertions(+), 27 deletions(-) diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c index 5677b5b31a86..4c264750cfc6 100644 --- a/drivers/i3c/master/svc-i3c-master.c +++ b/drivers/i3c/master/svc-i3c-master.c @@ -17,7 +17,9 @@ #include #include #include +#include #include +#include /* Master Mode Registers */ #define SVC_I3C_MCONFIG 0x000 @@ -119,6 +121,7 @@ #define SVC_MDYNADDR_ADDR(x) FIELD_PREP(GENMASK(7, 1), (x)) #define SVC_I3C_MAX_DEVS 32 +#define SVC_I3C_PM_TIMEOUT_MS 1000 /* This parameter depends on the implementation and may be tuned */ #define SVC_I3C_FIFO_SIZE 16 @@ -452,10 +455,18 @@ static int svc_i3c_master_bus_init(struct i3c_master_controller *m) u32 ppbaud, pplow, odhpp, odbaud, odstop, i2cbaud, reg; int ret; + ret = pm_runtime_resume_and_get(master->dev); + if (ret < 0) { + dev_err(master->dev, "<%s> Cannot get runtime PM.\n", __func__); + return ret; + } + /* Timings derivation */ fclk_rate = clk_get_rate(master->fclk); - if (!fclk_rate) - return -EINVAL; + if (!fclk_rate) { + ret = -EINVAL; + goto rpm_out; + } fclk_period_ns = DIV_ROUND_UP(1000000000, fclk_rate); @@ -499,7 +510,7 @@ static int svc_i3c_master_bus_init(struct i3c_master_controller *m) odstop = 1; break; default: - return -EINVAL; + goto rpm_out; } reg = SVC_I3C_MCONFIG_MASTER_EN | @@ -517,7 +528,7 @@ static int svc_i3c_master_bus_init(struct i3c_master_controller *m) /* Master core's registration */ ret = i3c_master_get_free_addr(m, 0); if (ret < 0) - return ret; + goto rpm_out; info.dyn_addr = ret; @@ -526,21 +537,35 @@ static int svc_i3c_master_bus_init(struct i3c_master_controller *m) ret = i3c_master_set_info(&master->base, &info); if (ret) - return ret; + goto rpm_out; svc_i3c_master_enable_interrupts(master, SVC_I3C_MINT_SLVSTART); - return 0; +rpm_out: + pm_runtime_mark_last_busy(master->dev); + pm_runtime_put_autosuspend(master->dev); + + return ret; } static void svc_i3c_master_bus_cleanup(struct i3c_master_controller *m) { struct svc_i3c_master *master = to_svc_i3c_master(m); + int ret; + + ret = pm_runtime_resume_and_get(master->dev); + if (ret < 0) { + dev_err(master->dev, "<%s> Cannot get runtime PM.\n", __func__); + return; + } svc_i3c_master_disable_interrupts(master); /* Disable master */ writel(0, master->regs + SVC_I3C_MCONFIG); + + pm_runtime_mark_last_busy(master->dev); + pm_runtime_put_autosuspend(master->dev); } static int svc_i3c_master_reserve_slot(struct svc_i3c_master *master) @@ -839,6 +864,12 @@ static int svc_i3c_master_do_daa(struct i3c_master_controller *m) unsigned int dev_nb; int ret, i; + ret = pm_runtime_resume_and_get(master->dev); + if (ret < 0) { + dev_err(master->dev, "<%s> Cannot get runtime PM.\n", __func__); + return ret; + } + spin_lock_irqsave(&master->xferqueue.lock, flags); ret = svc_i3c_master_do_daa_locked(master, addrs, &dev_nb); spin_unlock_irqrestore(&master->xferqueue.lock, flags); @@ -849,22 +880,24 @@ static int svc_i3c_master_do_daa(struct i3c_master_controller *m) for (i = 0; i < dev_nb; i++) { ret = i3c_master_add_i3c_dev_locked(m, addrs[i]); if (ret) - return ret; + goto rpm_out; } /* Configure IBI auto-rules */ ret = svc_i3c_update_ibirules(master); - if (ret) { + if (ret) dev_err(master->dev, "Cannot handle such a list of devices"); - return ret; - } - return 0; + goto rpm_out; emit_stop: svc_i3c_master_emit_stop(master); svc_i3c_master_clear_merrwarn(master); +rpm_out: + pm_runtime_mark_last_busy(master->dev); + pm_runtime_put_autosuspend(master->dev); + return ret; } @@ -936,6 +969,12 @@ static int svc_i3c_master_xfer(struct svc_i3c_master *master, u32 reg; int ret; + ret = pm_runtime_resume_and_get(master->dev); + if (ret < 0) { + dev_err(master->dev, "<%s> Cannot get runtime PM.\n", __func__); + return ret; + } + writel(SVC_I3C_MCTRL_REQUEST_START_ADDR | xfer_type | SVC_I3C_MCTRL_IBIRESP_NACK | @@ -966,12 +1005,18 @@ static int svc_i3c_master_xfer(struct svc_i3c_master *master, if (!continued) svc_i3c_master_emit_stop(master); + pm_runtime_mark_last_busy(master->dev); + pm_runtime_put_autosuspend(master->dev); + return 0; emit_stop: svc_i3c_master_emit_stop(master); svc_i3c_master_clear_merrwarn(master); + pm_runtime_mark_last_busy(master->dev); + pm_runtime_put_autosuspend(master->dev); + return ret; } @@ -1310,6 +1355,14 @@ static void svc_i3c_master_free_ibi(struct i3c_dev_desc *dev) static int svc_i3c_master_enable_ibi(struct i3c_dev_desc *dev) { struct i3c_master_controller *m = i3c_dev_get_master(dev); + struct svc_i3c_master *master = to_svc_i3c_master(m); + int ret; + + ret = pm_runtime_resume_and_get(master->dev); + if (ret < 0) { + dev_err(master->dev, "<%s> Cannot get runtime PM.\n", __func__); + return ret; + } return i3c_master_enec_locked(m, dev->info.dyn_addr, I3C_CCC_EVENT_SIR); } @@ -1317,8 +1370,15 @@ static int svc_i3c_master_enable_ibi(struct i3c_dev_desc *dev) static int svc_i3c_master_disable_ibi(struct i3c_dev_desc *dev) { struct i3c_master_controller *m = i3c_dev_get_master(dev); + struct svc_i3c_master *master = to_svc_i3c_master(m); + int ret; - return i3c_master_disec_locked(m, dev->info.dyn_addr, I3C_CCC_EVENT_SIR); + ret = i3c_master_disec_locked(m, dev->info.dyn_addr, I3C_CCC_EVENT_SIR); + + pm_runtime_mark_last_busy(master->dev); + pm_runtime_put_autosuspend(master->dev); + + return ret; } static void svc_i3c_master_recycle_ibi_slot(struct i3c_dev_desc *dev, @@ -1405,19 +1465,30 @@ static int svc_i3c_master_probe(struct platform_device *pdev) return ret; ret = clk_prepare_enable(master->fclk); - if (ret) - goto err_disable_pclk; + if (ret) { + clk_disable_unprepare(master->pclk); + return ret; + } ret = clk_prepare_enable(master->sclk); - if (ret) - goto err_disable_fclk; + if (ret) { + clk_disable_unprepare(master->pclk); + clk_disable_unprepare(master->fclk); + return ret; + } + + pm_runtime_set_autosuspend_delay(&pdev->dev, SVC_I3C_PM_TIMEOUT_MS); + pm_runtime_use_autosuspend(&pdev->dev); + pm_runtime_get_noresume(&pdev->dev); + pm_runtime_set_active(&pdev->dev); + pm_runtime_enable(&pdev->dev); INIT_WORK(&master->hj_work, svc_i3c_master_hj_work); INIT_WORK(&master->ibi_work, svc_i3c_master_ibi_work); ret = devm_request_irq(dev, master->irq, svc_i3c_master_irq_handler, IRQF_NO_SUSPEND, "svc-i3c-irq", master); if (ret) - goto err_disable_sclk; + goto rpm_disable; master->free_slots = GENMASK(SVC_I3C_MAX_DEVS - 1, 0); @@ -1431,7 +1502,7 @@ static int svc_i3c_master_probe(struct platform_device *pdev) GFP_KERNEL); if (!master->ibi.slots) { ret = -ENOMEM; - goto err_disable_sclk; + goto rpm_disable; } platform_set_drvdata(pdev, master); @@ -1442,18 +1513,17 @@ static int svc_i3c_master_probe(struct platform_device *pdev) ret = i3c_master_register(&master->base, &pdev->dev, &svc_i3c_master_ops, false); if (ret) - goto err_disable_sclk; + goto rpm_disable; - return 0; - -err_disable_sclk: - clk_disable_unprepare(master->sclk); + pm_runtime_mark_last_busy(&pdev->dev); + pm_runtime_put_autosuspend(&pdev->dev); -err_disable_fclk: - clk_disable_unprepare(master->fclk); + return 0; -err_disable_pclk: - clk_disable_unprepare(master->pclk); +rpm_disable: + pm_runtime_dont_use_autosuspend(&pdev->dev); + pm_runtime_put_sync(&pdev->dev); + pm_runtime_disable(&pdev->dev); return ret; } @@ -1467,13 +1537,57 @@ static int svc_i3c_master_remove(struct platform_device *pdev) if (ret) return ret; + pm_runtime_dont_use_autosuspend(&pdev->dev); + pm_runtime_disable(&pdev->dev); + + return 0; +} + +static int __maybe_unused svc_i3c_runtime_suspend(struct device *dev) +{ + struct svc_i3c_master *master = dev_get_drvdata(dev); + clk_disable_unprepare(master->pclk); clk_disable_unprepare(master->fclk); clk_disable_unprepare(master->sclk); + pinctrl_pm_select_sleep_state(dev); return 0; } +static int __maybe_unused svc_i3c_runtime_resume(struct device *dev) +{ + struct svc_i3c_master *master = dev_get_drvdata(dev); + int ret = 0; + + pinctrl_pm_select_default_state(dev); + ret = clk_prepare_enable(master->pclk); + if (ret) + return ret; + + ret = clk_prepare_enable(master->fclk); + if (ret) { + clk_disable_unprepare(master->pclk); + return ret; + } + + ret = clk_prepare_enable(master->sclk); + if (ret) { + clk_disable_unprepare(master->pclk); + clk_disable_unprepare(master->fclk); + return ret; + } + + return ret; +} + +static const struct dev_pm_ops svc_i3c_pm_ops = { + SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, + pm_runtime_force_resume) + SET_RUNTIME_PM_OPS(svc_i3c_runtime_suspend, + svc_i3c_runtime_resume, NULL) +}; + static const struct of_device_id svc_i3c_master_of_match_tbl[] = { { .compatible = "silvaco,i3c-master" }, { /* sentinel */ }, @@ -1485,6 +1599,7 @@ static struct platform_driver svc_i3c_master = { .driver = { .name = "silvaco-i3c-master", .of_match_table = svc_i3c_master_of_match_tbl, + .pm = &svc_i3c_pm_ops, }, }; module_platform_driver(svc_i3c_master);