0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #include <linux/kernel.h>
0012 #include <linux/init.h>
0013 #include <linux/module.h>
0014 #include <linux/pci-ecam.h>
0015 #include <linux/platform_device.h>
0016
0017 static const struct pci_ecam_ops gen_pci_cfg_cam_bus_ops = {
0018 .bus_shift = 16,
0019 .pci_ops = {
0020 .map_bus = pci_ecam_map_bus,
0021 .read = pci_generic_config_read,
0022 .write = pci_generic_config_write,
0023 }
0024 };
0025
0026 static bool pci_dw_valid_device(struct pci_bus *bus, unsigned int devfn)
0027 {
0028 struct pci_config_window *cfg = bus->sysdata;
0029
0030
0031
0032
0033
0034
0035
0036 if (bus->number == cfg->busr.start && PCI_SLOT(devfn) > 0)
0037 return false;
0038
0039 return true;
0040 }
0041
0042 static void __iomem *pci_dw_ecam_map_bus(struct pci_bus *bus,
0043 unsigned int devfn, int where)
0044 {
0045 if (!pci_dw_valid_device(bus, devfn))
0046 return NULL;
0047
0048 return pci_ecam_map_bus(bus, devfn, where);
0049 }
0050
0051 static const struct pci_ecam_ops pci_dw_ecam_bus_ops = {
0052 .pci_ops = {
0053 .map_bus = pci_dw_ecam_map_bus,
0054 .read = pci_generic_config_read,
0055 .write = pci_generic_config_write,
0056 }
0057 };
0058
0059 static const struct of_device_id gen_pci_of_match[] = {
0060 { .compatible = "pci-host-cam-generic",
0061 .data = &gen_pci_cfg_cam_bus_ops },
0062
0063 { .compatible = "pci-host-ecam-generic",
0064 .data = &pci_generic_ecam_ops },
0065
0066 { .compatible = "marvell,armada8k-pcie-ecam",
0067 .data = &pci_dw_ecam_bus_ops },
0068
0069 { .compatible = "socionext,synquacer-pcie-ecam",
0070 .data = &pci_dw_ecam_bus_ops },
0071
0072 { .compatible = "snps,dw-pcie-ecam",
0073 .data = &pci_dw_ecam_bus_ops },
0074
0075 { },
0076 };
0077 MODULE_DEVICE_TABLE(of, gen_pci_of_match);
0078
0079 static struct platform_driver gen_pci_driver = {
0080 .driver = {
0081 .name = "pci-host-generic",
0082 .of_match_table = gen_pci_of_match,
0083 },
0084 .probe = pci_host_common_probe,
0085 .remove = pci_host_common_remove,
0086 };
0087 module_platform_driver(gen_pci_driver);
0088
0089 MODULE_LICENSE("GPL v2");