Skip to content

Commit 0b78766

Browse files
committed
arc: timer: fix divu instruction bug
in some configure of ARC processor, there is no divu instruction, so it need to be removed. Signed-off-by: Watson Zeng <zhiwei@synopsys.com>
1 parent f815037 commit 0b78766

File tree

1 file changed

+15
-18
lines changed

1 file changed

+15
-18
lines changed

arc/arc_timer.c

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -358,24 +358,21 @@ void secure_timer_init(void)
358358
*/
359359
void arc_delay_us(uint32_t usecs)
360360
{
361-
__asm__ __volatile__(
362-
363-
" .extern gl_loops_per_jiffy \n"
364-
" .extern gl_count \n"
365-
" cmp %0, 0 \n"
366-
" jeq 1f \n"
367-
" ld %%r1, [gl_loops_per_jiffy] \n"
368-
" mpy %%r1, %%r1, %0 \n"
369-
" ld %%r2, [gl_count] \n"
370-
" divu %%r1, %%r1, %%r2 \n"
371-
" .align 4 \n"
372-
" mov %%lp_count, %%r1 \n"
373-
" lp 1f \n"
374-
" nop \n"
375-
"1: \n"
376-
:
377-
: "r"(usecs)
378-
: "lp_count", "r1", "r2");
361+
if (usecs == 0) {
362+
return;
363+
}
364+
365+
usecs = usecs * gl_loops_per_jiffy / gl_count;
366+
367+
__asm__ __volatile__ (
368+
" .align 4 \n"
369+
" mov %%lp_count, %0 \n"
370+
" lp 1f \n"
371+
" nop \n"
372+
"1: \n"
373+
:
374+
: "r" (usecs)
375+
: "lp_count");
379376
}
380377

381378
/**

0 commit comments

Comments
 (0)