Move cpu_reset to be a platform method to allow multiple implementations.

Reviewed by:	mmel
Sponsored by:	ABT Systems Ltd
Differential Revision:	https://reviews.freebsd.org/D8010
This commit is contained in:
Andrew Turner 2016-09-23 13:08:15 +00:00
parent c35b5d8372
commit 0dbb8873c8
10 changed files with 50 additions and 24 deletions

View File

@ -146,8 +146,8 @@ allwinner_devmap_init(platform_t plat)
return (0);
}
void
cpu_reset()
static void
allwinner_cpu_reset(platform_t plat)
{
aw_wdog_watchdog_reset();
printf("Reset failed!\n");
@ -159,6 +159,7 @@ static platform_method_t a10_methods[] = {
PLATFORMMETHOD(platform_attach, a10_attach),
PLATFORMMETHOD(platform_lastaddr, allwinner_lastaddr),
PLATFORMMETHOD(platform_devmap_init, allwinner_devmap_init),
PLATFORMMETHOD(platform_cpu_reset, allwinner_cpu_reset),
PLATFORMMETHOD_END,
};
@ -170,6 +171,7 @@ static platform_method_t a13_methods[] = {
PLATFORMMETHOD(platform_attach, a13_attach),
PLATFORMMETHOD(platform_lastaddr, allwinner_lastaddr),
PLATFORMMETHOD(platform_devmap_init, allwinner_devmap_init),
PLATFORMMETHOD(platform_cpu_reset, allwinner_cpu_reset),
PLATFORMMETHOD_END,
};
@ -181,6 +183,7 @@ static platform_method_t a20_methods[] = {
PLATFORMMETHOD(platform_attach, a20_attach),
PLATFORMMETHOD(platform_lastaddr, allwinner_lastaddr),
PLATFORMMETHOD(platform_devmap_init, allwinner_devmap_init),
PLATFORMMETHOD(platform_cpu_reset, allwinner_cpu_reset),
#ifdef SMP
PLATFORMMETHOD(platform_mp_start_ap, aw_mp_start_ap),
@ -196,6 +199,7 @@ static platform_method_t a31_methods[] = {
PLATFORMMETHOD(platform_attach, a31_attach),
PLATFORMMETHOD(platform_lastaddr, allwinner_lastaddr),
PLATFORMMETHOD(platform_devmap_init, allwinner_devmap_init),
PLATFORMMETHOD(platform_cpu_reset, allwinner_cpu_reset),
#ifdef SMP
PLATFORMMETHOD(platform_mp_start_ap, aw_mp_start_ap),
@ -211,6 +215,7 @@ static platform_method_t a31s_methods[] = {
PLATFORMMETHOD(platform_attach, a31s_attach),
PLATFORMMETHOD(platform_lastaddr, allwinner_lastaddr),
PLATFORMMETHOD(platform_devmap_init, allwinner_devmap_init),
PLATFORMMETHOD(platform_cpu_reset, allwinner_cpu_reset),
#ifdef SMP
PLATFORMMETHOD(platform_mp_start_ap, aw_mp_start_ap),
@ -226,6 +231,7 @@ static platform_method_t a83t_methods[] = {
PLATFORMMETHOD(platform_attach, a83t_attach),
PLATFORMMETHOD(platform_lastaddr, allwinner_lastaddr),
PLATFORMMETHOD(platform_devmap_init, allwinner_devmap_init),
PLATFORMMETHOD(platform_cpu_reset, allwinner_cpu_reset),
#ifdef SMP
PLATFORMMETHOD(platform_mp_start_ap, a83t_mp_start_ap),
@ -241,6 +247,7 @@ static platform_method_t h3_methods[] = {
PLATFORMMETHOD(platform_attach, h3_attach),
PLATFORMMETHOD(platform_lastaddr, allwinner_lastaddr),
PLATFORMMETHOD(platform_devmap_init, allwinner_devmap_init),
PLATFORMMETHOD(platform_cpu_reset, allwinner_cpu_reset),
#ifdef SMP
PLATFORMMETHOD(platform_mp_start_ap, aw_mp_start_ap),

View File

@ -188,6 +188,20 @@ platform_late_init(void)
PLATFORM_LATE_INIT(plat_obj);
}
void
cpu_reset(void)
{
PLATFORM_CPU_RESET(plat_obj);
printf("cpu_reset failed");
intr_disable();
while(1) {
cpu_sleep(0);
}
}
#ifdef MULTIDELAY
static void
platform_delay(int usec, void *arg __unused)

View File

@ -133,3 +133,10 @@ METHOD void mp_setmaxid {
METHOD void mp_start_ap {
platform_t _plat;
};
/**
* @brief Called by cpu_reset to reboot.
*/
METHOD void cpu_reset {
platform_t _plat;
};

View File

@ -114,11 +114,10 @@ bcm2836_devmap_init(platform_t plat)
void
cpu_reset()
static void
bcm2835_cpu_reset(platform_t plat)
{
bcmwd_watchdog_reset();
while (1);
}
#ifdef SOC_BCM2835
@ -126,6 +125,7 @@ static platform_method_t bcm2835_methods[] = {
PLATFORMMETHOD(platform_devmap_init, bcm2835_devmap_init),
PLATFORMMETHOD(platform_lastaddr, bcm2835_lastaddr),
PLATFORMMETHOD(platform_late_init, bcm2835_late_init),
PLATFORMMETHOD(platform_cpu_reset, bcm2835_cpu_reset),
PLATFORMMETHOD_END,
};

View File

@ -81,8 +81,8 @@ imx51_devmap_init(platform_t plat)
return (0);
}
void
cpu_reset(void)
static void
imx51_cpu_reset(platform_t plat)
{
imx_wdog_cpu_reset(0x73F98000);
@ -97,6 +97,7 @@ static platform_method_t imx51_methods[] = {
PLATFORMMETHOD(platform_attach, imx51_attach),
PLATFORMMETHOD(platform_devmap_init, imx51_devmap_init),
PLATFORMMETHOD(platform_lastaddr, imx51_lastaddr),
PLATFORMMETHOD(platform_cpu_reset, imx51_cpu_reset),
PLATFORMMETHOD_END,
};

View File

@ -81,8 +81,8 @@ imx53_devmap_init(platform_t plat)
return (0);
}
void
cpu_reset(void)
static void
imx53_cpu_reset(platform_t plat)
{
imx_wdog_cpu_reset(0x53F98000);
@ -97,6 +97,7 @@ static platform_method_t imx53_methods[] = {
PLATFORMMETHOD(platform_attach, imx53_attach),
PLATFORMMETHOD(platform_devmap_init, imx53_devmap_init),
PLATFORMMETHOD(platform_lastaddr, imx53_lastaddr),
PLATFORMMETHOD(platform_cpu_reset, imx53_cpu_reset),
PLATFORMMETHOD_END,
};

View File

@ -227,8 +227,8 @@ imx6_devmap_init(platform_t plat)
return (0);
}
void
cpu_reset(void)
static void
imx6_cpu_reset(platform_t plat)
{
const uint32_t IMX6_WDOG_CR_PHYS = 0x020bc000;
@ -350,6 +350,7 @@ static platform_method_t imx6_methods[] = {
PLATFORMMETHOD(platform_lastaddr, imx6_lastaddr),
PLATFORMMETHOD(platform_devmap_init, imx6_devmap_init),
PLATFORMMETHOD(platform_late_init, imx6_late_init),
PLATFORMMETHOD(platform_cpu_reset, imx6_cpu_reset),
PLATFORMMETHOD_END,
};

View File

@ -97,8 +97,8 @@ tegra124_devmap_init(platform_t plat)
return (0);
}
void
cpu_reset(void)
static void
tegra124_cpu_reset(platform_t plat)
{
bus_space_handle_t pmc;
uint32_t reg;
@ -148,6 +148,8 @@ static platform_method_t tegra124_methods[] = {
PLATFORMMETHOD(platform_lastaddr, tegra124_lastaddr),
PLATFORMMETHOD(platform_devmap_init, tegra124_devmap_init),
PLATFORMMETHOD(platform_late_init, tegra124_late_init),
PLATFORMMETHOD(platform_cpu_reset, tegra124_cpu_reset),
#ifdef SMP
PLATFORMMETHOD(platform_mp_start_ap, tegra124_mp_start_ap),
PLATFORMMETHOD(platform_mp_setmaxid, tegra124_mp_setmaxid),

View File

@ -44,13 +44,6 @@ __FBSDID("$FreeBSD$");
#include "platform_if.h"
void
cpu_reset(void)
{
while (1);
}
static vm_offset_t
virt_lastaddr(platform_t plat)
{

View File

@ -95,21 +95,20 @@ ti_am335x_devmap_init(platform_t plat)
}
#endif
void
cpu_reset()
static void
ti_plat_cpu_reset(platform_t plat)
{
if (ti_cpu_reset)
(*ti_cpu_reset)();
else
printf("no cpu_reset implementation\n");
printf("Reset failed!\n");
while (1);
}
#if defined(SOC_OMAP4)
static platform_method_t omap4_methods[] = {
PLATFORMMETHOD(platform_devmap_init, ti_omap4_devmap_init),
PLATFORMMETHOD(platform_lastaddr, ti_lastaddr),
PLATFORMMETHOD(platform_cpu_reset, ti_plat_cpu_reset),
PLATFORMMETHOD_END,
};
@ -120,6 +119,7 @@ FDT_PLATFORM_DEF(omap4, "omap4", 0, "ti,omap4430", 0);
static platform_method_t am335x_methods[] = {
PLATFORMMETHOD(platform_devmap_init, ti_am335x_devmap_init),
PLATFORMMETHOD(platform_lastaddr, ti_lastaddr),
PLATFORMMETHOD(platform_cpu_reset, ti_plat_cpu_reset),
PLATFORMMETHOD_END,
};