Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp317789ybb; Fri, 3 Apr 2020 03:21:39 -0700 (PDT) X-Google-Smtp-Source: APiQypLGc/CmW9XtbCGfrIyS3WEYQyQwadflZiMciMAQIg6SnoLgPdHhmNp7LY3jSaWo/yKulKhy X-Received: by 2002:a9d:6b98:: with SMTP id b24mr5569694otq.242.1585909299558; Fri, 03 Apr 2020 03:21:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585909299; cv=none; d=google.com; s=arc-20160816; b=C4MjepTNrhkOxoGBxu0muJol1ZruH8FImAsK6p/3flzeOcVHip0dlx5W9OIDKfRDKt Bu0RSEavQD/f8WGvc5SekWlNOpKjWavklDMpT9MKX69n9wBgyTThBE76sD3ITFdNArgr enq5/g7AmRQ4GI/WZRLoxJIS4Zirv+8sKNf5ejW3+hRFSMISwx/Ww43D2W9OKNLVQ5Fj 4J6KhLmreYjwzRU5Dl7ZClBjN9Mn4+DEfgolpgui02aJ6jEnK1gG8UTd7n428j0bJkqT ihukqmucb/m/wTzVKY3FwisChkeDtmdWfnF6JeNat+xzSfdNBNqQZ+55T4KqTI2ePqqf La+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:dlp-filter:cms-type :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :dkim-filter; bh=gWnByIF2TF7BpHpZ8lBqenOh9TPRH1yh+ZUfFe4lVHE=; b=1FO8DoqCo8QrYORSz8iNshlE9pJsaQl43mlpqTujg3zK0HpIfutI1giBrIrSKMRJwH LLVKj7xgCNJtQOQLtmWzn+wmuu+cXuW7pj6czOoMi21pQLeyai1az4WoR18ruFQSFxI4 K64vu310I4U1qbZNWH5YS6v1yi3KS+5dlyoWcZ0s0sGbDGQG4q6OYoRLeIQIOK84J2yg XlALJr8PqyQMji/DpiOeWHZkMPiolLv5hHloDM7bbx3hz80hxXuE0VMPYccksSS2K95b XnvMmTpz0jX95rKhWZBMujKQZCjshn17k3NmrcSpK9WUSHka4i7fB5nVw5ymoB+12fCT V/6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=YpfcSXCY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z17si3634846oth.282.2020.04.03.03.21.27; Fri, 03 Apr 2020 03:21:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=YpfcSXCY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727898AbgDCKUz (ORCPT + 99 others); Fri, 3 Apr 2020 06:20:55 -0400 Received: from mailout2.samsung.com ([203.254.224.25]:22234 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727792AbgDCKUz (ORCPT ); Fri, 3 Apr 2020 06:20:55 -0400 Received: from epcas2p4.samsung.com (unknown [182.195.41.56]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20200403102053epoutp02fda0827bb34afe98027fbd2f17293469~CSBA6BCIc1004910049epoutp02j for ; Fri, 3 Apr 2020 10:20:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20200403102053epoutp02fda0827bb34afe98027fbd2f17293469~CSBA6BCIc1004910049epoutp02j DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1585909253; bh=gWnByIF2TF7BpHpZ8lBqenOh9TPRH1yh+ZUfFe4lVHE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YpfcSXCY4wUj9Z6R6RE4h5keD3/wPNZ4OfJAC7AJKBBkzjFSl7hjFjb4ypZtiDjFF MEt2/qhdlsa4p6tk3CP05sKQBE/rzGTNBt61ur6eDkr9n4jELmA5eYOoROo/aoFjfo WsoB/zFZ0wrD0a81X0FFI/AyMEmyMlR5Wn7g25YQ= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas2p2.samsung.com (KnoxPortal) with ESMTP id 20200403102052epcas2p2d034bd7c83c272adb9857726af03bca0~CSBAVMU920630806308epcas2p2X; Fri, 3 Apr 2020 10:20:52 +0000 (GMT) Received: from epsmges2p4.samsung.com (unknown [182.195.40.188]) by epsnrtp1.localdomain (Postfix) with ESMTP id 48twtp4XTjzMqYlr; Fri, 3 Apr 2020 10:20:50 +0000 (GMT) Received: from epcas2p1.samsung.com ( [182.195.41.53]) by epsmges2p4.samsung.com (Symantec Messaging Gateway) with SMTP id 7F.56.04647.20E078E5; Fri, 3 Apr 2020 19:20:50 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas2p1.samsung.com (KnoxPortal) with ESMTPA id 20200403102049epcas2p1d1fe95160b7f37609a8b1710c196cdd8~CSA9zxZcW1184411844epcas2p1T; Fri, 3 Apr 2020 10:20:49 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20200403102049epsmtrp1beb6d41bcd7ee8d7c122a030e641a55c~CSA9zDWhy1547015470epsmtrp1I; Fri, 3 Apr 2020 10:20:49 +0000 (GMT) X-AuditID: b6c32a48-8a5ff70000001227-d1-5e870e02578b Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id F7.BB.04024.10E078E5; Fri, 3 Apr 2020 19:20:49 +0900 (KST) Received: from ishtar.dsn.sec.samsung.com (unknown [12.36.155.159]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20200403102049epsmtip1a4910c78177bf84375a630447a9237cd~CSA9hZILc3182831828epsmtip14; Fri, 3 Apr 2020 10:20:49 +0000 (GMT) From: Hyunki Koo To: gregkh@linuxfoundation.org, krzk@kernel.org Cc: Hyunki Koo , Kukjin Kim , Jiri Slaby , linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3] tty: samsung_tty: 32-bit access for TX/RX hold registers Date: Fri, 3 Apr 2020 19:20:41 +0900 Message-Id: <20200403102041.22015-1-hyunki00.koo@samsung.com> X-Mailer: git-send-email 2.15.0.rc1 In-Reply-To: <20200401082721.19431-1-hyunki00.koo@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA01Sa0hTYRj229nlaE1O0+xDQsYJo6XTTZ0dRSVL41QWUhASpp304KRdDjub qQWurGlimd3QlZiVJEOarVliVOq0e5lWUuGfqOxKaDXXzWjHs6h/z/u8z/M9L+/3oojMJ4pE Sw1m2mSgdLg4RHjJo9AoBaE1Baq9VyOI6jNOMeFof4oQR7smBUTDyw8IMTzcJSFcL8dExKPe k2KiafiagLh35oBkeTDpcuwXk9dbOiXkxbNV5EG3A5BO9xMh+cUVlSverEvT0lQxbZLThiJj camhJB1fu7FwZaEmWaVWqlOIZbjcQOnpdDwrJ1e5qlTnHwqXl1E6i5/KpVgWj89IMxktZlqu NbLmdJxminWMWs3EsZSetRhK4oqM+lS1SpWg8Su36rQPbDcBY4spn25fYAWti+pAMAqxJHjb eklYB0JQGdYDYL+7N1B8BnCgzSvhi2kAu/uc4K+luu2WgG9cBXCi7b6IL74B2NN0HOFUYiwG fvQ1+zGKhmPx8FU3yWkQbArA0budAk4ThuVAp29CwmEhFg0fH7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5I479O8Y5FCAumJJanZqakFqUUwWSYOTqkGRpX+mifXi/usDmyyidt8 dMK+69v5Zsy65hj+4eyq+Wdye99drg4tvWaYsfvWecUffEqa5hs8TK8x/XrFN3FTuOkOkfmc RqbK7YJzRPe7zn5sP72xO+n5jyZLv6kCLsyhO2by+NxaG7vtw4FQoc3Pkx83ZeqcXGK8x+up /851fnuPJ/0R3Hsw+YoSS3FGoqEWc1FxIgCR8LJhRQIAAA== X-CMS-MailID: 20200403102049epcas2p1d1fe95160b7f37609a8b1710c196cdd8 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20200403102049epcas2p1d1fe95160b7f37609a8b1710c196cdd8 References: <20200401082721.19431-1-hyunki00.koo@samsung.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Support 32-bit access for the TX/RX hold registers UTXH and URXH. This is required for some newer SoCs. Signed-off-by: Hyunki Koo --- v3: change rd_regl to rd_reg in line 954 for backward compatibility. --- drivers/tty/serial/samsung_tty.c | 76 +++++++++++++++++++++++++++++++++------- 1 file changed, 64 insertions(+), 12 deletions(-) diff --git a/drivers/tty/serial/samsung_tty.c b/drivers/tty/serial/samsung_tty.c index 73f951d65b93..a674a80163ed 100644 --- a/drivers/tty/serial/samsung_tty.c +++ b/drivers/tty/serial/samsung_tty.c @@ -154,12 +154,47 @@ struct s3c24xx_uart_port { #define portaddrl(port, reg) \ ((unsigned long *)(unsigned long)((port)->membase + (reg))) -#define rd_regb(port, reg) (readb_relaxed(portaddr(port, reg))) +static unsigned int rd_reg(struct uart_port *port, int reg) +{ + switch (port->iotype) { + case UPIO_MEM: + return readb_relaxed(portaddr(port, reg)); + case UPIO_MEM32: + return readl_relaxed(portaddr(port, reg)); + default: + return 0; + } + return 0; +} + #define rd_regl(port, reg) (readl_relaxed(portaddr(port, reg))) -#define wr_regb(port, reg, val) writeb_relaxed(val, portaddr(port, reg)) +static void wr_reg(struct uart_port *port, int reg, int val) +{ + switch (port->iotype) { + case UPIO_MEM: + writeb_relaxed(val, portaddr(port, reg)); + break; + case UPIO_MEM32: + writel_relaxed(val, portaddr(port, reg)); + break; + } +} + #define wr_regl(port, reg, val) writel_relaxed(val, portaddr(port, reg)) +static void write_buf(struct uart_port *port, int reg, int val) +{ + switch (port->iotype) { + case UPIO_MEM: + writeb(val, portaddr(port, reg)); + break; + case UPIO_MEM32: + writel(val, portaddr(port, reg)); + break; + } +} + /* Byte-order aware bit setting/clearing functions. */ static inline void s3c24xx_set_bit(struct uart_port *port, int idx, @@ -714,7 +749,7 @@ static void s3c24xx_serial_rx_drain_fifo(struct s3c24xx_uart_port *ourport) fifocnt--; uerstat = rd_regl(port, S3C2410_UERSTAT); - ch = rd_regb(port, S3C2410_URXH); + ch = rd_reg(port, S3C2410_URXH); if (port->flags & UPF_CONS_FLOW) { int txe = s3c24xx_serial_txempty_nofifo(port); @@ -826,7 +861,7 @@ static irqreturn_t s3c24xx_serial_tx_chars(int irq, void *id) } if (port->x_char) { - wr_regb(port, S3C2410_UTXH, port->x_char); + wr_reg(port, S3C2410_UTXH, port->x_char); port->icount.tx++; port->x_char = 0; goto out; @@ -852,7 +887,7 @@ static irqreturn_t s3c24xx_serial_tx_chars(int irq, void *id) if (rd_regl(port, S3C2410_UFSTAT) & ourport->info->tx_fifofull) break; - wr_regb(port, S3C2410_UTXH, xmit->buf[xmit->tail]); + wr_reg(port, S3C2410_UTXH, xmit->buf[xmit->tail]); xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1); port->icount.tx++; count--; @@ -916,7 +951,7 @@ static unsigned int s3c24xx_serial_tx_empty(struct uart_port *port) /* no modem control lines */ static unsigned int s3c24xx_serial_get_mctrl(struct uart_port *port) { - unsigned int umstat = rd_regb(port, S3C2410_UMSTAT); + unsigned int umstat = rd_reg(port, S3C2410_UMSTAT); if (umstat & S3C2410_UMSTAT_CTS) return TIOCM_CAR | TIOCM_DSR | TIOCM_CTS; @@ -1974,7 +2009,7 @@ static int s3c24xx_serial_probe(struct platform_device *pdev) struct device_node *np = pdev->dev.of_node; struct s3c24xx_uart_port *ourport; int index = probe_index; - int ret; + int ret, prop = 0; if (np) { ret = of_alias_get_id(np, "serial"); @@ -2000,10 +2035,27 @@ static int s3c24xx_serial_probe(struct platform_device *pdev) dev_get_platdata(&pdev->dev) : ourport->drv_data->def_cfg; - if (np) + if (np) { of_property_read_u32(np, "samsung,uart-fifosize", &ourport->port.fifosize); + if (of_property_read_u32(np, "reg-io-width", &prop) == 0) { + switch (prop) { + case 1: + ourport->port.iotype = UPIO_MEM; + break; + case 4: + ourport->port.iotype = UPIO_MEM32; + break; + default: + dev_warn(&pdev->dev, "unsupported reg-io-width (%d)\n", + prop); + ret = -EINVAL; + break; + } + } + } + if (ourport->drv_data->fifosize[index]) ourport->port.fifosize = ourport->drv_data->fifosize[index]; else if (ourport->info->fifosize) @@ -2185,7 +2237,7 @@ static int s3c24xx_serial_get_poll_char(struct uart_port *port) if (s3c24xx_serial_rx_fifocnt(ourport, ufstat) == 0) return NO_POLL_CHAR; - return rd_regb(port, S3C2410_URXH); + return rd_reg(port, S3C2410_URXH); } static void s3c24xx_serial_put_poll_char(struct uart_port *port, @@ -2200,7 +2252,7 @@ static void s3c24xx_serial_put_poll_char(struct uart_port *port, while (!s3c24xx_serial_console_txrdy(port, ufcon)) cpu_relax(); - wr_regb(port, S3C2410_UTXH, c); + wr_reg(port, S3C2410_UTXH, c); } #endif /* CONFIG_CONSOLE_POLL */ @@ -2212,7 +2264,7 @@ s3c24xx_serial_console_putchar(struct uart_port *port, int ch) while (!s3c24xx_serial_console_txrdy(port, ufcon)) cpu_relax(); - wr_regb(port, S3C2410_UTXH, ch); + wr_reg(port, S3C2410_UTXH, ch); } static void @@ -2612,7 +2664,7 @@ static void samsung_early_putc(struct uart_port *port, int c) else samsung_early_busyuart(port); - writeb(c, port->membase + S3C2410_UTXH); + write_buf(port, S3C2410_UTXH, c); } static void samsung_early_write(struct console *con, const char *s, -- 2.15.0.rc1