From patchwork Fri Jul 16 08:53:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Clark Wang X-Patchwork-Id: 12381743 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 2BB32C12002 for ; Fri, 16 Jul 2021 08:52:19 +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 E5C5C613E8 for ; Fri, 16 Jul 2021 08:52:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E5C5C613E8 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=+/T0l3xEvp54nzCnuU467360fQNhiO9jYX+MtLV8fmQ=; b=qntnWboW5HhqB4 ghHJjD+GmKSGcfviO+XbFF5xsKtIp+vRW2O8F1ilaxD0s3XcOz66IFVbYm4n3ZiVRi55czoMCqgKW Z7nvf/T9MTOl5aKsT27IwuDLOz//A+Njvn7IGAw9tudg708TNgfVl9tfyIjjhWVauF2xZHzJd8id9 0nSX4gYA3xmzUHDbn725H3+Hs4ViEsLuRCDeIFID3757SeS0Pht2r1kVPS/4HnTN0Jt9MNqJdMTcC gQlVF5o3QjE2RD6+mJ9cY6wikvy8blSfxgYuRlvWymLvBEaM9nnlA7E3aGGOpcv3XPc+SA2IW795S m8gUuIipFyUb7BB5NSHQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m4JZy-003rTu-F8; Fri, 16 Jul 2021 08:52:18 +0000 Received: from mail-eopbgr140074.outbound.protection.outlook.com ([40.107.14.74] helo=EUR01-VE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m4JZv-003rSM-3r for linux-i3c@lists.infradead.org; Fri, 16 Jul 2021 08:52:16 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VAZD69AM3HLbw3X/wt/qDEgIukECVTdex5co0FGJVWxmN3/iJF/HitVoW7Sju+jExPHBi8KfZ0F8UPfC9XSxZfmPDzK0A/c9J+5HG6ldN0ibC/BWS9a9sPsq5g1X7hCTGwVCr92rUF6ejYkUFY4AfWaevHgBr+mvOQxQ/rkEnOCJx8ti7ILb1SRbI78y0zH46ntstO4Yj5YYqpGZouyylE5BGLn0VbyjRB9yanxVHkNREcCK8GP8ti9eKvrCCSecph0XPxgRWaAWwH/B1yrzksRSxJRuHRFLr8fU3mCCXw5s5p/iQiMgJdJFyYKVc9l1luV1o6vR0/kH5YmMovkrhw== 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=JqHELfMAV1jQRtFCJqhUnZzmkjktMKYpui8R0icHono=; b=NLUyIBXPEwA4zw6Bg1OsTFm1aazkZJwx1AeN6uIg6w0RejHFmeBaoQ+rzQuGC7ejRC/dQ7cQjesGISndjGdkYSLNz/plFuKV2myRB0GKccsJpT7Rd38QjhGTKLLgH9hfAF1+UovH/jA2HtSWwPXPKnd8Blk8Qe3hukOimFMXTwCpcPKo+5JcCL/dGlt5ayAqqOoV3U2Dzz/PDu0qwFpT4oynIcGewL7SjCoLiY6nv5kdlj7zkXvSFv0nH0EQ4UZOgXiBJwaYW9SaeqgxOkGLUG4VHu9/UN4nGBEl0KmGBmgllswNFqYZwnN7LB4+gOyLvH2z/QhPYTyMaXVrsWMHZQ== 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=JqHELfMAV1jQRtFCJqhUnZzmkjktMKYpui8R0icHono=; b=iZAvWpOfDt1AJIOVmb6cXZ5BzEsBqcuYbAjIPsu1SZJS7PMuaZ4SKPTjlPllftywRUlx7nPYPGij9EWykavBtn3Gn7H+fKoroQ6q7A8vBcoBqIcVXRe9kzzgxysD8jIFBS/k0HsiksOBqpn/0vEOsiFfvNiUf94293M/FIvxKGg= 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 AM7PR04MB7142.eurprd04.prod.outlook.com (2603:10a6:20b:113::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.26; Fri, 16 Jul 2021 08:52:12 +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 08:52:07 +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 V3 1/5] i3c: master: svc: move module reset behind clk enable Date: Fri, 16 Jul 2021 16:53:13 +0800 Message-Id: <20210716085317.3572224-2-xiaoning.wang@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210716085317.3572224-1-xiaoning.wang@nxp.com> References: <20210716085317.3572224-1-xiaoning.wang@nxp.com> X-ClientProxiedBy: SG2PR04CA0158.apcprd04.prod.outlook.com (2603:1096:4::20) 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 SG2PR04CA0158.apcprd04.prod.outlook.com (2603:1096:4::20) 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 08:52:04 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1dc5e029-6a4b-41a2-7178-08d94836fd2c X-MS-TrafficTypeDiagnostic: AM7PR04MB7142: 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: R8C0lPnSDt/mUO9hQIEL2QZa0/EJfs+Zw+SHPgJeH0MrJmBBx0z5zo9s8pRRgM12VBpz3W48Wo04+vpc0PM3G+BRNIrCAUQeIy1Kzsw9POKZKECaeN99Akgis8HefW0+lp8HGosqcWXD0tqDBoBJMH77YQMpk6/n2NrhqiBJT9PXM8rmNdN9QHoLMPoW+IyVq0IXa5+xNd/VVnF6datvVzeGEGpnIREppr0wiFPq7ScWEFYP0XD4Jl/MVfZU/wbc0wKchD74eEY+clSUgBwtontb1Ocg876jal4zNRi7WQQXqDR6Tepz4V4xvHF+s0CrGfOS9ds6ezwIG9wglY/iC9FtZY18zpdcLPtyp73fAdhhucamkAbVrZ5NWEou1gUa1JidTEycOpF3fv5yxYisPEuV4aoH4V7AkeB7z3GGP8/vRAhFnoqFG6zl5jE5iDmZuOHNarYlWSl9EY9t5zhrEBL1JQ7QpWPWWybJxeh5y0kGJwvfnBVCDJpEPYhefXM2i5oDVHiMBaqarLLq3n0yjZrBJzfNZ98nMqcAKqBfSftr63v2GrkoObVO1pDCxA4gtYC6c//FhzY3TENSVRlNXafwcsGFmN3HEOJzkzvXNeGnd1oprPWn9hupiPe2WrgOo84+n4qyjF1kbkDzWGd8eb4S/9+2v5XwhWZmjaoJabYcMYL4e9oMu3RhqUyOjt6JimmZDKiM2msaMo9fCrbl3w== 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)(396003)(346002)(39850400004)(136003)(366004)(376002)(36756003)(478600001)(5660300002)(8936002)(4744005)(316002)(66556008)(66476007)(8676002)(4326008)(86362001)(6512007)(1076003)(66946007)(26005)(2616005)(956004)(6506007)(52116002)(2906002)(6486002)(6666004)(186003)(83380400001)(38350700002)(38100700002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: yJRDL0SXwAKiFvZID5ihuVyg2NW4mPIGsZx7YwWizVqmqVGC2m4NZxeISmnhwRHoiDYz0R3SIRF4SwChLalAuHssKOs5e0TvcKuBE6jWrkGUSe7/k4C5XfWT7Sqe1UKssQFVABPNKUaFmrd0mf+GX8fd2eMAaqbOgsrIGiQ/C/vTP/NAPzcvHtzaeHptu1tTrlkqbjl74bwO+XcVrYqRcJ/NO+nx4JtYRZ/bbFUbJr8yz2jWFep+Lm09t8WQv0ptQ8WPjeIGfwqZs0bMOge14y/HvBdDR9+3edAHJFHkqvYOnlbiqCKEtbzQm4fZjP3kQ+jg3qtfNcyV5a0CHSWbsk5pjntl54zylkJrWRqIc1icbVp6I81PzBnB/jgx3iNchu+HvgBrVPaM5uAU2r/OyKbw0ZZa1iM06AigVmngFyK7GGE9W8lt6QANgkmHW3QYzSv5wdUZGy7qTJ4T813VdjATfpx5sYVyi8XEPqAK+5Lrsp8imRXEoUJ+z8pXvVb5NRIahK17nLvH8M9W+YJg+8MpKDaw130RM59lWhAZJKWFb5M4tYyqlft7Fw6l9iI708MPKiBJoLIlrP04C7GO4xYS08C8OTg9vHKS9zp5hGAYzM4wq5Pts3UYsOW+GvwdCTyY98Fydw7NVVCpJXun6CL+mmjDpbkNn6ZW6fxQNOy/+JtvDf0vTQyiDjHVCP4AiIA85Ii8G4lYYbg9aPyePzuwHHNkSCoESVxf0Q7duHaB5Smh2TVuA82nW4viWwsPTuJmHEXpFNkXPJ2SvV2JpRyPRIe6Pp6YM94EsPcdeaS9P1T1pAfOGjf1LS15HJStH01FQYdzz/SU/ROjA98NlvQN2IRjy50nBNwFBAXV76z2iguzcB7eF6HT2pmjarur0zZSJNOZ6AhhK1WAZ5OCuxlc0386KiajMHIex4SgBIDz5zjhDJOGX/3s7vIvBP5iSdnkNtRBHlCbaB5Xt2+lIpVqYQ6nWRBzg5DETk6wlGoHzQiBC3zq/XV6znwkKyitfAUrPY9CWLdC/Lk1fImyctmXjpaZJWK39zkfEI8cWIuvkvh4hqDls67pC6cF6c98+11X6ntUI8YA6hzVBzawrpcdFbt6Ghk+WJLVkcBx9UHT7TU6/bAMb/sNBBMCYRTk4GtAHRfhrZbhoKcv+V2svqXMSvs+w5X/wWPEluG1iS7RP6i7N68tJFF99T+RR6rtnxCvs4ZYqdC4UVzmuoQ+MMG2BbZi3EZ/krgAzB1dFp0CGRGNC92lFFJ+lxzPc3UUErPEf26WJdcdQmhhpqOIP1pOtWKg7YD0MnsP5HW0Q3JM4SNKU3DBciAFhfghBpdV X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1dc5e029-6a4b-41a2-7178-08d94836fd2c X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB5623.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jul 2021 08:52:07.0513 (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: yPa5EDi53OzUq+3rAMvn0m/KWulNbyZ4TM4gfeY9AO0oXmEYjNXZPWyhYwRZHeQHezwGG2bHziGI107MEytZ2A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR04MB7142 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210716_015215_203510_83608AF4 X-CRM114-Status: GOOD ( 10.36 ) 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/V3: 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 08:53:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Clark Wang X-Patchwork-Id: 12381745 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=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 95C85C636CB for ; Fri, 16 Jul 2021 08:52:19 +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 3D3F061404 for ; Fri, 16 Jul 2021 08:52:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3D3F061404 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=FicxAXLlS3lDUdw1+inyLRLUmhoLyBtJYRky1gfQymE=; b=E8Oy950vGqw/M3 Dv7RwJihpL/zrCOJ9xi4sc+CyMEqQiJr62yhxWd/RoFERGMZp7pUhsAratoHlPPEmxsr0mLuBThTA 278pMcURYhcJikAV4ndclodGiMSkFNv2g/lhKySZNTkF/8fnpRRpZaEex96upvHejyKvZ21FnyAg9 qq72wyO/7ktBIcDywJkgSyEj6m86ls5Nb5gzI3F7FwfwRZ3K333QtnWCxdEkCp8/9cDg7IftR/HuK b9+N7I7lyBdT42QjHZnQCAu5RHNehwfnAG+oLbAxe7ZJRMEAQDkmEbPX88PcJ1YhGDK292Z/5Ite/ kk2oF2pajDEokuW7Eljg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m4JZy-003rUF-Na; Fri, 16 Jul 2021 08:52:18 +0000 Received: from mail-eopbgr140074.outbound.protection.outlook.com ([40.107.14.74] helo=EUR01-VE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m4JZw-003rSM-QI for linux-i3c@lists.infradead.org; Fri, 16 Jul 2021 08:52:18 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B+SVFz23RyFV4Iy4HL/bQVGDxA2jcHjC/40TDFItglBEOw9DEJKDJ2tt2sYHm44jPQKWcusVZjtC+fFWSEptixlHI1mHtV3hnCn/4mty8PNbxwusCizT6eTPQj+IVTYBZA7cKhcfFxPw4vhTYy7tvP0N54af+xl/hquFtJLp74dg20/qvOPhrW9nyp4AZZR7QTj56i8Z+y5EoqsSKdIVsgnuL2FQwmzLNHN7P1oykgRqgFDzyrHZKVZDmGTPjqyuy2t8ory8q62siZ+42QJt62pxN5Bs32boMBUfIePCqhS8pl7rYNvxIvqx6+H4FseWNBxWFmlN9ECMHpsgkx4GCA== 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=M8iJASn+k+hE36e7mucUotmHPbltM93635xrofcgJXE=; b=kZMXe8dfVpJ8lzx2TIrcClmWyfZgNyEukZq36sV2LRxqksvW/e17a2ie68DVTulZmdmDyeKQGFkVAtYMucwaVwCl0wkrmjEP6oNAq+AgyEMXIefcIgFlzFVJIAv3SEPch+96hW2Iv2X7vxnq47SJ/XWXKm2G4uTi78EnOIZ9V8l0c3zFXvswmTqJ1iDi6uFc67NufsSoRextDgKZ4ssQyfrk63c4S3Hs6bXIfmh69r0kuOcODSRkqbtxNNyiU03c+sP6SrQ7eoFVjjZEvCRxE2Tl+yf/vDGpsKqNwSWf8GMn09xFaGRtw+vYUq5spL3vlTw/Lw7zr+iOkY70ZHETFw== 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=M8iJASn+k+hE36e7mucUotmHPbltM93635xrofcgJXE=; b=WCwxBOiDPctp4G8KVW8USvTanERZudNKhhxiuazAc6XOjz2ryLPj/HgmyWkBbfDEfAqfG9wJbJwweSUmETMQEvH1IXnG9XPqgUiZwT/RsdZchJGvrKUbkM5bfb5JXagnsjy58B+hl+h0pZYdWYZzXpLwMTSWzMv3eFWV403+1mI= 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 AM7PR04MB7142.eurprd04.prod.outlook.com (2603:10a6:20b:113::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.26; Fri, 16 Jul 2021 08:52:12 +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 08:52:12 +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 V3 2/5] i3c: master: svc: fix atomic issue Date: Fri, 16 Jul 2021 16:53:14 +0800 Message-Id: <20210716085317.3572224-3-xiaoning.wang@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210716085317.3572224-1-xiaoning.wang@nxp.com> References: <20210716085317.3572224-1-xiaoning.wang@nxp.com> X-ClientProxiedBy: SG2PR04CA0158.apcprd04.prod.outlook.com (2603:1096:4::20) 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 SG2PR04CA0158.apcprd04.prod.outlook.com (2603:1096:4::20) 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 08:52:07 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f812006c-92a5-4901-3d5a-08d94836ff3e X-MS-TrafficTypeDiagnostic: AM7PR04MB7142: 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: R7rChvOnNm7R4I33kOPSf+E5OkdHW0a/d1CEcV60S8Q9VEhzuacUtf6lmjj4fui5MBva1IZGRkJyyS2WCztWybqUeFtniUO0M7B6oD1YbuyPL+579ff8bbzf3voEhLMCMe1Kcj6sX0k5DRHQmJzEwiKPcQSKEywUeElN4gHtEG8tE4+JE8c5g49O0+kh9vEXnPE7AbUJEpYgqk0oqtfbyIexssB15eW7gEsFcsQ8dq72Wqza/emgPon9KNb7GYNCoCDVH4w5hTZ/myTry79GvB6lkXQRsMkRLhH3Ye5i62H4nTUmjzWz9HGWjKIQFLxWh/y0xSeK4i6efbe4lev19wQg+MYzuJ9l4dU3D+20OOKxJhF6CRxPGivQk/zJerZwEOlPBi63qm7NDGNWbrWH6r6l8PEW+dCktERL1EA4XQLh/hk4O7HDHliYfzyUXt4oxympn2bmmrW1u0WQGGBDUgQlwwQ1RmCHk0vbdxdDlYpj+HyttL8dASw612H6QnpGOx4fNb49SACgLeUGKfCTxdbD5UJw/+eDL71NUaAdFrw+jba4QuJWFhzioWj9+Hw7w/M214/nvM0F2j3cBN+0R6pRb4ACk2Zb0Ri020HKvLcdhtbdDrYyM2vhFC6VBlsU7oP5QGKn6f0tVvAey12NduTuxGNzwnBsKvOUKWJKMtgyK23cRA5z3kHD8o8YiSHTLFh3dQnQIqAA3f/fEOsCaA== 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)(396003)(346002)(39850400004)(136003)(366004)(376002)(36756003)(478600001)(5660300002)(8936002)(316002)(66556008)(66476007)(8676002)(4326008)(86362001)(6512007)(1076003)(66946007)(26005)(2616005)(956004)(6506007)(52116002)(2906002)(6486002)(6666004)(186003)(83380400001)(38350700002)(38100700002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: iH7SRjtUtiQ9RiwhJoQfeylX+bEInCQSesoJ0kunokdcuWFKnsnRsCXGtkyoA/HFe1mdoAzd125dAHlljGtGIUkZUpMePZhSKMi7dR3J6G3gE63jvQVp825FmFen7RJiHS/dKp+/prZGRV4K28RnNPOYIAXkxLwwAEBt/ZZwZ4CQiNYiAJCdYIjoJXK5KNrJDs+sX9nvL1x4PX4NyFlrZoBoiko4a+LN9hrSucJ6+qxd5VOrGt0WzV3vUpd3IPnZuyExTWC/g5Y2elMZz6S+uMKgOzUQGIF0bsdQ/HvK+0S1066iy1mFhREpyfP1nsDha2frLXNgReK4m0WEyEFhqOXZWWlUD5sN6nFL69BU0PJb5WpD8QNKE32yjzAErns2EtwZnRhwLpFdLBx7/qk1efwDtYJOxviwzbWLC4U3NQHCylkXigx3/TG7YYRPfb8nqCknvXAji5K3xoJeaMxmjYDnKwF7S4J7bwMzqg8JayFWR0uLXVPciQ1PX/331fTLpU4JqIFzm5YF7I9lvDw2H+BSfDVo5Fujiz3bbLS6+w4Njpz/gO+BfvtI750l+WaMRx0mC/RL+xD/NxdKLTI6Bcbm8Lc6MJ1zBpgFT54F492XLMB3ZjUfrgZK1sJ5OYc0by6qGB9MM/dfATo+AZKR61GkVGdti0ORI8K1A8+aMEkSV4uLm7lDc/bNPZx06UB/omOtZB+5k7GLq1eJVyjFH4RXzumtFe+84Q0xut6sugiXzxavSDmhlKnr467iwIDiTsz/ouYuqEjQ5l303Safp5QW31vlKUbHVCKHr5Uy2W1qZySD1vsGiuh4tHJGyr2CRxuEZXxwf6KHtigxVlK3X8LVBlEXJ1EMY0TSplZY/xXQCPgJ8lSv39NDPXYpYX/oEQZN6NN/Tv7oyLhlV6pqk01Saf9FqkKVHkae3V9YNcEQ5CfT7S6c29ylg6yq3QVGWsYdIfZoXQ7tI038E1E8TpEICCjpPo/YaqL4vFKz7eglJq8f5pzr7IT1JG1ii9wLLhHL69HgSiVYwYGNScEHUDVLi57Jlq7RrbV3mXAJSInhmiMa/x11k5cY192ffCEfhgMzAo2ETAO/lRVUAbQYkVsgugkQj8t7G3jQMpJYfQkpf9d9dIDtJpoJO7EhpAayC+1fxhILCSndFOhKjj44somvXpUkVFGuRkeuY+4SxxXTDPqncP22mGeZCAkbPklcBkoybv47LU8v0nqEEB8UFdQqzZsF5R7KrBMeQL0t5DqLd8EXrd9KWDwmEwXHl2sqhPNG6sY/LKnmHHSKsUun70Fc0Y6i5HshytFot4WOEKj/Nuw9ipC5oGP8f5pHVUhi X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f812006c-92a5-4901-3d5a-08d94836ff3e X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB5623.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jul 2021 08:52:10.0756 (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: keboCUMzk3rHY1X6f9VkppmqgWpHG7NRlcmvbv/dAW4sgpLqv5ZFn+8Dk2EWJDKhX04uogLQPnpFHHWOaLU+uA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR04MB7142 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210716_015216_880942_2C84EA59 X-CRM114-Status: GOOD ( 11.43 ) 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. V3: no change. --- 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 08:53:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Clark Wang X-Patchwork-Id: 12381747 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=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 911C2C12002 for ; Fri, 16 Jul 2021 08:52: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 5F31A613EB for ; Fri, 16 Jul 2021 08:52:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5F31A613EB 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=X1A0UFlA2BG0g6o3YnhlUQH0D0bkHpIySu4KWiz8wBY=; b=WoRPF2LQcIaWuw UL4vW0SZVXNLkAUa4gNZKT21WHmL9KFTCjgzp95iYZKP7IVrN0VnBq6Xw/NTZYmoLXCs3YfLcajZ1 TzfkYLD3xSBZ50rPIU6arcvxC22T18+wYlD1XjvXsmUmD+/BMgsaFq0hemZYamyyICkRhNnQPQKIe f903vgglkmmbIJCn7UxPkomnCGyha+Y1xQliVyEAZ4ese+9xUs5d9zBDs7gIok+NKIyCQUu/izhbg RExlHtto+aEORx5TuD64xjm3kdvROzWUEfDCKUG5D12IzpZjMCu1iz7P/O0UYo8nUeuWt0OSYP0Ag AZVlgLvLLDwhi4FZIybQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m4Ja0-003rVb-UF; Fri, 16 Jul 2021 08:52:20 +0000 Received: from mail-eopbgr140074.outbound.protection.outlook.com ([40.107.14.74] helo=EUR01-VE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m4JZy-003rSM-Gh for linux-i3c@lists.infradead.org; Fri, 16 Jul 2021 08:52:20 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BaM/wqhoJyuFqb+4966jX9AYzNQJr61gjBVM/vlNNH8WLVKAE7EtTNO8jQjkZhOe4YqGOARvh+wNvorbiETnCfBrIx50y0lTdV6Sd5zxBvpIuCrX91Dt+fxjVMucQRmALXmLA/Id9LwMCbU+jgiRL4UFuYPlf+9WRuoGr0VqRum/qmUcduhwkxD63YwGyCw6i0qPYO6YtRZxPTZX21wtlpWfXRLQwTyVxvkCLbww7i9g8ok16TDf+6PYtTI9ACGMRcrGfKoVou5YR8Sq8EPR7axz4ONJXrEG5xPXYiK0vaApcKinqnE30jBr6G7o9Ps/LkEsBGljzmjM6DzRWa7oug== 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=5S3BdZ5HGel6Pba7pPoFqB2GWWf2xkSJ9NM/7MB5k+M=; b=Cl+EaYNibjVbsLbqhQ8kQzG89F4FTQ5f1N3Ifgq78MK+vaIEkb7uf6Xux83ZyFbOPlaHCJYi6IljJ/rwm/wgYWQv8OGxCjVM+8M0bGOn0mUeZg2dSMEHUZguabnoxr0yvKvmeykflvZBJEb0OGtqLYB9EOLg31BULNkB+/vMlO6rxxE/haD79DaKOT0vBujF5HhivyxEWOFJh0so3UKv5UQOhjYLQ0adQL3sRoHlZZHClbMtHHGOgFZQqu+iKxdmX0V57W0ltWD5TuQgPOPmDzT3kewjWQLzBhpwOxp6KTQz1MGtkyvCovVgYC1XTsOrTItjsMY2MiQQAKGozukmGA== 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=5S3BdZ5HGel6Pba7pPoFqB2GWWf2xkSJ9NM/7MB5k+M=; b=CYQtrwaCSADcFblbYEYd/hk1oYTkF66Jrouqnl356VO6PU3Xl1bxdzLbDiiwkcMLk6osP/0lyK7mvBaPoTwMcPD40GiZ1/Kz06PLeAMA8LFE37aFQKAtKQMb3Dov9j7q63qKnEKropoVsXtqcKP4lo94CzPfD1nUGaBahOcLD0o= 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 AM7PR04MB7142.eurprd04.prod.outlook.com (2603:10a6:20b:113::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.26; Fri, 16 Jul 2021 08:52:13 +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 08:52:13 +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 V3 3/5] i3c: master: svc: add support for slave to stop returning data Date: Fri, 16 Jul 2021 16:53:15 +0800 Message-Id: <20210716085317.3572224-4-xiaoning.wang@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210716085317.3572224-1-xiaoning.wang@nxp.com> References: <20210716085317.3572224-1-xiaoning.wang@nxp.com> X-ClientProxiedBy: SG2PR04CA0158.apcprd04.prod.outlook.com (2603:1096:4::20) 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 SG2PR04CA0158.apcprd04.prod.outlook.com (2603:1096:4::20) 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 08:52:10 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5dbbbb66-8e87-4875-3c6d-08d9483700d9 X-MS-TrafficTypeDiagnostic: AM7PR04MB7142: 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: pcjS7T/CGPuzTTg7KAL9EOVxtbqaUFwq0DPiuBcFdJmZJnZuMz0UM6I0j0ArV2/vjSrLjdEe2PSXT2kIUtwjpBZG0TnwEuCPCPFJBDqiM7N/vQTiYR61nvFgTo2NQSCVhJwcGYwC/G7cKmtfsVkSx+jV6N97OMyiVduvizHaGWUck6VnYx39LFPUGjv5EVDYkjwKjf62T2O6rU+aR+YWVkJdL3EYMnjpBTYZMANfSmWJ0LqBYhmnTWetu9MZPYAH8sMDVttjxcQihU+CeJOowHr1/I4t0mwAdqUTLBdhLKBDtbW5wGyV1BkP+iV8TifIgax33JTgeCBM351lkAgvGW+KOtWFe98Gkwy+g6cyg2sQbMq38vaWeQkrlwy1j8dj+9CAUYdihLaTtl/37BFa0Mr8wNaB05uMtoerqrcdOUNdaEN6KccOSC6rBD/SlwEShMv3vRn3hJtE9uYg03m6NKPgcJiYTNOQaUy5lVdX7R8GG9ntgOvbSVbwdpoSJHKFSGNw6b7hkEdEYSzaHa+GXVfmQ5KpVj91uiPOHfg3KOoTzk0nsISlzLqe4tvURuVLEnTM0CDp6ljvW+MILUE/YmsFW+vrT64G7cBqexwkcgDm3uafJ8YN8jAbCgUHKe1VNIzlMD9Cos/y6O/rlXjkFpWv1P5APsODjRm0vWX4iRhlSAHlfwclOCJEF9Sndx+h5Eq1dHooq3ZGRISc9/EPNw== 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)(396003)(346002)(39850400004)(136003)(366004)(376002)(36756003)(478600001)(5660300002)(8936002)(316002)(66556008)(66476007)(8676002)(4326008)(86362001)(6512007)(1076003)(66946007)(26005)(2616005)(956004)(6506007)(52116002)(2906002)(6486002)(186003)(83380400001)(38350700002)(38100700002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: UpsAEItGrSHLZKOm+6fhKDtrPvJO+utjPm2d6Y9I5R6xirMRSNJA+HS+8MIMv6wRrzL5WmKX2kogQs0vxqncFdcfdQXYO+tbL+SMeP6nMCCYDstn0gQxvSl8fWWRT4zr5DR2U0dg3VT5BYtukqCtiRs8MfRzsA001ZYYM4kEe+O0VfhMN70q/AZkuC2437JhiAlHn/w0U8ncZWN9d3s7Jaga0qXpEWaGfOfXQumZxSU6nPGo46QLM4MBpswpLCqFrPAQJJOREW26Dx6LlUi9rgwpUajYptc7AIlFCKvp355of81H4Wt1MWCRwOTqBRuSBEGdOXIw5s+YYYZcskC0YoAbRgfd1R0pUnzqeziVcZrM5kLu4DCxcChEhZuSpCa/SAvHAV/vG9XInKYgnzEpYhPO0UD/KPL6BsO4EQab09jh5H9UDK9eoDDBNwON5E55+NoCzU8wi+76peyComgUEzoEdf/omnEi2LrsUpKfQuctpkXcWjdmSYITsuBsuG06lG1TCxWcqBrn/1tt057TBGly5vMDDnMnGm0Cwtku6b4F3eejqKX8cgFUrJ47iZWWlRsUL96lbRpHS9BMyssbIuwIEahHb0svRy6yV1SDjJqITsM/VtU9ZGXTcrps8zRDANfRL41Rp0KhFVB5WUH2SGQVXJh0H6Aqiy84fgawyKHR58PmGq6mkGEi9aHIm48O9PfOkB7U/3Y2tTCs9OZS5ZHWHaYV71lPYYzJUqjaCClcf/B6b4S8YIRL/A2F48mvWokKAdxuab8mtfSKKgNxjuUcZJZKt7OaRcOPkdM5BcAu7Zc/oZZg+JBmrllB1VVGaDNehhbrWym5ZsRhhr8Vi9jLZTOgSeKchLsaySAkMrMtY2vL1iCMs40d6Ppj+7R8asIKYQpBVkSagKk2198jLAE2mNmIVH+wOOBdiSRn6lpNsR+Pv9vwwHjBzJe/a8pFpIgCARy6i9Ctzgg/4aCwQGyTK5p72cjFHUixdNczXMDn469vi96lDiqev9SPPmlmQfqzAIeDutsEvrAjTcpQgzn64aLJoepdpmUZSzBw69QQxKt7UnaGuKOTmhrr7r/NrQRTKzQ5rflf0KVjwjKUdu/2Ump5ftqv1ea8TjwedWVDdIDBQtSoqNEOkr8NX5+zZca6xOvug4YjMeWR//37pan2st/et3VsgeIwr3Cjzm/RMkaOQNZkN0WoGmcRN+Lhfe5k7FNhTYzJiiIumyX1x3o/uHQJv6tlyRBJqxmy4jWGWtL1+m9JGUKSlHa3Ey3wKne810sFamRj2IP6G2LB1+YcAVJH1XORJg+uUV9tI1bMSU664PxXvaDkt+hsIx9P X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5dbbbb66-8e87-4875-3c6d-08d9483700d9 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB5623.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jul 2021 08:52:12.7741 (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: 4AyqVDPbDhdyMzje/B1Ipg0+c98q7znz+naoy36odvhZYvoG76Ugnajem3OWEwQ+/tTAkHym6svO6WkDM6jbBw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR04MB7142 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210716_015218_588325_FFEE80BD X-CRM114-Status: GOOD ( 15.38 ) 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/V3: 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 08:53:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Clark Wang X-Patchwork-Id: 12381749 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 C64E6C12002 for ; Fri, 16 Jul 2021 08:52:23 +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 93CAE613EB for ; Fri, 16 Jul 2021 08:52:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 93CAE613EB 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=f2HRQZPESA5fmeA2c7tfBWcZYapGZ2/IQkSmxwckAcM=; b=0LM0vryPNL+uoD b+eM63Gc0g7zRieQmrUFFXUFgsPax6ZchzktBb4RrWAFKX4/AKqydsrjuwzhYz5aMuiRZgVn/OtkY LWjS8L11pd7sMi6hITmYCSn9w6ep1uD9OtrTuXuqnawE6mgLhPr9pzg16zkpZMRTxt0119IwT8zZj ppLUpbVXu14nbhVbhpKAxa1Kk3jTqQNuPdoxf76VwpLNkWaunN+tG5/7zBEdbMtp0K6cUP9qQsb4+ jVZFQvtw4jCvOjdGmTdrgKOzXCkoVCcGRQuhUBlyHtl69aOM+NZjPf8Gw/DIufdAvWj13RuyPLZDq ID5frqPFN0a0rs5w+IHA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m4Ja3-003rWo-4A; Fri, 16 Jul 2021 08:52:23 +0000 Received: from mail-eopbgr140074.outbound.protection.outlook.com ([40.107.14.74] helo=EUR01-VE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m4Ja0-003rSM-D8 for linux-i3c@lists.infradead.org; Fri, 16 Jul 2021 08:52:21 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Drwk+z6QJBfgNTnwnsp3xRDT7EChLnlLKvNv5Ah5JtZpFKW/M+FYgMWJZ/Cv8EX0ME05G3VwpSqEnuqrcUaGOYoy2H/vjCIUtVJJZ2Z9ywDCJ8Y+lHK0FUW5gi2aSDJZbhmrVLG2yM8AmmXKnZNIkxbAls2UKTyX0epiUrgwSQpK8A1sgUYZpSvjiI81yntEyaBdffAYjT20QcMA8U+CHYsGptN8Zxv6Qc493obc9ol+QAU9IE6AXsY4JqS7r6Df3tjzcpaM8zIKjvKV5MJgZIRjtBBj71MkFCfLBrmm2mOXOqxIdr3UfISQd09AxFk1graFhXHnCvTzwwzbnaBOPQ== 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=KzNerl5RycHV0szSWiucsBQNntFy6TdjIuRE9P5VxXM=; b=PCt2DvuXldYyM20cPnmLXizEJVdvSIQoL5xuFUvGCaoOaFcwueG3oQ0iy7MuP56SpPVsoAf6Bw4Ap8064cWXC6rSd3NAfBmHyvdFOp9Mfzf7EK6s1c69LHd426qKEYWbp59jH+MWzNWQS1ulKs9FKnyt1A5MFNgCulQGkvGVSkTlK2FYbwf4x0heyKHHckGJ8iS1wU0QJuk7aLvvKdG7b7SVy5JNITrwko+F9oc1RLNqp5d1aZ3lxwadI+8w0mwJUj/LeF+OkJSKcMIUtqJwfwbsRDG0VO80pdJ37w+i77xIMj1M3kwsc4vUjWuw3MlCBYrtqcONpI0SfUphoo6rbA== 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=KzNerl5RycHV0szSWiucsBQNntFy6TdjIuRE9P5VxXM=; b=duJn/Qq1UnHYJlr3v07kATju+Bbh9rvJiVvFgzJlLxYEUBXKonCPBMJflnmfvBVC6HTiszWhTgZIGBCFqUYO4kExN6pgzXeO1dJ9iwPK5PnggOL5fUZiiLhb6zdh5868qczdUoTd0Grg0qaucQl/1yoemJ4Wnh0r0Pp6yx5ixbw= 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 AM7PR04MB7142.eurprd04.prod.outlook.com (2603:10a6:20b:113::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.26; Fri, 16 Jul 2021 08:52:15 +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 08:52:15 +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 V3 4/5] i3c: master: svc: set ODSTOP to let I2C device see the STOP signal Date: Fri, 16 Jul 2021 16:53:16 +0800 Message-Id: <20210716085317.3572224-5-xiaoning.wang@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210716085317.3572224-1-xiaoning.wang@nxp.com> References: <20210716085317.3572224-1-xiaoning.wang@nxp.com> X-ClientProxiedBy: SG2PR04CA0158.apcprd04.prod.outlook.com (2603:1096:4::20) 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 SG2PR04CA0158.apcprd04.prod.outlook.com (2603:1096:4::20) 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 08:52:13 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 790100e4-c39f-4a60-1cce-08d948370279 X-MS-TrafficTypeDiagnostic: AM7PR04MB7142: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1148; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: eB3AjaBsSU/tfbypnivETYcs6BwoKWE3euNIPQHdHA2zhbU7DUJCnDKuY1+ZEpq2ZmIqSCrGm6Kp80FbQWGRrdthT3/8x/7ord2vRTUnBHuUxbnBumdwFxqri4h9eAKHM3jhJbVO4wPXmyOb4g1YfyGpPS3hAqjvn1wHfUnD4sYNiTYuLeJCMphhbU9ULCY3yztdb9+NfeR6mKosahGHROuq5okfsWofXfSUDGttnndLiK+bGyimgR0n5WyEwzEdNdzlEWo7PkURcq7e0fiNbVbObkOoBqwuJ8T79J5A0iFcrNf6q0n3bxQRhpqY6jX5QLL0HfNqxY5CC7cnf9rN6/3UDLvdWkVgMCLeMSX1Xy2rgWQlCZ5Yz4WavAByQpn+LBhIL2DIdiPKqXlEbMtysl4x/B5Ow7pQ9lSFWYzxQfFccrPrw6Pw8DtnYExfvR8j89jGqaZMH0hidQpKqAWj3uT1knbLtsgAZPbZrAMGQid16tUwwexsB/7405Tekp9iwuO2y3Mxow4O2o2dBqtYcZ6pze7wzV+ZW5Z0Ogv7joI2aEckSqfOwCDwlEw+y/J/XNK7ki3uEGQaQbUVy/ugtwibwa7mKasgB+7TmzeX4cu5nX4Bqjj0jtBmCWl1+2a3YhT+w8FSfxhXDmSQzITr9WW0z2EBSjZjy5P6gzDx6dlUuuVvTsn/MCL79ndIAoIyi/1EPTaIFqiP33JNfEaJtQ== 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)(396003)(346002)(39850400004)(136003)(366004)(376002)(36756003)(478600001)(5660300002)(8936002)(316002)(66556008)(66476007)(8676002)(4326008)(86362001)(6512007)(1076003)(66946007)(26005)(2616005)(956004)(6506007)(52116002)(2906002)(6486002)(186003)(83380400001)(38350700002)(38100700002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: E/50bgkW/darEW98A1e8lClM6L9Z5rn91vgK02eFQkSDBFnp0nGkdYSwrJTA3oAnyO+os3hKN6FQwXFiPiynrRH7OzNFaUuL78yF8jbPPnL2MZp/wpmNplLq7B85zIPyWNqjifXX0DENhW9hybU4MMDnln3S+x7Ro+aFQ85YTr4emZB6yKvYb2RjdaYYITiEwP5q083vgNMEfiGrBogKO31AT8IHYFrt1ODCAF0MWYsDzUrC+g5MEx9I9SLQRZtBHirPRsXr+9NGRqb+yCsLKcsVPjz4XVy7/cnySr19oroTmmqniIjevVpT3q4X7E/nyQOvfgY/wKE6ibR9l/0OK8uI8SyiziwzjYHWdn0MtpaAbQe7aHT4v6vT2g/WCdHtjxjka3YX5EqHERn18DU8FdwUv3tLghu0Ib66uzyzyLYXarc3GTq7idVSXXqE42+4cbBqqIDFlmK1UIdZmcwyXGdYfiF9lCDOwHS8x4XJsaLcsVeIkLXkg1Jf7bzhUaI/NZGQA2nHLPWdYrlpV0WzvIuwey1MHNOxsn0TIkJtLhhAsk4ionqGcgfiSTKPAIo0aeKFrU7QqueS/HAScQZHGvWrR5eb5cUarWvu58FMb7do3IbeVtiurhJdKkb27SHzGrvQHUyp32nimaq97KBUCNwaVtkFiBac3LvsCAAdu+PaqmHDA+Ci+TAes9TUfva8herzYe3CCjxpHCZguQA53bx2RDfFlSYa3wnAimCjhlmBf3rNzQ2YPBlBnw5m+XwO2D8Sl7EZGa+RhsKgMRMQs6VVJsdKKkCFrf2BVo4ziXHUwfrFotBt3yiafy6c1Z4ez1ZnWcF9e8UXwJpEcKM2C80CsGeQG4ZaIlGrseg3NKzEOT7N9xi17OrHtPpKYziT1WzI5dnVfX8RQhWORWTf8clfGz+QEJPptaqi27YEsu+TYUwmsvlPuKBEza2JdY7F+vnIqsJcEMNOGg2DTeIz73ebugA5f4E+Soy7hfWkxdZiifX17jpltXMxdhjKABevmoQeIGzu7yzg/jRGa+sNW4xyLqsm4gH3VHhDQc5hijKlLGv0PnyAO8Robtby6eOcH9TcwhOG+Dfr/KowoWHZ1jP5foUz7F0LD2v21wpjjf5V7ZmiEvLq5Tr9YlOe0dL1i7ypFcc5t333QIEUtxLxjyjCZ6390l5J/5DsjfsjZ6k9lUh+IIFm3WFVglUJcUQxBKnTkaxv36xFOqfoeNrhZi9mRdlg4GdHl7t2RjyHmP7fgpaYEn2DIaF98PXxWfq2FD+iKkXiceM58WAY2CxqQV5iZajll2tMgxaZuBRUukD0fgCWOfDry10cNPUtUDQO X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 790100e4-c39f-4a60-1cce-08d948370279 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB5623.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jul 2021 08:52:15.3307 (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: TYBRZVzaO4Enol+cksOBuJ7XxOAn+gClKWf+QvgCTGXiRr4/2u0Tx7QTqculdesFnBF7h0M50/IwYJVZaiRnEQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR04MB7142 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210716_015220_468934_19E93A79 X-CRM114-Status: GOOD ( 11.88 ) 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/V3: 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 08:53:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Clark Wang X-Patchwork-Id: 12381751 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.6 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,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 0BD89C07E95 for ; Fri, 16 Jul 2021 08:52:26 +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 C0B57613E8 for ; Fri, 16 Jul 2021 08:52:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C0B57613E8 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=Fye8jEcObNXxDh9QxDMe5bB4Pkr/mgMYXQ5GyRWxKrA=; b=f65f4p45aiaFKN dEUxRDBfx/fomr8/ryD11mLLx4+OWWAU0iKS/qHAZneosJKzdkJ8Z1A8zgK9fmkSZtSKEfKOMyZwZ D+5Z549hYSLu1NLsV3ZfNwn2g9LvU4JsLclMwcFXR2fdR7IyoG4zBsSRzkfAC3Bs+sCbeBKmEQuZN dPj3bOfc4jlFUObhJWypjdEanyifEy8oeNrXqrF5c7VA7agLDT+A+270aABWWO+5BqX+l+3dG6PHK cegk41Vc8IVG/Av92toeDIKTMfLHCW4S2RM6OsKcQfeE427kLA0O4Ynp/VuOou3e83b+bGnkY898K Li9xLFk5VQ7LpA+90QIg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m4Ja5-003rXg-9p; Fri, 16 Jul 2021 08:52:25 +0000 Received: from mail-eopbgr140074.outbound.protection.outlook.com ([40.107.14.74] helo=EUR01-VE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m4Ja2-003rSM-3J for linux-i3c@lists.infradead.org; Fri, 16 Jul 2021 08:52:24 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=T0aUzAsSywrEtudwqMUk8pY8WJcwimyZHdwpeHBU4ElgwWD7uP/QtF8K2ct6S+7LPIg7inqLCneGEddUjqycXgNGCUlwiw8vjHqyWiu1mU+yMzAOYtZnZoSZ+Lk+KdRCzvZJuQhns/1jwx2XCeYgU04E8EnkCm+HsV+8NOMK2F+Q6qt/BYNartWJzSk2/WnuY1vGdNXjoTYwCjt8Zj82sIRzUJswGZDf2nHNdV+E1c3M4Bw56M99h750i+SY/ZKNpvrFuxORCj+JJzpmjkxcwgxxkY877ET8wSq0tbvPTy0+3NwTrfivJDnXCdQ+nSQqR0L9j/3b1PXq4uLXFNu6HA== 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=DsHrpi+ics9IrRRVC6OXyhj3wizkpq2mDQPicBq6U08=; b=HHXZyTRSqI5ODqkJES7SZ4+P5q+yRu6Z8pa1sZblW9xU4GOrsU/QSjoJc1yTRjiQN4J006ptRctAqEVi6jrGdfDFlKejFGy0/JakUgMbjoCYx+MFso/3G5jUKZVYcEzYey6JlVIMOQkiiBNpDbkx8PQWMxBL+r4EqAOGGabNx+0bsjFteKFb8lGB3Ndbtm0oOrfo0rxfi+1A6e82YpWDRowDrnqNQMNOZQJLztjBvkx78wWGo0wQnz2LsNqDKPurQjnRfrOYutXIVioNAc64H65KtJA43nJD3IDjeQcoRW0XFpd8dxfev8p0tqugqNw29/LQGCRieRuhJBLRpmTteg== 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=DsHrpi+ics9IrRRVC6OXyhj3wizkpq2mDQPicBq6U08=; b=Et6iuQpCvp0wGDO9boACMUgGyfsAFWyEOE4x9XtxuAUpzUtm301rAxrGxA1Jp5rGBcd4isg3rRfGrfIGMZnAVq+RQUUMkMbR8qF8BYVMGKGGr00pFtxBeDRLn9oYqIpIkpNlUKkIxWgXqCKzE2jggmoh3nQneRYACJI6bXOnVjo= 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 AM7PR04MB7142.eurprd04.prod.outlook.com (2603:10a6:20b:113::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.26; Fri, 16 Jul 2021 08:52:18 +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 08:52:18 +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 V3 5/5] i3c: master: svc: add runtime pm support Date: Fri, 16 Jul 2021 16:53:17 +0800 Message-Id: <20210716085317.3572224-6-xiaoning.wang@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210716085317.3572224-1-xiaoning.wang@nxp.com> References: <20210716085317.3572224-1-xiaoning.wang@nxp.com> X-ClientProxiedBy: SG2PR04CA0158.apcprd04.prod.outlook.com (2603:1096:4::20) 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 SG2PR04CA0158.apcprd04.prod.outlook.com (2603:1096:4::20) 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 08:52:15 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0aa1e2e4-89e2-4bbd-66e9-08d948370441 X-MS-TrafficTypeDiagnostic: AM7PR04MB7142: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:324; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: S9q2eJNJ+s7beg+aMEXeBskNYrlE+TGUpaARQBCuaplgUZP9eBWP0xtSnaiZvRZqZs4pc4r+WbmvEymSmyupORwiZD69SGXF+3YIQ2UhSC/ZtyGG/0N+I//Vmt0/Bn5Aw1PKXKi71LRJnLMeSwlZZAb5lgVmtjbZcRzmKSBpPPSHf16Y/7RM7nG4qb9HzFAxAEA9TNj90n6oyrY31YLIKTxzzOYO7KSR6lz/EVOFKN4IgnnYQl7O+ZpE6tgI6/EQlWm0gHinX70vKJVrZDktL2zIimeFkwKrocedDdH+KDq8SWhKUzC3TD9NeLLFLVAfc8E8j3tTqHfFBbl4O6ZgtPArMZZ6OdBNChxRu2nxkbzTeTsDexV7jYi3N1eTjMBG/LWf3bpLQCOvl3dLC572VQ2Xz++W4CGkJAHGzZvguIN2eocrZ/DLLC172NiKuGD8YqdYUopkaLvGjvQpymk1dOj7MjwlRplOahTn1zXP28jAqEigTonDmP6NZrFulityx5Kou0SO7rBGKOaCmnabe4v/ncf6MDIrRgGgKVb/SLJLuPtTqHyLqjfVfT3kKDXmm+kD0N8iXOnqv5syg2+LmMhYD1VRZODrU8avjvMKTQZwF/iG4oUd4YtmpTxdYDCjP5cGDBmJNTSIvnFr9j4m/e6j1smHhWe7qOfdUTSecefk6AhIcCu/XaIEBwZhteaQpOsJRxD89DMPJ09niTSvsw== 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)(396003)(346002)(39850400004)(136003)(366004)(376002)(36756003)(478600001)(5660300002)(8936002)(316002)(66556008)(66476007)(8676002)(4326008)(86362001)(6512007)(1076003)(66946007)(26005)(2616005)(956004)(6506007)(52116002)(2906002)(6486002)(186003)(83380400001)(38350700002)(38100700002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /EvoGSVP2MwUFbmmR7+gD1YBrxaqs4AHP6QygYV8XKBMHsuRh+y22PcbZhi6wm8GMhJuH4vb3lMakCCZdhZo+mXH4OeTuQmaPltorS2vM69ZyKRQeGKZV5LHgSiiF3yPZJWAXUi3Cu7YCygz4PrkSVAnetT6jNcgVtcng8iE9MAJyH7gGbzvjlNt4YaFVJITEw0hYurIZ4jpS/zmP1Z10YVTQWsdltVEf18ulsZyoRz/9DBGNUOMCLTc9KGuYy2MebJvO+nzuqZU7xBN4l4g8Z9U7lXx8NQeSXBOttl1JRK3odaQAqzdEIh9Xpkvchd+gKTDeTx4wEtyBuxEwy6dDUoUpxPO9J5veB3i65vrLiEmTuDgNPkqnkYsDsG+9uWFJ4SYjMPTCd7J81hJkABj/OUJIwovt/Aa7yJsi7Y0XWOLkkTvsEls1RcrBhx3JQbIj+i6w0rN7Gzw9AFqt1dqE7kX+v7TZ+91s9oGoCfHzyk2znPSlA8vmH9yhOuY90FXl2qTimvpLaW/X74iT3sG52fvC1+iSPm8c5ultvXfsKCCGLKAwP6+mr1CWzVmEwf8mvdjCg8RAOZOJZLT3auqWL+CQ4f2rDJK4vU9f0LWXJ4SBjyPq+6al6OKjG3xRAv8eg+8kWWtBe9CuG2jBO6pDrsacjScNSyS5v4cRFxkubh72YOaONh2KCxNQdc80876jIbb64mmvaDwgbwBfMt2s89wBsZEU7oODMeS/d2pYo0eEtuGWinR4RTUb8G8bwZmWt2RzBIJ3sCrHJWKN94Sbh7WTs9ZEWIbBHRC1S3fLOHH4zNfkEEbcmTjP216kb05/upfRClUlhTe8eRmmZKtJS2OofRmyEUsCPxQuvCtJb4ABWUgSnJzfEG7x4ffns4RRWg82vdyhBO77iUE/RWZzxV6dzs0HTwlu2OdBZTIW8Pm2ZgKDu4LCi2wW4+UHpEyr9Pu/AS0XR9xtqRkfdPjfN/VHUvf4TySefp25xaPuK7Q1FHIghXLMfCksefJOmsgtJU3H2HlXd8Tg3GRkGCqDQAFGnOsFg620/oDQ8M9QNfXVYZMmJnvpqwpAsUSmQ2bcLlwmVxFHeFZk7TyGRRgT0KSzBn7Wgfhacrlge3riHLf5w2UcD314SpEpZcZ8pHECIRl+dkHIaLvp8rRdiwaORjvr4B2+7wgzolP2j15Htl2qDvTzZtCdl1T6aVLz2SFiG+xYXRm8IgW7tY4FhbiRcrDe6YSJxMrteuWHfYmSmXZ8pBKsJMg533UymzwB+kom2lv1Taq0u+o30i/n11hHaaps4M07uzw2Dvgp0D/1W2KqMV0px3KKvCc/5a6WuTR X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0aa1e2e4-89e2-4bbd-66e9-08d948370441 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB5623.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jul 2021 08:52:18.7238 (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: LCFaDZJ26uxamisHDqDbcDRHU1ycklTs72MizG5eOYbj3YswZIVvxFXcYVKGyfSI09KkhjSuSbg6W5KPmdKkSQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR04MB7142 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210716_015222_325895_24873FBB X-CRM114-Status: GOOD ( 19.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 Add runtime pm support to dynamically manage the clock. Signed-off-by: Clark Wang --- V2: New patch in V2. V3: - restore the error path of probe function - enable runtime pm just before i3c module reset --- drivers/i3c/master/svc-i3c-master.c | 146 +++++++++++++++++++++++++--- 1 file changed, 133 insertions(+), 13 deletions(-) diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c index 5677b5b31a86..3121ffd82745 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; + + 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 i3c_master_disec_locked(m, dev->info.dyn_addr, I3C_CCC_EVENT_SIR); + return ret; } static void svc_i3c_master_recycle_ibi_slot(struct i3c_dev_desc *dev, @@ -1436,16 +1496,31 @@ static int svc_i3c_master_probe(struct platform_device *pdev) platform_set_drvdata(pdev, master); + 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); + svc_i3c_master_reset(master); /* Register the master */ ret = i3c_master_register(&master->base, &pdev->dev, &svc_i3c_master_ops, false); if (ret) - goto err_disable_sclk; + goto rpm_disable; + + pm_runtime_mark_last_busy(&pdev->dev); + pm_runtime_put_autosuspend(&pdev->dev); return 0; +rpm_disable: + pm_runtime_dont_use_autosuspend(&pdev->dev); + pm_runtime_put_noidle(&pdev->dev); + pm_runtime_set_suspended(&pdev->dev); + pm_runtime_disable(&pdev->dev); + err_disable_sclk: clk_disable_unprepare(master->sclk); @@ -1467,13 +1542,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 +1604,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);