1 // SPDX-License-Identifier: GPL-2.0+
2 // Platform driver for Loongson SPI Support
3 // Copyright (C) 2023 Loongson Technology Corporation Limited
6 #include <linux/mod_devicetable.h>
7 #include <linux/platform_device.h>
9 #include "spi-loongson.h"
11 static int loongson_spi_platform_probe(struct platform_device
*pdev
)
14 void __iomem
*reg_base
;
15 struct device
*dev
= &pdev
->dev
;
17 reg_base
= devm_platform_ioremap_resource(pdev
, 0);
19 return PTR_ERR(reg_base
);
21 ret
= loongson_spi_init_controller(dev
, reg_base
);
23 return dev_err_probe(dev
, ret
, "failed to initialize controller\n");
28 static const struct of_device_id loongson_spi_id_table
[] = {
29 { .compatible
= "loongson,ls2k1000-spi" },
32 MODULE_DEVICE_TABLE(of
, loongson_spi_id_table
);
34 static struct platform_driver loongson_spi_plat_driver
= {
35 .probe
= loongson_spi_platform_probe
,
37 .name
= "loongson-spi",
38 .bus
= &platform_bus_type
,
39 .pm
= &loongson_spi_dev_pm_ops
,
40 .of_match_table
= loongson_spi_id_table
,
43 module_platform_driver(loongson_spi_plat_driver
);
45 MODULE_DESCRIPTION("Loongson spi platform driver");
46 MODULE_LICENSE("GPL");
47 MODULE_IMPORT_NS(SPI_LOONGSON_CORE
);