dma-fence: Add some more fence-merge-unwrap tests
[drm/drm-misc.git] / drivers / spi / spi-loongson-pci.c
blobcbcde153260e778613f6ca57e9028dcfaf2c01ec
1 // SPDX-License-Identifier: GPL-2.0+
2 // PCI interface driver for Loongson SPI Support
3 // Copyright (C) 2023 Loongson Technology Corporation Limited
5 #include <linux/mod_devicetable.h>
6 #include <linux/pci.h>
8 #include "spi-loongson.h"
10 static int loongson_spi_pci_register(struct pci_dev *pdev,
11 const struct pci_device_id *ent)
13 int ret;
14 void __iomem *reg_base;
15 struct device *dev = &pdev->dev;
16 int pci_bar = 0;
18 ret = pcim_enable_device(pdev);
19 if (ret < 0)
20 return dev_err_probe(dev, ret, "cannot enable pci device\n");
22 reg_base = pcim_iomap_region(pdev, pci_bar, pci_name(pdev));
23 ret = PTR_ERR_OR_ZERO(reg_base);
24 if (ret)
25 return dev_err_probe(dev, ret, "failed to request and remap memory\n");
27 ret = loongson_spi_init_controller(dev, reg_base);
28 if (ret)
29 return dev_err_probe(dev, ret, "failed to initialize controller\n");
31 return 0;
34 static struct pci_device_id loongson_spi_devices[] = {
35 { PCI_DEVICE(PCI_VENDOR_ID_LOONGSON, 0x7a0b) },
36 { PCI_DEVICE(PCI_VENDOR_ID_LOONGSON, 0x7a1b) },
37 { }
39 MODULE_DEVICE_TABLE(pci, loongson_spi_devices);
41 static struct pci_driver loongson_spi_pci_driver = {
42 .name = "loongson-spi-pci",
43 .id_table = loongson_spi_devices,
44 .probe = loongson_spi_pci_register,
45 .driver = {
46 .bus = &pci_bus_type,
47 .pm = &loongson_spi_dev_pm_ops,
50 module_pci_driver(loongson_spi_pci_driver);
52 MODULE_DESCRIPTION("Loongson spi pci driver");
53 MODULE_LICENSE("GPL");
54 MODULE_IMPORT_NS("SPI_LOONGSON_CORE");