1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * Copyright (c) 2016, NVIDIA CORPORATION.
4 */
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,
42			struct ofnode_phandle_args *args);
43	/**
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	/**
57	 * rfree - Free a previously requested power domain.
58	 *
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	 */
64	int (*rfree)(struct power_domain *power_domain);
65	/**
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
82