Skip to content

Commit 6e49557

Browse files
committed
Merge tag 'iio-for-3.20a_take2' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-testing
Jonathan writes: First round of IIO new drivers, cleanups and functionality for the 3.20 cycle take 2 Updated pull request with Daniel's fix on top for the power management Kconfig changes that had snuck in since last update of the IIO tree worked it's way through from mainline. Original pull message New device support * jsa1212 proxmity / ambient light sensor * SM08500 supported added to the kxcjk-1013 accelerometer driver * KMX61 Accelerometer/Magnetometer. This took a somewhat rocky path being first merged, then reverted for a rewrite after a discussion of how to support additional functionality and finally being merged prior to some last reviews coming in, with resultant follow up patches. * Freescale mma9551l driver (minor follow up warning supression patch). * Semtech SX9500 proximity device driver. * ak8975 gains support for ak09911 and ak09912 and drop the standalone driver for the ak09911. New functionality * Dummy driver gains some virtual registers making it more flexible. * IIO_ACTIVITY channel types, with modifiers running, walking etc. This is to support on chip motion clasifiers. As such it is in the form of a confidence percentage. The only devices so far only do binary decisions but this gives us room when other devices give more nuanced clasification. * IIO_EV_DIR_NONE type for events where there is no obvious direction. First case is step detection. * IIO_STEPS channel type for pedometers. * ENABLE mask element used to control turning on counting types such as the pedometer that need a 'start point'. * INSTANCE event type to support things that happen once. * info element for height calibration (used in various motion estimation algorithms). Note heigh tof use * dummy driver demonstration of the use of all the new bits above. * event monitor support for the new events. * inv_mpu6050 gains an i2c mux to allow bypassing the device to access additional devices connected on the other side of it. Note that in Windows these are handled by firmware on the device and not exposed directly. * inv_mpu6050 gains ACPI enumeration. * inkern interface gains iio_write_channel_raw to allow in kernel users of DAC functionality via a simple wrapper. * Document input current readings in the ABI docs. * Add an error message when we get an out of range error in device tree processing for the in kernel interfaces. Basically a device tree debugging aid. * Add a sanity check that a scan index for a channel is unique during registration. There to help catch bugs as this should never happen in a bug free driver. Cleanups and fixlets A rework of buffer registration from Lars - a precursor to some other upcoming new stuff (a few patches from others rolled in here as well). * Ensure all drivers register the same channels for the device and buffer. * Move buffer registration into the core rather than using the old two step approach. Now we have simple ways of using a unified set channels for both without requiring channels be exposed by both interface, this removes a fair bit of boilerplate. * Stop sca3000 and ad5933 (both in staging) enabling buffer channels by default. It has long be convention in IIO to startup with no channels enabled and leave it up to userspace to say what goes in the buffer. Getting rid of these allows us to drop export of iio_scan_mask_set. * Drop get_bytes_per_datum from iio_buffer_access_funcs as not been used for a while. * Allocate standard buffer attributes in the core rather than in every driver with a buffer. * Make the length attribute read only when a driver is not able to set the length. * Drop the get_length callback for buffers as it is already available in struct iio_buffer. * Drop an unused arguement form iio_kfifo_allocate and add devm allocator for it. * some kconfig entries gain anotation with the resulting module name. * Fix a resulting compile issue in dummy driver due to a stub taking wrong parameters as a result of the above rework. * Fix an off by 2 error in copying the core assigned buffer attributes. Other cleanups, * Trivial space before comma fixups. * ak8975 fixlets - none critical. Rework to allow more device support. * Drop unnecessary sizeof(u8) calls. * bmp280 - refactor the compensation code to reduce copy operations and code length. A second patch futher optimized this and performed some other minor cleanups. * kxcjk-1013 - various power control cleanups to avoid unnecessary enable / disable of device. Make sure it is only controlled at all if CONFIG_PM is enabled. Also som cleanups of error paths. * Small cleanups in adf4530 driver - pointless message and unnecessary braces. * Clarifiy the proximity ABI docs to make it clear it should get bigger as we move futher away. * Drop a misleading comment form industrialio-core.c * Trivial white space cleanups. * sca3000 looses an unused debug function. * Fix char unsigned ordering in ad8366 * Increase the sleep time in ad9523 to make it predictable (value didn't really matter so make it more than 20 msecs) * mxs-lradc touchscreen property cleanups in device tree are fixed to ensure the meet all the 'interesting' documentation. * A couple of cleanups for the staging ad5933 driver to avoid unnecessary conversion to a processed temperature vlaue in kernel and remove platform data form the state structure as not needed after probe. * Fix a wrong scale factor in the docs. Misc * Add IIO include files to the maintainers entry.
2 parents e600885 + df1fad8 commit 6e49557

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+5313
-1115
lines changed

Documentation/ABI/testing/sysfs-bus-iio

Lines changed: 94 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,18 @@ Description:
9292
is required is a consistent labeling. Units after application
9393
of scale and offset are millivolts.
9494

95+
What: /sys/bus/iio/devices/iio:deviceX/in_currentY_raw
96+
What: /sys/bus/iio/devices/iio:deviceX/in_currentY_supply_raw
97+
KernelVersion: 3.17
98+
99+
Description:
100+
Raw (unscaled no bias removal etc.) current measurement from
101+
channel Y. In special cases where the channel does not
102+
correspond to externally available input one of the named
103+
versions may be used. The number must always be specified and
104+
unique to allow association with event codes. Units after
105+
application of scale and offset are milliamps.
106+
95107
What: /sys/bus/iio/devices/iio:deviceX/in_capacitanceY_raw
96108
KernelVersion: 3.2
97109
@@ -234,6 +246,8 @@ What: /sys/bus/iio/devices/iio:deviceX/in_accel_y_offset
234246
What: /sys/bus/iio/devices/iio:deviceX/in_accel_z_offset
235247
What: /sys/bus/iio/devices/iio:deviceX/in_voltageY_offset
236248
What: /sys/bus/iio/devices/iio:deviceX/in_voltage_offset
249+
What: /sys/bus/iio/devices/iio:deviceX/in_currentY_offset
250+
What: /sys/bus/iio/devices/iio:deviceX/in_current_offset
237251
What: /sys/bus/iio/devices/iio:deviceX/in_tempY_offset
238252
What: /sys/bus/iio/devices/iio:deviceX/in_temp_offset
239253
What: /sys/bus/iio/devices/iio:deviceX/in_pressureY_offset
@@ -262,6 +276,9 @@ What: /sys/bus/iio/devices/iio:deviceX/in_voltage_scale
262276
What: /sys/bus/iio/devices/iio:deviceX/in_voltage-voltage_scale
263277
What: /sys/bus/iio/devices/iio:deviceX/out_voltageY_scale
264278
What: /sys/bus/iio/devices/iio:deviceX/out_altvoltageY_scale
279+
What: /sys/bus/iio/devices/iio:deviceX/in_currentY_scale
280+
What: /sys/bus/iio/devices/iio:deviceX/in_currentY_supply_scale
281+
What: /sys/bus/iio/devices/iio:deviceX/in_current_scale
265282
What: /sys/bus/iio/devices/iio:deviceX/in_accel_scale
266283
What: /sys/bus/iio/devices/iio:deviceX/in_accel_peak_scale
267284
What: /sys/bus/iio/devices/iio:deviceX/in_anglvel_scale
@@ -323,6 +340,14 @@ Description:
323340
production inaccuracies). If shared across all channels,
324341
<type>_calibscale is used.
325342

343+
What: /sys/bus/iio/devices/iio:deviceX/in_steps_calibheight
344+
KernelVersion: 3.19
345+
346+
Description:
347+
Height of the user (in centimeters) used by some pedometers
348+
to compute the stride length, distance, speed and activity
349+
type.
350+
326351
What: /sys/bus/iio/devices/iio:deviceX/in_accel_scale_available
327352
What: /sys/.../iio:deviceX/in_voltageX_scale_available
328353
What: /sys/.../iio:deviceX/in_voltage-voltage_scale_available
@@ -790,6 +815,40 @@ Description:
790815
met before an event is generated. If direction is not
791816
specified then this period applies to both directions.
792817

818+
What: /sys/.../events/in_activity_still_thresh_rising_en
819+
What: /sys/.../events/in_activity_still_thresh_falling_en
820+
What: /sys/.../events/in_activity_walking_thresh_rising_en
821+
What: /sys/.../events/in_activity_walking_thresh_falling_en
822+
What: /sys/.../events/in_activity_jogging_thresh_rising_en
823+
What: /sys/.../events/in_activity_jogging_thresh_falling_en
824+
What: /sys/.../events/in_activity_running_thresh_rising_en
825+
What: /sys/.../events/in_activity_running_thresh_falling_en
826+
KernelVersion: 3.19
827+
828+
Description:
829+
Enables or disables activitity events. Depending on direction
830+
an event is generated when sensor ENTERS or LEAVES a given state.
831+
832+
What: /sys/.../events/in_activity_still_thresh_rising_value
833+
What: /sys/.../events/in_activity_still_thresh_falling_value
834+
What: /sys/.../events/in_activity_walking_thresh_rising_value
835+
What: /sys/.../events/in_activity_walking_thresh_falling_value
836+
What: /sys/.../events/in_activity_jogging_thresh_rising_value
837+
What: /sys/.../events/in_activity_jogging_thresh_falling_value
838+
What: /sys/.../events/in_activity_running_thresh_rising_value
839+
What: /sys/.../events/in_activity_running_thresh_falling_value
840+
KernelVersion: 3.19
841+
842+
Description:
843+
Confidence value (in units as percentage) to be used
844+
for deciding when an event should be generated. E.g for
845+
running: If the confidence value reported by the sensor
846+
is greater than in_activity_running_thresh_rising_value
847+
then the sensor ENTERS running state. Conversely, if the
848+
confidence value reported by the sensor is lower than
849+
in_activity_running_thresh_falling_value then the sensor
850+
is LEAVING running state.
851+
793852
What: /sys/.../iio:deviceX/events/in_accel_mag_en
794853
What: /sys/.../iio:deviceX/events/in_accel_mag_rising_en
795854
What: /sys/.../iio:deviceX/events/in_accel_mag_falling_en
@@ -822,6 +881,13 @@ Description:
822881
number or direction is not specified, applies to all channels of
823882
this type.
824883

884+
What: /sys/.../events/in_steps_instance_en
885+
KernelVersion: 3.19
886+
887+
Description:
888+
Enables or disables step detection. Each time the user takes a step an
889+
event of this type will be generated.
890+
825891
What: /sys/bus/iio/devices/iio:deviceX/trigger/current_trigger
826892
KernelVersion: 2.6.35
827893
@@ -956,6 +1022,16 @@ Description:
9561022
and the relevant _type attributes to establish the data storage
9571023
format.
9581024

1025+
What: /sys/.../iio:deviceX/in_activity_still_input
1026+
What: /sys/.../iio:deviceX/in_activity_walking_input
1027+
What: /sys/.../iio:deviceX/in_activity_jogging_input
1028+
What: /sys/.../iio:deviceX/in_activity_running_input
1029+
KernelVersion: 3.19
1030+
1031+
Description:
1032+
This attribute is used to read the confidence for an activity
1033+
expressed in units as percentage.
1034+
9591035
What: /sys/.../iio:deviceX/in_anglvel_z_quadrature_correction_raw
9601036
KernelVersion: 2.6.38
9611037
@@ -992,7 +1068,9 @@ Description:
9921068
reflectivity of infrared or ultrasound emitted.
9931069
Often these sensors are unit less and as such conversion
9941070
to SI units is not possible. Where it is, the units should
995-
be meters.
1071+
be meters. If such a conversion is not possible, the reported
1072+
values should behave in the same way as a distance, i.e. lower
1073+
values indicate something is closer to the sensor.
9961074

9971075
What: /sys/.../iio:deviceX/in_illuminanceY_input
9981076
What: /sys/.../iio:deviceX/in_illuminanceY_raw
@@ -1051,3 +1129,18 @@ Description:
10511129
after application of scale and offset. If no offset or scale is
10521130
present, output should be considered as processed with the
10531131
unit in milliamps.
1132+
1133+
What: /sys/.../iio:deviceX/in_steps_en
1134+
KernelVersion: 3.19
1135+
1136+
Description:
1137+
Activates the step counter. After activation, the number of steps
1138+
taken by the user will be counted in hardware and exported through
1139+
in_steps_input.
1140+
1141+
What: /sys/.../iio:deviceX/in_steps_input
1142+
KernelVersion: 3.19
1143+
1144+
Description:
1145+
This attribute is used to read the number of steps taken by the user
1146+
since the last reboot while activated.

Documentation/devicetree/bindings/staging/iio/adc/mxs-lradc.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ Optional properties:
1212
property is not present, then the touchscreen is
1313
disabled. 5 wires is valid for i.MX28 SoC only.
1414
- fsl,ave-ctrl: number of samples per direction to calculate an average value.
15-
Allowed value is 1 ... 31, default is 4
15+
Allowed value is 1 ... 32, default is 4
1616
- fsl,ave-delay: delay between consecutive samples. Allowed value is
17-
1 ... 2047. It is used if 'fsl,ave-ctrl' > 1, counts at
17+
2 ... 2048. It is used if 'fsl,ave-ctrl' > 1, counts at
1818
2 kHz and its default is 2 (= 1 ms)
1919
- fsl,settling: delay between plate switch to next sample. Allowed value is
2020
1 ... 2047. It counts at 2 kHz and its default is

Documentation/driver-model/devres.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,8 @@ IIO
258258
devm_iio_device_free()
259259
devm_iio_device_register()
260260
devm_iio_device_unregister()
261+
devm_iio_kfifo_allocate()
262+
devm_iio_kfifo_free()
261263
devm_iio_trigger_alloc()
262264
devm_iio_trigger_free()
263265

drivers/iio/accel/Kconfig

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ config HID_SENSOR_ACCEL_3D
4343
Say yes here to build support for the HID SENSOR
4444
accelerometers 3D.
4545

46+
To compile this driver as a module, choose M here: the
47+
module will be called hid-sensor-accel-3d.
48+
4649
config IIO_ST_ACCEL_3AXIS
4750
tristate "STMicroelectronics accelerometers 3-Axis Driver"
4851
depends on (I2C || SPI_MASTER) && SYSFS
@@ -80,6 +83,9 @@ config KXSD9
8083
Say yes here to build support for the Kionix KXSD9 accelerometer.
8184
Currently this only supports the device via an SPI interface.
8285

86+
To compile this driver as a module, choose M here: the module
87+
will be called kxsd9.
88+
8389
config MMA8452
8490
tristate "Freescale MMA8452Q Accelerometer Driver"
8591
depends on I2C
@@ -105,4 +111,14 @@ config KXCJK1013
105111
To compile this driver as a module, choose M here: the module will
106112
be called kxcjk-1013.
107113

114+
config MMA9551
115+
tristate "Freescale MMA9551L Intelligent Motion-Sensing Platform Driver"
116+
depends on I2C
117+
help
118+
Say yes here to build support for the Freescale MMA9551L
119+
Intelligent Motion-Sensing Platform Driver.
120+
121+
To compile this driver as a module, choose M here: the module
122+
will be called mma9551.
123+
108124
endmenu

drivers/iio/accel/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ obj-$(CONFIG_HID_SENSOR_ACCEL_3D) += hid-sensor-accel-3d.o
99
obj-$(CONFIG_KXCJK1013) += kxcjk-1013.o
1010
obj-$(CONFIG_KXSD9) += kxsd9.o
1111
obj-$(CONFIG_MMA8452) += mma8452.o
12+
obj-$(CONFIG_MMA9551) += mma9551.o
1213

1314
obj-$(CONFIG_IIO_ST_ACCEL_3AXIS) += st_accel.o
1415
st_accel-y := st_accel_core.o

drivers/iio/accel/kxcjk-1013.c

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ struct kxcjk1013_data {
108108
bool motion_trigger_on;
109109
int64_t timestamp;
110110
enum kx_chipset chipset;
111+
bool is_smo8500_device;
111112
};
112113

113114
enum kxcjk1013_axis {
@@ -377,6 +378,7 @@ static int kxcjk1013_get_startup_times(struct kxcjk1013_data *data)
377378

378379
static int kxcjk1013_set_power_state(struct kxcjk1013_data *data, bool on)
379380
{
381+
#ifdef CONFIG_PM
380382
int ret;
381383

382384
if (on)
@@ -388,8 +390,11 @@ static int kxcjk1013_set_power_state(struct kxcjk1013_data *data, bool on)
388390
if (ret < 0) {
389391
dev_err(&data->client->dev,
390392
"Failed: kxcjk1013_set_power_state for %d\n", on);
393+
if (on)
394+
pm_runtime_put_noidle(&data->client->dev);
391395
return ret;
392396
}
397+
#endif
393398

394399
return 0;
395400
}
@@ -858,6 +863,8 @@ static int kxcjk1013_write_event_config(struct iio_dev *indio_dev,
858863

859864
ret = kxcjk1013_setup_any_motion_interrupt(data, state);
860865
if (ret < 0) {
866+
kxcjk1013_set_power_state(data, false);
867+
data->ev_enable_state = 0;
861868
mutex_unlock(&data->mutex);
862869
return ret;
863870
}
@@ -1008,6 +1015,7 @@ static int kxcjk1013_data_rdy_trigger_set_state(struct iio_trigger *trig,
10081015
else
10091016
ret = kxcjk1013_setup_new_data_interrupt(data, state);
10101017
if (ret < 0) {
1018+
kxcjk1013_set_power_state(data, false);
10111019
mutex_unlock(&data->mutex);
10121020
return ret;
10131021
}
@@ -1131,12 +1139,16 @@ static irqreturn_t kxcjk1013_data_rdy_trig_poll(int irq, void *private)
11311139
}
11321140

11331141
static const char *kxcjk1013_match_acpi_device(struct device *dev,
1134-
enum kx_chipset *chipset)
1142+
enum kx_chipset *chipset,
1143+
bool *is_smo8500_device)
11351144
{
11361145
const struct acpi_device_id *id;
1146+
11371147
id = acpi_match_device(dev->driver->acpi_match_table, dev);
11381148
if (!id)
11391149
return NULL;
1150+
if (strcmp(id->id, "SMO8500") == 0)
1151+
*is_smo8500_device = true;
11401152
*chipset = (enum kx_chipset)id->driver_data;
11411153

11421154
return dev_name(dev);
@@ -1151,6 +1163,8 @@ static int kxcjk1013_gpio_probe(struct i2c_client *client,
11511163

11521164
if (!client)
11531165
return -EINVAL;
1166+
if (data->is_smo8500_device)
1167+
return -ENOTSUPP;
11541168

11551169
dev = &client->dev;
11561170

@@ -1200,7 +1214,8 @@ static int kxcjk1013_probe(struct i2c_client *client,
12001214
name = id->name;
12011215
} else if (ACPI_HANDLE(&client->dev)) {
12021216
name = kxcjk1013_match_acpi_device(&client->dev,
1203-
&data->chipset);
1217+
&data->chipset,
1218+
&data->is_smo8500_device);
12041219
} else
12051220
return -ENODEV;
12061221

@@ -1228,21 +1243,25 @@ static int kxcjk1013_probe(struct i2c_client *client,
12281243
KXCJK1013_IRQ_NAME,
12291244
indio_dev);
12301245
if (ret)
1231-
return ret;
1246+
goto err_poweroff;
12321247

12331248
data->dready_trig = devm_iio_trigger_alloc(&client->dev,
12341249
"%s-dev%d",
12351250
indio_dev->name,
12361251
indio_dev->id);
1237-
if (!data->dready_trig)
1238-
return -ENOMEM;
1252+
if (!data->dready_trig) {
1253+
ret = -ENOMEM;
1254+
goto err_poweroff;
1255+
}
12391256

12401257
data->motion_trig = devm_iio_trigger_alloc(&client->dev,
12411258
"%s-any-motion-dev%d",
12421259
indio_dev->name,
12431260
indio_dev->id);
1244-
if (!data->motion_trig)
1245-
return -ENOMEM;
1261+
if (!data->motion_trig) {
1262+
ret = -ENOMEM;
1263+
goto err_poweroff;
1264+
}
12461265

12471266
data->dready_trig->dev.parent = &client->dev;
12481267
data->dready_trig->ops = &kxcjk1013_trigger_ops;
@@ -1251,7 +1270,7 @@ static int kxcjk1013_probe(struct i2c_client *client,
12511270
iio_trigger_get(indio_dev->trig);
12521271
ret = iio_trigger_register(data->dready_trig);
12531272
if (ret)
1254-
return ret;
1273+
goto err_poweroff;
12551274

12561275
data->motion_trig->dev.parent = &client->dev;
12571276
data->motion_trig->ops = &kxcjk1013_trigger_ops;
@@ -1300,6 +1319,8 @@ static int kxcjk1013_probe(struct i2c_client *client,
13001319
iio_trigger_unregister(data->dready_trig);
13011320
if (data->motion_trig)
13021321
iio_trigger_unregister(data->motion_trig);
1322+
err_poweroff:
1323+
kxcjk1013_set_mode(data, STANDBY);
13031324

13041325
return ret;
13051326
}
@@ -1349,10 +1370,7 @@ static int kxcjk1013_resume(struct device *dev)
13491370
int ret = 0;
13501371

13511372
mutex_lock(&data->mutex);
1352-
/* Check, if the suspend occured while active */
1353-
if (data->dready_trigger_on || data->motion_trigger_on ||
1354-
data->ev_enable_state)
1355-
ret = kxcjk1013_set_mode(data, OPERATION);
1373+
ret = kxcjk1013_set_mode(data, OPERATION);
13561374
mutex_unlock(&data->mutex);
13571375

13581376
return ret;
@@ -1364,8 +1382,14 @@ static int kxcjk1013_runtime_suspend(struct device *dev)
13641382
{
13651383
struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
13661384
struct kxcjk1013_data *data = iio_priv(indio_dev);
1385+
int ret;
13671386

1368-
return kxcjk1013_set_mode(data, STANDBY);
1387+
ret = kxcjk1013_set_mode(data, STANDBY);
1388+
if (ret < 0) {
1389+
dev_err(&data->client->dev, "powering off device failed\n");
1390+
return -EAGAIN;
1391+
}
1392+
return 0;
13691393
}
13701394

13711395
static int kxcjk1013_runtime_resume(struct device *dev)
@@ -1399,6 +1423,7 @@ static const struct acpi_device_id kx_acpi_match[] = {
13991423
{"KXCJ1013", KXCJK1013},
14001424
{"KXCJ1008", KXCJ91008},
14011425
{"KXTJ1009", KXTJ21009},
1426+
{"SMO8500", KXCJ91008},
14021427
{ },
14031428
};
14041429
MODULE_DEVICE_TABLE(acpi, kx_acpi_match);
@@ -1407,6 +1432,7 @@ static const struct i2c_device_id kxcjk1013_id[] = {
14071432
{"kxcjk1013", KXCJK1013},
14081433
{"kxcj91008", KXCJ91008},
14091434
{"kxtj21009", KXTJ21009},
1435+
{"SMO8500", KXCJ91008},
14101436
{}
14111437
};
14121438

0 commit comments

Comments
 (0)