Skip to content

Commit 0140ba8

Browse files
Zhiyong.Taoabhsahu
authored andcommitted
NVIDIA: SAUCE: MEDIATEK: serial: 8250_mtk: Add ACPI support
This patch is applied from https://patchwork.kernel.org/project/linux-mediatek/patch/20260105024103.2027085-2-zhiyong.tao@mediatek.com/ Add ACPI support to 8250_mtk driver. This makes it possible to use UART on ARM-based desktops with EDK2 UEFI firmware. Signed-off-by: Yenchia Chen <yenchia.chen@mediatek.com> Signed-off-by: Zhiyong.Tao <zhiyong.tao@mediatek.com> Signed-off-by: Abhishek Sahu <abhsahu@nvidia.com>
1 parent 5a793f2 commit 0140ba8

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

drivers/tty/serial/8250/8250_mtk.c

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <linux/dma-mapping.h>
2020
#include <linux/tty.h>
2121
#include <linux/tty_flip.h>
22+
#include <linux/units.h>
2223

2324
#include "8250.h"
2425

@@ -521,6 +522,7 @@ static int mtk8250_probe(struct platform_device *pdev)
521522
struct mtk8250_data *data;
522523
struct resource *regs;
523524
int irq, err;
525+
struct fwnode_handle *fwnode = dev_fwnode(&pdev->dev);
524526

525527
irq = platform_get_irq(pdev, 0);
526528
if (irq < 0)
@@ -543,12 +545,13 @@ static int mtk8250_probe(struct platform_device *pdev)
543545

544546
data->clk_count = 0;
545547

546-
if (pdev->dev.of_node) {
548+
if (is_of_node(fwnode)) {
547549
err = mtk8250_probe_of(pdev, &uart.port, data);
548550
if (err)
549551
return err;
550-
} else
552+
} else if (!fwnode) {
551553
return -ENODEV;
554+
}
552555

553556
spin_lock_init(&uart.port.lock);
554557
uart.port.mapbase = regs->start;
@@ -564,14 +567,18 @@ static int mtk8250_probe(struct platform_device *pdev)
564567
uart.port.startup = mtk8250_startup;
565568
uart.port.set_termios = mtk8250_set_termios;
566569
uart.port.uartclk = clk_get_rate(data->uart_clk);
570+
if (!uart.port.uartclk)
571+
uart.port.uartclk = 26 * HZ_PER_MHZ;
567572
#ifdef CONFIG_SERIAL_8250_DMA
568573
if (data->dma)
569574
uart.dma = data->dma;
570575
#endif
571576

572-
/* Disable Rate Fix function */
573-
writel(0x0, uart.port.membase +
577+
if (is_of_node(fwnode)) {
578+
/* Disable Rate Fix function */
579+
writel(0x0, uart.port.membase +
574580
(MTK_UART_RATE_FIX << uart.port.regshift));
581+
}
575582

576583
platform_set_drvdata(pdev, data);
577584

@@ -649,11 +656,19 @@ static const struct of_device_id mtk8250_of_match[] = {
649656
};
650657
MODULE_DEVICE_TABLE(of, mtk8250_of_match);
651658

659+
static const struct acpi_device_id mtk8250_acpi_match[] = {
660+
{ "MTKI0511" },
661+
{ "NVDA0240" },
662+
{}
663+
};
664+
MODULE_DEVICE_TABLE(acpi, mtk8250_acpi_match);
665+
652666
static struct platform_driver mtk8250_platform_driver = {
653667
.driver = {
654668
.name = "mt6577-uart",
655669
.pm = &mtk8250_pm_ops,
656670
.of_match_table = mtk8250_of_match,
671+
.acpi_match_table = mtk8250_acpi_match,
657672
},
658673
.probe = mtk8250_probe,
659674
.remove = mtk8250_remove,

0 commit comments

Comments
 (0)