Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Gregory CLEMENT and committed by
Mark Brown
4dacccfa ce2f6ea1

+50 -5
+7 -1
Documentation/devicetree/bindings/spi/spi-orion.txt
··· 1 1 Marvell Orion SPI device 2 2 3 3 Required 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 11 - reg : offset and length of the register set for the device 6 12 - cell-index : Which of multiple SPI controllers is this. 7 13 Optional properties:
+43 -4
drivers/spi/spi-orion.c
··· 391 391 .prescale_mask = ORION_SPI_CLK_PRESCALE_MASK, 392 392 }; 393 393 394 - static const struct orion_spi_dev armada_spi_dev_data = { 394 + static const struct orion_spi_dev armada_370_spi_dev_data = { 395 395 .typ = ARMADA_SPI, 396 396 .min_divisor = 4, 397 397 .max_divisor = 1920, ··· 399 399 .prescale_mask = ARMADA_SPI_CLK_PRESCALE_MASK, 400 400 }; 401 401 402 + static 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 + 409 + static 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 + 402 416 static const struct of_device_id orion_spi_of_match_table[] = { 403 - { .compatible = "marvell,orion-spi", .data = &orion_spi_dev_data, }, 404 - { .compatible = "marvell,armada-370-spi", .data = &armada_spi_dev_data, }, 417 + { 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 }; 407 444 MODULE_DEVICE_TABLE(of, orion_spi_of_match_table); ··· 510 473 "marvell,armada-370-spi")) 511 474 master->max_speed_hz = min(devdata->max_hz, 512 475 DIV_ROUND_UP(tclk_hz, devdata->min_divisor)); 513 - else 476 + else if (devdata->min_divisor) 514 477 master->max_speed_hz = 515 478 DIV_ROUND_UP(tclk_hz, devdata->min_divisor); 479 + else 480 + master->max_speed_hz = devdata->max_hz; 516 481 master->min_speed_hz = DIV_ROUND_UP(tclk_hz, devdata->max_divisor); 517 482 518 483 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);