payloads/edk2: Disable the CPU Timer Lib unless supported
[coreboot.git] / src / mainboard / google / corsola / regulator.c
blob4f03c181e2167fab11ebfe19698082cfc3e1a5bf
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <assert.h>
4 #include <console/console.h>
5 #include <soc/mt6366.h>
6 #include <soc/regulator.h>
8 #define REGULATOR_NOT_SUPPORT -1
10 static const int regulator_id[] = {
11 [MTK_REGULATOR_VDD1] = REGULATOR_NOT_SUPPORT,
12 [MTK_REGULATOR_VDD2] = REGULATOR_NOT_SUPPORT,
13 [MTK_REGULATOR_VDDQ] = MT6366_VDDQ,
14 [MTK_REGULATOR_VMDDR] = REGULATOR_NOT_SUPPORT,
15 [MTK_REGULATOR_VCORE] = MT6366_VCORE,
16 [MTK_REGULATOR_VCC] = REGULATOR_NOT_SUPPORT,
17 [MTK_REGULATOR_VCCQ] = REGULATOR_NOT_SUPPORT,
18 [MTK_REGULATOR_VDRAM1] = MT6366_VDRAM1,
19 [MTK_REGULATOR_VMCH] = MT6366_VMCH,
20 [MTK_REGULATOR_VMC] = MT6366_VMC,
21 [MTK_REGULATOR_VPROC12] = MT6366_VPROC12,
22 [MTK_REGULATOR_VSRAM_PROC12] = MT6366_VSRAM_PROC12,
23 [MTK_REGULATOR_VRF12] = MT6366_VRF12,
24 [MTK_REGULATOR_VCN33] = MT6366_VCN33,
27 _Static_assert(ARRAY_SIZE(regulator_id) == MTK_REGULATOR_NUM, "regulator_id size error");
29 void mainboard_set_regulator_voltage(enum mtk_regulator regulator, uint32_t voltage_uv)
31 assert(regulator < MTK_REGULATOR_NUM);
33 if (regulator_id[regulator] < 0) {
34 printk(BIOS_ERR, "Invalid regulator ID: %d\n", regulator);
35 return;
37 mt6366_set_voltage(regulator_id[regulator], voltage_uv);
40 uint32_t mainboard_get_regulator_voltage(enum mtk_regulator regulator)
42 assert(regulator < MTK_REGULATOR_NUM);
44 if (regulator_id[regulator] < 0) {
45 printk(BIOS_ERR, "Invalid regulator ID: %d\n", regulator);
46 return 0;
48 return mt6366_get_voltage(regulator_id[regulator]);