• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef PIN_CORE_H
9 #define PIN_CORE_H
10 
11 #include "hdf_base.h"
12 #include "hdf_device_desc.h"
13 #include "hdf_dlist.h"
14 #include "pin_if.h"
15 #include "osal_spinlock.h"
16 #include "osal_atomic.h"
17 
18 #ifdef __cplusplus
19 #if __cplusplus
20 extern "C" {
21 #endif
22 #endif /* __cplusplus */
23 
24 struct PinCntlr;
25 struct PinCntlrMethod;
26 struct PinDesc;
27 
28 struct PinDesc {
29     const char *pinName;
30     void *priv;
31 };
32 
33 struct PinCntlr {
34     struct IDeviceIoService service;
35     struct HdfDeviceObject *device;
36     struct PinCntlrMethod *method;
37     struct DListHead node;
38     OsalSpinlock spin;
39     uint16_t number;
40     uint16_t pinCount;
41     struct PinDesc *pins;
42     void *priv;
43 };
44 
45 struct PinCntlrMethod {
46     int32_t (*SetPinPull)(struct PinCntlr *cntlr, uint32_t index, enum PinPullType pullType);
47     int32_t (*GetPinPull)(struct PinCntlr *cntlr, uint32_t index, enum PinPullType *pullType);
48     int32_t (*SetPinStrength)(struct PinCntlr *cntlr, uint32_t index, uint32_t strength);
49     int32_t (*GetPinStrength)(struct PinCntlr *cntlr, uint32_t index, uint32_t *strength);
50     int32_t (*SetPinFunc)(struct PinCntlr *cntlr, uint32_t index, const char *funcName);
51     int32_t (*GetPinFunc)(struct PinCntlr *cntlr, uint32_t index, const char **funcName);
52 };
53 
54 int32_t PinCntlrAdd(struct PinCntlr *cntlr);
55 
56 void PinCntlrRemove(struct PinCntlr *cntlr);
57 
58 struct PinDesc *PinCntlrGetPinDescByName(const char *pinName);
59 
60 struct PinCntlr *PinCntlrGetByNumber(uint16_t number);
61 
62 struct PinCntlr *PinCntlrGetByPin(const struct PinDesc *desc);
63 
64 void PinCntlrPutPin(const struct PinDesc *desc);
65 
66 int32_t PinCntlrSetPinPull(struct PinCntlr *cntlr, struct PinDesc *desc, enum PinPullType pullType);
67 
68 int32_t PinCntlrGetPinPull(struct PinCntlr *cntlr, struct PinDesc *desc, enum PinPullType *pullType);
69 
70 int32_t PinCntlrSetPinStrength(struct PinCntlr *cntlr, struct PinDesc *desc, uint32_t strength);
71 
72 int32_t PinCntlrGetPinStrength(struct PinCntlr *cntlr, struct PinDesc *desc, uint32_t *strength);
73 
74 int32_t PinCntlrSetPinFunc(struct PinCntlr *cntlr, struct PinDesc *desc, const char *funcName);
75 
76 int32_t PinCntlrGetPinFunc(struct PinCntlr *cntlr, struct PinDesc *desc, const char **funcName);
77 
78 #ifdef __cplusplus
79 #if __cplusplus
80 }
81 #endif
82 #endif /* __cplusplus */
83 
84 #endif /* PIN_CORE_H */
85