Skip to content

Add support for SOPHGO SoCs and Milk-V boards #69594

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

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
105 changes: 105 additions & 0 deletions dts/riscv/sophgo/cv181x.dtsi
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/*
* Copyright (c) 2024 Chen Xingyu <[email protected]>
* SPDX-License-Identifier: Apache-2.0
*/

#include <mem.h>
#include <freq.h>

#include <sophgo/cv18xx-c906-common.dtsi>

/ {
soc {
compatible = "sophgo,cv181x", "simple-bus";

gpioa: gpio@3020000 {
compatible = "snps,designware-gpio";
reg = <0x3020000 DT_SIZE_K(4)>;
interrupts = <41 1>;
gpio-controller;
#gpio-cells = <2>;
status = "disabled";
};

gpiob: gpio@3021000 {
compatible = "snps,designware-gpio";
reg = <0x3021000 DT_SIZE_K(4)>;
interrupts = <42 1>;
gpio-controller;
#gpio-cells = <2>;
status = "disabled";
};

gpioc: gpio@3022000 {
compatible = "snps,designware-gpio";
reg = <0x3022000 DT_SIZE_K(4)>;
interrupts = <43 1>;
gpio-controller;
#gpio-cells = <2>;
status = "disabled";
};

gpiod: gpio@3023000 {
compatible = "snps,designware-gpio";
reg = <0x3023000 DT_SIZE_K(4)>;
interrupts = <44 1>;
gpio-controller;
#gpio-cells = <2>;
status = "disabled";
};

uart0: uart@4140000 {
compatible = "ns16550";
reg = <0x4140000 DT_SIZE_K(64)>;
interrupts = <30 1>;
reg-shift = <2>;
clock-frequency = <DT_FREQ_M(25)>;
status = "disabled";
};

uart1: uart@4150000 {
compatible = "ns16550";
reg = <0x4150000 DT_SIZE_K(64)>;
interrupts = <31 1>;
reg-shift = <2>;
clock-frequency = <DT_FREQ_M(25)>;
status = "disabled";
};

uart2: uart@4160000 {
compatible = "ns16550";
reg = <0x4160000 DT_SIZE_K(64)>;
/* interrupt is not supported */
reg-shift = <2>;
clock-frequency = <DT_FREQ_M(25)>;
status = "disabled";
};

uart3: uart@4170000 {
compatible = "ns16550";
reg = <0x4170000 DT_SIZE_K(64)>;
/* interrupt is not supported */
reg-shift = <2>;
clock-frequency = <DT_FREQ_M(25)>;
status = "disabled";
};

uart4: uart@41c0000 {
compatible = "ns16550";
reg = <0x41c0000 DT_SIZE_K(64)>;
/* interrupt is not supported */
reg-shift = <2>;
clock-frequency = <DT_FREQ_M(25)>;
status = "disabled";
};

pwr_gpio: gpio@5021000 {
compatible = "snps,designware-gpio";
reg = <0x5021000 DT_SIZE_K(4)>;
interrupts = <48 1>;
gpio-controller;
#gpio-cells = <2>;
status = "disabled";
};
};
};
3 changes: 3 additions & 0 deletions soc/sophgo/cv181x/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# SPDX-License-Identifier: Apache-2.0

set(SOC_LINKER_SCRIPT ${ZEPHYR_BASE}/include/zephyr/arch/riscv/common/linker.ld CACHE INTERNAL "")
18 changes: 18 additions & 0 deletions soc/sophgo/cv181x/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright (c) 2024 Chen Xingyu <[email protected]>
# SPDX-License-Identifier: Apache-2.0

config SOC_SERIES_CV181X
select 64BIT
select RISCV
select RISCV_PRIVILEGED
select RISCV_ISA_RV64I
select RISCV_ISA_EXT_M
select RISCV_ISA_EXT_A
select RISCV_ISA_EXT_F
select RISCV_ISA_EXT_D
select RISCV_ISA_EXT_C
select RISCV_ISA_EXT_ZICSR
select RISCV_ISA_EXT_ZIFENCEI
select RISCV_SOC_HAS_GP_RELATIVE_ADDRESSING
select INCLUDE_RESET_VECTOR
select ATOMIC_OPERATIONS_C
22 changes: 22 additions & 0 deletions soc/sophgo/cv181x/Kconfig.defconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright (c) 2024 Chen Xingyu <[email protected]>
# SPDX-License-Identifier: Apache-2.0

if SOC_SERIES_CV181X

config SYS_CLOCK_HW_CYCLES_PER_SEC
default 25000000

Comment on lines +6 to +8
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as above

config NUM_IRQS
int
default 128
Comment on lines +6 to +11
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as above

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not fixed

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the comment here refers to a point above about removing int not that this value come from dts

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you need to be very specific, above here, at least for me is the DTS comment above.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's above that, and shows the same thing as this #69594 (comment)


config RISCV_SOC_INTERRUPT_INIT
default y

config RISCV_HAS_PLIC
default y

config 2ND_LVL_INTR_00_OFFSET
default 11

endif # SOC_SERIES_CV181X
21 changes: 21 additions & 0 deletions soc/sophgo/cv181x/Kconfig.soc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright (c) 2024 Chen Xingyu <[email protected]>
# SPDX-License-Identifier: Apache-2.0

config SOC_SERIES_CV181X
bool
select SOC_FAMILY_SOPHGO

config SOC_SERIES
default "cv181x" if SOC_SERIES_CV181X

config SOC_SG2000
bool
select SOC_SERIES_CV181X

config SOC_SG2002
bool
select SOC_SERIES_CV181X

config SOC
default "sg2000" if SOC_SG2000
default "sg2002" if SOC_SG2002
8 changes: 8 additions & 0 deletions soc/sophgo/soc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,11 @@ family:
- name: cv1800b
cpuclusters:
- name: c906_1
- name: cv181x
socs:
- name: sg2000
cpuclusters:
- name: c906_1
- name: sg2002
cpuclusters:
- name: c906_1