2013-11-23 00:14:41 +08:00
|
|
|
/*
|
|
|
|
* Simple, generic PCI host controller driver targetting firmware-initialised
|
|
|
|
* systems and virtual machines (e.g. the PCI emulation provided by kvmtool).
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2014 ARM Limited
|
|
|
|
*
|
|
|
|
* Author: Will Deacon <will.deacon@arm.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
2016-07-23 05:21:38 +08:00
|
|
|
#include <linux/init.h>
|
2013-11-23 00:14:41 +08:00
|
|
|
#include <linux/of_address.h>
|
|
|
|
#include <linux/of_pci.h>
|
2016-06-11 03:55:09 +08:00
|
|
|
#include <linux/pci-ecam.h>
|
2013-11-23 00:14:41 +08:00
|
|
|
#include <linux/platform_device.h>
|
|
|
|
|
2016-05-12 06:34:46 +08:00
|
|
|
static struct pci_ecam_ops gen_pci_cfg_cam_bus_ops = {
|
2013-11-23 00:14:41 +08:00
|
|
|
.bus_shift = 16,
|
2016-05-12 06:34:46 +08:00
|
|
|
.pci_ops = {
|
|
|
|
.map_bus = pci_ecam_map_bus,
|
2015-10-08 23:15:10 +08:00
|
|
|
.read = pci_generic_config_read,
|
|
|
|
.write = pci_generic_config_write,
|
|
|
|
}
|
2013-11-23 00:14:41 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static const struct of_device_id gen_pci_of_match[] = {
|
|
|
|
{ .compatible = "pci-host-cam-generic",
|
|
|
|
.data = &gen_pci_cfg_cam_bus_ops },
|
|
|
|
|
|
|
|
{ .compatible = "pci-host-ecam-generic",
|
2016-05-12 06:34:46 +08:00
|
|
|
.data = &pci_generic_ecam_ops },
|
2013-11-23 00:14:41 +08:00
|
|
|
|
|
|
|
{ },
|
|
|
|
};
|
2016-05-12 06:34:46 +08:00
|
|
|
|
2016-03-12 05:25:13 +08:00
|
|
|
static int gen_pci_probe(struct platform_device *pdev)
|
|
|
|
{
|
|
|
|
const struct of_device_id *of_id;
|
2016-05-12 06:34:46 +08:00
|
|
|
struct pci_ecam_ops *ops;
|
2016-03-12 05:25:13 +08:00
|
|
|
|
2016-05-12 06:34:46 +08:00
|
|
|
of_id = of_match_node(gen_pci_of_match, pdev->dev.of_node);
|
|
|
|
ops = (struct pci_ecam_ops *)of_id->data;
|
2016-03-12 05:25:13 +08:00
|
|
|
|
2016-05-12 06:34:46 +08:00
|
|
|
return pci_host_common_probe(pdev, ops);
|
2016-03-12 05:25:13 +08:00
|
|
|
}
|
|
|
|
|
2013-11-23 00:14:41 +08:00
|
|
|
static struct platform_driver gen_pci_driver = {
|
|
|
|
.driver = {
|
|
|
|
.name = "pci-host-generic",
|
|
|
|
.of_match_table = gen_pci_of_match,
|
|
|
|
},
|
|
|
|
.probe = gen_pci_probe,
|
|
|
|
};
|
2016-07-23 05:21:38 +08:00
|
|
|
builtin_platform_driver(gen_pci_driver);
|