bootwrapper: Add non-OF serial console support
PATCH 4/6 bootwrapper: Add non-OF serial console support
This patch adds support for serial I/O to the bootwrapper.
It is broken into 2 layers. The first layer is generic serial operations that calls uart-specific routines to do the actual I/O. The second layer contains support for a 16550 compatible uart.
The division allows support for other serial devices to be easily added in the future (e.g., the Marvell MPSC and the Freescale CPM).
--
io.h | 53 ++++++++++++++++++++++++++++ ns16550.c | 117 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ serial.c | 89 +++++++++++++++++++++++++++++++++++++++++++++++ util.S | 101 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 360 insertions(+)
--
arch/powerpc/boot/io.h new file +53 -0
@@ -0,0 +1,53 @@ +#ifndef _IO_H +#define __IO_H +/* +* Low-level I/O routines. +* +* Copied from <file:include/asm-powerpc/io.h> +*/ +static inline int in_8 (const volatile unsigned char *addr) +{ +int ret; + + __asm__ __volatile__("lbz%U1%X1 %0,%1; twi 0,%0,0; isync" + :"=r" (ret) :"m" (*addr)); +return ret; +} + +static inline void out_8 (volatile unsigned char *addr,int val) +{ + __asm__ __volatile__("stb%U0%X0 %1,%0; sync" + :"=m" (*addr) :"r" (val)); +} + +static inline unsigned in_le32 (const volatile unsigned *addr) +{ +unsigned ret; + + __asm__ __volatile__("lwbrx %0,0,%1; twi 0,%0,0; isync" + :"=r" (ret) :"r" (addr),"m" (*addr)); +return ret; +} + +static inline unsigned in_be32 (const volatile unsigned *addr) +{ +unsigned ret; + + __asm__ __volatile__("lwz%U1%X1 %0,%1; twi 0,%0,0; isync" + :"=r" (ret) :"m" (*addr)); +return ret; +} + +static inline void out_le32 (volatile unsigned *addr,int val) +{ + __asm__ __volatile__("stwbrx %1,0,%2; sync" :"=m" (*addr) + :"r" (val),"r" (addr)); +} + +static inline void out_be32 (volatile unsigned *addr,int val) +{ + __asm__ __volatile__("stw%U0%X0 %1,%0; sync" + :"=m" (*addr) :"r" (val)); +} + +#endif /* _IO_H */
arch/powerpc/boot/ns16550.c new file +117 -0
117 lines not on this page · raw message
arch/powerpc/boot/serial.c new file +89 -0
89 lines not on this page · raw message
arch/powerpc/boot/util.S new file +101 -0
101 lines not on this page · raw message
Quoted 8 lines · Mark A. Greer
This patch adds support for serial I/O to the bootwrapper.
It is broken into 2 layers. The first layer is generic serial operations that calls uart-specific routines to do the actual I/O. The second layer contains support for a 16550 compatible uart.
The division allows support for other serial devices to be easily added in the future (e.g., the Marvell MPSC and the Freescale CPM).
Why do we do this with indirection rather than weak defaults and then real implementations? The only places I see that are data are:
arch/powerpc/boot/ns16550.c line 108
Quoted 2 lines
arch/powerpc/boot/ns16550.c new file +2
-0+ ns16550_scd.base =NULL ; + ns16550_scd.reg_shift =0 ;
And I imagine that on platforms where these are real, we dig them out of the tree and set them, in your scheme, so it'd just be an empty (return 0/NULL) weak function, or the dig in the tree function. Heck, it could just always be a 'dig in the tree' function.
Signature · 1 line
Tom Rini
Quoted 8 lines · Tom Rini
Quoted 6 lines · Mark A. Greer
This patch adds support for serial I/O to the bootwrapper.
It is broken into 2 layers. The first layer is generic serial operations that calls uart-specific routines to do the actual I/O. The second layer contains support for a 16550 compatible uart.
Quoted 5 lines
Quoted 2 lines
The division allows support for other serial devices to be easily added in the future (e.g., the Marvell MPSC and the Freescale CPM).
Why do we do this with indirection rather than weak defaults and then real implementations?
Remember, devtrees can be added years after the zImage built. So what if you had a board with 4 serial ports, 2 MPSC, 2 16550/8250 and the /chosen/linux,stdout-path could choose any of the four?
The current code doesn't handle that now either :) but it easily could (and I should make it handle that). The reason for the indirections and not weak routines is to allow maximum flexibility.
Once things become more concrete, we can look at what can be replaced by weak routines. Now isn't the time, IMHO.
Quoted 9 lines
The only places I see that are data are:
arch/powerpc/boot/ns16550.c line 108
Quoted 2 lines
arch/powerpc/boot/ns16550.c new file +2
-0+ ns16550_scd.base =NULL ; + ns16550_scd.reg_shift =0 ;And I imagine that on platforms where these are real, we dig them out of the tree and set them, in your scheme, so it'd just be an empty (return 0/NULL) weak function, or the dig in the tree function. Heck, it could just always be a 'dig in the tree' function.
I'm sorry, but I can't parse this paragraph.
What I probably should do, is rework serial_open() to query the dt to get the stdout-path, match it up to one of the low-level serial drivers that's been linked into the zImage, hook it up, and can call its open routine. Its open routine can then look for the properies it needs in the devtree. Something like that.
Again, when things have settled down, we can convert indirects to weak routines where it makes sense. But also remember, that the zImage doesn't necessarily know a priori what's going to be in its devtree (unless what's been compiled & linked into the zImage is so minimal that it allows it no options--maybe that ends up always being the case, I don't know).
Mark
This patch adds support for serial I/O to the bootwrapper.
It is broken into 2 layers. The first layer is generic serial operations that calls uart-specific routines to do the actual I/O. The second layer contains support for a 16550 compatible uart.
The division allows support for other serial devices to be easily added in the future (e.g., the Marvell MPSC and the Freescale CPM).
--
io.h | 53 ++++++++++++++++++++ ns16550.c | 81 +++++++++++++++++++++++++++++++ serial.c | 159 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ util.S | 101 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 394 insertions(+)
--
arch/powerpc/boot/io.h new file +53 -0
@@ -0,0 +1,53 @@ +#ifndef _IO_H +#define __IO_H +/* +* Low-level I/O routines. +* +* Copied from <file:include/asm-powerpc/io.h> (which has no copyright) +*/ +static inline int in_8 (const volatile unsigned char *addr) +{ +int ret; + + __asm__ __volatile__("lbz%U1%X1 %0,%1; twi 0,%0,0; isync" + :"=r" (ret) :"m" (*addr)); +return ret; +} + +static inline void out_8 (volatile unsigned char *addr,int val) +{ + __asm__ __volatile__("stb%U0%X0 %1,%0; sync" + :"=m" (*addr) :"r" (val)); +} + +static inline unsigned in_le32 (const volatile unsigned *addr) +{ +unsigned ret; + + __asm__ __volatile__("lwbrx %0,0,%1; twi 0,%0,0; isync" + :"=r" (ret) :"r" (addr),"m" (*addr)); +return ret; +} + +static inline unsigned in_be32 (const volatile unsigned *addr) +{ +unsigned ret; + + __asm__ __volatile__("lwz%U1%X1 %0,%1; twi 0,%0,0; isync" + :"=r" (ret) :"m" (*addr)); +return ret; +} + +static inline void out_le32 (volatile unsigned *addr,int val) +{ + __asm__ __volatile__("stwbrx %1,0,%2; sync" :"=m" (*addr) + :"r" (val),"r" (addr)); +} + +static inline void out_be32 (volatile unsigned *addr,int val) +{ + __asm__ __volatile__("stw%U0%X0 %1,%0; sync" + :"=m" (*addr) :"r" (val)); +} + +#endif /* _IO_H */
arch/powerpc/boot/ns16550.c new file +81 -0
81 lines not on this page · raw message
arch/powerpc/boot/serial.c new file +159 -0
159 lines not on this page · raw message
arch/powerpc/boot/util.S new file +101 -0
101 lines not on this page · raw message