From patchwork Sun Dec 11 16:32:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jernej_=C5=A0krabec?= X-Patchwork-Id: 1714689 X-Patchwork-Delegate: andre.przywara@arm.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=20210112 header.b=p+cLd4q7; dkim-atps=neutral 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 (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NVVhR38Dtz23yc for ; Mon, 12 Dec 2022 03:34:15 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1D975853D1; Sun, 11 Dec 2022 17:33:05 +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="p+cLd4q7"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 469C685254; Sun, 11 Dec 2022 17:32:52 +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 autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) (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 9704B85254 for ; Sun, 11 Dec 2022 17:32:48 +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=jernej.skrabec@gmail.com Received: by mail-ej1-x633.google.com with SMTP id t17so22507735eju.1 for ; Sun, 11 Dec 2022 08:32:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=zlWFrNuTpa3fFaC/NIelmd2af7NBgw5TVl2l3ldpg1k=; b=p+cLd4q7Eh5usIoW+vhQLaoSZONSK8PXm+37quIXCR+dQFTjkDHa0eOTFSBP867KOo lqT/tZvDU+A6C/J/N5/zJXme3g1AE/fUcey0sKP9aboHsNQp2ir+rgHc4am7pGAd+pYS JuTognlfS10IAp+NWWyM0snI9tKebSVv6YS2gE+Fx/PW3PG0I11DAo+/D3D3rohDahlq PYbGbj8sK8j+Ys44YDmqrwP56yNtboJefnveriFS3k64f/v2t9OGZsId94VZC+idq/B+ UgUKCL3y3ULM6rq2dkRnXK68w2yt5ZdfJ24Ug9dsPve1xaUKSheq5XVDIAZcLEvsguIV 9qeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=zlWFrNuTpa3fFaC/NIelmd2af7NBgw5TVl2l3ldpg1k=; b=1fpX1By8ar+r2z/zaQk2r+MgH6jIOyvYjQjy5nols39d5V2exJ/juUYIty+rXT+XA5 PeQX/iOXgLT9kwpYr10XmSDJkghuTfsiUDHcvN4EMMtwHhSxUParXu+p9XfWZk6J6z3F zeFoICmCsyn0h/a479sF7QRU++6xsLMlvngiZoEf1lNgTSdogfkSCO9eDYEh2b1irHVT srhJukX+vgFQG86lshLMImNUSOhmHgfoTK2m5YKPIkD/I7hjFJGb3TKfKQ74b0nfOs5t 9pIBq9wZW5+HnKz5GCCFOcIuSEwqP4G4FkbEnR8YCrRnhbtAjHqnNzY/cJm2UExv4b2c 9MeA== X-Gm-Message-State: ANoB5plr8HGY0ojR5z8LdFqvU4gQ+HHlXqIZeZEWThsjal4XOaXhG28s j6axCgHwdNT4UQ8Wj96jg58= X-Google-Smtp-Source: AA0mqf4VZb83Ifeoh4gkfuPrUyMLaMzv/kHNfiYtAnshILG+vAAM/lCOxu15139wTZHqjbVa7zIbBQ== X-Received: by 2002:a17:906:b114:b0:7ae:72ae:264c with SMTP id u20-20020a170906b11400b007ae72ae264cmr10842058ejy.77.1670776367964; Sun, 11 Dec 2022 08:32:47 -0800 (PST) Received: from localhost.localdomain (82-149-19-102.dynamic.telemach.net. [82.149.19.102]) by smtp.gmail.com with ESMTPSA id qu27-20020a170907111b00b007c0d41736c0sm2243564ejb.39.2022.12.11.08.32.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Dec 2022 08:32:47 -0800 (PST) From: Jernej Skrabec To: andre.przywara@arm.com, jagan@amarulasolutions.com Cc: u-boot@lists.denx.de, Jernej Skrabec Subject: [PATCH 8/8] sunxi: Parameterize H616 DRAM code some more Date: Sun, 11 Dec 2022 17:32:13 +0100 Message-Id: <20221211163213.98540-9-jernej.skrabec@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221211163213.98540-1-jernej.skrabec@gmail.com> References: <20221211163213.98540-1-jernej.skrabec@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.6 at phobos.denx.de X-Virus-Status: Clean Part of the code, previously known as "unknown feature" also doesn't have constant values. They are derived from TPR0 parameter in vendor DRAM code. Introduce that parameter here too, to ease adding new boards. Signed-off-by: Jernej Skrabec --- .../include/asm/arch-sunxi/dram_sun50i_h616.h | 1 + arch/arm/mach-sunxi/Kconfig | 6 ++++ arch/arm/mach-sunxi/dram_sun50i_h616.c | 35 +++++++++++++++---- 3 files changed, 35 insertions(+), 7 deletions(-) diff --git a/arch/arm/include/asm/arch-sunxi/dram_sun50i_h616.h b/arch/arm/include/asm/arch-sunxi/dram_sun50i_h616.h index c7890c83391f..ff736bd88d10 100644 --- a/arch/arm/include/asm/arch-sunxi/dram_sun50i_h616.h +++ b/arch/arm/include/asm/arch-sunxi/dram_sun50i_h616.h @@ -158,6 +158,7 @@ struct dram_para { u32 dx_dri; u32 ca_dri; u32 odt_en; + u32 tpr0; u32 tpr10; u32 tpr11; u32 tpr12; diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig index b050f0a56971..7858a7045f7e 100644 --- a/arch/arm/mach-sunxi/Kconfig +++ b/arch/arm/mach-sunxi/Kconfig @@ -73,6 +73,12 @@ config DRAM_SUN50I_H616_ODT_EN help ODT EN value from vendor DRAM settings. +config DRAM_SUN50I_H616_TPR0 + hex "H616 DRAM TPR0 parameter" + default 0x0 + help + TPR0 value from vendor DRAM settings. + config DRAM_SUN50I_H616_TPR10 hex "H616 DRAM TPR10 parameter" help diff --git a/arch/arm/mach-sunxi/dram_sun50i_h616.c b/arch/arm/mach-sunxi/dram_sun50i_h616.c index df06cea42464..6d8f8d371bfe 100644 --- a/arch/arm/mach-sunxi/dram_sun50i_h616.c +++ b/arch/arm/mach-sunxi/dram_sun50i_h616.c @@ -808,15 +808,35 @@ static bool mctl_phy_init(struct dram_para *para) writel(phy_init[i], &ptr[i]); if (para->tpr10 & TPR10_UNKNOWN_FEAT0) { + if (para->tpr0 & BIT(30)) + val = (para->tpr0 >> 7) & 0x3e; + else + val = (para->tpr10 >> 3) & 0x1e; + ptr = (u32 *)(SUNXI_DRAM_PHY0_BASE + 0x780); for (i = 0; i < 32; i++) - writel(0x16, &ptr[i]); - writel(0xe, SUNXI_DRAM_PHY0_BASE + 0x78c); - writel(0xe, SUNXI_DRAM_PHY0_BASE + 0x7a4); - writel(0xe, SUNXI_DRAM_PHY0_BASE + 0x7b8); - writel(0x8, SUNXI_DRAM_PHY0_BASE + 0x7d4); - writel(0xe, SUNXI_DRAM_PHY0_BASE + 0x7dc); - writel(0xe, SUNXI_DRAM_PHY0_BASE + 0x7e0); + writel(val, &ptr[i]); + + val = (para->tpr10 << 1) & 0x1e; + writel(val, SUNXI_DRAM_PHY0_BASE + 0x7dc); + writel(val, SUNXI_DRAM_PHY0_BASE + 0x7e0); + + /* following configuration is DDR3 specific */ + val = (para->tpr10 >> 7) & 0x1e; + writel(val, SUNXI_DRAM_PHY0_BASE + 0x7d4); + /* + * TODO: Offsets 0x79c, 0x794 and 0x7e4 may need + * to be set here. However, this doesn't seem to + * be needed by any board seen in the wild for now. + * It's not implemented because it would unnecessarily + * introduce PARA2 and TPR2 options. + */ + if (para->tpr0 & BIT(31)) { + val = (para->tpr0 << 1) & 0x3e; + writel(val, SUNXI_DRAM_PHY0_BASE + 0x78c); + writel(val, SUNXI_DRAM_PHY0_BASE + 0x7a4); + writel(val, SUNXI_DRAM_PHY0_BASE + 0x7b8); + } } writel(0x80, SUNXI_DRAM_PHY0_BASE + 0x3dc); @@ -1110,6 +1130,7 @@ unsigned long sunxi_dram_init(void) .dx_dri = CONFIG_DRAM_SUN50I_H616_DX_DRI, .ca_dri = CONFIG_DRAM_SUN50I_H616_CA_DRI, .odt_en = CONFIG_DRAM_SUN50I_H616_ODT_EN, + .tpr0 = CONFIG_DRAM_SUN50I_H616_TPR0, .tpr10 = CONFIG_DRAM_SUN50I_H616_TPR10, .tpr11 = CONFIG_DRAM_SUN50I_H616_TPR11, .tpr12 = CONFIG_DRAM_SUN50I_H616_TPR12,