Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

board: add support for k230_canmv_01studio #2

Merged
merged 4 commits into from
Nov 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
fail-fast: false
matrix:
name: [gcc-13]
board: [canmv, evb]
board: [canmv, evb, canmv_01studio]

runs-on: ubuntu-22.04

Expand Down
4 changes: 4 additions & 0 deletions arch/riscv/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ config TARGET_K230_EVB
config TARGET_K230_CANMV
bool "Support k230_CANMV(K230PI)"

config TARGET_K230_CANMV_01STUDIO
bool "Support k230_CANMV 01studio"

config TARGET_K230D_CANMV
bool "Support k230D_CANMV(K230PI zero)"

Expand Down Expand Up @@ -86,6 +89,7 @@ source "board/sipeed/maix/Kconfig"
source "board/canaan/k230_fpga/Kconfig"
source "board/canaan/k230_evb/Kconfig"
source "board/canaan/k230_canmv/Kconfig"
source "board/canaan/k230_canmv_01studio/Kconfig"
source "board/canaan/k230d_canmv/Kconfig"
source "board/canaan/k230_unsiplp4/Kconfig"
source "board/canaan/k230_siplp4/Kconfig"
Expand Down
6 changes: 1 addition & 5 deletions arch/riscv/cpu/k230/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ static inline void improving_cpu_performance(void)
csr_write(CSR_MCOR, 0x70013);
csr_write(CSR_MCCR2, 0xe0000009);
csr_write(CSR_MHCR, 0x11ff); //Enable L1 Cache
csr_write(CSR_MXSTATUS, 0x638000);
csr_write(CSR_MXSTATUS, 0x438000);
csr_write(CSR_MHINT, 0x6e30c);

csr_write(CSR_SMPEN, 0x1);
Expand Down Expand Up @@ -79,10 +79,6 @@ void harts_early_init(void)

writel(0x80199805, (void*)0x91100004);

csr_write(pmpaddr0, 0x24484dff);//start addr:0x24484c00<<2=0x91213000 len=1<<9 * 8 = 4KB
csr_write(pmpaddr1, 0x244851ff);//start addr:0x24485000<<2=0x91214000 len=1<<9 * 8 = 4KB
csr_write(pmpcfg0, 0x9999);

//improving_cpu_performance();
}
u32 spl_boot_device(void)
Expand Down
2 changes: 2 additions & 0 deletions arch/riscv/cpu/k230/dram.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ __weak int ddr_init_training(void)
sip_ddr_init_3200_have_all_odt();
#elif defined(CONFIG_CANMV_LPDDR3_2133)
pi_ddr_init_2133();
#elif defined(CONFIG_CANMV_01STUDIO_LPDDR4_2667)
ddr_init_2667();
#elif defined(CONFIG_SIPLP4_1600)
sip_ddr_init_1600();
#elif defined(CONFIG_SIPLP4_2667)
Expand Down
26 changes: 26 additions & 0 deletions board/canaan/k230_canmv_01studio/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
if TARGET_K230_CANMV_01STUDIO

config SYS_CPU
default "k230"

config SYS_VENDOR
default "canaan"

config SYS_BOARD
default "k230_canmv_01studio"

config SYS_CONFIG_NAME
default "k230_evb"


config BOARD_SPECIFIC_OPTIONS # dummy
def_bool y
select RISCV_THEAD
choice
prompt "ddr typy freq"
default CANMV_01STUDIO_LPDDR4_2667

config CANMV_01STUDIO_LPDDR4_2667
bool "canmv 01studio ddr4 2667"
endchoice
endif
45 changes: 45 additions & 0 deletions board/canaan/k230_canmv_01studio/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# /* Copyright (c) 2023, Canaan Bright Sight Co., Ltd
# *
# * Redistribution and use in source and binary forms, with or without
# * modification, are permitted provided that the following conditions are met:
# * 1. Redistributions of source code must retain the above copyright
# * notice, this list of conditions and the following disclaimer.
# * 2. Redistributions in binary form must reproduce the above copyright
# * notice, this list of conditions and the following disclaimer in the
# * documentation and/or other materials provided with the distribution.
# *
# * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
# * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
# * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# */

obj-y += board.o

obj-$(CONFIG_CANMV_01STUDIO_LPDDR4_2667) += gen_canmv_01studio_lpddr4_2667.o

$(obj)/gen_canmv_01studio_lpddr4_2667.c: $(src)/lpddr4_init_32_swap_2667.c $(srctree)/arch/riscv/cpu/k230/ddr.sh
($(srctree)/arch/riscv/cpu/k230/ddr.sh $< $@ 0x50000 0x53fff 0x54000 0x5433d || exit 1)

EXTRA_CFLAGS += -I$(srctree)/arch/$(ARCH)/cpu/k230/
EXTRA_CFLAGS += -I$(srctree)/arch/$(ARCH)/cpu/k230/puf_fw/pufs_common
EXTRA_CFLAGS += -I$(srctree)/arch/$(ARCH)/cpu/k230/puf_fw/pufs_crypto
EXTRA_CFLAGS += -I$(srctree)/arch/$(ARCH)/cpu/k230/puf_fw/pufs_dma
EXTRA_CFLAGS += -I$(srctree)/arch/$(ARCH)/cpu/k230/puf_fw/pufs_ka
EXTRA_CFLAGS += -I$(srctree)/arch/$(ARCH)/cpu/k230/puf_fw/pufs_rt
EXTRA_CFLAGS += -I$(srctree)/arch/$(ARCH)/cpu/k230/puf_fw/pufs_ecc
EXTRA_CFLAGS += -I$(srctree)/arch/$(ARCH)/cpu/k230/puf_fw/pufs_hmac
EXTRA_CFLAGS += -I$(srctree)/arch/$(ARCH)/cpu/k230/puf_fw/pufs_ecp
EXTRA_CFLAGS += -I$(srctree)/arch/$(ARCH)/cpu/k230/puf_fw/pufs_sm2
EXTRA_CFLAGS += -I$(srctree)/arch/$(ARCH)/cpu/k230/puf_fw/pufs_sp38a
EXTRA_CFLAGS += -I$(srctree)/arch/$(ARCH)/cpu/k230/puf_fw/pufs_sp38d

36 changes: 36 additions & 0 deletions board/canaan/k230_canmv_01studio/board.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include <asm/asm.h>
#include <asm/io.h>
#include <asm/types.h>
#include <lmb.h>
#include <cpu_func.h>
#include <stdio.h>
#include <common.h>
#include <command.h>
#include <image.h>
#include <gzip.h>
#include <asm/spl.h>
#include "sysctl.h"

#include <pufs_hmac.h>
#include <pufs_ecp.h>
#include <pufs_rt.h>
#include "pufs_sm2.h"
#include <pufs_sp38a.h>
#include <pufs_sp38d.h>
#include <linux/kernel.h>
// #include "sdk_autoconf.h"
// #include "k230_board_common.h"
#include <env_internal.h>
#include <linux/delay.h>

sysctl_boot_mode_e sysctl_boot_get_boot_mode(void)
{
return SYSCTL_BOOT_SDIO0;
}

#ifdef CONFIG_BOARD_LATE_INIT
int board_late_init(void)
{
return 0;
}
#endif
Loading
Loading