From patchwork Mon Feb 15 12:13:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jun Nie X-Patchwork-Id: 8314121 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A76949F399 for ; Mon, 15 Feb 2016 12:24:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 69C5B20414 for ; Mon, 15 Feb 2016 12:24:17 +0000 (UTC) Received: from bombadil.infradead.org (unknown [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5C02F20303 for ; Mon, 15 Feb 2016 12:24:16 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aVI2v-0001XZ-6g; Mon, 15 Feb 2016 12:14:29 +0000 Received: from mail-pf0-x229.google.com ([2607:f8b0:400e:c00::229]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aVI2m-0001Rf-VZ for linux-arm-kernel@lists.infradead.org; Mon, 15 Feb 2016 12:14:23 +0000 Received: by mail-pf0-x229.google.com with SMTP id x65so86831911pfb.1 for ; Mon, 15 Feb 2016 04:14:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=9eEthiNMLM1K5t9rl+TbODvlH/RWlwhrFyE7TLhe7Q8=; b=DGjNL744uxMB3N4wcLfjoh6K/2qELXe9yq+fqgcLQRtRuy8gS/ABlcrZQoPGibR2Z+ E1JpMuIhbZK7Wr87o3FAMXvF6hlvbNsIKtsARNmJMFaWB/PDyyzaYPZznS9CrVPbdoSe N7N+IRrfk5bxFbaHEuSgyCcqXHU15KWuYsKxc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=9eEthiNMLM1K5t9rl+TbODvlH/RWlwhrFyE7TLhe7Q8=; b=B8L0NltVqAwVCr/2rETNuf9w/SfjEhDNKKCIKd/LAQnXu/3fwIKQtAW+NAB6UbS08I F5C+zOgvveWo7mQZNL1jGb0VrjuFFAtcCUz8mDj5tP+8kWTeeC+P44CjufKWR2L8Cqyf UpjVBUYuBqkOZ/0l/RZj3WvuoZh4NL7RaRZl69LdwyVlQS5+dAhZ20pQOTNEYr2TV1zy Sf8HHKNcMA8jWl7YPY/rBQfc5keb7JE3/g+qDIDlrpJieN9D/N7sccklCbG4DwjdnVxV 3dyoXBl7tUAs3+e20LVqEx/oZ0YE6paBanUdkt2FutrZM7XUZHmD7RKnXxgtWM6gBSWi lF3g== X-Gm-Message-State: AG10YOSgT8MYDFXVtwkZC3g+A+2t3nFcCQAFBSliXbQDiCuUCDPX0pDpRnSG9XzmAF7ikEPG X-Received: by 10.98.9.129 with SMTP id 1mr23131142pfj.163.1455538440076; Mon, 15 Feb 2016 04:14:00 -0800 (PST) Received: from localhost.localdomain (us1.aimitrade.com. [173.255.218.183]) by smtp.gmail.com with ESMTPSA id 76sm38242346pft.44.2016.02.15.04.13.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 15 Feb 2016 04:13:58 -0800 (PST) From: Jun Nie To: andre.przywara@arm.com, timur@codeaurora.org, linux@arm.linux.org.uk, graeme.gregory@linaro.org, peter@hurleysoftware.com, linux-arm-kernel@lists.infradead.org, linux-serial@vger.kernel.org, shawn.guo@linaro.org Subject: [PATCH 2/3] serial: amba-pl011: complete support to ZTE uart Date: Mon, 15 Feb 2016 20:13:13 +0800 Message-Id: <1455538393-7038-2-git-send-email-jun.nie@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1455538393-7038-1-git-send-email-jun.nie@linaro.org> References: <1455538393-7038-1-git-send-email-jun.nie@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160215_041421_235692_EA6D4AFF X-CRM114-Status: GOOD ( 14.82 ) X-Spam-Score: -2.0 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jason.liu@linaro.org, Jun Nie MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-3.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, RDNS_NONE, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Complete support to ZTE uart with adding specific registers mask. Signed-off-by: Jun Nie --- drivers/tty/serial/amba-pl011.c | 70 ++++++++++++++++++++++++++++++++++------- include/linux/amba/serial.h | 4 +++ 2 files changed, 62 insertions(+), 12 deletions(-) diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c index f52a243..72ae785 100644 --- a/drivers/tty/serial/amba-pl011.c +++ b/drivers/tty/serial/amba-pl011.c @@ -97,6 +97,10 @@ struct vendor_data { const u16 *reg_offset; const struct uart_ops *uart_pops; unsigned int ifls; + unsigned int fr_busy; + unsigned int fr_dsr; + unsigned int fr_cts; + unsigned int fr_ri; bool access_32b; bool oversampling; bool dma_threshold; @@ -115,6 +119,10 @@ static unsigned int get_fifosize_arm(struct amba_device *dev) static struct vendor_data vendor_arm = { .reg_offset = pl011_std_offsets, .ifls = UART011_IFLS_RX4_8|UART011_IFLS_TX4_8, + .fr_busy = UART01x_FR_BUSY, + .fr_dsr = UART01x_FR_DSR, + .fr_cts = UART01x_FR_CTS, + .fr_ri = UART011_FR_RI, .oversampling = false, .dma_threshold = false, .cts_event_workaround = false, @@ -130,6 +138,10 @@ static unsigned int get_fifosize_sbsa(struct amba_device *dev) static struct vendor_data vendor_sbsa = { .reg_offset = pl011_std_offsets, + .fr_busy = UART01x_FR_BUSY, + .fr_dsr = UART01x_FR_DSR, + .fr_cts = UART01x_FR_CTS, + .fr_ri = UART011_FR_RI, .uart_pops = &sbsa_uart_pops, .oversampling = false, .dma_threshold = false, @@ -174,6 +186,10 @@ static unsigned int get_fifosize_st(struct amba_device *dev) static struct vendor_data vendor_st = { .reg_offset = pl011_st_offsets, .ifls = UART011_IFLS_RX_HALF|UART011_IFLS_TX_HALF, + .fr_busy = UART01x_FR_BUSY, + .fr_dsr = UART01x_FR_DSR, + .fr_cts = UART01x_FR_CTS, + .fr_ri = UART011_FR_RI, .oversampling = true, .dma_threshold = true, .cts_event_workaround = true, @@ -198,12 +214,26 @@ static const u16 pl011_zte_offsets[REG_ARRAY_SIZE] = { [REG_DMACR] = ZX_UART011_DMACR, }; +static unsigned int get_fifosize_zte(struct amba_device *dev) +{ + return 16; +} + static struct vendor_data vendor_zte __maybe_unused = { .reg_offset = pl011_zte_offsets, .uart_pops = &amba_pl011_pops, .access_32b = true, .ifls = UART011_IFLS_RX4_8|UART011_IFLS_TX4_8, - .get_fifosize = get_fifosize_arm, + .fr_busy = ZX_UART01x_FR_BUSY, + .fr_dsr = ZX_UART01x_FR_DSR, + .fr_cts = ZX_UART01x_FR_CTS, + .fr_ri = ZX_UART011_FR_RI, + .oversampling = false, + .dma_threshold = false, + .cts_event_workaround = false, + .always_enabled = false, + .fixed_options = false, + .get_fifosize = get_fifosize_zte, }; /* Deals with DMA transactions */ @@ -248,6 +278,10 @@ struct uart_amba_port { unsigned int im; /* interrupt mask */ unsigned int old_status; unsigned int fifosize; /* vendor-specific */ + unsigned int fr_busy; /* vendor-specific */ + unsigned int fr_dsr; /* vendor-specific */ + unsigned int fr_cts; /* vendor-specific */ + unsigned int fr_ri; /* vendor-specific */ unsigned int old_cr; /* state during shutdown */ bool autorts; unsigned int fixed_baud; /* vendor-set fixed baud rate */ @@ -1178,7 +1212,7 @@ static void pl011_dma_shutdown(struct uart_amba_port *uap) return; /* Disable RX and TX DMA */ - while (pl011_read(uap, REG_FR) & UART01x_FR_BUSY) + while (pl011_read(uap, REG_FR) & uap->fr_busy) cpu_relax(); spin_lock_irq(&uap->port.lock); @@ -1427,11 +1461,11 @@ static void pl011_modem_status(struct uart_amba_port *uap) if (delta & UART01x_FR_DCD) uart_handle_dcd_change(&uap->port, status & UART01x_FR_DCD); - if (delta & UART01x_FR_DSR) + if (delta & uap->fr_dsr) uap->port.icount.dsr++; - if (delta & UART01x_FR_CTS) - uart_handle_cts_change(&uap->port, status & UART01x_FR_CTS); + if (delta & uap->fr_cts) + uart_handle_cts_change(&uap->port, status & uap->fr_cts); wake_up_interruptible(&uap->port.state->port.delta_msr_wait); } @@ -1504,7 +1538,7 @@ static unsigned int pl011_tx_empty(struct uart_port *port) struct uart_amba_port *uap = container_of(port, struct uart_amba_port, port); unsigned int status = pl011_read(uap, REG_FR); - return status & (UART01x_FR_BUSY|UART01x_FR_TXFF) ? 0 : TIOCSER_TEMT; + return status & (uap->fr_busy | UART01x_FR_TXFF) ? 0 : TIOCSER_TEMT; } static unsigned int pl011_get_mctrl(struct uart_port *port) @@ -1519,9 +1553,9 @@ static unsigned int pl011_get_mctrl(struct uart_port *port) result |= tiocmbit TIOCMBIT(UART01x_FR_DCD, TIOCM_CAR); - TIOCMBIT(UART01x_FR_DSR, TIOCM_DSR); - TIOCMBIT(UART01x_FR_CTS, TIOCM_CTS); - TIOCMBIT(UART011_FR_RI, TIOCM_RNG); + TIOCMBIT(uap->fr_dsr, TIOCM_DSR); + TIOCMBIT(uap->fr_cts, TIOCM_CTS); + TIOCMBIT(uap->fr_ri, TIOCM_RNG); #undef TIOCMBIT return result; } @@ -2200,7 +2234,7 @@ pl011_console_write(struct console *co, const char *s, unsigned int count) * Finally, wait for transmitter to become empty * and restore the TCR */ - while (pl011_read(uap, REG_FR) & UART01x_FR_BUSY) + while (pl011_read(uap, REG_FR) & uap->fr_busy) cpu_relax(); if (!uap->vendor->always_enabled) pl011_write(old_cr, uap, REG_CR); @@ -2482,8 +2516,12 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id) return PTR_ERR(uap->clk); uap->reg_offset = vendor->reg_offset; - uap->vendor = vendor; - uap->fifosize = vendor->get_fifosize(dev); + uap->vendor = vendor; + uap->fifosize = vendor->get_fifosize(dev); + uap->fr_busy = vendor->fr_busy; + uap->fr_dsr = vendor->fr_dsr; + uap->fr_cts = vendor->fr_cts; + uap->fr_ri = vendor->fr_ri; uap->port.iotype = vendor->access_32b ? UPIO_MEM32 : UPIO_MEM; uap->port.irq = dev->irq[0]; uap->port.ops = &amba_pl011_pops; @@ -2568,9 +2606,17 @@ static int pl011_uart_plat_probe(struct platform_device *pdev) if (!uap) return -ENOMEM; + uap->clk = devm_clk_get(&pdev->dev, NULL); + if (IS_ERR(uap->clk)) + return PTR_ERR(uap->clk); + uap->vendor = vendor; uap->reg_offset = vendor->reg_offset; uap->fifosize = vendor->get_fifosize(NULL); + uap->fr_busy = vendor_sbsa.fr_busy; + uap->fr_dsr = vendor_sbsa.fr_dsr; + uap->fr_cts = vendor_sbsa.fr_cts; + uap->fr_ri = vendor_sbsa.fr_ri; uap->port.iotype = vendor->access_32b ? UPIO_MEM32 : UPIO_MEM; uap->port.irq = platform_get_irq(pdev, 0); uap->port.ops = vendor->uart_pops; diff --git a/include/linux/amba/serial.h b/include/linux/amba/serial.h index d76a19b..750f2ef 100644 --- a/include/linux/amba/serial.h +++ b/include/linux/amba/serial.h @@ -103,6 +103,10 @@ #define UART01x_FR_DSR 0x002 #define UART01x_FR_CTS 0x001 #define UART01x_FR_TMSK (UART01x_FR_TXFF + UART01x_FR_BUSY) +#define ZX_UART01x_FR_BUSY 0x300 +#define ZX_UART01x_FR_DSR 0x008 +#define ZX_UART01x_FR_CTS 0x002 +#define ZX_UART011_FR_RI 0x001 #define UART011_CR_CTSEN 0x8000 /* CTS hardware flow control */ #define UART011_CR_RTSEN 0x4000 /* RTS hardware flow control */