XWOS API  4.0
XWOS C/C++ API参考手册
载入中...
搜索中...
未找到
power.c
浏览该文件的文档.
1
21#include <xwcd/ds/standard.h>
22#include <string.h>
23#include <xwcd/ds/soc/power.h>
24
27{
28 const struct xwds_soc_driver * drv;
29 xwer_t rc;
30
31 XWDS_VALIDATE(soc, "nullptr", -EFAULT);
32 XWDS_VALIDATE((id < soc->pwr.num), "out-of-range", -ERANGE);
33
34 rc = xwds_soc_grab(soc);
35 if (rc < 0) {
36 goto err_soc_grab;
37 }
38
39 drv = xwds_cast(const struct xwds_soc_driver *, soc->dev.drv);
40 if ((drv) && (drv->pwr_req)) {
41 rc = drv->pwr_req(soc, id);
42 } else {
43 rc = -ENOSYS;
44 }
45 if (rc < 0) {
46 goto err_drv_pwr_req;
47 }
48 return XWOK;
49
50err_drv_pwr_req:
51 xwds_soc_put(soc);
52err_soc_grab:
53 return rc;
54}
55
58{
59 const struct xwds_soc_driver * drv;
60 xwer_t rc;
61
62 XWDS_VALIDATE(soc, "nullptr", -EFAULT);
63 XWDS_VALIDATE((id < soc->pwr.num), "out-of-range", -ERANGE);
64
65 drv = xwds_cast(const struct xwds_soc_driver *, soc->dev.drv);
66 if ((drv) && (drv->pwr_rls)) {
67 rc = drv->pwr_rls(soc, id);
68 } else {
69 rc = -ENOSYS;
70 }
71 if (rc < 0) {
72 goto err_drv_pwr_rls;
73 }
74
75 xwds_soc_put(soc);
76 return XWOK;
77
78err_drv_pwr_rls:
79 return rc;
80}
81
84 xwu32_t * buf, xwsz_t * num)
85{
86 const struct xwds_soc_driver * drv;
87 xwer_t rc;
88
89 XWDS_VALIDATE(soc, "nullptr", -EFAULT);
90 XWDS_VALIDATE((id < soc->pwr.num), "out-of-range", -ERANGE);
91 XWDS_VALIDATE(buf, "nullptr", -EFAULT);
92 XWDS_VALIDATE(num, "nullptr", -EFAULT);
93
94 rc = xwds_soc_grab(soc);
95 if (rc < 0) {
96 goto err_soc_grab;
97 }
98
99 drv = xwds_cast(const struct xwds_soc_driver *, soc->dev.drv);
100 if ((drv) && (drv->pwr_getvltg)) {
101 rc = drv->pwr_getvltg(soc, id, buf, num);
102 } else {
103 rc = -ENOSYS;
104 }
105 if (rc < 0) {
106 goto err_drv_getvltg;
107 }
108
109 xwds_soc_put(soc);
110 return XWOK;
111
112err_drv_getvltg:
113 xwds_soc_put(soc);
114err_soc_grab:
115 return rc;
116}
xwer_t xwds_pwr_req(struct xwds_soc *soc, xwid_t id)
XWDS API:申请电源
Definition power.c:26
xwer_t xwds_soc_grab(struct xwds_soc *soc)
XWDS API:增加对象的引用计数
Definition chip.c:71
xwer_t xwds_soc_put(struct xwds_soc *soc)
XWDS API:减少对象的引用计数
Definition chip.c:77
#define xwds_cast(type, dev)
Definition standard.h:40
#define __xwds_api
Definition standard.h:33
#define XWDS_VALIDATE(exp, errstr,...)
Definition standard.h:51
#define EFAULT
Bad address
Definition errno.h:44
#define ENOSYS
Function not implemented
Definition errno.h:110
#define XWOK
No error
Definition errno.h:182
#define ERANGE
Result too large
Definition errno.h:64
signed long xwer_t
Definition type.h:554
unsigned long xwid_t
Definition type.h:481
unsigned long xwsz_t
Definition type.h:339
uint32_t xwu32_t
Definition type.h:266
xwer_t xwds_pwr_rls(struct xwds_soc *soc, xwid_t id)
XWDS API:释放电源
Definition power.c:57
xwer_t xwds_pwr_getvltg(struct xwds_soc *soc, xwid_t id, xwu32_t *buf, xwsz_t *num)
XWDS API:获取电源电压
Definition power.c:83
玄武设备栈:SOC:电源
const struct xwds_driver * drv
Definition device.h:133
BSP中需要提供的SOC设备驱动函数表
Definition chip.h:51
SOC设备
Definition chip.h:161
struct xwds_device dev
Definition chip.h:162
玄武设备栈:顶级头文件