dm: serial/16550: rollback to upstream version
rollback to: 02234e4 UPSTREAM: usbtty: fix typos
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
Change-Id: I84296fad2b06823afc77477ef4ef11a2f801960a
This commit is contained in:
parent
e6b325265d
commit
8c22eae691
|
|
@ -346,11 +346,6 @@ config DEBUG_UART_SKIP_INIT
|
|||
Select this if the UART you want to use for debug output is already
|
||||
initialized by the time U-Boot starts its execution.
|
||||
|
||||
config DEBUG_UART_ALWAYS_MODE
|
||||
bool "Always use debug UART mode"
|
||||
help
|
||||
Select this to always use debug UART, skip complicated console UART register.
|
||||
|
||||
config ALTERA_JTAG_UART
|
||||
bool "Altera JTAG UART support"
|
||||
depends on DM_SERIAL
|
||||
|
|
@ -536,7 +531,7 @@ config STM32X7_SERIAL
|
|||
|
||||
config MPC8XX_CONS
|
||||
bool "Console driver for MPC8XX"
|
||||
depends on MPC8xx
|
||||
depends on 8xx
|
||||
default y
|
||||
|
||||
choice
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ static inline int serial_in_shift(void *addr, int shift)
|
|||
#ifdef CONFIG_DM_SERIAL
|
||||
|
||||
#ifndef CONFIG_SYS_NS16550_CLK
|
||||
#define CONFIG_SYS_NS16550_CLK 24000000
|
||||
#define CONFIG_SYS_NS16550_CLK 0
|
||||
#endif
|
||||
|
||||
static void ns16550_writeb(NS16550_t port, int offset, int value)
|
||||
|
|
@ -254,13 +254,6 @@ static inline void _debug_uart_init(void)
|
|||
*/
|
||||
baud_divisor = ns16550_calc_divisor(com_port, CONFIG_DEBUG_UART_CLOCK,
|
||||
CONFIG_BAUDRATE);
|
||||
|
||||
if (gd && gd->serial.using_pre_serial) {
|
||||
com_port = (struct NS16550 *)gd->serial.addr;
|
||||
baud_divisor = ns16550_calc_divisor(com_port,
|
||||
CONFIG_DEBUG_UART_CLOCK, gd->serial.baudrate);
|
||||
}
|
||||
|
||||
serial_dout(&com_port->ier, CONFIG_SYS_NS16550_IER);
|
||||
serial_dout(&com_port->mcr, UART_MCRVAL);
|
||||
serial_dout(&com_port->fcr, UART_FCR_DEFVAL);
|
||||
|
|
@ -275,9 +268,6 @@ static inline void _debug_uart_putc(int ch)
|
|||
{
|
||||
struct NS16550 *com_port = (struct NS16550 *)CONFIG_DEBUG_UART_BASE;
|
||||
|
||||
if (gd && gd->serial.using_pre_serial)
|
||||
com_port = (struct NS16550 *)gd->serial.addr;
|
||||
|
||||
while (!(serial_din(&com_port->lsr) & UART_LSR_THRE))
|
||||
;
|
||||
serial_dout(&com_port->thr, ch);
|
||||
|
|
@ -298,13 +288,6 @@ static inline void _debug_uart_init(void)
|
|||
|
||||
baud_divisor = ns16550_calc_divisor(com_port, CONFIG_DEBUG_UART_CLOCK,
|
||||
CONFIG_BAUDRATE);
|
||||
|
||||
if (gd && gd->serial.using_pre_serial) {
|
||||
com_port = (struct NS16550 *)gd->serial.addr;
|
||||
baud_divisor = ns16550_calc_divisor(com_port,
|
||||
CONFIG_DEBUG_UART_CLOCK, gd->serial.baudrate);
|
||||
}
|
||||
|
||||
serial_dout(&com_port->ier, CONFIG_SYS_NS16550_IER);
|
||||
serial_dout(&com_port->mdr1, 0x7);
|
||||
serial_dout(&com_port->mcr, UART_MCRVAL);
|
||||
|
|
@ -321,9 +304,6 @@ static inline void _debug_uart_putc(int ch)
|
|||
{
|
||||
struct NS16550 *com_port = (struct NS16550 *)CONFIG_DEBUG_UART_BASE;
|
||||
|
||||
if (gd && gd->serial.using_pre_serial)
|
||||
com_port = (struct NS16550 *)gd->serial.addr;
|
||||
|
||||
while (!(serial_din(&com_port->lsr) & UART_LSR_THRE))
|
||||
;
|
||||
serial_dout(&com_port->thr, ch);
|
||||
|
|
@ -338,20 +318,8 @@ static int ns16550_serial_putc(struct udevice *dev, const char ch)
|
|||
{
|
||||
struct NS16550 *const com_port = dev_get_priv(dev);
|
||||
|
||||
#ifdef CONFIG_ARCH_ROCKCHIP
|
||||
/*
|
||||
* Use fifo function.
|
||||
*
|
||||
* UART_USR: bit1 trans_fifo_not_full:
|
||||
* 0 = Transmit FIFO is full;
|
||||
* 1 = Transmit FIFO is not full;
|
||||
*/
|
||||
while (!(serial_in(&com_port->rbr + 0x1f) & 0x02))
|
||||
;
|
||||
#else
|
||||
if (!(serial_in(&com_port->lsr) & UART_LSR_THRE))
|
||||
return -EAGAIN;
|
||||
#endif
|
||||
serial_out(ch, &com_port->thr);
|
||||
|
||||
/*
|
||||
|
|
@ -399,24 +367,6 @@ static int ns16550_serial_setbrg(struct udevice *dev, int baudrate)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int ns16550_serial_clear(struct udevice *dev)
|
||||
{
|
||||
#ifdef CONFIG_ARCH_ROCKCHIP
|
||||
struct NS16550 *const com_port = dev_get_priv(dev);
|
||||
|
||||
/*
|
||||
* Wait fifo flush.
|
||||
*
|
||||
* UART_USR: bit2 trans_fifo_empty:
|
||||
* 0 = Transmit FIFO is not empty
|
||||
* 1 = Transmit FIFO is empty
|
||||
*/
|
||||
while (!(serial_in(&com_port->rbr + 0x1f) & 0x04))
|
||||
;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ns16550_serial_probe(struct udevice *dev)
|
||||
{
|
||||
struct NS16550 *const com_port = dev_get_priv(dev);
|
||||
|
|
@ -480,10 +430,6 @@ int ns16550_serial_ofdata_to_platdata(struct udevice *dev)
|
|||
#ifdef CONFIG_SYS_NS16550_PORT_MAPPED
|
||||
plat->base = addr;
|
||||
#else
|
||||
|
||||
if (gd && gd->serial.using_pre_serial && gd->serial.id == dev->req_seq)
|
||||
addr = gd->serial.addr;
|
||||
|
||||
plat->base = (unsigned long)map_physmem(addr, 0, MAP_NOCACHE);
|
||||
#endif
|
||||
|
||||
|
|
@ -496,7 +442,7 @@ int ns16550_serial_ofdata_to_platdata(struct udevice *dev)
|
|||
if (!IS_ERR_VALUE(err))
|
||||
plat->clock = err;
|
||||
} else if (err != -ENOENT && err != -ENODEV && err != -ENOSYS) {
|
||||
printf("ns16550 failed to get clock, err=%d\n", err);
|
||||
debug("ns16550 failed to get clock\n");
|
||||
return err;
|
||||
}
|
||||
|
||||
|
|
@ -521,10 +467,8 @@ const struct dm_serial_ops ns16550_serial_ops = {
|
|||
.pending = ns16550_serial_pending,
|
||||
.getc = ns16550_serial_getc,
|
||||
.setbrg = ns16550_serial_setbrg,
|
||||
.clear = ns16550_serial_clear,
|
||||
};
|
||||
|
||||
#if CONFIG_IS_ENABLED(SERIAL_PRESENT)
|
||||
#if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)
|
||||
/*
|
||||
* Please consider existing compatible strings before adding a new
|
||||
|
|
@ -547,6 +491,8 @@ static const struct udevice_id ns16550_serial_ids[] = {
|
|||
};
|
||||
#endif /* OF_CONTROL && !OF_PLATDATA */
|
||||
|
||||
#if CONFIG_IS_ENABLED(SERIAL_PRESENT)
|
||||
|
||||
/* TODO(sjg@chromium.org): Integrate this into a macro like CONFIG_IS_ENABLED */
|
||||
#if !defined(CONFIG_TPL_BUILD) || defined(CONFIG_TPL_DM_SERIAL)
|
||||
U_BOOT_DRIVER(ns16550_serial) = {
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@
|
|||
#include <dm/lists.h>
|
||||
#include <dm/device-internal.h>
|
||||
#include <dm/of_access.h>
|
||||
#include <dm/uclass-internal.h>
|
||||
|
||||
DECLARE_GLOBAL_DATA_PTR;
|
||||
|
||||
|
|
@ -28,7 +27,6 @@ static const unsigned long baudrate_table[] = CONFIG_SYS_BAUDRATE_TABLE;
|
|||
#error "Serial is required before relocation - define CONFIG_$(SPL_)SYS_MALLOC_F_LEN to make this work"
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_DEBUG_UART_ALWAYS_MODE
|
||||
static int serial_check_stdout(const void *blob, struct udevice **devp)
|
||||
{
|
||||
int node;
|
||||
|
|
@ -56,23 +54,6 @@ static int serial_check_stdout(const void *blob, struct udevice **devp)
|
|||
}
|
||||
if (node < 0)
|
||||
node = fdt_path_offset(blob, "console");
|
||||
|
||||
if (gd && gd->serial.using_pre_serial) {
|
||||
const char *serial_path;
|
||||
char serial[12];
|
||||
|
||||
snprintf(serial, 12, "serial%d", gd->serial.id);
|
||||
serial_path = fdt_get_alias(blob, serial);
|
||||
if (serial_path) {
|
||||
debug("Find alias %s, path: %s\n", serial, serial_path);
|
||||
node = fdt_path_offset(blob, serial_path);
|
||||
if (node < 0)
|
||||
printf("Can't find %s by path\n", serial);
|
||||
} else {
|
||||
printf("Can't find alias %s\n", serial);
|
||||
}
|
||||
}
|
||||
|
||||
if (!uclass_get_device_by_of_offset(UCLASS_SERIAL, node, devp))
|
||||
return 0;
|
||||
|
||||
|
|
@ -88,72 +69,11 @@ static int serial_check_stdout(const void *blob, struct udevice **devp)
|
|||
|
||||
return -ENODEV;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_OF_LIVE) && !defined(CONFIG_DEBUG_UART_ALWAYS_MODE)
|
||||
/*
|
||||
* Hide and present pinctrl prop int live device tree
|
||||
*
|
||||
* 1. We bind all serial nodes including UART debug node from kernel dtb.
|
||||
*
|
||||
* 2. On some rockchip platforms, UART debug and SDMMC pin are multiplex.
|
||||
* Without this, iomux is switched from SDMMC => UART debug at this time.
|
||||
*
|
||||
* 3. We may switch to UART debug iomux after SDMMC boot failed to print log
|
||||
* by console record mechanism.
|
||||
*/
|
||||
static void serial_console_hide_prop(char **p1, char **p2)
|
||||
{
|
||||
struct udevice *dev;
|
||||
|
||||
if (!of_live_active())
|
||||
return;
|
||||
|
||||
for (uclass_find_first_device(UCLASS_SERIAL, &dev);
|
||||
dev;
|
||||
uclass_find_next_device(&dev)) {
|
||||
if (dev_read_bool(dev, "u-boot,dm-pre-reloc") ||
|
||||
dev_read_bool(dev, "u-boot,dm-spl"))
|
||||
continue;
|
||||
|
||||
if (gd->cur_serial_dev->req_seq == dev->req_seq) {
|
||||
*p1 = (char *)dev_hide_prop(dev, "pinctrl-names");
|
||||
*p2 = (char *)dev_hide_prop(dev, "pinctrl-0");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void serial_console_present_prop(char *p1, char *p2)
|
||||
{
|
||||
struct udevice *dev;
|
||||
|
||||
if (!of_live_active() || !p1 || !p2)
|
||||
return;
|
||||
|
||||
for (uclass_find_first_device(UCLASS_SERIAL, &dev);
|
||||
dev;
|
||||
uclass_find_next_device(&dev)) {
|
||||
if (dev_read_bool(dev, "u-boot,dm-pre-reloc") ||
|
||||
dev_read_bool(dev, "u-boot,dm-spl"))
|
||||
continue;
|
||||
|
||||
if (gd->cur_serial_dev->req_seq == dev->req_seq) {
|
||||
dev_present_prop(dev, p1);
|
||||
dev_present_prop(dev, p2);
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
static inline void serial_console_hide_prop(char **p1, char **p2) {}
|
||||
static inline void serial_console_present_prop(char *p1, char *p2) {}
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_DEBUG_UART_ALWAYS_MODE
|
||||
static void serial_find_console_or_panic(void)
|
||||
{
|
||||
const void *blob = gd->fdt_blob;
|
||||
struct udevice *dev;
|
||||
char *p1 = NULL, *p2 = NULL;
|
||||
|
||||
if (CONFIG_IS_ENABLED(OF_PLATDATA)) {
|
||||
uclass_first_device(UCLASS_SERIAL, &dev);
|
||||
|
|
@ -166,27 +86,11 @@ static void serial_find_console_or_panic(void)
|
|||
if (of_live_active()) {
|
||||
struct device_node *np = of_get_stdout();
|
||||
|
||||
serial_console_hide_prop(&p1, &p2);
|
||||
if (np && !uclass_get_device_by_ofnode(UCLASS_SERIAL,
|
||||
np_to_ofnode(np), &dev)) {
|
||||
serial_console_present_prop(p1, p2);
|
||||
gd->cur_serial_dev = dev;
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* If the console is not marked to be bound, bind it
|
||||
* anyway.
|
||||
*/
|
||||
if (!lists_bind_fdt(gd->dm_root, np_to_ofnode(np),
|
||||
&dev)) {
|
||||
serial_console_hide_prop(&p1, &p2);
|
||||
if (!device_probe(dev)) {
|
||||
serial_console_present_prop(p1, p2);
|
||||
gd->cur_serial_dev = dev;
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!serial_check_stdout(blob, &dev)) {
|
||||
gd->cur_serial_dev = dev;
|
||||
|
|
@ -230,9 +134,6 @@ int serial_init(void)
|
|||
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
int serial_init(void) { return 0; }
|
||||
#endif
|
||||
|
||||
/* Called after relocation */
|
||||
void serial_initialize(void)
|
||||
|
|
@ -283,14 +184,6 @@ static int __serial_tstc(struct udevice *dev)
|
|||
return 1;
|
||||
}
|
||||
|
||||
static void __serial_clear(struct udevice *dev)
|
||||
{
|
||||
struct dm_serial_ops *ops = serial_get_ops(dev);
|
||||
|
||||
if (ops->clear)
|
||||
ops->clear(dev);
|
||||
}
|
||||
|
||||
#if CONFIG_IS_ENABLED(SERIAL_RX_BUFFER)
|
||||
static int _serial_tstc(struct udevice *dev)
|
||||
{
|
||||
|
|
@ -369,66 +262,6 @@ void serial_setbrg(void)
|
|||
ops->setbrg(gd->cur_serial_dev, gd->baudrate);
|
||||
}
|
||||
|
||||
void serial_clear(void)
|
||||
{
|
||||
if (!gd->cur_serial_dev)
|
||||
return;
|
||||
|
||||
__serial_clear(gd->cur_serial_dev);
|
||||
}
|
||||
|
||||
void serial_dev_putc(struct udevice *dev, char ch)
|
||||
{
|
||||
if (!dev)
|
||||
return;
|
||||
|
||||
_serial_putc(dev, ch);
|
||||
}
|
||||
|
||||
void serial_dev_puts(struct udevice *dev, const char *str)
|
||||
{
|
||||
if (!dev)
|
||||
return;
|
||||
|
||||
_serial_puts(dev, str);
|
||||
}
|
||||
|
||||
int serial_dev_getc(struct udevice *dev)
|
||||
{
|
||||
if (!dev)
|
||||
return 0;
|
||||
|
||||
return _serial_getc(dev);
|
||||
}
|
||||
|
||||
int serial_dev_tstc(struct udevice *dev)
|
||||
{
|
||||
if (!dev)
|
||||
return 0;
|
||||
|
||||
return _serial_tstc(dev);
|
||||
}
|
||||
|
||||
void serial_dev_setbrg(struct udevice *dev, int baudrate)
|
||||
{
|
||||
struct dm_serial_ops *ops;
|
||||
|
||||
if (!dev)
|
||||
return;
|
||||
|
||||
ops = serial_get_ops(dev);
|
||||
if (ops->setbrg)
|
||||
ops->setbrg(dev, baudrate);
|
||||
}
|
||||
|
||||
void serial_dev_clear(struct udevice *dev)
|
||||
{
|
||||
if (!dev)
|
||||
return;
|
||||
|
||||
__serial_clear(dev);
|
||||
}
|
||||
|
||||
void serial_stdio_init(void)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue