Commit 7e9fa830 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

Merge tag 'iio-for-6.4b' of...

Merge tag 'iio-for-6.4b' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into char-misc-next

Jonathan writes:

2nd set of IIO features and cleanups for the 6.4 cycle.

A few more changes. Some were dependent on fixes that are now upstream
and in char-misc-next.

st,lsm6dsx:
 - Add an ACPI ID (SMO8B30) and mount matrix (ROTM) seen in the wild.
ti,palmas
 - Take probe fully devm managed.
 - Add threshold event support (after some rework)
 - Stop changing the event config on suspend and resume.

* tag 'iio-for-6.4b' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio:
  iio: adc: palmas: don't alter event config on suspend/resume
  iio: adc: palmas: add support for iio threshold events
  iio: adc: palmas: always reset events on unload
  iio: adc: palmas: move eventX_enable into palmas_adc_event
  iio: adc: palmas: use iio_event_direction for threshold polarity
  iio: adc: palmas: replace "wakeup" with "event"
  iio: adc: palmas: remove adc_wakeupX_data
  iio: adc: palmas: Take probe fully device managed.
  iio: imu: lsm6dsx: Add ACPI mount matrix retrieval
  iio: imu: lsm6dsx: Support SMO8B30 ACPI ID for LSM6DS3TR-C
parents fba51482 52cc189b
This diff is collapsed.
......@@ -40,7 +40,7 @@
#define ST_ASM330LHB_DEV_NAME "asm330lhb"
enum st_lsm6dsx_hw_id {
ST_LSM6DS3_ID,
ST_LSM6DS3_ID = 1,
ST_LSM6DS3H_ID,
ST_LSM6DSL_ID,
ST_LSM6DSM_ID,
......
......@@ -56,6 +56,7 @@
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/acpi.h>
#include <linux/delay.h>
#include <linux/iio/events.h>
#include <linux/iio/iio.h>
......@@ -2624,6 +2625,73 @@ static int st_lsm6dsx_init_regulators(struct device *dev)
return 0;
}
#ifdef CONFIG_ACPI
static int lsm6dsx_get_acpi_mount_matrix(struct device *dev,
struct iio_mount_matrix *orientation)
{
struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
struct acpi_device *adev = ACPI_COMPANION(dev);
union acpi_object *obj, *elements;
acpi_status status;
int i, j, val[3];
char *str;
if (!has_acpi_companion(dev))
return -EINVAL;
if (!acpi_has_method(adev->handle, "ROTM"))
return -EINVAL;
status = acpi_evaluate_object(adev->handle, "ROTM", NULL, &buffer);
if (ACPI_FAILURE(status)) {
dev_warn(dev, "Failed to get ACPI mount matrix: %d\n", status);
return -EINVAL;
}
obj = buffer.pointer;
if (obj->type != ACPI_TYPE_PACKAGE || obj->package.count != 3)
goto unknown_format;
elements = obj->package.elements;
for (i = 0; i < 3; i++) {
if (elements[i].type != ACPI_TYPE_STRING)
goto unknown_format;
str = elements[i].string.pointer;
if (sscanf(str, "%d %d %d", &val[0], &val[1], &val[2]) != 3)
goto unknown_format;
for (j = 0; j < 3; j++) {
switch (val[j]) {
case -1: str = "-1"; break;
case 0: str = "0"; break;
case 1: str = "1"; break;
default: goto unknown_format;
}
orientation->rotation[i * 3 + j] = str;
}
}
kfree(buffer.pointer);
return 0;
unknown_format:
dev_warn(dev, "Unknown ACPI mount matrix format, ignoring\n");
kfree(buffer.pointer);
return -EINVAL;
}
#else
static int lsm6dsx_get_acpi_mount_matrix(struct device *dev,
struct iio_mount_matrix *orientation)
{
return false;
}
#endif
int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id,
struct regmap *regmap)
{
......@@ -2698,9 +2766,12 @@ int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id,
return err;
}
err = iio_read_mount_matrix(hw->dev, &hw->orientation);
if (err)
return err;
err = lsm6dsx_get_acpi_mount_matrix(hw->dev, &hw->orientation);
if (err) {
err = iio_read_mount_matrix(hw->dev, &hw->orientation);
if (err)
return err;
}
for (i = 0; i < ST_LSM6DSX_ID_MAX; i++) {
if (!hw->iio_devs[i])
......
......@@ -23,10 +23,15 @@ static const struct regmap_config st_lsm6dsx_i2c_regmap_config = {
static int st_lsm6dsx_i2c_probe(struct i2c_client *client)
{
const struct i2c_device_id *id = i2c_client_get_device_id(client);
int hw_id = id->driver_data;
int hw_id;
struct regmap *regmap;
hw_id = (kernel_ulong_t)device_get_match_data(&client->dev);
if (!hw_id)
hw_id = i2c_client_get_device_id(client)->driver_data;
if (!hw_id)
return -EINVAL;
regmap = devm_regmap_init_i2c(client, &st_lsm6dsx_i2c_regmap_config);
if (IS_ERR(regmap)) {
dev_err(&client->dev, "Failed to register i2c regmap %ld\n", PTR_ERR(regmap));
......@@ -133,6 +138,12 @@ static const struct of_device_id st_lsm6dsx_i2c_of_match[] = {
};
MODULE_DEVICE_TABLE(of, st_lsm6dsx_i2c_of_match);
static const struct acpi_device_id st_lsm6dsx_i2c_acpi_match[] = {
{ "SMO8B30", ST_LSM6DS3TRC_ID, },
{}
};
MODULE_DEVICE_TABLE(acpi, st_lsm6dsx_i2c_acpi_match);
static const struct i2c_device_id st_lsm6dsx_i2c_id_table[] = {
{ ST_LSM6DS3_DEV_NAME, ST_LSM6DS3_ID },
{ ST_LSM6DS3H_DEV_NAME, ST_LSM6DS3H_ID },
......@@ -166,6 +177,7 @@ static struct i2c_driver st_lsm6dsx_driver = {
.name = "st_lsm6dsx_i2c",
.pm = pm_sleep_ptr(&st_lsm6dsx_pm_ops),
.of_match_table = st_lsm6dsx_i2c_of_match,
.acpi_match_table = st_lsm6dsx_i2c_acpi_match,
},
.probe_new = st_lsm6dsx_i2c_probe,
.id_table = st_lsm6dsx_i2c_id_table,
......
......@@ -128,12 +128,6 @@ struct palmas_pmic_driver_data {
struct regulator_config config);
};
struct palmas_adc_wakeup_property {
int adc_channel_number;
int adc_high_threshold;
int adc_low_threshold;
};
struct palmas_gpadc_platform_data {
/* Channel 3 current source is only enabled during conversion */
int ch3_current; /* 0: off; 1: 10uA; 2: 400uA; 3: 800 uA */
......@@ -152,8 +146,6 @@ struct palmas_gpadc_platform_data {
int start_polarity;
int auto_conversion_period_ms;
struct palmas_adc_wakeup_property *adc_wakeup1_data;
struct palmas_adc_wakeup_property *adc_wakeup2_data;
};
struct palmas_reg_init {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment