diff mbox

[2/3] spi: orion: Fix extended baud rates for each Armada SoCs

Message ID 1432633484-18758-3-git-send-email-gregory.clement@free-electrons.com
State Accepted, archived
Headers show

Commit Message

Gregory CLEMENT May 26, 2015, 9:44 a.m. UTC
The commit df59fa7f4bca "spi: orion: support armada extended baud
rates" made the assumptions that all the Armada SoCs supported the
same maximum frequency. However, according the hardware datasheet, the
maximum frequency supported by the Armada 370 SoC is tclk/4, for the
Armada XP, Armada 38x and Armada 39x SoCs the limitation is 50MHz and
for the Armada 375 it is tclk/15.

This patch introduces new compatible strings to handle all these
case. In order to be future proof a compatible was created for each
SoC even if currently some SoCs seem using the same IP.

Signed-off-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
---
 .../devicetree/bindings/spi/spi-orion.txt          |  8 +++-
 drivers/spi/spi-orion.c                            | 47 ++++++++++++++++++++--
 2 files changed, 50 insertions(+), 5 deletions(-)

Comments

Mark Brown May 26, 2015, 10:38 a.m. UTC | #1
On Tue, May 26, 2015 at 11:44:43AM +0200, Gregory CLEMENT wrote:
> The commit df59fa7f4bca "spi: orion: support armada extended baud
> rates" made the assumptions that all the Armada SoCs supported the
> same maximum frequency. However, according the hardware datasheet, the
> maximum frequency supported by the Armada 370 SoC is tclk/4, for the
> Armada XP, Armada 38x and Armada 39x SoCs the limitation is 50MHz and
> for the Armada 375 it is tclk/15.

Applied, thanks.
Andrew Lunn May 26, 2015, 12:08 p.m. UTC | #2
> --- a/Documentation/devicetree/bindings/spi/spi-orion.txt
> +++ b/Documentation/devicetree/bindings/spi/spi-orion.txt
> @@ -1,7 +1,13 @@
>  Marvell Orion SPI device
>  
>  Required properties:
> -- compatible : should be "marvell,orion-spi" or "marvell,armada-370-spi".
> +- compatible : should be on of the following:
> +    - "marvell,orion-spi" for the Orion, mv78x00, Kirkwood and Dove SoCs
> +    - "marvell,armada-370-spi", for the Armada 370 SoCs
> +    - "marvell,armada-375-spi", for the Armada 375 SoCs
> +    - "marvell,armada-380-spi", for the Armada 38x SoCs
> +    - "marvell,armada-390-spi", for the Armada 38x SoCs

Hi Gregory

Is that a typ0?

   Andrew
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Gregory CLEMENT May 26, 2015, 12:20 p.m. UTC | #3
Hi Andrew, Mark,

On 26/05/2015 14:08, Andrew Lunn wrote:
>> --- a/Documentation/devicetree/bindings/spi/spi-orion.txt
>> +++ b/Documentation/devicetree/bindings/spi/spi-orion.txt
>> @@ -1,7 +1,13 @@
>>  Marvell Orion SPI device
>>  
>>  Required properties:
>> -- compatible : should be "marvell,orion-spi" or "marvell,armada-370-spi".
>> +- compatible : should be on of the following:
>> +    - "marvell,orion-spi" for the Orion, mv78x00, Kirkwood and Dove SoCs
>> +    - "marvell,armada-370-spi", for the Armada 370 SoCs
>> +    - "marvell,armada-375-spi", for the Armada 375 SoCs
>> +    - "marvell,armada-380-spi", for the Armada 38x SoCs
>> +    - "marvell,armada-390-spi", for the Armada 38x SoCs
> 
> Hi Gregory
> 
> Is that a typ0?

yes it is! :/

Mark do you want a new patch or do you prefer fixing the typo
yourself ? it should be
    - "marvell,armada-390-spi", for the Armada 39x SoCs
instead of
    - "marvell,armada-390-spi", for the Armada 38x SoCs

s/38x/39x/ on this line.


Thanks,

Gregory


> 
>    Andrew
>
Mark Brown May 27, 2015, 5:45 p.m. UTC | #4
On Tue, May 26, 2015 at 02:20:08PM +0200, Gregory CLEMENT wrote:

> Mark do you want a new patch or do you prefer fixing the typo
> yourself ? it should be

I fixed it up locally (in general it's easier to just send the patch
though).
Gregory CLEMENT May 27, 2015, 5:47 p.m. UTC | #5
Hi Mark,

On 27/05/2015 19:45, Mark Brown wrote:
> On Tue, May 26, 2015 at 02:20:08PM +0200, Gregory CLEMENT wrote:
> 
>> Mark do you want a new patch or do you prefer fixing the typo
>> yourself ? it should be
> 
> I fixed it up locally (in general it's easier to just send the patch
> though).
> 

Thanks! And next time I will send a v2 then if it is easier for you.

Gregory
Mark Brown May 27, 2015, 6:39 p.m. UTC | #6
On Wed, May 27, 2015 at 07:47:47PM +0200, Gregory CLEMENT wrote:
> On 27/05/2015 19:45, Mark Brown wrote:

> > I fixed it up locally (in general it's easier to just send the patch
> > though).

> Thanks! And next time I will send a v2 then if it is easier for you.

I'd say it's just easier in general - "can you please either fix this up
locally or apply this patch" means that whatever the answer is it can be
acted on immediately.
diff mbox

Patch

diff --git a/Documentation/devicetree/bindings/spi/spi-orion.txt b/Documentation/devicetree/bindings/spi/spi-orion.txt
index 50c3a3de61c1..51d63df3d99d 100644
--- a/Documentation/devicetree/bindings/spi/spi-orion.txt
+++ b/Documentation/devicetree/bindings/spi/spi-orion.txt
@@ -1,7 +1,13 @@ 
 Marvell Orion SPI device
 
 Required properties:
-- compatible : should be "marvell,orion-spi" or "marvell,armada-370-spi".
+- compatible : should be on of the following:
+    - "marvell,orion-spi" for the Orion, mv78x00, Kirkwood and Dove SoCs
+    - "marvell,armada-370-spi", for the Armada 370 SoCs
+    - "marvell,armada-375-spi", for the Armada 375 SoCs
+    - "marvell,armada-380-spi", for the Armada 38x SoCs
+    - "marvell,armada-390-spi", for the Armada 38x SoCs
+    - "marvell,armada-xp-spi", for the Armada XP SoCs
 - reg : offset and length of the register set for the device
 - cell-index : Which of multiple SPI controllers is this.
 Optional properties:
diff --git a/drivers/spi/spi-orion.c b/drivers/spi/spi-orion.c
index ff97cabdaa81..8cad107a5b3f 100644
--- a/drivers/spi/spi-orion.c
+++ b/drivers/spi/spi-orion.c
@@ -391,7 +391,7 @@  static const struct orion_spi_dev orion_spi_dev_data = {
 	.prescale_mask = ORION_SPI_CLK_PRESCALE_MASK,
 };
 
-static const struct orion_spi_dev armada_spi_dev_data = {
+static const struct orion_spi_dev armada_370_spi_dev_data = {
 	.typ = ARMADA_SPI,
 	.min_divisor = 4,
 	.max_divisor = 1920,
@@ -399,9 +399,46 @@  static const struct orion_spi_dev armada_spi_dev_data = {
 	.prescale_mask = ARMADA_SPI_CLK_PRESCALE_MASK,
 };
 
+static const struct orion_spi_dev armada_xp_spi_dev_data = {
+	.typ = ARMADA_SPI,
+	.max_hz = 50000000,
+	.max_divisor = 1920,
+	.prescale_mask = ARMADA_SPI_CLK_PRESCALE_MASK,
+};
+
+static const struct orion_spi_dev armada_375_spi_dev_data = {
+	.typ = ARMADA_SPI,
+	.min_divisor = 15,
+	.max_divisor = 1920,
+	.prescale_mask = ARMADA_SPI_CLK_PRESCALE_MASK,
+};
+
 static const struct of_device_id orion_spi_of_match_table[] = {
-	{ .compatible = "marvell,orion-spi", .data = &orion_spi_dev_data, },
-	{ .compatible = "marvell,armada-370-spi", .data = &armada_spi_dev_data, },
+	{
+		.compatible = "marvell,orion-spi",
+		.data = &orion_spi_dev_data,
+	},
+	{
+		.compatible = "marvell,armada-370-spi",
+		.data = &armada_370_spi_dev_data,
+	},
+	{
+		.compatible = "marvell,armada-375-spi",
+		.data = &armada_375_spi_dev_data,
+	},
+	{
+		.compatible = "marvell,armada-380-spi",
+		.data = &armada_xp_spi_dev_data,
+	},
+	{
+		.compatible = "marvell,armada-390-spi",
+		.data = &armada_xp_spi_dev_data,
+	},
+	{
+		.compatible = "marvell,armada-xp-spi",
+		.data = &armada_xp_spi_dev_data,
+	},
+
 	{}
 };
 MODULE_DEVICE_TABLE(of, orion_spi_of_match_table);
@@ -473,9 +510,11 @@  static int orion_spi_probe(struct platform_device *pdev)
 					"marvell,armada-370-spi"))
 		master->max_speed_hz = min(devdata->max_hz,
 				DIV_ROUND_UP(tclk_hz, devdata->min_divisor));
-	else
+	else if (devdata->min_divisor)
 		master->max_speed_hz =
 			DIV_ROUND_UP(tclk_hz, devdata->min_divisor);
+	else
+		master->max_speed_hz = devdata->max_hz;
 	master->min_speed_hz = DIV_ROUND_UP(tclk_hz, devdata->max_divisor);
 
 	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);