pci-host-generic.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  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. #include <linux/kernel.h>
  22. #include <linux/module.h>
  23. #include <linux/of_address.h>
  24. #include <linux/of_pci.h>
  25. #include <linux/platform_device.h>
  26. #include "../ecam.h"
  27. static struct pci_ecam_ops gen_pci_cfg_cam_bus_ops = {
  28. .bus_shift = 16,
  29. .pci_ops = {
  30. .map_bus = pci_ecam_map_bus,
  31. .read = pci_generic_config_read,
  32. .write = pci_generic_config_write,
  33. }
  34. };
  35. static const struct of_device_id gen_pci_of_match[] = {
  36. { .compatible = "pci-host-cam-generic",
  37. .data = &gen_pci_cfg_cam_bus_ops },
  38. { .compatible = "pci-host-ecam-generic",
  39. .data = &pci_generic_ecam_ops },
  40. { },
  41. };
  42. MODULE_DEVICE_TABLE(of, gen_pci_of_match);
  43. static int gen_pci_probe(struct platform_device *pdev)
  44. {
  45. const struct of_device_id *of_id;
  46. struct pci_ecam_ops *ops;
  47. of_id = of_match_node(gen_pci_of_match, pdev->dev.of_node);
  48. ops = (struct pci_ecam_ops *)of_id->data;
  49. return pci_host_common_probe(pdev, ops);
  50. }
  51. static struct platform_driver gen_pci_driver = {
  52. .driver = {
  53. .name = "pci-host-generic",
  54. .of_match_table = gen_pci_of_match,
  55. },
  56. .probe = gen_pci_probe,
  57. };
  58. module_platform_driver(gen_pci_driver);
  59. MODULE_DESCRIPTION("Generic PCI host driver");
  60. MODULE_AUTHOR("Will Deacon <will.deacon@arm.com>");
  61. MODULE_LICENSE("GPL v2");