| 1 |
|
| 2 |
|
| 3 |
#include <console/console.h> |
| 4 |
#include <soc/mt6366.h> |
| 5 |
#include <soc/regulator.h> |
| 6 |
|
| 7 |
#define MTK_REGULATOR_INVALID -1 |
| 8 |
|
| 9 |
static int get_mt6366_regulator_id(enum mtk_regulator regulator) |
| 10 |
{ |
| 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; |
| 34 |
} |
| 35 |
} |
| 36 |
|
| 37 |
void mainboard_set_regulator_voltage(enum mtk_regulator regulator, uint32_t voltage_uv) |
| 38 |
{ |
| 39 |
int id; |
| 40 |
|
| 41 |
id = get_mt6366_regulator_id(regulator); |
| 42 |
if (id < 0) { |
| 43 |
printk(BIOS_ERR, "Invalid regulator ID: %d\n", regulator); |
| 44 |
return; |
| 45 |
} |
| 46 |
mt6366_set_voltage(id, voltage_uv); |
| 47 |
} |
| 48 |
|
| 49 |
uint32_t mainboard_get_regulator_voltage(enum mtk_regulator regulator) |
| 50 |
{ |
| 51 |
int id; |
| 52 |
|
| 53 |
id = get_mt6366_regulator_id(regulator); |
| 54 |
if (id < 0) { |
| 55 |
printk(BIOS_ERR, "Invalid regulator ID: %d\n", regulator); |
| 56 |
return 0; |
| 57 |
} |
| 58 |
return mt6366_get_voltage(id); |
| 59 |
} |