Commit c6c9e995 authored by Markus Pargmann's avatar Markus Pargmann Committed by Jonathan Cameron

iio: bmg160: Use i2c regmap instead of direct i2c access

This patch introduces regmap usage into the driver. This is done to
later easily support the SPI interface of this chip.
Signed-off-by: default avatarMarkus Pargmann <mpa@pengutronix.de>
Reviewed-by: default avatarSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent 8548a63b
...@@ -55,6 +55,7 @@ config BMG160 ...@@ -55,6 +55,7 @@ config BMG160
depends on I2C depends on I2C
select IIO_BUFFER select IIO_BUFFER
select IIO_TRIGGERED_BUFFER select IIO_TRIGGERED_BUFFER
select REGMAP_I2C
help help
Say yes here to build support for Bosch BMG160 Tri-axis Gyro Sensor Say yes here to build support for Bosch BMG160 Tri-axis Gyro Sensor
driver. This driver also supports BMI055 gyroscope. driver. This driver also supports BMI055 gyroscope.
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <linux/iio/events.h> #include <linux/iio/events.h>
#include <linux/iio/trigger_consumer.h> #include <linux/iio/trigger_consumer.h>
#include <linux/iio/triggered_buffer.h> #include <linux/iio/triggered_buffer.h>
#include <linux/regmap.h>
#define BMG160_DRV_NAME "bmg160" #define BMG160_DRV_NAME "bmg160"
#define BMG160_IRQ_NAME "bmg160_event" #define BMG160_IRQ_NAME "bmg160_event"
...@@ -98,6 +99,7 @@ ...@@ -98,6 +99,7 @@
struct bmg160_data { struct bmg160_data {
struct i2c_client *client; struct i2c_client *client;
struct regmap *regmap;
struct iio_trigger *dready_trig; struct iio_trigger *dready_trig;
struct iio_trigger *motion_trig; struct iio_trigger *motion_trig;
struct mutex mutex; struct mutex mutex;
...@@ -134,12 +136,17 @@ static const struct { ...@@ -134,12 +136,17 @@ static const struct {
{ 133, BMG160_RANGE_250DPS}, { 133, BMG160_RANGE_250DPS},
{ 66, BMG160_RANGE_125DPS} }; { 66, BMG160_RANGE_125DPS} };
static struct regmap_config bmg160_regmap_i2c_conf = {
.reg_bits = 8,
.val_bits = 8,
.max_register = 0x3f
};
static int bmg160_set_mode(struct bmg160_data *data, u8 mode) static int bmg160_set_mode(struct bmg160_data *data, u8 mode)
{ {
int ret; int ret;
ret = i2c_smbus_write_byte_data(data->client, ret = regmap_write(data->regmap, BMG160_REG_PMU_LPW, mode);
BMG160_REG_PMU_LPW, mode);
if (ret < 0) { if (ret < 0) {
dev_err(&data->client->dev, "Error writing reg_pmu_lpw\n"); dev_err(&data->client->dev, "Error writing reg_pmu_lpw\n");
return ret; return ret;
...@@ -169,8 +176,7 @@ static int bmg160_set_bw(struct bmg160_data *data, int val) ...@@ -169,8 +176,7 @@ static int bmg160_set_bw(struct bmg160_data *data, int val)
if (bw_bits < 0) if (bw_bits < 0)
return bw_bits; return bw_bits;
ret = i2c_smbus_write_byte_data(data->client, BMG160_REG_PMU_BW, ret = regmap_write(data->regmap, BMG160_REG_PMU_BW, bw_bits);
bw_bits);
if (ret < 0) { if (ret < 0) {
dev_err(&data->client->dev, "Error writing reg_pmu_bw\n"); dev_err(&data->client->dev, "Error writing reg_pmu_bw\n");
return ret; return ret;
...@@ -184,16 +190,17 @@ static int bmg160_set_bw(struct bmg160_data *data, int val) ...@@ -184,16 +190,17 @@ static int bmg160_set_bw(struct bmg160_data *data, int val)
static int bmg160_chip_init(struct bmg160_data *data) static int bmg160_chip_init(struct bmg160_data *data)
{ {
int ret; int ret;
unsigned int val;
ret = i2c_smbus_read_byte_data(data->client, BMG160_REG_CHIP_ID); ret = regmap_read(data->regmap, BMG160_REG_CHIP_ID, &val);
if (ret < 0) { if (ret < 0) {
dev_err(&data->client->dev, "Error reading reg_chip_id\n"); dev_err(&data->client->dev, "Error reading reg_chip_id\n");
return ret; return ret;
} }
dev_dbg(&data->client->dev, "Chip Id %x\n", ret); dev_dbg(&data->client->dev, "Chip Id %x\n", val);
if (ret != BMG160_CHIP_ID_VAL) { if (val != BMG160_CHIP_ID_VAL) {
dev_err(&data->client->dev, "invalid chip %x\n", ret); dev_err(&data->client->dev, "invalid chip %x\n", val);
return -ENODEV; return -ENODEV;
} }
...@@ -210,40 +217,31 @@ static int bmg160_chip_init(struct bmg160_data *data) ...@@ -210,40 +217,31 @@ static int bmg160_chip_init(struct bmg160_data *data)
return ret; return ret;
/* Set Default Range */ /* Set Default Range */
ret = i2c_smbus_write_byte_data(data->client, ret = regmap_write(data->regmap, BMG160_REG_RANGE, BMG160_RANGE_500DPS);
BMG160_REG_RANGE,
BMG160_RANGE_500DPS);
if (ret < 0) { if (ret < 0) {
dev_err(&data->client->dev, "Error writing reg_range\n"); dev_err(&data->client->dev, "Error writing reg_range\n");
return ret; return ret;
} }
data->dps_range = BMG160_RANGE_500DPS; data->dps_range = BMG160_RANGE_500DPS;
ret = i2c_smbus_read_byte_data(data->client, BMG160_REG_SLOPE_THRES); ret = regmap_read(data->regmap, BMG160_REG_SLOPE_THRES, &val);
if (ret < 0) { if (ret < 0) {
dev_err(&data->client->dev, "Error reading reg_slope_thres\n"); dev_err(&data->client->dev, "Error reading reg_slope_thres\n");
return ret; return ret;
} }
data->slope_thres = ret; data->slope_thres = val;
/* Set default interrupt mode */ /* Set default interrupt mode */
ret = i2c_smbus_read_byte_data(data->client, BMG160_REG_INT_EN_1); ret = regmap_update_bits(data->regmap, BMG160_REG_INT_EN_1,
if (ret < 0) { BMG160_INT1_BIT_OD, 0);
dev_err(&data->client->dev, "Error reading reg_int_en_1\n");
return ret;
}
ret &= ~BMG160_INT1_BIT_OD;
ret = i2c_smbus_write_byte_data(data->client,
BMG160_REG_INT_EN_1, ret);
if (ret < 0) { if (ret < 0) {
dev_err(&data->client->dev, "Error writing reg_int_en_1\n"); dev_err(&data->client->dev, "Error updating bits in reg_int_en_1\n");
return ret; return ret;
} }
ret = i2c_smbus_write_byte_data(data->client, ret = regmap_write(data->regmap, BMG160_REG_INT_RST_LATCH,
BMG160_REG_INT_RST_LATCH, BMG160_INT_MODE_LATCH_INT |
BMG160_INT_MODE_LATCH_INT | BMG160_INT_MODE_LATCH_RESET);
BMG160_INT_MODE_LATCH_RESET);
if (ret < 0) { if (ret < 0) {
dev_err(&data->client->dev, dev_err(&data->client->dev,
"Error writing reg_motion_intr\n"); "Error writing reg_motion_intr\n");
...@@ -284,41 +282,28 @@ static int bmg160_setup_any_motion_interrupt(struct bmg160_data *data, ...@@ -284,41 +282,28 @@ static int bmg160_setup_any_motion_interrupt(struct bmg160_data *data,
int ret; int ret;
/* Enable/Disable INT_MAP0 mapping */ /* Enable/Disable INT_MAP0 mapping */
ret = i2c_smbus_read_byte_data(data->client, BMG160_REG_INT_MAP_0); ret = regmap_update_bits(data->regmap, BMG160_REG_INT_MAP_0,
if (ret < 0) { BMG160_INT_MAP_0_BIT_ANY,
dev_err(&data->client->dev, "Error reading reg_int_map0\n"); (status ? BMG160_INT_MAP_0_BIT_ANY : 0));
return ret;
}
if (status)
ret |= BMG160_INT_MAP_0_BIT_ANY;
else
ret &= ~BMG160_INT_MAP_0_BIT_ANY;
ret = i2c_smbus_write_byte_data(data->client,
BMG160_REG_INT_MAP_0,
ret);
if (ret < 0) { if (ret < 0) {
dev_err(&data->client->dev, "Error writing reg_int_map0\n"); dev_err(&data->client->dev, "Error updating bits reg_int_map0\n");
return ret; return ret;
} }
/* Enable/Disable slope interrupts */ /* Enable/Disable slope interrupts */
if (status) { if (status) {
/* Update slope thres */ /* Update slope thres */
ret = i2c_smbus_write_byte_data(data->client, ret = regmap_write(data->regmap, BMG160_REG_SLOPE_THRES,
BMG160_REG_SLOPE_THRES, data->slope_thres);
data->slope_thres);
if (ret < 0) { if (ret < 0) {
dev_err(&data->client->dev, dev_err(&data->client->dev,
"Error writing reg_slope_thres\n"); "Error writing reg_slope_thres\n");
return ret; return ret;
} }
ret = i2c_smbus_write_byte_data(data->client, ret = regmap_write(data->regmap, BMG160_REG_MOTION_INTR,
BMG160_REG_MOTION_INTR, BMG160_INT_MOTION_X | BMG160_INT_MOTION_Y |
BMG160_INT_MOTION_X | BMG160_INT_MOTION_Z);
BMG160_INT_MOTION_Y |
BMG160_INT_MOTION_Z);
if (ret < 0) { if (ret < 0) {
dev_err(&data->client->dev, dev_err(&data->client->dev,
"Error writing reg_motion_intr\n"); "Error writing reg_motion_intr\n");
...@@ -331,10 +316,10 @@ static int bmg160_setup_any_motion_interrupt(struct bmg160_data *data, ...@@ -331,10 +316,10 @@ static int bmg160_setup_any_motion_interrupt(struct bmg160_data *data,
* to set latched mode, we will be flooded anyway with INTR * to set latched mode, we will be flooded anyway with INTR
*/ */
if (!data->dready_trigger_on) { if (!data->dready_trigger_on) {
ret = i2c_smbus_write_byte_data(data->client, ret = regmap_write(data->regmap,
BMG160_REG_INT_RST_LATCH, BMG160_REG_INT_RST_LATCH,
BMG160_INT_MODE_LATCH_INT | BMG160_INT_MODE_LATCH_INT |
BMG160_INT_MODE_LATCH_RESET); BMG160_INT_MODE_LATCH_RESET);
if (ret < 0) { if (ret < 0) {
dev_err(&data->client->dev, dev_err(&data->client->dev,
"Error writing reg_rst_latch\n"); "Error writing reg_rst_latch\n");
...@@ -342,14 +327,12 @@ static int bmg160_setup_any_motion_interrupt(struct bmg160_data *data, ...@@ -342,14 +327,12 @@ static int bmg160_setup_any_motion_interrupt(struct bmg160_data *data,
} }
} }
ret = i2c_smbus_write_byte_data(data->client, ret = regmap_write(data->regmap, BMG160_REG_INT_EN_0,
BMG160_REG_INT_EN_0, BMG160_DATA_ENABLE_INT);
BMG160_DATA_ENABLE_INT);
} else } else {
ret = i2c_smbus_write_byte_data(data->client, ret = regmap_write(data->regmap, BMG160_REG_INT_EN_0, 0);
BMG160_REG_INT_EN_0, }
0);
if (ret < 0) { if (ret < 0) {
dev_err(&data->client->dev, "Error writing reg_int_en0\n"); dev_err(&data->client->dev, "Error writing reg_int_en0\n");
...@@ -365,55 +348,39 @@ static int bmg160_setup_new_data_interrupt(struct bmg160_data *data, ...@@ -365,55 +348,39 @@ static int bmg160_setup_new_data_interrupt(struct bmg160_data *data,
int ret; int ret;
/* Enable/Disable INT_MAP1 mapping */ /* Enable/Disable INT_MAP1 mapping */
ret = i2c_smbus_read_byte_data(data->client, BMG160_REG_INT_MAP_1); ret = regmap_update_bits(data->regmap, BMG160_REG_INT_MAP_1,
if (ret < 0) { BMG160_INT_MAP_1_BIT_NEW_DATA,
dev_err(&data->client->dev, "Error reading reg_int_map1\n"); (status ? BMG160_INT_MAP_1_BIT_NEW_DATA : 0));
return ret;
}
if (status)
ret |= BMG160_INT_MAP_1_BIT_NEW_DATA;
else
ret &= ~BMG160_INT_MAP_1_BIT_NEW_DATA;
ret = i2c_smbus_write_byte_data(data->client,
BMG160_REG_INT_MAP_1,
ret);
if (ret < 0) { if (ret < 0) {
dev_err(&data->client->dev, "Error writing reg_int_map1\n"); dev_err(&data->client->dev, "Error updating bits in reg_int_map1\n");
return ret; return ret;
} }
if (status) { if (status) {
ret = i2c_smbus_write_byte_data(data->client, ret = regmap_write(data->regmap, BMG160_REG_INT_RST_LATCH,
BMG160_REG_INT_RST_LATCH, BMG160_INT_MODE_NON_LATCH_INT |
BMG160_INT_MODE_NON_LATCH_INT | BMG160_INT_MODE_LATCH_RESET);
BMG160_INT_MODE_LATCH_RESET);
if (ret < 0) { if (ret < 0) {
dev_err(&data->client->dev, dev_err(&data->client->dev,
"Error writing reg_rst_latch\n"); "Error writing reg_rst_latch\n");
return ret; return ret;
} }
ret = i2c_smbus_write_byte_data(data->client, ret = regmap_write(data->regmap, BMG160_REG_INT_EN_0,
BMG160_REG_INT_EN_0, BMG160_DATA_ENABLE_INT);
BMG160_DATA_ENABLE_INT);
} else { } else {
/* Restore interrupt mode */ /* Restore interrupt mode */
ret = i2c_smbus_write_byte_data(data->client, ret = regmap_write(data->regmap, BMG160_REG_INT_RST_LATCH,
BMG160_REG_INT_RST_LATCH, BMG160_INT_MODE_LATCH_INT |
BMG160_INT_MODE_LATCH_INT | BMG160_INT_MODE_LATCH_RESET);
BMG160_INT_MODE_LATCH_RESET);
if (ret < 0) { if (ret < 0) {
dev_err(&data->client->dev, dev_err(&data->client->dev,
"Error writing reg_rst_latch\n"); "Error writing reg_rst_latch\n");
return ret; return ret;
} }
ret = i2c_smbus_write_byte_data(data->client, ret = regmap_write(data->regmap, BMG160_REG_INT_EN_0, 0);
BMG160_REG_INT_EN_0,
0);
} }
if (ret < 0) { if (ret < 0) {
...@@ -444,10 +411,8 @@ static int bmg160_set_scale(struct bmg160_data *data, int val) ...@@ -444,10 +411,8 @@ static int bmg160_set_scale(struct bmg160_data *data, int val)
for (i = 0; i < ARRAY_SIZE(bmg160_scale_table); ++i) { for (i = 0; i < ARRAY_SIZE(bmg160_scale_table); ++i) {
if (bmg160_scale_table[i].scale == val) { if (bmg160_scale_table[i].scale == val) {
ret = i2c_smbus_write_byte_data( ret = regmap_write(data->regmap, BMG160_REG_RANGE,
data->client, bmg160_scale_table[i].dps_range);
BMG160_REG_RANGE,
bmg160_scale_table[i].dps_range);
if (ret < 0) { if (ret < 0) {
dev_err(&data->client->dev, dev_err(&data->client->dev,
"Error writing reg_range\n"); "Error writing reg_range\n");
...@@ -464,6 +429,7 @@ static int bmg160_set_scale(struct bmg160_data *data, int val) ...@@ -464,6 +429,7 @@ static int bmg160_set_scale(struct bmg160_data *data, int val)
static int bmg160_get_temp(struct bmg160_data *data, int *val) static int bmg160_get_temp(struct bmg160_data *data, int *val)
{ {
int ret; int ret;
unsigned int raw_val;
mutex_lock(&data->mutex); mutex_lock(&data->mutex);
ret = bmg160_set_power_state(data, true); ret = bmg160_set_power_state(data, true);
...@@ -472,7 +438,7 @@ static int bmg160_get_temp(struct bmg160_data *data, int *val) ...@@ -472,7 +438,7 @@ static int bmg160_get_temp(struct bmg160_data *data, int *val)
return ret; return ret;
} }
ret = i2c_smbus_read_byte_data(data->client, BMG160_REG_TEMP); ret = regmap_read(data->regmap, BMG160_REG_TEMP, &raw_val);
if (ret < 0) { if (ret < 0) {
dev_err(&data->client->dev, "Error reading reg_temp\n"); dev_err(&data->client->dev, "Error reading reg_temp\n");
bmg160_set_power_state(data, false); bmg160_set_power_state(data, false);
...@@ -480,7 +446,7 @@ static int bmg160_get_temp(struct bmg160_data *data, int *val) ...@@ -480,7 +446,7 @@ static int bmg160_get_temp(struct bmg160_data *data, int *val)
return ret; return ret;
} }
*val = sign_extend32(ret, 7); *val = sign_extend32(raw_val, 7);
ret = bmg160_set_power_state(data, false); ret = bmg160_set_power_state(data, false);
mutex_unlock(&data->mutex); mutex_unlock(&data->mutex);
if (ret < 0) if (ret < 0)
...@@ -492,6 +458,7 @@ static int bmg160_get_temp(struct bmg160_data *data, int *val) ...@@ -492,6 +458,7 @@ static int bmg160_get_temp(struct bmg160_data *data, int *val)
static int bmg160_get_axis(struct bmg160_data *data, int axis, int *val) static int bmg160_get_axis(struct bmg160_data *data, int axis, int *val)
{ {
int ret; int ret;
unsigned int raw_val;
mutex_lock(&data->mutex); mutex_lock(&data->mutex);
ret = bmg160_set_power_state(data, true); ret = bmg160_set_power_state(data, true);
...@@ -500,7 +467,8 @@ static int bmg160_get_axis(struct bmg160_data *data, int axis, int *val) ...@@ -500,7 +467,8 @@ static int bmg160_get_axis(struct bmg160_data *data, int axis, int *val)
return ret; return ret;
} }
ret = i2c_smbus_read_word_data(data->client, BMG160_AXIS_TO_REG(axis)); ret = regmap_bulk_read(data->regmap, BMG160_AXIS_TO_REG(axis), &raw_val,
2);
if (ret < 0) { if (ret < 0) {
dev_err(&data->client->dev, "Error reading axis %d\n", axis); dev_err(&data->client->dev, "Error reading axis %d\n", axis);
bmg160_set_power_state(data, false); bmg160_set_power_state(data, false);
...@@ -508,7 +476,7 @@ static int bmg160_get_axis(struct bmg160_data *data, int axis, int *val) ...@@ -508,7 +476,7 @@ static int bmg160_get_axis(struct bmg160_data *data, int axis, int *val)
return ret; return ret;
} }
*val = sign_extend32(ret, 15); *val = sign_extend32(raw_val, 15);
ret = bmg160_set_power_state(data, false); ret = bmg160_set_power_state(data, false);
mutex_unlock(&data->mutex); mutex_unlock(&data->mutex);
if (ret < 0) if (ret < 0)
...@@ -807,12 +775,13 @@ static irqreturn_t bmg160_trigger_handler(int irq, void *p) ...@@ -807,12 +775,13 @@ static irqreturn_t bmg160_trigger_handler(int irq, void *p)
struct iio_dev *indio_dev = pf->indio_dev; struct iio_dev *indio_dev = pf->indio_dev;
struct bmg160_data *data = iio_priv(indio_dev); struct bmg160_data *data = iio_priv(indio_dev);
int bit, ret, i = 0; int bit, ret, i = 0;
unsigned int val;
mutex_lock(&data->mutex); mutex_lock(&data->mutex);
for_each_set_bit(bit, indio_dev->active_scan_mask, for_each_set_bit(bit, indio_dev->active_scan_mask,
indio_dev->masklength) { indio_dev->masklength) {
ret = i2c_smbus_read_word_data(data->client, ret = regmap_bulk_read(data->regmap, BMG160_AXIS_TO_REG(bit),
BMG160_AXIS_TO_REG(bit)); &val, 2);
if (ret < 0) { if (ret < 0) {
mutex_unlock(&data->mutex); mutex_unlock(&data->mutex);
goto err; goto err;
...@@ -840,10 +809,9 @@ static int bmg160_trig_try_reen(struct iio_trigger *trig) ...@@ -840,10 +809,9 @@ static int bmg160_trig_try_reen(struct iio_trigger *trig)
return 0; return 0;
/* Set latched mode interrupt and clear any latched interrupt */ /* Set latched mode interrupt and clear any latched interrupt */
ret = i2c_smbus_write_byte_data(data->client, ret = regmap_write(data->regmap, BMG160_REG_INT_RST_LATCH,
BMG160_REG_INT_RST_LATCH, BMG160_INT_MODE_LATCH_INT |
BMG160_INT_MODE_LATCH_INT | BMG160_INT_MODE_LATCH_RESET);
BMG160_INT_MODE_LATCH_RESET);
if (ret < 0) { if (ret < 0) {
dev_err(&data->client->dev, "Error writing reg_rst_latch\n"); dev_err(&data->client->dev, "Error writing reg_rst_latch\n");
return ret; return ret;
...@@ -907,33 +875,34 @@ static irqreturn_t bmg160_event_handler(int irq, void *private) ...@@ -907,33 +875,34 @@ static irqreturn_t bmg160_event_handler(int irq, void *private)
struct bmg160_data *data = iio_priv(indio_dev); struct bmg160_data *data = iio_priv(indio_dev);
int ret; int ret;
int dir; int dir;
unsigned int val;
ret = i2c_smbus_read_byte_data(data->client, BMG160_REG_INT_STATUS_2); ret = regmap_read(data->regmap, BMG160_REG_INT_STATUS_2, &val);
if (ret < 0) { if (ret < 0) {
dev_err(&data->client->dev, "Error reading reg_int_status2\n"); dev_err(&data->client->dev, "Error reading reg_int_status2\n");
goto ack_intr_status; goto ack_intr_status;
} }
if (ret & 0x08) if (val & 0x08)
dir = IIO_EV_DIR_RISING; dir = IIO_EV_DIR_RISING;
else else
dir = IIO_EV_DIR_FALLING; dir = IIO_EV_DIR_FALLING;
if (ret & BMG160_ANY_MOTION_BIT_X) if (val & BMG160_ANY_MOTION_BIT_X)
iio_push_event(indio_dev, IIO_MOD_EVENT_CODE(IIO_ANGL_VEL, iio_push_event(indio_dev, IIO_MOD_EVENT_CODE(IIO_ANGL_VEL,
0, 0,
IIO_MOD_X, IIO_MOD_X,
IIO_EV_TYPE_ROC, IIO_EV_TYPE_ROC,
dir), dir),
iio_get_time_ns()); iio_get_time_ns());
if (ret & BMG160_ANY_MOTION_BIT_Y) if (val & BMG160_ANY_MOTION_BIT_Y)
iio_push_event(indio_dev, IIO_MOD_EVENT_CODE(IIO_ANGL_VEL, iio_push_event(indio_dev, IIO_MOD_EVENT_CODE(IIO_ANGL_VEL,
0, 0,
IIO_MOD_Y, IIO_MOD_Y,
IIO_EV_TYPE_ROC, IIO_EV_TYPE_ROC,
dir), dir),
iio_get_time_ns()); iio_get_time_ns());
if (ret & BMG160_ANY_MOTION_BIT_Z) if (val & BMG160_ANY_MOTION_BIT_Z)
iio_push_event(indio_dev, IIO_MOD_EVENT_CODE(IIO_ANGL_VEL, iio_push_event(indio_dev, IIO_MOD_EVENT_CODE(IIO_ANGL_VEL,
0, 0,
IIO_MOD_Z, IIO_MOD_Z,
...@@ -943,10 +912,9 @@ static irqreturn_t bmg160_event_handler(int irq, void *private) ...@@ -943,10 +912,9 @@ static irqreturn_t bmg160_event_handler(int irq, void *private)
ack_intr_status: ack_intr_status:
if (!data->dready_trigger_on) { if (!data->dready_trigger_on) {
ret = i2c_smbus_write_byte_data(data->client, ret = regmap_write(data->regmap, BMG160_REG_INT_RST_LATCH,
BMG160_REG_INT_RST_LATCH, BMG160_INT_MODE_LATCH_INT |
BMG160_INT_MODE_LATCH_INT | BMG160_INT_MODE_LATCH_RESET);
BMG160_INT_MODE_LATCH_RESET);
if (ret < 0) if (ret < 0)
dev_err(&data->client->dev, dev_err(&data->client->dev,
"Error writing reg_rst_latch\n"); "Error writing reg_rst_latch\n");
...@@ -1038,6 +1006,14 @@ static int bmg160_probe(struct i2c_client *client, ...@@ -1038,6 +1006,14 @@ static int bmg160_probe(struct i2c_client *client,
struct iio_dev *indio_dev; struct iio_dev *indio_dev;
int ret; int ret;
const char *name = NULL; const char *name = NULL;
struct regmap *regmap;
regmap = devm_regmap_init_i2c(client, &bmg160_regmap_i2c_conf);
if (IS_ERR(regmap)) {
dev_err(&client->dev, "Failed to register i2c regmap %d\n",
(int)PTR_ERR(regmap));
return PTR_ERR(regmap);
}
indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data)); indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
if (!indio_dev) if (!indio_dev)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment