pr_debug("%s inv_mpu_resume\n", st->hw->name);
+ mutex_lock(&indio_dev->mlock);
if (st->support_hw_poweroff) {
- mutex_lock(&indio_dev->mlock);
/* reset to make sure previous state are not there */
result = inv_plat_single_write(st, st->reg.pwr_mgmt_1, BIT_H_RESET);
if (result) {
pr_err("%s, set user_ctrl failed\n", __func__);
goto rw_err;
}
- inv_reg_recover(st);
- mutex_unlock(&indio_dev->mlock);
+ inv_resume_recover_setting(st);
} else {
result = st->set_power_state(st, true);
}
- return result;
rw_err:
mutex_unlock(&indio_dev->mlock);
pr_debug("%s inv_mpu_suspend\n", st->hw->name);
mutex_lock(&indio_dev->mlock);
- if (st->support_hw_poweroff)
- inv_reg_store(st);
if ((!st->chip_config.dmp_on) ||
(!st->chip_config.enable) ||
(!st->chip_config.dmp_event_int_on))
int *gyro_result, int *accl_result);
int inv_hw_self_test(struct inv_mpu_iio_s *st);
void inv_recover_setting(struct inv_mpu_iio_s *st);
+void inv_resume_recover_setting(struct inv_mpu_iio_s *st);
int inv_power_up_self_test(struct inv_mpu_iio_s *st);
s64 get_time_ns(void);
int write_be32_key_to_mem(struct inv_mpu_iio_s *st,
st->set_power_state(st, false);
}
+/*
+ * inv_resume_recover_setting() recover the old settings after from hw powerdown
+ */
+void inv_resume_recover_setting(struct inv_mpu_iio_s *st)
+{
+ struct inv_reg_map_s *reg;
+ int data;
+
+ reg = &st->reg;
+ inv_plat_single_write(st, reg->gyro_config,
+ st->chip_config.fsr << GYRO_CONFIG_FSR_SHIFT);
+ inv_plat_single_write(st, reg->lpf, st->chip_config.lpf);
+ data = ONE_K_HZ / st->chip_config.new_fifo_rate - 1;
+ inv_plat_single_write(st, reg->sample_rate_div, data);
+ if (INV_ITG3500 != st->chip_type) {
+ inv_plat_single_write(st, reg->accl_config,
+ (st->chip_config.accl_fs <<
+ ACCL_CONFIG_FSR_SHIFT));
+ }
+}
+
static int inv_check_compass_self_test(struct inv_mpu_iio_s *st)
{
int result;
pr_debug("%s inv_mpu_resume\n", st->hw->name);
+ mutex_lock(&indio_dev->mlock);
if (st->support_hw_poweroff) {
- mutex_lock(&indio_dev->mlock);
/* reset to make sure previous state are not there */
result = inv_plat_single_write(st, st->reg.pwr_mgmt_1, BIT_H_RESET);
if (result) {
pr_err("%s, set user_ctrl failed\n", __func__);
goto rw_err;
}
- inv_reg_recover(st);
- mutex_unlock(&indio_dev->mlock);
+ inv_resume_recover_setting(st);
} else {
result = st->set_power_state(st, true);
}
- return result;
rw_err:
mutex_unlock(&indio_dev->mlock);
pr_debug("%s inv_mpu_suspend\n", st->hw->name);
mutex_lock(&indio_dev->mlock);
- if (st->support_hw_poweroff)
- inv_reg_store(st);
if ((!st->chip_config.dmp_on) ||
(!st->chip_config.enable) ||
(!st->chip_config.dmp_event_int_on))