coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
regulator.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <assert.h>
4 #include <console/console.h>
5 #include <soc/mt6366.h>
6 #include <soc/regulator.h>
7 
8 #define REGULATOR_NOT_SUPPORT -1
9 
10 static const int regulator_id[] = {
25 };
26 
27 _Static_assert(ARRAY_SIZE(regulator_id) == MTK_REGULATOR_NUM, "regulator_id size error");
28 
30  uint32_t voltage_uv)
31 {
32  assert(regulator < MTK_REGULATOR_NUM);
33 
34  if (regulator_id[regulator] < 0) {
35  printk(BIOS_ERR, "Invalid regulator ID: %d\n", regulator);
36  return;
37  }
38  mt6366_set_voltage(regulator_id[regulator], voltage_uv);
39 }
40 
42 {
43  assert(regulator < MTK_REGULATOR_NUM);
44 
45  if (regulator_id[regulator] < 0) {
46  printk(BIOS_ERR, "Invalid regulator ID: %d\n", regulator);
47  return 0;
48  }
49  return mt6366_get_voltage(regulator_id[regulator]);
50 }
#define assert(statement)
Definition: assert.h:74
void mainboard_set_regulator_vol(enum mtk_regulator regulator, uint32_t voltage_uv)
Definition: regulator.c:41
uint32_t mainboard_get_regulator_vol(enum mtk_regulator regulator)
Definition: regulator.c:71
#define ARRAY_SIZE(a)
Definition: helpers.h:12
#define printk(level,...)
Definition: stdlib.h:16
static const int regulator_id[]
Definition: regulator.c:10
_Static_assert(ARRAY_SIZE(regulator_id)==MTK_REGULATOR_NUM, "regulator_id size error")
#define REGULATOR_NOT_SUPPORT
Definition: regulator.c:8
#define BIOS_ERR
BIOS_ERR - System in incomplete state.
Definition: loglevel.h:72
u32 mt6366_get_voltage(enum mt6366_regulator_id id)
Definition: mt6366.c:914
@ MT6366_VPROC12
Definition: mt6366.h:66
@ MT6366_VCORE
Definition: mt6366.h:61
@ MT6366_VDDQ
Definition: mt6366.h:63
@ MT6366_VMCH
Definition: mt6366.h:64
@ MT6366_VRF12
Definition: mt6366.h:68
@ MT6366_VMC
Definition: mt6366.h:65
@ MT6366_VSRAM_PROC12
Definition: mt6366.h:67
@ MT6366_VDRAM1
Definition: mt6366.h:62
@ MT6366_VCN33
Definition: mt6366.h:69
void mt6366_set_voltage(enum mt6366_regulator_id id, u32 vcore_uv)
Definition: mt6366.c:877
mtk_regulator
Definition: regulator.h:8
@ MTK_REGULATOR_VDDQ
Definition: regulator.h:11
@ MTK_REGULATOR_VRF12
Definition: regulator.h:21
@ MTK_REGULATOR_VCCQ
Definition: regulator.h:15
@ MTK_REGULATOR_VCC
Definition: regulator.h:14
@ MTK_REGULATOR_VMC
Definition: regulator.h:18
@ MTK_REGULATOR_VDD1
Definition: regulator.h:9
@ MTK_REGULATOR_VCN33
Definition: regulator.h:22
@ MTK_REGULATOR_VCORE
Definition: regulator.h:13
@ MTK_REGULATOR_VDD2
Definition: regulator.h:10
@ MTK_REGULATOR_VPROC12
Definition: regulator.h:19
@ MTK_REGULATOR_VMCH
Definition: regulator.h:17
@ MTK_REGULATOR_NUM
Definition: regulator.h:23
@ MTK_REGULATOR_VDRAM1
Definition: regulator.h:16
@ MTK_REGULATOR_VSRAM_PROC12
Definition: regulator.h:20
@ MTK_REGULATOR_VMDDR
Definition: regulator.h:12
unsigned int uint32_t
Definition: stdint.h:14