From 7f8eb4f8ba48c8af037e8e08ee6f918f94c48201 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E8=A1=8D?= Date: Tue, 26 Nov 2024 06:47:33 +0000 Subject: [PATCH 01/13] =?UTF-8?q?zephyr=203.7.1=E5=86=85=E6=A0=B8=E9=80=82?= =?UTF-8?q?=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gdbinit | 42 + .gitlint_qemu | 39 + arch/arm/core/Kconfig | 5 + arch/arm/core/cortex_a_r/Kconfig | 18 + arch/arm/core/cortex_a_r/reset.S | 85 +- arch/arm/core/mmu/arm_mmu.c | 10 +- arch/arm/core/vector_table.ld | 5 + arch/arm64/core/Kconfig | 21 + arch/arm64/core/mmu.c | 2 +- arch/arm64/core/reset.S | 94 +- boards/phytium/d2000_demo/Kconfig.d2000_demo | 18 + boards/phytium/d2000_demo/Kconfig.defconfig | 19 + boards/phytium/d2000_demo/board.cmake | 1 + boards/phytium/d2000_demo/board.yml | 5 + boards/phytium/d2000_demo/d2000_demo.dts | 31 + boards/phytium/d2000_demo/d2000_demo.yaml | 7 + .../phytium/d2000_demo/d2000_demo_defconfig | 33 + .../d2000_demo_smp/Kconfig.d2000_demo_smp | 18 + .../phytium/d2000_demo_smp/Kconfig.defconfig | 19 + boards/phytium/d2000_demo_smp/board.cmake | 1 + boards/phytium/d2000_demo_smp/board.yml | 5 + .../phytium/d2000_demo_smp/d2000_demo_smp.dts | 37 + .../d2000_demo_smp/d2000_demo_smp.yaml | 9 + .../d2000_demo_smp/d2000_demo_smp_defconfig | 41 + boards/phytium/d3000_demo/Kconfig.d3000_demo | 18 + boards/phytium/d3000_demo/Kconfig.defconfig | 19 + boards/phytium/d3000_demo/board.cmake | 1 + boards/phytium/d3000_demo/board.yml | 5 + boards/phytium/d3000_demo/d3000_demo.dts | 27 + boards/phytium/d3000_demo/d3000_demo.yaml | 10 + .../phytium/d3000_demo/d3000_demo_defconfig | 33 + .../d3000_demo_smp/Kconfig.d3000_demo_smp | 18 + .../phytium/d3000_demo_smp/Kconfig.defconfig | 19 + boards/phytium/d3000_demo_smp/board.cmake | 1 + boards/phytium/d3000_demo_smp/board.yml | 5 + .../phytium/d3000_demo_smp/d3000_demo_smp.dts | 32 + .../d3000_demo_smp/d3000_demo_smp.yaml | 10 + .../d3000_demo_smp/d3000_demo_smp_defconfig | 41 + boards/phytium/e2000q_demo/CMakeLists.txt | 1 + boards/phytium/e2000q_demo/Kconfig.defconfig | 28 + .../phytium/e2000q_demo/Kconfig.e2000q_demo | 18 + boards/phytium/e2000q_demo/board.cmake | 1 + boards/phytium/e2000q_demo/board.yml | 5 + boards/phytium/e2000q_demo/e2000q_demo.dts | 54 + boards/phytium/e2000q_demo/e2000q_demo.yaml | 7 + .../phytium/e2000q_demo/e2000q_demo_defconfig | 33 + .../phytium/e2000q_demo/e2000q_pinctrl.dtsi | 19 + .../phytium/e2000q_demo_smp/Kconfig.defconfig | 19 + .../e2000q_demo_smp/Kconfig.e2000q_demo_smp | 18 + boards/phytium/e2000q_demo_smp/board.cmake | 1 + boards/phytium/e2000q_demo_smp/board.yml | 5 + .../e2000q_demo_smp/e2000q_demo_smp.dts | 49 + .../e2000q_demo_smp/e2000q_demo_smp.yaml | 9 + .../e2000q_demo_smp/e2000q_demo_smp_defconfig | 41 + boards/phytium/index.rst | 10 + cmake/gcc-m-cpu.cmake | 2 + cmake/gcc-m-fpu.cmake | 12 + drivers/ethernet/CMakeLists.txt | 1 + drivers/ethernet/Kconfig | 1 + drivers/ethernet/Kconfig.phytium_xmac | 22 + drivers/ethernet/eth_phytium_xmac.c | 1467 +++++++++++++++++ drivers/ethernet/eth_phytium_xmac.h | 117 ++ drivers/pinctrl/CMakeLists.txt | 1 + drivers/pinctrl/Kconfig | 1 + drivers/pinctrl/Kconfig.phytium | 22 + drivers/pinctrl/pinctrl_phytium.c | 99 ++ drivers/sdhc/CMakeLists.txt | 1 + drivers/sdhc/Kconfig | 1 + drivers/sdhc/Kconfig.phytium_sdhc | 49 + drivers/sdhc/phytium_sdhc.c | 1003 +++++++++++ drivers/serial/CMakeLists.txt | 1 + drivers/serial/Kconfig | 2 + drivers/serial/kconfig.phytium_pl011 | 21 + drivers/serial/uart_phytium_pl011.c | 148 ++ dts/arm/phytium/e2000q.dtsi | 149 ++ dts/arm64/phytium/d2000.dtsi | 141 ++ dts/arm64/phytium/d3000.dtsi | 135 ++ dts/arm64/phytium/e2000d.dtsi | 149 ++ dts/arm64/phytium/e2000q.dtsi | 177 ++ dts/bindings/cpu/phytium,ftc310.yaml | 20 + dts/bindings/cpu/phytium,ftc663.yaml | 20 + dts/bindings/cpu/phytium,ftc862.yaml | 20 + dts/bindings/ethernet/phytium,xmac.yaml | 233 +++ dts/bindings/pinctrl/phytium,pinctrl.yaml | 38 + dts/bindings/sdhc/phytium,sdhc.yaml | 61 + dts/bindings/serial/arm,pl011.yaml | 2 + dts/bindings/serial/phytium,pl011.yaml | 27 + include/zephyr/arch/arm/arch.h | 2 +- include/zephyr/arch/arm/cortex_a_r/cpu.h | 2 +- .../pinctrl/phytium-e2000q-pinctrl.h | 278 ++++ makefile | 28 + modules/Kconfig | 1 + modules/Kconfig.phytium | 52 + samples/arch/smp/pktqueue/src/main.c | 2 +- soc/arm/phytium_d2000/CMakeLists.txt | 10 + soc/arm/phytium_d2000/Kconfig | 10 + soc/arm/phytium_d2000/Kconfig.defconfig | 29 + soc/arm/phytium_d2000/Kconfig.soc | 24 + soc/arm/phytium_d2000/mmu_regions.c | 38 + soc/arm/phytium_d2000/soc.c | 23 + soc/arm/phytium_d3000/CMakeLists.txt | 10 + soc/arm/phytium_d3000/Kconfig | 10 + soc/arm/phytium_d3000/Kconfig.defconfig | 29 + soc/arm/phytium_d3000/Kconfig.soc | 27 + soc/arm/phytium_d3000/mmu_regions.c | 52 + soc/arm/phytium_d3000/soc.c | 23 + soc/arm/phytium_e2000q/CMakeLists.txt | 10 + soc/arm/phytium_e2000q/Kconfig | 9 + soc/arm/phytium_e2000q/Kconfig.defconfig | 29 + soc/arm/phytium_e2000q/Kconfig.soc | 24 + soc/arm/phytium_e2000q/mmu_regions.c | 38 + soc/arm/phytium_e2000q/pinctrl_soc.h | 51 + soc/arm/phytium_e2000q/soc.c | 23 + soc/arm/soc.yml | 70 +- subsys/sd/sd.c | 3 +- west.yml | 8 + 116 files changed, 6138 insertions(+), 42 deletions(-) create mode 100644 .gdbinit create mode 100644 .gitlint_qemu create mode 100644 boards/phytium/d2000_demo/Kconfig.d2000_demo create mode 100644 boards/phytium/d2000_demo/Kconfig.defconfig create mode 100644 boards/phytium/d2000_demo/board.cmake create mode 100644 boards/phytium/d2000_demo/board.yml create mode 100644 boards/phytium/d2000_demo/d2000_demo.dts create mode 100644 boards/phytium/d2000_demo/d2000_demo.yaml create mode 100644 boards/phytium/d2000_demo/d2000_demo_defconfig create mode 100644 boards/phytium/d2000_demo_smp/Kconfig.d2000_demo_smp create mode 100644 boards/phytium/d2000_demo_smp/Kconfig.defconfig create mode 100644 boards/phytium/d2000_demo_smp/board.cmake create mode 100644 boards/phytium/d2000_demo_smp/board.yml create mode 100644 boards/phytium/d2000_demo_smp/d2000_demo_smp.dts create mode 100644 boards/phytium/d2000_demo_smp/d2000_demo_smp.yaml create mode 100644 boards/phytium/d2000_demo_smp/d2000_demo_smp_defconfig create mode 100644 boards/phytium/d3000_demo/Kconfig.d3000_demo create mode 100644 boards/phytium/d3000_demo/Kconfig.defconfig create mode 100644 boards/phytium/d3000_demo/board.cmake create mode 100644 boards/phytium/d3000_demo/board.yml create mode 100644 boards/phytium/d3000_demo/d3000_demo.dts create mode 100644 boards/phytium/d3000_demo/d3000_demo.yaml create mode 100644 boards/phytium/d3000_demo/d3000_demo_defconfig create mode 100644 boards/phytium/d3000_demo_smp/Kconfig.d3000_demo_smp create mode 100644 boards/phytium/d3000_demo_smp/Kconfig.defconfig create mode 100644 boards/phytium/d3000_demo_smp/board.cmake create mode 100644 boards/phytium/d3000_demo_smp/board.yml create mode 100644 boards/phytium/d3000_demo_smp/d3000_demo_smp.dts create mode 100644 boards/phytium/d3000_demo_smp/d3000_demo_smp.yaml create mode 100644 boards/phytium/d3000_demo_smp/d3000_demo_smp_defconfig create mode 100644 boards/phytium/e2000q_demo/CMakeLists.txt create mode 100644 boards/phytium/e2000q_demo/Kconfig.defconfig create mode 100644 boards/phytium/e2000q_demo/Kconfig.e2000q_demo create mode 100644 boards/phytium/e2000q_demo/board.cmake create mode 100644 boards/phytium/e2000q_demo/board.yml create mode 100644 boards/phytium/e2000q_demo/e2000q_demo.dts create mode 100644 boards/phytium/e2000q_demo/e2000q_demo.yaml create mode 100644 boards/phytium/e2000q_demo/e2000q_demo_defconfig create mode 100644 boards/phytium/e2000q_demo/e2000q_pinctrl.dtsi create mode 100644 boards/phytium/e2000q_demo_smp/Kconfig.defconfig create mode 100644 boards/phytium/e2000q_demo_smp/Kconfig.e2000q_demo_smp create mode 100644 boards/phytium/e2000q_demo_smp/board.cmake create mode 100644 boards/phytium/e2000q_demo_smp/board.yml create mode 100644 boards/phytium/e2000q_demo_smp/e2000q_demo_smp.dts create mode 100644 boards/phytium/e2000q_demo_smp/e2000q_demo_smp.yaml create mode 100644 boards/phytium/e2000q_demo_smp/e2000q_demo_smp_defconfig create mode 100644 boards/phytium/index.rst create mode 100644 drivers/ethernet/Kconfig.phytium_xmac create mode 100644 drivers/ethernet/eth_phytium_xmac.c create mode 100644 drivers/ethernet/eth_phytium_xmac.h create mode 100644 drivers/pinctrl/Kconfig.phytium create mode 100644 drivers/pinctrl/pinctrl_phytium.c create mode 100644 drivers/sdhc/Kconfig.phytium_sdhc create mode 100644 drivers/sdhc/phytium_sdhc.c create mode 100644 drivers/serial/kconfig.phytium_pl011 create mode 100644 drivers/serial/uart_phytium_pl011.c create mode 100644 dts/arm/phytium/e2000q.dtsi create mode 100644 dts/arm64/phytium/d2000.dtsi create mode 100644 dts/arm64/phytium/d3000.dtsi create mode 100644 dts/arm64/phytium/e2000d.dtsi create mode 100644 dts/arm64/phytium/e2000q.dtsi create mode 100644 dts/bindings/cpu/phytium,ftc310.yaml create mode 100644 dts/bindings/cpu/phytium,ftc663.yaml create mode 100644 dts/bindings/cpu/phytium,ftc862.yaml create mode 100644 dts/bindings/ethernet/phytium,xmac.yaml create mode 100644 dts/bindings/pinctrl/phytium,pinctrl.yaml create mode 100644 dts/bindings/sdhc/phytium,sdhc.yaml create mode 100644 dts/bindings/serial/phytium,pl011.yaml create mode 100644 include/zephyr/dt-bindings/pinctrl/phytium-e2000q-pinctrl.h create mode 100644 makefile create mode 100644 modules/Kconfig.phytium create mode 100644 soc/arm/phytium_d2000/CMakeLists.txt create mode 100644 soc/arm/phytium_d2000/Kconfig create mode 100644 soc/arm/phytium_d2000/Kconfig.defconfig create mode 100644 soc/arm/phytium_d2000/Kconfig.soc create mode 100644 soc/arm/phytium_d2000/mmu_regions.c create mode 100644 soc/arm/phytium_d2000/soc.c create mode 100644 soc/arm/phytium_d3000/CMakeLists.txt create mode 100644 soc/arm/phytium_d3000/Kconfig create mode 100644 soc/arm/phytium_d3000/Kconfig.defconfig create mode 100644 soc/arm/phytium_d3000/Kconfig.soc create mode 100644 soc/arm/phytium_d3000/mmu_regions.c create mode 100644 soc/arm/phytium_d3000/soc.c create mode 100644 soc/arm/phytium_e2000q/CMakeLists.txt create mode 100644 soc/arm/phytium_e2000q/Kconfig create mode 100644 soc/arm/phytium_e2000q/Kconfig.defconfig create mode 100644 soc/arm/phytium_e2000q/Kconfig.soc create mode 100644 soc/arm/phytium_e2000q/mmu_regions.c create mode 100644 soc/arm/phytium_e2000q/pinctrl_soc.h create mode 100644 soc/arm/phytium_e2000q/soc.c diff --git a/.gdbinit b/.gdbinit new file mode 100644 index 00000000000..76b6f237a7b --- /dev/null +++ b/.gdbinit @@ -0,0 +1,42 @@ +# increase the default remote timeout in gdb because +# Windows libusb transactions could be slow +set remotetimeout 100000 + +# gdb connect to openocd in port 3333 +target extended-remote localhost:3333 + +# start openocd working queue, monitor followed with openocd command here +monitor init + +# force to use hardware breakpoint, otherwise use software breakpoint +# for e2000d/q, num of hardware breakpoints supposed to be 6 +monitor gdb_breakpoint_override hardware + +# load elf image +load ./build/zephyr/zephyr.elf + +# in case symbols skip load,load agin +file ./build/zephyr/zephyr.elf + +# we can break at the beginning of code by address or by symbol +#break _boot + +# add more breakpoints in application +#break JtagTouchRegisters +#break JtagTouchMemory +# break bubbleSort +# break JtagPostSort +#break bubbleSortCXX + +# show all breakspoints we before running +# info breakpoints + +# show [-0x10 ~ +0x10 ] range of instructions when breaked +# display /10i $pc-16 + +# start running +# continue + +layout split + +si diff --git a/.gitlint_qemu b/.gitlint_qemu new file mode 100644 index 00000000000..c4e4cf7f036 --- /dev/null +++ b/.gitlint_qemu @@ -0,0 +1,39 @@ +# increase the default remote timeout in gdb because +# Windows libusb transactions could be slow +set remotetimeout 100000 + +# gdb connect to openocd in port 3333 +target extended-remote localhost:1234 + +# start openocd working queue, monitor followed with openocd command here +# monitor init + +# force to use hardware breakpoint, otherwise use software breakpoint +# for e2000d/q, num of hardware breakpoints supposed to be 6 +# monitor gdb_breakpoint_override hardware + +# load elf image +# load ./build/zephyr/zephyr.elf + +# in case symbols skip load,load agin +file ./build/zephyr/zephyr.elf + +# we can break at the beginning of code by address or by symbol +#break _boot + +# add more breakpoints in application +#break JtagTouchRegisters +#break JtagTouchMemory +# break bubbleSort +# break JtagPostSort +#break bubbleSortCXX + +# show all breakspoints we before running +# info breakpoints + +# show [-0x10 ~ +0x10 ] range of instructions when breaked +# display /10i $pc-16 + +# start running +# continue +si diff --git a/arch/arm/core/Kconfig b/arch/arm/core/Kconfig index 41c2b1f7684..2b98e64f13d 100644 --- a/arch/arm/core/Kconfig +++ b/arch/arm/core/Kconfig @@ -70,6 +70,11 @@ config GDBSTUB_BUF_SZ # registers - 336 HEX letters default 350 if GDBSTUB +config CPU_AARCH32_ARMV8 + bool + help + This option signifies the use of a CPU of the Armv8 family. + config ISA_THUMB2 bool help diff --git a/arch/arm/core/cortex_a_r/Kconfig b/arch/arm/core/cortex_a_r/Kconfig index 4095a277c61..3c8393e1e29 100644 --- a/arch/arm/core/cortex_a_r/Kconfig +++ b/arch/arm/core/cortex_a_r/Kconfig @@ -13,6 +13,24 @@ # CPU_AARCH32_CORTEX_A / if CPU_AARCH32_CORTEX_R blocks so they are not # exposed if one selects a different ARM Cortex Family (Cortex-M). +config CPU_PHYTIUM_FT310 + bool + select CPU_AARCH32_CORTEX_A + select CPU_AARCH32_ARMV8 + select CPU_HAS_ICACHE + select CPU_HAS_DCACHE + select ARMV7_A + help + This option signifies the use of a FT310 CPU. + +if CPU_PHYTIUM_FT310 + config AARCH64_2_AARCH32 + bool + help + Example Convert aarch64 to aarch32 + +endif + config CPU_CORTEX_A9 bool select CPU_AARCH32_CORTEX_A diff --git a/arch/arm/core/cortex_a_r/reset.S b/arch/arm/core/cortex_a_r/reset.S index 0b107fbf596..cc3da81ab7d 100644 --- a/arch/arm/core/cortex_a_r/reset.S +++ b/arch/arm/core/cortex_a_r/reset.S @@ -34,6 +34,87 @@ GDATA(z_arm_undef_stack) GTEXT(z_arm_platform_init) #endif +SECTION_SUBSEC_FUNC(TEXT, _reset_section, __start) +#if defined(CONFIG_AARCH64_2_AARCH32) +aarch64_2_aarch32: + .long 0xd5384240 /* mrs x0, currentel */ + .long 0xd342fc00 /* lsr x0, x0, #2 */ + .long 0x92400400 /* and x0, x0, #0x3 */ + .long 0xf1000c1f /* cmp x0, #0x3 */ + .long 0x540003a1 /* b.ne 1d0080c4 */ + +el3_mode: + .long 0xd53ecca0 /* mrs x0, s3_6_c12_c12_5 - ICC_SRE_EL3 */ + .long 0xb2400c00 /* orr x0, x0, #0xf */ + .long 0xd51ecca0 /* msr s3_6_c12_c12_5, x0 */ + .long 0xd5033fdf /* isb */ + .long 0xd53cc9a0 /* mrs x0, s3_4_c12_c9_5 - ICC_SRE_EL2 */ + .long 0xb2400c00 /* orr x0, x0, #0xf */ + .long 0xd51cc9a0 /* msr s3_4_c12_c9_5, x0 */ + .long 0xd5033fdf /* isb */ + .long 0xd538cca0 /* mrs x0, s3_0_c12_c12_5 - ICC_SRE_EL1 */ + .long 0xb2400000 /* orr x0, x0, #0x1 */ + .long 0xd518cca0 /* msr s3_0_c12_c12_5, x0 */ + .long 0xd5033fdf /* isb */ + + .long 0xd2803620 /* mov x0, #0x1b1 */ + .long 0xd51e1100 /* msr scr_el3, x0 */ + .long 0xd2867fe0 /* mov x0, #0x33ff */ + .long 0xd51c1140 /* msr cptr_el2, x0 */ + .long 0xd2810000 /* mov x0, #0x800 */ + .long 0xf2a61a00 /* movk x0, #0x30d0, lsl #16 */ + .long 0xd5181000 /* msr sctlr_el1, x0 */ + .long 0x910003e0 /* mov x0, sp */ + .long 0xd51c4100 /* msr sp_el1, x0 */ + .long 0xd53ec000 /* mrs x0, vbar_el3 */ + .long 0xd518c000 /* msr vbar_el1, x0 */ + .long 0xd2803a60 /* mov x0, #0x1d3 */ + .long 0xd51e4000 /* msr spsr_el3, x0 */ + .long 0x10000500 /* adr x0, 1d008158 */ + .long 0xd51e4020 /* msr elr_el3, x0 */ + .long 0xd69f03e0 /* eret */ + +el2_mode: + .long 0xd53cc9a0 /* mrs x0, s3_4_c12_c9_5 - ICC_SRE_EL2 */ + .long 0xb2400c00 /* orr x0, x0, #0xf */ + .long 0xd51cc9a0 /* msr s3_4_c12_c9_5, x0 */ + .long 0xd5033fdf /* isb */ + .long 0xd538cca0 /* mrs x0, s3_0_c12_c12_5 - ICC_SRE_EL1 */ + .long 0xb2400000 /* orr x0, x0, #0x1 */ + .long 0xd518cca0 /* msr s3_0_c12_c12_5, x0 */ + .long 0xd5033fdf /* isb */ + .long 0xd53ce100 /* mrs x0, cnthctl_el2 */ + .long 0xb2400400 /* orr x0, x0, #0x3 */ + .long 0xd51ce100 /* msr cnthctl_el2, x0 */ + .long 0xd51ce07f /* msr cntvoff_el2, xzr */ + .long 0xd5380000 /* mrs x0, midr_el1 */ + .long 0xd53800a1 /* mrs x1, mpidr_el1 */ + .long 0xd51c0000 /* msr vpidr_el2, x0 */ + .long 0xd51c00a1 /* msr vmpidr_el2, x1 */ + .long 0xd2867fe0 /* mov x0, #0x33ff */ + .long 0xd51c1140 /* msr cptr_el2, x0 */ + .long 0xd51c117f /* msr hstr_el2, xzr */ + .long 0xd2a00600 /* mov x0, #0x300000 */ + .long 0xd5181040 /* msr cpacr_el1, x0 */ + .long 0xd2800000 /* mov x0, #0x0 */ + .long 0xb2630000 /* orr x0, x0, #0x20000000 */ + .long 0xd51c1100 /* msr hcr_el2, x0 */ + .long 0xd53c1100 /* mrs x0, hcr_el2 */ + .long 0xd2810000 /* mov x0, #0x800 */ + .long 0xf2a61a00 /* movk x0, #0x30d0, lsl #16 */ + .long 0xd5181000 /* msr sctlr_el1, x0 */ + .long 0x910003e0 /* mov x0, sp */ + .long 0xd51c4100 /* msr sp_el1, x0 */ + .long 0xd53cc000 /* mrs x0, vbar_el2 */ + .long 0xd518c000 /* msr vbar_el1, x0 */ + .long 0xd2803a60 /* mov x0, #0x1d3 */ + .long 0xd51c4000 /* msr spsr_el2, x0 */ + .long 0x10000060 /* adr x0, 1d008158 */ + .long 0xd51c4020 /* msr elr_el2, x0 */ + .long 0xd69f03e0 /* eret */ +el1_mode: + b z_arm_reset +#endif /** * * @brief Reset vector @@ -47,8 +128,10 @@ GTEXT(z_arm_platform_init) * */ SECTION_SUBSEC_FUNC(TEXT, _reset_section, z_arm_reset) -SECTION_SUBSEC_FUNC(TEXT, _reset_section, __start) + + #if defined(CONFIG_AARCH32_ARMV8_R) + /* Check if we are starting in HYP mode */ mrs r0, cpsr and r0, r0, #MODE_MASK diff --git a/arch/arm/core/mmu/arm_mmu.c b/arch/arm/core/mmu/arm_mmu.c index f37b4354d46..7f8cf8ffcc1 100644 --- a/arch/arm/core/mmu/arm_mmu.c +++ b/arch/arm/core/mmu/arm_mmu.c @@ -34,6 +34,10 @@ #include #include "arm_mmu_priv.h" +#ifdef CONFIG_DCACHE +#include +#endif + LOG_MODULE_DECLARE(os, CONFIG_KERNEL_LOG_LEVEL); /* Level 1 page table: always required, must be 16k-aligned */ @@ -73,7 +77,7 @@ static const struct arm_mmu_flat_range mmu_zephyr_ranges[] = { .start = (uint32_t)_image_ram_start, .end = (uint32_t)_image_ram_end, .attrs = MT_NORMAL | MATTR_SHARED | - MPERM_R | MPERM_W | + MPERM_R | MPERM_W |MPERM_X | MATTR_CACHE_OUTER_WB_WA | MATTR_CACHE_INNER_WB_WA}, /* Mark text segment cacheable, read only and executable */ @@ -855,7 +859,9 @@ int z_arm_mmu_init(void) reg_val |= ARM_MMU_SCTLR_DCACHE_ENABLE_BIT; reg_val |= ARM_MMU_SCTLR_MMU_ENABLE_BIT; __set_SCTLR(reg_val); - +#ifdef CONFIG_DCACHE + arch_dcache_invd_all() ; +#endif return 0; } diff --git a/arch/arm/core/vector_table.ld b/arch/arm/core/vector_table.ld index 463e389de9f..75019401d95 100644 --- a/arch/arm/core/vector_table.ld +++ b/arch/arm/core/vector_table.ld @@ -47,6 +47,11 @@ . = ALIGN( 0x80 ); #endif +aarch64_2_aarch32 = .; +KEEP(*(.aarch64_2_aarch32_section)) +KEEP(*(".aarch64_2_aarch32_section.*")) + +. = ALIGN( 0x80 ); _vector_start = .; KEEP(*(.exc_vector_table)) KEEP(*(".exc_vector_table.*")) diff --git a/arch/arm64/core/Kconfig b/arch/arm64/core/Kconfig index 367480015c4..17553a8a775 100644 --- a/arch/arm64/core/Kconfig +++ b/arch/arm64/core/Kconfig @@ -30,6 +30,27 @@ config CPU_AARCH64_CORTEX_R help This option signifies the use of a CPU of the Cortex-R 64-bit family. +config CPU_PHYTIUM_FTC310 + bool + select CPU_CORTEX_A + select ARMV8_A + help + This option signifies the use of a Phytium-FTC310 CPU + +config CPU_PHYTIUM_FTC862 + bool + select CPU_CORTEX_A + select ARMV8_A + help + This option signifies the use of a Phytium-FTC862 CPU + +config CPU_PHYTIUM_FTC664 + bool + select CPU_CORTEX_A + select ARMV8_A + help + This option signifies the use of a Phytium-FTC664 CPU + config CPU_CORTEX_A53 bool select CPU_CORTEX_A diff --git a/arch/arm64/core/mmu.c b/arch/arm64/core/mmu.c index f0abb4a029a..12f391a598a 100644 --- a/arch/arm64/core/mmu.c +++ b/arch/arm64/core/mmu.c @@ -939,7 +939,7 @@ static void enable_mmu_el1(struct arm_mmu_ptables *ptables, unsigned int flags) /* Enable the MMU and data cache */ val = read_sctlr_el1(); write_sctlr_el1(val | SCTLR_M_BIT | SCTLR_C_BIT); - + /* Ensure the MMU enable takes effect immediately */ barrier_isync_fence_full(); diff --git a/arch/arm64/core/reset.S b/arch/arm64/core/reset.S index a01139ad700..d155b877841 100644 --- a/arch/arm64/core/reset.S +++ b/arch/arm64/core/reset.S @@ -238,10 +238,25 @@ switch_el: mov_imm x0, (SPSR_DAIF_MASK | SPSR_MODE_EL1T) msr spsr_el2, x0 + bl InvalidateFlushDcaches + dsb sy + isb + adr x0, 1f msr elr_el2, x0 - eret + mrs x1, HCR_EL2 + orr x1, x1, #(1<<31) + bic x1, x1, #(1<<27) /* HCR_EL2.TGE = 0 */ + bic x1, x1, #(1<<5) /* HCR_EL2.AMO = 0 */ + bic x1, x1, #(1<<4) /* HCR_EL2.IMO = 0 */ + bic x1, x1, #(1<<3) /* HCR_EL2.FMO = 0 */ + orr x1, x1, #(1<<1) /* HCR_EL2.SWIO = 1 */ + /* rw=1 el1 execution state is aarch64.*/ + msr HCR_EL2, x1 + isb + + eret 1: /* EL1 init */ bl z_arm64_el1_init @@ -254,3 +269,80 @@ switch_el: isb ret x25 /* either z_prep_c or z_arm64_secondary_prep_c */ + + +/* flush or invalidate dcache, refer to rt-thread __asm_flush_dcache_all */ +InvalidateFlushDcacheLevel: + lsl x12, x0, #1 + msr csselr_el1, x12 /* select cache level */ + isb /* sync change of cssidr_el1 */ + mrs x6, ccsidr_el1 /* read the new cssidr_el1 */ + and x2, x6, #7 /* x2 <- log2(cache line size)-4 */ + add x2, x2, #4 /* x2 <- log2(cache line size) */ + mov x3, #0x3ff + and x3, x3, x6, lsr #3 /* x3 <- max number of #ways, ccsidr_el1[12:3] */ + clz w5, w3 /* bit position of #ways */ + mov x4, #0x7fff + and x4, x4, x6, lsr #13 /* x4 <- max number of #sets, ccsidr_el1[27:13] */ + /* x12 <- cache level << 1 */ + /* x2 <- line length offset */ + /* x3 <- number of cache ways - 1 */ + /* x4 <- number of cache sets - 1 */ + /* x5 <- bit position of #ways */ + +InvalidateFlushCacheSet: + mov x6, x3 /* x6 <- working copy of #ways */ + +InvalidateFlushCacheWay: + lsl x7, x6, x5 /* x7 = x6 << x5 */ + orr x9, x12, x7 /* x9 = x12 | x7, map way and level to cisw value */ + lsl x7, x4, x2 + orr x9, x9, x7 /* map set number to cisw value */ + tbz w1, #0, 1f /* x1 = 0f, flush cache */ + dc isw, x9 /* invalidate dcache */ + b 2f +1: dc cisw, x9 /* clean & invalidate by set/way */ +2: subs x6, x6, #1 /* decrement the way */ + b.ge InvalidateFlushCacheWay + subs x4, x4, #1 /* decrement the set */ + b.ge InvalidateFlushCacheSet + + ret + +.global InvalidateFlushDcaches +InvalidateFlushDcaches: + mov x1, x0 /* x1 = 0 flush, x1 = 1 invalidate */ + dsb sy /* barrier for full system */ + mrs x10, clidr_el1 /* read clidr_el1 */ + lsr x11, x10, #24 + and x11, x11, #0x7 /* x11 <- loc bit[26:24], level of cache hierarchy */ + cbz x11, InvalidateFlushDcacheEnd /* if loc is 0, no cache, exit */ + mov x15, lr /* preserve LR */ + mov x0, #0 /* start flush at cache level 0 */ + /* x0 <- cache level */ + /* x10 <- clidr_el1 */ + /* x11 <- loc */ + /* x15 <- return address */ + +InvalidateFlushCachesLoopLevel: + lsl x12, x0, #1 /* x12 = x0 * 2 */ + add x12, x12, x0 /* x0 <- tripled cache level */ + lsr x12, x10, x12 /* get x10, clidr_el1[ctype-n] to x12 */ + and x12, x12, #7 /* x12 <- cache type */ + cmp x12, #2 /* if not 000(no-cache), 001(i-cache only) */ + b.lt InvalidateFlushCachesSkipLevel /* skip if no cache or icache */ + bl InvalidateFlushDcacheLevel /* x1 = 0 flush, 1 invalidate */ + +InvalidateFlushCachesSkipLevel: + add x0, x0, #1 /* increment cache level */ + cmp x11, x0 + b.gt InvalidateFlushCachesLoopLevel + + mov x0, #0 + msr csselr_el1, x0 /* restore csselr_el1 */ + dsb sy + isb + mov lr, x15 + +InvalidateFlushDcacheEnd: + ret \ No newline at end of file diff --git a/boards/phytium/d2000_demo/Kconfig.d2000_demo b/boards/phytium/d2000_demo/Kconfig.d2000_demo new file mode 100644 index 00000000000..e11315682ce --- /dev/null +++ b/boards/phytium/d2000_demo/Kconfig.d2000_demo @@ -0,0 +1,18 @@ +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +# +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# https://opensource.org/license/apache-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. + +config BOARD_D2000_DEMO + bool "phytium d2000" + select SOC_D2000 diff --git a/boards/phytium/d2000_demo/Kconfig.defconfig b/boards/phytium/d2000_demo/Kconfig.defconfig new file mode 100644 index 00000000000..cb024a29c37 --- /dev/null +++ b/boards/phytium/d2000_demo/Kconfig.defconfig @@ -0,0 +1,19 @@ +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +# +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# https://opensource.org/license/apache-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. + + +config BOARD + default "Phytium d2000 demo" + depends on BOARD_D2000_DEMO diff --git a/boards/phytium/d2000_demo/board.cmake b/boards/phytium/d2000_demo/board.cmake new file mode 100644 index 00000000000..9881313609a --- /dev/null +++ b/boards/phytium/d2000_demo/board.cmake @@ -0,0 +1 @@ +# SPDX-License-Identifier: Apache-2.0 diff --git a/boards/phytium/d2000_demo/board.yml b/boards/phytium/d2000_demo/board.yml new file mode 100644 index 00000000000..82b49d204cd --- /dev/null +++ b/boards/phytium/d2000_demo/board.yml @@ -0,0 +1,5 @@ +board: + name: d2000_demo + vendor: arm64 + socs: + - name: phytium_d2000 \ No newline at end of file diff --git a/boards/phytium/d2000_demo/d2000_demo.dts b/boards/phytium/d2000_demo/d2000_demo.dts new file mode 100644 index 00000000000..bb59f288f27 --- /dev/null +++ b/boards/phytium/d2000_demo/d2000_demo.dts @@ -0,0 +1,31 @@ +/* + * Copyright 2024 zhangyan + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; +#include + +/ { + model = "Phytium d2000 demo"; + compatible = "phytium,d2000-demo", "phytium,d2000"; + #address-cells = <2>; + #size-cells = <2>; + +chosen { + zephyr,console = &uart1; + zephyr,shell-uart = &uart1; + zephyr,sram = &sram0; + }; +}; + +&uart1 { + current-speed = <115200>; + status = "okay"; +}; + +&uart2 { + current-speed = <115200>; + status = "okay"; +}; diff --git a/boards/phytium/d2000_demo/d2000_demo.yaml b/boards/phytium/d2000_demo/d2000_demo.yaml new file mode 100644 index 00000000000..88ef06e759f --- /dev/null +++ b/boards/phytium/d2000_demo/d2000_demo.yaml @@ -0,0 +1,7 @@ +identifier: d2000_demo +name: Phytium d2000 demo +type: mcu +arch: arm64 +toolchain: + - zephyr + - cross-compile diff --git a/boards/phytium/d2000_demo/d2000_demo_defconfig b/boards/phytium/d2000_demo/d2000_demo_defconfig new file mode 100644 index 00000000000..f816f41440e --- /dev/null +++ b/boards/phytium/d2000_demo/d2000_demo_defconfig @@ -0,0 +1,33 @@ +# SPDX-License-Identifier: Apache-2.0 + +# Platform Configuration +CONFIG_ARM64_VA_BITS_42=y +CONFIG_ARM64_PA_BITS_42=y +# Main stack size +CONFIG_MAIN_STACK_SIZE=8192 + +CONFIG_ARMV8_A_NS=y + +# Zephyr Kernel Configuration +CONFIG_XIP=n +CONFIG_FLASH_SIZE=0 +CONFIG_FLASH_BASE_ADDRESS=0x0 + +# Serial Drivers +CONFIG_SERIAL=y + +# Enable Console +CONFIG_CONSOLE=y +CONFIG_UART_CONSOLE=y + + +# Timer Drivers +CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME=y + + +#cache +CONFIG_CACHE_MANAGEMENT=y + +# PSCI is supported with NS +CONFIG_PM_CPU_OPS=y +CONFIG_PM_CPU_OPS_PSCI=y diff --git a/boards/phytium/d2000_demo_smp/Kconfig.d2000_demo_smp b/boards/phytium/d2000_demo_smp/Kconfig.d2000_demo_smp new file mode 100644 index 00000000000..271c7362ca8 --- /dev/null +++ b/boards/phytium/d2000_demo_smp/Kconfig.d2000_demo_smp @@ -0,0 +1,18 @@ +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +# +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# https://opensource.org/license/apache-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. + +config BOARD_D2000_DEMO_SMP + bool "phytium d2000" + select SOC_D2000 diff --git a/boards/phytium/d2000_demo_smp/Kconfig.defconfig b/boards/phytium/d2000_demo_smp/Kconfig.defconfig new file mode 100644 index 00000000000..f42f153b533 --- /dev/null +++ b/boards/phytium/d2000_demo_smp/Kconfig.defconfig @@ -0,0 +1,19 @@ +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +# +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# https://opensource.org/license/apache-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. + + +config BOARD + default "Phytium d2000 demo" + depends on BOARD_D2000_DEMO_SMP diff --git a/boards/phytium/d2000_demo_smp/board.cmake b/boards/phytium/d2000_demo_smp/board.cmake new file mode 100644 index 00000000000..9881313609a --- /dev/null +++ b/boards/phytium/d2000_demo_smp/board.cmake @@ -0,0 +1 @@ +# SPDX-License-Identifier: Apache-2.0 diff --git a/boards/phytium/d2000_demo_smp/board.yml b/boards/phytium/d2000_demo_smp/board.yml new file mode 100644 index 00000000000..9029c67e04a --- /dev/null +++ b/boards/phytium/d2000_demo_smp/board.yml @@ -0,0 +1,5 @@ +board: + name: d2000_demo_smp + vendor: arm64 + socs: + - name: phytium_d2000 \ No newline at end of file diff --git a/boards/phytium/d2000_demo_smp/d2000_demo_smp.dts b/boards/phytium/d2000_demo_smp/d2000_demo_smp.dts new file mode 100644 index 00000000000..c679cdd7269 --- /dev/null +++ b/boards/phytium/d2000_demo_smp/d2000_demo_smp.dts @@ -0,0 +1,37 @@ +/* + * Copyright 2024 zhangyan + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; + +#include +/ { + model = "Phytium d2000 demo"; + compatible = "phytium,d2000-demo", "phytium,d2000"; + #address-cells = <2>; + #size-cells = <2>; + + psci { + compatible = "arm,psci-0.2"; + method = "smc"; + }; + +chosen { + zephyr,console = &uart1; + zephyr,shell-uart = &uart1; + zephyr,sram = &sram0; + }; +}; + +&uart1 { + status = "okay"; + current-speed = <115200>; +}; + +&uart2 { + status = "okay"; + current-speed = <115200>; +}; + diff --git a/boards/phytium/d2000_demo_smp/d2000_demo_smp.yaml b/boards/phytium/d2000_demo_smp/d2000_demo_smp.yaml new file mode 100644 index 00000000000..5f7d415126b --- /dev/null +++ b/boards/phytium/d2000_demo_smp/d2000_demo_smp.yaml @@ -0,0 +1,9 @@ +identifier: d2000_demo +name: Phytium d2000 demo +type: mcu +arch: arm64 +toolchain: + - zephyr + - cross-compile +supported: + - smp \ No newline at end of file diff --git a/boards/phytium/d2000_demo_smp/d2000_demo_smp_defconfig b/boards/phytium/d2000_demo_smp/d2000_demo_smp_defconfig new file mode 100644 index 00000000000..2896228ec7e --- /dev/null +++ b/boards/phytium/d2000_demo_smp/d2000_demo_smp_defconfig @@ -0,0 +1,41 @@ +# SPDX-License-Identifier: Apache-2.0 + +# Platform Configuration +CONFIG_ARM64_VA_BITS_42=y +CONFIG_ARM64_PA_BITS_42=y +# Main stack size +CONFIG_MAIN_STACK_SIZE=4096 + +CONFIG_ARMV8_A_NS=y + +# Zephyr Kernel Configuration +CONFIG_XIP=n +CONFIG_FLASH_SIZE=0 +CONFIG_FLASH_BASE_ADDRESS=0x0 + +# Serial Drivers +CONFIG_SERIAL=y + +# Enable Console +CONFIG_CONSOLE=y +CONFIG_UART_CONSOLE=y + +#cache +CONFIG_CACHE_MANAGEMENT=y + +# Timer Drivers +CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME=y + +# PSCI is supported with NS +CONFIG_PM_CPU_OPS=y +CONFIG_PM_CPU_OPS_PSCI=y + +# SMP-related +CONFIG_SMP=y +CONFIG_MP_MAX_NUM_CPUS=8 +CONFIG_TIMEOUT_64BIT=y + +# CONFIG_SHELL=y +# CONFIG_SHELL_BACKEND_SERIAL_INTERRUPT_DRIVEN=n +# CONFIG_SHELL_BACKEND_SERIAL_RX_POLL_PERIOD=1 +# CONFIG_BOOT_BANNER=n diff --git a/boards/phytium/d3000_demo/Kconfig.d3000_demo b/boards/phytium/d3000_demo/Kconfig.d3000_demo new file mode 100644 index 00000000000..2d00a9c69e5 --- /dev/null +++ b/boards/phytium/d3000_demo/Kconfig.d3000_demo @@ -0,0 +1,18 @@ +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +# +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# https://opensource.org/license/apache-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. + +config BOARD_D3000_DEMO + bool "phytium d3000" + select SOC_D3000 diff --git a/boards/phytium/d3000_demo/Kconfig.defconfig b/boards/phytium/d3000_demo/Kconfig.defconfig new file mode 100644 index 00000000000..96f810154c3 --- /dev/null +++ b/boards/phytium/d3000_demo/Kconfig.defconfig @@ -0,0 +1,19 @@ +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +# +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# https://opensource.org/license/apache-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. + + +config BOARD + default "Phytium d3000 demo" + depends on BOARD_D3000_DEMO diff --git a/boards/phytium/d3000_demo/board.cmake b/boards/phytium/d3000_demo/board.cmake new file mode 100644 index 00000000000..9881313609a --- /dev/null +++ b/boards/phytium/d3000_demo/board.cmake @@ -0,0 +1 @@ +# SPDX-License-Identifier: Apache-2.0 diff --git a/boards/phytium/d3000_demo/board.yml b/boards/phytium/d3000_demo/board.yml new file mode 100644 index 00000000000..dcde87d08c2 --- /dev/null +++ b/boards/phytium/d3000_demo/board.yml @@ -0,0 +1,5 @@ +board: + name: d3000_demo + vendor: arm64 + socs: + - name: phytium_d3000 \ No newline at end of file diff --git a/boards/phytium/d3000_demo/d3000_demo.dts b/boards/phytium/d3000_demo/d3000_demo.dts new file mode 100644 index 00000000000..9e367314f12 --- /dev/null +++ b/boards/phytium/d3000_demo/d3000_demo.dts @@ -0,0 +1,27 @@ +/* + * Copyright 2024 zhangyan + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; +#include + +/ { + model = "Phytium d3000 demo"; + compatible = "phytium,d3000-demo", "phytium,d3000"; + #address-cells = <2>; + #size-cells = <2>; + +chosen { + zephyr,console = &uart1; + zephyr,shell-uart = &uart1; + zephyr,sram = &sram0; + }; +}; + +&uart1 { + current-speed = <115200>; + status = "okay"; +}; + diff --git a/boards/phytium/d3000_demo/d3000_demo.yaml b/boards/phytium/d3000_demo/d3000_demo.yaml new file mode 100644 index 00000000000..a96439bbb3c --- /dev/null +++ b/boards/phytium/d3000_demo/d3000_demo.yaml @@ -0,0 +1,10 @@ + +identifier: d3000_demo +name: Phytium d3000 demo +type: mcu +arch: arm64 +toolchain: + - zephyr + - cross-compile +supported: + - smp diff --git a/boards/phytium/d3000_demo/d3000_demo_defconfig b/boards/phytium/d3000_demo/d3000_demo_defconfig new file mode 100644 index 00000000000..f816f41440e --- /dev/null +++ b/boards/phytium/d3000_demo/d3000_demo_defconfig @@ -0,0 +1,33 @@ +# SPDX-License-Identifier: Apache-2.0 + +# Platform Configuration +CONFIG_ARM64_VA_BITS_42=y +CONFIG_ARM64_PA_BITS_42=y +# Main stack size +CONFIG_MAIN_STACK_SIZE=8192 + +CONFIG_ARMV8_A_NS=y + +# Zephyr Kernel Configuration +CONFIG_XIP=n +CONFIG_FLASH_SIZE=0 +CONFIG_FLASH_BASE_ADDRESS=0x0 + +# Serial Drivers +CONFIG_SERIAL=y + +# Enable Console +CONFIG_CONSOLE=y +CONFIG_UART_CONSOLE=y + + +# Timer Drivers +CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME=y + + +#cache +CONFIG_CACHE_MANAGEMENT=y + +# PSCI is supported with NS +CONFIG_PM_CPU_OPS=y +CONFIG_PM_CPU_OPS_PSCI=y diff --git a/boards/phytium/d3000_demo_smp/Kconfig.d3000_demo_smp b/boards/phytium/d3000_demo_smp/Kconfig.d3000_demo_smp new file mode 100644 index 00000000000..7544f39d609 --- /dev/null +++ b/boards/phytium/d3000_demo_smp/Kconfig.d3000_demo_smp @@ -0,0 +1,18 @@ +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +# +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# https://opensource.org/license/apache-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. + +config BOARD_D3000_DEMO_SMP + bool "phytium d3000" + select SOC_D3000 diff --git a/boards/phytium/d3000_demo_smp/Kconfig.defconfig b/boards/phytium/d3000_demo_smp/Kconfig.defconfig new file mode 100644 index 00000000000..8d30845b111 --- /dev/null +++ b/boards/phytium/d3000_demo_smp/Kconfig.defconfig @@ -0,0 +1,19 @@ +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +# +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# https://opensource.org/license/apache-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. + + +config BOARD + default "Phytium d3000 demo" + depends on BOARD_D3000_DEMO_SMP diff --git a/boards/phytium/d3000_demo_smp/board.cmake b/boards/phytium/d3000_demo_smp/board.cmake new file mode 100644 index 00000000000..9881313609a --- /dev/null +++ b/boards/phytium/d3000_demo_smp/board.cmake @@ -0,0 +1 @@ +# SPDX-License-Identifier: Apache-2.0 diff --git a/boards/phytium/d3000_demo_smp/board.yml b/boards/phytium/d3000_demo_smp/board.yml new file mode 100644 index 00000000000..8124178fd98 --- /dev/null +++ b/boards/phytium/d3000_demo_smp/board.yml @@ -0,0 +1,5 @@ +board: + name: d3000_demo_smp + vendor: arm64 + socs: + - name: phytium_d3000 \ No newline at end of file diff --git a/boards/phytium/d3000_demo_smp/d3000_demo_smp.dts b/boards/phytium/d3000_demo_smp/d3000_demo_smp.dts new file mode 100644 index 00000000000..fa1b9bb2cec --- /dev/null +++ b/boards/phytium/d3000_demo_smp/d3000_demo_smp.dts @@ -0,0 +1,32 @@ +/* + * Copyright 2024 zhangyan + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; + +#include +/ { + model = "Phytium d3000 demo"; + compatible = "phytium,d3000-demo", "phytium,d3000"; + #address-cells = <2>; + #size-cells = <2>; + + psci { + compatible = "arm,psci-0.2"; + method = "smc"; + }; + +chosen { + zephyr,console = &uart1; + zephyr,shell-uart = &uart1; + zephyr,sram = &sram0; + }; +}; + +&uart1 { + status = "okay"; + current-speed = <115200>; +}; + diff --git a/boards/phytium/d3000_demo_smp/d3000_demo_smp.yaml b/boards/phytium/d3000_demo_smp/d3000_demo_smp.yaml new file mode 100644 index 00000000000..a96439bbb3c --- /dev/null +++ b/boards/phytium/d3000_demo_smp/d3000_demo_smp.yaml @@ -0,0 +1,10 @@ + +identifier: d3000_demo +name: Phytium d3000 demo +type: mcu +arch: arm64 +toolchain: + - zephyr + - cross-compile +supported: + - smp diff --git a/boards/phytium/d3000_demo_smp/d3000_demo_smp_defconfig b/boards/phytium/d3000_demo_smp/d3000_demo_smp_defconfig new file mode 100644 index 00000000000..2896228ec7e --- /dev/null +++ b/boards/phytium/d3000_demo_smp/d3000_demo_smp_defconfig @@ -0,0 +1,41 @@ +# SPDX-License-Identifier: Apache-2.0 + +# Platform Configuration +CONFIG_ARM64_VA_BITS_42=y +CONFIG_ARM64_PA_BITS_42=y +# Main stack size +CONFIG_MAIN_STACK_SIZE=4096 + +CONFIG_ARMV8_A_NS=y + +# Zephyr Kernel Configuration +CONFIG_XIP=n +CONFIG_FLASH_SIZE=0 +CONFIG_FLASH_BASE_ADDRESS=0x0 + +# Serial Drivers +CONFIG_SERIAL=y + +# Enable Console +CONFIG_CONSOLE=y +CONFIG_UART_CONSOLE=y + +#cache +CONFIG_CACHE_MANAGEMENT=y + +# Timer Drivers +CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME=y + +# PSCI is supported with NS +CONFIG_PM_CPU_OPS=y +CONFIG_PM_CPU_OPS_PSCI=y + +# SMP-related +CONFIG_SMP=y +CONFIG_MP_MAX_NUM_CPUS=8 +CONFIG_TIMEOUT_64BIT=y + +# CONFIG_SHELL=y +# CONFIG_SHELL_BACKEND_SERIAL_INTERRUPT_DRIVEN=n +# CONFIG_SHELL_BACKEND_SERIAL_RX_POLL_PERIOD=1 +# CONFIG_BOOT_BANNER=n diff --git a/boards/phytium/e2000q_demo/CMakeLists.txt b/boards/phytium/e2000q_demo/CMakeLists.txt new file mode 100644 index 00000000000..9881313609a --- /dev/null +++ b/boards/phytium/e2000q_demo/CMakeLists.txt @@ -0,0 +1 @@ +# SPDX-License-Identifier: Apache-2.0 diff --git a/boards/phytium/e2000q_demo/Kconfig.defconfig b/boards/phytium/e2000q_demo/Kconfig.defconfig new file mode 100644 index 00000000000..c91698970a1 --- /dev/null +++ b/boards/phytium/e2000q_demo/Kconfig.defconfig @@ -0,0 +1,28 @@ +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +# +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# https://opensource.org/license/apache-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. + + +config BOARD + default "Phytium e2000q demo" + depends on BOARD_E2000Q_DEMO + +if NETWORKING + +config NET_L2_ETHERNET + default y + + + +endif # NETWORKING diff --git a/boards/phytium/e2000q_demo/Kconfig.e2000q_demo b/boards/phytium/e2000q_demo/Kconfig.e2000q_demo new file mode 100644 index 00000000000..8168955e270 --- /dev/null +++ b/boards/phytium/e2000q_demo/Kconfig.e2000q_demo @@ -0,0 +1,18 @@ +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +# +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# https://opensource.org/license/apache-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. + +config BOARD_E2000Q_DEMO + bool "phytium e2000q" + select SOC_E2000Q diff --git a/boards/phytium/e2000q_demo/board.cmake b/boards/phytium/e2000q_demo/board.cmake new file mode 100644 index 00000000000..9881313609a --- /dev/null +++ b/boards/phytium/e2000q_demo/board.cmake @@ -0,0 +1 @@ +# SPDX-License-Identifier: Apache-2.0 diff --git a/boards/phytium/e2000q_demo/board.yml b/boards/phytium/e2000q_demo/board.yml new file mode 100644 index 00000000000..9f5a0cb0baa --- /dev/null +++ b/boards/phytium/e2000q_demo/board.yml @@ -0,0 +1,5 @@ +board: + name: e2000q_demo + vendor: arm64 + socs: + - name: phytium_e2000q \ No newline at end of file diff --git a/boards/phytium/e2000q_demo/e2000q_demo.dts b/boards/phytium/e2000q_demo/e2000q_demo.dts new file mode 100644 index 00000000000..50dfaa539bc --- /dev/null +++ b/boards/phytium/e2000q_demo/e2000q_demo.dts @@ -0,0 +1,54 @@ +/* + * Copyright 2024 zhangyan + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; +#include +#include "e2000q_pinctrl.dtsi" + +/ { + model = "Phytium e2000q demo"; + compatible = "phytium,e2000q-demo", "phytium,e2000q"; + #address-cells = <2>; + #size-cells = <2>; + +chosen { + zephyr,console = &uart1; + zephyr,shell-uart = &uart1; + zephyr,sram = &sram0; + zephyr,pcie-controller = &pcie0; + }; +}; + +&sdhc1 { + status = "okay"; + sdmmc { + compatible = "zephyr,sdmmc-disk"; + status = "okay"; + }; +}; + +&xmac0 { + status = "okay"; + local-mac-address = [00 00 00 01 02 03]; +}; + +&uart1 { + current-speed = <115200>; + pinctrl-0 = <&uart1_rx_default &uart1_tx_default>; + pinctrl-names = "default"; + status = "okay"; +}; + +&uart2 { + current-speed = <115200>; + pinctrl-0 = <&uart2_rx_default &uart2_tx_default>; + pinctrl-names = "default"; + status = "okay"; +}; + +&pcie0 { + status = "okay"; +}; diff --git a/boards/phytium/e2000q_demo/e2000q_demo.yaml b/boards/phytium/e2000q_demo/e2000q_demo.yaml new file mode 100644 index 00000000000..115d5cdfd56 --- /dev/null +++ b/boards/phytium/e2000q_demo/e2000q_demo.yaml @@ -0,0 +1,7 @@ +identifier: e2000q_demo +name: Phytium e2000q demo +type: mcu +arch: arm64 +toolchain: + - zephyr + - cross-compile diff --git a/boards/phytium/e2000q_demo/e2000q_demo_defconfig b/boards/phytium/e2000q_demo/e2000q_demo_defconfig new file mode 100644 index 00000000000..e6578193dfa --- /dev/null +++ b/boards/phytium/e2000q_demo/e2000q_demo_defconfig @@ -0,0 +1,33 @@ +# SPDX-License-Identifier: Apache-2.0 + +# Platform Configuration +CONFIG_ARM64_VA_BITS_42=y +CONFIG_ARM64_PA_BITS_42=y +# Main stack size +CONFIG_MAIN_STACK_SIZE=4096 + +CONFIG_ARMV8_A_NS=y + +# Zephyr Kernel Configuration +CONFIG_XIP=n +CONFIG_FLASH_SIZE=0 +CONFIG_FLASH_BASE_ADDRESS=0x0 + +# Serial Drivers +CONFIG_SERIAL=y + +# Enable Console +CONFIG_CONSOLE=y +CONFIG_UART_CONSOLE=y + + +# Timer Drivers +CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME=y + + +#cache +CONFIG_CACHE_MANAGEMENT=y + +# PSCI is supported with NS +CONFIG_PM_CPU_OPS=y +CONFIG_PM_CPU_OPS_PSCI=y diff --git a/boards/phytium/e2000q_demo/e2000q_pinctrl.dtsi b/boards/phytium/e2000q_demo/e2000q_pinctrl.dtsi new file mode 100644 index 00000000000..c72996bb7fd --- /dev/null +++ b/boards/phytium/e2000q_demo/e2000q_pinctrl.dtsi @@ -0,0 +1,19 @@ + + +#include + +&pinctrl { + uart1_rx_default: uart1_rx_default { + pinmux = ; + }; + uart1_tx_default: uart1_tx_default { + pinmux = ; + }; + + uart2_rx_default: uart2_rx_default { + pinmux = ; + }; + uart2_tx_default: uart2_tx_default { + pinmux = ; + }; +}; \ No newline at end of file diff --git a/boards/phytium/e2000q_demo_smp/Kconfig.defconfig b/boards/phytium/e2000q_demo_smp/Kconfig.defconfig new file mode 100644 index 00000000000..5d80fa7868f --- /dev/null +++ b/boards/phytium/e2000q_demo_smp/Kconfig.defconfig @@ -0,0 +1,19 @@ +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +# +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# https://opensource.org/license/apache-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. + + +config BOARD + default "Phytium e2000q demo" + depends on BOARD_E2000Q_DEMO_SMP diff --git a/boards/phytium/e2000q_demo_smp/Kconfig.e2000q_demo_smp b/boards/phytium/e2000q_demo_smp/Kconfig.e2000q_demo_smp new file mode 100644 index 00000000000..13ef5e49ed7 --- /dev/null +++ b/boards/phytium/e2000q_demo_smp/Kconfig.e2000q_demo_smp @@ -0,0 +1,18 @@ +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +# +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# https://opensource.org/license/apache-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. + +config BOARD_E2000Q_DEMO_SMP + bool "phytium e2000q" + select SOC_E2000Q diff --git a/boards/phytium/e2000q_demo_smp/board.cmake b/boards/phytium/e2000q_demo_smp/board.cmake new file mode 100644 index 00000000000..9881313609a --- /dev/null +++ b/boards/phytium/e2000q_demo_smp/board.cmake @@ -0,0 +1 @@ +# SPDX-License-Identifier: Apache-2.0 diff --git a/boards/phytium/e2000q_demo_smp/board.yml b/boards/phytium/e2000q_demo_smp/board.yml new file mode 100644 index 00000000000..664d0cffa3e --- /dev/null +++ b/boards/phytium/e2000q_demo_smp/board.yml @@ -0,0 +1,5 @@ +board: + name: e2000q_demo_smp + vendor: arm64 + socs: + - name: phytium_e2000q \ No newline at end of file diff --git a/boards/phytium/e2000q_demo_smp/e2000q_demo_smp.dts b/boards/phytium/e2000q_demo_smp/e2000q_demo_smp.dts new file mode 100644 index 00000000000..fff1f97392a --- /dev/null +++ b/boards/phytium/e2000q_demo_smp/e2000q_demo_smp.dts @@ -0,0 +1,49 @@ +/* + * Copyright 2024 zhangyan + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; + +#include +/ { + model = "Phytium e2000q demo"; + compatible = "phytium,e2000q-demo", "phytium,e2000q"; + #address-cells = <2>; + #size-cells = <2>; + + psci { + compatible = "arm,psci-0.2"; + method = "smc"; + }; + +chosen { + zephyr,console = &uart1; + zephyr,shell-uart = &uart1; + zephyr,sram = &sram0; + }; +}; + +&sdhc1 { + status = "okay"; + sdmmc { + compatible = "zephyr,sdmmc-disk"; + status = "okay"; + }; +}; + +&uart1 { + status = "okay"; + current-speed = <115200>; +}; + +&uart2 { + status = "okay"; + current-speed = <115200>; +}; + +&xmac0 { + status = "okay"; + local-mac-address = [00 00 00 01 02 03]; +}; diff --git a/boards/phytium/e2000q_demo_smp/e2000q_demo_smp.yaml b/boards/phytium/e2000q_demo_smp/e2000q_demo_smp.yaml new file mode 100644 index 00000000000..c3562a9b4c4 --- /dev/null +++ b/boards/phytium/e2000q_demo_smp/e2000q_demo_smp.yaml @@ -0,0 +1,9 @@ +identifier: e2000q_demo +name: Phytium e2000q demo +type: mcu +arch: arm64 +toolchain: + - zephyr + - cross-compile +supported: + - smp \ No newline at end of file diff --git a/boards/phytium/e2000q_demo_smp/e2000q_demo_smp_defconfig b/boards/phytium/e2000q_demo_smp/e2000q_demo_smp_defconfig new file mode 100644 index 00000000000..20660c4b1d2 --- /dev/null +++ b/boards/phytium/e2000q_demo_smp/e2000q_demo_smp_defconfig @@ -0,0 +1,41 @@ +# SPDX-License-Identifier: Apache-2.0 + +# Platform Configuration +CONFIG_ARM64_VA_BITS_42=y +CONFIG_ARM64_PA_BITS_42=y +# Main stack size +CONFIG_MAIN_STACK_SIZE=4096 + +CONFIG_ARMV8_A_NS=y + +# Zephyr Kernel Configuration +CONFIG_XIP=n +CONFIG_FLASH_SIZE=0 +CONFIG_FLASH_BASE_ADDRESS=0x0 + +# Serial Drivers +CONFIG_SERIAL=y + +# Enable Console +CONFIG_CONSOLE=y +CONFIG_UART_CONSOLE=y + +#cache +CONFIG_CACHE_MANAGEMENT=y + +# Timer Drivers +CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME=y + +# PSCI is supported with NS +CONFIG_PM_CPU_OPS=y +CONFIG_PM_CPU_OPS_PSCI=y + +# SMP-related +CONFIG_SMP=y +CONFIG_MP_MAX_NUM_CPUS=4 +CONFIG_TIMEOUT_64BIT=y + +# CONFIG_SHELL=y +# CONFIG_SHELL_BACKEND_SERIAL_INTERRUPT_DRIVEN=n +# CONFIG_SHELL_BACKEND_SERIAL_RX_POLL_PERIOD=1 +# CONFIG_BOOT_BANNER=n diff --git a/boards/phytium/index.rst b/boards/phytium/index.rst new file mode 100644 index 00000000000..0595bf57122 --- /dev/null +++ b/boards/phytium/index.rst @@ -0,0 +1,10 @@ +.. _boards-aspeed: + +PHYTIUM +####### + +.. toctree:: + :maxdepth: 1 + :glob: + + **/* diff --git a/cmake/gcc-m-cpu.cmake b/cmake/gcc-m-cpu.cmake index 8cb777c4769..307b8848f5f 100644 --- a/cmake/gcc-m-cpu.cmake +++ b/cmake/gcc-m-cpu.cmake @@ -77,6 +77,8 @@ if("${ARCH}" STREQUAL "arm") endif() elseif(CONFIG_CPU_CORTEX_A9) set(GCC_M_CPU cortex-a9) + elseif(CONFIG_CPU_PHYTIUM_FT310) + set(GCC_M_CPU cortex-a9) else() message(FATAL_ERROR "Expected CONFIG_CPU_CORTEX_x to be defined") endif() diff --git a/cmake/gcc-m-fpu.cmake b/cmake/gcc-m-fpu.cmake index a25cdf05679..163ff890c32 100644 --- a/cmake/gcc-m-fpu.cmake +++ b/cmake/gcc-m-fpu.cmake @@ -23,6 +23,12 @@ if("${ARCH}" STREQUAL "arm") set(GCC_M_FPU fpv5-sp-d16) endif() endif() + elseif(CONFIG_CPU_CORTEX_A9) + if(CONFIG_VFP_FEATURE_DOUBLE_PRECISION) + set(GCC_M_FPU neon-fp-armv8) + elseif(CONFIG_VFP_FEATURE_SINGLE_PRECISION) + set(GCC_M_FPU fpv5-sp-d16) + endif() elseif(CONFIG_CPU_CORTEX_M) # Defines a mapping from GCC_M_CPU to FPU if(CONFIG_CPU_HAS_FPU_DOUBLE_PRECISION) @@ -45,6 +51,12 @@ if("${ARCH}" STREQUAL "arm") set(FPU_FOR_cortex-m85+nodsp auto) set(GCC_M_FPU ${FPU_FOR_${GCC_M_CPU}}) + else() + if(CONFIG_VFP_FEATURE_DOUBLE_PRECISION) + set(GCC_M_FPU neon-fp-armv8) + elseif(CONFIG_VFP_FEATURE_SINGLE_PRECISION) + set(GCC_M_FPU fpv5-sp-d16) + endif() endif() endif() diff --git a/drivers/ethernet/CMakeLists.txt b/drivers/ethernet/CMakeLists.txt index 02b8f96bc9b..64ec4e8bb4f 100644 --- a/drivers/ethernet/CMakeLists.txt +++ b/drivers/ethernet/CMakeLists.txt @@ -40,6 +40,7 @@ zephyr_library_sources_ifdef(CONFIG_ETH_IVSHMEM eth_ivshmem.c eth_ivshmem_queue zephyr_library_sources_ifdef(CONFIG_ETH_ADIN2111 eth_adin2111.c) zephyr_library_sources_ifdef(CONFIG_ETH_LAN865X eth_lan865x.c oa_tc6.c) zephyr_library_sources_ifdef(CONFIG_ETH_XMC4XXX eth_xmc4xxx.c) +zephyr_library_sources_ifdef(CONFIG_ETH_PHYTIUM_XMAC eth_phytium_xmac.c) if(CONFIG_ETH_NXP_S32_NETC) zephyr_library_sources(eth_nxp_s32_netc.c) diff --git a/drivers/ethernet/Kconfig b/drivers/ethernet/Kconfig index f54d659b7c0..0a8d90d4fa2 100644 --- a/drivers/ethernet/Kconfig +++ b/drivers/ethernet/Kconfig @@ -73,6 +73,7 @@ source "drivers/ethernet/Kconfig.adin2111" source "drivers/ethernet/Kconfig.numaker" source "drivers/ethernet/Kconfig.lan865x" source "drivers/ethernet/Kconfig.xmc4xxx" +source "drivers/ethernet/Kconfig.phytium_xmac" source "drivers/ethernet/eth_nxp_enet_qos/Kconfig" diff --git a/drivers/ethernet/Kconfig.phytium_xmac b/drivers/ethernet/Kconfig.phytium_xmac new file mode 100644 index 00000000000..e9d52749210 --- /dev/null +++ b/drivers/ethernet/Kconfig.phytium_xmac @@ -0,0 +1,22 @@ +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +# +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# https://opensource.org/license/apache-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. + +menuconfig ETH_PHYTIUM_XMAC + bool "Phytium ETH_PHYTIUM_XMAC Ethernet driver" + default y + depends on DT_HAS_PHYTIUM_XMAC_ENABLED + help + Enable Phytium XMAC Ethernet driver. + diff --git a/drivers/ethernet/eth_phytium_xmac.c b/drivers/ethernet/eth_phytium_xmac.c new file mode 100644 index 00000000000..3038adba0b5 --- /dev/null +++ b/drivers/ethernet/eth_phytium_xmac.c @@ -0,0 +1,1467 @@ +// Phytium is pleased to support the open source community by making Zephyr-SDK available. + +// +// Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +// +// Licensed under the Apache-2.0 License (the "License"); you may not use this file except +// in compliance with the License. You may obtain a copy of the License at +// +// https://opensource.org/license/apache-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 "fxmac.h" +#include "fxmac_hw.h" +#include "fxmac_bdring.h" +#include "fxmac_phy.h" +#include "eth_ieee_reg.h" +#include "eth_phytium_xmac.h" + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + + + +#define LOG_MODULE_NAME phytium_xmac +#define LOG_LEVEL CONFIG_ETHERNET_LOG_LEVEL +#include +LOG_MODULE_REGISTER(LOG_MODULE_NAME); + +#define DT_DRV_COMPAT phytium_xmac + + +/* dma buffer */ +#define ETH_PHYTIUM_BDL_ALIGNMENT 256 +#define ETH_PHYTIUM_BUFFER_ALIGNMENT ETH_PHYTIUM_BDL_ALIGNMENT +#define ETH_ALIGNMENT_OFFSET_DEFINED(buffer_size) ((buffer_size\ + + (ETH_PHYTIUM_BUFFER_ALIGNMENT - 1))\ + & ~(ETH_PHYTIUM_BUFFER_ALIGNMENT - 1)) + + +/* IRQ handler function type */ +typedef void (*eth_phytiium_xmac_config_irq_t)(const struct device *dev); + +typedef enum +{ + FXMAC_LWIP_PORT_INTERFACE_SGMII = 0, + FXMAC_LWIP_PORT_INTERFACE_RMII, + FXMAC_LWIP_PORT_INTERFACE_RGMII, + FXMAC_LWIP_PORT_INTERFACE_USXGMII, + FXMAC_LWIP_PORT_INTERFACE_LENGTH +} FXmacLwipPortInterface; + + +#define FXMAC_PHY_SPEED_10M 10 +#define FXMAC_PHY_SPEED_100M 100 +#define FXMAC_PHY_SPEED_1000M 1000 +#define FXMAC_PHY_SPEED_10G 10000 + + +/* phy link */ +enum eth_phytium_link_speed { + /* The values of this enum are consecutively numbered */ + LINK_DOWN = 0, + LINK_10MBIT, + LINK_100MBIT, + LINK_1GBIT +}; + +#define FXMAC_BD_TO_INDEX(ringptr, bdptr) \ + (((uintptr)bdptr - (uintptr)(ringptr)->base_bd_addr) / (ringptr)->separation) + +struct eth_phytium_xmac_dev_cfg { + DEVICE_MMIO_ROM; + uint32_t instance_id ; /* */ + eth_phytiium_xmac_config_irq_t config_func; + uint32_t pll_clock_frequency; + + uint32_t phy_poll_interval; + uint8_t defer_rxp_to_queue; + uint8_t defer_txd_to_queue; + + uint8_t rxbd_count; /* rx bdl count */ + uint8_t txbd_count; /* tx bdl count */ + uint16_t rx_buffer_size; /* per buffer size */ + uint16_t tx_buffer_size; + + /* dtc defined */ + uint32_t phy_speed ; /* FXMAC_PHY_SPEED_XX */ + uint32_t interface_mode ; /* followed by FXmacLwipPortInterface */ + uint32_t dma_brust_length ; + uint32_t max_queue_num; /* Number of Xmac Controller Queues */ + bool phy_autonegotiation : 1 ; + bool enable_fdx : 1 ; + bool enable_jumbo : 1; + bool enable_ucast_hash :1; + bool copy_all_frames :1; + bool disable_reject_fcs_crc_errors:1; + bool enable_mcast_hash :1; + +}; + + +struct eth_phytium_xmac_dev_data { + DEVICE_MMIO_RAM; /* used for controller base address */ + struct net_if *iface; + FXmac instance ; + uint8_t mac_addr[6]; + enum eth_phytium_link_speed eff_link_speed ; + struct k_work tx_done_work; + struct k_work rx_pend_work; + struct k_sem tx_done_sem; + + struct k_sem ring_sem; + + uint8_t phy_addr; + uint32_t phy_id; + struct k_work_delayable phy_poll_delayed_work; + +#ifdef CONFIG_NET_STATISTICS_ETHERNET + struct net_stats_eth stats; +#endif + + uint8_t *rx_bdspace ; + uint8_t *rx_bdspace_virt ; + uint8_t *tx_bdspace ; + uint8_t *tx_bdspace_virt ; + + uint8_t *first_rx_buffer ; + uint8_t *first_rx_buffer_virt ; + uint8_t *first_tx_buffer ; + uint8_t *first_tx_buffer_virt ; + + bool started; +}; + + +static int eth_phytium_xmac_dev_init(const struct device *dev) ; +static void eth_phytium_xmac_iface_init(struct net_if *iface) ; +static enum ethernet_hw_caps eth_phytium_xmac_get_capabilities(const struct device *dev) ; +static int eth_phytium_xmac_send(const struct device *dev, struct net_pkt *pkt) ; +static int eth_phytium_xmac_start_device(const struct device *dev) ; +static int eth_phytium_xmac_stop_device(const struct device *dev) ; +#ifdef CONFIG_NET_STATISTICS_ETHERNET +static struct net_stats_eth *eth_phytium_xmac_stats(const struct device *dev) ; +#endif + +static void eth_phytium_xmac_isr(const struct device *dev) ; + +static const struct ethernet_api eth_phytium_xmac_apis = { + .iface_api.init = eth_phytium_xmac_iface_init, + .get_capabilities = eth_phytium_xmac_get_capabilities, + .send = eth_phytium_xmac_send, + .start = eth_phytium_xmac_start_device, + .stop = eth_phytium_xmac_stop_device, +#if defined(CONFIG_NET_STATISTICS_ETHERNET) + .get_stats = eth_phytium_xmac_stats, +#endif +}; + + +/* + * Insert the configuration & run-time data for all GEM instances which + * are enabled in the device tree of the current target board. + */ +DT_INST_FOREACH_STATUS_OKAY(ETH_PHYTIUM_XMAC_INITIALIZE) + + +static void FXmacSetupIsr(const struct device *dev) ; + +static uint32_t phy_autoneg_status(FXmac *xmac_p, uint32_t phy_addr) +{ + u16 status; + + /* Read Phy Status register twice to get the confirmation of the current + * link status. + */ + FXmacPhyRead(xmac_p, phy_addr, PHY_STATUS_REG_OFFSET, &status); + + if (status & PHY_STATUS_AUTONEGOTIATE_COMPLETE) + return 1; + return 0; +} + +/** + * @name: phy_link_detect + * @msg: Get current link status + * @note: + * @param {FXmac} *fxmac_p + * @param {u32} phy_addr + * @return {*} 1 is link up , 0 is link down + */ +static u32 phy_link_detect(FXmac *xmac_p, u32 phy_addr) +{ + u16 status; + + /* Read Phy Status register twice to get the confirmation of the current + * link status. + */ + + FXmacPhyRead(xmac_p, phy_addr, PHY_STATUS_REG_OFFSET, &status); + + if (status & PHY_STAT_LINK_STATUS) + return 1; + return 0; +} + +FXmacLinkStatus FXmacRgmiiLinkDetect(const struct device *dev) +{ + struct eth_phytium_xmac_dev_data *dev_data = (struct eth_phytium_xmac_dev_data *)dev->data ; + FXmac *instance_p; + instance_p = &dev_data->instance; + + u32 phy_link_status; + + + phy_link_status = phy_link_detect(instance_p, instance_p->phy_address); + + if ((instance_p->link_status == FXMAC_LINKUP) && (!phy_link_status)) + instance_p->link_status = FXMAC_LINKDOWN; + + switch (instance_p->link_status) + { + case FXMAC_LINKUP: + return FXMAC_LINKUP; + case FXMAC_LINKDOWN: + instance_p->link_status = FXMAC_NEGOTIATING; + LOG_DBG("Ethernet Link down"); + return FXMAC_LINKDOWN; + case FXMAC_NEGOTIATING: + if ((phy_link_status == FXMAC_LINKUP) && phy_autoneg_status(instance_p, instance_p->phy_address)) + { + if(FXmacPhyInit(instance_p, instance_p->config.speed, instance_p->config.duplex, instance_p->config.auto_neg, XMAC_PHY_RESET_DISABLE)) + { + return FXMAC_LINKDOWN; + } + + FXmacSelectClk(instance_p); + FXmacInitInterface(instance_p); + + /* Initiate Phy setup to get link speed */ + instance_p->link_status = FXMAC_LINKUP; + LOG_DBG("Ethernet Link up"); + return FXMAC_LINKUP; + } + return FXMAC_LINKDOWN; + default: + return FXMAC_LINKDOWN; + } +} + +FXmacLinkStatus FXmacSgmiiLinkDetect(const struct device *dev) +{ + struct eth_phytium_xmac_dev_data *dev_data = (struct eth_phytium_xmac_dev_data *)dev->data ; + FXmac *instance_p; + u32 ctrl; + u32 link, link_status; + instance_p = &dev_data->instance; + + ctrl = FXMAC_READREG32(instance_p->config.base_address, FXMAC_PCS_AN_LP_OFFSET); + link = (ctrl & FXMAC_PCS_LINK_PARTNER_NEXT_PAGE_STATUS) >> FXMAC_PCS_LINK_PARTNER_NEXT_PAGE_OFFSET; + + switch (link) + { + case 0: + link_status = FXMAC_LINKDOWN; + break; + case 1: + link_status = FXMAC_LINKUP; + break; + default: + LOG_ERR("link status is error 0x%x \r\n", link); + return FXMAC_LINKDOWN; + } + + if (link_status == FXMAC_LINKUP) + { + if (link_status != instance_p->link_status) + { + instance_p->link_status = FXMAC_NEGOTIATING; + LOG_INF("need NEGOTIATING"); + } + } + else + { + instance_p->link_status = FXMAC_LINKDOWN; + } + + if (instance_p->link_status == FXMAC_NEGOTIATING) + { + /* renegotiate */ + if (FXmacPhyInit(instance_p, instance_p->config.speed, instance_p->config.duplex, instance_p->config.auto_neg,XMAC_PHY_RESET_DISABLE)) + { + LOG_ERR("FXmacPhyInit is error \r\n"); + return FXMAC_LINKDOWN; + } + else + { + FXmacSelectClk(instance_p); + FXmacInitInterface(instance_p); + instance_p->link_status = FXMAC_LINKUP; + return FXMAC_LINKUP; + } + } + return instance_p->link_status ; +} + +static void eth_phytium_xmac_poll_phy(struct k_work *work) +{ + struct k_work_delayable *dwork = k_work_delayable_from_work(work); + struct eth_phytium_xmac_dev_data *dev_data = CONTAINER_OF(dwork, + struct eth_phytium_xmac_dev_data, phy_poll_delayed_work); + const struct device *dev = net_if_get_device(dev_data->iface); + const struct eth_phytium_xmac_dev_cfg *dev_conf = dev->config; + FXmacLinkStatus link_status = FXMAC_LINKDOWN ; + FXmac *instance_p; + instance_p = &dev_data->instance; + + if(instance_p->config.interface == FXMAC_PHY_INTERFACE_MODE_SGMII) + { + link_status = FXmacSgmiiLinkDetect(dev) ; + } + else if((instance_p->config.interface == FXMAC_PHY_INTERFACE_MODE_RMII) || (instance_p->config.interface == FXMAC_PHY_INTERFACE_MODE_RGMII)) + { + link_status = FXmacRgmiiLinkDetect(dev) ; + } + + if(link_status == FXMAC_LINKDOWN) + { + dev_data->eff_link_speed = LINK_DOWN; + net_eth_carrier_off(dev_data->iface); + + LOG_WRN("%s link down", dev->name); + } + else if(link_status == FXMAC_LINKUP) + { + switch(instance_p->config.speed) + { + case FXMAC_SPEED_10: + dev_data->eff_link_speed = LINK_10MBIT ; + break ; + case FXMAC_SPEED_100: + dev_data->eff_link_speed = LINK_100MBIT ; + break ; + case FXMAC_SPEED_1000: + dev_data->eff_link_speed = LINK_1GBIT ; + break ; + } + net_eth_carrier_on(dev_data->iface); + } + + k_work_reschedule(&dev_data->phy_poll_delayed_work, + K_MSEC(dev_conf->phy_poll_interval)); + +} + +/** + * @name: eth_phytium_xmac_get_capabilities + * @msg: Reports the hardware capabilities of the Ethernet device, such as supported speeds and duplex modes. + * @param {const struct device} *dev is a pointer to the device structure for the driver instance. + * @return {enum ethernet_hw_caps} A bitmask of supported features defined in `enum ethernet_hw_caps`. + */ +static enum ethernet_hw_caps eth_phytium_xmac_get_capabilities(const struct device *dev) +{ + struct eth_phytium_xmac_dev_cfg *dev_cfg = (struct eth_phytium_xmac_dev_cfg *)dev->config ; + enum ethernet_hw_caps caps = (enum ethernet_hw_caps)0; + + switch (dev_cfg->phy_speed) + { + case FXMAC_PHY_SPEED_10M: + caps |= ETHERNET_LINK_10BASE_T; + break; + case FXMAC_PHY_SPEED_100M: + caps |= (ETHERNET_LINK_100BASE_T | + ETHERNET_LINK_10BASE_T); + break; + case FXMAC_PHY_SPEED_1000M: + caps |= (ETHERNET_LINK_1000BASE_T | + ETHERNET_LINK_100BASE_T | + ETHERNET_LINK_10BASE_T); + break; + case FXMAC_PHY_SPEED_10G: + caps |= (ETHERNET_LINK_1000BASE_T | + ETHERNET_LINK_100BASE_T | + ETHERNET_LINK_10BASE_T); + break; + } + + if (dev_cfg->enable_fdx) { + caps |= ETHERNET_DUPLEX_SET; + } + + if (dev_cfg->copy_all_frames) { + caps |= ETHERNET_PROMISC_MODE; + } + return caps; +} + +static int eth_phytium_xmac_config_convert(struct eth_phytium_xmac_dev_cfg *dev_conf,FXmacConfig *mac_config,uint32_t *options) +{ + *options = 0 ; + switch (dev_conf->interface_mode) + { + case FXMAC_LWIP_PORT_INTERFACE_SGMII: + mac_config->interface = FXMAC_PHY_INTERFACE_MODE_SGMII; + LOG_INF("SGMII select"); + break; + case FXMAC_LWIP_PORT_INTERFACE_RMII: + mac_config->interface = FXMAC_PHY_INTERFACE_MODE_RMII; + LOG_INF("RMII select"); + break; + case FXMAC_LWIP_PORT_INTERFACE_RGMII: + LOG_INF("RGMII select"); + mac_config->interface = FXMAC_PHY_INTERFACE_MODE_RGMII; + break; + case FXMAC_LWIP_PORT_INTERFACE_USXGMII: + LOG_INF("USXGMII select"); + mac_config->interface = FXMAC_PHY_INTERFACE_MODE_USXGMII; + break; + default: + return -EINVAL; + } + + switch (dev_conf->phy_speed) + { + case FXMAC_PHY_SPEED_10M: + mac_config->speed = FXMAC_SPEED_10; + break; + case FXMAC_PHY_SPEED_100M: + mac_config->speed = FXMAC_SPEED_100; + break; + case FXMAC_PHY_SPEED_1000M: + mac_config->speed = FXMAC_SPEED_1000; + break; + case FXMAC_PHY_SPEED_10G: + LOG_INF("select FXMAC_PHY_SPEED_10G"); + mac_config->speed = FXMAC_SPEED_10000; + break; + default: + return -EINVAL; + } + + mac_config->duplex = dev_conf->enable_fdx? 1:0 ; /* 1 is full-duplex , 0 is half-duplex */ + mac_config->auto_neg = dev_conf->phy_autonegotiation ; /* Enable auto-negotiation - when set active high, + autonegotiation operation is enabled. */ + mac_config->pclk_hz = dev_conf->pll_clock_frequency ; + mac_config->max_queue_num = dev_conf->max_queue_num ; /* Number of Xmac Controller Queues */ + mac_config->tx_queue_id = 0 ; /* 0 ~ FXMAC_QUEUE_MAX_NUM ,Index queue number */ + mac_config->rx_queue_id = 0 ; /* 0 ~ FXMAC_QUEUE_MAX_NUM ,Index queue number */ + mac_config->dma_brust_length = dev_conf->dma_brust_length ; /* burst length */ + mac_config->network_default_config = FXMAC_DEFAULT_OPTIONS ; + mac_config->caps = 0 ; /* used to configure tail ptr feature */ + + /* options */ + if(dev_conf->enable_jumbo) + { + *options |= FXMAC_JUMBO_ENABLE_OPTION ; + } + + if(dev_conf->enable_ucast_hash) + { + *options |= FXMAC_UNICAST_OPTION; + } + + if(dev_conf->enable_mcast_hash) + { + *options |= FXMAC_MULTICAST_OPTION; + } + + if(dev_conf->copy_all_frames) + { + *options |= FXMAC_PROMISC_OPTION; + } + + if(dev_conf->disable_reject_fcs_crc_errors) + { + *options |= FXMAC_FCS_STRIP_OPTION; + } + + + return 0 ; +} + +/* irq init */ +static int eth_phytium_xmac_setuphandler(const struct device *dev) +{ + + struct eth_phytium_xmac_dev_cfg *dev_conf = (struct eth_phytium_xmac_dev_cfg *)dev->config ; + struct eth_phytium_xmac_dev_data *dev_data = (struct eth_phytium_xmac_dev_data *)dev->data ; + FXmac *instance_p; + + FXmacBd bdtemplate; + FXmacBdRing *rxringptr, *txringptr; + FXmacBd *rxbd; + int i; + u32 bdindex; + u32 *temp; + instance_p = &dev_data->instance; + /* init buffer to data */ + /* Initial configuration of the RX/TX BD rings */ + DT_INST_FOREACH_STATUS_OKAY(ETH_PHYTIUM_XMAC_INIT_BD_RING) + rxringptr = &FXMAC_GET_RXRING((*instance_p)); + txringptr = &FXMAC_GET_TXRING((*instance_p)); + + /* Setup RxBD space. */ + FXMAC_BD_CLEAR(&bdtemplate); + + /* Create the RxBD ring */ + if(FXmacBdRingCreate(rxringptr, (uintptr)dev_data->rx_bdspace, + (uintptr)dev_data->rx_bdspace, + ETH_PHYTIUM_BDL_ALIGNMENT, + dev_conf->rxbd_count)) + { + LOG_ERR("Error setting up RxBD space\r\n"); + return -EIO ; + } + + if(FXmacBdRingClone(rxringptr, &bdtemplate, FXMAC_RECV)) + { + LOG_ERR("Error initializing RxBD space\r\n"); + return -EIO; + } + + FXMAC_BD_CLEAR(&bdtemplate); + FXMAC_BD_SET_STATUS(&bdtemplate, FXMAC_TXBUF_USED_MASK); + + + /* Create the TxBD ring */ + if (FXmacBdRingCreate(txringptr, (uintptr)dev_data->tx_bdspace, + (uintptr)dev_data->tx_bdspace, ETH_PHYTIUM_BDL_ALIGNMENT, + dev_conf->txbd_count)) + { + return -EIO; + } + + /* We reuse the bd template, as the same one will work for both rx and tx. */ + if(FXmacBdRingClone(txringptr, &bdtemplate, FXMAC_SEND)) + { + return -EIO; + } + + /* init rx buffer */ + for (i = 0; i < dev_conf->rxbd_count; i++) + { + if(FXmacBdRingAlloc(rxringptr, 1, &rxbd)) + { + LOG_ERR("InitDma: Error allocating RxBD\r\n"); + return -ERANGE; + } + + /* Enqueue to HW */ + if(FXmacBdRingToHw(rxringptr, 1, rxbd)) + { + LOG_ERR("Error: committing RxBD to HW\r\n"); + FXmacBdRingUnAlloc(rxringptr, 1, rxbd); + return -ERANGE; + } + + bdindex = FXMAC_BD_TO_INDEX(rxringptr, rxbd); + temp = (u32 *)rxbd; + *temp = 0; + if (bdindex == (dev_conf->rxbd_count - 1)) + { + *temp = 0x00000002; /* Marks last descriptor in receive buffer descriptor list */ + } + temp++; + *temp = 0; /* Clear word 1 in descriptor */ + + FXMAC_BD_SET_ADDRESS_RX(rxbd, (uintptr)(dev_data->first_rx_buffer_virt + ETH_ALIGNMENT_OFFSET_DEFINED(dev_conf->rx_buffer_size)*bdindex)); + + } + FXmacSetQueuePtr(instance_p, instance_p->tx_bd_queue.bdring.phys_base_addr, 0, (u16)FXMAC_SEND); + FXmacSetQueuePtr(instance_p, instance_p->rx_bd_queue.bdring.phys_base_addr, 0, (u16)FXMAC_RECV); + + return 0; +} + + + +static void eth_phytium_xmac_handle_tx_done(const struct device *dev) +{ + struct eth_phytium_xmac_dev_data *dev_data = (struct eth_phytium_xmac_dev_data *)dev->data ; + struct eth_phytium_xmac_dev_cfg *dev_conf = (struct eth_phytium_xmac_dev_cfg *)dev->config ; + FXmac *instance_p; + FXmacBd *txbdset; + FXmacBd *curbdpntr; + u32 n_bds; + FError status; + u32 n_pbufs_freed = 0; + u32 bdindex; + u32 *temp; + instance_p = &dev_data->instance ; + FXmacBdRing *txring; + + if (dev_conf->defer_txd_to_queue) { + k_sem_take(&(dev_data->ring_sem), K_FOREVER); + } + txring = &(FXMAC_GET_TXRING((*instance_p))); + while (1) + { + /* obtain processed BD's */ + n_bds = FXmacBdRingFromHwTx(txring, dev_conf->txbd_count, &txbdset); + if (n_bds == 0) + { + break; + } + /* free the processed BD's */ + n_pbufs_freed = n_bds; + curbdpntr = txbdset; + while (n_pbufs_freed > 0) + { + bdindex = FXMAC_BD_TO_INDEX(txring, curbdpntr); + temp = (u32 *)curbdpntr; + *temp = 0; /* Word 0 */ + temp++; + + if (bdindex == (dev_conf->txbd_count - 1)) + { + *temp = 0xC0000000; /* Word 1 ,used/Wrap – marks last descriptor in transmit buffer descriptor list.*/ + } + else + { + *temp = 0x80000000; /* Word 1 , Used – must be zero for GEM to read data to the transmit buffer.*/ + } + + curbdpntr = FXMAC_BD_RING_NEXT(txring, curbdpntr); + n_pbufs_freed--; + + } + + status = FXmacBdRingFree(txring, n_bds, txbdset); + if (status != FT_SUCCESS) + { + LOG_ERR("Failure while freeing in Tx Done ISR\r\n"); + } + } + + if (dev_conf->defer_txd_to_queue) { + k_sem_give(&(dev_data->ring_sem)); + } + + /* Re-enable the TX complete interrupt source */ + FXMAC_WRITEREG32(instance_p->config.base_address,FXMAC_IER_OFFSET,FXMAC_IXR_TXCOMPL_MASK) ; + + /* Indicate completion to a blocking eth_xlnx_gem_send() call */ + k_sem_give(&dev_data->tx_done_sem); +} + +static void eth_phytium_xmac_tx_done_work(struct k_work *item) +{ + struct eth_phytium_xmac_dev_data *dev_data = CONTAINER_OF(item, struct eth_phytium_xmac_dev_data, tx_done_work); + const struct device *dev = net_if_get_device(dev_data->iface); + + eth_phytium_xmac_handle_tx_done(dev); +} + +/** + * @name: eth_phytium_xmac_send + * @msg: Sends an Ethernet frame. The frame is contained in a packet that is managed by the networking stack. + * @param {const struct device} *dev is a pointer to the device structure for the driver instance. + * @param {struct net_pkt} *pkt is a pointer to the network packet that contains the data to be sent. + * @return {int} Zero on success or negative error code on failure. + */ +static int eth_phytium_xmac_send(const struct device *dev, struct net_pkt *pkt) +{ + struct eth_phytium_xmac_dev_cfg *dev_conf = (struct eth_phytium_xmac_dev_cfg *)dev->config ; + struct eth_phytium_xmac_dev_data *dev_data = (struct eth_phytium_xmac_dev_data *)dev->data ; + FXmac *instance_p; + + FXmacBd *txbdset, *txbd, *last_txbd = NULL; + FXmacBdRing *txring; + u32 bdindex; + + uint16_t tx_data_length; + uint16_t tx_data_remaining; + void *tx_buffer_offs; + uint32_t bds_reqd; + uint32_t tx_length = 0 ; + instance_p = &dev_data->instance; + txring = &FXMAC_GET_TXRING((*instance_p)); + + if (!dev_data->started || dev_data->eff_link_speed == LINK_DOWN || + (!net_if_flag_is_set(dev_data->iface, NET_IF_UP))) { +#ifdef CONFIG_NET_STATISTICS_ETHERNET + dev_data->stats.tx_dropped++; +#endif + return -EIO; + } + + tx_data_length = tx_data_remaining = net_pkt_get_len(pkt); + if (tx_data_length == 0) { + LOG_ERR("%s cannot TX, zero packet length", dev->name); +#ifdef CONFIG_NET_STATISTICS_ETHERNET + dev_data->stats.errors.tx++; +#endif + return -EINVAL; + } + + bds_reqd = (uint8_t)((tx_data_length + (dev_conf->tx_buffer_size - 1)) / + dev_conf->tx_buffer_size); + + if (dev_conf->defer_txd_to_queue) { + k_sem_take(&(dev_data->ring_sem), K_FOREVER); + } else { + FXMAC_WRITEREG32(instance_p->config.base_address,FXMAC_IDR_OFFSET,FXMAC_IXR_TXCOMPL_MASK) ; + } + + /* obtain as many BD's */ + if(FXmacBdRingAlloc(txring, bds_reqd, &txbdset)) + { + LOG_ERR("sgsend: Error allocating TxBD\r\n"); +#ifdef CONFIG_NET_STATISTICS_ETHERNET + dev_data->stats.tx_dropped++; +#endif + FXMAC_WRITEREG32(instance_p->config.base_address,FXMAC_IER_OFFSET,FXMAC_IXR_TXCOMPL_MASK) ; + return ERR_GENERAL; + } + + if (dev_conf->defer_txd_to_queue) { + k_sem_give(&(dev_data->ring_sem)); + } else { + FXMAC_WRITEREG32(instance_p->config.base_address,FXMAC_IER_OFFSET,FXMAC_IXR_TXCOMPL_MASK) ; + } + + /* + * Scatter the contents of the network packet's buffer to + * one or more DMA buffers. + */ + net_pkt_cursor_init(pkt); + txbd = txbdset ; + while (tx_data_remaining) + { + bdindex = FXMAC_BD_TO_INDEX(txring, txbd); + + /* Calculate the base pointer of the target TX buffer */ + tx_buffer_offs = (void *)(dev_data->first_tx_buffer + + (ETH_ALIGNMENT_OFFSET_DEFINED(dev_conf->tx_buffer_size) * bdindex)); + + /* Copy packet data to DMA buffer */ + tx_length = (tx_data_remaining < dev_conf->tx_buffer_size) ? + tx_data_remaining : dev_conf->tx_buffer_size ; + net_pkt_read(pkt, (void *)tx_buffer_offs,tx_length); + + FXMAC_BD_SET_ADDRESS_TX(txbd, (uintptr)tx_buffer_offs); + + FXMAC_BD_SET_LENGTH(txbd, tx_length & 0x3FFF); + + last_txbd = txbd; + FXMAC_BD_CLEAR_LAST(txbd); + txbd = FXMAC_BD_RING_NEXT(txring, txbd); + tx_data_remaining -= (tx_data_remaining < dev_conf->tx_buffer_size) ? + tx_data_remaining : dev_conf->tx_buffer_size; + } + FXMAC_BD_SET_LAST(last_txbd); + FXMAC_BD_CLEAR_TX_USED(last_txbd); + + if(FXmacBdRingToHw(txring, bds_reqd, txbdset)) + { + LOG_ERR("sgsend: Error submitting TxBD\r\n"); + } + + /* Start transmit */ + FXMAC_WRITEREG32(instance_p->config.base_address, + FXMAC_NWCTRL_OFFSET, + (FXMAC_READREG32(instance_p->config.base_address, + FXMAC_NWCTRL_OFFSET) | + FXMAC_NWCTRL_STARTTX_MASK)); + +#ifdef CONFIG_NET_STATISTICS_ETHERNET + dev_data->stats.bytes.sent += tx_data_length; + dev_data->stats.pkts.tx++; +#endif + + return 0 ; +} + +static void eth_phytium_xmac_setup_rx_bds(const struct device *dev,FXmacBdRing *rxring) +{ + const struct eth_phytium_xmac_dev_cfg *dev_conf = dev->config; + struct eth_phytium_xmac_dev_data *dev_data = dev->data; + FXmacBd *rxbd; + FError status; + u32 freebds; + u32 bdindex; + u32 *temp; + FXmac *instance_p; + instance_p = &dev_data->instance ; + + freebds = FXMAC_BD_RING_GET_FREE_CNT(rxring); + while (freebds > 0) + { + freebds --; + status = FXmacBdRingAlloc(rxring, 1, &rxbd); + if (status != FT_SUCCESS) + { + LOG_ERR("SetupRxBds: Error allocating RxBD\r\n"); + return; + } + status = FXmacBdRingToHw(rxring, 1, rxbd); + if (status != FT_SUCCESS) + { + LOG_ERR("Error committing RxBD to hardware: "); + if (status == FXMAC_ERR_SG_LIST) + { + LOG_ERR("XST_DMA_SG_LIST_ERROR: this function was called out of sequence with FXmacBdRingAlloc()\r\n"); + } + else + { + LOG_ERR("set of BDs was rejected because the first BD did not have its start-of-packet bit set, or the last BD did not have its end-of-packet bit set, or any one of the BD set has 0 as length value\r\n"); + } + + FXmacBdRingUnAlloc(rxring, 1, rxbd); + return; + } + + + bdindex = FXMAC_BD_TO_INDEX(rxring, rxbd); + temp = (u32 *)rxbd; + if (bdindex == (dev_conf->rxbd_count - 1)) + { + *temp = 0x00000002; /* Mask last descriptor in receive buffer list */ + } + else + { + *temp = 0; + } + temp++; + *temp = 0; + + FXMAC_BD_SET_ADDRESS_RX(rxbd, (uintptr)(dev_data->first_rx_buffer_virt + ETH_ALIGNMENT_OFFSET_DEFINED(dev_conf->rx_buffer_size)*bdindex)); + + } +} + +static void eth_phytium_xmac_handle_rx_pending(const struct device *dev) +{ + const struct eth_phytium_xmac_dev_cfg *dev_conf = dev->config; + struct eth_phytium_xmac_dev_data *dev_data = dev->data; + FXmacBd *rxbdset, *curbdptr; + FXmacBdRing *rxring; + volatile u32 bd_processed; + u32 k; + u32 bdindex; + FXmac *instance_p; + struct net_pkt *pkt; + uint32_t rx_data_length; + instance_p = &dev_data->instance ; + rxring = &FXMAC_GET_RXRING((*instance_p)); + + /* Re-enable the frame received interrupt source */ + FXMAC_WRITEREG32(instance_p->config.base_address,FXMAC_IER_OFFSET,FXMAC_IXR_RXCOMPL_MASK); + + while (1) + { + bd_processed = FXmacBdRingFromHwRx(rxring, dev_conf->rxbd_count, &rxbdset); + if (bd_processed <= 0) + { + break; + } + + for (k = 0, curbdptr = rxbdset; k < bd_processed; k++) + { + bdindex = FXMAC_BD_TO_INDEX(rxring, curbdptr); + rx_data_length = FXMAC_BD_GET_LENGTH(curbdptr); + if(rx_data_length > dev_conf->rx_buffer_size) + { + LOG_ERR("rx_data_length length is error: %u bytes \r\n", + rx_data_length); + goto error_exit ; + } + + pkt = net_pkt_rx_alloc_with_buffer(dev_data->iface, rx_data_length, + AF_UNSPEC, 0, K_FOREVER); + if (pkt == NULL) + { + LOG_ERR("RX packet buffer alloc failed: %u bytes", + rx_data_length); +#ifdef CONFIG_NET_STATISTICS_ETHERNET + dev_data->stats.errors.rx++; + dev_data->stats.error_details.rx_no_buffer_count++; +#endif + /* free up the BD's */ + goto error_exit ; + } + + net_pkt_write(pkt, (const void *) + (dev_data->first_rx_buffer_virt + ETH_ALIGNMENT_OFFSET_DEFINED(dev_conf->rx_buffer_size)*bdindex), + rx_data_length); + + if (net_recv_data(dev_data->iface, pkt) < 0) { + printf("%s RX packet hand-over to IP stack failed", dev->name); + net_pkt_unref(pkt); + } +#ifdef CONFIG_NET_STATISTICS_ETHERNET + else { + dev_data->stats.bytes.received += rx_data_length; + dev_data->stats.pkts.rx++; + } +#endif + curbdptr = FXMAC_BD_RING_NEXT(rxring, curbdptr); + } + FXmacBdRingFree(rxring, bd_processed, rxbdset); + eth_phytium_xmac_setup_rx_bds(dev,rxring) ; + } + + return; + +error_exit: + printf("eth_phytium_xmac_handle_rx_pending error exit \r\n") ; + FXmacBdRingFree(rxring, bd_processed, rxbdset); +} + +static void eth_phytium_xmac_rx_pending_work(struct k_work *item) +{ + struct eth_phytium_xmac_dev_data *dev_data = CONTAINER_OF(item, + struct eth_phytium_xmac_dev_data, rx_pend_work); + const struct device *dev = net_if_get_device(dev_data->iface); + + eth_phytium_xmac_handle_rx_pending(dev); +} + + +static void FXmacSendHandler(void *arg) +{ + const struct device *dev = (const struct device *)arg; + struct eth_phytium_xmac_dev_data *dev_data = dev->data; + const struct eth_phytium_xmac_dev_cfg *dev_conf = dev->config; + FXmac *instance_p; + instance_p = &dev_data->instance; + + FXMAC_WRITEREG32(instance_p->config.base_address, FXMAC_IDR_OFFSET,FXMAC_IXR_TXCOMPL_MASK); + if (dev_conf->defer_txd_to_queue) + { + k_work_submit(&dev_data->tx_done_work); + } + else + { + eth_phytium_xmac_handle_tx_done(dev); + } +} + +static void FXmacRecvHandler(void *arg) +{ + const struct device *dev = (const struct device *)arg ; + struct eth_phytium_xmac_dev_data *dev_data = dev->data; + const struct eth_phytium_xmac_dev_cfg *dev_conf = dev->config; + FXmac *instance_p; + instance_p = &dev_data->instance ; + + FXMAC_WRITEREG32(instance_p->config.base_address,FXMAC_IDR_OFFSET,FXMAC_IXR_RXCOMPL_MASK) ; + + if (dev_conf->defer_rxp_to_queue) + { + k_work_submit(&dev_data->rx_pend_work); + } + else + { + printk("recv data \r\n") ; + eth_phytium_xmac_handle_rx_pending(dev); + printk("recv data exit \r\n") ; + } +} + +/* interrupt */ +static void FXmacHandleDmaTxError( const struct device *dev) +{ + u32 dmacrreg; + struct eth_phytium_xmac_dev_data *dev_data = (struct eth_phytium_xmac_dev_data *)dev->data; + FXmac *instance_p; + instance_p = &dev_data->instance ; + /* initialize the mac */ + if (FXmacCfgInitialize(instance_p, &instance_p->config)) + { + LOG_ERR("In %s:EmacPs Configuration Failed....\r\n", __func__); + } + + /* set mac address */ + FXmacSetMacAddress(instance_p, (void *)(dev_data->mac_addr), 0) ; + + dmacrreg = FXMAC_READREG32(instance_p->config.base_address, FXMAC_DMACR_OFFSET); + dmacrreg = dmacrreg | (FXMAC_DMACR_ORCE_DISCARD_ON_ERR_MASK); + FXMAC_WRITEREG32(instance_p->config.base_address, FXMAC_DMACR_OFFSET, dmacrreg); + /* setup dma bdl */ + eth_phytium_xmac_setuphandler(dev) ; + FXmacSetupIsr(dev); + + FXmacStart(instance_p); +} + +static void eth_phytium_xmac_tx_dma_init(const struct device *dev) +{ + struct eth_phytium_xmac_dev_data *dev_data = (struct eth_phytium_xmac_dev_data *)dev->data ; + struct eth_phytium_xmac_dev_cfg *dev_conf = (struct eth_phytium_xmac_dev_cfg *)dev->config ; + FXmac *instance_p; + instance_p = &dev_data->instance ; + FXmacBd bdtemplate; + FXmacBdRing *txringptr; + + txringptr = &FXMAC_GET_TXRING((*instance_p)); + FXMAC_BD_CLEAR(&bdtemplate); + FXMAC_BD_SET_STATUS(&bdtemplate, FXMAC_TXBUF_USED_MASK); + + if (FXmacBdRingCreate(txringptr, (uintptr)dev_data->tx_bdspace, + (uintptr)dev_data->tx_bdspace, ETH_PHYTIUM_BDL_ALIGNMENT, + dev_conf->txbd_count)) + { + LOG_ERR("FXmacBdRingCreate is error") ; + return ; + } + + FXmacBdRingClone(txringptr, &bdtemplate, FXMAC_SEND); +} + +static void FXmacHandleTxErrors( const struct device *dev) +{ + struct eth_phytium_xmac_dev_data *dev_data = (struct eth_phytium_xmac_dev_data *)dev->data ; + FXmac *instance_p; + + instance_p = &dev_data->instance ; + + u32 netctrlreg; + + netctrlreg = FXMAC_READREG32(instance_p->config.base_address, + FXMAC_NWCTRL_OFFSET); + netctrlreg = netctrlreg & (~FXMAC_NWCTRL_TXEN_MASK); + FXMAC_WRITEREG32(instance_p->config.base_address, + FXMAC_NWCTRL_OFFSET, netctrlreg); + + eth_phytium_xmac_tx_dma_init(dev); + netctrlreg = FXMAC_READREG32(instance_p->config.base_address, FXMAC_NWCTRL_OFFSET); + netctrlreg = netctrlreg | (FXMAC_NWCTRL_TXEN_MASK); + FXMAC_WRITEREG32(instance_p->config.base_address, FXMAC_NWCTRL_OFFSET, netctrlreg); +} + +void FXmacErrorHandler(void *arg, u8 direction, u32 error_word) +{ + const struct device *dev = (const struct device *)arg ; + struct eth_phytium_xmac_dev_data *dev_data = (struct eth_phytium_xmac_dev_data *)dev->data; + struct eth_phytium_xmac_dev_cfg *dev_conf = (struct eth_phytium_xmac_dev_cfg *)dev->config; + FXmac *instance_p; + instance_p = &dev_data->instance ; + + if (error_word != 0) + { + switch (direction) + { + case FXMAC_RECV: + if (error_word & FXMAC_RXSR_HRESPNOK_MASK) + { + LOG_ERR("Receive DMA error\r\n"); + FXmacHandleDmaTxError(dev); + } + if (error_word & FXMAC_RXSR_RXOVR_MASK) + { + LOG_ERR("Receive over run\r\n"); + FXmacRecvHandler((void *)dev) ; + } + if (error_word & FXMAC_RXSR_BUFFNA_MASK) + { + LOG_ERR("Receive buffer not available\r\n"); + FXmacRecvHandler((void *)dev) ; + } + break; + case FXMAC_SEND: + if (error_word & FXMAC_TXSR_HRESPNOK_MASK) + { + LOG_ERR("Transmit DMA error\r\n"); + FXmacHandleDmaTxError(dev); + } + if (error_word & FXMAC_TXSR_URUN_MASK) + { + LOG_ERR("Transmit under run\r\n"); + FXmacHandleTxErrors(dev); + } + if (error_word & FXMAC_TXSR_BUFEXH_MASK) + { + LOG_ERR("Transmit buffer exhausted\r\n"); + FXmacHandleTxErrors(dev); + } + if (error_word & FXMAC_TXSR_RXOVR_MASK) + { + LOG_ERR("Transmit retry excessed limits\r\n"); + FXmacHandleTxErrors(dev); + } + if (error_word & FXMAC_TXSR_FRAMERX_MASK) + { + LOG_ERR("Transmit collision\r\n"); + if (dev_conf->defer_txd_to_queue) { + k_work_submit(&dev_data->tx_done_work); + } + else + { + eth_phytium_xmac_handle_tx_done(dev); + } + } + break; + } + } +} + +#ifdef CONFIG_NET_STATISTICS_ETHERNET +/** + * @name: eth_phytium_xmac_stats + * @msg: Retrieves the Ethernet statistics for the device. + * @param {const struct device} *dev is a pointer to the device structure for the driver instance. + * @return {struct net_stats_eth} * A pointer to the statistics structure. + */ +static struct net_stats_eth *eth_phytium_xmac_stats(const struct device *dev) +{ + struct eth_phytium_xmac_dev_data *dev_data = dev->data; + + return &dev_data->stats; +} +#endif + +/** + * @name: FXmacSetupIsr + * @msg: Sets up the interrupt service routine handlers for transmit, receive, and error events. + * @param {const struct device} *dev is a pointer to the device structure for the driver instance. + */ +static void FXmacSetupIsr(const struct device *dev) +{ + struct eth_phytium_xmac_dev_data *dev_data = (struct eth_phytium_xmac_dev_data *)dev->data ; + /* Setup callbacks */ + FXmac *instance_p; + instance_p = &dev_data->instance; + + FXmacSetHandler(instance_p, FXMAC_HANDLER_DMASEND, FXmacSendHandler, (void *)dev); + FXmacSetHandler(instance_p, FXMAC_HANDLER_DMARECV, FXmacRecvHandler,(void *) (void *)dev); + FXmacSetHandler(instance_p, FXMAC_HANDLER_ERROR, FXmacErrorHandler, (void *)dev); +} + +/** + * @name: eth_phytium_xmac_start_device + * @msg: Starts the Ethernet device, enabling packet transmission and reception. + * @param {const struct device} *dev is a pointer to the device structure for the driver instance. + * @return {int} Zero on success or negative error code on failure. + */ +static int eth_phytium_xmac_start_device(const struct device *dev) +{ + struct eth_phytium_xmac_dev_data *dev_data = (struct eth_phytium_xmac_dev_data *)dev->data; + /* Setup callbacks */ + if (dev_data->started) { + return 0; + } + dev_data->started = true; + + FXmac *instance_p; + instance_p = &dev_data->instance; + FXmacStart(instance_p) ; + return 0 ; +} + +/** + * @name: eth_phytium_xmac_stop_device + * @msg: Stops the Ethernet device, disabling packet transmission and reception. + * @param {const struct device} *dev is a pointer to the device structure for the driver instance. + * @return {int} Zero on success or negative error code on failure. + */ +static int eth_phytium_xmac_stop_device(const struct device *dev) +{ + struct eth_phytium_xmac_dev_data *dev_data = (struct eth_phytium_xmac_dev_data *)dev->data; + FXmac *instance_p; + instance_p = &dev_data->instance; + + if (!dev_data->started) { + return 0; + } + dev_data->started = false; + + /* Cancel the delayed work that polls the link state */ + if (k_work_delayable_remaining_get(&dev_data->phy_poll_delayed_work) != 0) + { + k_work_cancel_delayable(&dev_data->phy_poll_delayed_work); + } + + FXmacStop(instance_p) ; + + return 0 ; +} + +/** + * @name: eth_phytium_xmac_isr + * @msg: Interrupt service routine for handling all interrupts from the Ethernet device. + * @param {const struct device} *dev is a pointer to the device structure for the driver instance. + */ +static void eth_phytium_xmac_isr(const struct device *dev) +{ + u32 reg_isr; + u32 reg_temp; + u32 reg_ctrl; + + struct eth_phytium_xmac_dev_data *dev_data = (struct eth_phytium_xmac_dev_data *)dev->data; + /* Setup callbacks */ + FXmac *instance_p; + instance_p = &dev_data->instance; + + reg_isr = FXMAC_READREG32(instance_p->config.base_address, FXMAC_ISR_OFFSET); + { + if ((reg_isr & FXMAC_IXR_TXCOMPL_MASK) != 0x00000000U) + { + /* Clear TX status register TX complete indication but preserve + * error bits if there is any */ + FXMAC_WRITEREG32(instance_p->config.base_address, + FXMAC_TXSR_OFFSET, + ((u32)FXMAC_TXSR_TXCOMPL_MASK | + (u32)FXMAC_TXSR_USEDREAD_MASK)); + if (instance_p->send_irq_handler) + { + /* code */ + instance_p->send_irq_handler(instance_p->send_args); + } + /* add */ + if(instance_p->caps& FXMAC_CAPS_ISR_CLEAR_ON_WRITE) + { + FXMAC_WRITEREG32(instance_p->config.base_address, FXMAC_ISR_OFFSET, FXMAC_IXR_TXCOMPL_MASK); + } + } + + /* Transmit error conditions interrupt */ + if (((reg_isr & FXMAC_IXR_TX_ERR_MASK) != 0x00000000U) && + (!(reg_isr & FXMAC_IXR_TXCOMPL_MASK) != 0x00000000U)) + { + /* Clear TX status register */ + reg_temp = FXMAC_READREG32(instance_p->config.base_address, FXMAC_TXSR_OFFSET); + FXMAC_WRITEREG32(instance_p->config.base_address, FXMAC_TXSR_OFFSET, reg_temp); + if (instance_p->error_irq_handler) + { + instance_p->error_irq_handler(instance_p->error_args, FXMAC_SEND, reg_temp); + } + /* add */ + if(instance_p->caps& FXMAC_CAPS_ISR_CLEAR_ON_WRITE) + { + FXMAC_WRITEREG32(instance_p->config.base_address, FXMAC_ISR_OFFSET, FXMAC_IXR_TX_ERR_MASK); + } + } + + /* add restart */ + if ((reg_isr & FXMAC_IXR_TXUSED_MASK) != 0x00000000U) + { + /* add */ + if(instance_p->caps& FXMAC_CAPS_ISR_CLEAR_ON_WRITE) + { + FXMAC_WRITEREG32(instance_p->config.base_address, FXMAC_ISR_OFFSET, FXMAC_IXR_TXUSED_MASK); + } + if (instance_p->restart_handler) + { + instance_p->restart_handler(instance_p->restart_args); + } + } + + /* link changed */ + if ((reg_isr & FXMAC_IXR_LINKCHANGE_MASK) != 0x00000000U) + { + if (instance_p->link_change_handler) + { + instance_p->link_change_handler(instance_p->link_change_args); + } + if(instance_p->caps& FXMAC_CAPS_ISR_CLEAR_ON_WRITE) + { + FXMAC_WRITEREG32(instance_p->config.base_address, FXMAC_ISR_OFFSET, FXMAC_IXR_LINKCHANGE_MASK); + } + } + } + + + { + /* Receive complete interrupt */ + if ((reg_isr & FXMAC_IXR_RXCOMPL_MASK) != 0x00000000U) + { + /* Clear RX status register RX complete indication but preserve + * error bits if there is any */ + FXMAC_WRITEREG32(instance_p->config.base_address, + FXMAC_RXSR_OFFSET, + ((u32)FXMAC_RXSR_FRAMERX_MASK | + (u32)FXMAC_RXSR_BUFFNA_MASK)); + instance_p->recv_irq_handler(instance_p->recv_args); + /* add */ + if(instance_p->caps& FXMAC_CAPS_ISR_CLEAR_ON_WRITE) + { + FXMAC_WRITEREG32(instance_p->config.base_address, FXMAC_ISR_OFFSET, FXMAC_IXR_RXCOMPL_MASK); + } + } + + /* Receive error conditions interrupt */ + if ((reg_isr & FXMAC_IXR_RX_ERR_MASK) != 0x00000000U) + { + /* Clear RX status register */ + reg_temp = FXMAC_READREG32(instance_p->config.base_address, + FXMAC_RXSR_OFFSET); + FXMAC_WRITEREG32(instance_p->config.base_address, + FXMAC_RXSR_OFFSET, reg_temp); + if ((reg_isr & FXMAC_IXR_RXUSED_MASK) != 0x00000000U) + { + reg_ctrl = FXMAC_READREG32(instance_p->config.base_address, + FXMAC_NWCTRL_OFFSET); + reg_ctrl |= (u32)FXMAC_NWCTRL_FLUSH_DPRAM_MASK; + /* add */ + reg_ctrl &= (u32)(~FXMAC_NWCTRL_RXEN_MASK); + FXMAC_WRITEREG32(instance_p->config.base_address, + FXMAC_NWCTRL_OFFSET, reg_ctrl); + /* add */ + reg_ctrl |= (u32)FXMAC_NWCTRL_RXEN_MASK; + FXMAC_WRITEREG32(instance_p->config.base_address, + FXMAC_NWCTRL_OFFSET, reg_ctrl); + + if(instance_p->caps& FXMAC_CAPS_ISR_CLEAR_ON_WRITE) + { + FXMAC_WRITEREG32(instance_p->config.base_address, FXMAC_ISR_OFFSET, FXMAC_IXR_RXUSED_MASK); + } + } + /* add */ + if ((reg_isr & FXMAC_IXR_RXOVR_MASK) != 0x00000000U) + { + if(instance_p->caps& FXMAC_CAPS_ISR_CLEAR_ON_WRITE) + { + FXMAC_WRITEREG32(instance_p->config.base_address, FXMAC_ISR_OFFSET, FXMAC_IXR_RXOVR_MASK); + } + } + /* add */ + if ((reg_isr & FXMAC_IXR_HRESPNOK_MASK) != 0x00000000U) + { + if(instance_p->caps& FXMAC_CAPS_ISR_CLEAR_ON_WRITE) + { + FXMAC_WRITEREG32(instance_p->config.base_address, FXMAC_ISR_OFFSET, FXMAC_IXR_HRESPNOK_MASK); + } + } + if (reg_temp != 0) + { + instance_p->error_irq_handler(instance_p->error_args, + FXMAC_RECV, reg_temp); + } + } + } +} + +/** + * @name: eth_phytium_xmac_iface_init + * @msg: Initializes the network interface for the Ethernet driver. Sets the link address and registers the Ethernet interface with the network stack. + * @param {struct net_if} *iface is a pointer to the network interface structure. + */ +static void eth_phytium_xmac_iface_init(struct net_if *iface) +{ + const struct device *dev = net_if_get_device(iface); + const struct eth_phytium_xmac_dev_cfg *dev_conf = dev->config; + struct eth_phytium_xmac_dev_data *dev_data = dev->data; + + /* Set the initial contents of the current instance's run-time data */ + dev_data->iface = iface; + net_if_set_link_addr(iface, dev_data->mac_addr, 6, NET_LINK_ETHERNET); + ethernet_init(iface); + net_if_carrier_off(iface); + + /* + * Initialize the (delayed) work items for RX pending, TX done + * and PHY status polling handlers + */ + k_work_init(&dev_data->tx_done_work, eth_phytium_xmac_tx_done_work); + k_work_init(&dev_data->rx_pend_work, eth_phytium_xmac_rx_pending_work); + k_work_init_delayable(&dev_data->phy_poll_delayed_work, + eth_phytium_xmac_poll_phy); + + /* Initialize TX completion semaphore */ + k_sem_init(&dev_data->tx_done_sem, 0, 1); + + /* + * Initialize semaphores in the RX/TX BD rings which have not + * yet been initialized + */ + k_sem_init(&dev_data->ring_sem, 1, 1); + /* RX BD ring semaphore is not required at the time being */ + + /* Initialize the device's interrupt */ + dev_conf->config_func(dev); + + /* Submit initial PHY status polling delayed work */ + k_work_reschedule(&dev_data->phy_poll_delayed_work, K_NO_WAIT); + +} + +/** + * @name: eth_phytium_xmac_dev_init + * @msg: Initializes the Ethernet device, including hardware configuration and MAC address setting. + * @param {const struct device} *dev is a pointer to the device structure for the driver instance. + * @return {int} Zero on success or negative error code on failure. + */ +static int eth_phytium_xmac_dev_init(const struct device *dev) +{ + struct eth_phytium_xmac_dev_data *dev_data = (struct eth_phytium_xmac_dev_data *)dev->data ; + struct eth_phytium_xmac_dev_cfg *dev_conf = (struct eth_phytium_xmac_dev_cfg *)dev->config ; + FXmacConfig mac_config; + FXmac *instance_p; + uint32_t xmac_options ; + uint32_t dmacrreg; + int ret ; + + /* init base */ + DEVICE_MMIO_MAP(dev, K_MEM_CACHE_NONE); + + /* config init */ + mac_config.base_address = DEVICE_MMIO_GET(dev) ; + mac_config.instance_id = 0; + + ret = eth_phytium_xmac_config_convert(dev_conf,&mac_config,&xmac_options) ; + if(ret) + { + return -EINVAL; + } + + instance_p = &dev_data->instance; + if(FXmacCfgInitialize(instance_p, &mac_config)) + { + return -EIO; + } + + FXmacSetOptions(instance_p, xmac_options, 0); + + /* set mac address */ + if(FXmacSetMacAddress(instance_p, (void *)(dev_data->mac_addr), 0)) + { + return -EIO; + } + + if(mac_config.interface != FXMAC_PHY_INTERFACE_MODE_USXGMII) + { + /* initialize phy */ + if(FXmacPhyInit(instance_p, instance_p->config.speed, instance_p->config.duplex, instance_p->config.auto_neg,XMAC_PHY_RESET_ENABLE)) + { + LOG_WRN("FXmacPhyInit is error \r\n"); + } + } + + FXmacSelectClk(instance_p); + FXmacInitInterface(instance_p); + + /* initialize dma */ + dmacrreg = FXMAC_READREG32(instance_p->config.base_address, FXMAC_DMACR_OFFSET); + dmacrreg &= ~(FXMAC_DMACR_BLENGTH_MASK); + dmacrreg = dmacrreg | FXMAC_DMACR_INCR16_AHB_AXI_BURST; /* Attempt to use bursts of up to 16. */ + FXMAC_WRITEREG32(instance_p->config.base_address, FXMAC_DMACR_OFFSET, dmacrreg); + /* setup dma bdl */ + eth_phytium_xmac_setuphandler(dev) ; + instance_p->mask = ((u32)FXMAC_IXR_TX_ERR_MASK + | (u32)FXMAC_IXR_RX_ERR_MASK + | (u32)FXMAC_IXR_RXCOMPL_MASK + | (u32)FXMAC_IXR_TXCOMPL_MASK); + /* setup tx、rx intr */ + FXmacSetupIsr(dev) ; + + return 0 ; +} + + + + diff --git a/drivers/ethernet/eth_phytium_xmac.h b/drivers/ethernet/eth_phytium_xmac.h new file mode 100644 index 00000000000..33cc1ecb713 --- /dev/null +++ b/drivers/ethernet/eth_phytium_xmac.h @@ -0,0 +1,117 @@ +#ifndef _ZEPHYR_DRIVERS_ETHERNET_ETH_PHYTIUM_XMAC_H_ +#define _ZEPHYR_DRIVERS_ETHERNET_ETH_PHYTIUM_XMAC_H_ + +#include "fxmac_bd.h" + +/* DMA memory area instantiation macro */ +#define ETH_PHYTIUM_XMAC_DMA_AREA_INST(port) \ +static struct eth_phytium_dma_area_gem##port eth_phytium_xmac##port##_dma_area\ + __aligned(4096); + +/* DMA memory area declaration macro */ +#define ETH_PHYTIUM_XMAC_DMA_AREA_DECL(port) \ +struct eth_phytium_dma_area_gem##port {\ + uint8_t rx_bd[DT_INST_PROP(port, rx_buffer_descriptors) * (u32)sizeof(FXmacBd)] __attribute__((aligned(256))) ;\ + uint8_t tx_bd[DT_INST_PROP(port, tx_buffer_descriptors) * (u32)sizeof(FXmacBd)] __attribute__((aligned(256)));\ + uint8_t rx_buffer\ + [DT_INST_PROP(port, rx_buffer_descriptors)]\ + [((DT_INST_PROP(port, rx_buffer_size)\ + + (ETH_PHYTIUM_BUFFER_ALIGNMENT - 1))\ + & ~(ETH_PHYTIUM_BUFFER_ALIGNMENT - 1))];\ + uint8_t tx_buffer\ + [DT_INST_PROP(port, tx_buffer_descriptors)]\ + [((DT_INST_PROP(port, tx_buffer_size)\ + + (ETH_PHYTIUM_BUFFER_ALIGNMENT - 1))\ + & ~(ETH_PHYTIUM_BUFFER_ALIGNMENT - 1))];\ +}; + + +/* RX/TX BD Ring initialization macro */ +#define ETH_PHYTIUM_XMAC_INIT_BD_RING(port) \ + dev_data->rx_bdspace = &(eth_phytium_xmac##port##_dma_area.rx_bd[0]);\ + dev_data->tx_bdspace = &(eth_phytium_xmac##port##_dma_area.tx_bd[0]);\ + dev_data->first_rx_buffer = (uint8_t *)eth_phytium_xmac##port##_dma_area.rx_buffer;\ + dev_data->first_rx_buffer_virt = dev_data->first_rx_buffer ;\ + dev_data->first_tx_buffer = (uint8_t *)eth_phytium_xmac##port##_dma_area.tx_buffer; \ + dev_data->first_tx_buffer_virt =dev_data->first_tx_buffer ; + + + + +#define ETH_PHYTIUM_XMAC_NET_DEV_INIT(port) \ +ETH_NET_DEVICE_DT_INST_DEFINE(port,\ + eth_phytium_xmac_dev_init,\ + NULL,\ + ð_phytium_xmac##port##_dev_data,\ + ð_phytium_xmac##port##_dev_cfg,\ + CONFIG_ETH_INIT_PRIORITY,\ + ð_phytium_xmac_apis,\ + NET_ETH_MTU); + + + +/* Device configuration data declaration macro */ +#define ETH_PHYTIUM_XMAC_DEV_CONFIG(port) \ +static const struct eth_phytium_xmac_dev_cfg eth_phytium_xmac##port##_dev_cfg = {\ + DEVICE_MMIO_ROM_INIT(DT_DRV_INST(port)), \ + .instance_id = port, \ + .config_func = eth_phytium_xmac##port##_irq_config,\ + .pll_clock_frequency = DT_INST_PROP(port, clock_frequency),\ + .phy_poll_interval = DT_INST_PROP(port, phy_poll_interval),\ + .defer_rxp_to_queue = !DT_INST_PROP(port, handle_rx_in_isr),\ + .defer_txd_to_queue = DT_INST_PROP(port, handle_tx_in_workq),\ + .rxbd_count = (uint8_t)\ + (DT_INST_PROP(port, rx_buffer_descriptors)),\ + .txbd_count = (uint8_t)\ + (DT_INST_PROP(port, tx_buffer_descriptors)),\ + .rx_buffer_size = (((uint16_t)(DT_INST_PROP(port, rx_buffer_size)) +\ + (ETH_PHYTIUM_BUFFER_ALIGNMENT-1)) & ~(ETH_PHYTIUM_BUFFER_ALIGNMENT-1)),\ + .tx_buffer_size = (((uint16_t)(DT_INST_PROP(port, tx_buffer_size)) +\ + (ETH_PHYTIUM_BUFFER_ALIGNMENT-1)) & ~(ETH_PHYTIUM_BUFFER_ALIGNMENT-1)),\ + .phy_speed = DT_INST_PROP(port, phy_speed),\ + .interface_mode = DT_INST_PROP(port, interface_mode),\ + .dma_brust_length = DT_INST_PROP(port, dma_brust_length),\ + .max_queue_num = DT_INST_PROP(port, max_queue_num),\ + .phy_autonegotiation = DT_INST_PROP(port, phy_autonegotiation),\ + .enable_fdx = DT_INST_PROP(port, enable_fdx),\ + .enable_jumbo = DT_INST_PROP(port, enable_jumbo),\ + .enable_ucast_hash = DT_INST_PROP(port, enable_ucast_hash),\ + .copy_all_frames = DT_INST_PROP(port, copy_all_frames),\ + .disable_reject_fcs_crc_errors = DT_INST_PROP(port, disable_reject_fcs_crc_errors),\ + .enable_mcast_hash = DT_INST_PROP(port, enable_mcast_hash),\ +}; + +/* Device run-time data declaration macro */ +#define ETH_PHYTIUM_XMAC_DEV_DATA(port) \ +static struct eth_phytium_xmac_dev_data eth_phytium_xmac##port##_dev_data = {\ + .mac_addr = DT_INST_PROP(port, local_mac_address),\ + .started = 0,\ + .eff_link_speed = LINK_DOWN,\ + .phy_addr = 0,\ + .phy_id = 0,\ + .first_rx_buffer = NULL,\ + .first_tx_buffer = NULL\ +}; + +/* Interrupt configuration function macro */ +#define ETH_PHYTIUM_XMAC_CONFIG_IRQ_FUNC(port) \ +static void eth_phytium_xmac##port##_irq_config(const struct device *dev)\ +{\ + ARG_UNUSED(dev);\ + IRQ_CONNECT(DT_INST_IRQN(port), DT_INST_IRQ(port, priority),\ + eth_phytium_xmac_isr, DEVICE_DT_INST_GET(port), 0);\ + irq_enable(DT_INST_IRQN(port));\ +} + + +/* Top-level device initialization macro - bundles all of the above */ +#define ETH_PHYTIUM_XMAC_INITIALIZE(port) \ +ETH_PHYTIUM_XMAC_CONFIG_IRQ_FUNC(port);\ +ETH_PHYTIUM_XMAC_DEV_CONFIG(port);\ +ETH_PHYTIUM_XMAC_DEV_DATA(port);\ +ETH_PHYTIUM_XMAC_DMA_AREA_DECL(port);\ +ETH_PHYTIUM_XMAC_DMA_AREA_INST(port);\ +ETH_PHYTIUM_XMAC_NET_DEV_INIT(port);\ + + +#endif diff --git a/drivers/pinctrl/CMakeLists.txt b/drivers/pinctrl/CMakeLists.txt index 1dce91d5977..6ab336dadb0 100644 --- a/drivers/pinctrl/CMakeLists.txt +++ b/drivers/pinctrl/CMakeLists.txt @@ -38,5 +38,6 @@ zephyr_library_sources_ifdef(CONFIG_PINCTRL_MCI_IO_MUX pinctrl_mci_io_mux.c) zephyr_library_sources_ifdef(CONFIG_PINCTRL_ENE_KB1200 pinctrl_ene_kb1200.c) zephyr_library_sources_ifdef(CONFIG_PINCTRL_IMX_SCU pinctrl_imx_scu.c) zephyr_library_sources_ifdef(CONFIG_PINCTRL_MAX32 pinctrl_max32.c) +zephyr_library_sources_ifdef(CONFIG_PINCTRL_PHYTIUM pinctrl_phytium.c) add_subdirectory(renesas) diff --git a/drivers/pinctrl/Kconfig b/drivers/pinctrl/Kconfig index b919fa0f169..bb8d4283881 100644 --- a/drivers/pinctrl/Kconfig +++ b/drivers/pinctrl/Kconfig @@ -66,6 +66,7 @@ source "drivers/pinctrl/Kconfig.mci_io_mux" source "drivers/pinctrl/Kconfig.ene" source "drivers/pinctrl/Kconfig.zynqmp" source "drivers/pinctrl/Kconfig.max32" +source "drivers/pinctrl/Kconfig.phytium" rsource "renesas/Kconfig" diff --git a/drivers/pinctrl/Kconfig.phytium b/drivers/pinctrl/Kconfig.phytium new file mode 100644 index 00000000000..e0c80c267d1 --- /dev/null +++ b/drivers/pinctrl/Kconfig.phytium @@ -0,0 +1,22 @@ +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +# +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# https://opensource.org/license/apache-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. + +config PINCTRL_PHYTIUM + bool "Pin controller driver for phytium" + default n + depends on DT_HAS_PHYTIUM_PINCTRL_ENABLED + + help + Enable pin controller driver for phytium . \ No newline at end of file diff --git a/drivers/pinctrl/pinctrl_phytium.c b/drivers/pinctrl/pinctrl_phytium.c new file mode 100644 index 00000000000..e80da694d4b --- /dev/null +++ b/drivers/pinctrl/pinctrl_phytium.c @@ -0,0 +1,99 @@ +// Phytium is pleased to support the open source community by making Zephyr-SDK available. + +// +// Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +// +// Licensed under the Apache-2.0 License (the "License"); you may not use this file except +// in compliance with the License. You may obtain a copy of the License at +// +// https://opensource.org/license/apache-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 +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define DT_DRV_COMPAT phytium_pinctrl +LOG_MODULE_REGISTER(pinctrl, CONFIG_PINCTRL_LOG_LEVEL); + +FIOPadCtrl iopad_ctrl; + +static FError pinctrl_configure_pin(const pinctrl_soc_pin_t *pin) +{ + FError ret; + ret = FIOPadSetFunc(&iopad_ctrl, pin->pin_reg_offset, pin->func_num); + if (ret != FIOPAD_SUCCESS) + { + LOG_ERR("FIOPadSetFunc error."); + } + + return ret; +} + +int pinctrl_configure_pins(const pinctrl_soc_pin_t *pins, uint8_t pin_cnt, uintptr_t reg) +{ + FError ret; + ARG_UNUSED(reg); + for (uint8_t i = 0U; i < pin_cnt; i++) + { + ret = pinctrl_configure_pin(pins++); + if (ret != FIOPAD_SUCCESS) + { + LOG_ERR("pinctrl_configure_pin error."); + } + } + return 0; +} + +struct pinctrl_config { + DEVICE_MMIO_ROM; +}; + +struct pinctrl_data { + DEVICE_MMIO_RAM; +}; + +static int phytium_pinctrl_init(const struct device *dev) +{ + FIOPadConfig config_p; + config_p.instance_id = 0; + + DEVICE_MMIO_MAP(dev, K_MEM_CACHE_NONE); + FIOPadCfgInitialize(&iopad_ctrl, &config_p); + + iopad_ctrl.config.base_address = DEVICE_MMIO_GET(dev); + + return 0; +} + +#define PHYTIUM_PINCTRL_INIT(n) \ + static const struct pinctrl_config pinctrl_##n##_config = { \ + DEVICE_MMIO_ROM_INIT(DT_DRV_INST(n)), \ + }; \ + \ + static struct pinctrl_data pinctrl_##n##_data = { \ + }; \ + \ + DEVICE_DT_INST_DEFINE(n, \ + &phytium_pinctrl_init, \ + NULL, \ + &pinctrl_##n##_data, \ + &pinctrl_##n##_config, \ + PRE_KERNEL_1, \ + CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, \ + NULL); + +DT_INST_FOREACH_STATUS_OKAY(PHYTIUM_PINCTRL_INIT) + diff --git a/drivers/sdhc/CMakeLists.txt b/drivers/sdhc/CMakeLists.txt index 42985f873f1..f88a5e47e83 100644 --- a/drivers/sdhc/CMakeLists.txt +++ b/drivers/sdhc/CMakeLists.txt @@ -12,4 +12,5 @@ zephyr_library_sources_ifdef(CONFIG_INTEL_EMMC_HOST intel_emmc_host.c) zephyr_library_sources_ifdef(CONFIG_SDHC_INFINEON_CAT1 ifx_cat1_sdio.c) zephyr_library_sources_ifdef(CONFIG_CDNS_SDHC sdhc_cdns_ll.c sdhc_cdns.c) zephyr_library_sources_ifdef(CONFIG_SDHC_ESP32 sdhc_esp32.c) +zephyr_library_sources_ifdef(CONFIG_PHYTIUM_USDHC phytium_sdhc.c) endif() diff --git a/drivers/sdhc/Kconfig b/drivers/sdhc/Kconfig index b6b1276207b..26b75054009 100644 --- a/drivers/sdhc/Kconfig +++ b/drivers/sdhc/Kconfig @@ -17,6 +17,7 @@ source "drivers/sdhc/Kconfig.sam_hsmci" source "drivers/sdhc/Kconfig.intel" source "drivers/sdhc/Kconfig.sdhc_cdns" source "drivers/sdhc/Kconfig.esp32" +source "drivers/sdhc/Kconfig.phytium_sdhc" config SDHC_INIT_PRIORITY int "SDHC driver init priority" diff --git a/drivers/sdhc/Kconfig.phytium_sdhc b/drivers/sdhc/Kconfig.phytium_sdhc new file mode 100644 index 00000000000..9018be571cc --- /dev/null +++ b/drivers/sdhc/Kconfig.phytium_sdhc @@ -0,0 +1,49 @@ +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +# +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# https://opensource.org/license/apache-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. + +config PHYTIUM_USDHC + bool "PHYTIUM SDHC Driver" + default y + depends on DT_HAS_PHYTIUM_SDHC_ENABLED + select SDHC_SUPPORTS_NATIVE_MODE + select EVENTS + select PHYTIUM_PINCTRL + help + Enable the PHYTIUM SD Host controller driver + + +if PHYTIUM_USDHC + +config PHYTIUM_USDHC_DMA_SUPPORT + bool "DMA support for USDHC" + default y + select NOCACHE_MEMORY if ARCH_HAS_NOCACHE_MEMORY_SUPPORT + help + Enable DMA support for USDHC + +config PHYTIUM_PINCTRL + bool + +# SDIF DMA needs 32 bit aligned buffers +config SDHC_BUFFER_ALIGNMENT + int "Size of DMA descriptor buffer in bytes" + default 512 + +config PHYTIUM_SDIF_DMA_DESC_LENGTH + int "Length of DMA descriptor length" + default 256 + help + Size of PHYTIUM SDIF DMA descriptor length +endif \ No newline at end of file diff --git a/drivers/sdhc/phytium_sdhc.c b/drivers/sdhc/phytium_sdhc.c new file mode 100644 index 00000000000..b2be77b446f --- /dev/null +++ b/drivers/sdhc/phytium_sdhc.c @@ -0,0 +1,1003 @@ +// Phytium is pleased to support the open source community by making Zephyr-SDK available. + +// +// Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +// +// Licensed under the Apache-2.0 License (the "License"); you may not use this file except +// in compliance with the License. You may obtain a copy of the License at +// +// https://opensource.org/license/apache-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. + +#define DT_DRV_COMPAT phytium_sdhc + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + + +static void card_stoptrans(const struct device *dev) ; + +static int card_setblcok(const struct device *dev, uint32_t num_blocks) ; + + +LOG_MODULE_REGISTER(sdhc, CONFIG_SDHC_LOG_LEVEL); + +#define FSDIF_IRQ_BIT_CMD_DONE 1 +#define FSDIF_IRQ_BIT_DATA_DONE 2 +#define FSDIF_IRQ_BIT_ERROR_OCCUR 4 +#define FSDIF_IRQ_CMD_BIT_MASK (FSDIF_IRQ_BIT_CMD_DONE|FSDIF_IRQ_BIT_ERROR_OCCUR) +#define FSDIF_IRQ_DATA_BIT_MASK (FSDIF_IRQ_BIT_CMD_DONE|FSDIF_IRQ_BIT_DATA_DONE|FSDIF_IRQ_BIT_ERROR_OCCUR) + +typedef enum +{ + FSDIF_CLK_SPEED_400KHZ_IDX = 0, + FSDIF_CLK_SPEED_25_MHZ_IDX , + FSDIF_CLK_SPEED_26_MHZ_IDX , + FSDIF_CLK_SPEED_50_MHZ_IDX , + FSDIF_CLK_SPEED_52_MHZ_IDX , + FSDIF_CLK_SPEED_100_MHZ_IDX , + FSDIF_CLK_SPEED_200_MHZ_IDX , + FSDIF_CLK_SPEED_NUM +} sdhc_speed_mod ; + +typedef struct +{ + boolean use_hold; /* 1: CMD[29] = 1, equal to add one sampling time delay */ + uint32_t clk_div; /* for reg 0x8 */ + uint32_t clk_src; /* for reg 0x108 */ + uint32_t shift; /* for reg 0x110 */ +} sdhc_static_timming ; + + + +struct usdhc_config { + DEVICE_MMIO_ROM; + const struct device *clock_dev; + uint32_t pio_id ; + uint32_t pio_base ; + uint32_t pio_length; + uint32_t instance_id ; + uint32_t is_enable_irq ; + uint32_t enable_dma ; + /* smaple timing data */ + sdhc_static_timming static_timming[FSDIF_CLK_SPEED_NUM] ; + bool detect_dat3; + bool no_180_vol; + uint32_t data_timeout; + uint32_t write_watermark; + bool mmc_hs200_1_8v; + bool mmc_hs400_1_8v; + void (*irq_config_func)(const struct device *dev); + +}; + +struct usdhc_data { + DEVICE_MMIO_RAM; + struct sdhc_host_props props; + bool card_present; + struct sdhc_io host_io; + struct k_mutex access_mutex; +#ifdef CONFIG_PHYTIUM_USDHC_DMA_SUPPORT + FSdifIDmaDesc *usdhc_dma_descriptor; /* ADMA descriptor table (noncachable) */ + uint32_t dma_descriptor_len; /* DMA descriptor table length in words */ +#endif + /* pin ctrl */ + FIOPadCtrl iopad_ctrl; + FSdif instance ; + FSdifCmdData cmd_data ; + FSdifData trans_data ; + u32 is_enable_dma ; + struct k_event irq_event; /* include err、cmd、data event */ + +}; + +typedef struct +{ + boolean use_hold; /* 1: CMD[29] = 1, equal to add one sampling time delay */ + u32 clk_div; /* for reg 0x8 */ + u32 clk_src; /* for reg 0x108 */ + u32 shift; /* for reg 0x110 */ + void (*pad_delay)(void *instance); /* method to adjust pad delay ,with args*/ +} fsdhc_timming; /* SDIF timing configuration */ + + + +#define FSDIF_0_SD_CCLK_OUT_DELAY FIOPAD_AJ49_REG1_OFFSET +#define FSDIF_1_SD_CCLK_OUT_DELAY FIOPAD_J57_REG1_OFFSET + +/** + * @name: FSdifUpdateExternalClk + * @msg: update uhs clock value and wait clock ready + * @return {FError} + * @param {uintptr} base_addr + * @param {u32} uhs_reg_val + */ +static FError FSdifUpdateExternalClk(uintptr base_addr, u32 uhs_reg_val) +{ + u32 reg_val; + int retries = FSDIF_TIMEOUT; + FSDIF_WRITE_REG(base_addr, FSDIF_CLK_SRC_OFFSET, 0U); + FSDIF_WRITE_REG(base_addr, FSDIF_CLK_SRC_OFFSET, uhs_reg_val); + + do + { + reg_val = FSDIF_READ_REG(base_addr, FSDIF_CKSTS_OFFSET); + if (--retries <= 0) + { + break; + } + } + while (!(reg_val & FSDIF_CLK_READY)); + + return (retries <= 0) ? FSDIF_ERR_TIMEOUT : FSDIF_SUCCESS; +} + +/* irq test */ +static void FSDIFHOST_CardDetected(FSdif *const instance_p, void *args, u32 status, u32 dmac_status) +{ + (void)instance_p; + (void)status; + (void)dmac_status; + LOG_DBG("Card detected !!!"); +} + +static void FSDIFHOST_CmdDone(FSdif *const instance_p, void *args, u32 status, u32 dmac_status) +{ + struct usdhc_data *data = (struct usdhc_data *)args; + (void)instance_p; + (void)status; + (void)dmac_status; + /*Replace cmd_done by event */ + k_event_post(&data->irq_event,FSDIF_IRQ_BIT_CMD_DONE) ; +} + +static void FSDIFHOST_DataDone(FSdif *const instance_p, void *args, u32 status, u32 dmac_status) +{ + struct usdhc_data *data = (struct usdhc_data *)args; + + uint32_t check_status = status & (FSDIF_INT_DTO_BIT | FSDIF_INT_RCRC_BIT | + FSDIF_INT_DCRC_BIT | FSDIF_INT_RE_BIT | + FSDIF_INT_DRTO_BIT | FSDIF_INT_EBE_BIT | + FSDIF_INT_SBE_BCI_BIT | FSDIF_INT_RTO_BIT); + uint32_t check_dmac = dmac_status & (FSDIF_DMAC_STATUS_AIS | FSDIF_DMAC_STATUS_DU); + + if (check_status | check_dmac) + { + if (check_status & FSDIF_INT_DTO_BIT) + { + /* Replace data_done by event */ + k_event_post(&data->irq_event,FSDIF_IRQ_BIT_DATA_DONE) ; + } + else + { + LOG_DBG("Xfer data error, status: 0x%x, dmac status: 0x%x", + check_status, check_dmac); + } + } +} + +static void FSDIFHOST_ErrorOccur(FSdif *const instance_p, void *args, u32 status, u32 dmac_status) +{ + struct usdhc_data *data = (struct usdhc_data *)args; + LOG_ERR("Error occur !!!"); + LOG_ERR("Status: 0x%x, dmac status: 0x%x.", status, dmac_status); + + if (status & FSDIF_INT_RE_BIT) + LOG_ERR("Response err. 0x%x", (uint32_t)FSDIF_INT_RE_BIT); + + if (status & FSDIF_INT_RTO_BIT) + LOG_ERR("Response timeout. 0x%x", (uint32_t)FSDIF_INT_RTO_BIT); + + if (dmac_status & FSDIF_DMAC_STATUS_DU) + LOG_ERR("Descriptor un-readable. 0x%x", (uint32_t)FSDIF_DMAC_STATUS_DU); + + if (status & FSDIF_INT_DCRC_BIT) + LOG_ERR("Data CRC error. 0x%x", (uint32_t)FSDIF_INT_DCRC_BIT); + + if (status & FSDIF_INT_RCRC_BIT) + LOG_ERR("Data CRC error. 0x%x", (uint32_t)FSDIF_INT_RCRC_BIT); + + /* Replace data_done by event */ + k_event_post(&data->irq_event,FSDIF_IRQ_BIT_CMD_DONE|FSDIF_IRQ_BIT_ERROR_OCCUR) ; +} + + + +static void FSdifSetSDIFDelay(void * instance) +{ + /* + for SD-0: 0x32b31120 = 0x1f00 + SD-1: 0x32b31178 = 0x1f00 + */ + FIOPadCtrl * iopad_ctrl = (FIOPadCtrl * )instance; + u32 reg; + + if (FSDIF0_ID == iopad_ctrl->config.instance_id) + { + reg = FSDIF_0_SD_CCLK_OUT_DELAY; + } + else + { + reg = FSDIF_1_SD_CCLK_OUT_DELAY; + } + + FIOPadSetDelay(iopad_ctrl, reg, FIOPAD_OUTPUT_DELAY, FIOPAD_DELAY_COARSE_TUNING, FIOPAD_DELAY_1); + FIOPadSetDelay(iopad_ctrl, reg, FIOPAD_OUTPUT_DELAY, FIOPAD_DELAY_FINE_TUNING, FIOPAD_DELAY_7); + FIOPadSetDelayEn(iopad_ctrl, reg, FIOPAD_OUTPUT_DELAY, TRUE); +} + +static void FSdifUnsetSDIFDelay(void * instance) +{ + /* + for SD-0: 0x32b31120 = 0x0 + SD-1: 0x32b31178 = 0x0 + */ + FIOPadCtrl * iopad_ctrl = (FIOPadCtrl *)instance; + u32 reg; + + if (FSDIF0_ID == iopad_ctrl->config.instance_id) + { + reg = FSDIF_0_SD_CCLK_OUT_DELAY; + } + else + { + reg = FSDIF_1_SD_CCLK_OUT_DELAY; + } + + FIOPadSetDelay(iopad_ctrl, reg, FIOPAD_OUTPUT_DELAY, FIOPAD_DELAY_COARSE_TUNING, FIOPAD_DELAY_NONE); + FIOPadSetDelay(iopad_ctrl, reg, FIOPAD_OUTPUT_DELAY, FIOPAD_DELAY_FINE_TUNING, FIOPAD_DELAY_NONE); + FIOPadSetDelayEn(iopad_ctrl, reg, FIOPAD_OUTPUT_DELAY, FALSE); +} + +/* default timing settings in e2000q demo board */ +static fsdhc_timming mmc_sd_400khz = +{ + .use_hold = 1, + .clk_div = 0x7e7dfa, + .clk_src = 0x000502, + .shift = 0x0, + .pad_delay = FSdifUnsetSDIFDelay, +}; + +static fsdhc_timming sd_25mhz = +{ + .use_hold = 1, + .clk_div = 0x030204, + .clk_src = 0x000302, + .shift = 0x0, + .pad_delay = FSdifUnsetSDIFDelay, +}; + +static fsdhc_timming sd_50mhz = +{ + .use_hold = 1, + .clk_div = 0x030204, + .clk_src = 0x000502, + .shift = 0x0, + .pad_delay = FSdifSetSDIFDelay +}; + +static fsdhc_timming sd_100mhz = +{ + .use_hold = 0, + .clk_div = 0x010002, + .clk_src = 0x000202, + .shift = 0x0, + .pad_delay = FSdifSetSDIFDelay, +}; + +static fsdhc_timming mmc_26mhz = +{ + .use_hold = 1, + .clk_div = 0x030204, + .clk_src = 0x000302, + .shift = 0x0, + .pad_delay = FSdifSetSDIFDelay, +}; + +static fsdhc_timming mmc_52mhz = +{ + .use_hold = 0, + .clk_div = 0x030204, + .clk_src = 0x000202, + .shift = 0x0, + .pad_delay = FSdifSetSDIFDelay, +}; + +const fsdhc_timming *fsdif_hc_get_timming(FSdifClkSpeed clock_freq, boolean non_removable) +{ + const fsdhc_timming * tuning = NULL; + + if (clock_freq == FSDIF_CLK_SPEED_400KHZ) + { + return &mmc_sd_400khz; + } + + if (non_removable) + { + /* for emmc card */ + switch (clock_freq) + { + case FSDIF_CLK_SPEED_26_MHZ: + tuning = &mmc_26mhz; + break; + case FSDIF_CLK_SPEED_52_MHZ: + tuning = &mmc_52mhz; + break; + /* TODO: more clock freq for tuning */ + default: + break; + } + } + else + { + /* for sd card */ + switch (clock_freq) + { + case FSDIF_CLK_SPEED_25_MHZ: + tuning = &sd_25mhz; + break; + case FSDIF_CLK_SPEED_50_MHZ: + tuning = &sd_50mhz; + break; + case FSDIF_CLK_SPEED_100_MHZ: + tuning = &sd_100mhz; + break; + /* TODO: more clock freq for tuning */ + default: + break; + } + } + + return tuning; +} + + +/* + * Reset USDHC controller + */ +static int phytium_sdhc_reset(const struct device *dev) +{ + struct usdhc_data *data = dev->data; + FSdif *instance = &data->instance ; + + return FSdifRestart(instance) == 0 ? 0 : -ETIMEDOUT; + +} + + +static int phytium_sdhc_set_io(const struct device *dev, struct sdhc_io *ios) +{ + struct usdhc_data *data = dev->data; + FSdif *instance = &data->instance ; + FIOPadCtrl *pin_ctrl = &data->iopad_ctrl ; + struct sdhc_io *host_io = &data->host_io; + const fsdhc_timming *target_timing; + u32 mci_cmd_bits = FSDIF_CMD_UPD_CLK; + FError ret ; + uint32_t cmd_reg; + uint32_t cur_cmd_index; + + LOG_DBG("SDHC I/O: bus width %d, clock %dHz, card power %s, voltage %s \r\n", + ios->bus_width, + ios->clock, + ios->power_mode == SDHC_POWER_ON ? "ON" : "OFF", + ios->signal_voltage == SD_VOL_1_8_V ? "1.8V" : "3.3V" + ); + + /* host clock , must have */ + if(ios->clock > 0) + { + cmd_reg = FSDIF_READ_REG(instance->config.base_addr, FSDIF_CMD_OFFSET); + cur_cmd_index = FSDIF_CMD_INDX_GET(cmd_reg); + + if (FSDIF_SWITCH_VOLTAGE == cur_cmd_index) + { + mci_cmd_bits |= FSDIF_CMD_VOLT_SWITCH; + } + + target_timing = fsdif_hc_get_timming(ios->clock,instance->config.non_removable) ; + if (NULL == target_timing) + { + LOG_ERR("No available timeing !!!"); + return -ENOTSUP; + } + + /* update pad delay */ + if (target_timing->pad_delay) + { + target_timing->pad_delay(pin_ctrl); + } + + /* update clock source setting */ + if (FSDIF_SUCCESS != FSdifUpdateExternalClk(instance->config.base_addr, target_timing->clk_src)) + { + LOG_ERR("update clock source failed !!!"); + return -ENOTSUP; + } + + FSdifSetClock(instance->config.base_addr, FALSE); + + /* update clock for clock source */ + if (FSDIF_SWITCH_VOLTAGE == cur_cmd_index) + { + ret = FSdifSendPrivateCmd11(instance->config.base_addr, mci_cmd_bits | cmd_reg); + } + else + { + ret = FSdifSendPrivateCmd(instance->config.base_addr, mci_cmd_bits, 0); + } + + if (FSDIF_SUCCESS != ret) + { + LOG_ERR("update ext clock failed !!!"); + return -ret; + } + + /* set clock divider */ + FSDIF_WRITE_REG(instance->config.base_addr, FSDIF_CLKDIV_OFFSET, target_timing->clk_div); + + FSDIF_WRITE_REG(instance->config.base_addr, FSDIF_ENABLE_SHIFT_OFFSET, target_timing->shift); + + LOG_DBG("clk_src: 0x%x clk_div: 0x%x, shift: 0x%x", + FSDIF_READ_REG(instance->config.base_addr, FSDIF_CLK_SRC_OFFSET), + FSDIF_READ_REG(instance->config.base_addr, FSDIF_CLKDIV_OFFSET), + FSDIF_READ_REG(instance->config.base_addr, FSDIF_ENABLE_SHIFT_OFFSET)); + + FSdifSetClock(instance->config.base_addr, TRUE); + + /* sd card issue */ + if (FSDIF_SWITCH_VOLTAGE == cur_cmd_index) + { + ret = FSdifSendPrivateCmd11(instance->config.base_addr, mci_cmd_bits | cmd_reg); + } + else + { + ret = FSdifSendPrivateCmd(instance->config.base_addr, mci_cmd_bits, 0); + } + + + instance->curr_timing = (const FSdifTiming *)target_timing; + + } + + /* bus width */ + if (host_io->bus_width != ios->bus_width) { + switch (ios->bus_width) { + case SDHC_BUS_WIDTH1BIT: + FSdifSetBusWidth(instance->config.base_addr, 1); + break; + case SDHC_BUS_WIDTH4BIT: + FSdifSetBusWidth(instance->config.base_addr, 4); + break; + case SDHC_BUS_WIDTH8BIT: + FSdifSetBusWidth(instance->config.base_addr, 8); + break; + default: + return -ENOTSUP; + } + host_io->bus_width = ios->bus_width; + } + /* only surpport 3.3V */ + /* Set host signal voltage */ + if (ios->signal_voltage != host_io->signal_voltage) { + switch (ios->signal_voltage) { + case SD_VOL_3_3_V: + case SD_VOL_3_0_V: + FSdifSetVoltage1_8V(instance->config.base_addr, FALSE); + break; + case SD_VOL_1_8_V: + break; + default: + return -ENOTSUP; + } + /* Save new host voltage */ + host_io->signal_voltage = ios->signal_voltage; + } + return 0; +} + + +static int phytium_sdhc_card_busy(const struct device *dev) +{ + struct usdhc_data *device_data = dev->data; + FSdif *instance = &device_data->instance ; + + return FSdifCheckIfCardBusy(instance->config.base_addr) ? 1 : 0; +} + + +#define SPI_MASK ((1U << 4) | (2U << 4) | (3U << 4) | (4U << 4) | (5U << 4) | (6U << 4) | (7U << 4)) + +static void phytium_cmddata_convert_dri_data(struct sdhc_command *cmd, struct sdhc_data *data, FSdifCmdData *cmd_data) +{ + cmd->response_type &= ~SPI_MASK ; + + if(cmd->opcode == SD_GO_IDLE_STATE) + { + cmd_data->flag |= FSDIF_CMD_FLAG_NEED_INIT; + } + + if((cmd->opcode == SD_GO_INACTIVE_STATE) && + ((cmd->arg >> 9) & 0x1FFFF) == SD_SWITCH) + { + cmd_data->flag |= FSDIF_CMD_FLAG_ABORT; + } + + if(SD_RSP_TYPE_NONE != cmd->response_type) + { + cmd_data->flag |= FSDIF_CMD_FLAG_EXP_RESP; + + if(cmd->response_type == SD_RSP_TYPE_R2) + { + cmd_data->flag |= FSDIF_CMD_FLAG_EXP_LONG_RESP; + } + + if((cmd->response_type != SD_RSP_TYPE_R3) && + (cmd->response_type != SD_RSP_TYPE_R4)) + { + cmd_data->flag |= FSDIF_CMD_FLAG_NEED_RESP_CRC; + } + } + + if(cmd->opcode == SD_VOL_SWITCH) + { + cmd_data->flag |= FSDIF_CMD_FLAG_SWITCH_VOLTAGE; + } + + if(cmd->opcode == SD_GO_INACTIVE_STATE) + { + /* CMD15 go inactive and abort current transfer */ + cmd_data->flag |= FSDIF_CMD_FLAG_ABORT; + } + + if(data) + { + cmd_data->flag |= FSDIF_CMD_FLAG_EXP_DATA; + + switch(cmd->opcode) + { + case SD_WRITE_SINGLE_BLOCK: + case SD_WRITE_MULTIPLE_BLOCK: + cmd_data->flag |= FSDIF_CMD_FLAG_WRITE_DATA; + cmd_data->data_p->buf = data->data; + cmd_data->data_p->buf_dma = (uintptr_t)data->data; + break; + default: + cmd_data->flag |= FSDIF_CMD_FLAG_READ_DATA; + cmd_data->data_p->buf = data->data; + // This assumes that the data pointer can be used as a DMA address, which might not always be correct. + cmd_data->data_p->buf_dma = (uintptr_t)data->data; + break; + } + + cmd_data->data_p->blksz = data->block_size; + cmd_data->data_p->blkcnt = data->blocks; + cmd_data->data_p->datalen = data->block_size * data->blocks; + } + + cmd_data->cmdidx = cmd->opcode; + cmd_data->cmdarg = cmd->arg; + +} + +static int phytium_sdhc_request(const struct device *dev, struct sdhc_command *cmd, struct sdhc_data *data) +{ + struct usdhc_data *device_data = dev->data; + struct usdhc_config *device_config = (struct usdhc_config *)dev->config; + FSdif *instance = &device_data->instance ; + FSdifCmdData *cmd_data = &device_data->cmd_data ; + uint32_t timeout = 5000U ; + uint32_t wait_timeout_cnt = 0 ; + uint32_t events = 0; + uint32_t end_event = 0; /* 0 is init ,1 is finish ,2 is err ocurr */ + uint32_t wait_mask = 0; + + /* add send cmd23 */ + if(cmd->opcode == SD_WRITE_MULTIPLE_BLOCK||cmd->opcode == SD_READ_MULTIPLE_BLOCK) + { + if(card_setblcok(dev,data->blocks)) + { + LOG_ERR("FSdifDMATransfer is error") ; + return -EHOSTUNREACH; + } + } + + /* init event data is zero */ + if(device_config->is_enable_irq) + { + k_event_set(&device_data->irq_event,0) ; + } + + memset(&device_data->cmd_data,0,sizeof(FSdifCmdData)) ; + if(data) + { + memset(&device_data->trans_data,0,sizeof(FSdifData)) ; + cmd_data->data_p = &device_data->trans_data ; + wait_mask = FSDIF_IRQ_BIT_CMD_DONE | FSDIF_IRQ_BIT_DATA_DONE ; + } + else + { + cmd_data->data_p = NULL ; + wait_mask = FSDIF_IRQ_BIT_CMD_DONE ; + } + + phytium_cmddata_convert_dri_data(cmd,data,cmd_data) ; + + if(device_data->is_enable_dma) + { + if (0 != FSdifDMATransfer(instance, cmd_data)) + { + LOG_ERR("FSdifDMATransfer is error") ; + return -EHOSTUNREACH; + } + } + else + { + if (FSDIF_SUCCESS != FSdifPIOTransfer(instance, cmd_data)) + { + LOG_ERR("FSdifPIOTransfer is error") ; + return -EHOSTUNREACH; + } + } + + if(device_config->is_enable_irq) + { + do + { + events = k_event_wait(&device_data->irq_event,wait_mask|FSDIF_IRQ_BIT_ERROR_OCCUR,false,K_MSEC(1)) ; + if(events & FSDIF_IRQ_BIT_ERROR_OCCUR) + { + end_event = 2 ; + break ; + } + else if((events & wait_mask) == wait_mask) + { + end_event = 1 ; + break ; + } + else + { + wait_timeout_cnt ++ ; + end_event = 3 ; + } + }while (wait_timeout_cnt < 0xffffff) ; + + if(end_event == 2) + { + return -EIO ; + } + else if(end_event == 3) + { + return -ETIME ; + } + + } + else + { + /* If the interrupt is not enabled */ + if(device_data->is_enable_dma) + { + /* If the interrupt is not enabled */ + if (0 != FSdifPollWaitDMAEnd(instance, cmd_data)) + { + LOG_ERR("FSdifPollWaitDMAEnd is error") ; + return -ETIMEDOUT; + } + } + else + { + /* If the interrupt is not enabled */ + if (FSDIF_SUCCESS != FSdifPollWaitPIOEnd(instance,cmd_data)) + { + LOG_ERR("FSdifPollWaitPIOEnd is error") ; + return -ETIMEDOUT; + } + } + } + /* wait event is over */ + if(0 != FSdifGetCmdResponse(instance, cmd_data)) + { + LOG_ERR("FSdifGetCmdResponse is error") ; + + if(cmd_data->data_p) + { + card_stoptrans(dev) ; + + while (timeout > 0) { + if (!phytium_sdhc_card_busy(dev)) { + break; + } + /* Wait 125us before polling again */ + k_busy_wait(125); + timeout -= 125; + } + if (timeout <= 0) { + LOG_DBG("Card did not idle after CMD12"); + k_mutex_unlock(&device_data->access_mutex); + return -ETIMEDOUT; + } + + return -ETIMEDOUT; + } + + return -ETIMEDOUT; + } + + if(SD_RSP_TYPE_NONE != cmd->response_type) + { + memcpy(cmd->response,&cmd_data->response,sizeof(u32) * 4) ; + } + + return 0; +} + + + +/* Stops transmission after failed command with CMD12 */ +static void card_stoptrans(const struct device *dev) +{ + struct sdhc_command cmd = {0}; + + cmd.opcode = SD_STOP_TRANSMISSION; + cmd.arg = 0; + + cmd.response_type = (SD_RSP_TYPE_R1b); + + phytium_sdhc_request(dev, &cmd, NULL) ; + +} + +static int card_setblcok(const struct device *dev, uint32_t num_blocks) +{ + struct sdhc_command cmd = {0}; + + /* + * See the note in card_read() above. We will not issue CMD23 + * or CMD12, and expect the host to handle those details. + */ + cmd.opcode = SD_SET_BLOCK_COUNT; + + cmd.arg = num_blocks; + + cmd.response_type = (SD_RSP_TYPE_R1); + + return phytium_sdhc_request(dev, &cmd, NULL) ; +} + + + + +static int phytium_sdhc_get_card_present(const struct device *dev) +{ + struct usdhc_data *data = dev->data; + FSdif *instance = &data->instance ; + + data->card_present = FSdifCheckIfCardExists(instance->config.base_addr) ? true : false ; + return data->card_present ; +} + + +static int phytium_sdhc_get_host_props(const struct device *dev, + struct sdhc_host_props *props) +{ + struct usdhc_data *data = dev->data; + + memcpy(props, &data->props, sizeof(struct sdhc_host_props)); + return 0; +} + +static int phytium_sdhc_isr(const struct device *dev) +{ + // const struct usdhc_config *cfg = dev->config; + struct usdhc_data *data = dev->data; + FSdif *instance = &data->instance ; + + FSdifInterruptHandler(0, instance); + return 0; +} + + +static void phytium_sdhc_init_host_props(const struct device *dev) +{ + struct usdhc_data *data = dev->data; + struct sdhc_host_props *props = &data->props; + + memset(props, 0, sizeof(struct sdhc_host_props)); + props->f_max = 50000000U; + props->f_min = 400000; + + props->host_caps.vol_180_support = false; + props->host_caps.vol_300_support = true; + props->host_caps.vol_330_support = true; + props->host_caps.suspend_res_support = false; + props->host_caps.high_spd_support = true; + + props->host_caps.ddr50_support = false; + props->host_caps.sdr104_support = false; + props->host_caps.sdr50_support = false; + + props->host_caps.bus_4_bit_support = true; + props->host_caps.bus_8_bit_support = false; + props->host_caps.hs200_support = false; + props->host_caps.hs400_support = false; +} + + +void phytium_relax_delay(void) +{ + k_usleep(1); +} + + +static int phytium_usdhc_init(const struct device *dev) +{ + struct usdhc_config *cfg = (struct usdhc_config *)dev->config; + struct usdhc_data *data = (struct usdhc_data *)dev->data; + FSdifConfig sdhc_cfg; + FIOPadConfig io_config = {0} ; + + /* init base */ + DEVICE_MMIO_MAP(dev, K_MEM_CACHE_NONE); + /* control init */ + sdhc_cfg.base_addr = DEVICE_MMIO_GET(dev) ; + sdhc_cfg.instance_id = cfg->instance_id; /* Device instance id */ + LOG_DBG("sdhc_cfg.instance_id is %d \r\n",sdhc_cfg.instance_id) ; + + sdhc_cfg.non_removable = FALSE ; /* No removeable media, e.g eMMC */ + sdhc_cfg.get_tuning = NULL ; /* Get time-tuning related parameters and method */ +#if defined(CONFIG_PHYTIUM_USDHC_DMA_SUPPORT) + data->is_enable_dma = 1 ; +#else + data->is_enable_dma = 0 ; +#endif + + if(data->is_enable_dma) + { + sdhc_cfg.trans_mode = FSDIF_IDMA_TRANS_MODE ; /* Trans mode, PIO/DMA */ + } + else + { + sdhc_cfg.trans_mode = FSDIF_PIO_TRANS_MODE ; /* Trans mode, PIO/DMA */ + } + + /* init pio init */ + io_config.instance_id = cfg->pio_id ; + + device_map(&io_config.base_address, + cfg->pio_base, + cfg->pio_length, + K_MEM_CACHE_NONE); + + if(0 != FIOPadCfgInitialize(&data->iopad_ctrl, &io_config)) + { + LOG_ERR("FIOPadCfgInitialize is error") ; + } + + if(0 != FSdifCfgInitialize(&data->instance,&sdhc_cfg)) + { + LOG_ERR("FSdifCfgInitialize is error") ; + } + data->instance.relax_handler = phytium_relax_delay ; + + phytium_sdhc_init_host_props(dev) ; + /* irq init */ + if(cfg->is_enable_irq) + { + if(cfg->irq_config_func) + { + FSdifRegisterEvtHandler(&data->instance, FSDIF_EVT_CARD_DETECTED, FSDIFHOST_CardDetected, (void *)data); + FSdifRegisterEvtHandler(&data->instance, FSDIF_EVT_ERR_OCCURE, FSDIFHOST_ErrorOccur, (void *)data); + FSdifRegisterEvtHandler(&data->instance, FSDIF_EVT_CMD_DONE, FSDIFHOST_CmdDone, (void *)data); + FSdifRegisterEvtHandler(&data->instance, FSDIF_EVT_DATA_DONE, FSDIFHOST_DataDone, (void *)data); + cfg->irq_config_func(dev) ; + } + } + +#if defined(CONFIG_PHYTIUM_USDHC_DMA_SUPPORT) + + if(data->is_enable_dma) + { + + if(FSdifSetIDMAList(&data->instance,data->usdhc_dma_descriptor,(uintptr)data->usdhc_dma_descriptor,CONFIG_PHYTIUM_SDIF_DMA_DESC_LENGTH)) + { + LOG_ERR("Init dma is error ") ; + return -EPERM; + } + } + +#endif + + /* init host_io */ + memset(&data->host_io, 0, sizeof(data->host_io)); + /* access_mutex */ + k_mutex_init(&data->access_mutex); + /* transfer_sem */ + k_event_init(&data->irq_event) ; + return 0 ; +} + +static const struct sdhc_driver_api usdhc_api = { + .reset = phytium_sdhc_reset, + .request = phytium_sdhc_request, + .set_io = phytium_sdhc_set_io, + .get_card_present = phytium_sdhc_get_card_present, + .execute_tuning = NULL, + .card_busy = phytium_sdhc_card_busy, + .get_host_props = phytium_sdhc_get_host_props, +}; + +#ifdef CONFIG_NOCACHE_MEMORY +#define PHYTIUM_USDHC_NOCACHE_TAG __attribute__((__section__(".nocache"))); +#else +#define PHYTIUM_USDHC_NOCACHE_TAG +#endif + +#ifdef CONFIG_PHYTIUM_USDHC_DMA_SUPPORT +#define PHYTIUM_USDHC_DMA_BUFFER_DEFINE(n) \ + static FSdifIDmaDesc __aligned(512) \ + usdhc_##n##_dma_descriptor[CONFIG_PHYTIUM_SDIF_DMA_DESC_LENGTH]\ + PHYTIUM_USDHC_NOCACHE_TAG; +#define PHYTIUM_USDHC_DMA_BUFFER_INIT(n) \ + .usdhc_dma_descriptor = usdhc_##n##_dma_descriptor, \ + .dma_descriptor_len = CONFIG_PHYTIUM_SDIF_DMA_DESC_LENGTH, + +#else +#define PHYTIUM_USDHC_DMA_BUFFER_DEFINE(n) +#define PHYTIUM_USDHC_DMA_BUFFER_INIT(n) +#endif /* CONFIG_PHYTIUM_USDHC_DMA_SUPPORT */ + +#define PHYTIUM_SDHC_INIT(n) \ + static void usdhc_##n##_irq_config_func(const struct device *dev) \ + { \ + IRQ_CONNECT(DT_INST_IRQN(n), DT_INST_IRQ(n, priority), \ + phytium_sdhc_isr, DEVICE_DT_INST_GET(n), 0); \ + irq_enable(DT_INST_IRQN(n)); \ + } \ + \ + static const struct usdhc_config usdhc_##n##_config = { \ + DEVICE_MMIO_ROM_INIT(DT_DRV_INST(n)), \ + .instance_id = n, \ + .no_180_vol = DT_INST_PROP(n, no_1_8_v), \ + .mmc_hs200_1_8v = DT_INST_PROP(n, mmc_hs200_1_8v), \ + .mmc_hs400_1_8v = DT_INST_PROP(n, mmc_hs400_1_8v), \ + .pio_id = DT_INST_PROP(n, pio_id), \ + .pio_base = DT_INST_PROP(n, pio_base), \ + .pio_length = DT_INST_PROP(n, pio_length), \ + .is_enable_irq = DT_INST_PROP(n, is_enable_irq),\ + .irq_config_func = usdhc_##n##_irq_config_func ,\ + }; \ + \ + \ + PHYTIUM_USDHC_DMA_BUFFER_DEFINE(n) \ + \ + static struct usdhc_data usdhc_##n##_data = { \ + .card_present = false, \ + PHYTIUM_USDHC_DMA_BUFFER_INIT(n) \ + }; \ + \ + DEVICE_DT_INST_DEFINE(n, \ + &phytium_usdhc_init, \ + NULL, \ + &usdhc_##n##_data, \ + &usdhc_##n##_config, \ + POST_KERNEL, \ + CONFIG_SDHC_INIT_PRIORITY, \ + &usdhc_api); + +DT_INST_FOREACH_STATUS_OKAY(PHYTIUM_SDHC_INIT) + + + diff --git a/drivers/serial/CMakeLists.txt b/drivers/serial/CMakeLists.txt index 9ac2f22920d..e59851875bb 100644 --- a/drivers/serial/CMakeLists.txt +++ b/drivers/serial/CMakeLists.txt @@ -41,6 +41,7 @@ zephyr_library_sources_ifdef(CONFIG_UART_STM32 uart_stm32.c) zephyr_library_sources_ifdef(CONFIG_UART_SAM0 uart_sam0.c) zephyr_library_sources_ifdef(CONFIG_UART_PSOC6 uart_psoc6.c) zephyr_library_sources_ifdef(CONFIG_UART_PL011 uart_pl011.c) +# zephyr_library_sources_ifdef(CONFIG_PHYTIUM_UART_PL011 uart_phytium_pl011.c) zephyr_library_sources_ifdef(CONFIG_UART_QUICKLOGIC_USBSERIALPORT_S3B uart_ql_usbserialport_s3b.c) zephyr_library_sources_ifdef(CONFIG_UART_RV32M1_LPUART uart_rv32m1_lpuart.c) zephyr_library_sources_ifdef(CONFIG_UART_RPI_PICO_PIO uart_rpi_pico_pio.c) diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig index faa150237c5..2d6c9b45d55 100644 --- a/drivers/serial/Kconfig +++ b/drivers/serial/Kconfig @@ -278,6 +278,8 @@ rsource "Kconfig.ene" rsource "Kconfig.rzt2m" +rsource "kconfig.phytium_pl011" + source "drivers/serial/Kconfig.renesas_ra8" endif # SERIAL diff --git a/drivers/serial/kconfig.phytium_pl011 b/drivers/serial/kconfig.phytium_pl011 new file mode 100644 index 00000000000..6e9a7912524 --- /dev/null +++ b/drivers/serial/kconfig.phytium_pl011 @@ -0,0 +1,21 @@ +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +# +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# https://opensource.org/license/apache-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. + +menuconfig PHYTIUM_UART_PL011 + bool "PHYTIUM PL011 UART Driver" + default y + select SERIAL_HAS_DRIVER + help + This option enables the UART driver for the PL011 diff --git a/drivers/serial/uart_phytium_pl011.c b/drivers/serial/uart_phytium_pl011.c new file mode 100644 index 00000000000..e6f04b16b47 --- /dev/null +++ b/drivers/serial/uart_phytium_pl011.c @@ -0,0 +1,148 @@ +// Phytium is pleased to support the open source community by making Zephyr-SDK available. + +// +// Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +// +// Licensed under the Apache-2.0 License (the "License"); you may not use this file except +// in compliance with the License. You may obtain a copy of the License at +// +// https://opensource.org/license/apache-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. + +#define DT_DRV_COMPAT phytium_pl011 /* phytium,pl011 */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +struct phytium_pl011_data { + DEVICE_MMIO_RAM; + uint32_t baud_rate; +#ifdef CONFIG_UART_INTERRUPT_DRIVEN + uart_irq_callback_user_data_t irq_cb; + void *irq_cb_data; +#endif + FPl011 instance ; +}; + +struct phytium_pl011_config { + DEVICE_MMIO_ROM; + uint32_t instance_id; + uint32_t sys_clk_freq; +#ifdef CONFIG_UART_INTERRUPT_DRIVEN + /*Interrupt initialization function through the device tree*/ + uart_irq_config_func_t irq_config_func; +#endif +}; + +static int pl011_poll_in(const struct device *dev, unsigned char *c) +{ + struct phytium_pl011_data *data = dev->data; + FPl011 *uart_p = &data->instance ; + + if(FUART_RECEIVEDATAEMPTY(uart_p->config.base_address)) + { + return -1 ; + } + + *c = FPl011RecvByte(uart_p->config.base_address) ; + + return (FUART_RECEIVEDATAEMPTY(uart_p->config.base_address) == 0); +} + +static void pl011_poll_out(const struct device *dev, + unsigned char c) +{ + struct phytium_pl011_data *data = dev->data; + FPl011 *uart_p = &data->instance ; + + FPl011SendByte(uart_p->config.base_address,c) ; +} + +static const struct uart_driver_api pl011_driver_api = { + .poll_in = pl011_poll_in, + .poll_out = pl011_poll_out, +}; + +static int pl011_init(const struct device *dev) +{ + const struct phytium_pl011_config *config = dev->config; + struct phytium_pl011_data *data = dev->data; + FPl011Config pl011_config = {0} ; + FError driver_ret ; + + FPl011Format format = + { + .baudrate = FPL011_BAUDRATE, + .data_bits = FPL011_FORMAT_WORDLENGTH_8BIT, + .parity = FPL011_FORMAT_NO_PARITY, + .stopbits = FPL011_FORMAT_1_STOP_BIT + }; + + DEVICE_MMIO_MAP(dev, K_MEM_CACHE_NONE); + + /* Id of device*/ + pl011_config.instance_id = config->instance_id; + pl011_config.base_address = DEVICE_MMIO_GET(dev) ; + pl011_config.ref_clock_hz = config->sys_clk_freq; + pl011_config.baudrate = data->baud_rate; + + driver_ret = FPl011CfgInitialize(&data->instance,&pl011_config) ; + + if(driver_ret) + { + return -1 ; + } + + driver_ret = FPl011SetDataFormat(&data->instance, &format); + + if(driver_ret) + { + return -2 ; + } + + /* set UART */ + FPl011SetOptions(&data->instance, FPL011_OPTION_UARTEN | FPL011_OPTION_FIFOEN | FPL011_OPTION_RXEN | FPL011_OPTION_TXEN | FPL011_OPTION_DTR | FPL011_OPTION_RTS); + + return 0; +} + + + + +#define PL011_CONFIG_PORT(n) \ + static struct phytium_pl011_config pl011_cfg_port_##n = { \ + DEVICE_MMIO_ROM_INIT(DT_DRV_INST(n)), \ + .sys_clk_freq = DT_INST_PROP_BY_PHANDLE(n, clocks, clock_frequency), \ + .instance_id = n \ + }; + + +#define PHYTIUM_PL011_INIT(n) \ + PL011_CONFIG_PORT(n) \ + \ + static struct phytium_pl011_data pl011_data_port_##n = { \ + .baud_rate = DT_INST_PROP(n, current_speed), \ + }; \ + \ + DEVICE_DT_INST_DEFINE(n, &pl011_init, \ + NULL, \ + &pl011_data_port_##n, \ + &pl011_cfg_port_##n, \ + PRE_KERNEL_1, \ + CONFIG_SERIAL_INIT_PRIORITY, \ + &pl011_driver_api); + +DT_INST_FOREACH_STATUS_OKAY(PHYTIUM_PL011_INIT) \ No newline at end of file diff --git a/dts/arm/phytium/e2000q.dtsi b/dts/arm/phytium/e2000q.dtsi new file mode 100644 index 00000000000..5c28ddcc4fc --- /dev/null +++ b/dts/arm/phytium/e2000q.dtsi @@ -0,0 +1,149 @@ +// Phytium is pleased to support the open source community by making Zephyr-SDK available. + +// +// Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +// +// Licensed under the Apache-2.0 License (the "License"); you may not use this file except +// in compliance with the License. You may obtain a copy of the License at +// +// https://opensource.org/license/apache-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 +#include +#include + + +/ { + cpus { + #address-cells = <2>; + #size-cells = <0>; + + cpu@0 { + device_type = "cpu"; + compatible = "phytium,ftc310"; + reg = <0 0x200>; + }; + + cpu@1 { + device_type = "cpu"; + compatible = "phytium,ftc310"; + reg = <0 0x201>; + }; + + cpu@2 { + device_type = "cpu"; + compatible = "phytium,ftc664"; + reg = <0 0>; + }; + + cpu@3 { + device_type = "cpu"; + compatible = "phytium,ftc664"; + reg = <0 0x100>; + }; + }; + + + + uartclk: apb-pclk { + compatible = "fixed-clock"; + clock-frequency = <100000000>; + #clock-cells = <0>; + }; + + soc { + interrupt-parent = <&gic>; + + timer { + compatible = "arm,armv8-timer"; + interrupt-parent = <&gic>; + // ppi =+ 16, 13 == 29 Security physical timer interrupt, 14 == 30 Non secure physical timer interrupt + interrupts = , + , + , + ; + }; + + + uart1: uart@2800d000 { + compatible = "arm,pl011"; + reg = <0x2800d000 0x1000>; + status = "disabled"; + interrupts = ; + interrupt-names = "irq_0"; + clocks = <&uartclk>; + }; + + gic: interrupt-controller@30800000 { + compatible = "arm,gic-v3", "arm,gic"; + reg = <0x30800000 0x40000>, + <0x30880000 0x80000>; + interrupt-controller; + #interrupt-cells = <4>; + status = "okay"; + #size-cells = <0x02>; + #address-cells = <0x02>; + }; + + + + sram0: memory@80100000 { + device_type = "memory"; + compatible = "mmio-sram"; + reg = <0x80100000 0x20000000>; + }; + + xmac0: xmac@3200C000 { + compatible = "phytium,xmac"; + reg = <0x3200C000 0x2000>; + status = "disabled"; + interrupts = ; + interrupt-names = "irq_0"; + phy-poll-interval = <1000>; + clock-frequency = <50000000> ; + phy-speed = <1000> ; + interface-mode = <0> ; + dma-brust-length = <16> ; + max-queue-num = <1> ; + rx-buffer-descriptors = <128>; + tx-buffer-descriptors = <32>; + rx-buffer-size = <1600>; + tx-buffer-size = <1600>; + phy-autonegotiation; + enable-fdx; + disable-reject-fcs-crc-errors ; + } ; + + sdhc0: sdhc@28000000 { + compatible = "phytium,sdhc"; + reg = <0x28000000 0x1000>; + status = "disabled"; + interrupts = ; + max-current-330 = <1020>; + max-bus-freq = <25000000>; + min-bus-freq = <400000>; + }; + + + sdhc1: sdhc@28001000 { + compatible = "phytium,sdhc"; + reg = <0x28001000 0x1000>; + status = "disabled"; + interrupts = ; + max-current-330 = <1020>; + max-bus-freq = <25000000>; + min-bus-freq = <400000>; + }; + + }; +}; diff --git a/dts/arm64/phytium/d2000.dtsi b/dts/arm64/phytium/d2000.dtsi new file mode 100644 index 00000000000..94cbb3d1b38 --- /dev/null +++ b/dts/arm64/phytium/d2000.dtsi @@ -0,0 +1,141 @@ +// Phytium is pleased to support the open source community by making Zephyr-SDK available. + +// +// Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +// +// Licensed under the Apache-2.0 License (the "License"); you may not use this file except +// in compliance with the License. You may obtain a copy of the License at +// +// https://opensource.org/license/apache-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 +#include +#include + +/ { + #address-cells = <2>; + #size-cells = <2>; + + cpus { + #address-cells = <2>; + #size-cells = <0>; + + cpu@0 { + device_type = "cpu"; + compatible = "phytium,ftc663"; + reg = <0 0x0>; + }; + + cpu@1 { + device_type = "cpu"; + compatible = "phytium,ftc663"; + reg = <0 0x1>; + }; + + cpu@2 { + device_type = "cpu"; + compatible = "phytium,ftc663"; + reg = <0 0x100>; + }; + + cpu@3 { + device_type = "cpu"; + compatible = "phytium,ftc663"; + reg = <0 0x101>; + }; + + cpu@4 { + device_type = "cpu"; + compatible = "phytium,ftc663"; + reg = <0 0x200>; + }; + + cpu@5 { + device_type = "cpu"; + compatible = "phytium,ftc663"; + reg = <0 0x201>; + }; + + cpu@6 { + device_type = "cpu"; + compatible = "phytium,ftc663"; + reg = <0 0x300>; + }; + + cpu@7 { + device_type = "cpu"; + compatible = "phytium,ftc663"; + reg = <0 0x301>; + }; + + }; + + timer { + compatible = "arm,armv8-timer"; + interrupt-parent = <&gic>; + // ppi =+ 16, 13 == 29 Security physical timer interrupt, 14 == 30 Non secure physical timer interrupt + interrupts = , + , + , + ; + }; + + uartclk: apb-pclk { + compatible = "fixed-clock"; + clock-frequency = <48000000>; + #clock-cells = <0>; + }; + + soc { + #address-cells = <2>; + #size-cells = <2>; + ranges; + + interrupt-parent = <&gic>; + + gic: interrupt-controller@29a00000 { + compatible = "arm,gic-v3", "arm,gic"; + reg = <0x00 0x29A00000 0x00 0x40000>, + <0x00 0x29B00000 0x00 0x100000>; + interrupt-controller; + #interrupt-cells = <4>; + status = "okay"; + #size-cells = <0x02>; + #address-cells = <0x02>; + }; + + uart1: uart@28001000 { + compatible = "arm,pl011"; + reg = <0x00 0x28001000 0x00 0x1000>; + status = "disabled"; + interrupts = ; + interrupt-names = "irq_0"; + clocks = <&uartclk>; + }; + + uart2: uart@28002000 { + compatible = "arm,pl011"; + reg = <0x00 0x28002000 0x00 0x1000>; + status = "disabled"; + interrupts = ; + interrupt-names = "irq_1"; + clocks = <&uartclk>; + }; + + /* 512MB DDR */ + sram0: memory@80100000 { + device_type = "memory"; + compatible = "mmio-sram"; + reg = <0x00 0x80100000 0x00 0x20000000>; + }; + }; +}; diff --git a/dts/arm64/phytium/d3000.dtsi b/dts/arm64/phytium/d3000.dtsi new file mode 100644 index 00000000000..f5b3c044477 --- /dev/null +++ b/dts/arm64/phytium/d3000.dtsi @@ -0,0 +1,135 @@ +// Phytium is pleased to support the open source community by making Zephyr-SDK available. + +// +// Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +// +// Licensed under the Apache-2.0 License (the "License"); you may not use this file except +// in compliance with the License. You may obtain a copy of the License at +// +// https://opensource.org/license/apache-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 +#include +#include + +/ { + #address-cells = <2>; + #size-cells = <2>; + + cpus { + #address-cells = <2>; + #size-cells = <0>; + + cpu@0 { + device_type = "cpu"; + compatible = "phytium,ftc862"; + reg = <0 0x0>; + }; + + cpu@1 { + device_type = "cpu"; + compatible = "phytium,ftc862"; + reg = <0 0x100>; + }; + + cpu@2 { + device_type = "cpu"; + compatible = "phytium,ftc862"; + reg = <0 0x200>; + }; + + cpu@3 { + device_type = "cpu"; + compatible = "phytium,ftc862"; + reg = <0 0x300>; + }; + + cpu@4 { + device_type = "cpu"; + compatible = "phytium,ftc862"; + reg = <0 0x10000>; + }; + + cpu@5 { + device_type = "cpu"; + compatible = "phytium,ftc862"; + reg = <0 0x10100>; + }; + + cpu@6 { + device_type = "cpu"; + compatible = "phytium,ftc862"; + reg = <0 0x10200>; + }; + + cpu@7 { + device_type = "cpu"; + compatible = "phytium,ftc862"; + reg = <0 0x10300>; + }; + }; + + timer { + compatible = "arm,armv8-timer"; + interrupt-parent = <&gic>; + // ppi =+ 16, 13 == 29 Security physical timer interrupt, 14 == 30 Non secure physical timer interrupt + interrupts = , + , + , + ; + label = "arch_timer"; + }; + + uartclk: apb-pclk { + compatible = "fixed-clock"; + clock-frequency = <100000000>; + #clock-cells = <0>; + }; + + soc { + #address-cells = <2>; + #size-cells = <2>; + ranges; + + interrupt-parent = <&gic>; + + gic: interrupt-controller@36800000 { + compatible = "arm,gic-v3", "arm,gic"; + reg = <0x00 0x36800000 0x00 0x40000>, + <0x00 0x36860000 0x00 0x200000>; + interrupt-controller; + #interrupt-cells = <4>; + label = "GIC"; + status = "okay"; + #size-cells = <0x02>; + #address-cells = <0x02>; + }; + + uart1: uart@28009000 { + compatible = "arm,pl011"; + reg = <0x00 0x28009000 0x00 0x1000>; + status = "disabled"; + interrupts = ; + interrupt-names = "irq_0"; + clocks = <&uartclk>; + label = "UART_1"; + }; + + /* 512MB DDR */ + sram0: memory@80100000 { + device_type = "memory"; + compatible = "mmio-sram"; + reg = <0x00 0x80100000 0x00 0x40000000>; + }; + + }; +}; diff --git a/dts/arm64/phytium/e2000d.dtsi b/dts/arm64/phytium/e2000d.dtsi new file mode 100644 index 00000000000..397540ea202 --- /dev/null +++ b/dts/arm64/phytium/e2000d.dtsi @@ -0,0 +1,149 @@ +// Phytium is pleased to support the open source community by making Zephyr-SDK available. + +// +// Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +// +// Licensed under the Apache-2.0 License (the "License"); you may not use this file except +// in compliance with the License. You may obtain a copy of the License at +// +// https://opensource.org/license/apache-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 +#include +#include + +/ { + #address-cells = <2>; + #size-cells = <2>; + + cpus { + #address-cells = <2>; + #size-cells = <0>; + + cpu@0 { + device_type = "cpu"; + compatible = "phytium,ftc310"; + reg = <0 0x200>; + }; + + cpu@1 { + device_type = "cpu"; + compatible = "phytium,ftc310"; + reg = <0 0x201>; + }; + + }; + + timer { + compatible = "arm,armv8-timer"; + interrupt-parent = <&gic>; + // ppi =+ 16, 13 == 29 安全物理定时器中断, 14 == 30 非安全物理定时器中断 + interrupts = , + , + , + ; + }; + + uartclk: apb-pclk { + compatible = "fixed-clock"; + clock-frequency = <100000000>; + #clock-cells = <0>; + }; + + soc { + #address-cells = <2>; + #size-cells = <2>; + ranges; + + interrupt-parent = <&gic>; + + gic: interrupt-controller@30800000 { + compatible = "arm,gic-v3", "arm,gic"; + reg = <0x00 0x30800000 0x00 0x40000>, + <0x00 0x30880000 0x00 0x80000>; + interrupt-controller; + #interrupt-cells = <4>; + status = "okay"; + #size-cells = <0x02>; + #address-cells = <0x02>; + }; + + uart1: uart@2800d000 { + compatible = "arm,pl011"; + reg = <0x00 0x2800d000 0x00 0x1000>; + status = "disabled"; + interrupts = ; + interrupt-names = "irq_0"; + clocks = <&uartclk>; + }; + + uart2: uart@2800E000 { + compatible = "arm,pl011"; + reg = <0x00 0x2800E000 0x00 0x1000>; + status = "disabled"; + interrupts = ; + interrupt-names = "irq_1"; + clocks = <&uartclk>; + }; + + sdhc0: sdhc@28000000 { + compatible = "phytium,sdhc"; + reg = <0x00 0x28000000 0x00 0x1000>; + status = "disabled"; + interrupts = ; + max-current-330 = <1020>; + max-bus-freq = <25000000>; + min-bus-freq = <400000>; + }; + + + sdhc1: sdhc@28001000 { + compatible = "phytium,sdhc"; + reg = <0x00 0x28001000 0x00 0x1000>; + status = "disabled"; + interrupts = ; + max-current-330 = <1020>; + max-bus-freq = <25000000>; + min-bus-freq = <400000>; + }; + + + xmac0: xmac@3200C000 { + compatible = "phytium,xmac"; + reg = <0x00 0x3200C000 0x00 0x2000>; + status = "disabled"; + interrupts = ; + interrupt-names = "irq_0"; + phy-poll-interval = <1000>; + clock-frequency = <50000000> ; + phy-speed = <1000> ; + interface-mode = <0> ; + dma-brust-length = <16> ; + max-queue-num = <1> ; + rx-buffer-descriptors = <128>; + tx-buffer-descriptors = <32>; + rx-buffer-size = <1600>; + tx-buffer-size = <1600>; + phy-autonegotiation; + enable-fdx; + disable-reject-fcs-crc-errors ; + } ; + + /* 256MB DDR */ + sram0: memory@80100000 { + device_type = "memory"; + compatible = "mmio-sram"; + reg = <0x00 0x80100000 0x00 0x10000000>; + }; + }; +}; diff --git a/dts/arm64/phytium/e2000q.dtsi b/dts/arm64/phytium/e2000q.dtsi new file mode 100644 index 00000000000..8724b329e97 --- /dev/null +++ b/dts/arm64/phytium/e2000q.dtsi @@ -0,0 +1,177 @@ +// Phytium is pleased to support the open source community by making Zephyr-SDK available. + +// +// Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +// +// Licensed under the Apache-2.0 License (the "License"); you may not use this file except +// in compliance with the License. You may obtain a copy of the License at +// +// https://opensource.org/license/apache-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 +#include +#include + +/ { + #address-cells = <2>; + #size-cells = <2>; + + cpus { + #address-cells = <2>; + #size-cells = <0>; + + cpu@0 { + device_type = "cpu"; + compatible = "phytium,ftc310"; + reg = <0 0x200>; + }; + + cpu@1 { + device_type = "cpu"; + compatible = "phytium,ftc310"; + reg = <0 0x201>; + }; + + cpu@2 { + device_type = "cpu"; + compatible = "phytium,ftc664"; + reg = <0 0>; + }; + + cpu@3 { + device_type = "cpu"; + compatible = "phytium,ftc664"; + reg = <0 0x100>; + }; + + }; + + timer { + compatible = "arm,armv8-timer"; + interrupt-parent = <&gic>; + // ppi =+ 16, 13 == 29 Security physical timer interrupt, 14 == 30 Non secure physical timer interrupt + interrupts = , + , + , + ; + }; + + uartclk: apb-pclk { + compatible = "fixed-clock"; + clock-frequency = <100000000>; + #clock-cells = <0>; + }; + + soc { + #address-cells = <2>; + #size-cells = <2>; + ranges; + + interrupt-parent = <&gic>; + + gic: interrupt-controller@30800000 { + compatible = "arm,gic-v3", "arm,gic"; + reg = <0x00 0x30800000 0x00 0x40000>, + <0x00 0x30880000 0x00 0x80000>; + interrupt-controller; + #interrupt-cells = <4>; + status = "okay"; + #size-cells = <0x02>; + #address-cells = <0x02>; + }; + + pinctrl: pinctrl@32B30000 { + compatible = "phytium,pinctrl"; + reg = <0x00 0x32B30000 0x00 0x2000>; + status = "okay"; + }; + + uart1: uart@2800d000 { + compatible = "arm,pl011"; + reg = <0x00 0x2800d000 0x00 0x1000>; + status = "disabled"; + interrupts = ; + interrupt-names = "irq_0"; + clocks = <&uartclk>; + }; + + uart2: uart@2800E000 { + compatible = "arm,pl011"; + reg = <0x00 0x2800E000 0x00 0x1000>; + status = "disabled"; + interrupts = ; + interrupt-names = "irq_1"; + clocks = <&uartclk>; + }; + + sdhc0: sdhc@28000000 { + compatible = "phytium,sdhc"; + reg = <0x00 0x28000000 0x00 0x1000>; + status = "disabled"; + interrupts = ; + max-current-330 = <1020>; + max-bus-freq = <25000000>; + min-bus-freq = <400000>; + }; + + xmac0: xmac@3200C000 { + compatible = "phytium,xmac"; + reg = <0x00 0x3200C000 0x00 0x2000>; + status = "disabled"; + interrupts = ; + interrupt-names = "irq_0"; + phy-poll-interval = <5000>; + clock-frequency = <50000000> ; + phy-speed = <1000> ; + interface-mode = <0> ; + dma-brust-length = <16> ; + max-queue-num = <1> ; + rx-buffer-descriptors = <128>; + tx-buffer-descriptors = <128>; + rx-buffer-size = <1600>; + tx-buffer-size = <1600>; + phy-autonegotiation; + enable-fdx; + disable-reject-fcs-crc-errors ; + } ; + + sdhc1: sdhc@28001000 { + compatible = "phytium,sdhc"; + reg = <0x00 0x28001000 0x00 0x1000>; + status = "disabled"; + interrupts = ; + max-current-330 = <1020>; + max-bus-freq = <25000000>; + min-bus-freq = <400000>; + }; + + /* 512MB DDR */ + sram0: memory@80100000 { + device_type = "memory"; + compatible = "mmio-sram"; + reg = <0x00 0x80100000 0x00 0x20000000>; + }; + + pcie0: pcie@40000000 { + compatible = "pci-host-ecam-generic"; + device_type = "pci"; + reg = <0x00 0x40000000 0x00 0x10000000>; + #size-cells = <0x02>; + #address-cells = <0x03>; + ranges = <0x1000000 0x00 0x50000000 0x00 0x50000000 0x00 0x08000000 + 0x2000000 0x00 0x58000000 0x00 0x58000000 0x00 0x27ffffff + 0x3000000 0x10 0x00 0x10 0x00 0x1f 0xffffffff>; + bus-range = <0x00 0xff>; + }; + }; +}; diff --git a/dts/bindings/cpu/phytium,ftc310.yaml b/dts/bindings/cpu/phytium,ftc310.yaml new file mode 100644 index 00000000000..e1f9c01fcc3 --- /dev/null +++ b/dts/bindings/cpu/phytium,ftc310.yaml @@ -0,0 +1,20 @@ +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +# +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# https://opensource.org/license/apache-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. + +description: Phytium ftc310 arm CPU + +compatible: "phytium,ftc310" + +include: cpu.yaml \ No newline at end of file diff --git a/dts/bindings/cpu/phytium,ftc663.yaml b/dts/bindings/cpu/phytium,ftc663.yaml new file mode 100644 index 00000000000..5e8e7ef56f1 --- /dev/null +++ b/dts/bindings/cpu/phytium,ftc663.yaml @@ -0,0 +1,20 @@ +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +# +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# https://opensource.org/license/apache-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. + +description: Phytium ftc663 arm CPU + +compatible: "phytium,ftc663" + +include: cpu.yaml \ No newline at end of file diff --git a/dts/bindings/cpu/phytium,ftc862.yaml b/dts/bindings/cpu/phytium,ftc862.yaml new file mode 100644 index 00000000000..60dae60453e --- /dev/null +++ b/dts/bindings/cpu/phytium,ftc862.yaml @@ -0,0 +1,20 @@ +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +# +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# https://opensource.org/license/apache-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. + +description: Phytium ftc862 arm CPU + +compatible: "phytium,ftc862" + +include: cpu.yaml \ No newline at end of file diff --git a/dts/bindings/ethernet/phytium,xmac.yaml b/dts/bindings/ethernet/phytium,xmac.yaml new file mode 100644 index 00000000000..a17038ebbe8 --- /dev/null +++ b/dts/bindings/ethernet/phytium,xmac.yaml @@ -0,0 +1,233 @@ +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +# +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# https://opensource.org/license/apache-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. + +description: Phytium xmac Ethernet controller + +compatible: "phytium,xmac" + +include: ethernet-controller.yaml + +properties: + reg: + required: true + + interrupts: + required: true + + clock-frequency: + type: int + required: true + description: | + Specifies the base clock frequency from which the XMAC's TX clock + frequency . + + phy-poll-interval: + type: int + required: true + description: | + PHY status polling interval in milliseconds for a driver instance + managing an associated PHY. + + phy-speed: + type: int + required: true + description: | + Nominal link speed. If no PHY is managed by an instance of this driver, + the respective controller will be configured to match the link speed + specified here. If a PHY is managed by the driver, advertisement of + the link speed specified here will be requested. If the optional pro- + perty advertise-lower-link-speeds is set, advertisement of the link + speed specified here plus any valid link speed below this value will + be requested. + enum: + - 10 + - 100 + - 1000 + - 10000 + + + interface-mode: + type: int + required: true + description: | + Specifies the interface mode for the Xmac. Each mode corresponds to a different type of media-independent interface that determines how the Ethernet PHY is connected to the MAC. The available modes are: + - 0: SGMII (Serial Gigabit Media Independent Interface), a serial version of the Gigabit Media Independent Interface that is used for Gigabit Ethernet connections. + - 1: RMII (Reduced Media Independent Interface), a reduced version of the Media Independent Interface designed for 10/100Mbps Ethernet connections with a reduced number of signal lines. + - 2: RGMII (Reduced Gigabit Media Independent Interface), a version of the Gigabit Media Independent Interface designed for 10/100/1000Mbps Ethernet connections with a reduced number of signal lines. + - 3: USXGMII (Universal Serial 10 Gigabit Media Independent Interface), a serial interface designed for speeds beyond 1Gbps, supporting a range of speeds up to 10Gbps over a single pair of copper or optical fiber. + enum: + - 0 + - 1 + - 2 + - 3 + + + + dma-brust-length: + type: int + required: true + description: | + Defines the burst length for DMA (Direct Memory Access) operations in the Xmac driver. + The burst length specifies the maximum number of words the DMA controller can transfer in a single burst. + Adjusting this parameter can impact the efficiency of data transfers between the Ethernet MAC and the system memory, + potentially affecting overall throughput and latency. A value of 16 indicates that the DMA controller is configured to transfer up to 16 words in a single burst. + Choosing the optimal burst length depends on the specific characteristics of the system, including the DMA controller's capabilities and the memory system's response to burst accesses. + enum: + - 16 + + + max-queue-num: + type: int + required: true + description: | + Specifies the maximum number of queue slots available for managing Ethernet frames in the Xmac driver. + This parameter determines the capacity of the driver to handle multiple Ethernet frames concurrently, + which can influence the efficiency of packet processing, especially under high network traffic conditions. + A value of 1 indicates that the driver is configured to manage Ethernet frames using a single queue. + This configuration is suitable for simpler network setups or systems with lower traffic demands. + Implementing multiple queues can be advantageous in systems that require high throughput and efficient traffic management, + but this comes at the cost of increased complexity in queue management. + enum: + - 1 + + + phy-autonegotiation: + type: boolean + description: | + Determines whether the PHY (Physical Layer Transceiver) should use autonegotiation to automatically select the speed and duplex mode of the Ethernet connection. + When enabled (`true`), the PHY will communicate with the link partner (typically a switch, router, or another network device) to determine the best mutual settings for speed (10/100/1000 Mbps) and duplex mode (half or full duplex). + This process ensures compatibility and optimizes the connection for the best possible performance. + When disabled (`false`), the PHY will not initiate or respond to autonegotiation attempts, and the speed and duplex mode must be manually configured to match the link partner's settings, potentially reducing flexibility and compatibility. + + + enable-fdx: + type: boolean + description: | + Indicates whether the PHY (Physical Layer Transceiver) should operate in full-duplex mode. + In full-duplex mode (`true`), the Ethernet connection supports simultaneous bi-directional data transmission, allowing data to be sent and received at the same time, + effectively doubling the potential throughput compared to half-duplex. + This mode is ideal for high-speed networks where data collisions are managed and can significantly enhance network performance. + When set to `false`, the PHY operates in half-duplex mode, where data transmission and reception cannot occur simultaneously, + leading to a possible increase in data collisions and retransmissions, especially in high traffic conditions. + Selecting the appropriate duplex mode depends on network infrastructure, cable types, and the capabilities of the network devices involved in the connection. + + + enable-jumbo: + type: boolean + description: | + Specifies whether Jumbo Frames are enabled for the Ethernet device. Jumbo Frames are Ethernet frames with a payload greater than the standard maximum of 1500 bytes, + often up to 9000 bytes (9 KB). Enabling Jumbo Frames (`true`) can significantly increase data transfer efficiency by reducing the number of frames needed to transmit large amounts of data, + thereby decreasing CPU usage, increasing throughput, and improving network performance. + However, all devices in the network path must support Jumbo Frames to avoid fragmentation or dropped packets. + Disabling this feature (`false`) restricts the Ethernet frames to standard sizes, ensuring compatibility with network devices that do not support Jumbo Frames. + + + enable-ucast-hash: + type: boolean + description: | + Determines whether unicast hash filtering is enabled for the Ethernet device. + When activated (`true`), this feature allows the network interface to filter incoming unicast packets based on a hash function applied to the destination MAC address. + This mechanism is particularly useful in managing network traffic by ensuring that the Ethernet device processes only those unicast packets that match its hash criteria, + effectively reducing unnecessary packet processing and improving overall network efficiency. + This is beneficial in environments with high traffic levels or when the network interface is part of a larger, segmented network setup. + Disabling this feature (`false`) means the device will not use hash-based filtering for incoming unicast frames, + potentially leading to increased processing of irrelevant packets. + + + copy-all-frames: + type: boolean + description: | + Controls whether the Ethernet device is set to copy all incoming frames to system memory, + regardless of their destination MAC address. When enabled (`true`), + this feature instructs the device to pass all observed frames to the higher layers of the network stack, + effectively putting the network interface in a promiscuous mode. This mode is essential for network monitoring, + packet sniffing, and debugging tasks, where it's necessary to examine all traffic passing through the network segment the device is attached to. + However, it can lead to increased processing overhead due to the higher volume of data being passed up the stack. When disabled (`false`), + the device filters incoming frames, processing only those addressed to it or broadcast/multicast frames, + depending on its configuration, which is the normal operation mode for most network interfaces. + + + disable-reject-fcs-crc-errors: + type: boolean + description: | + Optional feature flag - Disable rejection of FCS/CRC errors. + When set, frames with FCS/CRC errors will not be rejected. FCS error + statistics will still be collected for frames with bad FCS and FCS + status will be recorded in the frame's DMA descriptor. This option + should not be activated for normal operation. + + enable-mcast-hash: + type: boolean + description: | + Enables multicast hash filtering for the Ethernet device. + When set to `true`, this feature allows the network interface to utilize a hash function on the destination MAC address of incoming multicast packets to determine if they should be passed to the system for processing. + This targeted approach helps manage multicast traffic more efficiently by ensuring the device processes only those multicast packets that match predefined criteria, + reducing unnecessary data processing and enhancing network throughput. This is especially beneficial in environments with substantial multicast traffic, such as multimedia streaming or multicast group communications. When disabled (`false`), + the device may not use hash-based filtering for multicast frames, which could result in increased processing of multicast packets that are not of interest to the receiving system. + + + handle-rx-in-isr: + type: boolean + description: | + Moves the handling of the frame received interrupt including the + transfer of packet data from the DMA to network packet buffers and + the subsequent propagation of the received packets to the network + stack into the context of the ISR. Due to the unpredictability of + the runtime of the ISR whenever large amounts of data are received, + handling of the RX interrupt is normally deferred to the context + of the system work queue. + + + handle-tx-in-workq: + type: boolean + description: | + Moves the handling of the frame transmission done interrupt into the + context of the system work queue. By default, TX done handling is per- + formed in the context of the ISR, as it only involves a limited number + of memory accesses. This option CAN NOT be used if any component ex- + ists within the current system setup that triggers the transmission + of packets from within the context of the system work queue! + + + rx-buffer-descriptors: + type: int + required: true + description: | + The number of descriptors to be allocated in the RX buffer descriptor + ring. Must be <= 255. + + + rx-buffer-size: + type: int + required: true + description: | + The size of each receive data buffer, must be a multiple of 8, highest + valid value is 16320, values less than 64 are not really useful. + + + tx-buffer-descriptors: + type: int + required: true + description: | + The number of descriptors to be allocated in the TX buffer descriptor + ring. Must be <= 255. + + tx-buffer-size: + type: int + required: true + description: | + The size of each transmit data buffer, highest valid value is 16380, + values less than 64 are not really useful. + diff --git a/dts/bindings/pinctrl/phytium,pinctrl.yaml b/dts/bindings/pinctrl/phytium,pinctrl.yaml new file mode 100644 index 00000000000..3a2e5da838d --- /dev/null +++ b/dts/bindings/pinctrl/phytium,pinctrl.yaml @@ -0,0 +1,38 @@ + +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +# +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# https://opensource.org/license/apache-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. + +description: | + Phytium pinctrl node + +compatible: "phytium,pinctrl" + +include: base.yaml + +properties: + reg: + required: true + +child-binding: + description: | + This binding gives a base representation of the Phytium + pin configuration. + + properties: + pinmux: + required: true + type: array + description: | + Phytium pin configuration. diff --git a/dts/bindings/sdhc/phytium,sdhc.yaml b/dts/bindings/sdhc/phytium,sdhc.yaml new file mode 100644 index 00000000000..152f92213b6 --- /dev/null +++ b/dts/bindings/sdhc/phytium,sdhc.yaml @@ -0,0 +1,61 @@ +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +# +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# https://opensource.org/license/apache-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. + +description: Phytium SDHC controller + +compatible: "phytium,sdhc" + +include: [sdhc.yaml] + +properties: + reg: + required: true + + pio-id: + type: int + + default: 0 + description: | + pio id + + pio-base: + type: int + default: 0x28008000 + description: | + pio base + + pio-length: + type: int + default: 0x1000 + description: | + pio length + + is-enable-irq: + type: int + default: 1 + description: | + enable irq + + data-timeout: + type: int + default: 0xF + description: | + Data timeout, as multiple of the SD clock. See DTOCV field of USDHC + + no-1-8-v: + type: boolean + description: | + When the external SD card circuit does not support 1.8V, add this + property to disable 1.8v card voltage of SD card controller. diff --git a/dts/bindings/serial/arm,pl011.yaml b/dts/bindings/serial/arm,pl011.yaml index e823638ede0..80b4f2a7c18 100644 --- a/dts/bindings/serial/arm,pl011.yaml +++ b/dts/bindings/serial/arm,pl011.yaml @@ -10,3 +10,5 @@ properties: interrupts: required: true + + diff --git a/dts/bindings/serial/phytium,pl011.yaml b/dts/bindings/serial/phytium,pl011.yaml new file mode 100644 index 00000000000..8b5804e7e45 --- /dev/null +++ b/dts/bindings/serial/phytium,pl011.yaml @@ -0,0 +1,27 @@ +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +# +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# https://opensource.org/license/apache-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. + +description: PHYTIUM PL011 UART + +compatible: "phytium,pl011" + +include: [uart-controller.yaml, pinctrl-device.yaml] + +properties: + reg: + required: true + + interrupts: + required: true diff --git a/include/zephyr/arch/arm/arch.h b/include/zephyr/arch/arm/arch.h index 804e1d23dbd..759df697f83 100644 --- a/include/zephyr/arch/arm/arch.h +++ b/include/zephyr/arch/arm/arch.h @@ -43,7 +43,7 @@ #elif defined(CONFIG_CPU_AARCH32_CORTEX_R) || defined(CONFIG_CPU_AARCH32_CORTEX_A) #include #include -#if defined(CONFIG_AARCH32_ARMV8_R) +#if defined(CONFIG_AARCH32_ARMV8_R) || defined(CONFIG_CPU_AARCH32_ARMV8) #include #include #else diff --git a/include/zephyr/arch/arm/cortex_a_r/cpu.h b/include/zephyr/arch/arm/cortex_a_r/cpu.h index 13455fe6ac4..ccaf2b880e4 100644 --- a/include/zephyr/arch/arm/cortex_a_r/cpu.h +++ b/include/zephyr/arch/arm/cortex_a_r/cpu.h @@ -85,7 +85,7 @@ #define ICC_SRE_EL3_EN_BIT BIT(3) /* MPIDR */ -#define MPIDR_AFFLVL_MASK (0xff) +#define MPIDR_AFFLVL_MASK (0xfff) #define MPIDR_AFF0_SHIFT (0) #define MPIDR_AFF1_SHIFT (8) diff --git a/include/zephyr/dt-bindings/pinctrl/phytium-e2000q-pinctrl.h b/include/zephyr/dt-bindings/pinctrl/phytium-e2000q-pinctrl.h new file mode 100644 index 00000000000..9bf9b8a8fd9 --- /dev/null +++ b/include/zephyr/dt-bindings/pinctrl/phytium-e2000q-pinctrl.h @@ -0,0 +1,278 @@ +// Phytium is pleased to support the open source community by making Zephyr-SDK available. + +// +// Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +// +// Licensed under the Apache-2.0 License (the "License"); you may not use this file except +// in compliance with the License. You may obtain a copy of the License at +// +// https://opensource.org/license/apache-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 ZEPHYR_INCLUDE_DT_BINDINGS_PINCTRL_PHYTIUM_PINCTRL_H_ +#define ZEPHYR_INCLUDE_DT_BINDINGS_PINCTRL_PHYTIUM_PINCTRL_H_ + +#define FIOPAD_AN59_REG0_OFFSET 0x0000U +#define FIOPAD_AW47_REG0_OFFSET 0x0004U +#define FIOPAD_AR55_REG0_OFFSET 0x0020U +#define FIOPAD_AJ55_REG0_OFFSET 0x0024U +#define FIOPAD_AL55_REG0_OFFSET 0x0028U +#define FIOPAD_AL53_REG0_OFFSET 0x002CU +#define FIOPAD_AN51_REG0_OFFSET 0x0030U +#define FIOPAD_AR51_REG0_OFFSET 0x0034U +#define FIOPAD_BA57_REG0_OFFSET 0x0038U +#define FIOPAD_BA59_REG0_OFFSET 0x003CU +#define FIOPAD_AW57_REG0_OFFSET 0x0040U +#define FIOPAD_AW59_REG0_OFFSET 0x0044U +#define FIOPAD_AU55_REG0_OFFSET 0x0048U +#define FIOPAD_AN57_REG0_OFFSET 0x004CU +#define FIOPAD_AL59_REG0_OFFSET 0x0050U +#define FIOPAD_AJ59_REG0_OFFSET 0x0054U +#define FIOPAD_AJ57_REG0_OFFSET 0x0058U +#define FIOPAD_AG59_REG0_OFFSET 0x005CU +#define FIOPAD_AG57_REG0_OFFSET 0x0060U +#define FIOPAD_AE59_REG0_OFFSET 0x0064U +#define FIOPAD_AC59_REG0_OFFSET 0x0068U +#define FIOPAD_AC57_REG0_OFFSET 0x006CU +#define FIOPAD_AR49_REG0_OFFSET 0x0070U +#define FIOPAD_BA55_REG0_OFFSET 0x0074U +#define FIOPAD_BA53_REG0_OFFSET 0x0078U +#define FIOPAD_AR59_REG0_OFFSET 0x007CU +#define FIOPAD_AU59_REG0_OFFSET 0x0080U +#define FIOPAD_AR57_REG0_OFFSET 0x0084U +#define FIOPAD_BA49_REG0_OFFSET 0x0088U +#define FIOPAD_AW55_REG0_OFFSET 0x008CU +#define FIOPAD_A35_REG0_OFFSET 0x0090U +#define FIOPAD_R57_REG0_OFFSET 0x0094U +#define FIOPAD_R59_REG0_OFFSET 0x0098U +#define FIOPAD_U59_REG0_OFFSET 0x009CU +#define FIOPAD_W59_REG0_OFFSET 0x00A0U +#define FIOPAD_U57_REG0_OFFSET 0x00A4U +#define FIOPAD_AA57_REG0_OFFSET 0x00A8U +#define FIOPAD_AA59_REG0_OFFSET 0x00ACU +#define FIOPAD_AW51_REG0_OFFSET 0x00B0U +#define FIOPAD_AU51_REG0_OFFSET 0x00B4U +#define FIOPAD_A39_REG0_OFFSET 0x00B8U +#define FIOPAD_C39_REG0_OFFSET 0x00BCU +#define FIOPAD_C37_REG0_OFFSET 0x00C0U +#define FIOPAD_A37_REG0_OFFSET 0x00C4U +#define FIOPAD_A41_REG0_OFFSET 0x00C8U +#define FIOPAD_A43_REG0_OFFSET 0x00CCU +#define FIOPAD_A45_REG0_OFFSET 0x00D0U +#define FIOPAD_C45_REG0_OFFSET 0x00D4U +#define FIOPAD_A47_REG0_OFFSET 0x00D8U +#define FIOPAD_A49_REG0_OFFSET 0x00DCU +#define FIOPAD_C49_REG0_OFFSET 0x00E0U +#define FIOPAD_A51_REG0_OFFSET 0x00E4U +#define FIOPAD_A33_REG0_OFFSET 0x00E8U +#define FIOPAD_C33_REG0_OFFSET 0x00ECU +#define FIOPAD_C31_REG0_OFFSET 0x00F0U +#define FIOPAD_A31_REG0_OFFSET 0x00F4U +#define FIOPAD_AJ53_REG0_OFFSET 0x00F8U +#define FIOPAD_AL49_REG0_OFFSET 0x00FCU +#define FIOPAD_AL47_REG0_OFFSET 0x0100U +#define FIOPAD_AN49_REG0_OFFSET 0x0104U +#define FIOPAD_AG51_REG0_OFFSET 0x0108U +#define FIOPAD_AJ51_REG0_OFFSET 0x010CU +#define FIOPAD_AG49_REG0_OFFSET 0x0110U +#define FIOPAD_AE55_REG0_OFFSET 0x0114U +#define FIOPAD_AE53_REG0_OFFSET 0x0118U +#define FIOPAD_AG55_REG0_OFFSET 0x011CU +#define FIOPAD_AJ49_REG0_OFFSET 0x0120U +#define FIOPAD_AC55_REG0_OFFSET 0x0124U +#define FIOPAD_AC53_REG0_OFFSET 0x0128U +#define FIOPAD_AE51_REG0_OFFSET 0x012CU +#define FIOPAD_W51_REG0_OFFSET 0x0130U +#define FIOPAD_W55_REG0_OFFSET 0x0134U +#define FIOPAD_W53_REG0_OFFSET 0x0138U +#define FIOPAD_U55_REG0_OFFSET 0x013CU +#define FIOPAD_U53_REG0_OFFSET 0x0140U +#define FIOPAD_AE49_REG0_OFFSET 0x0144U +#define FIOPAD_AC49_REG0_OFFSET 0x0148U +#define FIOPAD_AE47_REG0_OFFSET 0x014CU +#define FIOPAD_AA47_REG0_OFFSET 0x0150U +#define FIOPAD_AA49_REG0_OFFSET 0x0154U +#define FIOPAD_W49_REG0_OFFSET 0x0158U +#define FIOPAD_AA51_REG0_OFFSET 0x015CU +#define FIOPAD_U49_REG0_OFFSET 0x0160U +#define FIOPAD_G59_REG0_OFFSET 0x0164U +#define FIOPAD_J59_REG0_OFFSET 0x0168U +#define FIOPAD_L57_REG0_OFFSET 0x016CU +#define FIOPAD_C59_REG0_OFFSET 0x0170U +#define FIOPAD_E59_REG0_OFFSET 0x0174U +#define FIOPAD_J57_REG0_OFFSET 0x0178U +#define FIOPAD_L59_REG0_OFFSET 0x017CU +#define FIOPAD_N59_REG0_OFFSET 0x0180U +#define FIOPAD_C57_REG0_OFFSET 0x0184U +#define FIOPAD_E57_REG0_OFFSET 0x0188U +#define FIOPAD_E31_REG0_OFFSET 0x018CU +#define FIOPAD_G31_REG0_OFFSET 0x0190U +#define FIOPAD_N41_REG0_OFFSET 0x0194U +#define FIOPAD_N39_REG0_OFFSET 0x0198U +#define FIOPAD_J33_REG0_OFFSET 0x019CU +#define FIOPAD_N33_REG0_OFFSET 0x01A0U +#define FIOPAD_L33_REG0_OFFSET 0x01A4U +#define FIOPAD_N45_REG0_OFFSET 0x01A8U +#define FIOPAD_N43_REG0_OFFSET 0x01ACU +#define FIOPAD_L31_REG0_OFFSET 0x01B0U +#define FIOPAD_J31_REG0_OFFSET 0x01B4U +#define FIOPAD_J29_REG0_OFFSET 0x01B8U +#define FIOPAD_E29_REG0_OFFSET 0x01BCU +#define FIOPAD_G29_REG0_OFFSET 0x01C0U +#define FIOPAD_N27_REG0_OFFSET 0x01C4U +#define FIOPAD_L29_REG0_OFFSET 0x01C8U +#define FIOPAD_J37_REG0_OFFSET 0x01CCU +#define FIOPAD_J39_REG0_OFFSET 0x01D0U +#define FIOPAD_G41_REG0_OFFSET 0x01D4U +#define FIOPAD_E43_REG0_OFFSET 0x01D8U +#define FIOPAD_L43_REG0_OFFSET 0x01DCU +#define FIOPAD_C43_REG0_OFFSET 0x01E0U +#define FIOPAD_E41_REG0_OFFSET 0x01E4U +#define FIOPAD_L45_REG0_OFFSET 0x01E8U +#define FIOPAD_J43_REG0_OFFSET 0x01ECU +#define FIOPAD_J41_REG0_OFFSET 0x01F0U +#define FIOPAD_L39_REG0_OFFSET 0x01F4U +#define FIOPAD_E37_REG0_OFFSET 0x01F8U +#define FIOPAD_E35_REG0_OFFSET 0x01FCU +#define FIOPAD_G35_REG0_OFFSET 0x0200U +#define FIOPAD_J35_REG0_OFFSET 0x0204U +#define FIOPAD_L37_REG0_OFFSET 0x0208U +#define FIOPAD_N35_REG0_OFFSET 0x020CU +#define FIOPAD_R51_REG0_OFFSET 0x0210U +#define FIOPAD_R49_REG0_OFFSET 0x0214U +#define FIOPAD_N51_REG0_OFFSET 0x0218U +#define FIOPAD_N55_REG0_OFFSET 0x021CU +#define FIOPAD_L55_REG0_OFFSET 0x0220U +#define FIOPAD_J55_REG0_OFFSET 0x0224U +#define FIOPAD_J45_REG0_OFFSET 0x0228U +#define FIOPAD_E47_REG0_OFFSET 0x022CU +#define FIOPAD_G47_REG0_OFFSET 0x0230U +#define FIOPAD_J47_REG0_OFFSET 0x0234U +#define FIOPAD_J49_REG0_OFFSET 0x0238U +#define FIOPAD_N49_REG0_OFFSET 0x023CU +#define FIOPAD_L51_REG0_OFFSET 0x0240U +#define FIOPAD_L49_REG0_OFFSET 0x0244U +#define FIOPAD_N53_REG0_OFFSET 0x0248U +#define FIOPAD_J53_REG0_OFFSET 0x024CU + +#define FIOPAD_REG0_BEG_OFFSET FIOPAD_AN59_REG0_OFFSET +#define FIOPAD_REG0_END_OFFSET FIOPAD_J53_REG0_OFFSET + +/* register offset of iopad delay */ +#define FIOPAD_AJ55_REG1_OFFSET 0x1024U +#define FIOPAD_AL55_REG1_OFFSET 0x1028U +#define FIOPAD_AL53_REG1_OFFSET 0x102CU +#define FIOPAD_AN51_REG1_OFFSET 0x1030U +#define FIOPAD_AR51_REG1_OFFSET 0x1034U +#define FIOPAD_AJ57_REG1_OFFSET 0x1058U +#define FIOPAD_AG59_REG1_OFFSET 0x105CU +#define FIOPAD_AG57_REG1_OFFSET 0x1060U +#define FIOPAD_AE59_REG1_OFFSET 0x1064U +#define FIOPAD_BA55_REG1_OFFSET 0x1074U +#define FIOPAD_BA53_REG1_OFFSET 0x1078U +#define FIOPAD_AR59_REG1_OFFSET 0x107CU +#define FIOPAD_AU59_REG1_OFFSET 0x1080U +#define FIOPAD_A45_REG1_OFFSET 0x10D0U +#define FIOPAD_C45_REG1_OFFSET 0x10D4U +#define FIOPAD_A47_REG1_OFFSET 0x10D8U +#define FIOPAD_A49_REG1_OFFSET 0x10DCU +#define FIOPAD_C49_REG1_OFFSET 0x10E0U +#define FIOPAD_A51_REG1_OFFSET 0x10E4U +#define FIOPAD_A33_REG1_OFFSET 0x10E8U +#define FIOPAD_C33_REG1_OFFSET 0x10ECU +#define FIOPAD_C31_REG1_OFFSET 0x10F0U +#define FIOPAD_A31_REG1_OFFSET 0x10F4U +#define FIOPAD_AJ53_REG1_OFFSET 0x10F8U +#define FIOPAD_AL49_REG1_OFFSET 0x10FCU +#define FIOPAD_AL47_REG1_OFFSET 0x1100U +#define FIOPAD_AN49_REG1_OFFSET 0x1104U +#define FIOPAD_AG51_REG1_OFFSET 0x1108U +#define FIOPAD_AJ51_REG1_OFFSET 0x110CU +#define FIOPAD_AG49_REG1_OFFSET 0x1110U +#define FIOPAD_AE55_REG1_OFFSET 0x1114U +#define FIOPAD_AE53_REG1_OFFSET 0x1118U +#define FIOPAD_AG55_REG1_OFFSET 0x111CU +#define FIOPAD_AJ49_REG1_OFFSET 0x1120U +#define FIOPAD_AC55_REG1_OFFSET 0x1124U +#define FIOPAD_AC53_REG1_OFFSET 0x1128U +#define FIOPAD_AE51_REG1_OFFSET 0x112CU +#define FIOPAD_W51_REG1_OFFSET 0x1130U +#define FIOPAD_W53_REG1_OFFSET 0x1138U +#define FIOPAD_U55_REG1_OFFSET 0x113CU +#define FIOPAD_U53_REG1_OFFSET 0x1140U +#define FIOPAD_AE49_REG1_OFFSET 0x1144U +#define FIOPAD_AC49_REG1_OFFSET 0x1148U +#define FIOPAD_AE47_REG1_OFFSET 0x114CU +#define FIOPAD_AA47_REG1_OFFSET 0x1150U +#define FIOPAD_AA49_REG1_OFFSET 0x1154U +#define FIOPAD_W49_REG1_OFFSET 0x1158U +#define FIOPAD_AA51_REG1_OFFSET 0x115CU +#define FIOPAD_U49_REG1_OFFSET 0x1160U +#define FIOPAD_J59_REG1_OFFSET 0x1168U +#define FIOPAD_L57_REG1_OFFSET 0x116CU +#define FIOPAD_C59_REG1_OFFSET 0x1170U +#define FIOPAD_E59_REG1_OFFSET 0x1174U +#define FIOPAD_J57_REG1_OFFSET 0x1178U +#define FIOPAD_L59_REG1_OFFSET 0x117CU +#define FIOPAD_N59_REG1_OFFSET 0x1180U +#define FIOPAD_E31_REG1_OFFSET 0x118CU +#define FIOPAD_G31_REG1_OFFSET 0x1190U +#define FIOPAD_N41_REG1_OFFSET 0x1194U +#define FIOPAD_N39_REG1_OFFSET 0x1198U +#define FIOPAD_J33_REG1_OFFSET 0x119CU +#define FIOPAD_N33_REG1_OFFSET 0x11A0U +#define FIOPAD_L33_REG1_OFFSET 0x11A4U +#define FIOPAD_N45_REG1_OFFSET 0x11A8U +#define FIOPAD_N43_REG1_OFFSET 0x11ACU +#define FIOPAD_L31_REG1_OFFSET 0x11B0U +#define FIOPAD_J31_REG1_OFFSET 0x11B4U +#define FIOPAD_J29_REG1_OFFSET 0x11B8U +#define FIOPAD_E29_REG1_OFFSET 0x11BCU +#define FIOPAD_G29_REG1_OFFSET 0x11C0U +#define FIOPAD_J37_REG1_OFFSET 0x11CCU +#define FIOPAD_J39_REG1_OFFSET 0x11D0U +#define FIOPAD_G41_REG1_OFFSET 0x11D4U +#define FIOPAD_E43_REG1_OFFSET 0x11D8U +#define FIOPAD_L43_REG1_OFFSET 0x11DCU +#define FIOPAD_C43_REG1_OFFSET 0x11E0U +#define FIOPAD_E41_REG1_OFFSET 0x11E4U +#define FIOPAD_L45_REG1_OFFSET 0x11E8U +#define FIOPAD_J43_REG1_OFFSET 0x11ECU +#define FIOPAD_J41_REG1_OFFSET 0x11F0U +#define FIOPAD_L39_REG1_OFFSET 0x11F4U +#define FIOPAD_E37_REG1_OFFSET 0x11F8U +#define FIOPAD_E35_REG1_OFFSET 0x11FCU +#define FIOPAD_G35_REG1_OFFSET 0x1200U +#define FIOPAD_L55_REG1_OFFSET 0x1220U +#define FIOPAD_J55_REG1_OFFSET 0x1224U +#define FIOPAD_J45_REG1_OFFSET 0x1228U +#define FIOPAD_E47_REG1_OFFSET 0x122CU +#define FIOPAD_G47_REG1_OFFSET 0x1230U +#define FIOPAD_J47_REG1_OFFSET 0x1234U +#define FIOPAD_J49_REG1_OFFSET 0x1238U +#define FIOPAD_N49_REG1_OFFSET 0x123CU +#define FIOPAD_L51_REG1_OFFSET 0x1240U +#define FIOPAD_L49_REG1_OFFSET 0x1244U +#define FIOPAD_N53_REG1_OFFSET 0x1248U +#define FIOPAD_J53_REG1_OFFSET 0x124CU + +#define FIOPAD_REG1_BEG_OFFSET FIOPAD_AJ55_REG1_OFFSET +#define FIOPAD_REG1_END_OFFSET FIOPAD_J53_REG1_OFFSET + + +#define FIOPAD_FUNC0 0x0 +#define FIOPAD_FUNC1 0x1 +#define FIOPAD_FUNC2 0x2 +#define FIOPAD_FUNC3 0x3 +#define FIOPAD_FUNC4 0x4 +#define FIOPAD_FUNC5 0x5 +#define FIOPAD_FUNC6 0x6 +#define FIOPAD_FUNC7 0x7 + +#define PHYTIUM_PINMUX(pin_reg_offset, func_num) (pin_reg_offset) (func_num) + +#endif /* ZEPHYR_INCLUDE_DT_BINDINGS_PINCTRL_TI_K3_PINCTRL_H_ */ diff --git a/makefile b/makefile new file mode 100644 index 00000000000..0aa37f3c41d --- /dev/null +++ b/makefile @@ -0,0 +1,28 @@ + + +boot_smp: + west build -b e2000q_demo_smp samples/arch/smp/pktqueue + cp ./build/zephyr/zephyr.elf /mnt/d/tftboot/ + +boot: + west build -b e2000q_demo samples/hello_world + cp ./build/zephyr/zephyr.elf /mnt/d/tftboot/ + +menuconfig: + west build -t menuconfig + +boot_gdb: + west build -b qemu_cortex_a53_smp samples/arch/smp/pi + +clean: + west build -t clean + +debug_qemu: + west build -t debugserver_qemu + +gdb: + gdb-multiarch -x .gdbinit + + +gdb_qemu: + gdb-multiarch -x .gitlint_qemu \ No newline at end of file diff --git a/modules/Kconfig b/modules/Kconfig index 9d5abd1f4b0..16d15779e72 100644 --- a/modules/Kconfig +++ b/modules/Kconfig @@ -44,6 +44,7 @@ source "modules/zcbor/Kconfig" source "modules/Kconfig.mcuboot" source "modules/Kconfig.intel" source "modules/hostap/Kconfig" +source "modules/Kconfig.phytium" comment "Unavailable modules, please install those via the project manifest." diff --git a/modules/Kconfig.phytium b/modules/Kconfig.phytium new file mode 100644 index 00000000000..ca36693353a --- /dev/null +++ b/modules/Kconfig.phytium @@ -0,0 +1,52 @@ +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +# +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# https://opensource.org/license/apache-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. + +config PHYTIUM_SOFT + bool + +config PHYTIUM_STANDALONE_SDK + bool + depends on PHYTIUM_SOFT + +if PHYTIUM_STANDALONE_SDK + +config USE_SERIAL + bool + prompt "Use serial" + default y + help + Include serial modules and enable serial + +if USE_SERIAL + config ENABLE_Pl011_UART + bool + prompt "Use Pl011 uart" + default y +endif + +config USE_SDHC + bool + prompt "Use SDHC" + default y + +if USE_SDHC + config ENABLE_PHYTIUM_SDHC + bool + prompt "Use phytium sdhc" + default y + +endif + +endif \ No newline at end of file diff --git a/samples/arch/smp/pktqueue/src/main.c b/samples/arch/smp/pktqueue/src/main.c index cfffd813a8b..fd57e1de079 100644 --- a/samples/arch/smp/pktqueue/src/main.c +++ b/samples/arch/smp/pktqueue/src/main.c @@ -25,7 +25,7 @@ #define CRC_BYTE_1 10 #define CRC_BYTE_2 11 -#define STACK_SIZE 2048 +#define STACK_SIZE 4096 static struct k_thread tthread[THREADS_NUM*QUEUE_NUM]; static struct k_thread qthread[QUEUE_NUM]; diff --git a/soc/arm/phytium_d2000/CMakeLists.txt b/soc/arm/phytium_d2000/CMakeLists.txt new file mode 100644 index 00000000000..801a8ef8fc7 --- /dev/null +++ b/soc/arm/phytium_d2000/CMakeLists.txt @@ -0,0 +1,10 @@ +# Copyright (c) 2024 zhangyan +# SPDX-License-Identifier: Apache-2.0 + +zephyr_sources_ifdef(CONFIG_ARM_MMU mmu_regions.c) + +zephyr_sources(soc.c) + +zephyr_include_directories(.) + +set(SOC_LINKER_SCRIPT ${ZEPHYR_BASE}/include/zephyr/arch/arm64/scripts/linker.ld CACHE INTERNAL "") diff --git a/soc/arm/phytium_d2000/Kconfig b/soc/arm/phytium_d2000/Kconfig new file mode 100644 index 00000000000..3a2f1a3d24e --- /dev/null +++ b/soc/arm/phytium_d2000/Kconfig @@ -0,0 +1,10 @@ +# Copyright (c) 2024 zhangyan +# SPDX-License-Identifier: Apache-2.0 + +config SOC_D2000 + select ARM64 + select CPU_PHYTIUM_FTC862 + select CPU_CORTEX_A53 + select ARM_ARCH_TIMER if SYS_CLOCK_EXISTS + select PHYTIUM_STANDALONE_SDK + select PHYTIUM_SOFT diff --git a/soc/arm/phytium_d2000/Kconfig.defconfig b/soc/arm/phytium_d2000/Kconfig.defconfig new file mode 100644 index 00000000000..3e8ed43a346 --- /dev/null +++ b/soc/arm/phytium_d2000/Kconfig.defconfig @@ -0,0 +1,29 @@ +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. + +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at + +# https://opensource.org/license/apache-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. + +if SOC_D2000 + +config SOC + default "phytium_d2000" + +config NUM_IRQS + int + default 159 + +config SYS_CLOCK_HW_CYCLES_PER_SEC + int + default 48000000 + +endif diff --git a/soc/arm/phytium_d2000/Kconfig.soc b/soc/arm/phytium_d2000/Kconfig.soc new file mode 100644 index 00000000000..3ec2d1fe893 --- /dev/null +++ b/soc/arm/phytium_d2000/Kconfig.soc @@ -0,0 +1,24 @@ +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. + +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at + +# https://opensource.org/license/apache-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. + +config SOC_D2000 + bool "d2000" + select SOC_FAMILY_ARM64 + +if SOC_D2000 +config HAL_STANDALONE_SDK_DEBUG + bool "standalone_sdk_debug" + +endif \ No newline at end of file diff --git a/soc/arm/phytium_d2000/mmu_regions.c b/soc/arm/phytium_d2000/mmu_regions.c new file mode 100644 index 00000000000..5f2a0000ad8 --- /dev/null +++ b/soc/arm/phytium_d2000/mmu_regions.c @@ -0,0 +1,38 @@ +// Phytium is pleased to support the open source community by making Zephyr-SDK available. + +// +// Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. + +// Licensed under the Apache-2.0 License (the "License"); you may not use this file except +// in compliance with the License. You may obtain a copy of the License at + +// https://opensource.org/license/apache-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 +#include +#include + +static const struct arm_mmu_region mmu_regions[] = { + MMU_REGION_FLAT_ENTRY("GIC", + DT_REG_ADDR_BY_IDX(DT_INST(0, arm_gic), 0), + DT_REG_SIZE_BY_IDX(DT_INST(0, arm_gic), 0), + MT_DEVICE_nGnRnE | MT_P_RW_U_NA | MT_DEFAULT_SECURE_STATE), + + MMU_REGION_FLAT_ENTRY("GIC", + DT_REG_ADDR_BY_IDX(DT_INST(0, arm_gic), 1), + DT_REG_SIZE_BY_IDX(DT_INST(0, arm_gic), 1), + MT_DEVICE_nGnRnE | MT_P_RW_U_NA | MT_DEFAULT_SECURE_STATE), +}; + +const struct arm_mmu_config mmu_config = { + .num_regions = ARRAY_SIZE(mmu_regions), + .mmu_regions = mmu_regions, +}; + + + diff --git a/soc/arm/phytium_d2000/soc.c b/soc/arm/phytium_d2000/soc.c new file mode 100644 index 00000000000..d879c4fb8d1 --- /dev/null +++ b/soc/arm/phytium_d2000/soc.c @@ -0,0 +1,23 @@ +// Phytium is pleased to support the open source community by making Zephyr-SDK available. + +// +// Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. + +// Licensed under the Apache-2.0 License (the "License"); you may not use this file except +// in compliance with the License. You may obtain a copy of the License at + +// https://opensource.org/license/apache-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 + +/* Boot-time static default printk handler, possibly to be overridden later. */ +int arch_printk_char_out(int c) +{ + putchar(c) ; + return 0; +} \ No newline at end of file diff --git a/soc/arm/phytium_d3000/CMakeLists.txt b/soc/arm/phytium_d3000/CMakeLists.txt new file mode 100644 index 00000000000..801a8ef8fc7 --- /dev/null +++ b/soc/arm/phytium_d3000/CMakeLists.txt @@ -0,0 +1,10 @@ +# Copyright (c) 2024 zhangyan +# SPDX-License-Identifier: Apache-2.0 + +zephyr_sources_ifdef(CONFIG_ARM_MMU mmu_regions.c) + +zephyr_sources(soc.c) + +zephyr_include_directories(.) + +set(SOC_LINKER_SCRIPT ${ZEPHYR_BASE}/include/zephyr/arch/arm64/scripts/linker.ld CACHE INTERNAL "") diff --git a/soc/arm/phytium_d3000/Kconfig b/soc/arm/phytium_d3000/Kconfig new file mode 100644 index 00000000000..3d19d834304 --- /dev/null +++ b/soc/arm/phytium_d3000/Kconfig @@ -0,0 +1,10 @@ +# Copyright (c) 2024 zhangyan +# SPDX-License-Identifier: Apache-2.0 + +config SOC_D3000 + select ARM64 + select CPU_PHYTIUM_FTC862 + select CPU_CORTEX_A53 + select ARM_ARCH_TIMER if SYS_CLOCK_EXISTS + select PHYTIUM_STANDALONE_SDK + select PHYTIUM_SOFT diff --git a/soc/arm/phytium_d3000/Kconfig.defconfig b/soc/arm/phytium_d3000/Kconfig.defconfig new file mode 100644 index 00000000000..8a7af8bc4da --- /dev/null +++ b/soc/arm/phytium_d3000/Kconfig.defconfig @@ -0,0 +1,29 @@ +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. + +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at + +# https://opensource.org/license/apache-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. + +if SOC_D3000 + +config SOC + default "phytium_d3000" + +config NUM_IRQS + int + default 266 + +config SYS_CLOCK_HW_CYCLES_PER_SEC + int + default 50000000 + +endif diff --git a/soc/arm/phytium_d3000/Kconfig.soc b/soc/arm/phytium_d3000/Kconfig.soc new file mode 100644 index 00000000000..e36fe4a4d46 --- /dev/null +++ b/soc/arm/phytium_d3000/Kconfig.soc @@ -0,0 +1,27 @@ +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. + +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at + +# https://opensource.org/license/apache-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. + +config SOC_D3000 + bool "phytium_d3000" + select SOC_FAMILY_ARM64 + +config SOC + default "soc_d3000" if SOC_D3000 + +if SOC_D3000 +config HAL_STANDALONE_SDK_DEBUG + bool "standalone_sdk_debug" + +endif diff --git a/soc/arm/phytium_d3000/mmu_regions.c b/soc/arm/phytium_d3000/mmu_regions.c new file mode 100644 index 00000000000..6c51737df3f --- /dev/null +++ b/soc/arm/phytium_d3000/mmu_regions.c @@ -0,0 +1,52 @@ +/* + * Copyright : (C) 2024 Phytium Information Technology, Inc. + * All Rights Reserved. + * + * This program is OPEN SOURCE software: you can redistribute it and/or modify it + * under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd, + * either version 1.0 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the Phytium Public License for more details. + * + * + * FilePath: mmu_regions.c + * Created Date: 2024-10-11 14:03:59 + * Last Modified: 2024-10-15 13:43:05 + * Description: This file is for + * + * Modify History: + * Ver Who Date Changes + * ----- ---------- -------- --------------------------------- + */ + +#include +#include +#include + +static const struct arm_mmu_region mmu_regions[] = { + MMU_REGION_FLAT_ENTRY("GIC", + DT_REG_ADDR_BY_IDX(DT_INST(0, arm_gic), 0), + DT_REG_SIZE_BY_IDX(DT_INST(0, arm_gic), 0), + MT_DEVICE_nGnRnE | MT_P_RW_U_NA | MT_DEFAULT_SECURE_STATE), + + MMU_REGION_FLAT_ENTRY("GIC", + DT_REG_ADDR_BY_IDX(DT_INST(0, arm_gic), 1), + DT_REG_SIZE_BY_IDX(DT_INST(0, arm_gic), 1), + MT_DEVICE_nGnRnE | MT_P_RW_U_NA | MT_DEFAULT_SECURE_STATE), + + MMU_REGION_FLAT_ENTRY("UART1", + DT_REG_ADDR(DT_INST(0, arm_pl011)), + DT_REG_SIZE(DT_INST(0, arm_pl011)), + MT_DEVICE_nGnRnE | MT_P_RW_U_NA | MT_DEFAULT_SECURE_STATE), + +}; + +const struct arm_mmu_config mmu_config = { + .num_regions = ARRAY_SIZE(mmu_regions), + .mmu_regions = mmu_regions, +}; + + + diff --git a/soc/arm/phytium_d3000/soc.c b/soc/arm/phytium_d3000/soc.c new file mode 100644 index 00000000000..d879c4fb8d1 --- /dev/null +++ b/soc/arm/phytium_d3000/soc.c @@ -0,0 +1,23 @@ +// Phytium is pleased to support the open source community by making Zephyr-SDK available. + +// +// Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. + +// Licensed under the Apache-2.0 License (the "License"); you may not use this file except +// in compliance with the License. You may obtain a copy of the License at + +// https://opensource.org/license/apache-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 + +/* Boot-time static default printk handler, possibly to be overridden later. */ +int arch_printk_char_out(int c) +{ + putchar(c) ; + return 0; +} \ No newline at end of file diff --git a/soc/arm/phytium_e2000q/CMakeLists.txt b/soc/arm/phytium_e2000q/CMakeLists.txt new file mode 100644 index 00000000000..801a8ef8fc7 --- /dev/null +++ b/soc/arm/phytium_e2000q/CMakeLists.txt @@ -0,0 +1,10 @@ +# Copyright (c) 2024 zhangyan +# SPDX-License-Identifier: Apache-2.0 + +zephyr_sources_ifdef(CONFIG_ARM_MMU mmu_regions.c) + +zephyr_sources(soc.c) + +zephyr_include_directories(.) + +set(SOC_LINKER_SCRIPT ${ZEPHYR_BASE}/include/zephyr/arch/arm64/scripts/linker.ld CACHE INTERNAL "") diff --git a/soc/arm/phytium_e2000q/Kconfig b/soc/arm/phytium_e2000q/Kconfig new file mode 100644 index 00000000000..50ef9a1cb39 --- /dev/null +++ b/soc/arm/phytium_e2000q/Kconfig @@ -0,0 +1,9 @@ +# Copyright (c) 2024 zhangyan +# SPDX-License-Identifier: Apache-2.0 + +config SOC_E2000Q + select ARM64 + select CPU_PHYTIUM_FTC310 + select ARM_ARCH_TIMER if SYS_CLOCK_EXISTS + select PHYTIUM_STANDALONE_SDK + select PHYTIUM_SOFT \ No newline at end of file diff --git a/soc/arm/phytium_e2000q/Kconfig.defconfig b/soc/arm/phytium_e2000q/Kconfig.defconfig new file mode 100644 index 00000000000..af35d0a3431 --- /dev/null +++ b/soc/arm/phytium_e2000q/Kconfig.defconfig @@ -0,0 +1,29 @@ +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. + +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at + +# https://opensource.org/license/apache-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. + +if SOC_E2000Q + +config SOC + default "phytium_e2000q" + +config NUM_IRQS + int + default 266 + +config SYS_CLOCK_HW_CYCLES_PER_SEC + int + default 50000000 + +endif diff --git a/soc/arm/phytium_e2000q/Kconfig.soc b/soc/arm/phytium_e2000q/Kconfig.soc new file mode 100644 index 00000000000..a884c694e5b --- /dev/null +++ b/soc/arm/phytium_e2000q/Kconfig.soc @@ -0,0 +1,24 @@ +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. + +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at + +# https://opensource.org/license/apache-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. + +config SOC_E2000Q + bool "e2000q" + select SOC_FAMILY_ARM64 + +if SOC_E2000Q +config HAL_STANDALONE_SDK_DEBUG + bool "standalone_sdk_debug" + +endif \ No newline at end of file diff --git a/soc/arm/phytium_e2000q/mmu_regions.c b/soc/arm/phytium_e2000q/mmu_regions.c new file mode 100644 index 00000000000..5f2a0000ad8 --- /dev/null +++ b/soc/arm/phytium_e2000q/mmu_regions.c @@ -0,0 +1,38 @@ +// Phytium is pleased to support the open source community by making Zephyr-SDK available. + +// +// Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. + +// Licensed under the Apache-2.0 License (the "License"); you may not use this file except +// in compliance with the License. You may obtain a copy of the License at + +// https://opensource.org/license/apache-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 +#include +#include + +static const struct arm_mmu_region mmu_regions[] = { + MMU_REGION_FLAT_ENTRY("GIC", + DT_REG_ADDR_BY_IDX(DT_INST(0, arm_gic), 0), + DT_REG_SIZE_BY_IDX(DT_INST(0, arm_gic), 0), + MT_DEVICE_nGnRnE | MT_P_RW_U_NA | MT_DEFAULT_SECURE_STATE), + + MMU_REGION_FLAT_ENTRY("GIC", + DT_REG_ADDR_BY_IDX(DT_INST(0, arm_gic), 1), + DT_REG_SIZE_BY_IDX(DT_INST(0, arm_gic), 1), + MT_DEVICE_nGnRnE | MT_P_RW_U_NA | MT_DEFAULT_SECURE_STATE), +}; + +const struct arm_mmu_config mmu_config = { + .num_regions = ARRAY_SIZE(mmu_regions), + .mmu_regions = mmu_regions, +}; + + + diff --git a/soc/arm/phytium_e2000q/pinctrl_soc.h b/soc/arm/phytium_e2000q/pinctrl_soc.h new file mode 100644 index 00000000000..50a66ff0a0a --- /dev/null +++ b/soc/arm/phytium_e2000q/pinctrl_soc.h @@ -0,0 +1,51 @@ +// Phytium is pleased to support the open source community by making Zephyr-SDK available. + +// +// Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +// +// Licensed under the Apache-2.0 License (the "License"); you may not use this file except +// in compliance with the License. You may obtain a copy of the License at +// +// https://opensource.org/license/apache-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 ZEPHYR_SOC_ARM64_PHYTIUM_E2000_PINCTRL_SOC_H_ +#define ZEPHYR_SOC_ARM64_PHYTIUM_E2000_PINCTRL_SOC_H_ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct pinctrl_soc_pin { + + uint32_t pin_reg_offset; + uint32_t func_num; +}; + +typedef struct pinctrl_soc_pin pinctrl_soc_pin_t; + +#define PHYTIUM_E2000_DT_PIN(node_id) \ + { \ + .pin_reg_offset = DT_PROP_BY_IDX(node_id, pinmux, 0), \ + .func_num = DT_PROP_BY_IDX(node_id, pinmux, 1) \ + }, + +#define Z_PINCTRL_STATE_PIN_INIT(node_id, prop, idx) \ + PHYTIUM_E2000_DT_PIN(DT_PROP_BY_IDX(node_id, prop, idx)) + +#define Z_PINCTRL_STATE_PINS_INIT(node_id, prop) \ + { DT_FOREACH_PROP_ELEM(node_id, prop, Z_PINCTRL_STATE_PIN_INIT) } + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/soc/arm/phytium_e2000q/soc.c b/soc/arm/phytium_e2000q/soc.c new file mode 100644 index 00000000000..d879c4fb8d1 --- /dev/null +++ b/soc/arm/phytium_e2000q/soc.c @@ -0,0 +1,23 @@ +// Phytium is pleased to support the open source community by making Zephyr-SDK available. + +// +// Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. + +// Licensed under the Apache-2.0 License (the "License"); you may not use this file except +// in compliance with the License. You may obtain a copy of the License at + +// https://opensource.org/license/apache-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 + +/* Boot-time static default printk handler, possibly to be overridden later. */ +int arch_printk_char_out(int c) +{ + putchar(c) ; + return 0; +} \ No newline at end of file diff --git a/soc/arm/soc.yml b/soc/arm/soc.yml index c0b2456501e..05549143502 100644 --- a/soc/arm/soc.yml +++ b/soc/arm/soc.yml @@ -1,33 +1,37 @@ -family: -- name: arm - series: - - name: mps2 - socs: - - name: an385 - - name: an521 - cpuclusters: - - name: cpu0 - - name: cpu1 - - name: mps3 - socs: - - name: an547 - - name: musca - socs: - - name: musca_b1 - - name: musca_s1 - - name: designstart - socs: - - name: designstart_fpga_cortex_m1 - - name: designstart_fpga_cortex_m3 -- name: arm64 - series: - - name: fvp_aemv8a - socs: - - name: fvp_base_revc_2xaemv8a - - name: fvp_aemv8r - socs: - - name: fvp_aemv8r_aarch64 - - name: fvp_aemv8r_aarch32 - socs: - - name: qemu_cortex_a53 - - name: qemu_virt_arm64 +family: +- name: arm + series: + - name: mps2 + socs: + - name: an385 + - name: an521 + cpuclusters: + - name: cpu0 + - name: cpu1 + - name: mps3 + socs: + - name: an547 + - name: musca + socs: + - name: musca_b1 + - name: musca_s1 + - name: designstart + socs: + - name: designstart_fpga_cortex_m1 + - name: designstart_fpga_cortex_m3 + +- name: arm64 + series: + - name: fvp_aemv8a + socs: + - name: fvp_base_revc_2xaemv8a + - name: fvp_aemv8r + socs: + - name: fvp_aemv8r_aarch64 + - name: fvp_aemv8r_aarch32 + socs: + - name: qemu_cortex_a53 + - name: qemu_virt_arm64 + - name: phytium_d3000 + - name: phytium_d2000 + - name: phytium_e2000q diff --git a/subsys/sd/sd.c b/subsys/sd/sd.c index f075203601d..53d87d46939 100644 --- a/subsys/sd/sd.c +++ b/subsys/sd/sd.c @@ -209,6 +209,7 @@ static int sd_command_init(struct sd_card *card) } #endif /* CONFIG_SDIO_STACK */ #ifdef CONFIG_SDMMC_STACK + LOG_DBG("sdmmc_card_init is start"); /* Attempt to initialize SDMMC card */ if (!sdmmc_card_init(card)) { return 0; @@ -261,7 +262,7 @@ int sd_init(const struct device *sdhc_dev, struct sd_card *card) k_mutex_unlock(&card->lock); return ret; } - + LOG_DBG("start sd_command_init"); /* * SD protocol is stateful, so we must account for the possibility * that the card is in a bad state. The return code SD_RESTART diff --git a/west.yml b/west.yml index b9a45385d60..3fc08ce6a22 100644 --- a/west.yml +++ b/west.yml @@ -23,6 +23,8 @@ manifest: url-base: https://github.com/zephyrproject-rtos - name: babblesim url-base: https://github.com/BabbleSim + - name: phytium + url-base: https://gitee.com/phytium_embedded group-filter: [-babblesim, -optional] @@ -342,6 +344,12 @@ manifest: - name: zcbor revision: 75d088037eb237b18e7ec1f47c9ce494b9b95aab path: modules/lib/zcbor + - name: phytium-standalone-sdk + remote: phytium + revision: c38dcff60bf78f1612429c3d80c3e1bc962dd462 + path: modules/hal/phytium/hal/phytium-standalone-sdk + groups: + - hal self: path: zephyr -- Gitee From 105a594d291570ce746b6785059feed4c5c9e4cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E8=A1=8D?= Date: Wed, 27 Nov 2024 11:36:30 +0000 Subject: [PATCH 02/13] e2000d,s5000c add --- boards/phytium/e2000d_demo/CMakeLists.txt | 1 + boards/phytium/e2000d_demo/Kconfig.defconfig | 28 +++ .../phytium/e2000d_demo/Kconfig.e2000d_demo | 18 ++ boards/phytium/e2000d_demo/board.cmake | 1 + boards/phytium/e2000d_demo/board.yml | 5 + boards/phytium/e2000d_demo/e2000d_demo.dts | 44 ++++ boards/phytium/e2000d_demo/e2000d_demo.yaml | 7 + .../phytium/e2000d_demo/e2000d_demo_defconfig | 33 +++ .../phytium/e2000d_demo_smp/Kconfig.defconfig | 19 ++ .../e2000d_demo_smp/Kconfig.e2000d_demo_smp | 18 ++ boards/phytium/e2000d_demo_smp/board.cmake | 1 + boards/phytium/e2000d_demo_smp/board.yml | 5 + .../e2000d_demo_smp/e2000d_demo_smp.dts | 49 ++++ .../e2000d_demo_smp/e2000d_demo_smp.yaml | 9 + .../e2000d_demo_smp/e2000d_demo_smp_defconfig | 41 +++ boards/phytium/s5000c_testb/Kconfig.defconfig | 30 +++ .../phytium/s5000c_testb/Kconfig.s5000c_testb | 18 ++ boards/phytium/s5000c_testb/board.cmake | 1 + boards/phytium/s5000c_testb/board.yml | 5 + boards/phytium/s5000c_testb/s5000c_testb.dts | 50 ++++ boards/phytium/s5000c_testb/s5000c_testb.yaml | 10 + .../s5000c_testb/s5000c_testb_defconfig | 33 +++ .../s5000c_testb_smp/Kconfig.defconfig | 30 +++ .../s5000c_testb_smp/Kconfig.s5000c_testb_smp | 18 ++ boards/phytium/s5000c_testb_smp/board.cmake | 1 + boards/phytium/s5000c_testb_smp/board.yml | 5 + .../s5000c_testb_smp/s5000c_testb_smp.dts | 50 ++++ .../s5000c_testb_smp/s5000c_testb_smp.yaml | 10 + .../s5000c_testb_smp_defconfig | 41 +++ dts/arm64/phytium/s5000c.dtsi | 233 ++++++++++++++++++ soc/arm/phytium_e2000d/CMakeLists.txt | 10 + soc/arm/phytium_e2000d/Kconfig | 9 + soc/arm/phytium_e2000d/Kconfig.defconfig | 29 +++ soc/arm/phytium_e2000d/Kconfig.soc | 24 ++ soc/arm/phytium_e2000d/mmu_regions.c | 38 +++ soc/arm/phytium_e2000d/soc.c | 23 ++ soc/arm/phytium_s5000c/CMakeLists.txt | 10 + soc/arm/phytium_s5000c/Kconfig | 10 + soc/arm/phytium_s5000c/Kconfig.defconfig | 29 +++ soc/arm/phytium_s5000c/Kconfig.soc | 27 ++ soc/arm/phytium_s5000c/mmu_regions.c | 52 ++++ soc/arm/phytium_s5000c/soc.c | 23 ++ soc/arm/soc.yml | 2 + 43 files changed, 1100 insertions(+) create mode 100644 boards/phytium/e2000d_demo/CMakeLists.txt create mode 100644 boards/phytium/e2000d_demo/Kconfig.defconfig create mode 100644 boards/phytium/e2000d_demo/Kconfig.e2000d_demo create mode 100644 boards/phytium/e2000d_demo/board.cmake create mode 100644 boards/phytium/e2000d_demo/board.yml create mode 100644 boards/phytium/e2000d_demo/e2000d_demo.dts create mode 100644 boards/phytium/e2000d_demo/e2000d_demo.yaml create mode 100644 boards/phytium/e2000d_demo/e2000d_demo_defconfig create mode 100644 boards/phytium/e2000d_demo_smp/Kconfig.defconfig create mode 100644 boards/phytium/e2000d_demo_smp/Kconfig.e2000d_demo_smp create mode 100644 boards/phytium/e2000d_demo_smp/board.cmake create mode 100644 boards/phytium/e2000d_demo_smp/board.yml create mode 100644 boards/phytium/e2000d_demo_smp/e2000d_demo_smp.dts create mode 100644 boards/phytium/e2000d_demo_smp/e2000d_demo_smp.yaml create mode 100644 boards/phytium/e2000d_demo_smp/e2000d_demo_smp_defconfig create mode 100644 boards/phytium/s5000c_testb/Kconfig.defconfig create mode 100644 boards/phytium/s5000c_testb/Kconfig.s5000c_testb create mode 100644 boards/phytium/s5000c_testb/board.cmake create mode 100644 boards/phytium/s5000c_testb/board.yml create mode 100644 boards/phytium/s5000c_testb/s5000c_testb.dts create mode 100644 boards/phytium/s5000c_testb/s5000c_testb.yaml create mode 100644 boards/phytium/s5000c_testb/s5000c_testb_defconfig create mode 100644 boards/phytium/s5000c_testb_smp/Kconfig.defconfig create mode 100644 boards/phytium/s5000c_testb_smp/Kconfig.s5000c_testb_smp create mode 100644 boards/phytium/s5000c_testb_smp/board.cmake create mode 100644 boards/phytium/s5000c_testb_smp/board.yml create mode 100644 boards/phytium/s5000c_testb_smp/s5000c_testb_smp.dts create mode 100644 boards/phytium/s5000c_testb_smp/s5000c_testb_smp.yaml create mode 100644 boards/phytium/s5000c_testb_smp/s5000c_testb_smp_defconfig create mode 100644 dts/arm64/phytium/s5000c.dtsi create mode 100644 soc/arm/phytium_e2000d/CMakeLists.txt create mode 100644 soc/arm/phytium_e2000d/Kconfig create mode 100644 soc/arm/phytium_e2000d/Kconfig.defconfig create mode 100644 soc/arm/phytium_e2000d/Kconfig.soc create mode 100644 soc/arm/phytium_e2000d/mmu_regions.c create mode 100644 soc/arm/phytium_e2000d/soc.c create mode 100644 soc/arm/phytium_s5000c/CMakeLists.txt create mode 100644 soc/arm/phytium_s5000c/Kconfig create mode 100644 soc/arm/phytium_s5000c/Kconfig.defconfig create mode 100644 soc/arm/phytium_s5000c/Kconfig.soc create mode 100644 soc/arm/phytium_s5000c/mmu_regions.c create mode 100644 soc/arm/phytium_s5000c/soc.c diff --git a/boards/phytium/e2000d_demo/CMakeLists.txt b/boards/phytium/e2000d_demo/CMakeLists.txt new file mode 100644 index 00000000000..9881313609a --- /dev/null +++ b/boards/phytium/e2000d_demo/CMakeLists.txt @@ -0,0 +1 @@ +# SPDX-License-Identifier: Apache-2.0 diff --git a/boards/phytium/e2000d_demo/Kconfig.defconfig b/boards/phytium/e2000d_demo/Kconfig.defconfig new file mode 100644 index 00000000000..ec8be524969 --- /dev/null +++ b/boards/phytium/e2000d_demo/Kconfig.defconfig @@ -0,0 +1,28 @@ +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +# +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# https://opensource.org/license/apache-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. + + +config BOARD + default "Phytium e2000d demo" + depends on BOARD_E2000D_DEMO + +if NETWORKING + +config NET_L2_ETHERNET + default y + + + +endif # NETWORKING diff --git a/boards/phytium/e2000d_demo/Kconfig.e2000d_demo b/boards/phytium/e2000d_demo/Kconfig.e2000d_demo new file mode 100644 index 00000000000..9050daa42cd --- /dev/null +++ b/boards/phytium/e2000d_demo/Kconfig.e2000d_demo @@ -0,0 +1,18 @@ +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +# +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# https://opensource.org/license/apache-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. + +config BOARD_E2000D_DEMO + bool "phytium e2000d" + select SOC_E2000D diff --git a/boards/phytium/e2000d_demo/board.cmake b/boards/phytium/e2000d_demo/board.cmake new file mode 100644 index 00000000000..9881313609a --- /dev/null +++ b/boards/phytium/e2000d_demo/board.cmake @@ -0,0 +1 @@ +# SPDX-License-Identifier: Apache-2.0 diff --git a/boards/phytium/e2000d_demo/board.yml b/boards/phytium/e2000d_demo/board.yml new file mode 100644 index 00000000000..70e7234f0a0 --- /dev/null +++ b/boards/phytium/e2000d_demo/board.yml @@ -0,0 +1,5 @@ +board: + name: e2000d_demo + vendor: arm64 + socs: + - name: phytium_e2000d \ No newline at end of file diff --git a/boards/phytium/e2000d_demo/e2000d_demo.dts b/boards/phytium/e2000d_demo/e2000d_demo.dts new file mode 100644 index 00000000000..9ea6c9be8b0 --- /dev/null +++ b/boards/phytium/e2000d_demo/e2000d_demo.dts @@ -0,0 +1,44 @@ +/* + * Copyright 2024 zhangyan + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; +#include + +/ { + model = "Phytium e2000d demo"; + compatible = "phytium,e2000d-demo", "phytium,e2000d"; + #address-cells = <2>; + #size-cells = <2>; + +chosen { + zephyr,console = &uart1; + zephyr,shell-uart = &uart1; + zephyr,sram = &sram0; + }; +}; + +&sdhc1 { + status = "okay"; + sdmmc { + compatible = "zephyr,sdmmc-disk"; + status = "okay"; + }; +}; + +&xmac0 { + status = "okay"; + local-mac-address = [00 00 00 01 02 03]; +}; + +&uart1 { + current-speed = <115200>; + status = "okay"; +}; + +&uart2 { + current-speed = <115200>; + status = "okay"; +}; \ No newline at end of file diff --git a/boards/phytium/e2000d_demo/e2000d_demo.yaml b/boards/phytium/e2000d_demo/e2000d_demo.yaml new file mode 100644 index 00000000000..636d8bc87cf --- /dev/null +++ b/boards/phytium/e2000d_demo/e2000d_demo.yaml @@ -0,0 +1,7 @@ +identifier: e2000d_demo +name: Phytium e2000d demo +type: mcu +arch: arm64 +toolchain: + - zephyr + - cross-compile diff --git a/boards/phytium/e2000d_demo/e2000d_demo_defconfig b/boards/phytium/e2000d_demo/e2000d_demo_defconfig new file mode 100644 index 00000000000..e6578193dfa --- /dev/null +++ b/boards/phytium/e2000d_demo/e2000d_demo_defconfig @@ -0,0 +1,33 @@ +# SPDX-License-Identifier: Apache-2.0 + +# Platform Configuration +CONFIG_ARM64_VA_BITS_42=y +CONFIG_ARM64_PA_BITS_42=y +# Main stack size +CONFIG_MAIN_STACK_SIZE=4096 + +CONFIG_ARMV8_A_NS=y + +# Zephyr Kernel Configuration +CONFIG_XIP=n +CONFIG_FLASH_SIZE=0 +CONFIG_FLASH_BASE_ADDRESS=0x0 + +# Serial Drivers +CONFIG_SERIAL=y + +# Enable Console +CONFIG_CONSOLE=y +CONFIG_UART_CONSOLE=y + + +# Timer Drivers +CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME=y + + +#cache +CONFIG_CACHE_MANAGEMENT=y + +# PSCI is supported with NS +CONFIG_PM_CPU_OPS=y +CONFIG_PM_CPU_OPS_PSCI=y diff --git a/boards/phytium/e2000d_demo_smp/Kconfig.defconfig b/boards/phytium/e2000d_demo_smp/Kconfig.defconfig new file mode 100644 index 00000000000..cb4e5d602ed --- /dev/null +++ b/boards/phytium/e2000d_demo_smp/Kconfig.defconfig @@ -0,0 +1,19 @@ +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +# +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# https://opensource.org/license/apache-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. + + +config BOARD + default "Phytium e2000d demo" + depends on BOARD_E2000D_DEMO_SMP diff --git a/boards/phytium/e2000d_demo_smp/Kconfig.e2000d_demo_smp b/boards/phytium/e2000d_demo_smp/Kconfig.e2000d_demo_smp new file mode 100644 index 00000000000..cf9a2620c37 --- /dev/null +++ b/boards/phytium/e2000d_demo_smp/Kconfig.e2000d_demo_smp @@ -0,0 +1,18 @@ +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +# +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# https://opensource.org/license/apache-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. + +config BOARD_E2000D_DEMO_SMP + bool "phytium e2000d" + select SOC_E2000D diff --git a/boards/phytium/e2000d_demo_smp/board.cmake b/boards/phytium/e2000d_demo_smp/board.cmake new file mode 100644 index 00000000000..9881313609a --- /dev/null +++ b/boards/phytium/e2000d_demo_smp/board.cmake @@ -0,0 +1 @@ +# SPDX-License-Identifier: Apache-2.0 diff --git a/boards/phytium/e2000d_demo_smp/board.yml b/boards/phytium/e2000d_demo_smp/board.yml new file mode 100644 index 00000000000..b29aeb83054 --- /dev/null +++ b/boards/phytium/e2000d_demo_smp/board.yml @@ -0,0 +1,5 @@ +board: + name: e2000d_demo_smp + vendor: arm64 + socs: + - name: phytium_e2000d \ No newline at end of file diff --git a/boards/phytium/e2000d_demo_smp/e2000d_demo_smp.dts b/boards/phytium/e2000d_demo_smp/e2000d_demo_smp.dts new file mode 100644 index 00000000000..cb2792a2427 --- /dev/null +++ b/boards/phytium/e2000d_demo_smp/e2000d_demo_smp.dts @@ -0,0 +1,49 @@ +/* + * Copyright 2024 zhangyan + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; + +#include +/ { + model = "Phytium e2000d demo"; + compatible = "phytium,e2000d-demo", "phytium,e2000d"; + #address-cells = <2>; + #size-cells = <2>; + + psci { + compatible = "arm,psci-0.2"; + method = "smc"; + }; + +chosen { + zephyr,console = &uart1; + zephyr,shell-uart = &uart1; + zephyr,sram = &sram0; + }; +}; + +&sdhc1 { + status = "okay"; + sdmmc { + compatible = "zephyr,sdmmc-disk"; + status = "okay"; + }; +}; + +&uart1 { + status = "okay"; + current-speed = <115200>; +}; + +&uart2 { + status = "okay"; + current-speed = <115200>; +}; + +&xmac0 { + status = "okay"; + local-mac-address = [00 00 00 01 02 03]; +}; diff --git a/boards/phytium/e2000d_demo_smp/e2000d_demo_smp.yaml b/boards/phytium/e2000d_demo_smp/e2000d_demo_smp.yaml new file mode 100644 index 00000000000..5f42073f919 --- /dev/null +++ b/boards/phytium/e2000d_demo_smp/e2000d_demo_smp.yaml @@ -0,0 +1,9 @@ +identifier: e2000d_demo +name: Phytium e2000d demo +type: mcu +arch: arm64 +toolchain: + - zephyr + - cross-compile +supported: + - smp \ No newline at end of file diff --git a/boards/phytium/e2000d_demo_smp/e2000d_demo_smp_defconfig b/boards/phytium/e2000d_demo_smp/e2000d_demo_smp_defconfig new file mode 100644 index 00000000000..513ffeac72f --- /dev/null +++ b/boards/phytium/e2000d_demo_smp/e2000d_demo_smp_defconfig @@ -0,0 +1,41 @@ +# SPDX-License-Identifier: Apache-2.0 + +# Platform Configuration +CONFIG_ARM64_VA_BITS_42=y +CONFIG_ARM64_PA_BITS_42=y +# Main stack size +CONFIG_MAIN_STACK_SIZE=4096 + +CONFIG_ARMV8_A_NS=y + +# Zephyr Kernel Configuration +CONFIG_XIP=n +CONFIG_FLASH_SIZE=0 +CONFIG_FLASH_BASE_ADDRESS=0x0 + +# Serial Drivers +CONFIG_SERIAL=y + +# Enable Console +CONFIG_CONSOLE=y +CONFIG_UART_CONSOLE=y + +#cache +CONFIG_CACHE_MANAGEMENT=y + +# Timer Drivers +CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME=y + +# PSCI is supported with NS +CONFIG_PM_CPU_OPS=y +CONFIG_PM_CPU_OPS_PSCI=y + +# SMP-related +CONFIG_SMP=y +CONFIG_MP_MAX_NUM_CPUS=2 +CONFIG_TIMEOUT_64BIT=y + +# CONFIG_SHELL=y +# CONFIG_SHELL_BACKEND_SERIAL_INTERRUPT_DRIVEN=n +# CONFIG_SHELL_BACKEND_SERIAL_RX_POLL_PERIOD=1 +# CONFIG_BOOT_BANNER=n diff --git a/boards/phytium/s5000c_testb/Kconfig.defconfig b/boards/phytium/s5000c_testb/Kconfig.defconfig new file mode 100644 index 00000000000..754f09e2b9f --- /dev/null +++ b/boards/phytium/s5000c_testb/Kconfig.defconfig @@ -0,0 +1,30 @@ +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +# +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# https://opensource.org/license/apache-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. + + +config BOARD + default "Phytium S5000C testb" + depends on BOARD_S5000C_TESTB + + + +if NETWORKING + +config NET_L2_ETHERNET + default y + + + +endif # NETWORKING diff --git a/boards/phytium/s5000c_testb/Kconfig.s5000c_testb b/boards/phytium/s5000c_testb/Kconfig.s5000c_testb new file mode 100644 index 00000000000..9686b07d2b7 --- /dev/null +++ b/boards/phytium/s5000c_testb/Kconfig.s5000c_testb @@ -0,0 +1,18 @@ +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +# +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# https://opensource.org/license/apache-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. + +config BOARD_S5000C_TESTB + bool "phytium S5000C" + select SOC_S5000C diff --git a/boards/phytium/s5000c_testb/board.cmake b/boards/phytium/s5000c_testb/board.cmake new file mode 100644 index 00000000000..9881313609a --- /dev/null +++ b/boards/phytium/s5000c_testb/board.cmake @@ -0,0 +1 @@ +# SPDX-License-Identifier: Apache-2.0 diff --git a/boards/phytium/s5000c_testb/board.yml b/boards/phytium/s5000c_testb/board.yml new file mode 100644 index 00000000000..7247dae857a --- /dev/null +++ b/boards/phytium/s5000c_testb/board.yml @@ -0,0 +1,5 @@ +board: + name: s5000c_testb + vendor: arm64 + socs: + - name: phytium_s5000c \ No newline at end of file diff --git a/boards/phytium/s5000c_testb/s5000c_testb.dts b/boards/phytium/s5000c_testb/s5000c_testb.dts new file mode 100644 index 00000000000..9d7ceda7549 --- /dev/null +++ b/boards/phytium/s5000c_testb/s5000c_testb.dts @@ -0,0 +1,50 @@ +/* + * Copyright 2023 honglin leng + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; + +#include +/ { + model = "Phytium s5000c testb"; + compatible = "phytium,s5000c-testb", "phytium,s5000c"; + #address-cells = <2>; + #size-cells = <2>; + + psci { + compatible = "arm,psci-0.2"; + method = "smc"; + label = "PSCI"; + }; + +chosen { + zephyr,console = &uart1; + zephyr,shell-uart = &uart1; + zephyr,sram = &sram0; + }; +}; + +// &sdhc1 { +// status = "okay"; +// sdmmc { +// compatible = "zephyr,sdmmc-disk"; +// status = "okay"; +// }; +// }; + +&uart1 { + status = "okay"; + current-speed = <115200>; +}; + +// &uart2 { +// status = "okay"; +// current-speed = <115200>; +// }; + +// &xmac0 { +// status = "okay"; +// local-mac-address = [00 00 00 01 02 03]; +// }; diff --git a/boards/phytium/s5000c_testb/s5000c_testb.yaml b/boards/phytium/s5000c_testb/s5000c_testb.yaml new file mode 100644 index 00000000000..13359566554 --- /dev/null +++ b/boards/phytium/s5000c_testb/s5000c_testb.yaml @@ -0,0 +1,10 @@ + +identifier: s5000c_testb +name: Phytium s5000c testb +type: mcu +arch: arm64 +toolchain: + - zephyr + - cross-compile +supported: + - smp diff --git a/boards/phytium/s5000c_testb/s5000c_testb_defconfig b/boards/phytium/s5000c_testb/s5000c_testb_defconfig new file mode 100644 index 00000000000..f816f41440e --- /dev/null +++ b/boards/phytium/s5000c_testb/s5000c_testb_defconfig @@ -0,0 +1,33 @@ +# SPDX-License-Identifier: Apache-2.0 + +# Platform Configuration +CONFIG_ARM64_VA_BITS_42=y +CONFIG_ARM64_PA_BITS_42=y +# Main stack size +CONFIG_MAIN_STACK_SIZE=8192 + +CONFIG_ARMV8_A_NS=y + +# Zephyr Kernel Configuration +CONFIG_XIP=n +CONFIG_FLASH_SIZE=0 +CONFIG_FLASH_BASE_ADDRESS=0x0 + +# Serial Drivers +CONFIG_SERIAL=y + +# Enable Console +CONFIG_CONSOLE=y +CONFIG_UART_CONSOLE=y + + +# Timer Drivers +CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME=y + + +#cache +CONFIG_CACHE_MANAGEMENT=y + +# PSCI is supported with NS +CONFIG_PM_CPU_OPS=y +CONFIG_PM_CPU_OPS_PSCI=y diff --git a/boards/phytium/s5000c_testb_smp/Kconfig.defconfig b/boards/phytium/s5000c_testb_smp/Kconfig.defconfig new file mode 100644 index 00000000000..754f09e2b9f --- /dev/null +++ b/boards/phytium/s5000c_testb_smp/Kconfig.defconfig @@ -0,0 +1,30 @@ +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +# +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# https://opensource.org/license/apache-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. + + +config BOARD + default "Phytium S5000C testb" + depends on BOARD_S5000C_TESTB + + + +if NETWORKING + +config NET_L2_ETHERNET + default y + + + +endif # NETWORKING diff --git a/boards/phytium/s5000c_testb_smp/Kconfig.s5000c_testb_smp b/boards/phytium/s5000c_testb_smp/Kconfig.s5000c_testb_smp new file mode 100644 index 00000000000..e71bc1878df --- /dev/null +++ b/boards/phytium/s5000c_testb_smp/Kconfig.s5000c_testb_smp @@ -0,0 +1,18 @@ +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +# +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# https://opensource.org/license/apache-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. + +config BOARD_S5000C_TESTB_SMP + bool "phytium S5000C" + select SOC_S5000C diff --git a/boards/phytium/s5000c_testb_smp/board.cmake b/boards/phytium/s5000c_testb_smp/board.cmake new file mode 100644 index 00000000000..9881313609a --- /dev/null +++ b/boards/phytium/s5000c_testb_smp/board.cmake @@ -0,0 +1 @@ +# SPDX-License-Identifier: Apache-2.0 diff --git a/boards/phytium/s5000c_testb_smp/board.yml b/boards/phytium/s5000c_testb_smp/board.yml new file mode 100644 index 00000000000..7dbc474c98a --- /dev/null +++ b/boards/phytium/s5000c_testb_smp/board.yml @@ -0,0 +1,5 @@ +board: + name: s5000c_testb_smp + vendor: arm64 + socs: + - name: phytium_s5000c \ No newline at end of file diff --git a/boards/phytium/s5000c_testb_smp/s5000c_testb_smp.dts b/boards/phytium/s5000c_testb_smp/s5000c_testb_smp.dts new file mode 100644 index 00000000000..9d7ceda7549 --- /dev/null +++ b/boards/phytium/s5000c_testb_smp/s5000c_testb_smp.dts @@ -0,0 +1,50 @@ +/* + * Copyright 2023 honglin leng + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; + +#include +/ { + model = "Phytium s5000c testb"; + compatible = "phytium,s5000c-testb", "phytium,s5000c"; + #address-cells = <2>; + #size-cells = <2>; + + psci { + compatible = "arm,psci-0.2"; + method = "smc"; + label = "PSCI"; + }; + +chosen { + zephyr,console = &uart1; + zephyr,shell-uart = &uart1; + zephyr,sram = &sram0; + }; +}; + +// &sdhc1 { +// status = "okay"; +// sdmmc { +// compatible = "zephyr,sdmmc-disk"; +// status = "okay"; +// }; +// }; + +&uart1 { + status = "okay"; + current-speed = <115200>; +}; + +// &uart2 { +// status = "okay"; +// current-speed = <115200>; +// }; + +// &xmac0 { +// status = "okay"; +// local-mac-address = [00 00 00 01 02 03]; +// }; diff --git a/boards/phytium/s5000c_testb_smp/s5000c_testb_smp.yaml b/boards/phytium/s5000c_testb_smp/s5000c_testb_smp.yaml new file mode 100644 index 00000000000..13359566554 --- /dev/null +++ b/boards/phytium/s5000c_testb_smp/s5000c_testb_smp.yaml @@ -0,0 +1,10 @@ + +identifier: s5000c_testb +name: Phytium s5000c testb +type: mcu +arch: arm64 +toolchain: + - zephyr + - cross-compile +supported: + - smp diff --git a/boards/phytium/s5000c_testb_smp/s5000c_testb_smp_defconfig b/boards/phytium/s5000c_testb_smp/s5000c_testb_smp_defconfig new file mode 100644 index 00000000000..2896228ec7e --- /dev/null +++ b/boards/phytium/s5000c_testb_smp/s5000c_testb_smp_defconfig @@ -0,0 +1,41 @@ +# SPDX-License-Identifier: Apache-2.0 + +# Platform Configuration +CONFIG_ARM64_VA_BITS_42=y +CONFIG_ARM64_PA_BITS_42=y +# Main stack size +CONFIG_MAIN_STACK_SIZE=4096 + +CONFIG_ARMV8_A_NS=y + +# Zephyr Kernel Configuration +CONFIG_XIP=n +CONFIG_FLASH_SIZE=0 +CONFIG_FLASH_BASE_ADDRESS=0x0 + +# Serial Drivers +CONFIG_SERIAL=y + +# Enable Console +CONFIG_CONSOLE=y +CONFIG_UART_CONSOLE=y + +#cache +CONFIG_CACHE_MANAGEMENT=y + +# Timer Drivers +CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME=y + +# PSCI is supported with NS +CONFIG_PM_CPU_OPS=y +CONFIG_PM_CPU_OPS_PSCI=y + +# SMP-related +CONFIG_SMP=y +CONFIG_MP_MAX_NUM_CPUS=8 +CONFIG_TIMEOUT_64BIT=y + +# CONFIG_SHELL=y +# CONFIG_SHELL_BACKEND_SERIAL_INTERRUPT_DRIVEN=n +# CONFIG_SHELL_BACKEND_SERIAL_RX_POLL_PERIOD=1 +# CONFIG_BOOT_BANNER=n diff --git a/dts/arm64/phytium/s5000c.dtsi b/dts/arm64/phytium/s5000c.dtsi new file mode 100644 index 00000000000..dd7c801c67e --- /dev/null +++ b/dts/arm64/phytium/s5000c.dtsi @@ -0,0 +1,233 @@ + +// Phytium is pleased to support the open source community by making Zephyr-SDK available. + +// +// Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +// +// Licensed under the Apache-2.0 License (the "License"); you may not use this file except +// in compliance with the License. You may obtain a copy of the License at +// +// https://opensource.org/license/apache-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 +#include +#include + +/ { + #address-cells = <2>; + #size-cells = <2>; + + cpus { + #address-cells = <2>; + #size-cells = <0>; + + cpu@0 { + device_type = "cpu"; + compatible = "phytium,ftc862"; + reg = <0 0x0>; + }; + + cpu@1 { + device_type = "cpu"; + compatible = "phytium,ftc862"; + reg = <0 0x10000>; + }; + + cpu@2 { + device_type = "cpu"; + compatible = "phytium,ftc862"; + reg = <0 0x20000>; + }; + + cpu@3 { + device_type = "cpu"; + compatible = "phytium,ftc862"; + reg = <0 0x30000>; + }; + + cpu@4 { + device_type = "cpu"; + compatible = "phytium,ftc862"; + reg = <0 0x40000>; + }; + + cpu@5 { + device_type = "cpu"; + compatible = "phytium,ftc862"; + reg = <0 0x50000>; + }; + + cpu@6 { + device_type = "cpu"; + compatible = "phytium,ftc862"; + reg = <0 0x60000>; + }; + + cpu@7 { + device_type = "cpu"; + compatible = "phytium,ftc862"; + reg = <0 0x70000>; + }; + }; + + timer { + compatible = "arm,armv8-timer"; + interrupt-parent = <&gic>; + // ppi =+ 16, 13 == 29 Security physical timer interrupt, 14 == 30 Non secure physical timer interrupt + interrupts = , + , + , + ; + label = "arch_timer"; + }; + + uartclk: apb-pclk { + compatible = "fixed-clock"; + clock-frequency = <50000000>; + #clock-cells = <0>; + }; + + soc { + #address-cells = <2>; + #size-cells = <2>; + ranges; + + interrupt-parent = <&gic>; + + gic: interrupt-controller@22000000 { + compatible = "arm,gic-v3", "arm,gic"; + reg = <0x00 0x22000000 0x00 0x40000>, + <0x00 0x220c0000 0x00 0x200000>; + interrupt-controller; + #interrupt-cells = <4>; + label = "GIC"; + status = "okay"; + #size-cells = <0x02>; + #address-cells = <0x02>; + }; + + // pinctrl: pinctrl@32b30000 { + // compatible = "phytium,pinctrl"; + // reg = <0x00 0x32b30000 0x00 0x2000>; + // status = "okay"; + // }; + + uart1: uart@0x20001000 { + compatible = "arm,pl011"; + reg = <0x00 0x20001000 0x00 0x1000>; + status = "disabled"; + interrupts = ; + interrupt-names = "irq_0"; + clocks = <&uartclk>; + label = "UART_1"; + }; + + // uart0: uart@0x28008000 { + // compatible = "arm,pl011"; + // reg = <0x00 0x28008000 0x00 0x1000>; + // status = "disabled"; + // interrupts = ; + // interrupt-names = "irq_0"; + // clocks = <&uartclk>; + // label = "UART_0"; + // }; + + // uart2: uart@2800e000 { + // compatible = "arm,pl011"; + // reg = <0x00 0x2800e000 0x00 0x1000>; + // status = "disabled"; + // interrupts = ; + // interrupt-names = "irq_1"; + // clocks = <&uartclk>; + // label = "UART_2"; + // }; + + + // uart3: uart@2800f000 { + // compatible = "arm,pl011"; + // reg = <0x00 0x2800f000 0x00 0x1000>; + // status = "disabled"; + // interrupts = ; + // interrupt-names = "irq_0"; + // clocks = <&uartclk>; + // label = "UART_3"; + // }; + + + // sdhc0: sdhc@28000000 { + // compatible = "phytium,sdhc"; + // reg = <0x00 0x28000000 0x00 0x1000>; + // status = "disabled"; + // interrupts = ; + // max-current-330 = <1020>; + // max-bus-freq = <25000000>; + // min-bus-freq = <400000>; + // }; + + // xmac0: xmac@3200C000 { + // compatible = "phytium,xmac"; + // reg = <0x00 0x3200C000 0x00 0x2000>; + // status = "disabled"; + // interrupts = ; + // interrupt-names = "irq_0"; + // phy-poll-interval = <5000>; + // clock-frequency = <50000000> ; + // phy-speed = <1000> ; + // interface-mode = <0> ; + // dma-brust-length = <16> ; + // max-queue-num = <1> ; + // rx-buffer-descriptors = <128>; + // tx-buffer-descriptors = <128>; + // rx-buffer-size = <1600>; + // tx-buffer-size = <1600>; + // phy-autonegotiation; + // enable-fdx; + // disable-reject-fcs-crc-errors ; + // } ; + + // sdhc1: sdhc@28001000 { + // compatible = "phytium,sdhc"; + // reg = <0x00 0x28001000 0x00 0x1000>; + // status = "disabled"; + // interrupts = ; + // max-current-330 = <1020>; + // max-bus-freq = <25000000>; + // min-bus-freq = <400000>; + // }; + + /* 512MB DDR */ + sram0: memory@80100000 { + device_type = "memory"; + compatible = "mmio-sram"; + reg = <0x00 0x80100000 0x00 0x20000000>; + }; + + // temp_mem0:memory@0xe0000000 { + // device_type = "memory"; + // compatible = "mmio-sram"; + // reg = <0x00 0xe0000000 0x00 0x10000000>; + // } ; + + // pcie0: pcie@40000000 { + // compatible = "pci-host-ecam-generic"; + // device_type = "pci"; + // reg = <0x00 0x40000000 0x00 0x10000000>; + // #size-cells = <0x02>; + // #address-cells = <0x03>; + // ranges = <0x1000000 0x00 0x50000000 0x00 0x50000000 0x00 0x08000000 + // 0x2000000 0x00 0x58000000 0x00 0x58000000 0x00 0x27ffffff + // 0x3000000 0x10 0x00 0x10 0x00 0x1f 0xffffffff>; + // bus-range = <0x00 0xff>; + // }; + }; +}; diff --git a/soc/arm/phytium_e2000d/CMakeLists.txt b/soc/arm/phytium_e2000d/CMakeLists.txt new file mode 100644 index 00000000000..801a8ef8fc7 --- /dev/null +++ b/soc/arm/phytium_e2000d/CMakeLists.txt @@ -0,0 +1,10 @@ +# Copyright (c) 2024 zhangyan +# SPDX-License-Identifier: Apache-2.0 + +zephyr_sources_ifdef(CONFIG_ARM_MMU mmu_regions.c) + +zephyr_sources(soc.c) + +zephyr_include_directories(.) + +set(SOC_LINKER_SCRIPT ${ZEPHYR_BASE}/include/zephyr/arch/arm64/scripts/linker.ld CACHE INTERNAL "") diff --git a/soc/arm/phytium_e2000d/Kconfig b/soc/arm/phytium_e2000d/Kconfig new file mode 100644 index 00000000000..a61e901569b --- /dev/null +++ b/soc/arm/phytium_e2000d/Kconfig @@ -0,0 +1,9 @@ +# Copyright (c) 2024 zhangyan +# SPDX-License-Identifier: Apache-2.0 + +config SOC_E2000D + select ARM64 + select CPU_PHYTIUM_FTC310 + select ARM_ARCH_TIMER if SYS_CLOCK_EXISTS + select PHYTIUM_STANDALONE_SDK + select PHYTIUM_SOFT \ No newline at end of file diff --git a/soc/arm/phytium_e2000d/Kconfig.defconfig b/soc/arm/phytium_e2000d/Kconfig.defconfig new file mode 100644 index 00000000000..e61a0be8a4c --- /dev/null +++ b/soc/arm/phytium_e2000d/Kconfig.defconfig @@ -0,0 +1,29 @@ +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. + +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at + +# https://opensource.org/license/apache-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. + +if SOC_E2000D + +config SOC + default "phytium_e2000d" + +config NUM_IRQS + int + default 266 + +config SYS_CLOCK_HW_CYCLES_PER_SEC + int + default 50000000 + +endif diff --git a/soc/arm/phytium_e2000d/Kconfig.soc b/soc/arm/phytium_e2000d/Kconfig.soc new file mode 100644 index 00000000000..cf7518e7e7c --- /dev/null +++ b/soc/arm/phytium_e2000d/Kconfig.soc @@ -0,0 +1,24 @@ +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. + +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at + +# https://opensource.org/license/apache-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. + +config SOC_E2000D + bool "e2000d" + select SOC_FAMILY_ARM64 + +if SOC_E2000D +config HAL_STANDALONE_SDK_DEBUG + bool "standalone_sdk_debug" + +endif \ No newline at end of file diff --git a/soc/arm/phytium_e2000d/mmu_regions.c b/soc/arm/phytium_e2000d/mmu_regions.c new file mode 100644 index 00000000000..5f2a0000ad8 --- /dev/null +++ b/soc/arm/phytium_e2000d/mmu_regions.c @@ -0,0 +1,38 @@ +// Phytium is pleased to support the open source community by making Zephyr-SDK available. + +// +// Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. + +// Licensed under the Apache-2.0 License (the "License"); you may not use this file except +// in compliance with the License. You may obtain a copy of the License at + +// https://opensource.org/license/apache-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 +#include +#include + +static const struct arm_mmu_region mmu_regions[] = { + MMU_REGION_FLAT_ENTRY("GIC", + DT_REG_ADDR_BY_IDX(DT_INST(0, arm_gic), 0), + DT_REG_SIZE_BY_IDX(DT_INST(0, arm_gic), 0), + MT_DEVICE_nGnRnE | MT_P_RW_U_NA | MT_DEFAULT_SECURE_STATE), + + MMU_REGION_FLAT_ENTRY("GIC", + DT_REG_ADDR_BY_IDX(DT_INST(0, arm_gic), 1), + DT_REG_SIZE_BY_IDX(DT_INST(0, arm_gic), 1), + MT_DEVICE_nGnRnE | MT_P_RW_U_NA | MT_DEFAULT_SECURE_STATE), +}; + +const struct arm_mmu_config mmu_config = { + .num_regions = ARRAY_SIZE(mmu_regions), + .mmu_regions = mmu_regions, +}; + + + diff --git a/soc/arm/phytium_e2000d/soc.c b/soc/arm/phytium_e2000d/soc.c new file mode 100644 index 00000000000..d879c4fb8d1 --- /dev/null +++ b/soc/arm/phytium_e2000d/soc.c @@ -0,0 +1,23 @@ +// Phytium is pleased to support the open source community by making Zephyr-SDK available. + +// +// Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. + +// Licensed under the Apache-2.0 License (the "License"); you may not use this file except +// in compliance with the License. You may obtain a copy of the License at + +// https://opensource.org/license/apache-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 + +/* Boot-time static default printk handler, possibly to be overridden later. */ +int arch_printk_char_out(int c) +{ + putchar(c) ; + return 0; +} \ No newline at end of file diff --git a/soc/arm/phytium_s5000c/CMakeLists.txt b/soc/arm/phytium_s5000c/CMakeLists.txt new file mode 100644 index 00000000000..801a8ef8fc7 --- /dev/null +++ b/soc/arm/phytium_s5000c/CMakeLists.txt @@ -0,0 +1,10 @@ +# Copyright (c) 2024 zhangyan +# SPDX-License-Identifier: Apache-2.0 + +zephyr_sources_ifdef(CONFIG_ARM_MMU mmu_regions.c) + +zephyr_sources(soc.c) + +zephyr_include_directories(.) + +set(SOC_LINKER_SCRIPT ${ZEPHYR_BASE}/include/zephyr/arch/arm64/scripts/linker.ld CACHE INTERNAL "") diff --git a/soc/arm/phytium_s5000c/Kconfig b/soc/arm/phytium_s5000c/Kconfig new file mode 100644 index 00000000000..aaf59fb79d5 --- /dev/null +++ b/soc/arm/phytium_s5000c/Kconfig @@ -0,0 +1,10 @@ +# Copyright (c) 2024 zhangyan +# SPDX-License-Identifier: Apache-2.0 + +config SOC_S5000C + select ARM64 + select CPU_PHYTIUM_FTC862 + select CPU_CORTEX_A53 + select ARM_ARCH_TIMER if SYS_CLOCK_EXISTS + select PHYTIUM_STANDALONE_SDK + select PHYTIUM_SOFT diff --git a/soc/arm/phytium_s5000c/Kconfig.defconfig b/soc/arm/phytium_s5000c/Kconfig.defconfig new file mode 100644 index 00000000000..5f00a34bea9 --- /dev/null +++ b/soc/arm/phytium_s5000c/Kconfig.defconfig @@ -0,0 +1,29 @@ +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. + +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at + +# https://opensource.org/license/apache-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. + +if SOC_S5000C + +config SOC + default "phytium_s5000c" + +config NUM_IRQS + int + default 266 + +config SYS_CLOCK_HW_CYCLES_PER_SEC + int + default 50000000 + +endif diff --git a/soc/arm/phytium_s5000c/Kconfig.soc b/soc/arm/phytium_s5000c/Kconfig.soc new file mode 100644 index 00000000000..572605098ac --- /dev/null +++ b/soc/arm/phytium_s5000c/Kconfig.soc @@ -0,0 +1,27 @@ +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. + +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at + +# https://opensource.org/license/apache-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. + +config SOC_S5000C + bool "phytium_s5000c" + select SOC_FAMILY_ARM64 + +config SOC + default "soc_s5000c" if SOC_S5000C + +if SOC_S5000C +config HAL_STANDALONE_SDK_DEBUG + bool "standalone_sdk_debug" + +endif diff --git a/soc/arm/phytium_s5000c/mmu_regions.c b/soc/arm/phytium_s5000c/mmu_regions.c new file mode 100644 index 00000000000..6c51737df3f --- /dev/null +++ b/soc/arm/phytium_s5000c/mmu_regions.c @@ -0,0 +1,52 @@ +/* + * Copyright : (C) 2024 Phytium Information Technology, Inc. + * All Rights Reserved. + * + * This program is OPEN SOURCE software: you can redistribute it and/or modify it + * under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd, + * either version 1.0 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the Phytium Public License for more details. + * + * + * FilePath: mmu_regions.c + * Created Date: 2024-10-11 14:03:59 + * Last Modified: 2024-10-15 13:43:05 + * Description: This file is for + * + * Modify History: + * Ver Who Date Changes + * ----- ---------- -------- --------------------------------- + */ + +#include +#include +#include + +static const struct arm_mmu_region mmu_regions[] = { + MMU_REGION_FLAT_ENTRY("GIC", + DT_REG_ADDR_BY_IDX(DT_INST(0, arm_gic), 0), + DT_REG_SIZE_BY_IDX(DT_INST(0, arm_gic), 0), + MT_DEVICE_nGnRnE | MT_P_RW_U_NA | MT_DEFAULT_SECURE_STATE), + + MMU_REGION_FLAT_ENTRY("GIC", + DT_REG_ADDR_BY_IDX(DT_INST(0, arm_gic), 1), + DT_REG_SIZE_BY_IDX(DT_INST(0, arm_gic), 1), + MT_DEVICE_nGnRnE | MT_P_RW_U_NA | MT_DEFAULT_SECURE_STATE), + + MMU_REGION_FLAT_ENTRY("UART1", + DT_REG_ADDR(DT_INST(0, arm_pl011)), + DT_REG_SIZE(DT_INST(0, arm_pl011)), + MT_DEVICE_nGnRnE | MT_P_RW_U_NA | MT_DEFAULT_SECURE_STATE), + +}; + +const struct arm_mmu_config mmu_config = { + .num_regions = ARRAY_SIZE(mmu_regions), + .mmu_regions = mmu_regions, +}; + + + diff --git a/soc/arm/phytium_s5000c/soc.c b/soc/arm/phytium_s5000c/soc.c new file mode 100644 index 00000000000..d879c4fb8d1 --- /dev/null +++ b/soc/arm/phytium_s5000c/soc.c @@ -0,0 +1,23 @@ +// Phytium is pleased to support the open source community by making Zephyr-SDK available. + +// +// Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. + +// Licensed under the Apache-2.0 License (the "License"); you may not use this file except +// in compliance with the License. You may obtain a copy of the License at + +// https://opensource.org/license/apache-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 + +/* Boot-time static default printk handler, possibly to be overridden later. */ +int arch_printk_char_out(int c) +{ + putchar(c) ; + return 0; +} \ No newline at end of file diff --git a/soc/arm/soc.yml b/soc/arm/soc.yml index 05549143502..3b471c77264 100644 --- a/soc/arm/soc.yml +++ b/soc/arm/soc.yml @@ -34,4 +34,6 @@ family: - name: qemu_virt_arm64 - name: phytium_d3000 - name: phytium_d2000 + - name: phytium_e2000d - name: phytium_e2000q + - name: phytium_s5000c -- Gitee From 0845a459d094c80368cb484ea1bc06fd5bdee87e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E9=B9=A4?= Date: Mon, 9 Dec 2024 11:11:09 +0000 Subject: [PATCH 03/13] Add el2 --- .gdbinit | 42 - arch/arm64/core/Kconfig | 5 + arch/arm64/core/fatal.c | 7 + arch/arm64/core/mmu.c | 75 +- arch/arm64/core/reset.S | 78 +- arch/arm64/core/reset.c | 24 + arch/arm64/core/switch.S | 7 + arch/arm64/core/thread.c | 6 +- arch/arm64/core/vector_table.S | 36 + boards/deprecated.cmake | 27 + boards/phytium/d2000_demo/Kconfig.d2000_demo | 18 - boards/phytium/d2000_demo/Kconfig.defconfig | 19 - boards/phytium/d2000_demo/board.cmake | 1 - boards/phytium/d2000_demo/board.yml | 5 - .../d2000_demo_smp/Kconfig.d2000_demo_smp | 18 - .../phytium/d2000_demo_smp/Kconfig.defconfig | 19 - boards/phytium/d2000_demo_smp/board.cmake | 1 - boards/phytium/d2000_demo_smp/board.yml | 5 - .../d2000_demo_smp/d2000_demo_smp_defconfig | 41 - boards/phytium/d3000_demo/Kconfig.d3000_demo | 18 - boards/phytium/d3000_demo/Kconfig.defconfig | 19 - boards/phytium/d3000_demo/board.cmake | 1 - boards/phytium/d3000_demo/board.yml | 5 - .../d3000_demo_smp/Kconfig.d3000_demo_smp | 18 - .../phytium/d3000_demo_smp/Kconfig.defconfig | 19 - boards/phytium/d3000_demo_smp/board.cmake | 1 - boards/phytium/d3000_demo_smp/board.yml | 5 - .../d3000_demo_smp/d3000_demo_smp.yaml | 10 - boards/phytium/e2000d_demo/board.yml | 11 +- .../e2000d_demo_e2000d_el2_smp.dts} | 0 .../e2000d_demo_e2000d_el2_smp.yaml} | 2 +- .../e2000d_demo_e2000d_el2_smp_defconfig} | 5 +- .../e2000d_demo_e2000d_smp.dts} | 18 +- .../e2000d_demo_e2000d_smp.yaml} | 5 +- .../e2000d_demo_e2000d_smp_defconfig} | 1 + .../e2000d_demo_el2.dts} | 21 +- .../e2000d_demo_el2.yaml} | 6 +- .../e2000d_demo_el2_defconfig} | 5 +- .../phytium/e2000d_demo_smp/Kconfig.defconfig | 19 - .../e2000d_demo_smp/Kconfig.e2000d_demo_smp | 18 - boards/phytium/e2000d_demo_smp/board.cmake | 1 - boards/phytium/e2000d_demo_smp/board.yml | 5 - boards/phytium/e2000q_demo/board.yml | 9 +- .../e2000q_demo_e2000q_el2.dts} | 33 +- .../e2000q_demo_e2000q_el2.yaml} | 4 +- .../e2000q_demo_e2000q_el2_defconfig} | 5 +- .../e2000q_demo_e2000q_el2_smp.dts} | 0 .../e2000q_demo_e2000q_el2_smp.yaml} | 4 +- .../e2000q_demo_e2000q_el2_smp_defconfig} | 5 +- .../e2000q_demo_e2000q_smp.dts} | 23 +- .../e2000q_demo_e2000q_smp.yaml} | 5 +- .../e2000q_demo_e2000q_smp_defconfig} | 0 .../phytium/e2000q_demo_smp/Kconfig.defconfig | 19 - .../e2000q_demo_smp/Kconfig.e2000q_demo_smp | 18 - boards/phytium/e2000q_demo_smp/board.cmake | 1 - boards/phytium/e2000q_demo_smp/board.yml | 5 - boards/phytium/s5000c_testb/Kconfig.defconfig | 30 - .../phytium/s5000c_testb/Kconfig.s5000c_testb | 18 - boards/phytium/s5000c_testb/board.cmake | 1 - boards/phytium/s5000c_testb/board.yml | 5 - boards/phytium/s5000c_testb/s5000c_testb.dts | 50 - .../s5000c_testb/s5000c_testb_defconfig | 33 - .../s5000c_testb_smp/Kconfig.defconfig | 30 - .../s5000c_testb_smp/Kconfig.s5000c_testb_smp | 18 - boards/phytium/s5000c_testb_smp/board.cmake | 1 - boards/phytium/s5000c_testb_smp/board.yml | 5 - .../s5000c_testb_smp/s5000c_testb_smp.dts | 50 - .../s5000c_testb_smp/s5000c_testb_smp.yaml | 10 - drivers/ethernet/eth_phytium_xmac.c | 2934 ++++++++--------- drivers/interrupt_controller/intc_gicv3.c | 23 + dts/arm64/phytium/d3000.dtsi | 135 - dts/arm64/phytium/e2000q.dtsi | 354 +- dts/arm64/phytium/s5000c.dtsi | 233 -- include/zephyr/arch/arm64/lib_helpers.h | 3 + include/zephyr/arch/arm64/timer.h | 29 +- makefile | 18 +- soc/arm/phytium_s5000c/soc.c | 23 - soc/arm/soc.yml | 73 +- .../d2000}/CMakeLists.txt | 0 .../phytium_d2000 => phytium/d2000}/Kconfig | 0 .../d2000}/Kconfig.defconfig | 0 .../d2000}/Kconfig.soc | 0 .../d2000}/mmu_regions.c | 0 .../phytium_d2000 => phytium/d2000}/soc.c | 0 .../e2000d}/CMakeLists.txt | 0 .../phytium_e2000d => phytium/e2000d}/Kconfig | 0 .../e2000d}/Kconfig.defconfig | 2 +- .../e2000d}/Kconfig.soc | 0 .../e2000d}/mmu_regions.c | 0 .../phytium_e2000q => phytium/e2000d}/soc.c | 2 +- soc/phytium/e2000d/soc.h | 0 soc/phytium/e2000d/soc.yml | 5 + .../e2000q}/CMakeLists.txt | 0 .../phytium_e2000q => phytium/e2000q}/Kconfig | 0 .../e2000q}/Kconfig.defconfig | 2 +- .../e2000q}/Kconfig.soc | 0 .../e2000q}/mmu_regions.c | 0 .../e2000q}/pinctrl_soc.h | 0 .../phytium_d3000 => phytium/e2000q}/soc.c | 0 soc/phytium/e2000q/soc.yml | 5 + .../pd2308}/CMakeLists.txt | 0 .../phytium_s5000c => phytium/pd2308}/Kconfig | 2 +- .../pd2308}/Kconfig.defconfig | 4 +- .../pd2308}/Kconfig.soc | 8 +- .../pd2308}/mmu_regions.c | 0 soc/phytium/pd2308/soc.c | 32 + .../ps2316}/CMakeLists.txt | 0 .../phytium_d3000 => phytium/ps2316}/Kconfig | 2 +- .../ps2316}/Kconfig.defconfig | 4 +- .../ps2316}/Kconfig.soc | 8 +- .../ps2316}/mmu_regions.c | 0 .../phytium_e2000d => phytium/ps2316}/soc.c | 0 112 files changed, 2170 insertions(+), 2760 deletions(-) delete mode 100644 .gdbinit delete mode 100644 boards/phytium/d2000_demo/Kconfig.d2000_demo delete mode 100644 boards/phytium/d2000_demo/Kconfig.defconfig delete mode 100644 boards/phytium/d2000_demo/board.cmake delete mode 100644 boards/phytium/d2000_demo/board.yml delete mode 100644 boards/phytium/d2000_demo_smp/Kconfig.d2000_demo_smp delete mode 100644 boards/phytium/d2000_demo_smp/Kconfig.defconfig delete mode 100644 boards/phytium/d2000_demo_smp/board.cmake delete mode 100644 boards/phytium/d2000_demo_smp/board.yml delete mode 100644 boards/phytium/d2000_demo_smp/d2000_demo_smp_defconfig delete mode 100644 boards/phytium/d3000_demo/Kconfig.d3000_demo delete mode 100644 boards/phytium/d3000_demo/Kconfig.defconfig delete mode 100644 boards/phytium/d3000_demo/board.cmake delete mode 100644 boards/phytium/d3000_demo/board.yml delete mode 100644 boards/phytium/d3000_demo_smp/Kconfig.d3000_demo_smp delete mode 100644 boards/phytium/d3000_demo_smp/Kconfig.defconfig delete mode 100644 boards/phytium/d3000_demo_smp/board.cmake delete mode 100644 boards/phytium/d3000_demo_smp/board.yml delete mode 100644 boards/phytium/d3000_demo_smp/d3000_demo_smp.yaml rename boards/phytium/{e2000d_demo_smp/e2000d_demo_smp.dts => e2000d_demo/e2000d_demo_e2000d_el2_smp.dts} (100%) rename boards/phytium/{e2000d_demo_smp/e2000d_demo_smp.yaml => e2000d_demo/e2000d_demo_e2000d_el2_smp.yaml} (93%) rename boards/phytium/{d3000_demo_smp/d3000_demo_smp_defconfig => e2000d_demo/e2000d_demo_e2000d_el2_smp_defconfig} (93%) rename boards/phytium/{d2000_demo_smp/d2000_demo_smp.dts => e2000d_demo/e2000d_demo_e2000d_smp.dts} (60%) rename boards/phytium/{d3000_demo/d3000_demo.yaml => e2000d_demo/e2000d_demo_e2000d_smp.yaml} (61%) rename boards/phytium/{e2000d_demo_smp/e2000d_demo_smp_defconfig => e2000d_demo/e2000d_demo_e2000d_smp_defconfig} (99%) rename boards/phytium/{d2000_demo/d2000_demo.dts => e2000d_demo/e2000d_demo_el2.dts} (56%) rename boards/phytium/{d2000_demo_smp/d2000_demo_smp.yaml => e2000d_demo/e2000d_demo_el2.yaml} (48%) rename boards/phytium/{d3000_demo/d3000_demo_defconfig => e2000d_demo/e2000d_demo_el2_defconfig} (90%) delete mode 100644 boards/phytium/e2000d_demo_smp/Kconfig.defconfig delete mode 100644 boards/phytium/e2000d_demo_smp/Kconfig.e2000d_demo_smp delete mode 100644 boards/phytium/e2000d_demo_smp/board.cmake delete mode 100644 boards/phytium/e2000d_demo_smp/board.yml rename boards/phytium/{d3000_demo/d3000_demo.dts => e2000q_demo/e2000q_demo_e2000q_el2.dts} (34%) rename boards/phytium/{d2000_demo/d2000_demo.yaml => e2000q_demo/e2000q_demo_e2000q_el2.yaml} (54%) rename boards/phytium/{d2000_demo/d2000_demo_defconfig => e2000q_demo/e2000q_demo_e2000q_el2_defconfig} (90%) rename boards/phytium/{e2000q_demo_smp/e2000q_demo_smp.dts => e2000q_demo/e2000q_demo_e2000q_el2_smp.dts} (100%) rename boards/phytium/{e2000q_demo_smp/e2000q_demo_smp.yaml => e2000q_demo/e2000q_demo_e2000q_el2_smp.yaml} (69%) rename boards/phytium/{s5000c_testb_smp/s5000c_testb_smp_defconfig => e2000q_demo/e2000q_demo_e2000q_el2_smp_defconfig} (93%) rename boards/phytium/{d3000_demo_smp/d3000_demo_smp.dts => e2000q_demo/e2000q_demo_e2000q_smp.dts} (52%) rename boards/phytium/{s5000c_testb/s5000c_testb.yaml => e2000q_demo/e2000q_demo_e2000q_smp.yaml} (57%) rename boards/phytium/{e2000q_demo_smp/e2000q_demo_smp_defconfig => e2000q_demo/e2000q_demo_e2000q_smp_defconfig} (100%) delete mode 100644 boards/phytium/e2000q_demo_smp/Kconfig.defconfig delete mode 100644 boards/phytium/e2000q_demo_smp/Kconfig.e2000q_demo_smp delete mode 100644 boards/phytium/e2000q_demo_smp/board.cmake delete mode 100644 boards/phytium/e2000q_demo_smp/board.yml delete mode 100644 boards/phytium/s5000c_testb/Kconfig.defconfig delete mode 100644 boards/phytium/s5000c_testb/Kconfig.s5000c_testb delete mode 100644 boards/phytium/s5000c_testb/board.cmake delete mode 100644 boards/phytium/s5000c_testb/board.yml delete mode 100644 boards/phytium/s5000c_testb/s5000c_testb.dts delete mode 100644 boards/phytium/s5000c_testb/s5000c_testb_defconfig delete mode 100644 boards/phytium/s5000c_testb_smp/Kconfig.defconfig delete mode 100644 boards/phytium/s5000c_testb_smp/Kconfig.s5000c_testb_smp delete mode 100644 boards/phytium/s5000c_testb_smp/board.cmake delete mode 100644 boards/phytium/s5000c_testb_smp/board.yml delete mode 100644 boards/phytium/s5000c_testb_smp/s5000c_testb_smp.dts delete mode 100644 boards/phytium/s5000c_testb_smp/s5000c_testb_smp.yaml delete mode 100644 dts/arm64/phytium/d3000.dtsi delete mode 100644 dts/arm64/phytium/s5000c.dtsi delete mode 100644 soc/arm/phytium_s5000c/soc.c rename soc/{arm/phytium_d2000 => phytium/d2000}/CMakeLists.txt (100%) rename soc/{arm/phytium_d2000 => phytium/d2000}/Kconfig (100%) rename soc/{arm/phytium_d2000 => phytium/d2000}/Kconfig.defconfig (100%) rename soc/{arm/phytium_d2000 => phytium/d2000}/Kconfig.soc (100%) rename soc/{arm/phytium_d2000 => phytium/d2000}/mmu_regions.c (100%) rename soc/{arm/phytium_d2000 => phytium/d2000}/soc.c (100%) rename soc/{arm/phytium_d3000 => phytium/e2000d}/CMakeLists.txt (100%) rename soc/{arm/phytium_e2000d => phytium/e2000d}/Kconfig (100%) rename soc/{arm/phytium_e2000d => phytium/e2000d}/Kconfig.defconfig (96%) rename soc/{arm/phytium_e2000d => phytium/e2000d}/Kconfig.soc (100%) rename soc/{arm/phytium_e2000d => phytium/e2000d}/mmu_regions.c (100%) rename soc/{arm/phytium_e2000q => phytium/e2000d}/soc.c (99%) create mode 100644 soc/phytium/e2000d/soc.h create mode 100644 soc/phytium/e2000d/soc.yml rename soc/{arm/phytium_e2000d => phytium/e2000q}/CMakeLists.txt (100%) rename soc/{arm/phytium_e2000q => phytium/e2000q}/Kconfig (100%) rename soc/{arm/phytium_e2000q => phytium/e2000q}/Kconfig.defconfig (96%) rename soc/{arm/phytium_e2000q => phytium/e2000q}/Kconfig.soc (100%) rename soc/{arm/phytium_e2000q => phytium/e2000q}/mmu_regions.c (100%) rename soc/{arm/phytium_e2000q => phytium/e2000q}/pinctrl_soc.h (100%) rename soc/{arm/phytium_d3000 => phytium/e2000q}/soc.c (100%) create mode 100644 soc/phytium/e2000q/soc.yml rename soc/{arm/phytium_e2000q => phytium/pd2308}/CMakeLists.txt (100%) rename soc/{arm/phytium_s5000c => phytium/pd2308}/Kconfig (93%) rename soc/{arm/phytium_s5000c => phytium/pd2308}/Kconfig.defconfig (95%) rename soc/{arm/phytium_s5000c => phytium/pd2308}/Kconfig.soc (89%) rename soc/{arm/phytium_d3000 => phytium/pd2308}/mmu_regions.c (100%) create mode 100644 soc/phytium/pd2308/soc.c rename soc/{arm/phytium_s5000c => phytium/ps2316}/CMakeLists.txt (100%) rename soc/{arm/phytium_d3000 => phytium/ps2316}/Kconfig (93%) rename soc/{arm/phytium_d3000 => phytium/ps2316}/Kconfig.defconfig (95%) rename soc/{arm/phytium_d3000 => phytium/ps2316}/Kconfig.soc (89%) rename soc/{arm/phytium_s5000c => phytium/ps2316}/mmu_regions.c (100%) rename soc/{arm/phytium_e2000d => phytium/ps2316}/soc.c (100%) diff --git a/.gdbinit b/.gdbinit deleted file mode 100644 index 76b6f237a7b..00000000000 --- a/.gdbinit +++ /dev/null @@ -1,42 +0,0 @@ -# increase the default remote timeout in gdb because -# Windows libusb transactions could be slow -set remotetimeout 100000 - -# gdb connect to openocd in port 3333 -target extended-remote localhost:3333 - -# start openocd working queue, monitor followed with openocd command here -monitor init - -# force to use hardware breakpoint, otherwise use software breakpoint -# for e2000d/q, num of hardware breakpoints supposed to be 6 -monitor gdb_breakpoint_override hardware - -# load elf image -load ./build/zephyr/zephyr.elf - -# in case symbols skip load,load agin -file ./build/zephyr/zephyr.elf - -# we can break at the beginning of code by address or by symbol -#break _boot - -# add more breakpoints in application -#break JtagTouchRegisters -#break JtagTouchMemory -# break bubbleSort -# break JtagPostSort -#break bubbleSortCXX - -# show all breakspoints we before running -# info breakpoints - -# show [-0x10 ~ +0x10 ] range of instructions when breaked -# display /10i $pc-16 - -# start running -# continue - -layout split - -si diff --git a/arch/arm64/core/Kconfig b/arch/arm64/core/Kconfig index 17553a8a775..014da571042 100644 --- a/arch/arm64/core/Kconfig +++ b/arch/arm64/core/Kconfig @@ -239,6 +239,11 @@ config ARMV8_A so that it can support some features included in the AArch64 state. It supports the T32 and A32 instruction sets. +config USE_EL2 + bool "Use EL2 for kernel execution" + help + this option enables the use of EL2 for kernel execution + rsource "xen/Kconfig" endif # CPU_CORTEX_A diff --git a/arch/arm64/core/fatal.c b/arch/arm64/core/fatal.c index a02ae13acf8..0b6878b118b 100644 --- a/arch/arm64/core/fatal.c +++ b/arch/arm64/core/fatal.c @@ -322,6 +322,13 @@ void z_arm64_fatal_error(unsigned int reason, struct arch_esf *esf) far = read_far_el1(); elr = read_elr_el1(); break; +#ifdef CONFIG_USE_EL2 + case MODE_EL2: + esr = read_esr_el2(); + far = read_far_el2(); + elr = read_elr_el2(); + break; +#endif #if !defined(CONFIG_ARMV8_R) case MODE_EL3: esr = read_esr_el3(); diff --git a/arch/arm64/core/mmu.c b/arch/arm64/core/mmu.c index 12f391a598a..61810f7de07 100644 --- a/arch/arm64/core/mmu.c +++ b/arch/arm64/core/mmu.c @@ -686,9 +686,12 @@ static uint64_t get_region_desc(uint32_t attrs) case MT_NORMAL_NC: case MT_NORMAL: /* Make Normal RW memory as execute never */ - if ((attrs & MT_RW) || (attrs & MT_P_EXECUTE_NEVER)) - desc |= PTE_BLOCK_DESC_PXN; +#ifndef CONFIG_USE_EL2 + if ((attrs & MT_RW) || (attrs & MT_P_EXECUTE_NEVER)) + desc |= PTE_BLOCK_DESC_PXN; +#else +#endif if (((attrs & MT_RW) && (attrs & MT_RW_AP_ELx)) || (attrs & MT_U_EXECUTE_NEVER)) desc |= PTE_BLOCK_DESC_UXN; @@ -750,9 +753,16 @@ static void remove_map(struct arm_mmu_ptables *ptables, const char *name, static void invalidate_tlb_all(void) { - __asm__ volatile ( - "dsb ishst; tlbi vmalle1; dsb ish; isb" +#ifndef CONFIG_USE_EL2 +__asm__ volatile ( + "dsb ishst; tlbi vmalle1; dsb sy; isb" : : : "memory"); +#else +__asm__ volatile ( + "dsb ishst; tlbi alle2; dsb ish; isb" + : : : "memory"); +#endif + } /* zephyr execution regions with appropriate attributes */ @@ -773,7 +783,12 @@ static const struct arm_mmu_flat_range mmu_zephyr_ranges[] = { { .name = "zephyr_data", .start = _image_ram_start, .end = _image_ram_end, - .attrs = MT_NORMAL | MT_P_RW_U_NA | MT_DEFAULT_SECURE_STATE }, +#ifndef CONFIG_USE_EL2 + .attrs = MT_NORMAL | MT_P_RW_U_NA | MT_DEFAULT_SECURE_STATE , +#else + .attrs = MT_NORMAL | MT_P_RW_U_RW | MT_DEFAULT_SECURE_STATE, +#endif + }, /* Mark text segment cacheable,read only and executable */ { .name = "zephyr_code", @@ -939,7 +954,30 @@ static void enable_mmu_el1(struct arm_mmu_ptables *ptables, unsigned int flags) /* Enable the MMU and data cache */ val = read_sctlr_el1(); write_sctlr_el1(val | SCTLR_M_BIT | SCTLR_C_BIT); - + + /* Ensure the MMU enable takes effect immediately */ + barrier_isync_fence_full(); + + MMU_DEBUG("MMU enabled with dcache\n"); +} + +static void enable_mmu_el2(struct arm_mmu_ptables *ptables, unsigned int flags) +{ + ARG_UNUSED(flags); + uint64_t val; + + /* Set MAIR, TCR and TBBR registers */ + write_mair_el2(MEMORY_ATTRIBUTES); + write_tcr_el2(get_tcr(2)); + write_ttbr0_el2((uint64_t)ptables->base_xlat_table); + + /* Ensure these changes are seen before MMU is enabled */ + barrier_isync_fence_full(); + + /* Enable the MMU and data cache */ + val = read_sctlr_el2(); + write_sctlr_el2(val | SCTLR_M_BIT | SCTLR_C_BIT | SCTLR_I_BIT); + /* Ensure the MMU enable takes effect immediately */ barrier_isync_fence_full(); @@ -966,12 +1004,21 @@ void z_arm64_mm_init(bool is_primary_core) __ASSERT(CONFIG_MMU_PAGE_SIZE == KB(4), "Only 4K page size is supported\n"); - __ASSERT(GET_EL(read_currentel()) == MODE_EL1, - "Exception level not EL1, MMU not enabled!\n"); +#ifndef CONFIG_USE_EL2 + __ASSERT(GET_EL(read_currentel()) == MODE_EL1, + "Exception level not EL1, MMU not enabled!\n"); +#else + __ASSERT(GET_EL(read_currentel()) == MODE_EL2, + "Exception level not EL2, MMU not enabled!\n"); +#endif +#ifndef CONFIG_USE_EL2 + /* Ensure that MMU is already not enabled */ + __ASSERT((read_sctlr_el1() & SCTLR_M_BIT) == 0, "MMU is already enabled\n"); +#else /* Ensure that MMU is already not enabled */ - __ASSERT((read_sctlr_el1() & SCTLR_M_BIT) == 0, "MMU is already enabled\n"); - + __ASSERT((read_sctlr_el2() & SCTLR_M_BIT) == 0, "MMU is already enabled\n"); +#endif /* * Only booting core setup up the page tables. */ @@ -980,8 +1027,12 @@ void z_arm64_mm_init(bool is_primary_core) setup_page_tables(&kernel_ptables); } - /* currently only EL1 is supported */ - enable_mmu_el1(&kernel_ptables, flags); +#ifndef CONFIG_USE_EL2 + /* currently only EL1 is supported */ + enable_mmu_el1(&kernel_ptables, flags); +#else + enable_mmu_el2(&kernel_ptables, flags) ; +#endif } static void sync_domains(uintptr_t virt, size_t size, const char *name) diff --git a/arch/arm64/core/reset.S b/arch/arm64/core/reset.S index d155b877841..970a7348264 100644 --- a/arch/arm64/core/reset.S +++ b/arch/arm64/core/reset.S @@ -67,9 +67,15 @@ SECTION_SUBSEC_FUNC(TEXT,_reset_section,__reset_prep_c) /* Custom plat prep_c init */ bl z_arm64_el2_plat_prep_c +#ifndef CONFIG_USE_EL2 /* Set SP_EL1 */ msr sp_el1, x24 - +#else + # msr sp_el2, x24 + msr SPSel, #1 + # use sp_el2 + mov sp, x24 +#endif b out 1: /* Disable alignment fault checking */ @@ -221,6 +227,7 @@ switch_el: 3: #if !defined(CONFIG_ARMV8_R) +#ifndef CONFIG_USE_EL2 /* EL3 init */ bl z_arm64_el3_init @@ -228,12 +235,40 @@ switch_el: adr x0, switch_el bl z_arm64_el3_get_next_el eret +#else + /* initialize sctlr_el2 and hcr_el2 to save values before entering el2.*/ + msr sctlr_el2, xzr + msr hcr_el2, xzr + /* determine the el2 execution state.*/ + mrs x0, scr_el3 + orr x0, x0, #(1<<10) + /* rw el2 execution state is aarch64.*/ + orr x0, x0, #(1<<0) + /* ns el1 is non-secure world.*/ + msr scr_el3, x0 + mov x0, #0b01001 + orr x0, x0, SPSR_DAIF_MASK + # orr x0, x0, SPSR_MODE_EL1T + /* daif=0000 */ + msr spsr_el3, x0 + /* m[4:0]=01001 el2h must match scr_el3.rw*/ + + # bl FTraceEL3 + /* determine el2 entry.*/ + adr x0, 2f + /* El2Entry points to the first instruction of */ + msr elr_el3, x0 + /* el2 code.*/ + eret +#endif #endif /* CONFIG_ARMV8_R */ 2: + mov sp, x24 /* EL2 init */ bl z_arm64_el2_init +#ifndef CONFIG_USE_EL2 /* Move to EL1 with all exceptions masked */ mov_imm x0, (SPSR_DAIF_MASK | SPSR_MODE_EL1T) msr spsr_el2, x0 @@ -246,7 +281,7 @@ switch_el: msr elr_el2, x0 mrs x1, HCR_EL2 - orr x1, x1, #(1<<31) + orr x1, x1, #(1<<31) bic x1, x1, #(1<<27) /* HCR_EL2.TGE = 0 */ bic x1, x1, #(1<<5) /* HCR_EL2.AMO = 0 */ bic x1, x1, #(1<<4) /* HCR_EL2.IMO = 0 */ @@ -254,9 +289,35 @@ switch_el: orr x1, x1, #(1<<1) /* HCR_EL2.SWIO = 1 */ /* rw=1 el1 execution state is aarch64.*/ msr HCR_EL2, x1 - isb + isb eret +#else + + msr sctlr_el2, xzr + isb + + ldr x0,=__hcr_set + ldr x0, [x0] + msr hcr_el2, x0 + mov x0,0 + msr CNTHCTL_EL2, x0 + bl InvalidateFlushDcaches + dsb sy + isb + + /* We want to use SP_ELx from now on */ + msr SPSel, #1 + + /* Enable SError interrupts */ + msr DAIFClr, #(DAIFCLR_ABT_BIT) + isb + + ret x25 + +#endif + + 1: /* EL1 init */ bl z_arm64_el1_init @@ -279,7 +340,7 @@ InvalidateFlushDcacheLevel: mrs x6, ccsidr_el1 /* read the new cssidr_el1 */ and x2, x6, #7 /* x2 <- log2(cache line size)-4 */ add x2, x2, #4 /* x2 <- log2(cache line size) */ - mov x3, #0x3ff + mov x3, #0x3ff and x3, x3, x6, lsr #3 /* x3 <- max number of #ways, ccsidr_el1[12:3] */ clz w5, w3 /* bit position of #ways */ mov x4, #0x7fff @@ -291,7 +352,7 @@ InvalidateFlushDcacheLevel: /* x5 <- bit position of #ways */ InvalidateFlushCacheSet: - mov x6, x3 /* x6 <- working copy of #ways */ + mov x6, x3 /* x6 <- working copy of #ways */ InvalidateFlushCacheWay: lsl x7, x6, x5 /* x7 = x6 << x5 */ @@ -345,4 +406,9 @@ InvalidateFlushCachesSkipLevel: mov lr, x15 InvalidateFlushDcacheEnd: - ret \ No newline at end of file + ret + + +.align 3 +__hcr_set: + .dword 0x38 diff --git a/arch/arm64/core/reset.c b/arch/arm64/core/reset.c index 03cf389007d..54e62bc159f 100644 --- a/arch/arm64/core/reset.c +++ b/arch/arm64/core/reset.c @@ -121,6 +121,10 @@ void z_arm64_el2_init(void) { uint64_t reg; + write_vbar_el2((uint64_t)_vector_table); + barrier_isync_fence_full(); +#ifndef CONFIG_USE_EL2 + reg = read_sctlr_el2(); reg |= (SCTLR_EL2_RES1 | /* RES1 */ SCTLR_I_BIT | /* Enable i-cache */ @@ -142,7 +146,23 @@ void z_arm64_el2_init(void) reg &= ~(CPTR_TFP_BIT | /* Do not trap SVE, SIMD and FP */ CPTR_TCPAC_BIT); /* Do not trap CPACR_EL1 accesses */ write_cptr_el2(reg); +#else + + reg = 0U; /* RES0 */ + reg |= CPACR_EL1_FPEN_NOTRAP; /* Do not trap NEON/SIMD/FP initially */ + /* TODO: CONFIG_FLOAT_*_FORBIDDEN */ + write_cpacr_el1(reg); + + reg = read_sctlr_el2(); + reg |= (SCTLR_EL2_RES1 | /* RES1 */ + SCTLR_I_BIT | /* Enable i-cache */ + SCTLR_C_BIT | /* Enable d-cache */ + SCTLR_SA_BIT); /* Enable SP alignment check */ + write_sctlr_el1(reg); + write_cntv_cval_el0(~(uint64_t)0); + +#endif zero_cntvoff_el2(); /* Set 64-bit virtual timer offset to 0 */ zero_cnthctl_el2(); #ifdef CONFIG_CPU_AARCH64_CORTEX_R @@ -208,6 +228,7 @@ void z_arm64_el3_get_next_el(uint64_t switch_addr) /* Mask the DAIF */ spsr = SPSR_DAIF_MASK; +#ifndef CONFIG_USE_EL2 if (el3_get_next_el() == EL3_TO_EL2) { /* Dropping into EL2 */ spsr |= SPSR_MODE_EL2T; @@ -215,6 +236,9 @@ void z_arm64_el3_get_next_el(uint64_t switch_addr) /* Dropping into EL1 */ spsr |= SPSR_MODE_EL1T; } +#else + spsr |= SPSR_MODE_EL2T; +#endif write_spsr_el3(spsr); } diff --git a/arch/arm64/core/switch.S b/arch/arm64/core/switch.S index 333b8f0b21e..a436cfa1a3e 100644 --- a/arch/arm64/core/switch.S +++ b/arch/arm64/core/switch.S @@ -141,8 +141,15 @@ SECTION_FUNC(TEXT, z_arm64_context_switch) GTEXT(z_arm64_sync_exc) SECTION_FUNC(TEXT, z_arm64_sync_exc) +#ifndef CONFIG_USE_EL2 mrs x0, esr_el1 lsr x1, x0, #26 +#else + mrs x0, esr_el2 + lsr x1, x0, #26 +#endif + + #ifdef CONFIG_FPU_SHARING cmp x1, #0x07 /*Access to SIMD or floating-point */ diff --git a/arch/arm64/core/thread.c b/arch/arm64/core/thread.c index 18f49945eda..5a9c83a6e78 100644 --- a/arch/arm64/core/thread.c +++ b/arch/arm64/core/thread.c @@ -130,9 +130,13 @@ void arch_new_thread(struct k_thread *thread, k_thread_stack_t *stack, pInitCtx->elr = (uint64_t)z_thread_entry; #endif +#ifndef CONFIG_USE_EL2 /* Keep using SP_EL1 */ pInitCtx->spsr = SPSR_MODE_EL1H | DAIF_FIQ_BIT; - +#else + /* Keep using SP_EL1 */ + pInitCtx->spsr = SPSR_MODE_EL2H | DAIF_FIQ_BIT; +#endif /* thread birth happens through the exception return path */ thread->arch.exception_depth = 1; diff --git a/arch/arm64/core/vector_table.S b/arch/arm64/core/vector_table.S index 632304b7029..fa90c0eb6be 100644 --- a/arch/arm64/core/vector_table.S +++ b/arch/arm64/core/vector_table.S @@ -76,9 +76,15 @@ _ASM_FILE_PROLOGUE str x29, [sp, ___esf_t_fp_OFFSET] #endif +#ifndef CONFIG_USE_EL2 mrs \xreg0, spsr_el1 mrs \xreg1, elr_el1 stp \xreg0, \xreg1, [sp, ___esf_t_spsr_elr_OFFSET] +#else + mrs \xreg0, spsr_el2 + mrs \xreg1, elr_el2 + stp \xreg0, \xreg1, [sp, ___esf_t_spsr_elr_OFFSET] +#endif #ifdef CONFIG_ARM64_SAFE_EXCEPTION_STACK .if \el == el0 @@ -152,12 +158,20 @@ SECTION_SUBSEC_FUNC(exc_vector_table,_vector_table_section,_vector_table) /* Current EL with SP0 / Synchronous */ .align 7 +#ifndef CONFIG_USE_EL2 z_arm64_enter_exc x0, x1, el1 +#else + z_arm64_enter_exc x0, x1, el2 +#endif b z_arm64_sync_exc /* Current EL with SP0 / IRQ */ .align 7 +#ifndef CONFIG_USE_EL2 z_arm64_enter_exc x0, x1, el1 +#else + z_arm64_enter_exc x0, x1, el2 +#endif #ifdef CONFIG_GEN_SW_ISR_TABLE b _isr_wrapper #else @@ -170,17 +184,29 @@ SECTION_SUBSEC_FUNC(exc_vector_table,_vector_table_section,_vector_table) /* Current EL with SP0 / SError */ .align 7 +#ifndef CONFIG_USE_EL2 z_arm64_enter_exc x0, x1, el1 +#else + z_arm64_enter_exc x0, x1, el2 +#endif b z_arm64_serror /* Current EL with SPx / Synchronous */ .align 7 +#ifndef CONFIG_USE_EL2 z_arm64_enter_exc x0, x1, el1 +#else + z_arm64_enter_exc x0, x1, el2 +#endif b z_arm64_sync_exc /* Current EL with SPx / IRQ */ .align 7 +#ifndef CONFIG_USE_EL2 z_arm64_enter_exc x0, x1, el1 +#else + z_arm64_enter_exc x0, x1, el2 +#endif #ifdef CONFIG_GEN_SW_ISR_TABLE b _isr_wrapper #else @@ -193,7 +219,11 @@ SECTION_SUBSEC_FUNC(exc_vector_table,_vector_table_section,_vector_table) /* Current EL with SPx / SError */ .align 7 +#ifndef CONFIG_USE_EL2 z_arm64_enter_exc x0, x1, el1 +#else + z_arm64_enter_exc x0, x1, el2 +#endif b z_arm64_serror /* Lower EL using AArch64 / Synchronous */ @@ -309,8 +339,14 @@ SECTION_FUNC(TEXT, z_arm64_exit_exc) #endif ldp x0, x1, [sp, ___esf_t_spsr_elr_OFFSET] + +#ifndef CONFIG_USE_EL2 msr spsr_el1, x0 msr elr_el1, x1 +#else + msr spsr_el2, x0 + msr elr_el2, x1 +#endif /* Restore the kernel/user mode flag and decrement exception depth */ tst x0, #SPSR_MODE_MASK /* EL0 == 0 */ diff --git a/boards/deprecated.cmake b/boards/deprecated.cmake index f1a40a8b318..ae39096db03 100644 --- a/boards/deprecated.cmake +++ b/boards/deprecated.cmake @@ -902,3 +902,30 @@ set(xiao_esp32s3_DEPRECATED set(yd_esp32_DEPRECATED yd_esp32/esp32/procpu ) + +set(e2000d_demo_smp_DEPRECATED + e2000d_demo/e2000d/smp +) + +set(e2000d_demo_el2_DEPRECATED + e2000d_demo/e2000d/el2 +) + +set(e2000d_demo_el2_smp_DEPRECATED + e2000d_demo/e2000d/el2/smp +) + + +set(e2000q_demo_smp_DEPRECATED + e2000q_demo/e2000q/smp +) + +set(e2000q_demo_el2_DEPRECATED + e2000q_demo/e2000q/el2 +) + +set(e2000q_demo_el2_smp_DEPRECATED + e2000q_demo/e2000q/el2/smp +) + + diff --git a/boards/phytium/d2000_demo/Kconfig.d2000_demo b/boards/phytium/d2000_demo/Kconfig.d2000_demo deleted file mode 100644 index e11315682ce..00000000000 --- a/boards/phytium/d2000_demo/Kconfig.d2000_demo +++ /dev/null @@ -1,18 +0,0 @@ -# Phytium is pleased to support the open source community by making Zephyr-SDK available. - -# -# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. -# -# Licensed under the Apache-2.0 License (the "License"); you may not use this file except -# in compliance with the License. You may obtain a copy of the License at -# -# https://opensource.org/license/apache-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. - -config BOARD_D2000_DEMO - bool "phytium d2000" - select SOC_D2000 diff --git a/boards/phytium/d2000_demo/Kconfig.defconfig b/boards/phytium/d2000_demo/Kconfig.defconfig deleted file mode 100644 index cb024a29c37..00000000000 --- a/boards/phytium/d2000_demo/Kconfig.defconfig +++ /dev/null @@ -1,19 +0,0 @@ -# Phytium is pleased to support the open source community by making Zephyr-SDK available. - -# -# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. -# -# Licensed under the Apache-2.0 License (the "License"); you may not use this file except -# in compliance with the License. You may obtain a copy of the License at -# -# https://opensource.org/license/apache-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. - - -config BOARD - default "Phytium d2000 demo" - depends on BOARD_D2000_DEMO diff --git a/boards/phytium/d2000_demo/board.cmake b/boards/phytium/d2000_demo/board.cmake deleted file mode 100644 index 9881313609a..00000000000 --- a/boards/phytium/d2000_demo/board.cmake +++ /dev/null @@ -1 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 diff --git a/boards/phytium/d2000_demo/board.yml b/boards/phytium/d2000_demo/board.yml deleted file mode 100644 index 82b49d204cd..00000000000 --- a/boards/phytium/d2000_demo/board.yml +++ /dev/null @@ -1,5 +0,0 @@ -board: - name: d2000_demo - vendor: arm64 - socs: - - name: phytium_d2000 \ No newline at end of file diff --git a/boards/phytium/d2000_demo_smp/Kconfig.d2000_demo_smp b/boards/phytium/d2000_demo_smp/Kconfig.d2000_demo_smp deleted file mode 100644 index 271c7362ca8..00000000000 --- a/boards/phytium/d2000_demo_smp/Kconfig.d2000_demo_smp +++ /dev/null @@ -1,18 +0,0 @@ -# Phytium is pleased to support the open source community by making Zephyr-SDK available. - -# -# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. -# -# Licensed under the Apache-2.0 License (the "License"); you may not use this file except -# in compliance with the License. You may obtain a copy of the License at -# -# https://opensource.org/license/apache-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. - -config BOARD_D2000_DEMO_SMP - bool "phytium d2000" - select SOC_D2000 diff --git a/boards/phytium/d2000_demo_smp/Kconfig.defconfig b/boards/phytium/d2000_demo_smp/Kconfig.defconfig deleted file mode 100644 index f42f153b533..00000000000 --- a/boards/phytium/d2000_demo_smp/Kconfig.defconfig +++ /dev/null @@ -1,19 +0,0 @@ -# Phytium is pleased to support the open source community by making Zephyr-SDK available. - -# -# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. -# -# Licensed under the Apache-2.0 License (the "License"); you may not use this file except -# in compliance with the License. You may obtain a copy of the License at -# -# https://opensource.org/license/apache-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. - - -config BOARD - default "Phytium d2000 demo" - depends on BOARD_D2000_DEMO_SMP diff --git a/boards/phytium/d2000_demo_smp/board.cmake b/boards/phytium/d2000_demo_smp/board.cmake deleted file mode 100644 index 9881313609a..00000000000 --- a/boards/phytium/d2000_demo_smp/board.cmake +++ /dev/null @@ -1 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 diff --git a/boards/phytium/d2000_demo_smp/board.yml b/boards/phytium/d2000_demo_smp/board.yml deleted file mode 100644 index 9029c67e04a..00000000000 --- a/boards/phytium/d2000_demo_smp/board.yml +++ /dev/null @@ -1,5 +0,0 @@ -board: - name: d2000_demo_smp - vendor: arm64 - socs: - - name: phytium_d2000 \ No newline at end of file diff --git a/boards/phytium/d2000_demo_smp/d2000_demo_smp_defconfig b/boards/phytium/d2000_demo_smp/d2000_demo_smp_defconfig deleted file mode 100644 index 2896228ec7e..00000000000 --- a/boards/phytium/d2000_demo_smp/d2000_demo_smp_defconfig +++ /dev/null @@ -1,41 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 - -# Platform Configuration -CONFIG_ARM64_VA_BITS_42=y -CONFIG_ARM64_PA_BITS_42=y -# Main stack size -CONFIG_MAIN_STACK_SIZE=4096 - -CONFIG_ARMV8_A_NS=y - -# Zephyr Kernel Configuration -CONFIG_XIP=n -CONFIG_FLASH_SIZE=0 -CONFIG_FLASH_BASE_ADDRESS=0x0 - -# Serial Drivers -CONFIG_SERIAL=y - -# Enable Console -CONFIG_CONSOLE=y -CONFIG_UART_CONSOLE=y - -#cache -CONFIG_CACHE_MANAGEMENT=y - -# Timer Drivers -CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME=y - -# PSCI is supported with NS -CONFIG_PM_CPU_OPS=y -CONFIG_PM_CPU_OPS_PSCI=y - -# SMP-related -CONFIG_SMP=y -CONFIG_MP_MAX_NUM_CPUS=8 -CONFIG_TIMEOUT_64BIT=y - -# CONFIG_SHELL=y -# CONFIG_SHELL_BACKEND_SERIAL_INTERRUPT_DRIVEN=n -# CONFIG_SHELL_BACKEND_SERIAL_RX_POLL_PERIOD=1 -# CONFIG_BOOT_BANNER=n diff --git a/boards/phytium/d3000_demo/Kconfig.d3000_demo b/boards/phytium/d3000_demo/Kconfig.d3000_demo deleted file mode 100644 index 2d00a9c69e5..00000000000 --- a/boards/phytium/d3000_demo/Kconfig.d3000_demo +++ /dev/null @@ -1,18 +0,0 @@ -# Phytium is pleased to support the open source community by making Zephyr-SDK available. - -# -# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. -# -# Licensed under the Apache-2.0 License (the "License"); you may not use this file except -# in compliance with the License. You may obtain a copy of the License at -# -# https://opensource.org/license/apache-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. - -config BOARD_D3000_DEMO - bool "phytium d3000" - select SOC_D3000 diff --git a/boards/phytium/d3000_demo/Kconfig.defconfig b/boards/phytium/d3000_demo/Kconfig.defconfig deleted file mode 100644 index 96f810154c3..00000000000 --- a/boards/phytium/d3000_demo/Kconfig.defconfig +++ /dev/null @@ -1,19 +0,0 @@ -# Phytium is pleased to support the open source community by making Zephyr-SDK available. - -# -# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. -# -# Licensed under the Apache-2.0 License (the "License"); you may not use this file except -# in compliance with the License. You may obtain a copy of the License at -# -# https://opensource.org/license/apache-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. - - -config BOARD - default "Phytium d3000 demo" - depends on BOARD_D3000_DEMO diff --git a/boards/phytium/d3000_demo/board.cmake b/boards/phytium/d3000_demo/board.cmake deleted file mode 100644 index 9881313609a..00000000000 --- a/boards/phytium/d3000_demo/board.cmake +++ /dev/null @@ -1 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 diff --git a/boards/phytium/d3000_demo/board.yml b/boards/phytium/d3000_demo/board.yml deleted file mode 100644 index dcde87d08c2..00000000000 --- a/boards/phytium/d3000_demo/board.yml +++ /dev/null @@ -1,5 +0,0 @@ -board: - name: d3000_demo - vendor: arm64 - socs: - - name: phytium_d3000 \ No newline at end of file diff --git a/boards/phytium/d3000_demo_smp/Kconfig.d3000_demo_smp b/boards/phytium/d3000_demo_smp/Kconfig.d3000_demo_smp deleted file mode 100644 index 7544f39d609..00000000000 --- a/boards/phytium/d3000_demo_smp/Kconfig.d3000_demo_smp +++ /dev/null @@ -1,18 +0,0 @@ -# Phytium is pleased to support the open source community by making Zephyr-SDK available. - -# -# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. -# -# Licensed under the Apache-2.0 License (the "License"); you may not use this file except -# in compliance with the License. You may obtain a copy of the License at -# -# https://opensource.org/license/apache-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. - -config BOARD_D3000_DEMO_SMP - bool "phytium d3000" - select SOC_D3000 diff --git a/boards/phytium/d3000_demo_smp/Kconfig.defconfig b/boards/phytium/d3000_demo_smp/Kconfig.defconfig deleted file mode 100644 index 8d30845b111..00000000000 --- a/boards/phytium/d3000_demo_smp/Kconfig.defconfig +++ /dev/null @@ -1,19 +0,0 @@ -# Phytium is pleased to support the open source community by making Zephyr-SDK available. - -# -# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. -# -# Licensed under the Apache-2.0 License (the "License"); you may not use this file except -# in compliance with the License. You may obtain a copy of the License at -# -# https://opensource.org/license/apache-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. - - -config BOARD - default "Phytium d3000 demo" - depends on BOARD_D3000_DEMO_SMP diff --git a/boards/phytium/d3000_demo_smp/board.cmake b/boards/phytium/d3000_demo_smp/board.cmake deleted file mode 100644 index 9881313609a..00000000000 --- a/boards/phytium/d3000_demo_smp/board.cmake +++ /dev/null @@ -1 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 diff --git a/boards/phytium/d3000_demo_smp/board.yml b/boards/phytium/d3000_demo_smp/board.yml deleted file mode 100644 index 8124178fd98..00000000000 --- a/boards/phytium/d3000_demo_smp/board.yml +++ /dev/null @@ -1,5 +0,0 @@ -board: - name: d3000_demo_smp - vendor: arm64 - socs: - - name: phytium_d3000 \ No newline at end of file diff --git a/boards/phytium/d3000_demo_smp/d3000_demo_smp.yaml b/boards/phytium/d3000_demo_smp/d3000_demo_smp.yaml deleted file mode 100644 index a96439bbb3c..00000000000 --- a/boards/phytium/d3000_demo_smp/d3000_demo_smp.yaml +++ /dev/null @@ -1,10 +0,0 @@ - -identifier: d3000_demo -name: Phytium d3000 demo -type: mcu -arch: arm64 -toolchain: - - zephyr - - cross-compile -supported: - - smp diff --git a/boards/phytium/e2000d_demo/board.yml b/boards/phytium/e2000d_demo/board.yml index 70e7234f0a0..c2e60a89b35 100644 --- a/boards/phytium/e2000d_demo/board.yml +++ b/boards/phytium/e2000d_demo/board.yml @@ -1,5 +1,12 @@ board: name: e2000d_demo - vendor: arm64 + vendor: phytium socs: - - name: phytium_e2000d \ No newline at end of file + - name: e2000d + variants: + - name: smp + - name: el2 + variants: + - name: smp + + diff --git a/boards/phytium/e2000d_demo_smp/e2000d_demo_smp.dts b/boards/phytium/e2000d_demo/e2000d_demo_e2000d_el2_smp.dts similarity index 100% rename from boards/phytium/e2000d_demo_smp/e2000d_demo_smp.dts rename to boards/phytium/e2000d_demo/e2000d_demo_e2000d_el2_smp.dts diff --git a/boards/phytium/e2000d_demo_smp/e2000d_demo_smp.yaml b/boards/phytium/e2000d_demo/e2000d_demo_e2000d_el2_smp.yaml similarity index 93% rename from boards/phytium/e2000d_demo_smp/e2000d_demo_smp.yaml rename to boards/phytium/e2000d_demo/e2000d_demo_e2000d_el2_smp.yaml index 5f42073f919..2a04357ff9d 100644 --- a/boards/phytium/e2000d_demo_smp/e2000d_demo_smp.yaml +++ b/boards/phytium/e2000d_demo/e2000d_demo_e2000d_el2_smp.yaml @@ -6,4 +6,4 @@ toolchain: - zephyr - cross-compile supported: - - smp \ No newline at end of file + - smp diff --git a/boards/phytium/d3000_demo_smp/d3000_demo_smp_defconfig b/boards/phytium/e2000d_demo/e2000d_demo_e2000d_el2_smp_defconfig similarity index 93% rename from boards/phytium/d3000_demo_smp/d3000_demo_smp_defconfig rename to boards/phytium/e2000d_demo/e2000d_demo_e2000d_el2_smp_defconfig index 2896228ec7e..caa1af3329f 100644 --- a/boards/phytium/d3000_demo_smp/d3000_demo_smp_defconfig +++ b/boards/phytium/e2000d_demo/e2000d_demo_e2000d_el2_smp_defconfig @@ -32,10 +32,13 @@ CONFIG_PM_CPU_OPS_PSCI=y # SMP-related CONFIG_SMP=y -CONFIG_MP_MAX_NUM_CPUS=8 +CONFIG_MP_MAX_NUM_CPUS=2 CONFIG_TIMEOUT_64BIT=y # CONFIG_SHELL=y # CONFIG_SHELL_BACKEND_SERIAL_INTERRUPT_DRIVEN=n # CONFIG_SHELL_BACKEND_SERIAL_RX_POLL_PERIOD=1 # CONFIG_BOOT_BANNER=n + +# EL2 +CONFIG_USE_EL2=y diff --git a/boards/phytium/d2000_demo_smp/d2000_demo_smp.dts b/boards/phytium/e2000d_demo/e2000d_demo_e2000d_smp.dts similarity index 60% rename from boards/phytium/d2000_demo_smp/d2000_demo_smp.dts rename to boards/phytium/e2000d_demo/e2000d_demo_e2000d_smp.dts index c679cdd7269..cb2792a2427 100644 --- a/boards/phytium/d2000_demo_smp/d2000_demo_smp.dts +++ b/boards/phytium/e2000d_demo/e2000d_demo_e2000d_smp.dts @@ -6,10 +6,10 @@ /dts-v1/; -#include +#include / { - model = "Phytium d2000 demo"; - compatible = "phytium,d2000-demo", "phytium,d2000"; + model = "Phytium e2000d demo"; + compatible = "phytium,e2000d-demo", "phytium,e2000d"; #address-cells = <2>; #size-cells = <2>; @@ -25,6 +25,14 @@ chosen { }; }; +&sdhc1 { + status = "okay"; + sdmmc { + compatible = "zephyr,sdmmc-disk"; + status = "okay"; + }; +}; + &uart1 { status = "okay"; current-speed = <115200>; @@ -35,3 +43,7 @@ chosen { current-speed = <115200>; }; +&xmac0 { + status = "okay"; + local-mac-address = [00 00 00 01 02 03]; +}; diff --git a/boards/phytium/d3000_demo/d3000_demo.yaml b/boards/phytium/e2000d_demo/e2000d_demo_e2000d_smp.yaml similarity index 61% rename from boards/phytium/d3000_demo/d3000_demo.yaml rename to boards/phytium/e2000d_demo/e2000d_demo_e2000d_smp.yaml index a96439bbb3c..2a04357ff9d 100644 --- a/boards/phytium/d3000_demo/d3000_demo.yaml +++ b/boards/phytium/e2000d_demo/e2000d_demo_e2000d_smp.yaml @@ -1,6 +1,5 @@ - -identifier: d3000_demo -name: Phytium d3000 demo +identifier: e2000d_demo +name: Phytium e2000d demo type: mcu arch: arm64 toolchain: diff --git a/boards/phytium/e2000d_demo_smp/e2000d_demo_smp_defconfig b/boards/phytium/e2000d_demo/e2000d_demo_e2000d_smp_defconfig similarity index 99% rename from boards/phytium/e2000d_demo_smp/e2000d_demo_smp_defconfig rename to boards/phytium/e2000d_demo/e2000d_demo_e2000d_smp_defconfig index 513ffeac72f..50ea07918d6 100644 --- a/boards/phytium/e2000d_demo_smp/e2000d_demo_smp_defconfig +++ b/boards/phytium/e2000d_demo/e2000d_demo_e2000d_smp_defconfig @@ -39,3 +39,4 @@ CONFIG_TIMEOUT_64BIT=y # CONFIG_SHELL_BACKEND_SERIAL_INTERRUPT_DRIVEN=n # CONFIG_SHELL_BACKEND_SERIAL_RX_POLL_PERIOD=1 # CONFIG_BOOT_BANNER=n + diff --git a/boards/phytium/d2000_demo/d2000_demo.dts b/boards/phytium/e2000d_demo/e2000d_demo_el2.dts similarity index 56% rename from boards/phytium/d2000_demo/d2000_demo.dts rename to boards/phytium/e2000d_demo/e2000d_demo_el2.dts index bb59f288f27..9ea6c9be8b0 100644 --- a/boards/phytium/d2000_demo/d2000_demo.dts +++ b/boards/phytium/e2000d_demo/e2000d_demo_el2.dts @@ -5,11 +5,11 @@ */ /dts-v1/; -#include +#include / { - model = "Phytium d2000 demo"; - compatible = "phytium,d2000-demo", "phytium,d2000"; + model = "Phytium e2000d demo"; + compatible = "phytium,e2000d-demo", "phytium,e2000d"; #address-cells = <2>; #size-cells = <2>; @@ -20,6 +20,19 @@ chosen { }; }; +&sdhc1 { + status = "okay"; + sdmmc { + compatible = "zephyr,sdmmc-disk"; + status = "okay"; + }; +}; + +&xmac0 { + status = "okay"; + local-mac-address = [00 00 00 01 02 03]; +}; + &uart1 { current-speed = <115200>; status = "okay"; @@ -28,4 +41,4 @@ chosen { &uart2 { current-speed = <115200>; status = "okay"; -}; +}; \ No newline at end of file diff --git a/boards/phytium/d2000_demo_smp/d2000_demo_smp.yaml b/boards/phytium/e2000d_demo/e2000d_demo_el2.yaml similarity index 48% rename from boards/phytium/d2000_demo_smp/d2000_demo_smp.yaml rename to boards/phytium/e2000d_demo/e2000d_demo_el2.yaml index 5f7d415126b..87ca6dcdb61 100644 --- a/boards/phytium/d2000_demo_smp/d2000_demo_smp.yaml +++ b/boards/phytium/e2000d_demo/e2000d_demo_el2.yaml @@ -1,9 +1,7 @@ -identifier: d2000_demo -name: Phytium d2000 demo +identifier: e2000d_demo/e2000d/el2 +name: Phytium e2000d demo type: mcu arch: arm64 toolchain: - zephyr - cross-compile -supported: - - smp \ No newline at end of file diff --git a/boards/phytium/d3000_demo/d3000_demo_defconfig b/boards/phytium/e2000d_demo/e2000d_demo_el2_defconfig similarity index 90% rename from boards/phytium/d3000_demo/d3000_demo_defconfig rename to boards/phytium/e2000d_demo/e2000d_demo_el2_defconfig index f816f41440e..4962f631bdd 100644 --- a/boards/phytium/d3000_demo/d3000_demo_defconfig +++ b/boards/phytium/e2000d_demo/e2000d_demo_el2_defconfig @@ -4,7 +4,7 @@ CONFIG_ARM64_VA_BITS_42=y CONFIG_ARM64_PA_BITS_42=y # Main stack size -CONFIG_MAIN_STACK_SIZE=8192 +CONFIG_MAIN_STACK_SIZE=4096 CONFIG_ARMV8_A_NS=y @@ -31,3 +31,6 @@ CONFIG_CACHE_MANAGEMENT=y # PSCI is supported with NS CONFIG_PM_CPU_OPS=y CONFIG_PM_CPU_OPS_PSCI=y + +# el2 +CONFIG_USE_EL2=y diff --git a/boards/phytium/e2000d_demo_smp/Kconfig.defconfig b/boards/phytium/e2000d_demo_smp/Kconfig.defconfig deleted file mode 100644 index cb4e5d602ed..00000000000 --- a/boards/phytium/e2000d_demo_smp/Kconfig.defconfig +++ /dev/null @@ -1,19 +0,0 @@ -# Phytium is pleased to support the open source community by making Zephyr-SDK available. - -# -# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. -# -# Licensed under the Apache-2.0 License (the "License"); you may not use this file except -# in compliance with the License. You may obtain a copy of the License at -# -# https://opensource.org/license/apache-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. - - -config BOARD - default "Phytium e2000d demo" - depends on BOARD_E2000D_DEMO_SMP diff --git a/boards/phytium/e2000d_demo_smp/Kconfig.e2000d_demo_smp b/boards/phytium/e2000d_demo_smp/Kconfig.e2000d_demo_smp deleted file mode 100644 index cf9a2620c37..00000000000 --- a/boards/phytium/e2000d_demo_smp/Kconfig.e2000d_demo_smp +++ /dev/null @@ -1,18 +0,0 @@ -# Phytium is pleased to support the open source community by making Zephyr-SDK available. - -# -# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. -# -# Licensed under the Apache-2.0 License (the "License"); you may not use this file except -# in compliance with the License. You may obtain a copy of the License at -# -# https://opensource.org/license/apache-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. - -config BOARD_E2000D_DEMO_SMP - bool "phytium e2000d" - select SOC_E2000D diff --git a/boards/phytium/e2000d_demo_smp/board.cmake b/boards/phytium/e2000d_demo_smp/board.cmake deleted file mode 100644 index 9881313609a..00000000000 --- a/boards/phytium/e2000d_demo_smp/board.cmake +++ /dev/null @@ -1 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 diff --git a/boards/phytium/e2000d_demo_smp/board.yml b/boards/phytium/e2000d_demo_smp/board.yml deleted file mode 100644 index b29aeb83054..00000000000 --- a/boards/phytium/e2000d_demo_smp/board.yml +++ /dev/null @@ -1,5 +0,0 @@ -board: - name: e2000d_demo_smp - vendor: arm64 - socs: - - name: phytium_e2000d \ No newline at end of file diff --git a/boards/phytium/e2000q_demo/board.yml b/boards/phytium/e2000q_demo/board.yml index 9f5a0cb0baa..2156ebade2e 100644 --- a/boards/phytium/e2000q_demo/board.yml +++ b/boards/phytium/e2000q_demo/board.yml @@ -1,5 +1,10 @@ board: name: e2000q_demo - vendor: arm64 + vendor: phytium socs: - - name: phytium_e2000q \ No newline at end of file + - name: e2000q + variants: + - name: smp + - name: el2 + variants: + - name: smp diff --git a/boards/phytium/d3000_demo/d3000_demo.dts b/boards/phytium/e2000q_demo/e2000q_demo_e2000q_el2.dts similarity index 34% rename from boards/phytium/d3000_demo/d3000_demo.dts rename to boards/phytium/e2000q_demo/e2000q_demo_e2000q_el2.dts index 9e367314f12..50dfaa539bc 100644 --- a/boards/phytium/d3000_demo/d3000_demo.dts +++ b/boards/phytium/e2000q_demo/e2000q_demo_e2000q_el2.dts @@ -5,11 +5,12 @@ */ /dts-v1/; -#include +#include +#include "e2000q_pinctrl.dtsi" / { - model = "Phytium d3000 demo"; - compatible = "phytium,d3000-demo", "phytium,d3000"; + model = "Phytium e2000q demo"; + compatible = "phytium,e2000q-demo", "phytium,e2000q"; #address-cells = <2>; #size-cells = <2>; @@ -17,11 +18,37 @@ chosen { zephyr,console = &uart1; zephyr,shell-uart = &uart1; zephyr,sram = &sram0; + zephyr,pcie-controller = &pcie0; }; }; +&sdhc1 { + status = "okay"; + sdmmc { + compatible = "zephyr,sdmmc-disk"; + status = "okay"; + }; +}; + +&xmac0 { + status = "okay"; + local-mac-address = [00 00 00 01 02 03]; +}; + &uart1 { current-speed = <115200>; + pinctrl-0 = <&uart1_rx_default &uart1_tx_default>; + pinctrl-names = "default"; status = "okay"; }; +&uart2 { + current-speed = <115200>; + pinctrl-0 = <&uart2_rx_default &uart2_tx_default>; + pinctrl-names = "default"; + status = "okay"; +}; + +&pcie0 { + status = "okay"; +}; diff --git a/boards/phytium/d2000_demo/d2000_demo.yaml b/boards/phytium/e2000q_demo/e2000q_demo_e2000q_el2.yaml similarity index 54% rename from boards/phytium/d2000_demo/d2000_demo.yaml rename to boards/phytium/e2000q_demo/e2000q_demo_e2000q_el2.yaml index 88ef06e759f..ac20226602a 100644 --- a/boards/phytium/d2000_demo/d2000_demo.yaml +++ b/boards/phytium/e2000q_demo/e2000q_demo_e2000q_el2.yaml @@ -1,5 +1,5 @@ -identifier: d2000_demo -name: Phytium d2000 demo +identifier: e2000q_demo/ +name: Phytium e2000q demo type: mcu arch: arm64 toolchain: diff --git a/boards/phytium/d2000_demo/d2000_demo_defconfig b/boards/phytium/e2000q_demo/e2000q_demo_e2000q_el2_defconfig similarity index 90% rename from boards/phytium/d2000_demo/d2000_demo_defconfig rename to boards/phytium/e2000q_demo/e2000q_demo_e2000q_el2_defconfig index f816f41440e..0d19db0fb29 100644 --- a/boards/phytium/d2000_demo/d2000_demo_defconfig +++ b/boards/phytium/e2000q_demo/e2000q_demo_e2000q_el2_defconfig @@ -4,7 +4,7 @@ CONFIG_ARM64_VA_BITS_42=y CONFIG_ARM64_PA_BITS_42=y # Main stack size -CONFIG_MAIN_STACK_SIZE=8192 +CONFIG_MAIN_STACK_SIZE=4096 CONFIG_ARMV8_A_NS=y @@ -31,3 +31,6 @@ CONFIG_CACHE_MANAGEMENT=y # PSCI is supported with NS CONFIG_PM_CPU_OPS=y CONFIG_PM_CPU_OPS_PSCI=y + +# EL2 +CONFIG_USE_EL2=y diff --git a/boards/phytium/e2000q_demo_smp/e2000q_demo_smp.dts b/boards/phytium/e2000q_demo/e2000q_demo_e2000q_el2_smp.dts similarity index 100% rename from boards/phytium/e2000q_demo_smp/e2000q_demo_smp.dts rename to boards/phytium/e2000q_demo/e2000q_demo_e2000q_el2_smp.dts diff --git a/boards/phytium/e2000q_demo_smp/e2000q_demo_smp.yaml b/boards/phytium/e2000q_demo/e2000q_demo_e2000q_el2_smp.yaml similarity index 69% rename from boards/phytium/e2000q_demo_smp/e2000q_demo_smp.yaml rename to boards/phytium/e2000q_demo/e2000q_demo_e2000q_el2_smp.yaml index c3562a9b4c4..4b9ff667a37 100644 --- a/boards/phytium/e2000q_demo_smp/e2000q_demo_smp.yaml +++ b/boards/phytium/e2000q_demo/e2000q_demo_e2000q_el2_smp.yaml @@ -1,4 +1,4 @@ -identifier: e2000q_demo +identifier: e2000q_demo/e2000q/smp name: Phytium e2000q demo type: mcu arch: arm64 @@ -6,4 +6,4 @@ toolchain: - zephyr - cross-compile supported: - - smp \ No newline at end of file + - smp diff --git a/boards/phytium/s5000c_testb_smp/s5000c_testb_smp_defconfig b/boards/phytium/e2000q_demo/e2000q_demo_e2000q_el2_smp_defconfig similarity index 93% rename from boards/phytium/s5000c_testb_smp/s5000c_testb_smp_defconfig rename to boards/phytium/e2000q_demo/e2000q_demo_e2000q_el2_smp_defconfig index 2896228ec7e..c03c4c25d26 100644 --- a/boards/phytium/s5000c_testb_smp/s5000c_testb_smp_defconfig +++ b/boards/phytium/e2000q_demo/e2000q_demo_e2000q_el2_smp_defconfig @@ -32,10 +32,13 @@ CONFIG_PM_CPU_OPS_PSCI=y # SMP-related CONFIG_SMP=y -CONFIG_MP_MAX_NUM_CPUS=8 +CONFIG_MP_MAX_NUM_CPUS=4 CONFIG_TIMEOUT_64BIT=y # CONFIG_SHELL=y # CONFIG_SHELL_BACKEND_SERIAL_INTERRUPT_DRIVEN=n # CONFIG_SHELL_BACKEND_SERIAL_RX_POLL_PERIOD=1 # CONFIG_BOOT_BANNER=n + +# EL2 +CONFIG_USE_EL2=y diff --git a/boards/phytium/d3000_demo_smp/d3000_demo_smp.dts b/boards/phytium/e2000q_demo/e2000q_demo_e2000q_smp.dts similarity index 52% rename from boards/phytium/d3000_demo_smp/d3000_demo_smp.dts rename to boards/phytium/e2000q_demo/e2000q_demo_e2000q_smp.dts index fa1b9bb2cec..fff1f97392a 100644 --- a/boards/phytium/d3000_demo_smp/d3000_demo_smp.dts +++ b/boards/phytium/e2000q_demo/e2000q_demo_e2000q_smp.dts @@ -6,10 +6,10 @@ /dts-v1/; -#include +#include / { - model = "Phytium d3000 demo"; - compatible = "phytium,d3000-demo", "phytium,d3000"; + model = "Phytium e2000q demo"; + compatible = "phytium,e2000q-demo", "phytium,e2000q"; #address-cells = <2>; #size-cells = <2>; @@ -25,8 +25,25 @@ chosen { }; }; +&sdhc1 { + status = "okay"; + sdmmc { + compatible = "zephyr,sdmmc-disk"; + status = "okay"; + }; +}; + &uart1 { status = "okay"; current-speed = <115200>; }; +&uart2 { + status = "okay"; + current-speed = <115200>; +}; + +&xmac0 { + status = "okay"; + local-mac-address = [00 00 00 01 02 03]; +}; diff --git a/boards/phytium/s5000c_testb/s5000c_testb.yaml b/boards/phytium/e2000q_demo/e2000q_demo_e2000q_smp.yaml similarity index 57% rename from boards/phytium/s5000c_testb/s5000c_testb.yaml rename to boards/phytium/e2000q_demo/e2000q_demo_e2000q_smp.yaml index 13359566554..4b9ff667a37 100644 --- a/boards/phytium/s5000c_testb/s5000c_testb.yaml +++ b/boards/phytium/e2000q_demo/e2000q_demo_e2000q_smp.yaml @@ -1,6 +1,5 @@ - -identifier: s5000c_testb -name: Phytium s5000c testb +identifier: e2000q_demo/e2000q/smp +name: Phytium e2000q demo type: mcu arch: arm64 toolchain: diff --git a/boards/phytium/e2000q_demo_smp/e2000q_demo_smp_defconfig b/boards/phytium/e2000q_demo/e2000q_demo_e2000q_smp_defconfig similarity index 100% rename from boards/phytium/e2000q_demo_smp/e2000q_demo_smp_defconfig rename to boards/phytium/e2000q_demo/e2000q_demo_e2000q_smp_defconfig diff --git a/boards/phytium/e2000q_demo_smp/Kconfig.defconfig b/boards/phytium/e2000q_demo_smp/Kconfig.defconfig deleted file mode 100644 index 5d80fa7868f..00000000000 --- a/boards/phytium/e2000q_demo_smp/Kconfig.defconfig +++ /dev/null @@ -1,19 +0,0 @@ -# Phytium is pleased to support the open source community by making Zephyr-SDK available. - -# -# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. -# -# Licensed under the Apache-2.0 License (the "License"); you may not use this file except -# in compliance with the License. You may obtain a copy of the License at -# -# https://opensource.org/license/apache-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. - - -config BOARD - default "Phytium e2000q demo" - depends on BOARD_E2000Q_DEMO_SMP diff --git a/boards/phytium/e2000q_demo_smp/Kconfig.e2000q_demo_smp b/boards/phytium/e2000q_demo_smp/Kconfig.e2000q_demo_smp deleted file mode 100644 index 13ef5e49ed7..00000000000 --- a/boards/phytium/e2000q_demo_smp/Kconfig.e2000q_demo_smp +++ /dev/null @@ -1,18 +0,0 @@ -# Phytium is pleased to support the open source community by making Zephyr-SDK available. - -# -# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. -# -# Licensed under the Apache-2.0 License (the "License"); you may not use this file except -# in compliance with the License. You may obtain a copy of the License at -# -# https://opensource.org/license/apache-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. - -config BOARD_E2000Q_DEMO_SMP - bool "phytium e2000q" - select SOC_E2000Q diff --git a/boards/phytium/e2000q_demo_smp/board.cmake b/boards/phytium/e2000q_demo_smp/board.cmake deleted file mode 100644 index 9881313609a..00000000000 --- a/boards/phytium/e2000q_demo_smp/board.cmake +++ /dev/null @@ -1 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 diff --git a/boards/phytium/e2000q_demo_smp/board.yml b/boards/phytium/e2000q_demo_smp/board.yml deleted file mode 100644 index 664d0cffa3e..00000000000 --- a/boards/phytium/e2000q_demo_smp/board.yml +++ /dev/null @@ -1,5 +0,0 @@ -board: - name: e2000q_demo_smp - vendor: arm64 - socs: - - name: phytium_e2000q \ No newline at end of file diff --git a/boards/phytium/s5000c_testb/Kconfig.defconfig b/boards/phytium/s5000c_testb/Kconfig.defconfig deleted file mode 100644 index 754f09e2b9f..00000000000 --- a/boards/phytium/s5000c_testb/Kconfig.defconfig +++ /dev/null @@ -1,30 +0,0 @@ -# Phytium is pleased to support the open source community by making Zephyr-SDK available. - -# -# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. -# -# Licensed under the Apache-2.0 License (the "License"); you may not use this file except -# in compliance with the License. You may obtain a copy of the License at -# -# https://opensource.org/license/apache-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. - - -config BOARD - default "Phytium S5000C testb" - depends on BOARD_S5000C_TESTB - - - -if NETWORKING - -config NET_L2_ETHERNET - default y - - - -endif # NETWORKING diff --git a/boards/phytium/s5000c_testb/Kconfig.s5000c_testb b/boards/phytium/s5000c_testb/Kconfig.s5000c_testb deleted file mode 100644 index 9686b07d2b7..00000000000 --- a/boards/phytium/s5000c_testb/Kconfig.s5000c_testb +++ /dev/null @@ -1,18 +0,0 @@ -# Phytium is pleased to support the open source community by making Zephyr-SDK available. - -# -# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. -# -# Licensed under the Apache-2.0 License (the "License"); you may not use this file except -# in compliance with the License. You may obtain a copy of the License at -# -# https://opensource.org/license/apache-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. - -config BOARD_S5000C_TESTB - bool "phytium S5000C" - select SOC_S5000C diff --git a/boards/phytium/s5000c_testb/board.cmake b/boards/phytium/s5000c_testb/board.cmake deleted file mode 100644 index 9881313609a..00000000000 --- a/boards/phytium/s5000c_testb/board.cmake +++ /dev/null @@ -1 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 diff --git a/boards/phytium/s5000c_testb/board.yml b/boards/phytium/s5000c_testb/board.yml deleted file mode 100644 index 7247dae857a..00000000000 --- a/boards/phytium/s5000c_testb/board.yml +++ /dev/null @@ -1,5 +0,0 @@ -board: - name: s5000c_testb - vendor: arm64 - socs: - - name: phytium_s5000c \ No newline at end of file diff --git a/boards/phytium/s5000c_testb/s5000c_testb.dts b/boards/phytium/s5000c_testb/s5000c_testb.dts deleted file mode 100644 index 9d7ceda7549..00000000000 --- a/boards/phytium/s5000c_testb/s5000c_testb.dts +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2023 honglin leng - * - * SPDX-License-Identifier: Apache-2.0 - */ - -/dts-v1/; - -#include -/ { - model = "Phytium s5000c testb"; - compatible = "phytium,s5000c-testb", "phytium,s5000c"; - #address-cells = <2>; - #size-cells = <2>; - - psci { - compatible = "arm,psci-0.2"; - method = "smc"; - label = "PSCI"; - }; - -chosen { - zephyr,console = &uart1; - zephyr,shell-uart = &uart1; - zephyr,sram = &sram0; - }; -}; - -// &sdhc1 { -// status = "okay"; -// sdmmc { -// compatible = "zephyr,sdmmc-disk"; -// status = "okay"; -// }; -// }; - -&uart1 { - status = "okay"; - current-speed = <115200>; -}; - -// &uart2 { -// status = "okay"; -// current-speed = <115200>; -// }; - -// &xmac0 { -// status = "okay"; -// local-mac-address = [00 00 00 01 02 03]; -// }; diff --git a/boards/phytium/s5000c_testb/s5000c_testb_defconfig b/boards/phytium/s5000c_testb/s5000c_testb_defconfig deleted file mode 100644 index f816f41440e..00000000000 --- a/boards/phytium/s5000c_testb/s5000c_testb_defconfig +++ /dev/null @@ -1,33 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 - -# Platform Configuration -CONFIG_ARM64_VA_BITS_42=y -CONFIG_ARM64_PA_BITS_42=y -# Main stack size -CONFIG_MAIN_STACK_SIZE=8192 - -CONFIG_ARMV8_A_NS=y - -# Zephyr Kernel Configuration -CONFIG_XIP=n -CONFIG_FLASH_SIZE=0 -CONFIG_FLASH_BASE_ADDRESS=0x0 - -# Serial Drivers -CONFIG_SERIAL=y - -# Enable Console -CONFIG_CONSOLE=y -CONFIG_UART_CONSOLE=y - - -# Timer Drivers -CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME=y - - -#cache -CONFIG_CACHE_MANAGEMENT=y - -# PSCI is supported with NS -CONFIG_PM_CPU_OPS=y -CONFIG_PM_CPU_OPS_PSCI=y diff --git a/boards/phytium/s5000c_testb_smp/Kconfig.defconfig b/boards/phytium/s5000c_testb_smp/Kconfig.defconfig deleted file mode 100644 index 754f09e2b9f..00000000000 --- a/boards/phytium/s5000c_testb_smp/Kconfig.defconfig +++ /dev/null @@ -1,30 +0,0 @@ -# Phytium is pleased to support the open source community by making Zephyr-SDK available. - -# -# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. -# -# Licensed under the Apache-2.0 License (the "License"); you may not use this file except -# in compliance with the License. You may obtain a copy of the License at -# -# https://opensource.org/license/apache-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. - - -config BOARD - default "Phytium S5000C testb" - depends on BOARD_S5000C_TESTB - - - -if NETWORKING - -config NET_L2_ETHERNET - default y - - - -endif # NETWORKING diff --git a/boards/phytium/s5000c_testb_smp/Kconfig.s5000c_testb_smp b/boards/phytium/s5000c_testb_smp/Kconfig.s5000c_testb_smp deleted file mode 100644 index e71bc1878df..00000000000 --- a/boards/phytium/s5000c_testb_smp/Kconfig.s5000c_testb_smp +++ /dev/null @@ -1,18 +0,0 @@ -# Phytium is pleased to support the open source community by making Zephyr-SDK available. - -# -# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. -# -# Licensed under the Apache-2.0 License (the "License"); you may not use this file except -# in compliance with the License. You may obtain a copy of the License at -# -# https://opensource.org/license/apache-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. - -config BOARD_S5000C_TESTB_SMP - bool "phytium S5000C" - select SOC_S5000C diff --git a/boards/phytium/s5000c_testb_smp/board.cmake b/boards/phytium/s5000c_testb_smp/board.cmake deleted file mode 100644 index 9881313609a..00000000000 --- a/boards/phytium/s5000c_testb_smp/board.cmake +++ /dev/null @@ -1 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 diff --git a/boards/phytium/s5000c_testb_smp/board.yml b/boards/phytium/s5000c_testb_smp/board.yml deleted file mode 100644 index 7dbc474c98a..00000000000 --- a/boards/phytium/s5000c_testb_smp/board.yml +++ /dev/null @@ -1,5 +0,0 @@ -board: - name: s5000c_testb_smp - vendor: arm64 - socs: - - name: phytium_s5000c \ No newline at end of file diff --git a/boards/phytium/s5000c_testb_smp/s5000c_testb_smp.dts b/boards/phytium/s5000c_testb_smp/s5000c_testb_smp.dts deleted file mode 100644 index 9d7ceda7549..00000000000 --- a/boards/phytium/s5000c_testb_smp/s5000c_testb_smp.dts +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2023 honglin leng - * - * SPDX-License-Identifier: Apache-2.0 - */ - -/dts-v1/; - -#include -/ { - model = "Phytium s5000c testb"; - compatible = "phytium,s5000c-testb", "phytium,s5000c"; - #address-cells = <2>; - #size-cells = <2>; - - psci { - compatible = "arm,psci-0.2"; - method = "smc"; - label = "PSCI"; - }; - -chosen { - zephyr,console = &uart1; - zephyr,shell-uart = &uart1; - zephyr,sram = &sram0; - }; -}; - -// &sdhc1 { -// status = "okay"; -// sdmmc { -// compatible = "zephyr,sdmmc-disk"; -// status = "okay"; -// }; -// }; - -&uart1 { - status = "okay"; - current-speed = <115200>; -}; - -// &uart2 { -// status = "okay"; -// current-speed = <115200>; -// }; - -// &xmac0 { -// status = "okay"; -// local-mac-address = [00 00 00 01 02 03]; -// }; diff --git a/boards/phytium/s5000c_testb_smp/s5000c_testb_smp.yaml b/boards/phytium/s5000c_testb_smp/s5000c_testb_smp.yaml deleted file mode 100644 index 13359566554..00000000000 --- a/boards/phytium/s5000c_testb_smp/s5000c_testb_smp.yaml +++ /dev/null @@ -1,10 +0,0 @@ - -identifier: s5000c_testb -name: Phytium s5000c testb -type: mcu -arch: arm64 -toolchain: - - zephyr - - cross-compile -supported: - - smp diff --git a/drivers/ethernet/eth_phytium_xmac.c b/drivers/ethernet/eth_phytium_xmac.c index 3038adba0b5..b2afd1b3565 100644 --- a/drivers/ethernet/eth_phytium_xmac.c +++ b/drivers/ethernet/eth_phytium_xmac.c @@ -1,1467 +1,1467 @@ -// Phytium is pleased to support the open source community by making Zephyr-SDK available. - -// -// Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. -// -// Licensed under the Apache-2.0 License (the "License"); you may not use this file except -// in compliance with the License. You may obtain a copy of the License at -// -// https://opensource.org/license/apache-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 "fxmac.h" -#include "fxmac_hw.h" -#include "fxmac_bdring.h" -#include "fxmac_phy.h" -#include "eth_ieee_reg.h" -#include "eth_phytium_xmac.h" - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - - - -#define LOG_MODULE_NAME phytium_xmac -#define LOG_LEVEL CONFIG_ETHERNET_LOG_LEVEL -#include -LOG_MODULE_REGISTER(LOG_MODULE_NAME); - -#define DT_DRV_COMPAT phytium_xmac - - -/* dma buffer */ -#define ETH_PHYTIUM_BDL_ALIGNMENT 256 -#define ETH_PHYTIUM_BUFFER_ALIGNMENT ETH_PHYTIUM_BDL_ALIGNMENT -#define ETH_ALIGNMENT_OFFSET_DEFINED(buffer_size) ((buffer_size\ - + (ETH_PHYTIUM_BUFFER_ALIGNMENT - 1))\ - & ~(ETH_PHYTIUM_BUFFER_ALIGNMENT - 1)) - - -/* IRQ handler function type */ -typedef void (*eth_phytiium_xmac_config_irq_t)(const struct device *dev); - -typedef enum -{ - FXMAC_LWIP_PORT_INTERFACE_SGMII = 0, - FXMAC_LWIP_PORT_INTERFACE_RMII, - FXMAC_LWIP_PORT_INTERFACE_RGMII, - FXMAC_LWIP_PORT_INTERFACE_USXGMII, - FXMAC_LWIP_PORT_INTERFACE_LENGTH -} FXmacLwipPortInterface; - - -#define FXMAC_PHY_SPEED_10M 10 -#define FXMAC_PHY_SPEED_100M 100 -#define FXMAC_PHY_SPEED_1000M 1000 -#define FXMAC_PHY_SPEED_10G 10000 - - -/* phy link */ -enum eth_phytium_link_speed { - /* The values of this enum are consecutively numbered */ - LINK_DOWN = 0, - LINK_10MBIT, - LINK_100MBIT, - LINK_1GBIT -}; - -#define FXMAC_BD_TO_INDEX(ringptr, bdptr) \ - (((uintptr)bdptr - (uintptr)(ringptr)->base_bd_addr) / (ringptr)->separation) - -struct eth_phytium_xmac_dev_cfg { - DEVICE_MMIO_ROM; - uint32_t instance_id ; /* */ - eth_phytiium_xmac_config_irq_t config_func; - uint32_t pll_clock_frequency; - - uint32_t phy_poll_interval; - uint8_t defer_rxp_to_queue; - uint8_t defer_txd_to_queue; - - uint8_t rxbd_count; /* rx bdl count */ - uint8_t txbd_count; /* tx bdl count */ - uint16_t rx_buffer_size; /* per buffer size */ - uint16_t tx_buffer_size; - - /* dtc defined */ - uint32_t phy_speed ; /* FXMAC_PHY_SPEED_XX */ - uint32_t interface_mode ; /* followed by FXmacLwipPortInterface */ - uint32_t dma_brust_length ; - uint32_t max_queue_num; /* Number of Xmac Controller Queues */ - bool phy_autonegotiation : 1 ; - bool enable_fdx : 1 ; - bool enable_jumbo : 1; - bool enable_ucast_hash :1; - bool copy_all_frames :1; - bool disable_reject_fcs_crc_errors:1; - bool enable_mcast_hash :1; - -}; - - -struct eth_phytium_xmac_dev_data { - DEVICE_MMIO_RAM; /* used for controller base address */ - struct net_if *iface; - FXmac instance ; - uint8_t mac_addr[6]; - enum eth_phytium_link_speed eff_link_speed ; - struct k_work tx_done_work; - struct k_work rx_pend_work; - struct k_sem tx_done_sem; - - struct k_sem ring_sem; - - uint8_t phy_addr; - uint32_t phy_id; - struct k_work_delayable phy_poll_delayed_work; - -#ifdef CONFIG_NET_STATISTICS_ETHERNET - struct net_stats_eth stats; -#endif - - uint8_t *rx_bdspace ; - uint8_t *rx_bdspace_virt ; - uint8_t *tx_bdspace ; - uint8_t *tx_bdspace_virt ; - - uint8_t *first_rx_buffer ; - uint8_t *first_rx_buffer_virt ; - uint8_t *first_tx_buffer ; - uint8_t *first_tx_buffer_virt ; - - bool started; -}; - - -static int eth_phytium_xmac_dev_init(const struct device *dev) ; -static void eth_phytium_xmac_iface_init(struct net_if *iface) ; -static enum ethernet_hw_caps eth_phytium_xmac_get_capabilities(const struct device *dev) ; -static int eth_phytium_xmac_send(const struct device *dev, struct net_pkt *pkt) ; -static int eth_phytium_xmac_start_device(const struct device *dev) ; -static int eth_phytium_xmac_stop_device(const struct device *dev) ; -#ifdef CONFIG_NET_STATISTICS_ETHERNET -static struct net_stats_eth *eth_phytium_xmac_stats(const struct device *dev) ; -#endif - -static void eth_phytium_xmac_isr(const struct device *dev) ; - -static const struct ethernet_api eth_phytium_xmac_apis = { - .iface_api.init = eth_phytium_xmac_iface_init, - .get_capabilities = eth_phytium_xmac_get_capabilities, - .send = eth_phytium_xmac_send, - .start = eth_phytium_xmac_start_device, - .stop = eth_phytium_xmac_stop_device, -#if defined(CONFIG_NET_STATISTICS_ETHERNET) - .get_stats = eth_phytium_xmac_stats, -#endif -}; - - -/* - * Insert the configuration & run-time data for all GEM instances which - * are enabled in the device tree of the current target board. - */ -DT_INST_FOREACH_STATUS_OKAY(ETH_PHYTIUM_XMAC_INITIALIZE) - - -static void FXmacSetupIsr(const struct device *dev) ; - -static uint32_t phy_autoneg_status(FXmac *xmac_p, uint32_t phy_addr) -{ - u16 status; - - /* Read Phy Status register twice to get the confirmation of the current - * link status. - */ - FXmacPhyRead(xmac_p, phy_addr, PHY_STATUS_REG_OFFSET, &status); - - if (status & PHY_STATUS_AUTONEGOTIATE_COMPLETE) - return 1; - return 0; -} - -/** - * @name: phy_link_detect - * @msg: Get current link status - * @note: - * @param {FXmac} *fxmac_p - * @param {u32} phy_addr - * @return {*} 1 is link up , 0 is link down - */ -static u32 phy_link_detect(FXmac *xmac_p, u32 phy_addr) -{ - u16 status; - - /* Read Phy Status register twice to get the confirmation of the current - * link status. - */ - - FXmacPhyRead(xmac_p, phy_addr, PHY_STATUS_REG_OFFSET, &status); - - if (status & PHY_STAT_LINK_STATUS) - return 1; - return 0; -} - -FXmacLinkStatus FXmacRgmiiLinkDetect(const struct device *dev) -{ - struct eth_phytium_xmac_dev_data *dev_data = (struct eth_phytium_xmac_dev_data *)dev->data ; - FXmac *instance_p; - instance_p = &dev_data->instance; - - u32 phy_link_status; - - - phy_link_status = phy_link_detect(instance_p, instance_p->phy_address); - - if ((instance_p->link_status == FXMAC_LINKUP) && (!phy_link_status)) - instance_p->link_status = FXMAC_LINKDOWN; - - switch (instance_p->link_status) - { - case FXMAC_LINKUP: - return FXMAC_LINKUP; - case FXMAC_LINKDOWN: - instance_p->link_status = FXMAC_NEGOTIATING; - LOG_DBG("Ethernet Link down"); - return FXMAC_LINKDOWN; - case FXMAC_NEGOTIATING: - if ((phy_link_status == FXMAC_LINKUP) && phy_autoneg_status(instance_p, instance_p->phy_address)) - { - if(FXmacPhyInit(instance_p, instance_p->config.speed, instance_p->config.duplex, instance_p->config.auto_neg, XMAC_PHY_RESET_DISABLE)) - { - return FXMAC_LINKDOWN; - } - - FXmacSelectClk(instance_p); - FXmacInitInterface(instance_p); - - /* Initiate Phy setup to get link speed */ - instance_p->link_status = FXMAC_LINKUP; - LOG_DBG("Ethernet Link up"); - return FXMAC_LINKUP; - } - return FXMAC_LINKDOWN; - default: - return FXMAC_LINKDOWN; - } -} - -FXmacLinkStatus FXmacSgmiiLinkDetect(const struct device *dev) -{ - struct eth_phytium_xmac_dev_data *dev_data = (struct eth_phytium_xmac_dev_data *)dev->data ; - FXmac *instance_p; - u32 ctrl; - u32 link, link_status; - instance_p = &dev_data->instance; - - ctrl = FXMAC_READREG32(instance_p->config.base_address, FXMAC_PCS_AN_LP_OFFSET); - link = (ctrl & FXMAC_PCS_LINK_PARTNER_NEXT_PAGE_STATUS) >> FXMAC_PCS_LINK_PARTNER_NEXT_PAGE_OFFSET; - - switch (link) - { - case 0: - link_status = FXMAC_LINKDOWN; - break; - case 1: - link_status = FXMAC_LINKUP; - break; - default: - LOG_ERR("link status is error 0x%x \r\n", link); - return FXMAC_LINKDOWN; - } - - if (link_status == FXMAC_LINKUP) - { - if (link_status != instance_p->link_status) - { - instance_p->link_status = FXMAC_NEGOTIATING; - LOG_INF("need NEGOTIATING"); - } - } - else - { - instance_p->link_status = FXMAC_LINKDOWN; - } - - if (instance_p->link_status == FXMAC_NEGOTIATING) - { - /* renegotiate */ - if (FXmacPhyInit(instance_p, instance_p->config.speed, instance_p->config.duplex, instance_p->config.auto_neg,XMAC_PHY_RESET_DISABLE)) - { - LOG_ERR("FXmacPhyInit is error \r\n"); - return FXMAC_LINKDOWN; - } - else - { - FXmacSelectClk(instance_p); - FXmacInitInterface(instance_p); - instance_p->link_status = FXMAC_LINKUP; - return FXMAC_LINKUP; - } - } - return instance_p->link_status ; -} - -static void eth_phytium_xmac_poll_phy(struct k_work *work) -{ - struct k_work_delayable *dwork = k_work_delayable_from_work(work); - struct eth_phytium_xmac_dev_data *dev_data = CONTAINER_OF(dwork, - struct eth_phytium_xmac_dev_data, phy_poll_delayed_work); - const struct device *dev = net_if_get_device(dev_data->iface); - const struct eth_phytium_xmac_dev_cfg *dev_conf = dev->config; - FXmacLinkStatus link_status = FXMAC_LINKDOWN ; - FXmac *instance_p; - instance_p = &dev_data->instance; - - if(instance_p->config.interface == FXMAC_PHY_INTERFACE_MODE_SGMII) - { - link_status = FXmacSgmiiLinkDetect(dev) ; - } - else if((instance_p->config.interface == FXMAC_PHY_INTERFACE_MODE_RMII) || (instance_p->config.interface == FXMAC_PHY_INTERFACE_MODE_RGMII)) - { - link_status = FXmacRgmiiLinkDetect(dev) ; - } - - if(link_status == FXMAC_LINKDOWN) - { - dev_data->eff_link_speed = LINK_DOWN; - net_eth_carrier_off(dev_data->iface); - - LOG_WRN("%s link down", dev->name); - } - else if(link_status == FXMAC_LINKUP) - { - switch(instance_p->config.speed) - { - case FXMAC_SPEED_10: - dev_data->eff_link_speed = LINK_10MBIT ; - break ; - case FXMAC_SPEED_100: - dev_data->eff_link_speed = LINK_100MBIT ; - break ; - case FXMAC_SPEED_1000: - dev_data->eff_link_speed = LINK_1GBIT ; - break ; - } - net_eth_carrier_on(dev_data->iface); - } - - k_work_reschedule(&dev_data->phy_poll_delayed_work, - K_MSEC(dev_conf->phy_poll_interval)); - -} - -/** - * @name: eth_phytium_xmac_get_capabilities - * @msg: Reports the hardware capabilities of the Ethernet device, such as supported speeds and duplex modes. - * @param {const struct device} *dev is a pointer to the device structure for the driver instance. - * @return {enum ethernet_hw_caps} A bitmask of supported features defined in `enum ethernet_hw_caps`. - */ -static enum ethernet_hw_caps eth_phytium_xmac_get_capabilities(const struct device *dev) -{ - struct eth_phytium_xmac_dev_cfg *dev_cfg = (struct eth_phytium_xmac_dev_cfg *)dev->config ; - enum ethernet_hw_caps caps = (enum ethernet_hw_caps)0; - - switch (dev_cfg->phy_speed) - { - case FXMAC_PHY_SPEED_10M: - caps |= ETHERNET_LINK_10BASE_T; - break; - case FXMAC_PHY_SPEED_100M: - caps |= (ETHERNET_LINK_100BASE_T | - ETHERNET_LINK_10BASE_T); - break; - case FXMAC_PHY_SPEED_1000M: - caps |= (ETHERNET_LINK_1000BASE_T | - ETHERNET_LINK_100BASE_T | - ETHERNET_LINK_10BASE_T); - break; - case FXMAC_PHY_SPEED_10G: - caps |= (ETHERNET_LINK_1000BASE_T | - ETHERNET_LINK_100BASE_T | - ETHERNET_LINK_10BASE_T); - break; - } - - if (dev_cfg->enable_fdx) { - caps |= ETHERNET_DUPLEX_SET; - } - - if (dev_cfg->copy_all_frames) { - caps |= ETHERNET_PROMISC_MODE; - } - return caps; -} - -static int eth_phytium_xmac_config_convert(struct eth_phytium_xmac_dev_cfg *dev_conf,FXmacConfig *mac_config,uint32_t *options) -{ - *options = 0 ; - switch (dev_conf->interface_mode) - { - case FXMAC_LWIP_PORT_INTERFACE_SGMII: - mac_config->interface = FXMAC_PHY_INTERFACE_MODE_SGMII; - LOG_INF("SGMII select"); - break; - case FXMAC_LWIP_PORT_INTERFACE_RMII: - mac_config->interface = FXMAC_PHY_INTERFACE_MODE_RMII; - LOG_INF("RMII select"); - break; - case FXMAC_LWIP_PORT_INTERFACE_RGMII: - LOG_INF("RGMII select"); - mac_config->interface = FXMAC_PHY_INTERFACE_MODE_RGMII; - break; - case FXMAC_LWIP_PORT_INTERFACE_USXGMII: - LOG_INF("USXGMII select"); - mac_config->interface = FXMAC_PHY_INTERFACE_MODE_USXGMII; - break; - default: - return -EINVAL; - } - - switch (dev_conf->phy_speed) - { - case FXMAC_PHY_SPEED_10M: - mac_config->speed = FXMAC_SPEED_10; - break; - case FXMAC_PHY_SPEED_100M: - mac_config->speed = FXMAC_SPEED_100; - break; - case FXMAC_PHY_SPEED_1000M: - mac_config->speed = FXMAC_SPEED_1000; - break; - case FXMAC_PHY_SPEED_10G: - LOG_INF("select FXMAC_PHY_SPEED_10G"); - mac_config->speed = FXMAC_SPEED_10000; - break; - default: - return -EINVAL; - } - - mac_config->duplex = dev_conf->enable_fdx? 1:0 ; /* 1 is full-duplex , 0 is half-duplex */ - mac_config->auto_neg = dev_conf->phy_autonegotiation ; /* Enable auto-negotiation - when set active high, - autonegotiation operation is enabled. */ - mac_config->pclk_hz = dev_conf->pll_clock_frequency ; - mac_config->max_queue_num = dev_conf->max_queue_num ; /* Number of Xmac Controller Queues */ - mac_config->tx_queue_id = 0 ; /* 0 ~ FXMAC_QUEUE_MAX_NUM ,Index queue number */ - mac_config->rx_queue_id = 0 ; /* 0 ~ FXMAC_QUEUE_MAX_NUM ,Index queue number */ - mac_config->dma_brust_length = dev_conf->dma_brust_length ; /* burst length */ - mac_config->network_default_config = FXMAC_DEFAULT_OPTIONS ; - mac_config->caps = 0 ; /* used to configure tail ptr feature */ - - /* options */ - if(dev_conf->enable_jumbo) - { - *options |= FXMAC_JUMBO_ENABLE_OPTION ; - } - - if(dev_conf->enable_ucast_hash) - { - *options |= FXMAC_UNICAST_OPTION; - } - - if(dev_conf->enable_mcast_hash) - { - *options |= FXMAC_MULTICAST_OPTION; - } - - if(dev_conf->copy_all_frames) - { - *options |= FXMAC_PROMISC_OPTION; - } - - if(dev_conf->disable_reject_fcs_crc_errors) - { - *options |= FXMAC_FCS_STRIP_OPTION; - } - - - return 0 ; -} - -/* irq init */ -static int eth_phytium_xmac_setuphandler(const struct device *dev) -{ - - struct eth_phytium_xmac_dev_cfg *dev_conf = (struct eth_phytium_xmac_dev_cfg *)dev->config ; - struct eth_phytium_xmac_dev_data *dev_data = (struct eth_phytium_xmac_dev_data *)dev->data ; - FXmac *instance_p; - - FXmacBd bdtemplate; - FXmacBdRing *rxringptr, *txringptr; - FXmacBd *rxbd; - int i; - u32 bdindex; - u32 *temp; - instance_p = &dev_data->instance; - /* init buffer to data */ - /* Initial configuration of the RX/TX BD rings */ - DT_INST_FOREACH_STATUS_OKAY(ETH_PHYTIUM_XMAC_INIT_BD_RING) - rxringptr = &FXMAC_GET_RXRING((*instance_p)); - txringptr = &FXMAC_GET_TXRING((*instance_p)); - - /* Setup RxBD space. */ - FXMAC_BD_CLEAR(&bdtemplate); - - /* Create the RxBD ring */ - if(FXmacBdRingCreate(rxringptr, (uintptr)dev_data->rx_bdspace, - (uintptr)dev_data->rx_bdspace, - ETH_PHYTIUM_BDL_ALIGNMENT, - dev_conf->rxbd_count)) - { - LOG_ERR("Error setting up RxBD space\r\n"); - return -EIO ; - } - - if(FXmacBdRingClone(rxringptr, &bdtemplate, FXMAC_RECV)) - { - LOG_ERR("Error initializing RxBD space\r\n"); - return -EIO; - } - - FXMAC_BD_CLEAR(&bdtemplate); - FXMAC_BD_SET_STATUS(&bdtemplate, FXMAC_TXBUF_USED_MASK); - - - /* Create the TxBD ring */ - if (FXmacBdRingCreate(txringptr, (uintptr)dev_data->tx_bdspace, - (uintptr)dev_data->tx_bdspace, ETH_PHYTIUM_BDL_ALIGNMENT, - dev_conf->txbd_count)) - { - return -EIO; - } - - /* We reuse the bd template, as the same one will work for both rx and tx. */ - if(FXmacBdRingClone(txringptr, &bdtemplate, FXMAC_SEND)) - { - return -EIO; - } - - /* init rx buffer */ - for (i = 0; i < dev_conf->rxbd_count; i++) - { - if(FXmacBdRingAlloc(rxringptr, 1, &rxbd)) - { - LOG_ERR("InitDma: Error allocating RxBD\r\n"); - return -ERANGE; - } - - /* Enqueue to HW */ - if(FXmacBdRingToHw(rxringptr, 1, rxbd)) - { - LOG_ERR("Error: committing RxBD to HW\r\n"); - FXmacBdRingUnAlloc(rxringptr, 1, rxbd); - return -ERANGE; - } - - bdindex = FXMAC_BD_TO_INDEX(rxringptr, rxbd); - temp = (u32 *)rxbd; - *temp = 0; - if (bdindex == (dev_conf->rxbd_count - 1)) - { - *temp = 0x00000002; /* Marks last descriptor in receive buffer descriptor list */ - } - temp++; - *temp = 0; /* Clear word 1 in descriptor */ - - FXMAC_BD_SET_ADDRESS_RX(rxbd, (uintptr)(dev_data->first_rx_buffer_virt + ETH_ALIGNMENT_OFFSET_DEFINED(dev_conf->rx_buffer_size)*bdindex)); - - } - FXmacSetQueuePtr(instance_p, instance_p->tx_bd_queue.bdring.phys_base_addr, 0, (u16)FXMAC_SEND); - FXmacSetQueuePtr(instance_p, instance_p->rx_bd_queue.bdring.phys_base_addr, 0, (u16)FXMAC_RECV); - - return 0; -} - - - -static void eth_phytium_xmac_handle_tx_done(const struct device *dev) -{ - struct eth_phytium_xmac_dev_data *dev_data = (struct eth_phytium_xmac_dev_data *)dev->data ; - struct eth_phytium_xmac_dev_cfg *dev_conf = (struct eth_phytium_xmac_dev_cfg *)dev->config ; - FXmac *instance_p; - FXmacBd *txbdset; - FXmacBd *curbdpntr; - u32 n_bds; - FError status; - u32 n_pbufs_freed = 0; - u32 bdindex; - u32 *temp; - instance_p = &dev_data->instance ; - FXmacBdRing *txring; - - if (dev_conf->defer_txd_to_queue) { - k_sem_take(&(dev_data->ring_sem), K_FOREVER); - } - txring = &(FXMAC_GET_TXRING((*instance_p))); - while (1) - { - /* obtain processed BD's */ - n_bds = FXmacBdRingFromHwTx(txring, dev_conf->txbd_count, &txbdset); - if (n_bds == 0) - { - break; - } - /* free the processed BD's */ - n_pbufs_freed = n_bds; - curbdpntr = txbdset; - while (n_pbufs_freed > 0) - { - bdindex = FXMAC_BD_TO_INDEX(txring, curbdpntr); - temp = (u32 *)curbdpntr; - *temp = 0; /* Word 0 */ - temp++; - - if (bdindex == (dev_conf->txbd_count - 1)) - { - *temp = 0xC0000000; /* Word 1 ,used/Wrap – marks last descriptor in transmit buffer descriptor list.*/ - } - else - { - *temp = 0x80000000; /* Word 1 , Used – must be zero for GEM to read data to the transmit buffer.*/ - } - - curbdpntr = FXMAC_BD_RING_NEXT(txring, curbdpntr); - n_pbufs_freed--; - - } - - status = FXmacBdRingFree(txring, n_bds, txbdset); - if (status != FT_SUCCESS) - { - LOG_ERR("Failure while freeing in Tx Done ISR\r\n"); - } - } - - if (dev_conf->defer_txd_to_queue) { - k_sem_give(&(dev_data->ring_sem)); - } - - /* Re-enable the TX complete interrupt source */ - FXMAC_WRITEREG32(instance_p->config.base_address,FXMAC_IER_OFFSET,FXMAC_IXR_TXCOMPL_MASK) ; - - /* Indicate completion to a blocking eth_xlnx_gem_send() call */ - k_sem_give(&dev_data->tx_done_sem); -} - -static void eth_phytium_xmac_tx_done_work(struct k_work *item) -{ - struct eth_phytium_xmac_dev_data *dev_data = CONTAINER_OF(item, struct eth_phytium_xmac_dev_data, tx_done_work); - const struct device *dev = net_if_get_device(dev_data->iface); - - eth_phytium_xmac_handle_tx_done(dev); -} - -/** - * @name: eth_phytium_xmac_send - * @msg: Sends an Ethernet frame. The frame is contained in a packet that is managed by the networking stack. - * @param {const struct device} *dev is a pointer to the device structure for the driver instance. - * @param {struct net_pkt} *pkt is a pointer to the network packet that contains the data to be sent. - * @return {int} Zero on success or negative error code on failure. - */ -static int eth_phytium_xmac_send(const struct device *dev, struct net_pkt *pkt) -{ - struct eth_phytium_xmac_dev_cfg *dev_conf = (struct eth_phytium_xmac_dev_cfg *)dev->config ; - struct eth_phytium_xmac_dev_data *dev_data = (struct eth_phytium_xmac_dev_data *)dev->data ; - FXmac *instance_p; - - FXmacBd *txbdset, *txbd, *last_txbd = NULL; - FXmacBdRing *txring; - u32 bdindex; - - uint16_t tx_data_length; - uint16_t tx_data_remaining; - void *tx_buffer_offs; - uint32_t bds_reqd; - uint32_t tx_length = 0 ; - instance_p = &dev_data->instance; - txring = &FXMAC_GET_TXRING((*instance_p)); - - if (!dev_data->started || dev_data->eff_link_speed == LINK_DOWN || - (!net_if_flag_is_set(dev_data->iface, NET_IF_UP))) { -#ifdef CONFIG_NET_STATISTICS_ETHERNET - dev_data->stats.tx_dropped++; -#endif - return -EIO; - } - - tx_data_length = tx_data_remaining = net_pkt_get_len(pkt); - if (tx_data_length == 0) { - LOG_ERR("%s cannot TX, zero packet length", dev->name); -#ifdef CONFIG_NET_STATISTICS_ETHERNET - dev_data->stats.errors.tx++; -#endif - return -EINVAL; - } - - bds_reqd = (uint8_t)((tx_data_length + (dev_conf->tx_buffer_size - 1)) / - dev_conf->tx_buffer_size); - - if (dev_conf->defer_txd_to_queue) { - k_sem_take(&(dev_data->ring_sem), K_FOREVER); - } else { - FXMAC_WRITEREG32(instance_p->config.base_address,FXMAC_IDR_OFFSET,FXMAC_IXR_TXCOMPL_MASK) ; - } - - /* obtain as many BD's */ - if(FXmacBdRingAlloc(txring, bds_reqd, &txbdset)) - { - LOG_ERR("sgsend: Error allocating TxBD\r\n"); -#ifdef CONFIG_NET_STATISTICS_ETHERNET - dev_data->stats.tx_dropped++; -#endif - FXMAC_WRITEREG32(instance_p->config.base_address,FXMAC_IER_OFFSET,FXMAC_IXR_TXCOMPL_MASK) ; - return ERR_GENERAL; - } - - if (dev_conf->defer_txd_to_queue) { - k_sem_give(&(dev_data->ring_sem)); - } else { - FXMAC_WRITEREG32(instance_p->config.base_address,FXMAC_IER_OFFSET,FXMAC_IXR_TXCOMPL_MASK) ; - } - - /* - * Scatter the contents of the network packet's buffer to - * one or more DMA buffers. - */ - net_pkt_cursor_init(pkt); - txbd = txbdset ; - while (tx_data_remaining) - { - bdindex = FXMAC_BD_TO_INDEX(txring, txbd); - - /* Calculate the base pointer of the target TX buffer */ - tx_buffer_offs = (void *)(dev_data->first_tx_buffer + - (ETH_ALIGNMENT_OFFSET_DEFINED(dev_conf->tx_buffer_size) * bdindex)); - - /* Copy packet data to DMA buffer */ - tx_length = (tx_data_remaining < dev_conf->tx_buffer_size) ? - tx_data_remaining : dev_conf->tx_buffer_size ; - net_pkt_read(pkt, (void *)tx_buffer_offs,tx_length); - - FXMAC_BD_SET_ADDRESS_TX(txbd, (uintptr)tx_buffer_offs); - - FXMAC_BD_SET_LENGTH(txbd, tx_length & 0x3FFF); - - last_txbd = txbd; - FXMAC_BD_CLEAR_LAST(txbd); - txbd = FXMAC_BD_RING_NEXT(txring, txbd); - tx_data_remaining -= (tx_data_remaining < dev_conf->tx_buffer_size) ? - tx_data_remaining : dev_conf->tx_buffer_size; - } - FXMAC_BD_SET_LAST(last_txbd); - FXMAC_BD_CLEAR_TX_USED(last_txbd); - - if(FXmacBdRingToHw(txring, bds_reqd, txbdset)) - { - LOG_ERR("sgsend: Error submitting TxBD\r\n"); - } - - /* Start transmit */ - FXMAC_WRITEREG32(instance_p->config.base_address, - FXMAC_NWCTRL_OFFSET, - (FXMAC_READREG32(instance_p->config.base_address, - FXMAC_NWCTRL_OFFSET) | - FXMAC_NWCTRL_STARTTX_MASK)); - -#ifdef CONFIG_NET_STATISTICS_ETHERNET - dev_data->stats.bytes.sent += tx_data_length; - dev_data->stats.pkts.tx++; -#endif - - return 0 ; -} - -static void eth_phytium_xmac_setup_rx_bds(const struct device *dev,FXmacBdRing *rxring) -{ - const struct eth_phytium_xmac_dev_cfg *dev_conf = dev->config; - struct eth_phytium_xmac_dev_data *dev_data = dev->data; - FXmacBd *rxbd; - FError status; - u32 freebds; - u32 bdindex; - u32 *temp; - FXmac *instance_p; - instance_p = &dev_data->instance ; - - freebds = FXMAC_BD_RING_GET_FREE_CNT(rxring); - while (freebds > 0) - { - freebds --; - status = FXmacBdRingAlloc(rxring, 1, &rxbd); - if (status != FT_SUCCESS) - { - LOG_ERR("SetupRxBds: Error allocating RxBD\r\n"); - return; - } - status = FXmacBdRingToHw(rxring, 1, rxbd); - if (status != FT_SUCCESS) - { - LOG_ERR("Error committing RxBD to hardware: "); - if (status == FXMAC_ERR_SG_LIST) - { - LOG_ERR("XST_DMA_SG_LIST_ERROR: this function was called out of sequence with FXmacBdRingAlloc()\r\n"); - } - else - { - LOG_ERR("set of BDs was rejected because the first BD did not have its start-of-packet bit set, or the last BD did not have its end-of-packet bit set, or any one of the BD set has 0 as length value\r\n"); - } - - FXmacBdRingUnAlloc(rxring, 1, rxbd); - return; - } - - - bdindex = FXMAC_BD_TO_INDEX(rxring, rxbd); - temp = (u32 *)rxbd; - if (bdindex == (dev_conf->rxbd_count - 1)) - { - *temp = 0x00000002; /* Mask last descriptor in receive buffer list */ - } - else - { - *temp = 0; - } - temp++; - *temp = 0; - - FXMAC_BD_SET_ADDRESS_RX(rxbd, (uintptr)(dev_data->first_rx_buffer_virt + ETH_ALIGNMENT_OFFSET_DEFINED(dev_conf->rx_buffer_size)*bdindex)); - - } -} - -static void eth_phytium_xmac_handle_rx_pending(const struct device *dev) -{ - const struct eth_phytium_xmac_dev_cfg *dev_conf = dev->config; - struct eth_phytium_xmac_dev_data *dev_data = dev->data; - FXmacBd *rxbdset, *curbdptr; - FXmacBdRing *rxring; - volatile u32 bd_processed; - u32 k; - u32 bdindex; - FXmac *instance_p; - struct net_pkt *pkt; - uint32_t rx_data_length; - instance_p = &dev_data->instance ; - rxring = &FXMAC_GET_RXRING((*instance_p)); - - /* Re-enable the frame received interrupt source */ - FXMAC_WRITEREG32(instance_p->config.base_address,FXMAC_IER_OFFSET,FXMAC_IXR_RXCOMPL_MASK); - - while (1) - { - bd_processed = FXmacBdRingFromHwRx(rxring, dev_conf->rxbd_count, &rxbdset); - if (bd_processed <= 0) - { - break; - } - - for (k = 0, curbdptr = rxbdset; k < bd_processed; k++) - { - bdindex = FXMAC_BD_TO_INDEX(rxring, curbdptr); - rx_data_length = FXMAC_BD_GET_LENGTH(curbdptr); - if(rx_data_length > dev_conf->rx_buffer_size) - { - LOG_ERR("rx_data_length length is error: %u bytes \r\n", - rx_data_length); - goto error_exit ; - } - - pkt = net_pkt_rx_alloc_with_buffer(dev_data->iface, rx_data_length, - AF_UNSPEC, 0, K_FOREVER); - if (pkt == NULL) - { - LOG_ERR("RX packet buffer alloc failed: %u bytes", - rx_data_length); -#ifdef CONFIG_NET_STATISTICS_ETHERNET - dev_data->stats.errors.rx++; - dev_data->stats.error_details.rx_no_buffer_count++; -#endif - /* free up the BD's */ - goto error_exit ; - } - - net_pkt_write(pkt, (const void *) - (dev_data->first_rx_buffer_virt + ETH_ALIGNMENT_OFFSET_DEFINED(dev_conf->rx_buffer_size)*bdindex), - rx_data_length); - - if (net_recv_data(dev_data->iface, pkt) < 0) { - printf("%s RX packet hand-over to IP stack failed", dev->name); - net_pkt_unref(pkt); - } -#ifdef CONFIG_NET_STATISTICS_ETHERNET - else { - dev_data->stats.bytes.received += rx_data_length; - dev_data->stats.pkts.rx++; - } -#endif - curbdptr = FXMAC_BD_RING_NEXT(rxring, curbdptr); - } - FXmacBdRingFree(rxring, bd_processed, rxbdset); - eth_phytium_xmac_setup_rx_bds(dev,rxring) ; - } - - return; - -error_exit: - printf("eth_phytium_xmac_handle_rx_pending error exit \r\n") ; - FXmacBdRingFree(rxring, bd_processed, rxbdset); -} - -static void eth_phytium_xmac_rx_pending_work(struct k_work *item) -{ - struct eth_phytium_xmac_dev_data *dev_data = CONTAINER_OF(item, - struct eth_phytium_xmac_dev_data, rx_pend_work); - const struct device *dev = net_if_get_device(dev_data->iface); - - eth_phytium_xmac_handle_rx_pending(dev); -} - - -static void FXmacSendHandler(void *arg) -{ - const struct device *dev = (const struct device *)arg; - struct eth_phytium_xmac_dev_data *dev_data = dev->data; - const struct eth_phytium_xmac_dev_cfg *dev_conf = dev->config; - FXmac *instance_p; - instance_p = &dev_data->instance; - - FXMAC_WRITEREG32(instance_p->config.base_address, FXMAC_IDR_OFFSET,FXMAC_IXR_TXCOMPL_MASK); - if (dev_conf->defer_txd_to_queue) - { - k_work_submit(&dev_data->tx_done_work); - } - else - { - eth_phytium_xmac_handle_tx_done(dev); - } -} - -static void FXmacRecvHandler(void *arg) -{ - const struct device *dev = (const struct device *)arg ; - struct eth_phytium_xmac_dev_data *dev_data = dev->data; - const struct eth_phytium_xmac_dev_cfg *dev_conf = dev->config; - FXmac *instance_p; - instance_p = &dev_data->instance ; - - FXMAC_WRITEREG32(instance_p->config.base_address,FXMAC_IDR_OFFSET,FXMAC_IXR_RXCOMPL_MASK) ; - - if (dev_conf->defer_rxp_to_queue) - { - k_work_submit(&dev_data->rx_pend_work); - } - else - { - printk("recv data \r\n") ; - eth_phytium_xmac_handle_rx_pending(dev); - printk("recv data exit \r\n") ; - } -} - -/* interrupt */ -static void FXmacHandleDmaTxError( const struct device *dev) -{ - u32 dmacrreg; - struct eth_phytium_xmac_dev_data *dev_data = (struct eth_phytium_xmac_dev_data *)dev->data; - FXmac *instance_p; - instance_p = &dev_data->instance ; - /* initialize the mac */ - if (FXmacCfgInitialize(instance_p, &instance_p->config)) - { - LOG_ERR("In %s:EmacPs Configuration Failed....\r\n", __func__); - } - - /* set mac address */ - FXmacSetMacAddress(instance_p, (void *)(dev_data->mac_addr), 0) ; - - dmacrreg = FXMAC_READREG32(instance_p->config.base_address, FXMAC_DMACR_OFFSET); - dmacrreg = dmacrreg | (FXMAC_DMACR_ORCE_DISCARD_ON_ERR_MASK); - FXMAC_WRITEREG32(instance_p->config.base_address, FXMAC_DMACR_OFFSET, dmacrreg); - /* setup dma bdl */ - eth_phytium_xmac_setuphandler(dev) ; - FXmacSetupIsr(dev); - - FXmacStart(instance_p); -} - -static void eth_phytium_xmac_tx_dma_init(const struct device *dev) -{ - struct eth_phytium_xmac_dev_data *dev_data = (struct eth_phytium_xmac_dev_data *)dev->data ; - struct eth_phytium_xmac_dev_cfg *dev_conf = (struct eth_phytium_xmac_dev_cfg *)dev->config ; - FXmac *instance_p; - instance_p = &dev_data->instance ; - FXmacBd bdtemplate; - FXmacBdRing *txringptr; - - txringptr = &FXMAC_GET_TXRING((*instance_p)); - FXMAC_BD_CLEAR(&bdtemplate); - FXMAC_BD_SET_STATUS(&bdtemplate, FXMAC_TXBUF_USED_MASK); - - if (FXmacBdRingCreate(txringptr, (uintptr)dev_data->tx_bdspace, - (uintptr)dev_data->tx_bdspace, ETH_PHYTIUM_BDL_ALIGNMENT, - dev_conf->txbd_count)) - { - LOG_ERR("FXmacBdRingCreate is error") ; - return ; - } - - FXmacBdRingClone(txringptr, &bdtemplate, FXMAC_SEND); -} - -static void FXmacHandleTxErrors( const struct device *dev) -{ - struct eth_phytium_xmac_dev_data *dev_data = (struct eth_phytium_xmac_dev_data *)dev->data ; - FXmac *instance_p; - - instance_p = &dev_data->instance ; - - u32 netctrlreg; - - netctrlreg = FXMAC_READREG32(instance_p->config.base_address, - FXMAC_NWCTRL_OFFSET); - netctrlreg = netctrlreg & (~FXMAC_NWCTRL_TXEN_MASK); - FXMAC_WRITEREG32(instance_p->config.base_address, - FXMAC_NWCTRL_OFFSET, netctrlreg); - - eth_phytium_xmac_tx_dma_init(dev); - netctrlreg = FXMAC_READREG32(instance_p->config.base_address, FXMAC_NWCTRL_OFFSET); - netctrlreg = netctrlreg | (FXMAC_NWCTRL_TXEN_MASK); - FXMAC_WRITEREG32(instance_p->config.base_address, FXMAC_NWCTRL_OFFSET, netctrlreg); -} - -void FXmacErrorHandler(void *arg, u8 direction, u32 error_word) -{ - const struct device *dev = (const struct device *)arg ; - struct eth_phytium_xmac_dev_data *dev_data = (struct eth_phytium_xmac_dev_data *)dev->data; - struct eth_phytium_xmac_dev_cfg *dev_conf = (struct eth_phytium_xmac_dev_cfg *)dev->config; - FXmac *instance_p; - instance_p = &dev_data->instance ; - - if (error_word != 0) - { - switch (direction) - { - case FXMAC_RECV: - if (error_word & FXMAC_RXSR_HRESPNOK_MASK) - { - LOG_ERR("Receive DMA error\r\n"); - FXmacHandleDmaTxError(dev); - } - if (error_word & FXMAC_RXSR_RXOVR_MASK) - { - LOG_ERR("Receive over run\r\n"); - FXmacRecvHandler((void *)dev) ; - } - if (error_word & FXMAC_RXSR_BUFFNA_MASK) - { - LOG_ERR("Receive buffer not available\r\n"); - FXmacRecvHandler((void *)dev) ; - } - break; - case FXMAC_SEND: - if (error_word & FXMAC_TXSR_HRESPNOK_MASK) - { - LOG_ERR("Transmit DMA error\r\n"); - FXmacHandleDmaTxError(dev); - } - if (error_word & FXMAC_TXSR_URUN_MASK) - { - LOG_ERR("Transmit under run\r\n"); - FXmacHandleTxErrors(dev); - } - if (error_word & FXMAC_TXSR_BUFEXH_MASK) - { - LOG_ERR("Transmit buffer exhausted\r\n"); - FXmacHandleTxErrors(dev); - } - if (error_word & FXMAC_TXSR_RXOVR_MASK) - { - LOG_ERR("Transmit retry excessed limits\r\n"); - FXmacHandleTxErrors(dev); - } - if (error_word & FXMAC_TXSR_FRAMERX_MASK) - { - LOG_ERR("Transmit collision\r\n"); - if (dev_conf->defer_txd_to_queue) { - k_work_submit(&dev_data->tx_done_work); - } - else - { - eth_phytium_xmac_handle_tx_done(dev); - } - } - break; - } - } -} - -#ifdef CONFIG_NET_STATISTICS_ETHERNET -/** - * @name: eth_phytium_xmac_stats - * @msg: Retrieves the Ethernet statistics for the device. - * @param {const struct device} *dev is a pointer to the device structure for the driver instance. - * @return {struct net_stats_eth} * A pointer to the statistics structure. - */ -static struct net_stats_eth *eth_phytium_xmac_stats(const struct device *dev) -{ - struct eth_phytium_xmac_dev_data *dev_data = dev->data; - - return &dev_data->stats; -} -#endif - -/** - * @name: FXmacSetupIsr - * @msg: Sets up the interrupt service routine handlers for transmit, receive, and error events. - * @param {const struct device} *dev is a pointer to the device structure for the driver instance. - */ -static void FXmacSetupIsr(const struct device *dev) -{ - struct eth_phytium_xmac_dev_data *dev_data = (struct eth_phytium_xmac_dev_data *)dev->data ; - /* Setup callbacks */ - FXmac *instance_p; - instance_p = &dev_data->instance; - - FXmacSetHandler(instance_p, FXMAC_HANDLER_DMASEND, FXmacSendHandler, (void *)dev); - FXmacSetHandler(instance_p, FXMAC_HANDLER_DMARECV, FXmacRecvHandler,(void *) (void *)dev); - FXmacSetHandler(instance_p, FXMAC_HANDLER_ERROR, FXmacErrorHandler, (void *)dev); -} - -/** - * @name: eth_phytium_xmac_start_device - * @msg: Starts the Ethernet device, enabling packet transmission and reception. - * @param {const struct device} *dev is a pointer to the device structure for the driver instance. - * @return {int} Zero on success or negative error code on failure. - */ -static int eth_phytium_xmac_start_device(const struct device *dev) -{ - struct eth_phytium_xmac_dev_data *dev_data = (struct eth_phytium_xmac_dev_data *)dev->data; - /* Setup callbacks */ - if (dev_data->started) { - return 0; - } - dev_data->started = true; - - FXmac *instance_p; - instance_p = &dev_data->instance; - FXmacStart(instance_p) ; - return 0 ; -} - -/** - * @name: eth_phytium_xmac_stop_device - * @msg: Stops the Ethernet device, disabling packet transmission and reception. - * @param {const struct device} *dev is a pointer to the device structure for the driver instance. - * @return {int} Zero on success or negative error code on failure. - */ -static int eth_phytium_xmac_stop_device(const struct device *dev) -{ - struct eth_phytium_xmac_dev_data *dev_data = (struct eth_phytium_xmac_dev_data *)dev->data; - FXmac *instance_p; - instance_p = &dev_data->instance; - - if (!dev_data->started) { - return 0; - } - dev_data->started = false; - - /* Cancel the delayed work that polls the link state */ - if (k_work_delayable_remaining_get(&dev_data->phy_poll_delayed_work) != 0) - { - k_work_cancel_delayable(&dev_data->phy_poll_delayed_work); - } - - FXmacStop(instance_p) ; - - return 0 ; -} - -/** - * @name: eth_phytium_xmac_isr - * @msg: Interrupt service routine for handling all interrupts from the Ethernet device. - * @param {const struct device} *dev is a pointer to the device structure for the driver instance. - */ -static void eth_phytium_xmac_isr(const struct device *dev) -{ - u32 reg_isr; - u32 reg_temp; - u32 reg_ctrl; - - struct eth_phytium_xmac_dev_data *dev_data = (struct eth_phytium_xmac_dev_data *)dev->data; - /* Setup callbacks */ - FXmac *instance_p; - instance_p = &dev_data->instance; - - reg_isr = FXMAC_READREG32(instance_p->config.base_address, FXMAC_ISR_OFFSET); - { - if ((reg_isr & FXMAC_IXR_TXCOMPL_MASK) != 0x00000000U) - { - /* Clear TX status register TX complete indication but preserve - * error bits if there is any */ - FXMAC_WRITEREG32(instance_p->config.base_address, - FXMAC_TXSR_OFFSET, - ((u32)FXMAC_TXSR_TXCOMPL_MASK | - (u32)FXMAC_TXSR_USEDREAD_MASK)); - if (instance_p->send_irq_handler) - { - /* code */ - instance_p->send_irq_handler(instance_p->send_args); - } - /* add */ - if(instance_p->caps& FXMAC_CAPS_ISR_CLEAR_ON_WRITE) - { - FXMAC_WRITEREG32(instance_p->config.base_address, FXMAC_ISR_OFFSET, FXMAC_IXR_TXCOMPL_MASK); - } - } - - /* Transmit error conditions interrupt */ - if (((reg_isr & FXMAC_IXR_TX_ERR_MASK) != 0x00000000U) && - (!(reg_isr & FXMAC_IXR_TXCOMPL_MASK) != 0x00000000U)) - { - /* Clear TX status register */ - reg_temp = FXMAC_READREG32(instance_p->config.base_address, FXMAC_TXSR_OFFSET); - FXMAC_WRITEREG32(instance_p->config.base_address, FXMAC_TXSR_OFFSET, reg_temp); - if (instance_p->error_irq_handler) - { - instance_p->error_irq_handler(instance_p->error_args, FXMAC_SEND, reg_temp); - } - /* add */ - if(instance_p->caps& FXMAC_CAPS_ISR_CLEAR_ON_WRITE) - { - FXMAC_WRITEREG32(instance_p->config.base_address, FXMAC_ISR_OFFSET, FXMAC_IXR_TX_ERR_MASK); - } - } - - /* add restart */ - if ((reg_isr & FXMAC_IXR_TXUSED_MASK) != 0x00000000U) - { - /* add */ - if(instance_p->caps& FXMAC_CAPS_ISR_CLEAR_ON_WRITE) - { - FXMAC_WRITEREG32(instance_p->config.base_address, FXMAC_ISR_OFFSET, FXMAC_IXR_TXUSED_MASK); - } - if (instance_p->restart_handler) - { - instance_p->restart_handler(instance_p->restart_args); - } - } - - /* link changed */ - if ((reg_isr & FXMAC_IXR_LINKCHANGE_MASK) != 0x00000000U) - { - if (instance_p->link_change_handler) - { - instance_p->link_change_handler(instance_p->link_change_args); - } - if(instance_p->caps& FXMAC_CAPS_ISR_CLEAR_ON_WRITE) - { - FXMAC_WRITEREG32(instance_p->config.base_address, FXMAC_ISR_OFFSET, FXMAC_IXR_LINKCHANGE_MASK); - } - } - } - - - { - /* Receive complete interrupt */ - if ((reg_isr & FXMAC_IXR_RXCOMPL_MASK) != 0x00000000U) - { - /* Clear RX status register RX complete indication but preserve - * error bits if there is any */ - FXMAC_WRITEREG32(instance_p->config.base_address, - FXMAC_RXSR_OFFSET, - ((u32)FXMAC_RXSR_FRAMERX_MASK | - (u32)FXMAC_RXSR_BUFFNA_MASK)); - instance_p->recv_irq_handler(instance_p->recv_args); - /* add */ - if(instance_p->caps& FXMAC_CAPS_ISR_CLEAR_ON_WRITE) - { - FXMAC_WRITEREG32(instance_p->config.base_address, FXMAC_ISR_OFFSET, FXMAC_IXR_RXCOMPL_MASK); - } - } - - /* Receive error conditions interrupt */ - if ((reg_isr & FXMAC_IXR_RX_ERR_MASK) != 0x00000000U) - { - /* Clear RX status register */ - reg_temp = FXMAC_READREG32(instance_p->config.base_address, - FXMAC_RXSR_OFFSET); - FXMAC_WRITEREG32(instance_p->config.base_address, - FXMAC_RXSR_OFFSET, reg_temp); - if ((reg_isr & FXMAC_IXR_RXUSED_MASK) != 0x00000000U) - { - reg_ctrl = FXMAC_READREG32(instance_p->config.base_address, - FXMAC_NWCTRL_OFFSET); - reg_ctrl |= (u32)FXMAC_NWCTRL_FLUSH_DPRAM_MASK; - /* add */ - reg_ctrl &= (u32)(~FXMAC_NWCTRL_RXEN_MASK); - FXMAC_WRITEREG32(instance_p->config.base_address, - FXMAC_NWCTRL_OFFSET, reg_ctrl); - /* add */ - reg_ctrl |= (u32)FXMAC_NWCTRL_RXEN_MASK; - FXMAC_WRITEREG32(instance_p->config.base_address, - FXMAC_NWCTRL_OFFSET, reg_ctrl); - - if(instance_p->caps& FXMAC_CAPS_ISR_CLEAR_ON_WRITE) - { - FXMAC_WRITEREG32(instance_p->config.base_address, FXMAC_ISR_OFFSET, FXMAC_IXR_RXUSED_MASK); - } - } - /* add */ - if ((reg_isr & FXMAC_IXR_RXOVR_MASK) != 0x00000000U) - { - if(instance_p->caps& FXMAC_CAPS_ISR_CLEAR_ON_WRITE) - { - FXMAC_WRITEREG32(instance_p->config.base_address, FXMAC_ISR_OFFSET, FXMAC_IXR_RXOVR_MASK); - } - } - /* add */ - if ((reg_isr & FXMAC_IXR_HRESPNOK_MASK) != 0x00000000U) - { - if(instance_p->caps& FXMAC_CAPS_ISR_CLEAR_ON_WRITE) - { - FXMAC_WRITEREG32(instance_p->config.base_address, FXMAC_ISR_OFFSET, FXMAC_IXR_HRESPNOK_MASK); - } - } - if (reg_temp != 0) - { - instance_p->error_irq_handler(instance_p->error_args, - FXMAC_RECV, reg_temp); - } - } - } -} - -/** - * @name: eth_phytium_xmac_iface_init - * @msg: Initializes the network interface for the Ethernet driver. Sets the link address and registers the Ethernet interface with the network stack. - * @param {struct net_if} *iface is a pointer to the network interface structure. - */ -static void eth_phytium_xmac_iface_init(struct net_if *iface) -{ - const struct device *dev = net_if_get_device(iface); - const struct eth_phytium_xmac_dev_cfg *dev_conf = dev->config; - struct eth_phytium_xmac_dev_data *dev_data = dev->data; - - /* Set the initial contents of the current instance's run-time data */ - dev_data->iface = iface; - net_if_set_link_addr(iface, dev_data->mac_addr, 6, NET_LINK_ETHERNET); - ethernet_init(iface); - net_if_carrier_off(iface); - - /* - * Initialize the (delayed) work items for RX pending, TX done - * and PHY status polling handlers - */ - k_work_init(&dev_data->tx_done_work, eth_phytium_xmac_tx_done_work); - k_work_init(&dev_data->rx_pend_work, eth_phytium_xmac_rx_pending_work); - k_work_init_delayable(&dev_data->phy_poll_delayed_work, - eth_phytium_xmac_poll_phy); - - /* Initialize TX completion semaphore */ - k_sem_init(&dev_data->tx_done_sem, 0, 1); - - /* - * Initialize semaphores in the RX/TX BD rings which have not - * yet been initialized - */ - k_sem_init(&dev_data->ring_sem, 1, 1); - /* RX BD ring semaphore is not required at the time being */ - - /* Initialize the device's interrupt */ - dev_conf->config_func(dev); - - /* Submit initial PHY status polling delayed work */ - k_work_reschedule(&dev_data->phy_poll_delayed_work, K_NO_WAIT); - -} - -/** - * @name: eth_phytium_xmac_dev_init - * @msg: Initializes the Ethernet device, including hardware configuration and MAC address setting. - * @param {const struct device} *dev is a pointer to the device structure for the driver instance. - * @return {int} Zero on success or negative error code on failure. - */ -static int eth_phytium_xmac_dev_init(const struct device *dev) -{ - struct eth_phytium_xmac_dev_data *dev_data = (struct eth_phytium_xmac_dev_data *)dev->data ; - struct eth_phytium_xmac_dev_cfg *dev_conf = (struct eth_phytium_xmac_dev_cfg *)dev->config ; - FXmacConfig mac_config; - FXmac *instance_p; - uint32_t xmac_options ; - uint32_t dmacrreg; - int ret ; - - /* init base */ - DEVICE_MMIO_MAP(dev, K_MEM_CACHE_NONE); - - /* config init */ - mac_config.base_address = DEVICE_MMIO_GET(dev) ; - mac_config.instance_id = 0; - - ret = eth_phytium_xmac_config_convert(dev_conf,&mac_config,&xmac_options) ; - if(ret) - { - return -EINVAL; - } - - instance_p = &dev_data->instance; - if(FXmacCfgInitialize(instance_p, &mac_config)) - { - return -EIO; - } - - FXmacSetOptions(instance_p, xmac_options, 0); - - /* set mac address */ - if(FXmacSetMacAddress(instance_p, (void *)(dev_data->mac_addr), 0)) - { - return -EIO; - } - - if(mac_config.interface != FXMAC_PHY_INTERFACE_MODE_USXGMII) - { - /* initialize phy */ - if(FXmacPhyInit(instance_p, instance_p->config.speed, instance_p->config.duplex, instance_p->config.auto_neg,XMAC_PHY_RESET_ENABLE)) - { - LOG_WRN("FXmacPhyInit is error \r\n"); - } - } - - FXmacSelectClk(instance_p); - FXmacInitInterface(instance_p); - - /* initialize dma */ - dmacrreg = FXMAC_READREG32(instance_p->config.base_address, FXMAC_DMACR_OFFSET); - dmacrreg &= ~(FXMAC_DMACR_BLENGTH_MASK); - dmacrreg = dmacrreg | FXMAC_DMACR_INCR16_AHB_AXI_BURST; /* Attempt to use bursts of up to 16. */ - FXMAC_WRITEREG32(instance_p->config.base_address, FXMAC_DMACR_OFFSET, dmacrreg); - /* setup dma bdl */ - eth_phytium_xmac_setuphandler(dev) ; - instance_p->mask = ((u32)FXMAC_IXR_TX_ERR_MASK - | (u32)FXMAC_IXR_RX_ERR_MASK - | (u32)FXMAC_IXR_RXCOMPL_MASK - | (u32)FXMAC_IXR_TXCOMPL_MASK); - /* setup tx、rx intr */ - FXmacSetupIsr(dev) ; - - return 0 ; -} - - - - +// Phytium is pleased to support the open source community by making Zephyr-SDK available. + +// +// Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +// +// Licensed under the Apache-2.0 License (the "License"); you may not use this file except +// in compliance with the License. You may obtain a copy of the License at +// +// https://opensource.org/license/apache-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 "fxmac.h" +#include "fxmac_hw.h" +#include "fxmac_bdring.h" +#include "fxmac_phy.h" +#include "eth_ieee_reg.h" +#include "eth_phytium_xmac.h" + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + + + +#define LOG_MODULE_NAME phytium_xmac +#define LOG_LEVEL CONFIG_ETHERNET_LOG_LEVEL +#include +LOG_MODULE_REGISTER(LOG_MODULE_NAME); + +#define DT_DRV_COMPAT phytium_xmac + + +/* dma buffer */ +#define ETH_PHYTIUM_BDL_ALIGNMENT 256 +#define ETH_PHYTIUM_BUFFER_ALIGNMENT ETH_PHYTIUM_BDL_ALIGNMENT +#define ETH_ALIGNMENT_OFFSET_DEFINED(buffer_size) ((buffer_size\ + + (ETH_PHYTIUM_BUFFER_ALIGNMENT - 1))\ + & ~(ETH_PHYTIUM_BUFFER_ALIGNMENT - 1)) + + +/* IRQ handler function type */ +typedef void (*eth_phytiium_xmac_config_irq_t)(const struct device *dev); + +typedef enum +{ + FXMAC_LWIP_PORT_INTERFACE_SGMII = 0, + FXMAC_LWIP_PORT_INTERFACE_RMII, + FXMAC_LWIP_PORT_INTERFACE_RGMII, + FXMAC_LWIP_PORT_INTERFACE_USXGMII, + FXMAC_LWIP_PORT_INTERFACE_LENGTH +} FXmacLwipPortInterface; + + +#define FXMAC_PHY_SPEED_10M 10 +#define FXMAC_PHY_SPEED_100M 100 +#define FXMAC_PHY_SPEED_1000M 1000 +#define FXMAC_PHY_SPEED_10G 10000 + + +/* phy link */ +enum eth_phytium_link_speed { + /* The values of this enum are consecutively numbered */ + LINK_DOWN = 0, + LINK_10MBIT, + LINK_100MBIT, + LINK_1GBIT +}; + +#define FXMAC_BD_TO_INDEX(ringptr, bdptr) \ + (((uintptr)bdptr - (uintptr)(ringptr)->base_bd_addr) / (ringptr)->separation) + +struct eth_phytium_xmac_dev_cfg { + DEVICE_MMIO_ROM; + uint32_t instance_id ; /* */ + eth_phytiium_xmac_config_irq_t config_func; + uint32_t pll_clock_frequency; + + uint32_t phy_poll_interval; + uint8_t defer_rxp_to_queue; + uint8_t defer_txd_to_queue; + + uint8_t rxbd_count; /* rx bdl count */ + uint8_t txbd_count; /* tx bdl count */ + uint16_t rx_buffer_size; /* per buffer size */ + uint16_t tx_buffer_size; + + /* dtc defined */ + uint32_t phy_speed ; /* FXMAC_PHY_SPEED_XX */ + uint32_t interface_mode ; /* followed by FXmacLwipPortInterface */ + uint32_t dma_brust_length ; + uint32_t max_queue_num; /* Number of Xmac Controller Queues */ + bool phy_autonegotiation : 1 ; + bool enable_fdx : 1 ; + bool enable_jumbo : 1; + bool enable_ucast_hash :1; + bool copy_all_frames :1; + bool disable_reject_fcs_crc_errors:1; + bool enable_mcast_hash :1; + +}; + + +struct eth_phytium_xmac_dev_data { + DEVICE_MMIO_RAM; /* used for controller base address */ + struct net_if *iface; + FXmac instance ; + uint8_t mac_addr[6]; + enum eth_phytium_link_speed eff_link_speed ; + struct k_work tx_done_work; + struct k_work rx_pend_work; + struct k_sem tx_done_sem; + + struct k_sem ring_sem; + + uint8_t phy_addr; + uint32_t phy_id; + struct k_work_delayable phy_poll_delayed_work; + +#ifdef CONFIG_NET_STATISTICS_ETHERNET + struct net_stats_eth stats; +#endif + + uint8_t *rx_bdspace ; + uint8_t *rx_bdspace_virt ; + uint8_t *tx_bdspace ; + uint8_t *tx_bdspace_virt ; + + uint8_t *first_rx_buffer ; + uint8_t *first_rx_buffer_virt ; + uint8_t *first_tx_buffer ; + uint8_t *first_tx_buffer_virt ; + + bool started; +}; + + +static int eth_phytium_xmac_dev_init(const struct device *dev) ; +static void eth_phytium_xmac_iface_init(struct net_if *iface) ; +static enum ethernet_hw_caps eth_phytium_xmac_get_capabilities(const struct device *dev) ; +static int eth_phytium_xmac_send(const struct device *dev, struct net_pkt *pkt) ; +static int eth_phytium_xmac_start_device(const struct device *dev) ; +static int eth_phytium_xmac_stop_device(const struct device *dev) ; +#ifdef CONFIG_NET_STATISTICS_ETHERNET +static struct net_stats_eth *eth_phytium_xmac_stats(const struct device *dev) ; +#endif + +static void eth_phytium_xmac_isr(const struct device *dev) ; + +static const struct ethernet_api eth_phytium_xmac_apis = { + .iface_api.init = eth_phytium_xmac_iface_init, + .get_capabilities = eth_phytium_xmac_get_capabilities, + .send = eth_phytium_xmac_send, + .start = eth_phytium_xmac_start_device, + .stop = eth_phytium_xmac_stop_device, +#if defined(CONFIG_NET_STATISTICS_ETHERNET) + .get_stats = eth_phytium_xmac_stats, +#endif +}; + + +/* + * Insert the configuration & run-time data for all GEM instances which + * are enabled in the device tree of the current target board. + */ +DT_INST_FOREACH_STATUS_OKAY(ETH_PHYTIUM_XMAC_INITIALIZE) + + +static void FXmacSetupIsr(const struct device *dev) ; + +static uint32_t phy_autoneg_status(FXmac *xmac_p, uint32_t phy_addr) +{ + u16 status; + + /* Read Phy Status register twice to get the confirmation of the current + * link status. + */ + FXmacPhyRead(xmac_p, phy_addr, PHY_STATUS_REG_OFFSET, &status); + + if (status & PHY_STATUS_AUTONEGOTIATE_COMPLETE) + return 1; + return 0; +} + +/** + * @name: phy_link_detect + * @msg: Get current link status + * @note: + * @param {FXmac} *fxmac_p + * @param {u32} phy_addr + * @return {*} 1 is link up , 0 is link down + */ +static u32 phy_link_detect(FXmac *xmac_p, u32 phy_addr) +{ + u16 status; + + /* Read Phy Status register twice to get the confirmation of the current + * link status. + */ + + FXmacPhyRead(xmac_p, phy_addr, PHY_STATUS_REG_OFFSET, &status); + + if (status & PHY_STAT_LINK_STATUS) + return 1; + return 0; +} + +FXmacLinkStatus FXmacRgmiiLinkDetect(const struct device *dev) +{ + struct eth_phytium_xmac_dev_data *dev_data = (struct eth_phytium_xmac_dev_data *)dev->data ; + FXmac *instance_p; + instance_p = &dev_data->instance; + + u32 phy_link_status; + + + phy_link_status = phy_link_detect(instance_p, instance_p->phy_address); + + if ((instance_p->link_status == FXMAC_LINKUP) && (!phy_link_status)) + instance_p->link_status = FXMAC_LINKDOWN; + + switch (instance_p->link_status) + { + case FXMAC_LINKUP: + return FXMAC_LINKUP; + case FXMAC_LINKDOWN: + instance_p->link_status = FXMAC_NEGOTIATING; + LOG_DBG("Ethernet Link down"); + return FXMAC_LINKDOWN; + case FXMAC_NEGOTIATING: + if ((phy_link_status == FXMAC_LINKUP) && phy_autoneg_status(instance_p, instance_p->phy_address)) + { + if(FXmacPhyInit(instance_p, instance_p->config.speed, instance_p->config.duplex, instance_p->config.auto_neg, XMAC_PHY_RESET_DISABLE)) + { + return FXMAC_LINKDOWN; + } + + FXmacSelectClk(instance_p); + FXmacInitInterface(instance_p); + + /* Initiate Phy setup to get link speed */ + instance_p->link_status = FXMAC_LINKUP; + LOG_DBG("Ethernet Link up"); + return FXMAC_LINKUP; + } + return FXMAC_LINKDOWN; + default: + return FXMAC_LINKDOWN; + } +} + +FXmacLinkStatus FXmacSgmiiLinkDetect(const struct device *dev) +{ + struct eth_phytium_xmac_dev_data *dev_data = (struct eth_phytium_xmac_dev_data *)dev->data ; + FXmac *instance_p; + u32 ctrl; + u32 link, link_status; + instance_p = &dev_data->instance; + + ctrl = FXMAC_READREG32(instance_p->config.base_address, FXMAC_PCS_AN_LP_OFFSET); + link = (ctrl & FXMAC_PCS_LINK_PARTNER_NEXT_PAGE_STATUS) >> FXMAC_PCS_LINK_PARTNER_NEXT_PAGE_OFFSET; + + switch (link) + { + case 0: + link_status = FXMAC_LINKDOWN; + break; + case 1: + link_status = FXMAC_LINKUP; + break; + default: + LOG_ERR("link status is error 0x%x \r\n", link); + return FXMAC_LINKDOWN; + } + + if (link_status == FXMAC_LINKUP) + { + if (link_status != instance_p->link_status) + { + instance_p->link_status = FXMAC_NEGOTIATING; + LOG_INF("need NEGOTIATING"); + } + } + else + { + instance_p->link_status = FXMAC_LINKDOWN; + } + + if (instance_p->link_status == FXMAC_NEGOTIATING) + { + /* renegotiate */ + if (FXmacPhyInit(instance_p, instance_p->config.speed, instance_p->config.duplex, instance_p->config.auto_neg,XMAC_PHY_RESET_DISABLE)) + { + LOG_ERR("FXmacPhyInit is error \r\n"); + return FXMAC_LINKDOWN; + } + else + { + FXmacSelectClk(instance_p); + FXmacInitInterface(instance_p); + instance_p->link_status = FXMAC_LINKUP; + return FXMAC_LINKUP; + } + } + return instance_p->link_status ; +} + +static void eth_phytium_xmac_poll_phy(struct k_work *work) +{ + struct k_work_delayable *dwork = k_work_delayable_from_work(work); + struct eth_phytium_xmac_dev_data *dev_data = CONTAINER_OF(dwork, + struct eth_phytium_xmac_dev_data, phy_poll_delayed_work); + const struct device *dev = net_if_get_device(dev_data->iface); + const struct eth_phytium_xmac_dev_cfg *dev_conf = dev->config; + FXmacLinkStatus link_status = FXMAC_LINKDOWN ; + FXmac *instance_p; + instance_p = &dev_data->instance; + + if(instance_p->config.interface == FXMAC_PHY_INTERFACE_MODE_SGMII) + { + link_status = FXmacSgmiiLinkDetect(dev) ; + } + else if((instance_p->config.interface == FXMAC_PHY_INTERFACE_MODE_RMII) || (instance_p->config.interface == FXMAC_PHY_INTERFACE_MODE_RGMII)) + { + link_status = FXmacRgmiiLinkDetect(dev) ; + } + + if(link_status == FXMAC_LINKDOWN) + { + dev_data->eff_link_speed = LINK_DOWN; + net_eth_carrier_off(dev_data->iface); + + LOG_WRN("%s link down", dev->name); + } + else if(link_status == FXMAC_LINKUP) + { + switch(instance_p->config.speed) + { + case FXMAC_SPEED_10: + dev_data->eff_link_speed = LINK_10MBIT ; + break ; + case FXMAC_SPEED_100: + dev_data->eff_link_speed = LINK_100MBIT ; + break ; + case FXMAC_SPEED_1000: + dev_data->eff_link_speed = LINK_1GBIT ; + break ; + } + net_eth_carrier_on(dev_data->iface); + } + + k_work_reschedule(&dev_data->phy_poll_delayed_work, + K_MSEC(dev_conf->phy_poll_interval)); + +} + +/** + * @name: eth_phytium_xmac_get_capabilities + * @msg: Reports the hardware capabilities of the Ethernet device, such as supported speeds and duplex modes. + * @param {const struct device} *dev is a pointer to the device structure for the driver instance. + * @return {enum ethernet_hw_caps} A bitmask of supported features defined in `enum ethernet_hw_caps`. + */ +static enum ethernet_hw_caps eth_phytium_xmac_get_capabilities(const struct device *dev) +{ + struct eth_phytium_xmac_dev_cfg *dev_cfg = (struct eth_phytium_xmac_dev_cfg *)dev->config ; + enum ethernet_hw_caps caps = (enum ethernet_hw_caps)0; + + switch (dev_cfg->phy_speed) + { + case FXMAC_PHY_SPEED_10M: + caps |= ETHERNET_LINK_10BASE_T; + break; + case FXMAC_PHY_SPEED_100M: + caps |= (ETHERNET_LINK_100BASE_T | + ETHERNET_LINK_10BASE_T); + break; + case FXMAC_PHY_SPEED_1000M: + caps |= (ETHERNET_LINK_1000BASE_T | + ETHERNET_LINK_100BASE_T | + ETHERNET_LINK_10BASE_T); + break; + case FXMAC_PHY_SPEED_10G: + caps |= (ETHERNET_LINK_1000BASE_T | + ETHERNET_LINK_100BASE_T | + ETHERNET_LINK_10BASE_T); + break; + } + + if (dev_cfg->enable_fdx) { + caps |= ETHERNET_DUPLEX_SET; + } + + if (dev_cfg->copy_all_frames) { + caps |= ETHERNET_PROMISC_MODE; + } + return caps; +} + +static int eth_phytium_xmac_config_convert(struct eth_phytium_xmac_dev_cfg *dev_conf,FXmacConfig *mac_config,uint32_t *options) +{ + *options = 0 ; + switch (dev_conf->interface_mode) + { + case FXMAC_LWIP_PORT_INTERFACE_SGMII: + mac_config->interface = FXMAC_PHY_INTERFACE_MODE_SGMII; + LOG_INF("SGMII select"); + break; + case FXMAC_LWIP_PORT_INTERFACE_RMII: + mac_config->interface = FXMAC_PHY_INTERFACE_MODE_RMII; + LOG_INF("RMII select"); + break; + case FXMAC_LWIP_PORT_INTERFACE_RGMII: + LOG_INF("RGMII select"); + mac_config->interface = FXMAC_PHY_INTERFACE_MODE_RGMII; + break; + case FXMAC_LWIP_PORT_INTERFACE_USXGMII: + LOG_INF("USXGMII select"); + mac_config->interface = FXMAC_PHY_INTERFACE_MODE_USXGMII; + break; + default: + return -EINVAL; + } + + switch (dev_conf->phy_speed) + { + case FXMAC_PHY_SPEED_10M: + mac_config->speed = FXMAC_SPEED_10; + break; + case FXMAC_PHY_SPEED_100M: + mac_config->speed = FXMAC_SPEED_100; + break; + case FXMAC_PHY_SPEED_1000M: + mac_config->speed = FXMAC_SPEED_1000; + break; + case FXMAC_PHY_SPEED_10G: + LOG_INF("select FXMAC_PHY_SPEED_10G"); + mac_config->speed = FXMAC_SPEED_10000; + break; + default: + return -EINVAL; + } + + mac_config->duplex = dev_conf->enable_fdx? 1:0 ; /* 1 is full-duplex , 0 is half-duplex */ + mac_config->auto_neg = dev_conf->phy_autonegotiation ; /* Enable auto-negotiation - when set active high, + autonegotiation operation is enabled. */ + mac_config->pclk_hz = dev_conf->pll_clock_frequency ; + mac_config->max_queue_num = dev_conf->max_queue_num ; /* Number of Xmac Controller Queues */ + mac_config->tx_queue_id = 0 ; /* 0 ~ FXMAC_QUEUE_MAX_NUM ,Index queue number */ + mac_config->rx_queue_id = 0 ; /* 0 ~ FXMAC_QUEUE_MAX_NUM ,Index queue number */ + mac_config->dma_brust_length = dev_conf->dma_brust_length ; /* burst length */ + mac_config->network_default_config = FXMAC_DEFAULT_OPTIONS ; + mac_config->caps = 0 ; /* used to configure tail ptr feature */ + + /* options */ + if(dev_conf->enable_jumbo) + { + *options |= FXMAC_JUMBO_ENABLE_OPTION ; + } + + if(dev_conf->enable_ucast_hash) + { + *options |= FXMAC_UNICAST_OPTION; + } + + if(dev_conf->enable_mcast_hash) + { + *options |= FXMAC_MULTICAST_OPTION; + } + + if(dev_conf->copy_all_frames) + { + *options |= FXMAC_PROMISC_OPTION; + } + + if(dev_conf->disable_reject_fcs_crc_errors) + { + *options |= FXMAC_FCS_STRIP_OPTION; + } + + + return 0 ; +} + +/* irq init */ +static int eth_phytium_xmac_setuphandler(const struct device *dev) +{ + + struct eth_phytium_xmac_dev_cfg *dev_conf = (struct eth_phytium_xmac_dev_cfg *)dev->config ; + struct eth_phytium_xmac_dev_data *dev_data = (struct eth_phytium_xmac_dev_data *)dev->data ; + FXmac *instance_p; + + FXmacBd bdtemplate; + FXmacBdRing *rxringptr, *txringptr; + FXmacBd *rxbd; + int i; + u32 bdindex; + u32 *temp; + instance_p = &dev_data->instance; + /* init buffer to data */ + /* Initial configuration of the RX/TX BD rings */ + DT_INST_FOREACH_STATUS_OKAY(ETH_PHYTIUM_XMAC_INIT_BD_RING) + rxringptr = &FXMAC_GET_RXRING((*instance_p)); + txringptr = &FXMAC_GET_TXRING((*instance_p)); + + /* Setup RxBD space. */ + FXMAC_BD_CLEAR(&bdtemplate); + + /* Create the RxBD ring */ + if(FXmacBdRingCreate(rxringptr, (uintptr)dev_data->rx_bdspace, + (uintptr)dev_data->rx_bdspace, + ETH_PHYTIUM_BDL_ALIGNMENT, + dev_conf->rxbd_count)) + { + LOG_ERR("Error setting up RxBD space\r\n"); + return -EIO ; + } + + if(FXmacBdRingClone(rxringptr, &bdtemplate, FXMAC_RECV)) + { + LOG_ERR("Error initializing RxBD space\r\n"); + return -EIO; + } + + FXMAC_BD_CLEAR(&bdtemplate); + FXMAC_BD_SET_STATUS(&bdtemplate, FXMAC_TXBUF_USED_MASK); + + + /* Create the TxBD ring */ + if (FXmacBdRingCreate(txringptr, (uintptr)dev_data->tx_bdspace, + (uintptr)dev_data->tx_bdspace, ETH_PHYTIUM_BDL_ALIGNMENT, + dev_conf->txbd_count)) + { + return -EIO; + } + + /* We reuse the bd template, as the same one will work for both rx and tx. */ + if(FXmacBdRingClone(txringptr, &bdtemplate, FXMAC_SEND)) + { + return -EIO; + } + + /* init rx buffer */ + for (i = 0; i < dev_conf->rxbd_count; i++) + { + if(FXmacBdRingAlloc(rxringptr, 1, &rxbd)) + { + LOG_ERR("InitDma: Error allocating RxBD\r\n"); + return -ERANGE; + } + + /* Enqueue to HW */ + if(FXmacBdRingToHw(rxringptr, 1, rxbd)) + { + LOG_ERR("Error: committing RxBD to HW\r\n"); + FXmacBdRingUnAlloc(rxringptr, 1, rxbd); + return -ERANGE; + } + + bdindex = FXMAC_BD_TO_INDEX(rxringptr, rxbd); + temp = (u32 *)rxbd; + *temp = 0; + if (bdindex == (dev_conf->rxbd_count - 1)) + { + *temp = 0x00000002; /* Marks last descriptor in receive buffer descriptor list */ + } + temp++; + *temp = 0; /* Clear word 1 in descriptor */ + + FXMAC_BD_SET_ADDRESS_RX(rxbd, (uintptr)(dev_data->first_rx_buffer_virt + ETH_ALIGNMENT_OFFSET_DEFINED(dev_conf->rx_buffer_size)*bdindex)); + + } + FXmacSetQueuePtr(instance_p, instance_p->tx_bd_queue.bdring.phys_base_addr, 0, (u16)FXMAC_SEND); + FXmacSetQueuePtr(instance_p, instance_p->rx_bd_queue.bdring.phys_base_addr, 0, (u16)FXMAC_RECV); + + return 0; +} + + + +static void eth_phytium_xmac_handle_tx_done(const struct device *dev) +{ + struct eth_phytium_xmac_dev_data *dev_data = (struct eth_phytium_xmac_dev_data *)dev->data ; + struct eth_phytium_xmac_dev_cfg *dev_conf = (struct eth_phytium_xmac_dev_cfg *)dev->config ; + FXmac *instance_p; + FXmacBd *txbdset; + FXmacBd *curbdpntr; + u32 n_bds; + FError status; + u32 n_pbufs_freed = 0; + u32 bdindex; + u32 *temp; + instance_p = &dev_data->instance ; + FXmacBdRing *txring; + + if (dev_conf->defer_txd_to_queue) { + k_sem_take(&(dev_data->ring_sem), K_FOREVER); + } + txring = &(FXMAC_GET_TXRING((*instance_p))); + while (1) + { + /* obtain processed BD's */ + n_bds = FXmacBdRingFromHwTx(txring, dev_conf->txbd_count, &txbdset); + if (n_bds == 0) + { + break; + } + /* free the processed BD's */ + n_pbufs_freed = n_bds; + curbdpntr = txbdset; + while (n_pbufs_freed > 0) + { + bdindex = FXMAC_BD_TO_INDEX(txring, curbdpntr); + temp = (u32 *)curbdpntr; + *temp = 0; /* Word 0 */ + temp++; + + if (bdindex == (dev_conf->txbd_count - 1)) + { + *temp = 0xC0000000; /* Word 1 ,used/Wrap – marks last descriptor in transmit buffer descriptor list.*/ + } + else + { + *temp = 0x80000000; /* Word 1 , Used – must be zero for GEM to read data to the transmit buffer.*/ + } + + curbdpntr = FXMAC_BD_RING_NEXT(txring, curbdpntr); + n_pbufs_freed--; + + } + + status = FXmacBdRingFree(txring, n_bds, txbdset); + if (status != FT_SUCCESS) + { + LOG_ERR("Failure while freeing in Tx Done ISR\r\n"); + } + } + + if (dev_conf->defer_txd_to_queue) { + k_sem_give(&(dev_data->ring_sem)); + } + + /* Re-enable the TX complete interrupt source */ + FXMAC_WRITEREG32(instance_p->config.base_address,FXMAC_IER_OFFSET,FXMAC_IXR_TXCOMPL_MASK) ; + + /* Indicate completion to a blocking eth_xlnx_gem_send() call */ + k_sem_give(&dev_data->tx_done_sem); +} + +static void eth_phytium_xmac_tx_done_work(struct k_work *item) +{ + struct eth_phytium_xmac_dev_data *dev_data = CONTAINER_OF(item, struct eth_phytium_xmac_dev_data, tx_done_work); + const struct device *dev = net_if_get_device(dev_data->iface); + + eth_phytium_xmac_handle_tx_done(dev); +} + +/** + * @name: eth_phytium_xmac_send + * @msg: Sends an Ethernet frame. The frame is contained in a packet that is managed by the networking stack. + * @param {const struct device} *dev is a pointer to the device structure for the driver instance. + * @param {struct net_pkt} *pkt is a pointer to the network packet that contains the data to be sent. + * @return {int} Zero on success or negative error code on failure. + */ +static int eth_phytium_xmac_send(const struct device *dev, struct net_pkt *pkt) +{ + struct eth_phytium_xmac_dev_cfg *dev_conf = (struct eth_phytium_xmac_dev_cfg *)dev->config ; + struct eth_phytium_xmac_dev_data *dev_data = (struct eth_phytium_xmac_dev_data *)dev->data ; + FXmac *instance_p; + + FXmacBd *txbdset, *txbd, *last_txbd = NULL; + FXmacBdRing *txring; + u32 bdindex; + + uint16_t tx_data_length; + uint16_t tx_data_remaining; + void *tx_buffer_offs; + uint32_t bds_reqd; + uint32_t tx_length = 0 ; + instance_p = &dev_data->instance; + txring = &FXMAC_GET_TXRING((*instance_p)); + + if (!dev_data->started || dev_data->eff_link_speed == LINK_DOWN || + (!net_if_flag_is_set(dev_data->iface, NET_IF_UP))) { +#ifdef CONFIG_NET_STATISTICS_ETHERNET + dev_data->stats.tx_dropped++; +#endif + return -EIO; + } + + tx_data_length = tx_data_remaining = net_pkt_get_len(pkt); + if (tx_data_length == 0) { + LOG_ERR("%s cannot TX, zero packet length", dev->name); +#ifdef CONFIG_NET_STATISTICS_ETHERNET + dev_data->stats.errors.tx++; +#endif + return -EINVAL; + } + + bds_reqd = (uint8_t)((tx_data_length + (dev_conf->tx_buffer_size - 1)) / + dev_conf->tx_buffer_size); + + if (dev_conf->defer_txd_to_queue) { + k_sem_take(&(dev_data->ring_sem), K_FOREVER); + } else { + FXMAC_WRITEREG32(instance_p->config.base_address,FXMAC_IDR_OFFSET,FXMAC_IXR_TXCOMPL_MASK) ; + } + + /* obtain as many BD's */ + if(FXmacBdRingAlloc(txring, bds_reqd, &txbdset)) + { + LOG_ERR("sgsend: Error allocating TxBD\r\n"); +#ifdef CONFIG_NET_STATISTICS_ETHERNET + dev_data->stats.tx_dropped++; +#endif + FXMAC_WRITEREG32(instance_p->config.base_address,FXMAC_IER_OFFSET,FXMAC_IXR_TXCOMPL_MASK) ; + return ERR_GENERAL; + } + + if (dev_conf->defer_txd_to_queue) { + k_sem_give(&(dev_data->ring_sem)); + } else { + FXMAC_WRITEREG32(instance_p->config.base_address,FXMAC_IER_OFFSET,FXMAC_IXR_TXCOMPL_MASK) ; + } + + /* + * Scatter the contents of the network packet's buffer to + * one or more DMA buffers. + */ + net_pkt_cursor_init(pkt); + txbd = txbdset ; + while (tx_data_remaining) + { + bdindex = FXMAC_BD_TO_INDEX(txring, txbd); + + /* Calculate the base pointer of the target TX buffer */ + tx_buffer_offs = (void *)(dev_data->first_tx_buffer + + (ETH_ALIGNMENT_OFFSET_DEFINED(dev_conf->tx_buffer_size) * bdindex)); + + /* Copy packet data to DMA buffer */ + tx_length = (tx_data_remaining < dev_conf->tx_buffer_size) ? + tx_data_remaining : dev_conf->tx_buffer_size ; + net_pkt_read(pkt, (void *)tx_buffer_offs,tx_length); + + FXMAC_BD_SET_ADDRESS_TX(txbd, (uintptr)tx_buffer_offs); + + FXMAC_BD_SET_LENGTH(txbd, tx_length & 0x3FFF); + + last_txbd = txbd; + FXMAC_BD_CLEAR_LAST(txbd); + txbd = FXMAC_BD_RING_NEXT(txring, txbd); + tx_data_remaining -= (tx_data_remaining < dev_conf->tx_buffer_size) ? + tx_data_remaining : dev_conf->tx_buffer_size; + } + FXMAC_BD_SET_LAST(last_txbd); + FXMAC_BD_CLEAR_TX_USED(last_txbd); + + if(FXmacBdRingToHw(txring, bds_reqd, txbdset)) + { + LOG_ERR("sgsend: Error submitting TxBD\r\n"); + } + + /* Start transmit */ + FXMAC_WRITEREG32(instance_p->config.base_address, + FXMAC_NWCTRL_OFFSET, + (FXMAC_READREG32(instance_p->config.base_address, + FXMAC_NWCTRL_OFFSET) | + FXMAC_NWCTRL_STARTTX_MASK)); + +#ifdef CONFIG_NET_STATISTICS_ETHERNET + dev_data->stats.bytes.sent += tx_data_length; + dev_data->stats.pkts.tx++; +#endif + + return 0 ; +} + +static void eth_phytium_xmac_setup_rx_bds(const struct device *dev,FXmacBdRing *rxring) +{ + const struct eth_phytium_xmac_dev_cfg *dev_conf = dev->config; + struct eth_phytium_xmac_dev_data *dev_data = dev->data; + FXmacBd *rxbd; + FError status; + u32 freebds; + u32 bdindex; + u32 *temp; + FXmac *instance_p; + instance_p = &dev_data->instance ; + + freebds = FXMAC_BD_RING_GET_FREE_CNT(rxring); + while (freebds > 0) + { + freebds --; + status = FXmacBdRingAlloc(rxring, 1, &rxbd); + if (status != FT_SUCCESS) + { + LOG_ERR("SetupRxBds: Error allocating RxBD\r\n"); + return; + } + status = FXmacBdRingToHw(rxring, 1, rxbd); + if (status != FT_SUCCESS) + { + LOG_ERR("Error committing RxBD to hardware: "); + if (status == FXMAC_ERR_SG_LIST) + { + LOG_ERR("XST_DMA_SG_LIST_ERROR: this function was called out of sequence with FXmacBdRingAlloc()\r\n"); + } + else + { + LOG_ERR("set of BDs was rejected because the first BD did not have its start-of-packet bit set, or the last BD did not have its end-of-packet bit set, or any one of the BD set has 0 as length value\r\n"); + } + + FXmacBdRingUnAlloc(rxring, 1, rxbd); + return; + } + + + bdindex = FXMAC_BD_TO_INDEX(rxring, rxbd); + temp = (u32 *)rxbd; + if (bdindex == (dev_conf->rxbd_count - 1)) + { + *temp = 0x00000002; /* Mask last descriptor in receive buffer list */ + } + else + { + *temp = 0; + } + temp++; + *temp = 0; + + FXMAC_BD_SET_ADDRESS_RX(rxbd, (uintptr)(dev_data->first_rx_buffer_virt + ETH_ALIGNMENT_OFFSET_DEFINED(dev_conf->rx_buffer_size)*bdindex)); + + } +} + +static void eth_phytium_xmac_handle_rx_pending(const struct device *dev) +{ + const struct eth_phytium_xmac_dev_cfg *dev_conf = dev->config; + struct eth_phytium_xmac_dev_data *dev_data = dev->data; + FXmacBd *rxbdset, *curbdptr; + FXmacBdRing *rxring; + volatile u32 bd_processed; + u32 k; + u32 bdindex; + FXmac *instance_p; + struct net_pkt *pkt; + uint32_t rx_data_length; + instance_p = &dev_data->instance ; + rxring = &FXMAC_GET_RXRING((*instance_p)); + + /* Re-enable the frame received interrupt source */ + FXMAC_WRITEREG32(instance_p->config.base_address,FXMAC_IER_OFFSET,FXMAC_IXR_RXCOMPL_MASK); + + while (1) + { + bd_processed = FXmacBdRingFromHwRx(rxring, dev_conf->rxbd_count, &rxbdset); + if (bd_processed <= 0) + { + break; + } + + for (k = 0, curbdptr = rxbdset; k < bd_processed; k++) + { + bdindex = FXMAC_BD_TO_INDEX(rxring, curbdptr); + rx_data_length = FXMAC_BD_GET_LENGTH(curbdptr); + if(rx_data_length > dev_conf->rx_buffer_size) + { + LOG_ERR("rx_data_length length is error: %u bytes \r\n", + rx_data_length); + goto error_exit ; + } + + pkt = net_pkt_rx_alloc_with_buffer(dev_data->iface, rx_data_length, + AF_UNSPEC, 0, K_FOREVER); + if (pkt == NULL) + { + LOG_ERR("RX packet buffer alloc failed: %u bytes", + rx_data_length); +#ifdef CONFIG_NET_STATISTICS_ETHERNET + dev_data->stats.errors.rx++; + dev_data->stats.error_details.rx_no_buffer_count++; +#endif + /* free up the BD's */ + goto error_exit ; + } + + net_pkt_write(pkt, (const void *) + (dev_data->first_rx_buffer_virt + ETH_ALIGNMENT_OFFSET_DEFINED(dev_conf->rx_buffer_size)*bdindex), + rx_data_length); + + if (net_recv_data(dev_data->iface, pkt) < 0) { + printf("%s RX packet hand-over to IP stack failed", dev->name); + net_pkt_unref(pkt); + } +#ifdef CONFIG_NET_STATISTICS_ETHERNET + else { + dev_data->stats.bytes.received += rx_data_length; + dev_data->stats.pkts.rx++; + } +#endif + curbdptr = FXMAC_BD_RING_NEXT(rxring, curbdptr); + } + FXmacBdRingFree(rxring, bd_processed, rxbdset); + eth_phytium_xmac_setup_rx_bds(dev,rxring) ; + } + + return; + +error_exit: + printf("eth_phytium_xmac_handle_rx_pending error exit \r\n") ; + FXmacBdRingFree(rxring, bd_processed, rxbdset); +} + +static void eth_phytium_xmac_rx_pending_work(struct k_work *item) +{ + struct eth_phytium_xmac_dev_data *dev_data = CONTAINER_OF(item, + struct eth_phytium_xmac_dev_data, rx_pend_work); + const struct device *dev = net_if_get_device(dev_data->iface); + + eth_phytium_xmac_handle_rx_pending(dev); +} + + +static void FXmacSendHandler(void *arg) +{ + const struct device *dev = (const struct device *)arg; + struct eth_phytium_xmac_dev_data *dev_data = dev->data; + const struct eth_phytium_xmac_dev_cfg *dev_conf = dev->config; + FXmac *instance_p; + instance_p = &dev_data->instance; + + FXMAC_WRITEREG32(instance_p->config.base_address, FXMAC_IDR_OFFSET,FXMAC_IXR_TXCOMPL_MASK); + if (dev_conf->defer_txd_to_queue) + { + k_work_submit(&dev_data->tx_done_work); + } + else + { + eth_phytium_xmac_handle_tx_done(dev); + } +} + +static void FXmacRecvHandler(void *arg) +{ + const struct device *dev = (const struct device *)arg ; + struct eth_phytium_xmac_dev_data *dev_data = dev->data; + const struct eth_phytium_xmac_dev_cfg *dev_conf = dev->config; + FXmac *instance_p; + instance_p = &dev_data->instance ; + + FXMAC_WRITEREG32(instance_p->config.base_address,FXMAC_IDR_OFFSET,FXMAC_IXR_RXCOMPL_MASK) ; + + if (dev_conf->defer_rxp_to_queue) + { + k_work_submit(&dev_data->rx_pend_work); + } + else + { + printk("recv data \r\n") ; + eth_phytium_xmac_handle_rx_pending(dev); + printk("recv data exit \r\n") ; + } +} + +/* interrupt */ +static void FXmacHandleDmaTxError( const struct device *dev) +{ + u32 dmacrreg; + struct eth_phytium_xmac_dev_data *dev_data = (struct eth_phytium_xmac_dev_data *)dev->data; + FXmac *instance_p; + instance_p = &dev_data->instance ; + /* initialize the mac */ + if (FXmacCfgInitialize(instance_p, &instance_p->config)) + { + LOG_ERR("In %s:EmacPs Configuration Failed....\r\n", __func__); + } + + /* set mac address */ + FXmacSetMacAddress(instance_p, (void *)(dev_data->mac_addr), 0) ; + + dmacrreg = FXMAC_READREG32(instance_p->config.base_address, FXMAC_DMACR_OFFSET); + dmacrreg = dmacrreg | (FXMAC_DMACR_ORCE_DISCARD_ON_ERR_MASK); + FXMAC_WRITEREG32(instance_p->config.base_address, FXMAC_DMACR_OFFSET, dmacrreg); + /* setup dma bdl */ + eth_phytium_xmac_setuphandler(dev) ; + FXmacSetupIsr(dev); + + FXmacStart(instance_p); +} + +static void eth_phytium_xmac_tx_dma_init(const struct device *dev) +{ + struct eth_phytium_xmac_dev_data *dev_data = (struct eth_phytium_xmac_dev_data *)dev->data ; + struct eth_phytium_xmac_dev_cfg *dev_conf = (struct eth_phytium_xmac_dev_cfg *)dev->config ; + FXmac *instance_p; + instance_p = &dev_data->instance ; + FXmacBd bdtemplate; + FXmacBdRing *txringptr; + + txringptr = &FXMAC_GET_TXRING((*instance_p)); + FXMAC_BD_CLEAR(&bdtemplate); + FXMAC_BD_SET_STATUS(&bdtemplate, FXMAC_TXBUF_USED_MASK); + + if (FXmacBdRingCreate(txringptr, (uintptr)dev_data->tx_bdspace, + (uintptr)dev_data->tx_bdspace, ETH_PHYTIUM_BDL_ALIGNMENT, + dev_conf->txbd_count)) + { + LOG_ERR("FXmacBdRingCreate is error") ; + return ; + } + + FXmacBdRingClone(txringptr, &bdtemplate, FXMAC_SEND); +} + +static void FXmacHandleTxErrors( const struct device *dev) +{ + struct eth_phytium_xmac_dev_data *dev_data = (struct eth_phytium_xmac_dev_data *)dev->data ; + FXmac *instance_p; + + instance_p = &dev_data->instance ; + + u32 netctrlreg; + + netctrlreg = FXMAC_READREG32(instance_p->config.base_address, + FXMAC_NWCTRL_OFFSET); + netctrlreg = netctrlreg & (~FXMAC_NWCTRL_TXEN_MASK); + FXMAC_WRITEREG32(instance_p->config.base_address, + FXMAC_NWCTRL_OFFSET, netctrlreg); + + eth_phytium_xmac_tx_dma_init(dev); + netctrlreg = FXMAC_READREG32(instance_p->config.base_address, FXMAC_NWCTRL_OFFSET); + netctrlreg = netctrlreg | (FXMAC_NWCTRL_TXEN_MASK); + FXMAC_WRITEREG32(instance_p->config.base_address, FXMAC_NWCTRL_OFFSET, netctrlreg); +} + +void FXmacErrorHandler(void *arg, u8 direction, u32 error_word) +{ + const struct device *dev = (const struct device *)arg ; + struct eth_phytium_xmac_dev_data *dev_data = (struct eth_phytium_xmac_dev_data *)dev->data; + struct eth_phytium_xmac_dev_cfg *dev_conf = (struct eth_phytium_xmac_dev_cfg *)dev->config; + FXmac *instance_p; + instance_p = &dev_data->instance ; + + if (error_word != 0) + { + switch (direction) + { + case FXMAC_RECV: + if (error_word & FXMAC_RXSR_HRESPNOK_MASK) + { + LOG_ERR("Receive DMA error\r\n"); + FXmacHandleDmaTxError(dev); + } + if (error_word & FXMAC_RXSR_RXOVR_MASK) + { + LOG_ERR("Receive over run\r\n"); + FXmacRecvHandler((void *)dev) ; + } + if (error_word & FXMAC_RXSR_BUFFNA_MASK) + { + LOG_ERR("Receive buffer not available\r\n"); + FXmacRecvHandler((void *)dev) ; + } + break; + case FXMAC_SEND: + if (error_word & FXMAC_TXSR_HRESPNOK_MASK) + { + LOG_ERR("Transmit DMA error\r\n"); + FXmacHandleDmaTxError(dev); + } + if (error_word & FXMAC_TXSR_URUN_MASK) + { + LOG_ERR("Transmit under run\r\n"); + FXmacHandleTxErrors(dev); + } + if (error_word & FXMAC_TXSR_BUFEXH_MASK) + { + LOG_ERR("Transmit buffer exhausted\r\n"); + FXmacHandleTxErrors(dev); + } + if (error_word & FXMAC_TXSR_RXOVR_MASK) + { + LOG_ERR("Transmit retry excessed limits\r\n"); + FXmacHandleTxErrors(dev); + } + if (error_word & FXMAC_TXSR_FRAMERX_MASK) + { + LOG_ERR("Transmit collision\r\n"); + if (dev_conf->defer_txd_to_queue) { + k_work_submit(&dev_data->tx_done_work); + } + else + { + eth_phytium_xmac_handle_tx_done(dev); + } + } + break; + } + } +} + +#ifdef CONFIG_NET_STATISTICS_ETHERNET +/** + * @name: eth_phytium_xmac_stats + * @msg: Retrieves the Ethernet statistics for the device. + * @param {const struct device} *dev is a pointer to the device structure for the driver instance. + * @return {struct net_stats_eth} * A pointer to the statistics structure. + */ +static struct net_stats_eth *eth_phytium_xmac_stats(const struct device *dev) +{ + struct eth_phytium_xmac_dev_data *dev_data = dev->data; + + return &dev_data->stats; +} +#endif + +/** + * @name: FXmacSetupIsr + * @msg: Sets up the interrupt service routine handlers for transmit, receive, and error events. + * @param {const struct device} *dev is a pointer to the device structure for the driver instance. + */ +static void FXmacSetupIsr(const struct device *dev) +{ + struct eth_phytium_xmac_dev_data *dev_data = (struct eth_phytium_xmac_dev_data *)dev->data ; + /* Setup callbacks */ + FXmac *instance_p; + instance_p = &dev_data->instance; + + FXmacSetHandler(instance_p, FXMAC_HANDLER_DMASEND, FXmacSendHandler, (void *)dev); + FXmacSetHandler(instance_p, FXMAC_HANDLER_DMARECV, FXmacRecvHandler,(void *) (void *)dev); + FXmacSetHandler(instance_p, FXMAC_HANDLER_ERROR, FXmacErrorHandler, (void *)dev); +} + +/** + * @name: eth_phytium_xmac_start_device + * @msg: Starts the Ethernet device, enabling packet transmission and reception. + * @param {const struct device} *dev is a pointer to the device structure for the driver instance. + * @return {int} Zero on success or negative error code on failure. + */ +static int eth_phytium_xmac_start_device(const struct device *dev) +{ + struct eth_phytium_xmac_dev_data *dev_data = (struct eth_phytium_xmac_dev_data *)dev->data; + /* Setup callbacks */ + if (dev_data->started) { + return 0; + } + dev_data->started = true; + + FXmac *instance_p; + instance_p = &dev_data->instance; + FXmacStart(instance_p) ; + return 0 ; +} + +/** + * @name: eth_phytium_xmac_stop_device + * @msg: Stops the Ethernet device, disabling packet transmission and reception. + * @param {const struct device} *dev is a pointer to the device structure for the driver instance. + * @return {int} Zero on success or negative error code on failure. + */ +static int eth_phytium_xmac_stop_device(const struct device *dev) +{ + struct eth_phytium_xmac_dev_data *dev_data = (struct eth_phytium_xmac_dev_data *)dev->data; + FXmac *instance_p; + instance_p = &dev_data->instance; + + if (!dev_data->started) { + return 0; + } + dev_data->started = false; + + /* Cancel the delayed work that polls the link state */ + if (k_work_delayable_remaining_get(&dev_data->phy_poll_delayed_work) != 0) + { + k_work_cancel_delayable(&dev_data->phy_poll_delayed_work); + } + + FXmacStop(instance_p) ; + + return 0 ; +} + +/** + * @name: eth_phytium_xmac_isr + * @msg: Interrupt service routine for handling all interrupts from the Ethernet device. + * @param {const struct device} *dev is a pointer to the device structure for the driver instance. + */ +static void eth_phytium_xmac_isr(const struct device *dev) +{ + u32 reg_isr; + u32 reg_temp; + u32 reg_ctrl; + + struct eth_phytium_xmac_dev_data *dev_data = (struct eth_phytium_xmac_dev_data *)dev->data; + /* Setup callbacks */ + FXmac *instance_p; + instance_p = &dev_data->instance; + + reg_isr = FXMAC_READREG32(instance_p->config.base_address, FXMAC_ISR_OFFSET); + { + if ((reg_isr & FXMAC_IXR_TXCOMPL_MASK) != 0x00000000U) + { + /* Clear TX status register TX complete indication but preserve + * error bits if there is any */ + FXMAC_WRITEREG32(instance_p->config.base_address, + FXMAC_TXSR_OFFSET, + ((u32)FXMAC_TXSR_TXCOMPL_MASK | + (u32)FXMAC_TXSR_USEDREAD_MASK)); + if (instance_p->send_irq_handler) + { + /* code */ + instance_p->send_irq_handler(instance_p->send_args); + } + /* add */ + if(instance_p->caps& FXMAC_CAPS_ISR_CLEAR_ON_WRITE) + { + FXMAC_WRITEREG32(instance_p->config.base_address, FXMAC_ISR_OFFSET, FXMAC_IXR_TXCOMPL_MASK); + } + } + + /* Transmit error conditions interrupt */ + if (((reg_isr & FXMAC_IXR_TX_ERR_MASK) != 0x00000000U) && + (!(reg_isr & FXMAC_IXR_TXCOMPL_MASK) != 0x00000000U)) + { + /* Clear TX status register */ + reg_temp = FXMAC_READREG32(instance_p->config.base_address, FXMAC_TXSR_OFFSET); + FXMAC_WRITEREG32(instance_p->config.base_address, FXMAC_TXSR_OFFSET, reg_temp); + if (instance_p->error_irq_handler) + { + instance_p->error_irq_handler(instance_p->error_args, FXMAC_SEND, reg_temp); + } + /* add */ + if(instance_p->caps& FXMAC_CAPS_ISR_CLEAR_ON_WRITE) + { + FXMAC_WRITEREG32(instance_p->config.base_address, FXMAC_ISR_OFFSET, FXMAC_IXR_TX_ERR_MASK); + } + } + + /* add restart */ + if ((reg_isr & FXMAC_IXR_TXUSED_MASK) != 0x00000000U) + { + /* add */ + if(instance_p->caps& FXMAC_CAPS_ISR_CLEAR_ON_WRITE) + { + FXMAC_WRITEREG32(instance_p->config.base_address, FXMAC_ISR_OFFSET, FXMAC_IXR_TXUSED_MASK); + } + if (instance_p->restart_handler) + { + instance_p->restart_handler(instance_p->restart_args); + } + } + + /* link changed */ + if ((reg_isr & FXMAC_IXR_LINKCHANGE_MASK) != 0x00000000U) + { + if (instance_p->link_change_handler) + { + instance_p->link_change_handler(instance_p->link_change_args); + } + if(instance_p->caps& FXMAC_CAPS_ISR_CLEAR_ON_WRITE) + { + FXMAC_WRITEREG32(instance_p->config.base_address, FXMAC_ISR_OFFSET, FXMAC_IXR_LINKCHANGE_MASK); + } + } + } + + + { + /* Receive complete interrupt */ + if ((reg_isr & FXMAC_IXR_RXCOMPL_MASK) != 0x00000000U) + { + /* Clear RX status register RX complete indication but preserve + * error bits if there is any */ + FXMAC_WRITEREG32(instance_p->config.base_address, + FXMAC_RXSR_OFFSET, + ((u32)FXMAC_RXSR_FRAMERX_MASK | + (u32)FXMAC_RXSR_BUFFNA_MASK)); + instance_p->recv_irq_handler(instance_p->recv_args); + /* add */ + if(instance_p->caps& FXMAC_CAPS_ISR_CLEAR_ON_WRITE) + { + FXMAC_WRITEREG32(instance_p->config.base_address, FXMAC_ISR_OFFSET, FXMAC_IXR_RXCOMPL_MASK); + } + } + + /* Receive error conditions interrupt */ + if ((reg_isr & FXMAC_IXR_RX_ERR_MASK) != 0x00000000U) + { + /* Clear RX status register */ + reg_temp = FXMAC_READREG32(instance_p->config.base_address, + FXMAC_RXSR_OFFSET); + FXMAC_WRITEREG32(instance_p->config.base_address, + FXMAC_RXSR_OFFSET, reg_temp); + if ((reg_isr & FXMAC_IXR_RXUSED_MASK) != 0x00000000U) + { + reg_ctrl = FXMAC_READREG32(instance_p->config.base_address, + FXMAC_NWCTRL_OFFSET); + reg_ctrl |= (u32)FXMAC_NWCTRL_FLUSH_DPRAM_MASK; + /* add */ + reg_ctrl &= (u32)(~FXMAC_NWCTRL_RXEN_MASK); + FXMAC_WRITEREG32(instance_p->config.base_address, + FXMAC_NWCTRL_OFFSET, reg_ctrl); + /* add */ + reg_ctrl |= (u32)FXMAC_NWCTRL_RXEN_MASK; + FXMAC_WRITEREG32(instance_p->config.base_address, + FXMAC_NWCTRL_OFFSET, reg_ctrl); + + if(instance_p->caps& FXMAC_CAPS_ISR_CLEAR_ON_WRITE) + { + FXMAC_WRITEREG32(instance_p->config.base_address, FXMAC_ISR_OFFSET, FXMAC_IXR_RXUSED_MASK); + } + } + /* add */ + if ((reg_isr & FXMAC_IXR_RXOVR_MASK) != 0x00000000U) + { + if(instance_p->caps& FXMAC_CAPS_ISR_CLEAR_ON_WRITE) + { + FXMAC_WRITEREG32(instance_p->config.base_address, FXMAC_ISR_OFFSET, FXMAC_IXR_RXOVR_MASK); + } + } + /* add */ + if ((reg_isr & FXMAC_IXR_HRESPNOK_MASK) != 0x00000000U) + { + if(instance_p->caps& FXMAC_CAPS_ISR_CLEAR_ON_WRITE) + { + FXMAC_WRITEREG32(instance_p->config.base_address, FXMAC_ISR_OFFSET, FXMAC_IXR_HRESPNOK_MASK); + } + } + if (reg_temp != 0) + { + instance_p->error_irq_handler(instance_p->error_args, + FXMAC_RECV, reg_temp); + } + } + } +} + +/** + * @name: eth_phytium_xmac_iface_init + * @msg: Initializes the network interface for the Ethernet driver. Sets the link address and registers the Ethernet interface with the network stack. + * @param {struct net_if} *iface is a pointer to the network interface structure. + */ +static void eth_phytium_xmac_iface_init(struct net_if *iface) +{ + const struct device *dev = net_if_get_device(iface); + const struct eth_phytium_xmac_dev_cfg *dev_conf = dev->config; + struct eth_phytium_xmac_dev_data *dev_data = dev->data; + + /* Set the initial contents of the current instance's run-time data */ + dev_data->iface = iface; + net_if_set_link_addr(iface, dev_data->mac_addr, 6, NET_LINK_ETHERNET); + ethernet_init(iface); + net_if_carrier_off(iface); + + /* + * Initialize the (delayed) work items for RX pending, TX done + * and PHY status polling handlers + */ + k_work_init(&dev_data->tx_done_work, eth_phytium_xmac_tx_done_work); + k_work_init(&dev_data->rx_pend_work, eth_phytium_xmac_rx_pending_work); + k_work_init_delayable(&dev_data->phy_poll_delayed_work, + eth_phytium_xmac_poll_phy); + + /* Initialize TX completion semaphore */ + k_sem_init(&dev_data->tx_done_sem, 0, 1); + + /* + * Initialize semaphores in the RX/TX BD rings which have not + * yet been initialized + */ + k_sem_init(&dev_data->ring_sem, 1, 1); + /* RX BD ring semaphore is not required at the time being */ + + /* Initialize the device's interrupt */ + dev_conf->config_func(dev); + + /* Submit initial PHY status polling delayed work */ + k_work_reschedule(&dev_data->phy_poll_delayed_work, K_NO_WAIT); + +} + +/** + * @name: eth_phytium_xmac_dev_init + * @msg: Initializes the Ethernet device, including hardware configuration and MAC address setting. + * @param {const struct device} *dev is a pointer to the device structure for the driver instance. + * @return {int} Zero on success or negative error code on failure. + */ +static int eth_phytium_xmac_dev_init(const struct device *dev) +{ + struct eth_phytium_xmac_dev_data *dev_data = (struct eth_phytium_xmac_dev_data *)dev->data ; + struct eth_phytium_xmac_dev_cfg *dev_conf = (struct eth_phytium_xmac_dev_cfg *)dev->config ; + FXmacConfig mac_config; + FXmac *instance_p; + uint32_t xmac_options ; + uint32_t dmacrreg; + int ret ; + + /* init base */ + DEVICE_MMIO_MAP(dev, K_MEM_CACHE_NONE); + + /* config init */ + mac_config.base_address = DEVICE_MMIO_GET(dev) ; + mac_config.instance_id = 0; + + ret = eth_phytium_xmac_config_convert(dev_conf,&mac_config,&xmac_options) ; + if(ret) + { + return -EINVAL; + } + + instance_p = &dev_data->instance; + if(FXmacCfgInitialize(instance_p, &mac_config)) + { + return -EIO; + } + + FXmacSetOptions(instance_p, xmac_options, 0); + + /* set mac address */ + if(FXmacSetMacAddress(instance_p, (void *)(dev_data->mac_addr), 0)) + { + return -EIO; + } + + if(mac_config.interface != FXMAC_PHY_INTERFACE_MODE_USXGMII) + { + /* initialize phy */ + if(FXmacPhyInit(instance_p, instance_p->config.speed, instance_p->config.duplex, instance_p->config.auto_neg,XMAC_PHY_RESET_ENABLE)) + { + LOG_WRN("FXmacPhyInit is error \r\n"); + } + } + + FXmacSelectClk(instance_p); + FXmacInitInterface(instance_p); + + /* initialize dma */ + dmacrreg = FXMAC_READREG32(instance_p->config.base_address, FXMAC_DMACR_OFFSET); + dmacrreg &= ~(FXMAC_DMACR_BLENGTH_MASK); + dmacrreg = dmacrreg | FXMAC_DMACR_INCR16_AHB_AXI_BURST; /* Attempt to use bursts of up to 16. */ + FXMAC_WRITEREG32(instance_p->config.base_address, FXMAC_DMACR_OFFSET, dmacrreg); + /* setup dma bdl */ + eth_phytium_xmac_setuphandler(dev) ; + instance_p->mask = ((u32)FXMAC_IXR_TX_ERR_MASK + | (u32)FXMAC_IXR_RX_ERR_MASK + | (u32)FXMAC_IXR_RXCOMPL_MASK + | (u32)FXMAC_IXR_TXCOMPL_MASK); + /* setup tx、rx intr */ + FXmacSetupIsr(dev) ; + + return 0 ; +} + + + + diff --git a/drivers/interrupt_controller/intc_gicv3.c b/drivers/interrupt_controller/intc_gicv3.c index e3c25c4d8b8..09a2f75280d 100644 --- a/drivers/interrupt_controller/intc_gicv3.c +++ b/drivers/interrupt_controller/intc_gicv3.c @@ -405,6 +405,9 @@ static void gicv3_cpuif_init(void) /* Configure PPIs as level triggered */ sys_write32(0, ICFGR(base, 1)); + + +#ifndef CONFIG_USE_EL2 /* * Check if system interface can be enabled. * 'icc_sre_el3' needs to be configured at 'EL3' @@ -421,6 +424,26 @@ static void gicv3_cpuif_init(void) __ASSERT_NO_MSG(icc_sre & ICC_SRE_ELx_SRE_BIT); } +#else + /* + * Check if system interface can be enabled. + * 'icc_sre_el3' needs to be configured at 'EL3' + * to allow access to 'icc_sre_el1' at 'EL1' + * eg: z_arch_el3_plat_init can be used by platform. + */ + icc_sre = read_sysreg(ICC_SRE_EL2); + + if (!(icc_sre & ICC_SRE_ELx_SRE_BIT)) { + icc_sre = (icc_sre | ICC_SRE_ELx_SRE_BIT | + ICC_SRE_ELx_DIB_BIT | ICC_SRE_ELx_DFB_BIT); + write_sysreg(icc_sre, ICC_SRE_EL2); + icc_sre = read_sysreg(ICC_SRE_EL2); + + __ASSERT_NO_MSG(icc_sre & ICC_SRE_ELx_SRE_BIT); + } + +#endif + write_sysreg(GIC_IDLE_PRIO, ICC_PMR_EL1); diff --git a/dts/arm64/phytium/d3000.dtsi b/dts/arm64/phytium/d3000.dtsi deleted file mode 100644 index f5b3c044477..00000000000 --- a/dts/arm64/phytium/d3000.dtsi +++ /dev/null @@ -1,135 +0,0 @@ -// Phytium is pleased to support the open source community by making Zephyr-SDK available. - -// -// Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. -// -// Licensed under the Apache-2.0 License (the "License"); you may not use this file except -// in compliance with the License. You may obtain a copy of the License at -// -// https://opensource.org/license/apache-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 -#include -#include - -/ { - #address-cells = <2>; - #size-cells = <2>; - - cpus { - #address-cells = <2>; - #size-cells = <0>; - - cpu@0 { - device_type = "cpu"; - compatible = "phytium,ftc862"; - reg = <0 0x0>; - }; - - cpu@1 { - device_type = "cpu"; - compatible = "phytium,ftc862"; - reg = <0 0x100>; - }; - - cpu@2 { - device_type = "cpu"; - compatible = "phytium,ftc862"; - reg = <0 0x200>; - }; - - cpu@3 { - device_type = "cpu"; - compatible = "phytium,ftc862"; - reg = <0 0x300>; - }; - - cpu@4 { - device_type = "cpu"; - compatible = "phytium,ftc862"; - reg = <0 0x10000>; - }; - - cpu@5 { - device_type = "cpu"; - compatible = "phytium,ftc862"; - reg = <0 0x10100>; - }; - - cpu@6 { - device_type = "cpu"; - compatible = "phytium,ftc862"; - reg = <0 0x10200>; - }; - - cpu@7 { - device_type = "cpu"; - compatible = "phytium,ftc862"; - reg = <0 0x10300>; - }; - }; - - timer { - compatible = "arm,armv8-timer"; - interrupt-parent = <&gic>; - // ppi =+ 16, 13 == 29 Security physical timer interrupt, 14 == 30 Non secure physical timer interrupt - interrupts = , - , - , - ; - label = "arch_timer"; - }; - - uartclk: apb-pclk { - compatible = "fixed-clock"; - clock-frequency = <100000000>; - #clock-cells = <0>; - }; - - soc { - #address-cells = <2>; - #size-cells = <2>; - ranges; - - interrupt-parent = <&gic>; - - gic: interrupt-controller@36800000 { - compatible = "arm,gic-v3", "arm,gic"; - reg = <0x00 0x36800000 0x00 0x40000>, - <0x00 0x36860000 0x00 0x200000>; - interrupt-controller; - #interrupt-cells = <4>; - label = "GIC"; - status = "okay"; - #size-cells = <0x02>; - #address-cells = <0x02>; - }; - - uart1: uart@28009000 { - compatible = "arm,pl011"; - reg = <0x00 0x28009000 0x00 0x1000>; - status = "disabled"; - interrupts = ; - interrupt-names = "irq_0"; - clocks = <&uartclk>; - label = "UART_1"; - }; - - /* 512MB DDR */ - sram0: memory@80100000 { - device_type = "memory"; - compatible = "mmio-sram"; - reg = <0x00 0x80100000 0x00 0x40000000>; - }; - - }; -}; diff --git a/dts/arm64/phytium/e2000q.dtsi b/dts/arm64/phytium/e2000q.dtsi index 8724b329e97..789ce1a08b3 100644 --- a/dts/arm64/phytium/e2000q.dtsi +++ b/dts/arm64/phytium/e2000q.dtsi @@ -1,177 +1,177 @@ -// Phytium is pleased to support the open source community by making Zephyr-SDK available. - -// -// Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. -// -// Licensed under the Apache-2.0 License (the "License"); you may not use this file except -// in compliance with the License. You may obtain a copy of the License at -// -// https://opensource.org/license/apache-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 -#include -#include - -/ { - #address-cells = <2>; - #size-cells = <2>; - - cpus { - #address-cells = <2>; - #size-cells = <0>; - - cpu@0 { - device_type = "cpu"; - compatible = "phytium,ftc310"; - reg = <0 0x200>; - }; - - cpu@1 { - device_type = "cpu"; - compatible = "phytium,ftc310"; - reg = <0 0x201>; - }; - - cpu@2 { - device_type = "cpu"; - compatible = "phytium,ftc664"; - reg = <0 0>; - }; - - cpu@3 { - device_type = "cpu"; - compatible = "phytium,ftc664"; - reg = <0 0x100>; - }; - - }; - - timer { - compatible = "arm,armv8-timer"; - interrupt-parent = <&gic>; - // ppi =+ 16, 13 == 29 Security physical timer interrupt, 14 == 30 Non secure physical timer interrupt - interrupts = , - , - , - ; - }; - - uartclk: apb-pclk { - compatible = "fixed-clock"; - clock-frequency = <100000000>; - #clock-cells = <0>; - }; - - soc { - #address-cells = <2>; - #size-cells = <2>; - ranges; - - interrupt-parent = <&gic>; - - gic: interrupt-controller@30800000 { - compatible = "arm,gic-v3", "arm,gic"; - reg = <0x00 0x30800000 0x00 0x40000>, - <0x00 0x30880000 0x00 0x80000>; - interrupt-controller; - #interrupt-cells = <4>; - status = "okay"; - #size-cells = <0x02>; - #address-cells = <0x02>; - }; - - pinctrl: pinctrl@32B30000 { - compatible = "phytium,pinctrl"; - reg = <0x00 0x32B30000 0x00 0x2000>; - status = "okay"; - }; - - uart1: uart@2800d000 { - compatible = "arm,pl011"; - reg = <0x00 0x2800d000 0x00 0x1000>; - status = "disabled"; - interrupts = ; - interrupt-names = "irq_0"; - clocks = <&uartclk>; - }; - - uart2: uart@2800E000 { - compatible = "arm,pl011"; - reg = <0x00 0x2800E000 0x00 0x1000>; - status = "disabled"; - interrupts = ; - interrupt-names = "irq_1"; - clocks = <&uartclk>; - }; - - sdhc0: sdhc@28000000 { - compatible = "phytium,sdhc"; - reg = <0x00 0x28000000 0x00 0x1000>; - status = "disabled"; - interrupts = ; - max-current-330 = <1020>; - max-bus-freq = <25000000>; - min-bus-freq = <400000>; - }; - - xmac0: xmac@3200C000 { - compatible = "phytium,xmac"; - reg = <0x00 0x3200C000 0x00 0x2000>; - status = "disabled"; - interrupts = ; - interrupt-names = "irq_0"; - phy-poll-interval = <5000>; - clock-frequency = <50000000> ; - phy-speed = <1000> ; - interface-mode = <0> ; - dma-brust-length = <16> ; - max-queue-num = <1> ; - rx-buffer-descriptors = <128>; - tx-buffer-descriptors = <128>; - rx-buffer-size = <1600>; - tx-buffer-size = <1600>; - phy-autonegotiation; - enable-fdx; - disable-reject-fcs-crc-errors ; - } ; - - sdhc1: sdhc@28001000 { - compatible = "phytium,sdhc"; - reg = <0x00 0x28001000 0x00 0x1000>; - status = "disabled"; - interrupts = ; - max-current-330 = <1020>; - max-bus-freq = <25000000>; - min-bus-freq = <400000>; - }; - - /* 512MB DDR */ - sram0: memory@80100000 { - device_type = "memory"; - compatible = "mmio-sram"; - reg = <0x00 0x80100000 0x00 0x20000000>; - }; - - pcie0: pcie@40000000 { - compatible = "pci-host-ecam-generic"; - device_type = "pci"; - reg = <0x00 0x40000000 0x00 0x10000000>; - #size-cells = <0x02>; - #address-cells = <0x03>; - ranges = <0x1000000 0x00 0x50000000 0x00 0x50000000 0x00 0x08000000 - 0x2000000 0x00 0x58000000 0x00 0x58000000 0x00 0x27ffffff - 0x3000000 0x10 0x00 0x10 0x00 0x1f 0xffffffff>; - bus-range = <0x00 0xff>; - }; - }; -}; +// Phytium is pleased to support the open source community by making Zephyr-SDK available. + +// +// Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +// +// Licensed under the Apache-2.0 License (the "License"); you may not use this file except +// in compliance with the License. You may obtain a copy of the License at +// +// https://opensource.org/license/apache-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 +#include +#include + +/ { + #address-cells = <2>; + #size-cells = <2>; + + cpus { + #address-cells = <2>; + #size-cells = <0>; + + cpu@0 { + device_type = "cpu"; + compatible = "phytium,ftc310"; + reg = <0 0x200>; + }; + + cpu@1 { + device_type = "cpu"; + compatible = "phytium,ftc310"; + reg = <0 0x201>; + }; + + cpu@2 { + device_type = "cpu"; + compatible = "phytium,ftc664"; + reg = <0 0>; + }; + + cpu@3 { + device_type = "cpu"; + compatible = "phytium,ftc664"; + reg = <0 0x100>; + }; + + }; + + timer { + compatible = "arm,armv8-timer"; + interrupt-parent = <&gic>; + // ppi =+ 16, 13 == 29 Security physical timer interrupt, 14 == 30 Non secure physical timer interrupt + interrupts = , + , + , + ; + }; + + uartclk: apb-pclk { + compatible = "fixed-clock"; + clock-frequency = <100000000>; + #clock-cells = <0>; + }; + + soc { + #address-cells = <2>; + #size-cells = <2>; + ranges; + + interrupt-parent = <&gic>; + + gic: interrupt-controller@30800000 { + compatible = "arm,gic-v3", "arm,gic"; + reg = <0x00 0x30800000 0x00 0x40000>, + <0x00 0x30880000 0x00 0x80000>; + interrupt-controller; + #interrupt-cells = <4>; + status = "okay"; + #size-cells = <0x02>; + #address-cells = <0x02>; + }; + + pinctrl: pinctrl@32B30000 { + compatible = "phytium,pinctrl"; + reg = <0x00 0x32B30000 0x00 0x2000>; + status = "okay"; + }; + + uart1: uart@2800d000 { + compatible = "arm,pl011"; + reg = <0x00 0x2800d000 0x00 0x1000>; + status = "disabled"; + interrupts = ; + interrupt-names = "irq_0"; + clocks = <&uartclk>; + }; + + uart2: uart@2800E000 { + compatible = "arm,pl011"; + reg = <0x00 0x2800E000 0x00 0x1000>; + status = "disabled"; + interrupts = ; + interrupt-names = "irq_1"; + clocks = <&uartclk>; + }; + + sdhc0: sdhc@28000000 { + compatible = "phytium,sdhc"; + reg = <0x00 0x28000000 0x00 0x1000>; + status = "disabled"; + interrupts = ; + max-current-330 = <1020>; + max-bus-freq = <25000000>; + min-bus-freq = <400000>; + }; + + xmac0: xmac@3200C000 { + compatible = "phytium,xmac"; + reg = <0x00 0x3200C000 0x00 0x2000>; + status = "disabled"; + interrupts = ; + interrupt-names = "irq_0"; + phy-poll-interval = <5000>; + clock-frequency = <50000000> ; + phy-speed = <1000> ; + interface-mode = <0> ; + dma-brust-length = <16> ; + max-queue-num = <1> ; + rx-buffer-descriptors = <128>; + tx-buffer-descriptors = <128>; + rx-buffer-size = <1600>; + tx-buffer-size = <1600>; + phy-autonegotiation; + enable-fdx; + disable-reject-fcs-crc-errors ; + } ; + + sdhc1: sdhc@28001000 { + compatible = "phytium,sdhc"; + reg = <0x00 0x28001000 0x00 0x1000>; + status = "disabled"; + interrupts = ; + max-current-330 = <1020>; + max-bus-freq = <25000000>; + min-bus-freq = <400000>; + }; + + /* 512MB DDR */ + sram0: memory@80100000 { + device_type = "memory"; + compatible = "mmio-sram"; + reg = <0x00 0x80100000 0x00 0x20000000>; + }; + + pcie0: pcie@40000000 { + compatible = "pci-host-ecam-generic"; + device_type = "pci"; + reg = <0x00 0x40000000 0x00 0x10000000>; + #size-cells = <0x02>; + #address-cells = <0x03>; + ranges = <0x1000000 0x00 0x50000000 0x00 0x50000000 0x00 0x08000000 + 0x2000000 0x00 0x58000000 0x00 0x58000000 0x00 0x27ffffff + 0x3000000 0x10 0x00 0x10 0x00 0x1f 0xffffffff>; + bus-range = <0x00 0xff>; + }; + }; +}; diff --git a/dts/arm64/phytium/s5000c.dtsi b/dts/arm64/phytium/s5000c.dtsi deleted file mode 100644 index dd7c801c67e..00000000000 --- a/dts/arm64/phytium/s5000c.dtsi +++ /dev/null @@ -1,233 +0,0 @@ - -// Phytium is pleased to support the open source community by making Zephyr-SDK available. - -// -// Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. -// -// Licensed under the Apache-2.0 License (the "License"); you may not use this file except -// in compliance with the License. You may obtain a copy of the License at -// -// https://opensource.org/license/apache-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 -#include -#include - -/ { - #address-cells = <2>; - #size-cells = <2>; - - cpus { - #address-cells = <2>; - #size-cells = <0>; - - cpu@0 { - device_type = "cpu"; - compatible = "phytium,ftc862"; - reg = <0 0x0>; - }; - - cpu@1 { - device_type = "cpu"; - compatible = "phytium,ftc862"; - reg = <0 0x10000>; - }; - - cpu@2 { - device_type = "cpu"; - compatible = "phytium,ftc862"; - reg = <0 0x20000>; - }; - - cpu@3 { - device_type = "cpu"; - compatible = "phytium,ftc862"; - reg = <0 0x30000>; - }; - - cpu@4 { - device_type = "cpu"; - compatible = "phytium,ftc862"; - reg = <0 0x40000>; - }; - - cpu@5 { - device_type = "cpu"; - compatible = "phytium,ftc862"; - reg = <0 0x50000>; - }; - - cpu@6 { - device_type = "cpu"; - compatible = "phytium,ftc862"; - reg = <0 0x60000>; - }; - - cpu@7 { - device_type = "cpu"; - compatible = "phytium,ftc862"; - reg = <0 0x70000>; - }; - }; - - timer { - compatible = "arm,armv8-timer"; - interrupt-parent = <&gic>; - // ppi =+ 16, 13 == 29 Security physical timer interrupt, 14 == 30 Non secure physical timer interrupt - interrupts = , - , - , - ; - label = "arch_timer"; - }; - - uartclk: apb-pclk { - compatible = "fixed-clock"; - clock-frequency = <50000000>; - #clock-cells = <0>; - }; - - soc { - #address-cells = <2>; - #size-cells = <2>; - ranges; - - interrupt-parent = <&gic>; - - gic: interrupt-controller@22000000 { - compatible = "arm,gic-v3", "arm,gic"; - reg = <0x00 0x22000000 0x00 0x40000>, - <0x00 0x220c0000 0x00 0x200000>; - interrupt-controller; - #interrupt-cells = <4>; - label = "GIC"; - status = "okay"; - #size-cells = <0x02>; - #address-cells = <0x02>; - }; - - // pinctrl: pinctrl@32b30000 { - // compatible = "phytium,pinctrl"; - // reg = <0x00 0x32b30000 0x00 0x2000>; - // status = "okay"; - // }; - - uart1: uart@0x20001000 { - compatible = "arm,pl011"; - reg = <0x00 0x20001000 0x00 0x1000>; - status = "disabled"; - interrupts = ; - interrupt-names = "irq_0"; - clocks = <&uartclk>; - label = "UART_1"; - }; - - // uart0: uart@0x28008000 { - // compatible = "arm,pl011"; - // reg = <0x00 0x28008000 0x00 0x1000>; - // status = "disabled"; - // interrupts = ; - // interrupt-names = "irq_0"; - // clocks = <&uartclk>; - // label = "UART_0"; - // }; - - // uart2: uart@2800e000 { - // compatible = "arm,pl011"; - // reg = <0x00 0x2800e000 0x00 0x1000>; - // status = "disabled"; - // interrupts = ; - // interrupt-names = "irq_1"; - // clocks = <&uartclk>; - // label = "UART_2"; - // }; - - - // uart3: uart@2800f000 { - // compatible = "arm,pl011"; - // reg = <0x00 0x2800f000 0x00 0x1000>; - // status = "disabled"; - // interrupts = ; - // interrupt-names = "irq_0"; - // clocks = <&uartclk>; - // label = "UART_3"; - // }; - - - // sdhc0: sdhc@28000000 { - // compatible = "phytium,sdhc"; - // reg = <0x00 0x28000000 0x00 0x1000>; - // status = "disabled"; - // interrupts = ; - // max-current-330 = <1020>; - // max-bus-freq = <25000000>; - // min-bus-freq = <400000>; - // }; - - // xmac0: xmac@3200C000 { - // compatible = "phytium,xmac"; - // reg = <0x00 0x3200C000 0x00 0x2000>; - // status = "disabled"; - // interrupts = ; - // interrupt-names = "irq_0"; - // phy-poll-interval = <5000>; - // clock-frequency = <50000000> ; - // phy-speed = <1000> ; - // interface-mode = <0> ; - // dma-brust-length = <16> ; - // max-queue-num = <1> ; - // rx-buffer-descriptors = <128>; - // tx-buffer-descriptors = <128>; - // rx-buffer-size = <1600>; - // tx-buffer-size = <1600>; - // phy-autonegotiation; - // enable-fdx; - // disable-reject-fcs-crc-errors ; - // } ; - - // sdhc1: sdhc@28001000 { - // compatible = "phytium,sdhc"; - // reg = <0x00 0x28001000 0x00 0x1000>; - // status = "disabled"; - // interrupts = ; - // max-current-330 = <1020>; - // max-bus-freq = <25000000>; - // min-bus-freq = <400000>; - // }; - - /* 512MB DDR */ - sram0: memory@80100000 { - device_type = "memory"; - compatible = "mmio-sram"; - reg = <0x00 0x80100000 0x00 0x20000000>; - }; - - // temp_mem0:memory@0xe0000000 { - // device_type = "memory"; - // compatible = "mmio-sram"; - // reg = <0x00 0xe0000000 0x00 0x10000000>; - // } ; - - // pcie0: pcie@40000000 { - // compatible = "pci-host-ecam-generic"; - // device_type = "pci"; - // reg = <0x00 0x40000000 0x00 0x10000000>; - // #size-cells = <0x02>; - // #address-cells = <0x03>; - // ranges = <0x1000000 0x00 0x50000000 0x00 0x50000000 0x00 0x08000000 - // 0x2000000 0x00 0x58000000 0x00 0x58000000 0x00 0x27ffffff - // 0x3000000 0x10 0x00 0x10 0x00 0x1f 0xffffffff>; - // bus-range = <0x00 0xff>; - // }; - }; -}; diff --git a/include/zephyr/arch/arm64/lib_helpers.h b/include/zephyr/arch/arm64/lib_helpers.h index 0f3d9d563ab..117c79a326c 100644 --- a/include/zephyr/arch/arm64/lib_helpers.h +++ b/include/zephyr/arch/arm64/lib_helpers.h @@ -62,6 +62,9 @@ MAKE_REG_HELPER(cnthps_ctl_el2); MAKE_REG_HELPER(cntv_ctl_el0) MAKE_REG_HELPER(cntv_cval_el0) MAKE_REG_HELPER(cntvct_el0); +MAKE_REG_HELPER(cntpct_el0); +MAKE_REG_HELPER(cnthp_cval_el2) +MAKE_REG_HELPER(cnthp_tval_el2) MAKE_REG_HELPER(cntvoff_el2); MAKE_REG_HELPER(currentel); MAKE_REG_HELPER(csselr_el1); diff --git a/include/zephyr/arch/arm64/timer.h b/include/zephyr/arch/arm64/timer.h index d8abba1c0e4..8610ca95606 100644 --- a/include/zephyr/arch/arm64/timer.h +++ b/include/zephyr/arch/arm64/timer.h @@ -19,7 +19,11 @@ extern "C" { #endif +#ifndef CONFIG_USE_EL2 #define ARM_ARCH_TIMER_IRQ ARM_TIMER_VIRTUAL_IRQ +#else +#define ARM_ARCH_TIMER_IRQ ARM_TIMER_HYP_IRQ +#endif #define ARM_ARCH_TIMER_PRIO ARM_TIMER_VIRTUAL_PRIO #define ARM_ARCH_TIMER_FLAGS ARM_TIMER_VIRTUAL_FLAGS @@ -36,37 +40,52 @@ static ALWAYS_INLINE void arm_arch_timer_init(void) static ALWAYS_INLINE void arm_arch_timer_set_compare(uint64_t val) { +#ifndef CONFIG_USE_EL2 write_cntv_cval_el0(val); +#else + write_cnthp_cval_el2(val); +#endif } static ALWAYS_INLINE void arm_arch_timer_enable(unsigned char enable) { uint64_t cntv_ctl; - +#ifndef CONFIG_USE_EL2 cntv_ctl = read_cntv_ctl_el0(); +#else + cntv_ctl = read_cnthp_ctl_el2(); +#endif if (enable) { cntv_ctl |= CNTV_CTL_ENABLE_BIT; } else { cntv_ctl &= ~CNTV_CTL_ENABLE_BIT; } - +#ifndef CONFIG_USE_EL2 write_cntv_ctl_el0(cntv_ctl); +#else + write_cnthp_ctl_el2(cntv_ctl); +#endif } static ALWAYS_INLINE void arm_arch_timer_set_irq_mask(bool mask) { uint64_t cntv_ctl; - +#ifndef CONFIG_USE_EL2 cntv_ctl = read_cntv_ctl_el0(); - +#else + cntv_ctl = read_cnthp_ctl_el2(); +#endif if (mask) { cntv_ctl |= CNTV_CTL_IMASK_BIT; } else { cntv_ctl &= ~CNTV_CTL_IMASK_BIT; } - +#ifndef CONFIG_USE_EL2 write_cntv_ctl_el0(cntv_ctl); +#else + write_cnthp_ctl_el2(cntv_ctl); +#endif } static ALWAYS_INLINE uint64_t arm_arch_timer_count(void) diff --git a/makefile b/makefile index 0aa37f3c41d..ee42ce5071a 100644 --- a/makefile +++ b/makefile @@ -1,18 +1,22 @@ -boot_smp: - west build -b e2000q_demo_smp samples/arch/smp/pktqueue - cp ./build/zephyr/zephyr.elf /mnt/d/tftboot/ +boot_smp_el2: +# west build -b e2000d_demo_smp samples/arch/smp/pktqueue +# west build -b e2000d_demo_el2_smp samples/hello_world + west build -b e2000q_demo_el2_smp samples/arch/smp/pi + cp ./build/zephyr/zephyr.elf /mnt/d/tftpboot/baremetal.elf + scp ./build/zephyr/zephyr.elf root@10.31.32.21:/home/zhugy/tftpboot/huanghe/baremetal.elf boot: - west build -b e2000q_demo samples/hello_world - cp ./build/zephyr/zephyr.elf /mnt/d/tftboot/ + west build -b e2000q_demo_el2_smp samples/hello_world + cp ./build/zephyr/zephyr.elf /mnt/d/tftpboot/baremetal.elf +# scp ./build/zephyr/zephyr.elf root@10.31.32.21:/home/zhugy/tftpboot/huanghe/baremetal.elf menuconfig: west build -t menuconfig boot_gdb: - west build -b qemu_cortex_a53_smp samples/arch/smp/pi + west build -b qemu_cortex_a53_smp samples/hello_world clean: west build -t clean @@ -25,4 +29,4 @@ gdb: gdb_qemu: - gdb-multiarch -x .gitlint_qemu \ No newline at end of file + gdb-multiarch -x .gitlint_qemu diff --git a/soc/arm/phytium_s5000c/soc.c b/soc/arm/phytium_s5000c/soc.c deleted file mode 100644 index d879c4fb8d1..00000000000 --- a/soc/arm/phytium_s5000c/soc.c +++ /dev/null @@ -1,23 +0,0 @@ -// Phytium is pleased to support the open source community by making Zephyr-SDK available. - -// -// Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. - -// Licensed under the Apache-2.0 License (the "License"); you may not use this file except -// in compliance with the License. You may obtain a copy of the License at - -// https://opensource.org/license/apache-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 - -/* Boot-time static default printk handler, possibly to be overridden later. */ -int arch_printk_char_out(int c) -{ - putchar(c) ; - return 0; -} \ No newline at end of file diff --git a/soc/arm/soc.yml b/soc/arm/soc.yml index 3b471c77264..b85073bab34 100644 --- a/soc/arm/soc.yml +++ b/soc/arm/soc.yml @@ -1,39 +1,34 @@ -family: -- name: arm - series: - - name: mps2 - socs: - - name: an385 - - name: an521 - cpuclusters: - - name: cpu0 - - name: cpu1 - - name: mps3 - socs: - - name: an547 - - name: musca - socs: - - name: musca_b1 - - name: musca_s1 - - name: designstart - socs: - - name: designstart_fpga_cortex_m1 - - name: designstart_fpga_cortex_m3 - -- name: arm64 - series: - - name: fvp_aemv8a - socs: - - name: fvp_base_revc_2xaemv8a - - name: fvp_aemv8r - socs: - - name: fvp_aemv8r_aarch64 - - name: fvp_aemv8r_aarch32 - socs: - - name: qemu_cortex_a53 - - name: qemu_virt_arm64 - - name: phytium_d3000 - - name: phytium_d2000 - - name: phytium_e2000d - - name: phytium_e2000q - - name: phytium_s5000c +family: +- name: arm + series: + - name: mps2 + socs: + - name: an385 + - name: an521 + cpuclusters: + - name: cpu0 + - name: cpu1 + - name: mps3 + socs: + - name: an547 + - name: musca + socs: + - name: musca_b1 + - name: musca_s1 + - name: designstart + socs: + - name: designstart_fpga_cortex_m1 + - name: designstart_fpga_cortex_m3 + +- name: arm64 + series: + - name: fvp_aemv8a + socs: + - name: fvp_base_revc_2xaemv8a + - name: fvp_aemv8r + socs: + - name: fvp_aemv8r_aarch64 + - name: fvp_aemv8r_aarch32 + socs: + - name: qemu_cortex_a53 + - name: qemu_virt_arm64 diff --git a/soc/arm/phytium_d2000/CMakeLists.txt b/soc/phytium/d2000/CMakeLists.txt similarity index 100% rename from soc/arm/phytium_d2000/CMakeLists.txt rename to soc/phytium/d2000/CMakeLists.txt diff --git a/soc/arm/phytium_d2000/Kconfig b/soc/phytium/d2000/Kconfig similarity index 100% rename from soc/arm/phytium_d2000/Kconfig rename to soc/phytium/d2000/Kconfig diff --git a/soc/arm/phytium_d2000/Kconfig.defconfig b/soc/phytium/d2000/Kconfig.defconfig similarity index 100% rename from soc/arm/phytium_d2000/Kconfig.defconfig rename to soc/phytium/d2000/Kconfig.defconfig diff --git a/soc/arm/phytium_d2000/Kconfig.soc b/soc/phytium/d2000/Kconfig.soc similarity index 100% rename from soc/arm/phytium_d2000/Kconfig.soc rename to soc/phytium/d2000/Kconfig.soc diff --git a/soc/arm/phytium_d2000/mmu_regions.c b/soc/phytium/d2000/mmu_regions.c similarity index 100% rename from soc/arm/phytium_d2000/mmu_regions.c rename to soc/phytium/d2000/mmu_regions.c diff --git a/soc/arm/phytium_d2000/soc.c b/soc/phytium/d2000/soc.c similarity index 100% rename from soc/arm/phytium_d2000/soc.c rename to soc/phytium/d2000/soc.c diff --git a/soc/arm/phytium_d3000/CMakeLists.txt b/soc/phytium/e2000d/CMakeLists.txt similarity index 100% rename from soc/arm/phytium_d3000/CMakeLists.txt rename to soc/phytium/e2000d/CMakeLists.txt diff --git a/soc/arm/phytium_e2000d/Kconfig b/soc/phytium/e2000d/Kconfig similarity index 100% rename from soc/arm/phytium_e2000d/Kconfig rename to soc/phytium/e2000d/Kconfig diff --git a/soc/arm/phytium_e2000d/Kconfig.defconfig b/soc/phytium/e2000d/Kconfig.defconfig similarity index 96% rename from soc/arm/phytium_e2000d/Kconfig.defconfig rename to soc/phytium/e2000d/Kconfig.defconfig index e61a0be8a4c..0cb8669ed55 100644 --- a/soc/arm/phytium_e2000d/Kconfig.defconfig +++ b/soc/phytium/e2000d/Kconfig.defconfig @@ -16,7 +16,7 @@ if SOC_E2000D config SOC - default "phytium_e2000d" + default "e2000d" config NUM_IRQS int diff --git a/soc/arm/phytium_e2000d/Kconfig.soc b/soc/phytium/e2000d/Kconfig.soc similarity index 100% rename from soc/arm/phytium_e2000d/Kconfig.soc rename to soc/phytium/e2000d/Kconfig.soc diff --git a/soc/arm/phytium_e2000d/mmu_regions.c b/soc/phytium/e2000d/mmu_regions.c similarity index 100% rename from soc/arm/phytium_e2000d/mmu_regions.c rename to soc/phytium/e2000d/mmu_regions.c diff --git a/soc/arm/phytium_e2000q/soc.c b/soc/phytium/e2000d/soc.c similarity index 99% rename from soc/arm/phytium_e2000q/soc.c rename to soc/phytium/e2000d/soc.c index d879c4fb8d1..9b67afdc7b7 100644 --- a/soc/arm/phytium_e2000q/soc.c +++ b/soc/phytium/e2000d/soc.c @@ -20,4 +20,4 @@ int arch_printk_char_out(int c) { putchar(c) ; return 0; -} \ No newline at end of file +} diff --git a/soc/phytium/e2000d/soc.h b/soc/phytium/e2000d/soc.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/soc/phytium/e2000d/soc.yml b/soc/phytium/e2000d/soc.yml new file mode 100644 index 00000000000..e4b9e3ff9ac --- /dev/null +++ b/soc/phytium/e2000d/soc.yml @@ -0,0 +1,5 @@ +family: + +- name: arm64 + socs: + - name: e2000d diff --git a/soc/arm/phytium_e2000d/CMakeLists.txt b/soc/phytium/e2000q/CMakeLists.txt similarity index 100% rename from soc/arm/phytium_e2000d/CMakeLists.txt rename to soc/phytium/e2000q/CMakeLists.txt diff --git a/soc/arm/phytium_e2000q/Kconfig b/soc/phytium/e2000q/Kconfig similarity index 100% rename from soc/arm/phytium_e2000q/Kconfig rename to soc/phytium/e2000q/Kconfig diff --git a/soc/arm/phytium_e2000q/Kconfig.defconfig b/soc/phytium/e2000q/Kconfig.defconfig similarity index 96% rename from soc/arm/phytium_e2000q/Kconfig.defconfig rename to soc/phytium/e2000q/Kconfig.defconfig index af35d0a3431..d1bdd2b525d 100644 --- a/soc/arm/phytium_e2000q/Kconfig.defconfig +++ b/soc/phytium/e2000q/Kconfig.defconfig @@ -16,7 +16,7 @@ if SOC_E2000Q config SOC - default "phytium_e2000q" + default "e2000q" config NUM_IRQS int diff --git a/soc/arm/phytium_e2000q/Kconfig.soc b/soc/phytium/e2000q/Kconfig.soc similarity index 100% rename from soc/arm/phytium_e2000q/Kconfig.soc rename to soc/phytium/e2000q/Kconfig.soc diff --git a/soc/arm/phytium_e2000q/mmu_regions.c b/soc/phytium/e2000q/mmu_regions.c similarity index 100% rename from soc/arm/phytium_e2000q/mmu_regions.c rename to soc/phytium/e2000q/mmu_regions.c diff --git a/soc/arm/phytium_e2000q/pinctrl_soc.h b/soc/phytium/e2000q/pinctrl_soc.h similarity index 100% rename from soc/arm/phytium_e2000q/pinctrl_soc.h rename to soc/phytium/e2000q/pinctrl_soc.h diff --git a/soc/arm/phytium_d3000/soc.c b/soc/phytium/e2000q/soc.c similarity index 100% rename from soc/arm/phytium_d3000/soc.c rename to soc/phytium/e2000q/soc.c diff --git a/soc/phytium/e2000q/soc.yml b/soc/phytium/e2000q/soc.yml new file mode 100644 index 00000000000..eb16423c65e --- /dev/null +++ b/soc/phytium/e2000q/soc.yml @@ -0,0 +1,5 @@ +family: + +- name: arm64 + socs: + - name: e2000q diff --git a/soc/arm/phytium_e2000q/CMakeLists.txt b/soc/phytium/pd2308/CMakeLists.txt similarity index 100% rename from soc/arm/phytium_e2000q/CMakeLists.txt rename to soc/phytium/pd2308/CMakeLists.txt diff --git a/soc/arm/phytium_s5000c/Kconfig b/soc/phytium/pd2308/Kconfig similarity index 93% rename from soc/arm/phytium_s5000c/Kconfig rename to soc/phytium/pd2308/Kconfig index aaf59fb79d5..9d591128f3b 100644 --- a/soc/arm/phytium_s5000c/Kconfig +++ b/soc/phytium/pd2308/Kconfig @@ -1,7 +1,7 @@ # Copyright (c) 2024 zhangyan # SPDX-License-Identifier: Apache-2.0 -config SOC_S5000C +config SOC_PD2308 select ARM64 select CPU_PHYTIUM_FTC862 select CPU_CORTEX_A53 diff --git a/soc/arm/phytium_s5000c/Kconfig.defconfig b/soc/phytium/pd2308/Kconfig.defconfig similarity index 95% rename from soc/arm/phytium_s5000c/Kconfig.defconfig rename to soc/phytium/pd2308/Kconfig.defconfig index 5f00a34bea9..60bcd8d245f 100644 --- a/soc/arm/phytium_s5000c/Kconfig.defconfig +++ b/soc/phytium/pd2308/Kconfig.defconfig @@ -13,10 +13,10 @@ # CONDITIONS OF ANY KIND, either express or implied. See the License for the # specific language governing permissions and limitations under the License. -if SOC_S5000C +if SOC_PD2308 config SOC - default "phytium_s5000c" + default "phytium_PD2308" config NUM_IRQS int diff --git a/soc/arm/phytium_s5000c/Kconfig.soc b/soc/phytium/pd2308/Kconfig.soc similarity index 89% rename from soc/arm/phytium_s5000c/Kconfig.soc rename to soc/phytium/pd2308/Kconfig.soc index 572605098ac..95cadca507d 100644 --- a/soc/arm/phytium_s5000c/Kconfig.soc +++ b/soc/phytium/pd2308/Kconfig.soc @@ -13,14 +13,14 @@ # CONDITIONS OF ANY KIND, either express or implied. See the License for the # specific language governing permissions and limitations under the License. -config SOC_S5000C - bool "phytium_s5000c" +config SOC_PD2308 + bool "phytium_pd2308" select SOC_FAMILY_ARM64 config SOC - default "soc_s5000c" if SOC_S5000C + default "soc_pd2308" if SOC_PD2308 -if SOC_S5000C +if SOC_PD2308 config HAL_STANDALONE_SDK_DEBUG bool "standalone_sdk_debug" diff --git a/soc/arm/phytium_d3000/mmu_regions.c b/soc/phytium/pd2308/mmu_regions.c similarity index 100% rename from soc/arm/phytium_d3000/mmu_regions.c rename to soc/phytium/pd2308/mmu_regions.c diff --git a/soc/phytium/pd2308/soc.c b/soc/phytium/pd2308/soc.c new file mode 100644 index 00000000000..71dc4ec670d --- /dev/null +++ b/soc/phytium/pd2308/soc.c @@ -0,0 +1,32 @@ +/* + * Copyright : (C) 2024 Phytium Information Technology, Inc. + * All Rights Reserved. + * + * This program is OPEN SOURCE software: you can redistribute it and/or modify it + * under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd, + * either version 1.0 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the Phytium Public License for more details. + * + * + * FilePath: soc.c + * Created Date: 2024-12-04 16:39:00 + * Last Modified: 2024-12-04 16:39:01 + * Description: This file is for + * + * Modify History: + * Ver Who Date Changes + * ----- ---------- -------- --------------------------------- + */ + + +#include + +/* Boot-time static default printk handler, possibly to be overridden later. */ +int arch_printk_char_out(int c) +{ + putchar(c) ; + return 0; +} diff --git a/soc/arm/phytium_s5000c/CMakeLists.txt b/soc/phytium/ps2316/CMakeLists.txt similarity index 100% rename from soc/arm/phytium_s5000c/CMakeLists.txt rename to soc/phytium/ps2316/CMakeLists.txt diff --git a/soc/arm/phytium_d3000/Kconfig b/soc/phytium/ps2316/Kconfig similarity index 93% rename from soc/arm/phytium_d3000/Kconfig rename to soc/phytium/ps2316/Kconfig index 3d19d834304..941ce67d66f 100644 --- a/soc/arm/phytium_d3000/Kconfig +++ b/soc/phytium/ps2316/Kconfig @@ -1,7 +1,7 @@ # Copyright (c) 2024 zhangyan # SPDX-License-Identifier: Apache-2.0 -config SOC_D3000 +config SOC_PS2316 select ARM64 select CPU_PHYTIUM_FTC862 select CPU_CORTEX_A53 diff --git a/soc/arm/phytium_d3000/Kconfig.defconfig b/soc/phytium/ps2316/Kconfig.defconfig similarity index 95% rename from soc/arm/phytium_d3000/Kconfig.defconfig rename to soc/phytium/ps2316/Kconfig.defconfig index 8a7af8bc4da..eac604c61b1 100644 --- a/soc/arm/phytium_d3000/Kconfig.defconfig +++ b/soc/phytium/ps2316/Kconfig.defconfig @@ -13,10 +13,10 @@ # CONDITIONS OF ANY KIND, either express or implied. See the License for the # specific language governing permissions and limitations under the License. -if SOC_D3000 +if SOC_PS2316 config SOC - default "phytium_d3000" + default "phytium_ps2316" config NUM_IRQS int diff --git a/soc/arm/phytium_d3000/Kconfig.soc b/soc/phytium/ps2316/Kconfig.soc similarity index 89% rename from soc/arm/phytium_d3000/Kconfig.soc rename to soc/phytium/ps2316/Kconfig.soc index e36fe4a4d46..37484033ac3 100644 --- a/soc/arm/phytium_d3000/Kconfig.soc +++ b/soc/phytium/ps2316/Kconfig.soc @@ -13,14 +13,14 @@ # CONDITIONS OF ANY KIND, either express or implied. See the License for the # specific language governing permissions and limitations under the License. -config SOC_D3000 - bool "phytium_d3000" +config SOC_PS2316 + bool "phytium_ps2316" select SOC_FAMILY_ARM64 config SOC - default "soc_d3000" if SOC_D3000 + default "soc_ps2316" if SOC_PS2316 -if SOC_D3000 +if SOC_PS2316 config HAL_STANDALONE_SDK_DEBUG bool "standalone_sdk_debug" diff --git a/soc/arm/phytium_s5000c/mmu_regions.c b/soc/phytium/ps2316/mmu_regions.c similarity index 100% rename from soc/arm/phytium_s5000c/mmu_regions.c rename to soc/phytium/ps2316/mmu_regions.c diff --git a/soc/arm/phytium_e2000d/soc.c b/soc/phytium/ps2316/soc.c similarity index 100% rename from soc/arm/phytium_e2000d/soc.c rename to soc/phytium/ps2316/soc.c -- Gitee From be7d4384ceed7699acaca01c0f63c623494f839c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E8=A1=8D?= Date: Fri, 13 Dec 2024 09:34:38 +0000 Subject: [PATCH 04/13] =?UTF-8?q?d2000,pd2308,ps2316=E5=BC=80=E5=8F=91?= =?UTF-8?q?=E6=9D=BF=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- arch/arm64/core/Kconfig | 2 +- arch/arm64/core/mmu.c | 5 +- boards/deprecated.cmake | 36 ++- boards/phytium/d2000_demo/Kconfig.d2000_demo | 18 ++ boards/phytium/d2000_demo/Kconfig.defconfig | 28 ++ boards/phytium/d2000_demo/board.cmake | 1 + boards/phytium/d2000_demo/board.yml | 10 + boards/phytium/d2000_demo/d2000_demo.dts | 31 +++ boards/phytium/d2000_demo/d2000_demo.yaml | 7 + .../d2000_demo/d2000_demo_d2000_defconfig | 33 +++ .../d2000_demo/d2000_demo_d2000_el2.dts | 31 +++ .../d2000_demo/d2000_demo_d2000_el2.yaml | 7 + .../d2000_demo/d2000_demo_d2000_el2_defconfig | 36 +++ .../d2000_demo/d2000_demo_d2000_el2_smp.dts | 37 +++ .../d2000_demo/d2000_demo_d2000_el2_smp.yaml | 9 + .../d2000_demo_d2000_el2_smp_defconfig | 44 +++ .../d2000_demo/d2000_demo_d2000_smp.dts | 37 +++ .../d2000_demo/d2000_demo_d2000_smp.yaml | 9 + .../d2000_demo/d2000_demo_d2000_smp_defconfig | 41 +++ ...emo_el2.dts => e2000d_demo_e2000d_el2.dts} | 0 ...o_el2.yaml => e2000d_demo_e2000d_el2.yaml} | 2 +- ...onfig => e2000d_demo_e2000d_el2_defconfig} | 0 .../e2000d_demo_e2000d_el2_smp.yaml | 2 +- .../e2000d_demo/e2000d_demo_e2000d_smp.yaml | 2 +- boards/phytium/e2000q_demo/e2000q_demo.yaml | 2 + .../e2000q_demo/e2000q_demo_e2000q_el2.yaml | 2 +- .../e2000q_demo_e2000q_el2_smp.yaml | 2 +- .../e2000q_demo/e2000q_demo_e2000q_smp.yaml | 2 +- boards/phytium/pd2308_demo/Kconfig.defconfig | 19 ++ .../phytium/pd2308_demo/Kconfig.pd2308_demo | 18 ++ boards/phytium/pd2308_demo/board.cmake | 1 + boards/phytium/pd2308_demo/board.yml | 10 + boards/phytium/pd2308_demo/pd2308_demo.dts | 27 ++ boards/phytium/pd2308_demo/pd2308_demo.yaml | 7 + .../phytium/pd2308_demo/pd2308_demo_defconfig | 33 +++ .../pd2308_demo/pd2308_demo_pd2308_el2.dts | 27 ++ .../pd2308_demo/pd2308_demo_pd2308_el2.yaml | 7 + .../pd2308_demo_pd2308_el2_defconfig | 36 +++ .../pd2308_demo_pd2308_el2_smp.dts | 27 ++ .../pd2308_demo_pd2308_el2_smp.yaml | 9 + .../pd2308_demo_pd2308_el2_smp_defconfig | 44 +++ .../pd2308_demo/pd2308_demo_pd2308_smp.dts | 32 +++ .../pd2308_demo/pd2308_demo_pd2308_smp.yaml | 9 + .../pd2308_demo_pd2308_smp_defconfig | 41 +++ boards/phytium/ps2316_test/Kconfig.defconfig | 30 +++ .../phytium/ps2316_test/Kconfig.ps2316_test | 18 ++ boards/phytium/ps2316_test/board.cmake | 1 + boards/phytium/ps2316_test/board.yml | 10 + boards/phytium/ps2316_test/ps2316_test.dts | 49 ++++ boards/phytium/ps2316_test/ps2316_test.yaml | 10 + .../phytium/ps2316_test/ps2316_test_defconfig | 33 +++ .../ps2316_test/ps2316_test_ps2316_el2.dts | 50 ++++ .../ps2316_test/ps2316_test_ps2316_el2.yaml | 7 + .../ps2316_test_ps2316_el2_defconfig | 36 +++ .../ps2316_test_ps2316_el2_smp.dts | 50 ++++ .../ps2316_test_ps2316_el2_smp.yaml | 9 + .../ps2316_test_ps2316_el2_smp_defconfig | 44 +++ .../ps2316_test/ps2316_test_ps2316_smp.dts | 50 ++++ .../ps2316_test/ps2316_test_ps2316_smp.yaml | 10 + .../ps2316_test_ps2316_smp_defconfig | 41 +++ dts/arm64/phytium/pd2308.dtsi | 135 ++++++++++ dts/arm64/phytium/ps2316.dtsi | 254 ++++++++++++++++++ dts/bindings/vendor-prefixes.txt | 1 + soc/phytium/d2000/Kconfig | 3 +- soc/phytium/d2000/Kconfig.defconfig | 2 +- soc/phytium/d2000/soc.yml | 5 + soc/phytium/pd2308/Kconfig | 1 - soc/phytium/pd2308/Kconfig.defconfig | 4 +- soc/phytium/pd2308/Kconfig.soc | 2 +- soc/phytium/pd2308/soc.yml | 5 + soc/phytium/ps2316/Kconfig | 1 - soc/phytium/ps2316/Kconfig.defconfig | 4 +- soc/phytium/ps2316/Kconfig.soc | 2 +- soc/phytium/ps2316/soc.yml | 5 + 74 files changed, 1634 insertions(+), 21 deletions(-) create mode 100644 boards/phytium/d2000_demo/Kconfig.d2000_demo create mode 100644 boards/phytium/d2000_demo/Kconfig.defconfig create mode 100644 boards/phytium/d2000_demo/board.cmake create mode 100644 boards/phytium/d2000_demo/board.yml create mode 100644 boards/phytium/d2000_demo/d2000_demo.dts create mode 100644 boards/phytium/d2000_demo/d2000_demo.yaml create mode 100644 boards/phytium/d2000_demo/d2000_demo_d2000_defconfig create mode 100644 boards/phytium/d2000_demo/d2000_demo_d2000_el2.dts create mode 100644 boards/phytium/d2000_demo/d2000_demo_d2000_el2.yaml create mode 100644 boards/phytium/d2000_demo/d2000_demo_d2000_el2_defconfig create mode 100644 boards/phytium/d2000_demo/d2000_demo_d2000_el2_smp.dts create mode 100644 boards/phytium/d2000_demo/d2000_demo_d2000_el2_smp.yaml create mode 100644 boards/phytium/d2000_demo/d2000_demo_d2000_el2_smp_defconfig create mode 100644 boards/phytium/d2000_demo/d2000_demo_d2000_smp.dts create mode 100644 boards/phytium/d2000_demo/d2000_demo_d2000_smp.yaml create mode 100644 boards/phytium/d2000_demo/d2000_demo_d2000_smp_defconfig rename boards/phytium/e2000d_demo/{e2000d_demo_el2.dts => e2000d_demo_e2000d_el2.dts} (100%) rename boards/phytium/e2000d_demo/{e2000d_demo_el2.yaml => e2000d_demo_e2000d_el2.yaml} (71%) rename boards/phytium/e2000d_demo/{e2000d_demo_el2_defconfig => e2000d_demo_e2000d_el2_defconfig} (100%) create mode 100644 boards/phytium/pd2308_demo/Kconfig.defconfig create mode 100644 boards/phytium/pd2308_demo/Kconfig.pd2308_demo create mode 100644 boards/phytium/pd2308_demo/board.cmake create mode 100644 boards/phytium/pd2308_demo/board.yml create mode 100644 boards/phytium/pd2308_demo/pd2308_demo.dts create mode 100644 boards/phytium/pd2308_demo/pd2308_demo.yaml create mode 100644 boards/phytium/pd2308_demo/pd2308_demo_defconfig create mode 100644 boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2.dts create mode 100644 boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2.yaml create mode 100644 boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2_defconfig create mode 100644 boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2_smp.dts create mode 100644 boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2_smp.yaml create mode 100644 boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2_smp_defconfig create mode 100644 boards/phytium/pd2308_demo/pd2308_demo_pd2308_smp.dts create mode 100644 boards/phytium/pd2308_demo/pd2308_demo_pd2308_smp.yaml create mode 100644 boards/phytium/pd2308_demo/pd2308_demo_pd2308_smp_defconfig create mode 100644 boards/phytium/ps2316_test/Kconfig.defconfig create mode 100644 boards/phytium/ps2316_test/Kconfig.ps2316_test create mode 100644 boards/phytium/ps2316_test/board.cmake create mode 100644 boards/phytium/ps2316_test/board.yml create mode 100644 boards/phytium/ps2316_test/ps2316_test.dts create mode 100644 boards/phytium/ps2316_test/ps2316_test.yaml create mode 100644 boards/phytium/ps2316_test/ps2316_test_defconfig create mode 100644 boards/phytium/ps2316_test/ps2316_test_ps2316_el2.dts create mode 100644 boards/phytium/ps2316_test/ps2316_test_ps2316_el2.yaml create mode 100644 boards/phytium/ps2316_test/ps2316_test_ps2316_el2_defconfig create mode 100644 boards/phytium/ps2316_test/ps2316_test_ps2316_el2_smp.dts create mode 100644 boards/phytium/ps2316_test/ps2316_test_ps2316_el2_smp.yaml create mode 100644 boards/phytium/ps2316_test/ps2316_test_ps2316_el2_smp_defconfig create mode 100644 boards/phytium/ps2316_test/ps2316_test_ps2316_smp.dts create mode 100644 boards/phytium/ps2316_test/ps2316_test_ps2316_smp.yaml create mode 100644 boards/phytium/ps2316_test/ps2316_test_ps2316_smp_defconfig create mode 100644 dts/arm64/phytium/pd2308.dtsi create mode 100644 dts/arm64/phytium/ps2316.dtsi create mode 100644 soc/phytium/d2000/soc.yml create mode 100644 soc/phytium/pd2308/soc.yml create mode 100644 soc/phytium/ps2316/soc.yml diff --git a/arch/arm64/core/Kconfig b/arch/arm64/core/Kconfig index 014da571042..a5ad5ef1c45 100644 --- a/arch/arm64/core/Kconfig +++ b/arch/arm64/core/Kconfig @@ -44,7 +44,7 @@ config CPU_PHYTIUM_FTC862 help This option signifies the use of a Phytium-FTC862 CPU -config CPU_PHYTIUM_FTC664 +config CPU_PHYTIUM_FTC663 bool select CPU_CORTEX_A select ARMV8_A diff --git a/arch/arm64/core/mmu.c b/arch/arm64/core/mmu.c index 61810f7de07..54b38f66364 100644 --- a/arch/arm64/core/mmu.c +++ b/arch/arm64/core/mmu.c @@ -937,7 +937,7 @@ static uint64_t get_tcr(int el) return tcr; } - +#ifndef CONFIG_USE_EL2 static void enable_mmu_el1(struct arm_mmu_ptables *ptables, unsigned int flags) { ARG_UNUSED(flags); @@ -961,6 +961,7 @@ static void enable_mmu_el1(struct arm_mmu_ptables *ptables, unsigned int flags) MMU_DEBUG("MMU enabled with dcache\n"); } +#else static void enable_mmu_el2(struct arm_mmu_ptables *ptables, unsigned int flags) { ARG_UNUSED(flags); @@ -983,7 +984,7 @@ static void enable_mmu_el2(struct arm_mmu_ptables *ptables, unsigned int flags) MMU_DEBUG("MMU enabled with dcache\n"); } - +#endif /* ARM MMU Driver Initial Setup */ static struct arm_mmu_ptables kernel_ptables; diff --git a/boards/deprecated.cmake b/boards/deprecated.cmake index ae39096db03..d4da93c66d8 100644 --- a/boards/deprecated.cmake +++ b/boards/deprecated.cmake @@ -915,7 +915,6 @@ set(e2000d_demo_el2_smp_DEPRECATED e2000d_demo/e2000d/el2/smp ) - set(e2000q_demo_smp_DEPRECATED e2000q_demo/e2000q/smp ) @@ -928,4 +927,39 @@ set(e2000q_demo_el2_smp_DEPRECATED e2000q_demo/e2000q/el2/smp ) +set(d2000_demo_smp_DEPRECATED + d2000_demo/d2000/smp +) + +set(d2000_demo_el2_DEPRECATED + d2000_demo/d2000/el2 +) + +set(d2000_demo_el2_smp_DEPRECATED + d2000_demo/d2000/el2/smp +) + +set(pd2308_demo_smp_DEPRECATED + pd2308_demo/pd2308/smp +) + +set(pd2308_demo_el2_DEPRECATED + pd2308_demo/pd2308/el2 +) + +set(pd2308_demo_el2_smp_DEPRECATED + pd2308_demo/pd2308/el2/smp +) + +set(ps2316_test_smp_DEPRECATED + ps2316_test/ps2316/smp +) + +set(ps2316_test_el2_DEPRECATED + ps2316_test/ps2316/el2 +) + +set(ps2316_test_el2_smp_DEPRECATED + ps2316_test/ps2316/el2/smp +) diff --git a/boards/phytium/d2000_demo/Kconfig.d2000_demo b/boards/phytium/d2000_demo/Kconfig.d2000_demo new file mode 100644 index 00000000000..e11315682ce --- /dev/null +++ b/boards/phytium/d2000_demo/Kconfig.d2000_demo @@ -0,0 +1,18 @@ +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +# +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# https://opensource.org/license/apache-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. + +config BOARD_D2000_DEMO + bool "phytium d2000" + select SOC_D2000 diff --git a/boards/phytium/d2000_demo/Kconfig.defconfig b/boards/phytium/d2000_demo/Kconfig.defconfig new file mode 100644 index 00000000000..4285db23620 --- /dev/null +++ b/boards/phytium/d2000_demo/Kconfig.defconfig @@ -0,0 +1,28 @@ +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +# +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# https://opensource.org/license/apache-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. + + +config BOARD + default "Phytium d2000 demo" + depends on BOARD_D2000_DEMO + +if NETWORKING + +config NET_L2_ETHERNET + default y + + + +endif # NETWORKING diff --git a/boards/phytium/d2000_demo/board.cmake b/boards/phytium/d2000_demo/board.cmake new file mode 100644 index 00000000000..9881313609a --- /dev/null +++ b/boards/phytium/d2000_demo/board.cmake @@ -0,0 +1 @@ +# SPDX-License-Identifier: Apache-2.0 diff --git a/boards/phytium/d2000_demo/board.yml b/boards/phytium/d2000_demo/board.yml new file mode 100644 index 00000000000..132e76d256f --- /dev/null +++ b/boards/phytium/d2000_demo/board.yml @@ -0,0 +1,10 @@ +board: + name: d2000_demo + vendor: phytium + socs: + - name: d2000 + variants: + - name: smp + - name: el2 + variants: + - name: smp diff --git a/boards/phytium/d2000_demo/d2000_demo.dts b/boards/phytium/d2000_demo/d2000_demo.dts new file mode 100644 index 00000000000..bb59f288f27 --- /dev/null +++ b/boards/phytium/d2000_demo/d2000_demo.dts @@ -0,0 +1,31 @@ +/* + * Copyright 2024 zhangyan + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; +#include + +/ { + model = "Phytium d2000 demo"; + compatible = "phytium,d2000-demo", "phytium,d2000"; + #address-cells = <2>; + #size-cells = <2>; + +chosen { + zephyr,console = &uart1; + zephyr,shell-uart = &uart1; + zephyr,sram = &sram0; + }; +}; + +&uart1 { + current-speed = <115200>; + status = "okay"; +}; + +&uart2 { + current-speed = <115200>; + status = "okay"; +}; diff --git a/boards/phytium/d2000_demo/d2000_demo.yaml b/boards/phytium/d2000_demo/d2000_demo.yaml new file mode 100644 index 00000000000..88ef06e759f --- /dev/null +++ b/boards/phytium/d2000_demo/d2000_demo.yaml @@ -0,0 +1,7 @@ +identifier: d2000_demo +name: Phytium d2000 demo +type: mcu +arch: arm64 +toolchain: + - zephyr + - cross-compile diff --git a/boards/phytium/d2000_demo/d2000_demo_d2000_defconfig b/boards/phytium/d2000_demo/d2000_demo_d2000_defconfig new file mode 100644 index 00000000000..f816f41440e --- /dev/null +++ b/boards/phytium/d2000_demo/d2000_demo_d2000_defconfig @@ -0,0 +1,33 @@ +# SPDX-License-Identifier: Apache-2.0 + +# Platform Configuration +CONFIG_ARM64_VA_BITS_42=y +CONFIG_ARM64_PA_BITS_42=y +# Main stack size +CONFIG_MAIN_STACK_SIZE=8192 + +CONFIG_ARMV8_A_NS=y + +# Zephyr Kernel Configuration +CONFIG_XIP=n +CONFIG_FLASH_SIZE=0 +CONFIG_FLASH_BASE_ADDRESS=0x0 + +# Serial Drivers +CONFIG_SERIAL=y + +# Enable Console +CONFIG_CONSOLE=y +CONFIG_UART_CONSOLE=y + + +# Timer Drivers +CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME=y + + +#cache +CONFIG_CACHE_MANAGEMENT=y + +# PSCI is supported with NS +CONFIG_PM_CPU_OPS=y +CONFIG_PM_CPU_OPS_PSCI=y diff --git a/boards/phytium/d2000_demo/d2000_demo_d2000_el2.dts b/boards/phytium/d2000_demo/d2000_demo_d2000_el2.dts new file mode 100644 index 00000000000..bb59f288f27 --- /dev/null +++ b/boards/phytium/d2000_demo/d2000_demo_d2000_el2.dts @@ -0,0 +1,31 @@ +/* + * Copyright 2024 zhangyan + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; +#include + +/ { + model = "Phytium d2000 demo"; + compatible = "phytium,d2000-demo", "phytium,d2000"; + #address-cells = <2>; + #size-cells = <2>; + +chosen { + zephyr,console = &uart1; + zephyr,shell-uart = &uart1; + zephyr,sram = &sram0; + }; +}; + +&uart1 { + current-speed = <115200>; + status = "okay"; +}; + +&uart2 { + current-speed = <115200>; + status = "okay"; +}; diff --git a/boards/phytium/d2000_demo/d2000_demo_d2000_el2.yaml b/boards/phytium/d2000_demo/d2000_demo_d2000_el2.yaml new file mode 100644 index 00000000000..98fae9ecbb0 --- /dev/null +++ b/boards/phytium/d2000_demo/d2000_demo_d2000_el2.yaml @@ -0,0 +1,7 @@ +identifier: d2000_demo_el2 +name: Phytium d2000 demo +type: mcu +arch: arm64 +toolchain: + - zephyr + - cross-compile diff --git a/boards/phytium/d2000_demo/d2000_demo_d2000_el2_defconfig b/boards/phytium/d2000_demo/d2000_demo_d2000_el2_defconfig new file mode 100644 index 00000000000..0d19db0fb29 --- /dev/null +++ b/boards/phytium/d2000_demo/d2000_demo_d2000_el2_defconfig @@ -0,0 +1,36 @@ +# SPDX-License-Identifier: Apache-2.0 + +# Platform Configuration +CONFIG_ARM64_VA_BITS_42=y +CONFIG_ARM64_PA_BITS_42=y +# Main stack size +CONFIG_MAIN_STACK_SIZE=4096 + +CONFIG_ARMV8_A_NS=y + +# Zephyr Kernel Configuration +CONFIG_XIP=n +CONFIG_FLASH_SIZE=0 +CONFIG_FLASH_BASE_ADDRESS=0x0 + +# Serial Drivers +CONFIG_SERIAL=y + +# Enable Console +CONFIG_CONSOLE=y +CONFIG_UART_CONSOLE=y + + +# Timer Drivers +CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME=y + + +#cache +CONFIG_CACHE_MANAGEMENT=y + +# PSCI is supported with NS +CONFIG_PM_CPU_OPS=y +CONFIG_PM_CPU_OPS_PSCI=y + +# EL2 +CONFIG_USE_EL2=y diff --git a/boards/phytium/d2000_demo/d2000_demo_d2000_el2_smp.dts b/boards/phytium/d2000_demo/d2000_demo_d2000_el2_smp.dts new file mode 100644 index 00000000000..c679cdd7269 --- /dev/null +++ b/boards/phytium/d2000_demo/d2000_demo_d2000_el2_smp.dts @@ -0,0 +1,37 @@ +/* + * Copyright 2024 zhangyan + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; + +#include +/ { + model = "Phytium d2000 demo"; + compatible = "phytium,d2000-demo", "phytium,d2000"; + #address-cells = <2>; + #size-cells = <2>; + + psci { + compatible = "arm,psci-0.2"; + method = "smc"; + }; + +chosen { + zephyr,console = &uart1; + zephyr,shell-uart = &uart1; + zephyr,sram = &sram0; + }; +}; + +&uart1 { + status = "okay"; + current-speed = <115200>; +}; + +&uart2 { + status = "okay"; + current-speed = <115200>; +}; + diff --git a/boards/phytium/d2000_demo/d2000_demo_d2000_el2_smp.yaml b/boards/phytium/d2000_demo/d2000_demo_d2000_el2_smp.yaml new file mode 100644 index 00000000000..80b3cb561be --- /dev/null +++ b/boards/phytium/d2000_demo/d2000_demo_d2000_el2_smp.yaml @@ -0,0 +1,9 @@ +identifier: d2000_demo_el2_smp +name: Phytium d2000 demo +type: mcu +arch: arm64 +toolchain: + - zephyr + - cross-compile +supported: + - smp diff --git a/boards/phytium/d2000_demo/d2000_demo_d2000_el2_smp_defconfig b/boards/phytium/d2000_demo/d2000_demo_d2000_el2_smp_defconfig new file mode 100644 index 00000000000..e066e47dbe5 --- /dev/null +++ b/boards/phytium/d2000_demo/d2000_demo_d2000_el2_smp_defconfig @@ -0,0 +1,44 @@ +# SPDX-License-Identifier: Apache-2.0 + +# Platform Configuration +CONFIG_ARM64_VA_BITS_42=y +CONFIG_ARM64_PA_BITS_42=y +# Main stack size +CONFIG_MAIN_STACK_SIZE=4096 + +CONFIG_ARMV8_A_NS=y + +# Zephyr Kernel Configuration +CONFIG_XIP=n +CONFIG_FLASH_SIZE=0 +CONFIG_FLASH_BASE_ADDRESS=0x0 + +# Serial Drivers +CONFIG_SERIAL=y + +# Enable Console +CONFIG_CONSOLE=y +CONFIG_UART_CONSOLE=y + +#cache +CONFIG_CACHE_MANAGEMENT=y + +# Timer Drivers +CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME=y + +# PSCI is supported with NS +CONFIG_PM_CPU_OPS=y +CONFIG_PM_CPU_OPS_PSCI=y + +# SMP-related +CONFIG_SMP=y +CONFIG_MP_MAX_NUM_CPUS=8 +CONFIG_TIMEOUT_64BIT=y + +# CONFIG_SHELL=y +# CONFIG_SHELL_BACKEND_SERIAL_INTERRUPT_DRIVEN=n +# CONFIG_SHELL_BACKEND_SERIAL_RX_POLL_PERIOD=1 +# CONFIG_BOOT_BANNER=n + +# EL2 +CONFIG_USE_EL2=y diff --git a/boards/phytium/d2000_demo/d2000_demo_d2000_smp.dts b/boards/phytium/d2000_demo/d2000_demo_d2000_smp.dts new file mode 100644 index 00000000000..c679cdd7269 --- /dev/null +++ b/boards/phytium/d2000_demo/d2000_demo_d2000_smp.dts @@ -0,0 +1,37 @@ +/* + * Copyright 2024 zhangyan + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; + +#include +/ { + model = "Phytium d2000 demo"; + compatible = "phytium,d2000-demo", "phytium,d2000"; + #address-cells = <2>; + #size-cells = <2>; + + psci { + compatible = "arm,psci-0.2"; + method = "smc"; + }; + +chosen { + zephyr,console = &uart1; + zephyr,shell-uart = &uart1; + zephyr,sram = &sram0; + }; +}; + +&uart1 { + status = "okay"; + current-speed = <115200>; +}; + +&uart2 { + status = "okay"; + current-speed = <115200>; +}; + diff --git a/boards/phytium/d2000_demo/d2000_demo_d2000_smp.yaml b/boards/phytium/d2000_demo/d2000_demo_d2000_smp.yaml new file mode 100644 index 00000000000..d6e1cc25cec --- /dev/null +++ b/boards/phytium/d2000_demo/d2000_demo_d2000_smp.yaml @@ -0,0 +1,9 @@ +identifier: d2000_demo_smp +name: Phytium d2000 demo smp +type: mcu +arch: arm64 +toolchain: + - zephyr + - cross-compile +supported: + - smp \ No newline at end of file diff --git a/boards/phytium/d2000_demo/d2000_demo_d2000_smp_defconfig b/boards/phytium/d2000_demo/d2000_demo_d2000_smp_defconfig new file mode 100644 index 00000000000..2896228ec7e --- /dev/null +++ b/boards/phytium/d2000_demo/d2000_demo_d2000_smp_defconfig @@ -0,0 +1,41 @@ +# SPDX-License-Identifier: Apache-2.0 + +# Platform Configuration +CONFIG_ARM64_VA_BITS_42=y +CONFIG_ARM64_PA_BITS_42=y +# Main stack size +CONFIG_MAIN_STACK_SIZE=4096 + +CONFIG_ARMV8_A_NS=y + +# Zephyr Kernel Configuration +CONFIG_XIP=n +CONFIG_FLASH_SIZE=0 +CONFIG_FLASH_BASE_ADDRESS=0x0 + +# Serial Drivers +CONFIG_SERIAL=y + +# Enable Console +CONFIG_CONSOLE=y +CONFIG_UART_CONSOLE=y + +#cache +CONFIG_CACHE_MANAGEMENT=y + +# Timer Drivers +CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME=y + +# PSCI is supported with NS +CONFIG_PM_CPU_OPS=y +CONFIG_PM_CPU_OPS_PSCI=y + +# SMP-related +CONFIG_SMP=y +CONFIG_MP_MAX_NUM_CPUS=8 +CONFIG_TIMEOUT_64BIT=y + +# CONFIG_SHELL=y +# CONFIG_SHELL_BACKEND_SERIAL_INTERRUPT_DRIVEN=n +# CONFIG_SHELL_BACKEND_SERIAL_RX_POLL_PERIOD=1 +# CONFIG_BOOT_BANNER=n diff --git a/boards/phytium/e2000d_demo/e2000d_demo_el2.dts b/boards/phytium/e2000d_demo/e2000d_demo_e2000d_el2.dts similarity index 100% rename from boards/phytium/e2000d_demo/e2000d_demo_el2.dts rename to boards/phytium/e2000d_demo/e2000d_demo_e2000d_el2.dts diff --git a/boards/phytium/e2000d_demo/e2000d_demo_el2.yaml b/boards/phytium/e2000d_demo/e2000d_demo_e2000d_el2.yaml similarity index 71% rename from boards/phytium/e2000d_demo/e2000d_demo_el2.yaml rename to boards/phytium/e2000d_demo/e2000d_demo_e2000d_el2.yaml index 87ca6dcdb61..2c49d5fa807 100644 --- a/boards/phytium/e2000d_demo/e2000d_demo_el2.yaml +++ b/boards/phytium/e2000d_demo/e2000d_demo_e2000d_el2.yaml @@ -1,4 +1,4 @@ -identifier: e2000d_demo/e2000d/el2 +identifier: e2000d_demo_el2 name: Phytium e2000d demo type: mcu arch: arm64 diff --git a/boards/phytium/e2000d_demo/e2000d_demo_el2_defconfig b/boards/phytium/e2000d_demo/e2000d_demo_e2000d_el2_defconfig similarity index 100% rename from boards/phytium/e2000d_demo/e2000d_demo_el2_defconfig rename to boards/phytium/e2000d_demo/e2000d_demo_e2000d_el2_defconfig diff --git a/boards/phytium/e2000d_demo/e2000d_demo_e2000d_el2_smp.yaml b/boards/phytium/e2000d_demo/e2000d_demo_e2000d_el2_smp.yaml index 2a04357ff9d..d0ced7e0472 100644 --- a/boards/phytium/e2000d_demo/e2000d_demo_e2000d_el2_smp.yaml +++ b/boards/phytium/e2000d_demo/e2000d_demo_e2000d_el2_smp.yaml @@ -1,4 +1,4 @@ -identifier: e2000d_demo +identifier: e2000d_demo_el2_smp name: Phytium e2000d demo type: mcu arch: arm64 diff --git a/boards/phytium/e2000d_demo/e2000d_demo_e2000d_smp.yaml b/boards/phytium/e2000d_demo/e2000d_demo_e2000d_smp.yaml index 2a04357ff9d..828eb32262e 100644 --- a/boards/phytium/e2000d_demo/e2000d_demo_e2000d_smp.yaml +++ b/boards/phytium/e2000d_demo/e2000d_demo_e2000d_smp.yaml @@ -1,4 +1,4 @@ -identifier: e2000d_demo +identifier: e2000d_demo_smp name: Phytium e2000d demo type: mcu arch: arm64 diff --git a/boards/phytium/e2000q_demo/e2000q_demo.yaml b/boards/phytium/e2000q_demo/e2000q_demo.yaml index 115d5cdfd56..7485efceea0 100644 --- a/boards/phytium/e2000q_demo/e2000q_demo.yaml +++ b/boards/phytium/e2000q_demo/e2000q_demo.yaml @@ -5,3 +5,5 @@ arch: arm64 toolchain: - zephyr - cross-compile +supported: + - netif:eth diff --git a/boards/phytium/e2000q_demo/e2000q_demo_e2000q_el2.yaml b/boards/phytium/e2000q_demo/e2000q_demo_e2000q_el2.yaml index ac20226602a..437c84fc68d 100644 --- a/boards/phytium/e2000q_demo/e2000q_demo_e2000q_el2.yaml +++ b/boards/phytium/e2000q_demo/e2000q_demo_e2000q_el2.yaml @@ -1,4 +1,4 @@ -identifier: e2000q_demo/ +identifier: e2000q_demo_el2 name: Phytium e2000q demo type: mcu arch: arm64 diff --git a/boards/phytium/e2000q_demo/e2000q_demo_e2000q_el2_smp.yaml b/boards/phytium/e2000q_demo/e2000q_demo_e2000q_el2_smp.yaml index 4b9ff667a37..f54abe5aeec 100644 --- a/boards/phytium/e2000q_demo/e2000q_demo_e2000q_el2_smp.yaml +++ b/boards/phytium/e2000q_demo/e2000q_demo_e2000q_el2_smp.yaml @@ -1,4 +1,4 @@ -identifier: e2000q_demo/e2000q/smp +identifier: e2000q_demo_el2_smp name: Phytium e2000q demo type: mcu arch: arm64 diff --git a/boards/phytium/e2000q_demo/e2000q_demo_e2000q_smp.yaml b/boards/phytium/e2000q_demo/e2000q_demo_e2000q_smp.yaml index 4b9ff667a37..020f7fbd5ce 100644 --- a/boards/phytium/e2000q_demo/e2000q_demo_e2000q_smp.yaml +++ b/boards/phytium/e2000q_demo/e2000q_demo_e2000q_smp.yaml @@ -1,4 +1,4 @@ -identifier: e2000q_demo/e2000q/smp +identifier: e2000q_demo_smp name: Phytium e2000q demo type: mcu arch: arm64 diff --git a/boards/phytium/pd2308_demo/Kconfig.defconfig b/boards/phytium/pd2308_demo/Kconfig.defconfig new file mode 100644 index 00000000000..2b4010884f2 --- /dev/null +++ b/boards/phytium/pd2308_demo/Kconfig.defconfig @@ -0,0 +1,19 @@ +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +# +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# https://opensource.org/license/apache-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. + + +config BOARD + default "Phytium pd2308 demo" + depends on BOARD_PD2308_DEMO diff --git a/boards/phytium/pd2308_demo/Kconfig.pd2308_demo b/boards/phytium/pd2308_demo/Kconfig.pd2308_demo new file mode 100644 index 00000000000..52cdef8f728 --- /dev/null +++ b/boards/phytium/pd2308_demo/Kconfig.pd2308_demo @@ -0,0 +1,18 @@ +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +# +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# https://opensource.org/license/apache-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. + +config BOARD_PD2308_DEMO + bool "phytium pd2308" + select SOC_PD2308 diff --git a/boards/phytium/pd2308_demo/board.cmake b/boards/phytium/pd2308_demo/board.cmake new file mode 100644 index 00000000000..9881313609a --- /dev/null +++ b/boards/phytium/pd2308_demo/board.cmake @@ -0,0 +1 @@ +# SPDX-License-Identifier: Apache-2.0 diff --git a/boards/phytium/pd2308_demo/board.yml b/boards/phytium/pd2308_demo/board.yml new file mode 100644 index 00000000000..12f77f776c5 --- /dev/null +++ b/boards/phytium/pd2308_demo/board.yml @@ -0,0 +1,10 @@ +board: + name: pd2308_demo + vendor: phytium + socs: + - name: pd2308 + variants: + - name: smp + - name: el2 + variants: + - name: smp diff --git a/boards/phytium/pd2308_demo/pd2308_demo.dts b/boards/phytium/pd2308_demo/pd2308_demo.dts new file mode 100644 index 00000000000..d7f9fec48c0 --- /dev/null +++ b/boards/phytium/pd2308_demo/pd2308_demo.dts @@ -0,0 +1,27 @@ +/* + * Copyright 2024 zhangyan + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; +#include + +/ { + model = "Phytium pd2308 demo"; + compatible = "phytium,pd2308-demo", "phytium,pd2308"; + #address-cells = <2>; + #size-cells = <2>; + +chosen { + zephyr,console = &uart1; + zephyr,shell-uart = &uart1; + zephyr,sram = &sram0; + }; +}; + +&uart1 { + current-speed = <115200>; + status = "okay"; +}; + diff --git a/boards/phytium/pd2308_demo/pd2308_demo.yaml b/boards/phytium/pd2308_demo/pd2308_demo.yaml new file mode 100644 index 00000000000..298f3851447 --- /dev/null +++ b/boards/phytium/pd2308_demo/pd2308_demo.yaml @@ -0,0 +1,7 @@ +identifier: pd2308_demo +name: Phytium pd2308 demo +type: mcu +arch: arm64 +toolchain: + - zephyr + - cross-compile diff --git a/boards/phytium/pd2308_demo/pd2308_demo_defconfig b/boards/phytium/pd2308_demo/pd2308_demo_defconfig new file mode 100644 index 00000000000..f816f41440e --- /dev/null +++ b/boards/phytium/pd2308_demo/pd2308_demo_defconfig @@ -0,0 +1,33 @@ +# SPDX-License-Identifier: Apache-2.0 + +# Platform Configuration +CONFIG_ARM64_VA_BITS_42=y +CONFIG_ARM64_PA_BITS_42=y +# Main stack size +CONFIG_MAIN_STACK_SIZE=8192 + +CONFIG_ARMV8_A_NS=y + +# Zephyr Kernel Configuration +CONFIG_XIP=n +CONFIG_FLASH_SIZE=0 +CONFIG_FLASH_BASE_ADDRESS=0x0 + +# Serial Drivers +CONFIG_SERIAL=y + +# Enable Console +CONFIG_CONSOLE=y +CONFIG_UART_CONSOLE=y + + +# Timer Drivers +CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME=y + + +#cache +CONFIG_CACHE_MANAGEMENT=y + +# PSCI is supported with NS +CONFIG_PM_CPU_OPS=y +CONFIG_PM_CPU_OPS_PSCI=y diff --git a/boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2.dts b/boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2.dts new file mode 100644 index 00000000000..d7f9fec48c0 --- /dev/null +++ b/boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2.dts @@ -0,0 +1,27 @@ +/* + * Copyright 2024 zhangyan + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; +#include + +/ { + model = "Phytium pd2308 demo"; + compatible = "phytium,pd2308-demo", "phytium,pd2308"; + #address-cells = <2>; + #size-cells = <2>; + +chosen { + zephyr,console = &uart1; + zephyr,shell-uart = &uart1; + zephyr,sram = &sram0; + }; +}; + +&uart1 { + current-speed = <115200>; + status = "okay"; +}; + diff --git a/boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2.yaml b/boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2.yaml new file mode 100644 index 00000000000..c2080e9a8b4 --- /dev/null +++ b/boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2.yaml @@ -0,0 +1,7 @@ +identifier: pd2308_demo_el2 +name: Phytium d2000 demo +type: mcu +arch: arm64 +toolchain: + - zephyr + - cross-compile diff --git a/boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2_defconfig b/boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2_defconfig new file mode 100644 index 00000000000..0d19db0fb29 --- /dev/null +++ b/boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2_defconfig @@ -0,0 +1,36 @@ +# SPDX-License-Identifier: Apache-2.0 + +# Platform Configuration +CONFIG_ARM64_VA_BITS_42=y +CONFIG_ARM64_PA_BITS_42=y +# Main stack size +CONFIG_MAIN_STACK_SIZE=4096 + +CONFIG_ARMV8_A_NS=y + +# Zephyr Kernel Configuration +CONFIG_XIP=n +CONFIG_FLASH_SIZE=0 +CONFIG_FLASH_BASE_ADDRESS=0x0 + +# Serial Drivers +CONFIG_SERIAL=y + +# Enable Console +CONFIG_CONSOLE=y +CONFIG_UART_CONSOLE=y + + +# Timer Drivers +CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME=y + + +#cache +CONFIG_CACHE_MANAGEMENT=y + +# PSCI is supported with NS +CONFIG_PM_CPU_OPS=y +CONFIG_PM_CPU_OPS_PSCI=y + +# EL2 +CONFIG_USE_EL2=y diff --git a/boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2_smp.dts b/boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2_smp.dts new file mode 100644 index 00000000000..d7f9fec48c0 --- /dev/null +++ b/boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2_smp.dts @@ -0,0 +1,27 @@ +/* + * Copyright 2024 zhangyan + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; +#include + +/ { + model = "Phytium pd2308 demo"; + compatible = "phytium,pd2308-demo", "phytium,pd2308"; + #address-cells = <2>; + #size-cells = <2>; + +chosen { + zephyr,console = &uart1; + zephyr,shell-uart = &uart1; + zephyr,sram = &sram0; + }; +}; + +&uart1 { + current-speed = <115200>; + status = "okay"; +}; + diff --git a/boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2_smp.yaml b/boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2_smp.yaml new file mode 100644 index 00000000000..144d8474350 --- /dev/null +++ b/boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2_smp.yaml @@ -0,0 +1,9 @@ +identifier: pd2308_demo_el2_smp +name: Phytium d2000 demo +type: mcu +arch: arm64 +toolchain: + - zephyr + - cross-compile +supported: + - smp diff --git a/boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2_smp_defconfig b/boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2_smp_defconfig new file mode 100644 index 00000000000..e066e47dbe5 --- /dev/null +++ b/boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2_smp_defconfig @@ -0,0 +1,44 @@ +# SPDX-License-Identifier: Apache-2.0 + +# Platform Configuration +CONFIG_ARM64_VA_BITS_42=y +CONFIG_ARM64_PA_BITS_42=y +# Main stack size +CONFIG_MAIN_STACK_SIZE=4096 + +CONFIG_ARMV8_A_NS=y + +# Zephyr Kernel Configuration +CONFIG_XIP=n +CONFIG_FLASH_SIZE=0 +CONFIG_FLASH_BASE_ADDRESS=0x0 + +# Serial Drivers +CONFIG_SERIAL=y + +# Enable Console +CONFIG_CONSOLE=y +CONFIG_UART_CONSOLE=y + +#cache +CONFIG_CACHE_MANAGEMENT=y + +# Timer Drivers +CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME=y + +# PSCI is supported with NS +CONFIG_PM_CPU_OPS=y +CONFIG_PM_CPU_OPS_PSCI=y + +# SMP-related +CONFIG_SMP=y +CONFIG_MP_MAX_NUM_CPUS=8 +CONFIG_TIMEOUT_64BIT=y + +# CONFIG_SHELL=y +# CONFIG_SHELL_BACKEND_SERIAL_INTERRUPT_DRIVEN=n +# CONFIG_SHELL_BACKEND_SERIAL_RX_POLL_PERIOD=1 +# CONFIG_BOOT_BANNER=n + +# EL2 +CONFIG_USE_EL2=y diff --git a/boards/phytium/pd2308_demo/pd2308_demo_pd2308_smp.dts b/boards/phytium/pd2308_demo/pd2308_demo_pd2308_smp.dts new file mode 100644 index 00000000000..29d569f08ef --- /dev/null +++ b/boards/phytium/pd2308_demo/pd2308_demo_pd2308_smp.dts @@ -0,0 +1,32 @@ +/* + * Copyright 2024 zhangyan + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; + +#include +/ { + model = "Phytium pd2308 demo"; + compatible = "phytium,pd2308-demo", "phytium,pd2308"; + #address-cells = <2>; + #size-cells = <2>; + + psci { + compatible = "arm,psci-0.2"; + method = "smc"; + }; + +chosen { + zephyr,console = &uart1; + zephyr,shell-uart = &uart1; + zephyr,sram = &sram0; + }; +}; + +&uart1 { + status = "okay"; + current-speed = <115200>; +}; + diff --git a/boards/phytium/pd2308_demo/pd2308_demo_pd2308_smp.yaml b/boards/phytium/pd2308_demo/pd2308_demo_pd2308_smp.yaml new file mode 100644 index 00000000000..ba438d343f0 --- /dev/null +++ b/boards/phytium/pd2308_demo/pd2308_demo_pd2308_smp.yaml @@ -0,0 +1,9 @@ +identifier: pd2308_demo_smp +name: Phytium pd2308 demo +type: mcu +arch: arm64 +toolchain: + - zephyr + - cross-compile +supported: + - smp \ No newline at end of file diff --git a/boards/phytium/pd2308_demo/pd2308_demo_pd2308_smp_defconfig b/boards/phytium/pd2308_demo/pd2308_demo_pd2308_smp_defconfig new file mode 100644 index 00000000000..2896228ec7e --- /dev/null +++ b/boards/phytium/pd2308_demo/pd2308_demo_pd2308_smp_defconfig @@ -0,0 +1,41 @@ +# SPDX-License-Identifier: Apache-2.0 + +# Platform Configuration +CONFIG_ARM64_VA_BITS_42=y +CONFIG_ARM64_PA_BITS_42=y +# Main stack size +CONFIG_MAIN_STACK_SIZE=4096 + +CONFIG_ARMV8_A_NS=y + +# Zephyr Kernel Configuration +CONFIG_XIP=n +CONFIG_FLASH_SIZE=0 +CONFIG_FLASH_BASE_ADDRESS=0x0 + +# Serial Drivers +CONFIG_SERIAL=y + +# Enable Console +CONFIG_CONSOLE=y +CONFIG_UART_CONSOLE=y + +#cache +CONFIG_CACHE_MANAGEMENT=y + +# Timer Drivers +CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME=y + +# PSCI is supported with NS +CONFIG_PM_CPU_OPS=y +CONFIG_PM_CPU_OPS_PSCI=y + +# SMP-related +CONFIG_SMP=y +CONFIG_MP_MAX_NUM_CPUS=8 +CONFIG_TIMEOUT_64BIT=y + +# CONFIG_SHELL=y +# CONFIG_SHELL_BACKEND_SERIAL_INTERRUPT_DRIVEN=n +# CONFIG_SHELL_BACKEND_SERIAL_RX_POLL_PERIOD=1 +# CONFIG_BOOT_BANNER=n diff --git a/boards/phytium/ps2316_test/Kconfig.defconfig b/boards/phytium/ps2316_test/Kconfig.defconfig new file mode 100644 index 00000000000..0622550fb69 --- /dev/null +++ b/boards/phytium/ps2316_test/Kconfig.defconfig @@ -0,0 +1,30 @@ +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +# +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# https://opensource.org/license/apache-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. + + +config BOARD + default "Phytium ps2316 test" + depends on BOARD_PS2316_TEST + + + +if NETWORKING + +config NET_L2_ETHERNET + default y + + + +endif # NETWORKING diff --git a/boards/phytium/ps2316_test/Kconfig.ps2316_test b/boards/phytium/ps2316_test/Kconfig.ps2316_test new file mode 100644 index 00000000000..73c32ecdcf0 --- /dev/null +++ b/boards/phytium/ps2316_test/Kconfig.ps2316_test @@ -0,0 +1,18 @@ +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +# +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# https://opensource.org/license/apache-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. + +config BOARD_PS2316_TEST + bool "phytium ps2316" + select SOC_PS2316 diff --git a/boards/phytium/ps2316_test/board.cmake b/boards/phytium/ps2316_test/board.cmake new file mode 100644 index 00000000000..9881313609a --- /dev/null +++ b/boards/phytium/ps2316_test/board.cmake @@ -0,0 +1 @@ +# SPDX-License-Identifier: Apache-2.0 diff --git a/boards/phytium/ps2316_test/board.yml b/boards/phytium/ps2316_test/board.yml new file mode 100644 index 00000000000..cfa4e482be7 --- /dev/null +++ b/boards/phytium/ps2316_test/board.yml @@ -0,0 +1,10 @@ +board: + name: ps2316_test + vendor: phytium + socs: + - name: ps2316 + variants: + - name: smp + - name: el2 + variants: + - name: smp diff --git a/boards/phytium/ps2316_test/ps2316_test.dts b/boards/phytium/ps2316_test/ps2316_test.dts new file mode 100644 index 00000000000..fe7809be344 --- /dev/null +++ b/boards/phytium/ps2316_test/ps2316_test.dts @@ -0,0 +1,49 @@ +/* + * Copyright 2023 honglin leng + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; + +#include +/ { + model = "Phytium ps2316 test"; + compatible = "phytium,ps2316-test", "phytium,ps2316"; + #address-cells = <2>; + #size-cells = <2>; + + psci { + compatible = "arm,psci-0.2"; + method = "smc"; + }; + +chosen { + zephyr,console = &uart1; + zephyr,shell-uart = &uart1; + zephyr,sram = &sram0; + }; +}; + +// &sdhc1 { +// status = "okay"; +// sdmmc { +// compatible = "zephyr,sdmmc-disk"; +// status = "okay"; +// }; +// }; + +&uart1 { + status = "okay"; + current-speed = <115200>; +}; + +// &uart2 { +// status = "okay"; +// current-speed = <115200>; +// }; + +// &xmac0 { +// status = "okay"; +// local-mac-address = [00 00 00 01 02 03]; +// }; diff --git a/boards/phytium/ps2316_test/ps2316_test.yaml b/boards/phytium/ps2316_test/ps2316_test.yaml new file mode 100644 index 00000000000..e6fade4653a --- /dev/null +++ b/boards/phytium/ps2316_test/ps2316_test.yaml @@ -0,0 +1,10 @@ + +identifier: ps2316_test +name: Phytium ps2316 test +type: mcu +arch: arm64 +toolchain: + - zephyr + - cross-compile +supported: + - smp diff --git a/boards/phytium/ps2316_test/ps2316_test_defconfig b/boards/phytium/ps2316_test/ps2316_test_defconfig new file mode 100644 index 00000000000..f816f41440e --- /dev/null +++ b/boards/phytium/ps2316_test/ps2316_test_defconfig @@ -0,0 +1,33 @@ +# SPDX-License-Identifier: Apache-2.0 + +# Platform Configuration +CONFIG_ARM64_VA_BITS_42=y +CONFIG_ARM64_PA_BITS_42=y +# Main stack size +CONFIG_MAIN_STACK_SIZE=8192 + +CONFIG_ARMV8_A_NS=y + +# Zephyr Kernel Configuration +CONFIG_XIP=n +CONFIG_FLASH_SIZE=0 +CONFIG_FLASH_BASE_ADDRESS=0x0 + +# Serial Drivers +CONFIG_SERIAL=y + +# Enable Console +CONFIG_CONSOLE=y +CONFIG_UART_CONSOLE=y + + +# Timer Drivers +CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME=y + + +#cache +CONFIG_CACHE_MANAGEMENT=y + +# PSCI is supported with NS +CONFIG_PM_CPU_OPS=y +CONFIG_PM_CPU_OPS_PSCI=y diff --git a/boards/phytium/ps2316_test/ps2316_test_ps2316_el2.dts b/boards/phytium/ps2316_test/ps2316_test_ps2316_el2.dts new file mode 100644 index 00000000000..237eaf54180 --- /dev/null +++ b/boards/phytium/ps2316_test/ps2316_test_ps2316_el2.dts @@ -0,0 +1,50 @@ +/* + * Copyright 2023 honglin leng + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; + +#include +/ { + model = "Phytium ps2316 test"; + compatible = "phytium,ps2316-test", "phytium,ps2316"; + #address-cells = <2>; + #size-cells = <2>; + + psci { + compatible = "arm,psci-0.2"; + method = "smc"; + label = "PSCI"; + }; + +chosen { + zephyr,console = &uart1; + zephyr,shell-uart = &uart1; + zephyr,sram = &sram0; + }; +}; + +// &sdhc1 { +// status = "okay"; +// sdmmc { +// compatible = "zephyr,sdmmc-disk"; +// status = "okay"; +// }; +// }; + +&uart1 { + status = "okay"; + current-speed = <115200>; +}; + +// &uart2 { +// status = "okay"; +// current-speed = <115200>; +// }; + +// &xmac0 { +// status = "okay"; +// local-mac-address = [00 00 00 01 02 03]; +// }; diff --git a/boards/phytium/ps2316_test/ps2316_test_ps2316_el2.yaml b/boards/phytium/ps2316_test/ps2316_test_ps2316_el2.yaml new file mode 100644 index 00000000000..6a7a0f33d63 --- /dev/null +++ b/boards/phytium/ps2316_test/ps2316_test_ps2316_el2.yaml @@ -0,0 +1,7 @@ +identifier: ps2316_test_el2 +name: Phytium ps2316 test +type: mcu +arch: arm64 +toolchain: + - zephyr + - cross-compile diff --git a/boards/phytium/ps2316_test/ps2316_test_ps2316_el2_defconfig b/boards/phytium/ps2316_test/ps2316_test_ps2316_el2_defconfig new file mode 100644 index 00000000000..0d19db0fb29 --- /dev/null +++ b/boards/phytium/ps2316_test/ps2316_test_ps2316_el2_defconfig @@ -0,0 +1,36 @@ +# SPDX-License-Identifier: Apache-2.0 + +# Platform Configuration +CONFIG_ARM64_VA_BITS_42=y +CONFIG_ARM64_PA_BITS_42=y +# Main stack size +CONFIG_MAIN_STACK_SIZE=4096 + +CONFIG_ARMV8_A_NS=y + +# Zephyr Kernel Configuration +CONFIG_XIP=n +CONFIG_FLASH_SIZE=0 +CONFIG_FLASH_BASE_ADDRESS=0x0 + +# Serial Drivers +CONFIG_SERIAL=y + +# Enable Console +CONFIG_CONSOLE=y +CONFIG_UART_CONSOLE=y + + +# Timer Drivers +CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME=y + + +#cache +CONFIG_CACHE_MANAGEMENT=y + +# PSCI is supported with NS +CONFIG_PM_CPU_OPS=y +CONFIG_PM_CPU_OPS_PSCI=y + +# EL2 +CONFIG_USE_EL2=y diff --git a/boards/phytium/ps2316_test/ps2316_test_ps2316_el2_smp.dts b/boards/phytium/ps2316_test/ps2316_test_ps2316_el2_smp.dts new file mode 100644 index 00000000000..237eaf54180 --- /dev/null +++ b/boards/phytium/ps2316_test/ps2316_test_ps2316_el2_smp.dts @@ -0,0 +1,50 @@ +/* + * Copyright 2023 honglin leng + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; + +#include +/ { + model = "Phytium ps2316 test"; + compatible = "phytium,ps2316-test", "phytium,ps2316"; + #address-cells = <2>; + #size-cells = <2>; + + psci { + compatible = "arm,psci-0.2"; + method = "smc"; + label = "PSCI"; + }; + +chosen { + zephyr,console = &uart1; + zephyr,shell-uart = &uart1; + zephyr,sram = &sram0; + }; +}; + +// &sdhc1 { +// status = "okay"; +// sdmmc { +// compatible = "zephyr,sdmmc-disk"; +// status = "okay"; +// }; +// }; + +&uart1 { + status = "okay"; + current-speed = <115200>; +}; + +// &uart2 { +// status = "okay"; +// current-speed = <115200>; +// }; + +// &xmac0 { +// status = "okay"; +// local-mac-address = [00 00 00 01 02 03]; +// }; diff --git a/boards/phytium/ps2316_test/ps2316_test_ps2316_el2_smp.yaml b/boards/phytium/ps2316_test/ps2316_test_ps2316_el2_smp.yaml new file mode 100644 index 00000000000..e0951f2d265 --- /dev/null +++ b/boards/phytium/ps2316_test/ps2316_test_ps2316_el2_smp.yaml @@ -0,0 +1,9 @@ +identifier: ps2316_test_el2_smp +name: Phytium d2000 demo +type: mcu +arch: arm64 +toolchain: + - zephyr + - cross-compile +supported: + - smp diff --git a/boards/phytium/ps2316_test/ps2316_test_ps2316_el2_smp_defconfig b/boards/phytium/ps2316_test/ps2316_test_ps2316_el2_smp_defconfig new file mode 100644 index 00000000000..e066e47dbe5 --- /dev/null +++ b/boards/phytium/ps2316_test/ps2316_test_ps2316_el2_smp_defconfig @@ -0,0 +1,44 @@ +# SPDX-License-Identifier: Apache-2.0 + +# Platform Configuration +CONFIG_ARM64_VA_BITS_42=y +CONFIG_ARM64_PA_BITS_42=y +# Main stack size +CONFIG_MAIN_STACK_SIZE=4096 + +CONFIG_ARMV8_A_NS=y + +# Zephyr Kernel Configuration +CONFIG_XIP=n +CONFIG_FLASH_SIZE=0 +CONFIG_FLASH_BASE_ADDRESS=0x0 + +# Serial Drivers +CONFIG_SERIAL=y + +# Enable Console +CONFIG_CONSOLE=y +CONFIG_UART_CONSOLE=y + +#cache +CONFIG_CACHE_MANAGEMENT=y + +# Timer Drivers +CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME=y + +# PSCI is supported with NS +CONFIG_PM_CPU_OPS=y +CONFIG_PM_CPU_OPS_PSCI=y + +# SMP-related +CONFIG_SMP=y +CONFIG_MP_MAX_NUM_CPUS=8 +CONFIG_TIMEOUT_64BIT=y + +# CONFIG_SHELL=y +# CONFIG_SHELL_BACKEND_SERIAL_INTERRUPT_DRIVEN=n +# CONFIG_SHELL_BACKEND_SERIAL_RX_POLL_PERIOD=1 +# CONFIG_BOOT_BANNER=n + +# EL2 +CONFIG_USE_EL2=y diff --git a/boards/phytium/ps2316_test/ps2316_test_ps2316_smp.dts b/boards/phytium/ps2316_test/ps2316_test_ps2316_smp.dts new file mode 100644 index 00000000000..237eaf54180 --- /dev/null +++ b/boards/phytium/ps2316_test/ps2316_test_ps2316_smp.dts @@ -0,0 +1,50 @@ +/* + * Copyright 2023 honglin leng + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; + +#include +/ { + model = "Phytium ps2316 test"; + compatible = "phytium,ps2316-test", "phytium,ps2316"; + #address-cells = <2>; + #size-cells = <2>; + + psci { + compatible = "arm,psci-0.2"; + method = "smc"; + label = "PSCI"; + }; + +chosen { + zephyr,console = &uart1; + zephyr,shell-uart = &uart1; + zephyr,sram = &sram0; + }; +}; + +// &sdhc1 { +// status = "okay"; +// sdmmc { +// compatible = "zephyr,sdmmc-disk"; +// status = "okay"; +// }; +// }; + +&uart1 { + status = "okay"; + current-speed = <115200>; +}; + +// &uart2 { +// status = "okay"; +// current-speed = <115200>; +// }; + +// &xmac0 { +// status = "okay"; +// local-mac-address = [00 00 00 01 02 03]; +// }; diff --git a/boards/phytium/ps2316_test/ps2316_test_ps2316_smp.yaml b/boards/phytium/ps2316_test/ps2316_test_ps2316_smp.yaml new file mode 100644 index 00000000000..380da0fa9cb --- /dev/null +++ b/boards/phytium/ps2316_test/ps2316_test_ps2316_smp.yaml @@ -0,0 +1,10 @@ + +identifier: ps2316_test_smp +name: Phytium ps2316 test +type: mcu +arch: arm64 +toolchain: + - zephyr + - cross-compile +supported: + - smp diff --git a/boards/phytium/ps2316_test/ps2316_test_ps2316_smp_defconfig b/boards/phytium/ps2316_test/ps2316_test_ps2316_smp_defconfig new file mode 100644 index 00000000000..f4254033d81 --- /dev/null +++ b/boards/phytium/ps2316_test/ps2316_test_ps2316_smp_defconfig @@ -0,0 +1,41 @@ +# SPDX-License-Identifier: Apache-2.0 + +# Platform Configuration +CONFIG_ARM64_VA_BITS_42=y +CONFIG_ARM64_PA_BITS_42=y +# Main stack size +CONFIG_MAIN_STACK_SIZE=4096 + +CONFIG_ARMV8_A_NS=y + +# Zephyr Kernel Configuration +CONFIG_XIP=n +CONFIG_FLASH_SIZE=0 +CONFIG_FLASH_BASE_ADDRESS=0x0 + +# Serial Drivers +CONFIG_SERIAL=y + +# Enable Console +CONFIG_CONSOLE=y +CONFIG_UART_CONSOLE=y + +#cache +CONFIG_CACHE_MANAGEMENT=y + +# Timer Drivers +CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME=y + +# PSCI is supported with NS +CONFIG_PM_CPU_OPS=y +CONFIG_PM_CPU_OPS_PSCI=y + +# SMP-related +CONFIG_SMP=y +CONFIG_MP_MAX_NUM_CPUS=12 +CONFIG_TIMEOUT_64BIT=y + +# CONFIG_SHELL=y +# CONFIG_SHELL_BACKEND_SERIAL_INTERRUPT_DRIVEN=n +# CONFIG_SHELL_BACKEND_SERIAL_RX_POLL_PERIOD=1 +# CONFIG_BOOT_BANNER=n diff --git a/dts/arm64/phytium/pd2308.dtsi b/dts/arm64/phytium/pd2308.dtsi new file mode 100644 index 00000000000..f5b3c044477 --- /dev/null +++ b/dts/arm64/phytium/pd2308.dtsi @@ -0,0 +1,135 @@ +// Phytium is pleased to support the open source community by making Zephyr-SDK available. + +// +// Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +// +// Licensed under the Apache-2.0 License (the "License"); you may not use this file except +// in compliance with the License. You may obtain a copy of the License at +// +// https://opensource.org/license/apache-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 +#include +#include + +/ { + #address-cells = <2>; + #size-cells = <2>; + + cpus { + #address-cells = <2>; + #size-cells = <0>; + + cpu@0 { + device_type = "cpu"; + compatible = "phytium,ftc862"; + reg = <0 0x0>; + }; + + cpu@1 { + device_type = "cpu"; + compatible = "phytium,ftc862"; + reg = <0 0x100>; + }; + + cpu@2 { + device_type = "cpu"; + compatible = "phytium,ftc862"; + reg = <0 0x200>; + }; + + cpu@3 { + device_type = "cpu"; + compatible = "phytium,ftc862"; + reg = <0 0x300>; + }; + + cpu@4 { + device_type = "cpu"; + compatible = "phytium,ftc862"; + reg = <0 0x10000>; + }; + + cpu@5 { + device_type = "cpu"; + compatible = "phytium,ftc862"; + reg = <0 0x10100>; + }; + + cpu@6 { + device_type = "cpu"; + compatible = "phytium,ftc862"; + reg = <0 0x10200>; + }; + + cpu@7 { + device_type = "cpu"; + compatible = "phytium,ftc862"; + reg = <0 0x10300>; + }; + }; + + timer { + compatible = "arm,armv8-timer"; + interrupt-parent = <&gic>; + // ppi =+ 16, 13 == 29 Security physical timer interrupt, 14 == 30 Non secure physical timer interrupt + interrupts = , + , + , + ; + label = "arch_timer"; + }; + + uartclk: apb-pclk { + compatible = "fixed-clock"; + clock-frequency = <100000000>; + #clock-cells = <0>; + }; + + soc { + #address-cells = <2>; + #size-cells = <2>; + ranges; + + interrupt-parent = <&gic>; + + gic: interrupt-controller@36800000 { + compatible = "arm,gic-v3", "arm,gic"; + reg = <0x00 0x36800000 0x00 0x40000>, + <0x00 0x36860000 0x00 0x200000>; + interrupt-controller; + #interrupt-cells = <4>; + label = "GIC"; + status = "okay"; + #size-cells = <0x02>; + #address-cells = <0x02>; + }; + + uart1: uart@28009000 { + compatible = "arm,pl011"; + reg = <0x00 0x28009000 0x00 0x1000>; + status = "disabled"; + interrupts = ; + interrupt-names = "irq_0"; + clocks = <&uartclk>; + label = "UART_1"; + }; + + /* 512MB DDR */ + sram0: memory@80100000 { + device_type = "memory"; + compatible = "mmio-sram"; + reg = <0x00 0x80100000 0x00 0x40000000>; + }; + + }; +}; diff --git a/dts/arm64/phytium/ps2316.dtsi b/dts/arm64/phytium/ps2316.dtsi new file mode 100644 index 00000000000..959724656b9 --- /dev/null +++ b/dts/arm64/phytium/ps2316.dtsi @@ -0,0 +1,254 @@ + +// Phytium is pleased to support the open source community by making Zephyr-SDK available. + +// +// Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +// +// Licensed under the Apache-2.0 License (the "License"); you may not use this file except +// in compliance with the License. You may obtain a copy of the License at +// +// https://opensource.org/license/apache-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 +#include +#include + +/ { + #address-cells = <2>; + #size-cells = <2>; + + cpus { + #address-cells = <2>; + #size-cells = <0>; + + cpu@0 { + device_type = "cpu"; + compatible = "phytium,ftc862"; + reg = <0 0x0>; + }; + + cpu@1 { + device_type = "cpu"; + compatible = "phytium,ftc862"; + reg = <0 0x10000>; + }; + + cpu@2 { + device_type = "cpu"; + compatible = "phytium,ftc862"; + reg = <0 0x20000>; + }; + + cpu@3 { + device_type = "cpu"; + compatible = "phytium,ftc862"; + reg = <0 0x30000>; + }; + + cpu@4 { + device_type = "cpu"; + compatible = "phytium,ftc862"; + reg = <0 0x40000>; + }; + + cpu@5 { + device_type = "cpu"; + compatible = "phytium,ftc862"; + reg = <0 0x50000>; + }; + + cpu@6 { + device_type = "cpu"; + compatible = "phytium,ftc862"; + reg = <0 0x60000>; + }; + + cpu@7 { + device_type = "cpu"; + compatible = "phytium,ftc862"; + reg = <0 0x70000>; + }; + + cpu@8 { + device_type = "cpu"; + compatible = "phytium,ftc862"; + reg = <0 0x80000>; + }; + + cpu@9 { + device_type = "cpu"; + compatible = "phytium,ftc862"; + reg = <0 0x90000>; + }; + + cpu@10 { + device_type = "cpu"; + compatible = "phytium,ftc862"; + reg = <0 0xa0000>; + }; + + cpu@11 { + device_type = "cpu"; + compatible = "phytium,ftc862"; + reg = <0 0xb0000>; + }; + }; + + timer { + compatible = "arm,armv8-timer"; + interrupt-parent = <&gic>; + // ppi =+ 16, 13 == 29 Security physical timer interrupt, 14 == 30 Non secure physical timer interrupt + interrupts = , + , + , + ; + }; + + uartclk: apb-pclk { + compatible = "fixed-clock"; + clock-frequency = <50000000>; + #clock-cells = <0>; + }; + + soc { + #address-cells = <2>; + #size-cells = <2>; + ranges; + + interrupt-parent = <&gic>; + + gic: interrupt-controller@22000000 { + compatible = "arm,gic-v3", "arm,gic"; + reg = <0x00 0x22000000 0x00 0x40000>, + <0x00 0x220c0000 0x00 0x200000>; + interrupt-controller; + #interrupt-cells = <4>; + status = "okay"; + #size-cells = <0x02>; + #address-cells = <0x02>; + }; + + // pinctrl: pinctrl@32b30000 { + // compatible = "phytium,pinctrl"; + // reg = <0x00 0x32b30000 0x00 0x2000>; + // status = "okay"; + // }; + + uart1: uart@0x20001000 { + compatible = "arm,pl011"; + reg = <0x00 0x20001000 0x00 0x1000>; + status = "disabled"; + interrupts = ; + interrupt-names = "irq_0"; + clocks = <&uartclk>; + }; + + // uart0: uart@0x28008000 { + // compatible = "arm,pl011"; + // reg = <0x00 0x28008000 0x00 0x1000>; + // status = "disabled"; + // interrupts = ; + // interrupt-names = "irq_0"; + // clocks = <&uartclk>; + // label = "UART_0"; + // }; + + // uart2: uart@2800e000 { + // compatible = "arm,pl011"; + // reg = <0x00 0x2800e000 0x00 0x1000>; + // status = "disabled"; + // interrupts = ; + // interrupt-names = "irq_1"; + // clocks = <&uartclk>; + // label = "UART_2"; + // }; + + + // uart3: uart@2800f000 { + // compatible = "arm,pl011"; + // reg = <0x00 0x2800f000 0x00 0x1000>; + // status = "disabled"; + // interrupts = ; + // interrupt-names = "irq_0"; + // clocks = <&uartclk>; + // label = "UART_3"; + // }; + + + // sdhc0: sdhc@28000000 { + // compatible = "phytium,sdhc"; + // reg = <0x00 0x28000000 0x00 0x1000>; + // status = "disabled"; + // interrupts = ; + // max-current-330 = <1020>; + // max-bus-freq = <25000000>; + // min-bus-freq = <400000>; + // }; + + // xmac0: xmac@3200C000 { + // compatible = "phytium,xmac"; + // reg = <0x00 0x3200C000 0x00 0x2000>; + // status = "disabled"; + // interrupts = ; + // interrupt-names = "irq_0"; + // phy-poll-interval = <5000>; + // clock-frequency = <50000000> ; + // phy-speed = <1000> ; + // interface-mode = <0> ; + // dma-brust-length = <16> ; + // max-queue-num = <1> ; + // rx-buffer-descriptors = <128>; + // tx-buffer-descriptors = <128>; + // rx-buffer-size = <1600>; + // tx-buffer-size = <1600>; + // phy-autonegotiation; + // enable-fdx; + // disable-reject-fcs-crc-errors ; + // } ; + + // sdhc1: sdhc@28001000 { + // compatible = "phytium,sdhc"; + // reg = <0x00 0x28001000 0x00 0x1000>; + // status = "disabled"; + // interrupts = ; + // max-current-330 = <1020>; + // max-bus-freq = <25000000>; + // min-bus-freq = <400000>; + // }; + + /* 512MB DDR */ + sram0: memory@80100000 { + device_type = "memory"; + compatible = "mmio-sram"; + reg = <0x00 0x80100000 0x00 0x20000000>; + }; + + // temp_mem0:memory@0xe0000000 { + // device_type = "memory"; + // compatible = "mmio-sram"; + // reg = <0x00 0xe0000000 0x00 0x10000000>; + // } ; + + // pcie0: pcie@40000000 { + // compatible = "pci-host-ecam-generic"; + // device_type = "pci"; + // reg = <0x00 0x40000000 0x00 0x10000000>; + // #size-cells = <0x02>; + // #address-cells = <0x03>; + // ranges = <0x1000000 0x00 0x50000000 0x00 0x50000000 0x00 0x08000000 + // 0x2000000 0x00 0x58000000 0x00 0x58000000 0x00 0x27ffffff + // 0x3000000 0x10 0x00 0x10 0x00 0x1f 0xffffffff>; + // bus-range = <0x00 0xff>; + // }; + }; +}; diff --git a/dts/bindings/vendor-prefixes.txt b/dts/bindings/vendor-prefixes.txt index edf9c4ae825..e524453a7ad 100644 --- a/dts/bindings/vendor-prefixes.txt +++ b/dts/bindings/vendor-prefixes.txt @@ -11,6 +11,7 @@ # # zephyr-keep-sorted-start +phytium Phytium Technology 96boards 96Boards aaeon AAEON Technology Inc. abb ABB diff --git a/soc/phytium/d2000/Kconfig b/soc/phytium/d2000/Kconfig index 3a2f1a3d24e..d9a1e0285fb 100644 --- a/soc/phytium/d2000/Kconfig +++ b/soc/phytium/d2000/Kconfig @@ -3,8 +3,7 @@ config SOC_D2000 select ARM64 - select CPU_PHYTIUM_FTC862 - select CPU_CORTEX_A53 + select CPU_PHYTIUM_FTC663 select ARM_ARCH_TIMER if SYS_CLOCK_EXISTS select PHYTIUM_STANDALONE_SDK select PHYTIUM_SOFT diff --git a/soc/phytium/d2000/Kconfig.defconfig b/soc/phytium/d2000/Kconfig.defconfig index 3e8ed43a346..717aa2518b9 100644 --- a/soc/phytium/d2000/Kconfig.defconfig +++ b/soc/phytium/d2000/Kconfig.defconfig @@ -16,7 +16,7 @@ if SOC_D2000 config SOC - default "phytium_d2000" + default "d2000" config NUM_IRQS int diff --git a/soc/phytium/d2000/soc.yml b/soc/phytium/d2000/soc.yml new file mode 100644 index 00000000000..a2e5892d147 --- /dev/null +++ b/soc/phytium/d2000/soc.yml @@ -0,0 +1,5 @@ +family: + +- name: arm64 + socs: + - name: d2000 diff --git a/soc/phytium/pd2308/Kconfig b/soc/phytium/pd2308/Kconfig index 9d591128f3b..708224fbd0b 100644 --- a/soc/phytium/pd2308/Kconfig +++ b/soc/phytium/pd2308/Kconfig @@ -4,7 +4,6 @@ config SOC_PD2308 select ARM64 select CPU_PHYTIUM_FTC862 - select CPU_CORTEX_A53 select ARM_ARCH_TIMER if SYS_CLOCK_EXISTS select PHYTIUM_STANDALONE_SDK select PHYTIUM_SOFT diff --git a/soc/phytium/pd2308/Kconfig.defconfig b/soc/phytium/pd2308/Kconfig.defconfig index 60bcd8d245f..06e1237c322 100644 --- a/soc/phytium/pd2308/Kconfig.defconfig +++ b/soc/phytium/pd2308/Kconfig.defconfig @@ -16,11 +16,11 @@ if SOC_PD2308 config SOC - default "phytium_PD2308" + default "pd2308" config NUM_IRQS int - default 266 + default 195 config SYS_CLOCK_HW_CYCLES_PER_SEC int diff --git a/soc/phytium/pd2308/Kconfig.soc b/soc/phytium/pd2308/Kconfig.soc index 95cadca507d..50c230a2309 100644 --- a/soc/phytium/pd2308/Kconfig.soc +++ b/soc/phytium/pd2308/Kconfig.soc @@ -14,7 +14,7 @@ # specific language governing permissions and limitations under the License. config SOC_PD2308 - bool "phytium_pd2308" + bool "pd2308" select SOC_FAMILY_ARM64 config SOC diff --git a/soc/phytium/pd2308/soc.yml b/soc/phytium/pd2308/soc.yml new file mode 100644 index 00000000000..e638d2389c4 --- /dev/null +++ b/soc/phytium/pd2308/soc.yml @@ -0,0 +1,5 @@ +family: + +- name: arm64 + socs: + - name: pd2308 diff --git a/soc/phytium/ps2316/Kconfig b/soc/phytium/ps2316/Kconfig index 941ce67d66f..22e4c65fd5a 100644 --- a/soc/phytium/ps2316/Kconfig +++ b/soc/phytium/ps2316/Kconfig @@ -4,7 +4,6 @@ config SOC_PS2316 select ARM64 select CPU_PHYTIUM_FTC862 - select CPU_CORTEX_A53 select ARM_ARCH_TIMER if SYS_CLOCK_EXISTS select PHYTIUM_STANDALONE_SDK select PHYTIUM_SOFT diff --git a/soc/phytium/ps2316/Kconfig.defconfig b/soc/phytium/ps2316/Kconfig.defconfig index eac604c61b1..da16dd0ceb6 100644 --- a/soc/phytium/ps2316/Kconfig.defconfig +++ b/soc/phytium/ps2316/Kconfig.defconfig @@ -16,11 +16,11 @@ if SOC_PS2316 config SOC - default "phytium_ps2316" + default "ps2316" config NUM_IRQS int - default 266 + default 195 config SYS_CLOCK_HW_CYCLES_PER_SEC int diff --git a/soc/phytium/ps2316/Kconfig.soc b/soc/phytium/ps2316/Kconfig.soc index 37484033ac3..3771a56f8a9 100644 --- a/soc/phytium/ps2316/Kconfig.soc +++ b/soc/phytium/ps2316/Kconfig.soc @@ -14,7 +14,7 @@ # specific language governing permissions and limitations under the License. config SOC_PS2316 - bool "phytium_ps2316" + bool "ps2316" select SOC_FAMILY_ARM64 config SOC diff --git a/soc/phytium/ps2316/soc.yml b/soc/phytium/ps2316/soc.yml new file mode 100644 index 00000000000..5a34dcab1f7 --- /dev/null +++ b/soc/phytium/ps2316/soc.yml @@ -0,0 +1,5 @@ +family: + +- name: arm64 + socs: + - name: ps2316 -- Gitee From d83984145887b0206295a30fd1253a694118e6ef Mon Sep 17 00:00:00 2001 From: zhangyan <1422953826@qq.com> Date: Fri, 13 Dec 2024 18:27:14 +0800 Subject: [PATCH 05/13] gamc add --- boards/phytium/d2000_demo/d2000_demo.dts | 5 + drivers/ethernet/CMakeLists.txt | 1 + drivers/ethernet/Kconfig | 1 + drivers/ethernet/Kconfig.phytium_gmac | 22 + drivers/ethernet/eth_phytium_gmac.c | 764 +++++++++++++++++++++++ drivers/ethernet/eth_phytium_gmac.h | 51 ++ drivers/ethernet/eth_phytium_xmac.c | 210 +++---- dts/arm64/phytium/d2000.dtsi | 11 + dts/arm64/phytium/e2000d.dtsi | 12 +- dts/arm64/phytium/e2000q.dtsi | 10 +- dts/bindings/ethernet/phytium,gmac.yaml | 88 +++ modules/Kconfig.phytium | 2 +- 12 files changed, 1060 insertions(+), 117 deletions(-) create mode 100644 drivers/ethernet/Kconfig.phytium_gmac create mode 100644 drivers/ethernet/eth_phytium_gmac.c create mode 100644 drivers/ethernet/eth_phytium_gmac.h create mode 100644 dts/bindings/ethernet/phytium,gmac.yaml diff --git a/boards/phytium/d2000_demo/d2000_demo.dts b/boards/phytium/d2000_demo/d2000_demo.dts index bb59f288f27..fa8d244904e 100644 --- a/boards/phytium/d2000_demo/d2000_demo.dts +++ b/boards/phytium/d2000_demo/d2000_demo.dts @@ -20,6 +20,11 @@ chosen { }; }; +&gmac0 { + local-mac-address = [00 00 00 01 02 03]; + status = "okay"; +}; + &uart1 { current-speed = <115200>; status = "okay"; diff --git a/drivers/ethernet/CMakeLists.txt b/drivers/ethernet/CMakeLists.txt index 64ec4e8bb4f..692338f7754 100644 --- a/drivers/ethernet/CMakeLists.txt +++ b/drivers/ethernet/CMakeLists.txt @@ -41,6 +41,7 @@ zephyr_library_sources_ifdef(CONFIG_ETH_ADIN2111 eth_adin2111.c) zephyr_library_sources_ifdef(CONFIG_ETH_LAN865X eth_lan865x.c oa_tc6.c) zephyr_library_sources_ifdef(CONFIG_ETH_XMC4XXX eth_xmc4xxx.c) zephyr_library_sources_ifdef(CONFIG_ETH_PHYTIUM_XMAC eth_phytium_xmac.c) +zephyr_library_sources_ifdef(CONFIG_ETH_PHYTIUM_GMAC eth_phytium_gmac.c) if(CONFIG_ETH_NXP_S32_NETC) zephyr_library_sources(eth_nxp_s32_netc.c) diff --git a/drivers/ethernet/Kconfig b/drivers/ethernet/Kconfig index 0a8d90d4fa2..62568e4a155 100644 --- a/drivers/ethernet/Kconfig +++ b/drivers/ethernet/Kconfig @@ -74,6 +74,7 @@ source "drivers/ethernet/Kconfig.numaker" source "drivers/ethernet/Kconfig.lan865x" source "drivers/ethernet/Kconfig.xmc4xxx" source "drivers/ethernet/Kconfig.phytium_xmac" +source "drivers/ethernet/Kconfig.phytium_gmac" source "drivers/ethernet/eth_nxp_enet_qos/Kconfig" diff --git a/drivers/ethernet/Kconfig.phytium_gmac b/drivers/ethernet/Kconfig.phytium_gmac new file mode 100644 index 00000000000..1743ea53f2b --- /dev/null +++ b/drivers/ethernet/Kconfig.phytium_gmac @@ -0,0 +1,22 @@ +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +# +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# https://opensource.org/license/apache-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. + +menuconfig ETH_PHYTIUM_GMAC + bool "Phytium ETH_PHYTIUM_GMAC Ethernet driver" + default y + depends on DT_HAS_PHYTIUM_GMAC_ENABLED + help + Enable Phytium GMAC Ethernet driver. + diff --git a/drivers/ethernet/eth_phytium_gmac.c b/drivers/ethernet/eth_phytium_gmac.c new file mode 100644 index 00000000000..899802ec05b --- /dev/null +++ b/drivers/ethernet/eth_phytium_gmac.c @@ -0,0 +1,764 @@ +// Phytium is pleased to support the open source community by making Zephyr-SDK available. + +// +// Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +// +// Licensed under the Apache-2.0 License (the "License"); you may not use this file except +// in compliance with the License. You may obtain a copy of the License at +// +// https://opensource.org/license/apache-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 +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "fgmac.h" +#include "fgmac_hw.h" +#include "fgmac_phy.h" +#include "eth_phytium_gmac.h" + +#define LOG_MODULE_NAME phytium_gmac +#define LOG_LEVEL CONFIG_ETHERNET_LOG_LEVEL +#include +LOG_MODULE_REGISTER(LOG_MODULE_NAME); + +#define DT_DRV_COMPAT phytium_gmac + +#define GMAC_RX_DESCNUM 128 +#define GMAC_TX_DESCNUM 128 +#define FGMAC_DMA_MIN_ALIGN 128 +#define FGMAC_MAX_PACKET_SIZE 1600 +#define FGMAC_PHY_SPEED_10M 10 +#define FGMAC_PHY_SPEED_100M 100 +#define FGMAC_PHY_SPEED_1000M 1000 +#define FGMAC_PHY_HALF_DUPLEX 0 +#define FGMAC_PHY_FULL_DUPLEX 1 + +typedef void (*eth_phytium_gmac_config_irq_t)(const struct device *dev); + +#define FGMAC_CALL_EVT_HANDLER(instance_p, evt, dev) \ + {\ + if (NULL != (instance_p)->evt_handler[(evt)]) \ + { \ + (instance_p)->evt_handler[evt]((void *)(dev)); \ + }\ + } + +/* phy link */ +enum eth_phytium_link_speed { + /* The values of this enum are consecutively numbered */ + LINK_DOWN = 0, + LINK_10MBIT, + LINK_100MBIT, + LINK_1GBIT +}; + +struct eth_phytium_gmac_dev_cfg +{ + DEVICE_MMIO_ROM; + uint32_t instance_id; + eth_phytium_gmac_config_irq_t config_func; + uint32_t phy_poll_interval; + uint32_t autonegotiation; + uint32_t phy_speed; + uint32_t phy_duplex; + + uint8_t defer_rxp_to_queue; + uint8_t defer_txd_to_queue; +}; + +struct eth_phytium_gmac_dev_data +{ + DEVICE_MMIO_RAM; + struct net_if *iface; + FGmac instance; + enum eth_phytium_link_speed eff_link_speed; + + u8 tx_buf[GMAC_TX_DESCNUM * FGMAC_MAX_PACKET_SIZE] __aligned(FGMAC_DMA_MIN_ALIGN); + u8 rx_buf[GMAC_RX_DESCNUM * FGMAC_MAX_PACKET_SIZE] __aligned(FGMAC_DMA_MIN_ALIGN); + u8 tx_desc[GMAC_TX_DESCNUM * sizeof(FGmacDmaDesc)] __aligned(FGMAC_DMA_MIN_ALIGN); + u8 rx_desc[GMAC_RX_DESCNUM * sizeof(FGmacDmaDesc)] __aligned(FGMAC_DMA_MIN_ALIGN); + + uint8_t hwaddr[6]; + + struct k_work tx_done_work; + struct k_work rx_pend_work; + struct k_sem tx_done_sem; + + struct k_work_delayable phy_poll_delayed_work; + +#ifdef CONFIG_NET_STATISTICS_ETHERNET + struct net_stats_eth stats; +#endif + + bool enable_jumbo : 1; + bool multicast_addr_filiter : 1; + bool started; +}; + +static void eth_phytium_gmac_tx_done_work(struct k_work *item); +static void eth_phytium_gmac_rx_pending_work(struct k_work *item); +static void eth_phytium_gmac_iface_init(struct net_if *iface); +static enum ethernet_hw_caps eth_phytium_gmac_get_capabilities(const struct device *dev); +static int eth_phytium_gmac_send(const struct device *dev, struct net_pkt *pkt); +static int eth_phytium_gmac_start_device(const struct device *dev); +static int eth_phytium_gmac_stop_device(const struct device *dev); +static void eth_phytium_gmac_isr(const struct device *dev); +#ifdef CONFIG_NET_STATISTICS_ETHERNET +static struct net_stats_eth *eth_phytium_gmac_stats(const struct device *dev); +#endif + +static const struct ethernet_api eth_phytium_gmac_apis = +{ + .iface_api.init = eth_phytium_gmac_iface_init, + .get_capabilities = eth_phytium_gmac_get_capabilities, + .send = eth_phytium_gmac_send, + .start = eth_phytium_gmac_start_device, + .stop = eth_phytium_gmac_stop_device, +#if defined(CONFIG_NET_STATISTICS_ETHERNET) + .get_stats = eth_phytium_gmac_stats, +#endif +}; + +static void eth_phytium_gmac_poll_phy(struct k_work *work) +{ + struct k_work_delayable *dwork = k_work_delayable_from_work(work); + struct eth_phytium_gmac_dev_data *dev_data = CONTAINER_OF(dwork, struct eth_phytium_gmac_dev_data, phy_poll_delayed_work); + const struct device *dev = net_if_get_device(dev_data->iface); + const struct eth_phytium_gmac_dev_cfg *dev_conf = dev->config; + FGmac *gmac_p; + gmac_p = &dev_data->instance; + uintptr base_addr = gmac_p->config.base_addr; + + u32 link_status = FGMAC_READ_REG32(base_addr, FGMAC_MAC_PHY_STATUS); + + if(FGMAC_RGSMIIIS_LNKSTS_UP == (FGMAC_RGSMIIIS_LNKSTS & link_status)) + { + switch(gmac_p->config.speed) + { + case FGMAC_PHY_SPEED_10M: + dev_data->eff_link_speed = LINK_10MBIT ; + break ; + case FGMAC_PHY_SPEED_100M: + dev_data->eff_link_speed = LINK_100MBIT ; + break ; + case FGMAC_PHY_SPEED_1000M: + dev_data->eff_link_speed = LINK_1GBIT ; + break ; + } + net_eth_carrier_on(dev_data->iface); + } + else + { + dev_data->eff_link_speed = LINK_DOWN; + net_eth_carrier_off(dev_data->iface); + + LOG_WRN("%s link down", dev->name); + } + + k_work_reschedule(&dev_data->phy_poll_delayed_work, K_MSEC(dev_conf->phy_poll_interval)); +} + +static void eth_phytium_gmac_iface_init(struct net_if *iface) +{ + const struct device *dev = net_if_get_device(iface); + struct eth_phytium_gmac_dev_data *dev_data = dev->data; + const struct eth_phytium_gmac_dev_cfg *dev_conf = dev->config; + + /* Register Ethernet MAC Address with the upper layer */ + dev_data->iface = iface; + net_if_set_link_addr(iface, dev_data->hwaddr, 6, NET_LINK_ETHERNET); + ethernet_init(iface); + net_if_carrier_off(iface); + + /* + * Initialize the (delayed) work items for RX pending, TX done + */ + k_work_init(&dev_data->tx_done_work, eth_phytium_gmac_tx_done_work); + k_work_init(&dev_data->rx_pend_work, eth_phytium_gmac_rx_pending_work); + k_work_init_delayable(&dev_data->phy_poll_delayed_work, + eth_phytium_gmac_poll_phy); + + /* Initialize TX completion semaphore */ + k_sem_init(&dev_data->tx_done_sem, 0, 1); + + /* RX BD ring semaphore is not required at the time being */ + dev_conf->config_func(dev); + /* Submit initial PHY status polling delayed work */ + + k_work_reschedule(&dev_data->phy_poll_delayed_work, K_NO_WAIT); +} + +static void eth_phytium_gmac_isr(const struct device *dev) +{ + struct eth_phytium_gmac_dev_data *dev_data = (struct eth_phytium_gmac_dev_data *)dev->data; + FGmac *gmac_p; + gmac_p = &dev_data->instance; + uintptr base_addr = gmac_p->config.base_addr; + u32 status = 0; + + /* dma interrupt */ + status = FGMAC_READ_REG32(base_addr, FGMAC_DMA_STATUS_OFFSET); + + if (FGMAC_DMA_STATUS_GLI & status) + { + FGMAC_CALL_EVT_HANDLER(gmac_p, FGMAC_PHY_STATUS_EVT, dev); + } + + if (FGMAC_DMA_STATUS_RI & status) + { + FGMAC_CALL_EVT_HANDLER(gmac_p, FGMAC_RX_COMPLETE_EVT, dev); + FGMAC_SET_REG32(base_addr, FGMAC_DMA_STATUS_OFFSET, FGMAC_DMA_STATUS_RI); /* write to clear */ + } + + if (FGMAC_DMA_STATUS_TI & status) + { + FGMAC_CALL_EVT_HANDLER(gmac_p, FGMAC_TX_COMPLETE_EVT, dev); + FGMAC_SET_REG32(base_addr, FGMAC_DMA_STATUS_OFFSET, FGMAC_DMA_STATUS_TI); /* write to clear */ + } + + if (FGMAC_DMA_STATUS_AIS & status) + { + FGMAC_CALL_EVT_HANDLER(gmac_p, FGMAC_DMA_ERR_EVT, dev); + FGMAC_SET_REG32(base_addr, FGMAC_DMA_STATUS_OFFSET, FGMAC_DMA_STATUS_CLR_ABLE); + } + + FGMAC_WRITE_REG32(base_addr, FGMAC_DMA_STATUS_OFFSET, status); /* write to clear */ + + /* RGMII/SGMII Interrupt */ + status = FGMAC_READ_REG32(base_addr, FGMAC_INTR_STATUS_OFFSET); + if (status & FGMAC_ISR_STATUS_RSIS) + { + /* status changed, read SGMII register to clear */ + FGMAC_READ_REG32(base_addr, FGMAC_MAC_PHY_STATUS); + } + + return; +} +static void EthLinkPhyStatusChecker(const struct device *dev) +{ + struct eth_phytium_gmac_dev_data *dev_data = (struct eth_phytium_gmac_dev_data *)dev->data; + FGmac *gmac_p; + gmac_p = &dev_data->instance; + uintptr base_addr = gmac_p->config.base_addr; + u32 status = FGMAC_READ_REG32(base_addr, FGMAC_MAC_PHY_STATUS); + + if (FGMAC_RGSMIIIS_LNKSTS_UP == (FGMAC_RGSMIIIS_LNKSTS & status)) + { + printf("link is up\n"); + if(gmac_p->phy_link_status != FGMAC_LINKUP) + gmac_p->phy_link_status = FGMAC_NEGOTIATION; + } + else + { + printf("link is down\n"); + gmac_p->phy_link_status = FGMAC_LINKDOWN; + } + + return; +} + +static void EthLinkDmaErrChecker(const struct device *dev) +{ + struct eth_phytium_gmac_dev_data *dev_data = (struct eth_phytium_gmac_dev_data *)dev->data; + FGmac *gmac_p; + gmac_p = &dev_data->instance; + + uintptr base_addr = gmac_p->config.base_addr; + + u32 reg_val = FGMAC_READ_REG32(base_addr, FGMAC_DMA_INTR_OFFSET); + u32 status = FGMAC_READ_REG32(base_addr, FGMAC_DMA_STATUS_OFFSET); + + if ((FGMAC_DMA_STATUS_TPS & status) && (FGMAC_DMA_INTR_ENA_TSE & reg_val)) + { + LOG_ERR("Transmit process stopped"); + } + + if ((FGMAC_DMA_STATUS_TU & status) && (FGMAC_DMA_INTR_ENA_TUE & reg_val)) + { + LOG_ERR("Transmit Buffer Unavailable"); + } + + if ((FGMAC_DMA_STATUS_TJT & status) && (FGMAC_DMA_INTR_ENA_THE & reg_val)) + { + LOG_ERR("Transmit Jabber Timeout"); + } + + if ((FGMAC_DMA_STATUS_OVF & status) && (FGMAC_DMA_INTR_ENA_OVE & reg_val)) + { + LOG_ERR("Receive Overflow"); + } + + if ((FGMAC_DMA_STATUS_UNF & status) && (FGMAC_DMA_INTR_ENA_UNE & reg_val)) + { + LOG_ERR("Transmit Underflow"); + } + + if ((FGMAC_DMA_STATUS_RU & status) && (FGMAC_DMA_INTR_ENA_RUE & reg_val)) + { + LOG_ERR("Receive Buffer Unavailable"); + } + + if ((FGMAC_DMA_STATUS_RPS & status) && (FGMAC_DMA_INTR_ENA_RSE & reg_val)) + { + LOG_ERR("Receive Process Stopped"); + } + + if ((FGMAC_DMA_STATUS_RWT & status) && (FGMAC_DMA_INTR_ENA_RWE & reg_val)) + { + LOG_ERR("Receive Watchdog Timeout"); + } + + if ((FGMAC_DMA_STATUS_ETI & status) && (FGMAC_DMA_INTR_ENA_ETE & reg_val)) + { + LOG_ERR("Early Transmit Interrupt"); + } + + if ((FGMAC_DMA_STATUS_FBI & status) && (FGMAC_DMA_INTR_ENA_FBE & reg_val)) + { + LOG_ERR("Fatal Bus Error"); + } + + return; +} + +static void EthLinkStatusChecker(const struct device *dev) +{ + struct eth_phytium_gmac_dev_data *dev_data = (struct eth_phytium_gmac_dev_data *)dev->data; + FGmac *gmac_p; + gmac_p = &dev_data->instance; + + uintptr base_addr = gmac_p->config.base_addr; + u32 status = FGMAC_READ_REG32(base_addr, FGMAC_MAC_PHY_STATUS); + u32 speed_status, duplex_status; + u32 speed, duplex; + + /* Check the link status */ + if (FGMAC_RGSMIIIS_LNKSTS_UP == (FGMAC_RGSMIIIS_LNKSTS & status)) + { + speed_status = FGMAC_RGSMIIIS_SPEED & status; + duplex_status = FGMAC_RGSMIIIS_LNKMODE & status; + + if (FGMAC_RGSMIIIS_SPEED_125MHZ == speed_status) + speed = FGMAC_PHY_SPEED_1000; + else if (FGMAC_RGSMIIIS_SPEED_25MHZ == speed_status) + speed = FGMAC_PHY_SPEED_100; + else + speed = FGMAC_PHY_SPEED_10; + + if (FGMAC_RGSMIIIS_LNKMODE_HALF == duplex_status) + duplex = FGMAC_PHY_MODE_HALFDUPLEX; + else + duplex = FGMAC_PHY_MODE_FULLDUPLEX; + + printf("link is up --- %d/%s", + speed, (FGMAC_PHY_MODE_FULLDUPLEX == duplex) ? "full" : "half"); + } + else + { + printf("link is down ---"); + } +} + +static void eth_phytium_gmac_handle_tx_done(const struct device *dev) +{ + struct eth_phytium_gmac_dev_data *dev_data = (struct eth_phytium_gmac_dev_data *)dev->data; + FGmac *gmac_p; + gmac_p = &dev_data->instance; + + FGmacResumeDmaSend(gmac_p->config.base_addr); + LOG_INF("resume trans"); + + k_sem_give(&dev_data->tx_done_sem); + return; +} + +static void eth_phytium_gmac_tx_done_work(struct k_work *item) +{ + struct eth_phytium_gmac_dev_data *dev_data = CONTAINER_OF(item, struct eth_phytium_gmac_dev_data, tx_done_work); + const struct device *dev = net_if_get_device(dev_data->iface); + + eth_phytium_gmac_handle_tx_done(dev); +} + +static void FGmacTxDoneHandler(const struct device *dev) +{ + struct eth_phytium_gmac_dev_data *dev_data = (struct eth_phytium_gmac_dev_data *)dev->data; + struct eth_phytium_gmac_dev_cfg *dev_conf = (struct eth_phytium_gmac_dev_cfg *)dev->config; + FGmac *gmac_p; + gmac_p = &dev_data->instance; + + if (dev_conf->defer_txd_to_queue) + { + k_work_submit(&dev_data->tx_done_work); + } + else + { + eth_phytium_gmac_handle_tx_done(dev); + } +} + +static void eth_phytium_gmac_handle_rx_pending(const struct device *dev) +{ + struct eth_phytium_gmac_dev_data *dev_data = (struct eth_phytium_gmac_dev_data *)dev->data; + FGmac *gmac_p; + gmac_p = &dev_data->instance; + struct net_pkt *pkt; + volatile FGmacDmaDesc *dma_rx_desc; + u16 rx_data_length = 0; + u8 *buffer; + + u32 desc_buffer_index; /* For Current Desc buffer buf position */ + u32 desc_buffer_last_index;/* For Last Desc buffer buf position */ + u32 rx_buffer_size = FGMAC_MAX_PACKET_SIZE & GENMASK(10, 0); /* Size of a rx buffer */ + + /* get received frame */ + if (FGmacRecvFrame(gmac_p) != FT_SUCCESS) + { + LOG_ERR("FGmacRecvFrame failed!\n"); + } + + desc_buffer_last_index = gmac_p->rx_ring.desc_buf_idx; + rx_data_length = (gmac_p->rx_desc[desc_buffer_last_index].status & FGMAC_DMA_RDES0_FRAME_LEN_MASK) >> FGMAC_DMA_RDES0_FRAME_LEN_SHIFT; + buffer = (u8 *)(intptr)(gmac_p->rx_desc[gmac_p->rx_ring.desc_first_buf_idx].buf_addr); + + pkt = net_pkt_rx_alloc_with_buffer(dev_data->iface, rx_data_length, AF_UNSPEC, 0, K_FOREVER); + if (pkt == NULL) + { + LOG_ERR("RX packet buffer alloc failed: %u bytes", rx_data_length); +#ifdef CONFIG_NET_STATISTICS_ETHERNET + dev_data->stats.errors.rx++; + dev_data->stats.error_details.rx_no_buffer_count++; +#endif + } + else + { + desc_buffer_index = gmac_p->rx_ring.desc_first_buf_idx; + while (rx_data_length > rx_buffer_size) + { + net_pkt_write(pkt, buffer, rx_buffer_size); + rx_data_length = rx_data_length - rx_buffer_size; + FGMAC_DMA_INC_DESC(desc_buffer_index, gmac_p->rx_ring.desc_max_num); + dma_rx_desc = &gmac_p->rx_desc[desc_buffer_index]; + buffer = (u8 *)(intptr)(dma_rx_desc->buf_addr); + } + desc_buffer_index = gmac_p->rx_ring.desc_first_buf_idx; + dma_rx_desc = &gmac_p->rx_desc[desc_buffer_index]; + net_pkt_write(pkt, buffer, rx_data_length); + if (net_recv_data(dev_data->iface, pkt) < 0) + { + printf("%s RX packet hand-over to IP stack failed", dev->name); + net_pkt_unref(pkt); + } + } + + for (desc_buffer_index = gmac_p->rx_ring.desc_first_buf_idx; desc_buffer_index != gmac_p->rx_ring.desc_idx; FGMAC_DMA_INC_DESC(desc_buffer_index, gmac_p->rx_ring.desc_max_num)) + { + dma_rx_desc = &gmac_p->rx_desc[desc_buffer_index]; + dma_rx_desc->status |= FGMAC_DMA_RDES0_OWN; + } + /* Sync index */ + gmac_p->rx_ring.desc_buf_idx = gmac_p->rx_ring.desc_idx; + + FGmacResumeDmaRecv(gmac_p->config.base_addr); +} + +static void eth_phytium_gmac_rx_pending_work(struct k_work *item) +{ + struct eth_phytium_gmac_dev_data *dev_data = CONTAINER_OF(item, struct eth_phytium_gmac_dev_data, rx_pend_work); + const struct device *dev = net_if_get_device(dev_data->iface); + + eth_phytium_gmac_handle_rx_pending(dev); +} + +static void FGmacRecvHandler(const struct device *dev) +{ + struct eth_phytium_gmac_dev_data *dev_data = (struct eth_phytium_gmac_dev_data *)dev->data; + struct eth_phytium_gmac_dev_cfg *dev_conf = (struct eth_phytium_gmac_dev_cfg *)dev->config; + FGmac *gmac_p; + gmac_p = &dev_data->instance; + + if (dev_conf->defer_rxp_to_queue) + { + k_work_submit(&dev_data->rx_pend_work); + } + else + { + LOG_INF("recv data \r\n"); + eth_phytium_gmac_handle_rx_pending(dev); + LOG_INF("recv data exit \r\n"); + } +} + +static int FGmacSetupIsr(const struct device *dev) +{ + struct eth_phytium_gmac_dev_data *dev_data = (struct eth_phytium_gmac_dev_data *)dev->data; + FGmac *gmac_p; + gmac_p = &dev_data->instance; + + /* disable all gmac & dma intr */ + FGmacSetInterruptMask(gmac_p, FGMAC_CTRL_INTR, FGMAC_ISR_MASK_ALL_BITS); + FGmacSetInterruptMask(gmac_p, FGMAC_DMA_INTR, FGMAC_DMA_INTR_ENA_ALL_MASK); + + FGmacRegisterEvtHandler(gmac_p, FGMAC_PHY_STATUS_EVT, EthLinkPhyStatusChecker); + FGmacRegisterEvtHandler(gmac_p, FGMAC_DMA_ERR_EVT, EthLinkDmaErrChecker); + FGmacRegisterEvtHandler(gmac_p, FGMAC_LINK_STATUS_EVT, EthLinkStatusChecker); + + FGmacRegisterEvtHandler(gmac_p, FGMAC_TX_COMPLETE_EVT, FGmacTxDoneHandler); + FGmacRegisterEvtHandler(gmac_p, FGMAC_RX_COMPLETE_EVT, FGmacRecvHandler); + + return 0; +} + +static int eth_phytium_gmac_dev_init(const struct device *dev) +{ + struct eth_phytium_gmac_dev_data *dev_data = (struct eth_phytium_gmac_dev_data *)dev->data; + struct eth_phytium_gmac_dev_cfg *dev_conf = (struct eth_phytium_gmac_dev_cfg *)dev->config; + FGmac *gmac_p; + FError status; + FGmacConfig mac_config; + gmac_p = &dev_data->instance; + mac_config = *FGmacLookupConfig(dev_conf->instance_id); + /* init base */ + DEVICE_MMIO_MAP(dev, K_MEM_CACHE_NONE); + /* config init */ + mac_config.base_addr = DEVICE_MMIO_GET(dev); + mac_config.instance_id = 0; + + if(dev_conf->autonegotiation) + { + mac_config.en_auto_negtiation = 1; + } + else + { + mac_config.en_auto_negtiation = 0; + } + + switch (dev_conf->phy_speed) + { + case FGMAC_PHY_SPEED_10M: + mac_config.speed = 10; + break; + case FGMAC_PHY_SPEED_100M: + mac_config.speed = 100; + break; + case FGMAC_PHY_SPEED_1000M: + mac_config.speed = 1000; + break; + default: + LOG_ERR("setting speed is not valid , speed is %d", dev_conf->phy_speed); + return -EIO; + } + + switch(dev_conf->phy_duplex) + { + case FGMAC_PHY_HALF_DUPLEX: + mac_config.duplex_mode = 0; + break; + case FGMAC_PHY_FULL_DUPLEX: + mac_config.duplex_mode = 1; + break; + } + status = FGmacCfgInitialize(gmac_p, &mac_config); + + if (status != FGMAC_SUCCESS) + { + LOG_ERR("In %s:EmacPs Configuration Failed....\r\n", __func__); + } + if(dev_data->multicast_addr_filiter) + { + FGmacMulticastHashEnable(gmac_p); + } + + if(dev_data->enable_jumbo) + { + FGmacJumboEnable(gmac_p); + } + + FGmacSetMacAddr(dev_data->instance.config.base_addr, (void *)(dev_data->hwaddr)); + /* step 4: initialize phy */ + status = FGmacPhyCfgInitialize(gmac_p, GMAC_PHY_RESET_ENABLE); + if(status!=FGMAC_SUCCESS) + { + LOG_ERR("FGmacPhyCfgInitialize: init phy failed \r\n"); + } + /* step 5: initialize dma */ + /* Initialize Rx Description list : ring Mode */ + status = FGmacSetupRxDescRing(gmac_p, (FGmacDmaDesc *)(dev_data->rx_desc), dev_data->rx_buf, FGMAC_MAX_PACKET_SIZE, GMAC_RX_DESCNUM); + if (FT_SUCCESS != status) + { + LOG_ERR("gmac setup rx return err code %d\r\n", status); + FASSERT(FT_SUCCESS == status); + } + + /* Initialize Tx Description list : ring Mode */ + status = FGmacSetupTxDescRing(gmac_p, (FGmacDmaDesc *)(dev_data->tx_desc), dev_data->tx_buf, FGMAC_MAX_PACKET_SIZE, GMAC_TX_DESCNUM); + if (FT_SUCCESS != status) + { + LOG_ERR("gmac setup tx return err code %d\r\n", status); + FASSERT(FT_SUCCESS == status); + } + + /* step 6: initialize interrupt */ + FGmacSetupIsr(dev); + return 0; +} + +static int eth_phytium_gmac_start_device(const struct device *dev) +{ + struct eth_phytium_gmac_dev_data *dev_data = (struct eth_phytium_gmac_dev_data *)dev->data; + /* Setup callbacks */ + if (dev_data->started) { + return 0; + } + dev_data->started = true; + + FGmac *gmac_p; + gmac_p = &dev_data->instance; + FGmacStartTrans(gmac_p); + + FGmacSetInterruptUmask(gmac_p, FGMAC_CTRL_INTR, FGMAC_ISR_MASK_RSIM); + FGmacSetInterruptUmask(gmac_p, FGMAC_DMA_INTR, FGMAC_DMA_INTR_ENA_NIE | FGMAC_DMA_INTR_ENA_RIE | FGMAC_DMA_INTR_ENA_AIE | FGMAC_DMA_INTR_ENA_TIE); + return 0; +} + +static int eth_phytium_gmac_stop_device(const struct device *dev) +{ + struct eth_phytium_gmac_dev_data *dev_data = (struct eth_phytium_gmac_dev_data *)dev->data; + /* Setup callbacks */ + if (dev_data->started) { + return 0; + } + dev_data->started = false; + + FGmac *gmac_p; + gmac_p = &dev_data->instance; + + /* Cancel the delayed work that polls the link state */ + if (k_work_delayable_remaining_get(&dev_data->phy_poll_delayed_work) != 0) + { + k_work_cancel_delayable(&dev_data->phy_poll_delayed_work); + } + + FGmacStopTrans(gmac_p); + return 0; +} + +static enum ethernet_hw_caps eth_phytium_gmac_get_capabilities(const struct device *dev) +{ + struct eth_phytium_gmac_dev_cfg *dev_cfg = (struct eth_phytium_gmac_dev_cfg *)dev->config; + enum ethernet_hw_caps caps = (enum ethernet_hw_caps)0; + switch (dev_cfg->phy_speed) + { + case FGMAC_PHY_SPEED_10M: + caps |= ETHERNET_LINK_10BASE_T; + break; + case FGMAC_PHY_SPEED_100M: + caps |= (ETHERNET_LINK_100BASE_T | + ETHERNET_LINK_10BASE_T); + break; + case FGMAC_PHY_SPEED_1000M: + caps |= (ETHERNET_LINK_1000BASE_T | + ETHERNET_LINK_100BASE_T | + ETHERNET_LINK_10BASE_T); + break; + } + + return caps; +} +static int eth_phytium_gmac_send(const struct device *dev, struct net_pkt *pkt) +{ + struct eth_phytium_gmac_dev_data *dev_data = (struct eth_phytium_gmac_dev_data *)dev->data; + int res; + FError ret; + FGmac *gmac_p; + volatile FGmacDmaDesc *dma_tx_desc; + u8 *buffer = NULL; + gmac_p = &dev_data->instance; + dma_tx_desc = &gmac_p->tx_desc[gmac_p->tx_ring.desc_buf_idx]; + buffer = (u8 *)(intptr)(dma_tx_desc->buf_addr); + + if (buffer == NULL) + { + printf(" error buffer is 0 \r\n"); + return -EIO; + } + + if (!dev_data->started || (!net_if_flag_is_set(dev_data->iface, NET_IF_UP))) + { +#ifdef CONFIG_NET_STATISTICS_ETHERNET + dev_data->stats.tx_dropped++; +#endif + return -EIO; + } + + uint16_t remaining_read = net_pkt_get_len(pkt); + uint16_t total_len = remaining_read; + if (total_len == 0) { + LOG_ERR("%s cannot TX, zero packet length", dev->name); +#ifdef CONFIG_NET_STATISTICS_ETHERNET + dev_data->stats.tx_dropped++; +#endif + return -EINVAL; + } + + while (remaining_read > FGMAC_MAX_PACKET_SIZE) + { + if (net_pkt_read(pkt, buffer, FGMAC_MAX_PACKET_SIZE)) { + res = -ENOBUFS; + goto error; + } + FGMAC_DMA_INC_DESC(gmac_p->tx_ring.desc_buf_idx, gmac_p->tx_ring.desc_max_num); + dma_tx_desc = &gmac_p->tx_desc[gmac_p->tx_ring.desc_buf_idx]; + buffer = (u8 *)(intptr)(dma_tx_desc->buf_addr); + remaining_read -= FGMAC_MAX_PACKET_SIZE; + } + if (net_pkt_read(pkt, buffer, remaining_read)) + { + res = -ENOBUFS; + goto error; + } + else + { + } + + FGMAC_DMA_INC_DESC(gmac_p->tx_ring.desc_buf_idx, gmac_p->tx_ring.desc_max_num); + + ret = FGmacSendFrame(gmac_p, total_len); + if (ret != FGMAC_SUCCESS) + { + res = -ENOBUFS; + LOG_INF("error errval = ERR_USE; FGmacSendFrame\r\n"); + goto error; + } + +error: + FGmacResmuDmaUnderflow(gmac_p->config.base_addr); + + return res; +} + +#ifdef CONFIG_NET_STATISTICS_ETHERNET + +static struct net_stats_eth *eth_phytium_gmac_stats(const struct device *dev) +{ + struct eth_phytium_gmac_dev_data *dev_data = dev->data; + + return &dev_data->stats; +} +#endif + + +DT_INST_FOREACH_STATUS_OKAY(ETH_PHYTIUM_GMAC_INITIALIZE) \ No newline at end of file diff --git a/drivers/ethernet/eth_phytium_gmac.h b/drivers/ethernet/eth_phytium_gmac.h new file mode 100644 index 00000000000..e821b9623ce --- /dev/null +++ b/drivers/ethernet/eth_phytium_gmac.h @@ -0,0 +1,51 @@ +#ifndef _ZEPHYR_DRIVERS_ETHERNET_ETH_PHYTIUM_GMAC_H_ +#define _ZEPHYR_DRIVERS_ETHERNET_ETH_PHYTIUM_GMAC_H_ + +/* Device configuration data declaration macro */ +#define ETH_PHYTIUM_GMAC_DEV_CONFIG(port) \ +static const struct eth_phytium_gmac_dev_cfg eth_phytium_gmac##port##_dev_cfg = {\ + DEVICE_MMIO_ROM_INIT(DT_DRV_INST(port)), \ + .instance_id = port, \ + .config_func = eth_phytium_gmac##port##_irq_config,\ + .phy_poll_interval = DT_INST_PROP(port, phy_poll_interval),\ + .defer_rxp_to_queue = !DT_INST_PROP(port, handle_rx_in_isr),\ + .defer_txd_to_queue = DT_INST_PROP(port, handle_tx_in_workq),\ + .autonegotiation = (uint32_t)DT_INST_PROP(port, autonegotiation),\ + .phy_speed = (uint32_t)DT_INST_PROP(port, phy_speed),\ + .phy_duplex = (uint32_t)DT_INST_PROP(port, phy_duplex),\ +}; + +/* Device run-time data declaration macro */ +#define ETH_PHYTIUM_GMAC_DEV_DATA(port) \ +static struct eth_phytium_gmac_dev_data eth_phytium_gmac##port##_dev_data = {\ + .hwaddr = DT_INST_PROP(port, local_mac_address),\ +}; + +/* Interrupt configuration function macro */ +#define ETH_PHYTIUM_GMAC_CONFIG_IRQ_FUNC(port) \ +static void eth_phytium_gmac##port##_irq_config(const struct device *dev)\ +{\ + ARG_UNUSED(dev);\ + IRQ_CONNECT(DT_INST_IRQN(port), DT_INST_IRQ(port, priority),\ + eth_phytium_gmac_isr, DEVICE_DT_INST_GET(port), 0);\ + irq_enable(DT_INST_IRQN(port));\ +} + +#define ETH_PHYTIUM_GMAC_NET_DEV_INIT(port) \ +ETH_NET_DEVICE_DT_INST_DEFINE(port,\ + eth_phytium_gmac_dev_init,\ + NULL,\ + ð_phytium_gmac##port##_dev_data,\ + ð_phytium_gmac##port##_dev_cfg,\ + CONFIG_ETH_INIT_PRIORITY,\ + ð_phytium_gmac_apis,\ + NET_ETH_MTU); + +/* Top-level device initialization macro - bundles all of the above */ +#define ETH_PHYTIUM_GMAC_INITIALIZE(port) \ +ETH_PHYTIUM_GMAC_CONFIG_IRQ_FUNC(port);\ +ETH_PHYTIUM_GMAC_DEV_CONFIG(port);\ +ETH_PHYTIUM_GMAC_DEV_DATA(port);\ +ETH_PHYTIUM_GMAC_NET_DEV_INIT(port);\ + +#endif diff --git a/drivers/ethernet/eth_phytium_xmac.c b/drivers/ethernet/eth_phytium_xmac.c index b2afd1b3565..043e3873f6c 100644 --- a/drivers/ethernet/eth_phytium_xmac.c +++ b/drivers/ethernet/eth_phytium_xmac.c @@ -84,7 +84,7 @@ enum eth_phytium_link_speed { struct eth_phytium_xmac_dev_cfg { DEVICE_MMIO_ROM; - uint32_t instance_id ; /* */ + uint32_t instance_id; /* */ eth_phytiium_xmac_config_irq_t config_func; uint32_t pll_clock_frequency; @@ -98,12 +98,12 @@ struct eth_phytium_xmac_dev_cfg { uint16_t tx_buffer_size; /* dtc defined */ - uint32_t phy_speed ; /* FXMAC_PHY_SPEED_XX */ - uint32_t interface_mode ; /* followed by FXmacLwipPortInterface */ - uint32_t dma_brust_length ; + uint32_t phy_speed; /* FXMAC_PHY_SPEED_XX */ + uint32_t interface_mode; /* followed by FXmacLwipPortInterface */ + uint32_t dma_brust_length; uint32_t max_queue_num; /* Number of Xmac Controller Queues */ - bool phy_autonegotiation : 1 ; - bool enable_fdx : 1 ; + bool phy_autonegotiation : 1; + bool enable_fdx : 1; bool enable_jumbo : 1; bool enable_ucast_hash :1; bool copy_all_frames :1; @@ -116,9 +116,9 @@ struct eth_phytium_xmac_dev_cfg { struct eth_phytium_xmac_dev_data { DEVICE_MMIO_RAM; /* used for controller base address */ struct net_if *iface; - FXmac instance ; + FXmac instance; uint8_t mac_addr[6]; - enum eth_phytium_link_speed eff_link_speed ; + enum eth_phytium_link_speed eff_link_speed; struct k_work tx_done_work; struct k_work rx_pend_work; struct k_sem tx_done_sem; @@ -133,31 +133,31 @@ struct eth_phytium_xmac_dev_data { struct net_stats_eth stats; #endif - uint8_t *rx_bdspace ; - uint8_t *rx_bdspace_virt ; - uint8_t *tx_bdspace ; - uint8_t *tx_bdspace_virt ; + uint8_t *rx_bdspace; + uint8_t *rx_bdspace_virt; + uint8_t *tx_bdspace; + uint8_t *tx_bdspace_virt; - uint8_t *first_rx_buffer ; - uint8_t *first_rx_buffer_virt ; - uint8_t *first_tx_buffer ; - uint8_t *first_tx_buffer_virt ; + uint8_t *first_rx_buffer; + uint8_t *first_rx_buffer_virt; + uint8_t *first_tx_buffer; + uint8_t *first_tx_buffer_virt; bool started; }; -static int eth_phytium_xmac_dev_init(const struct device *dev) ; -static void eth_phytium_xmac_iface_init(struct net_if *iface) ; -static enum ethernet_hw_caps eth_phytium_xmac_get_capabilities(const struct device *dev) ; -static int eth_phytium_xmac_send(const struct device *dev, struct net_pkt *pkt) ; -static int eth_phytium_xmac_start_device(const struct device *dev) ; -static int eth_phytium_xmac_stop_device(const struct device *dev) ; +static int eth_phytium_xmac_dev_init(const struct device *dev); +static void eth_phytium_xmac_iface_init(struct net_if *iface); +static enum ethernet_hw_caps eth_phytium_xmac_get_capabilities(const struct device *dev); +static int eth_phytium_xmac_send(const struct device *dev, struct net_pkt *pkt); +static int eth_phytium_xmac_start_device(const struct device *dev); +static int eth_phytium_xmac_stop_device(const struct device *dev); #ifdef CONFIG_NET_STATISTICS_ETHERNET -static struct net_stats_eth *eth_phytium_xmac_stats(const struct device *dev) ; +static struct net_stats_eth *eth_phytium_xmac_stats(const struct device *dev); #endif -static void eth_phytium_xmac_isr(const struct device *dev) ; +static void eth_phytium_xmac_isr(const struct device *dev); static const struct ethernet_api eth_phytium_xmac_apis = { .iface_api.init = eth_phytium_xmac_iface_init, @@ -178,7 +178,7 @@ static const struct ethernet_api eth_phytium_xmac_apis = { DT_INST_FOREACH_STATUS_OKAY(ETH_PHYTIUM_XMAC_INITIALIZE) -static void FXmacSetupIsr(const struct device *dev) ; +static void FXmacSetupIsr(const struct device *dev); static uint32_t phy_autoneg_status(FXmac *xmac_p, uint32_t phy_addr) { @@ -219,7 +219,7 @@ static u32 phy_link_detect(FXmac *xmac_p, u32 phy_addr) FXmacLinkStatus FXmacRgmiiLinkDetect(const struct device *dev) { - struct eth_phytium_xmac_dev_data *dev_data = (struct eth_phytium_xmac_dev_data *)dev->data ; + struct eth_phytium_xmac_dev_data *dev_data = (struct eth_phytium_xmac_dev_data *)dev->data; FXmac *instance_p; instance_p = &dev_data->instance; @@ -263,7 +263,7 @@ FXmacLinkStatus FXmacRgmiiLinkDetect(const struct device *dev) FXmacLinkStatus FXmacSgmiiLinkDetect(const struct device *dev) { - struct eth_phytium_xmac_dev_data *dev_data = (struct eth_phytium_xmac_dev_data *)dev->data ; + struct eth_phytium_xmac_dev_data *dev_data = (struct eth_phytium_xmac_dev_data *)dev->data; FXmac *instance_p; u32 ctrl; u32 link, link_status; @@ -314,7 +314,7 @@ FXmacLinkStatus FXmacSgmiiLinkDetect(const struct device *dev) return FXMAC_LINKUP; } } - return instance_p->link_status ; + return instance_p->link_status; } static void eth_phytium_xmac_poll_phy(struct k_work *work) @@ -324,17 +324,17 @@ static void eth_phytium_xmac_poll_phy(struct k_work *work) struct eth_phytium_xmac_dev_data, phy_poll_delayed_work); const struct device *dev = net_if_get_device(dev_data->iface); const struct eth_phytium_xmac_dev_cfg *dev_conf = dev->config; - FXmacLinkStatus link_status = FXMAC_LINKDOWN ; + FXmacLinkStatus link_status = FXMAC_LINKDOWN; FXmac *instance_p; instance_p = &dev_data->instance; if(instance_p->config.interface == FXMAC_PHY_INTERFACE_MODE_SGMII) { - link_status = FXmacSgmiiLinkDetect(dev) ; + link_status = FXmacSgmiiLinkDetect(dev); } else if((instance_p->config.interface == FXMAC_PHY_INTERFACE_MODE_RMII) || (instance_p->config.interface == FXMAC_PHY_INTERFACE_MODE_RGMII)) { - link_status = FXmacRgmiiLinkDetect(dev) ; + link_status = FXmacRgmiiLinkDetect(dev); } if(link_status == FXMAC_LINKDOWN) @@ -349,14 +349,14 @@ static void eth_phytium_xmac_poll_phy(struct k_work *work) switch(instance_p->config.speed) { case FXMAC_SPEED_10: - dev_data->eff_link_speed = LINK_10MBIT ; - break ; + dev_data->eff_link_speed = LINK_10MBIT; + break; case FXMAC_SPEED_100: - dev_data->eff_link_speed = LINK_100MBIT ; - break ; + dev_data->eff_link_speed = LINK_100MBIT; + break; case FXMAC_SPEED_1000: - dev_data->eff_link_speed = LINK_1GBIT ; - break ; + dev_data->eff_link_speed = LINK_1GBIT; + break; } net_eth_carrier_on(dev_data->iface); } @@ -374,7 +374,7 @@ static void eth_phytium_xmac_poll_phy(struct k_work *work) */ static enum ethernet_hw_caps eth_phytium_xmac_get_capabilities(const struct device *dev) { - struct eth_phytium_xmac_dev_cfg *dev_cfg = (struct eth_phytium_xmac_dev_cfg *)dev->config ; + struct eth_phytium_xmac_dev_cfg *dev_cfg = (struct eth_phytium_xmac_dev_cfg *)dev->config; enum ethernet_hw_caps caps = (enum ethernet_hw_caps)0; switch (dev_cfg->phy_speed) @@ -410,7 +410,7 @@ static enum ethernet_hw_caps eth_phytium_xmac_get_capabilities(const struct devi static int eth_phytium_xmac_config_convert(struct eth_phytium_xmac_dev_cfg *dev_conf,FXmacConfig *mac_config,uint32_t *options) { - *options = 0 ; + *options = 0; switch (dev_conf->interface_mode) { case FXMAC_LWIP_PORT_INTERFACE_SGMII: @@ -452,21 +452,21 @@ static int eth_phytium_xmac_config_convert(struct eth_phytium_xmac_dev_cfg *dev_ return -EINVAL; } - mac_config->duplex = dev_conf->enable_fdx? 1:0 ; /* 1 is full-duplex , 0 is half-duplex */ - mac_config->auto_neg = dev_conf->phy_autonegotiation ; /* Enable auto-negotiation - when set active high, + mac_config->duplex = dev_conf->enable_fdx? 1:0; /* 1 is full-duplex , 0 is half-duplex */ + mac_config->auto_neg = dev_conf->phy_autonegotiation; /* Enable auto-negotiation - when set active high, autonegotiation operation is enabled. */ - mac_config->pclk_hz = dev_conf->pll_clock_frequency ; - mac_config->max_queue_num = dev_conf->max_queue_num ; /* Number of Xmac Controller Queues */ - mac_config->tx_queue_id = 0 ; /* 0 ~ FXMAC_QUEUE_MAX_NUM ,Index queue number */ - mac_config->rx_queue_id = 0 ; /* 0 ~ FXMAC_QUEUE_MAX_NUM ,Index queue number */ - mac_config->dma_brust_length = dev_conf->dma_brust_length ; /* burst length */ - mac_config->network_default_config = FXMAC_DEFAULT_OPTIONS ; - mac_config->caps = 0 ; /* used to configure tail ptr feature */ + mac_config->pclk_hz = dev_conf->pll_clock_frequency; + mac_config->max_queue_num = dev_conf->max_queue_num; /* Number of Xmac Controller Queues */ + mac_config->tx_queue_id = 0; /* 0 ~ FXMAC_QUEUE_MAX_NUM ,Index queue number */ + mac_config->rx_queue_id = 0; /* 0 ~ FXMAC_QUEUE_MAX_NUM ,Index queue number */ + mac_config->dma_brust_length = dev_conf->dma_brust_length; /* burst length */ + mac_config->network_default_config = FXMAC_DEFAULT_OPTIONS; + mac_config->caps = 0; /* used to configure tail ptr feature */ /* options */ if(dev_conf->enable_jumbo) { - *options |= FXMAC_JUMBO_ENABLE_OPTION ; + *options |= FXMAC_JUMBO_ENABLE_OPTION; } if(dev_conf->enable_ucast_hash) @@ -490,15 +490,15 @@ static int eth_phytium_xmac_config_convert(struct eth_phytium_xmac_dev_cfg *dev_ } - return 0 ; + return 0; } /* irq init */ static int eth_phytium_xmac_setuphandler(const struct device *dev) { - struct eth_phytium_xmac_dev_cfg *dev_conf = (struct eth_phytium_xmac_dev_cfg *)dev->config ; - struct eth_phytium_xmac_dev_data *dev_data = (struct eth_phytium_xmac_dev_data *)dev->data ; + struct eth_phytium_xmac_dev_cfg *dev_conf = (struct eth_phytium_xmac_dev_cfg *)dev->config; + struct eth_phytium_xmac_dev_data *dev_data = (struct eth_phytium_xmac_dev_data *)dev->data; FXmac *instance_p; FXmacBd bdtemplate; @@ -524,7 +524,7 @@ static int eth_phytium_xmac_setuphandler(const struct device *dev) dev_conf->rxbd_count)) { LOG_ERR("Error setting up RxBD space\r\n"); - return -EIO ; + return -EIO; } if(FXmacBdRingClone(rxringptr, &bdtemplate, FXMAC_RECV)) @@ -591,8 +591,8 @@ static int eth_phytium_xmac_setuphandler(const struct device *dev) static void eth_phytium_xmac_handle_tx_done(const struct device *dev) { - struct eth_phytium_xmac_dev_data *dev_data = (struct eth_phytium_xmac_dev_data *)dev->data ; - struct eth_phytium_xmac_dev_cfg *dev_conf = (struct eth_phytium_xmac_dev_cfg *)dev->config ; + struct eth_phytium_xmac_dev_data *dev_data = (struct eth_phytium_xmac_dev_data *)dev->data; + struct eth_phytium_xmac_dev_cfg *dev_conf = (struct eth_phytium_xmac_dev_cfg *)dev->config; FXmac *instance_p; FXmacBd *txbdset; FXmacBd *curbdpntr; @@ -601,7 +601,7 @@ static void eth_phytium_xmac_handle_tx_done(const struct device *dev) u32 n_pbufs_freed = 0; u32 bdindex; u32 *temp; - instance_p = &dev_data->instance ; + instance_p = &dev_data->instance; FXmacBdRing *txring; if (dev_conf->defer_txd_to_queue) { @@ -652,7 +652,7 @@ static void eth_phytium_xmac_handle_tx_done(const struct device *dev) } /* Re-enable the TX complete interrupt source */ - FXMAC_WRITEREG32(instance_p->config.base_address,FXMAC_IER_OFFSET,FXMAC_IXR_TXCOMPL_MASK) ; + FXMAC_WRITEREG32(instance_p->config.base_address,FXMAC_IER_OFFSET,FXMAC_IXR_TXCOMPL_MASK); /* Indicate completion to a blocking eth_xlnx_gem_send() call */ k_sem_give(&dev_data->tx_done_sem); @@ -675,8 +675,8 @@ static void eth_phytium_xmac_tx_done_work(struct k_work *item) */ static int eth_phytium_xmac_send(const struct device *dev, struct net_pkt *pkt) { - struct eth_phytium_xmac_dev_cfg *dev_conf = (struct eth_phytium_xmac_dev_cfg *)dev->config ; - struct eth_phytium_xmac_dev_data *dev_data = (struct eth_phytium_xmac_dev_data *)dev->data ; + struct eth_phytium_xmac_dev_cfg *dev_conf = (struct eth_phytium_xmac_dev_cfg *)dev->config; + struct eth_phytium_xmac_dev_data *dev_data = (struct eth_phytium_xmac_dev_data *)dev->data; FXmac *instance_p; FXmacBd *txbdset, *txbd, *last_txbd = NULL; @@ -687,7 +687,7 @@ static int eth_phytium_xmac_send(const struct device *dev, struct net_pkt *pkt) uint16_t tx_data_remaining; void *tx_buffer_offs; uint32_t bds_reqd; - uint32_t tx_length = 0 ; + uint32_t tx_length = 0; instance_p = &dev_data->instance; txring = &FXMAC_GET_TXRING((*instance_p)); @@ -714,7 +714,7 @@ static int eth_phytium_xmac_send(const struct device *dev, struct net_pkt *pkt) if (dev_conf->defer_txd_to_queue) { k_sem_take(&(dev_data->ring_sem), K_FOREVER); } else { - FXMAC_WRITEREG32(instance_p->config.base_address,FXMAC_IDR_OFFSET,FXMAC_IXR_TXCOMPL_MASK) ; + FXMAC_WRITEREG32(instance_p->config.base_address,FXMAC_IDR_OFFSET,FXMAC_IXR_TXCOMPL_MASK); } /* obtain as many BD's */ @@ -724,14 +724,14 @@ static int eth_phytium_xmac_send(const struct device *dev, struct net_pkt *pkt) #ifdef CONFIG_NET_STATISTICS_ETHERNET dev_data->stats.tx_dropped++; #endif - FXMAC_WRITEREG32(instance_p->config.base_address,FXMAC_IER_OFFSET,FXMAC_IXR_TXCOMPL_MASK) ; + FXMAC_WRITEREG32(instance_p->config.base_address,FXMAC_IER_OFFSET,FXMAC_IXR_TXCOMPL_MASK); return ERR_GENERAL; } if (dev_conf->defer_txd_to_queue) { k_sem_give(&(dev_data->ring_sem)); } else { - FXMAC_WRITEREG32(instance_p->config.base_address,FXMAC_IER_OFFSET,FXMAC_IXR_TXCOMPL_MASK) ; + FXMAC_WRITEREG32(instance_p->config.base_address,FXMAC_IER_OFFSET,FXMAC_IXR_TXCOMPL_MASK); } /* @@ -739,7 +739,7 @@ static int eth_phytium_xmac_send(const struct device *dev, struct net_pkt *pkt) * one or more DMA buffers. */ net_pkt_cursor_init(pkt); - txbd = txbdset ; + txbd = txbdset; while (tx_data_remaining) { bdindex = FXMAC_BD_TO_INDEX(txring, txbd); @@ -750,7 +750,7 @@ static int eth_phytium_xmac_send(const struct device *dev, struct net_pkt *pkt) /* Copy packet data to DMA buffer */ tx_length = (tx_data_remaining < dev_conf->tx_buffer_size) ? - tx_data_remaining : dev_conf->tx_buffer_size ; + tx_data_remaining : dev_conf->tx_buffer_size; net_pkt_read(pkt, (void *)tx_buffer_offs,tx_length); FXMAC_BD_SET_ADDRESS_TX(txbd, (uintptr)tx_buffer_offs); @@ -783,7 +783,7 @@ static int eth_phytium_xmac_send(const struct device *dev, struct net_pkt *pkt) dev_data->stats.pkts.tx++; #endif - return 0 ; + return 0; } static void eth_phytium_xmac_setup_rx_bds(const struct device *dev,FXmacBdRing *rxring) @@ -796,7 +796,7 @@ static void eth_phytium_xmac_setup_rx_bds(const struct device *dev,FXmacBdRing * u32 bdindex; u32 *temp; FXmac *instance_p; - instance_p = &dev_data->instance ; + instance_p = &dev_data->instance; freebds = FXMAC_BD_RING_GET_FREE_CNT(rxring); while (freebds > 0) @@ -856,7 +856,7 @@ static void eth_phytium_xmac_handle_rx_pending(const struct device *dev) FXmac *instance_p; struct net_pkt *pkt; uint32_t rx_data_length; - instance_p = &dev_data->instance ; + instance_p = &dev_data->instance; rxring = &FXMAC_GET_RXRING((*instance_p)); /* Re-enable the frame received interrupt source */ @@ -878,7 +878,7 @@ static void eth_phytium_xmac_handle_rx_pending(const struct device *dev) { LOG_ERR("rx_data_length length is error: %u bytes \r\n", rx_data_length); - goto error_exit ; + goto error_exit; } pkt = net_pkt_rx_alloc_with_buffer(dev_data->iface, rx_data_length, @@ -892,7 +892,7 @@ static void eth_phytium_xmac_handle_rx_pending(const struct device *dev) dev_data->stats.error_details.rx_no_buffer_count++; #endif /* free up the BD's */ - goto error_exit ; + goto error_exit; } net_pkt_write(pkt, (const void *) @@ -912,13 +912,13 @@ static void eth_phytium_xmac_handle_rx_pending(const struct device *dev) curbdptr = FXMAC_BD_RING_NEXT(rxring, curbdptr); } FXmacBdRingFree(rxring, bd_processed, rxbdset); - eth_phytium_xmac_setup_rx_bds(dev,rxring) ; + eth_phytium_xmac_setup_rx_bds(dev,rxring); } return; error_exit: - printf("eth_phytium_xmac_handle_rx_pending error exit \r\n") ; + printf("eth_phytium_xmac_handle_rx_pending error exit \r\n"); FXmacBdRingFree(rxring, bd_processed, rxbdset); } @@ -953,13 +953,13 @@ static void FXmacSendHandler(void *arg) static void FXmacRecvHandler(void *arg) { - const struct device *dev = (const struct device *)arg ; + const struct device *dev = (const struct device *)arg; struct eth_phytium_xmac_dev_data *dev_data = dev->data; const struct eth_phytium_xmac_dev_cfg *dev_conf = dev->config; FXmac *instance_p; - instance_p = &dev_data->instance ; + instance_p = &dev_data->instance; - FXMAC_WRITEREG32(instance_p->config.base_address,FXMAC_IDR_OFFSET,FXMAC_IXR_RXCOMPL_MASK) ; + FXMAC_WRITEREG32(instance_p->config.base_address,FXMAC_IDR_OFFSET,FXMAC_IXR_RXCOMPL_MASK); if (dev_conf->defer_rxp_to_queue) { @@ -967,9 +967,9 @@ static void FXmacRecvHandler(void *arg) } else { - printk("recv data \r\n") ; + printk("recv data \r\n"); eth_phytium_xmac_handle_rx_pending(dev); - printk("recv data exit \r\n") ; + printk("recv data exit \r\n"); } } @@ -979,7 +979,7 @@ static void FXmacHandleDmaTxError( const struct device *dev) u32 dmacrreg; struct eth_phytium_xmac_dev_data *dev_data = (struct eth_phytium_xmac_dev_data *)dev->data; FXmac *instance_p; - instance_p = &dev_data->instance ; + instance_p = &dev_data->instance; /* initialize the mac */ if (FXmacCfgInitialize(instance_p, &instance_p->config)) { @@ -987,13 +987,13 @@ static void FXmacHandleDmaTxError( const struct device *dev) } /* set mac address */ - FXmacSetMacAddress(instance_p, (void *)(dev_data->mac_addr), 0) ; + FXmacSetMacAddress(instance_p, (void *)(dev_data->mac_addr), 0); dmacrreg = FXMAC_READREG32(instance_p->config.base_address, FXMAC_DMACR_OFFSET); dmacrreg = dmacrreg | (FXMAC_DMACR_ORCE_DISCARD_ON_ERR_MASK); FXMAC_WRITEREG32(instance_p->config.base_address, FXMAC_DMACR_OFFSET, dmacrreg); /* setup dma bdl */ - eth_phytium_xmac_setuphandler(dev) ; + eth_phytium_xmac_setuphandler(dev); FXmacSetupIsr(dev); FXmacStart(instance_p); @@ -1001,10 +1001,10 @@ static void FXmacHandleDmaTxError( const struct device *dev) static void eth_phytium_xmac_tx_dma_init(const struct device *dev) { - struct eth_phytium_xmac_dev_data *dev_data = (struct eth_phytium_xmac_dev_data *)dev->data ; - struct eth_phytium_xmac_dev_cfg *dev_conf = (struct eth_phytium_xmac_dev_cfg *)dev->config ; + struct eth_phytium_xmac_dev_data *dev_data = (struct eth_phytium_xmac_dev_data *)dev->data; + struct eth_phytium_xmac_dev_cfg *dev_conf = (struct eth_phytium_xmac_dev_cfg *)dev->config; FXmac *instance_p; - instance_p = &dev_data->instance ; + instance_p = &dev_data->instance; FXmacBd bdtemplate; FXmacBdRing *txringptr; @@ -1016,8 +1016,8 @@ static void eth_phytium_xmac_tx_dma_init(const struct device *dev) (uintptr)dev_data->tx_bdspace, ETH_PHYTIUM_BDL_ALIGNMENT, dev_conf->txbd_count)) { - LOG_ERR("FXmacBdRingCreate is error") ; - return ; + LOG_ERR("FXmacBdRingCreate is error"); + return; } FXmacBdRingClone(txringptr, &bdtemplate, FXMAC_SEND); @@ -1025,10 +1025,10 @@ static void eth_phytium_xmac_tx_dma_init(const struct device *dev) static void FXmacHandleTxErrors( const struct device *dev) { - struct eth_phytium_xmac_dev_data *dev_data = (struct eth_phytium_xmac_dev_data *)dev->data ; + struct eth_phytium_xmac_dev_data *dev_data = (struct eth_phytium_xmac_dev_data *)dev->data; FXmac *instance_p; - instance_p = &dev_data->instance ; + instance_p = &dev_data->instance; u32 netctrlreg; @@ -1046,11 +1046,11 @@ static void FXmacHandleTxErrors( const struct device *dev) void FXmacErrorHandler(void *arg, u8 direction, u32 error_word) { - const struct device *dev = (const struct device *)arg ; + const struct device *dev = (const struct device *)arg; struct eth_phytium_xmac_dev_data *dev_data = (struct eth_phytium_xmac_dev_data *)dev->data; struct eth_phytium_xmac_dev_cfg *dev_conf = (struct eth_phytium_xmac_dev_cfg *)dev->config; FXmac *instance_p; - instance_p = &dev_data->instance ; + instance_p = &dev_data->instance; if (error_word != 0) { @@ -1065,12 +1065,12 @@ void FXmacErrorHandler(void *arg, u8 direction, u32 error_word) if (error_word & FXMAC_RXSR_RXOVR_MASK) { LOG_ERR("Receive over run\r\n"); - FXmacRecvHandler((void *)dev) ; + FXmacRecvHandler((void *)dev); } if (error_word & FXMAC_RXSR_BUFFNA_MASK) { LOG_ERR("Receive buffer not available\r\n"); - FXmacRecvHandler((void *)dev) ; + FXmacRecvHandler((void *)dev); } break; case FXMAC_SEND: @@ -1132,7 +1132,7 @@ static struct net_stats_eth *eth_phytium_xmac_stats(const struct device *dev) */ static void FXmacSetupIsr(const struct device *dev) { - struct eth_phytium_xmac_dev_data *dev_data = (struct eth_phytium_xmac_dev_data *)dev->data ; + struct eth_phytium_xmac_dev_data *dev_data = (struct eth_phytium_xmac_dev_data *)dev->data; /* Setup callbacks */ FXmac *instance_p; instance_p = &dev_data->instance; @@ -1159,8 +1159,8 @@ static int eth_phytium_xmac_start_device(const struct device *dev) FXmac *instance_p; instance_p = &dev_data->instance; - FXmacStart(instance_p) ; - return 0 ; + FXmacStart(instance_p); + return 0; } /** @@ -1186,9 +1186,9 @@ static int eth_phytium_xmac_stop_device(const struct device *dev) k_work_cancel_delayable(&dev_data->phy_poll_delayed_work); } - FXmacStop(instance_p) ; + FXmacStop(instance_p); - return 0 ; + return 0; } /** @@ -1398,22 +1398,22 @@ static void eth_phytium_xmac_iface_init(struct net_if *iface) */ static int eth_phytium_xmac_dev_init(const struct device *dev) { - struct eth_phytium_xmac_dev_data *dev_data = (struct eth_phytium_xmac_dev_data *)dev->data ; - struct eth_phytium_xmac_dev_cfg *dev_conf = (struct eth_phytium_xmac_dev_cfg *)dev->config ; + struct eth_phytium_xmac_dev_data *dev_data = (struct eth_phytium_xmac_dev_data *)dev->data; + struct eth_phytium_xmac_dev_cfg *dev_conf = (struct eth_phytium_xmac_dev_cfg *)dev->config; FXmacConfig mac_config; FXmac *instance_p; - uint32_t xmac_options ; + uint32_t xmac_options; uint32_t dmacrreg; - int ret ; + int ret; /* init base */ DEVICE_MMIO_MAP(dev, K_MEM_CACHE_NONE); /* config init */ - mac_config.base_address = DEVICE_MMIO_GET(dev) ; + mac_config.base_address = DEVICE_MMIO_GET(dev); mac_config.instance_id = 0; - ret = eth_phytium_xmac_config_convert(dev_conf,&mac_config,&xmac_options) ; + ret = eth_phytium_xmac_config_convert(dev_conf,&mac_config,&xmac_options); if(ret) { return -EINVAL; @@ -1451,15 +1451,15 @@ static int eth_phytium_xmac_dev_init(const struct device *dev) dmacrreg = dmacrreg | FXMAC_DMACR_INCR16_AHB_AXI_BURST; /* Attempt to use bursts of up to 16. */ FXMAC_WRITEREG32(instance_p->config.base_address, FXMAC_DMACR_OFFSET, dmacrreg); /* setup dma bdl */ - eth_phytium_xmac_setuphandler(dev) ; + eth_phytium_xmac_setuphandler(dev); instance_p->mask = ((u32)FXMAC_IXR_TX_ERR_MASK | (u32)FXMAC_IXR_RX_ERR_MASK | (u32)FXMAC_IXR_RXCOMPL_MASK | (u32)FXMAC_IXR_TXCOMPL_MASK); /* setup tx、rx intr */ - FXmacSetupIsr(dev) ; + FXmacSetupIsr(dev); - return 0 ; + return 0; } diff --git a/dts/arm64/phytium/d2000.dtsi b/dts/arm64/phytium/d2000.dtsi index 94cbb3d1b38..b7ff0fb5f2f 100644 --- a/dts/arm64/phytium/d2000.dtsi +++ b/dts/arm64/phytium/d2000.dtsi @@ -130,6 +130,17 @@ interrupt-names = "irq_1"; clocks = <&uartclk>; }; + + gmac0: gmac@2820C000 { + compatible = "phytium,gmac"; + reg = <0x0 0x2820C000 0x0 0x4000>; + interrupts = ; + phy-poll-interval = <5000>; + phy-speed = <100>; + autonegotiation = <0>; + phy_duplex = <1>; + status = "disabled"; + }; /* 512MB DDR */ sram0: memory@80100000 { diff --git a/dts/arm64/phytium/e2000d.dtsi b/dts/arm64/phytium/e2000d.dtsi index 397540ea202..950deda1df2 100644 --- a/dts/arm64/phytium/e2000d.dtsi +++ b/dts/arm64/phytium/e2000d.dtsi @@ -125,18 +125,18 @@ IRQ_DEFAULT_PRIORITY>; interrupt-names = "irq_0"; phy-poll-interval = <1000>; - clock-frequency = <50000000> ; - phy-speed = <1000> ; - interface-mode = <0> ; - dma-brust-length = <16> ; - max-queue-num = <1> ; + clock-frequency = <50000000>; + phy-speed = <1000>; + interface-mode = <0>; + dma-brust-length = <16>; + max-queue-num = <1>; rx-buffer-descriptors = <128>; tx-buffer-descriptors = <32>; rx-buffer-size = <1600>; tx-buffer-size = <1600>; phy-autonegotiation; enable-fdx; - disable-reject-fcs-crc-errors ; + disable-reject-fcs-crc-errors; } ; /* 256MB DDR */ diff --git a/dts/arm64/phytium/e2000q.dtsi b/dts/arm64/phytium/e2000q.dtsi index 789ce1a08b3..73af5a41fb8 100644 --- a/dts/arm64/phytium/e2000q.dtsi +++ b/dts/arm64/phytium/e2000q.dtsi @@ -131,11 +131,11 @@ IRQ_DEFAULT_PRIORITY>; interrupt-names = "irq_0"; phy-poll-interval = <5000>; - clock-frequency = <50000000> ; - phy-speed = <1000> ; - interface-mode = <0> ; - dma-brust-length = <16> ; - max-queue-num = <1> ; + clock-frequency = <50000000>; + phy-speed = <1000>; + interface-mode = <0>; + dma-brust-length = <16>; + max-queue-num = <1>; rx-buffer-descriptors = <128>; tx-buffer-descriptors = <128>; rx-buffer-size = <1600>; diff --git a/dts/bindings/ethernet/phytium,gmac.yaml b/dts/bindings/ethernet/phytium,gmac.yaml new file mode 100644 index 00000000000..eb23c5d65c3 --- /dev/null +++ b/dts/bindings/ethernet/phytium,gmac.yaml @@ -0,0 +1,88 @@ +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +# +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# https://opensource.org/license/apache-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. + +description: Phytium gmac Ethernet controller + +compatible: "phytium,gmac" + +include: ethernet-controller.yaml + +properties: + reg: + required: true + + interrupts: + required: true + + phy-speed: + type: int + required: true + description: | + Nominal link speed. If no PHY is managed by an instance of this driver, + the respective controller will be configured to match the link speed + specified here. If a PHY is managed by the driver, advertisement of + the link speed specified here will be requested. If the optional pro- + perty advertise-lower-link-speeds is set, advertisement of the link + speed specified here plus any valid link speed below this value will + be requested. + enum: + - 10 + - 100 + - 1000 + - 10000 + + autonegotiation: + type: int + required: true + enum: + - 0 + - 1 + + phy_duplex: + type: int + required: true + enum: + - 0 + - 1 + + + phy-poll-interval: + type: int + required: true + description: | + PHY status polling interval in milliseconds for a driver instance + managing an associated PHY. + + handle-rx-in-isr: + type: boolean + description: | + Moves the handling of the frame received interrupt including the + transfer of packet data from the DMA to network packet buffers and + the subsequent propagation of the received packets to the network + stack into the context of the ISR. Due to the unpredictability of + the runtime of the ISR whenever large amounts of data are received, + handling of the RX interrupt is normally deferred to the context + of the system work queue. + + + handle-tx-in-workq: + type: boolean + description: | + Moves the handling of the frame transmission done interrupt into the + context of the system work queue. By default, TX done handling is per- + formed in the context of the ISR, as it only involves a limited number + of memory accesses. This option CAN NOT be used if any component ex- + ists within the current system setup that triggers the transmission + of packets from within the context of the system work queue! diff --git a/modules/Kconfig.phytium b/modules/Kconfig.phytium index ca36693353a..41bae1d0a1a 100644 --- a/modules/Kconfig.phytium +++ b/modules/Kconfig.phytium @@ -45,7 +45,7 @@ if USE_SDHC config ENABLE_PHYTIUM_SDHC bool prompt "Use phytium sdhc" - default y + default nn endif -- Gitee From d50278a753f84a050bbfbf9760b4d8fb01fa1611 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E8=A1=8D?= Date: Wed, 19 Feb 2025 01:49:32 +0000 Subject: [PATCH 06/13] =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=B7=B2=E9=80=82?= =?UTF-8?q?=E9=85=8D=E9=A9=B1=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- boards/phytium/d2000_demo/d2000_demo.dts | 5 + .../d2000_demo/d2000_demo_d2000_el2.dts | 10 + .../d2000_demo/d2000_demo_d2000_el2.yaml | 2 +- .../d2000_demo/d2000_demo_d2000_el2_smp.dts | 9 + .../d2000_demo/d2000_demo_d2000_el2_smp.yaml | 2 +- .../d2000_demo/d2000_demo_d2000_smp.dts | 9 + .../d2000_demo/d2000_demo_d2000_smp.yaml | 2 +- boards/phytium/e2000d_demo/e2000d_demo.dts | 4 + .../e2000d_demo/e2000d_demo_e2000d_el2.dts | 4 + .../e2000d_demo/e2000d_demo_e2000d_el2.yaml | 2 +- .../e2000d_demo_e2000d_el2_smp.dts | 4 + .../e2000d_demo_e2000d_el2_smp.yaml | 2 +- .../e2000d_demo/e2000d_demo_e2000d_smp.dts | 4 + .../e2000d_demo/e2000d_demo_e2000d_smp.yaml | 2 +- .../e2000q_demo/e2000q_demo_e2000q_el2.yaml | 2 +- .../e2000q_demo_e2000q_el2_smp.dts | 4 + .../e2000q_demo_e2000q_el2_smp.yaml | 2 +- .../e2000q_demo/e2000q_demo_e2000q_smp.dts | 4 + .../e2000q_demo/e2000q_demo_e2000q_smp.yaml | 2 +- boards/phytium/pd2308_demo/pd2308_demo.dts | 17 ++ .../pd2308_demo/pd2308_demo_pd2308_el2.dts | 17 ++ .../pd2308_demo/pd2308_demo_pd2308_el2.yaml | 2 +- .../pd2308_demo_pd2308_el2_smp.dts | 17 ++ .../pd2308_demo_pd2308_el2_smp.yaml | 2 +- .../pd2308_demo/pd2308_demo_pd2308_smp.dts | 18 ++ .../pd2308_demo/pd2308_demo_pd2308_smp.yaml | 2 +- boards/phytium/ps2316_test/ps2316_test.dts | 18 -- .../ps2316_test/ps2316_test_ps2316_el2.dts | 18 -- .../ps2316_test/ps2316_test_ps2316_el2.yaml | 2 +- .../ps2316_test_ps2316_el2_smp.dts | 18 -- .../ps2316_test_ps2316_el2_smp.yaml | 2 +- .../ps2316_test/ps2316_test_ps2316_smp.dts | 19 -- .../ps2316_test/ps2316_test_ps2316_smp.yaml | 2 +- drivers/ethernet/eth_phytium_gmac.c | 16 +- drivers/sdhc/phytium_sdhc.c | 13 +- dts/arm64/phytium/d2000.dtsi | 12 + dts/arm64/phytium/e2000d.dtsi | 20 +- dts/arm64/phytium/e2000q.dtsi | 4 +- dts/arm64/phytium/pd2308.dtsi | 57 +++- dts/arm64/phytium/ps2316.dtsi | 97 ------ .../pinctrl/phytium-e2000d-pinctrl.h | 278 ++++++++++++++++++ .../pinctrl/phytium-pd2308-pinctrl.h | 226 ++++++++++++++ soc/phytium/pd2308/pinctrl_soc.h | 51 ++++ 43 files changed, 799 insertions(+), 204 deletions(-) create mode 100644 include/zephyr/dt-bindings/pinctrl/phytium-e2000d-pinctrl.h create mode 100644 include/zephyr/dt-bindings/pinctrl/phytium-pd2308-pinctrl.h create mode 100644 soc/phytium/pd2308/pinctrl_soc.h diff --git a/boards/phytium/d2000_demo/d2000_demo.dts b/boards/phytium/d2000_demo/d2000_demo.dts index fa8d244904e..480f94e0794 100644 --- a/boards/phytium/d2000_demo/d2000_demo.dts +++ b/boards/phytium/d2000_demo/d2000_demo.dts @@ -17,6 +17,7 @@ chosen { zephyr,console = &uart1; zephyr,shell-uart = &uart1; zephyr,sram = &sram0; + zephyr,pcie-controller = &pcie0; }; }; @@ -34,3 +35,7 @@ chosen { current-speed = <115200>; status = "okay"; }; + +&pcie0 { + status = "okay"; +}; diff --git a/boards/phytium/d2000_demo/d2000_demo_d2000_el2.dts b/boards/phytium/d2000_demo/d2000_demo_d2000_el2.dts index bb59f288f27..480f94e0794 100644 --- a/boards/phytium/d2000_demo/d2000_demo_d2000_el2.dts +++ b/boards/phytium/d2000_demo/d2000_demo_d2000_el2.dts @@ -17,9 +17,15 @@ chosen { zephyr,console = &uart1; zephyr,shell-uart = &uart1; zephyr,sram = &sram0; + zephyr,pcie-controller = &pcie0; }; }; +&gmac0 { + local-mac-address = [00 00 00 01 02 03]; + status = "okay"; +}; + &uart1 { current-speed = <115200>; status = "okay"; @@ -29,3 +35,7 @@ chosen { current-speed = <115200>; status = "okay"; }; + +&pcie0 { + status = "okay"; +}; diff --git a/boards/phytium/d2000_demo/d2000_demo_d2000_el2.yaml b/boards/phytium/d2000_demo/d2000_demo_d2000_el2.yaml index 98fae9ecbb0..0d345a6812a 100644 --- a/boards/phytium/d2000_demo/d2000_demo_d2000_el2.yaml +++ b/boards/phytium/d2000_demo/d2000_demo_d2000_el2.yaml @@ -1,4 +1,4 @@ -identifier: d2000_demo_el2 +identifier: d2000_demo/d2000/el2 name: Phytium d2000 demo type: mcu arch: arm64 diff --git a/boards/phytium/d2000_demo/d2000_demo_d2000_el2_smp.dts b/boards/phytium/d2000_demo/d2000_demo_d2000_el2_smp.dts index c679cdd7269..73e7666abcc 100644 --- a/boards/phytium/d2000_demo/d2000_demo_d2000_el2_smp.dts +++ b/boards/phytium/d2000_demo/d2000_demo_d2000_el2_smp.dts @@ -22,9 +22,15 @@ chosen { zephyr,console = &uart1; zephyr,shell-uart = &uart1; zephyr,sram = &sram0; + zephyr,pcie-controller = &pcie0; }; }; +&gmac0 { + local-mac-address = [00 00 00 01 02 03]; + status = "okay"; +}; + &uart1 { status = "okay"; current-speed = <115200>; @@ -35,3 +41,6 @@ chosen { current-speed = <115200>; }; +&pcie0 { + status = "okay"; +}; diff --git a/boards/phytium/d2000_demo/d2000_demo_d2000_el2_smp.yaml b/boards/phytium/d2000_demo/d2000_demo_d2000_el2_smp.yaml index 80b3cb561be..8eb762aa7d8 100644 --- a/boards/phytium/d2000_demo/d2000_demo_d2000_el2_smp.yaml +++ b/boards/phytium/d2000_demo/d2000_demo_d2000_el2_smp.yaml @@ -1,4 +1,4 @@ -identifier: d2000_demo_el2_smp +identifier: d2000_demo/d2000/el2/smp name: Phytium d2000 demo type: mcu arch: arm64 diff --git a/boards/phytium/d2000_demo/d2000_demo_d2000_smp.dts b/boards/phytium/d2000_demo/d2000_demo_d2000_smp.dts index c679cdd7269..73e7666abcc 100644 --- a/boards/phytium/d2000_demo/d2000_demo_d2000_smp.dts +++ b/boards/phytium/d2000_demo/d2000_demo_d2000_smp.dts @@ -22,9 +22,15 @@ chosen { zephyr,console = &uart1; zephyr,shell-uart = &uart1; zephyr,sram = &sram0; + zephyr,pcie-controller = &pcie0; }; }; +&gmac0 { + local-mac-address = [00 00 00 01 02 03]; + status = "okay"; +}; + &uart1 { status = "okay"; current-speed = <115200>; @@ -35,3 +41,6 @@ chosen { current-speed = <115200>; }; +&pcie0 { + status = "okay"; +}; diff --git a/boards/phytium/d2000_demo/d2000_demo_d2000_smp.yaml b/boards/phytium/d2000_demo/d2000_demo_d2000_smp.yaml index d6e1cc25cec..c75ca49b3e2 100644 --- a/boards/phytium/d2000_demo/d2000_demo_d2000_smp.yaml +++ b/boards/phytium/d2000_demo/d2000_demo_d2000_smp.yaml @@ -1,4 +1,4 @@ -identifier: d2000_demo_smp +identifier: d2000_demo/d2000/smp name: Phytium d2000 demo smp type: mcu arch: arm64 diff --git a/boards/phytium/e2000d_demo/e2000d_demo.dts b/boards/phytium/e2000d_demo/e2000d_demo.dts index 9ea6c9be8b0..6bed72d828f 100644 --- a/boards/phytium/e2000d_demo/e2000d_demo.dts +++ b/boards/phytium/e2000d_demo/e2000d_demo.dts @@ -41,4 +41,8 @@ chosen { &uart2 { current-speed = <115200>; status = "okay"; +}; + +&pcie0 { + status = "okay"; }; \ No newline at end of file diff --git a/boards/phytium/e2000d_demo/e2000d_demo_e2000d_el2.dts b/boards/phytium/e2000d_demo/e2000d_demo_e2000d_el2.dts index 9ea6c9be8b0..6bed72d828f 100644 --- a/boards/phytium/e2000d_demo/e2000d_demo_e2000d_el2.dts +++ b/boards/phytium/e2000d_demo/e2000d_demo_e2000d_el2.dts @@ -41,4 +41,8 @@ chosen { &uart2 { current-speed = <115200>; status = "okay"; +}; + +&pcie0 { + status = "okay"; }; \ No newline at end of file diff --git a/boards/phytium/e2000d_demo/e2000d_demo_e2000d_el2.yaml b/boards/phytium/e2000d_demo/e2000d_demo_e2000d_el2.yaml index 2c49d5fa807..87ca6dcdb61 100644 --- a/boards/phytium/e2000d_demo/e2000d_demo_e2000d_el2.yaml +++ b/boards/phytium/e2000d_demo/e2000d_demo_e2000d_el2.yaml @@ -1,4 +1,4 @@ -identifier: e2000d_demo_el2 +identifier: e2000d_demo/e2000d/el2 name: Phytium e2000d demo type: mcu arch: arm64 diff --git a/boards/phytium/e2000d_demo/e2000d_demo_e2000d_el2_smp.dts b/boards/phytium/e2000d_demo/e2000d_demo_e2000d_el2_smp.dts index cb2792a2427..8420f7fd427 100644 --- a/boards/phytium/e2000d_demo/e2000d_demo_e2000d_el2_smp.dts +++ b/boards/phytium/e2000d_demo/e2000d_demo_e2000d_el2_smp.dts @@ -47,3 +47,7 @@ chosen { status = "okay"; local-mac-address = [00 00 00 01 02 03]; }; + +&pcie0 { + status = "okay"; +}; diff --git a/boards/phytium/e2000d_demo/e2000d_demo_e2000d_el2_smp.yaml b/boards/phytium/e2000d_demo/e2000d_demo_e2000d_el2_smp.yaml index d0ced7e0472..90093797e21 100644 --- a/boards/phytium/e2000d_demo/e2000d_demo_e2000d_el2_smp.yaml +++ b/boards/phytium/e2000d_demo/e2000d_demo_e2000d_el2_smp.yaml @@ -1,4 +1,4 @@ -identifier: e2000d_demo_el2_smp +identifier: e2000d_demo/e2000d/el2/smp name: Phytium e2000d demo type: mcu arch: arm64 diff --git a/boards/phytium/e2000d_demo/e2000d_demo_e2000d_smp.dts b/boards/phytium/e2000d_demo/e2000d_demo_e2000d_smp.dts index cb2792a2427..8420f7fd427 100644 --- a/boards/phytium/e2000d_demo/e2000d_demo_e2000d_smp.dts +++ b/boards/phytium/e2000d_demo/e2000d_demo_e2000d_smp.dts @@ -47,3 +47,7 @@ chosen { status = "okay"; local-mac-address = [00 00 00 01 02 03]; }; + +&pcie0 { + status = "okay"; +}; diff --git a/boards/phytium/e2000d_demo/e2000d_demo_e2000d_smp.yaml b/boards/phytium/e2000d_demo/e2000d_demo_e2000d_smp.yaml index 828eb32262e..a983077654c 100644 --- a/boards/phytium/e2000d_demo/e2000d_demo_e2000d_smp.yaml +++ b/boards/phytium/e2000d_demo/e2000d_demo_e2000d_smp.yaml @@ -1,4 +1,4 @@ -identifier: e2000d_demo_smp +identifier: e2000d_demo/e2000d/smp name: Phytium e2000d demo type: mcu arch: arm64 diff --git a/boards/phytium/e2000q_demo/e2000q_demo_e2000q_el2.yaml b/boards/phytium/e2000q_demo/e2000q_demo_e2000q_el2.yaml index 437c84fc68d..67be2b381d4 100644 --- a/boards/phytium/e2000q_demo/e2000q_demo_e2000q_el2.yaml +++ b/boards/phytium/e2000q_demo/e2000q_demo_e2000q_el2.yaml @@ -1,4 +1,4 @@ -identifier: e2000q_demo_el2 +identifier: e2000q_demo/e2000q/el2 name: Phytium e2000q demo type: mcu arch: arm64 diff --git a/boards/phytium/e2000q_demo/e2000q_demo_e2000q_el2_smp.dts b/boards/phytium/e2000q_demo/e2000q_demo_e2000q_el2_smp.dts index fff1f97392a..3b829e76720 100644 --- a/boards/phytium/e2000q_demo/e2000q_demo_e2000q_el2_smp.dts +++ b/boards/phytium/e2000q_demo/e2000q_demo_e2000q_el2_smp.dts @@ -47,3 +47,7 @@ chosen { status = "okay"; local-mac-address = [00 00 00 01 02 03]; }; + +&pcie0 { + status = "okay"; +}; diff --git a/boards/phytium/e2000q_demo/e2000q_demo_e2000q_el2_smp.yaml b/boards/phytium/e2000q_demo/e2000q_demo_e2000q_el2_smp.yaml index f54abe5aeec..84cf27eb3ac 100644 --- a/boards/phytium/e2000q_demo/e2000q_demo_e2000q_el2_smp.yaml +++ b/boards/phytium/e2000q_demo/e2000q_demo_e2000q_el2_smp.yaml @@ -1,4 +1,4 @@ -identifier: e2000q_demo_el2_smp +identifier: e2000q_demo/e2000q/el2/smp name: Phytium e2000q demo type: mcu arch: arm64 diff --git a/boards/phytium/e2000q_demo/e2000q_demo_e2000q_smp.dts b/boards/phytium/e2000q_demo/e2000q_demo_e2000q_smp.dts index fff1f97392a..3b829e76720 100644 --- a/boards/phytium/e2000q_demo/e2000q_demo_e2000q_smp.dts +++ b/boards/phytium/e2000q_demo/e2000q_demo_e2000q_smp.dts @@ -47,3 +47,7 @@ chosen { status = "okay"; local-mac-address = [00 00 00 01 02 03]; }; + +&pcie0 { + status = "okay"; +}; diff --git a/boards/phytium/e2000q_demo/e2000q_demo_e2000q_smp.yaml b/boards/phytium/e2000q_demo/e2000q_demo_e2000q_smp.yaml index 020f7fbd5ce..4b9ff667a37 100644 --- a/boards/phytium/e2000q_demo/e2000q_demo_e2000q_smp.yaml +++ b/boards/phytium/e2000q_demo/e2000q_demo_e2000q_smp.yaml @@ -1,4 +1,4 @@ -identifier: e2000q_demo_smp +identifier: e2000q_demo/e2000q/smp name: Phytium e2000q demo type: mcu arch: arm64 diff --git a/boards/phytium/pd2308_demo/pd2308_demo.dts b/boards/phytium/pd2308_demo/pd2308_demo.dts index d7f9fec48c0..279fb1e984c 100644 --- a/boards/phytium/pd2308_demo/pd2308_demo.dts +++ b/boards/phytium/pd2308_demo/pd2308_demo.dts @@ -17,11 +17,28 @@ chosen { zephyr,console = &uart1; zephyr,shell-uart = &uart1; zephyr,sram = &sram0; + zephyr,pcie-controller = &pcie0; }; }; +&sdhc1 { + status = "okay"; + sdmmc { + compatible = "zephyr,sdmmc-disk"; + status = "okay"; + }; +}; + +&xmac0 { + status = "okay"; + local-mac-address = [00 00 00 01 02 03]; +}; + &uart1 { current-speed = <115200>; status = "okay"; }; +&pcie0 { + status = "okay"; +}; diff --git a/boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2.dts b/boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2.dts index d7f9fec48c0..279fb1e984c 100644 --- a/boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2.dts +++ b/boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2.dts @@ -17,11 +17,28 @@ chosen { zephyr,console = &uart1; zephyr,shell-uart = &uart1; zephyr,sram = &sram0; + zephyr,pcie-controller = &pcie0; }; }; +&sdhc1 { + status = "okay"; + sdmmc { + compatible = "zephyr,sdmmc-disk"; + status = "okay"; + }; +}; + +&xmac0 { + status = "okay"; + local-mac-address = [00 00 00 01 02 03]; +}; + &uart1 { current-speed = <115200>; status = "okay"; }; +&pcie0 { + status = "okay"; +}; diff --git a/boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2.yaml b/boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2.yaml index c2080e9a8b4..f9e61c55457 100644 --- a/boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2.yaml +++ b/boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2.yaml @@ -1,4 +1,4 @@ -identifier: pd2308_demo_el2 +identifier: pd2308_demo/pd2308/el2 name: Phytium d2000 demo type: mcu arch: arm64 diff --git a/boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2_smp.dts b/boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2_smp.dts index d7f9fec48c0..279fb1e984c 100644 --- a/boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2_smp.dts +++ b/boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2_smp.dts @@ -17,11 +17,28 @@ chosen { zephyr,console = &uart1; zephyr,shell-uart = &uart1; zephyr,sram = &sram0; + zephyr,pcie-controller = &pcie0; }; }; +&sdhc1 { + status = "okay"; + sdmmc { + compatible = "zephyr,sdmmc-disk"; + status = "okay"; + }; +}; + +&xmac0 { + status = "okay"; + local-mac-address = [00 00 00 01 02 03]; +}; + &uart1 { current-speed = <115200>; status = "okay"; }; +&pcie0 { + status = "okay"; +}; diff --git a/boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2_smp.yaml b/boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2_smp.yaml index 144d8474350..1e720bf6ed1 100644 --- a/boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2_smp.yaml +++ b/boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2_smp.yaml @@ -1,4 +1,4 @@ -identifier: pd2308_demo_el2_smp +identifier: pd2308_demo/pd2308/el2/smp name: Phytium d2000 demo type: mcu arch: arm64 diff --git a/boards/phytium/pd2308_demo/pd2308_demo_pd2308_smp.dts b/boards/phytium/pd2308_demo/pd2308_demo_pd2308_smp.dts index 29d569f08ef..bbd49704488 100644 --- a/boards/phytium/pd2308_demo/pd2308_demo_pd2308_smp.dts +++ b/boards/phytium/pd2308_demo/pd2308_demo_pd2308_smp.dts @@ -22,11 +22,29 @@ chosen { zephyr,console = &uart1; zephyr,shell-uart = &uart1; zephyr,sram = &sram0; + zephyr,pcie-controller = &pcie0; }; }; +&sdhc1 { + status = "okay"; + sdmmc { + compatible = "zephyr,sdmmc-disk"; + status = "okay"; + }; +}; + +&xmac0 { + status = "okay"; + local-mac-address = [00 00 00 01 02 03]; +}; + &uart1 { status = "okay"; current-speed = <115200>; }; +&pcie0 { + status = "okay"; +}; + diff --git a/boards/phytium/pd2308_demo/pd2308_demo_pd2308_smp.yaml b/boards/phytium/pd2308_demo/pd2308_demo_pd2308_smp.yaml index ba438d343f0..093f834e85e 100644 --- a/boards/phytium/pd2308_demo/pd2308_demo_pd2308_smp.yaml +++ b/boards/phytium/pd2308_demo/pd2308_demo_pd2308_smp.yaml @@ -1,4 +1,4 @@ -identifier: pd2308_demo_smp +identifier: pd2308_demo/pd2308/smp name: Phytium pd2308 demo type: mcu arch: arm64 diff --git a/boards/phytium/ps2316_test/ps2316_test.dts b/boards/phytium/ps2316_test/ps2316_test.dts index fe7809be344..2b8b8bccf47 100644 --- a/boards/phytium/ps2316_test/ps2316_test.dts +++ b/boards/phytium/ps2316_test/ps2316_test.dts @@ -25,25 +25,7 @@ chosen { }; }; -// &sdhc1 { -// status = "okay"; -// sdmmc { -// compatible = "zephyr,sdmmc-disk"; -// status = "okay"; -// }; -// }; - &uart1 { status = "okay"; current-speed = <115200>; }; - -// &uart2 { -// status = "okay"; -// current-speed = <115200>; -// }; - -// &xmac0 { -// status = "okay"; -// local-mac-address = [00 00 00 01 02 03]; -// }; diff --git a/boards/phytium/ps2316_test/ps2316_test_ps2316_el2.dts b/boards/phytium/ps2316_test/ps2316_test_ps2316_el2.dts index 237eaf54180..a7a5c3ffec5 100644 --- a/boards/phytium/ps2316_test/ps2316_test_ps2316_el2.dts +++ b/boards/phytium/ps2316_test/ps2316_test_ps2316_el2.dts @@ -26,25 +26,7 @@ chosen { }; }; -// &sdhc1 { -// status = "okay"; -// sdmmc { -// compatible = "zephyr,sdmmc-disk"; -// status = "okay"; -// }; -// }; - &uart1 { status = "okay"; current-speed = <115200>; }; - -// &uart2 { -// status = "okay"; -// current-speed = <115200>; -// }; - -// &xmac0 { -// status = "okay"; -// local-mac-address = [00 00 00 01 02 03]; -// }; diff --git a/boards/phytium/ps2316_test/ps2316_test_ps2316_el2.yaml b/boards/phytium/ps2316_test/ps2316_test_ps2316_el2.yaml index 6a7a0f33d63..19ec3faa26e 100644 --- a/boards/phytium/ps2316_test/ps2316_test_ps2316_el2.yaml +++ b/boards/phytium/ps2316_test/ps2316_test_ps2316_el2.yaml @@ -1,4 +1,4 @@ -identifier: ps2316_test_el2 +identifier: ps2316_test/ps2316/el2 name: Phytium ps2316 test type: mcu arch: arm64 diff --git a/boards/phytium/ps2316_test/ps2316_test_ps2316_el2_smp.dts b/boards/phytium/ps2316_test/ps2316_test_ps2316_el2_smp.dts index 237eaf54180..a7a5c3ffec5 100644 --- a/boards/phytium/ps2316_test/ps2316_test_ps2316_el2_smp.dts +++ b/boards/phytium/ps2316_test/ps2316_test_ps2316_el2_smp.dts @@ -26,25 +26,7 @@ chosen { }; }; -// &sdhc1 { -// status = "okay"; -// sdmmc { -// compatible = "zephyr,sdmmc-disk"; -// status = "okay"; -// }; -// }; - &uart1 { status = "okay"; current-speed = <115200>; }; - -// &uart2 { -// status = "okay"; -// current-speed = <115200>; -// }; - -// &xmac0 { -// status = "okay"; -// local-mac-address = [00 00 00 01 02 03]; -// }; diff --git a/boards/phytium/ps2316_test/ps2316_test_ps2316_el2_smp.yaml b/boards/phytium/ps2316_test/ps2316_test_ps2316_el2_smp.yaml index e0951f2d265..074d7eae7da 100644 --- a/boards/phytium/ps2316_test/ps2316_test_ps2316_el2_smp.yaml +++ b/boards/phytium/ps2316_test/ps2316_test_ps2316_el2_smp.yaml @@ -1,4 +1,4 @@ -identifier: ps2316_test_el2_smp +identifier: ps2316_test/ps2316/el2/smp name: Phytium d2000 demo type: mcu arch: arm64 diff --git a/boards/phytium/ps2316_test/ps2316_test_ps2316_smp.dts b/boards/phytium/ps2316_test/ps2316_test_ps2316_smp.dts index 237eaf54180..2b8b8bccf47 100644 --- a/boards/phytium/ps2316_test/ps2316_test_ps2316_smp.dts +++ b/boards/phytium/ps2316_test/ps2316_test_ps2316_smp.dts @@ -16,7 +16,6 @@ psci { compatible = "arm,psci-0.2"; method = "smc"; - label = "PSCI"; }; chosen { @@ -26,25 +25,7 @@ chosen { }; }; -// &sdhc1 { -// status = "okay"; -// sdmmc { -// compatible = "zephyr,sdmmc-disk"; -// status = "okay"; -// }; -// }; - &uart1 { status = "okay"; current-speed = <115200>; }; - -// &uart2 { -// status = "okay"; -// current-speed = <115200>; -// }; - -// &xmac0 { -// status = "okay"; -// local-mac-address = [00 00 00 01 02 03]; -// }; diff --git a/boards/phytium/ps2316_test/ps2316_test_ps2316_smp.yaml b/boards/phytium/ps2316_test/ps2316_test_ps2316_smp.yaml index 380da0fa9cb..841a15cfb4e 100644 --- a/boards/phytium/ps2316_test/ps2316_test_ps2316_smp.yaml +++ b/boards/phytium/ps2316_test/ps2316_test_ps2316_smp.yaml @@ -1,5 +1,5 @@ -identifier: ps2316_test_smp +identifier: ps2316_test/ps2316/smp name: Phytium ps2316 test type: mcu arch: arm64 diff --git a/drivers/ethernet/eth_phytium_gmac.c b/drivers/ethernet/eth_phytium_gmac.c index 899802ec05b..5cbd3fc5c83 100644 --- a/drivers/ethernet/eth_phytium_gmac.c +++ b/drivers/ethernet/eth_phytium_gmac.c @@ -194,7 +194,6 @@ static void eth_phytium_gmac_iface_init(struct net_if *iface) /* Initialize TX completion semaphore */ k_sem_init(&dev_data->tx_done_sem, 0, 1); - /* RX BD ring semaphore is not required at the time being */ dev_conf->config_func(dev); /* Submit initial PHY status polling delayed work */ @@ -257,13 +256,13 @@ static void EthLinkPhyStatusChecker(const struct device *dev) if (FGMAC_RGSMIIIS_LNKSTS_UP == (FGMAC_RGSMIIIS_LNKSTS & status)) { - printf("link is up\n"); + LOG_INF("link is up\n"); if(gmac_p->phy_link_status != FGMAC_LINKUP) gmac_p->phy_link_status = FGMAC_NEGOTIATION; } else { - printf("link is down\n"); + LOG_INF("link is down\n"); gmac_p->phy_link_status = FGMAC_LINKDOWN; } @@ -363,12 +362,12 @@ static void EthLinkStatusChecker(const struct device *dev) else duplex = FGMAC_PHY_MODE_FULLDUPLEX; - printf("link is up --- %d/%s", + LOG_INF("link is up --- %d/%s", speed, (FGMAC_PHY_MODE_FULLDUPLEX == duplex) ? "full" : "half"); } else { - printf("link is down ---"); + LOG_INF("link is down ---"); } } @@ -459,7 +458,7 @@ static void eth_phytium_gmac_handle_rx_pending(const struct device *dev) net_pkt_write(pkt, buffer, rx_data_length); if (net_recv_data(dev_data->iface, pkt) < 0) { - printf("%s RX packet hand-over to IP stack failed", dev->name); + LOG_ERR("%s RX packet hand-over to IP stack failed", dev->name); net_pkt_unref(pkt); } } @@ -611,7 +610,7 @@ static int eth_phytium_gmac_dev_init(const struct device *dev) FASSERT(FT_SUCCESS == status); } - /* step 6: initialize interrupt */ + /* initialize interrupt */ FGmacSetupIsr(dev); return 0; } @@ -692,7 +691,7 @@ static int eth_phytium_gmac_send(const struct device *dev, struct net_pkt *pkt) if (buffer == NULL) { - printf(" error buffer is 0 \r\n"); + LOG_ERR(" error buffer is 0 \r\n"); return -EIO; } @@ -760,5 +759,4 @@ static struct net_stats_eth *eth_phytium_gmac_stats(const struct device *dev) } #endif - DT_INST_FOREACH_STATUS_OKAY(ETH_PHYTIUM_GMAC_INITIALIZE) \ No newline at end of file diff --git a/drivers/sdhc/phytium_sdhc.c b/drivers/sdhc/phytium_sdhc.c index b2be77b446f..348c340f171 100644 --- a/drivers/sdhc/phytium_sdhc.c +++ b/drivers/sdhc/phytium_sdhc.c @@ -112,10 +112,15 @@ typedef struct void (*pad_delay)(void *instance); /* method to adjust pad delay ,with args*/ } fsdhc_timming; /* SDIF timing configuration */ - - +#ifdef CONFIG_SOC_E2000Q #define FSDIF_0_SD_CCLK_OUT_DELAY FIOPAD_AJ49_REG1_OFFSET #define FSDIF_1_SD_CCLK_OUT_DELAY FIOPAD_J57_REG1_OFFSET +#elif defined (CONFIG_SOC_E2000D) +#define FSDIF_0_SD_CCLK_OUT_DELAY FIOPAD_AJ45_REG1_OFFSET +#define FSDIF_1_SD_CCLK_OUT_DELAY FIOPAD_J53_REG1_OFFSET +#elif defined (CONFIG_SOC_PD2308) +#define FSDIF_0_SD_CCLK_OUT_DELAY FIOPAD_BV65_REG1_OFFSET +#endif /** * @name: FSdifUpdateExternalClk @@ -230,7 +235,9 @@ static void FSdifSetSDIFDelay(void * instance) } else { +#if defined(CONFIG_SOC_E2000Q) || defined(CONFIG_SOC_E2000D) reg = FSDIF_1_SD_CCLK_OUT_DELAY; +#endif } FIOPadSetDelay(iopad_ctrl, reg, FIOPAD_OUTPUT_DELAY, FIOPAD_DELAY_COARSE_TUNING, FIOPAD_DELAY_1); @@ -253,7 +260,9 @@ static void FSdifUnsetSDIFDelay(void * instance) } else { +#if defined(CONFIG_SOC_E2000Q) || defined(CONFIG_SOC_E2000D) reg = FSDIF_1_SD_CCLK_OUT_DELAY; +#endif } FIOPadSetDelay(iopad_ctrl, reg, FIOPAD_OUTPUT_DELAY, FIOPAD_DELAY_COARSE_TUNING, FIOPAD_DELAY_NONE); diff --git a/dts/arm64/phytium/d2000.dtsi b/dts/arm64/phytium/d2000.dtsi index b7ff0fb5f2f..2bd1ee0c8d8 100644 --- a/dts/arm64/phytium/d2000.dtsi +++ b/dts/arm64/phytium/d2000.dtsi @@ -142,6 +142,18 @@ status = "disabled"; }; + pcie0: pcie@40000000 { + compatible = "pci-host-ecam-generic"; + device_type = "pci"; + reg = <0x00 0x40000000 0x00 0x10000000>; + #size-cells = <0x02>; + #address-cells = <0x03>; + ranges = <0x1000000 0x00 0x50000000 0x00 0x50000000 0x00 0x08000000 + 0x2000000 0x00 0x58000000 0x00 0x58000000 0x00 0x27ffffff + 0x3000000 0x10 0x00 0x10 0x00 0x1f 0xffffffff>; + bus-range = <0x00 0xff>; + }; + /* 512MB DDR */ sram0: memory@80100000 { device_type = "memory"; diff --git a/dts/arm64/phytium/e2000d.dtsi b/dts/arm64/phytium/e2000d.dtsi index 950deda1df2..5dd03338fc4 100644 --- a/dts/arm64/phytium/e2000d.dtsi +++ b/dts/arm64/phytium/e2000d.dtsi @@ -77,6 +77,12 @@ #address-cells = <0x02>; }; + pinctrl: pinctrl@32B30000 { + compatible = "phytium,pinctrl"; + reg = <0x00 0x32B30000 0x00 0x2000>; + status = "okay"; + }; + uart1: uart@2800d000 { compatible = "arm,pl011"; reg = <0x00 0x2800d000 0x00 0x1000>; @@ -137,7 +143,19 @@ phy-autonegotiation; enable-fdx; disable-reject-fcs-crc-errors; - } ; + }; + + pcie0: pcie@40000000 { + compatible = "pci-host-ecam-generic"; + device_type = "pci"; + reg = <0x00 0x40000000 0x00 0x10000000>; + #size-cells = <0x02>; + #address-cells = <0x03>; + ranges = <0x1000000 0x00 0x50000000 0x00 0x50000000 0x00 0x08000000 + 0x2000000 0x00 0x58000000 0x00 0x58000000 0x00 0x27ffffff + 0x3000000 0x10 0x00 0x10 0x00 0x1f 0xffffffff>; + bus-range = <0x00 0xff>; + }; /* 256MB DDR */ sram0: memory@80100000 { diff --git a/dts/arm64/phytium/e2000q.dtsi b/dts/arm64/phytium/e2000q.dtsi index 73af5a41fb8..5402fb38344 100644 --- a/dts/arm64/phytium/e2000q.dtsi +++ b/dts/arm64/phytium/e2000q.dtsi @@ -142,8 +142,8 @@ tx-buffer-size = <1600>; phy-autonegotiation; enable-fdx; - disable-reject-fcs-crc-errors ; - } ; + disable-reject-fcs-crc-errors; + }; sdhc1: sdhc@28001000 { compatible = "phytium,sdhc"; diff --git a/dts/arm64/phytium/pd2308.dtsi b/dts/arm64/phytium/pd2308.dtsi index f5b3c044477..0f7cc1249d9 100644 --- a/dts/arm64/phytium/pd2308.dtsi +++ b/dts/arm64/phytium/pd2308.dtsi @@ -63,7 +63,7 @@ cpu@6 { device_type = "cpu"; - compatible = "phytium,ftc862"; + compatible = "phytium,ftc862"; reg = <0 0x10200>; }; @@ -86,7 +86,6 @@ IRQ_DEFAULT_PRIORITY>, ; - label = "arch_timer"; }; uartclk: apb-pclk { @@ -101,18 +100,23 @@ ranges; interrupt-parent = <&gic>; - + gic: interrupt-controller@36800000 { compatible = "arm,gic-v3", "arm,gic"; reg = <0x00 0x36800000 0x00 0x40000>, <0x00 0x36860000 0x00 0x200000>; interrupt-controller; #interrupt-cells = <4>; - label = "GIC"; status = "okay"; #size-cells = <0x02>; #address-cells = <0x02>; }; + + pinctrl: pinctrl@36cea000 { + compatible = "phytium,pinctrl"; + reg = <0x00 0x36cea000 0x00 0x2000>; + status = "okay"; + }; uart1: uart@28009000 { compatible = "arm,pl011"; @@ -121,7 +125,38 @@ interrupts = ; interrupt-names = "irq_0"; clocks = <&uartclk>; - label = "UART_1"; + }; + + xmac0: xmac@36ce0000 { + compatible = "phytium,xmac"; + reg = <0x00 0x36ce0000 0x00 0x2000>; + status = "disabled"; + interrupts = ; + interrupt-names = "irq_0"; + phy-poll-interval = <1000>; + clock-frequency = <50000000>; + phy-speed = <1000>; + interface-mode = <0>; + dma-brust-length = <16>; + max-queue-num = <1>; + rx-buffer-descriptors = <128>; + tx-buffer-descriptors = <32>; + rx-buffer-size = <1600>; + tx-buffer-size = <1600>; + phy-autonegotiation; + enable-fdx; + disable-reject-fcs-crc-errors; + }; + + sdhc1: sdhc@28000000 { + compatible = "phytium,sdhc"; + reg = <0x00 0x28000000 0x00 0x1000>; + status = "disabled"; + interrupts = ; + max-current-330 = <1020>; + max-bus-freq = <25000000>; + min-bus-freq = <400000>; }; /* 512MB DDR */ @@ -131,5 +166,17 @@ reg = <0x00 0x80100000 0x00 0x40000000>; }; + pcie0: pcie@40000000 { + compatible = "pci-host-ecam-generic"; + device_type = "pci"; + reg = <0x00 0x40000000 0x00 0x10000000>; + #size-cells = <0x02>; + #address-cells = <0x03>; + ranges = <0x1000000 0x00 0x50000000 0x00 0x50000000 0x00 0x08000000 + 0x2000000 0x00 0x58000000 0x00 0x58000000 0x00 0x27ffffff + 0x3000000 0x10 0x00 0x10 0x00 0x1f 0xffffffff>; + bus-range = <0x00 0xff>; + }; + }; }; diff --git a/dts/arm64/phytium/ps2316.dtsi b/dts/arm64/phytium/ps2316.dtsi index 959724656b9..7df2c666ca8 100644 --- a/dts/arm64/phytium/ps2316.dtsi +++ b/dts/arm64/phytium/ps2316.dtsi @@ -137,12 +137,6 @@ #address-cells = <0x02>; }; - // pinctrl: pinctrl@32b30000 { - // compatible = "phytium,pinctrl"; - // reg = <0x00 0x32b30000 0x00 0x2000>; - // status = "okay"; - // }; - uart1: uart@0x20001000 { compatible = "arm,pl011"; reg = <0x00 0x20001000 0x00 0x1000>; @@ -152,80 +146,6 @@ clocks = <&uartclk>; }; - // uart0: uart@0x28008000 { - // compatible = "arm,pl011"; - // reg = <0x00 0x28008000 0x00 0x1000>; - // status = "disabled"; - // interrupts = ; - // interrupt-names = "irq_0"; - // clocks = <&uartclk>; - // label = "UART_0"; - // }; - - // uart2: uart@2800e000 { - // compatible = "arm,pl011"; - // reg = <0x00 0x2800e000 0x00 0x1000>; - // status = "disabled"; - // interrupts = ; - // interrupt-names = "irq_1"; - // clocks = <&uartclk>; - // label = "UART_2"; - // }; - - - // uart3: uart@2800f000 { - // compatible = "arm,pl011"; - // reg = <0x00 0x2800f000 0x00 0x1000>; - // status = "disabled"; - // interrupts = ; - // interrupt-names = "irq_0"; - // clocks = <&uartclk>; - // label = "UART_3"; - // }; - - - // sdhc0: sdhc@28000000 { - // compatible = "phytium,sdhc"; - // reg = <0x00 0x28000000 0x00 0x1000>; - // status = "disabled"; - // interrupts = ; - // max-current-330 = <1020>; - // max-bus-freq = <25000000>; - // min-bus-freq = <400000>; - // }; - - // xmac0: xmac@3200C000 { - // compatible = "phytium,xmac"; - // reg = <0x00 0x3200C000 0x00 0x2000>; - // status = "disabled"; - // interrupts = ; - // interrupt-names = "irq_0"; - // phy-poll-interval = <5000>; - // clock-frequency = <50000000> ; - // phy-speed = <1000> ; - // interface-mode = <0> ; - // dma-brust-length = <16> ; - // max-queue-num = <1> ; - // rx-buffer-descriptors = <128>; - // tx-buffer-descriptors = <128>; - // rx-buffer-size = <1600>; - // tx-buffer-size = <1600>; - // phy-autonegotiation; - // enable-fdx; - // disable-reject-fcs-crc-errors ; - // } ; - - // sdhc1: sdhc@28001000 { - // compatible = "phytium,sdhc"; - // reg = <0x00 0x28001000 0x00 0x1000>; - // status = "disabled"; - // interrupts = ; - // max-current-330 = <1020>; - // max-bus-freq = <25000000>; - // min-bus-freq = <400000>; - // }; - /* 512MB DDR */ sram0: memory@80100000 { device_type = "memory"; @@ -233,22 +153,5 @@ reg = <0x00 0x80100000 0x00 0x20000000>; }; - // temp_mem0:memory@0xe0000000 { - // device_type = "memory"; - // compatible = "mmio-sram"; - // reg = <0x00 0xe0000000 0x00 0x10000000>; - // } ; - - // pcie0: pcie@40000000 { - // compatible = "pci-host-ecam-generic"; - // device_type = "pci"; - // reg = <0x00 0x40000000 0x00 0x10000000>; - // #size-cells = <0x02>; - // #address-cells = <0x03>; - // ranges = <0x1000000 0x00 0x50000000 0x00 0x50000000 0x00 0x08000000 - // 0x2000000 0x00 0x58000000 0x00 0x58000000 0x00 0x27ffffff - // 0x3000000 0x10 0x00 0x10 0x00 0x1f 0xffffffff>; - // bus-range = <0x00 0xff>; - // }; }; }; diff --git a/include/zephyr/dt-bindings/pinctrl/phytium-e2000d-pinctrl.h b/include/zephyr/dt-bindings/pinctrl/phytium-e2000d-pinctrl.h new file mode 100644 index 00000000000..3f6f0f7ede3 --- /dev/null +++ b/include/zephyr/dt-bindings/pinctrl/phytium-e2000d-pinctrl.h @@ -0,0 +1,278 @@ +// Phytium is pleased to support the open source community by making Zephyr-SDK available. + +// +// Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +// +// Licensed under the Apache-2.0 License (the "License"); you may not use this file except +// in compliance with the License. You may obtain a copy of the License at +// +// https://opensource.org/license/apache-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 ZEPHYR_INCLUDE_DT_BINDINGS_PINCTRL_PHYTIUM_PINCTRL_H_ +#define ZEPHYR_INCLUDE_DT_BINDINGS_PINCTRL_PHYTIUM_PINCTRL_H_ + +#define FIOPAD_AN55_REG0_OFFSET 0x0000U +#define FIOPAD_AW43_REG0_OFFSET 0x0004U +#define FIOPAD_AR51_REG0_OFFSET 0x0020U +#define FIOPAD_AJ51_REG0_OFFSET 0x0024U +#define FIOPAD_AL51_REG0_OFFSET 0x0028U +#define FIOPAD_AL49_REG0_OFFSET 0x002CU +#define FIOPAD_AN47_REG0_OFFSET 0x0030U +#define FIOPAD_AR47_REG0_OFFSET 0x0034U +#define FIOPAD_BA53_REG0_OFFSET 0x0038U +#define FIOPAD_BA55_REG0_OFFSET 0x003CU +#define FIOPAD_AW53_REG0_OFFSET 0x0040U +#define FIOPAD_AW55_REG0_OFFSET 0x0044U +#define FIOPAD_AU51_REG0_OFFSET 0x0048U +#define FIOPAD_AN53_REG0_OFFSET 0x004CU +#define FIOPAD_AL55_REG0_OFFSET 0x0050U +#define FIOPAD_AJ55_REG0_OFFSET 0x0054U +#define FIOPAD_AJ53_REG0_OFFSET 0x0058U +#define FIOPAD_AG55_REG0_OFFSET 0x005CU +#define FIOPAD_AG53_REG0_OFFSET 0x0060U +#define FIOPAD_AE55_REG0_OFFSET 0x0064U +#define FIOPAD_AC55_REG0_OFFSET 0x0068U +#define FIOPAD_AC53_REG0_OFFSET 0x006CU +#define FIOPAD_AR45_REG0_OFFSET 0x0070U +#define FIOPAD_BA51_REG0_OFFSET 0x0074U +#define FIOPAD_BA49_REG0_OFFSET 0x0078U +#define FIOPAD_AR55_REG0_OFFSET 0x007CU +#define FIOPAD_AU55_REG0_OFFSET 0x0080U +#define FIOPAD_AR53_REG0_OFFSET 0x0084U +#define FIOPAD_BA45_REG0_OFFSET 0x0088U +#define FIOPAD_AW51_REG0_OFFSET 0x008CU +#define FIOPAD_A31_REG0_OFFSET 0x0090U +#define FIOPAD_R53_REG0_OFFSET 0x0094U +#define FIOPAD_R55_REG0_OFFSET 0x0098U +#define FIOPAD_U55_REG0_OFFSET 0x009CU +#define FIOPAD_W55_REG0_OFFSET 0x00A0U +#define FIOPAD_U53_REG0_OFFSET 0x00A4U +#define FIOPAD_AA53_REG0_OFFSET 0x00A8U +#define FIOPAD_AA55_REG0_OFFSET 0x00ACU +#define FIOPAD_AW47_REG0_OFFSET 0x00B0U +#define FIOPAD_AU47_REG0_OFFSET 0x00B4U +#define FIOPAD_A35_REG0_OFFSET 0x00B8U +#define FIOPAD_C35_REG0_OFFSET 0x00BCU +#define FIOPAD_C33_REG0_OFFSET 0x00C0U +#define FIOPAD_A33_REG0_OFFSET 0x00C4U +#define FIOPAD_A37_REG0_OFFSET 0x00C8U +#define FIOPAD_A39_REG0_OFFSET 0x00CCU +#define FIOPAD_A41_REG0_OFFSET 0x00D0U +#define FIOPAD_C41_REG0_OFFSET 0x00D4U +#define FIOPAD_A43_REG0_OFFSET 0x00D8U +#define FIOPAD_A45_REG0_OFFSET 0x00DCU +#define FIOPAD_C45_REG0_OFFSET 0x00E0U +#define FIOPAD_A47_REG0_OFFSET 0x00E4U +#define FIOPAD_A29_REG0_OFFSET 0x00E8U +#define FIOPAD_C29_REG0_OFFSET 0x00ECU +#define FIOPAD_C27_REG0_OFFSET 0x00F0U +#define FIOPAD_A27_REG0_OFFSET 0x00F4U +#define FIOPAD_AJ49_REG0_OFFSET 0x00F8U +#define FIOPAD_AL45_REG0_OFFSET 0x00FCU +#define FIOPAD_AL43_REG0_OFFSET 0x0100U +#define FIOPAD_AN45_REG0_OFFSET 0x0104U +#define FIOPAD_AG47_REG0_OFFSET 0x0108U +#define FIOPAD_AJ47_REG0_OFFSET 0x010CU +#define FIOPAD_AG45_REG0_OFFSET 0x0110U +#define FIOPAD_AE51_REG0_OFFSET 0x0114U +#define FIOPAD_AE49_REG0_OFFSET 0x0118U +#define FIOPAD_AG51_REG0_OFFSET 0x011CU +#define FIOPAD_AJ45_REG0_OFFSET 0x0120U +#define FIOPAD_AC51_REG0_OFFSET 0x0124U +#define FIOPAD_AC49_REG0_OFFSET 0x0128U +#define FIOPAD_AE47_REG0_OFFSET 0x012CU +#define FIOPAD_W47_REG0_OFFSET 0x0130U +#define FIOPAD_W51_REG0_OFFSET 0x0134U +#define FIOPAD_W49_REG0_OFFSET 0x0138U +#define FIOPAD_U51_REG0_OFFSET 0x013CU +#define FIOPAD_U49_REG0_OFFSET 0x0140U +#define FIOPAD_AE45_REG0_OFFSET 0x0144U +#define FIOPAD_AC45_REG0_OFFSET 0x0148U +#define FIOPAD_AE43_REG0_OFFSET 0x014CU +#define FIOPAD_AA43_REG0_OFFSET 0x0150U +#define FIOPAD_AA45_REG0_OFFSET 0x0154U +#define FIOPAD_W45_REG0_OFFSET 0x0158U +#define FIOPAD_AA47_REG0_OFFSET 0x015CU +#define FIOPAD_U45_REG0_OFFSET 0x0160U +#define FIOPAD_G55_REG0_OFFSET 0x0164U +#define FIOPAD_J55_REG0_OFFSET 0x0168U +#define FIOPAD_L53_REG0_OFFSET 0x016CU +#define FIOPAD_C55_REG0_OFFSET 0x0170U +#define FIOPAD_E55_REG0_OFFSET 0x0174U +#define FIOPAD_J53_REG0_OFFSET 0x0178U +#define FIOPAD_L55_REG0_OFFSET 0x017CU +#define FIOPAD_N55_REG0_OFFSET 0x0180U +#define FIOPAD_C53_REG0_OFFSET 0x0184U +#define FIOPAD_E53_REG0_OFFSET 0x0188U +#define FIOPAD_E27_REG0_OFFSET 0x018CU +#define FIOPAD_G27_REG0_OFFSET 0x0190U +#define FIOPAD_N37_REG0_OFFSET 0x0194U +#define FIOPAD_N35_REG0_OFFSET 0x0198U +#define FIOPAD_J29_REG0_OFFSET 0x019CU +#define FIOPAD_N29_REG0_OFFSET 0x01A0U +#define FIOPAD_L29_REG0_OFFSET 0x01A4U +#define FIOPAD_N41_REG0_OFFSET 0x01A8U +#define FIOPAD_N39_REG0_OFFSET 0x01ACU +#define FIOPAD_L27_REG0_OFFSET 0x01B0U +#define FIOPAD_J27_REG0_OFFSET 0x01B4U +#define FIOPAD_J25_REG0_OFFSET 0x01B8U +#define FIOPAD_E25_REG0_OFFSET 0x01BCU +#define FIOPAD_G25_REG0_OFFSET 0x01C0U +#define FIOPAD_N23_REG0_OFFSET 0x01C4U +#define FIOPAD_L25_REG0_OFFSET 0x01C8U +#define FIOPAD_J33_REG0_OFFSET 0x01CCU +#define FIOPAD_J35_REG0_OFFSET 0x01D0U +#define FIOPAD_G37_REG0_OFFSET 0x01D4U +#define FIOPAD_E39_REG0_OFFSET 0x01D8U +#define FIOPAD_L39_REG0_OFFSET 0x01DCU +#define FIOPAD_C39_REG0_OFFSET 0x01E0U +#define FIOPAD_E37_REG0_OFFSET 0x01E4U +#define FIOPAD_L41_REG0_OFFSET 0x01E8U +#define FIOPAD_J39_REG0_OFFSET 0x01ECU +#define FIOPAD_J37_REG0_OFFSET 0x01F0U +#define FIOPAD_L35_REG0_OFFSET 0x01F4U +#define FIOPAD_E33_REG0_OFFSET 0x01F8U +#define FIOPAD_E31_REG0_OFFSET 0x01FCU +#define FIOPAD_G31_REG0_OFFSET 0x0200U +#define FIOPAD_J31_REG0_OFFSET 0x0204U +#define FIOPAD_L33_REG0_OFFSET 0x0208U +#define FIOPAD_N31_REG0_OFFSET 0x020CU +#define FIOPAD_R47_REG0_OFFSET 0x0210U +#define FIOPAD_R45_REG0_OFFSET 0x0214U +#define FIOPAD_N47_REG0_OFFSET 0x0218U +#define FIOPAD_N51_REG0_OFFSET 0x021CU +#define FIOPAD_L51_REG0_OFFSET 0x0220U +#define FIOPAD_J51_REG0_OFFSET 0x0224U +#define FIOPAD_J41_REG0_OFFSET 0x0228U +#define FIOPAD_E43_REG0_OFFSET 0x022CU +#define FIOPAD_G43_REG0_OFFSET 0x0230U +#define FIOPAD_J43_REG0_OFFSET 0x0234U +#define FIOPAD_J45_REG0_OFFSET 0x0238U +#define FIOPAD_N45_REG0_OFFSET 0x023CU +#define FIOPAD_L47_REG0_OFFSET 0x0240U +#define FIOPAD_L45_REG0_OFFSET 0x0244U +#define FIOPAD_N49_REG0_OFFSET 0x0248U +#define FIOPAD_J49_REG0_OFFSET 0x024CU + +#define FIOPAD_REG0_BEG_OFFSET FIOPAD_AN55_REG0_OFFSET +#define FIOPAD_REG0_END_OFFSET FIOPAD_J49_REG0_OFFSET + +/* register offset of iopad delay */ +#define FIOPAD_AJ51_REG1_OFFSET 0x1024U +#define FIOPAD_AL51_REG1_OFFSET 0x1028U +#define FIOPAD_AL49_REG1_OFFSET 0x102CU +#define FIOPAD_AN47_REG1_OFFSET 0x1030U +#define FIOPAD_AR47_REG1_OFFSET 0x1034U +#define FIOPAD_AJ53_REG1_OFFSET 0x1058U +#define FIOPAD_AG55_REG1_OFFSET 0x105CU +#define FIOPAD_AG53_REG1_OFFSET 0x1060U +#define FIOPAD_AE55_REG1_OFFSET 0x1064U +#define FIOPAD_BA51_REG1_OFFSET 0x1074U +#define FIOPAD_BA49_REG1_OFFSET 0x1078U +#define FIOPAD_AR55_REG1_OFFSET 0x107CU +#define FIOPAD_AU55_REG1_OFFSET 0x1080U +#define FIOPAD_A41_REG1_OFFSET 0x10D0U +#define FIOPAD_C41_REG1_OFFSET 0x10D4U +#define FIOPAD_A43_REG1_OFFSET 0x10D8U +#define FIOPAD_A45_REG1_OFFSET 0x10DCU +#define FIOPAD_C45_REG1_OFFSET 0x10E0U +#define FIOPAD_A47_REG1_OFFSET 0x10E4U +#define FIOPAD_A29_REG1_OFFSET 0x10E8U +#define FIOPAD_C29_REG1_OFFSET 0x10ECU +#define FIOPAD_C27_REG1_OFFSET 0x10F0U +#define FIOPAD_A27_REG1_OFFSET 0x10F4U +#define FIOPAD_AJ49_REG1_OFFSET 0x10F8U +#define FIOPAD_AL45_REG1_OFFSET 0x10FCU +#define FIOPAD_AL43_REG1_OFFSET 0x1100U +#define FIOPAD_AN45_REG1_OFFSET 0x1104U +#define FIOPAD_AG47_REG1_OFFSET 0x1108U +#define FIOPAD_AJ47_REG1_OFFSET 0x110CU +#define FIOPAD_AG45_REG1_OFFSET 0x1110U +#define FIOPAD_AE51_REG1_OFFSET 0x1114U +#define FIOPAD_AE49_REG1_OFFSET 0x1118U +#define FIOPAD_AG51_REG1_OFFSET 0x111CU +#define FIOPAD_AJ45_REG1_OFFSET 0x1120U +#define FIOPAD_AC51_REG1_OFFSET 0x1124U +#define FIOPAD_AC49_REG1_OFFSET 0x1128U +#define FIOPAD_AE47_REG1_OFFSET 0x112CU +#define FIOPAD_W47_REG1_OFFSET 0x1130U +#define FIOPAD_W49_REG1_OFFSET 0x1138U +#define FIOPAD_U51_REG1_OFFSET 0x113CU +#define FIOPAD_U49_REG1_OFFSET 0x1140U +#define FIOPAD_AE45_REG1_OFFSET 0x1144U +#define FIOPAD_AC45_REG1_OFFSET 0x1148U +#define FIOPAD_AE43_REG1_OFFSET 0x114CU +#define FIOPAD_AA43_REG1_OFFSET 0x1150U +#define FIOPAD_AA45_REG1_OFFSET 0x1154U +#define FIOPAD_W45_REG1_OFFSET 0x1158U +#define FIOPAD_AA47_REG1_OFFSET 0x115CU +#define FIOPAD_U45_REG1_OFFSET 0x1160U +#define FIOPAD_J55_REG1_OFFSET 0x1168U +#define FIOPAD_L53_REG1_OFFSET 0x116CU +#define FIOPAD_C55_REG1_OFFSET 0x1170U +#define FIOPAD_E55_REG1_OFFSET 0x1174U +#define FIOPAD_J53_REG1_OFFSET 0x1178U +#define FIOPAD_L55_REG1_OFFSET 0x117CU +#define FIOPAD_N55_REG1_OFFSET 0x1180U +#define FIOPAD_E27_REG1_OFFSET 0x118CU +#define FIOPAD_G27_REG1_OFFSET 0x1190U +#define FIOPAD_N37_REG1_OFFSET 0x1194U +#define FIOPAD_N35_REG1_OFFSET 0x1198U +#define FIOPAD_J29_REG1_OFFSET 0x119CU +#define FIOPAD_N29_REG1_OFFSET 0x11A0U +#define FIOPAD_L29_REG1_OFFSET 0x11A4U +#define FIOPAD_N41_REG1_OFFSET 0x11A8U +#define FIOPAD_N39_REG1_OFFSET 0x11ACU +#define FIOPAD_L27_REG1_OFFSET 0x11B0U +#define FIOPAD_J27_REG1_OFFSET 0x11B4U +#define FIOPAD_J25_REG1_OFFSET 0x11B8U +#define FIOPAD_E25_REG1_OFFSET 0x11BCU +#define FIOPAD_G25_REG1_OFFSET 0x11C0U +#define FIOPAD_J33_REG1_OFFSET 0x11CCU +#define FIOPAD_J35_REG1_OFFSET 0x11D0U +#define FIOPAD_G37_REG1_OFFSET 0x11D4U +#define FIOPAD_E39_REG1_OFFSET 0x11D8U +#define FIOPAD_L39_REG1_OFFSET 0x11DCU +#define FIOPAD_C39_REG1_OFFSET 0x11E0U +#define FIOPAD_E37_REG1_OFFSET 0x11E4U +#define FIOPAD_L41_REG1_OFFSET 0x11E8U +#define FIOPAD_J39_REG1_OFFSET 0x11ECU +#define FIOPAD_J37_REG1_OFFSET 0x11F0U +#define FIOPAD_L35_REG1_OFFSET 0x11F4U +#define FIOPAD_E33_REG1_OFFSET 0x11F8U +#define FIOPAD_E31_REG1_OFFSET 0x11FCU +#define FIOPAD_G31_REG1_OFFSET 0x1200U +#define FIOPAD_L51_REG1_OFFSET 0x1220U +#define FIOPAD_J51_REG1_OFFSET 0x1224U +#define FIOPAD_J41_REG1_OFFSET 0x1228U +#define FIOPAD_E43_REG1_OFFSET 0x122CU +#define FIOPAD_G43_REG1_OFFSET 0x1230U +#define FIOPAD_J43_REG1_OFFSET 0x1234U +#define FIOPAD_J45_REG1_OFFSET 0x1238U +#define FIOPAD_N45_REG1_OFFSET 0x123CU +#define FIOPAD_L47_REG1_OFFSET 0x1240U +#define FIOPAD_L45_REG1_OFFSET 0x1244U +#define FIOPAD_N49_REG1_OFFSET 0x1248U +#define FIOPAD_J49_REG1_OFFSET 0x124CU + +#define FIOPAD_REG1_BEG_OFFSET FIOPAD_AJ51_REG1_OFFSET +#define FIOPAD_REG1_END_OFFSET FIOPAD_J49_REG1_OFFSET + + +#define FIOPAD_FUNC0 0x0 +#define FIOPAD_FUNC1 0x1 +#define FIOPAD_FUNC2 0x2 +#define FIOPAD_FUNC3 0x3 +#define FIOPAD_FUNC4 0x4 +#define FIOPAD_FUNC5 0x5 +#define FIOPAD_FUNC6 0x6 +#define FIOPAD_FUNC7 0x7 + +#define PHYTIUM_PINMUX(pin_reg_offset, func_num) (pin_reg_offset) (func_num) + +#endif /* ZEPHYR_INCLUDE_DT_BINDINGS_PINCTRL_TI_K3_PINCTRL_H_ */ diff --git a/include/zephyr/dt-bindings/pinctrl/phytium-pd2308-pinctrl.h b/include/zephyr/dt-bindings/pinctrl/phytium-pd2308-pinctrl.h new file mode 100644 index 00000000000..d18cf773f16 --- /dev/null +++ b/include/zephyr/dt-bindings/pinctrl/phytium-pd2308-pinctrl.h @@ -0,0 +1,226 @@ +// Phytium is pleased to support the open source community by making Zephyr-SDK available. + +// +// Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +// +// Licensed under the Apache-2.0 License (the "License"); you may not use this file except +// in compliance with the License. You may obtain a copy of the License at +// +// https://opensource.org/license/apache-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 ZEPHYR_INCLUDE_DT_BINDINGS_PINCTRL_PHYTIUM_PINCTRL_H_ +#define ZEPHYR_INCLUDE_DT_BINDINGS_PINCTRL_PHYTIUM_PINCTRL_H_ + +#define FIOPAD_C5_REG0_OFFSET 0x0018U +#define FIOPAD_E5_REG0_OFFSET 0x001CU + +#define FIOPAD_E3_REG0_OFFSET 0x0020U +#define FIOPAD_L5_REG0_OFFSET 0x0024U +#define FIOPAD_J5_REG0_OFFSET 0x0028U +#define FIOPAD_L3_REG0_OFFSET 0x002CU + +#define FIOPAD_N1_REG0_OFFSET 0x0030U +#define FIOPAD_L1_REG0_OFFSET 0x0034U +#define FIOPAD_J1_REG0_OFFSET 0x0038U +#define FIOPAD_N5_REG0_OFFSET 0x003CU + +#define FIOPAD_CH19_REG0_OFFSET 0x0040U +#define FIOPAD_CF19_REG0_OFFSET 0x0044U +#define FIOPAD_G3_REG0_OFFSET 0x0048U +#define FIOPAD_G1_REG0_OFFSET 0x004CU + +#define FIOPAD_G5_REG0_OFFSET 0x0050U +#define FIOPAD_CB19_REG0_OFFSET 0x0054U +#define FIOPAD_CB21_REG0_OFFSET 0x0058U +#define FIOPAD_BY19_REG0_OFFSET 0x005CU + +#define FIOPAD_U13_REG0_OFFSET 0x0060U +#define FIOPAD_U15_REG0_OFFSET 0x0064U +#define FIOPAD_AA7_REG0_OFFSET 0x0068U +#define FIOPAD_AA9_REG0_OFFSET 0x006CU + +#define FIOPAD_AA13_REG0_OFFSET 0x0070U +#define FIOPAD_AA11_REG0_OFFSET 0x0074U +#define FIOPAD_AA15_REG0_OFFSET 0x0078U +#define FIOPAD_W11_REG0_OFFSET 0x007CU + +#define FIOPAD_W7_REG0_OFFSET 0x0080U +#define FIOPAD_U11_REG0_OFFSET 0x0084U +#define FIOPAD_U9_REG0_OFFSET 0x0088U +#define FIOPAD_U3_REG0_OFFSET 0x008CU + +#define FIOPAD_U1_REG0_OFFSET 0x0090U +#define FIOPAD_CM43_REG0_OFFSET 0x0094U +#define FIOPAD_CP45_REG0_OFFSET 0x0098U +#define FIOPAD_CH21_REG0_OFFSET 0x009CU + +#define FIOPAD_CK19_REG0_OFFSET 0x00A0U +#define FIOPAD_BT67_REG0_OFFSET 0x00A4U +#define FIOPAD_BP67_REG0_OFFSET 0x00A8U +#define FIOPAD_BV63_REG0_OFFSET 0x00ACU + +#define FIOPAD_BT63_REG0_OFFSET 0x00B0U +#define FIOPAD_AN17_REG0_OFFSET 0x00B4U +#define FIOPAD_AR17_REG0_OFFSET 0x00B8U +#define FIOPAD_AR15_REG0_OFFSET 0x00BCU + +#define FIOPAD_AN15_REG0_OFFSET 0x00C0U +#define FIOPAD_AJ19_REG0_OFFSET 0x00C4U +#define FIOPAD_AN19_REG0_OFFSET 0x00C8U +#define FIOPAD_AJ15_REG0_OFFSET 0x00CCU + +#define FIOPAD_AG21_REG0_OFFSET 0x00D0U +#define FIOPAD_AJ13_REG0_OFFSET 0x00D4U +#define FIOPAD_AJ11_REG0_OFFSET 0x00D8U +#define FIOPAD_AN21_REG0_OFFSET 0x00DCU + +#define FIOPAD_AC5_REG0_OFFSET 0x00E0U +#define FIOPAD_AE1_REG0_OFFSET 0x00E4U +#define FIOPAD_AE3_REG0_OFFSET 0x00E8U +#define FIOPAD_AC3_REG0_OFFSET 0x00ECU + +#define FIOPAD_AR19_REG0_OFFSET 0x00F0U +#define FIOPAD_BM21_REG0_OFFSET 0x00F4U +#define FIOPAD_BK19_REG0_OFFSET 0x00F8U +#define FIOPAD_BK21_REG0_OFFSET 0x00FCU + +#define FIOPAD_BM19_REG0_OFFSET 0x0100U +#define FIOPAD_BP21_REG0_OFFSET 0x0104U +#define FIOPAD_BP19_REG0_OFFSET 0x0108U +#define FIOPAD_BV19_REG0_OFFSET 0x010CU + +#define FIOPAD_BV12_REG0_OFFSET 0x0110U +#define FIOPAD_CF67_REG0_OFFSET 0x0114U +#define FIOPAD_CD67_REG0_OFFSET 0x0118U +#define FIOPAD_BY65_REG0_OFFSET 0x011CU + +#define FIOPAD_BY67_REG0_OFFSET 0x0120U +#define FIOPAD_CB67_REG0_OFFSET 0x0124U +#define FIOPAD_BV65_REG0_OFFSET 0x0128U +#define FIOPAD_BV67_REG0_OFFSET 0x012CU + +#define FIOPAD_BY63_REG0_OFFSET 0x0130U +#define FIOPAD_CB63_REG0_OFFSET 0x0134U +#define FIOPAD_CD63_REG0_OFFSET 0x0138U +#define FIOPAD_W5_REG0_OFFSET 0x013CU + +#define FIOPAD_U5_REG0_OFFSET 0x0140U +#define FIOPAD_W3_REG0_OFFSET 0x0144U +#define FIOPAD_AC7_REG0_OFFSET 0x0148U +#define FIOPAD_W1_REG0_OFFSET 0x014CU + +#define FIOPAD_AA5_REG0_OFFSET 0x0150U +#define FIOPAD_AA1_REG0_OFFSET 0x0154U +#define FIOPAD_AC1_REG0_OFFSET 0x0158U +#define FIOPAD_BM63_REG0_OFFSET 0x015CU + +#define FIOPAD_BP63_REG0_OFFSET 0x0160U +#define FIOPAD_CM47_REG0_OFFSET 0x0164U +#define FIOPAD_CK47_REG0_OFFSET 0x0168U +#define FIOPAD_AG13_REG0_OFFSET 0x016CU + +#define FIOPAD_AG11_REG0_OFFSET 0x0170U +#define FIOPAD_AL15_REG0_OFFSET 0x0174U +#define FIOPAD_AJ17_REG0_OFFSET 0x0178U +#define FIOPAD_AC15_REG0_OFFSET 0x017CU + +#define FIOPAD_AC9_REG0_OFFSET 0x0180U +#define FIOPAD_AC11_REG0_OFFSET 0x0184U +#define FIOPAD_AE13_REG0_OFFSET 0x0188U +#define FIOPAD_AE11_REG0_OFFSET 0x018CU + +#define FIOPAD_CD65_REG0_OFFSET 0x0190U +#define FIOPAD_CF63_REG0_OFFSET 0x0194U +#define FIOPAD_CH63_REG0_OFFSET 0x0198U +#define FIOPAD_CH65_REG0_OFFSET 0x019CU + +#define FIOPAD_CH67_REG0_OFFSET 0x01A0U +#define FIOPAD_AE17_REG0_OFFSET 0x01A4U +#define FIOPAD_CF65_REG0_OFFSET 0x01A8U +#define FIOPAD_AA19_REG0_OFFSET 0x01ACU + +#define FIOPAD_CE61_REG0_OFFSET 0x01B0U +#define FIOPAD_AC19_REG0_OFFSET 0x01B4U +#define FIOPAD_AA17_REG0_OFFSET 0x01B8U +#define FIOPAD_W13_REG0_OFFSET 0x01BCU + +#define FIOPAD_AG15_REG0_OFFSET 0x01C0U +#define FIOPAD_AE21_REG0_OFFSET 0x01C4U +#define FIOPAD_CM45_REG0_OFFSET 0x01C8U +#define FIOPAD_CK45_REG0_OFFSET 0x01CCU + +#define FIOPAD_BM65_REG0_OFFSET 0x01D0U +#define FIOPAD_BP65_REG0_OFFSET 0x01D4U + +#define FIOPAD_REG0_BEG_OFFSET FIOPAD_C5_REG0_OFFSET +#define FIOPAD_REG0_END_OFFSET FIOPAD_BP65_REG0_OFFSET + +/* register offset of iopad delay */ +#define FIOPAD_CK19_REG1_OFFSET 0x10A0U +#define FIOPAD_BT67_REG1_OFFSET 0x10A4U +#define FIOPAD_BP67_REG1_OFFSET 0x10A8U +#define FIOPAD_BV63_REG1_OFFSET 0x10ACU + +#define FIOPAD_BT63_REG1_OFFSET 0x10B0U +#define FIOPAD_AN17_REG1_OFFSET 0x10B4U +#define FIOPAD_AR17_REG1_OFFSET 0x10B8U +#define FIOPAD_AR15_REG1_OFFSET 0x10BCU + +#define FIOPAD_AN15_REG1_OFFSET 0x10C0U +#define FIOPAD_AJ19_REG1_OFFSET 0x10C4U +#define FIOPAD_AN19_REG1_OFFSET 0x10C8U +#define FIOPAD_AJ15_REG1_OFFSET 0x10CCU + +#define FIOPAD_AG21_REG1_OFFSET 0x10D0U +#define FIOPAD_AJ13_REG1_OFFSET 0x10D4U +#define FIOPAD_AJ11_REG1_OFFSET 0x10D8U +#define FIOPAD_AN21_REG1_OFFSET 0x10DCU + +#define FIOPAD_AE1_REG1_OFFSET 0x10E4U +#define FIOPAD_AE3_REG1_OFFSET 0x10E8U +#define FIOPAD_AC3_REG1_OFFSET 0x10ECU + +#define FIOPAD_AR19_REG1_OFFSET 0x10F0U +#define FIOPAD_BM21_REG1_OFFSET 0x10F4U +#define FIOPAD_BK19_REG1_OFFSET 0x10F8U +#define FIOPAD_BK21_REG1_OFFSET 0x10FCU + +#define FIOPAD_BM19_REG1_OFFSET 0x1100U +#define FIOPAD_BP21_REG1_OFFSET 0x1104U +#define FIOPAD_BP19_REG1_OFFSET 0x1108U +#define FIOPAD_BV19_REG1_OFFSET 0x110CU + +#define FIOPAD_BV21_REG1_OFFSET 0x1110U +#define FIOPAD_CF67_REG1_OFFSET 0x1114U +#define FIOPAD_CD67_REG1_OFFSET 0x1118U +#define FIOPAD_BY65_REG1_OFFSET 0x111CU + +#define FIOPAD_BY67_REG1_OFFSET 0x1120U +#define FIOPAD_CB67_REG1_OFFSET 0x1124U +#define FIOPAD_BV65_REG1_OFFSET 0x1128U + +#define FIOPAD_CD65_REG1_OFFSET 0x1190U +#define FIOPAD_CF63_REG1_OFFSET 0x1194U +#define FIOPAD_CH63_REG1_OFFSET 0x1198U +#define FIOPAD_CH65_REG1_OFFSET 0x119CU + +#define FIOPAD_REG1_BEG_OFFSET FIOPAD_CK19_REG1_OFFSET +#define FIOPAD_REG1_END_OFFSET FIOPAD_CH65_REG1_OFFSET + +#define FIOPAD_FUNC0 0x0 +#define FIOPAD_FUNC1 0x1 +#define FIOPAD_FUNC2 0x2 +#define FIOPAD_FUNC3 0x3 +#define FIOPAD_FUNC4 0x4 +#define FIOPAD_FUNC5 0x5 +#define FIOPAD_FUNC6 0x6 +#define FIOPAD_FUNC7 0x7 + +#define PHYTIUM_PINMUX(pin_reg_offset, func_num) (pin_reg_offset) (func_num) + +#endif /* ZEPHYR_INCLUDE_DT_BINDINGS_PINCTRL_TI_K3_PINCTRL_H_ */ diff --git a/soc/phytium/pd2308/pinctrl_soc.h b/soc/phytium/pd2308/pinctrl_soc.h new file mode 100644 index 00000000000..40628b5fce6 --- /dev/null +++ b/soc/phytium/pd2308/pinctrl_soc.h @@ -0,0 +1,51 @@ +// Phytium is pleased to support the open source community by making Zephyr-SDK available. + +// +// Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +// +// Licensed under the Apache-2.0 License (the "License"); you may not use this file except +// in compliance with the License. You may obtain a copy of the License at +// +// https://opensource.org/license/apache-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 ZEPHYR_SOC_ARM64_PHYTIUM_PD2308_PINCTRL_SOC_H_ +#define ZEPHYR_SOC_ARM64_PHYTIUM_PD2308_PINCTRL_SOC_H_ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct pinctrl_soc_pin { + + uint32_t pin_reg_offset; + uint32_t func_num; +}; + +typedef struct pinctrl_soc_pin pinctrl_soc_pin_t; + +#define PHYTIUM_PD2308_DT_PIN(node_id) \ + { \ + .pin_reg_offset = DT_PROP_BY_IDX(node_id, pinmux, 0), \ + .func_num = DT_PROP_BY_IDX(node_id, pinmux, 1) \ + }, + +#define Z_PINCTRL_STATE_PIN_INIT(node_id, prop, idx) \ + PHYTIUM_PD2308_DT_PIN(DT_PROP_BY_IDX(node_id, prop, idx)) + +#define Z_PINCTRL_STATE_PINS_INIT(node_id, prop) \ + { DT_FOREACH_PROP_ELEM(node_id, prop, Z_PINCTRL_STATE_PIN_INIT) } + +#ifdef __cplusplus +} +#endif + +#endif + -- Gitee From e5fc1e7e917f96d9ee0deeebb42fe52fb5067d22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E8=A1=8D?= Date: Fri, 11 Apr 2025 02:08:03 +0000 Subject: [PATCH 07/13] =?UTF-8?q?=E6=B7=BB=E5=8A=A0D2000,E2000D/Q,32?= =?UTF-8?q?=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- arch/arm/core/cortex_a_r/Kconfig | 19 ++ .../Kconfig.d2000_aarch32_demo | 18 ++ .../d2000_aarch32_demo/Kconfig.defconfig | 28 +++ boards/phytium/d2000_aarch32_demo/board.cmake | 1 + boards/phytium/d2000_aarch32_demo/board.yml | 6 + .../d2000_aarch32_demo/d2000_aarch32_demo.dts | 36 ++++ .../d2000_aarch32_demo_defconfig | 20 ++ .../e2000d_aarch32_demo/Kconfig.defconfig | 28 +++ .../Kconfig.e2000d_aarch32_demo | 18 ++ .../phytium/e2000d_aarch32_demo/board.cmake | 1 + boards/phytium/e2000d_aarch32_demo/board.yml | 5 + .../e2000d_aarch32_demo.dts | 48 +++++ .../e2000d_aarch32_demo_defconfig | 20 ++ .../e2000q_aarch32_demo/Kconfig.defconfig | 28 +++ .../Kconfig.e2000q_aarch32_demo | 18 ++ .../phytium/e2000q_aarch32_demo/board.cmake | 1 + boards/phytium/e2000q_aarch32_demo/board.yml | 5 + .../e2000q_aarch32_demo.dts | 49 +++++ .../e2000q_aarch32_demo_defconfig | 20 ++ cmake/gcc-m-cpu.cmake | 2 + dts/arm/phytium/d2000_aarch32.dtsi | 164 ++++++++++++++++ .../{e2000q.dtsi => e2000d_aarch32.dtsi} | 174 +++++++++-------- dts/arm/phytium/e2000q_aarch32.dtsi | 177 ++++++++++++++++++ samples/userspace/hello_world_user/prj.conf | 2 + soc/phytium/d2000_aarch32/CMakeLists.txt | 8 + soc/phytium/d2000_aarch32/Kconfig | 32 ++++ soc/phytium/d2000_aarch32/Kconfig.defconfig | 29 +++ soc/phytium/d2000_aarch32/Kconfig.soc | 24 +++ soc/phytium/d2000_aarch32/soc.c | 57 ++++++ soc/phytium/d2000_aarch32/soc.h | 22 +++ soc/phytium/d2000_aarch32/soc.yml | 5 + soc/phytium/e2000d_aarch32/CMakeLists.txt | 8 + soc/phytium/e2000d_aarch32/Kconfig | 31 +++ soc/phytium/e2000d_aarch32/Kconfig.defconfig | 29 +++ soc/phytium/e2000d_aarch32/Kconfig.soc | 24 +++ soc/phytium/e2000d_aarch32/soc.c | 57 ++++++ soc/phytium/e2000d_aarch32/soc.h | 22 +++ soc/phytium/e2000d_aarch32/soc.yml | 5 + soc/phytium/e2000q_aarch32/CMakeLists.txt | 8 + soc/phytium/e2000q_aarch32/Kconfig | 31 +++ soc/phytium/e2000q_aarch32/Kconfig.defconfig | 29 +++ soc/phytium/e2000q_aarch32/Kconfig.soc | 24 +++ soc/phytium/e2000q_aarch32/soc.c | 57 ++++++ soc/phytium/e2000q_aarch32/soc.h | 22 +++ soc/phytium/e2000q_aarch32/soc.yml | 5 + 45 files changed, 1339 insertions(+), 78 deletions(-) create mode 100644 boards/phytium/d2000_aarch32_demo/Kconfig.d2000_aarch32_demo create mode 100644 boards/phytium/d2000_aarch32_demo/Kconfig.defconfig create mode 100644 boards/phytium/d2000_aarch32_demo/board.cmake create mode 100644 boards/phytium/d2000_aarch32_demo/board.yml create mode 100644 boards/phytium/d2000_aarch32_demo/d2000_aarch32_demo.dts create mode 100644 boards/phytium/d2000_aarch32_demo/d2000_aarch32_demo_defconfig create mode 100644 boards/phytium/e2000d_aarch32_demo/Kconfig.defconfig create mode 100644 boards/phytium/e2000d_aarch32_demo/Kconfig.e2000d_aarch32_demo create mode 100644 boards/phytium/e2000d_aarch32_demo/board.cmake create mode 100644 boards/phytium/e2000d_aarch32_demo/board.yml create mode 100644 boards/phytium/e2000d_aarch32_demo/e2000d_aarch32_demo.dts create mode 100644 boards/phytium/e2000d_aarch32_demo/e2000d_aarch32_demo_defconfig create mode 100644 boards/phytium/e2000q_aarch32_demo/Kconfig.defconfig create mode 100644 boards/phytium/e2000q_aarch32_demo/Kconfig.e2000q_aarch32_demo create mode 100644 boards/phytium/e2000q_aarch32_demo/board.cmake create mode 100644 boards/phytium/e2000q_aarch32_demo/board.yml create mode 100644 boards/phytium/e2000q_aarch32_demo/e2000q_aarch32_demo.dts create mode 100644 boards/phytium/e2000q_aarch32_demo/e2000q_aarch32_demo_defconfig create mode 100644 dts/arm/phytium/d2000_aarch32.dtsi rename dts/arm/phytium/{e2000q.dtsi => e2000d_aarch32.dtsi} (50%) create mode 100644 dts/arm/phytium/e2000q_aarch32.dtsi create mode 100644 soc/phytium/d2000_aarch32/CMakeLists.txt create mode 100644 soc/phytium/d2000_aarch32/Kconfig create mode 100644 soc/phytium/d2000_aarch32/Kconfig.defconfig create mode 100644 soc/phytium/d2000_aarch32/Kconfig.soc create mode 100644 soc/phytium/d2000_aarch32/soc.c create mode 100644 soc/phytium/d2000_aarch32/soc.h create mode 100644 soc/phytium/d2000_aarch32/soc.yml create mode 100644 soc/phytium/e2000d_aarch32/CMakeLists.txt create mode 100644 soc/phytium/e2000d_aarch32/Kconfig create mode 100644 soc/phytium/e2000d_aarch32/Kconfig.defconfig create mode 100644 soc/phytium/e2000d_aarch32/Kconfig.soc create mode 100644 soc/phytium/e2000d_aarch32/soc.c create mode 100644 soc/phytium/e2000d_aarch32/soc.h create mode 100644 soc/phytium/e2000d_aarch32/soc.yml create mode 100644 soc/phytium/e2000q_aarch32/CMakeLists.txt create mode 100644 soc/phytium/e2000q_aarch32/Kconfig create mode 100644 soc/phytium/e2000q_aarch32/Kconfig.defconfig create mode 100644 soc/phytium/e2000q_aarch32/Kconfig.soc create mode 100644 soc/phytium/e2000q_aarch32/soc.c create mode 100644 soc/phytium/e2000q_aarch32/soc.h create mode 100644 soc/phytium/e2000q_aarch32/soc.yml diff --git a/arch/arm/core/cortex_a_r/Kconfig b/arch/arm/core/cortex_a_r/Kconfig index 3c8393e1e29..e5130af91e4 100644 --- a/arch/arm/core/cortex_a_r/Kconfig +++ b/arch/arm/core/cortex_a_r/Kconfig @@ -31,6 +31,25 @@ if CPU_PHYTIUM_FT310 endif +config CPU_PHYTIUM_FT663 + bool + select CPU_AARCH32_CORTEX_A + select CPU_AARCH32_ARMV8 + select CPU_HAS_ICACHE + select CPU_HAS_DCACHE + select ARMV7_A + help + This option signifies the use of a FT663 CPU. + +if CPU_PHYTIUM_FT663 + config AARCH64_2_AARCH32 + bool + help + Example Convert aarch64 to aarch32 + +endif + + config CPU_CORTEX_A9 bool select CPU_AARCH32_CORTEX_A diff --git a/boards/phytium/d2000_aarch32_demo/Kconfig.d2000_aarch32_demo b/boards/phytium/d2000_aarch32_demo/Kconfig.d2000_aarch32_demo new file mode 100644 index 00000000000..9c41344e237 --- /dev/null +++ b/boards/phytium/d2000_aarch32_demo/Kconfig.d2000_aarch32_demo @@ -0,0 +1,18 @@ +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +# +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# https://opensource.org/license/apache-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. + +config BOARD_D2000_AARCH32_DEMO + bool "phytium D2000 aarch32" + select SOC_D2000_AARCH32 \ No newline at end of file diff --git a/boards/phytium/d2000_aarch32_demo/Kconfig.defconfig b/boards/phytium/d2000_aarch32_demo/Kconfig.defconfig new file mode 100644 index 00000000000..d1a8a233290 --- /dev/null +++ b/boards/phytium/d2000_aarch32_demo/Kconfig.defconfig @@ -0,0 +1,28 @@ +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +# +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# https://opensource.org/license/apache-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. + + +config BOARD + default "Phytium d2000 aarch32 demo" + depends on BOARD_D2000_AARCH32_DEMO + +if NETWORKING + +config NET_L2_ETHERNET + default y + + + +endif # NETWORKING diff --git a/boards/phytium/d2000_aarch32_demo/board.cmake b/boards/phytium/d2000_aarch32_demo/board.cmake new file mode 100644 index 00000000000..9881313609a --- /dev/null +++ b/boards/phytium/d2000_aarch32_demo/board.cmake @@ -0,0 +1 @@ +# SPDX-License-Identifier: Apache-2.0 diff --git a/boards/phytium/d2000_aarch32_demo/board.yml b/boards/phytium/d2000_aarch32_demo/board.yml new file mode 100644 index 00000000000..3c959d9b142 --- /dev/null +++ b/boards/phytium/d2000_aarch32_demo/board.yml @@ -0,0 +1,6 @@ +board: + name: d2000_aarch32_demo + vendor: phytium + socs: + - name: d2000_aarch32 + diff --git a/boards/phytium/d2000_aarch32_demo/d2000_aarch32_demo.dts b/boards/phytium/d2000_aarch32_demo/d2000_aarch32_demo.dts new file mode 100644 index 00000000000..ab878ada57f --- /dev/null +++ b/boards/phytium/d2000_aarch32_demo/d2000_aarch32_demo.dts @@ -0,0 +1,36 @@ +/* + * Copyright 2024 zhangyan + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; +#include + +/ { + model = "Phytium d2000 demo"; + compatible = "phytium,d2000-demo", "phytium,d2000"; + #address-cells = <2>; + #size-cells = <2>; + +chosen { + zephyr,console = &uart1; + zephyr,shell-uart = &uart1; + zephyr,sram = &sram0; + }; +}; + +&gmac0 { + local-mac-address = [00 00 00 01 02 03]; + status = "okay"; +}; + +&uart1 { + current-speed = <115200>; + status = "okay"; +}; + +&uart2 { + current-speed = <115200>; + status = "okay"; +}; diff --git a/boards/phytium/d2000_aarch32_demo/d2000_aarch32_demo_defconfig b/boards/phytium/d2000_aarch32_demo/d2000_aarch32_demo_defconfig new file mode 100644 index 00000000000..c5ef03f680d --- /dev/null +++ b/boards/phytium/d2000_aarch32_demo/d2000_aarch32_demo_defconfig @@ -0,0 +1,20 @@ +CONFIG_SOC_D2000_AARCH32=y +CONFIG_BOARD_D2000_AARCH32_DEMO=y + + +# The GTC is always clocked at 1/2 of the CPU frequency (CPU_3x2x) +CONFIG_ARM_ARCH_TIMER=y +CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=50000000 + +#CONFIG_PINCTRL=y +CONFIG_SERIAL=y +CONFIG_CONSOLE=y +CONFIG_UART_CONSOLE=y + + +CONFIG_ARM_MMU_NUM_L2_TABLES=1024 + + +CONFIG_ARMV7_SYS_STACK_SIZE=8192 +# 主堆栈的大小 +CONFIG_MAIN_STACK_SIZE=8192 \ No newline at end of file diff --git a/boards/phytium/e2000d_aarch32_demo/Kconfig.defconfig b/boards/phytium/e2000d_aarch32_demo/Kconfig.defconfig new file mode 100644 index 00000000000..185d900eb3e --- /dev/null +++ b/boards/phytium/e2000d_aarch32_demo/Kconfig.defconfig @@ -0,0 +1,28 @@ +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +# +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# https://opensource.org/license/apache-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. + + +config BOARD + default "Phytium e2000d aarch32 demo" + depends on BOARD_E2000D_A32_DEMO + +if NETWORKING + +config NET_L2_ETHERNET + default y + + + +endif # NETWORKING diff --git a/boards/phytium/e2000d_aarch32_demo/Kconfig.e2000d_aarch32_demo b/boards/phytium/e2000d_aarch32_demo/Kconfig.e2000d_aarch32_demo new file mode 100644 index 00000000000..f8607de6e9e --- /dev/null +++ b/boards/phytium/e2000d_aarch32_demo/Kconfig.e2000d_aarch32_demo @@ -0,0 +1,18 @@ +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +# +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# https://opensource.org/license/apache-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. + +config BOARD_E2000D_AARCH32_DEMO + bool "phytium e2000d aarch32" + select SOC_E2000D_AARCH32 \ No newline at end of file diff --git a/boards/phytium/e2000d_aarch32_demo/board.cmake b/boards/phytium/e2000d_aarch32_demo/board.cmake new file mode 100644 index 00000000000..9881313609a --- /dev/null +++ b/boards/phytium/e2000d_aarch32_demo/board.cmake @@ -0,0 +1 @@ +# SPDX-License-Identifier: Apache-2.0 diff --git a/boards/phytium/e2000d_aarch32_demo/board.yml b/boards/phytium/e2000d_aarch32_demo/board.yml new file mode 100644 index 00000000000..e3e8513eea6 --- /dev/null +++ b/boards/phytium/e2000d_aarch32_demo/board.yml @@ -0,0 +1,5 @@ +board: + name: e2000d_aarch32_demo + vendor: phytium + socs: + - name: e2000d_aarch32 diff --git a/boards/phytium/e2000d_aarch32_demo/e2000d_aarch32_demo.dts b/boards/phytium/e2000d_aarch32_demo/e2000d_aarch32_demo.dts new file mode 100644 index 00000000000..ca935d4a675 --- /dev/null +++ b/boards/phytium/e2000d_aarch32_demo/e2000d_aarch32_demo.dts @@ -0,0 +1,48 @@ +/* + * Copyright 2024 zhangyan + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; +#include + +/ { + model = "Phytium e2000d aarch32 demo"; + compatible = "phytium,e2000d-demo", "phytium,e2000d"; + #address-cells = <2>; + #size-cells = <2>; + +chosen { + zephyr,console = &uart1; + zephyr,shell-uart = &uart1; + zephyr,sram = &sram0; + }; +}; + +&sdhc1 { + status = "okay"; + sdmmc { + compatible = "zephyr,sdmmc-disk"; + status = "okay"; + }; +}; + +&xmac0 { + status = "okay"; + local-mac-address = [00 00 00 01 02 03]; +}; + +&uart1 { + current-speed = <115200>; + status = "okay"; +}; + +&uart2 { + current-speed = <115200>; + status = "okay"; +}; + +&pcie0 { + status = "okay"; +}; \ No newline at end of file diff --git a/boards/phytium/e2000d_aarch32_demo/e2000d_aarch32_demo_defconfig b/boards/phytium/e2000d_aarch32_demo/e2000d_aarch32_demo_defconfig new file mode 100644 index 00000000000..78dc87bd8fb --- /dev/null +++ b/boards/phytium/e2000d_aarch32_demo/e2000d_aarch32_demo_defconfig @@ -0,0 +1,20 @@ +CONFIG_SOC_E2000D_AARCH32=y +CONFIG_BOARD_E2000D_AARCH32_DEMO=y + + +# The GTC is always clocked at 1/2 of the CPU frequency (CPU_3x2x) +CONFIG_ARM_ARCH_TIMER=y +CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=50000000 + +#CONFIG_PINCTRL=y +CONFIG_SERIAL=y +CONFIG_CONSOLE=y +CONFIG_UART_CONSOLE=y + + +CONFIG_ARM_MMU_NUM_L2_TABLES=1024 + + +CONFIG_ARMV7_SYS_STACK_SIZE=8192 +# 主堆栈的大小 +CONFIG_MAIN_STACK_SIZE=8192 \ No newline at end of file diff --git a/boards/phytium/e2000q_aarch32_demo/Kconfig.defconfig b/boards/phytium/e2000q_aarch32_demo/Kconfig.defconfig new file mode 100644 index 00000000000..cf6ae0db201 --- /dev/null +++ b/boards/phytium/e2000q_aarch32_demo/Kconfig.defconfig @@ -0,0 +1,28 @@ +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +# +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# https://opensource.org/license/apache-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. + + +config BOARD + default "Phytium e2000q aarch32 demo" + depends on BOARD_E2000Q_AARCH32_DEMO + +if NETWORKING + +config NET_L2_ETHERNET + default y + + + +endif # NETWORKING diff --git a/boards/phytium/e2000q_aarch32_demo/Kconfig.e2000q_aarch32_demo b/boards/phytium/e2000q_aarch32_demo/Kconfig.e2000q_aarch32_demo new file mode 100644 index 00000000000..4a6e2c812de --- /dev/null +++ b/boards/phytium/e2000q_aarch32_demo/Kconfig.e2000q_aarch32_demo @@ -0,0 +1,18 @@ +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +# +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# https://opensource.org/license/apache-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. + +config BOARD_E2000Q_AARCH32_DEMO + bool "phytium e2000q aarch32" + select SOC_E2000Q_AARCH32 \ No newline at end of file diff --git a/boards/phytium/e2000q_aarch32_demo/board.cmake b/boards/phytium/e2000q_aarch32_demo/board.cmake new file mode 100644 index 00000000000..9881313609a --- /dev/null +++ b/boards/phytium/e2000q_aarch32_demo/board.cmake @@ -0,0 +1 @@ +# SPDX-License-Identifier: Apache-2.0 diff --git a/boards/phytium/e2000q_aarch32_demo/board.yml b/boards/phytium/e2000q_aarch32_demo/board.yml new file mode 100644 index 00000000000..7b1ecd8cdab --- /dev/null +++ b/boards/phytium/e2000q_aarch32_demo/board.yml @@ -0,0 +1,5 @@ +board: + name: e2000q_aarch32_demo + vendor: phytium + socs: + - name: e2000q_aarch32 diff --git a/boards/phytium/e2000q_aarch32_demo/e2000q_aarch32_demo.dts b/boards/phytium/e2000q_aarch32_demo/e2000q_aarch32_demo.dts new file mode 100644 index 00000000000..e61fc533f3c --- /dev/null +++ b/boards/phytium/e2000q_aarch32_demo/e2000q_aarch32_demo.dts @@ -0,0 +1,49 @@ +/* + * Copyright 2024 zhangyan + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; +#include + +/ { + model = "Phytium e2000q demo"; + compatible = "phytium,e2000q-demo", "phytium,e2000q"; + #address-cells = <2>; + #size-cells = <2>; + +chosen { + zephyr,console = &uart1; + zephyr,shell-uart = &uart1; + zephyr,sram = &sram0; + zephyr,pcie-controller = &pcie0; + }; +}; + +&sdhc1 { + status = "okay"; + sdmmc { + compatible = "zephyr,sdmmc-disk"; + status = "okay"; + }; +}; + +&xmac0 { + status = "okay"; + local-mac-address = [00 00 00 01 02 03]; +}; + +&uart1 { + current-speed = <115200>; + status = "okay"; +}; + +&uart2 { + current-speed = <115200>; + status = "okay"; +}; + +&pcie0 { + status = "okay"; +}; diff --git a/boards/phytium/e2000q_aarch32_demo/e2000q_aarch32_demo_defconfig b/boards/phytium/e2000q_aarch32_demo/e2000q_aarch32_demo_defconfig new file mode 100644 index 00000000000..f667a09b182 --- /dev/null +++ b/boards/phytium/e2000q_aarch32_demo/e2000q_aarch32_demo_defconfig @@ -0,0 +1,20 @@ +CONFIG_SOC_E2000Q_AARCH32=y +CONFIG_BOARD_E2000Q_AARCH32_DEMO=y + + +# The GTC is always clocked at 1/2 of the CPU frequency (CPU_3x2x) +CONFIG_ARM_ARCH_TIMER=y +CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=50000000 + +#CONFIG_PINCTRL=y +CONFIG_SERIAL=y +CONFIG_CONSOLE=y +CONFIG_UART_CONSOLE=y + + +CONFIG_ARM_MMU_NUM_L2_TABLES=1024 + + +CONFIG_ARMV7_SYS_STACK_SIZE=8192 +# 主堆栈的大小 +CONFIG_MAIN_STACK_SIZE=8192 \ No newline at end of file diff --git a/cmake/gcc-m-cpu.cmake b/cmake/gcc-m-cpu.cmake index 307b8848f5f..18ce61c1a03 100644 --- a/cmake/gcc-m-cpu.cmake +++ b/cmake/gcc-m-cpu.cmake @@ -79,6 +79,8 @@ if("${ARCH}" STREQUAL "arm") set(GCC_M_CPU cortex-a9) elseif(CONFIG_CPU_PHYTIUM_FT310) set(GCC_M_CPU cortex-a9) + elseif(CONFIG_CPU_PHYTIUM_FT663) + set(GCC_M_CPU cortex-a9) else() message(FATAL_ERROR "Expected CONFIG_CPU_CORTEX_x to be defined") endif() diff --git a/dts/arm/phytium/d2000_aarch32.dtsi b/dts/arm/phytium/d2000_aarch32.dtsi new file mode 100644 index 00000000000..2bd1ee0c8d8 --- /dev/null +++ b/dts/arm/phytium/d2000_aarch32.dtsi @@ -0,0 +1,164 @@ +// Phytium is pleased to support the open source community by making Zephyr-SDK available. + +// +// Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +// +// Licensed under the Apache-2.0 License (the "License"); you may not use this file except +// in compliance with the License. You may obtain a copy of the License at +// +// https://opensource.org/license/apache-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 +#include +#include + +/ { + #address-cells = <2>; + #size-cells = <2>; + + cpus { + #address-cells = <2>; + #size-cells = <0>; + + cpu@0 { + device_type = "cpu"; + compatible = "phytium,ftc663"; + reg = <0 0x0>; + }; + + cpu@1 { + device_type = "cpu"; + compatible = "phytium,ftc663"; + reg = <0 0x1>; + }; + + cpu@2 { + device_type = "cpu"; + compatible = "phytium,ftc663"; + reg = <0 0x100>; + }; + + cpu@3 { + device_type = "cpu"; + compatible = "phytium,ftc663"; + reg = <0 0x101>; + }; + + cpu@4 { + device_type = "cpu"; + compatible = "phytium,ftc663"; + reg = <0 0x200>; + }; + + cpu@5 { + device_type = "cpu"; + compatible = "phytium,ftc663"; + reg = <0 0x201>; + }; + + cpu@6 { + device_type = "cpu"; + compatible = "phytium,ftc663"; + reg = <0 0x300>; + }; + + cpu@7 { + device_type = "cpu"; + compatible = "phytium,ftc663"; + reg = <0 0x301>; + }; + + }; + + timer { + compatible = "arm,armv8-timer"; + interrupt-parent = <&gic>; + // ppi =+ 16, 13 == 29 Security physical timer interrupt, 14 == 30 Non secure physical timer interrupt + interrupts = , + , + , + ; + }; + + uartclk: apb-pclk { + compatible = "fixed-clock"; + clock-frequency = <48000000>; + #clock-cells = <0>; + }; + + soc { + #address-cells = <2>; + #size-cells = <2>; + ranges; + + interrupt-parent = <&gic>; + + gic: interrupt-controller@29a00000 { + compatible = "arm,gic-v3", "arm,gic"; + reg = <0x00 0x29A00000 0x00 0x40000>, + <0x00 0x29B00000 0x00 0x100000>; + interrupt-controller; + #interrupt-cells = <4>; + status = "okay"; + #size-cells = <0x02>; + #address-cells = <0x02>; + }; + + uart1: uart@28001000 { + compatible = "arm,pl011"; + reg = <0x00 0x28001000 0x00 0x1000>; + status = "disabled"; + interrupts = ; + interrupt-names = "irq_0"; + clocks = <&uartclk>; + }; + + uart2: uart@28002000 { + compatible = "arm,pl011"; + reg = <0x00 0x28002000 0x00 0x1000>; + status = "disabled"; + interrupts = ; + interrupt-names = "irq_1"; + clocks = <&uartclk>; + }; + + gmac0: gmac@2820C000 { + compatible = "phytium,gmac"; + reg = <0x0 0x2820C000 0x0 0x4000>; + interrupts = ; + phy-poll-interval = <5000>; + phy-speed = <100>; + autonegotiation = <0>; + phy_duplex = <1>; + status = "disabled"; + }; + + pcie0: pcie@40000000 { + compatible = "pci-host-ecam-generic"; + device_type = "pci"; + reg = <0x00 0x40000000 0x00 0x10000000>; + #size-cells = <0x02>; + #address-cells = <0x03>; + ranges = <0x1000000 0x00 0x50000000 0x00 0x50000000 0x00 0x08000000 + 0x2000000 0x00 0x58000000 0x00 0x58000000 0x00 0x27ffffff + 0x3000000 0x10 0x00 0x10 0x00 0x1f 0xffffffff>; + bus-range = <0x00 0xff>; + }; + + /* 512MB DDR */ + sram0: memory@80100000 { + device_type = "memory"; + compatible = "mmio-sram"; + reg = <0x00 0x80100000 0x00 0x20000000>; + }; + }; +}; diff --git a/dts/arm/phytium/e2000q.dtsi b/dts/arm/phytium/e2000d_aarch32.dtsi similarity index 50% rename from dts/arm/phytium/e2000q.dtsi rename to dts/arm/phytium/e2000d_aarch32.dtsi index 5c28ddcc4fc..5dd03338fc4 100644 --- a/dts/arm/phytium/e2000q.dtsi +++ b/dts/arm/phytium/e2000d_aarch32.dtsi @@ -14,15 +14,17 @@ // specific language governing permissions and limitations under the License. #include -#include +#include #include - / { - cpus { - #address-cells = <2>; + #address-cells = <2>; + #size-cells = <2>; + + cpus { + #address-cells = <2>; #size-cells = <0>; - + cpu@0 { device_type = "cpu"; compatible = "phytium,ftc310"; @@ -35,58 +37,39 @@ reg = <0 0x201>; }; - cpu@2 { - device_type = "cpu"; - compatible = "phytium,ftc664"; - reg = <0 0>; - }; - - cpu@3 { - device_type = "cpu"; - compatible = "phytium,ftc664"; - reg = <0 0x100>; - }; - }; - + }; + timer { + compatible = "arm,armv8-timer"; + interrupt-parent = <&gic>; + // ppi =+ 16, 13 == 29 安全物理定时器中断, 14 == 30 非安全物理定时器中断 + interrupts = , + , + , + ; + }; - uartclk: apb-pclk { - compatible = "fixed-clock"; - clock-frequency = <100000000>; - #clock-cells = <0>; - }; + uartclk: apb-pclk { + compatible = "fixed-clock"; + clock-frequency = <100000000>; + #clock-cells = <0>; + }; soc { - interrupt-parent = <&gic>; - - timer { - compatible = "arm,armv8-timer"; - interrupt-parent = <&gic>; - // ppi =+ 16, 13 == 29 Security physical timer interrupt, 14 == 30 Non secure physical timer interrupt - interrupts = , - , - , - ; - }; + #address-cells = <2>; + #size-cells = <2>; + ranges; + interrupt-parent = <&gic>; - uart1: uart@2800d000 { - compatible = "arm,pl011"; - reg = <0x2800d000 0x1000>; - status = "disabled"; - interrupts = ; - interrupt-names = "irq_0"; - clocks = <&uartclk>; - }; - - gic: interrupt-controller@30800000 { + gic: interrupt-controller@30800000 { compatible = "arm,gic-v3", "arm,gic"; - reg = <0x30800000 0x40000>, - <0x30880000 0x80000>; + reg = <0x00 0x30800000 0x00 0x40000>, + <0x00 0x30880000 0x00 0x80000>; interrupt-controller; #interrupt-cells = <4>; status = "okay"; @@ -94,39 +77,33 @@ #address-cells = <0x02>; }; + pinctrl: pinctrl@32B30000 { + compatible = "phytium,pinctrl"; + reg = <0x00 0x32B30000 0x00 0x2000>; + status = "okay"; + }; - - sram0: memory@80100000 { - device_type = "memory"; - compatible = "mmio-sram"; - reg = <0x80100000 0x20000000>; - }; - - xmac0: xmac@3200C000 { - compatible = "phytium,xmac"; - reg = <0x3200C000 0x2000>; + uart1: uart@2800d000 { + compatible = "arm,pl011"; + reg = <0x00 0x2800d000 0x00 0x1000>; status = "disabled"; - interrupts = ; + interrupts = ; interrupt-names = "irq_0"; - phy-poll-interval = <1000>; - clock-frequency = <50000000> ; - phy-speed = <1000> ; - interface-mode = <0> ; - dma-brust-length = <16> ; - max-queue-num = <1> ; - rx-buffer-descriptors = <128>; - tx-buffer-descriptors = <32>; - rx-buffer-size = <1600>; - tx-buffer-size = <1600>; - phy-autonegotiation; - enable-fdx; - disable-reject-fcs-crc-errors ; - } ; + clocks = <&uartclk>; + }; + + uart2: uart@2800E000 { + compatible = "arm,pl011"; + reg = <0x00 0x2800E000 0x00 0x1000>; + status = "disabled"; + interrupts = ; + interrupt-names = "irq_1"; + clocks = <&uartclk>; + }; sdhc0: sdhc@28000000 { compatible = "phytium,sdhc"; - reg = <0x28000000 0x1000>; + reg = <0x00 0x28000000 0x00 0x1000>; status = "disabled"; interrupts = ; max-current-330 = <1020>; @@ -137,7 +114,7 @@ sdhc1: sdhc@28001000 { compatible = "phytium,sdhc"; - reg = <0x28001000 0x1000>; + reg = <0x00 0x28001000 0x00 0x1000>; status = "disabled"; interrupts = ; max-current-330 = <1020>; @@ -145,5 +122,46 @@ min-bus-freq = <400000>; }; + + xmac0: xmac@3200C000 { + compatible = "phytium,xmac"; + reg = <0x00 0x3200C000 0x00 0x2000>; + status = "disabled"; + interrupts = ; + interrupt-names = "irq_0"; + phy-poll-interval = <1000>; + clock-frequency = <50000000>; + phy-speed = <1000>; + interface-mode = <0>; + dma-brust-length = <16>; + max-queue-num = <1>; + rx-buffer-descriptors = <128>; + tx-buffer-descriptors = <32>; + rx-buffer-size = <1600>; + tx-buffer-size = <1600>; + phy-autonegotiation; + enable-fdx; + disable-reject-fcs-crc-errors; + }; + + pcie0: pcie@40000000 { + compatible = "pci-host-ecam-generic"; + device_type = "pci"; + reg = <0x00 0x40000000 0x00 0x10000000>; + #size-cells = <0x02>; + #address-cells = <0x03>; + ranges = <0x1000000 0x00 0x50000000 0x00 0x50000000 0x00 0x08000000 + 0x2000000 0x00 0x58000000 0x00 0x58000000 0x00 0x27ffffff + 0x3000000 0x10 0x00 0x10 0x00 0x1f 0xffffffff>; + bus-range = <0x00 0xff>; + }; + + /* 256MB DDR */ + sram0: memory@80100000 { + device_type = "memory"; + compatible = "mmio-sram"; + reg = <0x00 0x80100000 0x00 0x10000000>; + }; }; }; diff --git a/dts/arm/phytium/e2000q_aarch32.dtsi b/dts/arm/phytium/e2000q_aarch32.dtsi new file mode 100644 index 00000000000..5402fb38344 --- /dev/null +++ b/dts/arm/phytium/e2000q_aarch32.dtsi @@ -0,0 +1,177 @@ +// Phytium is pleased to support the open source community by making Zephyr-SDK available. + +// +// Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +// +// Licensed under the Apache-2.0 License (the "License"); you may not use this file except +// in compliance with the License. You may obtain a copy of the License at +// +// https://opensource.org/license/apache-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 +#include +#include + +/ { + #address-cells = <2>; + #size-cells = <2>; + + cpus { + #address-cells = <2>; + #size-cells = <0>; + + cpu@0 { + device_type = "cpu"; + compatible = "phytium,ftc310"; + reg = <0 0x200>; + }; + + cpu@1 { + device_type = "cpu"; + compatible = "phytium,ftc310"; + reg = <0 0x201>; + }; + + cpu@2 { + device_type = "cpu"; + compatible = "phytium,ftc664"; + reg = <0 0>; + }; + + cpu@3 { + device_type = "cpu"; + compatible = "phytium,ftc664"; + reg = <0 0x100>; + }; + + }; + + timer { + compatible = "arm,armv8-timer"; + interrupt-parent = <&gic>; + // ppi =+ 16, 13 == 29 Security physical timer interrupt, 14 == 30 Non secure physical timer interrupt + interrupts = , + , + , + ; + }; + + uartclk: apb-pclk { + compatible = "fixed-clock"; + clock-frequency = <100000000>; + #clock-cells = <0>; + }; + + soc { + #address-cells = <2>; + #size-cells = <2>; + ranges; + + interrupt-parent = <&gic>; + + gic: interrupt-controller@30800000 { + compatible = "arm,gic-v3", "arm,gic"; + reg = <0x00 0x30800000 0x00 0x40000>, + <0x00 0x30880000 0x00 0x80000>; + interrupt-controller; + #interrupt-cells = <4>; + status = "okay"; + #size-cells = <0x02>; + #address-cells = <0x02>; + }; + + pinctrl: pinctrl@32B30000 { + compatible = "phytium,pinctrl"; + reg = <0x00 0x32B30000 0x00 0x2000>; + status = "okay"; + }; + + uart1: uart@2800d000 { + compatible = "arm,pl011"; + reg = <0x00 0x2800d000 0x00 0x1000>; + status = "disabled"; + interrupts = ; + interrupt-names = "irq_0"; + clocks = <&uartclk>; + }; + + uart2: uart@2800E000 { + compatible = "arm,pl011"; + reg = <0x00 0x2800E000 0x00 0x1000>; + status = "disabled"; + interrupts = ; + interrupt-names = "irq_1"; + clocks = <&uartclk>; + }; + + sdhc0: sdhc@28000000 { + compatible = "phytium,sdhc"; + reg = <0x00 0x28000000 0x00 0x1000>; + status = "disabled"; + interrupts = ; + max-current-330 = <1020>; + max-bus-freq = <25000000>; + min-bus-freq = <400000>; + }; + + xmac0: xmac@3200C000 { + compatible = "phytium,xmac"; + reg = <0x00 0x3200C000 0x00 0x2000>; + status = "disabled"; + interrupts = ; + interrupt-names = "irq_0"; + phy-poll-interval = <5000>; + clock-frequency = <50000000>; + phy-speed = <1000>; + interface-mode = <0>; + dma-brust-length = <16>; + max-queue-num = <1>; + rx-buffer-descriptors = <128>; + tx-buffer-descriptors = <128>; + rx-buffer-size = <1600>; + tx-buffer-size = <1600>; + phy-autonegotiation; + enable-fdx; + disable-reject-fcs-crc-errors; + }; + + sdhc1: sdhc@28001000 { + compatible = "phytium,sdhc"; + reg = <0x00 0x28001000 0x00 0x1000>; + status = "disabled"; + interrupts = ; + max-current-330 = <1020>; + max-bus-freq = <25000000>; + min-bus-freq = <400000>; + }; + + /* 512MB DDR */ + sram0: memory@80100000 { + device_type = "memory"; + compatible = "mmio-sram"; + reg = <0x00 0x80100000 0x00 0x20000000>; + }; + + pcie0: pcie@40000000 { + compatible = "pci-host-ecam-generic"; + device_type = "pci"; + reg = <0x00 0x40000000 0x00 0x10000000>; + #size-cells = <0x02>; + #address-cells = <0x03>; + ranges = <0x1000000 0x00 0x50000000 0x00 0x50000000 0x00 0x08000000 + 0x2000000 0x00 0x58000000 0x00 0x58000000 0x00 0x27ffffff + 0x3000000 0x10 0x00 0x10 0x00 0x1f 0xffffffff>; + bus-range = <0x00 0xff>; + }; + }; +}; diff --git a/samples/userspace/hello_world_user/prj.conf b/samples/userspace/hello_world_user/prj.conf index 7de714c1418..c4bfc740a08 100644 --- a/samples/userspace/hello_world_user/prj.conf +++ b/samples/userspace/hello_world_user/prj.conf @@ -1,2 +1,4 @@ + + CONFIG_USERSPACE=y CONFIG_ASSERT=y diff --git a/soc/phytium/d2000_aarch32/CMakeLists.txt b/soc/phytium/d2000_aarch32/CMakeLists.txt new file mode 100644 index 00000000000..3abcd5f07af --- /dev/null +++ b/soc/phytium/d2000_aarch32/CMakeLists.txt @@ -0,0 +1,8 @@ +# Copyright (c) 2024 zhangyan +# SPDX-License-Identifier: Apache-2.0 + +zephyr_sources(soc.c) + +zephyr_include_directories(.) + +set(SOC_LINKER_SCRIPT ${ZEPHYR_BASE}/include/zephyr/arch/arm/cortex_a_r/scripts/linker.ld CACHE INTERNAL "") diff --git a/soc/phytium/d2000_aarch32/Kconfig b/soc/phytium/d2000_aarch32/Kconfig new file mode 100644 index 00000000000..d5c0f47b00f --- /dev/null +++ b/soc/phytium/d2000_aarch32/Kconfig @@ -0,0 +1,32 @@ + +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +# +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# https://opensource.org/license/apache-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. + +config SOC_D2000_AARCH32 + bool "Phytium D2000 Soc series" + select SOC_FAMILY_PHYTIUM_D2000 + select ARM + select CPU_PHYTIUM_FT663 + select PLATFORM_SPECIFIC_INIT + select GIC_SINGLE_SECURITY_STATE + select CACHE_MANAGEMENT + select AARCH64_2_AARCH32 + select PHYTIUM_STANDALONE_SDK + select PHYTIUM_SOFT + #select CPU_HAS_FPU + select VFP_DP_D16 + help + Enable support for the Phytium d2000 + SoC series (8-core Armv8 cpu). \ No newline at end of file diff --git a/soc/phytium/d2000_aarch32/Kconfig.defconfig b/soc/phytium/d2000_aarch32/Kconfig.defconfig new file mode 100644 index 00000000000..e8c7faae68a --- /dev/null +++ b/soc/phytium/d2000_aarch32/Kconfig.defconfig @@ -0,0 +1,29 @@ +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. + +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at + +# https://opensource.org/license/apache-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. + +if SOC_D2000_AARCH32 + +config SOC + default "d2000_aarch32" + +config NUM_IRQS + int + default 159 + +config SYS_CLOCK_HW_CYCLES_PER_SEC + int + default 48000000 + +endif diff --git a/soc/phytium/d2000_aarch32/Kconfig.soc b/soc/phytium/d2000_aarch32/Kconfig.soc new file mode 100644 index 00000000000..cbae6004e1f --- /dev/null +++ b/soc/phytium/d2000_aarch32/Kconfig.soc @@ -0,0 +1,24 @@ +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. + +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at + +# https://opensource.org/license/apache-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. + +config SOC_D2000_AARCH32 + bool "d2000_aarch32" + select SOC_FAMILY_ARM + +if SOC_D2000_AARCH32 +config HAL_STANDALONE_SDK_DEBUG + bool "standalone_sdk_debug" + +endif \ No newline at end of file diff --git a/soc/phytium/d2000_aarch32/soc.c b/soc/phytium/d2000_aarch32/soc.c new file mode 100644 index 00000000000..bbb92f33a94 --- /dev/null +++ b/soc/phytium/d2000_aarch32/soc.c @@ -0,0 +1,57 @@ +// Phytium is pleased to support the open source community by making Zephyr-SDK available. + +// +// Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +// +// Licensed under the Apache-2.0 License (the "License"); you may not use this file except +// in compliance with the License. You may obtain a copy of the License at +// +// https://opensource.org/license/apache-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 +#include +#include +extern void *_vector_table[]; + + +static const struct arm_mmu_region mmu_regions[] = { + MMU_REGION_FLAT_ENTRY("GIC", + DT_REG_ADDR_BY_IDX(DT_INST(0, arm_gic), 0), + DT_REG_SIZE_BY_IDX(DT_INST(0, arm_gic), 0), + MT_DEVICE | MATTR_SHARED | MPERM_R | MPERM_W), + + MMU_REGION_FLAT_ENTRY("GIC", + DT_REG_ADDR_BY_IDX(DT_INST(0, arm_gic), 1), + DT_REG_SIZE_BY_IDX(DT_INST(0, arm_gic), 1), + MT_DEVICE | MATTR_SHARED | MPERM_R | MPERM_W), + +}; + +const struct arm_mmu_config mmu_config = { + .num_regions = ARRAY_SIZE(mmu_regions), + .mmu_regions = mmu_regions, +}; + + +void z_arm_platform_init(void) +{ + /* + * Use normal exception vectors address range (0x0-0x1C). + */ + unsigned int sctlr; + + __set_VBAR((uintptr_t)_vector_table); + + sctlr = 0; + __set_SCTLR(sctlr); +} + +void relocate_vector_table(void) +{ + +} \ No newline at end of file diff --git a/soc/phytium/d2000_aarch32/soc.h b/soc/phytium/d2000_aarch32/soc.h new file mode 100644 index 00000000000..23e4823671e --- /dev/null +++ b/soc/phytium/d2000_aarch32/soc.h @@ -0,0 +1,22 @@ +// Phytium is pleased to support the open source community by making Zephyr-SDK available. + +// +// Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +// +// Licensed under the Apache-2.0 License (the "License"); you may not use this file except +// in compliance with the License. You may obtain a copy of the License at +// +// https://opensource.org/license/apache-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 _BOARD__H_ +#define _BOARD__H_ + +/* Define CMSIS configurations */ +#define __GIC_PRESENT 0 +#define __TIM_PRESENT 0 +#endif /* _BOARD__H_ */ \ No newline at end of file diff --git a/soc/phytium/d2000_aarch32/soc.yml b/soc/phytium/d2000_aarch32/soc.yml new file mode 100644 index 00000000000..fc032adf16c --- /dev/null +++ b/soc/phytium/d2000_aarch32/soc.yml @@ -0,0 +1,5 @@ +family: + +- name: arm + socs: + - name: d2000_aarch32 diff --git a/soc/phytium/e2000d_aarch32/CMakeLists.txt b/soc/phytium/e2000d_aarch32/CMakeLists.txt new file mode 100644 index 00000000000..3abcd5f07af --- /dev/null +++ b/soc/phytium/e2000d_aarch32/CMakeLists.txt @@ -0,0 +1,8 @@ +# Copyright (c) 2024 zhangyan +# SPDX-License-Identifier: Apache-2.0 + +zephyr_sources(soc.c) + +zephyr_include_directories(.) + +set(SOC_LINKER_SCRIPT ${ZEPHYR_BASE}/include/zephyr/arch/arm/cortex_a_r/scripts/linker.ld CACHE INTERNAL "") diff --git a/soc/phytium/e2000d_aarch32/Kconfig b/soc/phytium/e2000d_aarch32/Kconfig new file mode 100644 index 00000000000..40489f08275 --- /dev/null +++ b/soc/phytium/e2000d_aarch32/Kconfig @@ -0,0 +1,31 @@ + +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +# +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# https://opensource.org/license/apache-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. + +config SOC_E2000Q_AARCH32 + bool "Phytium E2000 Soc series" + select ARM + select CPU_PHYTIUM_FT310 + select PLATFORM_SPECIFIC_INIT + select GIC_SINGLE_SECURITY_STATE + select CACHE_MANAGEMENT + select AARCH64_2_AARCH32 + select PHYTIUM_STANDALONE_SDK + select PHYTIUM_SOFT + #select CPU_HAS_FPU + select VFP_DP_D16 + help + Enable support for the Phytium e2000q + SoC series (4-core Armv8 cpu). \ No newline at end of file diff --git a/soc/phytium/e2000d_aarch32/Kconfig.defconfig b/soc/phytium/e2000d_aarch32/Kconfig.defconfig new file mode 100644 index 00000000000..440afdca7cb --- /dev/null +++ b/soc/phytium/e2000d_aarch32/Kconfig.defconfig @@ -0,0 +1,29 @@ +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. + +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at + +# https://opensource.org/license/apache-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. + +if SOC_E2000Q_AARCH32 + +config SOC + default "e2000q_aarch32" + +config NUM_IRQS + int + default 266 + +config SYS_CLOCK_HW_CYCLES_PER_SEC + int + default 50000000 + +endif diff --git a/soc/phytium/e2000d_aarch32/Kconfig.soc b/soc/phytium/e2000d_aarch32/Kconfig.soc new file mode 100644 index 00000000000..43040d8719c --- /dev/null +++ b/soc/phytium/e2000d_aarch32/Kconfig.soc @@ -0,0 +1,24 @@ +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. + +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at + +# https://opensource.org/license/apache-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. + +config SOC_E2000Q_AARCH32 + bool "e2000q_aarch32" + select SOC_FAMILY_ARM + +if SOC_E2000Q_AARCH32 +config HAL_STANDALONE_SDK_DEBUG + bool "standalone_sdk_debug" + +endif \ No newline at end of file diff --git a/soc/phytium/e2000d_aarch32/soc.c b/soc/phytium/e2000d_aarch32/soc.c new file mode 100644 index 00000000000..bbb92f33a94 --- /dev/null +++ b/soc/phytium/e2000d_aarch32/soc.c @@ -0,0 +1,57 @@ +// Phytium is pleased to support the open source community by making Zephyr-SDK available. + +// +// Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +// +// Licensed under the Apache-2.0 License (the "License"); you may not use this file except +// in compliance with the License. You may obtain a copy of the License at +// +// https://opensource.org/license/apache-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 +#include +#include +extern void *_vector_table[]; + + +static const struct arm_mmu_region mmu_regions[] = { + MMU_REGION_FLAT_ENTRY("GIC", + DT_REG_ADDR_BY_IDX(DT_INST(0, arm_gic), 0), + DT_REG_SIZE_BY_IDX(DT_INST(0, arm_gic), 0), + MT_DEVICE | MATTR_SHARED | MPERM_R | MPERM_W), + + MMU_REGION_FLAT_ENTRY("GIC", + DT_REG_ADDR_BY_IDX(DT_INST(0, arm_gic), 1), + DT_REG_SIZE_BY_IDX(DT_INST(0, arm_gic), 1), + MT_DEVICE | MATTR_SHARED | MPERM_R | MPERM_W), + +}; + +const struct arm_mmu_config mmu_config = { + .num_regions = ARRAY_SIZE(mmu_regions), + .mmu_regions = mmu_regions, +}; + + +void z_arm_platform_init(void) +{ + /* + * Use normal exception vectors address range (0x0-0x1C). + */ + unsigned int sctlr; + + __set_VBAR((uintptr_t)_vector_table); + + sctlr = 0; + __set_SCTLR(sctlr); +} + +void relocate_vector_table(void) +{ + +} \ No newline at end of file diff --git a/soc/phytium/e2000d_aarch32/soc.h b/soc/phytium/e2000d_aarch32/soc.h new file mode 100644 index 00000000000..23e4823671e --- /dev/null +++ b/soc/phytium/e2000d_aarch32/soc.h @@ -0,0 +1,22 @@ +// Phytium is pleased to support the open source community by making Zephyr-SDK available. + +// +// Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +// +// Licensed under the Apache-2.0 License (the "License"); you may not use this file except +// in compliance with the License. You may obtain a copy of the License at +// +// https://opensource.org/license/apache-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 _BOARD__H_ +#define _BOARD__H_ + +/* Define CMSIS configurations */ +#define __GIC_PRESENT 0 +#define __TIM_PRESENT 0 +#endif /* _BOARD__H_ */ \ No newline at end of file diff --git a/soc/phytium/e2000d_aarch32/soc.yml b/soc/phytium/e2000d_aarch32/soc.yml new file mode 100644 index 00000000000..917a5a2fec0 --- /dev/null +++ b/soc/phytium/e2000d_aarch32/soc.yml @@ -0,0 +1,5 @@ +family: + +- name: arm + socs: + - name: e2000q_aarch32 diff --git a/soc/phytium/e2000q_aarch32/CMakeLists.txt b/soc/phytium/e2000q_aarch32/CMakeLists.txt new file mode 100644 index 00000000000..3abcd5f07af --- /dev/null +++ b/soc/phytium/e2000q_aarch32/CMakeLists.txt @@ -0,0 +1,8 @@ +# Copyright (c) 2024 zhangyan +# SPDX-License-Identifier: Apache-2.0 + +zephyr_sources(soc.c) + +zephyr_include_directories(.) + +set(SOC_LINKER_SCRIPT ${ZEPHYR_BASE}/include/zephyr/arch/arm/cortex_a_r/scripts/linker.ld CACHE INTERNAL "") diff --git a/soc/phytium/e2000q_aarch32/Kconfig b/soc/phytium/e2000q_aarch32/Kconfig new file mode 100644 index 00000000000..f6bc09fb14d --- /dev/null +++ b/soc/phytium/e2000q_aarch32/Kconfig @@ -0,0 +1,31 @@ + +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +# +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# https://opensource.org/license/apache-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. + +config SOC_E2000D_AARCH32 + bool "Phytium E2000 Soc series" + select ARM + select CPU_PHYTIUM_FT310 + select PLATFORM_SPECIFIC_INIT + select GIC_SINGLE_SECURITY_STATE + select CACHE_MANAGEMENT + select AARCH64_2_AARCH32 + select PHYTIUM_STANDALONE_SDK + select PHYTIUM_SOFT + #select CPU_HAS_FPU + select VFP_DP_D16 + help + Enable support for the Phytium e2000d + SoC series (4-core Armv8 cpu). \ No newline at end of file diff --git a/soc/phytium/e2000q_aarch32/Kconfig.defconfig b/soc/phytium/e2000q_aarch32/Kconfig.defconfig new file mode 100644 index 00000000000..7e4a3ece87b --- /dev/null +++ b/soc/phytium/e2000q_aarch32/Kconfig.defconfig @@ -0,0 +1,29 @@ +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. + +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at + +# https://opensource.org/license/apache-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. + +if SOC_E2000D_AARCH32 + +config SOC + default "e2000d_aarch32" + +config NUM_IRQS + int + default 266 + +config SYS_CLOCK_HW_CYCLES_PER_SEC + int + default 50000000 + +endif diff --git a/soc/phytium/e2000q_aarch32/Kconfig.soc b/soc/phytium/e2000q_aarch32/Kconfig.soc new file mode 100644 index 00000000000..67ba4584aca --- /dev/null +++ b/soc/phytium/e2000q_aarch32/Kconfig.soc @@ -0,0 +1,24 @@ +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. + +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at + +# https://opensource.org/license/apache-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. + +config SOC_E2000D_AARCH32 + bool "e2000d_aarch32" + select SOC_FAMILY_ARM + +if SOC_E2000D_AARCH32 +config HAL_STANDALONE_SDK_DEBUG + bool "standalone_sdk_debug" + +endif \ No newline at end of file diff --git a/soc/phytium/e2000q_aarch32/soc.c b/soc/phytium/e2000q_aarch32/soc.c new file mode 100644 index 00000000000..bbb92f33a94 --- /dev/null +++ b/soc/phytium/e2000q_aarch32/soc.c @@ -0,0 +1,57 @@ +// Phytium is pleased to support the open source community by making Zephyr-SDK available. + +// +// Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +// +// Licensed under the Apache-2.0 License (the "License"); you may not use this file except +// in compliance with the License. You may obtain a copy of the License at +// +// https://opensource.org/license/apache-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 +#include +#include +extern void *_vector_table[]; + + +static const struct arm_mmu_region mmu_regions[] = { + MMU_REGION_FLAT_ENTRY("GIC", + DT_REG_ADDR_BY_IDX(DT_INST(0, arm_gic), 0), + DT_REG_SIZE_BY_IDX(DT_INST(0, arm_gic), 0), + MT_DEVICE | MATTR_SHARED | MPERM_R | MPERM_W), + + MMU_REGION_FLAT_ENTRY("GIC", + DT_REG_ADDR_BY_IDX(DT_INST(0, arm_gic), 1), + DT_REG_SIZE_BY_IDX(DT_INST(0, arm_gic), 1), + MT_DEVICE | MATTR_SHARED | MPERM_R | MPERM_W), + +}; + +const struct arm_mmu_config mmu_config = { + .num_regions = ARRAY_SIZE(mmu_regions), + .mmu_regions = mmu_regions, +}; + + +void z_arm_platform_init(void) +{ + /* + * Use normal exception vectors address range (0x0-0x1C). + */ + unsigned int sctlr; + + __set_VBAR((uintptr_t)_vector_table); + + sctlr = 0; + __set_SCTLR(sctlr); +} + +void relocate_vector_table(void) +{ + +} \ No newline at end of file diff --git a/soc/phytium/e2000q_aarch32/soc.h b/soc/phytium/e2000q_aarch32/soc.h new file mode 100644 index 00000000000..23e4823671e --- /dev/null +++ b/soc/phytium/e2000q_aarch32/soc.h @@ -0,0 +1,22 @@ +// Phytium is pleased to support the open source community by making Zephyr-SDK available. + +// +// Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +// +// Licensed under the Apache-2.0 License (the "License"); you may not use this file except +// in compliance with the License. You may obtain a copy of the License at +// +// https://opensource.org/license/apache-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 _BOARD__H_ +#define _BOARD__H_ + +/* Define CMSIS configurations */ +#define __GIC_PRESENT 0 +#define __TIM_PRESENT 0 +#endif /* _BOARD__H_ */ \ No newline at end of file diff --git a/soc/phytium/e2000q_aarch32/soc.yml b/soc/phytium/e2000q_aarch32/soc.yml new file mode 100644 index 00000000000..c6dc628728e --- /dev/null +++ b/soc/phytium/e2000q_aarch32/soc.yml @@ -0,0 +1,5 @@ +family: + +- name: arm + socs: + - name: e2000d_aarch32 -- Gitee From 10c0316d2356235ed78e207b28f452abf506d127 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E8=A1=8D?= Date: Fri, 13 Jun 2025 01:14:44 +0000 Subject: [PATCH 08/13] =?UTF-8?q?=E6=B7=BB=E5=8A=A0PD2308=20uart=20?= =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96=E5=A4=8D=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- boards/phytium/pd2308_demo/pd2308_demo.dts | 3 +++ .../phytium/pd2308_demo/pd2308_demo_pd2308_el2.dts | 3 +++ .../pd2308_demo/pd2308_demo_pd2308_el2_smp.dts | 3 +++ .../phytium/pd2308_demo/pd2308_demo_pd2308_smp.dts | 6 +++++- boards/phytium/pd2308_demo/pd2308_pinctrl.dtsi | 12 ++++++++++++ 5 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 boards/phytium/pd2308_demo/pd2308_pinctrl.dtsi diff --git a/boards/phytium/pd2308_demo/pd2308_demo.dts b/boards/phytium/pd2308_demo/pd2308_demo.dts index 279fb1e984c..6204d8b94e4 100644 --- a/boards/phytium/pd2308_demo/pd2308_demo.dts +++ b/boards/phytium/pd2308_demo/pd2308_demo.dts @@ -6,6 +6,7 @@ /dts-v1/; #include +#include "pd2308_pinctrl.dtsi" / { model = "Phytium pd2308 demo"; @@ -36,6 +37,8 @@ chosen { &uart1 { current-speed = <115200>; + pinctrl-0 = <&uart1_rx_default &uart1_tx_default>; + pinctrl-names = "default"; status = "okay"; }; diff --git a/boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2.dts b/boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2.dts index 279fb1e984c..6204d8b94e4 100644 --- a/boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2.dts +++ b/boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2.dts @@ -6,6 +6,7 @@ /dts-v1/; #include +#include "pd2308_pinctrl.dtsi" / { model = "Phytium pd2308 demo"; @@ -36,6 +37,8 @@ chosen { &uart1 { current-speed = <115200>; + pinctrl-0 = <&uart1_rx_default &uart1_tx_default>; + pinctrl-names = "default"; status = "okay"; }; diff --git a/boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2_smp.dts b/boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2_smp.dts index 279fb1e984c..6204d8b94e4 100644 --- a/boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2_smp.dts +++ b/boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2_smp.dts @@ -6,6 +6,7 @@ /dts-v1/; #include +#include "pd2308_pinctrl.dtsi" / { model = "Phytium pd2308 demo"; @@ -36,6 +37,8 @@ chosen { &uart1 { current-speed = <115200>; + pinctrl-0 = <&uart1_rx_default &uart1_tx_default>; + pinctrl-names = "default"; status = "okay"; }; diff --git a/boards/phytium/pd2308_demo/pd2308_demo_pd2308_smp.dts b/boards/phytium/pd2308_demo/pd2308_demo_pd2308_smp.dts index bbd49704488..5ee587b1fa1 100644 --- a/boards/phytium/pd2308_demo/pd2308_demo_pd2308_smp.dts +++ b/boards/phytium/pd2308_demo/pd2308_demo_pd2308_smp.dts @@ -7,6 +7,8 @@ /dts-v1/; #include +#include "pd2308_pinctrl.dtsi" + / { model = "Phytium pd2308 demo"; compatible = "phytium,pd2308-demo", "phytium,pd2308"; @@ -40,8 +42,10 @@ chosen { }; &uart1 { - status = "okay"; current-speed = <115200>; + pinctrl-0 = <&uart1_rx_default &uart1_tx_default>; + pinctrl-names = "default"; + status = "okay"; }; &pcie0 { diff --git a/boards/phytium/pd2308_demo/pd2308_pinctrl.dtsi b/boards/phytium/pd2308_demo/pd2308_pinctrl.dtsi new file mode 100644 index 00000000000..7f69aa2ec98 --- /dev/null +++ b/boards/phytium/pd2308_demo/pd2308_pinctrl.dtsi @@ -0,0 +1,12 @@ + + +#include + +&pinctrl { + uart1_rx_default: uart1_rx_default { + pinmux = ; + }; + uart1_tx_default: uart1_tx_default { + pinmux = ; + }; +}; \ No newline at end of file -- Gitee From 9794eec451ce8639bf666a832a697dab9ccc0959 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E8=80=BF=E5=AE=87?= Date: Mon, 30 Jun 2025 06:16:30 +0000 Subject: [PATCH 09/13] =?UTF-8?q?Zephyr=20=E5=86=85=E6=A0=B8=E9=80=82?= =?UTF-8?q?=E9=85=8D=20SDIF=20=E9=A9=B1=E5=8A=A8=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- boards/phytium/e2000d_demo/e2000d_demo.dts | 8 + boards/phytium/e2000q_demo/e2000q_demo.dts | 8 + boards/phytium/pd2308_demo/pd2308_demo.dts | 2 +- drivers/sdhc/phytium_sdhc.c | 627 ++++++--------------- dts/arm64/phytium/e2000d.dtsi | 7 +- dts/arm64/phytium/e2000q.dtsi | 25 +- dts/arm64/phytium/pd2308.dtsi | 3 +- dts/bindings/sdhc/phytium,sdhc.yaml | 9 +- 8 files changed, 230 insertions(+), 459 deletions(-) diff --git a/boards/phytium/e2000d_demo/e2000d_demo.dts b/boards/phytium/e2000d_demo/e2000d_demo.dts index 6bed72d828f..e527c8d3e5d 100644 --- a/boards/phytium/e2000d_demo/e2000d_demo.dts +++ b/boards/phytium/e2000d_demo/e2000d_demo.dts @@ -20,6 +20,14 @@ chosen { }; }; +&sdhc0 { + status = "okay"; + emmc { + compatible = "zephyr,emmc-disk"; + status = "okay"; + }; +}; + &sdhc1 { status = "okay"; sdmmc { diff --git a/boards/phytium/e2000q_demo/e2000q_demo.dts b/boards/phytium/e2000q_demo/e2000q_demo.dts index 50dfaa539bc..fa1f8c82355 100644 --- a/boards/phytium/e2000q_demo/e2000q_demo.dts +++ b/boards/phytium/e2000q_demo/e2000q_demo.dts @@ -22,6 +22,14 @@ chosen { }; }; +&sdhc0 { + status = "okay"; + emmc { + compatible = "zephyr,emmc-disk"; + status = "okay"; + }; +}; + &sdhc1 { status = "okay"; sdmmc { diff --git a/boards/phytium/pd2308_demo/pd2308_demo.dts b/boards/phytium/pd2308_demo/pd2308_demo.dts index 6204d8b94e4..44daa234029 100644 --- a/boards/phytium/pd2308_demo/pd2308_demo.dts +++ b/boards/phytium/pd2308_demo/pd2308_demo.dts @@ -22,7 +22,7 @@ chosen { }; }; -&sdhc1 { +&sdhc0 { status = "okay"; sdmmc { compatible = "zephyr,sdmmc-disk"; diff --git a/drivers/sdhc/phytium_sdhc.c b/drivers/sdhc/phytium_sdhc.c index 348c340f171..52dd3a4387d 100644 --- a/drivers/sdhc/phytium_sdhc.c +++ b/drivers/sdhc/phytium_sdhc.c @@ -40,56 +40,32 @@ LOG_MODULE_REGISTER(sdhc, CONFIG_SDHC_LOG_LEVEL); #define FSDIF_IRQ_CMD_BIT_MASK (FSDIF_IRQ_BIT_CMD_DONE|FSDIF_IRQ_BIT_ERROR_OCCUR) #define FSDIF_IRQ_DATA_BIT_MASK (FSDIF_IRQ_BIT_CMD_DONE|FSDIF_IRQ_BIT_DATA_DONE|FSDIF_IRQ_BIT_ERROR_OCCUR) -typedef enum -{ - FSDIF_CLK_SPEED_400KHZ_IDX = 0, - FSDIF_CLK_SPEED_25_MHZ_IDX , - FSDIF_CLK_SPEED_26_MHZ_IDX , - FSDIF_CLK_SPEED_50_MHZ_IDX , - FSDIF_CLK_SPEED_52_MHZ_IDX , - FSDIF_CLK_SPEED_100_MHZ_IDX , - FSDIF_CLK_SPEED_200_MHZ_IDX , - FSDIF_CLK_SPEED_NUM -} sdhc_speed_mod ; - -typedef struct -{ - boolean use_hold; /* 1: CMD[29] = 1, equal to add one sampling time delay */ - uint32_t clk_div; /* for reg 0x8 */ - uint32_t clk_src; /* for reg 0x108 */ - uint32_t shift; /* for reg 0x110 */ -} sdhc_static_timming ; - - - struct usdhc_config { DEVICE_MMIO_ROM; - const struct device *clock_dev; + uint32_t pio_id ; uint32_t pio_base ; uint32_t pio_length; uint32_t instance_id ; uint32_t is_enable_irq ; - uint32_t enable_dma ; - /* smaple timing data */ - sdhc_static_timming static_timming[FSDIF_CLK_SPEED_NUM] ; - bool detect_dat3; + bool no_180_vol; - uint32_t data_timeout; - uint32_t write_watermark; bool mmc_hs200_1_8v; bool mmc_hs400_1_8v; + bool non_removeable; + uint32_t max_bus_freq; + uint32_t min_bus_freq; void (*irq_config_func)(const struct device *dev); - }; struct usdhc_data { DEVICE_MMIO_RAM; struct sdhc_host_props props; + struct sdhc_io cur_ios; bool card_present; struct sdhc_io host_io; struct k_mutex access_mutex; -#ifdef CONFIG_PHYTIUM_USDHC_DMA_SUPPORT +#if CONFIG_PHYTIUM_USDHC_DMA_SUPPORT FSdifIDmaDesc *usdhc_dma_descriptor; /* ADMA descriptor table (noncachable) */ uint32_t dma_descriptor_len; /* DMA descriptor table length in words */ #endif @@ -98,59 +74,14 @@ struct usdhc_data { FSdif instance ; FSdifCmdData cmd_data ; FSdifData trans_data ; - u32 is_enable_dma ; struct k_event irq_event; /* include err、cmd、data event */ }; -typedef struct -{ - boolean use_hold; /* 1: CMD[29] = 1, equal to add one sampling time delay */ - u32 clk_div; /* for reg 0x8 */ - u32 clk_src; /* for reg 0x108 */ - u32 shift; /* for reg 0x110 */ - void (*pad_delay)(void *instance); /* method to adjust pad delay ,with args*/ -} fsdhc_timming; /* SDIF timing configuration */ - -#ifdef CONFIG_SOC_E2000Q -#define FSDIF_0_SD_CCLK_OUT_DELAY FIOPAD_AJ49_REG1_OFFSET -#define FSDIF_1_SD_CCLK_OUT_DELAY FIOPAD_J57_REG1_OFFSET -#elif defined (CONFIG_SOC_E2000D) -#define FSDIF_0_SD_CCLK_OUT_DELAY FIOPAD_AJ45_REG1_OFFSET -#define FSDIF_1_SD_CCLK_OUT_DELAY FIOPAD_J53_REG1_OFFSET -#elif defined (CONFIG_SOC_PD2308) -#define FSDIF_0_SD_CCLK_OUT_DELAY FIOPAD_BV65_REG1_OFFSET -#endif - -/** - * @name: FSdifUpdateExternalClk - * @msg: update uhs clock value and wait clock ready - * @return {FError} - * @param {uintptr} base_addr - * @param {u32} uhs_reg_val - */ -static FError FSdifUpdateExternalClk(uintptr base_addr, u32 uhs_reg_val) -{ - u32 reg_val; - int retries = FSDIF_TIMEOUT; - FSDIF_WRITE_REG(base_addr, FSDIF_CLK_SRC_OFFSET, 0U); - FSDIF_WRITE_REG(base_addr, FSDIF_CLK_SRC_OFFSET, uhs_reg_val); - - do - { - reg_val = FSDIF_READ_REG(base_addr, FSDIF_CKSTS_OFFSET); - if (--retries <= 0) - { - break; - } - } - while (!(reg_val & FSDIF_CLK_READY)); - - return (retries <= 0) ? FSDIF_ERR_TIMEOUT : FSDIF_SUCCESS; -} +static int card_polling_busy(const struct device *dev, int timeout_us); /* irq test */ -static void FSDIFHOST_CardDetected(FSdif *const instance_p, void *args, u32 status, u32 dmac_status) +static void phytium_sdhc_card_detect_handler(FSdif *const instance_p, void *args, u32 status, u32 dmac_status) { (void)instance_p; (void)status; @@ -158,7 +89,7 @@ static void FSDIFHOST_CardDetected(FSdif *const instance_p, void *args, u32 stat LOG_DBG("Card detected !!!"); } -static void FSDIFHOST_CmdDone(FSdif *const instance_p, void *args, u32 status, u32 dmac_status) +static void phytium_sdhc_command_done_handler(FSdif *const instance_p, void *args, u32 status, u32 dmac_status) { struct usdhc_data *data = (struct usdhc_data *)args; (void)instance_p; @@ -168,7 +99,7 @@ static void FSDIFHOST_CmdDone(FSdif *const instance_p, void *args, u32 status, u k_event_post(&data->irq_event,FSDIF_IRQ_BIT_CMD_DONE) ; } -static void FSDIFHOST_DataDone(FSdif *const instance_p, void *args, u32 status, u32 dmac_status) +static void phytium_sdhc_data_done_handler(FSdif *const instance_p, void *args, u32 status, u32 dmac_status) { struct usdhc_data *data = (struct usdhc_data *)args; @@ -193,7 +124,7 @@ static void FSDIFHOST_DataDone(FSdif *const instance_p, void *args, u32 status, } } -static void FSDIFHOST_ErrorOccur(FSdif *const instance_p, void *args, u32 status, u32 dmac_status) +static void phytium_sdhc_error_occurred_handler(FSdif *const instance_p, void *args, u32 status, u32 dmac_status) { struct usdhc_data *data = (struct usdhc_data *)args; LOG_ERR("Error occur !!!"); @@ -218,162 +149,6 @@ static void FSDIFHOST_ErrorOccur(FSdif *const instance_p, void *args, u32 status k_event_post(&data->irq_event,FSDIF_IRQ_BIT_CMD_DONE|FSDIF_IRQ_BIT_ERROR_OCCUR) ; } - - -static void FSdifSetSDIFDelay(void * instance) -{ - /* - for SD-0: 0x32b31120 = 0x1f00 - SD-1: 0x32b31178 = 0x1f00 - */ - FIOPadCtrl * iopad_ctrl = (FIOPadCtrl * )instance; - u32 reg; - - if (FSDIF0_ID == iopad_ctrl->config.instance_id) - { - reg = FSDIF_0_SD_CCLK_OUT_DELAY; - } - else - { -#if defined(CONFIG_SOC_E2000Q) || defined(CONFIG_SOC_E2000D) - reg = FSDIF_1_SD_CCLK_OUT_DELAY; -#endif - } - - FIOPadSetDelay(iopad_ctrl, reg, FIOPAD_OUTPUT_DELAY, FIOPAD_DELAY_COARSE_TUNING, FIOPAD_DELAY_1); - FIOPadSetDelay(iopad_ctrl, reg, FIOPAD_OUTPUT_DELAY, FIOPAD_DELAY_FINE_TUNING, FIOPAD_DELAY_7); - FIOPadSetDelayEn(iopad_ctrl, reg, FIOPAD_OUTPUT_DELAY, TRUE); -} - -static void FSdifUnsetSDIFDelay(void * instance) -{ - /* - for SD-0: 0x32b31120 = 0x0 - SD-1: 0x32b31178 = 0x0 - */ - FIOPadCtrl * iopad_ctrl = (FIOPadCtrl *)instance; - u32 reg; - - if (FSDIF0_ID == iopad_ctrl->config.instance_id) - { - reg = FSDIF_0_SD_CCLK_OUT_DELAY; - } - else - { -#if defined(CONFIG_SOC_E2000Q) || defined(CONFIG_SOC_E2000D) - reg = FSDIF_1_SD_CCLK_OUT_DELAY; -#endif - } - - FIOPadSetDelay(iopad_ctrl, reg, FIOPAD_OUTPUT_DELAY, FIOPAD_DELAY_COARSE_TUNING, FIOPAD_DELAY_NONE); - FIOPadSetDelay(iopad_ctrl, reg, FIOPAD_OUTPUT_DELAY, FIOPAD_DELAY_FINE_TUNING, FIOPAD_DELAY_NONE); - FIOPadSetDelayEn(iopad_ctrl, reg, FIOPAD_OUTPUT_DELAY, FALSE); -} - -/* default timing settings in e2000q demo board */ -static fsdhc_timming mmc_sd_400khz = -{ - .use_hold = 1, - .clk_div = 0x7e7dfa, - .clk_src = 0x000502, - .shift = 0x0, - .pad_delay = FSdifUnsetSDIFDelay, -}; - -static fsdhc_timming sd_25mhz = -{ - .use_hold = 1, - .clk_div = 0x030204, - .clk_src = 0x000302, - .shift = 0x0, - .pad_delay = FSdifUnsetSDIFDelay, -}; - -static fsdhc_timming sd_50mhz = -{ - .use_hold = 1, - .clk_div = 0x030204, - .clk_src = 0x000502, - .shift = 0x0, - .pad_delay = FSdifSetSDIFDelay -}; - -static fsdhc_timming sd_100mhz = -{ - .use_hold = 0, - .clk_div = 0x010002, - .clk_src = 0x000202, - .shift = 0x0, - .pad_delay = FSdifSetSDIFDelay, -}; - -static fsdhc_timming mmc_26mhz = -{ - .use_hold = 1, - .clk_div = 0x030204, - .clk_src = 0x000302, - .shift = 0x0, - .pad_delay = FSdifSetSDIFDelay, -}; - -static fsdhc_timming mmc_52mhz = -{ - .use_hold = 0, - .clk_div = 0x030204, - .clk_src = 0x000202, - .shift = 0x0, - .pad_delay = FSdifSetSDIFDelay, -}; - -const fsdhc_timming *fsdif_hc_get_timming(FSdifClkSpeed clock_freq, boolean non_removable) -{ - const fsdhc_timming * tuning = NULL; - - if (clock_freq == FSDIF_CLK_SPEED_400KHZ) - { - return &mmc_sd_400khz; - } - - if (non_removable) - { - /* for emmc card */ - switch (clock_freq) - { - case FSDIF_CLK_SPEED_26_MHZ: - tuning = &mmc_26mhz; - break; - case FSDIF_CLK_SPEED_52_MHZ: - tuning = &mmc_52mhz; - break; - /* TODO: more clock freq for tuning */ - default: - break; - } - } - else - { - /* for sd card */ - switch (clock_freq) - { - case FSDIF_CLK_SPEED_25_MHZ: - tuning = &sd_25mhz; - break; - case FSDIF_CLK_SPEED_50_MHZ: - tuning = &sd_50mhz; - break; - case FSDIF_CLK_SPEED_100_MHZ: - tuning = &sd_100mhz; - break; - /* TODO: more clock freq for tuning */ - default: - break; - } - } - - return tuning; -} - - /* * Reset USDHC controller */ @@ -382,139 +157,72 @@ static int phytium_sdhc_reset(const struct device *dev) struct usdhc_data *data = dev->data; FSdif *instance = &data->instance ; - return FSdifRestart(instance) == 0 ? 0 : -ETIMEDOUT; + return (FSdifRestart(instance) == FSDIF_SUCCESS) ? 0 : -ETIMEDOUT; } static int phytium_sdhc_set_io(const struct device *dev, struct sdhc_io *ios) { - struct usdhc_data *data = dev->data; - FSdif *instance = &data->instance ; - FIOPadCtrl *pin_ctrl = &data->iopad_ctrl ; - struct sdhc_io *host_io = &data->host_io; - const fsdhc_timming *target_timing; - u32 mci_cmd_bits = FSDIF_CMD_UPD_CLK; - FError ret ; - uint32_t cmd_reg; - uint32_t cur_cmd_index; - - LOG_DBG("SDHC I/O: bus width %d, clock %dHz, card power %s, voltage %s \r\n", - ios->bus_width, - ios->clock, - ios->power_mode == SDHC_POWER_ON ? "ON" : "OFF", - ios->signal_voltage == SD_VOL_1_8_V ? "1.8V" : "3.3V" - ); - - /* host clock , must have */ - if(ios->clock > 0) - { - cmd_reg = FSDIF_READ_REG(instance->config.base_addr, FSDIF_CMD_OFFSET); - cur_cmd_index = FSDIF_CMD_INDX_GET(cmd_reg); + struct usdhc_data *data = dev->data; + FSdif *instance = &data->instance; + uintptr base_addr = instance->config.base_addr; + bool is_drr = false; - if (FSDIF_SWITCH_VOLTAGE == cur_cmd_index) - { - mci_cmd_bits |= FSDIF_CMD_VOLT_SWITCH; - } + if ((ios->timing == SDHC_TIMING_DDR50) || (ios->timing == SDHC_TIMING_DDR52) || + (ios->timing == SDHC_TIMING_HS400)) + { + is_drr = true; + } - target_timing = fsdif_hc_get_timming(ios->clock,instance->config.non_removable) ; - if (NULL == target_timing) - { - LOG_ERR("No available timeing !!!"); - return -ENOTSUP; - } + LOG_DBG("SDHC I/O: bus width %d, clock %dHz, card power %s, voltage %s ddr %s\r\n", + ios->bus_width, ios->clock, ios->power_mode == SDHC_POWER_ON ? "ON" : "OFF", + ios->signal_voltage == SD_VOL_1_8_V ? "1.8V" : "3.3V", is_drr ? "on" : "off"); - /* update pad delay */ - if (target_timing->pad_delay) + if (data->cur_ios.clock != ios->clock) + { + if (FSDIF_SUCCESS != FSdifSetClkFreqByCalc(instance, is_drr, ios->clock)) { - target_timing->pad_delay(pin_ctrl); - } - - /* update clock source setting */ - if (FSDIF_SUCCESS != FSdifUpdateExternalClk(instance->config.base_addr, target_timing->clk_src)) - { - LOG_ERR("update clock source failed !!!"); - return -ENOTSUP; + LOG_ERR("FSdifSetClkFreqByCalc failed\r\n"); + return -ENXIO; } + } - FSdifSetClock(instance->config.base_addr, FALSE); - - /* update clock for clock source */ - if (FSDIF_SWITCH_VOLTAGE == cur_cmd_index) - { - ret = FSdifSendPrivateCmd11(instance->config.base_addr, mci_cmd_bits | cmd_reg); - } - else - { - ret = FSdifSendPrivateCmd(instance->config.base_addr, mci_cmd_bits, 0); - } - - if (FSDIF_SUCCESS != ret) - { - LOG_ERR("update ext clock failed !!!"); - return -ret; - } - - /* set clock divider */ - FSDIF_WRITE_REG(instance->config.base_addr, FSDIF_CLKDIV_OFFSET, target_timing->clk_div); - - FSDIF_WRITE_REG(instance->config.base_addr, FSDIF_ENABLE_SHIFT_OFFSET, target_timing->shift); - - LOG_DBG("clk_src: 0x%x clk_div: 0x%x, shift: 0x%x", - FSDIF_READ_REG(instance->config.base_addr, FSDIF_CLK_SRC_OFFSET), - FSDIF_READ_REG(instance->config.base_addr, FSDIF_CLKDIV_OFFSET), - FSDIF_READ_REG(instance->config.base_addr, FSDIF_ENABLE_SHIFT_OFFSET)); - - FSdifSetClock(instance->config.base_addr, TRUE); - - /* sd card issue */ - if (FSDIF_SWITCH_VOLTAGE == cur_cmd_index) - { - ret = FSdifSendPrivateCmd11(instance->config.base_addr, mci_cmd_bits | cmd_reg); - } - else + if (data->cur_ios.bus_width != ios->bus_width) + { + switch (ios->bus_width) { - ret = FSdifSendPrivateCmd(instance->config.base_addr, mci_cmd_bits, 0); - } - - - instance->curr_timing = (const FSdifTiming *)target_timing; - - } - - /* bus width */ - if (host_io->bus_width != ios->bus_width) { - switch (ios->bus_width) { case SDHC_BUS_WIDTH1BIT: - FSdifSetBusWidth(instance->config.base_addr, 1); + FSdifSetCardBusWidth(instance, 1U); break; case SDHC_BUS_WIDTH4BIT: - FSdifSetBusWidth(instance->config.base_addr, 4); + FSdifSetCardBusWidth(instance, 4U); break; case SDHC_BUS_WIDTH8BIT: - FSdifSetBusWidth(instance->config.base_addr, 8); + FSdifSetCardBusWidth(instance, 8U); break; default: return -ENOTSUP; } - host_io->bus_width = ios->bus_width; } - /* only surpport 3.3V */ - /* Set host signal voltage */ - if (ios->signal_voltage != host_io->signal_voltage) { - switch (ios->signal_voltage) { + + if (data->cur_ios.signal_voltage != ios->signal_voltage) + { + switch (ios->signal_voltage) + { case SD_VOL_3_3_V: case SD_VOL_3_0_V: - FSdifSetVoltage1_8V(instance->config.base_addr, FALSE); + FSdifSetVoltage1_8V(base_addr, FALSE); break; case SD_VOL_1_8_V: + FSdifSetVoltage1_8V(base_addr, TRUE); break; default: return -ENOTSUP; } - /* Save new host voltage */ - host_io->signal_voltage = ios->signal_voltage; } + + memcpy(&(data->cur_ios), ios, sizeof(*ios)); return 0; } @@ -524,7 +232,7 @@ static int phytium_sdhc_card_busy(const struct device *dev) struct usdhc_data *device_data = dev->data; FSdif *instance = &device_data->instance ; - return FSdifCheckIfCardBusy(instance->config.base_addr) ? 1 : 0; + return FSdifCheckCardBusy(instance) ? 1 : 0; } @@ -532,74 +240,67 @@ static int phytium_sdhc_card_busy(const struct device *dev) static void phytium_cmddata_convert_dri_data(struct sdhc_command *cmd, struct sdhc_data *data, FSdifCmdData *cmd_data) { - cmd->response_type &= ~SPI_MASK ; + uint32_t raw_cmd = FSDIF_CMD_INDX_SET(cmd->opcode); + uint32_t response_type = cmd->response_type & ~SPI_MASK; - if(cmd->opcode == SD_GO_IDLE_STATE) + if (cmd->opcode == SD_GO_IDLE_STATE) { - cmd_data->flag |= FSDIF_CMD_FLAG_NEED_INIT; - } + raw_cmd |= FSDIF_CMD_INIT; + } - if((cmd->opcode == SD_GO_INACTIVE_STATE) && - ((cmd->arg >> 9) & 0x1FFFF) == SD_SWITCH) + if (cmd->opcode == SD_GO_INACTIVE_STATE) { - cmd_data->flag |= FSDIF_CMD_FLAG_ABORT; - } + raw_cmd |= FSDIF_CMD_STOP_ABORT; + } - if(SD_RSP_TYPE_NONE != cmd->response_type) + if (SD_RSP_TYPE_NONE != response_type) { - cmd_data->flag |= FSDIF_CMD_FLAG_EXP_RESP; + raw_cmd |= FSDIF_CMD_RESP_EXP; - if(cmd->response_type == SD_RSP_TYPE_R2) + if (response_type == SD_RSP_TYPE_R2) { - cmd_data->flag |= FSDIF_CMD_FLAG_EXP_LONG_RESP; - } + raw_cmd |= FSDIF_CMD_RESP_LONG; + } - if((cmd->response_type != SD_RSP_TYPE_R3) && - (cmd->response_type != SD_RSP_TYPE_R4)) + if ((response_type != SD_RSP_TYPE_R3) && (response_type != SD_RSP_TYPE_R4)) { - cmd_data->flag |= FSDIF_CMD_FLAG_NEED_RESP_CRC; - } - } - - if(cmd->opcode == SD_VOL_SWITCH) - { - cmd_data->flag |= FSDIF_CMD_FLAG_SWITCH_VOLTAGE; - } + raw_cmd |= FSDIF_CMD_RESP_CRC; + } + } - if(cmd->opcode == SD_GO_INACTIVE_STATE) + if (cmd->opcode == SD_VOL_SWITCH) { - /* CMD15 go inactive and abort current transfer */ - cmd_data->flag |= FSDIF_CMD_FLAG_ABORT; - } + raw_cmd |= FSDIF_CMD_VOLT_SWITCH; + } - if(data) + if (data) { - cmd_data->flag |= FSDIF_CMD_FLAG_EXP_DATA; + raw_cmd |= FSDIF_CMD_DAT_EXP; - switch(cmd->opcode) + switch (cmd->opcode) { - case SD_WRITE_SINGLE_BLOCK: - case SD_WRITE_MULTIPLE_BLOCK: - cmd_data->flag |= FSDIF_CMD_FLAG_WRITE_DATA; - cmd_data->data_p->buf = data->data; - cmd_data->data_p->buf_dma = (uintptr_t)data->data; - break; - default: - cmd_data->flag |= FSDIF_CMD_FLAG_READ_DATA; - cmd_data->data_p->buf = data->data; - // This assumes that the data pointer can be used as a DMA address, which might not always be correct. - cmd_data->data_p->buf_dma = (uintptr_t)data->data; - break; - } - - cmd_data->data_p->blksz = data->block_size; - cmd_data->data_p->blkcnt = data->blocks; - cmd_data->data_p->datalen = data->block_size * data->blocks; - } + case SD_WRITE_SINGLE_BLOCK: + case SD_WRITE_MULTIPLE_BLOCK: + raw_cmd |= FSDIF_CMD_DAT_WRITE; + cmd_data->data_p->buf = data->data; + cmd_data->data_p->buf_dma = (uintptr_t)data->data; + break; + default: + cmd_data->data_p->buf = data->data; + /* This assumes that the data pointer can be used as a DMA address, which + * might not always be correct. */ + cmd_data->data_p->buf_dma = (uintptr_t)data->data; + break; + } - cmd_data->cmdidx = cmd->opcode; - cmd_data->cmdarg = cmd->arg; + cmd_data->data_p->blksz = data->block_size; + cmd_data->data_p->blkcnt = data->blocks; + cmd_data->data_p->datalen = data->block_size * data->blocks; + } + cmd_data->rawcmd = raw_cmd; + cmd_data->cmdidx = cmd->opcode; + cmd_data->cmdarg = cmd->arg; } static int phytium_sdhc_request(const struct device *dev, struct sdhc_command *cmd, struct sdhc_data *data) @@ -614,6 +315,29 @@ static int phytium_sdhc_request(const struct device *dev, struct sdhc_command *c uint32_t end_event = 0; /* 0 is init ,1 is finish ,2 is err ocurr */ uint32_t wait_mask = 0; + if (card_polling_busy(dev, timeout)) + { + return -EBUSY; + } + + if (instance->config.non_removable) + { + /* ignore micro SD detect command, not in eMMC spec. */ + if ((SD_APP_SEND_OP_COND == cmd->opcode) || + (SD_APP_CMD == cmd->opcode)) + { + return 0; + } + + /* ignore mmcsd_send_if_cond(CMD-8) which will failed for eMMC + but check cmd arg to let SEND_EXT_CSD (CMD-8) run */ + if ((SD_SEND_IF_COND == cmd->opcode) && + (0x1aa == cmd->arg)) + { + return 0; + } + } + /* add send cmd23 */ if(cmd->opcode == SD_WRITE_MULTIPLE_BLOCK||cmd->opcode == SD_READ_MULTIPLE_BLOCK) { @@ -645,9 +369,18 @@ static int phytium_sdhc_request(const struct device *dev, struct sdhc_command *c phytium_cmddata_convert_dri_data(cmd,data,cmd_data) ; - if(device_data->is_enable_dma) + if(instance->config.trans_mode == FSDIF_IDMA_TRANS_MODE) { - if (0 != FSdifDMATransfer(instance, cmd_data)) + if (cmd_data->data_p) + { + if (FSDIF_SUCCESS != FSdifSetupDMADescriptor(instance, cmd_data->data_p)) + { + LOG_ERR("FSdifSetupDMADescriptor is failed"); + return -EHOSTUNREACH; + } + } + + if (FSDIF_SUCCESS != FSdifDMATransfer(instance, cmd_data)) { LOG_ERR("FSdifDMATransfer is error") ; return -EHOSTUNREACH; @@ -666,7 +399,7 @@ static int phytium_sdhc_request(const struct device *dev, struct sdhc_command *c { do { - events = k_event_wait(&device_data->irq_event,wait_mask|FSDIF_IRQ_BIT_ERROR_OCCUR,false,K_MSEC(1)) ; + events = k_event_wait_all(&device_data->irq_event,wait_mask,false,K_MSEC(1)) ; if(events & FSDIF_IRQ_BIT_ERROR_OCCUR) { end_event = 2 ; @@ -696,28 +429,14 @@ static int phytium_sdhc_request(const struct device *dev, struct sdhc_command *c } else { - /* If the interrupt is not enabled */ - if(device_data->is_enable_dma) - { - /* If the interrupt is not enabled */ - if (0 != FSdifPollWaitDMAEnd(instance, cmd_data)) - { - LOG_ERR("FSdifPollWaitDMAEnd is error") ; - return -ETIMEDOUT; - } - } - else + if (FSDIF_SUCCESS != FSdifPollWaitTransferEnd(instance, cmd_data)) { - /* If the interrupt is not enabled */ - if (FSDIF_SUCCESS != FSdifPollWaitPIOEnd(instance,cmd_data)) - { - LOG_ERR("FSdifPollWaitPIOEnd is error") ; - return -ETIMEDOUT; - } - } + LOG_ERR("FSdifPollWaitTransferEnd failed \r\n"); + return -ETIMEDOUT; + } } /* wait event is over */ - if(0 != FSdifGetCmdResponse(instance, cmd_data)) + if(FSDIF_SUCCESS != FSdifGetCmdResponse(instance, cmd_data)) { LOG_ERR("FSdifGetCmdResponse is error") ; @@ -786,16 +505,13 @@ static int card_setblcok(const struct device *dev, uint32_t num_blocks) return phytium_sdhc_request(dev, &cmd, NULL) ; } - - - static int phytium_sdhc_get_card_present(const struct device *dev) { struct usdhc_data *data = dev->data; FSdif *instance = &data->instance ; - data->card_present = FSdifCheckIfCardExists(instance->config.base_addr) ? true : false ; - return data->card_present ; + data->card_present = FSdifCheckCardExists(instance) ? 1 : 0; + return data->card_present; } @@ -821,12 +537,13 @@ static int phytium_sdhc_isr(const struct device *dev) static void phytium_sdhc_init_host_props(const struct device *dev) { - struct usdhc_data *data = dev->data; + struct usdhc_config *cfg = (struct usdhc_config *)dev->config; + struct usdhc_data *data = (struct usdhc_data *)dev->data; struct sdhc_host_props *props = &data->props; memset(props, 0, sizeof(struct sdhc_host_props)); - props->f_max = 50000000U; - props->f_min = 400000; + props->f_max = cfg->max_bus_freq; + props->f_min = cfg->min_bus_freq; props->host_caps.vol_180_support = false; props->host_caps.vol_300_support = true; @@ -851,6 +568,38 @@ void phytium_relax_delay(void) } +static int card_polling_busy(const struct device *dev, int timeout_us) +{ + struct usdhc_data *device_data = dev->data; + FSdif *instance = &device_data->instance; + int wait_counter = 0; + + while (FSdifCheckCardBusy(instance)) + { + if (wait_counter > timeout_us) + { + LOG_ERR("Failed to wait card not busy\r\n"); + return EBUSY; + } + + /* busy waiting here will actually faster */ + phytium_relax_delay(); /* wait 1us here */ + wait_counter++; + } + + return 0; +} + +static void phytium_sdhc_pad_delay_init(FIOPadCtrl * iopad_ctrl) +{ +#if defined(CONFIG_SOC_PD2308) + #define FSDIF_0_SD_CCLK_OUT_DELAY FIOPAD_BV65_REG1_OFFSET + + /* fix this for firmwire */ + FtOut32(iopad_ctrl->config.base_address + FSDIF_0_SD_CCLK_OUT_DELAY, 0x5f00); +#endif +} + static int phytium_usdhc_init(const struct device *dev) { struct usdhc_config *cfg = (struct usdhc_config *)dev->config; @@ -865,22 +614,13 @@ static int phytium_usdhc_init(const struct device *dev) sdhc_cfg.instance_id = cfg->instance_id; /* Device instance id */ LOG_DBG("sdhc_cfg.instance_id is %d \r\n",sdhc_cfg.instance_id) ; - sdhc_cfg.non_removable = FALSE ; /* No removeable media, e.g eMMC */ - sdhc_cfg.get_tuning = NULL ; /* Get time-tuning related parameters and method */ -#if defined(CONFIG_PHYTIUM_USDHC_DMA_SUPPORT) - data->is_enable_dma = 1 ; + sdhc_cfg.non_removable = cfg->non_removeable ; /* No removeable media, e.g eMMC */ +#if CONFIG_PHYTIUM_USDHC_DMA_SUPPORT + sdhc_cfg.trans_mode = FSDIF_IDMA_TRANS_MODE; /* Trans mode, DMA */ #else - data->is_enable_dma = 0 ; + sdhc_cfg.trans_mode = FSDIF_PIO_TRANS_MODE; /* Trans mode, PIO */ #endif - - if(data->is_enable_dma) - { - sdhc_cfg.trans_mode = FSDIF_IDMA_TRANS_MODE ; /* Trans mode, PIO/DMA */ - } - else - { - sdhc_cfg.trans_mode = FSDIF_PIO_TRANS_MODE ; /* Trans mode, PIO/DMA */ - } + sdhc_cfg.src_clk_rate = FSDIF_CLK_FREQ_HZ; /* init pio init */ io_config.instance_id = cfg->pio_id ; @@ -894,6 +634,8 @@ static int phytium_usdhc_init(const struct device *dev) { LOG_ERR("FIOPadCfgInitialize is error") ; } + + phytium_sdhc_pad_delay_init(&data->iopad_ctrl); if(0 != FSdifCfgInitialize(&data->instance,&sdhc_cfg)) { @@ -907,17 +649,17 @@ static int phytium_usdhc_init(const struct device *dev) { if(cfg->irq_config_func) { - FSdifRegisterEvtHandler(&data->instance, FSDIF_EVT_CARD_DETECTED, FSDIFHOST_CardDetected, (void *)data); - FSdifRegisterEvtHandler(&data->instance, FSDIF_EVT_ERR_OCCURE, FSDIFHOST_ErrorOccur, (void *)data); - FSdifRegisterEvtHandler(&data->instance, FSDIF_EVT_CMD_DONE, FSDIFHOST_CmdDone, (void *)data); - FSdifRegisterEvtHandler(&data->instance, FSDIF_EVT_DATA_DONE, FSDIFHOST_DataDone, (void *)data); + FSdifRegisterEvtHandler(&data->instance, FSDIF_EVT_CARD_DETECTED, phytium_sdhc_card_detect_handler, (void *)data); + FSdifRegisterEvtHandler(&data->instance, FSDIF_EVT_ERR_OCCURE, phytium_sdhc_error_occurred_handler, (void *)data); + FSdifRegisterEvtHandler(&data->instance, FSDIF_EVT_CMD_DONE, phytium_sdhc_command_done_handler, (void *)data); + FSdifRegisterEvtHandler(&data->instance, FSDIF_EVT_DATA_DONE, phytium_sdhc_data_done_handler, (void *)data); cfg->irq_config_func(dev) ; } } -#if defined(CONFIG_PHYTIUM_USDHC_DMA_SUPPORT) +#if CONFIG_PHYTIUM_USDHC_DMA_SUPPORT - if(data->is_enable_dma) + if (sdhc_cfg.trans_mode == FSDIF_IDMA_TRANS_MODE) { if(FSdifSetIDMAList(&data->instance,data->usdhc_dma_descriptor,(uintptr)data->usdhc_dma_descriptor,CONFIG_PHYTIUM_SDIF_DMA_DESC_LENGTH)) @@ -954,9 +696,9 @@ static const struct sdhc_driver_api usdhc_api = { #define PHYTIUM_USDHC_NOCACHE_TAG #endif -#ifdef CONFIG_PHYTIUM_USDHC_DMA_SUPPORT +#if CONFIG_PHYTIUM_USDHC_DMA_SUPPORT #define PHYTIUM_USDHC_DMA_BUFFER_DEFINE(n) \ - static FSdifIDmaDesc __aligned(512) \ + static FSdifIDmaDesc __aligned(FSDIF_DMA_DESC_ALIGMENT) \ usdhc_##n##_dma_descriptor[CONFIG_PHYTIUM_SDIF_DMA_DESC_LENGTH]\ PHYTIUM_USDHC_NOCACHE_TAG; #define PHYTIUM_USDHC_DMA_BUFFER_INIT(n) \ @@ -986,6 +728,9 @@ static const struct sdhc_driver_api usdhc_api = { .pio_base = DT_INST_PROP(n, pio_base), \ .pio_length = DT_INST_PROP(n, pio_length), \ .is_enable_irq = DT_INST_PROP(n, is_enable_irq),\ + .non_removeable = DT_INST_PROP(n, non_removeable),\ + .max_bus_freq = DT_INST_PROP(n, max_bus_freq),\ + .min_bus_freq = DT_INST_PROP(n, min_bus_freq),\ .irq_config_func = usdhc_##n##_irq_config_func ,\ }; \ \ diff --git a/dts/arm64/phytium/e2000d.dtsi b/dts/arm64/phytium/e2000d.dtsi index 5dd03338fc4..c5baeb09f71 100644 --- a/dts/arm64/phytium/e2000d.dtsi +++ b/dts/arm64/phytium/e2000d.dtsi @@ -104,21 +104,24 @@ sdhc0: sdhc@28000000 { compatible = "phytium,sdhc"; reg = <0x00 0x28000000 0x00 0x1000>; + pio-base = <0x32B30000>; status = "disabled"; interrupts = ; max-current-330 = <1020>; - max-bus-freq = <25000000>; + max-bus-freq = <52000000>; min-bus-freq = <400000>; + non-removeable; }; sdhc1: sdhc@28001000 { compatible = "phytium,sdhc"; reg = <0x00 0x28001000 0x00 0x1000>; + pio-base = <0x32B30000>; status = "disabled"; interrupts = ; max-current-330 = <1020>; - max-bus-freq = <25000000>; + max-bus-freq = <50000000>; min-bus-freq = <400000>; }; diff --git a/dts/arm64/phytium/e2000q.dtsi b/dts/arm64/phytium/e2000q.dtsi index 5402fb38344..c10a481dfc2 100644 --- a/dts/arm64/phytium/e2000q.dtsi +++ b/dts/arm64/phytium/e2000q.dtsi @@ -116,10 +116,23 @@ sdhc0: sdhc@28000000 { compatible = "phytium,sdhc"; reg = <0x00 0x28000000 0x00 0x1000>; + pio-base = <0x32B30000>; status = "disabled"; interrupts = ; max-current-330 = <1020>; - max-bus-freq = <25000000>; + max-bus-freq = <52000000>; + min-bus-freq = <400000>; + non-removeable; + }; + + sdhc1: sdhc@28001000 { + compatible = "phytium,sdhc"; + reg = <0x00 0x28001000 0x00 0x1000>; + pio-base = <0x32B30000>; + status = "disabled"; + interrupts = ; + max-current-330 = <1020>; + max-bus-freq = <50000000>; min-bus-freq = <400000>; }; @@ -145,16 +158,6 @@ disable-reject-fcs-crc-errors; }; - sdhc1: sdhc@28001000 { - compatible = "phytium,sdhc"; - reg = <0x00 0x28001000 0x00 0x1000>; - status = "disabled"; - interrupts = ; - max-current-330 = <1020>; - max-bus-freq = <25000000>; - min-bus-freq = <400000>; - }; - /* 512MB DDR */ sram0: memory@80100000 { device_type = "memory"; diff --git a/dts/arm64/phytium/pd2308.dtsi b/dts/arm64/phytium/pd2308.dtsi index 0f7cc1249d9..e99165e0fc5 100644 --- a/dts/arm64/phytium/pd2308.dtsi +++ b/dts/arm64/phytium/pd2308.dtsi @@ -149,9 +149,10 @@ disable-reject-fcs-crc-errors; }; - sdhc1: sdhc@28000000 { + sdhc0: sdhc@28000000 { compatible = "phytium,sdhc"; reg = <0x00 0x28000000 0x00 0x1000>; + pio-base = <0x36CEA000>; status = "disabled"; interrupts = ; max-current-330 = <1020>; diff --git a/dts/bindings/sdhc/phytium,sdhc.yaml b/dts/bindings/sdhc/phytium,sdhc.yaml index 152f92213b6..014ada1d64a 100644 --- a/dts/bindings/sdhc/phytium,sdhc.yaml +++ b/dts/bindings/sdhc/phytium,sdhc.yaml @@ -32,9 +32,7 @@ properties: pio-base: type: int - default: 0x28008000 - description: | - pio base + required: true pio-length: type: int @@ -59,3 +57,8 @@ properties: description: | When the external SD card circuit does not support 1.8V, add this property to disable 1.8v card voltage of SD card controller. + + non-removeable: + type: boolean + description: | + The host controller is for non-remveable device, e.g. eMMC \ No newline at end of file -- Gitee From 52ec8cddd49fbc326941e618ca95b38e19a13923 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E9=94=A6?= Date: Tue, 1 Jul 2025 09:15:14 +0000 Subject: [PATCH 10/13] add tx tail --- drivers/ethernet/eth_phytium_xmac.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/drivers/ethernet/eth_phytium_xmac.c b/drivers/ethernet/eth_phytium_xmac.c index 043e3873f6c..ac697423b8f 100644 --- a/drivers/ethernet/eth_phytium_xmac.c +++ b/drivers/ethernet/eth_phytium_xmac.c @@ -14,6 +14,7 @@ // specific language governing permissions and limitations under the License. +#include "fparameters.h" #include "fxmac.h" #include "fxmac_hw.h" #include "fxmac_bdring.h" @@ -461,7 +462,11 @@ static int eth_phytium_xmac_config_convert(struct eth_phytium_xmac_dev_cfg *dev_ mac_config->rx_queue_id = 0; /* 0 ~ FXMAC_QUEUE_MAX_NUM ,Index queue number */ mac_config->dma_brust_length = dev_conf->dma_brust_length; /* burst length */ mac_config->network_default_config = FXMAC_DEFAULT_OPTIONS; - mac_config->caps = 0; /* used to configure tail ptr feature */ +#if defined(FXMAC_CAPS) + mac_config->caps = FXMAC_CAPS; /* used to configure tail ptr feature */ +#else + mac_config->caps = 0; +#endif /* options */ if(dev_conf->enable_jumbo) @@ -489,6 +494,10 @@ static int eth_phytium_xmac_config_convert(struct eth_phytium_xmac_dev_cfg *dev_ *options |= FXMAC_FCS_STRIP_OPTION; } + if(mac_config->caps & FXMAC_CAPS_TAILPTR) + { + *options |= FXMAC_TAIL_PTR_OPTION; + } return 0; } @@ -764,6 +773,12 @@ static int eth_phytium_xmac_send(const struct device *dev, struct net_pkt *pkt) tx_data_remaining : dev_conf->tx_buffer_size; } FXMAC_BD_SET_LAST(last_txbd); + + if (instance_p->config.caps & FXMAC_CAPS_TAILPTR) + { + bdindex = FXMAC_BD_TO_INDEX(txring, txbd); + } + FXMAC_BD_CLEAR_TX_USED(last_txbd); if(FXmacBdRingToHw(txring, bds_reqd, txbdset)) @@ -771,6 +786,11 @@ static int eth_phytium_xmac_send(const struct device *dev, struct net_pkt *pkt) LOG_ERR("sgsend: Error submitting TxBD\r\n"); } + if (instance_p->config.caps & FXMAC_CAPS_TAILPTR) + { + FXMAC_WRITEREG32(instance_p->config.base_address, FXMAC_TAIL_QUEUE(0), BIT(31)|bdindex); + } + /* Start transmit */ FXMAC_WRITEREG32(instance_p->config.base_address, FXMAC_NWCTRL_OFFSET, -- Gitee From 2e5d2fcd9c770c116b02412ea22335cf45a5810f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E8=A1=8D?= Date: Mon, 7 Jul 2025 10:01:23 +0000 Subject: [PATCH 11/13] =?UTF-8?q?=E9=80=82=E9=85=8Dgitee=E6=96=B0=E5=8F=91?= =?UTF-8?q?=E5=B8=83=E7=89=88=E6=9C=ACsdk?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- boards/deprecated.cmake | 41 ++- .../Kconfig.d2000_aarch32_demo | 2 +- boards/phytium/d2000_aarch32_demo/board.yml | 2 +- .../d2000_aarch32_demo/d2000_aarch32_demo.dts | 2 +- .../d2000_aarch32_demo_defconfig | 2 +- boards/phytium/d2000_demo/Kconfig.d2000_demo | 2 +- boards/phytium/d2000_demo/board.yml | 2 +- boards/phytium/d2000_demo/d2000_demo.dts | 2 +- ..._defconfig => d2000_demo_pd2008_defconfig} | 4 - ...2000_el2.dts => d2000_demo_pd2008_el2.dts} | 2 +- ...00_el2.yaml => d2000_demo_pd2008_el2.yaml} | 0 ...config => d2000_demo_pd2008_el2_defconfig} | 4 - ..._smp.dts => d2000_demo_pd2008_el2_smp.dts} | 2 +- ...mp.yaml => d2000_demo_pd2008_el2_smp.yaml} | 0 ...ig => d2000_demo_pd2008_el2_smp_defconfig} | 0 ..._el2_smp.dts => d2000_demo_pd2008_smp.dts} | 2 +- ...00_smp.yaml => d2000_demo_pd2008_smp.yaml} | 0 ...config => d2000_demo_pd2008_smp_defconfig} | 0 .../Kconfig.e2000d_aarch32_demo | 2 +- boards/phytium/e2000d_aarch32_demo/board.yml | 2 +- .../e2000d_aarch32_demo.dts | 2 +- .../e2000d_aarch32_demo_defconfig | 2 +- .../phytium/e2000d_demo/Kconfig.e2000d_demo | 2 +- boards/phytium/e2000d_demo/board.yml | 2 +- boards/phytium/e2000d_demo/e2000d_demo.dts | 3 +- .../phytium/e2000d_demo/e2000d_demo_defconfig | 4 - ...00d_el2.dts => e2000d_demo_pe2202_el2.dts} | 3 +- ...d_el2.yaml => e2000d_demo_pe2202_el2.yaml} | 0 ...onfig => e2000d_demo_pe2202_el2_defconfig} | 4 - ...smp.dts => e2000d_demo_pe2202_el2_smp.dts} | 4 +- ...p.yaml => e2000d_demo_pe2202_el2_smp.yaml} | 0 ...g => e2000d_demo_pe2202_el2_smp_defconfig} | 0 ...00d_smp.dts => e2000d_demo_pe2202_smp.dts} | 3 +- ...d_smp.yaml => e2000d_demo_pe2202_smp.yaml} | 0 ...onfig => e2000d_demo_pe2202_smp_defconfig} | 0 .../e2000d_demo/e2000d_demo_pinctrl.dtsi | 19 ++ .../Kconfig.e2000q_aarch32_demo | 2 +- boards/phytium/e2000q_aarch32_demo/board.yml | 2 +- .../e2000q_aarch32_demo.dts | 2 +- .../e2000q_aarch32_demo_defconfig | 2 +- .../phytium/e2000q_demo/Kconfig.e2000q_demo | 4 +- boards/phytium/e2000q_demo/board.yml | 2 +- boards/phytium/e2000q_demo/e2000q_demo.dts | 4 +- .../phytium/e2000q_demo/e2000q_demo_defconfig | 4 - ...00q_el2.dts => e2000q_demo_pe2204_el2.dts} | 4 +- ...q_el2.yaml => e2000q_demo_pe2204_el2.yaml} | 0 ...onfig => e2000q_demo_pe2204_el2_defconfig} | 4 - ...smp.dts => e2000q_demo_pe2204_el2_smp.dts} | 4 +- ...p.yaml => e2000q_demo_pe2204_el2_smp.yaml} | 0 ...g => e2000q_demo_pe2204_el2_smp_defconfig} | 0 ...el2_smp.dts => e2000q_demo_pe2204_smp.dts} | 4 +- ...q_smp.yaml => e2000q_demo_pe2204_smp.yaml} | 0 ...onfig => e2000q_demo_pe2204_smp_defconfig} | 0 ..._pinctrl.dtsi => e2000q_demo_pinctrl.dtsi} | 2 +- .../phytium/pd2308_demo/pd2308_demo_defconfig | 4 - .../pd2308_demo/pd2308_demo_pd2308_el2.dts | 2 +- .../pd2308_demo_pd2308_el2_defconfig | 4 - .../pd2308_demo_pd2308_el2_smp.dts | 2 +- .../pd2308_demo_pd2308_el2_smp.yaml | 2 +- .../pd2308_demo/pd2308_demo_pd2308_smp.dts | 2 +- .../phytium/pd2408_test_a/Kconfig.defconfig | 19 ++ .../pd2408_test_a/Kconfig.pd2408_test_a | 18 + boards/phytium/pd2408_test_a/board.cmake | 1 + boards/phytium/pd2408_test_a/board.yml | 10 + .../phytium/pd2408_test_a/pd2408_test_a.dts | 34 ++ .../phytium/pd2408_test_a/pd2408_test_a.yaml | 7 + .../pd2408_test_a/pd2408_test_a_defconfig | 29 ++ .../pd2408_test_a_pd2408_el2.dts | 34 ++ .../pd2408_test_a_pd2408_el2.yaml | 7 + .../pd2408_test_a_pd2408_el2_defconfig | 32 ++ .../pd2408_test_a_pd2408_el2_smp.dts | 34 ++ .../pd2408_test_a_pd2408_el2_smp.yaml | 9 + .../pd2408_test_a_pd2408_el2_smp_defconfig | 44 +++ .../pd2408_test_a_pd2408_smp.dts | 41 +++ .../pd2408_test_a_pd2408_smp.yaml | 9 + .../pd2408_test_a_pd2408_smp_defconfig | 41 +++ .../pd2408_test_a/pd2408_test_a_pinctrl.dtsi | 12 + .../phytium/pd2408_test_b/Kconfig.defconfig | 19 ++ .../pd2408_test_b/Kconfig.pd2408_test_b | 18 + boards/phytium/pd2408_test_b/board.cmake | 1 + boards/phytium/pd2408_test_b/board.yml | 10 + .../phytium/pd2408_test_b/pd2408_test_b.dts | 34 ++ .../phytium/pd2408_test_b/pd2408_test_b.yaml | 7 + .../pd2408_test_b/pd2408_test_b_defconfig | 29 ++ .../pd2408_test_b_pd2408_el2.dts | 34 ++ .../pd2408_test_b_pd2408_el2.yaml | 7 + .../pd2408_test_b_pd2408_el2_defconfig | 32 ++ .../pd2408_test_b_pd2408_el2_smp.dts | 34 ++ .../pd2408_test_b_pd2408_el2_smp.yaml | 9 + .../pd2408_test_b_pd2408_el2_smp_defconfig | 44 +++ .../pd2408_test_b_pd2408_smp.dts | 41 +++ .../pd2408_test_b_pd2408_smp.yaml | 9 + .../pd2408_test_b_pd2408_smp_defconfig | 41 +++ .../pd2408_test_b/pd2408_test_b_pinctrl.dtsi | 12 + .../phytium/ps2316_test/ps2316_test_defconfig | 4 - .../ps2316_test_ps2316_el2_defconfig | 4 - ...d2000_aarch32.dtsi => pd2008_aarch32.dtsi} | 0 ...2000d_aarch32.dtsi => pe2202_aarch32.dtsi} | 3 +- ...2000q_aarch32.dtsi => pe2204_aarch32.dtsi} | 11 +- dts/arm64/phytium/{d2000.dtsi => pd2008.dtsi} | 0 dts/arm64/phytium/pd2408.dtsi | 150 +++++++++ .../phytium/{e2000d.dtsi => pe2202.dtsi} | 16 +- .../phytium/{e2000q.dtsi => pe2204.dtsi} | 18 +- .../pinctrl/phytium-pd2408-pinctrl.h | 168 ++++++++++ ...00d-pinctrl.h => phytium-pe2202-pinctrl.h} | 0 ...00q-pinctrl.h => phytium-pe2204-pinctrl.h} | 0 soc/phytium/{d2000 => pd2008}/CMakeLists.txt | 0 soc/phytium/{d2000 => pd2008}/Kconfig | 2 +- .../{d2000 => pd2008}/Kconfig.defconfig | 4 +- soc/phytium/{e2000q => pd2008}/Kconfig.soc | 6 +- soc/phytium/{d2000 => pd2008}/mmu_regions.c | 0 soc/phytium/{d2000 => pd2008}/soc.c | 0 soc/phytium/{d2000 => pd2008}/soc.yml | 2 +- .../CMakeLists.txt | 0 .../{d2000_aarch32 => pd2008_aarch32}/Kconfig | 8 +- .../Kconfig.defconfig | 4 +- .../Kconfig.soc | 6 +- .../{d2000_aarch32 => pd2008_aarch32}/soc.c | 0 .../{d2000_aarch32 => pd2008_aarch32}/soc.h | 0 .../soc.yml | 2 +- soc/phytium/{e2000d => pd2408}/CMakeLists.txt | 0 soc/phytium/pd2408/Kconfig | 9 + soc/phytium/pd2408/Kconfig.defconfig | 29 ++ soc/phytium/pd2408/Kconfig.soc | 27 ++ soc/phytium/pd2408/mmu_regions.c | 52 +++ soc/phytium/{e2000q => pd2408}/pinctrl_soc.h | 8 +- soc/phytium/pd2408/soc.c | 32 ++ soc/phytium/{e2000d => pd2408}/soc.yml | 2 +- soc/phytium/{e2000q => pe2202}/CMakeLists.txt | 0 soc/phytium/{e2000d => pe2202}/Kconfig | 2 +- .../{e2000d => pe2202}/Kconfig.defconfig | 4 +- soc/phytium/{d2000 => pe2202}/Kconfig.soc | 6 +- soc/phytium/{e2000d => pe2202}/mmu_regions.c | 0 soc/phytium/pe2202/pinctrl_soc.h | 51 +++ soc/phytium/{e2000d => pe2202}/soc.c | 0 soc/phytium/{e2000d => pe2202}/soc.h | 0 soc/phytium/{e2000q => pe2202}/soc.yml | 2 +- .../CMakeLists.txt | 0 .../Kconfig | 4 +- .../Kconfig.defconfig | 4 +- .../Kconfig.soc | 6 +- soc/phytium/pe2202_aarch32/pinctrl_soc.h | 51 +++ .../{e2000d_aarch32 => pe2202_aarch32}/soc.c | 0 .../{e2000d_aarch32 => pe2202_aarch32}/soc.h | 0 .../{d2000_aarch32 => pe2202_aarch32}/soc.yml | 2 +- soc/phytium/pe2204/CMakeLists.txt | 10 + soc/phytium/{e2000q => pe2204}/Kconfig | 2 +- .../{e2000q => pe2204}/Kconfig.defconfig | 4 +- soc/phytium/{e2000d => pe2204}/Kconfig.soc | 6 +- soc/phytium/{e2000q => pe2204}/mmu_regions.c | 0 soc/phytium/pe2204/pinctrl_soc.h | 51 +++ soc/phytium/{e2000q => pe2204}/soc.c | 0 soc/phytium/pe2204/soc.yml | 5 + .../CMakeLists.txt | 0 .../Kconfig | 6 +- .../Kconfig.defconfig | 4 +- .../Kconfig.soc | 6 +- soc/phytium/pe2204_aarch32/pinctrl_soc.h | 51 +++ .../{e2000q_aarch32 => pe2204_aarch32}/soc.c | 0 .../{e2000q_aarch32 => pe2204_aarch32}/soc.h | 0 .../soc.yml | 2 +- west.yml | 310 +----------------- 162 files changed, 1630 insertions(+), 465 deletions(-) rename boards/phytium/d2000_demo/{d2000_demo_d2000_defconfig => d2000_demo_pd2008_defconfig} (86%) rename boards/phytium/d2000_demo/{d2000_demo_d2000_el2.dts => d2000_demo_pd2008_el2.dts} (95%) rename boards/phytium/d2000_demo/{d2000_demo_d2000_el2.yaml => d2000_demo_pd2008_el2.yaml} (100%) rename boards/phytium/d2000_demo/{d2000_demo_d2000_el2_defconfig => d2000_demo_pd2008_el2_defconfig} (86%) rename boards/phytium/d2000_demo/{d2000_demo_d2000_smp.dts => d2000_demo_pd2008_el2_smp.dts} (95%) rename boards/phytium/d2000_demo/{d2000_demo_d2000_el2_smp.yaml => d2000_demo_pd2008_el2_smp.yaml} (100%) rename boards/phytium/d2000_demo/{d2000_demo_d2000_el2_smp_defconfig => d2000_demo_pd2008_el2_smp_defconfig} (100%) rename boards/phytium/d2000_demo/{d2000_demo_d2000_el2_smp.dts => d2000_demo_pd2008_smp.dts} (95%) rename boards/phytium/d2000_demo/{d2000_demo_d2000_smp.yaml => d2000_demo_pd2008_smp.yaml} (100%) rename boards/phytium/d2000_demo/{d2000_demo_d2000_smp_defconfig => d2000_demo_pd2008_smp_defconfig} (100%) rename boards/phytium/e2000d_demo/{e2000d_demo_e2000d_el2.dts => e2000d_demo_pe2202_el2.dts} (90%) rename boards/phytium/e2000d_demo/{e2000d_demo_e2000d_el2.yaml => e2000d_demo_pe2202_el2.yaml} (100%) rename boards/phytium/e2000d_demo/{e2000d_demo_e2000d_el2_defconfig => e2000d_demo_pe2202_el2_defconfig} (86%) rename boards/phytium/e2000d_demo/{e2000d_demo_e2000d_el2_smp.dts => e2000d_demo_pe2202_el2_smp.dts} (91%) rename boards/phytium/e2000d_demo/{e2000d_demo_e2000d_el2_smp.yaml => e2000d_demo_pe2202_el2_smp.yaml} (100%) rename boards/phytium/e2000d_demo/{e2000d_demo_e2000d_el2_smp_defconfig => e2000d_demo_pe2202_el2_smp_defconfig} (100%) rename boards/phytium/e2000d_demo/{e2000d_demo_e2000d_smp.dts => e2000d_demo_pe2202_smp.dts} (91%) rename boards/phytium/e2000d_demo/{e2000d_demo_e2000d_smp.yaml => e2000d_demo_pe2202_smp.yaml} (100%) rename boards/phytium/e2000d_demo/{e2000d_demo_e2000d_smp_defconfig => e2000d_demo_pe2202_smp_defconfig} (100%) create mode 100644 boards/phytium/e2000d_demo/e2000d_demo_pinctrl.dtsi rename boards/phytium/e2000q_demo/{e2000q_demo_e2000q_el2.dts => e2000q_demo_pe2204_el2.dts} (92%) rename boards/phytium/e2000q_demo/{e2000q_demo_e2000q_el2.yaml => e2000q_demo_pe2204_el2.yaml} (100%) rename boards/phytium/e2000q_demo/{e2000q_demo_e2000q_el2_defconfig => e2000q_demo_pe2204_el2_defconfig} (86%) rename boards/phytium/e2000q_demo/{e2000q_demo_e2000q_smp.dts => e2000q_demo_pe2204_el2_smp.dts} (91%) rename boards/phytium/e2000q_demo/{e2000q_demo_e2000q_el2_smp.yaml => e2000q_demo_pe2204_el2_smp.yaml} (100%) rename boards/phytium/e2000q_demo/{e2000q_demo_e2000q_el2_smp_defconfig => e2000q_demo_pe2204_el2_smp_defconfig} (100%) rename boards/phytium/e2000q_demo/{e2000q_demo_e2000q_el2_smp.dts => e2000q_demo_pe2204_smp.dts} (91%) rename boards/phytium/e2000q_demo/{e2000q_demo_e2000q_smp.yaml => e2000q_demo_pe2204_smp.yaml} (100%) rename boards/phytium/e2000q_demo/{e2000q_demo_e2000q_smp_defconfig => e2000q_demo_pe2204_smp_defconfig} (100%) rename boards/phytium/e2000q_demo/{e2000q_pinctrl.dtsi => e2000q_demo_pinctrl.dtsi} (87%) create mode 100644 boards/phytium/pd2408_test_a/Kconfig.defconfig create mode 100644 boards/phytium/pd2408_test_a/Kconfig.pd2408_test_a create mode 100644 boards/phytium/pd2408_test_a/board.cmake create mode 100644 boards/phytium/pd2408_test_a/board.yml create mode 100644 boards/phytium/pd2408_test_a/pd2408_test_a.dts create mode 100644 boards/phytium/pd2408_test_a/pd2408_test_a.yaml create mode 100644 boards/phytium/pd2408_test_a/pd2408_test_a_defconfig create mode 100644 boards/phytium/pd2408_test_a/pd2408_test_a_pd2408_el2.dts create mode 100644 boards/phytium/pd2408_test_a/pd2408_test_a_pd2408_el2.yaml create mode 100644 boards/phytium/pd2408_test_a/pd2408_test_a_pd2408_el2_defconfig create mode 100644 boards/phytium/pd2408_test_a/pd2408_test_a_pd2408_el2_smp.dts create mode 100644 boards/phytium/pd2408_test_a/pd2408_test_a_pd2408_el2_smp.yaml create mode 100644 boards/phytium/pd2408_test_a/pd2408_test_a_pd2408_el2_smp_defconfig create mode 100644 boards/phytium/pd2408_test_a/pd2408_test_a_pd2408_smp.dts create mode 100644 boards/phytium/pd2408_test_a/pd2408_test_a_pd2408_smp.yaml create mode 100644 boards/phytium/pd2408_test_a/pd2408_test_a_pd2408_smp_defconfig create mode 100644 boards/phytium/pd2408_test_a/pd2408_test_a_pinctrl.dtsi create mode 100644 boards/phytium/pd2408_test_b/Kconfig.defconfig create mode 100644 boards/phytium/pd2408_test_b/Kconfig.pd2408_test_b create mode 100644 boards/phytium/pd2408_test_b/board.cmake create mode 100644 boards/phytium/pd2408_test_b/board.yml create mode 100644 boards/phytium/pd2408_test_b/pd2408_test_b.dts create mode 100644 boards/phytium/pd2408_test_b/pd2408_test_b.yaml create mode 100644 boards/phytium/pd2408_test_b/pd2408_test_b_defconfig create mode 100644 boards/phytium/pd2408_test_b/pd2408_test_b_pd2408_el2.dts create mode 100644 boards/phytium/pd2408_test_b/pd2408_test_b_pd2408_el2.yaml create mode 100644 boards/phytium/pd2408_test_b/pd2408_test_b_pd2408_el2_defconfig create mode 100644 boards/phytium/pd2408_test_b/pd2408_test_b_pd2408_el2_smp.dts create mode 100644 boards/phytium/pd2408_test_b/pd2408_test_b_pd2408_el2_smp.yaml create mode 100644 boards/phytium/pd2408_test_b/pd2408_test_b_pd2408_el2_smp_defconfig create mode 100644 boards/phytium/pd2408_test_b/pd2408_test_b_pd2408_smp.dts create mode 100644 boards/phytium/pd2408_test_b/pd2408_test_b_pd2408_smp.yaml create mode 100644 boards/phytium/pd2408_test_b/pd2408_test_b_pd2408_smp_defconfig create mode 100644 boards/phytium/pd2408_test_b/pd2408_test_b_pinctrl.dtsi rename dts/arm/phytium/{d2000_aarch32.dtsi => pd2008_aarch32.dtsi} (100%) rename dts/arm/phytium/{e2000d_aarch32.dtsi => pe2202_aarch32.dtsi} (98%) rename dts/arm/phytium/{e2000q_aarch32.dtsi => pe2204_aarch32.dtsi} (92%) rename dts/arm64/phytium/{d2000.dtsi => pd2008.dtsi} (100%) create mode 100644 dts/arm64/phytium/pd2408.dtsi rename dts/arm64/phytium/{e2000d.dtsi => pe2202.dtsi} (94%) rename dts/arm64/phytium/{e2000q.dtsi => pe2204.dtsi} (90%) create mode 100644 include/zephyr/dt-bindings/pinctrl/phytium-pd2408-pinctrl.h rename include/zephyr/dt-bindings/pinctrl/{phytium-e2000d-pinctrl.h => phytium-pe2202-pinctrl.h} (100%) rename include/zephyr/dt-bindings/pinctrl/{phytium-e2000q-pinctrl.h => phytium-pe2204-pinctrl.h} (100%) rename soc/phytium/{d2000 => pd2008}/CMakeLists.txt (100%) rename soc/phytium/{d2000 => pd2008}/Kconfig (92%) rename soc/phytium/{d2000 => pd2008}/Kconfig.defconfig (96%) rename soc/phytium/{e2000q => pd2008}/Kconfig.soc (94%) rename soc/phytium/{d2000 => pd2008}/mmu_regions.c (100%) rename soc/phytium/{d2000 => pd2008}/soc.c (100%) rename soc/phytium/{d2000 => pd2008}/soc.yml (64%) rename soc/phytium/{d2000_aarch32 => pd2008_aarch32}/CMakeLists.txt (100%) rename soc/phytium/{d2000_aarch32 => pd2008_aarch32}/Kconfig (85%) rename soc/phytium/{d2000_aarch32 => pd2008_aarch32}/Kconfig.defconfig (94%) rename soc/phytium/{e2000q_aarch32 => pd2008_aarch32}/Kconfig.soc (91%) rename soc/phytium/{d2000_aarch32 => pd2008_aarch32}/soc.c (100%) rename soc/phytium/{d2000_aarch32 => pd2008_aarch32}/soc.h (100%) rename soc/phytium/{e2000q_aarch32 => pd2008_aarch32}/soc.yml (53%) rename soc/phytium/{e2000d => pd2408}/CMakeLists.txt (100%) create mode 100644 soc/phytium/pd2408/Kconfig create mode 100644 soc/phytium/pd2408/Kconfig.defconfig create mode 100644 soc/phytium/pd2408/Kconfig.soc create mode 100644 soc/phytium/pd2408/mmu_regions.c rename soc/phytium/{e2000q => pd2408}/pinctrl_soc.h (85%) create mode 100644 soc/phytium/pd2408/soc.c rename soc/phytium/{e2000d => pd2408}/soc.yml (64%) rename soc/phytium/{e2000q => pe2202}/CMakeLists.txt (100%) rename soc/phytium/{e2000d => pe2202}/Kconfig (89%) rename soc/phytium/{e2000d => pe2202}/Kconfig.defconfig (96%) rename soc/phytium/{d2000 => pe2202}/Kconfig.soc (94%) rename soc/phytium/{e2000d => pe2202}/mmu_regions.c (100%) create mode 100644 soc/phytium/pe2202/pinctrl_soc.h rename soc/phytium/{e2000d => pe2202}/soc.c (100%) rename soc/phytium/{e2000d => pe2202}/soc.h (100%) rename soc/phytium/{e2000q => pe2202}/soc.yml (64%) rename soc/phytium/{e2000d_aarch32 => pe2202_aarch32}/CMakeLists.txt (100%) rename soc/phytium/{e2000d_aarch32 => pe2202_aarch32}/Kconfig (91%) rename soc/phytium/{e2000d_aarch32 => pe2202_aarch32}/Kconfig.defconfig (94%) rename soc/phytium/{d2000_aarch32 => pe2202_aarch32}/Kconfig.soc (91%) create mode 100644 soc/phytium/pe2202_aarch32/pinctrl_soc.h rename soc/phytium/{e2000d_aarch32 => pe2202_aarch32}/soc.c (100%) rename soc/phytium/{e2000d_aarch32 => pe2202_aarch32}/soc.h (100%) rename soc/phytium/{d2000_aarch32 => pe2202_aarch32}/soc.yml (53%) create mode 100644 soc/phytium/pe2204/CMakeLists.txt rename soc/phytium/{e2000q => pe2204}/Kconfig (89%) rename soc/phytium/{e2000q => pe2204}/Kconfig.defconfig (96%) rename soc/phytium/{e2000d => pe2204}/Kconfig.soc (94%) rename soc/phytium/{e2000q => pe2204}/mmu_regions.c (100%) create mode 100644 soc/phytium/pe2204/pinctrl_soc.h rename soc/phytium/{e2000q => pe2204}/soc.c (100%) create mode 100644 soc/phytium/pe2204/soc.yml rename soc/phytium/{e2000q_aarch32 => pe2204_aarch32}/CMakeLists.txt (100%) rename soc/phytium/{e2000q_aarch32 => pe2204_aarch32}/Kconfig (88%) rename soc/phytium/{e2000q_aarch32 => pe2204_aarch32}/Kconfig.defconfig (94%) rename soc/phytium/{e2000d_aarch32 => pe2204_aarch32}/Kconfig.soc (91%) create mode 100644 soc/phytium/pe2204_aarch32/pinctrl_soc.h rename soc/phytium/{e2000q_aarch32 => pe2204_aarch32}/soc.c (100%) rename soc/phytium/{e2000q_aarch32 => pe2204_aarch32}/soc.h (100%) rename soc/phytium/{e2000d_aarch32 => pe2204_aarch32}/soc.yml (53%) diff --git a/boards/deprecated.cmake b/boards/deprecated.cmake index d4da93c66d8..01d6d40e215 100644 --- a/boards/deprecated.cmake +++ b/boards/deprecated.cmake @@ -904,39 +904,39 @@ set(yd_esp32_DEPRECATED ) set(e2000d_demo_smp_DEPRECATED - e2000d_demo/e2000d/smp + e2000d_demo/pe2202/smp ) set(e2000d_demo_el2_DEPRECATED - e2000d_demo/e2000d/el2 + e2000d_demo/pe2202/el2 ) set(e2000d_demo_el2_smp_DEPRECATED - e2000d_demo/e2000d/el2/smp + e2000d_demo/pe2202/el2/smp ) set(e2000q_demo_smp_DEPRECATED - e2000q_demo/e2000q/smp + e2000q_demo/pe2204/smp ) set(e2000q_demo_el2_DEPRECATED - e2000q_demo/e2000q/el2 + e2000q_demo/pe2204/el2 ) set(e2000q_demo_el2_smp_DEPRECATED - e2000q_demo/e2000q/el2/smp + e2000q_demo/pe2204/el2/smp ) set(d2000_demo_smp_DEPRECATED - d2000_demo/d2000/smp + d2000_demo/pd2008/smp ) set(d2000_demo_el2_DEPRECATED - d2000_demo/d2000/el2 + d2000_demo/pd2008/el2 ) set(d2000_demo_el2_smp_DEPRECATED - d2000_demo/d2000/el2/smp + d2000_demo/pd2008/el2/smp ) set(pd2308_demo_smp_DEPRECATED @@ -963,3 +963,26 @@ set(ps2316_test_el2_smp_DEPRECATED ps2316_test/ps2316/el2/smp ) +set(pd2408_test_a_smp_DEPRECATED + pd2408_test_a/pd2408/smp +) + +set(pd2408_test_a_el2_DEPRECATED + pd2408_test_a/pd2408/el2 +) + +set(pd2408_test_a_el2_smp_DEPRECATED + pd2408_test_a/pd2408/el2/smp +) + +set(pd2408_test_b_smp_DEPRECATED + pd2408_test_b/pd2408/smp +) + +set(pd2408_test_b_el2_DEPRECATED + pd2408_test_b/pd2408/el2 +) + +set(pd2408_test_b_el2_smp_DEPRECATED + pd2408_test_b/pd2408/el2/smp +) diff --git a/boards/phytium/d2000_aarch32_demo/Kconfig.d2000_aarch32_demo b/boards/phytium/d2000_aarch32_demo/Kconfig.d2000_aarch32_demo index 9c41344e237..ffc4c7cf907 100644 --- a/boards/phytium/d2000_aarch32_demo/Kconfig.d2000_aarch32_demo +++ b/boards/phytium/d2000_aarch32_demo/Kconfig.d2000_aarch32_demo @@ -15,4 +15,4 @@ config BOARD_D2000_AARCH32_DEMO bool "phytium D2000 aarch32" - select SOC_D2000_AARCH32 \ No newline at end of file + select SOC_PD2008_AARCH32 \ No newline at end of file diff --git a/boards/phytium/d2000_aarch32_demo/board.yml b/boards/phytium/d2000_aarch32_demo/board.yml index 3c959d9b142..27eaf1b2255 100644 --- a/boards/phytium/d2000_aarch32_demo/board.yml +++ b/boards/phytium/d2000_aarch32_demo/board.yml @@ -2,5 +2,5 @@ board: name: d2000_aarch32_demo vendor: phytium socs: - - name: d2000_aarch32 + - name: pd2008_aarch32 diff --git a/boards/phytium/d2000_aarch32_demo/d2000_aarch32_demo.dts b/boards/phytium/d2000_aarch32_demo/d2000_aarch32_demo.dts index ab878ada57f..43529d289c0 100644 --- a/boards/phytium/d2000_aarch32_demo/d2000_aarch32_demo.dts +++ b/boards/phytium/d2000_aarch32_demo/d2000_aarch32_demo.dts @@ -5,7 +5,7 @@ */ /dts-v1/; -#include +#include / { model = "Phytium d2000 demo"; diff --git a/boards/phytium/d2000_aarch32_demo/d2000_aarch32_demo_defconfig b/boards/phytium/d2000_aarch32_demo/d2000_aarch32_demo_defconfig index c5ef03f680d..a96402d4b33 100644 --- a/boards/phytium/d2000_aarch32_demo/d2000_aarch32_demo_defconfig +++ b/boards/phytium/d2000_aarch32_demo/d2000_aarch32_demo_defconfig @@ -1,4 +1,4 @@ -CONFIG_SOC_D2000_AARCH32=y +CONFIG_SOC_PD2008_AARCH32=y CONFIG_BOARD_D2000_AARCH32_DEMO=y diff --git a/boards/phytium/d2000_demo/Kconfig.d2000_demo b/boards/phytium/d2000_demo/Kconfig.d2000_demo index e11315682ce..8f7b2d81780 100644 --- a/boards/phytium/d2000_demo/Kconfig.d2000_demo +++ b/boards/phytium/d2000_demo/Kconfig.d2000_demo @@ -15,4 +15,4 @@ config BOARD_D2000_DEMO bool "phytium d2000" - select SOC_D2000 + select SOC_PD2008 diff --git a/boards/phytium/d2000_demo/board.yml b/boards/phytium/d2000_demo/board.yml index 132e76d256f..4e0dfb76135 100644 --- a/boards/phytium/d2000_demo/board.yml +++ b/boards/phytium/d2000_demo/board.yml @@ -2,7 +2,7 @@ board: name: d2000_demo vendor: phytium socs: - - name: d2000 + - name: pd2008 variants: - name: smp - name: el2 diff --git a/boards/phytium/d2000_demo/d2000_demo.dts b/boards/phytium/d2000_demo/d2000_demo.dts index 480f94e0794..118d0225a55 100644 --- a/boards/phytium/d2000_demo/d2000_demo.dts +++ b/boards/phytium/d2000_demo/d2000_demo.dts @@ -5,7 +5,7 @@ */ /dts-v1/; -#include +#include / { model = "Phytium d2000 demo"; diff --git a/boards/phytium/d2000_demo/d2000_demo_d2000_defconfig b/boards/phytium/d2000_demo/d2000_demo_pd2008_defconfig similarity index 86% rename from boards/phytium/d2000_demo/d2000_demo_d2000_defconfig rename to boards/phytium/d2000_demo/d2000_demo_pd2008_defconfig index f816f41440e..23ad632a796 100644 --- a/boards/phytium/d2000_demo/d2000_demo_d2000_defconfig +++ b/boards/phytium/d2000_demo/d2000_demo_pd2008_defconfig @@ -27,7 +27,3 @@ CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME=y #cache CONFIG_CACHE_MANAGEMENT=y - -# PSCI is supported with NS -CONFIG_PM_CPU_OPS=y -CONFIG_PM_CPU_OPS_PSCI=y diff --git a/boards/phytium/d2000_demo/d2000_demo_d2000_el2.dts b/boards/phytium/d2000_demo/d2000_demo_pd2008_el2.dts similarity index 95% rename from boards/phytium/d2000_demo/d2000_demo_d2000_el2.dts rename to boards/phytium/d2000_demo/d2000_demo_pd2008_el2.dts index 480f94e0794..118d0225a55 100644 --- a/boards/phytium/d2000_demo/d2000_demo_d2000_el2.dts +++ b/boards/phytium/d2000_demo/d2000_demo_pd2008_el2.dts @@ -5,7 +5,7 @@ */ /dts-v1/; -#include +#include / { model = "Phytium d2000 demo"; diff --git a/boards/phytium/d2000_demo/d2000_demo_d2000_el2.yaml b/boards/phytium/d2000_demo/d2000_demo_pd2008_el2.yaml similarity index 100% rename from boards/phytium/d2000_demo/d2000_demo_d2000_el2.yaml rename to boards/phytium/d2000_demo/d2000_demo_pd2008_el2.yaml diff --git a/boards/phytium/d2000_demo/d2000_demo_d2000_el2_defconfig b/boards/phytium/d2000_demo/d2000_demo_pd2008_el2_defconfig similarity index 86% rename from boards/phytium/d2000_demo/d2000_demo_d2000_el2_defconfig rename to boards/phytium/d2000_demo/d2000_demo_pd2008_el2_defconfig index 0d19db0fb29..6a7fc9d29a1 100644 --- a/boards/phytium/d2000_demo/d2000_demo_d2000_el2_defconfig +++ b/boards/phytium/d2000_demo/d2000_demo_pd2008_el2_defconfig @@ -28,9 +28,5 @@ CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME=y #cache CONFIG_CACHE_MANAGEMENT=y -# PSCI is supported with NS -CONFIG_PM_CPU_OPS=y -CONFIG_PM_CPU_OPS_PSCI=y - # EL2 CONFIG_USE_EL2=y diff --git a/boards/phytium/d2000_demo/d2000_demo_d2000_smp.dts b/boards/phytium/d2000_demo/d2000_demo_pd2008_el2_smp.dts similarity index 95% rename from boards/phytium/d2000_demo/d2000_demo_d2000_smp.dts rename to boards/phytium/d2000_demo/d2000_demo_pd2008_el2_smp.dts index 73e7666abcc..39c3082fc60 100644 --- a/boards/phytium/d2000_demo/d2000_demo_d2000_smp.dts +++ b/boards/phytium/d2000_demo/d2000_demo_pd2008_el2_smp.dts @@ -6,7 +6,7 @@ /dts-v1/; -#include +#include / { model = "Phytium d2000 demo"; compatible = "phytium,d2000-demo", "phytium,d2000"; diff --git a/boards/phytium/d2000_demo/d2000_demo_d2000_el2_smp.yaml b/boards/phytium/d2000_demo/d2000_demo_pd2008_el2_smp.yaml similarity index 100% rename from boards/phytium/d2000_demo/d2000_demo_d2000_el2_smp.yaml rename to boards/phytium/d2000_demo/d2000_demo_pd2008_el2_smp.yaml diff --git a/boards/phytium/d2000_demo/d2000_demo_d2000_el2_smp_defconfig b/boards/phytium/d2000_demo/d2000_demo_pd2008_el2_smp_defconfig similarity index 100% rename from boards/phytium/d2000_demo/d2000_demo_d2000_el2_smp_defconfig rename to boards/phytium/d2000_demo/d2000_demo_pd2008_el2_smp_defconfig diff --git a/boards/phytium/d2000_demo/d2000_demo_d2000_el2_smp.dts b/boards/phytium/d2000_demo/d2000_demo_pd2008_smp.dts similarity index 95% rename from boards/phytium/d2000_demo/d2000_demo_d2000_el2_smp.dts rename to boards/phytium/d2000_demo/d2000_demo_pd2008_smp.dts index 73e7666abcc..39c3082fc60 100644 --- a/boards/phytium/d2000_demo/d2000_demo_d2000_el2_smp.dts +++ b/boards/phytium/d2000_demo/d2000_demo_pd2008_smp.dts @@ -6,7 +6,7 @@ /dts-v1/; -#include +#include / { model = "Phytium d2000 demo"; compatible = "phytium,d2000-demo", "phytium,d2000"; diff --git a/boards/phytium/d2000_demo/d2000_demo_d2000_smp.yaml b/boards/phytium/d2000_demo/d2000_demo_pd2008_smp.yaml similarity index 100% rename from boards/phytium/d2000_demo/d2000_demo_d2000_smp.yaml rename to boards/phytium/d2000_demo/d2000_demo_pd2008_smp.yaml diff --git a/boards/phytium/d2000_demo/d2000_demo_d2000_smp_defconfig b/boards/phytium/d2000_demo/d2000_demo_pd2008_smp_defconfig similarity index 100% rename from boards/phytium/d2000_demo/d2000_demo_d2000_smp_defconfig rename to boards/phytium/d2000_demo/d2000_demo_pd2008_smp_defconfig diff --git a/boards/phytium/e2000d_aarch32_demo/Kconfig.e2000d_aarch32_demo b/boards/phytium/e2000d_aarch32_demo/Kconfig.e2000d_aarch32_demo index f8607de6e9e..1f81e5ab921 100644 --- a/boards/phytium/e2000d_aarch32_demo/Kconfig.e2000d_aarch32_demo +++ b/boards/phytium/e2000d_aarch32_demo/Kconfig.e2000d_aarch32_demo @@ -15,4 +15,4 @@ config BOARD_E2000D_AARCH32_DEMO bool "phytium e2000d aarch32" - select SOC_E2000D_AARCH32 \ No newline at end of file + select SOC_PE2202_AARCH32 \ No newline at end of file diff --git a/boards/phytium/e2000d_aarch32_demo/board.yml b/boards/phytium/e2000d_aarch32_demo/board.yml index e3e8513eea6..783de4876ba 100644 --- a/boards/phytium/e2000d_aarch32_demo/board.yml +++ b/boards/phytium/e2000d_aarch32_demo/board.yml @@ -2,4 +2,4 @@ board: name: e2000d_aarch32_demo vendor: phytium socs: - - name: e2000d_aarch32 + - name: pe2202_aarch32 diff --git a/boards/phytium/e2000d_aarch32_demo/e2000d_aarch32_demo.dts b/boards/phytium/e2000d_aarch32_demo/e2000d_aarch32_demo.dts index ca935d4a675..4c88b749bda 100644 --- a/boards/phytium/e2000d_aarch32_demo/e2000d_aarch32_demo.dts +++ b/boards/phytium/e2000d_aarch32_demo/e2000d_aarch32_demo.dts @@ -5,7 +5,7 @@ */ /dts-v1/; -#include +#include / { model = "Phytium e2000d aarch32 demo"; diff --git a/boards/phytium/e2000d_aarch32_demo/e2000d_aarch32_demo_defconfig b/boards/phytium/e2000d_aarch32_demo/e2000d_aarch32_demo_defconfig index 78dc87bd8fb..f5172782954 100644 --- a/boards/phytium/e2000d_aarch32_demo/e2000d_aarch32_demo_defconfig +++ b/boards/phytium/e2000d_aarch32_demo/e2000d_aarch32_demo_defconfig @@ -1,4 +1,4 @@ -CONFIG_SOC_E2000D_AARCH32=y +CONFIG_SOC_PE2202_AARCH32=y CONFIG_BOARD_E2000D_AARCH32_DEMO=y diff --git a/boards/phytium/e2000d_demo/Kconfig.e2000d_demo b/boards/phytium/e2000d_demo/Kconfig.e2000d_demo index 9050daa42cd..3a72cf44d26 100644 --- a/boards/phytium/e2000d_demo/Kconfig.e2000d_demo +++ b/boards/phytium/e2000d_demo/Kconfig.e2000d_demo @@ -15,4 +15,4 @@ config BOARD_E2000D_DEMO bool "phytium e2000d" - select SOC_E2000D + select SOC_PE2202 diff --git a/boards/phytium/e2000d_demo/board.yml b/boards/phytium/e2000d_demo/board.yml index c2e60a89b35..05d11e269b7 100644 --- a/boards/phytium/e2000d_demo/board.yml +++ b/boards/phytium/e2000d_demo/board.yml @@ -2,7 +2,7 @@ board: name: e2000d_demo vendor: phytium socs: - - name: e2000d + - name: pe2202 variants: - name: smp - name: el2 diff --git a/boards/phytium/e2000d_demo/e2000d_demo.dts b/boards/phytium/e2000d_demo/e2000d_demo.dts index e527c8d3e5d..a909f11309e 100644 --- a/boards/phytium/e2000d_demo/e2000d_demo.dts +++ b/boards/phytium/e2000d_demo/e2000d_demo.dts @@ -5,7 +5,8 @@ */ /dts-v1/; -#include +#include +#include "e2000d_demo_pinctrl.dtsi" / { model = "Phytium e2000d demo"; diff --git a/boards/phytium/e2000d_demo/e2000d_demo_defconfig b/boards/phytium/e2000d_demo/e2000d_demo_defconfig index e6578193dfa..1e8c182d8ff 100644 --- a/boards/phytium/e2000d_demo/e2000d_demo_defconfig +++ b/boards/phytium/e2000d_demo/e2000d_demo_defconfig @@ -27,7 +27,3 @@ CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME=y #cache CONFIG_CACHE_MANAGEMENT=y - -# PSCI is supported with NS -CONFIG_PM_CPU_OPS=y -CONFIG_PM_CPU_OPS_PSCI=y diff --git a/boards/phytium/e2000d_demo/e2000d_demo_e2000d_el2.dts b/boards/phytium/e2000d_demo/e2000d_demo_pe2202_el2.dts similarity index 90% rename from boards/phytium/e2000d_demo/e2000d_demo_e2000d_el2.dts rename to boards/phytium/e2000d_demo/e2000d_demo_pe2202_el2.dts index 6bed72d828f..ef8d6b06bba 100644 --- a/boards/phytium/e2000d_demo/e2000d_demo_e2000d_el2.dts +++ b/boards/phytium/e2000d_demo/e2000d_demo_pe2202_el2.dts @@ -5,7 +5,8 @@ */ /dts-v1/; -#include +#include +#include "e2000d_demo_pinctrl.dtsi" / { model = "Phytium e2000d demo"; diff --git a/boards/phytium/e2000d_demo/e2000d_demo_e2000d_el2.yaml b/boards/phytium/e2000d_demo/e2000d_demo_pe2202_el2.yaml similarity index 100% rename from boards/phytium/e2000d_demo/e2000d_demo_e2000d_el2.yaml rename to boards/phytium/e2000d_demo/e2000d_demo_pe2202_el2.yaml diff --git a/boards/phytium/e2000d_demo/e2000d_demo_e2000d_el2_defconfig b/boards/phytium/e2000d_demo/e2000d_demo_pe2202_el2_defconfig similarity index 86% rename from boards/phytium/e2000d_demo/e2000d_demo_e2000d_el2_defconfig rename to boards/phytium/e2000d_demo/e2000d_demo_pe2202_el2_defconfig index 4962f631bdd..01601d8dd9c 100644 --- a/boards/phytium/e2000d_demo/e2000d_demo_e2000d_el2_defconfig +++ b/boards/phytium/e2000d_demo/e2000d_demo_pe2202_el2_defconfig @@ -28,9 +28,5 @@ CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME=y #cache CONFIG_CACHE_MANAGEMENT=y -# PSCI is supported with NS -CONFIG_PM_CPU_OPS=y -CONFIG_PM_CPU_OPS_PSCI=y - # el2 CONFIG_USE_EL2=y diff --git a/boards/phytium/e2000d_demo/e2000d_demo_e2000d_el2_smp.dts b/boards/phytium/e2000d_demo/e2000d_demo_pe2202_el2_smp.dts similarity index 91% rename from boards/phytium/e2000d_demo/e2000d_demo_e2000d_el2_smp.dts rename to boards/phytium/e2000d_demo/e2000d_demo_pe2202_el2_smp.dts index 8420f7fd427..5aa64e45aa5 100644 --- a/boards/phytium/e2000d_demo/e2000d_demo_e2000d_el2_smp.dts +++ b/boards/phytium/e2000d_demo/e2000d_demo_pe2202_el2_smp.dts @@ -6,7 +6,9 @@ /dts-v1/; -#include +#include +#include "e2000d_demo_pinctrl.dtsi" + / { model = "Phytium e2000d demo"; compatible = "phytium,e2000d-demo", "phytium,e2000d"; diff --git a/boards/phytium/e2000d_demo/e2000d_demo_e2000d_el2_smp.yaml b/boards/phytium/e2000d_demo/e2000d_demo_pe2202_el2_smp.yaml similarity index 100% rename from boards/phytium/e2000d_demo/e2000d_demo_e2000d_el2_smp.yaml rename to boards/phytium/e2000d_demo/e2000d_demo_pe2202_el2_smp.yaml diff --git a/boards/phytium/e2000d_demo/e2000d_demo_e2000d_el2_smp_defconfig b/boards/phytium/e2000d_demo/e2000d_demo_pe2202_el2_smp_defconfig similarity index 100% rename from boards/phytium/e2000d_demo/e2000d_demo_e2000d_el2_smp_defconfig rename to boards/phytium/e2000d_demo/e2000d_demo_pe2202_el2_smp_defconfig diff --git a/boards/phytium/e2000d_demo/e2000d_demo_e2000d_smp.dts b/boards/phytium/e2000d_demo/e2000d_demo_pe2202_smp.dts similarity index 91% rename from boards/phytium/e2000d_demo/e2000d_demo_e2000d_smp.dts rename to boards/phytium/e2000d_demo/e2000d_demo_pe2202_smp.dts index 8420f7fd427..d26e3c6ecf1 100644 --- a/boards/phytium/e2000d_demo/e2000d_demo_e2000d_smp.dts +++ b/boards/phytium/e2000d_demo/e2000d_demo_pe2202_smp.dts @@ -5,8 +5,9 @@ */ /dts-v1/; +#include +#include "e2000d_demo_pinctrl.dtsi" -#include / { model = "Phytium e2000d demo"; compatible = "phytium,e2000d-demo", "phytium,e2000d"; diff --git a/boards/phytium/e2000d_demo/e2000d_demo_e2000d_smp.yaml b/boards/phytium/e2000d_demo/e2000d_demo_pe2202_smp.yaml similarity index 100% rename from boards/phytium/e2000d_demo/e2000d_demo_e2000d_smp.yaml rename to boards/phytium/e2000d_demo/e2000d_demo_pe2202_smp.yaml diff --git a/boards/phytium/e2000d_demo/e2000d_demo_e2000d_smp_defconfig b/boards/phytium/e2000d_demo/e2000d_demo_pe2202_smp_defconfig similarity index 100% rename from boards/phytium/e2000d_demo/e2000d_demo_e2000d_smp_defconfig rename to boards/phytium/e2000d_demo/e2000d_demo_pe2202_smp_defconfig diff --git a/boards/phytium/e2000d_demo/e2000d_demo_pinctrl.dtsi b/boards/phytium/e2000d_demo/e2000d_demo_pinctrl.dtsi new file mode 100644 index 00000000000..cb1fd77213b --- /dev/null +++ b/boards/phytium/e2000d_demo/e2000d_demo_pinctrl.dtsi @@ -0,0 +1,19 @@ + + +#include + +&pinctrl { + uart1_rx_default: uart1_rx_default { + pinmux = ; + }; + uart1_tx_default: uart1_tx_default { + pinmux = ; + }; + + uart2_rx_default: uart2_rx_default { + pinmux = ; + }; + uart2_tx_default: uart2_tx_default { + pinmux = ; + }; +}; \ No newline at end of file diff --git a/boards/phytium/e2000q_aarch32_demo/Kconfig.e2000q_aarch32_demo b/boards/phytium/e2000q_aarch32_demo/Kconfig.e2000q_aarch32_demo index 4a6e2c812de..6706147b560 100644 --- a/boards/phytium/e2000q_aarch32_demo/Kconfig.e2000q_aarch32_demo +++ b/boards/phytium/e2000q_aarch32_demo/Kconfig.e2000q_aarch32_demo @@ -15,4 +15,4 @@ config BOARD_E2000Q_AARCH32_DEMO bool "phytium e2000q aarch32" - select SOC_E2000Q_AARCH32 \ No newline at end of file + select SOC_PE2204_AARCH32 \ No newline at end of file diff --git a/boards/phytium/e2000q_aarch32_demo/board.yml b/boards/phytium/e2000q_aarch32_demo/board.yml index 7b1ecd8cdab..ccba83529ee 100644 --- a/boards/phytium/e2000q_aarch32_demo/board.yml +++ b/boards/phytium/e2000q_aarch32_demo/board.yml @@ -2,4 +2,4 @@ board: name: e2000q_aarch32_demo vendor: phytium socs: - - name: e2000q_aarch32 + - name: pe2204_aarch32 diff --git a/boards/phytium/e2000q_aarch32_demo/e2000q_aarch32_demo.dts b/boards/phytium/e2000q_aarch32_demo/e2000q_aarch32_demo.dts index e61fc533f3c..7b0eb4d46d3 100644 --- a/boards/phytium/e2000q_aarch32_demo/e2000q_aarch32_demo.dts +++ b/boards/phytium/e2000q_aarch32_demo/e2000q_aarch32_demo.dts @@ -5,7 +5,7 @@ */ /dts-v1/; -#include +#include / { model = "Phytium e2000q demo"; diff --git a/boards/phytium/e2000q_aarch32_demo/e2000q_aarch32_demo_defconfig b/boards/phytium/e2000q_aarch32_demo/e2000q_aarch32_demo_defconfig index f667a09b182..f8ded46085d 100644 --- a/boards/phytium/e2000q_aarch32_demo/e2000q_aarch32_demo_defconfig +++ b/boards/phytium/e2000q_aarch32_demo/e2000q_aarch32_demo_defconfig @@ -1,4 +1,4 @@ -CONFIG_SOC_E2000Q_AARCH32=y +CONFIG_SOC_PE2204_AARCH32=y CONFIG_BOARD_E2000Q_AARCH32_DEMO=y diff --git a/boards/phytium/e2000q_demo/Kconfig.e2000q_demo b/boards/phytium/e2000q_demo/Kconfig.e2000q_demo index 8168955e270..154f282ec13 100644 --- a/boards/phytium/e2000q_demo/Kconfig.e2000q_demo +++ b/boards/phytium/e2000q_demo/Kconfig.e2000q_demo @@ -14,5 +14,5 @@ # specific language governing permissions and limitations under the License. config BOARD_E2000Q_DEMO - bool "phytium e2000q" - select SOC_E2000Q + bool "phytium e2000q demo" + select SOC_PE2204 diff --git a/boards/phytium/e2000q_demo/board.yml b/boards/phytium/e2000q_demo/board.yml index 2156ebade2e..f1a589959f6 100644 --- a/boards/phytium/e2000q_demo/board.yml +++ b/boards/phytium/e2000q_demo/board.yml @@ -2,7 +2,7 @@ board: name: e2000q_demo vendor: phytium socs: - - name: e2000q + - name: pe2204 variants: - name: smp - name: el2 diff --git a/boards/phytium/e2000q_demo/e2000q_demo.dts b/boards/phytium/e2000q_demo/e2000q_demo.dts index fa1f8c82355..baaa0dce370 100644 --- a/boards/phytium/e2000q_demo/e2000q_demo.dts +++ b/boards/phytium/e2000q_demo/e2000q_demo.dts @@ -5,8 +5,8 @@ */ /dts-v1/; -#include -#include "e2000q_pinctrl.dtsi" +#include +#include "e2000q_demo_pinctrl.dtsi" / { model = "Phytium e2000q demo"; diff --git a/boards/phytium/e2000q_demo/e2000q_demo_defconfig b/boards/phytium/e2000q_demo/e2000q_demo_defconfig index e6578193dfa..1e8c182d8ff 100644 --- a/boards/phytium/e2000q_demo/e2000q_demo_defconfig +++ b/boards/phytium/e2000q_demo/e2000q_demo_defconfig @@ -27,7 +27,3 @@ CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME=y #cache CONFIG_CACHE_MANAGEMENT=y - -# PSCI is supported with NS -CONFIG_PM_CPU_OPS=y -CONFIG_PM_CPU_OPS_PSCI=y diff --git a/boards/phytium/e2000q_demo/e2000q_demo_e2000q_el2.dts b/boards/phytium/e2000q_demo/e2000q_demo_pe2204_el2.dts similarity index 92% rename from boards/phytium/e2000q_demo/e2000q_demo_e2000q_el2.dts rename to boards/phytium/e2000q_demo/e2000q_demo_pe2204_el2.dts index 50dfaa539bc..c021b5097ec 100644 --- a/boards/phytium/e2000q_demo/e2000q_demo_e2000q_el2.dts +++ b/boards/phytium/e2000q_demo/e2000q_demo_pe2204_el2.dts @@ -5,8 +5,8 @@ */ /dts-v1/; -#include -#include "e2000q_pinctrl.dtsi" +#include +#include "e2000q_demo_pinctrl.dtsi" / { model = "Phytium e2000q demo"; diff --git a/boards/phytium/e2000q_demo/e2000q_demo_e2000q_el2.yaml b/boards/phytium/e2000q_demo/e2000q_demo_pe2204_el2.yaml similarity index 100% rename from boards/phytium/e2000q_demo/e2000q_demo_e2000q_el2.yaml rename to boards/phytium/e2000q_demo/e2000q_demo_pe2204_el2.yaml diff --git a/boards/phytium/e2000q_demo/e2000q_demo_e2000q_el2_defconfig b/boards/phytium/e2000q_demo/e2000q_demo_pe2204_el2_defconfig similarity index 86% rename from boards/phytium/e2000q_demo/e2000q_demo_e2000q_el2_defconfig rename to boards/phytium/e2000q_demo/e2000q_demo_pe2204_el2_defconfig index 0d19db0fb29..6a7fc9d29a1 100644 --- a/boards/phytium/e2000q_demo/e2000q_demo_e2000q_el2_defconfig +++ b/boards/phytium/e2000q_demo/e2000q_demo_pe2204_el2_defconfig @@ -28,9 +28,5 @@ CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME=y #cache CONFIG_CACHE_MANAGEMENT=y -# PSCI is supported with NS -CONFIG_PM_CPU_OPS=y -CONFIG_PM_CPU_OPS_PSCI=y - # EL2 CONFIG_USE_EL2=y diff --git a/boards/phytium/e2000q_demo/e2000q_demo_e2000q_smp.dts b/boards/phytium/e2000q_demo/e2000q_demo_pe2204_el2_smp.dts similarity index 91% rename from boards/phytium/e2000q_demo/e2000q_demo_e2000q_smp.dts rename to boards/phytium/e2000q_demo/e2000q_demo_pe2204_el2_smp.dts index 3b829e76720..1520fc809c3 100644 --- a/boards/phytium/e2000q_demo/e2000q_demo_e2000q_smp.dts +++ b/boards/phytium/e2000q_demo/e2000q_demo_pe2204_el2_smp.dts @@ -6,7 +6,9 @@ /dts-v1/; -#include +#include +#include "e2000q_demo_pinctrl.dtsi" + / { model = "Phytium e2000q demo"; compatible = "phytium,e2000q-demo", "phytium,e2000q"; diff --git a/boards/phytium/e2000q_demo/e2000q_demo_e2000q_el2_smp.yaml b/boards/phytium/e2000q_demo/e2000q_demo_pe2204_el2_smp.yaml similarity index 100% rename from boards/phytium/e2000q_demo/e2000q_demo_e2000q_el2_smp.yaml rename to boards/phytium/e2000q_demo/e2000q_demo_pe2204_el2_smp.yaml diff --git a/boards/phytium/e2000q_demo/e2000q_demo_e2000q_el2_smp_defconfig b/boards/phytium/e2000q_demo/e2000q_demo_pe2204_el2_smp_defconfig similarity index 100% rename from boards/phytium/e2000q_demo/e2000q_demo_e2000q_el2_smp_defconfig rename to boards/phytium/e2000q_demo/e2000q_demo_pe2204_el2_smp_defconfig diff --git a/boards/phytium/e2000q_demo/e2000q_demo_e2000q_el2_smp.dts b/boards/phytium/e2000q_demo/e2000q_demo_pe2204_smp.dts similarity index 91% rename from boards/phytium/e2000q_demo/e2000q_demo_e2000q_el2_smp.dts rename to boards/phytium/e2000q_demo/e2000q_demo_pe2204_smp.dts index 3b829e76720..1520fc809c3 100644 --- a/boards/phytium/e2000q_demo/e2000q_demo_e2000q_el2_smp.dts +++ b/boards/phytium/e2000q_demo/e2000q_demo_pe2204_smp.dts @@ -6,7 +6,9 @@ /dts-v1/; -#include +#include +#include "e2000q_demo_pinctrl.dtsi" + / { model = "Phytium e2000q demo"; compatible = "phytium,e2000q-demo", "phytium,e2000q"; diff --git a/boards/phytium/e2000q_demo/e2000q_demo_e2000q_smp.yaml b/boards/phytium/e2000q_demo/e2000q_demo_pe2204_smp.yaml similarity index 100% rename from boards/phytium/e2000q_demo/e2000q_demo_e2000q_smp.yaml rename to boards/phytium/e2000q_demo/e2000q_demo_pe2204_smp.yaml diff --git a/boards/phytium/e2000q_demo/e2000q_demo_e2000q_smp_defconfig b/boards/phytium/e2000q_demo/e2000q_demo_pe2204_smp_defconfig similarity index 100% rename from boards/phytium/e2000q_demo/e2000q_demo_e2000q_smp_defconfig rename to boards/phytium/e2000q_demo/e2000q_demo_pe2204_smp_defconfig diff --git a/boards/phytium/e2000q_demo/e2000q_pinctrl.dtsi b/boards/phytium/e2000q_demo/e2000q_demo_pinctrl.dtsi similarity index 87% rename from boards/phytium/e2000q_demo/e2000q_pinctrl.dtsi rename to boards/phytium/e2000q_demo/e2000q_demo_pinctrl.dtsi index c72996bb7fd..3fedac477b0 100644 --- a/boards/phytium/e2000q_demo/e2000q_pinctrl.dtsi +++ b/boards/phytium/e2000q_demo/e2000q_demo_pinctrl.dtsi @@ -1,6 +1,6 @@ -#include +#include &pinctrl { uart1_rx_default: uart1_rx_default { diff --git a/boards/phytium/pd2308_demo/pd2308_demo_defconfig b/boards/phytium/pd2308_demo/pd2308_demo_defconfig index f816f41440e..23ad632a796 100644 --- a/boards/phytium/pd2308_demo/pd2308_demo_defconfig +++ b/boards/phytium/pd2308_demo/pd2308_demo_defconfig @@ -27,7 +27,3 @@ CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME=y #cache CONFIG_CACHE_MANAGEMENT=y - -# PSCI is supported with NS -CONFIG_PM_CPU_OPS=y -CONFIG_PM_CPU_OPS_PSCI=y diff --git a/boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2.dts b/boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2.dts index 6204d8b94e4..44daa234029 100644 --- a/boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2.dts +++ b/boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2.dts @@ -22,7 +22,7 @@ chosen { }; }; -&sdhc1 { +&sdhc0 { status = "okay"; sdmmc { compatible = "zephyr,sdmmc-disk"; diff --git a/boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2_defconfig b/boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2_defconfig index 0d19db0fb29..6a7fc9d29a1 100644 --- a/boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2_defconfig +++ b/boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2_defconfig @@ -28,9 +28,5 @@ CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME=y #cache CONFIG_CACHE_MANAGEMENT=y -# PSCI is supported with NS -CONFIG_PM_CPU_OPS=y -CONFIG_PM_CPU_OPS_PSCI=y - # EL2 CONFIG_USE_EL2=y diff --git a/boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2_smp.dts b/boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2_smp.dts index 6204d8b94e4..44daa234029 100644 --- a/boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2_smp.dts +++ b/boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2_smp.dts @@ -22,7 +22,7 @@ chosen { }; }; -&sdhc1 { +&sdhc0 { status = "okay"; sdmmc { compatible = "zephyr,sdmmc-disk"; diff --git a/boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2_smp.yaml b/boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2_smp.yaml index 1e720bf6ed1..4dbd7da1a8f 100644 --- a/boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2_smp.yaml +++ b/boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2_smp.yaml @@ -1,5 +1,5 @@ identifier: pd2308_demo/pd2308/el2/smp -name: Phytium d2000 demo +name: Phytium pd2308 demo type: mcu arch: arm64 toolchain: diff --git a/boards/phytium/pd2308_demo/pd2308_demo_pd2308_smp.dts b/boards/phytium/pd2308_demo/pd2308_demo_pd2308_smp.dts index 5ee587b1fa1..4d8507663f6 100644 --- a/boards/phytium/pd2308_demo/pd2308_demo_pd2308_smp.dts +++ b/boards/phytium/pd2308_demo/pd2308_demo_pd2308_smp.dts @@ -28,7 +28,7 @@ chosen { }; }; -&sdhc1 { +&sdhc0 { status = "okay"; sdmmc { compatible = "zephyr,sdmmc-disk"; diff --git a/boards/phytium/pd2408_test_a/Kconfig.defconfig b/boards/phytium/pd2408_test_a/Kconfig.defconfig new file mode 100644 index 00000000000..bcc66bf6771 --- /dev/null +++ b/boards/phytium/pd2408_test_a/Kconfig.defconfig @@ -0,0 +1,19 @@ +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +# +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# https://opensource.org/license/apache-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. + + +config BOARD + default "Phytium pd2408 test a" + depends on BOARD_PD2408_TEST_A diff --git a/boards/phytium/pd2408_test_a/Kconfig.pd2408_test_a b/boards/phytium/pd2408_test_a/Kconfig.pd2408_test_a new file mode 100644 index 00000000000..01c209b5b64 --- /dev/null +++ b/boards/phytium/pd2408_test_a/Kconfig.pd2408_test_a @@ -0,0 +1,18 @@ +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +# +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# https://opensource.org/license/apache-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. + +config BOARD_PD2408_TEST_A + bool "phytium pd2408" + select SOC_PD2408 diff --git a/boards/phytium/pd2408_test_a/board.cmake b/boards/phytium/pd2408_test_a/board.cmake new file mode 100644 index 00000000000..9881313609a --- /dev/null +++ b/boards/phytium/pd2408_test_a/board.cmake @@ -0,0 +1 @@ +# SPDX-License-Identifier: Apache-2.0 diff --git a/boards/phytium/pd2408_test_a/board.yml b/boards/phytium/pd2408_test_a/board.yml new file mode 100644 index 00000000000..868e2d9cf3f --- /dev/null +++ b/boards/phytium/pd2408_test_a/board.yml @@ -0,0 +1,10 @@ +board: + name: pd2408_test_a + vendor: phytium + socs: + - name: pd2408 + variants: + - name: smp + - name: el2 + variants: + - name: smp diff --git a/boards/phytium/pd2408_test_a/pd2408_test_a.dts b/boards/phytium/pd2408_test_a/pd2408_test_a.dts new file mode 100644 index 00000000000..a102bd04b2b --- /dev/null +++ b/boards/phytium/pd2408_test_a/pd2408_test_a.dts @@ -0,0 +1,34 @@ +/* + * Copyright 2024 zhangyan + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; +#include +#include "pd2408_test_a_pinctrl.dtsi" + +/ { + model = "Phytium pd2408 test a"; + compatible = "phytium,pd2408-test-a", "phytium,pd2408"; + #address-cells = <2>; + #size-cells = <2>; + +chosen { + zephyr,console = &uart1; + zephyr,shell-uart = &uart1; + zephyr,sram = &sram0; + zephyr,pcie-controller = &pcie0; + }; +}; + +&uart1 { + current-speed = <115200>; + pinctrl-0 = <&uart1_rx_default &uart1_tx_default>; + pinctrl-names = "default"; + status = "okay"; +}; + +&pcie0 { + status = "okay"; +}; diff --git a/boards/phytium/pd2408_test_a/pd2408_test_a.yaml b/boards/phytium/pd2408_test_a/pd2408_test_a.yaml new file mode 100644 index 00000000000..bd83dc786cb --- /dev/null +++ b/boards/phytium/pd2408_test_a/pd2408_test_a.yaml @@ -0,0 +1,7 @@ +identifier: pd2408_test_a +name: Phytium pd2408 test a +type: mcu +arch: arm64 +toolchain: + - zephyr + - cross-compile diff --git a/boards/phytium/pd2408_test_a/pd2408_test_a_defconfig b/boards/phytium/pd2408_test_a/pd2408_test_a_defconfig new file mode 100644 index 00000000000..23ad632a796 --- /dev/null +++ b/boards/phytium/pd2408_test_a/pd2408_test_a_defconfig @@ -0,0 +1,29 @@ +# SPDX-License-Identifier: Apache-2.0 + +# Platform Configuration +CONFIG_ARM64_VA_BITS_42=y +CONFIG_ARM64_PA_BITS_42=y +# Main stack size +CONFIG_MAIN_STACK_SIZE=8192 + +CONFIG_ARMV8_A_NS=y + +# Zephyr Kernel Configuration +CONFIG_XIP=n +CONFIG_FLASH_SIZE=0 +CONFIG_FLASH_BASE_ADDRESS=0x0 + +# Serial Drivers +CONFIG_SERIAL=y + +# Enable Console +CONFIG_CONSOLE=y +CONFIG_UART_CONSOLE=y + + +# Timer Drivers +CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME=y + + +#cache +CONFIG_CACHE_MANAGEMENT=y diff --git a/boards/phytium/pd2408_test_a/pd2408_test_a_pd2408_el2.dts b/boards/phytium/pd2408_test_a/pd2408_test_a_pd2408_el2.dts new file mode 100644 index 00000000000..a102bd04b2b --- /dev/null +++ b/boards/phytium/pd2408_test_a/pd2408_test_a_pd2408_el2.dts @@ -0,0 +1,34 @@ +/* + * Copyright 2024 zhangyan + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; +#include +#include "pd2408_test_a_pinctrl.dtsi" + +/ { + model = "Phytium pd2408 test a"; + compatible = "phytium,pd2408-test-a", "phytium,pd2408"; + #address-cells = <2>; + #size-cells = <2>; + +chosen { + zephyr,console = &uart1; + zephyr,shell-uart = &uart1; + zephyr,sram = &sram0; + zephyr,pcie-controller = &pcie0; + }; +}; + +&uart1 { + current-speed = <115200>; + pinctrl-0 = <&uart1_rx_default &uart1_tx_default>; + pinctrl-names = "default"; + status = "okay"; +}; + +&pcie0 { + status = "okay"; +}; diff --git a/boards/phytium/pd2408_test_a/pd2408_test_a_pd2408_el2.yaml b/boards/phytium/pd2408_test_a/pd2408_test_a_pd2408_el2.yaml new file mode 100644 index 00000000000..3a8d9cc95a7 --- /dev/null +++ b/boards/phytium/pd2408_test_a/pd2408_test_a_pd2408_el2.yaml @@ -0,0 +1,7 @@ +identifier: pd2408_demo/pd2408/el2 +name: Phytium pd2408 demo +type: mcu +arch: arm64 +toolchain: + - zephyr + - cross-compile diff --git a/boards/phytium/pd2408_test_a/pd2408_test_a_pd2408_el2_defconfig b/boards/phytium/pd2408_test_a/pd2408_test_a_pd2408_el2_defconfig new file mode 100644 index 00000000000..6a7fc9d29a1 --- /dev/null +++ b/boards/phytium/pd2408_test_a/pd2408_test_a_pd2408_el2_defconfig @@ -0,0 +1,32 @@ +# SPDX-License-Identifier: Apache-2.0 + +# Platform Configuration +CONFIG_ARM64_VA_BITS_42=y +CONFIG_ARM64_PA_BITS_42=y +# Main stack size +CONFIG_MAIN_STACK_SIZE=4096 + +CONFIG_ARMV8_A_NS=y + +# Zephyr Kernel Configuration +CONFIG_XIP=n +CONFIG_FLASH_SIZE=0 +CONFIG_FLASH_BASE_ADDRESS=0x0 + +# Serial Drivers +CONFIG_SERIAL=y + +# Enable Console +CONFIG_CONSOLE=y +CONFIG_UART_CONSOLE=y + + +# Timer Drivers +CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME=y + + +#cache +CONFIG_CACHE_MANAGEMENT=y + +# EL2 +CONFIG_USE_EL2=y diff --git a/boards/phytium/pd2408_test_a/pd2408_test_a_pd2408_el2_smp.dts b/boards/phytium/pd2408_test_a/pd2408_test_a_pd2408_el2_smp.dts new file mode 100644 index 00000000000..a102bd04b2b --- /dev/null +++ b/boards/phytium/pd2408_test_a/pd2408_test_a_pd2408_el2_smp.dts @@ -0,0 +1,34 @@ +/* + * Copyright 2024 zhangyan + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; +#include +#include "pd2408_test_a_pinctrl.dtsi" + +/ { + model = "Phytium pd2408 test a"; + compatible = "phytium,pd2408-test-a", "phytium,pd2408"; + #address-cells = <2>; + #size-cells = <2>; + +chosen { + zephyr,console = &uart1; + zephyr,shell-uart = &uart1; + zephyr,sram = &sram0; + zephyr,pcie-controller = &pcie0; + }; +}; + +&uart1 { + current-speed = <115200>; + pinctrl-0 = <&uart1_rx_default &uart1_tx_default>; + pinctrl-names = "default"; + status = "okay"; +}; + +&pcie0 { + status = "okay"; +}; diff --git a/boards/phytium/pd2408_test_a/pd2408_test_a_pd2408_el2_smp.yaml b/boards/phytium/pd2408_test_a/pd2408_test_a_pd2408_el2_smp.yaml new file mode 100644 index 00000000000..a334fe4e5aa --- /dev/null +++ b/boards/phytium/pd2408_test_a/pd2408_test_a_pd2408_el2_smp.yaml @@ -0,0 +1,9 @@ +identifier: pd2408_test_a/pd2408/el2/smp +name: Phytium pd2408 test a +type: mcu +arch: arm64 +toolchain: + - zephyr + - cross-compile +supported: + - smp diff --git a/boards/phytium/pd2408_test_a/pd2408_test_a_pd2408_el2_smp_defconfig b/boards/phytium/pd2408_test_a/pd2408_test_a_pd2408_el2_smp_defconfig new file mode 100644 index 00000000000..e066e47dbe5 --- /dev/null +++ b/boards/phytium/pd2408_test_a/pd2408_test_a_pd2408_el2_smp_defconfig @@ -0,0 +1,44 @@ +# SPDX-License-Identifier: Apache-2.0 + +# Platform Configuration +CONFIG_ARM64_VA_BITS_42=y +CONFIG_ARM64_PA_BITS_42=y +# Main stack size +CONFIG_MAIN_STACK_SIZE=4096 + +CONFIG_ARMV8_A_NS=y + +# Zephyr Kernel Configuration +CONFIG_XIP=n +CONFIG_FLASH_SIZE=0 +CONFIG_FLASH_BASE_ADDRESS=0x0 + +# Serial Drivers +CONFIG_SERIAL=y + +# Enable Console +CONFIG_CONSOLE=y +CONFIG_UART_CONSOLE=y + +#cache +CONFIG_CACHE_MANAGEMENT=y + +# Timer Drivers +CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME=y + +# PSCI is supported with NS +CONFIG_PM_CPU_OPS=y +CONFIG_PM_CPU_OPS_PSCI=y + +# SMP-related +CONFIG_SMP=y +CONFIG_MP_MAX_NUM_CPUS=8 +CONFIG_TIMEOUT_64BIT=y + +# CONFIG_SHELL=y +# CONFIG_SHELL_BACKEND_SERIAL_INTERRUPT_DRIVEN=n +# CONFIG_SHELL_BACKEND_SERIAL_RX_POLL_PERIOD=1 +# CONFIG_BOOT_BANNER=n + +# EL2 +CONFIG_USE_EL2=y diff --git a/boards/phytium/pd2408_test_a/pd2408_test_a_pd2408_smp.dts b/boards/phytium/pd2408_test_a/pd2408_test_a_pd2408_smp.dts new file mode 100644 index 00000000000..07369b2b458 --- /dev/null +++ b/boards/phytium/pd2408_test_a/pd2408_test_a_pd2408_smp.dts @@ -0,0 +1,41 @@ +/* + * Copyright 2024 zhangyan + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; + +#include +#include "pd2408_test_a_pinctrl.dtsi" + +/ { + model = "Phytium pd2408 test a"; + compatible = "phytium,pd2408-test-a", "phytium,pd2408"; + #address-cells = <2>; + #size-cells = <2>; + + psci { + compatible = "arm,psci-0.2"; + method = "smc"; + }; + +chosen { + zephyr,console = &uart1; + zephyr,shell-uart = &uart1; + zephyr,sram = &sram0; + zephyr,pcie-controller = &pcie0; + }; +}; + +&uart1 { + current-speed = <115200>; + pinctrl-0 = <&uart1_rx_default &uart1_tx_default>; + pinctrl-names = "default"; + status = "okay"; +}; + +&pcie0 { + status = "okay"; +}; + diff --git a/boards/phytium/pd2408_test_a/pd2408_test_a_pd2408_smp.yaml b/boards/phytium/pd2408_test_a/pd2408_test_a_pd2408_smp.yaml new file mode 100644 index 00000000000..a76019e132c --- /dev/null +++ b/boards/phytium/pd2408_test_a/pd2408_test_a_pd2408_smp.yaml @@ -0,0 +1,9 @@ +identifier: pd2408_test_a/pd2408/smp +name: Phytium pd2408 test a +type: mcu +arch: arm64 +toolchain: + - zephyr + - cross-compile +supported: + - smp \ No newline at end of file diff --git a/boards/phytium/pd2408_test_a/pd2408_test_a_pd2408_smp_defconfig b/boards/phytium/pd2408_test_a/pd2408_test_a_pd2408_smp_defconfig new file mode 100644 index 00000000000..2896228ec7e --- /dev/null +++ b/boards/phytium/pd2408_test_a/pd2408_test_a_pd2408_smp_defconfig @@ -0,0 +1,41 @@ +# SPDX-License-Identifier: Apache-2.0 + +# Platform Configuration +CONFIG_ARM64_VA_BITS_42=y +CONFIG_ARM64_PA_BITS_42=y +# Main stack size +CONFIG_MAIN_STACK_SIZE=4096 + +CONFIG_ARMV8_A_NS=y + +# Zephyr Kernel Configuration +CONFIG_XIP=n +CONFIG_FLASH_SIZE=0 +CONFIG_FLASH_BASE_ADDRESS=0x0 + +# Serial Drivers +CONFIG_SERIAL=y + +# Enable Console +CONFIG_CONSOLE=y +CONFIG_UART_CONSOLE=y + +#cache +CONFIG_CACHE_MANAGEMENT=y + +# Timer Drivers +CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME=y + +# PSCI is supported with NS +CONFIG_PM_CPU_OPS=y +CONFIG_PM_CPU_OPS_PSCI=y + +# SMP-related +CONFIG_SMP=y +CONFIG_MP_MAX_NUM_CPUS=8 +CONFIG_TIMEOUT_64BIT=y + +# CONFIG_SHELL=y +# CONFIG_SHELL_BACKEND_SERIAL_INTERRUPT_DRIVEN=n +# CONFIG_SHELL_BACKEND_SERIAL_RX_POLL_PERIOD=1 +# CONFIG_BOOT_BANNER=n diff --git a/boards/phytium/pd2408_test_a/pd2408_test_a_pinctrl.dtsi b/boards/phytium/pd2408_test_a/pd2408_test_a_pinctrl.dtsi new file mode 100644 index 00000000000..0c800d14776 --- /dev/null +++ b/boards/phytium/pd2408_test_a/pd2408_test_a_pinctrl.dtsi @@ -0,0 +1,12 @@ + + +#include + +&pinctrl { + uart1_rx_default: uart1_rx_default { + pinmux = ; + }; + uart1_tx_default: uart1_tx_default { + pinmux = ; + }; +}; \ No newline at end of file diff --git a/boards/phytium/pd2408_test_b/Kconfig.defconfig b/boards/phytium/pd2408_test_b/Kconfig.defconfig new file mode 100644 index 00000000000..7c362df0faa --- /dev/null +++ b/boards/phytium/pd2408_test_b/Kconfig.defconfig @@ -0,0 +1,19 @@ +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +# +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# https://opensource.org/license/apache-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. + + +config BOARD + default "Phytium pd2408 test b" + depends on BOARD_PD2408_TEST_B diff --git a/boards/phytium/pd2408_test_b/Kconfig.pd2408_test_b b/boards/phytium/pd2408_test_b/Kconfig.pd2408_test_b new file mode 100644 index 00000000000..72a341186cb --- /dev/null +++ b/boards/phytium/pd2408_test_b/Kconfig.pd2408_test_b @@ -0,0 +1,18 @@ +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +# +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# https://opensource.org/license/apache-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. + +config BOARD_PD2408_TEST_B + bool "phytium pd2408" + select SOC_PD2408 diff --git a/boards/phytium/pd2408_test_b/board.cmake b/boards/phytium/pd2408_test_b/board.cmake new file mode 100644 index 00000000000..9881313609a --- /dev/null +++ b/boards/phytium/pd2408_test_b/board.cmake @@ -0,0 +1 @@ +# SPDX-License-Identifier: Apache-2.0 diff --git a/boards/phytium/pd2408_test_b/board.yml b/boards/phytium/pd2408_test_b/board.yml new file mode 100644 index 00000000000..1ef7a9e7a61 --- /dev/null +++ b/boards/phytium/pd2408_test_b/board.yml @@ -0,0 +1,10 @@ +board: + name: pd2408_test_b + vendor: phytium + socs: + - name: pd2408 + variants: + - name: smp + - name: el2 + variants: + - name: smp diff --git a/boards/phytium/pd2408_test_b/pd2408_test_b.dts b/boards/phytium/pd2408_test_b/pd2408_test_b.dts new file mode 100644 index 00000000000..fe40e62f16e --- /dev/null +++ b/boards/phytium/pd2408_test_b/pd2408_test_b.dts @@ -0,0 +1,34 @@ +/* + * Copyright 2024 zhangyan + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; +#include +#include "pd2408_test_b_pinctrl.dtsi" + +/ { + model = "Phytium pd2408 test b"; + compatible = "phytium,pd2408-test-a", "phytium,pd2408"; + #address-cells = <2>; + #size-cells = <2>; + +chosen { + zephyr,console = &uart1; + zephyr,shell-uart = &uart1; + zephyr,sram = &sram0; + zephyr,pcie-controller = &pcie0; + }; +}; + +&uart1 { + current-speed = <115200>; + pinctrl-0 = <&uart1_rx_default &uart1_tx_default>; + pinctrl-names = "default"; + status = "okay"; +}; + +&pcie0 { + status = "okay"; +}; diff --git a/boards/phytium/pd2408_test_b/pd2408_test_b.yaml b/boards/phytium/pd2408_test_b/pd2408_test_b.yaml new file mode 100644 index 00000000000..ec68f42cd95 --- /dev/null +++ b/boards/phytium/pd2408_test_b/pd2408_test_b.yaml @@ -0,0 +1,7 @@ +identifier: pd2408_test_b +name: Phytium pd2408 test b +type: mcu +arch: arm64 +toolchain: + - zephyr + - cross-compile diff --git a/boards/phytium/pd2408_test_b/pd2408_test_b_defconfig b/boards/phytium/pd2408_test_b/pd2408_test_b_defconfig new file mode 100644 index 00000000000..23ad632a796 --- /dev/null +++ b/boards/phytium/pd2408_test_b/pd2408_test_b_defconfig @@ -0,0 +1,29 @@ +# SPDX-License-Identifier: Apache-2.0 + +# Platform Configuration +CONFIG_ARM64_VA_BITS_42=y +CONFIG_ARM64_PA_BITS_42=y +# Main stack size +CONFIG_MAIN_STACK_SIZE=8192 + +CONFIG_ARMV8_A_NS=y + +# Zephyr Kernel Configuration +CONFIG_XIP=n +CONFIG_FLASH_SIZE=0 +CONFIG_FLASH_BASE_ADDRESS=0x0 + +# Serial Drivers +CONFIG_SERIAL=y + +# Enable Console +CONFIG_CONSOLE=y +CONFIG_UART_CONSOLE=y + + +# Timer Drivers +CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME=y + + +#cache +CONFIG_CACHE_MANAGEMENT=y diff --git a/boards/phytium/pd2408_test_b/pd2408_test_b_pd2408_el2.dts b/boards/phytium/pd2408_test_b/pd2408_test_b_pd2408_el2.dts new file mode 100644 index 00000000000..fe40e62f16e --- /dev/null +++ b/boards/phytium/pd2408_test_b/pd2408_test_b_pd2408_el2.dts @@ -0,0 +1,34 @@ +/* + * Copyright 2024 zhangyan + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; +#include +#include "pd2408_test_b_pinctrl.dtsi" + +/ { + model = "Phytium pd2408 test b"; + compatible = "phytium,pd2408-test-a", "phytium,pd2408"; + #address-cells = <2>; + #size-cells = <2>; + +chosen { + zephyr,console = &uart1; + zephyr,shell-uart = &uart1; + zephyr,sram = &sram0; + zephyr,pcie-controller = &pcie0; + }; +}; + +&uart1 { + current-speed = <115200>; + pinctrl-0 = <&uart1_rx_default &uart1_tx_default>; + pinctrl-names = "default"; + status = "okay"; +}; + +&pcie0 { + status = "okay"; +}; diff --git a/boards/phytium/pd2408_test_b/pd2408_test_b_pd2408_el2.yaml b/boards/phytium/pd2408_test_b/pd2408_test_b_pd2408_el2.yaml new file mode 100644 index 00000000000..3a8d9cc95a7 --- /dev/null +++ b/boards/phytium/pd2408_test_b/pd2408_test_b_pd2408_el2.yaml @@ -0,0 +1,7 @@ +identifier: pd2408_demo/pd2408/el2 +name: Phytium pd2408 demo +type: mcu +arch: arm64 +toolchain: + - zephyr + - cross-compile diff --git a/boards/phytium/pd2408_test_b/pd2408_test_b_pd2408_el2_defconfig b/boards/phytium/pd2408_test_b/pd2408_test_b_pd2408_el2_defconfig new file mode 100644 index 00000000000..6a7fc9d29a1 --- /dev/null +++ b/boards/phytium/pd2408_test_b/pd2408_test_b_pd2408_el2_defconfig @@ -0,0 +1,32 @@ +# SPDX-License-Identifier: Apache-2.0 + +# Platform Configuration +CONFIG_ARM64_VA_BITS_42=y +CONFIG_ARM64_PA_BITS_42=y +# Main stack size +CONFIG_MAIN_STACK_SIZE=4096 + +CONFIG_ARMV8_A_NS=y + +# Zephyr Kernel Configuration +CONFIG_XIP=n +CONFIG_FLASH_SIZE=0 +CONFIG_FLASH_BASE_ADDRESS=0x0 + +# Serial Drivers +CONFIG_SERIAL=y + +# Enable Console +CONFIG_CONSOLE=y +CONFIG_UART_CONSOLE=y + + +# Timer Drivers +CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME=y + + +#cache +CONFIG_CACHE_MANAGEMENT=y + +# EL2 +CONFIG_USE_EL2=y diff --git a/boards/phytium/pd2408_test_b/pd2408_test_b_pd2408_el2_smp.dts b/boards/phytium/pd2408_test_b/pd2408_test_b_pd2408_el2_smp.dts new file mode 100644 index 00000000000..fe40e62f16e --- /dev/null +++ b/boards/phytium/pd2408_test_b/pd2408_test_b_pd2408_el2_smp.dts @@ -0,0 +1,34 @@ +/* + * Copyright 2024 zhangyan + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; +#include +#include "pd2408_test_b_pinctrl.dtsi" + +/ { + model = "Phytium pd2408 test b"; + compatible = "phytium,pd2408-test-a", "phytium,pd2408"; + #address-cells = <2>; + #size-cells = <2>; + +chosen { + zephyr,console = &uart1; + zephyr,shell-uart = &uart1; + zephyr,sram = &sram0; + zephyr,pcie-controller = &pcie0; + }; +}; + +&uart1 { + current-speed = <115200>; + pinctrl-0 = <&uart1_rx_default &uart1_tx_default>; + pinctrl-names = "default"; + status = "okay"; +}; + +&pcie0 { + status = "okay"; +}; diff --git a/boards/phytium/pd2408_test_b/pd2408_test_b_pd2408_el2_smp.yaml b/boards/phytium/pd2408_test_b/pd2408_test_b_pd2408_el2_smp.yaml new file mode 100644 index 00000000000..7b136e46b13 --- /dev/null +++ b/boards/phytium/pd2408_test_b/pd2408_test_b_pd2408_el2_smp.yaml @@ -0,0 +1,9 @@ +identifier: pd2408_test_b/pd2408/el2/smp +name: Phytium pd2408 test b +type: mcu +arch: arm64 +toolchain: + - zephyr + - cross-compile +supported: + - smp diff --git a/boards/phytium/pd2408_test_b/pd2408_test_b_pd2408_el2_smp_defconfig b/boards/phytium/pd2408_test_b/pd2408_test_b_pd2408_el2_smp_defconfig new file mode 100644 index 00000000000..e066e47dbe5 --- /dev/null +++ b/boards/phytium/pd2408_test_b/pd2408_test_b_pd2408_el2_smp_defconfig @@ -0,0 +1,44 @@ +# SPDX-License-Identifier: Apache-2.0 + +# Platform Configuration +CONFIG_ARM64_VA_BITS_42=y +CONFIG_ARM64_PA_BITS_42=y +# Main stack size +CONFIG_MAIN_STACK_SIZE=4096 + +CONFIG_ARMV8_A_NS=y + +# Zephyr Kernel Configuration +CONFIG_XIP=n +CONFIG_FLASH_SIZE=0 +CONFIG_FLASH_BASE_ADDRESS=0x0 + +# Serial Drivers +CONFIG_SERIAL=y + +# Enable Console +CONFIG_CONSOLE=y +CONFIG_UART_CONSOLE=y + +#cache +CONFIG_CACHE_MANAGEMENT=y + +# Timer Drivers +CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME=y + +# PSCI is supported with NS +CONFIG_PM_CPU_OPS=y +CONFIG_PM_CPU_OPS_PSCI=y + +# SMP-related +CONFIG_SMP=y +CONFIG_MP_MAX_NUM_CPUS=8 +CONFIG_TIMEOUT_64BIT=y + +# CONFIG_SHELL=y +# CONFIG_SHELL_BACKEND_SERIAL_INTERRUPT_DRIVEN=n +# CONFIG_SHELL_BACKEND_SERIAL_RX_POLL_PERIOD=1 +# CONFIG_BOOT_BANNER=n + +# EL2 +CONFIG_USE_EL2=y diff --git a/boards/phytium/pd2408_test_b/pd2408_test_b_pd2408_smp.dts b/boards/phytium/pd2408_test_b/pd2408_test_b_pd2408_smp.dts new file mode 100644 index 00000000000..544dc8e6816 --- /dev/null +++ b/boards/phytium/pd2408_test_b/pd2408_test_b_pd2408_smp.dts @@ -0,0 +1,41 @@ +/* + * Copyright 2024 zhangyan + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; + +#include +#include "pd2408_test_b_pinctrl.dtsi" + +/ { + model = "Phytium pd2408 test b"; + compatible = "phytium,pd2408-test-a", "phytium,pd2408"; + #address-cells = <2>; + #size-cells = <2>; + + psci { + compatible = "arm,psci-0.2"; + method = "smc"; + }; + +chosen { + zephyr,console = &uart1; + zephyr,shell-uart = &uart1; + zephyr,sram = &sram0; + zephyr,pcie-controller = &pcie0; + }; +}; + +&uart1 { + current-speed = <115200>; + pinctrl-0 = <&uart1_rx_default &uart1_tx_default>; + pinctrl-names = "default"; + status = "okay"; +}; + +&pcie0 { + status = "okay"; +}; + diff --git a/boards/phytium/pd2408_test_b/pd2408_test_b_pd2408_smp.yaml b/boards/phytium/pd2408_test_b/pd2408_test_b_pd2408_smp.yaml new file mode 100644 index 00000000000..fbb6c3926d7 --- /dev/null +++ b/boards/phytium/pd2408_test_b/pd2408_test_b_pd2408_smp.yaml @@ -0,0 +1,9 @@ +identifier: pd2408_test_b/pd2408/smp +name: Phytium pd2408 test b +type: mcu +arch: arm64 +toolchain: + - zephyr + - cross-compile +supported: + - smp \ No newline at end of file diff --git a/boards/phytium/pd2408_test_b/pd2408_test_b_pd2408_smp_defconfig b/boards/phytium/pd2408_test_b/pd2408_test_b_pd2408_smp_defconfig new file mode 100644 index 00000000000..2896228ec7e --- /dev/null +++ b/boards/phytium/pd2408_test_b/pd2408_test_b_pd2408_smp_defconfig @@ -0,0 +1,41 @@ +# SPDX-License-Identifier: Apache-2.0 + +# Platform Configuration +CONFIG_ARM64_VA_BITS_42=y +CONFIG_ARM64_PA_BITS_42=y +# Main stack size +CONFIG_MAIN_STACK_SIZE=4096 + +CONFIG_ARMV8_A_NS=y + +# Zephyr Kernel Configuration +CONFIG_XIP=n +CONFIG_FLASH_SIZE=0 +CONFIG_FLASH_BASE_ADDRESS=0x0 + +# Serial Drivers +CONFIG_SERIAL=y + +# Enable Console +CONFIG_CONSOLE=y +CONFIG_UART_CONSOLE=y + +#cache +CONFIG_CACHE_MANAGEMENT=y + +# Timer Drivers +CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME=y + +# PSCI is supported with NS +CONFIG_PM_CPU_OPS=y +CONFIG_PM_CPU_OPS_PSCI=y + +# SMP-related +CONFIG_SMP=y +CONFIG_MP_MAX_NUM_CPUS=8 +CONFIG_TIMEOUT_64BIT=y + +# CONFIG_SHELL=y +# CONFIG_SHELL_BACKEND_SERIAL_INTERRUPT_DRIVEN=n +# CONFIG_SHELL_BACKEND_SERIAL_RX_POLL_PERIOD=1 +# CONFIG_BOOT_BANNER=n diff --git a/boards/phytium/pd2408_test_b/pd2408_test_b_pinctrl.dtsi b/boards/phytium/pd2408_test_b/pd2408_test_b_pinctrl.dtsi new file mode 100644 index 00000000000..0c800d14776 --- /dev/null +++ b/boards/phytium/pd2408_test_b/pd2408_test_b_pinctrl.dtsi @@ -0,0 +1,12 @@ + + +#include + +&pinctrl { + uart1_rx_default: uart1_rx_default { + pinmux = ; + }; + uart1_tx_default: uart1_tx_default { + pinmux = ; + }; +}; \ No newline at end of file diff --git a/boards/phytium/ps2316_test/ps2316_test_defconfig b/boards/phytium/ps2316_test/ps2316_test_defconfig index f816f41440e..23ad632a796 100644 --- a/boards/phytium/ps2316_test/ps2316_test_defconfig +++ b/boards/phytium/ps2316_test/ps2316_test_defconfig @@ -27,7 +27,3 @@ CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME=y #cache CONFIG_CACHE_MANAGEMENT=y - -# PSCI is supported with NS -CONFIG_PM_CPU_OPS=y -CONFIG_PM_CPU_OPS_PSCI=y diff --git a/boards/phytium/ps2316_test/ps2316_test_ps2316_el2_defconfig b/boards/phytium/ps2316_test/ps2316_test_ps2316_el2_defconfig index 0d19db0fb29..6a7fc9d29a1 100644 --- a/boards/phytium/ps2316_test/ps2316_test_ps2316_el2_defconfig +++ b/boards/phytium/ps2316_test/ps2316_test_ps2316_el2_defconfig @@ -28,9 +28,5 @@ CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME=y #cache CONFIG_CACHE_MANAGEMENT=y -# PSCI is supported with NS -CONFIG_PM_CPU_OPS=y -CONFIG_PM_CPU_OPS_PSCI=y - # EL2 CONFIG_USE_EL2=y diff --git a/dts/arm/phytium/d2000_aarch32.dtsi b/dts/arm/phytium/pd2008_aarch32.dtsi similarity index 100% rename from dts/arm/phytium/d2000_aarch32.dtsi rename to dts/arm/phytium/pd2008_aarch32.dtsi diff --git a/dts/arm/phytium/e2000d_aarch32.dtsi b/dts/arm/phytium/pe2202_aarch32.dtsi similarity index 98% rename from dts/arm/phytium/e2000d_aarch32.dtsi rename to dts/arm/phytium/pe2202_aarch32.dtsi index 5dd03338fc4..6a6b25f2e97 100644 --- a/dts/arm/phytium/e2000d_aarch32.dtsi +++ b/dts/arm/phytium/pe2202_aarch32.dtsi @@ -115,10 +115,11 @@ sdhc1: sdhc@28001000 { compatible = "phytium,sdhc"; reg = <0x00 0x28001000 0x00 0x1000>; + pio-base = <0x32B30000>; status = "disabled"; interrupts = ; max-current-330 = <1020>; - max-bus-freq = <25000000>; + max-bus-freq = <50000000>; min-bus-freq = <400000>; }; diff --git a/dts/arm/phytium/e2000q_aarch32.dtsi b/dts/arm/phytium/pe2204_aarch32.dtsi similarity index 92% rename from dts/arm/phytium/e2000q_aarch32.dtsi rename to dts/arm/phytium/pe2204_aarch32.dtsi index 5402fb38344..67f4bcc44ae 100644 --- a/dts/arm/phytium/e2000q_aarch32.dtsi +++ b/dts/arm/phytium/pe2204_aarch32.dtsi @@ -89,9 +89,9 @@ #address-cells = <0x02>; }; - pinctrl: pinctrl@32B30000 { + pinctrl: pinctrl@32b30000 { compatible = "phytium,pinctrl"; - reg = <0x00 0x32B30000 0x00 0x2000>; + reg = <0x00 0x32b30000 0x00 0x2000>; status = "okay"; }; @@ -104,9 +104,9 @@ clocks = <&uartclk>; }; - uart2: uart@2800E000 { + uart2: uart@2800e000 { compatible = "arm,pl011"; - reg = <0x00 0x2800E000 0x00 0x1000>; + reg = <0x00 0x2800e000 0x00 0x1000>; status = "disabled"; interrupts = ; interrupt-names = "irq_1"; @@ -148,10 +148,11 @@ sdhc1: sdhc@28001000 { compatible = "phytium,sdhc"; reg = <0x00 0x28001000 0x00 0x1000>; + pio-base = <0x32B30000>; status = "disabled"; interrupts = ; max-current-330 = <1020>; - max-bus-freq = <25000000>; + max-bus-freq = <50000000>; min-bus-freq = <400000>; }; diff --git a/dts/arm64/phytium/d2000.dtsi b/dts/arm64/phytium/pd2008.dtsi similarity index 100% rename from dts/arm64/phytium/d2000.dtsi rename to dts/arm64/phytium/pd2008.dtsi diff --git a/dts/arm64/phytium/pd2408.dtsi b/dts/arm64/phytium/pd2408.dtsi new file mode 100644 index 00000000000..eee5e97bbe1 --- /dev/null +++ b/dts/arm64/phytium/pd2408.dtsi @@ -0,0 +1,150 @@ +// Phytium is pleased to support the open source community by making Zephyr-SDK available. + +// +// Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +// +// Licensed under the Apache-2.0 License (the "License"); you may not use this file except +// in compliance with the License. You may obtain a copy of the License at +// +// https://opensource.org/license/apache-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 +#include +#include + +/ { + #address-cells = <2>; + #size-cells = <2>; + + cpus { + #address-cells = <2>; + #size-cells = <0>; + + cpu@0 { + device_type = "cpu"; + compatible = "phytium,ftc862"; + reg = <0 0x0>; + }; + + cpu@1 { + device_type = "cpu"; + compatible = "phytium,ftc862"; + reg = <0 0x100>; + }; + + cpu@2 { + device_type = "cpu"; + compatible = "phytium,ftc862"; + reg = <0 0x200>; + }; + + cpu@3 { + device_type = "cpu"; + compatible = "phytium,ftc862"; + reg = <0 0x300>; + }; + + cpu@4 { + device_type = "cpu"; + compatible = "phytium,ftc862"; + reg = <0 0x10000>; + }; + + cpu@5 { + device_type = "cpu"; + compatible = "phytium,ftc862"; + reg = <0 0x10100>; + }; + + cpu@6 { + device_type = "cpu"; + compatible = "phytium,ftc862"; + reg = <0 0x10200>; + }; + + cpu@7 { + device_type = "cpu"; + compatible = "phytium,ftc862"; + reg = <0 0x10300>; + }; + }; + + timer { + compatible = "arm,armv8-timer"; + interrupt-parent = <&gic>; + // ppi =+ 16, 13 == 29 Security physical timer interrupt, 14 == 30 Non secure physical timer interrupt + interrupts = , + , + , + ; + }; + + uartclk: apb-pclk { + compatible = "fixed-clock"; + clock-frequency = <100000000>; + #clock-cells = <0>; + }; + + soc { + #address-cells = <2>; + #size-cells = <2>; + ranges; + + interrupt-parent = <&gic>; + + gic: interrupt-controller@26800000 { + compatible = "arm,gic-v3", "arm,gic"; + reg = <0x00 0x26800000 0x00 0x40000>, + <0x00 0x26860000 0x00 0x200000>; + interrupt-controller; + #interrupt-cells = <4>; + status = "okay"; + #size-cells = <0x02>; + #address-cells = <0x02>; + }; + + pinctrl: pinctrl@26FD2000 { + compatible = "phytium,pinctrl"; + reg = <0x00 0x26FD2000 0x00 0x2000>; + status = "okay"; + }; + + uart1: uart@18002000 { + compatible = "arm,pl011"; + reg = <0x00 0x18002000 0x00 0x1000>; + status = "disabled"; + interrupts = ; + interrupt-names = "irq_0"; + clocks = <&uartclk>; + }; + + /* 512MB DDR */ + sram0: memory@80100000 { + device_type = "memory"; + compatible = "mmio-sram"; + reg = <0x00 0x80100000 0x00 0x40000000>; + }; + + pcie0: pcie@40000000 { + compatible = "pci-host-ecam-generic"; + device_type = "pci"; + reg = <0x00 0x40000000 0x00 0x10000000>; + #size-cells = <0x02>; + #address-cells = <0x03>; + ranges = <0x1000000 0x00 0x50000000 0x00 0x50000000 0x00 0x08000000 + 0x2000000 0x00 0x58000000 0x00 0x58000000 0x00 0x27ffffff + 0x3000000 0x10 0x00 0x10 0x00 0x1f 0xffffffff>; + bus-range = <0x00 0xff>; + }; + + }; +}; diff --git a/dts/arm64/phytium/e2000d.dtsi b/dts/arm64/phytium/pe2202.dtsi similarity index 94% rename from dts/arm64/phytium/e2000d.dtsi rename to dts/arm64/phytium/pe2202.dtsi index c5baeb09f71..f7b0ea0603f 100644 --- a/dts/arm64/phytium/e2000d.dtsi +++ b/dts/arm64/phytium/pe2202.dtsi @@ -77,9 +77,9 @@ #address-cells = <0x02>; }; - pinctrl: pinctrl@32B30000 { + pinctrl: pinctrl@32b30000 { compatible = "phytium,pinctrl"; - reg = <0x00 0x32B30000 0x00 0x2000>; + reg = <0x00 0x32b30000 0x00 0x2000>; status = "okay"; }; @@ -92,9 +92,9 @@ clocks = <&uartclk>; }; - uart2: uart@2800E000 { + uart2: uart@2800e000 { compatible = "arm,pl011"; - reg = <0x00 0x2800E000 0x00 0x1000>; + reg = <0x00 0x2800e000 0x00 0x1000>; status = "disabled"; interrupts = ; interrupt-names = "irq_1"; @@ -104,7 +104,7 @@ sdhc0: sdhc@28000000 { compatible = "phytium,sdhc"; reg = <0x00 0x28000000 0x00 0x1000>; - pio-base = <0x32B30000>; + pio-base = <0x32b30000>; status = "disabled"; interrupts = ; max-current-330 = <1020>; @@ -117,7 +117,7 @@ sdhc1: sdhc@28001000 { compatible = "phytium,sdhc"; reg = <0x00 0x28001000 0x00 0x1000>; - pio-base = <0x32B30000>; + pio-base = <0x32b30000>; status = "disabled"; interrupts = ; max-current-330 = <1020>; @@ -126,9 +126,9 @@ }; - xmac0: xmac@3200C000 { + xmac0: xmac@3200c000 { compatible = "phytium,xmac"; - reg = <0x00 0x3200C000 0x00 0x2000>; + reg = <0x00 0x3200c000 0x00 0x2000>; status = "disabled"; interrupts = ; diff --git a/dts/arm64/phytium/e2000q.dtsi b/dts/arm64/phytium/pe2204.dtsi similarity index 90% rename from dts/arm64/phytium/e2000q.dtsi rename to dts/arm64/phytium/pe2204.dtsi index c10a481dfc2..45b1dda2f99 100644 --- a/dts/arm64/phytium/e2000q.dtsi +++ b/dts/arm64/phytium/pe2204.dtsi @@ -89,10 +89,10 @@ #address-cells = <0x02>; }; - pinctrl: pinctrl@32B30000 { + pinctrl: pinctrl@32b30000 { compatible = "phytium,pinctrl"; - reg = <0x00 0x32B30000 0x00 0x2000>; - status = "okay"; + reg = <0x00 0x32b30000 0x00 0x2000>; + status = "okay"; }; uart1: uart@2800d000 { @@ -104,9 +104,9 @@ clocks = <&uartclk>; }; - uart2: uart@2800E000 { + uart2: uart@2800e000 { compatible = "arm,pl011"; - reg = <0x00 0x2800E000 0x00 0x1000>; + reg = <0x00 0x2800e000 0x00 0x1000>; status = "disabled"; interrupts = ; interrupt-names = "irq_1"; @@ -116,7 +116,7 @@ sdhc0: sdhc@28000000 { compatible = "phytium,sdhc"; reg = <0x00 0x28000000 0x00 0x1000>; - pio-base = <0x32B30000>; + pio-base = <0x32b30000>; status = "disabled"; interrupts = ; max-current-330 = <1020>; @@ -128,7 +128,7 @@ sdhc1: sdhc@28001000 { compatible = "phytium,sdhc"; reg = <0x00 0x28001000 0x00 0x1000>; - pio-base = <0x32B30000>; + pio-base = <0x32b30000>; status = "disabled"; interrupts = ; max-current-330 = <1020>; @@ -136,9 +136,9 @@ min-bus-freq = <400000>; }; - xmac0: xmac@3200C000 { + xmac0: xmac@3200c000 { compatible = "phytium,xmac"; - reg = <0x00 0x3200C000 0x00 0x2000>; + reg = <0x00 0x3200c000 0x00 0x2000>; status = "disabled"; interrupts = ; diff --git a/include/zephyr/dt-bindings/pinctrl/phytium-pd2408-pinctrl.h b/include/zephyr/dt-bindings/pinctrl/phytium-pd2408-pinctrl.h new file mode 100644 index 00000000000..f1b7c9935d5 --- /dev/null +++ b/include/zephyr/dt-bindings/pinctrl/phytium-pd2408-pinctrl.h @@ -0,0 +1,168 @@ +// Phytium is pleased to support the open source community by making Zephyr-SDK available. + +// +// Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +// +// Licensed under the Apache-2.0 License (the "License"); you may not use this file except +// in compliance with the License. You may obtain a copy of the License at +// +// https://opensource.org/license/apache-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 ZEPHYR_INCLUDE_DT_BINDINGS_PINCTRL_PHYTIUM_PINCTRL_H_ +#define ZEPHYR_INCLUDE_DT_BINDINGS_PINCTRL_PHYTIUM_PINCTRL_H_ + +#define FIOPAD_REG0_BEG_OFFSET FIOPAD_C7_REG0_OFFSET +#define FIOPAD_REG0_END_OFFSET FIOPAD_T2_REG0_OFFSET + +#define FIOPAD_C7_REG0_OFFSET 0x0018U +#define FIOPAD_B4_REG0_OFFSET 0x0024U +#define FIOPAD_B6_REG0_OFFSET 0x0028U +#define FIOPAD_A5_REG0_OFFSET 0x002CU +#define FIOPAD_C3_REG0_OFFSET 0x0030U +#define FIOPAD_B8_REG0_OFFSET 0x0034U +#define FIOPAD_E1_REG0_OFFSET 0x0038U +#define FIOPAD_R3_REG0_OFFSET 0x003CU +#define FIOPAD_P2_REG0_OFFSET 0x0040U +#define FIOPAD_A9_REG0_OFFSET 0x0044U +#define FIOPAD_C9_REG0_OFFSET 0x0048U +#define FIOPAD_F10_REG0_OFFSET 0x004CU +#define FIOPAD_AD6_REG0_OFFSET 0x0050U +#define FIOPAD_AK6_REG0_OFFSET 0x0054U +#define FIOPAD_Y8_REG0_OFFSET 0x0058U +#define FIOPAD_AJ5_REG0_OFFSET 0x005CU +#define FIOPAD_AH6_REG0_OFFSET 0x0060U +#define FIOPAD_AC5_REG0_OFFSET 0x0064U +#define FIOPAD_AB6_REG0_OFFSET 0x0068U +#define FIOPAD_AF6_REG0_OFFSET 0x006CU +#define FIOPAD_AB8_REG0_OFFSET 0x0070U +#define FIOPAD_AA5_REG0_OFFSET 0x0074U +#define FIOPAD_V6_REG0_OFFSET 0x0078U +#define FIOPAD_W5_REG0_OFFSET 0x007CU +#define FIOPAD_Y6_REG0_OFFSET 0x0080U +#define FIOPAD_W3_REG0_OFFSET 0x0084U +#define FIOPAD_U5_REG0_OFFSET 0x0088U +#define FIOPAD_T8_REG0_OFFSET 0x008CU +#define FIOPAD_V8_REG0_OFFSET 0x0090U +#define FIOPAD_P8_REG0_OFFSET 0x0094U +#define FIOPAD_M8_REG0_OFFSET 0x0098U +#define FIOPAD_AE5_REG0_OFFSET 0x009CU +#define FIOPAD_AG5_REG0_OFFSET 0x00A0U +#define FIOPAD_J13_REG0_OFFSET 0x00A4U +#define FIOPAD_L13_REG0_OFFSET 0x00A8U +#define FIOPAD_D10_REG0_OFFSET 0x00ACU +#define FIOPAD_E9_REG0_OFFSET 0x00B0U +#define FIOPAD_BL19_REG0_OFFSET 0x00B4U +#define FIOPAD_BK18_REG0_OFFSET 0x00B8U +#define FIOPAD_BL15_REG0_OFFSET 0x00BCU +#define FIOPAD_BK16_REG0_OFFSET 0x00C0U +#define FIOPAD_BL13_REG0_OFFSET 0x00C4U +#define FIOPAD_BK14_REG0_OFFSET 0x00C8U +#define FIOPAD_J1_REG0_OFFSET 0x00CCU +#define FIOPAD_H2_REG0_OFFSET 0x00D0U +#define FIOPAD_E3_REG0_OFFSET 0x00D4U +#define FIOPAD_F2_REG0_OFFSET 0x00D8U +#define FIOPAD_G3_REG0_OFFSET 0x00DCU +#define FIOPAD_E5_REG0_OFFSET 0x00E0U +#define FIOPAD_F6_REG0_OFFSET 0x00E4U +#define FIOPAD_E7_REG0_OFFSET 0x00E8U +#define FIOPAD_F8_REG0_OFFSET 0x00ECU +#define FIOPAD_N3_REG0_OFFSET 0x00F0U +#define FIOPAD_N1_REG0_OFFSET 0x00F4U +#define FIOPAD_M2_REG0_OFFSET 0x00F8U +#define FIOPAD_K2_REG0_OFFSET 0x00FCU +#define FIOPAD_K8_REG0_OFFSET 0x0100U +#define FIOPAD_M6_REG0_OFFSET 0x0104U +#define FIOPAD_H6_REG0_OFFSET 0x0108U +#define FIOPAD_K6_REG0_OFFSET 0x010CU +#define FIOPAD_J5_REG0_OFFSET 0x0110U +#define FIOPAD_J3_REG0_OFFSET 0x0114U +#define FIOPAD_G5_REG0_OFFSET 0x0118U +#define FIOPAD_L5_REG0_OFFSET 0x011CU +#define FIOPAD_L3_REG0_OFFSET 0x0120U +#define FIOPAD_AP4_REG0_OFFSET 0x0124U +#define FIOPAD_AE1_REG0_OFFSET 0x0128U +#define FIOPAD_AG3_REG0_OFFSET 0x012CU +#define FIOPAD_AJ3_REG0_OFFSET 0x0130U +#define FIOPAD_AD2_REG0_OFFSET 0x0134U +#define FIOPAD_AM4_REG0_OFFSET 0x0138U +#define FIOPAD_AR5_REG0_OFFSET 0x013CU +#define FIOPAD_AT6_REG0_OFFSET 0x0140U +#define FIOPAD_AC3_REG0_OFFSET 0x0144U +#define FIOPAD_AE3_REG0_OFFSET 0x0148U +#define FIOPAD_AF2_REG0_OFFSET 0x014CU +#define FIOPAD_AH2_REG0_OFFSET 0x0150U +#define FIOPAD_AJ1_REG0_OFFSET 0x0154U +#define FIOPAD_AK2_REG0_OFFSET 0x0158U +#define FIOPAD_BM12_REG0_OFFSET 0x015CU +#define FIOPAD_BM10_REG0_OFFSET 0x0160U +#define FIOPAD_BK12_REG0_OFFSET 0x0164U +#define FIOPAD_BL11_REG0_OFFSET 0x0168U +#define FIOPAD_BK20_REG0_OFFSET 0x016CU +#define FIOPAD_BL21_REG0_OFFSET 0x0170U +#define FIOPAD_BK22_REG0_OFFSET 0x0174U +#define FIOPAD_BL23_REG0_OFFSET 0x0178U +#define FIOPAD_BK24_REG0_OFFSET 0x017CU +#define FIOPAD_BL25_REG0_OFFSET 0x0180U +#define FIOPAD_AA3_REG0_OFFSET 0x0184U +#define FIOPAD_Y2_REG0_OFFSET 0x0188U +#define FIOPAD_V2_REG0_OFFSET 0x018CU +#define FIOPAD_AA1_REG0_OFFSET 0x0190U +#define FIOPAD_AB2_REG0_OFFSET 0x0194U +#define FIOPAD_T2_REG0_OFFSET 0x0198U + +/* register offset of iopad delay */ + +#define FIOPAD_C7_REG1_OFFSET 0x1018U +#define FIOPAD_B4_REG1_OFFSET 0x1024U +#define FIOPAD_B6_REG1_OFFSET 0x1028U +#define FIOPAD_D10_REG1_OFFSET 0x10ACU +#define FIOPAD_E9_REG1_OFFSET 0x10B0U +#define FIOPAD_J1_REG1_OFFSET 0x10CCU +#define FIOPAD_H2_REG1_OFFSET 0x10D0U +#define FIOPAD_E3_REG1_OFFSET 0x10D4U +#define FIOPAD_F2_REG1_OFFSET 0x10D8U +#define FIOPAD_G3_REG1_OFFSET 0x10DCU +#define FIOPAD_E5_REG1_OFFSET 0x10E0U +#define FIOPAD_F6_REG1_OFFSET 0x10E4U +#define FIOPAD_E7_REG1_OFFSET 0x10E8U +#define FIOPAD_K8_REG1_OFFSET 0x1100U +#define FIOPAD_M6_REG1_OFFSET 0x1104U +#define FIOPAD_H6_REG1_OFFSET 0x1108U +#define FIOPAD_K6_REG1_OFFSET 0x110CU +#define FIOPAD_J5_REG1_OFFSET 0x1110U +#define FIOPAD_J3_REG1_OFFSET 0x1114U +#define FIOPAD_G5_REG1_OFFSET 0x1118U +#define FIOPAD_L5_REG1_OFFSET 0x111CU +#define FIOPAD_L3_REG1_OFFSET 0x1120U +#define FIOPAD_AP4_REG1_OFFSET 0x1124U +#define FIOPAD_AE1_REG1_OFFSET 0x1128U +#define FIOPAD_AG3_REG1_OFFSET 0x112CU +#define FIOPAD_AJ3_REG1_OFFSET 0x1130U +#define FIOPAD_AD2_REG1_OFFSET 0x1134U +#define FIOPAD_AM4_REG1_OFFSET 0x1138U +#define FIOPAD_AE3_REG1_OFFSET 0x1148U +#define FIOPAD_AF2_REG1_OFFSET 0x114CU +#define FIOPAD_AH2_REG1_OFFSET 0x1150U +#define FIOPAD_AJ1_REG1_OFFSET 0x1154U + + +#define FIOPAD_REG1_BEG_OFFSET FIOPAD_C7_REG1_OFFSET +#define FIOPAD_REG1_END_OFFSET FIOPAD_AJ1_REG1_OFFSET + +#define FIOPAD_FUNC0 0x0 +#define FIOPAD_FUNC1 0x1 +#define FIOPAD_FUNC2 0x2 +#define FIOPAD_FUNC3 0x3 +#define FIOPAD_FUNC4 0x4 +#define FIOPAD_FUNC5 0x5 +#define FIOPAD_FUNC6 0x6 +#define FIOPAD_FUNC7 0x7 + +#define PHYTIUM_PINMUX(pin_reg_offset, func_num) (pin_reg_offset) (func_num) + +#endif /* ZEPHYR_INCLUDE_DT_BINDINGS_PINCTRL_TI_K3_PINCTRL_H_ */ diff --git a/include/zephyr/dt-bindings/pinctrl/phytium-e2000d-pinctrl.h b/include/zephyr/dt-bindings/pinctrl/phytium-pe2202-pinctrl.h similarity index 100% rename from include/zephyr/dt-bindings/pinctrl/phytium-e2000d-pinctrl.h rename to include/zephyr/dt-bindings/pinctrl/phytium-pe2202-pinctrl.h diff --git a/include/zephyr/dt-bindings/pinctrl/phytium-e2000q-pinctrl.h b/include/zephyr/dt-bindings/pinctrl/phytium-pe2204-pinctrl.h similarity index 100% rename from include/zephyr/dt-bindings/pinctrl/phytium-e2000q-pinctrl.h rename to include/zephyr/dt-bindings/pinctrl/phytium-pe2204-pinctrl.h diff --git a/soc/phytium/d2000/CMakeLists.txt b/soc/phytium/pd2008/CMakeLists.txt similarity index 100% rename from soc/phytium/d2000/CMakeLists.txt rename to soc/phytium/pd2008/CMakeLists.txt diff --git a/soc/phytium/d2000/Kconfig b/soc/phytium/pd2008/Kconfig similarity index 92% rename from soc/phytium/d2000/Kconfig rename to soc/phytium/pd2008/Kconfig index d9a1e0285fb..9a244a5b22f 100644 --- a/soc/phytium/d2000/Kconfig +++ b/soc/phytium/pd2008/Kconfig @@ -1,7 +1,7 @@ # Copyright (c) 2024 zhangyan # SPDX-License-Identifier: Apache-2.0 -config SOC_D2000 +config SOC_PD2008 select ARM64 select CPU_PHYTIUM_FTC663 select ARM_ARCH_TIMER if SYS_CLOCK_EXISTS diff --git a/soc/phytium/d2000/Kconfig.defconfig b/soc/phytium/pd2008/Kconfig.defconfig similarity index 96% rename from soc/phytium/d2000/Kconfig.defconfig rename to soc/phytium/pd2008/Kconfig.defconfig index 717aa2518b9..86b46f46053 100644 --- a/soc/phytium/d2000/Kconfig.defconfig +++ b/soc/phytium/pd2008/Kconfig.defconfig @@ -13,10 +13,10 @@ # CONDITIONS OF ANY KIND, either express or implied. See the License for the # specific language governing permissions and limitations under the License. -if SOC_D2000 +if SOC_PD2008 config SOC - default "d2000" + default "pd2008" config NUM_IRQS int diff --git a/soc/phytium/e2000q/Kconfig.soc b/soc/phytium/pd2008/Kconfig.soc similarity index 94% rename from soc/phytium/e2000q/Kconfig.soc rename to soc/phytium/pd2008/Kconfig.soc index a884c694e5b..d44029a5f8a 100644 --- a/soc/phytium/e2000q/Kconfig.soc +++ b/soc/phytium/pd2008/Kconfig.soc @@ -13,11 +13,11 @@ # CONDITIONS OF ANY KIND, either express or implied. See the License for the # specific language governing permissions and limitations under the License. -config SOC_E2000Q - bool "e2000q" +config SOC_PD2008 + bool "pd2008" select SOC_FAMILY_ARM64 -if SOC_E2000Q +if SOC_PD2008 config HAL_STANDALONE_SDK_DEBUG bool "standalone_sdk_debug" diff --git a/soc/phytium/d2000/mmu_regions.c b/soc/phytium/pd2008/mmu_regions.c similarity index 100% rename from soc/phytium/d2000/mmu_regions.c rename to soc/phytium/pd2008/mmu_regions.c diff --git a/soc/phytium/d2000/soc.c b/soc/phytium/pd2008/soc.c similarity index 100% rename from soc/phytium/d2000/soc.c rename to soc/phytium/pd2008/soc.c diff --git a/soc/phytium/d2000/soc.yml b/soc/phytium/pd2008/soc.yml similarity index 64% rename from soc/phytium/d2000/soc.yml rename to soc/phytium/pd2008/soc.yml index a2e5892d147..c4ac9ad36b9 100644 --- a/soc/phytium/d2000/soc.yml +++ b/soc/phytium/pd2008/soc.yml @@ -2,4 +2,4 @@ family: - name: arm64 socs: - - name: d2000 + - name: pd2008 diff --git a/soc/phytium/d2000_aarch32/CMakeLists.txt b/soc/phytium/pd2008_aarch32/CMakeLists.txt similarity index 100% rename from soc/phytium/d2000_aarch32/CMakeLists.txt rename to soc/phytium/pd2008_aarch32/CMakeLists.txt diff --git a/soc/phytium/d2000_aarch32/Kconfig b/soc/phytium/pd2008_aarch32/Kconfig similarity index 85% rename from soc/phytium/d2000_aarch32/Kconfig rename to soc/phytium/pd2008_aarch32/Kconfig index d5c0f47b00f..5d592cfa59b 100644 --- a/soc/phytium/d2000_aarch32/Kconfig +++ b/soc/phytium/pd2008_aarch32/Kconfig @@ -14,9 +14,9 @@ # CONDITIONS OF ANY KIND, either express or implied. See the License for the # specific language governing permissions and limitations under the License. -config SOC_D2000_AARCH32 - bool "Phytium D2000 Soc series" - select SOC_FAMILY_PHYTIUM_D2000 +config SOC_PD2008_AARCH32 + bool "Phytium pd2008 Soc series" + select SOC_FAMILY_PHYTIUM_PD2008 select ARM select CPU_PHYTIUM_FT663 select PLATFORM_SPECIFIC_INIT @@ -28,5 +28,5 @@ config SOC_D2000_AARCH32 #select CPU_HAS_FPU select VFP_DP_D16 help - Enable support for the Phytium d2000 + Enable support for the Phytium pd2008 SoC series (8-core Armv8 cpu). \ No newline at end of file diff --git a/soc/phytium/d2000_aarch32/Kconfig.defconfig b/soc/phytium/pd2008_aarch32/Kconfig.defconfig similarity index 94% rename from soc/phytium/d2000_aarch32/Kconfig.defconfig rename to soc/phytium/pd2008_aarch32/Kconfig.defconfig index e8c7faae68a..66e6abf7671 100644 --- a/soc/phytium/d2000_aarch32/Kconfig.defconfig +++ b/soc/phytium/pd2008_aarch32/Kconfig.defconfig @@ -13,10 +13,10 @@ # CONDITIONS OF ANY KIND, either express or implied. See the License for the # specific language governing permissions and limitations under the License. -if SOC_D2000_AARCH32 +if SOC_PD2008_AARCH32 config SOC - default "d2000_aarch32" + default "pd2008_aarch32" config NUM_IRQS int diff --git a/soc/phytium/e2000q_aarch32/Kconfig.soc b/soc/phytium/pd2008_aarch32/Kconfig.soc similarity index 91% rename from soc/phytium/e2000q_aarch32/Kconfig.soc rename to soc/phytium/pd2008_aarch32/Kconfig.soc index 67ba4584aca..e9d5cd6169e 100644 --- a/soc/phytium/e2000q_aarch32/Kconfig.soc +++ b/soc/phytium/pd2008_aarch32/Kconfig.soc @@ -13,11 +13,11 @@ # CONDITIONS OF ANY KIND, either express or implied. See the License for the # specific language governing permissions and limitations under the License. -config SOC_E2000D_AARCH32 - bool "e2000d_aarch32" +config SOC_PD2008_AARCH32 + bool "pd2008_aarch32" select SOC_FAMILY_ARM -if SOC_E2000D_AARCH32 +if SOC_PD2008_AARCH32 config HAL_STANDALONE_SDK_DEBUG bool "standalone_sdk_debug" diff --git a/soc/phytium/d2000_aarch32/soc.c b/soc/phytium/pd2008_aarch32/soc.c similarity index 100% rename from soc/phytium/d2000_aarch32/soc.c rename to soc/phytium/pd2008_aarch32/soc.c diff --git a/soc/phytium/d2000_aarch32/soc.h b/soc/phytium/pd2008_aarch32/soc.h similarity index 100% rename from soc/phytium/d2000_aarch32/soc.h rename to soc/phytium/pd2008_aarch32/soc.h diff --git a/soc/phytium/e2000q_aarch32/soc.yml b/soc/phytium/pd2008_aarch32/soc.yml similarity index 53% rename from soc/phytium/e2000q_aarch32/soc.yml rename to soc/phytium/pd2008_aarch32/soc.yml index c6dc628728e..cc0dfc8d48d 100644 --- a/soc/phytium/e2000q_aarch32/soc.yml +++ b/soc/phytium/pd2008_aarch32/soc.yml @@ -2,4 +2,4 @@ family: - name: arm socs: - - name: e2000d_aarch32 + - name: pd2008_aarch32 diff --git a/soc/phytium/e2000d/CMakeLists.txt b/soc/phytium/pd2408/CMakeLists.txt similarity index 100% rename from soc/phytium/e2000d/CMakeLists.txt rename to soc/phytium/pd2408/CMakeLists.txt diff --git a/soc/phytium/pd2408/Kconfig b/soc/phytium/pd2408/Kconfig new file mode 100644 index 00000000000..ef7ec4d7bff --- /dev/null +++ b/soc/phytium/pd2408/Kconfig @@ -0,0 +1,9 @@ +# Copyright (c) 2024 zhangyan +# SPDX-License-Identifier: Apache-2.0 + +config SOC_PD2408 + select ARM64 + select CPU_PHYTIUM_FTC862 + select ARM_ARCH_TIMER if SYS_CLOCK_EXISTS + select PHYTIUM_STANDALONE_SDK + select PHYTIUM_SOFT diff --git a/soc/phytium/pd2408/Kconfig.defconfig b/soc/phytium/pd2408/Kconfig.defconfig new file mode 100644 index 00000000000..e197a49b94a --- /dev/null +++ b/soc/phytium/pd2408/Kconfig.defconfig @@ -0,0 +1,29 @@ +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. + +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at + +# https://opensource.org/license/apache-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. + +if SOC_PD2408 + +config SOC + default "pd2408" + +config NUM_IRQS + int + default 195 + +config SYS_CLOCK_HW_CYCLES_PER_SEC + int + default 50000000 + +endif diff --git a/soc/phytium/pd2408/Kconfig.soc b/soc/phytium/pd2408/Kconfig.soc new file mode 100644 index 00000000000..49f16e8ac93 --- /dev/null +++ b/soc/phytium/pd2408/Kconfig.soc @@ -0,0 +1,27 @@ +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. + +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at + +# https://opensource.org/license/apache-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. + +config SOC_PD2408 + bool "pd2408" + select SOC_FAMILY_ARM64 + +config SOC + default "soc_pd2408" if SOC_PD2408 + +if SOC_PD2408 +config HAL_STANDALONE_SDK_DEBUG + bool "standalone_sdk_debug" + +endif diff --git a/soc/phytium/pd2408/mmu_regions.c b/soc/phytium/pd2408/mmu_regions.c new file mode 100644 index 00000000000..6c51737df3f --- /dev/null +++ b/soc/phytium/pd2408/mmu_regions.c @@ -0,0 +1,52 @@ +/* + * Copyright : (C) 2024 Phytium Information Technology, Inc. + * All Rights Reserved. + * + * This program is OPEN SOURCE software: you can redistribute it and/or modify it + * under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd, + * either version 1.0 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the Phytium Public License for more details. + * + * + * FilePath: mmu_regions.c + * Created Date: 2024-10-11 14:03:59 + * Last Modified: 2024-10-15 13:43:05 + * Description: This file is for + * + * Modify History: + * Ver Who Date Changes + * ----- ---------- -------- --------------------------------- + */ + +#include +#include +#include + +static const struct arm_mmu_region mmu_regions[] = { + MMU_REGION_FLAT_ENTRY("GIC", + DT_REG_ADDR_BY_IDX(DT_INST(0, arm_gic), 0), + DT_REG_SIZE_BY_IDX(DT_INST(0, arm_gic), 0), + MT_DEVICE_nGnRnE | MT_P_RW_U_NA | MT_DEFAULT_SECURE_STATE), + + MMU_REGION_FLAT_ENTRY("GIC", + DT_REG_ADDR_BY_IDX(DT_INST(0, arm_gic), 1), + DT_REG_SIZE_BY_IDX(DT_INST(0, arm_gic), 1), + MT_DEVICE_nGnRnE | MT_P_RW_U_NA | MT_DEFAULT_SECURE_STATE), + + MMU_REGION_FLAT_ENTRY("UART1", + DT_REG_ADDR(DT_INST(0, arm_pl011)), + DT_REG_SIZE(DT_INST(0, arm_pl011)), + MT_DEVICE_nGnRnE | MT_P_RW_U_NA | MT_DEFAULT_SECURE_STATE), + +}; + +const struct arm_mmu_config mmu_config = { + .num_regions = ARRAY_SIZE(mmu_regions), + .mmu_regions = mmu_regions, +}; + + + diff --git a/soc/phytium/e2000q/pinctrl_soc.h b/soc/phytium/pd2408/pinctrl_soc.h similarity index 85% rename from soc/phytium/e2000q/pinctrl_soc.h rename to soc/phytium/pd2408/pinctrl_soc.h index 50a66ff0a0a..33b74d57db6 100644 --- a/soc/phytium/e2000q/pinctrl_soc.h +++ b/soc/phytium/pd2408/pinctrl_soc.h @@ -13,8 +13,8 @@ // CONDITIONS OF ANY KIND, either express or implied. See the License for the // specific language governing permissions and limitations under the License. -#ifndef ZEPHYR_SOC_ARM64_PHYTIUM_E2000_PINCTRL_SOC_H_ -#define ZEPHYR_SOC_ARM64_PHYTIUM_E2000_PINCTRL_SOC_H_ +#ifndef ZEPHYR_SOC_ARM64_PHYTIUM_PD2408_PINCTRL_SOC_H_ +#define ZEPHYR_SOC_ARM64_PHYTIUM_PD2408_PINCTRL_SOC_H_ #include #include @@ -31,14 +31,14 @@ struct pinctrl_soc_pin { typedef struct pinctrl_soc_pin pinctrl_soc_pin_t; -#define PHYTIUM_E2000_DT_PIN(node_id) \ +#define PHYTIUM_PD2408_DT_PIN(node_id) \ { \ .pin_reg_offset = DT_PROP_BY_IDX(node_id, pinmux, 0), \ .func_num = DT_PROP_BY_IDX(node_id, pinmux, 1) \ }, #define Z_PINCTRL_STATE_PIN_INIT(node_id, prop, idx) \ - PHYTIUM_E2000_DT_PIN(DT_PROP_BY_IDX(node_id, prop, idx)) + PHYTIUM_PD2408_DT_PIN(DT_PROP_BY_IDX(node_id, prop, idx)) #define Z_PINCTRL_STATE_PINS_INIT(node_id, prop) \ { DT_FOREACH_PROP_ELEM(node_id, prop, Z_PINCTRL_STATE_PIN_INIT) } diff --git a/soc/phytium/pd2408/soc.c b/soc/phytium/pd2408/soc.c new file mode 100644 index 00000000000..71dc4ec670d --- /dev/null +++ b/soc/phytium/pd2408/soc.c @@ -0,0 +1,32 @@ +/* + * Copyright : (C) 2024 Phytium Information Technology, Inc. + * All Rights Reserved. + * + * This program is OPEN SOURCE software: you can redistribute it and/or modify it + * under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd, + * either version 1.0 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the Phytium Public License for more details. + * + * + * FilePath: soc.c + * Created Date: 2024-12-04 16:39:00 + * Last Modified: 2024-12-04 16:39:01 + * Description: This file is for + * + * Modify History: + * Ver Who Date Changes + * ----- ---------- -------- --------------------------------- + */ + + +#include + +/* Boot-time static default printk handler, possibly to be overridden later. */ +int arch_printk_char_out(int c) +{ + putchar(c) ; + return 0; +} diff --git a/soc/phytium/e2000d/soc.yml b/soc/phytium/pd2408/soc.yml similarity index 64% rename from soc/phytium/e2000d/soc.yml rename to soc/phytium/pd2408/soc.yml index e4b9e3ff9ac..3cee8395b7a 100644 --- a/soc/phytium/e2000d/soc.yml +++ b/soc/phytium/pd2408/soc.yml @@ -2,4 +2,4 @@ family: - name: arm64 socs: - - name: e2000d + - name: pd2408 diff --git a/soc/phytium/e2000q/CMakeLists.txt b/soc/phytium/pe2202/CMakeLists.txt similarity index 100% rename from soc/phytium/e2000q/CMakeLists.txt rename to soc/phytium/pe2202/CMakeLists.txt diff --git a/soc/phytium/e2000d/Kconfig b/soc/phytium/pe2202/Kconfig similarity index 89% rename from soc/phytium/e2000d/Kconfig rename to soc/phytium/pe2202/Kconfig index a61e901569b..2dc4c7895f3 100644 --- a/soc/phytium/e2000d/Kconfig +++ b/soc/phytium/pe2202/Kconfig @@ -1,7 +1,7 @@ # Copyright (c) 2024 zhangyan # SPDX-License-Identifier: Apache-2.0 -config SOC_E2000D +config SOC_PE2202 select ARM64 select CPU_PHYTIUM_FTC310 select ARM_ARCH_TIMER if SYS_CLOCK_EXISTS diff --git a/soc/phytium/e2000d/Kconfig.defconfig b/soc/phytium/pe2202/Kconfig.defconfig similarity index 96% rename from soc/phytium/e2000d/Kconfig.defconfig rename to soc/phytium/pe2202/Kconfig.defconfig index 0cb8669ed55..17253e6f8f9 100644 --- a/soc/phytium/e2000d/Kconfig.defconfig +++ b/soc/phytium/pe2202/Kconfig.defconfig @@ -13,10 +13,10 @@ # CONDITIONS OF ANY KIND, either express or implied. See the License for the # specific language governing permissions and limitations under the License. -if SOC_E2000D +if SOC_PE2202 config SOC - default "e2000d" + default "pe2202" config NUM_IRQS int diff --git a/soc/phytium/d2000/Kconfig.soc b/soc/phytium/pe2202/Kconfig.soc similarity index 94% rename from soc/phytium/d2000/Kconfig.soc rename to soc/phytium/pe2202/Kconfig.soc index 3ec2d1fe893..6bd7d84044b 100644 --- a/soc/phytium/d2000/Kconfig.soc +++ b/soc/phytium/pe2202/Kconfig.soc @@ -13,11 +13,11 @@ # CONDITIONS OF ANY KIND, either express or implied. See the License for the # specific language governing permissions and limitations under the License. -config SOC_D2000 - bool "d2000" +config SOC_PE2202 + bool "pe2202" select SOC_FAMILY_ARM64 -if SOC_D2000 +if SOC_PE2202 config HAL_STANDALONE_SDK_DEBUG bool "standalone_sdk_debug" diff --git a/soc/phytium/e2000d/mmu_regions.c b/soc/phytium/pe2202/mmu_regions.c similarity index 100% rename from soc/phytium/e2000d/mmu_regions.c rename to soc/phytium/pe2202/mmu_regions.c diff --git a/soc/phytium/pe2202/pinctrl_soc.h b/soc/phytium/pe2202/pinctrl_soc.h new file mode 100644 index 00000000000..99c9648dcd9 --- /dev/null +++ b/soc/phytium/pe2202/pinctrl_soc.h @@ -0,0 +1,51 @@ +// Phytium is pleased to support the open source community by making Zephyr-SDK available. + +// +// Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +// +// Licensed under the Apache-2.0 License (the "License"); you may not use this file except +// in compliance with the License. You may obtain a copy of the License at +// +// https://opensource.org/license/apache-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 ZEPHYR_SOC_ARM64_PHYTIUM_PE2202_PINCTRL_SOC_H_ +#define ZEPHYR_SOC_ARM64_PHYTIUM_PE2202_PINCTRL_SOC_H_ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct pinctrl_soc_pin { + + uint32_t pin_reg_offset; + uint32_t func_num; +}; + +typedef struct pinctrl_soc_pin pinctrl_soc_pin_t; + +#define PHYTIUM_PE2202_DT_PIN(node_id) \ + { \ + .pin_reg_offset = DT_PROP_BY_IDX(node_id, pinmux, 0), \ + .func_num = DT_PROP_BY_IDX(node_id, pinmux, 1) \ + }, + +#define Z_PINCTRL_STATE_PIN_INIT(node_id, prop, idx) \ + PHYTIUM_PE2202_DT_PIN(DT_PROP_BY_IDX(node_id, prop, idx)) + +#define Z_PINCTRL_STATE_PINS_INIT(node_id, prop) \ + { DT_FOREACH_PROP_ELEM(node_id, prop, Z_PINCTRL_STATE_PIN_INIT) } + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/soc/phytium/e2000d/soc.c b/soc/phytium/pe2202/soc.c similarity index 100% rename from soc/phytium/e2000d/soc.c rename to soc/phytium/pe2202/soc.c diff --git a/soc/phytium/e2000d/soc.h b/soc/phytium/pe2202/soc.h similarity index 100% rename from soc/phytium/e2000d/soc.h rename to soc/phytium/pe2202/soc.h diff --git a/soc/phytium/e2000q/soc.yml b/soc/phytium/pe2202/soc.yml similarity index 64% rename from soc/phytium/e2000q/soc.yml rename to soc/phytium/pe2202/soc.yml index eb16423c65e..e519b35292f 100644 --- a/soc/phytium/e2000q/soc.yml +++ b/soc/phytium/pe2202/soc.yml @@ -2,4 +2,4 @@ family: - name: arm64 socs: - - name: e2000q + - name: pe2202 diff --git a/soc/phytium/e2000d_aarch32/CMakeLists.txt b/soc/phytium/pe2202_aarch32/CMakeLists.txt similarity index 100% rename from soc/phytium/e2000d_aarch32/CMakeLists.txt rename to soc/phytium/pe2202_aarch32/CMakeLists.txt diff --git a/soc/phytium/e2000d_aarch32/Kconfig b/soc/phytium/pe2202_aarch32/Kconfig similarity index 91% rename from soc/phytium/e2000d_aarch32/Kconfig rename to soc/phytium/pe2202_aarch32/Kconfig index 40489f08275..7536aada387 100644 --- a/soc/phytium/e2000d_aarch32/Kconfig +++ b/soc/phytium/pe2202_aarch32/Kconfig @@ -14,7 +14,7 @@ # CONDITIONS OF ANY KIND, either express or implied. See the License for the # specific language governing permissions and limitations under the License. -config SOC_E2000Q_AARCH32 +config SOC_PE2202_AARCH32 bool "Phytium E2000 Soc series" select ARM select CPU_PHYTIUM_FT310 @@ -27,5 +27,5 @@ config SOC_E2000Q_AARCH32 #select CPU_HAS_FPU select VFP_DP_D16 help - Enable support for the Phytium e2000q + Enable support for the Phytium pe2202 SoC series (4-core Armv8 cpu). \ No newline at end of file diff --git a/soc/phytium/e2000d_aarch32/Kconfig.defconfig b/soc/phytium/pe2202_aarch32/Kconfig.defconfig similarity index 94% rename from soc/phytium/e2000d_aarch32/Kconfig.defconfig rename to soc/phytium/pe2202_aarch32/Kconfig.defconfig index 440afdca7cb..62ad7985265 100644 --- a/soc/phytium/e2000d_aarch32/Kconfig.defconfig +++ b/soc/phytium/pe2202_aarch32/Kconfig.defconfig @@ -13,10 +13,10 @@ # CONDITIONS OF ANY KIND, either express or implied. See the License for the # specific language governing permissions and limitations under the License. -if SOC_E2000Q_AARCH32 +if SOC_PE2202_AARCH32 config SOC - default "e2000q_aarch32" + default "pe2202_aarch32" config NUM_IRQS int diff --git a/soc/phytium/d2000_aarch32/Kconfig.soc b/soc/phytium/pe2202_aarch32/Kconfig.soc similarity index 91% rename from soc/phytium/d2000_aarch32/Kconfig.soc rename to soc/phytium/pe2202_aarch32/Kconfig.soc index cbae6004e1f..15940a0aaa4 100644 --- a/soc/phytium/d2000_aarch32/Kconfig.soc +++ b/soc/phytium/pe2202_aarch32/Kconfig.soc @@ -13,11 +13,11 @@ # CONDITIONS OF ANY KIND, either express or implied. See the License for the # specific language governing permissions and limitations under the License. -config SOC_D2000_AARCH32 - bool "d2000_aarch32" +config SOC_PE2202_AARCH32 + bool "pe2202_aarch32" select SOC_FAMILY_ARM -if SOC_D2000_AARCH32 +if SOC_PE2202_AARCH32 config HAL_STANDALONE_SDK_DEBUG bool "standalone_sdk_debug" diff --git a/soc/phytium/pe2202_aarch32/pinctrl_soc.h b/soc/phytium/pe2202_aarch32/pinctrl_soc.h new file mode 100644 index 00000000000..92ae93572a6 --- /dev/null +++ b/soc/phytium/pe2202_aarch32/pinctrl_soc.h @@ -0,0 +1,51 @@ +// Phytium is pleased to support the open source community by making Zephyr-SDK available. + +// +// Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +// +// Licensed under the Apache-2.0 License (the "License"); you may not use this file except +// in compliance with the License. You may obtain a copy of the License at +// +// https://opensource.org/license/apache-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 ZEPHYR_SOC_ARM64_PHYTIUM_PE2204_AARCH32_PINCTRL_SOC_H_ +#define ZEPHYR_SOC_ARM64_PHYTIUM_PE2204_AARCH32_PINCTRL_SOC_H_ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct pinctrl_soc_pin { + + uint32_t pin_reg_offset; + uint32_t func_num; +}; + +typedef struct pinctrl_soc_pin pinctrl_soc_pin_t; + +#define PHYTIUM_PE2204_AARCH32_DT_PIN(node_id) \ + { \ + .pin_reg_offset = DT_PROP_BY_IDX(node_id, pinmux, 0), \ + .func_num = DT_PROP_BY_IDX(node_id, pinmux, 1) \ + }, + +#define Z_PINCTRL_STATE_PIN_INIT(node_id, prop, idx) \ + PHYTIUM_PE2204_AARCH32_DT_PIN(DT_PROP_BY_IDX(node_id, prop, idx)) + +#define Z_PINCTRL_STATE_PINS_INIT(node_id, prop) \ + { DT_FOREACH_PROP_ELEM(node_id, prop, Z_PINCTRL_STATE_PIN_INIT) } + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/soc/phytium/e2000d_aarch32/soc.c b/soc/phytium/pe2202_aarch32/soc.c similarity index 100% rename from soc/phytium/e2000d_aarch32/soc.c rename to soc/phytium/pe2202_aarch32/soc.c diff --git a/soc/phytium/e2000d_aarch32/soc.h b/soc/phytium/pe2202_aarch32/soc.h similarity index 100% rename from soc/phytium/e2000d_aarch32/soc.h rename to soc/phytium/pe2202_aarch32/soc.h diff --git a/soc/phytium/d2000_aarch32/soc.yml b/soc/phytium/pe2202_aarch32/soc.yml similarity index 53% rename from soc/phytium/d2000_aarch32/soc.yml rename to soc/phytium/pe2202_aarch32/soc.yml index fc032adf16c..b6ce5651e2d 100644 --- a/soc/phytium/d2000_aarch32/soc.yml +++ b/soc/phytium/pe2202_aarch32/soc.yml @@ -2,4 +2,4 @@ family: - name: arm socs: - - name: d2000_aarch32 + - name: pe2202_aarch32 diff --git a/soc/phytium/pe2204/CMakeLists.txt b/soc/phytium/pe2204/CMakeLists.txt new file mode 100644 index 00000000000..801a8ef8fc7 --- /dev/null +++ b/soc/phytium/pe2204/CMakeLists.txt @@ -0,0 +1,10 @@ +# Copyright (c) 2024 zhangyan +# SPDX-License-Identifier: Apache-2.0 + +zephyr_sources_ifdef(CONFIG_ARM_MMU mmu_regions.c) + +zephyr_sources(soc.c) + +zephyr_include_directories(.) + +set(SOC_LINKER_SCRIPT ${ZEPHYR_BASE}/include/zephyr/arch/arm64/scripts/linker.ld CACHE INTERNAL "") diff --git a/soc/phytium/e2000q/Kconfig b/soc/phytium/pe2204/Kconfig similarity index 89% rename from soc/phytium/e2000q/Kconfig rename to soc/phytium/pe2204/Kconfig index 50ef9a1cb39..4befee3a964 100644 --- a/soc/phytium/e2000q/Kconfig +++ b/soc/phytium/pe2204/Kconfig @@ -1,7 +1,7 @@ # Copyright (c) 2024 zhangyan # SPDX-License-Identifier: Apache-2.0 -config SOC_E2000Q +config SOC_PE2204 select ARM64 select CPU_PHYTIUM_FTC310 select ARM_ARCH_TIMER if SYS_CLOCK_EXISTS diff --git a/soc/phytium/e2000q/Kconfig.defconfig b/soc/phytium/pe2204/Kconfig.defconfig similarity index 96% rename from soc/phytium/e2000q/Kconfig.defconfig rename to soc/phytium/pe2204/Kconfig.defconfig index d1bdd2b525d..4a99515ed1c 100644 --- a/soc/phytium/e2000q/Kconfig.defconfig +++ b/soc/phytium/pe2204/Kconfig.defconfig @@ -13,10 +13,10 @@ # CONDITIONS OF ANY KIND, either express or implied. See the License for the # specific language governing permissions and limitations under the License. -if SOC_E2000Q +if SOC_PE2204 config SOC - default "e2000q" + default "pe2204" config NUM_IRQS int diff --git a/soc/phytium/e2000d/Kconfig.soc b/soc/phytium/pe2204/Kconfig.soc similarity index 94% rename from soc/phytium/e2000d/Kconfig.soc rename to soc/phytium/pe2204/Kconfig.soc index cf7518e7e7c..d81c3064a16 100644 --- a/soc/phytium/e2000d/Kconfig.soc +++ b/soc/phytium/pe2204/Kconfig.soc @@ -13,11 +13,11 @@ # CONDITIONS OF ANY KIND, either express or implied. See the License for the # specific language governing permissions and limitations under the License. -config SOC_E2000D - bool "e2000d" +config SOC_PE2204 + bool "pe2204" select SOC_FAMILY_ARM64 -if SOC_E2000D +if SOC_PE2204 config HAL_STANDALONE_SDK_DEBUG bool "standalone_sdk_debug" diff --git a/soc/phytium/e2000q/mmu_regions.c b/soc/phytium/pe2204/mmu_regions.c similarity index 100% rename from soc/phytium/e2000q/mmu_regions.c rename to soc/phytium/pe2204/mmu_regions.c diff --git a/soc/phytium/pe2204/pinctrl_soc.h b/soc/phytium/pe2204/pinctrl_soc.h new file mode 100644 index 00000000000..1436e64b567 --- /dev/null +++ b/soc/phytium/pe2204/pinctrl_soc.h @@ -0,0 +1,51 @@ +// Phytium is pleased to support the open source community by making Zephyr-SDK available. + +// +// Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +// +// Licensed under the Apache-2.0 License (the "License"); you may not use this file except +// in compliance with the License. You may obtain a copy of the License at +// +// https://opensource.org/license/apache-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 ZEPHYR_SOC_ARM64_PHYTIUM_PE2204_PINCTRL_SOC_H_ +#define ZEPHYR_SOC_ARM64_PHYTIUM_PE2204_PINCTRL_SOC_H_ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct pinctrl_soc_pin { + + uint32_t pin_reg_offset; + uint32_t func_num; +}; + +typedef struct pinctrl_soc_pin pinctrl_soc_pin_t; + +#define PHYTIUM_PE2204_DT_PIN(node_id) \ + { \ + .pin_reg_offset = DT_PROP_BY_IDX(node_id, pinmux, 0), \ + .func_num = DT_PROP_BY_IDX(node_id, pinmux, 1) \ + }, + +#define Z_PINCTRL_STATE_PIN_INIT(node_id, prop, idx) \ + PHYTIUM_PE2204_DT_PIN(DT_PROP_BY_IDX(node_id, prop, idx)) + +#define Z_PINCTRL_STATE_PINS_INIT(node_id, prop) \ + { DT_FOREACH_PROP_ELEM(node_id, prop, Z_PINCTRL_STATE_PIN_INIT) } + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/soc/phytium/e2000q/soc.c b/soc/phytium/pe2204/soc.c similarity index 100% rename from soc/phytium/e2000q/soc.c rename to soc/phytium/pe2204/soc.c diff --git a/soc/phytium/pe2204/soc.yml b/soc/phytium/pe2204/soc.yml new file mode 100644 index 00000000000..7a41f116ab7 --- /dev/null +++ b/soc/phytium/pe2204/soc.yml @@ -0,0 +1,5 @@ +family: + +- name: arm64 + socs: + - name: pe2204 diff --git a/soc/phytium/e2000q_aarch32/CMakeLists.txt b/soc/phytium/pe2204_aarch32/CMakeLists.txt similarity index 100% rename from soc/phytium/e2000q_aarch32/CMakeLists.txt rename to soc/phytium/pe2204_aarch32/CMakeLists.txt diff --git a/soc/phytium/e2000q_aarch32/Kconfig b/soc/phytium/pe2204_aarch32/Kconfig similarity index 88% rename from soc/phytium/e2000q_aarch32/Kconfig rename to soc/phytium/pe2204_aarch32/Kconfig index f6bc09fb14d..adce6e9eda0 100644 --- a/soc/phytium/e2000q_aarch32/Kconfig +++ b/soc/phytium/pe2204_aarch32/Kconfig @@ -14,8 +14,8 @@ # CONDITIONS OF ANY KIND, either express or implied. See the License for the # specific language governing permissions and limitations under the License. -config SOC_E2000D_AARCH32 - bool "Phytium E2000 Soc series" +config SOC_PE2204_AARCH32 + bool "Phytium PE2004 Soc series" select ARM select CPU_PHYTIUM_FT310 select PLATFORM_SPECIFIC_INIT @@ -27,5 +27,5 @@ config SOC_E2000D_AARCH32 #select CPU_HAS_FPU select VFP_DP_D16 help - Enable support for the Phytium e2000d + Enable support for the Phytium pe2204 SoC series (4-core Armv8 cpu). \ No newline at end of file diff --git a/soc/phytium/e2000q_aarch32/Kconfig.defconfig b/soc/phytium/pe2204_aarch32/Kconfig.defconfig similarity index 94% rename from soc/phytium/e2000q_aarch32/Kconfig.defconfig rename to soc/phytium/pe2204_aarch32/Kconfig.defconfig index 7e4a3ece87b..5f0a46a5bd7 100644 --- a/soc/phytium/e2000q_aarch32/Kconfig.defconfig +++ b/soc/phytium/pe2204_aarch32/Kconfig.defconfig @@ -13,10 +13,10 @@ # CONDITIONS OF ANY KIND, either express or implied. See the License for the # specific language governing permissions and limitations under the License. -if SOC_E2000D_AARCH32 +if SOC_PE2204_AARCH32 config SOC - default "e2000d_aarch32" + default "pe2204_aarch32" config NUM_IRQS int diff --git a/soc/phytium/e2000d_aarch32/Kconfig.soc b/soc/phytium/pe2204_aarch32/Kconfig.soc similarity index 91% rename from soc/phytium/e2000d_aarch32/Kconfig.soc rename to soc/phytium/pe2204_aarch32/Kconfig.soc index 43040d8719c..eb9f9799f14 100644 --- a/soc/phytium/e2000d_aarch32/Kconfig.soc +++ b/soc/phytium/pe2204_aarch32/Kconfig.soc @@ -13,11 +13,11 @@ # CONDITIONS OF ANY KIND, either express or implied. See the License for the # specific language governing permissions and limitations under the License. -config SOC_E2000Q_AARCH32 - bool "e2000q_aarch32" +config SOC_PE2204_AARCH32 + bool "pe2204_aarch32" select SOC_FAMILY_ARM -if SOC_E2000Q_AARCH32 +if SOC_PE2204_AARCH32 config HAL_STANDALONE_SDK_DEBUG bool "standalone_sdk_debug" diff --git a/soc/phytium/pe2204_aarch32/pinctrl_soc.h b/soc/phytium/pe2204_aarch32/pinctrl_soc.h new file mode 100644 index 00000000000..5b57b078ca8 --- /dev/null +++ b/soc/phytium/pe2204_aarch32/pinctrl_soc.h @@ -0,0 +1,51 @@ +// Phytium is pleased to support the open source community by making Zephyr-SDK available. + +// +// Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +// +// Licensed under the Apache-2.0 License (the "License"); you may not use this file except +// in compliance with the License. You may obtain a copy of the License at +// +// https://opensource.org/license/apache-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 ZEPHYR_SOC_ARM64_PHYTIUM_PE2202_AARCH32_PINCTRL_SOC_H_ +#define ZEPHYR_SOC_ARM64_PHYTIUM_PE2202_AARCH32_PINCTRL_SOC_H_ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct pinctrl_soc_pin { + + uint32_t pin_reg_offset; + uint32_t func_num; +}; + +typedef struct pinctrl_soc_pin pinctrl_soc_pin_t; + +#define PHYTIUM_PE2202_AARCH32_DT_PIN(node_id) \ + { \ + .pin_reg_offset = DT_PROP_BY_IDX(node_id, pinmux, 0), \ + .func_num = DT_PROP_BY_IDX(node_id, pinmux, 1) \ + }, + +#define Z_PINCTRL_STATE_PIN_INIT(node_id, prop, idx) \ + PHYTIUM_PE2202_AARCH32_DT_PIN(DT_PROP_BY_IDX(node_id, prop, idx)) + +#define Z_PINCTRL_STATE_PINS_INIT(node_id, prop) \ + { DT_FOREACH_PROP_ELEM(node_id, prop, Z_PINCTRL_STATE_PIN_INIT) } + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/soc/phytium/e2000q_aarch32/soc.c b/soc/phytium/pe2204_aarch32/soc.c similarity index 100% rename from soc/phytium/e2000q_aarch32/soc.c rename to soc/phytium/pe2204_aarch32/soc.c diff --git a/soc/phytium/e2000q_aarch32/soc.h b/soc/phytium/pe2204_aarch32/soc.h similarity index 100% rename from soc/phytium/e2000q_aarch32/soc.h rename to soc/phytium/pe2204_aarch32/soc.h diff --git a/soc/phytium/e2000d_aarch32/soc.yml b/soc/phytium/pe2204_aarch32/soc.yml similarity index 53% rename from soc/phytium/e2000d_aarch32/soc.yml rename to soc/phytium/pe2204_aarch32/soc.yml index 917a5a2fec0..44a923f0319 100644 --- a/soc/phytium/e2000d_aarch32/soc.yml +++ b/soc/phytium/pe2204_aarch32/soc.yml @@ -2,4 +2,4 @@ family: - name: arm socs: - - name: e2000q_aarch32 + - name: pe2204_aarch32 diff --git a/west.yml b/west.yml index 3fc08ce6a22..2b98ca2ae87 100644 --- a/west.yml +++ b/west.yml @@ -31,322 +31,26 @@ manifest: # # Please add items below based on alphabetical order projects: - - name: acpica - revision: 8d24867bc9c9d81c81eeac59391cda59333affd4 - path: modules/lib/acpica - - name: bsim - repo-path: babblesim-manifest - revision: 9351ae1ad44864a49c351f9704f65f43046abeb0 - path: tools/bsim - groups: - - babblesim - - name: babblesim_base - remote: babblesim - repo-path: base - path: tools/bsim/components - revision: 4bd907be0b2abec3b31a23fd8ca98db2a07209d2 - groups: - - babblesim - - name: babblesim_ext_2G4_libPhyComv1 - remote: babblesim - repo-path: ext_2G4_libPhyComv1 - path: tools/bsim/components/ext_2G4_libPhyComv1 - revision: 93f5eba512c438b0c9ebc1b1a947517c865b3643 - groups: - - babblesim - - name: babblesim_ext_2G4_phy_v1 - remote: babblesim - repo-path: ext_2G4_phy_v1 - path: tools/bsim/components/ext_2G4_phy_v1 - revision: 04eeb3c3794444122fbeeb3715f4233b0b50cfbb - groups: - - babblesim - - name: babblesim_ext_2G4_channel_NtNcable - remote: babblesim - repo-path: ext_2G4_channel_NtNcable - path: tools/bsim/components/ext_2G4_channel_NtNcable - revision: 20a38c997f507b0aa53817aab3d73a462fff7af1 - groups: - - babblesim - - name: babblesim_ext_2G4_channel_multiatt - remote: babblesim - repo-path: ext_2G4_channel_multiatt - path: tools/bsim/components/ext_2G4_channel_multiatt - revision: bde72a57384dde7a4310bcf3843469401be93074 - groups: - - babblesim - - name: babblesim_ext_2G4_modem_magic - remote: babblesim - repo-path: ext_2G4_modem_magic - path: tools/bsim/components/ext_2G4_modem_magic - revision: edfcda2d3937a74be0a59d6cd47e0f50183453da - groups: - - babblesim - - name: babblesim_ext_2G4_modem_BLE_simple - remote: babblesim - repo-path: ext_2G4_modem_BLE_simple - path: tools/bsim/components/ext_2G4_modem_BLE_simple - revision: a38d2d24b04a6f970a225d1316047256ebf5a539 - groups: - - babblesim - - name: babblesim_ext_2G4_device_burst_interferer - remote: babblesim - repo-path: ext_2G4_device_burst_interferer - path: tools/bsim/components/ext_2G4_device_burst_interferer - revision: 5b5339351d6e6a2368c686c734dc8b2fc65698fc - groups: - - babblesim - - name: babblesim_ext_2G4_device_WLAN_actmod - remote: babblesim - repo-path: ext_2G4_device_WLAN_actmod - path: tools/bsim/components/ext_2G4_device_WLAN_actmod - revision: 9cb6d8e72695f6b785e57443f0629a18069d6ce4 - groups: - - babblesim - - name: babblesim_ext_2G4_device_playback - remote: babblesim - repo-path: ext_2G4_device_playback - path: tools/bsim/components/ext_2G4_device_playback - revision: abb48cd71ddd4e2a9022f4bf49b2712524c483e8 - groups: - - babblesim - - name: babblesim_ext_libCryptov1 - remote: babblesim - repo-path: ext_libCryptov1 - path: tools/bsim/components/ext_libCryptov1 - revision: eed6d7038e839153e340bd333bc43541cb90ba64 - groups: - - babblesim - name: cmsis revision: 4b96cbb174678dcd3ca86e11e1f24bc5f8726da0 path: modules/hal/cmsis groups: - hal + - name: fatfs + revision: 427159bf95ea49b7680facffaa29ad506b42709b + path: modules/fs/fatfs + groups: + - fs - name: cmsis-dsp revision: 6489e771e9c405f1763b52d64a3f17a1ec488ace path: modules/lib/cmsis-dsp - name: cmsis-nn revision: ea987c1ca661be723de83bd159aed815d6cbd430 path: modules/lib/cmsis-nn - - name: edtt - revision: b9ca3c7030518f07b7937dacf970d37a47865a76 - path: tools/edtt - groups: - - tools - - name: fatfs - revision: 427159bf95ea49b7680facffaa29ad506b42709b - path: modules/fs/fatfs - groups: - - fs - - name: hal_adi - revision: dee9a7b1eff13a9da0560daf8842d61657f9d61e - path: modules/hal/adi - groups: - - hal - - name: hal_altera - revision: 4fe4df959d4593ce66e676aeba0b57f546dba0fe - path: modules/hal/altera - groups: - - hal - - name: hal_ambiq - revision: e25327f026df1ee08f1bf01a4bbfeb5e5f4026f1 - path: modules/hal/ambiq - groups: - - hal - - name: hal_atmel - revision: 56d60ebc909ad065bf6554cee73487969857614b - path: modules/hal/atmel - groups: - - hal - - name: hal_espressif - revision: b562c44cb5f453cb011001779ef2ad1a3851a96f - path: modules/hal/espressif - west-commands: west/west-commands.yml - groups: - - hal - - name: hal_ethos_u - revision: 8e2cf756b474eff9a32a9bdf1775d9620f1eadcf - path: modules/hal/ethos_u - groups: - - hal - - name: hal_gigadevice - revision: 2994b7dde8b0b0fa9b9c0ccb13474b6a486cddc3 - path: modules/hal/gigadevice - groups: - - hal - - name: hal_infineon - revision: f25734a72c585f6675e8254a382e80e78a3cd03a - path: modules/hal/infineon - groups: - - hal - - name: hal_intel - revision: 0905a528623de56b1bedf817536321bcdbc0efae - path: modules/hal/intel - groups: - - hal - - name: hal_microchip - revision: 71eba057c0cb7fc11b6f33eb40a82f1ebe2c571c - path: modules/hal/microchip - groups: - - hal - - name: hal_nordic - revision: ab5cb2e2faeb1edfad7a25286dcb513929ae55da - path: modules/hal/nordic - groups: - - hal - - name: hal_nuvoton - revision: 466c3eed9c98453fb23953bf0e0427fea01924be - path: modules/hal/nuvoton - groups: - - hal - - name: hal_nxp - revision: 862e001504bd6e0a4feade6a718e9f973116849c - path: modules/hal/nxp - groups: - - hal - - name: hal_openisa - revision: eabd530a64d71de91d907bad257cd61aacf607bc - path: modules/hal/openisa - groups: - - hal - - name: hal_quicklogic - revision: bad894440fe72c814864798c8e3a76d13edffb6c - path: modules/hal/quicklogic - repo-path: hal_quicklogic - groups: - - hal - - name: hal_renesas - path: modules/hal/renesas - revision: af77d7cdfeeff290593e7e99f54f0c1e2a3f91e6 - groups: - - hal - - name: hal_rpi_pico - path: modules/hal/rpi_pico - revision: fba7162cc7bee06d0149622bbcaac4e41062d368 - groups: - - hal - - name: hal_silabs - revision: a09dd1b82b24aa3060e162c0dfa40026c0dba450 - path: modules/hal/silabs - groups: - - hal - - name: hal_st - revision: b77157f6bc4395e398d90ab02a7d2cbc01ab2ce7 - path: modules/hal/st - groups: - - hal - - name: hal_stm32 - revision: f1317150eac951fdd8259337a47cbbc4c2e6d335 - path: modules/hal/stm32 - groups: - - hal - - name: hal_telink - revision: 4226c7fc17d5a34e557d026d428fc766191a0800 - path: modules/hal/telink - groups: - - hal - - name: hal_ti - revision: b85f86e51fc4d47c4c383d320d64d52d4d371ae4 - path: modules/hal/ti - groups: - - hal - - name: hal_wurthelektronik - revision: e5bcb2eac1bb9639ce13b4dafc78eb254e014342 - path: modules/hal/wurthelektronik - groups: - - hal - - name: hal_xtensa - revision: a2d658525b16c57bea8dd565f5bd5167e4b9f1ee - path: modules/hal/xtensa - groups: - - hal - - name: hostap - repo-path: hostap - path: modules/lib/hostap - revision: a90df86d7c596a5367ff70c2b50c7f599e6636f3 - - name: libmetal - revision: a6851ba6dba8c9e87d00c42f171a822f7a29639b - path: modules/hal/libmetal - groups: - - hal - - name: liblc3 - revision: 1a5938ebaca4f13fe79ce074f5dee079783aa29f - path: modules/lib/liblc3 - - name: littlefs - path: modules/fs/littlefs - groups: - - fs - revision: 408c16a909dd6cf128874a76f21c793798c9e423 - - name: loramac-node - revision: fb00b383072518c918e2258b0916c996f2d4eebe - path: modules/lib/loramac-node - - name: lvgl - revision: 2b498e6f36d6b82ae1da12c8b7742e318624ecf5 - path: modules/lib/gui/lvgl - - name: mbedtls - revision: a78176c6ff0733ba08018cba4447bd3f20de7978 - path: modules/crypto/mbedtls - groups: - - crypto - - name: mcuboot - revision: fb2cf0ec3da3687b93f28e556ab682bdd4b85223 - path: bootloader/mcuboot - - name: mipi-sys-t - path: modules/debug/mipi-sys-t - groups: - - debug - revision: 71ace1f5caa03e56c8740a09863e685efb4b2360 - - name: net-tools - revision: 7c7a856814d7f27509c8511fef14cec21f7d0c30 - path: tools/net-tools - groups: - - tools - - name: nrf_hw_models - revision: 6c389b9b5fa0a079cd4502e69d375da4c0c289b7 - path: modules/bsim_hw_models/nrf_hw_models - - name: open-amp - revision: 76d2168bcdfcd23a9a7dce8c21f2083b90a1e60a - path: modules/lib/open-amp - - name: openthread - revision: 3873c6fcd5a8a9dd01b71e8efe32ef5dc7923bb1 - path: modules/lib/openthread - - name: percepio - path: modules/debug/percepio - revision: b68d17993109b9bee6b45dc8c9794e7b7bce236d - groups: - - debug - - name: picolibc - path: modules/lib/picolibc - revision: 764ef4e401a8f4c6a86ab723533841f072885a5b - - name: segger - revision: b011c45b585e097d95d9cf93edf4f2e01588d3cd - path: modules/debug/segger - groups: - - debug - - name: tinycrypt - revision: 1012a3ebee18c15ede5efc8332ee2fc37817670f - path: modules/crypto/tinycrypt - groups: - - crypto - - name: trusted-firmware-m - revision: 069455be098383bf96eab73e3ff8e0c66c60fa5a - path: modules/tee/tf-m/trusted-firmware-m - groups: - - tee - - name: trusted-firmware-a - revision: 713ffbf96c5bcbdeab757423f10f73eb304eff07 - path: modules/tee/tf-a/trusted-firmware-a - groups: - - tee - - name: uoscore-uedhoc - revision: 84ef879a46d7bfd9a423fbfb502b04289861f9ea - path: modules/lib/uoscore-uedhoc - - name: zcbor - revision: 75d088037eb237b18e7ec1f47c9ce494b9b95aab - path: modules/lib/zcbor + - name: phytium-standalone-sdk remote: phytium - revision: c38dcff60bf78f1612429c3d80c3e1bc962dd462 + revision: 25470ef4e6bb721f1257682ae8d0cff93f5ae0d5 path: modules/hal/phytium/hal/phytium-standalone-sdk groups: - hal -- Gitee From bcc8a79e8fbc3ef68d6054db21bcf269311139a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E9=94=A6?= Date: Fri, 18 Jul 2025 05:56:34 +0000 Subject: [PATCH 12/13] add xmac v2 --- .../phytium/pd2408_test_a/Kconfig.defconfig | 5 + .../phytium/pd2408_test_a/pd2408_test_a.dts | 5 + .../phytium/pd2408_test_b/Kconfig.defconfig | 5 + .../phytium/pd2408_test_b/pd2408_test_b.dts | 5 + drivers/ethernet/CMakeLists.txt | 1 + drivers/ethernet/Kconfig | 1 + drivers/ethernet/Kconfig.phytium_xmac_v2 | 22 + drivers/ethernet/eth_phytium_xmac_v2.c | 1319 +++++++++++++++++ drivers/ethernet/eth_phytium_xmac_v2.h | 163 ++ dts/arm64/phytium/pd2408.dtsi | 23 + dts/bindings/ethernet/phytium,xmac_v2.yaml | 243 +++ 11 files changed, 1792 insertions(+) create mode 100644 drivers/ethernet/Kconfig.phytium_xmac_v2 create mode 100644 drivers/ethernet/eth_phytium_xmac_v2.c create mode 100644 drivers/ethernet/eth_phytium_xmac_v2.h create mode 100644 dts/bindings/ethernet/phytium,xmac_v2.yaml diff --git a/boards/phytium/pd2408_test_a/Kconfig.defconfig b/boards/phytium/pd2408_test_a/Kconfig.defconfig index bcc66bf6771..d3f80b48616 100644 --- a/boards/phytium/pd2408_test_a/Kconfig.defconfig +++ b/boards/phytium/pd2408_test_a/Kconfig.defconfig @@ -17,3 +17,8 @@ config BOARD default "Phytium pd2408 test a" depends on BOARD_PD2408_TEST_A + +if NETWORKING +config NET_L2_ETHERNET + default y +endif # NETWORKING diff --git a/boards/phytium/pd2408_test_a/pd2408_test_a.dts b/boards/phytium/pd2408_test_a/pd2408_test_a.dts index a102bd04b2b..7915d96763a 100644 --- a/boards/phytium/pd2408_test_a/pd2408_test_a.dts +++ b/boards/phytium/pd2408_test_a/pd2408_test_a.dts @@ -22,6 +22,11 @@ chosen { }; }; +&xmac_v2_0 { + status = "okay"; + local-mac-address = [00 00 00 01 02 03]; +}; + &uart1 { current-speed = <115200>; pinctrl-0 = <&uart1_rx_default &uart1_tx_default>; diff --git a/boards/phytium/pd2408_test_b/Kconfig.defconfig b/boards/phytium/pd2408_test_b/Kconfig.defconfig index 7c362df0faa..6f3f778c588 100644 --- a/boards/phytium/pd2408_test_b/Kconfig.defconfig +++ b/boards/phytium/pd2408_test_b/Kconfig.defconfig @@ -17,3 +17,8 @@ config BOARD default "Phytium pd2408 test b" depends on BOARD_PD2408_TEST_B + +if NETWORKING +config NET_L2_ETHERNET + default y +endif # NETWORKING diff --git a/boards/phytium/pd2408_test_b/pd2408_test_b.dts b/boards/phytium/pd2408_test_b/pd2408_test_b.dts index fe40e62f16e..d712e7b8a6a 100644 --- a/boards/phytium/pd2408_test_b/pd2408_test_b.dts +++ b/boards/phytium/pd2408_test_b/pd2408_test_b.dts @@ -22,6 +22,11 @@ chosen { }; }; +&xmac_v2_0 { + status = "okay"; + local-mac-address = [00 00 00 01 02 03]; +}; + &uart1 { current-speed = <115200>; pinctrl-0 = <&uart1_rx_default &uart1_tx_default>; diff --git a/drivers/ethernet/CMakeLists.txt b/drivers/ethernet/CMakeLists.txt index 692338f7754..ea00379db1d 100644 --- a/drivers/ethernet/CMakeLists.txt +++ b/drivers/ethernet/CMakeLists.txt @@ -42,6 +42,7 @@ zephyr_library_sources_ifdef(CONFIG_ETH_LAN865X eth_lan865x.c oa_tc6.c) zephyr_library_sources_ifdef(CONFIG_ETH_XMC4XXX eth_xmc4xxx.c) zephyr_library_sources_ifdef(CONFIG_ETH_PHYTIUM_XMAC eth_phytium_xmac.c) zephyr_library_sources_ifdef(CONFIG_ETH_PHYTIUM_GMAC eth_phytium_gmac.c) +zephyr_library_sources_ifdef(CONFIG_ETH_PHYTIUM_XMAC_V2 eth_phytium_xmac_v2.c) if(CONFIG_ETH_NXP_S32_NETC) zephyr_library_sources(eth_nxp_s32_netc.c) diff --git a/drivers/ethernet/Kconfig b/drivers/ethernet/Kconfig index 62568e4a155..200a58d2c70 100644 --- a/drivers/ethernet/Kconfig +++ b/drivers/ethernet/Kconfig @@ -75,6 +75,7 @@ source "drivers/ethernet/Kconfig.lan865x" source "drivers/ethernet/Kconfig.xmc4xxx" source "drivers/ethernet/Kconfig.phytium_xmac" source "drivers/ethernet/Kconfig.phytium_gmac" +source "drivers/ethernet/Kconfig.phytium_xmac_v2" source "drivers/ethernet/eth_nxp_enet_qos/Kconfig" diff --git a/drivers/ethernet/Kconfig.phytium_xmac_v2 b/drivers/ethernet/Kconfig.phytium_xmac_v2 new file mode 100644 index 00000000000..f3cc982f8bd --- /dev/null +++ b/drivers/ethernet/Kconfig.phytium_xmac_v2 @@ -0,0 +1,22 @@ +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +# +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# https://opensource.org/license/apache-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. + +menuconfig ETH_PHYTIUM_XMAC_V2 + bool "Phytium ETH_PHYTIUM_XMAC_V2 Ethernet driver" + default y + depends on DT_HAS_PHYTIUM_XMAC_V2_ENABLED + help + Enable Phytium XMAC V2 Ethernet driver. + diff --git a/drivers/ethernet/eth_phytium_xmac_v2.c b/drivers/ethernet/eth_phytium_xmac_v2.c new file mode 100644 index 00000000000..fd677fc215a --- /dev/null +++ b/drivers/ethernet/eth_phytium_xmac_v2.c @@ -0,0 +1,1319 @@ +// Phytium is pleased to support the open source community by making Zephyr-SDK available. + +// +// Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +// +// Licensed under the Apache-2.0 License (the "License"); you may not use this file except +// in compliance with the License. You may obtain a copy of the License at +// +// https://opensource.org/license/apache-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 "fparameters.h" +#include "fxmac_msg.h" +#include "fxmac_msg_hw.h" +#include "fxmac_msg_bdring.h" +#include "fxmac_msg_phy.h" +#include "fxmac_msg_common.h" +#include "eth_ieee_reg.h" +#include "eth_phytium_xmac_v2.h" + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#define LOG_MODULE_NAME phytium_xmac_v2 +#define LOG_LEVEL CONFIG_ETHERNET_LOG_LEVEL +#include +LOG_MODULE_REGISTER(LOG_MODULE_NAME); + +#define DT_DRV_COMPAT phytium_xmac_v2 + +/* dma buffer */ +#define ETH_PHYTIUM_BDL_ALIGNMENT 256 +#define ETH_PHYTIUM_BUFFER_ALIGNMENT ETH_PHYTIUM_BDL_ALIGNMENT +#define ETH_ALIGNMENT_OFFSET_DEFINED(buffer_size) ((buffer_size\ + + (ETH_PHYTIUM_BUFFER_ALIGNMENT - 1))\ + & ~(ETH_PHYTIUM_BUFFER_ALIGNMENT - 1)) + +/* IRQ handler function type */ +typedef void (*eth_phytiium_xmac_v2_config_irq_t)(const struct device *dev); + +typedef enum +{ + FXMAC_MSG_LWIP_PORT_INTERFACE_SGMII = 0, + FXMAC_MSG_LWIP_PORT_INTERFACE_RMII, + FXMAC_MSG_LWIP_PORT_INTERFACE_RGMII, + FXMAC_MSG_LWIP_PORT_INTERFACE_USXGMII, + FXMAC_MSG_LWIP_PORT_INTERFACE_LENGTH +} FXmacMsgLwipPortInterface; + + +#define FXMAC_MSG_PHY_SPEED_10M 10 +#define FXMAC_MSG_PHY_SPEED_100M 100 +#define FXMAC_MSG_PHY_SPEED_1000M 1000 +#define FXMAC_MSG_PHY_SPEED_10G 10000 + +/* configuration */ +#define FXMAC_MSG_LWIP_PORT_CONFIG_JUMBO BIT(0) +#define FXMAC_MSG_LWIP_PORT_CONFIG_MULTICAST_ADDRESS_FILITER BIT(1) /* Allow multicast address filtering */ +#define FXMAC_MSG_LWIP_PORT_CONFIG_COPY_ALL_FRAMES BIT(2) /* enable copy all frames */ +#define FXMAC_MSG_LWIP_PORT_CONFIG_CLOSE_FCS_CHECK BIT(3) /* close fcs check */ +#define FXMAC_MSG_LWIP_PORT_CONFIG_UNICAST_ADDRESS_FILITER BIT(5) /* Allow unicast address filtering */ + +/* phy link */ +enum eth_phytium_link_speed { + /* The values of this enum are consecutively numbered */ + LINK_DOWN = 0, + LINK_10MBIT, + LINK_100MBIT, + LINK_1GBIT +}; + +#define FXMAC_MSG_BD_TO_INDEX(ringptr, bdptr) (((uintptr)bdptr - (uintptr)(ringptr)->base_bd_addr) / (ringptr)->separation) + +struct eth_phytium_xmac_v2_dev_cfg { + DEVICE_MMIO_ROM; + uint32_t instance_id; /* */ + eth_phytiium_xmac_v2_config_irq_t config_func; + uint32_t pll_clock_frequency; + + uint32_t phy_poll_interval; + uint8_t defer_rxp_to_queue; + uint8_t defer_txd_to_queue; + + uint8_t rxbd_count; /* rx bdl count */ + uint8_t txbd_count; /* tx bdl count */ + uint16_t rx_buffer_size; /* per buffer size */ + uint16_t tx_buffer_size; + + /* dtc defined */ + uint32_t phy_speed; /* FXMAC_PHY_SPEED_XX */ + uint32_t interface_mode; /* followed by FXmacMsgLwipPortInterface */ + uint32_t dma_brust_length; + uint32_t max_queue_num; /* Number of Xmac Controller Queues */ + bool phy_autonegotiation : 1; + bool enable_fdx : 1; + bool enable_jumbo : 1; + bool enable_ucast_hash :1; + bool copy_all_frames :1; + bool disable_reject_fcs_crc_errors:1; + bool enable_mcast_hash :1; + +}; + + +struct eth_phytium_xmac_v2_dev_data { + DEVICE_MMIO_RAM; /* used for controller base address */ + struct net_if *iface; + FXmacMsgCtrl instance; + uint8_t mac_addr[6]; + enum eth_phytium_link_speed eff_link_speed; + struct k_work tx_done_work; + struct k_work rx_pend_work; + struct k_sem tx_done_sem; + + struct k_sem ring_sem; + + uint8_t phy_addr; + uint32_t phy_id; + struct k_work_delayable phy_poll_delayed_work; + +#ifdef CONFIG_NET_STATISTICS_ETHERNET + struct net_stats_eth stats; +#endif + + uint8_t *rx_bdspace; + uint8_t *rx_bdspace_virt; + uint8_t *tx_bdspace; + uint8_t *tx_bdspace_virt; + + uint8_t *first_rx_buffer; + uint8_t *first_rx_buffer_virt; + uint8_t *first_tx_buffer; + uint8_t *first_tx_buffer_virt; + + bool started; +}; + + +static int eth_phytium_xmac_v2_dev_init(const struct device *dev); +static void eth_phytium_xmac_v2_iface_init(struct net_if *iface); +static enum ethernet_hw_caps eth_phytium_xmac_v2_get_capabilities(const struct device *dev); +static int eth_phytium_xmac_v2_send(const struct device *dev, struct net_pkt *pkt); +static int eth_phytium_xmac_v2_start_device(const struct device *dev); +static int eth_phytium_xmac_v2_stop_device(const struct device *dev); +#ifdef CONFIG_NET_STATISTICS_ETHERNET +static struct net_stats_eth *eth_phytium_xmac_v2_stats(const struct device *dev); +#endif + +static void eth_phytium_xmac_v2_isr(const struct device *dev); + +static const struct ethernet_api eth_phytium_xmac_v2_apis = { + .iface_api.init = eth_phytium_xmac_v2_iface_init, + .get_capabilities = eth_phytium_xmac_v2_get_capabilities, + .send = eth_phytium_xmac_v2_send, + .start = eth_phytium_xmac_v2_start_device, + .stop = eth_phytium_xmac_v2_stop_device, +#if defined(CONFIG_NET_STATISTICS_ETHERNET) + .get_stats = eth_phytium_xmac_v2_stats, +#endif +}; + + +/* + * Insert the configuration & run-time data for all GEM instances which + * are enabled in the device tree of the current target board. + */ +DT_INST_FOREACH_STATUS_OKAY(ETH_PHYTIUM_XMAC_V2_INITIALIZE) + + +static void FXmacMsgSetupIsr(const struct device *dev); + +static uint32_t phy_autoneg_status(FXmacMsgCtrl *xmac_p, uint32_t phy_addr) +{ + u16 status; + + /* Read Phy Status register twice to get the confirmation of the current + * link status. + */ + status = FXmacMsgMdioDataReadC22(xmac_p, phy_addr, PHY_STATUS_REG_OFFSET); + + if (status & PHY_STATUS_AUTONEGOTIATE_COMPLETE) + return 1; + return 0; +} + +/** + * @name: phy_link_detect + * @msg: Get current link status + * @note: + * @param {FXmacMsgCtrl} *fxmac_p + * @param {u32} phy_addr + * @return {*} 1 is link up , 0 is link down + */ +static u32 phy_link_detect(FXmacMsgCtrl *xmac_p, u32 phy_addr) +{ + u16 status; + + /* Read Phy Status register twice to get the confirmation of the current + * link status. + */ + status = FXmacMsgMdioDataReadC22(xmac_p, phy_addr, PHY_STATUS_REG_OFFSET); + + if (status & PHY_STAT_LINK_STATUS) + return 1; + return 0; +} + +FXmacMsgLinkStatus FXmacMsgRgmiiLinkDetect(const struct device *dev) +{ + struct eth_phytium_xmac_v2_dev_data *dev_data = (struct eth_phytium_xmac_v2_dev_data *)dev->data; + FXmacMsgCtrl *instance_p; + instance_p = &dev_data->instance; + + u32 phy_link_status; + + + phy_link_status = phy_link_detect(instance_p, instance_p->phy_address); + + if ((instance_p->link_status == FXMAC_MSG_LINKUP) && (!phy_link_status)) + instance_p->link_status = FXMAC_MSG_LINKDOWN; + + switch (instance_p->link_status) + { + case FXMAC_MSG_LINKUP: + return FXMAC_MSG_LINKUP; + case FXMAC_MSG_LINKDOWN: + instance_p->link_status = FXMAC_MSG_NEGOTIATING; + LOG_DBG("Ethernet Link down"); + return FXMAC_MSG_LINKDOWN; + case FXMAC_MSG_NEGOTIATING: + if ((phy_link_status == FXMAC_MSG_LINKUP) && phy_autoneg_status(instance_p, instance_p->phy_address)) + { + if(FXmacMsgPhyInit(instance_p, instance_p->config.speed, instance_p->config.duplex, instance_p->config.auto_neg, FXMAC_MSG_PHY_RESET_DISABLE)) + { + return FXMAC_MSG_LINKDOWN; + } + + FXmacMsgInterfaceConfig(instance_p, 0); + + /* Initiate Phy setup to get link speed */ + instance_p->link_status = FXMAC_MSG_LINKUP; + LOG_DBG("Ethernet Link up"); + return FXMAC_MSG_LINKUP; + } + return FXMAC_MSG_LINKDOWN; + default: + return FXMAC_MSG_LINKDOWN; + } +} + +FXmacMsgLinkStatus FXmacMsgSgmiiLinkDetect(const struct device *dev) +{ + struct eth_phytium_xmac_v2_dev_data *dev_data = (struct eth_phytium_xmac_v2_dev_data *)dev->data; + FXmacMsgCtrl *xmac_p; + u32 ctrl; + u32 link, link_status; + xmac_p = &dev_data->instance; + + ctrl = FXMAC_MSG_READ(xmac_p, FXMAC_MSG_PCS_AN_LP); + link = (ctrl & BIT(FXMAC_MSG_PCS_LINK_PARTNER_NEXT_PAGE_INDEX)) >> FXMAC_MSG_PCS_LINK_PARTNER_NEXT_PAGE_INDEX; + + switch (link) + { + case 0: + link_status = FXMAC_MSG_LINKDOWN; + break; + case 1: + link_status = FXMAC_MSG_LINKUP; + break; + default: + LOG_ERR("link status is error 0x%x \r\n", link); + return FXMAC_MSG_LINKDOWN; + } + + if (link_status == FXMAC_MSG_LINKUP) + { + if (link_status != xmac_p->link_status) + { + xmac_p->link_status = FXMAC_MSG_NEGOTIATING; + LOG_INF("need NEGOTIATING"); + } + } + else + { + xmac_p->link_status = FXMAC_MSG_LINKDOWN; + } + + if (xmac_p->link_status == FXMAC_MSG_NEGOTIATING) + { + /* renegotiate */ + if (FXmacMsgPhyInit(xmac_p, xmac_p->config.speed, xmac_p->config.duplex, xmac_p->config.auto_neg, FXMAC_MSG_PHY_RESET_DISABLE)) + { + LOG_ERR("FXmacMsgPhyInit is error \r\n"); + return FXMAC_MSG_LINKDOWN; + } + else + { + FXmacMsgInterfaceConfig(xmac_p, 0); + xmac_p->link_status = FXMAC_MSG_LINKUP; + return FXMAC_MSG_LINKUP; + } + } + return xmac_p->link_status; +} + +static void eth_phytium_xmac_v2_poll_phy(struct k_work *work) +{ + struct k_work_delayable *dwork = k_work_delayable_from_work(work); + struct eth_phytium_xmac_v2_dev_data *dev_data = CONTAINER_OF(dwork, struct eth_phytium_xmac_v2_dev_data, phy_poll_delayed_work); + const struct device *dev = net_if_get_device(dev_data->iface); + const struct eth_phytium_xmac_v2_dev_cfg *dev_conf = dev->config; + FXmacMsgLinkStatus link_status = FXMAC_MSG_LINKDOWN; + FXmacMsgCtrl *instance_p; + instance_p = &dev_data->instance; + + if(instance_p->config.interface == FXMAC_MSG_PHY_INTERFACE_MODE_SGMII) + { + link_status = FXmacMsgSgmiiLinkDetect(dev); + } + else if((instance_p->config.interface == FXMAC_MSG_PHY_INTERFACE_MODE_RMII) || (instance_p->config.interface == FXMAC_MSG_PHY_INTERFACE_MODE_RGMII)) + { + link_status = FXmacMsgRgmiiLinkDetect(dev); + } + + if(link_status == FXMAC_MSG_LINKDOWN) + { + dev_data->eff_link_speed = LINK_DOWN; + net_eth_carrier_off(dev_data->iface); + + LOG_WRN("%s link down", dev->name); + } + else if(link_status == FXMAC_MSG_LINKUP) + { + switch(instance_p->config.speed) + { + case FXMAC_MSG_SPEED_10: + dev_data->eff_link_speed = LINK_10MBIT; + break; + case FXMAC_MSG_SPEED_100: + dev_data->eff_link_speed = LINK_100MBIT; + break; + case FXMAC_MSG_SPEED_1000: + dev_data->eff_link_speed = LINK_1GBIT; + break; + } + net_eth_carrier_on(dev_data->iface); + } + + k_work_reschedule(&dev_data->phy_poll_delayed_work, K_MSEC(dev_conf->phy_poll_interval)); +} + +/** + * @name: eth_phytium_xmac_v2_get_capabilities + * @msg: Reports the hardware capabilities of the Ethernet device, such as supported speeds and duplex modes. + * @param {const struct device} *dev is a pointer to the device structure for the driver instance. + * @return {enum ethernet_hw_caps} A bitmask of supported features defined in `enum ethernet_hw_caps`. + */ +static enum ethernet_hw_caps eth_phytium_xmac_v2_get_capabilities(const struct device *dev) +{ + struct eth_phytium_xmac_v2_dev_cfg *dev_cfg = (struct eth_phytium_xmac_v2_dev_cfg *)dev->config; + enum ethernet_hw_caps caps = (enum ethernet_hw_caps)0; + + switch (dev_cfg->phy_speed) + { + case FXMAC_MSG_PHY_SPEED_10M: + caps |= ETHERNET_LINK_10BASE_T; + break; + case FXMAC_MSG_PHY_SPEED_100M: + caps |= (ETHERNET_LINK_100BASE_T | + ETHERNET_LINK_10BASE_T); + break; + case FXMAC_MSG_PHY_SPEED_1000M: + caps |= (ETHERNET_LINK_1000BASE_T | + ETHERNET_LINK_100BASE_T | + ETHERNET_LINK_10BASE_T); + break; + case FXMAC_MSG_PHY_SPEED_10G: + caps |= (ETHERNET_LINK_1000BASE_T | + ETHERNET_LINK_100BASE_T | + ETHERNET_LINK_10BASE_T); + break; + } + + if (dev_cfg->enable_fdx) + { + caps |= ETHERNET_DUPLEX_SET; + } + + if (dev_cfg->copy_all_frames) + { + caps |= ETHERNET_PROMISC_MODE; + } + return caps; +} + +static int eth_phytium_xmac_config_convert(struct eth_phytium_xmac_v2_dev_cfg *dev_conf, FXmacMsgConfig *mac_config, uint32_t *options) +{ + *options = 0; + switch (dev_conf->interface_mode) + { + case FXMAC_MSG_LWIP_PORT_INTERFACE_SGMII: + mac_config->interface = FXMAC_MSG_PHY_INTERFACE_MODE_SGMII; + LOG_INF("SGMII select"); + break; + case FXMAC_MSG_LWIP_PORT_INTERFACE_RMII: + mac_config->interface = FXMAC_MSG_PHY_INTERFACE_MODE_RMII; + LOG_INF("RMII select"); + break; + case FXMAC_MSG_LWIP_PORT_INTERFACE_RGMII: + LOG_INF("RGMII select"); + mac_config->interface = FXMAC_MSG_PHY_INTERFACE_MODE_RGMII; + break; + case FXMAC_MSG_LWIP_PORT_INTERFACE_USXGMII: + LOG_INF("USXGMII select"); + mac_config->interface = FXMAC_MSG_PHY_INTERFACE_MODE_USXGMII; + break; + default: + return -EINVAL; + } + + switch (dev_conf->phy_speed) + { + case FXMAC_MSG_PHY_SPEED_10M: + mac_config->speed = FXMAC_MSG_SPEED_10; + break; + case FXMAC_MSG_PHY_SPEED_100M: + mac_config->speed = FXMAC_MSG_SPEED_100; + break; + case FXMAC_MSG_PHY_SPEED_1000M: + mac_config->speed = FXMAC_MSG_SPEED_1000; + break; + case FXMAC_MSG_PHY_SPEED_10G: + LOG_INF("select FXMAC_MSG_PHY_SPEED_10G"); + mac_config->speed = FXMAC_MSG_SPEED_10000; + break; + default: + return -EINVAL; + } + + mac_config->duplex = dev_conf->enable_fdx? 1:0; /* 1 is full-duplex , 0 is half-duplex */ + mac_config->auto_neg = dev_conf->phy_autonegotiation; /* Enable auto-negotiation - when set active high, autonegotiation operation is enabled. */ + mac_config->pclk_hz = dev_conf->pll_clock_frequency; + mac_config->max_queue_num = dev_conf->max_queue_num; /* Number of Xmac Controller Queues */ + mac_config->tx_queue_id = 0; /* 0 ~ FXMAC_QUEUE_MAX_NUM ,Index queue number */ + mac_config->rx_queue_id = 0; /* 0 ~ FXMAC_QUEUE_MAX_NUM ,Index queue number */ + mac_config->dma_brust_length = dev_conf->dma_brust_length; /* burst length */ + mac_config->network_default_config = FXMAC_MSG_DEFAULT_OPTIONS; +#if defined(FXMAC_MSG_CAPS) + mac_config->caps = FXMAC_MSG_CAPS; /* used to configure tail ptr feature */ +#else + mac_config->caps = 0; +#endif + + /* options */ + if(dev_conf->enable_jumbo) + { + *options |= FXMAC_MSG_JUMBO_ENABLE_OPTION; + } + + if(dev_conf->enable_ucast_hash) + { + *options |= FXMAC_MSG_UNICAST_OPTION; + } + + if(dev_conf->enable_mcast_hash) + { + *options |= FXMAC_MSG_MULTICAST_OPTION; + } + + if(dev_conf->copy_all_frames) + { + *options |= FXMAC_MSG_PROMISC_OPTION; + } + + if(dev_conf->disable_reject_fcs_crc_errors) + { + *options |= FXMAC_MSG_FCS_STRIP_OPTION; + } + + return 0; +} + +/* dma init */ +static int eth_phytium_xmac_v2_init_dma(const struct device *dev) +{ + struct eth_phytium_xmac_v2_dev_cfg *dev_conf = (struct eth_phytium_xmac_v2_dev_cfg *)dev->config; + struct eth_phytium_xmac_v2_dev_data *dev_data = (struct eth_phytium_xmac_v2_dev_data *)dev->data; + FXmacMsgCtrl *instance_p; + + FXmacMsgBd bdtemplate; + FXmacMsgBdRing *rxringptr, *txringptr; + FXmacMsgBd *rxbd; + int i; + u32 bdindex; + u32 *temp; + instance_p = &dev_data->instance; + /* init buffer to data */ + /* Initial configuration of the RX/TX BD rings */ + DT_INST_FOREACH_STATUS_OKAY(ETH_PHYTIUM_XMAC_V2_INIT_BD_RING) + rxringptr = &FXMAC_MSG_GET_RXRING((*instance_p)); + txringptr = &FXMAC_MSG_GET_TXRING((*instance_p)); + + /* Setup RxBD space. */ + FXMAC_MSG_BD_CLEAR(&bdtemplate); + + /* Create the RxBD ring */ + if(FXmacMsgBdRingCreate(rxringptr, (uintptr)dev_data->rx_bdspace, + (uintptr)dev_data->rx_bdspace, + ETH_PHYTIUM_BDL_ALIGNMENT, + dev_conf->rxbd_count)) + { + LOG_ERR("Error setting up RxBD space\r\n"); + return -EIO; + } + + if(FXmacMsgBdRingClone(rxringptr, &bdtemplate, FXMAC_MSG_RECV)) + { + LOG_ERR("Error initializing RxBD space\r\n"); + return -EIO; + } + + FXMAC_MSG_BD_CLEAR(&bdtemplate); + FXMAC_MSG_BD_SET_STATUS(&bdtemplate, FXMAC_MSG_TXBUF_USED_MASK); + + /* Create the TxBD ring */ + if (FXmacMsgBdRingCreate(txringptr, (uintptr)dev_data->tx_bdspace, (uintptr)dev_data->tx_bdspace, ETH_PHYTIUM_BDL_ALIGNMENT, dev_conf->txbd_count)) + { + return -EIO; + } + + /* We reuse the bd template, as the same one will work for both rx and tx. */ + if(FXmacMsgBdRingClone(txringptr, &bdtemplate, FXMAC_MSG_SEND)) + { + return -EIO; + } + + /* init rx buffer */ + for (i = 0; i < dev_conf->rxbd_count; i++) + { + if(FXmacMsgBdRingAlloc(rxringptr, 1, &rxbd)) + { + LOG_ERR("InitDma: Error allocating RxBD\r\n"); + return -ERANGE; + } + + /* Enqueue to HW */ + if(FXmacMsgBdRingToHw(rxringptr, 1, rxbd)) + { + LOG_ERR("Error: committing RxBD to HW\r\n"); + FXmacMsgBdRingUnAlloc(rxringptr, 1, rxbd); + return -ERANGE; + } + + bdindex = FXMAC_MSG_BD_TO_INDEX(rxringptr, rxbd); + temp = (u32 *)rxbd; + *temp = 0; + if (bdindex == (dev_conf->rxbd_count - 1)) + { + *temp = XMAC_V2_RXDESC_WRAP; /* Marks last descriptor in receive buffer descriptor list */ + } + temp++; + *temp = 0; /* Clear word 1 in descriptor */ + + FXMAC_MSG_BD_SET_ADDRESS_RX(rxbd, (uintptr)(dev_data->first_rx_buffer_virt + ETH_ALIGNMENT_OFFSET_DEFINED(dev_conf->rx_buffer_size) * bdindex)); + } + FXmacMsgSetQueuePtr(instance_p, instance_p->tx_bd_queue.bdring.phys_base_addr, 0, (u16)FXMAC_MSG_SEND); + FXmacMsgSetQueuePtr(instance_p, instance_p->rx_bd_queue.bdring.phys_base_addr, 0, (u16)FXMAC_MSG_RECV); + + return 0; +} + + + +static void eth_phytium_xmac_handle_tx_done(const struct device *dev) +{ + struct eth_phytium_xmac_v2_dev_data *dev_data = (struct eth_phytium_xmac_v2_dev_data *)dev->data; + struct eth_phytium_xmac_v2_dev_cfg *dev_conf = (struct eth_phytium_xmac_v2_dev_cfg *)dev->config; + FXmacMsgCtrl *instance_p; + FXmacMsgBd *txbdset; + FXmacMsgBd *curbdpntr; + u32 n_bds; + FError status; + u32 n_pbufs_freed = 0; + u32 bdindex; + u32 *temp; + instance_p = &dev_data->instance; + FXmacMsgBdRing *txring; + + if (dev_conf->defer_txd_to_queue) + { + k_sem_take(&(dev_data->ring_sem), K_FOREVER); + } + txring = &(FXMAC_MSG_GET_TXRING((*instance_p))); + while (1) + { + /* obtain processed BD's */ + n_bds = FXmacMsgBdRingFromHwTx(txring, dev_conf->txbd_count, &txbdset); + if (n_bds == 0) + { + break; + } + /* free the processed BD's */ + n_pbufs_freed = n_bds; + curbdpntr = txbdset; + while (n_pbufs_freed > 0) + { + bdindex = FXMAC_MSG_BD_TO_INDEX(txring, curbdpntr); + temp = (u32 *)curbdpntr; + *temp = 0; /* Word 0 */ + temp++; + + if (bdindex == (dev_conf->txbd_count - 1)) + { + *temp = XMAC_V2_TXDESC_USED | XMAC_V2_TXDESC_WRAP; /* Word 1 ,used/Wrap – marks last descriptor in transmit buffer descriptor list.*/ + } + else + { + *temp = XMAC_V2_TXDESC_USED; /* Word 1 , Used – must be zero for GEM to read data to the transmit buffer.*/ + } + + curbdpntr = FXMAC_MSG_BD_RING_NEXT(txring, curbdpntr); + n_pbufs_freed--; + + } + + status = FXmacMsgBdRingFree(txring, n_bds, txbdset); + if (status != FT_SUCCESS) + { + LOG_ERR("Failure while freeing in Tx Done ISR\r\n"); + } + } + + if (dev_conf->defer_txd_to_queue) + { + k_sem_give(&(dev_data->ring_sem)); + } + + /* Re-enable the TX complete interrupt source */ + FXmacMsgEnableIrq(instance_p, 0, FXMAC_MSG_INT_TX_COMPLETE); + + /* Indicate completion to a blocking eth_xlnx_gem_send() call */ + k_sem_give(&dev_data->tx_done_sem); +} + +static void eth_phytium_xmac_tx_done_work(struct k_work *item) +{ + struct eth_phytium_xmac_v2_dev_data *dev_data = CONTAINER_OF(item, struct eth_phytium_xmac_v2_dev_data, tx_done_work); + const struct device *dev = net_if_get_device(dev_data->iface); + + eth_phytium_xmac_handle_tx_done(dev); +} + +/** + * @name: eth_phytium_xmac_v2_send + * @msg: Sends an Ethernet frame. The frame is contained in a packet that is managed by the networking stack. + * @param {const struct device} *dev is a pointer to the device structure for the driver instance. + * @param {struct net_pkt} *pkt is a pointer to the network packet that contains the data to be sent. + * @return {int} Zero on success or negative error code on failure. + */ +static int eth_phytium_xmac_v2_send(const struct device *dev, struct net_pkt *pkt) +{ + struct eth_phytium_xmac_v2_dev_cfg *dev_conf = (struct eth_phytium_xmac_v2_dev_cfg *)dev->config; + struct eth_phytium_xmac_v2_dev_data *dev_data = (struct eth_phytium_xmac_v2_dev_data *)dev->data; + FXmacMsgCtrl *instance_p; + + FXmacMsgBd *txbdset, *txbd, *last_txbd = NULL; + FXmacMsgBdRing *txring; + u32 bdindex; + + uint16_t tx_data_length; + uint16_t tx_data_remaining; + void *tx_buffer_offs; + uint32_t bds_reqd; + uint32_t tx_length = 0; + instance_p = &dev_data->instance; + txring = &FXMAC_MSG_GET_TXRING((*instance_p)); + + if (!dev_data->started || dev_data->eff_link_speed == LINK_DOWN || (!net_if_flag_is_set(dev_data->iface, NET_IF_UP))) + { +#ifdef CONFIG_NET_STATISTICS_ETHERNET + dev_data->stats.tx_dropped++; +#endif + return -EIO; + } + + tx_data_length = tx_data_remaining = net_pkt_get_len(pkt); + if (tx_data_length == 0) + { + LOG_ERR("%s cannot TX, zero packet length", dev->name); +#ifdef CONFIG_NET_STATISTICS_ETHERNET + dev_data->stats.errors.tx++; +#endif + return -EINVAL; + } + + bds_reqd = (uint8_t)((tx_data_length + (dev_conf->tx_buffer_size - 1)) / dev_conf->tx_buffer_size); + + if (dev_conf->defer_txd_to_queue) + { + k_sem_take(&(dev_data->ring_sem), K_FOREVER); + } + else + { + FXmacMsgDisableIrq(instance_p, 0, FXMAC_MSG_INT_TX_COMPLETE); + } + + /* obtain as many BD's */ + if(FXmacMsgBdRingAlloc(txring, bds_reqd, &txbdset)) + { + LOG_ERR("sgsend: Error allocating TxBD\r\n"); +#ifdef CONFIG_NET_STATISTICS_ETHERNET + dev_data->stats.tx_dropped++; +#endif + FXmacMsgEnableIrq(instance_p, 0, FXMAC_MSG_INT_TX_COMPLETE); + return ERR_GENERAL; + } + + if (dev_conf->defer_txd_to_queue) + { + k_sem_give(&(dev_data->ring_sem)); + } + else + { + FXmacMsgEnableIrq(instance_p, 0, FXMAC_MSG_INT_TX_COMPLETE); + } + + /* + * Scatter the contents of the network packet's buffer to + * one or more DMA buffers. + */ + net_pkt_cursor_init(pkt); + txbd = txbdset; + while (tx_data_remaining) + { + bdindex = FXMAC_MSG_BD_TO_INDEX(txring, txbd); + + /* Calculate the base pointer of the target TX buffer */ + tx_buffer_offs = (void *)(dev_data->first_tx_buffer + (ETH_ALIGNMENT_OFFSET_DEFINED(dev_conf->tx_buffer_size) * bdindex)); + + /* Copy packet data to DMA buffer */ + tx_length = (tx_data_remaining < dev_conf->tx_buffer_size) ? tx_data_remaining : dev_conf->tx_buffer_size; + net_pkt_read(pkt, (void *)tx_buffer_offs, tx_length); + + FXMAC_MSG_BD_SET_ADDRESS_TX(txbd, (uintptr)tx_buffer_offs); + + FXMAC_MSG_BD_SET_LENGTH(txbd, tx_length & 0x3FFF); + + last_txbd = txbd; + FXMAC_MSG_BD_CLEAR_LAST(txbd); + txbd = FXMAC_MSG_BD_RING_NEXT(txring, txbd); + tx_data_remaining -= (tx_data_remaining < dev_conf->tx_buffer_size) ? tx_data_remaining : dev_conf->tx_buffer_size; + } + FXMAC_MSG_BD_SET_LAST(last_txbd); + + bdindex = FXMAC_MSG_BD_TO_INDEX(txring, txbd); + + FXMAC_MSG_BD_CLEAR_TX_USED(last_txbd); + + if(FXmacMsgBdRingToHw(txring, bds_reqd, txbdset)) + { + LOG_ERR("sgsend: Error submitting TxBD\r\n"); + } + + /* Start transmit */ + FXMAC_MSG_WRITE(instance_p, FXMAC_MSG_TX_PTR(0), bdindex); + +#ifdef CONFIG_NET_STATISTICS_ETHERNET + dev_data->stats.bytes.sent += tx_data_length; + dev_data->stats.pkts.tx++; +#endif + + return 0; +} + +static void eth_phytium_xmac_setup_rx_bds(const struct device *dev,FXmacMsgBdRing *rxring) +{ + const struct eth_phytium_xmac_v2_dev_cfg *dev_conf = dev->config; + struct eth_phytium_xmac_v2_dev_data *dev_data = dev->data; + FXmacMsgBd *rxbd; + FError status; + u32 freebds; + u32 bdindex; + u32 *temp; + FXmacMsgCtrl *instance_p; + instance_p = &dev_data->instance; + + freebds = FXMAC_MSG_BD_RING_GET_FREE_CNT(rxring); + while (freebds > 0) + { + freebds--; + status = FXmacMsgBdRingAlloc(rxring, 1, &rxbd); + if (status != FT_SUCCESS) + { + LOG_ERR("SetupRxBds: Error allocating RxBD\r\n"); + return; + } + status = FXmacMsgBdRingToHw(rxring, 1, rxbd); + if (status != FT_SUCCESS) + { + LOG_ERR("Error committing RxBD to hardware: "); + if (status == FXMAC_MSG_ERR_SG_LIST) + { + LOG_ERR("XST_DMA_SG_LIST_ERROR: this function was called out of sequence with FXmacMsgBdRingAlloc()\r\n"); + } + else + { + LOG_ERR("set of BDs was rejected because the first BD did not have its start-of-packet bit set, or the last BD did not have its end-of-packet bit set, or any one of the BD set has 0 as length value\r\n"); + } + + FXmacMsgBdRingUnAlloc(rxring, 1, rxbd); + return; + } + + + bdindex = FXMAC_MSG_BD_TO_INDEX(rxring, rxbd); + temp = (u32 *)rxbd; + if (bdindex == (dev_conf->rxbd_count - 1)) + { + *temp = XMAC_V2_RXDESC_WRAP; /* Mask last descriptor in receive buffer list */ + } + else + { + *temp = 0; + } + temp++; + *temp = 0; + + FXMAC_MSG_BD_SET_ADDRESS_RX(rxbd, (uintptr)(dev_data->first_rx_buffer_virt + ETH_ALIGNMENT_OFFSET_DEFINED(dev_conf->rx_buffer_size) * bdindex)); + } +} + +static void eth_phytium_xmac_handle_rx_pending(const struct device *dev) +{ + const struct eth_phytium_xmac_v2_dev_cfg *dev_conf = dev->config; + struct eth_phytium_xmac_v2_dev_data *dev_data = dev->data; + FXmacMsgBd *rxbdset, *curbdptr; + FXmacMsgBdRing *rxring; + volatile u32 bd_processed; + u32 k; + u32 bdindex; + FXmacMsgCtrl *instance_p; + struct net_pkt *pkt; + uint32_t rx_data_length; + instance_p = &dev_data->instance; + rxring = &FXMAC_MSG_GET_RXRING((*instance_p)); + + /* Re-enable the frame received interrupt source */ + FXmacMsgEnableIrq(instance_p, 0, FXMAC_MSG_INT_RX_COMPLETE); + + while (1) + { + bd_processed = FXmacMsgBdRingFromHwRx(rxring, dev_conf->rxbd_count, &rxbdset); + if (bd_processed <= 0) + { + break; + } + + for (k = 0, curbdptr = rxbdset; k < bd_processed; k++) + { + bdindex = FXMAC_MSG_BD_TO_INDEX(rxring, curbdptr); + rx_data_length = FXMAC_MSG_BD_GET_LENGTH(curbdptr); + if(rx_data_length > dev_conf->rx_buffer_size) + { + LOG_ERR("rx_data_length length is error: %u bytes \r\n", + rx_data_length); + goto error_exit; + } + + pkt = net_pkt_rx_alloc_with_buffer(dev_data->iface, rx_data_length, + AF_UNSPEC, 0, K_FOREVER); + if (pkt == NULL) + { + LOG_ERR("RX packet buffer alloc failed: %u bytes", + rx_data_length); +#ifdef CONFIG_NET_STATISTICS_ETHERNET + dev_data->stats.errors.rx++; + dev_data->stats.error_details.rx_no_buffer_count++; +#endif + /* free up the BD's */ + goto error_exit; + } + + net_pkt_write(pkt, (const void *) + (dev_data->first_rx_buffer_virt + ETH_ALIGNMENT_OFFSET_DEFINED(dev_conf->rx_buffer_size)*bdindex), + rx_data_length); + + if (net_recv_data(dev_data->iface, pkt) < 0) { + printf("%s RX packet hand-over to IP stack failed", dev->name); + net_pkt_unref(pkt); + } +#ifdef CONFIG_NET_STATISTICS_ETHERNET + else { + dev_data->stats.bytes.received += rx_data_length; + dev_data->stats.pkts.rx++; + } +#endif + curbdptr = FXMAC_MSG_BD_RING_NEXT(rxring, curbdptr); + } + FXmacMsgBdRingFree(rxring, bd_processed, rxbdset); + eth_phytium_xmac_setup_rx_bds(dev,rxring); + } + + return; + +error_exit: + printf("eth_phytium_xmac_handle_rx_pending error exit \r\n"); + FXmacMsgBdRingFree(rxring, bd_processed, rxbdset); +} + +static void eth_phytium_xmac_rx_pending_work(struct k_work *item) +{ + struct eth_phytium_xmac_v2_dev_data *dev_data = CONTAINER_OF(item, + struct eth_phytium_xmac_v2_dev_data, rx_pend_work); + const struct device *dev = net_if_get_device(dev_data->iface); + + eth_phytium_xmac_handle_rx_pending(dev); +} + + +static void FXmacMsgSendHandler(void *arg) +{ + const struct device *dev = (const struct device *)arg; + struct eth_phytium_xmac_v2_dev_data *dev_data = dev->data; + const struct eth_phytium_xmac_v2_dev_cfg *dev_conf = dev->config; + FXmacMsgCtrl *instance_p; + instance_p = &dev_data->instance; + + FXmacMsgDisableIrq(instance_p, 0, FXMAC_MSG_INT_TX_COMPLETE); + + if (dev_conf->defer_txd_to_queue) + { + k_work_submit(&dev_data->tx_done_work); + } + else + { + eth_phytium_xmac_handle_tx_done(dev); + } +} + +static void FXmacMsgRecvHandler(void *arg) +{ + const struct device *dev = (const struct device *)arg; + struct eth_phytium_xmac_v2_dev_data *dev_data = dev->data; + const struct eth_phytium_xmac_v2_dev_cfg *dev_conf = dev->config; + FXmacMsgCtrl *instance_p; + instance_p = &dev_data->instance; + + FXmacMsgDisableIrq(instance_p, 0, FXMAC_MSG_INT_RX_COMPLETE); + + if (dev_conf->defer_rxp_to_queue) + { + k_work_submit(&dev_data->rx_pend_work); + } + else + { + printk("recv data \r\n"); + eth_phytium_xmac_handle_rx_pending(dev); + printk("recv data exit \r\n"); + } +} + +#ifdef CONFIG_NET_STATISTICS_ETHERNET +/** + * @name: eth_phytium_xmac_v2_stats + * @msg: Retrieves the Ethernet statistics for the device. + * @param {const struct device} *dev is a pointer to the device structure for the driver instance. + * @return {struct net_stats_eth} * A pointer to the statistics structure. + */ +static struct net_stats_eth *eth_phytium_xmac_v2_stats(const struct device *dev) +{ + struct eth_phytium_xmac_v2_dev_data *dev_data = dev->data; + + return &dev_data->stats; +} +#endif + +/** + * @name: FXmacMsgSetupIsr + * @msg: Sets up the interrupt service routine handlers for transmit, receive, and error events. + * @param {const struct device} *dev is a pointer to the device structure for the driver instance. + */ +static void FXmacMsgSetupIsr(const struct device *dev) +{ + struct eth_phytium_xmac_v2_dev_data *dev_data = (struct eth_phytium_xmac_v2_dev_data *)dev->data; + /* Setup callbacks */ + FXmacMsgCtrl *instance_p; + instance_p = &dev_data->instance; + + FXmacMsgSetHandler(instance_p, FXMAC_MSG_HANDLER_DMASEND, FXmacMsgSendHandler, (void *)dev); + FXmacMsgSetHandler(instance_p, FXMAC_MSG_HANDLER_DMARECV, FXmacMsgRecvHandler,(void *) (void *)dev); +} + +/** + * @name: eth_phytium_xmac_v2_start_device + * @msg: Starts the Ethernet device, enabling packet transmission and reception. + * @param {const struct device} *dev is a pointer to the device structure for the driver instance. + * @return {int} Zero on success or negative error code on failure. + */ +static int eth_phytium_xmac_v2_start_device(const struct device *dev) +{ + struct eth_phytium_xmac_v2_dev_data *dev_data = (struct eth_phytium_xmac_v2_dev_data *)dev->data; + /* Setup callbacks */ + if (dev_data->started) + { + return 0; + } + dev_data->started = true; + + FXmacMsgCtrl *instance_p; + instance_p = &dev_data->instance; + FXmacMsgStart(instance_p); + return 0; +} + +/** + * @name: eth_phytium_xmac_v2_stop_device + * @msg: Stops the Ethernet device, disabling packet transmission and reception. + * @param {const struct device} *dev is a pointer to the device structure for the driver instance. + * @return {int} Zero on success or negative error code on failure. + */ +static int eth_phytium_xmac_v2_stop_device(const struct device *dev) +{ + struct eth_phytium_xmac_v2_dev_data *dev_data = (struct eth_phytium_xmac_v2_dev_data *)dev->data; + FXmacMsgCtrl *instance_p; + instance_p = &dev_data->instance; + + if (!dev_data->started) + { + return 0; + } + dev_data->started = false; + + /* Cancel the delayed work that polls the link state */ + if (k_work_delayable_remaining_get(&dev_data->phy_poll_delayed_work) != 0) + { + k_work_cancel_delayable(&dev_data->phy_poll_delayed_work); + } + + FXmacMsgStop(instance_p); + + return 0; +} + +/** + * @name: eth_phytium_xmac_v2_isr + * @msg: Interrupt service routine for handling all interrupts from the Ethernet device. + * @param {const struct device} *dev is a pointer to the device structure for the driver instance. + */ +static void eth_phytium_xmac_v2_isr(const struct device *dev) +{ + u32 reg_isr; + struct eth_phytium_xmac_v2_dev_data *dev_data = (struct eth_phytium_xmac_v2_dev_data *)dev->data; + FXmacMsgCtrl *instance_p; + instance_p = &dev_data->instance; + + reg_isr = FXMAC_MSG_READ(instance_p, FXMAC_MSG_INT_SR(instance_p->queues[0].index)); + /* 发送中断 */ + { + /* 发送完成中断 */ + if ((reg_isr & BIT(FXMAC_MSG_TXCOMP_INDEX)) != 0x00000000U) + { + if (instance_p->send_irq_handler) + { + instance_p->send_irq_handler(instance_p->send_args); + } + + if(instance_p->caps & FXMAC_MSG_CAPS_ISR_CLEAR_ON_WRITE) + { + FXMAC_MSG_WRITE(instance_p, FXMAC_MSG_INT_SR(instance_p->queues[0].index), BIT(FXMAC_MSG_TXCOMP_INDEX)); + } + } + + /* 发送错误中断 */ + if (((reg_isr & (BIT(FXMAC_MSG_DMA_ERR_INDEX) | BIT(FXMAC_MSG_RETRY_LIMIT_INDEX) | BIT(FXMAC_MSG_TX_UNDER_RUN_INDEX))) != 0x00000000U) && (!(reg_isr & BIT(FXMAC_MSG_TXCOMP_INDEX)) != 0x00000000U)) + { + if(instance_p->caps & FXMAC_MSG_CAPS_ISR_CLEAR_ON_WRITE) + { + FXMAC_MSG_WRITE(instance_p, FXMAC_MSG_INT_SR(instance_p->queues[0].index), (BIT(FXMAC_MSG_DMA_ERR_INDEX) | BIT(FXMAC_MSG_RETRY_LIMIT_INDEX) | BIT(FXMAC_MSG_TX_UNDER_RUN_INDEX))); + } + } + } + + /* 接收中断 */ + { + /* 接收完成中断 */ + if ((reg_isr & BIT(FXMAC_MSG_RXCOMP_INDEX)) != 0x00000000U) + { + if (instance_p->recv_irq_handler) + { + instance_p->recv_irq_handler(instance_p->recv_args); + } + + if(instance_p->caps & FXMAC_MSG_CAPS_ISR_CLEAR_ON_WRITE) + { + FXMAC_MSG_WRITE(instance_p, FXMAC_MSG_INT_SR(instance_p->queues[0].index), BIT(FXMAC_MSG_RXCOMP_INDEX)); + } + } + + /* 接收错误中断 */ + if ((reg_isr & (BIT(FXMAC_MSG_RUSED_INDEX) | BIT(FXMAC_MSG_RXOVERRUN_INDEX) | BIT(FXMAC_MSG_RESP_ERR_INDEX))) != 0x00000000U) + { + if ((reg_isr & BIT(FXMAC_MSG_RUSED_INDEX)) != 0x00000000U) + { + if(instance_p->caps & FXMAC_MSG_CAPS_ISR_CLEAR_ON_WRITE) + { + FXMAC_MSG_WRITE(instance_p, FXMAC_MSG_INT_SR(instance_p->queues[0].index), BIT(FXMAC_MSG_RUSED_INDEX)); + } + } + + if ((reg_isr & BIT(FXMAC_MSG_RXOVERRUN_INDEX)) != 0x00000000U) + { + if(instance_p->caps & FXMAC_MSG_CAPS_ISR_CLEAR_ON_WRITE) + { + FXMAC_MSG_WRITE(instance_p, FXMAC_MSG_INT_SR(instance_p->queues[0].index), BIT(FXMAC_MSG_RXOVERRUN_INDEX)); + } + } + + if ((reg_isr & BIT(FXMAC_MSG_RESP_ERR_INDEX)) != 0x00000000U) + { + if(instance_p->caps & FXMAC_MSG_CAPS_ISR_CLEAR_ON_WRITE) + { + FXMAC_MSG_WRITE(instance_p, FXMAC_MSG_INT_SR(instance_p->queues[0].index), BIT(FXMAC_MSG_RESP_ERR_INDEX)); + } + } + } + } +} + +/** + * @name: eth_phytium_xmac_v2_iface_init + * @msg: Initializes the network interface for the Ethernet driver. Sets the link address and registers the Ethernet interface with the network stack. + * @param {struct net_if} *iface is a pointer to the network interface structure. + */ +static void eth_phytium_xmac_v2_iface_init(struct net_if *iface) +{ + const struct device *dev = net_if_get_device(iface); + const struct eth_phytium_xmac_v2_dev_cfg *dev_conf = dev->config; + struct eth_phytium_xmac_v2_dev_data *dev_data = dev->data; + + /* Set the initial contents of the current instance's run-time data */ + dev_data->iface = iface; + net_if_set_link_addr(iface, dev_data->mac_addr, 6, NET_LINK_ETHERNET); + ethernet_init(iface); + net_if_carrier_off(iface); + + /* + * Initialize the (delayed) work items for RX pending, TX done + * and PHY status polling handlers + */ + k_work_init(&dev_data->tx_done_work, eth_phytium_xmac_tx_done_work); + k_work_init(&dev_data->rx_pend_work, eth_phytium_xmac_rx_pending_work); + k_work_init_delayable(&dev_data->phy_poll_delayed_work, eth_phytium_xmac_v2_poll_phy); + + /* Initialize TX completion semaphore */ + k_sem_init(&dev_data->tx_done_sem, 0, 1); + + /* + * Initialize semaphores in the RX/TX BD rings which have not + * yet been initialized + */ + k_sem_init(&dev_data->ring_sem, 1, 1); + /* RX BD ring semaphore is not required at the time being */ + + /* Initialize the device's interrupt */ + dev_conf->config_func(dev); + + /* Submit initial PHY status polling delayed work */ + k_work_reschedule(&dev_data->phy_poll_delayed_work, K_NO_WAIT); +} + +/* 设置特性 */ +void FXmacMsgFeatureSetOptions(u32 feature, FXmacMsgCtrl* xmac_p) +{ + u16 cmd_id, cmd_subid; + cmd_id = FXMAC_MSG_CMD_SET; + + /* 巨帧 */ + if (feature & FXMAC_MSG_LWIP_PORT_CONFIG_JUMBO) + { + xmac_p->config.network_default_config |= FXMAC_MSG_JUMBO_ENABLE_OPTION; + xmac_p->rx_buffer_len = FXMAC_MSG_MAX_FRAME_SIZE_JUMBO; + LOG_INF("FXMAC_MSG_JUMBO_ENABLE_OPTION is ok"); + } + + /* 单播 */ + if (feature & FXMAC_MSG_LWIP_PORT_CONFIG_UNICAST_ADDRESS_FILITER) + { + LOG_INF("FXMAC_MSG_UNICAST_OPTION is ok"); + } + + /* 多播 */ + if (feature & FXMAC_MSG_LWIP_PORT_CONFIG_MULTICAST_ADDRESS_FILITER) + { + cmd_subid = FXMAC_MSG_CMD_SET_ENABLE_MC; + FXmacMsgSendMessage(xmac_p, cmd_id, cmd_subid, NULL, 0, 1); + LOG_INF("FXMAC_MSG_MULTICAST_OPTION is ok"); + } + + /* 全帧 */ + if (feature & FXMAC_MSG_LWIP_PORT_CONFIG_COPY_ALL_FRAMES) + { + cmd_subid = FXMAC_MSG_CMD_SET_ENABLE_PROMISE; + FXmacMsgSendMessage(xmac_p, cmd_id, cmd_subid, NULL, 0, 0); + LOG_INF("FXMAC_MSG_PROMISC_OPTION is ok"); + } + + /* 关闭FCS(帧校验序列)校验 */ + if (feature & FXMAC_MSG_LWIP_PORT_CONFIG_CLOSE_FCS_CHECK) + { + LOG_INF("FXMAC_MSG_FCS_STRIP_OPTION is ok"); + } +} + +/** + * @name: eth_phytium_xmac_v2_dev_init + * @msg: Initializes the Ethernet device, including hardware configuration and MAC address setting. + * @param {const struct device} *dev is a pointer to the device structure for the driver instance. + * @return {int} Zero on success or negative error code on failure. + */ +static int eth_phytium_xmac_v2_dev_init(const struct device *dev) +{ + struct eth_phytium_xmac_v2_dev_data *dev_data = (struct eth_phytium_xmac_v2_dev_data *)dev->data; + struct eth_phytium_xmac_v2_dev_cfg *dev_conf = (struct eth_phytium_xmac_v2_dev_cfg *)dev->config; + FXmacMsgConfig mac_config; + FXmacMsgCtrl *instance_p; + uint32_t xmac_options; + int ret; + + /* DT */ + uintptr_t mac_base = DT_INST_PROP_BY_IDX(0, mac_regs, 1); + size_t mac_size = DT_INST_PROP_BY_IDX(0, mac_regs, 3); + + uintptr_t msg_base = DT_INST_PROP_BY_IDX(0, msg_regs, 1); + size_t msg_size = DT_INST_PROP_BY_IDX(0, msg_regs, 3); + + /* init base */ + DEVICE_MMIO_MAP(dev, K_MEM_CACHE_NONE); + + /* config init */ + mac_config.instance_id = 0; + + /* 获取配置 */ + mac_config = *FXmacMsgLookupConfig(mac_config.instance_id); + + /* 用户设置 */ + ret = eth_phytium_xmac_config_convert(dev_conf, &mac_config, &xmac_options); + if(ret) + { + return -EINVAL; + } + + /* regfile地址映射 */ + mm_reg_t regfile_virt_addr; + device_map(®file_virt_addr, mac_base, mac_size, K_MEM_CACHE_NONE); + mac_config.msg.regfile = regfile_virt_addr; + + /* shmem地址映射 */ + mm_reg_t shmem_virt_addr; + device_map(&shmem_virt_addr, msg_base, msg_size, K_MEM_CACHE_NONE); + mac_config.msg.shmem = shmem_virt_addr; + + instance_p = &dev_data->instance; + if(FXmacMsgCfgInitialize(instance_p, &mac_config)) + { + return -EIO; + } + + /* 初始化MSG消息队列 */ + FXmacMsgInitRing(instance_p); + + /* 获取配置参数 */ + FXmacMsgGetFeatureAll(instance_p); + + /* 硬件重置 */ + FXmacMsgResetHw(instance_p); + + /* 设置特性 */ + FXmacMsgFeatureSetOptions(xmac_options, instance_p); + + /* 初始化硬件 */ + FXmacMsgInitHw(instance_p, (void *)(dev_data->mac_addr)); + + /* 初始化PHY */ + if(mac_config.interface != FXMAC_MSG_PHY_INTERFACE_MODE_USXGMII) + { + if(FXmacMsgPhyInit(instance_p, instance_p->config.speed, instance_p->config.duplex, instance_p->config.auto_neg, FXMAC_MSG_PHY_RESET_ENABLE)) + { + LOG_WRN("FXmacMsgPhyInit is error \r\n"); + } + } + + /* 初始化PHY接口 */ + FXmacMsgInterfaceConfig(instance_p, 0); + + /* 初始化DMA描述符 */ + eth_phytium_xmac_v2_init_dma(dev); + + /* 初始化中断 */ + instance_p->mask = ((u32)BIT(FXMAC_MSG_DMA_ERR_INDEX) | (u32)BIT(FXMAC_MSG_RETRY_LIMIT_INDEX) | (u32)BIT(FXMAC_MSG_TX_UNDER_RUN_INDEX) + | (u32)BIT(FXMAC_MSG_RXOVERRUN_INDEX) | BIT(FXMAC_MSG_RESP_ERR_INDEX) | BIT(FXMAC_MSG_RUSED_INDEX) + | (u32)BIT(FXMAC_MSG_RXCOMP_INDEX) | (u32)BIT(FXMAC_MSG_TXCOMP_INDEX)); + FXmacMsgSetupIsr(dev); + + return 0; +} diff --git a/drivers/ethernet/eth_phytium_xmac_v2.h b/drivers/ethernet/eth_phytium_xmac_v2.h new file mode 100644 index 00000000000..5090dac6058 --- /dev/null +++ b/drivers/ethernet/eth_phytium_xmac_v2.h @@ -0,0 +1,163 @@ +#ifndef _ZEPHYR_DRIVERS_ETHERNET_ETH_PHYTIUM_XMAC_V2_H_ +#define _ZEPHYR_DRIVERS_ETHERNET_ETH_PHYTIUM_XMAC_V2_H_ + +#include "fxmac_msg_bd.h" + +/* Tx Desc Word1 */ +#define XMAC_V2_TXDESC_USED (1 << 31) /* done txmitting */ +#define XMAC_V2_TXDESC_WRAP (1 << 30) /* end descr ring */ +#define XMAC_V2_TXDESC_RETRY_ERR (1 << 29) +#define XMAC_V2_TXDESC_UNDER_RUN (1 << 28) /* underrun error */ +#define XMAC_V2_TXDESC_AHB_ERR (1 << 27) +#define XMAC_V2_TXDESC_LATE_COLL (1 << 26) +#define XMAC_V2_TXDESC_CKSUM_GEN_STAT_MASK (7 << 20) +#define XMAC_V2_TXDESC_CKSUM_GEN_STAT_VLAN_HDR_ERR (1 << 20) +#define XMAC_V2_TXDESC_CKSUM_GEN_STAT_SNAP_HDR_ERR (2 << 20) +#define XMAC_V2_TXDESC_CKSUM_GEN_STAT_IP_HDR_ERR (3 << 20) +#define XMAC_V2_TXDESC_CKSUM_GEN_STAT_UNKNOWN_TYPE (4 << 20) +#define XMAC_V2_TXDESC_CKSUM_GEN_STAT_UNSUPP_FRAG (5 << 20) +#define XMAC_V2_TXDESC_CKSUM_GEN_STAT_NOT_TCPUDP (6 << 20) +#define XMAC_V2_TXDESC_CKSUM_GEN_STAT_SHORT_PKT (7 << 20) +#define XMAC_V2_TXDESC_NO_CRC_APPENDED (1 << 16) +#define XMAC_V2_TXDESC_LAST_BUF (1 << 15) /* last in frame */ +#define XMAC_V2_TXDESC_LENGTH_MASK 0x3fff + +/* Rx Desc Word0 */ +#define XMAC_V2_RXDESC_WRAP (1 << 1) /* end descr ring */ +#define XMAC_V2_RXDESC_OWN (1 << 0) /* ownership flag */ +/* Rx Desc Word1 */ +#define XMAC_V2_RXDESC_BCAST (1 << 31) /* all 1's bcast */ +#define XMAC_V2_RXDESC_MULTI_MATCH (1 << 30) /* mutlicast match */ +#define XMAC_V2_RXDESC_UNICAST_MATCH (1 << 29) +#define XMAC_V2_RXDESC_EXTERNAL_MATCH (1 << 28) /* ext addr match */ +#define XMAC_V2_RXDESC_SPEC_MATCH_SHIFT 25 +#define XMAC_V2_RXDESC_SPEC_MATCH_MASK (3 << 25) +#define XMAC_V2_RXDESC_TYPE_ID_MATCH_SHIFT 22 +#define XMAC_V2_RXDESC_TYPE_ID_MATCH_MASK (3 << 22) +#define XMAC_V2_RXDESC_CKSUM_STAT_MASK (3 << 22) /* same as above */ +#define XMAC_V2_RXDESC_CKSUM_STAT_NONE (0 << 22) +#define XMAC_V2_RXDESC_CKSUM_STAT_IP_GOOD (1 << 22) +#define XMAC_V2_RXDESC_CKSUM_STAT_TCP_GOOD (2 << 22) /* and ip good */ +#define XMAC_V2_RXDESC_CKSUM_STAT_UDP_GOOD (3 << 22) /* and ip good */ +#define XMAC_V2_RXDESC_VLAN_DETECTED (1 << 21) +#define XMAC_V2_RXDESC_PRIO_DETECTED (1 << 20) +#define XMAC_V2_RXDESC_VLAN_PRIO_SHIFT 17 +#define XMAC_V2_RXDESC_VLAN_PRIO_MASK (7 << 17) +#define XMAC_V2_RXDESC_CFI (1 << 16) +#define XMAC_V2_RXDESC_EOF (1 << 15) /* end of frame */ +#define XMAC_V2_RXDESC_SOF (1 << 14) /* start of frame */ +#define XMAC_V2_RXDESC_BAD_FCS (1 << 13) +#define XMAC_V2_RXDESC_LENGTH_MASK 0x1fff + +/* DMA memory area instantiation macro */ +#define ETH_PHYTIUM_XMAC_V2_DMA_AREA_INST(port) \ +static struct eth_phytium_dma_area_gem##port eth_phytium_xmac_v2_##port##_dma_area\ + __aligned(4096); + +/* DMA memory area declaration macro */ +#define ETH_PHYTIUM_XMAC_V2_DMA_AREA_DECL(port) \ +struct eth_phytium_dma_area_gem##port {\ + uint8_t rx_bd[DT_INST_PROP(port, rx_buffer_descriptors) * (u32)sizeof(FXmacMsgBd)] __attribute__((aligned(256))) ;\ + uint8_t tx_bd[DT_INST_PROP(port, tx_buffer_descriptors) * (u32)sizeof(FXmacMsgBd)] __attribute__((aligned(256)));\ + uint8_t rx_buffer\ + [DT_INST_PROP(port, rx_buffer_descriptors)]\ + [((DT_INST_PROP(port, rx_buffer_size)\ + + (ETH_PHYTIUM_BUFFER_ALIGNMENT - 1))\ + & ~(ETH_PHYTIUM_BUFFER_ALIGNMENT - 1))];\ + uint8_t tx_buffer\ + [DT_INST_PROP(port, tx_buffer_descriptors)]\ + [((DT_INST_PROP(port, tx_buffer_size)\ + + (ETH_PHYTIUM_BUFFER_ALIGNMENT - 1))\ + & ~(ETH_PHYTIUM_BUFFER_ALIGNMENT - 1))];\ +}; + + +/* RX/TX BD Ring initialization macro */ +#define ETH_PHYTIUM_XMAC_V2_INIT_BD_RING(port) \ + dev_data->rx_bdspace = &(eth_phytium_xmac_v2_##port##_dma_area.rx_bd[0]);\ + dev_data->tx_bdspace = &(eth_phytium_xmac_v2_##port##_dma_area.tx_bd[0]);\ + dev_data->first_rx_buffer = (uint8_t *)eth_phytium_xmac_v2_##port##_dma_area.rx_buffer;\ + dev_data->first_rx_buffer_virt = dev_data->first_rx_buffer ;\ + dev_data->first_tx_buffer = (uint8_t *)eth_phytium_xmac_v2_##port##_dma_area.tx_buffer; \ + dev_data->first_tx_buffer_virt =dev_data->first_tx_buffer ; + + + + +#define ETH_PHYTIUM_XMAC_V2_NET_DEV_INIT(port) \ +ETH_NET_DEVICE_DT_INST_DEFINE(port,\ + eth_phytium_xmac_v2_dev_init,\ + NULL,\ + ð_phytium_xmac_v2_##port##_dev_data,\ + ð_phytium_xmac_v2_##port##_dev_cfg,\ + CONFIG_ETH_INIT_PRIORITY,\ + ð_phytium_xmac_v2_apis,\ + NET_ETH_MTU); + + + +/* Device configuration data declaration macro */ +#define ETH_PHYTIUM_XMAC_V2_DEV_CONFIG(port) \ +static const struct eth_phytium_xmac_v2_dev_cfg eth_phytium_xmac_v2_##port##_dev_cfg = {\ + DEVICE_MMIO_ROM_INIT(DT_DRV_INST(port)), \ + .instance_id = port, \ + .config_func = eth_phytium_xmac_v2_##port##_irq_config,\ + .pll_clock_frequency = DT_INST_PROP(port, clock_frequency),\ + .phy_poll_interval = DT_INST_PROP(port, phy_poll_interval),\ + .defer_rxp_to_queue = !DT_INST_PROP(port, handle_rx_in_isr),\ + .defer_txd_to_queue = DT_INST_PROP(port, handle_tx_in_workq),\ + .rxbd_count = (uint8_t)\ + (DT_INST_PROP(port, rx_buffer_descriptors)),\ + .txbd_count = (uint8_t)\ + (DT_INST_PROP(port, tx_buffer_descriptors)),\ + .rx_buffer_size = (((uint16_t)(DT_INST_PROP(port, rx_buffer_size)) +\ + (ETH_PHYTIUM_BUFFER_ALIGNMENT-1)) & ~(ETH_PHYTIUM_BUFFER_ALIGNMENT-1)),\ + .tx_buffer_size = (((uint16_t)(DT_INST_PROP(port, tx_buffer_size)) +\ + (ETH_PHYTIUM_BUFFER_ALIGNMENT-1)) & ~(ETH_PHYTIUM_BUFFER_ALIGNMENT-1)),\ + .phy_speed = DT_INST_PROP(port, phy_speed),\ + .interface_mode = DT_INST_PROP(port, interface_mode),\ + .dma_brust_length = DT_INST_PROP(port, dma_brust_length),\ + .max_queue_num = DT_INST_PROP(port, max_queue_num),\ + .phy_autonegotiation = DT_INST_PROP(port, phy_autonegotiation),\ + .enable_fdx = DT_INST_PROP(port, enable_fdx),\ + .enable_jumbo = DT_INST_PROP(port, enable_jumbo),\ + .enable_ucast_hash = DT_INST_PROP(port, enable_ucast_hash),\ + .copy_all_frames = DT_INST_PROP(port, copy_all_frames),\ + .disable_reject_fcs_crc_errors = DT_INST_PROP(port, disable_reject_fcs_crc_errors),\ + .enable_mcast_hash = DT_INST_PROP(port, enable_mcast_hash),\ +}; + +/* Device run-time data declaration macro */ +#define ETH_PHYTIUM_XMAC_V2_DEV_DATA(port) \ +static struct eth_phytium_xmac_v2_dev_data eth_phytium_xmac_v2_##port##_dev_data = {\ + .mac_addr = DT_INST_PROP(port, local_mac_address),\ + .started = 0,\ + .eff_link_speed = LINK_DOWN,\ + .phy_addr = 0,\ + .phy_id = 0,\ + .first_rx_buffer = NULL,\ + .first_tx_buffer = NULL\ +}; + +/* Interrupt configuration function macro */ +#define ETH_PHYTIUM_XMAC_V2_CONFIG_IRQ_FUNC(port) \ +static void eth_phytium_xmac_v2_##port##_irq_config(const struct device *dev)\ +{\ + ARG_UNUSED(dev);\ + IRQ_CONNECT(DT_INST_IRQN(port), DT_INST_IRQ(port, priority),\ + eth_phytium_xmac_v2_isr, DEVICE_DT_INST_GET(port), 0);\ + irq_enable(DT_INST_IRQN(port));\ +} + + +/* Top-level device initialization macro - bundles all of the above */ +#define ETH_PHYTIUM_XMAC_V2_INITIALIZE(port) \ +ETH_PHYTIUM_XMAC_V2_CONFIG_IRQ_FUNC(port);\ +ETH_PHYTIUM_XMAC_V2_DEV_CONFIG(port);\ +ETH_PHYTIUM_XMAC_V2_DEV_DATA(port);\ +ETH_PHYTIUM_XMAC_V2_DMA_AREA_DECL(port);\ +ETH_PHYTIUM_XMAC_V2_DMA_AREA_INST(port);\ +ETH_PHYTIUM_XMAC_V2_NET_DEV_INIT(port);\ + + +#endif diff --git a/dts/arm64/phytium/pd2408.dtsi b/dts/arm64/phytium/pd2408.dtsi index eee5e97bbe1..372c5e8979d 100644 --- a/dts/arm64/phytium/pd2408.dtsi +++ b/dts/arm64/phytium/pd2408.dtsi @@ -127,6 +127,29 @@ clocks = <&uartclk>; }; + xmac_v2_0: xmac_v2@26fd0000 { + compatible = "phytium,xmac_v2"; + reg = <0x00 0x26fd0000 0x00 0x2000>; + mac-regs = <0x00 0x2701d000 0x00 0x2000>; + msg-regs = <0x00 0x26fef000 0x00 0x1000>; + status = "disabled"; + interrupts = ; + interrupt-names = "irq_0"; + phy-poll-interval = <5000>; + clock-frequency = <50000000>; + phy-speed = <1000>; + interface-mode = <0>; + dma-brust-length = <16>; + max-queue-num = <1>; + rx-buffer-descriptors = <128>; + tx-buffer-descriptors = <128>; + rx-buffer-size = <1600>; + tx-buffer-size = <1600>; + phy-autonegotiation; + enable-fdx; + disable-reject-fcs-crc-errors; + }; + /* 512MB DDR */ sram0: memory@80100000 { device_type = "memory"; diff --git a/dts/bindings/ethernet/phytium,xmac_v2.yaml b/dts/bindings/ethernet/phytium,xmac_v2.yaml new file mode 100644 index 00000000000..696de182b37 --- /dev/null +++ b/dts/bindings/ethernet/phytium,xmac_v2.yaml @@ -0,0 +1,243 @@ +# Phytium is pleased to support the open source community by making Zephyr-SDK available. + +# +# Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. +# +# Licensed under the Apache-2.0 License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# https://opensource.org/license/apache-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. + +description: Phytium xmac v2 Ethernet controller + +compatible: "phytium,xmac_v2" + +include: ethernet-controller.yaml + +properties: + reg: + required: true + + mac-regs: + type: array + required: true + description: MAC register address range + + msg-regs: + type: array + required: true + description: Message register address range + + interrupts: + required: true + + clock-frequency: + type: int + required: true + description: | + Specifies the base clock frequency from which the XMAC's TX clock + frequency . + + phy-poll-interval: + type: int + required: true + description: | + PHY status polling interval in milliseconds for a driver instance + managing an associated PHY. + + phy-speed: + type: int + required: true + description: | + Nominal link speed. If no PHY is managed by an instance of this driver, + the respective controller will be configured to match the link speed + specified here. If a PHY is managed by the driver, advertisement of + the link speed specified here will be requested. If the optional pro- + perty advertise-lower-link-speeds is set, advertisement of the link + speed specified here plus any valid link speed below this value will + be requested. + enum: + - 10 + - 100 + - 1000 + - 10000 + + + interface-mode: + type: int + required: true + description: | + Specifies the interface mode for the Xmac. Each mode corresponds to a different type of media-independent interface that determines how the Ethernet PHY is connected to the MAC. The available modes are: + - 0: SGMII (Serial Gigabit Media Independent Interface), a serial version of the Gigabit Media Independent Interface that is used for Gigabit Ethernet connections. + - 1: RMII (Reduced Media Independent Interface), a reduced version of the Media Independent Interface designed for 10/100Mbps Ethernet connections with a reduced number of signal lines. + - 2: RGMII (Reduced Gigabit Media Independent Interface), a version of the Gigabit Media Independent Interface designed for 10/100/1000Mbps Ethernet connections with a reduced number of signal lines. + - 3: USXGMII (Universal Serial 10 Gigabit Media Independent Interface), a serial interface designed for speeds beyond 1Gbps, supporting a range of speeds up to 10Gbps over a single pair of copper or optical fiber. + enum: + - 0 + - 1 + - 2 + - 3 + + + + dma-brust-length: + type: int + required: true + description: | + Defines the burst length for DMA (Direct Memory Access) operations in the Xmac driver. + The burst length specifies the maximum number of words the DMA controller can transfer in a single burst. + Adjusting this parameter can impact the efficiency of data transfers between the Ethernet MAC and the system memory, + potentially affecting overall throughput and latency. A value of 16 indicates that the DMA controller is configured to transfer up to 16 words in a single burst. + Choosing the optimal burst length depends on the specific characteristics of the system, including the DMA controller's capabilities and the memory system's response to burst accesses. + enum: + - 16 + + + max-queue-num: + type: int + required: true + description: | + Specifies the maximum number of queue slots available for managing Ethernet frames in the Xmac driver. + This parameter determines the capacity of the driver to handle multiple Ethernet frames concurrently, + which can influence the efficiency of packet processing, especially under high network traffic conditions. + A value of 1 indicates that the driver is configured to manage Ethernet frames using a single queue. + This configuration is suitable for simpler network setups or systems with lower traffic demands. + Implementing multiple queues can be advantageous in systems that require high throughput and efficient traffic management, + but this comes at the cost of increased complexity in queue management. + enum: + - 1 + + + phy-autonegotiation: + type: boolean + description: | + Determines whether the PHY (Physical Layer Transceiver) should use autonegotiation to automatically select the speed and duplex mode of the Ethernet connection. + When enabled (`true`), the PHY will communicate with the link partner (typically a switch, router, or another network device) to determine the best mutual settings for speed (10/100/1000 Mbps) and duplex mode (half or full duplex). + This process ensures compatibility and optimizes the connection for the best possible performance. + When disabled (`false`), the PHY will not initiate or respond to autonegotiation attempts, and the speed and duplex mode must be manually configured to match the link partner's settings, potentially reducing flexibility and compatibility. + + + enable-fdx: + type: boolean + description: | + Indicates whether the PHY (Physical Layer Transceiver) should operate in full-duplex mode. + In full-duplex mode (`true`), the Ethernet connection supports simultaneous bi-directional data transmission, allowing data to be sent and received at the same time, + effectively doubling the potential throughput compared to half-duplex. + This mode is ideal for high-speed networks where data collisions are managed and can significantly enhance network performance. + When set to `false`, the PHY operates in half-duplex mode, where data transmission and reception cannot occur simultaneously, + leading to a possible increase in data collisions and retransmissions, especially in high traffic conditions. + Selecting the appropriate duplex mode depends on network infrastructure, cable types, and the capabilities of the network devices involved in the connection. + + + enable-jumbo: + type: boolean + description: | + Specifies whether Jumbo Frames are enabled for the Ethernet device. Jumbo Frames are Ethernet frames with a payload greater than the standard maximum of 1500 bytes, + often up to 9000 bytes (9 KB). Enabling Jumbo Frames (`true`) can significantly increase data transfer efficiency by reducing the number of frames needed to transmit large amounts of data, + thereby decreasing CPU usage, increasing throughput, and improving network performance. + However, all devices in the network path must support Jumbo Frames to avoid fragmentation or dropped packets. + Disabling this feature (`false`) restricts the Ethernet frames to standard sizes, ensuring compatibility with network devices that do not support Jumbo Frames. + + + enable-ucast-hash: + type: boolean + description: | + Determines whether unicast hash filtering is enabled for the Ethernet device. + When activated (`true`), this feature allows the network interface to filter incoming unicast packets based on a hash function applied to the destination MAC address. + This mechanism is particularly useful in managing network traffic by ensuring that the Ethernet device processes only those unicast packets that match its hash criteria, + effectively reducing unnecessary packet processing and improving overall network efficiency. + This is beneficial in environments with high traffic levels or when the network interface is part of a larger, segmented network setup. + Disabling this feature (`false`) means the device will not use hash-based filtering for incoming unicast frames, + potentially leading to increased processing of irrelevant packets. + + + copy-all-frames: + type: boolean + description: | + Controls whether the Ethernet device is set to copy all incoming frames to system memory, + regardless of their destination MAC address. When enabled (`true`), + this feature instructs the device to pass all observed frames to the higher layers of the network stack, + effectively putting the network interface in a promiscuous mode. This mode is essential for network monitoring, + packet sniffing, and debugging tasks, where it's necessary to examine all traffic passing through the network segment the device is attached to. + However, it can lead to increased processing overhead due to the higher volume of data being passed up the stack. When disabled (`false`), + the device filters incoming frames, processing only those addressed to it or broadcast/multicast frames, + depending on its configuration, which is the normal operation mode for most network interfaces. + + + disable-reject-fcs-crc-errors: + type: boolean + description: | + Optional feature flag - Disable rejection of FCS/CRC errors. + When set, frames with FCS/CRC errors will not be rejected. FCS error + statistics will still be collected for frames with bad FCS and FCS + status will be recorded in the frame's DMA descriptor. This option + should not be activated for normal operation. + + enable-mcast-hash: + type: boolean + description: | + Enables multicast hash filtering for the Ethernet device. + When set to `true`, this feature allows the network interface to utilize a hash function on the destination MAC address of incoming multicast packets to determine if they should be passed to the system for processing. + This targeted approach helps manage multicast traffic more efficiently by ensuring the device processes only those multicast packets that match predefined criteria, + reducing unnecessary data processing and enhancing network throughput. This is especially beneficial in environments with substantial multicast traffic, such as multimedia streaming or multicast group communications. When disabled (`false`), + the device may not use hash-based filtering for multicast frames, which could result in increased processing of multicast packets that are not of interest to the receiving system. + + + handle-rx-in-isr: + type: boolean + description: | + Moves the handling of the frame received interrupt including the + transfer of packet data from the DMA to network packet buffers and + the subsequent propagation of the received packets to the network + stack into the context of the ISR. Due to the unpredictability of + the runtime of the ISR whenever large amounts of data are received, + handling of the RX interrupt is normally deferred to the context + of the system work queue. + + + handle-tx-in-workq: + type: boolean + description: | + Moves the handling of the frame transmission done interrupt into the + context of the system work queue. By default, TX done handling is per- + formed in the context of the ISR, as it only involves a limited number + of memory accesses. This option CAN NOT be used if any component ex- + ists within the current system setup that triggers the transmission + of packets from within the context of the system work queue! + + + rx-buffer-descriptors: + type: int + required: true + description: | + The number of descriptors to be allocated in the RX buffer descriptor + ring. Must be <= 255. + + + rx-buffer-size: + type: int + required: true + description: | + The size of each receive data buffer, must be a multiple of 8, highest + valid value is 16320, values less than 64 are not really useful. + + + tx-buffer-descriptors: + type: int + required: true + description: | + The number of descriptors to be allocated in the TX buffer descriptor + ring. Must be <= 255. + + tx-buffer-size: + type: int + required: true + description: | + The size of each transmit data buffer, highest valid value is 16380, + values less than 64 are not really useful. + -- Gitee From cdfcf06e0754aa01305d34f68a79f17c85083fc0 Mon Sep 17 00:00:00 2001 From: zhangyan <1422953826@qq.com> Date: Tue, 12 Aug 2025 11:22:20 +0800 Subject: [PATCH 13/13] delete dts --- .../d2000_aarch32_demo/d2000_aarch32_demo.dts | 36 ---- boards/phytium/d2000_demo/d2000_demo.dts | 41 ---- .../d2000_demo/d2000_demo_pd2008_el2.dts | 41 ---- .../d2000_demo/d2000_demo_pd2008_el2_smp.dts | 46 ----- .../d2000_demo/d2000_demo_pd2008_smp.dts | 46 ----- boards/phytium/pd2308_demo/pd2308_demo.dts | 47 ----- .../pd2308_demo/pd2308_demo_pd2308_el2.dts | 47 ----- .../pd2308_demo_pd2308_el2_smp.dts | 47 ----- .../pd2308_demo/pd2308_demo_pd2308_smp.dts | 54 ------ .../phytium/pd2308_demo/pd2308_pinctrl.dtsi | 12 -- .../phytium/pd2408_test_a/pd2408_test_a.dts | 39 ---- .../pd2408_test_a_pd2408_el2.dts | 34 ---- .../pd2408_test_a_pd2408_el2_smp.dts | 34 ---- .../pd2408_test_a_pd2408_smp.dts | 41 ---- .../pd2408_test_a/pd2408_test_a_pinctrl.dtsi | 12 -- .../phytium/pd2408_test_b/pd2408_test_b.dts | 39 ---- .../pd2408_test_b_pd2408_el2.dts | 34 ---- .../pd2408_test_b_pd2408_el2_smp.dts | 34 ---- .../pd2408_test_b_pd2408_smp.dts | 41 ---- .../pd2408_test_b/pd2408_test_b_pinctrl.dtsi | 12 -- boards/phytium/ps2316_test/ps2316_test.dts | 31 --- .../ps2316_test/ps2316_test_ps2316_el2.dts | 32 --- .../ps2316_test_ps2316_el2_smp.dts | 32 --- .../ps2316_test/ps2316_test_ps2316_smp.dts | 31 --- dts/arm/phytium/pd2008_aarch32.dtsi | 164 ---------------- dts/arm64/phytium/pd2008.dtsi | 164 ---------------- dts/arm64/phytium/pd2308.dtsi | 183 ------------------ dts/arm64/phytium/pd2408.dtsi | 173 ----------------- dts/arm64/phytium/ps2316.dtsi | 157 --------------- 29 files changed, 1704 deletions(-) delete mode 100644 boards/phytium/d2000_aarch32_demo/d2000_aarch32_demo.dts delete mode 100644 boards/phytium/d2000_demo/d2000_demo.dts delete mode 100644 boards/phytium/d2000_demo/d2000_demo_pd2008_el2.dts delete mode 100644 boards/phytium/d2000_demo/d2000_demo_pd2008_el2_smp.dts delete mode 100644 boards/phytium/d2000_demo/d2000_demo_pd2008_smp.dts delete mode 100644 boards/phytium/pd2308_demo/pd2308_demo.dts delete mode 100644 boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2.dts delete mode 100644 boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2_smp.dts delete mode 100644 boards/phytium/pd2308_demo/pd2308_demo_pd2308_smp.dts delete mode 100644 boards/phytium/pd2308_demo/pd2308_pinctrl.dtsi delete mode 100644 boards/phytium/pd2408_test_a/pd2408_test_a.dts delete mode 100644 boards/phytium/pd2408_test_a/pd2408_test_a_pd2408_el2.dts delete mode 100644 boards/phytium/pd2408_test_a/pd2408_test_a_pd2408_el2_smp.dts delete mode 100644 boards/phytium/pd2408_test_a/pd2408_test_a_pd2408_smp.dts delete mode 100644 boards/phytium/pd2408_test_a/pd2408_test_a_pinctrl.dtsi delete mode 100644 boards/phytium/pd2408_test_b/pd2408_test_b.dts delete mode 100644 boards/phytium/pd2408_test_b/pd2408_test_b_pd2408_el2.dts delete mode 100644 boards/phytium/pd2408_test_b/pd2408_test_b_pd2408_el2_smp.dts delete mode 100644 boards/phytium/pd2408_test_b/pd2408_test_b_pd2408_smp.dts delete mode 100644 boards/phytium/pd2408_test_b/pd2408_test_b_pinctrl.dtsi delete mode 100644 boards/phytium/ps2316_test/ps2316_test.dts delete mode 100644 boards/phytium/ps2316_test/ps2316_test_ps2316_el2.dts delete mode 100644 boards/phytium/ps2316_test/ps2316_test_ps2316_el2_smp.dts delete mode 100644 boards/phytium/ps2316_test/ps2316_test_ps2316_smp.dts delete mode 100644 dts/arm/phytium/pd2008_aarch32.dtsi delete mode 100644 dts/arm64/phytium/pd2008.dtsi delete mode 100644 dts/arm64/phytium/pd2308.dtsi delete mode 100644 dts/arm64/phytium/pd2408.dtsi delete mode 100644 dts/arm64/phytium/ps2316.dtsi diff --git a/boards/phytium/d2000_aarch32_demo/d2000_aarch32_demo.dts b/boards/phytium/d2000_aarch32_demo/d2000_aarch32_demo.dts deleted file mode 100644 index 43529d289c0..00000000000 --- a/boards/phytium/d2000_aarch32_demo/d2000_aarch32_demo.dts +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2024 zhangyan - * - * SPDX-License-Identifier: Apache-2.0 - */ - -/dts-v1/; -#include - -/ { - model = "Phytium d2000 demo"; - compatible = "phytium,d2000-demo", "phytium,d2000"; - #address-cells = <2>; - #size-cells = <2>; - -chosen { - zephyr,console = &uart1; - zephyr,shell-uart = &uart1; - zephyr,sram = &sram0; - }; -}; - -&gmac0 { - local-mac-address = [00 00 00 01 02 03]; - status = "okay"; -}; - -&uart1 { - current-speed = <115200>; - status = "okay"; -}; - -&uart2 { - current-speed = <115200>; - status = "okay"; -}; diff --git a/boards/phytium/d2000_demo/d2000_demo.dts b/boards/phytium/d2000_demo/d2000_demo.dts deleted file mode 100644 index 118d0225a55..00000000000 --- a/boards/phytium/d2000_demo/d2000_demo.dts +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2024 zhangyan - * - * SPDX-License-Identifier: Apache-2.0 - */ - -/dts-v1/; -#include - -/ { - model = "Phytium d2000 demo"; - compatible = "phytium,d2000-demo", "phytium,d2000"; - #address-cells = <2>; - #size-cells = <2>; - -chosen { - zephyr,console = &uart1; - zephyr,shell-uart = &uart1; - zephyr,sram = &sram0; - zephyr,pcie-controller = &pcie0; - }; -}; - -&gmac0 { - local-mac-address = [00 00 00 01 02 03]; - status = "okay"; -}; - -&uart1 { - current-speed = <115200>; - status = "okay"; -}; - -&uart2 { - current-speed = <115200>; - status = "okay"; -}; - -&pcie0 { - status = "okay"; -}; diff --git a/boards/phytium/d2000_demo/d2000_demo_pd2008_el2.dts b/boards/phytium/d2000_demo/d2000_demo_pd2008_el2.dts deleted file mode 100644 index 118d0225a55..00000000000 --- a/boards/phytium/d2000_demo/d2000_demo_pd2008_el2.dts +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2024 zhangyan - * - * SPDX-License-Identifier: Apache-2.0 - */ - -/dts-v1/; -#include - -/ { - model = "Phytium d2000 demo"; - compatible = "phytium,d2000-demo", "phytium,d2000"; - #address-cells = <2>; - #size-cells = <2>; - -chosen { - zephyr,console = &uart1; - zephyr,shell-uart = &uart1; - zephyr,sram = &sram0; - zephyr,pcie-controller = &pcie0; - }; -}; - -&gmac0 { - local-mac-address = [00 00 00 01 02 03]; - status = "okay"; -}; - -&uart1 { - current-speed = <115200>; - status = "okay"; -}; - -&uart2 { - current-speed = <115200>; - status = "okay"; -}; - -&pcie0 { - status = "okay"; -}; diff --git a/boards/phytium/d2000_demo/d2000_demo_pd2008_el2_smp.dts b/boards/phytium/d2000_demo/d2000_demo_pd2008_el2_smp.dts deleted file mode 100644 index 39c3082fc60..00000000000 --- a/boards/phytium/d2000_demo/d2000_demo_pd2008_el2_smp.dts +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2024 zhangyan - * - * SPDX-License-Identifier: Apache-2.0 - */ - -/dts-v1/; - -#include -/ { - model = "Phytium d2000 demo"; - compatible = "phytium,d2000-demo", "phytium,d2000"; - #address-cells = <2>; - #size-cells = <2>; - - psci { - compatible = "arm,psci-0.2"; - method = "smc"; - }; - -chosen { - zephyr,console = &uart1; - zephyr,shell-uart = &uart1; - zephyr,sram = &sram0; - zephyr,pcie-controller = &pcie0; - }; -}; - -&gmac0 { - local-mac-address = [00 00 00 01 02 03]; - status = "okay"; -}; - -&uart1 { - status = "okay"; - current-speed = <115200>; -}; - -&uart2 { - status = "okay"; - current-speed = <115200>; -}; - -&pcie0 { - status = "okay"; -}; diff --git a/boards/phytium/d2000_demo/d2000_demo_pd2008_smp.dts b/boards/phytium/d2000_demo/d2000_demo_pd2008_smp.dts deleted file mode 100644 index 39c3082fc60..00000000000 --- a/boards/phytium/d2000_demo/d2000_demo_pd2008_smp.dts +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2024 zhangyan - * - * SPDX-License-Identifier: Apache-2.0 - */ - -/dts-v1/; - -#include -/ { - model = "Phytium d2000 demo"; - compatible = "phytium,d2000-demo", "phytium,d2000"; - #address-cells = <2>; - #size-cells = <2>; - - psci { - compatible = "arm,psci-0.2"; - method = "smc"; - }; - -chosen { - zephyr,console = &uart1; - zephyr,shell-uart = &uart1; - zephyr,sram = &sram0; - zephyr,pcie-controller = &pcie0; - }; -}; - -&gmac0 { - local-mac-address = [00 00 00 01 02 03]; - status = "okay"; -}; - -&uart1 { - status = "okay"; - current-speed = <115200>; -}; - -&uart2 { - status = "okay"; - current-speed = <115200>; -}; - -&pcie0 { - status = "okay"; -}; diff --git a/boards/phytium/pd2308_demo/pd2308_demo.dts b/boards/phytium/pd2308_demo/pd2308_demo.dts deleted file mode 100644 index 44daa234029..00000000000 --- a/boards/phytium/pd2308_demo/pd2308_demo.dts +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2024 zhangyan - * - * SPDX-License-Identifier: Apache-2.0 - */ - -/dts-v1/; -#include -#include "pd2308_pinctrl.dtsi" - -/ { - model = "Phytium pd2308 demo"; - compatible = "phytium,pd2308-demo", "phytium,pd2308"; - #address-cells = <2>; - #size-cells = <2>; - -chosen { - zephyr,console = &uart1; - zephyr,shell-uart = &uart1; - zephyr,sram = &sram0; - zephyr,pcie-controller = &pcie0; - }; -}; - -&sdhc0 { - status = "okay"; - sdmmc { - compatible = "zephyr,sdmmc-disk"; - status = "okay"; - }; -}; - -&xmac0 { - status = "okay"; - local-mac-address = [00 00 00 01 02 03]; -}; - -&uart1 { - current-speed = <115200>; - pinctrl-0 = <&uart1_rx_default &uart1_tx_default>; - pinctrl-names = "default"; - status = "okay"; -}; - -&pcie0 { - status = "okay"; -}; diff --git a/boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2.dts b/boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2.dts deleted file mode 100644 index 44daa234029..00000000000 --- a/boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2.dts +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2024 zhangyan - * - * SPDX-License-Identifier: Apache-2.0 - */ - -/dts-v1/; -#include -#include "pd2308_pinctrl.dtsi" - -/ { - model = "Phytium pd2308 demo"; - compatible = "phytium,pd2308-demo", "phytium,pd2308"; - #address-cells = <2>; - #size-cells = <2>; - -chosen { - zephyr,console = &uart1; - zephyr,shell-uart = &uart1; - zephyr,sram = &sram0; - zephyr,pcie-controller = &pcie0; - }; -}; - -&sdhc0 { - status = "okay"; - sdmmc { - compatible = "zephyr,sdmmc-disk"; - status = "okay"; - }; -}; - -&xmac0 { - status = "okay"; - local-mac-address = [00 00 00 01 02 03]; -}; - -&uart1 { - current-speed = <115200>; - pinctrl-0 = <&uart1_rx_default &uart1_tx_default>; - pinctrl-names = "default"; - status = "okay"; -}; - -&pcie0 { - status = "okay"; -}; diff --git a/boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2_smp.dts b/boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2_smp.dts deleted file mode 100644 index 44daa234029..00000000000 --- a/boards/phytium/pd2308_demo/pd2308_demo_pd2308_el2_smp.dts +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2024 zhangyan - * - * SPDX-License-Identifier: Apache-2.0 - */ - -/dts-v1/; -#include -#include "pd2308_pinctrl.dtsi" - -/ { - model = "Phytium pd2308 demo"; - compatible = "phytium,pd2308-demo", "phytium,pd2308"; - #address-cells = <2>; - #size-cells = <2>; - -chosen { - zephyr,console = &uart1; - zephyr,shell-uart = &uart1; - zephyr,sram = &sram0; - zephyr,pcie-controller = &pcie0; - }; -}; - -&sdhc0 { - status = "okay"; - sdmmc { - compatible = "zephyr,sdmmc-disk"; - status = "okay"; - }; -}; - -&xmac0 { - status = "okay"; - local-mac-address = [00 00 00 01 02 03]; -}; - -&uart1 { - current-speed = <115200>; - pinctrl-0 = <&uart1_rx_default &uart1_tx_default>; - pinctrl-names = "default"; - status = "okay"; -}; - -&pcie0 { - status = "okay"; -}; diff --git a/boards/phytium/pd2308_demo/pd2308_demo_pd2308_smp.dts b/boards/phytium/pd2308_demo/pd2308_demo_pd2308_smp.dts deleted file mode 100644 index 4d8507663f6..00000000000 --- a/boards/phytium/pd2308_demo/pd2308_demo_pd2308_smp.dts +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2024 zhangyan - * - * SPDX-License-Identifier: Apache-2.0 - */ - -/dts-v1/; - -#include -#include "pd2308_pinctrl.dtsi" - -/ { - model = "Phytium pd2308 demo"; - compatible = "phytium,pd2308-demo", "phytium,pd2308"; - #address-cells = <2>; - #size-cells = <2>; - - psci { - compatible = "arm,psci-0.2"; - method = "smc"; - }; - -chosen { - zephyr,console = &uart1; - zephyr,shell-uart = &uart1; - zephyr,sram = &sram0; - zephyr,pcie-controller = &pcie0; - }; -}; - -&sdhc0 { - status = "okay"; - sdmmc { - compatible = "zephyr,sdmmc-disk"; - status = "okay"; - }; -}; - -&xmac0 { - status = "okay"; - local-mac-address = [00 00 00 01 02 03]; -}; - -&uart1 { - current-speed = <115200>; - pinctrl-0 = <&uart1_rx_default &uart1_tx_default>; - pinctrl-names = "default"; - status = "okay"; -}; - -&pcie0 { - status = "okay"; -}; - diff --git a/boards/phytium/pd2308_demo/pd2308_pinctrl.dtsi b/boards/phytium/pd2308_demo/pd2308_pinctrl.dtsi deleted file mode 100644 index 7f69aa2ec98..00000000000 --- a/boards/phytium/pd2308_demo/pd2308_pinctrl.dtsi +++ /dev/null @@ -1,12 +0,0 @@ - - -#include - -&pinctrl { - uart1_rx_default: uart1_rx_default { - pinmux = ; - }; - uart1_tx_default: uart1_tx_default { - pinmux = ; - }; -}; \ No newline at end of file diff --git a/boards/phytium/pd2408_test_a/pd2408_test_a.dts b/boards/phytium/pd2408_test_a/pd2408_test_a.dts deleted file mode 100644 index 7915d96763a..00000000000 --- a/boards/phytium/pd2408_test_a/pd2408_test_a.dts +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2024 zhangyan - * - * SPDX-License-Identifier: Apache-2.0 - */ - -/dts-v1/; -#include -#include "pd2408_test_a_pinctrl.dtsi" - -/ { - model = "Phytium pd2408 test a"; - compatible = "phytium,pd2408-test-a", "phytium,pd2408"; - #address-cells = <2>; - #size-cells = <2>; - -chosen { - zephyr,console = &uart1; - zephyr,shell-uart = &uart1; - zephyr,sram = &sram0; - zephyr,pcie-controller = &pcie0; - }; -}; - -&xmac_v2_0 { - status = "okay"; - local-mac-address = [00 00 00 01 02 03]; -}; - -&uart1 { - current-speed = <115200>; - pinctrl-0 = <&uart1_rx_default &uart1_tx_default>; - pinctrl-names = "default"; - status = "okay"; -}; - -&pcie0 { - status = "okay"; -}; diff --git a/boards/phytium/pd2408_test_a/pd2408_test_a_pd2408_el2.dts b/boards/phytium/pd2408_test_a/pd2408_test_a_pd2408_el2.dts deleted file mode 100644 index a102bd04b2b..00000000000 --- a/boards/phytium/pd2408_test_a/pd2408_test_a_pd2408_el2.dts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2024 zhangyan - * - * SPDX-License-Identifier: Apache-2.0 - */ - -/dts-v1/; -#include -#include "pd2408_test_a_pinctrl.dtsi" - -/ { - model = "Phytium pd2408 test a"; - compatible = "phytium,pd2408-test-a", "phytium,pd2408"; - #address-cells = <2>; - #size-cells = <2>; - -chosen { - zephyr,console = &uart1; - zephyr,shell-uart = &uart1; - zephyr,sram = &sram0; - zephyr,pcie-controller = &pcie0; - }; -}; - -&uart1 { - current-speed = <115200>; - pinctrl-0 = <&uart1_rx_default &uart1_tx_default>; - pinctrl-names = "default"; - status = "okay"; -}; - -&pcie0 { - status = "okay"; -}; diff --git a/boards/phytium/pd2408_test_a/pd2408_test_a_pd2408_el2_smp.dts b/boards/phytium/pd2408_test_a/pd2408_test_a_pd2408_el2_smp.dts deleted file mode 100644 index a102bd04b2b..00000000000 --- a/boards/phytium/pd2408_test_a/pd2408_test_a_pd2408_el2_smp.dts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2024 zhangyan - * - * SPDX-License-Identifier: Apache-2.0 - */ - -/dts-v1/; -#include -#include "pd2408_test_a_pinctrl.dtsi" - -/ { - model = "Phytium pd2408 test a"; - compatible = "phytium,pd2408-test-a", "phytium,pd2408"; - #address-cells = <2>; - #size-cells = <2>; - -chosen { - zephyr,console = &uart1; - zephyr,shell-uart = &uart1; - zephyr,sram = &sram0; - zephyr,pcie-controller = &pcie0; - }; -}; - -&uart1 { - current-speed = <115200>; - pinctrl-0 = <&uart1_rx_default &uart1_tx_default>; - pinctrl-names = "default"; - status = "okay"; -}; - -&pcie0 { - status = "okay"; -}; diff --git a/boards/phytium/pd2408_test_a/pd2408_test_a_pd2408_smp.dts b/boards/phytium/pd2408_test_a/pd2408_test_a_pd2408_smp.dts deleted file mode 100644 index 07369b2b458..00000000000 --- a/boards/phytium/pd2408_test_a/pd2408_test_a_pd2408_smp.dts +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2024 zhangyan - * - * SPDX-License-Identifier: Apache-2.0 - */ - -/dts-v1/; - -#include -#include "pd2408_test_a_pinctrl.dtsi" - -/ { - model = "Phytium pd2408 test a"; - compatible = "phytium,pd2408-test-a", "phytium,pd2408"; - #address-cells = <2>; - #size-cells = <2>; - - psci { - compatible = "arm,psci-0.2"; - method = "smc"; - }; - -chosen { - zephyr,console = &uart1; - zephyr,shell-uart = &uart1; - zephyr,sram = &sram0; - zephyr,pcie-controller = &pcie0; - }; -}; - -&uart1 { - current-speed = <115200>; - pinctrl-0 = <&uart1_rx_default &uart1_tx_default>; - pinctrl-names = "default"; - status = "okay"; -}; - -&pcie0 { - status = "okay"; -}; - diff --git a/boards/phytium/pd2408_test_a/pd2408_test_a_pinctrl.dtsi b/boards/phytium/pd2408_test_a/pd2408_test_a_pinctrl.dtsi deleted file mode 100644 index 0c800d14776..00000000000 --- a/boards/phytium/pd2408_test_a/pd2408_test_a_pinctrl.dtsi +++ /dev/null @@ -1,12 +0,0 @@ - - -#include - -&pinctrl { - uart1_rx_default: uart1_rx_default { - pinmux = ; - }; - uart1_tx_default: uart1_tx_default { - pinmux = ; - }; -}; \ No newline at end of file diff --git a/boards/phytium/pd2408_test_b/pd2408_test_b.dts b/boards/phytium/pd2408_test_b/pd2408_test_b.dts deleted file mode 100644 index d712e7b8a6a..00000000000 --- a/boards/phytium/pd2408_test_b/pd2408_test_b.dts +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2024 zhangyan - * - * SPDX-License-Identifier: Apache-2.0 - */ - -/dts-v1/; -#include -#include "pd2408_test_b_pinctrl.dtsi" - -/ { - model = "Phytium pd2408 test b"; - compatible = "phytium,pd2408-test-a", "phytium,pd2408"; - #address-cells = <2>; - #size-cells = <2>; - -chosen { - zephyr,console = &uart1; - zephyr,shell-uart = &uart1; - zephyr,sram = &sram0; - zephyr,pcie-controller = &pcie0; - }; -}; - -&xmac_v2_0 { - status = "okay"; - local-mac-address = [00 00 00 01 02 03]; -}; - -&uart1 { - current-speed = <115200>; - pinctrl-0 = <&uart1_rx_default &uart1_tx_default>; - pinctrl-names = "default"; - status = "okay"; -}; - -&pcie0 { - status = "okay"; -}; diff --git a/boards/phytium/pd2408_test_b/pd2408_test_b_pd2408_el2.dts b/boards/phytium/pd2408_test_b/pd2408_test_b_pd2408_el2.dts deleted file mode 100644 index fe40e62f16e..00000000000 --- a/boards/phytium/pd2408_test_b/pd2408_test_b_pd2408_el2.dts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2024 zhangyan - * - * SPDX-License-Identifier: Apache-2.0 - */ - -/dts-v1/; -#include -#include "pd2408_test_b_pinctrl.dtsi" - -/ { - model = "Phytium pd2408 test b"; - compatible = "phytium,pd2408-test-a", "phytium,pd2408"; - #address-cells = <2>; - #size-cells = <2>; - -chosen { - zephyr,console = &uart1; - zephyr,shell-uart = &uart1; - zephyr,sram = &sram0; - zephyr,pcie-controller = &pcie0; - }; -}; - -&uart1 { - current-speed = <115200>; - pinctrl-0 = <&uart1_rx_default &uart1_tx_default>; - pinctrl-names = "default"; - status = "okay"; -}; - -&pcie0 { - status = "okay"; -}; diff --git a/boards/phytium/pd2408_test_b/pd2408_test_b_pd2408_el2_smp.dts b/boards/phytium/pd2408_test_b/pd2408_test_b_pd2408_el2_smp.dts deleted file mode 100644 index fe40e62f16e..00000000000 --- a/boards/phytium/pd2408_test_b/pd2408_test_b_pd2408_el2_smp.dts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2024 zhangyan - * - * SPDX-License-Identifier: Apache-2.0 - */ - -/dts-v1/; -#include -#include "pd2408_test_b_pinctrl.dtsi" - -/ { - model = "Phytium pd2408 test b"; - compatible = "phytium,pd2408-test-a", "phytium,pd2408"; - #address-cells = <2>; - #size-cells = <2>; - -chosen { - zephyr,console = &uart1; - zephyr,shell-uart = &uart1; - zephyr,sram = &sram0; - zephyr,pcie-controller = &pcie0; - }; -}; - -&uart1 { - current-speed = <115200>; - pinctrl-0 = <&uart1_rx_default &uart1_tx_default>; - pinctrl-names = "default"; - status = "okay"; -}; - -&pcie0 { - status = "okay"; -}; diff --git a/boards/phytium/pd2408_test_b/pd2408_test_b_pd2408_smp.dts b/boards/phytium/pd2408_test_b/pd2408_test_b_pd2408_smp.dts deleted file mode 100644 index 544dc8e6816..00000000000 --- a/boards/phytium/pd2408_test_b/pd2408_test_b_pd2408_smp.dts +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2024 zhangyan - * - * SPDX-License-Identifier: Apache-2.0 - */ - -/dts-v1/; - -#include -#include "pd2408_test_b_pinctrl.dtsi" - -/ { - model = "Phytium pd2408 test b"; - compatible = "phytium,pd2408-test-a", "phytium,pd2408"; - #address-cells = <2>; - #size-cells = <2>; - - psci { - compatible = "arm,psci-0.2"; - method = "smc"; - }; - -chosen { - zephyr,console = &uart1; - zephyr,shell-uart = &uart1; - zephyr,sram = &sram0; - zephyr,pcie-controller = &pcie0; - }; -}; - -&uart1 { - current-speed = <115200>; - pinctrl-0 = <&uart1_rx_default &uart1_tx_default>; - pinctrl-names = "default"; - status = "okay"; -}; - -&pcie0 { - status = "okay"; -}; - diff --git a/boards/phytium/pd2408_test_b/pd2408_test_b_pinctrl.dtsi b/boards/phytium/pd2408_test_b/pd2408_test_b_pinctrl.dtsi deleted file mode 100644 index 0c800d14776..00000000000 --- a/boards/phytium/pd2408_test_b/pd2408_test_b_pinctrl.dtsi +++ /dev/null @@ -1,12 +0,0 @@ - - -#include - -&pinctrl { - uart1_rx_default: uart1_rx_default { - pinmux = ; - }; - uart1_tx_default: uart1_tx_default { - pinmux = ; - }; -}; \ No newline at end of file diff --git a/boards/phytium/ps2316_test/ps2316_test.dts b/boards/phytium/ps2316_test/ps2316_test.dts deleted file mode 100644 index 2b8b8bccf47..00000000000 --- a/boards/phytium/ps2316_test/ps2316_test.dts +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2023 honglin leng - * - * SPDX-License-Identifier: Apache-2.0 - */ - -/dts-v1/; - -#include -/ { - model = "Phytium ps2316 test"; - compatible = "phytium,ps2316-test", "phytium,ps2316"; - #address-cells = <2>; - #size-cells = <2>; - - psci { - compatible = "arm,psci-0.2"; - method = "smc"; - }; - -chosen { - zephyr,console = &uart1; - zephyr,shell-uart = &uart1; - zephyr,sram = &sram0; - }; -}; - -&uart1 { - status = "okay"; - current-speed = <115200>; -}; diff --git a/boards/phytium/ps2316_test/ps2316_test_ps2316_el2.dts b/boards/phytium/ps2316_test/ps2316_test_ps2316_el2.dts deleted file mode 100644 index a7a5c3ffec5..00000000000 --- a/boards/phytium/ps2316_test/ps2316_test_ps2316_el2.dts +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2023 honglin leng - * - * SPDX-License-Identifier: Apache-2.0 - */ - -/dts-v1/; - -#include -/ { - model = "Phytium ps2316 test"; - compatible = "phytium,ps2316-test", "phytium,ps2316"; - #address-cells = <2>; - #size-cells = <2>; - - psci { - compatible = "arm,psci-0.2"; - method = "smc"; - label = "PSCI"; - }; - -chosen { - zephyr,console = &uart1; - zephyr,shell-uart = &uart1; - zephyr,sram = &sram0; - }; -}; - -&uart1 { - status = "okay"; - current-speed = <115200>; -}; diff --git a/boards/phytium/ps2316_test/ps2316_test_ps2316_el2_smp.dts b/boards/phytium/ps2316_test/ps2316_test_ps2316_el2_smp.dts deleted file mode 100644 index a7a5c3ffec5..00000000000 --- a/boards/phytium/ps2316_test/ps2316_test_ps2316_el2_smp.dts +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2023 honglin leng - * - * SPDX-License-Identifier: Apache-2.0 - */ - -/dts-v1/; - -#include -/ { - model = "Phytium ps2316 test"; - compatible = "phytium,ps2316-test", "phytium,ps2316"; - #address-cells = <2>; - #size-cells = <2>; - - psci { - compatible = "arm,psci-0.2"; - method = "smc"; - label = "PSCI"; - }; - -chosen { - zephyr,console = &uart1; - zephyr,shell-uart = &uart1; - zephyr,sram = &sram0; - }; -}; - -&uart1 { - status = "okay"; - current-speed = <115200>; -}; diff --git a/boards/phytium/ps2316_test/ps2316_test_ps2316_smp.dts b/boards/phytium/ps2316_test/ps2316_test_ps2316_smp.dts deleted file mode 100644 index 2b8b8bccf47..00000000000 --- a/boards/phytium/ps2316_test/ps2316_test_ps2316_smp.dts +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2023 honglin leng - * - * SPDX-License-Identifier: Apache-2.0 - */ - -/dts-v1/; - -#include -/ { - model = "Phytium ps2316 test"; - compatible = "phytium,ps2316-test", "phytium,ps2316"; - #address-cells = <2>; - #size-cells = <2>; - - psci { - compatible = "arm,psci-0.2"; - method = "smc"; - }; - -chosen { - zephyr,console = &uart1; - zephyr,shell-uart = &uart1; - zephyr,sram = &sram0; - }; -}; - -&uart1 { - status = "okay"; - current-speed = <115200>; -}; diff --git a/dts/arm/phytium/pd2008_aarch32.dtsi b/dts/arm/phytium/pd2008_aarch32.dtsi deleted file mode 100644 index 2bd1ee0c8d8..00000000000 --- a/dts/arm/phytium/pd2008_aarch32.dtsi +++ /dev/null @@ -1,164 +0,0 @@ -// Phytium is pleased to support the open source community by making Zephyr-SDK available. - -// -// Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. -// -// Licensed under the Apache-2.0 License (the "License"); you may not use this file except -// in compliance with the License. You may obtain a copy of the License at -// -// https://opensource.org/license/apache-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 -#include -#include - -/ { - #address-cells = <2>; - #size-cells = <2>; - - cpus { - #address-cells = <2>; - #size-cells = <0>; - - cpu@0 { - device_type = "cpu"; - compatible = "phytium,ftc663"; - reg = <0 0x0>; - }; - - cpu@1 { - device_type = "cpu"; - compatible = "phytium,ftc663"; - reg = <0 0x1>; - }; - - cpu@2 { - device_type = "cpu"; - compatible = "phytium,ftc663"; - reg = <0 0x100>; - }; - - cpu@3 { - device_type = "cpu"; - compatible = "phytium,ftc663"; - reg = <0 0x101>; - }; - - cpu@4 { - device_type = "cpu"; - compatible = "phytium,ftc663"; - reg = <0 0x200>; - }; - - cpu@5 { - device_type = "cpu"; - compatible = "phytium,ftc663"; - reg = <0 0x201>; - }; - - cpu@6 { - device_type = "cpu"; - compatible = "phytium,ftc663"; - reg = <0 0x300>; - }; - - cpu@7 { - device_type = "cpu"; - compatible = "phytium,ftc663"; - reg = <0 0x301>; - }; - - }; - - timer { - compatible = "arm,armv8-timer"; - interrupt-parent = <&gic>; - // ppi =+ 16, 13 == 29 Security physical timer interrupt, 14 == 30 Non secure physical timer interrupt - interrupts = , - , - , - ; - }; - - uartclk: apb-pclk { - compatible = "fixed-clock"; - clock-frequency = <48000000>; - #clock-cells = <0>; - }; - - soc { - #address-cells = <2>; - #size-cells = <2>; - ranges; - - interrupt-parent = <&gic>; - - gic: interrupt-controller@29a00000 { - compatible = "arm,gic-v3", "arm,gic"; - reg = <0x00 0x29A00000 0x00 0x40000>, - <0x00 0x29B00000 0x00 0x100000>; - interrupt-controller; - #interrupt-cells = <4>; - status = "okay"; - #size-cells = <0x02>; - #address-cells = <0x02>; - }; - - uart1: uart@28001000 { - compatible = "arm,pl011"; - reg = <0x00 0x28001000 0x00 0x1000>; - status = "disabled"; - interrupts = ; - interrupt-names = "irq_0"; - clocks = <&uartclk>; - }; - - uart2: uart@28002000 { - compatible = "arm,pl011"; - reg = <0x00 0x28002000 0x00 0x1000>; - status = "disabled"; - interrupts = ; - interrupt-names = "irq_1"; - clocks = <&uartclk>; - }; - - gmac0: gmac@2820C000 { - compatible = "phytium,gmac"; - reg = <0x0 0x2820C000 0x0 0x4000>; - interrupts = ; - phy-poll-interval = <5000>; - phy-speed = <100>; - autonegotiation = <0>; - phy_duplex = <1>; - status = "disabled"; - }; - - pcie0: pcie@40000000 { - compatible = "pci-host-ecam-generic"; - device_type = "pci"; - reg = <0x00 0x40000000 0x00 0x10000000>; - #size-cells = <0x02>; - #address-cells = <0x03>; - ranges = <0x1000000 0x00 0x50000000 0x00 0x50000000 0x00 0x08000000 - 0x2000000 0x00 0x58000000 0x00 0x58000000 0x00 0x27ffffff - 0x3000000 0x10 0x00 0x10 0x00 0x1f 0xffffffff>; - bus-range = <0x00 0xff>; - }; - - /* 512MB DDR */ - sram0: memory@80100000 { - device_type = "memory"; - compatible = "mmio-sram"; - reg = <0x00 0x80100000 0x00 0x20000000>; - }; - }; -}; diff --git a/dts/arm64/phytium/pd2008.dtsi b/dts/arm64/phytium/pd2008.dtsi deleted file mode 100644 index 2bd1ee0c8d8..00000000000 --- a/dts/arm64/phytium/pd2008.dtsi +++ /dev/null @@ -1,164 +0,0 @@ -// Phytium is pleased to support the open source community by making Zephyr-SDK available. - -// -// Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. -// -// Licensed under the Apache-2.0 License (the "License"); you may not use this file except -// in compliance with the License. You may obtain a copy of the License at -// -// https://opensource.org/license/apache-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 -#include -#include - -/ { - #address-cells = <2>; - #size-cells = <2>; - - cpus { - #address-cells = <2>; - #size-cells = <0>; - - cpu@0 { - device_type = "cpu"; - compatible = "phytium,ftc663"; - reg = <0 0x0>; - }; - - cpu@1 { - device_type = "cpu"; - compatible = "phytium,ftc663"; - reg = <0 0x1>; - }; - - cpu@2 { - device_type = "cpu"; - compatible = "phytium,ftc663"; - reg = <0 0x100>; - }; - - cpu@3 { - device_type = "cpu"; - compatible = "phytium,ftc663"; - reg = <0 0x101>; - }; - - cpu@4 { - device_type = "cpu"; - compatible = "phytium,ftc663"; - reg = <0 0x200>; - }; - - cpu@5 { - device_type = "cpu"; - compatible = "phytium,ftc663"; - reg = <0 0x201>; - }; - - cpu@6 { - device_type = "cpu"; - compatible = "phytium,ftc663"; - reg = <0 0x300>; - }; - - cpu@7 { - device_type = "cpu"; - compatible = "phytium,ftc663"; - reg = <0 0x301>; - }; - - }; - - timer { - compatible = "arm,armv8-timer"; - interrupt-parent = <&gic>; - // ppi =+ 16, 13 == 29 Security physical timer interrupt, 14 == 30 Non secure physical timer interrupt - interrupts = , - , - , - ; - }; - - uartclk: apb-pclk { - compatible = "fixed-clock"; - clock-frequency = <48000000>; - #clock-cells = <0>; - }; - - soc { - #address-cells = <2>; - #size-cells = <2>; - ranges; - - interrupt-parent = <&gic>; - - gic: interrupt-controller@29a00000 { - compatible = "arm,gic-v3", "arm,gic"; - reg = <0x00 0x29A00000 0x00 0x40000>, - <0x00 0x29B00000 0x00 0x100000>; - interrupt-controller; - #interrupt-cells = <4>; - status = "okay"; - #size-cells = <0x02>; - #address-cells = <0x02>; - }; - - uart1: uart@28001000 { - compatible = "arm,pl011"; - reg = <0x00 0x28001000 0x00 0x1000>; - status = "disabled"; - interrupts = ; - interrupt-names = "irq_0"; - clocks = <&uartclk>; - }; - - uart2: uart@28002000 { - compatible = "arm,pl011"; - reg = <0x00 0x28002000 0x00 0x1000>; - status = "disabled"; - interrupts = ; - interrupt-names = "irq_1"; - clocks = <&uartclk>; - }; - - gmac0: gmac@2820C000 { - compatible = "phytium,gmac"; - reg = <0x0 0x2820C000 0x0 0x4000>; - interrupts = ; - phy-poll-interval = <5000>; - phy-speed = <100>; - autonegotiation = <0>; - phy_duplex = <1>; - status = "disabled"; - }; - - pcie0: pcie@40000000 { - compatible = "pci-host-ecam-generic"; - device_type = "pci"; - reg = <0x00 0x40000000 0x00 0x10000000>; - #size-cells = <0x02>; - #address-cells = <0x03>; - ranges = <0x1000000 0x00 0x50000000 0x00 0x50000000 0x00 0x08000000 - 0x2000000 0x00 0x58000000 0x00 0x58000000 0x00 0x27ffffff - 0x3000000 0x10 0x00 0x10 0x00 0x1f 0xffffffff>; - bus-range = <0x00 0xff>; - }; - - /* 512MB DDR */ - sram0: memory@80100000 { - device_type = "memory"; - compatible = "mmio-sram"; - reg = <0x00 0x80100000 0x00 0x20000000>; - }; - }; -}; diff --git a/dts/arm64/phytium/pd2308.dtsi b/dts/arm64/phytium/pd2308.dtsi deleted file mode 100644 index e99165e0fc5..00000000000 --- a/dts/arm64/phytium/pd2308.dtsi +++ /dev/null @@ -1,183 +0,0 @@ -// Phytium is pleased to support the open source community by making Zephyr-SDK available. - -// -// Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. -// -// Licensed under the Apache-2.0 License (the "License"); you may not use this file except -// in compliance with the License. You may obtain a copy of the License at -// -// https://opensource.org/license/apache-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 -#include -#include - -/ { - #address-cells = <2>; - #size-cells = <2>; - - cpus { - #address-cells = <2>; - #size-cells = <0>; - - cpu@0 { - device_type = "cpu"; - compatible = "phytium,ftc862"; - reg = <0 0x0>; - }; - - cpu@1 { - device_type = "cpu"; - compatible = "phytium,ftc862"; - reg = <0 0x100>; - }; - - cpu@2 { - device_type = "cpu"; - compatible = "phytium,ftc862"; - reg = <0 0x200>; - }; - - cpu@3 { - device_type = "cpu"; - compatible = "phytium,ftc862"; - reg = <0 0x300>; - }; - - cpu@4 { - device_type = "cpu"; - compatible = "phytium,ftc862"; - reg = <0 0x10000>; - }; - - cpu@5 { - device_type = "cpu"; - compatible = "phytium,ftc862"; - reg = <0 0x10100>; - }; - - cpu@6 { - device_type = "cpu"; - compatible = "phytium,ftc862"; - reg = <0 0x10200>; - }; - - cpu@7 { - device_type = "cpu"; - compatible = "phytium,ftc862"; - reg = <0 0x10300>; - }; - }; - - timer { - compatible = "arm,armv8-timer"; - interrupt-parent = <&gic>; - // ppi =+ 16, 13 == 29 Security physical timer interrupt, 14 == 30 Non secure physical timer interrupt - interrupts = , - , - , - ; - }; - - uartclk: apb-pclk { - compatible = "fixed-clock"; - clock-frequency = <100000000>; - #clock-cells = <0>; - }; - - soc { - #address-cells = <2>; - #size-cells = <2>; - ranges; - - interrupt-parent = <&gic>; - - gic: interrupt-controller@36800000 { - compatible = "arm,gic-v3", "arm,gic"; - reg = <0x00 0x36800000 0x00 0x40000>, - <0x00 0x36860000 0x00 0x200000>; - interrupt-controller; - #interrupt-cells = <4>; - status = "okay"; - #size-cells = <0x02>; - #address-cells = <0x02>; - }; - - pinctrl: pinctrl@36cea000 { - compatible = "phytium,pinctrl"; - reg = <0x00 0x36cea000 0x00 0x2000>; - status = "okay"; - }; - - uart1: uart@28009000 { - compatible = "arm,pl011"; - reg = <0x00 0x28009000 0x00 0x1000>; - status = "disabled"; - interrupts = ; - interrupt-names = "irq_0"; - clocks = <&uartclk>; - }; - - xmac0: xmac@36ce0000 { - compatible = "phytium,xmac"; - reg = <0x00 0x36ce0000 0x00 0x2000>; - status = "disabled"; - interrupts = ; - interrupt-names = "irq_0"; - phy-poll-interval = <1000>; - clock-frequency = <50000000>; - phy-speed = <1000>; - interface-mode = <0>; - dma-brust-length = <16>; - max-queue-num = <1>; - rx-buffer-descriptors = <128>; - tx-buffer-descriptors = <32>; - rx-buffer-size = <1600>; - tx-buffer-size = <1600>; - phy-autonegotiation; - enable-fdx; - disable-reject-fcs-crc-errors; - }; - - sdhc0: sdhc@28000000 { - compatible = "phytium,sdhc"; - reg = <0x00 0x28000000 0x00 0x1000>; - pio-base = <0x36CEA000>; - status = "disabled"; - interrupts = ; - max-current-330 = <1020>; - max-bus-freq = <25000000>; - min-bus-freq = <400000>; - }; - - /* 512MB DDR */ - sram0: memory@80100000 { - device_type = "memory"; - compatible = "mmio-sram"; - reg = <0x00 0x80100000 0x00 0x40000000>; - }; - - pcie0: pcie@40000000 { - compatible = "pci-host-ecam-generic"; - device_type = "pci"; - reg = <0x00 0x40000000 0x00 0x10000000>; - #size-cells = <0x02>; - #address-cells = <0x03>; - ranges = <0x1000000 0x00 0x50000000 0x00 0x50000000 0x00 0x08000000 - 0x2000000 0x00 0x58000000 0x00 0x58000000 0x00 0x27ffffff - 0x3000000 0x10 0x00 0x10 0x00 0x1f 0xffffffff>; - bus-range = <0x00 0xff>; - }; - - }; -}; diff --git a/dts/arm64/phytium/pd2408.dtsi b/dts/arm64/phytium/pd2408.dtsi deleted file mode 100644 index 372c5e8979d..00000000000 --- a/dts/arm64/phytium/pd2408.dtsi +++ /dev/null @@ -1,173 +0,0 @@ -// Phytium is pleased to support the open source community by making Zephyr-SDK available. - -// -// Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. -// -// Licensed under the Apache-2.0 License (the "License"); you may not use this file except -// in compliance with the License. You may obtain a copy of the License at -// -// https://opensource.org/license/apache-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 -#include -#include - -/ { - #address-cells = <2>; - #size-cells = <2>; - - cpus { - #address-cells = <2>; - #size-cells = <0>; - - cpu@0 { - device_type = "cpu"; - compatible = "phytium,ftc862"; - reg = <0 0x0>; - }; - - cpu@1 { - device_type = "cpu"; - compatible = "phytium,ftc862"; - reg = <0 0x100>; - }; - - cpu@2 { - device_type = "cpu"; - compatible = "phytium,ftc862"; - reg = <0 0x200>; - }; - - cpu@3 { - device_type = "cpu"; - compatible = "phytium,ftc862"; - reg = <0 0x300>; - }; - - cpu@4 { - device_type = "cpu"; - compatible = "phytium,ftc862"; - reg = <0 0x10000>; - }; - - cpu@5 { - device_type = "cpu"; - compatible = "phytium,ftc862"; - reg = <0 0x10100>; - }; - - cpu@6 { - device_type = "cpu"; - compatible = "phytium,ftc862"; - reg = <0 0x10200>; - }; - - cpu@7 { - device_type = "cpu"; - compatible = "phytium,ftc862"; - reg = <0 0x10300>; - }; - }; - - timer { - compatible = "arm,armv8-timer"; - interrupt-parent = <&gic>; - // ppi =+ 16, 13 == 29 Security physical timer interrupt, 14 == 30 Non secure physical timer interrupt - interrupts = , - , - , - ; - }; - - uartclk: apb-pclk { - compatible = "fixed-clock"; - clock-frequency = <100000000>; - #clock-cells = <0>; - }; - - soc { - #address-cells = <2>; - #size-cells = <2>; - ranges; - - interrupt-parent = <&gic>; - - gic: interrupt-controller@26800000 { - compatible = "arm,gic-v3", "arm,gic"; - reg = <0x00 0x26800000 0x00 0x40000>, - <0x00 0x26860000 0x00 0x200000>; - interrupt-controller; - #interrupt-cells = <4>; - status = "okay"; - #size-cells = <0x02>; - #address-cells = <0x02>; - }; - - pinctrl: pinctrl@26FD2000 { - compatible = "phytium,pinctrl"; - reg = <0x00 0x26FD2000 0x00 0x2000>; - status = "okay"; - }; - - uart1: uart@18002000 { - compatible = "arm,pl011"; - reg = <0x00 0x18002000 0x00 0x1000>; - status = "disabled"; - interrupts = ; - interrupt-names = "irq_0"; - clocks = <&uartclk>; - }; - - xmac_v2_0: xmac_v2@26fd0000 { - compatible = "phytium,xmac_v2"; - reg = <0x00 0x26fd0000 0x00 0x2000>; - mac-regs = <0x00 0x2701d000 0x00 0x2000>; - msg-regs = <0x00 0x26fef000 0x00 0x1000>; - status = "disabled"; - interrupts = ; - interrupt-names = "irq_0"; - phy-poll-interval = <5000>; - clock-frequency = <50000000>; - phy-speed = <1000>; - interface-mode = <0>; - dma-brust-length = <16>; - max-queue-num = <1>; - rx-buffer-descriptors = <128>; - tx-buffer-descriptors = <128>; - rx-buffer-size = <1600>; - tx-buffer-size = <1600>; - phy-autonegotiation; - enable-fdx; - disable-reject-fcs-crc-errors; - }; - - /* 512MB DDR */ - sram0: memory@80100000 { - device_type = "memory"; - compatible = "mmio-sram"; - reg = <0x00 0x80100000 0x00 0x40000000>; - }; - - pcie0: pcie@40000000 { - compatible = "pci-host-ecam-generic"; - device_type = "pci"; - reg = <0x00 0x40000000 0x00 0x10000000>; - #size-cells = <0x02>; - #address-cells = <0x03>; - ranges = <0x1000000 0x00 0x50000000 0x00 0x50000000 0x00 0x08000000 - 0x2000000 0x00 0x58000000 0x00 0x58000000 0x00 0x27ffffff - 0x3000000 0x10 0x00 0x10 0x00 0x1f 0xffffffff>; - bus-range = <0x00 0xff>; - }; - - }; -}; diff --git a/dts/arm64/phytium/ps2316.dtsi b/dts/arm64/phytium/ps2316.dtsi deleted file mode 100644 index 7df2c666ca8..00000000000 --- a/dts/arm64/phytium/ps2316.dtsi +++ /dev/null @@ -1,157 +0,0 @@ - -// Phytium is pleased to support the open source community by making Zephyr-SDK available. - -// -// Copyright (C) 2024 Phytium Technology Co., Ltd. All rights reserved. -// -// Licensed under the Apache-2.0 License (the "License"); you may not use this file except -// in compliance with the License. You may obtain a copy of the License at -// -// https://opensource.org/license/apache-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 -#include -#include - -/ { - #address-cells = <2>; - #size-cells = <2>; - - cpus { - #address-cells = <2>; - #size-cells = <0>; - - cpu@0 { - device_type = "cpu"; - compatible = "phytium,ftc862"; - reg = <0 0x0>; - }; - - cpu@1 { - device_type = "cpu"; - compatible = "phytium,ftc862"; - reg = <0 0x10000>; - }; - - cpu@2 { - device_type = "cpu"; - compatible = "phytium,ftc862"; - reg = <0 0x20000>; - }; - - cpu@3 { - device_type = "cpu"; - compatible = "phytium,ftc862"; - reg = <0 0x30000>; - }; - - cpu@4 { - device_type = "cpu"; - compatible = "phytium,ftc862"; - reg = <0 0x40000>; - }; - - cpu@5 { - device_type = "cpu"; - compatible = "phytium,ftc862"; - reg = <0 0x50000>; - }; - - cpu@6 { - device_type = "cpu"; - compatible = "phytium,ftc862"; - reg = <0 0x60000>; - }; - - cpu@7 { - device_type = "cpu"; - compatible = "phytium,ftc862"; - reg = <0 0x70000>; - }; - - cpu@8 { - device_type = "cpu"; - compatible = "phytium,ftc862"; - reg = <0 0x80000>; - }; - - cpu@9 { - device_type = "cpu"; - compatible = "phytium,ftc862"; - reg = <0 0x90000>; - }; - - cpu@10 { - device_type = "cpu"; - compatible = "phytium,ftc862"; - reg = <0 0xa0000>; - }; - - cpu@11 { - device_type = "cpu"; - compatible = "phytium,ftc862"; - reg = <0 0xb0000>; - }; - }; - - timer { - compatible = "arm,armv8-timer"; - interrupt-parent = <&gic>; - // ppi =+ 16, 13 == 29 Security physical timer interrupt, 14 == 30 Non secure physical timer interrupt - interrupts = , - , - , - ; - }; - - uartclk: apb-pclk { - compatible = "fixed-clock"; - clock-frequency = <50000000>; - #clock-cells = <0>; - }; - - soc { - #address-cells = <2>; - #size-cells = <2>; - ranges; - - interrupt-parent = <&gic>; - - gic: interrupt-controller@22000000 { - compatible = "arm,gic-v3", "arm,gic"; - reg = <0x00 0x22000000 0x00 0x40000>, - <0x00 0x220c0000 0x00 0x200000>; - interrupt-controller; - #interrupt-cells = <4>; - status = "okay"; - #size-cells = <0x02>; - #address-cells = <0x02>; - }; - - uart1: uart@0x20001000 { - compatible = "arm,pl011"; - reg = <0x00 0x20001000 0x00 0x1000>; - status = "disabled"; - interrupts = ; - interrupt-names = "irq_0"; - clocks = <&uartclk>; - }; - - /* 512MB DDR */ - sram0: memory@80100000 { - device_type = "memory"; - compatible = "mmio-sram"; - reg = <0x00 0x80100000 0x00 0x20000000>; - }; - - }; -}; -- Gitee