Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'iio-fixes-for-6.9a' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into char-misc-linus

Jonathan writes:

IIO: 1st set of fixes for the 6.9 cycle.

adi,asdis16475
- Write the correct field in the register when setting the sync mode.
bosch,bmp280
- Wrong chip specific data being used for the bme280 in the SPI driver.
- Fix that we can't use chip IDs because Bosch reuses them for incompatible
devices (some require a padding byte, others don't).
maxim,max30102 (dt binding)
- Fix incorrect property check to actually match on a device from the
binding rather than a completely different one due to a typo.
memsic,mxc4005
- Fix wrong masking of interrupt register accidentally disabling temperature
compensation. Also hammer initial state to 0 as it's not documented
if interrupts are masked after reset.
- Explicit reset on probe() and resume() as some devices do not power up
correctly without a reset.

* tag 'iio-fixes-for-6.9a' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio:
iio:imu: adis16475: Fix sync mode setting
iio: accel: mxc4005: Reset chip on probe() and resume()
iio: accel: mxc4005: Interrupt handling fixes
dt-bindings: iio: health: maxim,max30102: fix compatible check
iio: pressure: Fixes SPI support for BMP3xx devices
iio: pressure: Fixes BME280 SPI driver data

+95 -18
+1 -1
Documentation/devicetree/bindings/iio/health/maxim,max30102.yaml
··· 42 42 properties: 43 43 compatible: 44 44 contains: 45 - const: maxim,max30100 45 + const: maxim,max30102 46 46 then: 47 47 properties: 48 48 maxim,green-led-current-microamp: false
+85 -7
drivers/iio/accel/mxc4005.c
··· 5 5 * Copyright (c) 2014, Intel Corporation. 6 6 */ 7 7 8 + #include <linux/delay.h> 8 9 #include <linux/module.h> 9 10 #include <linux/i2c.h> 10 11 #include <linux/iio/iio.h> ··· 28 27 #define MXC4005_REG_ZOUT_UPPER 0x07 29 28 #define MXC4005_REG_ZOUT_LOWER 0x08 30 29 30 + #define MXC4005_REG_INT_MASK0 0x0A 31 + 31 32 #define MXC4005_REG_INT_MASK1 0x0B 32 33 #define MXC4005_REG_INT_MASK1_BIT_DRDYE 0x01 33 34 35 + #define MXC4005_REG_INT_CLR0 0x00 36 + 34 37 #define MXC4005_REG_INT_CLR1 0x01 35 38 #define MXC4005_REG_INT_CLR1_BIT_DRDYC 0x01 39 + #define MXC4005_REG_INT_CLR1_SW_RST 0x10 36 40 37 41 #define MXC4005_REG_CONTROL 0x0D 38 42 #define MXC4005_REG_CONTROL_MASK_FSR GENMASK(6, 5) 39 43 #define MXC4005_CONTROL_FSR_SHIFT 5 40 44 41 45 #define MXC4005_REG_DEVICE_ID 0x0E 46 + 47 + /* Datasheet does not specify a reset time, this is a conservative guess */ 48 + #define MXC4005_RESET_TIME_US 2000 42 49 43 50 enum mxc4005_axis { 44 51 AXIS_X, ··· 71 62 s64 timestamp __aligned(8); 72 63 } scan; 73 64 bool trigger_enabled; 65 + unsigned int control; 66 + unsigned int int_mask1; 74 67 }; 75 68 76 69 /* ··· 124 113 static bool mxc4005_is_writeable_reg(struct device *dev, unsigned int reg) 125 114 { 126 115 switch (reg) { 116 + case MXC4005_REG_INT_CLR0: 127 117 case MXC4005_REG_INT_CLR1: 118 + case MXC4005_REG_INT_MASK0: 128 119 case MXC4005_REG_INT_MASK1: 129 120 case MXC4005_REG_CONTROL: 130 121 return true; ··· 343 330 { 344 331 struct iio_dev *indio_dev = iio_trigger_get_drvdata(trig); 345 332 struct mxc4005_data *data = iio_priv(indio_dev); 333 + unsigned int val; 346 334 int ret; 347 335 348 336 mutex_lock(&data->mutex); 349 - if (state) { 350 - ret = regmap_write(data->regmap, MXC4005_REG_INT_MASK1, 351 - MXC4005_REG_INT_MASK1_BIT_DRDYE); 352 - } else { 353 - ret = regmap_write(data->regmap, MXC4005_REG_INT_MASK1, 354 - ~MXC4005_REG_INT_MASK1_BIT_DRDYE); 355 - } 356 337 338 + val = state ? MXC4005_REG_INT_MASK1_BIT_DRDYE : 0; 339 + ret = regmap_write(data->regmap, MXC4005_REG_INT_MASK1, val); 357 340 if (ret < 0) { 358 341 mutex_unlock(&data->mutex); 359 342 dev_err(data->dev, "failed to update reg_int_mask1"); 360 343 return ret; 361 344 } 362 345 346 + data->int_mask1 = val; 363 347 data->trigger_enabled = state; 364 348 mutex_unlock(&data->mutex); 365 349 ··· 391 381 } 392 382 393 383 dev_dbg(data->dev, "MXC4005 chip id %02x\n", reg); 384 + 385 + ret = regmap_write(data->regmap, MXC4005_REG_INT_CLR1, 386 + MXC4005_REG_INT_CLR1_SW_RST); 387 + if (ret < 0) 388 + return dev_err_probe(data->dev, ret, "resetting chip\n"); 389 + 390 + fsleep(MXC4005_RESET_TIME_US); 391 + 392 + ret = regmap_write(data->regmap, MXC4005_REG_INT_MASK0, 0); 393 + if (ret < 0) 394 + return dev_err_probe(data->dev, ret, "writing INT_MASK0\n"); 395 + 396 + ret = regmap_write(data->regmap, MXC4005_REG_INT_MASK1, 0); 397 + if (ret < 0) 398 + return dev_err_probe(data->dev, ret, "writing INT_MASK1\n"); 394 399 395 400 return 0; 396 401 } ··· 494 469 return devm_iio_device_register(&client->dev, indio_dev); 495 470 } 496 471 472 + static int mxc4005_suspend(struct device *dev) 473 + { 474 + struct iio_dev *indio_dev = dev_get_drvdata(dev); 475 + struct mxc4005_data *data = iio_priv(indio_dev); 476 + int ret; 477 + 478 + /* Save control to restore it on resume */ 479 + ret = regmap_read(data->regmap, MXC4005_REG_CONTROL, &data->control); 480 + if (ret < 0) 481 + dev_err(data->dev, "failed to read reg_control\n"); 482 + 483 + return ret; 484 + } 485 + 486 + static int mxc4005_resume(struct device *dev) 487 + { 488 + struct iio_dev *indio_dev = dev_get_drvdata(dev); 489 + struct mxc4005_data *data = iio_priv(indio_dev); 490 + int ret; 491 + 492 + ret = regmap_write(data->regmap, MXC4005_REG_INT_CLR1, 493 + MXC4005_REG_INT_CLR1_SW_RST); 494 + if (ret) { 495 + dev_err(data->dev, "failed to reset chip: %d\n", ret); 496 + return ret; 497 + } 498 + 499 + fsleep(MXC4005_RESET_TIME_US); 500 + 501 + ret = regmap_write(data->regmap, MXC4005_REG_CONTROL, data->control); 502 + if (ret) { 503 + dev_err(data->dev, "failed to restore control register\n"); 504 + return ret; 505 + } 506 + 507 + ret = regmap_write(data->regmap, MXC4005_REG_INT_MASK0, 0); 508 + if (ret) { 509 + dev_err(data->dev, "failed to restore interrupt 0 mask\n"); 510 + return ret; 511 + } 512 + 513 + ret = regmap_write(data->regmap, MXC4005_REG_INT_MASK1, data->int_mask1); 514 + if (ret) { 515 + dev_err(data->dev, "failed to restore interrupt 1 mask\n"); 516 + return ret; 517 + } 518 + 519 + return 0; 520 + } 521 + 522 + static DEFINE_SIMPLE_DEV_PM_OPS(mxc4005_pm_ops, mxc4005_suspend, mxc4005_resume); 523 + 497 524 static const struct acpi_device_id mxc4005_acpi_match[] = { 498 525 {"MXC4005", 0}, 499 526 {"MXC6655", 0}, ··· 573 496 .name = MXC4005_DRV_NAME, 574 497 .acpi_match_table = mxc4005_acpi_match, 575 498 .of_match_table = mxc4005_of_match, 499 + .pm = pm_sleep_ptr(&mxc4005_pm_ops), 576 500 }, 577 501 .probe = mxc4005_probe, 578 502 .id_table = mxc4005_id,
+3 -1
drivers/iio/imu/adis16475.c
··· 1289 1289 struct device *dev = &st->adis.spi->dev; 1290 1290 const struct adis16475_sync *sync; 1291 1291 u32 sync_mode; 1292 + u16 val; 1292 1293 1293 1294 /* default to internal clk */ 1294 1295 st->clk_freq = st->info->int_clk * 1000; ··· 1351 1350 * I'm keeping this for simplicity and avoiding extra variables 1352 1351 * in chip_info. 1353 1352 */ 1353 + val = ADIS16475_SYNC_MODE(sync->sync_mode); 1354 1354 ret = __adis_update_bits(&st->adis, ADIS16475_REG_MSG_CTRL, 1355 - ADIS16475_SYNC_MODE_MASK, sync->sync_mode); 1355 + ADIS16475_SYNC_MODE_MASK, val); 1356 1356 if (ret) 1357 1357 return ret; 1358 1358
+1
drivers/iio/pressure/bmp280-core.c
··· 1233 1233 .chip_id = bmp380_chip_ids, 1234 1234 .num_chip_id = ARRAY_SIZE(bmp380_chip_ids), 1235 1235 .regmap_config = &bmp380_regmap_config, 1236 + .spi_read_extra_byte = true, 1236 1237 .start_up_time = 2000, 1237 1238 .channels = bmp380_channels, 1238 1239 .num_channels = 2,
+4 -9
drivers/iio/pressure/bmp280-spi.c
··· 96 96 97 97 chip_info = spi_get_device_match_data(spi); 98 98 99 - switch (chip_info->chip_id[0]) { 100 - case BMP380_CHIP_ID: 101 - case BMP390_CHIP_ID: 99 + if (chip_info->spi_read_extra_byte) 102 100 bmp_regmap_bus = &bmp380_regmap_bus; 103 - break; 104 - default: 101 + else 105 102 bmp_regmap_bus = &bmp280_regmap_bus; 106 - break; 107 - } 108 103 109 104 regmap = devm_regmap_init(&spi->dev, 110 105 bmp_regmap_bus, ··· 122 127 { .compatible = "bosch,bmp180", .data = &bmp180_chip_info }, 123 128 { .compatible = "bosch,bmp181", .data = &bmp180_chip_info }, 124 129 { .compatible = "bosch,bmp280", .data = &bmp280_chip_info }, 125 - { .compatible = "bosch,bme280", .data = &bmp280_chip_info }, 130 + { .compatible = "bosch,bme280", .data = &bme280_chip_info }, 126 131 { .compatible = "bosch,bmp380", .data = &bmp380_chip_info }, 127 132 { .compatible = "bosch,bmp580", .data = &bmp580_chip_info }, 128 133 { }, ··· 134 139 { "bmp180", (kernel_ulong_t)&bmp180_chip_info }, 135 140 { "bmp181", (kernel_ulong_t)&bmp180_chip_info }, 136 141 { "bmp280", (kernel_ulong_t)&bmp280_chip_info }, 137 - { "bme280", (kernel_ulong_t)&bmp280_chip_info }, 142 + { "bme280", (kernel_ulong_t)&bme280_chip_info }, 138 143 { "bmp380", (kernel_ulong_t)&bmp380_chip_info }, 139 144 { "bmp580", (kernel_ulong_t)&bmp580_chip_info }, 140 145 { }
+1
drivers/iio/pressure/bmp280.h
··· 423 423 int num_chip_id; 424 424 425 425 const struct regmap_config *regmap_config; 426 + bool spi_read_extra_byte; 426 427 427 428 const struct iio_chan_spec *channels; 428 429 int num_channels;