xref: /rk3399_rockchip-uboot/include/dm/root.h (revision 19c8205e6887d5e47c7dac6cd85d0376411b5444)
16494d708SSimon Glass /*
26494d708SSimon Glass  * Copyright (c) 2013 Google, Inc
36494d708SSimon Glass  *
46494d708SSimon Glass  * (C) Copyright 2012
56494d708SSimon Glass  * Pavel Herrmann <morpheus.ibis@gmail.com>
66494d708SSimon Glass  *
76494d708SSimon Glass  * SPDX-License-Identifier:	GPL-2.0+
86494d708SSimon Glass  */
96494d708SSimon Glass 
106494d708SSimon Glass #ifndef _DM_ROOT_H_
116494d708SSimon Glass #define _DM_ROOT_H_
126494d708SSimon Glass 
1354c5d08aSHeiko Schocher struct udevice;
146494d708SSimon Glass 
156494d708SSimon Glass /**
166494d708SSimon Glass  * dm_root() - Return pointer to the top of the driver tree
176494d708SSimon Glass  *
186494d708SSimon Glass  * This function returns pointer to the root node of the driver tree,
196494d708SSimon Glass  *
206494d708SSimon Glass  * @return pointer to root device, or NULL if not inited yet
216494d708SSimon Glass  */
2254c5d08aSHeiko Schocher struct udevice *dm_root(void);
236494d708SSimon Glass 
242f11cd91SSimon Glass struct global_data;
252f11cd91SSimon Glass /**
262f11cd91SSimon Glass  * dm_fixup_for_gd_move() - Handle global_data moving to a new place
272f11cd91SSimon Glass  *
282f11cd91SSimon Glass  * The uclass list is part of global_data. Due to the way lists work, moving
292f11cd91SSimon Glass  * the list will cause it to become invalid. This function fixes that up so
302f11cd91SSimon Glass  * that the uclass list will work correctly.
312f11cd91SSimon Glass  */
322f11cd91SSimon Glass void dm_fixup_for_gd_move(struct global_data *new_gd);
332f11cd91SSimon Glass 
346494d708SSimon Glass /**
356494d708SSimon Glass  * dm_scan_platdata() - Scan all platform data and bind drivers
366494d708SSimon Glass  *
376494d708SSimon Glass  * This scans all available platdata and creates drivers for each
386494d708SSimon Glass  *
3900606d7eSSimon Glass  * @pre_reloc_only: If true, bind only drivers with the DM_FLAG_PRE_RELOC
4000606d7eSSimon Glass  * flag. If false bind all drivers.
416494d708SSimon Glass  * @return 0 if OK, -ve on error
426494d708SSimon Glass  */
4300606d7eSSimon Glass int dm_scan_platdata(bool pre_reloc_only);
446494d708SSimon Glass 
456494d708SSimon Glass /**
466494d708SSimon Glass  * dm_scan_fdt() - Scan the device tree and bind drivers
476494d708SSimon Glass  *
480040b944SSimon Glass  * This scans the device tree and creates a driver for each node. Only
490040b944SSimon Glass  * the top-level subnodes are examined.
506494d708SSimon Glass  *
516494d708SSimon Glass  * @blob: Pointer to device tree blob
5200606d7eSSimon Glass  * @pre_reloc_only: If true, bind only drivers with the DM_FLAG_PRE_RELOC
5300606d7eSSimon Glass  * flag. If false bind all drivers.
546494d708SSimon Glass  * @return 0 if OK, -ve on error
556494d708SSimon Glass  */
5600606d7eSSimon Glass int dm_scan_fdt(const void *blob, bool pre_reloc_only);
576494d708SSimon Glass 
586494d708SSimon Glass /**
59bb58503dSSimon Glass  * dm_scan_other() - Scan for other devices
60bb58503dSSimon Glass  *
61bb58503dSSimon Glass  * Some devices may not be visible to Driver Model. This weak function can
62bb58503dSSimon Glass  * be provided by boards which wish to create their own devices
63bb58503dSSimon Glass  * programmaticaly. They should do this by calling device_bind() on each
64bb58503dSSimon Glass  * device.
65bb58503dSSimon Glass  *
66bb58503dSSimon Glass  * @pre_reloc_only: If true, bind only drivers with the DM_FLAG_PRE_RELOC
67bb58503dSSimon Glass  * flag. If false bind all drivers.
68bb58503dSSimon Glass  */
69bb58503dSSimon Glass int dm_scan_other(bool pre_reloc_only);
70bb58503dSSimon Glass 
71bb58503dSSimon Glass /**
72ab7cd627SSimon Glass  * dm_init_and_scan() - Initialise Driver Model structures and scan for devices
73ab7cd627SSimon Glass  *
74ab7cd627SSimon Glass  * This function initialises the roots of the driver tree and uclass trees,
75ab7cd627SSimon Glass  * then scans and binds available devices from platform data and the FDT.
76ab7cd627SSimon Glass  * This calls dm_init() to set up Driver Model structures.
77ab7cd627SSimon Glass  *
78ab7cd627SSimon Glass  * @pre_reloc_only: If true, bind only drivers with the DM_FLAG_PRE_RELOC
79ab7cd627SSimon Glass  * flag. If false bind all drivers.
80ab7cd627SSimon Glass  * @return 0 if OK, -ve on error
81ab7cd627SSimon Glass  */
82ab7cd627SSimon Glass int dm_init_and_scan(bool pre_reloc_only);
83ab7cd627SSimon Glass 
84ab7cd627SSimon Glass /**
85f2bc6fc3SSimon Glass  * dm_init() - Initialise Driver Model structures
866494d708SSimon Glass  *
876494d708SSimon Glass  * This function will initialize roots of driver tree and class tree.
886494d708SSimon Glass  * This needs to be called before anything uses the DM
896494d708SSimon Glass  *
90*19c8205eSSimon Glass  * @of_live:	Enable live device tree
916494d708SSimon Glass  * @return 0 if OK, -ve on error
926494d708SSimon Glass  */
93*19c8205eSSimon Glass int dm_init(bool of_live);
946494d708SSimon Glass 
959adbd7a1SSimon Glass /**
969adbd7a1SSimon Glass  * dm_uninit - Uninitialise Driver Model structures
979adbd7a1SSimon Glass  *
989adbd7a1SSimon Glass  * All devices will be removed and unbound
999adbd7a1SSimon Glass  * @return 0 if OK, -ve on error
1009adbd7a1SSimon Glass  */
1019adbd7a1SSimon Glass int dm_uninit(void);
1029adbd7a1SSimon Glass 
103bc85aa40SStefan Roese #if CONFIG_IS_ENABLED(DM_DEVICE_REMOVE)
104bc85aa40SStefan Roese /**
105bc85aa40SStefan Roese  * dm_remove_devices_flags - Call remove function of all drivers with
106bc85aa40SStefan Roese  *                           specific removal flags set to selectively
107bc85aa40SStefan Roese  *                           remove drivers
108bc85aa40SStefan Roese  *
109bc85aa40SStefan Roese  * All devices with the matching flags set will be removed
110bc85aa40SStefan Roese  *
111bc85aa40SStefan Roese  * @flags: Flags for selective device removal
112bc85aa40SStefan Roese  * @return 0 if OK, -ve on error
113bc85aa40SStefan Roese  */
114bc85aa40SStefan Roese int dm_remove_devices_flags(uint flags);
115bc85aa40SStefan Roese #else
116bc85aa40SStefan Roese static inline int dm_remove_devices_flags(uint flags) { return 0; }
117bc85aa40SStefan Roese #endif
118bc85aa40SStefan Roese 
1196494d708SSimon Glass #endif
120