From patchwork Tue Aug 6 06:48:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Song X-Patchwork-Id: 13755291 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 294D7C52D6F for ; Tue, 6 Aug 2024 20:40:26 +0000 (UTC) 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: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:In-Reply-To:References: List-Owner; bh=SkQDNMMUwiWumk7eq1m5Hwp6mxf27qoLn+iH1Snypy4=; b=kVKRSqLLnW7c5G Qj9VwICy5t35k9Cl6MGQMJyAU47WLfKzQPMS3jmM/tXcYGSVxzb6NWSgnyH4IDBNLAA56H7BCun4m Bo1j4SdmFBykuEVDUazJecUzH1IAkBE/3iW02xKqRLImssEuCkm7xa8T1eMaqcGVMk+Dg2DggqTkT SejIxxx3nPaHrK4pPDgZPfbRrqU6IeMP0j1/KGNgc52jgOLvTXicbARGsPLFmx2BwXtEsmuOS3MLO C695Lz85mnY+W6mYF8sQfw1MEXmJkstwANRhCOazut20TCGFMgGdgghNRsYBqXy5pmypPB8DzAXeD H3Unt1GUxsuN9MixW4XQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sbQyn-00000002qHN-2Zpr; Tue, 06 Aug 2024 20:40:25 +0000 Received: from mail-db8eur05on20603.outbound.protection.outlook.com ([2a01:111:f400:7e1a::603] helo=EUR05-DB8-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sbDsf-00000000hKY-3q9W for linux-i3c@lists.infradead.org; Tue, 06 Aug 2024 06:41:15 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=flKNZt8u2dpsoeGZYgInepSof9zyJ/5TzD5Is9s+G1WvejGkLaoK9P1fl9kC7ilVzbob0X23VycspCZAUebnb2rAw129PELUW1wEZKAMRF3ZiaGpa7l8s6/L5teJRIOmdN9fcV3xkng05uy077Z3s9GmuCxvDs6MDiIjID3Kwt7U/rIEfjNUsE9mZ2+EaZEUXNi3A3gPJxn/GuM2yV54Pa1vGpRbnksU+YhRMQMSPpwUA9enGqxrlYUODF+q2ZIvbmn1itfEiPsPszhhHL0DjzSPSwvO2lcyoz8+Z1GOqmXL9XRRgdT/doAO9jlWzBgjI3qbEAcc7vkzhCA3uy4dFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ErLV1tIvao2dN0HR063rroJmN3k2/TZ4fzvrDtm5hp4=; b=dKQeMhSlXbsEuxYaWeH6saEUf2kDElx93nETpIAnviIrBwgzJDoQoU7Zc5nHG+dWsGsja8EVkQaf8HvSqSpsThyEPDGQ0QkMCDgdsCPAvOpMcJkfx7rbLMGnrb16dbOiMrRlLaJ0SHr3EUSPZkPxmvoA69Lv/zYiQeJ0SFcjKe9RNN9c/m2u6BKHNRRUCCvu2QXczOoy5i5ew2xRJUe7Pfb1nmM67OHDeBD67QjGlYbvctBWWAva7WRtCUNE1fQ3k8wc9WglU8SXjG+B+MDF8GhC717cAIw3vhKjxkU2R1VaXdJ4WFzd5Q5YfCHNytUCF2++cZM/qX4A7/5mkgV8KA== 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=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ErLV1tIvao2dN0HR063rroJmN3k2/TZ4fzvrDtm5hp4=; b=MqbO70yIj9CM/3pkJVtYQbJqpNr6JMbKH9N//LpGazlokMQaZaW/RXRd2mK8709CvCk3+SkpFXZsMrXHyC4kAzmXZ6+twtg2d4yGrJbpOTIQfN2vHl0SzZlYPRv84sEvRHMRWcBP5Scx+wJBZibxKXjL3sXq+1FPlNIsEFoXpeczzbI1hqbMsMDSRqBC0UL3M5QpuL/eZVQdSYE5Y/1VnrQLN6/7CV+z2KidBBjORfiFn3oOrI6SARxwrp8woZoc57xa9H9+PWFo9vK1f+2LppBoSGDPWOHE7xYxo/p4VpE/wfO4moJxTM1caSC12+bLagRoD0x8x4NW+lhlil9o4w== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5005.eurprd04.prod.outlook.com (2603:10a6:803:57::30) by VI1PR04MB6912.eurprd04.prod.outlook.com (2603:10a6:803:134::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.26; Tue, 6 Aug 2024 06:40:59 +0000 Received: from VI1PR04MB5005.eurprd04.prod.outlook.com ([fe80::3a57:67cf:6ee0:5ddb]) by VI1PR04MB5005.eurprd04.prod.outlook.com ([fe80::3a57:67cf:6ee0:5ddb%4]) with mapi id 15.20.7828.021; Tue, 6 Aug 2024 06:40:59 +0000 From: carlos.song@nxp.com To: alexandre.belloni@bootlin.com, frank.li@nxp.com, miquel.raynal@bootlin.com, conor.culhane@silvaco.com Cc: linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, linux-imx@nxp.com Subject: [PATCH 1/2] i3c: master: support to adjust first broadcast address speed Date: Tue, 6 Aug 2024 14:48:50 +0800 Message-Id: <20240806064851.2425797-1-carlos.song@nxp.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: SI2P153CA0002.APCP153.PROD.OUTLOOK.COM (2603:1096:4:140::16) To VI1PR04MB5005.eurprd04.prod.outlook.com (2603:10a6:803:57::30) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5005:EE_|VI1PR04MB6912:EE_ X-MS-Office365-Filtering-Correlation-Id: 5df0112c-45f7-4b43-2214-08dcb5e2bb79 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|366016|52116014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: rEoVqTOQNRIbJPDGEb3iHPmuDJsmMTit7shaimgEHh7ADBTCSb753lFCPnDVPZufg/bAO7JubAB4X8YhjBHUPJfwGjWlnE3lfLScYXZ2MUDnaiO5fTnu9PiyVr4KrPzBr3YujtbtJuJohAnJYDw8F1oUT09keclL5UC6LlgKaIdpLj4nyFkhKZ7IggMoSH/SiObHvRnrz90GdMs901iDOG+MGAH0LwOMe2dM+FNFIDD++gdIoCEp/BiaKpyncqJBZ9KkyWCgI/Xy0fFK77whoeQ2o4NLOOMxw/mRW+IH7RoYmFQ34OPulskJvHQWuRxf/6JucYkd3W9BPRSZq5ci9RWYL9mqXiiT5w7xHmqsL7QV94CtuM5J9HkpNxaeTzneucHSqV7T00G97tMX8KtOxNqMKPIwh/V996qt4TW/dpRs4/LQbGIr3NfDciqescRHTN6WtUldaMSfNjhWlw8qQCqhkCmQvmxeVa7cKajEkp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016)(52116014)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: wkeTZqE/zZnd+TKcyOVGktKmhZbZKyF+Lu6FVyZpZdGPO69r6aVtDCYNSfltDiCFZpVj3yYr69xMnB1lT27llt/03rJbe4eJFUydHR6fSH2km/YK1l9fsVX6Q7c43672yY7dzbL3r5zWWKSJEcpuA8WseNqOLr3K7Cr9/TdKRURUz89nfLAQ0QGUBR8uaUgoLM4nccOFCY+KpN3tFt+Y70RcPWYYCmFoiqhssvT1Vowh9C3Zd6Vat5354hKDeJNQXLCiOy/W2JhAq94w6T0XWGzhk4oQsP3orkkglK15rd77G7tvTAIj+sRiBsnkpOs2cVUymGmxzQRTJtQBgKKd0eBRjpKP4fsok4XTuUI7240UQAdf6lZRAPf5zqISSf+2QqA5VQ9vjF/gSfs0OR2HxTDXRUPXJkEbv7sW2RJk5Buj2DVfF0n4lR1izh/NRbxkbXzk7TF7StKKs1FGWI9PYm5z8yPcwLpTuhfHc+BPV57uUncrmiEpsUorNDvSlNpHsKxHeuzrrcfOy/NwCCVz6Fwpr2pOL/2GGYNruO/yxDBeKW6lR+FsCU7UjirocB9zuD74T9R3f409oqsQkL8gS9CD6c7E0nSDbA/76CHKLoLh0Yp726tvmMyl27r3AkvwvYFEXt0i+4TUifnqDG4nBw/R5+r3/17r10TpfDMPVuPEHQ5Fu3QyvbbgxlphUZy+yE3Knmrv74Tyxih0tlEUEDuC4TCyqPAsi7xqKbirOvCNECjRmCwVXIBKS9c76TmTg9WB+2n3ZNUJVe2u7NtM0NXbpRxwu9Am+scbalC6p4LzPxc6NhClpj3LtEfjd5sIbOaI1mrWRGYLzMCgndjU9a02/RN8p/8D9s+OTshR9iJFIt8z5/ADCXvU29Y3Y0kGR58DAbP1Cz7YOK5CdC4qHTiRzZlDK35sl8b0ORPiuEM2FxxM17TjQAR19s7vNv6TpOya3u2O1NEx6mWNkiqVwZB9jXgPHeZbyHx9rNgdTLiKBd6KDz11pvs+42tiYRUOoh445EzHIH/IAW3l9vfgoRG+lPb49zlr++wlOTPacyDLE0mQ9qMa0T9nzeWdyygR2lTBvYmVnRT01o0ulXmO+VgA8Smw2ukqvIDpnB4SEW5KVUW+KErINSgiYVW9Kb+4fCSLl3OmMJiK4CYm7EmD3Ij25bwx2LOyieSNErLbtPVlL2mHceoDmyTbWzfJH7x1aiU+/bs8hzTP0NQJ/gIatfEjlLZmixMSHHoOlGpThOtGprZHxim+uJEDhds1JKGvpbEZYa+Zyx27C5bKPEGKSb4w2/fqE6uNP0LQUu/Vo9eir859wL+nfxuTCu6L0yF/gVp5AOwGMz4Hlx+l29FJQ5ZgFvvJ5dahZiVsOsbyfUhSPZ/jRaZs9Gb9kJFH14Y25pqcGn+diM8iZV0AzolF1wzvkroSItH/GpTN3lWFSTkb/tvPT9zUjxMTDeKGK8OeCBCvylX/uMYnEbilbO/MEDrijBCvuuacfWV7mvTP/6TkQUg6Ku7zcMdjH7+QYAau4HOBaPv4kPRHPi4thAnsnK2KX+NtsEHlj1wvp/NQGTBRo40XybYuaItRR26APiJG X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5df0112c-45f7-4b43-2214-08dcb5e2bb79 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5005.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Aug 2024 06:40:59.4502 (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: eZ7P+od+H2XnmfLZypJhdmKl9ocnvZkfQFNzQ8Nc91X7oQ5tJ5Kv/+1QA8bFgV5jR9X/bGa6tOT95xQkgMukcg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB6912 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240805_234114_222470_31272385 X-CRM114-Status: GOOD ( 11.62 ) X-Mailman-Approved-At: Tue, 06 Aug 2024 13:40:24 -0700 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 From: Carlos Song According to I3C spec 6.2 Timing Specification, the Open Drain High Period of SCL Clock timing for first broadcast address should be adjusted to 200ns at least. I3C device working as i2c device will see the broadcast to close its Spike Filter then change to work at I3C mode. After that I3C open drain SCL high level should be adjusted back. Signed-off-by: Carlos Song --- drivers/i3c/master.c | 12 ++++++++++++ include/linux/i3c/master.h | 16 ++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c index 7028f03c2c42..6f3eb710a75d 100644 --- a/drivers/i3c/master.c +++ b/drivers/i3c/master.c @@ -1868,6 +1868,12 @@ static int i3c_master_bus_init(struct i3c_master_controller *master) goto err_bus_cleanup; } + if (master->ops->set_speed) { + ret = master->ops->set_speed(master, I3C_OPEN_DRAIN_SLOW_SPEED); + if (ret) + goto err_bus_cleanup; + } + /* * Reset all dynamic address that may have been assigned before * (assigned by the bootloader for example). @@ -1876,6 +1882,12 @@ static int i3c_master_bus_init(struct i3c_master_controller *master) if (ret && ret != I3C_ERROR_M2) goto err_bus_cleanup; + if (master->ops->set_speed) { + master->ops->set_speed(master, I3C_OPEN_DRAIN_NORMAL_SPEED); + if (ret) + goto err_bus_cleanup; + } + /* Disable all slave events before starting DAA. */ ret = i3c_master_disec_locked(master, I3C_BROADCAST_ADDR, I3C_CCC_EVENT_SIR | I3C_CCC_EVENT_MR | diff --git a/include/linux/i3c/master.h b/include/linux/i3c/master.h index 074f632868d9..02e4f47f9d01 100644 --- a/include/linux/i3c/master.h +++ b/include/linux/i3c/master.h @@ -277,6 +277,20 @@ enum i3c_bus_mode { I3C_BUS_MODE_MIXED_SLOW, }; +/** + * enum i3c_open_drain_speed - I3C open drain speed + * @I3C_OPEN_DRAIN_SLOW_SPEED: Slow open drain speed for First Broadcast Address. + * First Broadcast Address in this speed is visible to all I2C/I3C + * devices on the I3C bus. I3C device working as a I2C device will + * turn off its 50ns Spike Filter to change to work in I3C mode. + * @I3C_OPEN_DRAIN_NORMAL_SPEED: Normal open drain speed configured according to + * I3C bus mode. + */ +enum i3c_open_drain_speed { + I3C_OPEN_DRAIN_SLOW_SPEED, + I3C_OPEN_DRAIN_NORMAL_SPEED, +}; + /** * enum i3c_addr_slot_status - I3C address slot status * @I3C_ADDR_SLOT_FREE: address is free @@ -436,6 +450,7 @@ struct i3c_bus { * NULL. * @enable_hotjoin: enable hot join event detect. * @disable_hotjoin: disable hot join event detect. + * @set_speed: adjust I3C open drain mode timing. */ struct i3c_master_controller_ops { int (*bus_init)(struct i3c_master_controller *master); @@ -464,6 +479,7 @@ struct i3c_master_controller_ops { struct i3c_ibi_slot *slot); int (*enable_hotjoin)(struct i3c_master_controller *master); int (*disable_hotjoin)(struct i3c_master_controller *master); + int (*set_speed)(struct i3c_master_controller *master, enum i3c_open_drain_speed speed); }; /** From patchwork Tue Aug 6 06:48:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Song X-Patchwork-Id: 13755292 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 4E962C52D70 for ; Tue, 6 Aug 2024 20:40:26 +0000 (UTC) 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=W6QfaiaOIs7u35P5nKicvN0TMtDmqoYUyRb5EbYZO9Y=; b=zt/17xpZXotfHk LTigmnqB0Wq6lD/Cw8cbAfEBNE4BTCzD6ieEZFjcY0vgfgt5VEg25AyvFrtypAXQhTkk9YCI7Q3W/ AECxnq9oMkkeEtdDkxfNOz3DBckGFycxRJ2AZIq7BkQ99ve5WPP6mIxqhnj+XXFqq7UT2O8oGaha6 QW6wtprD83lRQ85KzeGdPMd1GqnOnqolD16DrVc3v9MCFvMzMAD/5WNnyuTHiG3FWx8t5yIh2T0KY kVYxP5/Q+V2Gqz7nDuAqJD7+FGoYPHkmoyLMR4dCeC4cmLIBcOvyNJvRrtDFczgPYu7KJKDzaPVw1 2Pj0XIgY1nacXkxzG3sA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sbQyn-00000002qHT-3pqn; Tue, 06 Aug 2024 20:40:25 +0000 Received: from mail-db8eur05on20603.outbound.protection.outlook.com ([2a01:111:f400:7e1a::603] helo=EUR05-DB8-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sbDsh-00000000hKY-3YVO for linux-i3c@lists.infradead.org; Tue, 06 Aug 2024 06:41:17 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=BunZl9NgqadfgDKOPtm7o08o7sU/ijmS6sKqxjj/Zy6c4AcFMtdYLSiIuG28Ox1PoZtmpqcSPOeKgVS1+bJS5a2zh+kNlGATnonRolLVS0u4B/fz/5RD5Osh4fDe4HH7y8rIhTSAGGNJtIH8sbZ1D58680oLnICI+wkT70+GBMMbSE7jyPRg3poqB4yT5CBOCK958+cgVF2tTAedBSJaa3VKhbkgS1AbI74yeK+Pnjr63QjWd4Sr24X0RwCdiokPe7yj9K7zgh6pnW98XQlG1IcZ7kwKm1XVK1JLBUoFunykGULnC/lI662BexAxju9N3q1YmgXIj4dh5IW8+puj+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=HjSRBH6HICk+8sMLXJGzYuvzBGfIO1amZRqN2268VWA=; b=pAd4TXFaXBQOvbDVXkxJvbpisFT6LHMuTpNO9l4SkmbVh71r42s5U8K+rMuQYVh1bDT0COFiDwN2SFqYcQ/jDSXD46EVmKcNTF7Lxyz1RJ7w3cdhGSad40hRL/UqZKH6jFRucXSpyPkcQTlLHBAHvdA4AIvBVusmP27J2Hks8mHqS7f9lKhd7CENffedtjtpnpy3g/lknd1aDzfTaKzwvnLCtKHPS0o6qmGpJ8svnchELCZm6UOktiMK6Nda+bASMhZqaapXuwDC7ao0J/WRfkiN/bjEIWDO8dxV7//Xb4rZhbzbUhsmaOePxuQoQNte8+RANTNCx6KveSeffLPOQA== 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=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HjSRBH6HICk+8sMLXJGzYuvzBGfIO1amZRqN2268VWA=; b=EVMjfsKwInPcFUVV/I970WRxmdLGhnrS+dZI4Ym/QhxremnzHY9NmzW1OmqA7wXLr0EsE+rqa7X6H/FeyBzVi9fctqXaanAZhzb/9W+nlH+QQoo5jj6CccYLjf01+/xBWCGUhdZANg3sf16gXFb6/aFUnb3rL4vQl6qevy6ogWGKLlh+yOViW9hcoKdLzXtOFj6/gwVfh3xxDvK3KE5062Dw3sAs6OGhy/PVZXDGFd0TRz6PQgJRw03CwTO70j5IoWekr3oBzgpMxiplMOOMY0V9rz1Pa0Zj8dkK2R0BYsETr9y5qP40AkbPkt5fRJs8fm2R7V3hiJg4g6WJSGUrsw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5005.eurprd04.prod.outlook.com (2603:10a6:803:57::30) by VI1PR04MB6912.eurprd04.prod.outlook.com (2603:10a6:803:134::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.26; Tue, 6 Aug 2024 06:41:02 +0000 Received: from VI1PR04MB5005.eurprd04.prod.outlook.com ([fe80::3a57:67cf:6ee0:5ddb]) by VI1PR04MB5005.eurprd04.prod.outlook.com ([fe80::3a57:67cf:6ee0:5ddb%4]) with mapi id 15.20.7828.021; Tue, 6 Aug 2024 06:41:02 +0000 From: carlos.song@nxp.com To: alexandre.belloni@bootlin.com, frank.li@nxp.com, miquel.raynal@bootlin.com, conor.culhane@silvaco.com Cc: linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, linux-imx@nxp.com Subject: [PATCH 2/2] i3c: master: svc: use slow speed for first broadcast address Date: Tue, 6 Aug 2024 14:48:51 +0800 Message-Id: <20240806064851.2425797-2-carlos.song@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240806064851.2425797-1-carlos.song@nxp.com> References: <20240806064851.2425797-1-carlos.song@nxp.com> X-ClientProxiedBy: SI2P153CA0002.APCP153.PROD.OUTLOOK.COM (2603:1096:4:140::16) To VI1PR04MB5005.eurprd04.prod.outlook.com (2603:10a6:803:57::30) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5005:EE_|VI1PR04MB6912:EE_ X-MS-Office365-Filtering-Correlation-Id: e2926492-bc41-4217-fefb-08dcb5e2bd45 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|366016|52116014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: WbzwdgkJWNAU/iHJQQc3rX8vl7QR4PitPdrnFlCoVsoJYYADgXbNcC3f7bsAdYVVA5ANFneNTyRKCPq5XnfJem/c10KDOOHnLIW10D0O7VAE/SLfUZ+uGxZ+fNT/9kYNQzQgHye+sdXWFmG0B/W2FdOE57QvhMr79CgRNl2Kvfxv9/gNxOdmIfXIVDrPZYjEhkR/ycsRPpD1MIunNOTSAiQU52jPfC1GOSTbtOwZujmur8gn1XXgG19FBiGyMGzIpk6d/H1pFN6qbh2mZm5RjjHhgmNieWxKFbJdbXAPoeGcnLbFd8wyNrR9AKLHvmlirJBlRRg/bajkdK7jqX3p7bDUW6EVUDe/Wx9JaDPDK+PnjeIiImvfeDN/RmTHYz8y1l8tl3g0EBjdCvUMsTwpWLKU5rt4jUw6Lq8ERnUaNfE/yVuF2r7LTot5NwWm9XcjUY2S8cmARdFJ0VnAWuq5jf2QDQSQgvrtpd9OrAMhvXtYTMz6EWHqc77zXtZJ00yTte9TUCnSXp2MGaYjdORc5iRnQg69cYX3unJn4+FS+Y6imwP5UeeKYCBnOyeFJOcXORr3USVSfS8lcRk71uGuPoD7Uk0P8RUGvPqHNicvCLTTJpDbh2JKw0SqK+S2hb34KbwismgOtbNQyl+Hfy+xUCfnx0xq28nXjG3iTsiwY5ARVwAi9i9cpK5RdwD9+MwmgpraAXWyy/cOb/ZlX5stQluXeC/FBRkqCmvZYBh5qLf0wNd3u3mcHb+j9OsBKB0RIiXFxt4L9xRVsD9ti13do9ZJAkBl8djWeFR+Gjnt8z8J35vyM5SVuFuj0p2pKTTkuTLBpxWMdgHjnw6MSJjF9zJskLDZY+uELoIP9UIGUt5RQMRJs6C6snfBfkclgLpBvL7ERaYgse2L1emvLcwzr2xSgc9aB2yTyB18GbAN/EMAvPXk8ywVHxKmwBS1BRsDxwW1VQkJ94xNb9DmdBYTNY32G/UIHS3nSbCBYkEGGLbVjRsrIc3YcwrMtBR2NFU3zoQySVgKRQbbVhtQea9zdDRqeDQ8cJBLcv/zHued2njOpe6iTHM9UM/kwVnhne7MvkvTTIZg0XdTHZupYD/XemAgTIBvWvVUlDww7bfPhk7CljKEjRS+pcdaisO6DJyCR+HaidSZPER8PZ/TR7ZE4Z6Z5yY1hZ2DYYnimX2j2IideC2wdzH+uosasnRzUwVMZBrRyCXIW6K/0YliWeifZbN6UW9BES7a76Nk9ghtb62BlbzwFcDH2yVuBnBgjOSs5S7J9E5/SKmezCNnWwYK5JMcizf/ZAUUhAQX5Paoz8upelF0DEFcpYLesTptYNWlhjuFeHIpeYYcr9AOuccW0NJ6VXxjrrBpSnoXyLsnSXoxwD6jQp4uAI8Z/1zrBx7CfGImHx140gcrcVRdrNSj6Q== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5005.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(366016)(52116014)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: H3LZQRRDNBMcFXDLUoXLQLQ2jxsjoPCAt8A8fA7AuXsS7kF9k6XuKxarcEbF7q5XllrnFB/kwj/o4DJJapzzUfZnJtfYYRreY7JypexOm8w8ZmpDStaAezStYNi2eu0DunGhcPlZIJjdfK7DrMB8OQLnNA68mALAwmMZxvUS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MS0+UaAHcs+2o97P3etbR8/O/dQJn0fbHWad0uGwfYpKn1gjuQ8gLUsGBzgmejOSZRh+cb1ZAX3UuaOEXxkXscTOp01MUYISOtimoWlPAwGZZG7vYjAVa7Mco/Dfl7ZoWdjt87g3sIFlS2NKF3eUM302Zft3R4XAstGvohXyz20my8bAv0ZoaT+NwrMc/kz0hk4gNtJvrBpXvk4Y65Qx36EHK+Wtzo4jdRxP3ss01Gmb0upWM1b3i7VKP/uGauxPyXowGhfUHO7NJEjX6kUJF/SlATAuWqofisEi8v8CamxqxpJDJWaNIlfvlM2W413RsseHov9O+A6rtmURa X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: e2926492-bc41-4217-fefb-08dcb5e2bd45 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5005.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Aug 2024 06:41:02.4286 (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: QpgwOrbNlRYBGnoTscVJGHOHv9XBctYPPsEhtIPdd07054LrCABjDoYDboGzMvmDWWbq8agmYzMRSwEzy70C/A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB6912 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240805_234115_920089_180593B4 X-CRM114-Status: GOOD ( 15.90 ) X-Mailman-Approved-At: Tue, 06 Aug 2024 13:40:24 -0700 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 From: Carlos Song I3C controller should support adjusting open drain timing for the first broadcast address to make I3C device working as a i2c device can see slow broadcast address to close its Spike Filter to change working at i3c mode. Signed-off-by: Carlos Song --- drivers/i3c/master/svc-i3c-master.c | 51 +++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c index 0a68fd1b81d4..4cdce25c5cf7 100644 --- a/drivers/i3c/master/svc-i3c-master.c +++ b/drivers/i3c/master/svc-i3c-master.c @@ -212,6 +212,7 @@ struct svc_i3c_master { } ibi; struct mutex lock; int enabled_events; + u32 mctrl_config; }; /** @@ -529,6 +530,54 @@ static irqreturn_t svc_i3c_master_irq_handler(int irq, void *dev_id) return IRQ_HANDLED; } +static int svc_i3c_master_set_speed(struct i3c_master_controller *m, + enum i3c_open_drain_speed speed) +{ + struct svc_i3c_master *master = to_svc_i3c_master(m); + struct i3c_bus *bus = i3c_master_get_bus(&master->base); + unsigned long fclk_rate; + u32 ppbaud, odbaud, odhpp, mconfig; + 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; + } + + switch (speed) { + case I3C_OPEN_DRAIN_SLOW_SPEED: + fclk_rate = clk_get_rate(master->fclk); + if (!fclk_rate) { + ret = -EINVAL; + goto rpm_out; + } + /* + * Set 50% duty-cycle I2C speed to I3C OPEN-DRAIN mode, so the first + * broadcast address is visible to all I2C/I3C devices on the I3C bus. + * I3C device working as a I2C device will turn off its 50ns Spike + * Filter to change to I3C mode. + */ + mconfig = master->mctrl_config; + ppbaud = FIELD_GET(GENMASK(11, 8), mconfig); + odhpp = 0; + odbaud = DIV_ROUND_UP(fclk_rate, bus->scl_rate.i2c * (2 + 2 * ppbaud)) - 1; + mconfig &= ~GENMASK(24, 16); + mconfig |= SVC_I3C_MCONFIG_ODBAUD(odbaud) | SVC_I3C_MCONFIG_ODHPP(odhpp); + writel(mconfig, master->regs + SVC_I3C_MCONFIG); + break; + case I3C_OPEN_DRAIN_NORMAL_SPEED: + writel(master->mctrl_config, master->regs + SVC_I3C_MCONFIG); + break; + } + +rpm_out: + pm_runtime_mark_last_busy(master->dev); + pm_runtime_put_autosuspend(master->dev); + + return ret; +} + static int svc_i3c_master_bus_init(struct i3c_master_controller *m) { struct svc_i3c_master *master = to_svc_i3c_master(m); @@ -611,6 +660,7 @@ static int svc_i3c_master_bus_init(struct i3c_master_controller *m) SVC_I3C_MCONFIG_I2CBAUD(i2cbaud); writel(reg, master->regs + SVC_I3C_MCONFIG); + master->mctrl_config = reg; /* Master core's registration */ ret = i3c_master_get_free_addr(m, 0); if (ret < 0) @@ -1645,6 +1695,7 @@ static const struct i3c_master_controller_ops svc_i3c_master_ops = { .disable_ibi = svc_i3c_master_disable_ibi, .enable_hotjoin = svc_i3c_master_enable_hotjoin, .disable_hotjoin = svc_i3c_master_disable_hotjoin, + .set_speed = svc_i3c_master_set_speed, }; static int svc_i3c_master_prepare_clks(struct svc_i3c_master *master)