xref: /rk3399_rockchip-uboot/include/dm/root.h (revision 46fb92f0e825f26713d1527f3d701fd6ffab95b8)
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 /**
59*46fb92f0SPatrice Chotard  * dm_extended_scan_fdt() - Scan the device tree and bind drivers
60*46fb92f0SPatrice Chotard  *
61*46fb92f0SPatrice Chotard  * This calls dm_scna_dft() which scans the device tree and creates a driver
62*46fb92f0SPatrice Chotard  * for each node. the top-level subnodes are examined and also all sub-nodes
63*46fb92f0SPatrice Chotard  * of "clocks" node.
64*46fb92f0SPatrice Chotard  *
65*46fb92f0SPatrice Chotard  * @blob: Pointer to device tree blob
66*46fb92f0SPatrice Chotard  * @pre_reloc_only: If true, bind only drivers with the DM_FLAG_PRE_RELOC
67*46fb92f0SPatrice Chotard  * flag. If false bind all drivers.
68*46fb92f0SPatrice Chotard  * @return 0 if OK, -ve on error
69*46fb92f0SPatrice Chotard  */
70*46fb92f0SPatrice Chotard int dm_extended_scan_fdt(const void *blob, bool pre_reloc_only);
71*46fb92f0SPatrice Chotard 
72*46fb92f0SPatrice Chotard /**
73bb58503dSSimon Glass  * dm_scan_other() - Scan for other devices
74bb58503dSSimon Glass  *
75bb58503dSSimon Glass  * Some devices may not be visible to Driver Model. This weak function can
76bb58503dSSimon Glass  * be provided by boards which wish to create their own devices
77bb58503dSSimon Glass  * programmaticaly. They should do this by calling device_bind() on each
78bb58503dSSimon Glass  * device.
79bb58503dSSimon Glass  *
80bb58503dSSimon Glass  * @pre_reloc_only: If true, bind only drivers with the DM_FLAG_PRE_RELOC
81bb58503dSSimon Glass  * flag. If false bind all drivers.
82bb58503dSSimon Glass  */
83bb58503dSSimon Glass int dm_scan_other(bool pre_reloc_only);
84bb58503dSSimon Glass 
85bb58503dSSimon Glass /**
86ab7cd627SSimon Glass  * dm_init_and_scan() - Initialise Driver Model structures and scan for devices
87ab7cd627SSimon Glass  *
88ab7cd627SSimon Glass  * This function initialises the roots of the driver tree and uclass trees,
89ab7cd627SSimon Glass  * then scans and binds available devices from platform data and the FDT.
90ab7cd627SSimon Glass  * This calls dm_init() to set up Driver Model structures.
91ab7cd627SSimon Glass  *
92ab7cd627SSimon Glass  * @pre_reloc_only: If true, bind only drivers with the DM_FLAG_PRE_RELOC
93ab7cd627SSimon Glass  * flag. If false bind all drivers.
94ab7cd627SSimon Glass  * @return 0 if OK, -ve on error
95ab7cd627SSimon Glass  */
96ab7cd627SSimon Glass int dm_init_and_scan(bool pre_reloc_only);
97ab7cd627SSimon Glass 
98ab7cd627SSimon Glass /**
99f2bc6fc3SSimon Glass  * dm_init() - Initialise Driver Model structures
1006494d708SSimon Glass  *
1016494d708SSimon Glass  * This function will initialize roots of driver tree and class tree.
1026494d708SSimon Glass  * This needs to be called before anything uses the DM
1036494d708SSimon Glass  *
10419c8205eSSimon Glass  * @of_live:	Enable live device tree
1056494d708SSimon Glass  * @return 0 if OK, -ve on error
1066494d708SSimon Glass  */
10719c8205eSSimon Glass int dm_init(bool of_live);
1086494d708SSimon Glass 
1099adbd7a1SSimon Glass /**
1109adbd7a1SSimon Glass  * dm_uninit - Uninitialise Driver Model structures
1119adbd7a1SSimon Glass  *
1129adbd7a1SSimon Glass  * All devices will be removed and unbound
1139adbd7a1SSimon Glass  * @return 0 if OK, -ve on error
1149adbd7a1SSimon Glass  */
1159adbd7a1SSimon Glass int dm_uninit(void);
1169adbd7a1SSimon Glass 
117bc85aa40SStefan Roese #if CONFIG_IS_ENABLED(DM_DEVICE_REMOVE)
118bc85aa40SStefan Roese /**
119bc85aa40SStefan Roese  * dm_remove_devices_flags - Call remove function of all drivers with
120bc85aa40SStefan Roese  *                           specific removal flags set to selectively
121bc85aa40SStefan Roese  *                           remove drivers
122bc85aa40SStefan Roese  *
123bc85aa40SStefan Roese  * All devices with the matching flags set will be removed
124bc85aa40SStefan Roese  *
125bc85aa40SStefan Roese  * @flags: Flags for selective device removal
126bc85aa40SStefan Roese  * @return 0 if OK, -ve on error
127bc85aa40SStefan Roese  */
128bc85aa40SStefan Roese int dm_remove_devices_flags(uint flags);
129bc85aa40SStefan Roese #else
dm_remove_devices_flags(uint flags)130bc85aa40SStefan Roese static inline int dm_remove_devices_flags(uint flags) { return 0; }
131bc85aa40SStefan Roese #endif
132bc85aa40SStefan Roese 
1336494d708SSimon Glass #endif
134