spi: HiSilicon v3xx: Use DMI quirk to set controller buswidth override bits
authorJohn Garry <john.garry@huawei.com>
Fri, 28 Feb 2020 15:18:51 +0000 (23:18 +0800)
committerMark Brown <broonie@kernel.org>
Fri, 28 Feb 2020 18:01:44 +0000 (18:01 +0000)
The Huawei D06 board (and variants) can support Quad mode of operation.

Since we have no current method in ACPI SPI bus device resource description
to describe this information, use DMI to detect the board, and set the
controller buswidth override bits.

Signed-off-by: John Garry <john.garry@huawei.com>
Link: https://lore.kernel.org/r/1582903131-160033-4-git-send-email-john.garry@huawei.com
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-hisi-sfc-v3xx.c

index 45d906110ed15d9884e47133ae8f24f79d6a4400..e3b57252d075328600a2596468cef92a90e01630 100644 (file)
@@ -7,6 +7,7 @@
 
 #include <linux/acpi.h>
 #include <linux/bitops.h>
+#include <linux/dmi.h>
 #include <linux/iopoll.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
@@ -250,6 +251,44 @@ static const struct spi_controller_mem_ops hisi_sfc_v3xx_mem_ops = {
        .exec_op = hisi_sfc_v3xx_exec_op,
 };
 
+static int hisi_sfc_v3xx_buswidth_override_bits;
+
+/*
+ * ACPI FW does not allow us to currently set the device buswidth, so quirk it
+ * depending on the board.
+ */
+static int __init hisi_sfc_v3xx_dmi_quirk(const struct dmi_system_id *d)
+{
+       hisi_sfc_v3xx_buswidth_override_bits = SPI_RX_QUAD | SPI_TX_QUAD;
+
+       return 0;
+}
+
+static const struct dmi_system_id hisi_sfc_v3xx_dmi_quirk_table[]  = {
+       {
+       .callback = hisi_sfc_v3xx_dmi_quirk,
+       .matches = {
+               DMI_MATCH(DMI_SYS_VENDOR, "Huawei"),
+               DMI_MATCH(DMI_PRODUCT_NAME, "D06"),
+       },
+       },
+       {
+       .callback = hisi_sfc_v3xx_dmi_quirk,
+       .matches = {
+               DMI_MATCH(DMI_SYS_VENDOR, "Huawei"),
+               DMI_MATCH(DMI_PRODUCT_NAME, "TaiShan 2280 V2"),
+       },
+       },
+       {
+       .callback = hisi_sfc_v3xx_dmi_quirk,
+       .matches = {
+               DMI_MATCH(DMI_SYS_VENDOR, "Huawei"),
+               DMI_MATCH(DMI_PRODUCT_NAME, "TaiShan 200 (Model 2280)"),
+       },
+       },
+       {}
+};
+
 static int hisi_sfc_v3xx_probe(struct platform_device *pdev)
 {
        struct device *dev = &pdev->dev;
@@ -265,6 +304,8 @@ static int hisi_sfc_v3xx_probe(struct platform_device *pdev)
        ctlr->mode_bits = SPI_RX_DUAL | SPI_RX_QUAD |
                          SPI_TX_DUAL | SPI_TX_QUAD;
 
+       ctlr->buswidth_override_bits = hisi_sfc_v3xx_buswidth_override_bits;
+
        host = spi_controller_get_devdata(ctlr);
        host->dev = dev;
 
@@ -320,7 +361,20 @@ static struct platform_driver hisi_sfc_v3xx_spi_driver = {
        .probe  = hisi_sfc_v3xx_probe,
 };
 
-module_platform_driver(hisi_sfc_v3xx_spi_driver);
+static int __init hisi_sfc_v3xx_spi_init(void)
+{
+       dmi_check_system(hisi_sfc_v3xx_dmi_quirk_table);
+
+       return platform_driver_register(&hisi_sfc_v3xx_spi_driver);
+}
+
+static void __exit hisi_sfc_v3xx_spi_exit(void)
+{
+       platform_driver_unregister(&hisi_sfc_v3xx_spi_driver);
+}
+
+module_init(hisi_sfc_v3xx_spi_init);
+module_exit(hisi_sfc_v3xx_spi_exit);
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("John Garry <john.garry@huawei.com>");