blob: ae2a93d7d4da7a806826843296d8c2d0d67ce20c [file] [log] [blame]
Simon Glassdd6ab882014-02-26 15:59:18 -07001/*
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 */
Heiko Schocherb74fcb42014-05-22 12:43:05 +020024int uclass_find_device(enum uclass_id id, int index, struct udevice **devp);
Simon Glassdd6ab882014-02-26 15:59:18 -070025
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 */
Heiko Schocherb74fcb42014-05-22 12:43:05 +020034int uclass_bind_device(struct udevice *dev);
Simon Glassdd6ab882014-02-26 15:59:18 -070035
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 */
Heiko Schocherb74fcb42014-05-22 12:43:05 +020044int uclass_unbind_device(struct udevice *dev);
Simon Glassdd6ab882014-02-26 15:59:18 -070045
46/**
Simon Glass9c1f3822015-03-05 12:25:22 -070047 * uclass_pre_probe_device() - Deal with a device that is about to be probed
Simon Glass5104b982015-01-25 08:27:10 -070048 *
49 * Perform any pre-processing that is needed by the uclass before it can be
Simon Glass9c1f3822015-03-05 12:25:22 -070050 * probed. This includes the uclass' pre-probe() method and the parent
51 * uclass' child_pre_probe() method.
Simon Glass5104b982015-01-25 08:27:10 -070052 *
53 * @dev: Pointer to the device
54 * #return 0 on success, -ve on error
55 */
Simon Glass9c1f3822015-03-05 12:25:22 -070056int uclass_pre_probe_device(struct udevice *dev);
Simon Glass5104b982015-01-25 08:27:10 -070057
58/**
Simon Glassdd6ab882014-02-26 15:59:18 -070059 * uclass_post_probe_device() - Deal with a device that has just been probed
60 *
61 * Perform any post-processing of a probed device that is needed by the
62 * uclass.
63 *
64 * @dev: Pointer to the device
65 * #return 0 on success, -ve on error
66 */
Heiko Schocherb74fcb42014-05-22 12:43:05 +020067int uclass_post_probe_device(struct udevice *dev);
Simon Glassdd6ab882014-02-26 15:59:18 -070068
69/**
70 * uclass_pre_remove_device() - Handle a device which is about to be removed
71 *
72 * Perform any pre-processing of a device that is about to be removed.
73 *
74 * @dev: Pointer to the device
75 * #return 0 on success, -ve on error
76 */
Heiko Schocherb74fcb42014-05-22 12:43:05 +020077int uclass_pre_remove_device(struct udevice *dev);
Simon Glassdd6ab882014-02-26 15:59:18 -070078
79/**
80 * uclass_find() - Find uclass by its id
81 *
82 * @id: Id to serach for
83 * @return pointer to uclass, or NULL if not found
84 */
85struct uclass *uclass_find(enum uclass_id key);
86
87/**
88 * uclass_destroy() - Destroy a uclass
89 *
90 * Destroy a uclass and all its devices
91 *
92 * @uc: uclass to destroy
93 * @return 0 on success, -ve on error
94 */
95int uclass_destroy(struct uclass *uc);
96
Simon Glassdb6f0202014-07-23 06:55:12 -060097/**
98 * uclass_find_device_by_seq() - Find uclass device based on ID and sequence
99 *
100 * This searches for a device with the given seq or req_seq.
101 *
102 * For seq, if an active device has this sequence it will be returned.
103 * If there is no such device then this will return -ENODEV.
104 *
105 * For req_seq, if a device (whether activated or not) has this req_seq
106 * value, that device will be returned. This is a strong indication that
107 * the device will receive that sequence when activated.
108 *
109 * The device is NOT probed, it is merely returned.
110 *
111 * @id: ID to look up
112 * @seq_or_req_seq: Sequence number to find (0=first)
113 * @find_req_seq: true to find req_seq, false to find seq
114 * @devp: Returns pointer to device (there is only one per for each seq)
115 * @return 0 if OK, -ve on error
116 */
117int uclass_find_device_by_seq(enum uclass_id id, int seq_or_req_seq,
118 bool find_req_seq, struct udevice **devp);
119
Simon Glassdd6ab882014-02-26 15:59:18 -0700120#endif