spi: ich: Add mmio_base to struct ich_spi_platdata
[oweals/u-boot.git] / drivers / serial / altera_uart.c
index 7d5197a73f763af43d90ede3164ef2ab765642a8..436cf2331df952cc92e0ca0e9486ab96f0401f42 100644 (file)
@@ -1,16 +1,19 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * (C) Copyright 2004, Psyent Corporation <www.psyent.com>
  * Scott McNutt <smcnutt@psyent.com>
- *
- * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
 #include <dm.h>
 #include <errno.h>
-#include <asm/io.h>
-#include <linux/compiler.h>
 #include <serial.h>
+#include <asm/io.h>
+
+/* status register */
+#define ALTERA_UART_TMT                BIT(5)  /* tx empty */
+#define ALTERA_UART_TRDY       BIT(6)  /* tx ready */
+#define ALTERA_UART_RRDY       BIT(7)  /* rx ready */
 
 struct altera_uart_regs {
        u32     rxdata;         /* Rx data reg */
@@ -26,13 +29,6 @@ struct altera_uart_platdata {
        unsigned int uartclk;
 };
 
-/* status register */
-#define ALTERA_UART_TMT                BIT(5)  /* tx empty */
-#define ALTERA_UART_TRDY       BIT(6)  /* tx ready */
-#define ALTERA_UART_RRDY       BIT(7)  /* rx ready */
-
-DECLARE_GLOBAL_DATA_PTR;
-
 static int altera_uart_setbrg(struct udevice *dev, int baudrate)
 {
        struct altera_uart_platdata *plat = dev->platdata;
@@ -90,10 +86,10 @@ static int altera_uart_ofdata_to_platdata(struct udevice *dev)
 {
        struct altera_uart_platdata *plat = dev_get_platdata(dev);
 
-       plat->regs = ioremap(dev_get_addr(dev),
-               sizeof(struct altera_uart_regs));
-       plat->uartclk = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
-               "clock-frequency", 0);
+       plat->regs = map_physmem(devfdt_get_addr(dev),
+                                sizeof(struct altera_uart_regs),
+                                MAP_NOCACHE);
+       plat->uartclk = dev_read_u32_default(dev, "clock-frequency", 0);
 
        return 0;
 }
@@ -106,8 +102,8 @@ static const struct dm_serial_ops altera_uart_ops = {
 };
 
 static const struct udevice_id altera_uart_ids[] = {
-       { .compatible = "altr,uart-1.0", },
-       { }
+       { .compatible = "altr,uart-1.0" },
+       {}
 };
 
 U_BOOT_DRIVER(altera_uart) = {
@@ -118,14 +114,13 @@ U_BOOT_DRIVER(altera_uart) = {
        .platdata_auto_alloc_size = sizeof(struct altera_uart_platdata),
        .probe = altera_uart_probe,
        .ops    = &altera_uart_ops,
-       .flags = DM_FLAG_PRE_RELOC,
 };
 
 #ifdef CONFIG_DEBUG_UART_ALTERA_UART
 
 #include <debug_uart.h>
 
-void debug_uart_init(void)
+static inline void _debug_uart_init(void)
 {
        struct altera_uart_regs *regs = (void *)CONFIG_DEBUG_UART_BASE;
        u32 div;