From nobody Fri Jul 24 21:53:02 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 85061437440; Thu, 23 Jul 2026 11:03:06 +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=1784804591; cv=fail; b=ixgL6hxfZ2VJN+A6rn5lmVfcGhnj2LmMUhMIjw5HWUSfLOcrn2DRZ0wVBEg+WqrtzrcZZ2Xm8UDHbiECKvctX8f9EjJ8f2Kx6kkD7lPiV6ab6L/s2HQ0BY5DK6f9jhaDNE5uFt1Flz9C1L1BzLl17tI2M7+7OEtsrdYsOsV85ko= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784804591; c=relaxed/simple; bh=NpoT/cBBl4rAzM2NVlulrn3aPKLC+iksPz2nkPNIsok=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=VvH6ieUhBseGmA+yOYLMqKy/Nk7m81MKuFA/sOJRnBkHAZjiAdNE7RPPivdrpbMtcGs1EA8nqD6YgGOInua+HwAb/LQPoJ+0GRbZvP2vNhf/deumurqoBnmxkfjvDoK1mISHkftKPLa7jWjeVYBtaXHir0b+NhoqDrK90ewLnJQ= 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=KRNnc083; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=vziFv/Li; 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="KRNnc083"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="vziFv/Li" 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 66N9JjoS2008553; Thu, 23 Jul 2026 06:02: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=+pWYfJ1EP748IQC6CtiOQMdvqHr9KlmObkQrKfpTY Hk=; b=KRNnc083EkARV5IyP0SwtH7WNrY9MQwwGfTkGx9TdZOOsjTE0CT1gYrB5 DI+8uCOmhsMasyqyQWSQdV+ScPQ2xgnz6fcVytM4eBgcrQineniXmLJtmPGLX41j VgUgVjxzK1O0VXATr92fW7eqYmg/MB6DhdCVhbcSL7MA/TShzHgwLx2e7cw13xSX x5I7KTCmUZOFXubYbILpyHIudWQx5LHNK/yHh5+Drid9ZUfJ4Zsq1M9vrhafbDgu iCulMrkgbdxxfdDbbp+fEuhqckZ2bBdB62wMUOeYM7nT6QzvtPHvI3hdxxVuX0rn r2RF91iDXl3OPPcvhjFoNwQGkZt8A== Received: from ph7pr06cu001.outbound.protection.outlook.com (mail-westus3azon11010063.outbound.protection.outlook.com [52.101.201.63]) by mx0b-0002e601.pphosted.com (PPS) with ESMTPS id 4fkg7ugcd9-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 23 Jul 2026 06:02:40 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=eSl+9Z3/8K+TCV6Gvh5fKd2No0KL4XoRBPZpKJAEdE3I4c/m6isd4y3atx7KrYnrL2wtGDSDtFSzTmm4WfkCvLrDhXaCr6igfSYJPoIGFfXG4yfTRsHzOadlMASVbJBXW1CPgVAxJkSPXxVgNHe3JkRUCi6iAdcNxm7UkV5lPc2tSJqwD2qOVbJGCGmEVRv5eqRMbEjkSE1EcnKGKh8dKzZNsUjzTHC498vhnGnY2Unq15fk/tYzREP1k44txMuyZsNhu/Tg8OzbxB+FksuxgQ9+TX39XggX2ISfUHruloW9LejA5hosN694wbnYtHpAV+6eE4hDcvGsvNDSL3pZ3A== 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=O19sTkioV4DOvLTEDinqoXZwMcgcIfklf1/yoBmmcfJ1LAom+6b7NlDjmxH4yZX06ag+qGKaP8VSnRBJVZ385lLNISnsV3lxj8GVsN7nvuhl/LmExEah357VQkOps/6lDue8EBJcTObF36pvcaelM3k8a+Pb4S+dfQCxgM4P9RKPJNizapYxhr837gZoTYzY+Pt0atXM5Kp18BUqAPBY5YANykRVLp+rrzR/+RlsAaD/WL/6E8QE1R2XHlutZz6VoxyIF2soCelsxyPrgwN3XtxIxKg0MmEBSzlAuvMWzAlNH1BfnkMUn1BjKMA6LI1xxWOBxxHCMysWeMiy71JZqw== 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=vziFv/Liw925XUKvQFgNjwi/HfKDK3mwpKNujzD+Gu0Jm+0+Mu+Glp2GwXshV17uDqDCGp7ENuZGWCntudyK8IfoKkN5h9BkA2iewR4x1RwcYeT5xACMiaC2/8skslA3DqYp8VjtSXiDAY8OWjfnH2HGiKWAzfGEn95/NuWLAxI= Received: from DS1P222CA0026.NAMP222.PROD.OUTLOOK.COM (2603:10b6:8:44b::19) by MWHPR10MB998054.namprd10.prod.outlook.com (2603:10b6:303:2a3::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.223.18; Thu, 23 Jul 2026 11:02:38 +0000 Received: from SA2PEPF000015CD.namprd03.prod.outlook.com (2603:10b6:8:44b:cafe::39) by DS1P222CA0026.outlook.office365.com (2603:10b6:8:44b::19) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.245.11 via Frontend Transport; Thu, 23 Jul 2026 11:02:38 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 198.47.21.194) smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ti.com; Received-SPF: Pass (protection.outlook.com: domain of ti.com designates 198.47.21.194 as permitted sender) receiver=protection.outlook.com; client-ip=198.47.21.194; helo=flwvzet200.ext.ti.com; pr=C Received: from flwvzet200.ext.ti.com (198.47.21.194) by SA2PEPF000015CD.mail.protection.outlook.com (10.167.241.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.270.5 via Frontend Transport; Thu, 23 Jul 2026 11:02:36 +0000 Received: from DFLE213.ent.ti.com (10.64.6.71) by flwvzet200.ext.ti.com (10.248.192.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Thu, 23 Jul 2026 06:02:35 -0500 Received: from DFLE202.ent.ti.com (10.64.6.60) by DFLE213.ent.ti.com (10.64.6.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Thu, 23 Jul 2026 06:02:35 -0500 Received: from lelvem-mr05.itg.ti.com (10.180.75.9) by DFLE202.ent.ti.com (10.64.6.60) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Thu, 23 Jul 2026 06:02:35 -0500 Received: from santhoshkumark.dhcp.ti.com (santhoshkumark.dhcp.ti.com [10.24.52.55]) by lelvem-mr05.itg.ti.com (8.18.1/8.18.1) with ESMTP id 66NB2OVv1577597; Thu, 23 Jul 2026 06:02:30 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , , "Conor Dooley" Subject: [PATCH v6 01/17] spi: dt-bindings: add spi-max-post-config-frequency-hz property Date: Thu, 23 Jul 2026 16:32:03 +0530 Message-ID: <20260723110219.3180747-2-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260723110219.3180747-1-s-k6@ti.com> References: <20260723110219.3180747-1-s-k6@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF000015CD:EE_|MWHPR10MB998054:EE_ X-MS-Office365-Filtering-Correlation-Id: fc90bd39-3b25-4ad9-82cf-08dee8a9e771 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|23010399003|36860700016|7416014|376014|1800799024|56012099006|10067099003|921020|22082099003|18002099003|6133799003; X-Microsoft-Antispam-Message-Info: Ikw836c3h4W8dY9f8WLtkFVKmuzcjWkd/aIoA8bHid/5Uwh2yzypYiwpVk4rMmn87+D7fKEKauDGydd3mGQELUMRgUKShiBQONZjujEvcOCAx0BjKjTOQ5Kv5Sr5Qfi+KmPXWbZSh4BeMDxPPT5i1V7PqJsATpGLuLbWQO++0aZ4+8mhtA/c1mwNK9c8ju4zaPUSfzzz7Jaqus99qEtmxO74NZE+7YmXTUKQ3AGG3gT2hkEYwfLxK1jDfoaLo2i1q3fhALa7o379qEdLkGNaTNsnGIsW4/mCydGJF9Tt5gCv/B2yEL2/jUQMz3uqu1Mk315DbEZ5wG2UHq76TuyiKYGUm+6FyzRIJg8vDiw6RBfJZEw0XC4FLuKld49cekpWpyYPk5e5gYt9DqaTK8NcNw0X240h4GwxCgoIu5j27p2Eadd92kjqkG9yqK7SyXyhPod/Z4uPrtuEOPKwmJ6D+DKC3B0LRtHRti5bCU6jEiWkHj39uuUxYVTpg59jjyISKKtoEENb7oZOF/224JOPR7g+Tk1NiV+anI2Fg40rEhEIS3kbO5FdAPgvJP1oVam078VYq3gOjVpv0uFX9vZkuzGNSJdXiJ3MG3vv06RvidtiFp7KehTLneT1K0f6DutcmDWUVdQkyfI+SF+DXb4UFsgjFLgRA2HFE5HWKFC1EAcMda6RYOPEWniFAg75oWR8ri+55HdiRLmlnqARWCCJGBGog6Pc13lOuSnHqC4TM2WNf8Zo77NEsXmN2qotz9hO X-Forefront-Antispam-Report: CIP:198.47.21.194;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:flwvzet200.ext.ti.com;PTR:ErrorRetry;CAT:NONE;SFS:(13230040)(82310400026)(23010399003)(36860700016)(7416014)(376014)(1800799024)(56012099006)(10067099003)(921020)(22082099003)(18002099003)(6133799003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: L+qwpiIGEj0CdoUNwgRL6B9sshOgYJfpen1uxA2BiOjmqtCyyvlk/gfMzWFerQupxMINrMD3SanNsYTO7MH/+e6jpmMl2/a1VzM1e3QQHyedu7HDEEUG6vRp3DSpig39HNscCYlKrtaNtDLIHRx+N+YMjuratG12ZZBNTF0mgkSEcqU7YtEQcYY00nJtb7LTav1zmR7fmEW63i2HexnlxXfi2MmnmTSPijolRGnZgkRBqQxOjf7b9wkTIlC8EAlW9tstMQmB7OSMldgY+u5uzt6SZ24rFdkXL/eDRWj1GOQj7RLRgQlYsCX9NLvfmVQtN/vN6q33MCW7/JPSRJc3dddPGDp9jTpdugQiGzX9xAUDkSOOxOYooFMIj54ALVCJ2FLYTNduqWq8imFgw4DuVk8QHuuTS+YbeXBZiqfqKL1kM5jBOIvgaFXW8mjdOHMR X-Exchange-RoutingPolicyChecked: icsqEhjB3LXTBP41P+++f0QLy/NCQaGpSWcCL723Jxv38icGAW0Owh2KHb/N1DqHULGouOG9b/xX+jia/5COIzhf+Nv29WmOhrcGGI1dSzvO9GkW8rZ7Q3yw2oeDVk11T7sPuBCaW32JHI87ZkkPxWMOCKiR/Y9kM3z6Gayave0zz4EWDr5O0f9FIpvbbVE3ufmdg2POO33zK2z6W8ji5qr7Jyc7UIobYEsadaeEeSlDPzN4aot8MyJ5J+uDVxnnzdGgpxQtfRTwx9owGn+tzJvmGirQWfSLOdETUqnQ7O+kbuKmF2dgPdjJV53ueOIjkK69+2uCdn4Tu7ytskmjnA== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jul 2026 11:02:36.2536 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fc90bd39-3b25-4ad9-82cf-08dee8a9e771 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: SA2PEPF000015CD.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR10MB998054 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzIzMDEwOCBTYWx0ZWRfX5P8pH1nYrOrB 4GRjFAdGuFB5nUV85P6h49wQ5063QdJKGA/gROH39W5uPPYHGtO0mLGM/bheqDaUQiYYmOL8+Dd a9CiL/VAONtHZTJP89bLfT+Pr3a6J+XS8csNbPdsqEscmasfr7pv383sYzlmXDstwCJ9oWStEZc gDrG4rHN4ix7V4WV6p6Q2a5vWA8h9T+mJ6cxmr2XA827pmLfIuQoXIKgsqvY7fY2EjuCUbTCzwo ZIU3I1OJOIRkc5ZRw+BvMH2hd+v/FMy7yMHRAupqieUHwLPPdhxorGTiGxJj9EAOBHi9EgrL6Uz FvhouKUuMjlHvRTwTGVw1Uo1XKTeeRKP1Z+E33cRUmqj4VuHBcUVJoeKTb3xc0MnYODU5pXTkAK WhUALhrQyXeJhBIMuXrY9frOQGd+DX40gDZ8A+UuoGJrZrS7hbeDNb/y3I9Qs4fdG8r5mCHdu9g 7Ix+WSXf2g3/DT9W0Cg== X-Proofpoint-ORIG-GUID: jmlyWCyN59VwXbxHwT5AnbGrTNkbKGhs X-Authority-Analysis: v=2.4 cv=c/ibhx9l c=1 sm=1 tr=0 ts=6a61f4d0 cx=c_pps a=f333RhXzhOQaWIE8hCCRDA==:117 a=iwqwCZQqcuTv3JOpYdM7/Q==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=RAioF0-LDSMA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=jwouBfj2j3NM8CExmVVE:22 a=XYAwZIGsAAAA:8 a=sozttTNsAAAA:8 a=skPbNTvFiSR7kuR3s9sA:9 a=E8ToXWR_bxluHZ7gmE-Z:22 X-Proofpoint-Spam-Info: AW1haW4tMjYwNzIzMDEwOCBTYWx0ZWRfX3XUKCBqQX2Xh D24eSvTtVmpqZPzQun5laDD/5QRu8cWVd32BVykqSfZF1RpYbCa6GC8AnHwSKHcKNwMG/RpIBux 7at0IlpSfXF2+WwQQIR4e/OPtlJQ8Kg= X-Proofpoint-GUID: jmlyWCyN59VwXbxHwT5AnbGrTNkbKGhs X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-23_03,2026-07-22_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 priorityscore=1501 bulkscore=0 malwarescore=0 impostorscore=0 clxscore=1015 lowpriorityscore=0 suspectscore=0 phishscore=0 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607230108 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 Fri Jul 24 21:53:02 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 2DEC9459AEA; Thu, 23 Jul 2026 11:03:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=148.163.150.75 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784804588; cv=fail; b=XnWate74MfBU0D1AEI3ccAUDjOHMernRvq0yIORGrvOFSZQAAbAKhsd8TmlEQU2Yu/Bo4mKavRNGNAg+ADKIpAKIamvq+HB5ggz+eAUJTB9AgHErgbaPJx12aehjZIafpwN3l3ffJpAeDp/x5tkOBqf9OA0Zs2beQ7Ia+aBoFG0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784804588; 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=ce4tv3EdxLms4qlqsUNCI4sDQzgt1xCgNygmkVW294Rldy3qPo8gw6UPnPW0uj47xLAiFTwTJORMP3g/YyRUcIS2ohYdMDyVG2ooXY8+GkeRcfmCqg8Twopx0ksq131x3zBB8ahvCdwWahL8pt+Bc3dq0ztRuAMx37kPZQdKmhg= 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=F0tLFVaf; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=SZGLIf7x; 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="F0tLFVaf"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="SZGLIf7x" 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 66N9MK4n4111149; Thu, 23 Jul 2026 06:02:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint-05-2026; bh=CfcZ3asnTmwrkxDLnD+kXTLBg64BDPwemZSrihZFQ lA=; b=F0tLFVafzzdtbupgOGRFzprrdrX6dBIJgNPfwkpI6+EnWSL0Wy8drPVYX DIayrvY22dnDvtzCHVQP9bI6Ozbr1GlPJuw37OjoS+JbCcnoaqiUEEiua5Ic/ypk HVUnN6IQ0meactanZGz1+bpNuQmzwzL6YLe3jQ1vWRlwwkwzVXb6DqkmzdqVpZSD LXDIci8D0NsTfC18OZX8uD0/hG+UXhVUObF4+W6wEoi6P+P5t1aFfWu2loIjv7ky 7PqugoetyKRMJ3wOrfAHBHieqD7dSp1XGiQjoEU2g7YMui5ufXrNriXgXeU/qfmC 7F1GOHrprDMuH/JQr0v6F2gMUyDMg== Received: from sj2pr03cu001.outbound.protection.outlook.com (mail-westusazon11012019.outbound.protection.outlook.com [52.101.43.19]) by m0384305.ppops.net (PPS) with ESMTPS id 4fkg908csx-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 23 Jul 2026 06:02:47 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=nC/pfl1Rsc+7YfNywFWqiw2NI9fBmCV1LloQJojPTlXv0Sp9lI9WOdAu02PCE5gXiHK1CVs4JfkOz9aWlF1sBhpjprIbZ7JF7iBWRCKKfX4Xi1DUWULjcvsP1PRYMjGRxhu/P5rUDHQEujYc9C8CFrretsIfXB/29+9iVRVAipfNkzx9l+cMeiJlvzMtIbFcYeERUg4lohLw/fk180H5Tmc8d9Rhd6XR9Gon47RFXgT9Ma2wPLFyrAb8sfywA9faqnZ1aIsy0rwP+1PXOKnPGgAJajSNieveRC8X2irCN3tAd8u84TFFkUVrcN9OqBz85uQE9z8tMVb7yr3irh8TxQ== 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=o8Il9Wyq4y9ASEh9dnfo3bcPmUMDofF+gwndNYxkdw3YXJprl87zNhJkC3hZUP4DhsgPAYj48lMxrOy4uqSR5nO3RIY5qNTVxwx72wc853euMySPUlMdugW4iv3UmYsH41jRpx1xPAqjazFxD0dOrlp+zXhDGhRXANGvzH6dLcC/ws6LClVetmFpplBX8XLT7IMsvrN5k1sK6DEtlxMq5ruuvYp569Z3oC564zl7DSVYkEiz82rgg1hmgR32IJDIGSM8YDBqPdJor+OKXZu1ku8OYp06eWiR+u/wgJHCLtdR3SFcxOnKc74lLfSeBkoB4/4D8gB6mlRvUG8fRpMzNg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 198.47.23.194) smtp.rcpttodomain=oss.qualcomm.com smtp.mailfrom=ti.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=CfcZ3asnTmwrkxDLnD+kXTLBg64BDPwemZSrihZFQlA=; b=SZGLIf7xE9XCqzWpSDcEVPgehCjsPp7CGBDv9mKcUvQoTzpbvPzunahAqFDGaIsjCaYCfZ53CSPfA3DEkZqlWdL8rzOm3GcRcWw2OuB3wCm5jFc72VoonNXPiTtqhdjm/6Y7upXnOvtAY33SOkJCig7bTeGyAyNREhQMmWtrhfk= Received: from SA1PR04CA0023.namprd04.prod.outlook.com (2603:10b6:806:2ce::27) by PH0PR10MB5611.namprd10.prod.outlook.com (2603:10b6:510:f9::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.245.11; Thu, 23 Jul 2026 11:02:42 +0000 Received: from SN1PEPF000397B5.namprd05.prod.outlook.com (2603:10b6:806:2ce:cafe::3a) by SA1PR04CA0023.outlook.office365.com (2603:10b6:806:2ce::27) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.245.11 via Frontend Transport; Thu, 23 Jul 2026 11:02: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 SN1PEPF000397B5.mail.protection.outlook.com (10.167.248.59) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.270.5 via Frontend Transport; Thu, 23 Jul 2026 11:02: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.37; Thu, 23 Jul 2026 06:02:41 -0500 Received: from DLEE206.ent.ti.com (157.170.170.90) by DLEE212.ent.ti.com (157.170.170.114) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Thu, 23 Jul 2026 06:02:41 -0500 Received: from lelvem-mr05.itg.ti.com (10.180.75.9) by DLEE206.ent.ti.com (157.170.170.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Thu, 23 Jul 2026 06:02:41 -0500 Received: from santhoshkumark.dhcp.ti.com (santhoshkumark.dhcp.ti.com [10.24.52.55]) by lelvem-mr05.itg.ti.com (8.18.1/8.18.1) with ESMTP id 66NB2OVw1577597; Thu, 23 Jul 2026 06:02:36 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , , Krzysztof Kozlowski Subject: [PATCH v6 02/17] spi: dt-bindings: add spi-phy-pattern-partition property Date: Thu, 23 Jul 2026 16:32:04 +0530 Message-ID: <20260723110219.3180747-3-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260723110219.3180747-1-s-k6@ti.com> References: <20260723110219.3180747-1-s-k6@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF000397B5:EE_|PH0PR10MB5611:EE_ X-MS-Office365-Filtering-Correlation-Id: 6f3d1eed-f7e5-44bd-37a9-08dee8a9eadf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700016|82310400026|7416014|376014|23010399003|22082099003|18002099003|3023799007|10067099003|56012099006|921020; X-Microsoft-Antispam-Message-Info: cLS9Ev1KoyDz64xHgUvTBZLHdgZ5y9QuQTN8NLbJGuyB6aDFzierfafd9AN/UzldVGdTgC0eyOZUsHrmDRwJhTTiVC4paKSI4WTrbrmFVPx83DnG7DYnRYRHH/N+Bvmo7XTIk/oxV03q+nFDx+040gJTCAqVvbI+KvVqYPlOgW7oUSWdr2AmyGKWEVTcgjkH/JS8+6hsLVx07jalZOLYiZiwJp6D69JXUhIERrYUCRmXZ23UPgt/zJhK6aRNFMrhJDjXFKNfF+KN0ncStImKJRy7QZ+ipViRy5c3BCfGGP4HMIM9rQ1UwOKrB62H/iBlITlGlK3uEQ2e8rs8gINF4EN1M7b3eCvDEScqwOiuKncb56q92KLncYhjkEphfYNTQdmi1IuRywHvX2OyuZOkiJYi2GpcK4jz7xaLNJUBWB9ogrFZ7HrA1v9QKIuHsLUXB7jAJXQKmeCubNMsu8WRqZWpnPLok8fOl45GBoKvql4ti+dr06nZGendZe7ESp+Caey7UZw8Sx426MYlTdxoVl1odanN0hLMkd+ydyv0l547R4kn7TaPP0f7wvmeqA+0eWbzELjyrGkA1n3kBNbUDmsRm0Fmb7p09b/3Fhgc6BU1G7bWNv+45E/XL0f3PjMLd25pet2MzNm6g4GQTDK0/+YsdyuOmKwbZNNXUrx1OtFBjV0HdEVRaHm3k1nz6/wxRRCwYDfyWJv8SMs2A1aDjddo49uWgQ5cCP+WynA1/Xmiaqd5yVHqK7P1rR61M0vJ 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)(82310400026)(7416014)(376014)(23010399003)(22082099003)(18002099003)(3023799007)(10067099003)(56012099006)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: p2jMmK6xJC4nQlEiQeRMthtsOGaZdScEGCGsv27KE9xkOC/7qD5Ame+nFE5t08jDIwTxha3cn7oosncCGwHB4jrJEpvbpiuLSWhMRFDE+v3MngP09AUxPdqBCGjU66fcjf0J/j/32c8SfDsWWuqwvyFQySD5d1UBDSz3QLKyHbQtQBJt4h9mx1/GmrdVUHKEpHthxn/tfCVzhERmthCyx3yc1KoJHEcKKeRtSqZlMAyj2VKMVQFe5HckAQEpCZ2DvVL9g291m985t1gkiPwB/4XY3ZH9uRcbYptYG/9bIXk6i6ddPpSCSfnBZvrj19hmEeDpJGT6rxyFUzVpvqJn3dBM5blPdUkY3GwEUoJ1ned2At31q5PRyJpz3M0NSpQqIxa4TSBx5NXX/fkgFDZTW1nE0FDtbkJwtpif4/eALWbahLleqefJR6BiU75ojEDg X-Exchange-RoutingPolicyChecked: mfOXPy8fsnix18d+d0JKCIv95iwX1x3VOn/8pGKqXYb9kL+P9nnOxGxZxBJLC9iIOXuiGCJgvnlznhuI3lWEWPvSGhnzAsp1uvvyS0Ult6HO4SaR+1Z1xmS1i8dJJMdSUS/sn+8k1iB0ImokeUAM5klznz6jdT8xi8kS/OzOu+sqynLTnvoBDKrfQZrK86YqRa4VwkyL7kaaZqDuJu7AaP4BwT/d5ZM5nyuLl71HXucHUluo1Mf9GDbfdUHFGf4ciP2TYqsML+fZTZdAuZYYePlVW6uN7pDu4JvJqBKz6fxxLHwnr1YBTHPDd7tgKBr3gr4JHebwnzjZeu0Ip2kblQ== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jul 2026 11:02:42.0136 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6f3d1eed-f7e5-44bd-37a9-08dee8a9eadf 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: SN1PEPF000397B5.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB5611 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzIzMDEwOCBTYWx0ZWRfX2Dy8RDq+L/Wc oRnEy0h6LtPrktKIQ7Z8cOuZbHOqb65Q2uc/FkiDhIPsxijBnptJF2laKOxj9sY6cuTL9XR4aH0 2y5HsAqaSuWiW+FIKrfhhvQG9TkWek1vCaH4lVEqCIouU+1ZzpWmbZaHSt8o08eQjbHa8KhEFMB aSDB1aJNhRUoUMG12j8X9DyTDCHohf8wKnvfkD4M6G2p8spJFbcdZSHi/OsXxHZgl2HAdkLEHp1 QC4l3bN3Z24LzqWJkwEVjrE75RXXH+0K68JohpRVvRA3M6Pv45E3Oc5IPY6oFEv283/okDJb99t 1XCELryWPOX61vMt8VwLE4GAB77Xsf3VxPLuwvQun24SN8TPTpLvrDxXeLcxOK31EVT1Nb33h75 aX2Yc+HrwtVfRiHTaLCVD0cGEnfPoHoD5Aj20kZw4A0dyuenzCqcqqBaqeU2EwLUyVFslJ+Cv1Y uFvJmFq39LG3iiNr/FA== X-Proofpoint-ORIG-GUID: hekhYj6kS-FC7lL-kkSsXIrdQ29X4f7V X-Authority-Analysis: v=2.4 cv=EeT4hvmC c=1 sm=1 tr=0 ts=6a61f4d7 cx=c_pps a=/2P0sUepIMZl1V3lWabuzw==:117 a=WotqVVQAdb04rnGuttW3Kw==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=RAioF0-LDSMA:10 a=s63m1ICgrNkA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=taLDd7a_hP9WKsMzeGRc:22 a=EUspDBNiAAAA:8 a=sozttTNsAAAA:8 a=aBuQwODoJmrdCVe4joYA:9 X-Proofpoint-Spam-Info: AW1haW4tMjYwNzIzMDEwOCBTYWx0ZWRfX+Ov2A6KtRBLX 9sVRJT1ThCKdBCUeai4m171B26HJdxrBhdy+bU+WtztOR7gNO9RQmMBQpNnLirhV2eXijFotXgZ HprRsBeNHXV3j81Shf7w3srJ7261ydo= X-Proofpoint-GUID: hekhYj6kS-FC7lL-kkSsXIrdQ29X4f7V X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-23_03,2026-07-22_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 bulkscore=0 suspectscore=0 impostorscore=0 priorityscore=1501 adultscore=0 lowpriorityscore=0 malwarescore=0 phishscore=0 clxscore=1011 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607230108 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 Fri Jul 24 21:53:02 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 2DB85459AE3; Thu, 23 Jul 2026 11:03:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=148.163.150.75 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784804589; cv=fail; b=j2fRrlPCi5vB1ZFa+AMOi+7fPm0eCMy8rdbKW7AJ5QcUwKbSelBwfeFNRFn1y6DNOOtknpf9jLnvjeASribs7MAPz2rkP0aLninMG6lfchIQ7IZYf/5u43UhZ15iXb8ABiDfJL6XkM4w2rnj8k/DSnhGr6VJwOHhvRuEk7k5nZE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784804589; c=relaxed/simple; bh=4oa26rSgSzLAyhplzRa510WlcMbc4I0GAPg7DwxDKWM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=W5L8X+s8vgbbAnXUPu3/a0nNqfoqDDeIIwPoRmMcLpukzRTW6rrhYc0lG1tcASC/+uPYZ0RY1/qB1O4hxqK1MRcrbfnZslpDx9W4SgxypkPt1gBGM2KkuHrPRc9iIDzNuuZcBnkJqUz57AGK87rvXrTiN6CBpo+jNiBafTMPAFU= 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=H8q1TZdE; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=fN3l5KVg; 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="H8q1TZdE"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="fN3l5KVg" 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 66N9I94E2039663; Thu, 23 Jul 2026 06:02:54 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint-05-2026; bh=wthubxrx0wa3saAG/KwRvS2nadAg6fNYlJEYHhse0 H8=; b=H8q1TZdEtABAx1y+1P+kI6OKeAtQfk+lTKMrW6/E7KrxGo1jseN9DAs3C q+n47BuMXXjyUvXF0h17fKgy/qiVPenDNqIa04m+3dy6dEbyB0ejAN5JSKBgsZWS EpJDmAaCTspTKQ5yt9boJhbRwO/5bX59T2qydB8O5v4MidXyUyf1IQhanUby0sCg OBixYYr8iNgW27IiboLMrzvbLgWxtxIVqvOvs075mHUgFzQ5+KUboQet0tCYePHc gRYgZLB8WYyDHkFSA5HPpvWARwli2hlMEFV7NuEo9r+FCc/VnzbxT3TVTR7emUT5 S/bkdhoNPFP9L73DKBL1kjv4yD8Sg== Received: from ph8pr06cu001.outbound.protection.outlook.com (mail-westus3azon11012047.outbound.protection.outlook.com [40.107.209.47]) by m0380145.ppops.net (PPS) with ESMTPS id 4fkg730c3s-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 23 Jul 2026 06:02:53 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=cR/X59Gfu3qa1n3hzvU8t0tRLPXaDFx2nJWp1QhQD2xqc4a0Wq5qjygEhPsYTSDs+eeF4TkY+pIY0Rh+8bjp2O2evWbkvfDHz75i3mabEAMSnJT/yhrDx4NYKTFHaDA1uZOrl5/k2fUIyMPT+9iltkIvrJzviaLITapELOlnZxSkCkEt+MXQcOQ4k/NGpdpIz/r3vU35lYwbfQg3YlmoMMh34IpIatDCuCsbfrOqEPyKzEMSnvnPjdoX6sqZ0QLY+UkbIe5MKzC1+RduNfNx0s6PjFpK4FtO5bbHUAkjHpD0UXb6Yf904SY7A9+zBw1lWuF1XvkKD+BXzaj/CciOqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=wthubxrx0wa3saAG/KwRvS2nadAg6fNYlJEYHhse0H8=; b=co6RbIN6RoLydMC5MxjdVmeH9I/4uTWh4xSNhcC+8muVpuQ4JeaRZ31EZUSCZ/Qu8NALUwv2CRFhXFgmuEv6QRGKoel0ITKmZii5u0kPH+rPEzRhY/K8d/dyKmn9+BruOlAJq6sN25JTqw1ObQVRWxwpSa8+TqauhtGAywdts1mx8p3/7bIUzXMmNQ3PVBP0S4mX4AnDN2JLhkagQoSjrmNpemGDVa3qHwJhY682F+j2cy4Ca48DKJPuRjvM/t5XjijL5zAajAaSrkq6iBtjkLuH96XcW/mf96JoyzMBAYxFJV2pmqz+z0K8DFVItc6jfMR3RGx7SwMmR9g83qLOrA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 198.47.23.195) smtp.rcpttodomain=lists.infradead.org smtp.mailfrom=ti.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wthubxrx0wa3saAG/KwRvS2nadAg6fNYlJEYHhse0H8=; b=fN3l5KVglZS4VBpJnYuM5mOq5QWJqs+gLl1+0CH15SaNxBukhQJOEhWy+bXbgN/TZ3s4+wcxwZIbyMllTCmxsxM6r+YzAItl1ICH6jHitCkal9k0glzqlMUpB7hfPU5hYiV75JHzs59GKoogNWVVAUdYhndGYXUE/gHHQp3Rnkc= Received: from BY1P220CA0050.NAMP220.PROD.OUTLOOK.COM (2603:10b6:a03:59e::12) by CH2PR10MB4310.namprd10.prod.outlook.com (2603:10b6:610:ab::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.245.11; Thu, 23 Jul 2026 11:02:49 +0000 Received: from MWH0EPF000C6194.namprd02.prod.outlook.com (2603:10b6:a03:59e:cafe::30) by BY1P220CA0050.outlook.office365.com (2603:10b6:a03:59e::12) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.245.11 via Frontend Transport; Thu, 23 Jul 2026 11:02:49 +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 MWH0EPF000C6194.mail.protection.outlook.com (10.167.249.104) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.270.5 via Frontend Transport; Thu, 23 Jul 2026 11:02:47 +0000 Received: from DLEE203.ent.ti.com (157.170.170.78) by lewvzet201.ext.ti.com (10.4.14.104) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Thu, 23 Jul 2026 06:02:47 -0500 Received: from DLEE207.ent.ti.com (157.170.170.95) by DLEE203.ent.ti.com (157.170.170.78) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Thu, 23 Jul 2026 06:02:47 -0500 Received: from lelvem-mr05.itg.ti.com (10.180.75.9) by DLEE207.ent.ti.com (157.170.170.95) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Thu, 23 Jul 2026 06:02:47 -0500 Received: from santhoshkumark.dhcp.ti.com (santhoshkumark.dhcp.ti.com [10.24.52.55]) by lelvem-mr05.itg.ti.com (8.18.1/8.18.1) with ESMTP id 66NB2OVx1577597; Thu, 23 Jul 2026 06:02:42 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , Subject: [PATCH v6 03/17] spi: parse spi-max-post-config-frequency-hz into post_config_max_speed_hz Date: Thu, 23 Jul 2026 16:32:05 +0530 Message-ID: <20260723110219.3180747-4-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260723110219.3180747-1-s-k6@ti.com> References: <20260723110219.3180747-1-s-k6@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000C6194:EE_|CH2PR10MB4310:EE_ X-MS-Office365-Filtering-Correlation-Id: 41b91ff8-8ba0-4ea5-d5d1-08dee8a9ee51 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|23010399003|1800799024|36860700016|82310400026|376014|7416014|56012099006|10067099003|921020|22082099003|18002099003|6133799003|3023799007; X-Microsoft-Antispam-Message-Info: PiBg5yB1aVM3V5Atn2SxYJHw0vSVy5e6Zoppg9T0r5Jf5XOBIRAmXgGIavu0ZKmTB1LIePnQRj2NZBS9HQl/13aACGBfCvj09nlFBrTuBzs0pPh6e3bAqBxh7HqKUksg5g/XD1lEUpGO62lFX3npeOcXCBjwUfKPpPoSmNmce/sgXocmtS37AfcfQ5LL65HiBD9UvOfsVc81AGtZK6Vbaxmnjv+gw92DW1wrxndbQmT7pHjLoas3US4bonauKeTeGQgzhIMvbvfW1gyZlN61+FMGY7f9yNg29GSVDo97RmmgJeC8adSy5CJy4Pu432O09bin7VbyKlHrUQMSeAqU2NmEHx3y/fnn78bMOeunESa4KFwBzQsjDyZYo5AJcOYTe37ygPjby1boOdRirtGx/ay8K9ug//l8vY3t7uVFe4N4UeOmh++uJeUVMvxmmYHNaV/8To9aO6CQruL9AP+kJc7BswwNFwgt1i1IRoQfVemc66BNbUSeKNUBePfG7z7KkhGm1xWKwI9hY8+H9nmRFnoSb/cmLcA2ayyii0okEMid3jkJHoRTiKy5RDyZHa4+aTDfFuVBS8PweK0xdUx+qnVpUrNJq1KGcCRY8s0YDhyLgwAM4oAAtblSHl4IcGA5WhXcegaGJQ3JzYZC1QY8LMz/Silhbv7kYVB6AilDdDmwZsote2OxMjhFOTlRwDhPRRKcEYryY2T7ClGC3CQwiTwxSR2x3vCtVrSkbbOHJpaBjpjMKg1EXRUOxe6XxRvL 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)(36860700016)(82310400026)(376014)(7416014)(56012099006)(10067099003)(921020)(22082099003)(18002099003)(6133799003)(3023799007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: YAk2ZU8QvQB5gly4BqXLdJsyNQzK7Xp9I4ps3SADb3+BngJir7PwK81r/+10Yr9/PNcDyKtF7bI8m4cw4llhz9obwJpkZ3Oz31E0vRA3u6ZRarlS0waaqkVKWZtKAC8xcBtNiW7kok008UpA74YFCQbXMuegrl4zpn4xGn8H0/S4gdJt5TGTPlIHOx2RaDXuFUu5c1eE23kKquO26WNfkoNT6J1mCC6rwbxZFCEzw3bH9Oxlv6aMvZ5HMloDj2HZAjL+jvPpb8t8UE5wU2JYWUTSmg77UbMttH0Ks+vfUGEZnlalhbuxRkF12q3r8ZyFGbR9RLZLZ7s1A3sBAP7CVx8Ox0YY4u7v9vPgtKnf88y9/Xt1KzsbZKjPxClWaKKXzs5O7bsld9EGwl7h7cI5zmL+3yUvJwDdg5XlOfqUTUGBS21z1R7Ha0SPsLMzIfRT X-Exchange-RoutingPolicyChecked: EjTmGsP1NjgyBHrWc77bicp5bpQFWl0pUAVEI0BiGyMdCJ2o8DIwZtrGGuVxNCulU/cV+SH9lGnw3BhjFrEuAQj24laqprM7Gu0Iiq6KLdAF9529ARe3oPx+VXB72Df06mLLrxBZ0op3KoP1zhaq2H7UogSO6Ll9mw31te21SDhfkKMko8b4KYVD4qtf5dVZ0H1seo9QdCCfpf2j/0bkEnyccf6XM6lvil9cPEXGeeEOwXBmxo7g+jgvtT2o1IOY9NxU7PGV0OgumY0FLltcg26H6TTcfcsgJeqQz3RgBVIUfds71C/5wY8F1mjN9on7AFeHKZeCSkgN3tQ4mR58QA== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jul 2026 11:02:47.7252 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 41b91ff8-8ba0-4ea5-d5d1-08dee8a9ee51 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: MWH0EPF000C6194.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR10MB4310 X-Proofpoint-Spam-Info: AW1haW4tMjYwNzIzMDEwOCBTYWx0ZWRfXzkVxgachIDnA 60yqFBJnHY9B/RkW1RAQA3NaMsezZx48in9FIzxqhgvRaCskbbaYi7a0AOz5qlaw43DoIx4PZmk GQtYmsCdcM4qTqnaQRa1AoE1Gib85j4= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzIzMDEwOCBTYWx0ZWRfX3aXMbKK8daMj kIPCHWzb5ROhLPW+JSKHs9gmTSl1u9zG2Ra4iidaL2ww4uX7vqf0SGsl2YaYnfBNasoArJssKs2 5CMY8OuQgPTghv7daeVcvCUcJYVUZwGhZyFunLlbadEMLiU9IysStPfxgcP5W8e343kicaL1Owq CHEL/PfLEJf7D1ufvgLyEx70SF6u3KPA9eya2Yghck38S58szNkq0Nd7w3n2hVlpyxvCQr7DS8G aVTExRjzgqxG9gNOkyRwNZz/DxfpsmToyYBM3A5P6OxushcLLlN/aw1O7S15mQskObV30IiyJhH V5Id6rfzHvqzYSQKcucPwNzHIhJMdHfkGlUfiQnQhGsNPfR8KARHHVNWqYZA0HpdxQWAjK1sc+O 753lPbbUlgusLq+46TD/WoMSm3dcYXM3mcG9wQjT5v1sbA3sumo+LOOuYSwsUm7A0ZqP2ldNy0Y zkxRKrJ5v6P2r0Yg5YQ== X-Proofpoint-GUID: 7P4YJCt5m8JpUrz_Gvt-hPwBcw1bQ5UZ X-Proofpoint-ORIG-GUID: 7P4YJCt5m8JpUrz_Gvt-hPwBcw1bQ5UZ X-Authority-Analysis: v=2.4 cv=Z/Dc2nRA c=1 sm=1 tr=0 ts=6a61f4dd cx=c_pps a=AG4d6nCg1awo7HAtkzPOig==:117 a=f+v6EHfkeJbVwR46tk4DMg==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=RAioF0-LDSMA:10 a=s63m1ICgrNkA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=gO1vWkAQAl3rybz1DQOp:22 a=P-IC7800AAAA:8 a=sozttTNsAAAA:8 a=2Gi1gDZmOG9PIfG5304A:9 a=O8hF6Hzn-FEA:10 a=d3PnA9EDa4IxuAV0gXij:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-23_03,2026-07-22_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 lowpriorityscore=0 malwarescore=0 impostorscore=0 bulkscore=0 adultscore=0 clxscore=1015 priorityscore=1501 spamscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607230108 Content-Type: text/plain; charset="utf-8" Add post_config_max_speed_hz to struct spi_device and parse it from the spi-max-post-config-frequency-hz DT property in of_spi_parse_dt(). This supports SPI devices that operate at two distinct clock rates: a conservative rate always reachable without controller configuration, and a higher rate achievable only after controller-side configuration such as PHY tuning. With both properties set, spi-max-frequency gives the conservative pre-configuration rate and post_config_max_speed_hz carries the post-configuration target for the SPI-MEM layer. Zero when not set, preserving existing behaviour. Reviewed-by: Miquel Raynal Signed-off-by: Santhosh Kumar K --- drivers/spi/spi.c | 2 ++ include/linux/spi/spi.h | 3 +++ 2 files changed, 5 insertions(+) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index d9e6b4b87c89..7e7393d25810 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -2602,6 +2602,8 @@ static int of_spi_parse_dt(struct spi_controller *ctl= r, struct spi_device *spi, /* Device speed */ if (!of_property_read_u32(nc, "spi-max-frequency", &value)) spi->max_speed_hz =3D value; + if (!of_property_read_u32(nc, "spi-max-post-config-frequency-hz", &value)) + spi->post_config_max_speed_hz =3D value; =20 /* Device CS delays */ of_spi_parse_dt_cs_delay(nc, &spi->cs_setup, "spi-cs-setup-delay-ns"); diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h index 4c285d3ede1d..aa7b1b34a594 100644 --- a/include/linux/spi/spi.h +++ b/include/linux/spi/spi.h @@ -141,6 +141,8 @@ extern void spi_transfer_cs_change_delay_exec(struct sp= i_message *msg, * @max_speed_hz: Maximum clock rate to be used with this chip * (on this board); may be changed by the device's driver. * The spi_transfer.speed_hz can override this for each transfer. + * @post_config_max_speed_hz: Maximum clock rate achievable after controll= er + * configuration (e.g. PHY tuning); zero when not assigned. * @bits_per_word: Data transfers involve one or more words; word sizes * like eight or 12 bits are common. In-memory wordsizes are * powers of two bytes (e.g. 20 bit samples use 32 bits). @@ -193,6 +195,7 @@ struct spi_device { struct device dev; struct spi_controller *controller; u32 max_speed_hz; + u32 post_config_max_speed_hz; u8 bits_per_word; bool rt; #define SPI_NO_TX BIT(31) /* No transmit wire */ --=20 2.34.1 From nobody Fri Jul 24 21:53:02 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 A834E459AFD; Thu, 23 Jul 2026 11:03:08 +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=1784804597; cv=fail; b=Wtnm7zopG0aatHuJqrXjXglbB+fKshgqfO9ywmcgQw8hY9A38s9al0D0NZoL8+ViSNa5oiv2a2gZicZKp/ZTyyuBEqpXEsOUbd9tHEKgTa5Ig/65wZRp1Fta4m50/KWbUni/PoNS7yGhLTHf3fCl1k3B2STWekIkOPpCT7GT+88= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784804597; c=relaxed/simple; bh=s0jYk/5KEpyTn+gQ2ZgsqurVBgOxWDscHJlq6GjcfSY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=cPCraff8SiFAwH3nHejZI54YBeAo0qHuM1IVUeoKdXLnhBwqPNpIWj4Jgvmmu5kC6jxGg9SszPgA68Rcz1c0JH84xfuePDJtXF7iq3OBuZvVsaAvfv3Hw7l+SnhAx55+t8P30D9nIBdVhmB576L9ak2Jzmu7/HfnO16XE4xyM2I= 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=FK/HOpQi; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=oNpdzia4; 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="FK/HOpQi"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="oNpdzia4" 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 66N9MK4o4111149; Thu, 23 Jul 2026 06:02:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint-05-2026; bh=dF/dA9rfFrlBBCask2DwOPti+dzd1RR7KKfCA52tD cI=; b=FK/HOpQiaFeLjlcftquTYPHDUAvPFnq7/FEQL/NO4AUs0uKLKSSjgagqb nO2EeN/yZdl9O0wZXkOPZ1myLYJ74oFoJ9X4DI219RTc/gffJN4CqE5C8mOPoVyy I2bdGlmUKf+gy80tLbSFgh6YnXC6NgMVp1EIRBHSBnuxGY3W2OLqiSF+sLm+yt7o hpqA63SdCHVVxARHpfTTrd+6j2YmtIfT4XCvTsLUUKEOh2NewN16JhtlCt9VkZFz 82JnddD6yfkYxnvicoEsqgQnZtmbAm5105aY7nMKYNotywxUSAxkZ67T8/nO2RBe KbdeC+N31n0w+/ybr6nzotRgVXODg== Received: from co1pr03cu002.outbound.protection.outlook.com (mail-westus2azon11010042.outbound.protection.outlook.com [52.101.46.42]) by m0384305.ppops.net (PPS) with ESMTPS id 4fkg908ctn-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 23 Jul 2026 06:02:58 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=hgAkY7vFQgv2JPY3/U3GBFL/45QshyunT3ciisbEXxyOYlYloHRyQazd5A7yIXtLWJerb65gcSTY371jw3znQEBpy7wCXx5owi3FXIkR1MgNjLdTWSpnCElspRreELpmQPSYohfcMIuuEQBa6OC66B5Ce1C7BDLFggJidgQ8wifoFtrEq39ZunMtB/h8owb/zs7MlR9mjUMHZjXe9g/EJhN/+vcwkcxp2KLJwunepVXW8hcL4PLkrhagqmWQLNxvrH2hhlKz+dYIk/Q5rvOA7LXyU+Afyc31LXN11Txi5I7SkYosY4axkK90t0Mejxn/1Fg8FnRvb5sr/GITEifObg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=dF/dA9rfFrlBBCask2DwOPti+dzd1RR7KKfCA52tDcI=; b=k2Po5c6IHs/Y9lwAYyGjeCJ9kWjQPeiBcyy1L6H5XQy1LlpjcxN5ftecZKAma/jXirs1PJMogMGSlgFcANqwaw6w8CGYqB1nxibP8fnmKGwFYxwIQUeOcYha9OrJil37gbgfYd5rpVCZA1pqFV28wKEuQZEtju3tji+o5wcJYQQEODQww2CDDZe9lculDO+4qXvbCGT50QSsASpuNstPVtxIUHNIQte/4sMWXAJqPnG7CSqq4asd08KbnA4ENRbrIRH/D3eLu4hz6oxJc9yRZAJrr6VrjcevRgxtDToXLPI7RUa2lB4fxQMZpoNZtK8LWpTKkg8MYDYWWvE8vr2wpg== 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=dF/dA9rfFrlBBCask2DwOPti+dzd1RR7KKfCA52tDcI=; b=oNpdzia4XcFbPdbYQogAsnLW9xuPJtaHWJSZDWd5CjNpJiLhsRzOvrjs/LE4hlpBdYMw1sRvlO3KclOGwRl5RfkqkIKzW+Rv1X7xb9sxtoLgfQ90Su0DOar6G2u7Quxge5SqNCfH/rLcL3EJToxQz+csb+v1f3y+5J3TvmJc7rM= Received: from SJ0PR03CA0286.namprd03.prod.outlook.com (2603:10b6:a03:39e::21) by BL3PR10MB6187.namprd10.prod.outlook.com (2603:10b6:208:3be::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.223.18; Thu, 23 Jul 2026 11:02:54 +0000 Received: from SJ1PEPF000023D3.namprd21.prod.outlook.com (2603:10b6:a03:39e:cafe::86) by SJ0PR03CA0286.outlook.office365.com (2603:10b6:a03:39e::21) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.245.11 via Frontend Transport; Thu, 23 Jul 2026 11:02:54 +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 SJ1PEPF000023D3.mail.protection.outlook.com (10.167.244.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.270.0 via Frontend Transport; Thu, 23 Jul 2026 11:02:53 +0000 Received: from DFLE209.ent.ti.com (10.64.6.67) by flwvzet201.ext.ti.com (10.248.192.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Thu, 23 Jul 2026 06:02:52 -0500 Received: from DFLE214.ent.ti.com (10.64.6.72) by DFLE209.ent.ti.com (10.64.6.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Thu, 23 Jul 2026 06:02:52 -0500 Received: from lelvem-mr05.itg.ti.com (10.180.75.9) by DFLE214.ent.ti.com (10.64.6.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Thu, 23 Jul 2026 06:02:52 -0500 Received: from santhoshkumark.dhcp.ti.com (santhoshkumark.dhcp.ti.com [10.24.52.55]) by lelvem-mr05.itg.ti.com (8.18.1/8.18.1) with ESMTP id 66NB2OW01577597; Thu, 23 Jul 2026 06:02:47 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , Subject: [PATCH v6 04/17] spi: spi-mem: teach spi_mem_adjust_op_freq() about post-config ops Date: Thu, 23 Jul 2026 16:32:06 +0530 Message-ID: <20260723110219.3180747-5-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260723110219.3180747-1-s-k6@ti.com> References: <20260723110219.3180747-1-s-k6@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF000023D3:EE_|BL3PR10MB6187:EE_ X-MS-Office365-Filtering-Correlation-Id: e0fb2fb8-5b96-4a12-e775-08dee8a9f1df X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|7416014|23010399003|36860700016|376014|921020|22082099003|18002099003|56012099006|10067099003|6133799003; X-Microsoft-Antispam-Message-Info: 1d+oTefWt/KsrOWW214e7Zb9qIfOYl0yCq5n4iJXv112CjDMTjkuYClk4NOvApm7mZomPU57eDleiO6FwQZVM5+q0e1FWqDQrKK3Xhq683dtg3A5GKLDEgf6VUdc/aD5+EOwVh8H9fGI09VshAbYNpPKdA8WF750irl4dnR5Z67eLiAOlO1JH808JeoUJQk76AXYD9crPI3OllOCHboZpx2BmW0oXeThfzxZOht5KUSRgv0WABXotDFX5keLsoeMuaKX2uI/yAaFlInFyh+O8G5Q6xHWUMSZeXT1PAIoolWJneJYXyh01TZ5Q0HOMlsfg1mZQPkerIBVZG++FwIMJ4iRIEojcAC4Bj4mNXAa1hoxSmlLMgVmEqq4kg91Nxi42huMRl/XzoL0ix3v46aQiEH6f/U3xLz2KF6r4dLCQWAGcXpnh8V7J+4w17Hkhe5ca2XPkhhIEpVNy6EhGnR1u689Ur7/Dt9R6bBkKXqS/R0qKuL9Buusb3RteeL+DxMbb8EQdYuTah0iWLjYlFW7+DAKBR+PjA10L+EerAwT3CYmAq+7aAAVl9Y+/cj98Tej7lBw8fepZP0oCElfAhi9ey/SensE+h7vfEaYxD1qo9VHmM1okqvXsgS50fn7nxiMhBZk50vZ+wpqQkIc5+C3XjZetNQ7EScKT72emOmEfhyux/iApf0k8E0DslBD+DDZmpP0h47ZCTo+FHZJ9DoTmJh89hl9ohEg281daebH335vOSwxoOuX5PTCv2nQPMmg X-Forefront-Antispam-Report: CIP:198.47.21.195;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:flwvzet201.ext.ti.com;PTR:ErrorRetry;CAT:NONE;SFS:(13230040)(1800799024)(82310400026)(7416014)(23010399003)(36860700016)(376014)(921020)(22082099003)(18002099003)(56012099006)(10067099003)(6133799003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: hqaG+kP2WwV8XoeaSbRkGtOdHWYuinmPDPb2TAr10UoUqwzFGcUAJe7Gritl6wrVzhBgl+que4eAUdniTsRqLVplg9foSTM5KSwypEB9InVBkauuuroUCNPihlE121pfalOHEHWgHDwVD76xOzeV5NYWgKrc/Vwc1o6uRzbp+tqBU25tE/lWr41THbUXBN/t/H3Q1rya5Y/tF1jA9brGpMmVPBSxTAe7lHmEPNHhMAnpwSsMTV0lReWVgtqq8oRbC6XYNo6H+GrJ8ZIGo12L9n6yRo8+mYv0VWttETfro+x0jY7JmZMdBy53dE/CLgbosjtKygMDeZ2QdAonypedTNFUOToHDbr3ck1ALipy9WRN1lJX9A7ccNyVrCc8w/qO4UgOy2Pd3JbHucs87w1y0lElxIIlwyHwHMIFahet0PRGbLBNNdloyELb6FOuIRsW X-Exchange-RoutingPolicyChecked: bANIOwB9z9pQa/RhIaX7B+EWAnTyH1PcDMO2ipRo9OvSQBkcKIa3Spo9TcCts9AvFZ23dl/48b2XH/Q6n233/zBHfjDBzsmGSd8ITLflZN9XOPG8UXBlGgf9lAHZQruez5R8wAroOVYGvUV42n9pAIlRdc3z4nouMRWaogUtKb0AYlxl0rWOadsj7kw4Lpuua0ggZ4tync3TIulorm6UMWIYXM6031EhK7hnnDjbM0iHhFMkQqtetpqMyo98THIU7nxnRRLaNjNyUbHbg2ZcVz3G161r8U4k9tVt1DYQb2+7tQXjFX4XuNnXNSS1+yw+qj6RiHKgdThLV4ZhNl7smg== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jul 2026 11:02:53.6502 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e0fb2fb8-5b96-4a12-e775-08dee8a9f1df 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: SJ1PEPF000023D3.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR10MB6187 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzIzMDEwOCBTYWx0ZWRfXysojJ92YWl3h LjwpSlqACpYoT/B0x0BinKZsi7ZJdG5Uq/MhhtV6lb1Tyn8LETR6qQq36OJbqMkL/F/bu+9ISfc XMj+86VtnWkwp1jpxi/fpdklAyKUpTNLoTZIbDa5dviJCe1w9ZqUiHK20HhkvvV2wE8/W96Hw/p QU22UcSDRr6bs7sY6b3Mz+Y1ljApw/8wtP9jMN8hiVK02zGW+jn+WpRaNRE+SXHruQHu1WNBwND Gb3z4qwP1Dst0q1VJvfGA3MSKWLsZXGPzteq7l0qLbWoEmLzfvkHtOkPSgIge2GbcGuaM6xhM0d d1gxc1oeL6kx3CH3nod8zGVDFFTGrkjkZUfaHiYv/yMn6KBuXZSpy+n5H690TU+ztp+SsATVXi2 rNjH6rjiLKEXsSjPW4pg2J0i0nRF97vADpCX7s2/qvSy786vv964hHkf5xorCJQc8OyKP+OJ0kc +HkcKx117pCAlLwFK3w== X-Proofpoint-ORIG-GUID: 2YagQIoYkOYrPT03CqXNvZ52zM4kkxtx X-Authority-Analysis: v=2.4 cv=EeT4hvmC c=1 sm=1 tr=0 ts=6a61f4e2 cx=c_pps a=kAM6CeFpMxeFc5AoNv8A9w==:117 a=tJyPKKxUohctrY4NYmUjkA==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=RAioF0-LDSMA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=taLDd7a_hP9WKsMzeGRc:22 a=P-IC7800AAAA:8 a=sozttTNsAAAA:8 a=1EK_O1AJX7ox_F5CMUYA:9 a=d3PnA9EDa4IxuAV0gXij:22 X-Proofpoint-Spam-Info: AW1haW4tMjYwNzIzMDEwOCBTYWx0ZWRfX3ccfclLaTFUs dWesldEIap2LG144gyL1zXlHkQ7nRpL4RyRWfKMUf8pYrS3MmO7xH4q60y5p5wxLVBlzB5QPGAa s6K5wobc9lJ57Q7+qtJkk+6fUeWMnBI= X-Proofpoint-GUID: 2YagQIoYkOYrPT03CqXNvZ52zM4kkxtx X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-23_03,2026-07-22_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 bulkscore=0 suspectscore=0 impostorscore=0 priorityscore=1501 adultscore=0 lowpriorityscore=0 malwarescore=0 phishscore=0 clxscore=1015 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607230108 Content-Type: text/plain; charset="utf-8" Extend spi_mem_adjust_op_freq() with a bypass: if op->max_freq equals post_config_max_speed_hz (the value written by execute_tuning on success), return immediately leaving op->max_freq unchanged. All other ops are capped to max_speed_hz, the always-reachable base rate. This integrates the policy into the single existing frequency-adjustment point so exec_op(), supports_op(), and calc_op_duration() all behave consistently. Reviewed-by: Miquel Raynal Signed-off-by: Santhosh Kumar K --- drivers/spi/spi-mem.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/spi/spi-mem.c b/drivers/spi/spi-mem.c index a88b9f038356..e20eca1b8245 100644 --- a/drivers/spi/spi-mem.c +++ b/drivers/spi/spi-mem.c @@ -591,9 +591,18 @@ EXPORT_SYMBOL_GPL(spi_mem_adjust_op_size); * Some chips have per-op frequency limitations and must adapt the maximum * speed. This function allows SPI mem drivers to set @op->max_freq to the * maximum supported value. + * + * When @mem->spi->post_config_max_speed_hz is set, ops with @op->max_freq + * equal to that value are treated as post-configuration ops (e.g. PHY-tun= ed) + * and are allowed to run at the full post-config rate. All other ops are + * capped to @mem->spi->max_speed_hz, the always-reachable base rate. */ void spi_mem_adjust_op_freq(struct spi_mem *mem, struct spi_mem_op *op) { + if (mem->spi->post_config_max_speed_hz && + op->max_freq =3D=3D mem->spi->post_config_max_speed_hz) + return; + if (!op->max_freq || op->max_freq > mem->spi->max_speed_hz) op->max_freq =3D mem->spi->max_speed_hz; } --=20 2.34.1 From nobody Fri Jul 24 21:53:02 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 13BC6459AFC; Thu, 23 Jul 2026 11:03:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=148.163.154.28 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784804606; cv=fail; b=rIZdKKgESGnBWEu18rk5y4dlzM+JJ0t6ZPg5zx4SNm4caVnqVK15WSQmV0bl31mtkErpa0wZ7GIZigU+cvKB0nUCWjvMCDYOH3z9U1Tk72iPxh9JCyCBxQmSIfmLMFOaEgLzGdpB/l2XOpkl/jTezR2FKneUoTHP48qjO3Y74FA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784804606; c=relaxed/simple; bh=XXod5gsYdwM7TuNfFFwFZK80u1YkPJ13Yfu54EWDiXI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=cxdXn0A6ls9bWSyMZIo+wyHlCa8EKacp4SHBsQ/vRi6voRBGW1McddKjvmPH1SjT4YZyEHHv6y8b5cEXkPrTshlAXZWonKAs2/rL9xRuRLYZLypMMDTtWSGizAjyayi5eWBsXgyos2kWIcGwi9J19fojcy4RTr+aUcq7Cq2+yGA= 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=UMMce4JA; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=Mw0XQhMM; 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="UMMce4JA"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="Mw0XQhMM" 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 66N9JkQx2008572; Thu, 23 Jul 2026 06:03:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint-05-2026; bh=o06IxgyXWxwrCIaljlzC8v05IGlfq0oB+3XuQYWYM C8=; b=UMMce4JA5uHIfzLYEHEwIW4j8y7dABd7s0ovfjz34YV+0Rfxu/0qJ3ath g7EfquqADas1j98UkPQF64s+EZwkqUr+ElgP9Wo3CCRjrIki6KJzhTRuKZvronll wUDLts4uu7neUvil9SKJYX1KsXhoORTfgdE/xtWHH3Yx5QoVFFbigNjl5UhE2ht8 hVZnZBBVujJjS7IGul3K9h0JGv6ePrbKj8WxZuOOPE7bLea1sUgZwHWFhqCxkO4n N4sq5iLLlfXKdlmnmpaK2iJtrrvCmBTJ/btwqa91A+/yXttoKM0ROdnXI4PYJmPC WWNGUM4SqdcqBSKXsXmwqJtkqMYJQ== Received: from ph8pr06cu001.outbound.protection.outlook.com (mail-westus3azon11012067.outbound.protection.outlook.com [40.107.209.67]) by mx0b-0002e601.pphosted.com (PPS) with ESMTPS id 4fkg7ugcey-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 23 Jul 2026 06:03:07 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=oYwjWTQc7F2HOrDku2N2UjNS2Xt3eA/DtAMptgUX6rzWN4wkIuu5erF3Bx2eL3hXV7tCjtJN9q9xBXgfUqcBHzfPJoLX8enky+3d+jjNiMBOYYjNtIIsXLtn30t3YpMxqv+zUgInG8ivxsPpgVORfQqtXKY4eh2lEcVuyU7LWr7dxJqaN0nA9RQc9AD2anJLbP0gOwMkUs0PUJUJIncubGWmZTds1Uk7qXshIfBLM8YdpEq/gkUdhgRw+g/8cpUSwS0SeYHSP0AxqigUXEUndOnECvH0BftchmyF/avB1mYyFtT0bx+cYB/ssSR++9gsonIMdUbc02RSALxwZBlYGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=o06IxgyXWxwrCIaljlzC8v05IGlfq0oB+3XuQYWYMC8=; b=Th0Je7eI2cDC36ROBVePXopyeLBNBccczskq8PzGpDNuVYkugsjaTYs51qnAkOgqQieEvo8dBnqCeolArpLWX4GHD+SlaLWPSzpAuXjvWEufmghxTA55gsetzD1viLdtTnUe4RHmdMwLtEkNs46amXt39lt4pzp0MdzKpxp/JjypFMfF2iQDhBx6f++FzaqVeDc2XPxUfSnBgcJh5WfPzI/N0NzNKQ3edLedf60KSyUv8pk1Nl8/5Qg1B05GNdPJnbPQVRb8cWq1jIzeJ20DP83CfE3GjPxhyjonZyjSiqNqlKH+vpZBWXXnimGNKbaCq2WojPeRWCBpfXwB5m1n3g== 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=o06IxgyXWxwrCIaljlzC8v05IGlfq0oB+3XuQYWYMC8=; b=Mw0XQhMMIMPzxUAHAyvz2PUo4RmDLsh5HMiZN3ONtd/473TZC/tzSBs0pWtTSujeUwFO3vesvvzEjsRHRp7tOjAHcKIlMcZvcSNxPwnCeOM5ntgWT71JAbdtckQccFQWeiFCSQM4NxlRhf+D54gCL0Pj1sIVdnydzOCXmibeyyk= Received: from SJ0PR03CA0294.namprd03.prod.outlook.com (2603:10b6:a03:39e::29) by IA4PR10MB8496.namprd10.prod.outlook.com (2603:10b6:208:561::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.223.9; Thu, 23 Jul 2026 11:03:02 +0000 Received: from SJ1PEPF000023D3.namprd21.prod.outlook.com (2603:10b6:a03:39e:cafe::1e) by SJ0PR03CA0294.outlook.office365.com (2603:10b6:a03:39e::29) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.245.10 via Frontend Transport; Thu, 23 Jul 2026 11:03:01 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 198.47.21.195) smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ti.com; Received-SPF: Pass (protection.outlook.com: domain of ti.com designates 198.47.21.195 as permitted sender) receiver=protection.outlook.com; client-ip=198.47.21.195; helo=flwvzet201.ext.ti.com; pr=C Received: from flwvzet201.ext.ti.com (198.47.21.195) by SJ1PEPF000023D3.mail.protection.outlook.com (10.167.244.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.270.0 via Frontend Transport; Thu, 23 Jul 2026 11:03:00 +0000 Received: from DFLE204.ent.ti.com (10.64.6.62) by flwvzet201.ext.ti.com (10.248.192.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Thu, 23 Jul 2026 06:02:58 -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.37; Thu, 23 Jul 2026 06:02:58 -0500 Received: from lelvem-mr05.itg.ti.com (10.180.75.9) by DFLE203.ent.ti.com (10.64.6.61) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Thu, 23 Jul 2026 06:02:58 -0500 Received: from santhoshkumark.dhcp.ti.com (santhoshkumark.dhcp.ti.com [10.24.52.55]) by lelvem-mr05.itg.ti.com (8.18.1/8.18.1) with ESMTP id 66NB2OW11577597; Thu, 23 Jul 2026 06:02:52 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , Subject: [PATCH v6 05/17] spi: spi-mem: add execute_tuning callback and spi_mem_execute_tuning() Date: Thu, 23 Jul 2026 16:32:07 +0530 Message-ID: <20260723110219.3180747-6-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260723110219.3180747-1-s-k6@ti.com> References: <20260723110219.3180747-1-s-k6@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF000023D3:EE_|IA4PR10MB8496:EE_ X-MS-Office365-Filtering-Correlation-Id: 98409caa-9a33-41f8-bd7e-08dee8a9f5fc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|23010399003|36860700016|1800799024|82310400026|22082099003|56012099006|10067099003|6133799003|921020|18002099003; X-Microsoft-Antispam-Message-Info: SkSOul31+Jh1YBkf36OADHCWrp1dAFcgHM31uNJSQhArJhOVNxtb8qd5Xd7Pzdm2uZx76Qk5mxNctvKZQF3xkn3zdrDAxRRWxeBtLcZrYRQT+bjHo5CF9o0EL8NtkTuurh/M+11v3IJ6lxa1pQ8sV6ik62Es5jJQrRrIoPp2mAGL5cOP9PoUI/k0pdKjc8wCbCqRbDUAphq60Em5ZqDoXZHC2EYWrpq2Xju/2uWkjDQf6sswxvHxvlMDQ4HRY0Ztzah6DSc+7jvm2zhCl5j4A41mpTyoYUTTjRftkAC+oXO3KCAYSKG/Czhz81z4N+ERditbQ+lLFGejXQYkwx5WyyYoQ9Cz+z44lNo164LrpFGx2/NDfCJ4fu8ESE9Nulfomnxe0IT+KnhjExGljUqeGR9OotFVxrhST3flwgj7AUkW3/A9P072KxtOk6lUQDvlu3UW62RF2Z0FpcGzot3WCcEWcwVjjC07Jw+FA0C4Fuys67yMIdmhNFDgO1BBywzUBzpCwCrbaWFc43QV9w80NErNf3JRivHnmvwCP61skMkwVJG3Ct9q4YEqB3OrbelnjEAfeDY1rIb6tvLZ/yNz3sQKnx+b6H8KrU5QaoQt8zvwel3LVtyPAq8tiBbF5G6Zbi5khy3NH3egReLmpK7PF0XA9caEb8NHTC8xknISbSqsbKc04fV4n/A0BHhMtlqozU4fj3qeMbZTjzyd6U0CNzXX79X7xJoudDRuaUGQtnQEdhGmw4nLkDeg+aIPAxYS 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)(36860700016)(1800799024)(82310400026)(22082099003)(56012099006)(10067099003)(6133799003)(921020)(18002099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: wo7n5hffNG0MQaGdQS3/2KHCnmUG6Zf7iRgOKHfRHNFgQ0+m2zzb4Y744VwrtzYhdjB9BbCNV9YC1PiD5xTY53Ty0DJCQMkGoWCH8d5/NRs/KAgGPFwgHIxed7lEcHmU+jyBAjCYfqWK+ggEaUhf3/1YmW6InDEWjjVqSsVH+d0XL0BBxfLKg4DJTQulZsHOfP+iUgQTUU3oxGJN1IQBgAnKyHnBDP0tdSF4nItHNcq0+2t0+Wnfr5MWApsnxSnLKosw+46VgOJCgSpaG5mT9webGEFkIM5eTfAF2Irgk4k0vWJnOLWjrxSMHlg+ZlFSLHFVy/T5fVE+6il7Yp/xsf12RwsF6xkG7QPnke/nj7v5b/aLaYX68GGVsHbqdz6t/WTsbFM/4gaKkjC1hrr2IcRbCP4HUPf2/MfRzXns+P2OzGwOMNbwgb2gojkWyfON X-Exchange-RoutingPolicyChecked: e/bTkQmYGSIYzPtoPBOlnL2X59XPtjF0dXbyjm/mrOJzW7NCLamA9gqWHxR0ovLziIoNhuakvw8uQNk+8pd+TCsALq6s+4VSmED6g6uUpc805nJBHIMEI6Yy9/xTqdQWefxWrQIxWU4DlekodjmQZ53hvv1jl3auMF6O0YJbKgxpIV2qTZ/eMljZ3u1SzMpZnwgqLUiQghMRY9HYJFdjracRaBS3/keovN0pA20Z84kuBDsxwJSwD4RdB7ssNbKXvOR+BLoCDdOy87QZ7sFexlU0zf4rOkHvqjK0OnFexXp00Z7PowgarZObY/v1v/JfVH8JZoNiuM9wzsFeZ2h+PA== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jul 2026 11:03:00.6004 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 98409caa-9a33-41f8-bd7e-08dee8a9f5fc 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: SJ1PEPF000023D3.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA4PR10MB8496 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzIzMDEwOCBTYWx0ZWRfX1QuU9xLp3F5c h6i3zAaPGn4ieRaKePeSHhWb020ArHfN7MgA6lA9yuaVdisCOsiQxQxOYZwYT771x6aquBOFc9r yYhUeh7PeE5kj2ptaIOookBDT2c58MXMMcp2yWfOOBqIHpqHWQtxamC0g6GKWmIGo3omfDfoy/n F+BnAlw7V2J01nahpFrg/9omr6W8NJ2BGqyEJr8+Zt6obGSP/RdYdYhyS8q/eK6vWvrEiL2wus/ vwhWt52F9O7H6EmjHDoyvSSl6qcwSJAU/U+s5MI3B3hX87zYfgs8w8N3IM6xrO1bS2kkLMtlQ2D o7sAqNPUHqw9MbjJ/c6+kXvm0GW9GquW2jtkT3KLiIlU4vdcQ0KJ9huHHEQKIBV0okIj2Y/7+XR 9onDmtnxwg3ZyBQ2XfILLunOxKLTiV7YrYDJH7BOI6iaBnJWda4zlcsEwhgiryl1JQRZyRa7Bpe 2pAuDmViBzj0vEC6jhQ== X-Proofpoint-ORIG-GUID: 3JutbkMTXzGFsUT3iJ9msOrcrXrZ8cul X-Authority-Analysis: v=2.4 cv=c/ibhx9l c=1 sm=1 tr=0 ts=6a61f4eb cx=c_pps a=nfJ3K52CLbhVQgIdADXVOg==:117 a=tJyPKKxUohctrY4NYmUjkA==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=RAioF0-LDSMA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=jwouBfj2j3NM8CExmVVE:22 a=P-IC7800AAAA:8 a=sozttTNsAAAA:8 a=XczTfz52Gg2yNcvB9tIA:9 a=d3PnA9EDa4IxuAV0gXij:22 X-Proofpoint-Spam-Info: AW1haW4tMjYwNzIzMDEwOCBTYWx0ZWRfX18Yve9Q+ppdQ oPCnwG5MOoCsst9li2DS98YT1g1oA+61zmuP+W1to3hUWPqjbU0uPALAcl63GSpwZmaA1iNEY0h fF8AQNml7fucjIFZt95GxfOKzngI7LM= X-Proofpoint-GUID: 3JutbkMTXzGFsUT3iJ9msOrcrXrZ8cul X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-23_03,2026-07-22_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 priorityscore=1501 bulkscore=0 malwarescore=0 impostorscore=0 clxscore=1015 lowpriorityscore=0 suspectscore=0 phishscore=0 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607230108 Content-Type: text/plain; charset="utf-8" Add an execute_tuning callback to struct spi_controller_mem_ops. The callback receives a mandatory read op template and an optional write op template. On success the controller sets op->max_freq in each provided template to the validated clock rate. Add the corresponding spi_mem_execute_tuning() wrapper that checks for callback availability and returns -EOPNOTSUPP when the controller has not implemented it, allowing callers to handle controllers that do not support tuning gracefully. Reviewed-by: Miquel Raynal Signed-off-by: Santhosh Kumar K --- drivers/spi/spi-mem.c | 31 +++++++++++++++++++++++++++++++ include/linux/spi/spi-mem.h | 14 ++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/drivers/spi/spi-mem.c b/drivers/spi/spi-mem.c index e20eca1b8245..ae9e2d7ac6f3 100644 --- a/drivers/spi/spi-mem.c +++ b/drivers/spi/spi-mem.c @@ -660,6 +660,37 @@ u64 spi_mem_calc_op_duration(struct spi_mem *mem, stru= ct spi_mem_op *op) } EXPORT_SYMBOL_GPL(spi_mem_calc_op_duration); =20 +/** + * spi_mem_execute_tuning() - Execute controller tuning procedure + * @mem: the SPI memory device + * @read_op: read operation template (mandatory) + * @write_op: write operation template (optional, may be NULL) + * + * Requests the controller to perform tuning for high-speed operation + * using the provided op templates. On success the controller callback + * sets @read_op->max_freq (and @write_op->max_freq when non-NULL) to + * the validated clock rate. + * + * Return: 0 on success, -EINVAL if @mem or @read_op is NULL, + * -EOPNOTSUPP if the controller doesn't support tuning, + * or a negative error code on failure. + */ +int spi_mem_execute_tuning(struct spi_mem *mem, struct spi_mem_op *read_op, + struct spi_mem_op *write_op) +{ + struct spi_controller *ctlr; + + if (!mem || !read_op) + return -EINVAL; + + ctlr =3D mem->spi->controller; + if (!ctlr->mem_ops || !ctlr->mem_ops->execute_tuning) + return -EOPNOTSUPP; + + return ctlr->mem_ops->execute_tuning(mem, read_op, write_op); +} +EXPORT_SYMBOL_GPL(spi_mem_execute_tuning); + static ssize_t spi_mem_no_dirmap_read(struct spi_mem_dirmap_desc *desc, u64 offs, size_t len, void *buf) { diff --git a/include/linux/spi/spi-mem.h b/include/linux/spi/spi-mem.h index f660bb2e9f85..ef5a6d60bae9 100644 --- a/include/linux/spi/spi-mem.h +++ b/include/linux/spi/spi-mem.h @@ -346,6 +346,15 @@ static inline void *spi_mem_get_drvdata(struct spi_mem= *mem) * @poll_status: poll memory device status until (status & mask) =3D=3D ma= tch or * when the timeout has expired. It fills the data buffer wi= th * the last status value. + * @execute_tuning: run the controller tuning procedure using the provided + * read and optional write op templates. On success, set + * @read_op->max_freq (and @write_op->max_freq when non-NULL) + * to the validated clock rate. Return a negative errno on + * error. Return -EOPNOTSUPP if the controller has no tuning + * capability at all. Return 0 with @read_op->max_freq left at + * zero to signal that this specific op cannot be PHY-tuned + * (e.g. a hardware erratum blocks it) but another variant may + * succeed; the caller will iterate remaining op variants. * * This interface should be implemented by SPI controllers providing an * high-level interface to execute SPI memory operation, which is usually = the @@ -376,6 +385,8 @@ struct spi_controller_mem_ops { unsigned long initial_delay_us, unsigned long polling_rate_us, unsigned long timeout_ms); + int (*execute_tuning)(struct spi_mem *mem, struct spi_mem_op *read_op, + struct spi_mem_op *write_op); }; =20 /** @@ -465,6 +476,9 @@ int spi_mem_adjust_op_size(struct spi_mem *mem, struct = spi_mem_op *op); void spi_mem_adjust_op_freq(struct spi_mem *mem, struct spi_mem_op *op); u64 spi_mem_calc_op_duration(struct spi_mem *mem, struct spi_mem_op *op); =20 +int spi_mem_execute_tuning(struct spi_mem *mem, struct spi_mem_op *read_op, + struct spi_mem_op *write_op); + bool spi_mem_supports_op(struct spi_mem *mem, const struct spi_mem_op *op); =20 --=20 2.34.1 From nobody Fri Jul 24 21:53:02 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 A0C3C459AC0; Thu, 23 Jul 2026 11:03:23 +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=1784804607; cv=fail; b=ufUkfYZtBqdQWaj8UTHi+XUDJrQIBnzokmsLJplp3d0/7APJKirmoCeaV3J9jmYgubJY5Istk0kGEw0dn30MNBA0rSgTe1tiV2NZ+YZb8J7+kqcsiocyLgy8uJQJ7TCq6aAW6jb6V2wG/URHG/FNv24e6AOcmRwVgAome3vhftY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784804607; c=relaxed/simple; bh=v6ww6XIH8TcUT23LUPoMxzFGFmhFMyzO6/EXwGCMXPU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=hXtxavVLMazXb8m4aYtWJZbU/5xDYJ9X9/RHEo2tlqu+b9L30CY75pLi8E/WHUPDLBOKdmJ5mxXmnBoSPDZwe34QK3nKfkOvLG+P2LWcWYcCEkoesez0h+en2xOitryUtcTc5ojavONnC9AEUvCQY1ONYSDyHXPQJCBRdTjLi3A= 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=KR5jED/H; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=XUPKDAGO; 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="KR5jED/H"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="XUPKDAGO" 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 66N9MCVN4110983; Thu, 23 Jul 2026 06:03: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=vRIdRiZggGVJbvsgQ0voaqOH53asB/hPokr2J9K8C Qk=; b=KR5jED/HWWn5odMVjOBhqF74vtIFdPFl/d9InkUzmuWa5t6/+TUMlawUx 0jOC2h0ka91d9G2wQ2ZvowlgGvhvBuksG1IT7FPU+HtnDP6MPfhfu/uJkqK8PGqi gI8diVMvIJyuNcxxJUDyUxjs9HyaV+JG8Uunv0I3op0ubpzr0+obqyoFNcoQExMk vNJtmzfKgpQc7K02ycPTk9D5dQ2oXlBijRkUi2MvwOq2UWlLB79SbNO/2K4do7Ug Bm26m84SEakeKTbllSOeA+zFTQU7YZPG+8hzHPOE427vzDX+fL2kEYSA0oQiCwWN O3l7SLY0TSqJUuKHoqTVklwzvXhhQ== Received: from ch1pr05cu001.outbound.protection.outlook.com (mail-northcentralusazon11010024.outbound.protection.outlook.com [52.101.193.24]) by m0384305.ppops.net (PPS) with ESMTPS id 4fkg908cu8-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 23 Jul 2026 06:03:10 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=D4X91dFGIe6JpyjfRH9jBVFtqARFrL0lav5HuKwLgKj+4mLxnhIksRyoalfRnaDeiSnaGhQ22kmPuvtp7lFztnuWcwpMCoaRa/d1WSzMEVvrMIlys1+tkz2Y85yu4dFjidXe35qTMICfZ6V1iZoEfvXOA6Oom6W/rmIzepoPjVuIoSSEir072eQltMVQSEtdhZnaiUiSWzYLrm6vue5X1hFAv92egip7yx2ixOpuMyjbOEkf7CUguv2FlUKEeGCX1GZ0KsF99i56zjf9VfknMT9g8hXxwRN0q7KsNrCLY2h5ExsEMVbgnRVTqWs27KyYDr+QSieD9uFKwUKxgcQNUA== 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=vF0ACWZiXx5azuBBw4q2ffMYPHKn7KQ3A+u/5gUe8L0AVF/o03fqNeXebYID/A7YMcEUsAugHU5GkuAUKl9ufu90pGMVMhA2F+oLyoEtgtIyaRhHNvzM2ecGDPssMMPt/Mz5fVRyMg9nSmpMgty+EClJd8aLwa4cfrOdD3DPICREp12xQleRMlmCWUtgVpNp92MoLeqzFhpUW976nZnkuWmOh3yJMNI4IL6p5N9RDCuO82+HmbEc/qLGfmRBEoBXsB59dDTbWwX6nycmCPlLJB4Xh7/m6RkUhBmqf6jRGUBR8pROuaKqWB59r0JkAnC6ZphLq8QLwwICFO8XZp5fkQ== 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=vRIdRiZggGVJbvsgQ0voaqOH53asB/hPokr2J9K8CQk=; b=XUPKDAGOV/qL6rIlu7S/2k/bVlrbBoZeknHMlv5JCVFu8p6+4APD2nuiGJTL+cE3O/K5JKii3YWa3+ZT3Tn5WoKJFVk8ZeoFF2Hwrp6zmsZzNzC82t0NnK5eXtosXNyMpnR/jUujA2/yrgVg+fwtJjm+AtdfoA6zvQrgW9k5/3g= Received: from MW4P223CA0003.NAMP223.PROD.OUTLOOK.COM (2603:10b6:303:80::8) by BN0PR10MB4934.namprd10.prod.outlook.com (2603:10b6:408:120::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.245.10; Thu, 23 Jul 2026 11:03:04 +0000 Received: from MWH0EPF000C6190.namprd02.prod.outlook.com (2603:10b6:303:80:cafe::19) by MW4P223CA0003.outlook.office365.com (2603:10b6:303:80::8) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.245.11 via Frontend Transport; Thu, 23 Jul 2026 11:03:04 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 198.47.23.195) smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ti.com; Received-SPF: Pass (protection.outlook.com: domain of ti.com designates 198.47.23.195 as permitted sender) receiver=protection.outlook.com; client-ip=198.47.23.195; helo=lewvzet201.ext.ti.com; pr=C Received: from lewvzet201.ext.ti.com (198.47.23.195) by MWH0EPF000C6190.mail.protection.outlook.com (10.167.249.101) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.270.5 via Frontend Transport; Thu, 23 Jul 2026 11:03:04 +0000 Received: from DLEE214.ent.ti.com (157.170.170.117) by lewvzet201.ext.ti.com (10.4.14.104) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Thu, 23 Jul 2026 06:03:03 -0500 Received: from DLEE215.ent.ti.com (157.170.170.118) by DLEE214.ent.ti.com (157.170.170.117) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Thu, 23 Jul 2026 06:03:03 -0500 Received: from lelvem-mr05.itg.ti.com (10.180.75.9) by DLEE215.ent.ti.com (157.170.170.118) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Thu, 23 Jul 2026 06:03:03 -0500 Received: from santhoshkumark.dhcp.ti.com (santhoshkumark.dhcp.ti.com [10.24.52.55]) by lelvem-mr05.itg.ti.com (8.18.1/8.18.1) with ESMTP id 66NB2OW21577597; Thu, 23 Jul 2026 06:02:58 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , Subject: [PATCH v6 06/17] spi: cadence-quadspi: move cqspi_readdata_capture earlier Date: Thu, 23 Jul 2026 16:32:08 +0530 Message-ID: <20260723110219.3180747-7-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260723110219.3180747-1-s-k6@ti.com> References: <20260723110219.3180747-1-s-k6@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000C6190:EE_|BN0PR10MB4934:EE_ X-MS-Office365-Filtering-Correlation-Id: dc5151e9-c01a-49f9-dc72-08dee8a9f815 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|23010399003|82310400026|36860700016|376014|7416014|1800799024|10067099003|56012099006|921020|22082099003|18002099003; X-Microsoft-Antispam-Message-Info: DMxxMmgy1ofgVr3w9o82vZYz71w/C29vigBZOUmGdo7tIAECox+zTuUh6tiEgV7KEYpe5LgJjrVnihVHdql6XSo2AF/02vMXu+cB8YHSCcO5sHV72p04pbtiG3CwmxK0SN+a+MpkaqzbkJWVvEERPwFtKTdl+8vPuBnhYWtwxy74kDeFeXMzi4qIdjNUkCHNksMfLExcpUXxaV8MYEUo/ccmNuZPordekjj0RBvneXVWVwTS9XIMg3fc6kPY7d5WN6pvYIIw4n69dsvTMCYcV5xQ+wxtdxnifFTYvaRUHw2cR8rQ0FJ2acokRt+NLtX+ylzFGtH62KOJHrqb6XQPgBTszwiOkW32zO44aCeGTQA42AfPxe9z72Q3QiShTzRLCqiWisl9dNbqDY9qZUW9yGBAkKj2TuE0dSNftrw3OpL3FDkiWKvOM2w4q9aRkIoB40wGVCyh6rTVm3EfzumAN8jA6XitmkikXlzTIxIQwQPBlV7lqnl34x8Uuu+T0UydbUihSg0KIDt4eBZ0EI1t82irjZ+VLem75Gri2VZgdgcnItbcKW4N6t78Q4CqtFWjs6I6wqIM4Q44eRvjbb/jS8I42n5h3DJQop1TENLhVKt3ku+ELUllFiGA/g1incbCPVmlnWgswZpnnr0Lu9CCIDZD4OEyvINeo/v3XLo1uzeTAHpcXHBrQN7k/oiMQORmDCxiN+guEpE3bWaM+YVqnBfQP52TGEGe4wOQhRNJAyuodpxOrdLiOXNDU2SrKl0p 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)(82310400026)(36860700016)(376014)(7416014)(1800799024)(10067099003)(56012099006)(921020)(22082099003)(18002099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: OwgQiodx7LNxvlSSSvEXXVmMEGPMamEVe0GyDq0/i0UpwyVeua+HyTUzps6wXBKK1WA525QdSB1SM+QivMO2jD75Ds/vqFsiAyNYuTW8Mdke7E/DzuY7WGBU55/TISvUTUaImD2+KEJuU+T7GRkZ7Ll0NsWIvvedLgA685fclpNgvScvBTTzuDbXEfsZC+LOr87gBvWtM6eBIN7nn7Ssk4EoQg1u/9JSl7KFtvTPzXJf2A5Vw5vRrlOLOduVKW0nmioq3y5BeRa4vHkgoLhO93P/ZIJ2iV3Y3DVMVlfLuuJiCg8jgUPnpsnYIZkA4KdqJ5qoK7w2aLaF1vkwse393EF/pV6ALRfT9eJXYULqqMGKeonMBsDknj5YQ1aMadaITZQAHlEB49O++j3Y6d+biGbzPaAUNADGtrVmGv6nqTDuVBQx5NXLAHFqULgVzJlo X-Exchange-RoutingPolicyChecked: WaLmqN/fwkxYrchyKiVXGP4Gy1+naWuOLYhOyukoCwupbVlPEN+pthIhMbdlM1D3W5BkYVG4d/axqPpvVNPm7vep3BtYUIVsVlyfcLq2p+UEL0mEgL6jhMzmhO2uioP5H2zboBNhJKhtKkoR/3G3vJE0IudAz5Amwb4wdPmTAG36MEDV4FX7+nscI9wncssR3JCrnU1vUU0IWJWFpQFKw4D7bdz6exyWTjWHtuXi+9Joe/jA1sHONnZKBmgAMxfK8SXxXmcoSZ7j/iclrrnK2v3DxD6nnsG6JeQHDxSAjAFKweNhhv7gG48raG9dsnWXR/A8UX7vKwVNgvzYDAgPXQ== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jul 2026 11:03:04.1760 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dc5151e9-c01a-49f9-dc72-08dee8a9f815 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: MWH0EPF000C6190.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN0PR10MB4934 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzIzMDEwOCBTYWx0ZWRfXwhU/6dx849KT c6P5lsYUkiDtEuqs9WDH2TFfIXobXqRtsKwHT8myWMONRr3GxL/CYm9SZ3cj69gLFxPEU4JFpxP Lwcb1+MtDQmoldVOLYmM/TqjazaatQFHJUiGx4THp6224hrr4XKUVEWCCPzO3CVlM9mp+rjUwpn ILpkXBcYKC1syywDs3on6ZPrfj+TvZyUFgAX3mk0frZurpfoDEMWPW7NWdYRdIG9nBA7OTpc0CV Qs4GpORMsxjyT+Q5CzZ6UXYDobUPpygGytSGDjG12N2l0vwzXJgzlr4p2ufDYUXtmsxSBIBt2+b M+cTASdi1sNFilSxp9JJnG2IBBkrx6AAgl+2YJfhs0sSYkP8oFOyh5gGM4tBMdmZyiy1/SD2i2D iNUFIKkxyQ0oleAAMkeOiqpn/9gvUi/5vS6DL7Rr8wCDqLs3CEtyLZK2pI49Buvq1iZkC83FTUy ouFVuaTWK8ou07aoFcg== X-Proofpoint-ORIG-GUID: CBfeBlyrOMm4qt_xXyIUX6LbJuyWB5Ai X-Authority-Analysis: v=2.4 cv=EeT4hvmC c=1 sm=1 tr=0 ts=6a61f4ee cx=c_pps a=T1Ebi/dL4O4Qy7Yf5tf31Q==:117 a=f+v6EHfkeJbVwR46tk4DMg==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=RAioF0-LDSMA:10 a=s63m1ICgrNkA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=taLDd7a_hP9WKsMzeGRc:22 a=P-IC7800AAAA:8 a=sozttTNsAAAA:8 a=2vpyfyhlguDYHLkT4YcA:9 a=d3PnA9EDa4IxuAV0gXij:22 X-Proofpoint-Spam-Info: AW1haW4tMjYwNzIzMDEwOCBTYWx0ZWRfXx+OqXGM0rpj/ r1BMjklEtl16eY7fE/BCP1fbkuQtpPj9VBnXSOHT1873GQglD6GjJpkFcKpqnGD8Cz/OFccIumu fZeNEU0V9Dp+B64TZ9pro9sI/xNcKR4= X-Proofpoint-GUID: CBfeBlyrOMm4qt_xXyIUX6LbJuyWB5Ai X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-23_03,2026-07-22_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 bulkscore=0 suspectscore=0 impostorscore=0 priorityscore=1501 adultscore=0 lowpriorityscore=0 malwarescore=0 phishscore=0 clxscore=1015 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607230108 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 Fri Jul 24 21:53:02 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 E988545A2A8; Thu, 23 Jul 2026 11:03:36 +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=1784804620; cv=fail; b=NFzJ/VE06xT6nI68NFjOEneUzC6h78OBKhT14/X0U2gbwGDexwJJCNeQ/ss/TGCzqbw9YkCf/sSSOxm8GoJlT4al1jewe1KmlQGdVPmUIsQcpnHmcgBoM6SkZ86AvT8ziydz9LbRgv5p4cQ6+TRBRRObE1Uuf60BI7iE8Gw7pck= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784804620; c=relaxed/simple; bh=nHERynUITfg5e3Nh2yAHKyBReZZf4m9KBYLOhEczroA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Qic2wvVhCqmC1ZFQJzdoy3aMd2mADKwPUohdfNO3XUBCN5gWV+1KQyVETjafdBG00pN71qLL2eKvfxNRLjgwrnbtkqs3giYQjqH/FORVCcQ4tMp+UwU6v/TYCRFTSpqmNltqTnsv2U5KRgLKHkrUWg0b1Hvc5aNxU646PKQxrIM= 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=l0ds0fkA; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=EcS2uiD2; 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="l0ds0fkA"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="EcS2uiD2" 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 66N8t4Rg1974626; Thu, 23 Jul 2026 06:03:26 -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=l0ds0fkA687U/2p2+Sy3YcjyWBwlBcB3gVSe5/093oaZaoqGIBOLk7FDn pUr2GGyJYKhkSokHKjqF+xB4ygN2kQL3UaaU8qE0C6LwQHmtPdIQ+Zd61Zegbr3W Ll/MntVu22shU4c46byo5qSSJYHohrzpl+JaQr/DLwJH7w2DULr03AqP3fJ7Pkui 3oDne/ec5bFVHikbtqKyViTdoob0K9RwwL/qxMojki2DK33esvhvdhNQkhCLfhR2 G58e4zFqaw04O1i08GDHaCLurFI6n4EF3ldICpWCEqRTmKOanGpxOf1RCs6SxGkn R4DbdpDZOCz6oZqBnDIxHf4X2hZzg== Received: from dm5pr21cu001.outbound.protection.outlook.com (mail-centralusazon11011065.outbound.protection.outlook.com [52.101.62.65]) by mx0b-0002e601.pphosted.com (PPS) with ESMTPS id 4fjwjbxtdy-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 23 Jul 2026 06:03:25 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Sqbn4FSgGvebs54fpTdFd2m86xmQX1O0BhDYhTAnC4C9xVHhrg3/gP6IrfQPJnLKcO+G1moP6jW2N3FeesN18Fc11Xb6PvKNaaDAHke7vY6Qjd6wrWfJ2gDY1aKFs2UmoyoxxTzg12STEkDKnLddxuvCV/HHvMYPuGVho3aNK7v6MGWnnfuSMxx/jwWZR6jcV1PmfAQN9cRknJ1fzydJ2pjeYikRI5cwZYTLCrQKIaNxMBqZ+EEHx4/kj3fC3VtupeVOLHy+hhKynJ7NeY/hf7dEnQtf1F8x96D0ga7Ad5L0Y3cbCSOn3Cpd/0LQtixILpu9OHwMb0yMGE0ZhY7rWA== 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=WgPUa/oFWq65EzdQXAmAQcy7sHZac1sLdAMrjGQQBFGolm5aXhgZ5j6wS5zL9OR0ym4ehiZKRAhR8wG0XdzilIawJFyLcbN9nPAz7DZGmP8oEfkqMWbqdMmximPX3vA13ngiz8N3cRae6IgLREpDmCVIjkb58y4KF3gVx1jfeqHFrcrVVblktSKJnDBdVFKgZDIRexWyM4eX1Ks1qP/QC0CY9No114ews2tU7qjH+InPv3v2LoBirp3LTdS87hPhD7CwgjDZKu6xxhY+QB+d+RsHzfniDWySGLIeS/IdvHW94m0Qm7ZP/+DaVA1fV/5IkHweGEETquR+53TLpPvcBg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 198.47.21.195) smtp.rcpttodomain=lists.infradead.org smtp.mailfrom=ti.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=UDgIqenZB3DR5a29o3tuvANtwgRl7SpThCxLM+b+1nQ=; b=EcS2uiD2v7wz9OfZP1Y+H42lwh9DjBFiXPEoJiSESK/54bXB04pxMVTmuYFEFWdCOBAEPQusQm1luJowR/1ZHiEyGPgU6mLPnAaHTcJWYYFdJzU8AHO5KnwgnoZeNVj1NFwexuJx18JTzHrEZCt0WLWLdygsAdp4Wi6alJ7jIOc= Received: from SJ0PR03CA0291.namprd03.prod.outlook.com (2603:10b6:a03:39e::26) by LVUPR10MB997834.namprd10.prod.outlook.com (2603:10b6:408:3a2::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.245.10; Thu, 23 Jul 2026 11:03:19 +0000 Received: from SJ1PEPF000023D3.namprd21.prod.outlook.com (2603:10b6:a03:39e:cafe::ab) by SJ0PR03CA0291.outlook.office365.com (2603:10b6:a03:39e::26) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.245.11 via Frontend Transport; Thu, 23 Jul 2026 11:03:19 +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 SJ1PEPF000023D3.mail.protection.outlook.com (10.167.244.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.270.0 via Frontend Transport; Thu, 23 Jul 2026 11:03:17 +0000 Received: from DFLE211.ent.ti.com (10.64.6.69) by flwvzet201.ext.ti.com (10.248.192.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Thu, 23 Jul 2026 06:03:09 -0500 Received: from DFLE212.ent.ti.com (10.64.6.70) by DFLE211.ent.ti.com (10.64.6.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Thu, 23 Jul 2026 06:03:09 -0500 Received: from lelvem-mr05.itg.ti.com (10.180.75.9) by DFLE212.ent.ti.com (10.64.6.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Thu, 23 Jul 2026 06:03:09 -0500 Received: from santhoshkumark.dhcp.ti.com (santhoshkumark.dhcp.ti.com [10.24.52.55]) by lelvem-mr05.itg.ti.com (8.18.1/8.18.1) with ESMTP id 66NB2OW31577597; Thu, 23 Jul 2026 06:03:04 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , Subject: [PATCH v6 07/17] spi: cadence-quadspi: add DQS support to read data capture Date: Thu, 23 Jul 2026 16:32:09 +0530 Message-ID: <20260723110219.3180747-8-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260723110219.3180747-1-s-k6@ti.com> References: <20260723110219.3180747-1-s-k6@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF000023D3:EE_|LVUPR10MB997834:EE_ X-MS-Office365-Filtering-Correlation-Id: d0208192-26db-4fdb-c434-08dee8aa002a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700016|7416014|82310400026|23010399003|376014|22082099003|18002099003|10067099003|56012099006|921020; X-Microsoft-Antispam-Message-Info: Cv7ZAQtvOlP2ZtUff0wnQf3YU6Usq3UwG2/t4RiJZIYMUWg0QAbAnleMeKdQSkkgATymLD1SHVQyCx28rPiVQO9CgVTyRtCSOEsk+1iNBFTiUk5qiGrq7Qb9Nsfq5UVOgZG9cyeuZo5Q7uNxyv3KlNI9nKPeYcpf2sCKGjBGmcJtfHPAkSigTRrqjR2J69B+rEfLh2JYI7M7C5kw2NCLRscgt+cjW3u2uKoCgLr/rP4JG0tyxm0tRu67CHc6BmHywKZygwShDuH/N5eYeidMyet7Z597LwvCsMA1kt0ZaeMl6hWbr8DFx3aAnT8bwXxkXj8VxkUrlEQ/1ggFQto2D08sm8eVx7jTEB7e9NwzyjCjSFXVygbkedwh/ZnC9L9jepbN56nldaJostjr7skkNeS0QojCUU1ySl9fmb8eA7fk8MOBK+sNiIYlF9sDZR50oChENxnWAdpzexUbsgP/6ovAkOKmRET1jHI1aExZKb3p6YvaSXEjaLUW+fSV6CQh5RhowBXWZaruWOrmV8QCDiBhzSJFWjr1nuDQVtNXJ3l8rFrt/YozI4UqttEumOVaoEUpF/E8YlOGGXbogqCHp5XdkQfr+7cXegEmyT3Ix4J3jjG2I9olVndjn2fzJnpfHZCIbJevpH/8XGMW9Rxi+giaafk5TUFdzkuA7HMpgLcfJL3AroEljqUjWYmN4IuGX4O08OmQ3kEkC+g65kshpZubhsXVlNoApED7zKVqwl7MsYmWsmIKVEGAqrYOygoa X-Forefront-Antispam-Report: CIP:198.47.21.195;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:flwvzet201.ext.ti.com;PTR:ErrorRetry;CAT:NONE;SFS:(13230040)(1800799024)(36860700016)(7416014)(82310400026)(23010399003)(376014)(22082099003)(18002099003)(10067099003)(56012099006)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: KYRUovfIXF6Ppe1MdljVkVMm/U5jbfqizfOCCoTn3gX9SgE84kpX/PimrmtwWAwcWWk/P5G/PfwB6TpeRNZX6BDlVcK+l+qYBrEyf/thAKPdIrZS5hS1AMgxbB2PAF390OMGsLaITX+EPcxozs9OqSUBq7Mcx9gMYhCVuI/J1g2MJtwSci0JfEQglL5MlRMpm4G3T/ZKDowktCnihBRj2mpbPiyDuZCSi3QEnvlvJDS/V1bEa5UWXJ7MHTMztdWY75pzK0dCZDADHUCi3LmiLzgaSUjFqHszix4YxvymjORvsjLt6Bw1RouyWPJw9X1F6VeDTBpPRtsg5l2Nqv5Ku9B3Z4+WBGGq47gxaPO7mKK+f1ef7lb8l0WFcJYpyIsbeUm7RzzjE3JZ7zndgFtZPPT3BqGNRExi2L9TLKd4UD4oj4gJzSzYN+LjUsmkuNI2 X-Exchange-RoutingPolicyChecked: QRE2jMYMdxL3yNiZWYqLjxFpCJjakPKcPLJi043bKcbMyRC82bePsHlFd33zpnk44ZdRy4mRu7hH4o3nftyVnhWtWM/E3BhQj9cFAG3mVntZOnVSR7FITrIqyHGWzuRNYEqVKfiActaPdP5NePvhJ1yoI0XIoyWbnJMOBNMVQOv64BnVeJi3JZ6rmo1y3IKkYbOGLKUZdIvaediedZION9XpEkFlNRSxsZBNsDCi7DDo1PCBa6gQQrSrirCHhhIjUArwrc6yfcGE8IQiq0i2OqnlNfZyvfwpdZgFYnBaHbGnJDS3a60YgvufbiC/z1PgGraxHcF/xGUB1UObJ201Rg== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jul 2026 11:03:17.6785 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d0208192-26db-4fdb-c434-08dee8aa002a 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: SJ1PEPF000023D3.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LVUPR10MB997834 X-Proofpoint-ORIG-GUID: NVPHXPnJ-m9BXuMLo-DOCjzgdNx0zvS_ X-Authority-Analysis: v=2.4 cv=LPRWhpW9 c=1 sm=1 tr=0 ts=6a61f4fd cx=c_pps a=BToDjy1G2hQwEUS1Uhc31g==:117 a=tJyPKKxUohctrY4NYmUjkA==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=RAioF0-LDSMA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=fPAWb5peG099m5CrUpKH:22 a=P-IC7800AAAA:8 a=sozttTNsAAAA:8 a=by1YfaDFVIW1-MDklf4A:9 a=d3PnA9EDa4IxuAV0gXij:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzIzMDEwOCBTYWx0ZWRfXwvO1Yj8o1YhJ iQTK51q+ClbWlZaQiDigeU6lp9OB6jimMr6V9cvdeexqH7V53CHDUSrsaawygArDeUukA1KVjT8 IFeBIS97oP5kkLRISRrGV+UW4R8rmLNr2Tuag3+zVZZoLZCc6zxCQCZ2uqeaZncWW5SS2UlzSRZ SEa+h0HuK1YSeI5p0rz3RAbxtikuV4UofAxKS6LvSItInmz0guVjBvPBjFPnw9XJeQ4zu3YVxNV l68da5uJJEzDV5C6nZyvgBAbq48iL2jHovsXM7nmtPv2Ual74GuNBA3lx6OsDko4XhRnnkV9ykQ nj78ABcAxXCwdxFLdhAPSUkq9Tkbjd5QhjA/DCGrEkVleXh26LOMrQNT29mXUO70fh8Y2FoRtyj 3MwvLeXKuIs7nf5bzh4XfzwJo4Vkmkrbv/RJTaFYxBmicWR3Nknk79dirIWA05gmColx7UWM5Tm Gjs2cipRK6JJZSUa90w== X-Proofpoint-GUID: NVPHXPnJ-m9BXuMLo-DOCjzgdNx0zvS_ X-Proofpoint-Spam-Info: AW1haW4tMjYwNzIzMDEwOCBTYWx0ZWRfX/vuGwT61jkmK H4NLzVsLeTet0pQT6WkMSbnBUk//ilWUYsc6EUmmM2MzBtlJXFivrMke+gc23BbWQn9gRVM7hBC lQonN5ceZi8QNj7tWfE2SZH8TcgbZlo= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-23_03,2026-07-22_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 clxscore=1015 lowpriorityscore=0 phishscore=0 priorityscore=1501 impostorscore=0 adultscore=0 suspectscore=0 spamscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607230108 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 Fri Jul 24 21:53:02 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 2B137459AF0; Thu, 23 Jul 2026 11:03: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=1784804628; cv=fail; b=tXbTtUg1Dcxxb4zDnEwRihRAsuCzOcO8r6ghN3HcBwY5a+agXfPpl5drvh7Ebev+FDLJdRaW6GP8q7+tURDnNchjtsUyHjld7Pvlz41jD0DTdi7TAytc0UaDYlbstNlPOAPKsGDu9vOA68VyngoT0njN4e6vyvdmKc/oTdcvvcU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784804628; c=relaxed/simple; bh=Ws9G5suFGgWgDg6znQfNl9iU/PI5yTaPNUjDgEJ2oLk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=S/Vx3f0WWw7a7RgJeIBSd1iW7v6KCalX45u2HF7NfyhEFb7V0VxEiw784uU84gFbgmk+O+Zf6Y0ayWTbPlbIRxlWeOvAkObkuHIUhLErc5ULhSgJJyDrPp/XKEvmIg3YWFlidu9nbW4Oavmst5eo1tFR+7zDoIolONYBc/C3g6E= 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=Uki7A48e; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=Qd5JRE5f; 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="Uki7A48e"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="Qd5JRE5f" 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 66N9MG9D4111037; Thu, 23 Jul 2026 06:03:26 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint-05-2026; bh=jeApygkbCNgx3AJPUNBZRL5kbfuJAq8jwzrWjyGIm dI=; b=Uki7A48e297DiXYJr7o1oZFHz+6ThKK1LqNtIXGE2i3DzqFvifJzArJjr 9TAZ3JnanmJqS1bUxbCW7y7VOyLo7EHrFzOoGCdOEnqJIon8OYAHe7EnuH9gRG5U l4PG+XoI1KZdQ/sXX/wmxLUu1YPgfuxFgCqZ2sMhZvHMxdM1f+nqkxYKnHtUaPac 9ABfbsZDtBJOD+Hk1BlIWW5huTtTyXdIB4s1bnUO2VT6yYT0mV95ZiGK56Y2B4Z7 zo1GogpPVLXe6NDaZ2xXZw4TP7Vc86PmrM2vHEw7CiMmi7m49wHH02vLJuZ6vWoE 36HzAArBDRdZNq4cWx9jVkflBsNRQ== Received: from ch5pr02cu005.outbound.protection.outlook.com (mail-northcentralusazon11012007.outbound.protection.outlook.com [40.107.200.7]) by m0384305.ppops.net (PPS) with ESMTPS id 4fkg908cvc-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 23 Jul 2026 06:03:25 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=oRZ5t8itdkgznaeFbZUegiB/AJ9qeMNtHi5f4q/v4w9xu4METVwejqL4AZfDj1dvZ5F9ehWuBmzZgOhEtTW/TWbRsE2z2U+mWjUd4CV50kw/22KLwf+lIl/7NeZFdJoe93I+/7+Mhb8Th7OO0b75rO3uHf7V+Sz/K7NtwTLPi/av/0R5w+qbIAB9FzDvzBlHxNQjG1hLoIXzBUh7fM20cgToMP2uGWZCQd0eUz2LYlq/dcaZhDtZBn2gXn4VoFMT+Lo9GuIbvhKpJloJ7F6fVeq6z403ObwQUotP4gRLVzGiMfwGu7isEMYaciEzC1rnpiVOgNPY2KfOcbgACp1Nag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=jeApygkbCNgx3AJPUNBZRL5kbfuJAq8jwzrWjyGImdI=; b=dLtafm3x4BYGeJI0v3XeKieyDTo/hAXEDjhuQ5gEbv8v7el7ttB2/tc5PuNeW1WqhU7CdQvRfvku65VX5pFf5jQKKjXn6ojoiDOapJRyJvtTTZOsuJhsjmjDSRaRJRO2//9kVi9iYB3U5S6Nvng8WGQSy+8EBDQ6OpLXLBPuNoGKSDXWlJtXnPZMFO0chXW7pMa/UkbIU2hl+wRSk92kpgwXvAs69DKvPa4knQMFCmpTHaKbA9pHInJu69/UpPGMRBJq9L/JA97crUSjVBD+bKzRV1C+kPYIV/VEukjDmCtzlYY+oZb5NHVpRakBUf0fXUqmPbQsO/F2tGIylfNQFQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 198.47.21.194) smtp.rcpttodomain=lists.infradead.org smtp.mailfrom=ti.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jeApygkbCNgx3AJPUNBZRL5kbfuJAq8jwzrWjyGImdI=; b=Qd5JRE5fD58ACT7BUJgTOFs/nw3/X9AN0A7n/YPCXxK8Y3zThKLOC8u0jimM3DkQV8JpKFiz6UG5I5bMt8gSFA2RAUFb/BTI8KTpMe6m1C44O/yC4U7JT4tjHFfalJFCVI8TrcbsmRaBlhreZgTweZ+xPDaBVWCHp6w9W87ZnKY= Received: from DS1P222CA0019.NAMP222.PROD.OUTLOOK.COM (2603:10b6:8:44b::7) by BN0PR10MB5079.namprd10.prod.outlook.com (2603:10b6:408:128::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.245.10; Thu, 23 Jul 2026 11:03:17 +0000 Received: from SA2PEPF000015CD.namprd03.prod.outlook.com (2603:10b6:8:44b:cafe::7f) by DS1P222CA0019.outlook.office365.com (2603:10b6:8:44b::7) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.245.11 via Frontend Transport; Thu, 23 Jul 2026 11:03:17 +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 SA2PEPF000015CD.mail.protection.outlook.com (10.167.241.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.270.5 via Frontend Transport; Thu, 23 Jul 2026 11:03:15 +0000 Received: from DFLE212.ent.ti.com (10.64.6.70) by flwvzet200.ext.ti.com (10.248.192.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Thu, 23 Jul 2026 06:03:14 -0500 Received: from DFLE205.ent.ti.com (10.64.6.63) by DFLE212.ent.ti.com (10.64.6.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Thu, 23 Jul 2026 06:03:14 -0500 Received: from lelvem-mr05.itg.ti.com (10.180.75.9) by DFLE205.ent.ti.com (10.64.6.63) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Thu, 23 Jul 2026 06:03:14 -0500 Received: from santhoshkumark.dhcp.ti.com (santhoshkumark.dhcp.ti.com [10.24.52.55]) by lelvem-mr05.itg.ti.com (8.18.1/8.18.1) with ESMTP id 66NB2OW41577597; Thu, 23 Jul 2026 06:03:09 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , Subject: [PATCH v6 08/17] spi: cadence-quadspi: add PHY tuning support Date: Thu, 23 Jul 2026 16:32:10 +0530 Message-ID: <20260723110219.3180747-9-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260723110219.3180747-1-s-k6@ti.com> References: <20260723110219.3180747-1-s-k6@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF000015CD:EE_|BN0PR10MB5079:EE_ X-MS-Office365-Filtering-Correlation-Id: 5f54cca7-1d90-44e0-b02f-08dee8a9feaa X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|36860700016|82310400026|23010399003|7416014|921020|22082099003|18002099003|6133799003|3023799007|10067099003|56012099006; X-Microsoft-Antispam-Message-Info: 6DQ/AIu2SmTirGq4LbHV3mAn36Ks1vTcMMjh81yXh93MWbT+AjAnmPvBuU1m1kCypyl3Gmo3HOguYEhLtoPfKYZTpJzIL2KdE5tyhnLEIX04MmFZOjU6nXwbH54GWMabsH7sFgTletgxdK5oLWUPQ5vv3g7M8EIazwxIIYzYPSBf+y5j7Ry/WroAxTNz7M1MByXB2VBBOQD9ikrTReW+3H4mvmVT5ttvbM7BdjOgxDn80zHN9Ih7ATYA+ut8rGrFwm/aY8QuXp9k0TbGKFdV5XtiUYBPAe6Qxho0rdODXCAq9d5NIqvvf61WNxrXAD47stVTqfpluW5NJ4w54jgFbPXVmdufCdm6YDARZMeiW7RDZ8fb6ESMw+oqVmGtIvJHm5/LvkhscJ7jc10EdxIf+dNE6XhiuW8kNxjXNTXZSorzx0u/fe9NDRUDlhObKgj7GsUUZ2HjI8dJ/5zR8pbGwpJnw+aMSFwXK3Mz5RFuGjuEfzL9URdBofQjeb43tI/1KVomMW1ZvSL7WPiQKcAKXhzbptWA2dTuFPxoK2bWiFYb0siDKUolRLJkJEZzKmp7EVtqoVCdS749U8b2Db6LxEbA5t/NXdiSp1uvcKTS1cHFnnWkKAMXjjGgCq+YT1jooep/VPMxnE7wrfGjiQVTEEHD55gK3De1kPA65V1CJQriLlRw5eaWDzYMrtfBv7H9 X-Forefront-Antispam-Report: CIP:198.47.21.194;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:flwvzet200.ext.ti.com;PTR:ErrorRetry;CAT:NONE;SFS:(13230040)(1800799024)(376014)(36860700016)(82310400026)(23010399003)(7416014)(921020)(22082099003)(18002099003)(6133799003)(3023799007)(10067099003)(56012099006);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: DKU+dnTu48hqKNNK8lDxuc2w8KmnEFgE6Qg6bt1zPN9e9c9bZ2wcIjwcSQ2xIBzLA0M4cEDuxVkkf7dzOI0GU3FbMl5mC9Qw6+lHnpViwKJ4JOwFWJc+OTE5m+EAfTdXosnxZ8TOSutbfPJnIepvnC36g0BehflkWmc6bOu+iVQ9ONS9p8PALKlerFLkmyYClQoSgxXlEOhq91FN/E0VeAzEPpbT1op9oCROBXZk3i6THizJCNCkfWqkQr1Utre2Vo57EctrWqSwSPVtnsgycWlVwerMK4KaqInRBxghFnnfjCQrfmH6KjTn4C2+gJ0CjC0tj64BD2wLYQ7QrnJildDzmLriUP4Vhd8tjMvjnPKzrcDbOdf4NiyslhZg7LsKY4guUMlno+r7krOuaEbxQegzLQNyzXg2TA3aBa5m/PrkzOfRCO2lRPrBva3YasyM X-Exchange-RoutingPolicyChecked: d06IJweUuESCDIpNaMeO3MH+KVqI9g0lAtTmoEhRaBF+20inFQ5RQQU+p3kplIjaztVAF5a8xgOUP3EzfBwomWex9bolAec4Qc+Zp0jO5N+0lOE3CWl9PWv57qi4yVI0QR6xnw0AGPJ7DDwzUuoYMvHoS/YQSLc0CphxgoshlAEH/+APtKVQ8cKq5JBg6lfyl6B1RT9BcAcvkPOyqM8YUyvOEe7O8zSzbW1Z/fDur/EDztk/YwU0G2vitePyT1Ce2oqm3dU36p7nA+i7a6/bqHn561y36DzNg2Lgldp56r5JRwR0X40uFG9cHrh6ig5y1LNZ0Tofh8z2Evjm+NhOKg== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jul 2026 11:03:15.2171 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5f54cca7-1d90-44e0-b02f-08dee8a9feaa 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: SA2PEPF000015CD.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN0PR10MB5079 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzIzMDEwOCBTYWx0ZWRfX0WRsrzRMpgve bN5WYesI4rfiC4bytm54hNoE6ZR6TZUoXyARUNPFK4fMeSp4R0zjrLhCHoxc/j/Y+Dc/h+qBFqV FMZz1NQJteBayjE1SWEjAhT66X3K1nfMxh5h02j02W+XNLDadTaK7HGC8jmu40aiHEIMexKmdl4 GwtKAUb4TW8tlpjEh54beWbJec2NhiMCNam6tujmdxcyTf/GY0jTx8Zfoc4R/MAhok9trYc+ev2 Csug8b0PXWoMphXpL/JGdzj+MeEUPlO0qwq0ir2tFcQZHaIm1HhaklKi2tT+JnuALUcxIEUWlhe D2KZbsY3mMxj3l8CSzuM/GzYDgSaFyCwUA5aZYh4TSCQaewvkDAJecJho3kLcIMhzjdQesa+2bq Q3/X7YQ1zd7qXGAua1eBRv98iP8Qw9JvfwoNwsnaQcgAypOLadcR9pOgJi0o8iwmkvP67PIQB/9 u4cgT/7apZ3UVK7U5WA== X-Proofpoint-ORIG-GUID: 2jKJKCysO3-rP90XhUJcc2jPsW-Qy31E X-Authority-Analysis: v=2.4 cv=EeT4hvmC c=1 sm=1 tr=0 ts=6a61f4fd cx=c_pps a=xQfGHK7Kh/zEjKjNz0BexA==:117 a=iwqwCZQqcuTv3JOpYdM7/Q==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=IkcTkHD0fZMA:10 a=RAioF0-LDSMA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=taLDd7a_hP9WKsMzeGRc:22 a=sozttTNsAAAA:8 a=Uch-OgagLyHg9olWpLIA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 X-Proofpoint-Spam-Info: AW1haW4tMjYwNzIzMDEwOCBTYWx0ZWRfX+8f4cRfPNsLx SoPI8BgNkr174X03jxSpc971FHyX2pfvvOReyW4Bp7ly2r6Y1Eog/KGWzS0mBzQJo6rBYjoFMCG Ak6B/+J/AO3+uwF7/MgAFGiYveWaEWo= X-Proofpoint-GUID: 2jKJKCysO3-rP90XhUJcc2jPsW-Qy31E X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-23_03,2026-07-22_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 bulkscore=0 suspectscore=0 impostorscore=0 priorityscore=1501 adultscore=0 lowpriorityscore=0 malwarescore=0 phishscore=0 clxscore=1015 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607230108 The Cadence QSPI controller supports a delay-line PHY for high-speed operation. Without calibration the PHY is unused and read capture relies on a fixed delay, limiting throughput at frequencies above the base operating speed. Add an execute_tuning callback that performs delay-line calibration using a known data pattern written to a dedicated flash region. The pattern is either read from a NOR partition identified by the DT property spi-phy-pattern-partition, or written to the NAND page cache before each calibration read. For DDR protocols (8D-8D-8D) a 2D sweep of (rx_delay, tx_delay) pairs is performed to find the widest passing region in the combined RX/TX space. Binary search locates the gap boundary between passing regions when two separate windows exist; the final operating point is placed at the centre of the larger region with a small temperature-dependent offset. For SDR protocols a 1D sweep of the RX delay is sufficient. Two windows at adjacent read_delay values are measured; the wider one's midpoint is selected. The tuning infrastructure is platform-specific: only am654-based OSPI controllers populate the execute_tuning hook. All other platform data entries return -EOPNOTSUPP and are unaffected. The calibration target is sourced from spi->post_config_max_speed_hz, populated by the SPI core from the spi-max-post-config-frequency-hz DT property. Tuning is skipped when post_config_max_speed_hz is zero. Signed-off-by: Santhosh Kumar K --- drivers/spi/spi-cadence-quadspi.c | 1745 ++++++++++++++++++++++++++++- 1 file changed, 1734 insertions(+), 11 deletions(-) diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-qu= adspi.c index 046fa5d69b0f..22a5c88bbd8d 100644 --- a/drivers/spi/spi-cadence-quadspi.c +++ b/drivers/spi/spi-cadence-quadspi.c @@ -6,6 +6,7 @@ // Copyright Intel Corporation (C) 2019-2020. All rights reserved. // Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com =20 +#include #include #include #include @@ -65,15 +66,26 @@ enum { =20 struct cqspi_st; =20 +struct phy_setting { + u8 rx; + u8 tx; + u8 read_delay; +}; + struct cqspi_flash_pdata { - struct cqspi_st *cqspi; - u32 clk_rate; - u32 read_delay; - u32 tshsl_ns; - u32 tsd2d_ns; - u32 tchsh_ns; - u32 tslch_ns; - u8 cs; + struct cqspi_st *cqspi; + u32 read_delay; + u32 tshsl_ns; + u32 tsd2d_ns; + u32 tchsh_ns; + u32 tslch_ns; + bool use_dqs; + bool use_tuned_phy; + u8 cs; + struct phy_setting phy_setting; + struct spi_mem_op phy_read_op; + struct spi_mem_op phy_write_op; + u32 phy_pattern_partition_offset; }; =20 static const struct clk_bulk_data cqspi_clks[CLK_QSPI_NUM] =3D { @@ -129,12 +141,15 @@ struct cqspi_driver_platdata { int (*indirect_read_dma)(struct cqspi_flash_pdata *f_pdata, u_char *rxbuf, loff_t from_addr, size_t n_rx); u32 (*get_dma_status)(struct cqspi_st *cqspi); + int (*execute_tuning)(struct spi_mem *mem, struct spi_mem_op *read_op, + struct spi_mem_op *write_op); }; =20 /* Operation timeout value */ #define CQSPI_TIMEOUT_MS 500 #define CQSPI_READ_TIMEOUT_MS 10 #define CQSPI_BUSYWAIT_TIMEOUT_US 500 +#define CQSPI_DLL_TIMEOUT_US 300 =20 /* Runtime_pm autosuspend delay */ #define CQSPI_AUTOSUSPEND_TIMEOUT 2000 @@ -148,12 +163,14 @@ struct cqspi_driver_platdata { /* Register map */ #define CQSPI_REG_CONFIG 0x00 #define CQSPI_REG_CONFIG_ENABLE_MASK BIT(0) +#define CQSPI_REG_CONFIG_PHY_EN BIT(3) #define CQSPI_REG_CONFIG_ENB_DIR_ACC_CTRL BIT(7) #define CQSPI_REG_CONFIG_DECODE_MASK BIT(9) #define CQSPI_REG_CONFIG_CHIPSELECT_LSB 10 #define CQSPI_REG_CONFIG_DMA_MASK BIT(15) #define CQSPI_REG_CONFIG_BAUD_LSB 19 #define CQSPI_REG_CONFIG_DTR_PROTO BIT(24) +#define CQSPI_REG_CONFIG_PHY_PIPELINE BIT(25) #define CQSPI_REG_CONFIG_DUAL_OPCODE BIT(30) #define CQSPI_REG_CONFIG_IDLE_LSB 31 #define CQSPI_REG_CONFIG_CHIPSELECT_MASK 0xF @@ -192,6 +209,7 @@ struct cqspi_driver_platdata { #define CQSPI_REG_READCAPTURE_BYPASS_LSB 0 #define CQSPI_REG_READCAPTURE_DELAY_LSB 1 #define CQSPI_REG_READCAPTURE_DELAY_MASK 0xF +#define CQSPI_REG_READCAPTURE_EDGE_LSB 5 #define CQSPI_REG_READCAPTURE_DQS_LSB 8 =20 #define CQSPI_REG_SIZE 0x14 @@ -273,6 +291,27 @@ struct cqspi_driver_platdata { #define CQSPI_REG_POLLING_STATUS 0xB0 #define CQSPI_REG_POLLING_STATUS_DUMMY_LSB 16 =20 +#define CQSPI_REG_PHY_CONFIG 0xB4 +#define CQSPI_REG_PHY_CONFIG_RX_DEL_LSB 0 +#define CQSPI_REG_PHY_CONFIG_RX_DEL_MASK 0x7F +#define CQSPI_REG_PHY_CONFIG_TX_DEL_LSB 16 +#define CQSPI_REG_PHY_CONFIG_TX_DEL_MASK 0x7F +#define CQSPI_REG_PHY_CONFIG_DLL_RESET BIT(30) +#define CQSPI_REG_PHY_CONFIG_RESYNC BIT(31) + +#define CQSPI_REG_PHY_DLL_MASTER 0xB8 +#define CQSPI_REG_PHY_DLL_MASTER_INIT_DELAY_LSB 0 +#define CQSPI_REG_PHY_DLL_MASTER_INIT_DELAY_VAL 16 +#define CQSPI_REG_PHY_DLL_MASTER_DLY_ELMTS_LEN 0x7 +#define CQSPI_REG_PHY_DLL_MASTER_DLY_ELMTS_LSB 20 +#define CQSPI_REG_PHY_DLL_MASTER_DLY_ELMTS_3 0x2 +#define CQSPI_REG_PHY_DLL_MASTER_BYPASS BIT(23) +#define CQSPI_REG_PHY_DLL_MASTER_CYCLE BIT(24) + +#define CQSPI_REG_DLL_OBS_LOW 0xBC +#define CQSPI_REG_DLL_OBS_LOW_DLL_LOCK BIT(0) +#define CQSPI_REG_DLL_OBS_LOW_LOOPBACK_LOCK BIT(15) + #define CQSPI_REG_OP_EXT_LOWER 0xE0 #define CQSPI_REG_OP_EXT_READ_LSB 24 #define CQSPI_REG_OP_EXT_WRITE_LSB 16 @@ -321,6 +360,50 @@ struct cqspi_driver_platdata { =20 #define CQSPI_REG_VERSAL_DMA_VAL 0x602 =20 +#define CQSPI_PHY_INIT_RD 1 +#define CQSPI_PHY_MAX_RD 4 +#define CQSPI_PHY_MAX_DELAY 127 +#define CQSPI_PHY_DDR_SEARCH_STEP 4 +#define CQSPI_PHY_TX_LOOKUP_LOW_START 28 +#define CQSPI_PHY_TX_LOOKUP_LOW_END 48 +#define CQSPI_PHY_TX_LOOKUP_HIGH_START 60 +#define CQSPI_PHY_TX_LOOKUP_HIGH_END 96 +#define CQSPI_PHY_RX_LOW_SEARCH_START 0 +#define CQSPI_PHY_RX_LOW_SEARCH_END 40 +#define CQSPI_PHY_RX_HIGH_SEARCH_START 24 +#define CQSPI_PHY_RX_HIGH_SEARCH_END 127 +#define CQSPI_PHY_TX_LOW_SEARCH_START 0 +#define CQSPI_PHY_TX_LOW_SEARCH_END 64 +#define CQSPI_PHY_TX_HIGH_SEARCH_START 78 +#define CQSPI_PHY_TX_HIGH_SEARCH_END 127 +#define CQSPI_PHY_SEARCH_OFFSET 8 + +#define CQSPI_PHY_DEFAULT_TEMP 45 +#define CQSPI_PHY_MIN_TEMP -45 +#define CQSPI_PHY_MAX_TEMP 130 +#define CQSPI_PHY_MID_TEMP (CQSPI_PHY_MIN_TEMP + \ + ((CQSPI_PHY_MAX_TEMP - \ + CQSPI_PHY_MIN_TEMP) / 2)) + +/* + * PHY tuning pattern for calibrating read data capture delay. This 128-by= te + * pattern provides sufficient bit transitions across all byte lanes to + * reliably detect timing windows at high frequencies. + */ +static const u8 phy_tuning_pattern[] __aligned(64) =3D { + 0xFE, 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0xFE, 0xFE, 0x01, + 0x01, 0x01, 0x01, 0x00, 0x00, 0xFE, 0xFE, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0x00, 0x00, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFE, + 0xFE, 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0xFE, 0x00, 0xFE, 0xFE, 0x01, + 0x01, 0x01, 0x01, 0xFE, 0x00, 0xFE, 0xFE, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFE, 0x00, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0x00, 0xFE, + 0xFE, 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0xFE, 0xFE, 0xFE, 0x01, + 0x01, 0x01, 0x01, 0x00, 0xFE, 0xFE, 0xFE, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0x00, 0xFE, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFE, 0xFE, + 0xFE, 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0xFE, 0xFE, 0xFE, 0xFE, 0x01, + 0x01, 0x01, 0x01, 0xFE, 0xFE, 0xFE, 0xFE, 0x01, +}; + static int cqspi_wait_for_bit(const struct cqspi_driver_platdata *ddata, void __iomem *reg, const u32 mask, bool clr, bool busywait) @@ -913,6 +996,74 @@ static void cqspi_controller_enable(struct cqspi_st *c= qspi, bool enable) writel(reg, reg_base + CQSPI_REG_CONFIG); } =20 +static void cqspi_set_dll(void __iomem *reg_base, u8 rx_dll, u8 tx_dll) +{ + unsigned int reg; + + reg =3D readl(reg_base + CQSPI_REG_PHY_CONFIG); + reg &=3D ~((CQSPI_REG_PHY_CONFIG_RX_DEL_MASK + << CQSPI_REG_PHY_CONFIG_RX_DEL_LSB) | + (CQSPI_REG_PHY_CONFIG_TX_DEL_MASK + << CQSPI_REG_PHY_CONFIG_TX_DEL_LSB)); + reg |=3D ((rx_dll & CQSPI_REG_PHY_CONFIG_RX_DEL_MASK) + << CQSPI_REG_PHY_CONFIG_RX_DEL_LSB) | + ((tx_dll & CQSPI_REG_PHY_CONFIG_TX_DEL_MASK) + << CQSPI_REG_PHY_CONFIG_TX_DEL_LSB) | + CQSPI_REG_PHY_CONFIG_RESYNC; + writel(reg, reg_base + CQSPI_REG_PHY_CONFIG); +} + +static int cqspi_resync_dll(struct cqspi_st *cqspi) +{ + void __iomem *reg_base =3D cqspi->iobase; + unsigned int reg; + int ret; + + ret =3D cqspi_wait_idle(cqspi); + if (ret) + return ret; + + reg =3D readl(reg_base + CQSPI_REG_CONFIG); + reg &=3D ~CQSPI_REG_CONFIG_ENABLE_MASK; + writel(reg, reg_base + CQSPI_REG_CONFIG); + + reg =3D readl(reg_base + CQSPI_REG_PHY_CONFIG); + reg &=3D ~(CQSPI_REG_PHY_CONFIG_DLL_RESET | CQSPI_REG_PHY_CONFIG_RESYNC); + writel(reg, reg_base + CQSPI_REG_PHY_CONFIG); + + reg =3D readl(reg_base + CQSPI_REG_PHY_DLL_MASTER); + reg |=3D (CQSPI_REG_PHY_DLL_MASTER_INIT_DELAY_VAL + << CQSPI_REG_PHY_DLL_MASTER_INIT_DELAY_LSB); + writel(reg, reg_base + CQSPI_REG_PHY_DLL_MASTER); + + reg =3D readl(reg_base + CQSPI_REG_PHY_CONFIG); + reg |=3D CQSPI_REG_PHY_CONFIG_DLL_RESET; + writel(reg, reg_base + CQSPI_REG_PHY_CONFIG); + + ret =3D readl_poll_timeout(reg_base + CQSPI_REG_DLL_OBS_LOW, reg, + (reg & CQSPI_REG_DLL_OBS_LOW_DLL_LOCK), 0, + CQSPI_DLL_TIMEOUT_US); + if (ret) + goto re_enable; + + ret =3D readl_poll_timeout(reg_base + CQSPI_REG_DLL_OBS_LOW, reg, + (reg & CQSPI_REG_DLL_OBS_LOW_LOOPBACK_LOCK), 0, + CQSPI_DLL_TIMEOUT_US); + if (ret) + goto re_enable; + + reg =3D readl(reg_base + CQSPI_REG_PHY_CONFIG); + reg |=3D CQSPI_REG_PHY_CONFIG_RESYNC; + writel(reg, reg_base + CQSPI_REG_PHY_CONFIG); + +re_enable: + reg =3D readl(reg_base + CQSPI_REG_CONFIG); + reg |=3D CQSPI_REG_CONFIG_ENABLE_MASK; + writel(reg, reg_base + CQSPI_REG_CONFIG); + + return ret; +} + static int cqspi_versal_indirect_read_dma(struct cqspi_flash_pdata *f_pdat= a, u_char *rxbuf, loff_t from_addr, size_t n_rx) @@ -1559,10 +1710,1578 @@ static bool cqspi_supports_mem_op(struct spi_mem = *mem, return spi_mem_default_supports_op(mem, op); } =20 +static int cqspi_write_pattern_to_cache(struct cqspi_flash_pdata *f_pdata, + struct spi_mem *mem, + struct spi_mem_op *write_op) +{ + struct device *dev =3D &f_pdata->cqspi->pdev->dev; + int ret; + + write_op->data.nbytes =3D sizeof(phy_tuning_pattern); + write_op->data.buf.out =3D phy_tuning_pattern; + + ret =3D spi_mem_exec_op(mem, write_op); + if (ret) { + dev_err(dev, "Failed to write PHY pattern to cache: %d\n", ret); + return ret; + } + dev_dbg(dev, "PHY pattern (%zu bytes) written to cache\n", + sizeof(phy_tuning_pattern)); + + return 0; +} + +static int cqspi_phy_check_pattern(struct cqspi_flash_pdata *f_pdata, + struct spi_mem *mem) +{ + struct spi_mem_op op; + u8 *read_data; + int ret; + + read_data =3D kmalloc_array(ARRAY_SIZE(phy_tuning_pattern), + sizeof(phy_tuning_pattern[0]), GFP_KERNEL); + if (!read_data) + return -ENOMEM; + + op =3D f_pdata->phy_read_op; + op.data.buf.in =3D read_data; + op.data.nbytes =3D sizeof(phy_tuning_pattern); + + ret =3D spi_mem_exec_op(mem, &op); + if (ret) + goto out; + + if (memcmp(read_data, phy_tuning_pattern, sizeof(phy_tuning_pattern))) + ret =3D -EAGAIN; + +out: + kfree(read_data); + return ret; +} + +static void cqspi_phy_set_dll_master(struct cqspi_st *cqspi) +{ + void __iomem *reg_base =3D cqspi->iobase; + unsigned int reg; + + reg =3D readl(reg_base + CQSPI_REG_PHY_DLL_MASTER); + reg &=3D ~((CQSPI_REG_PHY_DLL_MASTER_DLY_ELMTS_LEN + << CQSPI_REG_PHY_DLL_MASTER_DLY_ELMTS_LSB) | + CQSPI_REG_PHY_DLL_MASTER_BYPASS | + CQSPI_REG_PHY_DLL_MASTER_CYCLE); + reg |=3D ((CQSPI_REG_PHY_DLL_MASTER_DLY_ELMTS_3 + << CQSPI_REG_PHY_DLL_MASTER_DLY_ELMTS_LSB) | + CQSPI_REG_PHY_DLL_MASTER_CYCLE); + + writel(reg, reg_base + CQSPI_REG_PHY_DLL_MASTER); +} + +static void cqspi_phy_pre_config(struct cqspi_st *cqspi, + struct cqspi_flash_pdata *f_pdata, + const bool bypass) +{ + void __iomem *reg_base =3D cqspi->iobase; + unsigned int reg; + u8 dummy; + + cqspi_readdata_capture(cqspi, bypass, f_pdata->use_dqs, + f_pdata->phy_setting.read_delay); + + reg =3D readl(reg_base + CQSPI_REG_CONFIG); + reg &=3D ~(CQSPI_REG_CONFIG_PHY_EN | CQSPI_REG_CONFIG_PHY_PIPELINE); + reg |=3D CQSPI_REG_CONFIG_PHY_EN; + writel(reg, reg_base + CQSPI_REG_CONFIG); + + reg =3D readl(reg_base + CQSPI_REG_RD_INSTR); + dummy =3D FIELD_GET(CQSPI_REG_RD_INSTR_DUMMY_MASK + << CQSPI_REG_RD_INSTR_DUMMY_LSB, + reg); + dummy--; + reg &=3D ~(CQSPI_REG_RD_INSTR_DUMMY_MASK << CQSPI_REG_RD_INSTR_DUMMY_LSB); + reg |=3D FIELD_PREP(CQSPI_REG_RD_INSTR_DUMMY_MASK + << CQSPI_REG_RD_INSTR_DUMMY_LSB, + dummy); + writel(reg, reg_base + CQSPI_REG_RD_INSTR); + + cqspi_phy_set_dll_master(cqspi); +} + +static void cqspi_phy_post_config(struct cqspi_st *cqspi, + const unsigned int delay) +{ + void __iomem *reg_base =3D cqspi->iobase; + unsigned int reg; + u8 dummy; + + reg =3D readl(reg_base + CQSPI_REG_READCAPTURE); + reg &=3D ~(CQSPI_REG_READCAPTURE_DELAY_MASK + << CQSPI_REG_READCAPTURE_DELAY_LSB); + + reg |=3D (delay & CQSPI_REG_READCAPTURE_DELAY_MASK) + << CQSPI_REG_READCAPTURE_DELAY_LSB; + writel(reg, reg_base + CQSPI_REG_READCAPTURE); + + reg =3D readl(reg_base + CQSPI_REG_CONFIG); + reg &=3D ~(CQSPI_REG_CONFIG_PHY_EN | CQSPI_REG_CONFIG_PHY_PIPELINE); + writel(reg, reg_base + CQSPI_REG_CONFIG); + + reg =3D readl(reg_base + CQSPI_REG_RD_INSTR); + dummy =3D FIELD_GET(CQSPI_REG_RD_INSTR_DUMMY_MASK + << CQSPI_REG_RD_INSTR_DUMMY_LSB, + reg); + dummy++; + reg &=3D ~(CQSPI_REG_RD_INSTR_DUMMY_MASK << CQSPI_REG_RD_INSTR_DUMMY_LSB); + reg |=3D FIELD_PREP(CQSPI_REG_RD_INSTR_DUMMY_MASK + << CQSPI_REG_RD_INSTR_DUMMY_LSB, + dummy); + writel(reg, reg_base + CQSPI_REG_RD_INSTR); +} + +static int cqspi_phy_apply_setting(struct cqspi_flash_pdata *f_pdata, + struct phy_setting *phy) +{ + struct cqspi_st *cqspi =3D f_pdata->cqspi; + unsigned int reg; + int ret; + + reg =3D readl(cqspi->iobase + CQSPI_REG_READCAPTURE); + reg |=3D BIT(CQSPI_REG_READCAPTURE_EDGE_LSB); + writel(reg, cqspi->iobase + CQSPI_REG_READCAPTURE); + + cqspi_set_dll(cqspi->iobase, phy->rx, phy->tx); + + ret =3D cqspi_resync_dll(cqspi); + if (ret) + return ret; + + f_pdata->phy_setting.rx =3D phy->rx; + f_pdata->phy_setting.tx =3D phy->tx; + f_pdata->phy_setting.read_delay =3D phy->read_delay; + return 0; +} + +static int cqspi_find_rx_low_ddr(struct cqspi_flash_pdata *f_pdata, + struct spi_mem *mem, struct phy_setting *phy) +{ + struct device *dev =3D &f_pdata->cqspi->pdev->dev; + int ret; + + do { + phy->rx =3D CQSPI_PHY_RX_LOW_SEARCH_START; + do { + ret =3D cqspi_phy_apply_setting(f_pdata, phy); + if (!ret) { + ret =3D cqspi_phy_check_pattern(f_pdata, mem); + if (!ret) + return 0; + } + + phy->rx +=3D CQSPI_PHY_DDR_SEARCH_STEP; + } while (phy->rx <=3D CQSPI_PHY_RX_LOW_SEARCH_END); + + phy->read_delay++; + } while (phy->read_delay <=3D CQSPI_PHY_MAX_RD); + + dev_dbg(dev, "Unable to find RX low\n"); + return -ENOENT; +} + +static int cqspi_find_rx_low_sdr(struct cqspi_flash_pdata *f_pdata, + struct spi_mem *mem, struct phy_setting *phy) +{ + struct device *dev =3D &f_pdata->cqspi->pdev->dev; + int ret; + + phy->rx =3D 0; + do { + ret =3D cqspi_phy_apply_setting(f_pdata, phy); + if (!ret) { + ret =3D cqspi_phy_check_pattern(f_pdata, mem); + if (!ret) + return 0; + } + phy->rx++; + } while (phy->rx <=3D CQSPI_PHY_MAX_DELAY); + + dev_dbg(dev, "Unable to find RX low\n"); + return -ENOENT; +} + +static int cqspi_find_rx_high_ddr(struct cqspi_flash_pdata *f_pdata, + struct spi_mem *mem, struct phy_setting *phy) +{ + struct device *dev =3D &f_pdata->cqspi->pdev->dev; + int ret; + + do { + phy->rx =3D CQSPI_PHY_RX_HIGH_SEARCH_END; + do { + ret =3D cqspi_phy_apply_setting(f_pdata, phy); + if (!ret) { + ret =3D cqspi_phy_check_pattern(f_pdata, mem); + if (!ret) + return 0; + } + + phy->rx -=3D CQSPI_PHY_DDR_SEARCH_STEP; + } while (phy->rx >=3D CQSPI_PHY_RX_HIGH_SEARCH_START); + + phy->read_delay--; + } while (phy->read_delay >=3D CQSPI_PHY_INIT_RD); + + dev_dbg(dev, "Unable to find RX high\n"); + return -ENOENT; +} + +static int cqspi_find_rx_high_sdr(struct cqspi_flash_pdata *f_pdata, + struct spi_mem *mem, struct phy_setting *phy, + u8 lowerbound) +{ + struct device *dev =3D &f_pdata->cqspi->pdev->dev; + int ret; + + phy->rx =3D CQSPI_PHY_MAX_DELAY; + do { + ret =3D cqspi_phy_apply_setting(f_pdata, phy); + if (!ret) { + ret =3D cqspi_phy_check_pattern(f_pdata, mem); + if (!ret) + return 0; + } + phy->rx--; + } while (phy->rx > lowerbound); + + dev_dbg(dev, "Unable to find RX high\n"); + return -ENOENT; +} + +static int cqspi_find_tx_low_ddr(struct cqspi_flash_pdata *f_pdata, + struct spi_mem *mem, struct phy_setting *phy) +{ + struct device *dev =3D &f_pdata->cqspi->pdev->dev; + int ret; + + do { + phy->tx =3D CQSPI_PHY_TX_LOW_SEARCH_START; + do { + ret =3D cqspi_phy_apply_setting(f_pdata, phy); + if (!ret) { + ret =3D cqspi_phy_check_pattern(f_pdata, mem); + if (!ret) + return 0; + } + + phy->tx +=3D CQSPI_PHY_DDR_SEARCH_STEP; + } while (phy->tx <=3D CQSPI_PHY_TX_LOW_SEARCH_END); + + phy->read_delay++; + } while (phy->read_delay <=3D CQSPI_PHY_MAX_RD); + + dev_dbg(dev, "Unable to find TX low\n"); + return -ENOENT; +} + +static int cqspi_find_tx_high_ddr(struct cqspi_flash_pdata *f_pdata, + struct spi_mem *mem, struct phy_setting *phy) +{ + struct device *dev =3D &f_pdata->cqspi->pdev->dev; + int ret; + + do { + phy->tx =3D CQSPI_PHY_TX_HIGH_SEARCH_END; + do { + ret =3D cqspi_phy_apply_setting(f_pdata, phy); + if (!ret) { + ret =3D cqspi_phy_check_pattern(f_pdata, mem); + if (!ret) + return 0; + } + + phy->tx -=3D CQSPI_PHY_DDR_SEARCH_STEP; + } while (phy->tx >=3D CQSPI_PHY_TX_HIGH_SEARCH_START); + + phy->read_delay--; + } while (phy->read_delay >=3D CQSPI_PHY_INIT_RD); + + dev_dbg(dev, "Unable to find TX high\n"); + return -ENOENT; +} + +static void cqspi_phy_find_gaplow_ddr(struct cqspi_flash_pdata *f_pdata, + struct spi_mem *mem, + struct phy_setting *bottomleft, + struct phy_setting *topright, + struct phy_setting *gaplow) +{ + struct phy_setting left, right, mid; + int ret; + + left =3D *bottomleft; + right =3D *topright; + + mid.tx =3D left.tx + ((right.tx - left.tx) / 2); + mid.rx =3D left.rx + ((right.rx - left.rx) / 2); + mid.read_delay =3D left.read_delay; + + do { + ret =3D cqspi_phy_apply_setting(f_pdata, &mid); + if (!ret) + ret =3D cqspi_phy_check_pattern(f_pdata, mem); + + if (ret) { + /* The pattern was not found. Go to the lower half. */ + right.tx =3D mid.tx; + right.rx =3D mid.rx; + + mid.tx =3D left.tx + ((mid.tx - left.tx) / 2); + mid.rx =3D left.rx + ((mid.rx - left.rx) / 2); + } else { + /* The pattern was found. Go to the upper half. */ + left.tx =3D mid.tx; + left.rx =3D mid.rx; + + mid.tx =3D mid.tx + ((right.tx - mid.tx) / 2); + mid.rx =3D mid.rx + ((right.rx - mid.rx) / 2); + } + + /* Break the loop if the window has closed. */ + } while ((right.tx - left.tx >=3D 2) && (right.rx - left.rx >=3D 2)); + + *gaplow =3D mid; +} + +static void cqspi_phy_find_gaphigh_ddr(struct cqspi_flash_pdata *f_pdata, + struct spi_mem *mem, + struct phy_setting *bottomleft, + struct phy_setting *topright, + struct phy_setting *gaphigh) +{ + struct phy_setting left, right, mid; + int ret; + + left =3D *bottomleft; + right =3D *topright; + + mid.tx =3D left.tx + ((right.tx - left.tx) / 2); + mid.rx =3D left.rx + ((right.rx - left.rx) / 2); + mid.read_delay =3D right.read_delay; + + do { + ret =3D cqspi_phy_apply_setting(f_pdata, &mid); + if (!ret) + ret =3D cqspi_phy_check_pattern(f_pdata, mem); + + if (ret) { + /* The pattern was not found. Go to the upper half. */ + left.tx =3D mid.tx; + left.rx =3D mid.rx; + + mid.tx =3D mid.tx + ((right.tx - mid.tx) / 2); + mid.rx =3D mid.rx + ((right.rx - mid.rx) / 2); + } else { + /* The pattern was found. Go to the lower half. */ + right.tx =3D mid.tx; + right.rx =3D mid.rx; + + mid.tx =3D left.tx + ((mid.tx - left.tx) / 2); + mid.rx =3D left.rx + ((mid.rx - left.rx) / 2); + } + + /* Break the loop if the window has closed. */ + } while ((right.tx - left.tx >=3D 2) && (right.rx - left.rx >=3D 2)); + + *gaphigh =3D mid; +} + +static int cqspi_get_temp(int *temp) +{ + /* TODO: read SoC thermal sensor; caller falls back to room temperature */ + return -EOPNOTSUPP; +} + +static inline void cqspi_phy_reset_setting(struct phy_setting *phy) +{ + *phy =3D (struct phy_setting){ .rx =3D 0, .tx =3D 127, .read_delay =3D 0 = }; +} + +static int cqspi_phy_tuning_ddr(struct cqspi_flash_pdata *f_pdata, + struct spi_mem *mem) +{ + struct cqspi_st *cqspi =3D f_pdata->cqspi; + struct device *dev =3D &cqspi->pdev->dev; + struct phy_setting rxlow, rxhigh, txlow, txhigh; + struct phy_setting srxlow, srxhigh; + struct phy_setting bottomleft, topright, searchpoint; + struct phy_setting gaplow, gaphigh; + struct phy_setting backuppoint, backupcornerpoint; + int ret, rx_window, temp; + bool primary =3D true, secondary =3D true; + + /* + * DDR tuning: 2D search across RX and TX delays for optimal timing. + * + * Algorithm: Find RX boundaries (rxlow/rxhigh) using TX window search, + * find TX boundaries (txlow/txhigh) at fixed RX, define valid region, + * locate gaps via binary search, select final point with temperature + * compensation. + * + * rx + * 127 ^ + * | topright + * | * + * | xxxxx ++++++++++++++++++++ + * | xxxxxx +++++++++++++++++++ + * | xxxxxxx ++++++++++++++++++ + * | xxxxxxxx +++++++++++++++++ + * | xxxxxxxxx ++++++++++++++++ + * | xxxxxxxxxx +++++++++++++++ + * | xxxxxxxxxxx ++++++++++++++ + * | xxxxxxxxxxxx +++++++++++++ + * | xxxxxxxxxxxxx ++++++++++++ + * | xxxxxxxxxxxxxx +++++++++++ + * | xxxxxxxxxxxxxxx ++++++++++ + * | xxxxxxxxxxxxxxxx +++++++++ + * | xxxxxxxxxxxxxxxxx ++++++++ + * | xxxxxxxxxxxxxxxxxx +++++++ + * | * + * | bottomleft + * -----------------------------------------> tx + * 0 127 + */ + + f_pdata->use_tuned_phy =3D true; + + /* Golden rxlow search: Find lower RX boundary using TX window sweep */ + + /* + * rx + * 127 ^ + * | xxxxx ++++++++++++++++++++ + * | xxxxxx +++++++++++++++++++ + * | xxxxxxx ++++++++++++++++++ + * | xxxxxxxx +++++++++++++++++ + * | xxxxxxxxx ++++++++++++++++ + * | xxxxxxxxxx +++++++++++++++ + * | xxxxxxxxxxx ++++++++++++++ + * | |xxxxx|xxxxx +++++++++++++ + * | |xxxxx|xxxxxx ++++++++++++ + * search | |xxxxx|xxxxxxx +++++++++++ + * rxlow --------->|xxxxx|xxxxxxxx ++++++++++ + * | |xxxxx|xxxxxxxxx +++++++++ + * | |xxxxx|xxxxxxxxxx ++++++++ + * | |xxxxx|xxxxxxxxxxx +++++++ + * | | | + * --------|-----|----------------------------> tx + * 0 | | 127 + * txlow txlow + * start end + * + * |----------------------------------------------------------| + * | Primary | Secondary | Final | + * | Search | Search | Point | + * |---------|-----------|------------------------------------| + * | Fail | Fail | Return Fail | + * |---------|-----------|------------------------------------| + * | Fail | Pass | Return Fail | + * |---------|-----------|------------------------------------| + * | Pass | Fail | Return Fail | + * |---------|-----------|------------------------------------| + * | Pass | Pass | rx =3D min(primary.rx, secondary.rx) | + * | | | tx =3D primary.tx | + * | | | read_delay =3D | + * | | | min(primary.read_delay, | + * | | | secondary.read_delay) | + * |----------------------------------------------------------| + */ + + /* Primary rxlow: Sweep TX window to find valid RX lower bound */ + + rxlow.tx =3D CQSPI_PHY_TX_LOOKUP_LOW_START; + do { + dev_dbg(dev, "Searching for Golden Primary rxlow on TX =3D %d\n", + rxlow.tx); + rxlow.read_delay =3D CQSPI_PHY_INIT_RD; + ret =3D cqspi_find_rx_low_ddr(f_pdata, mem, &rxlow); + rxlow.tx +=3D CQSPI_PHY_DDR_SEARCH_STEP; + } while (ret && rxlow.tx <=3D CQSPI_PHY_TX_LOOKUP_LOW_END); + if (ret) + goto out; + dev_dbg(dev, "Golden Primary rxlow: RX: %d TX: %d RD: %d\n", rxlow.rx, + rxlow.tx, rxlow.read_delay); + + /* Secondary rxlow: Verify at offset TX for robustness */ + + if (rxlow.tx <=3D (CQSPI_PHY_TX_LOOKUP_LOW_END - CQSPI_PHY_SEARCH_OFFSET)) + srxlow.tx =3D rxlow.tx + CQSPI_PHY_SEARCH_OFFSET; + else + srxlow.tx =3D CQSPI_PHY_TX_LOOKUP_LOW_END; + dev_dbg(dev, "Searching for Golden Secondary rxlow on TX =3D %d\n", + srxlow.tx); + srxlow.read_delay =3D CQSPI_PHY_INIT_RD; + ret =3D cqspi_find_rx_low_ddr(f_pdata, mem, &srxlow); + if (ret) + goto out; + dev_dbg(dev, "Golden Secondary rxlow: RX: %d TX: %d RD: %d\n", + srxlow.rx, srxlow.tx, srxlow.read_delay); + + rxlow.rx =3D min(rxlow.rx, srxlow.rx); + rxlow.read_delay =3D min(rxlow.read_delay, srxlow.read_delay); + dev_dbg(dev, "Golden Final rxlow: RX: %d TX: %d RD: %d\n", rxlow.rx, + rxlow.tx, rxlow.read_delay); + + /* Golden rxhigh search: Find upper RX boundary at fixed TX */ + + /* + * rx + * 127 ^ + * | |xxxx ++++++++++++++++++++ + * | |xxxxx +++++++++++++++++++ + * search | |xxxxxx ++++++++++++++++++ + * rxhigh --------->|xxxxxxx +++++++++++++++++ + * on fixed | |xxxxxxxx ++++++++++++++++ + * tx | |xxxxxxxxx +++++++++++++++ + * | |xxxxxxxxxx ++++++++++++++ + * | xxxxxxxxxxxx +++++++++++++ + * | xxxxxxxxxxxxx ++++++++++++ + * | xxxxxxxxxxxxxx +++++++++++ + * | xxxxxxxxxxxxxxx ++++++++++ + * | xxxxxxxxxxxxxxxx +++++++++ + * | xxxxxxxxxxxxxxxxx ++++++++ + * | xxxxxxxxxxxxxxxxxx +++++++ + * | + * -------------------------------------------> tx + * 0 127 + * + * |----------------------------------------------------------| + * | Primary | Secondary | Final | + * | Search | Search | Point | + * |---------|-----------|------------------------------------| + * | Fail | Fail | Return Fail | + * |---------|-----------|------------------------------------| + * | Fail | Pass | Choose Secondary | + * |---------|-----------|------------------------------------| + * | Pass | Fail | Choose Primary | + * |---------|-----------|------------------------------------| + * | Pass | Pass | if (secondary.rx > primary.rx) | + * | | | Choose Secondary | + * | | | else | + * | | | Choose Primary | + * |----------------------------------------------------------| + */ + + /* Primary rxhigh: Search at rxlow's TX, decrement from max read_delay */ + + rxhigh.tx =3D rxlow.tx; + dev_dbg(dev, "Searching for Golden Primary rxhigh on TX =3D %d\n", + rxhigh.tx); + rxhigh.read_delay =3D CQSPI_PHY_MAX_RD; + ret =3D cqspi_find_rx_high_ddr(f_pdata, mem, &rxhigh); + if (ret) + primary =3D false; + dev_dbg(dev, "Golden Primary rxhigh: RX: %d TX: %d RD: %d\n", rxhigh.rx, + rxhigh.tx, rxhigh.read_delay); + + /* Secondary rxhigh: Verify at offset TX */ + + if (rxhigh.tx <=3D + (CQSPI_PHY_TX_LOOKUP_LOW_END - CQSPI_PHY_SEARCH_OFFSET)) + srxhigh.tx =3D rxhigh.tx + CQSPI_PHY_SEARCH_OFFSET; + else + srxhigh.tx =3D CQSPI_PHY_TX_LOOKUP_LOW_END; + dev_dbg(dev, "Searching for Golden Secondary rxhigh on TX =3D %d\n", + srxhigh.tx); + srxhigh.read_delay =3D CQSPI_PHY_MAX_RD; + ret =3D cqspi_find_rx_high_ddr(f_pdata, mem, &srxhigh); + if (ret) + secondary =3D false; + dev_dbg(dev, "Golden Secondary rxhigh: RX: %d TX: %d RD: %d\n", + srxhigh.rx, srxhigh.tx, srxhigh.read_delay); + + if (!primary && !secondary) + goto out; + else if (!primary) + rxhigh =3D srxhigh; + else if (secondary && srxhigh.rx > rxhigh.rx) + rxhigh =3D srxhigh; + dev_dbg(dev, "Golden Final rxhigh: RX: %d TX: %d RD: %d\n", rxhigh.rx, + rxhigh.tx, rxhigh.read_delay); + + primary =3D true; + secondary =3D true; + + /* If rxlow/rxhigh at same read_delay, search backup at upper TX range */ + + if (rxlow.read_delay =3D=3D rxhigh.read_delay) { + dev_dbg(dev, "rxlow and rxhigh at the same read delay.\n"); + + /* Backup rxlow: Search at high TX window */ + + /* + * rx + * 127 ^ + * | xxxxx ++++++++++++++++++++ + * | xxxxxx +++++++++++++++++++ + * | xxxxxxx ++++++++++++++++++ + * | xxxxxxxx +++++++++++++++++ + * | xxxxxxxxx ++++++++++++++++ + * | xxxxxxxxxx +++++++++++++++ + * | xxxxxxxxxxx ++++++++++++++ + * | xxxxxxxxxxxx +++++++|++++| + * | xxxxxxxxxxxxx ++++++|++++| + * search | xxxxxxxxxxxxxx +++++|++++| + * rxlow --------------------------------->|++++| + * | xxxxxxxxxxxxxxxx +++|++++| + * | xxxxxxxxxxxxxxxxx ++|++++| + * | xxxxxxxxxxxxxxxxxx +|++++| + * | | | + * --------------------------------|----|-----> tx + * 0 | | 127 + * txhigh txhigh + * start end + * + * |-----------------------------------------------------| + * | Primary | Secondary | Final | + * | Search | Search | Point | + * |---------|-----------|-------------------------------| + * | Fail | Fail | Return Fail | + * |---------|-----------|-------------------------------| + * | Fail | Pass | Return Fail | + * |---------|-----------|-------------------------------| + * | Pass | Fail | Return Fail | + * |---------|-----------|-------------------------------| + * | Pass | Pass | rx =3D | + * | | | min(primary.rx, secondary.rx)| + * | | | tx =3D primary.tx | + * | | | read_delay =3D | + * | | | min(primary.read_delay, | + * | | | secondary.read_delay) | + * |-----------------------------------------------------| + */ + + /* Primary backup: Decrement TX from high window end */ + + backuppoint.tx =3D CQSPI_PHY_TX_LOOKUP_HIGH_END; + do { + dev_dbg(dev, + "Searching for Backup Primary rxlow on TX =3D %d\n", + backuppoint.tx); + backuppoint.read_delay =3D CQSPI_PHY_INIT_RD; + ret =3D cqspi_find_rx_low_ddr(f_pdata, mem, &backuppoint); + backuppoint.tx -=3D CQSPI_PHY_DDR_SEARCH_STEP; + } while (ret && + backuppoint.tx >=3D CQSPI_PHY_TX_LOOKUP_HIGH_START); + if (ret) + goto out; + dev_dbg(dev, "Backup Primary rxlow: RX: %d TX: %d RD: %d\n", + backuppoint.rx, backuppoint.tx, backuppoint.read_delay); + + /* Secondary backup: Verify at offset TX */ + + if (backuppoint.tx >=3D + (CQSPI_PHY_TX_LOOKUP_HIGH_START + CQSPI_PHY_SEARCH_OFFSET)) + srxlow.tx =3D backuppoint.tx - CQSPI_PHY_SEARCH_OFFSET; + else + srxlow.tx =3D CQSPI_PHY_TX_LOOKUP_HIGH_START; + dev_dbg(dev, + "Searching for Backup Secondary rxlow on TX =3D %d\n", + srxlow.tx); + srxlow.read_delay =3D CQSPI_PHY_INIT_RD; + ret =3D cqspi_find_rx_low_ddr(f_pdata, mem, &srxlow); + if (ret) + goto out; + dev_dbg(dev, "Backup Secondary rxlow: RX: %d TX: %d RD: %d\n", + srxlow.rx, srxlow.tx, srxlow.read_delay); + + backuppoint.rx =3D min(backuppoint.rx, srxlow.rx); + backuppoint.read_delay =3D + min(backuppoint.read_delay, srxlow.read_delay); + dev_dbg(dev, "Backup Final rxlow: RX: %d TX: %d RD: %d\n", + backuppoint.rx, backuppoint.tx, backuppoint.read_delay); + + if (backuppoint.rx < rxlow.rx) { + rxlow =3D backuppoint; + dev_dbg(dev, "Updating rxlow to the one at TX =3D %d\n", + backuppoint.tx); + } + dev_dbg(dev, "Final rxlow: RX: %d TX: %d RD: %d\n", rxlow.rx, + rxlow.tx, rxlow.read_delay); + + /* Backup rxhigh: Search at fixed backup TX */ + + /* + * rx + * 127 ^ + * | xxxxx +++++++++++++++++++| + * | xxxxxx ++++++++++++++++++| + * search | xxxxxxx +++++++++++++++++| + * rxhigh -------------------------------------->| + * on fixed | xxxxxxxxx +++++++++++++++| + * tx | xxxxxxxxxx ++++++++++++++| + * | xxxxxxxxxxx +++++++++++++| + * | xxxxxxxxxxxx +++++++++++++ + * | xxxxxxxxxxxxx ++++++++++++ + * | xxxxxxxxxxxxxx +++++++++++ + * | xxxxxxxxxxxxxxx ++++++++++ + * | xxxxxxxxxxxxxxxx +++++++++ + * | xxxxxxxxxxxxxxxxx ++++++++ + * | xxxxxxxxxxxxxxxxxx +++++++ + * | + * -------------------------------------------> tx + * 0 127 + * + * |-----------------------------------------------------| + * | Primary | Secondary | Final | + * | Search | Search | Point | + * |---------|-----------|-------------------------------| + * | Fail | Fail | Return Fail | + * |---------|-----------|-------------------------------| + * | Fail | Pass | Choose Secondary | + * |---------|-----------|-------------------------------| + * | Pass | Fail | Choose Primary | + * |---------|-----------|-------------------------------| + * | Pass | Pass | if (secondary.rx > primary.rx)| + * | | | Choose Secondary | + * | | | else | + * | | | Choose Primary | + * |-----------------------------------------------------| + */ + + /* Primary backup rxhigh: Use backup TX, decrement from max read_delay */ + + dev_dbg(dev, "Searching for Backup Primary rxhigh on TX =3D %d\n", + backuppoint.tx); + backuppoint.read_delay =3D CQSPI_PHY_MAX_RD; + ret =3D cqspi_find_rx_high_ddr(f_pdata, mem, &backuppoint); + if (ret) + primary =3D false; + dev_dbg(dev, "Backup Primary rxhigh: RX: %d TX: %d RD: %d\n", + backuppoint.rx, backuppoint.tx, backuppoint.read_delay); + + /* Secondary backup rxhigh: Verify at offset TX */ + + if (backuppoint.tx >=3D + (CQSPI_PHY_TX_LOOKUP_HIGH_START + CQSPI_PHY_SEARCH_OFFSET)) + srxhigh.tx =3D backuppoint.tx - CQSPI_PHY_SEARCH_OFFSET; + else + srxhigh.tx =3D CQSPI_PHY_TX_LOOKUP_HIGH_START; + dev_dbg(dev, + "Searching for Backup Secondary rxhigh on TX =3D %d\n", + srxhigh.tx); + srxhigh.read_delay =3D CQSPI_PHY_MAX_RD; + ret =3D cqspi_find_rx_high_ddr(f_pdata, mem, &srxhigh); + if (ret) + secondary =3D false; + dev_dbg(dev, "Backup Secondary rxhigh: RX: %d TX: %d RD: %d\n", + srxhigh.rx, srxhigh.tx, srxhigh.read_delay); + + if (!primary && !secondary) + goto out; + else if (!primary) + backuppoint =3D srxhigh; + else if (secondary && srxhigh.rx > backuppoint.rx) + backuppoint =3D srxhigh; + dev_dbg(dev, "Backup Final rxhigh: RX: %d TX: %d RD: %d\n", + backuppoint.rx, backuppoint.tx, backuppoint.read_delay); + + if (backuppoint.rx > rxhigh.rx) { + rxhigh =3D backuppoint; + dev_dbg(dev, "Updating rxhigh to the one at TX =3D %d\n", + backuppoint.tx); + } + dev_dbg(dev, "Final rxhigh: RX: %d TX: %d RD: %d\n", rxhigh.rx, + rxhigh.tx, rxhigh.read_delay); + } + + /* Golden txlow: Fix RX at 1/4 of RX window, search TX lower bound */ + + /* + * rx + * 127 ^ + * | + * rxhigh --------->xxxxx ++++++++++++++++++++ + * | xxxxxx +++++++++++++++++++ + * | xxxxxxx ++++++++++++++++++ + * | xxxxxxxx +++++++++++++++++ + * | xxxxxxxxx ++++++++++++++++ + * | xxxxxxxxxx +++++++++++++++ + * | xxxxxxxxxxx ++++++++++++++ + * | xxxxxxxxxxxx +++++++++++++ + * fix rx | xxxxxxxxxxxxx ++++++++++++ + * 1/4 b/w ---------><------->xxxxx +++++++++++ + * rxlow and | xxxx|xxxxxxxxxx ++++++++++ + * rxhigh | xxxx|xxxxxxxxxxx +++++++++ + * | xxxx|xxxxxxxxxxxx ++++++++ + * rxlow --------->xxxx|xxxxxxxxxxxxx +++++++ + * | | + * ------------|------------------------------> tx + * 0 | 127 + * search + * txlow + */ + + rx_window =3D rxhigh.rx - rxlow.rx; + txlow.rx =3D rxlow.rx + (rx_window / 4); + dev_dbg(dev, "Searching for Golden txlow on RX =3D %d\n", txlow.rx); + txlow.read_delay =3D CQSPI_PHY_INIT_RD; + ret =3D cqspi_find_tx_low_ddr(f_pdata, mem, &txlow); + if (ret) + goto out; + dev_dbg(dev, "Golden txlow: RX: %d TX: %d RD: %d\n", txlow.rx, txlow.tx, + txlow.read_delay); + + /* Golden txhigh: Same RX as txlow, decrement from max read_delay */ + + /* + * rx + * 127 ^ + * | + * rxhigh --------->xxxxx ++++++++++++++++++++ + * | xxxxxx +++++++++++++++++++ + * | xxxxxxx ++++++++++++++++++ + * | xxxxxxxx +++++++++++++++++ + * | xxxxxxxxx ++++++++++++++++ + * | xxxxxxxxxx +++++++++++++++ + * | xxxxxxxxxxx ++++++++++++++ + * | xxxxxxxxxxxx +++++++++++++ + * fix rx | xxxxxxxxxxxxx ++++++++++++ + * 1/4 b/w --------------------------------><-----> + * rxlow and | xxxxxxxxxxxxxxx ++++++|+++ + * rxhigh | xxxxxxxxxxxxxxxx +++++|+++ + * | xxxxxxxxxxxxxxxxx ++++|+++ + * rxlow --------->xxxxxxxxxxxxxxxxxx +++|+++ + * | | + * ----------------------------------|--------> tx + * 0 | 127 + * search + * txhigh + */ + + txhigh.rx =3D txlow.rx; + dev_dbg(dev, "Searching for Golden txhigh on RX =3D %d\n", txhigh.rx); + txhigh.read_delay =3D CQSPI_PHY_MAX_RD; + ret =3D cqspi_find_tx_high_ddr(f_pdata, mem, &txhigh); + if (ret) + goto out; + dev_dbg(dev, "Golden txhigh: RX: %d TX: %d RD: %d\n", txhigh.rx, + txhigh.tx, txhigh.read_delay); + + /* If txlow/txhigh at same read_delay, search backup at 3/4 RX window */ + + if (txlow.read_delay =3D=3D txhigh.read_delay) { + /* Backup txlow: Fix RX at 3/4 of RX window */ + + /* + * rx + * 127 ^ + * | + * rxhigh --------->xxxxx ++++++++++++++++++++ + * | xxxxxx +++++++++++++++++++ + * fix rx | xxxxxxx ++++++++++++++++++ + * 3/4 b/w ---------><----->x +++++++++++++++++ + * rxlow and | xxxx|xxxx ++++++++++++++++ + * rxhigh | xxxx|xxxxx +++++++++++++++ + * | xxxx|xxxxxx ++++++++++++++ + * | xxxx|xxxxxxx +++++++++++++ + * | xxxx|xxxxxxxx ++++++++++++ + * | xxxx|xxxxxxxxx +++++++++++ + * | xxxx|xxxxxxxxxx ++++++++++ + * | xxxx|xxxxxxxxxxx +++++++++ + * | xxxx|xxxxxxxxxxxx ++++++++ + * rxlow --------->xxxx|xxxxxxxxxxxxx +++++++ + * | | + * ------------|------------------------------> tx + * 0 | 127 + * search + * txlow + */ + + dev_dbg(dev, "txlow and txhigh at the same read delay.\n"); + backuppoint.rx =3D rxlow.rx + ((rx_window * 3) / 4); + dev_dbg(dev, "Searching for Backup txlow on RX =3D %d\n", + backuppoint.rx); + backuppoint.read_delay =3D CQSPI_PHY_INIT_RD; + ret =3D cqspi_find_tx_low_ddr(f_pdata, mem, &backuppoint); + if (ret) + goto out; + dev_dbg(dev, "Backup txlow: RX: %d TX: %d RD: %d\n", + backuppoint.rx, backuppoint.tx, backuppoint.read_delay); + + if (backuppoint.tx < txlow.tx) { + txlow =3D backuppoint; + dev_dbg(dev, "Updating txlow with the one at RX =3D %d\n", + backuppoint.rx); + } + dev_dbg(dev, "Final txlow: RX: %d TX: %d RD: %d\n", txlow.rx, + txlow.tx, txlow.read_delay); + + /* Backup txhigh: Same RX as backup txlow, decrement from max */ + + /* + * rx + * 127 ^ + * | + * rxhigh --------->xxxxx ++++++++++++++++++++ + * | xxxxxx +++++++++++++++++++ + * fix rx | xxxxxxx ++++++++++++++++++ + * 3/4 b/w ------------------------------><-------> + * rxlow and | xxxxxxxxx +++++++++++|++++ + * rxhigh | xxxxxxxxxx ++++++++++|++++ + * | xxxxxxxxxxx +++++++++|++++ + * | xxxxxxxxxxxx ++++++++|++++ + * | xxxxxxxxxxxxx +++++++|++++ + * | xxxxxxxxxxxxxx ++++++|++++ + * | xxxxxxxxxxxxxxx +++++|++++ + * | xxxxxxxxxxxxxxxx ++++|++++ + * | xxxxxxxxxxxxxxxxx +++|++++ + * rxlow --------->xxxxxxxxxxxxxxxxxx ++|++++ + * | | + * ---------------------------------|---------> tx + * 0 | 127 + * search + * txhigh + */ + + dev_dbg(dev, "Searching for Backup txhigh on RX =3D %d\n", + backuppoint.rx); + backuppoint.read_delay =3D CQSPI_PHY_MAX_RD; + ret =3D cqspi_find_tx_high_ddr(f_pdata, mem, &backuppoint); + if (ret) + goto out; + dev_dbg(dev, "Backup txhigh: RX: %d TX: %d RD: %d\n", + backuppoint.rx, backuppoint.tx, backuppoint.read_delay); + + if (backuppoint.tx > txhigh.tx) { + txhigh =3D backuppoint; + dev_dbg(dev, + "Updating txhigh with the one at RX =3D %d\n", + backuppoint.rx); + } + dev_dbg(dev, "Final txhigh: RX: %d TX: %d RD: %d\n", txhigh.rx, + txhigh.tx, txhigh.read_delay); + } + + /* Corner points: Define and verify bottomleft and topright boundaries */ + + /* + * rx + * 127 ^ + * | topright + * | * + * rxhigh -----------xxxxx ++++++++++++++++++++ + * | xxxxxx +++++++++++++++++++ + * | xxxxxxx ++++++++++++++++++ + * | xxxxxxxx +++++++++++++++++ + * | xxxxxxxxx ++++++++++++++++ + * | xxxxxxxxxx +++++++++++++++ + * | xxxxxxxxxxx ++++++++++++++ + * | xxxxxxxxxxxx +++++++++++++ + * | xxxxxxxxxxxxx ++++++++++++ + * | xxxxxxxxxxxxxx +++++++++++ + * | xxxxxxxxxxxxxxx ++++++++++ + * | xxxxxxxxxxxxxxxx +++++++++ + * | xxxxxxxxxxxxxxxxx ++++++++ + * rxlow -----------xxxxxxxxxxxxxxxxxx +++++++ + * | * | + * | bottom|left | + * --------|----------------------------|---> tx + * 0 | | 127 + * | | + * txlow txhigh + * + * Verification: Test point 4 taps inside each corner, adjust + * read_delay =C2=B11 if needed to ensure valid corners for gap search. + */ + + bottomleft.tx =3D txlow.tx; + bottomleft.rx =3D rxlow.rx; + if (txlow.read_delay <=3D rxlow.read_delay) + bottomleft.read_delay =3D txlow.read_delay; + else + bottomleft.read_delay =3D rxlow.read_delay; + + /* Verify bottomleft: Test 4 taps inside, adjust read_delay if needed */ + backupcornerpoint =3D bottomleft; + backupcornerpoint.tx +=3D 4; + backupcornerpoint.rx +=3D 4; + ret =3D cqspi_phy_apply_setting(f_pdata, &backupcornerpoint); + if (!ret) + ret =3D cqspi_phy_check_pattern(f_pdata, mem); + + if (ret) { + backupcornerpoint.read_delay--; + ret =3D cqspi_phy_apply_setting(f_pdata, &backupcornerpoint); + if (!ret) + ret =3D cqspi_phy_check_pattern(f_pdata, mem); + } + + if (ret) + goto out; + + bottomleft.read_delay =3D backupcornerpoint.read_delay; + + topright.tx =3D txhigh.tx; + topright.rx =3D rxhigh.rx; + if (txhigh.read_delay >=3D rxhigh.read_delay) + topright.read_delay =3D txhigh.read_delay; + else + topright.read_delay =3D rxhigh.read_delay; + + /* Verify topright: Test 4 taps inside, adjust read_delay if needed */ + backupcornerpoint =3D topright; + backupcornerpoint.tx -=3D 4; + backupcornerpoint.rx -=3D 4; + ret =3D cqspi_phy_apply_setting(f_pdata, &backupcornerpoint); + if (!ret) + ret =3D cqspi_phy_check_pattern(f_pdata, mem); + + if (ret) { + backupcornerpoint.read_delay++; + ret =3D cqspi_phy_apply_setting(f_pdata, &backupcornerpoint); + if (!ret) + ret =3D cqspi_phy_check_pattern(f_pdata, mem); + } + + if (ret) + goto out; + + topright.read_delay =3D backupcornerpoint.read_delay; + + dev_dbg(dev, "topright: RX: %d TX: %d RD: %d\n", topright.rx, + topright.tx, topright.read_delay); + dev_dbg(dev, "bottomleft: RX: %d TX: %d RD: %d\n", bottomleft.rx, + bottomleft.tx, bottomleft.read_delay); + cqspi_phy_find_gaplow_ddr(f_pdata, mem, &bottomleft, &topright, &gaplow); + dev_dbg(dev, "gaplow: RX: %d TX: %d RD: %d\n", gaplow.rx, gaplow.tx, + gaplow.read_delay); + + /* Final point selection: Handle single vs dual passing regions */ + + if (bottomleft.read_delay =3D=3D topright.read_delay) { + /* + * Single region: Use midpoint with temperature compensation. + * Gaplow approximates upper boundary of valid region. + * + * rx + * 127 ^ + * | gaplow (approx. topright) + * | | + * rxhigh -----------xxxxxxx| failing + * | xxxxxxx| region + * | xxxxxxx| <---------------> + * | xxxxxxx| +++++++++++++++++ + * | xxxxxxxxx ++++++++++++++++ + * | xxxxxxxxxx +++++++++++++++ + * | xxxxxxxxxxx ++++++++++++++ + * | xxxxxxxxxxxx +++++++++++++ + * | xxxxxxxxxxxxx ++++++++++++ + * | xxxxxxxxxxxxxx +++++++++++ + * | xxxxxxxxxxxxxxx ++++++++++ + * | xxxxxxxxxxxxxxxx +++++++++ + * | xxxxxxxxxxxxxxxxx ++++++++ + * rxlow -----------xxxxxxxxxxxxxxxxxx +++++++ + * | * | + * | bottom|left | + * --------|----------------------------|---> tx + * 0 | | 127 + * | | + * txlow txhigh + * (same read_delay) + * + * Temperature compensation: Valid region shifts with temp. + * Offset =3D region_size / (330 / (temp - 42=C2=B0C)) + * Factor 330 is empirically determined for this hardware. + */ + + dev_dbg(dev, + "bottomleft and topright at the same read delay.\n"); + + topright =3D gaplow; + searchpoint.read_delay =3D bottomleft.read_delay; + searchpoint.tx =3D + bottomleft.tx + ((topright.tx - bottomleft.tx) / 2); + searchpoint.rx =3D + bottomleft.rx + ((topright.rx - bottomleft.rx) / 2); + + ret =3D cqspi_get_temp(&temp); + if (ret) { + /* Assume room temperature if sensor unavailable */ + dev_dbg(dev, + "Unable to get temperature. Assuming room temperature\n"); + temp =3D CQSPI_PHY_DEFAULT_TEMP; + } + + if (temp < CQSPI_PHY_MIN_TEMP || temp > CQSPI_PHY_MAX_TEMP) { + dev_err(dev, + "Temperature outside operating range: %dC\n", + temp); + ret =3D -EINVAL; + goto out; + } + + if (temp =3D=3D CQSPI_PHY_MID_TEMP) + temp++; /* Avoid divide-by-zero */ + dev_dbg(dev, "Temperature: %dC\n", temp); + + /* + * Apply temperature offset: positive at high temp, negative at low. + * Compute the divisor once and apply to both TX and RX. Use int + * arithmetic throughout to avoid u8 wrapping on negative offsets. + */ + temp =3D 330 / (temp - CQSPI_PHY_MID_TEMP); + searchpoint.tx =3D clamp((int)searchpoint.tx + + (topright.tx - bottomleft.tx) / temp, + 0, CQSPI_PHY_MAX_DELAY); + searchpoint.rx =3D clamp((int)searchpoint.rx + + (topright.rx - bottomleft.rx) / temp, + 0, CQSPI_PHY_MAX_DELAY); + } else { + /* + * Dual regions: Gap separates two valid regions, choose larger. + * + * rx + * 127 ^ + * | topright + * | * + * rxhigh -----------xxxxx +++++++++++++++++++| + * | xxxxxx ++++++++| + * | xxxxxxx +++++++++++++++++| + * | xxxxxxxx ++++++++++++++++| + * | xxxxxxxxx +++++++++++++++| + * | xxxxxxxxxx ++++++++++++++| + * | failing | + * | region | + * | xxxxxxxxxxxxx +++++++++++| + * | xxxxxxxxxxxxxx ++++++++++| + * | xxxxxxxxxxxxxxx +++++++++| + * | xxxxxxxxxxxxxxxx ++++++++| + * | xxxxxxxxx +++++++| + * rxlow -----------xxxxxxxxxxxxxxxxxx ++++++| + * | * | + * | bottom|left | + * --------|----------------------------|---> tx + * 0 | | 127 + * | | + * txlow txhigh + * + * Strategy: Compare Manhattan distances from gap boundaries to + * corners. Choose corner furthest from gap (larger region). + * Apply 16-tap margin inward, scale RX proportionally. + */ + + cqspi_phy_find_gaphigh_ddr(f_pdata, mem, &bottomleft, + &topright, &gaphigh); + dev_dbg(dev, "gaphigh: RX: %d TX: %d RD: %d\n", gaphigh.rx, + gaphigh.tx, gaphigh.read_delay); + + if (topright.tx =3D=3D bottomleft.tx) { + dev_err(dev, "zero TX span in dual-region: cannot compute search point\= n"); + ret =3D -EINVAL; + goto out; + } + + /* Compare Manhattan distances: choose corner furthest from gap */ + if ((abs(gaplow.tx - bottomleft.tx) + + abs(gaplow.rx - bottomleft.rx)) < + (abs(gaphigh.tx - topright.tx) + + abs(gaphigh.rx - topright.rx))) { + /* Topright further: Use Region 2, 16 taps inward */ + searchpoint =3D topright; + searchpoint.tx -=3D 16; + searchpoint.rx -=3D (16 * (topright.rx - bottomleft.rx)) / + (topright.tx - bottomleft.tx); + } else { + /* Bottomleft further: Use Region 1, 16 taps inward */ + searchpoint =3D bottomleft; + searchpoint.tx +=3D 16; + searchpoint.rx +=3D (16 * (topright.rx - bottomleft.rx)) / + (topright.tx - bottomleft.tx); + } + } + + /* Apply and verify final tuning point */ + dev_dbg(dev, "Final tuning point: RX: %d TX: %d RD: %d\n", + searchpoint.rx, searchpoint.tx, searchpoint.read_delay); + ret =3D cqspi_phy_apply_setting(f_pdata, &searchpoint); + if (!ret) + ret =3D cqspi_phy_check_pattern(f_pdata, mem); + + if (ret) { + dev_err(dev, + "Failed to find pattern at final calibration point\n"); + ret =3D -EINVAL; + goto out; + } + + f_pdata->phy_setting.read_delay =3D searchpoint.read_delay; + f_pdata->phy_setting.rx =3D searchpoint.rx; + f_pdata->phy_setting.tx =3D searchpoint.tx; +out: + if (ret) + f_pdata->use_tuned_phy =3D false; + + return ret; +} + +static int cqspi_phy_tuning_sdr(struct cqspi_flash_pdata *f_pdata, + struct spi_mem *mem) +{ + struct cqspi_st *cqspi =3D f_pdata->cqspi; + struct device *dev =3D &cqspi->pdev->dev; + struct phy_setting rxlow, rxhigh, first, second, final; + u8 window1 =3D 0; + u8 window2 =3D 0; + int ret; + + /* + * SDR tuning: 1D search for optimal RX delay (TX less critical). + * Find two consecutive windows, choose larger, use midpoint. + * + * rx + * 127 ^ + * | |-----window at----------| + * | |-----read_delay =3D n+1---| + * | |xxxxxxxxxxxxxxxxxxxxxxxx| + * | |xxxxxxxxxxxxxxxxxxxxxxxx| + * | |xxxxxxxxxxxxxxxxxxxxxxxx| + * | |xxxxxxxxxxxxxxxxxxxxxxxx| + * | |xxxxxxxxxxxxxxxxxxxxxxxx| + * | rxlow(n+1) midpoint rxhigh(n+1) + * | + * | |---window at--------| + * | |---read_delay =3D n---| + * | |xxxxxxxxxxxxxxxxxxxx| + * | |xxxxxxxxxxxxxxxxxxxx| + * | |xxxxxxxxxxxxxxxxxxxx| + * | |xxxxxxxxxxxxxxxxxxxx| + * | |xxxxxxxxxxxxxxxxxxxx| + * | rxlow(n) midpoint rxhigh(n) + * | + * -----------------------------------------> tx + * 0 127 + * read_delay=3Dn read_delay=3Dn+1 + */ + + f_pdata->use_tuned_phy =3D true; + cqspi_phy_reset_setting(&rxlow); + cqspi_phy_reset_setting(&rxhigh); + cqspi_phy_reset_setting(&first); + + /* First window: Find rxlow by incrementing read_delay from 0 */ + + /* + * rx + * 127 ^ + * | |xxxxxxxxxxxxxxxxxxxx| + * search | |xxxxxxxxxxxxxxxxxxxx| + * rxlow | |xxxxxxxxxxxxxxxxxxxx| + * increasing | |xxxxxxxxxxxxxxxxxxxx| + * --------->|xxxxxxxxxxxxxxxxxxxx| + * read_delay | |xxxxxxxxxxxxxxxxxxx| + * until found | |xxxxxxxxxxxxxxxxxxx| + * | rxlow + * -----------------------------------------> tx + * 0 tx fixed at 127 + */ + + do { + ret =3D cqspi_find_rx_low_sdr(f_pdata, mem, &rxlow); + + if (ret) + rxlow.read_delay++; + } while (ret && rxlow.read_delay <=3D CQSPI_PHY_MAX_RD); + + /* Find rxhigh: Decrement from RX=3D127 at same read_delay */ + + /* + * rx + * 127 ^ search rxhigh + * | (decrement from + * | 127 until found) + * | | + * | | + * | v + * | |------------------------| + * | |xxxxxxxxxxxxxxxxxxxxxxxx| + * | |xxxxxxxxxxxxxxxxxxxxxxxx| + * | |xxxxxxxxxxxxxxxxxxxxxxxx| + * | |xxxxxxxxxxxxxxxxxxxxxxxx| + * | |xxxxxxxxxxxxxxxxxxxxxxxx| + * | rxlow rxhigh + * -----------------------------------------> tx + * 0 tx fixed at 127 + */ + + rxhigh.read_delay =3D rxlow.read_delay; + ret =3D cqspi_find_rx_high_sdr(f_pdata, mem, &rxhigh, rxlow.rx); + if (ret) + goto out; + + /* Calculate first window midpoint for max margin */ + + /* + * rx + * 127 ^ + * | |--------window1---------| + * | |xxxxxxxxxxxxxxxxxxxxxxxx| + * | |xxxxxxxxxxxxxxxxxxxxxxxx| + * | |xxxxxxxxxxx * xxxxxxxxxx| + * | |xxxxxxxxxxxxxxxxxxxxxxxx| + * | |xxxxxxxxxxxxxxxxxxxxxxxx| + * | rxlow ^ rxhigh + * ----------------------|------------------> tx + * 0 | tx fixed at 127 + * window1/2 + */ + + first.read_delay =3D rxlow.read_delay; + window1 =3D rxhigh.rx - rxlow.rx; + first.rx =3D rxlow.rx + (window1 / 2); + + dev_dbg(dev, "First tuning point: RX: %d TX: %d RD: %d\n", first.rx, + first.tx, first.read_delay); + ret =3D cqspi_phy_apply_setting(f_pdata, &first); + if (!ret) + ret =3D cqspi_phy_check_pattern(f_pdata, mem); + + if (ret || first.read_delay > CQSPI_PHY_MAX_RD) + goto out; + + /* Second window: Search at read_delay+1, may differ in size */ + + /* + * rx + * 127 ^ + * | |-------| + * | |xxxxxxx| + * | |xxxxxxx| + * | |xxxxxxx| + * | |xxxxxxx| + * | |xxxxxxx| + * | rxlow rxhigh + * -----------------------------------------> tx + * 0 + * read_delay =3D n (smaller window) + * + * rx + * 127 ^ + * | |-----------------| + * | |xxxxxxxxxxxxxxxxx| + * | |xxxxxxxxxxxxxxxxx| + * | |xxxxxxxxxxxxxxxxx| + * | |xxxxxxxxxxxxxxxxx| + * | |xxxxxxxxxxxxxxxxx| + * | rxlow rxhigh + * -----------------------------------------> tx + * 0 + * read_delay =3D n+1 (larger window - better) + */ + + cqspi_phy_reset_setting(&rxlow); + cqspi_phy_reset_setting(&rxhigh); + cqspi_phy_reset_setting(&second); + + rxlow.read_delay =3D first.read_delay + 1; + if (rxlow.read_delay > CQSPI_PHY_MAX_RD) + goto compare; + + ret =3D cqspi_find_rx_low_sdr(f_pdata, mem, &rxlow); + if (ret) + goto compare; + + rxhigh.read_delay =3D rxlow.read_delay; + ret =3D cqspi_find_rx_high_sdr(f_pdata, mem, &rxhigh, rxlow.rx); + if (ret) + goto compare; + + /* Calculate second window midpoint */ + + /* + * rx + * 127 ^ + * | |--------window2---------| + * | |xxxxxxxxxxxxxxxxxxxxxxxx| + * | |xxxxxxxxxxxxxxxxxxxxxxxx| + * | |xxxxxxxxxxx * xxxxxxxxxx| + * | |xxxxxxxxxxxxxxxxxxxxxxxx| + * | |xxxxxxxxxxxxxxxxxxxxxxxx| + * | rxlow ^ rxhigh + * ----------------------|------------------> tx + * 0 | tx fixed at 127 + * window2/2 + * read_delay =3D n+1 + */ + + window2 =3D rxhigh.rx - rxlow.rx; + second.rx =3D rxlow.rx + (window2 / 2); + second.read_delay =3D rxlow.read_delay; + + dev_dbg(dev, "Second tuning point: RX: %d TX: %d RD: %d\n", second.rx, + second.tx, second.read_delay); + ret =3D cqspi_phy_apply_setting(f_pdata, &second); + if (!ret) + ret =3D cqspi_phy_check_pattern(f_pdata, mem); + + if (ret || second.read_delay > CQSPI_PHY_MAX_RD) + window2 =3D 0; + + /* Window comparison: Choose larger window for better margin */ + +compare: + cqspi_phy_reset_setting(&final); + if (window2 > window1) { + final.rx =3D second.rx; + final.read_delay =3D second.read_delay; + } else { + final.rx =3D first.rx; + final.read_delay =3D first.read_delay; + } + + /* Apply and verify final tuning point */ + + dev_dbg(dev, "Final tuning point: RX: %d TX: %d RD: %d\n", final.rx, + final.tx, final.read_delay); + ret =3D cqspi_phy_apply_setting(f_pdata, &final); + if (!ret) + ret =3D cqspi_phy_check_pattern(f_pdata, mem); + + if (ret) { + ret =3D -EINVAL; + goto out; + } + + f_pdata->phy_setting.read_delay =3D final.read_delay; + f_pdata->phy_setting.rx =3D final.rx; + f_pdata->phy_setting.tx =3D final.tx; + +out: + if (ret) + f_pdata->use_tuned_phy =3D false; + + return ret; +} + +static int cqspi_am654_ospi_execute_tuning(struct spi_mem *mem, + struct spi_mem_op *read_op, + struct spi_mem_op *write_op) +{ + struct cqspi_st *cqspi =3D + spi_controller_get_devdata(mem->spi->controller); + struct cqspi_flash_pdata *f_pdata; + struct device *dev =3D &cqspi->pdev->dev; + int ret; + + f_pdata =3D &cqspi->f_pdata[spi_get_chipselect(mem->spi, 0)]; + + /* + * spi-max-post-config-frequency-hz must be present for PHY tuning. + * If absent, post_config_max_speed_hz is zero and there is no + * calibration target, so skip tuning gracefully. + */ + if (!mem->spi->post_config_max_speed_hz) { + dev_dbg(dev, + "No post-config frequency configured, skipping tuning\n"); + return -EOPNOTSUPP; + } + + if (write_op) { + /* + * For NAND: write the calibration pattern to the page cache. + * The write op runs at the conservative base speed (spi->max_speed_hz) + * so the write itself is reliable before PHY calibration. + */ + ret =3D cqspi_write_pattern_to_cache(f_pdata, mem, write_op); + if (ret) { + dev_warn(dev, + "failed to write pattern to cache: %d, skipping tuning\n", + ret); + goto out; + } + + f_pdata->phy_write_op =3D *write_op; + } else { + if (!f_pdata->phy_pattern_partition_offset) { + dev_warn(dev, "pattern partition not found, skipping tuning\n"); + goto out; + } + read_op->addr.val =3D f_pdata->phy_pattern_partition_offset; + } + + /* + * Verify the calibration pattern exists using the conservative base + * speed. At high clock rates the DLL is not yet trained, so DTR + * data capture is unreliable and the read would return garbage. + * Setting max_freq to 0 causes spi_mem_adjust_op_freq() to cap the + * read to max_speed_hz (the base rate), well within reliable DTR + * margins. max_freq is set to post_config_max_speed_hz below after + * the pattern is confirmed, so the tuning-loop reads run at full rate. + */ + f_pdata->phy_read_op =3D *read_op; + f_pdata->phy_read_op.max_freq =3D 0; + + ret =3D cqspi_phy_check_pattern(f_pdata, mem); + if (ret) { + dev_err(dev, "pattern not found: %d, skipping tuning\n", ret); + goto out; + } + + /* + * Pattern confirmed. Set phy_read_op.max_freq to + * post_config_max_speed_hz so that tuning-loop reads bypass the base + * frequency cap in spi_mem_adjust_op_freq() and run at the full + * calibration rate. + */ + f_pdata->phy_read_op.max_freq =3D mem->spi->post_config_max_speed_hz; + + if (read_op->cmd.dtr || read_op->addr.dtr || read_op->dummy.dtr || + read_op->data.dtr) { + f_pdata->use_dqs =3D true; + cqspi_phy_pre_config(cqspi, f_pdata, false); + ret =3D cqspi_phy_tuning_ddr(f_pdata, mem); + } else { + f_pdata->use_dqs =3D false; + cqspi_phy_pre_config(cqspi, f_pdata, true); + ret =3D cqspi_phy_tuning_sdr(f_pdata, mem); + } + + if (ret) + dev_warn(dev, "tuning failed: %d\n", ret); + + cqspi_phy_post_config(cqspi, f_pdata->read_delay); + +out: + /* + * On success, write back the validated maximum speed into the caller's + * op templates so that those specific ops bypass the cap in subsequent + * exec_op calls. + */ + if (!ret) { + read_op->max_freq =3D mem->spi->post_config_max_speed_hz; + if (write_op) + write_op->max_freq =3D mem->spi->post_config_max_speed_hz; + } + + return ret; +} + +static int cqspi_mem_op_execute_tuning(struct spi_mem *mem, + struct spi_mem_op *read_op, + struct spi_mem_op *write_op) +{ + struct cqspi_st *cqspi =3D + spi_controller_get_devdata(mem->spi->controller); + + if (!cqspi->ddata->execute_tuning) + return -EOPNOTSUPP; + + return cqspi->ddata->execute_tuning(mem, read_op, write_op); +} + static int cqspi_of_get_flash_pdata(struct platform_device *pdev, struct cqspi_flash_pdata *f_pdata, struct device_node *np) { + struct device_node *part_np; + if (of_property_read_u32(np, "cdns,read-delay", &f_pdata->read_delay)) { dev_err(&pdev->dev, "couldn't determine read-delay\n"); return -ENXIO; @@ -1588,9 +3307,11 @@ static int cqspi_of_get_flash_pdata(struct platform_= device *pdev, return -ENXIO; } =20 - if (of_property_read_u32(np, "spi-max-frequency", &f_pdata->clk_rate)) { - dev_err(&pdev->dev, "couldn't determine spi-max-frequency\n"); - return -ENXIO; + part_np =3D of_parse_phandle(np, "spi-phy-pattern-partition", 0); + if (part_np) { + of_property_read_u32_index(part_np, "reg", 0, + &f_pdata->phy_pattern_partition_offset); + of_node_put(part_np); } =20 return 0; @@ -1740,6 +3461,7 @@ static const struct spi_controller_mem_ops cqspi_mem_= ops =3D { .exec_op =3D cqspi_exec_mem_op, .get_name =3D cqspi_get_name, .supports_op =3D cqspi_supports_mem_op, + .execute_tuning =3D cqspi_mem_op_execute_tuning, }; =20 static const struct spi_controller_mem_caps cqspi_mem_caps =3D { @@ -2108,6 +3830,7 @@ static const struct cqspi_driver_platdata k2g_qspi = =3D { static const struct cqspi_driver_platdata am654_ospi =3D { .hwcaps_mask =3D CQSPI_SUPPORTS_OCTAL | CQSPI_SUPPORTS_QUAD, .quirks =3D CQSPI_NEEDS_WR_DELAY, + .execute_tuning =3D cqspi_am654_ospi_execute_tuning, }; =20 static const struct cqspi_driver_platdata intel_lgm_qspi =3D { --=20 2.34.1 From nobody Fri Jul 24 21:53:02 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 3F0E445A2B4; Thu, 23 Jul 2026 11:03:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=148.163.150.75 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784804629; cv=fail; b=NHN4bK7vBvOllrlsk7+UGhTIzUsT2uYSe403AClrAjnM8fn9lGMbvCLnWcqnseU3nGN3k3Dz280ZeZ9oxQjvII/tJB55ACVu2iu6sM4L/u8+7P+scCxy8+qyt/jPrb9Imlcx3IbytRH8KvmDVPiNwngC4Z6suhjsvAPTRtSOXvI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784804629; c=relaxed/simple; bh=9DQhRF1G/rF0B5GALQ3EZyhGRvGzHOF8xUyHuxCZA/c=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=jzM0dJwuT2xeVwZYuBcCWTeX/rvkbrh5GFu4ymlBfFXia5y7zJfLoTELanICElfS5Fd1G2JZgtmDtr6eCdv82vsVBCFEYoq7nKzHkl7PKEg5NB1O+i13jKjjx2WwkfOL46VS6NDTkPU9EeU2bjaSqLaPlxlno2U/50CqwnOfEgA= 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=V66wGVZE; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=O//rqZ+5; 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="V66wGVZE"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="O//rqZ+5" 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 66N9IB1w2039762; Thu, 23 Jul 2026 06:03:35 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint-05-2026; bh=teGB7+PbNvdPrr/+A55A/D2LxX4bde9Z29W1r+wtn fA=; b=V66wGVZEXsnIzMnHz2e/YacWW7d/PfYC7xYCzPfjQbc9Axeq1zgdjwGIA HVHa8ECtfPJxxnL8aSkMIicVyZtGI+b0e7+86AttACbzJuh9C4vo5ELU3yUGGsmA mgVWYgvRB1i6Lc/EH4SZa7SQErXK8M0mPeKazBIZ79CmNTHiSyK3FdIqIcvNLhL9 8GQuuJdrqAQsHKls8fce6gE9APthjJejpCVDTOVBcY4fSHlqh/rzV1EFIBFmwAVK BNPAhdKCX/zQvALpldKfN9cMTO7zvQlaSZBDRXNsGa4weQMxXgV23ueP2k4ChlVB tIC64nMCE0xVXPjlz453OE0SPT3SQ== Received: from co1pr03cu002.outbound.protection.outlook.com (mail-westus2azon11010043.outbound.protection.outlook.com [52.101.46.43]) by m0380145.ppops.net (PPS) with ESMTPS id 4fkg730c67-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 23 Jul 2026 06:03:35 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=GT3v2yGULrhZC4Asue2L/H8h/34Ipi0HAKIBrwX3ISX3Bwk1OJEX4QoS91vjJ3Vr0zXpRArRIs89Ta0aHI1gqHcJH3B5Abi4C2FNPK6+4d4Klic6rePMuPj6Wwfva1Wk6JGgUg3GtZIHbEGBStupHCy3uNhC68AguVzOunUP3GLUc8vHTvs5maDjUiNlJgMqw0IfH7PCrKvDW1HRUSTaBcd1IJ5M95KPmiqn4+o0HaEmHj004PUjPrVLygj/4ep1m3tY4eBZFnPk+LOtm1/k92/gVtnIoOpgV4Wfmx7lS84TxBiKgEqcgEoRGHmmTuyDOaSGW88/T0tV+L+IWXDubg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=teGB7+PbNvdPrr/+A55A/D2LxX4bde9Z29W1r+wtnfA=; b=MjixRk3KEx57Rkjy3z34UyVZO1Jdllki1jz7Ztz4PXwVOEto9ki7zxJEMJ0su7BzVCTmkUGNSIC9avvecNTOwjTTlLkkLSGbjTQQHW2RiSgqLVqGEOAd9oMoYsHMlZwaeQalICaAubiFBXE/JLevpAj3Jyj1Y4isgEaHujNJTlBun8N15RLCUGLgcejvlQqk8EhWzgk5FkY5N3cAsyl08ufQklRTwnVFSkbBzM7YZMK+lLxZLMZK7dlsR1q/CO9TZeWlkQ8bTeuHIpSJ68O181x7f2FQDE5XqB3ywkMEIRGC7OT53cTHmV4322ERnDbGVZyytfwIihIMKbh6SS5EDA== 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=teGB7+PbNvdPrr/+A55A/D2LxX4bde9Z29W1r+wtnfA=; b=O//rqZ+5PnfL6maTqtuGYFbpr6GLlA514FlJ+n3VY3bbRDppMLlqafB4HAD/VWUh9o6umrv9YK7QkXr6uYR6zrVBM8lBS8eDRaV40J+dGbl7CIohaYIfXSPlDjFIlYF+Fa5pGYtQmMzLLbyyBd3TwvIqqBqjeHyOefkKuIL8qrw= Received: from SJ0PR03CA0274.namprd03.prod.outlook.com (2603:10b6:a03:39e::9) by MW4PR10MB6678.namprd10.prod.outlook.com (2603:10b6:303:22c::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.245.11; Thu, 23 Jul 2026 11:03:30 +0000 Received: from SJ1PEPF000023D3.namprd21.prod.outlook.com (2603:10b6:a03:39e:cafe::52) by SJ0PR03CA0274.outlook.office365.com (2603:10b6:a03:39e::9) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.245.11 via Frontend Transport; Thu, 23 Jul 2026 11:03:30 +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 SJ1PEPF000023D3.mail.protection.outlook.com (10.167.244.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.270.0 via Frontend Transport; Thu, 23 Jul 2026 11:03:28 +0000 Received: from DFLE210.ent.ti.com (10.64.6.68) by flwvzet201.ext.ti.com (10.248.192.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Thu, 23 Jul 2026 06:03:20 -0500 Received: from DFLE211.ent.ti.com (10.64.6.69) by DFLE210.ent.ti.com (10.64.6.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Thu, 23 Jul 2026 06:03:20 -0500 Received: from lelvem-mr05.itg.ti.com (10.180.75.9) by DFLE211.ent.ti.com (10.64.6.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Thu, 23 Jul 2026 06:03:20 -0500 Received: from santhoshkumark.dhcp.ti.com (santhoshkumark.dhcp.ti.com [10.24.52.55]) by lelvem-mr05.itg.ti.com (8.18.1/8.18.1) with ESMTP id 66NB2OW51577597; Thu, 23 Jul 2026 06:03:15 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , Subject: [PATCH v6 09/17] spi: cadence-quadspi: skip DDR PHY tuning for 2-byte-address ops (i2383) Date: Thu, 23 Jul 2026 16:32:11 +0530 Message-ID: <20260723110219.3180747-10-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260723110219.3180747-1-s-k6@ti.com> References: <20260723110219.3180747-1-s-k6@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF000023D3:EE_|MW4PR10MB6678:EE_ X-MS-Office365-Filtering-Correlation-Id: 09785edc-e485-4207-bee0-08dee8aa06a8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|36860700016|82310400026|23010399003|1800799024|6133799003|13003099007|56012099006|18002099003|22082099003|921020|10067099003; X-Microsoft-Antispam-Message-Info: bf8C1DT7VQ1B8e0PMVbJ+XYevEdE3Bcl5wuMv1b0Ld5eiQ3jLagfyPw9kW7UJ84N2zMZrtcR2jKdgz+CXore4LeTFeLB0BXjxQbvCnGMMUf3Gs6o3wMPjM4lFQ4+lsqxBDZNSR12MfPpLq9Rrtgzv4zBvVUr4vspzDDH5cW0YG+6b4YpUU1whrez4WrvQN9AnuzHSK8GgNTAkHp/2rkil09CptA7ERCQd+DN00ODtMkQ0a2tRPEVUzODSs1xgzNQFD4jQr6nhRljYPLd9UkdzU12xEFc05jSv8bmCsxYiAI5F5Eku1liFEFH/KpQWJasv1Kv9b4snT0yxHlH6jHzAx3zve97WyOaPf96EFgg2JA6W2MK8lRfcAotphhcG9TGHfNLEjCVQuHzo83NA0WFr2vyVlpDSFbqzoo57InFXI9PW94IGGpfWVWL37mxGYRH7p9gvtDqIPjYRCklsNVhi9XDKCXMFgFkwP2Urh/Rb1oV78UqvXO9+GWCFzMYTFn1XpsfHvrj7ZdtC8bA6vpEqdMh7yOWVrtXBA3Q4URVI9jH0kBkbf4+05g1W8xfOURxajgO4/Rs/OMU/IefO+bcA0BPDDT+BpXDjQFErmAUut/A+JuXl1Dg3I8yIZtATmeBJyPNs77zenijXda2TX9/RgK7EPhBUFQKFtRqR4TFKhKygC8DZlCu2WNidZsR/LPuurK7945aiCTFv8tNKT0K6w== 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)(6133799003)(13003099007)(56012099006)(18002099003)(22082099003)(921020)(10067099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: L27yr59aLdFTNzIZ4G5fwscvE1oGGXuhW+Bc27U5XCCJsT38DyY+dUXYdpGPd80R91krn+W9WKiqYITEWx4hSggOxVm0/hBWfp5h87wWNln+CL+TzklGPjZg9fockJHUz9jn/4GBFQwoc0wi099cuIW++sRdIVtQjt/hF4BOj0Q+ozKCISuFso+Uu6+8Oq5/LsbIrV6BjEPxWUKcn1nsdejScQd5C1Cycsu0hgNn9rez7UtOdizbo/R7/Iyy89hRENmyqMaCIDgLOElUk1+BqwMEkgMXdDEm+Qr0EPgkjPyCAk5g6oWrEiLTdc3FRa9V67HTkKm21SVRbap0yba3dD+k30JNTfQI4OB5owJ5a/SNhZlC+A0ce0VSZZGLl91qNGefbhNeBbzFjUYlaDvzBzLu966pMmPmQn2BLwr6TL/sdAPot03Rwslf8cZrw3kU X-Exchange-RoutingPolicyChecked: o6b8zM96Rx+R6lMKynBukXAt6ZJ4EUmupBySzuTWiWZImCzawW7jMC9erIZgfeOPC32HV6fJScsK7/BaZZZV7xKmkwnAB/mgZTSq8NyKE2aC+ESOYAG71uejOz5B013LDidPy+ir/uFlvlOfsu4gSMhiUCBQvDR91dHrMURPhZAx6r+pJ5GRSzzIxaf/C3SIAtuvWvDNpc8vH/3KXv82n62GnsMTp6O6TxMxZ/cO7yqU+7Zh1JXtoLLyQIAQHUojl4Xtik8beSgRw/AVOYFDPDLL7ZXhoUIUDgSNVZ2qY26socRjgpeScF4ZbTqiIy0PJzAcXZxMu77+PmqZWxOACg== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jul 2026 11:03:28.5704 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 09785edc-e485-4207-bee0-08dee8aa06a8 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: SJ1PEPF000023D3.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR10MB6678 X-Proofpoint-Spam-Info: AW1haW4tMjYwNzIzMDEwOCBTYWx0ZWRfX6NvJoxKgXZEL AEpAQ1ENe6DxUEXl4ASD16yy6i9gJWrWlHUzB12qG4H2AldwfjBxj6RPqh8VCfddlAMNzc3jDR1 3D2KHQFRP9Fe17WK0RAHgDn9mR8JJ00= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzIzMDEwOCBTYWx0ZWRfX8KG7g3XCoLiY NtRamrE2JMu0foTEzldS8IXM4o5osSaSpPYPgFkYCJYzhPBeWY9UllijfYc5bNkao11qOu7u29o XJIQjKDxbIE/dM9uYgftviGWER0fMa0YkeISRb0JjqvGBPyf8V+Tx7KQjirDUo36kFlR4m0yKrp i9l8MMEOkd6iIIOTjWVOP6oZCQn2KZeY16P/sQu2GkVyE6yVudoPiasRPiQKdfahOxwDRGEWF9C YQ/sGQSFALfSe7sAjF6HdAtFpAAUjAPIrLuFe6EY2bQSzsUC7QIgDmEvuwYARLQlggB5Zb3mfBc pGof85LT26xJjPa+ZH77K8Wkzio55vcaynTRfKfOTsCCgDoMzW1zPysWEks8xZ0pM9Zt0eFxHFU VGtCAEx7kOnTmgLd5tHKUAt8KhT1MT4NtoifHXij9uSoqqQ2MWVFCbA+Qa/lOU/3qRdOCMgnPb2 huyS3tr0siMpWUm9kqg== X-Proofpoint-GUID: 6qG5UXoWv6BUzgG5X5p6lbGlgKTLjKO7 X-Proofpoint-ORIG-GUID: 6qG5UXoWv6BUzgG5X5p6lbGlgKTLjKO7 X-Authority-Analysis: v=2.4 cv=Z/Dc2nRA c=1 sm=1 tr=0 ts=6a61f507 cx=c_pps a=BNrqkoHBqsJX0pt4tOnUqg==:117 a=tJyPKKxUohctrY4NYmUjkA==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=IkcTkHD0fZMA:10 a=RAioF0-LDSMA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=gO1vWkAQAl3rybz1DQOp:22 a=sozttTNsAAAA:8 a=T-kh0MV4vbdY-aS4Zb4A:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-23_03,2026-07-22_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 lowpriorityscore=0 malwarescore=0 impostorscore=0 bulkscore=0 adultscore=0 clxscore=1015 priorityscore=1501 spamscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607230108 Erratum i2383 on AM654 locks the address phase in PHY DDR mode when a 2-byte column address is used. DDR PHY tuning must not be attempted for such operations; non-PHY DDR usage is unaffected. [0] Add CQSPI_NO_PHY_TUNING_WITH_ODDR_2B_ADDR quirk and check it in cqspi_am654_ospi_execute_tuning(). When the erratum applies, return 0 with read_op->max_freq cleared =E2=80=94 the op-skip signal that tells the caller to try another op variant. [0] https://www.ti.com/lit/er/sprz544c/sprz544c.pdf Signed-off-by: Santhosh Kumar K --- drivers/spi/spi-cadence-quadspi.c | 43 +++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-qu= adspi.c index 22a5c88bbd8d..5070ffc53d5e 100644 --- a/drivers/spi/spi-cadence-quadspi.c +++ b/drivers/spi/spi-cadence-quadspi.c @@ -37,19 +37,20 @@ static_assert(CQSPI_MAX_CHIPSELECT <=3D SPI_DEVICE_CS_CNT_MAX); =20 /* Quirks */ -#define CQSPI_NEEDS_WR_DELAY BIT(0) -#define CQSPI_DISABLE_DAC_MODE BIT(1) -#define CQSPI_SUPPORT_EXTERNAL_DMA BIT(2) -#define CQSPI_NO_SUPPORT_WR_COMPLETION BIT(3) -#define CQSPI_SLOW_SRAM BIT(4) -#define CQSPI_NEEDS_APB_AHB_HAZARD_WAR BIT(5) -#define CQSPI_RD_NO_IRQ BIT(6) -#define CQSPI_DMA_SET_MASK BIT(7) -#define CQSPI_SUPPORT_DEVICE_RESET BIT(8) -#define CQSPI_DISABLE_STIG_MODE BIT(9) -#define CQSPI_DISABLE_RUNTIME_PM BIT(10) -#define CQSPI_NO_INDIRECT_MODE BIT(11) -#define CQSPI_HAS_WR_PROTECT BIT(12) +#define CQSPI_NEEDS_WR_DELAY BIT(0) +#define CQSPI_DISABLE_DAC_MODE BIT(1) +#define CQSPI_SUPPORT_EXTERNAL_DMA BIT(2) +#define CQSPI_NO_SUPPORT_WR_COMPLETION BIT(3) +#define CQSPI_SLOW_SRAM BIT(4) +#define CQSPI_NEEDS_APB_AHB_HAZARD_WAR BIT(5) +#define CQSPI_RD_NO_IRQ BIT(6) +#define CQSPI_DMA_SET_MASK BIT(7) +#define CQSPI_SUPPORT_DEVICE_RESET BIT(8) +#define CQSPI_DISABLE_STIG_MODE BIT(9) +#define CQSPI_DISABLE_RUNTIME_PM BIT(10) +#define CQSPI_NO_INDIRECT_MODE BIT(11) +#define CQSPI_HAS_WR_PROTECT BIT(12) +#define CQSPI_NO_PHY_TUNING_WITH_ODDR_2B_ADDR BIT(13) =20 /* Capabilities */ #define CQSPI_SUPPORTS_OCTAL BIT(0) @@ -3183,6 +3184,20 @@ static int cqspi_am654_ospi_execute_tuning(struct sp= i_mem *mem, return -EOPNOTSUPP; } =20 + /* + * Erratum i2383: in PHY DDR mode, a 2-byte column address locks up + * the address phase. Skip DDR PHY tuning for such operations. + */ + if ((cqspi->ddata->quirks & CQSPI_NO_PHY_TUNING_WITH_ODDR_2B_ADDR) && + read_op->addr.nbytes =3D=3D 2 && + (read_op->cmd.dtr || read_op->addr.dtr || read_op->dummy.dtr || + read_op->data.dtr)) { + dev_dbg(dev, + "i2383: skipping DDR PHY tuning (2-byte address)\n"); + read_op->max_freq =3D 0; + return 0; + } + if (write_op) { /* * For NAND: write the calibration pattern to the page cache. @@ -3829,7 +3844,7 @@ static const struct cqspi_driver_platdata k2g_qspi = =3D { =20 static const struct cqspi_driver_platdata am654_ospi =3D { .hwcaps_mask =3D CQSPI_SUPPORTS_OCTAL | CQSPI_SUPPORTS_QUAD, - .quirks =3D CQSPI_NEEDS_WR_DELAY, + .quirks =3D CQSPI_NEEDS_WR_DELAY | CQSPI_NO_PHY_TUNING_WITH_ODDR_2B_ADDR, .execute_tuning =3D cqspi_am654_ospi_execute_tuning, }; =20 --=20 2.34.1 From nobody Fri Jul 24 21:53:02 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 7167A45DF74; Thu, 23 Jul 2026 11:03:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=148.163.150.75 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784804628; cv=fail; b=oGsZksMtb3F9XruxycKcoVjqJWNwtLLzXXmStcj6xFxMoO4DtihFtI0RCgTpX/ytYbTSKnZgi4h+kXLnvhmfk58aUY+a52orfOUSGfPgWVo4IggLckehu9ME+yjMEEK9UkpHKNFUNe1MxnBqVsAAUMXKvMHxo9Akmra6jnwyiVo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784804628; c=relaxed/simple; bh=r6mmBI47kM6LbC2TeTm5XGDNze+9ICvcqteBVTKQmZc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Wy87AdnBBAu0vbuNel4K9mpOx67JE6DjOPYhrx7zTg/RkN4uJ6ievtoie+tLW+4exgOduHFkMZMAQsDzvD4nCbLkmzoFrICTPEuB3pYB8H+jb3c72COvTOmjXCp6oRomXjHeb6YJTGhfqOa+owvOOBndOmq7dZT9OemhJ8M5SAM= 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=Ob32Ofdq; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=qdtNu324; 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="Ob32Ofdq"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="qdtNu324" 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 66N9I8xa2039510; Thu, 23 Jul 2026 06:03:34 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint-05-2026; bh=Jn4J4+v73YafNI7rjY+a4Pdbl5UXyUH8s/LMgvnmx Js=; b=Ob32Ofdqu5D8YdQQkTgSQcOjcOdIkpRjd/u1lsoeqccSmu7oj2b5wBJXI wAZTe5I09QGDVGkB/HNyzFGNJepLskslKzaeyyNtlY8H4o43QWt+JKCBW3Nk/46F 4lmfTte0Wn2egyfMSRKexiseFDBfsNexMHF38lbJH2txZ9Kt+TLfGSFgvOY1SPkm dWfnq8KyMXQ0Vkb+vk+4BgGbFVcxEw0XWtIWiAJ3koleMynVMXyGxVhSBzNHz6ME WdiLc5jRtdlbSQh1YAX9ekMussg5hYt0hGj9kfXXFOzmkHKU/ajvBuursxMPZQVf uEl5DUCF6fkK74wVnSr+DVpsuNfMQ== Received: from co1pr03cu002.outbound.protection.outlook.com (mail-westus2azon11010020.outbound.protection.outlook.com [52.101.46.20]) by m0380145.ppops.net (PPS) with ESMTPS id 4fkg730c64-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 23 Jul 2026 06:03:33 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=G8Xf5fadDUWGdWug1BKcdlmoY9ji++meSo3+uKL5betB9jx/HBlbwTedQukbJw8J1Vm6ns2XyuUOq+4hiN63cCC50b9M5QWNXezLhu0f6Vb/INrQmB0FNkHkmL7nWnN3FwuUYvEV+nKPUMqdVrxPpSFwoW19JDl9aR9PRJlqpPkCy135cOWUR2icB2lFQY6q/ss7oRBqYHZ+19gBmfeWf4qO5XpqMdXKeYdGxNuLD/xk9miZdqYeLydEjzpx5sNlEojWSclT9AptV8j2hEl6p8k9eYCjhTfr0ttB5nDjU0k/Rtz0ehDfuFMhjOKazjjLwvzrrASE/v0MOBcV8O4x+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=Jn4J4+v73YafNI7rjY+a4Pdbl5UXyUH8s/LMgvnmxJs=; b=Edw7XoICT7eltRWxNMiyf4GOtpr5WGwCWkyIO3dxvG1PATxHFO8RTLhO3KXW29FZkYmYqyydpHJd3gFQJFCYx8RWlTOtG6Zz/1/4IYL3z4Y/ZJ1qgZFNaGGiSQpA5Po/BWTiWPT0IUuftu8rI02QRKn8HEnXjLqVWxCGN3ZKLQMh1Ofr1+bkyEHFY9JVTZ77RHv5/Ld4xLKNqqxZ4YDYdQz5swBeq+B0vqOGyl2y+tPY+zBJo+UT9ceRzGFJVWVA02ytyfVYZDdqYLIH/ZPud1z8HEbQ/hwhWw+x8dVdirBSS1aDohORtdVi1gZVzLqLB89eep8qq7yUif8hLf+6DQ== 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=Jn4J4+v73YafNI7rjY+a4Pdbl5UXyUH8s/LMgvnmxJs=; b=qdtNu324tj1MY3XtvPSFedP4UaceXIssFJB2pG8t10VvnRk79d08Vo+85UQFuRt9dUH6kMRKWBjocq8B+pxNywvx/GmRSENSdCP6y3aapQ67Qdk3PBm+/Vk1LC8TizpfuP4wv0fNGWVNDwQCAL++DEguB8K3XNl9N25awU117N4= Received: from BL1PR13CA0171.namprd13.prod.outlook.com (2603:10b6:208:2bd::26) by SN4PR10MB997898.namprd10.prod.outlook.com (2603:10b6:806:4ff::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.223.18; Thu, 23 Jul 2026 11:03:30 +0000 Received: from BL02EPF0001A100.namprd03.prod.outlook.com (2603:10b6:208:2bd:cafe::8e) by BL1PR13CA0171.outlook.office365.com (2603:10b6:208:2bd::26) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.270.5 via Frontend Transport; Thu, 23 Jul 2026 11:03:29 +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 BL02EPF0001A100.mail.protection.outlook.com (10.167.242.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.270.5 via Frontend Transport; Thu, 23 Jul 2026 11:03:29 +0000 Received: from DLEE211.ent.ti.com (157.170.170.113) by lewvzet200.ext.ti.com (10.4.14.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Thu, 23 Jul 2026 06:03:25 -0500 Received: from DLEE214.ent.ti.com (157.170.170.117) by DLEE211.ent.ti.com (157.170.170.113) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Thu, 23 Jul 2026 06:03:25 -0500 Received: from lelvem-mr05.itg.ti.com (10.180.75.9) by DLEE214.ent.ti.com (157.170.170.117) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Thu, 23 Jul 2026 06:03:25 -0500 Received: from santhoshkumark.dhcp.ti.com (santhoshkumark.dhcp.ti.com [10.24.52.55]) by lelvem-mr05.itg.ti.com (8.18.1/8.18.1) with ESMTP id 66NB2OW61577597; Thu, 23 Jul 2026 06:03:20 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , Subject: [PATCH v6 10/17] spi: cadence-quadspi: refactor direct read path for PHY support Date: Thu, 23 Jul 2026 16:32:12 +0530 Message-ID: <20260723110219.3180747-11-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260723110219.3180747-1-s-k6@ti.com> References: <20260723110219.3180747-1-s-k6@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0001A100:EE_|SN4PR10MB997898:EE_ X-MS-Office365-Filtering-Correlation-Id: 01c146c5-ff42-4692-476d-08dee8aa071a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700016|82310400026|7416014|376014|1800799024|23010399003|56012099006|6133799003|10067099003|3023799007|22082099003|18002099003|921020; X-Microsoft-Antispam-Message-Info: tFumcifVa3gzbBGPdI+3uCxHc7A1qQ8uBSVmuhTTNMQpU/CkHS/RAmx9OrfaArfiPlT+Z42GhVbmMRjqWF0tLru2QwGwob31ySqi/bqLmq46ZxFXTlDR6lCdZX5k5EU40rZuPLnGsIJB35bAxE7EZ4aky0OuWNJhqS4S4fPdTUshtlFeqP5F+Mobgp+I6BQjkRDWecviXKgzB6MiQC6lJ5lp4OXa/4ui0+LTJXBrnSgsfJkq9zUMj/RlR4iXWZ7xfILoVC2Qs2MWO/S/A4C1WjbZK3frM0vJe5SmKMylLwfrLnVGYZMANGLpXraJ1BcX1bXdk7kvicHr241xOWRyot1/EEydOsTBEiBVzDHfCaYikWxbnjY7UByMGaiU8fmHYyoqqKET3P5RwvMzmshArMEGSWK2HqQFgfReePW3E9UlNOKK2n4yOFiVEWL6+CfeDTZY+6UcdzhVT4Q1ggaOpDZNKd7zXZ7R1O6SSxYOnR7SReGiR6EfL0QI4xFIrTtbL52ezUAwAE+n3Dd3moHTi8euyt7n43b6eZ7zuZwufOCbfFpMe+OHhGSz7X9EW95X4DzAXK6LqY/GYQdaW8pRmjz2hf/IolKPakx7hBS9qatrpNLTbr1l4UmyCLVx8mDiRuAAn9qycEdo2rOWob5cLt17e5pMqtiw4QqYdvN7vUZ6rB6oI2bJRPMPUz/gCHvP4DA7KEqqj6uugco12IGxuU2Mwr+yUaoz0E5Qlp6Oh4HMly0OHBL5p/4trKhLE05X X-Forefront-Antispam-Report: CIP:198.47.23.194;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:lewvzet200.ext.ti.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700016)(82310400026)(7416014)(376014)(1800799024)(23010399003)(56012099006)(6133799003)(10067099003)(3023799007)(22082099003)(18002099003)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 9UKX5ke8iJpssNyxsUJyxGTxA4gaJYCbxyGXaybtLSs228uspE76/HieFomCVYMvaC4jk3Gzvj/P4hDQ11EXdztX1+h2LzzSXpih+KVnVgG/CCvnnz22cnDPGHamTNAa3VHpYwSdvuMTpgIpXZo24ncnK3F0HhVEALtB4bQl3CITQXdT26bBpDlwSs+EMlTMFahtHrcNxZMIJ9wkGJXWgIDC4ZY2VGR5seObuRX0qtEX8y+k2U/pQQ6146FtfNLHPyMNRqDjJpCfFnKPjUFlzCGeQ76/f7Yb+Fc7FBh9fQ2PzQpfTEYICo3D2Q1hoFJcoaYii846qE2Tc4NI9fLyJbRJ06dc4lp2g8JZi8JRzJAJtjWAFXI8A4kweo9sBetqeVY3LXK/Nw2SURPALuLzc3WI/A7wcLtvhuSvTU4sXJQQPLApNz5Iso+2A1zPElVX X-Exchange-RoutingPolicyChecked: rTlUipoBXeBjvQZTAdRFrwn4oOBVtwoqoPmAZNZ0nbMoAsxKBCQcyu2iCVTzGyGGcQACpMOxz19ghERFJ4z6B1rcD67naRcpsJzP6/nzE6hDlPJ6OSX0QKQs+PuU4uMBWaGfK5hDUEfP8bUUNwTXTV0065ltsDtFRTtv9zvsK/MbBPOSxhAwwairdkZtuznvLJVtjNTWo5CWYSUO7RrRXy76vl68JnRwXa4oW0uT/6/0wiTMcZbJZxZKpEbST6cnOzTzd1zB+K0aYmiOYFkIxJUi3/tttR2IfG15+KR4F2CSqRdNT66Aee4RQmfDj4jd6FjOH8LoZjfOye2WdT5+fw== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jul 2026 11:03:29.3299 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 01c146c5-ff42-4692-476d-08dee8aa071a 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: BL02EPF0001A100.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN4PR10MB997898 X-Proofpoint-Spam-Info: AW1haW4tMjYwNzIzMDEwOCBTYWx0ZWRfX03bNA50+wJuI KLnaeOVXqGFREOCHJ4b3YVVs4q8wDt2PjCTa8vJqfqT2unLF/tftL/x85NoBmiBaxhnqk3sWNJp YnOYjVyhqo8ynZu4BZGXL6ai15W6bYA= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzIzMDEwOCBTYWx0ZWRfX+LVL0mwJibcs yLI2zO5mdeRU8E9hER4YO+x9BrhKdi+CGQZ9BD4lLxwz0tDPow2ayvGbqZmmX1n9CndrypAObET cGgQUvHExYQ3USODRWaPQmj93z1kk6WptIxord/t7E14aCla5JN7zEyrKgo/V3Ebp2lZlOX/7RN v9eMiSpjqOTmQg476qi21K+nb5piH544MIIVrMk3LDgLbfPQbHEFLhIKjJQie4uXThPrBj9M03k WMQXQyVa/bq5Vzn4+q+v0nz3eCZ9t6ePrlhc6PEy/al4AaWGs/cAi7F6I4wGbTUA2/IwpiLJF4A YCHNBvWY5fu9ZdznOTMShye0UvPzJM4cNrL9KYHfdnmI00dTQvN0FuyKa4qEQJ3WMtmLRe7Ladp G6JK+07TAQJuxL247OuZlbozb4fAwj/V7vkI/46nnyRPCF+zquwg+DMe8uVXR0aiLbbYZH7EP9Q T+p/U0med/UDj+KUIbQ== X-Proofpoint-GUID: svFy4xc0-p1e0e8Kl1q7TNEdKrUnh7vG X-Proofpoint-ORIG-GUID: svFy4xc0-p1e0e8Kl1q7TNEdKrUnh7vG X-Authority-Analysis: v=2.4 cv=Z/Dc2nRA c=1 sm=1 tr=0 ts=6a61f505 cx=c_pps a=VvAZzv+PhNtEUaR8E1V7rA==:117 a=WotqVVQAdb04rnGuttW3Kw==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=RAioF0-LDSMA:10 a=s63m1ICgrNkA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=gO1vWkAQAl3rybz1DQOp:22 a=sozttTNsAAAA:8 a=kQoCic6YF6TU8Y4tUr0A:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-23_03,2026-07-22_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 lowpriorityscore=0 malwarescore=0 impostorscore=0 bulkscore=0 adultscore=0 clxscore=1015 priorityscore=1501 spamscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607230108 Content-Type: text/plain; charset="utf-8" Extract the DMA transfer code from cqspi_direct_read_execute() into a new cqspi_direct_read_dma() helper. Add cqspi_memcpy_fromio() to handle non-DMA transfers, with 2-byte-aligned I/O accesses for 8D-8D-8D mode. Change cqspi_direct_read_execute() to take the full spi_mem_op and post_config_max_speed_hz instead of separate buf/from/len parameters, matching the interface needed by the PHY-aware version in the following patch. Thread post_config_max_speed_hz from cqspi_mem_process() through cqspi_read(). Transfers shorter than CQSPI_PHY_MIN_DIRECT_READ_LEN bytes always use the memcpy path; longer transfers use DMA when available. Signed-off-by: Santhosh Kumar K --- drivers/spi/spi-cadence-quadspi.c | 72 ++++++++++++++++++++++++++----- 1 file changed, 62 insertions(+), 10 deletions(-) diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-qu= adspi.c index 5070ffc53d5e..322e95b3bc17 100644 --- a/drivers/spi/spi-cadence-quadspi.c +++ b/drivers/spi/spi-cadence-quadspi.c @@ -151,6 +151,8 @@ struct cqspi_driver_platdata { #define CQSPI_READ_TIMEOUT_MS 10 #define CQSPI_BUSYWAIT_TIMEOUT_US 500 #define CQSPI_DLL_TIMEOUT_US 300 +/* Minimum transfer length to use DMA for direct reads */ +#define CQSPI_PHY_MIN_DIRECT_READ_LEN 17 =20 /* Runtime_pm autosuspend delay */ #define CQSPI_AUTOSUSPEND_TIMEOUT 2000 @@ -1521,8 +1523,8 @@ static void cqspi_rx_dma_callback(void *param) complete(&cqspi->rx_dma_complete); } =20 -static int cqspi_direct_read_execute(struct cqspi_flash_pdata *f_pdata, - u_char *buf, loff_t from, size_t len) +static int cqspi_direct_read_dma(struct cqspi_flash_pdata *f_pdata, u_char= *buf, + loff_t from, size_t len) { struct cqspi_st *cqspi =3D f_pdata->cqspi; struct device *dev =3D &cqspi->pdev->dev; @@ -1534,11 +1536,6 @@ static int cqspi_direct_read_execute(struct cqspi_fl= ash_pdata *f_pdata, dma_addr_t dma_dst; struct device *ddev; =20 - if (!cqspi->rx_chan || !virt_addr_valid(buf)) { - memcpy_fromio(buf, cqspi->ahb_base + from, len); - return 0; - } - ddev =3D cqspi->rx_chan->device->dev; dma_dst =3D dma_map_single(ddev, buf, len, DMA_FROM_DEVICE); if (dma_mapping_error(ddev, dma_dst)) { @@ -1580,8 +1577,61 @@ static int cqspi_direct_read_execute(struct cqspi_fl= ash_pdata *f_pdata, return ret; } =20 +static void cqspi_memcpy_fromio(const struct spi_mem_op *op, void *to, + const void __iomem *from, size_t count) +{ + if (op->data.buswidth =3D=3D 8 && op->data.dtr) { + unsigned long from_addr =3D (unsigned long)from; + + /* Handle unaligned start with 2-byte read */ + if (count && !IS_ALIGNED(from_addr, 4)) { + *(u16 *)to =3D __raw_readw(from); + from +=3D 2; + to +=3D 2; + count -=3D 2; + } + + /* Use 4-byte reads for aligned bulk (no readq for 32-bit) */ + if (count >=3D 4) { + size_t len =3D round_down(count, 4); + + memcpy_fromio(to, from, len); + from +=3D len; + to +=3D len; + count -=3D len; + } + + /* Handle remaining 2 bytes */ + if (count) + *(u16 *)to =3D __raw_readw(from); + + return; + } + + memcpy_fromio(to, from, count); +} + +static int cqspi_direct_read_execute(struct cqspi_flash_pdata *f_pdata, + const struct spi_mem_op *op, + u32 post_config_max_speed_hz) +{ + struct cqspi_st *cqspi =3D f_pdata->cqspi; + loff_t from =3D op->addr.val; + size_t len =3D op->data.nbytes; + u_char *buf =3D op->data.buf.in; + + if (!cqspi->rx_chan || !virt_addr_valid(buf) || + len < CQSPI_PHY_MIN_DIRECT_READ_LEN) { + cqspi_memcpy_fromio(op, buf, cqspi->ahb_base + from, len); + return 0; + } + + return cqspi_direct_read_dma(f_pdata, buf, from, len); +} + static ssize_t cqspi_read(struct cqspi_flash_pdata *f_pdata, - const struct spi_mem_op *op) + const struct spi_mem_op *op, + u32 post_config_max_speed_hz) { struct cqspi_st *cqspi =3D f_pdata->cqspi; const struct cqspi_driver_platdata *ddata =3D cqspi->ddata; @@ -1597,7 +1647,8 @@ static ssize_t cqspi_read(struct cqspi_flash_pdata *f= _pdata, =20 if ((cqspi->use_direct_mode && ((from + len) <=3D cqspi->ahb_size)) || (cqspi->ddata && cqspi->ddata->quirks & CQSPI_NO_INDIRECT_MODE)) - return cqspi_direct_read_execute(f_pdata, buf, from, len); + return cqspi_direct_read_execute(f_pdata, op, + post_config_max_speed_hz); =20 if (cqspi->use_dma_read && ddata && ddata->indirect_read_dma && virt_addr_valid(buf) && ((dma_align & CQSPI_DMA_UNALIGN) =3D=3D 0)) @@ -1625,7 +1676,8 @@ static int cqspi_mem_process(struct spi_mem *mem, con= st struct spi_mem_op *op) !cqspi->disable_stig_mode)) return cqspi_command_read(f_pdata, op); =20 - return cqspi_read(f_pdata, op); + return cqspi_read(f_pdata, op, + mem->spi->post_config_max_speed_hz); } =20 if (!op->addr.nbytes || !op->data.buf.out) --=20 2.34.1 From nobody Fri Jul 24 21:53:02 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 8B006431E4A; Thu, 23 Jul 2026 11:03: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=1784804639; cv=fail; b=SaMGvucTIpqWstOLAgZCxnjBzbbW0OFLjhEjw6OSFJWi7/XXClCXL7lB5xw2oK6HukaZfiqoD1k7g9ZKcQ8CwZ0MSREAHr3YCxoWYL9tGC8nHctg+i0sunVZxWfYjXCU2A6l5cXO1a00O30J5wv3x5v9qYYU3RU0ntQDPSuwD7Q= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784804639; c=relaxed/simple; bh=NlBClPnibM0KySwnwhBAcwY1mjSRn1kZGPB81D3dGzE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MZRcmH8A0kGFUBlGE+K+kUFfOKwUMP3iQxCjUx/d9b911nBqk4YTZdMlfRX5nse1jCRbInYP7CpDDHqcKtwc2ZSDKE9cG7NDq34tGIlq9HnagF7tCSPbantXgjegR/OlFm1b6Q19t7EF0DMNr+ou4Is/f5GAOapFkmMPfwdERZo= 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=howdu4Gh; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=tmfuN3HS; 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="howdu4Gh"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="tmfuN3HS" 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 66N9MJPr4111133; Thu, 23 Jul 2026 06:03:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint-05-2026; bh=Z+0x/gTksPXU7FZ2D9S8r1K8rcyMlV9iapZy8UL0O Z0=; b=howdu4GhOg+4lF0F9fu5eI1zFLY/XVErkMieWmkfNQQATeF5wBrY9nBkM tdAaK1jFja4cHRBmoTZUJ7YmD9IbST9iV44qNm9e5zediWda4TmX4Qwc8sQGYFdo i6Nz3pml4sbiJMEmcXXIjmBtM/HC3K05NYniQHckWVtlhIUuCOQza8KKV1AZ0PAt RAkDUTdWAaumKIvAA0wI6BYf3J1gm/uUqIc9/qD9SEdgP66gxzjkVB/Sr9uFZ2Cs LwF4UBSlmozi8bcuZFX0EqoE9z69/QQRo2pmPuCBwdk7Y5nG3gf5Rc3zIv1mx5i3 YOUQI4P4+PaMHQ0pHFGsqd1B6wO0Q== Received: from dm5pr21cu001.outbound.protection.outlook.com (mail-centralusazon11011015.outbound.protection.outlook.com [52.101.62.15]) by m0384305.ppops.net (PPS) with ESMTPS id 4fkg908cwu-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 23 Jul 2026 06:03:43 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=onOyz5PTazSEWrpq0W8eDsEqnCnZIJOgYQxVDK6C5qjJ15MgN3SrkNI6kkJzwqz2VsbJ196x69IPI7pQeQj2ah8/s+u5CUOO8h4DhB9J8HsUO53oWcr701IYKLnSLJxusyIeU8wXHG+6bg89zOZ5rfzGd77MLpxpZTnZ1YP1iDFmTQ5d/0SoXWUbO+g+NPi34LMsJP/SpKzfUGgX/3VBuMM7AV8/dURuaR5JvNgmANqhmSRhquoK5KpT2I6pU3tSRFjH2v5T1RFSQ+d6SgMIshch8fi8aAdR5RLOGFfkelCgO//CzMYkUorBnlUAOMUA4cEXKFflZ9/ahydv1QOM7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Z+0x/gTksPXU7FZ2D9S8r1K8rcyMlV9iapZy8UL0OZ0=; b=s0sTnQ9BHAQ2OFz3bTa2zETI+bJqR33XNEeZFAjXWIG9fV+79LVZmfr+eF0Um3t0T45Ryn/WDBU0EW0KdHiOkFb0B9snPOdb3AJ4VsDgw3n5j3eHGEAHOpuy6imnrTgl/oOtGtEX+h2v0aWQ4NuMuGTS5fN+BBDnJROOvpVP6hx6lslETdJhuYTbXsPQOSvD8mF5IKGuqeuz5+qDboafTrHSrsjDLgwnGYc2Vv1wqlf2ll1NXTBxyWPT61BNTR5WmJ2EX67ScgIighIOJLW9uHnj4w8/xVvFx/dHkhQHkUIjHsOU++D6jK/gndMWI4Tbob543OnmW1Yydj2IHSQV1w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 198.47.21.195) smtp.rcpttodomain=lists.infradead.org smtp.mailfrom=ti.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Z+0x/gTksPXU7FZ2D9S8r1K8rcyMlV9iapZy8UL0OZ0=; b=tmfuN3HS5Qwv2CgTwJQwE3rMAaiMmaCnG5BTX5yX0sckJMphvg2aEZeP9BTwjLFQj3/Rd8mOyhbSPwjANIouiLX4yJilzxfNdFO5NDIcYBacbULRzUDZUbTLYLryxhLnCdo8A18lNUgrX6Lwn+vVOKnwk7Q858nyHrUvDjox1lA= Received: from SJ0PR03CA0275.namprd03.prod.outlook.com (2603:10b6:a03:39e::10) by CH2PR10MB4294.namprd10.prod.outlook.com (2603:10b6:610:a7::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.245.11; Thu, 23 Jul 2026 11:03:39 +0000 Received: from SJ1PEPF000023D3.namprd21.prod.outlook.com (2603:10b6:a03:39e:cafe::8d) by SJ0PR03CA0275.outlook.office365.com (2603:10b6:a03:39e::10) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.245.11 via Frontend Transport; Thu, 23 Jul 2026 11:03: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 SJ1PEPF000023D3.mail.protection.outlook.com (10.167.244.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.270.0 via Frontend Transport; Thu, 23 Jul 2026 11:03:36 +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.37; Thu, 23 Jul 2026 06:03:31 -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.37; Thu, 23 Jul 2026 06:03:31 -0500 Received: from lelvem-mr05.itg.ti.com (10.180.75.9) by DFLE209.ent.ti.com (10.64.6.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Thu, 23 Jul 2026 06:03:30 -0500 Received: from santhoshkumark.dhcp.ti.com (santhoshkumark.dhcp.ti.com [10.24.52.55]) by lelvem-mr05.itg.ti.com (8.18.1/8.18.1) with ESMTP id 66NB2OW71577597; Thu, 23 Jul 2026 06:03:26 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , Subject: [PATCH v6 11/17] spi: cadence-quadspi: enable PHY for direct reads Date: Thu, 23 Jul 2026 16:32:13 +0530 Message-ID: <20260723110219.3180747-12-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260723110219.3180747-1-s-k6@ti.com> References: <20260723110219.3180747-1-s-k6@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF000023D3:EE_|CH2PR10MB4294:EE_ X-MS-Office365-Filtering-Correlation-Id: 90cb9f77-0e4d-4cc5-85f6-08dee8aa0ba9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|376014|7416014|23010399003|36860700016|10067099003|56012099006|6133799003|18002099003|22082099003|921020; X-Microsoft-Antispam-Message-Info: 0nm4UakhCcA7vS8gmvw2QAu+ay2qQl0gqs+NvpLsz+tS8ymCAwJVpk4aOmD+1aH8TNuS8B01c5gSf8cueA7FmbFNmV6ds6pFMZB1HoH9uIKuRtXNAPDQYcav2el6EmVSMVu2ChFuRtAFy89/tHwyjlI/ymT21gQm4MalTwSBd6uEC4U7iBpcQs954RvEEq3nd+/mK2YL6nOZj9KU1ftPC6bISmZKXrEiFtgbIX12vrfRWzhPAJLk+WQGajK9cpNqQQuiKe8n6N5bOcvHT6Q6eq8UIDHbENSrcYCF5aYk1R62ZcCVPeTSbgstRm9UvOilJDj8rCi/0UGnW+ehbkcLFh7iZUWR1Mz8D/KPWmgsksH5L/IPC0XqV565jkcpDoTol2N3UwxZLMFejDD4u6LhIB5NY5SsOsYCMmS7vaRhmY8US10snHKUh3F9LcPkKqzs/GJ4N+GQ8x3yLWSy390ex6LTUvqQIzMi93h0SzvTBi7TrLPJweknULfAuW/wTL1inNwBbxmsAJiTu32ssujzKDnkjS0v5/IDJdAV0jHkBA43Y4mFpOe9d4YB1HHSWP3FvwKiCBhnzVGEgvYNjTer1DL/ulKkglRcOuqka19eOPKwTh5ujtvxUrcV7zK7HUBQjM4yZM0dLDXKr4xlc2J4WoZx3Ki9OcXKRqGyZ65/uyHOPpeToRmD6cpFkKnkdfviIKNfUjIF5eUIkB8tBkWU3K0hqzFzkXvH9YV5/rdQG6P/1DltEPKaSyJwYRZUAieb X-Forefront-Antispam-Report: CIP:198.47.21.195;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:flwvzet201.ext.ti.com;PTR:ErrorRetry;CAT:NONE;SFS:(13230040)(1800799024)(82310400026)(376014)(7416014)(23010399003)(36860700016)(10067099003)(56012099006)(6133799003)(18002099003)(22082099003)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: rY+nSmfHuzjnzx9I/BuuR+aRnYX+kauVyHw6zYerYO3sTqe0U06QEZO2fX/ApqNBX7CSEkgcUb7LaQ1TaAMqLD1Y076AYI20LpBQSMQ1azRGcHbYV1piLZjJ/WZL7QS7hGIDXJLNdYlE2ZwjMspRYAcsjP4nPparPTMH4olLMIHzFKzTtNxbWkAr9qEQIpxgsjQ/eBjyNJaSiBrp72THy5lLA97LKCurZUBXreX+CE1geG5XpgavJZGWNoWCqsGl3dW3qN9NZpkLYhLv8zm1jjtjnkStTJzk/L+zdiZ+5Y6dItftlNN22MPjaxYZ4srur4b/AifvPXLXnL5wlC5kXWbmuoz1gdN2mn6GSHnWkA6o5eCfYPNtggRqcHnaVD2PJWSAF5imK95ZuPm0HBtvY/7VjEQVTEXNTZfx54RKc1FAZA5dTfvZvAlFip/PPIMs X-Exchange-RoutingPolicyChecked: jq1zy2CAKFIsMwmRDlH83S6B37pccxplO50fEZQwEXD9hAL5umlsvEVR6aeFn16sNAjy2hbOeLUUuEWF2AAaYqq4a6DuRvLZInwLyhaGPVf0CF0+gwGlmI4aOIR6i9siUc8XcMRrm6V2yAqP0FXLHGQ8+YqdsJsFSRmcNn97uVa+2GBCAkfCaLHGaRw8l+cFcHinxfAvwHJJcFBWtfQCtnd1MUzUcBy72+Cd046N24BWNWTUP55rhKgmubVBglxQOWHV8dTGDYFP+Xboz33/nGccy+EhnzDQISsTtLiHsp/K252l7nqhyPm8dq7q1xIr90lrzjMEv2uuzI88bRACIQ== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jul 2026 11:03:36.9586 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 90cb9f77-0e4d-4cc5-85f6-08dee8aa0ba9 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: SJ1PEPF000023D3.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR10MB4294 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzIzMDEwOCBTYWx0ZWRfX4Wz21CyMwydw HHjuMlpxdgfBYT4cYHAUaMFbxLEjjjDjYm/SzAeFTON7uSsi2/MDfByTmEGgtrG5JrsfbqrnFWd uRpbWfY6nKP4ZOcN6VBLYI7InQnPlJ/Zcphm8T+cau9Z6GyXu1DYHgbmF8xaQ6eAK6PYtR+K5Y5 MBzz9Hjoox8A2LJFwi3HeerlsT8OHy8r1eFvBrHbkRWFLlTe3A60FiaKlgiKIK5hLBPvRGnelM+ nRIvNQ0Bsz64hVHpSnhP2Mkvm5tFiz0CbxoZDzpaBV23DZojlwyehkzhME56CfQncnWKoBGFsYg w6p1DeeOHyaOI3SPXhTZsbDKEyRRU7xPoLSyzdAYukIVZjkKxgxWMp5qOvYoSNHYx7pFXdyU+VH eXnYeOJEy5P3za6zij8cceFRMBX6UVvSHSjKdIHZ2aXMUkKTVAoDPSwIdRtRu8dRVRPZCvOzYtB WVTrSLI+AzCuYKFu+rQ== X-Proofpoint-ORIG-GUID: pPUVeKDu8xUHYklAlQvJ3g9iNMQBffek X-Authority-Analysis: v=2.4 cv=EeT4hvmC c=1 sm=1 tr=0 ts=6a61f50f cx=c_pps a=+kBkz34/1DjdJIz+AnMsKg==:117 a=tJyPKKxUohctrY4NYmUjkA==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=RAioF0-LDSMA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=taLDd7a_hP9WKsMzeGRc:22 a=sozttTNsAAAA:8 a=EeSCy0yzjnJx7k32krcA:9 X-Proofpoint-Spam-Info: AW1haW4tMjYwNzIzMDEwOCBTYWx0ZWRfX2RCiv4zlCtSo EEyaCAU522JUnkaNddKz+J7PZvp7LkVqhYLsVlS9hiQcWZXD/116UANLydr4Ibukcoi7/6XddID 29PHxDxoqpNP5YVAJb6WPZFw1h6ybsw= X-Proofpoint-GUID: pPUVeKDu8xUHYklAlQvJ3g9iNMQBffek X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-23_03,2026-07-22_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 bulkscore=0 suspectscore=0 impostorscore=0 priorityscore=1501 adultscore=0 lowpriorityscore=0 malwarescore=0 phishscore=0 clxscore=1015 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607230108 Content-Type: text/plain; charset="utf-8" Add cqspi_tune_phy() to toggle PHY mode. Enabling sets the calibrated read-capture delay, asserts PHY_EN and PHY_PIPELINE, and decrements the dummy cycle count by one since the PHY pipeline absorbs that latency. When multiple chip selects have different calibration results, the DLL is reprogrammed on each enable to match the active device's settings. Disabling reverses all three. For direct reads, split the transfer into an unaligned head, a 16-byte-aligned middle section with PHY active, and an unaligned tail. PHY is used when tuning completed successfully and the transfer is at the calibrated frequency. Signed-off-by: Santhosh Kumar K --- drivers/spi/spi-cadence-quadspi.c | 124 +++++++++++++++++++++++++++++- 1 file changed, 123 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-qu= adspi.c index 322e95b3bc17..35a400073944 100644 --- a/drivers/spi/spi-cadence-quadspi.c +++ b/drivers/spi/spi-cadence-quadspi.c @@ -1067,6 +1067,82 @@ static int cqspi_resync_dll(struct cqspi_st *cqspi) return ret; } =20 +static int cqspi_tune_phy(struct cqspi_flash_pdata *f_pdata, bool enable) +{ + struct cqspi_st *cqspi =3D f_pdata->cqspi; + void __iomem *reg_base =3D cqspi->iobase; + u32 reg; + u8 dummy; + int ret; + + if (enable) { + /* + * CQSPI_REG_PHY_CONFIG holds the RX/TX delay line tap counts + * and is a single global register with no per-CS equivalent. + * Reprogramme and resync the DLL when the active device's + * calibrated values differ from what is currently in hardware, + * which happens when alternating PHY reads between two chip + * selects with different calibration results. + */ + reg =3D readl(reg_base + CQSPI_REG_PHY_CONFIG); + if (((reg >> CQSPI_REG_PHY_CONFIG_RX_DEL_LSB) & + CQSPI_REG_PHY_CONFIG_RX_DEL_MASK) !=3D f_pdata->phy_setting.rx || + ((reg >> CQSPI_REG_PHY_CONFIG_TX_DEL_LSB) & + CQSPI_REG_PHY_CONFIG_TX_DEL_MASK) !=3D f_pdata->phy_setting.tx) { + cqspi_set_dll(reg_base, f_pdata->phy_setting.rx, + f_pdata->phy_setting.tx); + ret =3D cqspi_resync_dll(cqspi); + if (ret) + return ret; + } + + cqspi_readdata_capture(cqspi, true, f_pdata->use_dqs, + f_pdata->phy_setting.read_delay); + + reg =3D readl(reg_base + CQSPI_REG_CONFIG); + reg |=3D CQSPI_REG_CONFIG_PHY_EN | CQSPI_REG_CONFIG_PHY_PIPELINE; + writel(reg, reg_base + CQSPI_REG_CONFIG); + + /* + * The PHY data-capture pipeline absorbs one dummy cycle's + * worth of latency; reduce the count to avoid over-compensation. + */ + reg =3D readl(reg_base + CQSPI_REG_RD_INSTR); + dummy =3D FIELD_GET(CQSPI_REG_RD_INSTR_DUMMY_MASK + << CQSPI_REG_RD_INSTR_DUMMY_LSB, + reg); + dummy--; + reg &=3D ~(CQSPI_REG_RD_INSTR_DUMMY_MASK + << CQSPI_REG_RD_INSTR_DUMMY_LSB); + reg |=3D FIELD_PREP(CQSPI_REG_RD_INSTR_DUMMY_MASK + << CQSPI_REG_RD_INSTR_DUMMY_LSB, + dummy); + writel(reg, reg_base + CQSPI_REG_RD_INSTR); + } else { + cqspi_readdata_capture(cqspi, !cqspi->rclk_en, false, + f_pdata->read_delay); + + reg =3D readl(reg_base + CQSPI_REG_CONFIG); + reg &=3D ~(CQSPI_REG_CONFIG_PHY_EN | + CQSPI_REG_CONFIG_PHY_PIPELINE); + writel(reg, reg_base + CQSPI_REG_CONFIG); + + reg =3D readl(reg_base + CQSPI_REG_RD_INSTR); + dummy =3D FIELD_GET(CQSPI_REG_RD_INSTR_DUMMY_MASK + << CQSPI_REG_RD_INSTR_DUMMY_LSB, + reg); + dummy++; + reg &=3D ~(CQSPI_REG_RD_INSTR_DUMMY_MASK + << CQSPI_REG_RD_INSTR_DUMMY_LSB); + reg |=3D FIELD_PREP(CQSPI_REG_RD_INSTR_DUMMY_MASK + << CQSPI_REG_RD_INSTR_DUMMY_LSB, + dummy); + writel(reg, reg_base + CQSPI_REG_RD_INSTR); + } + + return cqspi_wait_idle(cqspi); +} + static int cqspi_versal_indirect_read_dma(struct cqspi_flash_pdata *f_pdat= a, u_char *rxbuf, loff_t from_addr, size_t n_rx) @@ -1516,6 +1592,14 @@ static ssize_t cqspi_write(struct cqspi_flash_pdata = *f_pdata, return cqspi_indirect_write_execute(f_pdata, to, buf, len); } =20 +static bool cqspi_use_tuned_phy(struct cqspi_flash_pdata *f_pdata, + const struct spi_mem_op *op, + u32 post_config_max_speed_hz) +{ + return f_pdata->use_tuned_phy && + op->max_freq =3D=3D post_config_max_speed_hz; +} + static void cqspi_rx_dma_callback(void *param) { struct cqspi_st *cqspi =3D param; @@ -1617,8 +1701,11 @@ static int cqspi_direct_read_execute(struct cqspi_fl= ash_pdata *f_pdata, { struct cqspi_st *cqspi =3D f_pdata->cqspi; loff_t from =3D op->addr.val; + loff_t from_aligned, to_aligned; size_t len =3D op->data.nbytes; + size_t len_aligned; u_char *buf =3D op->data.buf.in; + int ret; =20 if (!cqspi->rx_chan || !virt_addr_valid(buf) || len < CQSPI_PHY_MIN_DIRECT_READ_LEN) { @@ -1626,7 +1713,42 @@ static int cqspi_direct_read_execute(struct cqspi_fl= ash_pdata *f_pdata, return 0; } =20 - return cqspi_direct_read_dma(f_pdata, buf, from, len); + if (!cqspi_use_tuned_phy(f_pdata, op, post_config_max_speed_hz)) + return cqspi_direct_read_dma(f_pdata, buf, from, len); + + /* Split into unaligned head, aligned middle, unaligned tail */ + from_aligned =3D ALIGN(from, 16); + to_aligned =3D ALIGN_DOWN(from + len, 16); + len_aligned =3D to_aligned - from_aligned; + + if (from !=3D from_aligned) { + ret =3D cqspi_direct_read_dma(f_pdata, buf, from, + from_aligned - from); + if (ret) + return ret; + buf +=3D from_aligned - from; + } + + if (len_aligned) { + ret =3D cqspi_tune_phy(f_pdata, true); + if (ret) + return ret; + ret =3D cqspi_direct_read_dma(f_pdata, buf, from_aligned, + len_aligned); + cqspi_tune_phy(f_pdata, false); + if (ret) + return ret; + buf +=3D len_aligned; + } + + if (to_aligned !=3D (from + len)) { + ret =3D cqspi_direct_read_dma(f_pdata, buf, to_aligned, + (from + len) - to_aligned); + if (ret) + return ret; + } + + return 0; } =20 static ssize_t cqspi_read(struct cqspi_flash_pdata *f_pdata, --=20 2.34.1 From nobody Fri Jul 24 21:53:02 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 8972245D5E6; Thu, 23 Jul 2026 11:03: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=1784804639; cv=fail; b=UEX14IY/peeaxjNST29m+7wZNQBEmMpFTrj3KzZ5CBL36YDShwHBNcPA5BGQESLUuwvSd90Z43QW0k+m/Z9XT/dgxKEiq3CjLEaxz/0AzkVFaNfG0mhjgH00hHVQVYB++WfdqYRyzPMoGMrxk+/SPf+sDBD1ILRbLllKAvLgUP8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784804639; c=relaxed/simple; bh=Sm4ubbEEN4Az76qfVMNZTIkkcnGNEOC/u3U9uX+LeJ0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=rihJX4eF1St8SdkRG2LAf7ufmS2WG6tu1Btkf0oChbR51pESZBxQ+k5UExRo7VzNU7PI6zHwfSwONtTAPRP3n5TNOSbrl9TbjKOtgI2rVAP8aVRGpIAN2la4/+fAMKBc+6HYol4qYxLKnLU8AEY+AMbQqI83ytSdJHeLCwtlIdE= 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=B3Rk99Rh; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=ZV08AVwh; 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="B3Rk99Rh"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="ZV08AVwh" 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 66N9IB202039762; Thu, 23 Jul 2026 06:03:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint-05-2026; bh=hB6pzNq3ewbcs9k9dCtsJN2CaWmJWpAUfqG98Iw46 N0=; b=B3Rk99RhcK8qXoI7uGXOptGkvDypcABTtzL2gEdcWXmbSezKKi2NHRUtx 4UueOF6+Vvu/wntDj0d1ggfxVs0jIiuijIRKnj4FSEZzQCDb/Red8hzollwiPtQw v6SBtMA1yL9QhiQudjQFwsFb4K9ZF5vS4bE8yredcTXgo9hyxNL7eUnBqTKT10UL AV4EpZoRVWQX3zvtOpf/PHclE9G9XfPANwlW6nm89Ji+V9bKwXlxuqilcvPrsEJK rqK1EBcZoBanq1DgZrWVHtSyxpZEbPdtEY3zVF8odwnkj3pMfSHJBTs8V/ygl71n bgTY/SovlENJWViDKclg3fErJ1qLQ== Received: from sa9pr02cu001.outbound.protection.outlook.com (mail-southcentralusazon11013068.outbound.protection.outlook.com [40.93.196.68]) by m0380145.ppops.net (PPS) with ESMTPS id 4fkg730c6w-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 23 Jul 2026 06:03:42 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=pfE9M/11tyi95XljBGUMBn8Rhm5K3UncYXvZThDLErHC5fBkfTDYQV5f+X57vtgEcRccJGH6thEu9fQvyGmRrvUYISXkdAwu1Zcxs4jDpZrm86Wb50UHgY9cS+f/12fjo9LwrHWEUcQNEkbiJALzLcp3P+gylQCN3xVaHGLKGlyNvRWH1ljDV9H0f681CDzqfVQJXEHnauj0mdaARJkmfR9WOepxqdOoguoqquQ9N/vudOjpTa0Z4EIyEEBKIrKHlFRCoP6uXgZFVitQ8czn45cPe+8Ei2hotzKuvFoiisI7ILsNG1H/p96Za6fQoJSGwhIKI81Kp0ZflunhRE4z0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=hB6pzNq3ewbcs9k9dCtsJN2CaWmJWpAUfqG98Iw46N0=; b=EZukZ4zHi775Ghj7JOlIBQRpGZmBTg3L+Ml0a7PXOhge4ZfvdhLXxX9tMz8H2Fta8sYc4QwyXCu7jkDqowccq6Cp4hMyI25PTKvo4r+wo5Qna3qrwkwNkANx+3S5aJrNxUUyNMrPBqQNmaY5IAzSzB/9MM1x+aQhp2xjIi1qsP9t+T/fPZnSSC5JK5RznCqCtaiqjwIAcWjMmyJesv+Vi5a2GMc8zILjr8PmBx9/cAeMKEF06qKdtBBI9qnWLU8Q8Bwp/sK2hCNewoWuz1ocgWTYbg7KESJSEAtewsD1vu9wkWZkJt/pTeRQyU3AeTRnXMMzLbDcfdV1bIlPFxGSog== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 198.47.21.194) smtp.rcpttodomain=lists.infradead.org smtp.mailfrom=ti.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hB6pzNq3ewbcs9k9dCtsJN2CaWmJWpAUfqG98Iw46N0=; b=ZV08AVwh13znxi4lvcra/7LFjcJi64xX6UHr12klHLRfgiebmiMD3lXBeH7JN83CjE6qJasm7VF5Kqpj5gze1M0NadXTVA8iSag69IQ/Taz4Ar/EILlYiS2O9jUOGYjKVIyJX+FtJTArtYM4DBOFR/iFuufHzfsgilDmw83AUoM= Received: from PH0PR07CA0087.namprd07.prod.outlook.com (2603:10b6:510:f::32) by SJ1PR10MB5907.namprd10.prod.outlook.com (2603:10b6:a03:48a::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.245.11; Thu, 23 Jul 2026 11:03:38 +0000 Received: from SA2PEPF000015C8.namprd03.prod.outlook.com (2603:10b6:510:f:cafe::2f) by PH0PR07CA0087.outlook.office365.com (2603:10b6:510:f::32) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.245.11 via Frontend Transport; Thu, 23 Jul 2026 11:03:38 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 198.47.21.194) smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ti.com; Received-SPF: Pass (protection.outlook.com: domain of ti.com designates 198.47.21.194 as permitted sender) receiver=protection.outlook.com; client-ip=198.47.21.194; helo=flwvzet200.ext.ti.com; pr=C Received: from flwvzet200.ext.ti.com (198.47.21.194) by SA2PEPF000015C8.mail.protection.outlook.com (10.167.241.198) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.270.5 via Frontend Transport; Thu, 23 Jul 2026 11:03:36 +0000 Received: from DFLE210.ent.ti.com (10.64.6.68) by flwvzet200.ext.ti.com (10.248.192.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Thu, 23 Jul 2026 06:03:36 -0500 Received: from DFLE211.ent.ti.com (10.64.6.69) by DFLE210.ent.ti.com (10.64.6.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Thu, 23 Jul 2026 06:03:36 -0500 Received: from lelvem-mr05.itg.ti.com (10.180.75.9) by DFLE211.ent.ti.com (10.64.6.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Thu, 23 Jul 2026 06:03:36 -0500 Received: from santhoshkumark.dhcp.ti.com (santhoshkumark.dhcp.ti.com [10.24.52.55]) by lelvem-mr05.itg.ti.com (8.18.1/8.18.1) with ESMTP id 66NB2OW81577597; Thu, 23 Jul 2026 06:03:31 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , Subject: [PATCH v6 12/17] spi: cadence-quadspi: enable PHY for indirect writes Date: Thu, 23 Jul 2026 16:32:14 +0530 Message-ID: <20260723110219.3180747-13-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260723110219.3180747-1-s-k6@ti.com> References: <20260723110219.3180747-1-s-k6@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF000015C8:EE_|SJ1PR10MB5907:EE_ X-MS-Office365-Filtering-Correlation-Id: 3af49e93-7ce2-4f61-d3da-08dee8aa0b96 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|23010399003|1800799024|36860700016|82310400026|376014|7416014|56012099006|10067099003|921020|22082099003|18002099003|6133799003; X-Microsoft-Antispam-Message-Info: jsqzRZp/Hc/2fHfrkKlLx3uZE3ainP5bDm/xjrZbLiu3ZESweU1HnFY45yE6Tyj68oYxPpMLvg1ja7xHAEgI4X40ATV9qNRQYnE45BTALkLRHf7Zh3C85LUX9XQ9iIJr/OwxHfDZMaRu2OSa/z8LFqv0PzvZ8/Y2hQatr1z/J0vbzz18Isi2IMgRYS6sQXhAQcBF6dAJpzQxdgg6rFq3nUBNr9xiIu678Btr8GK27Q9lwdMZjwO+wWXOKDKRRVqnH/PYoITJal+s8uY5cR5Rc2RbdsBYoT7MzkzR9D2pFKs2rmaewV6T7lkczqV01tFf0XaNl7w8bQOLnzlUkfeIA/vPRxWAUE62A85PKqMtd3Rj5epCw64XSzhIQo3QxL+KYnc9hKQPHe5r0hzUHwfaOlumGrTorzKSbBPnheNASL2ieOL9w/QUWhg2EL7gF7js61IyyWJ/xL/D8e64qISwFaGEKuACuDEnm9RV1+7pEnLJnyED1lVCedK3frzAp3Rlo09Uyy77I55OTa4NWU+FVEMP8zsUQBYn/TVJvosTXPPU4M5xbrnYGIu71tZebXIh782jI2mtnFoGWz0sowBt/pqyZva7pRSHEVLQHIk4fMh71sHyMzKkaAOpcPHEj0uGRjyhzanJ4MINp4AhhQMZCAPWIp4HicJM+CwknO4GWh18JaBd+xntPXDJ5QZHADA54q5KWP28j6Fov86YaGzHBEWNxVsfpraJGyw/CDg/dA520MXu/tfG2D+nxxS8Va1I 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)(36860700016)(82310400026)(376014)(7416014)(56012099006)(10067099003)(921020)(22082099003)(18002099003)(6133799003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 5jZggdddEnAy+3r1IHntWG9S6rhvJLla0bdvtlFhtCOyiwJtmfEyYBUbM73KQWqYzaLfc9IJpJqgFMZDH0GDu7MIiz4ULfO7qImzDljGd22m3t7LNWE5Zne86aVdq/W825goJ0lC7VXTEoK3J9t+/O8NQaPG0zXDt9oi6dQYb3gpkSyJbaJrdx9JDB3apoCdq1I7NtAGpJ7Ni7OpulnHxj+nENaiBiViBXNjCL2GkJ6474imWR7T6NfLH/h66Q/EOG9+9skW64X+mUVfbgrXP6yuKCE3I+Ft7Leo63wfUuIK4coSQ6DGt8StnR8YbxyncFrDcdIW8Ed6MijCsCwdGNNrNybfKmBJzs1hwG+CDC1k0uP94+X525nSlhx6X7DS4hIHAW+PtigB4QatzvbEfBdN1J6XuGimI+dkTIPbbgG4tIfvANtQbDmM7wQ4uyge X-Exchange-RoutingPolicyChecked: Rp/QOpLkMEbeUJUv6fzlBzN7thpNoPTENVztTwB0BOzdWc3PK8syVWFeX09znCUU4kvf3IWnU2GEZMx/hn2mEfuTJHddi+tEW5KfDfqpdwTdwr6aCuhlwEOaoVI4uIzxTlx22NYJi45j7d922BxPRrtFBzM/KjQSoqKxu5+5wugNMZsspfDY2/f2PfkheeimFSDikFCKzbY/ZAjhnmTb37EQoE8VfvAbS2d8YrpAUGrxoGTU2uLjBMuYCuwDFRMD1w2Ph/3qlGds2ffci7sVNBfCXCQgRn65g04pGc/T/4pnKaxpvHH0FpgFaaKi3adL5gAoxYuCDktGWv0m9dbDqA== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jul 2026 11:03:36.8926 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3af49e93-7ce2-4f61-d3da-08dee8aa0b96 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: SA2PEPF000015C8.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ1PR10MB5907 X-Proofpoint-Spam-Info: AW1haW4tMjYwNzIzMDEwOCBTYWx0ZWRfX04ZISOoSZ8/w guEhBVBu4PwiYFYN91VAMeNZJF4Ytv1F3tZvQv2jBWy0/aXdW+7sZr2tZxUNkwGJtMW5Pj6cQ9k g20dR/MemaR3YdjQ8Vqq+9VTTXU+sg4= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzIzMDEwOCBTYWx0ZWRfX9Br3/QWzZcqV tc2S4vMdGq+LTaWNGRau1AqYKAsE+L8N2QP6HmIuUv+gxckd0lPq6xNEaWUKIOXkMuZ8qZdSS5D YGaG20EvvqaoE5SJDJ0rWg/1E5q0qov5WolnKECqhznsiweq4TckzzLUTJumRbKm/SB/tdNAxMM xbSVi4sQcNAJoaAyIB+UmecjqWscP66myYo2jCK4qzCOuHrEGgJFn1s0Y0VYeXRV8Q5EQaNEFpm 0QxbGU7bHmPdjHJGND1kR986lQtan6Bcph1n0rq8GC8Df5saa5ESKOjPJnQ7NIQYjqJyeg3c3Xl TC3ky/x2UewPmWPpDm1Km1czgcMeVxGzpDmngdF2hY+PB8BZZTaK7LpCbVX3QM9ogBokU3KOUTa lDkceNcIupd4YUs07dm3VrjLligMyahZzPPJIoEN5AAdYSTuGyV8lLZB6iI7BihLMdvBMWmyi3W T+4n0k3LBdsebeCzMHw== X-Proofpoint-GUID: KO_OyvUiwXYl-dcKRFfreAcsTVJENGph X-Proofpoint-ORIG-GUID: KO_OyvUiwXYl-dcKRFfreAcsTVJENGph X-Authority-Analysis: v=2.4 cv=Z/Dc2nRA c=1 sm=1 tr=0 ts=6a61f50e cx=c_pps a=0JRlrhwbVVPmsaj0kffiDg==:117 a=iwqwCZQqcuTv3JOpYdM7/Q==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=RAioF0-LDSMA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=gO1vWkAQAl3rybz1DQOp:22 a=sozttTNsAAAA:8 a=-A2lziRS1w5XIjWNnAEA:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-23_03,2026-07-22_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 lowpriorityscore=0 malwarescore=0 impostorscore=0 bulkscore=0 adultscore=0 clxscore=1015 priorityscore=1501 spamscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607230108 Content-Type: text/plain; charset="utf-8" Enable PHY for indirect writes of at least CQSPI_PHY_MIN_INDIRECT_WRITE_LEN bytes. PHY is activated only when tuning completed successfully and the write op runs at the calibrated post-config frequency, matching the same frequency guard used by the read path. Thread post_config_max_speed_hz from cqspi_mem_process() through cqspi_write() into cqspi_indirect_write_execute() for the frequency check. Signed-off-by: Santhosh Kumar K --- drivers/spi/spi-cadence-quadspi.c | 32 +++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-qu= adspi.c index 35a400073944..542ad331ff16 100644 --- a/drivers/spi/spi-cadence-quadspi.c +++ b/drivers/spi/spi-cadence-quadspi.c @@ -153,6 +153,8 @@ struct cqspi_driver_platdata { #define CQSPI_DLL_TIMEOUT_US 300 /* Minimum transfer length to use DMA for direct reads */ #define CQSPI_PHY_MIN_DIRECT_READ_LEN 17 +/* Minimum indirect write length to amortize PHY enable/disable overhead */ +#define CQSPI_PHY_MIN_INDIRECT_WRITE_LEN SZ_1K =20 /* Runtime_pm autosuspend delay */ #define CQSPI_AUTOSUSPEND_TIMEOUT 2000 @@ -1335,13 +1337,15 @@ static int cqspi_write_setup(struct cqspi_flash_pda= ta *f_pdata, =20 static int cqspi_indirect_write_execute(struct cqspi_flash_pdata *f_pdata, loff_t to_addr, const u8 *txbuf, - const size_t n_tx) + const size_t n_tx, + u32 post_config_max_speed_hz) { struct cqspi_st *cqspi =3D f_pdata->cqspi; struct device *dev =3D &cqspi->pdev->dev; void __iomem *reg_base =3D cqspi->iobase; unsigned int remaining =3D n_tx; unsigned int write_bytes; + bool use_tuned_phy_write; int ret; =20 if (!refcount_read(&cqspi->refcount)) @@ -1377,6 +1381,18 @@ static int cqspi_indirect_write_execute(struct cqspi= _flash_pdata *f_pdata, if (cqspi->apb_ahb_hazard) readl(reg_base + CQSPI_REG_INDIRECTWR); =20 + /* Use PHY only for large writes at the calibrated rate */ + use_tuned_phy_write =3D n_tx >=3D CQSPI_PHY_MIN_INDIRECT_WRITE_LEN && + f_pdata->use_tuned_phy && + f_pdata->phy_write_op.max_freq =3D=3D + post_config_max_speed_hz; + + if (use_tuned_phy_write) { + ret =3D cqspi_tune_phy(f_pdata, true); + if (ret) + goto failwr; + } + while (remaining > 0) { size_t write_words, mod_bytes; =20 @@ -1425,9 +1441,15 @@ static int cqspi_indirect_write_execute(struct cqspi= _flash_pdata *f_pdata, =20 cqspi_wait_idle(cqspi); =20 + if (use_tuned_phy_write) + cqspi_tune_phy(f_pdata, false); + return 0; =20 failwr: + if (use_tuned_phy_write) + cqspi_tune_phy(f_pdata, false); + /* Disable interrupt. */ writel(0, reg_base + CQSPI_REG_IRQMASK); =20 @@ -1562,7 +1584,8 @@ static void cqspi_configure(struct cqspi_flash_pdata = *f_pdata, } =20 static ssize_t cqspi_write(struct cqspi_flash_pdata *f_pdata, - const struct spi_mem_op *op) + const struct spi_mem_op *op, + u32 post_config_max_speed_hz) { struct cqspi_st *cqspi =3D f_pdata->cqspi; loff_t to =3D op->addr.val; @@ -1589,7 +1612,8 @@ static ssize_t cqspi_write(struct cqspi_flash_pdata *= f_pdata, return cqspi_wait_idle(cqspi); } =20 - return cqspi_indirect_write_execute(f_pdata, to, buf, len); + return cqspi_indirect_write_execute(f_pdata, to, buf, len, + post_config_max_speed_hz); } =20 static bool cqspi_use_tuned_phy(struct cqspi_flash_pdata *f_pdata, @@ -1805,7 +1829,7 @@ static int cqspi_mem_process(struct spi_mem *mem, con= st struct spi_mem_op *op) if (!op->addr.nbytes || !op->data.buf.out) return cqspi_command_write(f_pdata, op); =20 - return cqspi_write(f_pdata, op); + return cqspi_write(f_pdata, op, mem->spi->post_config_max_speed_hz); } =20 static int cqspi_exec_mem_op(struct spi_mem *mem, const struct spi_mem_op = *op) --=20 2.34.1 From nobody Fri Jul 24 21:53:02 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 DEFDC45A2AF; Thu, 23 Jul 2026 11:03:58 +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=1784804648; cv=fail; b=qrfbtRsFpQlDH4GucpO8Xx5l+yXo17SNEtXEzf/tFMIgRCeD6JVpR/Kztdh7dCRXjaLNdps9Z46NDmNq6iy1EDFqkXUEjzLeONyd5TXb15m0X/1XOYEqU5qg1hwUbhRYYeMvBuyqFoCrql2/tJLoAl3LtLfpTl32BaW2jPuTICA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784804648; c=relaxed/simple; bh=pIn6FQMQVRmpAi1OIWqN2WjNohkALTG2Vfo107304pI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=pRNclnlnLzmqDgR70xU65VpSSF5/Rid3yJkTAFb4XrG0m2W35Fy53WY1maZzI9AScKKv02kciyhMv9QNtNFCRXUKYrdgpoOgSrzFw5Xxms6rhWLEnK3OjzOGwsv3Mwx7AL6slghlvoOrXztwtK0M62cJgBse5/MTm5XVRJyGiJo= 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=RiLErUiX; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=KazrTWR4; 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="RiLErUiX"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="KazrTWR4" 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 66N9I75I2039437; Thu, 23 Jul 2026 06:03: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=3KQVMFD538yJ3bW7oX3qUKzdhPkCw69tpRcHsh0Ql kk=; b=RiLErUiXOjVTE1mrtU/4/mxY0RFAEbeVIKGfDVL6GnGv7Qx4Te0aVQQYc sh9NdovyhrRD9KaLv56TrQcgVs1cgpd8J4fRqVUGCeML0Pwh7WgyDPPZvOJbWWy3 kh8G3frVsaV0BPryTBKsTWdDUQOA5Y8HGQd11gtEzGUWkJQLbwDwJFU5M6dYCBRq CrY1mBikJ5neN9HiHjtvYkRwjdLcQBh0pM/O6xw5y/YdPJAthUiIWpRUhwvw2kLc wTQd4fL7Ou+A2N9r6ru+koXCb4H/TBj+Qz4oCB/+T9fKhr8Ocdr45zKzTiJKEbBD WBIoBmlo440ZtHDvQiMAaHEEomeSw== Received: from sa9pr02cu001.outbound.protection.outlook.com (mail-southcentralusazon11013029.outbound.protection.outlook.com [40.93.196.29]) by m0380145.ppops.net (PPS) with ESMTPS id 4fkg730c7d-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 23 Jul 2026 06:03:47 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=VfDK02choWBPMONf9nV1d3tdg1hQikWHYNlMVljJianx/qwNgb498m5j/OjeqCNAbdCGOIgp1XlKLZo7lz2QI8Dy8eF/IBJkOIslsyc1u+B2eh0G4ZK78+1p7dpuMEk+N3sNuS0v8Ie1O0hj/Mg/ut3Fbhc2AX9Uaw1jD76KAJtcoBlsaztGZoZdoHBYwjb7EM8XPhaKMAEeHvlHZJHKE7ukLiXg6HTEmw9O6aG2s3SqHUDumaAzpZgCaAnVFhasg4G9n7I8uuMuVR6p2U1UAxmt29OEC9IjzMpXYns3KoVWN2RbdafrSdiwosqjw5OhiXpQqUHAX0iTh3xL29Db1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=3KQVMFD538yJ3bW7oX3qUKzdhPkCw69tpRcHsh0Qlkk=; b=itF7KtdYB42eqC8QyqkucMIgLkcqCHCmtfqqBH29Rb+dsPYAN+4JJCzdyx8csv8cu8GxYL07kxK0SzD0wrb6dTW+svfHvRlenUF/x0oKIbK8xeFCyBvS7hjcZXEj3a6QEFC2VlRZ68y+N/Ln/D/NcxBIste54zghaniN+/0JAdmcs7Hb0jatqRihUPh4px3i6fhcpeQY8WKC6zwuxBWku3GBE24+k+ec4UwyvZLpL3V5vINqXCcrw+Ac9swA90dr1MdGXNdu9/Ng6nznm5MYHkwsUnvul3Unq/KqZq5VOOpgEzlbjAv5CDOqkyWbLtRZu4RDEgJN3XmRCak6TVpu3A== 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=3KQVMFD538yJ3bW7oX3qUKzdhPkCw69tpRcHsh0Qlkk=; b=KazrTWR45QP14sA1/M2fcWHI/q2UnDnT/2GiciZHPN3bfw+Fxim+QrhpS12fzdrO5EKvzmdAam+tRp+oKp6pSsauKqHXv0kIjdIHUy1Z5R0gh8/TBL5aNKWglzhsp1/9J9KsbyK4jdXjGTIEiy6gfA365OvGZXayDt1VBxJrKn4= Received: from DS7P220CA0081.NAMP220.PROD.OUTLOOK.COM (2603:10b6:8:259::6) by IA3PR10MB8759.namprd10.prod.outlook.com (2603:10b6:208:574::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.223.18; Thu, 23 Jul 2026 11:03:43 +0000 Received: from SA2PEPF000015C9.namprd03.prod.outlook.com (2603:10b6:8:259:cafe::3f) by DS7P220CA0081.outlook.office365.com (2603:10b6:8:259::6) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.245.11 via Frontend Transport; Thu, 23 Jul 2026 11:03:43 +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 SA2PEPF000015C9.mail.protection.outlook.com (10.167.241.199) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.270.5 via Frontend Transport; Thu, 23 Jul 2026 11:03:42 +0000 Received: from DFLE207.ent.ti.com (10.64.6.65) by flwvzet200.ext.ti.com (10.248.192.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Thu, 23 Jul 2026 06:03:41 -0500 Received: from DFLE214.ent.ti.com (10.64.6.72) by DFLE207.ent.ti.com (10.64.6.65) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Thu, 23 Jul 2026 06:03:41 -0500 Received: from lelvem-mr05.itg.ti.com (10.180.75.9) by DFLE214.ent.ti.com (10.64.6.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Thu, 23 Jul 2026 06:03:41 -0500 Received: from santhoshkumark.dhcp.ti.com (santhoshkumark.dhcp.ti.com [10.24.52.55]) by lelvem-mr05.itg.ti.com (8.18.1/8.18.1) with ESMTP id 66NB2OW91577597; Thu, 23 Jul 2026 06:03:36 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , Subject: [PATCH v6 13/17] spi: cadence-quadspi: reprogram CS timing on every chip-select switch Date: Thu, 23 Jul 2026 16:32:15 +0530 Message-ID: <20260723110219.3180747-14-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260723110219.3180747-1-s-k6@ti.com> References: <20260723110219.3180747-1-s-k6@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF000015C9:EE_|IA3PR10MB8759:EE_ X-MS-Office365-Filtering-Correlation-Id: 2908fc95-6c0e-4362-d5f8-08dee8aa0ec5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|376014|7416014|23010399003|36860700016|921020|22082099003|18002099003|3023799007|56012099006|10067099003|6133799003; X-Microsoft-Antispam-Message-Info: Q1m6kMuvHskOajIKfPooGQDv2zhnaTQzuVRUqqREHzE+4uND7Hc7ad8zP72EqoKYuS37WjNXLotDXfS3uzwU+7K2HXi4L7GSBV0J1BZALmG+OPRqPvkE3UU38zcrUln6TrebICvdvqmU4SxWACYamjEFiSNX5D/wn/lz7gj5wkpzgnLl+JIr0X7MVExtkVPxxMklV7fXwQlIlL7/7pyajk/orGzqKSrQOSdDL9Q976L2GdLWNF+Vm3rVk5GA55KdvYAl9u4UbNdmEzXOORiOk6GbpC6/5A4M6P6Rl4ixhT8sl/L8dBuN9GjSAUuDG1PUsPOwvjQBi8Si43H8xgunb3GpKUn4nn6lBeoUZSCHBp52T7kXX6+Ju0qQosj3Xw0Kbg/ZSsxmqf5UP1k/hjDUxLf0BhG+V9NOS04ijXpvYGI+iq9ac8TKGa6R73o0jBwI3i5CP8iyD9aIOJJJDF8yvTckO5uwBfTHygwyxxJM5NQIKhUG6JTe8oRKFPMuD7O35ep5TfM25fF4coQUGz28F2UxjybqU+5DypaH3Ov2gfBXAAjIyDR+Xfm5BcnGI+uT81iLJWhFu9pbzDL1VTUZfdUORTwkFAYtBCyZUcRSA6OHXC85OLS6r2l6yrzkN2SAu8FRPb8XLxZjqF/NhVPO5yT7NNwD3LMhfCBEHay3TQGW2uen4KABt3iRkim1V69iy3rJ6ESTmBNOCxpZ3fUup7NbaUEF+ZxjVntFL0h6npWf8fysF3yLX4XrIaopN9X6 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)(376014)(7416014)(23010399003)(36860700016)(921020)(22082099003)(18002099003)(3023799007)(56012099006)(10067099003)(6133799003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 14aJnfrrf7HXFNwIS8042HfPbaHT5VyEnKolpMotz8ebM4X6TeAMnWwRE1db8Tzo3CbMkRo6otE+F4pKVRF52VYu3xqonIdDcOqu8f6lORP2q2aIZKQ1f9+Wt7Ndr5NC98vCqWSZ2/m2j9hdOcALURaQki/jq4hSVp7D36GEM/527GPJK8Jn5vef1duCiVD/n0RlJy9pVjdysWIK0C7l0GNcS4Hgmc5Sp7E95KhdVe97oelhYtKFpNz4fOc9FOKI0X3oEtimYdX6OJPrSxpM1EtnLqfF2aAL5XixGHAEQZO/xxPMayoW7Ajrhxg715U23ZgDG4oLGU4T6HVECVORG/VFKvb338g1ltv+hIeNW3tlyldQH2uP0kHFzemC+1roqsMGAfo5SOcirD4m3uN3nn9haziBN5Sf8f5L3z+JFVrb5XdNzM9YAHlZIrGyAUfw X-Exchange-RoutingPolicyChecked: QEwjnXUYgpbzmGbOsWG0hbApF6+z/I9BgMsSbhEa+aU2WKqZBoyUxOSX/NlVgw0od/yTmcTea2ng0/q+x5Cpz9/LojP4L8BLrEA5CDX2aolNb9Y2121Lt/aeqDXR3WOv4LaKJMB50sLhWDiNJK9nEw47pt98kx0duhs+GF1PLoNjQJoiCYWlUB6AlpFyj5DJMdIwGiIfW7/oyVZ/9AerZFf5+8emdE3nKdtugCJSX//U7lMoLpq3/gtNuQvuOSnFN5+l+Qeh/imaEb2cDiNzRLGLc6GtHs81QXQkSkZU3BCTSUAbUIRlib29XqyfbxbIQeL9qs8uczQ3vI1rgJvkNQ== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jul 2026 11:03:42.2381 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2908fc95-6c0e-4362-d5f8-08dee8aa0ec5 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: SA2PEPF000015C9.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA3PR10MB8759 X-Proofpoint-Spam-Info: AW1haW4tMjYwNzIzMDEwOCBTYWx0ZWRfXzbOFiEMUeriz 89y5RSeeMFco36LeYP5QVhRS0uCQo/CHqe2pzD47Yiwe9/f91JNEbvp47cVICw1VI/NMn+0Q73j pWAllgB+sDOaMP1DI9sMpPtxdCmROeA= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzIzMDEwOCBTYWx0ZWRfX8HydHqMb/nIU CUVvHBzYsx9hJ49tkSBHAyFsplwq85mNnc946L/w51lGXerHI2CMeFqMtfRbBb1psF4da2YvNvh 0IVuOTrkmgzHz8itsW2oeiMvVrYKEUfWKb6nY3e3yRSTffBQC61CDl7j7QK6vaA0AYdQWlkgSaN H1LwpVT8Df1HwV7M7PLnfz/z2tNTB+KdaK6sImM4nhKHTbRabfANwOuKJPX0AAaJKaH0sj64NLG llD71KYNunl8KG0XARf4hkfqhU2058ttTRBXuXEKSh4VYTXu4HJjz0YEWQW1fPgb1611Djx33O+ HsZ2Hn20ruionoXLNaHpKDpeISgTD8rpOylLXcEOpE1fEpdeh3/S0WhXBl9L8sxWhIpBvTLe5Xe RDidrD44J/0oQWbMI2iytlq+YnnCflvWFJQb/HzC01nNJ8pJuNR/yRn8S9CJqARZX7u1Y/mqPyK SeaJaISy3yWkOGyfn2g== X-Proofpoint-GUID: QYDsWxK5zhwYrW5BxLoM8_WIhpatGbkg X-Proofpoint-ORIG-GUID: QYDsWxK5zhwYrW5BxLoM8_WIhpatGbkg X-Authority-Analysis: v=2.4 cv=Z/Dc2nRA c=1 sm=1 tr=0 ts=6a61f513 cx=c_pps a=y599upwrfiZ3HV94zaFOUg==:117 a=iwqwCZQqcuTv3JOpYdM7/Q==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=RAioF0-LDSMA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=gO1vWkAQAl3rybz1DQOp:22 a=sozttTNsAAAA:8 a=okWzP3EbMLmikBYkquQA:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-23_03,2026-07-22_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 lowpriorityscore=0 malwarescore=0 impostorscore=0 bulkscore=0 adultscore=0 clxscore=1015 priorityscore=1501 spamscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607230108 Content-Type: text/plain; charset="utf-8" cqspi_configure() only reprogrammed per-device CS timing (CQSPI_REG_DELAY) and the non-PHY read-capture register when the clock frequency changed, not when the chip-select changed. In a multi-device setup where both devices operate at the same frequency, a CS switch leaves the previous device's timing parameters in hardware. Split the update condition: baud rate divisor is updated on clock change only (it is frequency-derived), but the per-device delay and read-capture registers are now updated on any CS or clock switch. Signed-off-by: Santhosh Kumar K --- drivers/spi/spi-cadence-quadspi.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-qu= adspi.c index 542ad331ff16..8bf3a5a8bf43 100644 --- a/drivers/spi/spi-cadence-quadspi.c +++ b/drivers/spi/spi-cadence-quadspi.c @@ -1570,10 +1570,19 @@ static void cqspi_configure(struct cqspi_flash_pdat= a *f_pdata, cqspi_chipselect(f_pdata); } =20 - /* Setup baudrate divisor and delays */ + /* Update baudrate only on clock change. */ if (switch_ck) { cqspi->sclk =3D sclk; cqspi_config_baudrate_div(cqspi); + } + + /* + * Reprogram per-device CS timing and non-PHY read capture on any + * chip-select or clock switch. Without this, two devices at the same + * frequency would each see the other's timing parameters after a CS + * switch, since the lazy clock-only check would never trigger. + */ + if (switch_cs || switch_ck) { cqspi_delay(f_pdata); cqspi_readdata_capture(cqspi, !cqspi->rclk_en, false, f_pdata->read_delay); --=20 2.34.1 From nobody Fri Jul 24 21:53:02 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 87D8046AA70; Thu, 23 Jul 2026 11:04:05 +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=1784804651; cv=fail; b=mevZBeCpAmPTMlDQWJlHmvZcZWTuetTVx+Gq5SgEyDycb13dexdxOmn/dwo//89R764mHeIVYq5DDkI3vQ8xFuuP8Da2Grq5lNsWEJ9VxXDX5TOFFzm1JdfruQP/mMDTtl905/eO6YCkOj12EtRRifWWcZhuPR++UTdvc//FfHM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784804651; c=relaxed/simple; bh=EgPd8VbcyrS6pF5XRBydAegNzfoN1Y0GfOtUmoBoCs4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Hbx6sDuFUPkw17XtPhv1vPi4gO0KeXMe8WMy9Hfanh3Hy8qLmHF3/9rCnfMOKVvNXdAMPXMDTN26JwnsuHhkv+jK04z2bZpYBik6jo5U5SSL84OEcR0dIyFVTYh8YxtAfKohpnvjX/vf1x1pIJ12kl9PS4Jsl+Ebcki2RzphsRs= 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=C2+ACR1H; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=q3+SeUPF; 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="C2+ACR1H"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="q3+SeUPF" 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 66N9I8xf2039510; Thu, 23 Jul 2026 06:03:53 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint-05-2026; bh=VdoYsWBenFgsbLRwW1KUBdy/3KraCabI36s9hznhh gI=; b=C2+ACR1HmqPrG44R/asWF28ZQUD7vofV+gpIOn45umti96c/Kvywht087 r3/QVSSljHUumzSDyLlc/UI4cLKHLbudVW2BG++UIRyw01CbCjrhGe0QcsmOh84H uu9JIF+fIoJ3GJiREIjegtgI0ARaSDTplcKrisqCQLVcFRpHRmnO/D9K5KauuIzn WWbhzSTnYn4zAki30Sd3lAolFRdNSBeQmPLFX8V/CCZN73cB4WYWO/ZWezjhU+oV X7XqcMDhbDTMCTOo4gh+b3ZeL80Scv5bvhfLFZ75i40VdIXu7WaLL6gUmiw7pFg3 00DTnalTUeVTutf0aOTSbyw+fws+A== Received: from mw6pr02cu001.outbound.protection.outlook.com (mail-westus2azon11012039.outbound.protection.outlook.com [52.101.48.39]) by m0380145.ppops.net (PPS) with ESMTPS id 4fkg730c89-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 23 Jul 2026 06:03:53 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Teub6oWlF1p/MTVCv63nOy8q0DhSKmoWlO/JJySkKc3tQdkTLxyoeVBu4MxUHNZ95eai3unTjhnBKvMDUo27JCngxDbuPPvyGkMQgEnRerzm2LtWTle21WkqQACj/ugjlPAukSL0PEpFAEBpGaoWmr+aAp6d007pxozGpio5Ety2lWE0IrRzmlDiNwNBOpgVL5saNNqRCXxnNqk7AYlgC3nyxiZxGyzsT9Z9FuFjS0/SLXTuFX5LireI23kwfj+RRZbJBSZ0kpgmvxpvP5gD2AqWnyBR/cO1GXpDvixh71zz8eei9zYm5SiT+6GxYbgfr8kqOj6yzxxnFoYisWPISg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=VdoYsWBenFgsbLRwW1KUBdy/3KraCabI36s9hznhhgI=; b=APhN+I7aA9edoxFGr9hy+9z736zhE8QGGQ/OWtMJ2FpVLkTcyg/bPpnOz1D5SbFBsDA7SnmwmwlV8Xfd+WeO5rJoeRyxx65xk4GNVIv3lGN//CvuA7yiK8KCKpMhMSyLp18P8JiziMPOmWaKxfdoYI79Vsfs3K3JW20eDkHuzo6Pc8LrIWIL0BWsa5PSBrMAWipOCuGZegNoXeNLpV8Qwuirz/SB5uwmNhR7LhUzpwm4/H/E/bemZm1nGxfSIx1j16PZd+Pgi7IsqkWkmEiZfkoYT1R2JiW3Xqlipu5VmrwoyJMTa0Ia2oG1lGh2VFBQNVblY3FNWEiaA+0Swgx2ow== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 198.47.23.195) smtp.rcpttodomain=lists.infradead.org smtp.mailfrom=ti.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=VdoYsWBenFgsbLRwW1KUBdy/3KraCabI36s9hznhhgI=; b=q3+SeUPF5ijqpDi5FsnEo2gGIXTkNVuyQIdtW2yKPABNOtg28JHD/J6VNwpKDIxudLcYMLJ1GUxoXR/8aW/oVqLrYv6V0SMwF+OK1qKgyKhU9SywtDOkjuLvodW/HonTdWL6sbPz/Xe3bVUcVZxXiJJ0Ak3KXrawbh7omfL1Zb0= Received: from MW4P222CA0027.NAMP222.PROD.OUTLOOK.COM (2603:10b6:303:114::32) by DM3PPFEC98198CD.namprd10.prod.outlook.com (2603:10b6:f:fc00::c55) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.245.11; Thu, 23 Jul 2026 11:03:48 +0000 Received: from MWH0EPF000C6193.namprd02.prod.outlook.com (2603:10b6:303:114:cafe::6b) by MW4P222CA0027.outlook.office365.com (2603:10b6:303:114::32) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.245.11 via Frontend Transport; Thu, 23 Jul 2026 11:03: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 MWH0EPF000C6193.mail.protection.outlook.com (10.167.249.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.270.5 via Frontend Transport; Thu, 23 Jul 2026 11:03:47 +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.37; Thu, 23 Jul 2026 06:03:47 -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.37; Thu, 23 Jul 2026 06:03:47 -0500 Received: from lelvem-mr05.itg.ti.com (10.180.75.9) 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.37 via Frontend Transport; Thu, 23 Jul 2026 06:03:47 -0500 Received: from santhoshkumark.dhcp.ti.com (santhoshkumark.dhcp.ti.com [10.24.52.55]) by lelvem-mr05.itg.ti.com (8.18.1/8.18.1) with ESMTP id 66NB2OWA1577597; Thu, 23 Jul 2026 06:03:42 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , Subject: [PATCH v6 14/17] mtd: spinand: extract variant ranking logic into spinand_op_find_best_variant() Date: Thu, 23 Jul 2026 16:32:16 +0530 Message-ID: <20260723110219.3180747-15-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260723110219.3180747-1-s-k6@ti.com> References: <20260723110219.3180747-1-s-k6@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000C6193:EE_|DM3PPFEC98198CD:EE_ X-MS-Office365-Filtering-Correlation-Id: 6eae1107-ae3c-4e90-6263-08dee8aa1237 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|36860700016|82310400026|23010399003|1800799024|3023799007|56012099006|18002099003|22082099003|921020|10067099003; X-Microsoft-Antispam-Message-Info: 72rmeUi7TL5/E7uGfSv9r/y4xl/1zxWLwUELqEbeJSpUI1hKTXc52IRuTcYwOmHt51eH3qfB+MFAwksqFvtCtKZYAE2z9IpVulwWXbSts4rLicQk0KcJLz2CPR+WmrmCyCVcZO1ftkD9yaWY2GtShVPL2iazEb5ubtmUNdV8p5HlYj0ag/xKJsZNPMn94t4pJYAqcoyOu2PqYUsDHUpNUcMuW33NdZ3PU/jZBrfgT9F0/akIb9tXOTLtdJmNcS5Z9o3WkSrGfrczRQlKtsUGh1PzjNoEiXZJA0EYINKY7Gk0kIc1kuqUEqF5WaZMNSXmkPWSVgrShON7V25ZDY6Df8/4YI1MO66yrzuaCwrNvYsU5ZAJBVuU41zXB0239g8xhF5KMScQW6l1hGq4zxfYI/GYG9LPqvYpwk85MLUFhip65FktFty7fyCmf5S5NXYdysHU/3WGcQgee99wcNzlU5hx7bC5yh6edRE5C0osVSX9CtFhaDDORiK6hHSnKa/4gpVii/FRRCg/nqM6oabAXpHMWl2EoWnVRfogWBhiQMADvRyxiZ5edYWnZBumiC4j9oDsV9Xe5iilB7zoRhu65kb2m3HkU1WtK5mA5aPYlUDRQmu5fNc/GFyBrq1gN1rML6YG69BCC9RNvlCPss+z0JpKfBmrcLfDDUZhS/0m+fgVplT85mbiTNmsBd/Pfa8bDr7JpujrCr8lxYZVGbTWNEnumm1OMIxQyuO+l5SByJ+q7nTn/rS9rkF790H3xpUE X-Forefront-Antispam-Report: CIP:198.47.23.195;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:lewvzet201.ext.ti.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(7416014)(36860700016)(82310400026)(23010399003)(1800799024)(3023799007)(56012099006)(18002099003)(22082099003)(921020)(10067099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: wfj/WrzM8y9oYgIgYcTYT4Uwe3vTN0Nd8eRjrMNiXFs7LRAQd/Qesumu5+f8mbK/EGR9q/qw2TiDw86r6iLWaB1510wfoRTck9kFiiDkpeX/08eceA2jS3Wd7U3tnCkLfO/7eranbEL1rlLr9h8Beo64PCF+bbn8h6LgIhtql+bSChTLjSiZat1DOo0ng84FausP5a3ZaN1YyJbIGBqmn4oVWiB9PIkdRVRyvlbC97mJkFNILv1OYYQ96s8MASBCLBp3WH+GJnCqQbkHIU13WwovgOBxTm0K7IM24Qa9Vux74lwhVhhA1M6UO00Oge7i0iSbbaLJ2wmxb3SerCoFQ6EFvDaO1mZXo1KYu0QPe1WCzpruORIEsPCiQ261wKbYmVpuK8RtsPgGFRaArfobpzmfDwDFP1nrQ2qoJEIeBmb/MwwAw88pBNx7RUP8tzkQ X-Exchange-RoutingPolicyChecked: h8vMYBbcC3/ZwWUXn9ZtbWqnpECqDbFu6IH5eF+zI0RIMZKfuKZZ4YuSPL5DstItwesA97oLg7bImcVHScng3Zh2zAHBIww9BBLywJwCuTbXBCoMN3YWoKpBztH8HY5QaIA/CXfJBOFyWUEUfVK7scMG1ei4LNdcNE+Yws7S1CrKlrYcqTyNCX7PxDxeGXgicl7V7qMOSyDpT30ce8rztPl7gjlfwK3e77pq6dIGaPQhqd06l3Hixzp5sysR0BLJbMaX++hXRvC1YrwxLQOGg3Yp5TZzr4O8lZInjENjAnuxwwvA+d/3CNnrNG32sPi95OJSknKichkPFywtT+/C2A== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jul 2026 11:03:47.9497 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6eae1107-ae3c-4e90-6263-08dee8aa1237 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: MWH0EPF000C6193.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM3PPFEC98198CD X-Proofpoint-Spam-Info: AW1haW4tMjYwNzIzMDEwOCBTYWx0ZWRfX1vfkMxR4ZRAx evdaGbeJ0u0H1Rmh/Sc2egsiSjSxI9CZu1uRc2U3IeqOj43Jml4KOtrekjYsaDqMI7cQrC7rnBU huoYTqv7ArGuS0cuzLMHrxWWwqa5/B8= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzIzMDEwOCBTYWx0ZWRfX+C1rw+2nAUId BvMOV4txRae61xCCMZZDPLPapRPdSUhGV+yHmZOy9bz7RXQAxXgfThH2cX1Mm2Rl2XVVc8ggN1L gP5QOeXUaYIeauKc+/F+krEJyGDnJZpspiUmbpqsxreQlI9QkPxgTZyRdFizbnQJiVoV9/CRUXc 1gf5AtiDxAD/MM4Y+w7ZZV3T7B/C2QI70ayE2tJQkPT3Klh4riBL/HmYgkl1CurA2jDuH/a1M1N uTIyrSLblvuSPQ+dTdcetquCrHwpdxqJ+PstGmEV04aVPIHsVwy/sNb15KCkGAa4kwPrZyZNBrh /At1SpZTcLZOx5VpgDpjAedrFMn9VqjJGdy8Yv2vngQzbcnmNC9YjIel+AoJb3uRysKZyaxLk6L rqNs8/RLRfdDAUphslQ/G/76D/PJYrs7F3NoIWsFaWY4C3rbUruwPIUoUhcOo81Mv1ys4UDg0Q5 8CQHRbiK0eNc77ZJDAg== X-Proofpoint-GUID: ziajPMycfSB_4T35WXAhbnY1nY60n80S X-Proofpoint-ORIG-GUID: ziajPMycfSB_4T35WXAhbnY1nY60n80S X-Authority-Analysis: v=2.4 cv=Z/Dc2nRA c=1 sm=1 tr=0 ts=6a61f519 cx=c_pps a=8rPU+5JwkgyrUHCwJFKWcg==:117 a=f+v6EHfkeJbVwR46tk4DMg==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=RAioF0-LDSMA:10 a=s63m1ICgrNkA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=gO1vWkAQAl3rybz1DQOp:22 a=sozttTNsAAAA:8 a=mFCyQ4P7OL-0BhijAlUA:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-23_03,2026-07-22_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 lowpriorityscore=0 malwarescore=0 impostorscore=0 bulkscore=0 adultscore=0 clxscore=1015 priorityscore=1501 spamscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607230108 Content-Type: text/plain; charset="utf-8" Refactor spinand_select_op_variant() to extract the inner loop into a shared helper spinand_op_find_best_variant(). The helper takes a skip_mask bitmask of already-tried variant indices, enabling callers to iterate variants in ranked performance order while skipping those already attempted. spinand_select_op_variant() becomes a one-liner wrapper. No functional change. Signed-off-by: Santhosh Kumar K --- drivers/mtd/nand/spi/core.c | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c index 8bf9301f25e7..7c3341f1fca0 100644 --- a/drivers/mtd/nand/spi/core.c +++ b/drivers/mtd/nand/spi/core.c @@ -1542,9 +1542,22 @@ static int spinand_init_odtr_instruction_set(struct = spinand_device *spinand) return 0; } =20 +/* + * spinand_op_find_best_variant() - Find the fastest eligible op variant. + * @spinand: SPI NAND device + * @variants: full variant list to search + * @iface: bus interface to consider (ODTR or SSDR) + * @skip_mask: bitmask of variant indices to skip (already tried) + * + * Iterates @variants, evaluates transfer duration for each eligible op, a= nd + * returns a pointer to the fastest one not in @skip_mask. Returns NULL w= hen + * no eligible variant remains. Used by both variant selection at init ti= me + * (skip_mask =3D=3D 0) and ranked PHY tuning iteration. + */ static const struct spi_mem_op * -spinand_select_op_variant(struct spinand_device *spinand, enum spinand_bus= _interface iface, - const struct spinand_op_variants *variants) +spinand_op_find_best_variant(struct spinand_device *spinand, + const struct spinand_op_variants *variants, + enum spinand_bus_interface iface, u32 skip_mask) { struct nand_device *nand =3D spinand_to_nand(spinand); const struct spi_mem_op *best_variant =3D NULL; @@ -1552,15 +1565,16 @@ spinand_select_op_variant(struct spinand_device *sp= inand, enum spinand_bus_inter unsigned int i; =20 for (i =3D 0; i < variants->nops; i++) { - struct spi_mem_op op =3D variants->ops[i]; + struct spi_mem_op op; u64 op_duration_ns =3D 0; unsigned int nbytes; int ret; =20 - if ((iface =3D=3D SSDR && spinand_op_is_odtr(&op)) || - (iface =3D=3D ODTR && !spinand_op_is_odtr(&op))) + if ((skip_mask & BIT(i)) || + spinand_op_is_odtr(&variants->ops[i]) !=3D (iface =3D=3D ODTR)) continue; =20 + op =3D variants->ops[i]; nbytes =3D nanddev_per_page_oobsize(nand) + nanddev_page_size(nand); =20 @@ -1589,6 +1603,14 @@ spinand_select_op_variant(struct spinand_device *spi= nand, enum spinand_bus_inter return best_variant; } =20 +static const struct spi_mem_op * +spinand_select_op_variant(struct spinand_device *spinand, + enum spinand_bus_interface iface, + const struct spinand_op_variants *variants) +{ + return spinand_op_find_best_variant(spinand, variants, iface, 0); +} + /** * spinand_match_and_init() - Try to find a match between a device ID and = an * entry in a spinand_info table --=20 2.34.1 From nobody Fri Jul 24 21:53:02 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 558AE46AEE0; Thu, 23 Jul 2026 11:04:09 +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=1784804655; cv=fail; b=VjGSweHSL0X3onqkg9UNxSPi2XBUkbWZeq36bbrR3DcqdzgmYed/6BzoFaiWBs+oW4888HUV5f7owq0WN0F6EB2qy4gN2Q3FpsWgHdY4xK8TxNMl8HHou7B+EAaXgHF4DRiw+7ZBQ8IPgidQVrfq475hso3zONAVUhTefytw3e4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784804655; c=relaxed/simple; bh=klTCINip5Cd5Q6sQw9ppFW49YqgxdSsn8/+OTbEeEkI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=UhhVTIZehCM3c/ZiNXohn1nDoYqtlGaYTABdzQCK5uT/FH7YJ2jL3jaPZ2RaQlM0RETktXBEcJoJCJOOh2EHT+Usdqf2LLaL1LhT64CXYr2H2SRiLeLOmZT1rJo3CmydlS5Z/9mSYv63LEHXOFtPuW6HvFLNUAII0sSFF/YF1+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=D6TLqKYl; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=CIf0LHBH; 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="D6TLqKYl"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="CIf0LHBH" 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 66N9MG9H4111037; Thu, 23 Jul 2026 06:03:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint-05-2026; bh=/t8AMDRHjLNpJH6jG/YwirgiSkZJEXr7FStcsZDms sQ=; b=D6TLqKYld2hzLZgYkXGJXibTfNYjn119JRUY+A2Ug2vbKof+cNB2tom9K 9CHhCuw+whrcfkz8kjI6ORGo2KowXBk7/+Vas66c/hXoNic8BtXSXlHaZCCrm0TI 6n3ZRvLdVQ9KL/CiySMDTnbJ/f6Ez8SDHYG8KolLcRKkLzJYWiU+yBcbAuRDs1R9 Dk/FMkiagHIPk1FT7FmqjzR0XpnnY8/LJBpvFJzoZuUVAUWu3UtuOuDuau8ntjNx hdtxovHj28KmvYr56RLU2tCKFyB5PbUprApshWVm98YcAO0Ex6vySfoY1NY+h5Y6 xmWAfbzmEHk7tAEd528KIIkYV0keg== Received: from sn4pr2101cu001.outbound.protection.outlook.com (mail-southcentralusazon11012019.outbound.protection.outlook.com [40.93.195.19]) by m0384305.ppops.net (PPS) with ESMTPS id 4fkg908cxx-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 23 Jul 2026 06:03:58 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=YvdzLQXVqdx9nVUaksjITD/L66y5Y9aMYd7UXQdpNmGGpFqiwjLnpOs1MUMQdnTVOgKUNhN+yxfbuAf10nq7nxdTC9cLvU8SqzCwZ1uQKyVW7lV2duGJ2J2kb0NklECQhnKGZEIbTca8avDXD/93lLMkimAY0t1KmI0tbvD0Kz8ETNiI17PHnGuTQf12hUfczwvQUIHbRrS66WuULpcDh6vSB4pIQ76SEZuYaBhItnmN+c16M6Uo4hIEh6QWBe2YOSJPQ/tTUwSzX/n1P6ce/jlJO6YpO7C0PosSALtUK5WOOKA3iksJRXMG6yRjypv87pQqIMKuUQAylLnW3XtvFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=/t8AMDRHjLNpJH6jG/YwirgiSkZJEXr7FStcsZDmssQ=; b=pye3W8mkUHrNoBoA8qxPBCfGS6xuasCY/CCgm9ezdFNMFa/W5JIXS+PdpM57PEqgSD7QDcsvpjCnVaC22uC7lM/VjUxrktgKFk1N3dKvefmMoaGRBqDTmt15+VXqnGeyw97aWD1Cuh50VGJ7I5a92l5NBLfbNQe7DpOE8bqPayoK6m46BXdMpfysnMz18qczHFUNe+iTwFkmNAvv5tnW6sQGHM9e+oIwyNty1jlEaKO6Tfx2mxVJpP2LKS0tg4x9wlvlHaWJqnsJHYYQOVlZnE9qLmMeS1gnY1cUbdRWjTotdLatK4kCBElKT/iQSR3LGnz0h768MHj53xkLTWe3Tw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 198.47.23.195) smtp.rcpttodomain=lists.infradead.org smtp.mailfrom=ti.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/t8AMDRHjLNpJH6jG/YwirgiSkZJEXr7FStcsZDmssQ=; b=CIf0LHBHHHAemzqDvQYyoBJmSU/NJ5maJrmAY5SQNuK8KYlmqfv6I57sL/Oi4l9A/V7x5n0nPrxoZ2TpOOosvFkPYY87p9TGvrE2fV1T0hOmpSCoVRz9Oi6LzQEVn3hUHD3HRyq/xijpbRsVVd5eCgmgWPkgLR0OX4SoFb4jG5E= Received: from BY1P220CA0045.NAMP220.PROD.OUTLOOK.COM (2603:10b6:a03:59e::14) by MN6PR10MB8118.namprd10.prod.outlook.com (2603:10b6:208:4fa::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.245.10; Thu, 23 Jul 2026 11:03:54 +0000 Received: from MWH0EPF000C6194.namprd02.prod.outlook.com (2603:10b6:a03:59e:cafe::30) by BY1P220CA0045.outlook.office365.com (2603:10b6:a03:59e::14) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.245.11 via Frontend Transport; Thu, 23 Jul 2026 11:03:53 +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 MWH0EPF000C6194.mail.protection.outlook.com (10.167.249.104) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.270.5 via Frontend Transport; Thu, 23 Jul 2026 11:03:53 +0000 Received: from DLEE215.ent.ti.com (157.170.170.118) by lewvzet201.ext.ti.com (10.4.14.104) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Thu, 23 Jul 2026 06:03:52 -0500 Received: from DLEE201.ent.ti.com (157.170.170.76) by DLEE215.ent.ti.com (157.170.170.118) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Thu, 23 Jul 2026 06:03:52 -0500 Received: from lelvem-mr05.itg.ti.com (10.180.75.9) by DLEE201.ent.ti.com (157.170.170.76) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Thu, 23 Jul 2026 06:03:52 -0500 Received: from santhoshkumark.dhcp.ti.com (santhoshkumark.dhcp.ti.com [10.24.52.55]) by lelvem-mr05.itg.ti.com (8.18.1/8.18.1) with ESMTP id 66NB2OWB1577597; Thu, 23 Jul 2026 06:03:47 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , Subject: [PATCH v6 15/17] mtd: spinand: negotiate optimal controller operating point before dirmap creation Date: Thu, 23 Jul 2026 16:32:17 +0530 Message-ID: <20260723110219.3180747-16-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260723110219.3180747-1-s-k6@ti.com> References: <20260723110219.3180747-1-s-k6@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000C6194:EE_|MN6PR10MB8118:EE_ X-MS-Office365-Filtering-Correlation-Id: a4a0dbf3-78c7-44c5-3360-08dee8aa1562 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700016|376014|7416014|1800799024|82310400026|23010399003|10067099003|6133799003|56012099006|18002099003|22082099003|921020; X-Microsoft-Antispam-Message-Info: YKaSK2/fw86h2MqPFgTHT4M71FCeSNmnRhmXq91s+nYQ01QLdw7ZCuW5xxo0CXluWiwVa8/FyhzT/YuivQXKn5uzfyvNGzAj4cLLirdWCMwsVgO3sF81l84nJnExFJGYnEBMhX2Eifs5H+4/7WmWvUc2/0Je+0E8qUkRl0xAY+rL5ApCJ6IdUZRGPP5QuB7HfvQc87fTftfkW2Ucwnhjmk0fkli0JY9EHshcwZfD0hXxkbqpf3aKEOMt6YyksdzlrVVFDVFwyHPfhQmWzXtZJG9IFQj9PSTAQTCWaDGq/VIRkW4bJOWv6pb7wrGx3uBuAwIr/GY6YBJo/nhwGp2Mxcy9WkaFDvn3xgxj++x6+uMdD3YNZoiW4HSGsE9tL4x9mxg0J3+LmIMKhbeskLEDPD00uz2zAacObUgmxnAAtDh0/a2HHkb8vZ6x3lPHdsDEhom49mWrUXCRYDIVOhZtgCCZBpVdsR0kD7WD0Y/sFoyApAHBi1GuT96H3xwtPU4UfrhGqj/4Z6AwbVp53ppeioqcKFXfWGnQgvrWfPSgj2DpLJ7+XPQrEoMIeNcXBh3GwgDRrfQQIv737U1zqAE2ELl7jS4A6lV9AFvFpM8rpCZ1ApFoi5KWCS54G4UbPLhYMlqUpCA1aLE/JlSQOS2+HxL/WJ6YnzW8tWRc+VHkZASa+Ophlgb5zoM/XIeCseylBA1Me3GsDdBNWlBew9+aoZlmaBVwJFZ2eeTZLy/SFpBrPEv2byeVtAWbluJWR+x+ X-Forefront-Antispam-Report: CIP:198.47.23.195;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:lewvzet201.ext.ti.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700016)(376014)(7416014)(1800799024)(82310400026)(23010399003)(10067099003)(6133799003)(56012099006)(18002099003)(22082099003)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Y4+zCMmTqWEVmHooQaTVQepYEe+9abybIkMo7OAAaXLRv1X6C5DD4pJ/4wDXNKOiscjct8qdtH33zqkGJRTEyE+8NjCJbsE1ZZ/aPDc+YaNSTuZxucCfSQ4lpwuB8PX0JXZA9AqnwqHs9HtYm6qeR9AArUWhFv7NeHrytAOQTzYzQ7w7nkQmCUS+0a9uPJNYDjZQT79N1BZCYgBXfJyKO0Bbs7fBJoSX3TL/Vq0wSQnjr9EjtMJTL8m+BQUiGityPD809fabo0252f6EmPSV+Z/2neNXZ+jVBhMQQDWAp26iFYYBq5wvBE68G7YRORSX8GLOQMcW8rmnoqpNobtZcYzZY0/TFmGqqv228JJph53IUB0YEukL/A6GF5+QR8OWPX/zxHtoo7m8ZqgkwwwfOISSSCUyZDbVUyaHNJ9n+WlWAWdcKJRYhmcS1v5tsgIc X-Exchange-RoutingPolicyChecked: kRswZQQNUCRR6ZY86iDpcvwswSvseg2z6CQE1j9Li8NdY23cQwHCMaguCUpzPNV9CnkKn/dG50T7kwREmb4N7OExrXyPeBrBKVLEwSx1bt73KFwZuFDnq908tcQfkbX46KFs4hhoy427D5K25JezImbwSJ1WrBlPiX+eDJP6X6XSr2PV1SRJuQ2MTY2kWykGYTEawAK+m3bS5tgy61SscVIAo9GHiP/5MelCTeNyNTwKbIU338u/9ayRQi3v4hZQKg+KNX8+FowlJgXXiUdi/ULUutTze33ug1ZnxyVkgSKCuJILf6X0pKWEwRZqP+F6AldxXb5h04XNp2728U7syw== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jul 2026 11:03:53.2773 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a4a0dbf3-78c7-44c5-3360-08dee8aa1562 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: MWH0EPF000C6194.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN6PR10MB8118 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzIzMDEwOCBTYWx0ZWRfXyxNF0YXcl+PZ HBKw9jFdPCVUwL6fSIwzhlNpRToiiCyWbkVyAlWRe0UxY/FhgYGJVNK+7AyLo2+Vl5AvtdgSnzW 9LCcdF8qZgvFTHAR32O/JyhYAKBlUPLjSBvW/sz0jR0zsyS8F82ivfCRqDJoEit84JoTx30q4ir s1abPw94taPUig61gJRCIaqDBjnZF4X+eIfwxMeUOVGMixbHcDKHq9SljKuggtjEvHd5IlirLT1 tccIsPrFMZYHRBCcXbjMUzdFjfBiP8nW61DaPc06n8IhO4OP9eIqZn5XRtJ+MImnBC7rq5wjIUs 7Fp8WSoWmJjT1DK4iSv+OTQL65f1P+maetDKSVUMvh9vLirgNtIY5xI81we/6KHka1m+hqKP43j xFw7a1gYm/G3uhNxR0CKxPAkaegV/O0c74D1Cc4xyqPv4dv9wSqVDkqtIPbdgW1eUKG81vXAdF6 scC7VQ4FXMC6NluqPyg== X-Proofpoint-ORIG-GUID: he9Jg7myGknCTrgjVKwnK-STt4amHQHJ X-Authority-Analysis: v=2.4 cv=EeT4hvmC c=1 sm=1 tr=0 ts=6a61f51e cx=c_pps a=7Di9vct5tcmjM1itADynpg==:117 a=f+v6EHfkeJbVwR46tk4DMg==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=IkcTkHD0fZMA:10 a=RAioF0-LDSMA:10 a=s63m1ICgrNkA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=taLDd7a_hP9WKsMzeGRc:22 a=sozttTNsAAAA:8 a=U5cn0f2nyUSNena3quMA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 X-Proofpoint-Spam-Info: AW1haW4tMjYwNzIzMDEwOCBTYWx0ZWRfX9u/XHEn9TwDe Fy/r4DDdVk+7A8FQFUtWFkh7V59FheD9s+e7fICnSF4im4AswcNF3Hc5nBNAuBp8Cr31KCCCsFE zeL2Q8QEky38FofkHUtJzysQne6ofnY= X-Proofpoint-GUID: he9Jg7myGknCTrgjVKwnK-STt4amHQHJ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-23_03,2026-07-22_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 bulkscore=0 suspectscore=0 impostorscore=0 priorityscore=1501 adultscore=0 lowpriorityscore=0 malwarescore=0 phishscore=0 clxscore=1015 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607230108 Dirmap descriptors encode the op template including the operating frequency at creation time, so controller optimization must complete before dirmaps are created to ensure the validated frequency is embedded in the descriptors from the start. Move dirmap creation from spinand_init() to spinand_probe(), after a new spinand_optimize_controller() call that negotiates the best available operating point. spinand_optimize_controller() tries the pre-selected variant first. If the controller signals that optimization is not applicable for that op, spinand_try_ranked_variant() iterates remaining variants in performance order =E2=80=94 ODTR variants first, then SSDR variants after switching the bus interface if needed. On full failure the device falls back to the best available non-optimized mode. Add spinand_reset_max_freq_ops() to copy op templates with max_freq zeroed before each execute_tuning call, enforcing the invariant that a non-zero max_freq only results from a successful operation. Optimization failure is never fatal; the device operates at the conservative base rate. Signed-off-by: Santhosh Kumar K --- drivers/mtd/nand/spi/core.c | 206 ++++++++++++++++++++++++++++++++++-- include/linux/mtd/spinand.h | 11 ++ 2 files changed, 208 insertions(+), 9 deletions(-) diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c index 7c3341f1fca0..b79d06d9ddaf 100644 --- a/drivers/mtd/nand/spi/core.c +++ b/drivers/mtd/nand/spi/core.c @@ -1284,6 +1284,7 @@ static int spinand_create_dirmap(struct spinand_devic= e *spinand, info.length =3D nanddev_page_size(nand) + nanddev_per_page_oobsize(nand); info.primary_op_tmpl =3D *spinand->op_templates->update_cache; info.primary_op_tmpl.data.ecc =3D enable_ecc; + info.primary_op_tmpl.max_freq =3D spinand->max_write_op.max_freq; desc =3D devm_spi_mem_dirmap_create(&spinand->spimem->spi->dev, spinand->spimem, &info); if (IS_ERR(desc)) @@ -1294,9 +1295,11 @@ static int spinand_create_dirmap(struct spinand_devi= ce *spinand, /* Read descriptor */ info.primary_op_tmpl =3D *spinand->op_templates->read_cache; info.primary_op_tmpl.data.ecc =3D enable_ecc; + info.primary_op_tmpl.max_freq =3D spinand->max_read_op.max_freq; if (secondary_op) { info.secondary_op_tmpl =3D *spinand->op_templates->cont_read_cache; info.secondary_op_tmpl.data.ecc =3D enable_ecc; + info.secondary_op_tmpl.max_freq =3D spinand->max_read_op.max_freq; } desc =3D spinand_create_rdesc(spinand, &info); if (IS_ERR(desc)) @@ -1745,6 +1748,17 @@ int spinand_match_and_init(struct spinand_device *sp= inand, spinand->cont_read_possible =3D false; } =20 + /* + * Save the full read variant list (ODTR and SSDR ops) for + * ranked controller optimization. Only saved when all ODTR + * templates are valid; spinand_optimize_controller() uses this + * to fall back to the next-best variant when needed. + */ + if (spinand->odtr_op_templates.read_cache && + spinand->odtr_op_templates.write_cache && + spinand->odtr_op_templates.update_cache) + spinand->all_read_variants =3D info->op_variants.read_cache; + return 0; } =20 @@ -1923,7 +1937,6 @@ static int spinand_mtd_suspend(struct mtd_info *mtd) =20 static int spinand_init(struct spinand_device *spinand) { - struct device *dev =3D &spinand->spimem->spi->dev; struct mtd_info *mtd =3D spinand_to_mtd(spinand); struct nand_device *nand =3D mtd_to_nanddev(mtd); int ret; @@ -2015,14 +2028,6 @@ static int spinand_init(struct spinand_device *spina= nd) mtd->ecc_step_size =3D nanddev_get_ecc_conf(nand)->step_size; mtd->bitflip_threshold =3D DIV_ROUND_UP(mtd->ecc_strength * 3, 4); =20 - ret =3D spinand_create_dirmaps(spinand); - if (ret) { - dev_err(dev, - "Failed to create direct mappings for read/write operations (err =3D %d= )\n", - ret); - goto err_cleanup_ecc_engine; - } - return 0; =20 err_cleanup_ecc_engine: @@ -2051,6 +2056,175 @@ static void spinand_cleanup(struct spinand_device *= spinand) kfree(spinand->scratchbuf); } =20 +/* + * spinand_try_ranked_variant() - Try controller optimization on variants = in + * performance order. + * @spinand: SPI NAND device + * @mem: SPI memory device + * @iface: bus interface to iterate (ODTR or SSDR) + * @tried_mask: bitmask of already-tried variant indices; updated on each = try + * + * Iterates the full read variant list in descending performance order, + * skipping variants in @tried_mask, and calls execute_tuning on each until + * one succeeds. Ranked iteration finds the best available variant without + * re-trying already-attempted ones. + * + * On success, sets spinand->max_read_op and updates the matching + * odtr_op_templates.read_cache or ssdr_op_templates.read_cache. + */ +static bool spinand_try_ranked_variant(struct spinand_device *spinand, + struct spi_mem *mem, + enum spinand_bus_interface iface, + u32 *tried_mask) +{ + const struct spinand_op_variants *variants =3D spinand->all_read_variants; + const struct spi_mem_op *best; + int ret; + + if (!variants) + return false; + + while ((best =3D spinand_op_find_best_variant(spinand, variants, iface, + *tried_mask))) { + *tried_mask |=3D BIT(best - variants->ops); + spinand->max_read_op =3D *best; + spinand->max_read_op.max_freq =3D 0; + ret =3D spi_mem_execute_tuning(mem, &spinand->max_read_op, + &spinand->max_write_op); + if (ret && ret !=3D -EOPNOTSUPP) + dev_dbg(&mem->spi->dev, "%s optimization failed: %d\n", + iface =3D=3D ODTR ? "ODTR" : "SSDR", ret); + if (!ret && spinand->max_read_op.max_freq) { + if (iface =3D=3D ODTR) + spinand->odtr_op_templates.read_cache =3D best; + else + spinand->ssdr_op_templates.read_cache =3D best; + return true; + } + } + return false; +} + +/* + * spinand_reset_max_freq_ops() - Copy op templates and zero max_freq on b= oth. + * @spinand: SPI NAND device + * @templates: op template set to copy from + * + * Called before execute_tuning so max_freq starts at zero; execute_tuning= sets + * it to the validated clock rate only on success. A non-zero max_freq mea= ns + * controller-optimized; zero means the base rate applies. + */ +static void spinand_reset_max_freq_ops(struct spinand_device *spinand, + struct spinand_mem_ops *templates) +{ + spinand->max_read_op =3D *templates->read_cache; + spinand->max_read_op.max_freq =3D 0; + spinand->max_write_op =3D *templates->write_cache; + spinand->max_write_op.max_freq =3D 0; +} + +/* + * spinand_optimize_controller() - Negotiate the optimal controller operat= ing + * point for the SPI NAND device. + * @spinand: SPI NAND device + * @mem: SPI memory device + * + * Tries the pre-selected variant first. If the controller signals that + * optimization is not applicable for that specific op, iterates all remai= ning + * variants in performance order. For devices that support both DTR and S= DR + * interfaces, DTR variants are tried first; if all fail the device is + * switched to SDR mode and SDR variants are tried. On full failure the + * device falls back to the best available non-optimized mode. Devices th= at + * support only SDR skip the DTR ranked pass entirely. + * + * Optimization failure is never fatal. + * + * Note: tried_mask is u32, supporting up to 32 variants total across both + * ODTR and SSDR. Flash devices with more than 32 read variants are not + * supported. + */ +static void spinand_optimize_controller(struct spinand_device *spinand, + struct spi_mem *mem) +{ + u32 tried_mask; + int ret; + + /* Skip entirely when no post-config target is configured. */ + if (!mem->spi->post_config_max_speed_hz) + return; + + spinand_reset_max_freq_ops(spinand, spinand->op_templates); + + ret =3D spi_mem_execute_tuning(mem, &spinand->max_read_op, + &spinand->max_write_op); + if (ret && ret !=3D -EOPNOTSUPP) + dev_dbg(&mem->spi->dev, "Controller optimization failed: %d\n", + ret); + + /* + * Any non-zero return or a set max_freq means we are done (error, + * unsupported, or success). Fallback only for the op-specific "skip" + * signal: ret =3D=3D 0 with max_freq still 0. + */ + if (ret || spinand->max_read_op.max_freq) + return; + + /* SSDR-only devices have no ranked ODTR fallback available. */ + if (spinand->bus_iface =3D=3D SSDR || !spinand->all_read_variants) + return; + + if (WARN_ON(spinand->all_read_variants->nops > 32)) + return; + + /* Mark the pre-selected ODTR variant as already tried. */ + tried_mask =3D BIT(spinand->odtr_op_templates.read_cache - + spinand->all_read_variants->ops); + + dev_dbg(&mem->spi->dev, + "Optimization skipped for current op; searching for best variant\n"); + + /* Pass 1: try all remaining ODTR variants in performance order. */ + if (spinand_try_ranked_variant(spinand, mem, ODTR, &tried_mask)) + return; + + /* + * Pass 2: switch to SSDR and try all SSDR variants in performance + * order. configure_chip is guaranteed non-NULL here: reaching ODTR + * mode requires it. + */ + if (WARN_ON(!spinand->configure_chip)) + goto use_odtr_fallback; + + if (spinand->configure_chip(spinand, SSDR)) + goto use_odtr_fallback; + + spinand->op_templates =3D &spinand->ssdr_op_templates; + spinand->bus_iface =3D SSDR; + spinand->max_write_op =3D *spinand->ssdr_op_templates.write_cache; + spinand->max_write_op.max_freq =3D 0; + + /* Only ODTR variants were candidates in Pass 1; SSDR bits are clear. */ + if (spinand_try_ranked_variant(spinand, mem, SSDR, &tried_mask)) + return; + + /* + * All attempts exhausted. Revert to ODTR for non-optimized DTR + * operation. If revert fails, stay in SSDR =E2=80=94 a mode mismatch + * (ODTR op templates on SSDR-mode device) would corrupt data. + */ + if (spinand->configure_chip(spinand, ODTR)) { + dev_warn(&mem->spi->dev, + "Failed to revert to ODTR, staying in SSDR\n"); + spinand_reset_max_freq_ops(spinand, &spinand->ssdr_op_templates); + return; + } + +use_odtr_fallback: + spinand->op_templates =3D &spinand->odtr_op_templates; + spinand->bus_iface =3D ODTR; + spinand_reset_max_freq_ops(spinand, &spinand->odtr_op_templates); +} + static int spinand_probe(struct spi_mem *mem) { struct spinand_device *spinand; @@ -2073,6 +2247,20 @@ static int spinand_probe(struct spi_mem *mem) if (ret) return ret; =20 + /* + * Negotiate the best controller operating point before creating dirmaps + * so the validated frequency is available at dirmap construction time. + */ + spinand_optimize_controller(spinand, mem); + + ret =3D spinand_create_dirmaps(spinand); + if (ret) { + dev_err(&mem->spi->dev, + "Failed to create direct mappings for read/write operations (err =3D %d= )\n", + ret); + goto err_spinand_cleanup; + } + ret =3D mtd_device_register(mtd, NULL, 0); if (ret) goto err_spinand_cleanup; diff --git a/include/linux/mtd/spinand.h b/include/linux/mtd/spinand.h index 5f4c00ae72a7..7eacda949719 100644 --- a/include/linux/mtd/spinand.h +++ b/include/linux/mtd/spinand.h @@ -792,8 +792,19 @@ struct spinand_device { struct spinand_mem_ops *op_templates; enum spinand_bus_interface bus_iface; =20 + /* + * Full read variant list (ODTR and SSDR ops together), saved when ODTR + * templates are valid. Used by spinand_optimize_controller() for ranked + * fallback when the pre-selected variant cannot be controller-optimized. + */ + const struct spinand_op_variants *all_read_variants; + struct spinand_dirmap *dirmaps; =20 + /* Persistent op templates updated by execute_tuning with validated speed= . */ + struct spi_mem_op max_read_op; + struct spi_mem_op max_write_op; + int (*select_target)(struct spinand_device *spinand, unsigned int target); unsigned int cur_target; --=20 2.34.1 From nobody Fri Jul 24 21:53:02 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 2A4C945DF51; Thu, 23 Jul 2026 11:04:16 +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=1784804661; cv=fail; b=XLUxTeqeS5iG31n9Zes2jR35IYYYKFkx7ydkpsWgjzIIFH49FBVWr7bzV8VSYfewLNCht/YjzAicytFpjVcquPWFm0/2f/eX0WXD40tN4Gaz3HTvxXhF2swd9r8PYLYEXJcrIUg4MWepg9eOG6bP+S2U3kggsnSQ1TyEzQ/PSGw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784804661; c=relaxed/simple; bh=zyzIHZWkbZiJeCTqvhBe5bpyE69d/84Z/bMFLKqBSj4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=uULs7dUO96X5u+0sti1m0pOj5Rbf8D6hU8aaattmZMkahZ4PBqaQ/6v7dV0faKF9spN/3kZkAK8pmezyra3dWm+LgRIdmKPH6Bdxj5bNJ6gOJse+f9CY9qulpQrPRo7cWZB4+rFGWZSsMO5j/fpRqdadn+IqozVOKHw6zwRJ1uE= 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=NdEHmJV0; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=TGLWYmtf; 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="NdEHmJV0"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="TGLWYmtf" 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 66N8t3Tc1974385; Thu, 23 Jul 2026 06:04:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint-05-2026; bh=NjiltEpWKo8+XGVIPeclBhOkyH3dhzzS6Rxspq0yy U4=; b=NdEHmJV0+fJZ297uUWTd/nhQCHgVsg7qwju+bQqSSQIGseCP3KS54XULE 6Or3rpbL1k1JT2aUeUjlYF8TRMZbePhYtXl0gSqv42cDfzZ5LP2Skl3PvPVLFtap DgNN0cgyNOJV+++I6E+tn2LV7wQhfdGvnzgWJ3mThCYvQTBS1+zYBvK6KAX0nV0L Fys0h2nbWY5yl1MeYl5GOaiJtoxCnZy+oAfJpVOT+EB8IspjjGtvDGVNq6oDiejo My3R3RJgllferZEUfJPZLxl7eaRAcC6DlL9ADs0sBdRb2f9rCLBwWUpNa+terDLA The84cnA6nbxmu4zUVhPWNJnCJ+8Q== Received: from dm5pr21cu001.outbound.protection.outlook.com (mail-centralusazon11011038.outbound.protection.outlook.com [52.101.62.38]) by mx0b-0002e601.pphosted.com (PPS) with ESMTPS id 4fjwjbxthh-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 23 Jul 2026 06:04:06 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Xv1jsdkgkviBX4RrLyAkY2Y1KUkAuov1f8Ip99Btwqa5mpNrYJYkuQjjnjcNkMb+v1t6pil5QPxdqtRFNXPr8QDro8tntrdMybZl7313oiUxmtO5TPGm0kCGINGzmO1DLudnoXBh3Jy+8dUCEgOYO0NZSfOhxlKNmoPHtcPXQ+eNcy23uGIk577tDwh4uBXVnWBWP1DJNmdob0D7cGv/Qpme4DtBm/49ANjZCOpi34B1cb7sqqPvh9fNlDhSj8EWOTsQR0J3pFt2tF7tcdzza+Y8lu07eU3cwOMCdvbI5BWOHZ6ieaGPwNO6ZKKI8eU3gdKpJDcfJLLwrDSM2QOdOw== 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=D2EILIaZQ4iz4o205jVaDarwnhERj24ATLqzOKOub4jCOo/ABZOQZh3ZHOkA/vVB0WKjhO7kM5tz5i8qT0OMOdVJAtlrc7sHWvysDV3by/5AGMmNLyf4mKKsO5536MrREP96lZHtw0kPWCCXr96sf+gZ2uL5byqnAslYcGZIWEpH3yrMjRoaWQoHpRJjMNCfYJkOvxzo3OwdUfv8Xpwn0S7dBM2bycV0GRtS1ZKvQ4oZhtHsoKe/PP6AP2cexcbQImfmVdrwveqnTFSAfUXaugc3/aa8ByUmKBeonTlmharkpMIklbuuUKWCB4WWLi4BkiCXHqh70VP93t7c/4dk9Q== 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=NjiltEpWKo8+XGVIPeclBhOkyH3dhzzS6Rxspq0yyU4=; b=TGLWYmtfMZZn7CE9C25HAwO4amoYb58hjEDo++2sSjGaDO29WpbuH280LiSw7Zh4yerzBT+JwFJFaWAmtEDjHOYG7AzpyPY0RROJGsoeny7p2C9J1JnySHkz2FXBjq9kG9O7lrezhtHSRKtrM+UVGUWj994oNwYRFdQQ7yJzHYM= Received: from MW4P222CA0003.NAMP222.PROD.OUTLOOK.COM (2603:10b6:303:114::8) by IA1PR10MB7114.namprd10.prod.outlook.com (2603:10b6:208:3fd::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.245.10; Thu, 23 Jul 2026 11:03:59 +0000 Received: from MWH0EPF000C6193.namprd02.prod.outlook.com (2603:10b6:303:114:cafe::4f) by MW4P222CA0003.outlook.office365.com (2603:10b6:303:114::8) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.245.11 via Frontend Transport; Thu, 23 Jul 2026 11:03:59 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 198.47.23.195) smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ti.com; Received-SPF: Pass (protection.outlook.com: domain of ti.com designates 198.47.23.195 as permitted sender) receiver=protection.outlook.com; client-ip=198.47.23.195; helo=lewvzet201.ext.ti.com; pr=C Received: from lewvzet201.ext.ti.com (198.47.23.195) by MWH0EPF000C6193.mail.protection.outlook.com (10.167.249.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.270.5 via Frontend Transport; Thu, 23 Jul 2026 11:03:59 +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.37; Thu, 23 Jul 2026 06:03:58 -0500 Received: from DLEE211.ent.ti.com (157.170.170.113) 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.37; Thu, 23 Jul 2026 06:03:57 -0500 Received: from lelvem-mr05.itg.ti.com (10.180.75.9) by DLEE211.ent.ti.com (157.170.170.113) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Thu, 23 Jul 2026 06:03:58 -0500 Received: from santhoshkumark.dhcp.ti.com (santhoshkumark.dhcp.ti.com [10.24.52.55]) by lelvem-mr05.itg.ti.com (8.18.1/8.18.1) with ESMTP id 66NB2OWC1577597; Thu, 23 Jul 2026 06:03:53 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , Subject: [PATCH v6 16/17] mtd: spi-nor: extract read op template construction into helper Date: Thu, 23 Jul 2026 16:32:18 +0530 Message-ID: <20260723110219.3180747-17-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260723110219.3180747-1-s-k6@ti.com> References: <20260723110219.3180747-1-s-k6@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000C6193:EE_|IA1PR10MB7114:EE_ X-MS-Office365-Filtering-Correlation-Id: bab235e5-0252-4ca3-0d18-08dee8aa18d3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|23010399003|82310400026|36860700016|376014|7416014|1800799024|3023799007|56012099006|10067099003|921020|22082099003|18002099003; X-Microsoft-Antispam-Message-Info: hXhRjZNpF+gd1Cu/5eTpGy076YZJ/gQGIczM/7bjbUMshQuA/tB5IAGfU+vx4ThWlFLP/5Y/wX0A677PWMnQDFbjuNyViF61tSc2LqbQzlAx64YIJ94mLMb9WlMsHzRPYkn8eTWNYmzIR/ikWY7vT1VqHaqRSKNiVZleq0/l0vG0vbstQBq0tTkG0rhgXeiDSmq00VoEMEuJ3Pq1BERHZ5iyJb1QWNe7Qi2aS2auqQrJhPqgnGQ7lPysx/gODTxv9wA9lqOhXj4f306gQ0rRqxFs8oxjsTGvuqJJmf3m1lFLtzTVUsO0VNwAUl98p5iBi0XXyu9B8SyrUHHxgVtXng1NORH4Lc/zdmyHiOOPG6W7UlPUOzoCHZ+c4kLL/76L5lP99VXXQO4uMJnzazrlyNE3Zvc9Zjrm/fxCrfD+wErZV5zUhcPahH2+M7PaoVgMTWMwZpwDhQslKbMrJ1ODAaYEVcwVp8+bkFNv3j1TrZKT33Sfcgev7hyqtX+e/PiUINTCNqhUmKI8hEwZ1Z7VREsPJFWaigCsUfdSgakeSqdmssh1uvIA2B1slyFruiBRP7SJOY59WaQ0l9NDzGhKMwzCBuG7EwVTzp1GOFbzhn1P2tg+bDTe9Si2dbPeJ793H7l3GhB8fGjleaiiR9OH46Jv9akHTc7lSuXnTZRkORgoUjEFeOmW9fKVJEejS5vz0FbOwDlRcg3AYnRfBCCTTuWLzOx3KQOrQlWK2QqKJr/p3wmEJqvdlcM5Qh7U2PYW 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)(82310400026)(36860700016)(376014)(7416014)(1800799024)(3023799007)(56012099006)(10067099003)(921020)(22082099003)(18002099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: RovVbBks3ESbiaFdv+HNXXrQIFcwt3du+WfIAdzcPrjsm2c5v7b/2ECxogL3T8DoF+BOUV8ipT01ygxeT4zBBN0P/xwLIgJiXUCV5vSQiD32C0b81Ey1ESf4zMef4i2smldwVdwRvKTlsqUBqZv02ia2aNqemxLLBg8EOpX85vt26p0j6cr1q5ksNReQsGmPu1DIxratZhWRkPLaF1mw+vkMdZ6RTv34HulzLvWzHCGpydbjXX8/CUAeBkVuq/h1dghDNNE+Kgf28FmDL33Bkwf25X6B/hgXurqLqLEE9Xt3R5OiOCiakaBi2yB+jJbR1lblUf48Gk7zTM99i/KQB4jgFX/MaF+/323/XoNkjOZ+mjFBDDDWu6MZ5g+SoRI5ZAIJLPPRDZ5J4zoyS9Pbvcos4+Qjdt55ktQMaJIHQVvpllIa7cbWDEll4JPiT9/3 X-Exchange-RoutingPolicyChecked: dEWS5t9Knbn2LixhQxaxqzBi+QOWaGN5yKtk9Vea1rgMCKTH18rXh/Mm39GzBjPY8SUQilLnGWSRLR6MMxibStZM9tbYMs3RExm3f7BQIeu04xb3kNUHh8gcfarLdDOUqzYUXQvzhBf+Lq/KR6FOBR6c5icDurPO3ACEsw3B3ZXTEPiGZdohI0Q2vC9GWCaWD0jzgOeRCH/TuF0IeBeqBNFzMGALUuiw1adgOuZSKsqo0rQs1otVbSKxEX+rn/I3dVELyjZEJBS2tE6b/psRU7+1TTNAHzdjcT7yxxQyuO3L6sP+fdMzEDQLu6fwMAkvG1BS5rYbX3ePwXP/lhsLhw== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jul 2026 11:03:59.0365 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bab235e5-0252-4ca3-0d18-08dee8aa18d3 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: MWH0EPF000C6193.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR10MB7114 X-Proofpoint-ORIG-GUID: fi9T88fyMVEDiwi71EDHtKdZmK8-ikWO X-Authority-Analysis: v=2.4 cv=LPRWhpW9 c=1 sm=1 tr=0 ts=6a61f526 cx=c_pps a=5I5pDAtSp800fId2YpAiPg==:117 a=f+v6EHfkeJbVwR46tk4DMg==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=RAioF0-LDSMA:10 a=s63m1ICgrNkA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=fPAWb5peG099m5CrUpKH:22 a=VwQbUJbxAAAA:8 a=sozttTNsAAAA:8 a=XAftrYwPDLqUVEEHSKEA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzIzMDEwOSBTYWx0ZWRfXxgN6epr8Urmk 1Bab1wf0ejjQMQuwfzvCAYNy8rY/YjqujwbdDwtjnY2/TbVJQ0kLLLY0On8kBSyUZ2ENkeC6pgD 2DTSVgTA7FlpW+9/8TGfIjgqpEMr4ds1R+pHIPFwUhfn3eYpeqS2p4J1/c5Pu/VT087jKTV3fwQ 1RIZNXbgLhtaXoiHhsM+C6cJwhTZD5gEGrY1lK4OxtjVJy17gADW4ah8+YHYBhBJdnhqYy6rTyz V4DfzXbY+un/2qZFKaQzdHfTnbCQp/Qs3GMDHta075DJev6o4vT+uGGJnwrqVTXe3kcTHxw0p5C R7vY8SZzd8AXyL1me2egvuzVSVqASBE/QtUxxgpK7kShK8r/aaFUZ/VPDwCkXGppPTp3OnF5u9E 1rGqKDOYqHZ4IkIGC8lTA8mCc1N4S6tgMFSZ2HeTaaTcAPkUdtguAai/AhoURMM3UGUWc5rbUqv XbdSb2ey2al53hLIeIQ== X-Proofpoint-GUID: fi9T88fyMVEDiwi71EDHtKdZmK8-ikWO X-Proofpoint-Spam-Info: AW1haW4tMjYwNzIzMDEwOSBTYWx0ZWRfX6TMX1NGtDi+Y zstO1FLQ5MDPXf4D294KSmNp3hXezJRHTJB/H3mKLJB98wY32c2RulnSBdoYc9Zk0GtoyBcXi8x 072swyUtkxS40wWPsCpkRbqvpuLo/tU= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-23_03,2026-07-22_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 clxscore=1015 lowpriorityscore=0 phishscore=0 priorityscore=1501 impostorscore=0 adultscore=0 suspectscore=0 spamscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607230109 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 Fri Jul 24 21:53:02 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 5E1B945DF4D; Thu, 23 Jul 2026 11:04:19 +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=1784804661; cv=fail; b=f7+Apj1c+NzE88Nqj9RaEJY7Ta56jkuEkmp+mblKHyC3YoxU8v7qFis81kIYe3IQId1Bp0+xdYa1ImIOzOk/zQqFE6pKwKTRVKfJ6ZR2jqNrw27ZCpmPwPGVHy/0f+YoLL10fR3ikQAJTknyd7uvPReNaPZG/bWC/oj0apSQ7fg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784804661; c=relaxed/simple; bh=QCZfApz0WI4MJamsj+4VqpsLIBBqXuUtwo6CKXU3FV4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HY837s389IVrh9apvA7YAwW1OYd9bhKsxFGikBGhrlJPjCeAxnSFkMgs70PGiYvI52RToHmSYi/n5bpOkd62Gs3/VM6LedJ4564y6QY4WO0ZuYlF9ovrNX3dHbrJK+LqagoTnHXPhQ9qgzIAQgxSYinMlgYviABVEfzERVATS8w= 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=BNMYfKdP; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=BIqXxrFb; 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="BNMYfKdP"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="BIqXxrFb" 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 66N9I7Zk2039430; Thu, 23 Jul 2026 06:04: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=CaKka2TXrNmZxg/2rKa+E19ixmWvfwzQpJ0sWclJR yk=; b=BNMYfKdP05qySWf/e9FYv1EhVoGyURvq621yqKQ/7c2VrjFqZRWYyWDdW qpdQlQHzRb4ED+l+KoccU0RRutnsSTelobmvKoKTxGxGzpa8CB5pqpyNn4oUUNX8 G7637jJMYTrBDbtVzcUC4z+MH8YDWZ7/ZHjBbKZWeXsSkEh6xwiSYrh5+6tJzU7H /GQ3dy1lB3Og0hSrZlKe37kfYfjqKQNmkv9o/bJa+SH58OIlcDh/AqgXeAc6nKIZ 2t+o8+y4Mr/Rs7FW7Kh+hw1EOtnRis9R4oeQOWlR/Ta0IUPlfkczQKpAnaETiKsz LZ+q53qjtycx8D84G3HrkHdR2i8ug== Received: from bn1pr04cu002.outbound.protection.outlook.com (mail-eastus2azon11010051.outbound.protection.outlook.com [52.101.56.51]) by m0380145.ppops.net (PPS) with ESMTPS id 4fkg730ca5-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 23 Jul 2026 06:04:09 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=iIwou2kTvwDeXMgwuAEJBnU0QKVk1/JCCdNQxyNCZCGTAnX6ZPiCi0GAIeBO9k6xB89WwxLneSR+ekVJ8B7JcNjaAlZgIjAel47TWPfLDpTp2lojlUAS4k9Xg3zlvt5uv4mm+YcMmKFqxAmJto0XKA7rKX3HKVFL28/x6lmSsav8yOKxN/9kE8pgMth6UAX5by7TRZPiBg/MmmqZyIgs6oZqkjcIt1LXLPpq5gWI3W7ajubM4+T4F4IXF8EE+yeAt80+mQSXG8X1J07AuRn7yhrMD6j+K80xg7L5A70uQgwYSRolu5SvjNqxGmk+XCxuCctYWY5OIbL3Q394OYM2yg== 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=hsgI9h91OCb+FOLm5mxvVPNd/gQsIV6TIqxdjxMyU4a8Zu6SznLHoWGYBiyIGGxU3bk+sqVEXK5qe+Q1UfHm5LGiGQFwemuU7oMUDzp296a/sBNFvH65kc+RRmqZvvpUakLoaTVbrrgX68u2nTAlnXl0P3PxfjTX4FyDPEHHg4xMzwu7Hj1/0z90J0AtVXo9W22Rk4f1v5iZFZ8N8pURUhCap6/r+Re8BnIBt0Vs90AW0EP/g5pqfgFLXbW1Ixn8RlG58p43DP5lyaEXVrMIv8X5ti1IfaPG6y6dCXhLozIg8OFa7ZKGZ8ZbuAW/wd1KA97OjS0zK0EvAz7bh8oStg== 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=BIqXxrFbWHMiCY0ID/QfHN2auWX2auxEpukmLe/tNGvuifffSlslQILZQd2YSDQcmRWD0LxFjOSfdeYYsJXn3cL5kb1esNNGL2hfvOgLN36gnyKQ6IA9Ed3zztyTbbSfkl6Tqk4HO7hVNA5g5y679jWwMPyzKoOP46o5mlRNZjo= Received: from SJ0PR13CA0085.namprd13.prod.outlook.com (2603:10b6:a03:2c4::30) by CHAPR10MB997697.namprd10.prod.outlook.com (2603:10b6:610:2f5::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.245.10; Thu, 23 Jul 2026 11:04:06 +0000 Received: from SJ1PEPF000023CC.namprd02.prod.outlook.com (2603:10b6:a03:2c4:cafe::ab) by SJ0PR13CA0085.outlook.office365.com (2603:10b6:a03:2c4::30) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.270.6 via Frontend Transport; Thu, 23 Jul 2026 11:04:05 +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 SJ1PEPF000023CC.mail.protection.outlook.com (10.167.244.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.270.5 via Frontend Transport; Thu, 23 Jul 2026 11:04:04 +0000 Received: from DFLE210.ent.ti.com (10.64.6.68) by flwvzet201.ext.ti.com (10.248.192.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Thu, 23 Jul 2026 06:04:03 -0500 Received: from DFLE201.ent.ti.com (10.64.6.59) by DFLE210.ent.ti.com (10.64.6.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Thu, 23 Jul 2026 06:04:03 -0500 Received: from lelvem-mr05.itg.ti.com (10.180.75.9) by DFLE201.ent.ti.com (10.64.6.59) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Thu, 23 Jul 2026 06:04:03 -0500 Received: from santhoshkumark.dhcp.ti.com (santhoshkumark.dhcp.ti.com [10.24.52.55]) by lelvem-mr05.itg.ti.com (8.18.1/8.18.1) with ESMTP id 66NB2OWD1577597; Thu, 23 Jul 2026 06:03:58 -0500 From: Santhosh Kumar K To: , , , , , , , , , CC: , , , , , , , Subject: [PATCH v6 17/17] mtd: spi-nor: run controller optimization before dirmap creation Date: Thu, 23 Jul 2026 16:32:19 +0530 Message-ID: <20260723110219.3180747-18-s-k6@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260723110219.3180747-1-s-k6@ti.com> References: <20260723110219.3180747-1-s-k6@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF000023CC:EE_|CHAPR10MB997697:EE_ X-MS-Office365-Filtering-Correlation-Id: 1ed72577-bd45-46fd-d387-08dee8aa1bfa X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|23010399003|7416014|376014|36860700016|82310400026|1800799024|56012099006|10067099003|6133799003|3023799007|22082099003|18002099003|921020; X-Microsoft-Antispam-Message-Info: ej6/IXDUdos+XKD/qmjeVJIqV8iV1En532qij/ioySokZ24nFDY/y9Eh5uhEytUOgHT8lOXJrv8Wk0Y/VVEwSen4uwgioBaIbTJv0WyClLAjW7q6KudwqZlXtTiKkv61NweHQ8MxafHPnOP8zy/v8I5zwP3txVsQqSwlcBkzEbNHtQFXR8jXJBKw935QnTRx+5zE74LNF/nYcr2vKcRXpZXEZ1+66/bGa3jxLrZEZRRuNf70GV/K3KQ6p0siKFSxGrbLDJM+PCuCR8cgncSxgM1fQAaXGKgfVrNok7Sb20YeZFBdwxpqaykt+2xJcDW8LY7Xur+4JFiiktcTI6MnLCbS7tEGFglamTG2Zt/wNjGPlxw7VUruFqI2jV5fZgXMRGwT+HFM6t5fQZ42/sctGrQWshJY3+MOxbXwoznL/HwwEo1EMNIFORkcOj/DmtPoFn1xvgQbksAeqlf+GM5vphkQtqonQImQRBo6FcShPDxqsFoIY72C161Gg6I0ziL+t6E47lXc5uzQ6A1fwd5cbcnQcLP8comzydou9xU6YwrhZCnLCe+AchwpWpCCs0t7izwY6m+YahTTTqwTli01IlzwNkBANVrHXD+D9x1xK963eedGLvgnLycPIS/ONGFWMbb5DvNxNunBws5yiypA7LxxsY7dEvYYyJa0BMIvCYfKq680GIgP9DSXkdGFiOnCif4s8ljExQ8TWmYIfA1FZdNuqQWL5DfvpWoSkpcd5jtWJGNrXY16Lv4qQaP8M20B X-Forefront-Antispam-Report: CIP:198.47.21.195;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:flwvzet201.ext.ti.com;PTR:ErrorRetry;CAT:NONE;SFS:(13230040)(23010399003)(7416014)(376014)(36860700016)(82310400026)(1800799024)(56012099006)(10067099003)(6133799003)(3023799007)(22082099003)(18002099003)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: vYuovQK656B9yhxrdVTwqN0vAAxzaIa+2UTocni0tSt66711HymRmJ/UxkONkZdWt4boqgSdk1qJyeTu2Q3Gld4yZD13I2Ii5I95ojowi8Jyug5DZg28eEcPsHe8ZYp1XwggzwtQoTnwmOwbbAQR14TX+Mtr+LPJJgJWiPESUu/IUkW6g6NoFpr2JNRcGCXLrwUIdO1s7TzMBXzvfQNvE358GnT2ueud8GaXwbDjBOdS6mb1hG64teJn26nBvYWnccytcrh7Pw0S2nYwT+yI79W9VqBZexjGXCY3JAEQqz8IZgYelKoVrdUUMfMQFhfv+Qhdg4gq0eqkW29HbGQqG56A1Btj6VRoxp1d5H9+VbUdCTfHLYSWG8K1C+CRjURKDjYIAV9kBNgHQ9bfAejbCZRe4LM0WwBWv7itBgQDJdy25Xs6BIK7u040uEDALeIT X-Exchange-RoutingPolicyChecked: I7HbNZaHtvJRffMrylipZCE7roGGxZtmsJoarwoaziNFrPrZJsdhoLkEBrOYRlPdT4Eq01YwiT16/TSILNnRbE4fyUo0E0t6G4FHlIlhHz8WkIqTjhkvp6fgRUAD+kVqD9Woj6FU3khcgrsTusljNPPLv70+wRrWSPijUZzA528ZqrabwZhdv5q4+z8ebGtdwiXAxXiV+dt1Lr6nWZCH1Vpqv0ysITznY2je7rb9t6xGzi1epaMw8CPnyLBgyoMW8tcbix4ap8fQbtcS3ym0ArMscdI6LiS4yaXBvzcYokTO619OmpG0cFVsqVSREHEgddSWRdeia7H4DUdqUq9EgA== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jul 2026 11:04:04.3312 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1ed72577-bd45-46fd-d387-08dee8aa1bfa 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: SJ1PEPF000023CC.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CHAPR10MB997697 X-Proofpoint-Spam-Info: AW1haW4tMjYwNzIzMDEwOSBTYWx0ZWRfX7sFaf7EJYEc7 9P4A7J8ppnkxVCsTqHoSjWTWI/ek43MFsbb0AvZPP7TjCDKhQTyjgFPqafKZNdLetSpB1kjMHGv nWynct7phTVclZKCw/XJ+xZXFOi6Pyc= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzIzMDEwOSBTYWx0ZWRfX+0LFjpnvtSGl L+PIFc2LtRRjj79ouZIVzzkIL7SbEnLd9JjuBWz4DWtY541+eK4c3ocrWtxsxbuB+lkbJK+vPmG /IfHq2+lmSu36lIxCiSd2UYrn37B3KxKEidnLoWgOt0f64LUx4ThamMb1xYLvbST2tKc5Tu7zdf uZIqFEWLdAuVaYdRcGtu6uwJCUIFuX516T+L5joOI6y68IhKrG1UDMUfnqy3juuLMaH6g/Y72OQ UorbO6zTF3iKcuWcwbqX0vgRkOz4bDT5QAMwVuomNg82PxI9EQ8V2BAYQqk9UbI10szsrFZO/Pz 1WOsd4JaN937i8081uoxBYaSuu/qNl1EGp+gjW47GmMp1A3PVblprXA82uVUsZ8XCXOiBC4zDPe seUmEvd4W5rLKcd33gDly3mXuah9jiJ1vdxcB8nHrFJHNquyUS1dO3Xt3G2CxhUK/iW3i1x44e6 9ioQICdtRgPcf5RGEiw== X-Proofpoint-GUID: ipLGOF56BzN1Ts5mTewgdVGUZ9BrfzmI X-Proofpoint-ORIG-GUID: ipLGOF56BzN1Ts5mTewgdVGUZ9BrfzmI X-Authority-Analysis: v=2.4 cv=Z/Dc2nRA c=1 sm=1 tr=0 ts=6a61f529 cx=c_pps a=oox2QBUX2gBgMMQWkhdftA==:117 a=tJyPKKxUohctrY4NYmUjkA==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=RAioF0-LDSMA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=gO1vWkAQAl3rybz1DQOp:22 a=sozttTNsAAAA:8 a=dAWDYLcBFR4q-bF-ZFAA:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-23_03,2026-07-22_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 lowpriorityscore=0 malwarescore=0 impostorscore=0 bulkscore=0 adultscore=0 clxscore=1015 priorityscore=1501 spamscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607230109 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