From patchwork Wed Mar 20 12:16:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joao Paulo Goncalves X-Patchwork-Id: 1914092 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=go8xCgRo; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4V06z76FG6z23r9 for ; Wed, 20 Mar 2024 23:17:07 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 80BEE87F8C; Wed, 20 Mar 2024 13:16:57 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="go8xCgRo"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DC24C87F8C; Wed, 20 Mar 2024 13:16:56 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id B7EF686FCE for ; Wed, 20 Mar 2024 13:16:52 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=jpaulo.silvagoncalves@gmail.com Received: by mail-pj1-x1033.google.com with SMTP id 98e67ed59e1d1-29bfc3ca816so5831430a91.0 for ; Wed, 20 Mar 2024 05:16:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710937011; x=1711541811; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=HGqlhAwXlNAbyn9wEG7QpeBZH4E/n9ApsSiGwFf52dI=; b=go8xCgRoVpF5c5vfjEryKXTYuk0GZMzuhL4Kv12Qt/Hwo3AJ7sr6Un7dwXhYsEdYl7 JszictDrjgLnvoMYIFObFllrH+9ewwTC2pP3NJBIOygE+VPufNG5dXR4ByXNgknds/ps j6ZZ05rxZYgM5IlPME9yZGK8IoU8jXkkRCZum6LSPMVGiFyayafe11CJnSWqKRF3qXyK 7ubwundzDJRRDlGCS5keafV/IDrAJlcn0APHfeNtb1iauhzrM/x8gSwXGEt1kCgUgucm 2Mnwj0HbcCEDOw1CwG+Fs67J/dgNjZTEZNIQBpJ2aui+GcRmpnFvA9aryHNh3+kN9aDK 6asA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710937011; x=1711541811; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HGqlhAwXlNAbyn9wEG7QpeBZH4E/n9ApsSiGwFf52dI=; b=Z4Ag0sg24OTa22TYZN7U+g1AmK3mBoK3sOVqwA/Lu0pfHrnLoBQkzi2iAyK2KxxYkj iqZmr4yIsxGKazDH8CCbDloUwzKXAzLGiwnKjdjJmG4QWh8wIioIqbr6xRxpNah7tnSQ NNMTx3i1LVx6Mwicw+1NDjHar18QbRDkw3mf4iuP853sG+IAmjdP55+6+Cmc5tyi5wom Aul0+6lWiCd1t1rqLmAGM0k4ZTk5X3MmwHkQ1u7gKl8+9WQ8XDlb2WvU1ndlW52vASGA aqb1LEUfBwxuoKj703I8P5XthMf7Suz2EpEtgvPnxZKeGm41doYaIOWHwuWXkwxOxO1f u6Kw== X-Forwarded-Encrypted: i=1; AJvYcCXNjmizty4V1fdXl8Z5QiNcraviLyUmGLMgKMZT1fe4Hd+uV8YM+PhrKgm3PtVq8ao4d3lwYfyLkirFLkOvKB3tldmTJw== X-Gm-Message-State: AOJu0YzPkUaQdHm4m78Hg14pj8exY03+58FoxYHtbfwdOjcPRK7C6xIy wS1VniknEFPs5nLseb84qDFElmJGrNaEthmwJAObO7PrRljTslP6 X-Google-Smtp-Source: AGHT+IE1jn5s0lzHOrdSszKwwavcpMAWfLK0lsMlooY12OvWNaxEeqZhC4BSBg7ly0IYwpIABjObZg== X-Received: by 2002:a17:90a:5283:b0:29b:68c:1779 with SMTP id w3-20020a17090a528300b0029b068c1779mr1692455pjh.40.1710937010956; Wed, 20 Mar 2024 05:16:50 -0700 (PDT) Received: from joaog-nb.corp.toradex.com ([201.82.41.210]) by smtp.gmail.com with ESMTPSA id sj10-20020a17090b2d8a00b0029af5587889sm1447870pjb.12.2024.03.20.05.16.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Mar 2024 05:16:50 -0700 (PDT) From: Joao Paulo Goncalves To: Tom Rini Cc: Joao Paulo Goncalves , u-boot@lists.denx.de, Vignesh Raghavendra Subject: [PATCH 1/2] arm: mach-k3: am62: Get a53 max cpu frequency by speed grade Date: Wed, 20 Mar 2024 09:16:31 -0300 Message-Id: <20240320121632.105730-2-jpaulo.silvagoncalves@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240320121632.105730-1-jpaulo.silvagoncalves@gmail.com> References: <20240320121632.105730-1-jpaulo.silvagoncalves@gmail.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean From: Joao Paulo Goncalves AM62 SoC has multiple speed grades. Add function to return max A53 CPU frequency based on grade. Fastest grade's max frequency also depends on PMIC voltage, to simplify implementation use the smaller value. Suggested-by: Vignesh Raghavendra Signed-off-by: Joao Paulo Goncalves --- arch/arm/mach-k3/include/mach/am62_hardware.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/arch/arm/mach-k3/include/mach/am62_hardware.h b/arch/arm/mach-k3/include/mach/am62_hardware.h index 264f8a488b4..90682d8ee31 100644 --- a/arch/arm/mach-k3/include/mach/am62_hardware.h +++ b/arch/arm/mach-k3/include/mach/am62_hardware.h @@ -122,6 +122,21 @@ static inline int k3_get_max_temp(void) } } +static inline int k3_get_a53_max_frequency(void) +{ + switch (k3_get_speed_grade()) { + case 'K': + return 800000000; + case 'S': + return 1000000000; + case 'T': + return 1250000000; + case 'G': + default: + return 300000000; + } +} + static inline int k3_has_pru(void) { u32 full_devid = readl(CTRLMMR_WKUP_JTAG_DEVICE_ID); From patchwork Wed Mar 20 12:16:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joao Paulo Goncalves X-Patchwork-Id: 1914093 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=Cz/ZR/8O; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4V06zN233hz23r9 for ; Wed, 20 Mar 2024 23:17:20 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id EA1EF87F6E; Wed, 20 Mar 2024 13:16:59 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Cz/ZR/8O"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 385DC87F6E; Wed, 20 Mar 2024 13:16:58 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id EADED87F6E for ; Wed, 20 Mar 2024 13:16:55 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=jpaulo.silvagoncalves@gmail.com Received: by mail-pj1-x102d.google.com with SMTP id 98e67ed59e1d1-29fa98705b1so2437977a91.3 for ; Wed, 20 Mar 2024 05:16:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710937014; x=1711541814; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YItxV2xnFEjqxWmK5FQWjrVm47bMelG+ZtuZfhx9PpI=; b=Cz/ZR/8OOp4mm7QOFLTodaU67LzzRXQqvyD8Sn82S5v1FE7JuNu6rGOkI+bEqEGOOD meFVEOaaLwItVvweKHWnYJHU9kvqs84NDKUz3SET51lylfa98GxlGxZOAIoL688vLy+a 9jYXJEE8ax5/3eMCV86FUCOV74c06Sc3E+9c2QtzHuPxM/zocMoKQR91IsJzbOWzPiks mOxnOsAmui0uRA++ulBd265nof36r8gZcpJsg+qAKJU2h1OlhBkkBMvRtxVRbyhqV+PY DM8497awN9qZIa2TbQ8Wxp+HhCbXQ0FOaKgaLk8yHy0sgApkLJSU1aq2AcuDRDlFFvAF tmvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710937014; x=1711541814; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YItxV2xnFEjqxWmK5FQWjrVm47bMelG+ZtuZfhx9PpI=; b=iY+8KR3umq5kFoNuAz7p2EKHzvBhgpxtvZ9l80TODN4lYdsAh6wj4zKUhyYUeTLLUS JV1ZQWqBiQtOLaKeWOqZK4bsBJ/WDd/pFmZvISPtl8I65QAi2hmA+1jDwv0Gu9sXl3+X acXKZXgj5QNpQNO8HIVH5eIhrQFOqCBSkUiKln/Da6mYoOZqqZ8LBcSR2OjT7yl30VvT wsa7axwtvsacaGYQoGIhttmoQ2qMx54+ZykjDL1jqlMVzZEISci+qye/teb4Wmy8lR2i k91w/yU6MBKrSFiSo1lr8sDn1PQDWl7LFjRXSAV7U2ZH8I3aWSuNIgvtQruQPqEUEWyq 13iQ== X-Forwarded-Encrypted: i=1; AJvYcCW+1GM5U0vo18+xac1ZEJwZe6Kt3R5C/qq6XljEsGX5BbyZDZoAc+PhF403bVHqN0YjOhsoE9d/UpMzlWil4ypfI68Z/A== X-Gm-Message-State: AOJu0Yyem9IR04N3hozMfkCCkKOYLSR8tV68giqHkxVNqoVjmghlSkT6 UXL9Sa+gvqWcNMTILyDDk2D3HXM+9BvoJ0AgyqCGuwlQXDVehcQc+oYc2HX5oIs= X-Google-Smtp-Source: AGHT+IHYgcqOEyfrKEEYMrvvO7nVL1WxThsc4pkijq/e8uune0jPlKYDUDGRWdF/dIsbxAB0VuIMXQ== X-Received: by 2002:a17:90b:1056:b0:29b:acc6:c54f with SMTP id gq22-20020a17090b105600b0029bacc6c54fmr5243984pjb.35.1710937014305; Wed, 20 Mar 2024 05:16:54 -0700 (PDT) Received: from joaog-nb.corp.toradex.com ([201.82.41.210]) by smtp.gmail.com with ESMTPSA id sj10-20020a17090b2d8a00b0029af5587889sm1447870pjb.12.2024.03.20.05.16.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Mar 2024 05:16:53 -0700 (PDT) From: Joao Paulo Goncalves To: Tom Rini Cc: Joao Paulo Goncalves , u-boot@lists.denx.de, Vignesh Raghavendra Subject: [PATCH 2/2] arm: mach-k3: am625: Fixup a53 cpu frequency by speed grade Date: Wed, 20 Mar 2024 09:16:32 -0300 Message-Id: <20240320121632.105730-3-jpaulo.silvagoncalves@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240320121632.105730-1-jpaulo.silvagoncalves@gmail.com> References: <20240320121632.105730-1-jpaulo.silvagoncalves@gmail.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean From: Joao Paulo Goncalves The maximum frequency of the A53 CPU on the AM62 depends on the speed grade of the SoC. However, this value is hardcoded in the DT for all AM62 variants, potentially causing specifications to be exceeded. Moreover, setting a common lower frequency for all variants increases boot time. To prevent these issues, modify the DT at runtime from the R5 core to adjust the A53 CPU frequency based on its speed grade. Suggested-by: Vignesh Raghavendra Signed-off-by: Joao Paulo Goncalves --- arch/arm/mach-k3/am625_init.c | 62 +++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/arch/arm/mach-k3/am625_init.c b/arch/arm/mach-k3/am625_init.c index 6c96e881146..961f36e6549 100644 --- a/arch/arm/mach-k3/am625_init.c +++ b/arch/arm/mach-k3/am625_init.c @@ -14,6 +14,7 @@ #include #include #include +#include #define RTC_BASE_ADDRESS 0x2b1f0000 #define REG_K3RTC_S_CNT_LSW (RTC_BASE_ADDRESS + 0x18) @@ -24,6 +25,9 @@ #define K3RTC_KICK0_UNLOCK_VALUE 0x83e70b13 #define K3RTC_KICK1_UNLOCK_VALUE 0x95a4f1e0 +/* TISCI DEV ID for A53 Clock */ +#define AM62X_DEV_A53SS0_CORE_0_DEV_ID 135 + /* * This uninitialized global variable would normal end up in the .bss section, * but the .bss is cleared between writing and reading this variable, so move @@ -112,6 +116,62 @@ static __maybe_unused void rtc_erratumi2327_init(void) writel(K3RTC_KICK1_UNLOCK_VALUE, REG_K3RTC_KICK1); } +#if CONFIG_IS_ENABLED(OF_CONTROL) +static int get_a53_cpu_clock_index(ofnode node) +{ + int count, i; + struct ofnode_phandle_args *args; + ofnode clknode; + + clknode = ofnode_path("/bus@f0000/system-controller@44043000/clock-controller"); + if (!ofnode_valid(clknode)) + return -1; + + count = ofnode_count_phandle_with_args(node, "assigned-clocks", "#clock-cells", 0); + + for (i = 0; i < count; i++) { + if (!ofnode_parse_phandle_with_args(node, "assigned-clocks", + "#clock-cells", 0, i, args)) { + if (ofnode_equal(clknode, args->node) && + args->args[0] == AM62X_DEV_A53SS0_CORE_0_DEV_ID) + return i; + } + } + + return -1; +} + +static void fixup_a53_cpu_freq_by_speed_grade(void) +{ + int index, size; + u32 *rates; + ofnode node; + + node = ofnode_path("/a53@0"); + if (!ofnode_valid(node)) + return; + + rates = fdt_getprop_w(ofnode_to_fdt(node), ofnode_to_offset(node), + "assigned-clock-rates", &size); + + index = get_a53_cpu_clock_index(node); + + if (!rates || index < 0 || index >= (size / sizeof(u32))) { + printf("Wrong A53 assigned-clocks configuration\n"); + return; + } + + rates[index] = cpu_to_fdt32(k3_get_a53_max_frequency()); + + printf("Changed A53 CPU frequency to %dHz (%c grade) in DT\n", + k3_get_a53_max_frequency(), k3_get_speed_grade()); +} +#else +static void fixup_a53_cpu_freq_by_speed_grade(void) +{ +} +#endif + void board_init_f(ulong dummy) { struct udevice *dev; @@ -210,6 +270,8 @@ void board_init_f(ulong dummy) panic("DRAM init failed: %d\n", ret); } spl_enable_cache(); + + fixup_a53_cpu_freq_by_speed_grade(); } u32 spl_mmc_boot_mode(struct mmc *mmc, const u32 boot_device)