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 246494d708SSimon Glass /** 256494d708SSimon Glass * dm_scan_platdata() - Scan all platform data and bind drivers 266494d708SSimon Glass * 276494d708SSimon Glass * This scans all available platdata and creates drivers for each 286494d708SSimon Glass * 2900606d7eSSimon Glass * @pre_reloc_only: If true, bind only drivers with the DM_FLAG_PRE_RELOC 3000606d7eSSimon Glass * flag. If false bind all drivers. 316494d708SSimon Glass * @return 0 if OK, -ve on error 326494d708SSimon Glass */ 3300606d7eSSimon Glass int dm_scan_platdata(bool pre_reloc_only); 346494d708SSimon Glass 356494d708SSimon Glass /** 366494d708SSimon Glass * dm_scan_fdt() - Scan the device tree and bind drivers 376494d708SSimon Glass * 380040b944SSimon Glass * This scans the device tree and creates a driver for each node. Only 390040b944SSimon Glass * the top-level subnodes are examined. 406494d708SSimon Glass * 416494d708SSimon Glass * @blob: Pointer to device tree blob 4200606d7eSSimon Glass * @pre_reloc_only: If true, bind only drivers with the DM_FLAG_PRE_RELOC 4300606d7eSSimon Glass * flag. If false bind all drivers. 446494d708SSimon Glass * @return 0 if OK, -ve on error 456494d708SSimon Glass */ 4600606d7eSSimon Glass int dm_scan_fdt(const void *blob, bool pre_reloc_only); 476494d708SSimon Glass 486494d708SSimon Glass /** 491ca7e206SSimon Glass * dm_scan_fdt_node() - Scan the device tree and bind drivers for a node 501ca7e206SSimon Glass * 511ca7e206SSimon Glass * This scans the subnodes of a device tree node and and creates a driver 521ca7e206SSimon Glass * for each one. 531ca7e206SSimon Glass * 541ca7e206SSimon Glass * @parent: Parent device for the devices that will be created 551ca7e206SSimon Glass * @blob: Pointer to device tree blob 561ca7e206SSimon Glass * @offset: Offset of node to scan 571ca7e206SSimon Glass * @pre_reloc_only: If true, bind only drivers with the DM_FLAG_PRE_RELOC 581ca7e206SSimon Glass * flag. If false bind all drivers. 591ca7e206SSimon Glass * @return 0 if OK, -ve on error 601ca7e206SSimon Glass */ 611ca7e206SSimon Glass int dm_scan_fdt_node(struct udevice *parent, const void *blob, int offset, 621ca7e206SSimon Glass bool pre_reloc_only); 631ca7e206SSimon Glass 641ca7e206SSimon Glass /** 65*bb58503dSSimon Glass * dm_scan_other() - Scan for other devices 66*bb58503dSSimon Glass * 67*bb58503dSSimon Glass * Some devices may not be visible to Driver Model. This weak function can 68*bb58503dSSimon Glass * be provided by boards which wish to create their own devices 69*bb58503dSSimon Glass * programmaticaly. They should do this by calling device_bind() on each 70*bb58503dSSimon Glass * device. 71*bb58503dSSimon Glass * 72*bb58503dSSimon Glass * @pre_reloc_only: If true, bind only drivers with the DM_FLAG_PRE_RELOC 73*bb58503dSSimon Glass * flag. If false bind all drivers. 74*bb58503dSSimon Glass */ 75*bb58503dSSimon Glass int dm_scan_other(bool pre_reloc_only); 76*bb58503dSSimon Glass 77*bb58503dSSimon Glass /** 78ab7cd627SSimon Glass * dm_init_and_scan() - Initialise Driver Model structures and scan for devices 79ab7cd627SSimon Glass * 80ab7cd627SSimon Glass * This function initialises the roots of the driver tree and uclass trees, 81ab7cd627SSimon Glass * then scans and binds available devices from platform data and the FDT. 82ab7cd627SSimon Glass * This calls dm_init() to set up Driver Model structures. 83ab7cd627SSimon Glass * 84ab7cd627SSimon Glass * @pre_reloc_only: If true, bind only drivers with the DM_FLAG_PRE_RELOC 85ab7cd627SSimon Glass * flag. If false bind all drivers. 86ab7cd627SSimon Glass * @return 0 if OK, -ve on error 87ab7cd627SSimon Glass */ 88ab7cd627SSimon Glass int dm_init_and_scan(bool pre_reloc_only); 89ab7cd627SSimon Glass 90ab7cd627SSimon Glass /** 91f2bc6fc3SSimon Glass * dm_init() - Initialise Driver Model structures 926494d708SSimon Glass * 936494d708SSimon Glass * This function will initialize roots of driver tree and class tree. 946494d708SSimon Glass * This needs to be called before anything uses the DM 956494d708SSimon Glass * 966494d708SSimon Glass * @return 0 if OK, -ve on error 976494d708SSimon Glass */ 986494d708SSimon Glass int dm_init(void); 996494d708SSimon Glass 1009adbd7a1SSimon Glass /** 1019adbd7a1SSimon Glass * dm_uninit - Uninitialise Driver Model structures 1029adbd7a1SSimon Glass * 1039adbd7a1SSimon Glass * All devices will be removed and unbound 1049adbd7a1SSimon Glass * @return 0 if OK, -ve on error 1059adbd7a1SSimon Glass */ 1069adbd7a1SSimon Glass int dm_uninit(void); 1079adbd7a1SSimon Glass 1086494d708SSimon Glass #endif 109