mb/google/brya/var/omnigul: Modify NVMe and UFS Storage support
[coreboot.git] / src / mainboard / google / geralt / regulator.c
blobf3b440751f760ecf3f7ffa70edd454aefa170b4b
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <console/console.h>
4 #include <soc/mt6359p.h>
5 #include <soc/regulator.h>
7 #define MTK_REGULATOR_INVALID -1
9 static int get_mt6359p_regulator_id(enum mtk_regulator regulator)
11 switch (regulator) {
12 case MTK_REGULATOR_VCORE:
13 return MT6359P_GPU11;
14 case MTK_REGULATOR_VPROC11:
15 return MT6359P_CORE;
16 case MTK_REGULATOR_VSRAM_PROC11:
17 return MT6359P_SRAM_PROC1;
18 case MTK_REGULATOR_VMCH:
19 return MT6359P_PA;
20 case MTK_REGULATOR_VMC:
21 return MT6359P_SIM1;
22 case MTK_REGULATOR_VDD18:
23 return MT6359P_VM18;
24 default:
25 return MTK_REGULATOR_INVALID;
29 void mainboard_set_regulator_voltage(enum mtk_regulator regulator, uint32_t voltage_uv)
31 int id;
33 id = get_mt6359p_regulator_id(regulator);
34 if (id < 0) {
35 printk(BIOS_ERR, "Invalid regulator ID: %d\n", regulator);
36 return;
39 if (id == MT6359P_SIM1)
40 mt6359p_set_vsim1_voltage(voltage_uv);
41 else
42 mt6359p_buck_set_voltage(id, voltage_uv);
45 uint32_t mainboard_get_regulator_voltage(enum mtk_regulator regulator)
47 int id;
49 id = get_mt6359p_regulator_id(regulator);
50 if (id < 0) {
51 printk(BIOS_ERR, "Invalid regulator ID: %d\n", regulator);
52 return 0;
55 if (id == MT6359P_SIM1)
56 return mt6359p_get_vsim1_voltage();
58 return mt6359p_buck_get_voltage(id);
61 int mainboard_enable_regulator(enum mtk_regulator regulator, bool enable)
63 int id;
65 id = get_mt6359p_regulator_id(regulator);
66 if (id < 0) {
67 printk(BIOS_ERR, "Invalid regulator ID: %d\n", regulator);
68 return -1;
71 if (id == MT6359P_SIM1)
72 mt6359p_enable_vsim1(enable);
73 else if (id == MT6359P_PA)
74 mt6359p_enable_vpa(enable);
75 else if (id == MT6359P_VM18)
76 mt6359p_enable_vm18(enable);
77 else
78 printk(BIOS_INFO, "No need to enable regulator ID: %d\n", regulator);
80 return 0;