[U-Boot] [PATCH v4 5/8] arm: serial: Add ability to use pre-initialized UARTs

Sergey Temerkhanov s.temerkhanov at gmail.com
Tue Aug 18 14:26:31 CEST 2015


On some systems, UART initialization is performed before running U-Boot.
This commit allows to skip UART re-initializaion on those systems

Signed-off-by: Sergey Temerkhanov <s.temerkhanov at gmail.com>
Signed-off-by: Radha Mohan Chintakuntla <rchintakuntla at cavium.com>

---

Changes in v4:
- Fixed build warnings
- Moved to DM_SERIAL

Changes in v3:
- Added __used keyword

Changes in v2: None

 drivers/serial/serial_pl01x.c           | 12 ++++++------
 include/dm/platform_data/serial_pl01x.h |  6 ++++++
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/drivers/serial/serial_pl01x.c b/drivers/serial/serial_pl01x.c
index ad503af..037fd23 100644
--- a/drivers/serial/serial_pl01x.c
+++ b/drivers/serial/serial_pl01x.c
@@ -125,7 +125,7 @@ static int pl011_set_line_control(struct pl01x_regs *regs)
 }
 
 static int pl01x_generic_setbrg(struct pl01x_regs *regs, enum pl01x_type type,
-				int clock, int baudrate)
+				       int clock, int baudrate)
 {
 	switch (type) {
 	case TYPE_PL010: {
@@ -295,7 +295,6 @@ __weak struct serial_device *default_serial_console(void)
 #endif /* nCONFIG_DM_SERIAL */
 
 #ifdef CONFIG_DM_SERIAL
-
 struct pl01x_priv {
 	struct pl01x_regs *regs;
 	enum pl01x_type type;
@@ -306,9 +305,9 @@ static int pl01x_serial_setbrg(struct udevice *dev, int baudrate)
 	struct pl01x_serial_platdata *plat = dev_get_platdata(dev);
 	struct pl01x_priv *priv = dev_get_priv(dev);
 
-	pl01x_generic_setbrg(priv->regs, priv->type, plat->clock, baudrate);
-
-	return 0;
+	return (plat->flags & PL0x_PREINITIALIZED) ? 0 :
+		pl01x_generic_setbrg(priv->regs, priv->type,
+				     plat->clock, baudrate);
 }
 
 static int pl01x_serial_probe(struct udevice *dev)
@@ -318,7 +317,8 @@ static int pl01x_serial_probe(struct udevice *dev)
 
 	priv->regs = (struct pl01x_regs *)plat->base;
 	priv->type = plat->type;
-	return pl01x_generic_serial_init(priv->regs, priv->type);
+	return (plat->flags & PL0x_PREINITIALIZED) ? 0 :
+		pl01x_generic_serial_init(priv->regs, priv->type);
 }
 
 static int pl01x_serial_getc(struct udevice *dev)
diff --git a/include/dm/platform_data/serial_pl01x.h b/include/dm/platform_data/serial_pl01x.h
index 5e068f3..455121b 100644
--- a/include/dm/platform_data/serial_pl01x.h
+++ b/include/dm/platform_data/serial_pl01x.h
@@ -11,17 +11,23 @@ enum pl01x_type {
 	TYPE_PL011,
 };
 
+enum pl01x_flags {
+	PL0x_PREINITIALIZED = 1 << 0, /* Skip port initialization */
+};
+
 /*
  *Information about a serial port
  *
  * @base: Register base address
  * @type: Port type
  * @clock: Input clock rate, used for calculating the baud rate divisor
+ * @flags: Port flags
  */
 struct pl01x_serial_platdata {
 	unsigned long base;
 	enum pl01x_type type;
 	unsigned int clock;
+	unsigned long flags;
 };
 
 #endif
-- 
2.2.0



More information about the U-Boot mailing list