forked from HorizonRDK/uboot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
qos: task [XJ3-3475] add feature to set qos in uboot
Summary: In order to prevent conflicts with spl, this feature is disabled by default. After enable the marcro SET_QOS_IN_UBOOT in include/hb_info.h, this feature will be enabled WRITE_QOS_VALUE and READ_QOS_VALUE represent the read and write qos value respectively Test Plan: NA Reviewers: zutao.min, yunqian.wang Reviewed By: yunqian.wang Subscribers: ming.yu Differential Revision: https://cr.hobot.cc/D98850
- Loading branch information
ming.yu
authored and
Xiaofeng Ling
committed
Aug 4, 2021
1 parent
49dadde
commit e590005
Showing
11 changed files
with
260 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,7 @@ | |
*.su | ||
*.swp | ||
*.tab.[ch] | ||
|
||
board/hobot/xj3/qos_hex.h | ||
# Build tree | ||
/build-* | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
|
||
MEMORY { .sram : ORIGIN = 0x8000a000, | ||
LENGTH = 0xc00 } | ||
|
||
OUTPUT_FORMAT("elf64-littleaarch64", "elf64-littleaarch64", "elf64-littleaarch64") | ||
OUTPUT_ARCH(aarch64) | ||
ENTRY(setup_c_runtime) | ||
SECTIONS | ||
{ | ||
.text : { | ||
. = ALIGN(8); | ||
*(.__image_copy_start) | ||
setup.o (.text*) | ||
*(.text*) | ||
KEEP(*(SORT(.text*))); | ||
} >.sram | ||
|
||
.rodata : { | ||
. = ALIGN(8); | ||
*(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) | ||
} >.sram | ||
|
||
.data : { | ||
. = ALIGN(8); | ||
*(.data*) | ||
KEEP(*(SORT(.data*))); | ||
} >.sram | ||
|
||
.image_copy_end : { | ||
. = ALIGN(8); | ||
*(.__image_copy_end) | ||
} >.sram | ||
|
||
.end : { | ||
. = ALIGN(8); | ||
*(.__end) | ||
} >.sram | ||
|
||
_image_binary_end = .; | ||
|
||
.bss_start (NOLOAD) : { | ||
. = ALIGN(8); | ||
KEEP(*(.__bss_start)); | ||
} >.sram | ||
|
||
.bss (NOLOAD) : { | ||
*(.bss*) | ||
. = ALIGN(8); | ||
} >.sram | ||
|
||
.bss_end (NOLOAD) : { | ||
KEEP(*(.__bss_end)); | ||
} >.sram | ||
|
||
/DISCARD/ : { *(.dynsym) } | ||
/DISCARD/ : { *(.dynstr*) } | ||
/DISCARD/ : { *(.dynamic*) } | ||
/DISCARD/ : { *(.plt*) } | ||
/DISCARD/ : { *(.interp*) } | ||
/DISCARD/ : { *(.gnu*) } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* Copyright 2021 Horizon Robotics, Inc. | ||
*/ | ||
#define ISB asm volatile ("isb sy" : : : "memory") | ||
#define DSB asm volatile ("dsb sy" : : : "memory") | ||
#define DMB asm volatile ("dmb sy" : : : "memory") | ||
#define isb() ISB | ||
#define dsb() DSB | ||
#define dmb() DMB | ||
/* | ||
* Generic virtual read/write. Note that we don't support half-word | ||
* read/writes. We define __arch_*[bl] here, and leave __arch_*w | ||
* to the architecture specific code. | ||
*/ | ||
#define __arch_getl(a) (*(volatile unsigned int *)(a)) | ||
#define __arch_putl(v, a) (*(volatile unsigned int *)(a) = (v)) | ||
/* | ||
* TODO: The kernel offers some more advanced versions of barriers, it might | ||
* have some advantages to use them instead of the simple one here. | ||
*/ | ||
#define mb() dsb() | ||
#define __iormb() dmb() | ||
#define __iowmb() dmb() | ||
|
||
#define writel(v, c) ({ unsigned int __v = v; __iowmb(); __arch_putl(__v, c); __v; }) | ||
#define readl(c) ({ unsigned int __v = __arch_getl(c); __iormb(); __v; }) | ||
|
||
static void set_ddrc_qos(unsigned int write_qos, unsigned int read_qos) | ||
{ | ||
#define REG_DDR_PORT_READ_QOS_CTRL 0xA2D10000 | ||
#define REG_DDR_PORT_WRITE_QOS_CTRL 0xA2D10004 | ||
// [0]: ACE | ||
// [1]: NOC | ||
// [2]: CNN0 | ||
// [3]: CNN1 | ||
// [4]: VIO0 | ||
// [5]: VSP | ||
// [6]: VIO1 | ||
// [7]: peri | ||
|
||
writel(read_qos, REG_DDR_PORT_READ_QOS_CTRL); | ||
writel(write_qos, REG_DDR_PORT_WRITE_QOS_CTRL); | ||
} | ||
|
||
void do_update_qos(unsigned int write_qos, unsigned int read_qos) | ||
{ | ||
unsigned int port_num = 0; | ||
unsigned long reg_addr = 0; | ||
|
||
//a. diable axi port n | ||
for(port_num = 0; port_num < 8; port_num++) { | ||
reg_addr = 0xA2D00490 + 0xB0 * port_num; | ||
writel(0, reg_addr); | ||
} | ||
|
||
//b. polling axi port n is in idle state | ||
do { | ||
}while(0x0 != (readl(0xA2D003FC))); | ||
|
||
//c. Set QoS | ||
set_ddrc_qos(write_qos, read_qos); | ||
|
||
//d. enable axi port n | ||
for(port_num = 0; port_num < 8; port_num++) { | ||
reg_addr = 0xA2D00490 + 0xB0 * port_num; | ||
writel(1, reg_addr); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
//#include <asm-offsets.h> | ||
#include <asm/macro.h> | ||
#include <linux/linkage.h> | ||
ENTRY(setup_c_runtime) | ||
stp x29, x30, [sp,#-96]! | ||
stp x27, x28, [sp,#80] | ||
stp x25, x26, [sp,#64] | ||
stp x23, x24, [sp,#48] | ||
stp x21, x22, [sp,#32] | ||
stp x19, x20, [sp,#16] | ||
|
||
mov x25, sp | ||
|
||
mov x20, #0xb000 | ||
movk x20, #0x8000,LSL #16 | ||
mov sp, x20 | ||
stp x25, x0, [sp, #-16]! | ||
|
||
bl do_update_qos | ||
|
||
ldp x25, x0, [sp],#16 | ||
mov sp, x25 | ||
ldp x19, x20, [sp,#16] | ||
ldp x21, x22, [sp,#32] | ||
ldp x23, x24, [sp,#48] | ||
ldp x25, x26, [sp,#64] | ||
ldp x27, x28, [sp,#80] | ||
ldp x29, x30, [sp],#96 | ||
mov w0, #0x0 // #0 | ||
ret | ||
ENDPROC(setup_c_runtime) | ||
|
||
ENTRY(_asm_invalidate_icache_all) | ||
ic ialluis | ||
isb sy | ||
ret | ||
ENDPROC(_asm_invalidate_icache_all) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
|
||
src := $(obj) | ||
|
||
# Create output directory if not already present | ||
_dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj)) | ||
|
||
QOS_BIN := qos | ||
|
||
include $(srctree)/scripts/Kbuild.include | ||
#-include include/config/auto.conf | ||
#-include $(obj)/include/autoconf.mk | ||
|
||
#include $(srctree)/config.mk | ||
#include $(srctree)/arch/$(ARCH)/Makefile | ||
#include $(srctree)/scripts/Makefile.lib | ||
|
||
KBUILD_CFLAGS += -ffunction-sections -fdata-sections | ||
LDFLAGS_FINAL += --gc-sections | ||
|
||
cpp_flags := -D__KERNEL__ -D__UBOOT__ -D__ASSEMBLY__ -fno-PIE -g -D__ARM__ -fno-pic -mstrict-align -ffunction-sections -fdata-sections -fno-common -ffixed-x18 -pipe -march=armv8-a -D__LINUX_ARM_ARCH__=8 | ||
c_flags := $(KBUILD_CFLAGS) $(cpp_flags) \ | ||
-I $(srctree)/include/ \ | ||
-I $(srctree)/arch/arm/include/ | ||
|
||
LDSCRIPT := $(srctree)/$(obj)/qos.lds | ||
|
||
head-y := $(addprefix $(obj)/,$(head-y)) | ||
qos-init := $(head-y) | ||
|
||
ALL-y += $(obj)/$(QOS_BIN).bin | ||
|
||
quiet_cmd_ddr_qos = SET_QOS $@ | ||
cmd_ddr_qos = $(CC) $(c_flags) -c $< -o $@ | ||
|
||
$(obj)/set_qos.o: $(obj)/set_qos.c | ||
$(CC) $(c_flags) -c $< -o $@ | ||
|
||
$(obj)/setup.o: $(obj)/setup.S | ||
$(CC) $(c_flags) -c $< -o $@ | ||
|
||
qos-main += $(obj)/set_qos.o | ||
qos-main += $(obj)/setup.o | ||
|
||
OBJCOPYFLAGS_$(QOS_BIN) = -O binary | ||
qos_objcopy := (cd $(obj) && $(OBJCOPY) $(OBJCOPYFLAGS_$(QOS_BIN)) qos qos.bin) | ||
|
||
LDFLAGS_$(QOS_BIN) += -T $(srctree)/$(obj)/qos.lds $(LDFLAGS_FINAL) | ||
|
||
qos := (cd $(obj) && $(LD) $(LDFLAGS) $(LDFLAGS_$(QOS_BIN)) \ | ||
$(patsubst $(obj)/%,%,$(qos-main)) \ | ||
-Map $(QOS_BIN).map -o $(QOS_BIN)) | ||
$(info "src tree:$(srctree), obj:$(obj)") | ||
$(obj)/$(QOS_BIN): $(qos-main) $(srctree)/$(obj)/qos.lds | ||
$(qos) | ||
|
||
$(obj)/$(QOS_BIN).bin : $(obj)/$(QOS_BIN) | ||
$(qos_objcopy) | ||
|
||
all: $(ALL-y) |
Binary file not shown.