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/d7ktlBZUSFsy7VCw0dCVIUGyZ8MSu3YOSpbfndV3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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-AntiSpam-MessageData-0: =?utf-8?q?3h80sjYvZbAJ0gyAVR6n6WlhFVtv?= =?utf-8?q?XWCwmBs9DzW3PFM+3110kNxkZnbBANAnLA250P0xjZN4CGrP98Dw2NWCRAmgTVIpA?= =?utf-8?q?cwYte4uS/Mrw4Da49felDxkh1KxHM1JSVpNzOwFxj0G684912Q5kzVjJwZ+s5OlBY?= =?utf-8?q?Nh2e7XgqEiVWqRnFh0/2g+sZqmBVC6NSBXCDLzWheX/ctoFeEZ2GkVF9z+ZBFJXHD?= =?utf-8?q?N0DE2gugY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kub04a51/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,