1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Copyright (c) 2013 Google, Inc
6 * Pavel Herrmann <morpheus.ibis@gmail.com>
14 /* Head of the uclass list if CONFIG_OF_PLATDATA_INST is enabled */
15 extern struct list_head uclass_head;
18 * dm_root() - Return pointer to the top of the driver tree
20 * This function returns pointer to the root node of the driver tree,
22 * Return: pointer to root device, or NULL if not inited yet
24 struct udevice *dm_root(void);
28 * dm_fixup_for_gd_move() - Handle global_data moving to a new place
30 * @new_gd: Pointer to the new global data
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.
36 void dm_fixup_for_gd_move(struct global_data *new_gd);
39 * dm_scan_plat() - Scan all platform data and bind drivers
41 * This scans all available plat and creates drivers for each
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
47 int dm_scan_plat(bool pre_reloc_only);
50 * dm_scan_fdt() - Scan the device tree and bind drivers
52 * This scans the device tree and creates a driver for each node. Only
53 * the top-level subnodes are examined.
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
59 int dm_scan_fdt(bool pre_reloc_only);
62 * dm_extended_scan() - Scan the device tree and bind drivers
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
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
72 int dm_extended_scan(bool pre_reloc_only);
75 * dm_scan_other() - Scan for other devices
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
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
86 int dm_scan_other(bool pre_reloc_only);
89 * dm_init_and_scan() - Initialise Driver Model structures and scan for devices
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.
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
99 int dm_init_and_scan(bool pre_reloc_only);
102 * dm_init() - Initialise Driver Model structures
104 * This function will initialize roots of driver tree and class tree.
105 * This needs to be called before anything uses the DM
107 * @of_live: Enable live device tree
108 * Return: 0 if OK, -ve on error
110 int dm_init(bool of_live);
113 * dm_uninit - Uninitialise Driver Model structures
115 * All devices will be removed and unbound
116 * Return: 0 if OK, -ve on error
120 #if CONFIG_IS_ENABLED(DM_DEVICE_REMOVE)
122 * dm_remove_devices_flags - Call remove function of all drivers with
123 * specific removal flags set to selectively
126 * All devices with the matching flags set will be removed
128 * @flags: Flags for selective device removal
129 * Return: 0 if OK, -ve on error
131 int dm_remove_devices_flags(uint flags);
133 static inline int dm_remove_devices_flags(uint flags) { return 0; }
137 * dm_get_stats() - Get some stats for driver mode
139 * @device_countp: Returns total number of devices that are bound
140 * @uclass_countp: Returns total number of uclasses in use
142 void dm_get_stats(int *device_countp, int *uclass_countp);