summaryrefslogtreecommitdiffstats
path: root/drivers/serial/serial_imx.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/serial/serial_imx.c')
-rw-r--r--drivers/serial/serial_imx.c40
1 files changed, 23 insertions, 17 deletions
diff --git a/drivers/serial/serial_imx.c b/drivers/serial/serial_imx.c
index e5280ac3e9..0f91028605 100644
--- a/drivers/serial/serial_imx.c
+++ b/drivers/serial/serial_imx.c
@@ -1,17 +1,6 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
/*
* (c) 2004 Sascha Hauer <sascha@saschahauer.de>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- *
*/
#include <common.h>
@@ -60,6 +49,7 @@ struct imx_serial_priv {
void __iomem *regs;
struct clk *clk;
struct imx_serial_devtype_data *devtype;
+ bool rs485_mode;
};
static int imx_serial_reffreq(struct imx_serial_priv *priv)
@@ -107,6 +97,9 @@ static int imx_serial_init_port(struct console_device *cdev)
/* Enable FIFOs */
val = readl(regs + UCR2);
+ /* set CTS to not block RS485 bus */
+ if (priv->rs485_mode)
+ val |= UCR2_CTS;
val |= UCR2_SRST | UCR2_RXEN | UCR2_TXEN;
writel(val, regs + UCR2);
@@ -204,7 +197,7 @@ static int imx_clocksource_clock_change(struct notifier_block *nb,
return 0;
}
-static int imx_serial_probe(struct device_d *dev)
+static int imx_serial_probe(struct device *dev)
{
struct resource *iores;
struct console_device *cdev;
@@ -241,17 +234,23 @@ static int imx_serial_probe(struct device_d *dev)
cdev->flush = imx_serial_flush;
cdev->setbrg = imx_serial_setbaudrate;
cdev->linux_console_name = "ttymxc";
- if (dev->device_node) {
- devname = of_alias_get(dev->device_node);
+ cdev->linux_earlycon_name = "ec_imx6q";
+ cdev->phys_base = priv->regs;
+ if (dev->of_node) {
+ devname = of_alias_get(dev->of_node);
if (devname) {
cdev->devname = xstrdup(devname);
cdev->devid = DEVICE_ID_SINGLE;
}
}
- if (of_property_read_bool(dev->device_node, "fsl,dte-mode"))
+ if (of_property_read_bool(dev->of_node, "fsl,dte-mode"))
priv->dte_mode = 1;
+ if (of_property_read_bool(dev->of_node, "linux,rs485-enabled-at-boot-time") &&
+ !of_property_read_bool(dev->of_node, "rs485-rts-active-low"))
+ priv->rs485_mode = 1;
+
imx_serial_init_port(cdev);
/* Enable UART */
@@ -291,9 +290,16 @@ static __maybe_unused struct of_device_id imx_serial_dt_ids[] = {
.compatible = "fsl,imx8mm-uart",
.data = &imx21_data,
}, {
+ .compatible = "fsl,imx8mn-uart",
+ .data = &imx21_data,
+ }, {
+ .compatible = "fsl,imx8mp-uart",
+ .data = &imx21_data,
+ }, {
/* sentinel */
}
};
+MODULE_DEVICE_TABLE(of, imx_serial_dt_ids);
static struct platform_device_id imx_serial_ids[] = {
{
@@ -307,7 +313,7 @@ static struct platform_device_id imx_serial_ids[] = {
},
};
-static struct driver_d imx_serial_driver = {
+static struct driver imx_serial_driver = {
.name = "imx_serial",
.probe = imx_serial_probe,
.of_compatible = DRV_OF_COMPAT(imx_serial_dt_ids),