Skip to content

Commit d73760e

Browse files
yenchia-chenjacobmartin0
authored andcommitted
NVIDIA: SAUCE: serial: 8250_mtk: Add ACPI support
BugLink: https://bugs.launchpad.net/bugs/2096888 Add ACPI support to 8250_mtk driver. This makes it possible to use UART on ARM-based desktops with EDK2 UEFI firmware. Acked-by: Brad Figg <bfigg@nvidia.com> Acked-by: Noah Wager <noah.wager@canonical.com> Acked-by: Jacob Martin <jacob.martin@canonical.com> Signed-off-by: Brad Figg <bfigg@nvidia.com> (cherry picked from commit 4647186 noble:linux-nvidia-6.11) Signed-off-by: Jacob Martin <jacob.martin@canonical.com>
1 parent 88d6a61 commit d73760e

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

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

Lines changed: 18 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

@@ -519,6 +520,7 @@ static int mtk8250_probe(struct platform_device *pdev)
519520
struct mtk8250_data *data;
520521
struct resource *regs;
521522
int irq, err;
523+
struct fwnode_handle *fwnode = dev_fwnode(&pdev->dev);
522524

523525
irq = platform_get_irq(pdev, 0);
524526
if (irq < 0)
@@ -541,12 +543,13 @@ static int mtk8250_probe(struct platform_device *pdev)
541543

542544
data->clk_count = 0;
543545

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

551554
spin_lock_init(&uart.port.lock);
552555
uart.port.mapbase = regs->start;
@@ -562,14 +565,18 @@ static int mtk8250_probe(struct platform_device *pdev)
562565
uart.port.startup = mtk8250_startup;
563566
uart.port.set_termios = mtk8250_set_termios;
564567
uart.port.uartclk = clk_get_rate(data->uart_clk);
568+
if (!uart.port.uartclk)
569+
uart.port.uartclk = 26 * HZ_PER_MHZ;
565570
#ifdef CONFIG_SERIAL_8250_DMA
566571
if (data->dma)
567572
uart.dma = data->dma;
568573
#endif
569574

570-
/* Disable Rate Fix function */
571-
writel(0x0, uart.port.membase +
575+
if (is_of_node(fwnode)) {
576+
/* Disable Rate Fix function */
577+
writel(0x0, uart.port.membase +
572578
(MTK_UART_RATE_FIX << uart.port.regshift));
579+
}
573580

574581
platform_set_drvdata(pdev, data);
575582

@@ -647,11 +654,18 @@ static const struct of_device_id mtk8250_of_match[] = {
647654
};
648655
MODULE_DEVICE_TABLE(of, mtk8250_of_match);
649656

657+
static const struct acpi_device_id mtk8250_acpi_match[] = {
658+
{ "MTKI0511" },
659+
{}
660+
};
661+
MODULE_DEVICE_TABLE(acpi, mtk8250_acpi_match);
662+
650663
static struct platform_driver mtk8250_platform_driver = {
651664
.driver = {
652665
.name = "mt6577-uart",
653666
.pm = &mtk8250_pm_ops,
654667
.of_match_table = mtk8250_of_match,
668+
.acpi_match_table = mtk8250_acpi_match,
655669
},
656670
.probe = mtk8250_probe,
657671
.remove = mtk8250_remove,

0 commit comments

Comments
 (0)