From patchwork Wed Feb 13 16:46:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 1041437 X-Patchwork-Delegate: promsoft@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="eaHbYsYp"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 44057c59PJz9s2P for ; Thu, 14 Feb 2019 03:48:28 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 5044BC22093; Wed, 13 Feb 2019 16:47:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 24DE5C220BB; Wed, 13 Feb 2019 16:47:17 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id EC18AC21F98; Wed, 13 Feb 2019 16:47:06 +0000 (UTC) Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by lists.denx.de (Postfix) with ESMTPS id CE479C220A4 for ; Wed, 13 Feb 2019 16:47:02 +0000 (UTC) Received: from localhost.localdomain (unknown [194.230.155.153]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8D30E222D1; Wed, 13 Feb 2019 16:46:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550076421; bh=eNJ7w4QwL7hqCXbmvEvIcgRG65EskXNlqnnPJEbtjL8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eaHbYsYpWv6BDUTJVzm4bDhQMPp0LZpam/u8mmspcsY2ZJvvN/pMcAYk8OLDcwIFx /VNaqqHvgz9Bwa+QaetqTYg320JPXedoEmxYvfWt+LqXUPKRs1lunoxzLOPcM0BYWt DglXDjLrg/JOxRNo/UI5uHp3cB0fKperHiqx+3kA= From: Krzysztof Kozlowski To: Albert Aribaud , Jaehoon Chung , Lukasz Majewski , Simon Glass , Minkyu Kang , Marek Szyprowski , u-boot@lists.denx.de Date: Wed, 13 Feb 2019 17:46:42 +0100 Message-Id: <20190213164648.26579-4-krzk@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190213164648.26579-1-krzk@kernel.org> References: <20190213164648.26579-1-krzk@kernel.org> Cc: Krzysztof Kozlowski Subject: [U-Boot] [PATCH v2 3/9] arm: exynos: Detect revision later, when all resources are ready X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 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" Detection of board revision is done early - before power setup. In case of Odroid XU3/XU4/HC1 family, the detection is done using ADC which is supplied by LDO4/VDD_ADC regulator. This regulator could be turned off (e.g. by kernel before reboot). If ADC is used early, the regulators are not yet available and the detection won't work. Split the revision detection out of set_board_type() into separate function called later - either when displaying board info or during misc_init_r (whatever succeeds first). The idea is that set_board_type() will be called early so its method of detection are limited to flattened device tree (exynos5-dt-types.c for Exynos5) or GPIO (odroid.c for Exynos4412). The newly added set_board_revision() can be called only later, when resources like regulator are available. This is necessary to fix the detection of Odroid HC1 after reboot, if kernel turned off the LDO4 regulator. Signed-off-by: Krzysztof Kozlowski --- board/samsung/common/board.c | 13 ++++++++++++- board/samsung/common/exynos5-dt-types.c | 20 +++++++++++++++++--- board/samsung/odroid/odroid.c | 8 ++++++++ include/samsung/misc.h | 1 + 4 files changed, 38 insertions(+), 4 deletions(-) diff --git a/board/samsung/common/board.c b/board/samsung/common/board.c index 96228a86a117..52a2764a1919 100644 --- a/board/samsung/common/board.c +++ b/board/samsung/common/board.c @@ -253,7 +253,12 @@ int board_eth_init(bd_t *bis) int checkboard(void) { if (IS_ENABLED(CONFIG_BOARD_TYPES)) { - const char *board_info = get_board_type(); + const char *board_info; + + /* Printing type requires having revision */ + set_board_revision(); + + board_info = get_board_type(); if (board_info) printf("Type: %s\n", board_info); @@ -287,6 +292,12 @@ int board_late_init(void) #ifdef CONFIG_MISC_INIT_R int misc_init_r(void) { + /* + * At this point regulators should be available so do full + * revision detection + */ + set_board_revision(); + #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG set_board_info(); #endif diff --git a/board/samsung/common/exynos5-dt-types.c b/board/samsung/common/exynos5-dt-types.c index 7a86e9187768..af711e727a78 100644 --- a/board/samsung/common/exynos5-dt-types.c +++ b/board/samsung/common/exynos5-dt-types.c @@ -192,8 +192,11 @@ const char *get_board_type(void) /** * set_board_type() - set board type in gd->board_type. - * As default type set EXYNOS5_BOARD_GENERIC, if detect Odroid, - * then set its proper type. + * As default type set EXYNOS5_BOARD_GENERIC. If Odroid is detected, + * set its proper type based on device tree. + * + * This might be called early when some more specific ways to detect revision + * are not yet available. */ void set_board_type(void) { @@ -211,8 +214,19 @@ void set_board_type(void) gd->board_type = of_match->data; break; } +} + +/** + * set_board_revision() - set detailed board type in gd->board_type. + * Should be called when resources (e.g. regulators) are available + * so ADC can be used to detect the specific revision of a board. + */ +void set_board_revision(void) +{ + /* Do not detect revision twice */ + if (gd->board_type == EXYNOS5_BOARD_GENERIC) + return; - /* If Odroid, then check its revision */ if (board_is_odroidxu3()) gd->board_type = odroid_get_board_type(); } diff --git a/board/samsung/odroid/odroid.c b/board/samsung/odroid/odroid.c index 552333fe869d..4be8cc9826c3 100644 --- a/board/samsung/odroid/odroid.c +++ b/board/samsung/odroid/odroid.c @@ -54,6 +54,14 @@ void set_board_type(void) gd->board_type = ODROID_TYPE_U3; } +void set_board_revision(void) +{ + /* + * Revision already set by set_board_type() because it can be + * executed early. + */ +} + const char *get_board_type(void) { const char *board_type[] = {"u3", "x2"}; diff --git a/include/samsung/misc.h b/include/samsung/misc.h index 017560c25662..4ff28a1df0e8 100644 --- a/include/samsung/misc.h +++ b/include/samsung/misc.h @@ -33,6 +33,7 @@ char *get_dfu_alt_system(char *interface, char *devstr); char *get_dfu_alt_boot(char *interface, char *devstr); #endif void set_board_type(void); +void set_board_revision(void); const char *get_board_type(void); #endif /* __SAMSUNG_MISC_COMMON_H__ */