summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorWadim Egorov <w.egorov@phytec.de>2017-02-09 10:36:42 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2017-02-10 13:19:40 +0100
commit49b321fb89bc3310ae902af4ca47b66747a41145 (patch)
treedac3c95122874bd1ea2e4bb2bfcedc489db123b4 /drivers
parent14c6fc99e1a338fc3804a1e858a60e8b32d4dd0a (diff)
downloadbarebox-49b321fb89bc3310ae902af4ca47b66747a41145.tar.gz
barebox-49b321fb89bc3310ae902af4ca47b66747a41145.tar.xz
serial: ns16550: Set read/write functions depending on reg-io-width
Set proper register read/write functions depending on reg-io-width device tree property. Signed-off-by: Wadim Egorov <w.egorov@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/serial/serial_ns16550.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/drivers/serial/serial_ns16550.c b/drivers/serial/serial_ns16550.c
index c6548e3b85..439b7d5517 100644
--- a/drivers/serial/serial_ns16550.c
+++ b/drivers/serial/serial_ns16550.c
@@ -287,12 +287,31 @@ static int ns16550_tstc(struct console_device *cdev)
static void ns16550_probe_dt(struct device_d *dev, struct ns16550_priv *priv)
{
struct device_node *np = dev->device_node;
+ u32 width;
if (!IS_ENABLED(CONFIG_OFDEVICE))
return;
of_property_read_u32(np, "clock-frequency", &priv->plat.clock);
of_property_read_u32(np, "reg-shift", &priv->plat.shift);
+ if (!of_property_read_u32(np, "reg-io-width", &width))
+ switch (width) {
+ case 1:
+ priv->read_reg = ns16550_read_reg_mmio_8;
+ priv->write_reg = ns16550_write_reg_mmio_8;
+ break;
+ case 2:
+ priv->read_reg = ns16550_read_reg_mmio_16;
+ 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;
+ break;
+ default:
+ dev_err(dev, "unsupported reg-io-width (%d)\n",
+ width);
+ }
}
static struct ns16550_drvdata ns16450_drvdata = {