Release 4.7 drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c
/*
* Copyright (C) 2012 Invensense, Inc.
*
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
* may be copied, distributed, and modified under those terms.
*
* 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.
*/
#include "inv_mpu_iio.h"
static void inv_scan_query(struct iio_dev *indio_dev)
{
struct inv_mpu6050_state *st = iio_priv(indio_dev);
st->chip_config.gyro_fifo_enable =
test_bit(INV_MPU6050_SCAN_GYRO_X,
indio_dev->active_scan_mask) ||
test_bit(INV_MPU6050_SCAN_GYRO_Y,
indio_dev->active_scan_mask) ||
test_bit(INV_MPU6050_SCAN_GYRO_Z,
indio_dev->active_scan_mask);
st->chip_config.accl_fifo_enable =
test_bit(INV_MPU6050_SCAN_ACCL_X,
indio_dev->active_scan_mask) ||
test_bit(INV_MPU6050_SCAN_ACCL_Y,
indio_dev->active_scan_mask) ||
test_bit(INV_MPU6050_SCAN_ACCL_Z,
indio_dev->active_scan_mask);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
ge gao | ge gao | 87 | 100.00% | 1 | 100.00% |
| Total | 87 | 100.00% | 1 | 100.00% |
/**
* inv_mpu6050_set_enable() - enable chip functions.
* @indio_dev: Device driver instance.
* @enable: enable/disable
*/
static int inv_mpu6050_set_enable(struct iio_dev *indio_dev, bool enable)
{
struct inv_mpu6050_state *st = iio_priv(indio_dev);
int result;
if (enable) {
result = inv_mpu6050_set_power_itg(st, true);
if (result)
return result;
inv_scan_query(indio_dev);
if (st->chip_config.gyro_fifo_enable) {
result = inv_mpu6050_switch_engine(st, true,
INV_MPU6050_BIT_PWR_GYRO_STBY);
if (result)
return result;
}
if (st->chip_config.accl_fifo_enable) {
result = inv_mpu6050_switch_engine(st, true,
INV_MPU6050_BIT_PWR_ACCL_STBY);
if (result)
return result;
}
result = inv_reset_fifo(indio_dev);
if (result)
return result;
} else {
result = regmap_write(st->map, st->reg->fifo_en, 0);
if (result)
return result;
result = regmap_write(st->map, st->reg->int_enable, 0);
if (result)
return result;
result = regmap_write(st->map, st->reg->user_ctrl, 0);
if (result)
return result;
result = inv_mpu6050_switch_engine(st, false,
INV_MPU6050_BIT_PWR_GYRO_STBY);
if (result)
return result;
result = inv_mpu6050_switch_engine(st, false,
INV_MPU6050_BIT_PWR_ACCL_STBY);
if (result)
return result;
result = inv_mpu6050_set_power_itg(st, false);
if (result)
return result;
}
st->chip_config.enable = enable;
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
ge gao | ge gao | 253 | 96.56% | 1 | 50.00% |
adriana reus | adriana reus | 9 | 3.44% | 1 | 50.00% |
| Total | 262 | 100.00% | 2 | 100.00% |
/**
* inv_mpu_data_rdy_trigger_set_state() - set data ready interrupt state
* @trig: Trigger instance
* @state: Desired trigger state
*/
static int inv_mpu_data_rdy_trigger_set_state(struct iio_trigger *trig,
bool state)
{
return inv_mpu6050_set_enable(iio_trigger_get_drvdata(trig), state);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
ge gao | ge gao | 22 | 88.00% | 1 | 50.00% |
lars-peter clausen | lars-peter clausen | 3 | 12.00% | 1 | 50.00% |
| Total | 25 | 100.00% | 2 | 100.00% |
static const struct iio_trigger_ops inv_mpu_trigger_ops = {
.owner = THIS_MODULE,
.set_trigger_state = &inv_mpu_data_rdy_trigger_set_state,
};
int inv_mpu6050_probe_trigger(struct iio_dev *indio_dev)
{
int ret;
struct inv_mpu6050_state *st = iio_priv(indio_dev);
st->trig = devm_iio_trigger_alloc(&indio_dev->dev,
"%s-dev%d",
indio_dev->name,
indio_dev->id);
if (!st->trig)
return -ENOMEM;
ret = devm_request_irq(&indio_dev->dev, st->irq,
&iio_trigger_generic_data_rdy_poll,
IRQF_TRIGGER_RISING,
"inv_mpu",
st->trig);
if (ret)
return ret;
st->trig->dev.parent = regmap_get_device(st->map);
st->trig->ops = &inv_mpu_trigger_ops;
iio_trigger_set_drvdata(st->trig, indio_dev);
ret = iio_trigger_register(st->trig);
if (ret)
return ret;
indio_dev->trig = iio_trigger_get(st->trig);
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
ge gao | ge gao | 115 | 76.16% | 1 | 14.29% |
varka bhadram | varka bhadram | 21 | 13.91% | 3 | 42.86% |
lars-peter clausen | lars-peter clausen | 8 | 5.30% | 1 | 14.29% |
adriana reus | adriana reus | 4 | 2.65% | 1 | 14.29% |
srinivas pandruvada | srinivas pandruvada | 3 | 1.99% | 1 | 14.29% |
| Total | 151 | 100.00% | 7 | 100.00% |
void inv_mpu6050_remove_trigger(struct inv_mpu6050_state *st)
{
iio_trigger_unregister(st->trig);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
ge gao | ge gao | 17 | 100.00% | 1 | 100.00% |
| Total | 17 | 100.00% | 1 | 100.00% |
Overall Contributors
| Person | Tokens | Prop | Commits | CommitProp |
ge gao | ge gao | 519 | 91.53% | 1 | 12.50% |
varka bhadram | varka bhadram | 21 | 3.70% | 3 | 37.50% |
adriana reus | adriana reus | 13 | 2.29% | 2 | 25.00% |
lars-peter clausen | lars-peter clausen | 11 | 1.94% | 1 | 12.50% |
srinivas pandruvada | srinivas pandruvada | 3 | 0.53% | 1 | 12.50% |
| Total | 567 | 100.00% | 8 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.