Lines Matching +full:pmic +full:- +full:specific
1 // SPDX-License-Identifier: GPL-2.0-only
3 * intel_pmic.c - Intel PMIC operation region driver
47 return -ENOENT; in pmic_get_reg_bit()
55 struct regmap *regmap = opregion->regmap; in intel_pmic_power_handler()
56 struct intel_pmic_opregion_data *d = opregion->data; in intel_pmic_power_handler()
65 result = pmic_get_reg_bit(address, d->power_table, in intel_pmic_power_handler()
66 d->power_table_count, ®, &bit); in intel_pmic_power_handler()
67 if (result == -ENOENT) in intel_pmic_power_handler()
70 mutex_lock(&opregion->lock); in intel_pmic_power_handler()
73 d->get_power(regmap, reg, bit, value64) : in intel_pmic_power_handler()
74 d->update_power(regmap, reg, bit, *value64 == 1); in intel_pmic_power_handler()
76 mutex_unlock(&opregion->lock); in intel_pmic_power_handler()
86 if (!opregion->data->get_raw_temp) in pmic_read_temp()
87 return -ENXIO; in pmic_read_temp()
89 raw_temp = opregion->data->get_raw_temp(opregion->regmap, reg); in pmic_read_temp()
93 if (!opregion->lpat_table) { in pmic_read_temp()
98 temp = acpi_lpat_raw_to_temp(opregion->lpat_table, raw_temp); in pmic_read_temp()
110 pmic_read_temp(opregion, reg, value) : -EINVAL; in pmic_thermal_temp()
121 if (!opregion->data->update_aux) in pmic_thermal_aux()
122 return -ENXIO; in pmic_thermal_aux()
124 if (opregion->lpat_table) { in pmic_thermal_aux()
125 raw_temp = acpi_lpat_temp_to_raw(opregion->lpat_table, *value); in pmic_thermal_aux()
132 return opregion->data->update_aux(opregion->regmap, reg, raw_temp); in pmic_thermal_aux()
138 struct intel_pmic_opregion_data *d = opregion->data; in pmic_thermal_pen()
139 struct regmap *regmap = opregion->regmap; in pmic_thermal_pen()
141 if (!d->get_policy || !d->update_policy) in pmic_thermal_pen()
142 return -ENXIO; in pmic_thermal_pen()
145 return d->get_policy(regmap, reg, bit, value); in pmic_thermal_pen()
148 return -EINVAL; in pmic_thermal_pen()
150 return d->update_policy(regmap, reg, bit, *value); in pmic_thermal_pen()
160 return (address >= 4 && address <= 0x40 && !((address - 4) % 12)) || in pmic_thermal_is_aux()
161 (address >= 8 && address <= 0x44 && !((address - 8) % 12)); in pmic_thermal_is_aux()
174 struct intel_pmic_opregion_data *d = opregion->data; in intel_pmic_thermal_handler()
180 result = pmic_get_reg_bit(address, d->thermal_table, in intel_pmic_thermal_handler()
181 d->thermal_table_count, ®, &bit); in intel_pmic_thermal_handler()
182 if (result == -ENOENT) in intel_pmic_thermal_handler()
185 mutex_lock(&opregion->lock); in intel_pmic_thermal_handler()
195 result = -EINVAL; in intel_pmic_thermal_handler()
197 mutex_unlock(&opregion->lock); in intel_pmic_thermal_handler()
200 if (result == -EINVAL) in intel_pmic_thermal_handler()
220 opregion->ctx.addr |= (*value64 & 0xff) << 8; in intel_pmic_regs_handler()
223 opregion->ctx.addr |= *value64 & 0xff; in intel_pmic_regs_handler()
226 opregion->ctx.val = *value64 & 0xff; in intel_pmic_regs_handler()
230 result = regmap_write(opregion->regmap, opregion->ctx.addr, in intel_pmic_regs_handler()
231 opregion->ctx.val); in intel_pmic_regs_handler()
233 result = regmap_read(opregion->regmap, opregion->ctx.addr, in intel_pmic_regs_handler()
234 &opregion->ctx.val); in intel_pmic_regs_handler()
236 *value64 = opregion->ctx.val; in intel_pmic_regs_handler()
238 memset(&opregion->ctx, 0x00, sizeof(opregion->ctx)); in intel_pmic_regs_handler()
242 if (result == -EINVAL) in intel_pmic_regs_handler()
260 return -EINVAL; in intel_pmic_install_opregion_handler()
263 return -ENODEV; in intel_pmic_install_opregion_handler()
267 return -ENOMEM; in intel_pmic_install_opregion_handler()
269 mutex_init(&opregion->lock); in intel_pmic_install_opregion_handler()
270 opregion->regmap = regmap; in intel_pmic_install_opregion_handler()
271 opregion->lpat_table = acpi_lpat_get_conversion_table(handle); in intel_pmic_install_opregion_handler()
273 if (d->power_table_count) in intel_pmic_install_opregion_handler()
279 ret = -ENODEV; in intel_pmic_install_opregion_handler()
283 if (d->thermal_table_count) in intel_pmic_install_opregion_handler()
289 ret = -ENODEV; in intel_pmic_install_opregion_handler()
297 ret = -ENODEV; in intel_pmic_install_opregion_handler()
301 opregion->data = d; in intel_pmic_install_opregion_handler()
306 if (d->thermal_table_count) in intel_pmic_install_opregion_handler()
312 if (d->power_table_count) in intel_pmic_install_opregion_handler()
318 acpi_lpat_free_conversion_table(opregion->lpat_table); in intel_pmic_install_opregion_handler()
324 * intel_soc_pmic_exec_mipi_pmic_seq_element - Execute PMIC MIPI sequence
325 * @i2c_address: I2C client address for the PMIC
326 * @reg_address: PMIC register address
332 * sequences is a PMIC specific element of 15 bytes.
334 * This function executes these PMIC specific elements sending the embedded
335 * commands to the PMIC.
346 pr_warn("%s: No PMIC registered\n", __func__); in intel_soc_pmic_exec_mipi_pmic_seq_element()
347 return -ENXIO; in intel_soc_pmic_exec_mipi_pmic_seq_element()
350 d = intel_pmic_opregion->data; in intel_soc_pmic_exec_mipi_pmic_seq_element()
352 mutex_lock(&intel_pmic_opregion->lock); in intel_soc_pmic_exec_mipi_pmic_seq_element()
354 if (d->exec_mipi_pmic_seq_element) { in intel_soc_pmic_exec_mipi_pmic_seq_element()
355 ret = d->exec_mipi_pmic_seq_element(intel_pmic_opregion->regmap, in intel_soc_pmic_exec_mipi_pmic_seq_element()
358 } else if (d->pmic_i2c_address) { in intel_soc_pmic_exec_mipi_pmic_seq_element()
359 if (i2c_address == d->pmic_i2c_address) { in intel_soc_pmic_exec_mipi_pmic_seq_element()
360 ret = regmap_update_bits(intel_pmic_opregion->regmap, in intel_soc_pmic_exec_mipi_pmic_seq_element()
363 pr_err("%s: Unexpected i2c-addr: 0x%02x (reg-addr 0x%x value 0x%x mask 0x%x)\n", in intel_soc_pmic_exec_mipi_pmic_seq_element()
365 ret = -ENXIO; in intel_soc_pmic_exec_mipi_pmic_seq_element()
369 pr_warn("%s: i2c-addr: 0x%x reg-addr 0x%x value 0x%x mask 0x%x\n", in intel_soc_pmic_exec_mipi_pmic_seq_element()
371 ret = -EOPNOTSUPP; in intel_soc_pmic_exec_mipi_pmic_seq_element()
374 mutex_unlock(&intel_pmic_opregion->lock); in intel_soc_pmic_exec_mipi_pmic_seq_element()