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