Lines Matching refs:data
37 /* RAM offsets with 16-bit data, MSB first */
38 #define MLX90614_RAW1 (MLX90614_OP_RAM | 0x04) /* raw data IR channel 1 */
39 #define MLX90614_RAW2 (MLX90614_OP_RAM | 0x05) /* raw data IR channel 2 */
44 /* EEPROM offsets with 16-bit data, MSB first */
61 #define MLX90614_TIMING_STARTUP 250 /* time before first data after wake-up */
106 union i2c_smbus_data data;
111 data.word = 0x0000; /* erase command */
115 I2C_SMBUS_WORD_DATA, &data);
121 data.word = value; /* actual write */
125 I2C_SMBUS_WORD_DATA, &data);
176 static int mlx90614_power_get(struct mlx90614_data *data, bool startup)
180 if (!data->wakeup_gpio)
183 pm_runtime_get_sync(&data->client->dev);
187 if (time_before(now, data->ready_timestamp) &&
189 data->ready_timestamp - now)) != 0) {
190 pm_runtime_put_autosuspend(&data->client->dev);
198 static void mlx90614_power_put(struct mlx90614_data *data)
200 if (!data->wakeup_gpio)
203 pm_runtime_mark_last_busy(&data->client->dev);
204 pm_runtime_put_autosuspend(&data->client->dev);
207 static inline int mlx90614_power_get(struct mlx90614_data *data, bool startup)
212 static inline void mlx90614_power_put(struct mlx90614_data *data)
221 struct mlx90614_data *data = iio_priv(indio_dev);
247 ret = mlx90614_power_get(data, true);
250 ret = i2c_smbus_read_word_data(data->client, cmd);
251 mlx90614_power_put(data);
270 mlx90614_power_get(data, false);
271 mutex_lock(&data->lock);
272 ret = i2c_smbus_read_word_data(data->client,
274 mutex_unlock(&data->lock);
275 mlx90614_power_put(data);
290 mlx90614_power_get(data, false);
291 mutex_lock(&data->lock);
292 ret = i2c_smbus_read_word_data(data->client, MLX90614_CONFIG);
293 mutex_unlock(&data->lock);
294 mlx90614_power_put(data);
312 struct mlx90614_data *data = iio_priv(indio_dev);
322 mlx90614_power_get(data, false);
323 mutex_lock(&data->lock);
324 ret = mlx90614_write_word(data->client, MLX90614_EMISSIVITY,
326 mutex_unlock(&data->lock);
327 mlx90614_power_put(data);
334 mlx90614_power_get(data, false);
335 mutex_lock(&data->lock);
336 ret = mlx90614_iir_search(data->client,
338 mutex_unlock(&data->lock);
339 mlx90614_power_put(data);
402 static int mlx90614_sleep(struct mlx90614_data *data)
406 if (!data->wakeup_gpio) {
407 dev_dbg(&data->client->dev, "Sleep disabled");
411 dev_dbg(&data->client->dev, "Requesting sleep");
413 mutex_lock(&data->lock);
414 ret = i2c_smbus_xfer(data->client->adapter, data->client->addr,
415 data->client->flags | I2C_CLIENT_PEC,
418 mutex_unlock(&data->lock);
423 static int mlx90614_wakeup(struct mlx90614_data *data)
425 if (!data->wakeup_gpio) {
426 dev_dbg(&data->client->dev, "Wake-up disabled");
430 dev_dbg(&data->client->dev, "Requesting wake-up");
432 i2c_lock_bus(data->client->adapter, I2C_LOCK_ROOT_ADAPTER);
433 gpiod_direction_output(data->wakeup_gpio, 0);
435 gpiod_direction_input(data->wakeup_gpio);
436 i2c_unlock_bus(data->client->adapter, I2C_LOCK_ROOT_ADAPTER);
438 data->ready_timestamp = jiffies +
447 i2c_smbus_read_word_data(data->client, MLX90614_CONFIG);
479 static inline int mlx90614_sleep(struct mlx90614_data *data)
483 static inline int mlx90614_wakeup(struct mlx90614_data *data)
510 struct mlx90614_data *data;
516 indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
520 data = iio_priv(indio_dev);
522 data->client = client;
523 mutex_init(&data->lock);
524 data->wakeup_gpio = mlx90614_probe_wakeup(client);
526 mlx90614_wakeup(data);
548 if (data->wakeup_gpio) {
562 struct mlx90614_data *data = iio_priv(indio_dev);
566 if (data->wakeup_gpio) {
569 mlx90614_sleep(data);
592 struct mlx90614_data *data = iio_priv(indio_dev);
594 if (data->wakeup_gpio && pm_runtime_active(dev))
595 return mlx90614_sleep(data);
603 struct mlx90614_data *data = iio_priv(indio_dev);
606 if (data->wakeup_gpio) {
607 err = mlx90614_wakeup(data);
624 struct mlx90614_data *data = iio_priv(indio_dev);
626 return mlx90614_sleep(data);
632 struct mlx90614_data *data = iio_priv(indio_dev);
634 return mlx90614_wakeup(data);