Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp371534ybb; Wed, 1 Apr 2020 01:29:58 -0700 (PDT) X-Google-Smtp-Source: APiQypK2+5twIYIUgVRz97pgQ+UXIHVEBfPpwwdydNLUQYvT1UAyY2F+x7NzG05j66Rvc3qvnj/D X-Received: by 2002:aca:ed4b:: with SMTP id l72mr1836243oih.95.1585729798221; Wed, 01 Apr 2020 01:29:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585729798; cv=none; d=google.com; s=arc-20160816; b=O/Dc8558nRaeQnyJh/oDARjGi5QZ5qMMMAhRi3v1k75tmDmbknTq91hsKjkXcRLlic H0TgOtxcim4fCARn8609jdfAmAR4NS4oMKTkA2XryA7fqrBlXDbsUBrVmL1NpCgT3qiM U8DWEP81O/j0YHj5STWNQRP7KKuaMU/gUgwZO+CC+wj/NtpEU37Otwh3QMJhECuyJytp AVOBnHcdc8essHf8MXb8/1PFh3R+icY008dJLXdiwJMAe4XWIac6iw+EH/rowBG9td/6 Mug6yeAtXKLLV0/1et2RdWoR5ccKfAfPXMnd7gNG2x2jK9UqCGeqCy9CZPj0isKy696Q OP1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:dlp-filter:cms-type :message-id:date:subject:cc:from:dkim-signature:dkim-filter; bh=4RnmtdyIh8SjY39KWfynOF/n6bcJzOBW6178U5uJrUw=; b=yWfuifyO/RzKMaO3BuHGwtreZzIfp1IWnwQMmhhAm64PDbWm52pq4/5hqDjhgCZSHi HmI4MqoEqIUQXM5GJBpBPI+iJS+JFCfRQqXrjWMpcCXA3gQNqIisDFw3uQa7vD3X0uLS OaJBHQqlGhYRjCunPVx5/p0lTqDWilu68pYL4CGY1Uqr1U3t4kKWop2qPQdKDK6gagD+ 4yCE2tNVfPkUYUG88MS+ha1sllcJWLpLZgeLp4otO/v91wun6ZVxBldj//Hhko2XZZra gT62u2W7zVtR4cMlf57yOwPGbliZE0loFxg66K6VQOE9qVOZ9rVz1YgYL1ZT7mCvTGYV mRRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@samsung.com header.s=mail20170921 header.b=ojaONP6s; 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=fail (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 94si503402otb.114.2020.04.01.01.29.45; Wed, 01 Apr 2020 01:29:58 -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=fail header.i=@samsung.com header.s=mail20170921 header.b=ojaONP6s; 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=fail (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732009AbgDAI14 (ORCPT + 99 others); Wed, 1 Apr 2020 04:27:56 -0400 Received: from mailout2.samsung.com ([203.254.224.25]:38268 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730720AbgDAI14 (ORCPT ); Wed, 1 Apr 2020 04:27:56 -0400 Received: from epcas2p3.samsung.com (unknown [182.195.41.55]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20200401082753epoutp0216a80cafdc229f944462dcb61805e6bb~BpLxu7KBJ0923009230epoutp021 for ; Wed, 1 Apr 2020 08:27:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20200401082753epoutp0216a80cafdc229f944462dcb61805e6bb~BpLxu7KBJ0923009230epoutp021 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1585729673; bh=4RnmtdyIh8SjY39KWfynOF/n6bcJzOBW6178U5uJrUw=; h=From:To:Cc:Subject:Date:References:From; b=ojaONP6sdc88OivWNNux+RCG1ib1vXug3N2xDToasOpQ/+5iVvb3wUO0TlACBvjnc o/FFR+OJ8gYzApRYGS7LjGYftFb96Aqhfv/ZbLi27gX04D1S3DN1l4OW/vPI9QBuOF lUoANhjXLrrAVkXXGChe+cFPbmSGCj9z+roSsnok= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas2p1.samsung.com (KnoxPortal) with ESMTP id 20200401082752epcas2p14bdde14707f6585fad78443fc7bc07c5~BpLxKw-jF0972709727epcas2p1s; Wed, 1 Apr 2020 08:27:52 +0000 (GMT) Received: from epsmges2p2.samsung.com (unknown [182.195.40.184]) by epsnrtp3.localdomain (Postfix) with ESMTP id 48sfTL1bxNzMqYkp; Wed, 1 Apr 2020 08:27:50 +0000 (GMT) Received: from epcas2p3.samsung.com ( [182.195.41.55]) by epsmges2p2.samsung.com (Symantec Messaging Gateway) with SMTP id A0.B5.04142.580548E5; Wed, 1 Apr 2020 17:27:49 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas2p2.samsung.com (KnoxPortal) with ESMTPA id 20200401082749epcas2p2a774da515805bc3f761b6b5a8dc9e3d2~BpLuGvQl51301413014epcas2p2Y; Wed, 1 Apr 2020 08:27:49 +0000 (GMT) Received: from epsmgms1p2new.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20200401082749epsmtrp23fead6d7c96f9108080f2e7c27e8b676~BpLuF4hQ41893818938epsmtrp2H; Wed, 1 Apr 2020 08:27:49 +0000 (GMT) X-AuditID: b6c32a46-3f9ff7000000102e-98-5e845085f5cf Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 66.49.04158.580548E5; Wed, 1 Apr 2020 17:27:49 +0900 (KST) Received: from ishtar.dsn.sec.samsung.com (unknown [12.36.155.159]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20200401082748epsmtip24cdc2c348186edfadcf42541b019e045~BpLt7osjy0747007470epsmtip20; Wed, 1 Apr 2020 08:27:48 +0000 (GMT) From: Hyunki Koo Cc: hyunki00.koo@gmail.com, Hyunki Koo , Kukjin Kim , Krzysztof Kozlowski , Greg Kroah-Hartman , 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] tty: samsung_tty: 32-bit access for TX/RX hold registers Date: Wed, 1 Apr 2020 17:27:20 +0900 Message-Id: <20200401082721.19431-1-hyunki00.koo@samsung.com> X-Mailer: git-send-email 2.15.0.rc1 X-Brightmail-Tracker: H4sIAAAAAAAAA01SfUgTYRzmvdvuTm11TKuX0ce4MNA0d6vpWa2ETK60WkSQUq7LHc7ax7Hb og8qq2UWWQkFaoaRympY2hQzwYRphRRqiKVBQYxKM0waaN+06xb13/N7fs/zPu/7e38Eqg4r NUSJw827HJyNwmIV7T1JGamnTd5C3T2fnjlV34wxwyc/YYy/cQRlLrdMIczF0ATKDAy04Ewg 9FzJDHXWYkzVwAOEeVpfgWfFsvdrXuFswH8WY7uvNeFsa8Nx9kKbH7DNbcMKNhxYZMILbGus PGfhXVreUeS0lDiKjVTudvN6syFdR6fSmUwGpXVwdt5IZeeZUnNKbJHrUdoDnM0ToUycKFJp a9e4nB43r7U6RbeR4gWLTaBpYbnI2UWPo3h5kdO+itbp9IaIco/N+qz2BxA6kw+29WWVghB1 DsQQkFwJ/Teu4OdALKEmOwCcHApFi88A/nr0HZGLaQCnSn2Kv5bX3ruYhNVkF4CN7Vtk0RcA q557lVIDI5fBjzPVqIQTSAW8NTOjkEQoGULgxGBTxE0Q8eRGeMW3WtIoyERYUe1DJFpFGuHZ rwVy1hI4ONmglKyQvIn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a S/Yd3t6peGTjRKWtL57GHuZ35vZm2LyRaUFZqJmpVeaXuHDF+hurTpr/Xr27lG2u4NuliaIl 6fZBFY+lJs1aa6C4Zony0bXnDE0aZnan6B5ct65nrparz46JJzq51lQuvZd+5f/F6blr1/sc y5rUkF5yUYmlOCPRUIu5qDgRAFutons1AgAA X-CMS-MailID: 20200401082749epcas2p2a774da515805bc3f761b6b5a8dc9e3d2 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: 20200401082749epcas2p2a774da515805bc3f761b6b5a8dc9e3d2 References: To: unlisted-recipients:; (no To-header on input) 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 --- 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..17d2ead7cfe2 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_regl(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