Lines Matching refs:data
59 #define MLX90614_TIMING_STARTUP 250 /* time before first data after wake-up */
76 /* EEPROM offsets with 16-bit data, MSB first */
80 /* RAM offsets with 16-bit data, MSB first */
119 union i2c_smbus_data data;
124 data.word = 0x0000; /* erase command */
128 I2C_SMBUS_WORD_DATA, &data);
134 data.word = value; /* actual write */
138 I2C_SMBUS_WORD_DATA, &data);
153 struct mlx90614_data *data = iio_priv(indio_dev);
154 const struct mlx_chip_info *chip_info = data->chip_info;
198 static int mlx90614_power_get(struct mlx90614_data *data, bool startup)
203 if (!data->wakeup_gpio)
206 ret = pm_runtime_resume_and_get(&data->client->dev);
212 if (time_before(now, data->ready_timestamp) &&
214 data->ready_timestamp - now)) != 0) {
215 pm_runtime_put_autosuspend(&data->client->dev);
223 static void mlx90614_power_put(struct mlx90614_data *data)
225 if (!data->wakeup_gpio)
228 pm_runtime_mark_last_busy(&data->client->dev);
229 pm_runtime_put_autosuspend(&data->client->dev);
232 static inline int mlx90614_power_get(struct mlx90614_data *data, bool startup)
237 static inline void mlx90614_power_put(struct mlx90614_data *data)
246 struct mlx90614_data *data = iio_priv(indio_dev);
247 const struct mlx_chip_info *chip_info = data->chip_info;
276 ret = mlx90614_power_get(data, true);
279 ret = i2c_smbus_read_word_data(data->client, cmd);
280 mlx90614_power_put(data);
299 ret = mlx90614_power_get(data, false);
303 mutex_lock(&data->lock);
304 ret = i2c_smbus_read_word_data(data->client,
306 mutex_unlock(&data->lock);
307 mlx90614_power_put(data);
322 ret = mlx90614_power_get(data, false);
326 mutex_lock(&data->lock);
327 ret = i2c_smbus_read_word_data(data->client,
329 mutex_unlock(&data->lock);
330 mlx90614_power_put(data);
350 struct mlx90614_data *data = iio_priv(indio_dev);
351 const struct mlx_chip_info *chip_info = data->chip_info;
361 ret = mlx90614_power_get(data, false);
365 mutex_lock(&data->lock);
366 ret = mlx90614_write_word(data->client,
368 mutex_unlock(&data->lock);
369 mlx90614_power_put(data);
376 ret = mlx90614_power_get(data, false);
380 mutex_lock(&data->lock);
381 ret = mlx90614_iir_search(data->client,
383 mutex_unlock(&data->lock);
384 mlx90614_power_put(data);
411 struct mlx90614_data *data = iio_priv(indio_dev);
412 const struct mlx_chip_info *chip_info = data->chip_info;
471 static int mlx90614_sleep(struct mlx90614_data *data)
473 const struct mlx_chip_info *chip_info = data->chip_info;
476 if (!data->wakeup_gpio) {
477 dev_dbg(&data->client->dev, "Sleep disabled");
481 dev_dbg(&data->client->dev, "Requesting sleep");
483 mutex_lock(&data->lock);
484 ret = i2c_smbus_xfer(data->client->adapter, data->client->addr,
485 data->client->flags | I2C_CLIENT_PEC,
488 mutex_unlock(&data->lock);
493 static int mlx90614_wakeup(struct mlx90614_data *data)
495 const struct mlx_chip_info *chip_info = data->chip_info;
497 if (!data->wakeup_gpio) {
498 dev_dbg(&data->client->dev, "Wake-up disabled");
502 dev_dbg(&data->client->dev, "Requesting wake-up");
504 i2c_lock_bus(data->client->adapter, I2C_LOCK_ROOT_ADAPTER);
505 gpiod_direction_output(data->wakeup_gpio, 0);
507 gpiod_direction_input(data->wakeup_gpio);
508 i2c_unlock_bus(data->client->adapter, I2C_LOCK_ROOT_ADAPTER);
510 data->ready_timestamp = jiffies +
519 i2c_smbus_read_word_data(data->client, chip_info->op_eeprom_config1);
551 static inline int mlx90614_sleep(struct mlx90614_data *data)
555 static inline int mlx90614_wakeup(struct mlx90614_data *data)
569 struct mlx90614_data *data = iio_priv(indio_dev);
570 const struct mlx_chip_info *chip_info = data->chip_info;
588 struct mlx90614_data *data;
594 indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
598 data = iio_priv(indio_dev);
600 data->client = client;
601 mutex_init(&data->lock);
602 data->wakeup_gpio = mlx90614_probe_wakeup(client);
603 data->chip_info = device_get_match_data(&client->dev);
605 mlx90614_wakeup(data);
627 if (data->wakeup_gpio) {
641 struct mlx90614_data *data = iio_priv(indio_dev);
645 if (data->wakeup_gpio) {
648 mlx90614_sleep(data);
713 { .compatible = "melexis,mlx90614", .data = &mlx90614_chip_info },
714 { .compatible = "melexis,mlx90615", .data = &mlx90615_chip_info },
722 struct mlx90614_data *data = iio_priv(indio_dev);
724 if (data->wakeup_gpio && pm_runtime_active(dev))
725 return mlx90614_sleep(data);
733 struct mlx90614_data *data = iio_priv(indio_dev);
736 if (data->wakeup_gpio) {
737 err = mlx90614_wakeup(data);
752 struct mlx90614_data *data = iio_priv(indio_dev);
754 return mlx90614_sleep(data);
760 struct mlx90614_data *data = iio_priv(indio_dev);
762 return mlx90614_wakeup(data);