From nobody Tue Sep 29 06:08:43 2026 Received: from mx0a-0002e601.pphosted.com (mx0a-0002e601.pphosted.com [148.163.150.75]) (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 BB7BB386576; Tue, 11 Aug 2026 18:34:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=148.163.150.75 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786473259; cv=fail; b=GIBI7BcAnSESM4MYpl9SnhB/UEiRdOhB8UQFRj+pBzXlCGL6LBcmxv8CRnWqO/7s67ewDrsxkkabF6Yo7c/aeHpCoRb+n8TXQiNhLr0dIy9pPsXN9zNQjbeHLnHO7Maclz1+QF3DtQvAMBkOx7dnjP5S7Mxu2e4dF/J771gAymc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786473259; c=relaxed/simple; bh=NpoT/cBBl4rAzM2NVlulrn3aPKLC+iksPz2nkPNIsok=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Euj0E2Ohs5a3LJTYlKZatWCxyUjb5CHR4egWrUB+z5Xdgz8UTPURoBsFq2vHfumjRtXGB/DZkWRK2Z1G6QuYKmozqEGpK+b9Xv67Tno0mRWnTPBudsaOJOHbNFFThQuy9cc74Ut2Y6iR+J1IOi4GL62JQpDJm8gjIf4TPfrAcm4= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b=KAySNhFe; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=kr5jKT1u; arc=fail smtp.client-ip=148.163.150.75 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b="KAySNhFe"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="kr5jKT1u" Received: from pps.filterd (m0384305.ppops.net [127.0.0.1]) by m0384305.ppops.net (8.18.1.11/8.18.1.11) with ESMTP id 67BGM53t2459900; Tue, 11 Aug 2026 13:34:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint-05-2026; bh=+pWYfJ1EP748IQC6CtiOQMdvqHr9KlmObkQrKfpTY Hk=; b=KAySNhFe6w7EQY7+QhQgWV6avom27/hB8Ij2U9WupA7IGEowFPAGyvU7P tgVUqHt+60yMKWT7OO2Xyb82rq/ynxIkMQNNk7YJLugs3Gf02GxAUlFfC2lM0lfC +orEJyhqGbs6w3N8T6WkX4/HJTC11KnUZJkf+OMs5dB4q27AA/VFJpfIEzTKiuN9 N1h/DfnokIfJQoWtSPzYwOnSV370gTXiU7/tWqXrxn846WOcopU0epLEfhiT1oyf 5znb5ifRrbeIctiREMQBpqb7wgi8Rr0iwNUOH0eqX9zHgqQ0QqHcYe3PNyjjDGLZ +anVwIZ1jClAPB2C9a6F6ZFGYYpwg== Received: from bl2pr02cu003.outbound.protection.outlook.com (mail-eastusazon11011060.outbound.protection.outlook.com [52.101.52.60]) by m0384305.ppops.net (PPS) with ESMTPS id 4g00wu3h29-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 11 Aug 2026 13:34:07 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=rabcwx5qayUfYXzN2SPRziffe8EFQp7Uj93BwnshIddwhSbZJuDTlqtPMTf+yV6hqfof6RaYarY4G1K7UBBfO6ryl8SsOH0Q8yWKDkEAgaXfWC4cT2ghPDtbstvH+UugGcI+HBycqMSMBleSds+G24fzITJ8Www5ikI4W48R+5fTWDXjOnl6M9F51/fyAgWWG/V8Le3WEL5hVvuRbtCHOjpj8vF8UKspE+AjToays+p+Iz1G84/2p5yFgjxmrhv+Do/o0c3P1j5IqCiExVLwe0uoenZ6BldfLhnGbEV3chIm/HRomuxxbDTxxV0s3Fhl0VL5PMj7QeBpl5NB7ugPLQ== 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=+pWYfJ1EP748IQC6CtiOQMdvqHr9KlmObkQrKfpTYHk=; b=K+lhGLvPUlWokvyQlyHGAYvJKcsXdDvHU1P7+1QHb8E2+FT6p64YObnv/FVfW4AB3/UB3lFZt0UY8SxFybtW6HvQwpFZK3IHOx/V5+NY2Ct87TecOTUXblF9W9fx07n5UDtskZsteAhuOlKZnd13nrCTRyz5WK2GyBoDhl3bv+26lfAHgrY0kcO0oVEzND6mvBAZ9JIzznLcyQHcift30ownTt6O8neYsqTGoWLc47Mk7uk2vCK8A1wXt1TKVS96WTJmf3TBUvpB8OGusrvc2sfbkasOXSLyep8yFiMeDzVwPw6hnKlVuyboqMMlh21/LGfuK8Um5Mdo2J247GnlOA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 198.47.21.195) smtp.rcpttodomain=microchip.com smtp.mailfrom=ti.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+pWYfJ1EP748IQC6CtiOQMdvqHr9KlmObkQrKfpTYHk=; b=kr5jKT1uAQ1gXvsVLpovthsljntf5KFhiQJNIGhKQqFS0TIYwhugrKbsQfvSQ35+KA7+6On6QIzAS8zEeAN9MYwx5Bpq4agqnRCXE/onb4P9we9UzzVkcLTInFBI3fJjZBlnE0JvWiD1IkbeXBt5tDwOKKyEw+b1bhTkvaGD5wc= Received: from BN9PR03CA0903.namprd03.prod.outlook.com (2603:10b6:408:107::8) by BY5PR10MB4355.namprd10.prod.outlook.com (2603:10b6:a03:20a::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.292.25; Tue, 11 Aug 2026 18:34:04 +0000 Received: from BN3PEPF0000B076.namprd04.prod.outlook.com (2603:10b6:408:107:cafe::ad) by BN9PR03CA0903.outlook.office365.com (2603:10b6:408:107::8) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.292.25 via Frontend Transport; Tue, 11 Aug 2026 18:34:03 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 198.47.21.195) smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ti.com; Received-SPF: Pass (protection.outlook.com: domain of ti.com designates 198.47.21.195 as permitted sender) receiver=protection.outlook.com; client-ip=198.47.21.195; helo=flwvzet201.ext.ti.com; pr=C Received: from flwvzet201.ext.ti.com (198.47.21.195) by BN3PEPF0000B076.mail.protection.outlook.com (10.167.243.121) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.315.6 via Frontend Transport; Tue, 11 Aug 2026 18:34:02 +0000 Received: from DFLE214.ent.ti.com (10.64.6.72) by flwvzet201.ext.ti.com (10.248.192.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Tue, 11 Aug 2026 13:33:29 -0500 Received: from DFLE201.ent.ti.com (10.64.6.59) by DFLE214.ent.ti.com (10.64.6.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Tue, 11 Aug 2026 13:33:28 -0500 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) by DFLE201.ent.ti.com (10.64.6.59) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Tue, 11 Aug 2026 13:33:28 -0500 Received: from santhoshkumark.dhcp.ti.com (santhoshkumark.dhcp.ti.com [10.24.52.55]) by lelvem-mr06.itg.ti.com (8.18.1/8.18.1) with ESMTP id 67BIXIdr659766; Tue, 11 Aug 2026 13:33:24 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , , "Conor Dooley" Subject: [PATCH v7 01/18] spi: dt-bindings: add spi-max-post-config-frequency-hz property Date: Wed, 12 Aug 2026 00:02:56 +0530 Message-ID: <20260811183313.1550425-2-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260811183313.1550425-1-s-k6@ti.com> References: <20260811183313.1550425-1-s-k6@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN3PEPF0000B076:EE_|BY5PR10MB4355:EE_ X-MS-Office365-Filtering-Correlation-Id: 0bace659-4b3c-45ad-9658-08def7d71dff X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700016|23010399003|7416014|1800799024|82310400026|376014|921020|6133799003|56012099006|10067099003|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: sCIiry09vR839yIVvEqszqPhrDYWsNJDlmlmQeD2Pgz4X18SNtXLMjeox19Y43AA27f06oS1bE0ov85zA4bwQFB+GvP9xVp5H2Q2G98H7CuokRSmiml2ZVD1UTvalFxV5oIK2Mtc+4OEhJYo5sI6FcvdTenc1Z9+ZM9r8AGLzQotJmF3xOwkv8UfTLC3CI5wlX0/NN05McxM1Nle86Llb3jkFYGuva8x3Hi1dA8lC5BwtEBOzsPVmmmqsORQxCkmI8jtZFfJpR+TUvg2onl17zd8LbpgHb7dsN7pws/J2dxH4jc0R10CE5fz8nhP6uGENtHVmFLDZgYDX8O01c7Iw0jP9OaMjwd/Sxn89MkCDN46I3mCCQ63AFohbJ/kMb4XqcDMzKQPNDKUKYZd3cSw/zGeZmn/HkNFt6ucHEMNNs4w8JW/LgRkWX19rZ0cgsedXr2kh40HXpxojICvc4fE0/klcW/ESU2JegsXdhpp0QiVxv6FqqguLjWle0E2cxZhhI6QUfTenYm35Nqn9Y8zMXc/1whgWN1hFZuAyjztsymx1w0idehR5sZXVPm8aZd9lG0fYQ5W/N+Do+vayNmC4Z4HRNkjt805W9tmfG7ojfWRSnPqEODKCFap8T8ojFSFVB5PUN3fD3ip3uj8EatlWkypH+ZovuH9TPxlr1Hs/WmG6qFtepHSWAEGx0IjGqmsVoDou1jPS3lYhBBkhVWHpp2jmM9RJSVsGEUtG0omjRqBwElO0TWipaQE+4jOA0J4 X-Forefront-Antispam-Report: CIP:198.47.21.195;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:flwvzet201.ext.ti.com;PTR:ErrorRetry;CAT:NONE;SFS:(13230040)(36860700016)(23010399003)(7416014)(1800799024)(82310400026)(376014)(921020)(6133799003)(56012099006)(10067099003)(18002099003)(22082099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 5nN4oetX5jkG2XzruWxs5AjrP/wKyR4tWnbq7Ce4TezWvN3wOEyTbRG9cHOGJTrnrRl5iXEGj+BQY2LL/qY8maND9sJT6F7e2Po5xFpjx+6iDjLvQliF4J8NaYMvfIz1rOKy7Nd14huxiBDnzx3mlhOgrM7opGdo0ar2eMOrZyaQea/XmO82EIZIjTsxYzW5F0LAjgBHgtPLUQ8cP8UmJ7Ib2C9j67UYtXDnFXB/iQ/At69SKZNlQmu2qZz4pow8Vw5GwYkslnnP+4u+aYS4cPZsGiTMt9AlpzsncIOLPjsTcQK1zGnvUYPib3fvWGHpvnSb1H6KP7xKXoQRqytV/x1f4K/T+zNMDLu3SOMiSnXQQ5NFuTG//md1aXuM8IKw/jPUrJTPPyUMa358lO9nDe3GKsJ5J+VPIOXCUHveoY8xENMX+vOxuAobbA+QI+l6 X-Exchange-RoutingPolicyChecked: bcQw0bm7Wg7MAVgxmzFqx+t5yN/XFh+D6KLQw9QqqNo9uriJHIG+HbVgOJNHK+YIhr7QQGu/EY18yRk4/a6WFm9MaYHao7pLHuxJrvwmAnBqV7c6XnDoU3kj3W+OFvINpyVSt1BcPA3/fJAT/S+i2bIeIeRZArRky3m+15JTrM+WggC1jEwN5Nd/4SboZG9n7UXUdFuKZWtk2iGhGrLLbREqoLkSGuwMGP3eemqbGdP6mH3YlB0Bx4lsvqhsBWdGVfgDQwy8GdpajG0KYCJvkzGHN2a8kR5/2okEckn79UqUgC2Kj9CR+vsw89+eqVplAVtrXy/e9MZVbs9CXZvwqA== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Aug 2026 18:34:02.5317 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0bace659-4b3c-45ad-9658-08def7d71dff X-MS-Exchange-CrossTenant-Id: e5b49634-450b-4709-8abb-1e2b19b982b7 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=e5b49634-450b-4709-8abb-1e2b19b982b7;Ip=[198.47.21.195];Helo=[flwvzet201.ext.ti.com] X-MS-Exchange-CrossTenant-AuthSource: BN3PEPF0000B076.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR10MB4355 X-Authority-Analysis: v=2.4 cv=M+V97Sws c=1 sm=1 tr=0 ts=6a7b6b1f cx=c_pps a=AqWYtYKdvuqIQX7AE/aD9Q==:117 a=tJyPKKxUohctrY4NYmUjkA==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=Sv0fKeRqtYgA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=taLDd7a_hP9WKsMzeGRc:22 a=XYAwZIGsAAAA:8 a=sozttTNsAAAA:8 a=skPbNTvFiSR7kuR3s9sA:9 a=E8ToXWR_bxluHZ7gmE-Z:22 X-Proofpoint-ORIG-GUID: -eaDOk-jHSzKY4JC3UrHITAcFyHRV4Zx X-Proofpoint-Spam-Info: AW1haW4tMjYwODExMDE1NiBTYWx0ZWRfX64kzLb2uxXy/ 9BbJfXG+1rclz1wOhU5+Fto0/nAbzZh4Uz/0MkDIN5ZZwTWOZyABnZgoYz85GmN8WEGQSP8GLvy 3FEKLjp5yWLhoxX38xse+heJW2rDL3w= X-Proofpoint-GUID: -eaDOk-jHSzKY4JC3UrHITAcFyHRV4Zx X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODExMDE1NiBTYWx0ZWRfX8r1vrmID5jhX bUNLsZMgIPIItm+8P0Z+ARpPsARPxP4JQKwGBUrtfkBPvcCYjwZAVJWtDxWCVgZvaXFG6LvJsfx pW1cowscquXdiedT4b1EcDjSzlDL0CkhxnPqSsF3zwfQKhDma2ewjR0evuXd8KmISkIUtfp3t8C 7UqE7t3IpGwE0ZSUIKWo8SXE6MLqhFAlcSINH5LwVWsqCEDKow73bJ06g64EkfmCILkZ0OppSHv YCCXP6/v8YZgMcZnQWPlHjap6GkBlSu3Po6Uf4RnRBEN+TK5wb/w8QNZxbbqgcIujqHEPRJzFtB org0IFqciG/54cvB7GRv/wI+rgUY3vEletD+yRA1rHXmMmikhnlboQDyfjy2F3480VLDAtEXX7E dyDFQHMhqgDyXMD7CBQ/tvgwomKk5rs6aWYnAaGrwSNx/pzQ0zkTnfJEGilOiP1jJQ7QJswK1Sv 43PVnEJ/7CFRp0WQDfw== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-11_04,2026-08-10_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 lowpriorityscore=0 adultscore=0 spamscore=0 impostorscore=0 bulkscore=0 malwarescore=0 clxscore=1015 phishscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608110156 Content-Type: text/plain; charset="utf-8" Add spi-max-post-config-frequency-hz, a generic property for SPI peripherals that operate at two distinct clock rates: a conservative rate always reachable without controller configuration, and a higher rate achievable only after controller-side configuration. When both properties are present, spi-max-frequency gives the conservative pre-configuration rate and spi-max-post-config-frequency-hz gives the higher post-configuration target. Acked-by: Conor Dooley Signed-off-by: Santhosh Kumar K --- .../devicetree/bindings/spi/spi-peripheral-props.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Documentation/devicetree/bindings/spi/spi-peripheral-props.yam= l b/Documentation/devicetree/bindings/spi/spi-peripheral-props.yaml index 880a9f624566..84976fd3ee1b 100644 --- a/Documentation/devicetree/bindings/spi/spi-peripheral-props.yaml +++ b/Documentation/devicetree/bindings/spi/spi-peripheral-props.yaml @@ -45,6 +45,12 @@ properties: description: Maximum SPI clocking speed of the device in Hz. =20 + spi-max-post-config-frequency-hz: + maxItems: 1 + description: + Maximum SPI clock frequency in Hz achievable after controller-side + configuration. + spi-cs-setup-delay-ns: description: Delay in nanoseconds to be introduced by the controller after CS is --=20 2.34.1 From nobody Tue Sep 29 06:08:43 2026 Received: from mx0b-0002e601.pphosted.com (mx0b-0002e601.pphosted.com [148.163.154.28]) (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 5360E3806D0; Tue, 11 Aug 2026 18:34:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=148.163.154.28 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786473256; cv=fail; b=LlCNFvEkWBbYSnqnDyrfoAKmMMq+nF+0CHDp+RQKi80E6fioH/Iegbwwo7aifw/OHNnLupzbMI69uxIjcuq1FNMHrHZXTBBX6djUGvvz/rBvhlBDrc5RCEAhrDIJPRE8FX5tUDcnDygcldK3YlJweuDTIr1H1Dbk4bzjgTcZEZ8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786473256; c=relaxed/simple; bh=aF/DbrmPXM4j0mLlW+L8B/c0eqWu65juxQfllEXfCQk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=XSRczZZQ7bTvpMtndRQNMplVobWC/qw3Qm4iHpNjuPgEeXfn0s5XEgNwa/be4gkn3qHom1ygXzpWajC0l2bRvl2whkB5N2JMqWR6v3NHKCaBbglVjLJxx63G7Y4BlIOmlIWjMQFe+X4TYhEwreplXvvkc8kMVgG/CiEHmMQvZDQ= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b=EP68VnfH; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=D98jcbWh; arc=fail smtp.client-ip=148.163.154.28 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b="EP68VnfH"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="D98jcbWh" Received: from pps.filterd (m0374955.ppops.net [127.0.0.1]) by mx0b-0002e601.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 67BGMc2R2174911; Tue, 11 Aug 2026 13:33:57 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint-05-2026; bh=CfcZ3asnTmwrkxDLnD+kXTLBg64BDPwemZSrihZFQ lA=; b=EP68VnfHQ4SoWS+W7DQaNHmBTGYcWtcY3vaEx7CGQe2C4y2EyShxVZonU gmZ0hcBLysrhULtm1C+cbOIx7CEIm2n0fvmEURuvO5h7icA6RXOuwn/otWv2tuWB LtfOAZwepLrYFcXpN8plSbkfzPVD9/XGfUyAsYrjy3U3Jc/3aO2yYwE8mrHLVah0 6Vc8BiyBUPRm8kvJeN8LZICUW2U/02s62D5/yCjwXXMoRrSBRF6dnnKmDVDGVHN6 YdhUsYrrDJpVjGVJr8+y20yMYw+dTDj3Skey4A2FoPyVwTTS7Ab7gi3tldc8Ygn+ JwGR5GnnNCraZpkNyMOY1xuLtnhrA== Received: from sa9pr02cu001.outbound.protection.outlook.com (mail-southcentralusazon11013028.outbound.protection.outlook.com [40.93.196.28]) by mx0b-0002e601.pphosted.com (PPS) with ESMTPS id 4g00w4uhxd-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 11 Aug 2026 13:33:57 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=OBll0I9/FbBNYtlDbVvOSiO7A24KYSl7uSiGUYk2qBmaZqxlSR+4xDU2DZlLUGskCw6EGhx7F5YFJj//6DnkxjZCA1SogAEWT/i6UuvBUHbXWdQII3L099L81dEp398E6bjO4a69qhNXDlVFoCoilv/D0cOP2PpuxHHWj9IpXaM5WZxXMo0PlFYfidQ1Eh8761NvYkow71hzual+dbvgRGop+jSoM4gDTLzxsuJ3FJbHMSAqtd+JTPNR1TaP8bDT0JPnNE//x8OwvYrcu8G7xB6Ck7o+0FL6VxZg4LkzD2w0kM/dUaC04LTMoo3fbKnaYZiodUhpU4uOOiiLSJrKTg== 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=CfcZ3asnTmwrkxDLnD+kXTLBg64BDPwemZSrihZFQlA=; b=NLzlpyxxQJwI2S39cMmADm6r6kxVPRnPaRpezcbfp+WwCdLQD6C/6Phzg1xhwfmqVP1yC8iZ6BacVaqX4okEt8D8Ez29CgE6VN6AXaehe2VbzRCk1XF9+dzkt66SktHEp/Wml6lVT6lJ3l8jYYOrIDSjV/xjYKQOodDTXpAIj3EYcI+LS2zVNm0ylhXYJkhz8QAnBjTjJb9CIC8ZpYEEks3v5YwixhW+aTitRiTZz/MCZ26nIMQLnDgTFriLxl9QmsxO96AToxy8f6ZsLUDXblO+74oOSpWTEoSv4ihwHPIQACpc5tVj+jDQr0MRHdiL7bWn/+DACc0ZZcO8AoED4A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 198.47.23.194) smtp.rcpttodomain=oss.qualcomm.com smtp.mailfrom=ti.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=CfcZ3asnTmwrkxDLnD+kXTLBg64BDPwemZSrihZFQlA=; b=D98jcbWhCM9nTbdvKzc/x3qLsSm2fZgQQ+I5uU7QzWXynUfOkdpOZuAosHrmp+8I1dbAfadTV15/08o8rzr5vLrlFe02W1+kcftagOiCBLA9YMLTdOc3eNWc+y1H8OPDNI4MNDzcZ3u6vPys9SxEfIe6oj5dDsRa43Xz4UkAIt0= Received: from CH2PR07CA0058.namprd07.prod.outlook.com (2603:10b6:610:5b::32) by SA6PR10MB8013.namprd10.prod.outlook.com (2603:10b6:806:447::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.292.25; Tue, 11 Aug 2026 18:33:51 +0000 Received: from CH3PEPF0000000A.namprd04.prod.outlook.com (2603:10b6:610:5b:cafe::83) by CH2PR07CA0058.outlook.office365.com (2603:10b6:610:5b::32) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.315.12 via Frontend Transport; Tue, 11 Aug 2026 18:33:51 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 198.47.23.194) smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ti.com; Received-SPF: Pass (protection.outlook.com: domain of ti.com designates 198.47.23.194 as permitted sender) receiver=protection.outlook.com; client-ip=198.47.23.194; helo=lewvzet200.ext.ti.com; pr=C Received: from lewvzet200.ext.ti.com (198.47.23.194) by CH3PEPF0000000A.mail.protection.outlook.com (10.167.244.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.315.6 via Frontend Transport; Tue, 11 Aug 2026 18:33:51 +0000 Received: from DLEE201.ent.ti.com (157.170.170.76) by lewvzet200.ext.ti.com (10.4.14.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Tue, 11 Aug 2026 13:33:34 -0500 Received: from DLEE215.ent.ti.com (157.170.170.118) by DLEE201.ent.ti.com (157.170.170.76) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Tue, 11 Aug 2026 13:33:34 -0500 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) by DLEE215.ent.ti.com (157.170.170.118) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Tue, 11 Aug 2026 13:33:34 -0500 Received: from santhoshkumark.dhcp.ti.com (santhoshkumark.dhcp.ti.com [10.24.52.55]) by lelvem-mr06.itg.ti.com (8.18.1/8.18.1) with ESMTP id 67BIXIds659766; Tue, 11 Aug 2026 13:33:29 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , , Krzysztof Kozlowski Subject: [PATCH v7 02/18] spi: dt-bindings: add spi-phy-pattern-partition property Date: Wed, 12 Aug 2026 00:02:57 +0530 Message-ID: <20260811183313.1550425-3-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260811183313.1550425-1-s-k6@ti.com> References: <20260811183313.1550425-1-s-k6@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PEPF0000000A:EE_|SA6PR10MB8013:EE_ X-MS-Office365-Filtering-Correlation-Id: b5998488-94e1-4fd7-f3c8-08def7d71786 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|23010399003|36860700016|1800799024|82310400026|921020|10067099003|56012099006|18002099003|22082099003|3023799007; X-Microsoft-Antispam-Message-Info: l3qKb2dz8KVn4etoZvkvLNSHXgSz+a/EfN+2CBTo9fraifTYhWF5pqWKZRGYs2C9Wapi/fziCiR3xETFZWvg4uSHd98ilYWlckXFe0BHNxDDFib7TQbGK3kEM9X68bX7D0cVelerOMOi53PW4xdzbYQ5zaLClCd4MRWULtVgn6CCEUxyi2UevgYdKcAO8tW3jWK4KNS/I+Xl/dXnLehd4IqaMioBUjX9rc46QD/MHu0lmrMi75Ryp0iZ/SywqEdCdX9v++z/TrRPIQUYz8ab57S2n2wz9xkCNOeLqbx1Ue48bWY2TGnTuubKHdspsZjPEVhTRcFP24fddsa2TszTOyePxEVC/cW8evTBdvxraTyD4D+76u3JYoqwdX88QmFCn0gFqJu8WR3A5yi3w3+Wifxno+5YffyRvydOhmZOSYhRNSCqJWOVM61qlR4aHOOMS4iX0bjivzikekmLycuazbFic5ghgol2FQhlBBKTVG0E/jF3XxghuYGSOk3e09ZiXg9dOMcQr4XtZz4NFr7QtGPYPOrMplMr1uxKnEMcbPqadxnvgiIxyGA+x0q7w2FG3hcciM4qz/C0l0G+shlEmL2RQmz2BZeuFVadcY9ydNjsPKoL0mTrKZ50hrUhuJ/m/m5nttt65NVFcphnpDGF45SnbwFXCwylPNLl1NqTtB9MDUFRnIMxUi2p2K4EqNAo2Rgf0gfT3eldlx/wyEdn2wcEti2xSvkvYENTWL0/6QXjX+35eRqrFlQ5U/nHI6dd X-Forefront-Antispam-Report: CIP:198.47.23.194;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:lewvzet200.ext.ti.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(7416014)(23010399003)(36860700016)(1800799024)(82310400026)(921020)(10067099003)(56012099006)(18002099003)(22082099003)(3023799007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 2Y7uWBYhM8hcBEQquaeKI/ZHK04umoeWpsI7sPq7jv/mKB4lWVh6LIXYxWgd69RxUmfK+ovhyOSG0KIedsFMhruuUiXq7QMnFo1DwsgKToISXcDdMl+kxb0kRbETdRKJI2TBLt1ILVhYlJ+t/MG1+buadEYz4jtCPX9u+qEGXhaeqGUAO+8JVJjed710HG3d1/rFHrZWOeN+LGRMrkxABt6cwgr6REKd4J7YlTxq/ENQSRY05bkstd5Z+r+Ga93WlwLTObJHFjtLOuVwiLBHwmLzgyBufbtAYzU135uD5OHcGIFDhs8GeiMC4tDaIeSNlPR54AiQpo0zxTiolthomc0uZHeppDj3tjskdyHEQg1VxOoQhD5SuEnlpLjk4+j6vixuy08aFHc7kV6ds8WoTM1nVOv7GRC5sOKKkFpmvuCx2ClrOklmwFApOm6AH/Rn X-Exchange-RoutingPolicyChecked: GEMmJ92VwZWmF2aab+NaptGpKfuGVf+mSyTG1SKQhCJZTNtID0OUEhYFOYk5Vbd6UA7D283MMdIF0xmUdBFZ0YlNHJXcBnBL+3rjse7jmIwnIZCNfy7AqdocowaJXMGDKJLjRVvyOY81/jumPBvwycyXjqAQWkMdlAyGGH7UV9bNZgyYWrLTywmgdTAG9ac3S1CDhEMTyojLUDpTEgrhk3vLpipBU+Z1ajAsfCGpsTecdfWtKdpvauSbJnpJzWwH8UU0g1Qf600QKnsOuDUT4Km0bLu8Kqw3g1a3NvFAETIXWHDmCvR/Hsm3u4IxB3tvYnkMZZYIm/Ge6eh8KxJWJA== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Aug 2026 18:33:51.6979 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b5998488-94e1-4fd7-f3c8-08def7d71786 X-MS-Exchange-CrossTenant-Id: e5b49634-450b-4709-8abb-1e2b19b982b7 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=e5b49634-450b-4709-8abb-1e2b19b982b7;Ip=[198.47.23.194];Helo=[lewvzet200.ext.ti.com] X-MS-Exchange-CrossTenant-AuthSource: CH3PEPF0000000A.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA6PR10MB8013 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODExMDE1NSBTYWx0ZWRfX5kVXG5VyZhx0 OPa0J7iV2WIkCcKe1nMH464gGhQaH8Owh6fZEG6rDAQPrZPM65A4wr8bLWWQ7IlKUzjKHvYgor+ hKpTcnG5b8lctK3sr9A31oDGj7DhS+Ul2na8p+O7DfjnubrlDpP3brJqO/YWEopuluL9rzG7cLa 0dvbJGKIpaoYWgGNEiEQBIaupys1dhKZBgJDxDL6CF0BJ6VP2c8WanUO2TsFpUe2Vas8NTwIagO xHMvIwKwflvtqzUHje6LBqHGWQCJ88S9nGZsKXOsO5rPDb5wT+retrA8atnAq90/kUEwI7iw4wH 2mwbiivMKIpuos6IxZ9KxcZXuEk07Yp1/w1ZvkNhmbjvEp6AKnYsiXXoaRVZHtE7wFJGgFihGRc gjGEOwpDOeHnguxgehBcTu4/ibqPifTFw3P57pcafMyD/74syEAfwZ4PDLdFaJvoQFU4NGCNPjg sVfx9Ju9xy5H3q3t9Jg== X-Proofpoint-ORIG-GUID: mKUW0hkLJd3rjeYkhWALZoo8CDKwneOl X-Authority-Analysis: v=2.4 cv=KZ/idwYD c=1 sm=1 tr=0 ts=6a7b6b15 cx=c_pps a=J6o3koRVWeMoKD0aP1wsjw==:117 a=WotqVVQAdb04rnGuttW3Kw==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=Sv0fKeRqtYgA:10 a=s63m1ICgrNkA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=fPAWb5peG099m5CrUpKH:22 a=EUspDBNiAAAA:8 a=sozttTNsAAAA:8 a=aBuQwODoJmrdCVe4joYA:9 X-Proofpoint-GUID: mKUW0hkLJd3rjeYkhWALZoo8CDKwneOl X-Proofpoint-Spam-Info: AW1haW4tMjYwODExMDE1NSBTYWx0ZWRfX3pxIQ4pjeIrX 8tIMmstBwIJeb2lVpo6MTv+777WVd0ivgxZCVQzBuO7DufXiFqSyrmjffB3yCXvKPaQSoSYk8/r 0yOdjUiG1UUaOsIVQwbVHQ4JDS0XZBg= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-11_04,2026-08-10_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 adultscore=0 spamscore=0 suspectscore=0 clxscore=1015 phishscore=0 lowpriorityscore=0 malwarescore=0 priorityscore=1501 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608110155 Content-Type: text/plain; charset="utf-8" Add spi-phy-pattern-partition, a per-device phandle property on the flash sub-node that allows the DT author to directly reference the partition holding the SPI PHY tuning pattern. Used to locate the pattern data during PHY tuning when the device cannot load the pattern dynamically. PHY tuning works by reading a known data pattern from the device repeatedly while sweeping controller delay parameters until the capture window is stable. For SPI NAND, the driver loads the pattern into the page cache once using write-to-cache opcodes, then reads it during the sweep. SPI NOR devices have no equivalent opcode, so the pattern must be pre-programmed in a dedicated flash partition. One partition per device is required to keep the procedure unambiguous when multiple devices share a bus. Reviewed-by: Krzysztof Kozlowski Signed-off-by: Santhosh Kumar K --- .../devicetree/bindings/spi/cdns,qspi-nor.yaml | 17 +++++++++++++++++ .../bindings/spi/spi-peripheral-props.yaml | 7 +++++++ 2 files changed, 24 insertions(+) diff --git a/Documentation/devicetree/bindings/spi/cdns,qspi-nor.yaml b/Doc= umentation/devicetree/bindings/spi/cdns,qspi-nor.yaml index 891f578b5ac4..277dedcd4246 100644 --- a/Documentation/devicetree/bindings/spi/cdns,qspi-nor.yaml +++ b/Documentation/devicetree/bindings/spi/cdns,qspi-nor.yaml @@ -209,5 +209,22 @@ examples: cdns,tsd2d-ns =3D <60>; cdns,tchsh-ns =3D <60>; cdns,tslch-ns =3D <60>; + spi-phy-pattern-partition =3D <&phy_pattern>; + + partitions { + compatible =3D "fixed-partitions"; + #address-cells =3D <1>; + #size-cells =3D <1>; + + partition@0 { + label =3D "data"; + reg =3D <0x0 0x3fc0000>; + }; + + phy_pattern: partition@3fc0000 { + label =3D "phy-pattern"; + reg =3D <0x3fc0000 0x40000>; + }; + }; }; }; diff --git a/Documentation/devicetree/bindings/spi/spi-peripheral-props.yam= l b/Documentation/devicetree/bindings/spi/spi-peripheral-props.yaml index 84976fd3ee1b..cc01b643fe9b 100644 --- a/Documentation/devicetree/bindings/spi/spi-peripheral-props.yaml +++ b/Documentation/devicetree/bindings/spi/spi-peripheral-props.yaml @@ -123,6 +123,13 @@ properties: description: Delay, in microseconds, after a write transfer. =20 + spi-phy-pattern-partition: + $ref: /schemas/types.yaml#/definitions/phandle + description: + Phandle to the flash partition holding the pre-programmed SPI PHY tu= ning + pattern. Used when the device cannot load the pattern dynamically du= ring + PHY tuning. + stacked-memories: description: Several SPI memories can be wired in stacked mode. This basically means that either a device features several chip --=20 2.34.1 From nobody Tue Sep 29 06:08:43 2026 Received: from mx0b-0002e601.pphosted.com (mx0b-0002e601.pphosted.com [148.163.154.28]) (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 EE462387581; Tue, 11 Aug 2026 18:34:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=148.163.154.28 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786473259; cv=fail; b=B1lHnCrVWd3kV6A7gsH5drbcLtknH7qm0f3Qns2U/n6d21Qd5/p9eRwGsttT1Za3AqQ8q5PjQ6AZmhDUOR+XSXbDjmC2DlN6nynKY8esuw9vMsEOJlMjA+l6gRcTcu4WfZR0rhAPtsuavI1GPNjyLlEjpnHVrs3dbwfRJLy2rsE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786473259; c=relaxed/simple; bh=shstm6OTM8uQraX2XsvM4iDwrlvLb8nvoS8/Hqj4oTA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=B9xlc4sPohb3+CqUP1UKqUkRfm+B3YmRVndlEIsWLipvRuIt9J2SigvBscDCcCljfbx12T8mOt6X4S4dU4mr/4OezQS/SUSwiJ3urCbV3D+txpMMF7R8J+8BEDHOnGLOA99EHdxG4+aMw90Wf4bCGTZbBXT0oC8Uo4QDu8IZzT8= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b=Oktkx+9n; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=GUe1BtTa; arc=fail smtp.client-ip=148.163.154.28 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b="Oktkx+9n"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="GUe1BtTa" Received: from pps.filterd (m0374956.ppops.net [127.0.0.1]) by mx0b-0002e601.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 67BGM8o11823876; Tue, 11 Aug 2026 13:34:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint-05-2026; bh=cfL4/7N30NGycxUM3IjaKjHLCNDrP70F5bdqRagiz MM=; b=Oktkx+9np8oWy0NhuMeNpOH5No+osqWDfgWSe4v/2VP+r9yaZR9VkHw8F 9Sedti5DRPyGhBUkgIF4Sc34eEIRKPxJHE3vrPoXzZ2StywzQvtFCe0Wh1A619J4 kCTkh7XgI6q7LCiGghdEmIHjjMIsl/GcqBW8R7yGZ/uYoKK9dkJU0Z10Tl7N/MdA zAThvermHk2ba4/GLtUQMoDk+azIS56A3g+Y3xwsI1GKBqSl0JIc9vGek5Gkcjba waFKbVVEZEJPv4SZ4xlpTjahuaCEp89BSZTK896PofRvzsk3RGWZZLAur2tm2vwi 7wXITBiMV/RzWJ+sqiB2Sb32YqUGA== Received: from bl0pr03cu003.outbound.protection.outlook.com (mail-eastusazon11012009.outbound.protection.outlook.com [52.101.53.9]) by mx0b-0002e601.pphosted.com (PPS) with ESMTPS id 4g00wnbk4n-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 11 Aug 2026 13:34:00 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=T1Jssgct2iA1oYNFPXGFSVorcvlzy29P8bOJyPrXJRWL2zH5mLDG3wsSW0xTaXAz1DS/EaJwg5EyQ0VNNBk/Y7o9NoNha8yZ3wK1xOe35xxOS245WgM+MsXdmR6XVZMorDlzUntrDpIRxbJXelbi/E/2dECOkpIr0fIFotN2ye0eS4I4Zev/LPxXZZ8j9n/GDq7fJZ4W65xYwZ389Sf8m7n7MioC17PcWoRIkwelf4L4LSTmXunLLNl1zAUZJvCcaF2hHSy3vbgI/c8vywrUcBrD9vJwkJPTbgSF4dhtK77BHWs5qOeCaeNOv1hedPyKOPOX5E28HTvt/aFW9aB+rQ== 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=cfL4/7N30NGycxUM3IjaKjHLCNDrP70F5bdqRagizMM=; b=WrNMLvJQFqQ0hCL7wsq0bubM6QX2PT6KnuEssqjvWkJB477Z+kYzvGSEqtQHDzhtD1lBIVzGxyr+/5XMrsDs3zXZp4L2JnQwmcgGoSR4Nzwmf991UyvgPmFLvIPSyvHWXC/Mf26pVepx5q0zeWiNFHia0A909PvyXVQ4lQjfJVlw8DV5ri567ZacbcpMzFce1zYmKq+NhMWpGRgg6WOHGK6cuPZdC+3ypGIO5JMFfEyk0cyHMWg8OXL44To00aO2IhK7SAXBoTiKkOqMjVuh+HQvMgvNdSfBLuzbWiNv00eKJixLpnOyjs4LuJ0qR0NduHb3S/RhVsXwiJUwoxwjZA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 198.47.23.194) smtp.rcpttodomain=lists.infradead.org smtp.mailfrom=ti.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=cfL4/7N30NGycxUM3IjaKjHLCNDrP70F5bdqRagizMM=; b=GUe1BtTa1UOjGBo171REV/W2TN6cGnvPoPs+C8D5vel0ZsJgBzr2NGVumawmJqx/15ICNro+cOqCrn/k9s1YeBj89TpGcjSv0nbqfm2F3KPpGHwiCHC5hTcXFNzoj+h60YwADP6Zw3HTzB55GEe11NmIAzJc1stn6nm9epXMLoM= Received: from CH2PR07CA0061.namprd07.prod.outlook.com (2603:10b6:610:5b::35) by CH3PR10MB7701.namprd10.prod.outlook.com (2603:10b6:610:1a9::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.315.12; Tue, 11 Aug 2026 18:33:56 +0000 Received: from CH3PEPF0000000A.namprd04.prod.outlook.com (2603:10b6:610:5b:cafe::a8) by CH2PR07CA0061.outlook.office365.com (2603:10b6:610:5b::35) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.292.25 via Frontend Transport; Tue, 11 Aug 2026 18:33:56 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 198.47.23.194) smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ti.com; Received-SPF: Pass (protection.outlook.com: domain of ti.com designates 198.47.23.194 as permitted sender) receiver=protection.outlook.com; client-ip=198.47.23.194; helo=lewvzet200.ext.ti.com; pr=C Received: from lewvzet200.ext.ti.com (198.47.23.194) by CH3PEPF0000000A.mail.protection.outlook.com (10.167.244.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.315.6 via Frontend Transport; Tue, 11 Aug 2026 18:33:56 +0000 Received: from DLEE214.ent.ti.com (157.170.170.117) by lewvzet200.ext.ti.com (10.4.14.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Tue, 11 Aug 2026 13:33:39 -0500 Received: from DLEE211.ent.ti.com (157.170.170.113) by DLEE214.ent.ti.com (157.170.170.117) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Tue, 11 Aug 2026 13:33:39 -0500 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) by DLEE211.ent.ti.com (157.170.170.113) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Tue, 11 Aug 2026 13:33:38 -0500 Received: from santhoshkumark.dhcp.ti.com (santhoshkumark.dhcp.ti.com [10.24.52.55]) by lelvem-mr06.itg.ti.com (8.18.1/8.18.1) with ESMTP id 67BIXIdt659766; Tue, 11 Aug 2026 13:33:34 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , Subject: [PATCH v7 03/18] spi: parse spi-max-post-config-frequency-hz into post_config_max_speed_hz Date: Wed, 12 Aug 2026 00:02:58 +0530 Message-ID: <20260811183313.1550425-4-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260811183313.1550425-1-s-k6@ti.com> References: <20260811183313.1550425-1-s-k6@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PEPF0000000A:EE_|CH3PR10MB7701:EE_ X-MS-Office365-Filtering-Correlation-Id: 8745b930-aaf4-4f7c-86d8-08def7d71a48 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700016|82310400026|376014|7416014|1800799024|23010399003|56012099006|10067099003|6133799003|18002099003|3023799007|22082099003|921020; X-Microsoft-Antispam-Message-Info: U/IXnfQuaaigVVDhJYnjXb8s3A4hKqheMsFQa9L9e+gbSlinsWmwkMMWL8ZBf6LxevG7omAXTyUTI2xGvhu6HWWxJHcY5wwDt3dsXyuhE1iGBLydjfvac+h4rHSCMJua2dDQfMPpMPOa0GkYE3CEZOcSO6046masXasFxRaSREhdf7yt/V56AA9p4/DOZPqDbt22TY89FQ6rUPzZsmlNGLvoCDlJIsS7VMJknB7HXTz5L03+oPsQxzDWOnc/Rbwpvv6m+c9pAc/AdWiI8xNaGzXYNjNSye7DdZJYsxUaahlw5n22oldPJmqOk3tjm0jhEhOB8eirrvEcQbySUyIPJEOyQYQ2+nsAQcfhFnN7pEleD/aRd5bemj7YO1YgDrgi+9YJNYh1ssceIExl322LIOeGsrycRTnjpU8jP7IIcI+bzziLs1I4nMsAMAMZZjsrmmc6Da6HBuoP80w+0vVlBjVI8X0MpMHmbZLhC5pMLz2sF9pODllLVd+2gvsb1nh9mpHpCkacYBheSRTaqQHGhHOJ7GOGsCWDwYj8zGATEeDuAgDgfL+9PGKn89DqMfwv/paFSxE63v0MlH9nwnlGv7rkFoT9Rx9byo9i17ihcRGXEJVSZbbg6FF2L9r2nWtYjlGLo7qlXoeFcaMQxAYIgm8g5bWL777AjZqDnSxwJKDX2HW0Me7d0OMjePGd4N1lynvRMLnEPwRSvPbhHMzMWY1DXsUpa0Z0dH55u5+OD8FmH1HtxLxeM87ZXqE7dsGd X-Forefront-Antispam-Report: CIP:198.47.23.194;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:lewvzet200.ext.ti.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700016)(82310400026)(376014)(7416014)(1800799024)(23010399003)(56012099006)(10067099003)(6133799003)(18002099003)(3023799007)(22082099003)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Tw6qvST3geva5dMh42GdTENtX8EcCro1T7m6S+3rX4Ocv+K7SmsOR/I5fShNjKj6sdzgMe69Jip0c3kcoSgN/3Ivz21ca9hyU/3acA2ivNz4iucPGiLk9fxwq2VsqVP0DcAevCwgELHfPmhxHt5AA7T9Hgde7oTZhSVLw04sfs5OktCuJPLHSwBvp7qudLRDS1xrSGRZXt1bkHK9+BQseIWqg8geZpryGhmJu1k6DL3V0WSkvLMA6vBqNwZ0Dd+t6JcRZEjjyyRTNwxxqH1ekfvmr5QVo4GYIuhJSH2lust8n9LFRrIYqB/nbNC8e56qiogPRb6PL+/1wKbXbRXkdw9eSpeIb5O1MV4dQ4FE0d+7/dyptZJzLBGXwyWbd56m85cCOccc2dAIxBiAwLJfaoe9CIJoBVVtZ2yWOoY5iS4Vp7mVBGngs6G5eZfWhDrg X-Exchange-RoutingPolicyChecked: B2mI4frORzU15EpKzK318/1lTd6qPBEJ6AWGH/UdvykDdKp2QjBlObrNx+MTmxJaKrHmvF4fFKGGm72unwfkE0by0uz9LvAHSAuunaNYeA739t1ukbnkBP6P7l+RBWyVcEGOYtkllLPK5/Rbexwb9bYnTW+3TRPW/PGN8zxL3Vn5d8tO2bwDronj8bZO8FHBozfDDruWCsjAPQ/9GrmIHQUSs/qDccJHCWMG5897LrD7qt1jjXE/1EpasXOSB2NiuIHoFe+RZw4HOtzW3Xfa8gUMElGn5scKlq1mJDH9cbN8sHSsbQGZZ/etstdud4UOxje/tqtjUbVCZd03mY6nxA== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Aug 2026 18:33:56.3284 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8745b930-aaf4-4f7c-86d8-08def7d71a48 X-MS-Exchange-CrossTenant-Id: e5b49634-450b-4709-8abb-1e2b19b982b7 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=e5b49634-450b-4709-8abb-1e2b19b982b7;Ip=[198.47.23.194];Helo=[lewvzet200.ext.ti.com] X-MS-Exchange-CrossTenant-AuthSource: CH3PEPF0000000A.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR10MB7701 X-Proofpoint-Spam-Info: AW1haW4tMjYwODExMDE1NSBTYWx0ZWRfX4o0077ypWqB+ DMx0/wi7YGZDFu/8Lxtw+MXmx13PpVj4l4ja/VfO0QZJnbB8YSNUPUG+xMVGYlk+E/+M0B49WPo DCdB4u/nm7D1aQyNv1ISf1klgan3zTw= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODExMDE1NSBTYWx0ZWRfX5+AiLU+fqPIx 17kwY0Kf7in6YFmwwKWzgeVaC4qg0k5JVzjIqhrt/hEYOWVUqcv2OcnX+/ys9TuiI8N5PZ567OF RImTofJtaBSwx1CSnKCbCV6pNMfk3o+o2akKf3YSUkJtKzfnwVkMYrQhb0JYYtW58IcWnpTIf16 yME4+BqE99i4bwFbUFECXd7Db5LPERk7Fbcmr5qXnrruQVs9xMv7DHE4FMp4v9NhfusuZQ/CHfT FjjiGq0/Pg5bNo265fbInw4/sbIRp3oy9CpznK3KiAisr1kZwget5lcAuX+Ebhv+MUJdiOfFXxY EGSgQEGseBq+gIcOLgVySYITVUD4PyweYCHg/MzWs+UkQZGE3SMM1PrxIWgN0Mw795wfpgHGLw6 SiN82L0tDwxZ6/La6PswNIsDT5lWgo+6+uhMm8iqj9qvTFcrXiWvtblctEDye1PSgRUL+XnZRrm Yn3a/eEPiwoKXAevMIA== X-Proofpoint-GUID: I3WjnEGthKzcf7674WG9bE1ovTtaG4nN X-Authority-Analysis: v=2.4 cv=cYziaHDM c=1 sm=1 tr=0 ts=6a7b6b18 cx=c_pps a=XZql7kJaNSG894ZXpSE/kQ==:117 a=WotqVVQAdb04rnGuttW3Kw==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=Sv0fKeRqtYgA:10 a=s63m1ICgrNkA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=jwouBfj2j3NM8CExmVVE:22 a=P-IC7800AAAA:8 a=sozttTNsAAAA:8 a=2Gi1gDZmOG9PIfG5304A:9 a=O8hF6Hzn-FEA:10 a=d3PnA9EDa4IxuAV0gXij:22 X-Proofpoint-ORIG-GUID: I3WjnEGthKzcf7674WG9bE1ovTtaG4nN X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-11_04,2026-08-10_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 bulkscore=0 priorityscore=1501 spamscore=0 suspectscore=0 impostorscore=0 malwarescore=0 phishscore=0 clxscore=1015 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608110155 Content-Type: text/plain; charset="utf-8" Add post_config_max_speed_hz to struct spi_device and parse it from the spi-max-post-config-frequency-hz DT property in of_spi_parse_dt(). This supports SPI devices that operate at two distinct clock rates: a conservative rate always reachable without controller configuration, and a higher rate achievable only after controller-side configuration such as PHY tuning. With both properties set, spi-max-frequency gives the conservative pre-configuration rate and post_config_max_speed_hz carries the post-configuration target for the SPI-MEM layer. Zero when not set, preserving existing behaviour. Reviewed-by: Miquel Raynal Signed-off-by: Santhosh Kumar K --- drivers/spi/spi.c | 2 ++ include/linux/spi/spi.h | 3 +++ 2 files changed, 5 insertions(+) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 07c572e1df5d..2688e987f900 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -2789,6 +2789,8 @@ static int of_spi_parse_dt(struct spi_controller *ctl= r, struct spi_device *spi, /* Device speed */ if (!of_property_read_u32(nc, "spi-max-frequency", &value)) spi->max_speed_hz =3D value; + if (!of_property_read_u32(nc, "spi-max-post-config-frequency-hz", &value)) + spi->post_config_max_speed_hz =3D value; =20 /* Device CS delays */ of_spi_parse_dt_cs_delay(nc, &spi->cs_setup, "spi-cs-setup-delay-ns"); diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h index 88d17fce02dc..02fd602f29e8 100644 --- a/include/linux/spi/spi.h +++ b/include/linux/spi/spi.h @@ -141,6 +141,8 @@ extern void spi_transfer_cs_change_delay_exec(struct sp= i_message *msg, * @max_speed_hz: Maximum clock rate to be used with this chip * (on this board); may be changed by the device's driver. * The spi_transfer.speed_hz can override this for each transfer. + * @post_config_max_speed_hz: Maximum clock rate achievable after controll= er + * configuration (e.g. PHY tuning); zero when not assigned. * @bits_per_word: Data transfers involve one or more words; word sizes * like eight or 12 bits are common. In-memory wordsizes are * powers of two bytes (e.g. 20 bit samples use 32 bits). @@ -195,6 +197,7 @@ struct spi_device { struct device dev; struct spi_controller *controller; u32 max_speed_hz; + u32 post_config_max_speed_hz; u8 bits_per_word; bool rt; #define SPI_NO_TX BIT(31) /* No transmit wire */ --=20 2.34.1 From nobody Tue Sep 29 06:08:43 2026 Received: from mx0b-0002e601.pphosted.com (mx0b-0002e601.pphosted.com [148.163.154.28]) (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 B7D3E38655D; Tue, 11 Aug 2026 18:34:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=148.163.154.28 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786473259; cv=fail; b=nZHtGqr2Gp9KEyoXFhZxme6N44ujKctPHSm001r3ZvmBdoZTVsg9cy7+ApfnzlxuH9WIBWiQtZYNr8Wmnz3px7l3uZZ+lCwobOi076t26NAJpHJSAiHep2jRgoN5nc7P7HEpNzN0/dionzyOkDJfWlMwQaS5/eakvL/lJHl8su0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786473259; c=relaxed/simple; bh=gRzYTg5YzeP4zSd6C5hQMTHda4VWK0ANUdYXRmJh8Ao=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=p6cTmctBOkLEB+6Dyi0ikpiQC65voozN1eeUMFgx9szOu2K5712KK7ODdWwEcnZyYDRnknsC6RHaEQdnB5ihXuxLvISD8n9x05Wy7Gt3z8pTwWLoyTQeQK42nbtJ+Qqf8g3SzuBEV53LjD5naM6Jm6hiqrhTJf1rtZrh9+go21g= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b=O5AHoiyJ; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=Yg+kHzSF; arc=fail smtp.client-ip=148.163.154.28 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b="O5AHoiyJ"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="Yg+kHzSF" Received: from pps.filterd (m0374955.ppops.net [127.0.0.1]) by mx0b-0002e601.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 67BGMepN2174930; Tue, 11 Aug 2026 13:34:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint-05-2026; bh=ZTWujPJJoyVHaVBDHyuFci9COH1pu2HMwliq1pdCX h0=; b=O5AHoiyJYlPWYjNLa1UACzOE/Nj4UlHaXdpDeHIO9lfySv7WMVoe+WuO3 5vBsq6orU8yHFJOotsNMwlyH5aUvhAeHdIU7JIdrMmIGlNCk5yEBtNcrGebejZSl NSIGFJvDLoEOoqnYcdnwhGaqvjcbe6Z/cpbK8JwGnMUpfAKVvlUwv24oGgQg91YV syiK6ZfBFBcNhFtILBi4xHJopSrzPTRIJdgQ0Wn1GowwEyH4uc7sAAJEmQ6ZpfeV C3Sb8U/Imsgn3fcXG3N83K0ucyxfZaIceoRJIaOh1dWfanYAfs+CvHYOEi8Azp5g qS2swS1dNnrVrBBLpSP+Do3POolmQ== Received: from bl2pr02cu003.outbound.protection.outlook.com (mail-eastusazon11011010.outbound.protection.outlook.com [52.101.52.10]) by mx0b-0002e601.pphosted.com (PPS) with ESMTPS id 4g00w4uhyd-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 11 Aug 2026 13:34:08 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=BHUb+vanhfSEAbwT86s0hDcoBeTiT6VP2z6MUskXic6KoTcj1n4ymasmhlgkKU5qT1oSVYyiFO79vzlZrp6A0V+G5gvliFWAcixQXDmEXwkpJ5MRxcqVJ0dEOFd8Xei8WywNKEh12g2jdUJW8TXx+k6CkUgVoaLpddFl6lKMARS2i1y0N74xVlnakYMd+Ja03BeM3nZ3tO7OcsYjr/8A+774KUoVsBq5ADCOJQOSYAxL220GjSdCOoT4flOqKt/1zTGyQ90yt07IY9L692f7LptSoSp7tCMa7XpXw3zYf/t5z9t4DJKAsnqxnuDwxUmjlqrE4z4zoWLNiD0L3f83WQ== 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=ZTWujPJJoyVHaVBDHyuFci9COH1pu2HMwliq1pdCXh0=; b=OxkCVgt5gvafzxjKRWzYKBSHeX3XMLxUUJPhMnxDytIwUVwW5TbFJZbrQUarYacoOk2O3aCrleaQPiJmvXR/Qxg68aXRpRSQIdxXXzIWSbzwwGohGb+OOEwX29sBjQ/9EJIWNTSWjujrIz4HZ/FX6hHToTfczXF7Zgsk8c+DE1vt7/RNYit+nlM6Sj56DbmhPP7IluKCkjUTsARDNOYRdKWaI6aVP/oprVA1Q6TAGmMwKTnD/9iT/R2taerzr5BxHVD9idqxjIDBq+WVXSb6NRk65RKJ05WREJK1GUP2++dya51gTgsrchFc4wsq7UVTbbGiCoNpo1K4kXmOP+8Ukg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 198.47.23.195) smtp.rcpttodomain=lists.infradead.org smtp.mailfrom=ti.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZTWujPJJoyVHaVBDHyuFci9COH1pu2HMwliq1pdCXh0=; b=Yg+kHzSFWev8LfAtCiX7ZuPd5jVqFucCYuhjI2/OkcfIkng/eJjMIVpEjLhtgXR/iP7KjZKMN8HNCoXfVO0mYcX+QyFFU8k6DR+AeeZSYTmB2q88CVLFdC6ltrRtPkfZp8IztQu48pYqEd2UPcD8E720GrOuCZ28V5/o/qnaYDA= Received: from SJ0PR05CA0108.namprd05.prod.outlook.com (2603:10b6:a03:334::23) by BLAPR10MB5106.namprd10.prod.outlook.com (2603:10b6:208:30c::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.292.20; Tue, 11 Aug 2026 18:34:05 +0000 Received: from SJ1PEPF000023CB.namprd02.prod.outlook.com (2603:10b6:a03:334:cafe::5e) by SJ0PR05CA0108.outlook.office365.com (2603:10b6:a03:334::23) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.315.11 via Frontend Transport; Tue, 11 Aug 2026 18:34:04 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 198.47.23.195) smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ti.com; Received-SPF: Pass (protection.outlook.com: domain of ti.com designates 198.47.23.195 as permitted sender) receiver=protection.outlook.com; client-ip=198.47.23.195; helo=lewvzet201.ext.ti.com; pr=C Received: from lewvzet201.ext.ti.com (198.47.23.195) by SJ1PEPF000023CB.mail.protection.outlook.com (10.167.244.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.315.6 via Frontend Transport; Tue, 11 Aug 2026 18:34:04 +0000 Received: from DLEE214.ent.ti.com (157.170.170.117) by lewvzet201.ext.ti.com (10.4.14.104) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Tue, 11 Aug 2026 13:33:43 -0500 Received: from DLEE212.ent.ti.com (157.170.170.114) by DLEE214.ent.ti.com (157.170.170.117) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Tue, 11 Aug 2026 13:33:43 -0500 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) by DLEE212.ent.ti.com (157.170.170.114) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Tue, 11 Aug 2026 13:33:43 -0500 Received: from santhoshkumark.dhcp.ti.com (santhoshkumark.dhcp.ti.com [10.24.52.55]) by lelvem-mr06.itg.ti.com (8.18.1/8.18.1) with ESMTP id 67BIXIdu659766; Tue, 11 Aug 2026 13:33:39 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , Subject: [PATCH v7 04/18] spi: spi-mem: teach spi_mem_adjust_op_freq() about post-config ops Date: Wed, 12 Aug 2026 00:02:59 +0530 Message-ID: <20260811183313.1550425-5-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260811183313.1550425-1-s-k6@ti.com> References: <20260811183313.1550425-1-s-k6@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF000023CB:EE_|BLAPR10MB5106:EE_ X-MS-Office365-Filtering-Correlation-Id: 1272024f-4b80-4482-29b8-08def7d71f15 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|36860700016|23010399003|82310400026|7416014|5023799004|56012099006|10067099003|6133799003|18002099003|22082099003|921020; X-Microsoft-Antispam-Message-Info: 78QFUSDMU7R4/5PcNLL1Poi1idZHFXCT6vUe3GUCDPxgNMqWoMrzsjUFKMHmZ7+IW4N0iekXDrg+uVVToj5S2WBbQD0WS+VQGPAsMGqWns+jhymVxC+8iKdyvSMAO1lB9z1umHqd6gFTmxWnvYrxSWgStu6R2qkdcAeLIzyp1KMrg2D6RVFoRhlZj+NXSsFKSXg9hKufXHjDzdrD36PXZiVsUbVOi34g0feW5912KTPnIkfwzIkalsNQK+5NK6Js6s8SGVtdAMHsa2ExPXE57X7Etn4XNGiaz3xywRp1GIk/w70Fa7NQGsOyX1cXCYOhQgnczB5JFOstL68aR0sJ7tPICbnn4GRuixe6HG2PJaOwo3Nm/J/nw6eUTBR3kLIbvaEBRHLUYMOfpYzNiF4Ow9fu16q8qZLPe/7m2aLKWSgjID/NscZGlEi2fgh7XbXUOxq24S69jhFEm0nkPkqwFz0T4Bg7RJlnfH9Ks/e5anJIsZefahgCnBuKrKPPI6G9rRqNhwbyEAlvYLTqC4P+/koxLvn2t4PQrBG3HFKXFDR854f6tHoV+svo0dv6bMLtBRdWhAgi/ys9b5KQVfDX2lUvtJWY68UK2FkW6kYCPu+2HlXB2EKVE0Pizi+HYWyNy1Dith/X39KcXoywrakAlEFVWzlMSNqQK0WNr5Vs0fX6slLsG/ebTyZe3ia2KFqN7KpSXxwQkFQnVPk+I9EIOK04Y/XPNpeOj+kvc4iVKTwGBjdp7ZqxxVvFAWFTyvaJ X-Forefront-Antispam-Report: CIP:198.47.23.195;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:lewvzet201.ext.ti.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(376014)(36860700016)(23010399003)(82310400026)(7416014)(5023799004)(56012099006)(10067099003)(6133799003)(18002099003)(22082099003)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: J8WUknP+PqTDxqCaUoTRNTwfun8uVEKR74U0gQKMEpMw1fJYEI6/5vDJkhjcu1TLLAWG1/MJxT2UxfnhTof55mGTEvbSJlvRur/8y/NUDNiTX8SLQ5lyXD43Xcj3bgWFMVOQvOU/h/vW9azbaQuhEdQlWE/7OrHaj7plUYvm2KQcOFHwMawbLycGnq1mfggRhqvIAav68soqtsg7FzCcVYrQJR3fHO2ETVUhZiKrov/Zlh8PICI1uU/SYPz74P03l7BwKlod/jDqGrJlC+eSAKuZ4WA58bqwlWsQjP8OkxHBHUso9wjpiHwzYdRLF4HEOPOBIwaQF81+JBEt3+9581w6CwWy/+39r7N3ODBTxxRiBebS5zQ+zdp4zeC6RfjeLj0QL6uBO0sTeKgl2d2uKw026fRPbVgQwTLz4Pp7g5+6sXvcNrgDUAFIB6TeYZgd X-Exchange-RoutingPolicyChecked: dPCfgdoIedWl3wFkaqeYZDb/Vj8XBjMvGO2ZBkR31HGNLi+6nehtZi/igb5xSM3Fbj7RXTm+MJwQLKshW86nwxYw6uc2GkkDfBMimMJXnIF3pcyAEShSgKVm6l+f+JShfXzSG5zutS18VP33bTAh5HOJbH8aISIzREQnV4JSTOK6o/Vn68qlyKS2ZrSzdC6CDiF5HfAHCENAuss3IKbDdS5HgopmgK0HdT3GE8far41yILsaFnUlvZgUAIIyseUeN1bfzU5CYnvL1NZa1VY+Nknfo/2Vr7s0SJ2edCCe4bDP+dLR84l5Gjpg6GEXankENBAtqxHAYf+G8cW0nniqNA== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Aug 2026 18:34:04.3337 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1272024f-4b80-4482-29b8-08def7d71f15 X-MS-Exchange-CrossTenant-Id: e5b49634-450b-4709-8abb-1e2b19b982b7 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=e5b49634-450b-4709-8abb-1e2b19b982b7;Ip=[198.47.23.195];Helo=[lewvzet201.ext.ti.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF000023CB.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR10MB5106 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODExMDE1NSBTYWx0ZWRfX56T0S9pEnkaR Pi1YwIB2j6AMVZlJYEb2nSC3dCfu/akwtG82Q4+jJh1e/xPa/9IFoIEBpN49YofZwsKtuJVcYRl f42mWtJvWNERUbPKlsyKs9mI0wYox7fGYIuH0+DaVhwTSprxS9Mz4ELksGRirNyXKR1vdSlt/Qk VQc5UShkybW/KYh0xAHb3PXdknVyuKo4yxUYZR1g9XRcFlYPrU0GJMu8oLPL5l1PkkNgS4nDgO0 hCa/ImFYxxrddCFZzOLDNH9o+qPM3G+KK0QgDmsKrz9sBPXfTm1V5QugWcWu0W1595kt/wUWaiw LnNR2XCf+4SAbdLmSdOgfLfUsuIEoRhWOk7ke7sT+HGY65afhLnBvlMZaNKaJmE9EqHtBAl8igo xYPOronDun77M47gfe7nS5D68QJKEsvAd4KxUK7JRkHes8l3nasp2sNGfR+3oIIKvR68KRGkDdS 9UHOPuMSTd3Kd0Vz15A== X-Proofpoint-ORIG-GUID: pmL68WHegTaC32GYQCeiFhxwrRlDRtxD X-Authority-Analysis: v=2.4 cv=KZ/idwYD c=1 sm=1 tr=0 ts=6a7b6b20 cx=c_pps a=5LsHMtEjVXEroYtotTqlkA==:117 a=f+v6EHfkeJbVwR46tk4DMg==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=Sv0fKeRqtYgA:10 a=s63m1ICgrNkA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=fPAWb5peG099m5CrUpKH:22 a=P-IC7800AAAA:8 a=sozttTNsAAAA:8 a=gHTh7DRQwxBKnKwRL7cA:9 a=d3PnA9EDa4IxuAV0gXij:22 X-Proofpoint-GUID: pmL68WHegTaC32GYQCeiFhxwrRlDRtxD X-Proofpoint-Spam-Info: AW1haW4tMjYwODExMDE1NSBTYWx0ZWRfX903IiU2qXuyj U8K2QeoeytqhV0pSZweYqpQ7fKyFX7C+iYo6XJsFmH20SVwkuSHtsp3dELxf5VdetFX/S1iWzmh Nz3bYpVnr1SwGHKhVX6ZHy373u9feYE= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-11_04,2026-08-10_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 adultscore=0 spamscore=0 suspectscore=0 clxscore=1015 phishscore=0 lowpriorityscore=0 malwarescore=0 priorityscore=1501 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608110155 Content-Type: text/plain; charset="utf-8" Extend spi_mem_adjust_op_freq() with a bypass for post-config ops: when op->max_freq equals post_config_max_speed_hz (the value written by execute_tuning on success), return immediately leaving op->max_freq unchanged. All other ops are capped to max_speed_hz, the always-reachable base rate. This places the policy at the single existing frequency-adjustment point so exec_op(), supports_op(), and calc_op_duration() all see consistent frequencies. Also extend spi_mem_default_supports_op() to require per_op_freq controller capability for post-config ops. A post-config op runs at a different clock rate than the pre-config base; a controller that cannot switch frequencies per-op cannot execute it correctly. Reviewed-by: Miquel Raynal Signed-off-by: Santhosh Kumar K --- drivers/spi/spi-mem.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-mem.c b/drivers/spi/spi-mem.c index a88b9f038356..c74858e58073 100644 --- a/drivers/spi/spi-mem.c +++ b/drivers/spi/spi-mem.c @@ -206,7 +206,8 @@ bool spi_mem_default_supports_op(struct spi_mem *mem, return false; =20 if (op->max_freq && - op->max_freq < mem->spi->max_speed_hz) { + (op->max_freq < mem->spi->max_speed_hz || + op->max_freq =3D=3D mem->spi->post_config_max_speed_hz)) { if (!spi_mem_controller_is_capable(ctlr, per_op_freq)) return false; } @@ -591,9 +592,18 @@ EXPORT_SYMBOL_GPL(spi_mem_adjust_op_size); * Some chips have per-op frequency limitations and must adapt the maximum * speed. This function allows SPI mem drivers to set @op->max_freq to the * maximum supported value. + * + * When @mem->spi->post_config_max_speed_hz is set, ops with @op->max_freq + * equal to that value are treated as post-configuration ops (e.g. PHY-tun= ed) + * and are allowed to run at the full post-config rate. All other ops are + * capped to @mem->spi->max_speed_hz, the always-reachable base rate. */ void spi_mem_adjust_op_freq(struct spi_mem *mem, struct spi_mem_op *op) { + if (mem->spi->post_config_max_speed_hz && + op->max_freq =3D=3D mem->spi->post_config_max_speed_hz) + return; + if (!op->max_freq || op->max_freq > mem->spi->max_speed_hz) op->max_freq =3D mem->spi->max_speed_hz; } --=20 2.34.1 From nobody Tue Sep 29 06:08:43 2026 Received: from mx0a-0002e601.pphosted.com (mx0a-0002e601.pphosted.com [148.163.150.75]) (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 B37183845B3; Tue, 11 Aug 2026 18:34:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=148.163.150.75 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786473258; cv=fail; b=ZwIyZ2RFTAy/BCmmDqtT3go6G9d3YMIdlvEQmg42+dVGGtEETByePqjI19fFxasTAD3mEs4F8TrbzAMxsBCMUL9/S4x/FT2O1Gc5XI7ML9JUKcxT3LlXKdY1d/b0LkNSxR2Q3e+s6y0VpfZYni1XkSAe4TLjoAX50KDnjFMSUX4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786473258; c=relaxed/simple; bh=T5iG/osPd4SmdfnjzfYz5mfXPIArTtH9q8l+2WYL280=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Xcn/pGeY6H3Aq6yhUGQjCn66SKhuIutwuimm9KTngQUzXhmEd9Npg3hJX/sH/ORgqPckAm7gLe8UeoU97dIbcq506IFNNV2MgjD2U/uajIpfEF0i9q9s8cdAl7GYFohq005jYExA9Ry4EyB1wy7bIb3zJVIJ53J1tz3pDr1ag+c= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b=LRdF5VK3; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=vF2xoFoC; arc=fail smtp.client-ip=148.163.150.75 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b="LRdF5VK3"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="vF2xoFoC" Received: from pps.filterd (m0384305.ppops.net [127.0.0.1]) by m0384305.ppops.net (8.18.1.11/8.18.1.11) with ESMTP id 67BGM2Ec2459496; Tue, 11 Aug 2026 13:34:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint-05-2026; bh=QULyOCZm+lfHwTvY04ItXlm9lRRerGZLH3MUpV3h3 Oc=; b=LRdF5VK3VRMN8D1vjpVCkjHH/Jmy3t5r9puwxVie2Y1O//R5nfJFOCRFb wYl+Bt+X7Wm7Uqfjyf4i85Xjz/Fl1ZZRBJBod9hjMtx/zvAXM6Vbkgs4JbJHQ8SH ISoQ75wlcS4woww5IBwqiLciAIJ3hn24hVTPuXVSYXZP0L51XEZbvOhjIxPrLBlo AHkS571iB1ofjRS+BYg7a3XQQ6BwKTj2svNFkC/M4VdyrrsrVwp0IlxMAGZqlaDu oH8oXeDsest75eMTz0uKfC0GOddkdLI7MNmFTNRaIXQ11TKaltAMzx/Qet3h3l+z +8v4kTorR0SVg5rLkwkzyyI4Fa8pQ== Received: from bl2pr02cu003.outbound.protection.outlook.com (mail-eastusazon11011023.outbound.protection.outlook.com [52.101.52.23]) by m0384305.ppops.net (PPS) with ESMTPS id 4g00wu3h27-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 11 Aug 2026 13:34:06 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=rZvmH8maTpCo7klOJQhU1IiOY4OKbeSITht+2DyPTaoNOevRpRDmfuscj0ilbSDploQ3Q9aYUQ95PdLZIDvHUnzys7xmOvEzgHRHImfr7/PBIXPFm88d26tzDhvHKdE5kojUEptdorx439WCGlxA37thKqLdwdNDo10uwaVkmOZiQ3Eb+XaM3GfaZn9zULwhc+kiydwfDpi/qhFdZM2Msc2VTbLOSUWk1YhQMdfDO4ky1U5rCvvLNRrsqmpqHUWW45+GcUp190kjrXr8cAqRj0YKxeYSSBq5D9q0bTkEJZUR6zD0jEsEEyXRt+40eyMEhWdfqjJhBlWEmfP3r+ftSQ== 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=QULyOCZm+lfHwTvY04ItXlm9lRRerGZLH3MUpV3h3Oc=; b=CsS21/73t8N/jqlsKqZdb7Lb9w3Twb9FhC+gyEcPInM/KS7XsUHxhp0U5fbZ5N73ml2deo+Tg2FlQm7NPhQeFFJ5PnHJAvHrrFQYx9HxSiJofgcvyyQHopcZIy3Ombwnr8RkojY5gXQNcLDHt8+QRjl7fN5nVsRD08rlyl+3jytQjfmXLQqVxzhSLbfukmetnPRd0TP8f5ytpRU4WTbkbmdgYwzaSz8/xQWeyXWJnvfgCxx/emiQmRwcRU+m1W9Q9/AwVLIeMTJaHwTOxPqj+qhEyQmkO4o2FUzdM4FBGiI1eMEB1hEUKdBQKLpiYWJFPoB/cNrKySsaVGgmuym3qg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 198.47.23.194) smtp.rcpttodomain=lists.infradead.org smtp.mailfrom=ti.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QULyOCZm+lfHwTvY04ItXlm9lRRerGZLH3MUpV3h3Oc=; b=vF2xoFoCOAj4PsjHB4mBNV+FViQvd7oktH7ycTWh2hnQGbIbLhytPCVSN0I6z4+39ctnnkEgBioh42AQELXxpmcDsHXlUfahoppliZw7/vbY76SBs+abWbU2RBpZ7bAf7+LxnXrJaYBaxX3i8NlZZhW9LNuy5fw/1BgrW18G+mY= Received: from CH2PR07CA0041.namprd07.prod.outlook.com (2603:10b6:610:5b::15) by SA0PR10MB6425.namprd10.prod.outlook.com (2603:10b6:806:2c0::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.315.12; Tue, 11 Aug 2026 18:34:03 +0000 Received: from CH3PEPF0000000A.namprd04.prod.outlook.com (2603:10b6:610:5b:cafe::58) by CH2PR07CA0041.outlook.office365.com (2603:10b6:610:5b::15) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.292.25 via Frontend Transport; Tue, 11 Aug 2026 18:34:03 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 198.47.23.194) smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ti.com; Received-SPF: Pass (protection.outlook.com: domain of ti.com designates 198.47.23.194 as permitted sender) receiver=protection.outlook.com; client-ip=198.47.23.194; helo=lewvzet200.ext.ti.com; pr=C Received: from lewvzet200.ext.ti.com (198.47.23.194) by CH3PEPF0000000A.mail.protection.outlook.com (10.167.244.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.315.6 via Frontend Transport; Tue, 11 Aug 2026 18:34:02 +0000 Received: from DLEE209.ent.ti.com (157.170.170.98) by lewvzet200.ext.ti.com (10.4.14.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Tue, 11 Aug 2026 13:33:48 -0500 Received: from DLEE201.ent.ti.com (157.170.170.76) by DLEE209.ent.ti.com (157.170.170.98) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Tue, 11 Aug 2026 13:33:48 -0500 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) by DLEE201.ent.ti.com (157.170.170.76) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Tue, 11 Aug 2026 13:33:48 -0500 Received: from santhoshkumark.dhcp.ti.com (santhoshkumark.dhcp.ti.com [10.24.52.55]) by lelvem-mr06.itg.ti.com (8.18.1/8.18.1) with ESMTP id 67BIXIdv659766; Tue, 11 Aug 2026 13:33:44 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , Subject: [PATCH v7 05/18] spi: spi-mem: add execute_tuning callback and spi_mem_execute_tuning() Date: Wed, 12 Aug 2026 00:03:00 +0530 Message-ID: <20260811183313.1550425-6-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260811183313.1550425-1-s-k6@ti.com> References: <20260811183313.1550425-1-s-k6@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PEPF0000000A:EE_|SA0PR10MB6425:EE_ X-MS-Office365-Filtering-Correlation-Id: 3e3b394b-16d1-4812-92fa-08def7d71e3c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|23010399003|36860700016|1800799024|82310400026|921020|6133799003|10067099003|56012099006|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: /8t3bGijUhKdwJmo9KUW1PHjbV71PpSci7SBDYfYnBe46Ox+cNaEionrs0TArvRjbCbMJh3GxnWA51LHGsaBNNbnPI/h2QT2kK9pFdtwuyLn7IZH+bnRCMy2PB1NbxG14v6eyKy1cxDbE2RbKdtqQtEenRMqH15bPLEY2A8e3njTMRDOrE3Nwt2dZjWZ2KP2ydqXQRP6szmDCtMprwKJW49vIynFtKTkOUqvhOFP+qVqHAKgigtEL/NmynSIZReyvuCItc8lAE3TjW1uHSzcmh2vzbKF0UzTCzO2/WTObjnDvfZ1sFL/2V3fia4LytnGJOijCw1VDfKbmQxj7J+m1BA+Xl8Oj9wdYxq9KYbyuziNs3e5Wjr9iNKCjpZFSVg0/IXJ245ASoV3RRwoPjy/qqRkuaAABwg/vBICXexffAaVUT2U8McMnRDTJkC0C9dxYLE0JUGJs/QGUUHaF4v3KEYSvMfC7tteYRUPQHPTZ9uCau264qMJVhbeshixl7PnomAsghHTB1060XXlX96UOOxUNs0iSOIfY/4kue2ASGQxvZVkRCxcYVPNSKvtt8n+z2yAyZH0ZsB102LKAaMKRRtUzncfWMqiHEDCIWDzZUS5RE9n97zNQ/qXYNZ+jdS/DixrYuIikyYRMkjx+OTaYMKbYsk51K2C+j2v8beKaF5PXMltBjeWScYinNcarTUZNAygAymb/gqHo4NwNB9OOlN4Jj+gq6nZd6I0Gf21Gd7Q/0pau4qy7/ii/NEOjJM9 X-Forefront-Antispam-Report: CIP:198.47.23.194;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:lewvzet200.ext.ti.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(7416014)(23010399003)(36860700016)(1800799024)(82310400026)(921020)(6133799003)(10067099003)(56012099006)(18002099003)(22082099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: QtH+3mzdTifNhvx+LkQidOvm7k1rXLn48f5XgJndfL7lpexA1qXmNd3DyxJayBTqbdZNZVpRKG2F60ZhY5yi1boCrI4SvsSfI91bkqsZt80ockRwUXLNP1njk066sSogWCDqM05Yon4Zy84aKbEVSxFm6kzJI4qhBG56sQ2cHYjYcP79cl0spKlYd3qUwgO7EqICSBdQYxqEExFXoz/wlx4JqvCFR1zpzpLXW+UfJO9q0MvAvF/UkyBrsMh17HADpj3NN5S61aUwzPJ5gc1Xnp1lKTAzQuLmEGvvDh6AzuJE28UTjPcdmzW+pxSus0rbo/3gifRX6kozLKh4/X9+M7RtpuqtDPU2s14KSHcahhlIhXHx4i/kT3HdbsR08FefbLE92sXTWu4PpNbo0LMczR+Uipk21Tu+iCxXVsNwmW+t4VOvZKwvAZgxw6x3eT0y X-Exchange-RoutingPolicyChecked: cDVWkL/n3v5kjgzTOhinqyDstqNmPaAvhdgtVRSsZwkdcPLe5w0q3hx4bATwHaHNRvYVAyDSzEbP7llsiE5k6v7sW522Xnm+AApAZJEChqaJa+CujdkNtshJDrq01zvXKq/kWid/uSZFmchWrCTJbh22xjgXF1GCHLo2b6LuIq+JkXrrXL2NrUa7dDYlrP2+LjGSHEI9OjosZROPbo/YSFHXF1v2v2QjBcYQOQZnZZZ1I4Xmav349jf0LP3P74LA74KOpiqQmOrZQmOnfZ8skXVjgz7XfYApLuFMLoUrCPr4Ogi1GbD/YIUR+eehuKqqvXDFFwP7vVCWSHiqz+lyjQ== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Aug 2026 18:34:02.9475 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3e3b394b-16d1-4812-92fa-08def7d71e3c X-MS-Exchange-CrossTenant-Id: e5b49634-450b-4709-8abb-1e2b19b982b7 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=e5b49634-450b-4709-8abb-1e2b19b982b7;Ip=[198.47.23.194];Helo=[lewvzet200.ext.ti.com] X-MS-Exchange-CrossTenant-AuthSource: CH3PEPF0000000A.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR10MB6425 X-Authority-Analysis: v=2.4 cv=M+V97Sws c=1 sm=1 tr=0 ts=6a7b6b1e cx=c_pps a=g4Zu/129bcKSj1q/f/8ScQ==:117 a=WotqVVQAdb04rnGuttW3Kw==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=Sv0fKeRqtYgA:10 a=s63m1ICgrNkA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=taLDd7a_hP9WKsMzeGRc:22 a=P-IC7800AAAA:8 a=sozttTNsAAAA:8 a=XczTfz52Gg2yNcvB9tIA:9 a=d3PnA9EDa4IxuAV0gXij:22 X-Proofpoint-ORIG-GUID: 4IBH53ijcxgtg9nCtSpYg6WqeTSTyRWQ X-Proofpoint-Spam-Info: AW1haW4tMjYwODExMDE1NiBTYWx0ZWRfXx1g9zYes6Fi/ NpMwmScG9wxin9Vw5tXU/0sWa864DjCa+Z+rDa492zhgcgLQXZIw2dENZBDZe8Dsm0mlTJTWNB3 2tfQR63jOL6W9o6N1MqITjdliEu0YGc= X-Proofpoint-GUID: 4IBH53ijcxgtg9nCtSpYg6WqeTSTyRWQ X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODExMDE1NiBTYWx0ZWRfX233FFjBXCctZ R2ot+bvkcZWzrULw24zvkKOsIjgeHzzbwPR8Segtl8Scs12u+6uy5Y4apYIBEdr7HfI7nyxL3oJ 1ZFUVr04DPu09SRLnecuoTn1g0ZRlan3bE/cWuel2itTSFbr2kvmC6jd94q4c+bGSOGqab0RqyI UfhUx8kNgBEAQUM1uQKN3BAjIjthwRXpTHsGAFdjEuQntda7TI+SBAD2/nVEvgIOCk6BEDeWEke rLUn/LVtxu1+mydF6f3BIJgQBFhs6/Ukkooun/gG/f7JyX8o0znkFpES6x4F3ENGbhNQVekULz4 aM5ChOmxUNCu57RF/j0sgyx8C0yZbPFwBA8Ku7mqLiRpODfpB9l8c58xh408pLAdKxZA/+9suQv OUT+m8gCAIZ4uq1lnbW2kX6WNBjQYh625UmZJX9V9jVP2iJEQsd1QZkV91WoGB0jwJxLZrHdBAj 8OAr7vjp+GV7oD52aUQ== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-11_04,2026-08-10_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 lowpriorityscore=0 adultscore=0 spamscore=0 impostorscore=0 bulkscore=0 malwarescore=0 clxscore=1015 phishscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608110156 Content-Type: text/plain; charset="utf-8" Add an execute_tuning callback to struct spi_controller_mem_ops. The callback receives a mandatory read op template and an optional write op template. On success the controller sets op->max_freq in each provided template to the validated clock rate. A callback return of 0 with max_freq left at zero signals that this specific op variant cannot be PHY-tuned (e.g. a hardware erratum blocks it), allowing the caller to try a different variant without treating it as a hard error. Add the corresponding spi_mem_execute_tuning() wrapper. Like other mem_ops paths it serialises access with spi_mem_access_start/end for serialisation and runtime PM, and rejects GPIO CS configurations which cannot support hardware-level tuning. Reviewed-by: Miquel Raynal Signed-off-by: Santhosh Kumar K --- drivers/spi/spi-mem.c | 43 +++++++++++++++++++++++++++++++++++++ include/linux/spi/spi-mem.h | 14 ++++++++++++ 2 files changed, 57 insertions(+) diff --git a/drivers/spi/spi-mem.c b/drivers/spi/spi-mem.c index c74858e58073..32773a4372f2 100644 --- a/drivers/spi/spi-mem.c +++ b/drivers/spi/spi-mem.c @@ -661,6 +661,49 @@ u64 spi_mem_calc_op_duration(struct spi_mem *mem, stru= ct spi_mem_op *op) } EXPORT_SYMBOL_GPL(spi_mem_calc_op_duration); =20 +/** + * spi_mem_execute_tuning() - Execute controller tuning procedure + * @mem: the SPI memory device + * @read_op: read operation template (mandatory) + * @write_op: write operation template (optional, may be NULL) + * + * Requests the controller to perform tuning for high-speed operation + * using the provided op templates. On success the controller callback + * sets @read_op->max_freq (and @write_op->max_freq when non-NULL) to + * the validated clock rate. + * + * Return: 0 on success, -EINVAL if @mem or @read_op is NULL, + * -EOPNOTSUPP if the controller doesn't support tuning, + * or a negative error code on failure. + */ +int spi_mem_execute_tuning(struct spi_mem *mem, struct spi_mem_op *read_op, + struct spi_mem_op *write_op) +{ + struct spi_controller *ctlr; + int ret; + + if (!mem || !read_op) + return -EINVAL; + + ctlr =3D mem->spi->controller; + if (!ctlr->mem_ops || !ctlr->mem_ops->execute_tuning) + return -EOPNOTSUPP; + + if (spi_get_csgpiod(mem->spi, 0)) + return -EOPNOTSUPP; + + ret =3D spi_mem_access_start(mem); + if (ret) + return ret; + + ret =3D ctlr->mem_ops->execute_tuning(mem, read_op, write_op); + + spi_mem_access_end(mem); + + return ret; +} +EXPORT_SYMBOL_GPL(spi_mem_execute_tuning); + static ssize_t spi_mem_no_dirmap_read(struct spi_mem_dirmap_desc *desc, u64 offs, size_t len, void *buf) { diff --git a/include/linux/spi/spi-mem.h b/include/linux/spi/spi-mem.h index f660bb2e9f85..ef5a6d60bae9 100644 --- a/include/linux/spi/spi-mem.h +++ b/include/linux/spi/spi-mem.h @@ -346,6 +346,15 @@ static inline void *spi_mem_get_drvdata(struct spi_mem= *mem) * @poll_status: poll memory device status until (status & mask) =3D=3D ma= tch or * when the timeout has expired. It fills the data buffer wi= th * the last status value. + * @execute_tuning: run the controller tuning procedure using the provided + * read and optional write op templates. On success, set + * @read_op->max_freq (and @write_op->max_freq when non-NULL) + * to the validated clock rate. Return a negative errno on + * error. Return -EOPNOTSUPP if the controller has no tuning + * capability at all. Return 0 with @read_op->max_freq left at + * zero to signal that this specific op cannot be PHY-tuned + * (e.g. a hardware erratum blocks it) but another variant may + * succeed; the caller will iterate remaining op variants. * * This interface should be implemented by SPI controllers providing an * high-level interface to execute SPI memory operation, which is usually = the @@ -376,6 +385,8 @@ struct spi_controller_mem_ops { unsigned long initial_delay_us, unsigned long polling_rate_us, unsigned long timeout_ms); + int (*execute_tuning)(struct spi_mem *mem, struct spi_mem_op *read_op, + struct spi_mem_op *write_op); }; =20 /** @@ -465,6 +476,9 @@ int spi_mem_adjust_op_size(struct spi_mem *mem, struct = spi_mem_op *op); void spi_mem_adjust_op_freq(struct spi_mem *mem, struct spi_mem_op *op); u64 spi_mem_calc_op_duration(struct spi_mem *mem, struct spi_mem_op *op); =20 +int spi_mem_execute_tuning(struct spi_mem *mem, struct spi_mem_op *read_op, + struct spi_mem_op *write_op); + bool spi_mem_supports_op(struct spi_mem *mem, const struct spi_mem_op *op); =20 --=20 2.34.1 From nobody Tue Sep 29 06:08:43 2026 Received: from mx0b-0002e601.pphosted.com (mx0b-0002e601.pphosted.com [148.163.154.28]) (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 268A83806CE; Tue, 11 Aug 2026 18:34:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=148.163.154.28 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786473263; cv=fail; b=ZPGkp8jmqTQPWIz4vpdo//xBNKJmgjrkhEdQEQ2OYuAsND7Vm+ki8q9JPDOZzjrxC+ev5s9IskZX91zi8+lV51P7glQpFWAR4dlanfifHzYISaRab7/EUGd0dsEQ0WSpG9Ow2bhx1HndwcZe642Xg5UJ6sMuzADhwQf83IB8d+s= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786473263; c=relaxed/simple; bh=v6ww6XIH8TcUT23LUPoMxzFGFmhFMyzO6/EXwGCMXPU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=h4JBzrTEmTky3yZXHYqkf6J8NftJT/SdeQLIvW6Xm6DmRMLkIpZy2UdgKNuqcqeWHk5I9r+XAAj0P6ce9J5gVTRSV7vdtPPNptRGk1r/4YmCOj+ZP1WOS8Lx4vcZGU+63WL/2kBOset7wAI8jkszA293cCFKucH5ym3SkqRFGBM= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b=BGiIpHAZ; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=v1XtAxaR; arc=fail smtp.client-ip=148.163.154.28 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b="BGiIpHAZ"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="v1XtAxaR" Received: from pps.filterd (m0374955.ppops.net [127.0.0.1]) by mx0b-0002e601.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 67BGMa4s2174814; Tue, 11 Aug 2026 13:34:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint-05-2026; bh=vRIdRiZggGVJbvsgQ0voaqOH53asB/hPokr2J9K8C Qk=; b=BGiIpHAZOgcZTBGtkqpGlzC8yrOfc1pbdqHv+vcaoPbaI5L3Seezlfeh1 sXWJQFIbkfwgFermbi7RWPUI3FVf0gorKw3BtccVUybpc+cKYREK2abP45djL1FH 8cVFuVtXjW9odz5HqD6u19b47qHL2ATMT0VcRuat7/1ZyV1Rr6B/8bAS45FL1V4o oi24Rg0gE2vjQfrDHczaZ9wHe2ndtUv7Rg2Z3V28ChIyRRtFRBpC0fg2yHDgT0hu fBXf3arG17ZCdtp6OKlHTbi2is33KiqiHKt5823+WRQ8XippCN9pckTzbnl2Vyjx yWOI+S5oMH8+DfrF0SnDaDnwnsNsQ== Received: from ph0pr06cu001.outbound.protection.outlook.com (mail-westus3azon11011062.outbound.protection.outlook.com [40.107.208.62]) by mx0b-0002e601.pphosted.com (PPS) with ESMTPS id 4g00w4uhyn-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 11 Aug 2026 13:34:11 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=CRzHUuyb3O6aqNOlSxsD6JK9+b8Xy08a51DERurhZFPdZwUztPJrAVH6321VRpFp3ik0EjXAURnBqGRsO2ZfFBtSoDPXwdMkjZMshLCS583Uh2e3uePRVWKZXJsL8WJVIlcbHoUWIuxMtn7FVHptpc6HoGXZnsbL01tfQsUJEdKUArEYC7NTkVa+BZFwxSx/I8QrAMatHo3RFYNdTvk637sD/NYRuKyTTtftE+pFvT/wC/BMIlQ1N5bE5fI702HsOC57WUmCeew+UmtDJdtXBhxsLlUevyoGjf8ZAM7B1gYoMPGJi3k8sL6XVH8WRrJi7yI8lGF/OJwA2/LEfu6ZwA== 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=vRIdRiZggGVJbvsgQ0voaqOH53asB/hPokr2J9K8CQk=; b=S1f9zC+izlSH7MmobDdE7xbdF0jEYJ+mzLYFASuTGqawJjqOLz8cXO/2rClXw5Hov7IesyKwsODpHSbhBAnkbi8xEnMTqTLIjXV6s9DwO54ZwJSb5uxMwb9akc4WL7Jt3bRiTBT8jj7A/IKqgcrCW+yvzlT7lo/DXpMQ/o7siUE5YTBgriGvkDbKejxkUzHUzJVvlUqh6dfWXXie+naiuDgExb8FCqjjS+NKNXGcae0Q3UXcY6Nxcb/YMzzpZD7IFkQggfUqm+LaPc40eMF8vLvlGN4M7Halsmg3pRBayv6OcB5EuGpcuLc3qgc/iTMy/8rVgmbOEqUrTZhdpyi8zw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 198.47.23.194) smtp.rcpttodomain=lists.infradead.org smtp.mailfrom=ti.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=vRIdRiZggGVJbvsgQ0voaqOH53asB/hPokr2J9K8CQk=; b=v1XtAxaRduBnJf2ClQHQimH9me0mnXGN257RXPeBwzUYsnP5WefeWkm1LhDYt1RAfCvxy0IK5461SecivJphYvbAVy/XSsHWrWIYezRa75wDL+Dz1QVFHodaogZxAb5fqBU3QsFVj9a6GEpJtN4aEEg+OzBKtw1sR0s+dmRy5Os= Received: from MW4PR04CA0057.namprd04.prod.outlook.com (2603:10b6:303:6a::32) by PH0PR10MB4696.namprd10.prod.outlook.com (2603:10b6:510:3d::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.315.11; Tue, 11 Aug 2026 18:34:06 +0000 Received: from CO1PEPF000075ED.namprd03.prod.outlook.com (2603:10b6:303:6a:cafe::35) by MW4PR04CA0057.outlook.office365.com (2603:10b6:303:6a::32) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.315.12 via Frontend Transport; Tue, 11 Aug 2026 18:34:06 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 198.47.23.194) smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ti.com; Received-SPF: Pass (protection.outlook.com: domain of ti.com designates 198.47.23.194 as permitted sender) receiver=protection.outlook.com; client-ip=198.47.23.194; helo=lewvzet200.ext.ti.com; pr=C Received: from lewvzet200.ext.ti.com (198.47.23.194) by CO1PEPF000075ED.mail.protection.outlook.com (10.167.249.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.315.6 via Frontend Transport; Tue, 11 Aug 2026 18:34:06 +0000 Received: from DLEE215.ent.ti.com (157.170.170.118) by lewvzet200.ext.ti.com (10.4.14.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Tue, 11 Aug 2026 13:33:53 -0500 Received: from DLEE207.ent.ti.com (157.170.170.95) by DLEE215.ent.ti.com (157.170.170.118) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Tue, 11 Aug 2026 13:33:53 -0500 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) by DLEE207.ent.ti.com (157.170.170.95) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Tue, 11 Aug 2026 13:33:53 -0500 Received: from santhoshkumark.dhcp.ti.com (santhoshkumark.dhcp.ti.com [10.24.52.55]) by lelvem-mr06.itg.ti.com (8.18.1/8.18.1) with ESMTP id 67BIXIdw659766; Tue, 11 Aug 2026 13:33:49 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , Subject: [PATCH v7 06/18] spi: cadence-quadspi: move cqspi_readdata_capture earlier Date: Wed, 12 Aug 2026 00:03:01 +0530 Message-ID: <20260811183313.1550425-7-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260811183313.1550425-1-s-k6@ti.com> References: <20260811183313.1550425-1-s-k6@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000075ED:EE_|PH0PR10MB4696:EE_ X-MS-Office365-Filtering-Correlation-Id: b9cb8886-067b-4592-a0d6-08def7d72040 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|23010399003|376014|7416014|1800799024|36860700016|56012099006|10067099003|18002099003|22082099003|921020; X-Microsoft-Antispam-Message-Info: W7PbwU0R/dBFsS0MT7jct+Ll08crxcHZT3MsmjW5Oettj7xuoM7cEFEPCEdSTs+cuWmGD4oOpNQMyQbNCGBUfsYTlYoXQVfFKiMBnDMmi2C8UUJPmvPxGyVBY1q4hYFlbmxFjpBMwzZZlUagEuIsY82IGHbgcbt2FsCggEu6EyyPk8mCkb05jN7ubkHR8lOH2044dH9uo+rRBA6TdVxFXzn8Z6I5fygjXx+9pUHb2csb+oeXtwlnSa3LAEmvqh6Nc0CcjM/iOcgvnO1N/TewK7UsMn1AMxWcLVNWKP7TJRsqk52z3FuAdNDyCGbg5uzr8Q+Hea1fEgFtPLxrPK1oNHAGAgtAW/QUov6IIAlSdiyHwAxa4HjXkABkK/QlAFpAGX1NLIfOJd1hp4/vXK8LWjYpUVyZz9MbSH+3GJaLDUUR8xv+AaKK11YrrS+eTVZDHLDNB5mEloVg/O6e1alqQMhwjEQA8pL/+blax38qPqDzWRb3BFNj5232mC2+GHrt5Ywc9wcyW2pjQyFU0W6f5Gzze8jq89EHz595IfvHL6JN+jo4faVhZDEpOyhZpQbcafyfEA4qtEa7nEZpKYlvDR6WshungbCjQRM39I+c4GpXdj+NqnJD5M2jjCXCvNYocUHN9btvctNPG0XRWaJOBx/LXUSvq2xaGADzgDt7KF3lkZ7r9meJRCfyEMZYI30JpQRmcHcArfvv2i4yotCFV8w5iYBYui7E5ujQQQJDfKABsHVK+NdkVWYuEj3Lr3bs X-Forefront-Antispam-Report: CIP:198.47.23.194;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:lewvzet200.ext.ti.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(23010399003)(376014)(7416014)(1800799024)(36860700016)(56012099006)(10067099003)(18002099003)(22082099003)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 4wbRChAaJGY/mTGCqnrIL4Pml0MNpfCp4368Nhs0XoC6Iz3HDzr2oo7H/S1oZFTjIEj0eeK5vF3CFgikHUqTxSkjHdWCXU79ZFR0G3VOoCMrslLit/mSzaGytPrROWGp1nSMZ0lUWAojnhDy+aFks9vgz8AxfLDOaShMmPBYHXAQPHDnf9JnfkkDwb/lK1lldxpuaiLGZ/jUCdcMPAY5ut+litDZ8UVutXvHygFynHML1jebP00nWqsI+ld+CfRxoDr1M5cmJXeMIy4aEwJhf27Zmo1xQrHU15emdncAkeyfC0fBS71y7bUJtk+xU95P3A6wRsOxHwC+SNaIEZcV9zFahz2jm1Fiy+ACHYxJjnv38B6H5muE1i04TNJLOMJHhIDLGw+t91Y868NPesT21/ESBF9yHx/qlPghdAcq+al23egsmnhS6L1voqx0U5wy X-Exchange-RoutingPolicyChecked: U6A5zZxQtaK/meU1xSDTL8OH9WROl3ZVa5QNQreM1emfA/mjc7fiexQTW3BeHJ4EQ29qn8ZeoD7rT9SM5Q4anmIpoA24AlGti9rygst/0BUFYLygy8WjMzGJTZzNJchBYjrwNAGgqhAvJo6fRJ69UuOZGGp9SWf/ll6/QbVKQYLfR7kDpszAD6BeEtxOu9L/EbjNf2n+ofF5AGv3gsuwdzP5Mcm0HLod82SwwOAiHenVP3zjeG4vzUnLL5sM96w+JC3uJrtAK3TiuaFReguMsaiNtVXepc14N55nShZLdLwn3rMi+J9W/ii06zYhasPgRjPs7qVSXYdtPbDO6T7+/Q== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Aug 2026 18:34:06.2990 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b9cb8886-067b-4592-a0d6-08def7d72040 X-MS-Exchange-CrossTenant-Id: e5b49634-450b-4709-8abb-1e2b19b982b7 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=e5b49634-450b-4709-8abb-1e2b19b982b7;Ip=[198.47.23.194];Helo=[lewvzet200.ext.ti.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000075ED.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4696 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODExMDE1NSBTYWx0ZWRfXy07CRiD7buLR QHrH7g8ttk1tDSPYwUgWJlIDZATX0KR3M8uDUr3GUuBo7G7jMEKG2Nl9cZRME5Bj0kTMDA/WtJX /lW8dAeLjDNknCaegfjNYIwDlneFNbfMZumnWhUHwb80QSgx0WLrpbsI3FenzBtXGKh+d4V4y2M qLL1Ip0rJCPMo3H10B3jF8CpGLIoScEcceF2qMGXkOVs5FT58guxBlxg0zzc9d4MR4Xyyjz8N8V a3KCHHNRmN6AoZFa5LdUqoCDp0EHXvCywbjPP3FzbnH8OnnoQdpp/HFrqWQbKLievPUVzTx7iRs tNhs0YGtlIPFgMaKF5V7UEBNiGdoQ8NuNj8Fwo0yHOTqNgrLVbj6qzFGB04GHDvGI4k/VireGb+ pw6036nak6RG4Tgp4TDG+jY/EEhvd5cc6bGuSDMLJxFPRqdSCO6eUTBCw0OFMDm1GAsLoL+aY4w QFAbNagI1NJ/zRSsF/Q== X-Proofpoint-ORIG-GUID: dr-DfMxLo8sise-gwiXcAYUbj0QgaDc1 X-Authority-Analysis: v=2.4 cv=KZ/idwYD c=1 sm=1 tr=0 ts=6a7b6b24 cx=c_pps a=ZweBVesMg4eTnUcQsPPJdg==:117 a=WotqVVQAdb04rnGuttW3Kw==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=Sv0fKeRqtYgA:10 a=s63m1ICgrNkA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=fPAWb5peG099m5CrUpKH:22 a=P-IC7800AAAA:8 a=sozttTNsAAAA:8 a=2vpyfyhlguDYHLkT4YcA:9 a=d3PnA9EDa4IxuAV0gXij:22 X-Proofpoint-GUID: dr-DfMxLo8sise-gwiXcAYUbj0QgaDc1 X-Proofpoint-Spam-Info: AW1haW4tMjYwODExMDE1NSBTYWx0ZWRfX9MXm+A4i7jnJ 5x7qnzQo0oXUNja3hraKHQ7u/l8Y1OPwf2mOqUtNcnWb+DXAoJ/ioJD3qssynis7RPfmqwTt1R5 ixJp6qYrWqLicx5zEpt4EaDhZwzLOi4= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-11_04,2026-08-10_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 adultscore=0 spamscore=0 suspectscore=0 clxscore=1015 phishscore=0 lowpriorityscore=0 malwarescore=0 priorityscore=1501 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608110155 Content-Type: text/plain; charset="utf-8" Move cqspi_readdata_capture() function earlier in the file. This is preparatory refactoring for upcoming PHY tuning support that needs to call it without a forward declaration. No functional changes. Reviewed-by: Miquel Raynal Signed-off-by: Santhosh Kumar K --- drivers/spi/spi-cadence-quadspi.c | 45 +++++++++++++++---------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-qu= adspi.c index ecb0be394696..f8e266372367 100644 --- a/drivers/spi/spi-cadence-quadspi.c +++ b/drivers/spi/spi-cadence-quadspi.c @@ -457,6 +457,28 @@ static int cqspi_wait_idle(struct cqspi_st *cqspi) } } =20 +static void cqspi_readdata_capture(struct cqspi_st *cqspi, const bool bypa= ss, + const unsigned int delay) +{ + void __iomem *reg_base =3D cqspi->iobase; + unsigned int reg; + + reg =3D readl(reg_base + CQSPI_REG_READCAPTURE); + + if (bypass) + reg |=3D BIT(CQSPI_REG_READCAPTURE_BYPASS_LSB); + else + reg &=3D ~BIT(CQSPI_REG_READCAPTURE_BYPASS_LSB); + + reg &=3D ~(CQSPI_REG_READCAPTURE_DELAY_MASK + << CQSPI_REG_READCAPTURE_DELAY_LSB); + + reg |=3D (delay & CQSPI_REG_READCAPTURE_DELAY_MASK) + << CQSPI_REG_READCAPTURE_DELAY_LSB; + + writel(reg, reg_base + CQSPI_REG_READCAPTURE); +} + static int cqspi_exec_flash_cmd(struct cqspi_st *cqspi, unsigned int reg) { void __iomem *reg_base =3D cqspi->iobase; @@ -1274,29 +1296,6 @@ static void cqspi_config_baudrate_div(struct cqspi_s= t *cqspi) writel(reg, reg_base + CQSPI_REG_CONFIG); } =20 -static void cqspi_readdata_capture(struct cqspi_st *cqspi, - const bool bypass, - const unsigned int delay) -{ - void __iomem *reg_base =3D cqspi->iobase; - unsigned int reg; - - reg =3D readl(reg_base + CQSPI_REG_READCAPTURE); - - if (bypass) - reg |=3D BIT(CQSPI_REG_READCAPTURE_BYPASS_LSB); - else - reg &=3D ~BIT(CQSPI_REG_READCAPTURE_BYPASS_LSB); - - reg &=3D ~(CQSPI_REG_READCAPTURE_DELAY_MASK - << CQSPI_REG_READCAPTURE_DELAY_LSB); - - reg |=3D (delay & CQSPI_REG_READCAPTURE_DELAY_MASK) - << CQSPI_REG_READCAPTURE_DELAY_LSB; - - writel(reg, reg_base + CQSPI_REG_READCAPTURE); -} - static void cqspi_configure(struct cqspi_flash_pdata *f_pdata, unsigned long sclk) { --=20 2.34.1 From nobody Tue Sep 29 06:08:43 2026 Received: from mx0b-0002e601.pphosted.com (mx0b-0002e601.pphosted.com [148.163.154.28]) (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 6761E396567; Tue, 11 Aug 2026 18:34:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=148.163.154.28 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786473299; cv=fail; b=J3DU2CmMo9DnFho6Np5C0yXqpO2SEKG1cM97HfNcyCZWz+iKo0fBO/Z0xeVxgZzIzW0+Ycubq9+eUq/kUGBZNVkk6RGzwSrfH5oYR/QyditPIa4Lfq1xPmAByJtQlKfDPEtvY2QwVP8gsX92/rsAe5TC+KtYlgGAgJeY1hm2C7k= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786473299; c=relaxed/simple; bh=nHERynUITfg5e3Nh2yAHKyBReZZf4m9KBYLOhEczroA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=oH3S6ueuFID8m9WHERoCCQMPLLLnO9XfXECZ9JZCaDcf/YXmdj+KAz9nAWcbpb+vHY6bgWb5cKZOGD1zhARpDqfEMnC0sABRPQcO7F7oziicNAgla3rFwgPOnKHTzd/djs2/KUIAVteaTHAkbGsa2BrSbw7ADHZZI+k2vPwYZMw= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b=VHY4cyro; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=JD89VWsh; arc=fail smtp.client-ip=148.163.154.28 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b="VHY4cyro"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="JD89VWsh" Received: from pps.filterd (m0374956.ppops.net [127.0.0.1]) by mx0b-0002e601.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 67BGM8f31823866; Tue, 11 Aug 2026 13:34:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint-05-2026; bh=UDgIqenZB3DR5a29o3tuvANtwgRl7SpThCxLM+b+1 nQ=; b=VHY4cyrolfSBHXaa7mzyJuvh+Z7kON18owhWHqC7CBRRRs5FA4s9gJ0jP ebbJYNfvu3BdynhGGaMADf/+oXYmRTC7qeNqjmy8hQyJPRO207Go1gJXyHS9rZQb YvZfecuwQsDCZ8JmHrM75MJU3UN89o/DkHDkSOlAoo5Eu0IVX7u+7aavE+3B49gl QQnabeNXcxLmc/WLVxUh2GtchAjPeURCXs0PqqvWwoAjP8ayR5R4KY+jGbI51gkl uZO/BvGplFGkX8G9yd0z4ApqlcEtwvPk2i0YL3FYRbmWzfrswVLEn0tvYJ9+NKxb 1eRdZFbgbGdBa/gqVZ4g23NcPkguQ== Received: from bl2pr02cu003.outbound.protection.outlook.com (mail-eastusazon11011009.outbound.protection.outlook.com [52.101.52.9]) by mx0b-0002e601.pphosted.com (PPS) with ESMTPS id 4g00wnbk9c-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 11 Aug 2026 13:34:47 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=moIhtydSMvYEjKr1Azt9LxPAVyoiUd4Oqc0XbWFDPLBDe0DDsNwVUP67I+pep3OgCOLpbXxvU+YJ0QfUXYpm58K5y9ru3jxnBY3Lq6nsQowAtUgjWuNuiYyPk04aWZ6Ert1lrqT1cy5wfzsNawH5Ec3KjgVnFZCzlr0iBFB9B7R2he3iCpmCMZyu7FuTOsJPFq0lcCwYHPUBmo+XuYdVJYmMiKWbtyX3goi/RJdzDZz9vd7xgw2SbY5ShSzLqpOoDVJSN646EHWF5/S5lnnCGz72eg0Rd+XuFcmnCjNTq/dQkDB4rQUGF1gd3s9DsrRCDKFQTJ/pJKgIVL+0i/qBcQ== 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=UDgIqenZB3DR5a29o3tuvANtwgRl7SpThCxLM+b+1nQ=; b=V0M/7qMrIu78rt/ljOyWnmNnICRXQeWDDYaHNvYWcua8MRnAG1IRLSQjYJZalSoQrgvzkXZ4EFwFPq8A5qDIb/XXjYXjYY16y1kxXXtN5NQl+TNSLpqARS0yfgS/pXeh+jH518QiHvCkXWyoaTRykONNYalrnbjeBLe83uG29QNgTsKPc312nZ3V9DddsT08PulTiZaaNv91oMKSdf0XydpT731Xr/hnVInEt2+OG/2oPpurriVZfBtc9ztPfRg7rQj6TvcjhyPH9J4+oD8mckYQhqYIyU0di70ZC2lHmZHeI/9JqawWjZ6MLcJ9PosqYX9VwQMGKU23vNIGKfbo1w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 198.47.21.195) smtp.rcpttodomain=lists.infradead.org smtp.mailfrom=ti.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=UDgIqenZB3DR5a29o3tuvANtwgRl7SpThCxLM+b+1nQ=; b=JD89VWshsDXoeRea5HaEZRrPz9nmQAuKTrfvfzf9seZsTz+BA6b3Onw5TGNbmYMiipBiI57uylwiW2ylKEhSHT59uIs4xUBWDOlK39CkfMHW3Crm4+cuvEc0KmVKjeyFQnpBI9l2WVubQAFZj5eTX6vaxDl/ecba1Ay3q8VDyGs= Received: from CH0P223CA0014.NAMP223.PROD.OUTLOOK.COM (2603:10b6:610:116::18) by DM6PR10MB4265.namprd10.prod.outlook.com (2603:10b6:5:217::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.315.12; Tue, 11 Aug 2026 18:34:36 +0000 Received: from BN3PEPF0000B076.namprd04.prod.outlook.com (2603:10b6:610:116:cafe::8f) by CH0P223CA0014.outlook.office365.com (2603:10b6:610:116::18) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.315.11 via Frontend Transport; Tue, 11 Aug 2026 18:34:36 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 198.47.21.195) smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ti.com; Received-SPF: Pass (protection.outlook.com: domain of ti.com designates 198.47.21.195 as permitted sender) receiver=protection.outlook.com; client-ip=198.47.21.195; helo=flwvzet201.ext.ti.com; pr=C Received: from flwvzet201.ext.ti.com (198.47.21.195) by BN3PEPF0000B076.mail.protection.outlook.com (10.167.243.121) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.315.6 via Frontend Transport; Tue, 11 Aug 2026 18:34:34 +0000 Received: from DFLE211.ent.ti.com (10.64.6.69) by flwvzet201.ext.ti.com (10.248.192.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Tue, 11 Aug 2026 13:33:58 -0500 Received: from DFLE208.ent.ti.com (10.64.6.66) by DFLE211.ent.ti.com (10.64.6.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Tue, 11 Aug 2026 13:33:58 -0500 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) by DFLE208.ent.ti.com (10.64.6.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45 via Frontend Transport; Tue, 11 Aug 2026 13:33:58 -0500 Received: from santhoshkumark.dhcp.ti.com (santhoshkumark.dhcp.ti.com [10.24.52.55]) by lelvem-mr06.itg.ti.com (8.18.1/8.18.1) with ESMTP id 67BIXIdx659766; Tue, 11 Aug 2026 13:33:54 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , Subject: [PATCH v7 07/18] spi: cadence-quadspi: add DQS support to read data capture Date: Wed, 12 Aug 2026 00:03:02 +0530 Message-ID: <20260811183313.1550425-8-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260811183313.1550425-1-s-k6@ti.com> References: <20260811183313.1550425-1-s-k6@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN3PEPF0000B076:EE_|DM6PR10MB4265:EE_ X-MS-Office365-Filtering-Correlation-Id: 26a12d71-28f5-4235-fccc-08def7d730e9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|23010399003|36860700016|376014|7416014|1800799024|82310400026|921020|56012099006|10067099003|22082099003|18002099003; X-Microsoft-Antispam-Message-Info: xVPWXlqZQskH2y933cwuUawTGodfeQunG5pSAR93PoZFYPZXJhmPOx5y5i058H9QCigjYaVmH1y+QQRNpTqO0fmaCTX1WDgsI0w5t0biWmw91j0wo/LIhCVkDuJX+lQS+SRQ0tpVez2yw3puetnzodbeXBRut9BkDqk+BMpXWvVUlcKa0ZH4MFkk/uqg6x7vK7+UpL6sHkJIkmXFN879O0cKIjkGU+WvrSxjxpk67qO1sA5RyeUhopFwvtBB+QlrXIJ/nDfzIjqvg+YNpKreyrCeblaaUao80aAqs71lj0gMoIhWUe+89NnGEhPKTXae96xsCWp6Jb8iqex9/IubSPUj2koZlsgR0/Q8OHubO8AOaff9aCAtb2AKWUTkzMev+g7e4gfensDqAeoQR6OvaOQQJgxKKOQdmFa9EsOh2abx1UzyfFAnEbeHxtYjbspCVYXsfN4/iwLWrcITCYL9rJF/7UxLkFQ0NVhb1YKse8jixkGgjEb8DYMlQbXlEPeCwYO21SskwDIP8tMSy963IQKjDit1DL2IIVPnktUyFV+yaCMxzXMGmWdJbxXvgE4XYYpRsMGhwgAbFCLYnbhW8inZPHayLtPHoey7jqgyDVs/oEHuUlEQmfzk5NdXWx5qyLGWMbj5+/Vpr0V4+gGxfqXH+UOAIG6/QW4YRePLgib+VB6pkeiI7gHwqONsE+tQjFa6KT8IWwggu+vEMUOU24aErrJh0XYcM0KyHJmuzX7iYTOWykUCieNuEVW5Yquv X-Forefront-Antispam-Report: CIP:198.47.21.195;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:flwvzet201.ext.ti.com;PTR:ErrorRetry;CAT:NONE;SFS:(13230040)(23010399003)(36860700016)(376014)(7416014)(1800799024)(82310400026)(921020)(56012099006)(10067099003)(22082099003)(18002099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: wZ/V3TDNAfDy4PEpYJhJS2htczFGjVHDnnJFJwyAdmP23sOkfKgH5Wj5mM7GDaBL3SF14q7UV/IevwZWpfXfL/5rF+3UBvebNVsFBJXgWIeve14EOYXbz2CJKvTRbbm4T6h2hXk8RUyzm3dv+4dS3mISFK0JvrFE/kbr1Jp6klaLyN9ArKR7GuMDHozsjt9TGy16YGq0XhMQW3I2fas6xhh3dzg6cCD+BQa2Gc7LCDj3NFfl2V5zHnOVvgX58+4mp6EsJ7TXCuAyOgadlNuzg4Xb6IojbSdHUpsZOHQrqlLvxRWGvmGR3T6FkmittJiREL+PKoMZ/Dtm7nbG03JJA6Zgy2Xv+JYQ4Y7G2ZpCNFFRBlOLLjiF93bgJIYodc1KhGs1Q9afYSZzKbGRvQvGt7Ch6b+iw+Eeqdc6bALoueNeYeAFB8/xzoppSGTHhTLn X-Exchange-RoutingPolicyChecked: OLNBDx17EOAGGUxL57WoRUZ6slBDW9nIM8PWwqudHWFKKOMbYB8KXNGdC6MZuLJ40cwa2J8pI+terOtd/hb9TouS8E7GSf/3gn05F5UBtFs1QwT72nPHFYolDI24oxa0OwKpxGdHL0YNuL0b8NAB3RAI+Zk4S/5+LZDpC8tMOkF6vPyODaKIWow8OZSjkijYbR4os8uqNi4fZjWXz7oCcvywaRANX3SghZIrGtarpmWISwXwvUrs8Lv5khCPGVjosuiZmLo3K719tdKlM+PT2YPS4GvWOKt2AD6LfU0AydX2VgA3wiE/effl5MCLOuJqcN7TJBuR6S+/bPz8Z/YnOQ== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Aug 2026 18:34:34.2706 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 26a12d71-28f5-4235-fccc-08def7d730e9 X-MS-Exchange-CrossTenant-Id: e5b49634-450b-4709-8abb-1e2b19b982b7 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=e5b49634-450b-4709-8abb-1e2b19b982b7;Ip=[198.47.21.195];Helo=[flwvzet201.ext.ti.com] X-MS-Exchange-CrossTenant-AuthSource: BN3PEPF0000B076.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR10MB4265 X-Proofpoint-Spam-Info: AW1haW4tMjYwODExMDE1NiBTYWx0ZWRfX0PjPtHS8Gl04 exRnOz0Nk7V0sQLTtL4A1/jTQACpeUPi+onmTyiwLFO1F+0Is9RX4eUihC47/Kx0caZ1FoNE/8L Othyn7bA0Dei/o/SnVjSAHMAe8h6Ss4= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODExMDE1NiBTYWx0ZWRfX5PWwU9okWjm3 v+AY3d9a8dGCoHmMBrSOPveO8YSVEJU3QNG2JDAR19FmfZ8zTfqVjxQoGe8kGZ8J5uFEioBzhFC k7XpOrTuOceeG9OgZwMt/2/q/K7WzO+ZAXHkkSc+8k6HvQWjluW60dtf44gCZkUMbbJO5OktFSY ngdwkl/6RKBYjOwz3/+7KUm7QX5gOAftQqdAfP8UBXTCy16mhecqAZ3T7ESnSEDUM8UiOaQJ8Eq FzAP/kYFj0qTQ07k5/DJNMFf1/TF2VXwLwCUYNp03Fz4k/jaNQR22lnJoKsKObK8ln9IwmoG8uQ 7Ut+ynbJOugyg7cpbst4OBlpkRnB9Ttpm40cw7doP3XrUaGckW0rQyA3/wv3JH8L/iOQ7ZqlTUO O7/lkffowQIkxoiJ6RHvdDS+ITtun6i1gd+MQsEEYWbWb+S6WqrqbHXd4lv+3kYmB7btMrkSUtF fdruT+njGLZFmaykeoQ== X-Proofpoint-GUID: BvvbCXM6H_EJSCeGNI69P3dZCFna6whP X-Authority-Analysis: v=2.4 cv=cYziaHDM c=1 sm=1 tr=0 ts=6a7b6b47 cx=c_pps a=kBTuJkHEWKOaoYTOH1TR3A==:117 a=tJyPKKxUohctrY4NYmUjkA==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=Sv0fKeRqtYgA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=jwouBfj2j3NM8CExmVVE:22 a=P-IC7800AAAA:8 a=sozttTNsAAAA:8 a=by1YfaDFVIW1-MDklf4A:9 a=d3PnA9EDa4IxuAV0gXij:22 X-Proofpoint-ORIG-GUID: BvvbCXM6H_EJSCeGNI69P3dZCFna6whP X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-11_04,2026-08-10_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 bulkscore=0 priorityscore=1501 spamscore=0 suspectscore=0 impostorscore=0 malwarescore=0 phishscore=0 clxscore=1015 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608110156 Content-Type: text/plain; charset="utf-8" Add DQS (Data Strobe) parameter to cqspi_readdata_capture() to control data capture timing. DQS mode uses a dedicated strobe signal for improved timing margins in high-speed SPI modes. Reviewed-by: Miquel Raynal Signed-off-by: Santhosh Kumar K --- drivers/spi/spi-cadence-quadspi.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-qu= adspi.c index f8e266372367..046fa5d69b0f 100644 --- a/drivers/spi/spi-cadence-quadspi.c +++ b/drivers/spi/spi-cadence-quadspi.c @@ -192,6 +192,7 @@ struct cqspi_driver_platdata { #define CQSPI_REG_READCAPTURE_BYPASS_LSB 0 #define CQSPI_REG_READCAPTURE_DELAY_LSB 1 #define CQSPI_REG_READCAPTURE_DELAY_MASK 0xF +#define CQSPI_REG_READCAPTURE_DQS_LSB 8 =20 #define CQSPI_REG_SIZE 0x14 #define CQSPI_REG_SIZE_ADDRESS_LSB 0 @@ -458,7 +459,7 @@ static int cqspi_wait_idle(struct cqspi_st *cqspi) } =20 static void cqspi_readdata_capture(struct cqspi_st *cqspi, const bool bypa= ss, - const unsigned int delay) + const bool dqs, const unsigned int delay) { void __iomem *reg_base =3D cqspi->iobase; unsigned int reg; @@ -476,6 +477,11 @@ static void cqspi_readdata_capture(struct cqspi_st *cq= spi, const bool bypass, reg |=3D (delay & CQSPI_REG_READCAPTURE_DELAY_MASK) << CQSPI_REG_READCAPTURE_DELAY_LSB; =20 + if (dqs) + reg |=3D BIT(CQSPI_REG_READCAPTURE_DQS_LSB); + else + reg &=3D ~BIT(CQSPI_REG_READCAPTURE_DQS_LSB); + writel(reg, reg_base + CQSPI_REG_READCAPTURE); } =20 @@ -1317,7 +1323,7 @@ static void cqspi_configure(struct cqspi_flash_pdata = *f_pdata, cqspi->sclk =3D sclk; cqspi_config_baudrate_div(cqspi); cqspi_delay(f_pdata); - cqspi_readdata_capture(cqspi, !cqspi->rclk_en, + cqspi_readdata_capture(cqspi, !cqspi->rclk_en, false, f_pdata->read_delay); } =20 --=20 2.34.1 From nobody Tue Sep 29 06:08:43 2026 Received: from mx0b-0002e601.pphosted.com (mx0b-0002e601.pphosted.com [148.163.154.28]) (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 2EB0D3921D0; Tue, 11 Aug 2026 18:34:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=148.163.154.28 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786473295; cv=fail; b=fZaG/J7PUaN0rFxk3d9aL8k2myz+fCem4wJ9XhNR4200QTPqnOYrFzDzSIa6NU80TQ6t5OM3n40MUYb9nvVOsA77+FMrqrv3aeQERDFhei+MKKTdKkep3kuZhnTn/eMisqU+WucMhWPp8SfRdOVI8m1NPgnVpNwzH57HEMIFRTI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786473295; c=relaxed/simple; bh=Pl8i4JrMF60JOyauZ+C6d7yyCiQG3W4ly9ddC1MuAjA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=lvI5TaSiE3BK5BGTDFKVhvfBqF7CMSRIuXPQHtGEWxdJ4g7HeOAj3y4g/jWyABmNlCrNGdrUA9nUhFE2QTG47qERnOI4tRd0Moe5nsBHojJnCsGwW+IsKsZTErTEdYDIXWXUoMefam3i0Lcy6zlc/V7tKaI/pB/3mXCHf+XywnQ= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b=BEmV19jx; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=sjRqdVmG; arc=fail smtp.client-ip=148.163.154.28 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b="BEmV19jx"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="sjRqdVmG" Received: from pps.filterd (m0374956.ppops.net [127.0.0.1]) by mx0b-0002e601.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 67BGMb7F1824733; Tue, 11 Aug 2026 13:34:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint-05-2026; bh=XKqZb514dU3Fr2ET9vB1QaHriVkBPOLEhjAauNEn8 iE=; b=BEmV19jx/fOqsJ3WZGOlHix1rf/iTqbEOqNgBEcyjjrk4/Us038iyCO/O WrOuK8uQMWROrlt19peTY1KhZ35IiMxMiMo/laZDXdEUJN40bxVP6uc+TvQdvlNC ZZ5rlhfNbibiaPMdcvqia+XLW3wNWd2l66AtAnY3xfXQAANvEbklcN+PQ9w+72uW zErhwQObgAKJ6EJgytUysOTXRi0L8wpmAKzj7rOC3rj7hOlQS1xDyubdtKJnk5nU 35xxh4D80UJYauvv1WwxeUF8wrhhEVuC+FQ48nykz/qpucn6y7vAag2Jlvw/cgUp XIMkzHuwqLDmknm+A3iCC6wY1Fqug== Received: from byapr05cu005.outbound.protection.outlook.com (mail-westusazon11010031.outbound.protection.outlook.com [52.101.85.31]) by mx0b-0002e601.pphosted.com (PPS) with ESMTPS id 4g00wnbk8f-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 11 Aug 2026 13:34:37 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=nJ/T60pmLibzvloe9xvvKT4vplydsaKA/EFaW2iYfp48WcqP26uH05tPtuS6CzTffAKHGlHm2/IhApncYE+nq7CawDTj/DJYa9ZGRqF8Bf7lMTVHYReXURfvhXWvm8B+ZtuQBt4yiLZaMzOygmjJMbaUCKJN2Ft/ODqwtuR1V/xCbgLmM2y2ERVlVjYXeqDWzwSLNUW13rKEcW4uHB4ZmC6m1AGb8PzuZdQNfZ7jJHvEDvSUNUmRJyFQbDDRoahmBPK1WR4gn4XctaszSEVJYUKrjF685+VpseEI8UFieOdYkaXQXjUYttoWs64IKn7cc1MNK4pkvPFTH7+5U0eb1A== 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=XKqZb514dU3Fr2ET9vB1QaHriVkBPOLEhjAauNEn8iE=; b=drypfz8L4e+Oyv5NjUtswqqDhhhm/Ox3nO6W39jPgFvv7XwkP72coCzZ6OtklzULLxzPYcRvGiFrZF7qzCmQupAyAkzvb8Ni5cmFEVrtWTEwxlAGHsyQsqil9bSjAedPxCE53O8gXKczuDLwp6i+GA8MFifg/18dN6f/lG4Zp/SCFWwPdo4hjo/+GFm96zlKBhW6mUlDe06HUfSl+2HyobnyrtEP1lqYa00hDxSTAhDeu7z9CrX50ySHt6kCD9B/ITUsuq7UyObr8wjWPRXrTxay+710E6kc+J/2/UpZGwF69SjM9NdRD276gw+aYNLYklrBWh+ov5T5mtt4h2jnqA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 198.47.21.194) smtp.rcpttodomain=lists.infradead.org smtp.mailfrom=ti.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XKqZb514dU3Fr2ET9vB1QaHriVkBPOLEhjAauNEn8iE=; b=sjRqdVmGNm/+7/L+2kl3P1wfpG4/FfAse5bEI+P2qNQnCDcZLjblM21/ZSt29H1Sc9LwxBPTgO1NzomCRihtN9JURd/5YN5IC6f7heLw21IKIOqFaimkEzKu19sac9Qv9eUSeixa32+rnaE5wjqaEhx6TAtjsbxSHDelAaODiYI= Received: from CH2PR02CA0005.namprd02.prod.outlook.com (2603:10b6:610:4e::15) by CY8PR10MB6708.namprd10.prod.outlook.com (2603:10b6:930:94::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.315.11; Tue, 11 Aug 2026 18:34:29 +0000 Received: from CH1PEPF0000AD79.namprd04.prod.outlook.com (2603:10b6:610:4e:cafe::ab) by CH2PR02CA0005.outlook.office365.com (2603:10b6:610:4e::15) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.315.11 via Frontend Transport; Tue, 11 Aug 2026 18:34:28 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 198.47.21.194) smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ti.com; Received-SPF: Pass (protection.outlook.com: domain of ti.com designates 198.47.21.194 as permitted sender) receiver=protection.outlook.com; client-ip=198.47.21.194; helo=flwvzet200.ext.ti.com; pr=C Received: from flwvzet200.ext.ti.com (198.47.21.194) by CH1PEPF0000AD79.mail.protection.outlook.com (10.167.244.57) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.315.6 via Frontend Transport; Tue, 11 Aug 2026 18:34:27 +0000 Received: from DFLE213.ent.ti.com (10.64.6.71) by flwvzet200.ext.ti.com (10.248.192.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Tue, 11 Aug 2026 13:34:03 -0500 Received: from DFLE211.ent.ti.com (10.64.6.69) by DFLE213.ent.ti.com (10.64.6.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Tue, 11 Aug 2026 13:34:03 -0500 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) by DFLE211.ent.ti.com (10.64.6.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Tue, 11 Aug 2026 13:34:03 -0500 Received: from santhoshkumark.dhcp.ti.com (santhoshkumark.dhcp.ti.com [10.24.52.55]) by lelvem-mr06.itg.ti.com (8.18.1/8.18.1) with ESMTP id 67BIXIe0659766; Tue, 11 Aug 2026 13:33:58 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , Subject: [PATCH v7 08/18] spi: cadence-quadspi: add PHY tuning support Date: Wed, 12 Aug 2026 00:03:03 +0530 Message-ID: <20260811183313.1550425-9-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260811183313.1550425-1-s-k6@ti.com> References: <20260811183313.1550425-1-s-k6@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000AD79:EE_|CY8PR10MB6708:EE_ X-MS-Office365-Filtering-Correlation-Id: 1f3b2801-f6ac-46d2-d02b-08def7d72cc1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700016|23010399003|82310400026|7416014|376014|56012099006|10067099003|6133799003|18002099003|22082099003|3023799007|921020; X-Microsoft-Antispam-Message-Info: DeCFaztqaLXQeNjpVSfxmowZcJ9QjbN1+tKEW+tAHPE4psRGJ4xEveYfOOIPtaN1p6keSF1hs0zHU6Yd8k3AJlfZ3ON7G4mFEu+iG+zvNgU+/Je+bpMLRtuwmkcEsj8HZRrkY8ud/tMd312Ri721FoJTPmBrTeP4WWRWVMZ/w5X9HffTvURGranFlWWMjLW2cBtgt9GLnVSulgBfqqyz3slIAzDKxRXT0hoQN9M1KCIdvLPn0DRUzmsBaCM5YNkTKbzg2xKkukyiv0J5K19K+xzjvQXO6sSTtrig61ahCe3MYnMOsFwLQOSDsac9+xEZ1k2R70h/apivlONJOBK3VCRJ6IGB/6hZZ2ZRu9VX7LndCxb+yW8VnlHsXQEpe8ZefqjEZeWo0H45CqTzD7pqKVy1ZAfvE7S/ilolpn+xBuP9R0ooe31I7ZB3nlRVrL2tuKczy4gVfM39mgCqd3ZHODsG8No94soesbZ533/kO+D/I+xbYfQrHHn6++VuuFqnGTehuh7jzpMx2d4BxELHpV7IBVliR+HgeBdBizxi01mYvnHpv6aYsuCqs6MWZhMCxgICmwLMMqYDF0yQowF1bhcLJ5K6McjpClJ5ACZqkK5+BhSEnoiTVBuxdfQvXOwvrPNZDC1ptGRuBA7Q7X75R4iiZuzOWoXVl4+fTQsYISav3u9QOBWH2NMmq6JwUIHU X-Forefront-Antispam-Report: CIP:198.47.21.194;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:flwvzet200.ext.ti.com;PTR:ErrorRetry;CAT:NONE;SFS:(13230040)(1800799024)(36860700016)(23010399003)(82310400026)(7416014)(376014)(56012099006)(10067099003)(6133799003)(18002099003)(22082099003)(3023799007)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: eh6/dWzSergFQVg0zcd8fPZoLC+9ydeuKHMt2oHbAeGMtnVH0mH98PP1loIWln42xunPKWhyqFPH2gsfQDWdjsISywXKkj3RZiRM6DDEeLf2STx/jJNnABqOdcJuvaPV/KIcDQ7V1E94h7vCeqI0vBpBqBsWAP6RHFFpJicuZPMfdqaTH6tnd7dCTtfwMBjX3GyTcpZrgjNKb/IFffzBoazczyT+Hg5/CTeglqzJT1uTlIJ3fgEb6jxxnjl5geyRp2vB9x2rmrwNxI+0h6kzcTsd4FQS2maLKamqnk0wgwJ3n0609Xf3AkfsGYtIMy938RNIep6uw4OM6UNkvxIvCQr2Qkfa+7vnXB9GttkjA8VFUQBViTlMDGKzr5jz1ITOocxEyrQjiBzGZXzWtY+G6SJ7LwtedSMUBkWwFGiy9fFr70dqgpQxWASMyMCqa5Vm X-Exchange-RoutingPolicyChecked: s9evfU7ESK6K5ZEkjA8zvw74zFC4NJzBqNAyjQpkL71lYYICAqQrUtUkp1P1P7bnqlpbCX1RhuguvZiGBmDWqOAl42yGle8cqgMHLu2nliQwnX+2Ga4vOz8na8tzGrapl07asUnPVvSI9qLl6ntheMoa9pLY4KMe2ZwfXK9G2tlrq4+lSqijpDgN1QKkMBl3O3uMw3o0Bj1o12dkRlkdtBDtrk/Ec1/AF10xp8BVjc8O6SIzAF3EO532cbbvNxtXY+rdQivfGgLyoFsHtrLFjQu8R2inltXs6nF6y87iGbkCAmh79Xe7vSTLLPr/m+qcaVL3YQj+JIi3ckC7P5n/1w== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Aug 2026 18:34:27.3189 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1f3b2801-f6ac-46d2-d02b-08def7d72cc1 X-MS-Exchange-CrossTenant-Id: e5b49634-450b-4709-8abb-1e2b19b982b7 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=e5b49634-450b-4709-8abb-1e2b19b982b7;Ip=[198.47.21.194];Helo=[flwvzet200.ext.ti.com] X-MS-Exchange-CrossTenant-AuthSource: CH1PEPF0000AD79.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR10MB6708 X-Proofpoint-Spam-Info: AW1haW4tMjYwODExMDE1NiBTYWx0ZWRfX2ycrU4g6DRCy u+eXZFeKaHVUz9hr0tWeZrOsisOGGntsHIZfuH0YxJknqSZzKblS9A83RmvW+vRtdSvFXugKCnH zcjPqUTdrkpq6j3W4bSM7TI+5cuIUsk= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODExMDE1NiBTYWx0ZWRfX6yBmvHnB+QaU WmSFl7PJCfqzQfUg1SzsyYVCAwkQEXgfHB1KREN45SSgrIzjgVl10PKVSvv+mtjdEGYfkkv5puM q4nhuzul882QP6nbpTKQc2EzPtBnvI1mcaPwjc9hfQ9Z9xog5mG6F+8YTjaq1XEROHYzidMqhdB /RPLWLhmwLFjrO0nVr/PnwqLCmZJJsgE5qfsQ7bjp9KdODbLGMZzYsmhX6eVpKHRiYLf6yWlvmo eMFKEn/QQ2bIFeWt6meEAnY7R5+kYI9DsZA+RP6KSkvoJL777aRRIxQkPzIIQjxr9dGmMltgCyN Ko9G5BX1HCSvSfUVKA+OvnH2paUYzF1iQ+/J0NQqGJPXOtls2Lh7WVAMDe/70LxNlc4kK0zF2lX rkYERctRPqKXZsXyHSua0F1Or8P4YQNDUHZ2feGIKTaaMLab7jqkDDDMAsOLf2ABWOwD0tfXq9G Ry3pbzs+eb6su5RCGBQ== X-Proofpoint-GUID: HQnOAemRzHxjH-ALoijSrLHk15CzcNvQ X-Authority-Analysis: v=2.4 cv=cYziaHDM c=1 sm=1 tr=0 ts=6a7b6b3d cx=c_pps a=mGKQszq4vdWEHw2ByKFqMg==:117 a=iwqwCZQqcuTv3JOpYdM7/Q==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=IkcTkHD0fZMA:10 a=Sv0fKeRqtYgA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=jwouBfj2j3NM8CExmVVE:22 a=sozttTNsAAAA:8 a=MlhAJnQaR0iBW2fQ34UA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 X-Proofpoint-ORIG-GUID: HQnOAemRzHxjH-ALoijSrLHk15CzcNvQ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-11_04,2026-08-10_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 bulkscore=0 priorityscore=1501 spamscore=0 suspectscore=0 impostorscore=0 malwarescore=0 phishscore=0 clxscore=1015 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608110156 The Cadence QSPI controller supports a delay-line PHY for high-speed operation. Without calibration the PHY is unused and read capture relies on a fixed delay, limiting throughput at frequencies above the base operating speed. Add an execute_tuning callback that performs delay-line calibration using a known data pattern written to a dedicated flash region. The pattern is either read from a NOR partition identified by the DT property spi-phy-pattern-partition, or written to the NAND page cache before each calibration read. For DDR protocols (8D-8D-8D) a 2D sweep of (rx_delay, tx_delay) pairs is performed to find the widest passing region in the combined RX/TX space. Binary search locates the gap boundary between passing regions when two separate windows exist; the final operating point is placed at the centre of the larger region with a small temperature-dependent offset. For SDR protocols a 1D sweep of the RX delay is sufficient. Two windows at adjacent read_delay values are measured; the wider one's midpoint is selected. The tuning infrastructure is platform-specific: only am654-based OSPI controllers populate the execute_tuning hook. All other platform data entries return -EOPNOTSUPP and are unaffected. The calibration target is sourced from spi->post_config_max_speed_hz, populated by the SPI core from the spi-max-post-config-frequency-hz DT property. Tuning is skipped when post_config_max_speed_hz is zero. Signed-off-by: Santhosh Kumar K --- drivers/spi/spi-cadence-quadspi.c | 1769 ++++++++++++++++++++++++++++- 1 file changed, 1756 insertions(+), 13 deletions(-) diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-qu= adspi.c index 046fa5d69b0f..5651320426b1 100644 --- a/drivers/spi/spi-cadence-quadspi.c +++ b/drivers/spi/spi-cadence-quadspi.c @@ -6,6 +6,7 @@ // Copyright Intel Corporation (C) 2019-2020. All rights reserved. // Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com =20 +#include #include #include #include @@ -65,15 +66,27 @@ enum { =20 struct cqspi_st; =20 +struct phy_setting { + u8 rx; + u8 tx; + u8 read_delay; +}; + struct cqspi_flash_pdata { - struct cqspi_st *cqspi; - u32 clk_rate; - u32 read_delay; - u32 tshsl_ns; - u32 tsd2d_ns; - u32 tchsh_ns; - u32 tslch_ns; - u8 cs; + struct cqspi_st *cqspi; + u32 read_delay; + u32 tshsl_ns; + u32 tsd2d_ns; + u32 tchsh_ns; + u32 tslch_ns; + bool use_dqs; + bool use_tuned_phy; + u8 cs; + struct phy_setting phy_setting; + struct spi_mem_op phy_read_op; + struct spi_mem_op phy_write_op; + u32 phy_pattern_partition_offset; + bool phy_pattern_partition_valid; }; =20 static const struct clk_bulk_data cqspi_clks[CLK_QSPI_NUM] =3D { @@ -117,6 +130,8 @@ struct cqspi_st { bool is_jh7110; /* Flag for StarFive JH7110 SoC */ bool is_rzn1; /* Flag for Renesas RZ/N1 SoC */ bool disable_stig_mode; + bool phy_tuning_active; + u8 phy_saved_dummy; refcount_t refcount; refcount_t inflight_ops; =20 @@ -129,12 +144,15 @@ struct cqspi_driver_platdata { int (*indirect_read_dma)(struct cqspi_flash_pdata *f_pdata, u_char *rxbuf, loff_t from_addr, size_t n_rx); u32 (*get_dma_status)(struct cqspi_st *cqspi); + int (*execute_tuning)(struct spi_mem *mem, struct spi_mem_op *read_op, + struct spi_mem_op *write_op); }; =20 /* Operation timeout value */ #define CQSPI_TIMEOUT_MS 500 #define CQSPI_READ_TIMEOUT_MS 10 #define CQSPI_BUSYWAIT_TIMEOUT_US 500 +#define CQSPI_DLL_TIMEOUT_US 300 =20 /* Runtime_pm autosuspend delay */ #define CQSPI_AUTOSUSPEND_TIMEOUT 2000 @@ -148,12 +166,14 @@ struct cqspi_driver_platdata { /* Register map */ #define CQSPI_REG_CONFIG 0x00 #define CQSPI_REG_CONFIG_ENABLE_MASK BIT(0) +#define CQSPI_REG_CONFIG_PHY_EN BIT(3) #define CQSPI_REG_CONFIG_ENB_DIR_ACC_CTRL BIT(7) #define CQSPI_REG_CONFIG_DECODE_MASK BIT(9) #define CQSPI_REG_CONFIG_CHIPSELECT_LSB 10 #define CQSPI_REG_CONFIG_DMA_MASK BIT(15) #define CQSPI_REG_CONFIG_BAUD_LSB 19 #define CQSPI_REG_CONFIG_DTR_PROTO BIT(24) +#define CQSPI_REG_CONFIG_PHY_PIPELINE BIT(25) #define CQSPI_REG_CONFIG_DUAL_OPCODE BIT(30) #define CQSPI_REG_CONFIG_IDLE_LSB 31 #define CQSPI_REG_CONFIG_CHIPSELECT_MASK 0xF @@ -192,6 +212,7 @@ struct cqspi_driver_platdata { #define CQSPI_REG_READCAPTURE_BYPASS_LSB 0 #define CQSPI_REG_READCAPTURE_DELAY_LSB 1 #define CQSPI_REG_READCAPTURE_DELAY_MASK 0xF +#define CQSPI_REG_READCAPTURE_EDGE_LSB 5 #define CQSPI_REG_READCAPTURE_DQS_LSB 8 =20 #define CQSPI_REG_SIZE 0x14 @@ -273,6 +294,28 @@ struct cqspi_driver_platdata { #define CQSPI_REG_POLLING_STATUS 0xB0 #define CQSPI_REG_POLLING_STATUS_DUMMY_LSB 16 =20 +#define CQSPI_REG_PHY_CONFIG 0xB4 +#define CQSPI_REG_PHY_CONFIG_RX_DEL_LSB 0 +#define CQSPI_REG_PHY_CONFIG_RX_DEL_MASK 0x7F +#define CQSPI_REG_PHY_CONFIG_TX_DEL_LSB 16 +#define CQSPI_REG_PHY_CONFIG_TX_DEL_MASK 0x7F +#define CQSPI_REG_PHY_CONFIG_DLL_RESET BIT(30) +#define CQSPI_REG_PHY_CONFIG_RESYNC BIT(31) + +#define CQSPI_REG_PHY_DLL_MASTER 0xB8 +#define CQSPI_REG_PHY_DLL_MASTER_INIT_DELAY_LSB 0 +#define CQSPI_REG_PHY_DLL_MASTER_INIT_DELAY_MASK 0x7f +#define CQSPI_REG_PHY_DLL_MASTER_INIT_DELAY_VAL 16 +#define CQSPI_REG_PHY_DLL_MASTER_DLY_ELMTS_LEN 0x7 +#define CQSPI_REG_PHY_DLL_MASTER_DLY_ELMTS_LSB 20 +#define CQSPI_REG_PHY_DLL_MASTER_DLY_ELMTS_3 0x2 +#define CQSPI_REG_PHY_DLL_MASTER_BYPASS BIT(23) +#define CQSPI_REG_PHY_DLL_MASTER_CYCLE BIT(24) + +#define CQSPI_REG_DLL_OBS_LOW 0xBC +#define CQSPI_REG_DLL_OBS_LOW_DLL_LOCK BIT(0) +#define CQSPI_REG_DLL_OBS_LOW_LOOPBACK_LOCK BIT(15) + #define CQSPI_REG_OP_EXT_LOWER 0xE0 #define CQSPI_REG_OP_EXT_READ_LSB 24 #define CQSPI_REG_OP_EXT_WRITE_LSB 16 @@ -321,6 +364,50 @@ struct cqspi_driver_platdata { =20 #define CQSPI_REG_VERSAL_DMA_VAL 0x602 =20 +#define CQSPI_PHY_INIT_RD 1 +#define CQSPI_PHY_MAX_RD 4 +#define CQSPI_PHY_MAX_DELAY 127 +#define CQSPI_PHY_DDR_SEARCH_STEP 4 +#define CQSPI_PHY_TX_LOOKUP_LOW_START 28 +#define CQSPI_PHY_TX_LOOKUP_LOW_END 48 +#define CQSPI_PHY_TX_LOOKUP_HIGH_START 60 +#define CQSPI_PHY_TX_LOOKUP_HIGH_END 96 +#define CQSPI_PHY_RX_LOW_SEARCH_START 0 +#define CQSPI_PHY_RX_LOW_SEARCH_END 40 +#define CQSPI_PHY_RX_HIGH_SEARCH_START 24 +#define CQSPI_PHY_RX_HIGH_SEARCH_END 127 +#define CQSPI_PHY_TX_LOW_SEARCH_START 0 +#define CQSPI_PHY_TX_LOW_SEARCH_END 64 +#define CQSPI_PHY_TX_HIGH_SEARCH_START 78 +#define CQSPI_PHY_TX_HIGH_SEARCH_END 127 +#define CQSPI_PHY_SEARCH_OFFSET 8 + +#define CQSPI_PHY_DEFAULT_TEMP 45 +#define CQSPI_PHY_MIN_TEMP -45 +#define CQSPI_PHY_MAX_TEMP 130 +#define CQSPI_PHY_MID_TEMP (CQSPI_PHY_MIN_TEMP + \ + ((CQSPI_PHY_MAX_TEMP - \ + CQSPI_PHY_MIN_TEMP) / 2)) + +/* + * PHY tuning pattern for calibrating read data capture delay. This 128-by= te + * pattern provides sufficient bit transitions across all byte lanes to + * reliably detect timing windows at high frequencies. + */ +static const u8 phy_tuning_pattern[] __aligned(64) =3D { + 0xFE, 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0xFE, 0xFE, 0x01, + 0x01, 0x01, 0x01, 0x00, 0x00, 0xFE, 0xFE, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0x00, 0x00, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFE, + 0xFE, 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0xFE, 0x00, 0xFE, 0xFE, 0x01, + 0x01, 0x01, 0x01, 0xFE, 0x00, 0xFE, 0xFE, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFE, 0x00, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0x00, 0xFE, + 0xFE, 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0xFE, 0xFE, 0xFE, 0x01, + 0x01, 0x01, 0x01, 0x00, 0xFE, 0xFE, 0xFE, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0x00, 0xFE, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFE, 0xFE, + 0xFE, 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0xFE, 0xFE, 0xFE, 0xFE, 0x01, + 0x01, 0x01, 0x01, 0xFE, 0xFE, 0xFE, 0xFE, 0x01, +}; + static int cqspi_wait_for_bit(const struct cqspi_driver_platdata *ddata, void __iomem *reg, const u32 mask, bool clr, bool busywait) @@ -913,6 +1000,76 @@ static void cqspi_controller_enable(struct cqspi_st *= cqspi, bool enable) writel(reg, reg_base + CQSPI_REG_CONFIG); } =20 +static void cqspi_set_dll(void __iomem *reg_base, u8 rx_dll, u8 tx_dll) +{ + unsigned int reg; + + reg =3D readl(reg_base + CQSPI_REG_PHY_CONFIG); + reg &=3D ~((CQSPI_REG_PHY_CONFIG_RX_DEL_MASK + << CQSPI_REG_PHY_CONFIG_RX_DEL_LSB) | + (CQSPI_REG_PHY_CONFIG_TX_DEL_MASK + << CQSPI_REG_PHY_CONFIG_TX_DEL_LSB)); + reg |=3D ((rx_dll & CQSPI_REG_PHY_CONFIG_RX_DEL_MASK) + << CQSPI_REG_PHY_CONFIG_RX_DEL_LSB) | + ((tx_dll & CQSPI_REG_PHY_CONFIG_TX_DEL_MASK) + << CQSPI_REG_PHY_CONFIG_TX_DEL_LSB) | + CQSPI_REG_PHY_CONFIG_RESYNC; + writel(reg, reg_base + CQSPI_REG_PHY_CONFIG); +} + +static int cqspi_resync_dll(struct cqspi_st *cqspi) +{ + void __iomem *reg_base =3D cqspi->iobase; + unsigned int reg; + int ret; + + ret =3D cqspi_wait_idle(cqspi); + if (ret) + return ret; + + reg =3D readl(reg_base + CQSPI_REG_CONFIG); + reg &=3D ~CQSPI_REG_CONFIG_ENABLE_MASK; + writel(reg, reg_base + CQSPI_REG_CONFIG); + + reg =3D readl(reg_base + CQSPI_REG_PHY_CONFIG); + reg &=3D ~(CQSPI_REG_PHY_CONFIG_DLL_RESET | CQSPI_REG_PHY_CONFIG_RESYNC); + writel(reg, reg_base + CQSPI_REG_PHY_CONFIG); + + reg =3D readl(reg_base + CQSPI_REG_PHY_DLL_MASTER); + reg &=3D ~(CQSPI_REG_PHY_DLL_MASTER_INIT_DELAY_MASK + << CQSPI_REG_PHY_DLL_MASTER_INIT_DELAY_LSB); + reg |=3D (CQSPI_REG_PHY_DLL_MASTER_INIT_DELAY_VAL + << CQSPI_REG_PHY_DLL_MASTER_INIT_DELAY_LSB); + writel(reg, reg_base + CQSPI_REG_PHY_DLL_MASTER); + + reg =3D readl(reg_base + CQSPI_REG_PHY_CONFIG); + reg |=3D CQSPI_REG_PHY_CONFIG_DLL_RESET; + writel(reg, reg_base + CQSPI_REG_PHY_CONFIG); + + ret =3D readl_poll_timeout(reg_base + CQSPI_REG_DLL_OBS_LOW, reg, + (reg & CQSPI_REG_DLL_OBS_LOW_DLL_LOCK), 0, + CQSPI_DLL_TIMEOUT_US); + if (ret) + goto re_enable; + + ret =3D readl_poll_timeout(reg_base + CQSPI_REG_DLL_OBS_LOW, reg, + (reg & CQSPI_REG_DLL_OBS_LOW_LOOPBACK_LOCK), 0, + CQSPI_DLL_TIMEOUT_US); + if (ret) + goto re_enable; + + reg =3D readl(reg_base + CQSPI_REG_PHY_CONFIG); + reg |=3D CQSPI_REG_PHY_CONFIG_RESYNC; + writel(reg, reg_base + CQSPI_REG_PHY_CONFIG); + +re_enable: + reg =3D readl(reg_base + CQSPI_REG_CONFIG); + reg |=3D CQSPI_REG_CONFIG_ENABLE_MASK; + writel(reg, reg_base + CQSPI_REG_CONFIG); + + return ret; +} + static int cqspi_versal_indirect_read_dma(struct cqspi_flash_pdata *f_pdat= a, u_char *rxbuf, loff_t from_addr, size_t n_rx) @@ -1323,8 +1480,9 @@ static void cqspi_configure(struct cqspi_flash_pdata = *f_pdata, cqspi->sclk =3D sclk; cqspi_config_baudrate_div(cqspi); cqspi_delay(f_pdata); - cqspi_readdata_capture(cqspi, !cqspi->rclk_en, false, - f_pdata->read_delay); + if (!cqspi->phy_tuning_active) + cqspi_readdata_capture(cqspi, !cqspi->rclk_en, false, + f_pdata->read_delay); } =20 if (switch_cs || switch_ck) @@ -1559,10 +1717,1590 @@ static bool cqspi_supports_mem_op(struct spi_mem = *mem, return spi_mem_default_supports_op(mem, op); } =20 +static int cqspi_write_pattern_to_cache(struct cqspi_flash_pdata *f_pdata, + struct spi_mem *mem, + const struct spi_mem_op *write_op) +{ + struct spi_controller *ctlr =3D mem->spi->controller; + struct device *dev =3D &f_pdata->cqspi->pdev->dev; + struct spi_mem_op op =3D *write_op; + int ret; + + op.max_freq =3D mem->spi->max_speed_hz; + op.data.nbytes =3D sizeof(phy_tuning_pattern); + op.data.buf.out =3D phy_tuning_pattern; + + ret =3D ctlr->mem_ops->exec_op(mem, &op); + if (ret) { + dev_err(dev, "Failed to write PHY pattern to cache: %d\n", ret); + return ret; + } + dev_dbg(dev, "PHY pattern (%zu bytes) written to cache\n", + sizeof(phy_tuning_pattern)); + + return 0; +} + +static int cqspi_phy_check_pattern(struct cqspi_flash_pdata *f_pdata, + struct spi_mem *mem) +{ + struct spi_controller *ctlr =3D mem->spi->controller; + struct spi_mem_op op; + u8 *read_data; + int ret; + + read_data =3D kmalloc_array(ARRAY_SIZE(phy_tuning_pattern), + sizeof(phy_tuning_pattern[0]), GFP_KERNEL); + if (!read_data) + return -ENOMEM; + + op =3D f_pdata->phy_read_op; + op.data.buf.in =3D read_data; + op.data.nbytes =3D sizeof(phy_tuning_pattern); + + ret =3D ctlr->mem_ops->exec_op(mem, &op); + if (ret) + goto out; + + if (memcmp(read_data, phy_tuning_pattern, sizeof(phy_tuning_pattern))) + ret =3D -EAGAIN; + +out: + kfree(read_data); + return ret; +} + +static void cqspi_phy_set_dll_master(struct cqspi_st *cqspi) +{ + void __iomem *reg_base =3D cqspi->iobase; + unsigned int reg; + + reg =3D readl(reg_base + CQSPI_REG_PHY_DLL_MASTER); + reg &=3D ~((CQSPI_REG_PHY_DLL_MASTER_DLY_ELMTS_LEN + << CQSPI_REG_PHY_DLL_MASTER_DLY_ELMTS_LSB) | + CQSPI_REG_PHY_DLL_MASTER_BYPASS | + CQSPI_REG_PHY_DLL_MASTER_CYCLE); + reg |=3D ((CQSPI_REG_PHY_DLL_MASTER_DLY_ELMTS_3 + << CQSPI_REG_PHY_DLL_MASTER_DLY_ELMTS_LSB) | + CQSPI_REG_PHY_DLL_MASTER_CYCLE); + + writel(reg, reg_base + CQSPI_REG_PHY_DLL_MASTER); +} + +static void cqspi_phy_pre_config(struct cqspi_st *cqspi, + struct cqspi_flash_pdata *f_pdata, + const bool bypass) +{ + void __iomem *reg_base =3D cqspi->iobase; + unsigned int reg; + u8 dummy; + + cqspi->phy_tuning_active =3D true; + + cqspi_readdata_capture(cqspi, bypass, f_pdata->use_dqs, + f_pdata->phy_setting.read_delay); + + reg =3D readl(reg_base + CQSPI_REG_CONFIG); + reg &=3D ~(CQSPI_REG_CONFIG_PHY_EN | CQSPI_REG_CONFIG_PHY_PIPELINE); + reg |=3D CQSPI_REG_CONFIG_PHY_EN; + writel(reg, reg_base + CQSPI_REG_CONFIG); + + reg =3D readl(reg_base + CQSPI_REG_RD_INSTR); + dummy =3D FIELD_GET(CQSPI_REG_RD_INSTR_DUMMY_MASK + << CQSPI_REG_RD_INSTR_DUMMY_LSB, + reg); + cqspi->phy_saved_dummy =3D dummy; + if (dummy) + dummy--; + reg &=3D ~(CQSPI_REG_RD_INSTR_DUMMY_MASK << CQSPI_REG_RD_INSTR_DUMMY_LSB); + reg |=3D FIELD_PREP(CQSPI_REG_RD_INSTR_DUMMY_MASK + << CQSPI_REG_RD_INSTR_DUMMY_LSB, + dummy); + writel(reg, reg_base + CQSPI_REG_RD_INSTR); + + cqspi_phy_set_dll_master(cqspi); +} + +static void cqspi_phy_post_config(struct cqspi_st *cqspi, + const unsigned int delay) +{ + void __iomem *reg_base =3D cqspi->iobase; + unsigned int reg; + + cqspi->phy_tuning_active =3D false; + + /* + * Clear the EDGE bit set by cqspi_phy_apply_setting, then restore the + * READCAPTURE register to its non-PHY state (bypass, DQS, and delay). + */ + reg =3D readl(reg_base + CQSPI_REG_READCAPTURE); + reg &=3D ~BIT(CQSPI_REG_READCAPTURE_EDGE_LSB); + writel(reg, reg_base + CQSPI_REG_READCAPTURE); + + cqspi_readdata_capture(cqspi, !cqspi->rclk_en, false, delay); + + reg =3D readl(reg_base + CQSPI_REG_CONFIG); + reg &=3D ~(CQSPI_REG_CONFIG_PHY_EN | CQSPI_REG_CONFIG_PHY_PIPELINE); + writel(reg, reg_base + CQSPI_REG_CONFIG); + + /* Restore the original dummy cycle count saved by cqspi_phy_pre_config. = */ + reg =3D readl(reg_base + CQSPI_REG_RD_INSTR); + reg &=3D ~(CQSPI_REG_RD_INSTR_DUMMY_MASK << CQSPI_REG_RD_INSTR_DUMMY_LSB); + reg |=3D FIELD_PREP(CQSPI_REG_RD_INSTR_DUMMY_MASK + << CQSPI_REG_RD_INSTR_DUMMY_LSB, + cqspi->phy_saved_dummy); + writel(reg, reg_base + CQSPI_REG_RD_INSTR); +} + +static int cqspi_phy_apply_setting(struct cqspi_flash_pdata *f_pdata, + struct phy_setting *phy) +{ + struct cqspi_st *cqspi =3D f_pdata->cqspi; + unsigned int reg; + int ret; + + reg =3D readl(cqspi->iobase + CQSPI_REG_READCAPTURE); + reg |=3D BIT(CQSPI_REG_READCAPTURE_EDGE_LSB); + writel(reg, cqspi->iobase + CQSPI_REG_READCAPTURE); + + cqspi_set_dll(cqspi->iobase, phy->rx, phy->tx); + + ret =3D cqspi_resync_dll(cqspi); + if (ret) + return ret; + + f_pdata->phy_setting.rx =3D phy->rx; + f_pdata->phy_setting.tx =3D phy->tx; + f_pdata->phy_setting.read_delay =3D phy->read_delay; + + cqspi_readdata_capture(cqspi, !f_pdata->use_dqs, f_pdata->use_dqs, + phy->read_delay); + + return 0; +} + +static int cqspi_find_rx_low_ddr(struct cqspi_flash_pdata *f_pdata, + struct spi_mem *mem, struct phy_setting *phy) +{ + struct device *dev =3D &f_pdata->cqspi->pdev->dev; + int ret; + + do { + phy->rx =3D CQSPI_PHY_RX_LOW_SEARCH_START; + do { + ret =3D cqspi_phy_apply_setting(f_pdata, phy); + if (!ret) { + ret =3D cqspi_phy_check_pattern(f_pdata, mem); + if (!ret) + return 0; + } + + phy->rx +=3D CQSPI_PHY_DDR_SEARCH_STEP; + } while (phy->rx <=3D CQSPI_PHY_RX_LOW_SEARCH_END); + + phy->read_delay++; + } while (phy->read_delay <=3D CQSPI_PHY_MAX_RD); + + dev_dbg(dev, "Unable to find RX low\n"); + return -ENOENT; +} + +static int cqspi_find_rx_low_sdr(struct cqspi_flash_pdata *f_pdata, + struct spi_mem *mem, struct phy_setting *phy) +{ + struct device *dev =3D &f_pdata->cqspi->pdev->dev; + int ret; + + phy->rx =3D 0; + do { + ret =3D cqspi_phy_apply_setting(f_pdata, phy); + if (!ret) { + ret =3D cqspi_phy_check_pattern(f_pdata, mem); + if (!ret) + return 0; + } + phy->rx++; + } while (phy->rx <=3D CQSPI_PHY_MAX_DELAY); + + dev_dbg(dev, "Unable to find RX low\n"); + return -ENOENT; +} + +static int cqspi_find_rx_high_ddr(struct cqspi_flash_pdata *f_pdata, + struct spi_mem *mem, struct phy_setting *phy) +{ + struct device *dev =3D &f_pdata->cqspi->pdev->dev; + int ret; + + do { + phy->rx =3D CQSPI_PHY_RX_HIGH_SEARCH_END; + do { + ret =3D cqspi_phy_apply_setting(f_pdata, phy); + if (!ret) { + ret =3D cqspi_phy_check_pattern(f_pdata, mem); + if (!ret) + return 0; + } + + phy->rx -=3D CQSPI_PHY_DDR_SEARCH_STEP; + } while (phy->rx >=3D CQSPI_PHY_RX_HIGH_SEARCH_START); + + phy->read_delay--; + } while (phy->read_delay >=3D CQSPI_PHY_INIT_RD); + + dev_dbg(dev, "Unable to find RX high\n"); + return -ENOENT; +} + +static int cqspi_find_rx_high_sdr(struct cqspi_flash_pdata *f_pdata, + struct spi_mem *mem, struct phy_setting *phy, + u8 lowerbound) +{ + struct device *dev =3D &f_pdata->cqspi->pdev->dev; + int ret; + + phy->rx =3D CQSPI_PHY_MAX_DELAY; + do { + ret =3D cqspi_phy_apply_setting(f_pdata, phy); + if (!ret) { + ret =3D cqspi_phy_check_pattern(f_pdata, mem); + if (!ret) + return 0; + } + phy->rx--; + } while (phy->rx > lowerbound); + + dev_dbg(dev, "Unable to find RX high\n"); + return -ENOENT; +} + +static int cqspi_find_tx_low_ddr(struct cqspi_flash_pdata *f_pdata, + struct spi_mem *mem, struct phy_setting *phy) +{ + struct device *dev =3D &f_pdata->cqspi->pdev->dev; + int ret; + + do { + phy->tx =3D CQSPI_PHY_TX_LOW_SEARCH_START; + do { + ret =3D cqspi_phy_apply_setting(f_pdata, phy); + if (!ret) { + ret =3D cqspi_phy_check_pattern(f_pdata, mem); + if (!ret) + return 0; + } + + phy->tx +=3D CQSPI_PHY_DDR_SEARCH_STEP; + } while (phy->tx <=3D CQSPI_PHY_TX_LOW_SEARCH_END); + + phy->read_delay++; + } while (phy->read_delay <=3D CQSPI_PHY_MAX_RD); + + dev_dbg(dev, "Unable to find TX low\n"); + return -ENOENT; +} + +static int cqspi_find_tx_high_ddr(struct cqspi_flash_pdata *f_pdata, + struct spi_mem *mem, struct phy_setting *phy) +{ + struct device *dev =3D &f_pdata->cqspi->pdev->dev; + int ret; + + do { + phy->tx =3D CQSPI_PHY_TX_HIGH_SEARCH_END; + do { + ret =3D cqspi_phy_apply_setting(f_pdata, phy); + if (!ret) { + ret =3D cqspi_phy_check_pattern(f_pdata, mem); + if (!ret) + return 0; + } + + phy->tx -=3D CQSPI_PHY_DDR_SEARCH_STEP; + } while (phy->tx >=3D CQSPI_PHY_TX_HIGH_SEARCH_START); + + phy->read_delay--; + } while (phy->read_delay >=3D CQSPI_PHY_INIT_RD); + + dev_dbg(dev, "Unable to find TX high\n"); + return -ENOENT; +} + +static void cqspi_phy_find_gaplow_ddr(struct cqspi_flash_pdata *f_pdata, + struct spi_mem *mem, + struct phy_setting *bottomleft, + struct phy_setting *topright, + struct phy_setting *gaplow) +{ + struct phy_setting left, right, mid; + int ret; + + left =3D *bottomleft; + right =3D *topright; + + mid.tx =3D left.tx + ((right.tx - left.tx) / 2); + mid.rx =3D left.rx + ((right.rx - left.rx) / 2); + mid.read_delay =3D left.read_delay; + + do { + ret =3D cqspi_phy_apply_setting(f_pdata, &mid); + if (!ret) + ret =3D cqspi_phy_check_pattern(f_pdata, mem); + + if (ret) { + /* The pattern was not found. Go to the lower half. */ + right.tx =3D mid.tx; + right.rx =3D mid.rx; + + mid.tx =3D left.tx + ((mid.tx - left.tx) / 2); + mid.rx =3D left.rx + ((mid.rx - left.rx) / 2); + } else { + /* The pattern was found. Go to the upper half. */ + left.tx =3D mid.tx; + left.rx =3D mid.rx; + + mid.tx =3D mid.tx + ((right.tx - mid.tx) / 2); + mid.rx =3D mid.rx + ((right.rx - mid.rx) / 2); + } + + /* Break the loop if the window has closed. */ + } while ((right.tx - left.tx >=3D 2) && (right.rx - left.rx >=3D 2)); + + *gaplow =3D mid; +} + +static void cqspi_phy_find_gaphigh_ddr(struct cqspi_flash_pdata *f_pdata, + struct spi_mem *mem, + struct phy_setting *bottomleft, + struct phy_setting *topright, + struct phy_setting *gaphigh) +{ + struct phy_setting left, right, mid; + int ret; + + left =3D *bottomleft; + right =3D *topright; + + mid.tx =3D left.tx + ((right.tx - left.tx) / 2); + mid.rx =3D left.rx + ((right.rx - left.rx) / 2); + mid.read_delay =3D right.read_delay; + + do { + ret =3D cqspi_phy_apply_setting(f_pdata, &mid); + if (!ret) + ret =3D cqspi_phy_check_pattern(f_pdata, mem); + + if (ret) { + /* The pattern was not found. Go to the upper half. */ + left.tx =3D mid.tx; + left.rx =3D mid.rx; + + mid.tx =3D mid.tx + ((right.tx - mid.tx) / 2); + mid.rx =3D mid.rx + ((right.rx - mid.rx) / 2); + } else { + /* The pattern was found. Go to the lower half. */ + right.tx =3D mid.tx; + right.rx =3D mid.rx; + + mid.tx =3D left.tx + ((mid.tx - left.tx) / 2); + mid.rx =3D left.rx + ((mid.rx - left.rx) / 2); + } + + /* Break the loop if the window has closed. */ + } while ((right.tx - left.tx >=3D 2) && (right.rx - left.rx >=3D 2)); + + *gaphigh =3D mid; +} + +static int cqspi_get_temp(int *temp) +{ + /* TODO: read SoC thermal sensor; caller falls back to room temperature */ + return -EOPNOTSUPP; +} + +static inline void cqspi_phy_reset_setting(struct phy_setting *phy) +{ + *phy =3D (struct phy_setting){ .rx =3D 0, .tx =3D 127, .read_delay =3D 0 = }; +} + +static int cqspi_phy_tuning_ddr(struct cqspi_flash_pdata *f_pdata, + struct spi_mem *mem) +{ + struct cqspi_st *cqspi =3D f_pdata->cqspi; + struct device *dev =3D &cqspi->pdev->dev; + struct phy_setting rxlow, rxhigh, txlow, txhigh; + struct phy_setting srxlow, srxhigh; + struct phy_setting bottomleft, topright, searchpoint; + struct phy_setting gaplow, gaphigh; + struct phy_setting backuppoint, backupcornerpoint; + int ret, rx_window, temp; + bool primary =3D true, secondary =3D true; + + /* + * DDR tuning: 2D search across RX and TX delays for optimal timing. + * + * Algorithm: Find RX boundaries (rxlow/rxhigh) using TX window search, + * find TX boundaries (txlow/txhigh) at fixed RX, define valid region, + * locate gaps via binary search, select final point with temperature + * compensation. + * + * rx + * 127 ^ + * | topright + * | * + * | xxxxx ++++++++++++++++++++ + * | xxxxxx +++++++++++++++++++ + * | xxxxxxx ++++++++++++++++++ + * | xxxxxxxx +++++++++++++++++ + * | xxxxxxxxx ++++++++++++++++ + * | xxxxxxxxxx +++++++++++++++ + * | xxxxxxxxxxx ++++++++++++++ + * | xxxxxxxxxxxx +++++++++++++ + * | xxxxxxxxxxxxx ++++++++++++ + * | xxxxxxxxxxxxxx +++++++++++ + * | xxxxxxxxxxxxxxx ++++++++++ + * | xxxxxxxxxxxxxxxx +++++++++ + * | xxxxxxxxxxxxxxxxx ++++++++ + * | xxxxxxxxxxxxxxxxxx +++++++ + * | * + * | bottomleft + * -----------------------------------------> tx + * 0 127 + */ + + f_pdata->use_tuned_phy =3D true; + + /* Golden rxlow search: Find lower RX boundary using TX window sweep */ + + /* + * rx + * 127 ^ + * | xxxxx ++++++++++++++++++++ + * | xxxxxx +++++++++++++++++++ + * | xxxxxxx ++++++++++++++++++ + * | xxxxxxxx +++++++++++++++++ + * | xxxxxxxxx ++++++++++++++++ + * | xxxxxxxxxx +++++++++++++++ + * | xxxxxxxxxxx ++++++++++++++ + * | |xxxxx|xxxxx +++++++++++++ + * | |xxxxx|xxxxxx ++++++++++++ + * search | |xxxxx|xxxxxxx +++++++++++ + * rxlow --------->|xxxxx|xxxxxxxx ++++++++++ + * | |xxxxx|xxxxxxxxx +++++++++ + * | |xxxxx|xxxxxxxxxx ++++++++ + * | |xxxxx|xxxxxxxxxxx +++++++ + * | | | + * --------|-----|----------------------------> tx + * 0 | | 127 + * txlow txlow + * start end + * + * |----------------------------------------------------------| + * | Primary | Secondary | Final | + * | Search | Search | Point | + * |---------|-----------|------------------------------------| + * | Fail | Fail | Return Fail | + * |---------|-----------|------------------------------------| + * | Fail | Pass | Return Fail | + * |---------|-----------|------------------------------------| + * | Pass | Fail | Return Fail | + * |---------|-----------|------------------------------------| + * | Pass | Pass | rx =3D min(primary.rx, secondary.rx) | + * | | | tx =3D primary.tx | + * | | | read_delay =3D | + * | | | min(primary.read_delay, | + * | | | secondary.read_delay) | + * |----------------------------------------------------------| + */ + + /* Primary rxlow: Sweep TX window to find valid RX lower bound */ + + rxlow.tx =3D CQSPI_PHY_TX_LOOKUP_LOW_START; + do { + dev_dbg(dev, "Searching for Golden Primary rxlow on TX =3D %d\n", + rxlow.tx); + rxlow.read_delay =3D CQSPI_PHY_INIT_RD; + ret =3D cqspi_find_rx_low_ddr(f_pdata, mem, &rxlow); + rxlow.tx +=3D CQSPI_PHY_DDR_SEARCH_STEP; + } while (ret && rxlow.tx <=3D CQSPI_PHY_TX_LOOKUP_LOW_END); + if (ret) + goto out; + dev_dbg(dev, "Golden Primary rxlow: RX: %d TX: %d RD: %d\n", rxlow.rx, + rxlow.tx, rxlow.read_delay); + + /* Secondary rxlow: Verify at offset TX for robustness */ + + if (rxlow.tx <=3D (CQSPI_PHY_TX_LOOKUP_LOW_END - CQSPI_PHY_SEARCH_OFFSET)) + srxlow.tx =3D rxlow.tx + CQSPI_PHY_SEARCH_OFFSET; + else + srxlow.tx =3D CQSPI_PHY_TX_LOOKUP_LOW_END; + dev_dbg(dev, "Searching for Golden Secondary rxlow on TX =3D %d\n", + srxlow.tx); + srxlow.read_delay =3D CQSPI_PHY_INIT_RD; + ret =3D cqspi_find_rx_low_ddr(f_pdata, mem, &srxlow); + if (ret) + goto out; + dev_dbg(dev, "Golden Secondary rxlow: RX: %d TX: %d RD: %d\n", + srxlow.rx, srxlow.tx, srxlow.read_delay); + + rxlow.rx =3D min(rxlow.rx, srxlow.rx); + rxlow.read_delay =3D min(rxlow.read_delay, srxlow.read_delay); + dev_dbg(dev, "Golden Final rxlow: RX: %d TX: %d RD: %d\n", rxlow.rx, + rxlow.tx, rxlow.read_delay); + + /* Golden rxhigh search: Find upper RX boundary at fixed TX */ + + /* + * rx + * 127 ^ + * | |xxxx ++++++++++++++++++++ + * | |xxxxx +++++++++++++++++++ + * search | |xxxxxx ++++++++++++++++++ + * rxhigh --------->|xxxxxxx +++++++++++++++++ + * on fixed | |xxxxxxxx ++++++++++++++++ + * tx | |xxxxxxxxx +++++++++++++++ + * | |xxxxxxxxxx ++++++++++++++ + * | xxxxxxxxxxxx +++++++++++++ + * | xxxxxxxxxxxxx ++++++++++++ + * | xxxxxxxxxxxxxx +++++++++++ + * | xxxxxxxxxxxxxxx ++++++++++ + * | xxxxxxxxxxxxxxxx +++++++++ + * | xxxxxxxxxxxxxxxxx ++++++++ + * | xxxxxxxxxxxxxxxxxx +++++++ + * | + * -------------------------------------------> tx + * 0 127 + * + * |----------------------------------------------------------| + * | Primary | Secondary | Final | + * | Search | Search | Point | + * |---------|-----------|------------------------------------| + * | Fail | Fail | Return Fail | + * |---------|-----------|------------------------------------| + * | Fail | Pass | Choose Secondary | + * |---------|-----------|------------------------------------| + * | Pass | Fail | Choose Primary | + * |---------|-----------|------------------------------------| + * | Pass | Pass | if (secondary.rx > primary.rx) | + * | | | Choose Secondary | + * | | | else | + * | | | Choose Primary | + * |----------------------------------------------------------| + */ + + /* Primary rxhigh: Search at rxlow's TX, decrement from max read_delay */ + + rxhigh.tx =3D rxlow.tx; + dev_dbg(dev, "Searching for Golden Primary rxhigh on TX =3D %d\n", + rxhigh.tx); + rxhigh.read_delay =3D CQSPI_PHY_MAX_RD; + ret =3D cqspi_find_rx_high_ddr(f_pdata, mem, &rxhigh); + if (ret) + primary =3D false; + dev_dbg(dev, "Golden Primary rxhigh: RX: %d TX: %d RD: %d\n", rxhigh.rx, + rxhigh.tx, rxhigh.read_delay); + + /* Secondary rxhigh: Verify at offset TX */ + + if (rxhigh.tx <=3D + (CQSPI_PHY_TX_LOOKUP_LOW_END - CQSPI_PHY_SEARCH_OFFSET)) + srxhigh.tx =3D rxhigh.tx + CQSPI_PHY_SEARCH_OFFSET; + else + srxhigh.tx =3D CQSPI_PHY_TX_LOOKUP_LOW_END; + dev_dbg(dev, "Searching for Golden Secondary rxhigh on TX =3D %d\n", + srxhigh.tx); + srxhigh.read_delay =3D CQSPI_PHY_MAX_RD; + ret =3D cqspi_find_rx_high_ddr(f_pdata, mem, &srxhigh); + if (ret) + secondary =3D false; + dev_dbg(dev, "Golden Secondary rxhigh: RX: %d TX: %d RD: %d\n", + srxhigh.rx, srxhigh.tx, srxhigh.read_delay); + + if (!primary && !secondary) + goto out; + else if (!primary) + rxhigh =3D srxhigh; + else if (secondary && srxhigh.rx > rxhigh.rx) + rxhigh =3D srxhigh; + dev_dbg(dev, "Golden Final rxhigh: RX: %d TX: %d RD: %d\n", rxhigh.rx, + rxhigh.tx, rxhigh.read_delay); + + primary =3D true; + secondary =3D true; + + /* If rxlow/rxhigh at same read_delay, search backup at upper TX range */ + + if (rxlow.read_delay =3D=3D rxhigh.read_delay) { + dev_dbg(dev, "rxlow and rxhigh at the same read delay.\n"); + + /* Backup rxlow: Search at high TX window */ + + /* + * rx + * 127 ^ + * | xxxxx ++++++++++++++++++++ + * | xxxxxx +++++++++++++++++++ + * | xxxxxxx ++++++++++++++++++ + * | xxxxxxxx +++++++++++++++++ + * | xxxxxxxxx ++++++++++++++++ + * | xxxxxxxxxx +++++++++++++++ + * | xxxxxxxxxxx ++++++++++++++ + * | xxxxxxxxxxxx +++++++|++++| + * | xxxxxxxxxxxxx ++++++|++++| + * search | xxxxxxxxxxxxxx +++++|++++| + * rxlow --------------------------------->|++++| + * | xxxxxxxxxxxxxxxx +++|++++| + * | xxxxxxxxxxxxxxxxx ++|++++| + * | xxxxxxxxxxxxxxxxxx +|++++| + * | | | + * --------------------------------|----|-----> tx + * 0 | | 127 + * txhigh txhigh + * start end + * + * |-----------------------------------------------------| + * | Primary | Secondary | Final | + * | Search | Search | Point | + * |---------|-----------|-------------------------------| + * | Fail | Fail | Return Fail | + * |---------|-----------|-------------------------------| + * | Fail | Pass | Return Fail | + * |---------|-----------|-------------------------------| + * | Pass | Fail | Return Fail | + * |---------|-----------|-------------------------------| + * | Pass | Pass | rx =3D | + * | | | min(primary.rx, secondary.rx)| + * | | | tx =3D primary.tx | + * | | | read_delay =3D | + * | | | min(primary.read_delay, | + * | | | secondary.read_delay) | + * |-----------------------------------------------------| + */ + + /* Primary backup: Decrement TX from high window end */ + + backuppoint.tx =3D CQSPI_PHY_TX_LOOKUP_HIGH_END; + do { + dev_dbg(dev, + "Searching for Backup Primary rxlow on TX =3D %d\n", + backuppoint.tx); + backuppoint.read_delay =3D CQSPI_PHY_INIT_RD; + ret =3D cqspi_find_rx_low_ddr(f_pdata, mem, &backuppoint); + backuppoint.tx -=3D CQSPI_PHY_DDR_SEARCH_STEP; + } while (ret && + backuppoint.tx >=3D CQSPI_PHY_TX_LOOKUP_HIGH_START); + if (ret) + goto out; + dev_dbg(dev, "Backup Primary rxlow: RX: %d TX: %d RD: %d\n", + backuppoint.rx, backuppoint.tx, backuppoint.read_delay); + + /* Secondary backup: Verify at offset TX */ + + if (backuppoint.tx >=3D + (CQSPI_PHY_TX_LOOKUP_HIGH_START + CQSPI_PHY_SEARCH_OFFSET)) + srxlow.tx =3D backuppoint.tx - CQSPI_PHY_SEARCH_OFFSET; + else + srxlow.tx =3D CQSPI_PHY_TX_LOOKUP_HIGH_START; + dev_dbg(dev, + "Searching for Backup Secondary rxlow on TX =3D %d\n", + srxlow.tx); + srxlow.read_delay =3D CQSPI_PHY_INIT_RD; + ret =3D cqspi_find_rx_low_ddr(f_pdata, mem, &srxlow); + if (ret) + goto out; + dev_dbg(dev, "Backup Secondary rxlow: RX: %d TX: %d RD: %d\n", + srxlow.rx, srxlow.tx, srxlow.read_delay); + + backuppoint.rx =3D min(backuppoint.rx, srxlow.rx); + backuppoint.read_delay =3D + min(backuppoint.read_delay, srxlow.read_delay); + dev_dbg(dev, "Backup Final rxlow: RX: %d TX: %d RD: %d\n", + backuppoint.rx, backuppoint.tx, backuppoint.read_delay); + + if (backuppoint.rx < rxlow.rx) { + rxlow =3D backuppoint; + dev_dbg(dev, "Updating rxlow to the one at TX =3D %d\n", + backuppoint.tx); + } + dev_dbg(dev, "Final rxlow: RX: %d TX: %d RD: %d\n", rxlow.rx, + rxlow.tx, rxlow.read_delay); + + /* Backup rxhigh: Search at fixed backup TX */ + + /* + * rx + * 127 ^ + * | xxxxx +++++++++++++++++++| + * | xxxxxx ++++++++++++++++++| + * search | xxxxxxx +++++++++++++++++| + * rxhigh -------------------------------------->| + * on fixed | xxxxxxxxx +++++++++++++++| + * tx | xxxxxxxxxx ++++++++++++++| + * | xxxxxxxxxxx +++++++++++++| + * | xxxxxxxxxxxx +++++++++++++ + * | xxxxxxxxxxxxx ++++++++++++ + * | xxxxxxxxxxxxxx +++++++++++ + * | xxxxxxxxxxxxxxx ++++++++++ + * | xxxxxxxxxxxxxxxx +++++++++ + * | xxxxxxxxxxxxxxxxx ++++++++ + * | xxxxxxxxxxxxxxxxxx +++++++ + * | + * -------------------------------------------> tx + * 0 127 + * + * |-----------------------------------------------------| + * | Primary | Secondary | Final | + * | Search | Search | Point | + * |---------|-----------|-------------------------------| + * | Fail | Fail | Return Fail | + * |---------|-----------|-------------------------------| + * | Fail | Pass | Choose Secondary | + * |---------|-----------|-------------------------------| + * | Pass | Fail | Choose Primary | + * |---------|-----------|-------------------------------| + * | Pass | Pass | if (secondary.rx > primary.rx)| + * | | | Choose Secondary | + * | | | else | + * | | | Choose Primary | + * |-----------------------------------------------------| + */ + + /* Primary backup rxhigh: Use backup TX, decrement from max read_delay */ + + dev_dbg(dev, "Searching for Backup Primary rxhigh on TX =3D %d\n", + backuppoint.tx); + backuppoint.read_delay =3D CQSPI_PHY_MAX_RD; + ret =3D cqspi_find_rx_high_ddr(f_pdata, mem, &backuppoint); + if (ret) + primary =3D false; + dev_dbg(dev, "Backup Primary rxhigh: RX: %d TX: %d RD: %d\n", + backuppoint.rx, backuppoint.tx, backuppoint.read_delay); + + /* Secondary backup rxhigh: Verify at offset TX */ + + if (backuppoint.tx >=3D + (CQSPI_PHY_TX_LOOKUP_HIGH_START + CQSPI_PHY_SEARCH_OFFSET)) + srxhigh.tx =3D backuppoint.tx - CQSPI_PHY_SEARCH_OFFSET; + else + srxhigh.tx =3D CQSPI_PHY_TX_LOOKUP_HIGH_START; + dev_dbg(dev, + "Searching for Backup Secondary rxhigh on TX =3D %d\n", + srxhigh.tx); + srxhigh.read_delay =3D CQSPI_PHY_MAX_RD; + ret =3D cqspi_find_rx_high_ddr(f_pdata, mem, &srxhigh); + if (ret) + secondary =3D false; + dev_dbg(dev, "Backup Secondary rxhigh: RX: %d TX: %d RD: %d\n", + srxhigh.rx, srxhigh.tx, srxhigh.read_delay); + + if (!primary && !secondary) + goto out; + else if (!primary) + backuppoint =3D srxhigh; + else if (secondary && srxhigh.rx > backuppoint.rx) + backuppoint =3D srxhigh; + dev_dbg(dev, "Backup Final rxhigh: RX: %d TX: %d RD: %d\n", + backuppoint.rx, backuppoint.tx, backuppoint.read_delay); + + if (backuppoint.rx > rxhigh.rx) { + rxhigh =3D backuppoint; + dev_dbg(dev, "Updating rxhigh to the one at TX =3D %d\n", + backuppoint.tx); + } + dev_dbg(dev, "Final rxhigh: RX: %d TX: %d RD: %d\n", rxhigh.rx, + rxhigh.tx, rxhigh.read_delay); + } + + /* Golden txlow: Fix RX at 1/4 of RX window, search TX lower bound */ + + /* + * rx + * 127 ^ + * | + * rxhigh --------->xxxxx ++++++++++++++++++++ + * | xxxxxx +++++++++++++++++++ + * | xxxxxxx ++++++++++++++++++ + * | xxxxxxxx +++++++++++++++++ + * | xxxxxxxxx ++++++++++++++++ + * | xxxxxxxxxx +++++++++++++++ + * | xxxxxxxxxxx ++++++++++++++ + * | xxxxxxxxxxxx +++++++++++++ + * fix rx | xxxxxxxxxxxxx ++++++++++++ + * 1/4 b/w ---------><------->xxxxx +++++++++++ + * rxlow and | xxxx|xxxxxxxxxx ++++++++++ + * rxhigh | xxxx|xxxxxxxxxxx +++++++++ + * | xxxx|xxxxxxxxxxxx ++++++++ + * rxlow --------->xxxx|xxxxxxxxxxxxx +++++++ + * | | + * ------------|------------------------------> tx + * 0 | 127 + * search + * txlow + */ + + rx_window =3D rxhigh.rx - rxlow.rx; + txlow.rx =3D rxlow.rx + (rx_window / 4); + dev_dbg(dev, "Searching for Golden txlow on RX =3D %d\n", txlow.rx); + txlow.read_delay =3D CQSPI_PHY_INIT_RD; + ret =3D cqspi_find_tx_low_ddr(f_pdata, mem, &txlow); + if (ret) + goto out; + dev_dbg(dev, "Golden txlow: RX: %d TX: %d RD: %d\n", txlow.rx, txlow.tx, + txlow.read_delay); + + /* Golden txhigh: Same RX as txlow, decrement from max read_delay */ + + /* + * rx + * 127 ^ + * | + * rxhigh --------->xxxxx ++++++++++++++++++++ + * | xxxxxx +++++++++++++++++++ + * | xxxxxxx ++++++++++++++++++ + * | xxxxxxxx +++++++++++++++++ + * | xxxxxxxxx ++++++++++++++++ + * | xxxxxxxxxx +++++++++++++++ + * | xxxxxxxxxxx ++++++++++++++ + * | xxxxxxxxxxxx +++++++++++++ + * fix rx | xxxxxxxxxxxxx ++++++++++++ + * 1/4 b/w --------------------------------><-----> + * rxlow and | xxxxxxxxxxxxxxx ++++++|+++ + * rxhigh | xxxxxxxxxxxxxxxx +++++|+++ + * | xxxxxxxxxxxxxxxxx ++++|+++ + * rxlow --------->xxxxxxxxxxxxxxxxxx +++|+++ + * | | + * ----------------------------------|--------> tx + * 0 | 127 + * search + * txhigh + */ + + txhigh.rx =3D txlow.rx; + dev_dbg(dev, "Searching for Golden txhigh on RX =3D %d\n", txhigh.rx); + txhigh.read_delay =3D CQSPI_PHY_MAX_RD; + ret =3D cqspi_find_tx_high_ddr(f_pdata, mem, &txhigh); + if (ret) + goto out; + dev_dbg(dev, "Golden txhigh: RX: %d TX: %d RD: %d\n", txhigh.rx, + txhigh.tx, txhigh.read_delay); + + /* If txlow/txhigh at same read_delay, search backup at 3/4 RX window */ + + if (txlow.read_delay =3D=3D txhigh.read_delay) { + /* Backup txlow: Fix RX at 3/4 of RX window */ + + /* + * rx + * 127 ^ + * | + * rxhigh --------->xxxxx ++++++++++++++++++++ + * | xxxxxx +++++++++++++++++++ + * fix rx | xxxxxxx ++++++++++++++++++ + * 3/4 b/w ---------><----->x +++++++++++++++++ + * rxlow and | xxxx|xxxx ++++++++++++++++ + * rxhigh | xxxx|xxxxx +++++++++++++++ + * | xxxx|xxxxxx ++++++++++++++ + * | xxxx|xxxxxxx +++++++++++++ + * | xxxx|xxxxxxxx ++++++++++++ + * | xxxx|xxxxxxxxx +++++++++++ + * | xxxx|xxxxxxxxxx ++++++++++ + * | xxxx|xxxxxxxxxxx +++++++++ + * | xxxx|xxxxxxxxxxxx ++++++++ + * rxlow --------->xxxx|xxxxxxxxxxxxx +++++++ + * | | + * ------------|------------------------------> tx + * 0 | 127 + * search + * txlow + */ + + dev_dbg(dev, "txlow and txhigh at the same read delay.\n"); + backuppoint.rx =3D rxlow.rx + ((rx_window * 3) / 4); + dev_dbg(dev, "Searching for Backup txlow on RX =3D %d\n", + backuppoint.rx); + backuppoint.read_delay =3D CQSPI_PHY_INIT_RD; + ret =3D cqspi_find_tx_low_ddr(f_pdata, mem, &backuppoint); + if (ret) + goto out; + dev_dbg(dev, "Backup txlow: RX: %d TX: %d RD: %d\n", + backuppoint.rx, backuppoint.tx, backuppoint.read_delay); + + if (backuppoint.tx < txlow.tx) { + txlow =3D backuppoint; + dev_dbg(dev, "Updating txlow with the one at RX =3D %d\n", + backuppoint.rx); + } + dev_dbg(dev, "Final txlow: RX: %d TX: %d RD: %d\n", txlow.rx, + txlow.tx, txlow.read_delay); + + /* Backup txhigh: Same RX as backup txlow, decrement from max */ + + /* + * rx + * 127 ^ + * | + * rxhigh --------->xxxxx ++++++++++++++++++++ + * | xxxxxx +++++++++++++++++++ + * fix rx | xxxxxxx ++++++++++++++++++ + * 3/4 b/w ------------------------------><-------> + * rxlow and | xxxxxxxxx +++++++++++|++++ + * rxhigh | xxxxxxxxxx ++++++++++|++++ + * | xxxxxxxxxxx +++++++++|++++ + * | xxxxxxxxxxxx ++++++++|++++ + * | xxxxxxxxxxxxx +++++++|++++ + * | xxxxxxxxxxxxxx ++++++|++++ + * | xxxxxxxxxxxxxxx +++++|++++ + * | xxxxxxxxxxxxxxxx ++++|++++ + * | xxxxxxxxxxxxxxxxx +++|++++ + * rxlow --------->xxxxxxxxxxxxxxxxxx ++|++++ + * | | + * ---------------------------------|---------> tx + * 0 | 127 + * search + * txhigh + */ + + dev_dbg(dev, "Searching for Backup txhigh on RX =3D %d\n", + backuppoint.rx); + backuppoint.read_delay =3D CQSPI_PHY_MAX_RD; + ret =3D cqspi_find_tx_high_ddr(f_pdata, mem, &backuppoint); + if (ret) + goto out; + dev_dbg(dev, "Backup txhigh: RX: %d TX: %d RD: %d\n", + backuppoint.rx, backuppoint.tx, backuppoint.read_delay); + + if (backuppoint.tx > txhigh.tx) { + txhigh =3D backuppoint; + dev_dbg(dev, + "Updating txhigh with the one at RX =3D %d\n", + backuppoint.rx); + } + dev_dbg(dev, "Final txhigh: RX: %d TX: %d RD: %d\n", txhigh.rx, + txhigh.tx, txhigh.read_delay); + } + + /* Corner points: Define and verify bottomleft and topright boundaries */ + + /* + * rx + * 127 ^ + * | topright + * | * + * rxhigh -----------xxxxx ++++++++++++++++++++ + * | xxxxxx +++++++++++++++++++ + * | xxxxxxx ++++++++++++++++++ + * | xxxxxxxx +++++++++++++++++ + * | xxxxxxxxx ++++++++++++++++ + * | xxxxxxxxxx +++++++++++++++ + * | xxxxxxxxxxx ++++++++++++++ + * | xxxxxxxxxxxx +++++++++++++ + * | xxxxxxxxxxxxx ++++++++++++ + * | xxxxxxxxxxxxxx +++++++++++ + * | xxxxxxxxxxxxxxx ++++++++++ + * | xxxxxxxxxxxxxxxx +++++++++ + * | xxxxxxxxxxxxxxxxx ++++++++ + * rxlow -----------xxxxxxxxxxxxxxxxxx +++++++ + * | * | + * | bottom|left | + * --------|----------------------------|---> tx + * 0 | | 127 + * | | + * txlow txhigh + * + * Verification: Test point 4 taps inside each corner, adjust + * read_delay =C2=B11 if needed to ensure valid corners for gap search. + */ + + bottomleft.tx =3D txlow.tx; + bottomleft.rx =3D rxlow.rx; + if (txlow.read_delay <=3D rxlow.read_delay) + bottomleft.read_delay =3D txlow.read_delay; + else + bottomleft.read_delay =3D rxlow.read_delay; + + /* Verify bottomleft: Test 4 taps inside, adjust read_delay if needed */ + backupcornerpoint =3D bottomleft; + backupcornerpoint.tx +=3D 4; + backupcornerpoint.rx +=3D 4; + ret =3D cqspi_phy_apply_setting(f_pdata, &backupcornerpoint); + if (!ret) + ret =3D cqspi_phy_check_pattern(f_pdata, mem); + + if (ret) { + backupcornerpoint.read_delay--; + ret =3D cqspi_phy_apply_setting(f_pdata, &backupcornerpoint); + if (!ret) + ret =3D cqspi_phy_check_pattern(f_pdata, mem); + } + + if (ret) + goto out; + + bottomleft.read_delay =3D backupcornerpoint.read_delay; + + topright.tx =3D txhigh.tx; + topright.rx =3D rxhigh.rx; + if (txhigh.read_delay >=3D rxhigh.read_delay) + topright.read_delay =3D txhigh.read_delay; + else + topright.read_delay =3D rxhigh.read_delay; + + /* Verify topright: Test 4 taps inside, adjust read_delay if needed */ + backupcornerpoint =3D topright; + backupcornerpoint.tx -=3D 4; + backupcornerpoint.rx -=3D 4; + ret =3D cqspi_phy_apply_setting(f_pdata, &backupcornerpoint); + if (!ret) + ret =3D cqspi_phy_check_pattern(f_pdata, mem); + + if (ret) { + backupcornerpoint.read_delay++; + ret =3D cqspi_phy_apply_setting(f_pdata, &backupcornerpoint); + if (!ret) + ret =3D cqspi_phy_check_pattern(f_pdata, mem); + } + + if (ret) + goto out; + + topright.read_delay =3D backupcornerpoint.read_delay; + + dev_dbg(dev, "topright: RX: %d TX: %d RD: %d\n", topright.rx, + topright.tx, topright.read_delay); + dev_dbg(dev, "bottomleft: RX: %d TX: %d RD: %d\n", bottomleft.rx, + bottomleft.tx, bottomleft.read_delay); + cqspi_phy_find_gaplow_ddr(f_pdata, mem, &bottomleft, &topright, &gaplow); + dev_dbg(dev, "gaplow: RX: %d TX: %d RD: %d\n", gaplow.rx, gaplow.tx, + gaplow.read_delay); + + /* Final point selection: Handle single vs dual passing regions */ + + if (bottomleft.read_delay =3D=3D topright.read_delay) { + /* + * Single region: Use midpoint with temperature compensation. + * Gaplow approximates upper boundary of valid region. + * + * rx + * 127 ^ + * | gaplow (approx. topright) + * | | + * rxhigh -----------xxxxxxx| failing + * | xxxxxxx| region + * | xxxxxxx| <---------------> + * | xxxxxxx| +++++++++++++++++ + * | xxxxxxxxx ++++++++++++++++ + * | xxxxxxxxxx +++++++++++++++ + * | xxxxxxxxxxx ++++++++++++++ + * | xxxxxxxxxxxx +++++++++++++ + * | xxxxxxxxxxxxx ++++++++++++ + * | xxxxxxxxxxxxxx +++++++++++ + * | xxxxxxxxxxxxxxx ++++++++++ + * | xxxxxxxxxxxxxxxx +++++++++ + * | xxxxxxxxxxxxxxxxx ++++++++ + * rxlow -----------xxxxxxxxxxxxxxxxxx +++++++ + * | * | + * | bottom|left | + * --------|----------------------------|---> tx + * 0 | | 127 + * | | + * txlow txhigh + * (same read_delay) + * + * Temperature compensation: Valid region shifts with temp. + * Offset =3D region_size / (330 / (temp - 42=C2=B0C)) + * Factor 330 is empirically determined for this hardware. + */ + + dev_dbg(dev, + "bottomleft and topright at the same read delay.\n"); + + topright =3D gaplow; + searchpoint.read_delay =3D bottomleft.read_delay; + searchpoint.tx =3D + bottomleft.tx + ((topright.tx - bottomleft.tx) / 2); + searchpoint.rx =3D + bottomleft.rx + ((topright.rx - bottomleft.rx) / 2); + + ret =3D cqspi_get_temp(&temp); + if (ret) { + /* Assume room temperature if sensor unavailable */ + dev_dbg(dev, + "Unable to get temperature. Assuming room temperature\n"); + temp =3D CQSPI_PHY_DEFAULT_TEMP; + } + + if (temp < CQSPI_PHY_MIN_TEMP || temp > CQSPI_PHY_MAX_TEMP) { + dev_err(dev, + "Temperature outside operating range: %dC\n", + temp); + ret =3D -EINVAL; + goto out; + } + + if (temp =3D=3D CQSPI_PHY_MID_TEMP) + temp++; /* Avoid divide-by-zero */ + dev_dbg(dev, "Temperature: %dC\n", temp); + + /* + * Apply temperature offset: positive at high temp, negative at low. + * Compute the divisor once and apply to both TX and RX. Use int + * arithmetic throughout to avoid u8 wrapping on negative offsets. + */ + temp =3D 330 / (temp - CQSPI_PHY_MID_TEMP); + searchpoint.tx =3D clamp((int)searchpoint.tx + + (topright.tx - bottomleft.tx) / temp, + 0, CQSPI_PHY_MAX_DELAY); + searchpoint.rx =3D clamp((int)searchpoint.rx + + (topright.rx - bottomleft.rx) / temp, + 0, CQSPI_PHY_MAX_DELAY); + } else { + /* + * Dual regions: Gap separates two valid regions, choose larger. + * + * rx + * 127 ^ + * | topright + * | * + * rxhigh -----------xxxxx +++++++++++++++++++| + * | xxxxxx ++++++++| + * | xxxxxxx +++++++++++++++++| + * | xxxxxxxx ++++++++++++++++| + * | xxxxxxxxx +++++++++++++++| + * | xxxxxxxxxx ++++++++++++++| + * | failing | + * | region | + * | xxxxxxxxxxxxx +++++++++++| + * | xxxxxxxxxxxxxx ++++++++++| + * | xxxxxxxxxxxxxxx +++++++++| + * | xxxxxxxxxxxxxxxx ++++++++| + * | xxxxxxxxx +++++++| + * rxlow -----------xxxxxxxxxxxxxxxxxx ++++++| + * | * | + * | bottom|left | + * --------|----------------------------|---> tx + * 0 | | 127 + * | | + * txlow txhigh + * + * Strategy: Compare Manhattan distances from gap boundaries to + * corners. Choose corner furthest from gap (larger region). + * Apply 16-tap margin inward, scale RX proportionally. + */ + + cqspi_phy_find_gaphigh_ddr(f_pdata, mem, &bottomleft, + &topright, &gaphigh); + dev_dbg(dev, "gaphigh: RX: %d TX: %d RD: %d\n", gaphigh.rx, + gaphigh.tx, gaphigh.read_delay); + + if (topright.tx =3D=3D bottomleft.tx) { + dev_err(dev, "zero TX span in dual-region: cannot compute search point\= n"); + ret =3D -EINVAL; + goto out; + } + + /* Compare Manhattan distances: choose corner furthest from gap */ + if ((abs(gaplow.tx - bottomleft.tx) + + abs(gaplow.rx - bottomleft.rx)) < + (abs(gaphigh.tx - topright.tx) + + abs(gaphigh.rx - topright.rx))) { + /* Topright further: Use Region 2, 16 taps inward */ + searchpoint =3D topright; + searchpoint.tx =3D clamp((int)topright.tx - 16, + 0, CQSPI_PHY_MAX_DELAY); + searchpoint.rx =3D clamp((int)topright.rx - + (16 * (topright.rx - bottomleft.rx)) / + (topright.tx - bottomleft.tx), + 0, CQSPI_PHY_MAX_DELAY); + } else { + /* Bottomleft further: Use Region 1, 16 taps inward */ + searchpoint =3D bottomleft; + searchpoint.tx =3D clamp((int)bottomleft.tx + 16, + 0, CQSPI_PHY_MAX_DELAY); + searchpoint.rx =3D clamp((int)bottomleft.rx + + (16 * (topright.rx - bottomleft.rx)) / + (topright.tx - bottomleft.tx), + 0, CQSPI_PHY_MAX_DELAY); + } + } + + /* Apply and verify final tuning point */ + dev_dbg(dev, "Final tuning point: RX: %d TX: %d RD: %d\n", + searchpoint.rx, searchpoint.tx, searchpoint.read_delay); + ret =3D cqspi_phy_apply_setting(f_pdata, &searchpoint); + if (!ret) + ret =3D cqspi_phy_check_pattern(f_pdata, mem); + + if (ret) { + dev_err(dev, + "Failed to find pattern at final calibration point\n"); + ret =3D -EINVAL; + goto out; + } + + f_pdata->phy_setting.read_delay =3D searchpoint.read_delay; + f_pdata->phy_setting.rx =3D searchpoint.rx; + f_pdata->phy_setting.tx =3D searchpoint.tx; +out: + if (ret) + f_pdata->use_tuned_phy =3D false; + + return ret; +} + +static int cqspi_phy_tuning_sdr(struct cqspi_flash_pdata *f_pdata, + struct spi_mem *mem) +{ + struct cqspi_st *cqspi =3D f_pdata->cqspi; + struct device *dev =3D &cqspi->pdev->dev; + struct phy_setting rxlow, rxhigh, first, second, final; + u8 window1 =3D 0; + u8 window2 =3D 0; + int ret; + + /* + * SDR tuning: 1D search for optimal RX delay (TX less critical). + * Find two consecutive windows, choose larger, use midpoint. + * + * rx + * 127 ^ + * | |-----window at----------| + * | |-----read_delay =3D n+1---| + * | |xxxxxxxxxxxxxxxxxxxxxxxx| + * | |xxxxxxxxxxxxxxxxxxxxxxxx| + * | |xxxxxxxxxxxxxxxxxxxxxxxx| + * | |xxxxxxxxxxxxxxxxxxxxxxxx| + * | |xxxxxxxxxxxxxxxxxxxxxxxx| + * | rxlow(n+1) midpoint rxhigh(n+1) + * | + * | |---window at--------| + * | |---read_delay =3D n---| + * | |xxxxxxxxxxxxxxxxxxxx| + * | |xxxxxxxxxxxxxxxxxxxx| + * | |xxxxxxxxxxxxxxxxxxxx| + * | |xxxxxxxxxxxxxxxxxxxx| + * | |xxxxxxxxxxxxxxxxxxxx| + * | rxlow(n) midpoint rxhigh(n) + * | + * -----------------------------------------> tx + * 0 127 + * read_delay=3Dn read_delay=3Dn+1 + */ + + f_pdata->use_tuned_phy =3D true; + cqspi_phy_reset_setting(&rxlow); + cqspi_phy_reset_setting(&rxhigh); + cqspi_phy_reset_setting(&first); + + /* First window: Find rxlow by incrementing read_delay from 0 */ + + /* + * rx + * 127 ^ + * | |xxxxxxxxxxxxxxxxxxxx| + * search | |xxxxxxxxxxxxxxxxxxxx| + * rxlow | |xxxxxxxxxxxxxxxxxxxx| + * increasing | |xxxxxxxxxxxxxxxxxxxx| + * --------->|xxxxxxxxxxxxxxxxxxxx| + * read_delay | |xxxxxxxxxxxxxxxxxxx| + * until found | |xxxxxxxxxxxxxxxxxxx| + * | rxlow + * -----------------------------------------> tx + * 0 tx fixed at 127 + */ + + do { + ret =3D cqspi_find_rx_low_sdr(f_pdata, mem, &rxlow); + + if (ret) + rxlow.read_delay++; + } while (ret && rxlow.read_delay <=3D CQSPI_PHY_MAX_RD); + + if (ret) + goto out; + + /* Find rxhigh: Decrement from RX=3D127 at same read_delay */ + + /* + * rx + * 127 ^ search rxhigh + * | (decrement from + * | 127 until found) + * | | + * | | + * | v + * | |------------------------| + * | |xxxxxxxxxxxxxxxxxxxxxxxx| + * | |xxxxxxxxxxxxxxxxxxxxxxxx| + * | |xxxxxxxxxxxxxxxxxxxxxxxx| + * | |xxxxxxxxxxxxxxxxxxxxxxxx| + * | |xxxxxxxxxxxxxxxxxxxxxxxx| + * | rxlow rxhigh + * -----------------------------------------> tx + * 0 tx fixed at 127 + */ + + rxhigh.read_delay =3D rxlow.read_delay; + ret =3D cqspi_find_rx_high_sdr(f_pdata, mem, &rxhigh, rxlow.rx); + if (ret) + goto out; + + /* Calculate first window midpoint for max margin */ + + /* + * rx + * 127 ^ + * | |--------window1---------| + * | |xxxxxxxxxxxxxxxxxxxxxxxx| + * | |xxxxxxxxxxxxxxxxxxxxxxxx| + * | |xxxxxxxxxxx * xxxxxxxxxx| + * | |xxxxxxxxxxxxxxxxxxxxxxxx| + * | |xxxxxxxxxxxxxxxxxxxxxxxx| + * | rxlow ^ rxhigh + * ----------------------|------------------> tx + * 0 | tx fixed at 127 + * window1/2 + */ + + first.read_delay =3D rxlow.read_delay; + window1 =3D rxhigh.rx - rxlow.rx; + first.rx =3D rxlow.rx + (window1 / 2); + + dev_dbg(dev, "First tuning point: RX: %d TX: %d RD: %d\n", first.rx, + first.tx, first.read_delay); + ret =3D cqspi_phy_apply_setting(f_pdata, &first); + if (!ret) + ret =3D cqspi_phy_check_pattern(f_pdata, mem); + + if (ret || first.read_delay > CQSPI_PHY_MAX_RD) + goto out; + + /* Second window: Search at read_delay+1, may differ in size */ + + /* + * rx + * 127 ^ + * | |-------| + * | |xxxxxxx| + * | |xxxxxxx| + * | |xxxxxxx| + * | |xxxxxxx| + * | |xxxxxxx| + * | rxlow rxhigh + * -----------------------------------------> tx + * 0 + * read_delay =3D n (smaller window) + * + * rx + * 127 ^ + * | |-----------------| + * | |xxxxxxxxxxxxxxxxx| + * | |xxxxxxxxxxxxxxxxx| + * | |xxxxxxxxxxxxxxxxx| + * | |xxxxxxxxxxxxxxxxx| + * | |xxxxxxxxxxxxxxxxx| + * | rxlow rxhigh + * -----------------------------------------> tx + * 0 + * read_delay =3D n+1 (larger window - better) + */ + + cqspi_phy_reset_setting(&rxlow); + cqspi_phy_reset_setting(&rxhigh); + cqspi_phy_reset_setting(&second); + + rxlow.read_delay =3D first.read_delay + 1; + if (rxlow.read_delay > CQSPI_PHY_MAX_RD) + goto compare; + + ret =3D cqspi_find_rx_low_sdr(f_pdata, mem, &rxlow); + if (ret) + goto compare; + + rxhigh.read_delay =3D rxlow.read_delay; + ret =3D cqspi_find_rx_high_sdr(f_pdata, mem, &rxhigh, rxlow.rx); + if (ret) + goto compare; + + /* Calculate second window midpoint */ + + /* + * rx + * 127 ^ + * | |--------window2---------| + * | |xxxxxxxxxxxxxxxxxxxxxxxx| + * | |xxxxxxxxxxxxxxxxxxxxxxxx| + * | |xxxxxxxxxxx * xxxxxxxxxx| + * | |xxxxxxxxxxxxxxxxxxxxxxxx| + * | |xxxxxxxxxxxxxxxxxxxxxxxx| + * | rxlow ^ rxhigh + * ----------------------|------------------> tx + * 0 | tx fixed at 127 + * window2/2 + * read_delay =3D n+1 + */ + + window2 =3D rxhigh.rx - rxlow.rx; + second.rx =3D rxlow.rx + (window2 / 2); + second.read_delay =3D rxlow.read_delay; + + dev_dbg(dev, "Second tuning point: RX: %d TX: %d RD: %d\n", second.rx, + second.tx, second.read_delay); + ret =3D cqspi_phy_apply_setting(f_pdata, &second); + if (!ret) + ret =3D cqspi_phy_check_pattern(f_pdata, mem); + + if (ret || second.read_delay > CQSPI_PHY_MAX_RD) + window2 =3D 0; + + /* Window comparison: Choose larger window for better margin */ + +compare: + cqspi_phy_reset_setting(&final); + if (window2 > window1) { + final.rx =3D second.rx; + final.read_delay =3D second.read_delay; + } else { + final.rx =3D first.rx; + final.read_delay =3D first.read_delay; + } + + /* Apply and verify final tuning point */ + + dev_dbg(dev, "Final tuning point: RX: %d TX: %d RD: %d\n", final.rx, + final.tx, final.read_delay); + ret =3D cqspi_phy_apply_setting(f_pdata, &final); + if (!ret) + ret =3D cqspi_phy_check_pattern(f_pdata, mem); + + if (ret) { + ret =3D -EINVAL; + goto out; + } + + f_pdata->phy_setting.read_delay =3D final.read_delay; + f_pdata->phy_setting.rx =3D final.rx; + f_pdata->phy_setting.tx =3D final.tx; + +out: + if (ret) + f_pdata->use_tuned_phy =3D false; + + return ret; +} + +static int cqspi_am654_ospi_execute_tuning(struct spi_mem *mem, + struct spi_mem_op *read_op, + struct spi_mem_op *write_op) +{ + struct cqspi_st *cqspi =3D + spi_controller_get_devdata(mem->spi->controller); + struct cqspi_flash_pdata *f_pdata; + struct device *dev =3D &cqspi->pdev->dev; + int ret =3D 0; + + f_pdata =3D &cqspi->f_pdata[spi_get_chipselect(mem->spi, 0)]; + + /* + * spi-max-post-config-frequency-hz must be present for PHY tuning. + * If absent, post_config_max_speed_hz is zero and there is no + * calibration target, so skip tuning gracefully. + */ + if (!mem->spi->post_config_max_speed_hz) { + dev_dbg(dev, + "No post-config frequency configured, skipping tuning\n"); + return -EOPNOTSUPP; + } + + if (write_op) { + /* + * For NAND: write the calibration pattern to the page cache. + * The write op runs at the conservative base speed (spi->max_speed_hz) + * so the write itself is reliable before PHY calibration. + */ + ret =3D cqspi_write_pattern_to_cache(f_pdata, mem, write_op); + if (ret) { + dev_warn(dev, + "failed to write pattern to cache: %d, skipping tuning\n", + ret); + goto out; + } + + f_pdata->phy_write_op =3D *write_op; + } else { + if (!f_pdata->phy_pattern_partition_valid) { + dev_warn(dev, "pattern partition not found, skipping tuning\n"); + return -EOPNOTSUPP; + } + } + + /* + * Build the read op template for pattern verification. For NOR, point + * at the pre-programmed pattern partition rather than the caller's + * address without altering the caller's template. + */ + f_pdata->phy_read_op =3D *read_op; + if (!write_op) + f_pdata->phy_read_op.addr.val =3D + f_pdata->phy_pattern_partition_offset; + + f_pdata->phy_read_op.max_freq =3D mem->spi->max_speed_hz; + + ret =3D cqspi_phy_check_pattern(f_pdata, mem); + if (ret) { + dev_err(dev, "pattern not found: %d, skipping tuning\n", ret); + goto out; + } + + f_pdata->phy_read_op.max_freq =3D mem->spi->post_config_max_speed_hz; + + if (read_op->cmd.dtr || read_op->addr.dtr || read_op->dummy.dtr || + read_op->data.dtr) { + f_pdata->use_dqs =3D true; + cqspi_phy_pre_config(cqspi, f_pdata, false); + ret =3D cqspi_phy_tuning_ddr(f_pdata, mem); + } else { + f_pdata->use_dqs =3D false; + cqspi_phy_pre_config(cqspi, f_pdata, true); + ret =3D cqspi_phy_tuning_sdr(f_pdata, mem); + } + + if (ret) + dev_warn(dev, "tuning failed: %d\n", ret); + + cqspi_phy_post_config(cqspi, f_pdata->read_delay); + +out: + if (!ret) { + read_op->max_freq =3D mem->spi->post_config_max_speed_hz; + if (write_op) { + write_op->max_freq =3D mem->spi->post_config_max_speed_hz; + f_pdata->phy_write_op.max_freq =3D + mem->spi->post_config_max_speed_hz; + } + } + + return ret; +} + +static int cqspi_mem_op_execute_tuning(struct spi_mem *mem, + struct spi_mem_op *read_op, + struct spi_mem_op *write_op) +{ + struct cqspi_st *cqspi =3D + spi_controller_get_devdata(mem->spi->controller); + + if (!cqspi->ddata || !cqspi->ddata->execute_tuning) + return -EOPNOTSUPP; + + return cqspi->ddata->execute_tuning(mem, read_op, write_op); +} + static int cqspi_of_get_flash_pdata(struct platform_device *pdev, struct cqspi_flash_pdata *f_pdata, struct device_node *np) { + struct device_node *part_np; + if (of_property_read_u32(np, "cdns,read-delay", &f_pdata->read_delay)) { dev_err(&pdev->dev, "couldn't determine read-delay\n"); return -ENXIO; @@ -1588,9 +3326,12 @@ static int cqspi_of_get_flash_pdata(struct platform_= device *pdev, return -ENXIO; } =20 - if (of_property_read_u32(np, "spi-max-frequency", &f_pdata->clk_rate)) { - dev_err(&pdev->dev, "couldn't determine spi-max-frequency\n"); - return -ENXIO; + part_np =3D of_parse_phandle(np, "spi-phy-pattern-partition", 0); + if (part_np) { + f_pdata->phy_pattern_partition_valid =3D + !of_property_read_u32_index(part_np, "reg", 0, + &f_pdata->phy_pattern_partition_offset); + of_node_put(part_np); } =20 return 0; @@ -1740,6 +3481,7 @@ static const struct spi_controller_mem_ops cqspi_mem_= ops =3D { .exec_op =3D cqspi_exec_mem_op, .get_name =3D cqspi_get_name, .supports_op =3D cqspi_supports_mem_op, + .execute_tuning =3D cqspi_mem_op_execute_tuning, }; =20 static const struct spi_controller_mem_caps cqspi_mem_caps =3D { @@ -2108,6 +3850,7 @@ static const struct cqspi_driver_platdata k2g_qspi = =3D { static const struct cqspi_driver_platdata am654_ospi =3D { .hwcaps_mask =3D CQSPI_SUPPORTS_OCTAL | CQSPI_SUPPORTS_QUAD, .quirks =3D CQSPI_NEEDS_WR_DELAY, + .execute_tuning =3D cqspi_am654_ospi_execute_tuning, }; =20 static const struct cqspi_driver_platdata intel_lgm_qspi =3D { --=20 2.34.1 From nobody Tue Sep 29 06:08:43 2026 Received: from mx0b-0002e601.pphosted.com (mx0b-0002e601.pphosted.com [148.163.154.28]) (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 2D89B381B01; Tue, 11 Aug 2026 18:34:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=148.163.154.28 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786473283; cv=fail; b=KyM9UURSvcqlD39jC8x//Ubw/otUI6kzyXacv8/3n0LS4EnOBDrGWv5J+curueEU6SEoj8WnncSca6DmVqcFNZUtWviAs4C8oVoFVWe+fLrP/lLBzNhbuGp9pCM1tc4Wm+3Go7tEvJvlFwwcY7hwmb6UR7IjxKL7gRY7uXkP1pU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786473283; c=relaxed/simple; bh=5qnezhdC7z+lORuvm/pjPzGWMGRQvmaJD+gNRZlgLhU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=tY68oBr4VAc2cbRgpmYv+BHZrGTlkHe+vvau6eYcyqMPGtWrGvW34Qh3u81HzYIJETViq+2m3NYstMPJUyW6ScSZdVf8wMTjGbZSCsoeN3SGdq02fDeGkdZZ83XOOjRZEQffMNUdJYU2fiDm/53r/jjokCfUaRFhiBUilJPP78w= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b=ZHYCwqkx; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=lqL8+3N3; arc=fail smtp.client-ip=148.163.154.28 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b="ZHYCwqkx"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="lqL8+3N3" Received: from pps.filterd (m0374955.ppops.net [127.0.0.1]) by mx0b-0002e601.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 67BGMcJa2174910; Tue, 11 Aug 2026 13:34:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint-05-2026; bh=L3r4+4BDkKDSVXfOUwFU3FkZBjUujBJu7lCtNDJ0T so=; b=ZHYCwqkxmPg0ox+1UNP3WMaWkSFQWfJcm5v61NdaRaTjoUvv+GXVWS9O/ 6iVyNhUP4YmUS01anX278s/Mia10N44r1Tq8AYPbKzkewW4VpvB5ocJRsLDq7to3 R5AG744S88E/OQL/Tccwc7gQ3Gle6RCn5QLRxVZmGhqjpIxYKIVEayGsG/2r9UqK 1HbZF7l0FvNMgPQsjkZB9feiDGilyd6F9g6kaZNLZT1WKrnbDTe+k14h1OqazLLG 05F2Zo8LyBM2qgCKpAzUgf+B42ffC5cKAetmkWwi7H/Mbxt1sUt166EnviZ/6pnL eF6fInNhyMaxhDEHmCfM7ia8YT0fQ== Received: from mw6pr02cu001.outbound.protection.outlook.com (mail-westus2azon11012047.outbound.protection.outlook.com [52.101.48.47]) by mx0b-0002e601.pphosted.com (PPS) with ESMTPS id 4g00w4uj2e-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 11 Aug 2026 13:34:29 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=kPnxhxBEXdBMVCG1z8ZeiiJNbnPmmuhFbgZ2lqAYdt2AyOn7I0Xi6mzgO+h4bCkcgcusViZsSW+7jeFt5fOlFqYMwk9VY4e1ptaAqnv4ovnXAwlSjugZwaVjKVA+EOCKMZ8zaWqOHSaNlOuV9J3VQbxdw+1rbP1VTKJ+1HBfBVYTAVD/ixrWFG/gZE9sOHZ0bFR3RuRNEIuVOdCeGsj+jhvPlfBu+ZMbcfLwPorAooXFygl7boZGcJMRaxuWAf/CDFrRJ5c+XBB1gKTaCa5FvfTGK/LU4+ttAo+eDvtTIETCt/KcOTe3rsOqkD5x8Twsm+ATZn3DBFLTbjpN/dKc0g== 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=L3r4+4BDkKDSVXfOUwFU3FkZBjUujBJu7lCtNDJ0Tso=; b=Gug/MOXmc6MPid/ye3KAxpFqdH43FNFYbrs1hk3YAiKvEIX6EKxlxO7cfrS7yFvK0OhCmFkOEquPQn1MYc+lrh4LMwtGgpNrTvvQQzQA2d+Oaur7v4FLVQoUoET4FJ/xp3m3pQD0R0kzPI6I4CkSAcVoYJUAg8Fv1JwDvklIODdWWoYgYoh7aL/oAHD31+9B3VQxXDi74fzFqXwnzZIWIbecD4swAg7m51LdXsLu08MhWcNWKlbUYsnV/1Xim02OY49SQPBlE9CpiXMDDpD7v2Mel8l3XKshRY86NfwGsivem5INvBio2WIxWU0b3aLWgLwNBxSMmrfOTcWEyI9rlQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 198.47.23.195) smtp.rcpttodomain=lists.infradead.org smtp.mailfrom=ti.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=L3r4+4BDkKDSVXfOUwFU3FkZBjUujBJu7lCtNDJ0Tso=; b=lqL8+3N3SB2LRvICWGg88QIVSFX2ovJ8aquUiTZeqbAm8cISA5JOFPlmUmmCfYhx3QOam2ukXvfTEwn8/bNCLKaVA775IQV7yX0jKHyTjGm9Y8cg1oXFUC2qq/mQt47KJCk2LPaRfz9BQrRnDSlvuy/uYhKm5tOLvi0mrew7Pm4= Received: from BY3PR10CA0018.namprd10.prod.outlook.com (2603:10b6:a03:255::23) by CY5PR10MB6012.namprd10.prod.outlook.com (2603:10b6:930:27::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.315.11; Tue, 11 Aug 2026 18:34:25 +0000 Received: from SJ1PEPF000023D0.namprd02.prod.outlook.com (2603:10b6:a03:255:cafe::28) by BY3PR10CA0018.outlook.office365.com (2603:10b6:a03:255::23) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.315.12 via Frontend Transport; Tue, 11 Aug 2026 18:34:24 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 198.47.23.195) smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ti.com; Received-SPF: Pass (protection.outlook.com: domain of ti.com designates 198.47.23.195 as permitted sender) receiver=protection.outlook.com; client-ip=198.47.23.195; helo=lewvzet201.ext.ti.com; pr=C Received: from lewvzet201.ext.ti.com (198.47.23.195) by SJ1PEPF000023D0.mail.protection.outlook.com (10.167.244.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.315.6 via Frontend Transport; Tue, 11 Aug 2026 18:34:24 +0000 Received: from DLEE207.ent.ti.com (157.170.170.95) by lewvzet201.ext.ti.com (10.4.14.104) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Tue, 11 Aug 2026 13:34:08 -0500 Received: from DLEE203.ent.ti.com (157.170.170.78) by DLEE207.ent.ti.com (157.170.170.95) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Tue, 11 Aug 2026 13:34:08 -0500 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) by DLEE203.ent.ti.com (157.170.170.78) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Tue, 11 Aug 2026 13:34:08 -0500 Received: from santhoshkumark.dhcp.ti.com (santhoshkumark.dhcp.ti.com [10.24.52.55]) by lelvem-mr06.itg.ti.com (8.18.1/8.18.1) with ESMTP id 67BIXIe1659766; Tue, 11 Aug 2026 13:34:03 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , Subject: [PATCH v7 09/18] spi: cadence-quadspi: skip DDR PHY tuning for 2-byte-address ops (i2383) Date: Wed, 12 Aug 2026 00:03:04 +0530 Message-ID: <20260811183313.1550425-10-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260811183313.1550425-1-s-k6@ti.com> References: <20260811183313.1550425-1-s-k6@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF000023D0:EE_|CY5PR10MB6012:EE_ X-MS-Office365-Filtering-Correlation-Id: 8ec79d20-38c5-459c-9298-08def7d72b26 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700016|376014|7416014|23010399003|1800799024|82310400026|13003099007|921020|6133799003|56012099006|10067099003|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: qhzlf51Y7Q8ukeGO9UoyZr19lV8koIFMFM//BMnofXzoE5dGR42v+j5j2BzyLVtggMYZeX9QsHy0h7JVZUutk8vGs+9pKOfYnEQGNrDyj9K0jgqgrJhlaGMRd9XdmtdyPYx2uMWKc+9BwfLgD/fAqTKImYgmhS/6IWm26+wJ+j4LPtYmogHETYQTxVxsaUhQ4n/vu7OrzWD9xi4NF9WCGQU7ytrEKMFShx20AsRgPKp44WY9LwynKbBxwEEPtabQAE4FK1HRHyQvcwq7ocvNufyKbyguBbQq9xWV/FhxeSxEYtsDsU8/aFoKLiA3vGwZpLyIVmwq2vofHvn2C+xTr/KfiAIblcG55uju36Hexq8W88dki+8AJZgXwMMyok8BW0DLixAibe7UxKcEH99wX8AauuZuuyT5t+k0cDdLeT20ikdt3nkgcynViH3Mkw7IPmCYRZUKN56yd00A47IU+ODHNr58TK+0q/qHmLIc2muqUcm9ukenwl42qXBWl5qfcCFvHjHLSqWprRt9M4ywH6ll/SKhdISItRDOEfp9RqmL/LL5WOhutRXEy94VJpLdheAd4RtRc8xbBz8d8eGOkemmCv//Jd9DtcgYvQtsUrq0NhpFNygXximJrWA3AG2iiWyrWx+Ro38oxRWUBg0ZVKkiyma4bs3s4Q5i4BWJb6Z0LStRk2IOUPEvWTx4tiKKHvwmUDdWlRlvo3RVHQYBuJMGQUX5iLJ8xoX40CNudyTopNbtLZLcbZwLf9seOxXL X-Forefront-Antispam-Report: CIP:198.47.23.195;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:lewvzet201.ext.ti.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700016)(376014)(7416014)(23010399003)(1800799024)(82310400026)(13003099007)(921020)(6133799003)(56012099006)(10067099003)(18002099003)(22082099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: f1u5PF+c8eFAetgK/HMvmeAJ20rOOgobX1GNH/PEZuyNbMmY98MSu8UDmgbQnI+iaaCYVMsbtJV7El6VAygzhhLwWbqSAVvkauYCMna/Y5skE7pJqs5TT/cqyLbDjKp2XUOjUEK+oMPllroa3wckkBtZ92dk9RYkxl5t20PgqjZ1b/Q1aKEyw2GxbLSBLlSGoE5YAzAgmkD1Hb3Tqq1yWRHQqI1DmumgHiiaGgRy0Bek8GGs/uzNM8/aouIwaHwqTcmeQz2D1OpOrrRJm1HKMcIRgXgawvxfJ8qgbuZcCFzhETZfCGi/u7kwUE6/OXXgzCgZuQqVLWm6mEnDvtFhsI5r9K4nlg/aqcubLGbrmUDmNe3jcRiQ2d/oXk7p+1MR+ed87s6k7Th33G5CunMvAM21VNBO5Ji2qP1KGGHbhaYPZq8arIeZek8kDbKuLIrt X-Exchange-RoutingPolicyChecked: kKWJiQUx/l5Ld+4QpuQiaILBt4dL677Ll2a7icrNgaKM39kDfByINi0dbWVdKCQmkSq/++gNB8kO8tOpjlyK2xiEjrHqGeZqUVeYpjh9JsIduqXVcXlvwLvXLUbK5qKmzngq6khHlMrzhbiBJqHcPLsovwykJtJ5TxB5uT8mgWL3S3sn2Z879bPKLoWBN5A5plvFVwHrCWSJEzHlzYDo60oTHC82fMwjKOuILQ9oxxbkO4hura8L48yGRA0SkxeNsxcElvUHUjx35YWZMDUQutf4SGBXboUkHzoZSHbq6ZE7/0qo9nwYkYtEz1piy7Qmkt3UvdVnQLuqQlfLykA4nw== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Aug 2026 18:34:24.5821 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8ec79d20-38c5-459c-9298-08def7d72b26 X-MS-Exchange-CrossTenant-Id: e5b49634-450b-4709-8abb-1e2b19b982b7 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=e5b49634-450b-4709-8abb-1e2b19b982b7;Ip=[198.47.23.195];Helo=[lewvzet201.ext.ti.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF000023D0.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR10MB6012 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODExMDE1NiBTYWx0ZWRfXyR48vf/J1E2s PEetTeI3Y+K9hHC2GSd8XhAZCAOE6ajpIXwsxRkRryRfiPaUq/9E+n4fn4mv7u5dPXuzZMt2Y4b YXt07VEhvPMMU/hQ30u3V9TZVM4bMi14zsATm4aN+rGOAUCkBv7m9Sa6/lIDiJ2Gf5/0tfv+lX7 qGQRniNmFYxBXmwBIFvhqacxAXJzmcHkxrUbgKfk7QLVOzyOFWLgsi8z9wdZ1437ueTQ8LZT7wr Th71ka5ERY/CekjJQnc0zlbLClxI/4MtvNYjp1Oh5bvLEcHRTVxWnm/MsMn3JdwcgiaOgUgWhOn SgwiIg2ZR7kX2GXeQs5eAWdR3pBwvxhf9Dao6zrD8DXQLHp/4Zf8jreeXVmkC6zFinauOMra9+X lOhARPlMfsk58Yza/OYuAXUr9MoJachd+Pc8XEEGGxf/6DvbUr5QxDTnbEnJLCSkWOJtnc1pCvR rL/Jf7QPY39ww43hVcQ== X-Proofpoint-ORIG-GUID: q_px9SPIjT6WV43-rzl_K23qy8wat3wW X-Authority-Analysis: v=2.4 cv=KZ/idwYD c=1 sm=1 tr=0 ts=6a7b6b35 cx=c_pps a=nAh4yJc8K/mwxcjpRfPwJQ==:117 a=f+v6EHfkeJbVwR46tk4DMg==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=IkcTkHD0fZMA:10 a=Sv0fKeRqtYgA:10 a=s63m1ICgrNkA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=fPAWb5peG099m5CrUpKH:22 a=sozttTNsAAAA:8 a=T-kh0MV4vbdY-aS4Zb4A:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 X-Proofpoint-GUID: q_px9SPIjT6WV43-rzl_K23qy8wat3wW X-Proofpoint-Spam-Info: AW1haW4tMjYwODExMDE1NiBTYWx0ZWRfX+g6/uts+Oyze wGFfqyZS0m8mCuuKFce1vIfLGtwxUj6655ntQSA2PQBTChEnSiBn9gfhdKL18UGTlP4CVllkCOW G7LfmmQJSaACS17szPVGJrRWgot087I= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-11_04,2026-08-10_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 adultscore=0 spamscore=0 suspectscore=0 clxscore=1015 phishscore=0 lowpriorityscore=0 malwarescore=0 priorityscore=1501 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608110156 Erratum i2383 on AM654 locks the address phase in PHY DDR mode when a 2-byte column address is used. DDR PHY tuning must not be attempted for such operations; non-PHY DDR usage is unaffected. [0] Add CQSPI_NO_PHY_TUNING_WITH_ODDR_2B_ADDR quirk and check it in cqspi_am654_ospi_execute_tuning(). When the erratum applies, return 0 with read_op->max_freq cleared =E2=80=94 the op-skip signal that tells the caller to try another op variant. [0] https://www.ti.com/lit/er/sprz544c/sprz544c.pdf Signed-off-by: Santhosh Kumar K --- drivers/spi/spi-cadence-quadspi.c | 43 +++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-qu= adspi.c index 5651320426b1..a1aaba7c1a7e 100644 --- a/drivers/spi/spi-cadence-quadspi.c +++ b/drivers/spi/spi-cadence-quadspi.c @@ -37,19 +37,20 @@ static_assert(CQSPI_MAX_CHIPSELECT <=3D SPI_DEVICE_CS_CNT_MAX); =20 /* Quirks */ -#define CQSPI_NEEDS_WR_DELAY BIT(0) -#define CQSPI_DISABLE_DAC_MODE BIT(1) -#define CQSPI_SUPPORT_EXTERNAL_DMA BIT(2) -#define CQSPI_NO_SUPPORT_WR_COMPLETION BIT(3) -#define CQSPI_SLOW_SRAM BIT(4) -#define CQSPI_NEEDS_APB_AHB_HAZARD_WAR BIT(5) -#define CQSPI_RD_NO_IRQ BIT(6) -#define CQSPI_DMA_SET_MASK BIT(7) -#define CQSPI_SUPPORT_DEVICE_RESET BIT(8) -#define CQSPI_DISABLE_STIG_MODE BIT(9) -#define CQSPI_DISABLE_RUNTIME_PM BIT(10) -#define CQSPI_NO_INDIRECT_MODE BIT(11) -#define CQSPI_HAS_WR_PROTECT BIT(12) +#define CQSPI_NEEDS_WR_DELAY BIT(0) +#define CQSPI_DISABLE_DAC_MODE BIT(1) +#define CQSPI_SUPPORT_EXTERNAL_DMA BIT(2) +#define CQSPI_NO_SUPPORT_WR_COMPLETION BIT(3) +#define CQSPI_SLOW_SRAM BIT(4) +#define CQSPI_NEEDS_APB_AHB_HAZARD_WAR BIT(5) +#define CQSPI_RD_NO_IRQ BIT(6) +#define CQSPI_DMA_SET_MASK BIT(7) +#define CQSPI_SUPPORT_DEVICE_RESET BIT(8) +#define CQSPI_DISABLE_STIG_MODE BIT(9) +#define CQSPI_DISABLE_RUNTIME_PM BIT(10) +#define CQSPI_NO_INDIRECT_MODE BIT(11) +#define CQSPI_HAS_WR_PROTECT BIT(12) +#define CQSPI_NO_PHY_TUNING_WITH_ODDR_2B_ADDR BIT(13) =20 /* Capabilities */ #define CQSPI_SUPPORTS_OCTAL BIT(0) @@ -3211,6 +3212,20 @@ static int cqspi_am654_ospi_execute_tuning(struct sp= i_mem *mem, return -EOPNOTSUPP; } =20 + /* + * Erratum i2383: in PHY DDR mode, a 2-byte column address locks up + * the address phase. Skip DDR PHY tuning for such operations. + */ + if ((cqspi->ddata->quirks & CQSPI_NO_PHY_TUNING_WITH_ODDR_2B_ADDR) && + read_op->addr.nbytes =3D=3D 2 && + (read_op->cmd.dtr || read_op->addr.dtr || read_op->dummy.dtr || + read_op->data.dtr)) { + dev_dbg(dev, + "i2383: skipping DDR PHY tuning (2-byte address)\n"); + read_op->max_freq =3D 0; + return 0; + } + if (write_op) { /* * For NAND: write the calibration pattern to the page cache. @@ -3849,7 +3864,7 @@ static const struct cqspi_driver_platdata k2g_qspi = =3D { =20 static const struct cqspi_driver_platdata am654_ospi =3D { .hwcaps_mask =3D CQSPI_SUPPORTS_OCTAL | CQSPI_SUPPORTS_QUAD, - .quirks =3D CQSPI_NEEDS_WR_DELAY, + .quirks =3D CQSPI_NEEDS_WR_DELAY | CQSPI_NO_PHY_TUNING_WITH_ODDR_2B_ADDR, .execute_tuning =3D cqspi_am654_ospi_execute_tuning, }; =20 --=20 2.34.1 From nobody Tue Sep 29 06:08:43 2026 Received: from mx0b-0002e601.pphosted.com (mx0b-0002e601.pphosted.com [148.163.154.28]) (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 1FB93384CDA; Tue, 11 Aug 2026 18:34:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=148.163.154.28 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786473288; cv=fail; b=K4Iffx0FPMC4YPFm56a4fXNXlGH3KByR3YJiGqQbibK6fazAW8UEQ1iE4B8DQMKW6T9Q/IMxELG4HC+a3XcFY4pqhRxokTik1+zcCyt5N4+bJdyr8ITcE6S3HtZl2SchKcqldJMVYWDQGvELexr7l85cFSf0R9gEtPwGLaEdkRk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786473288; c=relaxed/simple; bh=MDx2qjP/XXiD3vIr9oQt9kMeHBFs0R28iU0agoq2Hnk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=c/ndze+pW017fEPHt1L6Am9JoVoLfRKm7iu9W0KtoHuFbUzDz89WPIArGaWmObwJ4EmbJxJBS5EEGNDKbYT+LEjInftNFDSeUucr000NMeInQ4Q0oFYXBIdzB91GAJIPbEQFgBmNLnu2/qUoB4BYzz1/bZkH599CzrEOiXyDHnQ= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b=dIzHWIn6; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=OO52v4YO; arc=fail smtp.client-ip=148.163.154.28 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b="dIzHWIn6"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="OO52v4YO" Received: from pps.filterd (m0374956.ppops.net [127.0.0.1]) by mx0b-0002e601.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 67BGM8VH1823871; Tue, 11 Aug 2026 13:34:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint-05-2026; bh=8ugXXaYOACCqQhtO+XS/9SAqsz/zeF6YSVcc8SKLY /0=; b=dIzHWIn6/SDPbjm7e/oyY7jN1v6QUd5nWHfEgyGGogzie8yNF7pXXcMZN ql51h4b5ZFPcJb29Ry2R4pNbPwQxzxgIT5FBIoTL5A0Jj36ymwKiOgdQ7witmXp2 sRa8PbTt+SUPxEXI80+v3XWvvCi4SiDjE84AkPdbsT1XHZLUlkC8Fh3gryZqtCNv 4fyiPJZ9vSAAxKLHvJ+pIgoku+Sl2z0Fz7M3ublYzvupi+IcTEDLUU60QhtFX8un wsssSokU7qD6XYtKA5B/lvq90u7xV6/REgMt04CFIaixxg4Df38Vwu9PZEk/nhI8 KVK6ErB5uo6+a8y3P94O2+ZTarGBA== Received: from sa9pr02cu001.outbound.protection.outlook.com (mail-southcentralusazon11013059.outbound.protection.outlook.com [40.93.196.59]) by mx0b-0002e601.pphosted.com (PPS) with ESMTPS id 4g00wnbk8g-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 11 Aug 2026 13:34:37 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Vs2S4CONmImGZzq8HPNvrPfZxOUKK4O9t2/cL7UAkk4qkVBn+sk8/w5QZOAwMcctvn/4HQnWFxRtFx+keypkqEhIDeuvgr330+6bdtbyg3KtxJEXeq+92kE0B6csZ3VAGMdO4q9CjNCW29t3l2Tvv1R0wfCc9YRSvQJZ13zH0H777XFReFkj6E0CKuv3gI1Y9aSj5msxAihPrk9Ue5oLoUYu1yb4LAGBe+7eCyJrcO1aJN9kSaX5ySqh8PrlsIRlKcweVPI2h854Is0GTSO4YvxrydYi06R+bxmtydKvDbAOj8VhVaOB8Jaad9EAP+0uDrBdkxcks8s5d29+Ae0P5w== 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=8ugXXaYOACCqQhtO+XS/9SAqsz/zeF6YSVcc8SKLY/0=; b=d7/q9QlKMPfREkZGdaLZlVO8VlqQeQT0CKKDIuMCzc2HNKIkcikxCaV6yqGJRPYNHSxTm78CjQn/n5zdUiL/PkkqTv5IhNz8F4TTtOyZ51pvExCaxuco6tTeiC+hsZzKFOxGzZcirpGCSUp5t4RmNoFbuEP1H5Kgpj7irlSh6HJMXwR6KS3CVRkkcvMgmSUDvuVXE4lWzG0G+3cz0kTVfbhrxYVS84BE1pohZJYl8nuLR5mMnJMChnsF2edP6I3OHUEoShE/1F2s8Qt4Bp/yWd92fyOm+bvdR29O3WnVGgz9XWofrLD5+kKlPMxrNBaFFPQ64I/OkrwdMLkZLppm8w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 198.47.23.195) smtp.rcpttodomain=lists.infradead.org smtp.mailfrom=ti.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8ugXXaYOACCqQhtO+XS/9SAqsz/zeF6YSVcc8SKLY/0=; b=OO52v4YOA/KjqKvxkoZK7U4R7tdUq8kDgTEainR0EaivV20Ck1QQhFJw8kPlYRWwuLRFNpKHf8/rukkKUJENzBWl6/JsKQxskNm3h2N2I6DmWIccQORh7fKr92MdtQdH3noa1hb4Y3i3c1QRc+BKvstTHBUEuO7onv8gV2uq+8M= Received: from SJ0PR05CA0004.namprd05.prod.outlook.com (2603:10b6:a03:33b::9) by MN2PR10MB4302.namprd10.prod.outlook.com (2603:10b6:208:199::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.292.25; Tue, 11 Aug 2026 18:34:29 +0000 Received: from SJ1PEPF000023CC.namprd02.prod.outlook.com (2603:10b6:a03:33b:cafe::19) by SJ0PR05CA0004.outlook.office365.com (2603:10b6:a03:33b::9) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.315.12 via Frontend Transport; Tue, 11 Aug 2026 18:34:29 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 198.47.23.195) smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ti.com; Received-SPF: Pass (protection.outlook.com: domain of ti.com designates 198.47.23.195 as permitted sender) receiver=protection.outlook.com; client-ip=198.47.23.195; helo=lewvzet201.ext.ti.com; pr=C Received: from lewvzet201.ext.ti.com (198.47.23.195) by SJ1PEPF000023CC.mail.protection.outlook.com (10.167.244.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.315.6 via Frontend Transport; Tue, 11 Aug 2026 18:34:29 +0000 Received: from DLEE205.ent.ti.com (157.170.170.85) by lewvzet201.ext.ti.com (10.4.14.104) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Tue, 11 Aug 2026 13:34:13 -0500 Received: from DLEE207.ent.ti.com (157.170.170.95) by DLEE205.ent.ti.com (157.170.170.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Tue, 11 Aug 2026 13:34:13 -0500 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) by DLEE207.ent.ti.com (157.170.170.95) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Tue, 11 Aug 2026 13:34:13 -0500 Received: from santhoshkumark.dhcp.ti.com (santhoshkumark.dhcp.ti.com [10.24.52.55]) by lelvem-mr06.itg.ti.com (8.18.1/8.18.1) with ESMTP id 67BIXIe2659766; Tue, 11 Aug 2026 13:34:08 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , Subject: [PATCH v7 10/18] spi: cadence-quadspi: refactor direct read path for PHY support Date: Wed, 12 Aug 2026 00:03:05 +0530 Message-ID: <20260811183313.1550425-11-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260811183313.1550425-1-s-k6@ti.com> References: <20260811183313.1550425-1-s-k6@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF000023CC:EE_|MN2PR10MB4302:EE_ X-MS-Office365-Filtering-Correlation-Id: 7596eb46-11f1-493b-ac72-08def7d72dd4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|36860700016|1800799024|82310400026|23010399003|921020|6133799003|10067099003|56012099006|18002099003|22082099003|3023799007; X-Microsoft-Antispam-Message-Info: upfKuxHQQMnaw5IO6SQnSEbcRDOdoKRJotEAP1MxAYNMGSA6fvqiKHZlUXNGVuFclIClNG7D+/HZ+RaI+umVmOGPdA/m22MXM6WdR+gmvbxlwPex9Rso47l0pRAlt4kdM64pOAYT01kvcywaLACW/6OuxTu5Je4QX3YRckZC/9CURLqLypdGo65pS//emHQtLpPNjQUsn1gUcJSVvs3W7A4saOI9WbwSFxps3whQ5O09OqYEkn9Wb7Fkw5FM1aoxOKWP16gOnHk82BIN/j+qPQ7cPCYe6icOEf5r71H6S0Z7FnhC8scny7G2DNdJ9APIDwuYbumHOWkDzpqAC3VK4joySmYPkS+a/Z+X0na4zVXc0jl/14jRG3LTRKG3FpAIA7cVXucpT/uC5gP1ywm2QpPReNUptg3pGnb+6+Njo4gifiMJ6FeRSjIJ/lLzDSHWdKQVKBc5GVy/P/g/dfTBRYE7qxTX42xBjM5ecFbJ4MXrejZlO+vhWL74qR+EkPIMFTdkIe4i94Jnetlp7wksMyFZFEKIDb0CLBLvxvIY6MJwRfW0fQsqLcACm+HALNoDJnAUp1tTbz2bst/HuQz7seiP9kR5I+nTM6UmvnRWaUxhJKbe+WUjttGLvo4SVGa21bdYivlLA855YrDnd9LLH2XlH7ycITGoR4Emdfa2J74eQemDa1+Ce3tc6pU/EykEKnT53yUGfZGTFXrBOCPEkf/V9Prlvwcg9saOscsy0vwah8NSuIk77xIRIvoSue52 X-Forefront-Antispam-Report: CIP:198.47.23.195;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:lewvzet201.ext.ti.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(7416014)(36860700016)(1800799024)(82310400026)(23010399003)(921020)(6133799003)(10067099003)(56012099006)(18002099003)(22082099003)(3023799007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /ASxL24InyrHXEd631SniDjSdKfUYrX4rWuPEs6BWoFP+xX2EytDOtbcEWw7zM0vOg0jbZZkIVPMA7fQkibi8OnajcoGV0QPfdAvPWRHZGkyv863F52lK66HZX2RUNYTaVEefN+YcoUFJ4hrAygQKJNXtpckU4pDEdpOsiLrSQatnsVBIQ8xRTvrAhj5DczW1D/VnUF7jp2shqWmdb8cyArTBf+bhvHErce7fFa7HXZEV8nPguimQn5ZcPDBQxTj8xfYn6J4RobcpTWCjdqMvoxjujCmwl6zCrYsOzrgp+PNN/sefPVWco58hYbppHWS/k4YQfzocA6Pk/1MXE+0yY5Ff5RipN4RKzkz9GLm9toSLCKbrWYVAVNrNLqQvQ0NqM5sOjb3kp0z55KFewyXpHSs3kNIo09KDfStxmXQvjQULKKh9lg9lhxT5vdh237u X-Exchange-RoutingPolicyChecked: tEvvNSKGxDZ3iTxOvGSYf+uSj68okSmUtB+QYYILMqJYg/VGpasmZqTUaeSwkCS5VG/wJ9V9F1hXWWwIQSMbeZvJegfiVUEmJUQFr/1BFUZXl3wkKKNnrZ8f/7GBCdxLpUkhy6MhUNzsIrHm6vzh1auHgV7wvo6i3/VWrA3NSdzaKIes/pf+/QQci+S/8gHLg5MQosoRzRS/ACu8BmXZsQcIaVoGab3VYmcT1czDSm73vi6gaSK05nqVV1sux5NV5aDCNzxD8VB8FNAnfCfSaAwgAWecyLZ0IvpL8OF9c/oeFdAptYGG7ozfU7sCH+Ud2HfdTtY51Bg6RpsjrGErBw== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Aug 2026 18:34:29.0783 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7596eb46-11f1-493b-ac72-08def7d72dd4 X-MS-Exchange-CrossTenant-Id: e5b49634-450b-4709-8abb-1e2b19b982b7 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=e5b49634-450b-4709-8abb-1e2b19b982b7;Ip=[198.47.23.195];Helo=[lewvzet201.ext.ti.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF000023CC.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR10MB4302 X-Proofpoint-Spam-Info: AW1haW4tMjYwODExMDE1NiBTYWx0ZWRfX+F2KThycuAVD nub+v/zXcpnfEbV5iERgAB19pVxvCGkXsk/+J8h2EAFUl0MNdbX50zchwyDfqZgUjlnbqpl58nf taMx1Pw5TGmeNczDBdCnzf3yoYZlO2c= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODExMDE1NiBTYWx0ZWRfX5gpQcMiffUbh TNgMmVP0HHQZTDAwVKIsQuorp8KYr+iHXqpKWwL+maQ7ntVhixsWkLIm1KOxmh7UhK397WHjpWM 9uPRVDbGVk9zt/ZlJZWJlqOmr1cwtbvqXUVUox90f4u2AP+vhOdv16/GC6J2AuCCkvMjQaoTrSN Ju8VgsS4NtC5RbYNx0l1HATfKDYnAkzgp0UCvYY+GnVFz6GsbI8fU7ddhqN+UCHNMbSi0IVvN92 f5+uKMwzDqW9ggSNX1cLttDin04wXkTgvzflaacRQgH7H2l8SckCz0h5uePDP1To4sRLjwAVCda U7sWbDgCfH+m7t3SH+3kXo/xwqz7GzYDmJpQZV7cD954vJszJ1wYmYR5eHeLweghQpwXUADEIkp EVOwFtXsi2ZftXxdBIf0lRUI5SEkAlz6SC+wa4wLvv+UfafuVTq4AfFTzigzAV5oTgVrZliMssD 76eoAwwHMsiM23ZT/nA== X-Proofpoint-GUID: yAXZEOhNEzMwtZ6Fq5bmXqqjtdnl0suS X-Authority-Analysis: v=2.4 cv=cYziaHDM c=1 sm=1 tr=0 ts=6a7b6b3d cx=c_pps a=wUEmejkcrq5hT7YoMv924g==:117 a=f+v6EHfkeJbVwR46tk4DMg==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=Sv0fKeRqtYgA:10 a=s63m1ICgrNkA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=jwouBfj2j3NM8CExmVVE:22 a=sozttTNsAAAA:8 a=aauMkRGVHSVL3AvwFNMA:9 X-Proofpoint-ORIG-GUID: yAXZEOhNEzMwtZ6Fq5bmXqqjtdnl0suS X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-11_04,2026-08-10_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 bulkscore=0 priorityscore=1501 spamscore=0 suspectscore=0 impostorscore=0 malwarescore=0 phishscore=0 clxscore=1015 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608110156 Content-Type: text/plain; charset="utf-8" Extract the DMA transfer code from cqspi_direct_read_execute() into a new cqspi_direct_read_dma() helper. Add cqspi_memcpy_fromio() to handle non-DMA transfers, using 2-byte-aligned I/O reads for 8D-8D-8D mode to satisfy the minimum 16-bit AHB transaction width required by the Cadence OSPI controller in that mode. Change cqspi_direct_read_execute() to take the full spi_mem_op and post_config_max_speed_hz instead of separate buf/from/len parameters, matching the interface needed by the PHY-aware version in the following patch. Thread post_config_max_speed_hz from cqspi_mem_process() through cqspi_read(). Transfers shorter than CQSPI_PHY_MIN_DIRECT_READ_LEN bytes always use the memcpy path; longer transfers use DMA when available. Signed-off-by: Santhosh Kumar K --- drivers/spi/spi-cadence-quadspi.c | 75 ++++++++++++++++++++++++++----- 1 file changed, 65 insertions(+), 10 deletions(-) diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-qu= adspi.c index a1aaba7c1a7e..99a0ec0e769c 100644 --- a/drivers/spi/spi-cadence-quadspi.c +++ b/drivers/spi/spi-cadence-quadspi.c @@ -30,6 +30,7 @@ #include #include #include +#include =20 #define CQSPI_NAME "cadence-qspi" #define CQSPI_MAX_CHIPSELECT 4 @@ -154,6 +155,8 @@ struct cqspi_driver_platdata { #define CQSPI_READ_TIMEOUT_MS 10 #define CQSPI_BUSYWAIT_TIMEOUT_US 500 #define CQSPI_DLL_TIMEOUT_US 300 +/* Minimum transfer length to use DMA for direct reads */ +#define CQSPI_PHY_MIN_DIRECT_READ_LEN 17 =20 /* Runtime_pm autosuspend delay */ #define CQSPI_AUTOSUSPEND_TIMEOUT 2000 @@ -1528,8 +1531,8 @@ static void cqspi_rx_dma_callback(void *param) complete(&cqspi->rx_dma_complete); } =20 -static int cqspi_direct_read_execute(struct cqspi_flash_pdata *f_pdata, - u_char *buf, loff_t from, size_t len) +static int cqspi_direct_read_dma(struct cqspi_flash_pdata *f_pdata, u_char= *buf, + loff_t from, size_t len) { struct cqspi_st *cqspi =3D f_pdata->cqspi; struct device *dev =3D &cqspi->pdev->dev; @@ -1541,11 +1544,6 @@ static int cqspi_direct_read_execute(struct cqspi_fl= ash_pdata *f_pdata, dma_addr_t dma_dst; struct device *ddev; =20 - if (!cqspi->rx_chan || !virt_addr_valid(buf)) { - memcpy_fromio(buf, cqspi->ahb_base + from, len); - return 0; - } - ddev =3D cqspi->rx_chan->device->dev; dma_dst =3D dma_map_single(ddev, buf, len, DMA_FROM_DEVICE); if (dma_mapping_error(ddev, dma_dst)) { @@ -1587,8 +1585,63 @@ static int cqspi_direct_read_execute(struct cqspi_fl= ash_pdata *f_pdata, return ret; } =20 +static void cqspi_memcpy_fromio(const struct spi_mem_op *op, void *to, + const void __iomem *from, size_t count) +{ + if (op->data.buswidth =3D=3D 8 && op->data.dtr) { + unsigned long from_addr =3D (unsigned long)from; + + /* Handle unaligned start with 2-byte read */ + if (count && !IS_ALIGNED(from_addr, 4)) { + put_unaligned_le16(__raw_readw(from), to); + from +=3D 2; + to +=3D 2; + count -=3D 2; + } + + /* + * Use an explicit 32-bit read loop for the bulk; this + * guarantees the minimum 16-bit AHB transaction width required + * in 8D-8D-8D mode on all architectures. + */ + while (count >=3D 4) { + put_unaligned_le32(__raw_readl(from), to); + from +=3D 4; + to +=3D 4; + count -=3D 4; + } + + /* Handle remaining 2 bytes */ + if (count) + put_unaligned_le16(__raw_readw(from), to); + + return; + } + + memcpy_fromio(to, from, count); +} + +static int cqspi_direct_read_execute(struct cqspi_flash_pdata *f_pdata, + const struct spi_mem_op *op, + u32 post_config_max_speed_hz) +{ + struct cqspi_st *cqspi =3D f_pdata->cqspi; + loff_t from =3D op->addr.val; + size_t len =3D op->data.nbytes; + u_char *buf =3D op->data.buf.in; + + if (!cqspi->rx_chan || !virt_addr_valid(buf) || + len < CQSPI_PHY_MIN_DIRECT_READ_LEN) { + cqspi_memcpy_fromio(op, buf, cqspi->ahb_base + from, len); + return 0; + } + + return cqspi_direct_read_dma(f_pdata, buf, from, len); +} + static ssize_t cqspi_read(struct cqspi_flash_pdata *f_pdata, - const struct spi_mem_op *op) + const struct spi_mem_op *op, + u32 post_config_max_speed_hz) { struct cqspi_st *cqspi =3D f_pdata->cqspi; const struct cqspi_driver_platdata *ddata =3D cqspi->ddata; @@ -1604,7 +1657,8 @@ static ssize_t cqspi_read(struct cqspi_flash_pdata *f= _pdata, =20 if ((cqspi->use_direct_mode && ((from + len) <=3D cqspi->ahb_size)) || (cqspi->ddata && cqspi->ddata->quirks & CQSPI_NO_INDIRECT_MODE)) - return cqspi_direct_read_execute(f_pdata, buf, from, len); + return cqspi_direct_read_execute(f_pdata, op, + post_config_max_speed_hz); =20 if (cqspi->use_dma_read && ddata && ddata->indirect_read_dma && virt_addr_valid(buf) && ((dma_align & CQSPI_DMA_UNALIGN) =3D=3D 0)) @@ -1632,7 +1686,8 @@ static int cqspi_mem_process(struct spi_mem *mem, con= st struct spi_mem_op *op) !cqspi->disable_stig_mode)) return cqspi_command_read(f_pdata, op); =20 - return cqspi_read(f_pdata, op); + return cqspi_read(f_pdata, op, + mem->spi->post_config_max_speed_hz); } =20 if (!op->addr.nbytes || !op->data.buf.out) --=20 2.34.1 From nobody Tue Sep 29 06:08:43 2026 Received: from mx0b-0002e601.pphosted.com (mx0b-0002e601.pphosted.com [148.163.154.28]) (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 E2BCE3C1D73; Tue, 11 Aug 2026 18:35:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=148.163.154.28 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786473312; cv=fail; b=Jc8nfznIJBzOnt+nQITj2QQ7cidjxPRosd4EfiIyOQ4uRTFksAtO55fxHaPqs8+Opnsxc7jH3A0B7UKDeMlPxWDzDY19U2B/EeEbX/P7AzqlNa6XrvnSL+2p8YoMVo1tlqhZb4Rkc7ut2W6Hwf+k0c6BjZR8qqL7Xl0rYv30TLA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786473312; c=relaxed/simple; bh=F/AnUyhlV2AtS07KGqLS/htPuNT5wzyKdLdJIRHf0Yg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=KalGT9oS3gwDNu/b2/8po4o62fSLIn7HJk6UdBJsddYPkrOKJtAKc0NIJyPOQxysjr3Cvkp17b0lv0Abfu9G7ILopPJK6Lkle22pdU5SCDuv8mrMeTQi/GYeXtrHCK8vtCukvqWWL68J8t/cpkZIyLcaP5iqZaQfNqAmwGTmxoM= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b=KXyDUeW2; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=MbrejMw3; arc=fail smtp.client-ip=148.163.154.28 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b="KXyDUeW2"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="MbrejMw3" Received: from pps.filterd (m0374955.ppops.net [127.0.0.1]) by mx0b-0002e601.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 67BGMcJd2174910; Tue, 11 Aug 2026 13:35:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint-05-2026; bh=Tt2uwvzIqMNehFK76PrQJ6oaooM0SB13UAqWfokUR pU=; b=KXyDUeW2ISmVZ+b/UqMP3eNIuS/n2NqQgbstkjfUkZQmoNiUTqjiUFNx5 AYjO4rzqTwM/rMaEOWxIoYuJQ9l2Etb4BXz0ttTDoIax1mw8BMzXR3FJdWf+tOwn Uqo6F86vfvd90HWibu/F0A5pyA/Np6wUhugOtkd6yQYfdD5IkeRZ77XweMnLrfVD mAhWJq9wTT/piJ5B1brkpwUIkS4WFlvUSR9VVRAkzA5y/dDYGpgzXxNq+Ct+5AgL AlfiJrFd5HedVeM5VtnaUEUHKoss9Sanlax5TzQtV7oHG/8txpQ4b5ywp7FYFCsp EQMQ1gm+cj62H512nYxuGtY8VTyRQ== Received: from ch1pr05cu001.outbound.protection.outlook.com (mail-northcentralusazon11010071.outbound.protection.outlook.com [52.101.193.71]) by mx0b-0002e601.pphosted.com (PPS) with ESMTPS id 4g00w4uj4q-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 11 Aug 2026 13:35:00 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=BQnXqeSeWaaFRfzsS9mCh4BzsHaK4ID4037DUP8gsUT7Z5EWFL5XWYf6YVX/4YJotCjklCGHIUkSZnIiiiPT/xlR5aXaKg9BpLjsMseP9ejql7Hqi+U8gqhJXMqPEwcwqZnE3FhiHO6+8QdFTjGcCqm74E/Ww787cqh+/YQCgTIywcLRNXHMHMg+pW3oisH2H+GZMeIXwxDw5g3Sp6iZF1XeowcIqQeUADbOUlXQtvsaFKq615Zs5xxqyNALpY2dPJoTeuKrXMs/HaMbe4rnP3E879LAym66gU1czLg2ztMGIyOR75bLzwTy/lMTA0+6fo8/ogmnfbs283SfdcM9rA== 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=Tt2uwvzIqMNehFK76PrQJ6oaooM0SB13UAqWfokURpU=; b=lVWmujQjLORBMUFl++fdbMo34U5Dir8CF0ZxqBAXtlT+oNMdUmJf8QyTmnLBcg6o681U7QeYmkEBuzRuat2lJ0ti0WDA8fTB/W5uuMZ/QSy7C6towWoMdUCX/2o4eKsOV4T0atGgrqqvCaOVi3msvTfoaDo6Lra8Gz3LVEE5gcz41q5A84eO2fa2CXn3ldrVOKHGBDNItnxSJZYUSb0AQ5CFKnbIlEzRtLwJmE+HTc/fUEePNjIHdhKsRokUvOfjwHQhw87tkYpP/zh3nYI7b+vl1wXMrcArlo3HIjqL4lRJkadPhazxCE1Wpaf/kt2BySgB/4MHZOdL6O3Ut4LeLw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 198.47.21.194) smtp.rcpttodomain=lists.infradead.org smtp.mailfrom=ti.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Tt2uwvzIqMNehFK76PrQJ6oaooM0SB13UAqWfokURpU=; b=MbrejMw3jpbzvOS6hSP2ISH2M/WxYuI9nOP3u3MJwsvhRouHLOT10EW0AkEmtmfW7lCcGaBYwzzRi4k1D4TRcd/aJhUafZ5E4W6Qd4tYb8HDrbEGihNnlIeqMu/+hxStvRRgGLKoWafs16HaacV6+hHvTEq41Wx9H/M3WqIDPPs= Received: from CH2PR02CA0016.namprd02.prod.outlook.com (2603:10b6:610:4e::26) by PH7PR10MB6578.namprd10.prod.outlook.com (2603:10b6:510:205::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.292.25; Tue, 11 Aug 2026 18:34:48 +0000 Received: from CH1PEPF0000AD79.namprd04.prod.outlook.com (2603:10b6:610:4e:cafe::98) by CH2PR02CA0016.outlook.office365.com (2603:10b6:610:4e::26) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.315.12 via Frontend Transport; Tue, 11 Aug 2026 18:34:45 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 198.47.21.194) smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ti.com; Received-SPF: Pass (protection.outlook.com: domain of ti.com designates 198.47.21.194 as permitted sender) receiver=protection.outlook.com; client-ip=198.47.21.194; helo=flwvzet200.ext.ti.com; pr=C Received: from flwvzet200.ext.ti.com (198.47.21.194) by CH1PEPF0000AD79.mail.protection.outlook.com (10.167.244.57) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.315.6 via Frontend Transport; Tue, 11 Aug 2026 18:34:44 +0000 Received: from DFLE211.ent.ti.com (10.64.6.69) by flwvzet200.ext.ti.com (10.248.192.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Tue, 11 Aug 2026 13:34:18 -0500 Received: from DFLE201.ent.ti.com (10.64.6.59) by DFLE211.ent.ti.com (10.64.6.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Tue, 11 Aug 2026 13:34:18 -0500 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) by DFLE201.ent.ti.com (10.64.6.59) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Tue, 11 Aug 2026 13:34:18 -0500 Received: from santhoshkumark.dhcp.ti.com (santhoshkumark.dhcp.ti.com [10.24.52.55]) by lelvem-mr06.itg.ti.com (8.18.1/8.18.1) with ESMTP id 67BIXIe3659766; Tue, 11 Aug 2026 13:34:13 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , Subject: [PATCH v7 11/18] spi: cadence-quadspi: enable PHY for direct reads Date: Wed, 12 Aug 2026 00:03:06 +0530 Message-ID: <20260811183313.1550425-12-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260811183313.1550425-1-s-k6@ti.com> References: <20260811183313.1550425-1-s-k6@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000AD79:EE_|PH7PR10MB6578:EE_ X-MS-Office365-Filtering-Correlation-Id: 10ce881b-4cf2-4f6f-6253-08def7d7371a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700016|1800799024|82310400026|23010399003|376014|7416014|56012099006|10067099003|6133799003|18002099003|22082099003|921020; X-Microsoft-Antispam-Message-Info: X0JoRnAHNCbbV8PbxzHGUt+zpF/gBTPkcvMFCweqDRfdx1z1qd9wWjnkXxjjGi4pJbNLDAyih8XIzQyxnI2KFNJkOqdcLtcp6+KZlCNhD5r/TZ0PkGeAefyqsu7d4laScD7a0aZ7UB5/zI6zh5g/zlDZijR/ks99yBEuGsbDi1torqcX/TMWZ0huqo+V12S6MlhM5kCqUCzirNbac73Td5SzaKekdRcDEYHWIahwG0uRl059ar1UibJereYDQDDBrQsIxLLM/SJmOsFQxkUqIk625L82SFXMFfuTpWGvWj9/jhkE2umYSn6+jfM/DCTtHjy5z3Y1RlGCn0skASsrxwNRDrwwLDlkaSIpdOHx6GuH7dnnBN7SHuhY8JH0Qslkb2jMLljmIBLRwy/9ebxOgZhIEljbWyiKj7Llkr8DVSBO2d/DsOzTHLfXqgqlGGiiDzwiO+pB6ajEiK+2+VdbzILh2UYDHcE4t6p5CnNxdjPGOqYeSkXeDjuQtPfr8tekjLTG6xU7oOxpl9Xy+FuYN3wc5OBO8XFLSAXoSNeLxqRKpeac9W25jp2xYdakuofnhuHt8bVUwL2Wxmycz4B0/g0DxfPw/yhOp11Y/sRqNAZS/3uNxl3K4bw5QpqxG8xTMxsTntuSecP1nNm3eCwf1YfkhzS83z9sy2M38fEv5HnJqmdFLDR5t0lW2EFn4AfFfXo+Yrd0tQigZ23QOxp9jGy6c3hR0vj3TBipS6G5FYkjY3k6iCpHT+trxeTQirg9 X-Forefront-Antispam-Report: CIP:198.47.21.194;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:flwvzet200.ext.ti.com;PTR:ErrorRetry;CAT:NONE;SFS:(13230040)(36860700016)(1800799024)(82310400026)(23010399003)(376014)(7416014)(56012099006)(10067099003)(6133799003)(18002099003)(22082099003)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: TbQJB3mXuh4RCdJwc6Xmss1RkIogp0IdX2tLAnumxT7DZrpd9vL1TlQDTl77kmlpwtBbDHVuy6BdvGsHqOmHaYuCQwap27cXwZAR7eAIlDWMMWkx9t0iwZp9EhWqa+YRu6W+tIHVkHxAh0YijpE68s65/zhTcTb5orgM0ss75rmGe/5x7oda5ESK43JI2CH/drwlZPpWqkVgkq+hGzXPflAva05Nth12auZr+TCn2Bi8aUcwtWMEVKDAa+o0G/Og5Cmkd7vGFtts6aHDBUNdel6G2HlxEU2VoPBqVAu6XV1utuCc3ecAeqQXg8DXAikB++67eSuCWvpe+Nsl3AW4VT1V2LxYYnSkQTCVpOLDXqP3NUH7tiB6pZuGUDUVU6IGCumQfVb26bZYJi21ex3hnYPsvFQ/yIHbC8aqSzfc2sFKOWQnD414LxBhTf9V6vLp X-Exchange-RoutingPolicyChecked: GIpLPqYC18RECghvJUGuv7K28Fig5dRgZSJ5FW85maHghfFrc2HOiHUgjjXNPeCChzbQLnJ4ytnEKXNTWd1ec/rqFzD0C+RBJGDMuEck5dQVyhnHoqFRf+sMzVn4bk5Dh2QJD3RqKFF8DCgmfecz3ihLUmuySGeCkJZfR2IwgciLa6RbnmvlmaTOeYcRDrh2xow7ic/C2+f7pg9+YIg8yYs4nZXujqvmhGXTbtPva/wh5sX4Kwvfm4YwAgiHNkwqo/f9PwnJqf9prc63BG0CZtozqGjlHw5xX+v8M/Ny1hZ7M0kz4CLlwZc+6EACE9I+QCYIqG8MO2LaCWdCTKMqEw== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Aug 2026 18:34:44.6754 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 10ce881b-4cf2-4f6f-6253-08def7d7371a X-MS-Exchange-CrossTenant-Id: e5b49634-450b-4709-8abb-1e2b19b982b7 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=e5b49634-450b-4709-8abb-1e2b19b982b7;Ip=[198.47.21.194];Helo=[flwvzet200.ext.ti.com] X-MS-Exchange-CrossTenant-AuthSource: CH1PEPF0000AD79.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR10MB6578 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODExMDE1NiBTYWx0ZWRfX3ERnjMTTuMC8 QJDHiSvEvT+XnC29QylcNSp8PXCFVpX9NPtSmVXfUgr2in8FP2MRBR9M5hpMEvCBRdm4cHe5Qkf KQlx5kfnTKE6LlJNlytWGocjxC/bQn8I0vjbPP2ezlXv1ZBhh9gGZsS4L7zeIwDpchY8ybNSL92 IClOg6uRP22On41tOZiPte8X1zhMgTxoW+S2qcC0LXRV3J9+Wg8auHfck/lOpX1J8Y2DDI1/Z36 bWEG9YG2fHHawdqf5TkgXBNtC8Hky3WPGWog8u6u30pk0ZLQ1IcedWtDFKU2MTUDdYgK3BhVaHB MfMr1RqKwPLcESVSFW1i3SAzKFUVutvfZPYSr+X0PGMTPAEkobvcwN7VGYTAgPJJANiIIizWHxp wuP9dgsGKC1jFk7OSci2FrzvRMZtEnj6igJFnV+m8Jd+dWXuZdMuxasXA3c3rzg9nNsnMLb4Zli rFYzkIBBz3e8yyHBi+Q== X-Proofpoint-ORIG-GUID: P-ezgm4B89xyBlaze4ThOSe2qe27gATt X-Authority-Analysis: v=2.4 cv=KZ/idwYD c=1 sm=1 tr=0 ts=6a7b6b54 cx=c_pps a=/fsfGrOPy16csppsbskbtg==:117 a=iwqwCZQqcuTv3JOpYdM7/Q==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=Sv0fKeRqtYgA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=fPAWb5peG099m5CrUpKH:22 a=sozttTNsAAAA:8 a=DtXw2DrE-T2x2gJjnU0A:9 X-Proofpoint-GUID: P-ezgm4B89xyBlaze4ThOSe2qe27gATt X-Proofpoint-Spam-Info: AW1haW4tMjYwODExMDE1NiBTYWx0ZWRfX2twu+OvHc7Jt mwZJhr9Z0PQhqlX90MLENXybxf+Z5Y4qlzF1aO/GUtl704guGOMCnVydQsQiuUfObXz7bEYvGtA qyFvGRSafZObSqZRwSNPD/yH9E2g/zQ= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-11_04,2026-08-10_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 adultscore=0 spamscore=0 suspectscore=0 clxscore=1015 phishscore=0 lowpriorityscore=0 malwarescore=0 priorityscore=1501 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608110156 Content-Type: text/plain; charset="utf-8" Add cqspi_tune_phy() to toggle PHY mode around a DMA transfer. On enable: reprogramme the DLL from the per-CS calibration result when the hardware values differ (handles alternating PHY reads across two chip selects with different calibration), configure read-capture for the tuned delay, assert PHY_EN and PHY_PIPELINE in CONFIG, and decrement the dummy cycle count by one since the PHY data-capture pipeline absorbs that latency. The original count is saved in cqspi->phy_saved_dummy so the disable path restores it exactly, handling the case where the original count was zero. On disable, all settings are reversed using the saved count. Add cqspi_use_tuned_phy() predicate: PHY is activated only when calibration completed successfully and the op frequency equals the post-config rate. For direct reads, PHY is used only when both the start address and end address are 16-byte aligned. Unaligned transfers fall back to non-PHY DMA. Signed-off-by: Santhosh Kumar K --- drivers/spi/spi-cadence-quadspi.c | 119 +++++++++++++++++++++++++++++- 1 file changed, 118 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-qu= adspi.c index 99a0ec0e769c..8903b4cf4f6f 100644 --- a/drivers/spi/spi-cadence-quadspi.c +++ b/drivers/spi/spi-cadence-quadspi.c @@ -1074,6 +1074,102 @@ static int cqspi_resync_dll(struct cqspi_st *cqspi) return ret; } =20 +static int cqspi_tune_phy(struct cqspi_flash_pdata *f_pdata, bool enable) +{ + struct cqspi_st *cqspi =3D f_pdata->cqspi; + void __iomem *reg_base =3D cqspi->iobase; + u32 reg; + u8 dummy; + int ret; + + ret =3D cqspi_wait_idle(cqspi); + if (ret) + return ret; + + if (enable) { + /* + * CQSPI_REG_PHY_CONFIG holds the RX/TX delay line tap counts + * and is a single global register with no per-CS equivalent. + * Reprogramme and resync the DLL when the active device's + * calibrated values differ from what is currently in hardware, + * which happens when alternating PHY reads between two chip + * selects with different calibration results. + */ + reg =3D readl(reg_base + CQSPI_REG_PHY_CONFIG); + if (((reg >> CQSPI_REG_PHY_CONFIG_RX_DEL_LSB) & + CQSPI_REG_PHY_CONFIG_RX_DEL_MASK) !=3D f_pdata->phy_setting.rx || + ((reg >> CQSPI_REG_PHY_CONFIG_TX_DEL_LSB) & + CQSPI_REG_PHY_CONFIG_TX_DEL_MASK) !=3D f_pdata->phy_setting.tx) { + cqspi_set_dll(reg_base, f_pdata->phy_setting.rx, + f_pdata->phy_setting.tx); + ret =3D cqspi_resync_dll(cqspi); + if (ret) + return ret; + } + + cqspi_readdata_capture(cqspi, !f_pdata->use_dqs, f_pdata->use_dqs, + f_pdata->phy_setting.read_delay); + + reg =3D readl(reg_base + CQSPI_REG_CONFIG); + reg |=3D CQSPI_REG_CONFIG_PHY_EN | CQSPI_REG_CONFIG_PHY_PIPELINE; + writel(reg, reg_base + CQSPI_REG_CONFIG); + + /* + * The PHY data-capture pipeline absorbs one dummy cycle's + * worth of latency; reduce the count to avoid over-compensation. + * Save the original count so the disable path can restore it + * exactly, regardless of whether the original was zero. + */ + reg =3D readl(reg_base + CQSPI_REG_RD_INSTR); + dummy =3D FIELD_GET(CQSPI_REG_RD_INSTR_DUMMY_MASK + << CQSPI_REG_RD_INSTR_DUMMY_LSB, + reg); + cqspi->phy_saved_dummy =3D dummy; + if (dummy) + dummy--; + reg &=3D ~(CQSPI_REG_RD_INSTR_DUMMY_MASK + << CQSPI_REG_RD_INSTR_DUMMY_LSB); + reg |=3D FIELD_PREP(CQSPI_REG_RD_INSTR_DUMMY_MASK + << CQSPI_REG_RD_INSTR_DUMMY_LSB, + dummy); + writel(reg, reg_base + CQSPI_REG_RD_INSTR); + + ret =3D cqspi_wait_idle(cqspi); + if (ret) { + reg =3D readl(reg_base + CQSPI_REG_CONFIG); + reg &=3D ~(CQSPI_REG_CONFIG_PHY_EN | + CQSPI_REG_CONFIG_PHY_PIPELINE); + writel(reg, reg_base + CQSPI_REG_CONFIG); + reg =3D readl(reg_base + CQSPI_REG_RD_INSTR); + reg &=3D ~(CQSPI_REG_RD_INSTR_DUMMY_MASK + << CQSPI_REG_RD_INSTR_DUMMY_LSB); + reg |=3D FIELD_PREP(CQSPI_REG_RD_INSTR_DUMMY_MASK + << CQSPI_REG_RD_INSTR_DUMMY_LSB, + cqspi->phy_saved_dummy); + writel(reg, reg_base + CQSPI_REG_RD_INSTR); + } + return ret; + } + + cqspi_readdata_capture(cqspi, !cqspi->rclk_en, false, + f_pdata->read_delay); + + reg =3D readl(reg_base + CQSPI_REG_CONFIG); + reg &=3D ~(CQSPI_REG_CONFIG_PHY_EN | + CQSPI_REG_CONFIG_PHY_PIPELINE); + writel(reg, reg_base + CQSPI_REG_CONFIG); + + reg =3D readl(reg_base + CQSPI_REG_RD_INSTR); + reg &=3D ~(CQSPI_REG_RD_INSTR_DUMMY_MASK + << CQSPI_REG_RD_INSTR_DUMMY_LSB); + reg |=3D FIELD_PREP(CQSPI_REG_RD_INSTR_DUMMY_MASK + << CQSPI_REG_RD_INSTR_DUMMY_LSB, + cqspi->phy_saved_dummy); + writel(reg, reg_base + CQSPI_REG_RD_INSTR); + + return cqspi_wait_idle(cqspi); +} + static int cqspi_versal_indirect_read_dma(struct cqspi_flash_pdata *f_pdat= a, u_char *rxbuf, loff_t from_addr, size_t n_rx) @@ -1524,6 +1620,14 @@ static ssize_t cqspi_write(struct cqspi_flash_pdata = *f_pdata, return cqspi_indirect_write_execute(f_pdata, to, buf, len); } =20 +static bool cqspi_use_tuned_phy(struct cqspi_flash_pdata *f_pdata, + const struct spi_mem_op *op, + u32 post_config_max_speed_hz) +{ + return f_pdata->use_tuned_phy && + op->max_freq =3D=3D post_config_max_speed_hz; +} + static void cqspi_rx_dma_callback(void *param) { struct cqspi_st *cqspi =3D param; @@ -1629,6 +1733,7 @@ static int cqspi_direct_read_execute(struct cqspi_fla= sh_pdata *f_pdata, loff_t from =3D op->addr.val; size_t len =3D op->data.nbytes; u_char *buf =3D op->data.buf.in; + int ret; =20 if (!cqspi->rx_chan || !virt_addr_valid(buf) || len < CQSPI_PHY_MIN_DIRECT_READ_LEN) { @@ -1636,7 +1741,19 @@ static int cqspi_direct_read_execute(struct cqspi_fl= ash_pdata *f_pdata, return 0; } =20 - return cqspi_direct_read_dma(f_pdata, buf, from, len); + if (!cqspi_use_tuned_phy(f_pdata, op, post_config_max_speed_hz)) + return cqspi_direct_read_dma(f_pdata, buf, from, len); + + if (!IS_ALIGNED(from, 16) || !IS_ALIGNED(from + len, 16)) + return cqspi_direct_read_dma(f_pdata, buf, from, len); + + ret =3D cqspi_tune_phy(f_pdata, true); + if (ret) + return ret; + ret =3D cqspi_direct_read_dma(f_pdata, buf, from, len); + cqspi_tune_phy(f_pdata, false); + + return ret; } =20 static ssize_t cqspi_read(struct cqspi_flash_pdata *f_pdata, --=20 2.34.1 From nobody Tue Sep 29 06:08:43 2026 Received: from mx0b-0002e601.pphosted.com (mx0b-0002e601.pphosted.com [148.163.154.28]) (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 5A9F93D891F; Tue, 11 Aug 2026 18:35:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=148.163.154.28 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786473314; cv=fail; b=ixXFuwKlHKuHei+QHqMHNnY1m0p6HnzKTQF+hJTSekHwNwqAB3lUMBwShr+n35Hj5iZ8dL4XjeWdgn2QMuivtTyXMZHO7S/pV3QWR3thgTxopOa9QeZ0nqUNcRRR67jBNba2UEgN5OUz6rXrNL3i/ccAk/7wgJiOJw9NjoSlo4s= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786473314; c=relaxed/simple; bh=hq3CAzkpUTFk1VJMd1fRN0aOyH91Gsjw88BXwndIXfQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=V2Lq4RpaKZ0cEr/H/12wgsVLXWmY+BpP1OtrMTTmSpCkI82dapfejVTNGxd7VBvcMXO1sK98/2BUM2mNXQKyhmWKEn0WcYjUrVgvY08NshLV/81JSplSeWKJstk+y/ragZFAJJop/R6hbGwxoAfqcw4ZXESU/IXNGHqjaww2Z0c= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b=CVK/hsC/; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=bwDu9xgq; arc=fail smtp.client-ip=148.163.154.28 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b="CVK/hsC/"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="bwDu9xgq" Received: from pps.filterd (m0374955.ppops.net [127.0.0.1]) by mx0b-0002e601.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 67BGMa5O2174814; Tue, 11 Aug 2026 13:35:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint-05-2026; bh=320EJlLRqwG8h40qGDXjoLwm6rLEiZlkRgVW5kT+7 i4=; b=CVK/hsC/+AbQ2cwd24hxreD6V8j94Ps1D+sCfmIKPSszKX/zMZGfKvA0/ LlEU/cKxmTxecTnCGcEt/5JTlG1yH/5oPcutI6ghOOyn5CkHWRlDr08Zxr+rrCPT Ay4SzKHf0uLG/8+Q7fDO36Mzhm3YVjRLC7gc8ToqoFDHFPV2If6h/uP1Q880Esrs 4VN2xpwRag/TUSk9Wd32EqmKyqwNNo1WENu9jSavjoHkIhuy1W9aXitfthcO1/o2 7G5bswHw5pPT2GBmJBHvSRKH1JfipsVpjH0Hf1YEx9lDoIlJjKcSl4zewHdKfQdH VOdOyJDPAsreTv7/t/TLjTRl7qK6A== Received: from ch1pr05cu001.outbound.protection.outlook.com (mail-northcentralusazon11010008.outbound.protection.outlook.com [52.101.193.8]) by mx0b-0002e601.pphosted.com (PPS) with ESMTPS id 4g00w4uj4y-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 11 Aug 2026 13:35:00 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=sgm1Pmoi/88ER2/LEPPsivjdgdJpEe7KQ4rpznMSKIAaPBTorElznt6gsg7Zh3EMQTp7y7O5jtDWCr0K8+klmsyrdvHiJtdvSt6pfTkimCUM6P/5fpVz7Qz6/LXihfmk/v3Cuu0q+HNcoW886MR7s+W2nCSNPn8w1D7IrJWab3poiN6zipK/S/RY+w72aN+5QVAGlp4spFZ8sCA9EpKyLNYebYB3X0aFLq2TqWXYmMpzvWnxhWaIJ4ydinli0mAkp/H69C94gjDEK0EB3zGd1p9XPD9c0j/x5mR6Tm4h6z0XeuqFUuTv+ZCAj3IpihOpae+IEzbhxTz5P1W4BXmr3w== 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=320EJlLRqwG8h40qGDXjoLwm6rLEiZlkRgVW5kT+7i4=; b=zH4iqARXpepocEsQN5HslrMOj3QkoPIfTer6GNU+6yjZFrtKXI/Z9dqHNO2q6rbAqAyMlQ9o51kP1kQ3eQIzj8IDWDoHMSdbhjtdkNPf2lWpQZtbyAeKwz3nc3xwA5vr77nMHOABNSbKVZwtq9M1hYLSYnKm8jiTOa+o7/s2e9jJls0+o3Q+PXPbQZkQsqy6AmUa2ySxprCyW8GV7jFXfBc50fVS5WT7SOJlKrSJDcRTfZCRCkUf3k6wd9G9uXEJoLvgirz2uVPIbSjk83z3IufCJ3p8lH/mlr5AhNk3yU0ZLC4OlqiptRq2LTy1149MQ+o0JXCCGdIS1AGWYBhtnw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 198.47.21.194) smtp.rcpttodomain=lists.infradead.org smtp.mailfrom=ti.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=320EJlLRqwG8h40qGDXjoLwm6rLEiZlkRgVW5kT+7i4=; b=bwDu9xgqQ84kcxfgEXiin6tNQmdA3r+OFGmYkhXBWWNWVPXrinyFYG0+6MXMpf0EwMXzQNwbt2xdu07DRCTQ/1UtvELkxvMJ+VVggkjenr3B2n/GMXDRUgcLcECUfEb7Vu8Xcbj36iREB/aKVYvr9a+ErJRDLn1TFP8Yqtbly8Q= Received: from CH2PR08CA0029.namprd08.prod.outlook.com (2603:10b6:610:5a::39) by DS0PR10MB8173.namprd10.prod.outlook.com (2603:10b6:8:1f9::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.315.11; Tue, 11 Aug 2026 18:34:54 +0000 Received: from CH1PEPF0000AD76.namprd04.prod.outlook.com (2603:10b6:610:5a:cafe::58) by CH2PR08CA0029.outlook.office365.com (2603:10b6:610:5a::39) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.292.25 via Frontend Transport; Tue, 11 Aug 2026 18:34:54 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 198.47.21.194) smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ti.com; Received-SPF: Pass (protection.outlook.com: domain of ti.com designates 198.47.21.194 as permitted sender) receiver=protection.outlook.com; client-ip=198.47.21.194; helo=flwvzet200.ext.ti.com; pr=C Received: from flwvzet200.ext.ti.com (198.47.21.194) by CH1PEPF0000AD76.mail.protection.outlook.com (10.167.244.53) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.315.6 via Frontend Transport; Tue, 11 Aug 2026 18:34:53 +0000 Received: from DFLE214.ent.ti.com (10.64.6.72) by flwvzet200.ext.ti.com (10.248.192.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Tue, 11 Aug 2026 13:34:23 -0500 Received: from DFLE206.ent.ti.com (10.64.6.64) by DFLE214.ent.ti.com (10.64.6.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Tue, 11 Aug 2026 13:34:23 -0500 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) by DFLE206.ent.ti.com (10.64.6.64) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Tue, 11 Aug 2026 13:34:23 -0500 Received: from santhoshkumark.dhcp.ti.com (santhoshkumark.dhcp.ti.com [10.24.52.55]) by lelvem-mr06.itg.ti.com (8.18.1/8.18.1) with ESMTP id 67BIXIe4659766; Tue, 11 Aug 2026 13:34:18 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , Subject: [PATCH v7 12/18] spi: cadence-quadspi: enable PHY for indirect writes Date: Wed, 12 Aug 2026 00:03:07 +0530 Message-ID: <20260811183313.1550425-13-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260811183313.1550425-1-s-k6@ti.com> References: <20260811183313.1550425-1-s-k6@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000AD76:EE_|DS0PR10MB8173:EE_ X-MS-Office365-Filtering-Correlation-Id: ff3fdb63-0b34-4a69-cee7-08def7d73c54 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|23010399003|36860700016|82310400026|1800799024|7416014|376014|10067099003|921020|6133799003|56012099006|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: Ek2hI1FKEZp/ySqNomUVWA4+4SOTQiUjq5QtjDYseknoru/KFkZJubmm73nE2+HUhsZgOInY8QJR3m54hDvppEau9ppMjamdUVqogbWuOUi2TsPSB5xVzrLyir7s9R28jKDXA4Ms43bCE5CX83wprYFnsy4+4Wkk3+uuQWrV75z2wTrdJ+3r2c+In/B+9bZg18xFP5vc3gE5Wyz8geMTuJ5hp00Q8nMajrI2BFBoOzL8/W36XCyaZuOp7nzTymR+x2r5xE1O/a0257Y3uCYR3sHwvs1L5fI8u0t4NcWhKpyq/rS9gKUk/OYI9Wbtip4tKAJ7XFlFxI4MqBCeYzpwgIJJ68m7fZtbj9M5Dk7oA4PuDKFzDRAnU+3gac204e5gX1RN5MAtHke/f/gEdd69avhpzvwTsp9RZ4pTzqfxZWiPBJ/QsoojHo3bBT0cjipXvYhJDB3kBmNk1RPZWgx3SN8RIyaJCSxOAPorq3ZQ2R8XoMoQgHA0vx3Kx5yoxb4LDISY6Gts3GF31Sk7co1iU7Ex7WB/cRSWkFEdiPtOxCpuz5oqHqBaP0L1nfKnEdeilNQUNvgW+ET0Ns++9JIVcgVtCcX1HjoJj5owsin1fKyOJ5i0okEgZz6Gq4No1PTTshDxQN20U69/NIWHlvDMkWlab7P4+gde6iTd5YnsQRNyGaDbXzQUXyXYgokpShMqL6vB7bzNpq2wGwN8pc0+lA3qByU5WkYInwVHK6o1ua6ERr6CtlF9pDnMfteMTEJh X-Forefront-Antispam-Report: CIP:198.47.21.194;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:flwvzet200.ext.ti.com;PTR:ErrorRetry;CAT:NONE;SFS:(13230040)(23010399003)(36860700016)(82310400026)(1800799024)(7416014)(376014)(10067099003)(921020)(6133799003)(56012099006)(18002099003)(22082099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: i1AQhxbffWW3LH5E5XnXQgRNWags2lmILsYJdK4QUG6rs7HaSqX/7/HRd6P/f157G5pi+flvto6fGg03wnDVog8/aO8nwxbBCQRO1QEh6moJ5BccZWZZ3KHlnTUrW8NhCrs+owQzisAQViZ8WphVDmh8zhw93f6RDOMvYHLXk6SzjMWWwVHrgeqPgqk8TZ/qBElnidUE9OPht66aAUOa+/WoJTEr8gKpFcSbp2osFgFFRZ22IdsvfEgP8spxqMT43s0EWNmiRShWBenKyuo2ZXa6K4aeuwKB8gGWTJTOjv/CjQoflmoGUnFHzx1F8BD4Vd1UjnqIV0pP2IDsBl55K+qtIFyHQVRDYm4IFEdekk95QhJxXqa86L4++ZgFm3NN6TcCaMx3TB4GkS4fmSOPXB1Fsc+c2ER3WONS27CKV58BrvdnQfbVVwZqWKdsm8I8 X-Exchange-RoutingPolicyChecked: FS8GTgRiAGah7eIwL7w2s2t3/jH06/RfNxLqYz+c0R25xTo9ns12FMjXZI+5KaT3QnuxOAywhz54lP47LGBCLEECkn58GJhv51vAR4JjZ9zRiOG2dlYHDD5sMALFEIi6rtwkX4kDENpO5IRdOpLUlUtuaYGM7hGAG+jIopqCwZeUhu2i+CutczXd0v3MfmbAfOHwrfBqaZjEVISjdQyP3hZdQwWsdoe4WWbkb/4P2qkONpr6ai71qKP+2r94HKPQuEdle4cPuIq4yaGNL5SelsaIZDGkXIjSsGhRKqEr2CqBZ/lySmzFlX8DRCVtDtFj1n1fOWgw3pjsF7U48TxL9A== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Aug 2026 18:34:53.4492 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ff3fdb63-0b34-4a69-cee7-08def7d73c54 X-MS-Exchange-CrossTenant-Id: e5b49634-450b-4709-8abb-1e2b19b982b7 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=e5b49634-450b-4709-8abb-1e2b19b982b7;Ip=[198.47.21.194];Helo=[flwvzet200.ext.ti.com] X-MS-Exchange-CrossTenant-AuthSource: CH1PEPF0000AD76.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB8173 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODExMDE1NiBTYWx0ZWRfX1UPXl5TREt4r mpMS2+ejYNTiKWQZk7BhObKO/FNndTIYHJePQbC+G0nj8uKoPgV32pTJj/Em9X08rpFTFEkQvbm zI5m1yn+nQliGdzyhW8Q6XxEJz2KkbQoIOfCnqvsRqQt9ssBSi2gZmfrH5PaGfWDFmKeb5lCuMf z6Puy62MVSiTrGd/9e448HoocuC/7v96cj7s0rYO8/LKmWUXAoT4w3DiDoq/u6ndpFSbqfZMLLf eb2lgzY3ylsnRL74AjA2w/x4hTjLTEZRz+fY6bV4jMEwU3GHeIttHo5j/nJLCX/ApDJSqygWahQ RBB8lQ5b6nXarOyEkZrKf2J6pInCh8/QkqNO9gz0pPUE4lkvutY5LAU4SxvifOn4Ejm1KCF3+UA jPyo91wproftqbfaLMjWSwvv9/I64VtQiMnep3Evbc0jl6MBxSegtBpxioYiwVg7TbXQqjZtxxc e/MiQ3WB53/gI9d3YrQ== X-Proofpoint-ORIG-GUID: WVvVbxXH7Hg_2aqhWod-21F3TQ5xFoZ9 X-Authority-Analysis: v=2.4 cv=KZ/idwYD c=1 sm=1 tr=0 ts=6a7b6b54 cx=c_pps a=97Y4xzKGYTGm8d2IOhb7pg==:117 a=iwqwCZQqcuTv3JOpYdM7/Q==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=Sv0fKeRqtYgA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=fPAWb5peG099m5CrUpKH:22 a=sozttTNsAAAA:8 a=JqbSXTAX1eT4zVGs_pkA:9 X-Proofpoint-GUID: WVvVbxXH7Hg_2aqhWod-21F3TQ5xFoZ9 X-Proofpoint-Spam-Info: AW1haW4tMjYwODExMDE1NiBTYWx0ZWRfX+Y4VPnge3f6b DtePq6MHG/fUI7nNetehwvXcPOOZdC7+804JLzeNxP58CWJHcX61IXVkmfUM6tcjolN96Gq3BNx szZNJoBj94iGSLEQjUnXxSPJhVv0Lj4= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-11_04,2026-08-10_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 adultscore=0 spamscore=0 suspectscore=0 clxscore=1015 phishscore=0 lowpriorityscore=0 malwarescore=0 priorityscore=1501 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608110156 Content-Type: text/plain; charset="utf-8" Enable PHY for indirect writes of at least CQSPI_PHY_MIN_INDIRECT_WRITE_LEN bytes. PHY is activated only when tuning completed successfully and the write op was calibrated at the post-config frequency (phy_write_op.max_freq matches), which restricts PHY writes to NAND devices where a write op template was provided to execute_tuning. NOR flash writes are unaffected. The indirect write is cancelled before disabling PHY in the error path so that cqspi_wait_idle() inside cqspi_tune_phy() does not time out while the controller is still waiting for AHB data. Thread post_config_max_speed_hz from cqspi_mem_process() through cqspi_write() into cqspi_indirect_write_execute() for the frequency check. Signed-off-by: Santhosh Kumar K --- drivers/spi/spi-cadence-quadspi.c | 39 +++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-qu= adspi.c index 8903b4cf4f6f..940cfb72b946 100644 --- a/drivers/spi/spi-cadence-quadspi.c +++ b/drivers/spi/spi-cadence-quadspi.c @@ -157,6 +157,8 @@ struct cqspi_driver_platdata { #define CQSPI_DLL_TIMEOUT_US 300 /* Minimum transfer length to use DMA for direct reads */ #define CQSPI_PHY_MIN_DIRECT_READ_LEN 17 +/* Minimum indirect write length to amortize PHY enable/disable overhead */ +#define CQSPI_PHY_MIN_INDIRECT_WRITE_LEN SZ_1K =20 /* Runtime_pm autosuspend delay */ #define CQSPI_AUTOSUSPEND_TIMEOUT 2000 @@ -1362,18 +1364,32 @@ static int cqspi_write_setup(struct cqspi_flash_pda= ta *f_pdata, =20 static int cqspi_indirect_write_execute(struct cqspi_flash_pdata *f_pdata, loff_t to_addr, const u8 *txbuf, - const size_t n_tx) + const size_t n_tx, + u32 post_config_max_speed_hz) { struct cqspi_st *cqspi =3D f_pdata->cqspi; struct device *dev =3D &cqspi->pdev->dev; void __iomem *reg_base =3D cqspi->iobase; unsigned int remaining =3D n_tx; unsigned int write_bytes; + bool use_tuned_phy_write; int ret; =20 if (!refcount_read(&cqspi->refcount)) return -ENODEV; =20 + /* Use PHY only for large writes at the calibrated rate */ + use_tuned_phy_write =3D n_tx >=3D CQSPI_PHY_MIN_INDIRECT_WRITE_LEN && + f_pdata->use_tuned_phy && + f_pdata->phy_write_op.max_freq =3D=3D + post_config_max_speed_hz; + + if (use_tuned_phy_write) { + ret =3D cqspi_tune_phy(f_pdata, true); + if (ret) + return ret; + } + writel(to_addr, reg_base + CQSPI_REG_INDIRECTWRSTARTADDR); writel(remaining, reg_base + CQSPI_REG_INDIRECTWRBYTES); =20 @@ -1452,15 +1468,26 @@ static int cqspi_indirect_write_execute(struct cqsp= i_flash_pdata *f_pdata, =20 cqspi_wait_idle(cqspi); =20 + if (use_tuned_phy_write) + cqspi_tune_phy(f_pdata, false); + return 0; =20 failwr: /* Disable interrupt. */ writel(0, reg_base + CQSPI_REG_IRQMASK); =20 - /* Cancel the indirect write */ + /* + * Cancel the indirect write before disabling PHY so that + * cqspi_wait_idle() inside cqspi_tune_phy() does not time out + * while the controller is still waiting for AHB data. + */ writel(CQSPI_REG_INDIRECTWR_CANCEL_MASK, reg_base + CQSPI_REG_INDIRECTWR); + + if (use_tuned_phy_write) + cqspi_tune_phy(f_pdata, false); + return ret; } =20 @@ -1590,7 +1617,8 @@ static void cqspi_configure(struct cqspi_flash_pdata = *f_pdata, } =20 static ssize_t cqspi_write(struct cqspi_flash_pdata *f_pdata, - const struct spi_mem_op *op) + const struct spi_mem_op *op, + u32 post_config_max_speed_hz) { struct cqspi_st *cqspi =3D f_pdata->cqspi; loff_t to =3D op->addr.val; @@ -1617,7 +1645,8 @@ static ssize_t cqspi_write(struct cqspi_flash_pdata *= f_pdata, return cqspi_wait_idle(cqspi); } =20 - return cqspi_indirect_write_execute(f_pdata, to, buf, len); + return cqspi_indirect_write_execute(f_pdata, to, buf, len, + post_config_max_speed_hz); } =20 static bool cqspi_use_tuned_phy(struct cqspi_flash_pdata *f_pdata, @@ -1810,7 +1839,7 @@ static int cqspi_mem_process(struct spi_mem *mem, con= st struct spi_mem_op *op) if (!op->addr.nbytes || !op->data.buf.out) return cqspi_command_write(f_pdata, op); =20 - return cqspi_write(f_pdata, op); + return cqspi_write(f_pdata, op, mem->spi->post_config_max_speed_hz); } =20 static int cqspi_exec_mem_op(struct spi_mem *mem, const struct spi_mem_op = *op) --=20 2.34.1 From nobody Tue Sep 29 06:08:43 2026 Received: from mx0a-0002e601.pphosted.com (mx0a-0002e601.pphosted.com [148.163.150.75]) (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 4D343390C8E; Tue, 11 Aug 2026 18:35:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=148.163.150.75 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786473327; cv=fail; b=c+xB9jtCQfbn9ni4a3gF2tbRVDdlmNcNnE88ZfyHhQdxgUzT+3IL31l6dTxxqAB1BtE+lYW7ooHc3hPOoAluUX8lfbnyho/8+S7+tBUULAWnjfujqouwe9YkB4xoqLTPqHTMAAL7KWTsL6hX7weJKNj3efsrEtBZTmzSckEMb3E= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786473327; c=relaxed/simple; bh=WKVXHJB0AdeEulQEB73WpP8Du4kcQpGopGcbjSG6Kf0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YLQ3vFoBE9E3nz1+Uq9rOKWfngL1pLzVgzHCR7CH9/BKIj3+I5zGqT+E2EHX+F116mwcKNk8ZP6Y2OVR2S/f6jZh5oaiTndzwIHGjteVKrDD23FkJSY+MkZ7RFABnOUmJJAOavZ1wfwV6kwoGhhs76CexrtQm+DnHZP3FXU4vUc= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b=OwOPwgBP; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=QaSaWqvg; arc=fail smtp.client-ip=148.163.150.75 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b="OwOPwgBP"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="QaSaWqvg" Received: from pps.filterd (m0380145.ppops.net [127.0.0.1]) by m0380145.ppops.net (8.18.1.11/8.18.1.11) with ESMTP id 67BGMKDj2014181; Tue, 11 Aug 2026 13:35:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint-05-2026; bh=+X4OnFKe7SEw4gZmEqh997XautkroE44X9Vjvdyek nY=; b=OwOPwgBPguLIhSFb5vVzU9xnhrQYa8NflNjXQ7VtrmvZmXuaieAfKk5iC +osZgneelPGS2OnZTO+e4/MTxAB77lN1M3N99QArw/iJQZajr79AIkF3XDlrRuEf phr8hHm4XAPBP9UEN+gOUe5FbUBn2QChUdRQHM5p4U7Xc85uZfWgvOpsl6WRbTW7 UaR3KPaUvlpKSbzTrHOHQo/IuvGm5KdmAbVk+406yjmJHuy/Svs5widb8X13SiPU bC0IiGoLuzS6++YU+K505KQTiGeOKA3jSSoANEHuk+iWmrdY4oRc4VuduCY5UJf4 AuNcuRYKhYOEG3Jr21F19YZxUlIww== Received: from dm1pr04cu001.outbound.protection.outlook.com (mail-centralusazon11010022.outbound.protection.outlook.com [52.101.61.22]) by m0380145.ppops.net (PPS) with ESMTPS id 4g02pbb367-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 11 Aug 2026 13:35:15 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=FDz9fEpdZyBaja33OmC7ZhbauSOlXPDJDxkQk/5jf79DydPPQ1ULH6H2B7ygl/SpxGM2gaES+FCpfJPSFz81KWB4W49UHHsZGo7cMdFOf9Lg8QFFwFVA+HX/KcnzSthKxeOvnDjrlz0n5JnfpDegZCEWpAjQV/2FZU8MvgDNbVyTmiFTvPp7ful4ss7jxQPcq2MbGs5wY3gIovFbYI8PoJt1lh6sKc8gmqcuSUoYh42ajbqv/S9YVWDeB8lNhSjk6YgbqAtLNsETqwatD7lxsJyEgqxcY0QDA6tQYncIkRJX9EQ3VjW4oUitM6l6ZQD05UolsX88ab9P5G4i1OQuCg== 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=+X4OnFKe7SEw4gZmEqh997XautkroE44X9VjvdyeknY=; b=SjSII1Rtjm8d2Ww10I8zt5sNj1THtbc2FhRXLsSAY6c0OBYGM8n+md2egwtoOFu+caRpOoD+BUFTdYHMb8j1KQJ1DQB76lkI7EmgEPOPltFlB/EWz9twkVcRYOS7JAmBR/+73KkT2OPwcb0n0o1UNqK+M3ttTmw30f6mo4y1yCjvC/DLvelDGx4aD/u+gQwZ7GPKzNwMy/MJ0hBEqpwFJ9Hgt8JV8XRStSkT2Ib6jdnypg9bfhzRlNUvuLT3ouZvOktCtLoL10YXjY/POK5ABFrW06lLLppHEapWSoS3psMXKdGsbK2cViTMuRmDiPrI6zH1YR2g1h9ij4lnE/lK3A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 198.47.21.195) smtp.rcpttodomain=lists.infradead.org smtp.mailfrom=ti.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+X4OnFKe7SEw4gZmEqh997XautkroE44X9VjvdyeknY=; b=QaSaWqvgiKkvSag6xG/fITduWf32NjVrdbTByduDR95N0STWhysqdUszH26zbcSH9vmZ4higapL3IhIlGhM6JqETa5UAROcTecaRYS46GoyqwiL9Zr/oUhzEarbUSETVqixe1Ytav0rtkS/DHiBlYx4Q5aB+hghp8Tb915+lNFU= Received: from BN9PR03CA0452.namprd03.prod.outlook.com (2603:10b6:408:139::7) by SA1PR10MB335620.namprd10.prod.outlook.com (2603:10b6:806:51b::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.315.11; Tue, 11 Aug 2026 18:35:12 +0000 Received: from BN3PEPF0000B071.namprd04.prod.outlook.com (2603:10b6:408:139:cafe::6a) by BN9PR03CA0452.outlook.office365.com (2603:10b6:408:139::7) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.315.12 via Frontend Transport; Tue, 11 Aug 2026 18:35:12 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 198.47.21.195) smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ti.com; Received-SPF: Pass (protection.outlook.com: domain of ti.com designates 198.47.21.195 as permitted sender) receiver=protection.outlook.com; client-ip=198.47.21.195; helo=flwvzet201.ext.ti.com; pr=C Received: from flwvzet201.ext.ti.com (198.47.21.195) by BN3PEPF0000B071.mail.protection.outlook.com (10.167.243.116) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.315.6 via Frontend Transport; Tue, 11 Aug 2026 18:35:10 +0000 Received: from DFLE207.ent.ti.com (10.64.6.65) by flwvzet201.ext.ti.com (10.248.192.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Tue, 11 Aug 2026 13:34:28 -0500 Received: from DFLE208.ent.ti.com (10.64.6.66) by DFLE207.ent.ti.com (10.64.6.65) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Tue, 11 Aug 2026 13:34:28 -0500 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) by DFLE208.ent.ti.com (10.64.6.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45 via Frontend Transport; Tue, 11 Aug 2026 13:34:28 -0500 Received: from santhoshkumark.dhcp.ti.com (santhoshkumark.dhcp.ti.com [10.24.52.55]) by lelvem-mr06.itg.ti.com (8.18.1/8.18.1) with ESMTP id 67BIXIe5659766; Tue, 11 Aug 2026 13:34:23 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , Subject: [PATCH v7 13/18] spi: cadence-quadspi: reprogram CS timing on every chip-select switch Date: Wed, 12 Aug 2026 00:03:08 +0530 Message-ID: <20260811183313.1550425-14-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260811183313.1550425-1-s-k6@ti.com> References: <20260811183313.1550425-1-s-k6@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN3PEPF0000B071:EE_|SA1PR10MB335620:EE_ X-MS-Office365-Filtering-Correlation-Id: ba404fed-ffa3-43f1-b3c0-08def7d746a8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|23010399003|82310400026|1800799024|376014|7416014|36860700016|921020|6133799003|10067099003|56012099006|3023799007|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: voJqVUKySXUzmZLNKfZXxJcZCmYGo4H9DSAjTzc0p1uikeeW6FFm534AG1UA+IPfJZjPMIDvHRxaBQ0MMexjjVKwn9r0tDBZeBLEQCO8rlFu2RlmS0A7Q3nBcCVmC222xF2MJoLxjKiADmlwCYd0LgQx80UiwN1wZP10U1yNFaGXzWR92z2WqdhSXcuVze5OO3g9MtS7DUdNTCexCyLwWBuU1Wucm8Nt7oHd+mncBykDRFfx3Nxxe8Ci8EwO16unwSP3DuSWIgu0u6sy772rWjb3IVoSsVz/aQbsF0sraTwekanrsmex4pLD13eGPl2qMyMfRWR/o8nFtPcnlgKzSaeoui8WqdaZwLOJf5xFXKLplWlTXRL1X01fZEbmnEolOzd1fET3Hnz4upn+wU6czTs+mD4TLMZcJzOpFk4Ruw1buysSqeIanwy+aIgK6SG4FxvrO/levy0MU4HakByT6kXmOnynFjByPipS9gLTnjhvlneeyBStUYzx7YW7FdV8JTDlVWUEu189IKX9/FtTaX3VPGDma4SWO6ZaGOL5ztaHiWenl6H5VrzNx9t4GFlEjvU6Wy+2j56cWu5CRPr8w8MydA5pl7pihUrGJsuPJDCHU/13ckz9ttLHmtdBXxbtSCPZNbspMM6LNQ3Z/OXR8pNpLBUoqPjJopOJwo6K+Yeue8wqGvOfG/0ArE3CH30e3hO5P/ukDkCcJ5at2CQjxzCr5py97Aevs2X/inCUJ0LAjOpDvYnMy8G+sC/KFxUt X-Forefront-Antispam-Report: CIP:198.47.21.195;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:flwvzet201.ext.ti.com;PTR:ErrorRetry;CAT:NONE;SFS:(13230040)(23010399003)(82310400026)(1800799024)(376014)(7416014)(36860700016)(921020)(6133799003)(10067099003)(56012099006)(3023799007)(18002099003)(22082099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: jektnbXRyCZvWpVNWRvoBBLjfoKDUfuw5Dm/j0NfkZ06QKJUD/lIQO8emxOveeIkLhJLsvRHbMXhIhPy8dLeoULw/+E4nis19x29xXxsuY3Bw+ELMv99kPRDTYv3rOqtd3hUoLqi3TUQyYjEtdsqxuGCvOT1hkpzTHT46tGQsnz6kf8IJi1SzUf6GHCM6K371uAMXrfQ7naXQSHLnyatQlUdPx8fz2gVwfK10dm40lcTIzFvzaRBDvtk8ivwJppVevjVLrC2FtxJNuMUaeC+otZ3yGB1YDmR0FHVjqeV1Luq9LAb4zpCYqpAaRvSBCIZhuwCAVPYMgmH7Ven0s1n4+gykUMVHIxUm5X5qRnGEIEBnwqSMrIQMKHRUybYjHL3Uodzs4r7eWe1N89/e7zAwr1yIZ1i0bdKgC+cUUOFIVQUKHRSnMxHeDBaf8hgyybi X-Exchange-RoutingPolicyChecked: Nv2VO+nAItBQxyK2Vvnswk1tEXikb74MxFFeuTh1zmibdLj78zOdXTNeBmabqZzZ7AtNhPWptasSti/1iE5eqoDJQ7ZMyS/FR7rvHvQ8Hrfuizp7LuMEL17cy8izVojZH60l1gniCsY2ifuFjT9GcKGw56bZRWIEWfTQUtlY2UH1u1RwQwuACoevwaF5T9C6pO2gUAMPiHFPXab9sDhz0QP5aQeDUiqwV5X2w/ZnvbyQ6NK6JkosbzEUJ53GmhqtA2+m6ejNJb/d1unChhAr7JUQYXMnyM18G0ADyIkzx/znBnNwL/QFHWMRX4eGoXtuJHfUYw/N/U8Ez3anMagPSw== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Aug 2026 18:35:10.7527 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ba404fed-ffa3-43f1-b3c0-08def7d746a8 X-MS-Exchange-CrossTenant-Id: e5b49634-450b-4709-8abb-1e2b19b982b7 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=e5b49634-450b-4709-8abb-1e2b19b982b7;Ip=[198.47.21.195];Helo=[flwvzet201.ext.ti.com] X-MS-Exchange-CrossTenant-AuthSource: BN3PEPF0000B071.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR10MB335620 X-Proofpoint-Spam-Info: AW1haW4tMjYwODExMDE1NiBTYWx0ZWRfX7nibO+D/wdl6 U4Ewh6h0XTbLbO3BGxFzJzHv6LfJtR8UqSEJBWBNL912glq+dXFj0mThXjnas5pd9IYBaR+0uZN 49W8tjN9cH8BEFdHtYPGqGFJFtLOM2g= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODExMDE1NiBTYWx0ZWRfX9zU5Wc1rUoHW VFxCOgRkzNylcUciziJ9LnNVKx3aexaCrzDhXoRrgJSxVJ4WkHSV/dl5NYf995SYpWkFvVKlxzF 4PYsB6P2Ss2YMpT8esxnHoNdBL77s/577yuI9IdEA8dIkJxjVqme8yrAatIbUwwufeQ0JnCDtpa E6XDxqF/T5iBwqmoGUdMO1DoukJrDgoSJgc8ye/42spp8S4d9z1AeQ0p/uBZVlICXD7MZh63k7N +HOKcNS01LkF+YRou/G9ykXbOSovYvovvdaKNpyHJAH3t2Oct5a28OwK1M5+II0NR7MODHoJ6QI tMevp4L6pM7Tb5WG0sD3ejeY7u3t5cMaMyUIrrRjHol+ERCw0iuM7ssE/16BfLsF46RDOmgdYSa 1YO2x9CuouYoOXmpVLx1QNP9ZU5xNcqqMFBaVvlnx5ak+jpNLUb4tPfryhmjKduSexrPJv6wl/+ z6fvU7i3fL8zxhj9wFA== X-Proofpoint-ORIG-GUID: K5qSrjc4sWTDJhzm-4trZV0fCurNM-OO X-Proofpoint-GUID: K5qSrjc4sWTDJhzm-4trZV0fCurNM-OO X-Authority-Analysis: v=2.4 cv=Ic+3n2qa c=1 sm=1 tr=0 ts=6a7b6b63 cx=c_pps a=P7Y/ubs9jOqwJofkHNyo7w==:117 a=tJyPKKxUohctrY4NYmUjkA==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=Sv0fKeRqtYgA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=gO1vWkAQAl3rybz1DQOp:22 a=sozttTNsAAAA:8 a=okWzP3EbMLmikBYkquQA:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-11_04,2026-08-10_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 clxscore=1015 suspectscore=0 bulkscore=0 impostorscore=0 adultscore=0 spamscore=0 priorityscore=1501 lowpriorityscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608110156 Content-Type: text/plain; charset="utf-8" cqspi_configure() only reprogrammed per-device CS timing (CQSPI_REG_DELAY) and the non-PHY read-capture register when the clock frequency changed, not when the chip-select changed. In a multi-device setup where both devices operate at the same frequency, a CS switch leaves the previous device's timing parameters in hardware. Split the update condition: baud rate divisor is updated on clock change only (it is frequency-derived), but the per-device delay and read-capture registers are now updated on any CS or clock switch. Signed-off-by: Santhosh Kumar K --- drivers/spi/spi-cadence-quadspi.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-qu= adspi.c index 940cfb72b946..d4181b501d8d 100644 --- a/drivers/spi/spi-cadence-quadspi.c +++ b/drivers/spi/spi-cadence-quadspi.c @@ -1602,10 +1602,19 @@ static void cqspi_configure(struct cqspi_flash_pdat= a *f_pdata, cqspi_chipselect(f_pdata); } =20 - /* Setup baudrate divisor and delays */ + /* Update baudrate only on clock change. */ if (switch_ck) { cqspi->sclk =3D sclk; cqspi_config_baudrate_div(cqspi); + } + + /* + * Reprogram per-device CS timing and non-PHY read capture on any + * chip-select or clock switch. Without this, two devices at the same + * frequency would each see the other's timing parameters after a CS + * switch, since the lazy clock-only check would never trigger. + */ + if (switch_cs || switch_ck) { cqspi_delay(f_pdata); if (!cqspi->phy_tuning_active) cqspi_readdata_capture(cqspi, !cqspi->rclk_en, false, --=20 2.34.1 From nobody Tue Sep 29 06:08:43 2026 Received: from mx0a-0002e601.pphosted.com (mx0a-0002e601.pphosted.com [148.163.150.75]) (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 73BC23E2AD1; Tue, 11 Aug 2026 18:35:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=148.163.150.75 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786473323; cv=fail; b=U35rPBB0niGm/F/RJVJCz1nhRUu9FUE2HBxfnzFFk7SBI3ndpj4TR2L3zJ2QshCZVBvuBF6YnmVbHO1nTVaU+qUTVc5nHGDftlPSUtml4dXP6xB9KCJwzx81GWOIa4tL4aHoCBqVZxlqVSNyGlw8ypZ5U1ozltFSzrxAI8I5hFI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786473323; c=relaxed/simple; bh=/36EtgSHJjgS4ho34Va/fE/UiN7oZO1CuCAHGVoo6vY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TUys8AkOs5cvCYWjuNjFqqiOfHuNrhvQiAPdVnzQGVg+reINByuJtBgllFQBo2oKtSShiutfpcdKazDvlls1JTePI9T9xKWq1Q3SMvasyySY/CvmC48fC6nFOmiXawqq1BjpkO7fRU1aPCe9nvpHRMkM8OX2AD370c3A9sC3zh8= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b=qI7EGqKd; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=uzp1qasF; arc=fail smtp.client-ip=148.163.150.75 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b="qI7EGqKd"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="uzp1qasF" Received: from pps.filterd (m0384305.ppops.net [127.0.0.1]) by m0384305.ppops.net (8.18.1.11/8.18.1.11) with ESMTP id 67BGM9bg2460642; Tue, 11 Aug 2026 13:35:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint-05-2026; bh=Y5jcawn8CrAjnwc0j/CFtto7zEM1fdC/gjWbyM1Nf eI=; b=qI7EGqKd1+IPxup4nZyook3Zj2tJgZkIcYB3nKtUmd5dfA56aSn94HsEq QX+v3uC4SUmbAeemekVjK0g+lDc3shZB/DE3qR+5/TSVWPwML7DYTXBqrM8dLOSm DYKXpg1qmLcYvmFC7wzzvjM0wSD9iAntXwC5/GJaK/ywhJcH4Bv5y8KAT8AjwvN5 EfB/GjL7HFYJ76ay/QFrYLkoc1zkDU3ZpcQrPv0tNg2W/aDShJ2ps9eGJGS7O27e 7GyHLhVcyTJVuWZGKTbRWYdLEX1a19pLsoCQasLUSXPjjpAvtGzjoLliZuL0I5X+ W3PgRQ9n+I3C+egFtbmy3JHOuLuRA== Received: from dm5pr21cu001.outbound.protection.outlook.com (mail-centralusazon11011039.outbound.protection.outlook.com [52.101.62.39]) by m0384305.ppops.net (PPS) with ESMTPS id 4g00wu3h84-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 11 Aug 2026 13:35:12 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=NTt7HH6QOIXTVh8JR2Y/xeocgG69hrDwc1UeXvaaoJiREA+VlJUF9J+1qdx0CqV1DcHBvhte/fyj+aMPzmUXCEZFBf1D6NuCxGYqO6kJeT/RuF/zgX+AnIY39fbwimoIz160qTLr1UnJRRpOERPs3Jl4aT0CbnpyM8MDB7hKhOh/FvjG277M+a053KNSlAllSpi3QGUTaETDFdD3Jqzs23Ic7J86FsR6MowYCNhbU5R+vE35Yie/I/ySjha0TZFp5DVQQqPtuc4VDS8XL2OnQJV5sMuCjLh+OdCGSZj6QE2bqmHeVI5sfINgAKRqY/rnfdNCJ1RYPSsHW9WbJo17hQ== 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=Y5jcawn8CrAjnwc0j/CFtto7zEM1fdC/gjWbyM1NfeI=; b=yqyCcVvETLQJcS4XyjAyGu4xon5fQPVdNJvgNaQJejRKq9Ch41Sk3zF5mugdb3m4FHX6EdfxDZpp9XcLsde9hxVDuQdzfdxgR8hco0B+zlcE3vYEDU7T4BU3txSD5eyfaKPga7O1AnHagCBd2PZMxFErVU9Ja2gDOetTXTz5+Sfb5M9lXwXvAw4YUwmuUsAEvok+urFgeGtkQtDSXpE4BB1CTg3Q0afDZL54pTCXuIv6weTeh/MeSCFUW1E8RVkliscNO2ovYHmjQGJqbqxZdVCt+pdeCUorehOqnnHQvW70Uu7tnXmUITl/RW5w1kb/Z5u+7PsKvJiKRO1fhYYZaQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 198.47.21.194) smtp.rcpttodomain=lists.infradead.org smtp.mailfrom=ti.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Y5jcawn8CrAjnwc0j/CFtto7zEM1fdC/gjWbyM1NfeI=; b=uzp1qasFLosakRijpRHswINZepceRD7yQMv2tk2n9cJmeWOPTjEDOfL/lxEVsc/rK7or8UXFzEu1a5oihiffKFCr/cyYrR5f0+BXWn1kcfzVV4YsxoIZ+r2oLkJdEh30SDXiq8NyMYtZSPQSZeJi90pFPeWzRhTKNu/95Gpul1k= Received: from CH0PR03CA0440.namprd03.prod.outlook.com (2603:10b6:610:10e::29) by SA1PR10MB7854.namprd10.prod.outlook.com (2603:10b6:806:3a3::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.292.25; Tue, 11 Aug 2026 18:35:08 +0000 Received: from CH1PEPF0000AD79.namprd04.prod.outlook.com (2603:10b6:610:10e:cafe::a9) by CH0PR03CA0440.outlook.office365.com (2603:10b6:610:10e::29) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.315.12 via Frontend Transport; Tue, 11 Aug 2026 18:35:08 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 198.47.21.194) smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ti.com; Received-SPF: Pass (protection.outlook.com: domain of ti.com designates 198.47.21.194 as permitted sender) receiver=protection.outlook.com; client-ip=198.47.21.194; helo=flwvzet200.ext.ti.com; pr=C Received: from flwvzet200.ext.ti.com (198.47.21.194) by CH1PEPF0000AD79.mail.protection.outlook.com (10.167.244.57) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.315.6 via Frontend Transport; Tue, 11 Aug 2026 18:35:06 +0000 Received: from DFLE202.ent.ti.com (10.64.6.60) by flwvzet200.ext.ti.com (10.248.192.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Tue, 11 Aug 2026 13:34:40 -0500 Received: from DFLE203.ent.ti.com (10.64.6.61) by DFLE202.ent.ti.com (10.64.6.60) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Tue, 11 Aug 2026 13:34:32 -0500 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) by DFLE203.ent.ti.com (10.64.6.61) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Tue, 11 Aug 2026 13:34:32 -0500 Received: from santhoshkumark.dhcp.ti.com (santhoshkumark.dhcp.ti.com [10.24.52.55]) by lelvem-mr06.itg.ti.com (8.18.1/8.18.1) with ESMTP id 67BIXIe6659766; Tue, 11 Aug 2026 13:34:28 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , Subject: [PATCH v7 14/18] spi: cadence-quadspi: reprogram PHY DLL on runtime resume Date: Wed, 12 Aug 2026 00:03:09 +0530 Message-ID: <20260811183313.1550425-15-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260811183313.1550425-1-s-k6@ti.com> References: <20260811183313.1550425-1-s-k6@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000AD79:EE_|SA1PR10MB7854:EE_ X-MS-Office365-Filtering-Correlation-Id: c72b1846-eeea-4325-7c07-08def7d7445b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|376014|7416014|1800799024|23010399003|36860700016|18002099003|22082099003|921020|10067099003|56012099006|6133799003; X-Microsoft-Antispam-Message-Info: o0A/Rj9oRXDyfHdGQSHDRJcBnlu1iNx+vYzMBPb7CA8TxLhH3+rzQG9CsTsWt6EWox8fJGRVf9kvEws8xfN20+toeJpVu5Hh5eDRG4ytCdF22T4Dr0Dt8ukLoAExIueJ0uludcCZxyEdh7EY1vYR8mmKfjOrW4Ls0zZbLZTkcQE9+b+UJohKhzfF/vemyfAl//A5bttCRHa3MDQk0T0rdbLl38Y0H3ByiftBRgS6930mnikfJDmdtbRHl0X50oYIR9EfHJ0LcNPfxUiEXpbO7E9FDkhf0l+2em26Rzj9Kv3Toublu87S7WEIaWyiB0/o+lE5MNekj6mZg3btrwWaRRkkWrvOANQof4U7dlrqNBSdIiMST6xXZUJaHEwPA1DrV5yxsZ6ekNvvx82YFeOHhlNRZ9qZXfKy/C0BN1n68TW+dd3zlu5nrF5G8SQVx2bB4WwCEbp4VS65OYIhSyl78/FRfaPckLJujQ6/ytDXUNY2f8c/R6Y3LvJ/u0jgZqNgRfnHZJK2kA9VJHQgpLVhNzgaaWG1Qg/hQ6BzdHtzLEyYypJyRhVeYarEZnQZg1JILIWFN/nStYRK+u9dwQHTZO//DOJw9OflroM/N2rwUhmGGwEf1By9BKDDhR9PDcIj8dvE2vkpkxkzAvPs9MQXV2ZSYkFNH98BrK+2Hv79EHFZGyehxvAXnpF4LAu0zgMd1wuM2hU6sBBX0sKreIiNQ7UrXNSG+Hluf3yatZkZgaDE6vq2Ze4H620ls1mR6OmX X-Forefront-Antispam-Report: CIP:198.47.21.194;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:flwvzet200.ext.ti.com;PTR:ErrorRetry;CAT:NONE;SFS:(13230040)(82310400026)(376014)(7416014)(1800799024)(23010399003)(36860700016)(18002099003)(22082099003)(921020)(10067099003)(56012099006)(6133799003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: GtsG0xHFZZce+ML8JNtq/KJERXjqxXCAh798RSpzV0QC2jk5S9Bhc8ly2awuPAc+YvUeYBqCSHK6TNGg9W24Nv8HjkTYvq2Ruy+64vX8xz6xkwFRJrqeva6NaLy66CG3gHwDWO67QIvJE3IgCQVGBtJf7gEN3G6yZ0HSpeR8XE8P9BmIght46MfnqsZz+qRYyCxgN1RnTJtiNvSUL/zXvk/XRTx7DWoJ8DIZYqpV6I1W6eaR4CVnxfAR2Yg4kynALq0moFa90nNP/z2bODoPMmjXlB8MaTrWI9Wc+TX+S9OZYTGlVeuQJxdUUBVTJ5S3fgAlJNm0No3y0vjQW674B6qX+jF57ImUzVGa67mj1sjNgRcdLPtJ+/eCtUMfiSVi+rR+re7JoD5O5HmEeAodWHVptGlD2s0giniNU2wrDFmairlDURS3Rj0WsI+BKb8V X-Exchange-RoutingPolicyChecked: l9ZBKx56M9VSDpr6SQwt8yl2iwgcpCyUQxawHtYaobb+WSz368P/P2X9aEkGKUdIwaZuJFr3OEGR/J8Asm5dAtThBdqo+yyURgVQr49uYUp4culb2N0BXF2MwSiEOH9UjuLtjKQFSkRLlASPa45AGNWp69t691PTPjaGAxpIuMXb8FdCkreikyMqBTAUPiItSxckRrjYh4snpPuM6OU7js8rlNnpIeHNAWcvyXTlz1+8KylDev4XGtYokG+wp09tVbcrRrvOm6FOPehQOjTOTjnMnyv8iczYYvyrgyiis4AHcGeI8i9gXy2IPY/hLkCDcJJmLomi6DjAQBelSNsMcg== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Aug 2026 18:35:06.9149 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c72b1846-eeea-4325-7c07-08def7d7445b X-MS-Exchange-CrossTenant-Id: e5b49634-450b-4709-8abb-1e2b19b982b7 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=e5b49634-450b-4709-8abb-1e2b19b982b7;Ip=[198.47.21.194];Helo=[flwvzet200.ext.ti.com] X-MS-Exchange-CrossTenant-AuthSource: CH1PEPF0000AD79.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR10MB7854 X-Authority-Analysis: v=2.4 cv=M+V97Sws c=1 sm=1 tr=0 ts=6a7b6b60 cx=c_pps a=p2N+vRIgjjfURKXzpqLMRQ==:117 a=iwqwCZQqcuTv3JOpYdM7/Q==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=Sv0fKeRqtYgA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=taLDd7a_hP9WKsMzeGRc:22 a=sozttTNsAAAA:8 a=UNEB7AwOHobNk7BaE54A:9 X-Proofpoint-ORIG-GUID: VTvCEUC_1g4hbp2WUnVmsWvcV5dzc7cw X-Proofpoint-Spam-Info: AW1haW4tMjYwODExMDE1NiBTYWx0ZWRfXxOEzLc/zdnOl TSVe8oV+5VQaPWLRkVdLe+Ux4QTHVNBlUQNVZkhDkxPivD1HH+nKtRO+WCeCjqdipr/FjR6uejD 1UX+TQ1nQQD7jAAIEp5eZCGi6I7oKW4= X-Proofpoint-GUID: VTvCEUC_1g4hbp2WUnVmsWvcV5dzc7cw X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODExMDE1NiBTYWx0ZWRfX8jJV2w3nfC7C U4eGctOtOwvS90VyASr1ZLYjG3W+r/BHqKTR86ntQ+jlv2H62AYAcxFHwtqmMHeLCfVvwdmPhTX jlQUUH7hAGobrtupMCkT4oTLUse7o0sumoHoCUjv6gAbzPDwolo8Z1oKbMHp6aFuQfgNUTorjuP kO/ySY+e6njc2FH0v6KPg2ucVDIsGmhhswhQFwS8S+ZU+B8bmC3DKsz+MzctMxA2mW5QYdtg1lP /WxaRpK1TlnkyhSlbD1vlA2Tc3xYE0VxPRYUWwturyzGLcBQ6fChPzluoCGs8D0Foyb0nqAWrDs lJZkjOuo/TlouC1tepCjyLATftsMehdzAqjg0eBKsPYe8EuoTNpoW0FChfvAHsJbwg7aORflJg6 TRpuwlBZkCL6Cn3NYPjh2kzB//9Go7LyQbTkHXuIbetxkE9aXYk5LQnUqS0/fGp79oJ6ccGdDmj XgbZZbvEJcHhx55vvNg== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-11_04,2026-08-10_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 lowpriorityscore=0 adultscore=0 spamscore=0 impostorscore=0 bulkscore=0 malwarescore=0 clxscore=1015 phishscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608110156 Content-Type: text/plain; charset="utf-8" The PHY DLL loses its programmed delay values and lock when the OSPI controller is power-gated during runtime suspend. On resume, cqspi_controller_init() reinitialises the controller but does not touch the PHY DLL registers, leaving the DLL in an unlocked state. Any subsequent PHY read or write would then fail at the cqspi_resync_dll() call inside cqspi_tune_phy(). After the controller re-initialisation, iterate over all chip selects and reprogram the DLL with each CS's stored calibrated RX/TX tap counts, then resync to relock it. One invocation per calibrated CS allows each calibration to be independently validated after resume. DLL resync failure is non-fatal: a warning is emitted and resume continues, so the system degrades to non-PHY speed rather than blocking the resume path. Signed-off-by: Santhosh Kumar K --- drivers/spi/spi-cadence-quadspi.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-qu= adspi.c index d4181b501d8d..c78d4ce1c930 100644 --- a/drivers/spi/spi-cadence-quadspi.c +++ b/drivers/spi/spi-cadence-quadspi.c @@ -4017,7 +4017,7 @@ static int cqspi_runtime_suspend(struct device *dev) static int cqspi_runtime_resume(struct device *dev) { struct cqspi_st *cqspi =3D dev_get_drvdata(dev); - int ret; + int cs, ret; =20 ret =3D clk_bulk_prepare_enable(CLK_QSPI_NUM, cqspi->clks); if (ret) @@ -4030,6 +4030,23 @@ static int cqspi_runtime_resume(struct device *dev) =20 cqspi->current_cs =3D -1; cqspi->sclk =3D 0; + + for (cs =3D 0; cs < CQSPI_MAX_CHIPSELECT; cs++) { + struct cqspi_flash_pdata *f_pdata =3D &cqspi->f_pdata[cs]; + + if (!f_pdata->use_tuned_phy) + continue; + + cqspi_phy_set_dll_master(cqspi); + + cqspi_set_dll(cqspi->iobase, f_pdata->phy_setting.rx, + f_pdata->phy_setting.tx); + ret =3D cqspi_resync_dll(cqspi); + if (ret) + dev_warn(dev, "cs%d: PHY DLL resync failed on resume: %d\n", + cs, ret); + } + return 0; } =20 --=20 2.34.1 From nobody Tue Sep 29 06:08:43 2026 Received: from mx0b-0002e601.pphosted.com (mx0b-0002e601.pphosted.com [148.163.154.28]) (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 AB28D3B3BEC; Tue, 11 Aug 2026 18:35:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=148.163.154.28 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786473307; cv=fail; b=UvWYhE4mt4D4VbdPDFb9KE38M3oHSjkG66uqANEFLjvgHWHQeOf5DDhqxIOIikqloRdfEkYv8iyXOSpq3KHyyhXtEjitrafSN+sVTAX+RNNu1XvWr0INwVChe8gztmPPoQt5eVU/Ra+PdLbITo+S3iBZBAUpDgN2xMXQxOe2RNE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786473307; c=relaxed/simple; bh=EgPd8VbcyrS6pF5XRBydAegNzfoN1Y0GfOtUmoBoCs4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=KBXEOpZTS+PuZkMQujjw2fxSn5joqoKpNBlVW8bHw69l3w6EVHVFUSqX/IQNJI2A6KBQAsEAP8U9hsWh7OJN7IAJVZJ6WnWlvTAx1LjDIg5hFlF6OSDr4YLHzWbVC3iR2xYoWMaVmGw3rkg/MK+DeDIGWsAKBUb8Ir7xxjZTtnI= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b=BUNtkn8F; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=ZG14m/jx; arc=fail smtp.client-ip=148.163.154.28 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b="BUNtkn8F"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="ZG14m/jx" Received: from pps.filterd (m0374955.ppops.net [127.0.0.1]) by mx0b-0002e601.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 67BGMeCX2174931; Tue, 11 Aug 2026 13:34:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint-05-2026; bh=VdoYsWBenFgsbLRwW1KUBdy/3KraCabI36s9hznhh gI=; b=BUNtkn8FpFstvPoDKdCOMOQo168URZK6HSLXQnOk4uOQHlBgR4NEMsGrg Eos/oBaDZDM/OGHEa9kqYfPBMke6nUizTa8kKIwK2cQPMysDiAtQEzlcW/t++Tv8 rPnEJigb1Yp2d9QV1x/KbZgJUO5G9X38yxyxc1qzb15m8sgQxES5aW0yWe6ZbSU7 lEZoyLiYvhCNrAtSyBuxbkPyGl8MDjGCtOEXhkuat3zOnCU4k9WcdsWEis6LJk36 qoI4cib+DLE2wuucF25UbD5Df1OfKIl4exHpdvfWQmuQtsZD3zkph7LxdCqQbtw7 QhDp5MydWiEpitf0XizCWdwZRZuVg== Received: from sj2pr03cu001.outbound.protection.outlook.com (mail-westusazon11012057.outbound.protection.outlook.com [52.101.43.57]) by mx0b-0002e601.pphosted.com (PPS) with ESMTPS id 4g00w4uj4e-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 11 Aug 2026 13:34:56 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=PTNgQ1qPxk6fwmnI93jbWqh+yrX9gTWE6f0rQV7TuoLPDygaKUIxnvtixQ+LJ3n9sJTUIrQNYJ5LRgRr2WsT4K9JPm6Ci9GJz4IR4vjK23QGoTT1AQYn+uS8mr5ns1GRhN4DsikzuYBjT4L/qxuln8Gg86qGdneEskHXW/ydqUP5rQz7KprmxjzIFaa42ZIKy44XOpe1GR0ETDJkhM4evuVDXcUJUQYcGIpbvGWR6qfZU5woaBG6XUphqhKgZClsC1WRrQqFiMGiP5TvND6EZ08NrAkitH/PCj7ipRyxG/dMM6+SmVYGE5ziQ+V3n1iTifnURRkx9skZP7go0F8E5A== 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=VdoYsWBenFgsbLRwW1KUBdy/3KraCabI36s9hznhhgI=; b=q5aOOhZXrriAsNSwj3Egox0PFUFrLFX8uPXT1KIuDLXxDfDetyMEgSJkGEvGSKyXW5Cb9+9PtoEIDNg77sUNQBgPSAob9xmTWz6udaoq8N1hC4XFczI12edh5qmnjBjo+tLM6Jt8mKAanmaNkhLhQwqNFRTHhk/rcDMKTA+RDVZKfNEUOUlLXWQt+E5Et7OfiPhwn/XQxeRjyFjwtQaaYqST918V8LXcRAmp5sCjvuX+AVfH73480jmmVsojiX2ussWAI8blna1yR6heIKQ7TgMtA0mCrmXrsCP5ha8ugmnAsEiEIYAWd50PjxUybl6l9YZvwn1oZ2x0DTSvmzI/Qg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 198.47.23.195) smtp.rcpttodomain=lists.infradead.org smtp.mailfrom=ti.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=VdoYsWBenFgsbLRwW1KUBdy/3KraCabI36s9hznhhgI=; b=ZG14m/jxNECOMS4qnd3O14eZVw3UEhzpNSpAWgDIRbMVepapTfX9roGV2uQ4Vurgf8liNYjrja2ZK7+zrQEPbsrEoGWjjfhn/HLPLKQPSP61WSJbT5sVVe1AQrSw1h6LEXRuHVrjIzQV/aHJvPEEUmV6Mu/dGUJ1+SAcXAaokdw= Received: from MW3PR06CA0011.namprd06.prod.outlook.com (2603:10b6:303:2a::16) by PH0PR10MB4488.namprd10.prod.outlook.com (2603:10b6:510:35::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.315.12; Tue, 11 Aug 2026 18:34:53 +0000 Received: from SJ1PEPF000023CE.namprd02.prod.outlook.com (2603:10b6:303:2a:cafe::7c) by MW3PR06CA0011.outlook.office365.com (2603:10b6:303:2a::16) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.315.11 via Frontend Transport; Tue, 11 Aug 2026 18:34:52 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 198.47.23.195) smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ti.com; Received-SPF: Pass (protection.outlook.com: domain of ti.com designates 198.47.23.195 as permitted sender) receiver=protection.outlook.com; client-ip=198.47.23.195; helo=lewvzet201.ext.ti.com; pr=C Received: from lewvzet201.ext.ti.com (198.47.23.195) by SJ1PEPF000023CE.mail.protection.outlook.com (10.167.244.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.315.6 via Frontend Transport; Tue, 11 Aug 2026 18:34:51 +0000 Received: from DLEE211.ent.ti.com (157.170.170.113) by lewvzet201.ext.ti.com (10.4.14.104) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Tue, 11 Aug 2026 13:34:38 -0500 Received: from DLEE205.ent.ti.com (157.170.170.85) by DLEE211.ent.ti.com (157.170.170.113) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Tue, 11 Aug 2026 13:34:37 -0500 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) by DLEE205.ent.ti.com (157.170.170.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Tue, 11 Aug 2026 13:34:37 -0500 Received: from santhoshkumark.dhcp.ti.com (santhoshkumark.dhcp.ti.com [10.24.52.55]) by lelvem-mr06.itg.ti.com (8.18.1/8.18.1) with ESMTP id 67BIXIe7659766; Tue, 11 Aug 2026 13:34:33 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , Subject: [PATCH v7 15/18] mtd: spinand: extract variant ranking logic into spinand_op_find_best_variant() Date: Wed, 12 Aug 2026 00:03:10 +0530 Message-ID: <20260811183313.1550425-16-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260811183313.1550425-1-s-k6@ti.com> References: <20260811183313.1550425-1-s-k6@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF000023CE:EE_|PH0PR10MB4488:EE_ X-MS-Office365-Filtering-Correlation-Id: b3ff7f2e-0785-4c13-beea-08def7d73b1a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|23010399003|36860700016|1800799024|82310400026|921020|10067099003|56012099006|22082099003|18002099003|3023799007; X-Microsoft-Antispam-Message-Info: z1Wo7QZtjFbnWZ0QVbWk7AY6p5E3qqKg4LEI5c7HlGkwO3nhvUq60/GOn3EoEo4tsiwsl4d2B+NmCZzjr6QReJn1xv5G6w3uWB8O335deBswCqfrdYnLTKNJl3oMWZEq8gNop3bNyzYRdOIY1AqIDMWMHEf4AAv8J4uSYmZHSoGT6S1SDucMzP4x4tzDWVXfwLCygnFNwYGZk9RHHfjbvyPcE3d0hBOiWyIvpOUklDGhzWKdLk27P4mLnHJcp2tQnAXbSMtIjmnxI7CbLSpuKEm7lBkjtGjm3ZnKUF61DaZ7EW+hkBvQ39GtivCXOGZKDq58e/WW3QN+VI2eOmOfMo33Teijkazq3dSqxVQRplxoXKSujQFTYrK9pZ3li7+CJh8Adnn1G1eQXdmMX8dhf7ILGPk2dWjAh4ID3oimArJ2U2bUXKnAiZHeE0N9UTqzKmz+SyFMQgmlYBrvzZ4XJ7i/d/NUPwZyW+AAKtyh0p7F31KIfBwRxIWFbY5KE6LO2+d1FKkt0XRxULb9zLbh+lG4eOYoQFDUhrIXWi273fQL3PaXa1halordY8BmU3XhIOoRTN5HSlD6Fll2fwGk6AhEsP4GPZIgdL9Tj0XQWhBR8CgJEZcy7UZHd3wwNfARHfBb1EbapdBIgHADdTgm5Ncgcl50/h/Z73vJr7tmFRbZtCgr3OMQ5U62ooX4OVW/HmK5Jh+1b9VwsWeyttKa+9Aiq9Cr+3tDngtCbbmCxDInqx8lVo0CaWHxA7Hr7Eef X-Forefront-Antispam-Report: CIP:198.47.23.195;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:lewvzet201.ext.ti.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(7416014)(23010399003)(36860700016)(1800799024)(82310400026)(921020)(10067099003)(56012099006)(22082099003)(18002099003)(3023799007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: mtRUzakiqSDxWWz5QBN1dJirPelF6tXUvzScUazCctLUc1nShSo/AIgCMv4U/3lHwFAQ5FfBDjaoCAC2hbnKMDYZtFlr93ji47xzCYySYM9oPgaWU2K3BdPTXkoG0KT3LS2v6IjQtERQiz3gh0XH/ESB7NcTlzTUUU9hCz58a4SNSRxuhB37hWY1PQHIO8lJ9xvA6VdBbPjZ/Yj0FShcvSChMPlBm78r2f0dvn6I7yarTL7da0NES5E+Cyco/ac3ah57pDNd0cbQKnDWEdmcdsytwOM2gyJBZVfqaaNalciiF2XEffuVWaBdS8es4gmDzWUIry0PzkiWeisgT+/MGW2gErVlIpjwoLl552y+aroc+ze6bi3fnKNDPKm6aEVpI/0xQhsmOuhGSeoSlFZr2rGM7TBp0ISAVQUEG+VyC8WoLehdnilEgJO4C3FPsk6F X-Exchange-RoutingPolicyChecked: nYxAnsh/+7X3yes36VCWT46ImM9zvzSf/CsnGJmmbrZJI8Wm78B71P+wil2uour4661/DjR9QzqXAeywgZh/tbhU5I5R89nL4B4z0C6DOvyuLI5pfhh/7wPqbx9SfeG89t2LjrVWoqYH6/TFemd3Obc7i3tl+YlajaOYyXhhWupo7G14f2Igc+sH5s30r2WE8prKKBd1uaDwvPlsspkpqpnd7b8r94OwOF1oiV8LMwDA+TdSIU/UkWzzcnGQg5GOLyhpElwNOgawHNtbfq1+Tuyp6SVYDXBz0fLS2dGAgTOBXeZdjVpMBFh3g0F11mDQgOpte2dXHDKN+JWKNOrtZg== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Aug 2026 18:34:51.3475 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b3ff7f2e-0785-4c13-beea-08def7d73b1a X-MS-Exchange-CrossTenant-Id: e5b49634-450b-4709-8abb-1e2b19b982b7 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=e5b49634-450b-4709-8abb-1e2b19b982b7;Ip=[198.47.23.195];Helo=[lewvzet201.ext.ti.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF000023CE.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4488 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODExMDE1NiBTYWx0ZWRfX/RFuFPTOY9e3 XI6qITwcPIX+G/U/2/B0LOSaqBMqfWxaFRzBStbMc1ZrwFo87seKqvlIyzCTDB873pGgWeOiyMt wCXawPkfBW70EG64PkK2Y1weZGI9ByYcK2XqWj47e/hVfpnEi1V+EjdFopFc3y9oFbF2c523P/P mIO7EuaDWvM3SNBO7qYjs/N9dTr+BNsWgEskRhIvXvhyLEjrjeP+QIiFB4GuF8NbuUNOJOZlt4G aJPWycap6DYNMbSGv6CmODTLfq+AONPBpzDzVBKhbi1Pi4pey6+moO/76ibICM7Umtn0T4n5T27 R1u0K43fMY6dmtDVGN4DuMBot03KUIVqrtKj3bzz9RkEzroqbd4bxAzcQ6IOpfOq1aZMznONXYj l7JjRz9LjhI9kBdUcGy3722uUFL5TzrbEZzaVPwcjXEoZx7cy33bEPfrku2nm3KCttj3LFrnuPi SeQGb3PKW/NNRXqwPRQ== X-Proofpoint-ORIG-GUID: On7-fam9sYau_YHG4JE2QA96Muxg150S X-Authority-Analysis: v=2.4 cv=KZ/idwYD c=1 sm=1 tr=0 ts=6a7b6b50 cx=c_pps a=Y/Y9x3HtMOqQL+YbCjVQEg==:117 a=f+v6EHfkeJbVwR46tk4DMg==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=Sv0fKeRqtYgA:10 a=s63m1ICgrNkA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=fPAWb5peG099m5CrUpKH:22 a=sozttTNsAAAA:8 a=mFCyQ4P7OL-0BhijAlUA:9 X-Proofpoint-GUID: On7-fam9sYau_YHG4JE2QA96Muxg150S X-Proofpoint-Spam-Info: AW1haW4tMjYwODExMDE1NiBTYWx0ZWRfXw2gOYJOQZ2jt PaOj4qRA9Yax9V3AUEiEvVLQtCobf3fBwmBppMgQGmmVodLG8pgPEtn9LxQHokqAsc1bJqhBARY 0CqgPyXC1sAGQPf21VpFp3gXofuLHyw= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-11_04,2026-08-10_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 adultscore=0 spamscore=0 suspectscore=0 clxscore=1015 phishscore=0 lowpriorityscore=0 malwarescore=0 priorityscore=1501 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608110156 Content-Type: text/plain; charset="utf-8" Refactor spinand_select_op_variant() to extract the inner loop into a shared helper spinand_op_find_best_variant(). The helper takes a skip_mask bitmask of already-tried variant indices, enabling callers to iterate variants in ranked performance order while skipping those already attempted. spinand_select_op_variant() becomes a one-liner wrapper. No functional change. Signed-off-by: Santhosh Kumar K Reviewed-by: Miquel Raynal --- drivers/mtd/nand/spi/core.c | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c index 8bf9301f25e7..7c3341f1fca0 100644 --- a/drivers/mtd/nand/spi/core.c +++ b/drivers/mtd/nand/spi/core.c @@ -1542,9 +1542,22 @@ static int spinand_init_odtr_instruction_set(struct = spinand_device *spinand) return 0; } =20 +/* + * spinand_op_find_best_variant() - Find the fastest eligible op variant. + * @spinand: SPI NAND device + * @variants: full variant list to search + * @iface: bus interface to consider (ODTR or SSDR) + * @skip_mask: bitmask of variant indices to skip (already tried) + * + * Iterates @variants, evaluates transfer duration for each eligible op, a= nd + * returns a pointer to the fastest one not in @skip_mask. Returns NULL w= hen + * no eligible variant remains. Used by both variant selection at init ti= me + * (skip_mask =3D=3D 0) and ranked PHY tuning iteration. + */ static const struct spi_mem_op * -spinand_select_op_variant(struct spinand_device *spinand, enum spinand_bus= _interface iface, - const struct spinand_op_variants *variants) +spinand_op_find_best_variant(struct spinand_device *spinand, + const struct spinand_op_variants *variants, + enum spinand_bus_interface iface, u32 skip_mask) { struct nand_device *nand =3D spinand_to_nand(spinand); const struct spi_mem_op *best_variant =3D NULL; @@ -1552,15 +1565,16 @@ spinand_select_op_variant(struct spinand_device *sp= inand, enum spinand_bus_inter unsigned int i; =20 for (i =3D 0; i < variants->nops; i++) { - struct spi_mem_op op =3D variants->ops[i]; + struct spi_mem_op op; u64 op_duration_ns =3D 0; unsigned int nbytes; int ret; =20 - if ((iface =3D=3D SSDR && spinand_op_is_odtr(&op)) || - (iface =3D=3D ODTR && !spinand_op_is_odtr(&op))) + if ((skip_mask & BIT(i)) || + spinand_op_is_odtr(&variants->ops[i]) !=3D (iface =3D=3D ODTR)) continue; =20 + op =3D variants->ops[i]; nbytes =3D nanddev_per_page_oobsize(nand) + nanddev_page_size(nand); =20 @@ -1589,6 +1603,14 @@ spinand_select_op_variant(struct spinand_device *spi= nand, enum spinand_bus_inter return best_variant; } =20 +static const struct spi_mem_op * +spinand_select_op_variant(struct spinand_device *spinand, + enum spinand_bus_interface iface, + const struct spinand_op_variants *variants) +{ + return spinand_op_find_best_variant(spinand, variants, iface, 0); +} + /** * spinand_match_and_init() - Try to find a match between a device ID and = an * entry in a spinand_info table --=20 2.34.1 From nobody Tue Sep 29 06:08:43 2026 Received: from mx0b-0002e601.pphosted.com (mx0b-0002e601.pphosted.com [148.163.154.28]) (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 391A33876CD; Tue, 11 Aug 2026 18:35:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=148.163.154.28 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786473314; cv=fail; b=frhGdsWTzCPuiBA2G4SCKIlYJTsHnJBKGgVcvP4TS2+yJ63UmNW9Llnyb98FQqzPIumee7sKi6sTG+uIG76mvZJJqbgy3IV3z3P8dJJHsw4jt7qf6fxq0aRKUPxNFM/VgrZLTv510wr5MhH2lEn7/HuHBZwg9rZmmxzDPPel/xk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786473314; c=relaxed/simple; bh=LSX7xJd7Vwgm/bLKXPcZ5cLE1NFdYkPDcnBIWVQEjBA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=m/fam5WQKknvG/vhPr+G3mMCn1J8sOeIZ7Ee9q0jUxcGJYIim7XdSTWVJuSD70ljfVPqGDSOtMMHAGsP6MdXC5c3WyNCATTKo8cEtsgDqjYkWKC2eGbvWL/B4ip48vUlGImCIJDIPtbWU4O1nTmijbGetoJzg0vxBgpo7XVJzTQ= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b=XSb51lRR; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=jfp9rhaI; arc=fail smtp.client-ip=148.163.154.28 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b="XSb51lRR"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="jfp9rhaI" Received: from pps.filterd (m0374956.ppops.net [127.0.0.1]) by mx0b-0002e601.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 67BGM7Cn1823863; Tue, 11 Aug 2026 13:35:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint-05-2026; bh=Klw+Hpw7Xo1fMhBviBQ9oPnuoGquCmHUa4MOBKs3e qE=; b=XSb51lRRBf8hLqeKwNd6N4vuGXQXawedE2Yct2R7L/83EWSRA+CcIjlwr i9BKof7pv3Rnzht7M9NnZBzEeycdHuB/gGS4gA/lErK3crKgsqhmBPO/3GvahAXr qYyz1bG4+ei+XabUPBIArIjjl3YHTMRtzvo1IvVinWby6vva/bYIIG7oQi1s14KC tJwzmXzmzNzTwDAmzQVl8caoO/D8DPhwbtKaD8HY9UHoOuZS3dljpYMalYqrwRQQ NptnQ3gwmx6jB+XABu/0udq8NMOh9PG4OBZ0BoktF5LGgzJxGSUcTBvunaI5UlPg GHNa1QLT6zAMzeX9tWPBvS1m6Le3A== Received: from sa9pr02cu001.outbound.protection.outlook.com (mail-southcentralusazon11013051.outbound.protection.outlook.com [40.93.196.51]) by mx0b-0002e601.pphosted.com (PPS) with ESMTPS id 4g00wnbkap-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 11 Aug 2026 13:35:00 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=F+w8ztnwp/pCbwV4KTJaJTeVfRX7le1fKZDM3F5txE/Oq8cXyk7gov101wWQMXc3Kcl66Hvn7tmCe+Uq0ubNC2TwbXmqmgCjS6g9mLW0En55nWJJZdl6ej/DLezCT7Jd2fLXn10+bAkvFpPOD+s2zkwae+/I6hMolCaHpaWOsDNjFD5tnYIaFMUNWb8mvbnbbbQodqGNSAhbE8RXTTULWI3AzGX0c7ugWGzhLDM6VL21DatdVmVwkRthTZIVwcDFkrl1eJDBUqHAc8KVLw0BukMukRpPIMZBwvW11NpZaUO1TY/9T/qt+qWSwW1qA4B3IiW1DvHrcYIJIsEY12Olcg== 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=Klw+Hpw7Xo1fMhBviBQ9oPnuoGquCmHUa4MOBKs3eqE=; b=t01rjbAWc8j4VMqOkf67zbkE3w8/9LPnYv/xbQ03jsPlyKenSpGLRKhtJWYLzTOq/WsK9Un34LK/lKxk1asSPmkZ/KihSTPp86dstF6e+TLJqa/eebalFRNDHXnIfI2yqJAlxGd/9XG5l6eNhRvRjGxjU4BMUIc5kNCXt7fk8m/C2/uXLY/E9QKvViROYm78QbgJOytLen+LkBLMEEDsbNvyI0CRJpYXmWqn/F7fC7fQ3w6KxeJYG5GEcyda/Y7Yh0+ZV60Y0cj51kwqyrCLuua3VeV4V6Zik4CgNvFXSPhRiUWI+Id4mK5SZLemSK9LJEKnzGuII9xpE/YzHdxaiA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 198.47.23.195) smtp.rcpttodomain=lists.infradead.org smtp.mailfrom=ti.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Klw+Hpw7Xo1fMhBviBQ9oPnuoGquCmHUa4MOBKs3eqE=; b=jfp9rhaIG/JYjVhKeZahtgn8eScOYzhtn/9fmvTp6SdwcgNUGu0sFQI0O7ZWpYlbVSxOTp5SyL/EvLTx8hO36np1rtVLAGeIsnKic0mygJqv+YWQyLAqLepvabF/vHfkJUKFTwPwQPga5phbPffgADTmsyTQUbnKt/WE+rd875E= Received: from BY3PR10CA0015.namprd10.prod.outlook.com (2603:10b6:a03:255::20) by CH2PR10MB4149.namprd10.prod.outlook.com (2603:10b6:610:a7::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.315.12; Tue, 11 Aug 2026 18:34:57 +0000 Received: from SJ1PEPF000023D0.namprd02.prod.outlook.com (2603:10b6:a03:255:cafe::99) by BY3PR10CA0015.outlook.office365.com (2603:10b6:a03:255::20) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.292.25 via Frontend Transport; Tue, 11 Aug 2026 18:34:57 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 198.47.23.195) smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ti.com; Received-SPF: Pass (protection.outlook.com: domain of ti.com designates 198.47.23.195 as permitted sender) receiver=protection.outlook.com; client-ip=198.47.23.195; helo=lewvzet201.ext.ti.com; pr=C Received: from lewvzet201.ext.ti.com (198.47.23.195) by SJ1PEPF000023D0.mail.protection.outlook.com (10.167.244.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.315.6 via Frontend Transport; Tue, 11 Aug 2026 18:34:57 +0000 Received: from DLEE210.ent.ti.com (157.170.170.112) by lewvzet201.ext.ti.com (10.4.14.104) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Tue, 11 Aug 2026 13:34:42 -0500 Received: from DLEE209.ent.ti.com (157.170.170.98) by DLEE210.ent.ti.com (157.170.170.112) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Tue, 11 Aug 2026 13:34:42 -0500 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) by DLEE209.ent.ti.com (157.170.170.98) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Tue, 11 Aug 2026 13:34:42 -0500 Received: from santhoshkumark.dhcp.ti.com (santhoshkumark.dhcp.ti.com [10.24.52.55]) by lelvem-mr06.itg.ti.com (8.18.1/8.18.1) with ESMTP id 67BIXIe8659766; Tue, 11 Aug 2026 13:34:38 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , Subject: [PATCH v7 16/18] mtd: spinand: negotiate optimal controller operating point before dirmap creation Date: Wed, 12 Aug 2026 00:03:11 +0530 Message-ID: <20260811183313.1550425-17-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260811183313.1550425-1-s-k6@ti.com> References: <20260811183313.1550425-1-s-k6@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF000023D0:EE_|CH2PR10MB4149:EE_ X-MS-Office365-Filtering-Correlation-Id: ed0f082f-e6fd-4037-858a-08def7d73e8e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|23010399003|7416014|376014|36860700016|1800799024|82310400026|921020|6133799003|10067099003|56012099006|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: RchTOJlqCyWR1g5FnDhgXRgkd/9OaUGg8yXZfHYTJvNSNUzks8MHvWZ33Zql5mehTkp79ItkaaXtSFepBR5bml7hgjNnqmYglS28KDmxwJgsl41kNXaUCOoNIfXrDOwt3xpyA0dlyKfVNLLJ0MHO2LEQsoSIBULtjjPi/HqTApipv8LE9syhyH1GCZ6/yHX5adO00XOdG0XYVEajd0sMDTQSBAX0SduEk1nONetYp9EWib6K6OyAG8EL4MToJ5JwOjOVal40QZ6PI9NJh4MqrNkzzVzLYQ/7Ul5rkC7a1KzOLt8Xcn3BfNqgNfkunGkyJNCTJmzagOtsbxEajIrh3WggcHDKCCk97acDOtzQ0ow6bmHHHY5LnULj3PGDDA7O6Ujt3hsT53YT57xK8NPA4gcBJ8Ob30HcNMYM9rCXXj/C9MWy1iRnXXskOnvXWnalo5j1bV2HJNMFlloYL+VhXxXTE1VsybfvOCiFqO51erR4fR9/3u2L9vSes4HBEQRYwvvKqzYsm/wpdIs6ha7/KBXBu9HGFCUh3VX2wP5bbJ0evYR/RUXEpyxXD/T2IQYTjl1OvmEIXfniZQxFqVUfkt5Qfvw6r4DKpW4U+EI6pzgx97N1/DHi0lCTjFVg/DR0RNDJTijHPu5uyNyL9bmRFZ1PCfUMsljVcSee0NF5t+iqCqPY9bmcD2OoLgBGc5D2e6uL/TE1QKczk9lLRzoTiRayilSpAe7cBpN1H4nWga/5YZtl8YEq9ZsnvkjSU6Kh X-Forefront-Antispam-Report: CIP:198.47.23.195;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:lewvzet201.ext.ti.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(23010399003)(7416014)(376014)(36860700016)(1800799024)(82310400026)(921020)(6133799003)(10067099003)(56012099006)(18002099003)(22082099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: SCo6i0D3v1jOahkNo/VHQUSVyQZGIma/BCF/OCRXAQ/8MEl6HXs7SkvWwJw6iO5as9BsOyllssO5SFpjCQSe7IQsdBiFjzz5oQNE4g3TZWgNj1ExKzwZP745bMfauTLeZOabkq4lryK7czi/g+JXLbSZ+T51CD32KedQoXYZWGdbxA9duLUcVk9/BGZo6XzuUzEBPVwgFi6kmDJ5yYax6Rf1H8X4cRRrflxWt6U1fXGJ2v4jzfmfPPZNuHu8c0jyKK+3aRV1VM7TRAzyAGHg5MDUJfNqVXV7Jem7MfOyuFqlJ7KvcEqrIXIwSb0x9uWN2wmTdB3HLqhVe3MbpT0AZsME8DMH53gthJVUZh+usQqOLkFUMqjaQrHZTERyxfBG5x1wGC4/6ruFWAmQTql17eZs4rjfSjMkiecG4di5l3lcRQcq/FGIGdoBTlEQoYSM X-Exchange-RoutingPolicyChecked: Q+RExGnJbpOx6J7zqsnz0A8ncouI2jHs2gP76z3qVFIwk8IX8lojhlAzwsOc0PTh2GGgK+8gnlEmElgM0A3Mb6WMQxiWZJsiNfhUp0BBsFP0RR47KDBOnS1iL968oBV+TglqAhCjZlieqiDLWpxuU+pB66GOAa6OxWNgZoMS4Rl4QfR3vDCCDK1SqOsg1+NtuIHyhzZu6SQG9g/gr2uElm3sz+SSl/7ArTvW8/+nEWNd5Gn68emxJceQ8BzG/scO8KW/eZcnL2crSznWUZdm0KmMANlek/T04KltsikBNxzmVhrY+dm1zBDuZwfD+Pv/nd1kcTOvGnQNAQc0iRfYZQ== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Aug 2026 18:34:57.1463 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ed0f082f-e6fd-4037-858a-08def7d73e8e X-MS-Exchange-CrossTenant-Id: e5b49634-450b-4709-8abb-1e2b19b982b7 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=e5b49634-450b-4709-8abb-1e2b19b982b7;Ip=[198.47.23.195];Helo=[lewvzet201.ext.ti.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF000023D0.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR10MB4149 X-Proofpoint-Spam-Info: AW1haW4tMjYwODExMDE1NiBTYWx0ZWRfX1UKEoF+Ho7zX J5a29BCyionAZRxFaC4WAY60NRwhvSEtVHhl8L0fHqUMqwXC2480rjB7rjpl98e7CLv3g2fcmXB NT/jc7pKMVVo7KZUMV/XjFvAnnJUSkk= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODExMDE1NiBTYWx0ZWRfX9mejKKNTnPbQ KQR8rH9sBLCl6q4OZLkCH0coeEQorTOwsauNqCvnB4Lo1n4EFzBvH1TEJvpNJ9OMr70UOh5vKmu +gj0xioceYPqxnexIiRGiVDNltYRlwzS3vJdKF4WeiT3+FZHwRveBQcQ/CNwJrPXizUjGscNHkM 7xFV18sc9shD7Du42g7t/qCsgtylTRAeWFEwpK8ObnHwxH1TfbXdtXbki/1YbJbEg0hyWfyubG0 mq5fpx6kW9j6n9q+hbJ2FLsDzVMDKW7vwgBsv7BiKDH2SNWvFfZ+votipXwuKNWIP7ZT8SYL32K 8r6auiVhyRFwbFKlB6N9qQnBd5ja2rX0ZKxWGP1+sXqz7wIjj/lr7pBZSaz8REzI66Ic69WHAuq +PYr23m0gDc2S0HNPZ+YYvf2q/2D9iJZvXhP/Niv4ogDDW2KvDTji2UUwv/RmyNrGBDdTLH/89o LDzv0R4CNgbWhqnDnkA== X-Proofpoint-GUID: 9SAfGmxAgVBr5jA9-Wo3w5XNQA53m52y X-Authority-Analysis: v=2.4 cv=cYziaHDM c=1 sm=1 tr=0 ts=6a7b6b55 cx=c_pps a=021mb8W6rIxzgUEI7A/+3A==:117 a=f+v6EHfkeJbVwR46tk4DMg==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=IkcTkHD0fZMA:10 a=Sv0fKeRqtYgA:10 a=s63m1ICgrNkA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=jwouBfj2j3NM8CExmVVE:22 a=sozttTNsAAAA:8 a=VmYIjnxWTCUH1C-J5tsA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 X-Proofpoint-ORIG-GUID: 9SAfGmxAgVBr5jA9-Wo3w5XNQA53m52y X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-11_04,2026-08-10_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 bulkscore=0 priorityscore=1501 spamscore=0 suspectscore=0 impostorscore=0 malwarescore=0 phishscore=0 clxscore=1015 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608110156 Add spinand_optimize_controller() which calls spi_mem_execute_tuning() to negotiate the best operating point for the SPI NAND device before creating dirmaps. The validated max_freq is then embedded into the dirmap op templates so the controller uses the optimised frequency for all subsequent page I/O. The function tries the pre-selected op variant first. If the controller signals that optimisation is not applicable for that specific op (ret =3D=3D 0 with max_freq still zero), spinand_try_ranked_variant() iterates the remaining variants in descending performance order. For devices supporting both ODTR and SSDR interfaces, ODTR variants are tried first; if all ODTR variants fail, the bus is switched to SSDR and SSDR variants are tried. On full failure the device reverts to ODTR non-optimised mode. Add spinand_reset_max_freq_ops() to copy op templates with max_freq zeroed before each execute_tuning call, enforcing the invariant that a non-zero max_freq only results from a successful operation. Optimisation failure is never fatal; the device operates at the conservative base rate. When optimisation permanently selects SSDR (either because a ranked SSDR variant succeeds or because reverting to ODTR after exhausting all variants fails), clear the odtr_op_templates pointers. This prevents spinand_configure_chip() on resume from re-entering ODTR mode with dirmaps that were built for SSDR, which would cause data corruption. Reusing the existing NULL-check mechanism avoids the need for a separate flag and is consistent with how spinand_configure_chip() itself handles ODTR configure_chip() failure. Move spinand_create_dirmaps() from spinand_init() to spinand_probe() so the validated frequency is available at dirmap construction time. Signed-off-by: Santhosh Kumar K --- drivers/mtd/nand/spi/core.c | 221 ++++++++++++++++++++++++++++++++++-- include/linux/mtd/spinand.h | 11 ++ 2 files changed, 223 insertions(+), 9 deletions(-) diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c index 7c3341f1fca0..dfc9d0871e91 100644 --- a/drivers/mtd/nand/spi/core.c +++ b/drivers/mtd/nand/spi/core.c @@ -1284,6 +1284,7 @@ static int spinand_create_dirmap(struct spinand_devic= e *spinand, info.length =3D nanddev_page_size(nand) + nanddev_per_page_oobsize(nand); info.primary_op_tmpl =3D *spinand->op_templates->update_cache; info.primary_op_tmpl.data.ecc =3D enable_ecc; + info.primary_op_tmpl.max_freq =3D spinand->max_write_op.max_freq; desc =3D devm_spi_mem_dirmap_create(&spinand->spimem->spi->dev, spinand->spimem, &info); if (IS_ERR(desc)) @@ -1294,9 +1295,11 @@ static int spinand_create_dirmap(struct spinand_devi= ce *spinand, /* Read descriptor */ info.primary_op_tmpl =3D *spinand->op_templates->read_cache; info.primary_op_tmpl.data.ecc =3D enable_ecc; + info.primary_op_tmpl.max_freq =3D spinand->max_read_op.max_freq; if (secondary_op) { info.secondary_op_tmpl =3D *spinand->op_templates->cont_read_cache; info.secondary_op_tmpl.data.ecc =3D enable_ecc; + info.secondary_op_tmpl.max_freq =3D spinand->max_read_op.max_freq; } desc =3D spinand_create_rdesc(spinand, &info); if (IS_ERR(desc)) @@ -1745,6 +1748,17 @@ int spinand_match_and_init(struct spinand_device *sp= inand, spinand->cont_read_possible =3D false; } =20 + /* + * Save the full read variant list (ODTR and SSDR ops) for + * ranked controller optimization. Only saved when all ODTR + * templates are valid; spinand_optimize_controller() uses this + * to fall back to the next-best variant when needed. + */ + if (spinand->odtr_op_templates.read_cache && + spinand->odtr_op_templates.write_cache && + spinand->odtr_op_templates.update_cache) + spinand->all_read_variants =3D info->op_variants.read_cache; + return 0; } =20 @@ -1923,7 +1937,6 @@ static int spinand_mtd_suspend(struct mtd_info *mtd) =20 static int spinand_init(struct spinand_device *spinand) { - struct device *dev =3D &spinand->spimem->spi->dev; struct mtd_info *mtd =3D spinand_to_mtd(spinand); struct nand_device *nand =3D mtd_to_nanddev(mtd); int ret; @@ -2015,14 +2028,6 @@ static int spinand_init(struct spinand_device *spina= nd) mtd->ecc_step_size =3D nanddev_get_ecc_conf(nand)->step_size; mtd->bitflip_threshold =3D DIV_ROUND_UP(mtd->ecc_strength * 3, 4); =20 - ret =3D spinand_create_dirmaps(spinand); - if (ret) { - dev_err(dev, - "Failed to create direct mappings for read/write operations (err =3D %d= )\n", - ret); - goto err_cleanup_ecc_engine; - } - return 0; =20 err_cleanup_ecc_engine: @@ -2051,6 +2056,190 @@ static void spinand_cleanup(struct spinand_device *= spinand) kfree(spinand->scratchbuf); } =20 +/* + * spinand_try_ranked_variant() - Try controller optimization on variants = in + * performance order. + * @spinand: SPI NAND device + * @mem: SPI memory device + * @iface: bus interface to iterate (ODTR or SSDR) + * @tried_mask: bitmask of already-tried variant indices; updated on each = try + * + * Iterates the full read variant list in descending performance order, + * skipping variants in @tried_mask, and calls execute_tuning on each until + * one succeeds. Ranked iteration finds the best available variant without + * re-trying already-attempted ones. + * + * On success, sets spinand->max_read_op and updates the matching + * odtr_op_templates.read_cache or ssdr_op_templates.read_cache. + */ +static bool spinand_try_ranked_variant(struct spinand_device *spinand, + struct spi_mem *mem, + enum spinand_bus_interface iface, + u32 *tried_mask) +{ + const struct spinand_op_variants *variants =3D spinand->all_read_variants; + const struct spi_mem_op *best; + int ret; + + if (!variants) + return false; + + while ((best =3D spinand_op_find_best_variant(spinand, variants, iface, + *tried_mask))) { + *tried_mask |=3D BIT(best - variants->ops); + spinand->max_read_op =3D *best; + spinand->max_read_op.max_freq =3D 0; + spinand->max_write_op.max_freq =3D 0; + ret =3D spi_mem_execute_tuning(mem, &spinand->max_read_op, + &spinand->max_write_op); + if (ret && ret !=3D -EOPNOTSUPP) + dev_dbg(&mem->spi->dev, "%s optimization failed: %d\n", + iface =3D=3D ODTR ? "ODTR" : "SSDR", ret); + if (!ret && spinand->max_read_op.max_freq) { + if (iface =3D=3D ODTR) + spinand->odtr_op_templates.read_cache =3D best; + else + spinand->ssdr_op_templates.read_cache =3D best; + spinand->cont_read_possible =3D false; + return true; + } + } + return false; +} + +/* + * spinand_reset_max_freq_ops() - Copy op templates and zero max_freq on b= oth. + * @spinand: SPI NAND device + * @templates: op template set to copy from + * + * Called before execute_tuning so max_freq starts at zero; execute_tuning= sets + * it to the validated clock rate only on success. A non-zero max_freq mea= ns + * controller-optimized; zero means the base rate applies. + */ +static void spinand_reset_max_freq_ops(struct spinand_device *spinand, + struct spinand_mem_ops *templates) +{ + spinand->max_read_op =3D *templates->read_cache; + spinand->max_read_op.max_freq =3D 0; + spinand->max_write_op =3D *templates->write_cache; + spinand->max_write_op.max_freq =3D 0; +} + +/* + * spinand_optimize_controller() - Negotiate the optimal controller operat= ing + * point for the SPI NAND device. + * @spinand: SPI NAND device + * @mem: SPI memory device + * + * Tries the pre-selected variant first. If the controller signals that + * optimization is not applicable for that specific op, iterates all remai= ning + * variants in performance order. For devices that support both DTR and S= DR + * interfaces, DTR variants are tried first; if all fail the device is + * switched to SDR mode and SDR variants are tried. On full failure the + * device falls back to the best available non-optimized mode. Devices th= at + * support only SDR skip the DTR ranked pass entirely. + * + * Optimization failure is never fatal. + * + * Note: tried_mask is u32, supporting up to 32 variants total across both + * ODTR and SSDR. Flash devices with more than 32 read variants are not + * supported. + */ +static void spinand_optimize_controller(struct spinand_device *spinand, + struct spi_mem *mem) +{ + u32 tried_mask; + int ret; + + /* Skip entirely when no post-config target is configured. */ + if (!mem->spi->post_config_max_speed_hz) + return; + + spinand_reset_max_freq_ops(spinand, spinand->op_templates); + + ret =3D spi_mem_execute_tuning(mem, &spinand->max_read_op, + &spinand->max_write_op); + if (ret && ret !=3D -EOPNOTSUPP) + dev_dbg(&mem->spi->dev, "Controller optimization failed: %d\n", + ret); + + /* + * Any non-zero return or a set max_freq means we are done (error, + * unsupported, or success). Fallback only for the op-specific "skip" + * signal: ret =3D=3D 0 with max_freq still 0. + */ + if (ret || spinand->max_read_op.max_freq) + return; + + /* SSDR-only devices have no ranked ODTR fallback available. */ + if (spinand->bus_iface =3D=3D SSDR || !spinand->all_read_variants) + return; + + if (WARN_ON(spinand->all_read_variants->nops > 32)) + return; + + /* Mark the pre-selected ODTR variant as already tried. */ + tried_mask =3D BIT(spinand->odtr_op_templates.read_cache - + spinand->all_read_variants->ops); + + dev_dbg(&mem->spi->dev, + "Optimization skipped for current op; searching for best variant\n"); + + /* Pass 1: try all remaining ODTR variants in performance order. */ + if (spinand_try_ranked_variant(spinand, mem, ODTR, &tried_mask)) + return; + + /* + * Pass 2: switch to SSDR and try all SSDR variants in performance + * order. configure_chip is guaranteed non-NULL here: reaching ODTR + * mode requires it. + */ + if (WARN_ON(!spinand->configure_chip)) + goto use_odtr_fallback; + + if (spinand->configure_chip(spinand, SSDR)) + goto use_odtr_fallback; + + spinand->op_templates =3D &spinand->ssdr_op_templates; + spinand->bus_iface =3D SSDR; + spinand->max_write_op =3D *spinand->ssdr_op_templates.write_cache; + spinand->max_write_op.max_freq =3D 0; + + /* + * Only ODTR variants were candidates in Pass 1; SSDR bits are clear. + * Clear ODTR templates on success so spinand_configure_chip() on + * resume does not re-enter ODTR with mismatched SSDR dirmaps. + */ + if (spinand_try_ranked_variant(spinand, mem, SSDR, &tried_mask)) { + spinand->odtr_op_templates.read_cache =3D NULL; + spinand->odtr_op_templates.write_cache =3D NULL; + spinand->odtr_op_templates.update_cache =3D NULL; + return; + } + + /* + * All attempts exhausted. Revert to ODTR for non-optimized DTR + * operation. If revert fails, stay in SSDR =E2=80=94 a mode mismatch + * (ODTR op templates on SSDR-mode device) would corrupt data. + * Clear ODTR templates in either case to prevent resume from + * re-entering ODTR with mismatched SSDR dirmaps. + */ + if (spinand->configure_chip(spinand, ODTR)) { + dev_warn(&mem->spi->dev, + "Failed to revert to ODTR, staying in SSDR\n"); + spinand->odtr_op_templates.read_cache =3D NULL; + spinand->odtr_op_templates.write_cache =3D NULL; + spinand->odtr_op_templates.update_cache =3D NULL; + spinand_reset_max_freq_ops(spinand, &spinand->ssdr_op_templates); + return; + } + +use_odtr_fallback: + spinand->op_templates =3D &spinand->odtr_op_templates; + spinand->bus_iface =3D ODTR; + spinand_reset_max_freq_ops(spinand, &spinand->odtr_op_templates); +} + static int spinand_probe(struct spi_mem *mem) { struct spinand_device *spinand; @@ -2073,6 +2262,20 @@ static int spinand_probe(struct spi_mem *mem) if (ret) return ret; =20 + /* + * Negotiate the best controller operating point before creating dirmaps + * so the validated frequency is available at dirmap construction time. + */ + spinand_optimize_controller(spinand, mem); + + ret =3D spinand_create_dirmaps(spinand); + if (ret) { + dev_err(&mem->spi->dev, + "Failed to create direct mappings for read/write operations (err =3D %d= )\n", + ret); + goto err_spinand_cleanup; + } + ret =3D mtd_device_register(mtd, NULL, 0); if (ret) goto err_spinand_cleanup; diff --git a/include/linux/mtd/spinand.h b/include/linux/mtd/spinand.h index 5f4c00ae72a7..7eacda949719 100644 --- a/include/linux/mtd/spinand.h +++ b/include/linux/mtd/spinand.h @@ -792,8 +792,19 @@ struct spinand_device { struct spinand_mem_ops *op_templates; enum spinand_bus_interface bus_iface; =20 + /* + * Full read variant list (ODTR and SSDR ops together), saved when ODTR + * templates are valid. Used by spinand_optimize_controller() for ranked + * fallback when the pre-selected variant cannot be controller-optimized. + */ + const struct spinand_op_variants *all_read_variants; + struct spinand_dirmap *dirmaps; =20 + /* Persistent op templates updated by execute_tuning with validated speed= . */ + struct spi_mem_op max_read_op; + struct spi_mem_op max_write_op; + int (*select_target)(struct spinand_device *spinand, unsigned int target); unsigned int cur_target; --=20 2.34.1 From nobody Tue Sep 29 06:08:43 2026 Received: from mx0b-0002e601.pphosted.com (mx0b-0002e601.pphosted.com [148.163.154.28]) (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 A7997390239; Tue, 11 Aug 2026 18:35:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=148.163.154.28 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786473329; cv=fail; b=XW7zWRBNq97w93TLDH0rg4dobFr2S2a4IPh0lHrQAPkkMf5rYwekf/e0cC0Gk3Il7adOwbdxOHGTY3Fm4ZSp+9nrYujWuCKSxkHHf5dGyVoL5jjlvck/G7xz0AQVXPVkKwQP16KGc2L0ftr2GErY2RGZiT/lXA+S9XWP+hr4IQ0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786473329; c=relaxed/simple; bh=zyzIHZWkbZiJeCTqvhBe5bpyE69d/84Z/bMFLKqBSj4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=sShI/sTzNJpVqeQkBPzs9uKg5wz3FCPB0FIn8Gpm8B6RfFWOJWxnLpFce1XZRgZQkIlddlpYAsiPpq9SX0BIvTEo7yKAltl+Z5L55xwbpGrs2tARj0gOkJ4f5yPyaf4lJeN18hRKpJWBXyVVmiyuWNb/RqueSDcfURPfTXnf1kw= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b=IM+gGpv9; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=w/xyvjbZ; arc=fail smtp.client-ip=148.163.154.28 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b="IM+gGpv9"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="w/xyvjbZ" Received: from pps.filterd (m0374955.ppops.net [127.0.0.1]) by mx0b-0002e601.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 67BGMeCZ2174931; Tue, 11 Aug 2026 13:35:18 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint-05-2026; bh=NjiltEpWKo8+XGVIPeclBhOkyH3dhzzS6Rxspq0yy U4=; b=IM+gGpv9LBkN4aH/iCAxFZOCR1knkdIsClMErzyrfUKWiuuwkVo8/27jO ofvCEOkATqr0T7qZ5hQ2bWa5itSuv1feSSuPirc3CRLiGNuXNuhbN78a/uVUAkNA PiR2Qp089MqNt3m3/jc+PVbozYnpNx93LJeKfW7/GmD6qDpKeULMQ6xSFtH03csb NYzKvCqqGDg1F7k2dsyCjvCVM9GZidO8TWh0bqE2QSlxp86GvNHxOpjlb84ikaF2 ccXWYIIXEaGIoipQtWgzUBTqma5wxmDB9JYBUmI3Sg8GDbd8lSy/qeSdN1g9+wvI R5gd2RPLn2YJ0aVaTDsJ496vVOMRQ== Received: from bn1pr04cu002.outbound.protection.outlook.com (mail-eastus2azon11010003.outbound.protection.outlook.com [52.101.56.3]) by mx0b-0002e601.pphosted.com (PPS) with ESMTPS id 4g00w4uj75-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 11 Aug 2026 13:35:18 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=oLlRHP9RjCyQ7kMzz/uOGxPhx6nMBClPw3NEZMrgS/pjUTqqk63xF0hcK1CUGy2xNNcokh5JVQJBqFfCkY+vmSvsaOUO1mGdouBWfsMl8WFXsHG/Ynd/J5tUeboIRD1ioR59UQrCLIGuIC2DO5wrVzvA0MDaECEsv3qBf0RDeDFnCbLwDZUxCL5EWcdo3lYp4GsDKBo7Pm84uxRH0/CD3Rs59sVP/U1z6WpTkwzEGeuW+ckbl0eHHfJLC3guaudxfvhdkPatnS1msVI06nv9n47lUz5BfmbKshVfEyRa3XQ6fSohuWX4ogzRutnEAIKdpjUgofew23oXjtm3o5owdQ== 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=NjiltEpWKo8+XGVIPeclBhOkyH3dhzzS6Rxspq0yyU4=; b=HcBVWe5qqv2QBLKI51l1+WwAzmDGWx6OVLtk4rLSo/fjLkTzAIBLVjgJoXyFdlNNvtcCqs/jF/Iv+mLmYsvIWIf/lJ2n2Gi1kFHCI+J5+DIzhBqK9MPBOPU4zqg0ZOk3Eu9XX1yzjCk1a/duLLb98pM1DTFTi4dyAg4IQiG/MGy8jrex4MnXYT5ex7JYHNVh+yzwo6g/SkdbMgW8RuYBOlZcjJcyOJ+INZYSZNIrCnhAkhWhe2f8ne7RbcpcDrrKReZOhvvt6MFeC6OM/u/F6ct7ShBjG7ikEVMTNDF78gatBRzP22Wl+hkdWsvPF2GzBaT9yn5jE9GckDiXsE9yZg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 198.47.21.194) smtp.rcpttodomain=lists.infradead.org smtp.mailfrom=ti.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=NjiltEpWKo8+XGVIPeclBhOkyH3dhzzS6Rxspq0yyU4=; b=w/xyvjbZPO8I10BCksp32ARIvqMlrA9lRoUWcUmsCNTI9tEyiBYh9PjPaduD1v9fHFyh2uZbK9jG6lWwYVAK5Xne0rKqHHImCJQGf2Jan+RjvFbM0Jgcrnnk4NC5OTE3pXtcYmwwBO8DpkZJfzU3ldS/YCvqF3r5VT/snIDqQXA= Received: from CH2PR08CA0003.namprd08.prod.outlook.com (2603:10b6:610:5a::13) by DM3PR10MB7946.namprd10.prod.outlook.com (2603:10b6:0:4b::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.315.12; Tue, 11 Aug 2026 18:35:11 +0000 Received: from CH1PEPF0000AD76.namprd04.prod.outlook.com (2603:10b6:610:5a:cafe::93) by CH2PR08CA0003.outlook.office365.com (2603:10b6:610:5a::13) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.315.12 via Frontend Transport; Tue, 11 Aug 2026 18:35:11 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 198.47.21.194) smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ti.com; Received-SPF: Pass (protection.outlook.com: domain of ti.com designates 198.47.21.194 as permitted sender) receiver=protection.outlook.com; client-ip=198.47.21.194; helo=flwvzet200.ext.ti.com; pr=C Received: from flwvzet200.ext.ti.com (198.47.21.194) by CH1PEPF0000AD76.mail.protection.outlook.com (10.167.244.53) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.315.6 via Frontend Transport; Tue, 11 Aug 2026 18:35:10 +0000 Received: from DFLE206.ent.ti.com (10.64.6.64) by flwvzet200.ext.ti.com (10.248.192.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Tue, 11 Aug 2026 13:34:47 -0500 Received: from DFLE200.ent.ti.com (10.64.6.58) by DFLE206.ent.ti.com (10.64.6.64) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Tue, 11 Aug 2026 13:34:47 -0500 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) by DFLE200.ent.ti.com (10.64.6.58) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Tue, 11 Aug 2026 13:34:47 -0500 Received: from santhoshkumark.dhcp.ti.com (santhoshkumark.dhcp.ti.com [10.24.52.55]) by lelvem-mr06.itg.ti.com (8.18.1/8.18.1) with ESMTP id 67BIXIe9659766; Tue, 11 Aug 2026 13:34:43 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , Subject: [PATCH v7 17/18] mtd: spi-nor: extract read op template construction into helper Date: Wed, 12 Aug 2026 00:03:12 +0530 Message-ID: <20260811183313.1550425-18-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260811183313.1550425-1-s-k6@ti.com> References: <20260811183313.1550425-1-s-k6@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000AD76:EE_|DM3PR10MB7946:EE_ X-MS-Office365-Filtering-Correlation-Id: 75827002-b065-46b0-9b2e-08def7d74653 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|1800799024|82310400026|23010399003|36860700016|56012099006|10067099003|18002099003|3023799007|22082099003|921020; X-Microsoft-Antispam-Message-Info: HGjo1UTJI6NfxMP5eX1eCyObBN7HskhFXZoGjmQenzQx5OGPI5nbAHKgVgP9oEyE691wkCwL6UKbkmvxWl7zZuGlbKonFhimEmGByJI5FDDbXPTBN6oEsLmU/QjRPXoC4rcFtQ9HxiXd5qRwQwNWSqPmMNyUAS7Mfk4BuQxqZS0mn8PdP7GaPfh2kVXWH3ncsNDq2z3cJNjOfznjby27zvzKNAsEDfZpYXW9BQUZxRlPPcccyFo/zaJ9nisCr6cl3JcbbSyrlA+hB71UEqeozuSHu1812Mjt0KODmMfb9PpHiTai2CEPDWFUkMBShkfiYWpOW0z5bjjbiIksMIOgdWEMnB9dz0+iQMxGuXiZ0pakNrdEL0IBp/rBFN2r82wB12++n58vNvScwOdZ6wmmsGbO+V23g4tKIlF0Ng+LBb3e4KPfp0U8MrtoPd7UeXXbAbSYq9mVm8Ppf7zQj0qcBHBADNmgewt5KkvaIaCk9K4r2TKt/2VEjZIA7z6PWkCzK09N2QQ05x85N/5hdMW694+Vhwz5H7mW809f6rr86NyYvNUqZScGp47oMLXfb7qNBoOlzzQBmig/UwuJtQe3RxkKVj7+EEG4oWGHMrnYGvcnFKrj7EE7rGwUjGJK/f7W8yd893Dvr9ggklg35jNMTkkzowIaJNVwrsKpHYuTboj/0+k9DEBYKad8FOygbjgNMolIApG9rw6DyJAfn2qr7FjBJu6QOq19NIU/TEe80ZysuTCB58I78DjCE+JLzySD X-Forefront-Antispam-Report: CIP:198.47.21.194;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:flwvzet200.ext.ti.com;PTR:ErrorRetry;CAT:NONE;SFS:(13230040)(7416014)(376014)(1800799024)(82310400026)(23010399003)(36860700016)(56012099006)(10067099003)(18002099003)(3023799007)(22082099003)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: tNeyPhrszC2kAsCZ9ng1pp5RyKs3S/yvJMNZM6F0amwarkaQlNCa9FJEajCTLrNeSUX7VToACxuXJRGzCBkXcQulWvE36MhJcGUy3uDnxr97IuErX1Kn5+df3dOAIS4CKGOO9PUA9Y43GZ4r0v9zKYqmM+ZWjpxNzoYV30cPEuDbSnpJD3gQRKMjljqdvE0zq5k1buQd5ch08EML9yHUtZaWiUzIKZJjBZpyJtQSV5LvpIXZes/k/gKZu/PBOvVqkEDXZRinoT7UaKQLveW2jB7xJNwE8SMtALQ5R1sH6loVqeG5/8gWTAoktTHDkNZcRdbXa8FJEP6f7hiSScq3XHWrvYnrkX14yfKy1SH5GCfwWXj04uvN44KoKrGzmyO3LU3ZKQ0lCkS9oKFyCNzWlyb4HODCgRjWBcLJlCEldNZRDuGCFoomhejcUQr8jh3v X-Exchange-RoutingPolicyChecked: oNLEmtOPw+1ZUdi3dW+WMzoImPVnymslG+iJ/NYTibo5iD5Xkf6IAAoEuynY2iQF34xAvl6eDdGF49cVzCa2mBpKZwZh5MuMknH7XBkZTdvHRfEJcqPtsquHHfh5i1gklg7w3MGkzVTCc9QOQ1sfakpwl4gkrY3+b0xrt8QLIAuvN5a0ed2bzQwi4Ex/9afj79ytL364WCFmmoeezEpeGjonr6qfDW3kMRYWLiWPETwTx40DXouuuGNTNkY2u/n8gkiCI9WbkYsoetcW8sNpb4Agk3gqSv27J4jqmTV11eiefghYfgOhpwpw6BbAexlec/JWxHFW5N2kYyoIzpVIDg== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Aug 2026 18:35:10.2231 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 75827002-b065-46b0-9b2e-08def7d74653 X-MS-Exchange-CrossTenant-Id: e5b49634-450b-4709-8abb-1e2b19b982b7 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=e5b49634-450b-4709-8abb-1e2b19b982b7;Ip=[198.47.21.194];Helo=[flwvzet200.ext.ti.com] X-MS-Exchange-CrossTenant-AuthSource: CH1PEPF0000AD76.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM3PR10MB7946 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODExMDE1NiBTYWx0ZWRfX+hcGws46SBTn IFmz6T1eHlQKpat5DR+w7cdrGrQ4aPtzt/+CcxBL8aNn9Z9OehSRAg2VPMcstbODCWwNR6hQyVO 8BCHGiax+hg4y0MWdpi93RM11eTUlVlY/FRTvT8bao8JDO9Ozl7voghpJ9wZc/SzvSFFGsEcscu AX6HTbkcjhTacv2eUWV5Kd+oubKMBU/LXwRS1bnzz9/npRBF/zMixAH2MFUPj83UAuHfgHpu+T3 1f58yS1Jp0WO7iHke226gR91lm3Xc/kmYqpPA2qiG3ncrsohhAaCyIrsIaW+i0pyTbj4G1x8H2P GiZ2hxe9YHF1EAemQKpflHAK++UIxU1KVvL0kGrvHT685jeBLCtp/u6U3as60/g0NiSCDNPXfAK ulqy6PUbmzDjST1HRcGJ++oOpSCuYz3QNWZXx6Q3w81ZFWd8pxMLiWLV9WAQVyVdNjy59VK1OvT NEzoq8ecuU/+PHIPcvQ== X-Proofpoint-ORIG-GUID: hF17pYc0Z2jUeJIjVlfq4GzgchsNMLRt X-Authority-Analysis: v=2.4 cv=KZ/idwYD c=1 sm=1 tr=0 ts=6a7b6b66 cx=c_pps a=miQpwXaPIJxEFudIojRT/A==:117 a=iwqwCZQqcuTv3JOpYdM7/Q==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=Sv0fKeRqtYgA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=fPAWb5peG099m5CrUpKH:22 a=VwQbUJbxAAAA:8 a=sozttTNsAAAA:8 a=XAftrYwPDLqUVEEHSKEA:9 X-Proofpoint-GUID: hF17pYc0Z2jUeJIjVlfq4GzgchsNMLRt X-Proofpoint-Spam-Info: AW1haW4tMjYwODExMDE1NiBTYWx0ZWRfX8Hx25+PIB6kJ aPr82TwoWwI5i0h+KxTUAcnqs/LTKyvh8e5GuaN4Wpk0PIKMciRXQlMAAdWGqVudsoc8bFtzNet Bn/ML77U6FbR7InoF1R4QGkZd1rediM= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-11_04,2026-08-10_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 adultscore=0 spamscore=0 suspectscore=0 clxscore=1015 phishscore=0 lowpriorityscore=0 malwarescore=0 priorityscore=1501 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608110156 Content-Type: text/plain; charset="utf-8" From: Pratyush Yadav Extract spi_nor_spimem_get_read_op() from the duplicated op-template construction in spi_nor_spimem_read_data() and spi_nor_create_read_dirmap(). Using data.nbytes =3D 2 as a non-zero placeholder lets spi_nor_spimem_setup_op() configure the data buswidth without a separate override; callers replace data.nbytes with the actual transfer length before use. No functional change. Signed-off-by: Pratyush Yadav Signed-off-by: Santhosh Kumar K --- drivers/mtd/spi-nor/core.c | 66 +++++++++++++++++++++----------------- 1 file changed, 36 insertions(+), 30 deletions(-) diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c index ccf4396cdcd0..b683c077a233 100644 --- a/drivers/mtd/spi-nor/core.c +++ b/drivers/mtd/spi-nor/core.c @@ -188,6 +188,37 @@ static int spi_nor_controller_ops_erase(struct spi_nor= *nor, loff_t offs) return nor->controller_ops->erase(nor, offs); } =20 +/** + * spi_nor_spimem_get_read_op() - build a configured read op template + * @nor: the spi-nor device + * + * Returns a spi_mem_op with the command, address format, dummy cycles, + * and data buswidth configured for @nor. For direct reads, the caller + * must fill in addr.val, data.nbytes, and data.buf.in before use. + */ +static struct spi_mem_op spi_nor_spimem_get_read_op(struct spi_nor *nor) +{ + /* + * data.nbytes must be non-zero so spi_nor_spimem_setup_op() + * configures the data buswidth; callers replace it with the + * actual transfer length. + */ + struct spi_mem_op op =3D + SPI_MEM_OP(SPI_MEM_OP_CMD(nor->read_opcode, 0), + SPI_MEM_OP_ADDR(nor->addr_nbytes, 0, 0), + SPI_MEM_OP_DUMMY(nor->read_dummy, 0), + SPI_MEM_OP_DATA_IN(2, NULL, 0)); + + spi_nor_spimem_setup_op(nor, &op, nor->read_proto); + + /* convert the dummy cycles to the number of bytes */ + op.dummy.nbytes =3D (nor->read_dummy * op.dummy.buswidth) / 8; + if (spi_nor_protocol_is_dtr(nor->read_proto)) + op.dummy.nbytes *=3D 2; + + return op; +} + /** * spi_nor_spimem_read_data() - read data from flash's memory region via * spi-mem @@ -201,21 +232,14 @@ static int spi_nor_controller_ops_erase(struct spi_no= r *nor, loff_t offs) static ssize_t spi_nor_spimem_read_data(struct spi_nor *nor, loff_t from, size_t len, u8 *buf) { - struct spi_mem_op op =3D - SPI_MEM_OP(SPI_MEM_OP_CMD(nor->read_opcode, 0), - SPI_MEM_OP_ADDR(nor->addr_nbytes, from, 0), - SPI_MEM_OP_DUMMY(nor->read_dummy, 0), - SPI_MEM_OP_DATA_IN(len, buf, 0)); + struct spi_mem_op op =3D spi_nor_spimem_get_read_op(nor); bool usebouncebuf; ssize_t nbytes; int error; =20 - spi_nor_spimem_setup_op(nor, &op, nor->read_proto); - - /* convert the dummy cycles to the number of bytes */ - op.dummy.nbytes =3D (nor->read_dummy * op.dummy.buswidth) / 8; - if (spi_nor_protocol_is_dtr(nor->read_proto)) - op.dummy.nbytes *=3D 2; + op.addr.val =3D from; + op.data.nbytes =3D len; + op.data.buf.in =3D buf; =20 usebouncebuf =3D spi_nor_spimem_bounce(nor, &op); =20 @@ -3712,28 +3736,10 @@ static int spi_nor_create_read_dirmap(struct spi_no= r *nor) { struct spi_mem_dirmap_info info =3D { .op_tmpl =3D &info.primary_op_tmpl, - .primary_op_tmpl =3D SPI_MEM_OP(SPI_MEM_OP_CMD(nor->read_opcode, 0), - SPI_MEM_OP_ADDR(nor->addr_nbytes, 0, 0), - SPI_MEM_OP_DUMMY(nor->read_dummy, 0), - SPI_MEM_OP_DATA_IN(0, NULL, 0)), + .primary_op_tmpl =3D spi_nor_spimem_get_read_op(nor), .offset =3D 0, .length =3D nor->params->size, }; - struct spi_mem_op *op =3D info.op_tmpl; - - spi_nor_spimem_setup_op(nor, op, nor->read_proto); - - /* convert the dummy cycles to the number of bytes */ - op->dummy.nbytes =3D (nor->read_dummy * op->dummy.buswidth) / 8; - if (spi_nor_protocol_is_dtr(nor->read_proto)) - op->dummy.nbytes *=3D 2; - - /* - * Since spi_nor_spimem_setup_op() only sets buswidth when the number - * of data bytes is non-zero, the data buswidth won't be set here. So, - * do it explicitly. - */ - op->data.buswidth =3D spi_nor_get_protocol_data_nbits(nor->read_proto); =20 nor->dirmap.rdesc =3D devm_spi_mem_dirmap_create(nor->dev, nor->spimem, &info); --=20 2.34.1 From nobody Tue Sep 29 06:08:43 2026 Received: from mx0b-0002e601.pphosted.com (mx0b-0002e601.pphosted.com [148.163.154.28]) (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 985783803E3; Tue, 11 Aug 2026 18:35:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=148.163.154.28 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786473320; cv=fail; b=Gkji05hcMYL3sUFChpyJnROV0aBqHgZ1+cCNUZoScPzIH02+PZ1wBdBtUxXIhAT8D1AoOotyYQylikiVfOEspqaXWOyVR0sdYLkv3ZDal+mkjynNmAycMbthuKgzxu7DcSqGd8lChS/vSxuDniinywcRwX/ymKiB/q5aOHdZ/EE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786473320; c=relaxed/simple; bh=QCZfApz0WI4MJamsj+4VqpsLIBBqXuUtwo6CKXU3FV4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=QeKKOJC02tUer9sNYdJpE/sPRVDAYda+ZhATUOLycueVymIHKAGt4kWj0bHuYH/KUlZwhjx5I1p0TQERPyWSbqP2WBt222zOQm3Keo6+a0b7oGTwiG5NmNV0253CTlesp1CozyNOZvkp9x+vcGYJtW6A0wJKUPZ/XzWbzoeIDLs= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b=cq0etVM5; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=ieFz7rGj; arc=fail smtp.client-ip=148.163.154.28 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b="cq0etVM5"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="ieFz7rGj" Received: from pps.filterd (m0374956.ppops.net [127.0.0.1]) by mx0b-0002e601.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 67BGMNbf1824579; Tue, 11 Aug 2026 13:35:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint-05-2026; bh=CaKka2TXrNmZxg/2rKa+E19ixmWvfwzQpJ0sWclJR yk=; b=cq0etVM55pNppS7b1wDZxvEA4CflKjz+kj64z3BUl3IpHTcPRTKBE/9i5 jw2STZV5wNJyj1QZwEFFOYgztyEQDH3PgsgskmKYeUwn10P2cLcppSIlvgEyX6/5 GhjpaCecCMA1yE708FyTInG1C9GGUmCo/WPrWhVUzapoij2DkmJrN4mWjBnMYFck MTUPv8J59RvYcYXXAPhCh4Tjzt+G7mJjjfiSmnQFT6lJpzImz6CNYaOYY/WnuWJo btThpMiyzpSNUWeaSAP+6T7aK4FUezsjF7A+AdI8dWmlKB0yD1ellSxdV0Wi3n87 qoWnY2c2C6adhJnKHGlHF9DZiL4vA== Received: from bl0pr03cu003.outbound.protection.outlook.com (mail-eastusazon11012038.outbound.protection.outlook.com [52.101.53.38]) by mx0b-0002e601.pphosted.com (PPS) with ESMTPS id 4g00wnbkbg-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 11 Aug 2026 13:35:09 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=mlgUfXJa5EOY+vWpoCM4cp1Y7eRaxJj9gJ8nNxJjt4sHRRFyUnQyvPdLHaqzQdCPaDlFzU8DPHbSimq6cXtwydbN1enrYBL5ug6x6OZy0ujaW4kkjp6Wpn90VIXabh2S3rD3LhqCdqIcOrvZN7HdcLOxkT5um8sPhhXJKc1PDR+YNYinQ42u0qgp5z7ZCLwfNq+EG2PL+yPJ32s2rna1637PENVvo/urvoKWCQRVJwFniFdkHrO66NTzcitJEnjAs09lVQgLfwEg+l/g0dVA+wq3JSES5lXcqvNWV+1PRh+0zFxhLiHKTrOUPEYjKBx4FGiuoH1UozWTW4umSt925g== 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=CaKka2TXrNmZxg/2rKa+E19ixmWvfwzQpJ0sWclJRyk=; b=lz2tNRqk9cqZinoB/m0v6+Sx6h8MflgL7Bq8m6dliKhOPX6UY1FVE6hicQo48aN1W76D2P6ly0Q9c/235YflzFMf81N5pUZXCAOEH0vKnVHyRyPU0cVg6AISVo+MvskBNdx/hH00FUOjo09UDcOAOT+rcwwKKvI7mjprz5bmKqqvbRHfWi0y+a6s8RVZHUBmESCx49H5+2IBKpJIuG5rneEjtBmu89X5L4SrkXsBULpUD1HQydMeiKLSfc1xqQL46prJEj819dZ6k/tFlYPqgqR0z7MiIryRqcrcvP3C71TSzbl5aguho/wEHPk2pk/X6MmsvvPllX9rLbqEWOEYaw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 198.47.23.195) smtp.rcpttodomain=lists.infradead.org smtp.mailfrom=ti.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=CaKka2TXrNmZxg/2rKa+E19ixmWvfwzQpJ0sWclJRyk=; b=ieFz7rGjEplBdkbMjDPM6MzONNDWn89krfE1q/zc9FE6AplxawOiY547o1Tmp1x0m68uRpCYZ13piOl7OhfaO8JnfI+mGqzjt1ZzV9FTE/cPPLtuG4tft+MbiEfswelwT/FZxXVaaEaOMfHCExn9IE7yArHaham/MWp2oZEQ8RM= Received: from MW3PR06CA0007.namprd06.prod.outlook.com (2603:10b6:303:2a::12) by LV8PR10MB7824.namprd10.prod.outlook.com (2603:10b6:408:1e7::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.292.25; Tue, 11 Aug 2026 18:35:03 +0000 Received: from SJ1PEPF000023CE.namprd02.prod.outlook.com (2603:10b6:303:2a:cafe::80) by MW3PR06CA0007.outlook.office365.com (2603:10b6:303:2a::12) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.315.11 via Frontend Transport; Tue, 11 Aug 2026 18:35:01 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 198.47.23.195) smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ti.com; Received-SPF: Pass (protection.outlook.com: domain of ti.com designates 198.47.23.195 as permitted sender) receiver=protection.outlook.com; client-ip=198.47.23.195; helo=lewvzet201.ext.ti.com; pr=C Received: from lewvzet201.ext.ti.com (198.47.23.195) by SJ1PEPF000023CE.mail.protection.outlook.com (10.167.244.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.315.6 via Frontend Transport; Tue, 11 Aug 2026 18:35:01 +0000 Received: from DLEE210.ent.ti.com (157.170.170.112) by lewvzet201.ext.ti.com (10.4.14.104) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Tue, 11 Aug 2026 13:34:52 -0500 Received: from DLEE209.ent.ti.com (157.170.170.98) by DLEE210.ent.ti.com (157.170.170.112) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Tue, 11 Aug 2026 13:34:52 -0500 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) by DLEE209.ent.ti.com (157.170.170.98) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Tue, 11 Aug 2026 13:34:52 -0500 Received: from santhoshkumark.dhcp.ti.com (santhoshkumark.dhcp.ti.com [10.24.52.55]) by lelvem-mr06.itg.ti.com (8.18.1/8.18.1) with ESMTP id 67BIXIeA659766; Tue, 11 Aug 2026 13:34:48 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , Subject: [PATCH v7 18/18] mtd: spi-nor: run controller optimization before dirmap creation Date: Wed, 12 Aug 2026 00:03:13 +0530 Message-ID: <20260811183313.1550425-19-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260811183313.1550425-1-s-k6@ti.com> References: <20260811183313.1550425-1-s-k6@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF000023CE:EE_|LV8PR10MB7824:EE_ X-MS-Office365-Filtering-Correlation-Id: 9b9cf197-d2af-4263-01f6-08def7d74150 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|23010399003|7416014|376014|36860700016|1800799024|82310400026|22082099003|18002099003|921020|10067099003|56012099006|6133799003|3023799007; X-Microsoft-Antispam-Message-Info: Kmt7m2RuN+1zePww5ENTmHvrrE3IMQeFuXg36ObrrT9ta6M2U7GFWDb2iOLuEl7bvR+Ll0/UV4gzwwc/GpU3wXA+dYlOHg2RlqLbZErj//pWtIoOiRWb9FP0GpsAYErAKAIXRVEN+jWZGivkk4taemacj/oennbLLZVtQXtFF9teI+Z22hp2jerVMzUSzhDjYs1xUGIcYI43hXODy0wi8vHtDi3z4REdkRSXO/LT21xcvgvlVm8eb5EWLkVow6fAiXWnMt7yHQrFekJENKOT6jcuqIWKr8KNRIEhAjoheuSkfGn8STGBNRikpEyOGx0xhZ48FsLRQI+OLG/jmckgLrYrebHWTGFQtXspLQ8si/81GeREiUZKi8ZizYuJ5JH1WEM1GVbeLxgLRAfM+usptAmrJOSsqhD4Oen1jxaLaB8AfPwoMnAly5zq4SyG5d4WSVudiSYt4m6KBCrxiNByeqnY6lq5etgo5SxkOL7C6KxOiMfFQi3mNQnKphDYdsnitH0PgfGFg9Qvx3BkQ8KDHwQEeDE3YTnymEGkdQ2LPwyHWSInly+gZyzjiC1uutMm6GbjHJaCEweaF+q9vH9ZDOpb8U02xlql3mGCNeW90b141+BYUwbBSIiYhjGVgrkxwUyS/nk5DHuEX/3zR54WpypjDla92hV2eSwWIF7CQutiry5zqZ+Tuf+diz4G3oEi6+VWwU3pfMbePjPEmSBjO3+P9yEevmu2dJSoBeqXFKgU7Dap23UG5Tk1kwdL+iwJ X-Forefront-Antispam-Report: CIP:198.47.23.195;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:lewvzet201.ext.ti.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(23010399003)(7416014)(376014)(36860700016)(1800799024)(82310400026)(22082099003)(18002099003)(921020)(10067099003)(56012099006)(6133799003)(3023799007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: gDC6WW5HEY1g4r+0EYQxNdBsZBO52jFae5ILd5uHPKIICVTog78eY17iFKIsLw71ESDD2moxFS2Od2XFl1ODWdzn8vF2cQW+A0QuQMCp5QjtWbgzklZZ4ve/VgLVn9C1b9KVdq0/yIrEuVD3HsvXi0qhaL+8k2THu5axwgzCdM1Blx/gqhZ9jVPyz1wlDNnRmThsVDwu9KVCu2IhZvDdd7TobjdTq9IwS7q2HlJVw/4RTjeR5f5wUwgE1Wn7Xdy03Xsyu+ZFOhjWeLXLlCpetmQbfXE+cLSApib9pnFZPGLjinw0oSUXdI+giXkMfTqaI9T31d1/MCwiR0f19tiXDpLtw1LMtEuONkQoI2y5cNIJ1wWyT1MxIdP13j7HYlqyMnDiXG1NJSRbje45bNmvpsb1Temlfw1yToVWfUwmo/X9nvRhQnzMrQSZed/MOZxx X-Exchange-RoutingPolicyChecked: ssmzCYXHF/mQJyINjkkP7WNDYL+pKytRd5EbnY+77qYIvyDnsrGic14dJbt9hASAiTpkepi6EacBUdITZPhdcfk1/7T2H3io++jbIWoMv51yDbnJchrF7uyV5WyA6cXb7o0oRFhiZQ9Iz9KxQCaXsW9EM+Oy1/RI1AQhTo/OnUcKgMNEyTPRA/tWJpuNFfm3T2SwhJbk9VXVQH9rlt21sctd7U1OM2L7soLVuVCPauNvnO+rzjImZec0A3pgcloj5VZyIgWxL+RDYI6WR0lCr4eGvUx21hbNvR/IJikEiRytfjZuwhxFHOA9C+nnv9dPZaDWQqMCOpAfglugJjtnIw== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Aug 2026 18:35:01.7669 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9b9cf197-d2af-4263-01f6-08def7d74150 X-MS-Exchange-CrossTenant-Id: e5b49634-450b-4709-8abb-1e2b19b982b7 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=e5b49634-450b-4709-8abb-1e2b19b982b7;Ip=[198.47.23.195];Helo=[lewvzet201.ext.ti.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF000023CE.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV8PR10MB7824 X-Proofpoint-Spam-Info: AW1haW4tMjYwODExMDE1NiBTYWx0ZWRfX1JXy4YnTx2uU CYCuAEb78a2Jm6kmuanDalX09FfAynKLFB8nWtyrjfmKDFxBs3qdP0nWghyv84Kx5xVZ3L3DJ29 2lOTXkQ2+5vNwYhp4ZgfqP0TizHp0Ms= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODExMDE1NiBTYWx0ZWRfX2S1c8E9SPCmd ZHHR/6MFxLOC1UfXN7BhCKnyZenVydNMsGxX1rplLbVleyXVrTOyGLcZnZbTkJy+fM4cOmaYzDv UzlH77rGElHhClf381eNkckxsBJk8j5M151pGZouD1VMnU4SiC9bcHgjXqanWKzLFjsM8uw23JW t+SfICo+PQrVpc2sIxaR9LWatPxmPwIBdPfLYz+pya9Tu4zKybgpg8PZyqau5ajhV5IuntsUUdI 4TWss2hofi7LNtm23UDns2oWNfiEp11qIhJ0LKQO45uQ61Y5YOZFZYuA8CaVoc6/iltdzWvuOug Nmzm0KefT6t6T3R7wQetEG1yRaurMUQ2/89CZ6d+zgll1UzvDtTbyj4j9kibAPl8ZHL6CsLvwdV crNZceFJSrdj5HDnYXBo4tby5pVhwpc3hBapIGuxfTgKzCF5wmjm6GDOXBP574mROAJGtI0X/iF Hjpi7qbCkcpXSas2mQw== X-Proofpoint-GUID: TnxmyzMaCXRHdEeZgh27l09KcPdRQGer X-Authority-Analysis: v=2.4 cv=cYziaHDM c=1 sm=1 tr=0 ts=6a7b6b5d cx=c_pps a=EbvyHBp0GqBzY/XWR/wUiw==:117 a=f+v6EHfkeJbVwR46tk4DMg==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=Sv0fKeRqtYgA:10 a=s63m1ICgrNkA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=jwouBfj2j3NM8CExmVVE:22 a=sozttTNsAAAA:8 a=dAWDYLcBFR4q-bF-ZFAA:9 X-Proofpoint-ORIG-GUID: TnxmyzMaCXRHdEeZgh27l09KcPdRQGer X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-11_04,2026-08-10_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 bulkscore=0 priorityscore=1501 spamscore=0 suspectscore=0 impostorscore=0 malwarescore=0 phishscore=0 clxscore=1015 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608110156 Content-Type: text/plain; charset="utf-8" Run controller optimization in spi_nor_probe() before creating dirmaps so the validated frequency is available at dirmap construction time. Store the configured read op template in nor->max_read_op and pass it to spi_mem_execute_tuning(). On success the controller sets max_read_op.max_freq to the calibrated rate. spi_nor_spimem_get_read_op() propagates nor->max_read_op.max_freq into every op it returns, so the validated frequency flows automatically into the dirmap template and into regular read ops. Optimization failure is non-fatal; the device operates at the conservative base rate. Signed-off-by: Santhosh Kumar K --- drivers/mtd/spi-nor/core.c | 14 ++++++++++++++ include/linux/mtd/spi-nor.h | 3 +++ 2 files changed, 17 insertions(+) diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c index b683c077a233..2efcdc7f637f 100644 --- a/drivers/mtd/spi-nor/core.c +++ b/drivers/mtd/spi-nor/core.c @@ -216,6 +216,9 @@ static struct spi_mem_op spi_nor_spimem_get_read_op(str= uct spi_nor *nor) if (spi_nor_protocol_is_dtr(nor->read_proto)) op.dummy.nbytes *=3D 2; =20 + /* Propagate the validated frequency; zero before tuning. */ + op.max_freq =3D nor->max_read_op.max_freq; + return op; } =20 @@ -3843,6 +3846,17 @@ static int spi_nor_probe(struct spi_mem *spimem) return -ENOMEM; } =20 + /* + * Populate the persistent template and run PHY tuning before dirmap + * creation so the validated frequency feeds into the dirmap op. + * Tuning failure is non-fatal; the device operates at base speed. + */ + nor->max_read_op =3D spi_nor_spimem_get_read_op(nor); + + ret =3D spi_mem_execute_tuning(spimem, &nor->max_read_op, NULL); + if (ret && ret !=3D -EOPNOTSUPP) + dev_dbg(dev, "Controller optimization failed: %d\n", ret); + ret =3D spi_nor_create_read_dirmap(nor); if (ret) return ret; diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h index 4b92494827b1..ab498a50f15f 100644 --- a/include/linux/mtd/spi-nor.h +++ b/include/linux/mtd/spi-nor.h @@ -422,6 +422,9 @@ struct spi_nor { struct spi_mem_dirmap_desc *wdesc; } dirmap; =20 + /* Persistent op template updated by execute_tuning with validated speed.= */ + struct spi_mem_op max_read_op; + void *priv; }; =20 --=20 2.34.1