Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions arch/arm/dts/sc57x.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@
};

soc {
rcu: rcu@3108C000 {
compatible = "adi,reset-controller";
reg = <0x3108C000 0x1000>;
adi,sharc-min = <1>;
adi,sharc-max = <2>;
adi,enable-reboot;
status = "okay";
};

mmc: mmc0@31010000 {
compatible = "snps,dw-mshc";
reg = <0x31010000 0x400>;
Expand Down
4 changes: 2 additions & 2 deletions arch/arm/dts/sc58x.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
};

soc {
rcu: rcu@0x3108B000 {
rcu: rcu@3108B000 {
compatible = "adi,reset-controller";
reg = <0x3108B000 0x1000>;
adi,sharc-min = <1>;
adi,sharc-max = <2>;
adi,enable-reboot;
status = "disabled";
status = "okay";
};

mmc: mmc0@31010000 {
Expand Down
4 changes: 0 additions & 4 deletions arch/arm/dts/sc598-som.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,6 @@
reg-names = "cgu0", "cgu1", "cdu", "pll3";
};

&rcu {
status = "okay";
};

&uart0 {
clocks = <&clk ADSP_SC598_CLK_CGU0_SCLK0>;
};
Expand Down
5 changes: 3 additions & 2 deletions arch/arm/dts/sc59x.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@
};

soc {
rcu: rcu@0x3108C000 {
rcu: rcu@3108C000 {
compatible = "adi,reset-controller";
reg = <0x3108C000 0x1000>;
adi,sharc-min = <1>;
adi,sharc-max = <2>;
status = "disabled";
adi,enable-reboot;
status = "okay";
};

mdma: dma@0x310A7000 {
Expand Down
1 change: 0 additions & 1 deletion arch/arm/mach-sc5xx/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,3 @@ obj-$(CONFIG_SC59X_64) += sc59x_64.o
obj-$(CONFIG_SC59X_64) += sc59x_64-spl.o

obj-$(CONFIG_XPL_BUILD) += spl.o
obj-$(CONFIG_SYSCON) += rcu.o
21 changes: 0 additions & 21 deletions arch/arm/mach-sc5xx/rcu.c

This file was deleted.

2 changes: 2 additions & 0 deletions arch/arm/mach-sc5xx/soc.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,13 @@

DECLARE_GLOBAL_DATA_PTR;

#if !CONFIG_IS_ENABLED(SYSRESET)

Check warning on line 42 in arch/arm/mach-sc5xx/soc.c

View workflow job for this annotation

GitHub Actions / check / checks

checkpatch: Use 'if (IS_ENABLED(CONFIG...))' instead of '#if or #ifdef' where possible +#if !CONFIG_IS_ENABLED(SYSRESET)
void reset_cpu(void)
{
u32 val = readl(RCU0_CTL);
writel(val | 1, RCU0_CTL);
}
#endif

void enable_caches(void)
{
Expand Down
2 changes: 2 additions & 0 deletions configs/sc573-ezlite_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ CONFIG_SPECIFY_CONSOLE_INDEX=y
CONFIG_SPI=y
CONFIG_DM_SPI=y
CONFIG_ADI_SPI3=y
CONFIG_SYSRESET=y
CONFIG_SYSRESET_SC5XX=y
CONFIG_SPL_TIMER=y
CONFIG_USB=y
CONFIG_USB_MUSB_HOST=y
Expand Down
2 changes: 2 additions & 0 deletions configs/sc584-ezkit_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ CONFIG_SPECIFY_CONSOLE_INDEX=y
CONFIG_SPI=y
CONFIG_DM_SPI=y
CONFIG_ADI_SPI3=y
CONFIG_SYSRESET=y
CONFIG_SYSRESET_SC5XX=y
CONFIG_SPL_TIMER=y
CONFIG_USB=y
CONFIG_USB_MUSB_HOST=y
Expand Down
2 changes: 2 additions & 0 deletions configs/sc589-ezkit_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ CONFIG_SPECIFY_CONSOLE_INDEX=y
CONFIG_SPI=y
CONFIG_DM_SPI=y
CONFIG_ADI_SPI3=y
CONFIG_SYSRESET=y
CONFIG_SYSRESET_SC5XX=y
CONFIG_SPL_TIMER=y
CONFIG_USB=y
CONFIG_USB_MUSB_HOST=y
Expand Down
2 changes: 2 additions & 0 deletions configs/sc589-mini_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ CONFIG_SPECIFY_CONSOLE_INDEX=y
CONFIG_SPI=y
CONFIG_DM_SPI=y
CONFIG_ADI_SPI3=y
CONFIG_SYSRESET=y
CONFIG_SYSRESET_SC5XX=y
CONFIG_SPL_TIMER=y
CONFIG_USB=y
CONFIG_USB_MUSB_HOST=y
Expand Down
2 changes: 2 additions & 0 deletions configs/sc594-som-ezkit-spl_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ CONFIG_SPI=y
CONFIG_DM_SPI=y
CONFIG_ADI_SPI3=y
CONFIG_CADENCE_QSPI=y
CONFIG_SYSRESET=y
CONFIG_SYSRESET_SC5XX=y
CONFIG_SPL_TIMER=y
CONFIG_USB=y
CONFIG_USB_DWC2=y
Expand Down
2 changes: 2 additions & 0 deletions configs/sc594-som-ezlite-spl_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ CONFIG_SPI=y
CONFIG_DM_SPI=y
CONFIG_ADI_SPI3=y
CONFIG_CADENCE_QSPI=y
CONFIG_SYSRESET=y
CONFIG_SYSRESET_SC5XX=y
CONFIG_SPL_TIMER=y
CONFIG_USB=y
CONFIG_USB_DWC2=y
Expand Down
5 changes: 2 additions & 3 deletions configs/sc598-htol-spl_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ CONFIG_CMD_GPT=y
CONFIG_CMD_MMC=y
CONFIG_CMD_MTD=y
# CONFIG_CMD_PINMUX is not set
CONFIG_CMD_REMOTEPROC=y

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are we removing REMOTEPROC and CMD_REMOTEPROC here? thats unrelated to the reset fix. if qconfig flagged it because nothing selects it anymore thats fine but call it out in the commit message, otherwise it looks liek an accident.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are removed by qconfig. Honestly I don't know why they can be removed or why they were not removed yet. Maybe I put them back in this PR and remove them in another PR?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

qconfig removed CONFIG_CMD_REMOTEPROC since it can not be reachable within the current config. there is no CONFIG_SYSCON, which CONFIG_REMOTEPROC_ADI_SC5XX depends on. Also CONFIG_CMD_REMOTEPROC depends on REMOTEPROC which is selected by CONFIG_REMOTEPROC_ADI_SC5XX.

Just as an extra note, qconfig acutally build the configuration for the selected defconfigs. and then runs make savedefconfig. and savedefconfig actually removes the one that are unneccesary/non-reachable.

For your other PR, this information can be provided within the commit body, but mostly just saying syncing the configurations is enough.

See as an example: https://lore.kernel.org/u-boot/20260310115938.2902653-1-ozndrgt@gmail.com/

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it seems running qconfig is not a hard requirement. At least before this PR, it has not been run. Otherwise REMOTEPROC and CMD_REMOTEPROC should have been removed already. If running qconfig is required for all future PRs which touch defconfig files, I'd suggest use a separate PR to fix the differences from qconfig.

@ozan956 ozan956 Jun 1, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This runs occasionally in upstream. As I wrote above, the reason these are removed is because you removed SYSCON manually, before I asked you to run qconfig.

This 340fa41 is the last commit just before I asked you to run qconfig.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a bug in u-boot config system? If A depends on B and A is enabled but B is not, make config should report an error that A cannot be enabled since B is not enabled.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not think that this is a bug. A defconfig is not the final resolved config, it is only a set of requested options for that specific board. When dependencies are not satisfied, Kconfig resolves the final .config and savedefconfig drops options that are no longer reachable.

This is exactly why tools like qconfig exist, and why U-Boot provides ways to check and sync config files. They help catch cases where defconfig entries no longer match the resolved configuration.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But to get a resolved config, the config system drops a user requested config without telling user. This is dangerous. The config system should report the dependency cannot be satisfied instead.

CONFIG_CMD_SPI=y
CONFIG_DEFAULT_SPI_BUS=2
CONFIG_CMD_USB=y
Expand All @@ -68,7 +67,6 @@ CONFIG_NET_RETRY_COUNT=20
CONFIG_NETCONSOLE=y
CONFIG_IP_DEFRAG=y
CONFIG_REGMAP=y
CONFIG_SYSCON=y
CONFIG_DMA=y
CONFIG_DMA_CHANNELS=y
CONFIG_ADI_DMA=y
Expand Down Expand Up @@ -99,11 +97,12 @@ CONFIG_PINCTRL=y
# CONFIG_PINCTRL_GENERIC is not set
CONFIG_SPL_PINCTRL=y
# CONFIG_SPL_PINCTRL_GENERIC is not set
CONFIG_REMOTEPROC_ADI_SC5XX=y
CONFIG_SPI=y
CONFIG_DM_SPI=y
CONFIG_ADI_SPI3=y
CONFIG_CADENCE_QSPI=y
CONFIG_SYSRESET=y
CONFIG_SYSRESET_SC5XX=y
CONFIG_SPL_TIMER=y
CONFIG_USB=y
CONFIG_USB_DWC2=y
Expand Down
5 changes: 2 additions & 3 deletions configs/sc598-som-ezkit-spl_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ CONFIG_CMD_GPT=y
CONFIG_CMD_MMC=y
CONFIG_CMD_MTD=y
# CONFIG_CMD_PINMUX is not set
CONFIG_CMD_REMOTEPROC=y
CONFIG_CMD_SPI=y
CONFIG_DEFAULT_SPI_BUS=2
CONFIG_CMD_USB=y
Expand All @@ -67,7 +66,6 @@ CONFIG_NET_RETRY_COUNT=20
CONFIG_NETCONSOLE=y
CONFIG_IP_DEFRAG=y
CONFIG_REGMAP=y
CONFIG_SYSCON=y
CONFIG_DMA=y
CONFIG_DMA_CHANNELS=y
CONFIG_ADI_DMA=y
Expand Down Expand Up @@ -98,11 +96,12 @@ CONFIG_PINCTRL=y
# CONFIG_PINCTRL_GENERIC is not set
CONFIG_SPL_PINCTRL=y
# CONFIG_SPL_PINCTRL_GENERIC is not set
CONFIG_REMOTEPROC_ADI_SC5XX=y
CONFIG_SPI=y
CONFIG_DM_SPI=y
CONFIG_ADI_SPI3=y
CONFIG_CADENCE_QSPI=y
CONFIG_SYSRESET=y
CONFIG_SYSRESET_SC5XX=y
CONFIG_SPL_TIMER=y
CONFIG_USB=y
CONFIG_USB_DWC2=y
Expand Down
5 changes: 2 additions & 3 deletions configs/sc598-som-ezlite-spl_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ CONFIG_CMD_GPT=y
CONFIG_CMD_MMC=y
CONFIG_CMD_MTD=y
# CONFIG_CMD_PINMUX is not set
CONFIG_CMD_REMOTEPROC=y
CONFIG_CMD_SPI=y
CONFIG_DEFAULT_SPI_BUS=2
CONFIG_CMD_USB=y
Expand All @@ -66,7 +65,6 @@ CONFIG_NET_RETRY_COUNT=20
CONFIG_NETCONSOLE=y
CONFIG_IP_DEFRAG=y
CONFIG_REGMAP=y
CONFIG_SYSCON=y
CONFIG_DMA=y
CONFIG_DMA_CHANNELS=y
CONFIG_ADI_DMA=y
Expand Down Expand Up @@ -96,11 +94,12 @@ CONFIG_PINCTRL=y
# CONFIG_PINCTRL_GENERIC is not set
CONFIG_SPL_PINCTRL=y
# CONFIG_SPL_PINCTRL_GENERIC is not set
CONFIG_REMOTEPROC_ADI_SC5XX=y
CONFIG_SPI=y
CONFIG_DM_SPI=y
CONFIG_ADI_SPI3=y
CONFIG_CADENCE_QSPI=y
CONFIG_SYSRESET=y
CONFIG_SYSRESET_SC5XX=y
CONFIG_SPL_TIMER=y
CONFIG_USB=y
CONFIG_USB_DWC2=y
Expand Down
11 changes: 11 additions & 0 deletions drivers/mtd/spi/sf_probe.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,17 @@
struct spi_flash *flash = dev_get_uclass_priv(dev);
int ret;

#if !CONFIG_IS_ENABLED(SPI_FLASH_TINY)

Check warning on line 227 in drivers/mtd/spi/sf_probe.c

View workflow job for this annotation

GitHub Actions / check / checks

checkpatch: Use 'if (IS_ENABLED(CONFIG...))' instead of '#if or #ifdef' where possible +#if !CONFIG_IS_ENABLED(SPI_FLASH_TINY)
if (flash->addr_width == 4 &&
!(flash->info->flags & SPI_NOR_OCTAL_DTR_READ) &&
(JEDEC_MFR(flash->info) != SNOR_MFR_SPANSION) &&
!(flash->flags & SPI_NOR_4B_OPCODES)) {
ret = spi_nor_set_4byte(flash, flash->info, 0);
if (ret)
return ret;
}
#endif

if (CONFIG_IS_ENABLED(SPI_DIRMAP)) {
spi_mem_dirmap_destroy(flash->dirmap.wdesc);
spi_mem_dirmap_destroy(flash->dirmap.rdesc);
Expand Down
15 changes: 10 additions & 5 deletions drivers/mtd/spi/spi-nor-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -742,8 +742,7 @@ static void spi_nor_set_4byte_opcodes(struct spi_nor *nor,
#endif /* !CONFIG_IS_ENABLED(SPI_FLASH_BAR) */

/* Enable/disable 4-byte addressing mode. */
static int set_4byte(struct spi_nor *nor, const struct flash_info *info,
int enable)
int spi_nor_set_4byte(struct spi_nor *nor, const struct flash_info *info, int enable)
{
int status;
bool need_wren = false;
Expand All @@ -767,11 +766,17 @@ static int set_4byte(struct spi_nor *nor, const struct flash_info *info,
write_disable(nor);

if (!status && !enable &&
JEDEC_MFR(info) == SNOR_MFR_WINBOND) {
(JEDEC_MFR(info) == SNOR_MFR_WINBOND ||
JEDEC_MFR(info) == SNOR_MFR_ISSI)) {
/*
* On Winbond W25Q256FV, leaving 4byte mode causes
* the Extended Address Register to be set to 1, so all
* 3-byte-address reads come from the second 16M.
*
* On IS25LP01G (and similar ISSI parts), EX4B alone does
* not reliably exit 4-byte address mode; the Extended
* Address Register EXTADD bit (bit 7) stays set.
*
* We must clear the register to enable normal behavior.
*/
write_enable(nor);
Expand Down Expand Up @@ -3898,7 +3903,7 @@ static int s25_s28_post_bfpt_fixup(struct spi_nor *nor,
*/
if (params->size > SZ_128M) {
if (bfpt->dwords[BFPT_DWORD(16)] & BFPT_DWORD16_EX4B_PWRCYC) {
ret = set_4byte(nor, nor->info, 1);
ret = spi_nor_set_4byte(nor, nor->info, 1);
if (ret)
return ret;
}
Expand Down Expand Up @@ -4347,7 +4352,7 @@ static int spi_nor_init(struct spi_nor *nor)
*/
if (nor->flags & SNOR_F_BROKEN_RESET)
debug("enabling reset hack; may not recover from unexpected reboots\n");
set_4byte(nor, nor->info, 1);
spi_nor_set_4byte(nor, nor->info, 1);
}

return 0;
Expand Down
7 changes: 7 additions & 0 deletions drivers/sysreset/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,13 @@ config SYSRESET_OCTEON
This enables the system reset driver support for Marvell Octeon
SoCs.

config SYSRESET_SC5XX
bool "Enable support for Analog Devices SC5xx System Reset"
depends on ARCH_SC5XX
help
Enable system reset support for Analog Devices SC5xx SoCs.
Uses the RCU (Reset Control Unit) SYSRST bit.

config SYSRESET_AT91
bool "Enable support for Microchip/Atmel reset driver"
depends on ARCH_AT91
Expand Down
1 change: 1 addition & 0 deletions drivers/sysreset/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ obj-$(CONFIG_$(PHASE_)SYSRESET_MAX8907) += sysreset_max8907.o
obj-$(CONFIG_SYSRESET_MPC83XX) += sysreset_mpc83xx.o
obj-$(CONFIG_SYSRESET_MICROBLAZE) += sysreset_microblaze.o
obj-$(CONFIG_SYSRESET_OCTEON) += sysreset_octeon.o
obj-$(CONFIG_SYSRESET_SC5XX) += sysreset_sc5xx.o
obj-$(CONFIG_$(PHASE_)SYSRESET_PALMAS) += sysreset_palmas.o
obj-$(CONFIG_SYSRESET_PSCI) += sysreset_psci.o
obj-$(CONFIG_SYSRESET_SBI) += sysreset_sbi.o
Expand Down
10 changes: 10 additions & 0 deletions drivers/sysreset/sysreset-uclass.c

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is in the generic sysreset uclass so it hits every platform not just sc5xx. thats probably the right thing but worth flagging since its a behavioral change for all boards.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean by "flagging"?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sysreset-uclass is a broad reset thing. As I know all sysreset devices goes in there and for each of them it calls sysreset_request until one succeed. And in each trial we remove SPI flash. the problem is that with this change, every such trial now removes SPI flash device or devices before we even know whether the current sysreset driver will actually perform the reset.

plus, code continues toward reset regardless of whether the flash removal actually succeeded. the return value of device_remove is ignored

We can find a better approach to fix it I think. This one is like a SC5xx-specific workaround, not a generic sysreset concern. This logic/fix should live in the SC5xx reset driver itself or idk somewhere else.

@gmalysa gmalysa Jun 1, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with Ozan. I think the 3-byte vs. 4-byte default addressing issue is primarily a board design issue where our reset out line does not also trigger a flash reset (but on other boards from different mfgs I suspect this is the case, or the device is reset by the respective bootroms prior to access, etc.). I'm not sure what upstream would prefer but I think there are two ways to deal with it:

  1. Define sysreset handler for the RCU as you've done, as a driver. Then, create another one for the board that is higher priority, which will call exit 4-byte mode. Uboot doesn't have reset priorities the way Linux does though, so this is brittle at best.
  2. Suggest/introduce board_reset as a function hidden behind a Kconfig with an empty weak default if selected (much like other board_ functions). Modify sysreset_walk to start with a call to board_reset if enabled. This would provide deterministic sequencing and ensure exit 4-byte mode happens only once. There is a small existing board_reset that is tied to specific arch or cpu choices used by xtensa, m68k, and one powerpc cpu. You could unify those in the process and migrate that out of the arch-specific code.

I think based on the way uboot traditionally does things, removing all/any drivers before boot or reboot automatically is unlikely to be accepted. I would prefer to do option 2, as it is a bit cleaner in my mind and has a hierarchy between things the driver requires (spi flash does not itself require removal), things the cpu arch requires (arm64 doesn't require it), things our SoC requires (the sc5xx chips do not strictly require that it be reset they only require that it be in the right mode at boot), and things our board requires (it does not trigger a chip reset in another way so in software we need to manually reset it first).

This raises another question: what happens if there is a watchdog reset? That cannot be defended against in software unless the chip is always kept in 3 byte mode outside of a transaction. It seems the actual best solution is option 3, a new revision of the SOM-CRR which wires appropriate board-level resets and associated software configuration to ensure the RCU drives the reset out line when any reset event happens, but this is probably hard to arrange.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking a look @gmalysa!

I'm tempted to say that since we'll want to remove U-Boot Proper (except possibly for a special debug image) that this won't be an issue if we only use SPL. Additionally, it seems like all boards where 4-byte addressing should be used should have the boot ROM configured correctly using the OTP. And on top of that, as Greg suggests, this may be impacted by board design. Those combined with the fact that this issue has likely persisted for a very long time without it being reported mean that any fix should be very simple.

Let's discuss further on the call on Thursday.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we close this issue with won't fix?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw, I agree that this is a hardware issue. The real fix should be in hardware. But this is a quite common issue. You can find the same issue happened to boards from other vendors. Linux has done the same thing since 2017. I chose the fix in this PR so it can benefit all boards.

The return value from device_remove does not matter when doing reset. User already wants to reset the system, we can expect that something bad already happened. We just do what we can to help the reset happen. Trying to remove SPI flash multiple times should also be OK. It does no harm.

Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright (C) 2015 Google, Inc
Expand Down Expand Up @@ -26,9 +26,19 @@
{
struct sysreset_ops *ops = sysreset_get_ops(dev);

struct udevice *flash;
struct uclass *uc;

if (!ops->request)
return -ENOSYS;

/*
* Remove SPI flash devices before reset so they can exit 4-byte
* addressing mode.
*/
uclass_id_foreach_dev(UCLASS_SPI_FLASH, flash, uc)
device_remove(flash, DM_REMOVE_NORMAL);

return ops->request(dev, type);
}

Expand Down
48 changes: 48 additions & 0 deletions drivers/sysreset/sysreset_sc5xx.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* (C) Copyright 2026 - Analog Devices, Inc.
*/

#include <dm.h>
#include <sysreset.h>
#include <asm/io.h>

struct sc5xx_sysreset_priv {
void __iomem *rcu;
};

static int sc5xx_sysreset_request(struct udevice *dev, enum sysreset_t type)
{
struct sc5xx_sysreset_priv *priv = dev_get_priv(dev);

writel(readl(priv->rcu) | 1, priv->rcu);
return -EINPROGRESS;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: other sysreset drivers return -EPROTONOSUPPORT for types they cant handle (like SYSRESET_POWER_OFF). doesnt matter much in practice since the uclass retries with the next driver, but might be worth a one-liner switch to be consistent. up to you if you want to bother.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! I will fix it. Thanks.

}

static int sc5xx_sysreset_probe(struct udevice *dev)
{
struct sc5xx_sysreset_priv *priv = dev_get_priv(dev);

priv->rcu = dev_remap_addr(dev);
if (!priv->rcu)
return -EINVAL;
return 0;
}

static const struct udevice_id sc5xx_sysreset_ids[] = {
{ .compatible = "adi,reset-controller" },
{ }
};

static struct sysreset_ops sc5xx_sysreset_ops = {
.request = sc5xx_sysreset_request,
};

U_BOOT_DRIVER(sysreset_sc5xx) = {
.name = "sc5xx_sysreset",
.id = UCLASS_SYSRESET,
.of_match = sc5xx_sysreset_ids,
.ops = &sc5xx_sysreset_ops,
.probe = sc5xx_sysreset_probe,
.priv_auto = sizeof(struct sc5xx_sysreset_priv),
};
Loading
Loading