From patchwork Thu Oct 27 14:47:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 79693 Delivered-To: patch@linaro.org Received: by 10.80.142.83 with SMTP id 19csp685846edx; Thu, 27 Oct 2016 07:48:40 -0700 (PDT) X-Received: by 10.28.133.202 with SMTP id h193mr13245745wmd.85.1477579720196; Thu, 27 Oct 2016 07:48:40 -0700 (PDT) Return-Path: Received: from theia.denx.de (theia.denx.de. [85.214.87.163]) by mx.google.com with ESMTP id n4si8896044wji.277.2016.10.27.07.48.39; Thu, 27 Oct 2016 07:48:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 85.214.87.163 as permitted sender) client-ip=85.214.87.163; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 85.214.87.163 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 0F627A7549; Thu, 27 Oct 2016 16:48:08 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Tsac-cZR72To; Thu, 27 Oct 2016 16:48:07 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 615A3B3837; Thu, 27 Oct 2016 16:48:04 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id F0CB24B99D for ; Thu, 27 Oct 2016 16:47:33 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 2GNh47MmCO6J for ; Thu, 27 Oct 2016 16:47:33 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from conuserg-07.nifty.com (conuserg-07.nifty.com [210.131.2.74]) by theia.denx.de (Postfix) with ESMTPS id 05F8C4BA81 for ; Thu, 27 Oct 2016 16:47:29 +0200 (CEST) Received: from grover.sesame (FL1-111-169-71-157.osk.mesh.ad.jp [111.169.71.157]) (authenticated) by conuserg-07.nifty.com with ESMTP id u9RElDVL017011; Thu, 27 Oct 2016 23:47:22 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com u9RElDVL017011 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1477579642; bh=8w7pEIFvn9AUAHAIMpVrvweE9NvrMGtys5LzBio1EkU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KoCkBGzrlWayKrJJ22zA3naQ+Yb+wplPs4G8iQkQyXixkK2vxyNngKtJjkrajOSPn kDFDDjTWq9p4gpu6POoUont186MFW4cHkPJdp3xwvIzEi7Aw57/ssuOPRkZ1Hz4e2o Dj0YxAX2sgxTDsKbsafRbLVhQ4CpA7Wsr01zujTXUmr1+7jIoZ/AUsdKjEpy9qIp0q W8iwyvFErpEi+6Qctj+UbQd333S0AXWB8djMnA0BZWyGnhe+AAY9yUR0Gsg9ytZe5T 90lLSOVmSprGq7tfUYbOAU3I1jOukrIPNnvXTSYbKqRmvPQc9nl3DspcxfWPNCl+0g w/pfZSDNBfFEg== X-Nifty-SrcIP: [111.169.71.157] From: Masahiro Yamada To: u-boot@lists.denx.de Date: Thu, 27 Oct 2016 23:47:02 +0900 Message-Id: <1477579630-9692-4-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1477579630-9692-1-git-send-email-yamada.masahiro@socionext.com> References: <1477579630-9692-1-git-send-email-yamada.masahiro@socionext.com> Cc: Albert Aribaud Subject: [U-Boot] [PATCH 03/11] ARM: uniphier: update DRAM init code for LD20 SoC (3rd) X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" - Constify UMC setting data arrays - Merge data arrays *_d0 and *_d1. - Add PHY parameters for LD20 C1 board Signed-off-by: Masahiro Yamada --- arch/arm/mach-uniphier/dram/ddrphy-ld20-regs.h | 1 + arch/arm/mach-uniphier/dram/umc-ld20.c | 111 +++++++++++++++++-------- arch/arm/mach-uniphier/init.h | 7 +- 3 files changed, 83 insertions(+), 36 deletions(-) -- 1.9.1 _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot diff --git a/arch/arm/mach-uniphier/dram/ddrphy-ld20-regs.h b/arch/arm/mach-uniphier/dram/ddrphy-ld20-regs.h index 0c11b65..268ba7f 100644 --- a/arch/arm/mach-uniphier/dram/ddrphy-ld20-regs.h +++ b/arch/arm/mach-uniphier/dram/ddrphy-ld20-regs.h @@ -15,6 +15,7 @@ #define PHY_MAS_DLY_WIDTH 8 #define PHY_SCL_START (0x40 << (PHY_REG_SHIFT)) +#define PHY_SCL_START_GO_DONE BIT(28) #define PHY_SCL_DATA_0 (0x41 << (PHY_REG_SHIFT)) #define PHY_SCL_DATA_1 (0x42 << (PHY_REG_SHIFT)) #define PHY_SCL_LATENCY (0x43 << (PHY_REG_SHIFT)) diff --git a/arch/arm/mach-uniphier/dram/umc-ld20.c b/arch/arm/mach-uniphier/dram/umc-ld20.c index 4e1fbde..ea933fe 100644 --- a/arch/arm/mach-uniphier/dram/umc-ld20.c +++ b/arch/arm/mach-uniphier/dram/umc-ld20.c @@ -1,7 +1,7 @@ /* * Copyright (C) 2016 Socionext Inc. * - * based on commit 9073035a9860f892f8d1345dfb0ea862b5021145 of Diag + * based on commit a7a36122aa072fe1bb06e02b73b3634b7a6c555a of Diag * * SPDX-License-Identifier: GPL-2.0+ */ @@ -33,6 +33,7 @@ enum dram_size { enum dram_board { /* board type */ DRAM_BOARD_LD20_REF, /* LD20 reference */ DRAM_BOARD_LD20_GLOBAL, /* LD20 TV */ + DRAM_BOARD_LD20_C1, /* LD20 TV C1 */ DRAM_BOARD_LD21_REF, /* LD21 reference */ DRAM_BOARD_LD21_GLOBAL, /* LD21 TV */ DRAM_BOARD_NR, @@ -42,6 +43,7 @@ enum dram_board { /* board type */ static const int ddrphy_adrctrl[DRAM_BOARD_NR][DRAM_CH_NR] = { {268 - 262, 268 - 263, 268 - 378}, /* LD20 reference */ {268 - 262, 268 - 263, 268 - 378}, /* LD20 TV */ + {268 - 262, 268 - 263, 268 - 378}, /* LD20 TV C1 */ {268 - 212, 268 - 268, /* No CH2 */}, /* LD21 reference */ {268 - 212, 268 - 268, /* No CH2 */}, /* LD21 TV */ }; @@ -49,6 +51,7 @@ static const int ddrphy_adrctrl[DRAM_BOARD_NR][DRAM_CH_NR] = { static const int ddrphy_dlltrimclk[DRAM_BOARD_NR][DRAM_CH_NR] = { {268, 268, 268}, /* LD20 reference */ {268, 268, 268}, /* LD20 TV */ + {189, 189, 189}, /* LD20 TV C1 */ {268, 268 + 252, /* No CH2 */}, /* LD21 reference */ {268, 268 + 202, /* No CH2 */}, /* LD21 TV */ }; @@ -56,6 +59,7 @@ static const int ddrphy_dlltrimclk[DRAM_BOARD_NR][DRAM_CH_NR] = { static const int ddrphy_dllrecalib[DRAM_BOARD_NR][DRAM_CH_NR] = { {268 - 378, 268 - 263, 268 - 378}, /* LD20 reference */ {268 - 378, 268 - 263, 268 - 378}, /* LD20 TV */ + {268 - 378, 268 - 263, 268 - 378}, /* LD20 TV C1 */ {268 - 212, 268 - 536, /* No CH2 */}, /* LD21 reference */ {268 - 212, 268 - 536, /* No CH2 */}, /* LD21 TV */ }; @@ -63,6 +67,7 @@ static const int ddrphy_dllrecalib[DRAM_BOARD_NR][DRAM_CH_NR] = { static const u32 ddrphy_phy_pad_ctrl[DRAM_BOARD_NR][DRAM_CH_NR] = { {0x50B840B1, 0x50B840B1, 0x50B840B1}, /* LD20 reference */ {0x50BB40B1, 0x50BB40B1, 0x50BB40B1}, /* LD20 TV */ + {0x50BB40B1, 0x50BB40B1, 0x50BB40B1}, /* LD20 TV C1 */ {0x50BB40B4, 0x50B840B1, /* No CH2 */}, /* LD21 reference */ {0x50BB40B4, 0x50B840B1, /* No CH2 */}, /* LD21 TV */ }; @@ -112,6 +117,26 @@ static const int ddrphy_op_dq_shift_val[DRAM_BOARD_NR][DRAM_CH_NR][32] = { 1, 1, 1, 0, 2, 2, 1, 2, }, }, + { /* LD20 TV C1 */ + { + 2, 1, 0, 1, 2, 1, 1, 1, + 2, 1, 1, 2, 1, 1, 1, 1, + 1, 2, 1, 1, 1, 2, 1, 1, + 2, 2, 0, 1, 1, 2, 2, 1, + }, + { + 1, 1, 0, 1, 2, 2, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 0, 0, 1, 1, 0, 0, + 0, 1, 1, 1, 2, 1, 2, 1, + }, + { + 2, 2, 0, 2, 1, 1, 2, 1, + 1, 1, 0, 1, 1, -1, 1, 1, + 2, 2, 2, 2, 1, 1, 1, 1, + 1, 1, 1, 0, 2, 2, 1, 2, + }, + }, { /* LD21 reference */ { 1, 1, 0, 1, 1, 1, 1, 1, @@ -183,6 +208,26 @@ static int ddrphy_ip_dq_shift_val[DRAM_BOARD_NR][DRAM_CH_NR][32] = { 2, 2, 2, 2, 1, 2, 2, 1, }, }, + { /* LD20 TV C1 */ + { + 3, 3, 3, 2, 3, 2, 0, 2, + 2, 3, 3, 1, 2, 2, 2, 2, + 2, 2, 2, 2, 0, 1, 1, 1, + 2, 2, 2, 2, 3, 0, 2, 2, + }, + { + 2, 2, 1, 1, -1, 1, 1, 1, + 2, 0, 2, 2, 2, 1, 0, 2, + 2, 1, 2, 1, 0, 1, 1, 1, + 2, 2, 2, 2, 2, 2, 2, 2, + }, + { + 2, 2, 3, 2, 1, 2, 2, 2, + 2, 3, 4, 2, 3, 4, 3, 3, + 2, 2, 1, 2, 1, 1, 1, 1, + 2, 2, 2, 2, 1, 2, 2, 1, + }, + }, { /* LD21 reference */ { 2, 2, 2, 2, 1, 2, 2, 2, @@ -387,7 +432,7 @@ static int ddrphy_training(void __iomem *phy_base, enum dram_board board, writel(0x00010000, phy_base + PHY_DLL_TRIM_2); writel(0x50000000, phy_base + PHY_SCL_START); - while (readl(phy_base + PHY_SCL_START) & BIT(28)) + while (readl(phy_base + PHY_SCL_START) & PHY_SCL_START_GO_DONE) cpu_relax(); writel(0x00000000, phy_base + PHY_DISABLE_GATING_FOR_SCL); @@ -396,13 +441,13 @@ static int ddrphy_training(void __iomem *phy_base, enum dram_board board, writel(0xFBF8FFFF, phy_base + PHY_SCL_START_ADDR); writel(0x11000000, phy_base + PHY_SCL_START); - while (readl(phy_base + PHY_SCL_START) & BIT(28)) + while (readl(phy_base + PHY_SCL_START) & PHY_SCL_START_GO_DONE) cpu_relax(); writel(0xFBF0FFFF, phy_base + PHY_SCL_START_ADDR); writel(0x30500000, phy_base + PHY_SCL_START); - while (readl(phy_base + PHY_SCL_START) & BIT(28)) + while (readl(phy_base + PHY_SCL_START) & PHY_SCL_START_GO_DONE) cpu_relax(); writel(0x00000001, phy_base + PHY_DISABLE_GATING_FOR_SCL); @@ -411,12 +456,12 @@ static int ddrphy_training(void __iomem *phy_base, enum dram_board board, writel(0xf10e4a56, phy_base + PHY_SCL_DATA_1); writel(0x11000000, phy_base + PHY_SCL_START); - while (readl(phy_base + PHY_SCL_START) & BIT(28)) + while (readl(phy_base + PHY_SCL_START) & PHY_SCL_START_GO_DONE) cpu_relax(); writel(0x34000000, phy_base + PHY_SCL_START); - while (readl(phy_base + PHY_SCL_START) & BIT(28)) + while (readl(phy_base + PHY_SCL_START) & PHY_SCL_START_GO_DONE) cpu_relax(); writel(0x00000003, phy_base + PHY_DISABLE_GATING_FOR_SCL); @@ -445,45 +490,42 @@ static int ddrphy_training(void __iomem *phy_base, enum dram_board board, } /* UMC */ -static u32 umc_initctla[DRAM_FREQ_NR] = {0x71016D11}; -static u32 umc_initctlb[DRAM_FREQ_NR] = {0x07E390AC}; -static u32 umc_initctlc[DRAM_FREQ_NR] = {0x00FF00FF}; -static u32 umc_drmmr0[DRAM_FREQ_NR] = {0x00000114}; -static u32 umc_drmmr2[DRAM_FREQ_NR] = {0x000002a0}; +static const u32 umc_initctla[DRAM_FREQ_NR] = {0x71016D11}; +static const u32 umc_initctlb[DRAM_FREQ_NR] = {0x07E390AC}; +static const u32 umc_initctlc[DRAM_FREQ_NR] = {0x00FF00FF}; +static const u32 umc_drmmr0[DRAM_FREQ_NR] = {0x00000114}; +static const u32 umc_drmmr2[DRAM_FREQ_NR] = {0x000002a0}; -static u32 umc_memconf0a[DRAM_FREQ_NR][DRAM_SZ_NR] = { +static const u32 umc_memconf0a[DRAM_FREQ_NR][DRAM_SZ_NR] = { /* 256MB 512MB */ {0x00000601, 0x00000801}, /* 1866 MHz */ }; -static u32 umc_memconf0b[DRAM_FREQ_NR][DRAM_SZ_NR] = { +static const u32 umc_memconf0b[DRAM_FREQ_NR][DRAM_SZ_NR] = { /* 256MB 512MB */ {0x00000120, 0x00000130}, /* 1866 MHz */ }; -static u32 umc_memconfch[DRAM_FREQ_NR][DRAM_SZ_NR] = { +static const u32 umc_memconfch[DRAM_FREQ_NR][DRAM_SZ_NR] = { /* 256MB 512MB */ {0x00033603, 0x00033803}, /* 1866 MHz */ }; -static u32 umc_cmdctla[DRAM_FREQ_NR] = {0x060D0D20}; -static u32 umc_cmdctlb[DRAM_FREQ_NR] = {0x2D211C08}; -static u32 umc_cmdctlc[DRAM_FREQ_NR] = {0x00150C04}; -static u32 umc_cmdctle[DRAM_FREQ_NR][DRAM_SZ_NR] = { +static const u32 umc_cmdctla[DRAM_FREQ_NR] = {0x060D0D20}; +static const u32 umc_cmdctlb[DRAM_FREQ_NR] = {0x2D211C08}; +static const u32 umc_cmdctlc[DRAM_FREQ_NR] = {0x00150C04}; +static const u32 umc_cmdctle[DRAM_FREQ_NR][DRAM_SZ_NR] = { /* 256MB 512MB */ {0x0049071D, 0x0078071D}, /* 1866 MHz */ }; -static u32 umc_rdatactl_d0[DRAM_FREQ_NR] = {0x00000610}; -static u32 umc_rdatactl_d1[DRAM_FREQ_NR] = {0x00000610}; -static u32 umc_wdatactl_d0[DRAM_FREQ_NR] = {0x00000204}; -static u32 umc_wdatactl_d1[DRAM_FREQ_NR] = {0x00000204}; -static u32 umc_odtctl_d0[DRAM_FREQ_NR] = {0x02000002}; -static u32 umc_odtctl_d1[DRAM_FREQ_NR] = {0x02000002}; -static u32 umc_dataset[DRAM_FREQ_NR] = {0x04000000}; +static const u32 umc_rdatactl[DRAM_FREQ_NR] = {0x00000610}; +static const u32 umc_wdatactl[DRAM_FREQ_NR] = {0x00000204}; +static const u32 umc_odtctl[DRAM_FREQ_NR] = {0x02000002}; +static const u32 umc_dataset[DRAM_FREQ_NR] = {0x04000000}; -static u32 umc_flowctla[DRAM_FREQ_NR] = {0x0081E01E}; -static u32 umc_directbusctrla[DRAM_CH_NR] = { +static const u32 umc_flowctla[DRAM_FREQ_NR] = {0x0081E01E}; +static const u32 umc_directbusctrla[DRAM_CH_NR] = { 0x00000000, 0x00000001, 0x00000001 }; @@ -546,13 +588,13 @@ static int umc_dc_init(void __iomem *dc_base, unsigned int freq, writel(umc_cmdctlc[freq_e], dc_base + UMC_CMDCTLC); writel(umc_cmdctle[freq_e][size_e], dc_base + UMC_CMDCTLE); - writel(umc_rdatactl_d0[freq_e], dc_base + UMC_RDATACTL_D0); - writel(umc_rdatactl_d1[freq_e], dc_base + UMC_RDATACTL_D1); + writel(umc_rdatactl[freq_e], dc_base + UMC_RDATACTL_D0); + writel(umc_rdatactl[freq_e], dc_base + UMC_RDATACTL_D1); - writel(umc_wdatactl_d0[freq_e], dc_base + UMC_WDATACTL_D0); - writel(umc_wdatactl_d1[freq_e], dc_base + UMC_WDATACTL_D1); - writel(umc_odtctl_d0[freq_e], dc_base + UMC_ODTCTL_D0); - writel(umc_odtctl_d1[freq_e], dc_base + UMC_ODTCTL_D1); + writel(umc_wdatactl[freq_e], dc_base + UMC_WDATACTL_D0); + writel(umc_wdatactl[freq_e], dc_base + UMC_WDATACTL_D1); + writel(umc_odtctl[freq_e], dc_base + UMC_ODTCTL_D0); + writel(umc_odtctl[freq_e], dc_base + UMC_ODTCTL_D1); writel(umc_dataset[freq_e], dc_base + UMC_DATASET); writel(0x00400020, dc_base + UMC_DCCGCTL); @@ -644,6 +686,9 @@ int uniphier_ld20_umc_init(const struct uniphier_board_data *bd) case UNIPHIER_BD_BOARD_LD20_GLOBAL: board = DRAM_BOARD_LD20_GLOBAL; break; + case UNIPHIER_BD_BOARD_LD20_C1: + board = DRAM_BOARD_LD20_C1; + break; case UNIPHIER_BD_BOARD_LD21_REF: board = DRAM_BOARD_LD21_REF; break; diff --git a/arch/arm/mach-uniphier/init.h b/arch/arm/mach-uniphier/init.h index 361e024..f3f9e54 100644 --- a/arch/arm/mach-uniphier/init.h +++ b/arch/arm/mach-uniphier/init.h @@ -26,11 +26,12 @@ struct uniphier_board_data { #define UNIPHIER_BD_DDR3PLUS BIT(2) -#define UNIPHIER_BD_BOARD_GET_TYPE(f) ((f) & 0x3) +#define UNIPHIER_BD_BOARD_GET_TYPE(f) ((f) & 0x7) #define UNIPHIER_BD_BOARD_LD20_REF 0 /* LD20 reference */ #define UNIPHIER_BD_BOARD_LD20_GLOBAL 1 /* LD20 TV Set */ -#define UNIPHIER_BD_BOARD_LD21_REF 2 /* LD21 reference */ -#define UNIPHIER_BD_BOARD_LD21_GLOBAL 3 /* LD21 TV Set */ +#define UNIPHIER_BD_BOARD_LD20_C1 2 /* LD20 TV Set C1 */ +#define UNIPHIER_BD_BOARD_LD21_REF 3 /* LD21 reference */ +#define UNIPHIER_BD_BOARD_LD21_GLOBAL 4 /* LD21 TV Set */ }; const struct uniphier_board_data *uniphier_get_board_param(void);