From patchwork Thu Jun 20 18:55:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 681 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id C52443F086 for ; Thu, 20 Jun 2019 20:55:28 +0200 (CEST) Received: by mail-pf1-f198.google.com with SMTP id h27sf2596228pfq.17 for ; Thu, 20 Jun 2019 11:55:28 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1561056926; cv=pass; d=google.com; s=arc-20160816; b=hWvnfN8fANHdOChhmJcJ2hqb3HoUuUiD22Q54rbiIwqLVGmY8Yd5zNJbBtYya9Dz3b uXTqqnYVKqY2wOmUNdEX9q4x9QIp1dx1AWdSAqOr+unXvnTc/JxmjAP6PeoEziFWbwBr NGDc4zRqgWfWwYEqvfyzPcd2sKMZPGcK/FLK6kUE4XMESR+FYpQlWa1of3gxrkaxEUcC HIy9MJ6T7S5M2LdUWauour+dscDVxwo+0qsOt2iu/+l7Id41EPoscG4BrX9W54A/2OZt 4i9HqDQVbw79Y0HKFLSDEqY6OLrHD0x4tY30cdxMUmmzCf3rdNH7i6cC7Y0T2C3XAJfZ jO7A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=igJZszPbKtHa61Qp/b12I1VBL+bVHLl/JJKIE4RZ4ME=; b=LQntWeEoug5+n60V6YXsJxc16ZUEV07Su3GNg9+4Bh891fc/qf08O4VdQKiNBCfxQx Brj+R1k91QTZlfIJT3BR3Ef6FaPPB4Lz2jC50RZgasbZokqki0M1It4GCS5u56UwAHrO PybB03EX3aOnBCB8r9trini8IJ+IG1JaOXIKvL7fzjY1oe3rr/3EF91Mr6NPvHksD/KZ ndXgqh2E4uQCv7GaM0SsxoA24Z4EmkIo1J5c4763dVuNPxhuGxjJE0+2sxR8Gkm30XEr igHv19U0Kl3KuEyTwarYYnreCz3dtSPkqmyZeDJ/NCDKOXEQ84DNzaQ4P5KYWlDQd8+j +XWw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=EZnVm6BN; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com 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:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=igJZszPbKtHa61Qp/b12I1VBL+bVHLl/JJKIE4RZ4ME=; b=i66uUQZ5E+Nv6W21tY5V8BO+H+Ka7dJ0tFs1+6w1fzhGy3wickc7403I5WdkjMNbZ1 Hax38dPIfGWTNP5o2PQNb1r0yE/RTGfZDXICnszrCVdqjrkY5r3Goe3jh/BFrdQrcBqY sU0sfEZmVIrjQRNa6RwOrVo7bvkvoQsP3R8Cs= 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:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=igJZszPbKtHa61Qp/b12I1VBL+bVHLl/JJKIE4RZ4ME=; b=X/dImSzyuW3BX4UoIDK0Vd4kC7aOWemx621diDrxBfRotj3cO9pEkN3W6HroMJ5zYY PGEdokUsDsJnu6S2/z0RcRpWIJYVFqho6NZR1wBxDbS0POQU5dqsz+/UfzzoKYFJy2Fg qdwIWLVebsySm4rL0E6ETJftWKVIc2JAB8T/IoMJHwd019QWOH8IkjeZ6RWjxBN5gLJi IdSU2AN95ZnLyBAmuDavTGG2gl4iVgPhZBSFvSdFEWUenVt/TyE9E1/go6MF88wKACV7 u8J4KYfIM98/IB60OZvSYSAd4o2KS20SBfMkDqwJEvsA/HX6J1A7rN9yPZH02RsNHS5e Pcug== X-Gm-Message-State: APjAAAUvguDVYkuPgivSVANw+NoX1C6ynihuycjEodpBbj1cT6sk4WxF Ov6XoUE22+gXwnZVMjgwb/b6MnOW X-Google-Smtp-Source: APXvYqwkObCd2JfRpsIYa6n6tnCFyi0PIxeM4sxiYHSucNm5T9kd1u/apzFMsKbDGDC35i6YYNskew== X-Received: by 2002:a17:902:324:: with SMTP id 33mr126451261pld.284.1561056926766; Thu, 20 Jun 2019 11:55:26 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:902:a986:: with SMTP id bh6ls1551576plb.8.gmail; Thu, 20 Jun 2019 11:55:26 -0700 (PDT) X-Received: by 2002:a17:902:29a7:: with SMTP id h36mr75707103plb.158.1561056926417; Thu, 20 Jun 2019 11:55:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561056926; cv=none; d=google.com; s=arc-20160816; b=dRzYoS2EIGlUH8z+jFnU8xb0tqKWcJWBG3DQJJEPQXgTKx9Ye0+p0CiEvcyONsrZpf DWVryOwWAMTs72CmaYVKjtidT195ZlsYGiJR5AqO8O+ewgFHHqLJXaXyqKEzDpX9iP5q PnH8A8Tqppib57kimZ7CEUez7qJe2HYssuebPWk2uKdLyDlyamQYk8E9EGrBFfQ5Le+U yorP2Yk7GeT2NgFFLj4R0CaePULivXE4QHeg41wNZSaR6XetK9MMyiYXKVA66bfNJ/MA imC4PR9SDGNQRFoefpSiHYKoTYMip3jX4NUxsKy+izXOL6vEZmdtDHDX1ZcqlUsQR5zS k0zg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=9wih55CXddiDKm5F7deTRcQNx2Iu0ElwljLUHTPsi0A=; b=ORPpY47z4c8xVQpWogEb6Cd77zz7+HYXHK6tYhwNQWDVyNTsb7X3YHCyo24X2I99Y8 NAgBnyFUQXm0LD/SR9Y3b7LHUboKsMDIa9tnLaE3RN3n1q8QeugsBRE/eRON1bbVC5Lt bDNygynkh3+l8PAq5sp7cQ/1DUKSYS/u0z5bPGdizzK4bujq0B7fJ2EGOl6KcB17Y4il chm2OarSinIUHMPLm07aGT3qY+tUNn/fhQvsLodm3yR2sZ0Xo00Zz+EASTz9JCJ7i1ca x14J2l4Z+WAIKv3rpwo23Qsbsoh8lrPGvnUVpEPHVYXSTAn64aS7lP1R9DckpbgGYl6G sHBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=EZnVm6BN; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id m12sor571230pgd.27.2019.06.20.11.55.26 for (Google Transport Security); Thu, 20 Jun 2019 11:55:26 -0700 (PDT) Received-SPF: pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; X-Received: by 2002:a63:231a:: with SMTP id j26mr13869497pgj.389.1561056925968; Thu, 20 Jun 2019 11:55:25 -0700 (PDT) Received: from localhost.localdomain ([183.82.225.128]) by smtp.gmail.com with ESMTPSA id k3sm372183pju.27.2019.06.20.11.55.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Jun 2019 11:55:25 -0700 (PDT) From: Jagan Teki To: Simon Glass , Philipp Tomsich , Kever Yang , u-boot@lists.denx.de Cc: linux-rockchip@lists.infradead.org, linux-amarula@amarulasolutions.com, Jagan Teki Subject: [PATCH v2 2/8] rockchip: rk3399: Support common spl_board_init Date: Fri, 21 Jun 2019 00:25:00 +0530 Message-Id: <20190620185506.11449-3-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.18.0.321.gffc6fa0e3 In-Reply-To: <20190620185506.11449-1-jagan@amarulasolutions.com> References: <20190620185506.11449-1-jagan@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: jagan@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=EZnVm6BN; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Support common spl_board_init by moving code from puma board file into, common rk3399-board-spl.c. Part of the code has sysreset-gpio, regulators_enable_boot_on but right now only puma board is using this with relevant config options rest remains common for all targets. Signed-off-by: Jagan Teki Reviewed-by: Kever Yang --- arch/arm/mach-rockchip/rk3399-board-spl.c | 63 +++++++++++++++++++ board/rockchip/evb_rk3399/evb-rk3399.c | 8 --- .../puma_rk3399/puma-rk3399.c | 58 ----------------- board/vamrs/rock960_rk3399/rock960-rk3399.c | 8 --- 4 files changed, 63 insertions(+), 74 deletions(-) diff --git a/arch/arm/mach-rockchip/rk3399-board-spl.c b/arch/arm/mach-rockchip/rk3399-board-spl.c index 800ca80022..65c98b697d 100644 --- a/arch/arm/mach-rockchip/rk3399-board-spl.c +++ b/arch/arm/mach-rockchip/rk3399-board-spl.c @@ -11,13 +11,16 @@ #include #include #include +#include #include #include #include +#include #include #include #include #include +#include #include void board_return_to_bootrom(void) @@ -202,6 +205,66 @@ void board_init_f(ulong dummy) } } +#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 rk3399_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 + + preloader_console_init(); +} + #ifdef CONFIG_SPL_LOAD_FIT int board_fit_config_name_match(const char *name) { diff --git a/board/rockchip/evb_rk3399/evb-rk3399.c b/board/rockchip/evb_rk3399/evb-rk3399.c index 769b5d146f..c600553ff6 100644 --- a/board/rockchip/evb_rk3399/evb-rk3399.c +++ b/board/rockchip/evb_rk3399/evb-rk3399.c @@ -8,7 +8,6 @@ #include #include #include -#include int board_init(void) { @@ -64,10 +63,3 @@ int board_init(void) out: return 0; } - -void spl_board_init(void) -{ - preloader_console_init(); - - return; -} diff --git a/board/theobroma-systems/puma_rk3399/puma-rk3399.c b/board/theobroma-systems/puma_rk3399/puma-rk3399.c index c6b509c109..251cd2d566 100644 --- a/board/theobroma-systems/puma_rk3399/puma-rk3399.c +++ b/board/theobroma-systems/puma_rk3399/puma-rk3399.c @@ -13,10 +13,8 @@ #include #include #include -#include #include #include -#include #include #include #include @@ -38,62 +36,6 @@ int board_init(void) return 0; } -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); -} - -void spl_board_init(void) -{ - int ret; - struct rk3399_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(); - - /* - * Turning the eMMC and SPI back on (if disabled via the Qseven - * BIOS_ENABLE) signal is done through a always-on regulator). - */ - ret = regulators_enable_boot_on(false); - if (ret) - debug("%s: Cannot enable boot on regulator\n", __func__); - - preloader_console_init(); -} - static void setup_macaddr(void) { #if CONFIG_IS_ENABLED(CMD_NET) diff --git a/board/vamrs/rock960_rk3399/rock960-rk3399.c b/board/vamrs/rock960_rk3399/rock960-rk3399.c index 018e4b55b8..2eb7120e84 100644 --- a/board/vamrs/rock960_rk3399/rock960-rk3399.c +++ b/board/vamrs/rock960_rk3399/rock960-rk3399.c @@ -6,7 +6,6 @@ #include #include #include -#include int board_init(void) { @@ -18,10 +17,3 @@ int board_init(void) return 0; } - -void spl_board_init(void) -{ - preloader_console_init(); - - return; -}