Skip to contentSkip to conversation

spi: orion: support armada extended baud rates

PATCH Applied [email protected] 3 participants 7 messages Sep 28, 2014 – Oct 17, 2014 2 messages not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v3 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 accurate set.

This change introduces (and documents) a new device tree compatible device name "armada-370-spi" to support this.

---
Changes in v2:
Introduced a new devicetree compatible name for armada SPI support.

Changes in v3:
Changed compatible devicetree name to armada-370-spi. Split change to armada-370-xp.dtsi out into separate patch

 .../devicetree/bindings/spi/spi-orion.txt          |   2 +-
 drivers/spi/spi-orion.c                            | 116 +++++++++++++++++----
 2 files changed, 95 insertions(+), 23 deletions(-)
Documentation/devicetree/bindings/spi/spi-orion.txt +1 -1
index a3ff50f..50c3a3d 100644
@@ -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-370-spi".
 - reg : offset and length of the register set for the device
 - cell-index : Which of multiple SPI controllers is this.
 Optional properties:
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): 1411910644-7174-1-git-send-email-gerg-JBU5SbJe1FlAfugRpC6u6w@public.gmane.org

Applied
#2 lore raw
Quoted 6 lines · On Sun, Sep 28, 2014 at 11:24:04PM +1000…

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.

Applied, thanks.

#3 lore raw
In reply to a message not in the archive

drivers/spi/spi-orion.c static int orion_spi_probe(struct platform_device *pdev) · line 458

Quoted 8 lines · Greg Ungerer
drivers/spi/spi-orion.c +4 -0
@@ -378,6 +452,10 @@ static int orion_spi_probe(struct platform_device *pdev)
 	spi = spi_master_get_devdata(master);
 	spi->master = master;
 
+	of_id = of_match_device(orion_spi_of_match_table, &pdev->dev);
+	devdata = of_id->data;
+	spi->devdata = devdata;
+

Won't of_match_device return NULL on non-DT systems, and further references oops ?

Karl
--
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

#4 lore raw
Quoted 9 lines · Karl Beldan

drivers/spi/spi-orion.c static int orion_spi_probe(struct platform_device *pdev) · line 455

Quoted 5 lines · Greg Ungerer
drivers/spi/spi-orion.c +3 -0
@@ -378,6 +452,10 @@ static int orion_spi_probe(struct platform_device *pdev)
 
+	of_id = of_match_device(orion_spi_of_match_table, &pdev->dev);
+	devdata = of_id->data;
+	spi->devdata = devdata;

Won't of_match_device return NULL on non-DT systems, and further references oops ?

Yes.

#5 lore raw
In reply to Karl Beldan

Hi Karl,

Quoted 11 lines · Karl Beldan

Review static int orion_spi_probe(struct platform_device *pdev) · line 458

Quoted 8 lines · Greg Ungerer
(quoted diff) +4 -0
@@ -378,6 +452,10 @@ static int orion_spi_probe(struct platform_device *pdev)
 	spi = spi_master_get_devdata(master);
 	spi->master = master;
 
+	of_id = of_match_device(orion_spi_of_match_table, &pdev->dev);
+	devdata = of_id->data;
+	spi->devdata = devdata;
+

Won't of_match_device return NULL on non-DT systems, and further references oops ?

Yes, sure enough.

So I propose to fix with this change.

drivers/spi/spi-orion.c +1 -1
index acf8e48..c069ccd 100644
@@ -453,7 +453,7 @@ static int orion_spi_probe(struct platform_device *pdev)
        spi->master = master;
 
        of_id = of_match_device(orion_spi_of_match_table, &pdev->dev);
-       devdata = of_id->data;
+       devdata = (of_id) ? of_id->data : &orion_spi_dev_data;
        spi->devdata = devdata;
 
        spi->clk = devm_clk_get(&pdev->dev, NULL);

Mark: This was generated on linux-3.17-rc7 with the first spi-orion patch applied. What do you want it generated against?

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]

#7 lore raw
Quoted 24 lines · Greg Ungerer

Hi Karl,

Quoted 11 lines · Karl Beldan

Review static int orion_spi_probe(struct platform_device *pdev) · line 458

Quoted 8 lines · Greg Ungerer
(quoted diff) +4 -0
@@ -378,6 +452,10 @@ static int orion_spi_probe(struct platform_device *pdev)
 	spi = spi_master_get_devdata(master);
 	spi->master = master;
 
+	of_id = of_match_device(orion_spi_of_match_table, &pdev->dev);
+	devdata = of_id->data;
+	spi->devdata = devdata;
+

Won't of_match_device return NULL on non-DT systems, and further references oops ?

Yes, sure enough.

So I propose to fix with this change.

drivers/spi/spi-orion.c +0 -0
index acf8e48..c069ccd 100644

drivers/spi/spi-orion.c static int orion_spi_probe(struct platform_device *pdev) · line 458

Quoted 7 lines
drivers/spi/spi-orion.c +1 -1
@@ -453,7 +453,7 @@ static int orion_spi_probe(struct platform_device *pdev)
        spi->master = master;
 
        of_id = of_match_device(orion_spi_of_match_table, &pdev->dev);
-       devdata = of_id->data;
+       devdata = (of_id) ? of_id->data : &orion_spi_dev_data;
        spi->devdata = devdata;
 

I am not aware of the policy in the DT subsystem, I see some drivers bailing out when not getting any match, some remove non-DT support and add a dependency on OF, yet a message would feel appropriate. Other than that ok, it should fix df59fa7f4bca.

Karl
--
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

#8 lore raw

Hi Karl,

Quoted 27 lines · Karl Beldan
Quoted 26 lines · Greg Ungerer

Hi Karl,

Quoted 11 lines · Karl Beldan

Review static int orion_spi_probe(struct platform_device *pdev) · line 458

Quoted 8 lines · Greg Ungerer
(quoted diff) +4 -0
@@ -378,6 +452,10 @@ static int orion_spi_probe(struct platform_device *pdev)
 	spi = spi_master_get_devdata(master);
 	spi->master = master;
 
+	of_id = of_match_device(orion_spi_of_match_table, &pdev->dev);
+	devdata = of_id->data;
+	spi->devdata = devdata;
+

Won't of_match_device return NULL on non-DT systems, and further references oops ?

Yes, sure enough.

So I propose to fix with this change.

drivers/spi/spi-orion.c +0 -0
index acf8e48..c069ccd 100644
@@ -453,7 +453,7 @@ static int orion_spi_probe(struct platform_device *pdev)
        spi->master = master;
 
Quoted 9 lines

drivers/spi/spi-orion.c static int orion_spi_probe(struct platform_device *pdev) · line 458

Quoted 5 lines
drivers/spi/spi-orion.c +1 -1
        of_id = of_match_device(orion_spi_of_match_table, &pdev->dev);
-       devdata = of_id->data;
+       devdata = (of_id) ? of_id->data : &orion_spi_dev_data;
        spi->devdata = devdata;
 

I am not aware of the policy in the DT subsystem, I see some drivers bailing out when not getting any match, some remove non-DT support and add a dependency on OF, yet a message would feel appropriate. Other than that ok, it should fix df59fa7f4bca.

Before the recent changes this driver didn't call of_match_device(). With the above fix in place if it does return NULL then it will behave the same as it used to - using the default orion parameters. I think that is the ideal behavior.

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