18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * HID Sensors Driver
48c2ecf20Sopenharmony_ci * Copyright (c) 2012, Intel Corporation.
58c2ecf20Sopenharmony_ci */
68c2ecf20Sopenharmony_ci#include <linux/device.h>
78c2ecf20Sopenharmony_ci#include <linux/platform_device.h>
88c2ecf20Sopenharmony_ci#include <linux/module.h>
98c2ecf20Sopenharmony_ci#include <linux/interrupt.h>
108c2ecf20Sopenharmony_ci#include <linux/irq.h>
118c2ecf20Sopenharmony_ci#include <linux/slab.h>
128c2ecf20Sopenharmony_ci#include <linux/delay.h>
138c2ecf20Sopenharmony_ci#include <linux/hid-sensor-hub.h>
148c2ecf20Sopenharmony_ci#include <linux/iio/iio.h>
158c2ecf20Sopenharmony_ci#include <linux/iio/trigger.h>
168c2ecf20Sopenharmony_ci#include <linux/iio/triggered_buffer.h>
178c2ecf20Sopenharmony_ci#include <linux/iio/trigger_consumer.h>
188c2ecf20Sopenharmony_ci#include <linux/iio/buffer.h>
198c2ecf20Sopenharmony_ci#include <linux/iio/sysfs.h>
208c2ecf20Sopenharmony_ci#include "hid-sensor-trigger.h"
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_cistatic ssize_t _hid_sensor_set_report_latency(struct device *dev,
238c2ecf20Sopenharmony_ci					      struct device_attribute *attr,
248c2ecf20Sopenharmony_ci					      const char *buf, size_t len)
258c2ecf20Sopenharmony_ci{
268c2ecf20Sopenharmony_ci	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
278c2ecf20Sopenharmony_ci	struct hid_sensor_common *attrb = iio_device_get_drvdata(indio_dev);
288c2ecf20Sopenharmony_ci	int integer, fract, ret;
298c2ecf20Sopenharmony_ci	int latency;
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_ci	ret = iio_str_to_fixpoint(buf, 100000, &integer, &fract);
328c2ecf20Sopenharmony_ci	if (ret)
338c2ecf20Sopenharmony_ci		return ret;
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ci	latency = integer * 1000 + fract / 1000;
368c2ecf20Sopenharmony_ci	ret = hid_sensor_set_report_latency(attrb, latency);
378c2ecf20Sopenharmony_ci	if (ret < 0)
388c2ecf20Sopenharmony_ci		return len;
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ci	attrb->latency_ms = hid_sensor_get_report_latency(attrb);
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_ci	return len;
438c2ecf20Sopenharmony_ci}
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_cistatic ssize_t _hid_sensor_get_report_latency(struct device *dev,
468c2ecf20Sopenharmony_ci					      struct device_attribute *attr,
478c2ecf20Sopenharmony_ci					      char *buf)
488c2ecf20Sopenharmony_ci{
498c2ecf20Sopenharmony_ci	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
508c2ecf20Sopenharmony_ci	struct hid_sensor_common *attrb = iio_device_get_drvdata(indio_dev);
518c2ecf20Sopenharmony_ci	int latency;
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_ci	latency = hid_sensor_get_report_latency(attrb);
548c2ecf20Sopenharmony_ci	if (latency < 0)
558c2ecf20Sopenharmony_ci		return latency;
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ci	return sprintf(buf, "%d.%06u\n", latency / 1000, (latency % 1000) * 1000);
588c2ecf20Sopenharmony_ci}
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_cistatic ssize_t _hid_sensor_get_fifo_state(struct device *dev,
618c2ecf20Sopenharmony_ci					  struct device_attribute *attr,
628c2ecf20Sopenharmony_ci					  char *buf)
638c2ecf20Sopenharmony_ci{
648c2ecf20Sopenharmony_ci	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
658c2ecf20Sopenharmony_ci	struct hid_sensor_common *attrb = iio_device_get_drvdata(indio_dev);
668c2ecf20Sopenharmony_ci	int latency;
678c2ecf20Sopenharmony_ci
688c2ecf20Sopenharmony_ci	latency = hid_sensor_get_report_latency(attrb);
698c2ecf20Sopenharmony_ci	if (latency < 0)
708c2ecf20Sopenharmony_ci		return latency;
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_ci	return sprintf(buf, "%d\n", !!latency);
738c2ecf20Sopenharmony_ci}
748c2ecf20Sopenharmony_ci
758c2ecf20Sopenharmony_cistatic IIO_DEVICE_ATTR(hwfifo_timeout, 0644,
768c2ecf20Sopenharmony_ci		       _hid_sensor_get_report_latency,
778c2ecf20Sopenharmony_ci		       _hid_sensor_set_report_latency, 0);
788c2ecf20Sopenharmony_cistatic IIO_DEVICE_ATTR(hwfifo_enabled, 0444,
798c2ecf20Sopenharmony_ci		       _hid_sensor_get_fifo_state, NULL, 0);
808c2ecf20Sopenharmony_ci
818c2ecf20Sopenharmony_cistatic const struct attribute *hid_sensor_fifo_attributes[] = {
828c2ecf20Sopenharmony_ci	&iio_dev_attr_hwfifo_timeout.dev_attr.attr,
838c2ecf20Sopenharmony_ci	&iio_dev_attr_hwfifo_enabled.dev_attr.attr,
848c2ecf20Sopenharmony_ci	NULL,
858c2ecf20Sopenharmony_ci};
868c2ecf20Sopenharmony_ci
878c2ecf20Sopenharmony_cistatic void hid_sensor_setup_batch_mode(struct iio_dev *indio_dev,
888c2ecf20Sopenharmony_ci					struct hid_sensor_common *st)
898c2ecf20Sopenharmony_ci{
908c2ecf20Sopenharmony_ci	if (!hid_sensor_batch_mode_supported(st))
918c2ecf20Sopenharmony_ci		return;
928c2ecf20Sopenharmony_ci
938c2ecf20Sopenharmony_ci	iio_buffer_set_attrs(indio_dev->buffer, hid_sensor_fifo_attributes);
948c2ecf20Sopenharmony_ci}
958c2ecf20Sopenharmony_ci
968c2ecf20Sopenharmony_cistatic int _hid_sensor_power_state(struct hid_sensor_common *st, bool state)
978c2ecf20Sopenharmony_ci{
988c2ecf20Sopenharmony_ci	int state_val;
998c2ecf20Sopenharmony_ci	int report_val;
1008c2ecf20Sopenharmony_ci	s32 poll_value = 0;
1018c2ecf20Sopenharmony_ci
1028c2ecf20Sopenharmony_ci	if (state) {
1038c2ecf20Sopenharmony_ci		if (sensor_hub_device_open(st->hsdev))
1048c2ecf20Sopenharmony_ci			return -EIO;
1058c2ecf20Sopenharmony_ci
1068c2ecf20Sopenharmony_ci		atomic_inc(&st->data_ready);
1078c2ecf20Sopenharmony_ci
1088c2ecf20Sopenharmony_ci		state_val = hid_sensor_get_usage_index(st->hsdev,
1098c2ecf20Sopenharmony_ci			st->power_state.report_id,
1108c2ecf20Sopenharmony_ci			st->power_state.index,
1118c2ecf20Sopenharmony_ci			HID_USAGE_SENSOR_PROP_POWER_STATE_D0_FULL_POWER_ENUM);
1128c2ecf20Sopenharmony_ci		report_val = hid_sensor_get_usage_index(st->hsdev,
1138c2ecf20Sopenharmony_ci			st->report_state.report_id,
1148c2ecf20Sopenharmony_ci			st->report_state.index,
1158c2ecf20Sopenharmony_ci			HID_USAGE_SENSOR_PROP_REPORTING_STATE_ALL_EVENTS_ENUM);
1168c2ecf20Sopenharmony_ci
1178c2ecf20Sopenharmony_ci		poll_value = hid_sensor_read_poll_value(st);
1188c2ecf20Sopenharmony_ci	} else {
1198c2ecf20Sopenharmony_ci		int val;
1208c2ecf20Sopenharmony_ci
1218c2ecf20Sopenharmony_ci		val = atomic_dec_if_positive(&st->data_ready);
1228c2ecf20Sopenharmony_ci		if (val < 0)
1238c2ecf20Sopenharmony_ci			return 0;
1248c2ecf20Sopenharmony_ci
1258c2ecf20Sopenharmony_ci		sensor_hub_device_close(st->hsdev);
1268c2ecf20Sopenharmony_ci		state_val = hid_sensor_get_usage_index(st->hsdev,
1278c2ecf20Sopenharmony_ci			st->power_state.report_id,
1288c2ecf20Sopenharmony_ci			st->power_state.index,
1298c2ecf20Sopenharmony_ci			HID_USAGE_SENSOR_PROP_POWER_STATE_D4_POWER_OFF_ENUM);
1308c2ecf20Sopenharmony_ci		report_val = hid_sensor_get_usage_index(st->hsdev,
1318c2ecf20Sopenharmony_ci			st->report_state.report_id,
1328c2ecf20Sopenharmony_ci			st->report_state.index,
1338c2ecf20Sopenharmony_ci			HID_USAGE_SENSOR_PROP_REPORTING_STATE_NO_EVENTS_ENUM);
1348c2ecf20Sopenharmony_ci	}
1358c2ecf20Sopenharmony_ci
1368c2ecf20Sopenharmony_ci	if (state_val >= 0) {
1378c2ecf20Sopenharmony_ci		state_val += st->power_state.logical_minimum;
1388c2ecf20Sopenharmony_ci		sensor_hub_set_feature(st->hsdev, st->power_state.report_id,
1398c2ecf20Sopenharmony_ci				       st->power_state.index, sizeof(state_val),
1408c2ecf20Sopenharmony_ci				       &state_val);
1418c2ecf20Sopenharmony_ci	}
1428c2ecf20Sopenharmony_ci
1438c2ecf20Sopenharmony_ci	if (report_val >= 0) {
1448c2ecf20Sopenharmony_ci		report_val += st->report_state.logical_minimum;
1458c2ecf20Sopenharmony_ci		sensor_hub_set_feature(st->hsdev, st->report_state.report_id,
1468c2ecf20Sopenharmony_ci				       st->report_state.index,
1478c2ecf20Sopenharmony_ci				       sizeof(report_val),
1488c2ecf20Sopenharmony_ci				       &report_val);
1498c2ecf20Sopenharmony_ci	}
1508c2ecf20Sopenharmony_ci
1518c2ecf20Sopenharmony_ci	pr_debug("HID_SENSOR %s set power_state %d report_state %d\n",
1528c2ecf20Sopenharmony_ci		 st->pdev->name, state_val, report_val);
1538c2ecf20Sopenharmony_ci
1548c2ecf20Sopenharmony_ci	sensor_hub_get_feature(st->hsdev, st->power_state.report_id,
1558c2ecf20Sopenharmony_ci			       st->power_state.index,
1568c2ecf20Sopenharmony_ci			       sizeof(state_val), &state_val);
1578c2ecf20Sopenharmony_ci	if (state && poll_value)
1588c2ecf20Sopenharmony_ci		msleep_interruptible(poll_value * 2);
1598c2ecf20Sopenharmony_ci
1608c2ecf20Sopenharmony_ci	return 0;
1618c2ecf20Sopenharmony_ci}
1628c2ecf20Sopenharmony_ciEXPORT_SYMBOL(hid_sensor_power_state);
1638c2ecf20Sopenharmony_ci
1648c2ecf20Sopenharmony_ciint hid_sensor_power_state(struct hid_sensor_common *st, bool state)
1658c2ecf20Sopenharmony_ci{
1668c2ecf20Sopenharmony_ci
1678c2ecf20Sopenharmony_ci#ifdef CONFIG_PM
1688c2ecf20Sopenharmony_ci	int ret;
1698c2ecf20Sopenharmony_ci
1708c2ecf20Sopenharmony_ci	if (atomic_add_unless(&st->runtime_pm_enable, 1, 1))
1718c2ecf20Sopenharmony_ci		pm_runtime_enable(&st->pdev->dev);
1728c2ecf20Sopenharmony_ci
1738c2ecf20Sopenharmony_ci	if (state) {
1748c2ecf20Sopenharmony_ci		atomic_inc(&st->user_requested_state);
1758c2ecf20Sopenharmony_ci		ret = pm_runtime_get_sync(&st->pdev->dev);
1768c2ecf20Sopenharmony_ci	} else {
1778c2ecf20Sopenharmony_ci		atomic_dec(&st->user_requested_state);
1788c2ecf20Sopenharmony_ci		pm_runtime_mark_last_busy(&st->pdev->dev);
1798c2ecf20Sopenharmony_ci		pm_runtime_use_autosuspend(&st->pdev->dev);
1808c2ecf20Sopenharmony_ci		ret = pm_runtime_put_autosuspend(&st->pdev->dev);
1818c2ecf20Sopenharmony_ci	}
1828c2ecf20Sopenharmony_ci	if (ret < 0) {
1838c2ecf20Sopenharmony_ci		if (state)
1848c2ecf20Sopenharmony_ci			pm_runtime_put_noidle(&st->pdev->dev);
1858c2ecf20Sopenharmony_ci		return ret;
1868c2ecf20Sopenharmony_ci	}
1878c2ecf20Sopenharmony_ci
1888c2ecf20Sopenharmony_ci	return 0;
1898c2ecf20Sopenharmony_ci#else
1908c2ecf20Sopenharmony_ci	atomic_set(&st->user_requested_state, state);
1918c2ecf20Sopenharmony_ci	return _hid_sensor_power_state(st, state);
1928c2ecf20Sopenharmony_ci#endif
1938c2ecf20Sopenharmony_ci}
1948c2ecf20Sopenharmony_ci
1958c2ecf20Sopenharmony_cistatic void hid_sensor_set_power_work(struct work_struct *work)
1968c2ecf20Sopenharmony_ci{
1978c2ecf20Sopenharmony_ci	struct hid_sensor_common *attrb = container_of(work,
1988c2ecf20Sopenharmony_ci						       struct hid_sensor_common,
1998c2ecf20Sopenharmony_ci						       work);
2008c2ecf20Sopenharmony_ci
2018c2ecf20Sopenharmony_ci	if (attrb->poll_interval >= 0)
2028c2ecf20Sopenharmony_ci		sensor_hub_set_feature(attrb->hsdev, attrb->poll.report_id,
2038c2ecf20Sopenharmony_ci				       attrb->poll.index,
2048c2ecf20Sopenharmony_ci				       sizeof(attrb->poll_interval),
2058c2ecf20Sopenharmony_ci				       &attrb->poll_interval);
2068c2ecf20Sopenharmony_ci
2078c2ecf20Sopenharmony_ci	if (attrb->raw_hystersis >= 0)
2088c2ecf20Sopenharmony_ci		sensor_hub_set_feature(attrb->hsdev,
2098c2ecf20Sopenharmony_ci				       attrb->sensitivity.report_id,
2108c2ecf20Sopenharmony_ci				       attrb->sensitivity.index,
2118c2ecf20Sopenharmony_ci				       sizeof(attrb->raw_hystersis),
2128c2ecf20Sopenharmony_ci				       &attrb->raw_hystersis);
2138c2ecf20Sopenharmony_ci
2148c2ecf20Sopenharmony_ci	if (attrb->latency_ms > 0)
2158c2ecf20Sopenharmony_ci		hid_sensor_set_report_latency(attrb, attrb->latency_ms);
2168c2ecf20Sopenharmony_ci
2178c2ecf20Sopenharmony_ci	if (atomic_read(&attrb->user_requested_state))
2188c2ecf20Sopenharmony_ci		_hid_sensor_power_state(attrb, true);
2198c2ecf20Sopenharmony_ci}
2208c2ecf20Sopenharmony_ci
2218c2ecf20Sopenharmony_cistatic int hid_sensor_data_rdy_trigger_set_state(struct iio_trigger *trig,
2228c2ecf20Sopenharmony_ci						bool state)
2238c2ecf20Sopenharmony_ci{
2248c2ecf20Sopenharmony_ci	return hid_sensor_power_state(iio_trigger_get_drvdata(trig), state);
2258c2ecf20Sopenharmony_ci}
2268c2ecf20Sopenharmony_ci
2278c2ecf20Sopenharmony_civoid hid_sensor_remove_trigger(struct iio_dev *indio_dev,
2288c2ecf20Sopenharmony_ci			       struct hid_sensor_common *attrb)
2298c2ecf20Sopenharmony_ci{
2308c2ecf20Sopenharmony_ci	if (atomic_read(&attrb->runtime_pm_enable))
2318c2ecf20Sopenharmony_ci		pm_runtime_disable(&attrb->pdev->dev);
2328c2ecf20Sopenharmony_ci
2338c2ecf20Sopenharmony_ci	pm_runtime_set_suspended(&attrb->pdev->dev);
2348c2ecf20Sopenharmony_ci	pm_runtime_put_noidle(&attrb->pdev->dev);
2358c2ecf20Sopenharmony_ci
2368c2ecf20Sopenharmony_ci	cancel_work_sync(&attrb->work);
2378c2ecf20Sopenharmony_ci	iio_trigger_unregister(attrb->trigger);
2388c2ecf20Sopenharmony_ci	iio_trigger_free(attrb->trigger);
2398c2ecf20Sopenharmony_ci	iio_triggered_buffer_cleanup(indio_dev);
2408c2ecf20Sopenharmony_ci}
2418c2ecf20Sopenharmony_ciEXPORT_SYMBOL(hid_sensor_remove_trigger);
2428c2ecf20Sopenharmony_ci
2438c2ecf20Sopenharmony_cistatic const struct iio_trigger_ops hid_sensor_trigger_ops = {
2448c2ecf20Sopenharmony_ci	.set_trigger_state = &hid_sensor_data_rdy_trigger_set_state,
2458c2ecf20Sopenharmony_ci};
2468c2ecf20Sopenharmony_ci
2478c2ecf20Sopenharmony_ciint hid_sensor_setup_trigger(struct iio_dev *indio_dev, const char *name,
2488c2ecf20Sopenharmony_ci				struct hid_sensor_common *attrb)
2498c2ecf20Sopenharmony_ci{
2508c2ecf20Sopenharmony_ci	int ret;
2518c2ecf20Sopenharmony_ci	struct iio_trigger *trig;
2528c2ecf20Sopenharmony_ci
2538c2ecf20Sopenharmony_ci	ret = iio_triggered_buffer_setup(indio_dev, &iio_pollfunc_store_time,
2548c2ecf20Sopenharmony_ci					 NULL, NULL);
2558c2ecf20Sopenharmony_ci	if (ret) {
2568c2ecf20Sopenharmony_ci		dev_err(&indio_dev->dev, "Triggered Buffer Setup Failed\n");
2578c2ecf20Sopenharmony_ci		return ret;
2588c2ecf20Sopenharmony_ci	}
2598c2ecf20Sopenharmony_ci
2608c2ecf20Sopenharmony_ci	trig = iio_trigger_alloc("%s-dev%d", name, indio_dev->id);
2618c2ecf20Sopenharmony_ci	if (trig == NULL) {
2628c2ecf20Sopenharmony_ci		dev_err(&indio_dev->dev, "Trigger Allocate Failed\n");
2638c2ecf20Sopenharmony_ci		ret = -ENOMEM;
2648c2ecf20Sopenharmony_ci		goto error_triggered_buffer_cleanup;
2658c2ecf20Sopenharmony_ci	}
2668c2ecf20Sopenharmony_ci
2678c2ecf20Sopenharmony_ci	trig->dev.parent = indio_dev->dev.parent;
2688c2ecf20Sopenharmony_ci	iio_trigger_set_drvdata(trig, attrb);
2698c2ecf20Sopenharmony_ci	trig->ops = &hid_sensor_trigger_ops;
2708c2ecf20Sopenharmony_ci	ret = iio_trigger_register(trig);
2718c2ecf20Sopenharmony_ci
2728c2ecf20Sopenharmony_ci	if (ret) {
2738c2ecf20Sopenharmony_ci		dev_err(&indio_dev->dev, "Trigger Register Failed\n");
2748c2ecf20Sopenharmony_ci		goto error_free_trig;
2758c2ecf20Sopenharmony_ci	}
2768c2ecf20Sopenharmony_ci	attrb->trigger = trig;
2778c2ecf20Sopenharmony_ci	indio_dev->trig = iio_trigger_get(trig);
2788c2ecf20Sopenharmony_ci
2798c2ecf20Sopenharmony_ci	hid_sensor_setup_batch_mode(indio_dev, attrb);
2808c2ecf20Sopenharmony_ci
2818c2ecf20Sopenharmony_ci	ret = pm_runtime_set_active(&indio_dev->dev);
2828c2ecf20Sopenharmony_ci	if (ret)
2838c2ecf20Sopenharmony_ci		goto error_unreg_trigger;
2848c2ecf20Sopenharmony_ci
2858c2ecf20Sopenharmony_ci	iio_device_set_drvdata(indio_dev, attrb);
2868c2ecf20Sopenharmony_ci
2878c2ecf20Sopenharmony_ci	INIT_WORK(&attrb->work, hid_sensor_set_power_work);
2888c2ecf20Sopenharmony_ci
2898c2ecf20Sopenharmony_ci	pm_suspend_ignore_children(&attrb->pdev->dev, true);
2908c2ecf20Sopenharmony_ci	/* Default to 3 seconds, but can be changed from sysfs */
2918c2ecf20Sopenharmony_ci	pm_runtime_set_autosuspend_delay(&attrb->pdev->dev,
2928c2ecf20Sopenharmony_ci					 3000);
2938c2ecf20Sopenharmony_ci	return ret;
2948c2ecf20Sopenharmony_cierror_unreg_trigger:
2958c2ecf20Sopenharmony_ci	iio_trigger_unregister(trig);
2968c2ecf20Sopenharmony_cierror_free_trig:
2978c2ecf20Sopenharmony_ci	iio_trigger_free(trig);
2988c2ecf20Sopenharmony_cierror_triggered_buffer_cleanup:
2998c2ecf20Sopenharmony_ci	iio_triggered_buffer_cleanup(indio_dev);
3008c2ecf20Sopenharmony_ci	return ret;
3018c2ecf20Sopenharmony_ci}
3028c2ecf20Sopenharmony_ciEXPORT_SYMBOL(hid_sensor_setup_trigger);
3038c2ecf20Sopenharmony_ci
3048c2ecf20Sopenharmony_cistatic int __maybe_unused hid_sensor_suspend(struct device *dev)
3058c2ecf20Sopenharmony_ci{
3068c2ecf20Sopenharmony_ci	struct iio_dev *indio_dev = dev_get_drvdata(dev);
3078c2ecf20Sopenharmony_ci	struct hid_sensor_common *attrb = iio_device_get_drvdata(indio_dev);
3088c2ecf20Sopenharmony_ci
3098c2ecf20Sopenharmony_ci	return _hid_sensor_power_state(attrb, false);
3108c2ecf20Sopenharmony_ci}
3118c2ecf20Sopenharmony_ci
3128c2ecf20Sopenharmony_cistatic int __maybe_unused hid_sensor_resume(struct device *dev)
3138c2ecf20Sopenharmony_ci{
3148c2ecf20Sopenharmony_ci	struct iio_dev *indio_dev = dev_get_drvdata(dev);
3158c2ecf20Sopenharmony_ci	struct hid_sensor_common *attrb = iio_device_get_drvdata(indio_dev);
3168c2ecf20Sopenharmony_ci	schedule_work(&attrb->work);
3178c2ecf20Sopenharmony_ci	return 0;
3188c2ecf20Sopenharmony_ci}
3198c2ecf20Sopenharmony_ci
3208c2ecf20Sopenharmony_cistatic int __maybe_unused hid_sensor_runtime_resume(struct device *dev)
3218c2ecf20Sopenharmony_ci{
3228c2ecf20Sopenharmony_ci	struct iio_dev *indio_dev = dev_get_drvdata(dev);
3238c2ecf20Sopenharmony_ci	struct hid_sensor_common *attrb = iio_device_get_drvdata(indio_dev);
3248c2ecf20Sopenharmony_ci	return _hid_sensor_power_state(attrb, true);
3258c2ecf20Sopenharmony_ci}
3268c2ecf20Sopenharmony_ci
3278c2ecf20Sopenharmony_ciconst struct dev_pm_ops hid_sensor_pm_ops = {
3288c2ecf20Sopenharmony_ci	SET_SYSTEM_SLEEP_PM_OPS(hid_sensor_suspend, hid_sensor_resume)
3298c2ecf20Sopenharmony_ci	SET_RUNTIME_PM_OPS(hid_sensor_suspend,
3308c2ecf20Sopenharmony_ci			   hid_sensor_runtime_resume, NULL)
3318c2ecf20Sopenharmony_ci};
3328c2ecf20Sopenharmony_ciEXPORT_SYMBOL(hid_sensor_pm_ops);
3338c2ecf20Sopenharmony_ci
3348c2ecf20Sopenharmony_ciMODULE_AUTHOR("Srinivas Pandruvada <srinivas.pandruvada@intel.com>");
3358c2ecf20Sopenharmony_ciMODULE_DESCRIPTION("HID Sensor trigger processing");
3368c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL");
337