Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B5313C00140 for ; Thu, 18 Aug 2022 14:54:14 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A164884B0B; Thu, 18 Aug 2022 16:53:26 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=edgeble.ai 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=edgeble-ai.20210112.gappssmtp.com header.i=@edgeble-ai.20210112.gappssmtp.com header.b="z8zTnAXK"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7CCED84AE8; Thu, 18 Aug 2022 16:53:15 +0200 (CEST) Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) (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 01D6984AE1 for ; Thu, 18 Aug 2022 16:53:08 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=edgeble.ai Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=jagan@edgeble.ai Received: by mail-pl1-x62b.google.com with SMTP id u22so1691555plq.12 for ; Thu, 18 Aug 2022 07:53:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=edgeble-ai.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=TZiTMfWrPMOFbCCCaFK9Hi03+CAerbFoG/UzVyWCF18=; b=z8zTnAXKrZmjbwX+CX0dcVm9iEMdN+oQaOHPXyVjyy1C25lSCzGLXaQC9uUp9iy9H2 aOjEItIuQctEtHGyCxnvW8kHvNaXNiVkyWLbmIr8hgT3T4z3BgUjceWr+V32XOYHR9qA m3DvB8EokmfactNP9HP5xDfkGSu0cQZ+uTsjw4PxGEivdhvdIzS6NKLj2ljRcY9NSrrE MsJnk4PH4ooxj9uLfIDMOrOV1ZwoQ3F4ToQH4YVPYtRD1ehQnkycHivLLwywMWnu2bXb fImJAWe56NOUKD/mcWwDz+k0mc7B606EsuUe6DETiObpaj/IRdwayb34UoCSy8nsOw/m BVOg== 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; bh=TZiTMfWrPMOFbCCCaFK9Hi03+CAerbFoG/UzVyWCF18=; b=g+iNCoO5F8hKpKoSwLogiNbG3GIk6pcnutDi2SZAz1ovJhl/pKsbAuQ163JuwA0gJ6 /gR9Bhx0BOYJvqV26JZ8ks9izFKLoNTlUhZZ46lQ6XxAM+V5eAKoI0rxhSXKXE5CXa+s r4/a5jCUviVEG2i3RNkS+TQ3ulXVlqs06MoV1wYbNTqwfsSBqU4K70dYW95L1s+pTRHV g/sBmDoRtCL2pCb6lemJFKkjpBqTgDh4oDX8/jWxrFkE7x63wcAabS9oS3LlihsmKvAH e7F2xaZWzsnFp5Du5dEtFpKS58a8hXCc5LnqvUslBQtuuz5jsfkNAu0E3x51ERWzzHaM MYWQ== X-Gm-Message-State: ACgBeo2FXCMWcVMQYYTT1xGL4pqVB4ykf0ALe4a5O7zfPGJy1wHxKAke 3DWFvwONyBpWO8eAhZFoenvMHw== X-Google-Smtp-Source: AA6agR7v7o9mpL27V9XybDXoQjY0Gq/HY5iX/29d8zMH954oHUA0PQQYFsM/bZUaYU+LucTYDo4T/Q== X-Received: by 2002:a17:90a:2b42:b0:1f4:fc9a:be32 with SMTP id y2-20020a17090a2b4200b001f4fc9abe32mr8902547pjc.221.1660834386134; Thu, 18 Aug 2022 07:53:06 -0700 (PDT) Received: from localhost.localdomain ([2405:201:c00a:a073:d1c4:8ea9:aedc:add1]) by smtp.gmail.com with ESMTPSA id i15-20020a17090332cf00b0016dc6243bb2sm1504818plr.143.2022.08.18.07.53.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Aug 2022 07:53:05 -0700 (PDT) From: Jagan Teki To: Kever Yang , Philipp Tomsich , Simon Glass Cc: u-boot@lists.denx.de, Jagan Teki , YouMin Chen Subject: [PATCH v2 05/28] ram: rockchip: Update high row detection for full bw Date: Thu, 18 Aug 2022 20:22:23 +0530 Message-Id: <20220818145246.201205-6-jagan@edgeble.ai> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220818145246.201205-1-jagan@edgeble.ai> References: <20220818145246.201205-1-jagan@edgeble.ai> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 High row detection for non-8bit bw requires axi split. So, update the existing high row detection code in order to support full bw chips. Signed-off-by: YouMin Chen Signed-off-by: Jagan Teki --- Changes for v2: - none .../include/asm/arch-rockchip/sdram_common.h | 2 +- drivers/ram/rockchip/sdram_common.c | 56 ++++++++++++++++++- drivers/ram/rockchip/sdram_px30.c | 2 +- 3 files changed, 55 insertions(+), 5 deletions(-) diff --git a/arch/arm/include/asm/arch-rockchip/sdram_common.h b/arch/arm/include/asm/arch-rockchip/sdram_common.h index a14b37cbc5..dd316f771a 100644 --- a/arch/arm/include/asm/arch-rockchip/sdram_common.h +++ b/arch/arm/include/asm/arch-rockchip/sdram_common.h @@ -136,7 +136,7 @@ int sdram_detect_row(struct sdram_cap_info *cap_info, u32 coltmp, u32 bktmp, u32 rowtmp); int sdram_detect_row_3_4(struct sdram_cap_info *cap_info, u32 coltmp, u32 bktmp); -int sdram_detect_high_row(struct sdram_cap_info *cap_info); +int sdram_detect_high_row(struct sdram_cap_info *cap_info, u32 dramtype); int sdram_detect_cs1_row(struct sdram_cap_info *cap_info, u32 dram_type); u64 sdram_get_cs_cap(struct sdram_cap_info *cap_info, u32 cs, u32 dram_type); void sdram_copy_to_reg(u32 *dest, const u32 *src, u32 n); diff --git a/drivers/ram/rockchip/sdram_common.c b/drivers/ram/rockchip/sdram_common.c index 1c3236746a..17d0096dfd 100644 --- a/drivers/ram/rockchip/sdram_common.c +++ b/drivers/ram/rockchip/sdram_common.c @@ -381,10 +381,60 @@ int sdram_detect_row_3_4(struct sdram_cap_info *cap_info, return 0; } -int sdram_detect_high_row(struct sdram_cap_info *cap_info) +int sdram_detect_high_row(struct sdram_cap_info *cap_info, u32 dramtype) { - cap_info->cs0_high16bit_row = cap_info->cs0_row; - cap_info->cs1_high16bit_row = cap_info->cs1_row; + unsigned long base_addr; + u32 cs0_high_row, cs1_high_row, cs; + u64 cap = 0, cs0_cap = 0; + u32 i; + void __iomem *test_addr, *test_addr1; + + cs = cap_info->rank; + /* 8bit bandwidth no enable axi split*/ + if (!cap_info->bw) { + cs0_high_row = cap_info->cs0_row; + cs1_high_row = cap_info->cs1_row; + goto out; + } + + cs0_cap = sdram_get_cs_cap(cap_info, 0, dramtype); + if (cs == 2) { + base_addr = CONFIG_SYS_SDRAM_BASE + cs0_cap; + cap = sdram_get_cs_cap(cap_info, 1, dramtype); + } else { + base_addr = CONFIG_SYS_SDRAM_BASE; + cap = cs0_cap; + } + /* detect full bandwidth size */ + for (i = 0; i < 4; i++) { + test_addr = (void __iomem *)base_addr; + test_addr1 = (void __iomem *)(base_addr + + (unsigned long)(cap / (1ul << (i + 1)))); + writel(0x0, test_addr); + writel(PATTERN, test_addr1); + if ((readl(test_addr) == 0x0) && + (readl(test_addr1) == PATTERN)) + break; + } + if (i == 4 && cs == 1) { + printascii("can't support this cap\n"); + return -1; + } + + if (cs == 2) { + cs0_high_row = cap_info->cs0_row; + if (i == 4) + cs1_high_row = 0; + else + cs1_high_row = cap_info->cs1_row - i; + } else { + cs0_high_row = cap_info->cs0_row - i; + cs1_high_row = 0; + } + +out: + cap_info->cs0_high16bit_row = cs0_high_row; + cap_info->cs1_high16bit_row = cs1_high_row; return 0; } diff --git a/drivers/ram/rockchip/sdram_px30.c b/drivers/ram/rockchip/sdram_px30.c index a003893538..6b700f5ce5 100644 --- a/drivers/ram/rockchip/sdram_px30.c +++ b/drivers/ram/rockchip/sdram_px30.c @@ -677,7 +677,7 @@ static int sdram_init_detect(struct dram_info *dram, writel(sys_reg3, &dram->pmugrf->os_reg[3]); } - ret = sdram_detect_high_row(cap_info); + ret = sdram_detect_high_row(cap_info, sdram_params->base.dramtype); out: return ret; -- 2.25.1