Skip to content

Commit

Permalink
reset: Remove addr parameter from reset_cpu()
Browse files Browse the repository at this point in the history
Historically, the reset_cpu() function had an `addr` parameter which was
meant to pass in an address of the reset vector location, where the CPU
should reset to.  This feature is no longer used anywhere in U-Boot as
all reset_cpu() implementations now ignore the passed value.  Generic
code has been added which always calls reset_cpu() with `0` which means
this feature can no longer be used easily anyway.

Over time, many implementations seem to have "misunderstood" the
existence of this parameter as a way to customize/parameterize the reset
(e.g.  COLD vs WARM resets).  As this is not properly supported, the
code will almost always not do what it is intended to (because all
call-sites just call reset_cpu() with 0).

To avoid confusion and to clean up the codebase from unused left-overs
of the past, remove the `addr` parameter entirely.  Code which intends
to support different kinds of resets should be rewritten as a sysreset
driver instead.

This transformation was done with the following coccinelle patch:

    @@
    expression argvalue;
    @@
    - reset_cpu(argvalue)
    + reset_cpu()

    @@
    identifier argname;
    type argtype;
    @@
    - reset_cpu(argtype argname)
    + reset_cpu(void)
    { ... }

Signed-off-by: Harald Seiler <[email protected]>
Reviewed-by: Simon Glass <[email protected]>
  • Loading branch information
Rahix authored and trini committed Mar 2, 2021
1 parent 3394f39 commit 35b65dd
Show file tree
Hide file tree
Showing 134 changed files with 142 additions and 142 deletions.
4 changes: 2 additions & 2 deletions arch/arc/lib/reset.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <common.h>
#include <cpu_func.h>

__weak void reset_cpu(ulong addr)
__weak void reset_cpu(void)
{
/* Stop debug session here */
__builtin_arc_brk();
Expand All @@ -17,7 +17,7 @@ int do_reset(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
{
printf("Resetting the board...\n");

reset_cpu(0);
reset_cpu();

return 0;
}
2 changes: 1 addition & 1 deletion arch/arm/cpu/arm920t/ep93xx/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include <asm/io.h>

/* We reset the CPU by generating a 1-->0 transition on DeviceCfg bit 31. */
extern void reset_cpu(ulong addr)
extern void reset_cpu(void)
{
struct syscon_regs *syscon = (struct syscon_regs *)SYSCON_BASE;
uint32_t value;
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/cpu/arm920t/imx/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ ulong get_tbclk(void)
/*
* Reset the cpu by setting up the watchdog timer and let him time out
*/
void reset_cpu(ulong ignored)
void reset_cpu(void)
{
/* Disable watchdog and set Time-Out field to 0 */
WCR = 0x00000000;
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/cpu/arm926ejs/armada100/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ int timer_init(void)
* 2. Write key value to TMP_WSAR reg.
* 3. Perform write operation.
*/
void reset_cpu(unsigned long ignored)
void reset_cpu(void)
{
struct armd1mpmu_registers *mpmu =
(struct armd1mpmu_registers *) ARMD1_MPMU_BASE;
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/cpu/arm926ejs/mx25/reset.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
/*
* Reset the cpu by setting up the watchdog timer and let it time out
*/
void reset_cpu(ulong ignored)
void reset_cpu(void)
{
struct wdog_regs *regs = (struct wdog_regs *)IMX_WDT_BASE;
/* Disable watchdog and set Time-Out field to 0 */
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/cpu/arm926ejs/mx27/reset.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
/*
* Reset the cpu by setting up the watchdog timer and let it time out
*/
void reset_cpu(ulong ignored)
void reset_cpu(void)
{
struct wdog_regs *regs = (struct wdog_regs *)IMX_WDT_BASE;
/* Disable watchdog and set Time-Out field to 0 */
Expand Down
4 changes: 2 additions & 2 deletions arch/arm/cpu/arm926ejs/mxs/mxs.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ DECLARE_GLOBAL_DATA_PTR;
/* Lowlevel init isn't used on i.MX28, so just have a dummy here */
__weak void lowlevel_init(void) {}

void reset_cpu(ulong ignored) __attribute__((noreturn));
void reset_cpu(void) __attribute__((noreturn));

void reset_cpu(ulong ignored)
void reset_cpu(void)
{
struct mxs_rtc_regs *rtc_regs =
(struct mxs_rtc_regs *)MXS_RTC_BASE;
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/cpu/arm926ejs/spear/reset.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <asm/arch/spr_syscntl.h>
#include <linux/delay.h>

void reset_cpu(ulong ignored)
void reset_cpu(void)
{
struct syscntl_regs *syscntl_regs_p =
(struct syscntl_regs *)CONFIG_SPEAR_SYSCNTLBASE;
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/cpu/arm946es/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ static void cache_flush (void)

#ifndef CONFIG_ARCH_INTEGRATOR

__attribute__((noreturn)) void reset_cpu(ulong addr __attribute__((unused)))
__attribute__((noreturn)) void reset_cpu(void)
{
writew(0x0, 0xfffece10);
writew(0x8, 0xfffece10);
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/cpu/armv7/bcm281xx/reset.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#define CLKS_SHIFT 20 /* Clock period shift */
#define LD_SHIFT 0 /* Reload value shift */

void reset_cpu(ulong ignored)
void reset_cpu(void)
{
/*
* Set WD enable, RST enable,
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/cpu/armv7/bcmcygnus/reset.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#define CRMU_MAIL_BOX1 0x03024028
#define CRMU_SOFT_RESET_CMD 0xFFFFFFFF

void reset_cpu(ulong ignored)
void reset_cpu(void)
{
/* Send soft reset command via Mailbox. */
writel(CRMU_SOFT_RESET_CMD, CRMU_MAIL_BOX1);
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/cpu/armv7/bcmnsp/reset.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#define CRU_RESET_OFFSET 0x1803F184

void reset_cpu(ulong ignored)
void reset_cpu(void)
{
/* Reset the cpu by setting software reset request bit */
writel(0x1, CRU_RESET_OFFSET);
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/cpu/armv7/ls102xa/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ void smp_kick_all_cpus(void)
}
#endif

void reset_cpu(ulong addr)
void reset_cpu(void)
{
struct watchdog_regs *wdog = (struct watchdog_regs *)WDOG1_BASE_ADDR;

Expand Down
2 changes: 1 addition & 1 deletion arch/arm/cpu/armv7/s5p4418/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ int print_cpuinfo(void)
}
#endif

void reset_cpu(ulong ignored)
void reset_cpu(void)
{
void *clkpwr_reg = (void *)PHY_BASEADDR_CLKPWR;
const u32 sw_rst_enb_bitpos = 3;
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/cpu/armv7/stv0991/reset.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <asm/io.h>
#include <asm/arch/stv0991_wdru.h>
#include <linux/delay.h>
void reset_cpu(ulong ignored)
void reset_cpu(void)
{
puts("System is going to reboot ...\n");
/*
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/cpu/armv7m/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ int cleanup_before_linux(void)
/*
* Perform the low-level reset.
*/
void reset_cpu(ulong addr)
void reset_cpu(void)
{
/*
* Perform reset but keep priority group unchanged.
Expand Down
4 changes: 2 additions & 2 deletions arch/arm/cpu/armv8/fsl-layerscape/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1231,7 +1231,7 @@ int timer_init(void)

__efi_runtime_data u32 __iomem *rstcr = (u32 *)CONFIG_SYS_FSL_RST_ADDR;

void __efi_runtime reset_cpu(ulong addr)
void __efi_runtime reset_cpu(void)
{
#if defined(CONFIG_ARCH_LX2160A) || defined(CONFIG_ARCH_LX2162A)
/* clear the RST_REQ_MSK and SW_RST_REQ */
Expand Down Expand Up @@ -1260,7 +1260,7 @@ void __efi_runtime EFIAPI efi_reset_system(
case EFI_RESET_COLD:
case EFI_RESET_WARM:
case EFI_RESET_PLATFORM_SPECIFIC:
reset_cpu(0);
reset_cpu();
break;
case EFI_RESET_SHUTDOWN:
/* Nothing we can do */
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/cpu/armv8/s32v234/generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ static char *get_reset_cause(void)

#define SRC_SCR_SW_RST (1<<12)

void reset_cpu(ulong addr)
void reset_cpu(void)
{
printf("Feature not supported.\n");
};
Expand Down
4 changes: 2 additions & 2 deletions arch/arm/cpu/pxa/pxa2xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,9 @@ void i2c_clk_enable(void)
writel(readl(CKEN) | CKEN14_I2C, CKEN);
}

void __attribute__((weak)) reset_cpu(ulong ignored) __attribute__((noreturn));
void __attribute__((weak)) reset_cpu(void) __attribute__((noreturn));

void reset_cpu(ulong ignored)
void reset_cpu(void)
{
uint32_t tmp;

Expand Down
2 changes: 1 addition & 1 deletion arch/arm/cpu/sa1100/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ static void cache_flush (void)
#define RSRR 0x00
#define RCSR 0x04

__attribute__((noreturn)) void reset_cpu(ulong addr __attribute__((unused)))
__attribute__((noreturn)) void reset_cpu(void)
{
/* repeat endlessly */
while (1) {
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/lib/interrupts.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ int disable_interrupts(void)
void bad_mode (void)
{
panic ("Resetting CPU ...\n");
reset_cpu(0);
reset_cpu();
}

static void show_efi_loaded_images(struct pt_regs *regs)
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/lib/interrupts_m.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void dump_regs(struct autosave_regs *regs)
void bad_mode(void)
{
panic("Resetting CPU ...\n");
reset_cpu(0);
reset_cpu();
}

void do_hard_fault(struct autosave_regs *autosave_regs)
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/lib/reset.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ int do_reset(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
disable_interrupts();

reset_misc();
reset_cpu(0);
reset_cpu();

/*NOTREACHED*/
return 0;
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-at91/arm920t/reset.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ void __attribute__((weak)) board_reset(void)
/* true empty function for defining weak symbol */
}

void reset_cpu(ulong ignored)
void reset_cpu(void)
{
at91_st_t *st = (at91_st_t *) ATMEL_BASE_ST;

Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-at91/arm926ejs/reset.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <asm/arch/at91_rstc.h>

/* Reset the cpu by telling the reset controller to do so */
void reset_cpu(ulong ignored)
void reset_cpu(void)
{
at91_rstc_t *rstc = (at91_rstc_t *) ATMEL_BASE_RSTC;

Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-at91/armv7/reset.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include <asm/arch/at91_rstc.h>

/* Reset the cpu by telling the reset controller to do so */
void reset_cpu(ulong ignored)
void reset_cpu(void)
{
at91_rstc_t *rstc = (at91_rstc_t *)ATMEL_BASE_RSTC;

Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-bcm283x/reset.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ __reset_cpu(struct bcm2835_wdog_regs *wdog_regs, ulong ticks)
writel(BCM2835_WDOG_PASSWORD | rstc, &wdog_regs->rstc);
}

void reset_cpu(ulong ticks)
void reset_cpu(void)
{
struct bcm2835_wdog_regs *regs =
(struct bcm2835_wdog_regs *)BCM2835_WDOG_PHYSADDR;
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-davinci/reset.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <asm/arch/timer_defs.h>
#include <asm/arch/hardware.h>

void reset_cpu(unsigned long a)
void reset_cpu(void)
{
struct davinci_timer *const wdttimer =
(struct davinci_timer *)DAVINCI_WDOG_BASE;
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-exynos/soc.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ extern void _main(void);
void *secondary_boot_addr = (void *)_main;
#endif /* CONFIG_TARGET_ESPRESSO7420 */

void reset_cpu(ulong addr)
void reset_cpu(void)
{
#ifdef CONFIG_CPU_V7A
writel(0x1, samsung_get_base_swreset());
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-imx/imx8m/soc.c
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,7 @@ int ft_system_setup(void *blob, struct bd_info *bd)
#endif

#if !CONFIG_IS_ENABLED(SYSRESET)
void reset_cpu(ulong addr)
void reset_cpu(void)
{
struct watchdog_regs *wdog = (struct watchdog_regs *)WDOG1_BASE_ADDR;

Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-imx/mx7ulp/soc.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ void s_init(void)
#endif

#ifndef CONFIG_ULP_WATCHDOG
void reset_cpu(ulong addr)
void reset_cpu(void)
{
setbits_le32(SIM0_RBASE, SIM_SOPT1_A7_SW_RESET);
while (1)
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-k3/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ int fdt_disable_node(void *blob, char *node_path)
#endif

#ifndef CONFIG_SYSRESET
void reset_cpu(ulong ignored)
void reset_cpu(void)
{
}
#endif
Expand Down
4 changes: 2 additions & 2 deletions arch/arm/mach-keystone/ddr3.c
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ void ddr3_check_ecc_int(u32 base)

if (!ecc_test) {
puts("Reseting the device ...\n");
reset_cpu(0);
reset_cpu();
}
}

Expand Down Expand Up @@ -445,7 +445,7 @@ void ddr3_err_reset_workaround(void)
tmp &= ~KS2_RSTYPE_PLL_SOFT;
__raw_writel(tmp, KS2_RSTCTRL_RSCFG);

reset_cpu(0);
reset_cpu();
}
}
#endif
2 changes: 1 addition & 1 deletion arch/arm/mach-keystone/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ int arch_cpu_init(void)
return 0;
}

void reset_cpu(ulong addr)
void reset_cpu(void)
{
volatile u32 *rstctrl = (volatile u32 *)(KS2_RSTCTRL);
u32 tmp;
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-kirkwood/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <asm/arch/soc.h>
#include <mvebu_mmc.h>

void reset_cpu(unsigned long ignored)
void reset_cpu(void)
{
struct kwcpu_registers *cpureg =
(struct kwcpu_registers *)KW_CPU_REG_BASE;
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-lpc32xx/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
static struct clk_pm_regs *clk = (struct clk_pm_regs *)CLK_PM_BASE;
static struct wdt_regs *wdt = (struct wdt_regs *)WDT_BASE;

void reset_cpu(ulong addr)
void reset_cpu(void)
{
/* Enable watchdog clock */
setbits_le32(&clk->timclk_ctrl, CLK_TIMCLK_WATCHDOG);
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-mediatek/mt7622/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ int dram_init(void)

}

void reset_cpu(ulong addr)
void reset_cpu(void)
{
psci_system_reset();
}
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-mediatek/mt8512/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ int dram_init_banksize(void)
return 0;
}

void reset_cpu(ulong addr)
void reset_cpu(void)
{
struct udevice *watchdog_dev = NULL;

Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-mediatek/mt8516/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ int mtk_soc_early_init(void)
return 0;
}

void reset_cpu(ulong addr)
void reset_cpu(void)
{
psci_system_reset();
}
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-mediatek/mt8518/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ int dram_init_banksize(void)
return 0;
}

void reset_cpu(ulong addr)
void reset_cpu(void)
{
psci_system_reset();
}
Expand Down
Loading

0 comments on commit 35b65dd

Please sign in to comment.