From: Yao Zi <me@ziyao.cc>
To: "João Paulo Gonçalves" <jpaulo.silvagoncalves@gmail.com>,
"Hiago De Franco" <hfranco@baylibre.com>
Cc: u-boot@lists.u-boot-project.org, Yao Zi <me@ziyao.cc>,
Tom Rini <trini@konsulko.com>, Simon Glass <sjg@chromium.org>,
Alper Nebi Yasak <alpernebiyasak@gmail.com>,
Marek Vasut <marex@nabladev.com>,
Tim Ouyang <tim609@andestech.com>,
Leo Liang <leo.liang@sifive.com>,
Kongyang Liu <seashell11234455@gmail.com>,
Neha Malcom Francis <n-francis@ti.com>, Bin Liu <b-liu@ti.com>,
Quentin Schulz <quentin.schulz@cherry.de>,
Andrei Lalaev <andrey.lalaev@gmail.com>,
Zhuxu Ran <zhuxu_ran@zohomail.com>, Udit Kumar <u-kumar1@ti.com>
Subject: Re: [PATCH 6/8] board: sophgo: milkv_duo: enable RTC power and reset
Date: Wed, 4 Nov 2026 03:59:13 +0000 [thread overview]
Message-ID: <auqtkRJmEyJqGhKF@pie> (raw)
In-Reply-To: <auoV_97xdZB8MLlU@jpg-duosnb>
On Tue, Nov 03, 2026 at 02:31:51PM -0300, João Paulo Gonçalves wrote:
> On Wed, Oct 21, 2026 at 09:54:22AM -0300, Hiago De Franco wrote:
> > Let the RTC power domain handle shutdown, warm reset, power-cycle and
> > watchdog reset requests, and stop the board from powering back on by
> > itself after a power off.
> >
> > Without this, the reset and poweroff paths are left in their BootROM
> > defaults, which do not match what the vendor FSBL configures.
> >
> > Signed-off-by: Hiago De Franco <hfranco@baylibre.com>
> > ---
> > board/sophgo/milkv_duo/spl.c | 53 +++++++++++++++++++++++++++++++++++++++++++-
> > 1 file changed, 52 insertions(+), 1 deletion(-)
> >
> > diff --git a/board/sophgo/milkv_duo/spl.c b/board/sophgo/milkv_duo/spl.c
> > index 8b2dc2756ae..97681e5a61b 100644
> > --- a/board/sophgo/milkv_duo/spl.c
> > +++ b/board/sophgo/milkv_duo/spl.c
> > @@ -2,7 +2,7 @@
> > /*
> > * Copyright (c) 2026, Hiago De Franco <hfranco@baylibre.com>
> > *
> > - * PLL setup based on the Sophgo FSBL (https://github.com/sophgo/fsbl),
> > + * PLL and RTC setup based on the Sophgo FSBL (https://github.com/sophgo/fsbl),
> > * plat/cv180x/platform.c.
> > */
> >
> > @@ -13,7 +13,9 @@
> > #include <hang.h>
> > #include <linux/bitops.h>
> > #include <linux/delay.h>
> > +#include <linux/iopoll.h>
> > #include <linux/kernel.h>
> > +#include <log.h>
> > #include <spl.h>
> > #include <spl_load.h>
> >
> > @@ -52,6 +54,25 @@
> > #define CLK_DIV(div, src) (((div) << 16) | ((src) << 8) | BIT(3) | BIT(0))
> > #define clkgen_reg(off) ((void __iomem *)(CLKGEN_BASE + (off)))
> >
> > +#define RTC_BASE 0x05026000UL
> > +#define RTC_EN_SHDN_REQ 0x0c0
> > +#define RTC_EN_PWR_CYC_REQ 0x0c8
> > +#define RTC_EN_WARM_RST_REQ 0x0cc
> > +#define RTC_EN_PWR_VBAT_DET 0x0d0
> > +#define RTC_EN_PWR_VBAT_DET_PWR_UP BIT(2)
> > +#define RTC_EN_WDT_RST_REQ 0x0e0
> > +#define RTC_CTRL_BASE 0x05025000UL
> > +#define RTC_CTRL0_UNLOCKKEY 0x004
> > +#define RTC_CTRL0_UNLOCKKEY_VAL 0xab18
> > +#define RTC_CTRL0 0x008
> > +#define RTC_CTRL0_WRITE_MASK GENMASK(31, 16)
> > +#define RTC_CTRL0_HW_WDG_RST_EN BIT(11)
> > +#define RTC_POR_RST_CTRL 0x0ac
> > +#define RTC_EN_REQ_TIMEOUT_US 100000
> > +
> > +#define rtc_reg(off) ((void __iomem *)(RTC_BASE + (off)))
> > +#define rtc_ctrl_reg(off) ((void __iomem *)(RTC_CTRL_BASE + (off)))
>
> Instead of hardcoding the bases here, could we get them from the DT? The
> upstream cv18xx.dtsi already has the RTC node (rtc@5025000, with
> "syscon" in its compatible), and its range covers both RTC_CTRL_BASE and
> RTC_BASE. Also, use syscon/regmap in SPL (CONFIG_SPL_SYSCON and
> CONFIG_SPL_REGMAP) to read/write the registers.
>
> Just a suggestion though, I'll leave it to the maintainers to decide.
I'll second the idea of handling RTC stuff in its driver, and I think it
doesn't even need being configured at the SPL stage, right?
...
> Best regards,
> João Paulo Gonçalves
Regards,
Yao Zi
next prev parent reply other threads:[~2026-11-04 3:59 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-21 12:54 [PATCH 0/8] riscv: sophgo: add SPL support for the Milk-V Duo Hiago De Franco
2026-10-21 12:54 ` [PATCH 1/8] binman: add Sophgo CV18xx FIP entry type Hiago De Franco
2026-11-03 14:54 ` Simon Glass
2026-10-21 12:54 ` [PATCH 2/8] riscv: cv1800b: add SPL support Hiago De Franco
2026-11-03 13:53 ` Yao Zi
2026-10-21 12:54 ` [PATCH 3/8] ram: sophgo: add CV180x DDR2 driver Hiago De Franco
2026-10-21 12:54 ` [PATCH 4/8] board: sophgo: milkv_duo: add SPL support Hiago De Franco
2026-11-04 3:56 ` Yao Zi
2026-10-21 12:54 ` [PATCH 5/8] board: sophgo: milkv_duo: initialize PLLs in SPL Hiago De Franco
2026-11-04 4:19 ` Yao Zi
2026-10-21 12:54 ` [PATCH 6/8] board: sophgo: milkv_duo: enable RTC power and reset Hiago De Franco
2026-11-03 17:31 ` João Paulo Gonçalves
2026-11-04 3:59 ` Yao Zi [this message]
2026-10-21 12:54 ` [PATCH 7/8] doc: board: sophgo: milkv_duo: update documentation Hiago De Franco
2026-10-21 12:54 ` [PATCH 8/8] doc: board: sophgo: milkv_duo: document the SPL boot flow Hiago De Franco
2026-10-25 17:33 ` [PATCH 0/8] riscv: sophgo: add SPL support for the Milk-V Duo Andrei Lalaev
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=auqtkRJmEyJqGhKF@pie \
--to=me@ziyao.cc \
--cc=alpernebiyasak@gmail.com \
--cc=andrey.lalaev@gmail.com \
--cc=b-liu@ti.com \
--cc=hfranco@baylibre.com \
--cc=jpaulo.silvagoncalves@gmail.com \
--cc=leo.liang@sifive.com \
--cc=marex@nabladev.com \
--cc=n-francis@ti.com \
--cc=quentin.schulz@cherry.de \
--cc=seashell11234455@gmail.com \
--cc=sjg@chromium.org \
--cc=tim609@andestech.com \
--cc=trini@konsulko.com \
--cc=u-boot@lists.u-boot-project.org \
--cc=u-kumar1@ti.com \
--cc=zhuxu_ran@zohomail.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