Files
opensbi/platform/kendryte/k210/platform.c
Anup Patel c1b6200653 lib: Simplify sbi_platform ipi_init() hooks
Instead of having separate ipi_init() hooks for cold and warm boot,
this patch updates struct sbi_platform to have just one ipi_init()
hook. The type of boot (cold or warm) is now a boolean flag parameter
for the updated ipi_init() hook.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
2018-12-27 09:35:09 +05:30

119 lines
2.2 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"
#define K210_UART_BAUDRATE 115200
int k210_console_init(void)
{
uarths_init(K210_UART_BAUDRATE, 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_irqchip_init(u32 hartid, bool cold_boot)
{
int rc;
if (cold_boot) {
rc = plic_cold_irqchip_init(PLIC_BASE_ADDR,
PLIC_NUM_SOURCES,
K210_HART_COUNT);
if (rc)
return rc;
}
return plic_warm_irqchip_init(hartid,
(2 * hartid),
(2 * hartid + 1));
}
static int k210_ipi_init(u32 hartid, bool cold_boot)
{
int rc;
if (cold_boot) {
rc = clint_cold_ipi_init(CLINT_BASE_ADDR,
K210_HART_COUNT);
if (rc)
return rc;
}
return clint_warm_ipi_init(hartid);
}
static int k210_cold_timer_init(void)
{
return clint_cold_timer_init(CLINT_BASE_ADDR, K210_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 = "Kendryte K210",
.features = SBI_PLATFORM_HAS_MMIO_TIMER_VALUE,
.hart_count = K210_HART_COUNT,
.hart_stack_size = K210_HART_STACK_SIZE,
.disabled_hart_mask = 0,
.console_init = k210_console_init,
.console_putc = k210_console_putc,
.console_getc = k210_console_getc,
.irqchip_init = k210_irqchip_init,
.ipi_init = k210_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,
.system_reboot = k210_system_reboot,
.system_shutdown = k210_system_shutdown
};