blob: 89206cc49669c073194341467f76b975fe595ce8 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Simon Glass6494d702014-02-26 15:59:18 -07002/*
3 * Copyright (c) 2013 Google, Inc
Simon Glass6494d702014-02-26 15:59:18 -07004 */
5
6#ifndef __DM_UTIL_H
Masahiro Yamadab1799fc2014-10-07 14:49:38 +09007#define __DM_UTIL_H
Simon Glass6494d702014-02-26 15:59:18 -07008
Simon Glass2cb4ddb2022-05-08 04:39:26 -06009struct dm_stats;
10
Simon Glassabb9cd32020-10-03 11:31:26 -060011#if CONFIG_IS_ENABLED(DM_WARN)
Patrick Delaunayb18b38f2021-07-30 12:13:11 +020012#define dm_warn(fmt...) log(LOGC_DM, LOGL_WARNING, ##fmt)
Simon Glassa94f4682014-11-10 17:16:49 -070013#else
14static inline void dm_warn(const char *fmt, ...)
15{
16}
17#endif
Simon Glass6494d702014-02-26 15:59:18 -070018
Simon Glass6494d702014-02-26 15:59:18 -070019struct list_head;
20
21/**
22 * list_count_items() - Count number of items in a list
23 *
24 * @param head: Head of list
Heinrich Schuchardt185f8122022-01-19 18:05:50 +010025 * Return: number of items, or 0 if empty
Simon Glass6494d702014-02-26 15:59:18 -070026 */
27int list_count_items(struct list_head *head);
28
Simon Glass3d012542023-01-17 10:47:12 -070029/**
AKASHI Takahiro36e45f62023-08-23 10:49:47 +090030 * Dump out a tree of all devices starting @uclass
Simon Glass3d012542023-01-17 10:47:12 -070031 *
AKASHI Takahiro36e45f62023-08-23 10:49:47 +090032 * @dev_name: udevice name
33 * @extended: true if forword-matching expected
Simon Glass3d012542023-01-17 10:47:12 -070034 * @sort: Sort by uclass name
35 */
AKASHI Takahiro36e45f62023-08-23 10:49:47 +090036void dm_dump_tree(char *dev_name, bool extended, bool sort);
Simon Glass304fbef2015-06-23 15:38:35 -060037
AKASHI Takahiro36e45f62023-08-23 10:49:47 +090038/*
39 * Dump out a list of uclasses and their devices
40 *
41 * @uclass: uclass name
42 * @extended: true if forword-matching expected
43 */
44void dm_dump_uclass(char *uclass, bool extended);
Simon Glass304fbef2015-06-23 15:38:35 -060045
Masahiro Yamada40b6f2d2015-07-25 21:52:38 +090046#ifdef CONFIG_DEBUG_DEVRES
47/* Dump out a list of device resources */
48void dm_dump_devres(void);
49#else
50static inline void dm_dump_devres(void)
51{
52}
53#endif
54
Sean Anderson7b9d60f2020-01-17 14:48:09 -050055/* Dump out a list of drivers */
56void dm_dump_drivers(void);
57
Niel Fourie2e488362020-03-24 16:17:05 +010058/* Dump out a list with each driver's compatibility strings */
59void dm_dump_driver_compat(void);
60
61/* Dump out a list of drivers with static platform data */
62void dm_dump_static_driver_info(void);
63
Simon Glass2cb4ddb2022-05-08 04:39:26 -060064/**
65 * dm_dump_mem() - Dump stats on memory usage in driver model
66 *
67 * @mem: Stats to dump
68 */
69void dm_dump_mem(struct dm_stats *stats);
70
Simon Glasscfb9c9b2021-03-15 17:25:40 +130071#if CONFIG_IS_ENABLED(OF_PLATDATA_INST) && CONFIG_IS_ENABLED(READ_ONLY)
72void *dm_priv_to_rw(void *priv);
73#else
74static inline void *dm_priv_to_rw(void *priv)
75{
76 return priv;
77}
78#endif
Pierre-Clément Tosi36109702021-09-30 17:52:45 +020079
80#endif