stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] spi: orion: Fix maximum baud rates for Armada 370/XP
       [not found] <1430573152-26536-1-git-send-email-gregory.clement@free-electrons.com>
@ 2015-05-02 13:25 ` Gregory CLEMENT
  2015-05-03  8:06   ` Nadav Haklai
  0 siblings, 1 reply; 5+ messages in thread
From: Gregory CLEMENT @ 2015-05-02 13:25 UTC (permalink / raw)
  To: Nadav Haklai
  Cc: Lior Amsalem, Tawfik Bayouk, Thomas Petazzoni, Ezequiel Garcia,
	Maxime Ripard, Boris BREZILLON, Gregory CLEMENT, stable

The commit df59fa7f4bca "spi: orion: support armada extended baud
rates" was too optimistic for the maximum baud rate that the Armada
SoCs can support. According to the hardware datasheet the maximum
frequency supported by the Armada 370 SoC is tclk/4. But for the
Armada XP, Armada 38x and Armada 39x SoCs the limitation is 50MHz and
for the Armada 375 it is tclk/15.

Currently the armada-370-spi compatible is only used by the Armada 370
and the Armada XP device tree. On Armada 370, tclk cannot be higher
than 200MHz. In order to be able to handle both SoCs, we can take the
minimum of 50MHz and tclk/4.

A proper solution is adding a compatible string for each SoC, but it
can't be done as a fix for compatibility reason (we can't modify
device tree that have been already released) and it will be part of a
separate patch.

Signed-off-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
Cc: <stable@vger.kernel.org> #Fixes df59fa7f4bca
---
 drivers/spi/spi-orion.c | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi-orion.c b/drivers/spi/spi-orion.c
index 861664776672..ff97cabdaa81 100644
--- a/drivers/spi/spi-orion.c
+++ b/drivers/spi/spi-orion.c
@@ -61,6 +61,12 @@ enum orion_spi_type {
 
 struct orion_spi_dev {
 	enum orion_spi_type	typ;
+	/*
+	 * min_divisor and max_hz should be exclusive, the only we can
+	 * have both is for managing the armada-370-spi case with old
+	 * device tree
+	 */
+	unsigned long		max_hz;
 	unsigned int		min_divisor;
 	unsigned int		max_divisor;
 	u32			prescale_mask;
@@ -387,8 +393,9 @@ static const struct orion_spi_dev orion_spi_dev_data = {
 
 static const struct orion_spi_dev armada_spi_dev_data = {
 	.typ = ARMADA_SPI,
-	.min_divisor = 1,
+	.min_divisor = 4,
 	.max_divisor = 1920,
+	.max_hz = 50000000,
 	.prescale_mask = ARMADA_SPI_CLK_PRESCALE_MASK,
 };
 
@@ -454,7 +461,21 @@ static int orion_spi_probe(struct platform_device *pdev)
 		goto out;
 
 	tclk_hz = clk_get_rate(spi->clk);
-	master->max_speed_hz = DIV_ROUND_UP(tclk_hz, devdata->min_divisor);
+
+	/*
+	 * With old device tree, armada-370-spi could be used with
+	 * Armada XP, however for this SoC the maximum frequency is
+	 * 50MHz instead of tclk/4. On Armada 370, tclk cannot be
+	 * higher than 200MHz. So, in order to be able to handle both
+	 * SoCs, we can take the minimum of 50MHz and tclk/4.
+	 */
+	if (of_device_is_compatible(pdev->dev.of_node,
+					"marvell,armada-370-spi"))
+		master->max_speed_hz = min(devdata->max_hz,
+				DIV_ROUND_UP(tclk_hz, devdata->min_divisor));
+	else
+		master->max_speed_hz =
+			DIV_ROUND_UP(tclk_hz, devdata->min_divisor);
 	master->min_speed_hz = DIV_ROUND_UP(tclk_hz, devdata->max_divisor);
 
 	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* RE: [PATCH 1/3] spi: orion: Fix maximum baud rates for Armada 370/XP
  2015-05-02 13:25 ` Gregory CLEMENT
@ 2015-05-03  8:06   ` Nadav Haklai
  0 siblings, 0 replies; 5+ messages in thread
From: Nadav Haklai @ 2015-05-03  8:06 UTC (permalink / raw)
  To: Gregory CLEMENT, Kostya Porotchkin
  Cc: Lior Amsalem, Tawfik Bayouk, Thomas Petazzoni, Ezequiel Garcia,
	Maxime Ripard, Boris BREZILLON, stable@vger.kernel.org

+ Kostya

-----Original Message-----
From: Gregory CLEMENT [mailto:gregory.clement@free-electrons.com] 
Sent: Saturday, May 02, 2015 4:26 PM
To: Nadav Haklai
Cc: Lior Amsalem; Tawfik Bayouk; Thomas Petazzoni; Ezequiel Garcia; Maxime Ripard; Boris BREZILLON; Gregory CLEMENT; stable@vger.kernel.org
Subject: [PATCH 1/3] spi: orion: Fix maximum baud rates for Armada 370/XP

The commit df59fa7f4bca "spi: orion: support armada extended baud rates" was too optimistic for the maximum baud rate that the Armada SoCs can support. According to the hardware datasheet the maximum frequency supported by the Armada 370 SoC is tclk/4. But for the Armada XP, Armada 38x and Armada 39x SoCs the limitation is 50MHz and for the Armada 375 it is tclk/15.

Currently the armada-370-spi compatible is only used by the Armada 370 and the Armada XP device tree. On Armada 370, tclk cannot be higher than 200MHz. In order to be able to handle both SoCs, we can take the minimum of 50MHz and tclk/4.

A proper solution is adding a compatible string for each SoC, but it can't be done as a fix for compatibility reason (we can't modify device tree that have been already released) and it will be part of a separate patch.

Signed-off-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
Cc: <stable@vger.kernel.org> #Fixes df59fa7f4bca
---
 drivers/spi/spi-orion.c | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi-orion.c b/drivers/spi/spi-orion.c index 861664776672..ff97cabdaa81 100644
--- a/drivers/spi/spi-orion.c
+++ b/drivers/spi/spi-orion.c
@@ -61,6 +61,12 @@ enum orion_spi_type {
 
 struct orion_spi_dev {
 	enum orion_spi_type	typ;
+	/*
+	 * min_divisor and max_hz should be exclusive, the only we can
+	 * have both is for managing the armada-370-spi case with old
+	 * device tree
+	 */
+	unsigned long		max_hz;
 	unsigned int		min_divisor;
 	unsigned int		max_divisor;
 	u32			prescale_mask;
@@ -387,8 +393,9 @@ static const struct orion_spi_dev orion_spi_dev_data = {
 
 static const struct orion_spi_dev armada_spi_dev_data = {
 	.typ = ARMADA_SPI,
-	.min_divisor = 1,
+	.min_divisor = 4,
 	.max_divisor = 1920,
+	.max_hz = 50000000,
 	.prescale_mask = ARMADA_SPI_CLK_PRESCALE_MASK,  };
 
@@ -454,7 +461,21 @@ static int orion_spi_probe(struct platform_device *pdev)
 		goto out;
 
 	tclk_hz = clk_get_rate(spi->clk);
-	master->max_speed_hz = DIV_ROUND_UP(tclk_hz, devdata->min_divisor);
+
+	/*
+	 * With old device tree, armada-370-spi could be used with
+	 * Armada XP, however for this SoC the maximum frequency is
+	 * 50MHz instead of tclk/4. On Armada 370, tclk cannot be
+	 * higher than 200MHz. So, in order to be able to handle both
+	 * SoCs, we can take the minimum of 50MHz and tclk/4.
+	 */
+	if (of_device_is_compatible(pdev->dev.of_node,
+					"marvell,armada-370-spi"))
+		master->max_speed_hz = min(devdata->max_hz,
+				DIV_ROUND_UP(tclk_hz, devdata->min_divisor));
+	else
+		master->max_speed_hz =
+			DIV_ROUND_UP(tclk_hz, devdata->min_divisor);
 	master->min_speed_hz = DIV_ROUND_UP(tclk_hz, devdata->max_divisor);
 
 	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
--
2.1.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/3] spi: orion: Fix maximum baud rates for Armada 370/XP
       [not found] <1432633484-18758-1-git-send-email-gregory.clement@free-electrons.com>
@ 2015-05-26  9:44 ` Gregory CLEMENT
  2015-05-26 10:36   ` Mark Brown
  0 siblings, 1 reply; 5+ messages in thread
From: Gregory CLEMENT @ 2015-05-26  9:44 UTC (permalink / raw)
  To: Mark Brown, linux-spi, linux-kernel, Jason Cooper, Andrew Lunn,
	Sebastian Hesselbarth, Gregory CLEMENT
  Cc: Thomas Petazzoni, Ezequiel Garcia, linux-arm-kernel,
	Maxime Ripard, Boris BREZILLON, Lior Amsalem, Tawfik Bayouk,
	Nadav Haklai, devicetree, stable

The commit df59fa7f4bca "spi: orion: support armada extended baud
rates" was too optimistic for the maximum baud rate that the Armada
SoCs can support. According to the hardware datasheet the maximum
frequency supported by the Armada 370 SoC is tclk/4. But for the
Armada XP, Armada 38x and Armada 39x SoCs the limitation is 50MHz and
for the Armada 375 it is tclk/15.

Currently the armada-370-spi compatible is only used by the Armada 370
and the Armada XP device tree. On Armada 370, tclk cannot be higher
than 200MHz. In order to be able to handle both SoCs, we can take the
minimum of 50MHz and tclk/4.

A proper solution is adding a compatible string for each SoC, but it
can't be done as a fix for compatibility reason (we can't modify
device tree that have been already released) and it will be part of a
separate patch.

Signed-off-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
Reported-by: Kostya Porotchkin <kostap@marvell.com>
Cc: <stable@vger.kernel.org> #Fixes df59fa7f4bca
---
 drivers/spi/spi-orion.c | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi-orion.c b/drivers/spi/spi-orion.c
index 861664776672..ff97cabdaa81 100644
--- a/drivers/spi/spi-orion.c
+++ b/drivers/spi/spi-orion.c
@@ -61,6 +61,12 @@ enum orion_spi_type {
 
 struct orion_spi_dev {
 	enum orion_spi_type	typ;
+	/*
+	 * min_divisor and max_hz should be exclusive, the only we can
+	 * have both is for managing the armada-370-spi case with old
+	 * device tree
+	 */
+	unsigned long		max_hz;
 	unsigned int		min_divisor;
 	unsigned int		max_divisor;
 	u32			prescale_mask;
@@ -387,8 +393,9 @@ static const struct orion_spi_dev orion_spi_dev_data = {
 
 static const struct orion_spi_dev armada_spi_dev_data = {
 	.typ = ARMADA_SPI,
-	.min_divisor = 1,
+	.min_divisor = 4,
 	.max_divisor = 1920,
+	.max_hz = 50000000,
 	.prescale_mask = ARMADA_SPI_CLK_PRESCALE_MASK,
 };
 
@@ -454,7 +461,21 @@ static int orion_spi_probe(struct platform_device *pdev)
 		goto out;
 
 	tclk_hz = clk_get_rate(spi->clk);
-	master->max_speed_hz = DIV_ROUND_UP(tclk_hz, devdata->min_divisor);
+
+	/*
+	 * With old device tree, armada-370-spi could be used with
+	 * Armada XP, however for this SoC the maximum frequency is
+	 * 50MHz instead of tclk/4. On Armada 370, tclk cannot be
+	 * higher than 200MHz. So, in order to be able to handle both
+	 * SoCs, we can take the minimum of 50MHz and tclk/4.
+	 */
+	if (of_device_is_compatible(pdev->dev.of_node,
+					"marvell,armada-370-spi"))
+		master->max_speed_hz = min(devdata->max_hz,
+				DIV_ROUND_UP(tclk_hz, devdata->min_divisor));
+	else
+		master->max_speed_hz =
+			DIV_ROUND_UP(tclk_hz, devdata->min_divisor);
 	master->min_speed_hz = DIV_ROUND_UP(tclk_hz, devdata->max_divisor);
 
 	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/3] spi: orion: Fix maximum baud rates for Armada 370/XP
  2015-05-26  9:44 ` [PATCH 1/3] spi: orion: Fix maximum baud rates for Armada 370/XP Gregory CLEMENT
@ 2015-05-26 10:36   ` Mark Brown
  2015-05-26 12:08     ` Gregory CLEMENT
  0 siblings, 1 reply; 5+ messages in thread
From: Mark Brown @ 2015-05-26 10:36 UTC (permalink / raw)
  To: Gregory CLEMENT
  Cc: linux-spi, linux-kernel, Jason Cooper, Andrew Lunn,
	Sebastian Hesselbarth, Thomas Petazzoni, Ezequiel Garcia,
	linux-arm-kernel, Maxime Ripard, Boris BREZILLON, Lior Amsalem,
	Tawfik Bayouk, Nadav Haklai, devicetree, stable

[-- Attachment #1: Type: text/plain, Size: 438 bytes --]

On Tue, May 26, 2015 at 11:44:42AM +0200, Gregory CLEMENT wrote:

> Signed-off-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
> Reported-by: Kostya Porotchkin <kostap@marvell.com>
> Cc: <stable@vger.kernel.org> #Fixes df59fa7f4bca

Applied, but please format this stuff in a standard fashion - use a
Fixes: tag to reference commits you're fixing.  This makes it easier for
tooling to work with the information you're providing.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/3] spi: orion: Fix maximum baud rates for Armada 370/XP
  2015-05-26 10:36   ` Mark Brown
@ 2015-05-26 12:08     ` Gregory CLEMENT
  0 siblings, 0 replies; 5+ messages in thread
From: Gregory CLEMENT @ 2015-05-26 12:08 UTC (permalink / raw)
  To: Mark Brown
  Cc: linux-spi, linux-kernel, Jason Cooper, Andrew Lunn,
	Sebastian Hesselbarth, Thomas Petazzoni, Ezequiel Garcia,
	linux-arm-kernel, Maxime Ripard, Boris BREZILLON, Lior Amsalem,
	Tawfik Bayouk, Nadav Haklai, devicetree, stable

Hi Mark,

On 26/05/2015 12:36, Mark Brown wrote:
> On Tue, May 26, 2015 at 11:44:42AM +0200, Gregory CLEMENT wrote:
> 
>> Signed-off-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
>> Reported-by: Kostya Porotchkin <kostap@marvell.com>
>> Cc: <stable@vger.kernel.org> #Fixes df59fa7f4bca
> 
> Applied, but please format this stuff in a standard fashion - use a
> Fixes: tag to reference commits you're fixing.  This makes it easier for
> tooling to work with the information you're providing.

Yes, sure, I will do. I followed the Documentation/stable_kernel_rules.txt
file and I missed the new information in Documentation/SubmittingPatches
about this tag.

Thanks,

Gregory




-- 
Gregory Clement, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-05-26 12:08 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <1432633484-18758-1-git-send-email-gregory.clement@free-electrons.com>
2015-05-26  9:44 ` [PATCH 1/3] spi: orion: Fix maximum baud rates for Armada 370/XP Gregory CLEMENT
2015-05-26 10:36   ` Mark Brown
2015-05-26 12:08     ` Gregory CLEMENT
     [not found] <1430573152-26536-1-git-send-email-gregory.clement@free-electrons.com>
2015-05-02 13:25 ` Gregory CLEMENT
2015-05-03  8:06   ` Nadav Haklai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).