1 /* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * 4 * HDF is dual licensed: you can use it either under the terms of 5 * the GPL, or the BSD license, at your option. 6 * See the LICENSE file in the root of this repository for complete details. 7 */ 8 9 #ifndef REGULATOR_TREE_MGR_H 10 #define REGULATOR_TREE_MGR_H 11 12 #include "regulator_core.h" 13 #include "hdf_log.h" 14 #include "hdf_base.h" 15 #include "osal_mutex.h" 16 17 #ifdef __cplusplus 18 #if __cplusplus 19 extern "C" { 20 #endif /* __cplusplus */ 21 #endif /* __cplusplus */ 22 23 struct RegulatorChildNode { 24 struct RegulatorNode *child; 25 struct DListHead node; 26 }; 27 28 struct RegulatorTreeInfo { 29 const char *name; /* regulator name */ 30 struct RegulatorNode *parent; /* regulator parent info */ 31 struct DListHead node; 32 struct DListHead childHead; /* next level child regulator list */ 33 }; 34 35 struct RegulatorTreeManager { 36 struct DListHead treeMgrHead; 37 struct OsalMutex lock; 38 }; 39 40 int RegulatorTreeManagerInit(void); 41 int RegulatorTreeManagerDestory(void); 42 int RegulatorTreeNodeRemoveAll(void); 43 int RegulatorTreeSet(const char *name, struct RegulatorNode *child, struct RegulatorNode *parent); 44 void RegulatorTreePrint(void); 45 struct RegulatorNode *RegulatorTreeGetParent(const char *name); 46 int32_t RegulatorTreeChildForceDisable(struct RegulatorNode *node); 47 bool RegulatorTreeIsAllChildDisable(const char *name); 48 bool RegulatorTreeIsChildAlwayson(const char *name); 49 bool RegulatorTreeIsChildStatusOn(const char *name); 50 bool RegulatorTreeIsUpNodeComplete(const char *name); 51 52 #ifdef __cplusplus 53 #if __cplusplus 54 } 55 #endif /* __cplusplus */ 56 #endif /* __cplusplus */ 57 58 #endif /* REGULATOR_TREE_MGR_H */ 59