From patchwork Mon Sep 26 12:26:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabian Vogt X-Patchwork-Id: 675154 X-Patchwork-Delegate: trini@ti.com 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 3sjPP01yhBz9s65 for ; Mon, 26 Sep 2016 23:06:28 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 1DDCAA76A5; Mon, 26 Sep 2016 15:05: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 wFAXH_jBg6x7; Mon, 26 Sep 2016 15:05:29 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B7C5BA75DE; Mon, 26 Sep 2016 15:04:47 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 04E02A7573 for ; Mon, 26 Sep 2016 14:47:51 +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 WAEJHQUvuNNg for ; Mon, 26 Sep 2016 14:47:50 +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 smtp.nue.novell.com (smtp.nue.novell.com [195.135.221.5]) by theia.denx.de (Postfix) with ESMTPS id 10677A7527 for ; Mon, 26 Sep 2016 14:47:45 +0200 (CEST) Received: from nwb-ext-pat.microfocus.com ([10.120.13.103]) by smtp.nue.novell.com with ESMTP (TLS encrypted); Mon, 26 Sep 2016 14:27:43 +0200 Received: from linux-lm3i.site (nwb-a10-snat.microfocus.com [10.120.13.201]) by nwb-ext-pat.microfocus.com with ESMTP (TLS encrypted); Mon, 26 Sep 2016 13:27:30 +0100 From: Fabian Vogt To: u-boot@lists.denx.de Date: Mon, 26 Sep 2016 14:26:49 +0200 Message-Id: <20160926122651.22132-8-fvogt@suse.com> X-Mailer: git-send-email 2.10.0 In-Reply-To: <20160926122651.22132-1-fvogt@suse.com> References: <20160926122651.22132-1-fvogt@suse.com> X-Mailman-Approved-At: Mon, 26 Sep 2016 15:04:20 +0200 Subject: [U-Boot] [PATCH 7/9] serial: bcm283x_mu: support disabling after initialization 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" For the Raspberry Pi 3 it needs to be possible to disable the serial device after initialization happens, as only after the GPIO device is available it is known whether the mini uart is usable. Signed-off-by: Fabian Vogt Reviewed-by: Simon Glass --- drivers/serial/serial_bcm283x_mu.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/serial/serial_bcm283x_mu.c b/drivers/serial/serial_bcm283x_mu.c index e361909..3884f74 100644 --- a/drivers/serial/serial_bcm283x_mu.c +++ b/drivers/serial/serial_bcm283x_mu.c @@ -59,7 +59,7 @@ static int bcm283x_mu_serial_setbrg(struct udevice *dev, int baudrate) struct bcm283x_mu_regs *regs = priv->regs; u32 divider; - if (plat->skip_init) + if (plat->disabled || plat->skip_init) return 0; divider = plat->clock / (baudrate * 8); @@ -85,10 +85,14 @@ static int bcm283x_mu_serial_probe(struct udevice *dev) static int bcm283x_mu_serial_getc(struct udevice *dev) { + struct bcm283x_mu_serial_platdata *plat = dev_get_platdata(dev); struct bcm283x_mu_priv *priv = dev_get_priv(dev); struct bcm283x_mu_regs *regs = priv->regs; u32 data; + if (plat->disabled) + return -EAGAIN; + /* Wait until there is data in the FIFO */ if (!(readl(®s->lsr) & BCM283X_MU_LSR_RX_READY)) return -EAGAIN; @@ -100,9 +104,13 @@ static int bcm283x_mu_serial_getc(struct udevice *dev) static int bcm283x_mu_serial_putc(struct udevice *dev, const char data) { + struct bcm283x_mu_serial_platdata *plat = dev_get_platdata(dev); struct bcm283x_mu_priv *priv = dev_get_priv(dev); struct bcm283x_mu_regs *regs = priv->regs; + if (plat->disabled) + return 0; + /* Wait until there is space in the FIFO */ if (!(readl(®s->lsr) & BCM283X_MU_LSR_TX_EMPTY)) return -EAGAIN; @@ -115,9 +123,15 @@ static int bcm283x_mu_serial_putc(struct udevice *dev, const char data) static int bcm283x_mu_serial_pending(struct udevice *dev, bool input) { + struct bcm283x_mu_serial_platdata *plat = dev_get_platdata(dev); struct bcm283x_mu_priv *priv = dev_get_priv(dev); struct bcm283x_mu_regs *regs = priv->regs; - unsigned int lsr = readl(®s->lsr); + unsigned int lsr; + + if (plat->disabled) + return 0; + + lsr = readl(®s->lsr); if (input) { WATCHDOG_RESET();