Source
x
pr_err("%s: Unexpected i2c-addr: 0x%02x (reg-addr 0x%x value 0x%x mask 0x%x)\n",
/*
* intel_pmic.c - Intel PMIC operation region driver
*
* Copyright (C) 2014 Intel Corporation. All rights reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version
* 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
struct intel_pmic_regs_handler_ctx {
unsigned int val;
u16 addr;
};
struct intel_pmic_opregion {
struct mutex lock;
struct acpi_lpat_conversion_table *lpat_table;
struct regmap *regmap;
struct intel_pmic_opregion_data *data;
struct intel_pmic_regs_handler_ctx ctx;
};
static struct intel_pmic_opregion *intel_pmic_opregion;
static int pmic_get_reg_bit(int address, struct pmic_table *table,
int count, int *reg, int *bit)
{
int i;
for (i = 0; i < count; i++) {
if (table[i].address == address) {
*reg = table[i].reg;
if (bit)
*bit = table[i].bit;
return 0;
}
}
return -ENOENT;
}
static acpi_status intel_pmic_power_handler(u32 function,
acpi_physical_address address, u32 bits, u64 *value64,
void *handler_context, void *region_context)
{
struct intel_pmic_opregion *opregion = region_context;
struct regmap *regmap = opregion->regmap;
struct intel_pmic_opregion_data *d = opregion->data;
int reg, bit, result;
if (bits != 32 || !value64)
return AE_BAD_PARAMETER;
if (function == ACPI_WRITE && !(*value64 == 0 || *value64 == 1))
return AE_BAD_PARAMETER;
result = pmic_get_reg_bit(address, d->power_table,
d->power_table_count, ®, &bit);
if (result == -ENOENT)
return AE_BAD_PARAMETER;
mutex_lock(&opregion->lock);
result = function == ACPI_READ ?
d->get_power(regmap, reg, bit, value64) :
d->update_power(regmap, reg, bit, *value64 == 1);
mutex_unlock(&opregion->lock);
return result ? AE_ERROR : AE_OK;
}
static int pmic_read_temp(struct intel_pmic_opregion *opregion,
int reg, u64 *value)
{
int raw_temp, temp;