Skip to content

Commit fd080a0

Browse files
jwrdegoederafaeljw
authored andcommitted
ACPI / PMIC: XPower: optimize MIPI PMIQ sequence I2C-bus accesses
The I2C-bus to the XPower AXP288 is shared between the Linux kernel and the SoCs P-Unit. The P-Unit has a semaphore which the kernel must "lock" before it may use the bus and while the kernel holds the semaphore the CPU and GPU power-states must not be changed otherwise the system will freeze. This is a complex process, which is quite expensive. This is all done by iosf_mbi_block_punit_i2c_access(). To ensure that no unguarded I2C-bus accesses happen, iosf_mbi_block_punit_i2c_access() gets called by the I2C-bus-driver for every I2C transfer. Because this is so expensive it is allowed to call iosf_mbi_block_punit_i2c_access() in a nested fashion, so that higher-level code which does multiple I2C-transfers can call it once for a group of transfers, turning the calls done by the I2C-bus-driver into no-ops. The default exec_mipi_pmic_seq_element implementation from drivers/acpi/pmic/intel_pmic.c does a regmap_update_bits() call and the involved registers are typically marked as volatile in the regmap, so this leads to 2 I2C-bus accesses. Add a XPower AXP288 specific implementation of exec_mipi_pmic_seq_element which calls iosf_mbi_block_punit_i2c_access() calls before the regmap_update_bits() call to avoid having to do the whole expensive acquire P-Unit semaphore dance twice. Reviewed-by: Andy Shevchenko <[email protected]> Signed-off-by: Hans de Goede <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent e38ba40 commit fd080a0

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

drivers/acpi/pmic/intel_pmic_xpower.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,10 +270,34 @@ static int intel_xpower_pmic_get_raw_temp(struct regmap *regmap, int reg)
270270
return ret;
271271
}
272272

273+
static int intel_xpower_exec_mipi_pmic_seq_element(struct regmap *regmap,
274+
u16 i2c_address, u32 reg_address,
275+
u32 value, u32 mask)
276+
{
277+
int ret;
278+
279+
if (i2c_address != 0x34) {
280+
pr_err("%s: Unexpected i2c-addr: 0x%02x (reg-addr 0x%x value 0x%x mask 0x%x)\n",
281+
__func__, i2c_address, reg_address, value, mask);
282+
return -ENXIO;
283+
}
284+
285+
ret = iosf_mbi_block_punit_i2c_access();
286+
if (ret)
287+
return ret;
288+
289+
ret = regmap_update_bits(regmap, reg_address, mask, value);
290+
291+
iosf_mbi_unblock_punit_i2c_access();
292+
293+
return ret;
294+
}
295+
273296
static struct intel_pmic_opregion_data intel_xpower_pmic_opregion_data = {
274297
.get_power = intel_xpower_pmic_get_power,
275298
.update_power = intel_xpower_pmic_update_power,
276299
.get_raw_temp = intel_xpower_pmic_get_raw_temp,
300+
.exec_mipi_pmic_seq_element = intel_xpower_exec_mipi_pmic_seq_element,
277301
.power_table = power_table,
278302
.power_table_count = ARRAY_SIZE(power_table),
279303
.thermal_table = thermal_table,

0 commit comments

Comments
 (0)