bcm27xx: update 6.1 patches to latest version
[openwrt/staging/dangole.git] / target / linux / bcm27xx / patches-6.1 / 950-0877-serial-pl011-rp1-uart-support.patch
1 From f88da9e21d8eff58eeb9280ae96bf9593121d8eb Mon Sep 17 00:00:00 2001
2 From: Phil Elwell <phil@raspberrypi.com>
3 Date: Wed, 12 Oct 2022 13:24:51 +0100
4 Subject: [PATCH] serial: pl011: rp1 uart support
5
6 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
7 ---
8 drivers/tty/serial/amba-pl011.c | 96 +++++++++++++++++++++++++++++++++
9 1 file changed, 96 insertions(+)
10
11 --- a/drivers/tty/serial/amba-pl011.c
12 +++ b/drivers/tty/serial/amba-pl011.c
13 @@ -152,6 +152,20 @@ static const struct vendor_data vendor_s
14 .fixed_options = true,
15 };
16
17 +static struct vendor_data vendor_arm_axi = {
18 + .reg_offset = pl011_std_offsets,
19 + .ifls = UART011_IFLS_RX4_8 | UART011_IFLS_TX4_8,
20 + .fr_busy = UART01x_FR_BUSY,
21 + .fr_dsr = UART01x_FR_DSR,
22 + .fr_cts = UART01x_FR_CTS,
23 + .fr_ri = UART011_FR_RI,
24 + .oversampling = false,
25 + .dma_threshold = false,
26 + .cts_event_workaround = false,
27 + .always_enabled = false,
28 + .fixed_options = false,
29 +};
30 +
31 #ifdef CONFIG_ACPI_SPCR_TABLE
32 static const struct vendor_data vendor_qdt_qdf2400_e44 = {
33 .reg_offset = pl011_std_offsets,
34 @@ -2972,6 +2986,86 @@ static struct platform_driver arm_sbsa_u
35 },
36 };
37
38 +static int pl011_axi_probe(struct platform_device *pdev)
39 +{
40 + struct uart_amba_port *uap;
41 + struct vendor_data *vendor = &vendor_arm_axi;
42 + struct resource *r;
43 + unsigned int periphid;
44 + int portnr, ret, irq;
45 +
46 + portnr = pl011_find_free_port();
47 + if (portnr < 0)
48 + return portnr;
49 +
50 + uap = devm_kzalloc(&pdev->dev, sizeof(struct uart_amba_port),
51 + GFP_KERNEL);
52 + if (!uap)
53 + return -ENOMEM;
54 +
55 + uap->clk = devm_clk_get(&pdev->dev, NULL);
56 + if (IS_ERR(uap->clk))
57 + return PTR_ERR(uap->clk);
58 +
59 + if (of_property_read_bool(pdev->dev.of_node, "cts-event-workaround")) {
60 + vendor->cts_event_workaround = true;
61 + dev_info(&pdev->dev, "cts_event_workaround enabled\n");
62 + }
63 +
64 + irq = platform_get_irq(pdev, 0);
65 + if (irq < 0)
66 + return irq;
67 +
68 + periphid = 0x00241011; /* A safe default */
69 + of_property_read_u32(pdev->dev.of_node, "arm,primecell-periphid",
70 + &periphid);
71 +
72 + uap->reg_offset = vendor->reg_offset;
73 + uap->vendor = vendor;
74 + uap->fifosize = (AMBA_REV_BITS(periphid) < 3) ? 16 : 32;
75 + uap->port.iotype = vendor->access_32b ? UPIO_MEM32 : UPIO_MEM;
76 + uap->port.irq = irq;
77 + uap->port.ops = &amba_pl011_pops;
78 +
79 + snprintf(uap->type, sizeof(uap->type), "PL011 AXI");
80 +
81 + r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
82 +
83 + ret = pl011_setup_port(&pdev->dev, uap, r, portnr);
84 + if (ret)
85 + return ret;
86 +
87 + platform_set_drvdata(pdev, uap);
88 +
89 + return pl011_register_port(uap);
90 +}
91 +
92 +static int pl011_axi_remove(struct platform_device *pdev)
93 +{
94 + struct uart_amba_port *uap = platform_get_drvdata(pdev);
95 +
96 + uart_remove_one_port(&amba_reg, &uap->port);
97 + pl011_unregister_port(uap);
98 + return 0;
99 +}
100 +
101 +static const struct of_device_id pl011_axi_of_match[] = {
102 + { .compatible = "arm,pl011-axi" },
103 + {},
104 +};
105 +MODULE_DEVICE_TABLE(of, pl011_axi_of_match);
106 +
107 +static struct platform_driver pl011_axi_platform_driver = {
108 + .probe = pl011_axi_probe,
109 + .remove = pl011_axi_remove,
110 + .driver = {
111 + .name = "pl011-axi",
112 + .pm = &pl011_dev_pm_ops,
113 + .of_match_table = of_match_ptr(pl011_axi_of_match),
114 + .suppress_bind_attrs = IS_BUILTIN(CONFIG_SERIAL_AMBA_PL011),
115 + },
116 +};
117 +
118 static const struct amba_id pl011_ids[] = {
119 {
120 .id = 0x00041011,
121 @@ -3005,6 +3099,8 @@ static int __init pl011_init(void)
122
123 if (platform_driver_register(&arm_sbsa_uart_platform_driver))
124 pr_warn("could not register SBSA UART platform driver\n");
125 + if (platform_driver_register(&pl011_axi_platform_driver))
126 + pr_warn("could not register PL011 AXI platform driver\n");
127 return amba_driver_register(&pl011_driver);
128 }
129