From patchwork Tue Sep 10 05:16:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Song X-Patchwork-Id: 13797955 Received: from AS8PR04CU009.outbound.protection.outlook.com (mail-westeuropeazon11011054.outbound.protection.outlook.com [52.101.70.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4A56F745F2 for ; Tue, 10 Sep 2024 05:07:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.70.54 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725944861; cv=fail; b=WOJe+6PLh9U1UHmpvGIkRuGBac0C+104K8jU3/WJwlG8bMUeSBWMyC7o/EmptGPuLzKVh/AOfa3LodfU2AU3dhaOiqFob0q4vYQdGKeVfH3xHEw2zBtwB9RzJErgj7w8QSR1TfsQum/cbw6gWDQhF0+L7TUL1VmGQjElWgHzsy4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725944861; c=relaxed/simple; bh=3MVDNXQSoZgsbtBYxX9n7GXp3B5h2Dm5cODXsuwQy+c=; h=From:To:Cc:Subject:Date:Message-Id:Content-Type:MIME-Version; b=WvGjyaVX+7mAnSfaP4OUbhYGqo1Lyq+hHkcX8l3g9hLo6+dSgDiVS2DpqwfXJOI2MgVoqYw83EffaRIiv8UI1X3B97Lio3uN/dTnNd3vGqTepIE//T7Mbgq1wPGPdOBUeoOdkssHDfWw2lexojuePZ5EG8c9I10ZDS7VYsn49Go= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=VYIsnskB; arc=fail smtp.client-ip=52.101.70.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="VYIsnskB" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=vX5cpqT/qM8WXdhow+v7aJgv5B9OpmI2bobPehkpZ+z1tgw3CE1LzH6h69SSEwLd1qvPVYRVfD0lRHA/j5w1/QEYqtS9vIUt/+CCyrQ8mRyn/b/v06N7v9znHJCakPzhbxpIwiPuLcZArH/gE5Zf+vmOYljVn9AcwPobv+lVuqBoGm+PfWy2VRNWHlo6P5Y/w14jeaSfHweB/sZ2psJLIT0EiZ7QDDs4BscXE4LPZtXF/RywAPuoA1whmGfx3JHDPumikOvo+3lwmG8boHK6PNNkm1TnmoNyPyin5CIEp1t3Ra+Bg7Zv5vTj+3E/kmSrkPqXMfchsyswHBC9dsi4YA== 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=SLXvFcXqaV8OnaBfbT0OdUDO3x8JowFD99/xqDUU4Oo=; b=QMCrL0/lIExB0g6+Avh6xgoas6tbTOa/asI6BVAJ92si46IXREeD5mf5Kx8xjZpOKb5/fQ6+qD47yNgRfsgKZqeHuO7sEawHDZZUZjtxHew4tLm1L0a2FjFEKIZj8DNEEcXWowdsy7WSCv5JVaab/O7QLV4E8M71ZpwB2V6wG7SgAus6JGp8B9aWPm/XAW+vymX92RRU6IYdCY0VQd5WIdE0Ou0NV7I6LjCk1Ferpgnl2xr/94vov9/2lRcT0uEt0QeKZD6JNqy12oNtlWaz1FREcqSbnGLwt/oqRa0EBfXOvzc2lOMStGFr8BVrhq9ir8vqsRhULmNGOZEvA/nJPA== 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=SLXvFcXqaV8OnaBfbT0OdUDO3x8JowFD99/xqDUU4Oo=; b=VYIsnskBAytSJB2AT/kwGokCXITLHfI7v8drwfpE8iIU1HGTlKUtQpCikRQRa8a7qPRNn2oQ/eePbZBU6xyq08IooVvVxix4ICcRbH3E9cyTMKB4xBIyWhxKmSblRKHy39fiJPhw1H24rSrroHjnX6zQ9tKpg0TEXL06bWMoYW06YbEBUNc2BawwYki52gDTFtHc0hQu4MK1Iq/9Xk3hgonWouN2GUKcPPsRoxbKN1gtPpEgDGd7SavxBnf2z5/Rr5gwMR85/foyLvkuHPQF9CAiYSQWySNPMpuPrfFT+zaVmrVQHYI/8CKJKpWyqpYhpH6VeDHVbVwsha9lk+bX9A== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DB7PR04MB5003.eurprd04.prod.outlook.com (2603:10a6:10:1a::19) by VI1PR04MB7134.eurprd04.prod.outlook.com (2603:10a6:800:12e::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.23; Tue, 10 Sep 2024 05:07:35 +0000 Received: from DB7PR04MB5003.eurprd04.prod.outlook.com ([fe80::68ea:5937:4fa7:db2b]) by DB7PR04MB5003.eurprd04.prod.outlook.com ([fe80::68ea:5937:4fa7:db2b%6]) with mapi id 15.20.7918.024; Tue, 10 Sep 2024 05:07:35 +0000 From: carlos.song@nxp.com To: alexandre.belloni@bootlin.com, miquel.raynal@bootlin.com, conor.culhane@silvaco.com, frank.li@nxp.com Cc: linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev Subject: [PATCH V5 1/2] i3c: master: support to adjust first broadcast address speed Date: Tue, 10 Sep 2024 13:16:25 +0800 Message-Id: <20240910051626.4052552-1-carlos.song@nxp.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: SG2PR01CA0197.apcprd01.prod.exchangelabs.com (2603:1096:4:189::8) To DB7PR04MB5003.eurprd04.prod.outlook.com (2603:10a6:10:1a::19) Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB7PR04MB5003:EE_|VI1PR04MB7134:EE_ X-MS-Office365-Filtering-Correlation-Id: 4a49e9a2-b6ef-46de-6d99-08dcd1567b13 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|52116014|366016|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: tv3ADf5QxFVUY4BUfZNhU/20p589kn3PTdYolBMnEqseYaKgggXvgh9nfRX5Lcwdwx/A+Iexi5gMzf2Z0Auxnp/8GhjB5WuA9LkFu4gcX+3BE1i6zZoZaEOcevlV9uMoFen2V55ATg17e8+/5lOTsyP5zeAki/al9cIuyJpZTj/9ZqjStgGVP9xpr/SdNuNbG1MVT2zgFSxiH4q4FV2nSAxElI5EZt+M47F4sfu9sL1yujUhqVJ9rtdk9iP+HQbyXGmT1YDH9qspyCAHSghn8WFuAGaUUhkfpVBVslyofQm3ke904Glj1wNTBi2FzCbDKlxnSQ0UOh7XS3X5kO1Woeo8AohvEFR3jDrlLrRtqnzk6t7MfIpjbBQLrzf0IIo/pumjbpDXiaLw6u32SZ7arL2Am5xN/pH/3/N45OlAZfjN6zJILUzQ2sH2DNIB0GD+x/SGtPpO/ZyT3DA7roTmmBEny3OOFPCEus9lN1pPs+Dquaubdh7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dzHTgw1pb8qznROgI4+xSzVTeh0uRjqfsFTmIWBLGUEkO+xxwdzWCg81AeKiGxu3jbi9C8bP8guPwh23O6ODvOu+kw+ahIPmz++F8+92+4lhWygIhDXLz/PFRQBM7HenVvWOSAa1c0MTwl3e4pDKLghMpzW9HxObUhITdHoufK2gcBKHFGJ8TpxzPMzFdlswfTpZXxWGNHw6tc/vLlkV9pF0UxUVTt7SxhwPP75QlnALntlwJ2Z+oLasZHknGOL/2+TxnKUcKIwu98cop+yZL0+9vvIGXJr33FPE6l8Ge+E06rzmRo+w2ZlSFTQXXIyI+Pez4okI/jpLs5xDKLXg5kfUo+YAKYITDg63JbKidh4qaqaUGLQ7VlJfMGH5buq+B8MsWsyBbUiORj/5rXQA5I/M3qSaABqoSq6rTQP3B/JmvObOR6Op0pypQnerJpyYXOCvV3Qu/Pwo/ja9qVMqPkPnmueSC2SSDKuwOcjm4GJXnvWSzpBdx+WhvpzTT0/HEXT3V5HR3Wl2edtaqDVFK5MYbJCQuuQmZ37kFvIQ3sww7lS01xc1kCkDLGKhe3x/20E5juWPj4RxaD3ZcgVzJ4/F/0b X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4a49e9a2-b6ef-46de-6d99-08dcd1567b13 X-MS-Exchange-CrossTenant-AuthSource: DB7PR04MB5003.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Sep 2024 05:07:35.2017 (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: bwbQHt7AxKcuND1XtjPbSrPNQyKtmNFo2UJB/saTR0kLr51KVq14gUY2yNYCtdyDDSoZtczQTery+ByIJxhk3Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB7134 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 Reviewed-by: Miquel Raynal Reviewed-by: Frank Li --- Change for V5: - No change. Resend this patch to list after subscribe to mail list. Change for V4: - No change. Send this patch with svc-i3c-master.c fix patch. Change for V3: - Modify comments from Miquel's suggestion Change for V2: - Fix set_speed description from Frank's comment --- 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..2a1ed05d5782 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 sending the first + * broadcast address. The first broadcast address at this speed + * will be visible to all devices on the I3C bus. I3C devices + * working in I2C mode will turn off their spike filter when + * switching into I3C mode. + * @I3C_OPEN_DRAIN_NORMAL_SPEED: Normal open-drain speed in 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 Sep 10 05:16:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Song X-Patchwork-Id: 13797956 Received: from AM0PR83CU005.outbound.protection.outlook.com (mail-westeuropeazon11010015.outbound.protection.outlook.com [52.101.69.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EA4D516DC01 for ; Tue, 10 Sep 2024 05:07:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.69.15 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725944867; cv=fail; b=rUv+ISOOoFlMYA3zCJCzt5SxlKpYd4XliXA4TKdY72AeCMfMn29wMXX6Kzbuir0OhLAH9CDKwzKOt/jF58SP6pCf+tvBUYqZrsbqyS8HoN2U0DI7TcXRf5PkgzbM/JaSVSPmm7E0PM+z3F/vU2Twn3MVeZYtYZ5dQqEuwHmYj/4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725944867; c=relaxed/simple; bh=t0Zc+A2q60SYhtENJKabRYeuD/zhjX964LpXpAEr2Kw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=YEt9qKZdEM/LEcTL9U+tE9rNu6Jj15tS+PSzoZbN+s4SAdINW8VUDcO/tt8pJM2/WAEB21s4mj4tBYurRS/xGm6cP0s/GYmiaRGCHUPVETGhFXsI8qEJVjfgqdpmCG3fs/cn+cW3ZwcCRNzemKWWPQRzkHvbbNR6Vk+P/JYATFc= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=gWKhufzA; arc=fail smtp.client-ip=52.101.69.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="gWKhufzA" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=FyFy/9Kem+9Q1gvQK2T4Q2aKYslVuCtEL5UNVlpGsYP+R/r26r1jhyDSVYiCNy989GquynFgNnirc55L/LXBweuxM75uU4ppXCKRZnJx3fYAbdAevIZjHlxGmRn+vXalVj4/+W4bbPKmamtnpEeH6/G/xuQgFs9hzi9W6AHzeIAfzIvtzag+KeFSJrs+ou5BMNlqy5bEl8eRRAdz9sJKxsYpKqTF91FUp+4T8hE5SuDOVgp+st8J4mIe8wbEtsRJ6tJb3hj1f8BB/ckGxcYcVTB7fENym0xkzMHCjPcCXrqyfevaH6HT4mwfOMzSBYxfprajLwN9uxk6unzX/TekgA== 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=7jgYPtL5RXLvu2IOq7Dn3zXwwd7MgHjU4MVS06875VE=; b=BXY9BJ+vjYJ0Pg3R7JNPwirZF6qGJRR6iScmgRzAdX0n74I37USmRVTbiLTueOCwpqp/OMAdB/klHcft6ZpURoYMiMFjsjQ+/T95W0SyhDFYCkmzfM2s4o8f8P/OLd5kZa0VX1Hnn9kvNpoCaSfTL4YMTwW/yBDdowlvwNb2C24Aquz73cMIFYeO+w2Tzbkds6NrEFWcAHtp5GdizqIlEVKkGzWtky92LyewNUrf2orjOw9SVoYj7psilCFmfE5cx0pxX4lKeFlJTBQlUcjI3s9KG68g3qFSdwV57vpQkOnr8gvjssTTnwduMpeFQ1eAjyFdGWKpiIJhx/GTDJFr/g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7jgYPtL5RXLvu2IOq7Dn3zXwwd7MgHjU4MVS06875VE=; b=gWKhufzAcGGz9lE+8X4y54ubk+RpJc36q02PNiiNkGpkri77r5ixwVhes0G7AHA6iVaMqUnBdooJ5qgP1cgiLsNbwQpK1z/DArafnLlGbPEAIP9F6qDqGbJ1LQiLxCpU5634Aq7UBR2rgCW/1m9OoD+nSsj9Se+P78+ZlY1FkchrxkzWyl8v4xtLivKs74Hrq4a2DaKSUuU+LDGw0vJU7Qy2tbzj0LoJtCjhEvXYCqWbijN2+6zDHLiW/4rlXbA7uBgrevWrgSHe0uFCsGaDazWYM3uDV1JEhYrXROvfcKuaIdcZg9xLKZ7ukNbIkGiulehOBtgcGsv5p40hI1Rk8w== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DB7PR04MB5003.eurprd04.prod.outlook.com (2603:10a6:10:1a::19) by VI1PR04MB7134.eurprd04.prod.outlook.com (2603:10a6:800:12e::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.23; Tue, 10 Sep 2024 05:07:41 +0000 Received: from DB7PR04MB5003.eurprd04.prod.outlook.com ([fe80::68ea:5937:4fa7:db2b]) by DB7PR04MB5003.eurprd04.prod.outlook.com ([fe80::68ea:5937:4fa7:db2b%6]) with mapi id 15.20.7918.024; Tue, 10 Sep 2024 05:07:41 +0000 From: carlos.song@nxp.com To: alexandre.belloni@bootlin.com, miquel.raynal@bootlin.com, conor.culhane@silvaco.com, frank.li@nxp.com Cc: linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev Subject: [PATCH V5 2/2] i3c: master: svc: use slow speed for first broadcast address Date: Tue, 10 Sep 2024 13:16:26 +0800 Message-Id: <20240910051626.4052552-2-carlos.song@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240910051626.4052552-1-carlos.song@nxp.com> References: <20240910051626.4052552-1-carlos.song@nxp.com> X-ClientProxiedBy: SG2PR01CA0197.apcprd01.prod.exchangelabs.com (2603:1096:4:189::8) To DB7PR04MB5003.eurprd04.prod.outlook.com (2603:10a6:10:1a::19) Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB7PR04MB5003:EE_|VI1PR04MB7134:EE_ X-MS-Office365-Filtering-Correlation-Id: 913486fb-98ac-4e8c-6418-08dcd1567f29 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|52116014|366016|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: YRCNy1gdCjUlDh+GM7VDLiYe0UfiMNH7MVi5cd0jcv+z8uhFljaSnJN939U50xeMXia89/8pwRfZujGjcIr4a4h1+lJx9NUM1Y3Og5LZu2zMgZLveBhvm/fAmH5DSJr/k7AMgg6tMXbclZABbqmj5qzHB83dl04mbVfulYbfFEPCU/PHr0MOwpwOte7B9Lsz9+Onw20Ib4NnwPn0P9RMsurN1NVIstIRwXc/9f84SooorQAZAnPZwtQ2xFw1Hg2fbRxBKNcmt/sVtza96JyGxCiP8CPTv68ONcoEuHZul7ek/t/xIioHaGO3U+LD+DqEO5MsIFpDySfnnq7E1OR1MLewdpH6bCN633fnAEqpgYAFKUl0KPWHWrBk+rxjIekKlkxVuBNQeNyGII4qulAXRHCzs8oj2vU1zPPJ6rGnD+q+HQEkk9PdlhPPF/gwy9piuvNbX8D+x4AkM4i9B2yI5ZTa4vmJn4fZsrZAfKeEq+hc80T4REpKJxIyzMKfKz8klGuHqVuAI7np1o0Mt9Vdz1rNwUTQunaB98Zg/KY7vYSEez6Nmjhx07qODI6eZgAM78e8ZUwgwG3rulBNX0Hp7QvIwTKzVcRQpZ99/9QoBPcDrJxYgCAwkA1mCsEefJRbsAl+Iy6Y5vrqG0bf/85xUO1/NPR1MpyWa7dpBC8ohbDe7kimcxx87nthMG4K1BZwaq1BzcwS4sOmNMK+kl+ll35HR3IUxqdjfCiGHQCSogj2Gb3Qt8fvhvQv/hrPq9a6BYT9iW43gSzVTdPaBI2yk9eTo5iUDOip9cJth1tDd83kQ9Z+geMerE4o0LKECfO8ssKenMVjNrQypiuBbpc6PelGoInV2/y83QsL5uH+zGMore/BXI1JnOqDvYZXS/5ODwcbdsdLNyfbKfngTkkz6YO9q//TXkovTIvVDJTWLdCICh+dIIP44wUeiDwkyUaz5MO3jzXblhuTKkrDPBZx2/MJL9fHdYVxiB8ggsIlmoRtJ9h2VzVcEAoaQcz4cmds6w0p8iZH41TGVA2TQM1NXWA2cN9fiG6lIaqIrzPMMmytlo8iPh9S5Jdp4+2znyTeK03ZVspbmQKn6Sf5DMXhV2yYoiow18TjdIkb4S1nUDu+cs0JmKZK1pfw9KEzyVxDPYsSEajOaHGGg+2YySK1XfgBpNeJNteeaZxc0xt/fLck/6hSD5zNX8prL4giODU4HiOST97BjI6r7E/hkxztTb6X5NtJ2MqMkxzOvEBZHZvyZmIDb8v0IU6C2GiOfyvPTpe9dLpLii2PDstFJkPc7Z7ZRl7Jil7fhKN1gQuVoBe5QrzHxGBwOkP19t2HVxQgHPv8dFhbLIDNb/eVn4MeFyY8kyqII/44REr0d/olouucro5ren73wx3UMV30G/+I1RcYu4CsLmk9nL6nAO9k6Q== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB7PR04MB5003.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(52116014)(366016)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: sWhYhBv+b9fRYwa+AdRDcZhJ/ki2Xm6mPHekOk13YiPkl/OlzvAuoFwYudE8rYiYusfu1Nm3KWYX5skCJEqulGu7yUh3/3FFPYaBXtQXOoSO8ceZoAEABL2PzqDTqV8iAxQp3KgfvqrhVCvUJw86ey+IfPVW01M3Zw8T43fASa6wOcXf6GK5+amsUQcpG8qsuQZduDCXLoQ/YNAaW7qMSO5PkPXSwXiMZZ/LeDKiF3OWJ/6s+DaV2HQHtNB+XYsF1cAWbU+whVD6usP/jLHpeoGvIloLdkgEy/y6nRcimOcd/z19V+YykhztgpFIdo6HcMVhv8jVOGlsJ126h8/POm6p3cNooSmteoMiiPFkGEv9nDcJ0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1FRVUVJ8N8Xm7Oy11OWZrbObjILkwEY7NagAn1O2PTnFnePU8N0hQQhmpX0rK98ctIjM2VHc33UfsrNWYP8ux9RK1/1vI0h6F05HUeamFX59t7Zjsjm2y/CHPuHNsGARObF1yWmVxRX7EfwRsI/AJcmKfG X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 913486fb-98ac-4e8c-6418-08dcd1567f29 X-MS-Exchange-CrossTenant-AuthSource: DB7PR04MB5003.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Sep 2024 05:07:41.5801 (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: gCvUoyupMj1pgeRTpml5nwUwCHMTABB8mfmA1LQDQcLQMyVFp6NiThNj9DWno+5WhsFo//RzANEpx1PHd46T1w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB7134 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 Reviewed-by: Frank Li --- Change for V5: - No change. Resend this patch to list after subscribe to mail list. Change for V4: - No change. Send out together with I3C master.c fix patch. Change for V3: - No change. But miss sending it with I3C master.c fix patch. Change for V2: - Adjust variable definition order - Add mctrl_config description to fix build warning --- drivers/i3c/master/svc-i3c-master.c | 52 +++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c index 7c30f58e344b..423db3dca257 100644 --- a/drivers/i3c/master/svc-i3c-master.c +++ b/drivers/i3c/master/svc-i3c-master.c @@ -184,6 +184,7 @@ struct svc_i3c_regs_save { * @ibi.lock: IBI lock * @lock: Transfer lock, protect between IBI work thread and callbacks from master * @enabled_events: Bit masks for enable events (IBI, HotJoin). + * @mctrl_config: Configuration value in SVC_I3C_MCTRL for setting speed back. */ struct svc_i3c_master { struct i3c_master_controller base; @@ -214,6 +215,7 @@ struct svc_i3c_master { } ibi; struct mutex lock; int enabled_events; + u32 mctrl_config; }; /** @@ -531,6 +533,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); + u32 ppbaud, odbaud, odhpp, mconfig; + unsigned long fclk_rate; + 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); @@ -624,6 +674,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) @@ -1658,6 +1709,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)