1 /*
2  * Copyright (c) 2021-2022 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 HDF_CHIP_CONFIG_H
10 #define HDF_CHIP_CONFIG_H
11 
12 #include "device_resource_if.h"
13 #include "hdf_base.h"
14 #include "hdf_log.h"
15 #include "osal_mem.h"
16 #include "securec.h"
17 
18 #define HDF_CHIP_MAX_POWER_SUPPORTED 2
19 
20 #define BUS_FUNC_MAX 1
21 #define MAX_POWER_COUNT_LEN 32
22 
23 enum PowerType {
24     POWER_TYPE_ALWAYS_ON = 0,
25     POWER_TYPE_GPIO
26 };
27 
28 struct HdfConfigGpioBasedSwitch {
29     uint16_t gpioId;
30     uint8_t activeLevel;
31 };
32 
33 struct HdfPowerConfig {
34     uint8_t powerSeqDelay;
35     uint8_t type;
36     union {
37         struct HdfConfigGpioBasedSwitch gpio;
38     };
39 };
40 
41 struct HdfPowersConfig {
42     uint8_t powerCount;
43     struct HdfPowerConfig power[0];
44 };
45 
46 enum ResetType {
47     RESET_TYPE_NOT_MANAGEABLE = 0,
48     RESET_TYPE_GPIO
49 };
50 
51 struct HdfResetConfig {
52     union {
53         struct HdfConfigGpioBasedSwitch gpio;
54     };
55     uint8_t resetType;
56     uint8_t resetHoldTime;
57 };
58 
59 struct HdfChipConfig {
60     const char *name;
61     struct HdfPowersConfig *powers;
62     struct HdfResetConfig reset;
63     uint8_t bootUpTimeOut;
64 };
65 
66 void ClearChipConfig(struct HdfChipConfig *config);
67 int32_t ParseChipConfig(const struct DeviceResourceNode *node, struct HdfChipConfig *config);
68 
69 #endif