From patchwork Wed Jan 29 20:05:52 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13954100 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 6AC14C0218F for ; Wed, 29 Jan 2025 20:06:18 +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:Cc:To:In-Reply-To: References:Message-Id:Subject:Date:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=/zYp3NyYtMOdE7petW7+TO1iV11P675B16n0Jy+ax9A=; b=sElCjrKInhKBegpmYqAlnMDFrr 8hdgE8mTwt3gsl8hyGtItUQsVGpIstBQd+ywmVTMDkCaHTm/RZy2hxTx9iLEqyBgu5gHjHb1vYJbL a73RzLQSCOYI2eX/XaQ1rXTuhxsN2vaihzDaV2EbJu53R0UTJ2WlN7S5uXLFML8L544KZF543jgOT 9h5SAoj8k2VNa4yAXY5g5xPreitbTSHyYOtQr3bghYZFWU70WLEkiH2syTQroc8s0AOLcJbvyg8NE xl4wuhiunc19Kz//p2z3JpjPZn/XmvHBk1j0swwMOdbC5MmQe/VMzqSVUgheKsRjlQ2VQ0z2kogZd XOl1g2kQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tdEKI-00000007jnw-0XN3; Wed, 29 Jan 2025 20:06:18 +0000 Received: from mail-westeuropeazlp170100000.outbound.protection.outlook.com ([2a01:111:f403:c201::] helo=AM0PR83CU005.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tdEKG-00000007jml-0fjD for linux-i3c@lists.infradead.org; Wed, 29 Jan 2025 20:06:17 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=TlxbHDjDrWLMEj4QoQ4AgdGVBkl7q6A5TkPq+wZ2YtobbuRrr8+dhBmglKECw1j5N0baQIB7h1J3g5DbZVxvhaCiRYC8jrrR6MJcsiHBUp9i9KyTxKRZW9iYnqrhSwxCpZgYVwjlsgo5eR/lCtZenRWE9n20LCmeAIicUAarSHt0RCENdPbZx4jcMORtwUl6f/ybSyjkiP4pQEa5+FnloiHLS66wRO0u5Gp51Xwqz48WTLV8LwHs0QASoyyG5dR47icyVnQ20P6uZNtM9Vr52uej7XjvIikImHN6xcKUW+5ltO8jhfo21UFMiiQblA2diNoVxXiXZhfbVTBBvYk8Gg== 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=5xn3u/pAWnMVPiqNzEyEfz/JVJtr2ST8EZyxY/LMSig=; b=EmCLDg6teR+t5dNg+LkYWj/QTo3PJTsmIDhOeXhCR9up6AYmk5fwW1bmnxOMZHM9cYn/SN6a2bU/1TCcAmrWWRkGUtr/LMwCbInDsY0QQES5wKdsBcFrF86SKuWtXkerVQnUGOOZrd1MzGVQwVzLixr/Ooa7gMPGn8KZpO3gbF3DyDqCZkOPHOutBhxPj0KqnJSAj+Gq3mr2a6+I1Y13is2cHdsQjo0tcxXO6pNj7DCOzK6X/TwDaG9E2eWAEJzqIJY7ky5VqgFa6QnkZGOz900wFyCeEMloQi5rKf18sSOy5AVyxalYE36qWs1m/2qDN9sXXEUPUpOMCIAn7x4EuQ== 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=5xn3u/pAWnMVPiqNzEyEfz/JVJtr2ST8EZyxY/LMSig=; b=koL8xuk4hr9/FKboVdXoqp7vJrua7sS/ig4ZFb+dl0Mq3svcWNfqAJMCD5UJPiAVahcVkxZAjzIba7UFmD1tQBuMA4vTrLRr+dWNk3vYb8eLhs1j35CR3g41bdGaryrEam78l57+HbNma7GILNSloMWJIXnt6QQ9C4AhcnxbKdHxppJ4s7QxaZpEkcxYpn6yRJeWVI9gceZSsg1Itq0ugK27uY+KHkIdr4BF5BwYKYRLdEnar50Uy9u5mzZQuXM9MsCB/xfSg/UKZtIUkZkIzPRmIaFrHJHRnMqlyvQfw6IpzW70p0NHNg5VqyRON54ehQyyZU+8I9OrsZXX/Dp2fw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) by AS8PR04MB8995.eurprd04.prod.outlook.com (2603:10a6:20b:42e::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8398.18; Wed, 29 Jan 2025 20:06:07 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%5]) with mapi id 15.20.8377.021; Wed, 29 Jan 2025 20:06:07 +0000 From: Frank Li Date: Wed, 29 Jan 2025 15:05:52 -0500 Subject: [PATCH 1/2] i3c: Add basic HDR support Message-Id: <20250129-i3c_ddr-v1-1-028a7a5d4324@nxp.com> References: <20250129-i3c_ddr-v1-0-028a7a5d4324@nxp.com> In-Reply-To: <20250129-i3c_ddr-v1-0-028a7a5d4324@nxp.com> To: Alexandre Belloni , Miquel Raynal , Conor Culhane Cc: linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, Frank Li X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1738181163; l=6612; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=Qv+OIZUavFWAsZsR0hppGZh+8cB7gwaFIH0gV7V5F2Q=; b=wrmGPkIgbj/nyGtRsl41Dg9/ksdiyaa8YDyPFqFJsuwVmv+5LyiPATNBBUDi7EijUYL54GK// DJs11Sq/Q/DCWe7ctzzPqw0N7Zgmzliqx0bXQJDGsCFdZFn0S65tbfD X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: BY5PR03CA0012.namprd03.prod.outlook.com (2603:10b6:a03:1e0::22) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|AS8PR04MB8995:EE_ X-MS-Office365-Filtering-Correlation-Id: 587ad316-beb0-4472-ad9d-08dd40a05e18 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|52116014|376014|366016|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?6HFA/s2Ib9vtTzyalXjWrmKvGiQGlN1?= =?utf-8?q?hSFFpHuR39/oW/FCgeAUDT2niiln97k8TaQyblEH8rH4tVhucMtqMqLBkSA/WTqBr?= =?ut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= =?utf-8?q?XriVmxghTtBcZPORFj+w2kqF1vHviVprLYyl06EjdTvur9cf2F4kksV4JMmOUk2BK?= =?utf-8?q?xCMcEu2SM+F2geDBi5Rq6s+mS/+FwRxP5zIEJEVlg18zRbogBdjROXb4NurW6asQ5?= =?utf-8?q?c6QU4tWYCkSINmR28fgiPucr4GEhF25pyjGJfgZz5wFDStxPaG0HXt5+m4yqVyn8Z?= =?utf-8?q?peCyMcaFVhk29aszBeLMW8lqCE2PnjCZRt1+UfSORrg3Lh28lF/CWbVSjkBRCKyVq?= =?utf-8?q?MxliCEs52G3zqbxYy2oUJ0plALBS5Nwraq9V6B3wFrdoS0Ghf4WGr2fbYzkxiV16O?= =?utf-8?q?iX65XJT7SRlMkwDxgbyMTsQcQRh0UI6E3lajDbvRSQmeJafRms0CxQwRibWCsAvVw?= =?utf-8?q?ll4QPiXC072eECPNbIfwkLpXvhXaAVRI+DQO2gct5spAYDODxmneh5RZ8BXD5W1tZ?= =?utf-8?q?u7IaQ6zK9KS?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9642.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(52116014)(376014)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?Qech0cCpi1DCsQma4KZFDimmENZZ?= =?utf-8?q?Z8x/AsWrpo+u5cij2roWAvtsNsLt6gYyL/V+75YamlGywSqmJ0iLGmDzXTzIJr9H+?= =?utf-8?q?cLSZ6iNfRWoMpYsoMRcuJLmeHqlMKiZ2JPisDugz/Vrb/MPQL5jiziu/7qOM9l9xt?= =?utf-8?q?5N5JQPDfSF0KHvwDhhfRh+eCHLXL+R/Za0cG4X1GsqVyqED5EiP3G2x5vJJvm/a7Z?= =?utf-8?q?+LbCbmh3pmJ+q39d2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n4e38pyJVURhq31MCzkzIGvBtfikh+2twhzAxicNZaIspN?= =?utf-8?q?laHY77OTf6gFCf5FEswk9teZ0VFMiQBBfgnduaGgPGBg/oEyhW4OjMcewmJd4mpDt?= =?utf-8?q?OBsS+4L9WIOt68VaTegOkS9/adoI3HDu6GGsGcSBQiCmUA9AMZ0x8pGRuTAQySPhL?= =?utf-8?q?vaK0HEMw3wlK2ITe1jrTorF4ZWqmw7tP/tk02x6WE4D2BEL+kAhiESM4BW1W/OUl+?= =?utf-8?q?hLfPblGOF9ZEPoqyE+ZmOpUc7+qMphsWLZPPPo0WNDuWxTTP/SAZSFCPuCNOBH495?= =?utf-8?q?j9Sc8HmUWf7O/DnIln+Kh0RwIjQNBLOd1xOUQd1A36+RrbJ8FjhIGNsE3lwHCquo8?= =?utf-8?q?fnZLFNloWFIlGkHDC5wiiK03jqRfKI68fIQLYTCWkKwjN2pPkcA01xNFBxYp6deiw?= =?utf-8?q?UzwXLq1rschQ?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 587ad316-beb0-4472-ad9d-08dd40a05e18 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2025 20:06:07.5444 (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: JwywFUA+AUHDHqXQgHAfg9Vqs8oh0/7GP32Ppd7DP0+amRdm1XZvJw80oB9zPqVdFqh/5uoITjGi53NeYwobcA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8995 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250129_120616_352566_FF065FEE X-CRM114-Status: GOOD ( 18.24 ) 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 I3C HDR requires enter/exit patterns during each I3C transfer. Add a new API i3c_device_do_priv_xfers_mode(). The existing i3c_device_do_priv_xfers() now calls i3c_device_do_priv_xfers_mode(I3C_SDR) to maintain backward compatibility. Introduce a 'cmd' field in 'struct i3c_priv_xfer', using an anonymous union with 'rnw' since HDR mode relies on read/write commands instead of the 'rnw' bit in the address as in SDR mode. Add a priv_xfers_mode callback for I3C master drivers. If priv_xfers_mode is not implemented, fallback to SDR mode using the existing priv_xfers callback. Signed-off-by: Frank Li --- Why not add hdr mode in struct i3c_priv_xfer because mode can't be mixed in one i3c transfer. for example, can't send a HDR follow one SDR between START and STOP. i3c_priv_xfer should be treat as whole i3c transactions. If user want send HDR follow SDR, should be call i3c_device_do_priv_xfers_mode() twice, instead put into a big i3c_priv_xfer[n]. --- drivers/i3c/device.c | 19 +++++++++++++------ drivers/i3c/internals.h | 2 +- drivers/i3c/master.c | 8 +++++++- include/linux/i3c/device.h | 12 +++++++++++- include/linux/i3c/master.h | 3 +++ 5 files changed, 35 insertions(+), 9 deletions(-) diff --git a/drivers/i3c/device.c b/drivers/i3c/device.c index e80e487569146..e3db3a6a9e4f6 100644 --- a/drivers/i3c/device.c +++ b/drivers/i3c/device.c @@ -15,12 +15,13 @@ #include "internals.h" /** - * i3c_device_do_priv_xfers() - do I3C SDR private transfers directed to a - * specific device + * i3c_device_do_priv_xfers_mode() - do I3C SDR private transfers directed to a + * specific device * * @dev: device with which the transfers should be done * @xfers: array of transfers * @nxfers: number of transfers + * @mode: transfer mode * * Initiate one or several private SDR transfers with @dev. * @@ -32,9 +33,9 @@ * driver needs to resend the 'xfers' some time later. * See I3C spec ver 1.1.1 09-Jun-2021. Section: 5.1.2.2.3. */ -int i3c_device_do_priv_xfers(struct i3c_device *dev, - struct i3c_priv_xfer *xfers, - int nxfers) +int i3c_device_do_priv_xfers_mode(struct i3c_device *dev, + struct i3c_priv_xfer *xfers, + int nxfers, enum i3c_hdr_mode mode) { int ret, i; @@ -47,11 +48,17 @@ int i3c_device_do_priv_xfers(struct i3c_device *dev, } i3c_bus_normaluse_lock(dev->bus); - ret = i3c_dev_do_priv_xfers_locked(dev->desc, xfers, nxfers); + ret = i3c_dev_do_priv_xfers_locked(dev->desc, xfers, nxfers, mode); i3c_bus_normaluse_unlock(dev->bus); return ret; } +EXPORT_SYMBOL_GPL(i3c_device_do_priv_xfers_mode); + +int i3c_device_do_priv_xfers(struct i3c_device *dev, struct i3c_priv_xfer *xfers, int nxfers) +{ + return i3c_device_do_priv_xfers_mode(dev, xfers, nxfers, I3C_SDR); +} EXPORT_SYMBOL_GPL(i3c_device_do_priv_xfers); /** diff --git a/drivers/i3c/internals.h b/drivers/i3c/internals.h index 433f6088b7cec..553edc9846ac0 100644 --- a/drivers/i3c/internals.h +++ b/drivers/i3c/internals.h @@ -16,7 +16,7 @@ void i3c_bus_normaluse_unlock(struct i3c_bus *bus); int i3c_dev_setdasa_locked(struct i3c_dev_desc *dev); int i3c_dev_do_priv_xfers_locked(struct i3c_dev_desc *dev, struct i3c_priv_xfer *xfers, - int nxfers); + int nxfers, enum i3c_hdr_mode mode); int i3c_dev_disable_ibi_locked(struct i3c_dev_desc *dev); int i3c_dev_enable_ibi_locked(struct i3c_dev_desc *dev); int i3c_dev_request_ibi_locked(struct i3c_dev_desc *dev, diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c index d5dc4180afbcf..67aaba0a38db2 100644 --- a/drivers/i3c/master.c +++ b/drivers/i3c/master.c @@ -2945,7 +2945,7 @@ int i3c_dev_setdasa_locked(struct i3c_dev_desc *dev) int i3c_dev_do_priv_xfers_locked(struct i3c_dev_desc *dev, struct i3c_priv_xfer *xfers, - int nxfers) + int nxfers, enum i3c_hdr_mode mode) { struct i3c_master_controller *master; @@ -2956,9 +2956,15 @@ int i3c_dev_do_priv_xfers_locked(struct i3c_dev_desc *dev, if (!master || !xfers) return -EINVAL; + if (master->ops->priv_xfers_mode) + return master->ops->priv_xfers_mode(dev, xfers, nxfers, mode); + if (!master->ops->priv_xfers) return -ENOTSUPP; + if (mode != I3C_SDR) + return -EINVAL; + return master->ops->priv_xfers(dev, xfers, nxfers); } diff --git a/include/linux/i3c/device.h b/include/linux/i3c/device.h index b674f64d0822e..7ce70d0967e27 100644 --- a/include/linux/i3c/device.h +++ b/include/linux/i3c/device.h @@ -40,11 +40,13 @@ enum i3c_error_code { /** * enum i3c_hdr_mode - HDR mode ids + * @I3C_SDR: SDR mode (NOT HDR mode) * @I3C_HDR_DDR: DDR mode * @I3C_HDR_TSP: TSP mode * @I3C_HDR_TSL: TSL mode */ enum i3c_hdr_mode { + I3C_SDR, I3C_HDR_DDR, I3C_HDR_TSP, I3C_HDR_TSL, @@ -53,6 +55,7 @@ enum i3c_hdr_mode { /** * struct i3c_priv_xfer - I3C SDR private transfer * @rnw: encodes the transfer direction. true for a read, false for a write + * @cmd: Read/Write command in HDR mode, read: 0x80 - 0xff, write: 0x00 - 0x7f * @len: transfer length in bytes of the transfer * @actual_len: actual length in bytes are transferred by the controller * @data: input/output buffer @@ -61,7 +64,10 @@ enum i3c_hdr_mode { * @err: I3C error code */ struct i3c_priv_xfer { - u8 rnw; + union { + u8 rnw; + u8 cmd; + }; u16 len; u16 actual_len; union { @@ -301,6 +307,10 @@ int i3c_device_do_priv_xfers(struct i3c_device *dev, struct i3c_priv_xfer *xfers, int nxfers); +int i3c_device_do_priv_xfers_mode(struct i3c_device *dev, + struct i3c_priv_xfer *xfers, + int nxfers, enum i3c_hdr_mode mode); + int i3c_device_do_setdasa(struct i3c_device *dev); void i3c_device_get_info(const struct i3c_device *dev, struct i3c_device_info *info); diff --git a/include/linux/i3c/master.h b/include/linux/i3c/master.h index 12d532b012c5a..352bd41139569 100644 --- a/include/linux/i3c/master.h +++ b/include/linux/i3c/master.h @@ -472,6 +472,9 @@ struct i3c_master_controller_ops { int (*priv_xfers)(struct i3c_dev_desc *dev, struct i3c_priv_xfer *xfers, int nxfers); + int (*priv_xfers_mode)(struct i3c_dev_desc *dev, + struct i3c_priv_xfer *xfers, + int nxfers, enum i3c_hdr_mode mode); int (*attach_i2c_dev)(struct i2c_dev_desc *dev); void (*detach_i2c_dev)(struct i2c_dev_desc *dev); int (*i2c_xfers)(struct i2c_dev_desc *dev, From patchwork Wed Jan 29 20:05:53 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13954101 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 0F1A3C02194 for ; Wed, 29 Jan 2025 20:06:20 +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:Cc:To:In-Reply-To: References:Message-Id:Subject:Date:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=AEeqEKUoggundk6aoL9kzvydTPr+TFz5mCJCqEzgfkg=; b=zURDl4AzZ08+ECNZLjfKAlmhQx bDzAb7HE/Q8jqdYZgF9ljQHQO+nI3viQ6SRe6jGgLnuEzxXRC8Cej/srOJsJR6x1jzAAERL6Ef4h9 TYqQQ7aBZRnFC/Cqindipr7M5LG2fV4Rdafvg//ktbNt0doIwTQ5UEobxOfBS5KA0dX0PzurgNK5a ZT8qtQgxLDquhEk7S8kSeitjtCLmi561t3wHQBQY5EiNTYviSPWKCLlQSvXfBjVA3JPqIJ4bi5tJV HCa9NDCYDpiPo1vdzYjwm7Pe49wZQ5Wok2tRCFZ20AmfxUFaFz6vQq7yRDpFQasByoZirPTVNItrZ Skay89kg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tdEKK-00000007jpO-2n32; Wed, 29 Jan 2025 20:06:20 +0000 Received: from mail-westeuropeazlp170100000.outbound.protection.outlook.com ([2a01:111:f403:c201::] helo=AM0PR83CU005.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tdEKH-00000007jml-2uKq for linux-i3c@lists.infradead.org; Wed, 29 Jan 2025 20:06:18 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=tF0cr4Nwihlyh4wjxIKWvM4WgXLzslI8fRGwb/zAWAeCXhfgJW7+WfyxbHhJpKdyHSFg7Fj0//Ssepe7qgwpZlUsOxd7GOf4ai1c3jfPb5p5rYQ7sZI1H907bG+7SoOL5ZgGCgm9BlZ1CyXRPtMoDpI5opTneRB0JSkV8OpSqIZPPQhnGmY5XCOhUwN2QcYA8mdtkqHEpHeZFuzc8E+tOwHfViI8CX8Xn/ZbQcQ82DeZJXIVgxPwhi6C+d3fytCqkUX2gqdiFN453q5C04j8OvMZ/FOpfcyXL/7uxZ88RvQHFcqE4CejxpfQRNJrR+IHhN+9Rdi1S5J+aCXZnWcp9g== 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=OgXky10trcn/+bt/y3+16l8vQezgvECWvae9pCH4Y9w=; b=w9YyUDrvT7Y+UTz0vTOOcZCxw1FERivZWA1q3s7fat7YB1iVUdEudzoV+nAPJk4onEpzhA0vijOYJKxQ9w9ZcDIMZ3f67ebKQQYbx7dGbCL/931hzommJJpxsrAqbTxmTkuL1+tZ+F7H2xBw3RBY+n5vUdGlPWILerjbladYfBNujBMGRUcuhGWkUuN3KVJumRbXP7ILvRfTVNSsFEfJ7wwm1CoV7szYL9ytDRYC91y1PwatX+V7s0IwI1Tz1t0Esn06U9obD/xchCj839ePWcGWFGnIXSQBWLlYHosHyoGKf4uIMJDANvJtUkNnX3dWDW9RCwlH4Rd7P39aVQYCTg== 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=OgXky10trcn/+bt/y3+16l8vQezgvECWvae9pCH4Y9w=; b=D2tZ28PvWwkzIljwyzIBY9DfP7xJI4SM93RUPtaDq2KeayQbm82mPDSeEurdZHCW9Svv6wJD1dTL0YsrHPlnq0EuDNuzZ2XeY3ECO2uhbGRntecsYy2k8fDI+0gkNoYWMBHcIp6TfuFeDCb2XQbGXPlVKml7gXFTbU7tKl5fja2+2D7i+tTiey48LczNNUbj0AKj0dViudwhO/6MG7uB8h6H3u2pTuBwHUtURkoxEvr+3WqyFICXEVmbo7AKAMsqsCp10UVqIVBLjGByb9UP22P6XzcEXbSx5cor1q8BxOnGHFm7iXPE0i9zl3D6SkF/7Wj5ZL000y9nS8u2vq2hGw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) by AS8PR04MB8995.eurprd04.prod.outlook.com (2603:10a6:20b:42e::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8398.18; Wed, 29 Jan 2025 20:06:09 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%5]) with mapi id 15.20.8377.021; Wed, 29 Jan 2025 20:06:09 +0000 From: Frank Li Date: Wed, 29 Jan 2025 15:05:53 -0500 Subject: [PATCH 2/2] i3c: master: svc: Add basic HDR mode support Message-Id: <20250129-i3c_ddr-v1-2-028a7a5d4324@nxp.com> References: <20250129-i3c_ddr-v1-0-028a7a5d4324@nxp.com> In-Reply-To: <20250129-i3c_ddr-v1-0-028a7a5d4324@nxp.com> To: Alexandre Belloni , Miquel Raynal , Conor Culhane Cc: linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, Frank Li X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1738181163; l=7629; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=JEIsXJQCrGymehdd1Jleuv9Z0kCcnhQNHdjnEuYbQ1Y=; b=+zcPldY+xwTc1cXdayUYnO8yrl98j+jKLqjoeSEPPMt2k9vwcN0vnXAXTCxkGetbFeCkXqrZ3 W3IMtID44xLACAM+Tn7JLZi+imKbEeYZpjmSCKRCWZyIggAAEEVSt0P X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: BY5PR03CA0012.namprd03.prod.outlook.com (2603:10b6:a03:1e0::22) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|AS8PR04MB8995:EE_ X-MS-Office365-Filtering-Correlation-Id: 80250fb9-0219-4257-5e9d-08dd40a05f6b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|52116014|376014|366016|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?3S1ygNVHCrIsaZBncL+Y193GMzfH2in?= =?utf-8?q?A7LfWDFExUrom4yYzYK2z/d7ktlBZUSFsy7VCw0dCVIUGyZ8MSu3YOSpbfndV3IM9?= =?utf-8?q?r20rZrRT9XvxabdsyADngGJyKARn9+aeQ/AErdl51iCj7Y5KAp6i8jLv9+6zBVFcE?= =?utf-8?q?4kPA7gIadw8VA9TxJpEnTj1mK7+JKuzhD9ZpTq8W7uxH4P+hq2QrEQv5WbtNaAwEM?= =?utf-8?q?AddrsAS3urzefF93xdA0Fzea3jQlknziN8vQ5oXEOnOBHRYQNovuISzkrOms0Xc9i?= =?utf-8?q?Dp5kZm+OXKRvoowgFVMIzzt837g95fI7zAx9gCgDkBitNy4jPkdR1ViqTZ9oryABX?= =?utf-8?q?YPq7WcGf++PZt+DI9tZP4VUZhWC+0dziLy/804nPRcWdUJ7+v0HYzjEwhszmazKEF?= =?utf-8?q?IDCndFmrTfS/TQEYNzPDonLXtFrL7si6pQV/pAKpcMmKq64gT2OnBBwkbpGZ+puMZ?= =?utf-8?q?URZFFkgsJTJwEzlENxALnPq8VENbWBg1alLe7tabdG+r/DeycS2weDQ6H6KSTFGgB?= =?utf-8?q?ZyJ7M8rUnPFbqtG9bvYYit5WnaY9dTmOk/crnCFkca+r5HRchNNJLBz0oENOLafpg?= =?utf-8?q?qONeI1UU2kouiC6F+FDcXFxBnX7r7LrXwZOir+eeEEHDVrvJMwnYqi/dYU5H2a2Bv?= =?utf-8?q?QbOt7uF6FmLwU1ctbIXly6hYpb/PhaZ19/vtcqg8UK0g4WnxeN/mkeIAFrKENRCAq?= =?utf-8?q?sSM8erooaPcezhNZdLoTPxW7h25zKFM4bDj0HMsyVqT7HRTIuLHLyLTQy4irQjt4X?= =?utf-8?q?NMSZg0FzL9p2Us54jr2GTvwc2uYuYmVu23Jsdnr0seOGk6h+hf4NtF8ljIknyOMxa?= =?utf-8?q?8y0MaX5pZHdZsMdiknFwqfV5c2q3xxgNL57jUYka+tmNIwcuCtRTtgHo8n3/Ggkvk?= =?utf-8?q?Gfg7fUKueHyCzJNLqnVeDALBbOfwEJbP2fTSvDf+94Tq3EFbfnERTFcnRR0iFn2nS?= =?utf-8?q?FaMvWDWxqnf9xqKqDPcDjsoiR7JZxZwVe+4+jRK5ZanyGmlLqq/B1ESrEq2t3Nfjf?= =?utf-8?q?qDCGS1YNflCGYRV5R4Zla5b19mTFmWRZH9gvqOHxjxbIPKcRiA5L0TAnk8011hhvV?= =?utf-8?q?3xlV3jKdSq3+6UgAiN4cn3tYsaA4FAAxPDajBtjVxBAkQkYVNFSPxy5iynsY7pT4V?= =?utf-8?q?0yUALuV2Dmnq6RcUlkGu9e5R9sdA1Nyqh/nBj7TPCLSNfsXD+/njcy3pLogCS4cs9?= =?utf-8?q?sb3khD0TMrN5cW1Kd1mROrK7NcQ4M0ufiQ7l7KAGC8egbaznFEbx+VJHCU5tyTJ+K?= =?utf-8?q?S6G7MRxLAS2hk4Pu39WPT+wKdrPd4VWBIT34AUI26Rs/V4mX08eVyvhYEhC9vhzFr?= =?utf-8?q?CdGbHHxfyiNQM1ethB3LxdK17r8wLSD0uP67nAV0dscdRwzgon29d+1S/S/CFy8Ok?= =?utf-8?q?ztPtJ1W8rNH?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9642.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(52116014)(376014)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-Anti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f6sQhIksVPeCP7sc7AevFWoRT4yEmL7KbvJrCd6vSjskvbM76N?= =?utf-8?q?ZJJuscjgR8RQ3yurm/AwWcedqWNK7e4fX1Dj9YbFd1zrNDiOiA1GBJZgvqVD6Ig2Q?= =?utf-8?q?LmIwNyJ1j12yQtadwgqpcO+eVY42/a6/XneQsueLrzs5GWc8i8rTSDTgcfJ/srU9y?= =?utf-8?q?UIsHidtolUkxIdYzgeQMf2u9nYnyKKRMNh5E+7TxN2mQNiXreb+TC+/ZCXPEk1Bv3?= =?utf-8?q?F1LeATkub04a51/x1NyEUVn/HyUqakGFx49j5NkLRWziQOBWVlVUV15GHvjwsuDXD?= =?utf-8?q?1aa/QTnHhws4RJDiZ+HSXrHTFHnPDsFzdBY4bQ6a3ipFrFrF41MqGpktg6LUi4PJt?= =?utf-8?q?RzalESXBHnMx+7/Bkvm0rXL8iJIX+slRzfGZegi5mPRBIWSs5dBST6uC2w1NYNdng?= =?utf-8?q?GZ4T8lAH0qYzGZzFdDiv9J8915+abhGT/8l9OaCX1MrKoORBXXXgN7eo8Mt8pO47h?= =?utf-8?q?P9gTGYHFdp6G5ECQXcM0+mHMBUR+3J8mN68Ct3YmlbjZ3BfaEc8baMnwSrafRi2HE?= =?utf-8?q?NqlgpNRU2LK1AMTkrQfXQnmGS1dlt6bZctlRQfs7rXLgDQf+WZPPBhRJ5kgOrQTZ+?= =?utf-8?q?srRkutGJNenAjfZfLOLnFiFDYi42Ff3bSdBCjI3Wcr0nedCRlU55W/tk2u9ilf82R?= =?utf-8?q?7KN9DhDed+7a?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 80250fb9-0219-4257-5e9d-08dd40a05f6b X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2025 20:06:09.7429 (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: jUP36dF8AUo1y9mXsgb1NKTQEm7umzOvwLesxPJwzIHuLGv03AUPf4Qu+jtvbn5Kwjk3i1T+ktih7Kh1uwWP3Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8995 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250129_120617_740111_EB4778F5 X-CRM114-Status: GOOD ( 17.20 ) 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 basic HDR mode support for the svs I3C master driver. Supports HDR only for private transfers and does not support sending CCC commands in HDR mode. Key differences: - HDR uses commands (0x00-0x7F for write, 0x80-0xFF for read) to distinguish transfer direction. - HDR read/write commands must be written to FIFO before issuing the I3C address command. The hardware automatically sends the standard CCC command to enter HDR mode. - HDR exit pattern must be sent instead of send a stop after transfer completion. - Read/write data size must be an even number. Signed-off-by: Frank Li --- drivers/i3c/master/svc-i3c-master.c | 69 +++++++++++++++++++++++++++---------- 1 file changed, 51 insertions(+), 18 deletions(-) diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c index 19a16eb44220c..28b14972ca987 100644 --- a/drivers/i3c/master/svc-i3c-master.c +++ b/drivers/i3c/master/svc-i3c-master.c @@ -39,11 +39,13 @@ #define SVC_I3C_MCTRL_REQUEST_NONE 0 #define SVC_I3C_MCTRL_REQUEST_START_ADDR 1 #define SVC_I3C_MCTRL_REQUEST_STOP 2 +#define SVC_I3C_MCTRL_REQUEST_FORCE_EXIT 6 #define SVC_I3C_MCTRL_REQUEST_IBI_ACKNACK 3 #define SVC_I3C_MCTRL_REQUEST_PROC_DAA 4 #define SVC_I3C_MCTRL_REQUEST_AUTO_IBI 7 #define SVC_I3C_MCTRL_TYPE_I3C 0 #define SVC_I3C_MCTRL_TYPE_I2C BIT(4) +#define SVC_I3C_MCTRL_TYPE_DDR BIT(5) #define SVC_I3C_MCTRL_IBIRESP_AUTO 0 #define SVC_I3C_MCTRL_IBIRESP_ACK_WITHOUT_BYTE 0 #define SVC_I3C_MCTRL_IBIRESP_ACK_WITH_BYTE BIT(7) @@ -135,12 +137,13 @@ struct svc_i3c_cmd { u8 addr; - bool rnw; + u8 rnw; u8 *in; const void *out; unsigned int len; unsigned int actual_len; struct i3c_priv_xfer *xfer; + enum i3c_hdr_mode mode; bool continued; }; @@ -337,6 +340,20 @@ svc_i3c_master_dev_from_addr(struct svc_i3c_master *master, return master->descs[i]; } +static bool svc_is_read(u8 rnw_cmd, u32 type) +{ + return (type == SVC_I3C_MCTRL_TYPE_DDR) ? !!(rnw_cmd & 0x80) : rnw_cmd; +} + +static void svc_i3c_master_emit_force_exit(struct svc_i3c_master *master) +{ + u32 reg = 0; + + writel(SVC_I3C_MCTRL_REQUEST_FORCE_EXIT, master->regs + SVC_I3C_MCTRL); + readl_poll_timeout(master->regs + SVC_I3C_MSTATUS, reg, + SVC_I3C_MSTATUS_MCTRLDONE(reg), 0, 1000); + udelay(1); +} static void svc_i3c_master_emit_stop(struct svc_i3c_master *master) { writel(SVC_I3C_MCTRL_REQUEST_STOP, master->regs + SVC_I3C_MCTRL); @@ -1205,6 +1222,7 @@ static int svc_i3c_master_xfer(struct svc_i3c_master *master, u8 *in, const u8 *out, unsigned int xfer_len, unsigned int *actual_len, bool continued) { + unsigned int rdterm_len = *actual_len; int retry = 2; u32 reg; int ret; @@ -1212,14 +1230,19 @@ static int svc_i3c_master_xfer(struct svc_i3c_master *master, /* clean SVC_I3C_MINT_IBIWON w1c bits */ writel(SVC_I3C_MINT_IBIWON, master->regs + SVC_I3C_MSTATUS); + if (xfer_type == SVC_I3C_MCTRL_TYPE_DDR) { + writel(rnw, master->regs + SVC_I3C_MWDATAB); + if (svc_is_read(rnw, xfer_type)) + rdterm_len = DIV_ROUND_UP(*actual_len, 2); + } while (retry--) { writel(SVC_I3C_MCTRL_REQUEST_START_ADDR | xfer_type | SVC_I3C_MCTRL_IBIRESP_NACK | - SVC_I3C_MCTRL_DIR(rnw) | + SVC_I3C_MCTRL_DIR(svc_is_read(rnw, xfer_type)) | SVC_I3C_MCTRL_ADDR(addr) | - SVC_I3C_MCTRL_RDTERM(*actual_len), + SVC_I3C_MCTRL_RDTERM(rdterm_len), master->regs + SVC_I3C_MCTRL); ret = readl_poll_timeout(master->regs + SVC_I3C_MSTATUS, reg, @@ -1279,15 +1302,14 @@ static int svc_i3c_master_xfer(struct svc_i3c_master *master, break; } } - - if (rnw) + if (svc_is_read(rnw, xfer_type)) ret = svc_i3c_master_read(master, in, xfer_len); else ret = svc_i3c_master_write(master, out, xfer_len); if (ret < 0) goto emit_stop; - if (rnw) + if (svc_is_read(rnw, xfer_type)) *actual_len = ret; ret = readl_poll_timeout(master->regs + SVC_I3C_MSTATUS, reg, @@ -1298,7 +1320,10 @@ static int svc_i3c_master_xfer(struct svc_i3c_master *master, writel(SVC_I3C_MINT_COMPLETE, master->regs + SVC_I3C_MSTATUS); if (!continued) { - svc_i3c_master_emit_stop(master); + if (xfer_type != SVC_I3C_MCTRL_TYPE_DDR) + svc_i3c_master_emit_stop(master); + else + svc_i3c_master_emit_force_exit(master); /* Wait idle if stop is sent. */ readl_poll_timeout(master->regs + SVC_I3C_MSTATUS, reg, @@ -1308,7 +1333,11 @@ static int svc_i3c_master_xfer(struct svc_i3c_master *master, return 0; emit_stop: - svc_i3c_master_emit_stop(master); + if (xfer_type != SVC_I3C_MCTRL_TYPE_DDR) + svc_i3c_master_emit_stop(master); + else + svc_i3c_master_emit_force_exit(master); + svc_i3c_master_clear_merrwarn(master); return ret; @@ -1354,6 +1383,11 @@ static void svc_i3c_master_dequeue_xfer(struct svc_i3c_master *master, spin_unlock_irqrestore(&master->xferqueue.lock, flags); } +static int mode_to_type(enum i3c_hdr_mode mode) +{ + return (mode == I3C_SDR) ? SVC_I3C_MCTRL_TYPE_I3C : SVC_I3C_MCTRL_TYPE_DDR; +} + static void svc_i3c_master_start_xfer_locked(struct svc_i3c_master *master) { struct svc_i3c_xfer *xfer = master->xferqueue.cur; @@ -1368,7 +1402,7 @@ static void svc_i3c_master_start_xfer_locked(struct svc_i3c_master *master) for (i = 0; i < xfer->ncmds; i++) { struct svc_i3c_cmd *cmd = &xfer->cmds[i]; - ret = svc_i3c_master_xfer(master, cmd->rnw, xfer->type, + ret = svc_i3c_master_xfer(master, cmd->rnw, mode_to_type(cmd->mode), cmd->addr, cmd->in, cmd->out, cmd->len, &cmd->actual_len, cmd->continued); @@ -1544,9 +1578,8 @@ static int svc_i3c_master_send_ccc_cmd(struct i3c_master_controller *m, return ret; } -static int svc_i3c_master_priv_xfers(struct i3c_dev_desc *dev, - struct i3c_priv_xfer *xfers, - int nxfers) +static int svc_i3c_master_priv_xfers_mode(struct i3c_dev_desc *dev, struct i3c_priv_xfer *xfers, + int nxfers, enum i3c_hdr_mode mode) { struct i3c_master_controller *m = i3c_dev_get_master(dev); struct svc_i3c_master *master = to_svc_i3c_master(m); @@ -1558,16 +1591,16 @@ static int svc_i3c_master_priv_xfers(struct i3c_dev_desc *dev, if (!xfer) return -ENOMEM; - xfer->type = SVC_I3C_MCTRL_TYPE_I3C; for (i = 0; i < nxfers; i++) { + u8 rnw_cmd = (mode == I3C_SDR) ? xfers[i].rnw : xfers[i].cmd; struct svc_i3c_cmd *cmd = &xfer->cmds[i]; - + cmd->mode = mode; cmd->xfer = &xfers[i]; cmd->addr = master->addrs[data->index]; - cmd->rnw = xfers[i].rnw; - cmd->in = xfers[i].rnw ? xfers[i].data.in : NULL; - cmd->out = xfers[i].rnw ? NULL : xfers[i].data.out; + cmd->rnw = rnw_cmd; + cmd->in = svc_is_read(rnw_cmd, mode_to_type(mode)) ? xfers[i].data.in : NULL; + cmd->out = svc_is_read(rnw_cmd, mode_to_type(mode)) ? NULL : xfers[i].data.out; cmd->len = xfers[i].len; cmd->actual_len = xfers[i].rnw ? xfers[i].len : 0; cmd->continued = (i + 1) < nxfers; @@ -1766,7 +1799,7 @@ static const struct i3c_master_controller_ops svc_i3c_master_ops = { .do_daa = svc_i3c_master_do_daa, .supports_ccc_cmd = svc_i3c_master_supports_ccc_cmd, .send_ccc_cmd = svc_i3c_master_send_ccc_cmd, - .priv_xfers = svc_i3c_master_priv_xfers, + .priv_xfers_mode = svc_i3c_master_priv_xfers_mode, .i2c_xfers = svc_i3c_master_i2c_xfers, .request_ibi = svc_i3c_master_request_ibi, .free_ibi = svc_i3c_master_free_ibi,