pinctrl: Increase length of pinmux status buffer
[platform/kernel/u-boot.git] / include / dm / root.h
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * Copyright (c) 2013 Google, Inc
4  *
5  * (C) Copyright 2012
6  * Pavel Herrmann <morpheus.ibis@gmail.com>
7  */
8
9 #ifndef _DM_ROOT_H_
10 #define _DM_ROOT_H_
11
12 struct udevice;
13
14 /* Head of the uclass list if CONFIG_OF_PLATDATA_INST is enabled */
15 extern struct list_head uclass_head;
16
17 /**
18  * dm_root() - Return pointer to the top of the driver tree
19  *
20  * This function returns pointer to the root node of the driver tree,
21  *
22  * Return: pointer to root device, or NULL if not inited yet
23  */
24 struct udevice *dm_root(void);
25
26 struct global_data;
27 /**
28  * dm_fixup_for_gd_move() - Handle global_data moving to a new place
29  *
30  * @new_gd: Pointer to the new global data
31  *
32  * The uclass list is part of global_data. Due to the way lists work, moving
33  * the list will cause it to become invalid. This function fixes that up so
34  * that the uclass list will work correctly.
35  */
36 void dm_fixup_for_gd_move(struct global_data *new_gd);
37
38 /**
39  * dm_scan_plat() - Scan all platform data and bind drivers
40  *
41  * This scans all available plat and creates drivers for each
42  *
43  * @pre_reloc_only: If true, bind only drivers with the DM_FLAG_PRE_RELOC
44  * flag. If false bind all drivers.
45  * Return: 0 if OK, -ve on error
46  */
47 int dm_scan_plat(bool pre_reloc_only);
48
49 /**
50  * dm_scan_fdt() - Scan the device tree and bind drivers
51  *
52  * This scans the device tree and creates a driver for each node. Only
53  * the top-level subnodes are examined.
54  *
55  * @pre_reloc_only: If true, bind only nodes with special devicetree properties,
56  * or drivers with the DM_FLAG_PRE_RELOC flag. If false bind all drivers.
57  * Return: 0 if OK, -ve on error
58  */
59 int dm_scan_fdt(bool pre_reloc_only);
60
61 /**
62  * dm_extended_scan() - Scan the device tree and bind drivers
63  *
64  * This calls dm_scna_dft() which scans the device tree and creates a driver
65  * for each node. the top-level subnodes are examined and also all sub-nodes
66  * of "clocks" node.
67  *
68  * @pre_reloc_only: If true, bind only nodes with special devicetree properties,
69  * or drivers with the DM_FLAG_PRE_RELOC flag. If false bind all drivers.
70  * Return: 0 if OK, -ve on error
71  */
72 int dm_extended_scan(bool pre_reloc_only);
73
74 /**
75  * dm_scan_other() - Scan for other devices
76  *
77  * Some devices may not be visible to Driver Model. This weak function can
78  * be provided by boards which wish to create their own devices
79  * programmaticaly. They should do this by calling device_bind() on each
80  * device.
81  *
82  * @pre_reloc_only: If true, bind only nodes with special devicetree properties,
83  * or drivers with the DM_FLAG_PRE_RELOC flag. If false bind all drivers.
84  * Return: 0 if OK, -ve on error
85  */
86 int dm_scan_other(bool pre_reloc_only);
87
88 /**
89  * dm_init_and_scan() - Initialise Driver Model structures and scan for devices
90  *
91  * This function initialises the roots of the driver tree and uclass trees,
92  * then scans and binds available devices from platform data and the FDT.
93  * This calls dm_init() to set up Driver Model structures.
94  *
95  * @pre_reloc_only: If true, bind only nodes with special devicetree properties,
96  * or drivers with the DM_FLAG_PRE_RELOC flag. If false bind all drivers.
97  * Return: 0 if OK, -ve on error
98  */
99 int dm_init_and_scan(bool pre_reloc_only);
100
101 /**
102  * dm_init() - Initialise Driver Model structures
103  *
104  * This function will initialize roots of driver tree and class tree.
105  * This needs to be called before anything uses the DM
106  *
107  * @of_live:    Enable live device tree
108  * Return: 0 if OK, -ve on error
109  */
110 int dm_init(bool of_live);
111
112 /**
113  * dm_uninit - Uninitialise Driver Model structures
114  *
115  * All devices will be removed and unbound
116  * Return: 0 if OK, -ve on error
117  */
118 int dm_uninit(void);
119
120 #if CONFIG_IS_ENABLED(DM_DEVICE_REMOVE)
121 /**
122  * dm_remove_devices_flags - Call remove function of all drivers with
123  *                           specific removal flags set to selectively
124  *                           remove drivers
125  *
126  * All devices with the matching flags set will be removed
127  *
128  * @flags: Flags for selective device removal
129  * Return: 0 if OK, -ve on error
130  */
131 int dm_remove_devices_flags(uint flags);
132 #else
133 static inline int dm_remove_devices_flags(uint flags) { return 0; }
134 #endif
135
136 /**
137  * dm_get_stats() - Get some stats for driver mode
138  *
139  * @device_countp: Returns total number of devices that are bound
140  * @uclass_countp: Returns total number of uclasses in use
141  */
142 void dm_get_stats(int *device_countp, int *uclass_countp);
143
144 #endif