dm: treewide: Rename auto_alloc_size members to be shorter
[platform/kernel/u-boot.git] / drivers / serial / serial_sh.c
index a17698f..4e37ab0 100644 (file)
@@ -1,10 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * SuperH SCIF device driver.
  * Copyright (C) 2013  Renesas Electronics Corporation
  * Copyright (C) 2007,2008,2010, 2014 Nobuhiro Iwamatsu
  * Copyright (C) 2002 - 2008  Paul Mundt
- *
- * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
 #include <serial.h>
 #include <linux/compiler.h>
 #include <dm/platform_data/serial_sh.h>
+#include <linux/delay.h>
 #include "serial_sh.h"
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#if defined(CONFIG_CPU_SH7760) || \
-       defined(CONFIG_CPU_SH7780) || \
-       defined(CONFIG_CPU_SH7785) || \
-       defined(CONFIG_CPU_SH7786)
+#if defined(CONFIG_CPU_SH7780)
 static int scif_rxfill(struct uart_port *port)
 {
        return sci_in(port, SCRFDR) & 0xff;
@@ -40,14 +37,6 @@ static int scif_rxfill(struct uart_port *port)
                return sci_in(port, SCFDR) & SCIF2_RFDC_MASK;
        }
 }
-#elif defined(CONFIG_ARCH_SH7372)
-static int scif_rxfill(struct uart_port *port)
-{
-       if (port->type == PORT_SCIFA)
-               return sci_in(port, SCFDR) & SCIF_RFDC_MASK;
-       else
-               return sci_in(port, SCRFDR);
-}
 #else
 static int scif_rxfill(struct uart_port *port)
 {
@@ -64,6 +53,9 @@ static void sh_serial_init_generic(struct uart_port *port)
        sci_out(port, SCFCR, SCFCR_RFRST|SCFCR_TFRST);
        sci_in(port, SCFCR);
        sci_out(port, SCFCR, 0);
+#if defined(CONFIG_RZA1)
+       sci_out(port, SCSPTR, 0x0003);
+#endif
 }
 
 static void
@@ -124,7 +116,10 @@ static int serial_getc_check(struct uart_port *port)
                handle_error(port);
        if (sci_in(port, SCLSR) & SCxSR_ORER(port))
                handle_error(port);
-       return status & (SCIF_DR | SCxSR_RDxF(port));
+       status &= (SCIF_DR | SCxSR_RDxF(port));
+       if (status)
+               return status;
+       return scif_rxfill(port);
 }
 
 static int sh_serial_getc_generic(struct uart_port *port)
@@ -219,7 +214,7 @@ static int sh_serial_ofdata_to_platdata(struct udevice *dev)
        fdt_addr_t addr;
        int ret;
 
-       addr = devfdt_get_addr(dev);
+       addr = dev_read_addr(dev);
        if (!addr)
                return -EINVAL;
 
@@ -245,11 +240,13 @@ U_BOOT_DRIVER(serial_sh) = {
        .id     = UCLASS_SERIAL,
        .of_match = of_match_ptr(sh_serial_id),
        .ofdata_to_platdata = of_match_ptr(sh_serial_ofdata_to_platdata),
-       .platdata_auto_alloc_size = sizeof(struct sh_serial_platdata),
+       .platdata_auto  = sizeof(struct sh_serial_platdata),
        .probe  = sh_serial_probe,
        .ops    = &sh_serial_ops,
+#if !CONFIG_IS_ENABLED(OF_CONTROL)
        .flags  = DM_FLAG_PRE_RELOC,
-       .priv_auto_alloc_size = sizeof(struct uart_port),
+#endif
+       .priv_auto      = sizeof(struct uart_port),
 };
 
 #else /* CONFIG_DM_SERIAL */
@@ -270,6 +267,8 @@ U_BOOT_DRIVER(serial_sh) = {
 # define SCIF_BASE     SCIF6_BASE
 #elif defined(CONFIG_CONS_SCIF7)
 # define SCIF_BASE     SCIF7_BASE
+#elif defined(CONFIG_CONS_SCIFA0)
+# define SCIF_BASE     SCIFA0_BASE
 #else
 # error "Default SCIF doesn't set....."
 #endif