Merge tag 'dt-5.15' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc
[linux-2.6-microblaze.git] / drivers / acpi / pmic / intel_pmic_xpower.c
index a091d5a..cbe08e6 100644 (file)
@@ -178,15 +178,17 @@ static int intel_xpower_pmic_update_power(struct regmap *regmap, int reg,
 {
        int data, ret;
 
-       /* GPIO1 LDO regulator needs special handling */
-       if (reg == XPOWER_GPI1_CTRL)
-               return regmap_update_bits(regmap, reg, GPI1_LDO_MASK,
-                                         on ? GPI1_LDO_ON : GPI1_LDO_OFF);
-
        ret = iosf_mbi_block_punit_i2c_access();
        if (ret)
                return ret;
 
+       /* GPIO1 LDO regulator needs special handling */
+       if (reg == XPOWER_GPI1_CTRL) {
+               ret = regmap_update_bits(regmap, reg, GPI1_LDO_MASK,
+                                        on ? GPI1_LDO_ON : GPI1_LDO_OFF);
+               goto out;
+       }
+
        if (regmap_read(regmap, reg, &data)) {
                ret = -EIO;
                goto out;
@@ -234,6 +236,11 @@ static int intel_xpower_pmic_get_raw_temp(struct regmap *regmap, int reg)
                return ret;
 
        if (adc_ts_pin_ctrl & AXP288_ADC_TS_CURRENT_ON_OFF_MASK) {
+               /*
+                * AXP288_ADC_TS_PIN_CTRL reads are cached by the regmap, so
+                * this does to a single I2C-transfer, and thus there is no
+                * need to explicitly call iosf_mbi_block_punit_i2c_access().
+                */
                ret = regmap_update_bits(regmap, AXP288_ADC_TS_PIN_CTRL,
                                         AXP288_ADC_TS_CURRENT_ON_OFF_MASK,
                                         AXP288_ADC_TS_CURRENT_ON_ONDEMAND);
@@ -244,6 +251,10 @@ static int intel_xpower_pmic_get_raw_temp(struct regmap *regmap, int reg)
                usleep_range(6000, 10000);
        }
 
+       ret = iosf_mbi_block_punit_i2c_access();
+       if (ret)
+               return ret;
+
        ret = regmap_bulk_read(regmap, AXP288_GP_ADC_H, buf, 2);
        if (ret == 0)
                ret = (buf[0] << 4) + ((buf[1] >> 4) & 0x0f);
@@ -254,6 +265,31 @@ static int intel_xpower_pmic_get_raw_temp(struct regmap *regmap, int reg)
                                   AXP288_ADC_TS_CURRENT_ON);
        }
 
+       iosf_mbi_unblock_punit_i2c_access();
+
+       return ret;
+}
+
+static int intel_xpower_exec_mipi_pmic_seq_element(struct regmap *regmap,
+                                                  u16 i2c_address, u32 reg_address,
+                                                  u32 value, u32 mask)
+{
+       int ret;
+
+       if (i2c_address != 0x34) {
+               pr_err("%s: Unexpected i2c-addr: 0x%02x (reg-addr 0x%x value 0x%x mask 0x%x)\n",
+                      __func__, i2c_address, reg_address, value, mask);
+               return -ENXIO;
+       }
+
+       ret = iosf_mbi_block_punit_i2c_access();
+       if (ret)
+               return ret;
+
+       ret = regmap_update_bits(regmap, reg_address, mask, value);
+
+       iosf_mbi_unblock_punit_i2c_access();
+
        return ret;
 }
 
@@ -261,6 +297,7 @@ static struct intel_pmic_opregion_data intel_xpower_pmic_opregion_data = {
        .get_power = intel_xpower_pmic_get_power,
        .update_power = intel_xpower_pmic_update_power,
        .get_raw_temp = intel_xpower_pmic_get_raw_temp,
+       .exec_mipi_pmic_seq_element = intel_xpower_exec_mipi_pmic_seq_element,
        .power_table = power_table,
        .power_table_count = ARRAY_SIZE(power_table),
        .thermal_table = thermal_table,