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_TEST_H
10 #define REGULATOR_TEST_H
11 
12 #include "hdf_device_desc.h"
13 #include "platform_if.h"
14 
15 #ifdef REGULATOR_TEST_PRINTK_OPEN
16 #define REGULATOR_TEST_PRINT_LOG_DBG(fmt, arg...) \
17 dprintf("[HDF]-[REGULATOR]:[%s][%d]---" fmt "\r\n", __func__, __LINE__, ##arg)
18 #define REGULATOR_TEST_PRINT_LOG_INF(fmt, arg...) \
19 dprintf("[HDF]-[REGULATOR]:[%s][%d]---" fmt "\r\n", __func__, __LINE__, ##arg)
20 #define REGULATOR_TEST_PRINT_LOG_ERR(fmt, arg...) \
21 dprintf("[HDF]-[REGULATOR]:[%s][%d]---" fmt "\r\n", __func__, __LINE__, ##arg)
22 #else
23 #define REGULATOR_TEST_PRINT_LOG_DBG(fmt, arg...) HDF_LOGD_WRAPPER("[HDF]-[REGULATOR]:" fmt "\r\n",  ##arg)
24 #define REGULATOR_TEST_PRINT_LOG_INF(fmt, arg...) HDF_LOGI_WRAPPER("[HDF]-[REGULATOR]:" fmt "\r\n",  ##arg)
25 #define REGULATOR_TEST_PRINT_LOG_ERR(fmt, arg...) HDF_LOGE_WRAPPER("[HDF]-[REGULATOR]:" fmt "\r\n",  ##arg)
26 #endif
27 
28 enum RegulatorTestCmd {
29     REGULATOR_ENABLE_TEST,
30     REGULATOR_DISABLE_TEST,
31     REGULATOR_FORCE_DISABLE_TEST,
32     REGULATOR_SET_VOLTAGE_TEST,
33     REGULATOR_GET_VOLTAGE_TEST,
34     REGULATOR_SET_CURRENT_TEST,
35     REGULATOR_GET_CURRENT_TEST,
36     REGULATOR_GET_STATUS_TEST,
37     REGULATOR_MULTI_THREAD_TEST,
38     REGULATOR_RELIABILITY_TEST,
39 };
40 
41 #define REGULATOR_TEST_STACK_SIZE    (1024 * 100)
42 #define REGULATOR_TEST_WAIT_TIMES    200
43 #define REGULATOR_TEST_WAIT_TIMEOUT  20
44 
45 struct RegulatorTest {
46     struct IDeviceIoService service;
47     struct HdfDeviceObject *device;
48     int32_t (*TestEntry)(struct RegulatorTest *test, int32_t cmd);
49     DevHandle handle;
50     const char *name;
51     uint32_t maxUv;
52     uint32_t minUv;
53     uint32_t maxUa;
54     uint32_t minUa;
55     uint32_t uv;
56     uint32_t ua;
57     uint32_t status;
58     uint8_t mode;
59 };
60 
GetRegulatorTest(void)61 static inline struct RegulatorTest *GetRegulatorTest(void)
62 {
63     return (struct RegulatorTest *)DevSvcManagerClntGetService("REGULATOR_TEST");
64 }
65 
66 #endif /* REGULATOR_TEST_H */
67