From nobody Mon Sep 28 13:17:36 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 459D644C64E; Fri, 21 Aug 2026 11:49: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=1787312984; cv=fail; b=LcgfFyzLkqxqbfRIMZOxoCFRpo4rOjUwHCuurnG5A0xG40R6suDXT06IgxfxhLcD/DU+neYKL7O+t9dASAML0r39/snavZDCptIcIVLuiCfRQ+TLoCVnHZOIfLVch15XCiRabXjacXIAekE8pRRXn033SpeoEFLpW3yGAcaTHx0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787312984; c=relaxed/simple; bh=NpoT/cBBl4rAzM2NVlulrn3aPKLC+iksPz2nkPNIsok=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=IY4CwI9kjD0uBBfF2Y7QMWRD5eUDiMgNFyWyFEt4wBXMDxfxXlQXGEp1eCGauGNM1unjoDT2esBaYp0+aIxPULM8ugyd54qG7op5s1ThPmpzxdubphSyHKzdFS6YFzNww7WyNMPvzAq+iNfQbHe9zlU7WxcTiOl3kEnl8vqBolg= 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=AuMF4Ijt; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=kOiQC+Mm; 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="AuMF4Ijt"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="kOiQC+Mm" 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 67L9KNI03254941; Fri, 21 Aug 2026 06:49: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=+pWYfJ1EP748IQC6CtiOQMdvqHr9KlmObkQrKfpTY Hk=; b=AuMF4Ijt8dXz2EjyqoMTeCUaetHpGNMgZ1AGps2Y/hByumUtm2XY2VgIK Q6Rrcd7hLylFQNIbnw3WkKcAeGId6Wpm7RT81Ad2Rp3vZ6DnUPOro9mEN02g9lVM pKpXvEi7tqQwhSUL3pvmuI7N1ZCwT+pWcTK+2ICv/ZvkbU5I5ioQc8S/bCDHmhGQ 7gO8Ov/LBb1L3eTRWuOHenPgFWi72f5fKSMk1vXcFxQ7tNcSvLF9zhTQ484fuRvL lLDjPTIRvo/AQSlkPMjeh08Q+UQpzQ7auMJLltJjIENJrMoZ0R1AnySG7ddXWl44 P6U67G8mD4JQFnvaIDXrxjp3ixbEw== Received: from bl0pr03cu003.outbound.protection.outlook.com (mail-eastusazon11012035.outbound.protection.outlook.com [52.101.53.35]) by m0380145.ppops.net (PPS) with ESMTPS id 4g6hfk1de9-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 21 Aug 2026 06:49:25 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=hwJDA1f1mZ27Iro3/GPzbKDkvB+ZpTZpE6WZ6bYdFaML8aSWxmtg+Hke+LfiAUqPhlbd7XGxN+X4sZJupNS+evH+kkxDRBa4I7ompx3HbQFZf7OM/689dDE/Cn6j93H4PfLTd41oyzTFD2bOwN3NjHsOVbYlesbEdvfdE7DtwuwLNkKCAcQ4uBx1rNp2X6aJ70whcrAvcIpayceVpe3mCvxUoMy8Mfl4II2BWLxWdnZRCwOTdalMJCoyfPN+i6eVEIUdN2iJvt60atGpa5R+tJEYeZwNke8Vg8j2H203DMCeucQn9QIUYrY1lJjgvfeZmJBsACuY9JmmGqgkWmWwGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=+pWYfJ1EP748IQC6CtiOQMdvqHr9KlmObkQrKfpTYHk=; b=oXbF+570L8OVMUu5zT5Kts+ILkWXEcbmstfsXLcZD3zupEnM1Ki1ziOIMKWvTD6qlqfonL5yEGaBUHwG+4lf6Ut41XkdRoeXdB91dum1TrdTE3pQjnIwvsadYA1LbFfyACcBphKYXPMApCnNDXLGaSd/CkSbUVT8wLlED2hDWAsRKjN57gWY16Kk3yYsO9Q/atyt/abh8gv0vfVSblabFFSEhlrgv9eH2rDWmu1pejoEVEKPYvDKoq/0sGa4heNYXK5m7ZeABcXZH/krQDFvANL1v4vVo9ExhzcNNSHcpNd7U7qshwlpO+iAS1ojliOfoNKQRmi2po1gguPU8sKtDA== 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=+pWYfJ1EP748IQC6CtiOQMdvqHr9KlmObkQrKfpTYHk=; b=kOiQC+Mmxfra0O2LCjzltCntY2HA4g9Fc7I2g3cMlItZKUKhHPrDq6DgimgZHMMW0+tpixThMWE7vf4mi1Uv00sGSQJT8GfxGp8j7gvNrIM0dcJeNzs+jDewsUvz9zpXvpxCh0hrSbFk3irHDCS8QOXysREEW438A2tWzo/sDA4= Received: from BN9P222CA0029.NAMP222.PROD.OUTLOOK.COM (2603:10b6:408:10c::34) by PH7PR10MB7783.namprd10.prod.outlook.com (2603:10b6:510:2ff::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.339.8; Fri, 21 Aug 2026 11:49:19 +0000 Received: from LV8PEPF0000005D.namprd02.prod.outlook.com (2603:10b6:408:10c:cafe::7b) by BN9P222CA0029.outlook.office365.com (2603:10b6:408:10c::34) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.339.10 via Frontend Transport; Fri, 21 Aug 2026 11:49: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 LV8PEPF0000005D.mail.protection.outlook.com (10.167.245.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.360.3 via Frontend Transport; Fri, 21 Aug 2026 11:49:17 +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.45; Fri, 21 Aug 2026 06:48:42 -0500 Received: from DFLE203.ent.ti.com (10.64.6.61) 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.45; Fri, 21 Aug 2026 06:48:42 -0500 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) by DFLE203.ent.ti.com (10.64.6.61) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45 via Frontend Transport; Fri, 21 Aug 2026 06:48:42 -0500 Received: from santhoshkumark.dhcp.ti.com (santhoshkumark.dhcp.ti.com [10.24.52.55]) by lelvem-mr06.itg.ti.com (8.18.1/8.18.1) with ESMTP id 67LBmVlc2022942; Fri, 21 Aug 2026 06:48:37 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , , , Conor Dooley Subject: [PATCH v8 01/18] spi: dt-bindings: add spi-max-post-config-frequency-hz property Date: Fri, 21 Aug 2026 17:18:05 +0530 Message-ID: <20260821114822.4040338-2-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260821114822.4040338-1-s-k6@ti.com> References: <20260821114822.4040338-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-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV8PEPF0000005D:EE_|PH7PR10MB7783:EE_ X-MS-Office365-Filtering-Correlation-Id: 683c801c-0bc1-4125-89ca-08deff7a3b16 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|23010399003|36860700016|7416014|82310400026|376014|56012099006|10067099003|6133799003|18002099003|22082099003|921020; X-Microsoft-Antispam-Message-Info: 68QfZyQQkVBI7/XLY2b/6xjmLDOyAjtiYKoOMZLZHMe7BRfSJfh98Bk/l3heLaIaheThGXYDDefuIliHzCd6++TU7rKgLAm3O+q9Bfm7bf2GHuowOiZWfP1eQ8gmN4AdYNZ7Bq0zr0TquEM/ZEs/MT1h/PmVc9YNSU0OZ9UQofz1f6TpIy/fnl6EZaE+D4Ew2guyHcOdlGrjc9GmtNctC7FwXKdgHZx+XL9hmaZoo+7NTXUMPSCo1Tm7v0g7ep68Im1+FY+rq61P0NJHdiMHPrBlqLULbWl+F+T4GjxWDFenoH2ZoF4lD/cBT9jMm7xAi5SZWIGdAP89NbhJwIMh3RLmlb7eA4avvmS5kKJOGl1+fLIQ5ggA+edIMPt30BlEZe331zAUZQhlpjQghk+wooM1MODE3X3g9/UtZYLGJANwhfvFkx6nApKlm1SZNaHSWxmU8IgWEtCrWZMQzx9nQ++pQbtVhkCFmANjcdS+oUvkUFnig+Q45OLfIJE/7vEY1kBVDfqe6ld5UWeQoCnWUN/JC1eiDKx32y7uZyDqkGnoj9ZsL/6Y22c83i7BOgQqWMsBggnyVn5bvIR+ILpSMldNSasC2w1boZN3afKW4HIAPrY0jSBNgV+pMIxv9IB+fEI69TBx557j1dzeSQzT4efbZmU+EsKXTxqxUuxRGu2AASZmYmJg0++cIR9fpq/bTnyJpzlBBRz6U6VdHDrue9lSsMavtTW0vEUBhjl2L8gv9KrtfN7xmbi3/j+XkbtP X-Forefront-Antispam-Report: CIP:198.47.21.194;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:flwvzet200.ext.ti.com;PTR:ErrorRetry;CAT:NONE;SFS:(13230040)(1800799024)(23010399003)(36860700016)(7416014)(82310400026)(376014)(56012099006)(10067099003)(6133799003)(18002099003)(22082099003)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: j8T9Mlcuhcv++FOfrYHkWpuV3rmlTN68JZOdf+d5KWkklj1y4xkfX/vLd/93h9O2RIQqzBvZWjjTN7azp1LqeASxq8ikX/Jb07CjwguJYcXpVYboyb733GQwtMoV3zOqb66HB3Xt1F9MvDhEwq4Hh4v93bWRvF6KV/J6uB3k776y+2QYSu0DtiMd+a4hxEKLv+reynaKpXd4YTt9AfRtMSd8YyrCltrGK7SpQztitZZGbJeJxv4hUdMrd+J/JNRQ1jP/p260/H/1RsdEK3s7uvoOoKo6drqgEW/IIecL7ROdtXU2Fyh6td0TRfhOhadPnq/mNxt4jnwzbXgqo1dNnp6wvY7T8Sa2eTzWfJnFE1rRiZmjs7PBOD+j2yyIw5Nda9LojTg54hXIk/ZpKKOGLHX5VX8eizAbAIzVIG9ryPqKwLzM3zAcWYhHk+ScIt8T X-Exchange-RoutingPolicyChecked: pg8lpJPUQymh0cH/7l9gz8XyKA5lPiF7oZWKl6wEw9KUPiDnw3L7Q+3YJGRiLKE74YX8sI0YmsH0Ivc3jYggP8Zc5zI5ZxXRcwtn3Z0PeG4DEAUv5q5lVWDrLjGzgjqRvN3dUbPljN79Z6LVap4isR1Nt0ircydyzAMrkECa7ftwYPtPqgpamozqWFZlqgchUVEgdXoSKSxlJnYa7koIEyO/HQCr006OBRybtR8KOiLKifjFaNflSVlIeyU3kCZ6/zHl/EAACAiS9939pIl9fi2J+jE+CXBP+tR3xFZg4jAFu5v8See9QxlexspilZxABOMA0HQI5oyjBWth0vE3qg== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Aug 2026 11:49:17.4499 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 683c801c-0bc1-4125-89ca-08deff7a3b16 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: LV8PEPF0000005D.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR10MB7783 X-Authority-Analysis: v=2.4 cv=O7AJeh9W c=1 sm=1 tr=0 ts=6a883b45 cx=c_pps a=3/9ZW+mBBPtU5+OO10+n1Q==:117 a=iwqwCZQqcuTv3JOpYdM7/Q==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=Sv0fKeRqtYgA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=gO1vWkAQAl3rybz1DQOp:22 a=XYAwZIGsAAAA:8 a=sozttTNsAAAA:8 a=skPbNTvFiSR7kuR3s9sA:9 a=E8ToXWR_bxluHZ7gmE-Z:22 X-Proofpoint-ORIG-GUID: nBIZVHcBYHRwE9J6Tn4MgTiHaCBQDFhi X-Proofpoint-GUID: nBIZVHcBYHRwE9J6Tn4MgTiHaCBQDFhi X-Proofpoint-Spam-Info: AW1haW4tMjYwODIxMDA5MCBTYWx0ZWRfX+Hti4bWH0MEM /fUohhm3garA2R8EI0tvSn2uAWmg6vlEtJ160C4fQox3tsjTTaZO31Qc1UbQZ/9upq+jxdOrxKm 9SIL2bPc4fs6xWSFn6CGwausExwpVfg= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODIxMDA5MCBTYWx0ZWRfXxrESoefxnRHX +i/Z15SIakve7fmdtGYwpd1hrfMWrKLITGUOMeWONJYoWDo3n+yOZXw/ht7aklGmc42W5avn6VS 7LwqG75tf+j8MMAm/PiS7IN1d5EW3CMfYSrOZ9wxcqpFlOU2a9eTWxMyFB/gMQGJewNZqM/hPpR IK/X5cvh/pv14aknHSSVF+sXCXnf3YpvCDRa66zmXVKDrpLAGCCED7bvCwu4BXUP1tFMpE140YE OC75PQ0aTZsHlv1sSHhkprY2w2MSmf/K8gB+wqle1WAU5Ni7SyC0oSgUq53o+TfmapNPxm216zP aDHXkD1oG1B9m9Sc4wbSjAFllV5nA7oItokQPbdgaifDueQ04F58yi02MOietIqhRcbuphiyYsR T1LNCfZBVHtNuzMw9gn+aNlVYY1lcgZbYOait3o8Hk8fqDbJ09X/l0XuZHYWQzDcJLjywwYvHSp LxRij16x++/h59n454Q== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-21_03,2026-08-21_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 bulkscore=0 phishscore=0 adultscore=0 suspectscore=0 lowpriorityscore=0 malwarescore=0 clxscore=1015 impostorscore=0 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608210090 Content-Type: text/plain; charset="utf-8" Add spi-max-post-config-frequency-hz, a generic property for SPI peripherals that operate at two distinct clock rates: a conservative rate always reachable without controller configuration, and a higher rate achievable only after controller-side configuration. When both properties are present, spi-max-frequency gives the conservative pre-configuration rate and spi-max-post-config-frequency-hz gives the higher post-configuration target. Acked-by: Conor Dooley Signed-off-by: Santhosh Kumar K --- .../devicetree/bindings/spi/spi-peripheral-props.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Documentation/devicetree/bindings/spi/spi-peripheral-props.yam= l b/Documentation/devicetree/bindings/spi/spi-peripheral-props.yaml index 880a9f624566..84976fd3ee1b 100644 --- a/Documentation/devicetree/bindings/spi/spi-peripheral-props.yaml +++ b/Documentation/devicetree/bindings/spi/spi-peripheral-props.yaml @@ -45,6 +45,12 @@ properties: description: Maximum SPI clocking speed of the device in Hz. =20 + spi-max-post-config-frequency-hz: + maxItems: 1 + description: + Maximum SPI clock frequency in Hz achievable after controller-side + configuration. + spi-cs-setup-delay-ns: description: Delay in nanoseconds to be introduced by the controller after CS is --=20 2.34.1 From nobody Mon Sep 28 13:17:36 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 8543338E8A0; Fri, 21 Aug 2026 11:49:47 +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=1787312991; cv=fail; b=n9tE58gmDTtyk4z7E1rwozbLgnHrtUrmJjZwfjTXFYRARzCwd19YDYQoolcjgMH/DX+r64LugQJ0/2YxMrU4RcRkmPJBeHz7JZn47oQBVEsuHQSLvb7e3uF16hHl5W49dB7Mromr+EyC1MVjQW6/KvY2xmsbpd1a5mcW4j17u/A= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787312991; c=relaxed/simple; bh=aF/DbrmPXM4j0mLlW+L8B/c0eqWu65juxQfllEXfCQk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ACZr5Zf8HU12gk3ZKejK/9ABYLgzE+zdswdNjmmaahduGxia5gdjNLQknIjvLAHgcKoEABFPR4zOSyoUOoK7cMVoKZmI+0CzjyR5qG1aXtrIlUvTMzdsiwBUSyc8VH0wL8ULPJwpDf8B5L98rmobOoK61lAln+whRbtAItUO6GE= 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=NpXM/xOa; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=ebqrGvc5; 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="NpXM/xOa"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="ebqrGvc5" 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 67L9KKFk3421354; Fri, 21 Aug 2026 06:49:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint-05-2026; bh=CfcZ3asnTmwrkxDLnD+kXTLBg64BDPwemZSrihZFQ lA=; b=NpXM/xOatgHZcR/EAH2rRD5WNco4w0yTSQy2pbQuuZiEsofY7IPsZ4NRh FPoMX2dLT1khZ9V4EX+F2w8D4gujOZI5P0JsDScbupb02n0G0K8jMEU/mWLDgFYy 5CkEcY+tKwesyV3zk8VnWx+onNPhpFryaSnRkZrWljpGZoHqWp4qAy0wM+oHuCCh 08J/jDJMt7zBCNOleosMAlX+Qfn6x5lMWSELiOE0mirRKJI95U9fQppMmc5/EoNj dMzcRVtA7NxuCFklfvwSGrFCvmzazu8/hTmnBQZ3OstbdYvvE+YRw6J2SCh5WIZV dqXIpSjFShBbSidm5DTlnbTZOLY4w== Received: from sn4pr0501cu005.outbound.protection.outlook.com (mail-southcentralusazon11011047.outbound.protection.outlook.com [40.93.194.47]) by mx0b-0002e601.pphosted.com (PPS) with ESMTPS id 4g6knmrmy9-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 21 Aug 2026 06:49:23 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=YRQ/v7AmfTKpyi/e2RFmu0AqbgKzE4X3KP5aEMxHIOAPtHYCwP+LR2gV6lStgQq+qu7sFTSBVlnPpthZ12+SyvA7y6lYdorqL9XjlSi24eM9yZ9T422G01hXSBS20VRnrocvI9+CQl3o8a1O9bYBYgiwfV/W84YvaDS1ZkoQyFSEJIb1IV162NJ5CAua3Q8pVJ9xBQZZRf/sM9+GrRkuExkfrQBqAodEmSfbOt3Yo0fOOxkgSwwkIaG4dOQBVAT/B+zo8UjoB4E8wYIEvAjaR+YWgOWxI/SMbILZTImkM5nBgC3gWi7XFF6g4ic7YWju0KiHrH7d0hHVHNWKTnysSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=CfcZ3asnTmwrkxDLnD+kXTLBg64BDPwemZSrihZFQlA=; b=fSo3dmN+YORdwdw5LBwHRPOt4ht8+IcaB++EFEXiFBT4txY4dX79xz4OQ4/LKzsRO4Cn12lK4u9CnokrEFJkRLmsaV0xJu8cQi/JFIchWI5LPnLCtaqgS8XB0JmvwNOl8SbXRTPRmVJjUCn09kS6TpTqelr0vFNsyMCxMiEASFjnxNvo1h+rqgf532npsoeGWGF++y3ejU3KWmeKRi8h+F6zy3sw6BDLGiJvSJXxU1NzI7pEzeSTRuNWIYUeklvEhgTBPpU9UU4Ha5nAu/JMBtLgvdu09y6+qmNrJ78Wfi6Zj3iAHACcye1jN5FYuq28HqJPgP/5ad6zowsp08WCNg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 198.47.21.194) smtp.rcpttodomain=oss.qualcomm.com smtp.mailfrom=ti.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=CfcZ3asnTmwrkxDLnD+kXTLBg64BDPwemZSrihZFQlA=; b=ebqrGvc5TNEyQtKGPirzjZBSNHTGXe2+Js2BPvqelsF2OIHO1jDPgqd7j6LX2NfSynJvnHBZZQ69/+0AN6iZkk0PSr0XnTMQtEqRcGKvj/rVMKQ+gCOCoN/M85aT/rjg5+IcNDCvI2uTh5dunqhpS+hftIvGtaIyMrJVeVmYKh8= Received: from BN1PR12CA0001.namprd12.prod.outlook.com (2603:10b6:408:e1::6) by SJ5PPF8C7834C85.namprd10.prod.outlook.com (2603:10b6:a0f:fc02::7b6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.339.8; Fri, 21 Aug 2026 11:49:19 +0000 Received: from LV8PEPF0000005A.namprd02.prod.outlook.com (2603:10b6:408:e1:cafe::43) by BN1PR12CA0001.outlook.office365.com (2603:10b6:408:e1::6) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.339.11 via Frontend Transport; Fri, 21 Aug 2026 11:49:19 +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 LV8PEPF0000005A.mail.protection.outlook.com (10.167.245.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.360.3 via Frontend Transport; Fri, 21 Aug 2026 11:49:17 +0000 Received: from DFLE213.ent.ti.com (10.64.6.71) by flwvzet200.ext.ti.com (10.248.192.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Fri, 21 Aug 2026 06:48:48 -0500 Received: from DFLE208.ent.ti.com (10.64.6.66) by DFLE213.ent.ti.com (10.64.6.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Fri, 21 Aug 2026 06:48:47 -0500 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) by DFLE208.ent.ti.com (10.64.6.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45 via Frontend Transport; Fri, 21 Aug 2026 06:48:47 -0500 Received: from santhoshkumark.dhcp.ti.com (santhoshkumark.dhcp.ti.com [10.24.52.55]) by lelvem-mr06.itg.ti.com (8.18.1/8.18.1) with ESMTP id 67LBmVld2022942; Fri, 21 Aug 2026 06:48:42 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , , , Krzysztof Kozlowski Subject: [PATCH v8 02/18] spi: dt-bindings: add spi-phy-pattern-partition property Date: Fri, 21 Aug 2026 17:18:06 +0530 Message-ID: <20260821114822.4040338-3-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260821114822.4040338-1-s-k6@ti.com> References: <20260821114822.4040338-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-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV8PEPF0000005A:EE_|SJ5PPF8C7834C85:EE_ X-MS-Office365-Filtering-Correlation-Id: f99b175b-ee5a-4f90-7428-08deff7a3b43 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|36860700016|7416014|376014|23010399003|921020|22082099003|18002099003|3023799007|56012099006|10067099003; X-Microsoft-Antispam-Message-Info: e4xVSwoBP5OmXduYUxMlJpaTUE2pj8LIb9DuEAlIV46HsaOW//hYN0boVFk2ZzykYqD/rWbGlG2ODk32J79EReMSqWa91KTIEQ7BB1okLXN+f81j9TUwWQjMjdSbGKiHv4FfuyFrUankQ0BHn7pJhnQF6ySwDmnVLgHMF+PA7g1UphIGpVP6CruYE1cYXMD5wxvi0z6gZvC6EFunGA0urHx6n4D3wGtFcOY/F8V5ylI979UNoup8Oa2GCt2UaKsdK3lYc4ylzrRhCa89W69LtNqopw9+J0P0pOmr6JW6VBZ5AWSr6yBSWugB2jHV4YM9ciFC0AezGQjnkdBsUJ9TXtpXP1b93VJ6o4gMpo2nA67N4hc7fj+ZER2Db8NGmY+VqjGgBqcio6R0ijWdIt77wGgvY0yOF+cKFs5K+Ru6jl1uMY+wQH/TzJ1r6gNQq4QGhoSOXZrWzdOkxSxHLxywwEK7sr3SSSGKQaVDv/sO+sh8fCbF9YvIkqDK/7cqlwDcuCea6YBrkXljcjqIOJuF4buscae9WWXmsMvRJ3/6s58usYZrt+Jpd2h5tEX6Kk1L20+kmn6ro6AT8/GatcZwgPsCVJmt6vi3Imme5hZU3SZKty9B7b58LA1Ssj1aMTvtknvoQm/tI5hzFdnd8GdGCn3QChIIxA6s9DNXjz/J4JP5dlKPuzF4vJk+jvuGDjCwKn2vr96b4J6sIXxprLqap/6ryMTTRtqMK6yLCB3UMhAjLR6Lk0mbhDgmsZxBQIAG 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)(82310400026)(36860700016)(7416014)(376014)(23010399003)(921020)(22082099003)(18002099003)(3023799007)(56012099006)(10067099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 8k+rUO6AUgMV0yQLdWykpUlua9PgJU4cenNLXNw01Wc3zYfHVRb3gA2PYHAFxz2CkOF8K9XMO0vb4ZhprU7BIRncMUX1L7gcfycd7FMuOLD1jwbAM6wRqfZ1jpiDaQTBXmpi2ARuqFHdPou1UpXG0RAk+h2JqJ6qXXxv/gSSu+QstgNirjmdXK5vo3O8R67wKjyU5zgTyv6p1oumejOqO4iYnKhIacvLPeCLrVo1wtrezyqsvpcveTKBQeHjjpKlimfM/s7aAsxKi5XcOmUeSys13I6O6M+9z+kzJpT92TIkWDlMOC10crlKKtsSztrkIHCUNA0Ju5zGlqnU9QBCJxFJUxX2Givu6/Dzry9wqUBmIUhzBd7lNCGeJF83D5B/cZDcC9iL8fQm9kzXmTrNoJMxpyX3KE5QNQeKgbnw1oQ2hEr1961ooGkJHh/U8TIm X-Exchange-RoutingPolicyChecked: P+A2NFV0i19y/hEU+FBnvY7ofYCRTHz11lefqDByDiM/9xvQ2s0Q2VKOojMcUgQh49dwh/r5JsUuqgg954SOGmkGxVUWPKiDKchLSSObMsbXXNy6KcVEvwzLrEBHuJqDTLQweY2ZwXzF3309GecnGy5nEC5EkXkkhQWqoOo1LRpF8C+vPXGcc8LNNkJX6DWn0Mlwoo44YPifn5tvHwZn822Fb3onSd/xYbnRzJZNoZUSTDHFuCOFAON5Homg8/YZC0VyYtlR+sLBSpIyxaZS+z7MY2FgXi+dAea4VVNu2qugychOAw9sIwj799g6JaKYoT8LSqUyDls0J3xbT+xohA== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Aug 2026 11:49:17.7339 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f99b175b-ee5a-4f90-7428-08deff7a3b43 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: LV8PEPF0000005A.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ5PPF8C7834C85 X-Proofpoint-GUID: XFpRxZIXfOCKOyekEHDiwUaX5kT2hIME X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODIxMDA5MCBTYWx0ZWRfX1KOz8FyNlJJ2 LpyH2pN4ANlkS4qoPLh6BMbuUFjjgciyILX49GonxaoWhxcF4R5yZ0h5Tr0FnhY4CyUyKCq5q7Y IVzS7AkjMcbmG1bvy8+IxETRdncHsyJ+NQm0cqTn5gubLt4n9lMCmsshbnBO1JzPoyv/fxYJSSb zsEsQCUsVWzdQyV+FeMdkx+pk211jwnfsZHhmAR0hEH/RORmU2LaJUbLP9EXWySIfayiuHgkP4+ HFNUq9zlm8Vdl6sXZ7KX/jouK5/bjg29q2Y2KQusJuzxeM71PqN0aEsVToMwfRwdjJR5bD194cC YFYpdKhaopo4cch8nXZ4PN+IpHZzc+y597Q2SsAvj4XbptZXEq10r+66sC1F9tazEnDQYIA6XFt j8smQloxd9hMsnOjdeGiqtYUYiOg6fL1vnXRr8NZxfDx9Y54c5TaM7Ky8H8kY2hKMpzGs04TH8t al4SovGPo0VkmxVr0SQ== X-Proofpoint-ORIG-GUID: XFpRxZIXfOCKOyekEHDiwUaX5kT2hIME X-Authority-Analysis: v=2.4 cv=fuzsol4f c=1 sm=1 tr=0 ts=6a883b43 cx=c_pps a=bw0VQspFR1l10E3Rz9sV8Q==:117 a=iwqwCZQqcuTv3JOpYdM7/Q==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=Sv0fKeRqtYgA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=fPAWb5peG099m5CrUpKH:22 a=EUspDBNiAAAA:8 a=sozttTNsAAAA:8 a=aBuQwODoJmrdCVe4joYA:9 X-Proofpoint-Spam-Info: AW1haW4tMjYwODIxMDA5MCBTYWx0ZWRfX0h+m7rkHEkeO Vy+G6Xh/cxB+dZPzmLsuwsOZ+EhapSbueh2lyOF2yHNCpiuIOH+HnkuQw61mlYlzYymu+2s0V+b C+PNH73uOJ/9cZmRKK0rcYqhqoP6xwA= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-21_03,2026-08-21_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 malwarescore=0 bulkscore=0 suspectscore=0 priorityscore=1501 adultscore=0 clxscore=1015 phishscore=0 impostorscore=0 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608210090 Content-Type: text/plain; charset="utf-8" Add spi-phy-pattern-partition, a per-device phandle property on the flash sub-node that allows the DT author to directly reference the partition holding the SPI PHY tuning pattern. Used to locate the pattern data during PHY tuning when the device cannot load the pattern dynamically. PHY tuning works by reading a known data pattern from the device repeatedly while sweeping controller delay parameters until the capture window is stable. For SPI NAND, the driver loads the pattern into the page cache once using write-to-cache opcodes, then reads it during the sweep. SPI NOR devices have no equivalent opcode, so the pattern must be pre-programmed in a dedicated flash partition. One partition per device is required to keep the procedure unambiguous when multiple devices share a bus. Reviewed-by: Krzysztof Kozlowski Signed-off-by: Santhosh Kumar K --- .../devicetree/bindings/spi/cdns,qspi-nor.yaml | 17 +++++++++++++++++ .../bindings/spi/spi-peripheral-props.yaml | 7 +++++++ 2 files changed, 24 insertions(+) diff --git a/Documentation/devicetree/bindings/spi/cdns,qspi-nor.yaml b/Doc= umentation/devicetree/bindings/spi/cdns,qspi-nor.yaml index 891f578b5ac4..277dedcd4246 100644 --- a/Documentation/devicetree/bindings/spi/cdns,qspi-nor.yaml +++ b/Documentation/devicetree/bindings/spi/cdns,qspi-nor.yaml @@ -209,5 +209,22 @@ examples: cdns,tsd2d-ns =3D <60>; cdns,tchsh-ns =3D <60>; cdns,tslch-ns =3D <60>; + spi-phy-pattern-partition =3D <&phy_pattern>; + + partitions { + compatible =3D "fixed-partitions"; + #address-cells =3D <1>; + #size-cells =3D <1>; + + partition@0 { + label =3D "data"; + reg =3D <0x0 0x3fc0000>; + }; + + phy_pattern: partition@3fc0000 { + label =3D "phy-pattern"; + reg =3D <0x3fc0000 0x40000>; + }; + }; }; }; diff --git a/Documentation/devicetree/bindings/spi/spi-peripheral-props.yam= l b/Documentation/devicetree/bindings/spi/spi-peripheral-props.yaml index 84976fd3ee1b..cc01b643fe9b 100644 --- a/Documentation/devicetree/bindings/spi/spi-peripheral-props.yaml +++ b/Documentation/devicetree/bindings/spi/spi-peripheral-props.yaml @@ -123,6 +123,13 @@ properties: description: Delay, in microseconds, after a write transfer. =20 + spi-phy-pattern-partition: + $ref: /schemas/types.yaml#/definitions/phandle + description: + Phandle to the flash partition holding the pre-programmed SPI PHY tu= ning + pattern. Used when the device cannot load the pattern dynamically du= ring + PHY tuning. + stacked-memories: description: Several SPI memories can be wired in stacked mode. This basically means that either a device features several chip --=20 2.34.1 From nobody Mon Sep 28 13:17:36 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 96ECE3C37A5; Fri, 21 Aug 2026 11:49:31 +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=1787312975; cv=fail; b=jyVPchYy2/umsVwQOmoEIwLqub6hcI2bMVm5CUntEqsYQdoL8eeEQbEQUhd2Kmh2jJQ5/h9dRoaS3uF0Uf1GLwKhKkgvx1gUvLwcblASmSXJokLi40gczGHivSrYJ6Hz+C0baHpa8LsxHvaJODQ6sBvAF5fFMIqu/IG82IPqhrA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787312975; c=relaxed/simple; bh=Giwx2rrKgzNyerkKhGTq3O+MTCPxEYB1i6Ue4uASltM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=E07xtsFDbUP+FE5ckw2L/OoXSsVi5pzuZ2ItZB4+s5FY59dPANpLqJPdBGZzrROAEh1MC7Rrl+b93fouxe4imGyP5VpkSZ2a4ZEDljuZEOeoLLA0ULF1lb8Yu8PxMY6yUFZFQFK187K0OV2QD/NWZVL6QzRiK7ErWxdX9TldrVo= 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=PfclvTQo; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=lrsTzWqT; 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="PfclvTQo"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="lrsTzWqT" 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 67L9KNHq3254941; Fri, 21 Aug 2026 06:49: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=7PUSFr1CMLSKJQSYJa7YNC3gotH2wPORpfsTeMcMs DA=; b=PfclvTQoIly/+0rGzDm3dg0pLNl/q3kdXpdXxOilKPaKrzxMdKizHb0uA QrT0H/lO4eHt5/gDAqbL1O0XzvZRIhZz9DcWsFLtUH3y171gOFFLeGA+byIfqchO EIWgE+IKelGY46BgB+3Z0v65hyqWGTTu4ZqkLr2wAmHusTd1Rgk2CayQRkJDEWNz vrOxV+dgSDvDMWildJhvjKAUr+azjmTwmMV7XfvRecAS38W5A3CUvl04jVKDpjtJ AAoEfk4Azf3yISesQz6Fb3o+6bQz0PIU0zW3WadguAgon8p9k+1lVj1bwUGz7Mil /lnGjxE5/ezbG64joLPqzamDi8UlQ== Received: from dm5pr21cu001.outbound.protection.outlook.com (mail-centralusazon11011069.outbound.protection.outlook.com [52.101.62.69]) by m0380145.ppops.net (PPS) with ESMTPS id 4g6hfk1ddr-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 21 Aug 2026 06:49:18 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=VAKAF+xZ6YgpEF9t0Kv3oeVLhwfVAsng789gkRld8G7x010v/Xju4YZ7glk6qhmAlJuBdgJKBIJNdiUXu/RO3ohNtoCZycivIt0LWtBcUz0eX3HEJcgjWU43ZadiQqJJbZEAxL04EJkvIG0xUucwg5yuMdrpSRPIoUk/HxVLUjlN8pYDLhlRbbXUXe1dGQvilXATGqsRncnkLWH3MzmK85oxHPNwl2eUkZB+WhN0Y1fga3HP6z8Km43AO7TMhxiujMVI/GgZXgAYsHuatwe3pdsECMSAODF54hyoka0S+9KxC7hx5xBBK7sdOLgPPlC9WksnSsD88PSdmAW9iSnEKg== 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=7PUSFr1CMLSKJQSYJa7YNC3gotH2wPORpfsTeMcMsDA=; b=ykOZiaW/rqxq/mmnLT8QVtEi2i15nD4G8FqArBtytvKPIk8PhxhMIWaotwvUBVz6UKmiSsUOI3lBpNPRGVomeCt0I7XS24s1ckdXjKUTKHzuw9gO+C9SgQNL3DvClIAMyCV1d/tkZ7RW6qKHdWYyfzegtYo08v3UtJpH8JEXnl9dHAMhU/fg+gdTReEr+8xyIryrEhEF5XCJwMu0pebxcRdH2Q+x+SugV4VbsgY9YhCpMeNdw+tmFtPT8rucq3YdPa0We2/GrXH3ZaBdw3gqhP2PT45T/QcJtk1DEJtPoL/7nUTv8X3B64RteZP9xTVLJGrUfoLfPoXtMEvv8WV9wg== 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=7PUSFr1CMLSKJQSYJa7YNC3gotH2wPORpfsTeMcMsDA=; b=lrsTzWqTDrKRmrVFsvc70jO083FPkYRCIQbAgG9LmAcIPQmGOB27FC66+BYb3Pfyfyu0y2vySicRNNA8txIZ82fxFr4KLN4PB86qTy+YEciWYB8Uq0LitgEVSDOw9baEIyn6/TF+3sixRYnkxt15jb7U+eABP+VMkdq+Dma0qxU= Received: from CH5PR04CA0023.namprd04.prod.outlook.com (2603:10b6:610:1f4::23) by PH7PR10MB6082.namprd10.prod.outlook.com (2603:10b6:510:1fa::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.339.8; Fri, 21 Aug 2026 11:49:13 +0000 Received: from CH1PEPF0000AD75.namprd04.prod.outlook.com (2603:10b6:610:1f4:cafe::8f) by CH5PR04CA0023.outlook.office365.com (2603:10b6:610:1f4::23) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.339.11 via Frontend Transport; Fri, 21 Aug 2026 11:49:12 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 198.47.21.195) smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ti.com; Received-SPF: Pass (protection.outlook.com: domain of ti.com designates 198.47.21.195 as permitted sender) receiver=protection.outlook.com; client-ip=198.47.21.195; helo=flwvzet201.ext.ti.com; pr=C Received: from flwvzet201.ext.ti.com (198.47.21.195) by CH1PEPF0000AD75.mail.protection.outlook.com (10.167.244.54) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.360.3 via Frontend Transport; Fri, 21 Aug 2026 11:49:11 +0000 Received: from DFLE207.ent.ti.com (10.64.6.65) by flwvzet201.ext.ti.com (10.248.192.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Fri, 21 Aug 2026 06:48:53 -0500 Received: from DFLE200.ent.ti.com (10.64.6.58) 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.45; Fri, 21 Aug 2026 06:48:53 -0500 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) by DFLE200.ent.ti.com (10.64.6.58) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45 via Frontend Transport; Fri, 21 Aug 2026 06:48:53 -0500 Received: from santhoshkumark.dhcp.ti.com (santhoshkumark.dhcp.ti.com [10.24.52.55]) by lelvem-mr06.itg.ti.com (8.18.1/8.18.1) with ESMTP id 67LBmVle2022942; Fri, 21 Aug 2026 06:48:48 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , , Subject: [PATCH v8 03/18] spi: parse spi-max-post-config-frequency-hz into post_config_max_speed_hz Date: Fri, 21 Aug 2026 17:18:07 +0530 Message-ID: <20260821114822.4040338-4-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260821114822.4040338-1-s-k6@ti.com> References: <20260821114822.4040338-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-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000AD75:EE_|PH7PR10MB6082:EE_ X-MS-Office365-Filtering-Correlation-Id: 6202d965-fc95-4bb2-3a9c-08deff7a373c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|36860700016|82310400026|23010399003|1800799024|921020|3023799007|56012099006|6133799003|10067099003|22082099003|18002099003; X-Microsoft-Antispam-Message-Info: k9xloCUqI4ebJORK2gA1qDubc4dNz1eWJCneaiekxnI1EXdYHvUdJeH5LLz9123ixsNQSFPG+vwbvhuEZ7Jln85wlpvPaI67PabdqvM+QCSMQHO/0WAoCoL9/2K3XzmnpGS15creLIlt9+nnsRcEYIr8BtWDP3z6mVMtke9feehT79JJk3RWdFbO0uc8HUy7Nv5i2960uO+OGaGPam4czqNK7mTFaMawtpS5QchM3FOLyNUXGRcr3j23AiOAGPwaQAYKUdd6salOBHy4DOk6lQz5dIpY6Qllc19+16ZNhWv+tPRvVG4lI7NYwLPLw6uPIehKg+TlkvHWkVYgspASNjnpBssmlk5DukNUgi+ktNnzBdevZMLcsO3Ln2NCu3ZPZwqHRwmQYbK7QJDnlVAjpHUH/XeS8/bC1Z0j5CO3gyxk+OiTtbJAG4b+6AI/EqvMXTunhV99wKLU/EljhV8r2RTP/jVBut+UNxf/9Us4rseIO72mKKakKLYoTo2dTIgkX1DKKDAIYMFykkVsRV7amCIH7lm49ZUvDCYpLrOsvdzh3IeeUKNkbAqhGqpwPVTT5Xp14JwJQDJKVKnLzYC8/KKqogtbH9QSdKif0A9V1sZ4A5eoiG021z6K0fhiP412ykYNB8TqVs6syWg7U73+OVndlL/zf4hwKbkFHkB2EVFnFZXSJhVESReJxCNeJBPN+O51PepsEDi0qzSEdmFZy58Ik1dbhSYMkv7CFmdr77vmQfEu5MH+1oAq9wZo3jRl 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)(36860700016)(82310400026)(23010399003)(1800799024)(921020)(3023799007)(56012099006)(6133799003)(10067099003)(22082099003)(18002099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: XrP/B81iuWNu20j/3892Vm1VPwqjvv5412XAHHZYysWjF75u1Uuut/pXn0p0kSM5ZjoPn6kWAORq3uHHx9vivQyYtDn0WlFTjS4kAcPcKyb8Oql3mPBGBrG71edsn4x3j57JS155ThhuUrSFwTRr5y5ZYZJ6gP/OLffCX5uWkzi4kphVODxrk/vS4KMaDGGOcxff4INecsLQPmYWmy1SupnG1sdZP3jSjxVpDSR7mOjO2TziSfcoQLtfKyfcev+4qDEQZuhv5mKAGRFGHFLB0JmPIKgbFp/B+v44eGYOKWMW444jSQSNGaRpL9Dm8gPfOb17Y36TjdcmFXoTbnxLfgyjpLSBscCS9tA3uoDEX8ERX4qdIhQlZso4HHfGRHZ9b5AF/I3neTZbM8u/P5KytxDhfVl5cfy7pOSjEmKyvtsWBONld0NY3/v4YPlYkHCL X-Exchange-RoutingPolicyChecked: qEDt26lWrRh1EO8aDsdBWua7cPcacQjp7ai4dnTWHf+bqiF/LNTtH6uBfwCSeIh0NVOslYBcblXA8c11/WVSduNM76Ikk7sTmUAhM3gCPh/4dCY0OyF8knKQwautF5QKXn5FMpqHLFWg3qY3ezvSJS188KPDIWS6Fc30R84hD248klXeHAQpWezAtPq1bMxz4HwNkfIbGBOlPfb+AdEI51wkX3GDw/iRS5ZOkD0pWpWtFrAl5CJer1wfug0ihUJQMFjfqzVDc9zaa6prA+d7uHwava9G4e8afY8bRmZJ4R43liSUac5urNAXw7QFrxV4PIS5aMozC64M0mZs+cM1SQ== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Aug 2026 11:49:11.0005 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6202d965-fc95-4bb2-3a9c-08deff7a373c 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: CH1PEPF0000AD75.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR10MB6082 X-Authority-Analysis: v=2.4 cv=O7AJeh9W c=1 sm=1 tr=0 ts=6a883b3e cx=c_pps a=/8oI+ICX6VsmSI+SRIYafw==:117 a=tJyPKKxUohctrY4NYmUjkA==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=Sv0fKeRqtYgA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=gO1vWkAQAl3rybz1DQOp:22 a=P-IC7800AAAA:8 a=sozttTNsAAAA:8 a=2Gi1gDZmOG9PIfG5304A:9 a=O8hF6Hzn-FEA:10 a=d3PnA9EDa4IxuAV0gXij:22 X-Proofpoint-ORIG-GUID: QUn0jWqH5lDaAxBvBE5ayEf9z2mvM3oQ X-Proofpoint-GUID: QUn0jWqH5lDaAxBvBE5ayEf9z2mvM3oQ X-Proofpoint-Spam-Info: AW1haW4tMjYwODIxMDA5MCBTYWx0ZWRfX0avDnTlKNgqV p7/tml37+e4aIahhdBUStAERldiLz2O7xhTC5Pg2uIa1ZjXLh4Hi8a+oVEPNB9CvyJ28CFnKZeq yy1TSdQj4U4pCzCKDDemC8lq+seooW4= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODIxMDA5MCBTYWx0ZWRfXwU1ou5uTmZ+7 iyBVUKNOOa9Pyjx5ZiIQWDnlWVFWiCRw6T1jA1obgM/qIwPHFEkWzVazftlssbR9grnoV3Qqogl BuT6pJCKRW5DuyD9Njl673f03SbpcNLcdEPyIq7nNcB8JpagaIxKcsuY0S/I4CWsv0aVg20gB+/ 6uvKib+2eueyBxpp7V3g0jZ30EitJVeBhUg9cPNs9A4nXKHHSd78M8UNvB9nUOh2KnOvi1zDHhn 3vfmCMrMZ3RfQSNZTrkgAEMXHatTHM/MD7LZVgdPpjOB0WkJ8xVO/7icPq5EcoXXnuk0oNfnqYP 9Xq5jR5nTvx0j2DbtaPDa1cseFsSlnEiGwC2guA8Z1OGwNiOA1Cm6Hjwi2X/ChggshO9HFUAkfV ZyS5aNXzgTStf+WMUagkwN+IqR/gWCU8EfaMv7WJTucyV35ipAx75dVQVCUSV8/ONUPst9fBqdW iDEvrlli0jqt6VbZcCA== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-21_03,2026-08-21_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 bulkscore=0 phishscore=0 adultscore=0 suspectscore=0 lowpriorityscore=0 malwarescore=0 clxscore=1015 impostorscore=0 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608210090 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 5b5b3bc5f0d8..6b01ddb7cc32 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -2800,6 +2800,8 @@ static int of_spi_parse_dt(struct spi_controller *ctl= r, struct spi_device *spi, /* Device speed */ if (!of_property_read_u32(nc, "spi-max-frequency", &value)) spi->max_speed_hz =3D value; + if (!of_property_read_u32(nc, "spi-max-post-config-frequency-hz", &value)) + spi->post_config_max_speed_hz =3D value; =20 /* Device CS delays */ of_spi_parse_dt_cs_delay(nc, &spi->cs_setup, "spi-cs-setup-delay-ns"); diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h index 88d17fce02dc..02fd602f29e8 100644 --- a/include/linux/spi/spi.h +++ b/include/linux/spi/spi.h @@ -141,6 +141,8 @@ extern void spi_transfer_cs_change_delay_exec(struct sp= i_message *msg, * @max_speed_hz: Maximum clock rate to be used with this chip * (on this board); may be changed by the device's driver. * The spi_transfer.speed_hz can override this for each transfer. + * @post_config_max_speed_hz: Maximum clock rate achievable after controll= er + * configuration (e.g. PHY tuning); zero when not assigned. * @bits_per_word: Data transfers involve one or more words; word sizes * like eight or 12 bits are common. In-memory wordsizes are * powers of two bytes (e.g. 20 bit samples use 32 bits). @@ -195,6 +197,7 @@ struct spi_device { struct device dev; struct spi_controller *controller; u32 max_speed_hz; + u32 post_config_max_speed_hz; u8 bits_per_word; bool rt; #define SPI_NO_TX BIT(31) /* No transmit wire */ --=20 2.34.1 From nobody Mon Sep 28 13:17:36 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 7386C394490; Fri, 21 Aug 2026 11:50:10 +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=1787313013; cv=fail; b=EJfcu5l0nxweawTZ7h2QCJ7x130XZ0JBypT7vWKK/1ya5N20IPaR3md0J28faRAp3D6xYrPnL/IEcmsHbziOudM4Vd+bYIRkwpFcR/w4zJMeivWU2y6/GWhLDYA0mssU4n2IO211pjWnG4IJJZ5wKBZNH0IOCWr9f3kCv+Yp8aY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787313013; c=relaxed/simple; bh=bK36dcmI9LM2Zo2CmHrCSD9+IDm/OlfxjIURelHEDek=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=vCX/6HtXYhEZTablS91EOGDtUEZHJMThf7YPpnbNDp4FSk/Hn4/12xAntMKRdqVpjpF6gyDridBvPh2GqxoZPAPAig7qmqGFSae3h+DjkvPMfgKvjqKe+tNozngxmywhOStNZ4oEqFOM5DUORm5R9nxIkfM3RdOOYmRCtVtv/No= 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=RAaYMN8Y; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=TYdJgNjV; 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="RAaYMN8Y"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="TYdJgNjV" 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 67L9KRnH3255019; Fri, 21 Aug 2026 06:49: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=hKqYmG2fJOgXyuuCdu+UOY3ZnmCqqn9zeCJ1M8StE xc=; b=RAaYMN8YtmxIM5NgGlEpNAtJ9FEH+fnZVTo5OdycCOWrWx0v8CCq9QqeV bIlYqm2g8q3fvwld/+Khdu8Xw4nj2AZBZsKPFgY9b/odSXAzDKpCHfy6oPNx4qor kchCa4UF30luTfFaknOkCydjGUEEwpChstvTr20wQfrDYdW0p6ltxNjLYYYxKfRQ t5qpItR+1HsnRZaOlLj+4j+E+mZQZSvD1HlQlGd51fgpuqF7XBDDEauLui7lHrQj PtTm3fHPQrR+QTQogRXcvUXcm0AoZe8ruPOOUCdvZnHo48C+oiksIjWyf2ZKojCg CI9DCbL7kBZcNxn2Es5+eUqh7pUqw== Received: from byapr05cu005.outbound.protection.outlook.com (mail-westusazon11010005.outbound.protection.outlook.com [52.101.85.5]) by m0380145.ppops.net (PPS) with ESMTPS id 4g6hfk1dd0-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 21 Aug 2026 06:49:46 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=xXlNRvNJGdMlhPclpjGogNj60XAb9ppUVMsjmA00wdgM33tpzG/SeviBpE4T5vZeeMigpBBGfoz3xYASBWoqEFBrLYoR4hfSPr90bXsMHW1BXQ/wle32usu8iILrencqktITVEr03DLqGKx7Urzku/eXj4kmEb4DaEQIqLEBYOwQisXZQLF4DuXplTWnhPYy5T8Y0zWMleXRdcPdhaHVZSBLpYQsKWiCXDgho9/R2jzSu5LdUGPkh9zGVOGh40oXPnRMXBbh43rg4/DT35Shuu1NfEm2rj2vrrWRl+C6wMqeq3wRDNcP6F0wtsPe6y+Qw9+4VfQO7efGYXBDO1Jchw== 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=hKqYmG2fJOgXyuuCdu+UOY3ZnmCqqn9zeCJ1M8StExc=; b=kXyXZ2Cjn5c/PQ1+djSMt3udZ8R/DuMKejlWiP+PtWI/5o4EoQtbhJQkpHqxeCQ3y3xUGPaelgg1oGfurw4MsDMvC5uyy0kZ0vxqToaCOA9sI/1bCb4Wo4zq+upS+SmV73LYQNnL9f6AjHgHiWGTAYbKy7gJLDXQikDO9Q3xMmhEbbn9NZuQzFbHART79w1mFnwAyDMNZWuTf0R0Pjo7w4QqSW6d3YCL+YMNmQn7ZEFj9BzYVLm/VPqcKZ5gb4YWQYp78S+0fnG6rzGivEjM4S29RSa35HUffqQcbVGafvviHcDlIc+W6ebuzt63wglapiEjNVb2Viieua8JWAualw== 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=hKqYmG2fJOgXyuuCdu+UOY3ZnmCqqn9zeCJ1M8StExc=; b=TYdJgNjVGzO5a/92Eh9cV3lJ/PTf7EoLsXWw+CydUWzUYbMAfLgwnCdxYxHS8Fa9qVrFcUrdM6VhbHdgSMSQIWu8B4mHO8a/XEFXD/jZ7kltqp3qu9t/K9abD55zvTs5E0IPG+a4vywIyojRr7iEhCSzW2rlxALIIEmuzDcY9b8= Received: from CH2PR19CA0014.namprd19.prod.outlook.com (2603:10b6:610:4d::24) by DS0PR10MB997674.namprd10.prod.outlook.com (2603:10b6:8:311::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.339.11; Fri, 21 Aug 2026 11:49:06 +0000 Received: from CH1PEPF0000AD7F.namprd04.prod.outlook.com (2603:10b6:610:4d:cafe::8e) by CH2PR19CA0014.outlook.office365.com (2603:10b6:610:4d::24) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.339.11 via Frontend Transport; Fri, 21 Aug 2026 11:49:06 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 198.47.23.194) smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ti.com; Received-SPF: Pass (protection.outlook.com: domain of ti.com designates 198.47.23.194 as permitted sender) receiver=protection.outlook.com; client-ip=198.47.23.194; helo=lewvzet200.ext.ti.com; pr=C Received: from lewvzet200.ext.ti.com (198.47.23.194) by CH1PEPF0000AD7F.mail.protection.outlook.com (10.167.244.88) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.360.3 via Frontend Transport; Fri, 21 Aug 2026 11:49:05 +0000 Received: from DLEE209.ent.ti.com (157.170.170.98) by lewvzet200.ext.ti.com (10.4.14.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Fri, 21 Aug 2026 06:48:59 -0500 Received: from DLEE202.ent.ti.com (157.170.170.77) by DLEE209.ent.ti.com (157.170.170.98) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Fri, 21 Aug 2026 06:48:58 -0500 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) by DLEE202.ent.ti.com (157.170.170.77) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45 via Frontend Transport; Fri, 21 Aug 2026 06:48:58 -0500 Received: from santhoshkumark.dhcp.ti.com (santhoshkumark.dhcp.ti.com [10.24.52.55]) by lelvem-mr06.itg.ti.com (8.18.1/8.18.1) with ESMTP id 67LBmVlf2022942; Fri, 21 Aug 2026 06:48:54 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , , Subject: [PATCH v8 04/18] spi: spi-mem: teach spi_mem_adjust_op_freq() about post-config ops Date: Fri, 21 Aug 2026 17:18:08 +0530 Message-ID: <20260821114822.4040338-5-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260821114822.4040338-1-s-k6@ti.com> References: <20260821114822.4040338-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-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000AD7F:EE_|DS0PR10MB997674:EE_ X-MS-Office365-Filtering-Correlation-Id: fa6d62e2-14f0-44c4-bc4b-08deff7a33fe X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|23010399003|376014|7416014|1800799024|36860700016|6133799003|10067099003|56012099006|5023799004|22082099003|921020|18002099003; X-Microsoft-Antispam-Message-Info: kzI7rBmN4knvxjzs5cfeYwSfu2NwXzR7bXgxs/K/HHhMulUQTknynk3EwGM4YYe6RO5AKtyHP+mImkLZ4GJfZWyTPVBfMVRyrNfu+mlQLnnVIGLMnOBMlgfXOGcsVs+2iz8XXGsFqnoStWwwQgauQbk0cjvHLhRHbB8P0HeJUfF/cRZPV3HPp0/MKoNeFUIO+KE/a7cLjvnbBpf5VuvptP5ANp40Sh81BW/rI4wu0Gzyi7Rck2mtXq0X5uBr3v5vru26BCk1cfWmszIuO2vVjaLFv7f/Pq062+D1FZI4l42F/BFRTbtjK1RrJOnIuW/bPiru9UtRPerwwOYWJcMqzJrFKO9knhuY8wUDVn1ywsbUbl2px4iN7PXrMYG8lBzvXS50GnNprCN07CiRnqjnJDJQd2QrKC+JMscgY0MysxrKk3jNImFovcIJagX/6X6mLDUAdCI8CT6m7V+PQtDaDMVI5fUh+9uupH7VGbmltLS8qmzOsWpuDvy3RTDGPKYvDeg0OJyZRIf5qK+JshaLDyRfv1i0t+eEshVvG9bCvLYqr7mdcS8svLqZRdUVfXTfHOWhE4X4r8FHsHpiQk10YIhHdNLcsCrH9yyCyTxznamQFkZGDyvvi4yAu9D7w1GtVq5evvIvnE3YucCH5nSFJY1JWUD9DyoqjtBQkw5vOMrZ9Yb81RUnAx7GKI7oZuloeS79maumWPL6/POPJf/ZqkSoFBs0GB0U6bUp+qBWxpgmSn86bC7rkuLlVtWR85MT X-Forefront-Antispam-Report: CIP:198.47.23.194;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:lewvzet200.ext.ti.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(23010399003)(376014)(7416014)(1800799024)(36860700016)(6133799003)(10067099003)(56012099006)(5023799004)(22082099003)(921020)(18002099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: mqV0VGaY6QyUMfxZU7jCUDH7WQ2k+M0Z0VIQZo9r2bBc6E5NS7i8J0iUaAu7SYWby7vm64fXVPLmRK7StZzNeml7MP1OZ/qh01tIg1k7eQlHBv3TSgGV5IY0VQJ6DKfaO9UIC+ux0nTEuhBu0rReDuZ1+uVu2mV/8vn/Fl3K6p05Ptet6ca1i2IoIjnaMArSjDrKUYM05GQ+zEgLqvM46zVv/LOW5B+w8D/0NRtJVuiu4VSz5p5mj+L7nrxAf7g9BIXcXZzegbGsDYvSTlYU+m2YTm8RYnpC9337EIfwpBO43mbynY4DoPp+tFYhPmxV0YKOq6pqUuxyWsG5nsKU0IJOe9qCt8g6EY7JF2lAZjrSN13v09gc258ULFCzlCsduZooRv2wHd46KmopoCcZWVDz8d0qC0/SmSXB5Yj3m1zcpGQZFtyXy1E+QEAdFnPj X-Exchange-RoutingPolicyChecked: pFma8xx+oomI+AssYW3gOepY792DFUU/DjgwKyxvY4XlEPh8tovgg0PmaR4tJ8Eq3SwPSI5Y0wmaB8ku3JYs7lL973PsGpRx0FGlorQXeNGGgdLYWrmFY6IoT2SaGIbSfJbXewzLVoe+ffX3ypdEKtrLuZOUqeY6Kxa8LwA3QcIcxu33o7nITcKHcp0pWC3rBTI0afiZKxlx8bmIbvbjeXtv1mZ256eql9T7QGgbzrH72NnVepXFeY5XJmD+pSa7QOqVEP7cFvUbb51DFG2oq9kuEC1dfpqqp392UUBC02QjM/rlJexzkFZKfxAf5TlZtTUHIPNvmVmBayB1ZbbIZA== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Aug 2026 11:49:05.5673 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fa6d62e2-14f0-44c4-bc4b-08deff7a33fe 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: CH1PEPF0000AD7F.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB997674 X-Authority-Analysis: v=2.4 cv=O7AJeh9W c=1 sm=1 tr=0 ts=6a883b5b cx=c_pps a=AENbiTj01OTyMXuKFo/uig==:117 a=WotqVVQAdb04rnGuttW3Kw==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=Sv0fKeRqtYgA:10 a=s63m1ICgrNkA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=gO1vWkAQAl3rybz1DQOp:22 a=P-IC7800AAAA:8 a=sozttTNsAAAA:8 a=gHTh7DRQwxBKnKwRL7cA:9 a=d3PnA9EDa4IxuAV0gXij:22 X-Proofpoint-ORIG-GUID: liyfRz4nfwq-sXqKg5GC7bWwaiCxn6n4 X-Proofpoint-GUID: liyfRz4nfwq-sXqKg5GC7bWwaiCxn6n4 X-Proofpoint-Spam-Info: AW1haW4tMjYwODIxMDA5MCBTYWx0ZWRfX2MwRFtSndfgx mgaTu4G4W+bIv5sPIAL0R1T2+U4aBXxdlFV2qa34tCx59GXUN/C2faEwUUnRI6xAyXVeQKC1rjJ 89gND95eOEr5Tg9p3Q6NQSmD+UoT1aA= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODIxMDA5MCBTYWx0ZWRfX7mBEIMgzb4UG 1GbSS6qDT2zqhDSsJst7tVCXx9WhFYpym0ilI5JXM8Cm6IU+RobV9SK9GqGtkVTywDWr4L41zmP O+CeNYb1ZW1zi8MVm0XK4MS4gMZjRFrVocQwZsYgaVkJPF+E2UgI4VwCc8zDKMq3V7JRYdfn93y DF05P9f8xjXBUQWsfKKv/Ah7f45MMYkNbtNI2l07RXBPQCxlMsfpe4fB93mmVO96iN00v2AgD6n YmUrAZJVyF2l02y3/2aIzlcZr1+/Yy4oX/DRFTU9TUUNPMvPHcUY71O9MAiKbOBPvoMA5HMqxvy 4isJe9s26Id6WmxM2NaMfF1sSga8OxNFtQQisLCnBoVwHnZIkityPR+jiSi70n4G77hvNlTuOEy j9zzbomkz78KXXCPuRsacSJW59L4eIgIbjZ94Qm/+ace/cfWMCjWPUPuYWI/4l7l2GPi5l7mn4l LZW2NG1iBQxIW10xgtA== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-21_03,2026-08-21_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 bulkscore=0 phishscore=0 adultscore=0 suspectscore=0 lowpriorityscore=0 malwarescore=0 clxscore=1015 impostorscore=0 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608210090 Content-Type: text/plain; charset="utf-8" Extend spi_mem_adjust_op_freq() with a bypass for post-config ops: when op->max_freq equals post_config_max_speed_hz (the value written by execute_tuning on success), return immediately leaving op->max_freq unchanged. All other ops are capped to max_speed_hz, the always-reachable base rate. This places the policy at the single existing frequency-adjustment point so exec_op(), supports_op(), and calc_op_duration() all see consistent frequencies. Also extend spi_mem_default_supports_op() to require per_op_freq controller capability for post-config ops. A post-config op runs at a different clock rate than the pre-config base; a controller that cannot switch frequencies per-op cannot execute it correctly. Reviewed-by: Miquel Raynal Signed-off-by: Santhosh Kumar K --- drivers/spi/spi-mem.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-mem.c b/drivers/spi/spi-mem.c index 5f973ebfb8b6..cd4bc4c914e7 100644 --- a/drivers/spi/spi-mem.c +++ b/drivers/spi/spi-mem.c @@ -206,7 +206,8 @@ bool spi_mem_default_supports_op(struct spi_mem *mem, return false; =20 if (op->max_freq && - op->max_freq < mem->spi->max_speed_hz) { + (op->max_freq < mem->spi->max_speed_hz || + op->max_freq =3D=3D mem->spi->post_config_max_speed_hz)) { if (!spi_mem_controller_is_capable(ctlr, per_op_freq)) return false; } @@ -623,9 +624,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 Mon Sep 28 13:17:36 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 50C4B376A19; Fri, 21 Aug 2026 11:49:41 +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=1787312985; cv=fail; b=jNDn9nEGuUM17/42UHMcRjvlWnmZUlIFpL/OKgkxR0A+ipMo2lMUjiK8yX/0nphGQ10A/ktdMobJfi2Q/v/Jn81hnOQ8K1nqpP0Mf1hpNdQyNTC9s6JtYcsCodapwkEKdmgXZ7p4VCz0Y5hQ1jNGj72OoJrrBeHjacOhTYpaOiA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787312985; c=relaxed/simple; bh=jWsZQ8OrcqpFqX4dCEKZbtqhz7uNq3Qk8YJy2FkPPYc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=UJhEqu4J7iITD2Rab3vDi8QCoMrcPkT1GwIyD+tDbxYMKRpiN7mVxmLuW+mqug2rZB9vznA1c62bwvQ8kmQeCpqHtMf9bhol5VXEZTDaNuQ8Y3oEiA+s6b94YW+U02FUhS5I69A0azqw2AigzkZgPasY2QkU8fCXBB58XEpTwKo= 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=ADRqtyBO; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=Nf1cblEU; 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="ADRqtyBO"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="Nf1cblEU" 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 67L9KRtn2887015; Fri, 21 Aug 2026 06:49:32 -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=AIKfefqLLNKtwN3tukdkBIjsxtF9B5GgFsNKrzvlC So=; b=ADRqtyBO876YlWVkNJ79gQXsHAp3BrCDYt+S0KbbigaLAe8q4KwdEql1B 8ySfnHBZQuyckfRzQRoalxYp6aQmv9pMHVVhnDtjbAR+Zp6qO169ZX4T9dd7/eOf 5sbuMiZcXVqoKqmvoX3UxxefGLgGi3eMwAp4P+WrV/VAYTe6vkGUcJg/v9Z+E3bx r9fxLHxCTFpT8xxAQEufFDd2TMFMp4vWZO2tA61HYiWGihjtDbRlu6ZU+6J5vYfw u/QCV3T2pQsIkJ6g/gmHrVup5FjcUAyNoNQxquR824ZtX81G2oz7XDNgFNWtnGs3 pOtUHHWgq/eG3vztUt1kkVO0WiNaQ== Received: from cy3pr05cu001.outbound.protection.outlook.com (mail-westcentralusazon11013056.outbound.protection.outlook.com [40.93.201.56]) by m0384305.ppops.net (PPS) with ESMTPS id 4g6gke1mhq-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 21 Aug 2026 06:49:32 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=nuf6iKaB0XWPt9CEFV55q59wmoGxENH/+8UgW3xsS8Ue2kFLuf8pghEfV0+Bd2gxGKxGiXk1bjetGl/XBGVbmzjz8TrkoCtoXknMhpLT59ZRN6T2cH78QcDlidZvE31M6VQlT5F1CyQDdzr2Lpdbd33ThTIipGWxa4h0FpkVHqp4zK5BV+l8jGDN+TeG/uaI6Kxmrg/uoGz0FsylCyfH0NRDRby+yU/nqjgqu6rt1u+FvbVMNRlXYTAnkDFatDPHb1b7l7GIfEQmxMJdCZAouPGE8+cShkEA+RMyY46rNbSbFb/A7Y/RhJmzhU6dbWSe8OLGUNHpfEiWNGOLpn7dxg== 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=AIKfefqLLNKtwN3tukdkBIjsxtF9B5GgFsNKrzvlCSo=; b=phou3BQLkknoDg8+6Fmr0WmGdYCEHfxtR3JnI0jXQVLPrzaZZlRqVZGjT3RRhxyhp1ppR7nfHoPFZiCSE0ryPerIjDuzOie0ZC+vZ/uL3CG4PdvWPHJmtDpv8neIH814ZzcOzfqOS0qBnz83AXO4q+R3JbEbJg2v+7bkaAw5/lzulSNTaEgOlfv0JOmM2AdrDLLd8qZn1PFKF+uq0i2eguE2SGQrjsm7tj24T6//S41GRFC6ddcsU1188P5aAAclGetYpxp8QXFUOex3CMgWRLbUZBSDteWLxMwBF4t6M/ukA4U9+kNNCJltvMWHpHGqbA0dYW+xPzMxUYosPvcerA== 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=AIKfefqLLNKtwN3tukdkBIjsxtF9B5GgFsNKrzvlCSo=; b=Nf1cblEUXBbj1UWzGc3iR8inuSKm8T49p+HKhHbC7HYbI19M1fMvF97Vbk4bafdHpgMwaSa9EokPXpnD5dfzCHum3F1nRRyAkTk7pMuf/KhY3xrfTD5QT9LYOp/jFlfOLU2GtAdDy1DWAdpMnKQbI+c70gNMenFNxBUKqL4dl5s= Received: from BN1PR12CA0007.namprd12.prod.outlook.com (2603:10b6:408:e1::12) by SN7PR10MB6288.namprd10.prod.outlook.com (2603:10b6:806:26c::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.315.12; Fri, 21 Aug 2026 11:49:29 +0000 Received: from LV8PEPF0000005A.namprd02.prod.outlook.com (2603:10b6:408:e1:cafe::ac) by BN1PR12CA0007.outlook.office365.com (2603:10b6:408:e1::12) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.339.11 via Frontend Transport; Fri, 21 Aug 2026 11:49:28 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 198.47.21.194) smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ti.com; Received-SPF: Pass (protection.outlook.com: domain of ti.com designates 198.47.21.194 as permitted sender) receiver=protection.outlook.com; client-ip=198.47.21.194; helo=flwvzet200.ext.ti.com; pr=C Received: from flwvzet200.ext.ti.com (198.47.21.194) by LV8PEPF0000005A.mail.protection.outlook.com (10.167.245.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.360.3 via Frontend Transport; Fri, 21 Aug 2026 11:49:27 +0000 Received: from DFLE206.ent.ti.com (10.64.6.64) by flwvzet200.ext.ti.com (10.248.192.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Fri, 21 Aug 2026 06:49:04 -0500 Received: from DFLE209.ent.ti.com (10.64.6.67) by DFLE206.ent.ti.com (10.64.6.64) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Fri, 21 Aug 2026 06:49:04 -0500 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) 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.45 via Frontend Transport; Fri, 21 Aug 2026 06:49:04 -0500 Received: from santhoshkumark.dhcp.ti.com (santhoshkumark.dhcp.ti.com [10.24.52.55]) by lelvem-mr06.itg.ti.com (8.18.1/8.18.1) with ESMTP id 67LBmVlg2022942; Fri, 21 Aug 2026 06:48:59 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , , Subject: [PATCH v8 05/18] spi: spi-mem: add execute_tuning callback and spi_mem_execute_tuning() Date: Fri, 21 Aug 2026 17:18:09 +0530 Message-ID: <20260821114822.4040338-6-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260821114822.4040338-1-s-k6@ti.com> References: <20260821114822.4040338-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-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV8PEPF0000005A:EE_|SN7PR10MB6288:EE_ X-MS-Office365-Filtering-Correlation-Id: 4cb77eba-aeff-4bb4-7aad-08deff7a40ec X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|23010399003|7416014|36860700016|1800799024|376014|82310400026|56012099006|921020|10067099003|6133799003|22082099003|18002099003; X-Microsoft-Antispam-Message-Info: ammip5y93WrBxfw5ilMkGreNgoFP8naCqiOiXjZ5xpzTj4soJhEDZc3h+nidmUoemdhlORCwhCzLGvm88+IF5w34FkZsIULJRRaT2hfmITjwGlkbKHEXVmwC+q53L8aT3Pnt5u34pGtUT1hpGHUdX2O0wwlhv2Zud7eXEcl60njAyp67HbFb/Ck9J3mbxnuvtlIxRO887Vq/5K6vmt+w1iOAXw2+p91H7c/TQMLKyfOK0N92zjAUkbKA4mwhpqqEnqSgsBvzJHUxIhxXdVfRCxf6cASXYYQGRAnt3ZPg9wjijuMUpMSyJM/+zQbx62N5l1hbwLMPhNxU4+10zfC9vjHpbpWKmbrMIocVDg9WfezN0T5MZbTmb+PMKcijqS2AwAquAtPNL7Cz0dniW1Lfz+eznxy30lYOfF6TcE2c7wMOxEZtQdJl2YjSZ2NAFaUPbWAeq2MvP3Y1n4DDqv02icPpWUtxcPHB+rRev02g4HPy8nz+8LutyDrtvGJDEDlid26xcHxbHHaiqKiLyJlJJecsQxxNMf1/dVriL6xktj60O2CUlnVE/UkBL+TwmeCb1JIiOwxtW5Vy6ExRJ1S35CgBR6b26OtMvO5ishKd1KGPl9vpqenpp/VoroqLmRKnfQnfubGM17bx+gnXQeHV86jIPbI4Vfe9h4GZuqDhOJ+owp26skevCxbMoBWFNTo6UGMR7GInygbqK19yi4sOqpTC8Eorc7ZiB4ZMM+XHg0voytXPM0QqqSwn+n6E8E1p X-Forefront-Antispam-Report: CIP:198.47.21.194;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:flwvzet200.ext.ti.com;PTR:ErrorRetry;CAT:NONE;SFS:(13230040)(23010399003)(7416014)(36860700016)(1800799024)(376014)(82310400026)(56012099006)(921020)(10067099003)(6133799003)(22082099003)(18002099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: vbhnyxbFS0U2Cdw3XwyMXSBstX/vXumUfQPLYzDwdod0qjMnCI8k32YWIdZT1ZfQmtQPdwpMHggjts+2+ZaY2nigpZM8spdE4DcYHaJ6Oj1r0jOACPKNMoYYuOM6q6IrYxrb7GkEwpMu4VN344x/4iISlg6gOOLb0wZUuZ4TPDpztRYmZVVqbGw3omXI8XQAZa0sSDn+KfbOScvSt290hndtpYyDIIeBosoFXQbkZgH1hk5TuMiP3uGQX6DrCTBSk+cZcxvHt17E96uyF8h0XidilcVwLEYFoR4pkcGqXdHs89k7z0EF1tNLgWqL3GItu66XKGG1MAWtG0Qr1JJ8tj/FQZYGvE7e9104/ahoEmL65CTpdu0LDuamTKt9CklY2xgmIkTNqz5fPiXKCCCGOPMKMsRSJgRxDyk6bUp5AHCN5Qs5ysWrv79Dfj6e38F7 X-Exchange-RoutingPolicyChecked: TdrzTPJrW0SdpBnbuyRHFl7zZ5cD4RLVmiyzq/+00+bDL6YR7Ulyts5XUSH1rbTgoR1r9l14jzwQoSuOyYQfqle9NKi7O1ED6iYojMW1TWJT/kgFX8Zi8WbGmRQHshKRhTCGi+1K0ubeZ7E3NdF5QCOSde1fuFJXX4piPiNUu+ybyMC0FwUZflggM7rsmRWOCTukySoKS5E1cKCR8pXySlpwBDkmqq8kzch/nXchRTne2yZz+uauoE07tQfVM9STgbO79Ch5fMXK/fVzC1yo1gdkbQu8/MTzPLntglrcKEQo9CYfNhdc9F0jDfCakONTtbJxAwKo8a3uDr9URlCgVQ== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Aug 2026 11:49:27.2326 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4cb77eba-aeff-4bb4-7aad-08deff7a40ec 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: LV8PEPF0000005A.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB6288 X-Proofpoint-Spam-Info: AW1haW4tMjYwODIxMDA5MCBTYWx0ZWRfX4EwpSzYp1yKd NBGcOYcue+VtolMIp6x/YM4uRlVYQ3iGgBytNtUYTst4QmYcWUrgu0+1NtlCwoYlBhG84o2Ywi3 Nj185iHf05h1Df3K+a82YIvaY58kdn4= X-Proofpoint-GUID: yqnn4_HszUHF5xRs1TqjRVSMnvpbeh6_ X-Authority-Analysis: v=2.4 cv=Fp41OWrq c=1 sm=1 tr=0 ts=6a883b4c cx=c_pps a=nYaA4L0hYP7ZHAKl0WLIGg==:117 a=iwqwCZQqcuTv3JOpYdM7/Q==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=Sv0fKeRqtYgA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=taLDd7a_hP9WKsMzeGRc:22 a=P-IC7800AAAA:8 a=sozttTNsAAAA:8 a=XczTfz52Gg2yNcvB9tIA:9 a=d3PnA9EDa4IxuAV0gXij:22 X-Proofpoint-ORIG-GUID: yqnn4_HszUHF5xRs1TqjRVSMnvpbeh6_ X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODIxMDA5MCBTYWx0ZWRfXwfv0B/MYUnFk jWeXkkCqCIRqtdaNOD58vhBapRke7cDVdphDDwp9R6edKmUkzlaY/nMQSx8/f2wcaPZRQA0iMHq HirtMU0r7UUQ8TmjOmngLfVMcEhFs8DWq59wh9IPF3O5E1swI5zLy4GAMxJYZ00twbddv6J7Kq2 gaGAv1SQ3M/aHmi1PMk+vtPw4Li1ULkwHfQhqpcpJE7u6dqAI/m+oWk9LWTQZRMJfbF0e4TdRR3 vcaIKwEglxXLlrk8D2MSRAqwyo2e/F775UH/q1RNJ8uDY75sakdA7YbL746rgIN8R4xCUZ03MU7 H0jwcqACjQQTjkCYpnznL9Xtept26XlnRukhxqvWDW9WnCRExY0OQYcWIZq88qNskA9ia6a2xjt a3Ai5zxqPT3YBu7BF6JPocqESsbjgGF6yijSrsjeE4caApAdneSEVLTLOgPTL9nIdmzdiCof8uH OnioAsNmfw4l6/eu01w== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-21_03,2026-08-21_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 bulkscore=0 spamscore=0 malwarescore=0 lowpriorityscore=0 phishscore=0 impostorscore=0 clxscore=1015 priorityscore=1501 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608210090 Content-Type: text/plain; charset="utf-8" Add an execute_tuning callback to struct spi_controller_mem_ops. The callback receives a mandatory read op template and an optional write op template. On success the controller sets op->max_freq in each provided template to the validated clock rate. A callback return of 0 with max_freq left at zero signals that this specific op variant cannot be PHY-tuned (e.g. a hardware erratum blocks it), allowing the caller to try a different variant without treating it as a hard error. Add the corresponding spi_mem_execute_tuning() wrapper. Like other mem_ops paths it serialises access with spi_mem_access_start/end for serialisation and runtime PM, and rejects GPIO CS configurations which cannot support hardware-level tuning. Reviewed-by: Miquel Raynal Signed-off-by: Santhosh Kumar K --- drivers/spi/spi-mem.c | 43 +++++++++++++++++++++++++++++++++++++ include/linux/spi/spi-mem.h | 14 ++++++++++++ 2 files changed, 57 insertions(+) diff --git a/drivers/spi/spi-mem.c b/drivers/spi/spi-mem.c index cd4bc4c914e7..79e89de1ce8d 100644 --- a/drivers/spi/spi-mem.c +++ b/drivers/spi/spi-mem.c @@ -693,6 +693,49 @@ u64 spi_mem_calc_op_duration(struct spi_mem *mem, stru= ct spi_mem_op *op) } EXPORT_SYMBOL_GPL(spi_mem_calc_op_duration); =20 +/** + * spi_mem_execute_tuning() - Execute controller tuning procedure + * @mem: the SPI memory device + * @read_op: read operation template (mandatory) + * @write_op: write operation template (optional, may be NULL) + * + * Requests the controller to perform tuning for high-speed operation + * using the provided op templates. On success the controller callback + * sets @read_op->max_freq (and @write_op->max_freq when non-NULL) to + * the validated clock rate. + * + * Return: 0 on success, -EINVAL if @mem or @read_op is NULL, + * -EOPNOTSUPP if the controller doesn't support tuning, + * or a negative error code on failure. + */ +int spi_mem_execute_tuning(struct spi_mem *mem, struct spi_mem_op *read_op, + struct spi_mem_op *write_op) +{ + struct spi_controller *ctlr; + int ret; + + if (!mem || !read_op) + return -EINVAL; + + ctlr =3D mem->spi->controller; + if (!ctlr->mem_ops || !ctlr->mem_ops->execute_tuning) + return -EOPNOTSUPP; + + if (spi_get_csgpiod(mem->spi, 0)) + return -EOPNOTSUPP; + + ret =3D spi_mem_access_start(mem); + if (ret) + return ret; + + ret =3D ctlr->mem_ops->execute_tuning(mem, read_op, write_op); + + spi_mem_access_end(mem); + + return ret; +} +EXPORT_SYMBOL_GPL(spi_mem_execute_tuning); + static ssize_t spi_mem_no_dirmap_read(struct spi_mem_dirmap_desc *desc, u64 offs, size_t len, void *buf) { diff --git a/include/linux/spi/spi-mem.h b/include/linux/spi/spi-mem.h index 0cce6b57242a..b69f671c40e7 100644 --- a/include/linux/spi/spi-mem.h +++ b/include/linux/spi/spi-mem.h @@ -348,6 +348,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 @@ -378,6 +387,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 /** @@ -469,6 +480,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 Mon Sep 28 13:17:36 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 8475B3803E1; Fri, 21 Aug 2026 11:49:54 +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=1787312999; cv=fail; b=C1dNPMNpwUnqJNYeTtmba51tMYT/StldiVg83XCV5TqRE7hb8urWOPCDr0PaI7IDi5O5zin1iO+oQQ0PqJypGOjdgGrNMk4BKPndFwegVmtqGDAMuIx03eIkIUly3sMbyxjmStdvp35tw0nKfv2+XujLPgVtgaQg8Q/7dnElbHM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787312999; c=relaxed/simple; bh=v6ww6XIH8TcUT23LUPoMxzFGFmhFMyzO6/EXwGCMXPU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=LiBC3Iron4XBU07sNwrtXyokpVA1RS/RdHp7K/iX7edDnGAcuLyFHI3aXpWsatDqTYSLHTJTEbrcFC11MNRdh5/6JpLZuyg7HLmH3w5ym26FwBxCsVGVXsDzk6rZLl/IWeq92NnQrKqaqhPgwo3H4lCCMFtR3jhqKKZklzAXoEo= 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=EqSFYVQW; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=jfELBJfC; 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="EqSFYVQW"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="jfELBJfC" 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 67L9KNIG3254941; Fri, 21 Aug 2026 06:49:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint-05-2026; bh=vRIdRiZggGVJbvsgQ0voaqOH53asB/hPokr2J9K8C Qk=; b=EqSFYVQWWMH4lrEyBxY9GSAkySXYBtxMmCsXs46mn9M2OLfeyA42l7DcG 4csatyo7sMPZLDpzQY6ODkwtrAqFppzAXtSDHe6P4u1WFQ/X0JrpY/A2YCZPy2zv yslKwZ8xSqRIjofOzcOB9k/CLslrrM5CHIVVNxobda9BbR0ti9u9pXny+dYQVMpD myNNkwwQydsaAv4z6bpB7MxFi+5IwKV+gpPgwjhjszNsFKOtbqnfVacRRcPgunqc gZzSpXLDTFpwWit6i1QIzCKf/Z5K3vKPiMiYoimTvdwfu4L/4LR/zoygBLelbAOp WJSRWBZmjlYlhI0LKWsXNqvf4Ym7A== Received: from ch4pr04cu002.outbound.protection.outlook.com (mail-northcentralusazon11013006.outbound.protection.outlook.com [40.107.201.6]) by m0380145.ppops.net (PPS) with ESMTPS id 4g6hfk1df6-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 21 Aug 2026 06:49:41 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=GUgJH8gxU8Gvv7TAIFk1TXvFja59qUg/efuiQR7OMZsFj2omnXtfnl+Xwgdm9g+QuawgXlhNRiwn7wGafTvL2KnC4sxtEg0NvjH1KuE1YfmczNa7k1ILMNLA56uvVIRZ1TamomRsurBRkzy/LMgE2NAVFtPKUjBYOQkzKQ889nbr7NIZ3uw2bGQv7Jmv3j5oSN56g4xHmwYuA+O1YALutE0TrvVy0LOdFvGWwpWnz+mUcVpjrFYwbhv4irS5bwpRFfprYQb4PA6XF3R8tOQRkPTN1qbHzRHD9gymHww8YIJzPpRGkp0nsuTiWgre1eHb+h7ax6ZbN0embQeU07CGXg== 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=bCYDjASr7NADnSrQo1jCZWXnSxyB0z74QexGQc0HaVH1kNoiHpvOsEsZqRTeaF++Rq4nv04+ga9myrcnxMttlxXme2L3roiQ5Uqbxy+nxMxyU2tPWHyv7CD3CDznySE6qKtU6HO5uzCzYQXH11eVdl8buV5eu+oerEgo3KGwGxhL7CGC8gu0EBcrG/ec1Xz3ocQ6dy0j2QlP9wL6rc+UTU9TPcVavlTgao81/55S13TvCpMn6gq3mxnbaxNq93FUggDbfhhdZOt7nwwvgs/eKcE8aXrvAtjcx2LIbufJrOSXoYZLVkSCwhwIcsDlRo7Fmb8QpLk85sxEX0YEJzrIrg== 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=vRIdRiZggGVJbvsgQ0voaqOH53asB/hPokr2J9K8CQk=; b=jfELBJfC+3od7MWVr8AEv96mV7GqhQfEYq8XKkP3t9fwx1Uy4h++eESuQ9s99OPO/ccGvlMoL9PWTSM8KTRI5Q5lJT2IUrvgu+BeIc+DE3PuiS51w7EwziWL21vbNYgKExFB7mSUbW2KyPTLwvKhmosnDPIelAG0vD9KTgk8rRI= Received: from CH5P221CA0018.NAMP221.PROD.OUTLOOK.COM (2603:10b6:610:1f2::13) by IA0PR10MB6865.namprd10.prod.outlook.com (2603:10b6:208:435::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.339.11; Fri, 21 Aug 2026 11:49:37 +0000 Received: from CH1PEPF0000AD7B.namprd04.prod.outlook.com (2603:10b6:610:1f2:cafe::2f) by CH5P221CA0018.outlook.office365.com (2603:10b6:610:1f2::13) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.339.11 via Frontend Transport; Fri, 21 Aug 2026 11:49:37 +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 CH1PEPF0000AD7B.mail.protection.outlook.com (10.167.244.58) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.360.3 via Frontend Transport; Fri, 21 Aug 2026 11:49:36 +0000 Received: from DFLE201.ent.ti.com (10.64.6.59) by flwvzet201.ext.ti.com (10.248.192.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Fri, 21 Aug 2026 06:49:10 -0500 Received: from DFLE204.ent.ti.com (10.64.6.62) by DFLE201.ent.ti.com (10.64.6.59) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Fri, 21 Aug 2026 06:49:09 -0500 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) 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.45 via Frontend Transport; Fri, 21 Aug 2026 06:49:09 -0500 Received: from santhoshkumark.dhcp.ti.com (santhoshkumark.dhcp.ti.com [10.24.52.55]) by lelvem-mr06.itg.ti.com (8.18.1/8.18.1) with ESMTP id 67LBmVlh2022942; Fri, 21 Aug 2026 06:49:04 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , , Subject: [PATCH v8 06/18] spi: cadence-quadspi: move cqspi_readdata_capture earlier Date: Fri, 21 Aug 2026 17:18:10 +0530 Message-ID: <20260821114822.4040338-7-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260821114822.4040338-1-s-k6@ti.com> References: <20260821114822.4040338-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-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000AD7B:EE_|IA0PR10MB6865:EE_ X-MS-Office365-Filtering-Correlation-Id: 416628e3-10b2-4d91-3df8-08deff7a4685 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700016|1800799024|23010399003|7416014|376014|82310400026|921020|56012099006|22082099003|18002099003|10067099003; X-Microsoft-Antispam-Message-Info: pLyPs2oxokESth/MDqbNXTYWOomMZ0y1WJfDABOKH1ezQ2tD1VV0djmLqswxOyD0PE4d4/FUMeSM7/5aDXaBhpP1zYWEGK94s80ZaOuSAIibr36BZyPKkABgeIiXXOq2M5sKLjx3+CkM61srFqgbpvXc4Hcy2LsIqcM0Z8XDuhRVyD4CJx7olAMHZXswASDpJwMkAPxDVGC+sEjAlEdIBEiAUEUcokuOrbNxGz/1WasBpeEYYt6imPdG6CwmkO1Is90zaJHjVjTeJ15F55DJu0iGtFHgCx+b3+u68GmeDLRIOyzbkHEpgPlPljlOTt26Ka+dpntBKkdDjtH2MRQC6tlHzWvnSiUb8XT6yg6IjUwkz9JAc4ILF1AjfyhGAjN9jycRh+WNuaEIxgPpjxvs6FSuoKe+He7GQGD71KNBYqJVAuGmZKv6C5M4RIv5PadkzBVMG4cVCXKT8NN/GdFUTyKh2QKg8TjPNIgn4NDn3zKECw4pLGBH5byMKY5a1X57/TOZ87znOIaITrWBGwLEVBFc1nXvD6kdKlWyzt/1AEG0o/+zp3Q0AWXBu0jhYX2ekLFEz6JEgC2nY399R6DVIg3GEmLcNV7Q6F7kFVN2GOo9W+1/1kkyXRmwLrnyf0W+JWexeEAI07PM27LEBiXEdAO8hAKyjWuSkQ6LkwWTANdbVYpN9J1abpdkMrHDmOUyFlUgxJl/ZlD1TOW27ODWC7+nktsNTncjJxrY1g3gXBzLuDZOAoKapGMjKVtt45DW X-Forefront-Antispam-Report: CIP:198.47.21.195;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:flwvzet201.ext.ti.com;PTR:ErrorRetry;CAT:NONE;SFS:(13230040)(36860700016)(1800799024)(23010399003)(7416014)(376014)(82310400026)(921020)(56012099006)(22082099003)(18002099003)(10067099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: mp7XE/4J9qzIY7KV0gRJ4zKOG8wJOtnXHo+u4ebKP2G9qGNfcQx4ACT4X9RGCS94eko1lZxWxSUDwY5y6ySQVOIPMeYyCzD6bSkUwftvOecvNwOwKlwn3KYJiOPBNkyV9xRU7Fifz2VvdcywfIB1Yr0cIbC3LfAVg101eCYK4sBsl8dYUO/QCKKRCMQyts6UsuJ+gZ3nZs+zTAB/1ZnLf4iigGgYC8Sr7zY22KpgTvdG9nbTu8KAdR2ZM0hW3K5Kea5eD+TGPXHVyssgQKkw/phH5qE4zCeTrh48geeBa4oQXVes2UeIuMmr0Vlkjh40Ojfo4CJMP3whjR0hqwcND0RDGSY3ZL80Yw2UBswejGHwFkP6xYRQZM9it0tXyTuJ3NVtvDzLwSGl6zkd9mTzQStIy7fO9D6aRw1Cpko/g0RMmm3j9Nlol0eavouguQCP X-Exchange-RoutingPolicyChecked: aqDRODeNufUrgnXV38EPLEvbdRD/JfTTfWN0YmKXS4Nwzt6HwyMTRI+vXIhDOv71xLzzyJ0PMJg1YybQt/SfgLNrrLSaB3n/J3ptZPNDAez2Zf14jgD6jw43LWwgktIPLkf/MAThyjjALp1SenNOAkCrsPPy/VoMDSpMmXXxa32C3Ls9+7fz3knYZE6HNM4zAXCe4kJ18U5NysxNIp5qtUBRjoowSNgp4QCIHyPgGlMbYQjUB41rtfFJkD9ncyG/o6FnAlAsjK7Lt5kRAcdn8p63AGwVwHivV7hXZVXch3AgaUOkGSKQMgUEe2PZ2+36ZAAzhFtWU48UqYvJQzW5+w== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Aug 2026 11:49:36.6436 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 416628e3-10b2-4d91-3df8-08deff7a4685 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: CH1PEPF0000AD7B.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR10MB6865 X-Authority-Analysis: v=2.4 cv=O7AJeh9W c=1 sm=1 tr=0 ts=6a883b55 cx=c_pps a=1QNZTIC90Jmhh4/qmb3rWg==:117 a=tJyPKKxUohctrY4NYmUjkA==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=Sv0fKeRqtYgA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=gO1vWkAQAl3rybz1DQOp:22 a=P-IC7800AAAA:8 a=sozttTNsAAAA:8 a=2vpyfyhlguDYHLkT4YcA:9 a=d3PnA9EDa4IxuAV0gXij:22 X-Proofpoint-ORIG-GUID: lE1KpSXJQPdrNgMKUPmzA-g7jp4YTHzb X-Proofpoint-GUID: lE1KpSXJQPdrNgMKUPmzA-g7jp4YTHzb X-Proofpoint-Spam-Info: AW1haW4tMjYwODIxMDA5MCBTYWx0ZWRfX56Cq657ya1dn MBlNlRRR2CyfFXzJfNKcjaTuLyPuOwCQpRQ2NbHTHiZHVuK5ULQ2GTZ0C6gsWNe8k/cztNl88aU hhNBA8Flk0Jr0zkq4LHy7Rzj6+kzDpM= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODIxMDA5MCBTYWx0ZWRfX4mvWxl0sBFPG 6O+Zw4HqCfjsloFpUXuINvGikUh1h5X5TQJYNvRH+FODxVBuATLwIyhGuwXlg4b7VHh3dLJax4E PdbOgpc3D/k0vAzqp1UecUfDSQLsmWpW0RY2bINktpUCfYt9jLjb1hmRhvKEBairJTBFve/rxNW X8DgsQkAC9dNbTxXv3hTceTm09bIt+W48Z3IZMbMEHDbgBWOJBVSx93eA30zYPzRd8DdS8ko74F 4+DPjPnkuFMO1vCKsF+z1tfob6Jq/HHEy0ARNL9J3crACkTIILiLQN3HT6/d3p/i1R3x4f8nhQL FucJddJxiwDT25PScc3Juw86pH7VPqcd7Pv3Y0i44G0+M9GmFpuBhDqLu3q/I2gLTAfh5YPzdnu Y8e3+8u60ZlOAJmTtxDiakar1ghjwiS2bBKTBHdC2N53vuQu0pOzXJ5tGaSk+MbcLB+lXenRLuE G8gPq55PpBd8Hk/5CaA== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-21_03,2026-08-21_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 bulkscore=0 phishscore=0 adultscore=0 suspectscore=0 lowpriorityscore=0 malwarescore=0 clxscore=1015 impostorscore=0 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608210090 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 Mon Sep 28 13:17:36 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 EEA6447CC97; Fri, 21 Aug 2026 11:49:45 +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=1787312989; cv=fail; b=P0ghE9nGdWqMbtJP3EfOJHBp7VFThIJUN9a68DYB3aDqZ2nhHx3ihKnEQ7dpI9G+QOQ7NJv4Y50WzvUiSQ25xQ14serewxLJ+vA5mMC99NnQLusmtGZ+NfKmeDm3T9fmqa1jrzAvx4nsrKquMLQ6X6H+I2J3M2WrTGKVee8nJoo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787312989; c=relaxed/simple; bh=nHERynUITfg5e3Nh2yAHKyBReZZf4m9KBYLOhEczroA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=D0rTlbIfi6ULrozjCc8tc7kEJ77t7QWV54fKE7IIgERESylyNDYHVh0uS3CcOaJ28jWC49i4T2XswpnASU+1YzhLq6k96hS1t5WStBr1cs49q4Ku6tJJXbEhDzpY9H9F7x4M+vU7OdXhiiC29Qt2YHWJO2dz9ei2fQ0LMD7X9IA= 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=m1hZ2JTS; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=UXokbEiP; 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="m1hZ2JTS"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="UXokbEiP" 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 67L9KnCu3056096; Fri, 21 Aug 2026 06:49:21 -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=m1hZ2JTSXadfjIxkyzEu6I2d0MVpXw1nPb7UUmVseWtzofAGWGtlY6JSr KuJRlRKhhIO9c61k6gnHrh4AxSNpbhP1HupXr2S1w+amQxVRaygz5TIOvtFifk9c 4727gSTlZdyLKl5u4ki4OT3y+YfcvOQW5sycb9k/WUHWtA3dH3FLriRkvcl/0z6B FT7r+AAj67IdDOpIK71Zs45iLicywK+fEpDXFUB97le8HZzWS3IzgZhdbuKh/eJv qmILHzzbmXuBuEckhRWA/WExHRdwE/dwvVsPiZyQLRglZWmY5+4aUFKDGGh+dp2Y jsWIJZCMo7+MbLkXDXVHomqTJEPjA== Received: from mw6pr02cu001.outbound.protection.outlook.com (mail-westus2azon11012009.outbound.protection.outlook.com [52.101.48.9]) by mx0b-0002e601.pphosted.com (PPS) with ESMTPS id 4g6c9c2t0x-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 21 Aug 2026 06:49:21 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=JqHXzjWgi0SED7pYYqz+lGYHgbo67F4Ca2mAwWhMLOU09vwq9txkRm6xvzbBefMKYQ67uZPnUv03hBXdYV/t24bpNTJgA/+Kg/Qf39N0eBqlVNCjXDkYGBNHbxnUOuxJS3E9qLNug0CQeFzcoJDiIDlrQsaIjRoyc2UZHyrVUmkUPSsSNCbMabcnXMheTE+9IDASYlsg1+Kw36QZYH0yVmbqoCIJvXwk3jJcTlEzfEvvqVBPIsiFV4pHOgApPyfGu5zCtxnT6B4AvuaQizG2tWFgwIA/XRnBD4OmLr3B2elJ2kp4X+aLevI+IyvELX8/xkosXnSbqWqTOUVPpbVl9g== 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=xyzUfl1QjDM6qvt54B4YugYBuJC+g7BUvynbhHU1eGSAnB/7gOfO8vUiPrZbz41VbtKU4uM9vCwe+hv70q1Cml75hC5ZgYLW19j4PNviU5Xx5dtpCas8hdGmifOm6Vtv+9VILNu56qxxdiBEFU7rDMsg6fXUodL8g6LKxSoanw0QyztYoKLS1zBKSy3QeOquzloZrYiKcpLDRgErHKkyPvHqRLdgcJkIllAsPd6iHvYzIXKpdqCbJI3VdQlUz0ViexEzdfmvt2KNJeZ+slcbjF2HtA9/i3WQN8TTLEcO3gzXgtzMgBMxHcy9UghqAVncSFgnZP2XAz4gsxEvhgnjdA== 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=UDgIqenZB3DR5a29o3tuvANtwgRl7SpThCxLM+b+1nQ=; b=UXokbEiPWYagxJ+uuY488XZ7Oz8mip9WKUFlbyDHQT+dWSO8J0Hu7FCC0s9kAnNNy+biJ4EuvsSXkKFEgJ6Q7k3UIPWV81kfLHsIupa2Jm0Mvhx4dd1Ig26tDVbaKuMNP3OxGVokwHgMha4iP24N/TgxUm2BsPdnhoRKHn9whaE= Received: from SJ0PR13CA0194.namprd13.prod.outlook.com (2603:10b6:a03:2c3::19) by IA4PR10MB8471.namprd10.prod.outlook.com (2603:10b6:208:55e::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.339.11; Fri, 21 Aug 2026 11:49:16 +0000 Received: from BY1PEPF0001AE1D.namprd04.prod.outlook.com (2603:10b6:a03:2c3:cafe::6e) by SJ0PR13CA0194.outlook.office365.com (2603:10b6:a03:2c3::19) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.360.4 via Frontend Transport; Fri, 21 Aug 2026 11:49:15 +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 BY1PEPF0001AE1D.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.360.3 via Frontend Transport; Fri, 21 Aug 2026 11:49:15 +0000 Received: from DLEE212.ent.ti.com (157.170.170.114) by lewvzet201.ext.ti.com (10.4.14.104) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Fri, 21 Aug 2026 06:49:15 -0500 Received: from DLEE205.ent.ti.com (157.170.170.85) 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.45; Fri, 21 Aug 2026 06:49:15 -0500 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) by DLEE205.ent.ti.com (157.170.170.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45 via Frontend Transport; Fri, 21 Aug 2026 06:49:15 -0500 Received: from santhoshkumark.dhcp.ti.com (santhoshkumark.dhcp.ti.com [10.24.52.55]) by lelvem-mr06.itg.ti.com (8.18.1/8.18.1) with ESMTP id 67LBmVli2022942; Fri, 21 Aug 2026 06:49:10 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , , Subject: [PATCH v8 07/18] spi: cadence-quadspi: add DQS support to read data capture Date: Fri, 21 Aug 2026 17:18:11 +0530 Message-ID: <20260821114822.4040338-8-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260821114822.4040338-1-s-k6@ti.com> References: <20260821114822.4040338-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-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY1PEPF0001AE1D:EE_|IA4PR10MB8471:EE_ X-MS-Office365-Filtering-Correlation-Id: b71bbbd6-029f-4d2a-10e5-08deff7a3a14 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|23010399003|1800799024|376014|7416014|82310400026|36860700016|10067099003|56012099006|18002099003|22082099003|921020; X-Microsoft-Antispam-Message-Info: 4AIMtUKi9q9mNBimIuDa/3Vz865Oks66vpuvQn7mc1dD3qVJg3A8CLA04QPsxhrcZEXJc/PNtZ6/ltJdzggkkXcCqghXSJSVapoh7zuyEp/U9s0aBiKphc18mRA4OH/iaP86F9m72lSzzz0wsh6R/1NlAq0poiVqh8B8fqO3ngq3eI+LQxNtRVx+n+03ZIie3Nm6xTvGEwk9ur0aBDiB5vx4a5jsuhitjICh09m/Pgikz316OIC6/TAR3pehyuJikDJ1ymJEs9i+OtPe0qccn0K4rl/W5eNYDCxjLGXZtyIutuJv3hm45nxYZpzsxaSkBTcYxp2UKIeIwCBZL+kNBA2feOXHbX6T0XD3LIDr8YHF/u6a1G/i0qPJsxv1R/0SZ6eCu5ahtz8eHZoqC4brqtrqaTxPUydSeMvN8wNKvLI49eWeBfos3Yl9OpgWUJoe880JhP5Ais9Xckb36JCiim9N2y99cHPPgxvn0BfXJ7U+ABYAqOtddI08JZIp9AhdPWzGTGM4kDYzmJ4hOZcei909I5DBk59yu8U4E4XG6VZBmOHfYmBR9INdCNwuEdVk8X603d+f0pMZI9CiqhiDsVylycyJx+KA3GGAMbWxDZcBW6PvcGNP5yk1o9rx4E5YEaf8ZFSTFpN1g0K5oWHy/iqjBMoHbnT4iA8apTKaoMWRErweFHEKoPeQrx16R9wT9V3nU01owgAA88dHKL8oamPlHVP8LAWLFJcrhOxqMrTl83mMVGdF5nsvnZ0m59ni X-Forefront-Antispam-Report: CIP:198.47.23.195;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:lewvzet201.ext.ti.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(23010399003)(1800799024)(376014)(7416014)(82310400026)(36860700016)(10067099003)(56012099006)(18002099003)(22082099003)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: nPN8ryrxk2jN8eX8GI3qbqhzHBahEWYCemOHjwSa7T2+mrI4G8BR1sSmSywibyFmz3fWy6608wWQ1DgBcdsBagzfFtvWdrv99G96IAxeM5E9njHwjJiwzVgofb4t7wEYN18gFDXw+v4GVf8DS//M7t9ROdJHL5kbgipLMIPo8eT6r9992dLcDdpqWW5VvvO4RmnwBriH9WskcZHPu5u1OhXQfW1naX0s1bYIhwhgIjvRFnBRr0j/P00D0CRf6vUBZl3WKuu/jiTbCCVyyK1tleF+4vSiJNTTDhz+wVianRaqzjCpILgyM0RwRHP6EPUnlXBzT0HlVqa7OrISMALzwSOibmSNPNdw8lIMMoqJZwU1L+7TFTFGZVdK/34H/iEwUVxZPAQS2814A/2mmpIcuQsVDXHbnUMPBVd2zGyfNEz45aVDC/HZ2B7RSUVokH44 X-Exchange-RoutingPolicyChecked: TS58fT4caH1aSXSd57ycLd1xiJFbE9nsvir3CyotAblsbLhporfsXX7t3glwWFpnhEME8LzEvxH2ClJV1o5ydmg3VqFEiS6IVzVDyGNyqYFZEokyxrHSUqQgXLtcP0raUYwHzIXHLLf08Mgyew6F6PepEu50JIMWX9V3J8LpoogH6hk6hu6WnflLtXc/fvcqXvdIDagOm8LPwSOEt1eLV+g3dyd1UqmE5psZNX4Kga8OR1oANvZRRXyKlA3OX4vlyBgUy9/2TgdHuVCH7D0looK+slRCBGPPQKBdM3pHeBGE1H+nkL2XDtU/1i402Abu45V6Dl2pdwlqm8MnUtAzHA== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Aug 2026 11:49:15.7334 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b71bbbd6-029f-4d2a-10e5-08deff7a3a14 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: BY1PEPF0001AE1D.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA4PR10MB8471 X-Proofpoint-GUID: CIL5f26xvuQTDNk9oE7LN7JANKNkPeih X-Proofpoint-Spam-Info: AW1haW4tMjYwODIxMDA4OSBTYWx0ZWRfXwebF2VhedOLX z1HY1ihqS5E/d81i3txaw6FYm9v13Hlv3JP89RQu5hfkMKLwHV9s6pNwUQqQkreqNS5qbOYUwNs SUi0UKkGViLHa+HNyHEjy+k2DthOEo0= X-Authority-Analysis: v=2.4 cv=eqjvCIpX c=1 sm=1 tr=0 ts=6a883b41 cx=c_pps a=zrdfMquBAX+f6GZXohoIpQ==:117 a=f+v6EHfkeJbVwR46tk4DMg==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=Sv0fKeRqtYgA:10 a=s63m1ICgrNkA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=jwouBfj2j3NM8CExmVVE:22 a=P-IC7800AAAA:8 a=sozttTNsAAAA:8 a=by1YfaDFVIW1-MDklf4A:9 a=d3PnA9EDa4IxuAV0gXij:22 X-Proofpoint-ORIG-GUID: CIL5f26xvuQTDNk9oE7LN7JANKNkPeih X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODIxMDA4OSBTYWx0ZWRfX8l0NmG2taehu Spe71wEuzIocz2VnE+zrD7z+qfA1cCqcKy7xE6Ey3fQbiPSPqcJbZBZr+aZgsciZCvJvLb743bg MIZoJ/56gyiEmUFNJ4QbsnpTx3fYvtjBS+d7ri7CevmeK0mpAbDQkjY1fyZHFi6WNoEEFBmd0Su SEcUai3sSRgVZbio9cT6HyXxzJwgGH9ohTVSaP4VM6YW/koUFMt2MzwbSZHut2R3BaWA1NwHxtR G6O4JLWU/lU+zXOLRZvSEYJujgBCNudjzjIy+omdSt+Ww+hnJ/otf5N75NYjFd21AjgJFKiug8f qFBU0n//zvy/qnB2c9DeWC611HbleNBtS7JPoFBrT+ckdhSacbaSycyBdCBsZ2KGHQQ5oS736eE 8qqKSIBUpqhmb5dRvha79uwwzOPJpMxCHFlyDh4AmzinZ6Yvg/dUNGSvBcQ5FqGNubr+MHdNoh7 +8+K635Lc2SkLz4lL4Q== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-21_03,2026-08-21_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 impostorscore=0 suspectscore=0 phishscore=0 spamscore=0 adultscore=0 clxscore=1015 lowpriorityscore=0 bulkscore=0 priorityscore=1501 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608210089 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 Mon Sep 28 13:17:36 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 D9507492180; Fri, 21 Aug 2026 11:50:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=148.163.150.75 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787313024; cv=fail; b=Pfk7EYZlX5BfOgUjW07ZRSrAMw5elCfa/1FrWoLa68nMe1kuNIzdLEyjzVvX1C+QydP8Pp0E/iZDvE8jdctlVcLScCtZ1kIlY/WLph+ToSXl+5fAy+jBjMESqLDSEWn/fRqmSLTSPdz1OjmdQjClnGw7aKl5n9dEJIhi2ul60XE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787313024; c=relaxed/simple; bh=Pl8i4JrMF60JOyauZ+C6d7yyCiQG3W4ly9ddC1MuAjA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=q8PXxyEBKLGbRcPJVwECzJ+nkK+Du8R5C/kkpWwK7fSgVQaPZH2i/sT9COSkRdxgoz3u00UwnXcMQV3sjZvLKRpwpIo6HSRe60EJM9F9j1J5mqiKFYUnx7h0bbeURO8kqKWl5zl0FdWxOUajXlRmbFAZxUlj73UMiuUdV8KA+Do= 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=nCze5ZAj; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=g3BhBQs8; 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="nCze5ZAj"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="g3BhBQs8" 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 67L9KN2Y3254934; Fri, 21 Aug 2026 06:49:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint-05-2026; bh=XKqZb514dU3Fr2ET9vB1QaHriVkBPOLEhjAauNEn8 iE=; b=nCze5ZAjpvl+By2hvhG0Rc4Mdm2gP7QvfC4HSg2uXjlJODlfUe5/HFZyu v+Zbc1Rlr75U41XYQKfywGACvraeQHiJW5qR9Ez0BjYgcUTUmyYMbAPKXJW0UHW8 vM1BtDPmbB2DccqeXUhsR3JeOsPTtIeJhe5d2xW/cwlyigwK0K9ATLC609/ZiFsA H6EoBs/3j719Av7p0Ca8kxEHF+ecnNIF/r2x99KH5aZdYd8jv+dwgwFlN3bgLtLe Kfa/bH2p25cpfFaQLrNVD7fLjQf1eiflC2mSyaAb1kyVUus++QP3iA2D2sJyPv8u PSaJeH5qSA62rnRJcHdW4pwQAHbmg== Received: from cy3pr05cu001.outbound.protection.outlook.com (mail-westcentralusazon11013034.outbound.protection.outlook.com [40.93.201.34]) by m0380145.ppops.net (PPS) with ESMTPS id 4g6hfk1dg1-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 21 Aug 2026 06:49:56 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=o8oijUe+MzzxezEMTkJ3jmimQp26Dbhv51uWmV9h3wR1RTpPvti6gEp970kLSNKdP8Hav97aKkWzFXKdAxBi4Ncky4WjTTz2z8GBBXoRwARNCHiBKU8qxTxqGnNJOv/y5DONrJDHSXfhMWwMo7U39Ttz4paAYBIF1NyvwWJmYkGgz7zN35clTmbUgfe4G/XAHqRb/gALQp65T/YD960lztfynGG7Phbqzri2JeSno468Z6qjjhCGk6BIP75v27c0bXzVKLJQe/ZDpIyln3BaQulBddpkAPczar773dwygmhepb5qtWfs8ip8zD54lbmjtVBCY84LTHphq+X5g+k5cA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=XKqZb514dU3Fr2ET9vB1QaHriVkBPOLEhjAauNEn8iE=; b=E4Tktghm7ZnZOhkbteSxK93OOEKG/nryZ/HBYMs6C+Iv5gwvlawENA4aZbXSbbvVZVESinho7O95fIl9QHuN8objpWvWtUXMqYyKeaeEc7nmfNx1KOm++JZ5+j2ylJpAJwuwTVJh//oKmpfN7izVdVP1G89YAx77K7NizkROLJbzCVfFseK1g9/301uivZw/CfF3O3TorGNQXY2UJAE/vBGa9/boaEPqQu6T8eWaM56k9+nZ7tCNmx/r/aw6c9nWycMoYV9xQ+vKWFU/psvKHMFbMqvT4u2oEmpn95hY1TRylPEklTEsqDCTC+jAGkf2bqHP+AAc+MuXMb5m1TuGiA== 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=XKqZb514dU3Fr2ET9vB1QaHriVkBPOLEhjAauNEn8iE=; b=g3BhBQs8uqGWfc+RXAUKN10i5b640Zrec065yMPE4D3B9sYz/Jd5+VqoqOGNk/ciu8RspW5N4sx6AByF+o4l7EIJPEmYzqLqC5e7lJmHOKRsms06eGltMNKeKrYpjLQEWBRE7hZjrkqi3HBRy5VNwVoEjxibOMADQXhOzz2bu78= Received: from CH5P221CA0002.NAMP221.PROD.OUTLOOK.COM (2603:10b6:610:1f2::27) by SJ0PR10MB4702.namprd10.prod.outlook.com (2603:10b6:a03:2af::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.339.11; Fri, 21 Aug 2026 11:49:50 +0000 Received: from CH1PEPF0000AD7B.namprd04.prod.outlook.com (2603:10b6:610:1f2:cafe::24) by CH5P221CA0002.outlook.office365.com (2603:10b6:610:1f2::27) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.339.11 via Frontend Transport; Fri, 21 Aug 2026 11:49:50 +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 CH1PEPF0000AD7B.mail.protection.outlook.com (10.167.244.58) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.360.3 via Frontend Transport; Fri, 21 Aug 2026 11:49:49 +0000 Received: from DFLE207.ent.ti.com (10.64.6.65) by flwvzet201.ext.ti.com (10.248.192.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Fri, 21 Aug 2026 06:49:21 -0500 Received: from DFLE201.ent.ti.com (10.64.6.59) 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.45; Fri, 21 Aug 2026 06:49:20 -0500 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) by DFLE201.ent.ti.com (10.64.6.59) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45 via Frontend Transport; Fri, 21 Aug 2026 06:49:20 -0500 Received: from santhoshkumark.dhcp.ti.com (santhoshkumark.dhcp.ti.com [10.24.52.55]) by lelvem-mr06.itg.ti.com (8.18.1/8.18.1) with ESMTP id 67LBmVlj2022942; Fri, 21 Aug 2026 06:49:15 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , , Subject: [PATCH v8 08/18] spi: cadence-quadspi: add PHY tuning support Date: Fri, 21 Aug 2026 17:18:12 +0530 Message-ID: <20260821114822.4040338-9-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260821114822.4040338-1-s-k6@ti.com> References: <20260821114822.4040338-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-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000AD7B:EE_|SJ0PR10MB4702:EE_ X-MS-Office365-Filtering-Correlation-Id: c0bc1ee4-0a13-4e46-6c9c-08deff7a4de4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|1800799024|36860700016|82310400026|23010399003|22082099003|921020|18002099003|13003099007|3023799007|56012099006|10067099003|6133799003; X-Microsoft-Antispam-Message-Info: OH49ZXskFbgLg7C8E4EzwVFD2k70Sl02xMhh0aZyDBxadV3O59L0svW9HbvoAN8GF0jQeC/JAb0G8GZTFGGJ2b8sFMT96d++SOAMoAofwi2Dk9/M6eW6lFA/5jPCdvdzzZJg5poodlahcLpcKhvwdYhD+IK0yaBDxzmDyD8Rl3at+Se8P8bh97ZRWwhYLO6l8hudkmsdI33Kub8NPtD2pAyX/AqK79TRLN/o1QkcyqnSsAFuy6ayhM5atDuHx+U1q+ztiUFIgritW/qUs1ZAdfZOUALEjGR8uHPc/06GpqmC7PkCjxrRrNomFyy9ndSSRDnYNhjDs4gsKiWqni6UFZUU/NB7bvnFacLHO7zzFdicCrNd1cGLGA6G0paRSqnlYRiitoH/kHlgaZAu3HsOOBBFQj27vhKBs954SxDZqogqaSaEF6MScjVRNnS0DSx5X7xNkbc2GitIb7y9Asz0t9tgeb0FAk1jvYI5Lq91A1Uak8PqRSMi6ulwRv0TNILKUgPX+OnJCkA9psVbjQhT79jjsIxIoAHoyRk2WsO8YdQtq46mC6I3LIX3UdXvjTViBavwveQkany3JcmxrV/JUwiPsjCxMJAlDVaJ466AFBzOD3o0UnrPfXkexXMmNA5OMaNUASFveom81l6oAMFPiJeAGcXGk3hivooZaDUnV1LH5fVYnDBwCJgD4Nyx0m6q 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)(1800799024)(36860700016)(82310400026)(23010399003)(22082099003)(921020)(18002099003)(13003099007)(3023799007)(56012099006)(10067099003)(6133799003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: PG9K+RR8/5bePOnERpjSNL9Yf9UiQBfKWGeVvrrvCiqc9Ensnzw7ykDx9BI6Sd6b53xxdPwbRDB0NaDtMrPWrVXrXs2UXirMJBxkAbh0b5jFmS1w661NHEzXnkW/rX0bb0FDdGLO26XRU8Jrp8CzKUJpgtsxILTWjOlMGlNxMjQJ7923xOq5Uc0tnukxzlpgbNRCyhNrrs4p20XUqNd8UYHj5yNojvMa6Kxi0Nn3GGBYTokTQ7GgLcfy47ntGjlqYZOLSIzUGO8HlXXkmBIFCOvEIunsIlRDR6D2Y7lLcj+luoqUz8DrebACIRyrzZVfWYocds4p6fLCAloj15uhFETEX8Rq7zmyOFSP9lteFxEL4RZ9mHAlklMKsL5l1VuvMyeDeDvYR1+Oi4u30lUKWH1+t+uTYTWyXjW5gKZk6Molq7pM1Pw69HlbkWseilLr X-Exchange-RoutingPolicyChecked: CqcMu+7bsmLSuCj5kBLnTdNbDp0vnPgRRTYLWdff+2jyEd5i70Ud4+zUH7Ivg2fy/6jnOxcs8nFgSW1vcAhe/YLgwblbgivrFb1gpLca8NxjjkSh4dGvSPDBlZ04UUOrvC0dHfE/Yvc3rYHlzioMaVrorQO37+vYbqDCzhSYaF0g6m5Amud1Dy4lktRtg4WpaWT+LV+4wOynYRfU0qSPLoVb5oTMKV+s5A1Xz8RMVqbC0+ZcJMu7YXZx15uTj59aQ1D6jtM/Xop/Q0+63VqNXbWk8RWmuaJeQZMJJV3YmWTYubfOYxMQZIanWJhu/7yVaZPNpTc1I5Rd794HQyGWVg== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Aug 2026 11:49:49.0039 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c0bc1ee4-0a13-4e46-6c9c-08deff7a4de4 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: CH1PEPF0000AD7B.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4702 X-Authority-Analysis: v=2.4 cv=O7AJeh9W c=1 sm=1 tr=0 ts=6a883b64 cx=c_pps a=5W5/h04s0UwUCg87NMYX9Q==:117 a=tJyPKKxUohctrY4NYmUjkA==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=IkcTkHD0fZMA:10 a=Sv0fKeRqtYgA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=gO1vWkAQAl3rybz1DQOp:22 a=sozttTNsAAAA:8 a=MlhAJnQaR0iBW2fQ34UA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 X-Proofpoint-ORIG-GUID: SUV72JpkGcJcQHUQ4g2Ca5bfFF43nM1b X-Proofpoint-GUID: SUV72JpkGcJcQHUQ4g2Ca5bfFF43nM1b X-Proofpoint-Spam-Info: AW1haW4tMjYwODIxMDA5MCBTYWx0ZWRfXzze/piZdrCLe iNuvYQzverwommtBIu+mceS67/5re6RYhfruLWpGpJSSlkS+wvKerZD15GgBQD0VtJ4U3X/mJzz qrYMy+5GGjS54+wVM7vSAD2P9+NXld0= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODIxMDA5MCBTYWx0ZWRfX5M45G7PsQE2g FEsg5JWbWGtqmU/q7oh0z+FR+OTae9dnyEKTOsELnaHef8DzK4X1eicgoYCpDPiCnFCjzzzXReY k8MJxJzqc0NUxil+LFDyguXW9wMMK8bc4kdl7e9fxHpahypuKA1t650PpbSo/tb5yKnHfUEBAQs +iW40wj/FLMgMF6j4Ns+vFLtr71PxExf0QzUx6ToGqc8PaT2oz3xu6+4vl3X9b03E89RjkkX3uH 639C5PjCqmn/tigvWJSWwAWe/0KJX8psVdwF29IgeirFmuyc/8lww5em3+ZUkruiqrzmosyz5dB NxFJWzQLsxu3FpySvsHpxYHAK2O7dAs3s2XG+IclQ2MvgAjE+s54Y0klXwBNb/vvmjPVPitDo60 KvT0w8Jf5aLRmq8bycnFb6D3vK3iCTev/mIhq4umvLJ3GNF3rim7scs1ZSOHrvRM4meGQfv4+ac pGmQsR5p5PX+jJXXVJA== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-21_03,2026-08-21_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 bulkscore=0 phishscore=0 adultscore=0 suspectscore=0 lowpriorityscore=0 malwarescore=0 clxscore=1015 impostorscore=0 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608210090 The Cadence QSPI controller supports a delay-line PHY for high-speed operation. Without calibration the PHY is unused and read capture relies on a fixed delay, limiting throughput at frequencies above the base operating speed. Add an execute_tuning callback that performs delay-line calibration using a known data pattern written to a dedicated flash region. The pattern is either read from a NOR partition identified by the DT property spi-phy-pattern-partition, or written to the NAND page cache before each calibration read. For DDR protocols (8D-8D-8D) a 2D sweep of (rx_delay, tx_delay) pairs is performed to find the widest passing region in the combined RX/TX space. Binary search locates the gap boundary between passing regions when two separate windows exist; the final operating point is placed at the centre of the larger region with a small temperature-dependent offset. For SDR protocols a 1D sweep of the RX delay is sufficient. Two windows at adjacent read_delay values are measured; the wider one's midpoint is selected. The tuning infrastructure is platform-specific: only am654-based OSPI controllers populate the execute_tuning hook. All other platform data entries return -EOPNOTSUPP and are unaffected. The calibration target is sourced from spi->post_config_max_speed_hz, populated by the SPI core from the spi-max-post-config-frequency-hz DT property. Tuning is skipped when post_config_max_speed_hz is zero. Signed-off-by: Santhosh Kumar K --- drivers/spi/spi-cadence-quadspi.c | 1769 ++++++++++++++++++++++++++++- 1 file changed, 1756 insertions(+), 13 deletions(-) diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-qu= adspi.c index 046fa5d69b0f..5651320426b1 100644 --- a/drivers/spi/spi-cadence-quadspi.c +++ b/drivers/spi/spi-cadence-quadspi.c @@ -6,6 +6,7 @@ // Copyright Intel Corporation (C) 2019-2020. All rights reserved. // Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com =20 +#include #include #include #include @@ -65,15 +66,27 @@ enum { =20 struct cqspi_st; =20 +struct phy_setting { + u8 rx; + u8 tx; + u8 read_delay; +}; + struct cqspi_flash_pdata { - struct cqspi_st *cqspi; - u32 clk_rate; - u32 read_delay; - u32 tshsl_ns; - u32 tsd2d_ns; - u32 tchsh_ns; - u32 tslch_ns; - u8 cs; + struct cqspi_st *cqspi; + u32 read_delay; + u32 tshsl_ns; + u32 tsd2d_ns; + u32 tchsh_ns; + u32 tslch_ns; + bool use_dqs; + bool use_tuned_phy; + u8 cs; + struct phy_setting phy_setting; + struct spi_mem_op phy_read_op; + struct spi_mem_op phy_write_op; + u32 phy_pattern_partition_offset; + bool phy_pattern_partition_valid; }; =20 static const struct clk_bulk_data cqspi_clks[CLK_QSPI_NUM] =3D { @@ -117,6 +130,8 @@ struct cqspi_st { bool is_jh7110; /* Flag for StarFive JH7110 SoC */ bool is_rzn1; /* Flag for Renesas RZ/N1 SoC */ bool disable_stig_mode; + bool phy_tuning_active; + u8 phy_saved_dummy; refcount_t refcount; refcount_t inflight_ops; =20 @@ -129,12 +144,15 @@ struct cqspi_driver_platdata { int (*indirect_read_dma)(struct cqspi_flash_pdata *f_pdata, u_char *rxbuf, loff_t from_addr, size_t n_rx); u32 (*get_dma_status)(struct cqspi_st *cqspi); + int (*execute_tuning)(struct spi_mem *mem, struct spi_mem_op *read_op, + struct spi_mem_op *write_op); }; =20 /* Operation timeout value */ #define CQSPI_TIMEOUT_MS 500 #define CQSPI_READ_TIMEOUT_MS 10 #define CQSPI_BUSYWAIT_TIMEOUT_US 500 +#define CQSPI_DLL_TIMEOUT_US 300 =20 /* Runtime_pm autosuspend delay */ #define CQSPI_AUTOSUSPEND_TIMEOUT 2000 @@ -148,12 +166,14 @@ struct cqspi_driver_platdata { /* Register map */ #define CQSPI_REG_CONFIG 0x00 #define CQSPI_REG_CONFIG_ENABLE_MASK BIT(0) +#define CQSPI_REG_CONFIG_PHY_EN BIT(3) #define CQSPI_REG_CONFIG_ENB_DIR_ACC_CTRL BIT(7) #define CQSPI_REG_CONFIG_DECODE_MASK BIT(9) #define CQSPI_REG_CONFIG_CHIPSELECT_LSB 10 #define CQSPI_REG_CONFIG_DMA_MASK BIT(15) #define CQSPI_REG_CONFIG_BAUD_LSB 19 #define CQSPI_REG_CONFIG_DTR_PROTO BIT(24) +#define CQSPI_REG_CONFIG_PHY_PIPELINE BIT(25) #define CQSPI_REG_CONFIG_DUAL_OPCODE BIT(30) #define CQSPI_REG_CONFIG_IDLE_LSB 31 #define CQSPI_REG_CONFIG_CHIPSELECT_MASK 0xF @@ -192,6 +212,7 @@ struct cqspi_driver_platdata { #define CQSPI_REG_READCAPTURE_BYPASS_LSB 0 #define CQSPI_REG_READCAPTURE_DELAY_LSB 1 #define CQSPI_REG_READCAPTURE_DELAY_MASK 0xF +#define CQSPI_REG_READCAPTURE_EDGE_LSB 5 #define CQSPI_REG_READCAPTURE_DQS_LSB 8 =20 #define CQSPI_REG_SIZE 0x14 @@ -273,6 +294,28 @@ struct cqspi_driver_platdata { #define CQSPI_REG_POLLING_STATUS 0xB0 #define CQSPI_REG_POLLING_STATUS_DUMMY_LSB 16 =20 +#define CQSPI_REG_PHY_CONFIG 0xB4 +#define CQSPI_REG_PHY_CONFIG_RX_DEL_LSB 0 +#define CQSPI_REG_PHY_CONFIG_RX_DEL_MASK 0x7F +#define CQSPI_REG_PHY_CONFIG_TX_DEL_LSB 16 +#define CQSPI_REG_PHY_CONFIG_TX_DEL_MASK 0x7F +#define CQSPI_REG_PHY_CONFIG_DLL_RESET BIT(30) +#define CQSPI_REG_PHY_CONFIG_RESYNC BIT(31) + +#define CQSPI_REG_PHY_DLL_MASTER 0xB8 +#define CQSPI_REG_PHY_DLL_MASTER_INIT_DELAY_LSB 0 +#define CQSPI_REG_PHY_DLL_MASTER_INIT_DELAY_MASK 0x7f +#define CQSPI_REG_PHY_DLL_MASTER_INIT_DELAY_VAL 16 +#define CQSPI_REG_PHY_DLL_MASTER_DLY_ELMTS_LEN 0x7 +#define CQSPI_REG_PHY_DLL_MASTER_DLY_ELMTS_LSB 20 +#define CQSPI_REG_PHY_DLL_MASTER_DLY_ELMTS_3 0x2 +#define CQSPI_REG_PHY_DLL_MASTER_BYPASS BIT(23) +#define CQSPI_REG_PHY_DLL_MASTER_CYCLE BIT(24) + +#define CQSPI_REG_DLL_OBS_LOW 0xBC +#define CQSPI_REG_DLL_OBS_LOW_DLL_LOCK BIT(0) +#define CQSPI_REG_DLL_OBS_LOW_LOOPBACK_LOCK BIT(15) + #define CQSPI_REG_OP_EXT_LOWER 0xE0 #define CQSPI_REG_OP_EXT_READ_LSB 24 #define CQSPI_REG_OP_EXT_WRITE_LSB 16 @@ -321,6 +364,50 @@ struct cqspi_driver_platdata { =20 #define CQSPI_REG_VERSAL_DMA_VAL 0x602 =20 +#define CQSPI_PHY_INIT_RD 1 +#define CQSPI_PHY_MAX_RD 4 +#define CQSPI_PHY_MAX_DELAY 127 +#define CQSPI_PHY_DDR_SEARCH_STEP 4 +#define CQSPI_PHY_TX_LOOKUP_LOW_START 28 +#define CQSPI_PHY_TX_LOOKUP_LOW_END 48 +#define CQSPI_PHY_TX_LOOKUP_HIGH_START 60 +#define CQSPI_PHY_TX_LOOKUP_HIGH_END 96 +#define CQSPI_PHY_RX_LOW_SEARCH_START 0 +#define CQSPI_PHY_RX_LOW_SEARCH_END 40 +#define CQSPI_PHY_RX_HIGH_SEARCH_START 24 +#define CQSPI_PHY_RX_HIGH_SEARCH_END 127 +#define CQSPI_PHY_TX_LOW_SEARCH_START 0 +#define CQSPI_PHY_TX_LOW_SEARCH_END 64 +#define CQSPI_PHY_TX_HIGH_SEARCH_START 78 +#define CQSPI_PHY_TX_HIGH_SEARCH_END 127 +#define CQSPI_PHY_SEARCH_OFFSET 8 + +#define CQSPI_PHY_DEFAULT_TEMP 45 +#define CQSPI_PHY_MIN_TEMP -45 +#define CQSPI_PHY_MAX_TEMP 130 +#define CQSPI_PHY_MID_TEMP (CQSPI_PHY_MIN_TEMP + \ + ((CQSPI_PHY_MAX_TEMP - \ + CQSPI_PHY_MIN_TEMP) / 2)) + +/* + * PHY tuning pattern for calibrating read data capture delay. This 128-by= te + * pattern provides sufficient bit transitions across all byte lanes to + * reliably detect timing windows at high frequencies. + */ +static const u8 phy_tuning_pattern[] __aligned(64) =3D { + 0xFE, 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0xFE, 0xFE, 0x01, + 0x01, 0x01, 0x01, 0x00, 0x00, 0xFE, 0xFE, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0x00, 0x00, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFE, + 0xFE, 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0xFE, 0x00, 0xFE, 0xFE, 0x01, + 0x01, 0x01, 0x01, 0xFE, 0x00, 0xFE, 0xFE, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFE, 0x00, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0x00, 0xFE, + 0xFE, 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0xFE, 0xFE, 0xFE, 0x01, + 0x01, 0x01, 0x01, 0x00, 0xFE, 0xFE, 0xFE, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0x00, 0xFE, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFE, 0xFE, + 0xFE, 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0xFE, 0xFE, 0xFE, 0xFE, 0x01, + 0x01, 0x01, 0x01, 0xFE, 0xFE, 0xFE, 0xFE, 0x01, +}; + static int cqspi_wait_for_bit(const struct cqspi_driver_platdata *ddata, void __iomem *reg, const u32 mask, bool clr, bool busywait) @@ -913,6 +1000,76 @@ static void cqspi_controller_enable(struct cqspi_st *= cqspi, bool enable) writel(reg, reg_base + CQSPI_REG_CONFIG); } =20 +static void cqspi_set_dll(void __iomem *reg_base, u8 rx_dll, u8 tx_dll) +{ + unsigned int reg; + + reg =3D readl(reg_base + CQSPI_REG_PHY_CONFIG); + reg &=3D ~((CQSPI_REG_PHY_CONFIG_RX_DEL_MASK + << CQSPI_REG_PHY_CONFIG_RX_DEL_LSB) | + (CQSPI_REG_PHY_CONFIG_TX_DEL_MASK + << CQSPI_REG_PHY_CONFIG_TX_DEL_LSB)); + reg |=3D ((rx_dll & CQSPI_REG_PHY_CONFIG_RX_DEL_MASK) + << CQSPI_REG_PHY_CONFIG_RX_DEL_LSB) | + ((tx_dll & CQSPI_REG_PHY_CONFIG_TX_DEL_MASK) + << CQSPI_REG_PHY_CONFIG_TX_DEL_LSB) | + CQSPI_REG_PHY_CONFIG_RESYNC; + writel(reg, reg_base + CQSPI_REG_PHY_CONFIG); +} + +static int cqspi_resync_dll(struct cqspi_st *cqspi) +{ + void __iomem *reg_base =3D cqspi->iobase; + unsigned int reg; + int ret; + + ret =3D cqspi_wait_idle(cqspi); + if (ret) + return ret; + + reg =3D readl(reg_base + CQSPI_REG_CONFIG); + reg &=3D ~CQSPI_REG_CONFIG_ENABLE_MASK; + writel(reg, reg_base + CQSPI_REG_CONFIG); + + reg =3D readl(reg_base + CQSPI_REG_PHY_CONFIG); + reg &=3D ~(CQSPI_REG_PHY_CONFIG_DLL_RESET | CQSPI_REG_PHY_CONFIG_RESYNC); + writel(reg, reg_base + CQSPI_REG_PHY_CONFIG); + + reg =3D readl(reg_base + CQSPI_REG_PHY_DLL_MASTER); + reg &=3D ~(CQSPI_REG_PHY_DLL_MASTER_INIT_DELAY_MASK + << CQSPI_REG_PHY_DLL_MASTER_INIT_DELAY_LSB); + reg |=3D (CQSPI_REG_PHY_DLL_MASTER_INIT_DELAY_VAL + << CQSPI_REG_PHY_DLL_MASTER_INIT_DELAY_LSB); + writel(reg, reg_base + CQSPI_REG_PHY_DLL_MASTER); + + reg =3D readl(reg_base + CQSPI_REG_PHY_CONFIG); + reg |=3D CQSPI_REG_PHY_CONFIG_DLL_RESET; + writel(reg, reg_base + CQSPI_REG_PHY_CONFIG); + + ret =3D readl_poll_timeout(reg_base + CQSPI_REG_DLL_OBS_LOW, reg, + (reg & CQSPI_REG_DLL_OBS_LOW_DLL_LOCK), 0, + CQSPI_DLL_TIMEOUT_US); + if (ret) + goto re_enable; + + ret =3D readl_poll_timeout(reg_base + CQSPI_REG_DLL_OBS_LOW, reg, + (reg & CQSPI_REG_DLL_OBS_LOW_LOOPBACK_LOCK), 0, + CQSPI_DLL_TIMEOUT_US); + if (ret) + goto re_enable; + + reg =3D readl(reg_base + CQSPI_REG_PHY_CONFIG); + reg |=3D CQSPI_REG_PHY_CONFIG_RESYNC; + writel(reg, reg_base + CQSPI_REG_PHY_CONFIG); + +re_enable: + reg =3D readl(reg_base + CQSPI_REG_CONFIG); + reg |=3D CQSPI_REG_CONFIG_ENABLE_MASK; + writel(reg, reg_base + CQSPI_REG_CONFIG); + + return ret; +} + static int cqspi_versal_indirect_read_dma(struct cqspi_flash_pdata *f_pdat= a, u_char *rxbuf, loff_t from_addr, size_t n_rx) @@ -1323,8 +1480,9 @@ static void cqspi_configure(struct cqspi_flash_pdata = *f_pdata, cqspi->sclk =3D sclk; cqspi_config_baudrate_div(cqspi); cqspi_delay(f_pdata); - cqspi_readdata_capture(cqspi, !cqspi->rclk_en, false, - f_pdata->read_delay); + if (!cqspi->phy_tuning_active) + cqspi_readdata_capture(cqspi, !cqspi->rclk_en, false, + f_pdata->read_delay); } =20 if (switch_cs || switch_ck) @@ -1559,10 +1717,1590 @@ static bool cqspi_supports_mem_op(struct spi_mem = *mem, return spi_mem_default_supports_op(mem, op); } =20 +static int cqspi_write_pattern_to_cache(struct cqspi_flash_pdata *f_pdata, + struct spi_mem *mem, + const struct spi_mem_op *write_op) +{ + struct spi_controller *ctlr =3D mem->spi->controller; + struct device *dev =3D &f_pdata->cqspi->pdev->dev; + struct spi_mem_op op =3D *write_op; + int ret; + + op.max_freq =3D mem->spi->max_speed_hz; + op.data.nbytes =3D sizeof(phy_tuning_pattern); + op.data.buf.out =3D phy_tuning_pattern; + + ret =3D ctlr->mem_ops->exec_op(mem, &op); + if (ret) { + dev_err(dev, "Failed to write PHY pattern to cache: %d\n", ret); + return ret; + } + dev_dbg(dev, "PHY pattern (%zu bytes) written to cache\n", + sizeof(phy_tuning_pattern)); + + return 0; +} + +static int cqspi_phy_check_pattern(struct cqspi_flash_pdata *f_pdata, + struct spi_mem *mem) +{ + struct spi_controller *ctlr =3D mem->spi->controller; + struct spi_mem_op op; + u8 *read_data; + int ret; + + read_data =3D kmalloc_array(ARRAY_SIZE(phy_tuning_pattern), + sizeof(phy_tuning_pattern[0]), GFP_KERNEL); + if (!read_data) + return -ENOMEM; + + op =3D f_pdata->phy_read_op; + op.data.buf.in =3D read_data; + op.data.nbytes =3D sizeof(phy_tuning_pattern); + + ret =3D ctlr->mem_ops->exec_op(mem, &op); + if (ret) + goto out; + + if (memcmp(read_data, phy_tuning_pattern, sizeof(phy_tuning_pattern))) + ret =3D -EAGAIN; + +out: + kfree(read_data); + return ret; +} + +static void cqspi_phy_set_dll_master(struct cqspi_st *cqspi) +{ + void __iomem *reg_base =3D cqspi->iobase; + unsigned int reg; + + reg =3D readl(reg_base + CQSPI_REG_PHY_DLL_MASTER); + reg &=3D ~((CQSPI_REG_PHY_DLL_MASTER_DLY_ELMTS_LEN + << CQSPI_REG_PHY_DLL_MASTER_DLY_ELMTS_LSB) | + CQSPI_REG_PHY_DLL_MASTER_BYPASS | + CQSPI_REG_PHY_DLL_MASTER_CYCLE); + reg |=3D ((CQSPI_REG_PHY_DLL_MASTER_DLY_ELMTS_3 + << CQSPI_REG_PHY_DLL_MASTER_DLY_ELMTS_LSB) | + CQSPI_REG_PHY_DLL_MASTER_CYCLE); + + writel(reg, reg_base + CQSPI_REG_PHY_DLL_MASTER); +} + +static void cqspi_phy_pre_config(struct cqspi_st *cqspi, + struct cqspi_flash_pdata *f_pdata, + const bool bypass) +{ + void __iomem *reg_base =3D cqspi->iobase; + unsigned int reg; + u8 dummy; + + cqspi->phy_tuning_active =3D true; + + cqspi_readdata_capture(cqspi, bypass, f_pdata->use_dqs, + f_pdata->phy_setting.read_delay); + + reg =3D readl(reg_base + CQSPI_REG_CONFIG); + reg &=3D ~(CQSPI_REG_CONFIG_PHY_EN | CQSPI_REG_CONFIG_PHY_PIPELINE); + reg |=3D CQSPI_REG_CONFIG_PHY_EN; + writel(reg, reg_base + CQSPI_REG_CONFIG); + + reg =3D readl(reg_base + CQSPI_REG_RD_INSTR); + dummy =3D FIELD_GET(CQSPI_REG_RD_INSTR_DUMMY_MASK + << CQSPI_REG_RD_INSTR_DUMMY_LSB, + reg); + cqspi->phy_saved_dummy =3D dummy; + if (dummy) + dummy--; + reg &=3D ~(CQSPI_REG_RD_INSTR_DUMMY_MASK << CQSPI_REG_RD_INSTR_DUMMY_LSB); + reg |=3D FIELD_PREP(CQSPI_REG_RD_INSTR_DUMMY_MASK + << CQSPI_REG_RD_INSTR_DUMMY_LSB, + dummy); + writel(reg, reg_base + CQSPI_REG_RD_INSTR); + + cqspi_phy_set_dll_master(cqspi); +} + +static void cqspi_phy_post_config(struct cqspi_st *cqspi, + const unsigned int delay) +{ + void __iomem *reg_base =3D cqspi->iobase; + unsigned int reg; + + cqspi->phy_tuning_active =3D false; + + /* + * Clear the EDGE bit set by cqspi_phy_apply_setting, then restore the + * READCAPTURE register to its non-PHY state (bypass, DQS, and delay). + */ + reg =3D readl(reg_base + CQSPI_REG_READCAPTURE); + reg &=3D ~BIT(CQSPI_REG_READCAPTURE_EDGE_LSB); + writel(reg, reg_base + CQSPI_REG_READCAPTURE); + + cqspi_readdata_capture(cqspi, !cqspi->rclk_en, false, delay); + + reg =3D readl(reg_base + CQSPI_REG_CONFIG); + reg &=3D ~(CQSPI_REG_CONFIG_PHY_EN | CQSPI_REG_CONFIG_PHY_PIPELINE); + writel(reg, reg_base + CQSPI_REG_CONFIG); + + /* Restore the original dummy cycle count saved by cqspi_phy_pre_config. = */ + reg =3D readl(reg_base + CQSPI_REG_RD_INSTR); + reg &=3D ~(CQSPI_REG_RD_INSTR_DUMMY_MASK << CQSPI_REG_RD_INSTR_DUMMY_LSB); + reg |=3D FIELD_PREP(CQSPI_REG_RD_INSTR_DUMMY_MASK + << CQSPI_REG_RD_INSTR_DUMMY_LSB, + cqspi->phy_saved_dummy); + writel(reg, reg_base + CQSPI_REG_RD_INSTR); +} + +static int cqspi_phy_apply_setting(struct cqspi_flash_pdata *f_pdata, + struct phy_setting *phy) +{ + struct cqspi_st *cqspi =3D f_pdata->cqspi; + unsigned int reg; + int ret; + + reg =3D readl(cqspi->iobase + CQSPI_REG_READCAPTURE); + reg |=3D BIT(CQSPI_REG_READCAPTURE_EDGE_LSB); + writel(reg, cqspi->iobase + CQSPI_REG_READCAPTURE); + + cqspi_set_dll(cqspi->iobase, phy->rx, phy->tx); + + ret =3D cqspi_resync_dll(cqspi); + if (ret) + return ret; + + f_pdata->phy_setting.rx =3D phy->rx; + f_pdata->phy_setting.tx =3D phy->tx; + f_pdata->phy_setting.read_delay =3D phy->read_delay; + + cqspi_readdata_capture(cqspi, !f_pdata->use_dqs, f_pdata->use_dqs, + phy->read_delay); + + return 0; +} + +static int cqspi_find_rx_low_ddr(struct cqspi_flash_pdata *f_pdata, + struct spi_mem *mem, struct phy_setting *phy) +{ + struct device *dev =3D &f_pdata->cqspi->pdev->dev; + int ret; + + do { + phy->rx =3D CQSPI_PHY_RX_LOW_SEARCH_START; + do { + ret =3D cqspi_phy_apply_setting(f_pdata, phy); + if (!ret) { + ret =3D cqspi_phy_check_pattern(f_pdata, mem); + if (!ret) + return 0; + } + + phy->rx +=3D CQSPI_PHY_DDR_SEARCH_STEP; + } while (phy->rx <=3D CQSPI_PHY_RX_LOW_SEARCH_END); + + phy->read_delay++; + } while (phy->read_delay <=3D CQSPI_PHY_MAX_RD); + + dev_dbg(dev, "Unable to find RX low\n"); + return -ENOENT; +} + +static int cqspi_find_rx_low_sdr(struct cqspi_flash_pdata *f_pdata, + struct spi_mem *mem, struct phy_setting *phy) +{ + struct device *dev =3D &f_pdata->cqspi->pdev->dev; + int ret; + + phy->rx =3D 0; + do { + ret =3D cqspi_phy_apply_setting(f_pdata, phy); + if (!ret) { + ret =3D cqspi_phy_check_pattern(f_pdata, mem); + if (!ret) + return 0; + } + phy->rx++; + } while (phy->rx <=3D CQSPI_PHY_MAX_DELAY); + + dev_dbg(dev, "Unable to find RX low\n"); + return -ENOENT; +} + +static int cqspi_find_rx_high_ddr(struct cqspi_flash_pdata *f_pdata, + struct spi_mem *mem, struct phy_setting *phy) +{ + struct device *dev =3D &f_pdata->cqspi->pdev->dev; + int ret; + + do { + phy->rx =3D CQSPI_PHY_RX_HIGH_SEARCH_END; + do { + ret =3D cqspi_phy_apply_setting(f_pdata, phy); + if (!ret) { + ret =3D cqspi_phy_check_pattern(f_pdata, mem); + if (!ret) + return 0; + } + + phy->rx -=3D CQSPI_PHY_DDR_SEARCH_STEP; + } while (phy->rx >=3D CQSPI_PHY_RX_HIGH_SEARCH_START); + + phy->read_delay--; + } while (phy->read_delay >=3D CQSPI_PHY_INIT_RD); + + dev_dbg(dev, "Unable to find RX high\n"); + return -ENOENT; +} + +static int cqspi_find_rx_high_sdr(struct cqspi_flash_pdata *f_pdata, + struct spi_mem *mem, struct phy_setting *phy, + u8 lowerbound) +{ + struct device *dev =3D &f_pdata->cqspi->pdev->dev; + int ret; + + phy->rx =3D CQSPI_PHY_MAX_DELAY; + do { + ret =3D cqspi_phy_apply_setting(f_pdata, phy); + if (!ret) { + ret =3D cqspi_phy_check_pattern(f_pdata, mem); + if (!ret) + return 0; + } + phy->rx--; + } while (phy->rx > lowerbound); + + dev_dbg(dev, "Unable to find RX high\n"); + return -ENOENT; +} + +static int cqspi_find_tx_low_ddr(struct cqspi_flash_pdata *f_pdata, + struct spi_mem *mem, struct phy_setting *phy) +{ + struct device *dev =3D &f_pdata->cqspi->pdev->dev; + int ret; + + do { + phy->tx =3D CQSPI_PHY_TX_LOW_SEARCH_START; + do { + ret =3D cqspi_phy_apply_setting(f_pdata, phy); + if (!ret) { + ret =3D cqspi_phy_check_pattern(f_pdata, mem); + if (!ret) + return 0; + } + + phy->tx +=3D CQSPI_PHY_DDR_SEARCH_STEP; + } while (phy->tx <=3D CQSPI_PHY_TX_LOW_SEARCH_END); + + phy->read_delay++; + } while (phy->read_delay <=3D CQSPI_PHY_MAX_RD); + + dev_dbg(dev, "Unable to find TX low\n"); + return -ENOENT; +} + +static int cqspi_find_tx_high_ddr(struct cqspi_flash_pdata *f_pdata, + struct spi_mem *mem, struct phy_setting *phy) +{ + struct device *dev =3D &f_pdata->cqspi->pdev->dev; + int ret; + + do { + phy->tx =3D CQSPI_PHY_TX_HIGH_SEARCH_END; + do { + ret =3D cqspi_phy_apply_setting(f_pdata, phy); + if (!ret) { + ret =3D cqspi_phy_check_pattern(f_pdata, mem); + if (!ret) + return 0; + } + + phy->tx -=3D CQSPI_PHY_DDR_SEARCH_STEP; + } while (phy->tx >=3D CQSPI_PHY_TX_HIGH_SEARCH_START); + + phy->read_delay--; + } while (phy->read_delay >=3D CQSPI_PHY_INIT_RD); + + dev_dbg(dev, "Unable to find TX high\n"); + return -ENOENT; +} + +static void cqspi_phy_find_gaplow_ddr(struct cqspi_flash_pdata *f_pdata, + struct spi_mem *mem, + struct phy_setting *bottomleft, + struct phy_setting *topright, + struct phy_setting *gaplow) +{ + struct phy_setting left, right, mid; + int ret; + + left =3D *bottomleft; + right =3D *topright; + + mid.tx =3D left.tx + ((right.tx - left.tx) / 2); + mid.rx =3D left.rx + ((right.rx - left.rx) / 2); + mid.read_delay =3D left.read_delay; + + do { + ret =3D cqspi_phy_apply_setting(f_pdata, &mid); + if (!ret) + ret =3D cqspi_phy_check_pattern(f_pdata, mem); + + if (ret) { + /* The pattern was not found. Go to the lower half. */ + right.tx =3D mid.tx; + right.rx =3D mid.rx; + + mid.tx =3D left.tx + ((mid.tx - left.tx) / 2); + mid.rx =3D left.rx + ((mid.rx - left.rx) / 2); + } else { + /* The pattern was found. Go to the upper half. */ + left.tx =3D mid.tx; + left.rx =3D mid.rx; + + mid.tx =3D mid.tx + ((right.tx - mid.tx) / 2); + mid.rx =3D mid.rx + ((right.rx - mid.rx) / 2); + } + + /* Break the loop if the window has closed. */ + } while ((right.tx - left.tx >=3D 2) && (right.rx - left.rx >=3D 2)); + + *gaplow =3D mid; +} + +static void cqspi_phy_find_gaphigh_ddr(struct cqspi_flash_pdata *f_pdata, + struct spi_mem *mem, + struct phy_setting *bottomleft, + struct phy_setting *topright, + struct phy_setting *gaphigh) +{ + struct phy_setting left, right, mid; + int ret; + + left =3D *bottomleft; + right =3D *topright; + + mid.tx =3D left.tx + ((right.tx - left.tx) / 2); + mid.rx =3D left.rx + ((right.rx - left.rx) / 2); + mid.read_delay =3D right.read_delay; + + do { + ret =3D cqspi_phy_apply_setting(f_pdata, &mid); + if (!ret) + ret =3D cqspi_phy_check_pattern(f_pdata, mem); + + if (ret) { + /* The pattern was not found. Go to the upper half. */ + left.tx =3D mid.tx; + left.rx =3D mid.rx; + + mid.tx =3D mid.tx + ((right.tx - mid.tx) / 2); + mid.rx =3D mid.rx + ((right.rx - mid.rx) / 2); + } else { + /* The pattern was found. Go to the lower half. */ + right.tx =3D mid.tx; + right.rx =3D mid.rx; + + mid.tx =3D left.tx + ((mid.tx - left.tx) / 2); + mid.rx =3D left.rx + ((mid.rx - left.rx) / 2); + } + + /* Break the loop if the window has closed. */ + } while ((right.tx - left.tx >=3D 2) && (right.rx - left.rx >=3D 2)); + + *gaphigh =3D mid; +} + +static int cqspi_get_temp(int *temp) +{ + /* TODO: read SoC thermal sensor; caller falls back to room temperature */ + return -EOPNOTSUPP; +} + +static inline void cqspi_phy_reset_setting(struct phy_setting *phy) +{ + *phy =3D (struct phy_setting){ .rx =3D 0, .tx =3D 127, .read_delay =3D 0 = }; +} + +static int cqspi_phy_tuning_ddr(struct cqspi_flash_pdata *f_pdata, + struct spi_mem *mem) +{ + struct cqspi_st *cqspi =3D f_pdata->cqspi; + struct device *dev =3D &cqspi->pdev->dev; + struct phy_setting rxlow, rxhigh, txlow, txhigh; + struct phy_setting srxlow, srxhigh; + struct phy_setting bottomleft, topright, searchpoint; + struct phy_setting gaplow, gaphigh; + struct phy_setting backuppoint, backupcornerpoint; + int ret, rx_window, temp; + bool primary =3D true, secondary =3D true; + + /* + * DDR tuning: 2D search across RX and TX delays for optimal timing. + * + * Algorithm: Find RX boundaries (rxlow/rxhigh) using TX window search, + * find TX boundaries (txlow/txhigh) at fixed RX, define valid region, + * locate gaps via binary search, select final point with temperature + * compensation. + * + * rx + * 127 ^ + * | topright + * | * + * | xxxxx ++++++++++++++++++++ + * | xxxxxx +++++++++++++++++++ + * | xxxxxxx ++++++++++++++++++ + * | xxxxxxxx +++++++++++++++++ + * | xxxxxxxxx ++++++++++++++++ + * | xxxxxxxxxx +++++++++++++++ + * | xxxxxxxxxxx ++++++++++++++ + * | xxxxxxxxxxxx +++++++++++++ + * | xxxxxxxxxxxxx ++++++++++++ + * | xxxxxxxxxxxxxx +++++++++++ + * | xxxxxxxxxxxxxxx ++++++++++ + * | xxxxxxxxxxxxxxxx +++++++++ + * | xxxxxxxxxxxxxxxxx ++++++++ + * | xxxxxxxxxxxxxxxxxx +++++++ + * | * + * | bottomleft + * -----------------------------------------> tx + * 0 127 + */ + + f_pdata->use_tuned_phy =3D true; + + /* Golden rxlow search: Find lower RX boundary using TX window sweep */ + + /* + * rx + * 127 ^ + * | xxxxx ++++++++++++++++++++ + * | xxxxxx +++++++++++++++++++ + * | xxxxxxx ++++++++++++++++++ + * | xxxxxxxx +++++++++++++++++ + * | xxxxxxxxx ++++++++++++++++ + * | xxxxxxxxxx +++++++++++++++ + * | xxxxxxxxxxx ++++++++++++++ + * | |xxxxx|xxxxx +++++++++++++ + * | |xxxxx|xxxxxx ++++++++++++ + * search | |xxxxx|xxxxxxx +++++++++++ + * rxlow --------->|xxxxx|xxxxxxxx ++++++++++ + * | |xxxxx|xxxxxxxxx +++++++++ + * | |xxxxx|xxxxxxxxxx ++++++++ + * | |xxxxx|xxxxxxxxxxx +++++++ + * | | | + * --------|-----|----------------------------> tx + * 0 | | 127 + * txlow txlow + * start end + * + * |----------------------------------------------------------| + * | Primary | Secondary | Final | + * | Search | Search | Point | + * |---------|-----------|------------------------------------| + * | Fail | Fail | Return Fail | + * |---------|-----------|------------------------------------| + * | Fail | Pass | Return Fail | + * |---------|-----------|------------------------------------| + * | Pass | Fail | Return Fail | + * |---------|-----------|------------------------------------| + * | Pass | Pass | rx =3D min(primary.rx, secondary.rx) | + * | | | tx =3D primary.tx | + * | | | read_delay =3D | + * | | | min(primary.read_delay, | + * | | | secondary.read_delay) | + * |----------------------------------------------------------| + */ + + /* Primary rxlow: Sweep TX window to find valid RX lower bound */ + + rxlow.tx =3D CQSPI_PHY_TX_LOOKUP_LOW_START; + do { + dev_dbg(dev, "Searching for Golden Primary rxlow on TX =3D %d\n", + rxlow.tx); + rxlow.read_delay =3D CQSPI_PHY_INIT_RD; + ret =3D cqspi_find_rx_low_ddr(f_pdata, mem, &rxlow); + rxlow.tx +=3D CQSPI_PHY_DDR_SEARCH_STEP; + } while (ret && rxlow.tx <=3D CQSPI_PHY_TX_LOOKUP_LOW_END); + if (ret) + goto out; + dev_dbg(dev, "Golden Primary rxlow: RX: %d TX: %d RD: %d\n", rxlow.rx, + rxlow.tx, rxlow.read_delay); + + /* Secondary rxlow: Verify at offset TX for robustness */ + + if (rxlow.tx <=3D (CQSPI_PHY_TX_LOOKUP_LOW_END - CQSPI_PHY_SEARCH_OFFSET)) + srxlow.tx =3D rxlow.tx + CQSPI_PHY_SEARCH_OFFSET; + else + srxlow.tx =3D CQSPI_PHY_TX_LOOKUP_LOW_END; + dev_dbg(dev, "Searching for Golden Secondary rxlow on TX =3D %d\n", + srxlow.tx); + srxlow.read_delay =3D CQSPI_PHY_INIT_RD; + ret =3D cqspi_find_rx_low_ddr(f_pdata, mem, &srxlow); + if (ret) + goto out; + dev_dbg(dev, "Golden Secondary rxlow: RX: %d TX: %d RD: %d\n", + srxlow.rx, srxlow.tx, srxlow.read_delay); + + rxlow.rx =3D min(rxlow.rx, srxlow.rx); + rxlow.read_delay =3D min(rxlow.read_delay, srxlow.read_delay); + dev_dbg(dev, "Golden Final rxlow: RX: %d TX: %d RD: %d\n", rxlow.rx, + rxlow.tx, rxlow.read_delay); + + /* Golden rxhigh search: Find upper RX boundary at fixed TX */ + + /* + * rx + * 127 ^ + * | |xxxx ++++++++++++++++++++ + * | |xxxxx +++++++++++++++++++ + * search | |xxxxxx ++++++++++++++++++ + * rxhigh --------->|xxxxxxx +++++++++++++++++ + * on fixed | |xxxxxxxx ++++++++++++++++ + * tx | |xxxxxxxxx +++++++++++++++ + * | |xxxxxxxxxx ++++++++++++++ + * | xxxxxxxxxxxx +++++++++++++ + * | xxxxxxxxxxxxx ++++++++++++ + * | xxxxxxxxxxxxxx +++++++++++ + * | xxxxxxxxxxxxxxx ++++++++++ + * | xxxxxxxxxxxxxxxx +++++++++ + * | xxxxxxxxxxxxxxxxx ++++++++ + * | xxxxxxxxxxxxxxxxxx +++++++ + * | + * -------------------------------------------> tx + * 0 127 + * + * |----------------------------------------------------------| + * | Primary | Secondary | Final | + * | Search | Search | Point | + * |---------|-----------|------------------------------------| + * | Fail | Fail | Return Fail | + * |---------|-----------|------------------------------------| + * | Fail | Pass | Choose Secondary | + * |---------|-----------|------------------------------------| + * | Pass | Fail | Choose Primary | + * |---------|-----------|------------------------------------| + * | Pass | Pass | if (secondary.rx > primary.rx) | + * | | | Choose Secondary | + * | | | else | + * | | | Choose Primary | + * |----------------------------------------------------------| + */ + + /* Primary rxhigh: Search at rxlow's TX, decrement from max read_delay */ + + rxhigh.tx =3D rxlow.tx; + dev_dbg(dev, "Searching for Golden Primary rxhigh on TX =3D %d\n", + rxhigh.tx); + rxhigh.read_delay =3D CQSPI_PHY_MAX_RD; + ret =3D cqspi_find_rx_high_ddr(f_pdata, mem, &rxhigh); + if (ret) + primary =3D false; + dev_dbg(dev, "Golden Primary rxhigh: RX: %d TX: %d RD: %d\n", rxhigh.rx, + rxhigh.tx, rxhigh.read_delay); + + /* Secondary rxhigh: Verify at offset TX */ + + if (rxhigh.tx <=3D + (CQSPI_PHY_TX_LOOKUP_LOW_END - CQSPI_PHY_SEARCH_OFFSET)) + srxhigh.tx =3D rxhigh.tx + CQSPI_PHY_SEARCH_OFFSET; + else + srxhigh.tx =3D CQSPI_PHY_TX_LOOKUP_LOW_END; + dev_dbg(dev, "Searching for Golden Secondary rxhigh on TX =3D %d\n", + srxhigh.tx); + srxhigh.read_delay =3D CQSPI_PHY_MAX_RD; + ret =3D cqspi_find_rx_high_ddr(f_pdata, mem, &srxhigh); + if (ret) + secondary =3D false; + dev_dbg(dev, "Golden Secondary rxhigh: RX: %d TX: %d RD: %d\n", + srxhigh.rx, srxhigh.tx, srxhigh.read_delay); + + if (!primary && !secondary) + goto out; + else if (!primary) + rxhigh =3D srxhigh; + else if (secondary && srxhigh.rx > rxhigh.rx) + rxhigh =3D srxhigh; + dev_dbg(dev, "Golden Final rxhigh: RX: %d TX: %d RD: %d\n", rxhigh.rx, + rxhigh.tx, rxhigh.read_delay); + + primary =3D true; + secondary =3D true; + + /* If rxlow/rxhigh at same read_delay, search backup at upper TX range */ + + if (rxlow.read_delay =3D=3D rxhigh.read_delay) { + dev_dbg(dev, "rxlow and rxhigh at the same read delay.\n"); + + /* Backup rxlow: Search at high TX window */ + + /* + * rx + * 127 ^ + * | xxxxx ++++++++++++++++++++ + * | xxxxxx +++++++++++++++++++ + * | xxxxxxx ++++++++++++++++++ + * | xxxxxxxx +++++++++++++++++ + * | xxxxxxxxx ++++++++++++++++ + * | xxxxxxxxxx +++++++++++++++ + * | xxxxxxxxxxx ++++++++++++++ + * | xxxxxxxxxxxx +++++++|++++| + * | xxxxxxxxxxxxx ++++++|++++| + * search | xxxxxxxxxxxxxx +++++|++++| + * rxlow --------------------------------->|++++| + * | xxxxxxxxxxxxxxxx +++|++++| + * | xxxxxxxxxxxxxxxxx ++|++++| + * | xxxxxxxxxxxxxxxxxx +|++++| + * | | | + * --------------------------------|----|-----> tx + * 0 | | 127 + * txhigh txhigh + * start end + * + * |-----------------------------------------------------| + * | Primary | Secondary | Final | + * | Search | Search | Point | + * |---------|-----------|-------------------------------| + * | Fail | Fail | Return Fail | + * |---------|-----------|-------------------------------| + * | Fail | Pass | Return Fail | + * |---------|-----------|-------------------------------| + * | Pass | Fail | Return Fail | + * |---------|-----------|-------------------------------| + * | Pass | Pass | rx =3D | + * | | | min(primary.rx, secondary.rx)| + * | | | tx =3D primary.tx | + * | | | read_delay =3D | + * | | | min(primary.read_delay, | + * | | | secondary.read_delay) | + * |-----------------------------------------------------| + */ + + /* Primary backup: Decrement TX from high window end */ + + backuppoint.tx =3D CQSPI_PHY_TX_LOOKUP_HIGH_END; + do { + dev_dbg(dev, + "Searching for Backup Primary rxlow on TX =3D %d\n", + backuppoint.tx); + backuppoint.read_delay =3D CQSPI_PHY_INIT_RD; + ret =3D cqspi_find_rx_low_ddr(f_pdata, mem, &backuppoint); + backuppoint.tx -=3D CQSPI_PHY_DDR_SEARCH_STEP; + } while (ret && + backuppoint.tx >=3D CQSPI_PHY_TX_LOOKUP_HIGH_START); + if (ret) + goto out; + dev_dbg(dev, "Backup Primary rxlow: RX: %d TX: %d RD: %d\n", + backuppoint.rx, backuppoint.tx, backuppoint.read_delay); + + /* Secondary backup: Verify at offset TX */ + + if (backuppoint.tx >=3D + (CQSPI_PHY_TX_LOOKUP_HIGH_START + CQSPI_PHY_SEARCH_OFFSET)) + srxlow.tx =3D backuppoint.tx - CQSPI_PHY_SEARCH_OFFSET; + else + srxlow.tx =3D CQSPI_PHY_TX_LOOKUP_HIGH_START; + dev_dbg(dev, + "Searching for Backup Secondary rxlow on TX =3D %d\n", + srxlow.tx); + srxlow.read_delay =3D CQSPI_PHY_INIT_RD; + ret =3D cqspi_find_rx_low_ddr(f_pdata, mem, &srxlow); + if (ret) + goto out; + dev_dbg(dev, "Backup Secondary rxlow: RX: %d TX: %d RD: %d\n", + srxlow.rx, srxlow.tx, srxlow.read_delay); + + backuppoint.rx =3D min(backuppoint.rx, srxlow.rx); + backuppoint.read_delay =3D + min(backuppoint.read_delay, srxlow.read_delay); + dev_dbg(dev, "Backup Final rxlow: RX: %d TX: %d RD: %d\n", + backuppoint.rx, backuppoint.tx, backuppoint.read_delay); + + if (backuppoint.rx < rxlow.rx) { + rxlow =3D backuppoint; + dev_dbg(dev, "Updating rxlow to the one at TX =3D %d\n", + backuppoint.tx); + } + dev_dbg(dev, "Final rxlow: RX: %d TX: %d RD: %d\n", rxlow.rx, + rxlow.tx, rxlow.read_delay); + + /* Backup rxhigh: Search at fixed backup TX */ + + /* + * rx + * 127 ^ + * | xxxxx +++++++++++++++++++| + * | xxxxxx ++++++++++++++++++| + * search | xxxxxxx +++++++++++++++++| + * rxhigh -------------------------------------->| + * on fixed | xxxxxxxxx +++++++++++++++| + * tx | xxxxxxxxxx ++++++++++++++| + * | xxxxxxxxxxx +++++++++++++| + * | xxxxxxxxxxxx +++++++++++++ + * | xxxxxxxxxxxxx ++++++++++++ + * | xxxxxxxxxxxxxx +++++++++++ + * | xxxxxxxxxxxxxxx ++++++++++ + * | xxxxxxxxxxxxxxxx +++++++++ + * | xxxxxxxxxxxxxxxxx ++++++++ + * | xxxxxxxxxxxxxxxxxx +++++++ + * | + * -------------------------------------------> tx + * 0 127 + * + * |-----------------------------------------------------| + * | Primary | Secondary | Final | + * | Search | Search | Point | + * |---------|-----------|-------------------------------| + * | Fail | Fail | Return Fail | + * |---------|-----------|-------------------------------| + * | Fail | Pass | Choose Secondary | + * |---------|-----------|-------------------------------| + * | Pass | Fail | Choose Primary | + * |---------|-----------|-------------------------------| + * | Pass | Pass | if (secondary.rx > primary.rx)| + * | | | Choose Secondary | + * | | | else | + * | | | Choose Primary | + * |-----------------------------------------------------| + */ + + /* Primary backup rxhigh: Use backup TX, decrement from max read_delay */ + + dev_dbg(dev, "Searching for Backup Primary rxhigh on TX =3D %d\n", + backuppoint.tx); + backuppoint.read_delay =3D CQSPI_PHY_MAX_RD; + ret =3D cqspi_find_rx_high_ddr(f_pdata, mem, &backuppoint); + if (ret) + primary =3D false; + dev_dbg(dev, "Backup Primary rxhigh: RX: %d TX: %d RD: %d\n", + backuppoint.rx, backuppoint.tx, backuppoint.read_delay); + + /* Secondary backup rxhigh: Verify at offset TX */ + + if (backuppoint.tx >=3D + (CQSPI_PHY_TX_LOOKUP_HIGH_START + CQSPI_PHY_SEARCH_OFFSET)) + srxhigh.tx =3D backuppoint.tx - CQSPI_PHY_SEARCH_OFFSET; + else + srxhigh.tx =3D CQSPI_PHY_TX_LOOKUP_HIGH_START; + dev_dbg(dev, + "Searching for Backup Secondary rxhigh on TX =3D %d\n", + srxhigh.tx); + srxhigh.read_delay =3D CQSPI_PHY_MAX_RD; + ret =3D cqspi_find_rx_high_ddr(f_pdata, mem, &srxhigh); + if (ret) + secondary =3D false; + dev_dbg(dev, "Backup Secondary rxhigh: RX: %d TX: %d RD: %d\n", + srxhigh.rx, srxhigh.tx, srxhigh.read_delay); + + if (!primary && !secondary) + goto out; + else if (!primary) + backuppoint =3D srxhigh; + else if (secondary && srxhigh.rx > backuppoint.rx) + backuppoint =3D srxhigh; + dev_dbg(dev, "Backup Final rxhigh: RX: %d TX: %d RD: %d\n", + backuppoint.rx, backuppoint.tx, backuppoint.read_delay); + + if (backuppoint.rx > rxhigh.rx) { + rxhigh =3D backuppoint; + dev_dbg(dev, "Updating rxhigh to the one at TX =3D %d\n", + backuppoint.tx); + } + dev_dbg(dev, "Final rxhigh: RX: %d TX: %d RD: %d\n", rxhigh.rx, + rxhigh.tx, rxhigh.read_delay); + } + + /* Golden txlow: Fix RX at 1/4 of RX window, search TX lower bound */ + + /* + * rx + * 127 ^ + * | + * rxhigh --------->xxxxx ++++++++++++++++++++ + * | xxxxxx +++++++++++++++++++ + * | xxxxxxx ++++++++++++++++++ + * | xxxxxxxx +++++++++++++++++ + * | xxxxxxxxx ++++++++++++++++ + * | xxxxxxxxxx +++++++++++++++ + * | xxxxxxxxxxx ++++++++++++++ + * | xxxxxxxxxxxx +++++++++++++ + * fix rx | xxxxxxxxxxxxx ++++++++++++ + * 1/4 b/w ---------><------->xxxxx +++++++++++ + * rxlow and | xxxx|xxxxxxxxxx ++++++++++ + * rxhigh | xxxx|xxxxxxxxxxx +++++++++ + * | xxxx|xxxxxxxxxxxx ++++++++ + * rxlow --------->xxxx|xxxxxxxxxxxxx +++++++ + * | | + * ------------|------------------------------> tx + * 0 | 127 + * search + * txlow + */ + + rx_window =3D rxhigh.rx - rxlow.rx; + txlow.rx =3D rxlow.rx + (rx_window / 4); + dev_dbg(dev, "Searching for Golden txlow on RX =3D %d\n", txlow.rx); + txlow.read_delay =3D CQSPI_PHY_INIT_RD; + ret =3D cqspi_find_tx_low_ddr(f_pdata, mem, &txlow); + if (ret) + goto out; + dev_dbg(dev, "Golden txlow: RX: %d TX: %d RD: %d\n", txlow.rx, txlow.tx, + txlow.read_delay); + + /* Golden txhigh: Same RX as txlow, decrement from max read_delay */ + + /* + * rx + * 127 ^ + * | + * rxhigh --------->xxxxx ++++++++++++++++++++ + * | xxxxxx +++++++++++++++++++ + * | xxxxxxx ++++++++++++++++++ + * | xxxxxxxx +++++++++++++++++ + * | xxxxxxxxx ++++++++++++++++ + * | xxxxxxxxxx +++++++++++++++ + * | xxxxxxxxxxx ++++++++++++++ + * | xxxxxxxxxxxx +++++++++++++ + * fix rx | xxxxxxxxxxxxx ++++++++++++ + * 1/4 b/w --------------------------------><-----> + * rxlow and | xxxxxxxxxxxxxxx ++++++|+++ + * rxhigh | xxxxxxxxxxxxxxxx +++++|+++ + * | xxxxxxxxxxxxxxxxx ++++|+++ + * rxlow --------->xxxxxxxxxxxxxxxxxx +++|+++ + * | | + * ----------------------------------|--------> tx + * 0 | 127 + * search + * txhigh + */ + + txhigh.rx =3D txlow.rx; + dev_dbg(dev, "Searching for Golden txhigh on RX =3D %d\n", txhigh.rx); + txhigh.read_delay =3D CQSPI_PHY_MAX_RD; + ret =3D cqspi_find_tx_high_ddr(f_pdata, mem, &txhigh); + if (ret) + goto out; + dev_dbg(dev, "Golden txhigh: RX: %d TX: %d RD: %d\n", txhigh.rx, + txhigh.tx, txhigh.read_delay); + + /* If txlow/txhigh at same read_delay, search backup at 3/4 RX window */ + + if (txlow.read_delay =3D=3D txhigh.read_delay) { + /* Backup txlow: Fix RX at 3/4 of RX window */ + + /* + * rx + * 127 ^ + * | + * rxhigh --------->xxxxx ++++++++++++++++++++ + * | xxxxxx +++++++++++++++++++ + * fix rx | xxxxxxx ++++++++++++++++++ + * 3/4 b/w ---------><----->x +++++++++++++++++ + * rxlow and | xxxx|xxxx ++++++++++++++++ + * rxhigh | xxxx|xxxxx +++++++++++++++ + * | xxxx|xxxxxx ++++++++++++++ + * | xxxx|xxxxxxx +++++++++++++ + * | xxxx|xxxxxxxx ++++++++++++ + * | xxxx|xxxxxxxxx +++++++++++ + * | xxxx|xxxxxxxxxx ++++++++++ + * | xxxx|xxxxxxxxxxx +++++++++ + * | xxxx|xxxxxxxxxxxx ++++++++ + * rxlow --------->xxxx|xxxxxxxxxxxxx +++++++ + * | | + * ------------|------------------------------> tx + * 0 | 127 + * search + * txlow + */ + + dev_dbg(dev, "txlow and txhigh at the same read delay.\n"); + backuppoint.rx =3D rxlow.rx + ((rx_window * 3) / 4); + dev_dbg(dev, "Searching for Backup txlow on RX =3D %d\n", + backuppoint.rx); + backuppoint.read_delay =3D CQSPI_PHY_INIT_RD; + ret =3D cqspi_find_tx_low_ddr(f_pdata, mem, &backuppoint); + if (ret) + goto out; + dev_dbg(dev, "Backup txlow: RX: %d TX: %d RD: %d\n", + backuppoint.rx, backuppoint.tx, backuppoint.read_delay); + + if (backuppoint.tx < txlow.tx) { + txlow =3D backuppoint; + dev_dbg(dev, "Updating txlow with the one at RX =3D %d\n", + backuppoint.rx); + } + dev_dbg(dev, "Final txlow: RX: %d TX: %d RD: %d\n", txlow.rx, + txlow.tx, txlow.read_delay); + + /* Backup txhigh: Same RX as backup txlow, decrement from max */ + + /* + * rx + * 127 ^ + * | + * rxhigh --------->xxxxx ++++++++++++++++++++ + * | xxxxxx +++++++++++++++++++ + * fix rx | xxxxxxx ++++++++++++++++++ + * 3/4 b/w ------------------------------><-------> + * rxlow and | xxxxxxxxx +++++++++++|++++ + * rxhigh | xxxxxxxxxx ++++++++++|++++ + * | xxxxxxxxxxx +++++++++|++++ + * | xxxxxxxxxxxx ++++++++|++++ + * | xxxxxxxxxxxxx +++++++|++++ + * | xxxxxxxxxxxxxx ++++++|++++ + * | xxxxxxxxxxxxxxx +++++|++++ + * | xxxxxxxxxxxxxxxx ++++|++++ + * | xxxxxxxxxxxxxxxxx +++|++++ + * rxlow --------->xxxxxxxxxxxxxxxxxx ++|++++ + * | | + * ---------------------------------|---------> tx + * 0 | 127 + * search + * txhigh + */ + + dev_dbg(dev, "Searching for Backup txhigh on RX =3D %d\n", + backuppoint.rx); + backuppoint.read_delay =3D CQSPI_PHY_MAX_RD; + ret =3D cqspi_find_tx_high_ddr(f_pdata, mem, &backuppoint); + if (ret) + goto out; + dev_dbg(dev, "Backup txhigh: RX: %d TX: %d RD: %d\n", + backuppoint.rx, backuppoint.tx, backuppoint.read_delay); + + if (backuppoint.tx > txhigh.tx) { + txhigh =3D backuppoint; + dev_dbg(dev, + "Updating txhigh with the one at RX =3D %d\n", + backuppoint.rx); + } + dev_dbg(dev, "Final txhigh: RX: %d TX: %d RD: %d\n", txhigh.rx, + txhigh.tx, txhigh.read_delay); + } + + /* Corner points: Define and verify bottomleft and topright boundaries */ + + /* + * rx + * 127 ^ + * | topright + * | * + * rxhigh -----------xxxxx ++++++++++++++++++++ + * | xxxxxx +++++++++++++++++++ + * | xxxxxxx ++++++++++++++++++ + * | xxxxxxxx +++++++++++++++++ + * | xxxxxxxxx ++++++++++++++++ + * | xxxxxxxxxx +++++++++++++++ + * | xxxxxxxxxxx ++++++++++++++ + * | xxxxxxxxxxxx +++++++++++++ + * | xxxxxxxxxxxxx ++++++++++++ + * | xxxxxxxxxxxxxx +++++++++++ + * | xxxxxxxxxxxxxxx ++++++++++ + * | xxxxxxxxxxxxxxxx +++++++++ + * | xxxxxxxxxxxxxxxxx ++++++++ + * rxlow -----------xxxxxxxxxxxxxxxxxx +++++++ + * | * | + * | bottom|left | + * --------|----------------------------|---> tx + * 0 | | 127 + * | | + * txlow txhigh + * + * Verification: Test point 4 taps inside each corner, adjust + * read_delay =C2=B11 if needed to ensure valid corners for gap search. + */ + + bottomleft.tx =3D txlow.tx; + bottomleft.rx =3D rxlow.rx; + if (txlow.read_delay <=3D rxlow.read_delay) + bottomleft.read_delay =3D txlow.read_delay; + else + bottomleft.read_delay =3D rxlow.read_delay; + + /* Verify bottomleft: Test 4 taps inside, adjust read_delay if needed */ + backupcornerpoint =3D bottomleft; + backupcornerpoint.tx +=3D 4; + backupcornerpoint.rx +=3D 4; + ret =3D cqspi_phy_apply_setting(f_pdata, &backupcornerpoint); + if (!ret) + ret =3D cqspi_phy_check_pattern(f_pdata, mem); + + if (ret) { + backupcornerpoint.read_delay--; + ret =3D cqspi_phy_apply_setting(f_pdata, &backupcornerpoint); + if (!ret) + ret =3D cqspi_phy_check_pattern(f_pdata, mem); + } + + if (ret) + goto out; + + bottomleft.read_delay =3D backupcornerpoint.read_delay; + + topright.tx =3D txhigh.tx; + topright.rx =3D rxhigh.rx; + if (txhigh.read_delay >=3D rxhigh.read_delay) + topright.read_delay =3D txhigh.read_delay; + else + topright.read_delay =3D rxhigh.read_delay; + + /* Verify topright: Test 4 taps inside, adjust read_delay if needed */ + backupcornerpoint =3D topright; + backupcornerpoint.tx -=3D 4; + backupcornerpoint.rx -=3D 4; + ret =3D cqspi_phy_apply_setting(f_pdata, &backupcornerpoint); + if (!ret) + ret =3D cqspi_phy_check_pattern(f_pdata, mem); + + if (ret) { + backupcornerpoint.read_delay++; + ret =3D cqspi_phy_apply_setting(f_pdata, &backupcornerpoint); + if (!ret) + ret =3D cqspi_phy_check_pattern(f_pdata, mem); + } + + if (ret) + goto out; + + topright.read_delay =3D backupcornerpoint.read_delay; + + dev_dbg(dev, "topright: RX: %d TX: %d RD: %d\n", topright.rx, + topright.tx, topright.read_delay); + dev_dbg(dev, "bottomleft: RX: %d TX: %d RD: %d\n", bottomleft.rx, + bottomleft.tx, bottomleft.read_delay); + cqspi_phy_find_gaplow_ddr(f_pdata, mem, &bottomleft, &topright, &gaplow); + dev_dbg(dev, "gaplow: RX: %d TX: %d RD: %d\n", gaplow.rx, gaplow.tx, + gaplow.read_delay); + + /* Final point selection: Handle single vs dual passing regions */ + + if (bottomleft.read_delay =3D=3D topright.read_delay) { + /* + * Single region: Use midpoint with temperature compensation. + * Gaplow approximates upper boundary of valid region. + * + * rx + * 127 ^ + * | gaplow (approx. topright) + * | | + * rxhigh -----------xxxxxxx| failing + * | xxxxxxx| region + * | xxxxxxx| <---------------> + * | xxxxxxx| +++++++++++++++++ + * | xxxxxxxxx ++++++++++++++++ + * | xxxxxxxxxx +++++++++++++++ + * | xxxxxxxxxxx ++++++++++++++ + * | xxxxxxxxxxxx +++++++++++++ + * | xxxxxxxxxxxxx ++++++++++++ + * | xxxxxxxxxxxxxx +++++++++++ + * | xxxxxxxxxxxxxxx ++++++++++ + * | xxxxxxxxxxxxxxxx +++++++++ + * | xxxxxxxxxxxxxxxxx ++++++++ + * rxlow -----------xxxxxxxxxxxxxxxxxx +++++++ + * | * | + * | bottom|left | + * --------|----------------------------|---> tx + * 0 | | 127 + * | | + * txlow txhigh + * (same read_delay) + * + * Temperature compensation: Valid region shifts with temp. + * Offset =3D region_size / (330 / (temp - 42=C2=B0C)) + * Factor 330 is empirically determined for this hardware. + */ + + dev_dbg(dev, + "bottomleft and topright at the same read delay.\n"); + + topright =3D gaplow; + searchpoint.read_delay =3D bottomleft.read_delay; + searchpoint.tx =3D + bottomleft.tx + ((topright.tx - bottomleft.tx) / 2); + searchpoint.rx =3D + bottomleft.rx + ((topright.rx - bottomleft.rx) / 2); + + ret =3D cqspi_get_temp(&temp); + if (ret) { + /* Assume room temperature if sensor unavailable */ + dev_dbg(dev, + "Unable to get temperature. Assuming room temperature\n"); + temp =3D CQSPI_PHY_DEFAULT_TEMP; + } + + if (temp < CQSPI_PHY_MIN_TEMP || temp > CQSPI_PHY_MAX_TEMP) { + dev_err(dev, + "Temperature outside operating range: %dC\n", + temp); + ret =3D -EINVAL; + goto out; + } + + if (temp =3D=3D CQSPI_PHY_MID_TEMP) + temp++; /* Avoid divide-by-zero */ + dev_dbg(dev, "Temperature: %dC\n", temp); + + /* + * Apply temperature offset: positive at high temp, negative at low. + * Compute the divisor once and apply to both TX and RX. Use int + * arithmetic throughout to avoid u8 wrapping on negative offsets. + */ + temp =3D 330 / (temp - CQSPI_PHY_MID_TEMP); + searchpoint.tx =3D clamp((int)searchpoint.tx + + (topright.tx - bottomleft.tx) / temp, + 0, CQSPI_PHY_MAX_DELAY); + searchpoint.rx =3D clamp((int)searchpoint.rx + + (topright.rx - bottomleft.rx) / temp, + 0, CQSPI_PHY_MAX_DELAY); + } else { + /* + * Dual regions: Gap separates two valid regions, choose larger. + * + * rx + * 127 ^ + * | topright + * | * + * rxhigh -----------xxxxx +++++++++++++++++++| + * | xxxxxx ++++++++| + * | xxxxxxx +++++++++++++++++| + * | xxxxxxxx ++++++++++++++++| + * | xxxxxxxxx +++++++++++++++| + * | xxxxxxxxxx ++++++++++++++| + * | failing | + * | region | + * | xxxxxxxxxxxxx +++++++++++| + * | xxxxxxxxxxxxxx ++++++++++| + * | xxxxxxxxxxxxxxx +++++++++| + * | xxxxxxxxxxxxxxxx ++++++++| + * | xxxxxxxxx +++++++| + * rxlow -----------xxxxxxxxxxxxxxxxxx ++++++| + * | * | + * | bottom|left | + * --------|----------------------------|---> tx + * 0 | | 127 + * | | + * txlow txhigh + * + * Strategy: Compare Manhattan distances from gap boundaries to + * corners. Choose corner furthest from gap (larger region). + * Apply 16-tap margin inward, scale RX proportionally. + */ + + cqspi_phy_find_gaphigh_ddr(f_pdata, mem, &bottomleft, + &topright, &gaphigh); + dev_dbg(dev, "gaphigh: RX: %d TX: %d RD: %d\n", gaphigh.rx, + gaphigh.tx, gaphigh.read_delay); + + if (topright.tx =3D=3D bottomleft.tx) { + dev_err(dev, "zero TX span in dual-region: cannot compute search point\= n"); + ret =3D -EINVAL; + goto out; + } + + /* Compare Manhattan distances: choose corner furthest from gap */ + if ((abs(gaplow.tx - bottomleft.tx) + + abs(gaplow.rx - bottomleft.rx)) < + (abs(gaphigh.tx - topright.tx) + + abs(gaphigh.rx - topright.rx))) { + /* Topright further: Use Region 2, 16 taps inward */ + searchpoint =3D topright; + searchpoint.tx =3D clamp((int)topright.tx - 16, + 0, CQSPI_PHY_MAX_DELAY); + searchpoint.rx =3D clamp((int)topright.rx - + (16 * (topright.rx - bottomleft.rx)) / + (topright.tx - bottomleft.tx), + 0, CQSPI_PHY_MAX_DELAY); + } else { + /* Bottomleft further: Use Region 1, 16 taps inward */ + searchpoint =3D bottomleft; + searchpoint.tx =3D clamp((int)bottomleft.tx + 16, + 0, CQSPI_PHY_MAX_DELAY); + searchpoint.rx =3D clamp((int)bottomleft.rx + + (16 * (topright.rx - bottomleft.rx)) / + (topright.tx - bottomleft.tx), + 0, CQSPI_PHY_MAX_DELAY); + } + } + + /* Apply and verify final tuning point */ + dev_dbg(dev, "Final tuning point: RX: %d TX: %d RD: %d\n", + searchpoint.rx, searchpoint.tx, searchpoint.read_delay); + ret =3D cqspi_phy_apply_setting(f_pdata, &searchpoint); + if (!ret) + ret =3D cqspi_phy_check_pattern(f_pdata, mem); + + if (ret) { + dev_err(dev, + "Failed to find pattern at final calibration point\n"); + ret =3D -EINVAL; + goto out; + } + + f_pdata->phy_setting.read_delay =3D searchpoint.read_delay; + f_pdata->phy_setting.rx =3D searchpoint.rx; + f_pdata->phy_setting.tx =3D searchpoint.tx; +out: + if (ret) + f_pdata->use_tuned_phy =3D false; + + return ret; +} + +static int cqspi_phy_tuning_sdr(struct cqspi_flash_pdata *f_pdata, + struct spi_mem *mem) +{ + struct cqspi_st *cqspi =3D f_pdata->cqspi; + struct device *dev =3D &cqspi->pdev->dev; + struct phy_setting rxlow, rxhigh, first, second, final; + u8 window1 =3D 0; + u8 window2 =3D 0; + int ret; + + /* + * SDR tuning: 1D search for optimal RX delay (TX less critical). + * Find two consecutive windows, choose larger, use midpoint. + * + * rx + * 127 ^ + * | |-----window at----------| + * | |-----read_delay =3D n+1---| + * | |xxxxxxxxxxxxxxxxxxxxxxxx| + * | |xxxxxxxxxxxxxxxxxxxxxxxx| + * | |xxxxxxxxxxxxxxxxxxxxxxxx| + * | |xxxxxxxxxxxxxxxxxxxxxxxx| + * | |xxxxxxxxxxxxxxxxxxxxxxxx| + * | rxlow(n+1) midpoint rxhigh(n+1) + * | + * | |---window at--------| + * | |---read_delay =3D n---| + * | |xxxxxxxxxxxxxxxxxxxx| + * | |xxxxxxxxxxxxxxxxxxxx| + * | |xxxxxxxxxxxxxxxxxxxx| + * | |xxxxxxxxxxxxxxxxxxxx| + * | |xxxxxxxxxxxxxxxxxxxx| + * | rxlow(n) midpoint rxhigh(n) + * | + * -----------------------------------------> tx + * 0 127 + * read_delay=3Dn read_delay=3Dn+1 + */ + + f_pdata->use_tuned_phy =3D true; + cqspi_phy_reset_setting(&rxlow); + cqspi_phy_reset_setting(&rxhigh); + cqspi_phy_reset_setting(&first); + + /* First window: Find rxlow by incrementing read_delay from 0 */ + + /* + * rx + * 127 ^ + * | |xxxxxxxxxxxxxxxxxxxx| + * search | |xxxxxxxxxxxxxxxxxxxx| + * rxlow | |xxxxxxxxxxxxxxxxxxxx| + * increasing | |xxxxxxxxxxxxxxxxxxxx| + * --------->|xxxxxxxxxxxxxxxxxxxx| + * read_delay | |xxxxxxxxxxxxxxxxxxx| + * until found | |xxxxxxxxxxxxxxxxxxx| + * | rxlow + * -----------------------------------------> tx + * 0 tx fixed at 127 + */ + + do { + ret =3D cqspi_find_rx_low_sdr(f_pdata, mem, &rxlow); + + if (ret) + rxlow.read_delay++; + } while (ret && rxlow.read_delay <=3D CQSPI_PHY_MAX_RD); + + if (ret) + goto out; + + /* Find rxhigh: Decrement from RX=3D127 at same read_delay */ + + /* + * rx + * 127 ^ search rxhigh + * | (decrement from + * | 127 until found) + * | | + * | | + * | v + * | |------------------------| + * | |xxxxxxxxxxxxxxxxxxxxxxxx| + * | |xxxxxxxxxxxxxxxxxxxxxxxx| + * | |xxxxxxxxxxxxxxxxxxxxxxxx| + * | |xxxxxxxxxxxxxxxxxxxxxxxx| + * | |xxxxxxxxxxxxxxxxxxxxxxxx| + * | rxlow rxhigh + * -----------------------------------------> tx + * 0 tx fixed at 127 + */ + + rxhigh.read_delay =3D rxlow.read_delay; + ret =3D cqspi_find_rx_high_sdr(f_pdata, mem, &rxhigh, rxlow.rx); + if (ret) + goto out; + + /* Calculate first window midpoint for max margin */ + + /* + * rx + * 127 ^ + * | |--------window1---------| + * | |xxxxxxxxxxxxxxxxxxxxxxxx| + * | |xxxxxxxxxxxxxxxxxxxxxxxx| + * | |xxxxxxxxxxx * xxxxxxxxxx| + * | |xxxxxxxxxxxxxxxxxxxxxxxx| + * | |xxxxxxxxxxxxxxxxxxxxxxxx| + * | rxlow ^ rxhigh + * ----------------------|------------------> tx + * 0 | tx fixed at 127 + * window1/2 + */ + + first.read_delay =3D rxlow.read_delay; + window1 =3D rxhigh.rx - rxlow.rx; + first.rx =3D rxlow.rx + (window1 / 2); + + dev_dbg(dev, "First tuning point: RX: %d TX: %d RD: %d\n", first.rx, + first.tx, first.read_delay); + ret =3D cqspi_phy_apply_setting(f_pdata, &first); + if (!ret) + ret =3D cqspi_phy_check_pattern(f_pdata, mem); + + if (ret || first.read_delay > CQSPI_PHY_MAX_RD) + goto out; + + /* Second window: Search at read_delay+1, may differ in size */ + + /* + * rx + * 127 ^ + * | |-------| + * | |xxxxxxx| + * | |xxxxxxx| + * | |xxxxxxx| + * | |xxxxxxx| + * | |xxxxxxx| + * | rxlow rxhigh + * -----------------------------------------> tx + * 0 + * read_delay =3D n (smaller window) + * + * rx + * 127 ^ + * | |-----------------| + * | |xxxxxxxxxxxxxxxxx| + * | |xxxxxxxxxxxxxxxxx| + * | |xxxxxxxxxxxxxxxxx| + * | |xxxxxxxxxxxxxxxxx| + * | |xxxxxxxxxxxxxxxxx| + * | rxlow rxhigh + * -----------------------------------------> tx + * 0 + * read_delay =3D n+1 (larger window - better) + */ + + cqspi_phy_reset_setting(&rxlow); + cqspi_phy_reset_setting(&rxhigh); + cqspi_phy_reset_setting(&second); + + rxlow.read_delay =3D first.read_delay + 1; + if (rxlow.read_delay > CQSPI_PHY_MAX_RD) + goto compare; + + ret =3D cqspi_find_rx_low_sdr(f_pdata, mem, &rxlow); + if (ret) + goto compare; + + rxhigh.read_delay =3D rxlow.read_delay; + ret =3D cqspi_find_rx_high_sdr(f_pdata, mem, &rxhigh, rxlow.rx); + if (ret) + goto compare; + + /* Calculate second window midpoint */ + + /* + * rx + * 127 ^ + * | |--------window2---------| + * | |xxxxxxxxxxxxxxxxxxxxxxxx| + * | |xxxxxxxxxxxxxxxxxxxxxxxx| + * | |xxxxxxxxxxx * xxxxxxxxxx| + * | |xxxxxxxxxxxxxxxxxxxxxxxx| + * | |xxxxxxxxxxxxxxxxxxxxxxxx| + * | rxlow ^ rxhigh + * ----------------------|------------------> tx + * 0 | tx fixed at 127 + * window2/2 + * read_delay =3D n+1 + */ + + window2 =3D rxhigh.rx - rxlow.rx; + second.rx =3D rxlow.rx + (window2 / 2); + second.read_delay =3D rxlow.read_delay; + + dev_dbg(dev, "Second tuning point: RX: %d TX: %d RD: %d\n", second.rx, + second.tx, second.read_delay); + ret =3D cqspi_phy_apply_setting(f_pdata, &second); + if (!ret) + ret =3D cqspi_phy_check_pattern(f_pdata, mem); + + if (ret || second.read_delay > CQSPI_PHY_MAX_RD) + window2 =3D 0; + + /* Window comparison: Choose larger window for better margin */ + +compare: + cqspi_phy_reset_setting(&final); + if (window2 > window1) { + final.rx =3D second.rx; + final.read_delay =3D second.read_delay; + } else { + final.rx =3D first.rx; + final.read_delay =3D first.read_delay; + } + + /* Apply and verify final tuning point */ + + dev_dbg(dev, "Final tuning point: RX: %d TX: %d RD: %d\n", final.rx, + final.tx, final.read_delay); + ret =3D cqspi_phy_apply_setting(f_pdata, &final); + if (!ret) + ret =3D cqspi_phy_check_pattern(f_pdata, mem); + + if (ret) { + ret =3D -EINVAL; + goto out; + } + + f_pdata->phy_setting.read_delay =3D final.read_delay; + f_pdata->phy_setting.rx =3D final.rx; + f_pdata->phy_setting.tx =3D final.tx; + +out: + if (ret) + f_pdata->use_tuned_phy =3D false; + + return ret; +} + +static int cqspi_am654_ospi_execute_tuning(struct spi_mem *mem, + struct spi_mem_op *read_op, + struct spi_mem_op *write_op) +{ + struct cqspi_st *cqspi =3D + spi_controller_get_devdata(mem->spi->controller); + struct cqspi_flash_pdata *f_pdata; + struct device *dev =3D &cqspi->pdev->dev; + int ret =3D 0; + + f_pdata =3D &cqspi->f_pdata[spi_get_chipselect(mem->spi, 0)]; + + /* + * spi-max-post-config-frequency-hz must be present for PHY tuning. + * If absent, post_config_max_speed_hz is zero and there is no + * calibration target, so skip tuning gracefully. + */ + if (!mem->spi->post_config_max_speed_hz) { + dev_dbg(dev, + "No post-config frequency configured, skipping tuning\n"); + return -EOPNOTSUPP; + } + + if (write_op) { + /* + * For NAND: write the calibration pattern to the page cache. + * The write op runs at the conservative base speed (spi->max_speed_hz) + * so the write itself is reliable before PHY calibration. + */ + ret =3D cqspi_write_pattern_to_cache(f_pdata, mem, write_op); + if (ret) { + dev_warn(dev, + "failed to write pattern to cache: %d, skipping tuning\n", + ret); + goto out; + } + + f_pdata->phy_write_op =3D *write_op; + } else { + if (!f_pdata->phy_pattern_partition_valid) { + dev_warn(dev, "pattern partition not found, skipping tuning\n"); + return -EOPNOTSUPP; + } + } + + /* + * Build the read op template for pattern verification. For NOR, point + * at the pre-programmed pattern partition rather than the caller's + * address without altering the caller's template. + */ + f_pdata->phy_read_op =3D *read_op; + if (!write_op) + f_pdata->phy_read_op.addr.val =3D + f_pdata->phy_pattern_partition_offset; + + f_pdata->phy_read_op.max_freq =3D mem->spi->max_speed_hz; + + ret =3D cqspi_phy_check_pattern(f_pdata, mem); + if (ret) { + dev_err(dev, "pattern not found: %d, skipping tuning\n", ret); + goto out; + } + + f_pdata->phy_read_op.max_freq =3D mem->spi->post_config_max_speed_hz; + + if (read_op->cmd.dtr || read_op->addr.dtr || read_op->dummy.dtr || + read_op->data.dtr) { + f_pdata->use_dqs =3D true; + cqspi_phy_pre_config(cqspi, f_pdata, false); + ret =3D cqspi_phy_tuning_ddr(f_pdata, mem); + } else { + f_pdata->use_dqs =3D false; + cqspi_phy_pre_config(cqspi, f_pdata, true); + ret =3D cqspi_phy_tuning_sdr(f_pdata, mem); + } + + if (ret) + dev_warn(dev, "tuning failed: %d\n", ret); + + cqspi_phy_post_config(cqspi, f_pdata->read_delay); + +out: + if (!ret) { + read_op->max_freq =3D mem->spi->post_config_max_speed_hz; + if (write_op) { + write_op->max_freq =3D mem->spi->post_config_max_speed_hz; + f_pdata->phy_write_op.max_freq =3D + mem->spi->post_config_max_speed_hz; + } + } + + return ret; +} + +static int cqspi_mem_op_execute_tuning(struct spi_mem *mem, + struct spi_mem_op *read_op, + struct spi_mem_op *write_op) +{ + struct cqspi_st *cqspi =3D + spi_controller_get_devdata(mem->spi->controller); + + if (!cqspi->ddata || !cqspi->ddata->execute_tuning) + return -EOPNOTSUPP; + + return cqspi->ddata->execute_tuning(mem, read_op, write_op); +} + static int cqspi_of_get_flash_pdata(struct platform_device *pdev, struct cqspi_flash_pdata *f_pdata, struct device_node *np) { + struct device_node *part_np; + if (of_property_read_u32(np, "cdns,read-delay", &f_pdata->read_delay)) { dev_err(&pdev->dev, "couldn't determine read-delay\n"); return -ENXIO; @@ -1588,9 +3326,12 @@ static int cqspi_of_get_flash_pdata(struct platform_= device *pdev, return -ENXIO; } =20 - if (of_property_read_u32(np, "spi-max-frequency", &f_pdata->clk_rate)) { - dev_err(&pdev->dev, "couldn't determine spi-max-frequency\n"); - return -ENXIO; + part_np =3D of_parse_phandle(np, "spi-phy-pattern-partition", 0); + if (part_np) { + f_pdata->phy_pattern_partition_valid =3D + !of_property_read_u32_index(part_np, "reg", 0, + &f_pdata->phy_pattern_partition_offset); + of_node_put(part_np); } =20 return 0; @@ -1740,6 +3481,7 @@ static const struct spi_controller_mem_ops cqspi_mem_= ops =3D { .exec_op =3D cqspi_exec_mem_op, .get_name =3D cqspi_get_name, .supports_op =3D cqspi_supports_mem_op, + .execute_tuning =3D cqspi_mem_op_execute_tuning, }; =20 static const struct spi_controller_mem_caps cqspi_mem_caps =3D { @@ -2108,6 +3850,7 @@ static const struct cqspi_driver_platdata k2g_qspi = =3D { static const struct cqspi_driver_platdata am654_ospi =3D { .hwcaps_mask =3D CQSPI_SUPPORTS_OCTAL | CQSPI_SUPPORTS_QUAD, .quirks =3D CQSPI_NEEDS_WR_DELAY, + .execute_tuning =3D cqspi_am654_ospi_execute_tuning, }; =20 static const struct cqspi_driver_platdata intel_lgm_qspi =3D { --=20 2.34.1 From nobody Mon Sep 28 13:17:36 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 5D05F371D01; Fri, 21 Aug 2026 11:49: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=1787312997; cv=fail; b=FnFZKYYJYG+uqNk8SJJMkaBtwox7KVDteSphKs1N/21jEGLAU10HlPI2meofWBmSTKSxwEVGYd+q6YCTQSnRr5c/J3C6nwNL2oohakyD1UHjN/U73g17Jg2DV5rUEMFQjuvjs7fY9pBxSEHVJnVtCxAjwlmkBJeuGQq5ZC7YC/Q= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787312997; c=relaxed/simple; bh=5qnezhdC7z+lORuvm/pjPzGWMGRQvmaJD+gNRZlgLhU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=aT/7ZwwPDTx6Dc8vnZjNvJykNwQ6MSwdLU3ZTlwU7uVawjEW55NbtlZSGbPKXMqW9Lz63B/jObnDfhC5ahH6imjpVl8ds4z8BAskD7HZPzFCTlnOZJjOblN8eretS5n40v0cG9hCWX5nRSVJls1nOiMugAv1boREMpf/9jgRIKs= 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=aNfiMKGe; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=a7SOM8ae; 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="aNfiMKGe"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="a7SOM8ae" 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 67L9KKGE3421342; Fri, 21 Aug 2026 06:49:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint-05-2026; bh=L3r4+4BDkKDSVXfOUwFU3FkZBjUujBJu7lCtNDJ0T so=; b=aNfiMKGePmjXTdP99Dt0K8ng+PrrHni8LUcO4dMeFXbGktCmcyIUO7CR5 hGzVDULLe7LweEnSX0aFzWADKxv7OLqWfDsU66sQHccqwM5tySBrRsg+FxcZ+EN3 KkkQPuLpIRHGQ+9MkE2WCqIHpWc/aySFRiJlkMH7/4abloEeZq3fCapg8SpiPbMs DasgMfwJZQRT4mIS4TGpVDjyLEqL/twjtjiXepK7v/NWyCVncD9kWd8VrrwU9mm2 FModkqzd7gwM9P51pxwipuuiD7ORZP3wz/Xoea9cJib25L983xc9xECRcMOfoZpR el7nx739KCcN3mmY7bvEEtU9OX6Ow== Received: from ch1pr05cu001.outbound.protection.outlook.com (mail-northcentralusazon11010040.outbound.protection.outlook.com [52.101.193.40]) by mx0b-0002e601.pphosted.com (PPS) with ESMTPS id 4g6knmrn0g-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 21 Aug 2026 06:49:41 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=hH0MAlj9PmAPTDtY+wZTelvruVrAX3b+3/ICSiLpmu8ZqoCwN40zLpjj728xJFAgRtIzd4wlmp1D9rk2YZujRMeM8ODR4pndpX1Y2l6zsY07AoA0LbHIiBwGcGJjl7cxV3AVbkMLcoNtBVSQfWbfNwjf1hebxe0A/1wFvqf9QeHUyjTUmTBq8h/ioFNow9wuFWe9ZpzKB6hALZFttYcQWZoCWmep43FFIMvvQJ3fksPosatIyLVOURsW0Rdsn0JWWN1pUu1EaSnJ5ztqLrY6S2BK5pCZhmLYynLY9pxpokQ3qrLMhSg0WAIYI4wCVIwLKAlPRx7NHmwUIKpT68qX/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=L3r4+4BDkKDSVXfOUwFU3FkZBjUujBJu7lCtNDJ0Tso=; b=SeZ5CYwaxH8CC6/lWlBahFawAzoY4dP6MT2tX8nzN8zLdQ9Q6LcqjhdO2eZ/sZ3qvWIFhuNi86Zp+n3XbBkZyKKmOOwwNOGfX0RBrZZmn+jZGFfwCOcdhHAvsdhQZzHQrjSJpKJAeASGlw1fS/yNE7mj7PQSObASEoYQW7qQx9cO5seQXgk82Lupl517IgGY184K1n6RenzcKQBkoD81baQgjYoigOi/YZAbj31YZD/NzJ5HGypboLoXrwGbnyXgHdJlOXyZrEpb35gb6E5HqSZvxc7FHGs1qtbMOqstGOYIYpekALqFzVEGHrO03WEbyuzSM5D0EZZOFRgrQYNZ9A== 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=L3r4+4BDkKDSVXfOUwFU3FkZBjUujBJu7lCtNDJ0Tso=; b=a7SOM8ae/z5kf0JciM9LTGNd/xRMsuQl/WXodvJhBRRGYIUEbEAK+t6wefy4GBK9lnCCOYNH7BKt+FVDtI3aR2Pb4LeqJgOTPn31OZsBR3e1dsEQe7aCEtBz+7ShMaXx0Kb31jZ72QmUdbDLOPGIqW0ch3SeE4SQPZkFUH1auZA= Received: from BN1PR12CA0018.namprd12.prod.outlook.com (2603:10b6:408:e1::23) by IA6PR10MB997683.namprd10.prod.outlook.com (2603:10b6:208:5df::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.339.11; Fri, 21 Aug 2026 11:49:37 +0000 Received: from LV8PEPF0000005A.namprd02.prod.outlook.com (2603:10b6:408:e1:cafe::3b) by BN1PR12CA0018.outlook.office365.com (2603:10b6:408:e1::23) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.339.11 via Frontend Transport; Fri, 21 Aug 2026 11:49:37 +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 LV8PEPF0000005A.mail.protection.outlook.com (10.167.245.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.360.3 via Frontend Transport; Fri, 21 Aug 2026 11:49:36 +0000 Received: from DFLE206.ent.ti.com (10.64.6.64) by flwvzet200.ext.ti.com (10.248.192.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Fri, 21 Aug 2026 06:49:26 -0500 Received: from DFLE207.ent.ti.com (10.64.6.65) by DFLE206.ent.ti.com (10.64.6.64) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Fri, 21 Aug 2026 06:49:26 -0500 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) 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.45 via Frontend Transport; Fri, 21 Aug 2026 06:49:26 -0500 Received: from santhoshkumark.dhcp.ti.com (santhoshkumark.dhcp.ti.com [10.24.52.55]) by lelvem-mr06.itg.ti.com (8.18.1/8.18.1) with ESMTP id 67LBmVlk2022942; Fri, 21 Aug 2026 06:49:21 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , , Subject: [PATCH v8 09/18] spi: cadence-quadspi: skip DDR PHY tuning for 2-byte-address ops (i2383) Date: Fri, 21 Aug 2026 17:18:13 +0530 Message-ID: <20260821114822.4040338-10-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260821114822.4040338-1-s-k6@ti.com> References: <20260821114822.4040338-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-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV8PEPF0000005A:EE_|IA6PR10MB997683:EE_ X-MS-Office365-Filtering-Correlation-Id: 48b79d25-e17a-41cf-1bd7-08deff7a4670 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|23010399003|1800799024|7416014|376014|82310400026|36860700016|22082099003|18002099003|13003099007|6133799003|56012099006|10067099003|921020; X-Microsoft-Antispam-Message-Info: 2b8e9QDnpwXLy7Vjc4HH8yK+sXXvmLhPlErMhsbQMYtBzEaH9s+7QRvWXh9IjEJBcKVgnMBmftWtv6Y5JZL7pPzv1x7BN+tPLHfcE7J5XNwxtecnxVl0P2NtqtQxqqQAJBQieAb2B6+lzAEhL6lHEJrhmVGMZZLAS0wbtac0O3H5LEMc6JqjKuXyAuLZKwgRNkUqa79ppyhTXWiYif+VhhXFJAkUqqKAS9EaBVdQ78s4XAF61i2Gs9rKdboE9bmAbIVYjsvy6SB/a1uJOl6bHBogqT8biu8Jkk4CJmFwEXTU4neam8q/HsJyZ+t1QGqpJBcidVyEOUy4JOa/kH+HOyWP4zu/kTMkkCRPR2rcPyyeUI7sIPg+i5t06WK+X5EVtVdnwVIigm15SqbpnyEtV/nMhwDi/b1YPp38tGjwMQEwRWWm2Z57QeKJtY1F6udRuVbDxozgzQp6JPyBIkF1jjO7kKG5FEVVvUo99AX58/GlGwLo3jUSPA8DbFFn+4sCBUOrXXcjaB8isBZy4bgZ4wCbYqj0HfEgs8IIYjOWDI+lhES4fCpuLOZBoSX+1kvyYBRoiXEEX6Ub0kniUlV7L0PJ4zVX+u7njYMDZck+jZRKumdRRbuvCv9YEsKEyqsOKS4xrjyFS721PqL676ip1fHyCcL4ZEr+4gc4dnZu9RZgi0SL+FUANmoSbJYwtt37IAwcC3uwrHNgusdlRE2oyQ== X-Forefront-Antispam-Report: CIP:198.47.21.194;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:flwvzet200.ext.ti.com;PTR:ErrorRetry;CAT:NONE;SFS:(13230040)(23010399003)(1800799024)(7416014)(376014)(82310400026)(36860700016)(22082099003)(18002099003)(13003099007)(6133799003)(56012099006)(10067099003)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 8rttgtMZ6qrsjr1L97j6+NlEg/rPjWL///q8Fn47uOoALBxZejciKCa1rjj6fC78LcAYr+gkGOLcWzM3syWlrNI6cexkgGQo6m8rLDwtGNXcyrRuw5NZwZZMA1S9HGbTf+zQx3R0xBzXsJPdMRdiddRryPhTuWFZ6970/fgCauq+kQ/TzTZTXhWSm0kfjv+7XzmbXJnCWocwCLQGltRriJXdjQZbpDklsTEdNi0X7fKH1Ylab0e6loTLhcLKlmhCtCUKaBq3E/OmA6+UnVWrhqPHLYTSEMMjZNsMubl6an4bRnv33dsOGHKBivMfW1LIIW+wGBT6JE0cgBdaIGUxBk61Rvc6FLj6yYi0h7B5a1HcMkTDLth/OTyDcR/fINaMcaY7s4v+8cCGFS/2JFvUbH3qyokCHlSLOHyYlVwqZzDulwKXZSGp0QqvbAhCpttG X-Exchange-RoutingPolicyChecked: iXTiBczCmicTuzmUr0ZhftO8tdUjHnVcEsu8o90mWC8BTQZhnPQYbU/Gya88sqhX6Q9204qViQBjjJYd6BTDQ+Eddzv9MG9TIzYaXa83cQU5v3sl8w0XuVeexRZpJ8mUaq0GJYBp2bFodK8T2uZeCrsYvWzDyrwie8B/DJqEWY/X7M5uGvnv39VXcjmc48SiTCQUuZom64f1q1vNWs8JS/YjDpXgympo6eBVCVOA6iD/KcT/5bWtaCKMQysc7iVyhQWaxhY2kvmjE4g9tOkFVN9J9Xua3mhcJ1I8UPROz14AjQUSB1UpdK3RztEjP+AGdt55xcKNuWelt7ptwLEUmg== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Aug 2026 11:49:36.4805 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 48b79d25-e17a-41cf-1bd7-08deff7a4670 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: LV8PEPF0000005A.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA6PR10MB997683 X-Proofpoint-GUID: nLW6SBa2rdUK7n_svcM3E8a8jxJb5dis X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODIxMDA5MCBTYWx0ZWRfX4kFT3EW5PM23 /kiIdpiC/wfw/oAE3Mr4NHB3Hy7J/Ekg7SdmWpsv8eKOti8MJ3FkLmu89TpOUxwW5EHl8YAorIO OdhyEEbR2XTJa/FrU9n88sivRhCC15PtSEf7Tu/pzgWEfF98MdTpd8pUZh5KlALj4Tao/PNFOI6 qkUMwAg4R30j0RZugmOegzGBjD4ibxK3IcwCkuVkf94ntVKcbgLq9TyjuMe7nX4rhis0LIKcHkM bXCEdRtty0Aj3L6SS/cu6eg17voBgPmhmoKYXd6ACw5Tvkm/4znwQEKBiQ6shsQTu24TYxIsBa8 B+iNEXkQZMbe9b5IDFGyBVOBji9A6SnAvqVmj9OevIKkvNb4l8yAoepiub/ii5o/O6kHDupHrfu j1takKyys/HVyEw262ryhZXsGD42fj34YBFuhVjzZMRi/27OCHQj7UpF8WLv50EnT7JEPxjGkmY MwXDWjGNMiiDT1qm3Hg== X-Proofpoint-ORIG-GUID: nLW6SBa2rdUK7n_svcM3E8a8jxJb5dis X-Authority-Analysis: v=2.4 cv=fuzsol4f c=1 sm=1 tr=0 ts=6a883b55 cx=c_pps a=2d9FbaPwie0YXhWIRYJR4A==:117 a=iwqwCZQqcuTv3JOpYdM7/Q==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=IkcTkHD0fZMA:10 a=Sv0fKeRqtYgA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=fPAWb5peG099m5CrUpKH:22 a=sozttTNsAAAA:8 a=T-kh0MV4vbdY-aS4Zb4A:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 X-Proofpoint-Spam-Info: AW1haW4tMjYwODIxMDA5MCBTYWx0ZWRfXzwgH+VDzPcrZ gwjkqTUQtPzUpY6d9Trocy7Id22aZAIhBjvrA1uKmOwMC5a1ut8OuTLD4jIsuutJzyqaP2qm70C 5WJn4ud+gROxd/U1Izuc9qok+cicsj8= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-21_03,2026-08-21_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 malwarescore=0 bulkscore=0 suspectscore=0 priorityscore=1501 adultscore=0 clxscore=1015 phishscore=0 impostorscore=0 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608210090 Erratum i2383 on AM654 locks the address phase in PHY DDR mode when a 2-byte column address is used. DDR PHY tuning must not be attempted for such operations; non-PHY DDR usage is unaffected. [0] Add CQSPI_NO_PHY_TUNING_WITH_ODDR_2B_ADDR quirk and check it in cqspi_am654_ospi_execute_tuning(). When the erratum applies, return 0 with read_op->max_freq cleared =E2=80=94 the op-skip signal that tells the caller to try another op variant. [0] https://www.ti.com/lit/er/sprz544c/sprz544c.pdf Signed-off-by: Santhosh Kumar K --- drivers/spi/spi-cadence-quadspi.c | 43 +++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-qu= adspi.c index 5651320426b1..a1aaba7c1a7e 100644 --- a/drivers/spi/spi-cadence-quadspi.c +++ b/drivers/spi/spi-cadence-quadspi.c @@ -37,19 +37,20 @@ static_assert(CQSPI_MAX_CHIPSELECT <=3D SPI_DEVICE_CS_CNT_MAX); =20 /* Quirks */ -#define CQSPI_NEEDS_WR_DELAY BIT(0) -#define CQSPI_DISABLE_DAC_MODE BIT(1) -#define CQSPI_SUPPORT_EXTERNAL_DMA BIT(2) -#define CQSPI_NO_SUPPORT_WR_COMPLETION BIT(3) -#define CQSPI_SLOW_SRAM BIT(4) -#define CQSPI_NEEDS_APB_AHB_HAZARD_WAR BIT(5) -#define CQSPI_RD_NO_IRQ BIT(6) -#define CQSPI_DMA_SET_MASK BIT(7) -#define CQSPI_SUPPORT_DEVICE_RESET BIT(8) -#define CQSPI_DISABLE_STIG_MODE BIT(9) -#define CQSPI_DISABLE_RUNTIME_PM BIT(10) -#define CQSPI_NO_INDIRECT_MODE BIT(11) -#define CQSPI_HAS_WR_PROTECT BIT(12) +#define CQSPI_NEEDS_WR_DELAY BIT(0) +#define CQSPI_DISABLE_DAC_MODE BIT(1) +#define CQSPI_SUPPORT_EXTERNAL_DMA BIT(2) +#define CQSPI_NO_SUPPORT_WR_COMPLETION BIT(3) +#define CQSPI_SLOW_SRAM BIT(4) +#define CQSPI_NEEDS_APB_AHB_HAZARD_WAR BIT(5) +#define CQSPI_RD_NO_IRQ BIT(6) +#define CQSPI_DMA_SET_MASK BIT(7) +#define CQSPI_SUPPORT_DEVICE_RESET BIT(8) +#define CQSPI_DISABLE_STIG_MODE BIT(9) +#define CQSPI_DISABLE_RUNTIME_PM BIT(10) +#define CQSPI_NO_INDIRECT_MODE BIT(11) +#define CQSPI_HAS_WR_PROTECT BIT(12) +#define CQSPI_NO_PHY_TUNING_WITH_ODDR_2B_ADDR BIT(13) =20 /* Capabilities */ #define CQSPI_SUPPORTS_OCTAL BIT(0) @@ -3211,6 +3212,20 @@ static int cqspi_am654_ospi_execute_tuning(struct sp= i_mem *mem, return -EOPNOTSUPP; } =20 + /* + * Erratum i2383: in PHY DDR mode, a 2-byte column address locks up + * the address phase. Skip DDR PHY tuning for such operations. + */ + if ((cqspi->ddata->quirks & CQSPI_NO_PHY_TUNING_WITH_ODDR_2B_ADDR) && + read_op->addr.nbytes =3D=3D 2 && + (read_op->cmd.dtr || read_op->addr.dtr || read_op->dummy.dtr || + read_op->data.dtr)) { + dev_dbg(dev, + "i2383: skipping DDR PHY tuning (2-byte address)\n"); + read_op->max_freq =3D 0; + return 0; + } + if (write_op) { /* * For NAND: write the calibration pattern to the page cache. @@ -3849,7 +3864,7 @@ static const struct cqspi_driver_platdata k2g_qspi = =3D { =20 static const struct cqspi_driver_platdata am654_ospi =3D { .hwcaps_mask =3D CQSPI_SUPPORTS_OCTAL | CQSPI_SUPPORTS_QUAD, - .quirks =3D CQSPI_NEEDS_WR_DELAY, + .quirks =3D CQSPI_NEEDS_WR_DELAY | CQSPI_NO_PHY_TUNING_WITH_ODDR_2B_ADDR, .execute_tuning =3D cqspi_am654_ospi_execute_tuning, }; =20 --=20 2.34.1 From nobody Mon Sep 28 13:17:36 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 7311648D860; Fri, 21 Aug 2026 11:50:26 +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=1787313028; cv=fail; b=N3mmB4SHMUr02Gw1+7SV1OQMcs+2GyjBGKaIMM3kLTFEFvZMC7Kk0aakXC4M7yXX4OKO+lNRv4DFWm2LzIpD0fgsd67WGTyJQZbdTS/7IrFaeNSEZvX21XxQkoMfI6orA2R2HiTdOTyOTImHAdDbOReEqfGQFrC4Isuzpi54Vro= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787313028; c=relaxed/simple; bh=MDx2qjP/XXiD3vIr9oQt9kMeHBFs0R28iU0agoq2Hnk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ZnkmoCXwDy5X9ppyHccsC1nk6bLk29s3hKKM7uyIMcRTCT1VVhRUEfnGGNPL2V1L/El7mOHoYiJg1ajtvne6+Bju6OVF7NcGYFPfT2DTFs3zH+WT1rkBAsrK0rf9CklQsGsrTmOTmFh1yZdR+GK9e0EtWYwQvon5TRn08hIrMxA= 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=fpylUKhP; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=GSPj4kgP; 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="fpylUKhP"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="GSPj4kgP" 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 67L9KJBN3421338; Fri, 21 Aug 2026 06:50:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint-05-2026; bh=8ugXXaYOACCqQhtO+XS/9SAqsz/zeF6YSVcc8SKLY /0=; b=fpylUKhP1CWD7weTpVuOtIJAhnPVhtGNAI6lr/wky79IHJCO5mz44lMOQ fzA9YfKlGAJfRVyPdG3Y1KhDrLJRkYPWLoQwggZ6MD8tXeQylXZYwtSEuYX/KCDF dxCKXoXZ2JXMAVDQFWKkENAr2Hjsxa50HSM4ScltbvMz80A6f6tJPlCvFck1s6p7 cs/ualY/smzwt0NeYsT5L2pWw01wANstIF8DEv9l59ihdV+93Vz9dRpReQTmaMp7 AQo+Uk0H1WESiyccvmWVItfGzz1FmnBrCWevBD+UciZquPJkwncOi2xCP2frzSDD JGFkD5dUMlasKeoRPN5f4qNkOqq9Q== Received: from dm1pr04cu001.outbound.protection.outlook.com (mail-centralusazon11010051.outbound.protection.outlook.com [52.101.61.51]) by mx0b-0002e601.pphosted.com (PPS) with ESMTPS id 4g6knmrn2j-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 21 Aug 2026 06:50:15 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Z+vlhxZdsp2vnNLfpgYscZoqo6dTlfWL41hrVelqrPRiQITBXN69GkESUPd/eKg8UXZM+mHjSpkA8o5ac39CIkRxfIQNaBhTLhC716oGp7e0cUklGrx3hDbGW6t3kYl+XiU8i2+quo62FJn56Xzsvr0R9Nof6LD/GN6H/8ZIFUlozAtezXEi4c5MOuv/9lG+khc5pErYVCIqG7XtrzHusMYOCJ/jY9GeLVfHrNaDJIO9KD/koMQ90vt/khCX6/AkHbJ2P0fhBA/gLaL4EeTFsk8Gb06W6nYFz28DN1tHEeHuIadkcQa5N4SxLoEoHM4vkdVKy+vamSUo/Ch2n/ku6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=8ugXXaYOACCqQhtO+XS/9SAqsz/zeF6YSVcc8SKLY/0=; b=PggHi7IwT3SE7sdudErv91830QBLY6TBCmqCrBmnLAu1KUzbQCQWxYWHkNP2EhwSg30fEGOwplkOMlMmEqkORHW6PRwGKo0xXR0BLbh4SsSczyi+czbj5LYddfOuG67jIQco9PaorZdIw6Wyoa6oT9xhOxA1WRkB2qzEUwaIvavaqZ9Xm9IApKCVUFQ9FB0CIqNohm6Apdg3UP59zliCQJxM8oh4GfG7KPi/n8xGAk9nsyBoAo6xYNMWhEAl65RkKCMD2+iJLMZJlLaTnAFCLVLU814JQG6pG+ruilYy3TxvWjRqZVnMK7f2du52DHtdFQK98gEB37zL/iOMuO1kvw== 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=8ugXXaYOACCqQhtO+XS/9SAqsz/zeF6YSVcc8SKLY/0=; b=GSPj4kgPtkF8rqSKYmd8Nfn4reZ+UdgpLBvkWLHQnyFM46q5Z/dM9XQYHFmAUsLbkL2NyK6TMdB8kFwn5Efeogg4/IOAyYn+q9z6nLlP4maSN4ISkkFfIhKgP0t0/Xko1AZS9PEmN8fyO7EPWFu7HUrH7eDKbqGBpthm2d73hL4= Received: from CH5P221CA0016.NAMP221.PROD.OUTLOOK.COM (2603:10b6:610:1f2::12) by SA1PR10MB6392.namprd10.prod.outlook.com (2603:10b6:806:258::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.315.13; Fri, 21 Aug 2026 11:49:57 +0000 Received: from CH1PEPF0000AD7B.namprd04.prod.outlook.com (2603:10b6:610:1f2:cafe::d) by CH5P221CA0016.outlook.office365.com (2603:10b6:610:1f2::12) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.339.11 via Frontend Transport; Fri, 21 Aug 2026 11:49:57 +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 CH1PEPF0000AD7B.mail.protection.outlook.com (10.167.244.58) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.360.3 via Frontend Transport; Fri, 21 Aug 2026 11:49:56 +0000 Received: from DFLE206.ent.ti.com (10.64.6.64) by flwvzet201.ext.ti.com (10.248.192.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Fri, 21 Aug 2026 06:49:32 -0500 Received: from DFLE207.ent.ti.com (10.64.6.65) by DFLE206.ent.ti.com (10.64.6.64) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Fri, 21 Aug 2026 06:49:32 -0500 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) 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.45 via Frontend Transport; Fri, 21 Aug 2026 06:49:32 -0500 Received: from santhoshkumark.dhcp.ti.com (santhoshkumark.dhcp.ti.com [10.24.52.55]) by lelvem-mr06.itg.ti.com (8.18.1/8.18.1) with ESMTP id 67LBmVll2022942; Fri, 21 Aug 2026 06:49:26 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , , Subject: [PATCH v8 10/18] spi: cadence-quadspi: refactor direct read path for PHY support Date: Fri, 21 Aug 2026 17:18:14 +0530 Message-ID: <20260821114822.4040338-11-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260821114822.4040338-1-s-k6@ti.com> References: <20260821114822.4040338-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-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000AD7B:EE_|SA1PR10MB6392:EE_ X-MS-Office365-Filtering-Correlation-Id: e96ea42f-7ab5-4679-caa2-08deff7a526c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|36860700016|1800799024|23010399003|82310400026|376014|6133799003|56012099006|10067099003|22082099003|3023799007|18002099003|921020; X-Microsoft-Antispam-Message-Info: NGkxCzp261gkJpg8ejydcCSxF6N7t1gm0WwVkFF9KM1mnEwoUDAY5JDUSuJKYPNUUE9n30TIhRvfxqr1iFj2d4EBMbTYESw+57oMj09QQb/rqTlocPpBEhOOYWloZ2m2Jw88YzDT7Dcm00Q3Cjv/9nXhXKse+z/NhfkNEw9NiqomhinaZTj/A9TNqUPPXZVVvZI/0yASCGxJr2FYmLt6Vmm/0EUgxT1Gn6jSkkOJhc5i20AWYTwrVES/RNOVzqhs6gNwFdsubCqgesBXnw7BDYYJ2ZaerlAME14tA7fhqDWBO94OjjeEjMw4AUWNU0hJ+wJBKbRQ4sshc/E9nN6PVSr3Td0+E7Rfgg6+BF+tkpLdGxk/G5HleQ0Mhx1dZDTRvxpB7l+zO5zAURihiMt/ld0iQkh1ESRAvLHlQoWeG5IwLC14V5x8ob9zx4SFUYBPE7k8Pt1b0MlM2ksDn3l8pz8qL/FWTALikbT4IpifPDdE38vL+y/txzU3PskfELUYXpQvu7wW7wBaQLh8uNuks1TCaku+R9dDtPRWipWla4yjm+T5uij/w0TdKE+jzB21q0EpJ1rnrCvTl/zx9SGgTiwgVhKson+/2OXHbVMBMyNKvXob28Yz+P/31CA+68d9NmUyRh7vdffSkRHEqQYJZuZJXICHNJcHJEcCum1LV8pWjXdLmBeIah47HC7amxBho311TNDbIfb7bh7SiemHHsetP61MV9zDNTUhJiWbbi8JzkvKqpniBjvNuKOAg9CW X-Forefront-Antispam-Report: CIP:198.47.21.195;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:flwvzet201.ext.ti.com;PTR:ErrorRetry;CAT:NONE;SFS:(13230040)(7416014)(36860700016)(1800799024)(23010399003)(82310400026)(376014)(6133799003)(56012099006)(10067099003)(22082099003)(3023799007)(18002099003)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: AHn4Mdk0s+tJS260j9xPOBM0XxktPkY/kDfd7Pba/irmpj27BzV6A0Pq67q+pjhFhLMFan97adwPwwTSyIOfXQGnECMXqrWuMXkh2YG9chRymotG27QSCb4SR5a+F50D0rIBsvDmgluq9AzwkiKg31Ka9hGEkYJusIs6iT8N3IilPzaeZEDyMzQgQJ3kg/oV5LvqXvhbPtZYpXSyxO5t7EnEH+PIslj2pttc+pnk6NHWIPru9F6YNnAbLBT/WqOzVr5VZjS7ht7+UG/dA0xXpWNS2m9ZC/e0hXlvIFdhNe++lf3u5pnbCJxwIY8zhMrAmJT/t/gPSpBCc7azHf9cWUkbsL/ZuglRrNk1ccYHj1NabEzhDc5m5w6IdvrPgr7AwAVXh3/zCNy4X54Xq09xjRs4z9UDcicQ57T1uudwjuxEaL6Tx0+1m7trvCcVJdRs X-Exchange-RoutingPolicyChecked: MHBCZU0WKc+Kpw7wxRPcVA/fsRHX7Pufa4+GF6GsZikIBD4VrmFsKrYKjGAIOGaUgZunjTRHYsbwfK5WtLIJuZvIh/oAQgE9zMrW3BOiA8J0T//ljMMkZJgHP5db7hGO46TeqeoQQwbUiuaIQ2pal3PgoOG82OFjfcl5Yzz1Rn2Nzyom3NAH3GdrGy30UslnU49+TRBUm4gETNaXwp6Or29r5dCA4z8gjjH14HohAeqcFpQdb+wxYndVaE4xXp8JN89e65Tm0Sqyd2PjuK9vDgJtyxmgzRgSV8mEv4oj+cTW8dMoZsTJC/0MyEyJ1ZJ8SCRFjVpY76fYxjw96y888A== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Aug 2026 11:49:56.6071 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e96ea42f-7ab5-4679-caa2-08deff7a526c 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: CH1PEPF0000AD7B.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR10MB6392 X-Proofpoint-GUID: u8d_w_729nD1Xfxr9GELZ3PdN-YTbbkU X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODIxMDA5MCBTYWx0ZWRfXxk6L1M7OoRS1 JxhoUqULiMzNzOElR68cKMxwhLNDT0Jx0YVBpFXPbXhUnWbvpw92whnOdRd/DysJZ4Rsu7NFkJZ g/niEkzcJfoxDaYZURZIoFTNAwrIwGOzhtsw5MmR557scrC5DfmYx6i/Zsqsc7z5LMvThV82Xcp rl4vIrBAC0BARq+jhb6LC1+PXvN1Tc+Qkn/v06p41sDnCxS6xsBFRPxwMtmviGoyDKxRlIkOHww TiZGUaVHny4VqA+WNaFA/jvS9QHOBSZE5ym6l+/Aq9aSEGe9ggsEBRK6R9OiAh1E1EbsxTkNjjm ITLgeKcfPsAWZdqtMnTwT+Npokg8m5YWTpv9hcthjHjmmPId0oL6b+IMMH3GSs9Dlw27VXGWN87 qy3cQQDPQHEFpqrBv7nzLJPkBOV08rhtQi1HtZfhVnRogDwWwboosrQvhmMRuwr53t69iZp/w0C A7HvAkCj+MD6p8Bn0Pg== X-Proofpoint-ORIG-GUID: u8d_w_729nD1Xfxr9GELZ3PdN-YTbbkU X-Authority-Analysis: v=2.4 cv=fuzsol4f c=1 sm=1 tr=0 ts=6a883b77 cx=c_pps a=U2ki1QFzN2iGT7kcnsve6g==:117 a=tJyPKKxUohctrY4NYmUjkA==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=Sv0fKeRqtYgA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=fPAWb5peG099m5CrUpKH:22 a=sozttTNsAAAA:8 a=aauMkRGVHSVL3AvwFNMA:9 X-Proofpoint-Spam-Info: AW1haW4tMjYwODIxMDA5MCBTYWx0ZWRfX6x3SpGVygUWR eF3dDGLZ8wd71KaIXbS/v4CnXa/Ea3+2rNOVCvGsNbvUViitlps4adrfENHx42qbUY0K+F5/xvv rknDI6Z4UbSh1HhvTdSLf5odazfLM14= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-21_03,2026-08-21_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 malwarescore=0 bulkscore=0 suspectscore=0 priorityscore=1501 adultscore=0 clxscore=1015 phishscore=0 impostorscore=0 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608210090 Content-Type: text/plain; charset="utf-8" Extract the DMA transfer code from cqspi_direct_read_execute() into a new cqspi_direct_read_dma() helper. Add cqspi_memcpy_fromio() to handle non-DMA transfers, using 2-byte-aligned I/O reads for 8D-8D-8D mode to satisfy the minimum 16-bit AHB transaction width required by the Cadence OSPI controller in that mode. Change cqspi_direct_read_execute() to take the full spi_mem_op and post_config_max_speed_hz instead of separate buf/from/len parameters, matching the interface needed by the PHY-aware version in the following patch. Thread post_config_max_speed_hz from cqspi_mem_process() through cqspi_read(). Transfers shorter than CQSPI_PHY_MIN_DIRECT_READ_LEN bytes always use the memcpy path; longer transfers use DMA when available. Signed-off-by: Santhosh Kumar K --- drivers/spi/spi-cadence-quadspi.c | 75 ++++++++++++++++++++++++++----- 1 file changed, 65 insertions(+), 10 deletions(-) diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-qu= adspi.c index a1aaba7c1a7e..99a0ec0e769c 100644 --- a/drivers/spi/spi-cadence-quadspi.c +++ b/drivers/spi/spi-cadence-quadspi.c @@ -30,6 +30,7 @@ #include #include #include +#include =20 #define CQSPI_NAME "cadence-qspi" #define CQSPI_MAX_CHIPSELECT 4 @@ -154,6 +155,8 @@ struct cqspi_driver_platdata { #define CQSPI_READ_TIMEOUT_MS 10 #define CQSPI_BUSYWAIT_TIMEOUT_US 500 #define CQSPI_DLL_TIMEOUT_US 300 +/* Minimum transfer length to use DMA for direct reads */ +#define CQSPI_PHY_MIN_DIRECT_READ_LEN 17 =20 /* Runtime_pm autosuspend delay */ #define CQSPI_AUTOSUSPEND_TIMEOUT 2000 @@ -1528,8 +1531,8 @@ static void cqspi_rx_dma_callback(void *param) complete(&cqspi->rx_dma_complete); } =20 -static int cqspi_direct_read_execute(struct cqspi_flash_pdata *f_pdata, - u_char *buf, loff_t from, size_t len) +static int cqspi_direct_read_dma(struct cqspi_flash_pdata *f_pdata, u_char= *buf, + loff_t from, size_t len) { struct cqspi_st *cqspi =3D f_pdata->cqspi; struct device *dev =3D &cqspi->pdev->dev; @@ -1541,11 +1544,6 @@ static int cqspi_direct_read_execute(struct cqspi_fl= ash_pdata *f_pdata, dma_addr_t dma_dst; struct device *ddev; =20 - if (!cqspi->rx_chan || !virt_addr_valid(buf)) { - memcpy_fromio(buf, cqspi->ahb_base + from, len); - return 0; - } - ddev =3D cqspi->rx_chan->device->dev; dma_dst =3D dma_map_single(ddev, buf, len, DMA_FROM_DEVICE); if (dma_mapping_error(ddev, dma_dst)) { @@ -1587,8 +1585,63 @@ static int cqspi_direct_read_execute(struct cqspi_fl= ash_pdata *f_pdata, return ret; } =20 +static void cqspi_memcpy_fromio(const struct spi_mem_op *op, void *to, + const void __iomem *from, size_t count) +{ + if (op->data.buswidth =3D=3D 8 && op->data.dtr) { + unsigned long from_addr =3D (unsigned long)from; + + /* Handle unaligned start with 2-byte read */ + if (count && !IS_ALIGNED(from_addr, 4)) { + put_unaligned_le16(__raw_readw(from), to); + from +=3D 2; + to +=3D 2; + count -=3D 2; + } + + /* + * Use an explicit 32-bit read loop for the bulk; this + * guarantees the minimum 16-bit AHB transaction width required + * in 8D-8D-8D mode on all architectures. + */ + while (count >=3D 4) { + put_unaligned_le32(__raw_readl(from), to); + from +=3D 4; + to +=3D 4; + count -=3D 4; + } + + /* Handle remaining 2 bytes */ + if (count) + put_unaligned_le16(__raw_readw(from), to); + + return; + } + + memcpy_fromio(to, from, count); +} + +static int cqspi_direct_read_execute(struct cqspi_flash_pdata *f_pdata, + const struct spi_mem_op *op, + u32 post_config_max_speed_hz) +{ + struct cqspi_st *cqspi =3D f_pdata->cqspi; + loff_t from =3D op->addr.val; + size_t len =3D op->data.nbytes; + u_char *buf =3D op->data.buf.in; + + if (!cqspi->rx_chan || !virt_addr_valid(buf) || + len < CQSPI_PHY_MIN_DIRECT_READ_LEN) { + cqspi_memcpy_fromio(op, buf, cqspi->ahb_base + from, len); + return 0; + } + + return cqspi_direct_read_dma(f_pdata, buf, from, len); +} + static ssize_t cqspi_read(struct cqspi_flash_pdata *f_pdata, - const struct spi_mem_op *op) + const struct spi_mem_op *op, + u32 post_config_max_speed_hz) { struct cqspi_st *cqspi =3D f_pdata->cqspi; const struct cqspi_driver_platdata *ddata =3D cqspi->ddata; @@ -1604,7 +1657,8 @@ static ssize_t cqspi_read(struct cqspi_flash_pdata *f= _pdata, =20 if ((cqspi->use_direct_mode && ((from + len) <=3D cqspi->ahb_size)) || (cqspi->ddata && cqspi->ddata->quirks & CQSPI_NO_INDIRECT_MODE)) - return cqspi_direct_read_execute(f_pdata, buf, from, len); + return cqspi_direct_read_execute(f_pdata, op, + post_config_max_speed_hz); =20 if (cqspi->use_dma_read && ddata && ddata->indirect_read_dma && virt_addr_valid(buf) && ((dma_align & CQSPI_DMA_UNALIGN) =3D=3D 0)) @@ -1632,7 +1686,8 @@ static int cqspi_mem_process(struct spi_mem *mem, con= st struct spi_mem_op *op) !cqspi->disable_stig_mode)) return cqspi_command_read(f_pdata, op); =20 - return cqspi_read(f_pdata, op); + return cqspi_read(f_pdata, op, + mem->spi->post_config_max_speed_hz); } =20 if (!op->addr.nbytes || !op->data.buf.out) --=20 2.34.1 From nobody Mon Sep 28 13:17:36 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 D513546EC8A; Fri, 21 Aug 2026 11:49:55 +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=1787313002; cv=fail; b=tOQ0Y95keR9K+gmNFDeZmMo1VByQe+GtpmOk4IqBEQQoVOGXR/DFy+YMfswbMjvop0hOGoe8BsfJbASVp3tIzBY/TqSot0EVZj97hEnKNMQaCNs49ynwMeeP6OAleqHmDoAxUzzvYC5MlNLmWj3IdJekDtDU9Rqms6FWV2Lf240= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787313002; c=relaxed/simple; bh=F/AnUyhlV2AtS07KGqLS/htPuNT5wzyKdLdJIRHf0Yg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Rr6ZlNc5juquyJ+QI573mgb4wVH14Iyo3uc34S5IVwbiZMHoeq6fCmqd1z955qTNiU25W3LVLWfzzTiN7ip259RyN3ET15wGxJcqA18YJjHMZo7wTKL/jVEBRkWb0q8VaDcArfHdC58iv4kMXYPlOVfb1rm6i8BsId3SLZHguWE= 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=pG0je7W5; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=gVR4vDtg; 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="pG0je7W5"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="gVR4vDtg" 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 67L9KLvm3421359; Fri, 21 Aug 2026 06:49:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint-05-2026; bh=Tt2uwvzIqMNehFK76PrQJ6oaooM0SB13UAqWfokUR pU=; b=pG0je7W5qTr4LPALJs8kqQzV6immm7HNFIbJx7Jv+WisEtA0nITvRImqi q8+vg1uxHn8asvL3WtSDDFw0K8MDQf6fcYQboAaPSXVmE5YbuJ/TRSZpCVD8mUBq NNlh8b5iY25ZVXycc319bymROaH7Orj1NcxFrzVBHzFXuCdZ5kpHbhi3InUTkl36 eu/RcPH1oolKERwxRN7Gg4TNiSUP14viTzuk94boEwk6ESHoE+aY/nm47JgRl2ln TgaFQ+wtuKywAnUffupJ2LkPjGcfNpHuICf6MKnkTpHzvvuyBK8mRmrnoxBD4G/C 0ob5T8Dct3/j7xRUAjL7yPvBvTKFQ== Received: from bl2pr02cu003.outbound.protection.outlook.com (mail-eastusazon11011031.outbound.protection.outlook.com [52.101.52.31]) by mx0b-0002e601.pphosted.com (PPS) with ESMTPS id 4g6knmrn0n-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 21 Aug 2026 06:49:45 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=i1OGh8dhV1QlqdPGJA14sLBYNwZVKIEqfAvA4ANX6fh8BwFV3ZllmzUMWE/Aqv7X8mLxq3tV9sTrcvaoanYKjuWoJE5s2gJ5MhUovwxeT0V7cgI4KUp5EvpQmHIyNcaU3HEroLh8kn4litTjM8D5w2ub0kWzvKzSkgMA02kPWlWUvV8nBn/QW7NOrDEo3Bf0m6GsNQ1Up57hVmcMKnqVq+qzaOi9WTnFWMoDX9/IQAWjDBIhbq5fQ2ZyD6bczEl+PdrwHes5cWOpersY1n/VbHdPaRs1aL7VSKZftmBniD2LJgHUi+T2iJ0ITXaG4UcAzma1DM7tfY2x4GVBD6tmOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Tt2uwvzIqMNehFK76PrQJ6oaooM0SB13UAqWfokURpU=; b=IH/A3uaHQEZq+hcuDXKZXwQSm5OGg8p/wZ6F9BZyAclWfxCUzX1Roh2ZO+Rqm7RgYgj9NsXRs6mxGNhFFR1yfp0Rj4Nyp3zZQlismN9/D1YYTp8y1o+wpfPHJfUjFTUN3FRbZFyDpzvzOxpbZgxzJIS2pYIL5RNMUysqEHXSk5/cQJVJD/e87v3cgpVbMOEess0cRbf92wGYK9qZiR4FhW0Jw7IYfc3IT0fj5DTTUPw6Y/ThQvMBf4f5yU5XODoLobZRvOu6P5V0G0Em+TQCchj1WCqrGh9oOphT8ql+rmILDYGXOabUXgVvK/jnUEdJTw7UkIFor5jq+yjP46YqcQ== 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=Tt2uwvzIqMNehFK76PrQJ6oaooM0SB13UAqWfokURpU=; b=gVR4vDtgRE/T8CbBM+MXl9hAS71mrn4i1A59ZAD/qtwrkGC43sqeFrugDt2QFehmSPQFhiHQxTlZ/Vp0GZAMhrltoYq+DaTvg8fnnA9fakrUJtE8DlfqSPvsfbv/b6AhmrpjSE+pc8ffF+TaC43stAyzv2bhwWEQT5KToSs+UPc= Received: from CH0PR13CA0017.namprd13.prod.outlook.com (2603:10b6:610:b1::22) by DSVPR10MB998077.namprd10.prod.outlook.com (2603:10b6:8:422::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.339.11; Fri, 21 Aug 2026 11:49:42 +0000 Received: from CH1PEPF0000AD7E.namprd04.prod.outlook.com (2603:10b6:610:b1:cafe::48) by CH0PR13CA0017.outlook.office365.com (2603:10b6:610:b1::22) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.360.3 via Frontend Transport; Fri, 21 Aug 2026 11:49:42 +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 CH1PEPF0000AD7E.mail.protection.outlook.com (10.167.244.87) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.360.3 via Frontend Transport; Fri, 21 Aug 2026 11:49:42 +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.45; Fri, 21 Aug 2026 06:49:37 -0500 Received: from DLEE205.ent.ti.com (157.170.170.85) 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.45; Fri, 21 Aug 2026 06:49:37 -0500 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) by DLEE205.ent.ti.com (157.170.170.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45 via Frontend Transport; Fri, 21 Aug 2026 06:49:37 -0500 Received: from santhoshkumark.dhcp.ti.com (santhoshkumark.dhcp.ti.com [10.24.52.55]) by lelvem-mr06.itg.ti.com (8.18.1/8.18.1) with ESMTP id 67LBmVlm2022942; Fri, 21 Aug 2026 06:49:32 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , , Subject: [PATCH v8 11/18] spi: cadence-quadspi: enable PHY for direct reads Date: Fri, 21 Aug 2026 17:18:15 +0530 Message-ID: <20260821114822.4040338-12-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260821114822.4040338-1-s-k6@ti.com> References: <20260821114822.4040338-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-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000AD7E:EE_|DSVPR10MB998077:EE_ X-MS-Office365-Filtering-Correlation-Id: 5aac8424-9ead-4490-b7b7-08deff7a49e7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|23010399003|82310400026|376014|7416014|1800799024|36860700016|921020|6133799003|10067099003|56012099006|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: RvsnJiLykKjvJJ5nNTkwgZUpu/Xt+8tc38Nbc5e7crwLj11PGnhO4OOTU+ESyTc/D6ZXavSheGQZh/2bVDrsdzu8nBkvGeEIFi9fpZKNWihiO047q92xiocWPxDeHA+W/HGXKVotvRTtHZc0clp3ppxZ0hN43od63uHaQ9/BW9kcVcvzAqZ1doGGWI6pTbDvjsID9Yc7ZDpWPyuZF8xn/Xn26CdBTG2Lc8wJ10nJlEv+hPpxlAcy/+UfWrMz+84fbAH1ONLtpwBeITb1Jv4FfD+ZudxLaZWB0wXupo8zUASo7+CgyNUrA40gcVbW1eke9zWWWVbvtz/crSrBt5GZHzKT3VnVmYs1ospWCLDElAweGgt0W2vM2t2yDFqg+XAkrP/DYu21SvJNp7TGQ7RFrieecuhBkQCaVxAYcXOPLTZmiEj6HvHYc6/HnAfvFg7/7sK/x6YuPAcHTg7K9ur8hubSgUaYTVy1rv+FcK3/mCKdzNabgfwKL8IhoJtyS5WyMvWFxB2H1M/oMSyYkivdhnP2kPbbCm1aQpGjoUbvXLbkSS1GETNMOLdbsTlcfZ51ofbh1xC0f5eYzW6g+oPABh1R8+M4eULxgsI9T/mZFQlR7SJvOfELZZPq2PIxTxDEoDu+Vb57ZD17AliFHhxtbxER4QoYa4zoHyqMtm0B48H26kdNXBxKrKul+OLZpbdO8cz8ov9WPFTXax9cTjGbirWrXsjtf8uLvsZ6YSQAEH4N1+bCbriEzcVV8MPcqRta 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)(23010399003)(82310400026)(376014)(7416014)(1800799024)(36860700016)(921020)(6133799003)(10067099003)(56012099006)(18002099003)(22082099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: oA87Q+RLsO1dSF7YkH/ijIgtIAFm1qhUDTqqhAsb5SfS3V92yK+VI1CzZs5QDQq7x3I0+VQCce40RDLukb12ZHyj2honNDRsoBl12KRQ7SLwmIOxJmZxfnrVOFLgVcYevFWN/Q+bivFt8ZT59IxvHF7l4puzjxY1OtQTk3XFKOzkWm7A5n80tADjCAYFFSdTUSinz1HlV6cWNCfpYTjRwR+Jd7lgh00o6YMxyP6Xqtc8QKwm+7GCFaaNKjkCjrL4gR3L71GA5bwAoGfEAkFKz1bxGTZsN0oCruRmUO8g02pmMLFWQsBuCbJjEoKI4AiDNGPzsjELdEZayzJjCHf2f3LEEkd6ltlsJYTFX1IHqeWOqnMt4+z2ofMYlA+8spNEk0ACeuyZPvMvPOx2KSeESmx36/otbbj5rBOCIhW8dp1APxNktXzDxmktFV3rkiDc X-Exchange-RoutingPolicyChecked: oRIl20JAJPQUUkwdqxV7vme5YvIHrlhxiMzVN1w96EcNlBUlYCzSJv6IAT2zqDL/xUtx7Co8mQyAOJ9r34iVLna5lXjDcm+WuRp3AtYhm5mLCch9hAyLF1AJXxqDAzFPdc3tkVPErdSPWv0fXI6d8h1pKBxl4QV/4C304iNUP4dJOKIoG1U/BHwU7WTV2zhXXhL7tl135yaO87Fj3ZzTge+x/xBph5zuaLzDLy8QgHfEFq/0l8wP3FFBrZp06OQ7ub8BI+lQxqEEn6OHLROAph+vj2ibn9chozGiJJExaWBJWOk5BgRO+eiUZ7iSXeNWvMomCWDXGTRsEhelUT4UOQ== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Aug 2026 11:49:42.3260 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5aac8424-9ead-4490-b7b7-08deff7a49e7 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: CH1PEPF0000AD7E.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DSVPR10MB998077 X-Proofpoint-GUID: 1SYcASCU8Ei-rTLUadVdyqjVkPEALVb9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODIxMDA5MCBTYWx0ZWRfXxqx68fOw1mc9 Z7pjtVXahb37alMAlfAb/UKpNUW6QuVMhrgXUR19vs/Hx5wgGIKag5sjOT9AqKyGNkFngJk53EG KrKJKua8x+5uxY6A3grPfTtaUnv8kVUX5BPSVmDbn6Lx+m3WIdKJLRaRpjFNodUqMzH7A1fJgSc ujSHYR6Xpjb4FEkO1mwb5momUwbp8HUyWlz3J3/Ga+wd48tOeNjIyy3uAn4ihx724L9Oq0Cwlmq xhO/lK17kMrqHgjLeZL96leXoELZeJk3m4jNjStdQCRUFumQnwf3OrMUVvjZ/rsXLu6kx2qTwlQ p539Hjf75BRUZj8Lqplshp8CkCkFOowGjI2wKejWxBy2TzjmjD2AqGFjJSkqa2hpWksczFa2RKh GlQJf+zUcSzcOoddBpLvkD3aXqUS6eqIeL8NH3yg1ivWzpbqJszf5ATX4m7m/zsh8aNFV+xdDAu GTMGiWxZnQXPRcDzOvA== X-Proofpoint-ORIG-GUID: 1SYcASCU8Ei-rTLUadVdyqjVkPEALVb9 X-Authority-Analysis: v=2.4 cv=fuzsol4f c=1 sm=1 tr=0 ts=6a883b59 cx=c_pps a=PWz2vMGk566g1z9MD32Dlw==:117 a=WotqVVQAdb04rnGuttW3Kw==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=Sv0fKeRqtYgA:10 a=s63m1ICgrNkA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=fPAWb5peG099m5CrUpKH:22 a=sozttTNsAAAA:8 a=DtXw2DrE-T2x2gJjnU0A:9 X-Proofpoint-Spam-Info: AW1haW4tMjYwODIxMDA5MCBTYWx0ZWRfX99UhNOxP0itu qiswMDGosaOo2VkwXMg82RdLfAJfKp1+oNjHgaoo37OGV0rOZWoOTEhxipAd67l6oxa/lnOhiHs uh2hOGJZqy0VVr1C3ESvHQCL9Fcqf2A= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-21_03,2026-08-21_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 malwarescore=0 bulkscore=0 suspectscore=0 priorityscore=1501 adultscore=0 clxscore=1015 phishscore=0 impostorscore=0 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608210090 Content-Type: text/plain; charset="utf-8" Add cqspi_tune_phy() to toggle PHY mode around a DMA transfer. On enable: reprogramme the DLL from the per-CS calibration result when the hardware values differ (handles alternating PHY reads across two chip selects with different calibration), configure read-capture for the tuned delay, assert PHY_EN and PHY_PIPELINE in CONFIG, and decrement the dummy cycle count by one since the PHY data-capture pipeline absorbs that latency. The original count is saved in cqspi->phy_saved_dummy so the disable path restores it exactly, handling the case where the original count was zero. On disable, all settings are reversed using the saved count. Add cqspi_use_tuned_phy() predicate: PHY is activated only when calibration completed successfully and the op frequency equals the post-config rate. For direct reads, PHY is used only when both the start address and end address are 16-byte aligned. Unaligned transfers fall back to non-PHY DMA. Signed-off-by: Santhosh Kumar K --- drivers/spi/spi-cadence-quadspi.c | 119 +++++++++++++++++++++++++++++- 1 file changed, 118 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-qu= adspi.c index 99a0ec0e769c..8903b4cf4f6f 100644 --- a/drivers/spi/spi-cadence-quadspi.c +++ b/drivers/spi/spi-cadence-quadspi.c @@ -1074,6 +1074,102 @@ static int cqspi_resync_dll(struct cqspi_st *cqspi) return ret; } =20 +static int cqspi_tune_phy(struct cqspi_flash_pdata *f_pdata, bool enable) +{ + struct cqspi_st *cqspi =3D f_pdata->cqspi; + void __iomem *reg_base =3D cqspi->iobase; + u32 reg; + u8 dummy; + int ret; + + ret =3D cqspi_wait_idle(cqspi); + if (ret) + return ret; + + if (enable) { + /* + * CQSPI_REG_PHY_CONFIG holds the RX/TX delay line tap counts + * and is a single global register with no per-CS equivalent. + * Reprogramme and resync the DLL when the active device's + * calibrated values differ from what is currently in hardware, + * which happens when alternating PHY reads between two chip + * selects with different calibration results. + */ + reg =3D readl(reg_base + CQSPI_REG_PHY_CONFIG); + if (((reg >> CQSPI_REG_PHY_CONFIG_RX_DEL_LSB) & + CQSPI_REG_PHY_CONFIG_RX_DEL_MASK) !=3D f_pdata->phy_setting.rx || + ((reg >> CQSPI_REG_PHY_CONFIG_TX_DEL_LSB) & + CQSPI_REG_PHY_CONFIG_TX_DEL_MASK) !=3D f_pdata->phy_setting.tx) { + cqspi_set_dll(reg_base, f_pdata->phy_setting.rx, + f_pdata->phy_setting.tx); + ret =3D cqspi_resync_dll(cqspi); + if (ret) + return ret; + } + + cqspi_readdata_capture(cqspi, !f_pdata->use_dqs, f_pdata->use_dqs, + f_pdata->phy_setting.read_delay); + + reg =3D readl(reg_base + CQSPI_REG_CONFIG); + reg |=3D CQSPI_REG_CONFIG_PHY_EN | CQSPI_REG_CONFIG_PHY_PIPELINE; + writel(reg, reg_base + CQSPI_REG_CONFIG); + + /* + * The PHY data-capture pipeline absorbs one dummy cycle's + * worth of latency; reduce the count to avoid over-compensation. + * Save the original count so the disable path can restore it + * exactly, regardless of whether the original was zero. + */ + reg =3D readl(reg_base + CQSPI_REG_RD_INSTR); + dummy =3D FIELD_GET(CQSPI_REG_RD_INSTR_DUMMY_MASK + << CQSPI_REG_RD_INSTR_DUMMY_LSB, + reg); + cqspi->phy_saved_dummy =3D dummy; + if (dummy) + dummy--; + reg &=3D ~(CQSPI_REG_RD_INSTR_DUMMY_MASK + << CQSPI_REG_RD_INSTR_DUMMY_LSB); + reg |=3D FIELD_PREP(CQSPI_REG_RD_INSTR_DUMMY_MASK + << CQSPI_REG_RD_INSTR_DUMMY_LSB, + dummy); + writel(reg, reg_base + CQSPI_REG_RD_INSTR); + + ret =3D cqspi_wait_idle(cqspi); + if (ret) { + reg =3D readl(reg_base + CQSPI_REG_CONFIG); + reg &=3D ~(CQSPI_REG_CONFIG_PHY_EN | + CQSPI_REG_CONFIG_PHY_PIPELINE); + writel(reg, reg_base + CQSPI_REG_CONFIG); + reg =3D readl(reg_base + CQSPI_REG_RD_INSTR); + reg &=3D ~(CQSPI_REG_RD_INSTR_DUMMY_MASK + << CQSPI_REG_RD_INSTR_DUMMY_LSB); + reg |=3D FIELD_PREP(CQSPI_REG_RD_INSTR_DUMMY_MASK + << CQSPI_REG_RD_INSTR_DUMMY_LSB, + cqspi->phy_saved_dummy); + writel(reg, reg_base + CQSPI_REG_RD_INSTR); + } + return ret; + } + + cqspi_readdata_capture(cqspi, !cqspi->rclk_en, false, + f_pdata->read_delay); + + reg =3D readl(reg_base + CQSPI_REG_CONFIG); + reg &=3D ~(CQSPI_REG_CONFIG_PHY_EN | + CQSPI_REG_CONFIG_PHY_PIPELINE); + writel(reg, reg_base + CQSPI_REG_CONFIG); + + reg =3D readl(reg_base + CQSPI_REG_RD_INSTR); + reg &=3D ~(CQSPI_REG_RD_INSTR_DUMMY_MASK + << CQSPI_REG_RD_INSTR_DUMMY_LSB); + reg |=3D FIELD_PREP(CQSPI_REG_RD_INSTR_DUMMY_MASK + << CQSPI_REG_RD_INSTR_DUMMY_LSB, + cqspi->phy_saved_dummy); + writel(reg, reg_base + CQSPI_REG_RD_INSTR); + + return cqspi_wait_idle(cqspi); +} + static int cqspi_versal_indirect_read_dma(struct cqspi_flash_pdata *f_pdat= a, u_char *rxbuf, loff_t from_addr, size_t n_rx) @@ -1524,6 +1620,14 @@ static ssize_t cqspi_write(struct cqspi_flash_pdata = *f_pdata, return cqspi_indirect_write_execute(f_pdata, to, buf, len); } =20 +static bool cqspi_use_tuned_phy(struct cqspi_flash_pdata *f_pdata, + const struct spi_mem_op *op, + u32 post_config_max_speed_hz) +{ + return f_pdata->use_tuned_phy && + op->max_freq =3D=3D post_config_max_speed_hz; +} + static void cqspi_rx_dma_callback(void *param) { struct cqspi_st *cqspi =3D param; @@ -1629,6 +1733,7 @@ static int cqspi_direct_read_execute(struct cqspi_fla= sh_pdata *f_pdata, loff_t from =3D op->addr.val; size_t len =3D op->data.nbytes; u_char *buf =3D op->data.buf.in; + int ret; =20 if (!cqspi->rx_chan || !virt_addr_valid(buf) || len < CQSPI_PHY_MIN_DIRECT_READ_LEN) { @@ -1636,7 +1741,19 @@ static int cqspi_direct_read_execute(struct cqspi_fl= ash_pdata *f_pdata, return 0; } =20 - return cqspi_direct_read_dma(f_pdata, buf, from, len); + if (!cqspi_use_tuned_phy(f_pdata, op, post_config_max_speed_hz)) + return cqspi_direct_read_dma(f_pdata, buf, from, len); + + if (!IS_ALIGNED(from, 16) || !IS_ALIGNED(from + len, 16)) + return cqspi_direct_read_dma(f_pdata, buf, from, len); + + ret =3D cqspi_tune_phy(f_pdata, true); + if (ret) + return ret; + ret =3D cqspi_direct_read_dma(f_pdata, buf, from, len); + cqspi_tune_phy(f_pdata, false); + + return ret; } =20 static ssize_t cqspi_read(struct cqspi_flash_pdata *f_pdata, --=20 2.34.1 From nobody Mon Sep 28 13:17:36 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 7398345C718; Fri, 21 Aug 2026 11:50:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=148.163.154.28 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787313013; cv=fail; b=NuiYhjVAA4DQL5V/kIqmj/habLiKfsOEKgq+T7Rv34U3/bCzsRPHu5ILTO1xqIcR/Y+5Bm8/msDkuGTacY7/J1FfwWXhkf3PAWs518o0W+pdwd6IoknDFC8gtEvAmbBYhNEvnefAKwecSCZGe/4nrfqJkIs1C0OrRLh3GJKTYNY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787313013; c=relaxed/simple; bh=hq3CAzkpUTFk1VJMd1fRN0aOyH91Gsjw88BXwndIXfQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=lOeGyIAd5s5GlTB4ZS6czLWj1069MTB0Cc4lXDIrrUnCvkLdA1KS7R4g0zH7OUsNY7fEUiPv6TtRe6prhVb8ygOlQdwDpOGjix8bePdefRQ657meuD8ZY4zXbrEpb4w+ZSJbUXprRbDT6qVLo4Gg7VluvLMlaOnw/Xm0OOHxdSc= 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=DscyiKgw; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=oBFk/9hK; 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="DscyiKgw"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="oBFk/9hK" 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 67L9KJBH3421338; Fri, 21 Aug 2026 06:49: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=320EJlLRqwG8h40qGDXjoLwm6rLEiZlkRgVW5kT+7 i4=; b=DscyiKgwgStsfsc19jfYrc/UXsh/ylYm3XTEO8eqQGTIH/Brz09fFBIKZ ddjxkMeFRkOmn12l1xYyaeP5R4es5K0O2d+76c3XLuZfvaVIo7PL0gk20TKp+u58 tbW21dByX8C5w/2+Cdg1qtvcaETBlDl/wxfYdZlTJCTUQqis3Be3gkTjyS4ABvmp afNFVnJlYM8boPiCKrgLh0nrBcsLxmgP8bGg8g6MwWeCnfsptPo1UgUwYxOxy8cs UoE8onMPVfb+qd7U7vU/dDt1FHxKDG+CPcr+DMY6QdH4vVshu+s2/wzVQadhU4u/ B+ye020IcYFBy0vxLtglWvL6X2Ylg== Received: from sa9pr02cu001.outbound.protection.outlook.com (mail-southcentralusazon11013029.outbound.protection.outlook.com [40.93.196.29]) by mx0b-0002e601.pphosted.com (PPS) with ESMTPS id 4g6knmrn0r-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 21 Aug 2026 06:49:46 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=tXRGSwcNtxEEaOhWmJlNNTyCQLWuz3Dw/xYzsOd0EQkkHO1vmdPtPgobQTfZ+e2pD4sM3gXbm8C0Go9JlVW73CKJicxmhVw9eXHaEIThz4NW21xvwjSJgMe5y8fpBQY25eUYTAt+vQ8y0RU6jBNw+KuOUn/pPPhJGC3T8C7QVfnVO/tqkLPidqOreBtHsY7auVaXIXRB3rIyaHWNXR+uqrnJpo0MXZ2cIh6CSDyhlNNiv551fwR7JHU+n81UthVFJtSKILLky0Zk+Vc8WMntqc8Piy97py5Jqcm7ILkqOxaa28w4eiKtXm9X4xJQCUvtqnFiisEebaPQaRGZ4S/ArQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=320EJlLRqwG8h40qGDXjoLwm6rLEiZlkRgVW5kT+7i4=; b=hoS1Yo/Z/3MAB4Z5M89ooC2sPuvOcES9C5engxnlHAyJqpynwJzUQ1jBdb0Xbl6Oh1YfFmytbQv9xmIdrmcpeQI7UHpeOgauhGwOwYlFa1tZsr+fJf5l7yNx0mvRo1uqAYO5qokwTjAosIuB+UmTiqQITblOXXgkKlDAP+aWbuPhmvk4KBDKpTQu6sxIDLFtfGBwf8kQmoqdA0UxShETnqz07STK0FN627M33rGBdJaDyk5zIU5bCeYJUyDANYK8vwnY79qGU+KcKcdmMbcDAsFCJhPapYXr4K4OX5+QjzfwZqnurrwYberxBNkPyaWAJQdWp6y56av74A/ez4YD/A== 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=320EJlLRqwG8h40qGDXjoLwm6rLEiZlkRgVW5kT+7i4=; b=oBFk/9hK/Vp5fDtuhMxH6nUTUUgttOPAHNNfNuGcZpx8SvAEYxpnSOs2NfPenD3qD9dbQAErX9LZbj3X7chM2hsrULosA3MUl+zFPEjYeOQ7I40Zvh8NTiKoev6IotNzIbSC+AIPwB/yn9Al0Gf4pBvE7RawJv1yIsLe4S9qxJg= Received: from SJ0PR03CA0129.namprd03.prod.outlook.com (2603:10b6:a03:33c::14) by DS0PR10MB997650.namprd10.prod.outlook.com (2603:10b6:8:313::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.339.11; Fri, 21 Aug 2026 11:49:44 +0000 Received: from BY1PEPF0001AE1A.namprd04.prod.outlook.com (2603:10b6:a03:33c:cafe::8) by SJ0PR03CA0129.outlook.office365.com (2603:10b6:a03:33c::14) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.315.17 via Frontend Transport; Fri, 21 Aug 2026 11:49:43 +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 BY1PEPF0001AE1A.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.360.3 via Frontend Transport; Fri, 21 Aug 2026 11:49:43 +0000 Received: from DLEE209.ent.ti.com (157.170.170.98) by lewvzet201.ext.ti.com (10.4.14.104) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Fri, 21 Aug 2026 06:49:42 -0500 Received: from DLEE215.ent.ti.com (157.170.170.118) by DLEE209.ent.ti.com (157.170.170.98) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Fri, 21 Aug 2026 06:49:42 -0500 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) by DLEE215.ent.ti.com (157.170.170.118) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45 via Frontend Transport; Fri, 21 Aug 2026 06:49:42 -0500 Received: from santhoshkumark.dhcp.ti.com (santhoshkumark.dhcp.ti.com [10.24.52.55]) by lelvem-mr06.itg.ti.com (8.18.1/8.18.1) with ESMTP id 67LBmVln2022942; Fri, 21 Aug 2026 06:49:37 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , , Subject: [PATCH v8 12/18] spi: cadence-quadspi: enable PHY for indirect writes Date: Fri, 21 Aug 2026 17:18:16 +0530 Message-ID: <20260821114822.4040338-13-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260821114822.4040338-1-s-k6@ti.com> References: <20260821114822.4040338-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-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY1PEPF0001AE1A:EE_|DS0PR10MB997650:EE_ X-MS-Office365-Filtering-Correlation-Id: 1360da1e-5070-41af-1a87-08deff7a4a6c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700016|23010399003|82310400026|7416014|376014|921020|22082099003|18002099003|56012099006|10067099003|6133799003; X-Microsoft-Antispam-Message-Info: hDINCgiJ+yzRytAA0OUCsXva1ZK3bDovYCXK4OPs3IK9qwFiforTOxxXs9kWn986HsK2wF3IZMcdNkBxQC68C5/2kRnugI3FVHB5WTORepoEIinFlyuLr4nemqTiRNDCPxpHpzC2ZHKVdfnslGEcdbrpbDUyAM3O0T5/QBKmq+zyBip4cfcI4JFe1owU6k/9A3nGNnq73iD8NOyzGiIcfVm+qwKQoi6Y84XhFE86cCRtR47PTjVFebXoZsb37sBRIOtdtzkaVDZCUZvS5NODUVVw7r3Codcfn+ihnbVmcPVbKm+DrKyeuzXMpE6zfkdwZ12o4MklZY4B0xbw1H5IMJGVHj+bU2Gz1TelkxPOE/cBT1j7VbrJ+uN56nj2Urnuk7BZPNwA4f9gSDcuYCKo8E5C0AIdPx57hLc817ZfGK3rcLwr3Hb9tmw7tVsGQfdgf9V7CrihGS/rK9A8x+UBHaWdmYbonSIp1qLoUKCYZbLuRKSN9ox4hiKgxspZbNOZDW04jyA/SOlefHi+ropLgIRV6u6oQzqgbdm5ueQsZT/PZV6p3ZeKH/v6254OXmfJIy8UfUGY1KKruwaty0iDqAiGUYsercTPs8xl7bQ70TDVaX60zedJObaqAc6H52RQpcEFBcxk5+JwgCQXifA7aYdJuPFM81PIqO5PDA31zn0cQtE4jMbo42ClZc0PdlLwVfiwKk3V2SwKfN4r0FOQ6Da5fEr0SCHV/r+qQm3WVgF61hQYKtiHRInElEGBQuCB 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)(36860700016)(23010399003)(82310400026)(7416014)(376014)(921020)(22082099003)(18002099003)(56012099006)(10067099003)(6133799003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: gKWZY6M4lHKnyqSnPjZ9K+u3vFY0vBLpvNJgKy+uel3tz7408kpiq3InO0Rz73xO/LmTMmv98DBBg9s+yCDLuz8QFgSZPtkAVImPFmQDG91YKaDqZ6saNwH4+96vYXVJnSGFByXjELpAGNPWtV3Sr2LxbL6j32wfwbERp7zblXTPXN6mKxnqMlfROhWeu08mZE5ckSeqf3dPE/eV7rrOOeORyO1hS7s0ELchi/2oaZiyrPMdj4mx/xWq0F/gcN8+Rz4mmnqRltFqFdgr1IfBPcE/ZM630TiqTe9A5M8N/54ZN4pH/ytMnsRXCumYAIciwzUOUPBSRVENJpRW0m8dY5QerMwzBNxUTG5DmZU6A/vnpbD2ppj2ijvhdLNE6J+E9hFsd4X4SJtkGaWuDoVNpnUsQ9vYE/cfzB3HvSSUuGX4WJqqvBP2DXVfEsj5YZYQ X-Exchange-RoutingPolicyChecked: gz/JKrhKAniRPdeoUdG/upS65AVhrGSaky78SFIRKg247XBjS7xx9geexlLgwOwJ9kfPcBJ6VTxrxfQJJ3zMyOrh/y4VkXS+EdwBmPF0zJxltRbaWndTak1gAu4Q4qeWiF+hBjXTRAAfhsMbQk/Dt4jVPEWopXqPpfAnbqTkGvw+SDzvVXgbILPFldouzxn60f/KhhPv1sdzFMkmr6eoPPLHjMnTiAwf7ZWjV+yLzs43q1oRKmyoPADYRbUsgaIoybfnDMXZTmx9P43MgWZpALErebLQOBMCGPyix8CcVC35pFTNugpj6VpVXJvNzBVLj7eKL9/9I1oQx4la2Xu5mA== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Aug 2026 11:49:43.2127 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1360da1e-5070-41af-1a87-08deff7a4a6c 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: BY1PEPF0001AE1A.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB997650 X-Proofpoint-GUID: m4HhcOeUzFzYcVmXUQxuwi6asdVEjpHF X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODIxMDA5MCBTYWx0ZWRfX1cUMpOUURgZ6 lzY/Q5nj3lcV1Fhpg28EvC7Ls8i+HiywagXUGfeuckTMWJ8YPUft+nXOiJt+dz6V0ndSZ2v+Hpm iQdAInB/yY/rDTZfp+aQODn74YvyufT2vdgTrLhhwPzrjWeRkOlXKf9MFIR3FPqkGRbMzsLhozF 95JOHz3hAHsYrughjyfEgY1csNEQT9641DDWrgwA7c7cZL+xu1OlO+Si3xTgqZUHt3bPbw7XhcM HM0gGnK4O/uGlR4MB9uGgqEAqoAvwB6vOw5taseP9ZcWME/vjcNChK9ZnniVyKXwWkzBKfS7YIL ObKD74L+OrYnQDhO/wvWUJ+jfCyWuJKoP7Gk9M81fBASjPobJy3EhEt2HxqqgyKYJ4MLHzxL+A3 EuHnceMN1yy/+gJRLKeGZf8sN2fenZcUoL9eiqP+MaXYnhFjS0ducbSnz1FR6Cz+XK6fISCFnW5 c6hRsKFhPEa4BvLueew== X-Proofpoint-ORIG-GUID: m4HhcOeUzFzYcVmXUQxuwi6asdVEjpHF X-Authority-Analysis: v=2.4 cv=fuzsol4f c=1 sm=1 tr=0 ts=6a883b5a cx=c_pps a=y599upwrfiZ3HV94zaFOUg==:117 a=f+v6EHfkeJbVwR46tk4DMg==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=Sv0fKeRqtYgA:10 a=s63m1ICgrNkA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=fPAWb5peG099m5CrUpKH:22 a=sozttTNsAAAA:8 a=JqbSXTAX1eT4zVGs_pkA:9 X-Proofpoint-Spam-Info: AW1haW4tMjYwODIxMDA5MCBTYWx0ZWRfX1VOd0AqR0etl r/Lk4pzD2VpVYAVJdkKDx5kyfqBCwEBbejADaOG1lQDZ627Un0PtExTxiImtfUPoTEJSu0qd1Tp e23qBuLl5da86KHkMQomW1hwLgScCx0= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-21_03,2026-08-21_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 malwarescore=0 bulkscore=0 suspectscore=0 priorityscore=1501 adultscore=0 clxscore=1015 phishscore=0 impostorscore=0 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608210090 Content-Type: text/plain; charset="utf-8" Enable PHY for indirect writes of at least CQSPI_PHY_MIN_INDIRECT_WRITE_LEN bytes. PHY is activated only when tuning completed successfully and the write op was calibrated at the post-config frequency (phy_write_op.max_freq matches), which restricts PHY writes to NAND devices where a write op template was provided to execute_tuning. NOR flash writes are unaffected. The indirect write is cancelled before disabling PHY in the error path so that cqspi_wait_idle() inside cqspi_tune_phy() does not time out while the controller is still waiting for AHB data. Thread post_config_max_speed_hz from cqspi_mem_process() through cqspi_write() into cqspi_indirect_write_execute() for the frequency check. Signed-off-by: Santhosh Kumar K --- drivers/spi/spi-cadence-quadspi.c | 39 +++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-qu= adspi.c index 8903b4cf4f6f..940cfb72b946 100644 --- a/drivers/spi/spi-cadence-quadspi.c +++ b/drivers/spi/spi-cadence-quadspi.c @@ -157,6 +157,8 @@ struct cqspi_driver_platdata { #define CQSPI_DLL_TIMEOUT_US 300 /* Minimum transfer length to use DMA for direct reads */ #define CQSPI_PHY_MIN_DIRECT_READ_LEN 17 +/* Minimum indirect write length to amortize PHY enable/disable overhead */ +#define CQSPI_PHY_MIN_INDIRECT_WRITE_LEN SZ_1K =20 /* Runtime_pm autosuspend delay */ #define CQSPI_AUTOSUSPEND_TIMEOUT 2000 @@ -1362,18 +1364,32 @@ static int cqspi_write_setup(struct cqspi_flash_pda= ta *f_pdata, =20 static int cqspi_indirect_write_execute(struct cqspi_flash_pdata *f_pdata, loff_t to_addr, const u8 *txbuf, - const size_t n_tx) + const size_t n_tx, + u32 post_config_max_speed_hz) { struct cqspi_st *cqspi =3D f_pdata->cqspi; struct device *dev =3D &cqspi->pdev->dev; void __iomem *reg_base =3D cqspi->iobase; unsigned int remaining =3D n_tx; unsigned int write_bytes; + bool use_tuned_phy_write; int ret; =20 if (!refcount_read(&cqspi->refcount)) return -ENODEV; =20 + /* Use PHY only for large writes at the calibrated rate */ + use_tuned_phy_write =3D n_tx >=3D CQSPI_PHY_MIN_INDIRECT_WRITE_LEN && + f_pdata->use_tuned_phy && + f_pdata->phy_write_op.max_freq =3D=3D + post_config_max_speed_hz; + + if (use_tuned_phy_write) { + ret =3D cqspi_tune_phy(f_pdata, true); + if (ret) + return ret; + } + writel(to_addr, reg_base + CQSPI_REG_INDIRECTWRSTARTADDR); writel(remaining, reg_base + CQSPI_REG_INDIRECTWRBYTES); =20 @@ -1452,15 +1468,26 @@ static int cqspi_indirect_write_execute(struct cqsp= i_flash_pdata *f_pdata, =20 cqspi_wait_idle(cqspi); =20 + if (use_tuned_phy_write) + cqspi_tune_phy(f_pdata, false); + return 0; =20 failwr: /* Disable interrupt. */ writel(0, reg_base + CQSPI_REG_IRQMASK); =20 - /* Cancel the indirect write */ + /* + * Cancel the indirect write before disabling PHY so that + * cqspi_wait_idle() inside cqspi_tune_phy() does not time out + * while the controller is still waiting for AHB data. + */ writel(CQSPI_REG_INDIRECTWR_CANCEL_MASK, reg_base + CQSPI_REG_INDIRECTWR); + + if (use_tuned_phy_write) + cqspi_tune_phy(f_pdata, false); + return ret; } =20 @@ -1590,7 +1617,8 @@ static void cqspi_configure(struct cqspi_flash_pdata = *f_pdata, } =20 static ssize_t cqspi_write(struct cqspi_flash_pdata *f_pdata, - const struct spi_mem_op *op) + const struct spi_mem_op *op, + u32 post_config_max_speed_hz) { struct cqspi_st *cqspi =3D f_pdata->cqspi; loff_t to =3D op->addr.val; @@ -1617,7 +1645,8 @@ static ssize_t cqspi_write(struct cqspi_flash_pdata *= f_pdata, return cqspi_wait_idle(cqspi); } =20 - return cqspi_indirect_write_execute(f_pdata, to, buf, len); + return cqspi_indirect_write_execute(f_pdata, to, buf, len, + post_config_max_speed_hz); } =20 static bool cqspi_use_tuned_phy(struct cqspi_flash_pdata *f_pdata, @@ -1810,7 +1839,7 @@ static int cqspi_mem_process(struct spi_mem *mem, con= st struct spi_mem_op *op) if (!op->addr.nbytes || !op->data.buf.out) return cqspi_command_write(f_pdata, op); =20 - return cqspi_write(f_pdata, op); + return cqspi_write(f_pdata, op, mem->spi->post_config_max_speed_hz); } =20 static int cqspi_exec_mem_op(struct spi_mem *mem, const struct spi_mem_op = *op) --=20 2.34.1 From nobody Mon Sep 28 13:17:36 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 6B87547FAE0; Fri, 21 Aug 2026 11:50:11 +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=1787313014; cv=fail; b=d6pRtkZMefUPvhXTQ55nmpvHiz0iKYRqFsu9WD+s+MiHHevhnKewmFzD5QbWTBHCRgY1vbwKufYTGvzft7C+kcfegKBxNVmC5szfe8CFUAZ6RW6q+6wlQj5xDDhbDKlKad1DGhsMNU45fFrQkbr3qV+NxMa7L/w0VH6+n6MQhPs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787313014; c=relaxed/simple; bh=WKVXHJB0AdeEulQEB73WpP8Du4kcQpGopGcbjSG6Kf0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=G933y55uuv9dTWkkmA97o40T7jPdBulltdhFcK+WgfJpNF99J0MZRyJrDJZxnU7GvKV0WIXyUq4Yg7wPLjvoRY9i9d1gG3lXQwUbZGXLFY77HjdmNmRlsLvHZCJhJLJa4+jHEWy2rnuzTbEU9TG8p+uPfLiaBL0YBCZww/IdrAQ= 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=iqGlpFRD; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=rh1kH8cB; 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="iqGlpFRD"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="rh1kH8cB" 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 67L9KN2W3254934; Fri, 21 Aug 2026 06:49: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=+X4OnFKe7SEw4gZmEqh997XautkroE44X9Vjvdyek nY=; b=iqGlpFRDaPysHv4E72i9fuTITfa4VtOuwQN8drNwLOVPsuhgpf5OUdU19 1Zc0YFDQyxPXsLjqmKDTIPguoZRoWPl3IbsvI0g/Ea2EnHswQrO9e+kFTj6ojGiP xLhM98V71mBSg4n85ix5zkPRTksW6ms8mZWoY1qrk9vtLx2Xq4Gw380dEd3lmhJz 603exmG7dfViYChgDMbPOVjvJM1ZJUGEDa/RGIpY5zJmphGpWKEOM7CjC9ykaIO1 88dj4cngZxV5epEJesYwvFRSGPDEi3aAUTxTKk3JV0R6YndY2F6VdrkdU+8nhgxx r9QwxiAdcVQ4nbwAD2rFjMItvCq9g== Received: from ph8pr06cu001.outbound.protection.outlook.com (mail-westus3azon11012022.outbound.protection.outlook.com [40.107.209.22]) by m0380145.ppops.net (PPS) with ESMTPS id 4g6hfk1dfv-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 21 Aug 2026 06:49:51 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=S3zz3U6UmM8n1SQ9sb8zZ4tjTxTvLeeyFdvXyptKgc2v4dbd604BPxZHVucr9nvwd2Sk8IrAJjYQFgc22UllS6TKnNq9JNlWiWFkOfFjWq7F0U1chI3J6QliDfFhuDP/qiq8tGStahNB7Z0qfKhb1waD+1T/y47E5pnXOnOJqnPIaijDV2v9i4rEm+9G7eta7aCC+K+cvNqneYwryoyXBYtUHEgu1q1bdEnXq3soDQAsUXp284o9JaxUhf65LPuwbAf5QjOV3kK7mh8GYuiL+oCnrfg2Gki2xsbzRiSZrwTOuYqSYqZrefHiD41aGJERljem5Hw2Wi9qlfTsm5MagQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=+X4OnFKe7SEw4gZmEqh997XautkroE44X9VjvdyeknY=; b=PUxSFosNOXKN0/Dd6vA4oYs7fau5lCzGUvA3NlPzalxyLurcr3LUFcx+zXcoOrdhFFLp2lqRIirsBeghhOlOgrYgQcJ7O/3NjWXqji3PwGHKnC4DgjQYgizcmtNwqAmjt467VAr2tjgwyi/6cXZzPjewl1mhi54FLCqwuM8T8k9SjbceX1QnHGNTizysSaHlJ9Ox0pEqZ3BcC+o2miWsM5e+ylxkEqk7qhlmWsaksh/y9BRoLXhfc+YEqQ7TyFTT5PGiz0IsejYFRlTLVtRfZl1XB+uXyTxXtuBQhuWE0D6BN0mH5RD9ovcDPhL9MX2UJGha8QZjgguhq8J1rYTXlw== 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=+X4OnFKe7SEw4gZmEqh997XautkroE44X9VjvdyeknY=; b=rh1kH8cBml5zIQo4EG+m5iuBQYi43irI8HM5GBasq5SmgCNezWsxY16JgbL7d/xbIee2jAgmpHKSopScGerznosb/elHrEeLH2svdole7bahSlfaLGJgsD86IprDVV0EjNKVg0TkPxkk+B9VAIZypKHlebl3vva/MftNadtyjWU= Received: from SJ0PR03CA0143.namprd03.prod.outlook.com (2603:10b6:a03:33c::28) by CC6PR10MB411082.namprd10.prod.outlook.com (2603:10b6:170:200::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.339.11; Fri, 21 Aug 2026 11:49:49 +0000 Received: from BY1PEPF0001AE1A.namprd04.prod.outlook.com (2603:10b6:a03:33c:cafe::15) by SJ0PR03CA0143.outlook.office365.com (2603:10b6:a03:33c::28) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.315.17 via Frontend Transport; Fri, 21 Aug 2026 11:49:48 +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 BY1PEPF0001AE1A.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.360.3 via Frontend Transport; Fri, 21 Aug 2026 11:49:48 +0000 Received: from DLEE202.ent.ti.com (157.170.170.77) by lewvzet201.ext.ti.com (10.4.14.104) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Fri, 21 Aug 2026 06:49:48 -0500 Received: from DLEE202.ent.ti.com (157.170.170.77) by DLEE202.ent.ti.com (157.170.170.77) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Fri, 21 Aug 2026 06:49:48 -0500 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) by DLEE202.ent.ti.com (157.170.170.77) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45 via Frontend Transport; Fri, 21 Aug 2026 06:49:48 -0500 Received: from santhoshkumark.dhcp.ti.com (santhoshkumark.dhcp.ti.com [10.24.52.55]) by lelvem-mr06.itg.ti.com (8.18.1/8.18.1) with ESMTP id 67LBmVlo2022942; Fri, 21 Aug 2026 06:49:43 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , , Subject: [PATCH v8 13/18] spi: cadence-quadspi: reprogram CS timing on every chip-select switch Date: Fri, 21 Aug 2026 17:18:17 +0530 Message-ID: <20260821114822.4040338-14-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260821114822.4040338-1-s-k6@ti.com> References: <20260821114822.4040338-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-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY1PEPF0001AE1A:EE_|CC6PR10MB411082:EE_ X-MS-Office365-Filtering-Correlation-Id: 13d571da-9e95-41f4-5ec3-08deff7a4dc2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700016|23010399003|82310400026|7416014|376014|921020|22082099003|18002099003|3023799007|56012099006|10067099003|6133799003; X-Microsoft-Antispam-Message-Info: ePbkB/3l05np7cf5b2baKOUUUsRN9JSBIyVo0U6vDRV2NBs1hI09F94pRbH93koAsxJrR9x1aKZZpvDtCXuPGa2eub6N/02Iek871CnWimFeh9Efcd094DUGGHqhLBj27h8AhK5xplEc1d2S3cYOzBEK5HCqc77MDUNkVdBTEM1aIT01DC7zRSp71AhzLhi4e+0hpblUYe2KceqVqcQohff4HqjzSD4ubloqK42a9PRgu43Lh48FB9M5PUMhYDJDJ9aHZ0Yf1zmGfXEM9sv5kWu8IuOmxhrtc4VtVy6AP3J4bUy0/s+7MB2XpoZyqPZ08Im08qTCibl2M/ffmOMW5k/mb3Y21Fx/hp3yLytd6Rg4NG5J94GvBESwb1ph8A4v7i/g18XWV253fHTgcsT9g1Wp7Zi1eWbgL7F2yMnSzt/StZTB4DylMXVGZy2wa0doWfNjhF5gH/+/BdBMJaKXjHWLgOSlLSrgAJhuNPGMRvEyLChViG6O32VtlpP2cPgWvu6VjazTy7BodbLTlwWhOeG43AU6I25Jw8RNmBTUQgn8KaWaZvSrtNo+hRskIXCfWHXYPewMh+P7VGa73leTBlA0VDjXn/vnvlrnhMqO/qvHXU/2rXwVXEA/HZqoQxVkdweGlk5kAgoUYAHu+0shqWMYialkhCb7+pPvFFjyXwDgJ17FHwAaEVit8O/5aAiyoPJCaZ+uzS56U2B244VaSp3hItrBrDbnhz+y9J2+WC2wKwX+7z7xV8qAKKyCA1Xe 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)(36860700016)(23010399003)(82310400026)(7416014)(376014)(921020)(22082099003)(18002099003)(3023799007)(56012099006)(10067099003)(6133799003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: oq8NW/RRNd85996MR7T9y7HtXOPccyl21g6vOcm6T+/o7VXTVd6CnoxUp/S0x4MnUqrFLZIRlHYKS7J0I0QW0OQ40PyfxL0MOuPzGxQq7xM8KpvCyeN7mSeWUZrvX62D6LqFtlPGPJs/O0i+SchcxxedadxNyfcoCnjfLNqzTiLE3JAMKxbgUj6rJlGRgneR8R1fa4BYL4K3Hu95WsIaYq+ezH6mYa0OnL0WlMysvQsI/VHsOKSc7SuiIe5hF37ExW7ZQ2Tlb51+l9LM4/2uv6Ba9g5gT8TNl5jaGkJkOf5vNZk6xjPLR8IkA2AFvbAfFeJfh//aBsXlCeMFQWf9gXcNHTvwLiYiQwXzLkw3GDFN2RXZ3+rNzCiRBW2UHs6P9JMCxGb/O0dh/Iw7H2hTbqOAS6uPHtJPXUc59SjdOhikKlD9GnPMgYzQKYREBC5U X-Exchange-RoutingPolicyChecked: tNd/I5HavheVm+hqkh0ey90DNv06lEk+m3K36+j0SJSZiuIM6iF1cJBnWGFC2mDeD90Tdevf/TaLJeNmISMU//+RuFbw01j9YEgbN3afrZTcq2gHzud5RQqvfhcP+qh+c9wHEQZ48iiohpGkD7hWe8RioGJR7Y9zyZJSu+A6lgXHVjywmxiNd4R02sKlF7mRzyk6SnbeHEvb7S59kJ2Orm6kFbhBlYyYCkNQ3tIJQSdR8siO75qM+gdKsx0P8bynkX4kACH+sl1rGhSpKdV6DHrdqBMNamBAFb/Um+XbXAtHd81d1+CiSlPQJt/N19/ZgTqNGiaeLykxDQiGmEAI0w== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Aug 2026 11:49:48.7610 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 13d571da-9e95-41f4-5ec3-08deff7a4dc2 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: BY1PEPF0001AE1A.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CC6PR10MB411082 X-Authority-Analysis: v=2.4 cv=O7AJeh9W c=1 sm=1 tr=0 ts=6a883b60 cx=c_pps a=LdSsacNKwWtvIYfRw5AjOg==:117 a=f+v6EHfkeJbVwR46tk4DMg==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=Sv0fKeRqtYgA:10 a=s63m1ICgrNkA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=gO1vWkAQAl3rybz1DQOp:22 a=sozttTNsAAAA:8 a=okWzP3EbMLmikBYkquQA:9 X-Proofpoint-ORIG-GUID: KHn_u0ca5Kz4pUuu9ab7nqHFEaTd3_8D X-Proofpoint-GUID: KHn_u0ca5Kz4pUuu9ab7nqHFEaTd3_8D X-Proofpoint-Spam-Info: AW1haW4tMjYwODIxMDA5MCBTYWx0ZWRfXxny1Ar7kc3+g QoZdrSRaxW6NXjUbLPKqu+hGawC42a8hldU4hQZkcuYj35BI76JGKYJe/siTwAsY5YxhJEEbywt m5VELE85TX5o6Pl4v6AzC3nEDt66CTA= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODIxMDA5MCBTYWx0ZWRfX3xAOVks8RWeN jU4Q4TLlruIXGueQMqZ3caK7OJByr1DiR4Dt9mhgdxRZCUx8wJE8pLAP6DGSAc/dZrVmJFTsVBa aOAxZnXxu8wBiC6QlMhI6F0n+K4jnJjB8DZiu/CkS638L4mKh7b8Ic7zUaYo8KmmQqHvrF7k/Zk bS7GKohtST0RXLWTIAsNZXYDQiBpqhl7MjXtzhc7S8tTvkAKJcoacQOzxMe2NpEvmdDggBXqc5F k4/BoGrMH0Z8AOGn+wBZqM3fAcbE/sOFOrhonYElvKCS+gPFJe8vGtZNI2PUwh1Yn9aa/RGBMRx +NZ67sJs/H0+AeiTpKdk5Dme8M3/uIxcZSfUVi1S10N4RNLdSCA5NFakq9l5sWVlQxhEfs2Ossr 8909qzJU3dQMYXbJgFa01ZBOwOSWKowX9XW1g8QIQQCawaISnwwMgWn2SH40Uy02QPN5MdU291S WogGWeUunXb0VISqz9g== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-21_03,2026-08-21_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 bulkscore=0 phishscore=0 adultscore=0 suspectscore=0 lowpriorityscore=0 malwarescore=0 clxscore=1015 impostorscore=0 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608210090 Content-Type: text/plain; charset="utf-8" cqspi_configure() only reprogrammed per-device CS timing (CQSPI_REG_DELAY) and the non-PHY read-capture register when the clock frequency changed, not when the chip-select changed. In a multi-device setup where both devices operate at the same frequency, a CS switch leaves the previous device's timing parameters in hardware. Split the update condition: baud rate divisor is updated on clock change only (it is frequency-derived), but the per-device delay and read-capture registers are now updated on any CS or clock switch. Signed-off-by: Santhosh Kumar K --- drivers/spi/spi-cadence-quadspi.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-qu= adspi.c index 940cfb72b946..d4181b501d8d 100644 --- a/drivers/spi/spi-cadence-quadspi.c +++ b/drivers/spi/spi-cadence-quadspi.c @@ -1602,10 +1602,19 @@ static void cqspi_configure(struct cqspi_flash_pdat= a *f_pdata, cqspi_chipselect(f_pdata); } =20 - /* Setup baudrate divisor and delays */ + /* Update baudrate only on clock change. */ if (switch_ck) { cqspi->sclk =3D sclk; cqspi_config_baudrate_div(cqspi); + } + + /* + * Reprogram per-device CS timing and non-PHY read capture on any + * chip-select or clock switch. Without this, two devices at the same + * frequency would each see the other's timing parameters after a CS + * switch, since the lazy clock-only check would never trigger. + */ + if (switch_cs || switch_ck) { cqspi_delay(f_pdata); if (!cqspi->phy_tuning_active) cqspi_readdata_capture(cqspi, !cqspi->rclk_en, false, --=20 2.34.1 From nobody Mon Sep 28 13:17:36 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 18A0048D862; Fri, 21 Aug 2026 11:50: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=1787313017; cv=fail; b=IPNG+5mT85ahiB2SUFC3uD5JzGWJSNt97PvIfKIk0Kp+IEPSU5rDV5yYYPEcbjGZpT0ylfsDC6XzAjEc70wLlXSKm6DUw+VY9xvPzFZKB1L0jIK5Gb9Wlx4GkmXW/QcOHX7pm1I58QeDYXnZCgXdaWVBfx3VR/jxklWo7Lw8O7w= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787313017; c=relaxed/simple; bh=/36EtgSHJjgS4ho34Va/fE/UiN7oZO1CuCAHGVoo6vY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ZXyA8ZGW4gQ7tO2vEud9futY/IT75Cuhw0Tcv/XTGxFIa2rFGFQmPHflPBC64+PmNrPfVN0ywFsJ3pYp3DWeV1egYaRnigFm2wev2foJFWMG+glQ22hWN1LQTiMzpKycPbTjeOoTGJ8S4fH2UQHyN7PDTt/trD93sFyJkk7QH+c= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b=SO7SWRU2; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=YMwCyciB; 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="SO7SWRU2"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="YMwCyciB" 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 67L9KRpb2887012; Fri, 21 Aug 2026 06:50:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint-05-2026; bh=Y5jcawn8CrAjnwc0j/CFtto7zEM1fdC/gjWbyM1Nf eI=; b=SO7SWRU2teduYX9F7R0GXIDa9afi0SuXJlEk64tdjvB7ShDws5zojQf1j RZunRR5qPUN8Krke005CNvh2dsx9pFBRxIuIcrmcblr0q3zhGv3UUzY2xXadzt+m jlJH94flGOL4T7okoB+onv6hUAdZc53ZdlBSDwldqvlo5YU0MPP4t3Pv8xLHMjfV PsiKP+LtB20dL9zgwRCA2EqK2FIlsm9g9Lr7buTdjnN+dhB6K1uCKfqjx/Wha9vU IbRv6ObBNNLJbE0L4gJa4M/k4EsPR5A9QJI8Ni1Pi/rwgStTWyhLtSLzHp5FdKFD 8aiXh3LwsVHL6TOLkBglb1tH2U4rA== Received: from sn4pr0501cu005.outbound.protection.outlook.com (mail-southcentralusazon11011028.outbound.protection.outlook.com [40.93.194.28]) by m0384305.ppops.net (PPS) with ESMTPS id 4g6gke1mkr-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 21 Aug 2026 06:49:59 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=yDfEghNnzYt1Q2YLo50VdjDCrZh0JqCg95SNFEEFnF0D1xJ/TBy0xjcufNJfu04cgJa6I/bKn1xjyjVyd/7gUpR5rZxTkH1HxpyJBxCzijG+xqzsUKvpiCl3jwS3642PfsYZPUW+dsimCdWP4lon6p0C1TcrQ912tSSlOwaFrcj5rQxW0RAlk0dL3F2j3C9TuyJRSCDawqEFe4rHhanrevUAzF5PcHrdOpvxguU4daLoANzH+aK5Ku5Ue280/u0m2pI7BjfIxVEkvbFpBcn+DZQHAONjaKYQg+P160YXPMPpkC0DEixixVcIjHV4kwsoE5Gbt7m/2rHxufHz9KMyyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Y5jcawn8CrAjnwc0j/CFtto7zEM1fdC/gjWbyM1NfeI=; b=ZfWZbzZL2FucteVHb75049ZFLgSRL7Ndab3x3iZJnspRCIA/s00oOp8v2IfKnc/L17gjDQEW5WKIDUIvXvDc54nZYu2jyEBuLS3ux0pNBMPZfzuv8p7ZWrtIfWVyrJ1u+mW4ktZq1rOfz/QDiWRZ9ebpKIA2J9Yt3t1d1Lk5XYJQPEl097rtE4E5dNfyqgk7zIm7QAdgdIeAXIQQhvafWxiQ0FvVQTVVoyDxBOoy0UnpZq4X9UyCZljvgWUI62hFFNGR2J5lJrVbtEIb2GF2XsIGlKHzZF9SR9ZBVfCo+m/iNrj2+bltd0LEzLwLykCrZ6+zMzuK+1lY1cL8OLLmBg== 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=Y5jcawn8CrAjnwc0j/CFtto7zEM1fdC/gjWbyM1NfeI=; b=YMwCyciB9pG2hum2gxupUF2gtUlPfXBl2ngnFVsLHixCu2FwZEelC2vODeWQgXybdlq8xrehYWVKtVGsqaBtygYzoNKcutU/5zCAz8QAJNv9WqjIcti95Tb0joUCn4/C0/FA53vz7kx3VCuIfDDnWYQ66Q7wPvOofOWUuPN9nF8= Received: from CH5P222CA0023.NAMP222.PROD.OUTLOOK.COM (2603:10b6:610:1ee::11) by PH7PR10MB7010.namprd10.prod.outlook.com (2603:10b6:510:274::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.339.8; Fri, 21 Aug 2026 11:49:54 +0000 Received: from CH1PEPF0000AD82.namprd04.prod.outlook.com (2603:10b6:610:1ee:cafe::73) by CH5P222CA0023.outlook.office365.com (2603:10b6:610:1ee::11) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.339.11 via Frontend Transport; Fri, 21 Aug 2026 11:49:54 +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 CH1PEPF0000AD82.mail.protection.outlook.com (10.167.244.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.360.3 via Frontend Transport; Fri, 21 Aug 2026 11:49:53 +0000 Received: from DLEE203.ent.ti.com (157.170.170.78) by lewvzet200.ext.ti.com (10.4.14.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Fri, 21 Aug 2026 06:49:53 -0500 Received: from DLEE205.ent.ti.com (157.170.170.85) by DLEE203.ent.ti.com (157.170.170.78) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Fri, 21 Aug 2026 06:49:53 -0500 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) by DLEE205.ent.ti.com (157.170.170.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45 via Frontend Transport; Fri, 21 Aug 2026 06:49:53 -0500 Received: from santhoshkumark.dhcp.ti.com (santhoshkumark.dhcp.ti.com [10.24.52.55]) by lelvem-mr06.itg.ti.com (8.18.1/8.18.1) with ESMTP id 67LBmVlp2022942; Fri, 21 Aug 2026 06:49:48 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , , Subject: [PATCH v8 14/18] spi: cadence-quadspi: reprogram PHY DLL on runtime resume Date: Fri, 21 Aug 2026 17:18:18 +0530 Message-ID: <20260821114822.4040338-15-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260821114822.4040338-1-s-k6@ti.com> References: <20260821114822.4040338-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-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000AD82:EE_|PH7PR10MB7010:EE_ X-MS-Office365-Filtering-Correlation-Id: 56a6ca32-02f2-4662-5c2d-08deff7a50da X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700016|7416014|376014|82310400026|23010399003|10067099003|56012099006|6133799003|22082099003|18002099003|921020; X-Microsoft-Antispam-Message-Info: vnXsZ/b1RCf75L+qhud72bubYiupJceGoAzgsdrYzZGx4oTqlgldXAjW+c7yaE7YsuEoPaQnFAJmFUENlS4mhHtTq2br/m8bgxQCAK5Y+uxBI5DkOlVlfsx8IZAAnN+H21ORRgMU1C7liYe9Fx8mWRnywGwD+lKQAWpehPKSNp+yr0Aj9zE78LptQK5dnFK7a9TFTaSMy2tVFnrDex5rh1fVGanRvRpbIDHS+tpxjiXW4L7Mqs81Md8N+qzl27X0bqgSslIjNR/8i/V979+Lt4/kkNIwJ2b8uPkYTDBS050LdwPW4WBbo74F6J3gZRi07JpM5Fj+p2tiHIWCZ2zPbYTInVRBuTHOs0IJuEx3DfYMKw/29Z88bnL9eKWQPTw6q+NRb/PCZgcxGlX18mtu0l6WRF33tp72ImPD/OYkjRc+qORXOrCVQid31oYykym4nnU/AflhXQAqR7NUuYJNBZJGEcl6n5izj/GBqSKMicQX/EicgkK50u7WqTQqWBwf5S+d8el+ma1PZKVVk0waPy0swxP0NNasy66bfsrfZi9opyZja++kVJx01/IICaZkVV00lW5Ts+CfCOnhd8yOCu0DY7jhkatjciq8ykpGM0LcK9LVkIpgLHtM09ZpKCHwcjF3ImAtNvvI2SWQN8hHMwlQMQC0wZGG2tRxQyeSGrG6L40TAtlu65f8mzxR9Rmrtj39tt/RBU+izhzviyPTSxF+MeVYSSGU45ruH5HS/7K5BDwmkB/8oeAdjTP++zM7 X-Forefront-Antispam-Report: CIP:198.47.23.194;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:lewvzet200.ext.ti.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(36860700016)(7416014)(376014)(82310400026)(23010399003)(10067099003)(56012099006)(6133799003)(22082099003)(18002099003)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: mJgGf0OuYckrwLWkAkcvreHEOYdhP0Qu4SNhO6KN0sBAtjMSzvzhnnBx4f9gLsj6CRMPdD7gtckhZS7Q84ZpuqiuOVQhTMmn6RowP1RSQbhBfmoUVR2wln2veAsofnbGnrYyFiR/s00wTdyvWwyOGvLQcZhxUo4cyOqp8b9ZOXhs3O1wMxEcjxMDniiPO7wVSZPvLBS7wax3UJ0xSYnrPPdpeoRIskNUaMcctCYgXCqBFQaf9tbTNt/zdj5hbDpJGKhympO0F72kO5otvDTyReoI5A3C/MmEYJdEZqPgvzznG+gJ+bH2WKM/ulI4x6T6QgWgcMkqpcKLj4UP+/szcT8nNIuw6NMUcNCnPudL2nS+o6EZyLzooWmc1zbQ6bET3a1PHDxbei/DIqbfxUlfAdyYHXb/mxGGaeDdC2qyKoj0bUUpnYVcZAKFYDf0ZRVF X-Exchange-RoutingPolicyChecked: bRk5odW/G6wzYKs1BhojFrEcRQBlQ9V5qKT1QuNTz3q/ctzP69J7Yf5GPp+Sm7mfA6T468dXaS42kyq3oRgJsIUjUROhjH1yp+pIDt1bKz0p07ckFGCREpsjavHl2KNbKStNhCD0m7v5U6y/kZEFBWmyXnzIKm7W1io8hrXYuJth41dBaSkbzkdeFJXQ5joSdg3v2iBbAT4NWZ8jr2P0GHwDAdZ3h12WuePAi3GumrsgGc8ab1JVukWRLbYIJfspkbRw3dJIae7JRcsI9UQy51HFqO0RxuSJMU2CJCO2hvrt6ev0dOfyZaPRWKXrHRj8Cb/ETSK3KVtOYb5jPwlD7g== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Aug 2026 11:49:53.9784 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 56a6ca32-02f2-4662-5c2d-08deff7a50da 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: CH1PEPF0000AD82.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR10MB7010 X-Proofpoint-Spam-Info: AW1haW4tMjYwODIxMDA5MCBTYWx0ZWRfXw0IH/yQzeWMF uuI3eBXs0PV2Wpv1hi4O92fUmcPmdNIhkZEviEjpmLjcvPUhX92MJ2WPgMAP/u10BCbecUZLUJI jwHuF3BFkfiCMwgELSSsx8h5PCLgfb4= X-Proofpoint-GUID: fdljtLPmi9KQymp1frUYaohEGbC2GEX6 X-Authority-Analysis: v=2.4 cv=Fp41OWrq c=1 sm=1 tr=0 ts=6a883b68 cx=c_pps a=auv0RDqIM0MEGdyBMEg3Kw==:117 a=WotqVVQAdb04rnGuttW3Kw==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=Sv0fKeRqtYgA:10 a=s63m1ICgrNkA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=taLDd7a_hP9WKsMzeGRc:22 a=sozttTNsAAAA:8 a=UNEB7AwOHobNk7BaE54A:9 X-Proofpoint-ORIG-GUID: fdljtLPmi9KQymp1frUYaohEGbC2GEX6 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODIxMDA5MCBTYWx0ZWRfX4vzvKPv3BXkD P/Es4LiSPURz0iKC5FOtHuYUW0SU3V/3+Vj/cYQuJvn/bfiUC5+9+UbTKqhwvZ5O5u2KEBQxMRH kbOBZ67yzyKss9DV/ZTRGtGAQZkmHcWkdBqcWxbmD4MH6palT+kvFAq45wZVs3g8jljcAbjuSFr kEhp/S6uEqm8wqJc64yyH3KSoFK/u4O1GIV/MOCGGoWRXJayT0Twu/hVXJdC4BRjEeSd5c8A/xc c4XJTris1wnbGTzRl2RiV/Pf1vbgkFugzr5inpcwr5KllHvBNI5IXZN88ycueeUjcJcuT5CAWrf x/XApE5mCt/Fluh2K5/XPvqKRv9qSBRNerPVYgblZacjoXX0UcKkEoiBk0Jxec8OfNXyrFaYk1m fhKSYJRI9A3UgnRrAf3sTtWCgB7lhmnf8n40LlE6NrZjPpnWFsJlspKV+8GvhkTpuCdckLQfWIU Kmhx93IMLHSSGo8QC/g== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-21_03,2026-08-21_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 bulkscore=0 spamscore=0 malwarescore=0 lowpriorityscore=0 phishscore=0 impostorscore=0 clxscore=1015 priorityscore=1501 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608210090 Content-Type: text/plain; charset="utf-8" The PHY DLL loses its programmed delay values and lock when the OSPI controller is power-gated during runtime suspend. On resume, cqspi_controller_init() reinitialises the controller but does not touch the PHY DLL registers, leaving the DLL in an unlocked state. Any subsequent PHY read or write would then fail at the cqspi_resync_dll() call inside cqspi_tune_phy(). After the controller re-initialisation, iterate over all chip selects and reprogram the DLL with each CS's stored calibrated RX/TX tap counts, then resync to relock it. One invocation per calibrated CS allows each calibration to be independently validated after resume. DLL resync failure is non-fatal: a warning is emitted and resume continues, so the system degrades to non-PHY speed rather than blocking the resume path. Signed-off-by: Santhosh Kumar K --- drivers/spi/spi-cadence-quadspi.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-qu= adspi.c index d4181b501d8d..c78d4ce1c930 100644 --- a/drivers/spi/spi-cadence-quadspi.c +++ b/drivers/spi/spi-cadence-quadspi.c @@ -4017,7 +4017,7 @@ static int cqspi_runtime_suspend(struct device *dev) static int cqspi_runtime_resume(struct device *dev) { struct cqspi_st *cqspi =3D dev_get_drvdata(dev); - int ret; + int cs, ret; =20 ret =3D clk_bulk_prepare_enable(CLK_QSPI_NUM, cqspi->clks); if (ret) @@ -4030,6 +4030,23 @@ static int cqspi_runtime_resume(struct device *dev) =20 cqspi->current_cs =3D -1; cqspi->sclk =3D 0; + + for (cs =3D 0; cs < CQSPI_MAX_CHIPSELECT; cs++) { + struct cqspi_flash_pdata *f_pdata =3D &cqspi->f_pdata[cs]; + + if (!f_pdata->use_tuned_phy) + continue; + + cqspi_phy_set_dll_master(cqspi); + + cqspi_set_dll(cqspi->iobase, f_pdata->phy_setting.rx, + f_pdata->phy_setting.tx); + ret =3D cqspi_resync_dll(cqspi); + if (ret) + dev_warn(dev, "cs%d: PHY DLL resync failed on resume: %d\n", + cs, ret); + } + return 0; } =20 --=20 2.34.1 From nobody Mon Sep 28 13:17:36 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 2266448F831; Fri, 21 Aug 2026 11:50:20 +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=1787313022; cv=fail; b=B5zQUrS8F9horQVkJm1qb59z3dcibDHTanOHGd/yOTTk0cyLrvZoIgb0ginnx3zw/lXZn0IPWeaq5yqfKMR62du7tdsf7McNbhY9DhZ75FGFZtmgisIO/T3119RdumllsDHcAtRjqEOgZMhzg74fLRt/9h/n2xnhVNryXVbK6tE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787313022; c=relaxed/simple; bh=Z6kI0hhZdkpmUOsoj8CKbrqn8KbIVxP7eRMt0m77Rac=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=qZ13wJkqolagZZOnfRkqYL5x+7ct/zw+U/JSPp+uIH0roeJDtW7wBg9AhG6ORuPKKupXPyMuCiXhw3sz3ZChO54zyq5ecypUbnHfhe7VemRG6omusYMoZhxJMbLOFe0cDOgqgTpyZ2tJIBGshmaaUn7/GogZiGDV4/uxvRG5hu4= 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=AMh6JsqI; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=Rn/SXSYn; 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="AMh6JsqI"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="Rn/SXSYn" 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 67L9KP923254958; Fri, 21 Aug 2026 06:50: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=Otz2lO7GjrwnPQrwz7VTA4tB78J3Rlz8nvNj1qbpc F4=; b=AMh6JsqIGBOfn/9dhM9hQWbwffK/AQgfIdKt0ZCFIc+H8OK1h/ajw90En Vp77QtNz3xJTQldjFeGWOsuv+uxAvWcOfA1CvqeDC5dh/CYsosX/86V+vwROw1C7 akQNUd6D87WHSSezspVEwR+Z63CVkJfXIqIxSc3nisSfGs8iG9vKvxob+lCSr5GK VHyuE8MbW6+u4S9NwVpHwLKeWmJW5nndow/TeVMMC8UVgguBZGdY8mJcclo7FVTz Kk4uF7Tzo3kETYbj4lCNXU2Bb0NTw9dripyrBVw8DUwu39CLgjHCz5evuijzqOc2 TGt1FmumvjBDFykRLmDAWLw/JTPPA== Received: from cy3pr05cu001.outbound.protection.outlook.com (mail-westcentralusazon11013044.outbound.protection.outlook.com [40.93.201.44]) by m0380145.ppops.net (PPS) with ESMTPS id 4g6hfk1dgp-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 21 Aug 2026 06:50:10 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=CN6B9TtcHK91br0+qrqJCp3c2CDdbTBBjM6Oc2WugwwNR/YhXlWDbNzVHZlsB4js0SFrw76d32JPwLkQiNnMSVA0U9mjURddQzX7J5w83rMxGBnGDrLoenIgapnLfqIcv8FfJu/wk8Iad1fzmKA668HUx9POuoMl4kHOz0Rf9uXzTS+W0AkDWuzROdqkkREVXsEUrhcUJm23WJDPBXFH8dQm/1YnuE43IbvIqlOto1GPQSkT19nf1O4phApYFHsfbIWV/Eg6WvguThmHM5Sq+7g2w9AhN6nlare1QO5m5m+qQpCX4mOjCAm6kfKCMVLF5ejRJ27qaEqHv8r0Ro9+xQ== 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=Otz2lO7GjrwnPQrwz7VTA4tB78J3Rlz8nvNj1qbpcF4=; b=yvSgbCDVBh6ADNOb18EV9ntlFzlEdq5AtWjFFVi82+w8BV9hp0vT1rUQhEvKVKN4PSxRBMz/6AGyL3K1BIBLK7KdxlyYI8K/ok4ArY3lcHi7S2lJlJ0XDFIeHKwJyv5d7djuYn6bA4mkzyNObaw9EqWZBp+nHoVVfw+SpZWo8ar/+DA6qxV4+HHpGDZVfV8HX/hXuVzK1EbL+xFcEaB6rwarjepz1TEzOuxsi4is4cahg1Fm0aywbxTnw2eLuMv5Uy8Yy9mKluBXZZ05jqcfvCy8dSc/7iq6xft1H2Fh3OaJAZr6e3NPySZN1PXcfpsU2mJx45vFIg3+0f8GDKtdrQ== 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=Otz2lO7GjrwnPQrwz7VTA4tB78J3Rlz8nvNj1qbpcF4=; b=Rn/SXSYn5xCx9C0uR/IqLKaVUdZjXqjgrp2z5USdYxnazZG3CJGP9cEFIwycxfjhJDKYnE1z1dFrtFa9vusBSyuZFAre+RDlwPjNqnexrKRuVPaNuAKzOMKW36/DEq4e5gdxMij5ESycfssOuNSAayRWfHeZdQQw9zgJD657tnc= Received: from BN9PR03CA0296.namprd03.prod.outlook.com (2603:10b6:408:f5::31) by PH8PR10MB6598.namprd10.prod.outlook.com (2603:10b6:510:225::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.339.10; Fri, 21 Aug 2026 11:50:06 +0000 Received: from LV8PEPF0000005B.namprd02.prod.outlook.com (2603:10b6:408:f5:cafe::a8) by BN9PR03CA0296.outlook.office365.com (2603:10b6:408:f5::31) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.339.10 via Frontend Transport; Fri, 21 Aug 2026 11:50:06 +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 LV8PEPF0000005B.mail.protection.outlook.com (10.167.245.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.360.3 via Frontend Transport; Fri, 21 Aug 2026 11:50:05 +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.45; Fri, 21 Aug 2026 06:49:59 -0500 Received: from DFLE207.ent.ti.com (10.64.6.65) 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.45; Fri, 21 Aug 2026 06:49:58 -0500 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) 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.45 via Frontend Transport; Fri, 21 Aug 2026 06:49:58 -0500 Received: from santhoshkumark.dhcp.ti.com (santhoshkumark.dhcp.ti.com [10.24.52.55]) by lelvem-mr06.itg.ti.com (8.18.1/8.18.1) with ESMTP id 67LBmVlq2022942; Fri, 21 Aug 2026 06:49:53 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , , Subject: [PATCH v8 15/18] mtd: spinand: extract variant ranking logic into spinand_op_find_best_variant() Date: Fri, 21 Aug 2026 17:18:19 +0530 Message-ID: <20260821114822.4040338-16-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260821114822.4040338-1-s-k6@ti.com> References: <20260821114822.4040338-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-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV8PEPF0000005B:EE_|PH8PR10MB6598:EE_ X-MS-Office365-Filtering-Correlation-Id: 8f98e7b7-a6d3-4c9a-0923-08deff7a5795 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|23010399003|36860700016|1800799024|82310400026|921020|10067099003|56012099006|18002099003|22082099003|3023799007; X-Microsoft-Antispam-Message-Info: KADRxmwHqChhTlv+fHyU60PD4o1TGZly9MnoPzotqz2lpI9PeIuc9ivkpBqn6ovOocf14l55eU3LujNvJUez+KF0ode4THGstF1k8HnxM6JHwHxtYWyoqjvx95W0PAx4DMCE40qSvFMEf3OLvawK7JLUnNFGN1yu9HkT1O7XJCBF0iCfkUC0lFXRh6Cp9bYHpRhQjGE2bzULZE3KFNL9Mo2NR0spBhft9wCrALR8ggsHpXURc5u5wuYodnyvyHGFUo1Uu7RvUSyPzBvsPMBoCGjTTMqaVv7LvQCDcb6JRcJULfJU8mkbNtxPKP6364e3eMwWYTZlltna6qNtdGXcRBVV0q2Fgi2P6e3roD5Oe1i/6vewCR0xrA133MSjOvlyaA19mEzmTb1SN9/zVOnqp5+qPQuNbA8PdUGADHSF19GsLhjlKFk6OM7FiwY9DcX9UB4A4duemzyrZvbKMCE74uXGba0IBC6WAeWnprDJyVDajXpNsF35oiom7Qa0w9VA+y5alNDVGAEBXUK59gjKABa5NpHgbRFdertCG1fPF10w+VVBYNrW9VwbENXHQvVE89nyYU1SADTkRxTttKoxOm6jMeKeXgVtOI8cEAPXDoW1s7OdP0kNXajGyA6luIGdZi27E/PgoQ+X9Bd4BYo+tM+WaVrtsEiI0XaYmbmqpcMe3HEueCojxYRTxGw/y9wT8+JyM3+sRnChL+LPDyY+5QpXPpRcPva2OienEk/UDMxQ9JsHEroH2GX2aPbyXaNi X-Forefront-Antispam-Report: CIP:198.47.21.194;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:flwvzet200.ext.ti.com;PTR:ErrorRetry;CAT:NONE;SFS:(13230040)(7416014)(376014)(23010399003)(36860700016)(1800799024)(82310400026)(921020)(10067099003)(56012099006)(18002099003)(22082099003)(3023799007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: RfdZ1QgpSrq3aS3ulHsoQFXBsqcpPRcGgfRsSiSnRCb9z7McdGs72tBtY5EeZPERx4L6taEI+HZUXj4cuOkMxLMDIdFOYOM8s6uT+e9/LDMv7DoS5mFz8tvzXYD9wwYshh3+hQMrTowfY1VNBR908dOTMaJOxsiiC+bJ+vE2W+KoEtWz2sxhMCkazF9i0IEiCX2hsd+t+NO6uHyluAJOPZeTOcgGZuMm43wffo+/FzG7URZESo8cu7xIYWlfk43DBXj69Tf4oCJGOwOKJ922gLdJrt+eTn3gddeyWps/qTN+I40nYv8FV+SmU27iuOB7GV/uCrdU9IVPxpjHGl+Gj6GeGvA3JnInxXqfoGm/i5PShZ5pv5y0LZjRjvuNvsSSQJiPNDhk9HKjTtT/NCNHfFQr+ZJEE5bwhwBhQrCgsqcJOylHlEVy1oVVOVUdesTN X-Exchange-RoutingPolicyChecked: C8/DXWiDU2FCqDG/ehdgxWTEphVAamzJD5eDIldUIC2a1rCxBLGH/ZTLP+Spx1EFU4JILOLe+iolLpZGOmjriPMVnfR1qD+leBYEbBBfTKsmDoIOXfIqHcq795xuj2EDZcUgLNKATHMZgtDnwkTp7n61mw7o83xeshoN1PUZ+9X+AacKeTV7Z9Nb55UThWgcsimn+tr5negF5tnZ/XhDlMxGnecsb26Z1QSCoFwBYN7cHsln2Le/Um9DQeP+A43V0TFwhwpX0ylx569YqfpiQSzhDK25+fPy8MScmdjQCl7W3KgTXBNPBc4swqM33KIWLBg35oBceRkXDdBzlZ/7CA== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Aug 2026 11:50:05.2444 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8f98e7b7-a6d3-4c9a-0923-08deff7a5795 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: LV8PEPF0000005B.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR10MB6598 X-Authority-Analysis: v=2.4 cv=O7AJeh9W c=1 sm=1 tr=0 ts=6a883b72 cx=c_pps a=fVVZRgaqDuj868rfKEvgUg==:117 a=iwqwCZQqcuTv3JOpYdM7/Q==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=Sv0fKeRqtYgA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=gO1vWkAQAl3rybz1DQOp:22 a=P-IC7800AAAA:8 a=sozttTNsAAAA:8 a=mFCyQ4P7OL-0BhijAlUA:9 a=d3PnA9EDa4IxuAV0gXij:22 X-Proofpoint-ORIG-GUID: Dn8a9FOgEg_3n0DWDZuBF0GMr3HCILJ1 X-Proofpoint-GUID: Dn8a9FOgEg_3n0DWDZuBF0GMr3HCILJ1 X-Proofpoint-Spam-Info: AW1haW4tMjYwODIxMDA5MCBTYWx0ZWRfXxZq59M4Z+Pts Kvb3KAdnOSO1PIaZKMQoQIlrddXFAo4EwW2bAp4i5LxVRjmzK9U50DGrddr47h0mPpfnHZZa/N+ eTZDEDIPm9+oAATzsYUHLj2hSvukvJk= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODIxMDA5MCBTYWx0ZWRfX9QBkx7ft8kw2 pgMfChOtbBOnWJQsG6XHgvPsFooVv8UplyzlIutrOeCq5gGffUPQeKenfvdL10u3GNShB/VUFcz hmUbV8e6JUXVhk0XbXhLJweeA/cMUrJnaeV4n3zfWYVq28/JCQ4YyPSWHTxCVbiWxy8wp8ShCqT hY1CbYU0TCs/HBQ8mU9Tuv5aFXpcJwHoAhqaVi3V0njW55Cx/BdYLA9z5KdX7nSobtTkxPuEMUF UBGP8nGR5BdUNiXpzMeScmSIVnBsv6E8hgLH+GCqoV3SgfQ6a/QKU8zulSKzN7zvoTE/ik25674 3zacRxEdVa9O8J5eKFZBftFAV+olCgKi0SVSwBQoKH78zHPoTequizK793VTBqx3BkuLXFHW7mO EJBzTXkFfXQenVJ4D2YLegGF310rXH6mdh1mxkUZafR/ZBKxv4mvMigSs24Y8aKhg39yRgTPzI7 BUaiYIhuMWfuz8JHJsQ== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-21_03,2026-08-21_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 bulkscore=0 phishscore=0 adultscore=0 suspectscore=0 lowpriorityscore=0 malwarescore=0 clxscore=1015 impostorscore=0 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608210090 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. Reviewed-by: Miquel Raynal 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 Mon Sep 28 13:17:36 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 D23DB4908AD; Fri, 21 Aug 2026 11:50:24 +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=1787313027; cv=fail; b=ASTBPK72NSGZfNf9dFWkgnkXlamzmdUBRYtQkcL/Gi+4hY3tVjdW3f8kOO5cqyZaZeH4YINgDehGhtqYyQ/gIfKwzMXhF7CYMqmIvLsIDDS/dVeqAh4QcaxHqYv2I+a/2iTfUefnTI6yGREEjlsn0pOC9yiB0Kp7K/r3jPf7N2Y= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787313027; c=relaxed/simple; bh=NoM6T/+m/Y8FhxNH09GR379GBnAoDkPBo1RjNaYkypk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=hBsAt3YNzTKOy/hYFfMs0pggjFTiKHpQmmSnEIY05TL7kQQzpR4few4E+BRdXaEX4atpEMnbplKUXhClJ3JFnBFe6KbUOwBlo/u5lDluLHwXaGg0YNPvZrvsnTod9lT8g4jsDIeC9UMwQFMfxGisv2dM3EU+2H5ZpjGlmBd6IAs= 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=fSXHGsYF; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=d/6Q87tL; 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="fSXHGsYF"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="d/6Q87tL" 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 67L9KP933254958; Fri, 21 Aug 2026 06:50: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=VG32YQOxvDCXwVziXW0kuCU2/ysyjR6Bo9aedV6M5 FQ=; b=fSXHGsYFGh7wAqMHfnoOsrRaveEqXkmrVJjlMftN29KcytlcqeQSjltXx 0Gwqw7GZRodA63wZYLS+oGnE+mT3h+Ji+QbMfipA38bxo9xx39Gc0ho9ppVzj4gS VjU/AdAWa1qu/Qu5sLpo38Eqdmti6kpWkuvUAcKAwWUlMumWo0d713fLigGIEKqT XFw8NE/HxAIgEPk4+tVOHbk8DBIg7FjSSceT+NmvJHfpHDZGL8FRazxX/Sv6Cfsq LtAQ3zESYkI1IJfWrX5ucaZ1203Fr07d1BUSVNx2OlUgs9uBuELFQZc1dz57ObZb H5/R+/3h5JCy7QcRICk00DL5rNCOA== Received: from co1pr03cu002.outbound.protection.outlook.com (mail-westus2azon11010056.outbound.protection.outlook.com [52.101.46.56]) by m0380145.ppops.net (PPS) with ESMTPS id 4g6hfk1dgr-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 21 Aug 2026 06:50:10 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Dg1OPWkFgfk+gIxzJrTB3cJzr6CMCxo5Q28SBz+9AJ3bG8G0eLU3SmcU6tND5MOYMzMDNs9Q740s+3/6L9yqEUgTrTJw57+pzwH3d/7H30ZIOGCUnu6Udxb1IC65Mo+hRlKmdDqas9bIt+UWBcFjCDFLLCDMuiV/nLahvabETCMIeHCD7aNN81JhmOFEk8ZeWA9SUpobHDTJRv584LSm4ukhy1uQVXzaSQV4szpaAs6AmE92375o1sZocvKipJ6CPfUR1rV4N+pO90zcC+UF6bYTQbhvd7Qc4vD5dAVQDoC6l9GJPLpiLaNEPjlmlQyo143TsnDqzbxQXaiwsob5SA== 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=VG32YQOxvDCXwVziXW0kuCU2/ysyjR6Bo9aedV6M5FQ=; b=hjT6f9wO/+LEMivcB8242F/miNbzQMvRcjn/Gzi4BdLZwvR5DBvtVyWEHZH8OJSzwoi5HQuXnoNtikKvl4taNoOBARRTNoVXZXv8zy8Vg+ZVonMdgiRwvaaop+cKs9ayQoJEeQgv77jrVW6enWSm9nhXdK9n+ileQUl1ZVsBuAiI+5injPg7YDhMmMAOAYJVuP/QfcXlL9BBl5KxJ6cSSNoqBmey73tj4KAzhr/VwzeqNxsDi/85b6eqPcwn+EF2gn611X4TkmIpFiNuTDX4ERcriP/ZYiiviyRCW/ooU4/HiJPipB1R5qkypV+QE52OyWgAzQ56fDbEKcI6RzD6yQ== 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=VG32YQOxvDCXwVziXW0kuCU2/ysyjR6Bo9aedV6M5FQ=; b=d/6Q87tLcuvqSnviSms3N7152sqk+XRDnVJ1rsrQWsqU440ikcHEu99D2NDYaZUtNnmEGl+P4tAD2RnrHidy0YzNvnrI5u3Lzaa2YmX4oDQaXHeUf8PI502q8NNmY5hR4DosW0IFbY7gA+kA1zOLaV+Ttr2Eo+YsZHZTv6rb5WI= Received: from BY5PR04CA0003.namprd04.prod.outlook.com (2603:10b6:a03:1d0::13) by PH3PPFE6F9E2E1D.namprd10.prod.outlook.com (2603:10b6:518:1::7d4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.339.11; Fri, 21 Aug 2026 11:50:05 +0000 Received: from BY1PEPF0001AE19.namprd04.prod.outlook.com (2603:10b6:a03:1d0:cafe::d) by BY5PR04CA0003.outlook.office365.com (2603:10b6:a03:1d0::13) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.339.10 via Frontend Transport; Fri, 21 Aug 2026 11:50: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 BY1PEPF0001AE19.mail.protection.outlook.com (10.167.242.101) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.360.3 via Frontend Transport; Fri, 21 Aug 2026 11:50:04 +0000 Received: from DLEE212.ent.ti.com (157.170.170.114) by lewvzet201.ext.ti.com (10.4.14.104) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Fri, 21 Aug 2026 06:50:04 -0500 Received: from DLEE201.ent.ti.com (157.170.170.76) 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.45; Fri, 21 Aug 2026 06:50:04 -0500 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) by DLEE201.ent.ti.com (157.170.170.76) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45 via Frontend Transport; Fri, 21 Aug 2026 06:50:04 -0500 Received: from santhoshkumark.dhcp.ti.com (santhoshkumark.dhcp.ti.com [10.24.52.55]) by lelvem-mr06.itg.ti.com (8.18.1/8.18.1) with ESMTP id 67LBmVlr2022942; Fri, 21 Aug 2026 06:49:59 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , , Subject: [PATCH v8 16/18] mtd: spinand: negotiate optimal controller operating point before dirmap creation Date: Fri, 21 Aug 2026 17:18:20 +0530 Message-ID: <20260821114822.4040338-17-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260821114822.4040338-1-s-k6@ti.com> References: <20260821114822.4040338-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-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY1PEPF0001AE19:EE_|PH3PPFE6F9E2E1D:EE_ X-MS-Office365-Filtering-Correlation-Id: 9267d0a8-ccc6-4023-69ad-08deff7a575f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|23010399003|1800799024|36860700016|82310400026|10067099003|56012099006|3023799007|6133799003|18002099003|22082099003|921020; X-Microsoft-Antispam-Message-Info: Sz0JzGunXn8Hsbtmwtr53LgB2mWdoKoxFmTh3iz8gjhG6pX5gPzjwvQRjhe5ChqEljtVAtLHzViEWJE3XKhQBCHe8IeauOv2sQDlCz+FSICksdDSaRMCHGxt3ITdCIv1nAsuYa495dj3Jw25n3OC5kzqcFr4/ChyWdC+qDnQ2Ss1QBiRD/g4JIXwbZ7BR8JhUSyAc4jlXNtjUMED88Wiu7vH9yTlyDU8k9U16IGm0/diXDGkj84yNWLKKHQtlI6YZZG2urtrheZ+HhdHoVBDYAr6nY/9NVQekWw4GzsVb82SNIeRf2kPJ4VBZm90koiClYtEOXL3PIfGbnaTE4EZweFMJYaU7wJjwghPg0+H+VmG3r5c8ItE3ClGqP3Rxwa02XeCZDagrVu1oq96M5CFyRXUglAJ60KyG8NCnAFihcoTSisma/GNhKGeYAD+TNq9ifq0YeI7Tll5dpJ1dciZ8zLeRE63sRCMA/tfs5QSScQwNH62wUYVgJO0P0Ju8TTBR09O4ip0kZMZIIG1EHf2WwBuvjqoMP7CDW1akdhQTkQitGg8/U4G9vxMsrgEXHrpm+Y3T3kW3txS3/PRbsVPE4Z1SuDjM9lcs1F9MpJ/fTkGPZZF+Wtt5gXsLWnGGKvUPQbScgRZBs3SbUYXjvvZccqNURzl96mwHlwQ67ZVZpEKCshUHUDGzpeNXJs3kgfwSWI5nm4jhxPKhI02Llz2HbyD3B72yjkgjPDB/LQx6Fgmbjm6Vy67BcpNGuqfTocz 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)(1800799024)(36860700016)(82310400026)(10067099003)(56012099006)(3023799007)(6133799003)(18002099003)(22082099003)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: FoXwm8C3UknNdwrpavIssVJu8T7bMwfgy2ZOqin8019RcThzOHwCTeaOzVuvLYeP0pqtaWREcbK4Bfte438JRHjOpt75E7quXC3kXQCOoadtPXGKFAp25z8i1BmTOxu7BC+7K7e11lAQiTianZL4CrCzxuYoxy04HSpiHOHeMCKQ2ULfgRZeVYT2nuVSmO8daENj2zTKDKNzCRqCPPhjtL0fHd65vG/pCVmB5ioRaSMWXhwATXEvSnY0jE388gKI4z1QfiuRFdHvMtSftP42ZZqARsjOpJjzM9rhncBp89r8FTRW63WAk3D19x1E1vCri3u8F+F4nB1EQseWg8Uwp1U6m2W9qTKnV3lnZeIaaAgLgbjax6VjBk0h3Kp+snGmA4m3LHPl18/oRSWymi0wL2HrEqv7yMC9qNCnk/0RU+jfnpkoyupKNE0Q1tNZlr71 X-Exchange-RoutingPolicyChecked: ZlP8wA7b8ju7msmLP5hK5LK+Scqq6AqmEeYcclOY5vYyqYe8l+XxhF3HSEoIXbRpes1NrZRboAnDErJlUTtutCpI8qfu5un/4XjuaD+7T9YzDuCrJJvEGIl1BV/aC5FoGsPLhzQgRBmd/3odBcSgOBzRXZ7O03VhSiA5JnIyOeLylJRxO1CrphV4RhyJZRPlGz+h3gBqUnzFVXapJnW/VTqX8x7HAyPpm9eYGt+uvbTRI0DjuWTecR0pz1M4GN3n+Au0FN0URHLkbYLP/0yj6Gw05w9+ylMBcQJPRNp6lps1YR9h7ZFmSVh8dUEK4KfUKVl5pv0rwAMiznHfQbHqEQ== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Aug 2026 11:50:04.8790 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9267d0a8-ccc6-4023-69ad-08deff7a575f 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: BY1PEPF0001AE19.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH3PPFE6F9E2E1D X-Authority-Analysis: v=2.4 cv=O7AJeh9W c=1 sm=1 tr=0 ts=6a883b72 cx=c_pps a=0PDhd3HO6khzWhHQYbQRQA==:117 a=f+v6EHfkeJbVwR46tk4DMg==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=IkcTkHD0fZMA:10 a=Sv0fKeRqtYgA:10 a=s63m1ICgrNkA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=gO1vWkAQAl3rybz1DQOp:22 a=sozttTNsAAAA:8 a=-qpymeGUnIbieU4wEgcA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 X-Proofpoint-ORIG-GUID: oABq2ssV7IXsON27GmSictGlORRoK8r8 X-Proofpoint-GUID: oABq2ssV7IXsON27GmSictGlORRoK8r8 X-Proofpoint-Spam-Info: AW1haW4tMjYwODIxMDA5MCBTYWx0ZWRfX1PkIRJUJ1zlX K0mULi2lfbrtGRdztK7Dkpoh7ie2T+YKAaBLBimVg0JJQl+yO0PC/o1DghK6LEv8IP/9fQ4H+p9 Ft2YuOi1SYKLNstYM20axll33lojviE= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODIxMDA5MCBTYWx0ZWRfX6GVEi5YcQS4l MkOh0TZRcSCKx8ipa+SyQWM4Yi9vgZlUvbMNaH8ZDCXtPtpoIMnHlFehHSQ6VJgQaycKRKxEKTp TT49SFMjtTFtgcyS5rG/5gPt9qHDQvZG7ueLB7LlsUoTAilj3wpF06yYsjZ4MXHPpslK+lr03mz TexMRwgVW4uVLVMumkdZK5WJAX3bWI9rjpvJqHg4nlPBrnCvdf1CPi1SBHX+ATbxDOgUCBlJZqa nI/Ph8pPzHOPnqTLhaEo7uKnHu2z/uNZgCK37Dk2MFNy9cpiMiM7vs/67HxmgfUXPen5zPNzL5w Hxga4mV0/WxIFdlxJm92/pKQa1hyzs+9lgSpiPUm722m60cBEkmN+qsFplr/yQGbEEUs1KZgPrz ba/fvY0YOBkQXz4BxXpJ5Wodp03naR2XOMihvndX9xWJEuuCBQqm8sYgtiTPTFTU2LcAb0wFYkW i73x/eA8h0KFuUUsZ8Q== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-21_03,2026-08-21_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 bulkscore=0 phishscore=0 adultscore=0 suspectscore=0 lowpriorityscore=0 malwarescore=0 clxscore=1015 impostorscore=0 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608210090 PHY calibration must complete before dirmap creation so the validated max_freq is embedded into the dirmap op templates from the start; a dirmap built at the base rate cannot be updated later. Add spinand_optimize_controller() which calls spi_mem_execute_tuning() on the pre-selected op variant. If the controller returns a per-op skip signal (ret =3D=3D 0, max_freq still 0), spinand_try_ranked_variant() iterates all remaining variants in descending performance order, trying ODTR first and falling back to SSDR if all ODTR attempts fail. Optimisation failure is never fatal. When SSDR is permanently selected, clear odtr_op_templates to prevent spinand_configure_chip() on resume from re-entering ODTR mode with dirmaps built for SSDR, which would corrupt data. For devices with a distinct cont_read op table, spinand_try_ranked_variant() re-pairs cont_read_cache with the newly selected read_cache variant rather than disabling continuous reads outright. Re-pairing uses protocol-shape matching (cmd/addr buswidth, addr.nbytes, DTR-ness); addr.nbytes is included because different address byte counts represent different controller configurations that cannot share calibrated settings. Mode-toggle devices are unaffected. Move spinand_create_dirmaps() from spinand_init() to spinand_probe() so spinand_optimize_controller() can run first. Signed-off-by: Santhosh Kumar K --- drivers/mtd/nand/spi/core.c | 311 ++++++++++++++++++++++++++++++++++-- include/linux/mtd/spinand.h | 14 ++ 2 files changed, 308 insertions(+), 17 deletions(-) diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c index 7c3341f1fca0..6e58e0893736 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)) @@ -1542,22 +1545,51 @@ static int spinand_init_odtr_instruction_set(struct= spinand_device *spinand) return 0; } =20 +/* + * spinand_op_shape_matches() - Check whether two ops share the same proto= col + * shape. + * @a: first op + * @b: second op + * + * Compares cmd/addr/data buswidth, addr.nbytes, and DTR-ness, ignoring + * dummy cycle count and address value. A continuous-read op and its + * corresponding read_cache op are expected to differ only in those ignored + * fields: continuous read typically needs fewer dummy cycles, and always + * targets an internally tracked address rather than the caller's. + */ +static bool spinand_op_shape_matches(const struct spi_mem_op *a, + const struct spi_mem_op *b) +{ + return a->cmd.buswidth =3D=3D b->cmd.buswidth && + a->cmd.dtr =3D=3D b->cmd.dtr && + a->addr.nbytes =3D=3D b->addr.nbytes && + a->addr.buswidth =3D=3D b->addr.buswidth && + a->addr.dtr =3D=3D b->addr.dtr && + a->data.buswidth =3D=3D b->data.buswidth && + a->data.dtr =3D=3D b->data.dtr; +} + /* * 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) + * @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) + * @match_shape: if non-NULL, only consider variants whose protocol shape + * (see spinand_op_shape_matches()) matches this op * * 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. + * no eligible variant remains. Used by variant selection at init time + * (skip_mask =3D=3D 0, match_shape =3D=3D NULL), ranked PHY tuning iterat= ion + * (match_shape =3D=3D NULL), and continuous-read counterpart lookup + * (match_shape =3D=3D the read_cache op just selected). */ static const struct spi_mem_op * spinand_op_find_best_variant(struct spinand_device *spinand, const struct spinand_op_variants *variants, - enum spinand_bus_interface iface, u32 skip_mask) + enum spinand_bus_interface iface, u32 skip_mask, + const struct spi_mem_op *match_shape) { struct nand_device *nand =3D spinand_to_nand(spinand); const struct spi_mem_op *best_variant =3D NULL; @@ -1574,6 +1606,10 @@ spinand_op_find_best_variant(struct spinand_device *= spinand, spinand_op_is_odtr(&variants->ops[i]) !=3D (iface =3D=3D ODTR)) continue; =20 + if (match_shape && + !spinand_op_shape_matches(&variants->ops[i], match_shape)) + continue; + op =3D variants->ops[i]; nbytes =3D nanddev_per_page_oobsize(nand) + nanddev_page_size(nand); @@ -1608,7 +1644,37 @@ spinand_select_op_variant(struct spinand_device *spi= nand, enum spinand_bus_interface iface, const struct spinand_op_variants *variants) { - return spinand_op_find_best_variant(spinand, variants, iface, 0); + return spinand_op_find_best_variant(spinand, variants, iface, 0, NULL); +} + +/* + * spinand_find_cont_read_variant() - Find the continuous-read counterpart= of + * a chosen read_cache variant. + * @spinand: SPI NAND device + * @read_op: the read_cache op that was just selected + * @iface: bus interface @read_op belongs to (ODTR or SSDR) + * + * Devices that implement continuous read via a distinct op template (rath= er + * than a mode toggle around the existing read_cache op) need that template + * re-paired whenever a different read_cache variant is selected, since the + * two are not guaranteed to sit at the same index in their respective + * variant tables (some devices omit continuous-read counterparts for + * specific dummy-cycle sub-variants, shifting every later index out of + * alignment). Matching by protocol shape instead of index is unaffected by + * such gaps. Returns NULL if this device has no continuous-read variant + * table, or no matching variant is eligible on this controller. + */ +static const struct spi_mem_op * +spinand_find_cont_read_variant(struct spinand_device *spinand, + const struct spi_mem_op *read_op, + enum spinand_bus_interface iface) +{ + if (!spinand->all_cont_read_variants) + return NULL; + + return spinand_op_find_best_variant(spinand, + spinand->all_cont_read_variants, + iface, 0, read_op); } =20 /** @@ -1745,6 +1811,20 @@ 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; + spinand->all_cont_read_variants =3D + info->op_variants.cont_read_cache; + } + return 0; } =20 @@ -1923,7 +2003,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 +2094,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 +2122,198 @@ 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. For devic= es + * with a distinct cont_read_cache variant table (non-NULL + * all_cont_read_variants), re-pairs cont_read_cache via protocol-shape + * matching and updates cont_read_possible. Mode-toggle devices + * (all_cont_read_variants =3D=3D NULL) are unaffected. + */ +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; + struct spinand_mem_ops *templates =3D iface =3D=3D ODTR ? + &spinand->odtr_op_templates : &spinand->ssdr_op_templates; + 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, NULL))) { + *tried_mask |=3D BIT(best - variants->ops); + spinand->max_read_op =3D *best; + spinand->max_read_op.max_freq =3D 0; + spinand->max_write_op.max_freq =3D 0; + ret =3D spi_mem_execute_tuning(mem, &spinand->max_read_op, + &spinand->max_write_op); + if (ret && ret !=3D -EOPNOTSUPP) + dev_dbg(&mem->spi->dev, "%s optimization failed: %d\n", + iface =3D=3D ODTR ? "ODTR" : "SSDR", ret); + if (!ret && spinand->max_read_op.max_freq) { + templates->read_cache =3D best; + if (spinand->all_cont_read_variants) { + templates->cont_read_cache =3D + spinand_find_cont_read_variant(spinand, best, iface); + spinand->cont_read_possible =3D + !!templates->cont_read_cache; + } + return true; + } + } + return false; +} + +/* + * spinand_reset_max_freq_ops() - Copy op templates and zero max_freq on b= oth. + * @spinand: SPI NAND device + * @templates: op template set to copy from + * + * Called before execute_tuning so max_freq starts at zero; execute_tuning= sets + * it to the validated clock rate only on success. A non-zero max_freq mea= ns + * controller-optimized; zero means the base rate applies. + */ +static void spinand_reset_max_freq_ops(struct spinand_device *spinand, + struct spinand_mem_ops *templates) +{ + spinand->max_read_op =3D *templates->read_cache; + spinand->max_read_op.max_freq =3D 0; + spinand->max_write_op =3D *templates->write_cache; + spinand->max_write_op.max_freq =3D 0; +} + +/* + * spinand_optimize_controller() - Negotiate the optimal controller operat= ing + * point for the SPI NAND device. + * @spinand: SPI NAND device + * @mem: SPI memory device + * + * Tries the pre-selected variant first. If the controller signals that + * optimization is not applicable for that specific op, iterates all remai= ning + * variants in performance order. For devices that support both DTR and S= DR + * interfaces, DTR variants are tried first; if all fail the device is + * switched to SDR mode and SDR variants are tried. On full failure the + * device falls back to the best available non-optimized mode. Devices th= at + * support only SDR skip the DTR ranked pass entirely. + * + * Optimization failure is never fatal. + * + * Note: tried_mask is u32, supporting up to 32 variants total across both + * ODTR and SSDR. Flash devices with more than 32 read variants are not + * supported. + */ +static void spinand_optimize_controller(struct spinand_device *spinand, + struct spi_mem *mem) +{ + u32 tried_mask; + int ret; + + /* Skip entirely when no post-config target is configured. */ + if (!mem->spi->post_config_max_speed_hz) + return; + + spinand_reset_max_freq_ops(spinand, spinand->op_templates); + + ret =3D spi_mem_execute_tuning(mem, &spinand->max_read_op, + &spinand->max_write_op); + if (ret && ret !=3D -EOPNOTSUPP) + dev_dbg(&mem->spi->dev, "Controller optimization failed: %d\n", + ret); + + /* + * Any non-zero return or a set max_freq means we are done (error, + * unsupported, or success). Fallback only for the op-specific "skip" + * signal: ret =3D=3D 0 with max_freq still 0. + */ + if (ret || spinand->max_read_op.max_freq) + return; + + /* SSDR-only devices have no ranked ODTR fallback available. */ + if (spinand->bus_iface =3D=3D SSDR || !spinand->all_read_variants) + return; + + if (WARN_ON(spinand->all_read_variants->nops > 32)) + return; + + /* Mark the pre-selected ODTR variant as already tried. */ + tried_mask =3D BIT(spinand->odtr_op_templates.read_cache - + spinand->all_read_variants->ops); + + dev_dbg(&mem->spi->dev, + "Optimization skipped for current op; searching for best variant\n"); + + /* Pass 1: try all remaining ODTR variants in performance order. */ + if (spinand_try_ranked_variant(spinand, mem, ODTR, &tried_mask)) + return; + + /* + * Pass 2: switch to SSDR and try all SSDR variants in performance + * order. configure_chip is guaranteed non-NULL here: reaching ODTR + * mode requires it. + */ + if (WARN_ON(!spinand->configure_chip)) + goto use_odtr_fallback; + + if (spinand->configure_chip(spinand, SSDR)) + goto use_odtr_fallback; + + spinand->op_templates =3D &spinand->ssdr_op_templates; + spinand->bus_iface =3D SSDR; + spinand->max_write_op =3D *spinand->ssdr_op_templates.write_cache; + spinand->max_write_op.max_freq =3D 0; + + /* + * Only ODTR variants were candidates in Pass 1; SSDR bits are clear. + * Clear ODTR templates on success so spinand_configure_chip() on + * resume does not re-enter ODTR with mismatched SSDR dirmaps. + */ + if (spinand_try_ranked_variant(spinand, mem, SSDR, &tried_mask)) { + spinand->odtr_op_templates.read_cache =3D NULL; + spinand->odtr_op_templates.write_cache =3D NULL; + spinand->odtr_op_templates.update_cache =3D NULL; + return; + } + + /* + * All attempts exhausted. Revert to ODTR for non-optimized DTR + * operation. If revert fails, stay in SSDR =E2=80=94 a mode mismatch + * (ODTR op templates on SSDR-mode device) would corrupt data. + * Clear ODTR templates in either case to prevent resume from + * re-entering ODTR with mismatched SSDR dirmaps. + */ + if (spinand->configure_chip(spinand, ODTR)) { + dev_warn(&mem->spi->dev, + "Failed to revert to ODTR, staying in SSDR\n"); + spinand->odtr_op_templates.read_cache =3D NULL; + spinand->odtr_op_templates.write_cache =3D NULL; + spinand->odtr_op_templates.update_cache =3D NULL; + spinand_reset_max_freq_ops(spinand, &spinand->ssdr_op_templates); + return; + } + +use_odtr_fallback: + spinand->op_templates =3D &spinand->odtr_op_templates; + spinand->bus_iface =3D ODTR; + spinand_reset_max_freq_ops(spinand, &spinand->odtr_op_templates); +} + static int spinand_probe(struct spi_mem *mem) { struct spinand_device *spinand; @@ -2073,6 +2336,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..31e3a0dfe8a4 100644 --- a/include/linux/mtd/spinand.h +++ b/include/linux/mtd/spinand.h @@ -792,8 +792,22 @@ 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; + + /* Continuous-read counterpart of all_read_variants, if any. */ + const struct spinand_op_variants *all_cont_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 Mon Sep 28 13:17:36 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 9E69038AC7D; Fri, 21 Aug 2026 11:50:35 +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=1787313037; cv=fail; b=aKJEG+dt9i5QDXaI6mxn/YwDmN1gfph7GeTwuDamh6Hwrng3FKW759JmINbiq7gGw5mI0KCNwIHqUeunj6oM6CwYUhoB//Qw0Jve4VCZqDXL3OU/wUq++7f/ljgYE0kNkpWdQVfWpU635xCJkBqb+Ue+XRNrXgQC8eM9WnTDYqc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787313037; c=relaxed/simple; bh=zyzIHZWkbZiJeCTqvhBe5bpyE69d/84Z/bMFLKqBSj4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=grN8UbpD8c+Su581jiANpQaHgLWLmoDdNgzdBNecUYu4PbZInSoxn9ryLwcRyEB5ReHmQhYF04inkoBZlpTOLcy0hz2QYoV4igqzwoGExeHRnHQ6b1I5ud9Jky/wAP3hm2UYXyVQZHpjF97SwB41+As3v+rvYyeO6pbi2Tm7PgQ= 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=bpYkwGRd; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=k3966MTU; 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="bpYkwGRd"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="k3966MTU" 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 67L9KN2b3254934; Fri, 21 Aug 2026 06:50:14 -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=bpYkwGRdDy2ZkrjJFGgZ4//7AQaZkcsGUD8uBljoD3EqGAn2JY5witDyV xf5VQ8EWiBaNeLpgqoF3giQ8NoBl4IgfzghL0XFuqiF8q023jlAGz9eO1VKMYGGH zCvFDClHrHzpyYL6aLyO6YmED4Cu0zFAYOJtUUqAC3TOwapDPhM6TNvffNmoBh1t ZWEB1zYWVOZOlVIyHHegjq91J3vGhMr4sONM2ElNe610LVkF2McjmYSiOUYKkfbH xue8YYGAq1Pju9SSMWABeBcfm0VRy9qYemiN0DXO/00s7HZzcE7eWG4lOaVGLFsA 46t0TGJRLbMG6nnAntz5aUjRd2pnw== Received: from bl0pr03cu003.outbound.protection.outlook.com (mail-eastusazon11012032.outbound.protection.outlook.com [52.101.53.32]) by m0380145.ppops.net (PPS) with ESMTPS id 4g6hfk1dh2-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 21 Aug 2026 06:50:14 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=oPk09hSsLIk2hS5ABMaJLCGIsbN4FMn+J9YK4kl3icZVXeeeTy1S6A+dSHE3XrsPl8/O6tJT2FL/30t7ue1onwO2vTX6seJsIvVjKTGCSitc5fTXtDAy/tVjsQAtYoX3pRj6vE9MUZ1emWwIcjnLYHRpJ/ju7GwrJyb8m7p9+VZSeLj+LKv1hrXVb2q6insYI4nbUe7Da6UxF8oQOykRfygE2kFkP62FHj1IftWP91O23iop6/zBN0bC461pXIULlaIAEUhFx5O62XWmy7IgREBqZTPJpf1BWpgrj9H+5QUWFZXWnn30JG/JHaEKJc4HVKsvSEbv/SyTQkU2Ij2DxQ== 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=jY05LZadUKGmTem0P87zTuTVWT9K5vhGWLlw/EGrkXCx+npO8lethj4I75LPYFsgIdCrHdIcFsdBLYJRMs/GTrLixgbEk2VIG8ihChzHpkVlxKo5xC2UZihgM3bribxI/+DEC0MGfKZK5whdBhkqC/NTBYmYYvB+HCBfFc1NS0jKxWqIJ3Dg4mssx7c9Sif08zA3tCvX9doNzcwtUPc2r1jroCF4ASi+2u5i03/aID2kP0SdqmQ0ytciEzmBR30DBgiFMKPXdpSJAYuMPMwkV+8myfJ0lxZV+07G8XZlXpuywUURdprng/iuEKNsHprzUplszT3phQMaLr+Sy7HwWg== 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=NjiltEpWKo8+XGVIPeclBhOkyH3dhzzS6Rxspq0yyU4=; b=k3966MTUIkSV/hjlm06tsHwl8zfpzjirt1PsJqgyO0/7xC9QfHKsLivhFj8mkKPrCrQ8WjHR/q4Sg3Eg3suaHlnMUDQlN1eubDyfrK2/163fQ6tThxZqseK4pDoujn+wuPQBkdz9TOxYGiT8lXHSVXkpX4swD9jIBv78NSxpRU0= Received: from CH2PR19CA0007.namprd19.prod.outlook.com (2603:10b6:610:4d::17) by SA1PR10MB6318.namprd10.prod.outlook.com (2603:10b6:806:251::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.315.12; Fri, 21 Aug 2026 11:50:10 +0000 Received: from CH1PEPF0000AD7F.namprd04.prod.outlook.com (2603:10b6:610:4d:cafe::32) by CH2PR19CA0007.outlook.office365.com (2603:10b6:610:4d::17) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.339.11 via Frontend Transport; Fri, 21 Aug 2026 11:50:10 +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 CH1PEPF0000AD7F.mail.protection.outlook.com (10.167.244.88) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.360.3 via Frontend Transport; Fri, 21 Aug 2026 11:50:09 +0000 Received: from DLEE201.ent.ti.com (157.170.170.76) by lewvzet200.ext.ti.com (10.4.14.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Fri, 21 Aug 2026 06:50:09 -0500 Received: from DLEE212.ent.ti.com (157.170.170.114) by DLEE201.ent.ti.com (157.170.170.76) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Fri, 21 Aug 2026 06:50:09 -0500 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) by DLEE212.ent.ti.com (157.170.170.114) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45 via Frontend Transport; Fri, 21 Aug 2026 06:50:09 -0500 Received: from santhoshkumark.dhcp.ti.com (santhoshkumark.dhcp.ti.com [10.24.52.55]) by lelvem-mr06.itg.ti.com (8.18.1/8.18.1) with ESMTP id 67LBmVls2022942; Fri, 21 Aug 2026 06:50:04 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , , Subject: [PATCH v8 17/18] mtd: spi-nor: extract read op template construction into helper Date: Fri, 21 Aug 2026 17:18:21 +0530 Message-ID: <20260821114822.4040338-18-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260821114822.4040338-1-s-k6@ti.com> References: <20260821114822.4040338-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-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000AD7F:EE_|SA1PR10MB6318:EE_ X-MS-Office365-Filtering-Correlation-Id: a9bb8b1b-2276-4694-3772-08deff7a5a5e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|36860700016|1800799024|82310400026|23010399003|376014|10067099003|56012099006|22082099003|3023799007|18002099003|921020; X-Microsoft-Antispam-Message-Info: sfU+jiC+ugdvCma9zKGXKB5NrkD2EaRBX77hi0FwvmgqPtAdCiWYFxiR1qXqz+RBIvHSLG6yEkN+e3dOkbHoCo+Gn9hcB9ik3l0VxwklXhj1Dpfwv0DF7lBurpm4lx5KX0f8Q96DrI59SBYM9+VvN0QAx6O2j1/TwJZuW5z8/furZ7dEW7EYp5VbHBJjFRwy5hOX4294YycZWIVW5ZjcNWyjDeooQgOMoA4Fu3BaGFb5gZSfGeP5/J8T7hPBuFYY34r/Lb/RcvBvzTennwU869KX/EnKNpr14iia0BeY9eWIsb6yLMcSQrYhe+4aCZrgok6Uw8MfkQom5OFUnwrgPEtjsKppjX/+gJesikIDgYTmJcc7Hd1/Z/+cGSCIafR68zZvWnNg9b4iw1gi4EiOM3JoEYiYtccXY5OdrmHswiVvY0bkqogcRycy+Lwd1ypZ0Q9QtCgI5Rzzj6fJVtj8546+X86Ghtmj+9UuhNb9Jm17OZKR9Mu1BsPEJJKqatSfQqeM+WinQ/pcNNA90MOuiEbn1fQr+loA7RnjWYWFzv5cZYM3Ascqeah2pDdYss0Re8LYnZYLN45yrJHRBS/0Uk8EkTGKZEzGGATOonIlbp/MvzYGKAvOiIzrcA6yuV1BSL+q0qlTncZWOGYg8WgApLtqP40Z82Dv6yxF3SF4FIVC41olQowahYQiGDVkg4fnPFzFWbGyedAWS3s7HPbCjth/Ge3XXO1HVQKTcZfwjrvLRzfEs04NTVbrg9W827IV 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)(7416014)(36860700016)(1800799024)(82310400026)(23010399003)(376014)(10067099003)(56012099006)(22082099003)(3023799007)(18002099003)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: V6ksmP/n9UGjnSwu+h3VDwfkdsAGlpQq4zAe2YCUr84keyXkaxjsZyWtg8mHx7wSTyRe2+VyA/DFW9Qdz6ZxjuEN/BG5VqJhQjVVBSiOJ1X2v34RMmzdQYBWwtEJEMODYqCtHxB0X/IKxEQlAKfUfPKYE7p+ydieiPIAx7Umr0fzUdSM9okoQkCt3ralfkcoZFetD8iskwvLQ1ak6+mu09LwZXZHIbdB9gbbvGoLFp35q63mrabBuhYIZKkL+xnFZa74egWU01p3muWVeJfYvOwHKl5GsaRuZHXnsSBKduxrmHBLFES2hW9iPMQq79hFOPh6oTG/mGP6kKqV4czGSPhUYFG400rKcjZoWBhrQZlB3ULVMm6oWYpSpdgpauTRLE1F2FDtMD/3SIhduWMkfI3RdxA7nAy8jk/5VSHW+Puz99s59o6d8pTKYyejT0Wl X-Exchange-RoutingPolicyChecked: i67teFPREjJluLm4o5rVB2zRpGfqkydz71lFc5nM01lan9RhLyCLR7ywl1ugxq5bxW4stNtsD6PQt1cWDRmsY0V7wkNHba7moL7tYmus1mxOFl8efNjUsImU7wSOvzq5JpDmmzOP+UYERb/F2CaE1W5Z6S38GR11B0CGfDJqz3WwivarYV8AHcNxlWGO/EtIF12r37N1NpC/cr9Jop3rwZmHX3fDGRMSKupPKNTUOuqpEyMOP6O3gozZWjhc7vYkwJIbZqWafD1EH1gq7EN62vg1feTDwIiy1xvcAWAiUePhweXJbRj4PoXCvPf/CyKteBEYNifv2f8hcbCP3yLRZQ== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Aug 2026 11:50:09.9437 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a9bb8b1b-2276-4694-3772-08deff7a5a5e 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: CH1PEPF0000AD7F.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR10MB6318 X-Authority-Analysis: v=2.4 cv=O7AJeh9W c=1 sm=1 tr=0 ts=6a883b76 cx=c_pps a=9n5CQ2h0WC+XkeHDVU/11Q==:117 a=WotqVVQAdb04rnGuttW3Kw==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=Sv0fKeRqtYgA:10 a=s63m1ICgrNkA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=gO1vWkAQAl3rybz1DQOp:22 a=VwQbUJbxAAAA:8 a=sozttTNsAAAA:8 a=XAftrYwPDLqUVEEHSKEA:9 X-Proofpoint-ORIG-GUID: _l6JOy-uMQj3CB_8nzGg3YNLVNCaQMCT X-Proofpoint-GUID: _l6JOy-uMQj3CB_8nzGg3YNLVNCaQMCT X-Proofpoint-Spam-Info: AW1haW4tMjYwODIxMDA5MCBTYWx0ZWRfX3SIsj22vsqgE tRNdszX/oLvYHPxxuT5Cp+tkF/pBKl1QdbW7xlZYurZeE94ZC0u70g8tjdvZJmLJ2CrVCAhFQ73 JIxOHNX2orDKj0dqOObTMxfw3P1cZLM= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODIxMDA5MCBTYWx0ZWRfX0mg/Q8uyfpJc oU5vG5v0ELj9FEwYNGz+XSbLsJ9gpdgfbqUUAglBDl5+KQiQyRJFLt4RTimImKHVd+avOzXwmlx gZzjqsX6wN/R2C3r4ExTOk4zockQwbk5ALmTMcIqYlS4WjA0TQsUXP1py4GRyYXSL6sWJcC+n5P 4TaHBP92nhxk3fR+iNLWRntK0AGl2QUCSgI/vpHtVvZCEc2w8ok+JHu8LH0/ZPfjjTD/3iJo/mv yfLBUq5D9ZHJAcwvTtXIunzq3WiSzTa8b4YiWKraJ3Rq+ZMcrLFlJyVSiUX/DaJQuLpOHUQFecX q9wsYxcXXJaOc00UZ7RWNy2LikaAbQnry4TqKj/g4WXtKWm173lJEWELhmNa2mH02JECNLLNPii 8Thlx38gzYgJvlP/aFEU2TJoOFu5QbEVTgvxvPCbWQ0E5Qi+L038s5XoqlLogruJ86XWdbhiebk BikzjJFM2mGOiUDr1gQ== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-21_03,2026-08-21_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 bulkscore=0 phishscore=0 adultscore=0 suspectscore=0 lowpriorityscore=0 malwarescore=0 clxscore=1015 impostorscore=0 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608210090 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 Mon Sep 28 13:17:36 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 D504C49218C; Fri, 21 Aug 2026 11:50:54 +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=1787313056; cv=fail; b=CgMeWGuYLuarAPyZ7nY9YAS80ui9bLD7iYYj0zn4BZrXqG1sJJxdQNwdgmW199o8OCQxjrN4bQMn3/+v7QnbNPCKSKxFUjWwCg7BqOEpk5HBGRVuWohzDpwzoDGDW4kQAZvlvjlLOdcSkKYLnvHkTssltv5H4o1W/NETEpzMo5E= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787313056; c=relaxed/simple; bh=QCZfApz0WI4MJamsj+4VqpsLIBBqXuUtwo6CKXU3FV4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=VTrIc+brdoE19QncI26T3R2M76k5DTZSzrn4zZQTDrHx1TuhK4phudsFMlnauwMdroTIl4a/sueeO5lgQXwHvDOR9dJ3jXyKbl6vebzpAhNPR5qb4+KlknnVg4AClXMxBUrQ6T081luQ2NOjSfDKUzLLkqCWtbVapYR8nagcq5E= 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=RR2ltqSv; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=FhRFGO+q; 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="RR2ltqSv"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="FhRFGO+q" 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 67L9KRu72887015; Fri, 21 Aug 2026 06:50:45 -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=RR2ltqSvCMprVOfRmaTOlXQBqZwG/oyuDH3jBB7uvrfK1pGqdDM4xiqec UI+whvzg0xZt+D1nhU3gVGGV+OGY0XNVpkVW0cy9jHXOyL2ItJF+xfkxZGWsGIKi LfDFv+M0KLRI3vn7chT+9EZTqw4h+lMsCr+JR/28dWBg11lN9xwj06yuVcXELtw8 xHduiiajWy5RA4uPG4BqU9Mdsh7mOoq61hy1MsIA4F64xV5d8mi/Vq2Mf4C3xN2E 9lkpt5pIJ/fvfslSacmcv102D7WdxP2hJsPqWp4JYpD7bLNClYvf2A4hrKKsnAcU +42WNcqE6KYRVl2Jg2UyYqc2eF8dw== Received: from byapr05cu005.outbound.protection.outlook.com (mail-westusazon11010013.outbound.protection.outlook.com [52.101.85.13]) by m0384305.ppops.net (PPS) with ESMTPS id 4g6gke1mqh-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 21 Aug 2026 06:50:45 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=QUcdpNWbxtryHMpf2dt8siNtXmeYKjBiggZTICbKUk/87ZhdcNHX7o9CokCtOkkTLeY+G/qSxK2HPTcOEKidaRRYe69YOfLYs+aqdjpyosoIq8eM8TNDODDGPfo+MSUv+MdEAykq6CNWZay9VKPyy6Fjnz14S2LhCTh+zL6f7JY5YRUN2JGYTpPD31USXfiEOxLtGhYHRdjgu/XdAOaGvIhlK0I3SYac/eRwDyBVcYPGZBMy1XgP5O0z214oIGQAHzwiRM/g8t8FYhnwxMgzks/OkFnVyvAP6zDcFt4dIAbCRruy+b6Avl8hSwVimodjLz5OVRcZYwkzlLzAKAdPbQ== 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=LA5s2eHraEgpcss2Yy2crT8n8893Hbsv5bhI7/jS+NPnQp9GnnO9WpysEx3btdo7BJBeNONncEmqVNUiUTPZL8m0XskgrgeTN8AUQRBMRN84Y2B+0OpfsXLBlQ1PjdrqWKEqaHOLfpJgOhn5Lx7OY/PdRXK7x3CHz/wzb3uz2oLHktupFnHiI+FJ91t1beIRv33lTw4010++6i2lopv5zNgIc0egWR3gyK0pIojT1BPB2gfLNofcckeGwJ4taK+rHfnzBe16SPw2oWZphiIaF8+ySmyweYDvegMgSYzTEpT4D6RXN7YT1E0HHTllL5tDM7y42aMAHVa2NMjuYXgRZA== 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=CaKka2TXrNmZxg/2rKa+E19ixmWvfwzQpJ0sWclJRyk=; b=FhRFGO+q3VTqWoo5hllcYz1SYJKfHRmBIoq1/FHjeOnwNR+DnQXTlOUi6e37b6Xe7/QCh/uM7QLgR0scjY0//CmRVcbeRGpfiq/j/AFs44hUStEAvNYrXXGE/C+UirUUoTH0qxM77ALCVLjc+CmzfJCd6TGbxKOyfQk61CvtEQ4= Received: from CH5P221CA0010.NAMP221.PROD.OUTLOOK.COM (2603:10b6:610:1f2::28) by DS7PR10MB4990.namprd10.prod.outlook.com (2603:10b6:5:3a5::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.339.11; Fri, 21 Aug 2026 11:50:39 +0000 Received: from CH1PEPF0000AD76.namprd04.prod.outlook.com (2603:10b6:610:1f2:cafe::20) by CH5P221CA0010.outlook.office365.com (2603:10b6:610:1f2::28) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.339.11 via Frontend Transport; Fri, 21 Aug 2026 11:50:39 +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 CH1PEPF0000AD76.mail.protection.outlook.com (10.167.244.53) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.360.3 via Frontend Transport; Fri, 21 Aug 2026 11:50:37 +0000 Received: from DFLE202.ent.ti.com (10.64.6.60) by flwvzet201.ext.ti.com (10.248.192.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Fri, 21 Aug 2026 06:50:15 -0500 Received: from DFLE204.ent.ti.com (10.64.6.62) by DFLE202.ent.ti.com (10.64.6.60) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Fri, 21 Aug 2026 06:50:14 -0500 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) 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.45 via Frontend Transport; Fri, 21 Aug 2026 06:50:14 -0500 Received: from santhoshkumark.dhcp.ti.com (santhoshkumark.dhcp.ti.com [10.24.52.55]) by lelvem-mr06.itg.ti.com (8.18.1/8.18.1) with ESMTP id 67LBmVlt2022942; Fri, 21 Aug 2026 06:50:10 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , , Subject: [PATCH v8 18/18] mtd: spi-nor: run controller optimization before dirmap creation Date: Fri, 21 Aug 2026 17:18:22 +0530 Message-ID: <20260821114822.4040338-19-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260821114822.4040338-1-s-k6@ti.com> References: <20260821114822.4040338-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-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000AD76:EE_|DS7PR10MB4990:EE_ X-MS-Office365-Filtering-Correlation-Id: 24ea8083-7bc7-4976-2601-08deff7a6af8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|23010399003|1800799024|36860700016|82310400026|10067099003|56012099006|3023799007|6133799003|18002099003|22082099003|921020; X-Microsoft-Antispam-Message-Info: Het1R0eX8tseFNAqo7LqkZijY9hre6owpUihL8Ddgp0k1n/lJdT3cli1xktrKWcbHpExBg/Mc6EPrgN2zxoH+JBcI2Q5K/LtswCnzMP3Dg1UnQwkLJUgX9ZfA5mGGB65tZ4i9B7k3njdeMzr5CN6t9BjjlJkbI5fJ6aNBwhlVi7rnfG/pVYZL6yv4vmFbUkowL2wXs2L92vOm2TzSWt2ODfRQh94CnzvA9NhXRvrpZTUmd+l1XkRDNDyTcKRUKRf8CVEntBUr8DfnjeZdvN2tLCNZDLrNV7B8LoCLevPSe0SMx+Ycu3por4R3wWgT1urK0xQBhpyTULUCOILD3T6nl8UCImYNcWxCBihBnxTsU3OBTkdpzu1RqhRcO+W+NSmGO/y/DFHJhGtLjfUH/8+kDxxzhC12KAGMcyf7tDNidTyGnLT0lU/v0rdyZnrk5sViSOBwzBPrfPh3KFi628aWSmKWEeeTasrz/hjZktaA0IWbgr0x/STTqj2Zp6rWaAYOYOL1kOEcSVLdLvxo+SYzUfV+zziL2mHrl0mq5Gvp4VMzVRgpgiKY7lMpPu75PjfSgEIiWL/UE/9sep8QDbu/Regbk/tzxzLSXClQcnRglwNp9C9twr0eCkHSvZmghKPboDhuy494qS4I44DsGqk+DeNkJSKdoUsJ8J9QYq4+Co4hAqkMn4JGgPNE8589PwNPTZaGd0Yt8xuf7IDvpmMp0OPUK0HL7KcD5QwmEQqgsvhGnmoZF5Gb2UboHPKvueb X-Forefront-Antispam-Report: CIP:198.47.21.195;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:flwvzet201.ext.ti.com;PTR:ErrorRetry;CAT:NONE;SFS:(13230040)(7416014)(376014)(23010399003)(1800799024)(36860700016)(82310400026)(10067099003)(56012099006)(3023799007)(6133799003)(18002099003)(22082099003)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: I/zM+AeQc95vf9y+1pBXQ8953M2uHw92+cS9fn8tO+Y5UBfoSoBnhpbAboIok9GkqqMLqaFcOSDQB3LWbsJBPHNE5o4zkFUTJKJh9yI+dNzuRbTBrqqa3jwEd1FXe5lUUI2d3lb7bITxUgDf5iFYV8yHeI0JKdf3kQSA9m4uhaE1/59iomLKejLAKjwki/Z0MB5xkRcv+SFFE19XWUlJIlwe3jOsdWVKcX3v5IoE/iNnLLwx5xhRkw32+W8EoVdud9BtRPd5GPSwdoaCXZfiajcmm5xeh9O6bIT4yc4+VcJGsBHZeYt2UZ+Vv1MvhBDyqJL7Esq+tyoC9zgpCSMZJyu/n/L22YhXUnqeRrax4MeebiWaCybytmt8Z2tcMVA7YbQ6xsgeGBnVdXsejgdVIx227oD3c5NP1TtpsQ/8ESx5+gvJn7WUfWR4ocKOEGHr X-Exchange-RoutingPolicyChecked: B/JDjdgiG6CJ0tCx6+AZqn8d8pkyiT+Mph3919Vvw1XGk8b1x/m8aANW/qkRIF0MmMXQXKvZuSamaBDfSQF7MEHAzyAgkAF2qjImFgeddLWgkWK07I3VV1mFL0nQbnJQn0YPuD3bnV1TZoD9M0t05McyDu1liSv74biXaxSxaDxgORY2yFxDyQbFr81VXwE+zWCH3WhDDx8AfFy2Hk85cCmrIUGZOBjdfgRA02opJDZfejbRcP4Dy2he/OcWU6unPBTFgBr5cQeEneVyPf2j12m7v1fdUpEVkDcbdInPoRBbQBIww3bC0h5It01oj9fDeJy4LhALo6aHSkXtv5IxRA== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Aug 2026 11:50:37.7955 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 24ea8083-7bc7-4976-2601-08deff7a6af8 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: CH1PEPF0000AD76.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB4990 X-Proofpoint-Spam-Info: AW1haW4tMjYwODIxMDA5MCBTYWx0ZWRfXzHGxEWX4aBny FdDz2Kck7p+ST8AumHAY46L0qwKU/bcDVqBtZ0VLPxPkg9fD09dizrIvhC1yT6VFnMbb0qMwU3O ASrEsNWiAWCKxLdGuSVWD3UOJsr5Ci8= X-Proofpoint-GUID: GWZylLNDMpOvPOZCsasFcpH5mXP32QKd X-Authority-Analysis: v=2.4 cv=Fp41OWrq c=1 sm=1 tr=0 ts=6a883b95 cx=c_pps a=s0vAXdo1X8BWGfCUIwR35w==:117 a=tJyPKKxUohctrY4NYmUjkA==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=Sv0fKeRqtYgA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=taLDd7a_hP9WKsMzeGRc:22 a=sozttTNsAAAA:8 a=dAWDYLcBFR4q-bF-ZFAA:9 X-Proofpoint-ORIG-GUID: GWZylLNDMpOvPOZCsasFcpH5mXP32QKd X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODIxMDA5MCBTYWx0ZWRfXzgjs2m39bDfB LKKVDm+biyI8JzNZseb62y9TrOiO9l1/bulYVpS6aZ7MXY0ae8l0MNNfwuuGT0+kdUxVEJ8G4u2 fjAL6g67oixBN8hxq2OfnPtLsXUhUWtqMK0vvQHDwsTOYmV5sUH7IPvryeZgbfPfuP86w7BylcC Qu3comNJ3YKmulzFQCgIB7Uy/Xob+wQsPVr5O3pnwN/N1XkYXxwf6gBdvN00+Tv/Z7+5Ez0EdzT xa5AWDZz6fireDKqt2ikMtIL4FoVJz2dWbu1SsPZ8rk69WosuORuKPwZ4AUBQsEZRDqjTE/9uDy XmJfYiHGeL6MBokq2c58b8wunWGpyXmnZX/+hr0Wbx9lBfi8NLLHnZYGWYV0aEG9CVYDgiCZ1dc Oj9jbAZFkZLS/gk7lgZNYQb2UYPl8gtDDqi5EqS9dMj/Hqj2I0EznmSGJwTV918DUST5ytMhx0V zX3EhDGXlLQd2znd5UQ== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-21_03,2026-08-21_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 bulkscore=0 spamscore=0 malwarescore=0 lowpriorityscore=0 phishscore=0 impostorscore=0 clxscore=1015 priorityscore=1501 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608210090 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