aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Marangi2024-06-24 23:03:33 +0200
committerTom Rini2024-07-08 11:45:50 -0600
commit8bae5bf622c764a48d957a5ffc456dd3650dcb6b (patch)
tree20d84e64019dc87090b09baadeb04e8e217821c2
parent41d2cab1fcecfda40cbcc4add57761b1050dfa99 (diff)
serial: mediatek: add special handling for highspeed and linux compat
Upstream linux serial driver use a different logic to setup serial regs. They have 2 interval: - < 115200 we use lowspeed regs and 16 * baud - >= 115200 we use highspeed We currently use force_highspeed property to force usage of highspeed regs even with low baud rate. Add special handling if the upstream compatible is used where we just apply the same interval with anything >= 115200 in highspeed simulating force_highspeed. Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
-rw-r--r--drivers/serial/serial_mtk.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/drivers/serial/serial_mtk.c b/drivers/serial/serial_mtk.c
index 78e8d9dc735..becf9317076 100644
--- a/drivers/serial/serial_mtk.c
+++ b/drivers/serial/serial_mtk.c
@@ -10,6 +10,7 @@
#include <config.h>
#include <div64.h>
#include <dm.h>
+#include <dm/device.h>
#include <dm/device_compat.h>
#include <errno.h>
#include <log.h>
@@ -80,6 +81,7 @@ struct mtk_serial_regs {
* @fixed_clk_rate: Fallback fixed baud clock rate if baud clock
* device is not specified
* @force_highspeed: Force using high-speed mode
+ * @upstream_highspeed_logic: Apply upstream high-speed logic
*/
struct mtk_serial_priv {
struct mtk_serial_regs __iomem *regs;
@@ -87,6 +89,7 @@ struct mtk_serial_priv {
struct clk clk_bus;
u32 fixed_clk_rate;
bool force_highspeed;
+ bool upstream_highspeed_logic;
};
static void _mtk_serial_setbrg(struct mtk_serial_priv *priv, int baud,
@@ -113,7 +116,12 @@ static void _mtk_serial_setbrg(struct mtk_serial_priv *priv, int baud,
goto set_baud;
}
- if (priv->force_highspeed)
+ /*
+ * Upstream linux use highspeed for anything >= 115200 and lowspeed
+ * for < 115200. Simulate this if we are using the upstream compatible.
+ */
+ if (priv->force_highspeed ||
+ (priv->upstream_highspeed_logic && baud >= 115200))
goto use_hs3;
if (baud <= 115200) {
@@ -259,6 +267,8 @@ static int mtk_serial_of_to_plat(struct udevice *dev)
clk_get_by_name(dev, "bus", &priv->clk_bus);
priv->force_highspeed = dev_read_bool(dev, "mediatek,force-highspeed");
+ priv->upstream_highspeed_logic =
+ device_is_compatible(dev, "mediatek,mt6577-uart");
return 0;
}