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>
8 #include "spi-loongson.h"
10 static int loongson_spi_pci_register(struct pci_dev
*pdev
,
11 const struct pci_device_id
*ent
)
14 void __iomem
*reg_base
;
15 struct device
*dev
= &pdev
->dev
;
18 ret
= pcim_enable_device(pdev
);
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
);
25 return dev_err_probe(dev
, ret
, "failed to request and remap memory\n");
27 ret
= loongson_spi_init_controller(dev
, reg_base
);
29 return dev_err_probe(dev
, ret
, "failed to initialize controller\n");
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) },
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
,
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");