pci.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * Code borrowed from powerpc/kernel/pci-common.c
  3. *
  4. * Copyright (C) 2003 Anton Blanchard <anton@au.ibm.com>, IBM
  5. * Copyright (C) 2014 ARM Ltd.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * version 2 as published by the Free Software Foundation.
  10. *
  11. */
  12. #include <linux/init.h>
  13. #include <linux/io.h>
  14. #include <linux/kernel.h>
  15. #include <linux/mm.h>
  16. #include <linux/of_pci.h>
  17. #include <linux/of_platform.h>
  18. #include <linux/slab.h>
  19. #include <asm/pci-bridge.h>
  20. /*
  21. * Called after each bus is probed, but before its children are examined
  22. */
  23. void pcibios_fixup_bus(struct pci_bus *bus)
  24. {
  25. /* nothing to do, expected to be removed in the future */
  26. }
  27. /*
  28. * We don't have to worry about legacy ISA devices, so nothing to do here
  29. */
  30. resource_size_t pcibios_align_resource(void *data, const struct resource *res,
  31. resource_size_t size, resource_size_t align)
  32. {
  33. return res->start;
  34. }
  35. /*
  36. * Try to assign the IRQ number from DT when adding a new device
  37. */
  38. int pcibios_add_device(struct pci_dev *dev)
  39. {
  40. dev->irq = of_irq_parse_and_map_pci(dev, 0, 0);
  41. return 0;
  42. }
  43. #ifdef CONFIG_PCI_DOMAINS_GENERIC
  44. static bool dt_domain_found = false;
  45. void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent)
  46. {
  47. int domain = of_get_pci_domain_nr(parent->of_node);
  48. if (domain >= 0) {
  49. dt_domain_found = true;
  50. } else if (dt_domain_found == true) {
  51. dev_err(parent, "Node %s is missing \"linux,pci-domain\" property in DT\n",
  52. parent->of_node->full_name);
  53. return;
  54. } else {
  55. domain = pci_get_new_domain_nr();
  56. }
  57. bus->domain_nr = domain;
  58. }
  59. #endif