serial: ns16550: Add access functions that don't need platdata

For the debug UART we need to be able to provide any parameters before
driver model is set up. Add parameters to the low-level access functions
to make this possible.

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass 2015-01-26 18:27:08 -07:00
parent 2f964aa7b1
commit 765716744f

View file

@ -55,6 +55,37 @@ DECLARE_GLOBAL_DATA_PTR;
#endif /* CONFIG_SYS_NS16550_IER */ #endif /* CONFIG_SYS_NS16550_IER */
#ifdef CONFIG_DM_SERIAL #ifdef CONFIG_DM_SERIAL
static inline void serial_out_shift(unsigned char *addr, int shift, int value)
{
#ifdef CONFIG_SYS_NS16550_PORT_MAPPED
outb(value, (ulong)addr);
#elif defined(CONFIG_SYS_NS16550_MEM32) && !defined(CONFIG_SYS_BIG_ENDIAN)
out_le32(addr, value);
#elif defined(CONFIG_SYS_NS16550_MEM32) && defined(CONFIG_SYS_BIG_ENDIAN)
out_be32(addr, value);
#elif defined(CONFIG_SYS_BIG_ENDIAN)
writeb(value, addr + (1 << shift) - 1);
#else
writeb(value, addr);
#endif
}
static inline int serial_in_shift(unsigned char *addr, int shift)
{
#ifdef CONFIG_SYS_NS16550_PORT_MAPPED
return inb((ulong)addr);
#elif defined(CONFIG_SYS_NS16550_MEM32) && !defined(CONFIG_SYS_BIG_ENDIAN)
return in_le32(addr);
#elif defined(CONFIG_SYS_NS16550_MEM32) && defined(CONFIG_SYS_BIG_ENDIAN)
return in_be32(addr);
#elif defined(CONFIG_SYS_BIG_ENDIAN)
return readb(addr + (1 << reg_shift) - 1);
#else
return readb(addr);
#endif
}
static void ns16550_writeb(NS16550_t port, int offset, int value) static void ns16550_writeb(NS16550_t port, int offset, int value)
{ {
struct ns16550_platdata *plat = port->plat; struct ns16550_platdata *plat = port->plat;
@ -66,17 +97,7 @@ static void ns16550_writeb(NS16550_t port, int offset, int value)
* As far as we know it doesn't make sense to support selection of * As far as we know it doesn't make sense to support selection of
* these options at run-time, so use the existing CONFIG options. * these options at run-time, so use the existing CONFIG options.
*/ */
#ifdef CONFIG_SYS_NS16550_PORT_MAPPED serial_out_shift(addr, plat->reg_shift, value);
outb(value, (ulong)addr);
#elif defined(CONFIG_SYS_NS16550_MEM32) && !defined(CONFIG_SYS_BIG_ENDIAN)
out_le32(addr, value);
#elif defined(CONFIG_SYS_NS16550_MEM32) && defined(CONFIG_SYS_BIG_ENDIAN)
out_be32(addr, value);
#elif defined(CONFIG_SYS_BIG_ENDIAN)
writeb(value, addr + (1 << plat->reg_shift) - 1);
#else
writeb(value, addr);
#endif
} }
static int ns16550_readb(NS16550_t port, int offset) static int ns16550_readb(NS16550_t port, int offset)
@ -86,17 +107,8 @@ static int ns16550_readb(NS16550_t port, int offset)
offset *= 1 << plat->reg_shift; offset *= 1 << plat->reg_shift;
addr = map_sysmem(plat->base, 0) + offset; addr = map_sysmem(plat->base, 0) + offset;
#ifdef CONFIG_SYS_NS16550_PORT_MAPPED
return inb((ulong)addr); return serial_in_shift(addr, plat->reg_shift);
#elif defined(CONFIG_SYS_NS16550_MEM32) && !defined(CONFIG_SYS_BIG_ENDIAN)
return in_le32(addr);
#elif defined(CONFIG_SYS_NS16550_MEM32) && defined(CONFIG_SYS_BIG_ENDIAN)
return in_be32(addr);
#elif defined(CONFIG_SYS_BIG_ENDIAN)
return readb(addr + (1 << plat->reg_shift) - 1);
#else
return readb(addr);
#endif
} }
/* We can clean these up once everything is moved to driver model */ /* We can clean these up once everything is moved to driver model */