Changeset 26853a06 in rtems


Ignore:
Timestamp:
03/15/23 13:41:53 (7 months ago)
Author:
Alan Cudmore <alan.cudmore@…>
Branches:
master
Children:
4021b87
Parents:
ca1c4e70
git-author:
Alan Cudmore <alan.cudmore@…> (03/15/23 13:41:53)
git-committer:
Joel Sherrill <joel@…> (03/28/23 19:04:04)
Message:

bsps/riscv: add riscv/kendrytek210 BSP variant source changes

This patch adds support for the Kendryte K210 RISC-V BSP variant.
The SoC uses the existing Interrupt Controller, Timer, and console UART.
It only needs SoC specific initialization and an embedded device tree binary
similar to the polarfire SoC BSP.

Updates #4876

Location:
bsps/riscv/riscv
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • bsps/riscv/riscv/console/console-config.c

    rca1c4e70 r26853a06  
    5656#include <string.h>
    5757
    58 #if RISCV_ENABLE_FRDME310ARTY_SUPPORT != 0
     58#if RISCV_ENABLE_SIFIVE_UART_SUPPORT != 0
    5959#include <bsp/fe310-uart.h>
    6060static fe310_uart_context fe310_uart_instance;
     
    240240#endif
    241241
    242 #if RISCV_ENABLE_FRDME310ARTY_SUPPORT != 0
     242#if RISCV_ENABLE_SIFIVE_UART_SUPPORT != 0
    243243    if (fdt_stringlist_contains(compat, compat_len, "sifive,uart0")) {
    244244      fe310_uart_context *ctx;
     
    256256      }
    257257
    258       rtems_termios_device_context_initialize(&ctx->base, "FE310UART");
     258      rtems_termios_device_context_initialize(&ctx->base, "SIFIVEUART");
    259259    }
    260260#endif
     
    291291#endif
    292292
    293 #if RISCV_ENABLE_FRDME310ARTY_SUPPORT != 0
     293#if RISCV_ENABLE_SIFIVE_UART_SUPPORT != 0
    294294  fe310_uart_context *ctx;
    295295  char fe310_path[] = "/dev/ttyS0";
     
    327327#endif
    328328
    329 #if RISCV_ENABLE_FRDME310ARTY_SUPPORT != 0
     329#if RISCV_ENABLE_SIFIVE_UART_SUPPORT != 0
    330330  ctx = &fe310_uart_instance;
    331331  rtems_termios_device_install(
  • bsps/riscv/riscv/console/fe310-uart.c

    rca1c4e70 r26853a06  
    5454  size_t i;
    5555
    56   ctx->regs->div = riscv_get_core_frequency() / 115200 - 1;
     56  ctx->regs->div = (riscv_get_core_frequency() / 115200 - 1) & 0xFFFF;
    5757  ctx->regs->txctrl |= 1;
    5858  ctx->regs->rxctrl |= 1;
  • bsps/riscv/riscv/include/bsp.h

    rca1c4e70 r26853a06  
    6161#include <rtems/devnull.h>
    6262
     63#if RISCV_ENABLE_KENDRYTE_K210_SUPPORT != 0
     64   #include <bsp/k210.h>
     65#endif
     66
    6367#ifdef __cplusplus
    6468extern "C" {
  • bsps/riscv/riscv/include/bsp/riscv.h

    rca1c4e70 r26853a06  
    5757#endif
    5858
     59#if RISCV_ENABLE_KENDRYTE_K210_SUPPORT != 0
     60uint32_t k210_get_frequency(void);
     61#endif
     62
    5963#ifdef __cplusplus
    6064}
  • bsps/riscv/riscv/start/bspstart.c

    rca1c4e70 r26853a06  
    210210  }
    211211#endif
     212
     213#if RISCV_ENABLE_KENDRYTE_K210_SUPPORT != 0
     214  uint32_t cpu_clock;
     215
     216  cpu_clock = k210_get_frequency();
     217  return cpu_clock;
     218#else
    212219  return 0;
     220#endif
     221
    213222}
    214223
     
    223232  return RISCV_INTERRUPT_VECTOR_EXTERNAL(intr[0]);
    224233}
     234
     235#if RISCV_ENABLE_KENDRYTE_K210_SUPPORT != 0
     236uint32_t k210_get_frequency(void)
     237{
     238  k210_sysctl_t *sysctl = (k210_sysctl_t *)K210_SYSCTL_BASE;
     239  uint32_t cpu_clock = 0;
     240  uint32_t clk_freq;
     241  uint32_t pll0, nr, nf, od;
     242  uint32_t node;
     243  const char *fdt;
     244  const fdt32_t *val;
     245  int len;
     246
     247  fdt = bsp_fdt_get();
     248  node = fdt_node_offset_by_compatible(fdt, -1,"fixed-clock");
     249  val = fdt_getprop(fdt, node, "clock-frequency", &len);
     250  if (val != NULL && len == 4) {
     251    clk_freq = fdt32_to_cpu(*val);
     252
     253    if (CLKSEL0_ACLK_SEL(sysctl->clk_sel0) == 1) {
     254       /* PLL0 selected */
     255       pll0 = sysctl->pll0;
     256       nr = PLL_CLK_R(pll0) + 1;
     257       nf = PLL_CLK_F(pll0) + 1;
     258       od = PLL_CLK_OD(pll0) + 1;
     259       cpu_clock = (clk_freq / nr * nf / od)/2;
     260    } else {
     261       /* OSC selected */
     262       cpu_clock = clk_freq;
     263    }
     264  }
     265  return cpu_clock;
     266}
     267#endif
    225268
    226269void bsp_start(void)
Note: See TracChangeset for help on using the changeset viewer.