Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1E389606A31A for ; Tue, 1 Dec 2026 00:47:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.u-boot-project.org header.i=@lists.u-boot-project.org header.a=rsa-sha256 header.s=default header.b=NSsLffau; dkim=pass (2048-bit key, unprotected) header.d=phytec.de header.i=@phytec.de header.a=rsa-sha256 header.s=selector2 header.b=T5p20Qu9 Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id DA809607F0; Tue, 1 Dec 2026 00:47:19 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id R-SbReVDzRGc; Tue, 1 Dec 2026 00:47:19 +0000 (UTC) ARC-Filter: OpenARC Filter v1.3.2 smtp3.osuosl.org E471B607E7 Authentication-Results: smtp3.osuosl.org; arc=none smtp.remote-ip=140.211.166.142 ARC-Seal: i=1; d=osuosl.org; s=arc; a=rsa-sha256; cv=none; t=1796086039; b=Ji29EALwU4EmcsFGqhlS88SJ+ysO/GgdWEVKMZFA7f+aYDx6j+s/D0svbi6eDJTUS8l8 HxyXd6S8fD7bwRh5nP5CYQ1D+2NI0QpXGLk5j5iZwb58BVUhfcT5/EljlvfMOt+UB3k9V iAvIoHIsrIwpUnDgxp3YrxyjyrMRHPp7K4BkWSHzGrCg5tDXsWBzq+xX8+UOsoCC5cuGk gkojEl1fYBBv5Wdl5dzhlhOVYX+CWIXd23v09t75K7BB4wP/A3Ig/G+KvI6JFlbwMlFRq 1aEUMfcRON/OebhD7Tfx8leRbElFp3VKi/Jz8NFAkVRXz6BbEsIQI8rHIqqbswsVmSA== ARC-Message-Signature: i=1; d=osuosl.org; s=arc; a=rsa-sha256; c=relaxed/relaxed; t=1796086039; h=X-Comment:DKIM-Signature:X-Original-To:Delivered-To:Received: Received:X-Virus-Scanned:X-Spam-Flag:X-Spam-Score:X-Spam-Level: X-Spam-Status:Received:ARC-Filter:Received-SPF:Received: DKIM-Signature:Received:Received:X-MS-Exchange-Authentication-Results: Received-SPF:Received:Received:From:To:CC:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:Content-Type:X-Originating-IP: X-ClientProxiedBy:X-EOPAttributedMessage:X-MS-PublicTrafficType: X-MS-TrafficTypeDiagnostic:X-MS-Office365-Filtering-Correlation-Id: X-MS-Exchange-SenderADCheck:X-MS-Exchange-AntiSpam-Relay: X-Microsoft-Antispam:X-Microsoft-Antispam-Message-Info: X-Forefront-Antispam-Report: X-MS-Exchange-AntiSpam-MessageData-ChunkCount: X-MS-Exchange-AntiSpam-MessageData-0:X-OriginatorOrg: X-MS-Exchange-CrossTenant-OriginalArrivalTime: X-MS-Exchange-CrossTenant-Network-Message-Id: X-MS-Exchange-CrossTenant-Id: X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: X-MS-Exchange-CrossTenant-AuthSource:X-MS-Exchange-CrossTenant-AuthAs: X-MS-Exchange-CrossTenant-FromEntityHeader: X-MS-Exchange-Transport-CrossTenantHeadersStamped:X-BeenThere: X-Mailman-Version:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:Errors-To; bh=CfHn9xji5F1yP5m3HPWJdDjNW43+oqsERli3kgvy1Oc=; b=L/RPGeKcpMfcorwYelKbLXyiwgGoAoMYyy6rQ3Ubv8i/v1hgTWUo+w1PKUw5E03W+icf 15FmWKCxjFdYYosmc/IevuRRgl8zLaL+fR8v9Jg6GizsEf1F8eF/yDCXXUJmlh2FdW0XE +XPyKRcG0Of1ub+T98M4Rlx3RoHhHcvyl5fOJ8Gmru5uUdzhc8sKnSeoCItxl3hnpM/xt edtzAFa5OYxHAndNcbnEt7sgn4OTtzIjuUpqvEXWkxIZDatXE5o3ychtzaHRlkP5hRl3K b7HcLMkiKoWFZscoEetKBtfNTeaekrQrh+wm0k4aQhPAcQwptuaANLATqVrsb8n4N8A== ARC-Authentication-Results: i=1; smtp3.osuosl.org; arc=none smtp.remote-ip=140.211.166.142 X-Comment: SPF check N/A for local connections - client-ip=140.211.166.142; helo=lists1.osuosl.org; envelope-from=u-boot-bounces@lists.u-boot-project.org; receiver= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lists.u-boot-project.org; s=default; t=1796086039; bh=CfHn9xji5F1yP5m3HPWJdDjNW43+oqsERli3kgvy1Oc=; h=From:To:CC:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=NSsLffauh6YC8TzLhg/6/b5bOQegSurznySQf+HhaE7gXxChoyz2PMEqWlmdkok4p Mzbonw7gfgRyMOTvPrFLlHcUF/iVzsTc7FQiFcvkivg949ihtP+N2TtRggRGtXEd18 tbYJZYGcyGRfSHJRGjuWrMUtZKmNhU5KLgd11DPf6xTgjh5his+r1X9lzbOYalI8gY QMkRWZB7ol+sL4BRS1SZ49i3p+3nugoAJS+fmoWtzQ1WQ8v9QlEDypA38Dw8Pp/YsW 0hbmdcIASdQ/013cYMykgzUvZxa86WhfkdMkWVSdsxyiJPFAbMrSAF1p9QFlSs5Wb0 S8QIK/5IGFxpA== Received: from lists1.osuosl.org (lists1.osuosl.org [140.211.166.142]) by smtp3.osuosl.org (Postfix) with ESMTP id E471B607E7; Tue, 1 Dec 2026 00:47:18 +0000 (UTC) Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) by lists1.osuosl.org (Postfix) with ESMTP id 679F6D41 for ; Tue, 1 Dec 2026 00:47:16 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 4DD0D40750 for ; Tue, 1 Dec 2026 00:47:16 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id Wp9MlXnRHVni for ; Tue, 1 Dec 2026 00:47:15 +0000 (UTC) ARC-Filter: OpenARC Filter v1.3.2 smtp4.osuosl.org F37684074F Authentication-Results: smtp4.osuosl.org; arc=pass header.oldest-pass=0 smtp.remote-ip="2a01:111:f403:c200::3" Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=2a01:111:f403:c200::3; helo=du2pr03cu002.outbound.protection.outlook.com; envelope-from=d.haller@phytec.de; receiver= Authentication-Results: smtp4.osuosl.org; dmarc=pass (p=quarantine dis=none) header.from=phytec.de Authentication-Results: smtp4.osuosl.org; dkim=pass (2048-bit key, unprotected) header.d=phytec.de header.i=@phytec.de header.a=rsa-sha256 header.s=selector2 header.b=T5p20Qu9 Received: from DU2PR03CU002.outbound.protection.outlook.com (mail-northeuropeazlp170110003.outbound.protection.outlook.com [IPv6:2a01:111:f403:c200::3]) by smtp4.osuosl.org (Postfix) with ESMTPS id F37684074F for ; Tue, 1 Dec 2026 00:47:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=phytec.de; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=CfHn9xji5F1yP5m3HPWJdDjNW43+oqsERli3kgvy1Oc=; b=T5p20Qu9ohBrzxN5Y/Ii2sF+x7pnSiSN/BWsvE6QxTGA41aI04DY+gBdluJLA6SVKl2RQnyIWJ62p+KVpY/8CjVQac9SMKGZTnkrnnyBziTmJacEo1TAyvok2hitB9u6AI8ZmV1lipX11UPYmgs4NGFXy8v8ngp95kubXit4U1afp56DCuWfv1Ia1/iLi24e4OtFZSRXUhJI1/w12sGbXF8HIrLSaI6l0LSGGL531G09JHh1QKFNw9sE5u6FcenoxoNBQgrrqUEA/4IMQ1LdYzn3bOEpL/LM/YOi5HEJEB9vdqLdhboYHjYK7YlVR2ad8ac/9maHCP6WPWxbztpzUQ== Received: from AM8P191CA0012.EURP191.PROD.OUTLOOK.COM (2603:10a6:20b:21a::17) by DB9P195MB1708.EURP195.PROD.OUTLOOK.COM (2603:10a6:10:397::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.662.11; Tue, 1 Dec 2026 00:47:07 +0000 Received: from AM1PEPF000C1AD7.eurprd02.prod.outlook.com (2603:10a6:20b:21a:cafe::18) by AM8P191CA0012.outlook.office365.com (2603:10a6:20b:21a::17) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.662.13 via Frontend Transport; Tue, 1 Dec 2026 00:47:06 +0000 X-MS-Exchange-Authentication-Results: mx.microsoft.com 1; spf=fail (sender IP is 91.26.50.189) smtp.mailfrom=phytec.de; dkim=none (message not signed) header.d=none;dmarc=fail action=quarantine header.from=phytec.de; Received-SPF: Fail (protection.outlook.com: domain of phytec.de does not designate 91.26.50.189 as permitted sender) receiver=protection.outlook.com; client-ip=91.26.50.189; helo=Postix.phytec.de; Received: from Postix.phytec.de (91.26.50.189) by AM1PEPF000C1AD7.mail.protection.outlook.com (10.167.242.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.5 via Frontend Transport; Tue, 1 Dec 2026 00:47:06 +0000 Received: from lws-haller-privat.phytec.de (172.25.39.212) by Postix.phytec.de (172.25.0.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Tue, 1 Dec 2026 01:47:05 +0100 From: Dominik Haller To: Wadim Egorov , Tom Rini CC: , , "Dominik Haller" Subject: [PATCH 1/6] board: phytec: k3: Make k3_ddrss_patch SoC agnostic Date: Mon, 30 Nov 2026 16:46:34 -0800 Message-ID: <20261201004644.381033-2-d.haller@phytec.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261201004644.381033-1-d.haller@phytec.de> References: <20261201004644.381033-1-d.haller@phytec.de> X-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: Postix.phytec.de (172.25.0.11) To Postix.phytec.de (172.25.0.11) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM1PEPF000C1AD7:EE_|DB9P195MB1708:EE_ X-MS-Office365-Filtering-Correlation-Id: 05fff6ab-39d2-4c84-ca5c-08df4f449feb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700016|23010399003|1800799024|82310400026|376014|56012099006|10067099003|261028144727099003|261026121527099003|261021123027099003|261022105027099003|261022075727099003|261021121427099003|261026140227099003|261102123227099003|261009223027099003|18002099003|22082099003|5023799004|11063799006; X-Microsoft-Antispam-Message-Info: VZIhagKlmB06rURR6TfYXhIpPT+GVzbbCh+aE3/NoMEfJz+MHKYN9y5y81oDQr43DJ/iIl0mnp/kQy1kM2r6kLhnD8BkJr9+W9/yhjjBxTTD4doVWSrQacAtczNCs0bOCmqWtkE6B8J7mNr0vcoQs+PI2qpGihphq2/Y9VnXcj+spoO8d2V3XRjYe23GRYNXckOYBU4HeHX5DuIfx9S0UFvyoXwsE7qT0Wf05lzKNnbg6W8E0mHKQXfmoz0nz31lq9lmkn/tH9gcZzTDrHaySFzTY/1Q8izJ8EP054qYqNKSV2xoZU+Y0HW2tycLa+7TnvKjAhAXTomwoZrlN2dsTLtu4eb94edu7G2ofWgv9mm6sFJ/9IRoCYD0sbTfcpkasMT/j0TTY+9yMQQ3UdV5rZGh8zQOk5zw+FtNG8gTrvdDhJh4MUqjN43SkR7kVWoxbkBYcARjv+Gk4kufLnG2t3taUsak1wHsT3byKFrIFUIatFlZ+ydG1e4XhZOr98jM6GxoMV3/ZS41HjR3KulLaz42vnpmuLRfPS57wjFSgcmdACyrclPRHNOJTGM7t/95eLn/bEIjC7YavXj+lTDcTgEy4mV0c47czwHLNamyEfC2nvLPuC+3wvuHZUUBjTkiWqw4yRfdKzrHEsqekTu36VmyIizorjAHXajOskoUklvAEFtp71wmxY/zEntk/M9Xr/z9bAN2a3qGGUzwIj1dVg== X-Forefront-Antispam-Report: CIP:91.26.50.189; CTRY:DE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:Postix.phytec.de; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(36860700016)(23010399003)(1800799024)(82310400026)(376014)(56012099006)(10067099003)(261028144727099003)(261026121527099003)(261021123027099003)(261022105027099003)(261022075727099003)(261021121427099003)(261026140227099003)(261102123227099003)(261009223027099003)(18002099003)(22082099003)(5023799004)(11063799006); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: szh566OATP+QRtWVYD2YCYvKRski/j+7uhpKTeRPFnFUAuUcG1QTG1pCl0TAe0D8hrGNwXqEFVj5ICofO2LWlPjZjgu5Vw6/4ritdx6CdT5zd6gxLxW2LItq3jFeU+5VnpsZWktRQqCoBijrHO727/lvwm4Hs5eqGfdl7qdTluDrKXlt3aReyyZ4ULKI9STqeQ6fffCrnob46rVkiSGp23/bduv948gIFiqhxqNyZeTZywQeepB+Gvd6THs5MWGTKFXAGVr6WbvItwjRYB6Av/zK1dmrcalCCG2LStIIrAAX5cCcEwuoCsiP+vJ8WAlnRZ2K1DLbvxfuXd0i6x21h+UBr9/px4sYkAQQuWeCVp1rzy0ceX4ftXxQHSrudmqZEXXZT2Xiz0n5o6yp0gowFQp/TWawQcRhIAiZGZarsJsXoRAJmQn0I1GdtCs5Rqtc X-OriginatorOrg: phytec.de X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Dec 2026 00:47:06.8863 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 05fff6ab-39d2-4c84-ca5c-08df4f449feb X-MS-Exchange-CrossTenant-Id: e609157c-80e2-446d-9be3-9c99c2399d29 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=e609157c-80e2-446d-9be3-9c99c2399d29; Ip=[91.26.50.189]; Helo=[Postix.phytec.de] X-MS-Exchange-CrossTenant-AuthSource: AM1PEPF000C1AD7.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9P195MB1708 X-BeenThere: u-boot@lists.u-boot-project.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: U-Boot discussion List-Archive: List-Post: List-Help: List-Subscribe: , X-Spam-Status: No, score=-18.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 k3_ddrss_patch is somewhat hard coded to support the phycore_am62x which is using the ti,am64-ddrss memory controller. Add the following changes to support the j721s2 dual ddr-controller: - Instead of using static defines for the registers take the property count from the actual devicetree node and return -EINVAL in case the register is out of range - Pass the controller node from board code instead of hard coding it here - Ignore the msmc properties for single memory controller SoCs Update the call for the phycore_am62x accordingly. Signed-off-by: Dominik Haller --- board/phytec/common/k3/k3_ddrss_patch.c | 135 +++++++++++++++------ board/phytec/common/k3/k3_ddrss_patch.h | 56 ++++++++- board/phytec/phycore_am62x/phycore-am62x.c | 8 +- 3 files changed, 157 insertions(+), 42 deletions(-) diff --git a/board/phytec/common/k3/k3_ddrss_patch.c b/board/phytec/common/k3/k3_ddrss_patch.c index 5afe5a20c7f3..8370a93c19c6 100644 --- a/board/phytec/common/k3/k3_ddrss_patch.c +++ b/board/phytec/common/k3/k3_ddrss_patch.c @@ -9,12 +9,6 @@ #include #include -#ifdef CONFIG_K3_AM64_DDRSS -#define LPDDR4_INTR_CTL_REG_COUNT (423U) -#define LPDDR4_INTR_PHY_INDEP_REG_COUNT (345U) -#define LPDDR4_INTR_PHY_REG_COUNT (1406U) -#endif - static int fdt_setprop_inplace_idx_u32(void *fdt, int nodeoffset, const char *name, uint32_t idx, u32 val) { @@ -25,45 +19,106 @@ static int fdt_setprop_inplace_idx_u32(void *fdt, int nodeoffset, sizeof(val)); } -int fdt_apply_ddrss_timings_patch(void *fdt, struct ddrss *ddrss) +/* + * Patch a ti,*-data register array property of one DDR controller node + * with the given delta. + * + * Return: 0 on success, -ENOENT if the property is missing, -EINVAL if a + * register offset is out of range or a libfdt error code otherwise. + */ +static int fdt_patch_reg_array(void *fdt, int nodeoffset, const char *name, + const struct ddr_reg *regs, u32 num) +{ + u32 count, i; + int len, ret; + + /* Nothing to patch */ + if (!regs || !num) + return 0; + + if (!fdt_getprop(fdt, nodeoffset, name, &len)) + return -ENOENT; + + count = len / sizeof(u32); + for (i = 0; i < num; i++) { + if (regs[i].off >= count) + return -EINVAL; + + ret = fdt_setprop_inplace_idx_u32(fdt, nodeoffset, name, + regs[i].off, regs[i].val); + if (ret) + return ret; + } + + return 0; +} + +static int fdt_apply_ddrss_controller_patch(void *fdt, int root_offset, + const struct k3_ddrss_ctrl_patch *ctrl) { - int i, j; + int ctrl_offset = root_offset; int ret; - int mem_offset; - mem_offset = fdt_path_offset(fdt, "/memorycontroller@f300000"); - if (mem_offset < 0) + if (ctrl->name && *ctrl->name) { + ctrl_offset = fdt_subnode_offset(fdt, root_offset, ctrl->name); + if (ctrl_offset < 0) + return -ENODEV; + } + + if (ctrl->ddrss) { + ret = fdt_patch_reg_array(fdt, ctrl_offset, "ti,ctl-data", + ctrl->ddrss->ctl_regs, + ctrl->ddrss->ctl_regs_num); + if (ret) + return ret; + + ret = fdt_patch_reg_array(fdt, ctrl_offset, "ti,pi-data", + ctrl->ddrss->pi_regs, + ctrl->ddrss->pi_regs_num); + if (ret) + return ret; + + ret = fdt_patch_reg_array(fdt, ctrl_offset, "ti,phy-data", + ctrl->ddrss->phy_regs, + ctrl->ddrss->phy_regs_num); + if (ret) + return ret; + } + + /* ti,ddr-fhs-cnt is a per-controller property */ + if (ctrl->fhs_cnt >= 0) + return fdt_setprop_inplace_u32(fdt, ctrl_offset, "ti,ddr-fhs-cnt", + ctrl->fhs_cnt); + + return 0; +} + +int fdt_apply_ddrss_timings_patch(void *fdt, const char *node_path, + const struct k3_ddrss_msmc_patch *msmc, + const struct k3_ddrss_ctrl_patch *ctrls, + int num_ctrls) +{ + int root_offset; + int ret; + int i; + + root_offset = fdt_path_offset(fdt, node_path); + if (root_offset < 0) return -ENODEV; - for (i = 0; i < LPDDR4_INTR_CTL_REG_COUNT; i++) - for (j = 0; j < ddrss->ctl_regs_num; j++) - if (i == ddrss->ctl_regs[j].off) { - ret = fdt_setprop_inplace_idx_u32(fdt, - mem_offset, "ti,ctl-data", i, - ddrss->ctl_regs[j].val); - if (ret) - return ret; - } - - for (i = 0; i < LPDDR4_INTR_PHY_INDEP_REG_COUNT; i++) - for (j = 0; j < ddrss->pi_regs_num; j++) - if (i == ddrss->pi_regs[j].off) { - ret = fdt_setprop_inplace_idx_u32(fdt, - mem_offset, "ti,pi-data", i, - ddrss->pi_regs[j].val); - if (ret) - return ret; - } - - for (i = 0; i < LPDDR4_INTR_PHY_REG_COUNT; i++) - for (j = 0; j < ddrss->phy_regs_num; j++) - if (i == ddrss->phy_regs[j].off) { - ret = fdt_setprop_inplace_idx_u32(fdt, - mem_offset, "ti,phy-data", i, - ddrss->phy_regs[j].val); - if (ret) - return ret; - } + if (msmc && msmc->intrlv_size >= 0) { + ret = fdt_setprop_inplace_u32(fdt, root_offset, "intrlv-size", + msmc->intrlv_size); + if (ret) + return ret; + } + + for (i = 0; i < num_ctrls; i++) { + ret = fdt_apply_ddrss_controller_patch(fdt, root_offset, + &ctrls[i]); + if (ret) + return ret; + } return 0; } diff --git a/board/phytec/common/k3/k3_ddrss_patch.h b/board/phytec/common/k3/k3_ddrss_patch.h index 0a47c85116af..c90425bf1037 100644 --- a/board/phytec/common/k3/k3_ddrss_patch.h +++ b/board/phytec/common/k3/k3_ddrss_patch.h @@ -23,6 +23,60 @@ struct ddrss { u32 phy_regs_num; }; -int fdt_apply_ddrss_timings_patch(void *fdt, struct ddrss *ddrss); +/** + * struct k3_ddrss_ctrl_patch - Timing delta for one DDR memory controller + * + * @name: Name of the controller subnode below the node passed to + * fdt_apply_ddrss_timings_patch(). NULL or an empty string + * patches that node itself, covering SoCs with a single flat + * DDR controller node (e.g. AM62x, memorycontroller@f300000). + * @ddrss: Register deltas for ti,ctl-data, ti,pi-data and ti,phy-data. + * NULL leaves the register arrays untouched. + * @fhs_cnt: New value for ti,ddr-fhs-cnt. A negative value leaves the + * property untouched. + */ +struct k3_ddrss_ctrl_patch { + const char *name; + struct ddrss *ddrss; + s32 fhs_cnt; +}; + +/** + * struct k3_ddrss_msmc_patch - Timing delta for the MSMC node + * + * Only used on SoCs with multiple DDR controllers below an MSMC node + * (e.g. J721S2). + * + * @intrlv_size: New value for intrlv-size. A negative value leaves the + * property untouched. + */ +struct k3_ddrss_msmc_patch { + s32 intrlv_size; +}; + +/** + * fdt_apply_ddrss_timings_patch() - Patch DDR timings in the devicetree + * + * Apply register and property deltas to the DDR controller node(s) prior to + * probing the DDRSS driver. The properties are patched in place, so their + * sizes must not change. + * + * @fdt: Pointer to the devicetree blob + * @node_path: Path of the DDR controller node (single controller SoCs) or + * of the parent node holding the controller subnodes (e.g. the + * MSMC node on J721S2) + * @msmc: Delta for the parent node, may be NULL + * @ctrls: Array of per-controller deltas + * @num_ctrls: Number of entries in @ctrls + * + * Return: 0 on success, -ENODEV if @node_path or a controller subnode is + * not found, -ENOENT if a ti,*-data property is missing, -EINVAL if a + * register offset exceeds the size of its property or a libfdt error code + * otherwise. + */ +int fdt_apply_ddrss_timings_patch(void *fdt, const char *node_path, + const struct k3_ddrss_msmc_patch *msmc, + const struct k3_ddrss_ctrl_patch *ctrls, + int num_ctrls); #endif /* K3_DDRSS_PATCH */ diff --git a/board/phytec/phycore_am62x/phycore-am62x.c b/board/phytec/phycore_am62x/phycore-am62x.c index 376379767cfc..5c556b33bf44 100644 --- a/board/phytec/phycore_am62x/phycore-am62x.c +++ b/board/phytec/phycore_am62x/phycore-am62x.c @@ -143,6 +143,10 @@ int update_ddrss_timings(void) int ret; u8 ram_size; struct ddrss *ddr_patch = NULL; + struct k3_ddrss_ctrl_patch ctrl = { + .name = NULL, + .fhs_cnt = -1, + }; void *fdt = (void *)gd->fdt_blob; ram_size = phytec_get_am62_ddr_size_default(); @@ -166,7 +170,9 @@ int update_ddrss_timings(void) debug("Applying DDRSS timings patch for ram_size %d\n", ram_size); - ret = fdt_apply_ddrss_timings_patch(fdt, ddr_patch); + ctrl.ddrss = ddr_patch; + ret = fdt_apply_ddrss_timings_patch(fdt, "/memorycontroller@f300000", + NULL, &ctrl, 1); if (ret < 0) { printf("Failed to apply ddrs timings patch %d\n", ret); return ret; -- 2.43.0