1/* SPDX-License-Identifier: GPL-2.0+ */
2/*
3 * Copyright (c) 2013 Google, Inc
4 */
5
6#ifndef __DM_UTIL_H
7#define __DM_UTIL_H
8
9struct dm_stats;
10
11#if CONFIG_IS_ENABLED(DM_WARN)
12#define dm_warn(fmt...) log(LOGC_DM, LOGL_WARNING, ##fmt)
13#else
14#define dm_warn(fmt...) log(LOGC_DM, LOGL_DEBUG, ##fmt)
15#endif
16
17struct list_head;
18
19/**
20 * list_count_items() - Count number of items in a list
21 *
22 * @param head:		Head of list
23 * Return: number of items, or 0 if empty
24 */
25int list_count_items(struct list_head *head);
26
27/**
28 * Dump out a tree of all devices starting @uclass
29 *
30 * @dev_name: udevice name
31 * @extended: true if forword-matching expected
32 * @sort: Sort by uclass name
33 */
34void dm_dump_tree(char *dev_name, bool extended, bool sort);
35
36/*
37 * Dump out a list of uclasses and their devices
38 *
39 * @uclass: uclass name
40 * @extended: true if forword-matching expected
41 */
42void dm_dump_uclass(char *uclass, bool extended);
43
44#ifdef CONFIG_DEBUG_DEVRES
45/* Dump out a list of device resources */
46void dm_dump_devres(void);
47#else
48static inline void dm_dump_devres(void)
49{
50}
51#endif
52
53/* Dump out a list of drivers */
54void dm_dump_drivers(void);
55
56/* Dump out a list with each driver's compatibility strings */
57void dm_dump_driver_compat(void);
58
59/* Dump out a list of drivers with static platform data */
60void dm_dump_static_driver_info(void);
61
62/**
63 * dm_dump_mem() - Dump stats on memory usage in driver model
64 *
65 * @mem: Stats to dump
66 */
67void dm_dump_mem(struct dm_stats *stats);
68
69#if CONFIG_IS_ENABLED(OF_PLATDATA_INST) && CONFIG_IS_ENABLED(READ_ONLY)
70void *dm_priv_to_rw(void *priv);
71#else
72static inline void *dm_priv_to_rw(void *priv)
73{
74	return priv;
75}
76#endif
77
78#endif
79