soc/amd/common/psp/psp_def.h: increase P2C_BUFFER_MAXSIZE
[coreboot2.git] / src / mainboard / google / corsola / regulator.c
blob094e84264840ab49dc4318887e6f9700233535b4
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <console/console.h>
4 #include <soc/mt6366.h>
5 #include <soc/regulator.h>
7 #define MTK_REGULATOR_INVALID -1
9 static int get_mt6366_regulator_id(enum mtk_regulator regulator)
11 switch (regulator) {
12 case MTK_REGULATOR_VDDQ:
13 return MT6366_VDDQ;
14 case MTK_REGULATOR_VCORE:
15 return MT6366_VCORE;
16 case MTK_REGULATOR_VDRAM1:
17 return MT6366_VDRAM1;
18 case MTK_REGULATOR_VMCH:
19 return MT6366_VMCH;
20 case MTK_REGULATOR_VMC:
21 return MT6366_VMC;
22 case MTK_REGULATOR_VPROC12:
23 return MT6366_VPROC12;
24 case MTK_REGULATOR_VSRAM_PROC12:
25 return MT6366_VSRAM_PROC12;
26 case MTK_REGULATOR_VRF12:
27 return MT6366_VRF12;
28 case MTK_REGULATOR_VCN33:
29 return MT6366_VCN33;
30 case MTK_REGULATOR_VIO18:
31 return MT6366_VIO18;
32 default:
33 return MTK_REGULATOR_INVALID;
37 void mainboard_set_regulator_voltage(enum mtk_regulator regulator, uint32_t voltage_uv)
39 int id;
41 id = get_mt6366_regulator_id(regulator);
42 if (id < 0) {
43 printk(BIOS_ERR, "Invalid regulator ID: %d\n", regulator);
44 return;
46 mt6366_set_voltage(id, voltage_uv);
49 uint32_t mainboard_get_regulator_voltage(enum mtk_regulator regulator)
51 int id;
53 id = get_mt6366_regulator_id(regulator);
54 if (id < 0) {
55 printk(BIOS_ERR, "Invalid regulator ID: %d\n", regulator);
56 return 0;
58 return mt6366_get_voltage(id);