mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: Du Huanpeng <u74147@gmail.com>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH] MIPS: DEBUG_LL_UART_DIVISOR is 0, use a0 instead
Date: Thu, 17 Sep 2020 19:42:30 +0200	[thread overview]
Message-ID: <7101cee8-bdf4-4869-daf2-e9f2aac72e4e@pengutronix.de> (raw)
In-Reply-To: <20200917135606.GA12263@beer>

Hello,

On 9/17/20 3:56 PM, Du Huanpeng wrote:
> Hi, this patch should not intoduce any regression to existing boards,
> because: 
> 
>  1. pass divisor by DEBUG_LL_UART_DIVISOR
> 
> #define DEBUG_LL_UART_DIVISOR NUMBER
> 
> which the ``NUMBER'' is not ``0'' (zero). In this case, this patch
> has no effect and this line of code will be removed by preprocessor,
> before compile :)
>         move    t1, a0
> 
>  2. Pass divisor by a0
> 
> #define DEBUG_LL_UART_DIVISOR 0
> 
> recalculate the divisor is needed when the pll/div setting is changed
> outside of barebox. e.g. ejtag. and load barebox and run in ram.
> 
> Because 0 maybe an invalid value for a divisor, so I take this value for
> a hint to pass a0 as divisor. this will not conflict with other boards
> which pass divisor by defining DEBUG_LL_UART_DIVISOR with a valied value.

I guess we can agree that

  debug_ll_ns16550_init(
#if DEBUG_LL_UART_DIVISOR
  int a0
#endif
  );

is not the best way to go about it, so why do its equivalent in assembly?
 
>> you should migrate all users of this function all at once to supply a valid divisor
>> (probably `move a0, DEBUG_LL_UART_DIVISOR`).
> 
> MIPS use ``li'' load immediate, and move to copy inter registers.
> so, maybe change my patch to:
> 
> #if DEBUG_LL_UART_DIVISOR
> 	li	t1, DEBUG_LL_UART_DIVISOR
> #else
> 	move	t1, a0
> #endif

I'd prefer you keep it as move t1, a0 without an ifdef and move the argument
passing out of debug_ll_ns16550_init.

Cheers
Ahmad

> 
> - - - 
> or even do a bit tricky:
> 
> --- a/arch/mips/include/asm/debug_ll_ns16550.h
> +++ b/arch/mips/include/asm/debug_ll_ns16550.h
> @@ -65,7 +65,7 @@ static inline void PUTC_LL(char ch)
>  	li	t1, UART_LCR_DLAB		/* DLAB on */
>  	sb	t1, UART_LCR(t0)		/* Write it out */
>  
> -	li	t1, DEBUG_LL_UART_DIVISOR
> +	add	t1, zero, DEBUG_LL_UART_DIVISOR
>  	sb	t1, UART_DLL(t0)		/* write low order byte */
>  	srl	t1, t1, 8
>  	sb	t1, UART_DLM(t0)		/* write high order byte */
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2020-09-17 17:42 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-11 12:33 [PATCH] MIPS: loongson1: enable to run from spi flash Du Huanpeng
2020-09-11 12:33 ` [PATCH] MIPS: DEBUG_LL_UART_DIVISOR is 0, use a0 instead Du Huanpeng
2020-09-11 14:07   ` Ahmad Fatoum
2020-09-17 13:56     ` Du Huanpeng
2020-09-17 17:42       ` Ahmad Fatoum [this message]
2020-09-25 16:42         ` Du Huanpeng
2020-09-25 17:54           ` Ahmad Fatoum

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7101cee8-bdf4-4869-daf2-e9f2aac72e4e@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=u74147@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox