最近在做一个平台优化系统启动时间的任务,然后根据硬件BLOCK图以及端子配置表,选了一个测试端子,GPIO10,来量测系统时间,uboot 中加了如下代码作为uboot 启动时间点开始代码如下,uboot 启动开始点在start.s中,实现代码 如下:
— a/arch/arm/cpu/armv7/start.S
+++ b/arch/arm/cpu/armv7/start.S
@@ -127,7 +127,7 @@ switch_to_hypervisor_ret:
b _do_nonsec_entry
3: @ No STR boot
#endif
-
- bl _gpio_test
bl _main
— a/common/board_f.c
+++ b/common/board_f.c
@@ -1073,8 +1073,16 @@ static const init_fnc_t init_sequence_f[] = {
NULL,
};
+#define STA_GPIO0_BASE_TEST 0x48120000
+
+void _gpio_test()
+{
- writel((1 << 10), STA_GPIO0_BASE_TEST + 0x14);//set GPIO_DIRS
- writel((1 << 10), STA_GPIO0_BASE_TEST + 0x04);//set GPIO_DATAS
+}
void board_init_f(ulong boot_flags)
{ - /GPIO_TEST();/
#ifdef CONFIG_SYS_GENERIC_GLOBAL_DATA
kernel 中本来打算等GPIO 初始化完了,在init 进程开始前拉一段GPIO,但是考虑到kernel 初始化部分可能也需要占时间,于是在head.s 中加入了一段汇编代码,本来对汇编不熟悉,现学些了下,结果对照datasheet GPIO 的配置,最后设置成功了以此记录下问题,汇编代码如下:
diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S
index fc6d541549a2…9a81ecc0ff80 100644
— a/arch/arm/boot/compressed/head.S
+++ b/arch/arm/boot/compressed/head.S
@@ -543,6 +543,17 @@ not_relocated: mov r0, #0
mov r1, sp @ malloc space above stack
add r2, sp, #0x10000 @ 64k max
mov r3, r7
+
-
ldr r11, =0x48120014 //配置DIR地址
-
ldr r12,[r11] //读DIR值
-
orr r12,r12,#0x00000400 //读取值或0x400
-
str r12, [r11] //设置值写会DIR
-
ldr r11, =0x48120008 //DAT设置同上面
-
ldr r12,[r11]
-
orr r12,r12,#0x00000400
-
str r12, [r11]
-
bl decompress_kernel bl cache_clean_flush bl cache_off