]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
serial: uartlite: Add support for OF_PLATDATA
authorMichal Simek <michal.simek@amd.com>
Wed, 23 Jul 2025 09:06:47 +0000 (11:06 +0200)
committerMichal Simek <michal.simek@amd.com>
Tue, 26 Aug 2025 05:30:09 +0000 (07:30 +0200)
The first change is to list DM_DRIVER_ALIAS for compatible string to be
able to match the driver. Only xps one is listed because opb one is likely
unused for quite a long time.

The second change is to add dtplat structure to plat data and fill register
base in probe.

Signed-off-by: Michal Simek <michal.simek@amd.com>
Link: https://lore.kernel.org/r/b494dbad529e919d33977b8ea6e6dbcd14e78907.1753261604.git.michal.simek@amd.com
drivers/serial/serial_xuartlite.c

index 00155aba5eb23a80305a8a73afe872af6b3489cc..6bfd0e085e87e19244f1fcc761d618b1c9f70421 100644 (file)
@@ -32,7 +32,11 @@ struct uartlite {
 };
 
 struct uartlite_plat {
+#if CONFIG_IS_ENABLED(OF_PLATDATA)
+       struct dtd_serial_uartlite dtplat;
+#else
        struct uartlite *regs;
+#endif
 };
 
 struct uartlite_priv {
@@ -94,9 +98,16 @@ static int uartlite_serial_probe(struct udevice *dev)
 {
        struct uartlite_plat *plat = dev_get_plat(dev);
        struct uartlite_priv *priv = dev_get_priv(dev);
-       struct uartlite *regs = plat->regs;
+       struct uartlite *regs;
        int ret;
 
+#if CONFIG_IS_ENABLED(OF_PLATDATA)
+       struct dtd_serial_uartlite *dtplat = &plat->dtplat;
+
+       regs = (struct uartlite *)dtplat->reg[0];
+#else
+       regs = plat->regs;
+#endif
        priv->regs = regs;
 
        uart_out32(&regs->control, 0);
@@ -112,6 +123,7 @@ static int uartlite_serial_probe(struct udevice *dev)
        return 0;
 }
 
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
 static int uartlite_serial_of_to_plat(struct udevice *dev)
 {
        struct uartlite_plat *plat = dev_get_plat(dev);
@@ -120,6 +132,7 @@ static int uartlite_serial_of_to_plat(struct udevice *dev)
 
        return 0;
 }
+#endif
 
 static const struct dm_serial_ops uartlite_serial_ops = {
        .putc = uartlite_serial_putc,
@@ -137,13 +150,17 @@ U_BOOT_DRIVER(serial_uartlite) = {
        .name   = "serial_uartlite",
        .id     = UCLASS_SERIAL,
        .of_match = uartlite_serial_ids,
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
        .of_to_plat = uartlite_serial_of_to_plat,
+#endif
        .priv_auto      = sizeof(struct uartlite_priv),
        .plat_auto      = sizeof(struct uartlite_plat),
        .probe = uartlite_serial_probe,
        .ops    = &uartlite_serial_ops,
 };
 
+DM_DRIVER_ALIAS(serial_uartlite, xlnx_xps_uartlite_1_00_a)
+
 #ifdef CONFIG_DEBUG_UART_UARTLITE
 
 #include <debug_uart.h>