105 lines
2.1 KiB
C
105 lines
2.1 KiB
C
/*
|
|
* Copyright (c) 2018 Western Digital Corporation or its affiliates.
|
|
*
|
|
* Authors:
|
|
* Anup Patel <anup.patel@wdc.com>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <sbi/riscv_encoding.h>
|
|
#include <sbi/sbi_const.h>
|
|
#include <sbi/sbi_platform.h>
|
|
#include <sbi/sbi_console.h>
|
|
#include <plat/irqchip/plic.h>
|
|
#include <plat/sys/clint.h>
|
|
#include "platform.h"
|
|
#include "uarths.h"
|
|
|
|
int k210_console_init(void)
|
|
{
|
|
uarths_init(115200, UARTHS_STOP_1);
|
|
|
|
return 0;
|
|
}
|
|
|
|
void k210_console_putc(char c)
|
|
{
|
|
uarths_putc(c);
|
|
}
|
|
|
|
static char k210_console_getc(void)
|
|
{
|
|
return uarths_getc();
|
|
}
|
|
|
|
static int k210_cold_irqchip_init(void)
|
|
{
|
|
return plic_cold_irqchip_init(PLIC_BASE_ADDR, PLIC_NUM_SOURCES,
|
|
PLAT_HART_COUNT);
|
|
}
|
|
|
|
static int k210_warm_irqchip_init(u32 core_id)
|
|
{
|
|
return plic_warm_irqchip_init(core_id);
|
|
}
|
|
|
|
static int k210_cold_ipi_init(void)
|
|
{
|
|
return clint_cold_ipi_init(CLINT_BASE_ADDR, PLAT_HART_COUNT);
|
|
}
|
|
|
|
static int k210_cold_timer_init(void)
|
|
{
|
|
return clint_cold_timer_init(CLINT_BASE_ADDR, PLAT_HART_COUNT);
|
|
}
|
|
|
|
static int k210_system_reboot(u32 type)
|
|
{
|
|
/* For now nothing to do. */
|
|
sbi_printf("System reboot\n");
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int k210_system_shutdown(u32 type)
|
|
{
|
|
/* For now nothing to do. */
|
|
sbi_printf("System shutdown\n");
|
|
|
|
return 0;
|
|
}
|
|
|
|
struct sbi_platform platform = {
|
|
|
|
.name = STRINGIFY(PLAT_NAME),
|
|
.features = SBI_PLATFORM_HAS_MMIO_TIMER_VALUE,
|
|
|
|
.hart_count = PLAT_HART_COUNT,
|
|
.hart_stack_size = PLAT_HART_STACK_SIZE,
|
|
|
|
.console_init = k210_console_init,
|
|
.console_putc = k210_console_putc,
|
|
.console_getc = k210_console_getc,
|
|
|
|
.cold_irqchip_init = k210_cold_irqchip_init,
|
|
.warm_irqchip_init = k210_warm_irqchip_init,
|
|
|
|
.cold_ipi_init = k210_cold_ipi_init,
|
|
.warm_ipi_init = clint_warm_ipi_init,
|
|
.ipi_inject = clint_ipi_inject,
|
|
.ipi_sync = clint_ipi_sync,
|
|
.ipi_clear = clint_ipi_clear,
|
|
|
|
.cold_timer_init = k210_cold_timer_init,
|
|
.timer_value = clint_timer_value,
|
|
.timer_event_stop = clint_timer_event_stop,
|
|
.timer_event_start = clint_timer_event_start,
|
|
.warm_timer_init = clint_warm_timer_init,
|
|
|
|
.cold_final_init = NULL,
|
|
|
|
.system_reboot = k210_system_reboot,
|
|
.system_shutdown = k210_system_shutdown
|
|
};
|