From patchwork Thu Feb 20 05:43:27 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanley Chu X-Patchwork-Id: 13983352 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 22F7CC021B1 for ; Thu, 20 Feb 2025 05:43:49 +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=xGbKAsuKtU6/RlsUJ/XmK0g+I5TPz/glE8Ta/86QsFI=; b=bl0dgCfPyKdXKj zv4Qq3RzsVroFoMNllEbJnO3JOEOtDKpcETBkeQg3AKbtNFDT37JSS+pJZ9t4cPQYpMbGR4Mj2MwH xTmQHRiDVxVMAx5V8++T90+clxa1y2r2fF1kkxSbJyk0xXfIs/CbZGyNccXAlWszkIG9gvwlLnwUJ XEZwGb2utVwPXM7Q+s0S/b/3nESr88dYC3FL8YDNLwGoONn8wsBaNk17d8pyJaxRAew13O0uJAwpV 8Ak3UWm3ADEqTKVU10lhB6zAB1A8lH9kqvdUf2dx1xd0089dccHyGqJGwry0Ga45eAE3Faz5FuakK QReeyYcnVCCdoNzEDR4g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tkzLg-0000000GptL-3Wm0; Thu, 20 Feb 2025 05:43:48 +0000 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tkzLd-0000000GpsF-3A2G for linux-i3c@lists.infradead.org; Thu, 20 Feb 2025 05:43:46 +0000 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-221057b6ac4so8252365ad.2 for ; Wed, 19 Feb 2025 21:43:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1740030225; x=1740635025; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8IMohSeK8gkqwGyZxC38NO7B7vZzY5EIwZHxDi6wbmo=; b=hYXoiB2HEtbYNE8CkgPzX1syWT4Z8XaYJ7k+cWzxkFoz7w0HfbCO3UxJvoO9nAy2nH vECtZffbXCYSsLPoIftJX6/mQV3s5CJGgggTe1kiWwYblvzZdxckX05Ddd1HrGKyzzD5 +jRAUf2dnmxtNs8T34YaBHTCn9m5QC+24poZZX1WVw/hRsRSZhcyB9b5JhjeqjDuZext yIhCMWV8Bk9yEzARKN6ueyVxpI3iFGw1WgsRGuoQnt1devxa87DyzOO6NfemcB4EZkdH 5xqjzhRLREFRIxch345x4m0doFKuxIuoKw1ZR08a30zhUi3l01p3wAfebVZzVMd6UrpM 5+wQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740030225; x=1740635025; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8IMohSeK8gkqwGyZxC38NO7B7vZzY5EIwZHxDi6wbmo=; b=HQLvULWHPqdDuupqKYDqcv1kC6D7c2efi9lcuMHM4RGkJUTTC6DsjHEmH/zNW9Fr2H lO9U2fKkPfOoIKNt66vHVOoDiFSA3RlfFqf60apJRogVvB+2XprzzZrqZMgeO1Kg7IyF T5jwwIFxOjn2AEoul5XpGqU3SsfmuDFhi5ee6O0fjqGdtxgel+Mh15rEOt28f69C+/Ih YHojw9DVJ1UrCV1xbheih6Z/50jhHiTLAlHJEdTAk31A6nfgiog9de2dShdiIvb7d4QJ AH/y38X6i8eaQWiesCktvI9r0lgHY0TCR8Q2UqJGgkfkjRr++05+OUz3SjjrBiyTgzeJ 5qxw== X-Forwarded-Encrypted: i=1; AJvYcCUCiBcP+0ev7oC0IqcABikr/v1dwwGe11aKVyo4NqRXCmW5Vg2oPrnBMsDZqnpUWNTayUi4ughvh40=@lists.infradead.org X-Gm-Message-State: AOJu0YwVZUFjO78dMhIQ2SBIn1P81bCSiQlme7ID6txi7bl3F9SZRVL5 0N589ZP8/8ezefQGRMQyFs1IMPDxTYWJcrc/0n+1XqjfkhFnlL18 X-Gm-Gg: ASbGncv3FnMp1uk6PFuTJDmW+bI35HzLTNQigvATREClf7rt0/mhFlDKKaP8eDB1FVO mg00Vboohcqn+etsDdIWCMEaeSk19gb+lS3rv1fQjHOQ4dx/G6RBMyuMLcdfscahkgbr5Y42BMy dkFpjMbb5C0hZ82nVF5l1/P+EfQ8C1A96jJQEVtUXkv/msvo9fDzLumXXlvK2Kc1y/AtrYuJl0r 283tuJ6GYPYSG1jv0mHJUHgotwpe6HSa52RmwpU9YyPUiOhO+ERxyVR/mnDAl1696uKlSvyWfvm 2kJ1ANd4gECVSw5TGHpj7PtywQ== X-Google-Smtp-Source: AGHT+IGBXepTc9P17+2mR0kT1gPNO4iTdvt0WTXULVcNdkEoHownFPvxNPEmpScIh0GvM1j1L9uplg== X-Received: by 2002:a17:902:e88d:b0:215:bb50:6a05 with SMTP id d9443c01a7336-22103efc0c7mr317994265ad.9.1740030224974; Wed, 19 Feb 2025 21:43:44 -0800 (PST) Received: from cs20-buildserver.lan ([2403:c300:dc0a:4fe5:2e0:4cff:fe68:863]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-220d534951fsm114415335ad.25.2025.02.19.21.43.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Feb 2025 21:43:44 -0800 (PST) From: Stanley Chu X-Google-Original-From: Stanley Chu To: frank.li@nxp.com, miquel.raynal@bootlin.com, alexandre.belloni@bootlin.com, linux-i3c@lists.infradead.org Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, tomer.maimon@nuvoton.com, kwliu@nuvoton.com, yschu@nuvoton.com Subject: [PATCH v2 1/4] dt-bindings: i3c: silvaco: Add npcm845 compatible string Date: Thu, 20 Feb 2025 13:43:27 +0800 Message-Id: <20250220054330.1711979-2-yschu@nuvoton.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250220054330.1711979-1-yschu@nuvoton.com> References: <20250220054330.1711979-1-yschu@nuvoton.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250219_214345_802420_3A7CA09B X-CRM114-Status: UNSURE ( 8.70 ) X-CRM114-Notice: Please train this message. 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 a compatible string for Nuvoton BMC NPCM845 i3c controller. Signed-off-by: Stanley Chu --- Documentation/devicetree/bindings/i3c/silvaco,i3c-master.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/i3c/silvaco,i3c-master.yaml b/Documentation/devicetree/bindings/i3c/silvaco,i3c-master.yaml index c56ff77677f1..9be4bc4cc482 100644 --- a/Documentation/devicetree/bindings/i3c/silvaco,i3c-master.yaml +++ b/Documentation/devicetree/bindings/i3c/silvaco,i3c-master.yaml @@ -14,7 +14,9 @@ allOf: properties: compatible: - const: silvaco,i3c-master-v1 + enum: + - silvaco,i3c-master-v1 + - nuvoton,npcm845-i3c reg: maxItems: 1 From patchwork Thu Feb 20 05:43:28 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanley Chu X-Patchwork-Id: 13983353 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 AF04BC021B0 for ; Thu, 20 Feb 2025 05:43:50 +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=ndwDI7KcNauTIGHx3zC3mbSdkfJBfmNhS5L5Q2KpswI=; b=rtIq+gExkVbGVw 3L+AUkecjnCfrsvEAioshdJvUjWwLBQ7zzvk51+VXmgF8UYJyAZJ8InX8OWtZI+KIKOLOxFGQYTdI Nez5VGcINSmPwnyR0Jm9KkUdB8Jcly7KBnyWKXdhBvDwAh4Of6PaWfIS46LhRV9wl3Qdj+IlghoTh Gd0k9LUOmzrij7AS4SVCJAfXHSdUAcYJhqSStcQu136EuSja5GeYF2V0X3232KKtJgL9/thV3WDFu t7D0FnE0thk/nm9X+MAsDWbUinr6IdK1MIEKqp6OaMDUDPnw8PRdZtzXCHH3PCvPH0E+xx+MX/KqD bTbibsdiJUAKOXqWFbvg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tkzLi-0000000Gptx-1XNt; Thu, 20 Feb 2025 05:43:50 +0000 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tkzLg-0000000Gpsy-0clo for linux-i3c@lists.infradead.org; Thu, 20 Feb 2025 05:43:49 +0000 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-220ec47991aso6067455ad.1 for ; Wed, 19 Feb 2025 21:43:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1740030227; x=1740635027; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=JdyLMLTg8byPe8k/ZJkRLFsyG1RrElmC3EJS6e+873Y=; b=lNgAe3R5qYWwnrGkSnpmK3ogWwgHtxjmSoOWD2n1Wa2nfDeBsjZHqHsDTr+/033+T8 hcf835uNC1slkBMrDZcxeuYbhzY1FKABAaD84lzoxX7TX6/XwwKnxF+doDEQUhY7gbP5 i8zGG21RNrSc0BnL9bNM8f4aw8+RQSQ/Eygfo68FektfDhwzHaUJuzQ72T0VMW6vE+RL BuXs8o4wbfLtW2fsEE4ifhJYQDpdKKVOsCn55Cc3cwvlYv5PlOoMZa/p3H6j8qk4qp1+ brUiOKFGL1kmbsNiDRZ51UsMbCOaj8+h9A+Td2DmlTTEcSKTcC4rAaeI0dfgWzgf15II ulXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740030227; x=1740635027; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JdyLMLTg8byPe8k/ZJkRLFsyG1RrElmC3EJS6e+873Y=; b=A4/CqeBF4KRwCSafhpJBCnkapcXqnjVuAgdJvClV6KYFq+t6r1CsswZm5pR2WSPGj/ X0gX/tHdjKwakvOohkA0CnrI+TvJt5sFoVzp0weyN12mmJsctNltNGAgG9jx+0Q5TtF4 S5u1LFqaRMtHQ7ULBKleuNdrc5eM+hPOuAME+3aQJT2XxGYfuqDpffG9wz1Jh/zmB5kp Ac8NuEcs3Upw6vreMipE3QwT/Z8txRY/Rpys+fj9JOt8XyTpD8ODIJKkKoUWAFHIAtG2 9MOFkPO08t5Iw6GwdByQl83Ruue99MfbjyPIhW6ZonX7SGfD1t3ycN7W7EZbZnPN+csV 7hJw== X-Forwarded-Encrypted: i=1; AJvYcCVBzKnLVCvDKAA/1CTTEkpidiLqBO08tB7XGQioGrmZa9ppNsGIwjhh9ejrAZLAlX2Ksz/h0kBSID0=@lists.infradead.org X-Gm-Message-State: AOJu0Yz6ES4ezK3t7TzbgioDkFY15cIvOcG65s6SkxjhqvLeV49K6mhY fZGkENpeidvwQ0YPOIItR/9YHCHTqQDbBWflMJgE6jrtpm9UmbhH X-Gm-Gg: ASbGncspnCGw6xgvBt9PY02ks1GQHbBAOJZd1cMU1s21naA+xXZvYHs+6VWYHj4UL4L qiVrkEfhs89XhRpUuhGPS1mjfx+o4lRcqv5LvlPXSyRUF2LxvcG/AmHKGe9VHD6mFKIiO/R7YPq y14wAN8ByrR4yiI19B2ZA+f061m2ODlTiysEKF2AfPMxhVdqNIxmdTJajFQEYJvsh6hgDPmpEaU flIvJ1NDENCTpGtnW8RphS9BUF4Byr4rxfgMRFCMqmIT/hQJVgC/pzT+Q11NHecdOdUOSOw+AN9 H+4X146tG/YEiY986X7G4XtjgQ== X-Google-Smtp-Source: AGHT+IHpDIBFsH7vbUvCxPzxU+DThzUJ3gvnL5P2dGfiTDolUeJEuC1kCfITRVmlniKuIgAkbGy8og== X-Received: by 2002:a17:902:f609:b0:220:d79f:60f1 with SMTP id d9443c01a7336-2217119ecc7mr98131815ad.42.1740030227442; Wed, 19 Feb 2025 21:43:47 -0800 (PST) Received: from cs20-buildserver.lan ([2403:c300:dc0a:4fe5:2e0:4cff:fe68:863]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-220d534951fsm114415335ad.25.2025.02.19.21.43.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Feb 2025 21:43:47 -0800 (PST) From: Stanley Chu X-Google-Original-From: Stanley Chu To: frank.li@nxp.com, miquel.raynal@bootlin.com, alexandre.belloni@bootlin.com, linux-i3c@lists.infradead.org Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, tomer.maimon@nuvoton.com, kwliu@nuvoton.com, yschu@nuvoton.com Subject: [PATCH v2 2/4] i3c: master: svc: Add support for Nuvoton npcm845 i3c Date: Thu, 20 Feb 2025 13:43:28 +0800 Message-Id: <20250220054330.1711979-3-yschu@nuvoton.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250220054330.1711979-1-yschu@nuvoton.com> References: <20250220054330.1711979-1-yschu@nuvoton.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250219_214348_185658_C057403D X-CRM114-Status: GOOD ( 14.72 ) 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 Nuvoton npcm845 SoC uses the same Silvico IP but an older version. Add npcm845 specific quirks. Signed-off-by: Stanley Chu --- drivers/i3c/master/svc-i3c-master.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c index d6057d8c7dec..c58440061d5a 100644 --- a/drivers/i3c/master/svc-i3c-master.c +++ b/drivers/i3c/master/svc-i3c-master.c @@ -133,6 +133,22 @@ #define SVC_I3C_EVENT_IBI GENMASK(7, 0) #define SVC_I3C_EVENT_HOTJOIN BIT(31) +/* + * SVC_I3C_QUIRK_FIFO_EMPTY: + * I3C HW stalls the write transfer if the transmit FIFO becomes empty, + * when new data is written to FIFO, I3C HW resumes the transfer but + * the first transmitted data bit may have the wrong value. + * Workaround: + * Fill the FIFO in advance to prevent FIFO from becoming empty. + */ +#define SVC_I3C_QUIRK_FIFO_EMPTY BIT(0) +/* + * SVC_I3C_QUIRK_FLASE_SLVSTART: + * I3C HW may generate an invalid SlvStart event when emitting a STOP. + * If it is a true SlvStart, the MSTATUS state should be SLVREQ. + */ +#define SVC_I3C_QUIRK_FALSE_SLVSTART BIT(1) + struct svc_i3c_cmd { u8 addr; bool rnw; @@ -216,6 +232,7 @@ struct svc_i3c_master { struct mutex lock; u32 enabled_events; u32 mctrl_config; + u32 quirks; }; /** @@ -230,6 +247,14 @@ struct svc_i3c_i2c_dev_data { struct i3c_generic_ibi_pool *ibi_pool; }; +struct svc_i3c_drvdata { + u32 quirks; +}; + +const struct svc_i3c_drvdata npcm845_drvdata = { + .quirks = SVC_I3C_QUIRK_FIFO_EMPTY | SVC_I3C_QUIRK_FALSE_SLVSTART, +}; + static inline bool is_events_enabled(struct svc_i3c_master *master, u32 mask) { return !!(master->enabled_events & mask); @@ -1811,6 +1836,7 @@ static int svc_i3c_master_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct svc_i3c_master *master; + const struct svc_i3c_drvdata *data = of_device_get_match_data(dev); int ret; master = devm_kzalloc(dev, sizeof(*master), GFP_KERNEL); @@ -1868,6 +1894,8 @@ static int svc_i3c_master_probe(struct platform_device *pdev) } platform_set_drvdata(pdev, master); + if (data) + master->quirks = data->quirks; pm_runtime_set_autosuspend_delay(&pdev->dev, SVC_I3C_PM_TIMEOUT_MS); pm_runtime_use_autosuspend(&pdev->dev); @@ -1960,6 +1988,7 @@ static const struct dev_pm_ops svc_i3c_pm_ops = { static const struct of_device_id svc_i3c_master_of_match_tbl[] = { { .compatible = "silvaco,i3c-master-v1"}, + { .compatible = "nuvoton,npcm845-i3c", .data = &npcm845_drvdata }, { /* sentinel */ }, }; MODULE_DEVICE_TABLE(of, svc_i3c_master_of_match_tbl); From patchwork Thu Feb 20 05:43:29 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanley Chu X-Patchwork-Id: 13983354 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 4AC7EC021AD for ; Thu, 20 Feb 2025 05:43:54 +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=yVm8N0n+xzFhIUQCkn61nO0ayR2HoLGmP2dTtMbuk74=; b=H7AWW6gu2Tr6OJ qV7hybHK3NQIr/rnNNPVMQBtLFkwR9DftOgeJWuYMpJroIyV7EIqIZByA0FfH7reiJfe65PhU6L28 AmO6rnVzXyN1bU5xSqrdNwuWV+HZuDtTohSyspfvrAcfHz8GmQWKANtti56w+Tov3euGRBugCpEAP 5bh9DOo4cZwPqLFbaUEJ4RyVsdomb7AeScAmEAwj8AFfpnb3SsylDsUFKOIf4ZyXhL5lAgWjYC38a lbyOKhhFI4jl/xd6/bEaJkAQ5z7dG1TA4hGjOuDbUzzAoLOVULjxVLH4luLRpPko+phpuqWGuX4A0 oIyBqF0W8lMoQzp40mJQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tkzLl-0000000Gpvs-40Yk; Thu, 20 Feb 2025 05:43:53 +0000 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tkzLi-0000000Gpu1-2y4o for linux-i3c@lists.infradead.org; Thu, 20 Feb 2025 05:43:51 +0000 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-2212a930001so13476725ad.0 for ; Wed, 19 Feb 2025 21:43:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1740030230; x=1740635030; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=h+uWDhaMgi+jxwkqAdo/eMNwsqE8P1kcmn3GiPEcAYA=; b=c3208fBvZ7cM8/+/CRvovdP5ynkG/Mshna+x3iTD8P/JWQR/togcZQvFgyXpUNm3b0 67R0iAn1SCtgMjbZ8iGXExK6sXgd5hM2wUL6YPV4VG4a+1cduCTWyzExlltmySy6Fo3x w0bU++Au6R43pxHfW7a9d7EsRD+ghwD/km8AHEGEODlQktxJe0BECxJ+NT5rUUxYgf3G EjqfVxsTRK4MjqaV6N1oerNdS8qbnem9cj3j6K6GFK4aIumhkeO43GjjoOEgerxbsyKL LSxmHHTpxflZD//OWM3XCjGDatQlsUfhSbzf3DZPU5XEc7LcfAdf+BItGcAMcIh6Ijrd Lj9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740030230; x=1740635030; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=h+uWDhaMgi+jxwkqAdo/eMNwsqE8P1kcmn3GiPEcAYA=; b=qsfDMu2fiubGg5QHE8DWbTvVgp+4o1k94QLkdVjMFXVkVHtqWjJtbE0eipmajjfJB1 dhQqn+q0BobOe/jZXM7PwPm+0Qm3OgsPvobzGsVLkVepM6PyOMx1oLPuMdGtBp2g1GM/ VofNF1dTo0CdLbPy2OajJLKyGs0xjut4AHf1dZjLmFsC+R81ieycmq3s/SDDyTDqxYoE 5kHD0M6c7dGU+VPLqgD3xFszRncDfp6cmQ99mbEfEIUkki9/dq1T+NUkqre1HXJ+6Cpg zzRIJdond6ys7gvGlfQk4XRAEHenPrgHAYuaElud0FLXPBgeCvSKAIIiys8puGkBm5/y LoZQ== X-Forwarded-Encrypted: i=1; AJvYcCULQ/akVEjpGgWta76HvJAfErw4gPSRdkR0lcz7Ypc2NN637m/XLNimP+rBbKBX3nIHmACGHaiA6a8=@lists.infradead.org X-Gm-Message-State: AOJu0YxBDZrF50kIRZK7nJHQRlqo7K7kG+7n0X5Ookg2yecilxFSXJIu vXj6PlflfpU2CWGcSeJycgY1nReCO+/lKOpRCU4Q6+wOYpQ0Nq6nCbn7jg== X-Gm-Gg: ASbGncttWtaQdhy2yxD9nyEdhDRX8mPpiWSekM/dQ2SqAlw2s+6kl8du8W3unvR8UkE oUNktBGzBFkPgfpQawOcNs7SaYuDmfWRnQwwqtZbPZSbnos1/0+HpqMhZQbslrhIQU/9xU/27EO SMoIjiFJSyXaC7EaSI4myOL6mYxWG8+GxXEMyzrL5556lRh62rcAqIcWdKwmgiRydNvAMlRA/2E dwzptq84SmVs1/qM6+HuCKCnsg4iQXxNP4rKSb1cwq+sRct4Z9Y78UKpFPy2lLBOLFFOOEQD7gD TNwaITeZcRrNRoYhF2duBSv93g== X-Google-Smtp-Source: AGHT+IGGhLQt8RYHyL3O5/X/szpd7Iw5l6Qfx7Qwl68H9aQX/UAag77wmnRGfcRwgAJCMHxr4lD11w== X-Received: by 2002:a17:902:ce0d:b0:215:a179:14ca with SMTP id d9443c01a7336-22103ef5861mr324352105ad.2.1740030229980; Wed, 19 Feb 2025 21:43:49 -0800 (PST) Received: from cs20-buildserver.lan ([2403:c300:dc0a:4fe5:2e0:4cff:fe68:863]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-220d534951fsm114415335ad.25.2025.02.19.21.43.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Feb 2025 21:43:49 -0800 (PST) From: Stanley Chu X-Google-Original-From: Stanley Chu To: frank.li@nxp.com, miquel.raynal@bootlin.com, alexandre.belloni@bootlin.com, linux-i3c@lists.infradead.org Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, tomer.maimon@nuvoton.com, kwliu@nuvoton.com, yschu@nuvoton.com Subject: [PATCH v2 3/4] i3c: master: svc: Fix npcm845 FIFO empty issue Date: Thu, 20 Feb 2025 13:43:29 +0800 Message-Id: <20250220054330.1711979-4-yschu@nuvoton.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250220054330.1711979-1-yschu@nuvoton.com> References: <20250220054330.1711979-1-yschu@nuvoton.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250219_214350_768468_60283059 X-CRM114-Status: GOOD ( 13.32 ) 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 HW stalls the write transfer if the transmit FIFO becomes empty, when new data is written to FIFO, I3C HW resumes the transfer but the first transmitted data bit may have the wrong value. Fill the FIFO in advance to prevent FIFO from becoming empty. Signed-off-by: Stanley Chu --- drivers/i3c/master/svc-i3c-master.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c index c58440061d5a..2140da3f5187 100644 --- a/drivers/i3c/master/svc-i3c-master.c +++ b/drivers/i3c/master/svc-i3c-master.c @@ -1196,8 +1196,8 @@ static int svc_i3c_master_read(struct svc_i3c_master *master, return offset; } -static int svc_i3c_master_write(struct svc_i3c_master *master, - const u8 *out, unsigned int len) +static int svc_i3c_master_write(struct svc_i3c_master *master, const u8 *out, + unsigned int len, bool last) { int offset = 0, ret; u32 mdctrl; @@ -1214,7 +1214,7 @@ static int svc_i3c_master_write(struct svc_i3c_master *master, * The last byte to be sent over the bus must either have the * "end" bit set or be written in MWDATABE. */ - if (likely(offset < (len - 1))) + if (likely(offset < (len - 1)) || !last) writel(out[offset++], master->regs + SVC_I3C_MWDATAB); else writel(out[offset++], master->regs + SVC_I3C_MWDATABE); @@ -1245,6 +1245,19 @@ static int svc_i3c_master_xfer(struct svc_i3c_master *master, SVC_I3C_MCTRL_RDTERM(*actual_len), master->regs + SVC_I3C_MCTRL); + if ((master->quirks & SVC_I3C_QUIRK_FIFO_EMPTY) && !rnw && xfer_len) { + unsigned int len = xfer_len; + + if (xfer_len > SVC_I3C_FIFO_SIZE) + len = SVC_I3C_FIFO_SIZE; + ret = svc_i3c_master_write(master, out, len, + xfer_len <= SVC_I3C_FIFO_SIZE); + if (ret < 0) + goto emit_stop; + xfer_len -= len; + out += len; + } + ret = readl_poll_timeout(master->regs + SVC_I3C_MSTATUS, reg, SVC_I3C_MSTATUS_MCTRLDONE(reg), 0, 1000); if (ret) @@ -1306,7 +1319,7 @@ static int svc_i3c_master_xfer(struct svc_i3c_master *master, if (rnw) ret = svc_i3c_master_read(master, in, xfer_len); else - ret = svc_i3c_master_write(master, out, xfer_len); + ret = svc_i3c_master_write(master, out, xfer_len, true); if (ret < 0) goto emit_stop; @@ -1333,6 +1346,7 @@ static int svc_i3c_master_xfer(struct svc_i3c_master *master, emit_stop: svc_i3c_master_emit_stop(master); svc_i3c_master_clear_merrwarn(master); + svc_i3c_master_flush_fifo(master); return ret; } From patchwork Thu Feb 20 05:43:30 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanley Chu X-Patchwork-Id: 13983355 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 97FA7C021B1 for ; Thu, 20 Feb 2025 05:43:55 +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=srT1EI4stHcVt/Wu5HMVL+TczgZyc5b1/yrYh/uNZMQ=; b=l6cL5echWxI2pr pqbuh0u2+wsgIh2PkVsO1uZ+rjCc2R7PUYiXbTqtT9QdYUMb+xmKhHWtg1aZHXGp0vzpTMGpYVYTe aMyXu72RbAQ6o7BHOFrei7K3klMqvt4zOy2A+1JTN1UEyKe6UMHDnzS/moCUSZy2Qm3cNQx2yYryl H9DPHwnBjA1aiON+r5wrXuJ1Ct5VVUex0QhtROromOoPSTFv4J4N+/E1uikYCGIQi7RZLeeTZA3Bp VyGjiqtpGj5ihITcKaSJ1Q6zW9iV6wV5/KoJALgCOmH74dXZWHK8xleFNM6J9nnDorFafbKoPgw4q 78biel9g62zOd+QWNNHg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tkzLn-0000000GpwT-1Tng; Thu, 20 Feb 2025 05:43:55 +0000 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tkzLl-0000000GpvN-0OF3 for linux-i3c@lists.infradead.org; Thu, 20 Feb 2025 05:43:54 +0000 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-219f8263ae0so10249655ad.0 for ; Wed, 19 Feb 2025 21:43:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1740030232; x=1740635032; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=SEAs/2W8i6unwL/IOH0/meAWRqs6OoDg3QxDG87nlzI=; b=lRSYmwkjC0S6bWkiyrKE1lqJoE3CQJGzgz84YElyfXOtQbwAv2p4G8jytIPvrDFyDt GwxNgfiKm3J8RnG98ju1DIKUPVXqL3WsW9mAoeqO3NHKNQKhhdWmmS0UvD1tXu7pHWBg GYbbFFD7KaPCkD1VwQc2mvZazrATcJRiLADY+gLEKen6bf9M7MeHm9C3y8whomQxmigR EUlb0zFLHVGaO3sJKwf+6cNQDZ8Ab4lG78Ae6nxUxNikaTidy/RgJVyW9fXHk761xgNh WFsSbEX8ILbxyeiTP2JhjwLBt15xR0ETSZIgxkxjUF9xnmn6Sma29LaVxqflreFlw45e peGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740030232; x=1740635032; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SEAs/2W8i6unwL/IOH0/meAWRqs6OoDg3QxDG87nlzI=; b=wDCkNUn5CSP61u6Z8/cmR2O7ZA+ys4vVFmJetmUZm1+iqX6OukMEOgW4yttHdVTu4B 9R1ZXtxOwZvpITZ85Pip33+uWd1Yp4v7cg2SS6rAv/AMN2U+cLlFJ8F7Jyjqt+gjoC5t 3kFUQ5xnurQlHFK0MC7otnV+bsbTtOud9SkgPuf6JdP49Qa1p02IPDGjme6unKGVBWSq zJbHwHkmMKdXE4mvcFEaew7w/ALY/8XTh0NQia6ZD7yfCY+zNusgCBllkvQeP/pEujEk RsWxS8YbQXjPNoVMifiNnwUjbF/1R25652o9K5pYugOU9A0/pjsxm1QQfEQXz3hwKPgR 21LA== X-Forwarded-Encrypted: i=1; AJvYcCVBzo5SyK2QJLS1m5RQxJfDhX2Wd1mFhKj6448EphYq4VJ4bwSeOmtXVZd2RcKBB4RzurahowuJid4=@lists.infradead.org X-Gm-Message-State: AOJu0YyktkSWjJEyMK1428MUKc5FVLGoZZVGNl87717zdfbm9QEUKKOZ vUpdhwSIwhJV2mTbClo+j1PN4k7ZLuOBkgYsajHYbAH4HCSwgh6s X-Gm-Gg: ASbGncti5bHeGlnGnBWxTNuuH+8okOhSGcK/a5serNxQ14ooGQFukdsh1NsAWOBC072 EljfB9UMjJkYOyLilRl0CwBUh0VksSkI5BlgYTM4pGYQjHPIxjKGEOPfQMjAvHV/f1CXyerN04O rxNJudeDl/H6IDzK0kKZV2APe6MWlkZ09h3AE6ue0h+USMTg9xiOZGBJLvDq2nKEc6Y7LRBUYvq F5c7aiORmji1um4LKhQThHJfaN7NI3HJZLCDanIwQyY8kUQrno7SvzylQ71fCAfq2fDvKa2uN61 bjb28O9qDThxivv+NWvTfLH65Q== X-Google-Smtp-Source: AGHT+IGUkXoXo59VQXM/7j5YyIdcs9w/cg9RxyXROlX7CbTDYkiET2l2tQDyhfUyca1cDQgdkp4yXg== X-Received: by 2002:a17:902:e887:b0:21f:4c8b:c4de with SMTP id d9443c01a7336-221040bdb96mr284464145ad.42.1740030232395; Wed, 19 Feb 2025 21:43:52 -0800 (PST) Received: from cs20-buildserver.lan ([2403:c300:dc0a:4fe5:2e0:4cff:fe68:863]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-220d534951fsm114415335ad.25.2025.02.19.21.43.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Feb 2025 21:43:52 -0800 (PST) From: Stanley Chu X-Google-Original-From: Stanley Chu To: frank.li@nxp.com, miquel.raynal@bootlin.com, alexandre.belloni@bootlin.com, linux-i3c@lists.infradead.org Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, tomer.maimon@nuvoton.com, kwliu@nuvoton.com, yschu@nuvoton.com Subject: [PATCH v2 4/4] i3c: master: svc: Fix npcm845 invalid slvstart event Date: Thu, 20 Feb 2025 13:43:30 +0800 Message-Id: <20250220054330.1711979-5-yschu@nuvoton.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250220054330.1711979-1-yschu@nuvoton.com> References: <20250220054330.1711979-1-yschu@nuvoton.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250219_214353_130279_A3FEE41B X-CRM114-Status: GOOD ( 11.11 ) 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 HW may generate an invalid SlvStart event when emitting a STOP. If it is a true SlvStart, the MSTATUS state should be SLVREQ. Check the MSTATUS state to ignore the false event. Signed-off-by: Stanley Chu --- drivers/i3c/master/svc-i3c-master.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c index 2140da3f5187..5861358eb9e5 100644 --- a/drivers/i3c/master/svc-i3c-master.c +++ b/drivers/i3c/master/svc-i3c-master.c @@ -58,6 +58,7 @@ #define SVC_I3C_MSTATUS 0x088 #define SVC_I3C_MSTATUS_STATE(x) FIELD_GET(GENMASK(2, 0), (x)) #define SVC_I3C_MSTATUS_STATE_DAA(x) (SVC_I3C_MSTATUS_STATE(x) == 5) +#define SVC_I3C_MSTATUS_STATE_SLVREQ(x) (SVC_I3C_MSTATUS_STATE(x) == 1) #define SVC_I3C_MSTATUS_STATE_IDLE(x) (SVC_I3C_MSTATUS_STATE(x) == 0) #define SVC_I3C_MSTATUS_BETWEEN(x) FIELD_GET(BIT(4), (x)) #define SVC_I3C_MSTATUS_NACKED(x) FIELD_GET(BIT(5), (x)) @@ -589,6 +590,11 @@ static irqreturn_t svc_i3c_master_irq_handler(int irq, void *dev_id) /* Clear the interrupt status */ writel(SVC_I3C_MINT_SLVSTART, master->regs + SVC_I3C_MSTATUS); + /* Ignore the false event */ + if ((master->quirks & SVC_I3C_QUIRK_FALSE_SLVSTART) && + !SVC_I3C_MSTATUS_STATE_SLVREQ(active)) + return IRQ_HANDLED; + svc_i3c_master_disable_interrupts(master); /* Handle the interrupt in a non atomic context */