blob: c5cbaf1e60e01e86e38a58d7e42de6fa2df15da8 [file] [log] [blame]
Will Deaconce292992013-11-22 16:14:41 +00001/*
2 * Simple, generic PCI host controller driver targetting firmware-initialised
3 * systems and virtual machines (e.g. the PCI emulation provided by kvmtool).
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * Copyright (C) 2014 ARM Limited
18 *
19 * Author: Will Deacon <will.deacon@arm.com>
20 */
21
22#include <linux/kernel.h>
Paul Gortmaker99849bf2016-07-22 16:21:38 -050023#include <linux/init.h>
Will Deaconce292992013-11-22 16:14:41 +000024#include <linux/of_address.h>
25#include <linux/of_pci.h>
26#include <linux/platform_device.h>
27
Jayachandran C1958e712016-05-11 17:34:46 -050028#include "../ecam.h"
Will Deaconce292992013-11-22 16:14:41 +000029
Jayachandran C1958e712016-05-11 17:34:46 -050030static struct pci_ecam_ops gen_pci_cfg_cam_bus_ops = {
Will Deaconce292992013-11-22 16:14:41 +000031 .bus_shift = 16,
Jayachandran C1958e712016-05-11 17:34:46 -050032 .pci_ops = {
33 .map_bus = pci_ecam_map_bus,
David Daney9a280332015-10-08 10:15:10 -050034 .read = pci_generic_config_read,
35 .write = pci_generic_config_write,
36 }
Will Deaconce292992013-11-22 16:14:41 +000037};
38
39static const struct of_device_id gen_pci_of_match[] = {
40 { .compatible = "pci-host-cam-generic",
41 .data = &gen_pci_cfg_cam_bus_ops },
42
43 { .compatible = "pci-host-ecam-generic",
Jayachandran C1958e712016-05-11 17:34:46 -050044 .data = &pci_generic_ecam_ops },
Will Deaconce292992013-11-22 16:14:41 +000045
46 { },
47};
Jayachandran C1958e712016-05-11 17:34:46 -050048
David Daneyd51b37102016-03-11 15:25:13 -060049static int gen_pci_probe(struct platform_device *pdev)
50{
David Daneyd51b37102016-03-11 15:25:13 -060051 const struct of_device_id *of_id;
Jayachandran C1958e712016-05-11 17:34:46 -050052 struct pci_ecam_ops *ops;
David Daneyd51b37102016-03-11 15:25:13 -060053
Jayachandran C1958e712016-05-11 17:34:46 -050054 of_id = of_match_node(gen_pci_of_match, pdev->dev.of_node);
55 ops = (struct pci_ecam_ops *)of_id->data;
David Daneyd51b37102016-03-11 15:25:13 -060056
Jayachandran C1958e712016-05-11 17:34:46 -050057 return pci_host_common_probe(pdev, ops);
David Daneyd51b37102016-03-11 15:25:13 -060058}
59
Will Deaconce292992013-11-22 16:14:41 +000060static struct platform_driver gen_pci_driver = {
61 .driver = {
62 .name = "pci-host-generic",
Will Deaconce292992013-11-22 16:14:41 +000063 .of_match_table = gen_pci_of_match,
64 },
65 .probe = gen_pci_probe,
66};
Paul Gortmaker99849bf2016-07-22 16:21:38 -050067builtin_platform_driver(gen_pci_driver);