#include "opt_platform.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
#include <sys/devmap.h>
#include <sys/lock.h>
#include <sys/reboot.h>
#include <vm/vm.h>
#include <machine/bus.h>
#include <machine/fdt.h>
#include <machine/intr.h>
#include <machine/machdep.h>
#include <machine/platformvar.h>
#include <dev/ofw/openfirm.h>
#include <arm/rockchip/rk32xx_mp.h>
#include "platform_if.h"
#define CRU_PHYSBASE 0xFF760000
#define CRU_SIZE 0x00010000
#define CRU_GLB_SRST_FST_VALUE 0x1B0
static platform_def_t rk3288w_platform;
static void
rk32xx_late_init(platform_t plat)
{
}
static int
rk32xx_devmap_init(platform_t plat)
{
devmap_add_entry(0xFF000000, 0x00E00000);
return (0);
}
static void
rk32xx_cpu_reset(platform_t plat)
{
bus_space_handle_t cru;
printf("Resetting...\n");
bus_space_map(fdtbus_bs_tag, CRU_PHYSBASE, CRU_SIZE, 0, &cru);
spinlock_enter();
dsb();
bus_space_write_4(fdtbus_bs_tag, cru, CRU_GLB_SRST_FST_VALUE, 0xfdb9);
while(1)
;
}
#if 0
#ifdef EARLY_PRINTF
static void
rk32xx_early_putc(int c)
{
volatile uint32_t * UART_STAT_REG = (uint32_t *)(0x7009007C);
volatile uint32_t * UART_TX_REG = (uint32_t *)(0x70090000);
const uint32_t UART_TXRDY = (1 << 2);
while ((*UART_STAT_REG & UART_TXRDY) == 0)
continue;
*UART_TX_REG = c;
}
early_putc_t *early_putc = rk32xx_early_putc;
#endif
#endif
static platform_method_t rk32xx_methods[] = {
PLATFORMMETHOD(platform_devmap_init, rk32xx_devmap_init),
PLATFORMMETHOD(platform_late_init, rk32xx_late_init),
PLATFORMMETHOD(platform_cpu_reset, rk32xx_cpu_reset),
#ifdef SMP
PLATFORMMETHOD(platform_mp_start_ap, rk32xx_mp_start_ap),
PLATFORMMETHOD(platform_mp_setmaxid, rk32xx_mp_setmaxid),
#endif
PLATFORMMETHOD_END,
};
FDT_PLATFORM_DEF2(rk32xx, rk3288, "RK3288", 0, "rockchip,rk3288", 200);
FDT_PLATFORM_DEF2(rk32xx, rk3288w, "RK3288W", 0, "rockchip,rk3288w", 200);