From patchwork Thu Sep 5 07:45:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Song X-Patchwork-Id: 13791845 Received: from DU2PR03CU002.outbound.protection.outlook.com (mail-northeuropeazon11012046.outbound.protection.outlook.com [52.101.66.46]) (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 9C5A5193069 for ; Thu, 5 Sep 2024 07:36:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.66.46 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725521818; cv=fail; b=OUwbl852gO1TlbUP7xGCCHWQfKOsoCilK0IBaPNgiUT414A6ggYOAiAhlc9/MpPmgf60K9InW0EAgPBJsRBxiQorkECCz38JY6JzR7Y37R9w5PCMFM3J4D/vNXr7/NsKxMShgheDgFNMudPRPBbvAY5ztYZIjJC1XkLrwY3fM1A= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725521818; c=relaxed/simple; bh=ja9f9nxxOxBZED56XqeDYfMeEC9anG3OUofDYxUJFGQ=; h=From:To:Cc:Subject:Date:Message-Id:Content-Type:MIME-Version; b=fUTJAECAFkynEHFz8mVU6Ws2+vdaiYbd8o6hbsi4EEP5kN3samDPy8yViIbhEVCuWAQRDcwl8r+OTTEHcjcA2RGMqzkex1eeKsbCKS0iv2Evr1NxpY+F9w+9CkCffcu5PmoVVXFsKikVlqhGij6HD/70DUaQDyyiXMycuV4L6/8= 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=Viv6Esfi; arc=fail smtp.client-ip=52.101.66.46 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="Viv6Esfi" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Uju+TmWcvChH+6QAqXDtnYuPkkwm8g5YbL/CtR8slChQr0H754YaWdaPDFZgP9NmcNnGn3+zCXSPvyKuml5k3WNqq3P4NvtSt83ckMk1qRSoRiwRL5vRqW27ZT56N2uf75XBZcpdk3Ty4gNfYsDEO+QZreWb41jBmGIQP/mi/zFuW1afeVwlP4ImHp819uRBCchz2qj+xT72kS7RpNr8H0qaqrNGSapa2JsluYK3OyZyEm89pL6uizpQfLqkbAdS474ptwK4UIqT3Od9vuUoziIDIt7JltWknjwI8oQO1lRFp+e0PDeZwvDe+E7Rfsbc2edtrNGADd+2Pn51LPdNww== 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=lniF3Qc/9VXKVYvkp8znNidReg3xMQWnKpjmqnmEmYQ=; b=BRuSo0Yn6VfC5nUiGWJ60IX70BJ1dEcBLKFU54vF7Z9TudSRL+BdhuHa8uFAOpTUg0Z/JGZn9zTwVm9s8b1fOR+g8o5uCnVSq3oo9D3yyo8myGm6ytMIV7rTuhBf4TgVqP4rSnfr2E3gJ1Ya02VVTYlO3Cg+f8owQEgq20wwYzD6haAwW5uTIBq54dmGiQeSp12MThMSLA57qldUqilnpYK95lXJH2lAxtgmHrhV6pRGfnHoRpdkT09Hcb20oBzKrQQqGHxwSKmFKuLndPuKzgshmqZW/fz+61Ih9+PaYaXFu1Xvzdgy6/4nyvmZeeYFMfwjo049YcPuO2uwgPRusg== 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=lniF3Qc/9VXKVYvkp8znNidReg3xMQWnKpjmqnmEmYQ=; b=Viv6EsfikEXqLuPG/5Zh21bU3f+6aDavHu0/+IU/qOGObA1x+fEP/YAWs/WOg/CxpGZNu0MnjZAo36AyxGFb7kcqzkrwbqRseoJKg0SCioXrBzHq1ItrxmoKltTf0b5BnE/NUkxmC8lRdGMt0DdfjcS35tvQ4PChWPGHaNEPQcr8QRc1SIHOq00G3pN+PeBZRnB6fzF0iLVdEmBrMqne7nDxP+7lbSHpG43NVfPz7cd7a46Jgw8TmzKauho9yUJyFsZJnEV4Q8ZqB0H6eM/yOkFBfX9AJ79xk1weV5BRqEuzeUnN0RDFtl1tyDNyGLuWoC/qhp/zLjrSv1qdfC0HwA== 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 DB9PR04MB8429.eurprd04.prod.outlook.com (2603:10a6:10:242::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.27; Thu, 5 Sep 2024 07:36:53 +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.7918.019; Thu, 5 Sep 2024 07:36:53 +0000 From: Carlos Song 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, Carlos Song , Frank Li Subject: [PATCH V4 1/2] i3c: master: support to adjust first broadcast address speed Date: Thu, 5 Sep 2024 15:45:56 +0800 Message-Id: <20240905074557.3810026-1-carlos.song@nxp.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: AS4P191CA0024.EURP191.PROD.OUTLOOK.COM (2603:10a6:20b:5d9::18) To VI1PR04MB5005.eurprd04.prod.outlook.com (2603:10a6:803:57::30) 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: VI1PR04MB5005:EE_|DB9PR04MB8429:EE_ X-MS-Office365-Filtering-Correlation-Id: 99239e10-54a6-4906-1122-08dccd7d829c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|366016|52116014|38350700014; X-Microsoft-Antispam-Message-Info: mKkTh5eBuma7U2fL8CnRprpyggq2JKb4CXuvG8vAis+fl06MPLD4FgF6wWFXPprdGFr/1Bb0/GmH6VnwNDvEq+bFL2QM2/MaZsCMBa3sof7WF54T+sbSlx8gdRRSR6gG/ZiUXvuvFQwB4BDnz66nCncl/4v/oVwoIsefhm9EvWOYWy2WYBv4+PGB0lbMarC5ZkNlS1Deem3hOuXLwgZRRKBUohkvVLfEVjhtS1t0MqP7RN31OuoJLTUdGoSLN3JpzGBd6udvfcJr9tsWptncGQhBaDw3muu39aAShHp96Wk3gg9AFHUupeKQeSkGAr1eQf1TAcCTONQ5ZVy2mhPSG6xOJdcAf6I90ZuZxtsNu+YObVtpv7sOrvm2NckLfSyBLVQMbcDxsDCiZGHZzAMI31PWMEXZWNHPrWA8lVyfb7MUWPfPD76gkW8hlTmTPTaaobHzzlz0ncB4mtSXo0arJ77pbLRb9L/ZwxcQ4O5kPgc9tu8yZfrJVFsS+mzkUP6gR3VKAdRazixHv424xMPJr8os/DNxhmj8xHGl1AMezmuf/Y4gJtEFOCeKDmNByQC9Iu6+MPrGb+Q0R5XDRPfPKOIO1/v76ezM2Qk313ioFMPF54Ex8fIDQdQR8L4Q4hspGWsF3iyoGOViGq3FcD7xhnarNg/QZ266t2WbLMZ1BmpLcnCZ+u33X9bj8n/vkFkNs8hi7RntEOVQQgstjqJbp1d2uicSyi181MmJBmrheG1IfxXo0P8vgYizO77wcon+HHakXn/yUZ/2gxaXdlf/CckQ70Nf6XggSrUTSjAXt7GLE92HpBhCnE3lwxgjrya2H7AF1StKXLoUqgdna7bkNIMSKyk1gg72oNf1vevQLvg94kGe2WxC2mrfizXNKLMAJ6j+2T3cZrJhvbnMrxXFMNQcg9lc9MsS8hlB9KuPTT8i8zo1IkKrzOYLYobs6Ww/U3BI2Ud1m5+dWzaEAj6MkZChFYRmVsynDIZlsAQ2vYevJShb2GEbEFFytHA4SLTg1lQC+iL/6FJUe+uxzMWPFwv51VkHtshkCsO0NYIhqK23gj9UpiJ1Utrx5UfPkUgPV+FIm+t9wl16JSwkYsNyhdBAvXr0ta1xGGBOtDYrAqpRTRi/3bS14EXA4yjUScpUinkb2aKRPFsVsnPQv74dZG9LlE0i/Mm4ettrF8w0TltqdfW+oCgDK1x2iZEXQoIKq9KerkNe+nkw/FbfGTMOGkuuPUqoA0vmeS1O+OERCGa8OKCHsjmOn8Z1vlbT+KvHeC0+p8VeP2IZvbXVSpGxK8bbalflatDaWW8iRo/TaUspFQEeg/yykzRWxj7iPyDG4sB02Z9tgDhnelQGxbvURfvxdYlTvQQkD+CsuJXME5VYURm+Etny9tA880d1XW+nom1h05F+FysudADtxZkWHQ== 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)(1800799024)(376014)(366016)(52116014)(38350700014);DIR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xRj7jw00q9PEh9I9VWi+ai17yCoEodIyTlRR27NrK5x6b78NhCqmmiOXZ/VM/RrFeyXrOhm9JUzofieEYv0W/d8EU56NU+ku3n5UqSGgkwU/k8W6e3ZicZbt5EM9c6TClYfCkQxoi5edScQxAVJfujkwrWdXKH8jyEZM/nH9Z0iSCFNPEsCHsqhE+bokSbk1dJ5oeI5+giaK1vF45Aeoupz7PjLggcAiMhoF4gmW+ueOaKwtk09DNsZkGPBI0aRpEVD8O7rh6JWW6sbcbsQIT2SUyS0LtEG5A+x+4C5WffwvpXXfZHHs037iCnc+FISDuoy6rypXWbAEoOQJwX0BKDFDecrSTjeyftjpMlXtsliSOQ+UDJel1ycB3T7k8HQC+CmJAR1rvzS+0HgLYFVRPZ3LISCoBP/iMudpQfiiPktT2WDncnc1Us50VOCjZeY4wrl1xOZUVw/S7I3Oa7dtCYXdURPVdq4JWmC+4AUD7Y6Uu7TJ/5YjPtiFTlN91Gkfkz1XF8DXtodtHRpVcXHp4zf5cw7qFSGVQSGEfnkplZst0V0MFU7E9gN6x3OqAaOwEX42sSZ/4WqGAnvn2cIi X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 99239e10-54a6-4906-1122-08dccd7d829c X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5005.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Sep 2024 07:36:52.9719 (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: T9NI1kUOQGA0b3s09Npfq8ZHnSrQUp+kvlJFAcsLx9tN0E2BNBKpiM/PF49c2xN4G2lw/SAyZwVmGHdR1X04ZA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB8429 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 V4: - No change. Send this patch with svc-i3c-master.c fix patch. Change for V3: - Modify comments from Miquel's suggestion Chnage 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 Thu Sep 5 07:45:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Song X-Patchwork-Id: 13791846 Received: from DUZPR83CU001.outbound.protection.outlook.com (mail-northeuropeazon11013044.outbound.protection.outlook.com [52.101.67.44]) (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 9DC9B193418 for ; Thu, 5 Sep 2024 07:37:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.67.44 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725521825; cv=fail; b=eKSL134QepOy1KPTtPpLBpKkC3K5UgWqbqd+DnR0nfBcgxXjjr88UENUuMAzYxLQMxrsLFyzjkGDIUBe4JyBNhiMfNYt243Hxl9Gx/0pFeTtm8RJ0eVEnFAz4fp0Kz1AQug2WgearD1oaYoOCvjUaTawKCbjRgm5G52oQl8BmBo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725521825; c=relaxed/simple; bh=CsUsnJy8ztpf35b0ZzvNRxsSC5u0/Y1KmIwlmoomrRY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=eD7dpZJsek0EaU4MVDKdQywTVSAnOXn84nLaSk1T/4ArKH5PZ05vsTYEnqgeEmiNEe1+7szQKhX5hZJgQKKHIS5O+FvUrlOEQyDFq1AE2GNEXOpDlNiCKwBrVjq7UTAlhqHKKNHeOf+LUQxfD77AiH7AmCK7Btq34DQ31sfF+b8= 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=CHnS8Pqz; arc=fail smtp.client-ip=52.101.67.44 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="CHnS8Pqz" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=YkO6KOvnuDtWg2c7Rm45rA0kdMjfVsOJeegVhYdVi3K7Ej3iwEGvPJr1J+XuPnK95t4BQl+cAarIu7pAqUkxoSoPr8PGkMBYuzVEOH5Fs++jApzE5YNW3sBsyLZ5jiOxOZ9gGmcqXw83XSirpVsenYOraKEpFYbiIMhIScfgfayt018RUnYXj5yQ5SjUWBo16WLxoUBJvhX9tD9o89qWzii46EnwSnLBXxMo4oUE1/2ZxGKKBy8O5vxmg4KEyc9nAgyxYl2l1u7oo6Kni8F+H4ivPR6zo2sAtA6uvSFsbEt9kRfCwhxEkjgxpZT93d3MygVKKnOW105KoEGp24hPJQ== 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=mx4y3l2O4+orKNReYkqXIuKrIO9LyEVNaXBtRVkvCPQ=; b=GxDeKgG3bQ8Z4EgAmX0+YNhjhgpcu5LBP7J+qW44XsfAOtGtHdjr+X4nwkx8Vi8XMeUmQcH6LUfuuMC9tTEkr01+UpifPsxksMuFaf9bJRd4H/u2jm8/fJGRRmTPf/C2iqHlTnwnRrJBu8wLLYEvlSiwKrVosdgpSM97ei9hEAUzr1FDgS18sHALqrYrkRz1b7NSDE6N5VAeaVEzTbmHij+wzh9/KhT3nos9rcsicUpl2WlueidEOZMp5lSt29227UJtQmhlb1GHl0NEHzfmruERtamcEIzMx5wbV8VMHkU+s/DrkhGhm9xuWFgK151KpVBbTHvvcPvzGAEiRh3HDA== 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=mx4y3l2O4+orKNReYkqXIuKrIO9LyEVNaXBtRVkvCPQ=; b=CHnS8Pqz0ExUE4zdr6ZgrY6Pismh3QMOX19a4GWLAWTMKYN14683mxAhdXCXovvRQqjj79zJWLYSNr23C3AbeV9N4P8Dvuhr9BfdKRXfOGYvlh+oYY0xDLaX7t4jp6hHjA3FtjkPYrunT9UE45qzLxLBxbSfZvR5xi2BNNOXUJZnTLu9s2SjOXp2hg/Sgq6ySphSqJyjwm4K93JHpqoG8smAxnOha9lRWcRCvFHhowGNIS69HPLoQpfunvuCRn4o7jdNtFoPjjYA17rDZrG4hYtInSgvFx53qhdvWCwSCl/so3JFYW+c4L7SH6SK9PqbjCU9+agsomppJcSQszLdGA== 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 DB9PR04MB8429.eurprd04.prod.outlook.com (2603:10a6:10:242::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.27; Thu, 5 Sep 2024 07:37:00 +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.7918.019; Thu, 5 Sep 2024 07:37:00 +0000 From: Carlos Song 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, Carlos Song Subject: [PATCH V4 2/2] i3c: master: svc: use slow speed for first broadcast address Date: Thu, 5 Sep 2024 15:45:57 +0800 Message-Id: <20240905074557.3810026-2-carlos.song@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240905074557.3810026-1-carlos.song@nxp.com> References: <20240905074557.3810026-1-carlos.song@nxp.com> X-ClientProxiedBy: AS4P191CA0024.EURP191.PROD.OUTLOOK.COM (2603:10a6:20b:5d9::18) To VI1PR04MB5005.eurprd04.prod.outlook.com (2603:10a6:803:57::30) 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: VI1PR04MB5005:EE_|DB9PR04MB8429:EE_ X-MS-Office365-Filtering-Correlation-Id: 2feb133b-771d-4bd0-1188-08dccd7d86fe X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|366016|52116014|38350700014; X-Microsoft-Antispam-Message-Info: FL0L03QJQSDjbJQTUrI0EmFxRpEEQjWw6jq1nEbs6kJiub44BstWpKKXMcuAupNvCUv9NILl51h1DqQ9FEZnOofin8bSh6Rd9h01UwkldjY0ttjDgOnzqZK98snIfISGWnNKQfokjXqUqfK/EdM5+jTX2llW5hBta6Y1XbAkIjrZu4vU3xZCxU/heF+EzWjpZFdTQfGzQO1UiedXbNKXlPG+ZO3L7gUZorZLfLrdyOzHO6KILmkIykTakD5JlMsYi6YpAas1e7hcgeWLK1mjne/NCLzhMo+mxnGUFAUKWpZpKPzaKymEoeq+aFWzAWo5obrFxUvb2ujz2xSr0ZqWwZHeFWrabT08ieAeb41ZIXYZfRizvSIGxLO08f5HXILhNBaaHL/imK44ruXnSoYB6lmhNuYV82/Ag3cy6RVkNmDPb+FeZWUWHpdZwjapuYLdLChR7ZFvnOvcjNwU+iFs6F9NBr2G/xm4Z4Wm1P2M7C5sWSiIyagnuKtefPaMtrlaRbFPVy3MfWAjVXFuxQAY+JA+jszkea99pDSyKSgUOvgdo6+rBq7Yc2LudH8SiTifQ5Cc0PUlfOci7Qij6/UMECx7OLLi8PNZng6JpB/GSXugEbfVUMua+KTuzti1+Tf/Cn0jZebY0sZXj1fnxD022o5M2ixjKYAdQGm4Ye5eX3IK1f32kPpamAMiYplL4MM9+/6qa5l0v9G//HPIokr6BzHp/GOkhTYsv7q11eu3aETgMmNPedFeWO/0WQl2dr6bH3L2LhPAw6xFul0crRb274R9gf1Zqoypt3sZNSyPnExY2g8bwpUlnBxsAUKLeRIKuv/Qen4hoTsfn/y2GZy55MOLWPwJvY3G2COzgMLawm+mDpPxJs8xexsLYKrWTp+soOzz+wZDtB4hDO0X4qFogaf9zVcM2zZoS0BkhRd8YQHz7wE3+6FHCAaVFhxpwQBiOw3SWfry/TrAUNQMCIL0M/SXPdAkvho5fM6e5+gCy/V9aHjPdO6BbcavjbfipwyzpDXTwxzDgyC/Ox1gKoS9Vczoj3qdB2CXgUSNMbSjofFTglBsNAZhXaSuk12/cSZ2uSfZ2q55pOiJSrvmbMozcgOcUIPaXrMvl5T37gnc/OA67dePoEUSJVYmcIOQPnkd3FviDEcHNWQMCGACiFAi60ioSdbNwOBTLCrPEPzTEXWz1IRH3dTNHxUNrvbZVz5wNXv9C7q2iPjYFYzGSaJ+nrTNCOaarNOARmQjgIblJIuWttkimyCNcDmE+Vfco+KoS3HdcHfUelVPIVaw91/tvHUeqg5h7A2ZZcYbPowF7nZg4yWukASDc+kiLPLHkEMGpJxxsmg9fUjr5JQLZD+Nq9IGmiDbzPvBJdZmFZ4/LTBPYq+R4zLflmxLwjrwyDmnNGEG3OzBBDg72+EpKzOH9Q== 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)(1800799024)(376014)(366016)(52116014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: k+J6wp7oAzyzMl9ncwI96UobBZKysl9/1odRwVpPHd3RM3Dv/SqvB9wZWNq2cPNsM4AzoMXAm4kCbPR5OHBx/uAS9pnjRAQv6wIfpRgY9PJitwlQkklvtq0Kh0YKK74IA+I6RYjs+hU9roMCB1JOV7cjZfVyoq5SuOW2cfyXGFBUMhEe3I9wMPzQFlCSX3NsoCm9/V7l8g79zy4tRGYN12XGkEh/oBBo9X2qFlVF/IwDzTpIBdtNsNzWd0wF5o67lpSIIYv1OJ1HF/sApG3wa+rzSc+CCYFmIXM+pxeFC9u94ddM1oR9zTU0Mow9os7/2Jmf0ak38eoht/OYGNg/SE6kiQjUJ72BMjYBAgvjq0IRTR6NYm3sI6BGPbXubW3ISkath0SFfrLNXAumTa/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Mbpxvrho/9y6gSkoGKPcHbU19trRQKn2vDILcXVTp4gk4zQ6cue7JF5jPlsr6XIh3p3GS29kf/HSy3hqBDJT7oUlhg+DXQvxEfbdun7uK8hg3y0Aalc2CSnSm9qORChNEy X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2feb133b-771d-4bd0-1188-08dccd7d86fe X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5005.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Sep 2024 07:37:00.3160 (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: nhozXW8tW2QMGs7YXyHiDmnzPB1LZtFaOC96OHq8yW2T0uG1h/N4A2sVvQ/l1THR+0BsQ88fDHZDSX9efGc3Gw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB8429 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 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)