2 * serial.h - common serial defines for early debug and serial driver.
3 * any functions defined here must be always_inline since
4 * initcode cannot have function calls.
6 * Copyright (c) 2004-2011 Analog Devices Inc.
8 * Licensed under the GPL-2 or later.
11 #ifndef __BFIN_CPU_SERIAL_H__
12 #define __BFIN_CPU_SERIAL_H__
14 #include <asm/blackfin.h>
15 #include <asm/portmux.h>
17 #ifndef CONFIG_UART_CONSOLE
18 # define CONFIG_UART_CONSOLE 0
21 #ifdef CONFIG_DEBUG_EARLY_SERIAL
22 # define BFIN_DEBUG_EARLY_SERIAL 1
24 # define BFIN_DEBUG_EARLY_SERIAL 0
27 #if defined(__ADSPBF60x__)
28 # define BFIN_UART_HW_VER 4
29 #elif defined(__ADSPBF50x__) || defined(__ADSPBF54x__)
30 # define BFIN_UART_HW_VER 2
32 # define BFIN_UART_HW_VER 1
35 #define __PASTE_UART(num, pfx, sfx) pfx##num##_##sfx
36 #define _PASTE_UART(num, pfx, sfx) __PASTE_UART(num, pfx, sfx)
37 #define _P_UART(n, pin) _PASTE_UART(n, P_UART, pin)
38 #define P_UART(pin) _P_UART(CONFIG_UART_CONSOLE, pin)
40 #define pUART ((volatile struct bfin_mmr_serial *)uart_base)
43 __attribute__((always_inline))
44 static inline void serial_do_portmux(void);
47 #if BFIN_UART_HW_VER < 4
55 __attribute__((always_inline))
56 static inline void serial_do_portmux(void)
58 if (!BFIN_DEBUG_EARLY_SERIAL) {
59 const unsigned short pins[] = { P_UART(RX), P_UART(TX), 0, };
60 peripheral_request_list(pins, "bfin-uart");
64 serial_early_do_portmux();
67 #ifndef BFIN_IN_INITCODE
68 __attribute__((always_inline))
69 static inline void serial_early_puts(const char *s)
71 if (BFIN_DEBUG_EARLY_SERIAL) {
72 serial_puts("Early: ");
80 .macro serial_early_init
81 #ifdef CONFIG_DEBUG_EARLY_SERIAL
82 call _serial_initialize;
86 .macro serial_early_set_baud
87 #ifdef CONFIG_DEBUG_EARLY_SERIAL
88 R0.L = LO(CONFIG_BAUDRATE);
89 R0.H = HI(CONFIG_BAUDRATE);
90 call _serial_set_baud;
94 /* Since we embed the string right into our .text section, we need
95 * to find its address. We do this by getting our PC and adding 2
96 * bytes (which is the length of the jump instruction). Then we
97 * pass this address to serial_puts().
99 #ifdef CONFIG_DEBUG_EARLY_SERIAL
100 # define serial_early_puts(str) \
113 # define serial_early_puts(str)