From: "Bernhard Messerklinger" <bernhard.messerklinger@br-automation.com>
To: u-boot@lists.denx.de
Cc: "Bernhard Messerklinger"
<bernhard.messerklinger@br-automation.com>,
"Tom Rini" <trini@konsulko.com>,
"Wolfgang Wallner" <wolfgang.wallner@br-automation.com>
Subject: [PATCH v4 3/4] board/BuR/common: split br_resetc_bmode function
Date: Fri, 4 Apr 2025 09:27:59 +0200 [thread overview]
Message-ID: <20250404072819.69642-4-bernhard.messerklinger@br-automation.com> (raw)
In-Reply-To: <20250404072819.69642-1-bernhard.messerklinger@br-automation.com>
Split br_resetc_bmode function to add support for reading of reset
reason in board code with br_resetc_bmode_get.
Signed-off-by: Bernhard Messerklinger <bernhard.messerklinger@br-automation.com>
---
(no changes since v1)
board/BuR/common/br_resetc.c | 129 ++++++++++++++++++++---------------
board/BuR/common/br_resetc.h | 1 +
2 files changed, 74 insertions(+), 56 deletions(-)
diff --git a/board/BuR/common/br_resetc.c b/board/BuR/common/br_resetc.c
index 248064f974b..dfe2c2e0155 100644
--- a/board/BuR/common/br_resetc.c
+++ b/board/BuR/common/br_resetc.c
@@ -114,9 +114,73 @@ int br_resetc_bmode(void)
{
int rc = 0;
u16 regw;
+ unsigned int bmode = 0;
+
+ if (!resetc.i2cdev)
+ rc = resetc_init();
+
+ if (rc != 0)
+ return rc;
+
+ board_boot_led(1);
+
+ rc = br_resetc_bmode_get(&bmode);
+ if (rc != 0)
+ return rc;
+
+ LCD_SETCURSOR(1, 8);
+
+ switch (bmode) {
+ case BMODE_PME:
+ LCD_PUTS("entering PME-Mode (netscript). ");
+ regw = 0x0C0C;
+ break;
+ case BMODE_DEFAULTAR:
+ LCD_PUTS("entering BOOT-mode. ");
+ regw = 0x0000;
+ break;
+ case BMODE_DIAG:
+ LCD_PUTS("entering DIAGNOSE-mode. ");
+ regw = 0x0F0F;
+ break;
+ case BMODE_SERVICE:
+ LCD_PUTS("entering SERVICE mode. ");
+ regw = 0xB4B4;
+ break;
+ case BMODE_RUN:
+ LCD_PUTS("loading OS... ");
+ regw = 0x0404;
+ break;
+ }
+
+ board_boot_led(0);
+
+ if (resetc.is_psoc)
+ rc = dm_i2c_write(resetc.i2cdev, RSTCTRL_SCRATCHREG0,
+ (u8 *)®w, 2);
+ else
+ rc = dm_i2c_write(resetc.i2cdev, RSTCTRL_SCRATCHREG0,
+ (u8 *)®w, 1);
+
+ if (rc != 0)
+ printf("WARN: cannot write into resetcontroller!\n");
+
+ if (resetc.is_psoc)
+ printf("Reset: PSOC controller\n");
+ else
+ printf("Reset: STM32 controller\n");
+
+ printf("Mode: %s\n", bootmodeascii[regw & 0x0F]);
+ env_set_ulong("b_mode", regw & 0x0F);
+
+ return rc;
+}
+
+int br_resetc_bmode_get(unsigned int *bmode)
+{
+ int rc = 0;
u8 regb, scr;
int cnt;
- unsigned int bmode = 0;
if (!resetc.i2cdev)
rc = resetc_init();
@@ -136,13 +200,11 @@ int br_resetc_bmode(void)
return -1;
}
- board_boot_led(1);
-
/* special bootmode from resetcontroller */
if (regb & 0x4) {
- bmode = BMODE_DIAG;
+ *bmode = BMODE_DIAG;
} else if (regb & 0x8) {
- bmode = BMODE_DEFAULTAR;
+ *bmode = BMODE_DEFAULTAR;
} else if (board_boot_key() != 0) {
cnt = 4;
do {
@@ -169,68 +231,23 @@ int br_resetc_bmode(void)
switch (cnt) {
case 0:
- bmode = BMODE_PME;
+ *bmode = BMODE_PME;
break;
case 1:
- bmode = BMODE_DEFAULTAR;
+ *bmode = BMODE_DEFAULTAR;
break;
case 2:
- bmode = BMODE_DIAG;
+ *bmode = BMODE_DIAG;
break;
case 3:
- bmode = BMODE_SERVICE;
+ *bmode = BMODE_SERVICE;
break;
}
} else if ((regb & 0x1) || scr == 0xCC) {
- bmode = BMODE_PME;
+ *bmode = BMODE_PME;
} else {
- bmode = BMODE_RUN;
+ *bmode = BMODE_RUN;
}
- LCD_SETCURSOR(1, 8);
-
- switch (bmode) {
- case BMODE_PME:
- LCD_PUTS("entering PME-Mode (netscript). ");
- regw = 0x0C0C;
- break;
- case BMODE_DEFAULTAR:
- LCD_PUTS("entering BOOT-mode. ");
- regw = 0x0000;
- break;
- case BMODE_DIAG:
- LCD_PUTS("entering DIAGNOSE-mode. ");
- regw = 0x0F0F;
- break;
- case BMODE_SERVICE:
- LCD_PUTS("entering SERVICE mode. ");
- regw = 0xB4B4;
- break;
- case BMODE_RUN:
- LCD_PUTS("loading OS... ");
- regw = 0x0404;
- break;
- }
-
- board_boot_led(0);
-
- if (resetc.is_psoc)
- rc = dm_i2c_write(resetc.i2cdev, RSTCTRL_SCRATCHREG0,
- (u8 *)®w, 2);
- else
- rc = dm_i2c_write(resetc.i2cdev, RSTCTRL_SCRATCHREG0,
- (u8 *)®w, 1);
-
- if (rc != 0)
- printf("WARN: cannot write into resetcontroller!\n");
-
- if (resetc.is_psoc)
- printf("Reset: PSOC controller\n");
- else
- printf("Reset: STM32 controller\n");
-
- printf("Mode: %s\n", bootmodeascii[regw & 0x0F]);
- env_set_ulong("b_mode", regw & 0x0F);
-
return rc;
}
diff --git a/board/BuR/common/br_resetc.h b/board/BuR/common/br_resetc.h
index 999045b867d..3bd5ac20ae1 100644
--- a/board/BuR/common/br_resetc.h
+++ b/board/BuR/common/br_resetc.h
@@ -11,6 +11,7 @@
int br_resetc_regget(u8 reg, u8 *dst);
int br_resetc_regset(u8 reg, u8 val);
int br_resetc_bmode(void);
+int br_resetc_bmode_get(unsigned int *bmode);
/* reset controller register defines */
#define RSTCTRL_CTRLREG 0x01
--
2.49.0
next prev parent reply other threads:[~2025-04-05 10:24 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-04 7:27 [PATCH v4 0/4] Add support for BR Xilinx Zynq boards in mainline U-Boot Bernhard Messerklinger
2025-04-04 7:27 ` [PATCH v4 1/4] board/BuR/common: use strlcpy instead of strncpy Bernhard Messerklinger
2025-04-04 7:27 ` [PATCH v4 2/4] board/BuR/common: add parameter for reset controller I2C bus selection Bernhard Messerklinger
2025-04-04 7:27 ` Bernhard Messerklinger [this message]
2025-04-04 7:28 ` [PATCH v4 4/4] board/BuR/zynq: initial commit Bernhard Messerklinger
2025-04-14 6:48 ` Michal Simek
2025-04-17 10:11 ` [PATCH v4 0/4] Add support for BR Xilinx Zynq boards in mainline U-Boot Michal Simek
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=20250404072819.69642-4-bernhard.messerklinger@br-automation.com \
--to=bernhard.messerklinger@br-automation.com \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
--cc=wolfgang.wallner@br-automation.com \
/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