From patchwork Mon Dec 27 04:48:03 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Frysinger X-Patchwork-Id: 76742 X-Patchwork-Delegate: vapier@gentoo.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 36AFBB708B for ; Mon, 27 Dec 2010 15:43:54 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 2A52D280D6; Mon, 27 Dec 2010 05:43:09 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Vg2hII0NDiVd; Mon, 27 Dec 2010 05:43:08 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 6C266280D8; Mon, 27 Dec 2010 05:41:56 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 6219628085 for ; Mon, 27 Dec 2010 05:41:41 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id n3yHeRRFzevu for ; Mon, 27 Dec 2010 05:41:41 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by theia.denx.de (Postfix) with ESMTPS id CF2F128080 for ; Mon, 27 Dec 2010 05:41:36 +0100 (CET) Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id C81EE1B408E for ; Mon, 27 Dec 2010 04:41:34 +0000 (UTC) From: Mike Frysinger To: u-boot@lists.denx.de Date: Sun, 26 Dec 2010 23:48:03 -0500 Message-Id: <1293425300-27644-12-git-send-email-vapier@gentoo.org> X-Mailer: git-send-email 1.7.3.4 In-Reply-To: <1293425300-27644-1-git-send-email-vapier@gentoo.org> References: <1293425300-27644-1-git-send-email-vapier@gentoo.org> Subject: [U-Boot] [PATCH 11/28] Blackfin: serial: clean up muxing a bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Signed-off-by: Mike Frysinger --- arch/blackfin/cpu/serial.h | 51 +++++++++++++++++-------------------------- 1 files changed, 20 insertions(+), 31 deletions(-) diff --git a/arch/blackfin/cpu/serial.h b/arch/blackfin/cpu/serial.h index f9e311f..b0cf09a 100644 --- a/arch/blackfin/cpu/serial.h +++ b/arch/blackfin/cpu/serial.h @@ -74,23 +74,19 @@ struct bfin_mmr_serial { }; #undef __BFP -#ifndef UART_LSR -# if (CONFIG_UART_CONSOLE == 3) -# define UART_BASE UART3_DLL -# elif (CONFIG_UART_CONSOLE == 2) -# define UART_BASE UART2_DLL -# elif (CONFIG_UART_CONSOLE == 1) -# define UART_BASE UART1_DLL -# elif (CONFIG_UART_CONSOLE == 0) -# define UART_BASE UART0_DLL -# endif +#define __PASTE_UART(num, pfx, sfx) pfx##num##_##sfx +#define _PASTE_UART(num, pfx, sfx) __PASTE_UART(num, pfx, sfx) +#define MMR_UART(mmr) _PASTE_UART(CONFIG_UART_CONSOLE, UART, DLL) +#define P_UART(pin) _PASTE_UART(CONFIG_UART_CONSOLE, P_UART, pin) + +#ifndef UART_DLL +# define UART_DLL MMR_UART(DLL) #else # if CONFIG_UART_CONSOLE != 0 # error CONFIG_UART_CONSOLE must be 0 on parts with only one UART # endif -# define UART_BASE UART_DLL #endif -#define pUART ((volatile struct bfin_mmr_serial *)UART_BASE) +#define pUART ((volatile struct bfin_mmr_serial *)UART_DLL) #ifdef __ADSPBF54x__ # define ACCESS_LATCH() @@ -106,18 +102,7 @@ __attribute__((always_inline)) static inline void serial_do_portmux(void) { if (!BFIN_DEBUG_EARLY_SERIAL) { - const unsigned short pins[] = { -#if CONFIG_UART_CONSOLE == 0 - P_UART0_TX, P_UART0_RX, -#elif CONFIG_UART_CONSOLE == 1 - P_UART1_TX, P_UART1_RX, -#elif CONFIG_UART_CONSOLE == 2 - P_UART2_TX, P_UART2_RX, -#elif CONFIG_UART_CONSOLE == 3 - P_UART3_TX, P_UART3_RX, -#endif - 0, - }; + const unsigned short pins[] = { P_UART(RX), P_UART(TX), 0, }; peripheral_request_list(pins, "bfin-uart"); return; } @@ -141,13 +126,11 @@ static inline void serial_do_portmux(void) } SSYNC(); #elif defined(__ADSPBF537__) || defined(__ADSPBF536__) || defined(__ADSPBF534__) -# define DO_MUX(func, tx, rx) \ - bfin_write_PORT_MUX(bfin_read_PORT_MUX() & ~(func)); \ - bfin_write_PORTF_FER(bfin_read_PORTF_FER() | PF##tx | PF##rx); - switch (CONFIG_UART_CONSOLE) { - case 0: DO_MUX(PFDE, 0, 1); break; - case 1: DO_MUX(PFTE, 2, 3); break; - } + const uint16_t func[] = { PFDE, PFTE, }; + bfin_write_PORT_MUX(bfin_read_PORT_MUX() & ~func[CONFIG_UART_CONSOLE]); + bfin_write_PORTF_FER(bfin_read_PORTF_FER() | + (1 << P_IDENT(P_UART(RX))) | + (1 << P_IDENT(P_UART(TX)))); SSYNC(); #elif defined(__ADSPBF54x__) # define DO_MUX(port, tx, rx) \ @@ -160,6 +143,12 @@ static inline void serial_do_portmux(void) case 3: DO_MUX(B, 6, 7); break; /* Port B; PB6 and PB7 */ } SSYNC(); +#elif defined(__ADSPBF561__) + /* UART pins could be GPIO, but they aren't pin muxed. */ +#else +# if (P_UART(RX) & P_DEFINED) || (P_UART(TX) & P_DEFINED) +# error "missing portmux logic for UART" +# endif #endif }