summaryrefslogtreecommitdiff
path: root/src/soc/mediatek/mt8195/mt6360.c
diff options
context:
space:
mode:
authorRex-BC Chen <rex-bc.chen@mediatek.corp-partner.google.com>2021-07-16 20:04:26 +0800
committerFelix Held <felix-coreboot@felixheld.de>2021-07-21 15:46:53 +0000
commit86c50e11ced7d7e3ae62b90a4a0dcdae8d740247 (patch)
tree21cc1222df5db7a4cb8dcc166eef2984b9614e61 /src/soc/mediatek/mt8195/mt6360.c
parentcd67657dea6e4c5ca1f068ebf16623924e1b001d (diff)
soc/mediatek/mt8195: modify mt6360 interface
With the new definition of mt6360_regulator_id, merge the MT6360 LDO and PMIC interfaces into one. Signed-off-by: Rex-BC Chen <rex-bc.chen@mediatek.com> Change-Id: I7ccc32cb0a9481d5f55349c152267a44fe09d20a Reviewed-on: https://review.coreboot.org/c/coreboot/+/56435 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Hung-Te Lin <hungte@chromium.org> Reviewed-by: Yu-Ping Wu <yupingso@google.com>
Diffstat (limited to 'src/soc/mediatek/mt8195/mt6360.c')
-rw-r--r--src/soc/mediatek/mt8195/mt6360.c100
1 files changed, 68 insertions, 32 deletions
diff --git a/src/soc/mediatek/mt8195/mt6360.c b/src/soc/mediatek/mt8195/mt6360.c
index 437f995c3d..142e244e74 100644
--- a/src/soc/mediatek/mt8195/mt6360.c
+++ b/src/soc/mediatek/mt8195/mt6360.c
@@ -195,7 +195,7 @@ static bool is_valid_pmic(enum mt6360_regulator_id id)
return true;
}
-void mt6360_ldo_enable(enum mt6360_regulator_id id, uint8_t enable)
+static void mt6360_ldo_enable(enum mt6360_regulator_id id, uint8_t enable)
{
u8 val;
const struct mt6360_data *data;
@@ -216,7 +216,7 @@ void mt6360_ldo_enable(enum mt6360_regulator_id id, uint8_t enable)
mt6360_config_interface(MT6360_INDEX_LDO, data->enable_reg, val, 0xff, 0);
}
-uint8_t mt6360_ldo_is_enabled(enum mt6360_regulator_id id)
+static uint8_t mt6360_ldo_is_enabled(enum mt6360_regulator_id id)
{
u8 val;
const struct mt6360_data *data;
@@ -232,7 +232,7 @@ uint8_t mt6360_ldo_is_enabled(enum mt6360_regulator_id id)
return (val & data->enable_mask) ? 1 : 0;
}
-void mt6360_ldo_set_voltage(enum mt6360_regulator_id id, u32 voltage_uv)
+static void mt6360_ldo_set_voltage(enum mt6360_regulator_id id, u32 voltage_uv)
{
u8 val = 0;
u32 voltage_uv_temp = 0;
@@ -270,7 +270,7 @@ void mt6360_ldo_set_voltage(enum mt6360_regulator_id id, u32 voltage_uv)
mt6360_config_interface(MT6360_INDEX_LDO, data->vsel_reg, val, 0xff, 0);
}
-u32 mt6360_ldo_get_voltage(enum mt6360_regulator_id id)
+static u32 mt6360_ldo_get_voltage(enum mt6360_regulator_id id)
{
u8 val;
u32 voltage_uv;
@@ -297,31 +297,7 @@ u32 mt6360_ldo_get_voltage(enum mt6360_regulator_id id)
return voltage_uv;
}
-void mt6360_init(uint8_t bus)
-{
- u8 delay01, delay02, delay03, delay04;
-
- crc8_populate_msb(crc8_table[MT6360_INDEX_LDO], 0x7);
- crc8_populate_msb(crc8_table[MT6360_INDEX_PMIC], 0x7);
-
- i2c_data[MT6360_INDEX_LDO].bus = bus;
- i2c_data[MT6360_INDEX_PMIC].bus = bus;
-
- mt6360_config_interface(MT6360_INDEX_PMIC, 0x07, 0x04, 0xff, 0);
- mt6360_config_interface(MT6360_INDEX_PMIC, 0x08, 0x00, 0xff, 0);
- mt6360_config_interface(MT6360_INDEX_PMIC, 0x09, 0x02, 0xff, 0);
- mt6360_config_interface(MT6360_INDEX_PMIC, 0x0a, 0x00, 0xff, 0);
-
- mt6360_read_interface(MT6360_INDEX_PMIC, 0x07, &delay01, 0xff, 0);
- mt6360_read_interface(MT6360_INDEX_PMIC, 0x08, &delay02, 0xff, 0);
- mt6360_read_interface(MT6360_INDEX_PMIC, 0x09, &delay03, 0xff, 0);
- mt6360_read_interface(MT6360_INDEX_PMIC, 0x0a, &delay04, 0xff, 0);
- printk(BIOS_DEBUG,
- "%s: power off sequence delay: %#x, %#x, %#x, %#x\n",
- __func__, delay01, delay02, delay03, delay04);
-}
-
-void mt6360_pmic_enable(enum mt6360_regulator_id id, uint8_t enable)
+static void mt6360_pmic_enable(enum mt6360_regulator_id id, uint8_t enable)
{
u8 val;
const struct mt6360_data *data;
@@ -342,7 +318,7 @@ void mt6360_pmic_enable(enum mt6360_regulator_id id, uint8_t enable)
mt6360_config_interface(MT6360_INDEX_PMIC, data->enable_reg, val, 0xff, 0);
}
-uint8_t mt6360_pmic_is_enabled(enum mt6360_regulator_id id)
+static uint8_t mt6360_pmic_is_enabled(enum mt6360_regulator_id id)
{
u8 val;
const struct mt6360_data *data;
@@ -358,7 +334,7 @@ uint8_t mt6360_pmic_is_enabled(enum mt6360_regulator_id id)
return (val & data->enable_mask) ? 1 : 0;
}
-void mt6360_pmic_set_voltage(enum mt6360_regulator_id id, u32 voltage_uv)
+static void mt6360_pmic_set_voltage(enum mt6360_regulator_id id, u32 voltage_uv)
{
u8 val = 0;
@@ -379,7 +355,7 @@ void mt6360_pmic_set_voltage(enum mt6360_regulator_id id, u32 voltage_uv)
mt6360_config_interface(MT6360_INDEX_PMIC, data->vsel_reg, val, 0xff, 0);
}
-u32 mt6360_pmic_get_voltage(enum mt6360_regulator_id id)
+static u32 mt6360_pmic_get_voltage(enum mt6360_regulator_id id)
{
u8 val;
u32 voltage_uv = 0;
@@ -403,3 +379,63 @@ u32 mt6360_pmic_get_voltage(enum mt6360_regulator_id id)
return voltage_uv;
}
+
+void mt6360_init(uint8_t bus)
+{
+ u8 delay01, delay02, delay03, delay04;
+
+ crc8_populate_msb(crc8_table[MT6360_INDEX_LDO], 0x7);
+ crc8_populate_msb(crc8_table[MT6360_INDEX_PMIC], 0x7);
+
+ i2c_data[MT6360_INDEX_LDO].bus = bus;
+ i2c_data[MT6360_INDEX_PMIC].bus = bus;
+
+ mt6360_config_interface(MT6360_INDEX_PMIC, 0x07, 0x04, 0xff, 0);
+ mt6360_config_interface(MT6360_INDEX_PMIC, 0x08, 0x00, 0xff, 0);
+ mt6360_config_interface(MT6360_INDEX_PMIC, 0x09, 0x02, 0xff, 0);
+ mt6360_config_interface(MT6360_INDEX_PMIC, 0x0a, 0x00, 0xff, 0);
+
+ mt6360_read_interface(MT6360_INDEX_PMIC, 0x07, &delay01, 0xff, 0);
+ mt6360_read_interface(MT6360_INDEX_PMIC, 0x08, &delay02, 0xff, 0);
+ mt6360_read_interface(MT6360_INDEX_PMIC, 0x09, &delay03, 0xff, 0);
+ mt6360_read_interface(MT6360_INDEX_PMIC, 0x0a, &delay04, 0xff, 0);
+ printk(BIOS_DEBUG,
+ "%s: power off sequence delay: %#x, %#x, %#x, %#x\n",
+ __func__, delay01, delay02, delay03, delay04);
+}
+
+void mt6360_enable(enum mt6360_regulator_id id, uint8_t enable)
+{
+ if (is_valid_ldo(id))
+ mt6360_ldo_enable(id, enable);
+ else if (is_valid_pmic(id))
+ mt6360_pmic_enable(id, enable);
+}
+
+uint8_t mt6360_is_enabled(enum mt6360_regulator_id id)
+{
+ if (is_valid_ldo(id))
+ return mt6360_ldo_is_enabled(id);
+ else if (is_valid_pmic(id))
+ return mt6360_pmic_is_enabled(id);
+ else
+ return 0;
+}
+
+void mt6360_set_voltage(enum mt6360_regulator_id id, u32 voltage_uv)
+{
+ if (is_valid_ldo(id))
+ mt6360_ldo_set_voltage(id, voltage_uv);
+ else if (is_valid_pmic(id))
+ mt6360_pmic_set_voltage(id, voltage_uv);
+}
+
+u32 mt6360_get_voltage(enum mt6360_regulator_id id)
+{
+ if (is_valid_ldo(id))
+ return mt6360_ldo_get_voltage(id);
+ else if (is_valid_pmic(id))
+ return mt6360_pmic_get_voltage(id);
+ else
+ return 0;
+}