Intel® Quark™ Microcontroller Software Interface 1.4.0 Intel® Quark™ Microcontroller BSP

- Main Page
- Modules
- Data Structures
- Files

- File List

vreg.c
1 /*
2 * {% copyright %}
3 */
4
5 #include "vreg.h"
6
7 typedef enum { AON_VR = 0, PLAT3P3_VR, PLAT1P8_VR, HOST_VR, VREG_NUM } vreg_t;
8
9 QM_RW uint32_t *vreg[VREG_NUM] = {
10 &QM_SCSS_PMU->aon_vr, &QM_SCSS_PMU->plat3p3_vr, &QM_SCSS_PMU->plat1p8_vr,
11 &QM_SCSS_PMU->host_vr};
12
13 static int vreg_set_mode(const vreg_t id, const vreg_mode_t mode)
14 {
15 QM_CHECK(mode < VREG_MODE_NUM, -EINVAL);
16 uint32_t vr;
17
18 vr = *vreg[id];
19
20 switch (mode) {
21 case VREG_MODE_SWITCHING:
22 vr |= QM_SCSS_VR_EN;
23 vr &= ~QM_SCSS_VR_VREG_SEL;
24 break;
25 case VREG_MODE_LINEAR:
26 vr |= QM_SCSS_VR_EN;
27 vr |= QM_SCSS_VR_VREG_SEL;
28 break;
29 case VREG_MODE_SHUTDOWN:
30 vr &= ~QM_SCSS_VR_EN;
31 break;
32 default:
33 break;
34 }
35
36 *vreg[id] = vr;
37
38 while ((mode == VREG_MODE_SWITCHING) &&
39 (*vreg[id] & QM_SCSS_VR_ROK) == 0) {
40 }
41
42 return 0;
43 }
44
45 int vreg_aon_set_mode(const vreg_mode_t mode)
46 {
47 QM_CHECK(mode < VREG_MODE_NUM, -EINVAL);
48 QM_CHECK(mode != VREG_MODE_SWITCHING, -EINVAL);
49
50 return vreg_set_mode(AON_VR, mode);
51 }
52
53 int vreg_plat3p3_set_mode(const vreg_mode_t mode)
54 {
55 QM_CHECK(mode < VREG_MODE_NUM, -EINVAL);
56 return vreg_set_mode(PLAT3P3_VR, mode);
57 }
58
59 int vreg_plat1p8_set_mode(const vreg_mode_t mode)
60 {
61 QM_CHECK(mode < VREG_MODE_NUM, -EINVAL);
62 return vreg_set_mode(PLAT1P8_VR, mode);
63 }
64
65 int vreg_host_set_mode(const vreg_mode_t mode)
66 {
67 QM_CHECK(mode < VREG_MODE_NUM, -EINVAL);
68 return vreg_set_mode(HOST_VR, mode);
69 }
vreg_plat3p3_set_mode
int vreg_plat3p3_set_mode(const vreg_mode_t mode)
Set Platform 3P3 Voltage Regulator mode.
Definition: vreg.c:53
vreg_host_set_mode
int vreg_host_set_mode(const vreg_mode_t mode)
Set Host Voltage Regulator mode.
Definition: vreg.c:65
vreg_plat1p8_set_mode
int vreg_plat1p8_set_mode(const vreg_mode_t mode)
Set Platform 1P8 Voltage Regulator mode.
Definition: vreg.c:59
vreg_aon_set_mode
int vreg_aon_set_mode(const vreg_mode_t mode)
Set AON Voltage Regulator mode.
Definition: vreg.c:45