mirror of
https://github.com/u-boot/u-boot.git
synced 2025-05-08 19:11:53 +00:00
dm: console: Check for serial devices properly
With driver model the serial device is often not called "serial". Mark driver-model stdio devices so that they can be detected and we can look up the uclass. This is a more reliable way of finding out whether the console is connected to a serial device or not. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
42f9f915c2
commit
7b3c4c3a53
3 changed files with 12 additions and 2 deletions
|
@ -8,6 +8,7 @@
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
#include <console.h>
|
#include <console.h>
|
||||||
#include <debug_uart.h>
|
#include <debug_uart.h>
|
||||||
|
#include <dm.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <iomux.h>
|
#include <iomux.h>
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
|
@ -150,12 +151,20 @@ static int console_setfile(int file, struct stdio_dev * dev)
|
||||||
* console_dev_is_serial() - Check if a stdio device is a serial device
|
* console_dev_is_serial() - Check if a stdio device is a serial device
|
||||||
*
|
*
|
||||||
* @sdev: Device to check
|
* @sdev: Device to check
|
||||||
* @return true if this device is a serial device
|
* @return true if this device is in the serial uclass (or for pre-driver-model,
|
||||||
|
* whether it is called "serial".
|
||||||
*/
|
*/
|
||||||
static bool console_dev_is_serial(struct stdio_dev *sdev)
|
static bool console_dev_is_serial(struct stdio_dev *sdev)
|
||||||
{
|
{
|
||||||
bool is_serial;
|
bool is_serial;
|
||||||
|
|
||||||
|
#ifdef CONFIG_DM_SERIAL
|
||||||
|
if (sdev->flags & DEV_FLAGS_DM) {
|
||||||
|
struct udevice *dev = sdev->priv;
|
||||||
|
|
||||||
|
is_serial = device_get_uclass_id(dev) == UCLASS_SERIAL;
|
||||||
|
} else
|
||||||
|
#endif
|
||||||
is_serial = !strcmp(sdev->name, "serial");
|
is_serial = !strcmp(sdev->name, "serial");
|
||||||
|
|
||||||
return is_serial;
|
return is_serial;
|
||||||
|
|
|
@ -353,7 +353,7 @@ static int serial_post_probe(struct udevice *dev)
|
||||||
memset(&sdev, '\0', sizeof(sdev));
|
memset(&sdev, '\0', sizeof(sdev));
|
||||||
|
|
||||||
strncpy(sdev.name, dev->name, sizeof(sdev.name));
|
strncpy(sdev.name, dev->name, sizeof(sdev.name));
|
||||||
sdev.flags = DEV_FLAGS_OUTPUT | DEV_FLAGS_INPUT;
|
sdev.flags = DEV_FLAGS_OUTPUT | DEV_FLAGS_INPUT | DEV_FLAGS_DM;
|
||||||
sdev.priv = dev;
|
sdev.priv = dev;
|
||||||
sdev.putc = serial_stub_putc;
|
sdev.putc = serial_stub_putc;
|
||||||
sdev.puts = serial_stub_puts;
|
sdev.puts = serial_stub_puts;
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
#define DEV_FLAGS_INPUT 0x00000001 /* Device can be used as input console */
|
#define DEV_FLAGS_INPUT 0x00000001 /* Device can be used as input console */
|
||||||
#define DEV_FLAGS_OUTPUT 0x00000002 /* Device can be used as output console */
|
#define DEV_FLAGS_OUTPUT 0x00000002 /* Device can be used as output console */
|
||||||
|
#define DEV_FLAGS_DM 0x00000004 /* Device priv is a struct udevice * */
|
||||||
|
|
||||||
/* Device information */
|
/* Device information */
|
||||||
struct stdio_dev {
|
struct stdio_dev {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue