aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGregory CLEMENT <gregory.clement@free-electrons.com>2015-05-26 05:44:43 -0400
committerMark Brown <broonie@kernel.org>2015-05-27 13:44:57 -0400
commit4dacccfac69494ba70248b134352f299171c41b7 (patch)
tree945e09c4d5b66d515a2c1af274a14602bceb469f
parentce2f6ea1cbd41d78224f703af980a6ceeb0eb56a (diff)
spi: orion: Fix extended baud rates for each Armada SoCs
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> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--Documentation/devicetree/bindings/spi/spi-orion.txt8
-rw-r--r--drivers/spi/spi-orion.c47
2 files changed, 50 insertions, 5 deletions
diff --git a/Documentation/devicetree/bindings/spi/spi-orion.txt b/Documentation/devicetree/bindings/spi/spi-orion.txt
index 50c3a3de61c1..98bc69815eb3 100644
--- a/Documentation/devicetree/bindings/spi/spi-orion.txt
+++ b/Documentation/devicetree/bindings/spi/spi-orion.txt
@@ -1,7 +1,13 @@
1Marvell Orion SPI device 1Marvell Orion SPI device
2 2
3Required properties: 3Required properties:
4- compatible : should be "marvell,orion-spi" or "marvell,armada-370-spi". 4- compatible : should be on of the following:
5 - "marvell,orion-spi" for the Orion, mv78x00, Kirkwood and Dove SoCs
6 - "marvell,armada-370-spi", for the Armada 370 SoCs
7 - "marvell,armada-375-spi", for the Armada 375 SoCs
8 - "marvell,armada-380-spi", for the Armada 38x SoCs
9 - "marvell,armada-390-spi", for the Armada 39x SoCs
10 - "marvell,armada-xp-spi", for the Armada XP SoCs
5- reg : offset and length of the register set for the device 11- reg : offset and length of the register set for the device
6- cell-index : Which of multiple SPI controllers is this. 12- cell-index : Which of multiple SPI controllers is this.
7Optional properties: 13Optional 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 = {
391 .prescale_mask = ORION_SPI_CLK_PRESCALE_MASK, 391 .prescale_mask = ORION_SPI_CLK_PRESCALE_MASK,
392}; 392};
393 393
394static const struct orion_spi_dev armada_spi_dev_data = { 394static const struct orion_spi_dev armada_370_spi_dev_data = {
395 .typ = ARMADA_SPI, 395 .typ = ARMADA_SPI,
396 .min_divisor = 4, 396 .min_divisor = 4,
397 .max_divisor = 1920, 397 .max_divisor = 1920,
@@ -399,9 +399,46 @@ static const struct orion_spi_dev armada_spi_dev_data = {
399 .prescale_mask = ARMADA_SPI_CLK_PRESCALE_MASK, 399 .prescale_mask = ARMADA_SPI_CLK_PRESCALE_MASK,
400}; 400};
401 401
402static const struct orion_spi_dev armada_xp_spi_dev_data = {
403 .typ = ARMADA_SPI,
404 .max_hz = 50000000,
405 .max_divisor = 1920,
406 .prescale_mask = ARMADA_SPI_CLK_PRESCALE_MASK,
407};
408
409static const struct orion_spi_dev armada_375_spi_dev_data = {
410 .typ = ARMADA_SPI,
411 .min_divisor = 15,
412 .max_divisor = 1920,
413 .prescale_mask = ARMADA_SPI_CLK_PRESCALE_MASK,
414};
415
402static const struct of_device_id orion_spi_of_match_table[] = { 416static const struct of_device_id orion_spi_of_match_table[] = {
403 { .compatible = "marvell,orion-spi", .data = &orion_spi_dev_data, }, 417 {
404 { .compatible = "marvell,armada-370-spi", .data = &armada_spi_dev_data, }, 418 .compatible = "marvell,orion-spi",
419 .data = &orion_spi_dev_data,
420 },
421 {
422 .compatible = "marvell,armada-370-spi",
423 .data = &armada_370_spi_dev_data,
424 },
425 {
426 .compatible = "marvell,armada-375-spi",
427 .data = &armada_375_spi_dev_data,
428 },
429 {
430 .compatible = "marvell,armada-380-spi",
431 .data = &armada_xp_spi_dev_data,
432 },
433 {
434 .compatible = "marvell,armada-390-spi",
435 .data = &armada_xp_spi_dev_data,
436 },
437 {
438 .compatible = "marvell,armada-xp-spi",
439 .data = &armada_xp_spi_dev_data,
440 },
441
405 {} 442 {}
406}; 443};
407MODULE_DEVICE_TABLE(of, orion_spi_of_match_table); 444MODULE_DEVICE_TABLE(of, orion_spi_of_match_table);
@@ -473,9 +510,11 @@ static int orion_spi_probe(struct platform_device *pdev)
473 "marvell,armada-370-spi")) 510 "marvell,armada-370-spi"))
474 master->max_speed_hz = min(devdata->max_hz, 511 master->max_speed_hz = min(devdata->max_hz,
475 DIV_ROUND_UP(tclk_hz, devdata->min_divisor)); 512 DIV_ROUND_UP(tclk_hz, devdata->min_divisor));
476 else 513 else if (devdata->min_divisor)
477 master->max_speed_hz = 514 master->max_speed_hz =
478 DIV_ROUND_UP(tclk_hz, devdata->min_divisor); 515 DIV_ROUND_UP(tclk_hz, devdata->min_divisor);
516 else
517 master->max_speed_hz = devdata->max_hz;
479 master->min_speed_hz = DIV_ROUND_UP(tclk_hz, devdata->max_divisor); 518 master->min_speed_hz = DIV_ROUND_UP(tclk_hz, devdata->max_divisor);
480 519
481 r = platform_get_resource(pdev, IORESOURCE_MEM, 0); 520 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);