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
)
12 case MTK_REGULATOR_VCORE
:
14 case MTK_REGULATOR_VPROC11
:
16 case MTK_REGULATOR_VSRAM_PROC11
:
17 return MT6359P_SRAM_PROC1
;
18 case MTK_REGULATOR_VMCH
:
20 case MTK_REGULATOR_VMC
:
22 case MTK_REGULATOR_VDD18
:
25 return MTK_REGULATOR_INVALID
;
29 void mainboard_set_regulator_voltage(enum mtk_regulator regulator
, uint32_t voltage_uv
)
33 id
= get_mt6359p_regulator_id(regulator
);
35 printk(BIOS_ERR
, "Invalid regulator ID: %d\n", regulator
);
39 if (id
== MT6359P_SIM1
)
40 mt6359p_set_vsim1_voltage(voltage_uv
);
42 mt6359p_buck_set_voltage(id
, voltage_uv
);
45 uint32_t mainboard_get_regulator_voltage(enum mtk_regulator regulator
)
49 id
= get_mt6359p_regulator_id(regulator
);
51 printk(BIOS_ERR
, "Invalid regulator ID: %d\n", regulator
);
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
)
65 id
= get_mt6359p_regulator_id(regulator
);
67 printk(BIOS_ERR
, "Invalid regulator ID: %d\n", regulator
);
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
);
78 printk(BIOS_INFO
, "No need to enable regulator ID: %d\n", regulator
);