This series improves support for UART attached Bluetooth modules on
Amlogic Meson G12A and newer SoCs. These SoCs also support the "divide
XTAL by 2" bit which (greatly) reduces jitter when generating baud
rates such as 1500000 (which is used by the Bluetooth part of the
RTL8822CS SDIO WiFi and UART Bluetooth combo chip).
Without this the baud rate calculation is based on the XTAL clock
(running at 24MHz) divided by 3 (meaning: 8MHz). 8MHz cannot be divided
with integer division to a 1500000 baud rate. Using the "divide XTAL
by 2" bit however means that we can achieve 1500000 cleanly, without any
jitter.
In future we should allow dynamic switching of these UART controller
internal dividers to pick the best divider automatically for the
requested baud rate. This however still requires the new compatible
string - which is added by this series - to enable the "divide XTAL
by 2" logic on SoCs that support it (G12A and newer).
Changes since v1 at [1]:
- make meson-gx-uart a valid fallback compatible string for the newer
meson-g12a-uart
- rebased on top of v6.3-rc1
Changes since v2 at [2]:
- simplify the dt-bindings patch as suggested by Krzysztof Kozlowski
(thank you!) which actually uncovers an unwanted change
[0] https://lore.kernel.org/linux-bluetooth/[email protected]/
[1] https://lore.kernel.org/lkml/[email protected]/
[2] https://lore.kernel.org/lkml/[email protected]/
Martin Blumenstingl (3):
dt-bindings: serial: amlogic,meson-uart: Add compatible string for
G12A
tty: serial: meson: Add a new compatible string for the G12A SoC
arm64: dts: meson-g12-common: Use the G12A UART compatible string
.../bindings/serial/amlogic,meson-uart.yaml | 9 +++++++++
arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi | 15 ++++++++++-----
drivers/tty/serial/meson_uart.c | 8 ++++++--
3 files changed, 25 insertions(+), 7 deletions(-)
--
2.39.2
Amlogic Meson G12A (and later) SoCs also have the "divide XTAL by 2" bit
as the S4 UART controllers. Add a new compatible string for these SoCs
and enable the has_xtal_div2 flag for them.
Tested-by: Christian Hewitt <[email protected]>
Signed-off-by: Martin Blumenstingl <[email protected]>
---
Changes from v1 -> v2:
- none
Changes from v2 -> v3:
- none
drivers/tty/serial/meson_uart.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/tty/serial/meson_uart.c b/drivers/tty/serial/meson_uart.c
index 74110017988a..2501db5a7aaf 100644
--- a/drivers/tty/serial/meson_uart.c
+++ b/drivers/tty/serial/meson_uart.c
@@ -779,7 +779,7 @@ static int meson_uart_remove(struct platform_device *pdev)
return 0;
}
-static struct meson_uart_data s4_uart_data = {
+static struct meson_uart_data meson_g12a_uart_data = {
.has_xtal_div2 = true,
};
@@ -788,9 +788,13 @@ static const struct of_device_id meson_uart_dt_match[] = {
{ .compatible = "amlogic,meson8-uart" },
{ .compatible = "amlogic,meson8b-uart" },
{ .compatible = "amlogic,meson-gx-uart" },
+ {
+ .compatible = "amlogic,meson-g12a-uart",
+ .data = (void *)&meson_g12a_uart_data,
+ },
{
.compatible = "amlogic,meson-s4-uart",
- .data = (void *)&s4_uart_data,
+ .data = (void *)&meson_g12a_uart_data,
},
{ /* sentinel */ },
};
--
2.39.2
Amlogic G12A SoCs gained a new "divide XTAL by 2" bit. Everything else
(we know about) is identical to the UART IP on GX (GXBB/GXL/GXM) SoCs.
Add a new compatible string for this SoC so this new bit can be managed
accordingly while keeping "amlogic,meson-gx-uart" as fallback compatible
string.
Signed-off-by: Martin Blumenstingl <[email protected]>
---
Changes from v1 -> v2:
- make meson-gx-uart a valid compatible string for meson-g12a-uart
Changes from v2 -> v3:
- don't add extra oneOf as all of the entries are enclosed in oneOf
already
- don't allow amlogic,meson-g12a-uart as standalone compatible string
(which slipped through in v2 due to all of the formatting changes
that the extra oneOf required)
.../devicetree/bindings/serial/amlogic,meson-uart.yaml | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/Documentation/devicetree/bindings/serial/amlogic,meson-uart.yaml b/Documentation/devicetree/bindings/serial/amlogic,meson-uart.yaml
index 3cbdde85ed71..22656efe8ddc 100644
--- a/Documentation/devicetree/bindings/serial/amlogic,meson-uart.yaml
+++ b/Documentation/devicetree/bindings/serial/amlogic,meson-uart.yaml
@@ -34,6 +34,11 @@ properties:
- amlogic,meson-gx-uart
- amlogic,meson-s4-uart
- const: amlogic,meson-ao-uart
+ - description: Always-on power domain UART controller on G12A SoCs
+ items:
+ - const: amlogic,meson-g12a-uart
+ - const: amlogic,meson-gx-uart
+ - const: amlogic,meson-ao-uart
- description: Everything-Else power domain UART controller
enum:
- amlogic,meson6-uart
@@ -41,6 +46,10 @@ properties:
- amlogic,meson8b-uart
- amlogic,meson-gx-uart
- amlogic,meson-s4-uart
+ - description: Everything-Else power domain UART controller on G12A SoCs
+ items:
+ - const: amlogic,meson-g12a-uart
+ - const: amlogic,meson-gx-uart
reg:
maxItems: 1
--
2.39.2
Switch meson-12-common.dtsi to use the Meson G12A specific UART
compatible string. This enables the "divide XTAL by 2" divider which
improves support for UART attached Bluetooth modules (for example
RTL8822CS) running at a baud rate of 1500000. Without dividing XTAL
(24MHz) by 2 a baud rate of 1500000 cannot be generated cleanly and the
resulting jitter breaks communication with the module.
Tested-by: Christian Hewitt <[email protected]>
Signed-off-by: Martin Blumenstingl <[email protected]>
---
Greg, please don't take this through your tree. I included this patch
to show the overall goal of this series. If Neil won't take this as
part of another series then I'll send it separately.
Changes from v1 -> v2:
- keep meson-gx-uart as fallback compatible string
Changes from v2 -> v3:
- none
arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi b/arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi
index 123a56f7f818..904bcd4d2acf 100644
--- a/arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi
+++ b/arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi
@@ -2046,7 +2046,8 @@ pwm_AO_cd: pwm@2000 {
};
uart_AO: serial@3000 {
- compatible = "amlogic,meson-gx-uart",
+ compatible = "amlogic,meson-g12a-uart",
+ "amlogic,meson-gx-uart",
"amlogic,meson-ao-uart";
reg = <0x0 0x3000 0x0 0x18>;
interrupts = <GIC_SPI 193 IRQ_TYPE_EDGE_RISING>;
@@ -2056,7 +2057,8 @@ uart_AO: serial@3000 {
};
uart_AO_B: serial@4000 {
- compatible = "amlogic,meson-gx-uart",
+ compatible = "amlogic,meson-g12a-uart",
+ "amlogic,meson-gx-uart",
"amlogic,meson-ao-uart";
reg = <0x0 0x4000 0x0 0x18>;
interrupts = <GIC_SPI 197 IRQ_TYPE_EDGE_RISING>;
@@ -2293,7 +2295,8 @@ clk_msr: clock-measure@18000 {
};
uart_C: serial@22000 {
- compatible = "amlogic,meson-gx-uart";
+ compatible = "amlogic,meson-g12a-uart",
+ "amlogic,meson-gx-uart";
reg = <0x0 0x22000 0x0 0x18>;
interrupts = <GIC_SPI 93 IRQ_TYPE_EDGE_RISING>;
clocks = <&xtal>, <&clkc CLKID_UART2>, <&xtal>;
@@ -2302,7 +2305,8 @@ uart_C: serial@22000 {
};
uart_B: serial@23000 {
- compatible = "amlogic,meson-gx-uart";
+ compatible = "amlogic,meson-g12a-uart",
+ "amlogic,meson-gx-uart";
reg = <0x0 0x23000 0x0 0x18>;
interrupts = <GIC_SPI 75 IRQ_TYPE_EDGE_RISING>;
clocks = <&xtal>, <&clkc CLKID_UART1>, <&xtal>;
@@ -2311,7 +2315,8 @@ uart_B: serial@23000 {
};
uart_A: serial@24000 {
- compatible = "amlogic,meson-gx-uart";
+ compatible = "amlogic,meson-g12a-uart",
+ "amlogic,meson-gx-uart";
reg = <0x0 0x24000 0x0 0x18>;
interrupts = <GIC_SPI 26 IRQ_TYPE_EDGE_RISING>;
clocks = <&xtal>, <&clkc CLKID_UART0>, <&xtal>;
--
2.39.2
On 07/03/2023 23:26, Martin Blumenstingl wrote:
> Amlogic G12A SoCs gained a new "divide XTAL by 2" bit. Everything else
> (we know about) is identical to the UART IP on GX (GXBB/GXL/GXM) SoCs.
> Add a new compatible string for this SoC so this new bit can be managed
> accordingly while keeping "amlogic,meson-gx-uart" as fallback compatible
> string.
>
> Signed-off-by: Martin Blumenstingl <[email protected]>
> ---
> Changes from v1 -> v2:
> - make meson-gx-uart a valid compatible string for meson-g12a-uart
>
> Changes from v2 -> v3:
> - don't add extra oneOf as all of the entries are enclosed in oneOf
> already
> - don't allow amlogic,meson-g12a-uart as standalone compatible string
> (which slipped through in v2 due to all of the formatting changes
> that the extra oneOf required)
>
Acked-by: Krzysztof Kozlowski <[email protected]>
Best regards,
Krzysztof
On 07/03/2023 23:26, Martin Blumenstingl wrote:
> Amlogic Meson G12A (and later) SoCs also have the "divide XTAL by 2" bit
> as the S4 UART controllers. Add a new compatible string for these SoCs
> and enable the has_xtal_div2 flag for them.
>
> Tested-by: Christian Hewitt <[email protected]>
> Signed-off-by: Martin Blumenstingl <[email protected]>
> ---
> Changes from v1 -> v2:
> - none
>
> Changes from v2 -> v3:
> - none
>
>
> drivers/tty/serial/meson_uart.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/tty/serial/meson_uart.c b/drivers/tty/serial/meson_uart.c
> index 74110017988a..2501db5a7aaf 100644
> --- a/drivers/tty/serial/meson_uart.c
> +++ b/drivers/tty/serial/meson_uart.c
> @@ -779,7 +779,7 @@ static int meson_uart_remove(struct platform_device *pdev)
> return 0;
> }
>
> -static struct meson_uart_data s4_uart_data = {
> +static struct meson_uart_data meson_g12a_uart_data = {
> .has_xtal_div2 = true,
> };
>
> @@ -788,9 +788,13 @@ static const struct of_device_id meson_uart_dt_match[] = {
> { .compatible = "amlogic,meson8-uart" },
> { .compatible = "amlogic,meson8b-uart" },
> { .compatible = "amlogic,meson-gx-uart" },
> + {
> + .compatible = "amlogic,meson-g12a-uart",
> + .data = (void *)&meson_g12a_uart_data,
> + },
> {
> .compatible = "amlogic,meson-s4-uart",
> - .data = (void *)&s4_uart_data,
> + .data = (void *)&meson_g12a_uart_data,
> },
> { /* sentinel */ },
> };
Reviewed-by: Neil Armstrong <[email protected]>
On 07/03/2023 23:26, Martin Blumenstingl wrote:
> Switch meson-12-common.dtsi to use the Meson G12A specific UART
> compatible string. This enables the "divide XTAL by 2" divider which
> improves support for UART attached Bluetooth modules (for example
> RTL8822CS) running at a baud rate of 1500000. Without dividing XTAL
> (24MHz) by 2 a baud rate of 1500000 cannot be generated cleanly and the
> resulting jitter breaks communication with the module.
>
> Tested-by: Christian Hewitt <[email protected]>
> Signed-off-by: Martin Blumenstingl <[email protected]>
> ---
> Greg, please don't take this through your tree. I included this patch
> to show the overall goal of this series. If Neil won't take this as
> part of another series then I'll send it separately.
>
> Changes from v1 -> v2:
> - keep meson-gx-uart as fallback compatible string
>
> Changes from v2 -> v3:
> - none
>
>
> arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi | 15 ++++++++++-----
> 1 file changed, 10 insertions(+), 5 deletions(-)
>
> diff --git a/arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi b/arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi
> index 123a56f7f818..904bcd4d2acf 100644
> --- a/arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi
> +++ b/arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi
> @@ -2046,7 +2046,8 @@ pwm_AO_cd: pwm@2000 {
> };
>
> uart_AO: serial@3000 {
> - compatible = "amlogic,meson-gx-uart",
> + compatible = "amlogic,meson-g12a-uart",
> + "amlogic,meson-gx-uart",
> "amlogic,meson-ao-uart";
> reg = <0x0 0x3000 0x0 0x18>;
> interrupts = <GIC_SPI 193 IRQ_TYPE_EDGE_RISING>;
> @@ -2056,7 +2057,8 @@ uart_AO: serial@3000 {
> };
>
> uart_AO_B: serial@4000 {
> - compatible = "amlogic,meson-gx-uart",
> + compatible = "amlogic,meson-g12a-uart",
> + "amlogic,meson-gx-uart",
> "amlogic,meson-ao-uart";
> reg = <0x0 0x4000 0x0 0x18>;
> interrupts = <GIC_SPI 197 IRQ_TYPE_EDGE_RISING>;
> @@ -2293,7 +2295,8 @@ clk_msr: clock-measure@18000 {
> };
>
> uart_C: serial@22000 {
> - compatible = "amlogic,meson-gx-uart";
> + compatible = "amlogic,meson-g12a-uart",
> + "amlogic,meson-gx-uart";
> reg = <0x0 0x22000 0x0 0x18>;
> interrupts = <GIC_SPI 93 IRQ_TYPE_EDGE_RISING>;
> clocks = <&xtal>, <&clkc CLKID_UART2>, <&xtal>;
> @@ -2302,7 +2305,8 @@ uart_C: serial@22000 {
> };
>
> uart_B: serial@23000 {
> - compatible = "amlogic,meson-gx-uart";
> + compatible = "amlogic,meson-g12a-uart",
> + "amlogic,meson-gx-uart";
> reg = <0x0 0x23000 0x0 0x18>;
> interrupts = <GIC_SPI 75 IRQ_TYPE_EDGE_RISING>;
> clocks = <&xtal>, <&clkc CLKID_UART1>, <&xtal>;
> @@ -2311,7 +2315,8 @@ uart_B: serial@23000 {
> };
>
> uart_A: serial@24000 {
> - compatible = "amlogic,meson-gx-uart";
> + compatible = "amlogic,meson-g12a-uart",
> + "amlogic,meson-gx-uart";
> reg = <0x0 0x24000 0x0 0x18>;
> interrupts = <GIC_SPI 26 IRQ_TYPE_EDGE_RISING>;
> clocks = <&xtal>, <&clkc CLKID_UART0>, <&xtal>;
Reviewed-by: Neil Armstrong <[email protected]>
On 07/03/2023 23:26, Martin Blumenstingl wrote:
> Switch meson-12-common.dtsi to use the Meson G12A specific UART
> compatible string. This enables the "divide XTAL by 2" divider which
> improves support for UART attached Bluetooth modules (for example
> RTL8822CS) running at a baud rate of 1500000. Without dividing XTAL
> (24MHz) by 2 a baud rate of 1500000 cannot be generated cleanly and the
> resulting jitter breaks communication with the module.
>
> Tested-by: Christian Hewitt <[email protected]>
> Signed-off-by: Martin Blumenstingl <[email protected]>
> ---
> Greg, please don't take this through your tree. I included this patch
> to show the overall goal of this series. If Neil won't take this as
> part of another series then I'll send it separately.
Actually I'm ok if Greg takes the whole patchset, including this one, via
the tty tree.
Neil
>
> Changes from v1 -> v2:
> - keep meson-gx-uart as fallback compatible string
>
> Changes from v2 -> v3:
> - none
>
>
> arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi | 15 ++++++++++-----
> 1 file changed, 10 insertions(+), 5 deletions(-)
>
> diff --git a/arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi b/arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi
> index 123a56f7f818..904bcd4d2acf 100644
> --- a/arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi
> +++ b/arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi
> @@ -2046,7 +2046,8 @@ pwm_AO_cd: pwm@2000 {
> };
>
> uart_AO: serial@3000 {
> - compatible = "amlogic,meson-gx-uart",
> + compatible = "amlogic,meson-g12a-uart",
> + "amlogic,meson-gx-uart",
> "amlogic,meson-ao-uart";
> reg = <0x0 0x3000 0x0 0x18>;
> interrupts = <GIC_SPI 193 IRQ_TYPE_EDGE_RISING>;
> @@ -2056,7 +2057,8 @@ uart_AO: serial@3000 {
> };
>
> uart_AO_B: serial@4000 {
> - compatible = "amlogic,meson-gx-uart",
> + compatible = "amlogic,meson-g12a-uart",
> + "amlogic,meson-gx-uart",
> "amlogic,meson-ao-uart";
> reg = <0x0 0x4000 0x0 0x18>;
> interrupts = <GIC_SPI 197 IRQ_TYPE_EDGE_RISING>;
> @@ -2293,7 +2295,8 @@ clk_msr: clock-measure@18000 {
> };
>
> uart_C: serial@22000 {
> - compatible = "amlogic,meson-gx-uart";
> + compatible = "amlogic,meson-g12a-uart",
> + "amlogic,meson-gx-uart";
> reg = <0x0 0x22000 0x0 0x18>;
> interrupts = <GIC_SPI 93 IRQ_TYPE_EDGE_RISING>;
> clocks = <&xtal>, <&clkc CLKID_UART2>, <&xtal>;
> @@ -2302,7 +2305,8 @@ uart_C: serial@22000 {
> };
>
> uart_B: serial@23000 {
> - compatible = "amlogic,meson-gx-uart";
> + compatible = "amlogic,meson-g12a-uart",
> + "amlogic,meson-gx-uart";
> reg = <0x0 0x23000 0x0 0x18>;
> interrupts = <GIC_SPI 75 IRQ_TYPE_EDGE_RISING>;
> clocks = <&xtal>, <&clkc CLKID_UART1>, <&xtal>;
> @@ -2311,7 +2315,8 @@ uart_B: serial@23000 {
> };
>
> uart_A: serial@24000 {
> - compatible = "amlogic,meson-gx-uart";
> + compatible = "amlogic,meson-g12a-uart",
> + "amlogic,meson-gx-uart";
> reg = <0x0 0x24000 0x0 0x18>;
> interrupts = <GIC_SPI 26 IRQ_TYPE_EDGE_RISING>;
> clocks = <&xtal>, <&clkc CLKID_UART0>, <&xtal>;
On Wed, Mar 08, 2023 at 01:21:21PM +0100, [email protected] wrote:
> On 07/03/2023 23:26, Martin Blumenstingl wrote:
> > Switch meson-12-common.dtsi to use the Meson G12A specific UART
> > compatible string. This enables the "divide XTAL by 2" divider which
> > improves support for UART attached Bluetooth modules (for example
> > RTL8822CS) running at a baud rate of 1500000. Without dividing XTAL
> > (24MHz) by 2 a baud rate of 1500000 cannot be generated cleanly and the
> > resulting jitter breaks communication with the module.
> >
> > Tested-by: Christian Hewitt <[email protected]>
> > Signed-off-by: Martin Blumenstingl <[email protected]>
> > ---
> > Greg, please don't take this through your tree. I included this patch
> > to show the overall goal of this series. If Neil won't take this as
> > part of another series then I'll send it separately.
>
> Actually I'm ok if Greg takes the whole patchset, including this one, via
> the tty tree.
Ok, I'll take them all, thanks.
greg k-h