dm: treewide: Rename auto_alloc_size members to be shorter
[platform/kernel/u-boot.git] / drivers / serial / serial_zynq.c
index e4e4c39..d04c399 100644 (file)
 #include <dm.h>
 #include <errno.h>
 #include <fdtdec.h>
+#include <log.h>
 #include <watchdog.h>
 #include <asm/io.h>
 #include <dm/device_compat.h>
+#include <linux/bitops.h>
 #include <linux/compiler.h>
 #include <serial.h>
 #include <linux/err.h>
 
-DECLARE_GLOBAL_DATA_PTR;
-
 #define ZYNQ_UART_SR_TXACTIVE  BIT(11) /* TX active */
 #define ZYNQ_UART_SR_TXFULL    BIT(4) /* TX FIFO full */
 #define ZYNQ_UART_SR_RXEMPTY   BIT(1) /* RX FIFO empty */
@@ -45,7 +45,7 @@ struct zynq_uart_platdata {
        struct uart_zynq *regs;
 };
 
-/* Set up the baud rate in gd struct */
+/* Set up the baud rate */
 static void _uart_zynq_serial_setbrg(struct uart_zynq *regs,
                                     unsigned long clock, unsigned long baud)
 {
@@ -140,9 +140,12 @@ static int zynq_serial_setbrg(struct udevice *dev, int baudrate)
 static int zynq_serial_probe(struct udevice *dev)
 {
        struct zynq_uart_platdata *platdata = dev_get_platdata(dev);
+       struct uart_zynq *regs = platdata->regs;
+       u32 val;
 
-       /* No need to reinitialize the UART after relocation */
-       if (gd->flags & GD_FLG_RELOC)
+       /* No need to reinitialize the UART if TX already enabled */
+       val = readl(&regs->control);
+       if (val & ZYNQ_UART_CR_TX_EN)
                return 0;
 
        _uart_zynq_serial_init(platdata->regs);
@@ -209,7 +212,7 @@ U_BOOT_DRIVER(serial_zynq) = {
        .id     = UCLASS_SERIAL,
        .of_match = zynq_serial_ids,
        .ofdata_to_platdata = zynq_serial_ofdata_to_platdata,
-       .platdata_auto_alloc_size = sizeof(struct zynq_uart_platdata),
+       .platdata_auto  = sizeof(struct zynq_uart_platdata),
        .probe = zynq_serial_probe,
        .ops    = &zynq_serial_ops,
 };