"Das U-Boot" Source Tree
at master 30 lines 585 B view raw
1// SPDX-License-Identifier: GPL-2.0+ 2/* 3 * Copyright (c) 2013 Google, Inc 4 */ 5 6#include <vsprintf.h> 7#include <dm/device.h> 8#include <dm/ofnode.h> 9#include <dm/read.h> 10#include <dm/util.h> 11#include <linux/libfdt.h> 12#include <linux/list.h> 13 14#if CONFIG_IS_ENABLED(OF_REAL) 15int 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, 22 "reg", &addr, NULL); 23 if (ret) { 24 if (ret != -ENOENT) 25 return -EINVAL; 26 } 27 28 return addr.phys_hi & 0xff00; 29} 30#endif