diff options
Diffstat (limited to 'drivers/iio')
-rw-r--r-- | drivers/iio/accel/bmc150-accel.c | 40 | ||||
-rw-r--r-- | drivers/iio/accel/kxcjk-1013.c | 2 | ||||
-rw-r--r-- | drivers/iio/adc/men_z188_adc.c | 1 | ||||
-rw-r--r-- | drivers/iio/gyro/bmg160.c | 53 |
4 files changed, 85 insertions, 11 deletions
diff --git a/drivers/iio/accel/bmc150-accel.c b/drivers/iio/accel/bmc150-accel.c index 22c096ce39ad..513bd6d14293 100644 --- a/drivers/iio/accel/bmc150-accel.c +++ b/drivers/iio/accel/bmc150-accel.c | |||
@@ -44,6 +44,9 @@ | |||
44 | 44 | ||
45 | #define BMC150_ACCEL_REG_INT_STATUS_2 0x0B | 45 | #define BMC150_ACCEL_REG_INT_STATUS_2 0x0B |
46 | #define BMC150_ACCEL_ANY_MOTION_MASK 0x07 | 46 | #define BMC150_ACCEL_ANY_MOTION_MASK 0x07 |
47 | #define BMC150_ACCEL_ANY_MOTION_BIT_X BIT(0) | ||
48 | #define BMC150_ACCEL_ANY_MOTION_BIT_Y BIT(1) | ||
49 | #define BMC150_ACCEL_ANY_MOTION_BIT_Z BIT(2) | ||
47 | #define BMC150_ACCEL_ANY_MOTION_BIT_SIGN BIT(3) | 50 | #define BMC150_ACCEL_ANY_MOTION_BIT_SIGN BIT(3) |
48 | 51 | ||
49 | #define BMC150_ACCEL_REG_PMU_LPW 0x11 | 52 | #define BMC150_ACCEL_REG_PMU_LPW 0x11 |
@@ -92,9 +95,9 @@ | |||
92 | #define BMC150_ACCEL_SLOPE_THRES_MASK 0xFF | 95 | #define BMC150_ACCEL_SLOPE_THRES_MASK 0xFF |
93 | 96 | ||
94 | /* Slope duration in terms of number of samples */ | 97 | /* Slope duration in terms of number of samples */ |
95 | #define BMC150_ACCEL_DEF_SLOPE_DURATION 2 | 98 | #define BMC150_ACCEL_DEF_SLOPE_DURATION 1 |
96 | /* in terms of multiples of g's/LSB, based on range */ | 99 | /* in terms of multiples of g's/LSB, based on range */ |
97 | #define BMC150_ACCEL_DEF_SLOPE_THRESHOLD 5 | 100 | #define BMC150_ACCEL_DEF_SLOPE_THRESHOLD 1 |
98 | 101 | ||
99 | #define BMC150_ACCEL_REG_XOUT_L 0x02 | 102 | #define BMC150_ACCEL_REG_XOUT_L 0x02 |
100 | 103 | ||
@@ -536,6 +539,9 @@ static int bmc150_accel_set_power_state(struct bmc150_accel_data *data, bool on) | |||
536 | if (ret < 0) { | 539 | if (ret < 0) { |
537 | dev_err(&data->client->dev, | 540 | dev_err(&data->client->dev, |
538 | "Failed: bmc150_accel_set_power_state for %d\n", on); | 541 | "Failed: bmc150_accel_set_power_state for %d\n", on); |
542 | if (on) | ||
543 | pm_runtime_put_noidle(&data->client->dev); | ||
544 | |||
539 | return ret; | 545 | return ret; |
540 | } | 546 | } |
541 | 547 | ||
@@ -811,6 +817,7 @@ static int bmc150_accel_write_event_config(struct iio_dev *indio_dev, | |||
811 | 817 | ||
812 | ret = bmc150_accel_setup_any_motion_interrupt(data, state); | 818 | ret = bmc150_accel_setup_any_motion_interrupt(data, state); |
813 | if (ret < 0) { | 819 | if (ret < 0) { |
820 | bmc150_accel_set_power_state(data, false); | ||
814 | mutex_unlock(&data->mutex); | 821 | mutex_unlock(&data->mutex); |
815 | return ret; | 822 | return ret; |
816 | } | 823 | } |
@@ -846,7 +853,7 @@ static const struct attribute_group bmc150_accel_attrs_group = { | |||
846 | 853 | ||
847 | static const struct iio_event_spec bmc150_accel_event = { | 854 | static const struct iio_event_spec bmc150_accel_event = { |
848 | .type = IIO_EV_TYPE_ROC, | 855 | .type = IIO_EV_TYPE_ROC, |
849 | .dir = IIO_EV_DIR_RISING | IIO_EV_DIR_FALLING, | 856 | .dir = IIO_EV_DIR_EITHER, |
850 | .mask_separate = BIT(IIO_EV_INFO_VALUE) | | 857 | .mask_separate = BIT(IIO_EV_INFO_VALUE) | |
851 | BIT(IIO_EV_INFO_ENABLE) | | 858 | BIT(IIO_EV_INFO_ENABLE) | |
852 | BIT(IIO_EV_INFO_PERIOD) | 859 | BIT(IIO_EV_INFO_PERIOD) |
@@ -1054,6 +1061,7 @@ static int bmc150_accel_data_rdy_trigger_set_state(struct iio_trigger *trig, | |||
1054 | else | 1061 | else |
1055 | ret = bmc150_accel_setup_new_data_interrupt(data, state); | 1062 | ret = bmc150_accel_setup_new_data_interrupt(data, state); |
1056 | if (ret < 0) { | 1063 | if (ret < 0) { |
1064 | bmc150_accel_set_power_state(data, false); | ||
1057 | mutex_unlock(&data->mutex); | 1065 | mutex_unlock(&data->mutex); |
1058 | return ret; | 1066 | return ret; |
1059 | } | 1067 | } |
@@ -1092,12 +1100,26 @@ static irqreturn_t bmc150_accel_event_handler(int irq, void *private) | |||
1092 | else | 1100 | else |
1093 | dir = IIO_EV_DIR_RISING; | 1101 | dir = IIO_EV_DIR_RISING; |
1094 | 1102 | ||
1095 | if (ret & BMC150_ACCEL_ANY_MOTION_MASK) | 1103 | if (ret & BMC150_ACCEL_ANY_MOTION_BIT_X) |
1104 | iio_push_event(indio_dev, IIO_MOD_EVENT_CODE(IIO_ACCEL, | ||
1105 | 0, | ||
1106 | IIO_MOD_X, | ||
1107 | IIO_EV_TYPE_ROC, | ||
1108 | dir), | ||
1109 | data->timestamp); | ||
1110 | if (ret & BMC150_ACCEL_ANY_MOTION_BIT_Y) | ||
1096 | iio_push_event(indio_dev, IIO_MOD_EVENT_CODE(IIO_ACCEL, | 1111 | iio_push_event(indio_dev, IIO_MOD_EVENT_CODE(IIO_ACCEL, |
1097 | 0, | 1112 | 0, |
1098 | IIO_MOD_X_OR_Y_OR_Z, | 1113 | IIO_MOD_Y, |
1099 | IIO_EV_TYPE_ROC, | 1114 | IIO_EV_TYPE_ROC, |
1100 | IIO_EV_DIR_EITHER), | 1115 | dir), |
1116 | data->timestamp); | ||
1117 | if (ret & BMC150_ACCEL_ANY_MOTION_BIT_Z) | ||
1118 | iio_push_event(indio_dev, IIO_MOD_EVENT_CODE(IIO_ACCEL, | ||
1119 | 0, | ||
1120 | IIO_MOD_Z, | ||
1121 | IIO_EV_TYPE_ROC, | ||
1122 | dir), | ||
1101 | data->timestamp); | 1123 | data->timestamp); |
1102 | ack_intr_status: | 1124 | ack_intr_status: |
1103 | if (!data->dready_trigger_on) | 1125 | if (!data->dready_trigger_on) |
@@ -1354,10 +1376,14 @@ static int bmc150_accel_runtime_suspend(struct device *dev) | |||
1354 | { | 1376 | { |
1355 | struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev)); | 1377 | struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev)); |
1356 | struct bmc150_accel_data *data = iio_priv(indio_dev); | 1378 | struct bmc150_accel_data *data = iio_priv(indio_dev); |
1379 | int ret; | ||
1357 | 1380 | ||
1358 | dev_dbg(&data->client->dev, __func__); | 1381 | dev_dbg(&data->client->dev, __func__); |
1382 | ret = bmc150_accel_set_mode(data, BMC150_ACCEL_SLEEP_MODE_SUSPEND, 0); | ||
1383 | if (ret < 0) | ||
1384 | return -EAGAIN; | ||
1359 | 1385 | ||
1360 | return bmc150_accel_set_mode(data, BMC150_ACCEL_SLEEP_MODE_SUSPEND, 0); | 1386 | return 0; |
1361 | } | 1387 | } |
1362 | 1388 | ||
1363 | static int bmc150_accel_runtime_resume(struct device *dev) | 1389 | static int bmc150_accel_runtime_resume(struct device *dev) |
diff --git a/drivers/iio/accel/kxcjk-1013.c b/drivers/iio/accel/kxcjk-1013.c index a23e58c4ed99..320aa72c0349 100644 --- a/drivers/iio/accel/kxcjk-1013.c +++ b/drivers/iio/accel/kxcjk-1013.c | |||
@@ -269,6 +269,8 @@ static int kxcjk1013_set_range(struct kxcjk1013_data *data, int range_index) | |||
269 | return ret; | 269 | return ret; |
270 | } | 270 | } |
271 | 271 | ||
272 | ret &= ~(KXCJK1013_REG_CTRL1_BIT_GSEL0 | | ||
273 | KXCJK1013_REG_CTRL1_BIT_GSEL1); | ||
272 | ret |= (KXCJK1013_scale_table[range_index].gsel_0 << 3); | 274 | ret |= (KXCJK1013_scale_table[range_index].gsel_0 << 3); |
273 | ret |= (KXCJK1013_scale_table[range_index].gsel_1 << 4); | 275 | ret |= (KXCJK1013_scale_table[range_index].gsel_1 << 4); |
274 | 276 | ||
diff --git a/drivers/iio/adc/men_z188_adc.c b/drivers/iio/adc/men_z188_adc.c index b58d6302521f..d095efe1ba14 100644 --- a/drivers/iio/adc/men_z188_adc.c +++ b/drivers/iio/adc/men_z188_adc.c | |||
@@ -152,6 +152,7 @@ static void men_z188_remove(struct mcb_device *dev) | |||
152 | 152 | ||
153 | static const struct mcb_device_id men_z188_ids[] = { | 153 | static const struct mcb_device_id men_z188_ids[] = { |
154 | { .device = 0xbc }, | 154 | { .device = 0xbc }, |
155 | { } | ||
155 | }; | 156 | }; |
156 | MODULE_DEVICE_TABLE(mcb, men_z188_ids); | 157 | MODULE_DEVICE_TABLE(mcb, men_z188_ids); |
157 | 158 | ||
diff --git a/drivers/iio/gyro/bmg160.c b/drivers/iio/gyro/bmg160.c index 1f967e0d688e..d2fa526740ca 100644 --- a/drivers/iio/gyro/bmg160.c +++ b/drivers/iio/gyro/bmg160.c | |||
@@ -67,6 +67,9 @@ | |||
67 | #define BMG160_REG_INT_EN_0 0x15 | 67 | #define BMG160_REG_INT_EN_0 0x15 |
68 | #define BMG160_DATA_ENABLE_INT BIT(7) | 68 | #define BMG160_DATA_ENABLE_INT BIT(7) |
69 | 69 | ||
70 | #define BMG160_REG_INT_EN_1 0x16 | ||
71 | #define BMG160_INT1_BIT_OD BIT(1) | ||
72 | |||
70 | #define BMG160_REG_XOUT_L 0x02 | 73 | #define BMG160_REG_XOUT_L 0x02 |
71 | #define BMG160_AXIS_TO_REG(axis) (BMG160_REG_XOUT_L + (axis * 2)) | 74 | #define BMG160_AXIS_TO_REG(axis) (BMG160_REG_XOUT_L + (axis * 2)) |
72 | 75 | ||
@@ -82,6 +85,9 @@ | |||
82 | 85 | ||
83 | #define BMG160_REG_INT_STATUS_2 0x0B | 86 | #define BMG160_REG_INT_STATUS_2 0x0B |
84 | #define BMG160_ANY_MOTION_MASK 0x07 | 87 | #define BMG160_ANY_MOTION_MASK 0x07 |
88 | #define BMG160_ANY_MOTION_BIT_X BIT(0) | ||
89 | #define BMG160_ANY_MOTION_BIT_Y BIT(1) | ||
90 | #define BMG160_ANY_MOTION_BIT_Z BIT(2) | ||
85 | 91 | ||
86 | #define BMG160_REG_TEMP 0x08 | 92 | #define BMG160_REG_TEMP 0x08 |
87 | #define BMG160_TEMP_CENTER_VAL 23 | 93 | #define BMG160_TEMP_CENTER_VAL 23 |
@@ -222,6 +228,19 @@ static int bmg160_chip_init(struct bmg160_data *data) | |||
222 | data->slope_thres = ret; | 228 | data->slope_thres = ret; |
223 | 229 | ||
224 | /* Set default interrupt mode */ | 230 | /* Set default interrupt mode */ |
231 | ret = i2c_smbus_read_byte_data(data->client, BMG160_REG_INT_EN_1); | ||
232 | if (ret < 0) { | ||
233 | dev_err(&data->client->dev, "Error reading reg_int_en_1\n"); | ||
234 | return ret; | ||
235 | } | ||
236 | ret &= ~BMG160_INT1_BIT_OD; | ||
237 | ret = i2c_smbus_write_byte_data(data->client, | ||
238 | BMG160_REG_INT_EN_1, ret); | ||
239 | if (ret < 0) { | ||
240 | dev_err(&data->client->dev, "Error writing reg_int_en_1\n"); | ||
241 | return ret; | ||
242 | } | ||
243 | |||
225 | ret = i2c_smbus_write_byte_data(data->client, | 244 | ret = i2c_smbus_write_byte_data(data->client, |
226 | BMG160_REG_INT_RST_LATCH, | 245 | BMG160_REG_INT_RST_LATCH, |
227 | BMG160_INT_MODE_LATCH_INT | | 246 | BMG160_INT_MODE_LATCH_INT | |
@@ -250,6 +269,9 @@ static int bmg160_set_power_state(struct bmg160_data *data, bool on) | |||
250 | if (ret < 0) { | 269 | if (ret < 0) { |
251 | dev_err(&data->client->dev, | 270 | dev_err(&data->client->dev, |
252 | "Failed: bmg160_set_power_state for %d\n", on); | 271 | "Failed: bmg160_set_power_state for %d\n", on); |
272 | if (on) | ||
273 | pm_runtime_put_noidle(&data->client->dev); | ||
274 | |||
253 | return ret; | 275 | return ret; |
254 | } | 276 | } |
255 | #endif | 277 | #endif |
@@ -705,6 +727,7 @@ static int bmg160_write_event_config(struct iio_dev *indio_dev, | |||
705 | 727 | ||
706 | ret = bmg160_setup_any_motion_interrupt(data, state); | 728 | ret = bmg160_setup_any_motion_interrupt(data, state); |
707 | if (ret < 0) { | 729 | if (ret < 0) { |
730 | bmg160_set_power_state(data, false); | ||
708 | mutex_unlock(&data->mutex); | 731 | mutex_unlock(&data->mutex); |
709 | return ret; | 732 | return ret; |
710 | } | 733 | } |
@@ -743,7 +766,7 @@ static const struct attribute_group bmg160_attrs_group = { | |||
743 | 766 | ||
744 | static const struct iio_event_spec bmg160_event = { | 767 | static const struct iio_event_spec bmg160_event = { |
745 | .type = IIO_EV_TYPE_ROC, | 768 | .type = IIO_EV_TYPE_ROC, |
746 | .dir = IIO_EV_DIR_RISING | IIO_EV_DIR_FALLING, | 769 | .dir = IIO_EV_DIR_EITHER, |
747 | .mask_shared_by_type = BIT(IIO_EV_INFO_VALUE) | | 770 | .mask_shared_by_type = BIT(IIO_EV_INFO_VALUE) | |
748 | BIT(IIO_EV_INFO_ENABLE) | 771 | BIT(IIO_EV_INFO_ENABLE) |
749 | }; | 772 | }; |
@@ -871,6 +894,7 @@ static int bmg160_data_rdy_trigger_set_state(struct iio_trigger *trig, | |||
871 | else | 894 | else |
872 | ret = bmg160_setup_new_data_interrupt(data, state); | 895 | ret = bmg160_setup_new_data_interrupt(data, state); |
873 | if (ret < 0) { | 896 | if (ret < 0) { |
897 | bmg160_set_power_state(data, false); | ||
874 | mutex_unlock(&data->mutex); | 898 | mutex_unlock(&data->mutex); |
875 | return ret; | 899 | return ret; |
876 | } | 900 | } |
@@ -908,10 +932,24 @@ static irqreturn_t bmg160_event_handler(int irq, void *private) | |||
908 | else | 932 | else |
909 | dir = IIO_EV_DIR_FALLING; | 933 | dir = IIO_EV_DIR_FALLING; |
910 | 934 | ||
911 | if (ret & BMG160_ANY_MOTION_MASK) | 935 | if (ret & BMG160_ANY_MOTION_BIT_X) |
912 | iio_push_event(indio_dev, IIO_MOD_EVENT_CODE(IIO_ANGL_VEL, | 936 | iio_push_event(indio_dev, IIO_MOD_EVENT_CODE(IIO_ANGL_VEL, |
913 | 0, | 937 | 0, |
914 | IIO_MOD_X_OR_Y_OR_Z, | 938 | IIO_MOD_X, |
939 | IIO_EV_TYPE_ROC, | ||
940 | dir), | ||
941 | data->timestamp); | ||
942 | if (ret & BMG160_ANY_MOTION_BIT_Y) | ||
943 | iio_push_event(indio_dev, IIO_MOD_EVENT_CODE(IIO_ANGL_VEL, | ||
944 | 0, | ||
945 | IIO_MOD_Y, | ||
946 | IIO_EV_TYPE_ROC, | ||
947 | dir), | ||
948 | data->timestamp); | ||
949 | if (ret & BMG160_ANY_MOTION_BIT_Z) | ||
950 | iio_push_event(indio_dev, IIO_MOD_EVENT_CODE(IIO_ANGL_VEL, | ||
951 | 0, | ||
952 | IIO_MOD_Z, | ||
915 | IIO_EV_TYPE_ROC, | 953 | IIO_EV_TYPE_ROC, |
916 | dir), | 954 | dir), |
917 | data->timestamp); | 955 | data->timestamp); |
@@ -1169,8 +1207,15 @@ static int bmg160_runtime_suspend(struct device *dev) | |||
1169 | { | 1207 | { |
1170 | struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev)); | 1208 | struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev)); |
1171 | struct bmg160_data *data = iio_priv(indio_dev); | 1209 | struct bmg160_data *data = iio_priv(indio_dev); |
1210 | int ret; | ||
1211 | |||
1212 | ret = bmg160_set_mode(data, BMG160_MODE_SUSPEND); | ||
1213 | if (ret < 0) { | ||
1214 | dev_err(&data->client->dev, "set mode failed\n"); | ||
1215 | return -EAGAIN; | ||
1216 | } | ||
1172 | 1217 | ||
1173 | return bmg160_set_mode(data, BMG160_MODE_SUSPEND); | 1218 | return 0; |
1174 | } | 1219 | } |
1175 | 1220 | ||
1176 | static int bmg160_runtime_resume(struct device *dev) | 1221 | static int bmg160_runtime_resume(struct device *dev) |