From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1daavM-00026t-M7 for barebox@lists.infradead.org; Thu, 27 Jul 2017 05:01:27 +0000 From: Oleksij Rempel Date: Thu, 27 Jul 2017 07:00:55 +0200 Message-Id: <20170727050055.14188-2-o.rempel@pengutronix.de> In-Reply-To: <20170727050055.14188-1-o.rempel@pengutronix.de> References: <20170727050055.14188-1-o.rempel@pengutronix.de> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "barebox" Errors-To: barebox-bounces+u.kleine-koenig=pengutronix.de@lists.infradead.org Subject: [PATCH v1 2/2] serial: ns16550: provide big-endian support To: l.stach@pengutronix.de Cc: Oleksij Rempel , barebox@lists.infradead.org we need it at least for QCA AR9344 Signed-off-by: Oleksij Rempel --- drivers/serial/serial_ns16550.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/drivers/serial/serial_ns16550.c b/drivers/serial/serial_ns16550.c index a8953cd99d..4d73ea8b87 100644 --- a/drivers/serial/serial_ns16550.c +++ b/drivers/serial/serial_ns16550.c @@ -94,6 +94,16 @@ static void ns16550_write_reg_mmio_32(struct ns16550_priv *priv, uint8_t val, un writel(val, priv->mmiobase + offset); } +static uint8_t ns16550_read_reg_mmio_32be(struct ns16550_priv *priv, unsigned offset) +{ + return ioread32be(priv->mmiobase + offset); +} + +static void ns16550_write_reg_mmio_32be(struct ns16550_priv *priv, uint8_t val, unsigned offset) +{ + iowrite32be(val, priv->mmiobase + offset); +} + static uint8_t ns16550_read_reg_ioport_8(struct ns16550_priv *priv, unsigned offset) { return inb(priv->iobase + offset); @@ -305,8 +315,13 @@ static void ns16550_probe_dt(struct device_d *dev, struct ns16550_priv *priv) priv->write_reg = ns16550_write_reg_mmio_16; break; case 4: - priv->read_reg = ns16550_read_reg_mmio_32; - priv->write_reg = ns16550_write_reg_mmio_32; + if (of_device_is_big_endian(np)) { + priv->read_reg = ns16550_read_reg_mmio_32be; + priv->write_reg = ns16550_write_reg_mmio_32be; + } else { + priv->read_reg = ns16550_read_reg_mmio_32; + priv->write_reg = ns16550_write_reg_mmio_32; + } break; default: dev_err(dev, "unsupported reg-io-width (%d)\n", -- 2.11.0 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox