mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-17 04:49:33 +07:00
eafdca4d70
Here is the big staging and IIO driver update for 4.18-rc1. It was delayed as I wanted to make sure the final driver deletions did not cause any major merge issues, and all now looks good. There are a lot of patches here, just over 1000. The diffstat summary shows the major changes here: 1007 files changed, 16828 insertions(+), 227770 deletions(-) Because of this, we might be close to shrinking the overall kernel source code size for two releases in a row. There was loads of work in this release cycle, primarily: - tons of ks7010 driver cleanups - lots of mt7621 driver fixes and cleanups - most driver cleanups - wilc1000 fixes and cleanups - lots and lots of IIO driver cleanups and new additions - debugfs cleanups for all staging drivers - lots of other staging driver cleanups and fixes, the shortlog has the full details. but the big user-visable things here are the removal of 3 chunks of code: - ncpfs and ipx were removed on schedule, no one has cared about this code since it moved to staging last year, and if it needs to come back, it can be reverted. - lustre file system is removed. I've ranted at the lustre developers about once a year for the past 5 years, with no real forward progress at all to clean things up and get the code into the "real" part of the kernel. Given that the lustre developers continue to work on an external tree and try to port those changes to the in-kernel tree every once in a while, this whole thing really really is not working out at all. So I'm deleting it so that the developers can spend the time working in their out-of-tree location and get things cleaned up properly to get merged into the tree correctly at a later date. Because of these file removals, you will have merge issues on some of these files (2 in the ipx code, 1 in the ncpfs code, and 1 in the atomisp driver). Just delete those files, it's a simple merge :) All of this has been in linux-next for a while with no reported problems. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> -----BEGIN PGP SIGNATURE----- iG0EABECAC0WIQT0tgzFv3jCIUoxPcsxR9QN2y37KQUCWxvjGQ8cZ3JlZ0Brcm9h aC5jb20ACgkQMUfUDdst+ymoEwCbBYnyUl3cwCszIJ3L3/zvUWpmqIgAn1DDsAim dM4lmKg6HX/JBSV4GAN0 =zdta -----END PGP SIGNATURE----- Merge tag 'staging-4.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging Pull staging/IIO updates from Greg KH: "Here is the big staging and IIO driver update for 4.18-rc1. It was delayed as I wanted to make sure the final driver deletions did not cause any major merge issues, and all now looks good. There are a lot of patches here, just over 1000. The diffstat summary shows the major changes here: 1007 files changed, 16828 insertions(+), 227770 deletions(-) Because of this, we might be close to shrinking the overall kernel source code size for two releases in a row. There was loads of work in this release cycle, primarily: - tons of ks7010 driver cleanups - lots of mt7621 driver fixes and cleanups - most driver cleanups - wilc1000 fixes and cleanups - lots and lots of IIO driver cleanups and new additions - debugfs cleanups for all staging drivers - lots of other staging driver cleanups and fixes, the shortlog has the full details. but the big user-visable things here are the removal of 3 chunks of code: - ncpfs and ipx were removed on schedule, no one has cared about this code since it moved to staging last year, and if it needs to come back, it can be reverted. - lustre file system is removed. I've ranted at the lustre developers about once a year for the past 5 years, with no real forward progress at all to clean things up and get the code into the "real" part of the kernel. Given that the lustre developers continue to work on an external tree and try to port those changes to the in-kernel tree every once in a while, this whole thing really really is not working out at all. So I'm deleting it so that the developers can spend the time working in their out-of-tree location and get things cleaned up properly to get merged into the tree correctly at a later date. Because of these file removals, you will have merge issues on some of these files (2 in the ipx code, 1 in the ncpfs code, and 1 in the atomisp driver). Just delete those files, it's a simple merge :) All of this has been in linux-next for a while with no reported problems" * tag 'staging-4.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: (1011 commits) staging: ipx: delete it from the tree ncpfs: remove uapi .h files ncpfs: remove Documentation ncpfs: remove compat functionality staging: ncpfs: delete it staging: lustre: delete the filesystem from the tree. staging: vc04_services: no need to save the log debufs dentries staging: vc04_services: vchiq_debugfs_log_entry can be a void * staging: vc04_services: remove struct vchiq_debugfs_info staging: vc04_services: move client dbg directory into static variable staging: vc04_services: remove odd vchiq_debugfs_top() wrapper staging: vc04_services: no need to check debugfs return values staging: mt7621-gpio: reorder includes alphabetically staging: mt7621-gpio: change gc_map to don't use pointers staging: mt7621-gpio: use GPIOF_DIR_OUT and GPIOF_DIR_IN macros instead of custom values staging: mt7621-gpio: change 'to_mediatek_gpio' to make just a one line return staging: mt7621-gpio: dt-bindings: update documentation for #interrupt-cells property staging: mt7621-gpio: update #interrupt-cells for the gpio node staging: mt7621-gpio: dt-bindings: complete documentation for the gpio staging: mt7621-dts: add missing properties to gpio node ...
338 lines
9.3 KiB
C
338 lines
9.3 KiB
C
/*
|
|
* HID Sensors Driver
|
|
* Copyright (c) 2012, Intel Corporation.
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
* under the terms and conditions of the GNU General Public License,
|
|
* version 2, as published by the Free Software Foundation.
|
|
*
|
|
* This program is distributed in the hope it will be useful, but WITHOUT
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
* more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License along with
|
|
* this program; if not, write to the Free Software Foundation, Inc.,
|
|
* 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
|
|
*
|
|
*/
|
|
#include <linux/device.h>
|
|
#include <linux/platform_device.h>
|
|
#include <linux/module.h>
|
|
#include <linux/interrupt.h>
|
|
#include <linux/irq.h>
|
|
#include <linux/slab.h>
|
|
#include <linux/delay.h>
|
|
#include <linux/hid-sensor-hub.h>
|
|
#include <linux/iio/iio.h>
|
|
#include <linux/iio/trigger.h>
|
|
#include <linux/iio/buffer.h>
|
|
#include <linux/iio/sysfs.h>
|
|
#include "hid-sensor-trigger.h"
|
|
|
|
static ssize_t _hid_sensor_set_report_latency(struct device *dev,
|
|
struct device_attribute *attr,
|
|
const char *buf, size_t len)
|
|
{
|
|
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
|
struct hid_sensor_common *attrb = iio_device_get_drvdata(indio_dev);
|
|
int integer, fract, ret;
|
|
int latency;
|
|
|
|
ret = iio_str_to_fixpoint(buf, 100000, &integer, &fract);
|
|
if (ret)
|
|
return ret;
|
|
|
|
latency = integer * 1000 + fract / 1000;
|
|
ret = hid_sensor_set_report_latency(attrb, latency);
|
|
if (ret < 0)
|
|
return len;
|
|
|
|
attrb->latency_ms = hid_sensor_get_report_latency(attrb);
|
|
|
|
return len;
|
|
}
|
|
|
|
static ssize_t _hid_sensor_get_report_latency(struct device *dev,
|
|
struct device_attribute *attr,
|
|
char *buf)
|
|
{
|
|
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
|
struct hid_sensor_common *attrb = iio_device_get_drvdata(indio_dev);
|
|
int latency;
|
|
|
|
latency = hid_sensor_get_report_latency(attrb);
|
|
if (latency < 0)
|
|
return latency;
|
|
|
|
return sprintf(buf, "%d.%06u\n", latency / 1000, (latency % 1000) * 1000);
|
|
}
|
|
|
|
static ssize_t _hid_sensor_get_fifo_state(struct device *dev,
|
|
struct device_attribute *attr,
|
|
char *buf)
|
|
{
|
|
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
|
struct hid_sensor_common *attrb = iio_device_get_drvdata(indio_dev);
|
|
int latency;
|
|
|
|
latency = hid_sensor_get_report_latency(attrb);
|
|
if (latency < 0)
|
|
return latency;
|
|
|
|
return sprintf(buf, "%d\n", !!latency);
|
|
}
|
|
|
|
static IIO_DEVICE_ATTR(hwfifo_timeout, 0644,
|
|
_hid_sensor_get_report_latency,
|
|
_hid_sensor_set_report_latency, 0);
|
|
static IIO_DEVICE_ATTR(hwfifo_enabled, 0444,
|
|
_hid_sensor_get_fifo_state, NULL, 0);
|
|
|
|
static const struct attribute *hid_sensor_fifo_attributes[] = {
|
|
&iio_dev_attr_hwfifo_timeout.dev_attr.attr,
|
|
&iio_dev_attr_hwfifo_enabled.dev_attr.attr,
|
|
NULL,
|
|
};
|
|
|
|
static void hid_sensor_setup_batch_mode(struct iio_dev *indio_dev,
|
|
struct hid_sensor_common *st)
|
|
{
|
|
if (!hid_sensor_batch_mode_supported(st))
|
|
return;
|
|
|
|
iio_buffer_set_attrs(indio_dev->buffer, hid_sensor_fifo_attributes);
|
|
}
|
|
|
|
static int _hid_sensor_power_state(struct hid_sensor_common *st, bool state)
|
|
{
|
|
int state_val;
|
|
int report_val;
|
|
s32 poll_value = 0;
|
|
|
|
if (state) {
|
|
if (sensor_hub_device_open(st->hsdev))
|
|
return -EIO;
|
|
|
|
atomic_inc(&st->data_ready);
|
|
|
|
state_val = hid_sensor_get_usage_index(st->hsdev,
|
|
st->power_state.report_id,
|
|
st->power_state.index,
|
|
HID_USAGE_SENSOR_PROP_POWER_STATE_D0_FULL_POWER_ENUM);
|
|
report_val = hid_sensor_get_usage_index(st->hsdev,
|
|
st->report_state.report_id,
|
|
st->report_state.index,
|
|
HID_USAGE_SENSOR_PROP_REPORTING_STATE_ALL_EVENTS_ENUM);
|
|
|
|
poll_value = hid_sensor_read_poll_value(st);
|
|
} else {
|
|
int val;
|
|
|
|
val = atomic_dec_if_positive(&st->data_ready);
|
|
if (val < 0)
|
|
return 0;
|
|
|
|
sensor_hub_device_close(st->hsdev);
|
|
state_val = hid_sensor_get_usage_index(st->hsdev,
|
|
st->power_state.report_id,
|
|
st->power_state.index,
|
|
HID_USAGE_SENSOR_PROP_POWER_STATE_D4_POWER_OFF_ENUM);
|
|
report_val = hid_sensor_get_usage_index(st->hsdev,
|
|
st->report_state.report_id,
|
|
st->report_state.index,
|
|
HID_USAGE_SENSOR_PROP_REPORTING_STATE_NO_EVENTS_ENUM);
|
|
}
|
|
|
|
if (state_val >= 0) {
|
|
state_val += st->power_state.logical_minimum;
|
|
sensor_hub_set_feature(st->hsdev, st->power_state.report_id,
|
|
st->power_state.index, sizeof(state_val),
|
|
&state_val);
|
|
}
|
|
|
|
if (report_val >= 0) {
|
|
report_val += st->report_state.logical_minimum;
|
|
sensor_hub_set_feature(st->hsdev, st->report_state.report_id,
|
|
st->report_state.index,
|
|
sizeof(report_val),
|
|
&report_val);
|
|
}
|
|
|
|
pr_debug("HID_SENSOR %s set power_state %d report_state %d\n",
|
|
st->pdev->name, state_val, report_val);
|
|
|
|
sensor_hub_get_feature(st->hsdev, st->power_state.report_id,
|
|
st->power_state.index,
|
|
sizeof(state_val), &state_val);
|
|
if (state && poll_value)
|
|
msleep_interruptible(poll_value * 2);
|
|
|
|
return 0;
|
|
}
|
|
EXPORT_SYMBOL(hid_sensor_power_state);
|
|
|
|
int hid_sensor_power_state(struct hid_sensor_common *st, bool state)
|
|
{
|
|
|
|
#ifdef CONFIG_PM
|
|
int ret;
|
|
|
|
if (atomic_add_unless(&st->runtime_pm_enable, 1, 1))
|
|
pm_runtime_enable(&st->pdev->dev);
|
|
|
|
if (state) {
|
|
atomic_inc(&st->user_requested_state);
|
|
ret = pm_runtime_get_sync(&st->pdev->dev);
|
|
} else {
|
|
atomic_dec(&st->user_requested_state);
|
|
pm_runtime_mark_last_busy(&st->pdev->dev);
|
|
pm_runtime_use_autosuspend(&st->pdev->dev);
|
|
ret = pm_runtime_put_autosuspend(&st->pdev->dev);
|
|
}
|
|
if (ret < 0) {
|
|
if (state)
|
|
pm_runtime_put_noidle(&st->pdev->dev);
|
|
return ret;
|
|
}
|
|
|
|
return 0;
|
|
#else
|
|
atomic_set(&st->user_requested_state, state);
|
|
return _hid_sensor_power_state(st, state);
|
|
#endif
|
|
}
|
|
|
|
static void hid_sensor_set_power_work(struct work_struct *work)
|
|
{
|
|
struct hid_sensor_common *attrb = container_of(work,
|
|
struct hid_sensor_common,
|
|
work);
|
|
|
|
if (attrb->poll_interval >= 0)
|
|
sensor_hub_set_feature(attrb->hsdev, attrb->poll.report_id,
|
|
attrb->poll.index,
|
|
sizeof(attrb->poll_interval),
|
|
&attrb->poll_interval);
|
|
|
|
if (attrb->raw_hystersis >= 0)
|
|
sensor_hub_set_feature(attrb->hsdev,
|
|
attrb->sensitivity.report_id,
|
|
attrb->sensitivity.index,
|
|
sizeof(attrb->raw_hystersis),
|
|
&attrb->raw_hystersis);
|
|
|
|
if (attrb->latency_ms > 0)
|
|
hid_sensor_set_report_latency(attrb, attrb->latency_ms);
|
|
|
|
if (atomic_read(&attrb->user_requested_state))
|
|
_hid_sensor_power_state(attrb, true);
|
|
}
|
|
|
|
static int hid_sensor_data_rdy_trigger_set_state(struct iio_trigger *trig,
|
|
bool state)
|
|
{
|
|
return hid_sensor_power_state(iio_trigger_get_drvdata(trig), state);
|
|
}
|
|
|
|
void hid_sensor_remove_trigger(struct hid_sensor_common *attrb)
|
|
{
|
|
if (atomic_read(&attrb->runtime_pm_enable))
|
|
pm_runtime_disable(&attrb->pdev->dev);
|
|
|
|
pm_runtime_set_suspended(&attrb->pdev->dev);
|
|
pm_runtime_put_noidle(&attrb->pdev->dev);
|
|
|
|
cancel_work_sync(&attrb->work);
|
|
iio_trigger_unregister(attrb->trigger);
|
|
iio_trigger_free(attrb->trigger);
|
|
}
|
|
EXPORT_SYMBOL(hid_sensor_remove_trigger);
|
|
|
|
static const struct iio_trigger_ops hid_sensor_trigger_ops = {
|
|
.set_trigger_state = &hid_sensor_data_rdy_trigger_set_state,
|
|
};
|
|
|
|
int hid_sensor_setup_trigger(struct iio_dev *indio_dev, const char *name,
|
|
struct hid_sensor_common *attrb)
|
|
{
|
|
int ret;
|
|
struct iio_trigger *trig;
|
|
|
|
trig = iio_trigger_alloc("%s-dev%d", name, indio_dev->id);
|
|
if (trig == NULL) {
|
|
dev_err(&indio_dev->dev, "Trigger Allocate Failed\n");
|
|
ret = -ENOMEM;
|
|
goto error_ret;
|
|
}
|
|
|
|
trig->dev.parent = indio_dev->dev.parent;
|
|
iio_trigger_set_drvdata(trig, attrb);
|
|
trig->ops = &hid_sensor_trigger_ops;
|
|
ret = iio_trigger_register(trig);
|
|
|
|
if (ret) {
|
|
dev_err(&indio_dev->dev, "Trigger Register Failed\n");
|
|
goto error_free_trig;
|
|
}
|
|
attrb->trigger = trig;
|
|
indio_dev->trig = iio_trigger_get(trig);
|
|
|
|
hid_sensor_setup_batch_mode(indio_dev, attrb);
|
|
|
|
ret = pm_runtime_set_active(&indio_dev->dev);
|
|
if (ret)
|
|
goto error_unreg_trigger;
|
|
|
|
iio_device_set_drvdata(indio_dev, attrb);
|
|
|
|
INIT_WORK(&attrb->work, hid_sensor_set_power_work);
|
|
|
|
pm_suspend_ignore_children(&attrb->pdev->dev, true);
|
|
/* Default to 3 seconds, but can be changed from sysfs */
|
|
pm_runtime_set_autosuspend_delay(&attrb->pdev->dev,
|
|
3000);
|
|
return ret;
|
|
error_unreg_trigger:
|
|
iio_trigger_unregister(trig);
|
|
error_free_trig:
|
|
iio_trigger_free(trig);
|
|
error_ret:
|
|
return ret;
|
|
}
|
|
EXPORT_SYMBOL(hid_sensor_setup_trigger);
|
|
|
|
static int __maybe_unused hid_sensor_suspend(struct device *dev)
|
|
{
|
|
struct iio_dev *indio_dev = dev_get_drvdata(dev);
|
|
struct hid_sensor_common *attrb = iio_device_get_drvdata(indio_dev);
|
|
|
|
return _hid_sensor_power_state(attrb, false);
|
|
}
|
|
|
|
static int __maybe_unused hid_sensor_resume(struct device *dev)
|
|
{
|
|
struct iio_dev *indio_dev = dev_get_drvdata(dev);
|
|
struct hid_sensor_common *attrb = iio_device_get_drvdata(indio_dev);
|
|
schedule_work(&attrb->work);
|
|
return 0;
|
|
}
|
|
|
|
static int __maybe_unused hid_sensor_runtime_resume(struct device *dev)
|
|
{
|
|
struct iio_dev *indio_dev = dev_get_drvdata(dev);
|
|
struct hid_sensor_common *attrb = iio_device_get_drvdata(indio_dev);
|
|
return _hid_sensor_power_state(attrb, true);
|
|
}
|
|
|
|
const struct dev_pm_ops hid_sensor_pm_ops = {
|
|
SET_SYSTEM_SLEEP_PM_OPS(hid_sensor_suspend, hid_sensor_resume)
|
|
SET_RUNTIME_PM_OPS(hid_sensor_suspend,
|
|
hid_sensor_runtime_resume, NULL)
|
|
};
|
|
EXPORT_SYMBOL(hid_sensor_pm_ops);
|
|
|
|
MODULE_AUTHOR("Srinivas Pandruvada <srinivas.pandruvada@intel.com>");
|
|
MODULE_DESCRIPTION("HID Sensor trigger processing");
|
|
MODULE_LICENSE("GPL");
|