diff mbox series

[v1,10/16] serial: pl01x: Prepare the driver to support SPL_OF_PLATDATA

Message ID 20230519104359.2048821-11-lukma@denx.de
State Accepted
Commit 875752adc8b6a25ebaf9f45cb3fd206065a80f0e
Delegated to: Stefano Babic
Headers show
Series arm: xea: Update i.MX28 XEA board to use DM_SERIAL | expand

Commit Message

Lukasz Majewski May 19, 2023, 10:43 a.m. UTC
This commit prepares the pl01x serial driver to be used with
SPL_OF_PLATDATA enabled.

Signed-off-by: Lukasz Majewski <lukma@denx.de>
---

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

Comments

Stefano Babic July 11, 2023, 7:42 p.m. UTC | #1
> This commit prepares the pl01x serial driver to be used with
> SPL_OF_PLATDATA enabled.
> Signed-off-by: Lukasz Majewski <lukma@denx.de>
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic
diff mbox series

Patch

diff --git a/drivers/serial/serial_pl01x.c b/drivers/serial/serial_pl01x.c
index 18332c2192..dbf2b2df34 100644
--- a/drivers/serial/serial_pl01x.c
+++ b/drivers/serial/serial_pl01x.c
@@ -291,8 +291,16 @@  int pl01x_serial_probe(struct udevice *dev)
 	struct pl01x_serial_plat *plat = dev_get_plat(dev);
 	struct pl01x_priv *priv = dev_get_priv(dev);
 
+#if CONFIG_IS_ENABLED(OF_PLATDATA)
+	struct dtd_serial_pl01x *dtplat = &plat->dtplat;
+
+	priv->regs = (struct pl01x_regs *)dtplat->reg[0];
+	plat->type = dtplat->type;
+#else
 	priv->regs = (struct pl01x_regs *)plat->base;
+#endif
 	priv->type = plat->type;
+
 	if (!plat->skip_init)
 		return pl01x_generic_serial_init(priv->regs, priv->type);
 	else
@@ -380,8 +388,10 @@  int pl01x_serial_of_to_plat(struct udevice *dev)
 U_BOOT_DRIVER(serial_pl01x) = {
 	.name	= "serial_pl01x",
 	.id	= UCLASS_SERIAL,
+#if CONFIG_IS_ENABLED(OF_REAL)
 	.of_match = of_match_ptr(pl01x_serial_id),
 	.of_to_plat = of_match_ptr(pl01x_serial_of_to_plat),
+#endif
 	.plat_auto	= sizeof(struct pl01x_serial_plat),
 	.probe = pl01x_serial_probe,
 	.ops	= &pl01x_serial_ops,
@@ -389,6 +399,8 @@  U_BOOT_DRIVER(serial_pl01x) = {
 	.priv_auto	= sizeof(struct pl01x_priv),
 };
 
+DM_DRIVER_ALIAS(serial_pl01x, arm_pl011)
+DM_DRIVER_ALIAS(serial_pl01x, arm_pl010)
 #endif
 
 #if defined(CONFIG_DEBUG_UART_PL010) || defined(CONFIG_DEBUG_UART_PL011)
diff --git a/include/dm/platform_data/serial_pl01x.h b/include/dm/platform_data/serial_pl01x.h
index e3d4e308a1..811697ce5c 100644
--- a/include/dm/platform_data/serial_pl01x.h
+++ b/include/dm/platform_data/serial_pl01x.h
@@ -20,7 +20,11 @@  enum pl01x_type {
  * @skip_init: Don't attempt to change port configuration (also means @clock
  * is ignored)
  */
+#include <dt-structs.h>
 struct pl01x_serial_plat {
+#if CONFIG_IS_ENABLED(OF_PLATDATA)
+	struct dtd_serial_pl01x dtplat;
+#endif
 	unsigned long base;
 	enum pl01x_type type;
 	unsigned int clock;