blob: 1434db3eb4c75f5cacc4b219b1dff7090b8aace5 [file] [log] [blame]
Simon Glass6494d702014-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 Schocher54c5d082014-05-22 12:43:05 +020024int uclass_find_device(enum uclass_id id, int index, struct udevice **devp);
Simon Glass6494d702014-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 Schocher54c5d082014-05-22 12:43:05 +020034int uclass_bind_device(struct udevice *dev);
Simon Glass6494d702014-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 Schocher54c5d082014-05-22 12:43:05 +020044int uclass_unbind_device(struct udevice *dev);
Simon Glass6494d702014-02-26 15:59:18 -070045
46/**
47 * uclass_post_probe_device() - Deal with a device that has just been probed
48 *
49 * Perform any post-processing of a probed device that is needed by the
50 * uclass.
51 *
52 * @dev: Pointer to the device
53 * #return 0 on success, -ve on error
54 */
Heiko Schocher54c5d082014-05-22 12:43:05 +020055int uclass_post_probe_device(struct udevice *dev);
Simon Glass6494d702014-02-26 15:59:18 -070056
57/**
58 * uclass_pre_remove_device() - Handle a device which is about to be removed
59 *
60 * Perform any pre-processing of a device that is about to be removed.
61 *
62 * @dev: Pointer to the device
63 * #return 0 on success, -ve on error
64 */
Heiko Schocher54c5d082014-05-22 12:43:05 +020065int uclass_pre_remove_device(struct udevice *dev);
Simon Glass6494d702014-02-26 15:59:18 -070066
67/**
68 * uclass_find() - Find uclass by its id
69 *
70 * @id: Id to serach for
71 * @return pointer to uclass, or NULL if not found
72 */
73struct uclass *uclass_find(enum uclass_id key);
74
75/**
76 * uclass_destroy() - Destroy a uclass
77 *
78 * Destroy a uclass and all its devices
79 *
80 * @uc: uclass to destroy
81 * @return 0 on success, -ve on error
82 */
83int uclass_destroy(struct uclass *uc);
84
85#endif