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 /** 49*1ca7e206SSimon Glass * dm_scan_fdt_node() - Scan the device tree and bind drivers for a node 50*1ca7e206SSimon Glass * 51*1ca7e206SSimon Glass * This scans the subnodes of a device tree node and and creates a driver 52*1ca7e206SSimon Glass * for each one. 53*1ca7e206SSimon Glass * 54*1ca7e206SSimon Glass * @parent: Parent device for the devices that will be created 55*1ca7e206SSimon Glass * @blob: Pointer to device tree blob 56*1ca7e206SSimon Glass * @offset: Offset of node to scan 57*1ca7e206SSimon Glass * @pre_reloc_only: If true, bind only drivers with the DM_FLAG_PRE_RELOC 58*1ca7e206SSimon Glass * flag. If false bind all drivers. 59*1ca7e206SSimon Glass * @return 0 if OK, -ve on error 60*1ca7e206SSimon Glass */ 61*1ca7e206SSimon Glass int dm_scan_fdt_node(struct udevice *parent, const void *blob, int offset, 62*1ca7e206SSimon Glass bool pre_reloc_only); 63*1ca7e206SSimon Glass 64*1ca7e206SSimon Glass /** 65ab7cd627SSimon Glass * dm_init_and_scan() - Initialise Driver Model structures and scan for devices 66ab7cd627SSimon Glass * 67ab7cd627SSimon Glass * This function initialises the roots of the driver tree and uclass trees, 68ab7cd627SSimon Glass * then scans and binds available devices from platform data and the FDT. 69ab7cd627SSimon Glass * This calls dm_init() to set up Driver Model structures. 70ab7cd627SSimon Glass * 71ab7cd627SSimon Glass * @pre_reloc_only: If true, bind only drivers with the DM_FLAG_PRE_RELOC 72ab7cd627SSimon Glass * flag. If false bind all drivers. 73ab7cd627SSimon Glass * @return 0 if OK, -ve on error 74ab7cd627SSimon Glass */ 75ab7cd627SSimon Glass int dm_init_and_scan(bool pre_reloc_only); 76ab7cd627SSimon Glass 77ab7cd627SSimon Glass /** 78f2bc6fc3SSimon Glass * dm_init() - Initialise Driver Model structures 796494d708SSimon Glass * 806494d708SSimon Glass * This function will initialize roots of driver tree and class tree. 816494d708SSimon Glass * This needs to be called before anything uses the DM 826494d708SSimon Glass * 836494d708SSimon Glass * @return 0 if OK, -ve on error 846494d708SSimon Glass */ 856494d708SSimon Glass int dm_init(void); 866494d708SSimon Glass 879adbd7a1SSimon Glass /** 889adbd7a1SSimon Glass * dm_uninit - Uninitialise Driver Model structures 899adbd7a1SSimon Glass * 909adbd7a1SSimon Glass * All devices will be removed and unbound 919adbd7a1SSimon Glass * @return 0 if OK, -ve on error 929adbd7a1SSimon Glass */ 939adbd7a1SSimon Glass int dm_uninit(void); 949adbd7a1SSimon Glass 956494d708SSimon Glass #endif 96