From patchwork Thu Jun 18 15:39:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 11612793 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 74AE6138C for ; Thu, 18 Jun 2020 16:08:05 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5038820776 for ; Thu, 18 Jun 2020 16:08:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="nlYBWu4p"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amarulasolutions.com header.i=@amarulasolutions.com header.b="IYsmF42R" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5038820776 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=amarulasolutions.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=/Tc8AYbmycGq7ymLCmHdCbKdmuYwGqLewos+pdyeNNg=; b=nlYBWu4pL3sznr Vn7YuZAK9DhgCSgyy2s+lgNaMqcuOoQxdHeXUMIVVzAVLZJWuCS+bVk2NfTyGbQpr0Qi3TJD4bsZT HO8PY10ROhihumLZyE9XPjyyoSX4aBsUT9CHXSbbuwsS14ngK6vRv1WBrtilouvis+yHmKWb8neRL 85lmzH0fTFey7DoeLWw9HDB7r5vgmESVCHZFWgIJdsOHrWXeGaobDuoyN5xXPWP1vsL+2mmPK29eV /DFhp+YCRIXMPxZyekbHBG6DZhxPgqVpu76k7yofhGcA46p28WVt9IvxWgOzgU+drkKo3n4W/wQtZ Jv0URD71REb73eZ6ZoiQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jlx58-0000FI-8k; Thu, 18 Jun 2020 16:08:02 +0000 Received: from mail-pj1-x1044.google.com ([2607:f8b0:4864:20::1044]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jlx55-0000DU-Lv for linux-rockchip@lists.infradead.org; Thu, 18 Jun 2020 16:08:01 +0000 Received: by mail-pj1-x1044.google.com with SMTP id h95so2878024pje.4 for ; Thu, 18 Jun 2020 09:07:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EAnZQVPCbET9LiBd53nhS5d3NOeLarG2ciYDI0Pvwqo=; b=IYsmF42RgC5dlnCSchJGu/dsTvTpKeJNvEkfSL8+CCkNexXJ4eNGoU2i+V/nEuuYjp uE9eSfLpusAjEkdW8UCSVH/FoKpBIuIt2NV+e9s/ecn/cz1Dyxg3MmRFUAAf503pCcWj Ol4D8ybN996Qio2PJYP6hgITp1aCDBl9wWBQ0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=EAnZQVPCbET9LiBd53nhS5d3NOeLarG2ciYDI0Pvwqo=; b=Ulp0JkUkjo7zX4y9ErPBJVm22tTdnwZl2mzBng0pbuOzlCf8pK7t0LSf47qvRe9hCR URuUIrV5cOKGb1tQd+QGJLKo1ao0GpNVWCtERltya392IrLOOczxgPFpRyJD3apmayk6 9H5Fq6uDL0Xuf53cFDGnj5ZMJF4oP1Li3UTYzcD5Cl46onxor9Br7ih2+Vc6C9BQISVb glMtRSJevYWDgrO9Yc4Sbsl6dCWNgMlrdbNsD9yg036KwBwK7edPHOltvajG0R/czQl0 NiTLgS2nPg2e2s0g+Pg1nSz0gMyWEHPrO2iYpmPmk0SNjIXhgUdbw2DUheXGCXrosrqu z0fA== X-Gm-Message-State: AOAM531QHGLHPbU/hHjIF/67eVOip8wDg+aU3hNdaV9c0Xvu+wVVOgQF ZIdkSaLI8gHCitCzbkWPq0Yo+g== X-Google-Smtp-Source: ABdhPJytxK7jWMfvdzMmSa/ab42KvkivCoAIu0nyAktix3Z7EBddnwkuMLTr2NRBNSk6iFNCUobT6w== X-Received: by 2002:a17:902:7088:: with SMTP id z8mr4394536plk.320.1592496478973; Thu, 18 Jun 2020 09:07:58 -0700 (PDT) Received: from localhost.localdomain ([2405:201:c809:c7d5:b0c7:f192:869b:df87]) by smtp.gmail.com with ESMTPSA id u4sm3264943pfl.102.2020.06.18.09.07.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jun 2020 09:07:58 -0700 (PDT) From: Jagan Teki To: Kever Yang , Philipp Tomsich , Simon Glass Subject: [PATCH v4 1/5] rockchip: spl: Add spl_board_init Date: Thu, 18 Jun 2020 21:09:44 +0530 Message-Id: <20200618153948.218506-2-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200618153948.218506-1-jagan@amarulasolutions.com> References: <20200618153948.218506-1-jagan@amarulasolutions.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200618_090759_736742_39893098 X-CRM114-Status: GOOD ( 19.38 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:1044 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: U-Boot-Denx , linux-rockchip@lists.infradead.org, linux-amarula , Jagan Teki , Suniel Mahesh Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org spl_board_init is a proper location and common practice option to have a custom board initialization code after relocation in SPL. This patch add the feasibility to add the custom SPL board initzlaization throughout rockchip platforms and adjust existing the spl board code on respective boards. Signed-off-by: Jagan Teki --- Changes for v4: - new patch arch/arm/Kconfig | 1 + arch/arm/mach-rockchip/Kconfig | 2 - arch/arm/mach-rockchip/rk3188/rk3188.c | 2 +- arch/arm/mach-rockchip/rk3399/rk3399.c | 57 ----------------- arch/arm/mach-rockchip/spl.c | 10 +++ board/firefly/firefly-rk3288/firefly-rk3288.c | 2 +- board/phytec/phycore_rk3288/phycore-rk3288.c | 2 +- .../puma_rk3399/puma-rk3399.c | 61 +++++++++++++++++++ 8 files changed, 75 insertions(+), 62 deletions(-) diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index edc9e38c6c..57ddf15cb3 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -1679,6 +1679,7 @@ config ARCH_ROCKCHIP select ENABLE_ARM_SOC_BOOT0_HOOK select OF_CONTROL select SPI + select SPL_BOARD_INIT if SPL select SPL_DM if SPL select SYS_MALLOC_F select SYS_THUMB_BUILD if !ARM64 diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig index 0cb1f23d0f..b1008a5058 100644 --- a/arch/arm/mach-rockchip/Kconfig +++ b/arch/arm/mach-rockchip/Kconfig @@ -49,7 +49,6 @@ config ROCKCHIP_RK3128 config ROCKCHIP_RK3188 bool "Support Rockchip RK3188" select CPU_V7A - select SPL_BOARD_INIT if SPL select SUPPORT_SPL select SPL select SPL_CLK @@ -208,7 +207,6 @@ config ROCKCHIP_RK3399 select SPL select SPL_ATF select SPL_ATF_NO_PLATFORM_PARAM if SPL_ATF - select SPL_BOARD_INIT if SPL select SPL_LOAD_FIT select SPL_CLK if SPL select SPL_PINCTRL if SPL diff --git a/arch/arm/mach-rockchip/rk3188/rk3188.c b/arch/arm/mach-rockchip/rk3188/rk3188.c index ef57dfd761..0c0fe84ad5 100644 --- a/arch/arm/mach-rockchip/rk3188/rk3188.c +++ b/arch/arm/mach-rockchip/rk3188/rk3188.c @@ -111,7 +111,7 @@ static int setup_led(void) return 0; } -void spl_board_init(void) +void rk_spl_board_init(void) { int ret; diff --git a/arch/arm/mach-rockchip/rk3399/rk3399.c b/arch/arm/mach-rockchip/rk3399/rk3399.c index 4fda93b152..b53a111769 100644 --- a/arch/arm/mach-rockchip/rk3399/rk3399.c +++ b/arch/arm/mach-rockchip/rk3399/rk3399.c @@ -217,61 +217,4 @@ void spl_perform_fixups(struct spl_image_info *spl_image) "u-boot,spl-boot-device", boot_ofpath); } -#if defined(SPL_GPIO_SUPPORT) -static void rk3399_force_power_on_reset(void) -{ - ofnode node; - struct gpio_desc sysreset_gpio; - - debug("%s: trying to force a power-on reset\n", __func__); - - node = ofnode_path("/config"); - if (!ofnode_valid(node)) { - debug("%s: no /config node?\n", __func__); - return; - } - - if (gpio_request_by_name_nodev(node, "sysreset-gpio", 0, - &sysreset_gpio, GPIOD_IS_OUT)) { - debug("%s: could not find a /config/sysreset-gpio\n", __func__); - return; - } - - dm_gpio_set_value(&sysreset_gpio, 1); -} -#endif - -void spl_board_init(void) -{ -#if defined(SPL_GPIO_SUPPORT) - struct rockchip_cru *cru = rockchip_get_cru(); - - /* - * The RK3399 resets only 'almost all logic' (see also in the TRM - * "3.9.4 Global software reset"), when issuing a software reset. - * This may cause issues during boot-up for some configurations of - * the application software stack. - * - * To work around this, we test whether the last reset reason was - * a power-on reset and (if not) issue an overtemp-reset to reset - * the entire module. - * - * While this was previously fixed by modifying the various places - * that could generate a software reset (e.g. U-Boot's sysreset - * driver, the ATF or Linux), we now have it here to ensure that - * we no longer have to track this through the various components. - */ - if (cru->glb_rst_st != 0) - rk3399_force_power_on_reset(); -#endif - -#if defined(SPL_DM_REGULATOR) - /* - * Turning the eMMC and SPI back on (if disabled via the Qseven - * BIOS_ENABLE) signal is done through a always-on regulator). - */ - if (regulators_enable_boot_on(false)) - debug("%s: Cannot enable boot on regulator\n", __func__); -#endif -} #endif diff --git a/arch/arm/mach-rockchip/spl.c b/arch/arm/mach-rockchip/spl.c index cddf4fd3d5..d4c83a1119 100644 --- a/arch/arm/mach-rockchip/spl.c +++ b/arch/arm/mach-rockchip/spl.c @@ -150,6 +150,16 @@ void board_init_f(ulong dummy) preloader_console_init(); } +__weak void rk_spl_board_init(void) +{ +} + +void spl_board_init(void) +{ + /* board specific spl init */ + rk_spl_board_init(); +} + #ifdef CONFIG_SPL_LOAD_FIT int __weak board_fit_config_name_match(const char *name) { diff --git a/board/firefly/firefly-rk3288/firefly-rk3288.c b/board/firefly/firefly-rk3288/firefly-rk3288.c index 1965985a0f..96d44b1d9f 100644 --- a/board/firefly/firefly-rk3288/firefly-rk3288.c +++ b/board/firefly/firefly-rk3288/firefly-rk3288.c @@ -31,7 +31,7 @@ static int setup_led(void) return 0; } -void spl_board_init(void) +void rk_spl_board_init(void) { int ret; diff --git a/board/phytec/phycore_rk3288/phycore-rk3288.c b/board/phytec/phycore_rk3288/phycore-rk3288.c index ecc73227a0..b33070f62e 100644 --- a/board/phytec/phycore_rk3288/phycore-rk3288.c +++ b/board/phytec/phycore_rk3288/phycore-rk3288.c @@ -104,7 +104,7 @@ static int phycore_init(void) } #endif -void spl_board_init(void) +void rk_spl_board_init(void) { #if !defined(CONFIG_SPL_OF_PLATDATA) int ret; diff --git a/board/theobroma-systems/puma_rk3399/puma-rk3399.c b/board/theobroma-systems/puma_rk3399/puma-rk3399.c index deeba3084a..fd5cdd9ea1 100644 --- a/board/theobroma-systems/puma_rk3399/puma-rk3399.c +++ b/board/theobroma-systems/puma_rk3399/puma-rk3399.c @@ -152,3 +152,64 @@ void get_board_serial(struct tag_serialnr *serialnr) serialnr->low = (u32)(serial & 0xffffffff); } #endif + +#if defined(CONFIG_SPL_BUILD) + +#if defined(SPL_GPIO_SUPPORT) +static void rk3399_force_power_on_reset(void) +{ + ofnode node; + struct gpio_desc sysreset_gpio; + + debug("%s: trying to force a power-on reset\n", __func__); + + node = ofnode_path("/config"); + if (!ofnode_valid(node)) { + debug("%s: no /config node?\n", __func__); + return; + } + + if (gpio_request_by_name_nodev(node, "sysreset-gpio", 0, + &sysreset_gpio, GPIOD_IS_OUT)) { + debug("%s: could not find a /config/sysreset-gpio\n", __func__); + return; + } + + dm_gpio_set_value(&sysreset_gpio, 1); +} +#endif + +void rk_spl_board_init(void) +{ +#if defined(SPL_GPIO_SUPPORT) + struct rockchip_cru *cru = rockchip_get_cru(); + + /* + * The RK3399 resets only 'almost all logic' (see also in the TRM + * "3.9.4 Global software reset"), when issuing a software reset. + * This may cause issues during boot-up for some configurations of + * the application software stack. + * + * To work around this, we test whether the last reset reason was + * a power-on reset and (if not) issue an overtemp-reset to reset + * the entire module. + * + * While this was previously fixed by modifying the various places + * that could generate a software reset (e.g. U-Boot's sysreset + * driver, the ATF or Linux), we now have it here to ensure that + * we no longer have to track this through the various components. + */ + if (cru->glb_rst_st != 0) + rk3399_force_power_on_reset(); +#endif + +#if defined(SPL_DM_REGULATOR) + /* + * Turning the eMMC and SPI back on (if disabled via the Qseven + * BIOS_ENABLE) signal is done through a always-on regulator). + */ + if (regulators_enable_boot_on(false)) + debug("%s: Cannot enable boot on regulator\n", __func__); +#endif +} +#endif /* CONFIG_SPL_BUILD */ From patchwork Thu Jun 18 15:39:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 11612813 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7F2BF175D for ; Thu, 18 Jun 2020 16:08:11 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5D5A920776 for ; Thu, 18 Jun 2020 16:08:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="fD58X82K"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amarulasolutions.com header.i=@amarulasolutions.com header.b="CLJW58wU" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5D5A920776 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=amarulasolutions.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=/tOdEsqh4vWIIerts1PpFET40Er2KnoB0xRBfaxv0g4=; b=fD58X82K5mg8SN TkQ7S6WuKAb1732vXyg4XSxJRp1RM/wImo5Fi/b98p4ngS8H/2gH1zIEu81JvBtEfFyLCg4NzaqF1 uvI12kFRJf/sYMmNC69uXOPF/urKHH0g1REj96IcHE+7LB6mShb5oBiunyHXnJDCvvJxPFHKaxiR1 YNPzZvgOisI2t4XPdGoNCKoflFT0X/L3OID5i5PX6H/KCviqwwRk7NI/5Ia8ZmjAeZXpqcjA1EPSO +DLDgEGmkPzczeb8F0bAYGqH8TnUQFki88EQ0LzLHrfFWSQHfPyy0BH3+sJPx+eU2ZkUMiW+n0jPF Hjo8l6N454kXbP6ogA3g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jlx5D-0000IP-2y; Thu, 18 Jun 2020 16:08:07 +0000 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jlx59-0000Gk-Qq for linux-rockchip@lists.infradead.org; Thu, 18 Jun 2020 16:08:05 +0000 Received: by mail-pl1-x642.google.com with SMTP id v24so2615391plo.6 for ; Thu, 18 Jun 2020 09:08:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8sFgYtAh2b0Wohv3uaF5Qyt69kdsVZxcLGheuYLU8jY=; b=CLJW58wUdQ9cX2x6//WRzMUQKw87BP8bCFAC+UtrDcusYVavDEfW6ZAgZgVbyOv4cG po20i0OF0v5KMxOwwymCEx8zaOonmui7PkDy5D81vKyr3m4Vo3G9/WVOIUm6iaDNT6Ve 0DxVCQgIZlV3IKvgzymeinGjrMuwPmcCbSWPw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8sFgYtAh2b0Wohv3uaF5Qyt69kdsVZxcLGheuYLU8jY=; b=JP2CzyU2VupW5wFj5vBxlosqZsUh6ZWWFY3l+qR9/JvAUwYqlZM+hjigW2po8oxbR1 OEB0BaqaPBVgdMOq55kfzPY82yDGaxRyCTW2WeHdByanz23r/FR4bLodP8F8JGQQW6eJ UyW1evKpqw1PtWeCD2dVD3gRraO33xV8h2ZZd6wvML0xszGqM/X75rsxi/b28OENc8Ri /w3ht1RbBv9klfs1SjnaiWfWvnke+KJM9N7l6blBRYZoqpcQ7i0A2nVlTQqx3F09dapu QkrQklXVkbPn84tEevqL1J88SHOG15PWd8joCpWCmEVgcS5W3MRmq3d3ScB2kM0RXvnn 9cUg== X-Gm-Message-State: AOAM5307YjFxR5XJANUT0F/AOMOD5wqjSA2rqpcGOAxb79zoIG/Ox41L yvoOPqsRWql7tD98j3OSWjD/NQ== X-Google-Smtp-Source: ABdhPJyNaOqtpgacUTBxXtuk7d6u0lPY4DFww4TLwtCM1+qPYj/YE5W4CX/vrIc+/w+qayACut5lCA== X-Received: by 2002:a17:902:ea8a:: with SMTP id x10mr4325689plb.330.1592496483193; Thu, 18 Jun 2020 09:08:03 -0700 (PDT) Received: from localhost.localdomain ([2405:201:c809:c7d5:b0c7:f192:869b:df87]) by smtp.gmail.com with ESMTPSA id u4sm3264943pfl.102.2020.06.18.09.07.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jun 2020 09:08:02 -0700 (PDT) From: Jagan Teki To: Kever Yang , Philipp Tomsich , Simon Glass Subject: [PATCH v4 2/5] rk3399: spl: Print SPL banner after relocation Date: Thu, 18 Jun 2020 21:09:45 +0530 Message-Id: <20200618153948.218506-3-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200618153948.218506-1-jagan@amarulasolutions.com> References: <20200618153948.218506-1-jagan@amarulasolutions.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200618_090803_892274_29A3CC9C X-CRM114-Status: GOOD ( 11.53 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:642 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: U-Boot-Denx , linux-rockchip@lists.infradead.org, linux-amarula , Jagan Teki , Suniel Mahesh Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org Usually printing the SPL banner varies between architecture or board codes. - Some would print before relocation at the end board_init_f   for making sure all initialization prior to this would happen   properly. if at all there is a requirement for serial init,   that happens properly since it prints all after that. - Some would print after relocation at the spl_board_init for   making sure all initialization prior to relocation would happen properly. Also debug uart on these cases would be available before relocation. So debug support is available in before and after relocation. Rockchip SPL is following formar step to print the banner at the end of board_init_f. To support various custom use cases in SPL like leds, environment, board detections later options like printing the banner after relocation would be a better option. Printing banner would also help to support debugging availability between relocation codes, like debug uart available before relocation and banner availability after relation. By demonstrating all the above use cases, this patch is trying to print the SPL banner after relocation. Signed-off-by: Jagan Teki Tested-by: Suniel Mahesh --- Changes for v4: - none arch/arm/mach-rockchip/spl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-rockchip/spl.c b/arch/arm/mach-rockchip/spl.c index d4c83a1119..6d5c058548 100644 --- a/arch/arm/mach-rockchip/spl.c +++ b/arch/arm/mach-rockchip/spl.c @@ -147,7 +147,6 @@ void board_init_f(ulong dummy) gd->ram_top = gd->ram_base + get_effective_memsize(); gd->ram_top = board_get_usable_ram_top(gd->ram_size); #endif - preloader_console_init(); } __weak void rk_spl_board_init(void) @@ -158,6 +157,8 @@ void spl_board_init(void) { /* board specific spl init */ rk_spl_board_init(); + + preloader_console_init(); } #ifdef CONFIG_SPL_LOAD_FIT From patchwork Thu Jun 18 15:39:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 11612817 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3839014B7 for ; Thu, 18 Jun 2020 16:08:14 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 16A3720776 for ; Thu, 18 Jun 2020 16:08:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="mRFk1sKf"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amarulasolutions.com header.i=@amarulasolutions.com header.b="ZtGWj5LQ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 16A3720776 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=amarulasolutions.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=z27oEK5+htZp3HzhGHGCv+LX8I+g3qzih6AIe/W3zqU=; b=mRFk1sKfVYoO1b qU1cByLPIayIOK+7f3v2dJW3sSp+g/gNH/iI+kTEJbdKuUi2ZtboTLPuV0vDhyy/eshP2vWrsANBR XjX4MlUIdfppQV1vO8DEbc+6tdyTwcwEEgdvgClGXAYJbAWrLxJYIFrJT0VuQeRWn+qDUeVSEmqRL Yjj2hD+ftZ0KiIZDp5Pz3cE9xWJbKbr6mph07M/fWcBnihAlj6aR1hDdc4uMO5+rf1TOmDKpLeYEG eBkdHNJFIbtdBUNXq+hwNddTzqeBts8d66yMcEl6guN1B4Jnt84Q028BhAXMt/eelxL0jVP0HmcnQ QF0Tk3QuBtLGko1wdTdw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jlx5H-0000LR-7O; Thu, 18 Jun 2020 16:08:11 +0000 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jlx5E-0000JW-Au for linux-rockchip@lists.infradead.org; Thu, 18 Jun 2020 16:08:09 +0000 Received: by mail-pl1-x643.google.com with SMTP id y18so2619490plr.4 for ; Thu, 18 Jun 2020 09:08:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jSsm2gL9QZAY4GTGbTrZamobNQaqEtToYRe2AvoAmHk=; b=ZtGWj5LQZtFrknp6vQvog1NrauD/1enCKC5vqTsA1S6dZZSDDfe/NKj6egaS65QRTe CgoVUFVuPGGcikTtlW4zvsc+YQ9wHl3XzlEvgNF0le4sXr6uq3BVCX4wCJiAXu8Aikf9 W9q6fNnIYLQVKe8Hop26AWv0Z+nlDUuBpErkE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jSsm2gL9QZAY4GTGbTrZamobNQaqEtToYRe2AvoAmHk=; b=iQTPnqR2S88NqkyPF9fFz7lRyFaPD6ldfy65FtPpasAo7oURyQ6Y0Gl404d+anaceL y5E/+BUD15Ydb8r++NgDJHsHoO//mCLuPjXl559Eyhxk9+Z1T+mKKvMvOJinr6RTJCzF Rk3bEKX1gIjxsQyPHixKmPKSPpD1OQd5k8oEusoLCY2UMortuQpE9X9Is7mt+gHNfo9v 4jsQfKI+dD8Cw6dxldhiFSXaWpThQCVJt6uvngOPlbfwz1bh14RjaPSpP89wEv0XBISV 0fAbLbS1ehaOqE2SOfaVHfeJEnlKHRQfFaPJNZXCfYOdUvG0UAAqqjKf3fmKCNA3SfYs VjgQ== X-Gm-Message-State: AOAM532UkJkpjTbiZa77nJyg2yLamvKDzVF15sFutnwpFAahY3YEqFHL yWcgI77vSIQRI+GcLtAIda9euuprbHpIhQ== X-Google-Smtp-Source: ABdhPJzPZB2JA3GNdP8TP5tT5Ig/ENghF+1Rxvp8RBK8xGru+PsO4F4Uy3L4myDl8F9HXsufxcb0JQ== X-Received: by 2002:a17:90b:1009:: with SMTP id gm9mr5016843pjb.213.1592496487794; Thu, 18 Jun 2020 09:08:07 -0700 (PDT) Received: from localhost.localdomain ([2405:201:c809:c7d5:b0c7:f192:869b:df87]) by smtp.gmail.com with ESMTPSA id u4sm3264943pfl.102.2020.06.18.09.08.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jun 2020 09:08:07 -0700 (PDT) From: Jagan Teki To: Kever Yang , Philipp Tomsich , Simon Glass Subject: [PATCH v4 3/5] roc-rk3399-pc: Move leds setup in SPL Date: Thu, 18 Jun 2020 21:09:46 +0530 Message-Id: <20200618153948.218506-4-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200618153948.218506-1-jagan@amarulasolutions.com> References: <20200618153948.218506-1-jagan@amarulasolutions.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200618_090808_384485_32151804 X-CRM114-Status: GOOD ( 13.14 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:643 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: U-Boot-Denx , linux-rockchip@lists.infradead.org, linux-amarula , Jagan Teki , Suniel Mahesh Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org roc-rk3399-pc has some specific requirements to support LEDS, environment. board detection and etc prior to U-Boot proper. So as of now SPL would be a better stage for these custom board requirements to support unlike TPL. Adding few of these custom requirements like LEDS in TPL would require extra code pulling and also the size of TPL can grow. So, this patch moves the leds code from TPL into SPL after relocation. Signed-off-by: Jagan Teki Tested-by: Suniel Mahesh --- Changes for v4: - none arch/arm/mach-rockchip/tpl.c | 7 ------- board/firefly/roc-pc-rk3399/Makefile | 4 ++++ board/firefly/roc-pc-rk3399/roc-pc-rk3399.c | 21 ------------------- board/firefly/roc-pc-rk3399/spl.c | 23 +++++++++++++++++++++ configs/roc-pc-mezzanine-rk3399_defconfig | 2 +- configs/roc-pc-rk3399_defconfig | 2 +- 6 files changed, 29 insertions(+), 30 deletions(-) create mode 100644 board/firefly/roc-pc-rk3399/spl.c diff --git a/arch/arm/mach-rockchip/tpl.c b/arch/arm/mach-rockchip/tpl.c index 88f80b05a9..cc908e1b0e 100644 --- a/arch/arm/mach-rockchip/tpl.c +++ b/arch/arm/mach-rockchip/tpl.c @@ -43,18 +43,11 @@ __weak void rockchip_stimer_init(void) TIMER_CONTROL_REG); } -__weak int board_early_init_f(void) -{ - return 0; -} - void board_init_f(ulong dummy) { struct udevice *dev; int ret; - board_early_init_f(); - #if defined(CONFIG_DEBUG_UART) && defined(CONFIG_TPL_SERIAL_SUPPORT) /* * Debug UART can be used from here if required: diff --git a/board/firefly/roc-pc-rk3399/Makefile b/board/firefly/roc-pc-rk3399/Makefile index 29c79b25d7..3a9c4c744d 100644 --- a/board/firefly/roc-pc-rk3399/Makefile +++ b/board/firefly/roc-pc-rk3399/Makefile @@ -4,4 +4,8 @@ # SPDX-License-Identifier: GPL-2.0+ # +ifdef CONFIG_SPL_BUILD +obj-y += spl.o +else obj-y += roc-pc-rk3399.o +endif diff --git a/board/firefly/roc-pc-rk3399/roc-pc-rk3399.c b/board/firefly/roc-pc-rk3399/roc-pc-rk3399.c index 7c3a803654..581cdcd3b0 100644 --- a/board/firefly/roc-pc-rk3399/roc-pc-rk3399.c +++ b/board/firefly/roc-pc-rk3399/roc-pc-rk3399.c @@ -6,13 +6,8 @@ #include #include #include -#include #include -#include -#include -#include -#ifndef CONFIG_SPL_BUILD int board_early_init_f(void) { struct udevice *regulator; @@ -30,19 +25,3 @@ int board_early_init_f(void) out: return 0; } -#endif - -#if defined(CONFIG_TPL_BUILD) - -#define GPIO0_BASE 0xff720000 - -int board_early_init_f(void) -{ - struct rockchip_gpio_regs * const gpio0 = (void *)GPIO0_BASE; - - /* Turn on red LED, indicating full power mode */ - spl_gpio_output(gpio0, GPIO(BANK_B, 5), 1); - - return 0; -} -#endif diff --git a/board/firefly/roc-pc-rk3399/spl.c b/board/firefly/roc-pc-rk3399/spl.c new file mode 100644 index 0000000000..a7664c6b86 --- /dev/null +++ b/board/firefly/roc-pc-rk3399/spl.c @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (c) 2020 Amarula Solutions(India) + */ + +#include +#include +#include + +#define GPIO0_BASE 0xff720000 + +static void led_setup(void) +{ + struct rockchip_gpio_regs * const gpio0 = (void *)GPIO0_BASE; + + /* Turn on red LED, indicating full power mode */ + spl_gpio_output(gpio0, GPIO(BANK_B, 5), 1); +} + +void rk_spl_board_init(void) +{ + led_setup(); +} diff --git a/configs/roc-pc-mezzanine-rk3399_defconfig b/configs/roc-pc-mezzanine-rk3399_defconfig index 595f052cb7..060b4bfecf 100644 --- a/configs/roc-pc-mezzanine-rk3399_defconfig +++ b/configs/roc-pc-mezzanine-rk3399_defconfig @@ -1,6 +1,7 @@ CONFIG_ARM=y CONFIG_ARCH_ROCKCHIP=y CONFIG_SYS_TEXT_BASE=0x00200000 +CONFIG_SPL_GPIO_SUPPORT=y CONFIG_ENV_SIZE=0x8000 CONFIG_ENV_OFFSET=0x3F8000 CONFIG_ENV_SECT_SIZE=0x1000 @@ -20,7 +21,6 @@ CONFIG_SPL_STACK_R=y CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x10000 CONFIG_SPL_SPI_LOAD=y CONFIG_TPL=y -CONFIG_TPL_GPIO_SUPPORT=y CONFIG_CMD_BOOTZ=y CONFIG_CMD_GPT=y CONFIG_CMD_MMC=y diff --git a/configs/roc-pc-rk3399_defconfig b/configs/roc-pc-rk3399_defconfig index 1c4db3443f..9897a52cd8 100644 --- a/configs/roc-pc-rk3399_defconfig +++ b/configs/roc-pc-rk3399_defconfig @@ -1,6 +1,7 @@ CONFIG_ARM=y CONFIG_ARCH_ROCKCHIP=y CONFIG_SYS_TEXT_BASE=0x00200000 +CONFIG_SPL_GPIO_SUPPORT=y CONFIG_ENV_SIZE=0x8000 CONFIG_ENV_OFFSET=0x3F8000 CONFIG_ENV_SECT_SIZE=0x1000 @@ -20,7 +21,6 @@ CONFIG_SPL_STACK_R=y CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x10000 CONFIG_SPL_SPI_LOAD=y CONFIG_TPL=y -CONFIG_TPL_GPIO_SUPPORT=y CONFIG_CMD_BOOTZ=y CONFIG_CMD_GPT=y CONFIG_CMD_MMC=y From patchwork Thu Jun 18 15:39:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 11612819 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 897F3912 for ; Thu, 18 Jun 2020 16:08:17 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6766420776 for ; Thu, 18 Jun 2020 16:08:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Ek7p2Zi6"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amarulasolutions.com header.i=@amarulasolutions.com header.b="dBUjzQQ0" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6766420776 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=amarulasolutions.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=gCBJvJos+2eR5acqyO2Gxe4x6cGGxK6SjoDqU3FAyeg=; b=Ek7p2Zi6kfin15 FLgQuxR9vmVFtyE0jGlRl+MGs9MP2ZV94taSCxq0CLuXgAELFOw6IIGw1Etu/chvAEInh92Gv4NgG 5xmXRJrXnWsAGWJSTf+9R1aRlOSACa9oZDt6vLZdhl0ECCW4CT6BfQ0ApOvTuhBAeRO4J0ni0QQtt X8th1UpxVjc4rf2YN7gIbbi7iOBVAh25BBa8GwUje59TuJ1/o1NTLypxiO8VN7PBe8oMchtlw+c/L K950lFWIErmkIsfH63Q2IZMbbTVuCBc6JCRWtmGYZTpZNEXBlGCG8qp5qZbaYLHSMAbF2WIc9AKPN xSItihZqljIqEbBYVs4w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jlx5K-0000O6-7g; Thu, 18 Jun 2020 16:08:14 +0000 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jlx5I-0000Me-81 for linux-rockchip@lists.infradead.org; Thu, 18 Jun 2020 16:08:13 +0000 Received: by mail-pl1-x642.google.com with SMTP id n9so2629623plk.1 for ; Thu, 18 Jun 2020 09:08:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=UJ44Kh57FeMHUsvOOPAvMrXRvlmf36r3Ig6kWg0HNps=; b=dBUjzQQ0MAqA+ytZdRDC1SS8v41DyrYhcpdsWfPTJPaSHAncoccxYLipM0t/GTrzzC L/w7TqgLN5xv47SwhKcsinRuvsi3t7LJSJi/mAxOR80eM42AH3h11LR+0Zjjv7Ll8swy MTI50Z7rPTkCZ66RYApEuZpLZcXPS/tAbvrL4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UJ44Kh57FeMHUsvOOPAvMrXRvlmf36r3Ig6kWg0HNps=; b=tKaNRwnBn5p1YlLLqm/80++tVo3EEVZfcdp+P4Jszjp1iBCDO2cf/bhxt3SeaQ1pux tvXktY5Kn7DMOkvQiGVYtDgZywT7JkhSajOKBZEI1U00BOPCK0zNMyYygeYuRblxqt6B D0YnSOTvJxbrbTqKJEVNqVQuKPqoEC8lPPBSidvLvokomfqF+dnlp11sPVlvauEemuG5 j0klZTv8N/g0lumWMDpSYCvoIlJQ+HOi4v0b6TA8eSnFgy4GH76q5PzgHU6nNKAD5fdD qvMFZPKdF0seA4yTobYz4jv/Dkb6MXOGW/yFUOLRX9o63njHcKTKPPuBJfR5+B896JBT uYIg== X-Gm-Message-State: AOAM5312JayCaERCXCwICgE9UjlsR6mZ5GcqNtGopPMvL2hOCLNlAU3L M7fPrE/A+zUyaV7erhQr/eP6eQ== X-Google-Smtp-Source: ABdhPJzmCr4Y8i7mBlMJ0jZTr52HYD8Q9vPJ87v0KcCfBHZdm2xaxrTAByb85M4vduBjvWl5SoEbZw== X-Received: by 2002:a17:90b:2308:: with SMTP id mt8mr4896758pjb.211.1592496491737; Thu, 18 Jun 2020 09:08:11 -0700 (PDT) Received: from localhost.localdomain ([2405:201:c809:c7d5:b0c7:f192:869b:df87]) by smtp.gmail.com with ESMTPSA id u4sm3264943pfl.102.2020.06.18.09.08.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jun 2020 09:08:11 -0700 (PDT) From: Jagan Teki To: Kever Yang , Philipp Tomsich , Simon Glass Subject: [PATCH v4 4/5] rockchip: Separate the reset cause from display cpuinfo Date: Thu, 18 Jun 2020 21:09:47 +0530 Message-Id: <20200618153948.218506-5-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200618153948.218506-1-jagan@amarulasolutions.com> References: <20200618153948.218506-1-jagan@amarulasolutions.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200618_090812_285369_B7DE60D1 X-CRM114-Status: GOOD ( 13.71 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:642 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: U-Boot-Denx , linux-rockchip@lists.infradead.org, linux-amarula , Jagan Teki , Suniel Mahesh Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org reset cause is a generic functionality based on the soc cru registers in rockchip. This can be used for printing the cause of reset in cpuinfo or some other place where reset cause is needed.  Other than cpuinfo, reset cause can also be using during bootcount for checking the specific reset cause and glow the led based on the reset cause. So, let's separate the reset cause code from cpuinfo, and add a check to build it for rk3399, rk3288 since these two soc are supporting reset cause as of now. Signed-off-by: Jagan Teki Tested-by: Suniel Mahesh --- Changes for v4: - none arch/arm/include/asm/arch-rockchip/cru.h | 2 ++ arch/arm/mach-rockchip/Makefile | 5 ++++- arch/arm/mach-rockchip/cpu-info.c | 20 ++++++++++++-------- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/arch/arm/include/asm/arch-rockchip/cru.h b/arch/arm/include/asm/arch-rockchip/cru.h index 5eb17f9d55..317eb61049 100644 --- a/arch/arm/include/asm/arch-rockchip/cru.h +++ b/arch/arm/include/asm/arch-rockchip/cru.h @@ -31,4 +31,6 @@ enum { #define MHz 1000000 +char *get_reset_cause(void); + #endif /* _ROCKCHIP_CLOCK_H */ diff --git a/arch/arm/mach-rockchip/Makefile b/arch/arm/mach-rockchip/Makefile index 5b38526fe0..ef4898e00c 100644 --- a/arch/arm/mach-rockchip/Makefile +++ b/arch/arm/mach-rockchip/Makefile @@ -15,6 +15,10 @@ obj-tpl-$(CONFIG_ROCKCHIP_PX30) += px30-board-tpl.o obj-spl-$(CONFIG_ROCKCHIP_RK3036) += rk3036-board-spl.o +ifeq ($(CONFIG_ROCKCHIP_RK3288)$(CONFIG_ROCKCHIP_RK3399), y) +obj-y += cpu-info.o +endif + ifeq ($(CONFIG_SPL_BUILD)$(CONFIG_TPL_BUILD),) # Always include boot_mode.o, as we bypass it (i.e. turn it off) @@ -22,7 +26,6 @@ ifeq ($(CONFIG_SPL_BUILD)$(CONFIG_TPL_BUILD),) # we can have the preprocessor correctly recognise both 0x0 and 0 # meaning "turn it off". obj-y += boot_mode.o -obj-$(CONFIG_DISPLAY_CPUINFO) += cpu-info.o obj-$(CONFIG_ROCKCHIP_COMMON_BOARD) += board.o obj-$(CONFIG_MISC_INIT_R) += misc.o endif diff --git a/arch/arm/mach-rockchip/cpu-info.c b/arch/arm/mach-rockchip/cpu-info.c index 21ca9dedce..76a840e2c3 100644 --- a/arch/arm/mach-rockchip/cpu-info.c +++ b/arch/arm/mach-rockchip/cpu-info.c @@ -13,7 +13,7 @@ #include #include -static char *get_reset_cause(void) +char *get_reset_cause(void) { struct rockchip_cru *cru = rockchip_get_cru(); char *cause = NULL; @@ -41,12 +41,6 @@ static char *get_reset_cause(void) cause = "unknown reset"; } - /** - * reset_reason env is used by rk3288, due to special use case - * to figure it the boot behavior. so keep this as it is. - */ - env_set("reset_reason", cause); - /* * Clear glb_rst_st, so we can determine the last reset cause * for following resets. @@ -56,12 +50,22 @@ static char *get_reset_cause(void) return cause; } +#ifdef CONFIG_DISPLAY_CPUINFO int print_cpuinfo(void) { + char *cause = get_reset_cause(); + printf("SoC: Rockchip %s\n", CONFIG_SYS_SOC); - printf("Reset cause: %s\n", get_reset_cause()); + printf("Reset cause: %s\n", cause); + + /** + * reset_reason env is used by rk3288, due to special use case + * to figure it the boot behavior. so keep this as it is. + */ + env_set("reset_reason", cause); /* TODO print operating temparature and clock */ return 0; } +#endif From patchwork Thu Jun 18 15:39:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 11612821 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E01B7912 for ; Thu, 18 Jun 2020 16:08:22 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BE29620776 for ; Thu, 18 Jun 2020 16:08:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="gkC0scvr"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amarulasolutions.com header.i=@amarulasolutions.com header.b="W0hvtWN9" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BE29620776 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=amarulasolutions.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=2dPwuZ2LMBNZVi8gVndOEj1miBQ6OgSRSKbmAOyF49M=; b=gkC0scvrdauWCH mp4xubG1vYYFx1gn+nD70ECJV+YBEbcX/iQFNIeSWXcYEZMSRtHBKPs2uqdGcvRySMnBbL6J9nVsv z96MVpftwWhp8Py7NsvqiTNBfXN3OEBbvnz2EAaUb+GrARZq5W0QiZYCNASndHOog+irIILlhrDEV EPmeZW2I2qqG75pFoLcoqwo4Nam+HeNavTXDcpnJPm7MMBjuDbtcsMnoKDCoNgHRiCLqB2I+39oSQ GiFEGYvLRQ7lmCa3F8r5n2nBwiem0/zXDGA49cjFuLGHRagpXAMoHNj0WMmn4sOekAw2KR5vQWyIv iAqxbyzLTHyI2hI0Dk5w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jlx5Q-0000SK-1x; Thu, 18 Jun 2020 16:08:20 +0000 Received: from mail-pj1-x1042.google.com ([2607:f8b0:4864:20::1042]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jlx5M-0000QK-S1 for linux-rockchip@lists.infradead.org; Thu, 18 Jun 2020 16:08:18 +0000 Received: by mail-pj1-x1042.google.com with SMTP id jz3so2749214pjb.0 for ; Thu, 18 Jun 2020 09:08:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mNYUanoA/LbUwSUYp2wZmC9gOha0WbAjao5ZgQikr2M=; b=W0hvtWN9mgyoniye/nvyx8ActCUSCH8yS6vcU0KnTlZ/vTKwM66IvWUxLNKGR9I9wv E1+m3eCNCpv9n1YZjDgPdTp3YTaNMlXv1Uj8Ufb+89PTxXf6WRG7xfPHYufyTD/K72WW J4qD1EAEpgp/9hKYvXdEqD902UNVT+aAnWupw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mNYUanoA/LbUwSUYp2wZmC9gOha0WbAjao5ZgQikr2M=; b=KvdxjimMaoN0l9AJbyzXGyb187wuY4dNEyJRLqNHwoY0TJ5tSxNkf+3ZpyqPyGyIKV Wzt7h9VVsUTSXLeSVFlNlz+Od5E2zPJYPJHDN/9v7r50w58MsyUdkIzQaDLHZilKAvDv EIRZRYFwLbzC3WNiROvOx/f6mV9AbZtvAeaaUevA5v5hcID1XNEXMQX9hJsJcaUYnnyY 7JEQCMw9olKTsfR6FOa5Wvgqxo62Fvc+bPDimGn9i2cHmOT+hxoVh2Yd2Fe+Bhm2OCzu pbnRND9YQVd7+PYM4GrAOPL/GbVq8UTDl5NeWhQgOwijbxAuGNxUk7BcfgOsZAiJzyrL Vjuw== X-Gm-Message-State: AOAM532in1xiKIloWgn7YdgU4rNG3fVsTC8CvtujUcbRmokY7ouou9CB 0jC1WUqgtYltPRfLbpAY466MHA== X-Google-Smtp-Source: ABdhPJzsrh+P1yYUHPaBZeZ4jslJlN28hfslhJcxjL+rdG+0RyPW3aiW4RwMtmFyAgEth+Tm0ZmAow== X-Received: by 2002:a17:90b:1013:: with SMTP id gm19mr5002759pjb.231.1592496496134; Thu, 18 Jun 2020 09:08:16 -0700 (PDT) Received: from localhost.localdomain ([2405:201:c809:c7d5:b0c7:f192:869b:df87]) by smtp.gmail.com with ESMTPSA id u4sm3264943pfl.102.2020.06.18.09.08.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jun 2020 09:08:15 -0700 (PDT) From: Jagan Teki To: Kever Yang , Philipp Tomsich , Simon Glass Subject: [PATCH v4 5/5] roc-rk3399-pc: Set LED only during POR and pwr_key=y Date: Thu, 18 Jun 2020 21:09:48 +0530 Message-Id: <20200618153948.218506-6-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200618153948.218506-1-jagan@amarulasolutions.com> References: <20200618153948.218506-1-jagan@amarulasolutions.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200618_090816_908488_E986693D X-CRM114-Status: GOOD ( 12.70 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:1042 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: U-Boot-Denx , linux-rockchip@lists.infradead.org, linux-amarula , Jagan Teki , Suniel Mahesh Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org ROC-RK3399-PC has specific set of configurations for on-board led setup. Due to easiness for user to know the state of the board roc-rk339-pc board code will setup the low power led on/off, and waiting for user to press power key and then glow full power led. All this needs to happen only during power-on-reset not for soft reset or WDT. Also, it is not a proper usage to ask the user to press the Power key if the board connected remotely, so add the environment variable 'pwr_key' to check as well. So, user need to press Power key only - during POR - pwr_key=y Tested-by: Suniel Mahesh Signed-off-by: Jagan Teki --- Changes for v4: - none board/firefly/roc-pc-rk3399/spl.c | 35 ++++++++++++++++++++++- configs/roc-pc-mezzanine-rk3399_defconfig | 4 ++- configs/roc-pc-rk3399_defconfig | 4 ++- 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/board/firefly/roc-pc-rk3399/spl.c b/board/firefly/roc-pc-rk3399/spl.c index a7664c6b86..771a7fb2f2 100644 --- a/board/firefly/roc-pc-rk3399/spl.c +++ b/board/firefly/roc-pc-rk3399/spl.c @@ -4,16 +4,49 @@ */ #include +#include #include +#include +#include #include +#include +#define PMUGRF_BASE 0xff320000 #define GPIO0_BASE 0xff720000 +/** + * LED setup for roc-rk3399-pc + * + * 1. Set the low power leds (only during POR, pwr_key env is 'y') + * glow yellow LED, termed as low power + * poll for on board power key press + * once powe key pressed, turn off yellow + * 2. Turn on red LED, indicating full power mode + */ static void led_setup(void) { struct rockchip_gpio_regs * const gpio0 = (void *)GPIO0_BASE; + struct rk3399_pmugrf_regs * const pmugrf = (void *)PMUGRF_BASE; + bool press_pwr_key = false; + + if (IS_ENABLED(CONFIG_SPL_ENV_SUPPORT)) { + env_init(); + env_load(); + if (env_get_yesno("pwr_key") == 1) + press_pwr_key = true; + } + + if (press_pwr_key && !strcmp(get_reset_cause(), "POR")) { + spl_gpio_output(gpio0, GPIO(BANK_A, 2), 1); + + spl_gpio_set_pull(&pmugrf->gpio0_p, GPIO(BANK_A, 5), + GPIO_PULL_NORMAL); + while (readl(&gpio0->ext_port) & 0x20) + ; + + spl_gpio_output(gpio0, GPIO(BANK_A, 2), 0); + } - /* Turn on red LED, indicating full power mode */ spl_gpio_output(gpio0, GPIO(BANK_B, 5), 1); } diff --git a/configs/roc-pc-mezzanine-rk3399_defconfig b/configs/roc-pc-mezzanine-rk3399_defconfig index 060b4bfecf..7ca9fd0906 100644 --- a/configs/roc-pc-mezzanine-rk3399_defconfig +++ b/configs/roc-pc-mezzanine-rk3399_defconfig @@ -18,7 +18,8 @@ CONFIG_DEFAULT_FDT_FILE="rockchip/rk3399-roc-pc-mezzanine.dtb" CONFIG_DISPLAY_BOARDINFO_LATE=y # CONFIG_SPL_RAW_IMAGE_SUPPORT is not set CONFIG_SPL_STACK_R=y -CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x10000 +CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x20000 +CONFIG_SPL_ENV_SUPPORT=y CONFIG_SPL_SPI_LOAD=y CONFIG_TPL=y CONFIG_CMD_BOOTZ=y @@ -33,6 +34,7 @@ CONFIG_DEFAULT_DEVICE_TREE="rk3399-roc-pc-mezzanine" CONFIG_OF_SPL_REMOVE_PROPS="pinctrl-0 pinctrl-names clock-names interrupt-parent assigned-clocks assigned-clock-rates assigned-clock-parents" CONFIG_ENV_IS_IN_SPI_FLASH=y CONFIG_SYS_RELOC_GD_ENV_ADDR=y +CONFIG_SPL_DM_SEQ_ALIAS=y CONFIG_ROCKCHIP_GPIO=y CONFIG_SYS_I2C_ROCKCHIP=y CONFIG_MISC=y diff --git a/configs/roc-pc-rk3399_defconfig b/configs/roc-pc-rk3399_defconfig index 9897a52cd8..440c1ab303 100644 --- a/configs/roc-pc-rk3399_defconfig +++ b/configs/roc-pc-rk3399_defconfig @@ -18,7 +18,8 @@ CONFIG_DEFAULT_FDT_FILE="rockchip/rk3399-roc-pc.dtb" CONFIG_DISPLAY_BOARDINFO_LATE=y # CONFIG_SPL_RAW_IMAGE_SUPPORT is not set CONFIG_SPL_STACK_R=y -CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x10000 +CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x20000 +CONFIG_SPL_ENV_SUPPORT=y CONFIG_SPL_SPI_LOAD=y CONFIG_TPL=y CONFIG_CMD_BOOTZ=y @@ -32,6 +33,7 @@ CONFIG_DEFAULT_DEVICE_TREE="rk3399-roc-pc" CONFIG_OF_SPL_REMOVE_PROPS="pinctrl-0 pinctrl-names clock-names interrupt-parent assigned-clocks assigned-clock-rates assigned-clock-parents" CONFIG_ENV_IS_IN_SPI_FLASH=y CONFIG_SYS_RELOC_GD_ENV_ADDR=y +CONFIG_SPL_DM_SEQ_ALIAS=y CONFIG_ROCKCHIP_GPIO=y CONFIG_SYS_I2C_ROCKCHIP=y CONFIG_MISC=y