1 // SPDX-License-Identifier: GPL-2.0+ 2 // Platform driver for Loongson SPI Support 3 // Copyright (C) 2023 Loongson Technology Corporation Limited 4 5 #include <linux/err.h> 6 #include <linux/mod_devicetable.h> 7 #include <linux/platform_device.h> 8 9 #include "spi-loongson.h" 10 11 static int loongson_spi_platform_probe(struct platform_device *pdev) 12 { 13 int ret; 14 void __iomem *reg_base; 15 struct device *dev = &pdev->dev; 16 17 reg_base = devm_platform_ioremap_resource(pdev, 0); 18 if (IS_ERR(reg_base)) 19 return PTR_ERR(reg_base); 20 21 ret = loongson_spi_init_controller(dev, reg_base); 22 if (ret) 23 return dev_err_probe(dev, ret, "failed to initialize controller\n"); 24 25 return 0; 26 } 27 28 static const struct of_device_id loongson_spi_id_table[] = { 29 { .compatible = "loongson,ls2k1000-spi" }, 30 { } 31 }; 32 MODULE_DEVICE_TABLE(of, loongson_spi_id_table); 33 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, 41 }, 42 }; 43 module_platform_driver(loongson_spi_plat_driver); 44 45 MODULE_DESCRIPTION("Loongson spi platform driver"); 46 MODULE_LICENSE("GPL"); 47 MODULE_IMPORT_NS(SPI_LOONGSON_CORE); 48