]> git.ipfire.org Git - people/ms/u-boot.git/blobdiff - drivers/serial/serial_pxa.c
Add GPL-2.0+ SPDX-License-Identifier to source files
[people/ms/u-boot.git] / drivers / serial / serial_pxa.c
index 84bb17c11051b9d7ab33cc350d352defbc85e2ca..d5140045bfbb54ee0d790418fe07b7cbb4655343 100644 (file)
  *
  * Copyright (C) 1999 2000 2001 Erik Mouw (J.A.K.Mouw@its.tudelft.nl)
  *
- * 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>
@@ -36,6 +23,7 @@
 #include <asm/arch/pxa-regs.h>
 #include <asm/arch/regs-uart.h>
 #include <asm/io.h>
+#include <linux/compiler.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -49,7 +37,7 @@ DECLARE_GLOBAL_DATA_PTR;
 #define        BTUART_INDEX    0
 #define        FFUART_INDEX    1
 #define        STUART_INDEX    2
-#elif  CONFIG_PXA250
+#elif  CONFIG_CPU_PXA25X
 #define        UART_CLK_BASE   (1 << 4)        /* HWUART */
 #define        UART_CLK_REG    CKEN
 #define        HWUART_INDEX    0
@@ -68,25 +56,11 @@ DECLARE_GLOBAL_DATA_PTR;
  * Only PXA250 has HWUART, to avoid poluting the code with more macros,
  * artificially introduce this.
  */
-#ifndef        CONFIG_PXA250
+#ifndef        CONFIG_CPU_PXA25X
 #define        HWUART_INDEX    0xff
 #endif
 
-#ifndef CONFIG_SERIAL_MULTI
-#if defined(CONFIG_FFUART)
-#define UART_INDEX     FFUART_INDEX
-#elif defined(CONFIG_BTUART)
-#define UART_INDEX     BTUART_INDEX
-#elif defined(CONFIG_STUART)
-#define UART_INDEX     STUART_INDEX
-#elif defined(CONFIG_HWUART)
-#define UART_INDEX     HWUART_INDEX
-#else
-#error "Please select CONFIG_(FF|BT|ST|HW)UART in board config file."
-#endif
-#endif
-
-uint32_t pxa_uart_get_baud_divider(void)
+static uint32_t pxa_uart_get_baud_divider(void)
 {
        if (gd->baudrate == 1200)
                return 768;
@@ -104,7 +78,7 @@ uint32_t pxa_uart_get_baud_divider(void)
                return 0;
 }
 
-struct pxa_uart_regs *pxa_uart_index_to_regs(uint32_t uart_index)
+static struct pxa_uart_regs *pxa_uart_index_to_regs(uint32_t uart_index)
 {
        switch (uart_index) {
        case FFUART_INDEX: return (struct pxa_uart_regs *)FFUART_BASE;
@@ -116,7 +90,7 @@ struct pxa_uart_regs *pxa_uart_index_to_regs(uint32_t uart_index)
        }
 }
 
-void pxa_uart_toggle_clock(uint32_t uart_index, int enable)
+static void pxa_uart_toggle_clock(uint32_t uart_index, int enable)
 {
        uint32_t clk_reg, clk_offset, reg;
 
@@ -269,14 +243,14 @@ void pxa_puts_dev(unsigned int uart_index, const char *s)
 #define        pxa_uart_desc(uart)                                             \
        struct serial_device serial_##uart##_device =                   \
        {                                                               \
-               "serial_"#uart,                                         \
-               uart##_init,                                            \
-               NULL,                                                   \
-               uart##_setbrg,                                          \
-               uart##_getc,                                            \
-               uart##_tstc,                                            \
-               uart##_putc,                                            \
-               uart##_puts,                                            \
+               .name   = "serial_"#uart,                               \
+               .start  = uart##_init,                                  \
+               .stop   = NULL,                                         \
+               .setbrg = uart##_setbrg,                                \
+               .getc   = uart##_getc,                                  \
+               .tstc   = uart##_tstc,                                  \
+               .putc   = uart##_putc,                                  \
+               .puts   = uart##_puts,                                  \
        };
 
 #define        pxa_uart_multi(uart, UART)                                      \
@@ -296,6 +270,30 @@ void pxa_puts_dev(unsigned int uart_index, const char *s)
        pxa_uart_multi(btuart, BTUART)
 #endif
 
-#ifndef        CONFIG_SERIAL_MULTI
-       pxa_uart(serial, UART)
+__weak struct serial_device *default_serial_console(void)
+{
+#if CONFIG_CONS_INDEX == 1
+       return &serial_hwuart_device;
+#elif CONFIG_CONS_INDEX == 2
+       return &serial_stuart_device;
+#elif CONFIG_CONS_INDEX == 3
+       return &serial_ffuart_device;
+#elif CONFIG_CONS_INDEX == 4
+       return &serial_btuart_device;
+#else
+#error "Bad CONFIG_CONS_INDEX."
+#endif
+}
+
+void pxa_serial_initialize(void)
+{
+#if defined(CONFIG_FFUART)
+       serial_register(&serial_ffuart_device);
 #endif
+#if defined(CONFIG_BTUART)
+       serial_register(&serial_btuart_device);
+#endif
+#if defined(CONFIG_STUART)
+       serial_register(&serial_stuart_device);
+#endif
+}