From nobody Sun Jun 21 23:24: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 BE7D93D301D; Thu, 18 Jun 2026 07:38: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=1781768300; cv=fail; b=PJ0XOB5CfSHoB8z3WtZ59v0/M+8xx7PwO6N/NNARO93+jBpc3WTr/ZtOumCUQN503ZFNCvUvda/dzF0tYHUu3CTp5ODuFX41FCPOlshG2gdEz8bSZGIAfkdinvgR40P51V2xa7wdjGxPla/qex3ZuMOToNFX56RsIyXxD2oTQNk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781768300; c=relaxed/simple; bh=Vu1teNYjRv4sFo36XLDl4erWEbvPwLbZv3uwiHzCMqs=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=pgeCaU9W8QbRnQ5cyJzB4qOMZLsg3kCprRR/sVU9k5dF12jMrNyR9ZlQi+1wOo4pI2rNXqPU0EtOehNwsZAIkGdxsBYy4vAj0BLXCaQHJ59QB+cZt+DU3r+pbfHot34ELxz/j3Cdd2QFd0COkY4kHf+vwi9zeEz6EKhnEyDWeLI= 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=GY/eLEbO; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=W2egxUxZ; 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="GY/eLEbO"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="W2egxUxZ" 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 65I6iBrS3435899; Thu, 18 Jun 2026 02:38:02 -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=mqbrIgldhLr+OttscChTubSiZsBqcUGXMqM4/HbER OE=; b=GY/eLEbOgnt9kC74FvoDiyguzf72pdgPk4rM3/2G9D2V1SMLzmyj5yTIx z9YE4AoLx320K4NQb3Mxn21E5mcdyiB1qa+A8p34BbKGLWxHeLTE1XyyBJ8uwOtI aRMAR5RuXek2q3RkGRR9eTuF1o+tk6z45UcgJ3MHf8H2GYmM14CYbpZVB76Ao4Lf z6Ns95LdDWfVew8gmkxTvo7GqED1Nw40Ol4u+ROZcurjZQnbF2GRg8vDt++0cD7L JdK1VwUEWknX1LyrtU2o7ecvyHOzAMMF3JbIdkFmP+l+T8VdZ5z+sgDoKlkcudxR Q841IQpnJiJNHBWXJZzAZlddyZ0bA== Received: from cy3pr05cu001.outbound.protection.outlook.com (mail-westcentralusazon11013037.outbound.protection.outlook.com [40.93.201.37]) by mx0b-0002e601.pphosted.com (PPS) with ESMTPS id 4ev63rj0y5-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 18 Jun 2026 02:38:02 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=cjXV+qNV/FfQp1GZ7kV1T065ZUkTn4pCtDobjfF/DeLiA2AuZyqKIUXm7otHIA34E/+I3oHDE7WJF0rfBDvTfkOg+LcuIu+1sXwcdATi/wqo2aozSlbsrXtHoQhn8TsBkwaRf0Cc3z6/bLv1xHLuIfLXCTcxexNKbL1C/VHHklIXV+yhAvXpxDXrlRKCrJyZvewdll6VZnOM/Ow3T7aDgU2UZaxm8S3to1v419SAi1xbejPrgI7l3fcD2Fk8C2N0HdaqOld3MS0Y15yWNfMmsuJSgjv4yrDje/noE6KIQbNeooP5vN3Y25HCIZJB7rOARi7pr9HIoB+Xe4epprVAGw== 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=mqbrIgldhLr+OttscChTubSiZsBqcUGXMqM4/HbEROE=; b=sVXRT7/9YgY3rJXPMYPK3x6SCCmIvSTdSnulISJUn9ugp42zZz6SL7ZzWAwOkZ0/qPSzvgc2jT6xGDxWgKPvyQxcGvVXOdRJT43GWbS8E7uNIqpdd4M4a+0y56QJkF51/IRQj2muiWhq/H+qORU4wQLQ306U5SK24wBUuRPKSQr9T3FzMBdknJDlgRfeOnOUmxAOPYs/ZVGb27zSmcFhqWk2e19gooblbO3edypJFh9OJrun/59bv4xAiCokvfU5vqDvVr3TsCjG/TKXzXLWkRCvzN5ZfzecxG2vhQjXHzAEKniAhk46PjL8Q+aLrzvX1j9vh1F+f/qDl++5e3fJ5Q== 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=mqbrIgldhLr+OttscChTubSiZsBqcUGXMqM4/HbEROE=; b=W2egxUxZ6fLt2InPb4tI9bQcs4RlVEBIEG8U7jxEWRV2pi7hHeZ/DOqQwoa6fXEV7F5SK0PpmWy/exdDm/l4AToC8Fso/LAGe0KnS4tnyTVk3Alybi6QRJsY9I/pykaQQINKtue33wNpT3s1VLuag+sErH/DOw1oy+aIXqKVcD8= Received: from SJ0PR13CA0113.namprd13.prod.outlook.com (2603:10b6:a03:2c5::28) by IA6PR10MB997584.namprd10.prod.outlook.com (2603:10b6:208:5e2::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.139.11; Thu, 18 Jun 2026 07:37:59 +0000 Received: from SJ1PEPF00001CE0.namprd05.prod.outlook.com (2603:10b6:a03:2c5:cafe::a) by SJ0PR13CA0113.outlook.office365.com (2603:10b6:a03:2c5::28) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.139.13 via Frontend Transport; Thu, 18 Jun 2026 07:37:59 +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 SJ1PEPF00001CE0.mail.protection.outlook.com (10.167.242.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.139.8 via Frontend Transport; Thu, 18 Jun 2026 07:37:59 +0000 Received: from DFLE215.ent.ti.com (10.64.6.73) 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; Thu, 18 Jun 2026 02:37:45 -0500 Received: from DFLE215.ent.ti.com (10.64.6.73) by DFLE215.ent.ti.com (10.64.6.73) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Thu, 18 Jun 2026 02:37:45 -0500 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) by DFLE215.ent.ti.com (10.64.6.73) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Thu, 18 Jun 2026 02:37:45 -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 65I7bYvc3521710; Thu, 18 Jun 2026 02:37:40 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , Subject: [PATCH v4 01/16] spi: dt-bindings: add spi-max-post-config-frequency property Date: Thu, 18 Jun 2026 13:07:10 +0530 Message-ID: <20260618073725.84733-2-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260618073725.84733-1-s-k6@ti.com> References: <20260618073725.84733-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: SJ1PEPF00001CE0:EE_|IA6PR10MB997584:EE_ X-MS-Office365-Filtering-Correlation-Id: 458b389e-275f-4eeb-cf6a-08decd0c8542 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|23010399003|376014|7416014|1800799024|36860700016|921020|56012099006|6133799003|18002099003|22082099003|3023799007; X-Microsoft-Antispam-Message-Info: IFvy/XAbPZWnHVOvMvqtuYf+WM9zdgelb9mij4Rw2/F85+vDmitTmTQ11TIqm8ZD+g1CCdxyzO1BGz4ICjQwqd9FTjoI2habW1Nrd1uHlvcbK5YCTcVBIVcAV/jG0oAdqivSPewlev6RV8H1rFDSMzGSILIj0rjACo3DHvYvt7VgqbZTjsEAR38Xf5CInVAeyti3hwhDBLma68B2gFFOXheuiByJSdIS+BkJG4kP39izphNyva3plv7zCo8sC9Iec9G4+I1yPabWYtRvjHOMmpkYU0KwUTjl+n3DGtk8PHKYgbtvrvQZQYt3hB6HmLeE2E0ecFbLLYN4xEe6nBIZtVfg4sfk7GA4mbXjtHaZEw1xUmfS5HtdJtyxfv5i1yvqgwaqszncFoDO9R0/9vLtHJR9/azzO0Z4gXp/+i+xeiw456oLjVkdq6pX5wMbN0VQgRzkv6vqQMHDpcaVLOAMQUcDoEjKQ0zlD2xPPRQkzNzGXdopnfWt/EygqZ5rZ/r1cwj4/vxanyAYVccEIozbHaqqSM2MEgSfRuLb2y6GF9BsNs58Lm0KcxJKgweYrFOud4ra5hX2tFmM34HVMNmJBFIk7SbyxwthMss5orkYpJyL7ws6TaOcE1NqmC07VVi3PqDrURSmlnDzJfmVunJUYBIOsJKFbTvXnYTrlnIW/m8DpDDNE+LuhYM56zxuWyENGgFUFU0mPPWxkyL+EbWuwRiBBUPPJnQ1Pi2Md7r57tMY/yD1CDC9J14Jduz4FJNzWpO0r9Pn/772Hhv93RueNA== 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)(23010399003)(376014)(7416014)(1800799024)(36860700016)(921020)(56012099006)(6133799003)(18002099003)(22082099003)(3023799007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: bz5aeyxvhQn9GjG4qBv9ELUjhNWCwmGER7y6oErV+LlS/jrA9D2196jO299bhXgsAsMFFzniiTjNFqj19qDCP6wbAs2SzjoR42mGyCJzIvXnJr2kduWQTvvihjxpSe/+oxtVs7uJCjOJ5l/mtr0baZ3QN0TJ11V0VdyS0rn54Y/43pxSRWqVy6wO8IzwB3CQvU+oxO+Qj/Z+EvxM3BdJHzt424wEC9jq2gMe6LdWu/Hmrvzv8YiFxXsLiwqZQf7cEsEfnQGgZzPpFfjDYpfc3XzbuDFvwgbeBXqhAD/gHTutMXEh9T400v3gKa5Sx3V26Geb3WXCrcpXZTMq4J7cX4tIHBQkxTehkzCik+h0/k2xDX1+priXfQWBIr13zNp2b2MIznarSStlL7dz7tX1djTUcEUHkvtqH+L1h7QEg510THP3M3DZ1KeH68iTuzCN X-Exchange-RoutingPolicyChecked: XRMV4SKX5+5O7zVoNazkaCLyD9XPX0a3yzSBBVmCkDEfrX2i41xDeo3DRTexLzEVLK22t1oYR4D4EXp67RG/q7iZN12S35kq/+kux/a3GrRzC3oUnprx81tD3zFKG1wjyqwemAPqxqNX/+FvFr3Geok7pokQ12d2nlFeIkPZClPxCWDoT6iFu2+jaDiz0HFz+H34Sk0QyfPBcJYtaMRBub/kaqSoyYPAUs27u9OtlgeGGUF3x5JpbKF0R2REbH8DCA2Oj4nILm6gDtuuC7cEfCpdXNZneitrn3fyCpyeuTjsXMvpKABhPaIXVabfQGKr6BF3TfoA8p4f3nCxPQATfQ== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jun 2026 07:37:59.1002 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 458b389e-275f-4eeb-cf6a-08decd0c8542 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: SJ1PEPF00001CE0.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA6PR10MB997584 X-Authority-Analysis: v=2.4 cv=LpqiDHdc c=1 sm=1 tr=0 ts=6a33a05a cx=c_pps a=a2CzU9h33xTdk3q/+L33yA==:117 a=iwqwCZQqcuTv3JOpYdM7/Q==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=FelO9ux0wxsA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=fPAWb5peG099m5CrUpKH:22 a=sozttTNsAAAA:8 a=skPbNTvFiSR7kuR3s9sA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNjE4MDA2OCBTYWx0ZWRfXwEVlVTXonpFD tMoQ7WMIEQ9mSvbBZ60zG/xeJT9dH/X5F1pFqppYxcwSecaptqpye+8NU+ewlDAPLPEylcjI9aN 1R36iyzcLyAqtWGn3/4Yw2K8WTwETNSftmuMfp5nxAkMUW5l4e4VGf4ThxgpRi5eMw+n1UP8zaT Fcvn2gdB4pXdTm0NgO584dIPi80AdW8bHsUi6rrL2++zJtlrEbhNua3kG2Gyc1QS4K4dhLGdDOH B8AWXQgecQsdF1V+hcs6oJCUwgBOOJcWsR/0IcM4y+Ub54FaPCmJ40RcmtpPXzC3VhYscKtce+d mzQ0b48tfaOVYbCQQgFbhRexudwsc03YvlZ3LuJ6AMbb0XewyKvy3qj53VV4kHOT+1O1fuAzsxy GWewPK9X+4eD0Vb0k9e52407Lj0eJfa171b+KXchGFmt8SVtMQz2iOArvRCTfREF4b3HjB/CbwW 99N0MZj+uvodYhrfMFw== X-Proofpoint-Spam-Info: AW1haW4tMjYwNjE4MDA2OCBTYWx0ZWRfX8iK1QittEkMW vWXbmDhl9Ar2HQAs/Bow7swiE63dxZtBZFg6OS9YYmZJVrYaOUBMWi4KZ0paqmv28z139S1Gs9J aCJq1c8lFc2gbONQQmfqLw0Ka3akT7M= X-Proofpoint-GUID: IhGQLUSPCDMcvcm1k21WT270NwOSsIj7 X-Proofpoint-ORIG-GUID: IhGQLUSPCDMcvcm1k21WT270NwOSsIj7 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.125,FMLib:17.12.100.49 definitions=2026-06-17_02,2026-06-17_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1011 suspectscore=0 malwarescore=0 impostorscore=0 spamscore=0 lowpriorityscore=0 priorityscore=1501 phishscore=0 adultscore=0 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2606180068 Content-Type: text/plain; charset="utf-8" Add spi-max-post-config-frequency, a generic uint32 property for SPI peripherals that support two distinct clock rates: a conservative rate always reachable without controller configuration, and a higher rate reachable only after controller-side configuration such as PHY tuning. When both properties are present, spi-max-frequency gives the conservative pre-configuration rate and spi-max-post-config-frequency gives the higher post-configuration target. Signed-off-by: Santhosh Kumar K Acked-by: Conor Dooley --- .../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..ece86f65930f 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: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + Maximum SPI clock frequency in Hz achievable post 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 Sun Jun 21 23:24: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 F12133D3D1A; Thu, 18 Jun 2026 07:38:21 +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=1781768303; cv=fail; b=UgSJcL+stWQHY9WspHCu8qZLvEFefKAyB6JFG7K8sJAXBi/7DMPgmif8FBgAqhtK9v8T7Q7O93cSaXpEZ3TiVJpoIRVGCCevLQThqF4jL7Uqaj5lKWqZnUnEWkvUEWbndkekwaF7tn2i515sLI1MtRIiiESnL525iZ2vQCxxMb4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781768303; c=relaxed/simple; bh=Y+/RqBSTVSE8voR2NvvZxxAvxN5wbWU+037GIN6R47c=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=D/iATG6Yc6Q7N/f3pwJi+T1mrPhvYlFwG0LI6gsxJxqTKvzGOKrpmXJN65DXftoJwZYxoG52F/Q2NLB8FEtogkAxUTSN2ai/O+XysfMqa91VvUOAePQ1hGs3gHcgC4cXo68rpx4ku+/rsDVDHd8n0rjJ4O2Pa8zyWbb1fIrHP/U= 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=AdRIcMbS; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=iEfOseTH; 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="AdRIcMbS"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="iEfOseTH" 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 65I3ne6f3790566; Thu, 18 Jun 2026 02:38:06 -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=1aatmYLlcC0l5UoTFBkid383BeZCZ0O/sLOtEY0Pg G0=; b=AdRIcMbSQwUOHZb0YOj0Qi15yPcbSk2OIcRpnchFMpVw1y+6pe+Qb0Fid SsyFuBUPXu9Mv6xyjCLUpyXERSk1j+wQRdjNftE4qaSc6HtX183ThEppVi4LgIV1 c5k4XX9T5hB9maGnpgJagdrHzevNRhzr3h7KR6XKROy4wDDIqr81xeDKcYhhZZYk mUx9RSGzWucYGNSpPyYBMypsnTy2U9ziAH/6MSXwTTqQHSf41uoXzj6XWN7FPKec nfT6vcJxf9CUZYIKNK7Pq2sW28hPRiZkS7vt72ir1M7f8Gzvp32x93m6sp4w5Tn2 EX5oSGc9QC0dtx7vKUQRme6MTxmJg== Received: from cy7pr03cu001.outbound.protection.outlook.com (mail-westcentralusazon11010049.outbound.protection.outlook.com [40.93.198.49]) by mx0b-0002e601.pphosted.com (PPS) with ESMTPS id 4ev944932u-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 18 Jun 2026 02:38:06 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=J0ZCOLXDnnqx2KHaDTVqaGMtWcD5lR/9oW1tJRwOlVd5GHj9hzXArgcckI3Ew3hPvcJCgFiWMATT13i8GQo2Cb9kqn3+omznruE0F1lPIK9NNk2AwdOsyCQ8Pv0i0RaRESx8PMcFYs46AcElitJRTNcUY+/V7AAABV4wOC1qEhzsEAzBj9DdgpBni1A9WE0/3pIIq2j//kUubalQ+SMvOf+n3ECCiSnRZZOvwQMgIs+dNESQJqFydbJn0qNGAolsAbuTzXbkQxHvBoSW6aQ9210DKtsdBJH32qH/oqX+mbaI6Wdd9Q9QbMaLG0ibL5Pg96k4GpQohS3lsUM/xF8irA== 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=1aatmYLlcC0l5UoTFBkid383BeZCZ0O/sLOtEY0PgG0=; b=wUpkqL+5cm56esBrSvF8uYHXUUPslddmxAY6AhKn9gzk6qSllDvPMoyik4+2VDHrfyg+MgBuYsUFaJG13FrJV5q6NLaG5Iv1NwYfUzSiMc/ur3Y/eyJg0lcFijGnxYkIID4mFwzNGA0tkNR84L0DHD+N1wP9rQo1CCR5I5g0+nrmPoMuyETX5JAXSRSE6TRPk8RsDieKeEn+/EFMesBeUC+srk7o1zxjKUCabLZ4Lf4BRYTmyCI3uk9URFWg/7oJPifWY+1xUEFr7uHHUZcpV8RIkDahdWFvfYqt6WIuO/353szVPtTsPL+WDoyPYGrigdUTFFL/nm/pel1UI/YSSA== 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=1aatmYLlcC0l5UoTFBkid383BeZCZ0O/sLOtEY0PgG0=; b=iEfOseTHfIhOqBUx4+YJFdFw9PbsxCRkmq6HeTwyBZMiwC3ly2efiYWA+cFVyPFJCJSfpOKw4UMVYxiGi1VRx37vK4yhQh+kl9Y67lnfbOWPcGpErd+pHUvHhhENeyHq9nETMXiD5ffARv3UkZFWXqxGEA+B4R0hmhCsg0ELKXY= Received: from SA9PR11CA0007.namprd11.prod.outlook.com (2603:10b6:806:6e::12) by DS0PR10MB8198.namprd10.prod.outlook.com (2603:10b6:8:1f4::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.139.11; Thu, 18 Jun 2026 07:38:01 +0000 Received: from SA2PEPF00003AE9.namprd02.prod.outlook.com (2603:10b6:806:6e:cafe::9b) by SA9PR11CA0007.outlook.office365.com (2603:10b6:806:6e::12) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.113.18 via Frontend Transport; Thu, 18 Jun 2026 07:38:01 +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 SA2PEPF00003AE9.mail.protection.outlook.com (10.167.248.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.139.8 via Frontend Transport; Thu, 18 Jun 2026 07:37:59 +0000 Received: from DFLE215.ent.ti.com (10.64.6.73) 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.37; Thu, 18 Jun 2026 02:37:50 -0500 Received: from DFLE215.ent.ti.com (10.64.6.73) by DFLE215.ent.ti.com (10.64.6.73) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Thu, 18 Jun 2026 02:37:50 -0500 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) by DFLE215.ent.ti.com (10.64.6.73) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Thu, 18 Jun 2026 02:37:50 -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 65I7bYvd3521710; Thu, 18 Jun 2026 02:37:45 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , Subject: [PATCH v4 02/16] spi: dt-bindings: add spi-phy-pattern-partition property Date: Thu, 18 Jun 2026 13:07:11 +0530 Message-ID: <20260618073725.84733-3-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260618073725.84733-1-s-k6@ti.com> References: <20260618073725.84733-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: SA2PEPF00003AE9:EE_|DS0PR10MB8198:EE_ X-MS-Office365-Filtering-Correlation-Id: 47d93efe-b8da-42cc-588a-08decd0c85b8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|23010399003|82310400026|36860700016|1800799024|921020|18002099003|22082099003|3023799007|56012099006; X-Microsoft-Antispam-Message-Info: uKbicOQLk6BaW+urOR3ApDKuaANAh/5aohf0Ydz+w5bHE+KvChYq4DOwg6mGjFUW5pvYvWzgmZ8Kv/qVj/pF5WPyIBEvw5SM7WVjF8YlCbYo6FGcn6C8xr/krINo2X0HbzhLMEbet15qFeHpHrMTCc0wrR6zNJM9H0BI3Y9/qNRPWJ8pXo0aSXid4iJQAJNuBBsKrQ9r/MzsXPF+tTtYqVPc4xAqVyz7jRwtmWKHzzEA5I2ua5CZtcAWcbP8A/N3MmoIOtIn0tAjuh2VGdGdacjuEB3Dys4lizJZH6G2AZGCbDGiLnUCgArvtwY9HxQrKyDb3urTfIMMyGxsfEV2n/U2Ku/wJd8B/8CVioyl9bSs2np/3YFEE7FbcpVkBLJxSTXJCz+NLUyXLGmRm4Z2haJlU8XpKt1fGcK87BAbysGQogrwJNWOkXPHrxWrloqwPTnzY48H3J+DdGIG9xpSUkmRRRVgmymqUyICLOWfy9nD/+qHIvmSazXf3IcSUla1WwELRLNsHPCl6QO0F4R1kcVexOlGvbuwgEj8i74njQSHCFZQ2zCRh/gVHc1znH2MEEG8ceuVqOsfWMO/QJa2pDRYzLffbKZ1LC7MaAhfFNltJPy89qkAilp3lDCXsvSDLIV397fS2Cz8QHqtvVYKoAjMt7Q5qpu0b++r9gCW1EYYrnL+Jf8mFEk0joQsjfngEpwsDzPvLpYJLbr8t647aRf3otPAl7V1OfsRV3rQw/d1EPnBZEIbUXVFrlnia5ygW5XBCyKPTeX1gHJc3MWDCw== 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)(376014)(7416014)(23010399003)(82310400026)(36860700016)(1800799024)(921020)(18002099003)(22082099003)(3023799007)(56012099006);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: rePHVCB3y/ymPu7CdrX82u5KeHGsPmNBTEzd+qOkjfwEc/TT5lgquzkJs9rs5Dt7MRiQvr/T6ErCRz1YrNlMo84+Dniz+MDq5eDBScGXR7/8sLmlSXRvnpio03Uk2+kAA4NHfU6/f1r82eJEa7IyF6hfBOti+Cqy8ezGavPA8m85IgAaT7qWq9x48DG+hgnE+PAdGvIhmzwa0c4y8dd8YalsOI/vpduhCPxuH58QGUkE9nt0CPEO8LUIkEUvE9xoH5Q70N/a5Uwx9K8lzUuz4aAjXDi40oBycE3RkxvZuP/irotg2aBR47BZ60pd9yfUid8ZF3/fyQBoLq2amXHu0YWgUegzTumwgAlLsPnPmV6Ud0USvgXiI4SG6pA18YhzehJrsbgTz6VsxBVsK6nQXo4QHB7DGKX7jjZo396cS8M+rUMjDA9ucAUgesqwKXCy X-Exchange-RoutingPolicyChecked: Mn/auHgDgtiEKGOE3T1wksCCTyAEUy7BQJWCG/4mQa3BHqaS1JjpprXeU0+KaZro8olEtwfvOOB3L9qvFslWvEKtwMY9Cf22smacl9D/V8J4VGjSQ7Er3+6Zbv5Nb0LEqeYVKdTIlWDxLJirCWCjEM910YV8J8nw5tPuxR/m15Ttqs74z9C1JU35OnYr+LPhBrc8DeFU0XpWkkGQ85gy4JwsdNU5eNCH14NB+YmUefUZtZbibgW+SzmB2P1p6bG2SRlblt8jHX+fwiQnp1LRGASyQ56XmIC+36rww9CIH536V7z9owmnFfcBGpRSJIxxwIFGxAu0OpW45ahRPqKluA== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jun 2026 07:37:59.9199 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 47d93efe-b8da-42cc-588a-08decd0c85b8 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: SA2PEPF00003AE9.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB8198 X-Proofpoint-GUID: 2TARor_gIDzge74-omxG5JjqkVUDydvQ X-Proofpoint-Spam-Info: AW1haW4tMjYwNjE4MDA2NyBTYWx0ZWRfXz8QUedQddT/r P/H9f9qsQhkLDecp8vnece4Ddb4SK6CQJKpNz+Gwxb8o1FGNZc3P+TpxZRHI5isXz4lsrZgldcw Dp4QWdq56Tf5bctp4PlHVNhax+5iZRI= X-Authority-Analysis: v=2.4 cv=QMxYgALL c=1 sm=1 tr=0 ts=6a33a05e cx=c_pps a=+3f3g5PcVU0WeXiSVbezXg==:117 a=tJyPKKxUohctrY4NYmUjkA==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=FelO9ux0wxsA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=jwouBfj2j3NM8CExmVVE:22 a=sozttTNsAAAA:8 a=S03zC1y9aomtN7BeUG8A:9 X-Proofpoint-ORIG-GUID: 2TARor_gIDzge74-omxG5JjqkVUDydvQ X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNjE4MDA2NyBTYWx0ZWRfX5zf05cCnv0DU CXUTHfurte3YeXDUhgfQDPUJveDUpWkmScK/WH7HIBz+2rOvSgO+8p2aTlATQ/cfM15bZMIQ68D SSuMo3Sn++WRYaCxV0a9vrdOziNE1rqP23u6nlKnjrCCZWBBJaFVNKC6LcwgEUqdrxwwrt7yruw 4zex+oipIdahRVtLYGAXHAl2FgsffwhoVhYSmuUoVtORa7t8GSQ15EuHwzT7rPQMBOyXluyE0gm XC/yFMaDl9YZCADNcuSIKFd2lT/A1o92a4qmQtsrUmIlReB7653FKwXKL54d0wOo0KXSDifb2Ss c7bVKNyRHVZAKR2WcGWGL4D81p4KMeDm+DcKuXIY6GUaFv/9KRnN2lWpNGitTAO/Jql4VUZdnoC jVvQqMPj82t8G6L6P/Kao2s9O8gaqU2TvO7DxA/sco4atdfR9n23z9+A28ke5jVs5va94AQi3rQ SPSXN8mF+nEkcImPARA== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.125,FMLib:17.12.100.49 definitions=2026-06-17_02,2026-06-17_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 priorityscore=1501 malwarescore=0 phishscore=0 spamscore=0 clxscore=1015 adultscore=0 impostorscore=0 bulkscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2606180067 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 PHY tuning pattern. Used to locate the pattern data during PHY tuning when the device cannot load the pattern dynamically. "Read 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. Signed-off-by: Santhosh Kumar K --- .../bindings/spi/cdns,qspi-nor.yaml | 19 +++++++++++++++++++ .../bindings/spi/spi-peripheral-props.yaml | 7 +++++++ 2 files changed, 26 insertions(+) diff --git a/Documentation/devicetree/bindings/spi/cdns,qspi-nor.yaml b/Doc= umentation/devicetree/bindings/spi/cdns,qspi-nor.yaml index 891f578b5ac4..c6f1b1d1251d 100644 --- a/Documentation/devicetree/bindings/spi/cdns,qspi-nor.yaml +++ b/Documentation/devicetree/bindings/spi/cdns,qspi-nor.yaml @@ -204,10 +204,29 @@ examples: flash@0 { compatible =3D "jedec,spi-nor"; reg =3D <0x0>; + #address-cells =3D <1>; + #size-cells =3D <1>; cdns,read-delay =3D <4>; cdns,tshsl-ns =3D <60>; 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 ece86f65930f..38708f8197f9 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 PHY tuning + 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 Sun Jun 21 23:24: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 3CEC23CF211; Thu, 18 Jun 2026 07:38:13 +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=1781768294; cv=fail; b=Aa2uzsWHsG781WG32rLQ+stW2Rj4BR8L5CYMydiAlaD1gL6RK3+dm3fDBF0la0xWyOPhkbf4csx6OId436B2KMGDXel19wA7u8kpK6i2OH0KORRg1SKbo4UPvw+tmJmQqh7Gwd3LprxYp2bmM7JNb/LXzyr9mZgSLNJuP93dgzg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781768294; c=relaxed/simple; bh=LMtmo/WUC/A+I0HJKJTAB8R9eaHOE9iaISmxs8HTIpY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=msb0zHH1hCQzwhkid3oIsACuYvDcMwcq8AjNpI6lERaUeZ3Ld7B+8oYtaMGrCE6eR+FJ2VS2I00Z0eM8VndLodXP7QMPO0JVuIsfrN6tKfLIJBWzv/6Q704FoXmSDR0DZc+hi41hr0ry6bAZVdPpsRnjgcLSSCRdOnUo0n2jYbo= 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=aWQ+eU8z; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=VfcQTaGX; 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="aWQ+eU8z"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="VfcQTaGX" 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 65I7UQ3k1333596; Thu, 18 Jun 2026 02:38:03 -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=Y15+UpW9VPN/huHKTZPkcM1Y2nWfTKcuRilnh9JM6 0g=; b=aWQ+eU8zUA6NrxzoRIq2db5yR55v1iRRpCcDzjIBMmrKWTA/kVt59utza BtASNPA35TxEgEVzfT9uUdY6cWncgv1hcNFLyCb+WqSmIOJ962wvb8NDa8LzRXo0 g25sJJmDsy0XZp6xdRf8IMxvIeaoe0SMBLwk6Gn3p72kyQ4x9LsE8Oo5fF0icxqs 5d4ribbvwzklBJjRFXihEsBf8Syf7TEf89wJQloKgiHMMJfly/Yca82eQqU1Amwx xlfMG9nwZCA4hH7SbAdnTFnPiRDkTZLJtAxNriItGQRRZ6kiZe8KSUxFinQOFa60 XyxQNkXX+wsYpwDCZTz0EKq5tOHhQ== Received: from byapr05cu005.outbound.protection.outlook.com (mail-westusazon11010059.outbound.protection.outlook.com [52.101.85.59]) by m0384305.ppops.net (PPS) with ESMTPS id 4eutvept2h-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 18 Jun 2026 02:38:03 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=T40PIVITm+iBxZUrLCXOHIhFMLqhieGDw+o5mJOi/yKwUGIn1ZlF4gJCKdZl0IoHozzlhd22AjFjc3LfDUC6S+ir1ti1QGUopgGyhDBSnFDlg850eb3IePvGpnF5mzjN8PMXDnmtrzUJ+V0EjEy3s3vR31uMADrxS16LsfHtG4ROBaK1Hnukqmvrpokg4Ykwjmv4TnhioVEpxwKr0m7pAilS0jJT/kWQ8hl9iyiVctBaPIgKLKI/vh+EkWh5PlZgB/mIukSrizulQQNVQtSVJKlZYMvCI0BhFQLMoofdN/681SZ1WrYeTID5M+CuhnTLIs6uMR0gAutbWp9u0vShqQ== 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=Y15+UpW9VPN/huHKTZPkcM1Y2nWfTKcuRilnh9JM60g=; b=RTY9UFvpo4zttDgVAONg7X96JO+X8kb2A8Jv5sZYVP+cDOfjIhq+rDu8hrC/haDmVXE/7tdu2QdfQ91waOEV/MQtVy+e9ZSVJ/CDjrstkU2WrTkzFSeQhh3mxDY5QI+bIZ/075G2orY+NPPMoBTVMcxW2+Hu8uux7WqiO7EAovEdEt6t5BikVw86X63hwivfHjNEAQZWXUy2JakW8JstWstRMiCeES3Li+L4H4tDMrRKbJ3ieJd9pB3GJsBMivDCdLVSbPpvWnhWRhz+mjkfOI3RkQKKOv3KcR6yCo/7ZyozMc14tdZl2st7G/30b+Mkw30T4tlO63zsExkbFqBmgw== 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=Y15+UpW9VPN/huHKTZPkcM1Y2nWfTKcuRilnh9JM60g=; b=VfcQTaGXTbXLK8EeKfZmOY0Yn7Znya2JJMckb+NhbyGxH3tgKrMQnYoxbBbPTCQ8m7V8idjlni62Fa2DHeF9KM1daX/BV0EILoq+bQoR0job1gXTfj21PV50riwLRGEgu2+c8I+gsw4oElHSpFOmNZ64X7qymYvzx333mwwofbs= Received: from DM6PR21CA0004.namprd21.prod.outlook.com (2603:10b6:5:174::14) by IA1PR10MB6760.namprd10.prod.outlook.com (2603:10b6:208:42c::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.139.11; Thu, 18 Jun 2026 07:37:59 +0000 Received: from DS1PEPF0001709D.namprd05.prod.outlook.com (2603:10b6:5:174:cafe::a9) by DM6PR21CA0004.outlook.office365.com (2603:10b6:5:174::14) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.159.2 via Frontend Transport; Thu, 18 Jun 2026 07:37:59 +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 DS1PEPF0001709D.mail.protection.outlook.com (10.167.18.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.139.8 via Frontend Transport; Thu, 18 Jun 2026 07:37:59 +0000 Received: from DLEE204.ent.ti.com (157.170.170.84) 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.37; Thu, 18 Jun 2026 02:37:55 -0500 Received: from DLEE203.ent.ti.com (157.170.170.78) by DLEE204.ent.ti.com (157.170.170.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Thu, 18 Jun 2026 02:37:55 -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; Thu, 18 Jun 2026 02:37:55 -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 65I7bYve3521710; Thu, 18 Jun 2026 02:37:50 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , Subject: [PATCH v4 03/16] spi: parse spi-max-post-config-frequency into post_config_max_speed_hz Date: Thu, 18 Jun 2026 13:07:12 +0530 Message-ID: <20260618073725.84733-4-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260618073725.84733-1-s-k6@ti.com> References: <20260618073725.84733-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: DS1PEPF0001709D:EE_|IA1PR10MB6760:EE_ X-MS-Office365-Filtering-Correlation-Id: c27673c0-e7ce-4316-5b9a-08decd0c8578 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|23010399003|1800799024|82310400026|376014|7416014|36860700016|921020|6133799003|3023799007|18002099003|22082099003|56012099006; X-Microsoft-Antispam-Message-Info: VUtLE1Kc2dvvUcPbc56Smpe3yD40yiT7G486IEihSsDt8Uapda/01C9S8EZIMRIQMGRdZfrc7fyc3zxBxbf0amT31/EnYtwnpitVQgluRMbscq8Arjv5LKpTPgkhAwOdVXvy+g9Eu5aCb8PuC3kTK8Iu5nJdEMW89+3Y2LjVcNBkKLZdaQyYrrf9l32jWkgX0FoMpca7/JjE0I8oop5hgHdBiJF9bS+HL36HQ7JHX9SkKZSulQpPZAMhMnJ+vhXmW6TnGkwjveR33mG2BZL15K7x/X7DpY4bp5A9d9+Kroz4Iiv/730kk5ocZUmjjtwZHMBsyBoyvh/X1bCrWEXknHqR1MvxQWxa0g0g2UlIo2Nd/jOU2tX9aLTaDcRmzQCXn+FESfSWyQh14ACGyFbzoNgityHDUuC7bzrIzv7Y93CFuPq+Yru3voZKQSwVtQ0DGAMTlRAdscWOeFvSByAT8GOQ9rUwD3XYM+njutylfRDt6vmd5JHg74uSjy3SGirmel5gHAGjyCp62Ze2wbeZ3x3BB2fcb46drLc+PeMLAVnX6Yu6Eo924docTpts2uVVytHUbqNdCYCRPK6Q8EJOnqPuj3cirRrc9s63aO9LyLRaL9fKIqUdgHN1yDPJX0LWNWahbml1qjcnSh6BzIkzidVlXFQUm8DkXDNFfvd38gHtWXnSjwNZQ1gX+JgpEm+Dtw0nHT/1D05+UW5TwdfsuYw9pJ06gwQECIbW849VRFY0iFY2lsFqJ53I+j4NgRsBW2aBKG69xvAXI1qG4lko9g== 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)(1800799024)(82310400026)(376014)(7416014)(36860700016)(921020)(6133799003)(3023799007)(18002099003)(22082099003)(56012099006);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ENQWRjYqa+68PIlmyRVwrwyN62227SviaSO6L4DwysdtKXVuW6J4KP9P2rB2KxesdikgxwHt3PREt2bZEQRBcVWi2Q7IwPcyG9d+FVQu9orcES9suKz7pdMpeC62gPF6AF8qErWAotz1REcNZRuKsvUerQgyPvBvPs10OLQxJGgFUCySSCYX/y16+VlEqsOh7aA8G4ofr0VZ5YvVfb2wXUXNMo7SEvwhvvZ9zHwpcNHhZH4bL6867Mf2P7nDZUWy3G5Fg/ev2d+Kt+heXPm4jCGF9oxLyC8vt+kxqXkBxcdESIKXnPQi2haYV7v69RyJCe8eTbEirYd6OU7hBbemS77Os1+TIzlzDq15njHHwHNKTRK82bA5izkKZSeF6jTuUhHPz1O2XoCUf9rCOakiyBl8v40C6W0eG/dC3fgs4IZwdcmGf+B5iv+O2DT4jq6e X-Exchange-RoutingPolicyChecked: eAel2wQ6gSCzAJW+VEBJ31X2aH8UfxjF31DflndcDxtSTN4FeVOZ1RUucsu3J3OHF9/qrHvLYbu+jJqqe0MQtfyWTZcmQSmQp1bKhlriRqNXuOmdzhE3R8dWMEMyTSsYHcrgAhJvY5AUkkBQoLaSKHNagbVFAib7E2Gj1i0pnAdPftpQMPQmO91VKGB+djftzFfrM39VT9AkzHuo546akeyT8YFxMn9clsOV1vcD4RpBIXN4ZqF+x4J4807xfEbzD0FtKQI6DF0qkvH4fIfrOe7WPDPB2W5IrzXYt3W+2t24+DiNN9QMSEsVqGrD55+nu0crQwtdU3ycHWcYADQpQA== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jun 2026 07:37:59.4773 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c27673c0-e7ce-4316-5b9a-08decd0c8578 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: DS1PEPF0001709D.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR10MB6760 X-Authority-Analysis: v=2.4 cv=PtOjqQM3 c=1 sm=1 tr=0 ts=6a33a05b cx=c_pps a=333l4QiDdYhx7c8CB7C9lg==:117 a=f+v6EHfkeJbVwR46tk4DMg==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=FelO9ux0wxsA:10 a=s63m1ICgrNkA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=taLDd7a_hP9WKsMzeGRc:22 a=sozttTNsAAAA:8 a=2Gi1gDZmOG9PIfG5304A:9 a=O8hF6Hzn-FEA:10 X-Proofpoint-GUID: I7zLsRuj4AJv9-xeedLwf_2y4Pt_3TdG X-Proofpoint-ORIG-GUID: I7zLsRuj4AJv9-xeedLwf_2y4Pt_3TdG X-Proofpoint-Spam-Info: AW1haW4tMjYwNjE4MDA2OCBTYWx0ZWRfX1eFNfg2ckMHx vTjJlR02YGQAr7SWV6U9Fc+p616juwwo8GeWVMx0JknUMArjWNACB9Sv5z2/PkJIiRVNXS/Vfbf vF3/si1S7PCeR0pSzpWlNnecR/ikTfA= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNjE4MDA2OCBTYWx0ZWRfXw1pN/dHV0HhT 8px5eH37oi10EB4l7rDXXuoBF0Sy4eLK5cAphu8gpbo6bw5kYfiXKMuF3lMdDI9QVm82qJLRW8I rmED8FcoUGKqLhNji0m3nnZHvdOenwwHMBVsePuiXql63msYhL8dYVJQ4GuTumqV+FzFD090c5o umVGs1iUHYK+f3nR+CRpYyuXRFeGfAbh2XxHYd673CLaVOPfLfc3rW9TWrVL0W7Iij6lzE1OZ5g qPtrIp/bu0JQLybZ4+FgcQjwjkGmesUaUug/rJ4c8zBZEm9I8rBO/9yi3ujPAO195OpSOuqhysb /L5JVyNZtnvBFyaQGzX8unsCarJnzGaottLBkBAACdN1JxZDRmG8o6mul4o6fywkVxEGpBZyPhJ LNsKt7TnZxL5C2h+oM7mW3oFOprdv4kuOwdrFnYAwFwC1LjBAp4vSHoQ7IEgfnqm0MVHUDPXpGs P91c+tf4HT4+Ipkfd/A== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.125,FMLib:17.12.100.49 definitions=2026-06-17_02,2026-06-17_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 impostorscore=0 priorityscore=1501 bulkscore=0 clxscore=1011 adultscore=0 phishscore=0 lowpriorityscore=0 suspectscore=0 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2606180068 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 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. 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 76e3563c523f..36951ab47a2f 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -2599,6 +2599,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", &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 f6ed93eff00b..2d90ec91450a 100644 --- a/include/linux/spi/spi.h +++ b/include/linux/spi/spi.h @@ -139,6 +139,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). @@ -191,6 +193,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 Sun Jun 21 23:24: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 90B6635E1B3; Thu, 18 Jun 2026 07:38: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=1781768303; cv=fail; b=natH6Bhgv5lU7nB066Ck9j+Q8e1nO136SJcE1CHyw1HLWwrZNow0/WwxpqHWtO3xpEP/e98aOIoW38M25pFivfGsYDrXeAniJhsACLKx/2U9rUOrPN+o9gDT64Gukw/BAfTVhnPJz+50LbGRbKpI3lHFVdlpe0AvdWcQ/vrgh/E= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781768303; c=relaxed/simple; bh=dQT9BtiEHU2V2MuuGHjTzhml8WFPBRfdwURXDRd+Yzc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=t81xuno0gfhJrjAz2rN7dFAMT4VezA8cXztEqcZGGq1z94YUGV5YUFqMSikOzt8sBSZdVLt8AeWtWcZfLc15GrD1RVN5R4Y0CI1xHfAGb4vmzW3tfQauqtnVKVdA5MRDzU2MS5gkx4hS/caKq2OgMJ+l+pPk6ZxjX7Y0U29kDdQ= 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=eX+FgEEI; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=Jq52090N; 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="eX+FgEEI"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="Jq52090N" 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 65I7UQ3o1333596; Thu, 18 Jun 2026 02:38:13 -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=JVeRd9/aAVyEPJfyQgcj4HI1WC3n8r9uyRQgl8pOb co=; b=eX+FgEEI4XY5rIfCYPLB6UYrY4nbUEqgfLMhVPgok6U2BAj4LQYeTk5OL cQ43ATY0MJ925ztfqWVuRROUOpJviA1StxRkY0o1WtmL0YVCAwLgQMISvkOqq8Yw 6ipjVMW6IWppq9SFwaKcC56KIP3MAWMovnKh2QR2VLWGo4unTtf4RAScMuHom5tq 4/9Yoo5LN6sr4qnMDbrHYVWd58b95NtF0FT4UI7jrrmiY1lGsG337RlQwg41TTXj rBi7udLmS+5bQJYX6tn/rPD7TAQfmk38HAYaf+kTm+9+SfPPKYH77FnkQBQhgDW1 WIFjom5psLMx8L89ULw8ifAbFhD1g== Received: from sn4pr0501cu005.outbound.protection.outlook.com (mail-southcentralusazon11011062.outbound.protection.outlook.com [40.93.194.62]) by m0384305.ppops.net (PPS) with ESMTPS id 4eutvept3b-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 18 Jun 2026 02:38:12 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=bOOHMcta47eRGBQ+NJzthkRJ89VBU/eYOWKOX/OqFDwpYRQ6XNz1YxFXWPoBLqF+BxaW5PiYNwKMutBDTZNv1GghVYycKnb+IJ5cbuVvohjhyCxAAoXOLAMKF4e0s7CowO+cRL+N0pAFrjjFjS0sKAYwf2ygUYeCpU1NqkSsjHvr4oPfUd5P2fQarSoHIySCdr4cuivkDKclt/A86ABkufY9pA+nxDYT4gL9FGFsQ7hCQxf8DbxAmSKOD4T/X5L6rgAlInl///vNL7zX2/pMdGUtofsxpExC/MkjAcM5rVXg/y4h/QSDElFLdezQECunJT0kIaYaDAVDozfUbmCh+w== 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=JVeRd9/aAVyEPJfyQgcj4HI1WC3n8r9uyRQgl8pObco=; b=KFOTWANL9TwJoHXQHNyfHmzu+RoKOzCXVsHokT+ZKyQoD02GC7o9/aK/i8iTbgjjGuKXJN1k9cbFxYNjmXLrO5U7YjL5FaYig3GNU1r9WdX9YCz5rMsDO7DfSkALaPDcgtWwGTdE/MHzT/Q+vmOFDjxBEQEkAcJO0gWjBcwAuXGIkcVUfifafyF2ySW30ztZYLomih5yMKL8pL+HWjp3NqD69Qcl9xp5BV7hyPgruFaWq2gvPMsFv83FUKqxMSq43yfVypw6Rd0JsU/YkmklS8UwF3H1/CXPy6o32FJr8VFRIkcfYMjCrtQJEYs0Jok2SVJUW+xgSkmF/pYpSooP1w== 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=JVeRd9/aAVyEPJfyQgcj4HI1WC3n8r9uyRQgl8pObco=; b=Jq52090N0QyZ/lUy1Brq0a4rbQwv4KP0opdi3EPE7E7ziAegt99TngXSWHY0b8E8AoSzkoEHlDmj7j0CJtJBq/XLEe3h8/UjzQw1ebN6yO3+rQ0I0nZVW03J0RmoBA8hyHiLUhIp8Qx2Q1wGgl6uwVwUuBbqZ/sO24o5EGUCXoI= Received: from SA9PR11CA0006.namprd11.prod.outlook.com (2603:10b6:806:6e::11) by MW5PR10MB5850.namprd10.prod.outlook.com (2603:10b6:303:190::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.139.11; Thu, 18 Jun 2026 07:38:07 +0000 Received: from SA2PEPF00003AE9.namprd02.prod.outlook.com (2603:10b6:806:6e:cafe::5f) by SA9PR11CA0006.outlook.office365.com (2603:10b6:806:6e::11) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.113.18 via Frontend Transport; Thu, 18 Jun 2026 07:38:07 +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 SA2PEPF00003AE9.mail.protection.outlook.com (10.167.248.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.139.8 via Frontend Transport; Thu, 18 Jun 2026 07:38:05 +0000 Received: from DFLE213.ent.ti.com (10.64.6.71) 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.37; Thu, 18 Jun 2026 02:38:01 -0500 Received: from DFLE205.ent.ti.com (10.64.6.63) 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; Thu, 18 Jun 2026 02:38:00 -0500 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) by DFLE205.ent.ti.com (10.64.6.63) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Thu, 18 Jun 2026 02:38:00 -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 65I7bYvf3521710; Thu, 18 Jun 2026 02:37:56 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , Subject: [PATCH v4 04/16] spi: spi-mem: teach spi_mem_adjust_op_freq() about post-config ops Date: Thu, 18 Jun 2026 13:07:13 +0530 Message-ID: <20260618073725.84733-5-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260618073725.84733-1-s-k6@ti.com> References: <20260618073725.84733-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: SA2PEPF00003AE9:EE_|MW5PR10MB5850:EE_ X-MS-Office365-Filtering-Correlation-Id: 91d39544-107e-4c87-05c8-08decd0c894e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|23010399003|7416014|82310400026|36860700016|376014|921020|18002099003|22082099003|56012099006|6133799003; X-Microsoft-Antispam-Message-Info: znUeQrWwotSH8ABXzVCc+6zS+Bh/cgtSqJz4yB+KIHXEn0+N9BjhHgUvsdW7x4uk9z7N0BRHi5lfJtAJSiKBG5t4+eqgDcfHiT0fL8lGCxvCrm54nvhUz6IX5yTVGlzBKtpXQFRXnnYQNa3fTzRTLC+Hla3+q6IqcwLIyfV56r9/zbV1BkzuYvgSkD5Fnl7atEW77/1PpmWkRamz0nZay4WPWAysKmWKXSqbhoEThMahtZ7GhTSChDVLWqiOGTxgb2rwdjQU1lstjtXKuqENlYWZ+S3Sh75NVCEARzp+qd/u+s0aBB+G2FZI7Z4MRXMBOS35XGLzK4NzVrjm0bAKIpGhGpjC02W91tlEQmlL/bZcte59DD0kFpSBlLVyDBpDrPTnn1ztIOTBcPx+k1wyeXTjUEyIhUYBuVSPykp6vdVu7/lkUqtPHHBl9hyfEUMwl5RCbhXg0x3BZS2Eyu4mu0mgQFYocca0WXoIML4dQDfrcaob2UcdVGn5fqNUeKhAdN+uyvCInDsT7uINvWXs1fnte5TZrIF4tG6E8xzcJIIW+VH44AB+Zop7BHHT18EOaW2uMgp5KJ5IIPuqiMUXPNEsRPsimO/od/6s8JW1OzPZd2Zc2FiNQC1/y2rgnuQGtOVwIcl4CnGRDaiJdcUG25UB+SKd9R7JQxP9bEDX36rxdZJleNk/gm9OfZnK/ZRWOV4Bgm9D5kO9dcP9zDPq7w05RXmgM0bLLkDswdj6LFVwThZKMVoBu5V9/pwPzBs6J2co1nulZBfQkWOesZqiZg== 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)(1800799024)(23010399003)(7416014)(82310400026)(36860700016)(376014)(921020)(18002099003)(22082099003)(56012099006)(6133799003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: G3jKlSlmn/S3SDMMnp04ZnjvxC6WN0u2YW2UVTAHaDL27523ge5TBxgwlA2gtmWEpAZlGWGzWeXon0n98dUhJbXFLuNhe5JuaxhkZs41G02mRFsybnY9XPWHTvNaggGVEyNktkZfzDmCE6d1+DoqBtpU5YMJSlRMy+yAXzA5/hw8X5uDn7ik0/uKEpi8N1BUgOnupnolA37Sv5rwCsG6cU40GGEwlnV2EimdTJZKSEdrOYxHD4frcqLN61sNQJd6qpTlP0ekO94tytVMc+yZvsdmI8ilEnTW26p2J+URZ4NbiqTszRgnFDd614zFV14rRdjJFFZoxremg463Jt4XZQ6w8KdgX6QR8Eilut13/ITJf1Nyhhx+jyDmTSKLSy9pab7a9ZwZIiviPXNCi9/CCib5JaO/nZBM5xb6ye2euWVs8Svp5DpUwm7dExeK+PpH X-Exchange-RoutingPolicyChecked: UCmUHmCdHsCUQP6aN1zFlR3PoR02p7iHMuJSZX3JmwXQX+xsVb9i0VgUDitoJLe0roHDlE3QnNP04/EYohRuxNo9ZxAq5x1JLYgR6TWUHLFEesnyK3uqnzE98py/RlLqq0NRjGEmcSlFKIjSZTOx3Na1H5a0jqHovj/K5VFMGUOsOB6vj8glL+4LsNLyexpbAZrNEZNqb+tqmf0oin0JqNXgeFfj6hbCUQo9vcVPRi+4HtiYz6BGg+7Q8VaWxlM9m7dxNuxfD2is+7ly3sX/OhjAnSyStr80cLrrBTow6CW+VbyC1t93I/0h9QGH4PyEz2LMgZvxAIi4k1QokQH+Wg== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jun 2026 07:38:05.9274 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 91d39544-107e-4c87-05c8-08decd0c894e 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: SA2PEPF00003AE9.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW5PR10MB5850 X-Authority-Analysis: v=2.4 cv=PtOjqQM3 c=1 sm=1 tr=0 ts=6a33a064 cx=c_pps a=MAgfROEylrrND5Jw8NuT2A==:117 a=tJyPKKxUohctrY4NYmUjkA==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=FelO9ux0wxsA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=taLDd7a_hP9WKsMzeGRc:22 a=sozttTNsAAAA:8 a=SJHljg8rPhlK4JAv1-QA:9 X-Proofpoint-GUID: v91EJHzfeIimwGRDsYWQ0R58HCDt3486 X-Proofpoint-ORIG-GUID: v91EJHzfeIimwGRDsYWQ0R58HCDt3486 X-Proofpoint-Spam-Info: AW1haW4tMjYwNjE4MDA2OCBTYWx0ZWRfX3iQqKMmikMbM ZnwD3oOBfFh/plKfIiT2XGR4SHRSr0vV60YKMFxThp68EmawEs4alVXqzbIMAPhHRaz0p2kjy+r dXEgKRPpHAAzlskIFOLTBX8FPxD56Cs= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNjE4MDA2OCBTYWx0ZWRfX0RQamF78fWh2 vPGx91Y9HIRYXv24gAxEp4KbTiuiLAM7ONOgeVGnBNZDhv4sDh6roskXCyaYQrATsl8VuA7mGkJ omOfoFyjKoI9k/gqm0weUM/u5UQv8PWIoWdVAn4gy8pnfiWht5U1nJx5B1852wgMPpiXZJkKGm+ bb6gedab7mc94QmfL4sVK4sHojrvxSkNvDR50QfrGlDi5UUadYiw7PAvZeeEu05MpI1fd43Fj6n GRGuEfuG56jl6RVVC9R3d9u7zsuOFyWIRz6F0xtVYKMtGreJVLfhduuZ1wpj46XmZBi7oPcn1vI uhBph/pNlAlMjSzN0rYoWm2xmmoeQNmpCXDwYjmPXGiaSah2fy3iUTto/j1EyEgAU+Y/eQVw9AM cgMbKryul4x2ZHSuUgcqpAGlYG4X2gTEUCvpY3D3dS9h9vP/vLi+G8LHTS4WLqxCJepgpUDBgR8 7Zu9721oe2cAB95Kvog== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.125,FMLib:17.12.100.49 definitions=2026-06-17_02,2026-06-17_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 impostorscore=0 priorityscore=1501 bulkscore=0 clxscore=1015 adultscore=0 phishscore=0 lowpriorityscore=0 suspectscore=0 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2606180068 Content-Type: text/plain; charset="utf-8" When a device exposes both a conservative base speed (spi-max-frequency) and a maximum post-configuration speed (spi-max-post-config-frequency), operations validated after controller configuration must run at the higher rate while all others are capped at the base rate. Extend spi_mem_adjust_op_freq() with a bypass: if 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 integrates the policy into the single existing frequency-adjustment point so exec_op(), supports_op(), and calc_op_duration() all behave consistently. Signed-off-by: Santhosh Kumar K --- drivers/spi/spi-mem.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/spi/spi-mem.c b/drivers/spi/spi-mem.c index a88b9f038356..e20eca1b8245 100644 --- a/drivers/spi/spi-mem.c +++ b/drivers/spi/spi-mem.c @@ -591,9 +591,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 Sun Jun 21 23:24: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 F047D1A9FBC; Thu, 18 Jun 2026 07:38:44 +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=1781768326; cv=fail; b=k9J1osPUwQ0habjW+1HG8I5oH5FJWWmCnRx+lJDb8J0NrxaCDu5HTQCRws6nerC6jzgsA+bS+LWp1FOjtNtDxx1cbOGqnX6dWVQ4hXPnBcm8aXNBRmSg5OI+4mG6NmqMfqZywytpeSQ0ByZDlsvRalfmfWy0ZVgMxZspToE9zMk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781768326; c=relaxed/simple; bh=SPXUbum80aBQXY+3i3Pecu7ySp4hADkjyHw+4bh7V78=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=eVSkphRpA3iPaee81p4dkvyLgTMXGa25tDn29kA811ijiFtOwMg/SWml4QY6F370u2VTWubflSet2noBCejzfiCizWfvkKbkloXafifdciVZE7Q08ksMECDeqRVkE0kUqBFohendsFiYwfmzyhau/flp7TO7pFMzpS75uE/mLEI= 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=I93UvRcU; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=lvTWDSn6; 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="I93UvRcU"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="lvTWDSn6" 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 65I7AhTJ2383685; Thu, 18 Jun 2026 02:38:35 -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=0ivWwogJkYOorimiUnRp2KrXCkZKHDm/wzRVhkB6p 3s=; b=I93UvRcUk4OaSA08D+8GR1oyo3wG49e5h2V/uDc5XJOp5eKCORel9R2QD EQ6HbYPm8iEycsk8Xgoxec65vRGRWVkazONg/ErCHgV/NA+YvZnW6IDPcCjGVffS vnsNWS53dmYSqMIsJ2kReFyzmBE7zQg/tUrH83crnsMYOKipg/9C7bxIq8rdhLOg QEaX6gjIcEnphuP/gtSvjxecnEv9e4noEOstsGOrUF4D6JxK07wTyfrp0NulBVWr iJNYBaSPAJbYI6FaqZ5FwYJMp4SIgnOuzjhl6wrTl6XZ5C2yIkqg5L4C8CHDdwxj hgOFp9X6roUOtdSi8+niC6nQWqX1A== Received: from mw6pr02cu001.outbound.protection.outlook.com (mail-westus2azon11012052.outbound.protection.outlook.com [52.101.48.52]) by m0380145.ppops.net (PPS) with ESMTPS id 4euthp6s43-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 18 Jun 2026 02:38:35 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=nFUwxS+AVuxKoqW35wMT9Bj8su8eVIKoZI8Bk3jjBpSlMC4A/gLpl0hjpLamBApKuZdsNaYbfI6k63DWgojDggHfEW5Sm7+XoSji4mt6p0M8JdrBCFTD0AM1D1aRnXJ2enRZd2wrI7LLc3ZRfiE+OBiGKdFy5/lZDVnLYmiZpDFMfiLqRUDIwr2a9X3Zv4RXPNWbv97prPbrGSQ2dUAZl5NR2UacJ+j/nu25KbcPU3yVjBt/4G3PJzzogZqRow6ksOiQSgWHr/6kfgNIpfHcHkrKAFTI/SvW3NrC0le2t4gE58cjoLczesr+4Tm0y+xpBJZFf3e3uR8PxSY1mh/fXg== 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=0ivWwogJkYOorimiUnRp2KrXCkZKHDm/wzRVhkB6p3s=; b=VllwveDgHTYsq2gKQet+RVixo0MxJb2kF8hR+Y0fCkIYGQ25R36nqEWhh/pd+zuDmFQglFyyGEescQiEHTDJ0x3p2vLZKnCAfMhNPfLqeEAGAq/cyZf2tmyPeNatbRqD9VuSFw9VjkGvMpX9SDN2+0I5Ws24oJDb9+yLzihJuMSRiGjcDy8spT2bMoxQrSEgA3pSGFpXb4mB903XELCQDSk43/Ou3ZZ3ekM1jiMhd8GiTA0K5SdKM5KMh7G47iXfdq3Cl8cu6VO3sXUDDbYZzXVvHISCrv89IFufNmLiz/m/UOA1kbb5yCS3Ln13gMOCe55MhaIRpx4NtTDwp7BNyQ== 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=0ivWwogJkYOorimiUnRp2KrXCkZKHDm/wzRVhkB6p3s=; b=lvTWDSn6ovDuqzH27KZ6PloZ7lIa04Ih8GtOj9RxhnBBMJ28tVHIssFRkPP6T15jf8egbQfLBVwoK5redhRfCG5GnccH2+WGv7EdBinf6Okg6wjsE+ZI9G3FxeR7D539NNJbT731+N9XPpvVETxgLc1GLTWpCjuVwTtJdTc3KaU= Received: from SJ0PR03CA0223.namprd03.prod.outlook.com (2603:10b6:a03:39f::18) by SJ2PR10MB7057.namprd10.prod.outlook.com (2603:10b6:a03:4c8::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.113.18; Thu, 18 Jun 2026 07:38:32 +0000 Received: from SJ1PEPF00001CE1.namprd05.prod.outlook.com (2603:10b6:a03:39f:cafe::38) by SJ0PR03CA0223.outlook.office365.com (2603:10b6:a03:39f::18) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.139.11 via Frontend Transport; Thu, 18 Jun 2026 07:38:32 +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 SJ1PEPF00001CE1.mail.protection.outlook.com (10.167.242.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.139.8 via Frontend Transport; Thu, 18 Jun 2026 07:38:31 +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; Thu, 18 Jun 2026 02:38:06 -0500 Received: from DFLE214.ent.ti.com (10.64.6.72) 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; Thu, 18 Jun 2026 02:38:05 -0500 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) 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 via Frontend Transport; Thu, 18 Jun 2026 02:38:05 -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 65I7bYvg3521710; Thu, 18 Jun 2026 02:38:01 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , Subject: [PATCH v4 05/16] spi: spi-mem: add execute_tuning callback and spi_mem_execute_tuning() Date: Thu, 18 Jun 2026 13:07:14 +0530 Message-ID: <20260618073725.84733-6-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260618073725.84733-1-s-k6@ti.com> References: <20260618073725.84733-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: SJ1PEPF00001CE1:EE_|SJ2PR10MB7057:EE_ X-MS-Office365-Filtering-Correlation-Id: dc2247f2-8292-4cfa-fdc3-08decd0c9851 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|23010399003|82310400026|36860700016|7416014|376014|921020|56012099006|22082099003|18002099003|6133799003; X-Microsoft-Antispam-Message-Info: DKT8Okzy/DimRwCOT4B1X89V/mz/pUK7+lBUCe7x55K5c6jLdSBjvTacR6+++hTTQw+ATiGq7/OHPZ+H5GubOfYsUhG3HufVI773hxQis+cFegT8fmOaxa01hj/rlG+jLQUafi4Wp4XlET+2ikOxKlWrO3zUxaFfxzzjwsmR0Gl/g9mi3K13g4U1bICCXgGdIyWeJnuhhgB59DHntTsgn0uSaq2jVXzwbnKOR/Qfki26jznrQLDJqfTzf4rpjt8K3C/KMKXZj2UI+gdUXOAjPERKrlnD9Yom221keIOYdSkbke5KCS8cKKuLokg86DvwTlekk2qnsWhWxRGRsHwMcpH1pyF3SdbKzFohz+Nj5PTyunGhR2r+ygbypG6jWnaUNIcclJsH427/anGnS9pGU3m5eO7CqgdZdC/Q/zqI+tJgyle2KrzKbSJmbPDQGCI6DQTJ2hxfP8xopYTAUezoMzZqWpesJqZQyJxzYcnemqKFVAvmzY13Y5ObWgK98UMzSjmQMgExKg6yMcQC5teTdYhSiK9b9yViKc1xbxjNcOTEBxUSxVOKRcbbeLFWyEbCqsWrtEuP050myaSE3qaBzbIUOz1eVpqm22lZ07Q6ZWhq5IyrOitOd557UsdYb4+EFC3xqUNUVBubfNO6cEJhHlJ+FnchXsSmdJKCy44BOCN8kBOEaXubVGRsOIP6vzS9SWWDQbtrXHBfBBKwL2xCtKl0QQvo64Wq4XyelStFF9g2OTGKjdWogb6K5BvPRBy5OagMoZzcG4Vq5jrdUvi8fw== 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)(23010399003)(82310400026)(36860700016)(7416014)(376014)(921020)(56012099006)(22082099003)(18002099003)(6133799003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: GYAdUjZ7ISJ/mKTdcgmXSBGuzt8k+A2v+J9DN/0soFJiwTpRxuuXFMZTopnTAJRNW2jJxYsIgR9pbhaLOKANODbN7Yniph6ChjTBV8+3FFsfopYuJyI0K1HVpcr+YASzWoVWeQ8GfGmcV13X7LL91dht1oLYlR5bc/VWFGSdhqH8fJY1SfV10jrhzsv4DoDhZ667zaoOiHEiYKn0OLhRoIU1PELJRtqg2eFBS52HvnHxfIuC8d9uuIYDcuZxUoNg0r68yL+znl0NWI6B4f+jiKNQPTePUJZWQdFo99D458XLjWWHJvjXmmQIc76/IWrsU2yasjtK+kgcNfkbuEmH/wEzs0AxdHb/s5UBH2AAFTSji2vBjuQ42HRQteTg2KyR1gzjU/EYyQeB7w2msDtQYPvFnTodPQga5oqZ10n9++rhcUGk4LcWrkfMuSft0c6Y X-Exchange-RoutingPolicyChecked: CRzzt7xpUKOLyo0a+XzbHejg6UrgOG89au5LD9xAfrHULz3NGHysBcudTT3fnmq6c75PIXH/JeLLPBexak9MpGvcwuP8bSH/UmkbtD3Mv/uA0bQQRVgUw3tpsB3J+pTz6tQI3q+KY9R+DLB7fFR4Kc9NjgZwV0JhAefwtruD73DPajyYwQ8ZcDCU3A2iaBSA5sshQxjQSDlXD6xCsg61RBcK7CINJzryEju8cpvbD5ThbIqQah+wN0ojiBFsQcT7+MRDYEeKvu+pvhDJRMZp/MD4pM9cVkenpqXYbR6O5J7UcMVfc+wpwMiIxBZAmrHix6MEjLfgziKvY0jJbIPj3w== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jun 2026 07:38:31.0750 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dc2247f2-8292-4cfa-fdc3-08decd0c9851 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: SJ1PEPF00001CE1.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR10MB7057 X-Proofpoint-Spam-Info: AW1haW4tMjYwNjE4MDA2NyBTYWx0ZWRfX8BzDSO8zBlLe s1kSz7TXyGCE5JdcTsuCBqoDwQqG/07g99RxdGbQ1q2YmGxG2RPFmPCKN3QxIY8tQjiXHh6C94G CdwJF42odU/I5AE7o7ZoyecFeDSLldA= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNjE4MDA2NyBTYWx0ZWRfXxGTPQVkOJsdO O+BxpDJwfkiAAx7xP9JdVPsBVnCuyQjYzKZhmc8e3zq9dNrBE0jmwHv9Zbs5kqleHyKXNDcOyFy +YyJhk/DtxC7TFBhcsficvojEPo8HH/Pj5Ik1rUZxnOx5KDueJK/+q4QKxFgixY/HuZ3NkycNWD icMYfL5Y1P6k834f8BbHHMNCC9X7NP6iCqg1AuAEcwGtuYN4/5yw0+dOCtj+dvHOan/aNvUoReW O5U7AkP12s487l2I2P81bx4u91Z5rg4laCLS8Yx0bHV9txnBG6aofRWQ1nxXop+N0yUlOjKcPPY psojPEnUAW8xoFL6Fz7m4E0/RXmeYQeoZ4ylSCfsLv7JffL6HDsQMFwX/YpK2JQ2Y6n8xBidFBr VhZNbbl3zaRW8flaiUk9VkklsSCkAojHUAvfov6E0vQAmEiOU07qbiMJTH4c/Vk9xU61vtz0UBr X4LoddeUS5UrO1/T+Fw== X-Authority-Analysis: v=2.4 cv=N/wZ0W9B c=1 sm=1 tr=0 ts=6a33a07b cx=c_pps a=NkapyFR+xBWi1egQVwNhyQ==:117 a=iwqwCZQqcuTv3JOpYdM7/Q==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=FelO9ux0wxsA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=gO1vWkAQAl3rybz1DQOp:22 a=P-IC7800AAAA:8 a=sozttTNsAAAA:8 a=89-jStNdFWHnqtgceuoA:9 a=d3PnA9EDa4IxuAV0gXij:22 X-Proofpoint-ORIG-GUID: _1sPQngn34-yFmw26P9bMRNuLc0GDQWN X-Proofpoint-GUID: _1sPQngn34-yFmw26P9bMRNuLc0GDQWN X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.125,FMLib:17.12.100.49 definitions=2026-06-17_02,2026-06-17_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 bulkscore=0 spamscore=0 lowpriorityscore=0 adultscore=0 clxscore=1015 impostorscore=0 suspectscore=0 priorityscore=1501 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2606180067 Content-Type: text/plain; charset="utf-8" SPI memory controllers that support high-speed operating modes often require a tuning procedure to calibrate internal timing before operating at maximum frequency. There is currently no standard spi-mem interface for drivers to trigger this procedure. 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. Add the corresponding spi_mem_execute_tuning() wrapper that validates inputs and returns -EOPNOTSUPP when the controller has not implemented the callback, allowing callers to handle controllers that do not support tuning gracefully. Reviewed-by: Miquel Raynal Signed-off-by: Santhosh Kumar K --- drivers/spi/spi-mem.c | 31 +++++++++++++++++++++++++++++++ include/linux/spi/spi-mem.h | 14 ++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/drivers/spi/spi-mem.c b/drivers/spi/spi-mem.c index e20eca1b8245..571a7dd9c2a4 100644 --- a/drivers/spi/spi-mem.c +++ b/drivers/spi/spi-mem.c @@ -660,6 +660,37 @@ 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 controller doesn't support tuning, + * or a controller-specific 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; + + if (!mem || !read_op) + return -EINVAL; + + ctlr =3D mem->spi->controller; + if (!ctlr->mem_ops || !ctlr->mem_ops->execute_tuning) + return -EOPNOTSUPP; + + return ctlr->mem_ops->execute_tuning(mem, read_op, write_op); +} +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 Sun Jun 21 23:24: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 6D537317158; Thu, 18 Jun 2026 07:39:07 +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=1781768348; cv=fail; b=iivUdmeLquppKtVGEuF/8GZY41S1sNmrNVjwNjnNwiu9fKO6yzcKfSy4OrRGWnH2j2z1T7KWM/hfXizV33CNLguhpUGIQjrxEPbkc4v5OkaALMLuYMxJUQuFSj1P/3bit2c+bruLc2bSeMnjAaNFsIRFgF/eRowKvS8N7mBadmQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781768348; c=relaxed/simple; bh=1TNaL961Cge3k7wU6h0EQ4Y86FKi/4AiwNfqTwOJcWo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MN9UDmVG8znfFMizRW/OubJRXXbg5aAILuCktnqBGB5YkhnhW+44FnhiBvMnM9i2/MueLOOI495F6Jij0GDoBQKiXRO04xi4VF3pyes7uBlBnAG94pEGYwxN0KAQlDEYGixqrHLtvxLd3x6VqF7aWN90koB+NzQi2+8n3EBZixg= 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=nI9gbxqt; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=LNXlM9DA; 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="nI9gbxqt"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="LNXlM9DA" 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 65I6StIo3435889; Thu, 18 Jun 2026 02:38:58 -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=mWYfQJUfKbZZJ9k0BCHgnlW6JIDDm6EOLXaVsX8Kd e4=; b=nI9gbxqtUhQReS/y7A7Ii7TPoIV2x5ACRrideeMqNoC4WCA2CrOv9eipr T765px8dbLjyk+F4Nq1X+XCmpu+z5kqMwCsLSt0NT+dnJjT5nH+pG09/eLG9jn4L ELyKdFaHFwRiAMAD9+98wH0D5+0u5xtaIYtS4NzKHzAW7dNBAcB8Plz9VnZ8tlGd P0iMcNy+Fn+HcFudHkzgf2oliFocPqse8hajMf79vU0Pzxjp1iCZODrdZq1d9kuf TcN+egddwzwFNUwRDkFiA3Dwp5cYDCkb+gegHFxzIBIi6m871kWPLf0rFmIzmnhA 8kn4uz9qwunfX/Ys7nLg4DSnvKvfw== Received: from sa9pr02cu001.outbound.protection.outlook.com (mail-southcentralusazon11013070.outbound.protection.outlook.com [40.93.196.70]) by mx0b-0002e601.pphosted.com (PPS) with ESMTPS id 4ev63rj14r-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 18 Jun 2026 02:38:58 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=NbzXzfdBPDrx8q9kUNnKLnUpFhOSVdWiZePR0vPVN3bAoFfo0dWyPcYSREvKJKlCo0NwytgbK+tdonuYZRmsEvsL+r2KDOfbJbOqb5rgsF2SQDscsJB6IAIe7ND0et6zDPXRLKSrNOcQfNIpo7wXPiPZHx8XlFe5QhikImIJrWvdSHD9p/EPLAGGNmdrDdEtNT8Jeme3x2OeOdZybJEFMYx0B/yQArU9Y42QHOeD2C0H14pKZ8cLWDmAC3+pwYGBK8mhB3OjI0WsQMyaKJO517bowjg4YTA8AVy8iqzD7UKzspWP+mljbVt+vBK1+Jh6sHNA9fi5MXRkAm32UFv/9w== 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=mWYfQJUfKbZZJ9k0BCHgnlW6JIDDm6EOLXaVsX8Kde4=; b=yuCVQxQUI4zF3s4BXZ+vwgmiz66subbPUaCNnc1UXJnvOYLE6Bcuyowbm6/fwlKWXZq274D22zzppy8zY5kNyMwmAQgNvxuZ65hLANb/zB1rf5qPUS1J7txRob0qFfMh9PFUy7JE5yD6r/f4V+G0C0M4/ga4+Nu4gUOxw8KKOwL/QYhhQgVBZw2BADKnxmayiBPzpvXlYV9KfJoWc5TwfiCELYyjdde2XS6Vf/MWoMvB48rSebzhgrPvmq//8ltiuX/9LH7Ckd5MaBcagzq9MxAhDNSxl6jiGgs3d2/GJzIkwrF0HSScsj0OeAvZfOSnfVr/xb/nemrnm3M9DlqRWg== 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=mWYfQJUfKbZZJ9k0BCHgnlW6JIDDm6EOLXaVsX8Kde4=; b=LNXlM9DAEGLE/xyFbeAhBlaa+i8ZIWT+ADXyky02hvelDHII0e62AjP0i8rj8XK6O3pdc0vsWehoN0JhV2RjxEdeN5c7L18f67TxDg8WXyzSm3Q55TdZZsgbMQ25/fdXxA3+/w+QcYDH8Atlc66um+HbU53idrZTHtJq5emSAJo= Received: from SA9PR13CA0072.namprd13.prod.outlook.com (2603:10b6:806:23::17) by DS7PR10MB5197.namprd10.prod.outlook.com (2603:10b6:5:3ab::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.139.11; Thu, 18 Jun 2026 07:38:54 +0000 Received: from SA2PEPF00003AE4.namprd02.prod.outlook.com (2603:10b6:806:23:cafe::32) by SA9PR13CA0072.outlook.office365.com (2603:10b6:806:23::17) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.139.12 via Frontend Transport; Thu, 18 Jun 2026 07:38:53 +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 SA2PEPF00003AE4.mail.protection.outlook.com (10.167.248.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.139.8 via Frontend Transport; Thu, 18 Jun 2026 07:38:53 +0000 Received: from DFLE213.ent.ti.com (10.64.6.71) 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.37; Thu, 18 Jun 2026 02:38:26 -0500 Received: from DFLE205.ent.ti.com (10.64.6.63) 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; Thu, 18 Jun 2026 02:38:25 -0500 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) by DFLE205.ent.ti.com (10.64.6.63) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Thu, 18 Jun 2026 02:38:25 -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 65I7bYvh3521710; Thu, 18 Jun 2026 02:38:06 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , Subject: [PATCH v4 06/16] spi: cadence-quadspi: move cqspi_readdata_capture earlier Date: Thu, 18 Jun 2026 13:07:15 +0530 Message-ID: <20260618073725.84733-7-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260618073725.84733-1-s-k6@ti.com> References: <20260618073725.84733-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: SA2PEPF00003AE4:EE_|DS7PR10MB5197:EE_ X-MS-Office365-Filtering-Correlation-Id: 26f7006e-90bc-487d-fc77-08decd0ca58a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|36860700016|376014|82310400026|23010399003|1800799024|921020|56012099006|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: pilhlJirT7ciUU5EeNMPEx8WlTukzpUG+0MBH4n+sDwFVejlTAZ1UWDYYN6KqR2nWLnOckt4CG339Kf98h8bW5EnCGJzu7FnSKEBVVOHmZdb3gCQ0cvH52N+e5wWmIqkGR+tZJtpcbt84ZOWWRSEGlIUkuNVDCJWeZEwSkq5JICm6HXkyHPiGaTGZbKbZUTFJze0T5igrTivnOqnPXsfJr4/L2Yk/B8njGuEfzfIs+tfkyP9iVdlMish8WOaacnrORcDAQ4MuZzwC0eaZH1t2li9Dkero1RjH7Qj6mkd75HBHDze7Uz6UsyzpnBPvOiK8uITTW0OfnwaDe+u+I1lsWbcGBoS5jusssnE8e3IarrAyPYz4QD4aQ24verGNqWhBfhaSiCFc32AyAH5FTtuqcumZf1tijkRdqF4yCkWNFtBOOdKuq/m4rmHpu74+SEC4GWeYlt0u35B6Jla9bqik4KwGbrLYXV4m9YOYBS5uZpyguXlRhs5kIKM1buhuXJH/VWag02nTbUH9Qcb+yy+fIyH+KtZGQfbAs7IHIr2aveYQ8b//mjftzWxdpKWQJmYnVPIUvviX/tdDccl5AR/5pjg39RKRJxjFAUw2kolw5MxdB+z57j2pe+/TbPKPWsrhJk4nu9GktVd7yFMx+rquIdj/XWK1pxShrJeAClQiZeaYNPUHlrkyYPp63ESzJQtVQ2i85+C+XMrFjnxGX+PxJ6z9wRGwbANYmHKCCFFUM6FvHcswhhl9+rA1bmMQ7hTGAbm14qTQAfYmIWPR5RQ4g== 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)(7416014)(36860700016)(376014)(82310400026)(23010399003)(1800799024)(921020)(56012099006)(18002099003)(22082099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: e7y4Q6MafOq0Qr7SwutFQa3kpn/q9BClqAEOI01FxycmoAOo/5VrGKpWzsy3Hnl4ChNPQX+ZZBp/avCgcvKs33q5LMVd9vJR/dTV2NZdIghggaIjkUdCaMAnKS63TMi7oY7gImDtuu/pDxpqXJ3FrgVYnL21P6z4ES1pl6zXPuG9WD0XozGWhjynWe5AUo8feRAUw9GO8zangZHbp9oUcRM8pPGzFTiGIVrMuCEwVsiM9n0HGXredx8G7RvD19anN1aXkJD1z8fxn8KIjEZAeP8guGwAIaGbZ+0SIeEwB6HW1ebpEZLtG/JZqJkryJ6NdCaOpPU1yTBs62YdJP1E65TmT5i93RW5IW2p4Uo8qtb4PHg1t88S3Iq+v++YJF44mC4vel2zSSHNyKJLARDvPNPJ8ETSol0Drlr0G46wzN5RGYUZwZkWHQ1Jyx7dVtPD X-Exchange-RoutingPolicyChecked: qf1/+A4mGYxW8pOcpr1ndjopdqztig3kybTJzOa3XYSrNNMCyrOLXO/OF82eZMzcer1paPJfJj2AcLinN1a1gimj02Gj4ep5LTk0t0XMJaJ5SNRJ20CKzSuLV11k+xm7/hJ5AJSdFUCw+nmyXj5nht5Tw2a09hT1M/DHeJ+mZswTmA4Frn24wpHNH/RVUFOffKdG1PYGnR4Bd53UVo7x4lPrbBwYz+4jejStuQdINHlMd9zOzQFWqT5le7GHNux/RdO2jsyn1vhelcXKAp/8oj0pC8wg12I3Z3nf45i2IF6wsx/VTidu24tFzFTcDximWA0Wwph12LUtqdfniKhpRg== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jun 2026 07:38:53.3094 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 26f7006e-90bc-487d-fc77-08decd0ca58a 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: SA2PEPF00003AE4.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB5197 X-Authority-Analysis: v=2.4 cv=LpqiDHdc c=1 sm=1 tr=0 ts=6a33a092 cx=c_pps a=gDBu5PZszbgJPyH+JdeeiQ==:117 a=tJyPKKxUohctrY4NYmUjkA==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=FelO9ux0wxsA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=fPAWb5peG099m5CrUpKH:22 a=P-IC7800AAAA:8 a=sozttTNsAAAA:8 a=H4zukSXeJ-NHMtihckAA:9 a=d3PnA9EDa4IxuAV0gXij:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNjE4MDA2OSBTYWx0ZWRfXyWbw84lAivCS YaaAit2MGgiRZIS9dgheBvpfGPsd7pxdLvgeJV83XmCo9lKgrcIMVj0gu7xo6Up0uPHaLQ/GMtL yqj3UJGKcan0aoT6t6BnBt/Gq7EZFhREtMl6JqvBfz1yNU+a6UpBC8tTWIMA+FIDRUuOV7prcjc cbBysq+CIU1B/Md6NoFQ5G5R2p9X3c7nisLHDSN+9d69qhpNrlddtyKgTSxjPXy7Lkrj6c8nd3i iYHm/MiSEyFTWxMpM8eyehgTOvauBXwjtMVor9NnQUDWUgkkLay9exipjhe+lWRs6g/HJGrYAAt wDtzufzUCKk5spORCxLlnQ0AI47bPUOrGUydrr6UxhzEzRt72IyuFakmidYlwxx0CZ3jBEq8+ab EZHFTN5Ma7K9vsI1AlwZl4OzM0bA0ajd4hLCwXmldHl0cpxsEUbY38+SaUOjragPlG5rbhpXVys xOG+4tLehfrEl8vWusw== X-Proofpoint-Spam-Info: AW1haW4tMjYwNjE4MDA2OSBTYWx0ZWRfX1RKGEhwLN8j8 YhJH8LSm9W65bvKxzDPBpQLgiu7MxsGtb868F2YREzsT5pKubIGHixDNSn7130BgdqVHwhotpX5 ff47l/De/6V2Vu1zrTwmhBS80140kBk= X-Proofpoint-GUID: UnJRMqf63kBWzcQbG_YiG1VRgUdL5LwI X-Proofpoint-ORIG-GUID: UnJRMqf63kBWzcQbG_YiG1VRgUdL5LwI X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.125,FMLib:17.12.100.49 definitions=2026-06-17_02,2026-06-17_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 suspectscore=0 malwarescore=0 impostorscore=0 spamscore=0 lowpriorityscore=0 priorityscore=1501 phishscore=0 adultscore=0 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2606180069 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 for read and write operations. 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 aaba1a3ad577..54fd7b591e06 100644 --- a/drivers/spi/spi-cadence-quadspi.c +++ b/drivers/spi/spi-cadence-quadspi.c @@ -453,6 +453,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; @@ -1270,29 +1292,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 Sun Jun 21 23:24: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 681773D301D; Thu, 18 Jun 2026 07:38: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=1781768338; cv=fail; b=kXWPJNpNjoTei9cOvZeHFOqfy2Iar7vidb9Ke0TyAgmKl3tJ3P8bmglWlEHut9EcFUvetNQ2CLUs34UCLibCavfOi2gJBTv60HNDZfEhWeydzgqKTbuyL5KlJP+r+rLipY3UHlxjtmQ3k7GDIw0F4B0EJamT8rmJ+RiT0THoWuc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781768338; c=relaxed/simple; bh=jw3B9yi+hmX7DsJIwVzasLjy4Zy1mAqhau2w2IMS3zQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Rsd0/8E3Qxa0ShgTreKGy79MyJqCQ92erh6Vp8SEwYU0gJ1cFRYwS16fP+Ki0oDD+1+h4Tv4rNTEFVJnJb5ewihGYNVBcaxYtxS09LVIsXDYK+Ed8ygZlLzqkFDcq+GyZ2mXFTmeiTG9fBx817y9QcyBZp7EstHNAGHAVX/xF9c= 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=o6rryniB; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=ZZZxF/Ut; 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="o6rryniB"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="ZZZxF/Ut" 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 65I3ndbN3790559; Thu, 18 Jun 2026 02:38:48 -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=wCZc0wIVBtDCh1p0IprYueCIB6QFm2p/C8s4JQKgh v4=; b=o6rryniBkjClmnIVXZu5kvtTg0SLW7a/NXdSxK6gkdIHYoYPr4Az29Q6q vrJdpKZbVy3enSo17MG8Dv61eQrxNp78qFO1fqgFliNUD4QnJlSsQVYGc8oYCPFk jxlsFPCtOuMC1uq0v+YjcVSSo5WfbqBXxM9WvXatPAgeErzlNhepXZB9AY7OYyCb ZU764H+KdnnHPCIvBTvSjQ8cN+VN1bWg+w68hP3WCu76Mr1nuYWst+/yW1ksK78C 7RTsOvjgqfXlkS4/o+blgbOPHcn0ns1hvVNTReOwwefBUY4/doBMiz/fKIzuhSyJ 6j+QFGu9KBmuD3XXnxyiwL3BXIQFA== Received: from bn1pr04cu002.outbound.protection.outlook.com (mail-eastus2azon11010009.outbound.protection.outlook.com [52.101.56.9]) by mx0b-0002e601.pphosted.com (PPS) with ESMTPS id 4ev944935g-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 18 Jun 2026 02:38:47 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=kfgoAzLyJygW3s1S+gfaYvrCuneJaxE9SQtm3TBJ5JUUHt4cWwsAYo2VH3GExEk5m3UUqffnj0QxtfsU3NybVhUH/I2M3o+OkkYwVfCMKdcYk3ZEfauOQ/I67XBr4zc09FZ3SOTtQecoLMfljg0KUacU9bqDGcZnh6mGnbgKNbIuTr6FFC18el4Mlg7xHTozqqi4NMicS0aNcsagppYQz4dIdm6Dv0RxU3xoGFtiGYPO1xfPuMZ9w1FgBt/d4+Bg3agmPEPFmcxGJmFSUg8BDYMyr2HVxLpDM0YQMsyw0AOXKo52ooHO9+1luGh1c1fwFAQmqse1ygFSmVQRPCL4aA== 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=wCZc0wIVBtDCh1p0IprYueCIB6QFm2p/C8s4JQKghv4=; b=QsZ7jxMShCXLUnkGSEMZL7SH3OSwgeQFL9ewOCUbUuiwXnMLER1VTUwDBoLxAfTz34Bi3ypBnpOItnBM2oVVkujAuOszUuq3mW9fbcsDN95w9BfQcXaXqdx1rZwSQKDWrUvUiRh25Cijqsz6O3XVxzVazWDFIXH6Fj/50XVX0/SXJgC2cCK3Zd+rR0vwo6lZBTX0dC3P0ZaeARCL9G5rfTkPnSiZwMBOWgls8MSksUspIHfep2HahZSwWqo0He06HI8PLpx7A4cu1yvn3euATE7tpaKmJ/7u63lVLfQ0jUoU0Sgk2k56k0/p7tAguMlDtDEoFipyRWiFy2+AGjhEbQ== 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=wCZc0wIVBtDCh1p0IprYueCIB6QFm2p/C8s4JQKghv4=; b=ZZZxF/UtDBCvgGfE4wHw9Ga2dpGx8urMB6VV/tho8ZUG+bRRZAn7s8Lcn+RxqfoC4vZ3WwS2V7L4nQDsAUVYr3m0DFbDNNIy2jPw5l2hIDsCMkx3G5TlUkWjyFBz0vs6sq8INDLNUKBEmJ+b5LkUoxG099j6IWYcXc0xQ63ASVI= Received: from SA9PR13CA0066.namprd13.prod.outlook.com (2603:10b6:806:23::11) by MW4PR10MB5678.namprd10.prod.outlook.com (2603:10b6:303:18c::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.139.11; Thu, 18 Jun 2026 07:38:45 +0000 Received: from SA2PEPF00003AE4.namprd02.prod.outlook.com (2603:10b6:806:23:cafe::1a) by SA9PR13CA0066.outlook.office365.com (2603:10b6:806:23::11) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.139.13 via Frontend Transport; Thu, 18 Jun 2026 07:38:44 +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 SA2PEPF00003AE4.mail.protection.outlook.com (10.167.248.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.139.8 via Frontend Transport; Thu, 18 Jun 2026 07:38:43 +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.37; Thu, 18 Jun 2026 02:38:16 -0500 Received: from DFLE214.ent.ti.com (10.64.6.72) 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; Thu, 18 Jun 2026 02:38:16 -0500 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) 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 via Frontend Transport; Thu, 18 Jun 2026 02:38:16 -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 65I7bYvi3521710; Thu, 18 Jun 2026 02:38:11 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , Subject: [PATCH v4 07/16] spi: cadence-quadspi: add DQS support to read data capture Date: Thu, 18 Jun 2026 13:07:16 +0530 Message-ID: <20260618073725.84733-8-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260618073725.84733-1-s-k6@ti.com> References: <20260618073725.84733-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: SA2PEPF00003AE4:EE_|MW4PR10MB5678:EE_ X-MS-Office365-Filtering-Correlation-Id: 12c3a011-d7db-4d69-8d95-08decd0c9fc4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700016|82310400026|23010399003|1800799024|376014|7416014|921020|56012099006|22082099003|18002099003; X-Microsoft-Antispam-Message-Info: 7669C7Iz9St4oqhoJrn+u8c1ALBKLHPvEMyB31lB1eXWWICo5l9Z2ceqwLYimq083vdhfoFL3FYOjcAiKElf++JYJ30JOBf+Gz2AkwDR7Y8IXj2JmIsEfd4I+p6G9fssvVjaxHjfGMfqVyNKS+JLm6TlSNRqt4/Qd4ESyPjZ0Y7kV+85940w7sN8YEFg2KemYirwfSXrj5+Hf6KHNLjDWDtDDlD8/7+q5+jNRuQlVXafvYIiAf4hKRCmM/AoGbRNcXQDlOx1bZTQl7LFvq70cDkby4xdY73vuVnGfmIOhHCaRH+iIl+qOKNbYUVkfG+Jal/i/r7JTQv9k7rbXPcaLaGgVRW4nNM6GO5edlJidrUFeCgYbop7U3TAksfbu4fNV/r+N9xzVD5Z5+Dw0edHUXXTrGH+ZhuG8SYpqu9hiSznkxhFJu8CJVc0QEngnitaJkck4TR0J/IohWXej5rG5AU7uVtsPbTvPo0LIECW0VoKpgyCucKTN0IAOxc1Rq1gm4DCe5Wf5mnnpCOHD9FfPYBngsjBi6c4xA43/MNJEQtmGeVfVd/6OYPEr0oKZB2CKkfkhBI6UJ8fBbAqTMpDpuH2NPUuFHK3f4CG3yyY5I8/7ITVQMDCAMaltiRcseaYIKIY1rhcWVVVlmDoqjbeFADnbKPr2SLbcTG9t/tinOpiGBI97a5Jo3EzcIs+UEkaK0E0xWrlnNwg6pw6FKzb1mYanigSQiVIEsnBHmFlgG/QfQc2uxsJQpSa1BnKbh7C/CCuAkJ0E9WpkHJl3n0+Ng== 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)(82310400026)(23010399003)(1800799024)(376014)(7416014)(921020)(56012099006)(22082099003)(18002099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Eh++v4qoRGDr54zNn/1yKToHXUhxrY3PLbD/NxpKnvIQ7DPdrNTJHpnmNec9r8syaTUOXQD0IPUrLTbP1s05KOyCMTxeX7v7X0UlbcFOROalpugvZ5N7JMp7LcGFPUlOMKlbudy/NP/8IlKb6Cc512M9jSWTDimgrW4T6+BVjt8qTdx+FcRTsdNnBmffYOPEwgHS9JSAsWlx8vusraMAHB/6wZBDzTqB33v7UMbTRRvzXXA41pZ1ghBOmVVdQp6ezHe0bEebm8dpSRAvHWB/srJK2xGEDySZsCvjoBmGsd+yObCq29ZbU/AqJKeNKWxhUKdsgwdgw+jW4OggzuvsMSycQInV+7JxRODC4S96NorL/BCVujWce0Mxasry/AocQ+o8wTisbG2qxCx2Ruusxk7PBU4DIGW1kDBG/sxJ2N1Fn3Jzv/K8NK1ZSqLszQtH X-Exchange-RoutingPolicyChecked: AegOBd2Yn1ErM9q2NVePmOIqb7BZL+1xnmwSu/ge+FrHksTYekSHytyJ800N8o9FswdoAu+T1car3AwUwMwec8sv2oB9Zlof0gVwNgWjGuNIih2UOswvKkdMrbYluDRPUcecLxC6Hgz9HL06z7EpOHYrPbv2BRtYQvQeu4IwzBVFa3IAMx/B76dSbPdLbznjFgd3aPCk/VksbOa1JWdD6ZltZrIuwGKoZm5/nPwqr+x5j5Cm+4Kyb2nIso/S3y/MVGSoeWl9eQBhVbIkxbtqQY3B/PtOv+DGP9UzdugsM8POlU8aed1q5ztMoGlGRVN1ZKNHBu3Q+x7vYwMuxe1zNg== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jun 2026 07:38:43.6198 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 12c3a011-d7db-4d69-8d95-08decd0c9fc4 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: SA2PEPF00003AE4.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR10MB5678 X-Proofpoint-GUID: dYAfudZ4_Swbe0qVXqEMNo79_Zz2S6Zt X-Proofpoint-Spam-Info: AW1haW4tMjYwNjE4MDA2OSBTYWx0ZWRfX/9IUSFUdmQ45 10V0h3YxGXTMgTvRfYvhnOfmKkS3WcMBEuNzjiL+IlQXIG47gBN1+8+RpZna/1ZbXFPKiHrxrVq BlRW43ae2IewdF3Kq7sHxV3rMzVgBxo= X-Authority-Analysis: v=2.4 cv=QMxYgALL c=1 sm=1 tr=0 ts=6a33a088 cx=c_pps a=St4LTB+eVnQVBP+Ivca1Dg==:117 a=tJyPKKxUohctrY4NYmUjkA==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=FelO9ux0wxsA: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: dYAfudZ4_Swbe0qVXqEMNo79_Zz2S6Zt X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNjE4MDA2OSBTYWx0ZWRfX1SMcCcw4tqTq sKyTPcQlbwF1GwO9KIyJtKeiOlHMSCyuKeYp27pcQejUxY62S2kHkYYaYtznbFwoPnB5x8tIT5O AYJ9oegGKrWNJeH7+uV8F+AuyQzNcl4HdLZdNfLCqbgE8qfIFblkLX9AmFL/QF4gefzPuPw9bXN +uYaP6bDNB0Ku3m32pUBjQc3vn4Z/p8gL4h6KlEJQSUMU7bxEfEWMjDpzwlhPLah0zVj5ncJw9Y jq5SsJt4muz+/amaiuewXUooeZm+Ui+ZaKg1x1Nirmb76zYebC66/turkX2yJwSdCQhWiRMbNL/ tjNl1qCH2AM4e7c/a7rmnhHXT2IMLEG27ZASNng5h8RBCWafJRUqzZGdV3uHGZ9djSWAf3qUY2T 922Hw99EDIcEhGqTAc/f4Mp0gVqoW8FPukWXNrw+/Gy6JDzJgT6mhHepERd7+xatsQQjrYqlAbj i7rq4c/MVPymjQGFbrw== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.125,FMLib:17.12.100.49 definitions=2026-06-17_02,2026-06-17_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 priorityscore=1501 malwarescore=0 phishscore=0 spamscore=0 clxscore=1015 adultscore=0 impostorscore=0 bulkscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2606180069 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 54fd7b591e06..201d69c64c49 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 @@ -454,7 +455,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; @@ -472,6 +473,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 @@ -1313,7 +1319,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 Sun Jun 21 23:24: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 145F92F8E86; Thu, 18 Jun 2026 07:39:04 +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=1781768348; cv=fail; b=aOUR2UJBxg2Ex0FmitpEAxdO+5LpHB1OyBZtHfmtZGUnktkLhVlNb7Cg6X2TQp+Xpk+pUp7mo7nxMrUY9LMkSjmg2E4cjiQNWPX2OZ1/MTrP5kCeMKQG6dVN84t/x29L5eL4tDqHmhpK1waDcIouTciwvBkJwaLAnVFizDBkznU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781768348; c=relaxed/simple; bh=G28FJzSlG0QVvOgSX/9tPUgs05VCfG3f+t5XXJbLEs4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=W4WUO34XmxIiSoOcmGqNgJzOWc0AytiltCicsgyqmryu8D8SFk/Q6VnK04HY7E4NJ0aLYrUAG5IMJEoKX5XYOudm7dD0wToiovMKyEiwg2RvxB88s6vK7MWB9j4E36sIvlYZ1moHQA+JUz5KJbtxdH666HfZznPIbecsF3lsGpw= 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=mkwvZs9E; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=QMrN+kkh; 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="mkwvZs9E"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="QMrN+kkh" 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 65I7UQ3s1333596; Thu, 18 Jun 2026 02:38:52 -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=j4x5g+CiQde4eeKDq8rnpLA23uL512w+pIiwYR7fj PA=; b=mkwvZs9Eraol92KQjg1QstQIyUmRMYcYNNqcyUKrtVKKvK1KAeY9R4ZB2 KIiPxL2osFL/lN3uaHD0EoOD2QzuWmpjyB2+AN0x1FhnWJEfR2P5GfwcYJ7dWRK7 gjtpqE45HEhZKNE26hJv2q4nMCGUvsQdRu0qT0VQJiy3VappGo0WstmXmb1kYUPE O/K66PiBz/N3Twm8A+bVazT4JJNO4j+IJabKKCg0lNT64Zqf7IhbD6bMBC6xDakG eMxwbqNaEq46pbBodreWbjVeG7qVpqncjgu7FVsclLApEFIE6kQe/b8CTVmAXZG4 MB4bs+xIdvzIScwcQ3T1NQ6PvgGYw== Received: from co1pr03cu002.outbound.protection.outlook.com (mail-westus2azon11010066.outbound.protection.outlook.com [52.101.46.66]) by m0384305.ppops.net (PPS) with ESMTPS id 4eutvept67-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 18 Jun 2026 02:38:52 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=UNhXNrClXF9JE0Hu+AAl++QehdJi5vzYtKUqoRtGmP1VAKsLMgvmZi8KFhXQJyQDg5atBwSyu+uiv6VBkEQoWm3ev6HixMaLMN+Mc2WJ+F2jteOdBnoi6ZsEVG9UDYpoJNMRTA+Q52uDi1ybgmc05XT4G5N08Qv7XhgwmAx+HY9C4JCtQjOXoOVus14cR9uPp6FFn6w8r0fWGs7BpMk/9z/CG0ChFhl0AzenPzWJqnB3yKZ01oZq3XswLsucllID+k2+uXVCOgLPsGpT+3fPxzvLmzCmmFJ7XG1sR7hX0dL6F8WUNfG/otyUrgNyiCnXrkU9yXNOCEal5cFQ+YiNOg== 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=j4x5g+CiQde4eeKDq8rnpLA23uL512w+pIiwYR7fjPA=; b=fWl//QrNo6VAELKoW5OGKjIZg8cXuxqXCZ2V4Hu22JXu1lcsuMqaqG7tWGZyDiT+YLw5DN56QzlZk4dnGg8Tu5OshlwwK8dtTF/pMroGwkHLK39OySBuBQdFXAUXggXZ7XRY6z8WRBQSVZXH6B1MIi79Ex/W9gmL2bHkB7raYE/gMwlBvaypI88GW4Gb8fMlbzcS27NCLdtYRyu57nOyuj3yLSiGEHEeZ3xxCyT38IhXTV0gTHHuQZ6t5fOo0WxFXxnSYXHNai4jRWrZi01D0bQzhF4wuolesOapOXkmMI9FalLLK1U+WAEis8vtPtv0fvpaZ4Lkd3P+iurKbBgZPw== 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=j4x5g+CiQde4eeKDq8rnpLA23uL512w+pIiwYR7fjPA=; b=QMrN+kkha4kF9Pa8GLB9owPaa6SgeThG1UKovaPFMnV35W+dY5+KvET26zvOipwA80K04aEfgq8X0F27d2CxpJQWivR2fBFO3ypKmcie1ESZd2phIVC4tRhFNU2AyMu5chEtm622u/CKCV6M4a1MZztju7lEW+Gi2XY+QyLHU4I= Received: from DS7PR06CA0016.namprd06.prod.outlook.com (2603:10b6:8:2a::29) by IA3PR10MB8043.namprd10.prod.outlook.com (2603:10b6:208:511::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.139.12; Thu, 18 Jun 2026 07:38:47 +0000 Received: from DS1PEPF0001709B.namprd05.prod.outlook.com (2603:10b6:8:2a:cafe::1a) by DS7PR06CA0016.outlook.office365.com (2603:10b6:8:2a::29) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.139.13 via Frontend Transport; Thu, 18 Jun 2026 07:38:46 +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 DS1PEPF0001709B.mail.protection.outlook.com (10.167.18.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.139.8 via Frontend Transport; Thu, 18 Jun 2026 07:38:45 +0000 Received: from DLEE206.ent.ti.com (157.170.170.90) 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.37; Thu, 18 Jun 2026 02:38:42 -0500 Received: from DLEE205.ent.ti.com (157.170.170.85) by DLEE206.ent.ti.com (157.170.170.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Thu, 18 Jun 2026 02:38:36 -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; Thu, 18 Jun 2026 02:38:36 -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 65I7bYvj3521710; Thu, 18 Jun 2026 02:38:16 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , Subject: [PATCH v4 08/16] spi: cadence-quadspi: add PHY tuning support Date: Thu, 18 Jun 2026 13:07:17 +0530 Message-ID: <20260618073725.84733-9-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260618073725.84733-1-s-k6@ti.com> References: <20260618073725.84733-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: DS1PEPF0001709B:EE_|IA3PR10MB8043:EE_ X-MS-Office365-Filtering-Correlation-Id: 9859cc5e-3006-4618-6856-08decd0ca0fa X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|1800799024|23010399003|376014|36860700016|7416014|921020|3023799007|18002099003|22082099003|56012099006|6133799003; X-Microsoft-Antispam-Message-Info: tpuBzcew6km+376RTdB3R+r7ht6UAj8o1Lgl6rdcQz7XYvdZ6ZhukPcks2XFjBZVKUc5OPbEDueBvURe04KFri64M0q0RJty01FK5eVT94J25i4jQxyHTqIhtlE8LYqm/SzUMzV6dbEcTAs6jM7+9oDo1vIXiBkd+Q4IFWSAyadBJK6KCUz6RmnuF/WxJLIg4w1Nm4WUziFl/RTblaOtKR4rw3Mfrd4tuSL0vByTdFWYhyfW1S2LAy/5Za/CNx+8QQsK3txdR9xBAMIngLKw6C2ePGoeAyPtgrsmQ3MhXz9THByPjN0O+gshg9aY2AiZyphUiqRd8fKhQLO69gbalAU2ldkaKjP+j0+PzXHZJ2lf8cuAZrRVtmKCwLVdYlLKh34fDEBKo8/MgKe3SGcq4wP4otFbLb7XL/76LcRFZ7yKJlZSE7L05QPGlDdqWcXq73W27EVVhGYzJAjcq9T5LwtUh1LWWsHuGLCenMP4fsZySUcWdgvbCz8/8ghal+Lby53s4RSXSUHefWxpIlXr6KoHTO7B9tEhZoiRaIY8tir/TraxjE+CB/l8j3ePvnpo5BazdYWibzEITavT5qcdOmi5jfuPf/1/budB3eYL9cvlTFgqGeHujEiDAGp2Tn2x3ts9RlJny/0czTSUj54FgHiGQnoolD3Rw5f64cpuzmSDC9zdHJxGvtCUvJr+XbvVtTq5PzHrK4sDIbfPjLEXu+7/2RuZbxT117eGUx83/jBqBUXgaOl1ZuFB2u7NStmK8/BROApCnMX+5zugKczw3A== 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)(82310400026)(1800799024)(23010399003)(376014)(36860700016)(7416014)(921020)(3023799007)(18002099003)(22082099003)(56012099006)(6133799003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: wh9TZXSbWrVlkdqLtMx6l5uEGtQVhmO3ObKKfha+r0d43TKdb5+0Hp8eWdPz9mNgXvnw3XiIXa2D0NBVWUaSpWp/s4Ly7BEynOL5XcvYr7tA/ZSMTHk/+e+xONdoX5HtqCHlbWRJdYoNV9wHuPcgwCr6IZvmNcKJQuyGu/Z4i+qeA/kF33iJltM9Xf3tBc4NevvTfyVKV16geu+vJe9GH1VoID46zzGXCypu2slVYLu6sPzDKT0ul/ck2i7ozs+xZl1UjBbs1BbNk7KzeujdIkqf4vFOTRmgC+vM+RVlt5BQSaAeqs/KvGEhas68v0o7qVmgEOQHNkQBMxzJIE5U5P8ZaSuA+Ca7ZmC7xV4Hd+6DhTfAXxgkxs6by1rMQEvxELxHLqdH/Qx4p1XYMZFWKvx9JacXytyKpzq1yB+gGAfc9GIsZhPSd05vt8h3285H X-Exchange-RoutingPolicyChecked: SI8QA5EIIqCi7e1kra+pifwVS9moce12vgZYr4Eajbb9zXHHuoRcuQoh8Bo8sVb+O9f6a9IP5jGCfD5EYw9torPJEN6U33wSg8jDsHfyirQDAaxSw3x2PlbEMIstgH+vmVcRBtdeZn08J0s6vTZ/MmGW+up6ruL9UCDSn6OJ8iJOu43V0tKPwjeBdSBq4YxgT92JAsIVtkuAYLXdMwoRQEWJXHV0hNZ2/43qZYplFL80KxyyFnY2TyoxQHEhD6C3Ed2WKCAjUo7eNharA48+VtmDC9gqoy3+Dz0W03z8LqpiRWPB08W8hmb9A8FBVoRFJbzUUl9BnDVAU1wPvmu1lQ== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jun 2026 07:38:45.6244 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9859cc5e-3006-4618-6856-08decd0ca0fa 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: DS1PEPF0001709B.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA3PR10MB8043 X-Authority-Analysis: v=2.4 cv=PtOjqQM3 c=1 sm=1 tr=0 ts=6a33a08c cx=c_pps a=IF27h1RdCV0SK+IF5nJR9Q==:117 a=f+v6EHfkeJbVwR46tk4DMg==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=IkcTkHD0fZMA:10 a=FelO9ux0wxsA:10 a=s63m1ICgrNkA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=taLDd7a_hP9WKsMzeGRc:22 a=sozttTNsAAAA:8 a=TRE1JzdAjLUI3FCtY9sA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 X-Proofpoint-GUID: PO3YYeqhknpwvw_xHaomNPfX5-065xs2 X-Proofpoint-ORIG-GUID: PO3YYeqhknpwvw_xHaomNPfX5-065xs2 X-Proofpoint-Spam-Info: AW1haW4tMjYwNjE4MDA2OSBTYWx0ZWRfXwI/snllxQ8ob SFoM8f5FPGu8twicM38GVoyKDLn19pomnHnPa6X6iROsf7SIa8qIcSzkM7JgDKW8glVkK6YillY vuq64rqb9tjXumluQQgM0nZLcJ/2HAY= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNjE4MDA2OSBTYWx0ZWRfX/o37MzLNeiTh 7bB24PxXov0i1geQKq6wuMtR0f/4aGYov2pzmYl/KWscPKS3w03LLbUGnGmZOxEzApu98WJu42r DrwWy/dP4UQWPM5wExi66E7Zrx20pDponI+gRhJQHO91iIlNNI1Kriq8yNYXmrL4m8L6/fTe0wu s5Aos/OZNW6WDD/+Q1qmGL9B3UH+ANvByuqRxu8Lmbc/ijuCwOsEHoPcb3apgptkrU3GQPWOIul t56IlxMj9QLTkSU8MI+f0TXUViEtRuan8OMGic9njz0GOh/sEMOIA7en/ez3MtQV2cr4u+/Kfhk RoNMEAgnigen775l5zLVGFF+OmTWTEV/9beO89ZFXqCd6IMAhYH6oQd+574qImkdSpQyeDRiDcR 7b84jQtao8F+OmIm6Jw0NduJur9PyGyFi5vYYjt/KdsVxMNbuTyJoemGjLnnqKHXHN3QEiB18tU ObVQaJ15rRdkRsRqyMw== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.125,FMLib:17.12.100.49 definitions=2026-06-17_02,2026-06-17_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 impostorscore=0 priorityscore=1501 bulkscore=0 clxscore=1011 adultscore=0 phishscore=0 lowpriorityscore=0 suspectscore=0 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2606180069 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 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 | 1776 ++++++++++++++++++++++++++++- 1 file changed, 1763 insertions(+), 13 deletions(-) diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-qu= adspi.c index 201d69c64c49..72768292a32b 100644 --- a/drivers/spi/spi-cadence-quadspi.c +++ b/drivers/spi/spi-cadence-quadspi.c @@ -65,15 +65,25 @@ 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; }; =20 static const struct clk_bulk_data cqspi_clks[CLK_QSPI_NUM] =3D { @@ -129,12 +139,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 +161,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 +207,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 +289,27 @@ 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_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 +358,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) @@ -1555,6 +1636,1678 @@ 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, + struct spi_mem_op *write_op) +{ + struct device *dev =3D &f_pdata->cqspi->pdev->dev; + int ret; + + write_op->data.nbytes =3D sizeof(phy_tuning_pattern); + write_op->data.buf.out =3D phy_tuning_pattern; + + ret =3D spi_mem_exec_op(mem, write_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_get_phy_pattern_offset(struct device *dev, u32 *offset) +{ + struct device_node *np, *flash_np =3D NULL, *part_np; + const __be32 *reg; + int len; + + if (!dev || !dev->of_node) + return -EINVAL; + + for_each_child_of_node(dev->of_node, np) { + if (of_node_name_prefix(np, "flash")) { + flash_np =3D np; + break; + } + } + + if (!flash_np) + return -ENODEV; + + part_np =3D of_parse_phandle(flash_np, "spi-phy-pattern-partition", 0); + of_node_put(flash_np); + if (!part_np) + return -ENODEV; + + reg =3D of_get_property(part_np, "reg", &len); + if (reg && len >=3D sizeof(__be32)) { + *offset =3D be32_to_cpu(reg[0]); + of_node_put(part_np); + return 0; + } + + of_node_put(part_np); + return -ENOENT; +} + +static int cqspi_phy_check_pattern(struct cqspi_flash_pdata *f_pdata, + struct spi_mem *mem) +{ + 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 spi_mem_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_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); + 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; + u8 dummy; + + reg =3D readl(reg_base + CQSPI_REG_READCAPTURE); + 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); + + 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); + dummy =3D FIELD_GET(CQSPI_REG_RD_INSTR_DUMMY_MASK + << CQSPI_REG_RD_INSTR_DUMMY_LSB, + reg); + 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); +} + +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_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_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.read_delay =3D 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 16; + searchpoint.rx -=3D (16 * (topright.rx - bottomleft.rx)) / + (topright.tx - bottomleft.tx); + } else { + /* Bottomleft further: Use Region 1, 16 taps inward */ + searchpoint =3D bottomleft; + searchpoint.tx +=3D 16; + searchpoint.rx +=3D (16 * (topright.rx - bottomleft.rx)) / + (topright.tx - bottomleft.tx); + } + } + + /* 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); + + /* 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; + u32 phy_offset =3D 0; + int ret; + + f_pdata =3D &cqspi->f_pdata[spi_get_chipselect(mem->spi, 0)]; + + /* + * spi-max-post-config-frequency 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 { + ret =3D cqspi_get_phy_pattern_offset(dev, &phy_offset); + if (ret) { + dev_warn(dev, + "pattern partition not found: %d, skipping tuning\n", + ret); + goto out; + } + + read_op->addr.val =3D phy_offset; + } + + /* + * Verify the calibration pattern exists using the conservative base + * speed. At high clock rates the DLL is not yet trained, so DTR + * data capture is unreliable and the read would return garbage. + * Setting max_freq to 0 causes spi_mem_adjust_op_freq() to cap the + * read to max_speed_hz (the base rate), well within reliable DTR + * margins. max_freq is set to post_config_max_speed_hz below after + * the pattern is confirmed, so the tuning-loop reads run at full rate. + */ + f_pdata->phy_read_op =3D *read_op; + f_pdata->phy_read_op.max_freq =3D 0; + + ret =3D cqspi_phy_check_pattern(f_pdata, mem); + if (ret) { + dev_err(dev, "pattern not found: %d, skipping tuning\n", ret); + goto out; + } + + /* + * Pattern confirmed. Set phy_read_op.max_freq to + * post_config_max_speed_hz so that tuning-loop reads bypass the base + * frequency cap in spi_mem_adjust_op_freq() and run at the full + * calibration rate. + */ + 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: + /* + * On success, write back the validated maximum speed into the caller's + * op templates so that those specific ops bypass the cap in subsequent + * exec_op calls. + */ + 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; + } + + 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->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) @@ -1584,11 +3337,6 @@ 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; - } - return 0; } =20 @@ -1736,6 +3484,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 { @@ -2104,6 +3853,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 Sun Jun 21 23:24: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 4B383361DBC; Thu, 18 Jun 2026 07:38:56 +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=1781768337; cv=fail; b=FZpCoLYrkXiThpg3qtyYjR7QTzfZ+3UpVUUOcxSAn5x9VLefMOtrOCArfkpessaAyqyNTdQ/ubnLuCNV2Eap4d0BohPDHFMs4Fc7NZ5LsO4Blwst3RTy5maNAWIFAV/j/DvytEJQ5k/FCPNhqvUqcQV/uzqQWyokOg//ST9biZQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781768337; c=relaxed/simple; bh=xaFT7Z+NeN8X4WH7wDqidU8PiR/6ae0dv46GxhlKZ0M=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=C1tp50wTTPMV8T5guNwyQg/vaRQVuaW5CsgPD3Ah3Meybc7ZPqBtykitXBq0tmu4nQPJH4Zkar4zTFJy4+roW9V4WVUwD3jAzlzOypaBX6cT4hIX1uKxA8DGXUk2ABzFGqt1+AowyI6gxfpipWkEi7axtqM9iiW7kragfRNuM7U= 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=dUKprBIA; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=syia+itZ; 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="dUKprBIA"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="syia+itZ" 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 65I6IjPv1333613; Thu, 18 Jun 2026 02:38:46 -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=mscrmtCJhQFK22ELCgCkzBfMR9vXw5IX+aotF08Dt Ek=; b=dUKprBIAjKQf629P5VbkzqrGE7VZiPQYkg4Osu/ncg46KDvqg5r1Nl+/5 +L9s2h8heyExCAPRS6CAsc/uBUFz8AzsuOW15EJV+dntLjxOhl6u03W3oY9ph/zm c8ta2UiO+DgxadTFRZ6MAhnsvrnQSq+NtN0wrUaZDjBqCWzTHmlDZN5mP3WySwJW JHD49VXMCjsl+5CZ12mps0zUNpahB9tHGvX3qqjuXfJDV577+AwPsHq1q0+AkbGs C93RPiCyGkOciZ7pQNG+GRmhvaX47amkQCdiKcLz6ubKbRx/v/0IDAQOO28vu6Xb RxL+N4XC56NSiZYJUCDGaVtsm1mzg== Received: from dm1pr04cu001.outbound.protection.outlook.com (mail-centralusazon11010062.outbound.protection.outlook.com [52.101.61.62]) by m0384305.ppops.net (PPS) with ESMTPS id 4eutvept5r-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 18 Jun 2026 02:38:46 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Y5JsX9NwFSRKM1W2vHnxgQ32YWdnYvrBXdaswgoePLaFxmuEnxKS5PATSmrMPA1SISlTmEn0SJrCcvIFpcrwPeC/7Va08iTwDt/w8ijeWHGyC34hnyw6PsKP24YdeY3GV1SP3WzoE0a218bB9ISaa6qZ/un9mfmh8qP1fNecMU5gmHj4KUH/xO0y4pdI99BEyaevdrRFlSbPR9575VMSDXOFlwOYCddbzxtj4F3WSwc7idmyZXfkoGwWT3oRtvdkzLMpY+JLueLf0VmvBev8KKjbu9Qw+x/qNrHpjuBG1/bfnhLI5qih4vuo1cj38yQv11okcX/x/T6z+hkO9UzBhw== 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=mscrmtCJhQFK22ELCgCkzBfMR9vXw5IX+aotF08DtEk=; b=fL/EpW40qKRT6+aLW8hcbMxbibE06wlrYIlHdu7is+Dsrb3qcuo1YB6hSUrr2ZUxmQKMWHIXj7EQpkL3LHkP/AvTJQdnTEIlYvwgi/pOc3Cj5Zbj0cZdVo4sD5vXnwaa7OASCZFSwuwZ55agbS+s4kSYCzkTGFznuDRZZC9taFTvccjx15tzr37yNWAjEBZS8xW9DCAukJRKFavDlIChOLwMJHYSkc8AgeBxzMLrI0W6n+gQT7ZMcNaCmSWvP57wuUHvJcbOBSKIK6aq6g2QnneCrUPwP7H/LqV+P+SSrz7xvy13awmU5hkrL1KiyZXCCia6tXauc0pdwDW7/LJotQ== 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=mscrmtCJhQFK22ELCgCkzBfMR9vXw5IX+aotF08DtEk=; b=syia+itZXMRrV5nARFceknLDtRjCfRcJpIHpAAp6GFOdWzpnRoL15RbvBMkrcJzF+vcvwhLkYHiWdISk8607G7RAb/sCq0B6y9qGNtOMdczaPtu91vUXJY6GoCLAbuPvqcOEwB6A8CRQaA1JZNtl/rv0Y/dV8I3nYZ0lrLbRzys= Received: from BN9PR03CA0959.namprd03.prod.outlook.com (2603:10b6:408:108::34) by SAWPR10MB997878.namprd10.prod.outlook.com (2603:10b6:806:54d::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.113.18; Thu, 18 Jun 2026 07:38:43 +0000 Received: from BN1PEPF00005FFF.namprd05.prod.outlook.com (2603:10b6:408:108:cafe::23) by BN9PR03CA0959.outlook.office365.com (2603:10b6:408:108::34) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.92.10 via Frontend Transport; Thu, 18 Jun 2026 07:38:43 +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 BN1PEPF00005FFF.mail.protection.outlook.com (10.167.243.231) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.139.8 via Frontend Transport; Thu, 18 Jun 2026 07:38:43 +0000 Received: from DLEE203.ent.ti.com (157.170.170.78) 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; Thu, 18 Jun 2026 02:38:41 -0500 Received: from DLEE205.ent.ti.com (157.170.170.85) 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; Thu, 18 Jun 2026 02:38:41 -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; Thu, 18 Jun 2026 02:38:41 -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 65I7bYvk3521710; Thu, 18 Jun 2026 02:38:21 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , Subject: [PATCH v4 09/16] spi: cadence-quadspi: skip DDR PHY tuning for 2-byte-address ops (i2383) Date: Thu, 18 Jun 2026 13:07:18 +0530 Message-ID: <20260618073725.84733-10-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260618073725.84733-1-s-k6@ti.com> References: <20260618073725.84733-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: BN1PEPF00005FFF:EE_|SAWPR10MB997878:EE_ X-MS-Office365-Filtering-Correlation-Id: e18ef744-6cbf-495c-a33b-08decd0c9fb9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700016|23010399003|376014|7416014|1800799024|921020|56012099006|6133799003|22082099003|18002099003|13003099007; X-Microsoft-Antispam-Message-Info: bkdC+6ZFAeD8E2Ddmwcvn17dwQOr30yvydZQAEOhIApbR9FoBcvj4A3v/6u27zNQ6S4S3NOUUe22ljDC4KfhbPPTZaZVsyhWOB+ARX0/SoQSKezAtyU5vwz1TMnqE86htmFdeOjJ/N3nf1gFllOK3T09VxzL2KZwKk85duchTvawQWtkfsrLewxJeuWZ0gt+OHEYr7FdDhpfrkAkreIcA5X9QbrTPVPMjmoRF9qkeN5dMXf2w0XV3wuGU4Bgfh/LTPy9aewzqvsAnsX6x/DwprD9Ghh9woTqHi8T6T6ziszsv+J38PyYtoKVv8GnI9RER8YJWsPu2Pv/3V2YFIUTHkbK0puPCBvp3AMLpUDRQ7elWQkoE+WWidN96Hm46GqmP8jhkZLnU3YiQOhjoXmSxPzXUuYWkwtSo5xwPL7t5G1/8MRiMtRTUcIB/iIeW7qsmk75mn+BLJOBZ+19USakYsEeqZV15g5J+1rB/3i7B4ZhIgXZ5Ar3XY46kmkqYDF6Alx1vZQi0w40mk2R1//531oNG+KsHOJuWu323iflr1GQLRflXS2Np7ZEciq8h/gQKshtsYKifCvRYcOLIO8vMMFhWAEy7htzOkB+TSfZu9ybdnGs2aJV7TFiu8bQLGpiMlfr+0dWa/eKqat8MZxtWJ2GwWUzVh5H8UdpjU4y1+7SkNFNvoux3XImTQl+DgXFSXROGNtUFkwTDqI5mZ7f6UGxQU+XrW4SW7zxOajGshs= 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)(36860700016)(23010399003)(376014)(7416014)(1800799024)(921020)(56012099006)(6133799003)(22082099003)(18002099003)(13003099007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: AoNQdM623tSsf0/cKl3FubETfPcxelP/nvAdpy6l4qm3widx3T1td0tG9RuewZxhXcbuLeFe9gWHXGVhcMagjHgw9OVUa4HJdUFRWlBtpG2fZuTBc75pMKcyECXQfxvKQcMSX9meu0C51wxZi6O5+G8LO/bLZBZR2qCW4/itoafK79mnUa/TU77j7fvN96nzo/8ze39a/jbQ51cSVdqWkNzpI18SQOjw74/ggrMOnf1tbPGeo6ht0+1XRM8RpL4o/pZ6KnaKf1PPbb3vPUirTFDIefCMDiSQhOi9zbLWo1pwK8XmsmqVwgKL6bmSC40tWqzYypxVFBTpVqmnkT/gP5+RlmMdL41/JjCIUmtEEKRec3Dg1GtwketB10Rvn+1w1c6BAvjWqw6TDiio20qqm4Jyf+UL+vvbfUbwl+FDq5hyvWeOUXJVTf4rIHR6FiMZ X-Exchange-RoutingPolicyChecked: D/LorTkETx/BY5zUY+hOzHpGani736bf1f4rtZxne1hKKc3CWAftInMp+zBa6kAYn6ukOP+8RzFi9F9nu/uKLv1c36GYKga7NapKEmpo/nvZFi7sAenXPiXEH1wFrrRKUa46j0RZYeKrtFr9Ym1zMPlO9+D1VY4mbBZIsPloMzy7DGNHPhFm3OAIdlq7gA0pSeIYp4p6WvBGmOjxcp7V86nR9aaoCpS06Jgtoid/8/Tcb3tiFzK6gQHovXOomUVDBtUiRO6mZjXUZ/3aO5aYP2otiGiZm9zrecm5F8lZBKOJIwrktPpIue5kft4F7GjUkUgT1J5v3vEs2iJRgQdIng== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jun 2026 07:38:43.4984 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e18ef744-6cbf-495c-a33b-08decd0c9fb9 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: BN1PEPF00005FFF.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SAWPR10MB997878 X-Authority-Analysis: v=2.4 cv=PtOjqQM3 c=1 sm=1 tr=0 ts=6a33a086 cx=c_pps a=rA8xTxhMCG4Q6PG1LLvkJA==:117 a=WotqVVQAdb04rnGuttW3Kw==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=FelO9ux0wxsA:10 a=s63m1ICgrNkA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=taLDd7a_hP9WKsMzeGRc:22 a=sozttTNsAAAA:8 a=ozk51zWbLLA4aPkmxGIA:9 X-Proofpoint-GUID: X_GRh59PWAa_a2KU_4h1QrmIe98llyDm X-Proofpoint-ORIG-GUID: X_GRh59PWAa_a2KU_4h1QrmIe98llyDm X-Proofpoint-Spam-Info: AW1haW4tMjYwNjE4MDA2OSBTYWx0ZWRfX2qxocoBwuUYM dNpSDr9lht5Hjg51PS4DQtJOl/exVaPd7S3Cr+0eCzLWCtl9DOK80QYYfMHY5gfMjp5ZMbj2als IrxUtmotVECfx8G5RstJpzMvXkaEyqg= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNjE4MDA2OSBTYWx0ZWRfX8gdpyIIU/e9J KLwgxLkG/fhmHW2Me0f+OkUHxEwl/IjTt9SHSBaCtv7ldTKLZfhwA82fWZ8362msU+XPdSXOuCs 6oVlCydTxK1UR3uXPboOOR5JjLLHz85wEciV7NojUqaDexILF5B3D6qwxnsYCuwbsXaA1sk+BUy DZ5NPo1ujXJ2FoqnEvkyT4+08gKKD4k4JbFwMmk936RQl5eV8W5OqM9AzGlVYlYoIiV75IgWYx+ zmWDl0mAsrm1oOJ+bc5PqskjaCqqokZctoS2QEsrbEGgVNh7+dmptcMtPiLBv4YPjptsgiB36lt tNZc/3taVbfUZOzZtXbdcxle+24xF8E1e3JMs5EyguS9EPKlwfLBGYvbDnngXUWYaAwGN7IepET GkeDP8xjnEDp1d275AeVtFOL8xheOCYSnpuCdiJy6eCD/71fDxE4I6yxiqy4C697QxSDotAdneO Wqxae0+t05lTdIiyhIg== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.125,FMLib:17.12.100.49 definitions=2026-06-17_02,2026-06-17_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 impostorscore=0 priorityscore=1501 bulkscore=0 clxscore=1015 adultscore=0 phishscore=0 lowpriorityscore=0 suspectscore=0 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2606180069 Content-Type: text/plain; charset="utf-8" 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_2BYTE_ADDR_PHY_DDR quirk and check it in cqspi_am654_ospi_execute_tuning(). When the erratum applies, return 0 with read_op->max_freq cleared. [0] https://www.ti.com/lit/er/sprz544c/sprz544c.pdf Signed-off-by: Santhosh Kumar K --- drivers/spi/spi-cadence-quadspi.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-qu= adspi.c index 72768292a32b..22df5f3bdb96 100644 --- a/drivers/spi/spi-cadence-quadspi.c +++ b/drivers/spi/spi-cadence-quadspi.c @@ -49,6 +49,7 @@ static_assert(CQSPI_MAX_CHIPSELECT <=3D SPI_DEVICE_CS_CNT= _MAX); #define CQSPI_DISABLE_RUNTIME_PM BIT(10) #define CQSPI_NO_INDIRECT_MODE BIT(11) #define CQSPI_HAS_WR_PROTECT BIT(12) +#define CQSPI_NO_2BYTE_ADDR_PHY_DDR 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_2BYTE_ADDR_PHY_DDR) && + 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. @@ -3852,7 +3867,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_2BYTE_ADDR_PHY_DDR, .execute_tuning =3D cqspi_am654_ospi_execute_tuning, }; =20 --=20 2.34.1 From nobody Sun Jun 21 23:24: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 83D023D45CB; Thu, 18 Jun 2026 07:39:15 +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=1781768357; cv=fail; b=IVrFC7zlMpSqKalUauylhq4nEAjlLLNIxrZE4E+2aHQlVPPhqdxtNNExi2sFN8gjkbglQPhZm75mwj690PTvYH2dsUIk4uduG7OVfpgmKo7cXO97QZ0GZrewRlWK8lJvjrkidsMtxKzCRF/uZ4BKhbQ/J09Opk8duqHYHQzcWmk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781768357; c=relaxed/simple; bh=zsLp+yCjAKKcuE3SeIa0g8jRo3bb5PldJK6axaGlK0s=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=klzqeA9ozmc0OnXSNf3j6JfUt4httDDU3KyMRAEvyETcWsoOC/IdV9s6jXFZSonzjKeJKhxAnxaQIkzTNjj+7WbAha8opLvtHptlxf6EIWbdUooczJ34XqH/hOvEimeGZuyyNVR2ShCyrpR1DqUsZDl4fPUeYRFgtd+qfVFz9a4= 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=CmI65Txv; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=lo/4NUem; 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="CmI65Txv"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="lo/4NUem" 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 65I5vmK33435965; Thu, 18 Jun 2026 02:39:06 -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=75dngkiC36yZ4kKyz8DjvnZmAhZhVWeKW1KhPKh+K fI=; b=CmI65TxvIjgnV5bCfZERtohnUhm2EI2lE/1FQb2rEqBA6B7bRVDNvNoGq 70024kinxpMU5KUw7zonp7qq8bGcDdbDHKQI3zOYQ8DSq7vf16QQ6Z7rAycuOPOn f31XMPNHjdWJ06CFdFtKCAE1/Icqp6o+E1/vzMDM2WiLddNqfL+xnZoUc8vHJ0XA wj6N8K4ht/fDUGfnA6Rn0cEqPRKd4H1sh4fJNrIFXAtrBlRwLjV0Ncl60Ii/P1nn LOMAWvwHsjcbJSml0tdOVnTCZR85UY5/Q+pSt4LxT4PMaIl3tlrtfBaQa47tds68 XQLOnCxo8oROCf8cwlCAR06jUBv6A== Received: from bn1pr04cu002.outbound.protection.outlook.com (mail-eastus2azon11010053.outbound.protection.outlook.com [52.101.56.53]) by mx0b-0002e601.pphosted.com (PPS) with ESMTPS id 4ev63rj158-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 18 Jun 2026 02:39:05 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=s9X2djA0eRDU3TvcE9r2iV5A44oJP16XMBKJ0xH2UQhFH/3LoE7vnu341rIX1kzxMAf13tw25S6vekqegtEtfxZwSsRiIhYarwlOWlN+liUg8xrTZruu4xOy9/8616r6KaCymle+gqYFyhRPoAPsTt3cLW7tZp78g84LaLRjXoxHzhL04o4rJ4qlVpvb4U+fxB+zI8nZy/uY5pDPINcbiq+YJHDum8e1VC2tzEfOvxUhqtgKra6wS6Eiou5SkLzhxmX6WhOrUU29bKox8ay/ltHNWOv4G6qtoYHhh0oolgpKgP5Hi5Ua7FxcnTpvaSYicaR4sZxk8xT4hEbf+PzF6w== 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=75dngkiC36yZ4kKyz8DjvnZmAhZhVWeKW1KhPKh+KfI=; b=w9xVz/4cT38rXHBSTZ5N8KlBJz/lx1eQ8weBlTyxxvuNw1Lf5hnQPFSTWc0CMFHJ9EYue46xTAnWl1fF4dQSWYJ0ItDcq77lGcpvcsvTt4cKc6SrXCFbTJtXhgFYEjiBXS82xz9VOSwAayE+bSmtaCRy5pHnax2qRGPYbGpod7wVUKl8JnnUKY0sqZVUyfmZ/clzMcQJ9Y3RzdQypo57v1Xg6xw96+vUp8UtuUc0CP0cgXabjmqBp0lr0KP6vrasSWNXnWTrOkO1xRCtq5bKCdEfJBXjJzQ43QQgcC3Xo5avz8aWpsv3hFMQg4S7jIE6lexrLrblOB6htF5cmYtUpg== 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=75dngkiC36yZ4kKyz8DjvnZmAhZhVWeKW1KhPKh+KfI=; b=lo/4NUem434jPE99c7HPXSTDymBTnSQ+lLwnaA1tBlKS2u49MMp0mlaSx34+3mNt1gvUmkWrfpcUYRmfNTYTx1GeEYTyy/eZ2082wA5VV4tgAxmNbkaViIT2iD6jrXj4jr0oNE8jc5IBs1aNVFMIwrbRj84nH5BFyuzkGnUpNR0= Received: from SA9PR13CA0078.namprd13.prod.outlook.com (2603:10b6:806:23::23) by IA0PR10MB7181.namprd10.prod.outlook.com (2603:10b6:208:400::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.113.18; Thu, 18 Jun 2026 07:39:00 +0000 Received: from SA2PEPF00003AE4.namprd02.prod.outlook.com (2603:10b6:806:23:cafe::36) by SA9PR13CA0078.outlook.office365.com (2603:10b6:806:23::23) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.139.13 via Frontend Transport; Thu, 18 Jun 2026 07:38:59 +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 SA2PEPF00003AE4.mail.protection.outlook.com (10.167.248.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.139.8 via Frontend Transport; Thu, 18 Jun 2026 07:38:58 +0000 Received: from DFLE213.ent.ti.com (10.64.6.71) 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.37; Thu, 18 Jun 2026 02:38:46 -0500 Received: from DFLE205.ent.ti.com (10.64.6.63) 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; Thu, 18 Jun 2026 02:38:46 -0500 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) by DFLE205.ent.ti.com (10.64.6.63) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Thu, 18 Jun 2026 02:38:46 -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 65I7bYvl3521710; Thu, 18 Jun 2026 02:38:26 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , Subject: [PATCH v4 10/16] spi: cadence-quadspi: refactor direct read path for PHY support Date: Thu, 18 Jun 2026 13:07:19 +0530 Message-ID: <20260618073725.84733-11-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260618073725.84733-1-s-k6@ti.com> References: <20260618073725.84733-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: SA2PEPF00003AE4:EE_|IA0PR10MB7181:EE_ X-MS-Office365-Filtering-Correlation-Id: d10fc8f6-0c9c-4565-1e19-08decd0ca8c7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|7416014|36860700016|376014|23010399003|1800799024|921020|56012099006|6133799003|3023799007|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: t6J04jAw/v+0jmvX5ker1lfPpfe+Kg+BOXCFL+cJIsdQuYKTGfCHBh3F065T/PRrGeiC1bG0wCtFoizGA3PKWGHos0CXKBT5HYcFWrHQdGlHSk4yQRF9Og3dAcDo2cs/ZFDN383TpVTtSwDTdMBtKR6IDiSN/o+/yr/03Zu7w66RLYAXuCNgelFSWHEADfs/5gwXVEgqjXWCTwXM+0Uxe84lQmUB/aZWjt3pDXVEir4gn0oAcwS9MMNsOswopBahiuDKqU4Qk/o6TALfNObqku/3oLvgiOuFezqfjefHpsv6IuIefz4jB5h90zecjjqTurmaYDeYS3RkFwGzl0E6pmN9qfsT3SYLlbZKi9Al3IhbA2MslD2pXGz5LDjPcN/CEVA6tXRi8prT4FMQgqILn5HoyTPZgIyo8gVfHPXccPOyg7i6d5PBosokVYCSh9BaCztUbjaBxeNFLCJHC+lKL0TttmIFvB+lgz1x9XL6/gmp/QkN4GE7jGp8DFBZgQW4PO7xTKZSm2Ckwnj9a5YB6uXFpCtT2DdfYQEXHaEv7UF5bG2FZP0pvSh2M7eLfhelKncCCixCDMyhcYwwC6ERYsJ9ZFPwUvSwJ7ipRVzjI0ABruAhVxqSB5mi2SUC0M8ZALjEPg9IGSgETuHgqd94g5eBxWQtQdpH14FSRKIrXrgxjiM5Cf7vIe9xlpT5FaAcnl6HGCbuAHz3tBg/xjj14RfRFdB93sqtzMsLgXk7XLlgjhsl7SSJytLs6Xmmzt2GtsHjKI9pDbomT7r3+mtlbw== 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)(82310400026)(7416014)(36860700016)(376014)(23010399003)(1800799024)(921020)(56012099006)(6133799003)(3023799007)(18002099003)(22082099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: RcxyzWMROlDtcjPNhINn8SiMxUWV2hGGkxQHJTKp/xaS8ShIsc7LNMd30RSrl4pJ7awLCLyEfBqNVI6lcsKUDgjclEsgfG6EW57oCVSCI7i/Ze4vsZya6Cmcz4wJBVjN2wdE8VlqUHQIknlngVz2bpbj5KgtDk/bzORE03J3kWdcf2zYzV1T6iAQK9vNcVSVGlKBPrci0OvesTuPATF2lZ1fXNsJkLxMn55Zg3GMVip5KmmMxOK9+e/hGKWQx53S9wZwACLZNXIX9gxSSm91c/ru550/J2TFaxtcMBJMZ3yseXCf8FNDj6T6OaT1Z8v82wlJhTAYasDhHaufqog2EsnzT4ynw78LMZOql/tszKD0md6l4yQDOW5LW/jHvUGGbzAAXUahNHQtDY1VuvbQBhGaDkglFz1j/Qg9tkFeS59Y3Q800X9XPy1lo1wDPsAC X-Exchange-RoutingPolicyChecked: Vn4Kjsn+8136IseOypdU00dZWtRSZPOEXdJOQAja43FajGnVvrnX91e7jJbH2uxmL1yIdTpqUULc5KptHLAAi13jit5HEFo8RKrh6zhJDdkBKuMPpQVAkyQRbbSOGGOyQQDPNOODBQN5yxyn3Z5NGB3J1RFZsLM2SudXt+I58B0Kj0X7LucH2F1TaTY2SUGLWnUrzx8RhrmFhvJfuV+8vKkh6Ec0F59SzwVSllwtx/WGot9JZJ1sfaw0kVk3GTgTMPRLsBFE4xEwibSrB5tqnK8N8PF4u8SkbKDZL0jFNUCnyRt73T7HOn9JLqzF98eylXdSi/KvJTyZ3r5QR+Slzg== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jun 2026 07:38:58.7291 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d10fc8f6-0c9c-4565-1e19-08decd0ca8c7 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: SA2PEPF00003AE4.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR10MB7181 X-Authority-Analysis: v=2.4 cv=LpqiDHdc c=1 sm=1 tr=0 ts=6a33a09a cx=c_pps a=PQms4psfS+nBHIg3Mxsk7g==:117 a=tJyPKKxUohctrY4NYmUjkA==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=FelO9ux0wxsA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=fPAWb5peG099m5CrUpKH:22 a=sozttTNsAAAA:8 a=kQoCic6YF6TU8Y4tUr0A:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNjE4MDA2OSBTYWx0ZWRfX2Pw45N462oFI 3tF6ykvSgnh2F2tA1EewRiz9KtsihYD0b1GcvmWyOQh1+pF36MBcdVZ91WBIuXCcODCxhXLq1fv 78AxWH3ts4QntTSVQqcFzJRai3NZrXOp1dOaKH91koFaba7KAoBn+96c1pazOTNFFuskHgAczTL j/504XEsQB4MxaqYok2sFbJ/FYZewGdXD+0EJYcAM4ox+GTA148wd5IUftvzzxys+C4DY6QcyIG qy6n4+73BVcWvijyqqrC2cM4Mv88N+pDZN5PXXflJgQt9GqJIw9JFnY9ZqVp9GGWK9yVyaUSNU0 j8CQZLTFbOTqEvRjG2MDgwBN/1s5SlZv/V61ji2D6pJfDRsm//4+DBBjyTsK1eKCEfMvJmSMdRy awy34oqTQDMmqf8aER+yU2uavSDqlFxaj2FYsBsNKIFHsjMppGsWf2X2v3vAP07tQmHUB7bRqX/ d9ov+weFjVRi1Wp7dDA== X-Proofpoint-Spam-Info: AW1haW4tMjYwNjE4MDA2OSBTYWx0ZWRfXzuG2wwEzIrK6 ySiHBpSXz8KO7ZXrbMbs/JLBwM25hQO1AOKfY0aUdew4m+CVZEBu6XpxEMpr3LHaNVBd18EvHf6 ic7s5H3as3p7XZSeu6icS5lXCpL/Nn4= X-Proofpoint-GUID: ZNoL5rVrE4bhCxdCB-R2v_i3UpVjoh2O X-Proofpoint-ORIG-GUID: ZNoL5rVrE4bhCxdCB-R2v_i3UpVjoh2O X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.125,FMLib:17.12.100.49 definitions=2026-06-17_02,2026-06-17_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 suspectscore=0 malwarescore=0 impostorscore=0 spamscore=0 lowpriorityscore=0 priorityscore=1501 phishscore=0 adultscore=0 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2606180069 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, with 2-byte-aligned I/O accesses for 8D-8D-8D mode. Change cqspi_direct_read_execute() to take the full spi_mem_op and max_speed_hz instead of separate buf/from/len parameters, matching the interface needed by the PHY-aware version in the following patch. Thread 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 | 72 ++++++++++++++++++++++++++----- 1 file changed, 62 insertions(+), 10 deletions(-) diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-qu= adspi.c index 22df5f3bdb96..e41aeca47885 100644 --- a/drivers/spi/spi-cadence-quadspi.c +++ b/drivers/spi/spi-cadence-quadspi.c @@ -149,6 +149,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 @@ -1447,8 +1449,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; @@ -1460,11 +1462,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)) { @@ -1506,8 +1503,61 @@ 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)) { + *(u16 *)to =3D __raw_readw(from); + from +=3D 2; + to +=3D 2; + count -=3D 2; + } + + /* Use 4-byte reads for aligned bulk (no readq for 32-bit) */ + if (count >=3D 4) { + size_t len =3D round_down(count, 4); + + memcpy_fromio(to, from, len); + from +=3D len; + to +=3D len; + count -=3D len; + } + + /* Handle remaining 2 bytes */ + if (count) + *(u16 *)to =3D __raw_readw(from); + + 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; @@ -1523,7 +1573,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)) @@ -1551,7 +1602,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 Sun Jun 21 23:24: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 636171A9FBC; Thu, 18 Jun 2026 07:38:51 +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=1781768332; cv=fail; b=i64cjip6uNaCvelemm7ChzUX9ZRSzKZyV3Vx5dQ77UPUk/VTWePlcEGQPGKWzD1M3HMcNaPvDoUEyvQPOWfL/0F+hy7ao4fgKvToshzxAp922lYlCZmr8NqJB5PQZpw1trfrgRm8YuN3ibOxpUEfF1Ao1/WR6NHzRmBrxYT+ZpU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781768332; c=relaxed/simple; bh=ApRKDGZgT3ZmWL1jBrsrFpKTcyJA1rVtOslVwz1c4MU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=PNYjjovt6n8eG/3//+IJ8grFpIJLCSJjShgPxgb1nfEFnBnkf3FjalLIea6xiuVg8fS0HrxoQkrAGZgBheTC/BGBreA3INO7huyA9/3rVu6tkbnCDFFXbvJ4wOBgTp6B5hf1DatGUupQ49JxYi1bLd8KA57Sr/8pO6G8cNNkqX4= 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=JdW+h2am; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=j1d+t7KX; 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="JdW+h2am"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="j1d+t7KX" 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 65I3ndbL3790559; Thu, 18 Jun 2026 02:38:41 -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=Sk4XXVlQqbE0LCfZCUDloawVlmQZjdCxXegzpG/6h bQ=; b=JdW+h2am5R8aHVjR+v2viw6PsjeylwmBkekb9/0erJWCQYQ2iPrvbgcHq aeUCX9XstrAQKm660vh9CyRPIKJ8a9Xd7p4HkpHEwtCIgalqQB4F8SSiZ49EhnV3 rGBSwIIywdTIwBFuSyh4gdUUn8JeP9ga2VthrSnWnF+57iSHEKXd1OLjpy+lIdKH 95gbx73R9Mz3ZDBzbQKud41TS76VtJre5QWXNcykRir9xDSrdpJPfkC146nYi5hD r79OpX3NLzpDlyJWZtXdK7kxcBAsQuIYgK4HGkTZgR0GfITWEkfXkEqoS9CwQkiu GgM2FUlKOKPjeiGEPtMZCF+X1Awag== Received: from sj2pr03cu001.outbound.protection.outlook.com (mail-westusazon11012053.outbound.protection.outlook.com [52.101.43.53]) by mx0b-0002e601.pphosted.com (PPS) with ESMTPS id 4ev9449354-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 18 Jun 2026 02:38:41 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=h+24+q5CPVPLoiCf/q7VX7IWHkKD+3Pz8fjXFfGGSSQEuJcigugJh6XmHJm7YWBbzTUoMkVlh8Ne7/qBy3lo2CbY5CoAjX4U2Zj9NYuRCX05drQ6udsx5lIxkAun48Qxwgc9fMcNUWdMg7LZDIST4rEfsNRQuPF6kJ0Y/NcXlLDemdLCqbdc4HJ7vUDALvrJCS7xVpxej7v3zOLJQ1bkVnsGjQQBHJS/qDldRKbtJq05qU6f9WPT141V7aK2lMFwgW52NA8ZtW/BoIkLDIh874GLiUuqTnCkZPc+sVhTmonJ5xRQrS2lpHbSiaA/xxsHYt7lIuX9YpvnbxxhCk1Mzg== 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=Sk4XXVlQqbE0LCfZCUDloawVlmQZjdCxXegzpG/6hbQ=; b=XVcD5dDb8EOieuvX18ohG+2YAk7kPioPLcQ+PUXqhU+MdjFbykhUoNtUB+UyzdQy9LOn83ri5/KKNy8WjD40RsTwc1imZgBP2uKtjaUfg7abN7hVW8eyUZahMkU3GXJ03cvZXZWq+sgsk4OqK2OiMrOsDSdCy2EEOgKDXtLQ6nm7mpFH0ITr7VJog8EESkx8LKtJOWOHjxEKebbGcPj4GxzBj+xU4WnYZbbqEh43Xm4bj5HrXj+tdmh/MBlJa8O2lanDNmkBPDCNxOMV5liZJPqUS1IN4lZiT5QAZuIxn2ypzKDZVm2ojTS5W3x54Bv4R9vp763ssD5TZjt2okH6bg== 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=Sk4XXVlQqbE0LCfZCUDloawVlmQZjdCxXegzpG/6hbQ=; b=j1d+t7KX4M1Se9iRrmpru2OLbYNs/NnJToGIkuOSAvO669LyhvBqWLPkiZQmRYzbCsAyOJVWBNPfqfQAdL3GvOk6dJ7X2Lx5h9RDcPL9S5zqNpgKhz0WAXBq4cb2IrhT6Ng/ks4KIav9i8WAn+nQEokiC57PZEo8WTELidECZNA= Received: from BN9PR03CA0875.namprd03.prod.outlook.com (2603:10b6:408:13c::10) by CH3PR10MB7610.namprd10.prod.outlook.com (2603:10b6:610:171::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.139.11; Thu, 18 Jun 2026 07:38:37 +0000 Received: from BN1PEPF00006002.namprd05.prod.outlook.com (2603:10b6:408:13c:cafe::9f) by BN9PR03CA0875.outlook.office365.com (2603:10b6:408:13c::10) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.139.12 via Frontend Transport; Thu, 18 Jun 2026 07:38:37 +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 BN1PEPF00006002.mail.protection.outlook.com (10.167.243.234) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.139.8 via Frontend Transport; Thu, 18 Jun 2026 07:38:37 +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; Thu, 18 Jun 2026 02:38:36 -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; Thu, 18 Jun 2026 02:38:36 -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; Thu, 18 Jun 2026 02:38:36 -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 65I7bYvm3521710; Thu, 18 Jun 2026 02:38:32 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , Subject: [PATCH v4 11/16] spi: cadence-quadspi: enable PHY for direct reads Date: Thu, 18 Jun 2026 13:07:20 +0530 Message-ID: <20260618073725.84733-12-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260618073725.84733-1-s-k6@ti.com> References: <20260618073725.84733-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: BN1PEPF00006002:EE_|CH3PR10MB7610:EE_ X-MS-Office365-Filtering-Correlation-Id: 9268a2cd-5092-4d1a-83a0-08decd0c9c14 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|23010399003|376014|7416014|36860700016|6133799003|56012099006|18002099003|22082099003|921020; X-Microsoft-Antispam-Message-Info: kXtcaBp4XbAJsP3K0QedV2M8BQc4+bqkPDyOtl9kET6S5kxd9tNP5wTs8AvHVPf8Dg4lvOtnuH69HcJpe/DVArOYFJ60Wt3zt+YRUmGDzyYSYktj5/mjCAZzXogrnT5dgVt4hbJ/gU7KGdjXnJvUJawzApuTo8Ltl0uuqqyMdTZQeASlsc80P/rMZXlHjDgB56Z9zHQxoTzHzklauzHC9iRnTlxkK0qB72Nj1ZEfD/C9BkXG5NAc2n/9Tgcvb4FHc2gZToBYvPHtPbRzvuhc+hK0RYLvxjy0u7S3Aq+SphPstZBEafGiYn7pvSuHAx6K6zybCuVONHTxBPoN6v4DKnwrTP4vRUVSmUiyr0QEmT8BlCC+BOnAqAJlAD79IVCiBo55oliF8eBR1qGERFndGhgxEPjT3W5tcdNeMwKyMfum+U4iufnC2fRSIx+ufOxtGpx8bJGts8o5ezjZEEdITwN0fNs22o//o5+NjuR6ipqg/7oIST/z4tQw68Wrco6nr9x/85JVfu8JM/cLcRIw0IxvxkFWPLYgVjfoCWn/bYXR5Nki114S6zCKKkEVl6lCaCHVNW1jiVVqty5RwH6BrCGE7w2hGsFHG4AYLsf5F55aliqNX/l58HDt5LHQDo9F/sFqxAUbt7lKgU2Yj7pHBH/PjMyjWZvF4kPnSHkcz4ZgslsB8CSu/eKAgLV4j2K+Q9lSOrt2V4wvogi1dBTvnXZHM3w1RfvJWt2kmi2BFzm5kPavbapk+4ox6WUhkS8GDD6YvFTrXWsSE2NnI5O96A== 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)(1800799024)(82310400026)(23010399003)(376014)(7416014)(36860700016)(6133799003)(56012099006)(18002099003)(22082099003)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: p+eBBIvNmNvnozYbTgpFTvSdYRhKnWsn/hK60XlAQbifXaV5yklJZ8lT5SWUpm6xJGLLPXOmcG0klRbzCg98zCHlTQgD6Xjx5B2NuOPjkpgfS/dZWudKosz4mLnSckxKeAsfYW/bedFsbFeEeKhZcz59yyF/UOL7tB8WsFJGkG66koKCPoygK7uyTbnicEy0RlMGjsUpS0Wss0U1b8ztnwVlxPlK3/EzBVq96R2SVBXSvuM7iizdXIS01MNT1GX8W2HEBnKg4tVRd9CvMNtYF2+J9knCvUUxvz8CejhrkxEDxMYzcXePupBPWQHI/ssXY96FJeZ3v1ealy5fonlmxeJl02dhRFw6Na/cZthi6xa3MXKyPBJyYKinWtjdQ7Qjn5kxSZyGGRY2XJaqlkuFvp/BtQOMkR4+re+89JOmHskxYcJ7gbi369hO0+su2h+Q X-Exchange-RoutingPolicyChecked: CZGDLTBmdR2yoV9IQQE3O/h//72froTb2pD4lQG/jCxTNauxx8VBDi3fF6FE955sKFUgShf4H5u6UNyFFL/4JdWIIXi75cRfM0roUkLysa/Hb/EOEWawoUuKvDRtu/j3dn7m4pH/leSQIJ7EsKE4WU+AuE7+y+0gOfEwa8gaXlpCxFFajySVFtwo+nvYtTwPakx/oZwX/XodT4ctSsrv6FAbp71LR+WTijnxh4qu74P1YsRgJhFZmnojlks7TaoLjY7XqEQi1kWT1XRdtwyNWV2QIuerIyqQLqffmlxKoVM/qNU7XOahrX2TIW7SDigFvUy3sx49Hb0XObkWojHBxg== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jun 2026 07:38:37.3845 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9268a2cd-5092-4d1a-83a0-08decd0c9c14 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: BN1PEPF00006002.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR10MB7610 X-Proofpoint-GUID: vCHwsZdrflJ_sHre7IbjHJ0gRUiYgil5 X-Proofpoint-Spam-Info: AW1haW4tMjYwNjE4MDA2NyBTYWx0ZWRfX4GQJm/3VB0RQ iK2v8WjpNUJ/rWk8aitaObgLq7kO5HGGoxIittx5krbUwgTZB9fmI6oNX3aTqELQI6/ZWU4PsiQ JmbDo83mmK/1i92PAWzi+2VlpAjT2AM= X-Authority-Analysis: v=2.4 cv=QMxYgALL c=1 sm=1 tr=0 ts=6a33a081 cx=c_pps a=m4QPU8/Yf0DQKtM+qTkXOQ==:117 a=WotqVVQAdb04rnGuttW3Kw==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=FelO9ux0wxsA:10 a=s63m1ICgrNkA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=jwouBfj2j3NM8CExmVVE:22 a=sozttTNsAAAA:8 a=HwxfO7CK7rPlHD260gIA:9 X-Proofpoint-ORIG-GUID: vCHwsZdrflJ_sHre7IbjHJ0gRUiYgil5 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNjE4MDA2NyBTYWx0ZWRfX2GYlHjAI3aVk pr8EEh0RZpAaovU/HH1DuNiur8u8MiI2vf+ynAaVB8sSBeiywUkI9sUr+DhjppS2oOO2DgiMX76 C1sLM4QqOpwZP4+hvX4gX5veyO99QHSUZj6IKfxhJ9bfjUegVLbaFkHV6LhTv3/SDsErLjCo9E8 uNqE2lAkEzWt1Rqf3COy8h2rID8c4I0xUnVM/eyZJSZgleimL+osxhV5qsZC/qHGjWNkZhrDfF6 HIa8KXO8cDCqYFvtAEGiDiaH6Ad9F1GlM+wW3C5SEZs1X9vIb7OPqwTRGsW0ift9UzbSBmIaxrP XcYGi7ZHb8LYj95p2TuC5jJTdj/iC1JV89ZyhL66aKbtfEZRZ8vRYgYoIGrTn3a0kDFvlPyF83R AoGN4Aa19UTFi9/m0PrWv7sCfn9zmyOn8+gbt+S2/piypYc+Bs+zpYXoAX7vcBBkN9p7y0eZ7j/ ZoGKj8shqclBHtY3TRw== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.125,FMLib:17.12.100.49 definitions=2026-06-17_02,2026-06-17_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 priorityscore=1501 malwarescore=0 phishscore=0 spamscore=0 clxscore=1015 adultscore=0 impostorscore=0 bulkscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2606180067 Content-Type: text/plain; charset="utf-8" Add cqspi_tune_phy() to toggle PHY mode. Enabling sets the calibrated read-capture delay, asserts PHY_EN and PHY_PIPELINE, and decrements the dummy cycle count by one since the PHY pipeline absorbs that latency. Disabling reverses all three. Disable is best-effort. For direct reads, split the transfer into an unaligned head, a 16-byte-aligned middle section with PHY active, and an unaligned tail. PHY is used when tuning completed successfully and the transfer is at the calibrated frequency. Signed-off-by: Santhosh Kumar K --- drivers/spi/spi-cadence-quadspi.c | 103 +++++++++++++++++++++++++++++- 1 file changed, 102 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-qu= adspi.c index e41aeca47885..16e3b843f0aa 100644 --- a/drivers/spi/spi-cadence-quadspi.c +++ b/drivers/spi/spi-cadence-quadspi.c @@ -565,6 +565,61 @@ static void cqspi_readdata_capture(struct cqspi_st *cq= spi, const bool bypass, writel(reg, reg_base + CQSPI_REG_READCAPTURE); } =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; + + if (enable) { + cqspi_readdata_capture(cqspi, true, 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. + */ + 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); + 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); + } else { + 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); + dummy =3D FIELD_GET(CQSPI_REG_RD_INSTR_DUMMY_MASK + << CQSPI_REG_RD_INSTR_DUMMY_LSB, + reg); + 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); + } + + return cqspi_wait_idle(cqspi); +} + static int cqspi_exec_flash_cmd(struct cqspi_st *cqspi, unsigned int reg) { void __iomem *reg_base =3D cqspi->iobase; @@ -1442,6 +1497,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; @@ -1543,8 +1606,11 @@ static int cqspi_direct_read_execute(struct cqspi_fl= ash_pdata *f_pdata, { struct cqspi_st *cqspi =3D f_pdata->cqspi; loff_t from =3D op->addr.val; + loff_t from_aligned, to_aligned; size_t len =3D op->data.nbytes; + size_t len_aligned; 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) { @@ -1552,7 +1618,42 @@ 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); + + /* Split into unaligned head, aligned middle, unaligned tail */ + from_aligned =3D ALIGN(from, 16); + to_aligned =3D ALIGN_DOWN(from + len, 16); + len_aligned =3D to_aligned - from_aligned; + + if (from !=3D from_aligned) { + ret =3D cqspi_direct_read_dma(f_pdata, buf, from, + from_aligned - from); + if (ret) + return ret; + buf +=3D from_aligned - from; + } + + if (len_aligned) { + ret =3D cqspi_tune_phy(f_pdata, true); + if (ret) + return ret; + ret =3D cqspi_direct_read_dma(f_pdata, buf, from_aligned, + len_aligned); + cqspi_tune_phy(f_pdata, false); + if (ret) + return ret; + buf +=3D len_aligned; + } + + if (to_aligned !=3D (from + len)) { + ret =3D cqspi_direct_read_dma(f_pdata, buf, to_aligned, + (from + len) - to_aligned); + if (ret) + return ret; + } + + return 0; } =20 static ssize_t cqspi_read(struct cqspi_flash_pdata *f_pdata, --=20 2.34.1 From nobody Sun Jun 21 23:24: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 8B6183D6479; Thu, 18 Jun 2026 07:39:21 +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=1781768363; cv=fail; b=chZMX0Ct7L4s6CmI6LhbwPpkzWc9H4BJjBroadxEy8+7PmkyaRPYfTSfXS5ZKIQWoImao/KpzE2of6k6DcGSXKgDXPerMkasXQXN9Jw2LZtH5pUxzIIXPsgzY9yzbHxfDjw4KoVEFxpYObEvpRV4q5VwXQDQrrlicVIdIFkQ118= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781768363; c=relaxed/simple; bh=SFy56xr8X3A5c0K9TRUzjbxLxfG6dwgBA5mPXymSw+E=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=sF7sNutAqRmqELYTUW6U7sPAqy8JjBQsbaQ+0gsYS5RajxRfQ2TzNkU2O2HRlCKWUWCD2rtxa+cQNdejQd4zlJx87pdl2mv0EXPFmDHmhye5KQt6CHtvIqqb2PmDa9s9yoOQu2FxzCGxbDmgRJK+wO4X6g6LYAHjBE96KN6QWv0= 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=CICJGCSu; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=FY1RJmhM; 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="CICJGCSu"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="FY1RJmhM" 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 65I6VtEl3436102; Thu, 18 Jun 2026 02:39: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=JS4NTtIv1+BmR/53INOlP8U0bUMW8tU2EKG0i0H2N KQ=; b=CICJGCSua8woNAGSvAzhG7i4Gj1IobqBRWmYzsIg08HselD7HxfVhrFxZ T27zQYaifuW6bGpRw2/edqqlakz3ewZZQReyXYgzI3AIDImQKP8CZ8sYGoCHt0jm AdI9KRUwoTyIEZamXKSiHUHKyDYuUq7cLOoZ1KpzAuqDxILoiZ6egA3r2QwsjHzk eJSbQHzVw+aSsskoMQUnMiIELFCPcvRVFvdnqZxP3B2072mBSutrVIXCsjx95adl Zj7EOLk6MV3VmaG799euTl9NpqZgH5fyQsVRq9jVYb4qx9ynaaqOKQJolHGgiyYA mK7kWY1rhnhC4J4cefE3esPU/f2LQ== Received: from sj2pr03cu001.outbound.protection.outlook.com (mail-westusazon11012007.outbound.protection.outlook.com [52.101.43.7]) by mx0b-0002e601.pphosted.com (PPS) with ESMTPS id 4ev63rj15k-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 18 Jun 2026 02:39:12 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=KLwK/CRoMuBjDOHIfQy/hnm2l5o6cP0orFmSXUFIDbxiCdSxrNVKu9BT+saJTR6sHe8Ti+/+Usf2Cb/uam9BPbFt6nlBxbHI5jerx1Bxpa8ZFlURtF2mb5OKKQKeEbJXDF/FCmbuK87HcGMeJsCEt4HxLhhrywCeBJaYWOa6nyGMkaTb4dgbPgH2xd6qqPXnKB1R16wKN05eWQeDRUKMy5q83SBA14zD/EodwHQ7cJtRkPF6JoAzTaP+BTToVBlypLqJSv5ZLspH8QmjMEe9AiY4fNu43nG4f+XpkEFV8aA31VULkPPgCq9Zqrc4kuQl9PrvsG0HVN/lE84V5nM38g== 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=JS4NTtIv1+BmR/53INOlP8U0bUMW8tU2EKG0i0H2NKQ=; b=fj/47AcIFBmcJCcZzn9R0nQ8w0JTBlSq5j6433bCazYme9IqKw9bWBTIaNbI1hXJFxSqyhuTL9f4aRMnc55Tbcrzr2Kg6coQSZOynf3Uww+iJ7wCv3arOsl6PEY+vePkwOJ3+/Yxoc8VRrZejimdPkk9kZdxxk3CitRWow1jHJE6CeglEF6XTx5n+AWI1ii+DYG1wRkJcaqgZESW/FDi8Ojj05T4alJIhc0yYC/4ybpW4G83SzraK8E4OjKHgDBp8mQOV42BuqRd9lGuXP+CMDhJmsLYihkK8PoUYiAT5qhmyRoHCLGsHdl29OzaQzr6ouWDrJyn/tP9zF2KiWcnbA== 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=JS4NTtIv1+BmR/53INOlP8U0bUMW8tU2EKG0i0H2NKQ=; b=FY1RJmhMUEub35SnEGDnfp9rhPyx99YE/6Sw/2ZKaiLE4Vazly/zchkFD5CRbLVXWVw9lfFaEtwLjRd2qzV+k/MbNaIlHf948GOtvFeRdaw3VfDgagpMMl8N4Xkms/yjrV7XKYgbOe0uK+qVWt8KWlQsQslx3RfaYbuS9f2UkiE= Received: from SJ0PR03CA0223.namprd03.prod.outlook.com (2603:10b6:a03:39f::18) by CHAPR10MB997722.namprd10.prod.outlook.com (2603:10b6:610:2f3::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.139.11; Thu, 18 Jun 2026 07:39:08 +0000 Received: from SJ1PEPF00001CE1.namprd05.prod.outlook.com (2603:10b6:a03:39f::4) by SJ0PR03CA0223.outlook.office365.com (2603:10b6:a03:39f::18) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.139.11 via Frontend Transport; Thu, 18 Jun 2026 07:39:07 +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 SJ1PEPF00001CE1.mail.protection.outlook.com (10.167.242.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.139.8 via Frontend Transport; Thu, 18 Jun 2026 07:39:06 +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; Thu, 18 Jun 2026 02:38:42 -0500 Received: from DFLE205.ent.ti.com (10.64.6.63) 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; Thu, 18 Jun 2026 02:38:41 -0500 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) by DFLE205.ent.ti.com (10.64.6.63) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Thu, 18 Jun 2026 02:38:41 -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 65I7bYvn3521710; Thu, 18 Jun 2026 02:38:37 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , Subject: [PATCH v4 12/16] spi: cadence-quadspi: enable PHY for indirect writes Date: Thu, 18 Jun 2026 13:07:21 +0530 Message-ID: <20260618073725.84733-13-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260618073725.84733-1-s-k6@ti.com> References: <20260618073725.84733-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: SJ1PEPF00001CE1:EE_|CHAPR10MB997722:EE_ X-MS-Office365-Filtering-Correlation-Id: 49952809-37a6-48de-908f-08decd0cad77 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700016|82310400026|376014|7416014|23010399003|1800799024|921020|56012099006|6133799003|22082099003|18002099003; X-Microsoft-Antispam-Message-Info: O8GTEzHE0DAEOT+7Mioip/VUGIzH1PvA07P+T0JJe2Iz976e9xCzaR2q3gCrt72RzexXxL29JxCbMyj7XcOzbE4zWCjpbcOQ5V48tlykSbvpb+5Y/fvxzi7wiWswFaYj6FHUPxwzjB+Sh5AkchNURkkN0Eh4YvkIsGZJHlbhATnuvfdSzNry0Hn+fEXxq9xVcDWM3C0sbceui6YwedEgfTyaPvc3IcW3EJH+TA7WvPs1BbS4VzD15SNxvfPNFffQNq+ltF9vU//vj3o5E2N9JipFVCstR6WsUyvODwNW96MEY/bzu0V9UldRQW7FMdBNg4bKmuPG5Q5JQrzNmBvyUsKQlS3uIQiGiwpv7spmMVcB3i6iBzaL5R4qzO3OxxVo2ReDD4Xx7LzEFR7+cQcUshdFRtN9Z+qCdkvnEcaCAznPMHRtAor/9dr9hQ+dBtr74T/7pVchdgtuePqF9AzLAP34fdsvgqZ7Ibb3SHOuo2W1jynXYWXUW0oMmbYV8vyzkSLIa6cDBXjBKJN10IATCrvoq9SefFGGKhwJXrUjnztfX07stk3g5rhWYPmIjIu/hmY7FQCAOsvYa8841ARESU1rPh/DCeTbHaPDBhtPXyvjjh3rtvpiMGpCDkOGlWcXUUBacD6/YMvAeLqVsD3N87GpLcTVOmfDh0QTw9OiLHVC/ojaPqOba9OMQ9Oai3QXZO1KG1Ve4byEFCMUgFtdzDyEkFiSW+rexDKYbMw1LcCL+v1aBL8mkdDs5/6v5VL9x682yelJUg8hsmKIN43CNg== 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)(82310400026)(376014)(7416014)(23010399003)(1800799024)(921020)(56012099006)(6133799003)(22082099003)(18002099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: YLQiXD7I80ASjoEMQF5bNl1lqLFe7UZpx5edSUX8WsIcGFmwk0/QNRHNNutRL+2oTe+tvBPketBKJOZw+KT3LMOP8eSoWOKhc6W/sOaPq6aEM7yfaiYpEnS1theGNaiJEPTNqVUwdykKhwymF58nCgwpLj++0Ss1gnGUhP6psvyNEL9/rFYMZTop9+zJoV0jd24Cccd694MjzLFlUGVYEg6/jU4QpDngO3HKmKq7IGGN1QA/Xvf3hGx8W2ZLrdC3CRneEr4Gv+PKzq1To5LofkZVr8X6+sFLGOX/Hgs3z50lIyekS2s9slakwKVS/KlbsRUms4hF2046kXGDchIpR/H8zTS/Q8AqEKdLXllhaWzZ6S5GfBDFx6/YmRgFCQUxn+mFY5d8n6Mh0m5ZEdJ+/rcVDfanWoqfZmsPwvZPpOyCAVlRmmGmGRLatj6isTAN X-Exchange-RoutingPolicyChecked: hUhEtuECp9UdRdBZc0yxXrzYYTERhYAhBpp6ZuSAapgslAON+b4DwjRLCPFnRu261CWwWXrF/3F8PKYmizYL7xUW9dCTNrbC57OZVfn1vAB64v6nUIcETEG2S/o33dQLTNWxBLmDvPpPkhpy0ySA1Ki3zImqi1lIS+c34dq/gRsx8b6FHtKVQ8Y6TyEbmPluNiikjGKRORiyrcWigioBvkYHuHEpsvHqKP2zrp7JKVoKorTSlGyXMQjhtCepYrcy+NFpLAZhdh3ejZ4C+P87UMTXmeWXeacMt4RpyGKiVbTrXXLwhiaRVS8w24ZxIWoRgLOYNpepQggUWt4+qWfhfQ== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jun 2026 07:39:06.5473 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 49952809-37a6-48de-908f-08decd0cad77 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: SJ1PEPF00001CE1.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CHAPR10MB997722 X-Authority-Analysis: v=2.4 cv=LpqiDHdc c=1 sm=1 tr=0 ts=6a33a0a0 cx=c_pps a=Qv0FdJiMAyQkWbHkl99ofg==:117 a=iwqwCZQqcuTv3JOpYdM7/Q==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=FelO9ux0wxsA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=fPAWb5peG099m5CrUpKH:22 a=sozttTNsAAAA:8 a=-A2lziRS1w5XIjWNnAEA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNjE4MDA2OSBTYWx0ZWRfX/RIj5tigelQk MyWLNK5JORxODzk7gW879C3ZiSp3Bnzg54a9EQz1VZDwkyKj5DGPN/hAN9Ko1rGSgQ1NdAzdUPb cnwrqO7UWT7MaTSd1zQLDaShnG7svTM6MsLmcjRwzPM+fS2r9B/Wf9JAoMokTMAjOKP/00O3mEz LzbE/gzwB9flop03uLjvnqGRuhe1IJJxlocj27P4jxpDz1w5sksXzotlBwykte901hNBbIvU8hp H3nM16D2v+AVomv7SqFQwTx5l4jmc0aV3eoHkUE86WGp1LzJUgyPZk9gSxEJd9oBx13Os4Sfjx0 71Zo4nCbrV/pq/njYxEwAUAWM6uqgqNV4JICxfgDYp9BEsLJhmdaZYlAx/T6/i4EyLTsjz97SuM k//9BR9R0gPEpW7AfEMUUhlSv1rYHsMBhU9mgOCxNKeMGrdUr0deByBgWZsSIcozuoinRAm7t5o ktFR9DZfvC24gDxhbJQ== X-Proofpoint-Spam-Info: AW1haW4tMjYwNjE4MDA2OSBTYWx0ZWRfX4mJ4ViQ8Cndi nNnXTV0P9A6EfEZFYOMaTBF8P28EME1DOWN9x+ydtsPvSjNEVfgXc4VxOBwnG/8sLz5y8NNEAl/ Z8gjRIDJbbw0BQmJ8gnTdui0sdJP96c= X-Proofpoint-GUID: khwwr9m3-Dem76JktHeaeggYe9IFacrH X-Proofpoint-ORIG-GUID: khwwr9m3-Dem76JktHeaeggYe9IFacrH X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.125,FMLib:17.12.100.49 definitions=2026-06-17_02,2026-06-17_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 suspectscore=0 malwarescore=0 impostorscore=0 spamscore=0 lowpriorityscore=0 priorityscore=1501 phishscore=0 adultscore=0 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2606180069 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 runs at the calibrated post-config frequency, matching the same frequency guard used by the read path. Thread 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 | 32 +++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-qu= adspi.c index 16e3b843f0aa..df7fcdf404a6 100644 --- a/drivers/spi/spi-cadence-quadspi.c +++ b/drivers/spi/spi-cadence-quadspi.c @@ -151,6 +151,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 @@ -1240,13 +1242,15 @@ 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)) @@ -1282,6 +1286,18 @@ static int cqspi_indirect_write_execute(struct cqspi= _flash_pdata *f_pdata, if (cqspi->apb_ahb_hazard) readl(reg_base + CQSPI_REG_INDIRECTWR); =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) + goto failwr; + } + while (remaining > 0) { size_t write_words, mod_bytes; =20 @@ -1330,9 +1346,15 @@ static int cqspi_indirect_write_execute(struct cqspi= _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: + if (use_tuned_phy_write) + cqspi_tune_phy(f_pdata, false); + /* Disable interrupt. */ writel(0, reg_base + CQSPI_REG_IRQMASK); =20 @@ -1467,7 +1489,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; @@ -1494,7 +1517,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, @@ -1710,7 +1734,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 Sun Jun 21 23:24: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 BDF661A9FBC; Thu, 18 Jun 2026 07:39:13 +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=1781768355; cv=fail; b=mxBYAD18M8LBSOm88WCf4wTY59Qz9uDjpjrDB6QDwy9KpFdERp0GSbjGXYhzzvkiH6WTc9bBdGWL8fk1qI5yGUcNDKxN5hu12+xBftfHNyKW0823PNjcbDocdHLrXPT3ChePEcRkwPQ/vNXuVOu6HZpmg83Bau0Gs7ngQCCoNDU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781768355; c=relaxed/simple; bh=Vm2wjXIAgVaRLYNYzwtw/HBQOr2FZG728QoRz8FgKD4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=R17XKI4j5u59rB3QxNidvg7c0hno3UApyqbi7engm1gMSV0wPAVBx2WWrRKV8xzbQ+NLQ/iMLnFmpWNcp2gStTze0EihdseWrjUHH6N61v6P2zl6I7471fg2/SUOFeghVzkQiyG2MFkLM+pehg/arSOln+yCDUlQ42l85MJ5pG0= 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=Nej5yY1H; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=aC8el7ml; 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="Nej5yY1H"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="aC8el7ml" 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 65I7WrjE2383810; Thu, 18 Jun 2026 02:39:04 -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=Aq000ovTC8ur5gA6COEaYAn3sx7vf1Rg8oSz1eJZu KQ=; b=Nej5yY1HrJYIAhkLld+PqaBqub9SyHHIve4jPfsxZZOLmqo3EQlY+SB5Q gwPG5MWdTX/FvZYBvKaFaOTHOfbtxBluKdTztZP0IpnjzFzTI5Pt5D7K+SoelKAA D5RE2F/n+TsX+odb8MKGNnHmdjN3FSYa7UHgrSmFAewfgD5el90ngApkUvwyx1Me eELWtSklXtmW+ezgiTTgGI2kKoT1N4w9loAH5ijKuZMFRE9OqwbzGumlfOYI6+gQ SuZ65WecBcNVB60gleb8pOh7c54JNX+NAlNxEJW5vVTeDT43cpBq4+01n2zefMUM pBLb4rcNZODrK7hSWiiPgcyDDIbxA== Received: from sj2pr03cu001.outbound.protection.outlook.com (mail-westusazon11012031.outbound.protection.outlook.com [52.101.43.31]) by m0380145.ppops.net (PPS) with ESMTPS id 4euthp6s65-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 18 Jun 2026 02:39:04 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=IMEKZS174/1SQXMYwqJKsIO3JIfqJ9asFEz37pOm34wUthaEYyYOv5yPjYIOu3Y9/pCohhEwrZD0oWfinl7miMFsT0NhDKUFGfJgScfgCVueSL/hLVbcJE9S0eNwEGs86C57GM3DXIhsMw5ym9kRzlk2JhUTAahLODCU6HnJuLncAB8zSEvhesUFqc97X9YPax0GZRwmRhniZmpRsFPZu5u/vHjgupWH1KsoCcQqi5hPjyu1H0ixwpRbkpawKLHKS8kAPyXMSI9yA0mrvd7s+MKCByQODgDjlBFMjg9eQstBEx/fK83tfpqJy6jPVRLRotswtcE+oL5c+puA5pibWQ== 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=Aq000ovTC8ur5gA6COEaYAn3sx7vf1Rg8oSz1eJZuKQ=; b=U3sw6stST4ytjXEZarenPhx8tI2/qbluMjpKyy4NhtxdfheQfcBxXvpDU4Wrkby8D0pTHKjoWLqyuh1fyt0xgXpEzO4QSyUGu0zw82DkUjkf7eT19FPVbqs+neogNJf2pJD7mev4yGPm/9IWg/6boOweQdIKhte6uNzPPE685s2RJgMMa/p47tOmI4c08LFrUiaqHCnw+lHXO/kuVv7ZpgJirjQ8a0QgMfpCQOQO2JAg5/Fdd0OoOxznS8pCx/KbhBH4Nl7E9YeoVYwW2V0SRTx+Vl5vrPP2iLLu1OWlV6T7VwQ/RVrqHsmcR2ZuP2T/xfKa4/XePo+KuNfaSND7qw== 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=Aq000ovTC8ur5gA6COEaYAn3sx7vf1Rg8oSz1eJZuKQ=; b=aC8el7mlz5yNv3PSBIKuVXurylRTRvDQeHd6sEz7VSebSO3ri+/xNbJycondMRV0saRwPhTITVNjxdSEgEirUP8IzcTM3waa+/daK8kfvuMpRTcK0fyK6RDFEnNbuf0oYshftYDWo7vJMe7EcOi91wga8M8talF1BsEZ8JE81Aw= Received: from SA9PR13CA0078.namprd13.prod.outlook.com (2603:10b6:806:23::23) by BLAPR10MB5137.namprd10.prod.outlook.com (2603:10b6:208:306::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.139.13; Thu, 18 Jun 2026 07:39:02 +0000 Received: from SA2PEPF00003AE4.namprd02.prod.outlook.com (2603:10b6:806:23:cafe::36) by SA9PR13CA0078.outlook.office365.com (2603:10b6:806:23::23) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.139.13 via Frontend Transport; Thu, 18 Jun 2026 07:39:01 +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 SA2PEPF00003AE4.mail.protection.outlook.com (10.167.248.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.139.8 via Frontend Transport; Thu, 18 Jun 2026 07:39:00 +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.37; Thu, 18 Jun 2026 02:38:47 -0500 Received: from DFLE208.ent.ti.com (10.64.6.66) 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; Thu, 18 Jun 2026 02:38:46 -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.37 via Frontend Transport; Thu, 18 Jun 2026 02:38:46 -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 65I7bYvo3521710; Thu, 18 Jun 2026 02:38:42 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , Subject: [PATCH v4 13/16] mtd: spinand: extract variant ranking logic into spinand_op_find_best() Date: Thu, 18 Jun 2026 13:07:22 +0530 Message-ID: <20260618073725.84733-14-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260618073725.84733-1-s-k6@ti.com> References: <20260618073725.84733-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: SA2PEPF00003AE4:EE_|BLAPR10MB5137:EE_ X-MS-Office365-Filtering-Correlation-Id: da088629-a8a6-411b-cd60-08decd0ca9c6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700016|1800799024|23010399003|82310400026|7416014|376014|18002099003|22082099003|3023799007|56012099006|921020; X-Microsoft-Antispam-Message-Info: Td952za99nyksNtOCa2C+YRhG7xy7giXKYLI3WfU5CAcvFLIg4Q2281s19T+XLsRMgNeRboXriRDKNmQRoaDTpy0Gty2FQYtBM5VvOze00dzIGhc8AaqUIXuNrnPaIpL/tABXiFIjUbtiED+wPSUk8R8FCVpT/ehw/IWxxSziwsCNb/cZzBQHDL2W1iN7i5A6C9wxOrdCKbkaj+0g8N53kMRhVmop1BdN8rbBzBLQVLstUXi36Qacnir2y0hqNDJoLnxBmc4MoNKHG8/LfNLn2c94arh5+MWCzBbRxYLvQ+0NDftjolNYCDZadLyrJpAr848oY5Rh3lvtYhk2Qt3bJGO+munC068FDhM0UIgMDsupQcElzyqIO4vgOR9WbIgf5EYwtpwwIwiQYAKjHgl0kTO1cVV5wY8uqOqpDOvRL3pP6erEwVKCBKpXqJ4VNWop2BUaY8Apt+8yJzN9xnCXBbbRHPnmqbIwAkQ6ZeDn5iENYqDO7Un0CKmo7u/1X8emBysdGvMn0P8S4nF2Be/cENgrAADAIDZc+LtqAeJySaJF//Aumn9i947NCw09YNqzvReiCDTlM0D3I0FHbyikWzBkT8yciPjjIp7xJpHIqxvrUZYIO/jpl5T0GBtecHtvASweNE7r+XGzo2YCVC3YbWloeV7eQTMXA82d66nfhFhC3x2q1yMYDFSWMurLHQBJraEu2pevVHYL63NSiPBG1Gyeavb0TLpsM1DjS5iAsl6M+BSkxETHMG5X2TmEMAiwN7zwgQ2XMfmLI4yEsIaUA== 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)(1800799024)(23010399003)(82310400026)(7416014)(376014)(18002099003)(22082099003)(3023799007)(56012099006)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: I0FilY4JuSoCNTDO6ADRsWoOU1mNHmUNfihR4gqicnWV/O+khoZpZnLhTRgad4mDgi5S2YY82yQLfMa7RerLJ3sG3YEc6TS9aZnFTAj4zc3IfZqTyTkajpiDORzVveDYuZHN6o+X6Nba2wY7hEtkOuun/ZefLtS+HM6uGpl6oSKtnc//Gb8Ce0/U4CzMBvUoj1oFjatYhGbZnjL8hRC9TS+xTuluatNutd4kyoCF/a7YArwn08Q/JmSUHNX5+rVInKDUn/irPmPezNTrFoOQs4klv7azn0uuSBcaTe+WetbNnFJXc5k3qsa7le44TyQz+oD1Z4WHu4mcsGGGHy4mCzW9HjSj55guOfCpN24F+XfyFO3TnXCchrAwYPcFW4yuKWU/NtR+fub2PaZPdcHxszNDpuYg6f5oeRHtknpiSuUWzDAklMn/JyJa8M3SgUMO X-Exchange-RoutingPolicyChecked: FdhtWwLuo4VTbo+N8mdjXjZeJCVSF+3AQgZqOg59+kMHihyiXubiz77FRxSoORY4P5djtVDu5jaWPG0Goh9d7Z9YXMXSpM80gaMnEpdt+LherIxqYHw0hQduyLPbC7jlNyvbIyblXjgSl4Bq/kL5uDNaraI3LyAqsGnMKHHKsmTfrEBVuJ4TqHPraAX4WPpvzYofJjnq7n81YznakfSrziVJmQJbVSb2b0FXjsTOYfDcYcW65Oc7Ds84ejZvu0+Zm8sJGhjXTh3XoxEGIsVpxxYhpAwgKJ4NSkUqf5W82VWYaCa3at0cELvAcToWMWZipiAy8Un4NvKi72+awJDoYQ== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jun 2026 07:39:00.4095 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: da088629-a8a6-411b-cd60-08decd0ca9c6 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: SA2PEPF00003AE4.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR10MB5137 X-Proofpoint-Spam-Info: AW1haW4tMjYwNjE4MDA2OSBTYWx0ZWRfXwleS3dHZqrqC 9/MF0C1V+HnPz1j8wlYpL9cj2T5hFz92fG7P0g3i+VyzAV60MkcICDJirxtlT3d0iVSnx95SKEr GNJEwrHoe/ru2hLdATRDAIaOi6QKoHE= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNjE4MDA2OSBTYWx0ZWRfXzkw9NfwTEfNp ilaEKWLCbQdzUJ3xgNqH9vjkn2OANgxGAdkeHcVqqpYbrrwXttje2AJahXKP+xjoonA5hcr/dfD 2n7IpmBFXoqFlW6GlL8QJajDTVWLjL+tRynnmgoKhj3G5WAdUaRsqestGqWCeYdcnG3CGEmgn2b hrhHGR0HhM7X4Dn9wOOp+k/FbqPEupBe67D4VgqqKBksER2zTzAeklfY4ei7m32jT/wsHlVqfkW Q5RkVn6iVUVjNuDuGB33DwQ5Vl88W50FiUeQQkKyIrHnV0GFWsIrlhurBeQ9unX1FKcLQqAjZWp avpOutVsWz02m3C6oYVm717+7P/OnIlWH2uwQ60MjvaAZtmAu86bJlq20NYSA45jgdUfcw4SqX2 DNI/owuGOFkmEXu8L3zhDbAq4V3D3wAefwVMyrQFCi0zSScTzLsc9EMnCtF+oRCEf+apaeoRTNc DZL+Yl8l8wTDahO9TNA== X-Authority-Analysis: v=2.4 cv=N/wZ0W9B c=1 sm=1 tr=0 ts=6a33a098 cx=c_pps a=qV0RoXYxPRq0QxHYvE7eUA==:117 a=tJyPKKxUohctrY4NYmUjkA==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=FelO9ux0wxsA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=gO1vWkAQAl3rybz1DQOp:22 a=sozttTNsAAAA:8 a=b2CdaXXOtDrlFHZ3GWMA:9 X-Proofpoint-ORIG-GUID: 8K9WeKwORF_qj5ypYrkz3vFOBsLUl_9P X-Proofpoint-GUID: 8K9WeKwORF_qj5ypYrkz3vFOBsLUl_9P X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.125,FMLib:17.12.100.49 definitions=2026-06-17_02,2026-06-17_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 bulkscore=0 spamscore=0 lowpriorityscore=0 adultscore=0 clxscore=1015 impostorscore=0 suspectscore=0 priorityscore=1501 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2606180069 Content-Type: text/plain; charset="utf-8" spinand_select_op_variant() open-codes a loop that finds the fastest eligible op variant by transfer duration. Extract this into a shared helper spinand_op_find_best() that accepts a skip_mask bitmask of already-tried variant indices, enabling callers to iterate variants in ranked order while skipping previously attempted ones. spinand_select_op_variant() becomes a one-liner. No functional change. Signed-off-by: Santhosh Kumar K --- 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 f86786344d52..b678d0534297 100644 --- a/drivers/mtd/nand/spi/core.c +++ b/drivers/mtd/nand/spi/core.c @@ -1541,9 +1541,22 @@ static int spinand_init_odtr_instruction_set(struct = spinand_device *spinand) return 0; } =20 +/* + * spinand_op_find_best() - Find the fastest eligible op variant. + * @spinand: SPI NAND device + * @variants: full variant list to search + * @odtr: true to consider ODTR ops, false for SSDR ops + * @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(struct spinand_device *spinand, + const struct spinand_op_variants *variants, bool odtr, + u32 skip_mask) { struct nand_device *nand =3D spinand_to_nand(spinand); const struct spi_mem_op *best_variant =3D NULL; @@ -1551,15 +1564,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 odtr) continue; =20 + op =3D variants->ops[i]; nbytes =3D nanddev_per_page_oobsize(nand) + nanddev_page_size(nand); =20 @@ -1588,6 +1602,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(spinand, variants, iface =3D=3D ODTR, 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 Sun Jun 21 23:24: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 5E7EC35C188; Thu, 18 Jun 2026 07:39:12 +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=1781768354; cv=fail; b=G2n0/E4MJ6bTwj3XhFBUvubRl6eVPs8LCuydMFfqEyYaOYXicaN6lqZoqTrIb8vGTogI6oPx3/O+v5hwJp7CVNv5A1aWPntRcgMDoWP8EtO1Jn8vOs22Smu6iPtVX10Nh0j5WjhY2CBG/URnDGjxujFiBHrcsP1mXBVL6EDIBXQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781768354; c=relaxed/simple; bh=dSXQ7yGtMygKWf2xJB5ufR1pW47BXOTYoCHdcXE+KWA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=dEGZeOVnnC6paXm5i1uvJ+N3WaEhle7HUpP0a+HlklGj4WLqLiz0+rctpD8FHBLjod44MbrKX9paOZmG76wxjiP8tirv8TCtC+kd4JyPdsnszj0KZ9etXaRS98NJIR8HVe2qUeUNGZzCGZBXvgOsjr9qvkfI5VAdRTMXO7DSCBk= 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=VijqzUec; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=CFVF57ys; 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="VijqzUec"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="CFVF57ys" 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 65I6wScI2383668; Thu, 18 Jun 2026 02:39:03 -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=nwuNwmkSyUBvrOwre5d7aS6IC1s9Go/8NOOZC8va4 MU=; b=VijqzUecUcR5UDcXKnAf2R5toMSh/rTZtid1z0g3L7GqDv9UR3HPN/P69 OUdMhmPosL+/VFFdypaZgksEPeGHLRyTCc28GM6LAh6nu6jmGaY9iF4Ljq9iSBGL 9GxeGdbKw82UotS9YR6OYTKBzuhYnJT71AVctde8LX7zJOBjGRDNLzltUqsVcqn9 xFkplDCTf6gi38lvtVNMo1sL0/Z+kw0063sgGSKnCfDRdMKAQnL35eSE+ipc11EX QARaJYwYn06K9dtXXU1zP6Ss4Xxv0zFapm1KTw04CzAOtal/Gh24xcNWakI/SbgO kGNucUf4WBCSW6XPF0odHrRE22dLw== Received: from sj2pr03cu001.outbound.protection.outlook.com (mail-westusazon11012024.outbound.protection.outlook.com [52.101.43.24]) by m0380145.ppops.net (PPS) with ESMTPS id 4euthp6s5y-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 18 Jun 2026 02:39:02 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=yrLk96z5gxCiK7LK2sXvgEnj65q/2mrwwjQTzg/ZQIfOWItFCtnsOBWGT0kkQ2kJEoA8vvsw9jjzYZDqhi3rde87PW2eglb9//MP/4WCrXGKdK3l5vRXR7g0LQeN3d7SDbAs1v7wXKkWn3Bz1jd0OKNmpoSXK00Rk96R+h/BIt0Tkry8CKhRPQI7R0gUFe8SqdEposxK0Yy6WIxZTKd8wqumO0C386BIeH/nBsCTiQLySq/04Zmpp02ZCvLFICRYJOuHFj/UoWxEgY7GeGtlFSyUuUTwBZJi1cz8yWgVtTXM6F/L8rxmyJ+8JUkPGL+vlxvAM0pbNzvksTV5aou3tQ== 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=nwuNwmkSyUBvrOwre5d7aS6IC1s9Go/8NOOZC8va4MU=; b=DK0JDbNR81GLbS8DaVETM+fnRRrb7Se/kbmzIkGUgyWJS+zdU4dbQxuTwfHcS6ZjWmzDNhDn/evASTvoMWyph2pgdb6pWNBLjHcoYSjJIGd2N5sEvY8PAnEUGkaPqkKGLc+nQ+LTbocdkxIFJe1p+ZUzqNsasvMiACVt23zFPWkc6ie9abcDZVmTULyLucwU1BLOg0Yt7w+ccIwnBOqjkE6hvuJxuwZmBIhE+tC4bB0HESFUPj5i7XCgvly6Htt5UWLcEXoU5/qlHlZUkmXoz+UgQXA5b3e9TsIgFBRzNz1nLecflmzFgLqUMcSVKrw5agH77PgdIf0oXB1JaZ11pQ== 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=nwuNwmkSyUBvrOwre5d7aS6IC1s9Go/8NOOZC8va4MU=; b=CFVF57ysNOKzlkrGPhL2BQDVG8Dk4bbk5v7EIOKOkk9YY7nFKtZyezoOYMGi9a1yk0pSH2JBHc/wiYyUYALzigzD60PA4O458eTvA8WPai4KmpmMPUhqNI6/Kkc2CkXzCRsge3KciYgtuvS20wN82MtfQ5ZIIow9ko3NpIWeyeU= Received: from MN2PR16CA0063.namprd16.prod.outlook.com (2603:10b6:208:234::32) by CO1PR10MB4435.namprd10.prod.outlook.com (2603:10b6:303:6c::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.139.11; Thu, 18 Jun 2026 07:38:58 +0000 Received: from BN1PEPF00005FFC.namprd05.prod.outlook.com (2603:10b6:208:234:cafe::4e) by MN2PR16CA0063.outlook.office365.com (2603:10b6:208:234::32) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.139.13 via Frontend Transport; Thu, 18 Jun 2026 07:38:58 +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 BN1PEPF00005FFC.mail.protection.outlook.com (10.167.243.228) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.139.8 via Frontend Transport; Thu, 18 Jun 2026 07:38:58 +0000 Received: from DLEE213.ent.ti.com (157.170.170.116) 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; Thu, 18 Jun 2026 02:38:57 -0500 Received: from DLEE204.ent.ti.com (157.170.170.84) by DLEE213.ent.ti.com (157.170.170.116) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Thu, 18 Jun 2026 02:38:51 -0500 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) by DLEE204.ent.ti.com (157.170.170.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Thu, 18 Jun 2026 02:38:51 -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 65I7bYvp3521710; Thu, 18 Jun 2026 02:38:47 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , Subject: [PATCH v4 14/16] mtd: spinand: negotiate optimal PHY operating point before dirmap creation Date: Thu, 18 Jun 2026 13:07:23 +0530 Message-ID: <20260618073725.84733-15-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260618073725.84733-1-s-k6@ti.com> References: <20260618073725.84733-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: BN1PEPF00005FFC:EE_|CO1PR10MB4435:EE_ X-MS-Office365-Filtering-Correlation-Id: aea68711-1daf-40cc-2b8c-08decd0ca86a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|23010399003|376014|7416014|1800799024|36860700016|921020|56012099006|6133799003|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: C+hNAnuwWaImEr0NJkZWOUxkbtiyf1C1vfWHU9tcruEtRni7IZ4aVx/xf/WRfyYQhRj+fH8zOjC1VXeM/HWO/to9YJbr67kco9cN42M3O47di/QjCcysIinwQ88HJrtJ43tN4zSeERH6bKFQ6rUPiiZeYyk822T92gwbbnHhJ8iX3hcoQE0jL7ceOhxKlanEtcxESpsyeyw3IV6iFqHJamVA6lgoqI0KbJf213xqX3Q76YlDGG41L8SDqqWEHB8dJl9xgiqUicxmF61FkpDG8iSfh4LsbMGQ8VwsLZe4axqUJzh/55IsLfdT2fAGCvXMLqM0Umlmr7VYYU+jVMiHkmC2HBoD8cdApU+ki/wyL2kzGL8AGGz5+fQbGok5Q9PQlpw/Pn3edDltOkJO1P7LymWDyhmsrFwiJwidQ195stoQXgxrLvXpvcdRH2ir31DgeuaLdp1TIH1CTSkMNwTI2G3nnh3Qe2BfQ4k7x+FQVfsfEa5mQWv5ZeibYd7V1ZEOejZU48YIwRyr6ZXQI5/8a6YqLaaKL6da3ZoGy3GhWH7rXJquM4Sgr5n3wNcAy304z2PZbUpoK3nnhqX4m62YvIQwNSR7CgnOEED+SEbfUTpf4VyH8P5tt0M6a/KnrDrwe6UOVMXSfvj7hKdgYM1SYQ0uutkUtbBisDEnMHJgPmngiXm9YSo7QJc88ws4ELoZwB/9BdCq9IOhYRyKkg8oHuw2ZK4uCJSTglGabSTEIKzijLYeP8Hn3/XDG+A7Wuohqt1AoYcXJQ8MYwImi4GYqQ== 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)(921020)(56012099006)(6133799003)(18002099003)(22082099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: R6JtNlz+p8hTTxAYkD63A4RgWmcQymfNRmSjBxo4nQRocx9y7mI9SJh6/Ol0LpULQzLpf1+llQADwt5dyQSxE6x1iKrYf9YGCYIp7FlzWUinXezTUmcWETJP7MozNUy+j7PDDtu2SVvlWrHAihaZi1lnb41XN6gDsPrsuBPxYVfBorkRulEno+DeBxWKfqeX+yt/r4WHO58/ZK1zZ+F+jF2Lv+w+5m/2dBz0rXZPckur6fDa+JK8xUhtZSBCn2rQfzURBZ0Ll/kJ7O327TefPJi68psuPyFbAVJTz857wsBZLs0Z3pqCIWNMg21yGBlU08mVXf5PX/iJpDRdJNuXwizUDd6H/L9lHKc/PCXQA8T3zegKMPgnNMZ5nHDUPq8V/daLtGKVEy7hua/hmYHLH5Qk/rrLQGTY2F805tBeBA/PXbCAg9n/AuqBciJwVLEi X-Exchange-RoutingPolicyChecked: RelsBthS1Zz448Ce/Loj0oUXeF8GWCEJOiHPvb6d1y4pHUW54ZuevrQz8abxN312dajVjUkmLcldmFpBdCANe8i46u6JcRu8gkqaqUbgY+/1aS82h/UJf9r6gz+mLV2ZtvVpyA1YanWybmPxolwI+v6q6mWiIAnlA3r1jX3fS+4+exZUfnKrFneB/J3cWssczuc4BVey+rsYpkJ6u+VPn+HycW8bqSjdNhr3Lj8ctnaDefS5SgXUvIlf0QKOmMX1aMY/OeSz++xFPHw7j7RofcwNjqLOOcFRdZJeijeHq6QVazo9DuBRKF88VO1uGAT0GuH0/TnHjv/4Zs9kbAgFeA== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jun 2026 07:38:58.0841 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: aea68711-1daf-40cc-2b8c-08decd0ca86a 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: BN1PEPF00005FFC.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR10MB4435 X-Proofpoint-Spam-Info: AW1haW4tMjYwNjE4MDA2OSBTYWx0ZWRfX4y6ugKdKFZAu v+BY3TXh1voEelJ3SdROI5achP9fumIIgG/fYtBSYeLlvmTYLQLZw+EcyeBKwPVsKBlDpXTuGtt ayXrM6GXjLDqTLbnLT1uoWGLSYlKeaQ= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNjE4MDA2OSBTYWx0ZWRfX6adHRXMxSdyi 5p1/YDaEGBSwcTaODfL3jrxeuItUeVw5GUWyuYVRAvgZM9OeCA8RT97jDCST2fcoDgDNJfI5nzZ +sjIG3hFmLYOefj4c2JBjVjb4U6Wz7P1loeaJASNFji543sLxf3wfQfaxSPBA84RKOO2DbyYMek J6mbE4XBJVSsD21DcvuXComl3OznrMgwM/50uJMh+ywHSuPeJWL2E6LZY8Ifr0UtaXEAfITFmqZ /ywPi/0zutA+pjokHqg0iPkRaZRNipRCZ0E8DU/vfCAGllrTkrevTiEH9ig34bICX4nrLLaABUT aS1Qzi4HldjAEI0upCC1s/ljEUtqjiSerjKhn498M+QEvFVwE/xHIRszG0jhi38svSvYx8fmzzg +CHROqumRUq2uPyf3eF8q0z1REkXSKi9Xqz9g7yTaSMnpKHGucOtfl1m5+2Cu+SePeC7cwX2k6P gy+/1Binvp8kezjn29A== X-Authority-Analysis: v=2.4 cv=N/wZ0W9B c=1 sm=1 tr=0 ts=6a33a096 cx=c_pps a=zj1Wid/uFNkmIHgSYpofMA==:117 a=WotqVVQAdb04rnGuttW3Kw==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=IkcTkHD0fZMA:10 a=FelO9ux0wxsA:10 a=s63m1ICgrNkA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=gO1vWkAQAl3rybz1DQOp:22 a=sozttTNsAAAA:8 a=Pt3BfWhVW9kp4qBOMRYA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 X-Proofpoint-ORIG-GUID: bwwpx50fkWCDU2PKKW15lgunLrJEijvL X-Proofpoint-GUID: bwwpx50fkWCDU2PKKW15lgunLrJEijvL X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.125,FMLib:17.12.100.49 definitions=2026-06-17_02,2026-06-17_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 bulkscore=0 spamscore=0 lowpriorityscore=0 adultscore=0 clxscore=1015 impostorscore=0 suspectscore=0 priorityscore=1501 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2606180069 Dirmap descriptors encode the op template including the operating frequency at creation time, so PHY tuning must complete before dirmaps are created to ensure the validated frequency is embedded in the descriptors from the start. Move dirmap creation from spinand_init() to spinand_probe(), after a new spinand_configure_phy() call that negotiates the best available PHY operating point. spinand_configure_phy() tries the pre-selected variant first. If the controller signals that PHY tuning is not applicable for that op, spinand_try_phy_ranked() iterates remaining variants in performance order =E2=80=94 DTR variants first, then SDR variants after switching the bus interface if needed. On full failure the device falls back to the best available non-PHY mode. Add spinand_reset_max_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 tuning. PHY failure is non-fatal; the device operates at the conservative base rate. Signed-off-by: Santhosh Kumar K --- drivers/mtd/nand/spi/core.c | 214 ++++++++++++++++++++++++++++++++++-- include/linux/mtd/spinand.h | 11 ++ 2 files changed, 216 insertions(+), 9 deletions(-) diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c index b678d0534297..5dcfaabaf2cc 100644 --- a/drivers/mtd/nand/spi/core.c +++ b/drivers/mtd/nand/spi/core.c @@ -1280,10 +1280,16 @@ static int spinand_create_dirmap(struct spinand_dev= ice *spinand, /* The plane number is passed in MSB just above the column address */ info.offset =3D plane << fls(nand->memorg.pagesize); =20 + /* + * Propagate the validated PHY frequency into the dirmap op templates + * at construction time. + */ + /* Write descriptor */ 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 +1300,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)) @@ -1744,6 +1752,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 PHY + * tuning iteration. Only saved when all ODTR templates are + * valid so spinand_configure_phy() knows ranked fallback is + * available. + */ + if (spinand->odtr_op_templates.read_cache && + spinand->odtr_op_templates.write_cache && + spinand->odtr_op_templates.update_cache) + spinand->phy_read_variants =3D info->op_variants.read_cache; + return 0; } =20 @@ -1922,7 +1941,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; @@ -2014,14 +2032,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: @@ -2050,6 +2060,178 @@ static void spinand_cleanup(struct spinand_device *= spinand) kfree(spinand->scratchbuf); } =20 +/* + * spinand_try_phy_ranked() - Try PHY tuning on variants in performance or= der. + * @spinand: SPI NAND device + * @mem: SPI memory device + * @odtr: true to iterate ODTR variants, false for SSDR variants + * @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 unti= l one + * succeeds. The fastest PHY-tunable variant is chosen regardless of which= was + * pre-selected at init; 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_phy_ranked(struct spinand_device *spinand, + struct spi_mem *mem, bool odtr, + u32 *tried_mask) +{ + const struct spinand_op_variants *variants =3D spinand->phy_read_variants; + const struct spi_mem_op *best; + int ret; + + if (!variants) + return false; + + while ((best =3D spinand_op_find_best(spinand, variants, odtr, + *tried_mask))) { + *tried_mask |=3D BIT(best - variants->ops); + spinand->max_read_op =3D *best; + spinand->max_read_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_warn(&mem->spi->dev, "%s PHY tuning failed: %d\n", + odtr ? "ODTR" : "SSDR", ret); + if (!ret && spinand->max_read_op.max_freq) { + if (odtr) + spinand->odtr_op_templates.read_cache =3D best; + else + spinand->ssdr_op_templates.read_cache =3D best; + return true; + } + } + return false; +} + +/* + * spinand_reset_max_ops() - Copy op templates and zero max_freq on both. + * @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 + * PHY-validated; zero means the base rate applies. + */ +static void spinand_reset_max_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_configure_phy() - Negotiate the optimal PHY operating point. + * @spinand: SPI NAND device + * @mem: SPI memory device + * + * Tries the pre-selected variant first. If the controller signals that + * PHY tuning is not applicable for that specific op, iterates all remaini= ng + * 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-PHY mode. Devices that + * support only SDR skip the DTR ranked pass entirely. + * + * PHY 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_configure_phy(struct spinand_device *spinand, + struct spi_mem *mem) +{ + u32 tried_mask; + int ret; + + spinand_reset_max_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_warn(&mem->spi->dev, "Failed to execute PHY tuning: %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; + + if (!mem->spi->post_config_max_speed_hz || spinand->bus_iface =3D=3D SSDR= || + !spinand->phy_read_variants) + return; + + if (WARN_ON(spinand->phy_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->phy_read_variants->ops); + + dev_dbg(&mem->spi->dev, + "PHY tuning skipped for current op; searching for best PHY variant\n"); + + /* Pass 1: try all remaining ODTR variants in performance order */ + if (spinand_try_phy_ranked(spinand, mem, true, &tried_mask)) + return; + + /* + * Pass 2: switch to SSDR and try all SSDR variants in performance + * order. + * + * Only enter if we actually have SSDR support and a reconfigure + * callback. The hardware is still in ODTR mode here so no + * configure_chip call is needed to undo; just set up the ODTR non-PHY + * fallback and return. + */ + if (!spinand->ssdr_op_templates.read_cache || + !spinand->ssdr_op_templates.write_cache || + !spinand->configure_chip) + goto use_odtr_non_phy; + + if (spinand->configure_chip(spinand, SSDR)) + goto use_odtr_non_phy; + + 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 bit positions + * are clear + */ + if (spinand_try_phy_ranked(spinand, mem, false, &tried_mask)) + return; + + /* + * All PHY attempts exhausted. Revert to ODTR for non-PHY DTR + * operation. If revert fails, stay in SSDR =E2=80=94 a mode mismatch + * (ODTR op templates on SSDR-mode device) would corrupt data. + */ + if (spinand->configure_chip(spinand, ODTR)) { + dev_warn(&mem->spi->dev, + "Failed to revert to ODTR, staying in SSDR non-PHY\n"); + spinand_reset_max_ops(spinand, &spinand->ssdr_op_templates); + return; + } + +use_odtr_non_phy: + spinand->op_templates =3D &spinand->odtr_op_templates; + spinand->bus_iface =3D ODTR; + spinand_reset_max_ops(spinand, &spinand->odtr_op_templates); +} + static int spinand_probe(struct spi_mem *mem) { struct spinand_device *spinand; @@ -2072,6 +2254,20 @@ static int spinand_probe(struct spi_mem *mem) if (ret) return ret; =20 + /* + * Negotiate the best PHY operating point before creating dirmaps so + * the validated frequency is available at dirmap construction time. + */ + spinand_configure_phy(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 ec6efcfeef83..50a8319cf11e 100644 --- a/include/linux/mtd/spinand.h +++ b/include/linux/mtd/spinand.h @@ -791,8 +791,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_configure_phy() to iterate all + * candidates when the pre-selected variant cannot be PHY-tuned. + */ + const struct spinand_op_variants *phy_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 Sun Jun 21 23:24: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 C769E3D47A9; Thu, 18 Jun 2026 07:39:29 +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=1781768371; cv=fail; b=CoA9LmxWv/OS2guZInkXIK7xYsgG3we76GO/310uLxa8n436rpDX4j+Edv8YVD9Ktv/nKpAuzkDmz1lyy182f416ZA0FHY3lnUTp7RSzWarFBGgxLgB0hdlMFAGuxblGjuNOvpvv5rQ8a7rrmioNV+epXZ5Eufl+9omAMvbFln8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781768371; c=relaxed/simple; bh=X9JsfKDqTD0LifOzb15y1NLc84C2UsjYDOcm/3iNhlk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=LTaUgolNgvjUZjP2Hn1r7FIYTuJEK1s/pWWtJk8HeOD0hRERo/oieGtmKEEmVhJkYEdeP9coNKoji3jSBAQE7fBDJkpfS7NqVTQAtiTyUNaQcQQGkYNNTWddZqT/63Ji09ykGEACRnWUgMLD3S/BlxJY7GJZx/BjsWNdRp/gjT0= 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=H+LftAUR; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=BjWF1b8Z; 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="H+LftAUR"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="BjWF1b8Z" 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 65I7J29h1333653; Thu, 18 Jun 2026 02:39:19 -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=/B7KVUPS93KmLsKww0HkBCyppixp+5ieSO8VEOMMD fQ=; b=H+LftAURwtnV2tV8h+eHVnB9/Yy50nWPD79GYLKJMtqpuObkQM5watblO Zdz/sCuhaX9QS+NwSw/Kgwpo/HT4UFwwdCUQzdzJyl1EQkJB8NPmYDxbIJ81OHXm QCkoNQ7ygeddermpyb02p6pY62YDwOhO/XcOtvue5Dh+kUk8jZVtqmJIStrlea5g Ec7zjTwP66+Qi2xFYz0p/biivpWOUNuKZ75eF5EHMJOWPwrikkbhUGMkuJyoqa5C c709A8HeyF30WyOONXeSghzs99Ya5JSzlIoTYx8D5uXOJdv0My3NEB7YO4VZsUpn oOocIMo37Zk9OWbe8BYDzYXJTJrtg== Received: from bl2pr02cu003.outbound.protection.outlook.com (mail-eastusazon11011042.outbound.protection.outlook.com [52.101.52.42]) by m0384305.ppops.net (PPS) with ESMTPS id 4eutvept8n-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 18 Jun 2026 02:39:19 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Iekzvq8NNSyk889FxqdL/g16mu+M6vf+KFlMFIAyeHISRKE1ykAyMpiqd9ZrFixiiHkfzbbbVmU/EM4V1w+i5mVfPCcxlIUdZlByKBfFWQMi3Ik0leGW4KaRHlRF31nFrxUhQ/SaCtR4rU5hOOaZvM/ShyNd0iiYspn6CbkiqCAGh8C9o4jjAaRj10VJZWzgoBEaK7W8lPiycszCy5vAczT597T7lW+j8ZyZkZ/hxLjy8Z5JqZvguknfJ4IocWdjJLtiN0843Fm9QLkN4NCRY4SBUFEm42V1TNyKTMPwcgH8yiY9vFqdvEybXhWq38RGY+EP/5ICTLizBH62h/l40w== 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=/B7KVUPS93KmLsKww0HkBCyppixp+5ieSO8VEOMMDfQ=; b=H2VbGYoUJsMx6m/ydrGet6XW48BnbUhKHTmiCRRhYQsJUaM6tmNn47Th8RfuQTEGWPe6tZ3mHr/CItj46rRZXf+PjRh70aC6ayfJC8WeU60y7MaMc2TU/AyLSkLod0O3SpAqZJK8eqdAGD+KPOfSMSbMjR2jWOrCa39r4YsfILpbDJyCLbc44TUsbyHHCufaBJXtLeMr9deKvdpCu4JdOOutXqngRzfD7LkyW8QZscMPBSiIBbhbgNIw/UJdd6hLoDOmu2Q0Beehsu5vCk0zsQWAC07w+4grZQs502ZHfMltnKOi1IJ9dS+ItWMLzPsVK8QYRsuv8udV/hZBUcTjKw== 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=/B7KVUPS93KmLsKww0HkBCyppixp+5ieSO8VEOMMDfQ=; b=BjWF1b8ZhjZ8snTYRY58PwZO7tdvIg5M6r5uK7ky7dxvtoHcscnvK+A8IR6qHivDjlh+U5cg0hDMPBLotyXcRvAhWAGwqAsiolSDaDt5xyPSAIUIAUaGZl1D7O6/pLju4iCKihRdroM9AAi7fDLNfeUYESXFHNCkLgefaDzsmoI= Received: from SN7PR04CA0191.namprd04.prod.outlook.com (2603:10b6:806:126::16) by SJ0PR10MB4493.namprd10.prod.outlook.com (2603:10b6:a03:2dd::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.139.11; Thu, 18 Jun 2026 07:39:14 +0000 Received: from SA2PEPF00003AEA.namprd02.prod.outlook.com (2603:10b6:806:126:cafe::65) by SN7PR04CA0191.outlook.office365.com (2603:10b6:806:126::16) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.139.11 via Frontend Transport; Thu, 18 Jun 2026 07:39:14 +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 SA2PEPF00003AEA.mail.protection.outlook.com (10.167.248.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.139.8 via Frontend Transport; Thu, 18 Jun 2026 07:39:13 +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.37; Thu, 18 Jun 2026 02:39:12 -0500 Received: from DFLE205.ent.ti.com (10.64.6.63) 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; Thu, 18 Jun 2026 02:39:12 -0500 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) by DFLE205.ent.ti.com (10.64.6.63) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Thu, 18 Jun 2026 02:39:12 -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 65I7bYvq3521710; Thu, 18 Jun 2026 02:38:52 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , Subject: [PATCH v4 15/16] mtd: spi-nor: extract read op template construction into helper Date: Thu, 18 Jun 2026 13:07:24 +0530 Message-ID: <20260618073725.84733-16-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260618073725.84733-1-s-k6@ti.com> References: <20260618073725.84733-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: SA2PEPF00003AEA:EE_|SJ0PR10MB4493:EE_ X-MS-Office365-Filtering-Correlation-Id: 67bd035d-9d80-427e-58f9-08decd0cb165 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|23010399003|82310400026|36860700016|376014|7416014|921020|3023799007|56012099006|22082099003|18002099003; X-Microsoft-Antispam-Message-Info: +divZIi4/mEl6QJIzR7F7j5PoMmo1u7xsLwvq/z3jdUI5SBSRVoroMgbvlhx3+KrFEQCDsvZgeUM/21VZjZDCC001vUO3nswkpN04BSSyL/cvYCjDlEHjs3bF99J02APz8xXMAlTDl7GIR22PGEw0CCgl5ZY9xHnmgXXLeVi3n+19kDAwcTM2VA4xrVuk9MUlLhAjkxg9NkmfEktcdpWcWqOxIJ5W1zQSGQX6sPdBKCSt7e2qzpc3T4aC50OGYa4TLdPasEYMXKfejybKqQpTqWUz1bg+1PjzlNY09bjqhW3dykX6xNqqPhL8MZKJqnkLAESOQRPLJFs3Kkjx3wA70FjZysl+mDv+Zt/ORVqX3fl+uaq8Wp+8NX4agin7eGROHC/8AUNNgkLtrqWRDXG33YpxcqiDSu6PXAhyF69nON37NaU3ZNtek0szN9JaOfPteATdSDjvEYy3FuZZfEFxYdxL+cwhYI+A61ex7NpQ8SECtToEYXUu8j/xxWgJg5KaM/+eEQh0F+AnAQ5Te8rZB+KPOmWjA+JfLka7iDG4BJnPb94Ebit/sTi6pNonvpZF8t3x/ejrTa1ivy2tWlq0VdXWr7Pln/nR+/MSCEXyTKE1i76b47RWO9CoduCZDItLEpy9dq0Ewzq950DKPMj5bRpB6EBpk9pXIwLx5iS+6gC4DIwxxpH//RykhthS7c1vjLg5gk/Mtbe2JC0Xwksaug3ax53h8oOOTuUV/eVTrrdlZtoltxoKAqES8BoWnjl1gIrH3DOCMqM/qzFoTF0Gw== 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)(1800799024)(23010399003)(82310400026)(36860700016)(376014)(7416014)(921020)(3023799007)(56012099006)(22082099003)(18002099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 6zb8QPhom81wu4ch5fLhPPrm+vuFxfbRbhyN8qz9CON3AFO1jIadWjE7T3iFh1kRVLwYcPxwvvJLz0gPR+qjlIE2HLEZM6tRzKrmW+rL5g1v9iifg5emKc8Q+w56FypnhVLUhdZfs/FOaDuN3h6QOaX3XEWTVm8Zd9M2RYQmAiWroqy+iOzIgzLc9lwM90sIFey3UZFJ7PAxgK19n1r+4gUoQneiwbjRk4UFpDXxZ16uIwADvOAfI/P3unfiz8uLUsXStSpe9q7A/Tl/54rd62/xuxCKF/VGqRvK9JIHSMnrdVwoy5wahruHxhDRtiaFtUJhzJFpe3OpZvi1Uq54wgF2cTLhk5AVbrsWC/IugGpPKpkjq2NtgrHPRyd69O2CgIls4FhVOohQIQm2tFnYVgHF1dS+D2r3eNeCt6KjDxhesRHPmLw29bYEeyxaH801 X-Exchange-RoutingPolicyChecked: m4kTg8L/e127n8qo9RU+Wekq51l6yZLTC/lFVwQbczhjpeFj8lbY3M46/lz4nPleP/jKZrAdv5UouDz26H501rRGlx1vsqxdlRvseEyMRSIwMHDjEFNCEYiuaJxd91kl9G9q41c8h8WUDP7bazNr1sjbumzmNR4ztF+HzYXxKagbJnVa4F+aloG36RI4584kswf1Zx346hbu4CKjEehrUz8RPfK0x0x0A5fWIQucyjhyW05vsbzkptlkwtRjxiv0BfcApiEqhohRbk3Ogd1vwIHyOnpiSu1zvnoANFsFZ3ac4JITXJ49k59xsmpM68xXuXBrBzxVFDqWp0/Eia6g8A== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jun 2026 07:39:13.2003 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 67bd035d-9d80-427e-58f9-08decd0cb165 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: SA2PEPF00003AEA.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4493 X-Authority-Analysis: v=2.4 cv=PtOjqQM3 c=1 sm=1 tr=0 ts=6a33a0a7 cx=c_pps a=zXfEoyyUBsLHcbwyVEaNwg==:117 a=tJyPKKxUohctrY4NYmUjkA==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=FelO9ux0wxsA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=taLDd7a_hP9WKsMzeGRc:22 a=VwQbUJbxAAAA:8 a=sozttTNsAAAA:8 a=XAftrYwPDLqUVEEHSKEA:9 X-Proofpoint-GUID: tEYk6N3K7igcHkcwlTPHzOhNReusP587 X-Proofpoint-ORIG-GUID: tEYk6N3K7igcHkcwlTPHzOhNReusP587 X-Proofpoint-Spam-Info: AW1haW4tMjYwNjE4MDA2OSBTYWx0ZWRfX0CHF9X4u3+R3 5FAv7M/RCc2UL5uQ7DVL9Ul80Sw2o5r0S64ZCYigTHDROvrNOCkCMPeM5Ogkvm/GG7/aFbSMEZF KmjncLQws0K97K5415vfzpxuT9C4KEM= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNjE4MDA2OSBTYWx0ZWRfX/Ls6zX33q4hn PVra5n803EnAgjiZjuLIdt5TWSw4hi/AHEcdO7Tk/rTEovGkgZnFMEGb5Vd/svURg5zAt1XEFj7 3tONVUAfXGsCfUNL11WhpTtd4uRex6iKPbr1Zus84St8HcJNGgpSPGD7XuBSdREQrsHAAV65eug U4fXzmct1vbt7x/HdeSOZTjB3IctdiCnhz+HhTVEmEg6Hzw7ClwIQPIq3uhH/rD5LqTfGNUwtKL VM+R/pNfu1WGdVZULNQ5C2uu8gOEiPkrdmimc5Zi7sLLiiMcM26yo0GJsSYLSxXE8/PePzC7Chz 9UeoDzcr0u6TvqTAwwyWmhHiMkHsT61XHf0GHD/zaDXeo1brE1WcioJAFgFVAbthOrxVon/YtpZ COOvt+2YgmcmPWE9ftKSoy3AkMd6QUcjNfy4XB/ZfNwrB+8YnASC4V9tBzG9TyL4+M5whZXvweM VxZW0gG6J3bs+tluJCw== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.125,FMLib:17.12.100.49 definitions=2026-06-17_02,2026-06-17_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 impostorscore=0 priorityscore=1501 bulkscore=0 clxscore=1011 adultscore=0 phishscore=0 lowpriorityscore=0 suspectscore=0 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2606180069 Content-Type: text/plain; charset="utf-8" From: Pratyush Yadav spi_nor_spimem_read_data() and spi_nor_create_read_dirmap() both open-code the same sequence: construct a SPI_MEM_OP, call spi_nor_spimem_setup_op(), convert dummy cycles to bytes, and adjust for DTR. The dirmap path also needed an explicit data buswidth fixup because spi_nor_spimem_setup_op() skips buswidth when data.nbytes is zero. Extract this into spi_nor_spimem_get_read_op(). 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 Sun Jun 21 23:24: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 8A8FA3D522F; Thu, 18 Jun 2026 07:39:32 +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=1781768374; cv=fail; b=QMROVzRMRcIDfwanktybj31wef56xmq/gjmVNHhvt8Ssp4Im31XRjdMukF2fkc3avm0QHxrrPw0hlTtBogr9JF3PGELtjaPEIdjGoFbh/zLBRtzp3rCuet7vkVw7kZuLtIYROJcTkGEMbV1ZyxHcAd+2Ja15+V4mZuAzTtHHRu8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781768374; c=relaxed/simple; bh=hctqAfgoMyx82vfFDJZA/RKasIcOLJgU72iJK9bfuss=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=gmvGuKiz1Hg6lp5qmoXSxTDA/YsZxccbYVuysSz/JSpV89a5xNFaL/iYbVfcAMzyaa/0EpN/A49hb8iE6mUVrpwX8yb4qmcf0xcuaTtwVoOKlwO9A2goE9U6QVCELhXn3yXBV83c4am25zieHw6XuUYMg+GyhnhAmO3K/dnuoQY= 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=Idwzkjrl; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=gTAgzWCN; 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="Idwzkjrl"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="gTAgzWCN" 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 65I7WrjH2383810; Thu, 18 Jun 2026 02:39:23 -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=iyiB4E7JuWAgLkxJkRqXBfyZ5lxOKjiebvcEXuxoH 6c=; b=Idwzkjrlx1WsL1Ci4m4jH+BEjWQIdSUigWVEZTg/XF4pr/h0gNh1wRWWu YiyHJI98SOndWcgsFBlJeGN4YDA3RBjXw6oLc1cp4mx8KfD4J0ht9G9hFfx8LJ0P O1qLwGm5p5r4cUgK01xzmS0zgxwgU025f46jF2dFpb1FkiShpwkxX1pvmE7JFMQT 7Z9qgD46dJnOUeYA7xToP9CGXdSmfWlSadsJdM9gkjbOdHZ75bjXTEJ8Bl8mICJY e8SwBJsS4vNuEJ5d8wupx/06Kxd6BBD0d3lO5p7g+3c+DraYPcpnpoys3a0Q3H8k kKNGLJy2zPvzx4Re1MDFU5bhiAHFw== Received: from bn8pr05cu002.outbound.protection.outlook.com (mail-eastus2azon11011016.outbound.protection.outlook.com [52.101.57.16]) by m0380145.ppops.net (PPS) with ESMTPS id 4euthp6s7c-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 18 Jun 2026 02:39:23 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=WvCg3ZpiGwHguqhBddeQaSjjtw0W1Vp0VSO0TbfleaK86lYEygn0yPIdin4myRF4aGMCRNn4/d3aDbI0eQJnz5dAASMNcvBdk/XBVjvbqJ7GxhdtnJi6h41FRYupQzXHgGcqmml0qp2sPwJdvel3wKxLOx0GCTHkHaX3YPtMUP5ctOsJizBMa1D/jSx3ENhNf83PdNjKC/Tc8xDCPA7FJeZDwGHm94abrD/yUTkwhSQEBzvYQUtdugjUXPSFFUoTJdKvMzMnONSh18drw4jQIY931vs5fAiEjVDIkJCeNUgdt4y9msjbTsBCTcspIC7PhzJW3pc2e9WUgP0iI2JXKg== 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=iyiB4E7JuWAgLkxJkRqXBfyZ5lxOKjiebvcEXuxoH6c=; b=fd7FZDovDASuxI2S1U7z0UCTZH/nW45ipsZ1N2eI+y41/qPrReGZPOk+wHrs3pSDGZTsAo3x1ddyvUEmbtTZmkZgbeG/CD9lUhvjoeNU0rgRFIPJiTP3BV2qSM9jRynIzamQBZ0B9bxEyBHNKmbI6NzB1L6tS+Xh+Ueg5h9uqYJVtKrpa9fmkzjLPvLjAJjR6R1etWFwey85PUiBvvNRiLaD75/2UEkb92ew3eaSEI2XrNVKld/ZU9dbTCzefWuxtspTPVhEvwqKarGmJfB7t9D+TK/a9R8uLTrOL72+sJGuhSQ4wfFa8v35dDBh0naQJUiB+BWDfwWlD1LlCIwa5g== 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=iyiB4E7JuWAgLkxJkRqXBfyZ5lxOKjiebvcEXuxoH6c=; b=gTAgzWCNmP5jAksonm6icXD2OjyeMlWa2EvATX6VE8Nte7YWp8LKKFa2OdWE2t1svyETrLxVktMnATqTtrKy8P4W4ZoXCrY6D8DmYpy1WzO7aLYFmzYauTOmZKaGjM/G3bGJhPUMNaX50jSRUXsAMU59v06ttpJBATWSap0PJVY= Received: from SN7PR04CA0200.namprd04.prod.outlook.com (2603:10b6:806:126::25) by DM3PPF9E376D9DC.namprd10.prod.outlook.com (2603:10b6:f:fc00::c3a) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.139.11; Thu, 18 Jun 2026 07:39:18 +0000 Received: from SA2PEPF00003AEA.namprd02.prod.outlook.com (2603:10b6:806:126:cafe::3f) by SN7PR04CA0200.outlook.office365.com (2603:10b6:806:126::25) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.139.13 via Frontend Transport; Thu, 18 Jun 2026 07:39:17 +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 SA2PEPF00003AEA.mail.protection.outlook.com (10.167.248.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.139.8 via Frontend Transport; Thu, 18 Jun 2026 07:39:17 +0000 Received: from DLEE213.ent.ti.com (157.170.170.116) 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.37; Thu, 18 Jun 2026 02:39:17 -0500 Received: from DLEE203.ent.ti.com (157.170.170.78) by DLEE213.ent.ti.com (157.170.170.116) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Thu, 18 Jun 2026 02:39:17 -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; Thu, 18 Jun 2026 02:39:17 -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 65I7bYvr3521710; Thu, 18 Jun 2026 02:38:57 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , Subject: [PATCH v4 16/16] mtd: spi-nor: run PHY tuning after init and update dirmap frequency Date: Thu, 18 Jun 2026 13:07:25 +0530 Message-ID: <20260618073725.84733-17-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260618073725.84733-1-s-k6@ti.com> References: <20260618073725.84733-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: SA2PEPF00003AEA:EE_|DM3PPF9E376D9DC:EE_ X-MS-Office365-Filtering-Correlation-Id: 65864a0a-eba8-4dc7-fc2c-08decd0cb408 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|36860700016|23010399003|1800799024|82310400026|22082099003|18002099003|3023799007|56012099006|921020|6133799003; X-Microsoft-Antispam-Message-Info: CkQ5j2SdcaEQCf0zNK/cSgn4suY0IBgzacQ17NvLRwRsPiYVKSajCGEyEghtaCptu+ZrSGHjTs3PgfR3YKyerivJjgu9RiNdfZaSeFW94auXaCsPSehX7B2S16SwYsCmk5Id4if7zw2mXpL4iIOvyaKqk2BjBGcM+X5jmGB0M9SIws9IJMeAgXXgr+119BIQEs/xw2mzjW6LG+2zhWjLreCpccbg26KPW5hMKqKHT7xWCZ39FAufqGMorSxchl+A9NKmYmSWIQFWDjiBhScr/NKP3UIGDcsE4LtjgSFh126opwlgRzqBc3MbcrcHgAqE4n38IiMph46teOJnAXLo+Xv0pUif15xeK3iHo5I8nyneyBZ1d1c6/m1noMGK5Kq2EJE0PlPxiiud7DUC7UkyWl25z5YOD+feXe2JdF5xX/TKhue21e/yaSEXGiQgcBGi8lJr+TUNjpVu2zQ3obKuQymhPuYmbUtmCqH2szJ/mxrb/iE5vlhwc5hVKQruhwVQOpRI79JjyGtekC9vJ2exR/XPVBB2z/WaVZ6CNXhGtZFYbPofTPRYGE01/GJhHh70jUsPdXLFhDc0+1m8tkDvmVh/GUBiLg6jMMcTPwovGu1NDQyWCNkGXOC1bR+8JsanzS1VbCX1ID8VfCV8kDJwPPFkyqA0NH7PXpARxkRj4XphMc50hCWp4A4VYgMqS+2Ko77VmnftdMCuh/jb1AynKPg7fdEA/dK+yTly0DKrnsfuonujFkiNmCLaeGH5Ip/oc9//eYcuBw+gCm9cPG+WOw== 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)(7416014)(376014)(36860700016)(23010399003)(1800799024)(82310400026)(22082099003)(18002099003)(3023799007)(56012099006)(921020)(6133799003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Fb9PZhqaV6bfAGyFyCpeutbasmeJZfHLCjWxf/dQHvEOtEeMqQtQ3tgUp0m1KpdQCrpg8vk7RN4guf4KGfM+p9WPE57WqRL+h/Andu9bUu7PGiFJMqXum9GV50Wsa0/G65oWSZlZcG2OErTNnsDFh3mcXqVeEPRtAGNbAAcC21RuOaIVvYUfun2xMjF36upbKOSeJJHbVFbMCRFJeAsl+z5iohMvoH3CjHvfmPp5nSrOovlyzkEtQ0/dZsTv8fUT572x4L7Xa1TN259TtefnwCg02CQndxr8vTvp9EAlsIkBkHCw7x/4QnsTcwXqXz9u8vb4l8KbLb871SEk04Fer5r8aTfCteARSo0+mgPdVgl2vFg0zRiyKqbZXriR/LCuM1bYQHWo61w/JGYdIaXfE+icdWwwW8f6vqPi4Vig2j+gEGbyYSZlW3ZE+l1Psj+w X-Exchange-RoutingPolicyChecked: RNPIGTT65IoO8IZ1gYCU+/PFowFUhdPsAa1eATaBswVHoRiZjqp0lCQ/kSiN1Q+Gtnky4UB95NaPK2GfXaKR0Ett2V/sOul66P5WerK8Pb9PqVdGmvvFrTkovicuHHlsNGf5zMlDQZQNZWagDfGQvutPbXrxgYlJCHgdhimf9FNl1pJGDK0MV5PPy15/BE5AQ+8V8sbi8bf8rBrlMI1BKOHRVIctDOKsATlupBgqUgqwCD2s+fcTwxhyJUo0by1TiE+b3aYYvQXR7NckKxQ5BlDNoCqK0QafP1sLPlZ37KJImLoZh3fsat0RS6mdhJC1IJKndZeotNoxHqk3IVIqQg== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jun 2026 07:39:17.6322 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 65864a0a-eba8-4dc7-fc2c-08decd0cb408 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: SA2PEPF00003AEA.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM3PPF9E376D9DC X-Proofpoint-Spam-Info: AW1haW4tMjYwNjE4MDA2OSBTYWx0ZWRfX/8swKwp7hmS4 RJoA2iGlA8ntWeZdCSpeNWmRHDV2XyL7KNyVhZn5b71hWjIHYt2K9ciaNgByZ588Q9o+MsCZmQH yZGkdz6+PYIjPA9F6Rg8YSLnKjgj0dk= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNjE4MDA2OSBTYWx0ZWRfX22J5f7mIdK8Q 5ZPeOlZFptZwssHDrn4MYqSRhyr6U6bqgDpd4SNbPcrNdpggfxRfFiVEeYBZDpokckK9oMiS1D0 oVF6U0tUFFMtO9NJAV7KBTwDa8a7zjsnBvCM2GjoCBxHAPTlN9jQcuc5GtSGdQaU5nKHgKUgqY5 R1UfToI42Mobj+H4FByn9vN5Dj+dwwkylc1/CqcGBU8RdXBsmXZCXSH9cmZPJ2cvbhd22aoDEZU YbatT3O8ll5tW37vY/kaYbTQE+lL+aLaPoksuPrE9+8+MAlObYr229clQEE09Ew8pRvJV3rwI3Z 9i5/byra8odr1fv5WYzXsbOf+c40dEjfUvDvPI8pe3kPXF/xtBop3P0RUX9p9K760yxUKJbwk4T 2XWKOm9N7CpU1FHatdyhrxldUF8qBEX5ECoMONVbN2xpCbR9rYGM+iJVtyErc5PirR8hEiREjyd xeasENqv78Xg2D/DPwQ== X-Authority-Analysis: v=2.4 cv=N/wZ0W9B c=1 sm=1 tr=0 ts=6a33a0ab cx=c_pps a=TofqhMGnQVwdh0HkHXulOg==:117 a=f+v6EHfkeJbVwR46tk4DMg==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=FelO9ux0wxsA:10 a=s63m1ICgrNkA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=gO1vWkAQAl3rybz1DQOp:22 a=sozttTNsAAAA:8 a=dAWDYLcBFR4q-bF-ZFAA:9 X-Proofpoint-ORIG-GUID: CBRGxJNQjtTS_vxMAs2ov97uwSYT1N6P X-Proofpoint-GUID: CBRGxJNQjtTS_vxMAs2ov97uwSYT1N6P X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.125,FMLib:17.12.100.49 definitions=2026-06-17_02,2026-06-17_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 bulkscore=0 spamscore=0 lowpriorityscore=0 adultscore=0 clxscore=1015 impostorscore=0 suspectscore=0 priorityscore=1501 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2606180069 Content-Type: text/plain; charset="utf-8" Run PHY tuning 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. Tuning 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..a2a2cf3d3603 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_warn(dev, "Failed to execute PHY tuning: %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