2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2014-02-26 22:59:18 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2013 Google, Inc
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
2019-12-07 04:41:38 +00:00
|
|
|
#include <dm/device.h>
|
2018-10-11 05:06:57 +00:00
|
|
|
#include <dm/ofnode.h>
|
2019-12-07 04:41:38 +00:00
|
|
|
#include <dm/read.h>
|
2017-06-22 07:50:01 +00:00
|
|
|
#include <dm/util.h>
|
2018-03-04 16:20:11 +00:00
|
|
|
#include <linux/libfdt.h>
|
2014-02-26 22:59:18 +00:00
|
|
|
#include <vsprintf.h>
|
|
|
|
|
|
|
|
int list_count_items(struct list_head *head)
|
|
|
|
{
|
|
|
|
struct list_head *node;
|
|
|
|
int count = 0;
|
|
|
|
|
|
|
|
list_for_each(node, head)
|
|
|
|
count++;
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
2017-02-18 18:46:21 +00:00
|
|
|
|
2021-08-07 13:24:04 +00:00
|
|
|
#if CONFIG_IS_ENABLED(OF_REAL)
|
2019-12-07 04:41:38 +00:00
|
|
|
int pci_get_devfn(struct udevice *dev)
|
|
|
|
{
|
|
|
|
struct fdt_pci_addr addr;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
/* Extract the devfn from fdt_pci_addr */
|
|
|
|
ret = ofnode_read_pci_addr(dev_ofnode(dev), FDT_PCI_SPACE_CONFIG,
|
2023-09-26 14:14:58 +00:00
|
|
|
"reg", &addr, NULL);
|
2019-12-07 04:41:38 +00:00
|
|
|
if (ret) {
|
|
|
|
if (ret != -ENOENT)
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return addr.phys_hi & 0xff00;
|
|
|
|
}
|
|
|
|
#endif
|