Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (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 5F1F1606A31A for ; Tue, 1 Dec 2026 00:47:28 +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=FqvdEfvo; dkim=pass (2048-bit key, unprotected) header.d=phytec.de header.i=@phytec.de header.a=rsa-sha256 header.s=selector2 header.b=lBt7i5I1 Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 330B180F87; Tue, 1 Dec 2026 00:47:28 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id DhG---016aZk; Tue, 1 Dec 2026 00:47:27 +0000 (UTC) ARC-Filter: OpenARC Filter v1.3.2 smtp1.osuosl.org 0F2E380F6F Authentication-Results: smtp1.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=1796086047; b=GKxsc5MbHzywCBzrRld3KLQk6Y2JKAqAlUvVpxinmOrhJrE+gs/latHc/P9R/htBSu5R pDlXe4moNxCfczJ9yVlOtkPzQTCKqa9f38szmkygi5niY9gW9n6PH3ly3faprDHOO5lF2 2XdwiH5ScTd8yu9OE5p8mF79kap/hoct7iquPBP5qzStaFhOG+CD9f90lA/yJyoLz94gc 79bAKyTq/AwiFs7UeYpS+d4NlmDqOpS5oltF+/GadI6MF7yur71nTWFaw+myUG34albGh eoA3EB5ve7zR5ZQWIhvUoLH0GA/hJ6KUz/EWUw8jLJIV0PiNcbQZ1WiTWix5EZhns/w== ARC-Message-Signature: i=1; d=osuosl.org; s=arc; a=rsa-sha256; c=relaxed/relaxed; t=1796086047; 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=qc2AVkzBaOmQ+mhylY75ZhWJAkNl3P4wu8TAkNbhlf4=; b=MjjI5pO9uzqslULD1RJH2XZRKWuylhXrdXef8qMt4lJIf823NGBAqQlkdcfLPx6k9Cjb V8vbv4jdGh6f5EeJLV7uTA/qgAZpHS2xq+JmpxsxON57y65eCq3C2FGTp4OmgIH5clLl3 CoUZgRBgO8dlVlhxXQcg+PrbniX0ow7kEqujOloH4y28Zq9f7DPfTB9KvQOAhR/Hx5iW4 Lc8ZUmeRnjNWHo6Uog5yuC1wDsKOYndsoYxp4FCXB7LpxcH8UMZtXNuEEnFkHXyOaXZnJ RYSCeWoNSRHiP6dfHvpXhifEaVqHypfv4WUMvOB7xQQDx6NTb+ASlShMWmzb6UnCXqA== ARC-Authentication-Results: i=1; smtp1.osuosl.org; dmarc=pass header.from=phytec.de; dkim=pass header.d=phytec.de header.i=@phytec.de header.a=rsa-sha256 header.s=selector2 header.b=lBt7i5I1; 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=1796086047; bh=qc2AVkzBaOmQ+mhylY75ZhWJAkNl3P4wu8TAkNbhlf4=; h=From:To:CC:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=FqvdEfvowmOY6asZA5Ni/J06h/GPN4pbMzXj5oMrtNc99wFCXOX7XO/90PHsNYQZq t1BC1PyG5snDdA+SGZWfcnmmR0I6litt6GlGNMXbGIlUtk06YHW1S+KCbo3uQ389w2 M1FwRejZTtNNhr1TahOQ4X11laQbMJvHtso7JAg3VwMr9iIUIrMpdipOcqzsvqoJ3m /owBiU/iuesHr4Z4l469CrbxrC35SeDAio77YgbhBuqFqDw/ZnONMGbKY3OZvTT/44 djE3Og7zlGgm0t2C1v76vxP4gQRMr+ZRZfpqv386HzPuoJp8pb4oy+C2TMlnXTMd2R ptaDZm9vR6Luw== Received: from lists1.osuosl.org (lists1.osuosl.org [140.211.166.142]) by smtp1.osuosl.org (Postfix) with ESMTP id 0F2E380F6F; Tue, 1 Dec 2026 00:47:27 +0000 (UTC) Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) by lists1.osuosl.org (Postfix) with ESMTP id 29FF71184 for ; Tue, 1 Dec 2026 00:47:24 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 199A980F67 for ; Tue, 1 Dec 2026 00:47:24 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id sux4taW1Do0H for ; Tue, 1 Dec 2026 00:47:23 +0000 (UTC) ARC-Filter: OpenARC Filter v1.3.2 smtp1.osuosl.org C82B080870 Authentication-Results: smtp1.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: smtp1.osuosl.org; dmarc=pass (p=quarantine dis=none) header.from=phytec.de Authentication-Results: smtp1.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=lBt7i5I1 Received: from DU2PR03CU002.outbound.protection.outlook.com (mail-northeuropeazlp170110003.outbound.protection.outlook.com [IPv6:2a01:111:f403:c200::3]) by smtp1.osuosl.org (Postfix) with ESMTPS id C82B080870 for ; Tue, 1 Dec 2026 00:47:22 +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=qc2AVkzBaOmQ+mhylY75ZhWJAkNl3P4wu8TAkNbhlf4=; b=lBt7i5I1x8P1qoXFMvXYbn/3cKg48Gul1EwAYvmWKAERfbWTT2oND4/GfOMZnoyWMZoJ9DNBLVIiCzJXBxq/DM4XQubeFM+macUwdy4jGxaNlPLnCkLrmef1uFCa73DALXmdFvO6uJ08oimVSVRG/lZetQT9q1aRQwtwBCD9H4y642lBFgJyar0Hf90qBa8ENpAM37LAdwAJyMk1I+VyraPysRqo1X9SgdyBEuSgFPMn+fBHcXQQI6m8s6BWz8iwFtR/PZ6KNoINvMIH0UCR9ApL6QbwTldHVDAQ08+kngGAhozIW3r4JcbHO5ZRA89OGTYPbYhlLIf5+JvQ0qs+pA== Received: from AM8P191CA0029.EURP191.PROD.OUTLOOK.COM (2603:10a6:20b:21a::34) by FR8P195MB3379.EURP195.PROD.OUTLOOK.COM (2603:10a6:d10:1b6::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.662.13; Tue, 1 Dec 2026 00:47:16 +0000 Received: from AM1PEPF000C1AD7.eurprd02.prod.outlook.com (2603:10a6:20b:21a:cafe::81) by AM8P191CA0029.outlook.office365.com (2603:10a6:20b:21a::34) 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:16 +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:16 +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:13 +0100 From: Dominik Haller To: Manorit Chawdhry , Tom Rini , "Ilias Apalodimas" , Dominik Haller CC: , Subject: [PATCH 5/6] board: phytec: phycore_am68x: Support 8GB LPDDR4 Date: Mon, 30 Nov 2026 16:46:38 -0800 Message-ID: <20261201004644.381033-6-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_|FR8P195MB3379:EE_ X-MS-Office365-Filtering-Correlation-Id: ac4b4187-785e-4a31-1027-08df4f44a57a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700016|23010399003|1800799024|82310400026|376014|10067099003|56012099006|261026121527099003|261026140227099003|261021121427099003|261028144727099003|261022105027099003|261021123027099003|261022115727099003|261022075727099003|261102123227099003|261009223027099003|22082099003|18002099003|11063799006|5023799004|6133799003; X-Microsoft-Antispam-Message-Info: GJYKu6ntznuEL1/2z//8T/I+KsU//lXu3nbCPY405XzacCX93k6Jn2c2xzwdZGSGY9YlGQgkW4DZZUaFDFf+9GEXnGt7IWx1SolCUKdeyO8fr6BqZulXjAMN5N5wta2r72tYq1ymUnD18fQmc+pXoUr+y/imchpKA+N3Trgdn8QT2T1MzQiozpGKAxzgATSGbWcuVJQSZG3SQLbJTMrY4lGDHd9px2j+SCc4znwK4xnqmaojMbxym0IHrv9r6Pvzdg5+/mgDYYOpg8YuIix01und8No7YGdjd1g7CyujIMcEEuKXXN+DU8L6qO3TSJQ43Tlb0zmY3bCICNIPAoXSo1tS80eVtlbaxQ4wMG/Duuv5OYduB5v8T29UoHhRnwBje1yvmqIj8s2Z219sPB084AcTN61xuxbeTbY09+Zz1SaRe2uXBoKcqlL4pp0UHJHQrwstx1kANZ3wzfNxeHDdVTIoLOKGDyuQ3kqwfqdkx4S5wGzcI1QL/Dt+C4F9DyUqh9JdfUC7dnPW4fNXygzWLz0UHUWi3dqm2+NYJCKeI4XmNJ5+Y+TgUluB3eI0Zul9W5gx35RVULLd6nMI0smRRxUTSitTfQpXXrouOpsJX1lwxGu2S+zUCf4tzDxxcpvCd6iTfHUrKMCNe3Q4GrsVCx92UPGuL2MQ97nupEXwTBeoawwq2JcjIczEot7OOqLe0YAyJkV/sUrHYhhFd3HW3w== 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)(10067099003)(56012099006)(261026121527099003)(261026140227099003)(261021121427099003)(261028144727099003)(261022105027099003)(261021123027099003)(261022115727099003)(261022075727099003)(261102123227099003)(261009223027099003)(22082099003)(18002099003)(11063799006)(5023799004)(6133799003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: W23Bv+OCBFbP4A+7u+xWGKzJyf8E0paU7oWjp7gnWIal/LLZpidfh+8t7eoQTqpQ6HNurI/w1u/6mLx7JrjgRJvtbxkWMpZzLHN2yd/xoiJprKs55W+j4hmOOAN5r2E49+U8BbJ5kpumBTzWZfnj0GvuHuqUQOvcuxs9ogIgPDFyMmJVWGsFXRkQ2YyB0wdQYlGAlvK62N/+GGzcq6nT2HHXP9SjdqDy/jCkN/AZ3Ayp+C2fJ0bUy2uw5lowW1aImMJ4DhY98GSlJkqNmwYIJ/BAEk/0KiIuIaKSyBgumJLKTx7qKOsyMFZSV9int4jAfk90n/wzCLnAGtHVdWMoZtLV/sUYMu6lmFiXx2hd302VpyllGoP3GxHt78jjeOzp4mVrf6bFJ8lYq7tHfUeFHc/LuOmBynSUEZ6XstZtFN45zKfA62R79Y1krRZl+VqJ X-OriginatorOrg: phytec.de X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Dec 2026 00:47:16.2074 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ac4b4187-785e-4a31-1027-08df4f44a57a 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: FR8P195MB3379 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 Apply the DDR config delta for the 8GB in 2x4GB configuration option based on the introspection data in the eeprom. While the byte is at the same position the mapping is different from the other Phytec K3 SoMs. Use k3_ddrss_patch to update the DDR config registers and the devicetree nodes. Add Kconfig options to set the RAM size statically. Signed-off-by: Dominik Haller --- arch/arm/mach-k3/j721s2/Kconfig | 1 + board/phytec/phycore_am68x/Kconfig | 28 +++ .../phycore_am68x/phycore-am68x-ddr-data.h | 78 +++++++++ board/phytec/phycore_am68x/phycore-am68x.c | 161 +++++++++++++++++- 4 files changed, 263 insertions(+), 5 deletions(-) create mode 100644 board/phytec/phycore_am68x/phycore-am68x-ddr-data.h diff --git a/arch/arm/mach-k3/j721s2/Kconfig b/arch/arm/mach-k3/j721s2/Kconfig index feb76ab19da8..27225bc29154 100644 --- a/arch/arm/mach-k3/j721s2/Kconfig +++ b/arch/arm/mach-k3/j721s2/Kconfig @@ -46,6 +46,7 @@ config TARGET_PHYCORE_AM68X_R5 select SPL_RAM select K3_DDRSS select BINMAN + select PHYTEC_K3_DDR_PATCH imply SYS_K3_SPL_ATF endchoice diff --git a/board/phytec/phycore_am68x/Kconfig b/board/phytec/phycore_am68x/Kconfig index d82cdaf819b9..df800ed7455b 100644 --- a/board/phytec/phycore_am68x/Kconfig +++ b/board/phytec/phycore_am68x/Kconfig @@ -39,3 +39,31 @@ source "board/phytec/common/Kconfig" source "board/phytec/common/k3/Kconfig" endif + +config PHYCORE_AM68X_RAM_SIZE_FIX + bool "Set phyCORE-AM68x RAM size fix instead of detecting" + depends on TARGET_PHYCORE_AM68X_R5 + default n + help + The RAM size is automatically detected with the help of + the EEPROM introspection data. Set the RAM size to a fixed value + instead. + +choice + prompt "phyCORE-AM68x RAM size" + depends on PHYCORE_AM68X_RAM_SIZE_FIX + default PHYCORE_AM68X_RAM_SIZE_2X2GB + +config PHYCORE_AM68X_RAM_SIZE_2X2GB + bool "2x2GB RAM" + help + Set the RAM size to a fixed 4GB in 2x2GB configuration for + phyCORE-AM68x. + +config PHYCORE_AM68X_RAM_SIZE_2X4GB + bool "2x4GB RAM" + help + Set the RAM size to a fixed 8GB in 2x4GB configuration for + phyCORE-AM68x. + +endchoice diff --git a/board/phytec/phycore_am68x/phycore-am68x-ddr-data.h b/board/phytec/phycore_am68x/phycore-am68x-ddr-data.h new file mode 100644 index 000000000000..f6be2e1d90d5 --- /dev/null +++ b/board/phytec/phycore_am68x/phycore-am68x-ddr-data.h @@ -0,0 +1,78 @@ +/* SPDX-License-Identifier: GPL-2.0-only OR MIT */ +/* + * Copyright (C) 2026 PHYTEC Messtechnik GmbH + * Author: Dominik Haller + * + * LPDDR4 deltas for phyCORE-AM68x/TDA4x + */ + +#ifndef PHYCORE_AM68X_DDR_DATA +#define PHYCORE_AM68X_DDR_DATA + +#include "../common/k3/k3_ddrss_patch.h" + +#define PHYCORE_AM68X_DDR_FHS_CNT_8GB 5 +#define PHYCORE_AM68X_DDR_INTRLV_SIZE_8GB 9 + +/* RAM size encoding of the EEPROM introspection data */ +enum { + PHYCORE_AM68X_RAM_SIZE_1X512MB = 0, + PHYCORE_AM68X_RAM_SIZE_1X1GB = 1, + PHYCORE_AM68X_RAM_SIZE_2X512MB = 2, + PHYCORE_AM68X_RAM_SIZE_1X2GB = 3, + PHYCORE_AM68X_RAM_SIZE_2X1GB = 4, + PHYCORE_AM68X_RAM_SIZE_1X4GB = 5, + PHYCORE_AM68X_RAM_SIZE_2X2GB = 6, + PHYCORE_AM68X_RAM_SIZE_1X8GB = 7, + PHYCORE_AM68X_RAM_SIZE_2X4GB = 8, + PHYCORE_AM68X_RAM_SIZE_2X8GB = 9, +}; + +/* + * The J721S2 has up to two LPDDR4 memory controllers holding the same DDR + * configuration. The controller registers are identical for both + * controllers; only the PI configuration differs (offset 67). + */ +static struct ddr_reg phycore_am68x_ddrss_8gb_ctl_regs[] = { + { 267, 0x03030303 }, + { 271, 0x1FFF1000 }, + { 273, 0x000101FF }, + { 278, 0x00030000 }, + { 287, 0x04010100 }, +}; + +static struct ddr_reg phycore_am68x_ddrss0_8gb_pi_regs[] = { + { 14, 0x0800000F }, + { 29, 0x0F000000 }, + { 45, 0x000F0F00 }, + { 55, 0x0F000000 }, + { 67, 0x0102020F }, +}; + +static struct ddr_reg phycore_am68x_ddrss1_8gb_pi_regs[] = { + { 14, 0x0800000F }, + { 29, 0x0F000000 }, + { 45, 0x000F0F00 }, + { 55, 0x0F000000 }, + { 67, 0x0002020F }, +}; + +static struct ddrss __maybe_unused phycore_am68x_ddrss0_8gb = { + .ctl_regs = phycore_am68x_ddrss_8gb_ctl_regs, + .ctl_regs_num = ARRAY_SIZE(phycore_am68x_ddrss_8gb_ctl_regs), + .pi_regs = phycore_am68x_ddrss0_8gb_pi_regs, + .pi_regs_num = ARRAY_SIZE(phycore_am68x_ddrss0_8gb_pi_regs), + .phy_regs = NULL, + .phy_regs_num = 0, +}; + +static struct ddrss __maybe_unused phycore_am68x_ddrss1_8gb = { + .ctl_regs = phycore_am68x_ddrss_8gb_ctl_regs, + .ctl_regs_num = ARRAY_SIZE(phycore_am68x_ddrss_8gb_ctl_regs), + .pi_regs = phycore_am68x_ddrss1_8gb_pi_regs, + .pi_regs_num = ARRAY_SIZE(phycore_am68x_ddrss1_8gb_pi_regs), + .phy_regs = NULL, + .phy_regs_num = 0, +}; + +#endif /* PHYCORE_AM68X_DDR_DATA */ diff --git a/board/phytec/phycore_am68x/phycore-am68x.c b/board/phytec/phycore_am68x/phycore-am68x.c index 9b71a4bdc680..c1d7c253a219 100644 --- a/board/phytec/phycore_am68x/phycore-am68x.c +++ b/board/phytec/phycore_am68x/phycore-am68x.c @@ -22,9 +22,110 @@ #include #include #include +#include +#include "../common/am6_som_detection.h" +#include "phycore-am68x-ddr-data.h" DECLARE_GLOBAL_DATA_PTR; +#define PHYCORE_AM68X_DDR_LOW_SIZE SZ_2G +#define PHYCORE_AM68X_DDR_HIGH_BASE 0x880000000ULL +#define PHYCORE_AM68X_DDR_HIGH_SIZE_4GB SZ_2G +#define PHYCORE_AM68X_DDR_HIGH_SIZE_8GB (SZ_4G + SZ_2G) + +#if defined(CONFIG_K3_DDRSS) + +static u8 phycore_am68x_ddr_size = PHYCORE_AM68X_RAM_SIZE_2X2GB; + +static u8 phycore_am68x_detect_ddr_size(void) +{ + struct phytec_eeprom_data data; + u8 ddr_size; + int ret; + + if (IS_ENABLED(CONFIG_PHYCORE_AM68X_RAM_SIZE_FIX)) { + if (IS_ENABLED(CONFIG_PHYCORE_AM68X_RAM_SIZE_2X4GB)) + return PHYCORE_AM68X_RAM_SIZE_2X4GB; + return PHYCORE_AM68X_RAM_SIZE_2X2GB; + } + + ret = phytec_eeprom_data_setup(&data, CONFIG_PHYTEC_EEPROM_BUS, + EEPROM_ADDR); + if (ret || !data.valid) { + printf("WARNING: Could not read DDR size from EEPROM, falling back to 4GB\n"); + return PHYCORE_AM68X_RAM_SIZE_2X2GB; + } + + ddr_size = phytec_get_am6_ddr_size(&data); + switch (ddr_size) { + case PHYCORE_AM68X_RAM_SIZE_2X2GB: + case PHYCORE_AM68X_RAM_SIZE_2X4GB: + return ddr_size; + default: + printf("WARNING: DDR size %u is not supported, falling back to 4GB\n", + ddr_size); + return PHYCORE_AM68X_RAM_SIZE_2X2GB; + } +} + +static bool phycore_am68x_is_8gb(void) +{ + return phycore_am68x_ddr_size == PHYCORE_AM68X_RAM_SIZE_2X4GB; +} + +static void phycore_am68x_init_memory_banks(u64 *start, u64 *size) +{ + start[0] = CFG_SYS_SDRAM_BASE; + size[0] = PHYCORE_AM68X_DDR_LOW_SIZE; + start[1] = PHYCORE_AM68X_DDR_HIGH_BASE; + size[1] = phycore_am68x_is_8gb() ? PHYCORE_AM68X_DDR_HIGH_SIZE_8GB + : PHYCORE_AM68X_DDR_HIGH_SIZE_4GB; +} + +static int phycore_am68x_update_ddrss_timings(void *fdt) +{ + struct k3_ddrss_msmc_patch msmc = { + .intrlv_size = PHYCORE_AM68X_DDR_INTRLV_SIZE_8GB, + }; + struct k3_ddrss_ctrl_patch ctrls[] = { + { "memorycontroller@2990000", &phycore_am68x_ddrss0_8gb, + PHYCORE_AM68X_DDR_FHS_CNT_8GB }, + { "memorycontroller@29b0000", &phycore_am68x_ddrss1_8gb, + PHYCORE_AM68X_DDR_FHS_CNT_8GB }, + }; + + /* The 4GB timings are the DTS defaults, nothing to patch */ + if (!phycore_am68x_is_8gb()) + return 0; + + return fdt_apply_ddrss_timings_patch(fdt, "/bus@100000/bus@30000000/msmc", + &msmc, ctrls, ARRAY_SIZE(ctrls)); +} + +void do_board_detect(void) +{ + void *fdt = (void *)gd->fdt_blob; + u64 start[CONFIG_NR_DRAM_BANKS]; + u64 size[CONFIG_NR_DRAM_BANKS]; + int ret; + + phycore_am68x_ddr_size = phycore_am68x_detect_ddr_size(); + + ret = phycore_am68x_update_ddrss_timings(fdt); + if (ret) { + printf("Failed to apply AM68 DDRSS timings patch %d, falling back to 4GB\n", + ret); + phycore_am68x_ddr_size = PHYCORE_AM68X_RAM_SIZE_2X2GB; + } + + phycore_am68x_init_memory_banks(start, size); + + ret = fdt_fixup_memory_banks(fdt, start, size, CONFIG_NR_DRAM_BANKS); + if (ret) + printf("Error fixing up memory node! %d\n", ret); +} +#endif /* CONFIG_K3_DDRSS */ + phys_addr_t board_get_usable_ram_top(phys_size_t total_size) { #ifdef CONFIG_PHYS_64BIT @@ -38,6 +139,16 @@ phys_addr_t board_get_usable_ram_top(phys_size_t total_size) int dram_init(void) { +#if defined(CONFIG_K3_DDRSS) + u64 start[CONFIG_NR_DRAM_BANKS]; + u64 size[CONFIG_NR_DRAM_BANKS]; + + phycore_am68x_init_memory_banks(start, size); + + gd->ram_size = size[0]; + + return 0; +#else s32 ret; ret = fdtdec_setup_mem_size_base_lowest(); @@ -45,10 +156,25 @@ int dram_init(void) printf("Error setting up mem size and base. %d\n", ret); return ret; +#endif } int dram_init_banksize(void) { +#if defined(CONFIG_K3_DDRSS) + u64 start[CONFIG_NR_DRAM_BANKS]; + u64 size[CONFIG_NR_DRAM_BANKS]; + + memset(gd->dram, 0, sizeof(gd->dram[0]) * CONFIG_NR_DRAM_BANKS); + + phycore_am68x_init_memory_banks(start, size); + + gd->dram[0].start = start[0]; + gd->dram[0].size = size[0]; + gd->ram_size = size[0]; + + return 0; +#else s32 ret; ret = fdtdec_setup_memory_banksize(); @@ -56,17 +182,42 @@ int dram_init_banksize(void) printf("Error setting up memory banksize. %d\n", ret); return ret; +#endif } #if defined(CONFIG_XPL_BUILD) void spl_perform_board_fixups(struct spl_image_info *spl_image) { - if (IS_ENABLED(CONFIG_K3_DDRSS)) { - if (IS_ENABLED(CONFIG_K3_INLINE_ECC)) - fixup_ddr_driver_for_ecc(spl_image); - } else { - fixup_memory_node(spl_image); + /* + * With inline ECC, fixup_ddr_driver_for_ecc() also fixes up the + * memory node with the ECC reserved region subtracted, based on + * the memory banks of the already patched SPL devicetree. + */ + if (IS_ENABLED(CONFIG_K3_DDRSS) && IS_ENABLED(CONFIG_K3_INLINE_ECC)) { + fixup_ddr_driver_for_ecc(spl_image); + return; } + +#if defined(CONFIG_K3_DDRSS) + { + u64 start[CONFIG_NR_DRAM_BANKS]; + u64 size[CONFIG_NR_DRAM_BANKS]; + int ret; + + /* + * The R5 SPL runs 32 bit, so gd->dram[] can not hold the + * second DDR bank above 4GB. Compute the banks directly. + */ + phycore_am68x_init_memory_banks(start, size); + + ret = fdt_fixup_memory_banks(spl_image->fdt_addr, start, size, + CONFIG_NR_DRAM_BANKS); + if (ret) + printf("Error fixing up memory node! %d\n", ret); + return; + } +#endif + fixup_memory_node(spl_image); } #endif -- 2.43.0