From patchwork Tue Jun 23 21:39:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 487808 X-Patchwork-Delegate: sjg@chromium.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 E817914012C for ; Wed, 24 Jun 2015 07:45:11 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b=b8b4uhlq; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id CA6E14B6A2; Tue, 23 Jun 2015 23:43:30 +0200 (CEST) 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 Ao4jq49pJpdj; Tue, 23 Jun 2015 23:43:30 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 10ED44B758; Tue, 23 Jun 2015 23:42:27 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 564C14B67F for ; Tue, 23 Jun 2015 23:40:29 +0200 (CEST) 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 oBOZWrPKSisa for ; Tue, 23 Jun 2015 23:40:29 +0200 (CEST) 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 mail-ig0-f175.google.com (mail-ig0-f175.google.com [209.85.213.175]) by theia.denx.de (Postfix) with ESMTPS id 253914B6BA for ; Tue, 23 Jun 2015 23:40:03 +0200 (CEST) Received: by igboe5 with SMTP id oe5so99845980igb.1 for ; Tue, 23 Jun 2015 14:40:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=+gNdUaVt8jX04IFrg7bYJBpa7wGvk2qINZMJkxEIvFI=; b=b8b4uhlq5+hX7SxkL1IYAv2vegp4dQCEYzctR8J9JbwA/QXpNc+nNn+ABlqCr8iBQY BaTy+73h/3Jj3XzPyh33ogCRc7p7WGwc0Fb1jg8rXWMxChXB4oJ1yca+qmVQ18act0rE u03MAwkTeUUI5NQxLwX6W4Nq/x+Dco79H41IpsVtyo4BklGlvcaM+Iv3qV21+HMW94AK sCfrNKXMZcI6QlTlvDGboKSsHBwT3HquluQEBVUh0d5b7cKniCWRDQjvg/YIWjW5h0Pu y699eTARs54JCeItghF0UpUy53yoyjvJ42CHzGVI8Whf3YS/xyiUGh2b/E04rv22RZN3 YpzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=+gNdUaVt8jX04IFrg7bYJBpa7wGvk2qINZMJkxEIvFI=; b=Lq2OaBsSQmJ4z8JHAOJKLeq9GJ98ma1v9ambCcoh2es951NYahFPcJVhPWbbRFrLrE 6hFnOaIZuFkte/r/Q43vWFO7DfC07pf6BLDo/JeNHAIrRK1+sQpa2HZMUtxcKeJiKrMu vGTWMicd3iF2IpJa81KUC23hkG9Rt1sxn50CQuzM7UTZqg375l3AEa7iiJTCRSUvMlkK 2++xmWkDI6tRISMm2gWZ6dUjp477FhdcZpBl7Osf7iap8awuP5febP9ojjlwHb/dlCxe 49cimmAdm/RBil37jEowgtooopSVaAgoNJzlHxvYzoPdqQUkEYqcYdEPMN79JDfXZjQi N/HQ== X-Gm-Message-State: ALoCoQk/IoScCLoIpKcT1wfl6SaRRK4mcZlAIECZfpNIiaNT1O17j7g3Y8px7gzPHQVRXleUIped X-Received: by 10.50.13.10 with SMTP id d10mr5051509igc.20.1435095602652; Tue, 23 Jun 2015 14:40:02 -0700 (PDT) Received: from kaki.bld.corp.google.com ([172.29.216.32]) by mx.google.com with ESMTPSA id w4sm589920igl.22.2015.06.23.14.39.59 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Jun 2015 14:40:00 -0700 (PDT) Received: by kaki.bld.corp.google.com (Postfix, from userid 121222) id 4A704222126; Tue, 23 Jun 2015 15:39:53 -0600 (MDT) From: Simon Glass To: U-Boot Mailing List Date: Tue, 23 Jun 2015 15:39:06 -0600 Message-Id: <1435095556-15924-45-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 2.4.3.573.g4eafbef In-Reply-To: <1435095556-15924-1-git-send-email-sjg@chromium.org> References: <1435095556-15924-1-git-send-email-sjg@chromium.org> Cc: Tom Rini , Przemyslaw Marczak Subject: [U-Boot] [PATCH v3 44/54] ns16550: Improve debug UART so it can work with 32-bit access X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Since Rockchip requires 32-bit serial access, add this to the driver. Refactor a little to make this easier. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None drivers/serial/ns16550.c | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/drivers/serial/ns16550.c b/drivers/serial/ns16550.c index 9b044a3..c8a77e2 100644 --- a/drivers/serial/ns16550.c +++ b/drivers/serial/ns16550.c @@ -246,6 +246,17 @@ int NS16550_tstc(NS16550_t com_port) #include +#define serial_dout(reg, value) \ + serial_out_shift((char *)com_port + \ + ((char *)reg - (char *)com_port) * \ + (1 << CONFIG_DEBUG_UART_SHIFT), \ + CONFIG_DEBUG_UART_SHIFT, value) +#define serial_din(reg) \ + serial_in_shift((char *)com_port + \ + ((char *)reg - (char *)com_port) * \ + (1 << CONFIG_DEBUG_UART_SHIFT), \ + CONFIG_DEBUG_UART_SHIFT) + void debug_uart_init(void) { struct NS16550 *com_port = (struct NS16550 *)CONFIG_DEBUG_UART_BASE; @@ -259,28 +270,23 @@ void debug_uart_init(void) */ baud_divisor = calc_divisor(com_port, CONFIG_DEBUG_UART_CLOCK, CONFIG_BAUDRATE); - serial_out_shift(&com_port->ier, CONFIG_DEBUG_UART_SHIFT, - CONFIG_SYS_NS16550_IER); - serial_out_shift(&com_port->mcr, CONFIG_DEBUG_UART_SHIFT, UART_MCRVAL); - serial_out_shift(&com_port->fcr, CONFIG_DEBUG_UART_SHIFT, UART_FCRVAL); - - serial_out_shift(&com_port->lcr, CONFIG_DEBUG_UART_SHIFT, - UART_LCR_BKSE | UART_LCRVAL); - serial_out_shift(&com_port->dll, CONFIG_DEBUG_UART_SHIFT, - baud_divisor & 0xff); - serial_out_shift(&com_port->dlm, CONFIG_DEBUG_UART_SHIFT, - (baud_divisor >> 8) & 0xff); - serial_out_shift(&com_port->lcr, CONFIG_DEBUG_UART_SHIFT, - UART_LCRVAL); + serial_dout(&com_port->ier, CONFIG_SYS_NS16550_IER); + serial_dout(&com_port->mcr, UART_MCRVAL); + serial_dout(&com_port->fcr, UART_FCRVAL); + + serial_dout(&com_port->lcr, UART_LCR_BKSE | UART_LCRVAL); + serial_dout(&com_port->dll, baud_divisor & 0xff); + serial_dout(&com_port->dlm, (baud_divisor >> 8) & 0xff); + serial_dout(&com_port->lcr, UART_LCRVAL); } static inline void _debug_uart_putc(int ch) { struct NS16550 *com_port = (struct NS16550 *)CONFIG_DEBUG_UART_BASE; - while (!(serial_in_shift(&com_port->lsr, 0) & UART_LSR_THRE)) + while (!(serial_din(&com_port->lsr) & UART_LSR_THRE)) ; - serial_out_shift(&com_port->thr, CONFIG_DEBUG_UART_SHIFT, ch); + serial_dout(&com_port->thr, ch); } DEBUG_UART_FUNCS