]>
Commit | Line | Data |
---|---|---|
83d290c5 | 1 | // SPDX-License-Identifier: GPL-2.0+ |
6494d708 SG |
2 | /* |
3 | * Copyright (c) 2013 Google, Inc | |
6494d708 SG |
4 | */ |
5 | ||
939afc80 | 6 | #include <vsprintf.h> |
6dd4b014 | 7 | #include <dm/device.h> |
e601ab1b | 8 | #include <dm/ofnode.h> |
6dd4b014 | 9 | #include <dm/read.h> |
766c28a5 | 10 | #include <dm/util.h> |
b08c8c48 | 11 | #include <linux/libfdt.h> |
939afc80 | 12 | #include <linux/list.h> |
27326c7e | 13 | |
95397385 | 14 | #if CONFIG_IS_ENABLED(OF_REAL) |
6dd4b014 SG |
15 | int pci_get_devfn(struct udevice *dev) |
16 | { | |
17 | struct fdt_pci_addr addr; | |
18 | int ret; | |
19 | ||
20 | /* Extract the devfn from fdt_pci_addr */ | |
21 | ret = ofnode_read_pci_addr(dev_ofnode(dev), FDT_PCI_SPACE_CONFIG, | |
f69d3d6d | 22 | "reg", &addr, NULL); |
6dd4b014 SG |
23 | if (ret) { |
24 | if (ret != -ENOENT) | |
25 | return -EINVAL; | |
26 | } | |
27 | ||
28 | return addr.phys_hi & 0xff00; | |
29 | } | |
30 | #endif |