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

spi: ingenic: Add support for new Ingenic SoCs.

1.Since it would be dangerous to specify a newer SoC's compatible
string as the fallback of an older SoC's compatible string, we
add support for the "ingenic,jz4775-spi" compatible string in
the driver.

This will permit to support the JZ4775 by having:
compatible = "ingenic,jz4775-spi";

Instead of doing:
compatible = "ingenic,jz4775-spi", "ingenic,jz4780-spi";

2.Add support for probing the spi-ingenic driver on the X1000 SoC
from Ingenic. From the X1000 SoC onwards, the maximum frequency
allowed by the SSI module of Ingenic SoCs has been changed from
54MHz to 50MHz. So "max_speed_hz" is introduced in "jz_soc_info"
to set different maximum frequency values.

3.Add support for probing the spi-ingenic driver on the X2000 SoC
from Ingenic. The X2000 SoC has only one native chip select line,
so "max_native_cs" is introduced in "jz_soc_info" to set different
maximum number of native chip select lines.

4.Because of the introduction of support for the X-series SoCs, the
current driver is not only applicable to the JZ-series SoCs, so
the description texts has been modified to avoid misunderstanding.

Signed-off-by: 周琰杰 (Zhou Yanjie) <zhouyanjie@wanyeetech.com>
Reviewed-by: Paul Cercueil <paul@crapouillou.net>
Link: https://lore.kernel.org/r/1650724725-93758-4-git-send-email-zhouyanjie@wanyeetech.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

周琰杰 (Zhou Yanjie) and committed by
Mark Brown
6d72b114 aecec8bb

+39 -7
+2 -2
drivers/spi/Kconfig
··· 419 419 This enables support for the Freescale i.MX SPI controllers. 420 420 421 421 config SPI_INGENIC 422 - tristate "Ingenic JZ47xx SoCs SPI controller" 422 + tristate "Ingenic SoCs SPI controller" 423 423 depends on MACH_INGENIC || COMPILE_TEST 424 424 help 425 - This enables support for the Ingenic JZ47xx SoCs SPI controller. 425 + This enables support for the Ingenic SoCs SPI controller. 426 426 427 427 To compile this driver as a module, choose M here: the module 428 428 will be called spi-ingenic.
+37 -5
drivers/spi/spi-ingenic.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 2 /* 3 - * SPI bus driver for the Ingenic JZ47xx SoCs 3 + * SPI bus driver for the Ingenic SoCs 4 4 * Copyright (c) 2017-2021 Artur Rojek <contact@artur-rojek.eu> 5 5 * Copyright (c) 2017-2021 Paul Cercueil <paul@crapouillou.net> 6 + * Copyright (c) 2022 周琰杰 (Zhou Yanjie) <zhouyanjie@wanyeetech.com> 6 7 */ 7 8 8 9 #include <linux/clk.h> ··· 53 52 u32 bits_per_word_mask; 54 53 struct reg_field flen_field; 55 54 bool has_trendian; 55 + 56 + unsigned int max_speed_hz; 57 + unsigned int max_native_cs; 56 58 }; 57 59 58 60 struct ingenic_spi { ··· 421 417 return PTR_ERR(priv->flen_field); 422 418 423 419 if (device_property_read_u32(dev, "num-cs", &num_cs)) 424 - num_cs = 2; 420 + num_cs = pdata->max_native_cs; 425 421 426 422 platform_set_drvdata(pdev, ctlr); 427 423 ··· 435 431 ctlr->max_dma_len = SPI_INGENIC_FIFO_SIZE; 436 432 ctlr->bits_per_word_mask = pdata->bits_per_word_mask; 437 433 ctlr->min_speed_hz = 7200; 438 - ctlr->max_speed_hz = 54000000; 434 + ctlr->max_speed_hz = pdata->max_speed_hz; 439 435 ctlr->use_gpio_descriptors = true; 440 - ctlr->max_native_cs = 2; 436 + ctlr->max_native_cs = pdata->max_native_cs; 441 437 ctlr->num_chipselect = num_cs; 442 438 ctlr->dev.of_node = pdev->dev.of_node; 443 439 ··· 461 457 .bits_per_word_mask = SPI_BPW_RANGE_MASK(2, 17), 462 458 .flen_field = REG_FIELD(REG_SSICR1, 4, 7), 463 459 .has_trendian = false, 460 + 461 + .max_speed_hz = 54000000, 462 + .max_native_cs = 2, 464 463 }; 465 464 466 465 static const struct jz_soc_info jz4780_soc_info = { 467 466 .bits_per_word_mask = SPI_BPW_RANGE_MASK(2, 32), 468 467 .flen_field = REG_FIELD(REG_SSICR1, 3, 7), 469 468 .has_trendian = true, 469 + 470 + .max_speed_hz = 54000000, 471 + .max_native_cs = 2, 472 + }; 473 + 474 + static const struct jz_soc_info x1000_soc_info = { 475 + .bits_per_word_mask = SPI_BPW_RANGE_MASK(2, 32), 476 + .flen_field = REG_FIELD(REG_SSICR1, 3, 7), 477 + .has_trendian = true, 478 + 479 + .max_speed_hz = 50000000, 480 + .max_native_cs = 2, 481 + }; 482 + 483 + static const struct jz_soc_info x2000_soc_info = { 484 + .bits_per_word_mask = SPI_BPW_RANGE_MASK(2, 32), 485 + .flen_field = REG_FIELD(REG_SSICR1, 3, 7), 486 + .has_trendian = true, 487 + 488 + .max_speed_hz = 50000000, 489 + .max_native_cs = 1, 470 490 }; 471 491 472 492 static const struct of_device_id spi_ingenic_of_match[] = { 473 493 { .compatible = "ingenic,jz4750-spi", .data = &jz4750_soc_info }, 494 + { .compatible = "ingenic,jz4775-spi", .data = &jz4780_soc_info }, 474 495 { .compatible = "ingenic,jz4780-spi", .data = &jz4780_soc_info }, 496 + { .compatible = "ingenic,x1000-spi", .data = &x1000_soc_info }, 497 + { .compatible = "ingenic,x2000-spi", .data = &x2000_soc_info }, 475 498 {} 476 499 }; 477 500 MODULE_DEVICE_TABLE(of, spi_ingenic_of_match); ··· 512 481 }; 513 482 514 483 module_platform_driver(spi_ingenic_driver); 515 - MODULE_DESCRIPTION("SPI bus driver for the Ingenic JZ47xx SoCs"); 484 + MODULE_DESCRIPTION("SPI bus driver for the Ingenic SoCs"); 516 485 MODULE_AUTHOR("Artur Rojek <contact@artur-rojek.eu>"); 517 486 MODULE_AUTHOR("Paul Cercueil <paul@crapouillou.net>"); 487 + MODULE_AUTHOR("周琰杰 (Zhou Yanjie) <zhouyanjie@wanyeetech.com>"); 518 488 MODULE_LICENSE("GPL");