From patchwork Thu Jul 18 09:13:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Song X-Patchwork-Id: 13736273 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 1AE68C3DA49 for ; Thu, 18 Jul 2024 09:18:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=+FDOY+nIBGFVaHs/llMrAgbo6Iy5RyDx83V01OEyNSc=; b=0mE6FvpRJn/1hp 4VlpGVKN2ZX/OVFazY3Ix6wgcGXxd/Oh7HsOQ0D5yGUDwAd5ylhymCgIEfnV9KVbiHPuCWSvf9qOq C7RA30xJyjG2Vne0PKaEQrsCdt/W0RKkl/mca7CKVDvkrjLyJLzfQnx6Rs1wA0NcH868HFeIhIem+ J9ERX90wtAgoPkyXA7GFgCV0rg9REY/YkO/Uq69juExFfjcCj8WfVD1eARYaRPN98JW0mKIb2VypD 52AhWAtEGHq0tDWHru4NcxCgPYUo33jiauDLEmTkYlfOF7tO6ON/yt8kXqVVMlmsW3wyfG7uOfKo+ 7Z9TWITudK/3K6KO2pnQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUNH6-0000000GXNX-1rCb; Thu, 18 Jul 2024 09:18:08 +0000 Received: from mail-northeuropeazlp170130004.outbound.protection.outlook.com ([2a01:111:f403:c200::4] helo=DUZPR83CU001.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUNCZ-0000000GWmt-1myt for linux-i3c@lists.infradead.org; Thu, 18 Jul 2024 09:13:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=vQ2GjhSqt+OMVZ1nS5p06PZ3m629x1BQTqNXX3almXsPp/kxzwKqbL5YYXD27vy9ig46/T/V+wi7JWjh9lvAf4X23QNaHpjCdayjlXLbNi9tC2MwRaDQZ2iZ3aNAdmuybbzJjPXyoJLyTrl0A6L2K6zF2/c7b6ZG2Xoo+Ahn+TElfazTa33URfsNQszPyyb+so5qYsXOi1CIrXYuj+AQlcaF+PvuYJzWHmrhOOB38O6mWk0omMcBf7vb76x6xOkxOPkUjI/sQ4jUlisRa9dZUydY4y5rG0PA/s/KS5L8FclJw8qQYYZuRZB2ZIS/PJEmxOK3eIpVdMmI5Tp2fMG3qw== 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=sUlN195iaHMb95XQfoOEzASW5021qCHYsHsY16K2Zj0=; b=c+hKPeki0sh69khoyegCpF8bGRQUeK/AG86NXAWRB7n+XwarAIh9vB5G+w8y3LP0pPx3zx74VqOcKvbgWQ4gb/GqWUqMBpPGJFRMnKfNEkhD4j1yhqq+C99ABeAn8/LxiMwx7rxYgYkV0b8OHyGM4PCr9TMIK53VZrqQk8MIKv/KOhY8Kd4B79QcBmQLACRiizEIi+kGLaCN04SzBedDh2+4dkjdcxz/RAGxcOtPS7Q592mJd1WedNU0MZERRWOrCQeuVvausA2VKPLUh6+K0UBIiejM0YqLYFPs3/4Ah9z6Csszf2ajiQ4iXYcC34LC0+Zs+a4JbpBwZy6xPuBPYA== 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=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sUlN195iaHMb95XQfoOEzASW5021qCHYsHsY16K2Zj0=; b=htYjai+pCXbmuQEASdq8ZwVkL8NHmgC5B74xD3jVMF0NKKbosXik2zAyATxmlWaYh36yGpfC/YEJoZASr1tY9vMmiHkbpQmYPiN57LNN0NQKc7XkEjlaxBP96sZ2V/qqJT0OKP67vqU6hBpI942djsZojYrqzItR98G4Zwh8lug= 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 VE1PR04MB7456.eurprd04.prod.outlook.com (2603:10a6:800:1ac::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.18; Thu, 18 Jul 2024 09:13:21 +0000 Received: from VI1PR04MB5005.eurprd04.prod.outlook.com ([fe80::3a57:67cf:6ee0:5ddb]) by VI1PR04MB5005.eurprd04.prod.outlook.com ([fe80::3a57:67cf:6ee0:5ddb%7]) with mapi id 15.20.7784.017; Thu, 18 Jul 2024 09:13:21 +0000 From: carlos.song@nxp.com To: miquel.raynal@bootlin.com, conor.culhane@silvaco.com, alexandre.belloni@bootlin.com, frank.li@nxp.com Cc: linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org, linux-imx@nxp.com Subject: [PATCH] i3c: master: svc: adjust the first broadcast speed Date: Thu, 18 Jul 2024 17:13:29 +0800 Message-Id: <20240718091329.3788619-2-carlos.song@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240718091329.3788619-1-carlos.song@nxp.com> References: <20240718091329.3788619-1-carlos.song@nxp.com> X-ClientProxiedBy: SG2PR04CA0203.apcprd04.prod.outlook.com (2603:1096:4:187::22) To VI1PR04MB5005.eurprd04.prod.outlook.com (2603:10a6:803:57::30) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5005:EE_|VE1PR04MB7456:EE_ X-MS-Office365-Filtering-Correlation-Id: c61224b3-90b2-44f5-ffd5-08dca709de2d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|52116014|376014|38350700014; X-Microsoft-Antispam-Message-Info: 93bdetkHO6Y3epcENCDNupmT6VOltfh2y6YpoGcEjOcHuSJnyt4GuSMk1tMLuzqUcpSYqI79DMir30MpPW1jys5SZoBFCJb1Put0okAzIVJzZ1o6By81O8NoLbKUJD9+Eg+bwekq1kRfCJhr2/bG56y10YHg251WrOgEKCbCSh5+jimXScRXgMOPE2cEZkwSiAQgU2BACgQpNEjQts9GwJgpXCFfMlcKiquEPX/sYdzkpEfp7wEciy1ktPxxcL0iJJrLsrsfDwdivdLwo5YcOtCkTS7XIyoBLBfuy6nEzjddIAGY76c+QY6VMKdAhuiC3lFInMfsRTRIp8QirAjUfjF32ppmwTQfUMYuPILRHE2/uJyyTGITqRmKJBRhzvSGPO4hcOIeNts8SsDrSgCRJMsD9I4SLoJtrDT1WQ5cAN57FXsJZ4b1OuVZkPPMJqVKCbQsBSXYS5mRZ/1XILE+dRuLjIT841ve0J3ISz25AUutBBFZ6Wq3KJjtmaTFaP6g58WviUnlODE7M/8zb2Dn5OOw9qqk69a61vZjiYig/1gBlobLutS1D71E20nYUwxQSOdUSoMKLy8ehDbTOFK9PFuuVXu2f1HWWvk34gXy1nh8TCX2vA3Li+pazdBRtTW0/443vfB4aMTD5aHDKt7WidsMsmNseUOrRTtktyenmUp67ncDpmitgVXLDiRWR0qbnKtDgMHLBAO3RWo3EVcCS1VC2Ws7+9mETv9Y3+qUTPekOJSALuzE31MW03qfcSZiKNKchVjB1b81lqTAR7XRVK/PEQBgC2aatGvSC8d/b5E3JsdAzocXZecydGS4L22c9cVmdO76xjnQgrKj+Ne+2xlY1Qcn9Gd3Jz8Gk9GLL7Bwfxn7SiRPXZEuFEpzioZy712EfSWq77AA5rMUJwqmtb9dSiCeYsFHVMz/VulOOt/2ey9riuLoiy6wp650Msodauk6GPSqdMai2ZetVDPLW/T7B/qNK3pR1X9gAIb+5rvPDu/D6ug835eCXgRhSBUCtCUPEKcHT61S2QjtZFi7eWd8eqElAmObSSrAW9Hf7wU0PX27v2K4U3qDGf3JGSeGzXTsLVCzK+RuKPZp57WgtNI3YVvK1eYzDoPVNX6AzaA7CGODrldxufUc8i7CZMergXMn+hU9w75kZdt38BTf8eCnHCPuxD3F1VNIm0MtFSwXdqzAx3Rol6j6lYdIzi9Kl0Xqo7MCqb3NuXcj1nujVzIqWSL4azFzx5qt6OgOLd/JQseBXdrxrNXtv3p4UnwAMbj1Cpb7OPWltuj6/r1eufxrwUZqNGJeUl9ponFtNOA6th3v7LCWRK6mLYOJb4rnUJtLV88Kjf1jKgrgMoozABdXSDay3RJEDF83lYOK9CP1pSPhQWLxhIynGfYV/f6MXcpXf3+QHeC0qyau/tNkzA== 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)(366016)(52116014)(376014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: wW4QDVF4ZJZj6YgcRDqFy9gcqiHXLRDrTnAc844Bh98El7gf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TGlmv/14VclNjt9OBP9c3X6f81wfj0Zg87dSI/jLTv4Sr+v0MKOrLrxIiAGHs4iOarcGshQ7zUiI1oznCvCfBz1GXdamRqflQBenMwA970E9Oa51gzwWYO+ljPN88UIUG8LHo0740q4jAsjUOqIkMwqPhHXG+ED5BYaCOVkf4ooNxP63nT1GJJapBcHplJFMpLf4Xdp0o3bQvdHrT6L1fQffKklHXKUr1PyeV0ABn8boGqFh0ahnb3G88OZ1KMfacLdhNkCv0BwyUyZLFSD9wN7GoqadLvEG6mHk5GM4VluYh38InsQu5Zo+VIe477b6otV2EctVTuknnVF+jTREEGpTSMItsanlgZXwu+X4afuxJpcngWPhTHdnmZcgz77SsoqIv4MSJTXMO7NqqPICN3Ap9+as+VarWkUWO4NaUVkDngJt6tek8jntUf2R0F6xdb4BMopYVPd+zH2p0OBehi X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: c61224b3-90b2-44f5-ffd5-08dca709de2d X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5005.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jul 2024 09:13:21.0640 (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: itbjIQzCnvXwPBlDUedblSfHeQt9Gpgt6SNfIasDhonmLbRLMHGAfZ3FEIku5GEEPhSzlltCSUZAChzjEOTvjg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB7456 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240718_021327_529025_E443414D X-CRM114-Status: GOOD ( 16.81 ) X-Mailman-Approved-At: Thu, 18 Jul 2024 02:18:07 -0700 X-BeenThere: linux-i3c@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-i3c" Errors-To: linux-i3c-bounces+linux-i3c=archiver.kernel.org@lists.infradead.org From: Carlos Song According to the i3c spec 6.2 Timing Specification, the first broadcast open drain timing should be adjust to High Period of SCL Clock is 200ns at least. I3C device working as a i2c device will see the broadcast to close its Spike Filter to change to i3c mode. After that I3C open drain SCL high level should be adjust to 32ns~45ns. Signed-off-by: Carlos Song --- drivers/i3c/master/svc-i3c-master.c | 47 +++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c index 78116530f431..2d68c8d34089 100644 --- a/drivers/i3c/master/svc-i3c-master.c +++ b/drivers/i3c/master/svc-i3c-master.c @@ -142,6 +142,7 @@ struct svc_i3c_cmd { unsigned int actual_len; struct i3c_priv_xfer *xfer; bool continued; + bool slow_address; }; struct svc_i3c_xfer { @@ -214,6 +215,10 @@ struct svc_i3c_master { } ibi; struct mutex lock; int enabled_events; + + unsigned long fclk_rate; + u32 mctrl_config; + bool first_broadcast; }; /** @@ -531,6 +536,36 @@ static irqreturn_t svc_i3c_master_irq_handler(int irq, void *dev_id) return IRQ_HANDLED; } +static void svc_i3c_master_set_slow_address_speed(struct svc_i3c_master *master) +{ + struct i3c_bus *bus = i3c_master_get_bus(&master->base); + u32 ppbaud, odbaud, odhpp, mconfig; + + master->mctrl_config = readl(master->regs + SVC_I3C_MCONFIG); + mconfig = master->mctrl_config; + + /* + * Set the I3C OPEN-DRAIN mode to the FM speed of 50% duty-cycle(400K/2500ns), + * so that the first broadcast is visible to all devices on the i3c bus. + * I3C device with 50ns filter will turn off the filter. + */ + + ppbaud = FIELD_GET(GENMASK(11, 8), mconfig); + odhpp = 0; + odbaud = DIV_ROUND_UP(master->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); +} + +static void svc_i3c_master_set_default_speed(struct svc_i3c_master *master) +{ + /* Whatever, setting the controller to initial configuration */ + writel(master->mctrl_config, master->regs + SVC_I3C_MCONFIG); + master->first_broadcast = false; +} + static int svc_i3c_master_bus_init(struct i3c_master_controller *m) { struct svc_i3c_master *master = to_svc_i3c_master(m); @@ -624,6 +659,8 @@ 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->first_broadcast = true; + master->fclk_rate = fclk_rate; /* Master core's registration */ ret = i3c_master_get_free_addr(m, 0); if (ret < 0) @@ -1250,6 +1287,8 @@ 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]; + if (cmd->slow_address) + svc_i3c_master_set_slow_address_speed(master); ret = svc_i3c_master_xfer(master, cmd->rnw, xfer->type, cmd->addr, cmd->in, cmd->out, @@ -1259,6 +1298,9 @@ static void svc_i3c_master_start_xfer_locked(struct svc_i3c_master *master) if (cmd->xfer) cmd->xfer->actual_len = cmd->actual_len; + if (cmd->slow_address) + svc_i3c_master_set_default_speed(master); + if (ret) break; } @@ -1346,6 +1388,11 @@ static int svc_i3c_master_send_bdcast_ccc_cmd(struct svc_i3c_master *master, cmd->actual_len = 0; cmd->continued = false; + if (master->first_broadcast) + cmd->slow_address = true; + else + cmd->slow_address = false; + mutex_lock(&master->lock); svc_i3c_master_enqueue_xfer(master, xfer); if (!wait_for_completion_timeout(&xfer->comp, msecs_to_jiffies(1000)))