-
Notifications
You must be signed in to change notification settings - Fork 8.4k
Initial Support for ElemRV-N #89441
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial Support for ElemRV-N #89441
Changes from all commits
ec2d63a
1ff6e93
224f71b
1080530
50b56dc
40ea935
f780572
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # Copyright (c) 2025 Aesc Silicon | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| config BOARD_ELEMRV | ||
| select SOC_ELEMRV_N |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| board: | ||
| name: elemrv | ||
| full_name: ElemRV-N | ||
| vendor: aesc | ||
| socs: | ||
| - name: elemrv_n |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| .. zephyr:board:: elemrv | ||
|
|
||
| Overview | ||
| ******** | ||
|
|
||
| ElemRV-N is an end-to-end open-source RISC-V microcontroller designed using SpinalHDL. | ||
|
|
||
| Version 0.2 of ElemRV-N was successfully fabricated using `IHP's Open PDK`_, a 130nm open semiconductor process, with support from `FMD-QNC`_. | ||
|
|
||
| For more details, refer to the official `GitHub Project`_. | ||
|
|
||
| .. note:: | ||
| The currently supported silicon version is ElemRV-N 0.2. | ||
|
|
||
| Supported Features | ||
| ****************** | ||
|
|
||
| .. zephyr:board-supported-hw:: | ||
|
|
||
| System Clock | ||
| ============ | ||
|
|
||
| The system clock for the RISC-V core is set to 20 MHz. This value is specified in the ``cpu0`` devicetree node using the ``clock-frequency`` property. | ||
|
|
||
| CPU | ||
| === | ||
|
|
||
| ElemRV-N integrates a VexRiscv RISC-V core featuring a 5-stage pipeline and the following ISA extensions: | ||
|
|
||
| * M (Integer Multiply/Divide) | ||
| * C (Compressed Instructions) | ||
|
|
||
| It also includes the following general-purpose ``Z`` extensions: | ||
|
|
||
| * Zicntr – Base Counter and Timer extensions | ||
| * Zicsr – Control and Status Register operations | ||
| * Zifencei – Instruction-fetch fence | ||
|
|
||
| The complete ISA string for this CPU is: ``RV32IMC_Zicntr_Zicsr_Zifencei`` | ||
|
|
||
| Hart-Level Interrupt Controller (HLIC) | ||
| ====================================== | ||
|
|
||
| Each CPU core is equipped with a Hart-Level Interrupt Controller, configurable through Control and Status Registers (CSRs). | ||
|
|
||
| Machine Timer | ||
| ============= | ||
|
|
||
| A RISC-V compliant machine timer is enabled by default. | ||
|
|
||
| Serial | ||
| ====== | ||
|
|
||
| The UART (Universal Asynchronous Receiver-Transmitter) interface is a configurable serial communication peripheral used for transmitting and receiving data. | ||
|
|
||
| By default, ``uart0`` operates at a baud rate of ``115200``, which can be adjusted via the elemrv device tree. | ||
|
|
||
| To evaluate the UART interface, build and run the following sample: | ||
|
|
||
| .. zephyr-app-commands:: | ||
| :board: elemrv/elemrv_n | ||
| :zephyr-app: samples/hello_world | ||
| :goals: build | ||
|
|
||
| .. _GitHub Project: | ||
| https://github.com/aesc-silicon/elemrv | ||
|
|
||
| .. _IHP's Open PDK: | ||
| https://github.com/IHP-GmbH/IHP-Open-PDK | ||
|
|
||
| .. _FMD-QNC: | ||
| https://www.elektronikforschung.de/projekte/fmd-qnc | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| /* | ||
| * Copyright (C) 2025 Aesc Silicon | ||
| * | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| /dts-v1/; | ||
|
|
||
| #include <aesc/elemrv-n.dtsi> | ||
|
|
||
| / { | ||
| model = "ElemRV-N"; | ||
| compatible = "aesc,elemrv-n"; | ||
|
|
||
| chosen { | ||
| zephyr,console = &uart0; | ||
| zephyr,shell-uart = &uart0; | ||
| zephyr,sram = &hyperbus; | ||
| zephyr,flash = &flash; | ||
| }; | ||
|
|
||
| soc { | ||
| ocram: memory@80000000 { | ||
| device_type = "memory"; | ||
| compatible = "mmio-sram"; | ||
| reg = <0x80000000 DT_SIZE_K(1)>; | ||
| }; | ||
|
|
||
| hyperbus: memory@90000000 { | ||
| device_type = "memory"; | ||
| compatible = "mmio-sram"; | ||
| reg = <0x90000000 DT_SIZE_K(32)>; | ||
| }; | ||
|
|
||
| flash: flash@a0010000 { | ||
| compatible = "soc-nv-flash"; | ||
| reg = <0xa0010000 DT_SIZE_K(32)>; | ||
| }; | ||
| }; | ||
| }; | ||
|
|
||
| &uart0 { | ||
| clock-frequency = <DT_FREQ_M(20)>; | ||
henrikbrixandersen marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| current-speed = <115200>; | ||
| status = "okay"; | ||
| }; | ||
|
|
||
| &cpu0 { | ||
| clock-frequency = <DT_FREQ_M(20)>; | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| identifier: elemrv/elemrv_n | ||
| name: ElemRV-N | ||
| type: mcu | ||
| arch: riscv | ||
| toolchain: | ||
| - cross-compile | ||
| - zephyr | ||
| ram: 32 | ||
| flash: 32 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # Copyright (c) 2025 Aesc Silicon | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| # Serial Driver | ||
| CONFIG_SERIAL=y | ||
|
|
||
| # Enable Console | ||
| CONFIG_CONSOLE=y | ||
| CONFIG_UART_CONSOLE=y |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| .. _boards-aesc: | ||
|
|
||
| Aesc Silicon | ||
| ############ | ||
|
|
||
| .. toctree:: | ||
| :maxdepth: 1 | ||
| :glob: | ||
|
|
||
| **/* |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| # Copyright (c) 2025 Aesc Silicon | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| config UART_AESC | ||
| bool "Aesc Silicon UART driver" | ||
| default y | ||
| depends on DT_HAS_AESC_UART_ENABLED | ||
| select SERIAL_HAS_DRIVER | ||
| help | ||
| Enable the Aesc Silicon UART driver. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,126 @@ | ||
| /* | ||
| * Copyright (c) 2025 Aesc Silicon | ||
| * | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| #define DT_DRV_COMPAT aesc_uart | ||
|
|
||
| #include <errno.h> | ||
| #include <ip_identification.h> | ||
| #include <soc.h> | ||
|
|
||
| #include <zephyr/device.h> | ||
| #include <zephyr/devicetree.h> | ||
| #include <zephyr/drivers/uart.h> | ||
| #include <zephyr/init.h> | ||
| #include <zephyr/kernel.h> | ||
|
|
||
| #include <zephyr/logging/log.h> | ||
| LOG_MODULE_REGISTER(aesc_uart, CONFIG_UART_LOG_LEVEL); | ||
|
|
||
| struct uart_aesc_data { | ||
| DEVICE_MMIO_NAMED_RAM(regs); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will this driver be present on SoC with an MMU? Otherwise, this is not needed.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not yet but eventually in the future. So, if it's not a problem I would keep it. |
||
| }; | ||
|
|
||
| struct uart_aesc_config { | ||
| DEVICE_MMIO_NAMED_ROM(regs); | ||
| uint64_t sys_clk_freq; | ||
| uint32_t current_speed; | ||
| }; | ||
|
|
||
| struct uart_aesc_regs { | ||
| uint32_t data_width; | ||
| uint32_t sampling_sizes; | ||
| uint32_t fifo_depths; | ||
| uint32_t permissions; | ||
| uint32_t read_write; | ||
| uint32_t fifo_status; | ||
| uint32_t clock_div; | ||
| uint32_t frame_cfg; | ||
| uint32_t ip; | ||
| uint32_t ie; | ||
| }; | ||
|
|
||
| #define DEV_CFG(dev) ((struct uart_aesc_config *)(dev)->config) | ||
| #define DEV_DATA(dev) ((struct uart_aesc_data *)(dev)->data) | ||
| #define DEV_UART(dev) \ | ||
| ((struct uart_aesc_regs *)DEVICE_MMIO_NAMED_GET(dev, regs)) | ||
|
|
||
| #define AESC_UART_IRQ_TX_EN BIT(0) | ||
| #define AESC_UART_IRQ_RX_EN BIT(1) | ||
| #define AESC_UART_FIFO_TX_COUNT_MASK GENMASK(23, 16) | ||
| #define AESC_UART_READ_FIFO_VALID_BIT BIT(16) | ||
|
|
||
| static void uart_aesc_poll_out(const struct device *dev, unsigned char c) | ||
| { | ||
| struct uart_aesc_regs *uart = DEV_UART(dev); | ||
|
|
||
| while ((uart->fifo_status & AESC_UART_FIFO_TX_COUNT_MASK) == 0) { | ||
| /* Wait until transmit fifo is empty */ | ||
| } | ||
| uart->read_write = c; | ||
| } | ||
|
|
||
| static int uart_aesc_poll_in(const struct device *dev, unsigned char *c) | ||
| { | ||
| const struct uart_aesc_regs *uart = DEV_UART(dev); | ||
| int val; | ||
|
|
||
| val = uart->read_write; | ||
| if (val & AESC_UART_READ_FIFO_VALID_BIT) { | ||
| *c = val & 0xFF; | ||
| return 0; | ||
| } | ||
|
|
||
| return -1; | ||
| } | ||
|
|
||
| static int uart_aesc_init(const struct device *dev) | ||
| { | ||
| const struct uart_aesc_config *cfg = DEV_CFG(dev); | ||
| volatile uintptr_t *base_addr = (volatile uintptr_t *)DEV_UART(dev); | ||
| volatile struct uart_aesc_regs *uart; | ||
|
|
||
| DEVICE_MMIO_NAMED_MAP(dev, regs, K_MEM_CACHE_NONE); | ||
| LOG_DBG("IP core version: %i.%i.%i.", | ||
| ip_id_get_major_version(base_addr), | ||
| ip_id_get_minor_version(base_addr), | ||
| ip_id_get_patchlevel(base_addr) | ||
| ); | ||
| DEVICE_MMIO_NAMED_GET(dev, regs) = ip_id_relocate_driver(base_addr); | ||
| LOG_DBG("Relocate driver to address 0x%lx.", DEVICE_MMIO_NAMED_GET(dev, regs)); | ||
| uart = DEV_UART(dev); | ||
|
|
||
| uart->clock_div = cfg->sys_clk_freq / cfg->current_speed / 8; | ||
| uart->frame_cfg = 7; | ||
|
|
||
| return 0; | ||
| } | ||
|
|
||
dnltz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| static const struct uart_driver_api uart_aesc_driver_api = { | ||
| .poll_in = uart_aesc_poll_in, | ||
| .poll_out = uart_aesc_poll_out, | ||
| .err_check = NULL, | ||
| }; | ||
|
|
||
| #define AESC_UART_INIT(no) \ | ||
| static struct uart_aesc_data uart_aesc_dev_data_##no; \ | ||
| static struct uart_aesc_config uart_aesc_dev_cfg_##no = { \ | ||
| DEVICE_MMIO_NAMED_ROM_INIT(regs, \ | ||
| DT_INST(no, aesc_uart)), \ | ||
| .sys_clk_freq = \ | ||
| DT_PROP(DT_INST(no, aesc_uart), clock_frequency), \ | ||
| .current_speed = \ | ||
| DT_PROP(DT_INST(no, aesc_uart), current_speed), \ | ||
| }; \ | ||
| DEVICE_DT_INST_DEFINE(no, \ | ||
| uart_aesc_init, \ | ||
| NULL, \ | ||
| &uart_aesc_dev_data_##no, \ | ||
| &uart_aesc_dev_cfg_##no, \ | ||
| PRE_KERNEL_1, \ | ||
| CONFIG_KERNEL_INIT_PRIORITY_DEVICE, \ | ||
| (void *)&uart_aesc_driver_api); | ||
|
|
||
| DT_INST_FOREACH_STATUS_OKAY(AESC_UART_INIT) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| # | ||
| # Copyright (c) 2025 Aesc Silicon | ||
| # | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # | ||
|
|
||
| title: Aesc Silicon UART (Universal Synchronous/Asynchronous Receiver/Transmitter) | ||
|
|
||
| description: | | ||
| The UART (Universal Asynchronous Receiver-Transmitter) IP Core is a configurable serial | ||
| communication interface designed to handle data transmission and reception. The core includes | ||
| an internal clock divider and supports flexible frame configurations, allowing for variable data | ||
| length, parity, and stop bit settings. | ||
|
|
||
| compatible: "aesc,uart" | ||
henrikbrixandersen marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| include: uart-controller.yaml | ||
|
|
||
| properties: | ||
| reg: | ||
| required: true | ||
Uh oh!
There was an error while loading. Please reload this page.