mirror of
https://github.com/torvalds/linux.git
synced 2026-03-08 05:24:39 +01:00
iio: accel: adxl313: implement power-save on inactivity
Configure the link bit to associate activity and inactivity sensing, allowing the sensor to reflect its internal power-saving state. Additionally, enable the auto-sleep bit to transition the sensor into auto-sleep mode during periods of inactivity, as outlined in the datasheet. Reviewed-by: Andy Shevchenko <andy@kernel.org> Signed-off-by: Lothar Rubusch <l.rubusch@gmail.com> Link: https://patch.msgid.link/20250702230819.19353-7-l.rubusch@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This commit is contained in:
parent
e3fc1cadf2
commit
554396d4b0
2 changed files with 25 additions and 0 deletions
|
|
@ -41,6 +41,9 @@
|
|||
#define ADXL313_RATE_BASE 6
|
||||
|
||||
#define ADXL313_POWER_CTL_MSK BIT(3)
|
||||
#define ADXL313_POWER_CTL_INACT_MSK GENMASK(5, 4)
|
||||
#define ADXL313_POWER_CTL_LINK BIT(5)
|
||||
#define ADXL313_POWER_CTL_AUTO_SLEEP BIT(4)
|
||||
|
||||
#define ADXL313_RANGE_MSK GENMASK(1, 0)
|
||||
#define ADXL313_RANGE_MAX 3
|
||||
|
|
|
|||
|
|
@ -396,6 +396,23 @@ static int adxl313_is_act_inact_en(struct adxl313_data *data,
|
|||
return adxl313_act_int_reg[type] & regval;
|
||||
}
|
||||
|
||||
static int adxl313_set_act_inact_linkbit(struct adxl313_data *data, bool en)
|
||||
{
|
||||
int act_en, inact_en;
|
||||
|
||||
act_en = adxl313_is_act_inact_en(data, ADXL313_ACTIVITY);
|
||||
if (act_en < 0)
|
||||
return act_en;
|
||||
|
||||
inact_en = adxl313_is_act_inact_en(data, ADXL313_INACTIVITY);
|
||||
if (inact_en < 0)
|
||||
return inact_en;
|
||||
|
||||
return regmap_assign_bits(data->regmap, ADXL313_REG_POWER_CTL,
|
||||
ADXL313_POWER_CTL_AUTO_SLEEP | ADXL313_POWER_CTL_LINK,
|
||||
en && act_en && inact_en);
|
||||
}
|
||||
|
||||
static int adxl313_set_act_inact_en(struct adxl313_data *data,
|
||||
enum adxl313_activity_type type,
|
||||
bool cmd_en)
|
||||
|
|
@ -455,6 +472,11 @@ static int adxl313_set_act_inact_en(struct adxl313_data *data,
|
|||
if (ret)
|
||||
return ret;
|
||||
|
||||
/* Set link-bit and auto-sleep only when ACT and INACT are enabled */
|
||||
ret = adxl313_set_act_inact_linkbit(data, cmd_en);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
return adxl313_set_measure_en(data, true);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue