1 /* 2 * Copyright (c) 2013 Google, Inc 3 * 4 * (C) Copyright 2012 5 * Pavel Herrmann <morpheus.ibis@gmail.com> 6 * 7 * SPDX-License-Identifier: GPL-2.0+ 8 */ 9 10 #ifndef _DM_UCLASS_INTERNAL_H 11 #define _DM_UCLASS_INTERNAL_H 12 13 /** 14 * uclass_find_device() - Return n-th child of uclass 15 * @id: Id number of the uclass 16 * @index: Position of the child in uclass's list 17 * #devp: Returns pointer to device, or NULL on error 18 * 19 * The device is not prepared for use - this is an internal function 20 * 21 * @return the uclass pointer of a child at the given index or 22 * return NULL on error. 23 */ 24 int uclass_find_device(enum uclass_id id, int index, struct udevice **devp); 25 26 /** 27 * uclass_bind_device() - Associate device with a uclass 28 * 29 * Connect the device into uclass's list of devices. 30 * 31 * @dev: Pointer to the device 32 * #return 0 on success, -ve on error 33 */ 34 int uclass_bind_device(struct udevice *dev); 35 36 /** 37 * uclass_unbind_device() - Deassociate device with a uclass 38 * 39 * Disconnect the device from uclass's list of devices. 40 * 41 * @dev: Pointer to the device 42 * #return 0 on success, -ve on error 43 */ 44 int uclass_unbind_device(struct udevice *dev); 45 46 /** 47 * uclass_pre_probe_child() - Deal with a child that is about to be probed 48 * 49 * Perform any pre-processing that is needed by the uclass before it can be 50 * probed. 51 * 52 * @dev: Pointer to the device 53 * #return 0 on success, -ve on error 54 */ 55 int uclass_pre_probe_child(struct udevice *dev); 56 57 /** 58 * uclass_post_probe_device() - Deal with a device that has just been probed 59 * 60 * Perform any post-processing of a probed device that is needed by the 61 * uclass. 62 * 63 * @dev: Pointer to the device 64 * #return 0 on success, -ve on error 65 */ 66 int uclass_post_probe_device(struct udevice *dev); 67 68 /** 69 * uclass_pre_remove_device() - Handle a device which is about to be removed 70 * 71 * Perform any pre-processing of a device that is about to be removed. 72 * 73 * @dev: Pointer to the device 74 * #return 0 on success, -ve on error 75 */ 76 int uclass_pre_remove_device(struct udevice *dev); 77 78 /** 79 * uclass_find() - Find uclass by its id 80 * 81 * @id: Id to serach for 82 * @return pointer to uclass, or NULL if not found 83 */ 84 struct uclass *uclass_find(enum uclass_id key); 85 86 /** 87 * uclass_destroy() - Destroy a uclass 88 * 89 * Destroy a uclass and all its devices 90 * 91 * @uc: uclass to destroy 92 * @return 0 on success, -ve on error 93 */ 94 int uclass_destroy(struct uclass *uc); 95 96 /** 97 * uclass_find_device_by_seq() - Find uclass device based on ID and sequence 98 * 99 * This searches for a device with the given seq or req_seq. 100 * 101 * For seq, if an active device has this sequence it will be returned. 102 * If there is no such device then this will return -ENODEV. 103 * 104 * For req_seq, if a device (whether activated or not) has this req_seq 105 * value, that device will be returned. This is a strong indication that 106 * the device will receive that sequence when activated. 107 * 108 * The device is NOT probed, it is merely returned. 109 * 110 * @id: ID to look up 111 * @seq_or_req_seq: Sequence number to find (0=first) 112 * @find_req_seq: true to find req_seq, false to find seq 113 * @devp: Returns pointer to device (there is only one per for each seq) 114 * @return 0 if OK, -ve on error 115 */ 116 int uclass_find_device_by_seq(enum uclass_id id, int seq_or_req_seq, 117 bool find_req_seq, struct udevice **devp); 118 119 #endif 120