diff mbox

[U-Boot,v6,07/10] ns16550: map register base address for debug UART

Message ID BLU436-SMTP72755FE6888C48E213482AFFF20@phx.gbl
State Superseded
Delegated to: Daniel Schwierzeck
Headers show

Commit Message

Wills Wang Jan. 4, 2016, 11:14 a.m. UTC
MIPS need to use KSEG1 address for register operation, this patch
add map_physmem to convert CONFIG_DEBUG_UART_BASE for debug UART.

Signed-off-by: Wills Wang <wills.wang@live.com>
---

Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 drivers/serial/ns16550.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Thomas Chou Jan. 4, 2016, 1:07 p.m. UTC | #1
Hi Wills,

On 2016年01月04日 19:14, Wills Wang wrote:
> MIPS need to use KSEG1 address for register operation, this patch
> add map_physmem to convert CONFIG_DEBUG_UART_BASE for debug UART.
>
> Signed-off-by: Wills Wang <wills.wang@live.com>
> ---
>
> Changes in v6: None
> Changes in v5: None
> Changes in v4: None
> Changes in v3: None
> Changes in v2: None
>
>   drivers/serial/ns16550.c | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/serial/ns16550.c b/drivers/serial/ns16550.c
> index 3b24af0..1e2538e 100644
> --- a/drivers/serial/ns16550.c
> +++ b/drivers/serial/ns16550.c
> @@ -270,7 +270,8 @@ int NS16550_tstc(NS16550_t com_port)
>
>   static inline void _debug_uart_init(void)
>   {
> -	struct NS16550 *com_port = (struct NS16550 *)CONFIG_DEBUG_UART_BASE;
> +	struct NS16550 *com_port = (struct NS16550 *)map_physmem(
> +				CONFIG_DEBUG_UART_BASE, 0, MAP_NOCACHE);
>   	int baud_divisor;
>
>   	/*
> @@ -293,7 +294,8 @@ static inline void _debug_uart_init(void)
>
>   static inline void _debug_uart_putc(int ch)
>   {
> -	struct NS16550 *com_port = (struct NS16550 *)CONFIG_DEBUG_UART_BASE;
> +	struct NS16550 *com_port = (struct NS16550 *)map_physmem(
> +				CONFIG_DEBUG_UART_BASE, 0, MAP_NOCACHE);
>
>   	while (!(serial_din(&com_port->lsr) & UART_LSR_THRE))
>   		;
>

As debug uart may be used in very early stage and SPL, I would suggest 
the CONFIG_DEBUG_UART_BASE here is mapped to uncached space already. So 
that we can keep the code and stack usage minimal.

My concern is that the uncache mapping in nios2 arch is different 
between NOMMU and MMU core, which will be decoded from device tree. So 
it won't work for nios2 until DM initialized.

Naked-by: Thomas Chou <thomas@wytron.com.tw>

Best regards,
Thomas
Wills Wang Jan. 4, 2016, 2:10 p.m. UTC | #2
On 01/04/2016 09:07 PM, Thomas Chou wrote:
> Hi Wills,
>
> On 2016年01月04日 19:14, Wills Wang wrote:
>> MIPS need to use KSEG1 address for register operation, this patch
>> add map_physmem to convert CONFIG_DEBUG_UART_BASE for debug UART.
>>
>> Signed-off-by: Wills Wang <wills.wang@live.com>
>> ---
>>
>> Changes in v6: None
>> Changes in v5: None
>> Changes in v4: None
>> Changes in v3: None
>> Changes in v2: None
>>
>>   drivers/serial/ns16550.c | 6 ++++--
>>   1 file changed, 4 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/serial/ns16550.c b/drivers/serial/ns16550.c
>> index 3b24af0..1e2538e 100644
>> --- a/drivers/serial/ns16550.c
>> +++ b/drivers/serial/ns16550.c
>> @@ -270,7 +270,8 @@ int NS16550_tstc(NS16550_t com_port)
>>
>>   static inline void _debug_uart_init(void)
>>   {
>> -    struct NS16550 *com_port = (struct NS16550 
>> *)CONFIG_DEBUG_UART_BASE;
>> +    struct NS16550 *com_port = (struct NS16550 *)map_physmem(
>> +                CONFIG_DEBUG_UART_BASE, 0, MAP_NOCACHE);
>>       int baud_divisor;
>>
>>       /*
>> @@ -293,7 +294,8 @@ static inline void _debug_uart_init(void)
>>
>>   static inline void _debug_uart_putc(int ch)
>>   {
>> -    struct NS16550 *com_port = (struct NS16550 
>> *)CONFIG_DEBUG_UART_BASE;
>> +    struct NS16550 *com_port = (struct NS16550 *)map_physmem(
>> +                CONFIG_DEBUG_UART_BASE, 0, MAP_NOCACHE);
>>
>>       while (!(serial_din(&com_port->lsr) & UART_LSR_THRE))
>>           ;
>>
>
> As debug uart may be used in very early stage and SPL, I would suggest 
> the CONFIG_DEBUG_UART_BASE here is mapped to uncached space already. 
> So that we can keep the code and stack usage minimal.
>
> My concern is that the uncache mapping in nios2 arch is different 
> between NOMMU and MMU core, which will be decoded from device tree. So 
> it won't work for nios2 until DM initialized.
>
Ok, i see. CONFIG_DEBUG_UART_BASE is different from the address from 
device tree if not map.
> Naked-by: Thomas Chou <thomas@wytron.com.tw>
>
> Best regards,
> Thomas
Daniel Schwierzeck Jan. 5, 2016, 9:18 p.m. UTC | #3
2016-01-04 14:07 GMT+01:00 Thomas Chou <thomas@wytron.com.tw>:
> Hi Wills,
>
>
> On 2016年01月04日 19:14, Wills Wang wrote:
>>
>> MIPS need to use KSEG1 address for register operation, this patch
>> add map_physmem to convert CONFIG_DEBUG_UART_BASE for debug UART.
>>
>> Signed-off-by: Wills Wang <wills.wang@live.com>
>> ---
>>
>> Changes in v6: None
>> Changes in v5: None
>> Changes in v4: None
>> Changes in v3: None
>> Changes in v2: None
>>
>>   drivers/serial/ns16550.c | 6 ++++--
>>   1 file changed, 4 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/serial/ns16550.c b/drivers/serial/ns16550.c
>> index 3b24af0..1e2538e 100644
>> --- a/drivers/serial/ns16550.c
>> +++ b/drivers/serial/ns16550.c
>> @@ -270,7 +270,8 @@ int NS16550_tstc(NS16550_t com_port)
>>
>>   static inline void _debug_uart_init(void)
>>   {
>> -       struct NS16550 *com_port = (struct NS16550
>> *)CONFIG_DEBUG_UART_BASE;
>> +       struct NS16550 *com_port = (struct NS16550 *)map_physmem(
>> +                               CONFIG_DEBUG_UART_BASE, 0, MAP_NOCACHE);
>>         int baud_divisor;
>>
>>         /*
>> @@ -293,7 +294,8 @@ static inline void _debug_uart_init(void)
>>
>>   static inline void _debug_uart_putc(int ch)
>>   {
>> -       struct NS16550 *com_port = (struct NS16550
>> *)CONFIG_DEBUG_UART_BASE;
>> +       struct NS16550 *com_port = (struct NS16550 *)map_physmem(
>> +                               CONFIG_DEBUG_UART_BASE, 0, MAP_NOCACHE);
>>
>>         while (!(serial_din(&com_port->lsr) & UART_LSR_THRE))
>>                 ;
>>
>
> As debug uart may be used in very early stage and SPL, I would suggest the
> CONFIG_DEBUG_UART_BASE here is mapped to uncached space already. So that we
> can keep the code and stack usage minimal.
>
> My concern is that the uncache mapping in nios2 arch is different between
> NOMMU and MMU core, which will be decoded from device tree. So it won't work
> for nios2 until DM initialized.
>
> Naked-by: Thomas Chou <thomas@wytron.com.tw>
>

I agree with Thomas. Please set CONFIG_DEBUG_UART_BASE to a KSEG1
address and discard this patch.
Wills Wang Jan. 6, 2016, 2:50 a.m. UTC | #4
On 01/06/2016 05:18 AM, Daniel Schwierzeck wrote:
> 2016-01-04 14:07 GMT+01:00 Thomas Chou <thomas@wytron.com.tw>:
>> Hi Wills,
>>
>>
>> On 2016年01月04日 19:14, Wills Wang wrote:
>>> MIPS need to use KSEG1 address for register operation, this patch
>>> add map_physmem to convert CONFIG_DEBUG_UART_BASE for debug UART.
>>>
>>> Signed-off-by: Wills Wang <wills.wang@live.com>
>>> ---
>>>
>>> Changes in v6: None
>>> Changes in v5: None
>>> Changes in v4: None
>>> Changes in v3: None
>>> Changes in v2: None
>>>
>>>    drivers/serial/ns16550.c | 6 ++++--
>>>    1 file changed, 4 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/serial/ns16550.c b/drivers/serial/ns16550.c
>>> index 3b24af0..1e2538e 100644
>>> --- a/drivers/serial/ns16550.c
>>> +++ b/drivers/serial/ns16550.c
>>> @@ -270,7 +270,8 @@ int NS16550_tstc(NS16550_t com_port)
>>>
>>>    static inline void _debug_uart_init(void)
>>>    {
>>> -       struct NS16550 *com_port = (struct NS16550
>>> *)CONFIG_DEBUG_UART_BASE;
>>> +       struct NS16550 *com_port = (struct NS16550 *)map_physmem(
>>> +                               CONFIG_DEBUG_UART_BASE, 0, MAP_NOCACHE);
>>>          int baud_divisor;
>>>
>>>          /*
>>> @@ -293,7 +294,8 @@ static inline void _debug_uart_init(void)
>>>
>>>    static inline void _debug_uart_putc(int ch)
>>>    {
>>> -       struct NS16550 *com_port = (struct NS16550
>>> *)CONFIG_DEBUG_UART_BASE;
>>> +       struct NS16550 *com_port = (struct NS16550 *)map_physmem(
>>> +                               CONFIG_DEBUG_UART_BASE, 0, MAP_NOCACHE);
>>>
>>>          while (!(serial_din(&com_port->lsr) & UART_LSR_THRE))
>>>                  ;
>>>
>> As debug uart may be used in very early stage and SPL, I would suggest the
>> CONFIG_DEBUG_UART_BASE here is mapped to uncached space already. So that we
>> can keep the code and stack usage minimal.
>>
>> My concern is that the uncache mapping in nios2 arch is different between
>> NOMMU and MMU core, which will be decoded from device tree. So it won't work
>> for nios2 until DM initialized.
>>
>> Naked-by: Thomas Chou <thomas@wytron.com.tw>
>>
> I agree with Thomas. Please set CONFIG_DEBUG_UART_BASE to a KSEG1
> address and discard this patch.
>
Ok.
I will correct this in the next patch.
diff mbox

Patch

diff --git a/drivers/serial/ns16550.c b/drivers/serial/ns16550.c
index 3b24af0..1e2538e 100644
--- a/drivers/serial/ns16550.c
+++ b/drivers/serial/ns16550.c
@@ -270,7 +270,8 @@  int NS16550_tstc(NS16550_t com_port)
 
 static inline void _debug_uart_init(void)
 {
-	struct NS16550 *com_port = (struct NS16550 *)CONFIG_DEBUG_UART_BASE;
+	struct NS16550 *com_port = (struct NS16550 *)map_physmem(
+				CONFIG_DEBUG_UART_BASE, 0, MAP_NOCACHE);
 	int baud_divisor;
 
 	/*
@@ -293,7 +294,8 @@  static inline void _debug_uart_init(void)
 
 static inline void _debug_uart_putc(int ch)
 {
-	struct NS16550 *com_port = (struct NS16550 *)CONFIG_DEBUG_UART_BASE;
+	struct NS16550 *com_port = (struct NS16550 *)map_physmem(
+				CONFIG_DEBUG_UART_BASE, 0, MAP_NOCACHE);
 
 	while (!(serial_din(&com_port->lsr) & UART_LSR_THRE))
 		;