]> Git Repo - u-boot.git/blame - include/dm/root.h
Merge branch 'master' of https://source.denx.de/u-boot/custodians/u-boot-sh
[u-boot.git] / include / dm / root.h
CommitLineData
83d290c5 1/* SPDX-License-Identifier: GPL-2.0+ */
6494d708
SG
2/*
3 * Copyright (c) 2013 Google, Inc
4 *
5 * (C) Copyright 2012
6 * Pavel Herrmann <[email protected]>
6494d708
SG
7 */
8
9#ifndef _DM_ROOT_H_
10#define _DM_ROOT_H_
11
0dfda34c
SG
12#include <dm/tag.h>
13
54c5d08a 14struct udevice;
6494d708 15
3fa9f553
SG
16/* Head of the uclass list if CONFIG_OF_PLATDATA_INST is enabled */
17extern struct list_head uclass_head;
18
0dfda34c
SG
19/**
20 * struct dm_stats - Information about driver model memory usage
21 *
22 * @total_size: All data
23 * @dev_count: Number of devices
24 * @dev_size: Size of all devices (just the struct udevice)
25 * @dev_name_size: Bytes used by device names
26 * @uc_count: Number of uclasses
27 * @uc_size: Size of all uclasses (just the struct uclass)
28 * @tag_count: Number of tags
29 * @tag_size: Bytes used by all tags
30 * @uc_attach_count: Number of uclasses with attached data (priv)
31 * @uc_attach_size: Total size of that attached data
32 * @attach_count_total: Total number of attached data items for all udevices and
33 * uclasses
34 * @attach_size_total: Total number of bytes of attached data
35 * @attach_count: Number of devices with attached, for each type
36 * @attach_size: Total number of bytes of attached data, for each type
37 */
38struct dm_stats {
39 int total_size;
40 int dev_count;
41 int dev_size;
42 int dev_name_size;
43 int uc_count;
44 int uc_size;
45 int tag_count;
46 int tag_size;
47 int uc_attach_count;
48 int uc_attach_size;
49 int attach_count_total;
50 int attach_size_total;
51 int attach_count[DM_TAG_ATTACH_COUNT];
52 int attach_size[DM_TAG_ATTACH_COUNT];
53};
54
6494d708
SG
55/**
56 * dm_root() - Return pointer to the top of the driver tree
57 *
58 * This function returns pointer to the root node of the driver tree,
59 *
0cdd7ded 60 * Return: pointer to root device, or NULL if not inited yet
6494d708 61 */
54c5d08a 62struct udevice *dm_root(void);
6494d708 63
2f11cd91
SG
64struct global_data;
65/**
66 * dm_fixup_for_gd_move() - Handle global_data moving to a new place
67 *
0cdd7ded
PD
68 * @new_gd: Pointer to the new global data
69 *
2f11cd91
SG
70 * The uclass list is part of global_data. Due to the way lists work, moving
71 * the list will cause it to become invalid. This function fixes that up so
72 * that the uclass list will work correctly.
73 */
74void dm_fixup_for_gd_move(struct global_data *new_gd);
75
6494d708 76/**
8a8d24bd 77 * dm_scan_plat() - Scan all platform data and bind drivers
6494d708 78 *
caa4daa2 79 * This scans all available plat and creates drivers for each
6494d708 80 *
00606d7e
SG
81 * @pre_reloc_only: If true, bind only drivers with the DM_FLAG_PRE_RELOC
82 * flag. If false bind all drivers.
0cdd7ded 83 * Return: 0 if OK, -ve on error
6494d708 84 */
8a8d24bd 85int dm_scan_plat(bool pre_reloc_only);
6494d708
SG
86
87/**
88 * dm_scan_fdt() - Scan the device tree and bind drivers
89 *
0040b944
SG
90 * This scans the device tree and creates a driver for each node. Only
91 * the top-level subnodes are examined.
6494d708 92 *
6244fc64
BM
93 * @pre_reloc_only: If true, bind only nodes with special devicetree properties,
94 * or drivers with the DM_FLAG_PRE_RELOC flag. If false bind all drivers.
0cdd7ded 95 * Return: 0 if OK, -ve on error
6494d708 96 */
725e4fce 97int dm_scan_fdt(bool pre_reloc_only);
6494d708 98
e81c9864 99/**
8ee05b5f 100 * dm_extended_scan() - Scan the device tree and bind drivers
e81c9864
PC
101 *
102 * This calls dm_scna_dft() which scans the device tree and creates a driver
103 * for each node. the top-level subnodes are examined and also all sub-nodes
104 * of "clocks" node.
105 *
6244fc64
BM
106 * @pre_reloc_only: If true, bind only nodes with special devicetree properties,
107 * or drivers with the DM_FLAG_PRE_RELOC flag. If false bind all drivers.
0cdd7ded 108 * Return: 0 if OK, -ve on error
e81c9864 109 */
8ee05b5f 110int dm_extended_scan(bool pre_reloc_only);
e81c9864 111
bb58503d
SG
112/**
113 * dm_scan_other() - Scan for other devices
114 *
115 * Some devices may not be visible to Driver Model. This weak function can
116 * be provided by boards which wish to create their own devices
117 * programmaticaly. They should do this by calling device_bind() on each
118 * device.
119 *
6244fc64
BM
120 * @pre_reloc_only: If true, bind only nodes with special devicetree properties,
121 * or drivers with the DM_FLAG_PRE_RELOC flag. If false bind all drivers.
0cdd7ded 122 * Return: 0 if OK, -ve on error
bb58503d
SG
123 */
124int dm_scan_other(bool pre_reloc_only);
125
ab7cd627
SG
126/**
127 * dm_init_and_scan() - Initialise Driver Model structures and scan for devices
128 *
129 * This function initialises the roots of the driver tree and uclass trees,
130 * then scans and binds available devices from platform data and the FDT.
131 * This calls dm_init() to set up Driver Model structures.
132 *
6244fc64
BM
133 * @pre_reloc_only: If true, bind only nodes with special devicetree properties,
134 * or drivers with the DM_FLAG_PRE_RELOC flag. If false bind all drivers.
0cdd7ded 135 * Return: 0 if OK, -ve on error
ab7cd627
SG
136 */
137int dm_init_and_scan(bool pre_reloc_only);
138
6995f2c8
SG
139/**
140 * dm_autoprobe() - Probe devices which are marked for probe-after-bind
141 *
142 * This probes all devices with a DM_FLAG_PROBE_AFTER_BIND flag. It checks the
143 * entire tree, so parent nodes need not have the flag set.
144 *
145 * It recursively probes parent nodes, so they do not need to have the flag
146 * set themselves. Since parents are always probed before children, if a child
147 * has the flag set, then its parent (and any devices up the chain to the root
148 * device) will be probed too.
149 *
150 * Return: 0 if OK, -ve on error
151 */
152int dm_autoprobe(void);
153
6494d708 154/**
f2bc6fc3 155 * dm_init() - Initialise Driver Model structures
6494d708
SG
156 *
157 * This function will initialize roots of driver tree and class tree.
158 * This needs to be called before anything uses the DM
159 *
19c8205e 160 * @of_live: Enable live device tree
0cdd7ded 161 * Return: 0 if OK, -ve on error
6494d708 162 */
19c8205e 163int dm_init(bool of_live);
6494d708 164
9adbd7a1
SG
165/**
166 * dm_uninit - Uninitialise Driver Model structures
167 *
168 * All devices will be removed and unbound
0cdd7ded 169 * Return: 0 if OK, -ve on error
9adbd7a1
SG
170 */
171int dm_uninit(void);
172
bc85aa40
SR
173#if CONFIG_IS_ENABLED(DM_DEVICE_REMOVE)
174/**
175 * dm_remove_devices_flags - Call remove function of all drivers with
176 * specific removal flags set to selectively
177 * remove drivers
178 *
179 * All devices with the matching flags set will be removed
180 *
181 * @flags: Flags for selective device removal
0cdd7ded 182 * Return: 0 if OK, -ve on error
bc85aa40
SR
183 */
184int dm_remove_devices_flags(uint flags);
dabaa4ae
JG
185
186/**
187 * dm_remove_devices_active - Call remove function of all active drivers heeding
188 * device dependencies as far as know, i.e. removing
189 * devices marked with DM_FLAG_VITAL last.
190 *
191 * All active devices will be removed
192 */
193void dm_remove_devices_active(void);
bc85aa40
SR
194#else
195static inline int dm_remove_devices_flags(uint flags) { return 0; }
dabaa4ae 196static inline void dm_remove_devices_active(void) { }
bc85aa40
SR
197#endif
198
6476c4d9
SG
199/**
200 * dm_get_stats() - Get some stats for driver mode
201 *
202 * @device_countp: Returns total number of devices that are bound
203 * @uclass_countp: Returns total number of uclasses in use
204 */
205void dm_get_stats(int *device_countp, int *uclass_countp);
206
0dfda34c
SG
207/**
208 * dm_get_mem() - Get stats on memory usage in driver model
209 *
2cb4ddb9 210 * @stats: Place to put the information
0dfda34c
SG
211 */
212void dm_get_mem(struct dm_stats *stats);
213
6494d708 214#endif
This page took 0.472371 seconds and 4 git commands to generate.