Merge branch 'u-boot-tegra/master' into 'u-boot-arm/master'
[oweals/u-boot.git] / drivers / serial / serial_imx.c
index b9ca748f69b4fd1f447d2f62a5c3c529068711e4..d43a5fedcc87ed782542b88191d4d162b869a481 100644 (file)
@@ -1,24 +1,13 @@
 /*
  * (c) 2004 Sascha Hauer <sascha@saschahauer.de>
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
+ * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
 #include <asm/arch/imx-regs.h>
+#include <serial.h>
+#include <linux/compiler.h>
 
 #if defined CONFIG_IMX_SERIAL1
 #define UART_BASE IMX_UART1_BASE
@@ -50,7 +39,7 @@ struct imx_serial {
 
 DECLARE_GLOBAL_DATA_PTR;
 
-void serial_setbrg (void)
+static void imx_serial_setbrg(void)
 {
        serial_init();
 }
@@ -62,7 +51,7 @@ extern void imx_gpio_mode(int gpio_mode);
  * are always 8 data bits, no parity, 1 stop bit, no start bits.
  *
  */
-int serial_init (void)
+static int imx_serial_init(void)
 {
        volatile struct imx_serial* base = (struct imx_serial *)UART_BASE;
        unsigned int ufcr_rfdiv;
@@ -163,7 +152,7 @@ int serial_init (void)
  * otherwise. When the function is successful, the character read is
  * written into its argument c.
  */
-int serial_getc (void)
+static int imx_serial_getc(void)
 {
        volatile struct imx_serial* base = (struct imx_serial *)UART_BASE;
        unsigned char ch;
@@ -185,7 +174,7 @@ int hwflow_onoff(int on)
 /*
  * Output a single byte to the serial port.
  */
-void serial_putc (const char c)
+static void imx_serial_putc(const char c)
 {
        volatile struct imx_serial* base = (struct imx_serial *)UART_BASE;
 
@@ -202,7 +191,7 @@ void serial_putc (const char c)
 /*
  * Test whether a character is in the RX buffer
  */
-int serial_tstc (void)
+static int imx_serial_tstc(void)
 {
        volatile struct imx_serial* base = (struct imx_serial *)UART_BASE;
 
@@ -212,10 +201,23 @@ int serial_tstc (void)
        return 1;
 }
 
-void
-serial_puts (const char *s)
+static struct serial_device imx_serial_drv = {
+       .name   = "imx_serial",
+       .start  = imx_serial_init,
+       .stop   = NULL,
+       .setbrg = imx_serial_setbrg,
+       .putc   = imx_serial_putc,
+       .puts   = default_serial_puts,
+       .getc   = imx_serial_getc,
+       .tstc   = imx_serial_tstc,
+};
+
+void imx_serial_initialize(void)
+{
+       serial_register(&imx_serial_drv);
+}
+
+__weak struct serial_device *default_serial_console(void)
 {
-       while (*s) {
-               serial_putc (*s++);
-       }
+       return &imx_serial_drv;
 }