diff options
Diffstat (limited to 'drivers/iio/magnetometer')
-rw-r--r-- | drivers/iio/magnetometer/Kconfig | 1 | ||||
-rw-r--r-- | drivers/iio/magnetometer/bmc150_magn.c | 99 | ||||
-rw-r--r-- | drivers/iio/magnetometer/mmc35240.c | 45 | ||||
-rw-r--r-- | drivers/iio/magnetometer/st_magn.h | 3 | ||||
-rw-r--r-- | drivers/iio/magnetometer/st_magn_buffer.c | 7 | ||||
-rw-r--r-- | drivers/iio/magnetometer/st_magn_core.c | 98 | ||||
-rw-r--r-- | drivers/iio/magnetometer/st_magn_i2c.c | 6 | ||||
-rw-r--r-- | drivers/iio/magnetometer/st_magn_spi.c | 1 |
8 files changed, 195 insertions, 65 deletions
diff --git a/drivers/iio/magnetometer/Kconfig b/drivers/iio/magnetometer/Kconfig index dcadfc4f0661..efb9350b0d76 100644 --- a/drivers/iio/magnetometer/Kconfig +++ b/drivers/iio/magnetometer/Kconfig @@ -90,6 +90,7 @@ config IIO_ST_MAGN_SPI_3AXIS config BMC150_MAGN tristate "Bosch BMC150 Magnetometer Driver" depends on I2C + select REGMAP_I2C select IIO_BUFFER select IIO_TRIGGERED_BUFFER help diff --git a/drivers/iio/magnetometer/bmc150_magn.c b/drivers/iio/magnetometer/bmc150_magn.c index d4c178869991..e330205f8194 100644 --- a/drivers/iio/magnetometer/bmc150_magn.c +++ b/drivers/iio/magnetometer/bmc150_magn.c @@ -85,6 +85,7 @@ #define BMC150_MAGN_REG_HIGH_THRESH 0x50 #define BMC150_MAGN_REG_REP_XY 0x51 #define BMC150_MAGN_REG_REP_Z 0x52 +#define BMC150_MAGN_REG_REP_DATAMASK GENMASK(7, 0) #define BMC150_MAGN_REG_TRIM_START 0x5D #define BMC150_MAGN_REG_TRIM_END 0x71 @@ -559,7 +560,7 @@ static int bmc150_magn_write_raw(struct iio_dev *indio_dev, } ret = regmap_update_bits(data->regmap, BMC150_MAGN_REG_REP_XY, - 0xFF, + BMC150_MAGN_REG_REP_DATAMASK, BMC150_MAGN_REPXY_TO_REGVAL (val)); mutex_unlock(&data->mutex); @@ -575,7 +576,7 @@ static int bmc150_magn_write_raw(struct iio_dev *indio_dev, } ret = regmap_update_bits(data->regmap, BMC150_MAGN_REG_REP_Z, - 0xFF, + BMC150_MAGN_REG_REP_DATAMASK, BMC150_MAGN_REPZ_TO_REGVAL (val)); mutex_unlock(&data->mutex); @@ -588,17 +589,6 @@ static int bmc150_magn_write_raw(struct iio_dev *indio_dev, } } -static int bmc150_magn_validate_trigger(struct iio_dev *indio_dev, - struct iio_trigger *trig) -{ - struct bmc150_magn_data *data = iio_priv(indio_dev); - - if (data->dready_trig != trig) - return -EINVAL; - - return 0; -} - static ssize_t bmc150_magn_show_samp_freq_avail(struct device *dev, struct device_attribute *attr, char *buf) @@ -659,11 +649,12 @@ static const struct iio_info bmc150_magn_info = { .attrs = &bmc150_magn_attrs_group, .read_raw = bmc150_magn_read_raw, .write_raw = bmc150_magn_write_raw, - .validate_trigger = bmc150_magn_validate_trigger, .driver_module = THIS_MODULE, }; -static const unsigned long bmc150_magn_scan_masks[] = {0x07, 0}; +static const unsigned long bmc150_magn_scan_masks[] = { + BIT(AXIS_X) | BIT(AXIS_Y) | BIT(AXIS_Z), + 0}; static irqreturn_t bmc150_magn_trigger_handler(int irq, void *p) { @@ -674,7 +665,6 @@ static irqreturn_t bmc150_magn_trigger_handler(int irq, void *p) mutex_lock(&data->mutex); ret = bmc150_magn_read_xyz(data, data->buffer); - mutex_unlock(&data->mutex); if (ret < 0) goto err; @@ -682,7 +672,8 @@ static irqreturn_t bmc150_magn_trigger_handler(int irq, void *p) pf->timestamp); err: - iio_trigger_notify_done(data->dready_trig); + mutex_unlock(&data->mutex); + iio_trigger_notify_done(indio_dev->trig); return IRQ_HANDLED; } @@ -706,11 +697,11 @@ static int bmc150_magn_init(struct bmc150_magn_data *data) goto err_poweroff; } if (chip_id != BMC150_MAGN_CHIP_ID_VAL) { - dev_err(&data->client->dev, "Invalid chip id 0x%x\n", ret); + dev_err(&data->client->dev, "Invalid chip id 0x%x\n", chip_id); ret = -ENODEV; goto err_poweroff; } - dev_dbg(&data->client->dev, "Chip id %x\n", ret); + dev_dbg(&data->client->dev, "Chip id %x\n", chip_id); preset = bmc150_magn_presets_table[BMC150_MAGN_DEFAULT_PRESET]; ret = bmc150_magn_set_odr(data, preset.odr); @@ -793,29 +784,23 @@ static int bmc150_magn_data_rdy_trigger_set_state(struct iio_trigger *trig, if (state == data->dready_trigger_on) goto err_unlock; - ret = bmc150_magn_set_power_state(data, state); - if (ret < 0) - goto err_unlock; - ret = regmap_update_bits(data->regmap, BMC150_MAGN_REG_INT_DRDY, BMC150_MAGN_MASK_DRDY_EN, state << BMC150_MAGN_SHIFT_DRDY_EN); if (ret < 0) - goto err_poweroff; + goto err_unlock; data->dready_trigger_on = state; if (state) { ret = bmc150_magn_reset_intr(data); if (ret < 0) - goto err_poweroff; + goto err_unlock; } mutex_unlock(&data->mutex); return 0; -err_poweroff: - bmc150_magn_set_power_state(data, false); err_unlock: mutex_unlock(&data->mutex); return ret; @@ -827,6 +812,27 @@ static const struct iio_trigger_ops bmc150_magn_trigger_ops = { .owner = THIS_MODULE, }; +static int bmc150_magn_buffer_preenable(struct iio_dev *indio_dev) +{ + struct bmc150_magn_data *data = iio_priv(indio_dev); + + return bmc150_magn_set_power_state(data, true); +} + +static int bmc150_magn_buffer_postdisable(struct iio_dev *indio_dev) +{ + struct bmc150_magn_data *data = iio_priv(indio_dev); + + return bmc150_magn_set_power_state(data, false); +} + +static const struct iio_buffer_setup_ops bmc150_magn_buffer_setup_ops = { + .preenable = bmc150_magn_buffer_preenable, + .postenable = iio_triggered_buffer_postenable, + .predisable = iio_triggered_buffer_predisable, + .postdisable = bmc150_magn_buffer_postdisable, +}; + static int bmc150_magn_gpio_probe(struct i2c_client *client) { struct device *dev; @@ -932,16 +938,6 @@ static int bmc150_magn_probe(struct i2c_client *client, goto err_poweroff; } - ret = iio_triggered_buffer_setup(indio_dev, - &iio_pollfunc_store_time, - bmc150_magn_trigger_handler, - NULL); - if (ret < 0) { - dev_err(&client->dev, - "iio triggered buffer setup failed\n"); - goto err_trigger_unregister; - } - ret = request_threaded_irq(client->irq, iio_trigger_generic_data_rdy_poll, NULL, @@ -951,14 +947,24 @@ static int bmc150_magn_probe(struct i2c_client *client, if (ret < 0) { dev_err(&client->dev, "request irq %d failed\n", client->irq); - goto err_buffer_cleanup; + goto err_trigger_unregister; } } + ret = iio_triggered_buffer_setup(indio_dev, + iio_pollfunc_store_time, + bmc150_magn_trigger_handler, + &bmc150_magn_buffer_setup_ops); + if (ret < 0) { + dev_err(&client->dev, + "iio triggered buffer setup failed\n"); + goto err_free_irq; + } + ret = iio_device_register(indio_dev); if (ret < 0) { dev_err(&client->dev, "unable to register iio device\n"); - goto err_free_irq; + goto err_buffer_cleanup; } ret = pm_runtime_set_active(&client->dev); @@ -976,12 +982,11 @@ static int bmc150_magn_probe(struct i2c_client *client, err_iio_unregister: iio_device_unregister(indio_dev); +err_buffer_cleanup: + iio_triggered_buffer_cleanup(indio_dev); err_free_irq: if (client->irq > 0) free_irq(client->irq, data->dready_trig); -err_buffer_cleanup: - if (data->dready_trig) - iio_triggered_buffer_cleanup(indio_dev); err_trigger_unregister: if (data->dready_trig) iio_trigger_unregister(data->dready_trig); @@ -1000,14 +1005,13 @@ static int bmc150_magn_remove(struct i2c_client *client) pm_runtime_put_noidle(&client->dev); iio_device_unregister(indio_dev); + iio_triggered_buffer_cleanup(indio_dev); if (client->irq > 0) free_irq(data->client->irq, data->dready_trig); - if (data->dready_trig) { - iio_triggered_buffer_cleanup(indio_dev); + if (data->dready_trig) iio_trigger_unregister(data->dready_trig); - } mutex_lock(&data->mutex); bmc150_magn_set_power_mode(data, BMC150_MAGN_POWER_MODE_SUSPEND, true); @@ -1034,6 +1038,9 @@ static int bmc150_magn_runtime_suspend(struct device *dev) return 0; } +/* + * Should be called with data->mutex held. + */ static int bmc150_magn_runtime_resume(struct device *dev) { struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev)); @@ -1082,12 +1089,14 @@ static const struct dev_pm_ops bmc150_magn_pm_ops = { static const struct acpi_device_id bmc150_magn_acpi_match[] = { {"BMC150B", 0}, + {"BMC156B", 0}, {}, }; MODULE_DEVICE_TABLE(acpi, bmc150_magn_acpi_match); static const struct i2c_device_id bmc150_magn_id[] = { {"bmc150_magn", 0}, + {"bmc156_magn", 0}, {}, }; MODULE_DEVICE_TABLE(i2c, bmc150_magn_id); diff --git a/drivers/iio/magnetometer/mmc35240.c b/drivers/iio/magnetometer/mmc35240.c index d927397a6ef7..176e14a61558 100644 --- a/drivers/iio/magnetometer/mmc35240.c +++ b/drivers/iio/magnetometer/mmc35240.c @@ -202,8 +202,8 @@ static int mmc35240_hw_set(struct mmc35240_data *data, bool set) coil_bit = MMC35240_CTRL0_RESET_BIT; return regmap_update_bits(data->regmap, MMC35240_REG_CTRL0, - MMC35240_CTRL0_REFILL_BIT, - coil_bit); + coil_bit, coil_bit); + } static int mmc35240_init(struct mmc35240_data *data) @@ -222,14 +222,15 @@ static int mmc35240_init(struct mmc35240_data *data) /* * make sure we restore sensor characteristics, by doing - * a RESET/SET sequence + * a SET/RESET sequence, the axis polarity being naturally + * aligned after RESET */ - ret = mmc35240_hw_set(data, false); + ret = mmc35240_hw_set(data, true); if (ret < 0) return ret; usleep_range(MMC53240_WAIT_SET_RESET, MMC53240_WAIT_SET_RESET + 1); - ret = mmc35240_hw_set(data, true); + ret = mmc35240_hw_set(data, false); if (ret < 0) return ret; @@ -315,31 +316,31 @@ static int mmc35240_read_measurement(struct mmc35240_data *data, __le16 buf[3]) static int mmc35240_raw_to_mgauss(struct mmc35240_data *data, int index, __le16 buf[], int *val) { - int raw_x, raw_y, raw_z; - int sens_x, sens_y, sens_z; + int raw[3]; + int sens[3]; int nfo; - raw_x = le16_to_cpu(buf[AXIS_X]); - raw_y = le16_to_cpu(buf[AXIS_Y]); - raw_z = le16_to_cpu(buf[AXIS_Z]); + raw[AXIS_X] = le16_to_cpu(buf[AXIS_X]); + raw[AXIS_Y] = le16_to_cpu(buf[AXIS_Y]); + raw[AXIS_Z] = le16_to_cpu(buf[AXIS_Z]); - sens_x = mmc35240_props_table[data->res].sens[AXIS_X]; - sens_y = mmc35240_props_table[data->res].sens[AXIS_Y]; - sens_z = mmc35240_props_table[data->res].sens[AXIS_Z]; + sens[AXIS_X] = mmc35240_props_table[data->res].sens[AXIS_X]; + sens[AXIS_Y] = mmc35240_props_table[data->res].sens[AXIS_Y]; + sens[AXIS_Z] = mmc35240_props_table[data->res].sens[AXIS_Z]; nfo = mmc35240_props_table[data->res].nfo; switch (index) { case AXIS_X: - *val = (raw_x - nfo) * 1000 / sens_x; + *val = (raw[AXIS_X] - nfo) * 1000 / sens[AXIS_X]; break; case AXIS_Y: - *val = (raw_y - nfo) * 1000 / sens_y - - (raw_z - nfo) * 1000 / sens_z; + *val = (raw[AXIS_Y] - nfo) * 1000 / sens[AXIS_Y] - + (raw[AXIS_Z] - nfo) * 1000 / sens[AXIS_Z]; break; case AXIS_Z: - *val = (raw_y - nfo) * 1000 / sens_y + - (raw_z - nfo) * 1000 / sens_z; + *val = (raw[AXIS_Y] - nfo) * 1000 / sens[AXIS_Y] + + (raw[AXIS_Z] - nfo) * 1000 / sens[AXIS_Z]; break; default: return -EINVAL; @@ -503,6 +504,7 @@ static int mmc35240_probe(struct i2c_client *client, } data = iio_priv(indio_dev); + i2c_set_clientdata(client, indio_dev); data->client = client; data->regmap = regmap; data->res = MMC35240_16_BITS_SLOW; @@ -557,6 +559,12 @@ static const struct dev_pm_ops mmc35240_pm_ops = { SET_SYSTEM_SLEEP_PM_OPS(mmc35240_suspend, mmc35240_resume) }; +static const struct of_device_id mmc35240_of_match[] = { + { .compatible = "memsic,mmc35240", }, + { } +}; +MODULE_DEVICE_TABLE(of, mmc35240_of_match); + static const struct acpi_device_id mmc35240_acpi_match[] = { {"MMC35240", 0}, { }, @@ -572,6 +580,7 @@ MODULE_DEVICE_TABLE(i2c, mmc35240_id); static struct i2c_driver mmc35240_driver = { .driver = { .name = MMC35240_DRV_NAME, + .of_match_table = mmc35240_of_match, .pm = &mmc35240_pm_ops, .acpi_match_table = ACPI_PTR(mmc35240_acpi_match), }, diff --git a/drivers/iio/magnetometer/st_magn.h b/drivers/iio/magnetometer/st_magn.h index 287691ca56c1..06a4d9c35581 100644 --- a/drivers/iio/magnetometer/st_magn.h +++ b/drivers/iio/magnetometer/st_magn.h @@ -18,6 +18,7 @@ #define LSM303DLHC_MAGN_DEV_NAME "lsm303dlhc_magn" #define LSM303DLM_MAGN_DEV_NAME "lsm303dlm_magn" #define LIS3MDL_MAGN_DEV_NAME "lis3mdl" +#define LSM303AGR_MAGN_DEV_NAME "lsm303agr_magn" int st_magn_common_probe(struct iio_dev *indio_dev); void st_magn_common_remove(struct iio_dev *indio_dev); @@ -25,6 +26,8 @@ void st_magn_common_remove(struct iio_dev *indio_dev); #ifdef CONFIG_IIO_BUFFER int st_magn_allocate_ring(struct iio_dev *indio_dev); void st_magn_deallocate_ring(struct iio_dev *indio_dev); +int st_magn_trig_set_state(struct iio_trigger *trig, bool state); +#define ST_MAGN_TRIGGER_SET_STATE (&st_magn_trig_set_state) #else /* CONFIG_IIO_BUFFER */ static inline int st_magn_probe_trigger(struct iio_dev *indio_dev, int irq) { diff --git a/drivers/iio/magnetometer/st_magn_buffer.c b/drivers/iio/magnetometer/st_magn_buffer.c index bf427dc0d226..ecd3bd0a9769 100644 --- a/drivers/iio/magnetometer/st_magn_buffer.c +++ b/drivers/iio/magnetometer/st_magn_buffer.c @@ -23,6 +23,13 @@ #include <linux/iio/common/st_sensors.h> #include "st_magn.h" +int st_magn_trig_set_state(struct iio_trigger *trig, bool state) +{ + struct iio_dev *indio_dev = iio_trigger_get_drvdata(trig); + + return st_sensors_set_dataready_irq(indio_dev, state); +} + static int st_magn_buffer_preenable(struct iio_dev *indio_dev) { return st_sensors_set_enable(indio_dev, true); diff --git a/drivers/iio/magnetometer/st_magn_core.c b/drivers/iio/magnetometer/st_magn_core.c index b4bcfb790f49..f8dc4b85d70c 100644 --- a/drivers/iio/magnetometer/st_magn_core.c +++ b/drivers/iio/magnetometer/st_magn_core.c @@ -43,6 +43,7 @@ #define ST_MAGN_FS_AVL_8000MG 8000 #define ST_MAGN_FS_AVL_8100MG 8100 #define ST_MAGN_FS_AVL_12000MG 12000 +#define ST_MAGN_FS_AVL_15000MG 15000 #define ST_MAGN_FS_AVL_16000MG 16000 /* CUSTOM VALUES FOR SENSOR 0 */ @@ -157,6 +158,29 @@ #define ST_MAGN_2_OUT_Y_L_ADDR 0x2a #define ST_MAGN_2_OUT_Z_L_ADDR 0x2c +/* CUSTOM VALUES FOR SENSOR 3 */ +#define ST_MAGN_3_WAI_ADDR 0x4f +#define ST_MAGN_3_WAI_EXP 0x40 +#define ST_MAGN_3_ODR_ADDR 0x60 +#define ST_MAGN_3_ODR_MASK 0x0c +#define ST_MAGN_3_ODR_AVL_10HZ_VAL 0x00 +#define ST_MAGN_3_ODR_AVL_20HZ_VAL 0x01 +#define ST_MAGN_3_ODR_AVL_50HZ_VAL 0x02 +#define ST_MAGN_3_ODR_AVL_100HZ_VAL 0x03 +#define ST_MAGN_3_PW_ADDR 0x60 +#define ST_MAGN_3_PW_MASK 0x03 +#define ST_MAGN_3_PW_ON 0x00 +#define ST_MAGN_3_PW_OFF 0x03 +#define ST_MAGN_3_BDU_ADDR 0x62 +#define ST_MAGN_3_BDU_MASK 0x10 +#define ST_MAGN_3_DRDY_IRQ_ADDR 0x62 +#define ST_MAGN_3_DRDY_INT_MASK 0x01 +#define ST_MAGN_3_FS_AVL_15000_GAIN 1500 +#define ST_MAGN_3_MULTIREAD_BIT false +#define ST_MAGN_3_OUT_X_L_ADDR 0x68 +#define ST_MAGN_3_OUT_Y_L_ADDR 0x6a +#define ST_MAGN_3_OUT_Z_L_ADDR 0x6c + static const struct iio_chan_spec st_magn_16bit_channels[] = { ST_SENSORS_LSM_CHANNELS(IIO_MAGN, BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE), @@ -189,9 +213,26 @@ static const struct iio_chan_spec st_magn_2_16bit_channels[] = { IIO_CHAN_SOFT_TIMESTAMP(3) }; +static const struct iio_chan_spec st_magn_3_16bit_channels[] = { + ST_SENSORS_LSM_CHANNELS(IIO_MAGN, + BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE), + ST_SENSORS_SCAN_X, 1, IIO_MOD_X, 's', IIO_LE, 16, 16, + ST_MAGN_3_OUT_X_L_ADDR), + ST_SENSORS_LSM_CHANNELS(IIO_MAGN, + BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE), + ST_SENSORS_SCAN_Y, 1, IIO_MOD_Y, 's', IIO_LE, 16, 16, + ST_MAGN_3_OUT_Y_L_ADDR), + ST_SENSORS_LSM_CHANNELS(IIO_MAGN, + BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE), + ST_SENSORS_SCAN_Z, 1, IIO_MOD_Z, 's', IIO_LE, 16, 16, + ST_MAGN_3_OUT_Z_L_ADDR), + IIO_CHAN_SOFT_TIMESTAMP(3) +}; + static const struct st_sensor_settings st_magn_sensors_settings[] = { { .wai = 0, /* This sensor has no valid WhoAmI report 0 */ + .wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS, .sensors_supported = { [0] = LSM303DLH_MAGN_DEV_NAME, }, @@ -268,6 +309,7 @@ static const struct st_sensor_settings st_magn_sensors_settings[] = { }, { .wai = ST_MAGN_1_WAI_EXP, + .wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS, .sensors_supported = { [0] = LSM303DLHC_MAGN_DEV_NAME, [1] = LSM303DLM_MAGN_DEV_NAME, @@ -346,6 +388,7 @@ static const struct st_sensor_settings st_magn_sensors_settings[] = { }, { .wai = ST_MAGN_2_WAI_EXP, + .wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS, .sensors_supported = { [0] = LIS3MDL_MAGN_DEV_NAME, }, @@ -399,6 +442,48 @@ static const struct st_sensor_settings st_magn_sensors_settings[] = { .multi_read_bit = ST_MAGN_2_MULTIREAD_BIT, .bootime = 2, }, + { + .wai = ST_MAGN_3_WAI_EXP, + .wai_addr = ST_MAGN_3_WAI_ADDR, + .sensors_supported = { + [0] = LSM303AGR_MAGN_DEV_NAME, + }, + .ch = (struct iio_chan_spec *)st_magn_3_16bit_channels, + .odr = { + .addr = ST_MAGN_3_ODR_ADDR, + .mask = ST_MAGN_3_ODR_MASK, + .odr_avl = { + { 10, ST_MAGN_3_ODR_AVL_10HZ_VAL, }, + { 20, ST_MAGN_3_ODR_AVL_20HZ_VAL, }, + { 50, ST_MAGN_3_ODR_AVL_50HZ_VAL, }, + { 100, ST_MAGN_3_ODR_AVL_100HZ_VAL, }, + }, + }, + .pw = { + .addr = ST_MAGN_3_PW_ADDR, + .mask = ST_MAGN_3_PW_MASK, + .value_on = ST_MAGN_3_PW_ON, + .value_off = ST_MAGN_3_PW_OFF, + }, + .fs = { + .fs_avl = { + [0] = { + .num = ST_MAGN_FS_AVL_15000MG, + .gain = ST_MAGN_3_FS_AVL_15000_GAIN, + }, + }, + }, + .bdu = { + .addr = ST_MAGN_3_BDU_ADDR, + .mask = ST_MAGN_3_BDU_MASK, + }, + .drdy_irq = { + .addr = ST_MAGN_3_DRDY_IRQ_ADDR, + .mask_int1 = ST_MAGN_3_DRDY_INT_MASK, + }, + .multi_read_bit = ST_MAGN_3_MULTIREAD_BIT, + .bootime = 2, + }, }; static int st_magn_read_raw(struct iio_dev *indio_dev, @@ -477,6 +562,16 @@ static const struct iio_info magn_info = { .write_raw = &st_magn_write_raw, }; +#ifdef CONFIG_IIO_TRIGGER +static const struct iio_trigger_ops st_magn_trigger_ops = { + .owner = THIS_MODULE, + .set_trigger_state = ST_MAGN_TRIGGER_SET_STATE, +}; +#define ST_MAGN_TRIGGER_OPS (&st_magn_trigger_ops) +#else +#define ST_MAGN_TRIGGER_OPS NULL +#endif + int st_magn_common_probe(struct iio_dev *indio_dev) { struct st_sensor_data *mdata = iio_priv(indio_dev); @@ -513,7 +608,8 @@ int st_magn_common_probe(struct iio_dev *indio_dev) return err; if (irq > 0) { - err = st_sensors_allocate_trigger(indio_dev, NULL); + err = st_sensors_allocate_trigger(indio_dev, + ST_MAGN_TRIGGER_OPS); if (err < 0) goto st_magn_probe_trigger_error; } diff --git a/drivers/iio/magnetometer/st_magn_i2c.c b/drivers/iio/magnetometer/st_magn_i2c.c index 5311d8aea8cc..8aa37af306ed 100644 --- a/drivers/iio/magnetometer/st_magn_i2c.c +++ b/drivers/iio/magnetometer/st_magn_i2c.c @@ -36,6 +36,10 @@ static const struct of_device_id st_magn_of_match[] = { .compatible = "st,lis3mdl-magn", .data = LIS3MDL_MAGN_DEV_NAME, }, + { + .compatible = "st,lsm303agr-magn", + .data = LSM303AGR_MAGN_DEV_NAME, + }, {}, }; MODULE_DEVICE_TABLE(of, st_magn_of_match); @@ -79,13 +83,13 @@ static const struct i2c_device_id st_magn_id_table[] = { { LSM303DLHC_MAGN_DEV_NAME }, { LSM303DLM_MAGN_DEV_NAME }, { LIS3MDL_MAGN_DEV_NAME }, + { LSM303AGR_MAGN_DEV_NAME }, {}, }; MODULE_DEVICE_TABLE(i2c, st_magn_id_table); static struct i2c_driver st_magn_driver = { .driver = { - .owner = THIS_MODULE, .name = "st-magn-i2c", .of_match_table = of_match_ptr(st_magn_of_match), }, diff --git a/drivers/iio/magnetometer/st_magn_spi.c b/drivers/iio/magnetometer/st_magn_spi.c index 7adacf160146..0abca2c6afa6 100644 --- a/drivers/iio/magnetometer/st_magn_spi.c +++ b/drivers/iio/magnetometer/st_magn_spi.c @@ -51,6 +51,7 @@ static const struct spi_device_id st_magn_id_table[] = { { LSM303DLHC_MAGN_DEV_NAME }, { LSM303DLM_MAGN_DEV_NAME }, { LIS3MDL_MAGN_DEV_NAME }, + { LSM303AGR_MAGN_DEV_NAME }, {}, }; MODULE_DEVICE_TABLE(spi, st_magn_id_table); |