spi: orion: support armada extended baud rates
Subsystems (2)
PATCH v2 1/1 spi: orion: support armada extended baud rates
From: Greg Ungerer <[email protected]>
The Armada SoC family implementation of this SPI hardware module has extended the configuration register to allow for a wider range of SPI clock rates. Specifically the Serial Baud Rate Pre-selection bits in the SPI Interface Configuration Register now also use bits 6 and 7 as well.
Modify the baud rate calculation to handle these differences for the Armada case. Potentially a baud rate can be setup using a number of different pre-scalar and scalar combinations. This code tries all possible pre-scalar divisors (8 in total) to try and find the most accuate set.
This change introduces a new device tree compatible device name "armada-spi". This is used in place of "orion-spi" on the Armada SoC parts.
---
Changes in v2:
Introduced a new devicetree compatible name for armada SPI support.
.../devicetree/bindings/spi/spi-orion.txt | 2 +- arch/arm/boot/dts/armada-370-xp.dtsi | 4 +- drivers/spi/spi-orion.c | 116 +++++++++++++++++---- 3 files changed, 97 insertions(+), 25 deletions(-)
Documentation/devicetree/bindings/spi/spi-orion.txt +1 -1
@@ -1,7 +1,7 @@ Marvell Orion SPI device Required properties: -- compatible : should be "marvell,orion-spi". +- compatible : should be "marvell,orion-spi" or "marvell,armada-spi". - reg : offset and length of the register set for the device - cell-index : Which of multiple SPI controllers is this. Optional properties:
arch/arm/boot/dts/armada-370-xp.dtsi +2 -2
@@ -110,7 +110,7 @@ }; spi0: spi@10600 { - compatible = "marvell,orion-spi"; + compatible = "marvell,armada-spi"; reg = <0x10600 0x28>; #address-cells = <1>; #size-cells = <0>;
@@ -121,7 +121,7 @@ }; spi1: spi@10680 { - compatible = "marvell,orion-spi"; + compatible = "marvell,armada-spi"; reg = <0x10680 0x28>; #address-cells = <1>; #size-cells = <0>;
drivers/spi/spi-orion.c +94 -22
177 lines not on this page · raw message
Signature · 6 lines
1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 1409835268-29555-1-git-send-email-gerg-JBU5SbJe1FlAfugRpC6u6w@public.gmane.org
Hi Greg,
Quoted 10 lines · On Thu, Sep 4, 2014 at 2:54 PM, <[email protected]>…
The Armada SoC family implementation of this SPI hardware module has extended the configuration register to allow for a wider range of SPI clock rates. Specifically the Serial Baud Rate Pre-selection bits in the SPI Interface Configuration Register now also use bits 6 and 7 as well.
Modify the baud rate calculation to handle these differences for the Armada case. Potentially a baud rate can be setup using a number of different pre-scalar and scalar combinations. This code tries all possible pre-scalar divisors (8 in total) to try and find the most accuate set.
Are the Orion rates and register bits a subset of the Armada ones? I.e. does the Armada work with the Orion setup?
Review
Quoted 6 lines
This change introduces a new device tree compatible device name "armada-spi". This is used in place of "orion-spi" on the Armada SoC parts.
(quoted diff) +1
-1- compatible = "marvell,orion-spi"; + compatible = "marvell,armada-spi";
If the answer to my above question is yes, you want to keep "marvell,orion-spi" as a fallback.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): CAMuHMdWDOaPnmCzThqCo2848eDj6jmi-eaXM1YAXQLi41da34A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Hi Geert,
Quoted 6 lines · Geert Uytterhoeven
Quoted 5 lines · On Thu, Sep 4, 2014 at 2:54 PM, <[email protected]>…
The Armada SoC family implementation of this SPI hardware module has extended the configuration register to allow for a wider range of SPI clock rates. Specifically the Serial Baud Rate Pre-selection bits in the SPI Interface Configuration Register now also use bits 6 and 7 as well.
Quoted 8 lines
Quoted 5 lines
Modify the baud rate calculation to handle these differences for the Armada case. Potentially a baud rate can be setup using a number of different pre-scalar and scalar combinations. This code tries all possible pre-scalar divisors (8 in total) to try and find the most accuate set.
Are the Orion rates and register bits a subset of the Armada ones? I.e. does the Armada work with the Orion setup?
The bits used by the orion are a subset (bits 0-4 of the SPI configuration register) of those used by the armada (bits 0-4 and 6-7).
In practice the defined prescalar values for the orion do give the same divisor for the same bits set on armada. The extra bits on the armada let you get to lower SPI baudrates (which is more of a problem on the armada with its higher core clocks).
Quoted 9 lines
Review
Quoted 6 lines
This change introduces a new device tree compatible device name "armada-spi". This is used in place of "orion-spi" on the Armada SoC parts.
(quoted diff) +1
-1- compatible = "marvell,orion-spi"; + compatible = "marvell,armada-spi";If the answer to my above question is yes, you want to keep "marvell,orion-spi" as a fallback.
Do you mean like this?
compatible = "marvell,orion-spi", "marvell,armada-spi";
Regards
Greg
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): [email protected]
Hi Greg,
Quoted 11 lines · Greg Ungerer
Quoted 2 lines
Are the Orion rates and register bits a subset of the Armada ones? I.e. does the Armada work with the Orion setup?
The bits used by the orion are a subset (bits 0-4 of the SPI configuration register) of those used by the armada (bits 0-4 and 6-7).
In practice the defined prescalar values for the orion do give the same divisor for the same bits set on armada. The extra bits on the armada let you get to lower SPI baudrates (which is more of a problem on the armada with its higher core clocks).
OK, so the answer is yes.
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
This change introduces a new device tree compatible device name "armada-spi". This is used in place of "orion-spi" on the Armada SoC parts.
(quoted diff) +1
-1- compatible = "marvell,orion-spi"; + compatible = "marvell,armada-spi";
Quoted 6 lines
Quoted 2 lines
If the answer to my above question is yes, you want to keep "marvell,orion-spi" as a fallback.
Do you mean like this?
compatible = "marvell,orion-spi", "marvell,armada-spi";
No, the other way around (from most-specific to least-specific):
compatible = "marvell,armada-spi", "marvell,orion-spi"
So the Armada version is used if available, and the Orion version is used as a fallback.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): CAMuHMdWf6_yBhpNgK=wJcQqzLNJvTnC95SrqrcZyRH+jGL93vA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Hi Geert,
Quoted 24 lines · Geert Uytterhoeven
Hi Greg,
Quoted 10 lines · Greg Ungerer
Quoted 2 lines
Are the Orion rates and register bits a subset of the Armada ones? I.e. does the Armada work with the Orion setup?
The bits used by the orion are a subset (bits 0-4 of the SPI configuration register) of those used by the armada (bits 0-4 and 6-7).
In practice the defined prescalar values for the orion do give the same divisor for the same bits set on armada. The extra bits on the armada let you get to lower SPI baudrates (which is more of a problem on the armada with its higher core clocks).
OK, so the answer is yes.
Quoted 9 lines
Quoted 7 lines
Review
Quoted 5 lines
This change introduces a new device tree compatible device name "armada-spi". This is used in place of "orion-spi" on the Armada SoC parts.
(quoted diff) +1
-1- compatible = "marvell,orion-spi"; + compatible = "marvell,armada-spi";If the answer to my above question is yes, you want to keep "marvell,orion-spi" as a fallback.
Do you mean like this?
Quoted 7 lines
Quoted 1 line
compatible = "marvell,orion-spi", "marvell,armada-spi";No, the other way around (from most-specific to least-specific):
compatible = "marvell,armada-spi", "marvell,orion-spi"
So the Armada version is used if available, and the Orion version is used as a fallback.
Ok, got it. Thanks.
Regards
Greg
Quoted 11 lines
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): [email protected]
Hi Greg,
(Ccing mvebu guys, full discussion here: http://www.spinics.net/lists/devicetree/msg47806.html)
Quoted 7 lines · Greg Ungerer
Quoted 6 lines · Geert Uytterhoeven
No, the other way around (from most-specific to least-specific):
compatible = "marvell,armada-spi", "marvell,orion-spi"
So the Armada version is used if available, and the Orion version is used as a fallback.
Since you are doing another spin, please split this in two patches. The driver and devicetree binding documentation should be in one patch, and the devicetree .dtsi change in another patch.
By following Geert's request about the compatible, you make sure both patches can be merged through different maintainers, and that an old devicetree blob can be used safely.
Quoted 7 lines
Quoted 2 lines
Also what about armada370-xp, armada375, armada380
and any other variants out there?I don't know. I don't have access to functional specs for anything other than the 370. I expect they are probably the same though. (Can anyone confirm?)
Confirmed. Judging from the specs, seems the same SPI IP is on all the Armada SoCs; you can do the 'armada-spi' compatible addition on 375 and 38x.
Did a few tests on the AXP-GP board (which has an SPI flash) using 'orion-spi' and 'armada-spi' compatibles.
I haven't been able to spot any speed difference, though (perhaps my test is too limited?), so I wonder if there's any improvement with this patch?
Thanks,
Signature · 7 lines
Ezequiel García, Free Electrons Embedded Linux, Kernel and Android Engineering http://free-electrons.com -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): [email protected]
Hello,
Quoted 2 lines · Ezequiel Garcia
Confirmed. Judging from the specs, seems the same SPI IP is on all the Armada SoCs; you can do the 'armada-spi' compatible addition on 375 and 38x.
However, I believe a compatible string like "armada-370-spi" should be used instead of "armada-spi". The normal rule is to use the oldest SoC that introduced a certain feature as the compatible string.
Remember for example that Armada 1500 (Berlin) is a completely different line of SoC, which cannot use this SPI driver.
Thanks Greg for working on this! I noticed this as well recently when doing an SPI development, but you were faster than me in proposing a patch!
Thanks,
Thomas
Signature · 7 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 20140906151654.49584b70-wi1+55ScJUtKEb57/[email protected]
Hi Thomas,
Quoted 9 lines · Thomas Petazzoni
Hello,
Quoted 2 lines · Ezequiel Garcia
Confirmed. Judging from the specs, seems the same SPI IP is on all the Armada SoCs; you can do the 'armada-spi' compatible addition on 375 and 38x.
However, I believe a compatible string like "armada-370-spi" should be used instead of "armada-spi". The normal rule is to use the oldest SoC that introduced a certain feature as the compatible string.
Ok, will make it that then.
Quoted 7 lines
Remember for example that Armada 1500 (Berlin) is a completely different line of SoC, which cannot use this SPI driver.
Thanks Greg for working on this! I noticed this as well recently when doing an SPI development, but you were faster than me in proposing a patch!
No problem :-)
Regards
Greg
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi Ezequiel,
Quoted 12 lines · Ezequiel Garcia
Hi Greg,
(Ccing mvebu guys, full discussion here: http://www.spinics.net/lists/devicetree/msg47806.html)
Quoted 7 lines · Greg Ungerer
Quoted 6 lines · Geert Uytterhoeven
No, the other way around (from most-specific to least-specific):
compatible = "marvell,armada-spi", "marvell,orion-spi"
So the Armada version is used if available, and the Orion version is used as a fallback.
Quoted 7 lines
Since you are doing another spin, please split this in two patches. The driver and devicetree binding documentation should be in one patch, and the devicetree .dtsi change in another patch.
By following Geert's request about the compatible, you make sure both patches can be merged through different maintainers, and that an old devicetree blob can be used safely.
Sure, yes, I would prefer that too. I didn't do it for this because checkpatch complained for the spi-orion.c change in its own:
WARNING: DT compatible string "marvell,armada-spi" appears un-documented -- check ./Documentation/devicetree/bindings/ #170: FILE: drivers/spi/spi-orion.c:412:
+ { .compatible = "marvell,armada-spi", .data = &armada_spi_dev_data, },
But I am happy to ignore that :-)
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
Also what about armada370-xp, armada375, armada380
and any other variants out there?I don't know. I don't have access to functional specs for anything other than the 370. I expect they are probably the same though. (Can anyone confirm?)
Quoted 8 lines
Confirmed. Judging from the specs, seems the same SPI IP is on all the Armada SoCs; you can do the 'armada-spi' compatible addition on 375 and 38x.
Did a few tests on the AXP-GP board (which has an SPI flash) using 'orion-spi' and 'armada-spi' compatibles.
Thanks, appreciate that.
Quoted 3 lines
I haven't been able to spot any speed difference, though (perhaps my test is too limited?), so I wonder if there's any improvement with this patch?
Try setting a speed like 2MHz for an SPI device. It will fail because that is below the minimum divisor it can calculate with the old orion style behavior. I have an armada 370 based board with an ethernet switch that is controlled by SPI. Its typical SPI bus speed is 2MHz, that is how I came up against this.
Regards
Greg
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): [email protected]
Hi Greg,
Quoted 27 lines · Greg Ungerer
Hi Ezequiel,
Quoted 12 lines · Ezequiel Garcia
Hi Greg,
(Ccing mvebu guys, full discussion here: http://www.spinics.net/lists/devicetree/msg47806.html)
Quoted 7 lines · Greg Ungerer
Quoted 6 lines · Geert Uytterhoeven
No, the other way around (from most-specific to least-specific):
compatible = "marvell,armada-spi", "marvell,orion-spi"
So the Armada version is used if available, and the Orion version is used as a fallback.
Quoted 7 lines
Since you are doing another spin, please split this in two patches. The driver and devicetree binding documentation should be in one patch, and the devicetree .dtsi change in another patch.
By following Geert's request about the compatible, you make sure both patches can be merged through different maintainers, and that an old devicetree blob can be used safely.
Sure, yes, I would prefer that too. I didn't do it for this because checkpatch
complained for thespi-orion.cchange in its own:
Quoted 7 lines
WARNING: DT compatible string "marvell,armada-spi" appears un-documented -- check
./Documentation/devicetree/bindings/
#170: FILE:drivers/spi/spi-orion.c:412:
+ { .compatible = "marvell,armada-spi", .data =&armada_spi_dev_data, },But I am happy to ignore that :-)
If you split in two patches like this:
Patch #1: "spi: orion: Add a new foo feature"
.../devicetree/bindings/spi/spi-orion.txt | 2 +- drivers/spi/spi-orion.c | 116 +++++++++++++++++----
Patch #2: "ARM: mvebu: Add new compatible string for SPI"
arch/arm/boot/dts/armada-370-xp.dtsi | 4 +-
Then checkpatch shouldn't complain. As you can see, it makes more sense like this. The change to the devicetree binding in the driver and properly documented, but the devicetree files per-se, get modified in another patch.
Signature · 7 lines
Ezequiel García, Free Electrons Embedded Linux, Kernel and Android Engineering http://free-electrons.com -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): [email protected]
Hi Ezequiel,
Quoted 45 lines · Ezequiel Garcia
Hi Greg,
Quoted 27 lines · Greg Ungerer
Hi Ezequiel,
Quoted 12 lines · Ezequiel Garcia
Hi Greg,
(Ccing mvebu guys, full discussion here: http://www.spinics.net/lists/devicetree/msg47806.html)
Quoted 7 lines · Greg Ungerer
Quoted 6 lines · Geert Uytterhoeven
No, the other way around (from most-specific to least-specific):
compatible = "marvell,armada-spi", "marvell,orion-spi"
So the Armada version is used if available, and the Orion version is used as a fallback.
Quoted 7 lines
Since you are doing another spin, please split this in two patches. The driver and devicetree binding documentation should be in one patch, and the devicetree .dtsi change in another patch.
By following Geert's request about the compatible, you make sure both patches can be merged through different maintainers, and that an old devicetree blob can be used safely.
Sure, yes, I would prefer that too. I didn't do it for this because checkpatch
complained for thespi-orion.cchange in its own:Quoted 7 lines
WARNING: DT compatible string "marvell,armada-spi" appears un-documented -- check
./Documentation/devicetree/bindings/
#170: FILE:drivers/spi/spi-orion.c:412:
+ { .compatible = "marvell,armada-spi", .data =&armada_spi_dev_data, },But I am happy to ignore that :-)
If you split in two patches like this:
Patch #1: "spi: orion: Add a new foo feature"
.../devicetree/bindings/spi/spi-orion.txt | 2 +- drivers/spi/spi-orion.c | 116 +++++++++++++++++----
Quoted 7 lines
Patch #2: "ARM: mvebu: Add new compatible string for SPI"
arch/arm/boot/dts/armada-370-xp.dtsi | 4 +-Then checkpatch shouldn't complain. As you can see, it makes more sense like this. The change to the devicetree binding in the driver and properly documented, but the devicetree files per-se, get modified in another patch.
Ok, I see. Thanks.
Regards
Greg
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html