public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Jagan Teki <jagan@amarulasolutions.com>
To: u-boot@lists.denx.de
Subject: [PATCH v2 2/5] roc-rk3399-pc: Set low power leds, power key only if POR
Date: Thu, 19 Mar 2020 15:42:48 +0530	[thread overview]
Message-ID: <20200319101251.7354-2-jagan@amarulasolutions.com> (raw)
In-Reply-To: <20200319101251.7354-1-jagan@amarulasolutions.com>

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. So add reset cause check to POR
and configure the low power leds, power key only. Note
that the glowing red led is common across any reset.

Reported-by: Markus Reichl <m.reichl@fivetechno.de>
Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
Changes for v2:
- glow red led to common across reboots

 board/firefly/roc-pc-rk3399/roc-pc-rk3399.c | 24 ++++++++++++---------
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/board/firefly/roc-pc-rk3399/roc-pc-rk3399.c b/board/firefly/roc-pc-rk3399/roc-pc-rk3399.c
index de9185a7ce..6cc81952d8 100644
--- a/board/firefly/roc-pc-rk3399/roc-pc-rk3399.c
+++ b/board/firefly/roc-pc-rk3399/roc-pc-rk3399.c
@@ -33,6 +33,7 @@ out:
 #endif
 
 #if defined(CONFIG_TPL_BUILD)
+#include <asm/arch-rockchip/cru.h>
 
 #define PMUGRF_BASE     0xff320000
 #define GPIO0_BASE      0xff720000
@@ -42,18 +43,21 @@ int board_early_init_f(void)
 	struct rockchip_gpio_regs * const gpio0 = (void *)GPIO0_BASE;
 	struct rk3399_pmugrf_regs * const pmugrf = (void *)PMUGRF_BASE;
 
-	/**
-	 * 1. Glow yellow LED, termed as low power
-	 * 2. Poll for on board power key press
-	 * 3. Once 2 done, off yellow and glow red LED, termed as full power
-	 * 4. Continue booting...
-	 */
-	spl_gpio_output(gpio0, GPIO(BANK_A, 2), 1);
+	/* Set the low power leds, power key only during POR */
+	if (!strcmp(get_reset_cause(), "POR")) {
+		/* 1. Glow yellow LED, termed as low power */
+		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);
+		/* 2. Poll for on board power key press */
+		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);
+		/* 3. Once 2 done, turn off yellow */
+		spl_gpio_output(gpio0, GPIO(BANK_A, 2), 0);
+	}
+
+	 /* 4. Turn on red LED, termed as full power */
 	spl_gpio_output(gpio0, GPIO(BANK_B, 5), 1);
 
 	return 0;
-- 
2.17.1

  reply	other threads:[~2020-03-19 10:12 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-19 10:12 [PATCH v2 1/5] rockchip: Separate the reset cause from display cpuinfo Jagan Teki
2020-03-19 10:12 ` Jagan Teki [this message]
2020-03-26 17:02   ` [PATCH v2 2/5] roc-rk3399-pc: Set low power leds, power key only if POR Suniel Mahesh
2020-03-19 10:12 ` [PATCH v2 3/5] rockchip: tpl: Move board_early_init_f after cpu timer Jagan Teki
2020-03-26 17:03   ` Suniel Mahesh
2020-03-19 10:12 ` [PATCH v2 4/5] rockchip: tpl: Print TPL banner at end-of board_init_f Jagan Teki
2020-03-26 17:03   ` Suniel Mahesh
2020-03-19 10:12 ` [PATCH v2 5/5] rockchip: spl: Move board_early_init_f after cpu timer Jagan Teki
2020-03-26 17:04   ` Suniel Mahesh
2020-03-26 17:00 ` [PATCH v2 1/5] rockchip: Separate the reset cause from display cpuinfo Suniel Mahesh
2020-04-02 12:58 ` Kever Yang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200319101251.7354-2-jagan@amarulasolutions.com \
    --to=jagan@amarulasolutions.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox