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
)
12 case MTK_REGULATOR_VDDQ
:
14 case MTK_REGULATOR_VCORE
:
16 case MTK_REGULATOR_VDRAM1
:
18 case MTK_REGULATOR_VMCH
:
20 case MTK_REGULATOR_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
:
28 case MTK_REGULATOR_VCN33
:
30 case MTK_REGULATOR_VIO18
:
33 return MTK_REGULATOR_INVALID
;
37 void mainboard_set_regulator_voltage(enum mtk_regulator regulator
, uint32_t voltage_uv
)
41 id
= get_mt6366_regulator_id(regulator
);
43 printk(BIOS_ERR
, "Invalid regulator ID: %d\n", regulator
);
46 mt6366_set_voltage(id
, voltage_uv
);
49 uint32_t mainboard_get_regulator_voltage(enum mtk_regulator regulator
)
53 id
= get_mt6366_regulator_id(regulator
);
55 printk(BIOS_ERR
, "Invalid regulator ID: %d\n", regulator
);
58 return mt6366_get_voltage(id
);