Update Kendryte k210 support
Booting now. Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
This commit is contained in:
parent
d403c70fb1
commit
745ae45e65
|
@ -10,7 +10,7 @@
|
|||
# Essential defines required by SBI platform
|
||||
platform-cppflags-y = -DPLAT_NAME="Kendryte K210"
|
||||
platform-cppflags-y+= -DPLAT_HART_COUNT=2
|
||||
platform-cppflags-y+= -DPLAT_HART_STACK_SIZE=8192
|
||||
platform-cppflags-y+= -DPLAT_HART_STACK_SIZE=4096
|
||||
|
||||
# Compiler flags
|
||||
platform-cflags-y =-mabi=lp64 -march=rv64imafdc -mcmodel=medany
|
||||
|
@ -25,6 +25,6 @@ PLATFORM_SYS_CLINT=y
|
|||
FW_TEXT_START=0x80000000
|
||||
FW_JUMP=n
|
||||
FW_PAYLOAD=y
|
||||
FW_PAYLOAD_OFFSET=0x200000
|
||||
FW_PAYLOAD_FDT_ADDR=0x80040000
|
||||
FW_PAYLOAD_OFFSET=0x10000
|
||||
#FW_PAYLOAD_FDT_ADDR=0x80040000
|
||||
|
||||
|
|
|
@ -10,25 +10,20 @@
|
|||
#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_U_SYS_CLK 1000000000
|
||||
#define K210_U_PERIPH_CLK (K210_U_SYS_CLK / 2)
|
||||
|
||||
#define K210_U_PLIC_NUM_SOURCES 0x35
|
||||
#define K210_U_PLIC_NUM_PRIORITIES 7
|
||||
|
||||
static int k210_console_init(void)
|
||||
int k210_console_init(void)
|
||||
{
|
||||
uarths_init(115200, UARTHS_STOP_1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void k210_console_putc(char c)
|
||||
void k210_console_putc(char c)
|
||||
{
|
||||
uarths_putc(c);
|
||||
}
|
||||
|
@ -38,57 +33,40 @@ static char k210_console_getc(void)
|
|||
return uarths_getc();
|
||||
}
|
||||
|
||||
static u32 k210_pmp_region_count(u32 target_hart)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int k210_pmp_region_info(u32 target_hart, u32 index,
|
||||
ulong *prot, ulong *addr, ulong *log2size)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
*prot = PMP_R | PMP_W | PMP_X;
|
||||
*addr = 0;
|
||||
*log2size = __riscv_xlen;
|
||||
break;
|
||||
default:
|
||||
ret = -1;
|
||||
break;
|
||||
};
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int k210_cold_irqchip_init(void)
|
||||
{
|
||||
return plic_cold_irqchip_init(PLIC_BASE_ADDR,
|
||||
K210_U_PLIC_NUM_SOURCES,
|
||||
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);
|
||||
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);
|
||||
return clint_cold_timer_init(CLINT_BASE_ADDR, PLAT_HART_COUNT);
|
||||
}
|
||||
|
||||
static int k210_cold_final_init(void)
|
||||
{
|
||||
return plic_fdt_fixup(sbi_scratch_thishart_arg1_ptr(), "riscv,plic0");
|
||||
}
|
||||
|
||||
static int k210_system_down(u32 type)
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -100,29 +78,27 @@ struct sbi_platform platform = {
|
|||
.hart_count = PLAT_HART_COUNT,
|
||||
.hart_stack_size = PLAT_HART_STACK_SIZE,
|
||||
|
||||
.pmp_region_count = k210_pmp_region_count,
|
||||
.pmp_region_info = k210_pmp_region_info,
|
||||
|
||||
|
||||
.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 = plic_warm_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,
|
||||
.warm_ipi_init = clint_warm_ipi_init,
|
||||
.cold_ipi_init = k210_cold_ipi_init,
|
||||
.cold_final_init = k210_cold_final_init,
|
||||
|
||||
.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_timer_init = k210_cold_timer_init,
|
||||
|
||||
.system_reboot = k210_system_down,
|
||||
.system_shutdown = k210_system_down
|
||||
.cold_final_init = NULL,
|
||||
|
||||
.system_reboot = k210_system_reboot,
|
||||
.system_shutdown = k210_system_shutdown
|
||||
};
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -973,10 +973,12 @@ u32 sysctl_pll_get_freq(sysctl_pll_t pll)
|
|||
/*
|
||||
* Get final PLL output freq
|
||||
* FOUT = FIN / NR * NF / OD
|
||||
* = (FIN * NF) / (NR * OD)
|
||||
*/
|
||||
return (double)freq_in / (double)nr * (double)nf / (double)od;
|
||||
return ((u64)freq_in * (u64)nf) / ((u64)nr * (u64)od);
|
||||
}
|
||||
|
||||
#if 0
|
||||
static u32 sysctl_pll_source_set_freq(sysctl_pll_t pll,
|
||||
sysctl_clock_source_t source, u32 freq)
|
||||
{
|
||||
|
@ -1229,6 +1231,7 @@ static u32 sysctl_pll_source_set_freq(sysctl_pll_t pll,
|
|||
|
||||
return sysctl_pll_get_freq(pll);
|
||||
}
|
||||
#endif
|
||||
|
||||
u32 sysctl_clock_get_freq(sysctl_clock_t clock)
|
||||
{
|
||||
|
@ -1683,6 +1686,7 @@ void sysctl_set_power_mode(sysctl_power_bank_t power_bank, sysctl_io_power_mode_
|
|||
*((u32 *)(&sysctl->power_sel)) &= ~(1 << power_bank);
|
||||
}
|
||||
|
||||
#if 0
|
||||
u32 sysctl_pll_set_freq(sysctl_pll_t pll, u32 pll_freq)
|
||||
{
|
||||
u32 result;
|
||||
|
@ -1755,6 +1759,7 @@ u32 sysctl_cpu_set_freq(u32 freq)
|
|||
|
||||
return sysctl_pll_set_freq(SYSCTL_PLL0, (sysctl->clk_sel0.aclk_divider_sel + 1) * 2 * freq);
|
||||
}
|
||||
#endif
|
||||
|
||||
void sysctl_enable_irq(void)
|
||||
{
|
||||
|
|
|
@ -12,8 +12,8 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef _SYSCTL_H_
|
||||
#define _SYSCTL_H_
|
||||
#ifndef _K210_SYSCTL_H_
|
||||
#define _K210_SYSCTL_H_
|
||||
|
||||
#include <sbi/sbi_types.h>
|
||||
#include "platform.h"
|
||||
|
@ -942,4 +942,4 @@ u64 sysctl_get_time_us(void);
|
|||
|
||||
void sysctl_usleep(u64 usec);
|
||||
|
||||
#endif /* _SYSCTL_H_ */
|
||||
#endif /* _K210_SYSCTL_H_ */
|
||||
|
|
|
@ -31,9 +31,9 @@ void uarths_init(u32 baud_rate, enum uarths_stopbit stopbit)
|
|||
uarths->rxctrl.rxen = 1;
|
||||
uarths->txctrl.txcnt = 0;
|
||||
uarths->rxctrl.rxcnt = 0;
|
||||
uarths->ip.txwm = 0;
|
||||
uarths->ip.txwm = 1;
|
||||
uarths->ip.rxwm = 0;
|
||||
uarths->ie.txwm = 0;
|
||||
uarths->ie.txwm = 1;
|
||||
uarths->ie.rxwm = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -41,11 +41,13 @@
|
|||
* | 0x018 | div | Baud rate divisor |
|
||||
*/
|
||||
|
||||
#ifndef _UARTHS_H_
|
||||
#define _UARTHS_H_
|
||||
#ifndef _K210_UARTHS_H_
|
||||
#define _K210_UARTHS_H_
|
||||
|
||||
#include <sbi/sbi_types.h>
|
||||
#include "platform.h"
|
||||
|
||||
/* Base register address */
|
||||
#define UARTHS_BASE_ADDR (0x38000000U)
|
||||
|
||||
/* Register address offsets */
|
||||
#define UARTHS_REG_TXFIFO 0x00
|
||||
|
@ -152,12 +154,6 @@ struct uarths {
|
|||
struct uarths_div div;
|
||||
} __attribute__((packed, aligned(4)));
|
||||
|
||||
enum uarths_interrupt_mode {
|
||||
UARTHS_SEND = 1,
|
||||
UARTHS_RECEIVE = 2,
|
||||
UARTHS_SEND_RECEIVE = 3,
|
||||
};
|
||||
|
||||
enum uarths_stopbit {
|
||||
UARTHS_STOP_1,
|
||||
UARTHS_STOP_2
|
||||
|
@ -167,4 +163,4 @@ void uarths_init(u32 baud_rate, enum uarths_stopbit stopbit);
|
|||
void uarths_putc(char c);
|
||||
char uarths_getc(void);
|
||||
|
||||
#endif /* _UARTHS_H_ */
|
||||
#endif /* _K210_UARTHS_H_ */
|
||||
|
|
Loading…
Reference in New Issue