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>
|
|
|
|
|
2020-10-03 17:31:26 +00:00
|
|
|
#if CONFIG_IS_ENABLED(DM_WARN)
|
2014-02-26 22:59:18 +00:00
|
|
|
void dm_warn(const char *fmt, ...)
|
|
|
|
{
|
|
|
|
va_list args;
|
|
|
|
|
|
|
|
va_start(args, fmt);
|
|
|
|
vprintf(fmt, args);
|
|
|
|
va_end(args);
|
|
|
|
}
|
2017-06-22 07:50:01 +00:00
|
|
|
#endif
|
2014-02-26 22:59:18 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
2019-12-07 04:41:38 +00:00
|
|
|
#if !CONFIG_IS_ENABLED(OF_PLATDATA)
|
|
|
|
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,
|
|
|
|
"reg", &addr);
|
|
|
|
if (ret) {
|
|
|
|
if (ret != -ENOENT)
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return addr.phys_hi & 0xff00;
|
|
|
|
}
|
|
|
|
#endif
|