From patchwork Tue Mar 31 23:48:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1264956 X-Patchwork-Delegate: patrick.delaunay73@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: 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: ozlabs.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=denx.de header.i=@denx.de header.a=rsa-sha256 header.s=phobos-20191101 header.b=IMpNy9b8; 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 RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48sQz142Qtz9sT0 for ; Wed, 1 Apr 2020 10:49:17 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A1BCE81CB6; Wed, 1 Apr 2020 01:48:38 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1585698519; bh=cA9BSJjLjWUFekDWcNmtpvuR/oE3USEuLq9b5DXSSR8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=IMpNy9b8dVWW0uSZFaiPEx4SKCLCn4f9r5zefXYC0XRXe3rRLbG+Ba0vtR1ZlEJIg SijLfrIqdSScDVSh3ZqlKNcSS+x7XmDbBQwu86mrsTmeolNLRl5Gc7MS9LnYKXcAS/ bqmJY/AELqnQvbOq2u8/DsJ9ouGorGuHPTFFgBb1jr1R2Mh9Yk092iXkwYUvlNYciy ucjtC4tBTYFWF9Hzyp4K3Uh/DtA3wOtSfRix7Q70G8ElDO/WEx7dQwAiSkPSLJ/rId tivQ3+z0KmlW6xRvt3fC10syNsw59Gl/u25IM/iJkVdKL64JJjIsq1znyOMd2whRS1 KD74dOoC9LJLg== Received: by phobos.denx.de (Postfix, from userid 109) id 07A3C81C7A; Wed, 1 Apr 2020 01:48:33 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 8C77281C8F for ; Wed, 1 Apr 2020 01:48:23 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=marex@denx.de Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 48sQxz2fqfz1qrFM; Wed, 1 Apr 2020 01:48:23 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 48sQxz2T11z1qqkJ; Wed, 1 Apr 2020 01:48:23 +0200 (CEST) Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id PLpCAH4jGR_Z; Wed, 1 Apr 2020 01:48:22 +0200 (CEST) X-Auth-Info: oC/8OeYaSziiANTqJKQnOMbtY4KQ+4biZzbKgJo0pbk= Received: from desktop.lan (ip-86-49-35-8.net.upcbroadband.cz [86.49.35.8]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Wed, 1 Apr 2020 01:48:22 +0200 (CEST) From: Marek Vasut To: u-boot@lists.denx.de Cc: Marek Vasut , Manivannan Sadhasivam , Patrick Delaunay , Patrice Chotard Subject: [PATCH 4/4] [RFC] ARM: stm32: Implement DDR3 coding on DHCOR SoM Date: Wed, 1 Apr 2020 01:48:07 +0200 Message-Id: <20200331234807.432637-4-marex@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200331234807.432637-1-marex@denx.de> References: <20200331234807.432637-1-marex@denx.de> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 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.102.2 at phobos.denx.de X-Virus-Status: Clean The DHCOR board does exist in multiple variants with different DDR3 DRAM sizes. To cater for all of them, implement DDR3 code handling. There are two GPIOs which code the DRAM size populated on the SoM, read them out and use the value to pick the correct DDR3 config. Signed-off-by: Marek Vasut Cc: Manivannan Sadhasivam Cc: Patrick Delaunay Cc: Patrice Chotard Reviewed-by: Patrick Delaunay --- arch/arm/dts/stm32mp15xx-dhcor-u-boot.dtsi | 2 ++ board/dhelectronics/dh_stm32mp1/board.c | 26 +++++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/arch/arm/dts/stm32mp15xx-dhcor-u-boot.dtsi b/arch/arm/dts/stm32mp15xx-dhcor-u-boot.dtsi index 17a23ae21c..6db4ac37e1 100644 --- a/arch/arm/dts/stm32mp15xx-dhcor-u-boot.dtsi +++ b/arch/arm/dts/stm32mp15xx-dhcor-u-boot.dtsi @@ -9,6 +9,7 @@ #include #include "stm32mp157-u-boot.dtsi" +#include "stm32mp15-ddr3-1x4Gb-1066-binG.dtsi" #include "stm32mp15-ddr3-2x4Gb-1066-binG.dtsi" / { @@ -16,6 +17,7 @@ config { u-boot,dm-pre-reloc; #gpio-cells = <2>; + dh,ddr3-coding-gpios = <&gpiog 0 0>, <&gpiog 1 0>; dh,som-coding-gpios = <&gpioz 7 0>, <&gpiof 3 0>; }; }; diff --git a/board/dhelectronics/dh_stm32mp1/board.c b/board/dhelectronics/dh_stm32mp1/board.c index 36b8652521..a081a3f86b 100644 --- a/board/dhelectronics/dh_stm32mp1/board.c +++ b/board/dhelectronics/dh_stm32mp1/board.c @@ -134,6 +134,7 @@ int checkboard(void) } #ifdef CONFIG_SPL_BUILD +static u8 ddr3code __section("data"); static u8 somcode __section("data"); static void board_get_coding_straps(void) @@ -149,6 +150,16 @@ static void board_get_coding_straps(void) } for (i = 0; i < 2; i++) { + ret = gpio_request_by_name_nodev(node, "dh,ddr3-coding-gpios", + i, &gpio, GPIOD_IS_IN); + if (ret) { + printf("%s: could not find a /config/dh,ddr3-coding-gpios[%i]\n", + __func__, i); + return; + } + + ddr3code |= !!dm_gpio_get_value(&gpio) << i; + ret = gpio_request_by_name_nodev(node, "dh,som-coding-gpios", i, &gpio, GPIOD_IS_IN); if (ret) { @@ -160,7 +171,7 @@ static void board_get_coding_straps(void) somcode |= !!dm_gpio_get_value(&gpio) << i; } - printf("Code: SoM:%x\n", somcode); + printf("Code: DDR3:%x SoM:%x\n", ddr3code, somcode); } void board_init_f(ulong dummy) @@ -206,6 +217,19 @@ void board_init_f(ulong dummy) } } +int board_stm32mp1_ddr_config_name_match(struct udevice *dev, + const char *name) +{ + if (ddr3code == 2 && + !strcmp(name, "config@ddr3-1066-888-bin-g-1x4gb-533mhz")) + + if (ddr3code == 3 && + !strcmp(name, "config@ddr3-1066-888-bin-g-2x4gb-533mhz")) + return 0; + + return -EINVAL; +} + #ifdef CONFIG_SPL_LOAD_FIT int board_fit_config_name_match(const char *name) {