From patchwork Wed May 8 08:08:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 393 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 505B03F066 for ; Wed, 8 May 2019 10:09:27 +0200 (CEST) Received: by mail-pf1-f198.google.com with SMTP id a17sf12129251pff.6 for ; Wed, 08 May 2019 01:09:27 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1557302966; cv=pass; d=google.com; s=arc-20160816; b=D5xY3Y/oilJ0Xw/XsYEiEFsuRXnI/4T+Bsha74mknCpkuvTcaM8J3FV0LUykEwqeW9 ZQL31eU/2CVnkuACfW3MQhAAtkooTAtFfeeOd5KYJIt3PqqqSVBDyVPo70pgqI0tAe4z 0EfMWpBLw8Fgtvrrfk7m39K9p27aXMfaljdFIjaZTiyZ/IJIN6Duxf72T6T97j9fkv0+ Z/S7xnMZQ4EKIEAqAfbmymlR/J3yD8+CC2Ty972gWin0VwJ/CUwHR6mMcPDjskW+tu2Z 7AgX34yB9VorxKa0UPRmMi2+rsZappJiCZF+oxkg0Sg08SOYuXXkEpaV87WNi8pyPAD0 xKyw== 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=9OVqmkvUz8mU7KYmujePoDaHdvHYE6+5rVrjqR+ZOz8=; b=kkZu+23NL7mrABwzwMfPnaeR6KYL2rihShPvoJJpeezdEKln0dV8IxL3GPavNa0hYg gFzdCXCHD3rqh1ol6lVKLuQ+6Rt2zgKpyF3yCgxQvU+xoEDhn2y/z6GHKAOmWB3ePr3v ToC5zXe3OLp5kBGO9AmDdsyh0xIOLFgcFXhEs0K6+LpcVLrlWJHfyHMNW5tKPQkE0Cwr hzCWaSXGH3wQDGbuBoMSLjNPCcM85WJUh3GL03F35wKAufrDmhhSLr4PCDhNaR4beM4g 5gLO1K9HjuxWCAYSzvTwTaueziizc0AkOiY6Nkd6Xp6mSTGuCinWrzCGQUht81uMiB2T xBgA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=YLTiAkpr; 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=9OVqmkvUz8mU7KYmujePoDaHdvHYE6+5rVrjqR+ZOz8=; b=ga6gaL6SMEAlGznNnxxCpWso0VUtLKAvucOaKuru8sRm96P4KTg5zhovBNp/sikLca 8tEf5N8Em7lvaLz+ZoK+ducMuNT2EtOcg0vqVu2de1VxwcvmKQpbaw/MceANWpMcZS/p kql4T3BnrO9vTHStv8Pp/FaZSCd1VwXKzQBxA= 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=9OVqmkvUz8mU7KYmujePoDaHdvHYE6+5rVrjqR+ZOz8=; b=bcShimZmoDO0DuACnGUKOLCtZMJ2rWJkgtT10ZGA0wYv2k9zuX3g3kKwF7y5sy/5zE kWScKA2/SZGHiypgZR0T9uX2FV52OUAeJUBEXT0S1CVZVTORLTvj5VXFX6iDb4yNocrh 5YpnDQwNj+J0d1KCuBBQ7Ft3i+pBUCDqxuI8O4t5I9ccqk6CvUHtlsMZgjn39L9odrWF EdqT0GRZBjK8+rq4M0PpviIhjLNpARuywx79PAhID6MUJTCjGC9DL1yj51cyvixRWz6I hsDX9FfOkUSpUe4CaRmnZANvdIguRj6kAJtzzM532gGFYeS6rOvZacn8HPI9PtrP6rAm iJYA== X-Gm-Message-State: APjAAAWR+lL1Az7wS0Py+XmZGp4xjgOtYZRU5VibQpHFI0HglUIx2eEq SPpzRic8FCP8P42Ktxs0Mt59Y2bz X-Google-Smtp-Source: APXvYqxsXEZ95CozZTFU5crfsbqueJiezh5GGlEwo+qaiLuKaLcXH5L29rZ6GDqJUW7z4xt4ffH17A== X-Received: by 2002:a62:4595:: with SMTP id n21mr47563485pfi.79.1557302966095; Wed, 08 May 2019 01:09:26 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a62:2010:: with SMTP id g16ls4167041pfg.0.gmail; Wed, 08 May 2019 01:09:25 -0700 (PDT) X-Received: by 2002:a63:fc08:: with SMTP id j8mr24080390pgi.432.1557302965729; Wed, 08 May 2019 01:09:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557302965; cv=none; d=google.com; s=arc-20160816; b=JgD9Ef8VNo9q7fdANkswc/EeLxa47XvoEp3IbPsKfgtnjlQ9gRrLCjiAQyODevaTuo 9PhN1YNVjGLT781y+8CFNLsWbJn7xKkPVDBuhR8h19Qj0vV8iHOGziRbouhqa6hBePN6 xTgBqtDDfCHw845W/fwq+sMJ9LPpe+goy9C5KE5u0n/+4IXb6y7QhFdu+WMECMUgayrV h2fN5J0TVr/bJamn6YHMar24aKiAoL/xtQ8+xVbdX6gumX8OLDUcc9r5AO4mpfg/zsMr AUy0vNZjOXbx+LS/dTNUPKqfw+PtFEh6ZZk7UfZFKrVlKFmG0t19z2F0cMtJP7TeIuAP ah+Q== 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=RvueV0PhNPrXDT5MSIPl8OymJ30H1R/wIrXqrTQfjlE=; b=M++NsfmEdeFMziOa5XaP8VToOc8oIsnysccdmm8zkUEn9MvTJlnWrrHrd16e6Ru/HI Q0XoXx5RPPOMPFpePjqmU8CqMK4uJrjvvPINwsNi0aPAHKDnlRQwTA3mxkc1cm+cm12k vKqceTLSLhXAskjOo+YOOC85v36KZTrIM4Hjf4I/ti/KMms93i37gBJpffwPFm1SsdVh rjXdFc2UhMsK10EZrXkeyop6F8hf+9q+AWhusFDZG9bNLsf+82FlARqLlo17e38qtBay HGIG+r9/Zp4LmQHGVFOwWdj7MGf9aw6r3/znFdzMAg7oPbW2FGd4a8lFHGtnCxTZg6TZ ea+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=YLTiAkpr; 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 u1sor12843483pgq.63.2019.05.08.01.09.25 for (Google Transport Security); Wed, 08 May 2019 01:09:25 -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:a65:5845:: with SMTP id s5mr26891500pgr.286.1557302965382; Wed, 08 May 2019 01:09:25 -0700 (PDT) Received: from localhost.localdomain ([115.97.185.144]) by smtp.gmail.com with ESMTPSA id j9sm33537133pfc.43.2019.05.08.01.09.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 May 2019 01:09:24 -0700 (PDT) From: Jagan Teki To: Simon Glass , Philipp Tomsich , Kever Yang , Akash Gajjar Cc: linux-rockchip@lists.infradead.org, linux-amarula@amarulasolutions.com, u-boot@lists.denx.de, Jagan Teki Subject: [PATCH 2/8] rockchip: rk3399: Support common spl_board_init Date: Wed, 8 May 2019 13:38:58 +0530 Message-Id: <20190508080904.1567-3-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.18.0.321.gffc6fa0e3 In-Reply-To: <20190508080904.1567-1-jagan@amarulasolutions.com> References: <20190508080904.1567-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=YLTiAkpr; 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 --- 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 6b492ebdb7..058acdfe39 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) @@ -204,6 +207,66 @@ void board_init_f(ulong dummy) #endif } +#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; -}