staticint intel_xpower_pmic_update_power(struct regmap *regmap, int reg, int bit, bool on)
{ int data, ret;
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;
}
if (on)
data |= BIT(bit); else
data &= ~BIT(bit);
if (regmap_write(regmap, reg, data))
ret = -EIO;
out:
iosf_mbi_unblock_punit_i2c_access();
return ret;
}
/** * intel_xpower_pmic_get_raw_temp(): Get raw temperature reading from the PMIC * * @regmap: regmap of the PMIC device * @reg: register to get the reading * * Return a positive value on success, errno on failure.
*/ staticint intel_xpower_pmic_get_raw_temp(struct regmap *regmap, int reg)
{ int ret, adc_ts_pin_ctrl;
u8 buf[2];
/* * The current-source used for the battery temp-sensor (TS) is shared * with the GPADC. For proper fuel-gauge and charger operation the TS * current-source needs to be permanently on. But to read the GPADC we * need to temporary switch the TS current-source to ondemand, so that * the GPADC can use it, otherwise we will always read an all 0 value. * * Note that the switching from on to on-ondemand is not necessary * when the TS current-source is off (this happens on devices which * do not use the TS-pin).
*/
ret = regmap_read(regmap, AXP288_ADC_TS_PIN_CTRL, &adc_ts_pin_ctrl); if (ret) 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); if (ret) return ret;
/* Wait a bit after switching the current-source */
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, sizeof(buf)); if (ret == 0)
ret = (buf[0] << 4) + ((buf[1] >> 4) & 0x0f);
if (adc_ts_pin_ctrl & AXP288_ADC_TS_CURRENT_ON_OFF_MASK) {
regmap_update_bits(regmap, AXP288_ADC_TS_PIN_CTRL,
AXP288_ADC_TS_CURRENT_ON_OFF_MASK,
AXP288_ADC_TS_CURRENT_ON);
}
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;
}
staticint intel_xpower_lpat_raw_to_temp(struct acpi_lpat_conversion_table *lpat_table, int raw)
{ struct acpi_lpat first = lpat_table->lpat[0]; struct acpi_lpat last = lpat_table->lpat[lpat_table->lpat_count - 1];
/* * Some LPAT tables in the ACPI Device for the AXP288 PMIC for some * reason only describe a small temperature range, e.g. 27° - 37° * Celcius. Resulting in errors when the tablet is idle in a cool room. * * To avoid these errors clamp the raw value to be inside the LPAT.
*/ if (first.raw < last.raw)
raw = clamp(raw, first.raw, last.raw); else
raw = clamp(raw, last.raw, first.raw);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.