serial: 8250_dw: Introduce SG2044 uart support.
Subsystems (4)
cover serial: 8250_dw: Introduce SG2044 uart support.
SG2044 relys on an internal divisor when calculating bitrate, which means a wrong clock for the most common bitrates. So a quirk is needed for this uart device to skip the set rate call and only relys on the internal UART divisor.
Inochi Amaoto (2):
dt-bindings: serial: snps-dw-apb-uart: Add Sophgo SG2044 uarts
serial: 8250_dw: Add Sophgo SG2044 quirk
.../devicetree/bindings/serial/snps-dw-apb-uart.yaml | 4 ++++ drivers/tty/serial/8250/8250_dw.c | 6 ++++++ 2 files changed, 10 insertions(+)
--
2.47.0
PATCH 1/2 dt-bindings: serial: snps-dw-apb-uart: Add Sophgo SG2044 uarts
Add compatibles string for the Sophgo SG2044 uarts.
--- .../devicetree/bindings/serial/snps-dw-apb-uart.yaml | 4 ++++ 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/serial/snps-dw-apb-uart.yaml +4 -0
@@ -58,6 +58,10 @@ properties: - brcm,bcm11351-dw-apb-uart - brcm,bcm21664-dw-apb-uart - const: snps,dw-apb-uart + - items: + - enum: + - sophgo,sg2044-uart + - const: snps,dw-apb-uart - items: - enum: - starfive,jh7100-hsuart
Signature · 1 line
2.47.0
PATCH 2/2 serial: 8250_dw: Add Sophgo SG2044 quirk
In reply to Inochi AmaotoSG2044 relys on an internal divisor when calculating bitrate, which means a wrong clock for the most common bitrates. So add a quirk for this uart device to skip the set rate call and only relys on the internal UART divisor.
--- drivers/tty/serial/8250/8250_dw.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/tty/serial/8250/8250_dw.c +6 -0
@@ -750,6 +750,11 @@ static const struct dw8250_platform_data dw8250_renesas_rzn1_data = { .quirks = DW_UART_QUIRK_CPR_VALUE | DW_UART_QUIRK_IS_DMA_FC, }; +static const struct dw8250_platform_data dw8250_sophgo_sg2044_data = { + .usr_reg =DW_UART_USR , + .quirks =DW_UART_QUIRK_SKIP_SET_RATE , +}; +static const struct dw8250_platform_data dw8250_starfive_jh7100_data = { .usr_reg =DW_UART_USR , .quirks =DW_UART_QUIRK_SKIP_SET_RATE ,
@@ -760,6 +765,7 @@ static const struct of_device_id dw8250_of_match[] = { { .compatible = "cavium,octeon-3860-uart", .data = &dw8250_octeon_3860_data }, { .compatible = "marvell,armada-38x-uart", .data = &dw8250_armada_38x_data }, { .compatible = "renesas,rzn1-uart", .data = &dw8250_renesas_rzn1_data }, + { .compatible = "sophgo,sg2044-uart", .data = &dw8250_sophgo_sg2044_data }, { .compatible = "starfive,jh7100-uart", .data = &dw8250_starfive_jh7100_data }, {/* Sentinel */ } };
Signature · 1 line
2.47.0
Re: [PATCH 1/2] dt-bindings: serial: snps-dw-apb-uart: Add Sophgo SG2044 uarts
In reply to Inochi AmaotoQuoted 1 line · Inochi Amaoto
Add compatibles string for the Sophgo SG2044 uarts.
This we see from the diff, say something about hardware.
Quoted 11 lines
Signed-off-by Inochi Amaoto <[email protected]>--- .../devicetree/bindings/serial/snps-dw-apb-uart.yaml | 4 ++++ 1 file changed, 4 insertions(+)Documentation/devicetree/bindings/serial/snps-dw-apb-uart.yaml +0
-0
Documentation/devicetree/bindings/serial/snps-dw-apb-uart.yaml properties: · line 63
Quoted 6 lines
Documentation/devicetree/bindings/serial/snps-dw-apb-uart.yaml +3
-0@@ -58,6 +58,10 @@ properties: - brcm,bcm11351-dw-apb-uart - brcm,bcm21664-dw-apb-uart - const: snps,dw-apb-uart + - items: + - enum: + - sophgo,sg2044-uart
I would just add it to starfive enum, but this is fine as well.
Best regards,
Krzysztof
Re: [PATCH 1/2] dt-bindings: serial: snps-dw-apb-uart: Add Sophgo SG2044 uarts
Quoted 5 lines · Krzysztof Kozlowski
Quoted 1 line · Inochi Amaoto
Add compatibles string for the Sophgo SG2044 uarts.
This we see from the diff, say something about hardware.
The reason for this compatiable (and the hardware) is mainly in the next patch. Will it be better to submit a new verion with improved description? If so, I wonder whether I can reserve your ack.
Quoted 20 lines
Quoted 11 lines
Signed-off-by Inochi Amaoto <[email protected]>--- .../devicetree/bindings/serial/snps-dw-apb-uart.yaml | 4 ++++ 1 file changed, 4 insertions(+)Documentation/devicetree/bindings/serial/snps-dw-apb-uart.yaml +0
-0Documentation/devicetree/bindings/serial/snps-dw-apb-uart.yaml properties: · line 63
Quoted 6 lines
Documentation/devicetree/bindings/serial/snps-dw-apb-uart.yaml +3
-0@@ -58,6 +58,10 @@ properties: - brcm,bcm11351-dw-apb-uart - brcm,bcm21664-dw-apb-uart - const: snps,dw-apb-uart + - items: + - enum: + - sophgo,sg2044-uartI would just add it to starfive enum, but this is fine as well.
Quoted 5 lines
Best regards,
Krzysztof
Thanks.
Regard,
Inochi
Andy Shevchenko
reviewerRe: [PATCH 1/2] dt-bindings: serial: snps-dw-apb-uart: Add Sophgo SG2044 uarts
Quoted 11 lines · Inochi Amaoto
Quoted 4 lines · Krzysztof Kozlowski
Quoted 1 line · Inochi Amaoto
Add compatibles string for the Sophgo SG2044 uarts.
This we see from the diff, say something about hardware.
The reason for this compatiable (and the hardware) is mainly in the next patch. Will it be better to submit a new verion with improved description? If so, I wonder whether I can reserve your ack.
Quoted 1 line
I would just add it to starfive enum, but this is fine as well.
Even after reading the second patch I don't understand why you shouldn't re-use the starfive compatible or make a new one that covers this quirk? At least I would see that as second patch is basically not needed.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Andy Shevchenko
reviewerRe: [PATCH 2/2] serial: 8250_dw: Add Sophgo SG2044 quirk
In reply to Inochi AmaotoQuoted 4 lines · Inochi Amaoto
SG2044 relys on an internal divisor when calculating bitrate, which means a wrong clock for the most common bitrates. So add a quirk for this uart device to skip the set rate call and only relys on the internal UART divisor.
...
drivers/tty/serial/8250/8250_dw.c static const struct dw8250_platform_data dw8250_renesas_rzn1_data = { · line 760
Quoted 8 lines
drivers/tty/serial/8250/8250_dw.c +5
-0+static const struct dw8250_platform_data dw8250_sophgo_sg2044_data = { + .usr_reg =DW_UART_USR , + .quirks =DW_UART_QUIRK_SKIP_SET_RATE , +}; +static const struct dw8250_platform_data dw8250_starfive_jh7100_data = { .usr_reg =DW_UART_USR , .quirks =DW_UART_QUIRK_SKIP_SET_RATE ,
For the bare minimum this should be deduplicated as to have one record for now.
static const struct dw8250_platform_data dw8250_skip_set_rate_data = {
.usr_reg = DW_UART_USR,
.quirks = DW_UART_QUIRK_SKIP_SET_RATE,
};If we need different quirks in the future, they can be split again. Or, if you certain that new quirks will come, mention this in the commit message.
...
drivers/tty/serial/8250/8250_dw.c static const struct of_device_id dw8250_of_match[] = { · line 769
Quoted 5 lines
drivers/tty/serial/8250/8250_dw.c +1
-0{ .compatible = "cavium,octeon-3860-uart", .data = &dw8250_octeon_3860_data }, { .compatible = "marvell,armada-38x-uart", .data = &dw8250_armada_38x_data }, { .compatible = "renesas,rzn1-uart", .data = &dw8250_renesas_rzn1_data }, + { .compatible = "sophgo,sg2044-uart", .data = &dw8250_sophgo_sg2044_data }, { .compatible = "starfive,jh7100-uart", .data = &dw8250_starfive_jh7100_data },
I think my proposal for having a common compatible for those two is a no-go as compatible strings are for the (unique) hardware and shouldn't be abstracted based on some Linux or other OS shortcuts / quirks.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Hi, Inochi,
Can you please post this patchset to linux-riscv next time too?
Thanks,
Chen
Quoted 16 lines · Inochi Amaoto
SG2044 relys on an internal divisor when calculating bitrate, which means a wrong clock for the most common bitrates. So a quirk is needed for this uart device to skip the set rate call and only relys on the internal UART divisor.
Inochi Amaoto (2):
dt-bindings: serial: snps-dw-apb-uart: Add Sophgo SG2044 uarts
serial: 8250_dw: Add Sophgo SG2044 quirk.../devicetree/bindings/serial/snps-dw-apb-uart.yaml | 4 ++++ drivers/tty/serial/8250/8250_dw.c | 6 ++++++ 2 files changed, 10 insertions(+)--
2.47.0
Re: [PATCH 1/2] dt-bindings: serial: snps-dw-apb-uart: Add Sophgo SG2044 uarts
In reply to Andy ShevchenkoQuoted 11 lines · Andy Shevchenko
Quoted 10 lines · Inochi Amaoto
Quoted 4 lines · Krzysztof Kozlowski
Quoted 1 line · Inochi Amaoto
Add compatibles string for the Sophgo SG2044 uarts.
This we see from the diff, say something about hardware.
The reason for this compatiable (and the hardware) is mainly in the next patch. Will it be better to submit a new verion with improved description? If so, I wonder whether I can reserve your ack.
Quoted 6 lines
Quoted 1 line
Quoted 1 line
I would just add it to starfive enum, but this is fine as well.
Even after reading the second patch I don't understand why you shouldn't re-use the starfive compatible or make a new one that covers this quirk? At least I would see that as second patch is basically not needed.
I do not think it is good to re-use the starfive compatible, it is weird that a sophgo SoC has a peripheral on the statfive SoC. Another suggestion for adding a new one that covers the quirk is a good idea for me, but I am not sure whether it may cause some misunderstanding like reuse the starfive compatible. If the second one is possible, it is OK for me to drop the second patch.
Regard,
Inochi
Re: [PATCH 2/2] serial: 8250_dw: Add Sophgo SG2044 quirk
In reply to Andy ShevchenkoQuoted 19 lines · Andy Shevchenko
Quoted 4 lines · Inochi Amaoto
SG2044 relys on an internal divisor when calculating bitrate, which means a wrong clock for the most common bitrates. So add a quirk for this uart device to skip the set rate call and only relys on the internal UART divisor.
...
drivers/tty/serial/8250/8250_dw.c static const struct dw8250_platform_data dw8250_renesas_rzn1_data = { · line 760
Quoted 8 lines
drivers/tty/serial/8250/8250_dw.c +5
-0+static const struct dw8250_platform_data dw8250_sophgo_sg2044_data = { + .usr_reg =DW_UART_USR , + .quirks =DW_UART_QUIRK_SKIP_SET_RATE , +}; +static const struct dw8250_platform_data dw8250_starfive_jh7100_data = { .usr_reg =DW_UART_USR , .quirks =DW_UART_QUIRK_SKIP_SET_RATE ,For the bare minimum this should be deduplicated as to have one record for now.
Quoted 9 lines
static const struct dw8250_platform_data dw8250_skip_set_rate_data = { .usr_reg = DW_UART_USR, .quirks = DW_UART_QUIRK_SKIP_SET_RATE, };If we need different quirks in the future, they can be split again. Or, if you certain that new quirks will come, mention this in the commit message.
Yes, renaming this quirk as a common one is better. I will prefer if this patch is necessary. Duplication is not a good idea.
Quoted 12 lines
...
drivers/tty/serial/8250/8250_dw.c static const struct of_device_id dw8250_of_match[] = { · line 769
Quoted 5 lines
drivers/tty/serial/8250/8250_dw.c +1
-0{ .compatible = "cavium,octeon-3860-uart", .data = &dw8250_octeon_3860_data }, { .compatible = "marvell,armada-38x-uart", .data = &dw8250_armada_38x_data }, { .compatible = "renesas,rzn1-uart", .data = &dw8250_renesas_rzn1_data }, + { .compatible = "sophgo,sg2044-uart", .data = &dw8250_sophgo_sg2044_data }, { .compatible = "starfive,jh7100-uart", .data = &dw8250_starfive_jh7100_data },I think my proposal for having a common compatible for those two is a no-go as compatible strings are for the (unique) hardware and shouldn't be abstracted based on some Linux or other OS shortcuts / quirks.
Yes, a common compatible is not a good idea. But it is OK to share a common quirk, which means they have the same problem.
Regards,
Inochi