Skip to content
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

arch/risc-v/eic7700x: Add support for ESWIN EIC7700X SoC #95

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions Documentation/platforms/risc-v/eic7700x/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
==============
ESWIN EIC7700X
==============

`ESWIN EIC7700X <https://www.eswincomputing.com/en/products/index/36.html>`_ is a 64-bit RISC-V SoC with 4 RISC-V Cores:

- **Processors:** 4 x RV64GC 1.4 GHz 64-bit RISC-V Cores
- **NPU:** 19.95 TOPS INT8
- **Memory:** Up to 32 GB 64-bit LPDDR4 / 4x / 5
- **Storage:** eMMC 5.1, 2 x SDIO 3.0, SATA3, SPI NOR Flash
- **Video Decoding:** H.265 up to 8K @ 50 FPS, or 32 x 1080P @ 30 FPS
- **Video Encoding:** H.265 up to 8K @ 25 FPS, or 13 x 1080P @ 30 FPS
- **Image Processing:** JPEG ISO/IEC 10918-1, ITU-T T.81
- **Network:** 2 x GMAC, RGMII supported
- **PCI Express:** 4-lane PCIe 3.0 (RC + EP)
- **Peripherals:** 2 x USB 3.0 DRD (Host + Device), 12 x I2C, 5 x UART, 2 x SPI, 3 x I2S (Slave + Master)
23 changes: 23 additions & 0 deletions arch/risc-v/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,25 @@ config ARCH_CHIP_SG2000
---help---
SOPHGO SG2000 SoC.

config ARCH_CHIP_EIC7700X
bool "ESWIN EIC7700X"
select ARCH_RV64
select ARCH_RV_ISA_M
select ARCH_RV_ISA_A
select ARCH_RV_ISA_C
select ARCH_HAVE_FPU
select ARCH_HAVE_DPFPU
select ARCH_HAVE_MULTICPU
select ARCH_HAVE_MPU
select ARCH_MMU_TYPE_SV39
select ARCH_HAVE_ADDRENV
select ARCH_NEED_ADDRENV_MAPPING
select ARCH_HAVE_S_MODE
select ONESHOT
select ALARM_ARCH
---help---
ESWIN EIC7700X SoC.

config ARCH_CHIP_RISCV_CUSTOM
bool "Custom RISC-V chip"
select ARCH_CHIP_CUSTOM
Expand Down Expand Up @@ -534,6 +553,7 @@ config ARCH_CHIP
default "bl808" if ARCH_CHIP_BL808
default "k230" if ARCH_CHIP_K230
default "sg2000" if ARCH_CHIP_SG2000
default "eic7700x" if ARCH_CHIP_EIC7700X

config ARCH_RISCV_INTXCPT_EXTENSIONS
bool "RISC-V Integer Context Extensions"
Expand Down Expand Up @@ -774,4 +794,7 @@ endif
if ARCH_CHIP_SG2000
source "arch/risc-v/src/sg2000/Kconfig"
endif
if ARCH_CHIP_EIC7700X
source "arch/risc-v/src/eic7700x/Kconfig"
endif
endif # ARCH_RISCV
26 changes: 26 additions & 0 deletions arch/risc-v/include/eic7700x/chip.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/****************************************************************************
* arch/risc-v/include/eic7700x/chip.h
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/

#ifndef __ARCH_RISCV_INCLUDE_EIC7700X_CHIP_H
#define __ARCH_RISCV_INCLUDE_EIC7700X_CHIP_H

#endif /* __ARCH_RISCV_INCLUDE_EIC7700X_CHIP_H */
42 changes: 42 additions & 0 deletions arch/risc-v/include/eic7700x/irq.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/****************************************************************************
* arch/risc-v/include/eic7700x/irq.h
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/

#ifndef __ARCH_RISCV_INCLUDE_EIC7700X_IRQ_H
#define __ARCH_RISCV_INCLUDE_EIC7700X_IRQ_H

/****************************************************************************
* Included Files
****************************************************************************/

/****************************************************************************
* Pre-processor Definitions
****************************************************************************/

/* Number of PLIC External Interrupts supported */

#define EIC7700X_PLIC_IRQS 458

/* Map RISC-V exception code to NuttX IRQ */

#define NR_IRQS (RISCV_IRQ_SEXT + EIC7700X_PLIC_IRQS)

#endif /* __ARCH_RISCV_INCLUDE_EIC7700X_IRQ_H */
Empty file.
32 changes: 32 additions & 0 deletions arch/risc-v/src/eic7700x/Make.defs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
############################################################################
# arch/risc-v/src/eic7700x/Make.defs
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
############################################################################

include common/Make.defs

# Specify our HEAD assembly file. This will be linked as
# the first object file, so it will appear at address 0
HEAD_ASRC = eic7700x_head.S

# Specify our C code within this directory to be included
CHIP_CSRCS = eic7700x_start.c eic7700x_irq_dispatch.c eic7700x_irq.c
CHIP_CSRCS += eic7700x_timerisr.c eic7700x_allocateheap.c
CHIP_CSRCS += eic7700x_mm_init.c eic7700x_pgalloc.c
87 changes: 87 additions & 0 deletions arch/risc-v/src/eic7700x/chip.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/****************************************************************************
* arch/risc-v/src/eic7700x/chip.h
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/

#ifndef __ARCH_RISCV_SRC_EIC7700X_CHIP_H
#define __ARCH_RISCV_SRC_EIC7700X_CHIP_H

/****************************************************************************
* Included Files
****************************************************************************/

/* Include the chip capabilities file */

#include <arch/eic7700x/chip.h>

#include "eic7700x_memorymap.h"

#include "hardware/eic7700x_memorymap.h"
#include "hardware/eic7700x_plic.h"

#include "riscv_internal.h"
#include "riscv_percpu.h"

/****************************************************************************
* Public Data
****************************************************************************/

/* Hart ID that booted NuttX (0 to 3) */

#ifndef __ASSEMBLY__
extern int g_eic7700x_boot_hart;
#endif

/****************************************************************************
* Macro Definitions
****************************************************************************/

#ifdef __ASSEMBLY__

/****************************************************************************
* Name: setintstack
*
* Description:
* Set the current stack pointer to the "top" the correct interrupt stack
* for the current CPU.
*
****************************************************************************/

#if defined(CONFIG_SMP) && CONFIG_ARCH_INTERRUPTSTACK > 15
.macro setintstack tmp0, tmp1
up_cpu_index \tmp0
li \tmp1, STACK_ALIGN_DOWN(CONFIG_ARCH_INTERRUPTSTACK)
mul \tmp1, \tmp0, \tmp1
la \tmp0, g_intstacktop
sub sp, \tmp0, \tmp1
.endm
#endif /* CONFIG_SMP && CONFIG_ARCH_INTERRUPTSTACK > 15 */

#if CONFIG_ARCH_INTERRUPTSTACK > 15
#if !defined(CONFIG_SMP) && defined(CONFIG_ARCH_USE_S_MODE)
.macro setintstack tmp0, tmp1
csrr \tmp0, CSR_SCRATCH
REGLOAD sp, RISCV_PERCPU_IRQSTACK(\tmp0)
.endm
#endif /* !defined(CONFIG_SMP) && defined(CONFIG_ARCH_USE_S_MODE) */
#endif /* CONFIG_ARCH_INTERRUPTSTACK > 15 */

#endif /* __ASSEMBLY__ */
#endif /* __ARCH_RISCV_SRC_EIC7700X_CHIP_H */
87 changes: 87 additions & 0 deletions arch/risc-v/src/eic7700x/eic7700x_allocateheap.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/****************************************************************************
* arch/risc-v/src/eic7700x/eic7700x_allocateheap.c
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/

/****************************************************************************
* Included Files
****************************************************************************/

#include <nuttx/config.h>
#include <nuttx/kmalloc.h>
#include <nuttx/userspace.h>
#include <nuttx/arch.h>
#include <arch/board/board_memorymap.h>
#include "riscv_internal.h"

/****************************************************************************
* Pre-processor Definitions
****************************************************************************/

#define KRAM_END KSRAM_END

/****************************************************************************
* Public Data
****************************************************************************/

/****************************************************************************
* Public Functions
****************************************************************************/

/****************************************************************************
* Name: up_allocate_heap
*
* Description:
* This function will be called to dynamically set aside the heap region.
*
* For the kernel build (CONFIG_BUILD_PROTECTED=y) with both kernel- and
* user-space heaps (CONFIG_MM_KERNEL_HEAP=y), this function provides the
* size of the unprotected, user-space heap.
*
* If a protected kernel-space heap is provided, the kernel heap must be
* allocated (and protected) by an analogous up_allocate_kheap().
*
* The following memory map is assumed for the flat build:
*
* .data region. Size determined at link time.
* .bss region Size determined at link time.
* IDLE thread stack. Size determined by CONFIG_IDLETHREAD_STACKSIZE.
* Heap. Extends to the end of User SRAM.
*
* The following memory map is assumed for the protect build.
* The kernel and user space have it's own dedicated heap space.
*
* User .data region Size determined at link time
* User .bss region Size determined at link time
* User heap Extends to the end of User SRAM
* Kernel .data region Size determined at link time
* Kernel .bss region Size determined at link time
* Kernel IDLE thread stack Size determined by CONFIG_IDLETHREAD_STACKSIZE
* Kernel heap Size determined by CONFIG_MM_KERNEL_HEAPSIZE
*
****************************************************************************/

void up_allocate_kheap(void **heap_start, size_t *heap_size)
{
/* Return the heap settings */

*heap_start = (void *)g_idle_topstack;
*heap_size = KRAM_END - g_idle_topstack;
}
Loading
Loading