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