From patchwork Mon Apr 15 20:24:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 162268 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp3370970jan; Mon, 15 Apr 2019 13:28:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqzoB3HqYfLSJ7lvugAg3Y7dqolzM1YfSIGyM+EUSKCPo8o1TSxik4g+njJwrmVYWIaSZg3x X-Received: by 2002:a65:4689:: with SMTP id h9mr73666918pgr.295.1555360092262; Mon, 15 Apr 2019 13:28:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555360092; cv=none; d=google.com; s=arc-20160816; b=NbsZhoLYH4rXBH6ww8lFPeYzJ/jPHWJFSm6fpMq6q9TNJyzkaZSxaSY6mpfrUKCGvA wTFFtCCtB0iEscWQ4b1BpWSaY/I553si2DnVVjmQrQFe/40LpfNq00606XOihsnL4E5u QkwxY2KozMTpFrEOkRSYfG2lNHtUPiX325oh4L42Z63qRK/Xren7pu+eeRdkdieH1gJT Dx6bkjl6h8EP4zHlCNNm03G+kemS1+ku5Nu15NSfqqdw4PX0ltumGFnB0yasaJqdG3/Q aCIajQHwnWDQ2q6wph4v6P98QBIqNhsBXVJN4Ct8fGEFhNVoOSCQ7wOqAWmOixJKzr7Z t9eQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=VlpKk+wltTauLPpHD0HRuf072EP9pkiRNmQy/8SgpX4=; b=HnZCvJg2O07domhMWT5SH0g23oC/XCRASqKrdMDz5GJj1C5o7HUYBwpxn7ILZq8wHv NPqAbqgbNOCjNZ3OVmKJ9/WWuw1kiCyrdTpPXs8PpteaKPhIOcMrThLsn/AHMU5KvaoN zsK6/oU2OpABhyo442ej2WjrRx/RLuSVnvLLV8N/PG5zaTZIDFYxWLCzjQaGiG7fn4MW dPSkEadBdmqeQ53r4RAVnNugKaS1Oc1pv0pcQDWDv2daxsbvHdzXGBI8A0W8bxjd3/ft v+BA1DKdHWfISz+6AMBJwQ75Ljb64wJ5ZnoM3E9V+anHExyO5JEAJ90SXyCgt2IsAxVP 5VnA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-serial-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-serial-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x6si45403916pga.310.2019.04.15.13.28.12; Mon, 15 Apr 2019 13:28:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-serial-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-serial-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-serial-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727913AbfDOU2L (ORCPT + 1 other); Mon, 15 Apr 2019 16:28:11 -0400 Received: from mout.kundenserver.de ([212.227.126.134]:49801 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726182AbfDOU2L (ORCPT ); Mon, 15 Apr 2019 16:28:11 -0400 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.129]) with ESMTPA (Nemesis) id 1N2lv2-1gqaYG3eI8-0133p3; Mon, 15 Apr 2019 22:28:00 +0200 From: Arnd Bergmann To: Greg Ungerer Cc: Linus Walleij , arm@kernel.org, Arnd Bergmann , Greg Kroah-Hartman , Jiri Slaby , linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/6] ARM: ks8695, serial: skip manual tx IRQ ack Date: Mon, 15 Apr 2019 22:24:17 +0200 Message-Id: <20190415202501.941196-5-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20190415202501.941196-1-arnd@arndb.de> References: <20190415202501.941196-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:fEwh5/IPHWOscGE54ScL7hGHn8WgdBcrjrH0vEu6XJJU5jU6x09 arQS3T+kqphfbWD9RyZq5xcWC84Df5vj/PtVzPPnjiSxR5RFTFivpoQJgGj5I7To3nszDES fje9eP5M3lRHm3MGKMIZUyuc3C4x5WPcQoc0AcAQfGQoQIq5h5Z4ByzsEqBxwhM62vwfLTt E5G2O2HjGZYXtHPGu41KQ== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:XEW0CJHj1Lw=:QOVt6hMFCo3Y1RyVLtmzuO r8RtNtuy7qnoXWN5A0UEl8mVlahrAxQnSDV7+3NifjLNIZUsvPmtU8IY2N2eQPfmWQoLBgjKx G+sCfNF7c0kDsUnmwvVluee0ScFzuXXQWXMhb6fGHe/7IVhDVoZo1SEPCv7w8xOTGfmVh+S6M VH8EHalWipmnbFmJfkOWS/OM+MeRogHYtXo7AcCZx6lOzHjG6OtYtQUNt48A8ksEJYAi4/4YR 8zs2tcDC+2bVI11tQpgNBGe8HoJeMUvZI6szzFs7KUBXy7KwDk09BH1g/Xgg8/lNsgk1ql9y2 AzZRCQ3H+UBIvE9T6QFUCLactN/7aBsN/Gmlvg5GXXpWfmiOtDh+GTFZUdNMP0JKl/S8xeeG+ Fu57+dYEJi1bhbku3O8qRg2V8wG59Fo2yYSx8ZLcEpNhbXqkAqto+Xej6zG54pUqvFIhQOsg/ UBZNrDSvtzowWaCEeFGlg2xRifCSrCL00mVudY++XHC4DsAFn6/Eq+04S+GCdz+MGkzN22qw+ ztybp5fu0vgotxjgoTOgECC/KYX1x6KAFtIFKZu2o5WevOyo6ByRxkjo84obT2lWY8WheMftB mVDTB+qsOCZSP2WDtWPvRNXAUdLEhZtB+cntllFg1dQQn+HxoP9ijpvTKzVAAgfuq7cyoA6Ef oXHyyWoGbXFp36Y6vfWkjkefOOQ9P/KbCTSjmL2V9LiGrY1y7k4F6KmBGZ/lMe/gnsl/9sGZn 8cSaMQEkDxQFLS51y30UyGraIplEtq6123J2eg== Sender: linux-serial-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org The TX interrupt is marked as edge triggered, so it will already be acked by the top-level irq code, and does not need the ack in the driver. Removing this avoids a nasty dependency on the regs-irq.h file that is otherwise reserved for the interrupt controller driver. Signed-off-by: Arnd Bergmann --- drivers/tty/serial/serial_ks8695.c | 5 ----- 1 file changed, 5 deletions(-) -- 2.20.0 diff --git a/drivers/tty/serial/serial_ks8695.c b/drivers/tty/serial/serial_ks8695.c index b461d791188c..6c5e9900e69d 100644 --- a/drivers/tty/serial/serial_ks8695.c +++ b/drivers/tty/serial/serial_ks8695.c @@ -21,7 +21,6 @@ #include #include -#include #if defined(CONFIG_SERIAL_KS8695_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) #define SUPPORT_SYSRQ @@ -52,8 +51,6 @@ #define UART_GET_BRDR(p) __raw_readl((p)->membase + KS8695_URBD) #define UART_PUT_BRDR(p, c) __raw_writel((c), (p)->membase + KS8695_URBD) -#define KS8695_CLR_TX_INT() __raw_writel(1 << KS8695_IRQ_UART_TX, KS8695_IRQ_VA + KS8695_INTST) - #define UART_DUMMY_LSR_RX 0x100 #define UART_PORT_SIZE (KS8695_USR - KS8695_URRB + 4) @@ -207,7 +204,6 @@ static irqreturn_t ks8695uart_tx_chars(int irq, void *dev_id) unsigned int count; if (port->x_char) { - KS8695_CLR_TX_INT(); UART_PUT_CHAR(port, port->x_char); port->icount.tx++; port->x_char = 0; @@ -221,7 +217,6 @@ static irqreturn_t ks8695uart_tx_chars(int irq, void *dev_id) count = 16; /* fifo size */ while (!uart_circ_empty(xmit) && (count-- > 0)) { - KS8695_CLR_TX_INT(); UART_PUT_CHAR(port, xmit->buf[xmit->tail]); xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1); From patchwork Mon Apr 15 20:24:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 162269 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp3371866jan; Mon, 15 Apr 2019 13:29:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqyN6UOFW5agoAV1yDUKGulKge6OnSqF9vShE/wP3/6hn+NKjlhkHnY8ASZi6FqaxKP6Z8pe X-Received: by 2002:a62:1197:: with SMTP id 23mr78933683pfr.210.1555360155031; Mon, 15 Apr 2019 13:29:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555360155; cv=none; d=google.com; s=arc-20160816; b=qKMRLEeB541Ad87/7kK/Ue0EtvYfeOFbktdfteOOc+aGOUx3EcjKw/zCzHQUn+CH2s KSypgj45A0Y0ivq4Q7RjLO8YoCDXIUGT7hJRWO1qIE6ZSam+TZ+0I/pS3Wofyu/qJHUu 3Cc0mhEVimQ/84kCbxIn6U1GIUl95rdz00yCF/UDiTjn7nXc42Yc5e7G18q8M8RSBxc3 jy5WZAhfyUl8Uu7kc1SjykMPxHTWlVQbyUctTZFDjxXpnt2pURcU2e5jwCEOQSayNCQh uC4oFI8xdVdGPORlYsOz86BiJyNm2fAxcwOMYpi7+rxQOHH56KYYKETlKmlVhOeJ1xIm Sfjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=b1jLCZyW7W7Rd2lx0WwdNji79DZfvGNIodXfbudzyWQ=; b=J+LlueGLnr5sOPTFuRXz9j3EVzJjmlht4xRoGrsf9AqzCI6pgH1JjJWALSuqJXIASE TMGM/CP4iN+DYhfqV+l6g+I+aX1lcqocQUrNEG4ifuzELywCl1uw5XHdiUPuIDs6SYIM xBn4lJd3AqCFCAWbIaqdNjDP6zuafJzO3OD+NEuWyV5iJfIQq9EXu0NzOnfXdi/NjXpN Offwun9YRe9FyhhSlI11cSz68fxgn43SyfdTV+xbkyzEQG61oIoMVEqO/f4YyQ6upAQH VbUvgewnmc4q4LgnPkFRLaJcekWBzAUuzsM/A9zozFDuO9M9lMbTSQAjjE8MpykoWUY/ IcrQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-serial-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-serial-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a1si46261015pff.258.2019.04.15.13.29.14; Mon, 15 Apr 2019 13:29:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-serial-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-serial-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-serial-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728180AbfDOU3O (ORCPT + 1 other); Mon, 15 Apr 2019 16:29:14 -0400 Received: from mout.kundenserver.de ([212.227.126.135]:56647 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728014AbfDOU3N (ORCPT ); Mon, 15 Apr 2019 16:29:13 -0400 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.129]) with ESMTPA (Nemesis) id 1MRTAj-1hSSRo2tld-00NPXk; Mon, 15 Apr 2019 22:28:57 +0200 From: Arnd Bergmann To: Greg Ungerer Cc: Linus Walleij , arm@kernel.org, Arnd Bergmann , Greg Kroah-Hartman , Jiri Slaby , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Subject: [PATCH 6/6] ARM: ks8695: split up uart register headers Date: Mon, 15 Apr 2019 22:24:18 +0200 Message-Id: <20190415202501.941196-6-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20190415202501.941196-1-arnd@arndb.de> References: <20190415202501.941196-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:KiiZGm8YYPg8G/jJRJdkMeVv/8SrVOCElJq1sII8vzv/hVVohtD PXnBQ9HYNT07JO6Geh3HLK0DKVIDH0XKqg2a+JWb7TnfhFUflyT3zoLpCzoEnqA6C7s2nDy Gjt/2VjQ0Ym97AlIwcyOTNcLvygxk3jZIRJBTKc7x2WpYJs2hfhW5jY6QNnwyc0mu2+7pil R5GijGm9Pd6Pa4JxzCxYw== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:DjLmN6oN0FM=:qsjUL+sa3Iq66tbf9oaXwS TGy0M39DsDx/w99FJjVK+Pi9xppysOLr7HeNzg2j3Wnp2jHsBqO3g/vRmq504chITM3yIxFfk MREELmQtY4xpG9dyCc4DDRqwr4yeuUOLKq7g9ynjh4dh7QOOVYzI6dDZVrd+zhb7jEZ3Q4bIF W0Nt2vl9g8UW/+ltxf91e3kzUyR7J+zlUY8AfgN+td9csRJiDdksRRLu6ootqOyB4jz/pZa3Y 82ZqgAt01S3mkeeeLT9N29MNtp8fkidIy9M+ICm+cXEeqVunmD860OERBPZvFu/vqUCOGS8c7 uR7rK7zkn6Kt3GGOWbRNHtK5a+0koNf5sf/xwhc0sW3LwF/vCrID0OjHwkyuC1du/bgOgoaxd ujbg9Ngjy85qalJXvX1x64OxG3lbYEjj8ueuLTslKc6iPdqX4ezY060yoDCslhwnIso3gsraN s3GNKb0x/TX/wHVFEndV7LbUF7svYUKvmZaPkvjBzlVp+rRSE2juDrXZm0hdQ/WQ+gKXMAU4H c5BVYBNM3Wq6DOQLlak5NJS+BptOI6xX5HWYk66Tis2wnNEwfH7sdRLUj8z0u6pnQN/JeEQlB 82NgMzYI0f2NBYPS9x6mNmDBAuDTpJnWGRksC2073/aDCZRl39d0y1FmLDuAhcl3KKN0mEY2e lf/Wi088SL52HIhXyOU8iamIHSAwKNZc1wt0kwNOqwqYlTugyMPu7L9RKqbs96cG2/fgWjgbi BjDYnYUef0zp+mERSUIpF59U3M7rsIDzCpXbgA== Sender: linux-serial-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org The uart driver is tightly coupled with the platform code, without real need. The uart registers can be moved into the driver itself (and the uncompress code), and instead of referring to the IRQ lines by number, we can generally use port->irq. Finally, the initialization of the uart_port structure gets moved into the platform code. This cannot use platform_data since we need it before console_init(), but map_io is called very early, and the data is all hardcoded. Signed-off-by: Arnd Bergmann --- arch/arm/mach-ks8695/cpu.c | 15 ++- arch/arm/mach-ks8695/devices.c | 2 +- arch/arm/mach-ks8695/include/mach/regs-uart.h | 92 ------------- .../arm/mach-ks8695/include/mach/uncompress.h | 16 ++- arch/arm/mach-ks8695/regs-uart.h | 19 +++ drivers/tty/serial/Kconfig | 2 +- drivers/tty/serial/serial_ks8695.c | 123 ++++++++++++++---- include/linux/platform_data/serial-ks8695.h | 10 ++ 8 files changed, 157 insertions(+), 122 deletions(-) delete mode 100644 arch/arm/mach-ks8695/include/mach/regs-uart.h create mode 100644 arch/arm/mach-ks8695/regs-uart.h create mode 100644 include/linux/platform_data/serial-ks8695.h -- 2.20.0 diff --git a/arch/arm/mach-ks8695/cpu.c b/arch/arm/mach-ks8695/cpu.c index 7eadf73c7e30..680b94641196 100644 --- a/arch/arm/mach-ks8695/cpu.c +++ b/arch/arm/mach-ks8695/cpu.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -32,7 +33,7 @@ #include "regs-sys.h" #include "regs-misc.h" - +#include "regs-uart.h" static struct map_desc ks8695_io_desc[] __initdata = { { @@ -64,10 +65,22 @@ static void __init ks8695_clock_info(void) sysclk[scdc] / 1000000, cpuclk[scdc] / 1000000); } +static void __init ks8695_serial_setup(void) +{ + if (!IS_ENABLED(CONFIG_SERIAL_KS8695)) + return; + + ks8695uart_ports[0].membase = KS8695_UART_VA; + ks8695uart_ports[0].mapbase = KS8695_UART_PA; + ks8695uart_ports[0].irq = KS8695_IRQ_UART_TX; /* actaully four IRQs */ + ks8695uart_ports[0].uartclk = KS8695_CLOCK_RATE * 16; +} + void __init ks8695_map_io(void) { iotable_init(ks8695_io_desc, ARRAY_SIZE(ks8695_io_desc)); ks8695_processor_info(); ks8695_clock_info(); + ks8695_serial_setup(); } diff --git a/arch/arm/mach-ks8695/devices.c b/arch/arm/mach-ks8695/devices.c index 6bd50a8f12f9..ba9d0f0f47ac 100644 --- a/arch/arm/mach-ks8695/devices.c +++ b/arch/arm/mach-ks8695/devices.c @@ -29,6 +29,7 @@ #include "regs-hpna.h" #include "regs-switch.h" #include "regs-misc.h" +#include "regs-uart.h" /* -------------------------------------------------------------------- * Ethernet @@ -191,7 +192,6 @@ static void __init ks8695_add_device_watchdog(void) platform_device_register(&ks8695_wdt_device); } - /* -------------------------------------------------------------------- */ /* diff --git a/arch/arm/mach-ks8695/include/mach/regs-uart.h b/arch/arm/mach-ks8695/include/mach/regs-uart.h deleted file mode 100644 index 8581fbc6245f..000000000000 --- a/arch/arm/mach-ks8695/include/mach/regs-uart.h +++ /dev/null @@ -1,92 +0,0 @@ -/* - * arch/arm/mach-ks8695/include/mach/regs-uart.h - * - * Copyright (C) 2006 Ben Dooks - * Copyright (C) 2006 Simtec Electronics - * - * KS8695 - UART register and bit definitions. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - */ - -#ifndef KS8695_UART_H -#define KS8695_UART_H - -#define KS8695_UART_OFFSET (0xF0000 + 0xE000) -#define KS8695_UART_VA (KS8695_IO_VA + KS8695_UART_OFFSET) -#define KS8695_UART_PA (KS8695_IO_PA + KS8695_UART_OFFSET) - - -/* - * UART registers - */ -#define KS8695_URRB (0x00) /* Receive Buffer Register */ -#define KS8695_URTH (0x04) /* Transmit Holding Register */ -#define KS8695_URFC (0x08) /* FIFO Control Register */ -#define KS8695_URLC (0x0C) /* Line Control Register */ -#define KS8695_URMC (0x10) /* Modem Control Register */ -#define KS8695_URLS (0x14) /* Line Status Register */ -#define KS8695_URMS (0x18) /* Modem Status Register */ -#define KS8695_URBD (0x1C) /* Baud Rate Divisor Register */ -#define KS8695_USR (0x20) /* Status Register */ - - -/* FIFO Control Register */ -#define URFC_URFRT (3 << 6) /* Receive FIFO Trigger Level */ -#define URFC_URFRT_1 (0 << 6) -#define URFC_URFRT_4 (1 << 6) -#define URFC_URFRT_8 (2 << 6) -#define URFC_URFRT_14 (3 << 6) -#define URFC_URTFR (1 << 2) /* Transmit FIFO Reset */ -#define URFC_URRFR (1 << 1) /* Receive FIFO Reset */ -#define URFC_URFE (1 << 0) /* FIFO Enable */ - -/* Line Control Register */ -#define URLC_URSBC (1 << 6) /* Set Break Condition */ -#define URLC_PARITY (7 << 3) /* Parity */ -#define URPE_NONE (0 << 3) -#define URPE_ODD (1 << 3) -#define URPE_EVEN (3 << 3) -#define URPE_MARK (5 << 3) -#define URPE_SPACE (7 << 3) -#define URLC_URSB (1 << 2) /* Stop Bits */ -#define URLC_URCL (3 << 0) /* Character Length */ -#define URCL_5 (0 << 0) -#define URCL_6 (1 << 0) -#define URCL_7 (2 << 0) -#define URCL_8 (3 << 0) - -/* Modem Control Register */ -#define URMC_URLB (1 << 4) /* Loop-back mode */ -#define URMC_UROUT2 (1 << 3) /* OUT2 signal */ -#define URMC_UROUT1 (1 << 2) /* OUT1 signal */ -#define URMC_URRTS (1 << 1) /* Request to Send */ -#define URMC_URDTR (1 << 0) /* Data Terminal Ready */ - -/* Line Status Register */ -#define URLS_URRFE (1 << 7) /* Receive FIFO Error */ -#define URLS_URTE (1 << 6) /* Transmit Empty */ -#define URLS_URTHRE (1 << 5) /* Transmit Holding Register Empty */ -#define URLS_URBI (1 << 4) /* Break Interrupt */ -#define URLS_URFE (1 << 3) /* Framing Error */ -#define URLS_URPE (1 << 2) /* Parity Error */ -#define URLS_URROE (1 << 1) /* Receive Overrun Error */ -#define URLS_URDR (1 << 0) /* Receive Data Ready */ - -/* Modem Status Register */ -#define URMS_URDCD (1 << 7) /* Data Carrier Detect */ -#define URMS_URRI (1 << 6) /* Ring Indicator */ -#define URMS_URDSR (1 << 5) /* Data Set Ready */ -#define URMS_URCTS (1 << 4) /* Clear to Send */ -#define URMS_URDDCD (1 << 3) /* Delta Data Carrier Detect */ -#define URMS_URTERI (1 << 2) /* Trailing Edge Ring Indicator */ -#define URMS_URDDST (1 << 1) /* Delta Data Set Ready */ -#define URMS_URDCTS (1 << 0) /* Delta Clear to Send */ - -/* Status Register */ -#define USR_UTI (1 << 0) /* Timeout Indication */ - - -#endif diff --git a/arch/arm/mach-ks8695/include/mach/uncompress.h b/arch/arm/mach-ks8695/include/mach/uncompress.h index a001c7c34df2..a8ae2e82dcf1 100644 --- a/arch/arm/mach-ks8695/include/mach/uncompress.h +++ b/arch/arm/mach-ks8695/include/mach/uncompress.h @@ -15,7 +15,21 @@ #define __ASM_ARCH_UNCOMPRESS_H #include -#include + +#define KS8695_UART_OFFSET (0xF0000 + 0xE000) +#define KS8695_UART_PA (KS8695_IO_PA + KS8695_UART_OFFSET) +#define KS8695_URRB (0x00) /* Receive Buffer Register */ +#define KS8695_URTH (0x04) /* Transmit Holding Register */ +#define KS8695_URFC (0x08) /* FIFO Control Register */ +#define KS8695_URLC (0x0C) /* Line Control Register */ +#define KS8695_URMC (0x10) /* Modem Control Register */ +#define KS8695_URLS (0x14) /* Line Status Register */ +#define KS8695_URMS (0x18) /* Modem Status Register */ +#define KS8695_URBD (0x1C) /* Baud Rate Divisor Register */ +#define KS8695_USR (0x20) /* Status Register */ + +#define URLS_URTE (1 << 6) +#define URLS_URTHRE (1 << 5) static inline void putc(char c) { diff --git a/arch/arm/mach-ks8695/regs-uart.h b/arch/arm/mach-ks8695/regs-uart.h new file mode 100644 index 000000000000..ab6c70e8fc7a --- /dev/null +++ b/arch/arm/mach-ks8695/regs-uart.h @@ -0,0 +1,19 @@ +/* + * Copyright (C) 2006 Ben Dooks + * Copyright (C) 2006 Simtec Electronics + * + * KS8695 - UART register and bit definitions. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#ifndef KS8695_UART_H +#define KS8695_UART_H + +#define KS8695_UART_OFFSET (0xF0000 + 0xE000) +#define KS8695_UART_VA (KS8695_IO_VA + KS8695_UART_OFFSET) +#define KS8695_UART_PA (KS8695_IO_PA + KS8695_UART_OFFSET) + +#endif diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig index 72966bc0ac76..bdb3fc987ea2 100644 --- a/drivers/tty/serial/Kconfig +++ b/drivers/tty/serial/Kconfig @@ -198,7 +198,7 @@ config SERIAL_KGDB_NMI config SERIAL_KS8695 bool "Micrel KS8695 (Centaur) serial port support" - depends on ARCH_KS8695 + depends on ARCH_KS8695 || COMPILE_TEST select SERIAL_CORE help This selects the Micrel Centaur KS8695 UART. Say Y here. diff --git a/drivers/tty/serial/serial_ks8695.c b/drivers/tty/serial/serial_ks8695.c index 6c5e9900e69d..6caad7e5ab74 100644 --- a/drivers/tty/serial/serial_ks8695.c +++ b/drivers/tty/serial/serial_ks8695.c @@ -15,12 +15,11 @@ #include #include #include +#include -#include -#include -#include +#include -#include +#include #if defined(CONFIG_SERIAL_KS8695_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) #define SUPPORT_SYSRQ @@ -34,6 +33,82 @@ #define SERIAL_KS8695_DEVNAME "ttyAM" #define SERIAL_KS8695_NR 1 +extern struct uart_port ks8695uart_ports[SERIAL_KS8695_NR]; + +/* + * UART registers + */ +#define KS8695_URRB (0x00) /* Receive Buffer Register */ +#define KS8695_URTH (0x04) /* Transmit Holding Register */ +#define KS8695_URFC (0x08) /* FIFO Control Register */ +#define KS8695_URLC (0x0C) /* Line Control Register */ +#define KS8695_URMC (0x10) /* Modem Control Register */ +#define KS8695_URLS (0x14) /* Line Status Register */ +#define KS8695_URMS (0x18) /* Modem Status Register */ +#define KS8695_URBD (0x1C) /* Baud Rate Divisor Register */ +#define KS8695_USR (0x20) /* Status Register */ + + +/* FIFO Control Register */ +#define URFC_URFRT (3 << 6) /* Receive FIFO Trigger Level */ +#define URFC_URFRT_1 (0 << 6) +#define URFC_URFRT_4 (1 << 6) +#define URFC_URFRT_8 (2 << 6) +#define URFC_URFRT_14 (3 << 6) +#define URFC_URTFR (1 << 2) /* Transmit FIFO Reset */ +#define URFC_URRFR (1 << 1) /* Receive FIFO Reset */ +#define URFC_URFE (1 << 0) /* FIFO Enable */ + +/* Line Control Register */ +#define URLC_URSBC (1 << 6) /* Set Break Condition */ +#define URLC_PARITY (7 << 3) /* Parity */ +#define URPE_NONE (0 << 3) +#define URPE_ODD (1 << 3) +#define URPE_EVEN (3 << 3) +#define URPE_MARK (5 << 3) +#define URPE_SPACE (7 << 3) +#define URLC_URSB (1 << 2) /* Stop Bits */ +#define URLC_URCL (3 << 0) /* Character Length */ +#define URCL_5 (0 << 0) +#define URCL_6 (1 << 0) +#define URCL_7 (2 << 0) +#define URCL_8 (3 << 0) + +/* Modem Control Register */ +#define URMC_URLB (1 << 4) /* Loop-back mode */ +#define URMC_UROUT2 (1 << 3) /* OUT2 signal */ +#define URMC_UROUT1 (1 << 2) /* OUT1 signal */ +#define URMC_URRTS (1 << 1) /* Request to Send */ +#define URMC_URDTR (1 << 0) /* Data Terminal Ready */ + +/* Line Status Register */ +#define URLS_URRFE (1 << 7) /* Receive FIFO Error */ +#define URLS_URTE (1 << 6) /* Transmit Empty */ +#define URLS_URTHRE (1 << 5) /* Transmit Holding Register Empty */ +#define URLS_URBI (1 << 4) /* Break Interrupt */ +#define URLS_URFE (1 << 3) /* Framing Error */ +#define URLS_URPE (1 << 2) /* Parity Error */ +#define URLS_URROE (1 << 1) /* Receive Overrun Error */ +#define URLS_URDR (1 << 0) /* Receive Data Ready */ + +/* Modem Status Register */ +#define URMS_URDCD (1 << 7) /* Data Carrier Detect */ +#define URMS_URRI (1 << 6) /* Ring Indicator */ +#define URMS_URDSR (1 << 5) /* Data Set Ready */ +#define URMS_URCTS (1 << 4) /* Clear to Send */ +#define URMS_URDDCD (1 << 3) /* Delta Data Carrier Detect */ +#define URMS_URTERI (1 << 2) /* Trailing Edge Ring Indicator */ +#define URMS_URDDST (1 << 1) /* Delta Data Set Ready */ +#define URMS_URDCTS (1 << 0) /* Delta Clear to Send */ + +/* Status Register */ +#define USR_UTI (1 << 0) /* Timeout Indication */ + + +#define IRQ_TX 0 +#define IRQ_RX 1 +#define IRQ_LINE_STATUS 2 +#define IRQ_MODEM_STATUS 3 /* * Access macros for the KS8695 UART @@ -105,7 +180,7 @@ static void ks8695uart_stop_tx(struct uart_port *port) * imposed deadlock by not waiting for irq handler to end, * since this ks8695uart_stop_tx() is called from interrupt context. */ - disable_irq_nosync(KS8695_IRQ_UART_TX); + disable_irq_nosync(port->irq + IRQ_TX); tx_enable(port, 0); } } @@ -113,7 +188,7 @@ static void ks8695uart_stop_tx(struct uart_port *port) static void ks8695uart_start_tx(struct uart_port *port) { if (!tx_enabled(port)) { - enable_irq(KS8695_IRQ_UART_TX); + enable_irq(port->irq + IRQ_TX); tx_enable(port, 1); } } @@ -121,7 +196,7 @@ static void ks8695uart_start_tx(struct uart_port *port) static void ks8695uart_stop_rx(struct uart_port *port) { if (rx_enabled(port)) { - disable_irq(KS8695_IRQ_UART_RX); + disable_irq(port->irq + IRQ_RX); rx_enable(port, 0); } } @@ -129,7 +204,7 @@ static void ks8695uart_stop_rx(struct uart_port *port) static void ks8695uart_enable_ms(struct uart_port *port) { if (!ms_enabled(port)) { - enable_irq(KS8695_IRQ_UART_MODEM_STATUS); + enable_irq(port->irq + IRQ_MODEM_STATUS); ms_enable(port,1); } } @@ -137,7 +212,7 @@ static void ks8695uart_enable_ms(struct uart_port *port) static void ks8695uart_disable_ms(struct uart_port *port) { if (ms_enabled(port)) { - disable_irq(KS8695_IRQ_UART_MODEM_STATUS); + disable_irq(port->irq + IRQ_MODEM_STATUS); ms_enable(port,0); } } @@ -318,7 +393,7 @@ static int ks8695uart_startup(struct uart_port *port) { int retval; - irq_modify_status(KS8695_IRQ_UART_TX, IRQ_NOREQUEST, IRQ_NOAUTOEN); + irq_modify_status(port->irq + IRQ_TX, IRQ_NOREQUEST, IRQ_NOAUTOEN); tx_enable(port, 0); rx_enable(port, 1); ms_enable(port, 1); @@ -326,30 +401,30 @@ static int ks8695uart_startup(struct uart_port *port) /* * Allocate the IRQ */ - retval = request_irq(KS8695_IRQ_UART_TX, ks8695uart_tx_chars, 0, "UART TX", port); + retval = request_irq(port->irq + IRQ_TX, ks8695uart_tx_chars, 0, "UART TX", port); if (retval) goto err_tx; - retval = request_irq(KS8695_IRQ_UART_RX, ks8695uart_rx_chars, 0, "UART RX", port); + retval = request_irq(port->irq + IRQ_RX, ks8695uart_rx_chars, 0, "UART RX", port); if (retval) goto err_rx; - retval = request_irq(KS8695_IRQ_UART_LINE_STATUS, ks8695uart_rx_chars, 0, "UART LineStatus", port); + retval = request_irq(port->irq + IRQ_LINE_STATUS, ks8695uart_rx_chars, 0, "UART LineStatus", port); if (retval) goto err_ls; - retval = request_irq(KS8695_IRQ_UART_MODEM_STATUS, ks8695uart_modem_status, 0, "UART ModemStatus", port); + retval = request_irq(port->irq + IRQ_MODEM_STATUS, ks8695uart_modem_status, 0, "UART ModemStatus", port); if (retval) goto err_ms; return 0; err_ms: - free_irq(KS8695_IRQ_UART_LINE_STATUS, port); + free_irq(port->irq + IRQ_LINE_STATUS, port); err_ls: - free_irq(KS8695_IRQ_UART_RX, port); + free_irq(port->irq + IRQ_RX, port); err_rx: - free_irq(KS8695_IRQ_UART_TX, port); + free_irq(port->irq + IRQ_TX, port); err_tx: return retval; } @@ -359,10 +434,10 @@ static void ks8695uart_shutdown(struct uart_port *port) /* * Free the interrupt */ - free_irq(KS8695_IRQ_UART_RX, port); - free_irq(KS8695_IRQ_UART_TX, port); - free_irq(KS8695_IRQ_UART_MODEM_STATUS, port); - free_irq(KS8695_IRQ_UART_LINE_STATUS, port); + free_irq(port->irq + IRQ_TX, port); + free_irq(port->irq + IRQ_RX, port); + free_irq(port->irq + IRQ_MODEM_STATUS, port); + free_irq(port->irq + IRQ_LINE_STATUS, port); /* disable break condition and fifos */ UART_PUT_LCR(port, UART_GET_LCR(port) & ~URLC_URSBC); @@ -535,13 +610,9 @@ static struct uart_ops ks8695uart_pops = { .verify_port = ks8695uart_verify_port, }; -static struct uart_port ks8695uart_ports[SERIAL_KS8695_NR] = { +struct uart_port ks8695uart_ports[SERIAL_KS8695_NR] = { { - .membase = KS8695_UART_VA, - .mapbase = KS8695_UART_PA, .iotype = SERIAL_IO_MEM, - .irq = KS8695_IRQ_UART_TX, - .uartclk = KS8695_CLOCK_RATE * 16, .fifosize = 16, .ops = &ks8695uart_pops, .flags = UPF_BOOT_AUTOCONF, diff --git a/include/linux/platform_data/serial-ks8695.h b/include/linux/platform_data/serial-ks8695.h new file mode 100644 index 000000000000..ade3f0a03a75 --- /dev/null +++ b/include/linux/platform_data/serial-ks8695.h @@ -0,0 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0+ +#ifndef _LINUX_PLATFORM_DATA_SERIAL_KS8695 +#define _LINUX_PLATFORM_DATA_SERIAL_KS8695 + +#include + +#define SERIAL_KS8695_NR 1 +extern struct uart_port ks8695uart_ports[SERIAL_KS8695_NR]; + +#endif