blob: acf749b38edfca39f537264f684473fe276915bb [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0 */
Stephen Warren61f5ddc2016-07-13 13:45:31 -06002/*
3 * Copyright (c) 2016, NVIDIA CORPORATION.
Stephen Warren61f5ddc2016-07-13 13:45:31 -06004 */
5
6#ifndef _POWER_DOMAIN_UCLASS_H
7#define _POWER_DOMAIN_UCLASS_H
8
9/* See power-domain.h for background documentation. */
10
11#include <power-domain.h>
12
13struct udevice;
14
15/**
16 * struct power_domain_ops - The functions that a power domain controller driver
17 * must implement.
18 */
19struct power_domain_ops {
20 /**
21 * of_xlate - Translate a client's device-tree (OF) power domain
22 * specifier.
23 *
24 * The power domain core calls this function as the first step in
25 * implementing a client's power_domain_get() call.
26 *
27 * If this function pointer is set to NULL, the power domain core will
28 * use a default implementation, which assumes #power-domain-cells =
29 * <1>, and that the DT cell contains a simple integer power domain ID.
30 *
31 * At present, the power domain API solely supports device-tree. If
32 * this changes, other xxx_xlate() functions may be added to support
33 * those other mechanisms.
34 *
35 * @power_domain: The power domain struct to hold the
36 * translation result.
37 * @args: The power domain specifier values from device
38 * tree.
39 * @return 0 if OK, or a negative error code.
40 */
41 int (*of_xlate)(struct power_domain *power_domain,
Simon Glass424b2fe2017-05-18 20:09:49 -060042 struct ofnode_phandle_args *args);
Stephen Warren61f5ddc2016-07-13 13:45:31 -060043 /**
44 * request - Request a translated power domain.
45 *
46 * The power domain core calls this function as the second step in
47 * implementing a client's power_domain_get() call, following a
48 * successful xxx_xlate() call.
49 *
50 * @power_domain: The power domain to request; this has been
51 * filled in by a previous xxx_xlate() function
52 * call.
53 * @return 0 if OK, or a negative error code.
54 */
55 int (*request)(struct power_domain *power_domain);
56 /**
Simon Glass4f511882020-02-03 07:35:51 -070057 * rfree - Free a previously requested power domain.
Stephen Warren61f5ddc2016-07-13 13:45:31 -060058 *
59 * This is the implementation of the client power_domain_free() API.
60 *
61 * @power_domain: The power domain to free.
62 * @return 0 if OK, or a negative error code.
63 */
Simon Glass4f511882020-02-03 07:35:51 -070064 int (*rfree)(struct power_domain *power_domain);
Stephen Warren61f5ddc2016-07-13 13:45:31 -060065 /**
66 * on - Power on a power domain.
67 *
68 * @power_domain: The power domain to turn on.
69 * @return 0 if OK, or a negative error code.
70 */
71 int (*on)(struct power_domain *power_domain);
72 /**
73 * off - Power off a power domain.
74 *
75 * @power_domain: The power domain to turn off.
76 * @return 0 if OK, or a negative error code.
77 */
78 int (*off)(struct power_domain *power_domain);
79};
80
81#endif