Message ID | BLU436-SMTP72755FE6888C48E213482AFFF20@phx.gbl |
---|---|
State | Superseded |
Delegated to: | Daniel Schwierzeck |
Headers | show |
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
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
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.
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 --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)) ;
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(-)