From nobody Sat Jul 25 04:54:27 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 DDE363876CE; Fri, 17 Jul 2026 18:52:09 +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=1784314331; cv=fail; b=Fg7S75uX9b+PRqQ755G24Q4WncZSuWfjssvzp/V+/cqxCFOmWWEbxN7R7KGqGHCN5ebn7GCc8oBcMDoe/yho1397fQJxYupqNrfEkpaoWqjYr7KweH3jYav30VwOaxh5jhZb83QG6dCLThtbwjMj3BRDWf3WzaiCQRk5F6orPFs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784314331; c=relaxed/simple; bh=ttBwH70sqy/txKZTDc6BvDC5Fo49FbOnLDYVolU0gEc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=C/CbtDr4dsVSgczhmKHR797nQ44ywENszkPfyyGAqOro5Aqj7N3nNNsWvPhtv81IdTYMtKLN9E1roshJCY8eyiZsDjZjuVic407IQx03TW2ef2xEVtz5G+O0YIU3qkE8kueAtLwuaWUeaEPzUuzapUrMw9uc3MUnpLg1lVh6Hao= 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=Rz5unEAm; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=onFda8xz; 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="Rz5unEAm"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="onFda8xz" 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 66HIlFO63222589; Fri, 17 Jul 2026 13:51:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint-05-2026; bh=tAR7iq+VvMXykEbHa93yZVIqmDwvMwzOdF8NwxZut BE=; b=Rz5unEAmS3SqmL2OB05y7r47QHIEBGykO/r6ESHUTVqsVHpNJ4MPJt6Q3 PhIj60NIVgfbqf0CrsnGfKqbqysQP5xV3cO2BWlCbp/AQbTctHcgGU83OJ90PnB8 ak0P9CbhO0HxmfyNFMGvYM3UHmPpi1fsZMSKrPbrlT6zSWKPZlrOa1/oKHcC4fnN vTSAUqUL2V7zRsfFrSFwgvJNbBs763ksFK8dK4NG1H7CYE7HqFWQ+Q2KMA1Kin92 J28kUKKvV2YP/vAXIw7dxCC+HA8x22Upxffey80llQPv459oksx2EyR7PepFXG6x rLve5TrJkJWN5Da0SpHsxD2dBsc7w== Received: from sn4pr2101cu001.outbound.protection.outlook.com (mail-southcentralusazon11012001.outbound.protection.outlook.com [40.93.195.1]) by mx0b-0002e601.pphosted.com (PPS) with ESMTPS id 4ffkc3jtvn-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 17 Jul 2026 13:51:47 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=D5JhMLBwPVJ14+fulfIC2NtRt4MlwxH+AHUhEFhTGPqGwOTuTYH71OyoIVZYSkkZAPYRA5mjnKHRSoG8eeYiW9DSWJuvzuOuox5ca4+F5heBrx/drEBl5vnh0IQ2A+Swz5imvwdsAZj+QMDvtaP0IrPm+u6JLNu3q+y5j2KPv7WZsTBBouPcfxgMXtntO2YqF1IWqP536IEVelz83j68FqRLYOaL7q1hy+SpK8n/V+F2dgADynbAesaz01hI4SQSxQOmB8tWpsu8Df9uG9Lpn5hS/zKxwxSAx5be+hg8IGj0mCTAGbTt9WHWmR+IMnFCRvJU+PH9TEbauCRjM9DVRA== 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=tAR7iq+VvMXykEbHa93yZVIqmDwvMwzOdF8NwxZutBE=; b=bJx4/N6YT4mys0MeTO5Ug1zb1YoSFRIpmg9jRnuI/hP2/51Al1t5/dccxVnDVNutIqaO0ClfqzlXH7Z/0i6TB6qS2ryYriU/5Z262sqDyKj6aKMcmJz5IoLeWBswvJPt1Lwsb1WZECYbr0IVRJDscPmFBGR3kAg/CDA6xE5avUtzMK1OLe+Zc0lCGBXzIY6c9ydx/21oAaAkoLPDJhemT1SCbgXI/IoBGr17oQMS7/KPLmL8xZMIxsfVamoqr9GtmWvD6prwUdNpyHF1XuedI3sxEgpbF5E9WFFYjFncrb9RJXRK2qmZSAKRi12TOWHtSyeLbLwbFJz3YxLD+FMNSg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 198.47.21.194) smtp.rcpttodomain=microchip.com smtp.mailfrom=ti.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=tAR7iq+VvMXykEbHa93yZVIqmDwvMwzOdF8NwxZutBE=; b=onFda8xzEa+3viDXxDuzBNL8hhMT4VNc/ZpmGBXfDfS4Srg5SPcrLqGcWVhiI8fFliyWM0vIW2306HsW4eOL6L3bKZENGt0shYAJTSwVGnFHHY2mie8FWTnQ8+JEzFMJ5leAjxOpOOs+9YEMBD64ocL3eOGlPi9nm6MtOuekcdk= Received: from BN9PR03CA0201.namprd03.prod.outlook.com (2603:10b6:408:f9::26) by LV3PR10MB8108.namprd10.prod.outlook.com (2603:10b6:408:28b::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.223.12; Fri, 17 Jul 2026 18:51:44 +0000 Received: from BN1PEPF00005FFC.namprd05.prod.outlook.com (2603:10b6:408:f9:cafe::8c) by BN9PR03CA0201.outlook.office365.com (2603:10b6:408:f9::26) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.223.13 via Frontend Transport; Fri, 17 Jul 2026 18:51:44 +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 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.245.5 via Frontend Transport; Fri, 17 Jul 2026 18:51:42 +0000 Received: from DFLE208.ent.ti.com (10.64.6.66) 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; Fri, 17 Jul 2026 13:51:40 -0500 Received: from DFLE211.ent.ti.com (10.64.6.69) 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; Fri, 17 Jul 2026 13:51:40 -0500 Received: from lelvem-mr05.itg.ti.com (10.180.75.9) by DFLE211.ent.ti.com (10.64.6.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Fri, 17 Jul 2026 13:51:40 -0500 Received: from santhoshkumark.dhcp.ti.com (santhoshkumark.dhcp.ti.com [10.24.52.55]) by lelvem-mr05.itg.ti.com (8.18.1/8.18.1) with ESMTP id 66HIpU4l240969; Fri, 17 Jul 2026 13:51:35 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , , "Conor Dooley" Subject: [PATCH v5 01/17] spi: dt-bindings: add spi-max-post-config-frequency-hz property Date: Sat, 18 Jul 2026 00:21:00 +0530 Message-ID: <20260717185116.2065505-2-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260717185116.2065505-1-s-k6@ti.com> References: <20260717185116.2065505-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: BN1PEPF00005FFC:EE_|LV3PR10MB8108:EE_ X-MS-Office365-Filtering-Correlation-Id: c85c9f5e-63b1-4af2-1289-08dee43471ac X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700016|82310400026|1800799024|7416014|376014|23010399003|22082099003|18002099003|6133799003|56012099006|10067099003|921020; X-Microsoft-Antispam-Message-Info: lvHRnrhN98I3m5hxRwdLuM4q0+aQh6hkCOBT2gTzBrlZAYEBVBnHgq+U+sLdnkbnW83lvlySag3/B20lDS9A9yqdJQcVT4MvcwTAwg8A+mq/GMYWF0EqtbKCj6uKYGqFZJvW6gmdujuL8UUKbX9zTNOjeUjuiVUIRIHf4HHx+YfHJzaf3JBXA7e5Qsy3Uwn5kKr87GNMNZ9huz0S8zCE1jBdf/suZwsWDSbY11pU1ubTPK/aOYd3pXiCbAuofGymUWuQdQMhWBncR/CPnMBC+s2OUyNSc1LXCk8Bw2f5uOvBcXK2zuMfEg9+CNFJS/Z1XmHvvvTPIZjD+qGfMwSlPb+r2PLYdJEg5rbolwZwp1YKXgffGRCDdk8KHGM6QpD3N1qHDIS7Mrm19R2lqL/E15LYkvWRruqbxSwUzKmT+Dkkqiym77xquqGHMwcrordWJS9Msqm7ObvtCgYuXKIf7RlMLplkCOZ4J71VlydDUBSeZXSl7aU02zxfxQHp/97htzAVJJe//G9JQHkgkLQkQ9TIe2+fSFAjqSfYt6bL826Pun3GRCt0xxecdm8h+pnjY7f+4xe/veBj0rVeuMIxc+ruSfBc+I9+DVZCng/VLnXc6tpgwT3cusL9zHj+lLKtGoaURD8g1Vd+qtjcdRQnkyeyqLURuZUvBhBX1zSJSWSjEfHuM00jGJ8CfPLkbqOOKAb8PnE5RROdmZBEwzaQ3sHYSQBq4JPWiHC4VT/EyYnvb0I2We3bmwxVaxNIXz6A 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)(1800799024)(7416014)(376014)(23010399003)(22082099003)(18002099003)(6133799003)(56012099006)(10067099003)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: nl+kqrFyC6qg/cCJMXhDnklPScsL7VO+3X3qLEkK4EQKBtbkerHKTsT7TFizndN2Xy9BIEh900zc17PZuMd3P/IGDDylRSFcCprQQbNulh7Y9+uPfzbYAVNIAt4E+Q0Xx8L8ZW5o2IOZcoQeT6OmNLvJvFLExHu5mZzT0ZilYTqi4T7TnOSZo+ur3BQQWDnUuA+GPmznRk9devTgwfebPpoKUlmCkZCczJ9doWvfn9ZOpHnFrqC4DNRyD7ApUSz1tCOYj3RBSF5TsLN2LCtkL/KB3SBIpdtsIJk1OIDzJinXa/r5vph2JCdxid44SwJwn4RHUVCbCaC0Kr/kSzKSlERpcFoMsHOVDJotprDcMwxmKF3rTuobMeW+EUEkmFreYaHnf6SRNJiEiDyCCggCj4DMfy6HDc36TsUvay/6XvzsJTl87wMcXCHNlhYuNJfO X-Exchange-RoutingPolicyChecked: Sbhp8cQJGDIMQw9LsHya2TQsZZcqje11qlWvNm5zHY8pVbD1BYnVVC+8fuEHLWEHdU4nVoOnD2L3pPlMwATmqnMl5YGIdRjsPIXhHoN/pA4O5wAFVBAbzlaLx4nCzlqdKY6GQzogRZ6UHLDXUk1tl+GkrZgERc5SmBZmiLujHUxRXSWDQ2eZKq5JfyeHoS6qkyUyrnAOUf0urGve4InN2TyMfb7sBsvUy36Qsn6tkBAc/d+EGwpso8eCimrQffMpdIDQ2akhzFyhDHSxATFjuGmPAQxvZPHydOgTFjvzn94CNdiWY+eMizeDgDsJ1I27CFCHFN+CdOvLpaDWhua+zg== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jul 2026 18:51:42.8461 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c85c9f5e-63b1-4af2-1289-08dee43471ac 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: BN1PEPF00005FFC.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR10MB8108 X-Proofpoint-Spam-Info: AW1haW4tMjYwNzE3MDE5MiBTYWx0ZWRfX0WQV1NlgJYHR r14v0P/WDWBS01Xe8A2gTk2kjrzrU6IvQvoA00SrvektMf7Jj5dKruEkFm0U+ANoc7WpA2UXEhS AHgwazFPL3IyA9s7pd4pp4XkZX+zAcI= X-Proofpoint-GUID: WP_yUjVogvD60RezVV3vpRqalJ2yOdPS X-Authority-Analysis: v=2.4 cv=M7F97Sws c=1 sm=1 tr=0 ts=6a5a79c3 cx=c_pps a=Zn3nEQaGnpTLJDFXYNee2g==:117 a=iwqwCZQqcuTv3JOpYdM7/Q==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=RAioF0-LDSMA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=jwouBfj2j3NM8CExmVVE:22 a=XYAwZIGsAAAA:8 a=sozttTNsAAAA:8 a=skPbNTvFiSR7kuR3s9sA:9 a=E8ToXWR_bxluHZ7gmE-Z:22 X-Proofpoint-ORIG-GUID: WP_yUjVogvD60RezVV3vpRqalJ2yOdPS X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzE3MDE5MiBTYWx0ZWRfXzz9g71ojn6A2 0a2Md3d29yGVKmorJh31IJWQXbPExtcpD1J7ew/cvA+Aw4YjQQ7gssZaLXpyNY60Uc5Xm9eww99 v0VjpOHQpqIIBaWP9EqvZJJ2tZtrgsYIBw9Nf8AhyQbKKwORUll2Z11Y4+SF1deZ8Upsy/EHxY8 uly8mf34JWbaaL1ejCtO2MdprE90MDso7qch+32r1NY0eS8lqYflNbj5gKOCxKswqI3LhAvjAr4 ZEbUgN3TKjMexyXlMS13uMkXiW+2lUBasqnCvRg8RAIVSy6xgtbfQZDXApZ3oIS78tVsEiiPg2c XbTor9HNTGpfLEqXqP9+EjYCXxu89SE5gp/rIxo0I9NlXggEUPL4TPkAdfS37idgx7HiRTPrpE4 JOO+I7gypCx7PodtlTPWFdHzrPm9RIvSm6xIf0pu9XJU0CuEO8vET1Hns8Xs9IEbcRoLJpoj92k mGuH3/KjlDqIseD6iqg== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-17_05,2026-07-17_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1011 priorityscore=1501 bulkscore=0 adultscore=0 spamscore=0 lowpriorityscore=0 malwarescore=0 impostorscore=0 phishscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607170192 Content-Type: text/plain; charset="utf-8" Add spi-max-post-config-frequency-hz, a generic property for SPI peripherals that operate at two distinct clock rates: a conservative rate always reachable without controller configuration, and a higher rate achievable only after controller-side configuration. When both properties are present, spi-max-frequency gives the conservative pre-configuration rate and spi-max-post-config-frequency-hz gives the higher post-configuration target. Acked-by: Conor Dooley Signed-off-by: Santhosh Kumar K --- .../devicetree/bindings/spi/spi-peripheral-props.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Documentation/devicetree/bindings/spi/spi-peripheral-props.yam= l b/Documentation/devicetree/bindings/spi/spi-peripheral-props.yaml index 880a9f624566..12211f8c9f7d 100644 --- a/Documentation/devicetree/bindings/spi/spi-peripheral-props.yaml +++ b/Documentation/devicetree/bindings/spi/spi-peripheral-props.yaml @@ -45,6 +45,11 @@ properties: description: Maximum SPI clocking speed of the device in Hz. =20 + spi-max-post-config-frequency-hz: + description: + Maximum SPI clock frequency in Hz achievable after controller-side + configuration. + spi-cs-setup-delay-ns: description: Delay in nanoseconds to be introduced by the controller after CS is --=20 2.34.1 From nobody Sat Jul 25 04:54:27 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 17C1039182F; Fri, 17 Jul 2026 18:52:13 +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=1784314335; cv=fail; b=BIhbMZ61xeElanyZ0WG21ZkWNsnslnkSTPf7qxd/Mk3D469NBcdvSKkgIaRslavBFSHyTL2yOpZ71rq95L4lkb12BFwuKuTwI1MxtJKjPiJjVw1NrUpxrwnSw72+0/M3sziK/e2zVY5oRSHXq8x3MxID4dPpYVb0fRcAVE0PSu4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784314335; c=relaxed/simple; bh=ff4xKPF92zG+UqX9X1DnD+Zr7KTxJ/jAWu6wJ/4Oq0s=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=cuq4srlqz030ep6XBxyTOnpneLEVpAM7bRf59Xs813azQ2+W2WbzBa23uzyUqcnGr3U03n6wjJorpZb3YIHeP+9i78SEHCx9vTibfLnxgCFc59GAlDh4yI6xTBfdRMZ6UdlAfRy+ZFhZvB0ndobdRr4AAhOng5ttm9hXK/62wag= 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=hETqBNAy; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=BMTQ04g6; 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="hETqBNAy"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="BMTQ04g6" 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 66HIlKJi3222741; Fri, 17 Jul 2026 13:51: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=s3F6sYAM/ogfoAVPG0gjK+a53a3vaB1nPkLfBLzOb rk=; b=hETqBNAyocRKRfO6ITFHXYg4dp+ysnJHC83jFmzTY4Vv8HQPYJ2uJv0H3 I74N+EJ6TvB3BLZOeGOL9QVsn8xhkeOzi3teb7eaBD1vneofaNvJzDU6AkKRtoik XaG5Dz1RcjjICT/w7K7sn7i7dDe3827zZ7pRppC0ovU7cSF68ExyuZznfdTsUB30 oWoISiuvJlzR1B63nT+3FfvePo1pY2mYma3UYvxj/8vEa7Bo302ZnrkVb3xzKQhg naBA8wcXngnqW7loNAnoPFwPg8wXePpMs4sMx2g4N3KXkJPcw0TVkVAq8UXHx7pS DSPkaNJ83V2tR38snEmJW2upA6Z8g== Received: from co1pr03cu002.outbound.protection.outlook.com (mail-westus2azon11010051.outbound.protection.outlook.com [52.101.46.51]) by mx0b-0002e601.pphosted.com (PPS) with ESMTPS id 4ffkc3jtvs-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 17 Jul 2026 13:51:51 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=fhwmuLhBA7YEzRouDhgLeN7d9bUB433K6bKXIl2dBTXOu0f9FTekS0tBr7xC5jilhJh4Ukx0DwP3gxuORpt/CpJ6K0DRmlXn4ehS7GV5s0eGcmMCe0KHvEb6vRICW6M9MSqcmDzGsBH77egP2X2wEOQmicoBX+WVgIJW+QY8kpyh8PLVEs6nNpJFet7ly67/vaPJFMOBw9rzf+oe+rUZrXl3NlPY+heMfRL5RcntYQd9JnhwAiVtqDc51oxYtYpeqJO7DehCZyPbWIDaFP2oeEdIqR+vwnQ61rBuijch+ZbBKmkkui7vOi+HOSd8kb3/PDMMfmAa5mc2/Gv1AJblKg== 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=s3F6sYAM/ogfoAVPG0gjK+a53a3vaB1nPkLfBLzObrk=; b=xvLJB1VwBvyhjg6fJlNQwU8O9VHcam8fKxpt/0C+PAIVUITVtqy+m6pjOjcEIo7FSzf9RhA0y2y8vEW5ud0ZdabIhQ5SvvbnIHu0PUSEK87L+xYKytLyv3z81xS8tttX9/priCpJY2uwSEcKAqTSFKaDjov+jnhnA+fZfS5T+0IpbBYD/tPn4Hh3LwGGzczbcq4QS2dtcC6AGtUUAa63uDES7sZCdvQYVatnKbM1AAaP0SwggeH1Y91iXBtpDWjPOoPwYmHHgKYYoa4bhdMPpOUqDi4B1UO11v27DwczZSH3KnT0XkVqnJlJk+QRLwno5w4etOxd/rKYw+ZIoEw7/w== 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=s3F6sYAM/ogfoAVPG0gjK+a53a3vaB1nPkLfBLzObrk=; b=BMTQ04g6dUPi2Bd+7zV6jrsf0Lqm18Gq04zGvLKhjEFpKYHmR9rGEO3m8HVNQiOl7YFF5rcBW5vgBpeBUwJsBniyEDFJZl6osbvN/59KtdjCqFiDf3xC2+W6X78CymiUEntV/0RWqQhbDE34By3KKtVMHjVK1q7Alax88qFY0oE= Received: from DM6PR04CA0010.namprd04.prod.outlook.com (2603:10b6:5:334::15) by CH9PR10MB997880.namprd10.prod.outlook.com (2603:10b6:610:342::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.223.11; Fri, 17 Jul 2026 18:51:47 +0000 Received: from CY4PEPF0000E9CF.namprd03.prod.outlook.com (2603:10b6:5:334:cafe::d) by DM6PR04CA0010.outlook.office365.com (2603:10b6:5:334::15) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.223.13 via Frontend Transport; Fri, 17 Jul 2026 18:51:47 +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 CY4PEPF0000E9CF.mail.protection.outlook.com (10.167.241.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.245.5 via Frontend Transport; Fri, 17 Jul 2026 18:51:46 +0000 Received: from DLEE212.ent.ti.com (157.170.170.114) 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; Fri, 17 Jul 2026 13:51:45 -0500 Received: from DLEE213.ent.ti.com (157.170.170.116) by DLEE212.ent.ti.com (157.170.170.114) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Fri, 17 Jul 2026 13:51:45 -0500 Received: from lelvem-mr05.itg.ti.com (10.180.75.9) 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 via Frontend Transport; Fri, 17 Jul 2026 13:51:45 -0500 Received: from santhoshkumark.dhcp.ti.com (santhoshkumark.dhcp.ti.com [10.24.52.55]) by lelvem-mr05.itg.ti.com (8.18.1/8.18.1) with ESMTP id 66HIpU4m240969; Fri, 17 Jul 2026 13:51:40 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , Subject: [PATCH v5 02/17] spi: dt-bindings: add spi-phy-pattern-partition property Date: Sat, 18 Jul 2026 00:21:01 +0530 Message-ID: <20260717185116.2065505-3-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260717185116.2065505-1-s-k6@ti.com> References: <20260717185116.2065505-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: CY4PEPF0000E9CF:EE_|CH9PR10MB997880:EE_ X-MS-Office365-Filtering-Correlation-Id: 06355972-1537-4aef-548e-08dee43473ff X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700016|376014|7416014|23010399003|82310400026|1800799024|3023799007|921020|56012099006|10067099003|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: KFjVt1XxUYncDgDzJc646VhYmdIr8cVsGPIIWyahpWoctUyW2mRBflxqIgUudIpPPyZ9V8NPIJjbDyk6qwT/n49kKO5jC1lc4RgRAera6Tn32AXc7riqNXDlIqb+N5DkFiRPcpqL1d5KbjcisKyrnhgfOrO44Zrr92EEnSfcEanR/ZI7zdLya8UCkQGWZSesN4HFzs63UcSKlss43hBse1H54G+c30HvdvpGyug8F/ikaXX3kisQTabuPZ3p5ZWHLCsFBLrY90tkcB/CWDJpuQeTuqsomKNHof0vSoAyPYEd4/jLumGTg1iOA5DHc/bpf1Rt3eNopsOxW5rF3NVSejkPHbhw3LqkjH+SPSNp8tWrVgsOS7ZvmsZKL0uKfEfHYimlH/3hyeLSCvFJ1ohSHs55/5lX6MAjN0W0BPvDEiDhLW82g2FSUNE92AEgCJFVOK954ViA/HaiPoW0+B/0SZmbgg/5EJsIcIF1wkycqbiKVJOxDnHlFb+IEOuaJYgjI/ZQFD5F9xqUsskeXgVNIX+YSP8P5Dhdpy5W+hXwPFPUfHron/WTL4G0TE9HesTBa5/EdrLQIY8a3a6CsBKmKpD1s+CkZRS/VdshHdmpGNQ33AWuKpErcifOkLfkSQBh6jrLFbyTfqYaJNg2fNgFbV4LOgz8ltP9H/bjKvAwe3sfc7qfkTxPjGt07jta+d3g/4Umn0Ar6Mx9swrE2CMwyDl1nvdptMKTDTaxmxUHVQHVAcq5KYdIv6XCRmTuZJCa X-Forefront-Antispam-Report: CIP:198.47.23.194;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:lewvzet200.ext.ti.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700016)(376014)(7416014)(23010399003)(82310400026)(1800799024)(3023799007)(921020)(56012099006)(10067099003)(18002099003)(22082099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 1axJP5eUvMsUih4IlrrHHfN8ZSx4//L5pf3nk/5pYkrOgnESfryJRDBvQFrsXktgf2A4if88trsAOgRRGzsO2dfFlJnEQeoUTKStWTi1UHunVR3GsB6x9FBlEsz4Y5T4ZoCd/l1tRZt9sdnRzRyo9jwZEdrAaT3cUtHgy/EQZExh8ekIxLyPBWFsqoUnuukQCXq2IVHAMwBdJ5MUrnPQKpGY7xwI1ZMWZipc+FF0zF3uq57lXUIWJBfJFe8vfJ32EqCFjEkzlyg9Wijfd0LiE1VP09s4TBRQgBsD0hQL3fDAEtMLrfCdqxm1mP/e1s4H1P6S5Z1hn/7Q8HkziFfJvWFN1vHx1JVT++esEi9SQEwqoN1CI+qMR6MIUN7uc5Fa0nwiGfo0zRu5AnSxu2cImRFy4Py034OjxYAX/lm7JWOBvm7+OK6xFI3xUIyyT/P2 X-Exchange-RoutingPolicyChecked: Sa8wbmRK/SjgKYGWRg3kZUU8RrBK7RtE7LeFvrFd/h3xMRSe7NH/7PhAo9O0RAjotFqWQo27AqYXlVhcHFHxyb9UiRzyXdqPhJYkeI6/HofsFNX9lEI7iMW94FEIsrnnoApAsnJVNvRioFg1AjxNMIjnDmfjU/oStlQPHK6LSFVNRssV6bBbh/K7iee8k+PKAeCx0Fvd/Ka+mMwHbpcHEXdP88FTPDR8ZWazsdUUHPkeXGe7wo7NHLFl76Qe92O5oagc45cCxtFyvWnGBYepZjd8fyp9uq88Kht9ZBROk3qR45taTfudwMZp2kGqssM+/Fdk5F1bXgA+RyFNvRcXGg== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jul 2026 18:51:46.7806 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 06355972-1537-4aef-548e-08dee43473ff 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: CY4PEPF0000E9CF.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH9PR10MB997880 X-Proofpoint-Spam-Info: AW1haW4tMjYwNzE3MDE5MiBTYWx0ZWRfXwaJ94JcOlZK6 IYRXa4bQmMBLT+H4xr7gdvIHzp2CPGVmp0TkOOnXCt/G1ynRgRcuuSz2nXu2BBx2PlGufvKPNWp cHCG92VMUXmAULbhPlPlduMPM87dzqE= X-Proofpoint-GUID: qbkTxXABIGmkpn5PEyfCcvZzI1SkW2br X-Authority-Analysis: v=2.4 cv=M7F97Sws c=1 sm=1 tr=0 ts=6a5a79c7 cx=c_pps a=6wX/tLcgNF/HagpTIcwFsg==:117 a=WotqVVQAdb04rnGuttW3Kw==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=RAioF0-LDSMA:10 a=s63m1ICgrNkA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=jwouBfj2j3NM8CExmVVE:22 a=sozttTNsAAAA:8 a=aBuQwODoJmrdCVe4joYA:9 X-Proofpoint-ORIG-GUID: qbkTxXABIGmkpn5PEyfCcvZzI1SkW2br X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzE3MDE5MiBTYWx0ZWRfX4R5r1g8GFTck nieOaCz46/7ogk9SJWBmqxQ4fXC9uRUxvJQOktJdG+Ruu2O+dAbpFp9S8q5t1v49ENU8zyGgO82 sGfVVIn3TwTdzvbSV2RtJGI8UREl78kUlYI54WduJ3mk38A7o+cxFb8Zki5oe9J0d8Z0ZNlp+1a ZRd4bwjfo1QbGL/KsgRfgVnMZW2MDcPsfiK+sFpz7oFo9TgYbA2GcqOfgkjbMwGFnRwy1Q+WYeW wjMLtC3pTfbO/WbWSs4ce9qh+hH51KUnrFsBE62eBPLKqJel+jAVVZvMVqBGa5+ZFtIR3pTwOeT hJeLYawh05BJ+USfd/N+yyXu+G/GxfyOKCvtHSMNcBFmEajZb9TidoUtnaYEETq8Af10s+67Sc8 ZjwDZpy4mWKzpnhoDBfJ+wzWORVdXp+PuE5n10bAiqf6se/ZcogLam1UZf58ST2uKoPyfcwSl0g 9pMN4kIeaZhHjK2mDJA== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-17_05,2026-07-17_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 priorityscore=1501 bulkscore=0 adultscore=0 spamscore=0 lowpriorityscore=0 malwarescore=0 impostorscore=0 phishscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607170192 Content-Type: text/plain; charset="utf-8" Add spi-phy-pattern-partition, a per-device phandle property on the flash sub-node that allows the DT author to directly reference the partition holding the SPI PHY tuning pattern. Used to locate the pattern data during PHY tuning when the device cannot load the pattern dynamically. PHY tuning works by reading a known data pattern from the device repeatedly while sweeping controller delay parameters until the capture window is stable. For SPI NAND, the driver loads the pattern into the page cache once using write-to-cache opcodes, then reads it during the sweep. SPI NOR devices have no equivalent opcode, so the pattern must be pre-programmed in a dedicated flash partition. One partition per device is required to keep the procedure unambiguous when multiple devices share a bus. Signed-off-by: Santhosh Kumar K Reviewed-by: Krzysztof Kozlowski --- .../devicetree/bindings/spi/cdns,qspi-nor.yaml | 17 +++++++++++++++++ .../bindings/spi/spi-peripheral-props.yaml | 7 +++++++ 2 files changed, 24 insertions(+) diff --git a/Documentation/devicetree/bindings/spi/cdns,qspi-nor.yaml b/Doc= umentation/devicetree/bindings/spi/cdns,qspi-nor.yaml index 891f578b5ac4..277dedcd4246 100644 --- a/Documentation/devicetree/bindings/spi/cdns,qspi-nor.yaml +++ b/Documentation/devicetree/bindings/spi/cdns,qspi-nor.yaml @@ -209,5 +209,22 @@ examples: cdns,tsd2d-ns =3D <60>; cdns,tchsh-ns =3D <60>; cdns,tslch-ns =3D <60>; + spi-phy-pattern-partition =3D <&phy_pattern>; + + partitions { + compatible =3D "fixed-partitions"; + #address-cells =3D <1>; + #size-cells =3D <1>; + + partition@0 { + label =3D "data"; + reg =3D <0x0 0x3fc0000>; + }; + + phy_pattern: partition@3fc0000 { + label =3D "phy-pattern"; + reg =3D <0x3fc0000 0x40000>; + }; + }; }; }; diff --git a/Documentation/devicetree/bindings/spi/spi-peripheral-props.yam= l b/Documentation/devicetree/bindings/spi/spi-peripheral-props.yaml index 12211f8c9f7d..d506807c128a 100644 --- a/Documentation/devicetree/bindings/spi/spi-peripheral-props.yaml +++ b/Documentation/devicetree/bindings/spi/spi-peripheral-props.yaml @@ -122,6 +122,13 @@ properties: description: Delay, in microseconds, after a write transfer. =20 + spi-phy-pattern-partition: + $ref: /schemas/types.yaml#/definitions/phandle + description: + Phandle to the flash partition holding the pre-programmed SPI PHY tu= ning + pattern. Used when the device cannot load the pattern dynamically du= ring + PHY tuning. + stacked-memories: description: Several SPI memories can be wired in stacked mode. This basically means that either a device features several chip --=20 2.34.1 From nobody Sat Jul 25 04:54:27 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 11932395D99; Fri, 17 Jul 2026 18:52:19 +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=1784314342; cv=fail; b=isorndgzQN7jfQpua0oByd9wUyHGxOcNZY/6UTD8PQP7n1T6JKIDOHlVVHSz3ZMJHEsR5Np+NCa6Y/ogE+Dvt+a0fCh3MpMOcYSPz/pCoFMJkP7eVKngdJRdfihKvnoGMyQpVzYSGNM5BPrJjEdSwooQyUx2yQeywReKm03H0bQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784314342; c=relaxed/simple; bh=4oa26rSgSzLAyhplzRa510WlcMbc4I0GAPg7DwxDKWM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=RF3E1hFFq+HmU8Mmd1gd2F119MsnVjjaftsQ6VF40Wu7kBS+35OHimUP/9IIqUQ1h0FBtEODVG69NI4iENnrXlNvCSXWhMICvp3vHGfrdAREVUsMN0shd6cwePUBMagFhLJMki4dnWODxrzVrBRzDPOp4PPPjBsL+nMzHhwC670= 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=ZKyQv8SF; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=UX1A+tDI; 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="ZKyQv8SF"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="UX1A+tDI" 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 66HIlFLu3222590; Fri, 17 Jul 2026 13:52:10 -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=wthubxrx0wa3saAG/KwRvS2nadAg6fNYlJEYHhse0 H8=; b=ZKyQv8SF5g3oEgrz+i0UA1sRDUx0IE/K4/fUwxKtqLf/P6FzMU3ASAjns bVP9qF5bbwMEJEkbzyIP1xowzjpyDZYHRtr9lRFnymv6XIJbuJ5zNUfAuqigJV3S pq+oANrH+SzW+l+iGtva8VfjLYe/jZ3/sPrNVMKeyILkquuBRcDs44J9QmuLsIOB XDIs3H/zYTr1d3FrEZHpvrfSDz987yCsmOEOzUKldymEnJGbQagv7MwER8kXkgbH ObbZSatoi/FQCSaXrPafE/+1R/26Pc41OBTAJECw2UfGWnNx4ZbL3ysLqqSFqOJU meuvDyN+1aQwH/Nvc1GAUmRx2x5QQ== Received: from cy7pr03cu001.outbound.protection.outlook.com (mail-westcentralusazon11010066.outbound.protection.outlook.com [40.93.198.66]) by mx0b-0002e601.pphosted.com (PPS) with ESMTPS id 4ffkc3jtx6-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 17 Jul 2026 13:52:10 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=w6d8pUk1m7kFvkMvuDG2mYC1KiMgCSZkbDDKXlcNIRhqxCZcs7TpdPMvtpZx8PWlwRWsPyWBvrAfepMLU7ZtkyIE0XlujhMo4HI1JOmjen04Bxq6XzggFbSN3uBXX2ix3Hg4lhINzQCBOcL2oPKVB+sZek1qN6aZGceoBturUVYsyr0S6aBiceQuXfLK8owuJN2nvTFhDc/wIU7fUi2dng2nqld2bz+s3JCitQaIvVLaLFVYM+JO29gM8DD7ZqnDSXqPJfndWbWXoT+dZRDmWFjIEbp37QuPsyi70I7e/tGdkAN2mkdlT5z5n1UxAfArbanPDWgQhDTbyqxEpQqTXw== 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=wthubxrx0wa3saAG/KwRvS2nadAg6fNYlJEYHhse0H8=; b=dnCrah+lL3FhhIUQgtR+2Js8yV8xlIARgb/KPbg2OgFJVGMGVOeniFnC8oUVP4K/6753mqf0RaRzJy1P1JsbSYw5LQE9Np/3Sk5KZpUtPtIiPqNTx5rTJWL0DPHtajdmgd35QwfdPWBogU4rWrFno5pE45ZyOhP+cGlaMb853ZeiwDml5I623TzmZinnMevjCqQkhVyFRRqzarkJtwabz94m41W3TWYfIqqxlnwBSBluoSwNkXmNZ1wNwdEjGGM1Kjt2/2wnIvR56jE+QIz7oKPpx8SGsQ0BT5BvoFBHQ2nrDS8ciU1bnbS0bnGxyVce6B7sXfokSBBYuqEzIqCrrQ== 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=wthubxrx0wa3saAG/KwRvS2nadAg6fNYlJEYHhse0H8=; b=UX1A+tDIU3pngBHXlxliuiBWqFUa/u8mz0IONW/18SC6TGAI7ka5v0AhF3yfdXDJmNSrUbgudGD8ko/r29v5extDqG5D03k2GZbXeGh47G6A180IvIEazSGhVIA+paNmASEKxRT0h9EaiLyNvqG98NNYjnx8iDVKtyFVHksxVbk= Received: from BN9PR03CA0323.namprd03.prod.outlook.com (2603:10b6:408:112::28) by LVUPR10MB997810.namprd10.prod.outlook.com (2603:10b6:408:39e::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.223.13; Fri, 17 Jul 2026 18:52:05 +0000 Received: from BN1PEPF00004689.namprd05.prod.outlook.com (2603:10b6:408:112:cafe::77) by BN9PR03CA0323.outlook.office365.com (2603:10b6:408:112::28) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.223.12 via Frontend Transport; Fri, 17 Jul 2026 18:52:05 +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 BN1PEPF00004689.mail.protection.outlook.com (10.167.243.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.245.5 via Frontend Transport; Fri, 17 Jul 2026 18:52:05 +0000 Received: from DLEE215.ent.ti.com (157.170.170.118) 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; Fri, 17 Jul 2026 13:52:04 -0500 Received: from DLEE211.ent.ti.com (157.170.170.113) 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; Fri, 17 Jul 2026 13:51:50 -0500 Received: from lelvem-mr05.itg.ti.com (10.180.75.9) by DLEE211.ent.ti.com (157.170.170.113) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Fri, 17 Jul 2026 13:51:50 -0500 Received: from santhoshkumark.dhcp.ti.com (santhoshkumark.dhcp.ti.com [10.24.52.55]) by lelvem-mr05.itg.ti.com (8.18.1/8.18.1) with ESMTP id 66HIpU4n240969; Fri, 17 Jul 2026 13:51:46 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , Subject: [PATCH v5 03/17] spi: parse spi-max-post-config-frequency-hz into post_config_max_speed_hz Date: Sat, 18 Jul 2026 00:21:02 +0530 Message-ID: <20260717185116.2065505-4-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260717185116.2065505-1-s-k6@ti.com> References: <20260717185116.2065505-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: BN1PEPF00004689:EE_|LVUPR10MB997810:EE_ X-MS-Office365-Filtering-Correlation-Id: ed31c573-d272-45b1-1d3a-08dee4347ef9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|36860700016|376014|7416014|23010399003|10067099003|56012099006|6133799003|18002099003|22082099003|3023799007|921020; X-Microsoft-Antispam-Message-Info: X69xPt3iC2vlifCAnJQWPWOUdTYE+25AJdnjQlZ35eN0zORm+iZEC5DByh3tuqCnQfE2a2w1WkuogIK90nUfkuPXwclHqSX7JsTPGXI/vb7Fy3fAribNrngNyRHkQxhsLXanTBBNeBunaFsCIg5c3DGC12nWs1lwKqKCoKswHHymYIwzlzGv6Yun9+CULNKMIuk5N92hM4dVj9m6oHSAT9D8fwkBeWdKXlL1MzlgcaaLI4BfiLwfD9HpbkTCusrlNxMPbdc3LaHdz18d4hZkXflMSluvWSzSdlLv6TTCW/XYHfOnJtzHUFNC4Ios8+rXzUR8lhU48nxo+nzpx8vSWfpEhq+NMLg/3Wc2oxFZ+GZ0lmbGbQQ715xAgihwgFJpNEYlQUFTBPTS5Aw2FlqeQS3mErXtr/9FW7T4xYTz+gtF6S3PTdMkS/ScjGHvvc2UXtX0c6TqwQNg8JJ6AmSwG42WuHBuT1dksWxx5ElXchLlw/+OOnxDK5BdX+q8ZAzKUVmwxeGH8iyv5zcACrYm27+EQloVnVXFRuzcyKsUbLBL0N/Aig7LATF3Gvs3JDbHXWh4/zKLosYv+GMZ3Y2rztnZVK+sMIlDr023YoerQ9MEeTDOUx1mujXLnp6RbqzrAZZu5L1jD9cfOAy5DIaN00ReOCW4X+t2QaDZEC1TjLuReuihnem/KeNyQmTbx2ghmef1WLxZ1Bxgl7m65JspBqIpF0XkbFgJ/62ivUpRoVYX/ayKb7FAvX2ShmuoK4+B X-Forefront-Antispam-Report: CIP:198.47.23.195;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:lewvzet201.ext.ti.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(82310400026)(36860700016)(376014)(7416014)(23010399003)(10067099003)(56012099006)(6133799003)(18002099003)(22082099003)(3023799007)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 2T2OiEEynDlyzBocCcUE3xDsofIkAlgCPfhyYzUx9oEXsg8ECPlToV0bU1kQfghcWmathZhLbWCwbtqRjmmsR5B7nAOGGEjKKooQQ3yam5jJi7rW203U2+2oCQkRti7ARiC+teAZafq86CMAGN4BKUXa5ukn430CheadhLXGj8jhTYHc5WdNzWIQqrJTYUS63Swfvsgkx0z0Olv1kHFLCh2eUQkWOM0oYVItF3H/i0dxOUErZB9Noe8lK3WoyAh/cHkeumeO4sPBc/7nPXaxLJlBGdADm/nSswee6znddgr+hb5ueBiWIqL1VAzCLD8Uv/1G8rNUG//1kZba+0meGmy6sY1ZZUTDsdiHd2H9C9HMg3UTBxzHwHyWStHBY+w2WFtU2SwEI9c/AhleBNm3TvX+DhtlNmE+sSWMsPvSigW+x7iJLwWDPLn8MWpBaLDJ X-Exchange-RoutingPolicyChecked: P6BMpQOMBrevrtIkyKaqMvtO7kA/a7N21kQ5NAR6Tf7uO+R8QSi8OIitogJc2sDWN//Wx66lkDFpyHMCQZLjrdCs46xnQaTb2GVPfZaGAdLNo1jLD9LgDbwiIbXNOnr50dUCuHP+2kTqhOemUfpcVR+FJlj5XaRhU7Y3XEP6xibE/8kW84Al//To2pjWFaT/dghKT5lZipqXkLiyx0dhFQyC92CQ0Fuw2XKkmkzqiACqCBtcWckzV23AykXqilpXXN5jaf2IQlxVOLJoc/DvN3S8Gmbdxe6MVhlZIS/U4A9XhvwXmcG35Q/by4oW6NhOjSooqvB/VwoRqMOEHpS/Uw== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jul 2026 18:52:05.1802 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ed31c573-d272-45b1-1d3a-08dee4347ef9 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: BN1PEPF00004689.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LVUPR10MB997810 X-Proofpoint-Spam-Info: AW1haW4tMjYwNzE3MDE5MiBTYWx0ZWRfX4JAeFOD9U3e8 QgTnu0M7wEu1jaJn9YFQUd6MHK3CEtov0Q9u7YQe/m3YfN7tkzzxNMeX6RBgg3iFD5iapwtkyee 5Kw91wbjAzvLc6DQA9DJXvZ6V3L5zIQ= X-Proofpoint-GUID: lqm-ifoRnSEg4DaUKU3egV1XHboTIQQo X-Authority-Analysis: v=2.4 cv=M7F97Sws c=1 sm=1 tr=0 ts=6a5a79da cx=c_pps a=F8U3mngwmb3oM6JELIq/Eg==:117 a=f+v6EHfkeJbVwR46tk4DMg==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=RAioF0-LDSMA:10 a=s63m1ICgrNkA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=jwouBfj2j3NM8CExmVVE:22 a=P-IC7800AAAA:8 a=sozttTNsAAAA:8 a=2Gi1gDZmOG9PIfG5304A:9 a=O8hF6Hzn-FEA:10 a=d3PnA9EDa4IxuAV0gXij:22 X-Proofpoint-ORIG-GUID: lqm-ifoRnSEg4DaUKU3egV1XHboTIQQo X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzE3MDE5MiBTYWx0ZWRfXypJndXg5PBkd MBQwLPyqXA4EbMKV3dgV8gR/DAhABHLawodcI/SxhIfMEcPbF7mCo3vqcYpIn6IFCGxzbmksH65 3nZoCUwko3S8tq26kEAg300JnZVG5vQULd5A5VePsWYG6uv3gR/2zvqgE3RAu4ZNhJedYVmAxVe DkW7DY7JzJDZBwSmBCXF9P7DEtKcgh4I6RWlyjXNRa6pS5I5A7c1EMLm3mR9qaWbRWnZP22vpq4 ZNkbGMT2LvZkvkNrLj3NAot2z/RVgtC9cc9uyw5k4gLQ14tbUk/q8Bc9qlDqagVLm2gfyg/8vT4 XupVnBku3kyuOgT1hoeZRt10BoiyuzaYYyvyKrpaWvOV3MdMMsunvHftam+f/mB+X3n/QhAXE+0 dKltlXK7iNWsqezVi25vtmB3/EDvdMSNuhVIYcbFSQZfel+Id9EtwtIyZO+Z1VNA3HnGvR7Y/cS TCuZJGXKCnK719hx7UA== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-17_05,2026-07-17_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 priorityscore=1501 bulkscore=0 adultscore=0 spamscore=0 lowpriorityscore=0 malwarescore=0 impostorscore=0 phishscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607170192 Content-Type: text/plain; charset="utf-8" Add post_config_max_speed_hz to struct spi_device and parse it from the spi-max-post-config-frequency-hz DT property in of_spi_parse_dt(). This supports SPI devices that operate at two distinct clock rates: a conservative rate always reachable without controller configuration, and a higher rate achievable only after controller-side configuration such as PHY tuning. With both properties set, spi-max-frequency gives the conservative pre-configuration rate and post_config_max_speed_hz carries the post-configuration target for the SPI-MEM layer. Zero when not set, preserving existing behaviour. Reviewed-by: Miquel Raynal Signed-off-by: Santhosh Kumar K --- drivers/spi/spi.c | 2 ++ include/linux/spi/spi.h | 3 +++ 2 files changed, 5 insertions(+) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index d9e6b4b87c89..7e7393d25810 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -2602,6 +2602,8 @@ static int of_spi_parse_dt(struct spi_controller *ctl= r, struct spi_device *spi, /* Device speed */ if (!of_property_read_u32(nc, "spi-max-frequency", &value)) spi->max_speed_hz =3D value; + if (!of_property_read_u32(nc, "spi-max-post-config-frequency-hz", &value)) + spi->post_config_max_speed_hz =3D value; =20 /* Device CS delays */ of_spi_parse_dt_cs_delay(nc, &spi->cs_setup, "spi-cs-setup-delay-ns"); diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h index 4c285d3ede1d..aa7b1b34a594 100644 --- a/include/linux/spi/spi.h +++ b/include/linux/spi/spi.h @@ -141,6 +141,8 @@ extern void spi_transfer_cs_change_delay_exec(struct sp= i_message *msg, * @max_speed_hz: Maximum clock rate to be used with this chip * (on this board); may be changed by the device's driver. * The spi_transfer.speed_hz can override this for each transfer. + * @post_config_max_speed_hz: Maximum clock rate achievable after controll= er + * configuration (e.g. PHY tuning); zero when not assigned. * @bits_per_word: Data transfers involve one or more words; word sizes * like eight or 12 bits are common. In-memory wordsizes are * powers of two bytes (e.g. 20 bit samples use 32 bits). @@ -193,6 +195,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 Sat Jul 25 04:54:27 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 5ECA2391E44; Fri, 17 Jul 2026 18:52:14 +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=1784314335; cv=fail; b=F9boAmEj0y++jMNpRTL3wmERAgEMXrmMLjhnmg1q7K5905KVUhHU+pAgnTTUtJFfv+RX4qtt8LpbxSDk4CxToMsZb/kdKUxBnn4xDjR83TpoLIsVLMzVUSqfI3LAAUtENSIrFXu+byIgLL+O8NxBLFrjZs4gl7E8ou14o3pSNoY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784314335; c=relaxed/simple; bh=s0jYk/5KEpyTn+gQ2ZgsqurVBgOxWDscHJlq6GjcfSY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=tnnfpxnM2yimqvAcQMtbiTcC9U1gTR4srwj/nLC9uIBTya77jvTGdmlG6ARSDWyZa62FLrIu6T5qWBg4p0wLVYlEgrgIBlWhcRcEGDNJKiSCVn1zCXFFx8SS/UGug4f7Lkz/UIvuaWdGDuPmaBrxybbu1U3wzjXeMwAy/DFoK3c= 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=QeoXw4FH; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=GSYBF14r; 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="QeoXw4FH"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="GSYBF14r" 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 66HIlGZn1569979; Fri, 17 Jul 2026 13:52:05 -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=dF/dA9rfFrlBBCask2DwOPti+dzd1RR7KKfCA52tD cI=; b=QeoXw4FHvyNqYXwdVlbWJq2QDP2fxRRpf+by/Re54v0qjDCMBQjuBgoz6 PhkYx9ruIScShboHkVRcsGvUSN+htfba5eJ5Z+aOwMuBJE6ae5ujJ0XxWu97vBzS LHCLZaGUW1iPyI5jSmRd7MamhqskYbiWvTvTFcpacsuMoYwMh8qr2wqXVlm6Wocu zVV2ZQjPPvIbNmUzXyawNqnWthf0p8PYCqgahnTSTBPWmC+0WVGdxWCnxg+3Y67x kZjbC2POqHMtVD4Ohqc2zySWpL5Wl2FMoMJgKI6WgwTcnu9H529j7U6/6HVEOUMR wz3S0uBuyRF34QJnTtbFkFK/staSQ== Received: from ch5pr02cu005.outbound.protection.outlook.com (mail-northcentralusazon11012034.outbound.protection.outlook.com [40.107.200.34]) by m0384305.ppops.net (PPS) with ESMTPS id 4ffgsmbgqc-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 17 Jul 2026 13:52:04 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=yyz0tV1AfHv/p1ARs9+XiAHRVaWFBhMxv6ff+fXZPgs73dpIbcA6OpsVvIPyI0ny4+3ESa5PXGLOjh/1ke5jbpjXyn4YTo0dnFtIeDSo7ahZvZ863Xm8Wykq3XfQcIoF7d2NCR3coZnlcqzry1udOEfO/UJO5gcYT0sbZE3ChbfEh9zQmDzSktobHvP0ue9UZgSPffmYhzKQjh87Acvbjt85+bX5h5LqSRnJE0BPOMsE77Xc+UZWXnp6fW5j8dy0hzjEAXJO2kD5iK6Xw1RV3weQ6nZFiUkg1crKi1y28AJ3Qtnzv12f4sqVattNT/g3bn0okRZ8dw8ozzGkziM9wQ== 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=dF/dA9rfFrlBBCask2DwOPti+dzd1RR7KKfCA52tDcI=; b=ULAdpTvSg1xJdBtifwgQwpt3k3TwZgBcdAqFcla50zNLnUSc8aYdtgFryIEzbEmCeO9nyCxfd/IXYyVP/paJ+QMX2nbcPUjyJVabdlDTzcUlCO1eWoVonP7bNqqAhDSyC5etNC43p9gOQzjHszuxlWxhyejrqvdlmkMq9C8q7A6GUYs3WWnpDbT5Z/dRKqH0a4MSc0f3JSfj5EqdIguPI+M319ZpCxrMdq0EgZzpp8CTWdtz/16gnVzLpb+ItE5/pb8p5TWxV9qUuFl/s+lzuDS9BRysi/77kHpcxzT4x390b3Y4OZpRsNIqCxj+/APRMhVerHAq820g2rP65JNNSA== 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=dF/dA9rfFrlBBCask2DwOPti+dzd1RR7KKfCA52tDcI=; b=GSYBF14rS/IRvzD561rZlwZPM+sCXa3AYm+I23AEYBvjK0yqLuQoA3atFlrf7J1sAYdPwqveiSqtOYIcVkB26nLD/JoG9ORrVYTlwDLJcMkjpnjE1ZsR/EiNbW+a328SGZ+uECA/LZLFH3OAtYdcoK8roCtQSYHuMq2N5ZShCCI= Received: from MN2PR20CA0045.namprd20.prod.outlook.com (2603:10b6:208:235::14) by CH0PR10MB4892.namprd10.prod.outlook.com (2603:10b6:610:dd::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.223.13; Fri, 17 Jul 2026 18:51:57 +0000 Received: from BL02EPF0001A0FE.namprd03.prod.outlook.com (2603:10b6:208:235:cafe::6b) by MN2PR20CA0045.outlook.office365.com (2603:10b6:208:235::14) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.223.13 via Frontend Transport; Fri, 17 Jul 2026 18:51:57 +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 BL02EPF0001A0FE.mail.protection.outlook.com (10.167.242.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.245.5 via Frontend Transport; Fri, 17 Jul 2026 18:51:56 +0000 Received: from DFLE207.ent.ti.com (10.64.6.65) 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; Fri, 17 Jul 2026 13:51:55 -0500 Received: from DFLE204.ent.ti.com (10.64.6.62) 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; Fri, 17 Jul 2026 13:51:55 -0500 Received: from lelvem-mr05.itg.ti.com (10.180.75.9) by DFLE204.ent.ti.com (10.64.6.62) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Fri, 17 Jul 2026 13:51:55 -0500 Received: from santhoshkumark.dhcp.ti.com (santhoshkumark.dhcp.ti.com [10.24.52.55]) by lelvem-mr05.itg.ti.com (8.18.1/8.18.1) with ESMTP id 66HIpU4o240969; Fri, 17 Jul 2026 13:51:51 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , Subject: [PATCH v5 04/17] spi: spi-mem: teach spi_mem_adjust_op_freq() about post-config ops Date: Sat, 18 Jul 2026 00:21:03 +0530 Message-ID: <20260717185116.2065505-5-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260717185116.2065505-1-s-k6@ti.com> References: <20260717185116.2065505-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: BL02EPF0001A0FE:EE_|CH0PR10MB4892:EE_ X-MS-Office365-Filtering-Correlation-Id: 43110039-c692-47fe-39bd-08dee43479f1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|82310400026|376014|23010399003|1800799024|36860700016|921020|6133799003|56012099006|10067099003|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: upnMmJgiHp8FjICL2qBtP40r6W9P1QerYmPZz2WdyjgeWdFciYrBM/1eiTJrn/0Ye3nGGQbdrPvMtTlGU67RyEij4XckA/NZrmlXAX1EswIuEZvtFID76snV1hlAT26oIECX4vhtRw+pu1OrgRjCTtwM68rZTQPOs/Im4f2BsT1dTMbRnHErfXisFNuhVeWds270gxdI3Gr3P/16G0w00GXldgORllnvc9OsvdEAfKxJnE964iw0ZILhqWDI1JXavvRGqgZisXFxaORQgNh6H45tr0y5ZqAX7+dK98sbsxS8J0JKS9Lj89lDqN4Os9OW5GbEYrsSWy4a51rI6fxyYjhlK8ISbx8+qWi+Fu5mN6IHQvkG/dKgu3cYWa1tEcHr6M8u+SYpcSfpXcv5BDCq00VtYtRaUF6d83/H0fzQUoLPrwnV5GI/Vz6rMZERC1YrTsH/At5MfnyfzdCOZ37Uq3jmP5wm4PFiajY+OIO5uqiKohDL3uJheT1Bs2Qrpp8gBVT/bxZQV5WISEjkwCASglC6jHJ3Eq1IJQQ/+6x0BkJRsvrA20QjJ0PlrcxvY9BmYpYsNkFjRtKZuhxt4DD+NuS2QNpkv7jYDR9tj9LgxIZhis9U2o8rrx6S4i6h+oBPZuLcTEARf5WEZQIs0T2PYI0l5XYUgnXqR3W2AAqzrZ+1PUPGiuvJP8b8YfuCU3aiXgd28IEOYxQuOYj3sRTz4/cxZpZKCDHS7OzwVgYSW8ag9itJIaETZW3gMIjdm9Bf X-Forefront-Antispam-Report: CIP:198.47.21.194;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:flwvzet200.ext.ti.com;PTR:ErrorRetry;CAT:NONE;SFS:(13230040)(7416014)(82310400026)(376014)(23010399003)(1800799024)(36860700016)(921020)(6133799003)(56012099006)(10067099003)(18002099003)(22082099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: VxT9k9uP3uV5dmxF8lswUd6ZNlLVJSQoyCbhSjKxsiq2XCsr6pRiliwUBNqsLmbr+jUsUb2K4t6AlVoRH25gw/UwowjMyMvIN+nvmDZR+qALHiTYO7bmaAO3f6GHqJtRzJv0OJj4ARgw47ZoxmvTOADCivkKPXi9rzjedUiBGB8PMBdiO4ObTrgfH7ij21NoYyWUcePDfpJB3acHhohtQSKHLogAlefbXIc1mWdd7EcPInj4YWXT/TkHmRutbwe6orDShZAYnvizkjBfq2ij2iQqAQdCXyZihqGAMjIUPtKkKsof54hSdITduOpHlO9jI9pbFBifn50Dew/6XoPz6UWVhUZmenvjyIrIDqJD5ZVpAAbCNyrDe4hO8EAd31WNjDUavaqnJWWkpUqQrzTWCcoKsrJ5AyB7IDo/3q0xeflz5qQkH2eTfjn9LdAoBuuS X-Exchange-RoutingPolicyChecked: s0mBQD7fg0ZOwt2T2ZW0srK7naawD2c25aSrvtedWmP6+KvzeiRxB+93/XnU/YsKLsqkVJjqi8YkXWeHoucb4oAq9o47Hc0V1kqQawjlQGI7T9FWVackqYF/jOGf7ymnDWOxNDPND9JLTdvC52R8FE85SdU/UIxzLZ4VUVTwZ9uEYP82QSUGwhGQmIl9OZ+Wmz+oaVAmjgPS2ta6vafexD6rNt+GPT2FJQ2Zux2Ktuq7P86jJSW6r1aLkvRxOlIPsVxvDXzHGwo/xEBBMYrmB95oYuFRq2xRqzDgDn3fryWwSkyeZI/ZEfsIR3MHSajHhx8UITSdoTIjoZm1Wj5adA== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jul 2026 18:51:56.7243 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 43110039-c692-47fe-39bd-08dee43479f1 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: BL02EPF0001A0FE.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB4892 X-Proofpoint-GUID: 5NfMnoRoSNC_QgPLmj7nsbPyI38J56ok X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzE3MDE5MiBTYWx0ZWRfX3sgFKfW3k6uz s/gH/2FRkodYn2tSmUQjr2oXuNRtbO20DzSLDwfoTDGXTB18Nis/R0xtnLEm+rzXy+8CHJ6d6VV fkwDhgVd6xNvKV0ZX75bg9pgolV/yqJANvDWmhoVaRA45lLFarzWCUm0iXBUXi1bKPT391So6J2 JtgsjyYuwqR7VTkYaYqVrsxUv7fbRkQWpTQ6Auutoy1gF22ZOOT79ziidLZzBRKe+fKVjrZrCbL 7JrvKztPQfXq5Pdi6gHnPzgBVO8nSpnIjGoGYMysiLR4XNnYlAnB+N8l7APfZ4t67h9vdoRC0Kf OfzlxPOiyBTmSgotiKX/YrSbV0FVcFuM6dNTFajJ05QZquNInpcNYloN23YpZ6GvkKKddsv4nMS 4JoewaOKGbrCU4ix8xG7RoLzR3z/+ZNjqqi8Pv4hAeNGH3bj5kcTk26NZIfVZirkF7ISB0NNkes hxReeY39edZQn578rNA== X-Authority-Analysis: v=2.4 cv=GJ841ONK c=1 sm=1 tr=0 ts=6a5a79d4 cx=c_pps a=9AcDkMntNQwiSFi2uhiI7g==:117 a=iwqwCZQqcuTv3JOpYdM7/Q==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=RAioF0-LDSMA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=taLDd7a_hP9WKsMzeGRc:22 a=P-IC7800AAAA:8 a=sozttTNsAAAA:8 a=1EK_O1AJX7ox_F5CMUYA:9 a=d3PnA9EDa4IxuAV0gXij:22 X-Proofpoint-ORIG-GUID: 5NfMnoRoSNC_QgPLmj7nsbPyI38J56ok X-Proofpoint-Spam-Info: AW1haW4tMjYwNzE3MDE5MiBTYWx0ZWRfX+uDxFOsCev2P 1DeiUyuOXyb15pPCq/oXD61wQ2XI4cs4KOMYxtnkptN1IDzLPOxIQTZjZBbMcR3ACYYAOh2NZJy TjIbjDhcIO6Fnu8/kdwLXUuBnJ1bI5c= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-17_05,2026-07-17_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 clxscore=1015 impostorscore=0 malwarescore=0 lowpriorityscore=0 priorityscore=1501 suspectscore=0 phishscore=0 spamscore=0 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607170192 Content-Type: text/plain; charset="utf-8" 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. Reviewed-by: Miquel Raynal 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 Sat Jul 25 04:54:27 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 74183390C8E; Fri, 17 Jul 2026 18:52:18 +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=1784314340; cv=fail; b=GOcB/S5JCjhA9OHiGfVYF8tTyAjcG3nijHo74km+t665heMHF7eDiyXvcNzlMSIyOYSsfj55+tE3R0kUJWGergi2Efh89QOAx8usc59rEuM7NPHUBPmj6EktjecEBRjQX+PTn/POXFCDhhg4nY6rYsE0cUcGhGuGnpWQNyslSQM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784314340; c=relaxed/simple; bh=XXod5gsYdwM7TuNfFFwFZK80u1YkPJ13Yfu54EWDiXI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=qcQNfiJ9DWWzN8WI3MqHK/MJedBRMBrnM1b3vLOmyixT+EoXxzIf/jYk80JO/T6BO4GCjBsLv7zk96ddRRZRVOGGzUC8nT4T0YZnWmSX8ts70jkIEeHhdsV4J20dt8kbJVKdkGBQjx+U61azCdnGu2AqDyI9j78Ki3CLX5Ekym8= 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=kLAPSSbF; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=U1w1fLUI; 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="kLAPSSbF"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="U1w1fLUI" 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 66HIlA9d3254281; Fri, 17 Jul 2026 13:52:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint-05-2026; bh=o06IxgyXWxwrCIaljlzC8v05IGlfq0oB+3XuQYWYM C8=; b=kLAPSSbFVfZA0hvfnREh91XKCzdaTTjv5orgq54aNvNuMOwatY83yO8Lr LsqQWg3WLv2LxCovvxR7PW+rJMLwPAB4n61B/5ywDvENO1g3gAevcWfLQqC2/i/i DEF9tbHnKAz4wzj18SYUVInUAJWwn7MTCORLTbBUmjCPX6wpw6RZFU/N0IRmr2hC hjxD6M/Lsm4TN1NmnBpsdaxgRb8ORD7mQZvNQdwwRycaxHhkj4I5Squhb3c2+1nC Gr38NrxVQ4PqSoaeutyGMnpSYsbzpyCI3EFjLSNXueEdwiG5iLxfqHACrx8Mf/i0 WL/oYumKHLqc7MC88HPrHoJ7YRVew== Received: from sn4pr2101cu001.outbound.protection.outlook.com (mail-southcentralusazon11012045.outbound.protection.outlook.com [40.93.195.45]) by m0380145.ppops.net (PPS) with ESMTPS id 4ffks32ke9-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 17 Jul 2026 13:52:08 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=GEcE3iQOKxw0K0od7O4+t9Sxqf540dekNKSPbffh5CftXIFQfHoZaE85RKR2UeCWFxZZSVonS+eIVuWNzuwHWM6O/VPTA6tKjqY3JwWrNLFW7PtycVbOhyjQGyZ8Y9HFMC5FMNCe2PiwoZCy4LLYk6W/6290qOLghyC/pslZZwmD2TwCXrT1sFw7ahXdAccpvvSVDNLMLVvn1XOmASjoveV2fwx4lIBDY/IIr1SizMhkv0I2uno9wZ9kT1xYDKlpatdhPQ7h42xMCFci8+EPRQCzh0txx3Sv7XNOaVGGMKAq7ol8plqUCl8ZpUM+uN1aeSPprt4KwShVRY44v/9dkQ== 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=o06IxgyXWxwrCIaljlzC8v05IGlfq0oB+3XuQYWYMC8=; b=rYbKi03IUEzwIr2ruAo8FOkM76J5A3evtFKv9o8hHLiKWSp89A2XRaGz9GeACc4WjLAXT4ED4wuAw/UPa6kmk1MyH9ykCh1+e4nwrgvHXbQXe+277hb38Q6e0Tj3dmSNIxfcKAWYmcAA2vbEeGZpbkZXZAxEQolPoLa2hbLsbm+129KCVxTEtsv8wZRr37yPplPXEZ5V+UWqZRKxM+NkVBmBt75MBO1hKwbvBSuJ0eNLZGUTBvSkw+jItdwm7ZimpFWfMU3GWIspiWeOezlI4AnAE68IpV6oZYp920HAGhg80BYgJRxGjBWyL01v3LjX4qAHEtmlqw4v0fJzU7DYbw== 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=o06IxgyXWxwrCIaljlzC8v05IGlfq0oB+3XuQYWYMC8=; b=U1w1fLUIdx0C/m2yU7bh5YQGnu/Oz6XoknH28wlvkvGyw1SlcMLT6vhqTs/l5izA4IXu/eei5HBfHgNOmcFH5qw0QEc0sC338+sWgDfe4lNWvuQDtn2YWQLF5oIU/D4qRc06XJQS/Y4lIk1o17lNhEU6wloXDXAJMmkSgp+UMq4= Received: from BN9PR03CA0530.namprd03.prod.outlook.com (2603:10b6:408:131::25) by CH0PR10MB5049.namprd10.prod.outlook.com (2603:10b6:610:c4::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.223.12; Fri, 17 Jul 2026 18:52:01 +0000 Received: from BN1PEPF0000468A.namprd05.prod.outlook.com (2603:10b6:408:131:cafe::21) by BN9PR03CA0530.outlook.office365.com (2603:10b6:408:131::25) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.223.13 via Frontend Transport; Fri, 17 Jul 2026 18:52:01 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 198.47.23.195) smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ti.com; Received-SPF: Pass (protection.outlook.com: domain of ti.com designates 198.47.23.195 as permitted sender) receiver=protection.outlook.com; client-ip=198.47.23.195; helo=lewvzet201.ext.ti.com; pr=C Received: from lewvzet201.ext.ti.com (198.47.23.195) by BN1PEPF0000468A.mail.protection.outlook.com (10.167.243.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.245.5 via Frontend Transport; Fri, 17 Jul 2026 18:52:01 +0000 Received: from DLEE203.ent.ti.com (157.170.170.78) 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; Fri, 17 Jul 2026 13:52:00 -0500 Received: from DLEE212.ent.ti.com (157.170.170.114) 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; Fri, 17 Jul 2026 13:52:00 -0500 Received: from lelvem-mr05.itg.ti.com (10.180.75.9) by DLEE212.ent.ti.com (157.170.170.114) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Fri, 17 Jul 2026 13:52:00 -0500 Received: from santhoshkumark.dhcp.ti.com (santhoshkumark.dhcp.ti.com [10.24.52.55]) by lelvem-mr05.itg.ti.com (8.18.1/8.18.1) with ESMTP id 66HIpU4p240969; Fri, 17 Jul 2026 13:51:56 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , Subject: [PATCH v5 05/17] spi: spi-mem: add execute_tuning callback and spi_mem_execute_tuning() Date: Sat, 18 Jul 2026 00:21:04 +0530 Message-ID: <20260717185116.2065505-6-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260717185116.2065505-1-s-k6@ti.com> References: <20260717185116.2065505-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: BN1PEPF0000468A:EE_|CH0PR10MB5049:EE_ X-MS-Office365-Filtering-Correlation-Id: aa23ac0d-99b4-41d5-3ed6-08dee4347c9f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|7416014|23010399003|82310400026|36860700016|921020|6133799003|10067099003|18002099003|56012099006|22082099003; X-Microsoft-Antispam-Message-Info: lGlhlSJb+Dp7wKDE7h89+EszSrYLvp+VOSRzlFm5TQwNRflFGCWRVrl0PXiJ7snwa5gTkFoVA/vnUVZQhmu5zf56VjMN7Q1gAonR81evbIteaIXytPuLX76j5QIVfYReaRmBzL5kzbiRs0+dHfvESWt1V3q3NP/lbbVdp30ToTtbbM7SeLsV2o+SvopxBIbrqn67DRENn8FqvmZEIuT7TmmpVEufvW90l6Ix87t3MogTZL86F0j5vWdvsx8+1rtgzyK+PZT1RWPY9mSMDUQ7QNwlqOzezi3lowZFcGgQcriORgCVrbdM0dd+MGeoeVoaevW7TFeV/8V612Gd8Kc2J8TDzJgjMlft7UuGyt4EVI4rWtng4ZTBi3K20qjLEhG8anydDep7UXE1EyQshAiseufpQhmwhrn1TEgtOnJjZGflDJiP4WcH9o3oRWsXaZ48KeW2eAXlHEYtyLgIfNTR89gRYZ5SrI5gbbDTuCbC7gyV+0BrE7lA2/pUz/triNS+bhiIfBNW0tYYhshLRZuGhN4102eDCr3JtnIPgzeHhP6jIkSp9/xQXVHSpDZPNpVYzJrT5ofpOcXvn9PrxCbu7cd1b0itZBjsVcU65THAttNIQJDu7jYM9qu7bYhLC8/VOKviVAfs9RhxAC20+9nycpIYvfHDmqryVVgIZRVOMbXgj4mNkrmt+4MehSsFHSA0yDcd+K3imCOzY+T1u4ii1+3kkXVRgERyhq5hKeC3NQWYR+hdKrVEyQhIWhzynet2 X-Forefront-Antispam-Report: CIP:198.47.23.195;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:lewvzet201.ext.ti.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(1800799024)(7416014)(23010399003)(82310400026)(36860700016)(921020)(6133799003)(10067099003)(18002099003)(56012099006)(22082099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: xDjLiowePOkaTB9V2FPUly8lCZWFd2JAN13lij9eptvGOTL6r/+jyIxcp5JSZdwkpKD/14tIF7zsXOHGiHcP+ydzAb2VoEY7avsFhZfPVrCXaEHOvnkQr9L14FTfQ+uiXiDmeyLw7hidhAr98WVVlcpjC3k8D4P/OQGj7UnkypIIRKkqhrRq9LkMVZ9KSRjyW5BNphxRhLP4UCyAo2w2+FHgPhZZtNuFw/eGL+ZFM2MzXFo/NdFpDH9nbGc4J8m/kf/yX4L4acKOfoWQZSRSmBxHoLtvnlAy4L/IZH18IpbwNAtP3A8ab4fk9t/Beyv4ZzRrK3v1Y70flaU7jj/hmqI27XSUz15dLNPW0yRREhnPG0aJxdAPIRDKD/ks9y2Rm2Cq2pze0fkPG5htALDZh1y914eAuFSpIsEbO8hnb9oM8vZ2vw1YEEPY45S8jUri X-Exchange-RoutingPolicyChecked: skC/YVvo5fUtB3UotXK77sISaD7kMNkaWmxK86nqCdx8raKzzncxN82umM8BjxUoCWav+QI51I25PBLmu6cDuKobTJMJ0UxKP/PupoHxbAOw46HL/VJmSscn9nPqKk0K8debFfuOm1YzJ86vC2rKNMLa973pQ0PhGjTm8RoLyfc88q4poBK1g+6N2hYSNoedIBNIacQoZ84jxfls8Q/u4ms/hWkggcihfpmbB1BkS2vmJFcvy+aRRGpTLRQe6xzDbmUo5dXeJ1vHQbJiw2NKkSqGit0i4+SNMnGBsu5JMV0jLnYqy+CRK+a6bwhPs5RQMViEYUsTCXV+cHLAI+mb3g== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jul 2026 18:52:01.2333 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: aa23ac0d-99b4-41d5-3ed6-08dee4347c9f 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: BN1PEPF0000468A.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB5049 X-Authority-Analysis: v=2.4 cv=e9Y2j6p/ c=1 sm=1 tr=0 ts=6a5a79d8 cx=c_pps a=E0//De2tebslxPhFmdrqCw==:117 a=f+v6EHfkeJbVwR46tk4DMg==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=RAioF0-LDSMA:10 a=s63m1ICgrNkA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=gO1vWkAQAl3rybz1DQOp:22 a=P-IC7800AAAA:8 a=sozttTNsAAAA:8 a=XczTfz52Gg2yNcvB9tIA:9 a=d3PnA9EDa4IxuAV0gXij:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzE3MDE5MiBTYWx0ZWRfX4CFy5B56fNLk f3Do1pn8CH2hUSP2k/oiHA7YL6FVHZ9ujKaD7/xY143wsMUNGGQcIqru3pfEGXoJdQql4ouuvdr BdKymm6BkT54OqdvILza8s99bTjre96fcc3oMeoutDwOzbzbAVeDcDedgvXQmp/Kf94fxoX51+t K/UppHqLfpG+twWEZsiON8jLkyb3xS4JMEch9wVCpP3egTxtt3c9kTmbTCB2uY56OGONe52ViAa 4TjtOfeJoAfc1UpbhnWIw0dj3cc9VbFx3YqQLMYW9u4GYIT5x19vNrnSYKkGWT4LhfkAoZUw95k Kwh5kFpB8UETVjmHEt6Q9upK7fssFS/eFx17BV2F1R79nZbzL6ltY/nOpKfiFwAiRyqiCPB0HJ9 wQAN+cU+HLJtFfpqch20Uyq72MsXGyY5LHoG18zAkNDWEoyACiJlUhityXLih1hPL3NZsleb1cG XsvGdX/QPfkxe9I3gWw== X-Proofpoint-GUID: pHGCpxqNTw7RSQQTR5E1Vj9qF-n0e2ZQ X-Proofpoint-Spam-Info: AW1haW4tMjYwNzE3MDE5MiBTYWx0ZWRfX7JVojjRhTKba 0tz74ghu9nnNRP6LjK/d6j0MuasnZoCkddR/Xk0RCtli0SnhA0cIg1RumFT28/Mo7SuW4Bda9Io ArZlCUL/XrQTJtIQrqdgHXC3qP+oUXk= X-Proofpoint-ORIG-GUID: pHGCpxqNTw7RSQQTR5E1Vj9qF-n0e2ZQ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-17_05,2026-07-17_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 priorityscore=1501 malwarescore=0 spamscore=0 adultscore=0 lowpriorityscore=0 clxscore=1015 bulkscore=0 suspectscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607170192 Content-Type: text/plain; charset="utf-8" Add an execute_tuning callback to struct spi_controller_mem_ops. The callback receives a mandatory read op template and an optional write op template. On success the controller sets op->max_freq in each provided template to the validated clock rate. Add the corresponding spi_mem_execute_tuning() wrapper that checks for callback availability and returns -EOPNOTSUPP when the controller has not implemented it, 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..ae9e2d7ac6f3 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 the controller doesn't support tuning, + * or a negative error code on failure. + */ +int spi_mem_execute_tuning(struct spi_mem *mem, struct spi_mem_op *read_op, + struct spi_mem_op *write_op) +{ + struct spi_controller *ctlr; + + 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 Sat Jul 25 04:54:27 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 8A245390C95; Fri, 17 Jul 2026 18:52: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=1784314344; cv=fail; b=IPjiqF8WwTokK3P1p0IktSvES+igzRZvFrhoOkAup8jFE1o3c9Cdb23n8zwpb9uwOUODAerTKLWvP5O3haLugrL31daydpiG+75pfw8f/zMxiBN/ZLbw+1rEUJgLYzWJrQoMu6yYB0Kj3rZhU6HlMdrIujrZprBEHBM3OkbHIsA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784314344; c=relaxed/simple; bh=v6ww6XIH8TcUT23LUPoMxzFGFmhFMyzO6/EXwGCMXPU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ZzVo3EuAmhx/6efy/egXYEM9p8Hdq0+XkRMXc/rWntd+8BACBTQgboYPlFZYQdx7K2qTwOW37+ggGjYzgm5RKAlhh61f5cVYtftytz8jhQAtRINB2usAf+eDatUtrxN9sMr+KCWuBK7vvUpk302Oy1ngxwfD837KNxG7NaZttFQ= 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=LVabmH+B; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=cya8Rpn0; 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="LVabmH+B"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="cya8Rpn0" 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 66HIlUBl1570175; Fri, 17 Jul 2026 13:52:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint-05-2026; bh=vRIdRiZggGVJbvsgQ0voaqOH53asB/hPokr2J9K8C Qk=; b=LVabmH+BjzcGKDhhD99CYUwfvTI/sVkoDNGI4OH5DnbUDW0hBxLU/08bt IXlrsvyxQt9YgWDcU430OEJMiy0gm/ePw2k3dDlHqqaeogtOz8FnM3irnxLULn// 4wE/hgWCmtlSKp6ll59E6sSgmryujIq0FCAKMj3Hz+2e+10JRmgN/M4u6UCf6nYS CoIzI2l2HKud00760ZCIsio+4MQ03BNTEcOuWN5YRNV0hmheml45kdvnf5pAFyJg DQSco5Qqjx9FI/mKAWh5L8NlQfDt1frrQr94ydPTR+ETuGzIO/PZqr0RKeIOH7SI 6clWTFlwn1CKH16Whuc8K3ObdNAVg== Received: from bn1pr04cu002.outbound.protection.outlook.com (mail-eastus2azon11010005.outbound.protection.outlook.com [52.101.56.5]) by m0384305.ppops.net (PPS) with ESMTPS id 4ffgsmbgr2-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 17 Jul 2026 13:52:12 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ZKXKcA1YqI8W3hPRyd5KZTj1fGlsqqjosQPoc1dn8lOWdRVXC3H//pkQcnCpxTSk/K9HA2W/1DUn4wG30LpJNIU6ilS5+iaXrGeM6qWA+ZOUGbcSSFOTxFyOHZIkqtoA8Ln3w+8JZulo0GrYDLuvA6d3c/FITja6Qxx9wx/X6Axd0PT2PnCG2UTmHpvC4PXg8LtGwbTEvpTYOOTxl1RnyVsufP+YHsl74uEXtLBxwVZ92wgqxe+IEsJr6NzeejePUHDHXvwRFAUDwSVsP+yPeaO/9/wsrpi2uhjhTxlHZTt6gwNuzS2Jz2FJnoVLZi/VDqNpP9Nn5srRS0l7UsGUJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=vRIdRiZggGVJbvsgQ0voaqOH53asB/hPokr2J9K8CQk=; b=xfHTReXgwB7FO8WYHRE84FD36oXAZqzEOqCnDa35MjaoFd2blZKCUZVOyoE4085fnbHH1ADZXr+S1pBYgZJiyrK7pjHRiXq83Em++IdjyPti+Gwx1jrL2hfjjqluxpOleHCxKvlawahUXxw7O6kYOdTXdt1aUnLRiQmCKXKPFhnGXyS9P9H3qtfbjpnPMcxluxpJDd/1NGxLYfnNPI6hImFfr5HV84VGGanYrbNjMpxS2w30DwRlmNxoW4UE/NFGUY7gyRY7c8U/HvX9qLlv8SkU9/LPHgpPkniVE62kmGjw2tx2vAo4645gRjE+C5AJ9sSEOBeYxOjOqGGhtdg5eQ== 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=vRIdRiZggGVJbvsgQ0voaqOH53asB/hPokr2J9K8CQk=; b=cya8Rpn0TLQs8lcgKjjRD+KdrQa00zIanwLPkqATKdp1xkuoGVsdObHUsFrub+verPe0nh8SVeLlja39Sdyb0XhzWOprOmn1ieSJRKgMWNxblhWGkLdh8+KPhezLmSYCfYjrkSW8yLC+QsKYw9TBH0iQMNh7qzYol688DqZdxzw= Received: from MN2PR03CA0011.namprd03.prod.outlook.com (2603:10b6:208:23a::16) by CH4PR10MB8148.namprd10.prod.outlook.com (2603:10b6:610:244::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.223.13; Fri, 17 Jul 2026 18:52:09 +0000 Received: from BL02EPF0001A0FB.namprd03.prod.outlook.com (2603:10b6:208:23a:cafe::27) by MN2PR03CA0011.outlook.office365.com (2603:10b6:208:23a::16) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.223.13 via Frontend Transport; Fri, 17 Jul 2026 18:52:09 +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 BL02EPF0001A0FB.mail.protection.outlook.com (10.167.242.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.245.5 via Frontend Transport; Fri, 17 Jul 2026 18:52:07 +0000 Received: from DFLE204.ent.ti.com (10.64.6.62) 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; Fri, 17 Jul 2026 13:52:05 -0500 Received: from DFLE210.ent.ti.com (10.64.6.68) by DFLE204.ent.ti.com (10.64.6.62) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Fri, 17 Jul 2026 13:52:05 -0500 Received: from lelvem-mr05.itg.ti.com (10.180.75.9) by DFLE210.ent.ti.com (10.64.6.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Fri, 17 Jul 2026 13:52:05 -0500 Received: from santhoshkumark.dhcp.ti.com (santhoshkumark.dhcp.ti.com [10.24.52.55]) by lelvem-mr05.itg.ti.com (8.18.1/8.18.1) with ESMTP id 66HIpU4q240969; Fri, 17 Jul 2026 13:52:01 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , Subject: [PATCH v5 06/17] spi: cadence-quadspi: move cqspi_readdata_capture earlier Date: Sat, 18 Jul 2026 00:21:05 +0530 Message-ID: <20260717185116.2065505-7-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260717185116.2065505-1-s-k6@ti.com> References: <20260717185116.2065505-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: BL02EPF0001A0FB:EE_|CH4PR10MB8148:EE_ X-MS-Office365-Filtering-Correlation-Id: 3842ffe6-634f-4b70-e266-08dee4348015 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|82310400026|36860700016|1800799024|23010399003|56012099006|22082099003|18002099003|10067099003|921020; X-Microsoft-Antispam-Message-Info: Xffn9T5IwJlGnukuuRZZty+TkTrRFt7+OL25DzXZZPnYX47/IzjNBiDdVA+Q7TObe1n2/tDgnx4BhtdGnF2z52iLpMaYQhMqV6yzj9dQjgahwgU4gx9wCedcKIEUi5o61FiQRB0viu9t1sTxxE0PfFcfcUGlTE0Y4/HVJgJ2kDH/wA9Pq959cluyMmN4m6NVkJHIY1SRpMSC1JBs1AtzYaRJbwzooUYc2d4zAHJHrDClsLJM4SdbyA0HDml7BK4JLYTC2y2PkHyXjPt+9Sm79QDe0gp47VY3fEovVsx6Ezj0Drkah6GdAZZGIhf79oljH7WP+akxTa99YvNyveSh6ZmPBIOPACPaFlapmOV0cojyb0U6j3yk3WWmotJ1nG7XK1BxxZdRd9Xo7jswMs3rnDRe/iGrYeK55L/8skatW6AhuN1dOkX5Ge0RT8SljoNb2ffFzV2g9SZrpD8ByDRiwL89VDucAnAfyhNZVnucUaOjJjA/X37+YY4sx9x0rpZ0TOOKHLRc9cOfvc73L4li5Sg3KeWL47EIwJCj6rnFh/NUaaDGWjl6FT0TWJCeHkihktLwd+/aOaoq/qPd6f0EiRtZeMiBW2Z6Jmzr6UMuxRzDxoCeg5LCoT0jVn99jLeKRvLozqWazV/Gpd8+CwfC7hEz1JSZ0/KY+eXZ2wLIELltPQLqPl791Wd2SUnNdZh/xsR797KHX8/+43aiF/0OSoBPLOV2Nv3Lexy6hQa/+xQMIolib/4Kc2lSRKrnCkEU 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)(376014)(7416014)(82310400026)(36860700016)(1800799024)(23010399003)(56012099006)(22082099003)(18002099003)(10067099003)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: N/O4SVHLrzzZFHXN6gXhLHAyv5uK84q//TjoG6Zfu0rEQFxR6wTYwuwhNO//478CQUIGBwExVRiRdPgsYf3BH4ZYQSoakfujYPGThy4W10gkANiO5ti+OjFXM7drsT5HX67aa14bYY0WJrXzT7Fh4wQWJrkF+okPA4z+U4IsrVsM3Yfd2tfStC65LtB6w139EEnnXOWF4fxP/NDDgwbduRVmVTs4AD3tQry5kDZDCyYi2vo2QndXacMFKDqa1GBIZImv8DHP00a7hUnrBGu9jz2iBlE13jMDBpzbdpkYvaKzW/vWodo/Cznj70hS9wd0ZROj6KpAtBIIhLSQV15GtneiXeY0QNonfQ0LdcYOtxcpeFwqGKBHdac1JlTWb8+s4Ch0NARD6EyTe0AUqGiS2R0F556V/OZlL7rp2zu88Y4NR6M25H5JkglE7VQVP6OC X-Exchange-RoutingPolicyChecked: Nbqa3poZdiiZI5/A230u2vSOuo616jKF7BWVLD7pbx9HVMpEm/LrE0DJKeCJqOzgzpMcHdIBEMpFoSAwMmiris7LSUdS5fNFsnST89nsEw2Y0kdO3gjH/8TTALSwNCs99zBYBYMekrpucXiF+3mOoKCIQyyFTl9pyptiDylR1MNI5zXGswc0lc48IjqkrPb+fKBjqGDZwaDU8WtXKF1Guu5/HWrKRDcU4qoJx6EvCd/7+YfldXwabn6qEG+aMRnhk8LWJRymPVpppGMpLy5KrqFLn2fcyp4rPCAFMYKQZqJpLOxnb4bPQMHCn1YNWMfRA9HR5PR6mBnsiKr+Wmuhyg== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jul 2026 18:52:07.0383 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3842ffe6-634f-4b70-e266-08dee4348015 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: BL02EPF0001A0FB.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH4PR10MB8148 X-Proofpoint-GUID: rx4R1AeMRGiCRvBdcFTyzUk4wQ0WuOdN X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzE3MDE5MiBTYWx0ZWRfXxvCNY6DfQQrI lvI6MDBKxnNt4vpOkEuCFPdeAFZA0XKsAFSFkjecZ+O87b5mM4XVaI6cMKNl4JN1rH+S+8yedZ6 dFYwHqbk7iPQiaNHYWB7VUaMbW04i6skCleYtjBq3AK1pemzrEHoQReoRYlEgMdbQbaQISel7ts 8HRUs/WdNrbRmQ0Ywdnyptn/ZqME/XpXhxzxQi0XsqoBnabnTGY4DEnYNRqkglcuTGxXqYVwCw3 pZKt1cMiIIGqWLP6/dSrYO1SdVqEcenRijtBC+a+7h+IF3Y+2Nn58sySHe+mPv98X37SYDl1LkZ igJgFHUZ8lwUcvt6F5/Pon4njbio0x/UXRr64TbSpcp9lNzZ6QKbOdyiyaC3QMYzEwwEZY1tmuG Z0W/Dvmrx8/LGb9KtAyj/pS3EZ0HdZItzHOktQrz3hiU22+BwDfx+e6BfHszgzfNcSL0HBnaJZ6 1gUMw/2PF2+Kw9H77Bw== X-Authority-Analysis: v=2.4 cv=GJ841ONK c=1 sm=1 tr=0 ts=6a5a79dc cx=c_pps a=sh1HRyDNv5RGx04/W1QObA==:117 a=iwqwCZQqcuTv3JOpYdM7/Q==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=RAioF0-LDSMA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=taLDd7a_hP9WKsMzeGRc:22 a=P-IC7800AAAA:8 a=sozttTNsAAAA:8 a=2vpyfyhlguDYHLkT4YcA:9 a=d3PnA9EDa4IxuAV0gXij:22 X-Proofpoint-ORIG-GUID: rx4R1AeMRGiCRvBdcFTyzUk4wQ0WuOdN X-Proofpoint-Spam-Info: AW1haW4tMjYwNzE3MDE5MiBTYWx0ZWRfX6q30SVopgJsI h63ZSZIMGENUBG+0kb3Uxq0KdudiRycvlc/0DRDeX3wV9aYSgHw7pmJNZk0hEJTdl1NTHe7Q9/p 1CoIxT110cuuccF3dgLikjJrqL0DsTg= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-17_05,2026-07-17_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 clxscore=1015 impostorscore=0 malwarescore=0 lowpriorityscore=0 priorityscore=1501 suspectscore=0 phishscore=0 spamscore=0 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607170192 Content-Type: text/plain; charset="utf-8" Move cqspi_readdata_capture() function earlier in the file. This is preparatory refactoring for upcoming PHY tuning support that needs to call it without a forward declaration. No functional changes. Reviewed-by: Miquel Raynal Signed-off-by: Santhosh Kumar K --- drivers/spi/spi-cadence-quadspi.c | 45 +++++++++++++++---------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-qu= adspi.c index ecb0be394696..f8e266372367 100644 --- a/drivers/spi/spi-cadence-quadspi.c +++ b/drivers/spi/spi-cadence-quadspi.c @@ -457,6 +457,28 @@ static int cqspi_wait_idle(struct cqspi_st *cqspi) } } =20 +static void cqspi_readdata_capture(struct cqspi_st *cqspi, const bool bypa= ss, + const unsigned int delay) +{ + void __iomem *reg_base =3D cqspi->iobase; + unsigned int reg; + + reg =3D readl(reg_base + CQSPI_REG_READCAPTURE); + + if (bypass) + reg |=3D BIT(CQSPI_REG_READCAPTURE_BYPASS_LSB); + else + reg &=3D ~BIT(CQSPI_REG_READCAPTURE_BYPASS_LSB); + + reg &=3D ~(CQSPI_REG_READCAPTURE_DELAY_MASK + << CQSPI_REG_READCAPTURE_DELAY_LSB); + + reg |=3D (delay & CQSPI_REG_READCAPTURE_DELAY_MASK) + << CQSPI_REG_READCAPTURE_DELAY_LSB; + + writel(reg, reg_base + CQSPI_REG_READCAPTURE); +} + static int cqspi_exec_flash_cmd(struct cqspi_st *cqspi, unsigned int reg) { void __iomem *reg_base =3D cqspi->iobase; @@ -1274,29 +1296,6 @@ static void cqspi_config_baudrate_div(struct cqspi_s= t *cqspi) writel(reg, reg_base + CQSPI_REG_CONFIG); } =20 -static void cqspi_readdata_capture(struct cqspi_st *cqspi, - const bool bypass, - const unsigned int delay) -{ - void __iomem *reg_base =3D cqspi->iobase; - unsigned int reg; - - reg =3D readl(reg_base + CQSPI_REG_READCAPTURE); - - if (bypass) - reg |=3D BIT(CQSPI_REG_READCAPTURE_BYPASS_LSB); - else - reg &=3D ~BIT(CQSPI_REG_READCAPTURE_BYPASS_LSB); - - reg &=3D ~(CQSPI_REG_READCAPTURE_DELAY_MASK - << CQSPI_REG_READCAPTURE_DELAY_LSB); - - reg |=3D (delay & CQSPI_REG_READCAPTURE_DELAY_MASK) - << CQSPI_REG_READCAPTURE_DELAY_LSB; - - writel(reg, reg_base + CQSPI_REG_READCAPTURE); -} - static void cqspi_configure(struct cqspi_flash_pdata *f_pdata, unsigned long sclk) { --=20 2.34.1 From nobody Sat Jul 25 04:54:27 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 05DC5390228; Fri, 17 Jul 2026 18:52:28 +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=1784314350; cv=fail; b=lZZtHMFyy8/OVHLj6v7/ikwCxR3r5yDcX2fqgCPcB8bpdbCaOVbSqyKHXm6EvK0IH5z/sYVBXKDiU5x+IC1C1uV0wZcmsGCrX4kxz0u2y7oGznYfgo4qCnfuDrIn/4I9nCqlposZ11Ta3ZehziH4Q8oSIIvxsxvXVcdHQx2TFSQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784314350; c=relaxed/simple; bh=nHERynUITfg5e3Nh2yAHKyBReZZf4m9KBYLOhEczroA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=gJqFLyBCVALNT5Kb0V9Myo87A70kD/dxeFC27A7IuR6Tbi0yL18Pu6JlC9FV5eOV6BzIzxucjVXD45T21vHwp3ygztjQz3l40suB/u5E/RuQxzqqfugc0dTArQn+1x44wxOtVT5BMe19RqjM4gGIMXOCA0XldLB9uKDl1f1zCsw= 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=ETwZcZnQ; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=ls/wFkEP; 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="ETwZcZnQ"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="ls/wFkEP" 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 66HIlFLw3222590; Fri, 17 Jul 2026 13:52: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=UDgIqenZB3DR5a29o3tuvANtwgRl7SpThCxLM+b+1 nQ=; b=ETwZcZnQebBGluAKxwUBtg875N/IPKDZ/aX0i8o9kHUvVE4vNnISN87tT nSKYNhDpi3lDkTP6MDPPp6uoRHCxDsT2dsjZOsUiH2D1LKXkF0Q/IeZp8Se5E6FW 07OXPLSgUq/PtSoyFoVb6GeUo5iJ1H3xVN7VFDUoGhgwahzOfykH21RgCfHdtTbY jl0OQNMzv2akXEzU1ebaLjCIFm1ccjfTOxRLwNXjsDDZH4S5urlXAJOvNRATw0xy PhxJOs4Y8wYQDxt8QbhqK6FNqYdlGwxr69ug5WVDQD0K0coX1hRzH2JRciWIOA4E aZyVIEdH+lhwMd5n+Oyk7p5nNE6iA== Received: from dm5pr21cu001.outbound.protection.outlook.com (mail-centralusazon11011042.outbound.protection.outlook.com [52.101.62.42]) by mx0b-0002e601.pphosted.com (PPS) with ESMTPS id 4ffkc3jtxy-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 17 Jul 2026 13:52:19 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=P8IfhhJ1RcJAY3QJrkpUxJ47dQElT6IpCDqZ2S05xveOP0oPJt50ZFk7GaU/UzwSTY47yzkTkm6fXC5rL9CCzySVkuYUIvT89DVB+qvCPz7Fp69bXKFTcNEP2kKuro1VgE3mLMVL42LwvnzwLnPim4zOwNcGBBC1ikHe86mJlEKuetvbY5/wGACRobqECpwXxGrKY3/BUmd0c2GeI0Opi1LCfSzHvMbbNsaHPCbY6Grtb2Z1f1UbDMNVqe6WH91Gid+NP8m73Q8uwHO5SjNuKdmZc/MXEq5iuDLMnkO77BBvnM+urzi6DOJMmyVORZ8m59ssPxsQj9hCy6fS3/BQYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=UDgIqenZB3DR5a29o3tuvANtwgRl7SpThCxLM+b+1nQ=; b=AQ9GDbzSqkCYmy7dnbONRPy9Vpt8bd8pXzyZeLQhfoTXWO9dxAjbdKJ+XqHzvhiTyVQB8DCTfea6HNqDhDMMfoj0YW2FEEVMzVE9kSs2IUPH/I9uA7Wy1f8zFqJdplcqi8H3O58pp7rQXqAVQscLbCynES1ztGSEbRkBlb2sJQtGLUBir11UrtTi/iZiUwkoR390R17sTlutffeAhcxhVoC7ispnXyjbm5uKLWMK4bVay+wIznkIGRB3Sb1HUlK1IpwOQ2bgNqWKWpbIe/e8ABcA11ylpuFkNCuhkf0knY5N1W5sbPeFUHwuVSdHmAMRmtY5JyctcOvrvfXZxYpKMg== 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=UDgIqenZB3DR5a29o3tuvANtwgRl7SpThCxLM+b+1nQ=; b=ls/wFkEPL5r9AYBeBiDbe9Rkmwv9KWELdJetkXlGJz97CK/gCtfPv1I4EMuEEB+rbiTCH7RwMqb8Rho9FK2nsMMgW8zUdtsdnfLjqD8FuNxULmwSb8gGRay/eo2g82ZN2h8AXLcYhga87cge8whXFRkaQ5FOaQo3fGvquZYtCys= Received: from MN2PR03CA0026.namprd03.prod.outlook.com (2603:10b6:208:23a::31) by SJ0PR10MB6432.namprd10.prod.outlook.com (2603:10b6:a03:486::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.223.12; Fri, 17 Jul 2026 18:52:15 +0000 Received: from BL02EPF0001A0FB.namprd03.prod.outlook.com (2603:10b6:208:23a:cafe::a9) by MN2PR03CA0026.outlook.office365.com (2603:10b6:208:23a::31) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.223.12 via Frontend Transport; Fri, 17 Jul 2026 18:52:15 +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 BL02EPF0001A0FB.mail.protection.outlook.com (10.167.242.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.245.5 via Frontend Transport; Fri, 17 Jul 2026 18:52:13 +0000 Received: from DFLE212.ent.ti.com (10.64.6.70) 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; Fri, 17 Jul 2026 13:52:10 -0500 Received: from DFLE215.ent.ti.com (10.64.6.73) by DFLE212.ent.ti.com (10.64.6.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Fri, 17 Jul 2026 13:52:10 -0500 Received: from lelvem-mr05.itg.ti.com (10.180.75.9) 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; Fri, 17 Jul 2026 13:52:10 -0500 Received: from santhoshkumark.dhcp.ti.com (santhoshkumark.dhcp.ti.com [10.24.52.55]) by lelvem-mr05.itg.ti.com (8.18.1/8.18.1) with ESMTP id 66HIpU4r240969; Fri, 17 Jul 2026 13:52:06 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , Subject: [PATCH v5 07/17] spi: cadence-quadspi: add DQS support to read data capture Date: Sat, 18 Jul 2026 00:21:06 +0530 Message-ID: <20260717185116.2065505-8-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260717185116.2065505-1-s-k6@ti.com> References: <20260717185116.2065505-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: BL02EPF0001A0FB:EE_|SJ0PR10MB6432:EE_ X-MS-Office365-Filtering-Correlation-Id: c74af2a8-a892-4856-7c95-08dee434842f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|7416014|23010399003|82310400026|36860700016|22082099003|18002099003|921020|10067099003|56012099006; X-Microsoft-Antispam-Message-Info: pXEqX08TWRyfzOaw8mFs8vTlVlzelGlF6GLvjd6gdgFOb1mU8xfDQI6RVQZAt2P7Ubj/wd/PnWIxmUIsl552wrWaZgeXB8+vUZdQXL7wyPmX3+SYQofyBVw46nuvpVjV1MTCnG7wUbEFTY6YuSN5H7uxgER0sGsm7rIfKkAsoXZmwTdJjxCY50dHpfSwtmowgqkl78g+anOIES0/jrNYsTWZ+eD2/duHKV5wjGyUbDHrmpMAzigFfC8617bpMUdZ/pAkb3JP+n+Ge5uH6ZXPmhevP0TbK37HyE2LMGuF6X5F89SApEeejuP31Q7pMgabErliiccs32y8vbwe1/xLl8vxkWuF8xh4+qGZenywIzaj+vQOz4xL5K2jGJj2ph0kaw08MLGVrw//7TjYjU9DEdtON4TQNWnYA6bErUJQs6334pMzHTBsG2n3ozUgH3fgEqgLpGTmvZEFK2jy/Jmgwem97sBy9+rPKG6WekBQ//UjqaZ9CnXDnaGMCIpK4CzASOyCjMJ6gQX5RQw5tR6DQ0GGCO66sznkFrATI8sJaz4AE6RrKrYQKYpLIakSBp8W8pVOCaPiXGqSNUcK7cveFdCDScR0J0w/6XqRCoYnAxrscGTpqBSl7N4yPnBHhtG5dVuIK/yR2KwXm0zsUqMeQ4V6K/g4VdL0JtVcO2bDYLBAc2fERlbSrm4abH4vBdcH+FhfnSA0NMcrJ5V1nANgaxqyNXM/9RnaZ5Niu2mpx9Ux3sAC+JxKZDA41Aspukio 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)(376014)(7416014)(23010399003)(82310400026)(36860700016)(22082099003)(18002099003)(921020)(10067099003)(56012099006);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: zratcQh1+I8e9wkPFB7eOqE0BhSriYO3TkM40XX6nZyJH0qUw7cySjBh0xR+ECF8KPF/0kTU0Ed762NohFqN7QmcVR2Go7w6buSz2l/hhuNmXKiOPHv1IgWYPyNOH6Qw7TLqKx79ONxbPQX5zwHbxxDvwctRtUjnk3V176By4arvBJyj5eleV5qd6VY3ooLJUnUrNK2tnm8Apfh7eJYJIJR/fAo/UW5zu5fXaVh5Yhua1KVCPRg/FSC2ctSB8fLz46LHx8kGpGcAzOEsUNXdzs8o2iyTe4IUFsxL1R4k83BbB6RfRl9ojUm8UnNRvw0fHbYYPS77n8f67xjL02SX2blTw6wobzxmOjewHJlt76Zj6Ooe2AZMn34ttJ9JOuMDrNhDZ43TQGyAJmQOS8TO3eLbsSLeSxiNFDWt1oUZqVf0vxTmmzhPnvIrFAdw0yW+ X-Exchange-RoutingPolicyChecked: XYA21eoTjigRycCXyJXGdrD7VkdPbht198RO+iX7+vCs/QVI68rv7PZzLCE3XQCy+n3eVe1GlAjOWqWyJ4wadV/wnjSTZGQWA/sOk8SnFohir6jLIJinSn8XWGz3YELNtyvYL2aBk3+3ocWTbtlY5YUQRbNNaCorSvm8yoYXEn4ZM7eR3zTqQm32G/yiHF+9j5Yo7V+ZbD8XRBk+/2Le9E088+oIU3FxBui7MsljNaKiSZ/76QkDv4aQJk3QUsH/MAkFueGMa32j39HUYQPjWW0q41/U8XhjFAbTN4pHRFPI4R9jBJD4knUKLM6cizKYfVtUQYkesy/2MV6URgTNug== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jul 2026 18:52:13.9228 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c74af2a8-a892-4856-7c95-08dee434842f 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: BL02EPF0001A0FB.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB6432 X-Proofpoint-Spam-Info: AW1haW4tMjYwNzE3MDE5MiBTYWx0ZWRfX1y4ehPrMeXNi TyRvsFJgTQA7CUyr2lwFSbK8evSeRenOy5DzZWBKI3tZpX9MzkW9AL40VXPO/eimHpWSZwZiHeo 7MpCGqphz3OZnQKIsavjozsTzlty6KU= X-Proofpoint-GUID: -EqEQBDYkva5UdJlQa5ompPQmXZfyFtP X-Authority-Analysis: v=2.4 cv=M7F97Sws c=1 sm=1 tr=0 ts=6a5a79e3 cx=c_pps a=Sa5LwqyZh1jbhgnehO2qiQ==:117 a=iwqwCZQqcuTv3JOpYdM7/Q==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=RAioF0-LDSMA: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: -EqEQBDYkva5UdJlQa5ompPQmXZfyFtP X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzE3MDE5MiBTYWx0ZWRfXx+6bTWegbwWH qc9g3J43uAO8YN7EXSNfMD8MK9Fm7DPPQRn6Hy7yl2xFxAd2jFk/rCe/BKvNFBP0ofYgxAL6U1K Z/2tdqJk4LJOyPvL9be+1W/tsEKc1buBVqxSsuMwSmb4PMEFypS/btlurhFKMe3Uk3m81nk7DCK 0hN1/McbtH0xR2xmvKMkfB/pzWN4zm6FXzSQRTl5+7EHn02jOuOzPuWP0y+LRSYyVxBOA+8CbP6 WgGZra7dhyzRMTHNiH5oi0Sz9PsUU3lDxelTtTp/uiTvEgh9SDrMXzcf4HIiuNRauEfrNLvsEyU 9XnJSb+OSlcGedh0YbHHOf4WMUSYa0DjcQCeurwszv6EpK6SXHvYi6VhP69s3CtFWV2H17sHtRd SpAvGq4sih5CzNoa3WSP3WB+a1S7A06K20w10gWL58oQdlxdIrBKRZS03Lo16/oujNM/ecEY55e 3dfVeE7s99pov9gGX8w== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-17_05,2026-07-17_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 priorityscore=1501 bulkscore=0 adultscore=0 spamscore=0 lowpriorityscore=0 malwarescore=0 impostorscore=0 phishscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607170192 Content-Type: text/plain; charset="utf-8" Add DQS (Data Strobe) parameter to cqspi_readdata_capture() to control data capture timing. DQS mode uses a dedicated strobe signal for improved timing margins in high-speed SPI modes. Reviewed-by: Miquel Raynal Signed-off-by: Santhosh Kumar K --- drivers/spi/spi-cadence-quadspi.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-qu= adspi.c index f8e266372367..046fa5d69b0f 100644 --- a/drivers/spi/spi-cadence-quadspi.c +++ b/drivers/spi/spi-cadence-quadspi.c @@ -192,6 +192,7 @@ struct cqspi_driver_platdata { #define CQSPI_REG_READCAPTURE_BYPASS_LSB 0 #define CQSPI_REG_READCAPTURE_DELAY_LSB 1 #define CQSPI_REG_READCAPTURE_DELAY_MASK 0xF +#define CQSPI_REG_READCAPTURE_DQS_LSB 8 =20 #define CQSPI_REG_SIZE 0x14 #define CQSPI_REG_SIZE_ADDRESS_LSB 0 @@ -458,7 +459,7 @@ static int cqspi_wait_idle(struct cqspi_st *cqspi) } =20 static void cqspi_readdata_capture(struct cqspi_st *cqspi, const bool bypa= ss, - const unsigned int delay) + const bool dqs, const unsigned int delay) { void __iomem *reg_base =3D cqspi->iobase; unsigned int reg; @@ -476,6 +477,11 @@ static void cqspi_readdata_capture(struct cqspi_st *cq= spi, const bool bypass, reg |=3D (delay & CQSPI_REG_READCAPTURE_DELAY_MASK) << CQSPI_REG_READCAPTURE_DELAY_LSB; =20 + if (dqs) + reg |=3D BIT(CQSPI_REG_READCAPTURE_DQS_LSB); + else + reg &=3D ~BIT(CQSPI_REG_READCAPTURE_DQS_LSB); + writel(reg, reg_base + CQSPI_REG_READCAPTURE); } =20 @@ -1317,7 +1323,7 @@ static void cqspi_configure(struct cqspi_flash_pdata = *f_pdata, cqspi->sclk =3D sclk; cqspi_config_baudrate_div(cqspi); cqspi_delay(f_pdata); - cqspi_readdata_capture(cqspi, !cqspi->rclk_en, + cqspi_readdata_capture(cqspi, !cqspi->rclk_en, false, f_pdata->read_delay); } =20 --=20 2.34.1 From nobody Sat Jul 25 04:54:27 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 45B883914EE; Fri, 17 Jul 2026 18:52:39 +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=1784314367; cv=fail; b=dhfvqPrW8alMRKG+vo7OF79oSQcCA560jcSShO4TtN4W3uVlyXssFKIDmDuVH8Gol0Ym4hEKc3d3jwAFoNKIvoLdEnit0hkFNBy/b+SgqLY5rFKfVvzpIElBkicaJ2vksSCIiq/UOBdAPkMFSB0Jm9UUqjoTwEEX7SBrieJBo+8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784314367; c=relaxed/simple; bh=Ws9G5suFGgWgDg6znQfNl9iU/PI5yTaPNUjDgEJ2oLk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=uT0LsNjb/jXrKw9OZavsevljSvLxDv+COyUFJSox0w0wg4XbKDt9O3LRZVZp2oWBFu7ky7V/5QPs5px7+fbRTGqnANwR+GflW48NOsBR533XPHpQs1tERaUkF5BPDjNeRTQCMFTnG4gTMyJ9ndpTCPt32DIpIlYKvDUe82BHDAs= 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=ptVQEbw8; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=HpOAx9p6; 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="ptVQEbw8"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="HpOAx9p6" 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 66HIlHdB1570008; Fri, 17 Jul 2026 13:52:25 -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=jeApygkbCNgx3AJPUNBZRL5kbfuJAq8jwzrWjyGIm dI=; b=ptVQEbw8JOOy8CewhTIG1x+o+hMrGb+uZ9K0SSDq2c0rshDOTmYrJtXqJ 5shRLnziL6+bWSQF8avbqj+LzGyhgZc4akgH+JNUWIvqdvEFkb91rwK2vgcfzlkb UndU22TFY0WEA79Lh9m2cym3hC5XU/c06IMtGxgzq5KbwHm2Et2uIzwCOd/pFVzx lz5/ZkJHJHxADivHzFt7UnWc6jSuaqik4jxFs0syCAiRPLDXXkkNIaTKlJ/Okrks v7t8jkAhfJD9acG/QkvCkMk1HUwbnq8H9QC5z5MuL826MaysC4mfQkDd5nHGLHgT bXn3Z6DloctA8TiOzHlcNRiQt1USA== Received: from ch5pr02cu005.outbound.protection.outlook.com (mail-northcentralusazon11012008.outbound.protection.outlook.com [40.107.200.8]) by m0384305.ppops.net (PPS) with ESMTPS id 4ffgsmbgsf-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 17 Jul 2026 13:52:25 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=tU+8KpFMt3veBFG7xlxCgKIpFpyQO4So7DziL0WMqdd+P5LQYXmCfgxIuh7qZlgC2CORXYIOMsvWXQx3b7rs+94FAOPkqnybeopq7qFeq4SvehM+PdvNMQhgM5hPoF5j0raPSeyX91TdkOUUvEqXe82Q7SeMuAssybHR+VEk9gNd1n88WWTYw53FVLJoYp8fHR6maQCeF1FGIWMVLBqoyRV5TU6b0CiyMviZWiby9fl83LHQZHeaUm2SI1bObFNr4ud/Kr7hvlaGu4gPfNF/BGlxn43eYsjh/Sa2UPrxhkHr7PjTqS+wsynGtOh3Q3pOR9Yj1+E7foUkFRzU0He1jQ== 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=jeApygkbCNgx3AJPUNBZRL5kbfuJAq8jwzrWjyGImdI=; b=bqf6nm3Yue2oWoXiD4/Mnv4PZ51v+cBmEXspsPOjAjy7QZdivoUIbHqDgChgXP36qB5qZIHX0D7XgNHjHhL6s/io4dno3RRy1KA2nNrL4a0KOGT4T4/zVJqWgC81GWsmlAo18PYDC7eQ74mHeexZxAF8shIxk5kyS5s+2NdpiUTNJjm8wK7W0nCJ9az6u9O5SnaNp8efNYDYJeQ/QM6JCsnawN0EpihXGWikuYO4uenqusl2UL/jvzAhUwvjtHPP12CFoepM36hwNJ4CiwVhrGme35bNBFhopdAYgIvval8svSqv4oECiqzlfUwbEhL4udSE8ikj9KSJ4WBqNmXueg== 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=jeApygkbCNgx3AJPUNBZRL5kbfuJAq8jwzrWjyGImdI=; b=HpOAx9p6fbhMehnV0c7VnNYa8UDjHRiMY1/2ksQzg7XEdrhX44fwqSHz5mvvxmuyctWOFGoPO1WBPOMpIBKapZtY+2329dpufzpLMv/yEDqkyXP8oTkpf9+5AcgEs2LGd6gCgio8Mhdt/P2yRDUkfjh11ahHiJqlZI+HwjfP6Xo= Received: from BN9PR03CA0575.namprd03.prod.outlook.com (2603:10b6:408:10d::10) by PH7PR10MB7768.namprd10.prod.outlook.com (2603:10b6:510:30d::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.223.12; Fri, 17 Jul 2026 18:52:19 +0000 Received: from BL02EPF0001A0FD.namprd03.prod.outlook.com (2603:10b6:408:10d:cafe::7b) by BN9PR03CA0575.outlook.office365.com (2603:10b6:408:10d::10) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.223.13 via Frontend Transport; Fri, 17 Jul 2026 18:52:18 +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 BL02EPF0001A0FD.mail.protection.outlook.com (10.167.242.104) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.245.5 via Frontend Transport; Fri, 17 Jul 2026 18:52:17 +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; Fri, 17 Jul 2026 13:52:16 -0500 Received: from DFLE214.ent.ti.com (10.64.6.72) 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; Fri, 17 Jul 2026 13:52:16 -0500 Received: from lelvem-mr05.itg.ti.com (10.180.75.9) 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; Fri, 17 Jul 2026 13:52:16 -0500 Received: from santhoshkumark.dhcp.ti.com (santhoshkumark.dhcp.ti.com [10.24.52.55]) by lelvem-mr05.itg.ti.com (8.18.1/8.18.1) with ESMTP id 66HIpU4s240969; Fri, 17 Jul 2026 13:52:11 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , Subject: [PATCH v5 08/17] spi: cadence-quadspi: add PHY tuning support Date: Sat, 18 Jul 2026 00:21:07 +0530 Message-ID: <20260717185116.2065505-9-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260717185116.2065505-1-s-k6@ti.com> References: <20260717185116.2065505-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: BL02EPF0001A0FD:EE_|PH7PR10MB7768:EE_ X-MS-Office365-Filtering-Correlation-Id: 476e9a38-0c4a-4910-6168-08dee4348630 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700016|82310400026|7416014|376014|23010399003|56012099006|6133799003|3023799007|22082099003|18002099003|10067099003|921020; X-Microsoft-Antispam-Message-Info: /awMV65RD1lIX/Uk26r2JMiXFtQRZdFrGWCJsX7gBXvuOyv6MOSc6VaLV8P6Nuoj1+JwDcpafcf8KN3/xfLPGTKDIQ82FK0ZLLAJX+agW0iFIFWDSYxpKeqjyoO0Ki4RZ9S7TUDJUo83HxaUlGPGMrIwTvlZkKfEYbjgfYc6mO4G3kmcCv4lczkKq2quSMP3MsDSyg89/BwIeHfug3LacaBk/l5/znxWlTwruO6n6B32TcRM756uV1J5K0DdJ+oPFDFLbK/xyDoMUCtnI5KPrhFKYsiE6uFhF9UZbriNKbfxGRz+7SIk5nGLWYNNqMWXO7jtY6nUHsiIhFubugqOP7LUMsB3pYAO99LdzYEum8OZ0LP8oEmbTELGxPzE7GYWranlsHnb3D7pxNnCXwZkBuHba8p4MN6wyvsmng6Ij0yjbM3DeNvBdxnziT9weQEtcMcrj/xQkzt7LRtfhTMkp2C5+cltsF+mOVukSVYnLTk8wl7WewQHoAjuJxRVHTAYtvx27jD/XaLtr9vDCJjwhRzAWm7R+S3pwPaN4zdxzBySUeqqx5w6j7ud8/LMyxQOSpYryTAU7NPdDbS54taWYouP9gcBUiHtVE1uZ/2AjMVRwxJ7SoSSu65uen0qY3CYNSfJadudOJX3t4JyH4TGpfkcdCl5Qk5jsgTIoAcq/MVbx9Hz65fSJXJSh9FOj6SKLKeFy/XF2vjmvmVxgE21qw== X-Forefront-Antispam-Report: CIP:198.47.21.194;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:flwvzet200.ext.ti.com;PTR:ErrorRetry;CAT:NONE;SFS:(13230040)(1800799024)(36860700016)(82310400026)(7416014)(376014)(23010399003)(56012099006)(6133799003)(3023799007)(22082099003)(18002099003)(10067099003)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: JJ8TpcBAzwyPcULOGm+woMvMF6gUZ1Bq6u1vdLRiSWWfLy6dM00h/899Bpd/BMZkMWMy31ohUEtav1Nbq5x8XV6PfG+XMXL0aAODAuiHvcDlws7ZHiFrPFi0yWf8V+7BbPOalv1gAQLBtDgyFGNi6CR8Y7BlQxPbXXDhCBjIwjxLlNt0xluEuvg60RgqSV2X46yP4xnC4QXkKiW3FsQrC1/J/T48SyxO+8IXazRgj43Kx4XU4nnP6pfk0YQ9xTAp6lWGq3ArpJ/JS7hZJ4AS4lETEsGFcjXKzUpiWcmDc8W4JCACOQSsK2Xf+u/hkxfquCbqeBImftS7vhCJUtLxoZO+RG10B10WCTtHY1N5WDqEYEeD6IZI2QD9OHN2daD14PRBVnZ4GdQnSQFuMoTKiXAlLsYgrhoGg0ktT38cXlLuaUe95HDuGNlFH5+eG/Dy X-Exchange-RoutingPolicyChecked: rFa7rE0igZUWw8rU0gRjDDvYDNGJFoQuP33fZer6IkvlJ+nCzhjdq8spsWB/5L5Ghx3tEZGfmLnTS3WpAVM6SiiJlysBPbn2CQB23eYUlYa30GZ6O6tTjKv1Dubq1z7w71vawkAAzFLJN/ae2oJW3Caz8hy1tI/iTLzx3RRes9hWj7UkwW05Acn6E4ehl2VLs9G6okyW9kRsIgei5ZPZ2t0st0+ltwZ2OaOTEB4ew0gFpzbyNnHnQzZtWOC+1IbSJ4+T3dvrHGh3N24ybGWCYaT+9jod+9BQ+merTTTBQSjTVe9Vljio+nSYy6FhUQwc32UQ5Wr925d5EWO7rLg+Aw== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jul 2026 18:52:17.2740 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 476e9a38-0c4a-4910-6168-08dee4348630 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: BL02EPF0001A0FD.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR10MB7768 X-Proofpoint-GUID: NoQi7pUZQ8omQBW3O0yaEykVp67jay2- X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzE3MDE5MiBTYWx0ZWRfXw8xLmFUM5oMp dAPZK+/xK3glwEMKBe8YdhZjSzYYUlrTaDXh1EaNxbmS4Cw7EPmP2/duxpGspEnw/GL4PVeZQ2I xTCvZxznQhGq/1wlBlo/EtrQ29zm00FJVML7QuH0H0bLxvgeG2Ib2h2yWouoW8YQ5cIHhDXvmMf HygOjnbwBoFCauURD45zJ/yf/h6AYhIVfmFobLekKCGxPsW+Z5Uq/yDESRKnKdoZZskTQBc4prM uCFQ2v9/O1bbiGi9nM3MOtfwbl9Cmtr8moyMpDm0Yn1DwFDUT56YYNlXRXbIp+TyHuKKyYIHTlW fKzgeWMc8WbvNZwLQvulWsqtozERHt8hryiQoltUjVth1wAczX9mqV0X1RKbP4sqQKNYH/mTWo7 jZYtNoOHq6Jr14Abtd6VkXnijTUvXVsGf6Nggau0ApGvdlSmRdYzkF/WhkfXI+Oxgpupd12ty+m 7W5ktcVUQsoIVrBOhgA== X-Authority-Analysis: v=2.4 cv=GJ841ONK c=1 sm=1 tr=0 ts=6a5a79e9 cx=c_pps a=FIc/ztLQykAcit3pFYQDUA==:117 a=iwqwCZQqcuTv3JOpYdM7/Q==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=IkcTkHD0fZMA:10 a=RAioF0-LDSMA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=taLDd7a_hP9WKsMzeGRc:22 a=sozttTNsAAAA:8 a=Uch-OgagLyHg9olWpLIA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 X-Proofpoint-ORIG-GUID: NoQi7pUZQ8omQBW3O0yaEykVp67jay2- X-Proofpoint-Spam-Info: AW1haW4tMjYwNzE3MDE5MiBTYWx0ZWRfX3qwtOPfPRyVJ 3VHKnxox+zutNUy8aNEGvsWbUBZyg8ruNuQ00h4iVjt7U27PybOhYiOra30uworhnXRLv2y+S5v RwmDwDxeffiej37wI7gXSPibpARJ7LQ= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-17_05,2026-07-17_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 clxscore=1015 impostorscore=0 malwarescore=0 lowpriorityscore=0 priorityscore=1501 suspectscore=0 phishscore=0 spamscore=0 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607170192 The Cadence QSPI controller supports a delay-line PHY for high-speed operation. Without calibration the PHY is unused and read capture relies on a fixed delay, limiting throughput at frequencies above the base operating speed. Add an execute_tuning callback that performs delay-line calibration using a known data pattern written to a dedicated flash region. The pattern is either read from a NOR partition identified by the DT property spi-phy-pattern-partition, or written to the NAND page cache before each calibration read. For DDR protocols (8D-8D-8D) a 2D sweep of (rx_delay, tx_delay) pairs is performed to find the widest passing region in the combined RX/TX space. Binary search locates the gap boundary between passing regions when two separate windows exist; the final operating point is placed at the centre of the larger region with a small temperature-dependent offset. For SDR protocols a 1D sweep of the RX delay is sufficient. Two windows at adjacent read_delay values are measured; the wider one's midpoint is selected. The tuning infrastructure is platform-specific: only am654-based OSPI controllers populate the execute_tuning hook. All other platform data entries return -EOPNOTSUPP and are unaffected. The calibration target is sourced from spi->post_config_max_speed_hz, populated by the SPI core from the spi-max-post-config-frequency-hz DT property. Tuning is skipped when post_config_max_speed_hz is zero. Signed-off-by: Santhosh Kumar K --- drivers/spi/spi-cadence-quadspi.c | 1745 ++++++++++++++++++++++++++++- 1 file changed, 1734 insertions(+), 11 deletions(-) diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-qu= adspi.c index 046fa5d69b0f..22a5c88bbd8d 100644 --- a/drivers/spi/spi-cadence-quadspi.c +++ b/drivers/spi/spi-cadence-quadspi.c @@ -6,6 +6,7 @@ // Copyright Intel Corporation (C) 2019-2020. All rights reserved. // Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com =20 +#include #include #include #include @@ -65,15 +66,26 @@ enum { =20 struct cqspi_st; =20 +struct phy_setting { + u8 rx; + u8 tx; + u8 read_delay; +}; + struct cqspi_flash_pdata { - struct cqspi_st *cqspi; - u32 clk_rate; - u32 read_delay; - u32 tshsl_ns; - u32 tsd2d_ns; - u32 tchsh_ns; - u32 tslch_ns; - u8 cs; + struct cqspi_st *cqspi; + u32 read_delay; + u32 tshsl_ns; + u32 tsd2d_ns; + u32 tchsh_ns; + u32 tslch_ns; + bool use_dqs; + bool use_tuned_phy; + u8 cs; + struct phy_setting phy_setting; + struct spi_mem_op phy_read_op; + struct spi_mem_op phy_write_op; + u32 phy_pattern_partition_offset; }; =20 static const struct clk_bulk_data cqspi_clks[CLK_QSPI_NUM] =3D { @@ -129,12 +141,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 +163,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 +209,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 +291,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 +360,50 @@ struct cqspi_driver_platdata { =20 #define CQSPI_REG_VERSAL_DMA_VAL 0x602 =20 +#define CQSPI_PHY_INIT_RD 1 +#define CQSPI_PHY_MAX_RD 4 +#define CQSPI_PHY_MAX_DELAY 127 +#define CQSPI_PHY_DDR_SEARCH_STEP 4 +#define CQSPI_PHY_TX_LOOKUP_LOW_START 28 +#define CQSPI_PHY_TX_LOOKUP_LOW_END 48 +#define CQSPI_PHY_TX_LOOKUP_HIGH_START 60 +#define CQSPI_PHY_TX_LOOKUP_HIGH_END 96 +#define CQSPI_PHY_RX_LOW_SEARCH_START 0 +#define CQSPI_PHY_RX_LOW_SEARCH_END 40 +#define CQSPI_PHY_RX_HIGH_SEARCH_START 24 +#define CQSPI_PHY_RX_HIGH_SEARCH_END 127 +#define CQSPI_PHY_TX_LOW_SEARCH_START 0 +#define CQSPI_PHY_TX_LOW_SEARCH_END 64 +#define CQSPI_PHY_TX_HIGH_SEARCH_START 78 +#define CQSPI_PHY_TX_HIGH_SEARCH_END 127 +#define CQSPI_PHY_SEARCH_OFFSET 8 + +#define CQSPI_PHY_DEFAULT_TEMP 45 +#define CQSPI_PHY_MIN_TEMP -45 +#define CQSPI_PHY_MAX_TEMP 130 +#define CQSPI_PHY_MID_TEMP (CQSPI_PHY_MIN_TEMP + \ + ((CQSPI_PHY_MAX_TEMP - \ + CQSPI_PHY_MIN_TEMP) / 2)) + +/* + * PHY tuning pattern for calibrating read data capture delay. This 128-by= te + * pattern provides sufficient bit transitions across all byte lanes to + * reliably detect timing windows at high frequencies. + */ +static const u8 phy_tuning_pattern[] __aligned(64) =3D { + 0xFE, 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0xFE, 0xFE, 0x01, + 0x01, 0x01, 0x01, 0x00, 0x00, 0xFE, 0xFE, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0x00, 0x00, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFE, + 0xFE, 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0xFE, 0x00, 0xFE, 0xFE, 0x01, + 0x01, 0x01, 0x01, 0xFE, 0x00, 0xFE, 0xFE, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFE, 0x00, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0x00, 0xFE, + 0xFE, 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0xFE, 0xFE, 0xFE, 0x01, + 0x01, 0x01, 0x01, 0x00, 0xFE, 0xFE, 0xFE, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0x00, 0xFE, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFE, 0xFE, + 0xFE, 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0xFE, 0xFE, 0xFE, 0xFE, 0x01, + 0x01, 0x01, 0x01, 0xFE, 0xFE, 0xFE, 0xFE, 0x01, +}; + static int cqspi_wait_for_bit(const struct cqspi_driver_platdata *ddata, void __iomem *reg, const u32 mask, bool clr, bool busywait) @@ -913,6 +996,74 @@ static void cqspi_controller_enable(struct cqspi_st *c= qspi, bool enable) writel(reg, reg_base + CQSPI_REG_CONFIG); } =20 +static void cqspi_set_dll(void __iomem *reg_base, u8 rx_dll, u8 tx_dll) +{ + unsigned int reg; + + reg =3D readl(reg_base + CQSPI_REG_PHY_CONFIG); + reg &=3D ~((CQSPI_REG_PHY_CONFIG_RX_DEL_MASK + << CQSPI_REG_PHY_CONFIG_RX_DEL_LSB) | + (CQSPI_REG_PHY_CONFIG_TX_DEL_MASK + << CQSPI_REG_PHY_CONFIG_TX_DEL_LSB)); + reg |=3D ((rx_dll & CQSPI_REG_PHY_CONFIG_RX_DEL_MASK) + << CQSPI_REG_PHY_CONFIG_RX_DEL_LSB) | + ((tx_dll & CQSPI_REG_PHY_CONFIG_TX_DEL_MASK) + << CQSPI_REG_PHY_CONFIG_TX_DEL_LSB) | + CQSPI_REG_PHY_CONFIG_RESYNC; + writel(reg, reg_base + CQSPI_REG_PHY_CONFIG); +} + +static int cqspi_resync_dll(struct cqspi_st *cqspi) +{ + void __iomem *reg_base =3D cqspi->iobase; + unsigned int reg; + int ret; + + ret =3D cqspi_wait_idle(cqspi); + if (ret) + return ret; + + reg =3D readl(reg_base + CQSPI_REG_CONFIG); + reg &=3D ~CQSPI_REG_CONFIG_ENABLE_MASK; + writel(reg, reg_base + CQSPI_REG_CONFIG); + + reg =3D readl(reg_base + CQSPI_REG_PHY_CONFIG); + reg &=3D ~(CQSPI_REG_PHY_CONFIG_DLL_RESET | CQSPI_REG_PHY_CONFIG_RESYNC); + writel(reg, reg_base + CQSPI_REG_PHY_CONFIG); + + reg =3D readl(reg_base + CQSPI_REG_PHY_DLL_MASTER); + reg |=3D (CQSPI_REG_PHY_DLL_MASTER_INIT_DELAY_VAL + << CQSPI_REG_PHY_DLL_MASTER_INIT_DELAY_LSB); + writel(reg, reg_base + CQSPI_REG_PHY_DLL_MASTER); + + reg =3D readl(reg_base + CQSPI_REG_PHY_CONFIG); + reg |=3D CQSPI_REG_PHY_CONFIG_DLL_RESET; + writel(reg, reg_base + CQSPI_REG_PHY_CONFIG); + + ret =3D readl_poll_timeout(reg_base + CQSPI_REG_DLL_OBS_LOW, reg, + (reg & CQSPI_REG_DLL_OBS_LOW_DLL_LOCK), 0, + CQSPI_DLL_TIMEOUT_US); + if (ret) + goto re_enable; + + ret =3D readl_poll_timeout(reg_base + CQSPI_REG_DLL_OBS_LOW, reg, + (reg & CQSPI_REG_DLL_OBS_LOW_LOOPBACK_LOCK), 0, + CQSPI_DLL_TIMEOUT_US); + if (ret) + goto re_enable; + + reg =3D readl(reg_base + CQSPI_REG_PHY_CONFIG); + reg |=3D CQSPI_REG_PHY_CONFIG_RESYNC; + writel(reg, reg_base + CQSPI_REG_PHY_CONFIG); + +re_enable: + reg =3D readl(reg_base + CQSPI_REG_CONFIG); + reg |=3D CQSPI_REG_CONFIG_ENABLE_MASK; + writel(reg, reg_base + CQSPI_REG_CONFIG); + + return ret; +} + static int cqspi_versal_indirect_read_dma(struct cqspi_flash_pdata *f_pdat= a, u_char *rxbuf, loff_t from_addr, size_t n_rx) @@ -1559,10 +1710,1578 @@ 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_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 int cqspi_phy_apply_setting(struct cqspi_flash_pdata *f_pdata, + struct phy_setting *phy) +{ + struct cqspi_st *cqspi =3D f_pdata->cqspi; + unsigned int reg; + int ret; + + reg =3D readl(cqspi->iobase + CQSPI_REG_READCAPTURE); + reg |=3D BIT(CQSPI_REG_READCAPTURE_EDGE_LSB); + writel(reg, cqspi->iobase + CQSPI_REG_READCAPTURE); + + cqspi_set_dll(cqspi->iobase, phy->rx, phy->tx); + + ret =3D cqspi_resync_dll(cqspi); + if (ret) + return ret; + + f_pdata->phy_setting.rx =3D phy->rx; + f_pdata->phy_setting.tx =3D phy->tx; + f_pdata->phy_setting.read_delay =3D phy->read_delay; + 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; + int ret; + + f_pdata =3D &cqspi->f_pdata[spi_get_chipselect(mem->spi, 0)]; + + /* + * spi-max-post-config-frequency-hz must be present for PHY tuning. + * If absent, post_config_max_speed_hz is zero and there is no + * calibration target, so skip tuning gracefully. + */ + if (!mem->spi->post_config_max_speed_hz) { + dev_dbg(dev, + "No post-config frequency configured, skipping tuning\n"); + return -EOPNOTSUPP; + } + + if (write_op) { + /* + * For NAND: write the calibration pattern to the page cache. + * The write op runs at the conservative base speed (spi->max_speed_hz) + * so the write itself is reliable before PHY calibration. + */ + ret =3D cqspi_write_pattern_to_cache(f_pdata, mem, write_op); + if (ret) { + dev_warn(dev, + "failed to write pattern to cache: %d, skipping tuning\n", + ret); + goto out; + } + + f_pdata->phy_write_op =3D *write_op; + } else { + if (!f_pdata->phy_pattern_partition_offset) { + dev_warn(dev, "pattern partition not found, skipping tuning\n"); + goto out; + } + read_op->addr.val =3D f_pdata->phy_pattern_partition_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) { + struct device_node *part_np; + if (of_property_read_u32(np, "cdns,read-delay", &f_pdata->read_delay)) { dev_err(&pdev->dev, "couldn't determine read-delay\n"); return -ENXIO; @@ -1588,9 +3307,11 @@ static int cqspi_of_get_flash_pdata(struct platform_= device *pdev, return -ENXIO; } =20 - if (of_property_read_u32(np, "spi-max-frequency", &f_pdata->clk_rate)) { - dev_err(&pdev->dev, "couldn't determine spi-max-frequency\n"); - return -ENXIO; + part_np =3D of_parse_phandle(np, "spi-phy-pattern-partition", 0); + if (part_np) { + of_property_read_u32_index(part_np, "reg", 0, + &f_pdata->phy_pattern_partition_offset); + of_node_put(part_np); } =20 return 0; @@ -1740,6 +3461,7 @@ static const struct spi_controller_mem_ops cqspi_mem_= ops =3D { .exec_op =3D cqspi_exec_mem_op, .get_name =3D cqspi_get_name, .supports_op =3D cqspi_supports_mem_op, + .execute_tuning =3D cqspi_mem_op_execute_tuning, }; =20 static const struct spi_controller_mem_caps cqspi_mem_caps =3D { @@ -2108,6 +3830,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 Sat Jul 25 04:54:27 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 C3F7E391507; Fri, 17 Jul 2026 18:52:37 +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=1784314360; cv=fail; b=aCV+99i8MMDlt4LukzEKOJ0x3v4Egof9/43fHU+2Dle37U/HmtfR0DT1U2rfeEVRlwN17kff+6S5lRmx62/EKEX1oNrw6D86TCnHEV80izKrbGNEQOENksM0DzIQ14e3AWVEVCkEhsFnRB9PMjxmT9aMx7afQ6WpqAGzoso6kVA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784314360; c=relaxed/simple; bh=9DQhRF1G/rF0B5GALQ3EZyhGRvGzHOF8xUyHuxCZA/c=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=uUots1jPqksCwi9RQxw9m7ABMzlO66GjHtw/sSib4XHGH/7u/TFcR4qeOZP48da9HDydE32gpMDX3DqQxTUtogYpMe3qjgUBrlO1UMCcAXk6ksxmTn22+amwzI1JFokEIl43HRnkbFa5oHAx4tIZnTYNy+PEQC0YtvmXBAeZWdI= 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=lG9lLTDJ; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=Kj54N2CL; 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="lG9lLTDJ"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="Kj54N2CL" 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 66HIlFL43222579; Fri, 17 Jul 2026 13:52:27 -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=teGB7+PbNvdPrr/+A55A/D2LxX4bde9Z29W1r+wtn fA=; b=lG9lLTDJ+gh8Q/q6BsTOS4Lpbmka+2UDqYSetx1Fa8HQarQa1yF3LsYv5 J0mpKNXHCjE5PtKQc42ftYbKbq97G83C2pruCMqxlGMWoPpYf50nh/8NGD5Mde38 VE8G7ANWac235PkzbEetCYJc25/bOMgbOEZ2W+8fgq4BApYFmA8u27eDdUB2PEof 1slHw1FHnr8UXfzEly/FpWGrZ/LtDLQLDz/0fgjSgG1B2cpUXDUCMNNlJau699cg jwgucm1mrkxji/f7SDj31Ue9A792aWuBfspdklfRDsk9/BRQ/LObgmukhiJs39S1 AOjneumSLVXQsbY2ycvhLyKK7srng== Received: from ch5pr02cu005.outbound.protection.outlook.com (mail-northcentralusazon11012052.outbound.protection.outlook.com [40.107.200.52]) by mx0b-0002e601.pphosted.com (PPS) with ESMTPS id 4ffkc3jtyf-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 17 Jul 2026 13:52:27 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=oAByhg96umDb0vL66mZ91RZhe3SgiUeAXS53GxmtyRCx5mq9KpMS7eyi1AUdMttGghKngDmFDxsixym3euHZ16zkiWKxqqeCVntcpUVy+4t2T5JJxDHhfadhOe47GDTV8i2O+m1t8SvZH+EAfl52l4qE9MVL5mVsKcvsv0BFYBr6PCxGLqXFr7nMugWak+mPDsifhmXOYb2S4WVrcMCXxU3tJnuzn2miSZSM5MWiynOxyeqkDF9xquF6MeedidpZBGAHyFbmsRotD1hs8CUXENdg2um8cWjS2lz6mXpgZFJBQIF6qdR1VqXWooowjsah8xIoc8PyoLu55kEhyWh/6A== 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=teGB7+PbNvdPrr/+A55A/D2LxX4bde9Z29W1r+wtnfA=; b=nH3EFeUD4z5zv18KqlSdn8Uqs2m3BZ4NFVguMO81M9sJa7+o+OI4xZ4oafd+p1Rooukw1GwoXiNwpAtdV08xfxPaXcJblDWzlFJ1I2Un131C/e2R9Tj38/Q260olGg4AptnY1sgjnsMR//Q/r17jPHLjU6Sn+rQS4+UVEEeDCybu2RRanu0sgrzqqVjkCzF+kiuoIM2dD15NdgcQ94+jTKn4PQpwiW8LEuJ/lurBEjkHZj/GgLw4lf/GfFK0HmGGuWZ5gxV4yCWsopQR70YSzTZsDJKgt9HIzpBu1OyIel2ba16WHIbjHeo/ArUdreoWFxs8YPSON1uWK06b6vlV8A== 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=teGB7+PbNvdPrr/+A55A/D2LxX4bde9Z29W1r+wtnfA=; b=Kj54N2CLsEIRjLoOeP4i8m1lA5/7y17hgZ6Buo8hnWoqPKxp3UXLEnAhRlrkHUp6AgaJep6EoYSDGLO6AqCjpT5SsXrK+8DJb5I0Lj2nH6rG/JTLNoZvb8BzzpvEVKVaFFLJWJNfL1XGrNIx9nXN6f1w0shVN8I+omTs53oE/No= Received: from BN9PR03CA0330.namprd03.prod.outlook.com (2603:10b6:408:112::35) by PH8PR10MB6455.namprd10.prod.outlook.com (2603:10b6:510:22d::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.223.13; Fri, 17 Jul 2026 18:52:21 +0000 Received: from BN1PEPF00004689.namprd05.prod.outlook.com (2603:10b6:408:112:cafe::27) by BN9PR03CA0330.outlook.office365.com (2603:10b6:408:112::35) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.223.13 via Frontend Transport; Fri, 17 Jul 2026 18:52:21 +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 BN1PEPF00004689.mail.protection.outlook.com (10.167.243.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.245.5 via Frontend Transport; Fri, 17 Jul 2026 18:52:21 +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; Fri, 17 Jul 2026 13:52:21 -0500 Received: from DLEE200.ent.ti.com (157.170.170.75) 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; Fri, 17 Jul 2026 13:52:20 -0500 Received: from lelvem-mr05.itg.ti.com (10.180.75.9) by DLEE200.ent.ti.com (157.170.170.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Fri, 17 Jul 2026 13:52:20 -0500 Received: from santhoshkumark.dhcp.ti.com (santhoshkumark.dhcp.ti.com [10.24.52.55]) by lelvem-mr05.itg.ti.com (8.18.1/8.18.1) with ESMTP id 66HIpU4t240969; Fri, 17 Jul 2026 13:52:16 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , Subject: [PATCH v5 09/17] spi: cadence-quadspi: skip DDR PHY tuning for 2-byte-address ops (i2383) Date: Sat, 18 Jul 2026 00:21:08 +0530 Message-ID: <20260717185116.2065505-10-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260717185116.2065505-1-s-k6@ti.com> References: <20260717185116.2065505-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: BN1PEPF00004689:EE_|PH8PR10MB6455:EE_ X-MS-Office365-Filtering-Correlation-Id: dfac4114-4652-4b6b-66d5-08dee43488c4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|23010399003|376014|7416014|36860700016|82310400026|1800799024|13003099007|921020|6133799003|56012099006|10067099003|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: ZLk1L1ET3m4auYIj+yub5j8YEtaKY7F18cmwM0Vz3T/DMmQfwYn875qgonNFeruQYqX2GL7ZR9UVpIRS/SotPE1RmsJy/dWHNrUsXoDwK/dKhL8K2HRfXtDCjMCSQP3/F4a0KFrjn7TX1WSXSTtT2FN5k83kUj7PbHWpH7Xoeqk5ChQWNWJKh554oKSDB2HNTdib6iqe9QjZLGExD2X/1rvMMD0ENfxYOnm8C1vFk+wYmYv1GOZl6te/PUEUPLHHb4ygIUoN2YaQBJW9EjqYWb4uo52ImIAQGHm+v7taXYQhFOB/ymXFTOnHON3ij5vZFEEdjZW9RY+MHScqnURfSXWROeFdH4KdoVixBLYFQT19Kx5X8leP6kivllRfHBK9raacFVoqB6JiRnTdzMKhpK8ZwacoM35JmO8nt0A5ipzfQEcl6eRuRpblh3NdTkbOvtO2EtfdnENapK20NdsiyzjSNGXWwefM/xuJ0KfWBZX+aOXDgOeptdjf71g9iJ6B37vaiS8taupUfItGSsDQLQQcnUboFlH+xFJz8qClcirlE4NeAzHBMPDa7lRRYRn8TvlX6XOi7LVNvjkQ3eALXpDbzROj2QaiQ2nfqUvCrmpkwx/Nl9FwvGt8XYfTUPrG6kuudqQJz5CVvrQ2GnZDY9FE4f2XXUVQwErjzjr6PIOChUJcCz37NVO2PGyyCkaosZe9ranvgCoJqFl8MwQx5w== 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)(376014)(7416014)(36860700016)(82310400026)(1800799024)(13003099007)(921020)(6133799003)(56012099006)(10067099003)(18002099003)(22082099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Am9FPjKxF7qIR1ZlLbLyctNIb48xiXO7wjwe8YXIZW6p6OyhMYvuCxNwD4bpp81BaxjkOgPOeOYJCtHwxjXiKqgizj8fWHVF9xrVze1Kb2OSCt4DWjv+Yao3kkj25jImYwjIakmiJ0MDTHOCt6BgmCnG2axzC9CQmUnUE/EspPEtkIhK/A07vJvZqWvAqbnWcJk6JPhGQ3kvFIKRF9rA5UDcezZjUr5LlcB/BtWcpvlg4npT/o30FG4TEXw9vReV62wmix0ukne6tOoHz2hSmH0zwCUw/ZJpw4G+O45LjPZdgKNKyBc16Ru37YbIV6iYjHsY6V8KIMlwUR64HN2jlUwLxswr5Y1qbdjzXOxV0K+javteUEPLnrffuwfQRVuV9cBjTCGozM1x00699jMRRkZTfvVUQAMYeG6ifHzmMszVdaaubKF7l2ja+jM2Nmmx X-Exchange-RoutingPolicyChecked: ZBGToazEJWggSHW3SW1/4+ff/LNAn4UWbh+gWkiPJ0hCsLR7pGcviC97yhRQJmpCZZdTLzc+V4aHKc0ddOt6OMDLyStjO3MZpeLjmFN7MJEH/3t1EqbKiyvHG+b74gnIzMHdmXbrywqjYEO3MtpaVodsQF9s9tEafhQTGaAHVS9fihbZ6Jn1X9iFQkaOiO0intOJtzRgfiuqMBM+djEFMcaDrqjjMxSnG7i9o8nq1/Jl7dkSuBx4BL1AUaqx+PLHzwW+VY6OiBQcioBW9ZSctUVLUudyrio0H4eewSFJ1J8Aze+2hB/OjmQWvGCHTK7xQXpqTplrQVNXkhwmFQ4pyw== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jul 2026 18:52:21.6074 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dfac4114-4652-4b6b-66d5-08dee43488c4 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: BN1PEPF00004689.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR10MB6455 X-Proofpoint-Spam-Info: AW1haW4tMjYwNzE3MDE5MiBTYWx0ZWRfX36/ziEd56cwx T3dwVb+9sEMAnydiozs3slda5wXU+4LyNsu8PZMx/J85TF2A6xXmdnY175arfw+ByfKYzX9mPT5 lIFOHJprZJKxwD0qdm6L+/Aemro3ENc= X-Proofpoint-GUID: 0W9haMUlyy55D9itIjnTYde4u3xODX_p X-Authority-Analysis: v=2.4 cv=M7F97Sws c=1 sm=1 tr=0 ts=6a5a79eb cx=c_pps a=57vGMAxBKyli4KBmgVngpg==:117 a=f+v6EHfkeJbVwR46tk4DMg==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=IkcTkHD0fZMA:10 a=RAioF0-LDSMA:10 a=s63m1ICgrNkA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=jwouBfj2j3NM8CExmVVE:22 a=sozttTNsAAAA:8 a=T-kh0MV4vbdY-aS4Zb4A:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 X-Proofpoint-ORIG-GUID: 0W9haMUlyy55D9itIjnTYde4u3xODX_p X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzE3MDE5MiBTYWx0ZWRfXzQOlxUbFRioF vRPMwlyfZ8M05finqhm4D9kTYcJWwlw9l/PlHY1s6DH8x27zFk/kv205cnzsYgnKTku9LpvHREI B03Ni7u6J2WV34516kRJFWGQA6cEhm29WCv92icLjO7MINpnUX6FaCqFpuBDXY5F8/ZxW1jC4pr aJ41WHLpS6lfKtOMTSHSzxgfWz8KQbbnY0N0hYZWUnsyWQh1pSmpwF3UT1/0T73rmG5jT7edbyS 3WAk5Nk5PgLhCGOyqxxax64KbJwBRYjh4AxjAwZk1Nk/E1p5AJFxHnBlGFKW6vQ2wcLEogqLNs/ Tm+HzCp8ollSatpyQ6p8W4Tr8IctVlLGe8s+35S9wr+MuLnVh/ISgI6z7ES4Xvpu75bzQWu7S+s nuN6ZYCRiPmlnxN74P3Hr6cAV3qYqXLCsPgfpWriQflU8iVeKeb0LwD7UepuZa3yG/iyWLuMWlZ REp55iaQDCCw1Biog1A== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-17_05,2026-07-17_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 priorityscore=1501 bulkscore=0 adultscore=0 spamscore=0 lowpriorityscore=0 malwarescore=0 impostorscore=0 phishscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607170192 Erratum i2383 on AM654 locks the address phase in PHY DDR mode when a 2-byte column address is used. DDR PHY tuning must not be attempted for such operations; non-PHY DDR usage is unaffected. [0] Add CQSPI_NO_PHY_TUNING_WITH_ODDR_2B_ADDR quirk and check it in cqspi_am654_ospi_execute_tuning(). When the erratum applies, return 0 with read_op->max_freq cleared =E2=80=94 the op-skip signal that tells the caller to try another op variant. [0] https://www.ti.com/lit/er/sprz544c/sprz544c.pdf Signed-off-by: Santhosh Kumar K --- drivers/spi/spi-cadence-quadspi.c | 43 +++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-qu= adspi.c index 22a5c88bbd8d..5070ffc53d5e 100644 --- a/drivers/spi/spi-cadence-quadspi.c +++ b/drivers/spi/spi-cadence-quadspi.c @@ -37,19 +37,20 @@ static_assert(CQSPI_MAX_CHIPSELECT <=3D SPI_DEVICE_CS_CNT_MAX); =20 /* Quirks */ -#define CQSPI_NEEDS_WR_DELAY BIT(0) -#define CQSPI_DISABLE_DAC_MODE BIT(1) -#define CQSPI_SUPPORT_EXTERNAL_DMA BIT(2) -#define CQSPI_NO_SUPPORT_WR_COMPLETION BIT(3) -#define CQSPI_SLOW_SRAM BIT(4) -#define CQSPI_NEEDS_APB_AHB_HAZARD_WAR BIT(5) -#define CQSPI_RD_NO_IRQ BIT(6) -#define CQSPI_DMA_SET_MASK BIT(7) -#define CQSPI_SUPPORT_DEVICE_RESET BIT(8) -#define CQSPI_DISABLE_STIG_MODE BIT(9) -#define CQSPI_DISABLE_RUNTIME_PM BIT(10) -#define CQSPI_NO_INDIRECT_MODE BIT(11) -#define CQSPI_HAS_WR_PROTECT BIT(12) +#define CQSPI_NEEDS_WR_DELAY BIT(0) +#define CQSPI_DISABLE_DAC_MODE BIT(1) +#define CQSPI_SUPPORT_EXTERNAL_DMA BIT(2) +#define CQSPI_NO_SUPPORT_WR_COMPLETION BIT(3) +#define CQSPI_SLOW_SRAM BIT(4) +#define CQSPI_NEEDS_APB_AHB_HAZARD_WAR BIT(5) +#define CQSPI_RD_NO_IRQ BIT(6) +#define CQSPI_DMA_SET_MASK BIT(7) +#define CQSPI_SUPPORT_DEVICE_RESET BIT(8) +#define CQSPI_DISABLE_STIG_MODE BIT(9) +#define CQSPI_DISABLE_RUNTIME_PM BIT(10) +#define CQSPI_NO_INDIRECT_MODE BIT(11) +#define CQSPI_HAS_WR_PROTECT BIT(12) +#define CQSPI_NO_PHY_TUNING_WITH_ODDR_2B_ADDR BIT(13) =20 /* Capabilities */ #define CQSPI_SUPPORTS_OCTAL BIT(0) @@ -3183,6 +3184,20 @@ static int cqspi_am654_ospi_execute_tuning(struct sp= i_mem *mem, return -EOPNOTSUPP; } =20 + /* + * Erratum i2383: in PHY DDR mode, a 2-byte column address locks up + * the address phase. Skip DDR PHY tuning for such operations. + */ + if ((cqspi->ddata->quirks & CQSPI_NO_PHY_TUNING_WITH_ODDR_2B_ADDR) && + read_op->addr.nbytes =3D=3D 2 && + (read_op->cmd.dtr || read_op->addr.dtr || read_op->dummy.dtr || + read_op->data.dtr)) { + dev_dbg(dev, + "i2383: skipping DDR PHY tuning (2-byte address)\n"); + read_op->max_freq =3D 0; + return 0; + } + if (write_op) { /* * For NAND: write the calibration pattern to the page cache. @@ -3829,7 +3844,7 @@ static const struct cqspi_driver_platdata k2g_qspi = =3D { =20 static const struct cqspi_driver_platdata am654_ospi =3D { .hwcaps_mask =3D CQSPI_SUPPORTS_OCTAL | CQSPI_SUPPORTS_QUAD, - .quirks =3D CQSPI_NEEDS_WR_DELAY, + .quirks =3D CQSPI_NEEDS_WR_DELAY | CQSPI_NO_PHY_TUNING_WITH_ODDR_2B_ADDR, .execute_tuning =3D cqspi_am654_ospi_execute_tuning, }; =20 --=20 2.34.1 From nobody Sat Jul 25 04:54:27 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 019D73A0B38; Fri, 17 Jul 2026 18:52:45 +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=1784314368; cv=fail; b=qQTkUlTwCYR4U2TnlyQIdolndrkQl7B3gdUoJNeLmRd9iFq9tPTRZG7TUkSYLPVb06QiiFbUd5VHaA9RPNpSRj06ICyGdMAgF0bpbN0AzTPJ3zASJHqlyvJwpgShnltCoL+xxx1DCIrldvs9PVToRbRrk7H13Io+G49gCKciI/Q= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784314368; c=relaxed/simple; bh=r6mmBI47kM6LbC2TeTm5XGDNze+9ICvcqteBVTKQmZc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=rUJ3WlVYatbXZbtuG/QQs/WbyhQ5TTdlZXScSQE28vV82y14mN3Pe54bBhcw0txnxNdy9H6JOZ4lW+RUADZLpEdl0BMJNRYxgwC6r5vqqYsVO7TEEI89BDZ5S4t/gFom4scB1vTSH5H+pjrGVZH4fFc4CRLunf+a4Olfb9ZCqrw= 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=ViR/CaDf; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=AQwLOrms; 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="ViR/CaDf"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="AQwLOrms" 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 66HIlUBo1570175; Fri, 17 Jul 2026 13:52:36 -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=Jn4J4+v73YafNI7rjY+a4Pdbl5UXyUH8s/LMgvnmx Js=; b=ViR/CaDf6KSHGfMHE8gMNkpxJkIFSWif5SA2JyToDG0BhbzGaFtANGcKd DCyCfAqb1aLDZ0ZR+sLsk4hB75pE0YfcZKJDG9Wyb3MJysnZ7ldON53bYYWrAbLs 6pIM/4ogLXN46xxIRf+V3kUE4qzElcE1+9mNMvJKa8XHWJoSHQwmdz/LcLLJS3aL b0DVYK3JsNjdujZoregowEcgfTTn3+ECnWk8/6/gw+s89DDz/7aqHoQkidPFFPNT 4PWZyLilUz3fDb8Tof0oEw5MDT2PHzQGFnz2E96H/TAvibEH7ZOtQPhQZnkgW+PY PrOoKZnQifUio0Ynbiuu16vZN229w== Received: from co1pr03cu002.outbound.protection.outlook.com (mail-westus2azon11010058.outbound.protection.outlook.com [52.101.46.58]) by m0384305.ppops.net (PPS) with ESMTPS id 4ffgsmbgte-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 17 Jul 2026 13:52:36 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=b/mfNFdxCg7HqG2Pf2Xo9m6q+ln/QjtOgF7N5VH7vN4kCGDfjvezILEROv9Unq5rVAXWxRUcuU80dOsw999klhoMXojp2fIwzC/pkHxlX65XP1uSu4TCG4xyb70E3QslOKMakb6nFZv5H/jbvB+iR7pqe4whSgOi9GLvIgp/YPVK8dIp6vKG6E/DJXur69bfNjUQY3K4PsQVcSht4uHSoqfVtlMU/btqVoFaHAXpnF46wifs2a60xAgJa0tj1x38XZLsU/QVcy9RarAqB0DFSqhCWs2/5ngi/dlDtgR2DuI9+fr5bsofD8tlF0cYQPfEce0eO9bzXJxU9McNEKrQUw== 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=Jn4J4+v73YafNI7rjY+a4Pdbl5UXyUH8s/LMgvnmxJs=; b=rd6F6mNE+TUGmVnSJn6IY3IPShA9/OYAwO35aFJFvL0lFq8mnUF/lx4SjIBQP66t1aEJF1kk5akTsp+bLx1pxJjMSGCDAwhUnJjie5tEELMmW1GbZ+E0XARrifPqcmWyPCvcVG5IytAZDnxKj1XwDePrtuSWzOwkyTwzY3CwmkabLp/MkiVDOzTVoAnX9Q4cnwTRzUYYRpcHORXVyseKe5W/4PhugVHHt/6gwDeey5FwYAAbx4Y0BFS/J4x3h8vd1wctuyfSEEQ8P1GXJDbP3Wj8WZ4rDGhp/L6dkgDDVphGfO5Cwl2M5T0G6P/GwtPTgy5H2yiNUW79mUvWY6N1dg== 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=Jn4J4+v73YafNI7rjY+a4Pdbl5UXyUH8s/LMgvnmxJs=; b=AQwLOrms7Oa2Ef/EkD0ARx9eamXQ52mKz8bOQ9MJR3qhsh/yGnjgn6igGsqYFwF9LXpUawSb7DEs/ZoQg/UwtzLroFFIfpUMnQo6VBu0Foimt0HrFpqhMO+wGqIISMiz5Lj6i9LoFaLCFV+UfODx+rXIfHbyqcyx8iUOQ3Y+CDE= Received: from MN2PR08CA0009.namprd08.prod.outlook.com (2603:10b6:208:239::14) by SJ0PR10MB6375.namprd10.prod.outlook.com (2603:10b6:a03:484::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.223.13; Fri, 17 Jul 2026 18:52:31 +0000 Received: from BL02EPF0001A0FF.namprd03.prod.outlook.com (2603:10b6:208:239:cafe::4a) by MN2PR08CA0009.outlook.office365.com (2603:10b6:208:239::14) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.223.13 via Frontend Transport; Fri, 17 Jul 2026 18:52:30 +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 BL02EPF0001A0FF.mail.protection.outlook.com (10.167.242.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.245.5 via Frontend Transport; Fri, 17 Jul 2026 18:52:28 +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; Fri, 17 Jul 2026 13:52:26 -0500 Received: from DFLE200.ent.ti.com (10.64.6.58) 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; Fri, 17 Jul 2026 13:52:25 -0500 Received: from lelvem-mr05.itg.ti.com (10.180.75.9) by DFLE200.ent.ti.com (10.64.6.58) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Fri, 17 Jul 2026 13:52:26 -0500 Received: from santhoshkumark.dhcp.ti.com (santhoshkumark.dhcp.ti.com [10.24.52.55]) by lelvem-mr05.itg.ti.com (8.18.1/8.18.1) with ESMTP id 66HIpU4u240969; Fri, 17 Jul 2026 13:52:21 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , Subject: [PATCH v5 10/17] spi: cadence-quadspi: refactor direct read path for PHY support Date: Sat, 18 Jul 2026 00:21:09 +0530 Message-ID: <20260717185116.2065505-11-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260717185116.2065505-1-s-k6@ti.com> References: <20260717185116.2065505-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: BL02EPF0001A0FF:EE_|SJ0PR10MB6375:EE_ X-MS-Office365-Filtering-Correlation-Id: a9c63049-5f06-40bc-ab20-08dee4348d1e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|23010399003|82310400026|1800799024|36860700016|22082099003|18002099003|3023799007|10067099003|56012099006|921020|6133799003; X-Microsoft-Antispam-Message-Info: pOW/CraEobjpuHIF/j+xtpGY55qmxHL2W0BrCtf8ETxMvLHBi8avGUfa4MeWTy/sm7Rpa/54foXP4UNPYrLbZ/a8TD2WXYsGhPv008Q7BbCXFQrdDJ/S6XtJikVxbCmcqgh2Caz1UjvWTG3C+fI4Wt0CAh+EJEQWLwIGQwCl06PH0TiGNpzGwr48vRT/gi5O3r+rm3tTh+Ct/lPIjYgs0OOcJEAMTI/+obb4G6FwQSHOIgpHPKLrd3VkVW9S04XEobA302lJJ6Pg8Q0tBw74dtSEsGdzfcO+n6KgYoSo6GEtyrx+eJAO5Zdpfmu9IjXA2RjiBZciYV6mLRHrNTuon7CN6TrzReui9AnsfBXQKn6p/43HooA8G3AQdA5kiMlIRTGYUtwD6UyFyPmGFchS1q4a4sFmxjGfXTYCRJFidYK+qK49Tlwy52yTgWjJCmzXEppmuvKKN2F+vcSxF4w5/QZWeDAL+IFr+lY9TD8H12nZpm0dFF+FFVeGStaFAz8RPctD9lBqKKZo+fFb3UuPPdHb7v7jrAOMtF5JUCv3AeCivmjHnGK4OTEac8I5Da8BdkMuyPdEOEGeQmq5kqMKmkwpD/sz0fIcPy+z3VGDOPXCX0ScD9BJVJlrIPU+lMI4FNUeZWsnWeYljj+YSe8FKayMoYmSizTRfaHU6RTZZLjQ4mKgy6GtGiRGsPqA9MSXfwNOX9cfXvZuPy8DSYU9AMRxOAd8MXUyPdq0MbwUcNQhZyPHOYlirYpmzjTbMmX+ 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)(376014)(7416014)(23010399003)(82310400026)(1800799024)(36860700016)(22082099003)(18002099003)(3023799007)(10067099003)(56012099006)(921020)(6133799003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: st3025d7dt8OII0OROQJ08xXAHpQzAkpKjVgoJb2WlCN0mUTltBgH3Gs6wnBoeeFWnziSsOZnSIUXUQVm7BQUYG3J1pA4YC3X4bqSb2TDh66yBybOSDFRLMt2tlovGtk82nCp9Hun5Kn4NfDGBxjWRKS9L0G8XU5H5Jq0RPvQtZrg2KBjkroIsDP88z1ZjRIlr63yoFquKDXi2YDZuhOzcKrdAnbwi8X/JIlgsQXPtmCSbboi/BZWJq2PpmbgS5PyVZ/62d/tsYEtHdZ3Tz2Al4zBL9hgrlAQmtHC6DRubT0+ngNPPV6YttsDJ8XcSGaH8+Ll5fNsG8nvOKNUxM/9+aN2HXlH2Rd9xiv3xvnbMC5WwnU0TV9VyeGrffm5SGgROsGrAxo7j8WIDF6azlpbsW43XEgXXlSe45VvE0xVjyb8dOw2q4g3yXsFUvpZhlv X-Exchange-RoutingPolicyChecked: QtFv8o0sgd+1VdD+7KaNGZ7znuwYsKITw6zz+0EizSY7Feyu0bEYLhYuRwIaexrUpCra/w2m4TybO+wtiqJH0syQT3fZVycF4fDIKRb2IDmvP2E/XkBFxr0FYstUUOK4sP4xUc751NtOvNL8iZYPProXwdFiLeJUTwxGkGievuQM6exm9M+qO/UmAUcvtgnlrEqy5CTB3WvRj7Bu6gqp7MFRZ4ij7uICZyD3K0J0P0BAOXL0LLiIncZ+R7kTblo7PZ5oPIoKx6aPTr6N/WSqTu/cU6nShCCf0IJ+rr5g/H5poYRwwCNM7eB0Cx6C740VfAj8UYdKOcv/MbaQeLyiMA== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jul 2026 18:52:28.9109 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a9c63049-5f06-40bc-ab20-08dee4348d1e 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: BL02EPF0001A0FF.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB6375 X-Proofpoint-GUID: kZ67-bun3MZlTHJ-gVU_Uuigf4kINWDh X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzE3MDE5MiBTYWx0ZWRfXyVl6mRDCGlPL UJii4mv6xJqt6x9Lg/tmjqzluspeo6dcxnjOT5mulpaAhkyMLKR1RMkmD2eQ2PiF9CFqSBTJtHt ct/+9wstEymfTbaVC3EAfuhuwtr+QtYsGzrBTZ6/WI/os8KVwcP8AmPZJpezJwlpH22QScAiSep H+j1dctXRZj+gL1I06ht6eep3CDkAW8kTlmmDyUqNvR+gwA7fUrOl3WhIaIW3yQN6EdAL9ADdWI 4nAwLRdGxsY9QPEy0NpVeKmo1mrPS8YrTKcRdm/1HRFwol9E/Ev1CEoXr80UkT2a6EOctGbeljj abIfZXcUkEMb+eTjPuT8w3hpavow2ddcOm/Btqq4GoZ78ZFBVKCe9MRfQ/InBOOblI9ezR9u39U tq5riFH+BdB603pH6f72X6wD7ZPSvvOLViCrRiN4ReTzuMaPEUPrP7oxWlBXkPKb1r1m6ABh27Q a1Uh5ekUURHQQgqYGRQ== X-Authority-Analysis: v=2.4 cv=GJ841ONK c=1 sm=1 tr=0 ts=6a5a79f4 cx=c_pps a=ixAZ6W2pdOuc7GYTaWtIWQ==:117 a=iwqwCZQqcuTv3JOpYdM7/Q==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=RAioF0-LDSMA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=taLDd7a_hP9WKsMzeGRc:22 a=sozttTNsAAAA:8 a=kQoCic6YF6TU8Y4tUr0A:9 X-Proofpoint-ORIG-GUID: kZ67-bun3MZlTHJ-gVU_Uuigf4kINWDh X-Proofpoint-Spam-Info: AW1haW4tMjYwNzE3MDE5MiBTYWx0ZWRfX2gucHtccW1PL qQGLpxInEJczriRhl2KXfX9u85Q71sHHzHEf8RAE35xSaPhJ77El1kRDuC0E2pBum66ZgLa3Kv9 2YaLdRBlw0GVLL+mdeIionsI/dvmUjk= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-17_05,2026-07-17_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 clxscore=1015 impostorscore=0 malwarescore=0 lowpriorityscore=0 priorityscore=1501 suspectscore=0 phishscore=0 spamscore=0 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607170192 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 post_config_max_speed_hz instead of separate buf/from/len parameters, matching the interface needed by the PHY-aware version in the following patch. Thread post_config_max_speed_hz from cqspi_mem_process() through cqspi_read(). Transfers shorter than CQSPI_PHY_MIN_DIRECT_READ_LEN bytes always use the memcpy path; longer transfers use DMA when available. Signed-off-by: Santhosh Kumar K --- drivers/spi/spi-cadence-quadspi.c | 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 5070ffc53d5e..322e95b3bc17 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_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 @@ -1521,8 +1523,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; @@ -1534,11 +1536,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)) { @@ -1580,8 +1577,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; @@ -1597,7 +1647,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)) @@ -1625,7 +1676,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 Sat Jul 25 04:54:27 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 598AB39D6D4; Fri, 17 Jul 2026 18:52:47 +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=1784314369; cv=fail; b=Sifabvwb8ZkzYOh2nY0bWVlswuzkYXeOey8xDCYgP2xW1NVnb/I8yH7QQy25ieQkLZYuVc6PuWutVyn9jLIK80O6PHhsdbaZuaUWfU4jo0QRXZ8324niPGIPyJ4T0LKZLMM4clIBBn6uncV2zVVbBwZw3m/YWtFUy1VXGyMJJiI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784314369; c=relaxed/simple; bh=NlBClPnibM0KySwnwhBAcwY1mjSRn1kZGPB81D3dGzE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=M1e+pzDZuoUkx8rm0NQXB+K72Yb8E8tp/UelLFD0S0yZjtQrKtLGf2hhSmDmrbCeuRai5TBeEbgBy6jjxyv3hoj6QTOqyD19rxhaUcxhRTFVBC3wQ7uWRaUjzvMD9j0DME50fKV3hsedvMDaIkYFuLFhfxGF6mAJCvE27MNSILY= 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=ejYE4V46; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=oNadOK85; 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="ejYE4V46"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="oNadOK85" 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 66HIlA5T3254275; Fri, 17 Jul 2026 13:52:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint-05-2026; bh=Z+0x/gTksPXU7FZ2D9S8r1K8rcyMlV9iapZy8UL0O Z0=; b=ejYE4V46y39I5gYZ5X/0leEUqIbpa+l5KE1Wks6+RgV6Q3aDnddR8vWNM 12QWVdVR2Q6pvfB/ECetYZTwycxVTMOgeZEP68/5D2bwIlO0m2mrynPa+aai51nj MsAPg1Rxi2zAXJ7JEnajaoyI22umQJ6Cem00b0XPN9YJaRXa8VbaPPnpB2+mcK9O Cy5zsPDcmRZratHhIgBuyll4Vu5xQzCRvf72dtY86hR12Jj1KvtaTV2wlWqrcaYK wwn5ydjurhOPZLEGGy8gWZUAIG2OjqB7oLC+h6Bup32au9GbrZUPPKQBBYV0Cc2Y 7/hlrUN0uAdbJ63oqeVRbsSfssTfA== Received: from sj2pr03cu001.outbound.protection.outlook.com (mail-westusazon11012027.outbound.protection.outlook.com [52.101.43.27]) by m0380145.ppops.net (PPS) with ESMTPS id 4ffks32kh0-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 17 Jul 2026 13:52:37 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=eez2nCvd0fj5EQdScjYkqk4KGo4y76phq2ZZC12+XtmQ6lBcAL7nunPJiM2X6cpTmbFjtYgDGvThmm/9doGIBXS1L5jmy+2h3DFDpc7t1J/VU+s/E9/HgWB0aS0sbKLIP+s33l1DG4zMmjwQdoz5ufhN1R7DRDvufYfD06Q3n0TttUpUUTUOqgGRHh6B8iT1DR9dGyAVjPgD0zaIRgERf2WmjiVVdOCC2jPvDo9vlukZClmR1RjwCJzZVttcdyXMhqnKdHiOLGMk3wletd9TFXSXy89zzrCnuy3xLGs31Ygvhtduk68FSWYR3460EmVCh1LBD7JFnrgYghZFimT2lA== 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=Z+0x/gTksPXU7FZ2D9S8r1K8rcyMlV9iapZy8UL0OZ0=; b=uXKK9qKGPhow0iTYxDZqhqRSU53kyEOGYj4afeEbvVuyq/H2gRwytQfnFVMrvc4PKOTTl9oH35lI3UxtTMCd8QvbL7bVB1a7v9cG/3beTaUouh9c8b34/pV0/UCNbjgykg2M5jssX19llQhnnomipbcFSUx/HuhByTQ41/avb2cUR09KtivIfFwxXpea4loJxNk4J2UkKh58HYVvyPsrxoQRX/txkTNEzIaD3PGWmNVZgB8b4P3FG0FEh3F/vMHkD1mZWEpDstlmpYtRV79iutjCN+sjAYa1sIokaZuMp+2TRHdTW8Igaec+2X3+LxSkEf7RHMpNiWn+OLzT8m1mnA== 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=Z+0x/gTksPXU7FZ2D9S8r1K8rcyMlV9iapZy8UL0OZ0=; b=oNadOK85vk1Wz68Qd/V+XPTw5tFrwhfh9rvR1n1Gu/KRDnVzMDCJn3D+cLvC3NKN3JD0RPXGgggS7GnD/HYRPdeO7Q3axbPdDbQP82YjdKGgZafUZHCH0WyvHZv4amx4PeNMjfnAj43NXnS2GMSDdX6hxcooaSpDNNuqcfsfaQA= Received: from SJ0PR05CA0137.namprd05.prod.outlook.com (2603:10b6:a03:33d::22) by SA2PR10MB4746.namprd10.prod.outlook.com (2603:10b6:806:11c::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.223.13; Fri, 17 Jul 2026 18:52:32 +0000 Received: from SJ5PEPF00000208.namprd05.prod.outlook.com (2603:10b6:a03:33d:cafe::17) by SJ0PR05CA0137.outlook.office365.com (2603:10b6:a03:33d::22) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.245.6 via Frontend Transport; Fri, 17 Jul 2026 18:52:32 +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 SJ5PEPF00000208.mail.protection.outlook.com (10.167.244.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.245.5 via Frontend Transport; Fri, 17 Jul 2026 18:52:31 +0000 Received: from DFLE204.ent.ti.com (10.64.6.62) 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; Fri, 17 Jul 2026 13:52:31 -0500 Received: from DFLE200.ent.ti.com (10.64.6.58) by DFLE204.ent.ti.com (10.64.6.62) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Fri, 17 Jul 2026 13:52:31 -0500 Received: from lelvem-mr05.itg.ti.com (10.180.75.9) by DFLE200.ent.ti.com (10.64.6.58) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Fri, 17 Jul 2026 13:52:30 -0500 Received: from santhoshkumark.dhcp.ti.com (santhoshkumark.dhcp.ti.com [10.24.52.55]) by lelvem-mr05.itg.ti.com (8.18.1/8.18.1) with ESMTP id 66HIpU4v240969; Fri, 17 Jul 2026 13:52:26 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , Subject: [PATCH v5 11/17] spi: cadence-quadspi: enable PHY for direct reads Date: Sat, 18 Jul 2026 00:21:10 +0530 Message-ID: <20260717185116.2065505-12-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260717185116.2065505-1-s-k6@ti.com> References: <20260717185116.2065505-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: SJ5PEPF00000208:EE_|SA2PR10MB4746:EE_ X-MS-Office365-Filtering-Correlation-Id: 0881c66a-a4fa-42bb-abc1-08dee4348ec2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700016|376014|7416014|23010399003|1800799024|82310400026|921020|6133799003|56012099006|10067099003|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: dGftsrfzKL/Z0E4+l8HHO3c/28sLoPmb7Q0K6oN+ugA0cJtxeuYOH8IGTf3L1mokmH9ZnSrMNFutpnJRp9KvNq4THIGt9GmeqAWYnz6khik4jiljUY78CeCZ3HrL4ROpx5KtDeZNO3/ySs/fd3gZW7Maq6DvrWinWH/os1IKI+fR04UmcsTOXeI0ULAj0NG+N06Yjv2YlCVnN4C/r8wkCBWPFrDlYDCOLq6oz9HiuZgzZ9835+DwqkYUyIxLpG1HAMhcQlwOX1rFpDNbe27FYEw2s9DIJ+OL4JbUUfaVcsp7eFVWlzbKPA3fFlzyaabWgJvhdGGa8fOToIhDc7xpLmNXXd7vDrxgHIDGZ90BpAUUxlodHCoaiFPv7DVIXL3odqCIdrP1U63ZnLQYJp+eR/3caKgCXZlfO8pNn4XtJKJoFZWK87CuMFj/CWXoZj+/GTQIkz08GV9j+MfE7vvaLYi+5Gq7PGt0sYgG/tZoPv1UKNWQAvdwPo2VNgSwrkq1Fc4wnuMdAlGVYzYUnjUI/RgqUU7K2upS8qCBbvSnO+CL0YUas3d40p04C4lLhTuBApj4+cMQzG+iMZx8yhXS4+My1oSsBCUVX6V9jGl5Mc2j5upZ6NicGq8G7o+eTz52BBJbEZPEnUc1FK5nAyDySh5UXHsk7ZUeZgcZNC1pr9MdOiRB6kSCwjV4YWzEbnhF+b7qSkL32CqLwKnSsaIA5vfI4UM07DtUsFC1O9ln1hdPywnmLpsOFVd3Eiujr29n 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)(376014)(7416014)(23010399003)(1800799024)(82310400026)(921020)(6133799003)(56012099006)(10067099003)(18002099003)(22082099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ixcBjv/7ZjsaVP5kjeuF2/GRFJ0yTdFxeCgANI4leE8WT3dTAuq0D8RbwwHEk7JHJoZEz7xD01r4OiPyRKq7tFN7JlCFIMTKZd4v31dr5ClTHcsumapzkYdv2wf8dH5ZwbEmywWeV768Sk+Mt7XfYd63k4phONSiy2qIobLZkwq54X91nP7IXO0q0UXtCaU7BGHkDrY7OHcpFrLhWMNFsBVKscQNqO20dtxMbVo9Cn87aS0jnSV7yo0ayWSWocoiLfDpAUTVJJ1y8z4pFPuQGgVzuqLfYXCRhv4qQtkcv3X4oXPAumMZxAxek7IyXz+8D2ppTvRr89zd+BqybrbelaifEgkJLl5mVpkPvyxdgIrIUTQP1TN3lknUt8gdAzVzxMd5KBY2VswGOrFTt0q++zv012A5+Cb9VLShHU9UCaL7UYA9tkIxnQhLKSpEpOLI X-Exchange-RoutingPolicyChecked: a6vw+7MPJwxNRxl6EnfHfoiLPG013JdpZNnJZq1xqF+JXqz2uin1wcig4MQKlj91ReeSRL9FYjji37UWdshfBetwZTD9r2tKjWlYw0ys1PFb2tywhJS4n0Fj+WXhO1h24MyfFLs08FV4iKo5/62UNnVFvGEKgSsK1J3wiBBXi9sMQnDWk9o8ctJ1AL0fQdpd6AzE0+ldNeWPM27kWqD6Zuzl1Auqw2ggvmZmDrxYsjdlAeLcbv1ECB5YYwFCq13gkF65JCnw5HyTnMdNAMBW1LGIQ8DVVogsGwWGfSM5cWWeq1gZO9JeC7+7gfoybyimI1gMnZNdxk0nyeG0CSmSvg== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jul 2026 18:52:31.6357 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0881c66a-a4fa-42bb-abc1-08dee4348ec2 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: SJ5PEPF00000208.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR10MB4746 X-Authority-Analysis: v=2.4 cv=e9Y2j6p/ c=1 sm=1 tr=0 ts=6a5a79f5 cx=c_pps a=8g4i1X1tkAMDiabECo8pFg==:117 a=tJyPKKxUohctrY4NYmUjkA==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=RAioF0-LDSMA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=gO1vWkAQAl3rybz1DQOp:22 a=sozttTNsAAAA:8 a=EeSCy0yzjnJx7k32krcA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzE3MDE5MiBTYWx0ZWRfXxdgjq8TY0ibS NntsikqtdjfTWFMGye5+c77NrbGgwft9Jxv57ceYYUIRc3SrlGbzDN7lrQGiK7O+MoTvP/YeVi9 PEhjt/6AmjbSiQmzi4HF2ePHAD9hk/HEW9I2p8ArStpg2+kJPJUZSGiPpicntZlaxCc8NiKmgrM qNgGK/MDRvhiCKuNxHzZ8fvpqguibv5QgFAbeoawUj0ud7aVZJwGikIqR1prozdhUD/19Rclx3F 47JFJ1b4j6mzZCVZf5OvHb9HTufpxnnuN6XETiL5AA2shhzw4GbjpVciieyYlHdEJ4jz8jRSeSV nuxUK9JkcRfkKEkJrakTf9ey27u+GfnUo6hPw7XQTqdT/kyAZk1tYjFJeJbzX2tjUKpwWt5nFZk US3aokUubcGgWdRybk5zizubm+lliXduTVLcObHHlQeqKvr70wsfgMsNxdSBk+mpOSSl3eBPSz3 8y+FNB3yCLysPGOYzCw== X-Proofpoint-GUID: xFPJYKJzYzQRzuLGZ26Rx4Co_5QY2qL5 X-Proofpoint-Spam-Info: AW1haW4tMjYwNzE3MDE5MiBTYWx0ZWRfX208Upasw4rDT EdPUVOFk8v85OGGMb/lNZAnjAk5ZS6g9T3SuJPzpgWrMQ2gyDftgwFisCtwg41XUqMvfBKZo+9x Z9ywuow3u3nda5BXKj/zExOg1Tc+Sv8= X-Proofpoint-ORIG-GUID: xFPJYKJzYzQRzuLGZ26Rx4Co_5QY2qL5 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-17_05,2026-07-17_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 priorityscore=1501 malwarescore=0 spamscore=0 adultscore=0 lowpriorityscore=0 clxscore=1015 bulkscore=0 suspectscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607170192 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. When multiple chip selects have different calibration results, the DLL is reprogrammed on each enable to match the active device's settings. Disabling reverses all three. 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 | 124 +++++++++++++++++++++++++++++- 1 file changed, 123 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-qu= adspi.c index 322e95b3bc17..35a400073944 100644 --- a/drivers/spi/spi-cadence-quadspi.c +++ b/drivers/spi/spi-cadence-quadspi.c @@ -1067,6 +1067,82 @@ static int cqspi_resync_dll(struct cqspi_st *cqspi) return ret; } =20 +static int cqspi_tune_phy(struct cqspi_flash_pdata *f_pdata, bool enable) +{ + struct cqspi_st *cqspi =3D f_pdata->cqspi; + void __iomem *reg_base =3D cqspi->iobase; + u32 reg; + u8 dummy; + int ret; + + if (enable) { + /* + * CQSPI_REG_PHY_CONFIG holds the RX/TX delay line tap counts + * and is a single global register with no per-CS equivalent. + * Reprogramme and resync the DLL when the active device's + * calibrated values differ from what is currently in hardware, + * which happens when alternating PHY reads between two chip + * selects with different calibration results. + */ + reg =3D readl(reg_base + CQSPI_REG_PHY_CONFIG); + if (((reg >> CQSPI_REG_PHY_CONFIG_RX_DEL_LSB) & + CQSPI_REG_PHY_CONFIG_RX_DEL_MASK) !=3D f_pdata->phy_setting.rx || + ((reg >> CQSPI_REG_PHY_CONFIG_TX_DEL_LSB) & + CQSPI_REG_PHY_CONFIG_TX_DEL_MASK) !=3D f_pdata->phy_setting.tx) { + cqspi_set_dll(reg_base, f_pdata->phy_setting.rx, + f_pdata->phy_setting.tx); + ret =3D cqspi_resync_dll(cqspi); + if (ret) + return ret; + } + + cqspi_readdata_capture(cqspi, 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_versal_indirect_read_dma(struct cqspi_flash_pdata *f_pdat= a, u_char *rxbuf, loff_t from_addr, size_t n_rx) @@ -1516,6 +1592,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; @@ -1617,8 +1701,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) { @@ -1626,7 +1713,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 Sat Jul 25 04:54:27 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 C63E038E5DE; Fri, 17 Jul 2026 18:52:55 +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=1784314377; cv=fail; b=cf06QrQRUjS6ebWFabHEP2y+NWyPVfD3ZIYsF9BxCXJvoogNZW2oJzzJHVPAjK8+ajsRJLeviio7TBtqPn0j2UVYWueWR9pDoEmm8lmsRe47achzPryXep5HT7Dfvj/1a3XEjjpWsAudctOmlZX3f3/nNjoaQuSXTaiAH9iqx8I= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784314377; c=relaxed/simple; bh=Sm4ubbEEN4Az76qfVMNZTIkkcnGNEOC/u3U9uX+LeJ0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=r3f0VsrGy7EJ2YpYSEiepblO4SfNAV9qWJXpSDssmTRI1+YuMU/WiwhijBh1jgMEs20AFW2+XXAgiK41fHXPiicicmTOIqYW5wnrsj6DjUC+BEOeDoKsZ7pvNl6jFCSqbj+4FlNM6a50S6npE/lsSSMMCmgHkcSUvCD/YZ899Oo= 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=nAy6Nz56; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=xbGOU6i7; 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="nAy6Nz56"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="xbGOU6i7" 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 66HIlHdG1570008; Fri, 17 Jul 2026 13:52: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=hB6pzNq3ewbcs9k9dCtsJN2CaWmJWpAUfqG98Iw46 N0=; b=nAy6Nz56ON6AXbqK4TuBN7CxXbtBeBLEcHPZnyklt0Mp6apnCXAFUeU/B q6LCG0xPG4Yh0s2/CcFD8OB/pA3OuTO4j49E7hDJBrSNJtCU5LKR182ERoJtqWvX n3PLkMe3Pg8q400ZgYnO2Pc1e1o1B9FKTFSM9sk2S69uAqodxvDJcNCoNLcOYOCh CZMoxKM3dIy8Z0b0gqduWOX9ZlVBTwT/+Vgw641tV9OJYrXmr7FKKZ0pqz4L8Qw2 LjBhTUFMV4hdFXp4Zg+tXKxJOEALAHNGfw3gZjNGy+hPnoNspyKjNjUHee4Su0u2 A1w9dEeaAaTG4H5luG2N9EEW/RtUA== Received: from sa9pr02cu001.outbound.protection.outlook.com (mail-southcentralusazon11013029.outbound.protection.outlook.com [40.93.196.29]) by m0384305.ppops.net (PPS) with ESMTPS id 4ffgsmbgum-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 17 Jul 2026 13:52:45 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=CnGM3FC7E0Itb0ZcgGB38YyGCV67QPKJJOvmyJzv7TcXqTSDZeQpUjwFXinWpiZ03iX7s1+9wqIsjLOhkLKkIzz9Xs50uRT6e6/37enh8pgDqL3URBBX1iAtnpdvYa29sI8dTjWH1Mz/Qq3cAAO4R2ile8rWf492O6/iAZRVwlRJyzK/2GWiAyiV9ps3cdvd93Nqft0gLLiYjTK6APhK+u2NkBOlHCVjYT+8SRjIvSPl79GrLhmS5HuTjp6vigd4BhWXrGIh5lnF2dypjLn+BtbEpgVUSVXfWO4cXjhMidULJ2c5MOCWRahmgnG/dGabSg87YChc7QJ4VWTrH9OMkw== 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=hB6pzNq3ewbcs9k9dCtsJN2CaWmJWpAUfqG98Iw46N0=; b=eQKOn1sIHA7QfCBgsZQrv2n4Hxa2tssi+3sd9TAOQiTYNd2kq26zLYxK02tzDPeXr3OJAlsu4v0Ak0iO4wXXuud19zZQMw7lOgxRCl50vpsd9z9tAK4QWmM4tsHOiitWiOlZENMPRFbjUEh6no01KHHdl9nnokQPjnW1G9vHPBe6fzXuhGSB7DEC2G+ZiQ0v6cefCZHltTGhKCkGg7wMOKELhKKyOaxCWayoC3GQFfowct16I9u59pf9qlbbwTSQCVMI0mDHLrN5Jshxm8yEHafQPPJlZnsWl0YuGuGtW+TPnluT0iwJVHJWdamoFZpV+DDGGrRDl4B+OGHP8VPdBw== 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=hB6pzNq3ewbcs9k9dCtsJN2CaWmJWpAUfqG98Iw46N0=; b=xbGOU6i7ioTu4+eEx77tizXmjRDj0rvswWNglVDZombDBtJdByybfRIJD0OWRkGcZYMSbFaPA5UXETlX3dIeyMAB3d4m0BqpZtZZ94LQFV5eoYw/G+GZ/zS/GQkFhKY23LVmpiVI8Zind4JXJfPuyxYWe5Iw7eguIPj/Xd31DtE= Received: from BN9PR03CA0573.namprd03.prod.outlook.com (2603:10b6:408:10d::8) by CH3PR10MB7646.namprd10.prod.outlook.com (2603:10b6:610:179::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.181.17; Fri, 17 Jul 2026 18:52:38 +0000 Received: from BL02EPF0001A0FD.namprd03.prod.outlook.com (2603:10b6:408:10d:cafe::25) by BN9PR03CA0573.outlook.office365.com (2603:10b6:408:10d::8) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.223.13 via Frontend Transport; Fri, 17 Jul 2026 18:52:38 +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 BL02EPF0001A0FD.mail.protection.outlook.com (10.167.242.104) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.245.5 via Frontend Transport; Fri, 17 Jul 2026 18:52:36 +0000 Received: from DFLE204.ent.ti.com (10.64.6.62) 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; Fri, 17 Jul 2026 13:52:36 -0500 Received: from DFLE200.ent.ti.com (10.64.6.58) by DFLE204.ent.ti.com (10.64.6.62) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Fri, 17 Jul 2026 13:52:35 -0500 Received: from lelvem-mr05.itg.ti.com (10.180.75.9) by DFLE200.ent.ti.com (10.64.6.58) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Fri, 17 Jul 2026 13:52:35 -0500 Received: from santhoshkumark.dhcp.ti.com (santhoshkumark.dhcp.ti.com [10.24.52.55]) by lelvem-mr05.itg.ti.com (8.18.1/8.18.1) with ESMTP id 66HIpU4w240969; Fri, 17 Jul 2026 13:52:31 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , Subject: [PATCH v5 12/17] spi: cadence-quadspi: enable PHY for indirect writes Date: Sat, 18 Jul 2026 00:21:11 +0530 Message-ID: <20260717185116.2065505-13-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260717185116.2065505-1-s-k6@ti.com> References: <20260717185116.2065505-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: BL02EPF0001A0FD:EE_|CH3PR10MB7646:EE_ X-MS-Office365-Filtering-Correlation-Id: 260d484c-ed1c-4619-8c54-08dee43491a0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|82310400026|23010399003|1800799024|36860700016|6133799003|18002099003|22082099003|56012099006|921020|10067099003; X-Microsoft-Antispam-Message-Info: nR5X9/1LCN6fuj5c/rFAvZezD21IOBZB7SKRi7emCHXu7iSC1DzVVbi3+AuNYfZkHXGTAG8Psj38k+pBiOr0/XHsqbHLt7xjAEL9kI2zzuDG0NprbvoJdN6bz0NT99ZjdStCFenic0buKe6/OEMbUMtsEC9kQE+0Ya8/ZSESMi52QItNMnBi59wkXpeGun2Hju1clGTXcpaARPDDGjN5A9985Z44I2Txm0uBFZM+em9Zw4BJ7PR8bBYyCRe3+GjN1JOdBaGfgi8BK9Wp2i5RDzbgxutW/N0MzbmCEwtBQtLsvhnRSjxaf4bOM8ivT4/1NiRG4ORAU2i6wHXO9YuSVjL8OKFCib6fP707XSA4zuCRZ9QnKbNLWo9Q2zny4QdgjFU/eBEWBAwMakfQbVGdHCJFkSrotPRanCR3XpimYn65d17hz5cLj8pxE/GJsAS10qpavgw0rOZ3bCGViXvG2YY6MmPU+DBccgaHxgLSUUYRS5Keamf+uKV/C646u4p8F1w0hVghwzbyNSKBCyRZw9zaCzb7Nde+bpT384WSN1i4TQqMuhGXtcH5oKe3FGRCAVqxrvRPKKSdjWeChjQhUgaSUmTgFVYPiXsYppBXqIXGDEMRdTuOSRb74KBmlRGA/j1RIG9M/OpQqSoM9Q4xlX5gIZTnZDtsIc7qjvk3NoCF6DtQDy5i4C/A8u6UgW5LEkJQLmi3LRtdFMWknuWyK+PDEXD/sX0miem2N8tr0qvzqS1Qk3KtZsKuNWK8toOn 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)(376014)(7416014)(82310400026)(23010399003)(1800799024)(36860700016)(6133799003)(18002099003)(22082099003)(56012099006)(921020)(10067099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: v5DY2ZSkoOhivu21Wi9NkUSinygkIJYjhBkDWPyOsJszJHqh2Rex8cKfvp8XlEI/A4mgMw3Jc5BvHONqQ4HzlFjxVdIWvyNgyXCwNbvo9P4bjW9xFeUqmYtFrNAT9IlFGmCY39qVgkC9y9dSjtyqc1p+cd9WO4hEdLGsFtJGrY2+MHKKHEkSWsxcDIimohLeritpMjPYfKriXNkVbqqV/dXH87QnkmqH9mjTCPwQd5tb9uKTFPiIbwp5oaEzocot7at7tOEEG1UO3uRd6VcRo00113ymlHU+JB2FdbtqlU5rN6eLbbQVhMJJZJv1yqSwVol45tUNy5BrbInWr9At5pHsfoTfOdM4ntwA21U9TJMHgcTkn3ZMQpv6wyrBZ1PhjVZVcf6af9tGqSpraiipPsjZwcr3mxNj6iqLZcJKeJVlsXmJ67JIAEDBZ7JJaphB X-Exchange-RoutingPolicyChecked: sWvQCD6Gl2+F0SxgruRt0HqUr0DJTQ2JgH+CKNg/5VdZtj32NefD+8lR+MbOKU1hNnPp4Pxs3R3qkgUFG/fXur6VliYqP33s4kgNgCZs6m4X2QcjWWJcF1nPo8BNTy/dJwCL8fmnwKOmbIl6uWFz2q4Q95AcTZ0eaTZ8nVYy5c+R219l2nYPD9nhOFxES1d6baDxJqgwLu/E9phB2Ppsk+t2QaahqVRbR5c04X090ppN4q1yIsoemN1WKz1wA9cAGMDov3RA3/eMX3zqxQliyyglTTTIEDqZ6we67NJs0GvGtlFCN/awsMXsP3KlV3mE5lBUXR+xbfc4q3SXZtwSqQ== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jul 2026 18:52:36.4667 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 260d484c-ed1c-4619-8c54-08dee43491a0 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: BL02EPF0001A0FD.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR10MB7646 X-Proofpoint-GUID: xFhlT6EI9ll3zw_Ki5LaMp5s-DD6o-T7 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzE3MDE5MiBTYWx0ZWRfXx9YTBIy3gekd sDbTd8FpGq6xhWBXyA0SFz9gLtrtycTeQDzLcUPivWyeKOtpGghtULeo2zznd/8uNWPIsesbMgO pwTHDdj/0PRP6DAIV8k+ByOjCr9eJBOLm/e7EQLSxoFY5lJMCpEmbxXGuCeZymWLs01OdJmuw3Z hC2oQ0XP7QViVr9l1VMavDQMsPCaKMY5N6zkeZqkxCtvgzxR94Xzyv+d6C4iB2haI5qR0aThypE W3eHeeMfW8DRFJZuTvzR//ttOVtc+pkWT4wvDgYesVHN4sAIjsBytu0UyVbdKq7FXEy0m4xpfNa bxY9oiR6cMYXqcywwRaoSzwm1+7BXPXAse6QXwu/oh1TybgUpmwn1xXljfxftIbRMDZFWLYAsAr eJksav0qtUUwtFNWa5f/hLLfJMsLJP8uFXPeX/7q4mbZcIkksJ5DwcEAwl1bo0ZCvffkLpuwGy7 pxdW+C7k/IQTWpTHjcw== X-Authority-Analysis: v=2.4 cv=GJ841ONK c=1 sm=1 tr=0 ts=6a5a79fd cx=c_pps a=y599upwrfiZ3HV94zaFOUg==:117 a=iwqwCZQqcuTv3JOpYdM7/Q==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=RAioF0-LDSMA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=taLDd7a_hP9WKsMzeGRc:22 a=sozttTNsAAAA:8 a=-A2lziRS1w5XIjWNnAEA:9 X-Proofpoint-ORIG-GUID: xFhlT6EI9ll3zw_Ki5LaMp5s-DD6o-T7 X-Proofpoint-Spam-Info: AW1haW4tMjYwNzE3MDE5MiBTYWx0ZWRfX8VV5dPRUTihW 3ybxPmewdgwe3i49AuTJYYYf8GgqyhbCZksUR/cjshLahZ4x+wM9VI9SosXVVX+deo+CmbGdQiW SD/62r7f0W6pWOq5WjEL2Rm4WqQu6OE= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-17_05,2026-07-17_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 clxscore=1015 impostorscore=0 malwarescore=0 lowpriorityscore=0 priorityscore=1501 suspectscore=0 phishscore=0 spamscore=0 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607170192 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 post_config_max_speed_hz from cqspi_mem_process() through cqspi_write() into cqspi_indirect_write_execute() for the frequency check. Signed-off-by: Santhosh Kumar K --- drivers/spi/spi-cadence-quadspi.c | 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 35a400073944..542ad331ff16 100644 --- a/drivers/spi/spi-cadence-quadspi.c +++ b/drivers/spi/spi-cadence-quadspi.c @@ -153,6 +153,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 @@ -1335,13 +1337,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)) @@ -1377,6 +1381,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 @@ -1425,9 +1441,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 @@ -1562,7 +1584,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; @@ -1589,7 +1612,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, @@ -1805,7 +1829,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 Sat Jul 25 04:54:27 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 28BD53A0B38; Fri, 17 Jul 2026 18:52:53 +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=1784314375; cv=fail; b=X9lE+ltRuljZrpUmnbFAOqLdskQQRYv7GZ1zCwogKL/TDe3YpmGPDBzNaCVveS9uoOQ/cVfPoeqF4v9+M1nulyF8JkBeUK2NthIaCmG9EKqN8nrkdjhmozT9NyzYc6d25EdHilx1QAnLyeb7uINqxy31NYHW1MjPvPihJxR9ciY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784314375; c=relaxed/simple; bh=pIn6FQMQVRmpAi1OIWqN2WjNohkALTG2Vfo107304pI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Uk/Wv7hcqjgjyA6zjRuov0pap7/vw6f+vQjbR27ojJ4tQkPhB30I0yc61br2IdVZHiGuIrJ0kLgpkqJ+RPEmZT9Cu6aobaqbNk/6gSMLsnvCYO5RQuoB2NHk0s/CGImRNtcUR2BYRRJWNNyptbiGy543LI1QfwdZ6tsGVliT63c= 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=iPK78LUx; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=Xuz7YDNj; 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="iPK78LUx"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="Xuz7YDNj" 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 66HIlKJm3222741; Fri, 17 Jul 2026 13:52:44 -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=3KQVMFD538yJ3bW7oX3qUKzdhPkCw69tpRcHsh0Ql kk=; b=iPK78LUxrHeSVFyQGEheOmfuoh314U785Ib6mnsrJhe7Ew2Ca8iMc0SYO NlskoNCqgdpAHDrypMFGRZgT6HNjPnqcguIb9donJWp5gt8OLa2lZpJZBHx8f4Ms EJMS6IbVeuVTt60/uU8anLq0azFJrp/E64tKFlFXDyajfQUm4twi2/xcZIf+ofE4 Lwffi/9aNvgglA6wTX6nmlAVMd7ral4ZLI9o5jdvN0Stpz45gpWdPRbgqw7p1kSd p/vZCNgBuRPXdjHL9JQouYtglMKYXAa2pYyHB4XiOUdrgKmO52hdQMENIu4+z6sq b0aUUZQEZSZW/bmdTDMcLaMgyevrQ== Received: from bl2pr02cu003.outbound.protection.outlook.com (mail-eastusazon11011048.outbound.protection.outlook.com [52.101.52.48]) by mx0b-0002e601.pphosted.com (PPS) with ESMTPS id 4ffkc3ju1c-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 17 Jul 2026 13:52:44 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=DFI6DNW8Zr2q9IJAI1xrQBRbvHKHN4skOI11gSOkNLMIttwpu+cfaHciiuUO04rTPbTN1/6KjJw78YfseQ6/s+XJex8sKYX+KJDdflUFKhz7TiDnSkj5d92p87JZA4cdBHXxfvzGmhOXhtou1dtZEiDkd6m2/nR4FHxopskMFrco7dXZZy1E4TFemPUUiREezmS32Ut+2+SlrzxQExc1NEfeTGc6Rev+xb1zg1quFubPbHupIAiPamsWjUH160hFOzyCoZN3lJSzHvBeWM4/EGXc8RzNH7fZ1dWEB9uWWCczrEKTg1ciugSDjORYIr7Nw5AB2O86Kc73UY+AQS1Oqw== 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=3KQVMFD538yJ3bW7oX3qUKzdhPkCw69tpRcHsh0Qlkk=; b=mdmEiPF6vJVuCm63DeHuoDBmrAeiXjYRz0zgRnRVQkjJO1+Ro5XSkM7PvyjMwJj0krgnk1CXDPH1Ug33oydbd7qD1uVRxyRkvQ0GSpXjmWg9nhcIhO2o/S6YSYPpwaGnD+CYbwJ+kIi3AQ7zXwF58ikkjE1jWP9VyLSaOpTzCxB88aP7AXsKAPdW6i0OQA0JzRl5+shOprW3o0vAIjXHo9ODSmTXYtHeLrhoO2kTxYHNoRbQ0RL7dezDJJNgjbxkIF5OEHczDrsHR/R5+hYSdxMzJWjhZ9xHEtbTXez8oRwDhjg6ZZrJvPq23HJQpXijqXmwEpz5+8hT+EE2KdL3iQ== 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=3KQVMFD538yJ3bW7oX3qUKzdhPkCw69tpRcHsh0Qlkk=; b=Xuz7YDNji8ALdCv6Yra5SG0SHo7MDyGG8v5lwS/nngbxIKFsq9kcz9L5HtRNoPiU1n4TtfvfXAIkneEQ9u5jbN5CsyUpkfoFarGlOSpOFCsaNcy/uJgMf7yVzVcnW1tSEEBwx+OR/PD4rymz0lBui3+zHYnnEC5YPZiAmaGYTfs= Received: from BN9PR03CA0517.namprd03.prod.outlook.com (2603:10b6:408:131::12) by BN0PR10MB5061.namprd10.prod.outlook.com (2603:10b6:408:12b::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.223.13; Fri, 17 Jul 2026 18:52:41 +0000 Received: from BN1PEPF0000468A.namprd05.prod.outlook.com (2603:10b6:408:131:cafe::e) by BN9PR03CA0517.outlook.office365.com (2603:10b6:408:131::12) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.223.13 via Frontend Transport; Fri, 17 Jul 2026 18:52:41 +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 BN1PEPF0000468A.mail.protection.outlook.com (10.167.243.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.245.5 via Frontend Transport; Fri, 17 Jul 2026 18:52:41 +0000 Received: from DLEE214.ent.ti.com (157.170.170.117) by lewvzet201.ext.ti.com (10.4.14.104) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Fri, 17 Jul 2026 13:52:40 -0500 Received: from DLEE205.ent.ti.com (157.170.170.85) by DLEE214.ent.ti.com (157.170.170.117) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Fri, 17 Jul 2026 13:52:40 -0500 Received: from lelvem-mr05.itg.ti.com (10.180.75.9) 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; Fri, 17 Jul 2026 13:52:40 -0500 Received: from santhoshkumark.dhcp.ti.com (santhoshkumark.dhcp.ti.com [10.24.52.55]) by lelvem-mr05.itg.ti.com (8.18.1/8.18.1) with ESMTP id 66HIpU4x240969; Fri, 17 Jul 2026 13:52:36 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , Subject: [PATCH v5 13/17] spi: cadence-quadspi: reprogram CS timing on every chip-select switch Date: Sat, 18 Jul 2026 00:21:12 +0530 Message-ID: <20260717185116.2065505-14-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260717185116.2065505-1-s-k6@ti.com> References: <20260717185116.2065505-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: BN1PEPF0000468A:EE_|BN0PR10MB5061:EE_ X-MS-Office365-Filtering-Correlation-Id: 1cf41d07-c2fc-4b09-b7dd-08dee4349481 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|82310400026|23010399003|1800799024|36860700016|921020|6133799003|56012099006|10067099003|18002099003|22082099003|3023799007; X-Microsoft-Antispam-Message-Info: cS4xHRvP65ayRknD8S32XEwXbsg8OtmSCXlK9l+4DHOn+L9+RCKscqXdGQaAFgDNRAjt1GyxewbCLjhIe+Am47WwJJ6iU0mKtCfRyS/g15KbcrGNadONhFEXwX2UaDo68fCAbVykEUPXfUCxYK/2RUBaYdyxdCdM/NJl54Yev9kCRPcza/UOvGMBwP9HiaAlz+Pmo08XBbwY+Q8YrXcj2yvTekvXkAtNQZxZI1X1ixhdpPxkVbP+O1dtcHHnqdpPI/chvWAIfu9UwJcGRrx1EfgcxgIsmwTrk4hs93XUlETVQ46xv5GBZOR4Uj35XFCVDpEBBaPf1JUtTS+BnnAtdPUnknb2RbVDrfAxx5oFOI/kHRZdbscWSjC0uLYz+fi/fE6KkZeYkZY81Os7jLzaIfmbFf9vmlLc9Om9PLM8ESn4IiuRwckYnVOluFKI9edsWFQrxq4jLRm+I3WL+4pF0fyrW/+XBNFR7P33CsbGhFvTeo8bRQ1cNOZq30OWZS20K0mCThi4aOOx5uhC6SivecOTi1q3LiEcqJrzj0p2hk3QYhvRD0JUMPPgCtH8mgPNJSL93Wv96tI+yQbzp2aZcM1t89ebPvq9oIt3kL+QRBQACG/Z9sfAY8WcyjYV+eds6WlOIp7holFYDNmA4wKZcN+Pmo+5MOPfxVzx1RkRWJV35K2OL35tREqxs+iZEKvLS2rkwFdVQz6Xm9ba6dy5iFjn6vjr0kn/UiWWpodvv2HoP/6ugjJMYNiRqt2eM/u8 X-Forefront-Antispam-Report: CIP:198.47.23.195;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:lewvzet201.ext.ti.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(7416014)(82310400026)(23010399003)(1800799024)(36860700016)(921020)(6133799003)(56012099006)(10067099003)(18002099003)(22082099003)(3023799007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Wtl89I2qS0pzjvIyIh5+WGto3iBY6elxj5MkHwSB7ldFMa4xr1kyg+0G+uaKq5JyCSw1wso5rGWeCDX2XQruTbF+d4Z+dwVsITk2m0VnM/9UXNt26D8zBJhzTjCiy5ODm5wwQokF+g+v5oznDRHoiRcgqfRi9/+gBvEBVeiGDbTLcVfkJ+rIvF1gL4fIUd6SEptGINharJ8T0nuU6ajWSm9hCJGzOHVikVcnWgsbxhnvreJd4ICVcPkhx4o6RLQsDeWpbIh4NNuH2/znUGhKuBwOcbb3V/4c1cxOPsmFBiyYlzEPZehLmYGqJXkcUM2TFCfsUlkXjNED2rmgc3RIlDA8fQONtcDSxWL+Am4FVP0XVGgBfZ8DEIDq0VNoQKvAJvaU8Vcxe4ksf/0KMREVmHkAM9NvVLMM+SZgA9yWyXyOes+kra4nTJ3pvRHuTkc5 X-Exchange-RoutingPolicyChecked: MErphH8CLLVBY3MUtDv7Y0ZjWybjIvDwd0rwt943RWjSyy5GYCPiCcxq279KZD5K7brMhYuNnciKpWHeMEZBmRsDNUSZ2PcgJO2YlTx7/jSPFenvqqBjBlwk5qlqW5muvbYWIbJKcAeAvtr0uPoLKGaYWFh28vbhFcpWqdx0ziqK6oishq8yKiouDZsmlyaqWSQUVD8Pc8s0elcLw7Bw47OTpD7f5QXT4ltDOZMFf0A6rNF6KJCxyDLHT9CBnj7UXuatsBp6E4/VLoUd4MmsJ5HRXGkNdzwbYA0RZ6VxJ7pEnmuy0LnrazwuP59boOjyxCA0tbzt5dP30htBiGFtvQ== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jul 2026 18:52:41.3021 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1cf41d07-c2fc-4b09-b7dd-08dee4349481 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: BN1PEPF0000468A.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN0PR10MB5061 X-Proofpoint-Spam-Info: AW1haW4tMjYwNzE3MDE5MiBTYWx0ZWRfX30VWd1aIHy5C J4s4Icv/ily/HMoSMi7QOMDrNnNCljf8cKoqwbK6Go5ENabmbrI55SR//5H5Xlkj0EwTqS7TdAd xrKR2DVLkOlQfoYMzhcPYBDcaNwBAuc= X-Proofpoint-GUID: gzx9GSDdYGV5EaJ7BoBIiNtD5-RVo7YX X-Authority-Analysis: v=2.4 cv=M7F97Sws c=1 sm=1 tr=0 ts=6a5a79fc cx=c_pps a=SWHM+P2JNiUeaYpOZLdr7w==:117 a=f+v6EHfkeJbVwR46tk4DMg==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=RAioF0-LDSMA:10 a=s63m1ICgrNkA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=jwouBfj2j3NM8CExmVVE:22 a=sozttTNsAAAA:8 a=okWzP3EbMLmikBYkquQA:9 X-Proofpoint-ORIG-GUID: gzx9GSDdYGV5EaJ7BoBIiNtD5-RVo7YX X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzE3MDE5MiBTYWx0ZWRfX259U0WaAZROn ZNFGoM9JZertdNs5r2rqLj4LB5HimXb+QW9QxUgOzCagJDCZSEFt9iKjFTrnTk+aRlrV7g4EKMG 5IsjpKg72ZkheqeB4xVHhShSnpMKmUZiu+Fopqe2md1Ja3Ith7BIFMXUKgekb+DoBAY4SHiFzJN Xj6YfQ6F6jT3eLv3aIB3QYq2/MKUqw8ZHNnENYDFCkx0HjNSj7KXBOe/33hqYYwehZObU+LSjqs uLo5k/bhXu2HJVtAkuShBqbKjK/a4sG8QDrDOYCpY9sGifv8lux48O74UddAsvRsPODd6dJi4yq pnwoaexKFlLQudUBL95o+QAtGP5JhqktNCoFLOhSO9X1W9NI9Bxx5TUQvaeZmt1qf5EUzP7pTXB 3NN6q49YqVo24ApEjOsDgl+Hf96l/bvkYBRZqdk9RG+Wn0fFz8lEkqe2ey7Eap+/dQxQvnbcaOw MH3XiX9a1rRvtZ8GUcg== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-17_05,2026-07-17_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 priorityscore=1501 bulkscore=0 adultscore=0 spamscore=0 lowpriorityscore=0 malwarescore=0 impostorscore=0 phishscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607170192 Content-Type: text/plain; charset="utf-8" cqspi_configure() only reprogrammed per-device CS timing (CQSPI_REG_DELAY) and the non-PHY read-capture register when the clock frequency changed, not when the chip-select changed. In a multi-device setup where both devices operate at the same frequency, a CS switch leaves the previous device's timing parameters in hardware. Split the update condition: baud rate divisor is updated on clock change only (it is frequency-derived), but the per-device delay and read-capture registers are now updated on any CS or clock switch. Signed-off-by: Santhosh Kumar K --- drivers/spi/spi-cadence-quadspi.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-qu= adspi.c index 542ad331ff16..8bf3a5a8bf43 100644 --- a/drivers/spi/spi-cadence-quadspi.c +++ b/drivers/spi/spi-cadence-quadspi.c @@ -1570,10 +1570,19 @@ static void cqspi_configure(struct cqspi_flash_pdat= a *f_pdata, cqspi_chipselect(f_pdata); } =20 - /* Setup baudrate divisor and delays */ + /* Update baudrate only on clock change. */ if (switch_ck) { cqspi->sclk =3D sclk; cqspi_config_baudrate_div(cqspi); + } + + /* + * Reprogram per-device CS timing and non-PHY read capture on any + * chip-select or clock switch. Without this, two devices at the same + * frequency would each see the other's timing parameters after a CS + * switch, since the lazy clock-only check would never trigger. + */ + if (switch_cs || switch_ck) { cqspi_delay(f_pdata); cqspi_readdata_capture(cqspi, !cqspi->rclk_en, false, f_pdata->read_delay); --=20 2.34.1 From nobody Sat Jul 25 04:54:27 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 45D383914EE; Fri, 17 Jul 2026 18:53:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=148.163.154.28 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784314392; cv=fail; b=pkWk2xTLwBjUtGGoCf4cxUikTKTZMSi0Y+chbO2h6JPPczbb0LsAhGNff/X4v/xIDCAJMEm58AvdJDAl8dhRbfibS6suugqHH3kJueV0pT1SD7nvQPPgV0r7gQILbIzysMOL+0Bz3n+tfDpaK4fhXZBjwbRrsp52XoSnUxqUwSw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784314392; c=relaxed/simple; bh=EgPd8VbcyrS6pF5XRBydAegNzfoN1Y0GfOtUmoBoCs4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=qMQwTpaTnxCFKoNiDuBPUAYpAdyozTzG7ievGWPRbY6C+97xasv5t856mreqLI2i5heJXNOMUFaabl4p14eFSz15sP67AwA7hDqiKnUGQzD7ikZCN5UB87bV0PcSIFrkACuejiIm602JWAHSyHc8HrKK5cr1M/aJKJ7pG5aw9F4= 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=gTOdtuPi; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=RsWRe+Ds; 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="gTOdtuPi"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="RsWRe+Ds" 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 66HIlKQD3222740; Fri, 17 Jul 2026 13:53: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=VdoYsWBenFgsbLRwW1KUBdy/3KraCabI36s9hznhh gI=; b=gTOdtuPiiD2GYRYcrg5F5aRtuOCf+0akK+ORoMx1ET0+KC/TDMu41uwoP 4xUFSbu1MtuF8CbCo7nBAAFJ6p7SSwp75+mGKi8HecRhKsh47AILyi6YW+hOvZuJ I08qFMYfNga+u0DtfhbPlrUki81JIjsLpV4+HcnDNK/jU4b1SGnd+L/Pb/Btwi5f 64VaDH5R3W+pZCXPo0CrLffnVIELrgm4oZepqLz1wuzRk5sflwiEgZTQi3r5+6bF V/LskUXUZu4ynLy1A+8EfGyj66sYSmF+0qmsxYdbjLOWlAVPRF3mGlbeZfoPHKPe 2RzJCGOiCyvHrqOdpJP84QjzERJAg== Received: from ph7pr06cu001.outbound.protection.outlook.com (mail-westus3azon11010034.outbound.protection.outlook.com [52.101.201.34]) by mx0b-0002e601.pphosted.com (PPS) with ESMTPS id 4ffkc3ju2r-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 17 Jul 2026 13:53:01 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=nDfZFtM3/oyfVeNg+XZFsd+tlAGhmOZABVvIOg/b7ez60aeSi0eLbgYVx0/uoAOzWhhHiM0itqWhmhF1SLZWLMT7j9Eu6Zot48GdWa0Nu7wxwJMEecGSUOGmUFyirphwqXxfIdWnAcfBaih6mUGQhZTALngL+ADWmO8MiRZvCt7Ae0Zs/XPB0KUs4VlNXy8yDZ2CeHB48ezG/dgJr6Rg/CSvon6cbgjUr/0uMTaSTRrxqFSDMNuD2g5O0Yfmbq9mLnzmphS3xbVTXeOql4Z5P2YU/D0d7bLiFTejBpybFisky0p8d2M5rhIIOsT2FMMi0us5NvfFeL3ncO9FiJe9Yw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=VdoYsWBenFgsbLRwW1KUBdy/3KraCabI36s9hznhhgI=; b=c7hLVT7dxxmgmnBo89hX/3Ka/uVQZMmqhRxWKzai9niyHNJOcKy0nbvVxnm8VyIciI5aLoH+7NY4C5Hs9JXvAqZXlMyyWzetIscRii8W0VNWaLgatlMZuXSLa5b5Te4BgpP6Vur5ZhxWTOughkNzmYQtWzw9sKkkVDS7vcRIHiQMn6Gav8X6jSIxyZYe+HcaHUNqO7bTjHvbc8DgSs7PlUiWA8+1fBySMylKMuwLoxAtrZPPN1IK/YDlh0aFfeSgjRAlgYo1C5Dm7TZ+CkFASESdKUGk/73SHBb8KAeiY4jmB7dnA7CQMkCj+bdOVl0pKbi/XFJrvefuaH69JiLYoA== 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=VdoYsWBenFgsbLRwW1KUBdy/3KraCabI36s9hznhhgI=; b=RsWRe+DsbbchC67epfl+MP/kWZ29guB80jh+COlb5B4V4DVoUy7obwZOjNwsol7KFjzlTPa5osLre/1b1t6XbIUckScdVn0d5hXrOT/6tap3ap/hFgUL7XloidjRXNwC89mm4/Ic5bBm7fJuH49tV3ZW/pqAWTsuWqCjxvu7jcc= Received: from SJ0PR05CA0080.namprd05.prod.outlook.com (2603:10b6:a03:332::25) by CH3PR10MB6858.namprd10.prod.outlook.com (2603:10b6:610:152::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.223.13; Fri, 17 Jul 2026 18:52:58 +0000 Received: from SJ5PEPF00000209.namprd05.prod.outlook.com (2603:10b6:a03:332:cafe::55) by SJ0PR05CA0080.outlook.office365.com (2603:10b6:a03:332::25) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.245.4 via Frontend Transport; Fri, 17 Jul 2026 18:52:58 +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 SJ5PEPF00000209.mail.protection.outlook.com (10.167.244.42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.245.5 via Frontend Transport; Fri, 17 Jul 2026 18:52:57 +0000 Received: from DFLE203.ent.ti.com (10.64.6.61) 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; Fri, 17 Jul 2026 13:52:46 -0500 Received: from DFLE210.ent.ti.com (10.64.6.68) by DFLE203.ent.ti.com (10.64.6.61) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Fri, 17 Jul 2026 13:52:45 -0500 Received: from lelvem-mr05.itg.ti.com (10.180.75.9) by DFLE210.ent.ti.com (10.64.6.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Fri, 17 Jul 2026 13:52:45 -0500 Received: from santhoshkumark.dhcp.ti.com (santhoshkumark.dhcp.ti.com [10.24.52.55]) by lelvem-mr05.itg.ti.com (8.18.1/8.18.1) with ESMTP id 66HIpU50240969; Fri, 17 Jul 2026 13:52:41 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , Subject: [PATCH v5 14/17] mtd: spinand: extract variant ranking logic into spinand_op_find_best_variant() Date: Sat, 18 Jul 2026 00:21:13 +0530 Message-ID: <20260717185116.2065505-15-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260717185116.2065505-1-s-k6@ti.com> References: <20260717185116.2065505-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: SJ5PEPF00000209:EE_|CH3PR10MB6858:EE_ X-MS-Office365-Filtering-Correlation-Id: b8831eec-6bfc-4371-226a-08dee4349e05 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700016|376014|23010399003|7416014|82310400026|1800799024|921020|56012099006|10067099003|18002099003|22082099003|3023799007; X-Microsoft-Antispam-Message-Info: XB5Do4i6BnL2+DmOL5BOsSX/jo2vH2Y348ahM9MSyXbpsPB3vhYoLwqau6eUs15xVPNNI7fToZ/ZFkAWzJ/4cP7rXx84EieP7kdd3Q2IicaGs4as5I2lFd0oJVnNievUuPRLpCbOMSQM7ftnt17EhZ+DAEOZb2pbnYpxIQLgZGw3T+8VNB6y1ospRs9N7kGz869ocPowxPvz6bUebZb4cJD4wIrsu41Ssdncu45hZOwMvvaiIndqhyqnedCt0ysN/sNZDzLLXu0vVftxJTt2JqIwoxM6ZvZRwqKDKjbqPuUo5FicCpeR/5MHzOPCUfBTh4alBPma4yzRxlrMBlxJIMsCU06DhVPRTjzoj8HFN4y43P04NCaVBAeZ+KKEUC96TTaSMWq6EDRtUG2/cXlDCkf8UtEbF+DlcyL0zqCNEV9Fyp6dEOP/thgWsX9gla/Zxa2EjVc40Vcmg+n4kK+Kg9hW8MMKupD5SZYv5MT7lYR9C+68uNz7F43rGME1xgSyha9F1vOL20vY7X/T9S2OPsmUvM9Kn/+RYwmKiFxPd9A8JYGSYj2gZusxofIlWqx22IaWkZXDxbM6D5m8Qd4qTg7ucwdrYrpn4IXI92IueHdb+zVwet4HuTvELvpwPX3uLzEwfoT/6c7wZFRX+27gSs+oxJFQfw1uPrfophcqiAiSTQOtVjX5OxwOEwKCvHAJQRA5nTiYeVyCGxltoOLR2tCVe+jAhN/KuRLDMqSxRK2rP/O4BAq4ivZp78LWmCyL 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)(376014)(23010399003)(7416014)(82310400026)(1800799024)(921020)(56012099006)(10067099003)(18002099003)(22082099003)(3023799007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: +tiVtGdkZJzM1FQyuJPNNvXACkQbSCO1tbIKMXAio2ErHckctySbBZq9/DnSZjGgLyfYB92lVx6xACjj3baFPhTIzuhP4031yLqCrWIkEZKR7GqxsS2em1sqGQUPaLlDpggJ4iTlxzAhrsH8k3wB4xxrpdndCH/dSJ0iLhpsOHqnx5R1ldQhK/Yad0SRGl/ewYdWTfjmKMosx236C/l9Djxv0aBpJ/DV+f4ZGWc34wowm4+j7cmdafHFAicmInPVJtbPLCUZyjM2YK+xArtDXxOwgn/BgtXV0CD10WfoI9J0x5qMfjstaGvmxB8MJORu2d64pgD5+Sr08HPQxD088Av7aVhSely52qRwsHNOytXp1YUUNFbbbonwYkmlWsc/UqjItqXpX//5oAIGhbi2vYt+5X/9G6pjIxgD+OV2gsSU0rzAe49nhcCupiBpz0Ny X-Exchange-RoutingPolicyChecked: L9RDnoBnUB3bdh7kQPpVEqXAMQSkrOOxgID+0Yi1cQm9cxsE9xmwdtaA9rvV4lGRtCmxTFy9e+Dok3qIr+s/yBgoqsZqj1IlyEh/QfnzTwXZsfhtG2NWiiPFXgrMsdTFw3lzZmURLhYamzu1LiAut1WFlUcXpZJoL/oOSqP+5TPwMdo/EjBEg93fw35GT7zQxUn+Riz1e27loTg9zJ2NRTkxtH/a3q2SdK/HW4iuSaRId2pFLuUf6JnmKA5Ny62SsKTcpqQ9Cre/y7XUFrqljlGpvvaO4daxYYo0qIBMoZNFNXyh+TCgSpUwBJreT2VS34YYJMBpCmy5/jATUS/Dcg== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jul 2026 18:52:57.2420 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b8831eec-6bfc-4371-226a-08dee4349e05 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: SJ5PEPF00000209.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR10MB6858 X-Proofpoint-Spam-Info: AW1haW4tMjYwNzE3MDE5MiBTYWx0ZWRfX1yBqnwEq9QYh 0ThlRqALM+lIcVIidLw1G6wxVh2FHLMdljjznBvvwk3eMuGcGrmDxc7JFqNA+NL+3HU4Qr+8uZQ Tf2c/BqH2CuZzViizVH8U+AgR6iMtug= X-Proofpoint-GUID: Q3Z0MAG8Ir7ROu76lGmtOBwL5SIK8GP4 X-Authority-Analysis: v=2.4 cv=M7F97Sws c=1 sm=1 tr=0 ts=6a5a7a0d cx=c_pps a=p9IRwfs10qZ2nHdxx/cwJw==:117 a=tJyPKKxUohctrY4NYmUjkA==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=RAioF0-LDSMA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=jwouBfj2j3NM8CExmVVE:22 a=sozttTNsAAAA:8 a=mFCyQ4P7OL-0BhijAlUA:9 X-Proofpoint-ORIG-GUID: Q3Z0MAG8Ir7ROu76lGmtOBwL5SIK8GP4 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzE3MDE5MiBTYWx0ZWRfX3AY0X8dedHYP mK5QFpyC/MTA+Ehr4zTSKqG4RvSt8R8HaPvPXHh1HOL88raf2brKWQC1YrQslgvNqo0fDgye6wN iRFOG9EpDECSJNPKVGs9XlzItkOAi5Sou5Tl+kh6OyXtjbaMTEQShwiq2ciMWONzMjZfF8gRRK7 zXqFP7pHP3yPHDxBFoAiKQw7Wdhv8N1bIHHHPuzgsGhyPhaja4bM5IQI7GQiW1/zbd6IYu32xWD ARNB0XZypYBIAUtwWuJ40ewhX+2k//acH5kk7gY4i+m9SCwEcYf5zQtjQduShi1tv14IG37rDxu gjVo6Nhnp/wcLMCjsO9ocmFM6p1MkpsqDRpXT8FJC7dvBYSkzN4E7B3vF/eWmz+I2MxdbJ5fucN mi/5U/E62Q8lWqrGxoMtDzD6eIJvBbob4RZ+TpUeUx1I26arW9uMbK8ymcR04AI3vzBQ082MEK2 NAduGTEcD2kGSoVyEOA== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-17_05,2026-07-17_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 priorityscore=1501 bulkscore=0 adultscore=0 spamscore=0 lowpriorityscore=0 malwarescore=0 impostorscore=0 phishscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607170192 Content-Type: text/plain; charset="utf-8" Refactor spinand_select_op_variant() to extract the inner loop into a shared helper spinand_op_find_best_variant(). The helper takes a skip_mask bitmask of already-tried variant indices, enabling callers to iterate variants in ranked performance order while skipping those already attempted. spinand_select_op_variant() becomes a one-liner wrapper. No functional change. Signed-off-by: Santhosh Kumar K --- drivers/mtd/nand/spi/core.c | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c index 8bf9301f25e7..7c3341f1fca0 100644 --- a/drivers/mtd/nand/spi/core.c +++ b/drivers/mtd/nand/spi/core.c @@ -1542,9 +1542,22 @@ static int spinand_init_odtr_instruction_set(struct = spinand_device *spinand) return 0; } =20 +/* + * spinand_op_find_best_variant() - Find the fastest eligible op variant. + * @spinand: SPI NAND device + * @variants: full variant list to search + * @iface: bus interface to consider (ODTR or SSDR) + * @skip_mask: bitmask of variant indices to skip (already tried) + * + * Iterates @variants, evaluates transfer duration for each eligible op, a= nd + * returns a pointer to the fastest one not in @skip_mask. Returns NULL w= hen + * no eligible variant remains. Used by both variant selection at init ti= me + * (skip_mask =3D=3D 0) and ranked PHY tuning iteration. + */ static const struct spi_mem_op * -spinand_select_op_variant(struct spinand_device *spinand, enum spinand_bus= _interface iface, - const struct spinand_op_variants *variants) +spinand_op_find_best_variant(struct spinand_device *spinand, + const struct spinand_op_variants *variants, + enum spinand_bus_interface iface, u32 skip_mask) { struct nand_device *nand =3D spinand_to_nand(spinand); const struct spi_mem_op *best_variant =3D NULL; @@ -1552,15 +1565,16 @@ spinand_select_op_variant(struct spinand_device *sp= inand, enum spinand_bus_inter unsigned int i; =20 for (i =3D 0; i < variants->nops; i++) { - struct spi_mem_op op =3D variants->ops[i]; + struct spi_mem_op op; u64 op_duration_ns =3D 0; unsigned int nbytes; int ret; =20 - if ((iface =3D=3D SSDR && spinand_op_is_odtr(&op)) || - (iface =3D=3D ODTR && !spinand_op_is_odtr(&op))) + if ((skip_mask & BIT(i)) || + spinand_op_is_odtr(&variants->ops[i]) !=3D (iface =3D=3D ODTR)) continue; =20 + op =3D variants->ops[i]; nbytes =3D nanddev_per_page_oobsize(nand) + nanddev_page_size(nand); =20 @@ -1589,6 +1603,14 @@ spinand_select_op_variant(struct spinand_device *spi= nand, enum spinand_bus_inter return best_variant; } =20 +static const struct spi_mem_op * +spinand_select_op_variant(struct spinand_device *spinand, + enum spinand_bus_interface iface, + const struct spinand_op_variants *variants) +{ + return spinand_op_find_best_variant(spinand, variants, iface, 0); +} + /** * spinand_match_and_init() - Try to find a match between a device ID and = an * entry in a spinand_info table --=20 2.34.1 From nobody Sat Jul 25 04:54:27 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 A4460390228; Fri, 17 Jul 2026 18:53:08 +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=1784314390; cv=fail; b=oCeaX4W5may8wgFp074iaBypeM9YalQTGHgF1YoCaan5MVxv/0Z3RdswbRVK9QYJDQ/AGuT0nUTGVOb8bPnBcEZLWRUj5NbwxJ9olGARyO8SwjNGSH9WLeujFWM7sG9Cx4nMNGvOE3++vjW81Bbo06eb0kUjLmOcrPGcRlZ7Caw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784314390; c=relaxed/simple; bh=klTCINip5Cd5Q6sQw9ppFW49YqgxdSsn8/+OTbEeEkI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=iCyNRTlZ2Iuy6Y9NFKKoYsvLwsUZVEAk6BtuN5MI+0ylCunn+NnRfGcCYHZoSfySGlQWrRRa3BXi9YqvQbQq09vhaFJ5EQuFP2Rmx2EDDE2TXPQHf6/H5axbrWVj2bG0VEbOJy9AgalVwkG7YBmQMtkwx5dBNs4R6KLcGRDzjXQ= 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=fMM1Esfd; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=rf7LXToF; 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="fMM1Esfd"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="rf7LXToF" 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 66HIlgWM3222831; Fri, 17 Jul 2026 13:52: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=/t8AMDRHjLNpJH6jG/YwirgiSkZJEXr7FStcsZDms sQ=; b=fMM1Esfd7NxVm9DM7i7UHBLGXS2nrRw/OuH9Q+7rfyukkBtWyLyBxtpk3 c1I02JG12fb2vONFq2ztVRZiRccmDb546wISZYA1Sy7m5omTtYQ+x+FcwHFCJcpY TuBXNkBLtZYscsn+NQQblVDqR8Ep67KJuCgoLEMsCQN16D3K1v03OwnzDbu9DfpM GCRJjRIUyUuSqwHcctztthANQMhOwrnjy1P5SeyughlrQK9U/MTAgX1TpypxVuG0 Fh2Be/IXTO79pJDxczIxD8ZAcw+9MCYw0EMeXRVQcfcCSfVyJhlrODJzEPzfqf4a EstbAd4tLRwhYgvQVj8haiqBFPu4g== Received: from sa9pr02cu001.outbound.protection.outlook.com (mail-southcentralusazon11013024.outbound.protection.outlook.com [40.93.196.24]) by mx0b-0002e601.pphosted.com (PPS) with ESMTPS id 4ff2ccyxqg-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 17 Jul 2026 13:52:57 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=J7qKEcBNbDXDl/W/pFhSJfF/9PKJ1smAL+AduMmigQXYBlYNgV67mCKOM2V9fGGT6QExPsrjfhBQTKBzQJ4nJld3c4gMKFQAedMlAX5oPtUwey4dfwohgvpmKEqLdTb4pGanE5AnUZ5a0BnUcVMfUuqx+lH0IupEtnBcr3PoFpeiKAiVH3Gxh1hewUcabutZ3QIvNNfHANQiG+TvkUI1TSNeasVW1UJ+wo3fu10t0mzLJypNpX6V1mg5tblVA1fBf587ZWD0zTZxtk+Oplo5AW3+7/Pl0TDUqdJ5gax9gtXz9tuyaVM8AFNISnNb8kSLBz5zCcHr8bpOlFDOtBQCFA== 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=/t8AMDRHjLNpJH6jG/YwirgiSkZJEXr7FStcsZDmssQ=; b=IEHzd+QlQUdYALDfP9H4vbsev9j++icrlATQkDiEYsvTXz7+8qJ0W1LBkM3jtXtbx6/L5d/F9bkPljWv1hyAaSkdVRphGRBjETQMTuEstJHIWMNQrqJ4pYZJWPr2hOXY9xME9G14Qy+or+MuhX6PX4H06ceEjWgNe99qtxEozjm46rCYbmdlALgab15xzYox1snuq2qLFCTlccE9cKZ4mRmc5oYhhZJLsMrFHIHM4xpYRpb1RtTlQ924rBwN8GYQSYM/y/SBB7+Hl8bb/icPHZMqbvLCjv0r6BE394oDku979mFVsB6f3yGKAEO3B9odDX/c+FGyQkoaOGUQ6vWaSg== 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=/t8AMDRHjLNpJH6jG/YwirgiSkZJEXr7FStcsZDmssQ=; b=rf7LXToFEKcbBn0vwVeqWlGOs4YvjtgDxUEONu7ZKXt43IHefVNjvpCL0DWFIGG8fMByQPlZlzLxN2s7FtbCrWGD3DIzYAdiD3UjBAND+GeHE6vhnQj3a7GgJtGslViPQOVlezyzmx7pDjwjDjEbYBViTLAuUDexs10Ghto8POs= Received: from BN9PR03CA0316.namprd03.prod.outlook.com (2603:10b6:408:112::21) 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.223.13; Fri, 17 Jul 2026 18:52:51 +0000 Received: from BN1PEPF00004689.namprd05.prod.outlook.com (2603:10b6:408:112:cafe::20) by BN9PR03CA0316.outlook.office365.com (2603:10b6:408:112::21) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.223.13 via Frontend Transport; Fri, 17 Jul 2026 18:52:51 +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 BN1PEPF00004689.mail.protection.outlook.com (10.167.243.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.245.5 via Frontend Transport; Fri, 17 Jul 2026 18:52:51 +0000 Received: from DLEE203.ent.ti.com (157.170.170.78) 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; Fri, 17 Jul 2026 13:52:50 -0500 Received: from DLEE200.ent.ti.com (157.170.170.75) 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; Fri, 17 Jul 2026 13:52:50 -0500 Received: from lelvem-mr05.itg.ti.com (10.180.75.9) by DLEE200.ent.ti.com (157.170.170.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Fri, 17 Jul 2026 13:52:50 -0500 Received: from santhoshkumark.dhcp.ti.com (santhoshkumark.dhcp.ti.com [10.24.52.55]) by lelvem-mr05.itg.ti.com (8.18.1/8.18.1) with ESMTP id 66HIpU51240969; Fri, 17 Jul 2026 13:52:46 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , Subject: [PATCH v5 15/17] mtd: spinand: negotiate optimal controller operating point before dirmap creation Date: Sat, 18 Jul 2026 00:21:14 +0530 Message-ID: <20260717185116.2065505-16-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260717185116.2065505-1-s-k6@ti.com> References: <20260717185116.2065505-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: BN1PEPF00004689:EE_|CO1PR10MB4435:EE_ X-MS-Office365-Filtering-Correlation-Id: bc8c46ff-ce4f-4b7c-374d-08dee4349a85 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|7416014|376014|36860700016|23010399003|1800799024|921020|18002099003|22082099003|6133799003|56012099006|10067099003; X-Microsoft-Antispam-Message-Info: w6HQ65nehhY+Z5h40ayHpW2PF/X/Rqp/tRo753XNB4iI58wSmZzxyHuhif5FG8Za9iJ9UiC4dyf3LfuTURLQswvzJyyN4fNCRKXXAdT3im1MT4gOE/L3tTjj5pEeMwhxgqFh6oGd68S+Pa1BQIJHVTS1xIlfuQe1cw4u3lhf+WJ9wsz1gOiIxAjCtaZlSR6xMWAwB1zqdGuFaAG/X92ieP+/8uRMvruyW1N6g5TQiyhWs7H9ilN24YKiQPTmeh8O7aNOQKlueahtmJy5WZEo/PVFU8m723d5nhNyMiQoi14gRUT3jYkKeX87W2euYst0B/6vt64Xw/n64Cs6snJI7OnYRubWIqBjLaLAGWp64gyqkOmAbHqmtx4XsLf7htNAnpulrmHIq2d9Pe44jdaFRZ07euzBc+6RKpKdVuMAX9/4HqUJiJdl519pd8wdcbm4QOfBIkBbUytHSf1qucX3Ts3sbcMRCWs9x6MBW0uSNhitaS0V3oOXUhd1/BwaU5x5P+ZiuGl7RpaKJWyHzBkwlhl3HPLS4Ai/TXCnAFSEz2S9/3xqXJXGNbgm/U4e6Zgwjpkuk6wBQAS38IW5QRpGc17MpzlR7sD25guunFNJluMYiiypv8h/V5VQagQzJD1R7lXTKuNDf6G02gGWtoYKXGcXWusCewGuobutRO6FWposXvjuGGbZivN5k6fQFn4yVvGflPnDMbBGT0l1k+Yg3hKf6h1Jr+8dFVXPHaGYr/eMOHEgdmqU1HZB+s+n9A+C 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)(7416014)(376014)(36860700016)(23010399003)(1800799024)(921020)(18002099003)(22082099003)(6133799003)(56012099006)(10067099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: RCSgXrQ1BOpsVk0vXn5+0hlLdaG9pQPLZvTvU83XdBH5SEl6QihPtIqfzUGYedL7qckdLh/5HeOa+fEK/Pmme7kqtqLR6xUNukrCxZdp6khG2SMK7KwFMkU3KtOoL8rsy+WS9WHQT1zfMafN5HBSJmB3p2R74amIRKeRYCj8WAAf5tMtyYEPdVmn8VGJf98cZa21AxSrlpwuu2wu9ibZPrE4SqqkrK0zGlR5CTQoriqUm5KiNR0rHr0pQ8+BSswJ07NOjf2TeOpvovvCpjY1AL5AhaEizeexm6144WqmRWpyU6ghBE9oJk0eePFdlQsOgZRe0JDTbqJoOamtertUcuKzLf/wocFZl0UORCgByexOXrb3G/GsV6E6rya290tGLBMXN9j0uU0TChjFcaeD5pfy7eg+0LB904rSQHJV6m2jgO9/mVeu/J2TIf/Ah/D0 X-Exchange-RoutingPolicyChecked: KC03dT2K7np0oEFZ8sid3xsdkCIOfpeodFwfTIMfwhThmFWrBckqvcdITxq+3oJ0mQRINo0wTwn7V5vMQl9K3Bmoy9e2yCEPvgchZg7r3hygKyacLDWVC5fNhDTXv8JXvxmX1UIah2AeX/GbtHf9nG0h8hFD/43IAI7rQz9375UFbAWbteGqgFvL5BKMUwLnprMSYKF2vr5WsPhkrfg7B/nHKXET9xynjywrjZRphAUVBiN39BrsLe8NjlXA4vIN9MN3biXaMASx5kxRGbtHouVMXY1E4YUlenKEgMK76NegehtExJtbVi+0gFhqbSqERQKIscaDTfaGzuIyDqkb4A== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jul 2026 18:52:51.3921 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bc8c46ff-ce4f-4b7c-374d-08dee4349a85 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: BN1PEPF00004689.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR10MB4435 X-Authority-Analysis: v=2.4 cv=NtvhtcdJ c=1 sm=1 tr=0 ts=6a5a7a09 cx=c_pps a=SvXgiSASQu/JPdBzctYFLA==:117 a=f+v6EHfkeJbVwR46tk4DMg==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=IkcTkHD0fZMA:10 a=RAioF0-LDSMA:10 a=s63m1ICgrNkA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=fPAWb5peG099m5CrUpKH:22 a=sozttTNsAAAA:8 a=U5cn0f2nyUSNena3quMA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 X-Proofpoint-ORIG-GUID: TanEGkQ5Q-j7OciNGqBiZyPyHgZjA1pt X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzE3MDE5MiBTYWx0ZWRfX1LCu49qKSD+t lHbPEr2DPLPVdBlSGExT5Lr8LGSVMR/CSnN1gh/oy/+3+ePjHuYPI9EpTWTezXlw/LEYn4KKQFx aHpgx3URy1qLvgYkNZvgFN+q+jdSHgIiPYhff6oJc5mWzTHrnrhX5PFbXbWTLXQjodMAsq3EoMj Y1/JgJYMNuq0tgPhPKaUOAjz2M+gbpYZeM9N1sh/Y7w+GqQxFJ07W09ndG/mJxSTHZQsdhz13/2 LCGxkkx/gc4zSdguUclgx0TNndR21bZIG2h0eFDJcukNGtcfFoSRyAm65AMJxSwVrCB33zRU4m9 wtmajTk/Q/pDwks8IYmcrb4ahRGvt3eRcOJ5WaHiWKLx/57EKH/VvdhV1CIBXnBHffDy8XYq/3X VhKoAV+01IkGjxOP3B2FrZGgzav2NE1oQkpB5c3e8Epq6j+4oAVmmNStI9mdd5nSD3iSw06+h2a IoqBqwSr3VpvKLPp6tQ== X-Proofpoint-GUID: TanEGkQ5Q-j7OciNGqBiZyPyHgZjA1pt X-Proofpoint-Spam-Info: AW1haW4tMjYwNzE3MDE5MiBTYWx0ZWRfX/bv+YQfQ89GF UVTl60DcUiq8ENPnmWxWSSHg+5RtDwq1MLjswJJc802yM8U/DEkp57uRifuOkdP2bJx5XJfhx+p +0yTGnngMD7wQczTitPRfMjPWh+D4Is= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-17_05,2026-07-17_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 adultscore=0 lowpriorityscore=0 spamscore=0 clxscore=1015 suspectscore=0 bulkscore=0 impostorscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607170192 Dirmap descriptors encode the op template including the operating frequency at creation time, so controller optimization 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_optimize_controller() call that negotiates the best available operating point. spinand_optimize_controller() tries the pre-selected variant first. If the controller signals that optimization is not applicable for that op, spinand_try_ranked_variant() iterates remaining variants in performance order =E2=80=94 ODTR variants first, then SSDR variants after switching the bus interface if needed. On full failure the device falls back to the best available non-optimized mode. Add spinand_reset_max_freq_ops() to copy op templates with max_freq zeroed before each execute_tuning call, enforcing the invariant that a non-zero max_freq only results from a successful operation. Optimization failure is never fatal; the device operates at the conservative base rate. Signed-off-by: Santhosh Kumar K --- drivers/mtd/nand/spi/core.c | 206 ++++++++++++++++++++++++++++++++++-- include/linux/mtd/spinand.h | 11 ++ 2 files changed, 208 insertions(+), 9 deletions(-) diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c index 7c3341f1fca0..b79d06d9ddaf 100644 --- a/drivers/mtd/nand/spi/core.c +++ b/drivers/mtd/nand/spi/core.c @@ -1284,6 +1284,7 @@ static int spinand_create_dirmap(struct spinand_devic= e *spinand, info.length =3D nanddev_page_size(nand) + nanddev_per_page_oobsize(nand); info.primary_op_tmpl =3D *spinand->op_templates->update_cache; info.primary_op_tmpl.data.ecc =3D enable_ecc; + info.primary_op_tmpl.max_freq =3D spinand->max_write_op.max_freq; desc =3D devm_spi_mem_dirmap_create(&spinand->spimem->spi->dev, spinand->spimem, &info); if (IS_ERR(desc)) @@ -1294,9 +1295,11 @@ static int spinand_create_dirmap(struct spinand_devi= ce *spinand, /* Read descriptor */ info.primary_op_tmpl =3D *spinand->op_templates->read_cache; info.primary_op_tmpl.data.ecc =3D enable_ecc; + info.primary_op_tmpl.max_freq =3D spinand->max_read_op.max_freq; if (secondary_op) { info.secondary_op_tmpl =3D *spinand->op_templates->cont_read_cache; info.secondary_op_tmpl.data.ecc =3D enable_ecc; + info.secondary_op_tmpl.max_freq =3D spinand->max_read_op.max_freq; } desc =3D spinand_create_rdesc(spinand, &info); if (IS_ERR(desc)) @@ -1745,6 +1748,17 @@ int spinand_match_and_init(struct spinand_device *sp= inand, spinand->cont_read_possible =3D false; } =20 + /* + * Save the full read variant list (ODTR and SSDR ops) for + * ranked controller optimization. Only saved when all ODTR + * templates are valid; spinand_optimize_controller() uses this + * to fall back to the next-best variant when needed. + */ + if (spinand->odtr_op_templates.read_cache && + spinand->odtr_op_templates.write_cache && + spinand->odtr_op_templates.update_cache) + spinand->all_read_variants =3D info->op_variants.read_cache; + return 0; } =20 @@ -1923,7 +1937,6 @@ static int spinand_mtd_suspend(struct mtd_info *mtd) =20 static int spinand_init(struct spinand_device *spinand) { - struct device *dev =3D &spinand->spimem->spi->dev; struct mtd_info *mtd =3D spinand_to_mtd(spinand); struct nand_device *nand =3D mtd_to_nanddev(mtd); int ret; @@ -2015,14 +2028,6 @@ static int spinand_init(struct spinand_device *spina= nd) mtd->ecc_step_size =3D nanddev_get_ecc_conf(nand)->step_size; mtd->bitflip_threshold =3D DIV_ROUND_UP(mtd->ecc_strength * 3, 4); =20 - ret =3D spinand_create_dirmaps(spinand); - if (ret) { - dev_err(dev, - "Failed to create direct mappings for read/write operations (err =3D %d= )\n", - ret); - goto err_cleanup_ecc_engine; - } - return 0; =20 err_cleanup_ecc_engine: @@ -2051,6 +2056,175 @@ static void spinand_cleanup(struct spinand_device *= spinand) kfree(spinand->scratchbuf); } =20 +/* + * spinand_try_ranked_variant() - Try controller optimization on variants = in + * performance order. + * @spinand: SPI NAND device + * @mem: SPI memory device + * @iface: bus interface to iterate (ODTR or SSDR) + * @tried_mask: bitmask of already-tried variant indices; updated on each = try + * + * Iterates the full read variant list in descending performance order, + * skipping variants in @tried_mask, and calls execute_tuning on each until + * one succeeds. Ranked iteration finds the best available variant without + * re-trying already-attempted ones. + * + * On success, sets spinand->max_read_op and updates the matching + * odtr_op_templates.read_cache or ssdr_op_templates.read_cache. + */ +static bool spinand_try_ranked_variant(struct spinand_device *spinand, + struct spi_mem *mem, + enum spinand_bus_interface iface, + u32 *tried_mask) +{ + const struct spinand_op_variants *variants =3D spinand->all_read_variants; + const struct spi_mem_op *best; + int ret; + + if (!variants) + return false; + + while ((best =3D spinand_op_find_best_variant(spinand, variants, iface, + *tried_mask))) { + *tried_mask |=3D BIT(best - variants->ops); + spinand->max_read_op =3D *best; + spinand->max_read_op.max_freq =3D 0; + ret =3D spi_mem_execute_tuning(mem, &spinand->max_read_op, + &spinand->max_write_op); + if (ret && ret !=3D -EOPNOTSUPP) + dev_dbg(&mem->spi->dev, "%s optimization failed: %d\n", + iface =3D=3D ODTR ? "ODTR" : "SSDR", ret); + if (!ret && spinand->max_read_op.max_freq) { + if (iface =3D=3D ODTR) + spinand->odtr_op_templates.read_cache =3D best; + else + spinand->ssdr_op_templates.read_cache =3D best; + return true; + } + } + return false; +} + +/* + * spinand_reset_max_freq_ops() - Copy op templates and zero max_freq on b= oth. + * @spinand: SPI NAND device + * @templates: op template set to copy from + * + * Called before execute_tuning so max_freq starts at zero; execute_tuning= sets + * it to the validated clock rate only on success. A non-zero max_freq mea= ns + * controller-optimized; zero means the base rate applies. + */ +static void spinand_reset_max_freq_ops(struct spinand_device *spinand, + struct spinand_mem_ops *templates) +{ + spinand->max_read_op =3D *templates->read_cache; + spinand->max_read_op.max_freq =3D 0; + spinand->max_write_op =3D *templates->write_cache; + spinand->max_write_op.max_freq =3D 0; +} + +/* + * spinand_optimize_controller() - Negotiate the optimal controller operat= ing + * point for the SPI NAND device. + * @spinand: SPI NAND device + * @mem: SPI memory device + * + * Tries the pre-selected variant first. If the controller signals that + * optimization is not applicable for that specific op, iterates all remai= ning + * variants in performance order. For devices that support both DTR and S= DR + * interfaces, DTR variants are tried first; if all fail the device is + * switched to SDR mode and SDR variants are tried. On full failure the + * device falls back to the best available non-optimized mode. Devices th= at + * support only SDR skip the DTR ranked pass entirely. + * + * Optimization failure is never fatal. + * + * Note: tried_mask is u32, supporting up to 32 variants total across both + * ODTR and SSDR. Flash devices with more than 32 read variants are not + * supported. + */ +static void spinand_optimize_controller(struct spinand_device *spinand, + struct spi_mem *mem) +{ + u32 tried_mask; + int ret; + + /* Skip entirely when no post-config target is configured. */ + if (!mem->spi->post_config_max_speed_hz) + return; + + spinand_reset_max_freq_ops(spinand, spinand->op_templates); + + ret =3D spi_mem_execute_tuning(mem, &spinand->max_read_op, + &spinand->max_write_op); + if (ret && ret !=3D -EOPNOTSUPP) + dev_dbg(&mem->spi->dev, "Controller optimization failed: %d\n", + ret); + + /* + * Any non-zero return or a set max_freq means we are done (error, + * unsupported, or success). Fallback only for the op-specific "skip" + * signal: ret =3D=3D 0 with max_freq still 0. + */ + if (ret || spinand->max_read_op.max_freq) + return; + + /* SSDR-only devices have no ranked ODTR fallback available. */ + if (spinand->bus_iface =3D=3D SSDR || !spinand->all_read_variants) + return; + + if (WARN_ON(spinand->all_read_variants->nops > 32)) + return; + + /* Mark the pre-selected ODTR variant as already tried. */ + tried_mask =3D BIT(spinand->odtr_op_templates.read_cache - + spinand->all_read_variants->ops); + + dev_dbg(&mem->spi->dev, + "Optimization skipped for current op; searching for best variant\n"); + + /* Pass 1: try all remaining ODTR variants in performance order. */ + if (spinand_try_ranked_variant(spinand, mem, ODTR, &tried_mask)) + return; + + /* + * Pass 2: switch to SSDR and try all SSDR variants in performance + * order. configure_chip is guaranteed non-NULL here: reaching ODTR + * mode requires it. + */ + if (WARN_ON(!spinand->configure_chip)) + goto use_odtr_fallback; + + if (spinand->configure_chip(spinand, SSDR)) + goto use_odtr_fallback; + + spinand->op_templates =3D &spinand->ssdr_op_templates; + spinand->bus_iface =3D SSDR; + spinand->max_write_op =3D *spinand->ssdr_op_templates.write_cache; + spinand->max_write_op.max_freq =3D 0; + + /* Only ODTR variants were candidates in Pass 1; SSDR bits are clear. */ + if (spinand_try_ranked_variant(spinand, mem, SSDR, &tried_mask)) + return; + + /* + * All attempts exhausted. Revert to ODTR for non-optimized DTR + * operation. If revert fails, stay in SSDR =E2=80=94 a mode mismatch + * (ODTR op templates on SSDR-mode device) would corrupt data. + */ + if (spinand->configure_chip(spinand, ODTR)) { + dev_warn(&mem->spi->dev, + "Failed to revert to ODTR, staying in SSDR\n"); + spinand_reset_max_freq_ops(spinand, &spinand->ssdr_op_templates); + return; + } + +use_odtr_fallback: + spinand->op_templates =3D &spinand->odtr_op_templates; + spinand->bus_iface =3D ODTR; + spinand_reset_max_freq_ops(spinand, &spinand->odtr_op_templates); +} + static int spinand_probe(struct spi_mem *mem) { struct spinand_device *spinand; @@ -2073,6 +2247,20 @@ static int spinand_probe(struct spi_mem *mem) if (ret) return ret; =20 + /* + * Negotiate the best controller operating point before creating dirmaps + * so the validated frequency is available at dirmap construction time. + */ + spinand_optimize_controller(spinand, mem); + + ret =3D spinand_create_dirmaps(spinand); + if (ret) { + dev_err(&mem->spi->dev, + "Failed to create direct mappings for read/write operations (err =3D %d= )\n", + ret); + goto err_spinand_cleanup; + } + ret =3D mtd_device_register(mtd, NULL, 0); if (ret) goto err_spinand_cleanup; diff --git a/include/linux/mtd/spinand.h b/include/linux/mtd/spinand.h index 5f4c00ae72a7..7eacda949719 100644 --- a/include/linux/mtd/spinand.h +++ b/include/linux/mtd/spinand.h @@ -792,8 +792,19 @@ struct spinand_device { struct spinand_mem_ops *op_templates; enum spinand_bus_interface bus_iface; =20 + /* + * Full read variant list (ODTR and SSDR ops together), saved when ODTR + * templates are valid. Used by spinand_optimize_controller() for ranked + * fallback when the pre-selected variant cannot be controller-optimized. + */ + const struct spinand_op_variants *all_read_variants; + struct spinand_dirmap *dirmaps; =20 + /* Persistent op templates updated by execute_tuning with validated speed= . */ + struct spi_mem_op max_read_op; + struct spi_mem_op max_write_op; + int (*select_target)(struct spinand_device *spinand, unsigned int target); unsigned int cur_target; --=20 2.34.1 From nobody Sat Jul 25 04:54:27 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 30EFA3876CE; Fri, 17 Jul 2026 18:53:27 +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=1784314409; cv=fail; b=hvvFGo5Lhj1jgqn6OX7wwQe/UIB4HpxWr/PF3+1/IT/9r1MJ1JjtYKk8ixsh7Q/pv3JqFAx6vQtu+5kjnLEXdrJgC8gXKTDfHtZgpXQIciU6IqjZisqga5rn/o7wwW6BPdu0flem6fFsxJ8XPHhQ9+x5//5BqzmRE8e/pCTw6HI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784314409; c=relaxed/simple; bh=zyzIHZWkbZiJeCTqvhBe5bpyE69d/84Z/bMFLKqBSj4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TkZD82eFKXvDPITks7DGOw2eMktu6pDVuLtpLgJ1XjNbGicl0XBJKD8ZX/DG8sJx06TebUn3+D7V0T5OZM2F351c3YpRT9cjCqRui1GgAI/JzrZHWb7/yaXaEQIsrDfJWdv6oUpsgSIj1LepqYzficumrfl2UpNBx4kguuEz7m4= 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=oD4ffpUC; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=d4FBZ731; 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="oD4ffpUC"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="d4FBZ731" 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 66HIlUBv1570175; Fri, 17 Jul 2026 13:53:18 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint-05-2026; bh=NjiltEpWKo8+XGVIPeclBhOkyH3dhzzS6Rxspq0yy U4=; b=oD4ffpUCYNaFXrSXHSO6aZJsy82vlkm3G+SCXiTb0q31PrziRgo4SdCfO ck0VoR9oODNpGfyhJ9nivF64JQVg0Dwt9YvYg3SobA9tUVuI9HVrMkwzC5HKOJfZ 5u/JsoqYVCx6er631WdP/zBhO1jFFjfTO8QIVCWKeY1OQHhubrsh4N3MPGcOom1r p9aG4YCNrO1FLzDPSSdiEeQkon40RLLyfG2vrSJWa7VEvQUilfioi+fHdFS+wJPY lzwZhSmpGcnHn7iZuUKtcy+/CXOA3XFifruHXHZPfZyvKDx69hBKpJmwH1mkbRmG DwlA3xXh/jLk5Xoj3+q6A1sPG+75A== Received: from bl0pr03cu003.outbound.protection.outlook.com (mail-eastusazon11012054.outbound.protection.outlook.com [52.101.53.54]) by m0384305.ppops.net (PPS) with ESMTPS id 4ffgsmbgxg-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 17 Jul 2026 13:53:17 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=i0f/b9f7Xm2ZFH/TwjVfE0c8VddvwczdPK+nssPEhXooEx+YaSUyovXbkXa2csntVAGpZKnTB36asL6HmWVaz5jneTzemV7uQOc2nSl5azt5mO0wsayuexcNfKG+R+H/fTVEhMfPHaCwbIzXuC/0At9q4KKlZ1ZRMAHR9vvyjzOV4cRsTWKWW6lO4MOYO9yQvJkTPf3ENqPutEy4jQEUZ6ZfZNbxhPHqNRXjiUYTgSFR41pTDuy9PPJMta5nQvbuksES3ZVuU3D3IkpY5Hq6ZFKbU4gjZGPz4EBt0Ys8sEOIhnPPosFWpUXHIHG+VNLB49bkvtf64tsKJkRPurUyqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=NjiltEpWKo8+XGVIPeclBhOkyH3dhzzS6Rxspq0yyU4=; b=FYHLe92e7a75EowWVc8ku2WrGqhVsE5SZ59WwfKYbGcX9ac6SoWcZvlK99vOxQ+lDbbpBYyjTwrIWTgKF1bYJIUFn2KmMmcdTWLQpTP6SMg/OiAzhb58mXvH0sCxofWRnsfQHoS3bX3hTKZfsc+mCOdIjTGf2m3oXLQ8hPHvMPLhnADHEXLbR3Oj5RgSjEpZs7/Jg8lCI1AlG82fUWp6adWl9cm/Kx/ep2dAimSg+sdXf3XuxnX7JBdtRJlDuAsPvTLvevcj91K73uGqCSDhnhuXW7QPWPl6HlnSZUMHlBRg00AMOyPJI42kThrlZgHB8RnxnA7MMe8FFgJbxgROYA== 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=NjiltEpWKo8+XGVIPeclBhOkyH3dhzzS6Rxspq0yyU4=; b=d4FBZ731BhClLE6k8bVl41jFAbABLL2/0A7nTGX6jyTSip1hmPDEEq6qN5mRy+fG3vLpR+eHw9Pg2DlXgvxoa+Px7MqqZ1gccRJFm/RcwjVMrqPR/MOdGKA0ce2GwPVD6L23sFYrvChGdw6ZO7yLVpsbc9mUMd0hxA7t3LcqokM= Received: from SJ0PR05CA0077.namprd05.prod.outlook.com (2603:10b6:a03:332::22) by DS7PR10MB7249.namprd10.prod.outlook.com (2603:10b6:8:e6::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.223.12; Fri, 17 Jul 2026 18:53:10 +0000 Received: from SJ5PEPF00000209.namprd05.prod.outlook.com (2603:10b6:a03:332:cafe::86) by SJ0PR05CA0077.outlook.office365.com (2603:10b6:a03:332::22) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.245.4 via Frontend Transport; Fri, 17 Jul 2026 18:53:10 +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 SJ5PEPF00000209.mail.protection.outlook.com (10.167.244.42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.245.5 via Frontend Transport; Fri, 17 Jul 2026 18:53:09 +0000 Received: from DFLE209.ent.ti.com (10.64.6.67) 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; Fri, 17 Jul 2026 13:52:55 -0500 Received: from DFLE210.ent.ti.com (10.64.6.68) by DFLE209.ent.ti.com (10.64.6.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Fri, 17 Jul 2026 13:52:55 -0500 Received: from lelvem-mr05.itg.ti.com (10.180.75.9) by DFLE210.ent.ti.com (10.64.6.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Fri, 17 Jul 2026 13:52:55 -0500 Received: from santhoshkumark.dhcp.ti.com (santhoshkumark.dhcp.ti.com [10.24.52.55]) by lelvem-mr05.itg.ti.com (8.18.1/8.18.1) with ESMTP id 66HIpU52240969; Fri, 17 Jul 2026 13:52:51 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , Subject: [PATCH v5 16/17] mtd: spi-nor: extract read op template construction into helper Date: Sat, 18 Jul 2026 00:21:15 +0530 Message-ID: <20260717185116.2065505-17-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260717185116.2065505-1-s-k6@ti.com> References: <20260717185116.2065505-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: SJ5PEPF00000209:EE_|DS7PR10MB7249:EE_ X-MS-Office365-Filtering-Correlation-Id: 7b98fd82-11e0-4ebf-d456-08dee434a525 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|82310400026|23010399003|36860700016|1800799024|921020|10067099003|18002099003|22082099003|56012099006|3023799007; X-Microsoft-Antispam-Message-Info: 3rt+pcjzlA1Hokrly4WJa5SjTFNzNhhO32b+rAJLlGBGodEPGDmaJi+n0cSQpkw/LRgvR11wsKsWhdmIL2RznZRuVvMRreWk9AKCzFK6+fmrk3Ks5eFLXLyeJNe7d4EfzTSy3A8HMd3yevVkibMGOPIqlsCnVay53QpMlWzcAkUxr//v4OJ16GG4P/Pf98IhzTJpEWgMPNY8eIx1aFCO9oOf1goqiHJ8aw1vHDk6sC5a7nfpwICf0ADft/umJiW60BlApD71OGWrhcZ91Rgk/5bNST006sBki9OJF6TJFQFY6ny03E2ShhZEAr1bNmO71Q8Q24UTwOBjMLJvRAUVIAjF8NKwRzH9l+zH4+YyqR6oF41R+nFdeSP0p1ICaMv/HQJXvgoI7Uyc6U8FhrKqyeXqpWzT9jUWtLjYL7K5AhiiH/adNQBIqkrIh5OPXXb3Wk+oN4ys+ZYPToMdQRlTQ/pRMDwxfK3VHf8DFYhmOLaQJblSVOcy0eVkqELpyhperDeU2MZS8e1TJFffElxyYBxan/S2A+iupKIIvvP4IvtyaBDLiLL6+sAS3mSXeVWMdGsSQfGP+U96wRBH+eaAU5e1eEPvWepgAtygC4wrZx7u/lo1x7Q8alVjeoJn+Q76stWLsnvU4tkre5X3bkUey+02c2PcPSEYQzWF7OsxpxRNWnAMKARDV3a3kzNI669WhNxKD4tbSBuOA77CTJVXvGF+klUrtZJGxv0TFKZlFdif+rjDwzsuZF5oZJXUEqiW 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)(82310400026)(23010399003)(36860700016)(1800799024)(921020)(10067099003)(18002099003)(22082099003)(56012099006)(3023799007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: WLUxVf4A8Xlqjj6dd4HAHNfhAWSZTuQnbfXzKiSXmsKCJ5r+qp8hKJCBQq2n/hxVwZxhTvTxtQxgAjygUQxasF8WQd/vqYYrFBUlpqaaxbFy7FDCK+39fBCE4ggL7b1n/oa7NYPzIZxDhPjP5SkMsBBU266u40RcglV4kaGg+kgk1UoV6FeKo9+Zd7wOzvCleFf4rT4BoZEb7vlbv9zQVj97TApMpu4irDUjjbFEnRtHbMivamEDIXXVG/UhPpdTwv+Pc4/b1T7vlAdUsauk98e5WVZ+8lalfXISNxrua0qg37gc5brccOZDHQ7GuKVjhXAQQBvbcdCopbAjdjBa2wJaHqhS+grl6+WH7UgFkwzRoPspUcNR5jsX6Yqx8czerKoR1r/Kv1n7M7p8aj1aczCetyBujx0WQ+IXGsrccRuR9MMIlhUdLp7+TB6Q1GI1 X-Exchange-RoutingPolicyChecked: JQIIH7ZstJ8UcrvFeXoe27H7TFX6LszXpjfC6OzOkS/glf7anos8owBw0VBEeticxWwWZv46wlCJimHBu0f8A2Ydv0RJ5MVSx47bIOGJczVCgxxjHWAfOa83hsdLJVEeWwsTKMC9hnWmgr6WxDSD4RbmvKVs75B1tZkJ5BGpq9oqqjRJ4kZk3F0DVlDrITcyzcrNk/A3lXl89M37SiVZ+p9RtYj4TuyeReoPhfVD+/BmazAux0b1T4J1itDoUANAYJQcuj0v8kqpq2aaFdQhMlJ+BNfmsrintp+D3+rVGJEKtNGtIUd2ev4in7IWpFoXTkvTk+JeJeuwkBbN4A585w== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jul 2026 18:53:09.2039 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7b98fd82-11e0-4ebf-d456-08dee434a525 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: SJ5PEPF00000209.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB7249 X-Proofpoint-GUID: iNMrb2X4ldVj60xSeAS14zkZ32X-sDXc X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzE3MDE5MiBTYWx0ZWRfX6CWg7p7ABuuS 62Qbxoi2XwbMYm2Czyky4q51YrMPfSgH8fVVqZkklaFr6vDL6MgCnVHYZriXQZHeLAqYju+0748 0CxRtrUiMwmTNaNrCJOPJ80kB8q2SUWmZgxBWkifOPtW0JeCT7hWqKMedM1g0F5tQd15qHO4Iz9 gBz5gLHgr4QEWPe0+DWHsFtKtE7TcRscQ8pUCk8/XuDUyKkWBWEeuVv5fxH6gyDdMg4QiQm+Oqg AtzJiUdQ6CoaKx03t+k3d55kpQOxtfBy/BrfeJnauiKS5RpjOM+KV8ab3bLolZKAKw2t5nZDKXf uMvxrqLNFgF/Q8yC3jcQUnyKWgDsCcZpQIjBic71Pw788n9MqZy2x3EFB/up17zg684j9Ld73ka qrYbF6noCkxJZrmyRPi7oY4MY/dwuAoGPXx3xOhJu01RnegQFcjMJbTIe8Ho2edYI191/nrtj+X CjGhHVinAy8x7WkQK+Q== X-Authority-Analysis: v=2.4 cv=GJ841ONK c=1 sm=1 tr=0 ts=6a5a7a1d cx=c_pps a=diJABEK3oI6sFh9r2i/CNg==:117 a=tJyPKKxUohctrY4NYmUjkA==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=RAioF0-LDSMA: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-ORIG-GUID: iNMrb2X4ldVj60xSeAS14zkZ32X-sDXc X-Proofpoint-Spam-Info: AW1haW4tMjYwNzE3MDE5MiBTYWx0ZWRfX95CglwnpocTE Sbs3JlbI7NZbHsHy0fAPT6HLwPZPBoBkZWaAAX4OUxS48W75QHOqb5RNRxGOb/SwzhYznLt1YX8 KvBfAgVcjNLhLQxD/+2KIaXGxo7D5IM= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-17_05,2026-07-17_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 clxscore=1015 impostorscore=0 malwarescore=0 lowpriorityscore=0 priorityscore=1501 suspectscore=0 phishscore=0 spamscore=0 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607170192 Content-Type: text/plain; charset="utf-8" From: Pratyush Yadav Extract spi_nor_spimem_get_read_op() from the duplicated op-template construction in spi_nor_spimem_read_data() and spi_nor_create_read_dirmap(). Using data.nbytes =3D 2 as a non-zero placeholder lets spi_nor_spimem_setup_op() configure the data buswidth without a separate override; callers replace data.nbytes with the actual transfer length before use. No functional change. Signed-off-by: Pratyush Yadav Signed-off-by: Santhosh Kumar K --- drivers/mtd/spi-nor/core.c | 66 +++++++++++++++++++++----------------- 1 file changed, 36 insertions(+), 30 deletions(-) diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c index ccf4396cdcd0..b683c077a233 100644 --- a/drivers/mtd/spi-nor/core.c +++ b/drivers/mtd/spi-nor/core.c @@ -188,6 +188,37 @@ static int spi_nor_controller_ops_erase(struct spi_nor= *nor, loff_t offs) return nor->controller_ops->erase(nor, offs); } =20 +/** + * spi_nor_spimem_get_read_op() - build a configured read op template + * @nor: the spi-nor device + * + * Returns a spi_mem_op with the command, address format, dummy cycles, + * and data buswidth configured for @nor. For direct reads, the caller + * must fill in addr.val, data.nbytes, and data.buf.in before use. + */ +static struct spi_mem_op spi_nor_spimem_get_read_op(struct spi_nor *nor) +{ + /* + * data.nbytes must be non-zero so spi_nor_spimem_setup_op() + * configures the data buswidth; callers replace it with the + * actual transfer length. + */ + struct spi_mem_op op =3D + SPI_MEM_OP(SPI_MEM_OP_CMD(nor->read_opcode, 0), + SPI_MEM_OP_ADDR(nor->addr_nbytes, 0, 0), + SPI_MEM_OP_DUMMY(nor->read_dummy, 0), + SPI_MEM_OP_DATA_IN(2, NULL, 0)); + + spi_nor_spimem_setup_op(nor, &op, nor->read_proto); + + /* convert the dummy cycles to the number of bytes */ + op.dummy.nbytes =3D (nor->read_dummy * op.dummy.buswidth) / 8; + if (spi_nor_protocol_is_dtr(nor->read_proto)) + op.dummy.nbytes *=3D 2; + + return op; +} + /** * spi_nor_spimem_read_data() - read data from flash's memory region via * spi-mem @@ -201,21 +232,14 @@ static int spi_nor_controller_ops_erase(struct spi_no= r *nor, loff_t offs) static ssize_t spi_nor_spimem_read_data(struct spi_nor *nor, loff_t from, size_t len, u8 *buf) { - struct spi_mem_op op =3D - SPI_MEM_OP(SPI_MEM_OP_CMD(nor->read_opcode, 0), - SPI_MEM_OP_ADDR(nor->addr_nbytes, from, 0), - SPI_MEM_OP_DUMMY(nor->read_dummy, 0), - SPI_MEM_OP_DATA_IN(len, buf, 0)); + struct spi_mem_op op =3D spi_nor_spimem_get_read_op(nor); bool usebouncebuf; ssize_t nbytes; int error; =20 - spi_nor_spimem_setup_op(nor, &op, nor->read_proto); - - /* convert the dummy cycles to the number of bytes */ - op.dummy.nbytes =3D (nor->read_dummy * op.dummy.buswidth) / 8; - if (spi_nor_protocol_is_dtr(nor->read_proto)) - op.dummy.nbytes *=3D 2; + op.addr.val =3D from; + op.data.nbytes =3D len; + op.data.buf.in =3D buf; =20 usebouncebuf =3D spi_nor_spimem_bounce(nor, &op); =20 @@ -3712,28 +3736,10 @@ static int spi_nor_create_read_dirmap(struct spi_no= r *nor) { struct spi_mem_dirmap_info info =3D { .op_tmpl =3D &info.primary_op_tmpl, - .primary_op_tmpl =3D SPI_MEM_OP(SPI_MEM_OP_CMD(nor->read_opcode, 0), - SPI_MEM_OP_ADDR(nor->addr_nbytes, 0, 0), - SPI_MEM_OP_DUMMY(nor->read_dummy, 0), - SPI_MEM_OP_DATA_IN(0, NULL, 0)), + .primary_op_tmpl =3D spi_nor_spimem_get_read_op(nor), .offset =3D 0, .length =3D nor->params->size, }; - struct spi_mem_op *op =3D info.op_tmpl; - - spi_nor_spimem_setup_op(nor, op, nor->read_proto); - - /* convert the dummy cycles to the number of bytes */ - op->dummy.nbytes =3D (nor->read_dummy * op->dummy.buswidth) / 8; - if (spi_nor_protocol_is_dtr(nor->read_proto)) - op->dummy.nbytes *=3D 2; - - /* - * Since spi_nor_spimem_setup_op() only sets buswidth when the number - * of data bytes is non-zero, the data buswidth won't be set here. So, - * do it explicitly. - */ - op->data.buswidth =3D spi_nor_get_protocol_data_nbits(nor->read_proto); =20 nor->dirmap.rdesc =3D devm_spi_mem_dirmap_create(nor->dev, nor->spimem, &info); --=20 2.34.1 From nobody Sat Jul 25 04:54:27 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 DD6A839B94C; Fri, 17 Jul 2026 18:53:14 +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=1784314396; cv=fail; b=qyXHKf76rBB1R4XAJEc+CYakwL+SFoWuOz6MSWzO0GPS0ybMGTyTjP5yCSffCYnbHUxiVtEanmUEZv5U41OzJkn2tRcMCSfqfS0Eq7bdGs50OdEoIbZb+Jl0tf4fSwSIwdV+dto+CBYycxdk3D5HFJiDZxH749xCUwiATuqPi7o= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784314396; c=relaxed/simple; bh=QCZfApz0WI4MJamsj+4VqpsLIBBqXuUtwo6CKXU3FV4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MS0SS8DEFQFtMIRf3aBVgobZk3cTe4VcQ/EULjQn0BTqLlUJw8uljFvaIy+hntWwOsIN+kQG2qqzyTP7VdDOdcq+UpK4I89ilHYXHu8LBjp5XxFizKRZbOmjrIPgxogE21lU9xvzVMGrZXn6i+qgrUdW6crrvQUxqj8duIBXsHc= 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=EhTsaIu5; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=AxNtIQyb; 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="EhTsaIu5"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="AxNtIQyb" 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 66HIlrKL1570556; Fri, 17 Jul 2026 13:53:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint-05-2026; bh=CaKka2TXrNmZxg/2rKa+E19ixmWvfwzQpJ0sWclJR yk=; b=EhTsaIu5f8daQ0SmY0JGuP65Vk078swajK84UZh3zVTCj7rM6PKLju+1m tdcQLgnEGfE+KLYioJXhO6g5mqva/uoNHJAuHUO9e0JLo1qqKqvBBl6bwUz+of2V P/nT6JtMCZ6mUYP8WpXzJy361qimek3IaplL9iQ3aDMyhcfkbeN2G3w/Nx173iaI aaUpNRQVBYRmU8+fqcfXVKuUuAR8GJk1WzSjPHh5LUoGq4qO9bPa7k/1SWWnc0XQ RnZQxzIVbUZHkp2aZQrlUiVGSWA7LFBNwsrxJGeWsZLyB3TKReIY11K9IPQ65E3R F7MxNk0Thb1s/hI0j0r1e+o7FoN1w== Received: from ch5pr02cu005.outbound.protection.outlook.com (mail-northcentralusazon11012017.outbound.protection.outlook.com [40.107.200.17]) by m0384305.ppops.net (PPS) with ESMTPS id 4ffgsmbgwj-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 17 Jul 2026 13:53:05 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=rywdftgb/andqpf2euHevZN64Iaa/IHpPB4uqfET/eNw/GLCmtS00Ir7gDwKBmI1tNfyrwZ9Ni4E4A6wFdr/kE2wywGmi3UEBzubp/sNDetWFaENJPIM7+lw7nEe+FrVV1AnqnK9+b00a5bvQOmD+qzvwbFM24Lvk4d80veyCTQ1vPZWUkezKwqeJYRj5fYjeTwtd+qk8OL1QYleXTUaEqEigkYHev+fMN0nhmqDgSeWyjBya6cFcCmpVezSVq0EPt7dSRtst/bnJkJ495bD8MDP7MZZf+3xANujalMNCT1q4H5lXO4O78KZ3LE/nwOgKs/P3mIm7SvqiPSWKa0bBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=CaKka2TXrNmZxg/2rKa+E19ixmWvfwzQpJ0sWclJRyk=; b=BfIX888qjW3jlxlc736RI+wCDniESYBznAx+Z8TWli4RYH1lQJMzi4tQbfC4P/Hih/u59Gi3DfpeQdjVCm/DKWjn1xd0kjcV4vCNdLg9yoiCiu3ZtH8k6+iunkFy3IOliEFINkjNM2DCUjSFofcxjIXbgmLp6bixRND8PEx7HW+uVRdSIvDg4y382yE5tRLTXXAF+IpNdPu1N46FIubvsiZAo8PMtuE/hfOQ7PD10bIkV/GYx2zghTW28ujaGIs7Rs4s+MNtUghN2p6MJeo9Y/TDe8lqq/1qwgTyf7MDTpCBctnI7Tx+UGdu0FAeefq9BSGc8T2ev0VNXzs2QEyS/g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 198.47.23.195) smtp.rcpttodomain=lists.infradead.org smtp.mailfrom=ti.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=CaKka2TXrNmZxg/2rKa+E19ixmWvfwzQpJ0sWclJRyk=; b=AxNtIQybMfnwtfUDk5U9ztEQFD/mdSSMsUxgCuFxJgZMr73J8ksbxPmv5jVNWlnzAbdzKPxy8achxMwYp8uEQV83I6Mp/zCzfo/eMjYNoIZX34rvtGvz2t+ERHwWVphAVkYGIvhYYyJjUL3YPCkTkfRPdX4IjbOsNgE8GWmcuAw= Received: from BN0PR08CA0018.namprd08.prod.outlook.com (2603:10b6:408:142::29) by CO1PR10MB4547.namprd10.prod.outlook.com (2603:10b6:303:96::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.223.13; Fri, 17 Jul 2026 18:53:01 +0000 Received: from BN1PEPF00004688.namprd05.prod.outlook.com (2603:10b6:408:142:cafe::72) by BN0PR08CA0018.outlook.office365.com (2603:10b6:408:142::29) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.223.12 via Frontend Transport; Fri, 17 Jul 2026 18:53:01 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 198.47.23.195) smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ti.com; Received-SPF: Pass (protection.outlook.com: domain of ti.com designates 198.47.23.195 as permitted sender) receiver=protection.outlook.com; client-ip=198.47.23.195; helo=lewvzet201.ext.ti.com; pr=C Received: from lewvzet201.ext.ti.com (198.47.23.195) by BN1PEPF00004688.mail.protection.outlook.com (10.167.243.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.245.5 via Frontend Transport; Fri, 17 Jul 2026 18:53:01 +0000 Received: from DLEE205.ent.ti.com (157.170.170.85) by lewvzet201.ext.ti.com (10.4.14.104) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Fri, 17 Jul 2026 13:53:00 -0500 Received: from DLEE215.ent.ti.com (157.170.170.118) 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; Fri, 17 Jul 2026 13:53:00 -0500 Received: from lelvem-mr05.itg.ti.com (10.180.75.9) 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; Fri, 17 Jul 2026 13:53:00 -0500 Received: from santhoshkumark.dhcp.ti.com (santhoshkumark.dhcp.ti.com [10.24.52.55]) by lelvem-mr05.itg.ti.com (8.18.1/8.18.1) with ESMTP id 66HIpU53240969; Fri, 17 Jul 2026 13:52:56 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , Subject: [PATCH v5 17/17] mtd: spi-nor: run controller optimization before dirmap creation Date: Sat, 18 Jul 2026 00:21:16 +0530 Message-ID: <20260717185116.2065505-18-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260717185116.2065505-1-s-k6@ti.com> References: <20260717185116.2065505-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: BN1PEPF00004688:EE_|CO1PR10MB4547:EE_ X-MS-Office365-Filtering-Correlation-Id: 9c291d47-a707-40be-4c36-08dee434a06e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|23010399003|82310400026|1800799024|36860700016|18002099003|3023799007|22082099003|10067099003|56012099006|921020|6133799003; X-Microsoft-Antispam-Message-Info: NWsi9jdtI/YfG5zKf2+YY4HtU7jHlwsspFfBckKDY+ERaAhQmOZ8CTNJsPKr88Q2mbBKaSQZdLdnVNw+ITGPhONK++ho0ObKn2cBLfb//GmvV0WBY9eyG7gve6K0F4zwU1pwk65vLoO1Vu3tKh6+QhQCMFb0/q396zRliCdUTFL0h2C92N2jZKVPdDv8Z2dPt+G+Nj+N9XmKaBRY+NsauyrYwQOYgoKdc5ZyyOg1WhGyq4/y1FrtH8ONqZtvSNaEnrl2XSZNFEgvMnke8s5GAnLZ7AsUDLWCanTy4tFI8TXc41BqfySAGstSrNHbUCLajAUiFRDK9q2dmCQ7wD0YBgvWC1HvMXxIobr4xj4ru6z5T5ZJ5ZnvTXkueGB9RqP2cCZtB9aemOBzvBdROON47nqmDg5U3Ue9MOZr0xU9dn8J1me0Wg+rnokKCUIV59oVOrxXUp/afMeUatfxStRQVic2LQL0kQuSDKpWvK6jL9UbjjveCZjB4dGcoU12e4K0CpyO63PvPvEuvk0AF3//nj/Nj9ObJ9IreY4oC6cecuD+U00aMNB5nPEK1Cw8Rb/4mJ7iA+38NTG8hlC4Qq74fKXGu3QL8X0q4Ps5KMZ+/QUGnFdl1MSfxtpnIJYHCIG3s7AEIV2CcjrENXdC+BOvAVNKlOGUwd2R9d1Jy8POwa5qhXOfySYmPf47CPXdVnQVs+zHpJCtsl2Qgg7tC0O5mFbbfs5vX31wks6+uaJIbYuT+cYPf2iUu9wXLrhiLCgE X-Forefront-Antispam-Report: CIP:198.47.23.195;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:lewvzet201.ext.ti.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(7416014)(23010399003)(82310400026)(1800799024)(36860700016)(18002099003)(3023799007)(22082099003)(10067099003)(56012099006)(921020)(6133799003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: FklX9CBc2DWexH/Eui4jCdOoJ0KmfGc5JbDtmkJfK8YxNvHuAaTYEwLUTkn7UeAKMKbpkg/uxgo8d4VbmipLQZFgircTAHWlFDB7gVx/UbOQtQDCN67LH9FU01YXsTobp1bhOTXz+jPVFw46gEDszvheYaMSk66awDiQFBnpWmD7qALNasEkso9w56oQEv9nm/7DO0Kng5g9chHMNGH+fPjcW23OYSumNf/UOB9GUCuYTsc4SGYvu6TVIebiaQ0OY2kbrDVD67ZWOGFw8ctQuoZB8PDHmVx6DtVgIaywB6fGl+ic7mh7F4qQk6wZAtF0mXK+7xF7+0qOwE0wqEoqku4Os9ZnGQmlFxQP1xU/i6/no7tlqT/TDwfnZcJEfX9jlJb7pkrN12UwYgFrSfIqZwpE3oIvDfBu3Q6v+O1joT85Mj/bvocPQYgPuJaU1v5n X-Exchange-RoutingPolicyChecked: U/lWUQ8qVGO5+je1tKQbj28wx6DXHk/k9UnEbF5TY8/IeppvRGUDhsGEQ7fQtjBUkLkKxYsiJgR4F0aBfzQouGwFKbdH4q9inKAtiY/qyd0DbOqLKNcNFXjMjQH3isQiiYmnDlSQOpVb1cQFhfkjX5zwy8ihkoMqypbAu3U4eeDYimBt9+xd5fU30zHY8LD6nJomB6hmP7X/Gnbb9IuJcBFtXEg0GH2bI1cbqM3PsLbwyvCvB4jMLLXNpiEtNr7MII49BB0aERpwh8/zqiJtJgZ0FXwtgiB5nBKpffISwnHgfPZlzdS7OoAW0kphePmjB11v4bPi16e6bL5E938YSA== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jul 2026 18:53:01.3066 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9c291d47-a707-40be-4c36-08dee434a06e 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: BN1PEPF00004688.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR10MB4547 X-Proofpoint-GUID: 1Rh2_T_m39VeQf7atppSnFQfcnhBLQgf X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzE3MDE5MiBTYWx0ZWRfX4VXONPxKMCE4 UXkHQhVj/JrAVL90h2sHN1mclAfBVcmuRevjcc5J2TIkyBHJYmitenTDHM+gfKdtgOZR4V+UBwT 8VA8fDepK0bW0s5/PTzBO9BO7zf0kex5g+l2C0V57YkVe5AcYtDqWIfMKT4B97n71TfAeQWCSzG gRm7P2sZGaArwiqoKd86ssU0At+jHvyW9lzl6otxvj0z+VJR/huSL0BNhVVtDf3c4ZfSncqe0hQ T0H3xyAv8N/Xb/aw1Dce+u8JwhXzRDdqvc2+5QZqz1EaLkHh7SHKCDBnnKB8EeWYKFEid1ubiJ5 Y3nHYPqIxuc26rjTbytov/bjIfe5Sf4SPUNXFiuplwXeLXYIBe0nXZGHIRi/yYEyvJXK78E7BkJ Sq+uefxCIcOQqGCPiM7F3SMJSbQiY7x0yGSLUw7xz17OubkSE75WBramXpwrdVDFz5vgyvQqNnQ PeRi2/x67SZOIjdGeIg== X-Authority-Analysis: v=2.4 cv=GJ841ONK c=1 sm=1 tr=0 ts=6a5a7a11 cx=c_pps a=Pcpo/nSjxNMkuCW/QO6CAA==:117 a=f+v6EHfkeJbVwR46tk4DMg==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=RAioF0-LDSMA:10 a=s63m1ICgrNkA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=taLDd7a_hP9WKsMzeGRc:22 a=sozttTNsAAAA:8 a=dAWDYLcBFR4q-bF-ZFAA:9 X-Proofpoint-ORIG-GUID: 1Rh2_T_m39VeQf7atppSnFQfcnhBLQgf X-Proofpoint-Spam-Info: AW1haW4tMjYwNzE3MDE5MiBTYWx0ZWRfX+B/GnoF6oUB2 4tocqRRRDRloVO2ly9QDAyW+AfkEjkAcv79N5ZZTdqEcsqK2lS6cvMEeMmwmpEQv2WCOuBjQkmI ngcg2XU7M70iVe+QAVfCOclr/XkCB4I= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-17_05,2026-07-17_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 clxscore=1015 impostorscore=0 malwarescore=0 lowpriorityscore=0 priorityscore=1501 suspectscore=0 phishscore=0 spamscore=0 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607170192 Content-Type: text/plain; charset="utf-8" Run controller optimization in spi_nor_probe() before creating dirmaps so the validated frequency is available at dirmap construction time. Store the configured read op template in nor->max_read_op and pass it to spi_mem_execute_tuning(). On success the controller sets max_read_op.max_freq to the calibrated rate. spi_nor_spimem_get_read_op() propagates nor->max_read_op.max_freq into every op it returns, so the validated frequency flows automatically into the dirmap template and into regular read ops. Optimization failure is non-fatal; the device operates at the conservative base rate. Signed-off-by: Santhosh Kumar K --- drivers/mtd/spi-nor/core.c | 14 ++++++++++++++ include/linux/mtd/spi-nor.h | 3 +++ 2 files changed, 17 insertions(+) diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c index b683c077a233..2efcdc7f637f 100644 --- a/drivers/mtd/spi-nor/core.c +++ b/drivers/mtd/spi-nor/core.c @@ -216,6 +216,9 @@ static struct spi_mem_op spi_nor_spimem_get_read_op(str= uct spi_nor *nor) if (spi_nor_protocol_is_dtr(nor->read_proto)) op.dummy.nbytes *=3D 2; =20 + /* Propagate the validated frequency; zero before tuning. */ + op.max_freq =3D nor->max_read_op.max_freq; + return op; } =20 @@ -3843,6 +3846,17 @@ static int spi_nor_probe(struct spi_mem *spimem) return -ENOMEM; } =20 + /* + * Populate the persistent template and run PHY tuning before dirmap + * creation so the validated frequency feeds into the dirmap op. + * Tuning failure is non-fatal; the device operates at base speed. + */ + nor->max_read_op =3D spi_nor_spimem_get_read_op(nor); + + ret =3D spi_mem_execute_tuning(spimem, &nor->max_read_op, NULL); + if (ret && ret !=3D -EOPNOTSUPP) + dev_dbg(dev, "Controller optimization failed: %d\n", ret); + ret =3D spi_nor_create_read_dirmap(nor); if (ret) return ret; diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h index 4b92494827b1..ab498a50f15f 100644 --- a/include/linux/mtd/spi-nor.h +++ b/include/linux/mtd/spi-nor.h @@ -422,6 +422,9 @@ struct spi_nor { struct spi_mem_dirmap_desc *wdesc; } dirmap; =20 + /* Persistent op template updated by execute_tuning with validated speed.= */ + struct spi_mem_op max_read_op; + void *priv; }; =20 --=20 2.34.1