Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / drivers / spi / spi-loongson-plat.c
blobc066e5f5891e9a424e525559b8e765aee867f172
1 // SPDX-License-Identifier: GPL-2.0+
2 // Platform driver for Loongson SPI Support
3 // Copyright (C) 2023 Loongson Technology Corporation Limited
5 #include <linux/err.h>
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)
13 int ret;
14 void __iomem *reg_base;
15 struct device *dev = &pdev->dev;
17 reg_base = devm_platform_ioremap_resource(pdev, 0);
18 if (IS_ERR(reg_base))
19 return PTR_ERR(reg_base);
21 ret = loongson_spi_init_controller(dev, reg_base);
22 if (ret)
23 return dev_err_probe(dev, ret, "failed to initialize controller\n");
25 return 0;
28 static const struct of_device_id loongson_spi_id_table[] = {
29 { .compatible = "loongson,ls2k1000-spi" },
30 { }
32 MODULE_DEVICE_TABLE(of, loongson_spi_id_table);
34 static struct platform_driver loongson_spi_plat_driver = {
35 .probe = loongson_spi_platform_probe,
36 .driver = {
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);