mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-26 14:14:01 +08:00
Second set of Counter and IIO new device support, cleanups etc for 5.14
Counter ------ First part of general rework of counter subsystem to add a chrdev interface for event drive data capture. Most of it will hopefully land next cycle. * Consolidate documentation to avoid multiple copies of same docs in per device files. * Constify various arrays etc across subsystem. * 104-quad-8: - Annotate the module config parameter to avoid using it when kernel is locked down. - Spelling and trivial comment drops etc * Intel QEP - Follow up cleanups of trivial stuff from initial patch series. IIO --- Includes some cleanups as part of two ongoing audits - runtime pm usage in IIO. - Insufficient alignment on buffers passed to iio_push_to_buffers_with_timstamp() New device support * bosch,bmc150 - Add ID for BMA253 Minor features / cleanups / minor fixes / late breaking fixes * iio_push_to_buffers_with_timestamp() alignment fixes. This set includes those where the best option is to mark the buffer as __aligned(8). Normally this choice was made because there is too high a degree of possible variation in number of channels enabled to be able to guarantee the timestamp was always in the same location. This ruled out the more obvious structure form used in other drivers. Only one small class of related issues have patches under review and we can finally tighten up the explicit rules to reflect the hidden requirement. * dummy - Kconfig build dependency fix. * adi,ad_sigma_delta - General devm related simplifications for these devices. * adi,adf4350 - Fix some missing cleanup on error path. * adi,adis, ADC drivers. - Clean out unneeded spi_set_drvdata() * ams-taos,tcs3472 - Fix a potential free of an irq that was never allocated. * atlas,sensor - Drop unbalanced runtime pm call and use pm_runtime_resume_and_get() to reduce boilerplate. * bosch,bma180 - Fix bandwidth register values used. * bosch,bmc150 - Fix wrong pointer being dereferenced in remove. - Stop device trying unregister itself rather than the second device. - Refactor ACPI second device handing. - Add support for DUAL250E ACPI HID. - Move some stuff into the header to enable following patches to not add additional accessor functions. Drop existing accessors. - Add support for hinge angle setting with DUAL250E ACPI DSM to ensure keyboard and touchpad enabled correctly when in laptop mode and disabled otherwise. - Add label attr for the multiple sensor locations with DUAL250E ACPI HID. - Fix scale units for bma222 - Various reordering of devices supported lists to be alphabetical order. - Drop unnecessary duplicated chip_info_tbl[] entries. - Document that some devices have two interrupts, even if not currently used by the driver. - Move bma254 over to the bma255 driver. - Move to more consistent scale values, based on assumption that some datasheets use lower precision in their calculations in comparison with others. * hid-sensors - Use namespaces for exported symbols. - Update includes using manual inspection of output of the include-what-you-use tool. * invensense,icp10100 - Drop unbalanced runtime pm put. Use pm_runtime_resume_and_get() to cleanly handle potential error. * invensense,mpu6050 - Drop use of %hhx string formatting. - runtime pm boilerplate removal and drop an unbalanced call in remove. * liteon,ltr501 - Fix inaccurate volatile register list. - Fix wrong mode bit. - Add a missing leXX_to_cpu() conversion. - Mark ltr501_chip_info structure as const. * pulsed-light-lidar: - Boilerplate removal using runtime_pm_resume_and_get() * scmi-sensors - Formatting of SPDX fix. * silabs,si1133 - Fix a string format warning. - Drop remaining uses of %hhx string formatting. * silabs,si1145 - Drop use of %hhx string formatting. * ti,ads1015 - Drop unbalanced runtime pm call in remove and reduce boilerplate. -----BEGIN PGP SIGNATURE----- iQJEBAABCAAvFiEEbilms4eEBlKRJoGxVIU0mcT0FogFAmDLW3URHGppYzIzQGtl cm5lbC5vcmcACgkQVIU0mcT0Foj87Q/4h+ITG64s7RZzIGAgTCXDjClW4R/yDyiR fPUdwwKtYKy8hQ+1shV1WukEKfoQ3uz339nlI6Ttm7NiIlt4Lqf4xmHRmo1vw1IJ YgyCMiFSkuNUgU/yCoHqJIAVecnQ4kVP8npNelUA5vBgQiMruzNGfTW47HDDvhFa rc7OF+9oFDdikU2T3b44Rd3iXU8mMtH7afpfmWyJLhLfVjW9Stk6MLOW7ID+r+v8 TWIAtv5PbvWKSHhr95en4YTup+oChKR2R9G0l8YJEQVl4z85zD5CTavLJ0ZMuyDy 1oyVAefVDY/ML427ulAa3bo0BEWE0RZiuxCEBDzy3gHSDSdzmiTKQiNWdTYT7UB+ +SNeNfYjZkbY2OytcwNMk7W7GW+bIdeCvhZZcySzf6yp5ZmKbbVHbszB5mEqn4B3 R3arxq7DqcP5EwWnP7ja+Yk923Gfl8GNkzLMjZYhs4VXR/A4+qznfw9TKpAXIxge HN+fs5lbkxpgEAeLvTTwVb/uimWgnR4WhJYaJlWm497a6Gvnf5Vc7Z91XMe5iUR3 tIyX7Vz7qPtWUoIlghfjkIJOFDIPwCcqG4vyn3qax8I1mA6HtWPgZoYFMEWBDazW T1tX+ThMIcvsZr7WptKhaHlUamyz4z6L7PZPmIPOhNH8hcS2fR7WU9/fN4it+s/e a5rCw4kSfQ== =xwQK -----END PGP SIGNATURE----- Merge tag 'iio-for-5.14b' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next Jonathan writes: Second set of Counter and IIO new device support, cleanups etc for 5.14 Counter ------ First part of general rework of counter subsystem to add a chrdev interface for event drive data capture. Most of it will hopefully land next cycle. * Consolidate documentation to avoid multiple copies of same docs in per device files. * Constify various arrays etc across subsystem. * 104-quad-8: - Annotate the module config parameter to avoid using it when kernel is locked down. - Spelling and trivial comment drops etc * Intel QEP - Follow up cleanups of trivial stuff from initial patch series. IIO --- Includes some cleanups as part of two ongoing audits - runtime pm usage in IIO. - Insufficient alignment on buffers passed to iio_push_to_buffers_with_timstamp() New device support * bosch,bmc150 - Add ID for BMA253 Minor features / cleanups / minor fixes / late breaking fixes * iio_push_to_buffers_with_timestamp() alignment fixes. This set includes those where the best option is to mark the buffer as __aligned(8). Normally this choice was made because there is too high a degree of possible variation in number of channels enabled to be able to guarantee the timestamp was always in the same location. This ruled out the more obvious structure form used in other drivers. Only one small class of related issues have patches under review and we can finally tighten up the explicit rules to reflect the hidden requirement. * dummy - Kconfig build dependency fix. * adi,ad_sigma_delta - General devm related simplifications for these devices. * adi,adf4350 - Fix some missing cleanup on error path. * adi,adis, ADC drivers. - Clean out unneeded spi_set_drvdata() * ams-taos,tcs3472 - Fix a potential free of an irq that was never allocated. * atlas,sensor - Drop unbalanced runtime pm call and use pm_runtime_resume_and_get() to reduce boilerplate. * bosch,bma180 - Fix bandwidth register values used. * bosch,bmc150 - Fix wrong pointer being dereferenced in remove. - Stop device trying unregister itself rather than the second device. - Refactor ACPI second device handing. - Add support for DUAL250E ACPI HID. - Move some stuff into the header to enable following patches to not add additional accessor functions. Drop existing accessors. - Add support for hinge angle setting with DUAL250E ACPI DSM to ensure keyboard and touchpad enabled correctly when in laptop mode and disabled otherwise. - Add label attr for the multiple sensor locations with DUAL250E ACPI HID. - Fix scale units for bma222 - Various reordering of devices supported lists to be alphabetical order. - Drop unnecessary duplicated chip_info_tbl[] entries. - Document that some devices have two interrupts, even if not currently used by the driver. - Move bma254 over to the bma255 driver. - Move to more consistent scale values, based on assumption that some datasheets use lower precision in their calculations in comparison with others. * hid-sensors - Use namespaces for exported symbols. - Update includes using manual inspection of output of the include-what-you-use tool. * invensense,icp10100 - Drop unbalanced runtime pm put. Use pm_runtime_resume_and_get() to cleanly handle potential error. * invensense,mpu6050 - Drop use of %hhx string formatting. - runtime pm boilerplate removal and drop an unbalanced call in remove. * liteon,ltr501 - Fix inaccurate volatile register list. - Fix wrong mode bit. - Add a missing leXX_to_cpu() conversion. - Mark ltr501_chip_info structure as const. * pulsed-light-lidar: - Boilerplate removal using runtime_pm_resume_and_get() * scmi-sensors - Formatting of SPDX fix. * silabs,si1133 - Fix a string format warning. - Drop remaining uses of %hhx string formatting. * silabs,si1145 - Drop use of %hhx string formatting. * ti,ads1015 - Drop unbalanced runtime pm call in remove and reduce boilerplate. * tag 'iio-for-5.14b' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (76 commits) iio: light: tcs3472: do not free unallocated IRQ iio: accel: bmc150: Use more consistent and accurate scale values iio: hid-sensors: Update header includes iio: pressure: icp10100: Balance runtime pm + use pm_runtime_resume_and_get() iio: prox: pulsed-light-v2: Use pm_runtime_resume_and_get() iio: chemical: atlas-sensor: Balance runtime pm + pm_runtime_resume_and_get() iio: adc: ads1015: Balance runtime pm + pm_runtime_resume_and_get() iio: imu: mpu6050: Balance runtime pm + use pm_runtime_resume_and_get() iio: hid-sensors: lighten exported symbols by moving to IIO_HID namespace iio: prox: isl29501: Fix buffer alignment in iio_push_to_buffers_with_timestamp() iio: light: vcnl4035: Fix buffer alignment in iio_push_to_buffers_with_timestamp() iio: light: vcnl4000: Fix buffer alignment in iio_push_to_buffers_with_timestamp() iio: magn: rm3100: Fix alignment of buffer in iio_push_to_buffers_with_timestamp() iio: adc: ti-ads8688: Fix alignment of buffer in iio_push_to_buffers_with_timestamp() iio: adc: mxs-lradc: Fix buffer alignment in iio_push_to_buffers_with_timestamp() iio: adc: hx711: Fix buffer alignment in iio_push_to_buffers_with_timestamp() iio: adc: at91-sama5d2: Fix buffer alignment in iio_push_to_buffers_with_timestamp() counter: interrupt-cnt: Add const qualifier for actions_list array iio: ltr501: mark ltr501_chip_info as const iio: ltr501: ltr501_read_ps(): add missing endianness conversion ...
This commit is contained in:
commit
8c51c9b59a
@ -57,6 +57,7 @@ Description:
|
||||
What: /sys/bus/counter/devices/counterX/countY/count_mode_available
|
||||
What: /sys/bus/counter/devices/counterX/countY/error_noise_available
|
||||
What: /sys/bus/counter/devices/counterX/countY/function_available
|
||||
What: /sys/bus/counter/devices/counterX/countY/prescaler_available
|
||||
What: /sys/bus/counter/devices/counterX/countY/signalZ_action_available
|
||||
KernelVersion: 5.2
|
||||
Contact: linux-iio@vger.kernel.org
|
||||
@ -154,6 +155,15 @@ Description:
|
||||
Count Y. If possible, this should match the name of the
|
||||
respective channel as it appears in the device datasheet.
|
||||
|
||||
What: /sys/bus/counter/devices/counterX/countY/prescaler
|
||||
KernelVersion: 5.2
|
||||
Contact: linux-iio@vger.kernel.org
|
||||
Description:
|
||||
Configure the prescaler value associated with Count Y.
|
||||
On the FlexTimer, the counter clock source passes through a
|
||||
prescaler (i.e. a counter). This acts like a clock
|
||||
divider.
|
||||
|
||||
What: /sys/bus/counter/devices/counterX/countY/preset
|
||||
KernelVersion: 5.2
|
||||
Contact: linux-iio@vger.kernel.org
|
||||
@ -224,11 +234,45 @@ Description:
|
||||
Read-only attribute that indicates the total number of Signals
|
||||
belonging to the Counter.
|
||||
|
||||
What: /sys/bus/counter/devices/counterX/signalY/signal
|
||||
What: /sys/bus/counter/devices/counterX/signalY/cable_fault
|
||||
KernelVersion: 5.7
|
||||
Contact: linux-iio@vger.kernel.org
|
||||
Description:
|
||||
Read-only attribute that indicates whether a differential
|
||||
encoder cable fault (not connected or loose wires) is detected
|
||||
for the respective channel of Signal Y. Valid attribute values
|
||||
are boolean. Detection must first be enabled via the
|
||||
corresponding cable_fault_enable attribute.
|
||||
|
||||
What: /sys/bus/counter/devices/counterX/signalY/cable_fault_enable
|
||||
KernelVersion: 5.7
|
||||
Contact: linux-iio@vger.kernel.org
|
||||
Description:
|
||||
Whether detection of differential encoder cable faults for the
|
||||
respective channel of Signal Y is enabled. Valid attribute
|
||||
values are boolean.
|
||||
|
||||
What: /sys/bus/counter/devices/counterX/signalY/filter_clock_prescaler
|
||||
KernelVersion: 5.7
|
||||
Contact: linux-iio@vger.kernel.org
|
||||
Description:
|
||||
Filter clock factor for input Signal Y. This prescaler value
|
||||
affects the inputs of both quadrature pair signals.
|
||||
|
||||
What: /sys/bus/counter/devices/counterX/signalY/index_polarity
|
||||
KernelVersion: 5.2
|
||||
Contact: linux-iio@vger.kernel.org
|
||||
Description:
|
||||
Signal data of Signal Y represented as a string.
|
||||
Active level of index input Signal Y; irrelevant in
|
||||
non-synchronous load mode.
|
||||
|
||||
What: /sys/bus/counter/devices/counterX/signalY/index_polarity_available
|
||||
What: /sys/bus/counter/devices/counterX/signalY/synchronous_mode_available
|
||||
KernelVersion: 5.2
|
||||
Contact: linux-iio@vger.kernel.org
|
||||
Description:
|
||||
Discrete set of available values for the respective Signal Y
|
||||
configuration are listed in this file.
|
||||
|
||||
What: /sys/bus/counter/devices/counterX/signalY/name
|
||||
KernelVersion: 5.2
|
||||
@ -237,3 +281,31 @@ Description:
|
||||
Read-only attribute that indicates the device-specific name of
|
||||
Signal Y. If possible, this should match the name of the
|
||||
respective signal as it appears in the device datasheet.
|
||||
|
||||
What: /sys/bus/counter/devices/counterX/signalY/signal
|
||||
KernelVersion: 5.2
|
||||
Contact: linux-iio@vger.kernel.org
|
||||
Description:
|
||||
Signal data of Signal Y represented as a string.
|
||||
|
||||
What: /sys/bus/counter/devices/counterX/signalY/synchronous_mode
|
||||
KernelVersion: 5.2
|
||||
Contact: linux-iio@vger.kernel.org
|
||||
Description:
|
||||
Configure the counter associated with Signal Y for
|
||||
non-synchronous or synchronous load mode. Synchronous load mode
|
||||
cannot be selected in non-quadrature (Pulse-Direction) clock
|
||||
mode.
|
||||
|
||||
non-synchronous:
|
||||
A logic low level is the active level at this index
|
||||
input. The index function (as enabled via preset_enable)
|
||||
is performed directly on the active level of the index
|
||||
input.
|
||||
|
||||
synchronous:
|
||||
Intended for interfacing with encoder Index output in
|
||||
quadrature clock mode. The active level is configured
|
||||
via index_polarity. The index function (as enabled via
|
||||
preset_enable) is performed synchronously with the
|
||||
quadrature clock on the active level of the index input.
|
||||
|
@ -1,61 +0,0 @@
|
||||
What: /sys/bus/counter/devices/counterX/signalY/cable_fault
|
||||
KernelVersion: 5.7
|
||||
Contact: linux-iio@vger.kernel.org
|
||||
Description:
|
||||
Read-only attribute that indicates whether a differential
|
||||
encoder cable fault (not connected or loose wires) is detected
|
||||
for the respective channel of Signal Y. Valid attribute values
|
||||
are boolean. Detection must first be enabled via the
|
||||
corresponding cable_fault_enable attribute.
|
||||
|
||||
What: /sys/bus/counter/devices/counterX/signalY/cable_fault_enable
|
||||
KernelVersion: 5.7
|
||||
Contact: linux-iio@vger.kernel.org
|
||||
Description:
|
||||
Whether detection of differential encoder cable faults for the
|
||||
respective channel of Signal Y is enabled. Valid attribute
|
||||
values are boolean.
|
||||
|
||||
What: /sys/bus/counter/devices/counterX/signalY/filter_clock_prescaler
|
||||
KernelVersion: 5.7
|
||||
Contact: linux-iio@vger.kernel.org
|
||||
Description:
|
||||
Filter clock factor for input Signal Y. This prescaler value
|
||||
affects the inputs of both quadrature pair signals.
|
||||
|
||||
What: /sys/bus/counter/devices/counterX/signalY/index_polarity
|
||||
KernelVersion: 5.2
|
||||
Contact: linux-iio@vger.kernel.org
|
||||
Description:
|
||||
Active level of index input Signal Y; irrelevant in
|
||||
non-synchronous load mode.
|
||||
|
||||
What: /sys/bus/counter/devices/counterX/signalY/index_polarity_available
|
||||
What: /sys/bus/counter/devices/counterX/signalY/synchronous_mode_available
|
||||
KernelVersion: 5.2
|
||||
Contact: linux-iio@vger.kernel.org
|
||||
Description:
|
||||
Discrete set of available values for the respective Signal Y
|
||||
configuration are listed in this file.
|
||||
|
||||
What: /sys/bus/counter/devices/counterX/signalY/synchronous_mode
|
||||
KernelVersion: 5.2
|
||||
Contact: linux-iio@vger.kernel.org
|
||||
Description:
|
||||
Configure the counter associated with Signal Y for
|
||||
non-synchronous or synchronous load mode. Synchronous load mode
|
||||
cannot be selected in non-quadrature (Pulse-Direction) clock
|
||||
mode.
|
||||
|
||||
non-synchronous:
|
||||
A logic low level is the active level at this index
|
||||
input. The index function (as enabled via preset_enable)
|
||||
is performed directly on the active level of the index
|
||||
input.
|
||||
|
||||
synchronous:
|
||||
Intended for interfacing with encoder Index output in
|
||||
quadrature clock mode. The active level is configured
|
||||
via index_polarity. The index function (as enabled via
|
||||
preset_enable) is performed synchronously with the
|
||||
quadrature clock on the active level of the index input.
|
@ -1,16 +0,0 @@
|
||||
What: /sys/bus/counter/devices/counterX/countY/prescaler_available
|
||||
KernelVersion: 5.2
|
||||
Contact: linux-iio@vger.kernel.org
|
||||
Description:
|
||||
Discrete set of available values for the respective Count Y
|
||||
configuration are listed in this file. Values are delimited by
|
||||
newline characters.
|
||||
|
||||
What: /sys/bus/counter/devices/counterX/countY/prescaler
|
||||
KernelVersion: 5.2
|
||||
Contact: linux-iio@vger.kernel.org
|
||||
Description:
|
||||
Configure the prescaler value associated with Count Y.
|
||||
On the FlexTimer, the counter clock source passes through a
|
||||
prescaler (i.e. a counter). This acts like a clock
|
||||
divider.
|
@ -4,7 +4,7 @@
|
||||
$id: http://devicetree.org/schemas/iio/accel/bosch,bma180.yaml#
|
||||
$schema: http://devicetree.org/meta-schemas/core.yaml#
|
||||
|
||||
title: Bosch BMA023 / BMA150/ BMA180 / BMA25x / SMB380 triaxial accelerometers
|
||||
title: Bosch BMA023 / BMA150/ BMA180 / BMA250 / SMB380 triaxial accelerometers
|
||||
|
||||
maintainers:
|
||||
- Jonathan Cameron <jic23@kernel.org>
|
||||
@ -21,7 +21,6 @@ properties:
|
||||
- bosch,bma150
|
||||
- bosch,bma180
|
||||
- bosch,bma250
|
||||
- bosch,bma254
|
||||
- bosch,smb380
|
||||
|
||||
reg:
|
||||
|
@ -18,6 +18,8 @@ properties:
|
||||
enum:
|
||||
- bosch,bmc150_accel
|
||||
- bosch,bmi055_accel
|
||||
- bosch,bma253
|
||||
- bosch,bma254
|
||||
- bosch,bma255
|
||||
- bosch,bma250e
|
||||
- bosch,bma222
|
||||
@ -31,7 +33,12 @@ properties:
|
||||
vddio-supply: true
|
||||
|
||||
interrupts:
|
||||
maxItems: 1
|
||||
minItems: 1
|
||||
maxItems: 2
|
||||
description: |
|
||||
The first interrupt listed must be the one connected to the INT1 pin,
|
||||
the second (optional) interrupt listed must be the one connected to the
|
||||
INT2 pin (if available).
|
||||
|
||||
mount-matrix:
|
||||
description: an optional 3x3 mounting rotation matrix.
|
||||
|
@ -307,7 +307,7 @@ Determining the type of extension to create is a matter of scope.
|
||||
|
||||
* Device extensions are attributes that expose information/control
|
||||
non-specific to a particular Count or Signal. This is where you would
|
||||
put your global features or other miscellanous functionality.
|
||||
put your global features or other miscellaneous functionality.
|
||||
|
||||
For example, if your device has an overtemp sensor, you can report the
|
||||
chip overheated via a device extension called "error_overtemp":
|
||||
|
@ -299,7 +299,6 @@ M: William Breathitt Gray <vilhelm.gray@gmail.com>
|
||||
M: Syed Nayyar Waris <syednwaris@gmail.com>
|
||||
L: linux-iio@vger.kernel.org
|
||||
S: Maintained
|
||||
F: Documentation/ABI/testing/sysfs-bus-counter-104-quad-8
|
||||
F: drivers/counter/104-quad-8.c
|
||||
|
||||
ACCES PCI-IDIO-16 GPIO DRIVER
|
||||
@ -4684,7 +4683,7 @@ COUNTER SUBSYSTEM
|
||||
M: William Breathitt Gray <vilhelm.gray@gmail.com>
|
||||
L: linux-iio@vger.kernel.org
|
||||
S: Maintained
|
||||
F: Documentation/ABI/testing/sysfs-bus-counter*
|
||||
F: Documentation/ABI/testing/sysfs-bus-counter
|
||||
F: Documentation/driver-api/generic-counter.rst
|
||||
F: drivers/counter/
|
||||
F: include/linux/counter.h
|
||||
@ -7096,7 +7095,6 @@ FLEXTIMER FTM-QUADDEC DRIVER
|
||||
M: Patrick Havelange <patrick.havelange@essensium.com>
|
||||
L: linux-iio@vger.kernel.org
|
||||
S: Maintained
|
||||
F: Documentation/ABI/testing/sysfs-bus-counter-ftm-quaddec
|
||||
F: Documentation/devicetree/bindings/counter/ftm-quaddec.txt
|
||||
F: drivers/counter/ftm-quaddec.c
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
static unsigned int base[max_num_isa_dev(QUAD8_EXTENT)];
|
||||
static unsigned int num_quad8;
|
||||
module_param_array(base, uint, &num_quad8, 0);
|
||||
module_param_hw_array(base, uint, ioport, &num_quad8, 0);
|
||||
MODULE_PARM_DESC(base, "ACCES 104-QUAD-8 base addresses");
|
||||
|
||||
#define QUAD8_NUM_COUNTERS 8
|
||||
@ -193,7 +193,7 @@ enum quad8_count_function {
|
||||
QUAD8_COUNT_FUNCTION_QUADRATURE_X4
|
||||
};
|
||||
|
||||
static enum counter_count_function quad8_count_functions_list[] = {
|
||||
static const enum counter_count_function quad8_count_functions_list[] = {
|
||||
[QUAD8_COUNT_FUNCTION_PULSE_DIRECTION] = COUNTER_COUNT_FUNCTION_PULSE_DIRECTION,
|
||||
[QUAD8_COUNT_FUNCTION_QUADRATURE_X1] = COUNTER_COUNT_FUNCTION_QUADRATURE_X1_A,
|
||||
[QUAD8_COUNT_FUNCTION_QUADRATURE_X2] = COUNTER_COUNT_FUNCTION_QUADRATURE_X2_A,
|
||||
@ -305,12 +305,12 @@ enum quad8_synapse_action {
|
||||
QUAD8_SYNAPSE_ACTION_BOTH_EDGES
|
||||
};
|
||||
|
||||
static enum counter_synapse_action quad8_index_actions_list[] = {
|
||||
static const enum counter_synapse_action quad8_index_actions_list[] = {
|
||||
[QUAD8_SYNAPSE_ACTION_NONE] = COUNTER_SYNAPSE_ACTION_NONE,
|
||||
[QUAD8_SYNAPSE_ACTION_RISING_EDGE] = COUNTER_SYNAPSE_ACTION_RISING_EDGE
|
||||
};
|
||||
|
||||
static enum counter_synapse_action quad8_synapse_actions_list[] = {
|
||||
static const enum counter_synapse_action quad8_synapse_actions_list[] = {
|
||||
[QUAD8_SYNAPSE_ACTION_NONE] = COUNTER_SYNAPSE_ACTION_NONE,
|
||||
[QUAD8_SYNAPSE_ACTION_RISING_EDGE] = COUNTER_SYNAPSE_ACTION_RISING_EDGE,
|
||||
[QUAD8_SYNAPSE_ACTION_FALLING_EDGE] = COUNTER_SYNAPSE_ACTION_FALLING_EDGE,
|
||||
@ -632,8 +632,8 @@ static ssize_t quad8_count_preset_read(struct counter_device *counter,
|
||||
return sprintf(buf, "%u\n", priv->preset[count->id]);
|
||||
}
|
||||
|
||||
static void quad8_preset_register_set(struct quad8 *priv, int id,
|
||||
unsigned int preset)
|
||||
static void quad8_preset_register_set(struct quad8 *const priv, const int id,
|
||||
const unsigned int preset)
|
||||
{
|
||||
const unsigned int base_offset = priv->base + 2 * id;
|
||||
int i;
|
||||
@ -1082,7 +1082,6 @@ static int quad8_probe(struct device *dev, unsigned int id)
|
||||
/* Enable all counters */
|
||||
outb(QUAD8_CHAN_OP_ENABLE_COUNTERS, base[id] + QUAD8_REG_CHAN_OP);
|
||||
|
||||
/* Register Counter device */
|
||||
return devm_counter_register(dev, &priv->counter);
|
||||
}
|
||||
|
||||
|
@ -162,7 +162,7 @@ enum ftm_quaddec_synapse_action {
|
||||
FTM_QUADDEC_SYNAPSE_ACTION_BOTH_EDGES,
|
||||
};
|
||||
|
||||
static enum counter_synapse_action ftm_quaddec_synapse_actions[] = {
|
||||
static const enum counter_synapse_action ftm_quaddec_synapse_actions[] = {
|
||||
[FTM_QUADDEC_SYNAPSE_ACTION_BOTH_EDGES] =
|
||||
COUNTER_SYNAPSE_ACTION_BOTH_EDGES
|
||||
};
|
||||
|
@ -473,10 +473,9 @@ static void intel_qep_remove(struct pci_dev *pci)
|
||||
intel_qep_writel(qep, INTEL_QEPCON, 0);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
static int intel_qep_suspend(struct device *dev)
|
||||
static int __maybe_unused intel_qep_suspend(struct device *dev)
|
||||
{
|
||||
struct pci_dev *pdev = container_of(dev, struct pci_dev, dev);
|
||||
struct pci_dev *pdev = to_pci_dev(dev);
|
||||
struct intel_qep *qep = pci_get_drvdata(pdev);
|
||||
|
||||
qep->qepcon = intel_qep_readl(qep, INTEL_QEPCON);
|
||||
@ -486,9 +485,9 @@ static int intel_qep_suspend(struct device *dev)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int intel_qep_resume(struct device *dev)
|
||||
static int __maybe_unused intel_qep_resume(struct device *dev)
|
||||
{
|
||||
struct pci_dev *pdev = container_of(dev, struct pci_dev, dev);
|
||||
struct pci_dev *pdev = to_pci_dev(dev);
|
||||
struct intel_qep *qep = pci_get_drvdata(pdev);
|
||||
|
||||
/*
|
||||
@ -512,7 +511,6 @@ static int intel_qep_resume(struct device *dev)
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static UNIVERSAL_DEV_PM_OPS(intel_qep_pm_ops,
|
||||
intel_qep_suspend, intel_qep_resume, NULL);
|
||||
|
@ -77,7 +77,7 @@ static const struct counter_count_ext interrupt_cnt_ext[] = {
|
||||
},
|
||||
};
|
||||
|
||||
static enum counter_synapse_action interrupt_cnt_synapse_actionss[] = {
|
||||
static const enum counter_synapse_action interrupt_cnt_synapse_actions[] = {
|
||||
COUNTER_SYNAPSE_ACTION_RISING_EDGE,
|
||||
};
|
||||
|
||||
@ -112,7 +112,7 @@ static int interrupt_cnt_write(struct counter_device *counter,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static enum counter_count_function interrupt_cnt_functions[] = {
|
||||
static const enum counter_count_function interrupt_cnt_functions[] = {
|
||||
COUNTER_COUNT_FUNCTION_INCREASE,
|
||||
};
|
||||
|
||||
@ -194,8 +194,8 @@ static int interrupt_cnt_probe(struct platform_device *pdev)
|
||||
priv->counter.signals = &priv->signals;
|
||||
priv->counter.num_signals = 1;
|
||||
|
||||
priv->synapses.actions_list = interrupt_cnt_synapse_actionss;
|
||||
priv->synapses.num_actions = ARRAY_SIZE(interrupt_cnt_synapse_actionss);
|
||||
priv->synapses.actions_list = interrupt_cnt_synapse_actions;
|
||||
priv->synapses.num_actions = ARRAY_SIZE(interrupt_cnt_synapse_actions);
|
||||
priv->synapses.signal = &priv->signals;
|
||||
|
||||
priv->cnts.name = "Channel 0 Count";
|
||||
|
@ -37,7 +37,7 @@ enum mchp_tc_count_function {
|
||||
MCHP_TC_FUNCTION_QUADRATURE,
|
||||
};
|
||||
|
||||
static enum counter_count_function mchp_tc_count_functions[] = {
|
||||
static const enum counter_count_function mchp_tc_count_functions[] = {
|
||||
[MCHP_TC_FUNCTION_INCREASE] = COUNTER_COUNT_FUNCTION_INCREASE,
|
||||
[MCHP_TC_FUNCTION_QUADRATURE] = COUNTER_COUNT_FUNCTION_QUADRATURE_X4,
|
||||
};
|
||||
@ -49,7 +49,7 @@ enum mchp_tc_synapse_action {
|
||||
MCHP_TC_SYNAPSE_ACTION_BOTH_EDGE
|
||||
};
|
||||
|
||||
static enum counter_synapse_action mchp_tc_synapse_actions[] = {
|
||||
static const enum counter_synapse_action mchp_tc_synapse_actions[] = {
|
||||
[MCHP_TC_SYNAPSE_ACTION_NONE] = COUNTER_SYNAPSE_ACTION_NONE,
|
||||
[MCHP_TC_SYNAPSE_ACTION_RISING_EDGE] = COUNTER_SYNAPSE_ACTION_RISING_EDGE,
|
||||
[MCHP_TC_SYNAPSE_ACTION_FALLING_EDGE] = COUNTER_SYNAPSE_ACTION_FALLING_EDGE,
|
||||
|
@ -134,7 +134,7 @@ enum stm32_lptim_cnt_function {
|
||||
STM32_LPTIM_ENCODER_BOTH_EDGE,
|
||||
};
|
||||
|
||||
static enum counter_count_function stm32_lptim_cnt_functions[] = {
|
||||
static const enum counter_count_function stm32_lptim_cnt_functions[] = {
|
||||
[STM32_LPTIM_COUNTER_INCREASE] = COUNTER_COUNT_FUNCTION_INCREASE,
|
||||
[STM32_LPTIM_ENCODER_BOTH_EDGE] = COUNTER_COUNT_FUNCTION_QUADRATURE_X4,
|
||||
};
|
||||
@ -146,7 +146,7 @@ enum stm32_lptim_synapse_action {
|
||||
STM32_LPTIM_SYNAPSE_ACTION_NONE,
|
||||
};
|
||||
|
||||
static enum counter_synapse_action stm32_lptim_cnt_synapse_actions[] = {
|
||||
static const enum counter_synapse_action stm32_lptim_cnt_synapse_actions[] = {
|
||||
/* Index must match with stm32_lptim_cnt_polarity[] (priv->polarity) */
|
||||
[STM32_LPTIM_SYNAPSE_ACTION_RISING_EDGE] = COUNTER_SYNAPSE_ACTION_RISING_EDGE,
|
||||
[STM32_LPTIM_SYNAPSE_ACTION_FALLING_EDGE] = COUNTER_SYNAPSE_ACTION_FALLING_EDGE,
|
||||
|
@ -50,7 +50,7 @@ enum stm32_count_function {
|
||||
STM32_COUNT_ENCODER_MODE_3,
|
||||
};
|
||||
|
||||
static enum counter_count_function stm32_count_functions[] = {
|
||||
static const enum counter_count_function stm32_count_functions[] = {
|
||||
[STM32_COUNT_SLAVE_MODE_DISABLED] = COUNTER_COUNT_FUNCTION_INCREASE,
|
||||
[STM32_COUNT_ENCODER_MODE_1] = COUNTER_COUNT_FUNCTION_QUADRATURE_X2_A,
|
||||
[STM32_COUNT_ENCODER_MODE_2] = COUNTER_COUNT_FUNCTION_QUADRATURE_X2_B,
|
||||
@ -267,7 +267,7 @@ enum stm32_synapse_action {
|
||||
STM32_SYNAPSE_ACTION_BOTH_EDGES
|
||||
};
|
||||
|
||||
static enum counter_synapse_action stm32_synapse_actions[] = {
|
||||
static const enum counter_synapse_action stm32_synapse_actions[] = {
|
||||
[STM32_SYNAPSE_ACTION_NONE] = COUNTER_SYNAPSE_ACTION_NONE,
|
||||
[STM32_SYNAPSE_ACTION_BOTH_EDGES] = COUNTER_SYNAPSE_ACTION_BOTH_EDGES
|
||||
};
|
||||
|
@ -89,13 +89,13 @@ config ADXL372_I2C
|
||||
module will be called adxl372_i2c.
|
||||
|
||||
config BMA180
|
||||
tristate "Bosch BMA023/BMA1x0/BMA25x 3-Axis Accelerometer Driver"
|
||||
tristate "Bosch BMA023/BMA1x0/BMA250 3-Axis Accelerometer Driver"
|
||||
depends on I2C && INPUT_BMA150=n
|
||||
select IIO_BUFFER
|
||||
select IIO_TRIGGERED_BUFFER
|
||||
help
|
||||
Say Y here if you want to build a driver for the Bosch BMA023, BMA150
|
||||
BMA180, SMB380, or BMA25x triaxial acceleration sensor.
|
||||
BMA180, BMA250 or SMB380 triaxial acceleration sensor.
|
||||
|
||||
To compile this driver as a module, choose M here: the
|
||||
module will be called bma180.
|
||||
@ -143,9 +143,12 @@ config BMC150_ACCEL
|
||||
select BMC150_ACCEL_SPI if SPI
|
||||
help
|
||||
Say yes here to build support for the following Bosch accelerometers:
|
||||
BMC150, BMI055, BMA250E, BMA222E, BMA255, BMA280.
|
||||
BMA222, BMA222E, BMA250E, BMA253, BMA254, BMA255, BMA280, BMC150, BMI055.
|
||||
|
||||
Note that some of these are combo modules:
|
||||
- BMC150: accelerometer and magnetometer
|
||||
- BMI055: accelerometer and gyroscope
|
||||
|
||||
This is a combo module with both accelerometer and magnetometer.
|
||||
This driver is only implementing accelerometer part, which has
|
||||
its own address and register map.
|
||||
|
||||
|
@ -10,7 +10,6 @@
|
||||
* BMA023/BMA150/SMB380: 7-bit I2C slave address 0x38
|
||||
* BMA180: 7-bit I2C slave address 0x40 or 0x41
|
||||
* BMA250: 7-bit I2C slave address 0x18 or 0x19
|
||||
* BMA254: 7-bit I2C slave address 0x18 or 0x19
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
@ -38,7 +37,6 @@ enum chip_ids {
|
||||
BMA150,
|
||||
BMA180,
|
||||
BMA250,
|
||||
BMA254,
|
||||
};
|
||||
|
||||
struct bma180_data;
|
||||
@ -55,11 +53,10 @@ struct bma180_part_info {
|
||||
|
||||
u8 int_reset_reg, int_reset_mask;
|
||||
u8 sleep_reg, sleep_mask;
|
||||
u8 bw_reg, bw_mask;
|
||||
u8 bw_reg, bw_mask, bw_offset;
|
||||
u8 scale_reg, scale_mask;
|
||||
u8 power_reg, power_mask, lowpower_val;
|
||||
u8 int_enable_reg, int_enable_mask;
|
||||
u8 int_map_reg, int_enable_dataready_int1_mask;
|
||||
u8 softreset_reg, softreset_val;
|
||||
|
||||
int (*chip_config)(struct bma180_data *data);
|
||||
@ -112,7 +109,6 @@ struct bma180_part_info {
|
||||
#define BMA023_ID_REG_VAL 0x02
|
||||
#define BMA180_ID_REG_VAL 0x03
|
||||
#define BMA250_ID_REG_VAL 0x03
|
||||
#define BMA254_ID_REG_VAL 0xfa /* 250 decimal */
|
||||
|
||||
/* Chip power modes */
|
||||
#define BMA180_LOW_POWER 0x03
|
||||
@ -127,29 +123,13 @@ struct bma180_part_info {
|
||||
|
||||
#define BMA250_RANGE_MASK GENMASK(3, 0) /* Range of accel values */
|
||||
#define BMA250_BW_MASK GENMASK(4, 0) /* Accel bandwidth */
|
||||
#define BMA250_BW_OFFSET 8
|
||||
#define BMA250_SUSPEND_MASK BIT(7) /* chip will sleep */
|
||||
#define BMA250_LOWPOWER_MASK BIT(6)
|
||||
#define BMA250_DATA_INTEN_MASK BIT(4)
|
||||
#define BMA250_INT1_DATA_MASK BIT(0)
|
||||
#define BMA250_INT_RESET_MASK BIT(7) /* Reset pending interrupts */
|
||||
|
||||
#define BMA254_RANGE_REG 0x0f
|
||||
#define BMA254_BW_REG 0x10
|
||||
#define BMA254_POWER_REG 0x11
|
||||
#define BMA254_RESET_REG 0x14
|
||||
#define BMA254_INT_ENABLE_REG 0x17
|
||||
#define BMA254_INT_MAP_REG 0x1a
|
||||
#define BMA254_INT_RESET_REG 0x21
|
||||
|
||||
#define BMA254_RANGE_MASK GENMASK(3, 0) /* Range of accel values */
|
||||
#define BMA254_BW_MASK GENMASK(4, 0) /* Accel bandwidth */
|
||||
#define BMA254_SUSPEND_MASK BIT(7) /* chip will sleep */
|
||||
#define BMA254_LOWPOWER_MASK BIT(6)
|
||||
#define BMA254_DATA_INTEN_MASK BIT(4)
|
||||
#define BMA254_INT2_DATA_MASK BIT(7)
|
||||
#define BMA254_INT1_DATA_MASK BIT(0)
|
||||
#define BMA254_INT_RESET_MASK BIT(7) /* Reset pending interrupts */
|
||||
|
||||
struct bma180_data {
|
||||
struct regulator *vdd_supply;
|
||||
struct regulator *vddio_supply;
|
||||
@ -182,8 +162,8 @@ static int bma023_scale_table[] = { 2452, 4903, 9709, };
|
||||
static int bma180_bw_table[] = { 10, 20, 40, 75, 150, 300 }; /* Hz */
|
||||
static int bma180_scale_table[] = { 1275, 1863, 2452, 3727, 4903, 9709, 19417 };
|
||||
|
||||
static int bma25x_bw_table[] = { 8, 16, 31, 63, 125, 250, 500, 1000 }; /* Hz */
|
||||
static int bma25x_scale_table[] = { 0, 0, 0, 38344, 0, 76590, 0, 0, 153180, 0,
|
||||
static int bma250_bw_table[] = { 8, 16, 31, 63, 125, 250, 500, 1000 }; /* Hz */
|
||||
static int bma250_scale_table[] = { 0, 0, 0, 38344, 0, 76590, 0, 0, 153180, 0,
|
||||
0, 0, 306458 };
|
||||
|
||||
static int bma180_get_data_reg(struct bma180_data *data, enum bma180_chan chan)
|
||||
@ -287,7 +267,8 @@ static int bma180_set_bw(struct bma180_data *data, int val)
|
||||
for (i = 0; i < data->part_info->num_bw; ++i) {
|
||||
if (data->part_info->bw_table[i] == val) {
|
||||
ret = bma180_set_bits(data, data->part_info->bw_reg,
|
||||
data->part_info->bw_mask, i);
|
||||
data->part_info->bw_mask,
|
||||
i + data->part_info->bw_offset);
|
||||
if (ret) {
|
||||
dev_err(&data->client->dev,
|
||||
"failed to set bandwidth\n");
|
||||
@ -429,7 +410,7 @@ err:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int bma25x_chip_config(struct bma180_data *data)
|
||||
static int bma250_chip_config(struct bma180_data *data)
|
||||
{
|
||||
int ret = bma180_chip_init(data);
|
||||
|
||||
@ -448,8 +429,7 @@ static int bma25x_chip_config(struct bma180_data *data)
|
||||
* This enables dataready interrupt on the INT1 pin
|
||||
* FIXME: support using the INT2 pin
|
||||
*/
|
||||
ret = bma180_set_bits(data, data->part_info->int_map_reg,
|
||||
data->part_info->int_enable_dataready_int1_mask, 1);
|
||||
ret = bma180_set_bits(data, BMA250_INT_MAP_REG, BMA250_INT1_DATA_MASK, 1);
|
||||
if (ret)
|
||||
goto err;
|
||||
|
||||
@ -486,7 +466,7 @@ err:
|
||||
dev_err(&data->client->dev, "failed to disable the chip\n");
|
||||
}
|
||||
|
||||
static void bma25x_chip_disable(struct bma180_data *data)
|
||||
static void bma250_chip_disable(struct bma180_data *data)
|
||||
{
|
||||
if (bma180_set_new_data_intr_state(data, false))
|
||||
goto err;
|
||||
@ -772,14 +752,6 @@ static const struct iio_chan_spec bma250_channels[] = {
|
||||
IIO_CHAN_SOFT_TIMESTAMP(4),
|
||||
};
|
||||
|
||||
static const struct iio_chan_spec bma254_channels[] = {
|
||||
BMA180_ACC_CHANNEL(X, 12),
|
||||
BMA180_ACC_CHANNEL(Y, 12),
|
||||
BMA180_ACC_CHANNEL(Z, 12),
|
||||
BMA180_TEMP_CHANNEL,
|
||||
IIO_CHAN_SOFT_TIMESTAMP(4),
|
||||
};
|
||||
|
||||
static const struct bma180_part_info bma180_part_info[] = {
|
||||
[BMA023] = {
|
||||
.chip_id = BMA023_ID_REG_VAL,
|
||||
@ -869,10 +841,10 @@ static const struct bma180_part_info bma180_part_info[] = {
|
||||
.chip_id = BMA250_ID_REG_VAL,
|
||||
.channels = bma250_channels,
|
||||
.num_channels = ARRAY_SIZE(bma250_channels),
|
||||
.scale_table = bma25x_scale_table,
|
||||
.num_scales = ARRAY_SIZE(bma25x_scale_table),
|
||||
.bw_table = bma25x_bw_table,
|
||||
.num_bw = ARRAY_SIZE(bma25x_bw_table),
|
||||
.scale_table = bma250_scale_table,
|
||||
.num_scales = ARRAY_SIZE(bma250_scale_table),
|
||||
.bw_table = bma250_bw_table,
|
||||
.num_bw = ARRAY_SIZE(bma250_bw_table),
|
||||
.temp_offset = 48, /* 0 LSB @ 24 degree C */
|
||||
.int_reset_reg = BMA250_INT_RESET_REG,
|
||||
.int_reset_mask = BMA250_INT_RESET_MASK,
|
||||
@ -880,6 +852,7 @@ static const struct bma180_part_info bma180_part_info[] = {
|
||||
.sleep_mask = BMA250_SUSPEND_MASK,
|
||||
.bw_reg = BMA250_BW_REG,
|
||||
.bw_mask = BMA250_BW_MASK,
|
||||
.bw_offset = BMA250_BW_OFFSET,
|
||||
.scale_reg = BMA250_RANGE_REG,
|
||||
.scale_mask = BMA250_RANGE_MASK,
|
||||
.power_reg = BMA250_POWER_REG,
|
||||
@ -887,41 +860,10 @@ static const struct bma180_part_info bma180_part_info[] = {
|
||||
.lowpower_val = 1,
|
||||
.int_enable_reg = BMA250_INT_ENABLE_REG,
|
||||
.int_enable_mask = BMA250_DATA_INTEN_MASK,
|
||||
.int_map_reg = BMA250_INT_MAP_REG,
|
||||
.int_enable_dataready_int1_mask = BMA250_INT1_DATA_MASK,
|
||||
.softreset_reg = BMA250_RESET_REG,
|
||||
.softreset_val = BMA180_RESET_VAL,
|
||||
.chip_config = bma25x_chip_config,
|
||||
.chip_disable = bma25x_chip_disable,
|
||||
},
|
||||
[BMA254] = {
|
||||
.chip_id = BMA254_ID_REG_VAL,
|
||||
.channels = bma254_channels,
|
||||
.num_channels = ARRAY_SIZE(bma254_channels),
|
||||
.scale_table = bma25x_scale_table,
|
||||
.num_scales = ARRAY_SIZE(bma25x_scale_table),
|
||||
.bw_table = bma25x_bw_table,
|
||||
.num_bw = ARRAY_SIZE(bma25x_bw_table),
|
||||
.temp_offset = 46, /* 0 LSB @ 23 degree C */
|
||||
.int_reset_reg = BMA254_INT_RESET_REG,
|
||||
.int_reset_mask = BMA254_INT_RESET_MASK,
|
||||
.sleep_reg = BMA254_POWER_REG,
|
||||
.sleep_mask = BMA254_SUSPEND_MASK,
|
||||
.bw_reg = BMA254_BW_REG,
|
||||
.bw_mask = BMA254_BW_MASK,
|
||||
.scale_reg = BMA254_RANGE_REG,
|
||||
.scale_mask = BMA254_RANGE_MASK,
|
||||
.power_reg = BMA254_POWER_REG,
|
||||
.power_mask = BMA254_LOWPOWER_MASK,
|
||||
.lowpower_val = 1,
|
||||
.int_enable_reg = BMA254_INT_ENABLE_REG,
|
||||
.int_enable_mask = BMA254_DATA_INTEN_MASK,
|
||||
.int_map_reg = BMA254_INT_MAP_REG,
|
||||
.int_enable_dataready_int1_mask = BMA254_INT1_DATA_MASK,
|
||||
.softreset_reg = BMA254_RESET_REG,
|
||||
.softreset_val = BMA180_RESET_VAL,
|
||||
.chip_config = bma25x_chip_config,
|
||||
.chip_disable = bma25x_chip_disable,
|
||||
.chip_config = bma250_chip_config,
|
||||
.chip_disable = bma250_chip_disable,
|
||||
},
|
||||
};
|
||||
|
||||
@ -1161,7 +1103,6 @@ static const struct i2c_device_id bma180_ids[] = {
|
||||
{ "bma150", BMA150 },
|
||||
{ "bma180", BMA180 },
|
||||
{ "bma250", BMA250 },
|
||||
{ "bma254", BMA254 },
|
||||
{ "smb380", BMA150 },
|
||||
{ }
|
||||
};
|
||||
@ -1185,10 +1126,6 @@ static const struct of_device_id bma180_of_match[] = {
|
||||
.compatible = "bosch,bma250",
|
||||
.data = (void *)BMA250
|
||||
},
|
||||
{
|
||||
.compatible = "bosch,bma254",
|
||||
.data = (void *)BMA254
|
||||
},
|
||||
{
|
||||
.compatible = "bosch,smb380",
|
||||
.data = (void *)BMA150
|
||||
@ -1212,5 +1149,5 @@ module_i2c_driver(bma180_driver);
|
||||
|
||||
MODULE_AUTHOR("Kravchenko Oleksandr <x0199363@ti.com>");
|
||||
MODULE_AUTHOR("Texas Instruments, Inc.");
|
||||
MODULE_DESCRIPTION("Bosch BMA023/BMA1x0/BMA25x triaxial acceleration sensor");
|
||||
MODULE_DESCRIPTION("Bosch BMA023/BMA1x0/BMA250 triaxial acceleration sensor");
|
||||
MODULE_LICENSE("GPL");
|
||||
|
@ -1,14 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
/*
|
||||
* 3-axis accelerometer driver supporting following Bosch-Sensortec chips:
|
||||
* - BMC150
|
||||
* - BMI055
|
||||
* - BMA255
|
||||
* - BMA250E
|
||||
* - BMA222
|
||||
* - BMA222E
|
||||
* - BMA280
|
||||
*
|
||||
* 3-axis accelerometer driver supporting many Bosch-Sensortec chips
|
||||
* Copyright (c) 2014, Intel Corporation.
|
||||
*/
|
||||
|
||||
@ -157,59 +149,6 @@ struct bmc150_accel_chip_info {
|
||||
const struct bmc150_scale_info scale_table[4];
|
||||
};
|
||||
|
||||
struct bmc150_accel_interrupt {
|
||||
const struct bmc150_accel_interrupt_info *info;
|
||||
atomic_t users;
|
||||
};
|
||||
|
||||
struct bmc150_accel_trigger {
|
||||
struct bmc150_accel_data *data;
|
||||
struct iio_trigger *indio_trig;
|
||||
int (*setup)(struct bmc150_accel_trigger *t, bool state);
|
||||
int intr;
|
||||
bool enabled;
|
||||
};
|
||||
|
||||
enum bmc150_accel_interrupt_id {
|
||||
BMC150_ACCEL_INT_DATA_READY,
|
||||
BMC150_ACCEL_INT_ANY_MOTION,
|
||||
BMC150_ACCEL_INT_WATERMARK,
|
||||
BMC150_ACCEL_INTERRUPTS,
|
||||
};
|
||||
|
||||
enum bmc150_accel_trigger_id {
|
||||
BMC150_ACCEL_TRIGGER_DATA_READY,
|
||||
BMC150_ACCEL_TRIGGER_ANY_MOTION,
|
||||
BMC150_ACCEL_TRIGGERS,
|
||||
};
|
||||
|
||||
struct bmc150_accel_data {
|
||||
struct regmap *regmap;
|
||||
struct regulator_bulk_data regulators[2];
|
||||
struct bmc150_accel_interrupt interrupts[BMC150_ACCEL_INTERRUPTS];
|
||||
struct bmc150_accel_trigger triggers[BMC150_ACCEL_TRIGGERS];
|
||||
struct mutex mutex;
|
||||
u8 fifo_mode, watermark;
|
||||
s16 buffer[8];
|
||||
/*
|
||||
* Ensure there is sufficient space and correct alignment for
|
||||
* the timestamp if enabled
|
||||
*/
|
||||
struct {
|
||||
__le16 channels[3];
|
||||
s64 ts __aligned(8);
|
||||
} scan;
|
||||
u8 bw_bits;
|
||||
u32 slope_dur;
|
||||
u32 slope_thres;
|
||||
u32 range;
|
||||
int ev_enable_state;
|
||||
int64_t timestamp, old_timestamp; /* Only used in hw fifo mode. */
|
||||
const struct bmc150_accel_chip_info *chip_info;
|
||||
struct i2c_client *second_device;
|
||||
struct iio_mount_matrix orientation;
|
||||
};
|
||||
|
||||
static const struct {
|
||||
int val;
|
||||
int val2;
|
||||
@ -436,8 +375,8 @@ static int bmc150_accel_set_power_state(struct bmc150_accel_data *data, bool on)
|
||||
* Onda V80 plus
|
||||
* Predia Basic Tablet
|
||||
*/
|
||||
static bool bmc150_apply_acpi_orientation(struct device *dev,
|
||||
struct iio_mount_matrix *orientation)
|
||||
static bool bmc150_apply_bosc0200_acpi_orientation(struct device *dev,
|
||||
struct iio_mount_matrix *orientation)
|
||||
{
|
||||
struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
|
||||
struct iio_dev *indio_dev = dev_get_drvdata(dev);
|
||||
@ -447,9 +386,6 @@ static bool bmc150_apply_acpi_orientation(struct device *dev,
|
||||
acpi_status status;
|
||||
int i, j, val[3];
|
||||
|
||||
if (!adev || !acpi_dev_hid_uid_match(adev, "BOSC0200", NULL))
|
||||
return false;
|
||||
|
||||
if (strcmp(dev_name(dev), "i2c-BOSC0200:base") == 0) {
|
||||
alt_name = "ROMK";
|
||||
label = "accel-base";
|
||||
@ -505,6 +441,33 @@ unknown_format:
|
||||
kfree(buffer.pointer);
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool bmc150_apply_dual250e_acpi_orientation(struct device *dev,
|
||||
struct iio_mount_matrix *orientation)
|
||||
{
|
||||
struct iio_dev *indio_dev = dev_get_drvdata(dev);
|
||||
|
||||
if (strcmp(dev_name(dev), "i2c-DUAL250E:base") == 0)
|
||||
indio_dev->label = "accel-base";
|
||||
else
|
||||
indio_dev->label = "accel-display";
|
||||
|
||||
return false; /* DUAL250E fwnodes have no mount matrix info */
|
||||
}
|
||||
|
||||
static bool bmc150_apply_acpi_orientation(struct device *dev,
|
||||
struct iio_mount_matrix *orientation)
|
||||
{
|
||||
struct acpi_device *adev = ACPI_COMPANION(dev);
|
||||
|
||||
if (adev && acpi_dev_hid_uid_match(adev, "BOSC0200", NULL))
|
||||
return bmc150_apply_bosc0200_acpi_orientation(dev, orientation);
|
||||
|
||||
if (adev && acpi_dev_hid_uid_match(adev, "DUAL250E", NULL))
|
||||
return bmc150_apply_dual250e_acpi_orientation(dev, orientation);
|
||||
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
static bool bmc150_apply_acpi_orientation(struct device *dev,
|
||||
struct iio_mount_matrix *orientation)
|
||||
@ -1125,80 +1088,63 @@ static const struct iio_chan_spec bmc150_accel_channels[] =
|
||||
static const struct iio_chan_spec bma280_accel_channels[] =
|
||||
BMC150_ACCEL_CHANNELS(14);
|
||||
|
||||
/*
|
||||
* The range for the Bosch sensors is typically +-2g/4g/8g/16g, distributed
|
||||
* over the amount of bits (see above). The scale table can be calculated using
|
||||
* (range / 2^bits) * g = (range / 2^bits) * 9.80665 m/s^2
|
||||
* e.g. for +-2g and 12 bits: (4 / 2^12) * 9.80665 m/s^2 = 0.0095768... m/s^2
|
||||
* Multiply 10^6 and round to get the values listed below.
|
||||
*/
|
||||
static const struct bmc150_accel_chip_info bmc150_accel_chip_info_tbl[] = {
|
||||
[bmc150] = {
|
||||
.name = "BMC150A",
|
||||
.chip_id = 0xFA,
|
||||
.channels = bmc150_accel_channels,
|
||||
.num_channels = ARRAY_SIZE(bmc150_accel_channels),
|
||||
.scale_table = { {9610, BMC150_ACCEL_DEF_RANGE_2G},
|
||||
{19122, BMC150_ACCEL_DEF_RANGE_4G},
|
||||
{38344, BMC150_ACCEL_DEF_RANGE_8G},
|
||||
{76590, BMC150_ACCEL_DEF_RANGE_16G} },
|
||||
},
|
||||
[bmi055] = {
|
||||
.name = "BMI055A",
|
||||
.chip_id = 0xFA,
|
||||
.channels = bmc150_accel_channels,
|
||||
.num_channels = ARRAY_SIZE(bmc150_accel_channels),
|
||||
.scale_table = { {9610, BMC150_ACCEL_DEF_RANGE_2G},
|
||||
{19122, BMC150_ACCEL_DEF_RANGE_4G},
|
||||
{38344, BMC150_ACCEL_DEF_RANGE_8G},
|
||||
{76590, BMC150_ACCEL_DEF_RANGE_16G} },
|
||||
},
|
||||
[bma255] = {
|
||||
.name = "BMA0255",
|
||||
.chip_id = 0xFA,
|
||||
.channels = bmc150_accel_channels,
|
||||
.num_channels = ARRAY_SIZE(bmc150_accel_channels),
|
||||
.scale_table = { {9610, BMC150_ACCEL_DEF_RANGE_2G},
|
||||
{19122, BMC150_ACCEL_DEF_RANGE_4G},
|
||||
{38344, BMC150_ACCEL_DEF_RANGE_8G},
|
||||
{76590, BMC150_ACCEL_DEF_RANGE_16G} },
|
||||
},
|
||||
[bma250e] = {
|
||||
.name = "BMA250E",
|
||||
.chip_id = 0xF9,
|
||||
.channels = bma250e_accel_channels,
|
||||
.num_channels = ARRAY_SIZE(bma250e_accel_channels),
|
||||
.scale_table = { {38344, BMC150_ACCEL_DEF_RANGE_2G},
|
||||
{76590, BMC150_ACCEL_DEF_RANGE_4G},
|
||||
{153277, BMC150_ACCEL_DEF_RANGE_8G},
|
||||
{306457, BMC150_ACCEL_DEF_RANGE_16G} },
|
||||
},
|
||||
[bma222] = {
|
||||
{
|
||||
.name = "BMA222",
|
||||
.chip_id = 0x03,
|
||||
.channels = bma222e_accel_channels,
|
||||
.num_channels = ARRAY_SIZE(bma222e_accel_channels),
|
||||
/*
|
||||
* The datasheet page 17 says:
|
||||
* 15.6, 31.3, 62.5 and 125 mg per LSB.
|
||||
*/
|
||||
.scale_table = { {156000, BMC150_ACCEL_DEF_RANGE_2G},
|
||||
{313000, BMC150_ACCEL_DEF_RANGE_4G},
|
||||
{625000, BMC150_ACCEL_DEF_RANGE_8G},
|
||||
{1250000, BMC150_ACCEL_DEF_RANGE_16G} },
|
||||
.scale_table = { {153229, BMC150_ACCEL_DEF_RANGE_2G},
|
||||
{306458, BMC150_ACCEL_DEF_RANGE_4G},
|
||||
{612916, BMC150_ACCEL_DEF_RANGE_8G},
|
||||
{1225831, BMC150_ACCEL_DEF_RANGE_16G} },
|
||||
},
|
||||
[bma222e] = {
|
||||
{
|
||||
.name = "BMA222E",
|
||||
.chip_id = 0xF8,
|
||||
.channels = bma222e_accel_channels,
|
||||
.num_channels = ARRAY_SIZE(bma222e_accel_channels),
|
||||
.scale_table = { {153277, BMC150_ACCEL_DEF_RANGE_2G},
|
||||
{306457, BMC150_ACCEL_DEF_RANGE_4G},
|
||||
{612915, BMC150_ACCEL_DEF_RANGE_8G},
|
||||
.scale_table = { {153229, BMC150_ACCEL_DEF_RANGE_2G},
|
||||
{306458, BMC150_ACCEL_DEF_RANGE_4G},
|
||||
{612916, BMC150_ACCEL_DEF_RANGE_8G},
|
||||
{1225831, BMC150_ACCEL_DEF_RANGE_16G} },
|
||||
},
|
||||
[bma280] = {
|
||||
.name = "BMA0280",
|
||||
{
|
||||
.name = "BMA250E",
|
||||
.chip_id = 0xF9,
|
||||
.channels = bma250e_accel_channels,
|
||||
.num_channels = ARRAY_SIZE(bma250e_accel_channels),
|
||||
.scale_table = { {38307, BMC150_ACCEL_DEF_RANGE_2G},
|
||||
{76614, BMC150_ACCEL_DEF_RANGE_4G},
|
||||
{153229, BMC150_ACCEL_DEF_RANGE_8G},
|
||||
{306458, BMC150_ACCEL_DEF_RANGE_16G} },
|
||||
},
|
||||
{
|
||||
.name = "BMA253/BMA254/BMA255/BMC150/BMI055",
|
||||
.chip_id = 0xFA,
|
||||
.channels = bmc150_accel_channels,
|
||||
.num_channels = ARRAY_SIZE(bmc150_accel_channels),
|
||||
.scale_table = { {9577, BMC150_ACCEL_DEF_RANGE_2G},
|
||||
{19154, BMC150_ACCEL_DEF_RANGE_4G},
|
||||
{38307, BMC150_ACCEL_DEF_RANGE_8G},
|
||||
{76614, BMC150_ACCEL_DEF_RANGE_16G} },
|
||||
},
|
||||
{
|
||||
.name = "BMA280",
|
||||
.chip_id = 0xFB,
|
||||
.channels = bma280_accel_channels,
|
||||
.num_channels = ARRAY_SIZE(bma280_accel_channels),
|
||||
.scale_table = { {2392, BMC150_ACCEL_DEF_RANGE_2G},
|
||||
{4785, BMC150_ACCEL_DEF_RANGE_4G},
|
||||
{9581, BMC150_ACCEL_DEF_RANGE_8G},
|
||||
{19152, BMC150_ACCEL_DEF_RANGE_16G} },
|
||||
.scale_table = { {2394, BMC150_ACCEL_DEF_RANGE_2G},
|
||||
{4788, BMC150_ACCEL_DEF_RANGE_4G},
|
||||
{9577, BMC150_ACCEL_DEF_RANGE_8G},
|
||||
{19154, BMC150_ACCEL_DEF_RANGE_16G} },
|
||||
},
|
||||
};
|
||||
|
||||
@ -1803,26 +1749,6 @@ err_disable_regulators:
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(bmc150_accel_core_probe);
|
||||
|
||||
struct i2c_client *bmc150_get_second_device(struct i2c_client *client)
|
||||
{
|
||||
struct bmc150_accel_data *data = i2c_get_clientdata(client);
|
||||
|
||||
if (!data)
|
||||
return NULL;
|
||||
|
||||
return data->second_device;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(bmc150_get_second_device);
|
||||
|
||||
void bmc150_set_second_device(struct i2c_client *client)
|
||||
{
|
||||
struct bmc150_accel_data *data = i2c_get_clientdata(client);
|
||||
|
||||
if (data)
|
||||
data->second_device = client;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(bmc150_set_second_device);
|
||||
|
||||
int bmc150_accel_core_remove(struct device *dev)
|
||||
{
|
||||
struct iio_dev *indio_dev = dev_get_drvdata(dev);
|
||||
@ -1871,6 +1797,9 @@ static int bmc150_accel_resume(struct device *dev)
|
||||
bmc150_accel_fifo_set_mode(data);
|
||||
mutex_unlock(&data->mutex);
|
||||
|
||||
if (data->resume_callback)
|
||||
data->resume_callback(dev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
@ -1,14 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
/*
|
||||
* 3-axis accelerometer driver supporting following I2C Bosch-Sensortec chips:
|
||||
* - BMC150
|
||||
* - BMI055
|
||||
* - BMA255
|
||||
* - BMA250E
|
||||
* - BMA222
|
||||
* - BMA222E
|
||||
* - BMA280
|
||||
*
|
||||
* 3-axis accelerometer driver supporting many I2C Bosch-Sensortec chips
|
||||
* Copyright (c) 2014, Intel Corporation.
|
||||
*/
|
||||
|
||||
@ -21,6 +13,164 @@
|
||||
|
||||
#include "bmc150-accel.h"
|
||||
|
||||
#ifdef CONFIG_ACPI
|
||||
static const struct acpi_device_id bmc150_acpi_dual_accel_ids[] = {
|
||||
{"BOSC0200"},
|
||||
{"DUAL250E"},
|
||||
{ }
|
||||
};
|
||||
|
||||
/*
|
||||
* The DUAL250E ACPI device for 360° hinges type 2-in-1s with 1 accelerometer
|
||||
* in the display and 1 in the hinge has an ACPI-method (DSM) to tell the
|
||||
* ACPI code about the angle between the 2 halves. This will make the ACPI
|
||||
* code enable/disable the keyboard and touchpad. We need to call this to avoid
|
||||
* the keyboard being disabled when the 2-in-1 is turned-on or resumed while
|
||||
* fully folded into tablet mode (which gets detected with a HALL-sensor).
|
||||
* If we don't call this then the keyboard won't work even when the 2-in-1 is
|
||||
* changed to be used in laptop mode after the power-on / resume.
|
||||
*
|
||||
* This DSM takes 2 angles, selected by setting aux0 to 0 or 1, these presumably
|
||||
* define the angle between the gravity vector measured by the accelerometer in
|
||||
* the display (aux0=0) resp. the base (aux0=1) and some reference vector.
|
||||
* The 2 angles get subtracted from each other so the reference vector does
|
||||
* not matter and we can simply leave the second angle at 0.
|
||||
*/
|
||||
|
||||
#define BMC150_DSM_GUID "7681541e-8827-4239-8d9d-36be7fe12542"
|
||||
#define DUAL250E_SET_ANGLE_FN_INDEX 3
|
||||
|
||||
struct dual250e_set_angle_args {
|
||||
u32 aux0;
|
||||
u32 ang0;
|
||||
u32 rawx;
|
||||
u32 rawy;
|
||||
u32 rawz;
|
||||
} __packed;
|
||||
|
||||
static bool bmc150_acpi_set_angle_dsm(struct i2c_client *client, u32 aux0, u32 ang0)
|
||||
{
|
||||
struct acpi_device *adev = ACPI_COMPANION(&client->dev);
|
||||
struct dual250e_set_angle_args args = {
|
||||
.aux0 = aux0,
|
||||
.ang0 = ang0,
|
||||
};
|
||||
union acpi_object args_obj, *obj;
|
||||
guid_t guid;
|
||||
|
||||
if (!acpi_dev_hid_uid_match(adev, "DUAL250E", NULL))
|
||||
return false;
|
||||
|
||||
guid_parse(BMC150_DSM_GUID, &guid);
|
||||
|
||||
if (!acpi_check_dsm(adev->handle, &guid, 0, BIT(DUAL250E_SET_ANGLE_FN_INDEX)))
|
||||
return false;
|
||||
|
||||
/*
|
||||
* Note this triggers the following warning:
|
||||
* "ACPI Warning: \_SB.PCI0.I2C2.ACC1._DSM: Argument #4 type mismatch -
|
||||
* Found [Buffer], ACPI requires [Package]"
|
||||
* This is unavoidable since the _DSM implementation expects a "naked"
|
||||
* buffer, so wrapping it in a package will _not_ work.
|
||||
*/
|
||||
args_obj.type = ACPI_TYPE_BUFFER;
|
||||
args_obj.buffer.length = sizeof(args);
|
||||
args_obj.buffer.pointer = (u8 *)&args;
|
||||
|
||||
obj = acpi_evaluate_dsm(adev->handle, &guid, 0, DUAL250E_SET_ANGLE_FN_INDEX, &args_obj);
|
||||
if (!obj) {
|
||||
dev_err(&client->dev, "Failed to call DSM to enable keyboard and touchpad\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
ACPI_FREE(obj);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool bmc150_acpi_enable_keyboard(struct i2c_client *client)
|
||||
{
|
||||
/*
|
||||
* The EC must see a change for it to re-enable the kbd, so first
|
||||
* set the angle to 270° (tent/stand mode) and then change it to
|
||||
* 90° (laptop mode).
|
||||
*/
|
||||
if (!bmc150_acpi_set_angle_dsm(client, 0, 270))
|
||||
return false;
|
||||
|
||||
/* The EC needs some time to notice the angle being changed */
|
||||
msleep(100);
|
||||
|
||||
return bmc150_acpi_set_angle_dsm(client, 0, 90);
|
||||
}
|
||||
|
||||
static void bmc150_acpi_resume_work(struct work_struct *work)
|
||||
{
|
||||
struct bmc150_accel_data *data =
|
||||
container_of(work, struct bmc150_accel_data, resume_work.work);
|
||||
|
||||
bmc150_acpi_enable_keyboard(data->second_device);
|
||||
}
|
||||
|
||||
static void bmc150_acpi_resume_handler(struct device *dev)
|
||||
{
|
||||
struct bmc150_accel_data *data = iio_priv(dev_get_drvdata(dev));
|
||||
|
||||
/*
|
||||
* Delay the bmc150_acpi_enable_keyboard() call till after the system
|
||||
* resume has completed, otherwise it will not work.
|
||||
*/
|
||||
schedule_delayed_work(&data->resume_work, msecs_to_jiffies(1000));
|
||||
}
|
||||
|
||||
/*
|
||||
* Some acpi_devices describe 2 accelerometers in a single ACPI device,
|
||||
* try instantiating a second i2c_client for an I2cSerialBusV2 ACPI resource
|
||||
* with index 1.
|
||||
*/
|
||||
static void bmc150_acpi_dual_accel_probe(struct i2c_client *client)
|
||||
{
|
||||
struct bmc150_accel_data *data = iio_priv(i2c_get_clientdata(client));
|
||||
struct acpi_device *adev = ACPI_COMPANION(&client->dev);
|
||||
char dev_name[16];
|
||||
struct i2c_board_info board_info = {
|
||||
.type = "bmc150_accel",
|
||||
.dev_name = dev_name,
|
||||
.fwnode = client->dev.fwnode,
|
||||
};
|
||||
|
||||
if (acpi_match_device_ids(adev, bmc150_acpi_dual_accel_ids))
|
||||
return;
|
||||
|
||||
/*
|
||||
* The 2nd accel sits in the base of 2-in-1s. The suffix is static, as
|
||||
* there should never be more then 1 ACPI node with 2 accelerometers.
|
||||
*/
|
||||
snprintf(dev_name, sizeof(dev_name), "%s:base", acpi_device_hid(adev));
|
||||
|
||||
board_info.irq = acpi_dev_gpio_irq_get(adev, 1);
|
||||
|
||||
data->second_device = i2c_acpi_new_device(&client->dev, 1, &board_info);
|
||||
|
||||
if (!IS_ERR(data->second_device) && bmc150_acpi_enable_keyboard(data->second_device)) {
|
||||
INIT_DELAYED_WORK(&data->resume_work, bmc150_acpi_resume_work);
|
||||
data->resume_callback = bmc150_acpi_resume_handler;
|
||||
}
|
||||
}
|
||||
|
||||
static void bmc150_acpi_dual_accel_remove(struct i2c_client *client)
|
||||
{
|
||||
struct bmc150_accel_data *data = iio_priv(i2c_get_clientdata(client));
|
||||
|
||||
if (data->resume_callback)
|
||||
cancel_delayed_work_sync(&data->resume_work);
|
||||
|
||||
i2c_unregister_device(data->second_device);
|
||||
}
|
||||
#else
|
||||
static void bmc150_acpi_dual_accel_probe(struct i2c_client *client) {}
|
||||
static void bmc150_acpi_dual_accel_remove(struct i2c_client *client) {}
|
||||
#endif
|
||||
|
||||
static int bmc150_accel_probe(struct i2c_client *client,
|
||||
const struct i2c_device_id *id)
|
||||
{
|
||||
@ -30,7 +180,6 @@ static int bmc150_accel_probe(struct i2c_client *client,
|
||||
i2c_check_functionality(client->adapter, I2C_FUNC_I2C) ||
|
||||
i2c_check_functionality(client->adapter,
|
||||
I2C_FUNC_SMBUS_READ_I2C_BLOCK);
|
||||
struct acpi_device __maybe_unused *adev;
|
||||
int ret;
|
||||
|
||||
regmap = devm_regmap_init_i2c(client, &bmc150_regmap_conf);
|
||||
@ -47,80 +196,62 @@ static int bmc150_accel_probe(struct i2c_client *client,
|
||||
return ret;
|
||||
|
||||
/*
|
||||
* Some BOSC0200 acpi_devices describe 2 accelerometers in a single ACPI
|
||||
* device, try instantiating a second i2c_client for an I2cSerialBusV2
|
||||
* ACPI resource with index 1. The !id check avoids recursion when
|
||||
* bmc150_accel_probe() gets called for the second client.
|
||||
* The !id check avoids recursion when probe() gets called
|
||||
* for the second client.
|
||||
*/
|
||||
#ifdef CONFIG_ACPI
|
||||
adev = ACPI_COMPANION(&client->dev);
|
||||
if (!id && adev && strcmp(acpi_device_hid(adev), "BOSC0200") == 0) {
|
||||
struct i2c_board_info board_info = {
|
||||
.type = "bmc150_accel",
|
||||
/*
|
||||
* The 2nd accel sits in the base of 2-in-1s. Note this
|
||||
* name is static, as there should never be more then 1
|
||||
* BOSC0200 ACPI node with 2 accelerometers in it.
|
||||
*/
|
||||
.dev_name = "BOSC0200:base",
|
||||
.fwnode = client->dev.fwnode,
|
||||
.irq = -ENOENT,
|
||||
};
|
||||
struct i2c_client *second_dev;
|
||||
|
||||
second_dev = i2c_acpi_new_device(&client->dev, 1, &board_info);
|
||||
if (!IS_ERR(second_dev))
|
||||
bmc150_set_second_device(second_dev);
|
||||
}
|
||||
#endif
|
||||
if (!id && has_acpi_companion(&client->dev))
|
||||
bmc150_acpi_dual_accel_probe(client);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int bmc150_accel_remove(struct i2c_client *client)
|
||||
{
|
||||
struct i2c_client *second_dev = bmc150_get_second_device(client);
|
||||
|
||||
i2c_unregister_device(second_dev);
|
||||
bmc150_acpi_dual_accel_remove(client);
|
||||
|
||||
return bmc150_accel_core_remove(&client->dev);
|
||||
}
|
||||
|
||||
static const struct acpi_device_id bmc150_accel_acpi_match[] = {
|
||||
{"BSBA0150", bmc150},
|
||||
{"BMC150A", bmc150},
|
||||
{"BMI055A", bmi055},
|
||||
{"BMA0255", bma255},
|
||||
{"BMA250E", bma250e},
|
||||
{"BMA222", bma222},
|
||||
{"BMA222E", bma222e},
|
||||
{"BMA0280", bma280},
|
||||
{"BMA0255"},
|
||||
{"BMA0280"},
|
||||
{"BMA222"},
|
||||
{"BMA222E"},
|
||||
{"BMA250E"},
|
||||
{"BMC150A"},
|
||||
{"BMI055A"},
|
||||
{"BOSC0200"},
|
||||
{"BSBA0150"},
|
||||
{"DUAL250E"},
|
||||
{ },
|
||||
};
|
||||
MODULE_DEVICE_TABLE(acpi, bmc150_accel_acpi_match);
|
||||
|
||||
static const struct i2c_device_id bmc150_accel_id[] = {
|
||||
{"bmc150_accel", bmc150},
|
||||
{"bmi055_accel", bmi055},
|
||||
{"bma255", bma255},
|
||||
{"bma250e", bma250e},
|
||||
{"bma222", bma222},
|
||||
{"bma222e", bma222e},
|
||||
{"bma280", bma280},
|
||||
{"bma222"},
|
||||
{"bma222e"},
|
||||
{"bma250e"},
|
||||
{"bma253"},
|
||||
{"bma254"},
|
||||
{"bma255"},
|
||||
{"bma280"},
|
||||
{"bmc150_accel"},
|
||||
{"bmi055_accel"},
|
||||
{}
|
||||
};
|
||||
|
||||
MODULE_DEVICE_TABLE(i2c, bmc150_accel_id);
|
||||
|
||||
static const struct of_device_id bmc150_accel_of_match[] = {
|
||||
{ .compatible = "bosch,bmc150_accel" },
|
||||
{ .compatible = "bosch,bmi055_accel" },
|
||||
{ .compatible = "bosch,bma255" },
|
||||
{ .compatible = "bosch,bma250e" },
|
||||
{ .compatible = "bosch,bma222" },
|
||||
{ .compatible = "bosch,bma222e" },
|
||||
{ .compatible = "bosch,bma250e" },
|
||||
{ .compatible = "bosch,bma253" },
|
||||
{ .compatible = "bosch,bma254" },
|
||||
{ .compatible = "bosch,bma255" },
|
||||
{ .compatible = "bosch,bma280" },
|
||||
{ .compatible = "bosch,bmc150_accel" },
|
||||
{ .compatible = "bosch,bmi055_accel" },
|
||||
{ },
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, bmc150_accel_of_match);
|
||||
|
@ -34,26 +34,27 @@ static int bmc150_accel_remove(struct spi_device *spi)
|
||||
}
|
||||
|
||||
static const struct acpi_device_id bmc150_accel_acpi_match[] = {
|
||||
{"BSBA0150", bmc150},
|
||||
{"BMC150A", bmc150},
|
||||
{"BMI055A", bmi055},
|
||||
{"BMA0255", bma255},
|
||||
{"BMA250E", bma250e},
|
||||
{"BMA222", bma222},
|
||||
{"BMA222E", bma222e},
|
||||
{"BMA0280", bma280},
|
||||
{"BMA0255"},
|
||||
{"BMA0280"},
|
||||
{"BMA222"},
|
||||
{"BMA222E"},
|
||||
{"BMA250E"},
|
||||
{"BMC150A"},
|
||||
{"BMI055A"},
|
||||
{"BSBA0150"},
|
||||
{ },
|
||||
};
|
||||
MODULE_DEVICE_TABLE(acpi, bmc150_accel_acpi_match);
|
||||
|
||||
static const struct spi_device_id bmc150_accel_id[] = {
|
||||
{"bmc150_accel", bmc150},
|
||||
{"bmi055_accel", bmi055},
|
||||
{"bma255", bma255},
|
||||
{"bma250e", bma250e},
|
||||
{"bma222", bma222},
|
||||
{"bma222e", bma222e},
|
||||
{"bma280", bma280},
|
||||
{"bma222"},
|
||||
{"bma222e"},
|
||||
{"bma250e"},
|
||||
{"bma253"},
|
||||
{"bma255"},
|
||||
{"bma280"},
|
||||
{"bmc150_accel"},
|
||||
{"bmi055_accel"},
|
||||
{}
|
||||
};
|
||||
MODULE_DEVICE_TABLE(spi, bmc150_accel_id);
|
||||
|
@ -2,23 +2,75 @@
|
||||
#ifndef _BMC150_ACCEL_H_
|
||||
#define _BMC150_ACCEL_H_
|
||||
|
||||
struct regmap;
|
||||
#include <linux/atomic.h>
|
||||
#include <linux/iio/iio.h>
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/regulator/consumer.h>
|
||||
#include <linux/workqueue.h>
|
||||
|
||||
enum {
|
||||
bmc150,
|
||||
bmi055,
|
||||
bma255,
|
||||
bma250e,
|
||||
bma222,
|
||||
bma222e,
|
||||
bma280,
|
||||
struct regmap;
|
||||
struct i2c_client;
|
||||
struct bmc150_accel_chip_info;
|
||||
struct bmc150_accel_interrupt_info;
|
||||
|
||||
struct bmc150_accel_interrupt {
|
||||
const struct bmc150_accel_interrupt_info *info;
|
||||
atomic_t users;
|
||||
};
|
||||
|
||||
struct bmc150_accel_trigger {
|
||||
struct bmc150_accel_data *data;
|
||||
struct iio_trigger *indio_trig;
|
||||
int (*setup)(struct bmc150_accel_trigger *t, bool state);
|
||||
int intr;
|
||||
bool enabled;
|
||||
};
|
||||
|
||||
enum bmc150_accel_interrupt_id {
|
||||
BMC150_ACCEL_INT_DATA_READY,
|
||||
BMC150_ACCEL_INT_ANY_MOTION,
|
||||
BMC150_ACCEL_INT_WATERMARK,
|
||||
BMC150_ACCEL_INTERRUPTS,
|
||||
};
|
||||
|
||||
enum bmc150_accel_trigger_id {
|
||||
BMC150_ACCEL_TRIGGER_DATA_READY,
|
||||
BMC150_ACCEL_TRIGGER_ANY_MOTION,
|
||||
BMC150_ACCEL_TRIGGERS,
|
||||
};
|
||||
|
||||
struct bmc150_accel_data {
|
||||
struct regmap *regmap;
|
||||
struct regulator_bulk_data regulators[2];
|
||||
struct bmc150_accel_interrupt interrupts[BMC150_ACCEL_INTERRUPTS];
|
||||
struct bmc150_accel_trigger triggers[BMC150_ACCEL_TRIGGERS];
|
||||
struct mutex mutex;
|
||||
u8 fifo_mode, watermark;
|
||||
s16 buffer[8];
|
||||
/*
|
||||
* Ensure there is sufficient space and correct alignment for
|
||||
* the timestamp if enabled
|
||||
*/
|
||||
struct {
|
||||
__le16 channels[3];
|
||||
s64 ts __aligned(8);
|
||||
} scan;
|
||||
u8 bw_bits;
|
||||
u32 slope_dur;
|
||||
u32 slope_thres;
|
||||
u32 range;
|
||||
int ev_enable_state;
|
||||
int64_t timestamp, old_timestamp; /* Only used in hw fifo mode. */
|
||||
const struct bmc150_accel_chip_info *chip_info;
|
||||
struct i2c_client *second_device;
|
||||
void (*resume_callback)(struct device *dev);
|
||||
struct delayed_work resume_work;
|
||||
struct iio_mount_matrix orientation;
|
||||
};
|
||||
|
||||
int bmc150_accel_core_probe(struct device *dev, struct regmap *regmap, int irq,
|
||||
const char *name, bool block_supported);
|
||||
int bmc150_accel_core_remove(struct device *dev);
|
||||
struct i2c_client *bmc150_get_second_device(struct i2c_client *second_device);
|
||||
void bmc150_set_second_device(struct i2c_client *second_device);
|
||||
extern const struct dev_pm_ops bmc150_accel_pm_ops;
|
||||
extern const struct regmap_config bmc150_regmap_conf;
|
||||
|
||||
|
@ -6,13 +6,10 @@
|
||||
#include <linux/device.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/irq.h>
|
||||
#include <linux/mod_devicetable.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/hid-sensor-hub.h>
|
||||
#include <linux/iio/iio.h>
|
||||
#include <linux/iio/sysfs.h>
|
||||
#include <linux/iio/buffer.h>
|
||||
#include "../common/hid-sensors/hid-sensor-trigger.h"
|
||||
|
||||
@ -465,3 +462,4 @@ module_platform_driver(hid_accel_3d_platform_driver);
|
||||
MODULE_DESCRIPTION("HID Sensor Accel 3D");
|
||||
MODULE_AUTHOR("Srinivas Pandruvada <srinivas.pandruvada@intel.com>");
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_IMPORT_NS(IIO_HID);
|
||||
|
@ -862,6 +862,11 @@ static void ad7124_reg_disable(void *r)
|
||||
regulator_disable(r);
|
||||
}
|
||||
|
||||
static void ad7124_clk_disable(void *c)
|
||||
{
|
||||
clk_disable_unprepare(c);
|
||||
}
|
||||
|
||||
static int ad7124_probe(struct spi_device *spi)
|
||||
{
|
||||
const struct ad7124_chip_info *info;
|
||||
@ -883,8 +888,6 @@ static int ad7124_probe(struct spi_device *spi)
|
||||
|
||||
ad_sd_init(&st->sd, indio_dev, spi, &ad7124_sigma_delta_info);
|
||||
|
||||
spi_set_drvdata(spi, indio_dev);
|
||||
|
||||
indio_dev->name = st->chip_info->name;
|
||||
indio_dev->modes = INDIO_DIRECT_MODE;
|
||||
indio_dev->info = &ad7124_info;
|
||||
@ -922,48 +925,28 @@ static int ad7124_probe(struct spi_device *spi)
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
ret = devm_add_action_or_reset(&spi->dev, ad7124_clk_disable, st->mclk);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = ad7124_soft_reset(st);
|
||||
if (ret < 0)
|
||||
goto error_clk_disable_unprepare;
|
||||
return ret;
|
||||
|
||||
ret = ad7124_check_chip_id(st);
|
||||
if (ret)
|
||||
goto error_clk_disable_unprepare;
|
||||
return ret;
|
||||
|
||||
ret = ad7124_setup(st);
|
||||
if (ret < 0)
|
||||
goto error_clk_disable_unprepare;
|
||||
return ret;
|
||||
|
||||
ret = ad_sd_setup_buffer_and_trigger(indio_dev);
|
||||
ret = devm_ad_sd_setup_buffer_and_trigger(&spi->dev, indio_dev);
|
||||
if (ret < 0)
|
||||
goto error_clk_disable_unprepare;
|
||||
return ret;
|
||||
|
||||
ret = iio_device_register(indio_dev);
|
||||
if (ret < 0) {
|
||||
dev_err(&spi->dev, "Failed to register iio device\n");
|
||||
goto error_remove_trigger;
|
||||
}
|
||||
return devm_iio_device_register(&spi->dev, indio_dev);
|
||||
|
||||
return 0;
|
||||
|
||||
error_remove_trigger:
|
||||
ad_sd_cleanup_buffer_and_trigger(indio_dev);
|
||||
error_clk_disable_unprepare:
|
||||
clk_disable_unprepare(st->mclk);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int ad7124_remove(struct spi_device *spi)
|
||||
{
|
||||
struct iio_dev *indio_dev = spi_get_drvdata(spi);
|
||||
struct ad7124_state *st = iio_priv(indio_dev);
|
||||
|
||||
iio_device_unregister(indio_dev);
|
||||
ad_sd_cleanup_buffer_and_trigger(indio_dev);
|
||||
clk_disable_unprepare(st->mclk);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct of_device_id ad7124_of_match[] = {
|
||||
@ -981,7 +964,6 @@ static struct spi_driver ad71124_driver = {
|
||||
.of_match_table = ad7124_of_match,
|
||||
},
|
||||
.probe = ad7124_probe,
|
||||
.remove = ad7124_remove,
|
||||
};
|
||||
module_spi_driver(ad71124_driver);
|
||||
|
||||
|
@ -326,7 +326,7 @@ static int ad7192_of_clock_select(struct ad7192_state *st)
|
||||
clock_sel = AD7192_CLK_INT;
|
||||
|
||||
/* use internal clock */
|
||||
if (PTR_ERR(st->mclk) == -ENOENT) {
|
||||
if (st->mclk) {
|
||||
if (of_property_read_bool(np, "adi,int-clock-output-enable"))
|
||||
clock_sel = AD7192_CLK_INT_CO;
|
||||
} else {
|
||||
@ -908,6 +908,16 @@ static int ad7192_channels_config(struct iio_dev *indio_dev)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void ad7192_reg_disable(void *reg)
|
||||
{
|
||||
regulator_disable(reg);
|
||||
}
|
||||
|
||||
static void ad7192_clk_disable(void *clk)
|
||||
{
|
||||
clk_disable_unprepare(clk);
|
||||
}
|
||||
|
||||
static int ad7192_probe(struct spi_device *spi)
|
||||
{
|
||||
struct ad7192_state *st;
|
||||
@ -937,33 +947,38 @@ static int ad7192_probe(struct spi_device *spi)
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = devm_add_action_or_reset(&spi->dev, ad7192_reg_disable, st->avdd);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
st->dvdd = devm_regulator_get(&spi->dev, "dvdd");
|
||||
if (IS_ERR(st->dvdd)) {
|
||||
ret = PTR_ERR(st->dvdd);
|
||||
goto error_disable_avdd;
|
||||
}
|
||||
if (IS_ERR(st->dvdd))
|
||||
return PTR_ERR(st->dvdd);
|
||||
|
||||
ret = regulator_enable(st->dvdd);
|
||||
if (ret) {
|
||||
dev_err(&spi->dev, "Failed to enable specified DVdd supply\n");
|
||||
goto error_disable_avdd;
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = devm_add_action_or_reset(&spi->dev, ad7192_reg_disable, st->dvdd);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = regulator_get_voltage(st->avdd);
|
||||
if (ret < 0) {
|
||||
dev_err(&spi->dev, "Device tree error, reference voltage undefined\n");
|
||||
goto error_disable_avdd;
|
||||
return ret;
|
||||
}
|
||||
st->int_vref_mv = ret / 1000;
|
||||
|
||||
spi_set_drvdata(spi, indio_dev);
|
||||
st->chip_info = of_device_get_match_data(&spi->dev);
|
||||
indio_dev->name = st->chip_info->name;
|
||||
indio_dev->modes = INDIO_DIRECT_MODE;
|
||||
|
||||
ret = ad7192_channels_config(indio_dev);
|
||||
if (ret < 0)
|
||||
goto error_disable_dvdd;
|
||||
return ret;
|
||||
|
||||
if (st->chip_info->chip_id == CHIPID_AD7195)
|
||||
indio_dev->info = &ad7195_info;
|
||||
@ -972,17 +987,15 @@ static int ad7192_probe(struct spi_device *spi)
|
||||
|
||||
ad_sd_init(&st->sd, indio_dev, spi, &ad7192_sigma_delta_info);
|
||||
|
||||
ret = ad_sd_setup_buffer_and_trigger(indio_dev);
|
||||
ret = devm_ad_sd_setup_buffer_and_trigger(&spi->dev, indio_dev);
|
||||
if (ret)
|
||||
goto error_disable_dvdd;
|
||||
return ret;
|
||||
|
||||
st->fclk = AD7192_INT_FREQ_MHZ;
|
||||
|
||||
st->mclk = devm_clk_get(&st->sd.spi->dev, "mclk");
|
||||
if (IS_ERR(st->mclk) && PTR_ERR(st->mclk) != -ENOENT) {
|
||||
ret = PTR_ERR(st->mclk);
|
||||
goto error_remove_trigger;
|
||||
}
|
||||
st->mclk = devm_clk_get_optional(&spi->dev, "mclk");
|
||||
if (IS_ERR(st->mclk))
|
||||
return PTR_ERR(st->mclk);
|
||||
|
||||
st->clock_sel = ad7192_of_clock_select(st);
|
||||
|
||||
@ -990,55 +1003,26 @@ static int ad7192_probe(struct spi_device *spi)
|
||||
st->clock_sel == AD7192_CLK_EXT_MCLK2) {
|
||||
ret = clk_prepare_enable(st->mclk);
|
||||
if (ret < 0)
|
||||
goto error_remove_trigger;
|
||||
return ret;
|
||||
|
||||
ret = devm_add_action_or_reset(&spi->dev, ad7192_clk_disable,
|
||||
st->mclk);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
st->fclk = clk_get_rate(st->mclk);
|
||||
if (!ad7192_valid_external_frequency(st->fclk)) {
|
||||
ret = -EINVAL;
|
||||
dev_err(&spi->dev,
|
||||
"External clock frequency out of bounds\n");
|
||||
goto error_disable_clk;
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
ret = ad7192_setup(st, spi->dev.of_node);
|
||||
if (ret)
|
||||
goto error_disable_clk;
|
||||
return ret;
|
||||
|
||||
ret = iio_device_register(indio_dev);
|
||||
if (ret < 0)
|
||||
goto error_disable_clk;
|
||||
return 0;
|
||||
|
||||
error_disable_clk:
|
||||
if (st->clock_sel == AD7192_CLK_EXT_MCLK1_2 ||
|
||||
st->clock_sel == AD7192_CLK_EXT_MCLK2)
|
||||
clk_disable_unprepare(st->mclk);
|
||||
error_remove_trigger:
|
||||
ad_sd_cleanup_buffer_and_trigger(indio_dev);
|
||||
error_disable_dvdd:
|
||||
regulator_disable(st->dvdd);
|
||||
error_disable_avdd:
|
||||
regulator_disable(st->avdd);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int ad7192_remove(struct spi_device *spi)
|
||||
{
|
||||
struct iio_dev *indio_dev = spi_get_drvdata(spi);
|
||||
struct ad7192_state *st = iio_priv(indio_dev);
|
||||
|
||||
iio_device_unregister(indio_dev);
|
||||
if (st->clock_sel == AD7192_CLK_EXT_MCLK1_2 ||
|
||||
st->clock_sel == AD7192_CLK_EXT_MCLK2)
|
||||
clk_disable_unprepare(st->mclk);
|
||||
ad_sd_cleanup_buffer_and_trigger(indio_dev);
|
||||
|
||||
regulator_disable(st->dvdd);
|
||||
regulator_disable(st->avdd);
|
||||
|
||||
return 0;
|
||||
return devm_iio_device_register(&spi->dev, indio_dev);
|
||||
}
|
||||
|
||||
static const struct of_device_id ad7192_of_match[] = {
|
||||
@ -1056,7 +1040,6 @@ static struct spi_driver ad7192_driver = {
|
||||
.of_match_table = ad7192_of_match,
|
||||
},
|
||||
.probe = ad7192_probe,
|
||||
.remove = ad7192_remove,
|
||||
};
|
||||
module_spi_driver(ad7192_driver);
|
||||
|
||||
|
@ -389,8 +389,6 @@ static int ad7476_probe(struct spi_device *spi)
|
||||
if (IS_ERR(st->convst_gpio))
|
||||
return PTR_ERR(st->convst_gpio);
|
||||
|
||||
spi_set_drvdata(spi, indio_dev);
|
||||
|
||||
st->spi = spi;
|
||||
|
||||
indio_dev->name = spi_get_device_id(spi)->name;
|
||||
|
@ -273,8 +273,6 @@ static int ad7766_probe(struct spi_device *spi)
|
||||
return ret;
|
||||
}
|
||||
|
||||
spi_set_drvdata(spi, indio_dev);
|
||||
|
||||
ad7766->spi = spi;
|
||||
|
||||
/* First byte always 0 */
|
||||
|
@ -614,7 +614,6 @@ static int ad7768_probe(struct spi_device *spi)
|
||||
|
||||
st->mclk_freq = clk_get_rate(st->mclk);
|
||||
|
||||
spi_set_drvdata(spi, indio_dev);
|
||||
mutex_init(&st->lock);
|
||||
|
||||
indio_dev->channels = ad7768_channels;
|
||||
|
@ -300,6 +300,11 @@ static int ad7780_init_gpios(struct device *dev, struct ad7780_state *st)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void ad7780_reg_disable(void *reg)
|
||||
{
|
||||
regulator_disable(reg);
|
||||
}
|
||||
|
||||
static int ad7780_probe(struct spi_device *spi)
|
||||
{
|
||||
struct ad7780_state *st;
|
||||
@ -318,8 +323,6 @@ static int ad7780_probe(struct spi_device *spi)
|
||||
st->chip_info =
|
||||
&ad7780_chip_info_tbl[spi_get_device_id(spi)->driver_data];
|
||||
|
||||
spi_set_drvdata(spi, indio_dev);
|
||||
|
||||
indio_dev->name = spi_get_device_id(spi)->name;
|
||||
indio_dev->modes = INDIO_DIRECT_MODE;
|
||||
indio_dev->channels = &st->chip_info->channel;
|
||||
@ -340,35 +343,15 @@ static int ad7780_probe(struct spi_device *spi)
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = ad_sd_setup_buffer_and_trigger(indio_dev);
|
||||
ret = devm_add_action_or_reset(&spi->dev, ad7780_reg_disable, st->reg);
|
||||
if (ret)
|
||||
goto error_disable_reg;
|
||||
return ret;
|
||||
|
||||
ret = iio_device_register(indio_dev);
|
||||
ret = devm_ad_sd_setup_buffer_and_trigger(&spi->dev, indio_dev);
|
||||
if (ret)
|
||||
goto error_cleanup_buffer_and_trigger;
|
||||
return ret;
|
||||
|
||||
return 0;
|
||||
|
||||
error_cleanup_buffer_and_trigger:
|
||||
ad_sd_cleanup_buffer_and_trigger(indio_dev);
|
||||
error_disable_reg:
|
||||
regulator_disable(st->reg);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int ad7780_remove(struct spi_device *spi)
|
||||
{
|
||||
struct iio_dev *indio_dev = spi_get_drvdata(spi);
|
||||
struct ad7780_state *st = iio_priv(indio_dev);
|
||||
|
||||
iio_device_unregister(indio_dev);
|
||||
ad_sd_cleanup_buffer_and_trigger(indio_dev);
|
||||
|
||||
regulator_disable(st->reg);
|
||||
|
||||
return 0;
|
||||
return devm_iio_device_register(&spi->dev, indio_dev);
|
||||
}
|
||||
|
||||
static const struct spi_device_id ad7780_id[] = {
|
||||
@ -385,7 +368,6 @@ static struct spi_driver ad7780_driver = {
|
||||
.name = "ad7780",
|
||||
},
|
||||
.probe = ad7780_probe,
|
||||
.remove = ad7780_remove,
|
||||
.id_table = ad7780_id,
|
||||
};
|
||||
module_spi_driver(ad7780_driver);
|
||||
|
@ -394,6 +394,11 @@ static int ad7791_setup(struct ad7791_state *st,
|
||||
st->mode);
|
||||
}
|
||||
|
||||
static void ad7791_reg_disable(void *reg)
|
||||
{
|
||||
regulator_disable(reg);
|
||||
}
|
||||
|
||||
static int ad7791_probe(struct spi_device *spi)
|
||||
{
|
||||
struct ad7791_platform_data *pdata = spi->dev.platform_data;
|
||||
@ -420,11 +425,13 @@ static int ad7791_probe(struct spi_device *spi)
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = devm_add_action_or_reset(&spi->dev, ad7791_reg_disable, st->reg);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
st->info = &ad7791_chip_infos[spi_get_device_id(spi)->driver_data];
|
||||
ad_sd_init(&st->sd, indio_dev, spi, &ad7791_sigma_delta_info);
|
||||
|
||||
spi_set_drvdata(spi, indio_dev);
|
||||
|
||||
indio_dev->name = spi_get_device_id(spi)->name;
|
||||
indio_dev->modes = INDIO_DIRECT_MODE;
|
||||
indio_dev->channels = st->info->channels;
|
||||
@ -434,39 +441,15 @@ static int ad7791_probe(struct spi_device *spi)
|
||||
else
|
||||
indio_dev->info = &ad7791_no_filter_info;
|
||||
|
||||
ret = ad_sd_setup_buffer_and_trigger(indio_dev);
|
||||
ret = devm_ad_sd_setup_buffer_and_trigger(&spi->dev, indio_dev);
|
||||
if (ret)
|
||||
goto error_disable_reg;
|
||||
return ret;
|
||||
|
||||
ret = ad7791_setup(st, pdata);
|
||||
if (ret)
|
||||
goto error_remove_trigger;
|
||||
return ret;
|
||||
|
||||
ret = iio_device_register(indio_dev);
|
||||
if (ret)
|
||||
goto error_remove_trigger;
|
||||
|
||||
return 0;
|
||||
|
||||
error_remove_trigger:
|
||||
ad_sd_cleanup_buffer_and_trigger(indio_dev);
|
||||
error_disable_reg:
|
||||
regulator_disable(st->reg);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int ad7791_remove(struct spi_device *spi)
|
||||
{
|
||||
struct iio_dev *indio_dev = spi_get_drvdata(spi);
|
||||
struct ad7791_state *st = iio_priv(indio_dev);
|
||||
|
||||
iio_device_unregister(indio_dev);
|
||||
ad_sd_cleanup_buffer_and_trigger(indio_dev);
|
||||
|
||||
regulator_disable(st->reg);
|
||||
|
||||
return 0;
|
||||
return devm_iio_device_register(&spi->dev, indio_dev);
|
||||
}
|
||||
|
||||
static const struct spi_device_id ad7791_spi_ids[] = {
|
||||
@ -484,7 +467,6 @@ static struct spi_driver ad7791_driver = {
|
||||
.name = "ad7791",
|
||||
},
|
||||
.probe = ad7791_probe,
|
||||
.remove = ad7791_remove,
|
||||
.id_table = ad7791_spi_ids,
|
||||
};
|
||||
module_spi_driver(ad7791_driver);
|
||||
|
@ -769,6 +769,11 @@ static const struct ad7793_chip_info ad7793_chip_info_tbl[] = {
|
||||
},
|
||||
};
|
||||
|
||||
static void ad7793_reg_disable(void *reg)
|
||||
{
|
||||
regulator_disable(reg);
|
||||
}
|
||||
|
||||
static int ad7793_probe(struct spi_device *spi)
|
||||
{
|
||||
const struct ad7793_platform_data *pdata = spi->dev.platform_data;
|
||||
@ -803,11 +808,13 @@ static int ad7793_probe(struct spi_device *spi)
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = devm_add_action_or_reset(&spi->dev, ad7793_reg_disable, st->reg);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
vref_mv = regulator_get_voltage(st->reg);
|
||||
if (vref_mv < 0) {
|
||||
ret = vref_mv;
|
||||
goto error_disable_reg;
|
||||
}
|
||||
if (vref_mv < 0)
|
||||
return vref_mv;
|
||||
|
||||
vref_mv /= 1000;
|
||||
} else {
|
||||
@ -817,50 +824,21 @@ static int ad7793_probe(struct spi_device *spi)
|
||||
st->chip_info =
|
||||
&ad7793_chip_info_tbl[spi_get_device_id(spi)->driver_data];
|
||||
|
||||
spi_set_drvdata(spi, indio_dev);
|
||||
|
||||
indio_dev->name = spi_get_device_id(spi)->name;
|
||||
indio_dev->modes = INDIO_DIRECT_MODE;
|
||||
indio_dev->channels = st->chip_info->channels;
|
||||
indio_dev->num_channels = st->chip_info->num_channels;
|
||||
indio_dev->info = st->chip_info->iio_info;
|
||||
|
||||
ret = ad_sd_setup_buffer_and_trigger(indio_dev);
|
||||
ret = devm_ad_sd_setup_buffer_and_trigger(&spi->dev, indio_dev);
|
||||
if (ret)
|
||||
goto error_disable_reg;
|
||||
return ret;
|
||||
|
||||
ret = ad7793_setup(indio_dev, pdata, vref_mv);
|
||||
if (ret)
|
||||
goto error_remove_trigger;
|
||||
return ret;
|
||||
|
||||
ret = iio_device_register(indio_dev);
|
||||
if (ret)
|
||||
goto error_remove_trigger;
|
||||
|
||||
return 0;
|
||||
|
||||
error_remove_trigger:
|
||||
ad_sd_cleanup_buffer_and_trigger(indio_dev);
|
||||
error_disable_reg:
|
||||
if (pdata->refsel != AD7793_REFSEL_INTERNAL)
|
||||
regulator_disable(st->reg);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int ad7793_remove(struct spi_device *spi)
|
||||
{
|
||||
const struct ad7793_platform_data *pdata = spi->dev.platform_data;
|
||||
struct iio_dev *indio_dev = spi_get_drvdata(spi);
|
||||
struct ad7793_state *st = iio_priv(indio_dev);
|
||||
|
||||
iio_device_unregister(indio_dev);
|
||||
ad_sd_cleanup_buffer_and_trigger(indio_dev);
|
||||
|
||||
if (pdata->refsel != AD7793_REFSEL_INTERNAL)
|
||||
regulator_disable(st->reg);
|
||||
|
||||
return 0;
|
||||
return devm_iio_device_register(&spi->dev, indio_dev);
|
||||
}
|
||||
|
||||
static const struct spi_device_id ad7793_id[] = {
|
||||
@ -882,7 +860,6 @@ static struct spi_driver ad7793_driver = {
|
||||
.name = "ad7793",
|
||||
},
|
||||
.probe = ad7793_probe,
|
||||
.remove = ad7793_remove,
|
||||
.id_table = ad7793_id,
|
||||
};
|
||||
module_spi_driver(ad7793_driver);
|
||||
|
@ -268,7 +268,6 @@ static int ad7887_probe(struct spi_device *spi)
|
||||
st->chip_info =
|
||||
&ad7887_chip_info_tbl[spi_get_device_id(spi)->driver_data];
|
||||
|
||||
spi_set_drvdata(spi, indio_dev);
|
||||
st->spi = spi;
|
||||
|
||||
indio_dev->name = spi_get_device_id(spi)->name;
|
||||
|
@ -434,8 +434,6 @@ static int ad9467_probe(struct spi_device *spi)
|
||||
mdelay(10);
|
||||
}
|
||||
|
||||
spi_set_drvdata(spi, st);
|
||||
|
||||
conv->chip_info = &info->axi_adc_info;
|
||||
|
||||
id = ad9467_spi_read(spi, AN877_ADC_REG_CHIP_ID);
|
||||
|
@ -470,91 +470,65 @@ EXPORT_SYMBOL_GPL(ad_sd_validate_trigger);
|
||||
static const struct iio_trigger_ops ad_sd_trigger_ops = {
|
||||
};
|
||||
|
||||
static int ad_sd_probe_trigger(struct iio_dev *indio_dev)
|
||||
static int devm_ad_sd_probe_trigger(struct device *dev, struct iio_dev *indio_dev)
|
||||
{
|
||||
struct ad_sigma_delta *sigma_delta = iio_device_get_drvdata(indio_dev);
|
||||
int ret;
|
||||
|
||||
sigma_delta->trig = iio_trigger_alloc(&sigma_delta->spi->dev,
|
||||
"%s-dev%d", indio_dev->name,
|
||||
iio_device_id(indio_dev));
|
||||
if (sigma_delta->trig == NULL) {
|
||||
ret = -ENOMEM;
|
||||
goto error_ret;
|
||||
if (dev != &sigma_delta->spi->dev) {
|
||||
dev_err(dev, "Trigger parent should be '%s', got '%s'\n",
|
||||
dev_name(dev), dev_name(&sigma_delta->spi->dev));
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
sigma_delta->trig = devm_iio_trigger_alloc(dev, "%s-dev%d", indio_dev->name,
|
||||
iio_device_id(indio_dev));
|
||||
if (sigma_delta->trig == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
sigma_delta->trig->ops = &ad_sd_trigger_ops;
|
||||
init_completion(&sigma_delta->completion);
|
||||
|
||||
sigma_delta->irq_dis = true;
|
||||
ret = request_irq(sigma_delta->spi->irq,
|
||||
ad_sd_data_rdy_trig_poll,
|
||||
sigma_delta->info->irq_flags | IRQF_NO_AUTOEN,
|
||||
indio_dev->name,
|
||||
sigma_delta);
|
||||
ret = devm_request_irq(dev, sigma_delta->spi->irq,
|
||||
ad_sd_data_rdy_trig_poll,
|
||||
sigma_delta->info->irq_flags | IRQF_NO_AUTOEN,
|
||||
indio_dev->name,
|
||||
sigma_delta);
|
||||
if (ret)
|
||||
goto error_free_trig;
|
||||
return ret;
|
||||
|
||||
iio_trigger_set_drvdata(sigma_delta->trig, sigma_delta);
|
||||
|
||||
ret = iio_trigger_register(sigma_delta->trig);
|
||||
ret = devm_iio_trigger_register(dev, sigma_delta->trig);
|
||||
if (ret)
|
||||
goto error_free_irq;
|
||||
return ret;
|
||||
|
||||
/* select default trigger */
|
||||
indio_dev->trig = iio_trigger_get(sigma_delta->trig);
|
||||
|
||||
return 0;
|
||||
|
||||
error_free_irq:
|
||||
free_irq(sigma_delta->spi->irq, sigma_delta);
|
||||
error_free_trig:
|
||||
iio_trigger_free(sigma_delta->trig);
|
||||
error_ret:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void ad_sd_remove_trigger(struct iio_dev *indio_dev)
|
||||
{
|
||||
struct ad_sigma_delta *sigma_delta = iio_device_get_drvdata(indio_dev);
|
||||
|
||||
iio_trigger_unregister(sigma_delta->trig);
|
||||
free_irq(sigma_delta->spi->irq, sigma_delta);
|
||||
iio_trigger_free(sigma_delta->trig);
|
||||
}
|
||||
|
||||
/**
|
||||
* ad_sd_setup_buffer_and_trigger() -
|
||||
* devm_ad_sd_setup_buffer_and_trigger() - Device-managed buffer & trigger setup
|
||||
* @dev: Device object to which to bind the life-time of the resources attached
|
||||
* @indio_dev: The IIO device
|
||||
*/
|
||||
int ad_sd_setup_buffer_and_trigger(struct iio_dev *indio_dev)
|
||||
int devm_ad_sd_setup_buffer_and_trigger(struct device *dev, struct iio_dev *indio_dev)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = iio_triggered_buffer_setup(indio_dev, &iio_pollfunc_store_time,
|
||||
&ad_sd_trigger_handler, &ad_sd_buffer_setup_ops);
|
||||
ret = devm_iio_triggered_buffer_setup(dev, indio_dev,
|
||||
&iio_pollfunc_store_time,
|
||||
&ad_sd_trigger_handler,
|
||||
&ad_sd_buffer_setup_ops);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = ad_sd_probe_trigger(indio_dev);
|
||||
if (ret) {
|
||||
iio_triggered_buffer_cleanup(indio_dev);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return devm_ad_sd_probe_trigger(dev, indio_dev);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(ad_sd_setup_buffer_and_trigger);
|
||||
|
||||
/**
|
||||
* ad_sd_cleanup_buffer_and_trigger() -
|
||||
* @indio_dev: The IIO device
|
||||
*/
|
||||
void ad_sd_cleanup_buffer_and_trigger(struct iio_dev *indio_dev)
|
||||
{
|
||||
ad_sd_remove_trigger(indio_dev);
|
||||
iio_triggered_buffer_cleanup(indio_dev);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(ad_sd_cleanup_buffer_and_trigger);
|
||||
EXPORT_SYMBOL_GPL(devm_ad_sd_setup_buffer_and_trigger);
|
||||
|
||||
/**
|
||||
* ad_sd_init() - Initializes a ad_sigma_delta struct
|
||||
|
@ -403,7 +403,8 @@ struct at91_adc_state {
|
||||
struct at91_adc_dma dma_st;
|
||||
struct at91_adc_touch touch_st;
|
||||
struct iio_dev *indio_dev;
|
||||
u16 buffer[AT91_BUFFER_MAX_HWORDS];
|
||||
/* Ensure naturally aligned timestamp */
|
||||
u16 buffer[AT91_BUFFER_MAX_HWORDS] __aligned(8);
|
||||
/*
|
||||
* lock to prevent concurrent 'single conversion' requests through
|
||||
* sysfs.
|
||||
|
@ -483,7 +483,6 @@ static int hi8435_probe(struct spi_device *spi)
|
||||
gpiod_set_value_cansleep(reset_gpio, 1);
|
||||
}
|
||||
|
||||
spi_set_drvdata(spi, idev);
|
||||
mutex_init(&priv->lock);
|
||||
|
||||
idev->name = spi_get_device_id(spi)->name;
|
||||
|
@ -86,9 +86,9 @@ struct hx711_data {
|
||||
struct mutex lock;
|
||||
/*
|
||||
* triggered buffer
|
||||
* 2x32-bit channel + 64-bit timestamp
|
||||
* 2x32-bit channel + 64-bit naturally aligned timestamp
|
||||
*/
|
||||
u32 buffer[4];
|
||||
u32 buffer[4] __aligned(8);
|
||||
/*
|
||||
* delay after a rising edge on SCK until the data is ready DOUT
|
||||
* this is dependent on the hx711 where the datasheet tells a
|
||||
|
@ -430,8 +430,6 @@ static int max1027_probe(struct spi_device *spi)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
spi_set_drvdata(spi, indio_dev);
|
||||
|
||||
st = iio_priv(indio_dev);
|
||||
st->spi = spi;
|
||||
st->info = &max1027_chip_info_tbl[spi_get_device_id(spi)->driver_data];
|
||||
|
@ -147,8 +147,6 @@ static int max1241_probe(struct spi_device *spi)
|
||||
adc->spi = spi;
|
||||
mutex_init(&adc->lock);
|
||||
|
||||
spi_set_drvdata(spi, indio_dev);
|
||||
|
||||
adc->vdd = devm_regulator_get(dev, "vdd");
|
||||
if (IS_ERR(adc->vdd)) {
|
||||
dev_err(dev, "failed to get vdd regulator\n");
|
||||
|
@ -115,7 +115,8 @@ struct mxs_lradc_adc {
|
||||
struct device *dev;
|
||||
|
||||
void __iomem *base;
|
||||
u32 buffer[10];
|
||||
/* Maximum of 8 channels + 8 byte ts */
|
||||
u32 buffer[10] __aligned(8);
|
||||
struct iio_trigger *trig;
|
||||
struct completion completion;
|
||||
spinlock_t lock;
|
||||
|
@ -210,9 +210,6 @@ static int adc084s021_probe(struct spi_device *spi)
|
||||
adc = iio_priv(indio_dev);
|
||||
adc->spi = spi;
|
||||
|
||||
/* Connect the SPI device and the iio dev */
|
||||
spi_set_drvdata(spi, indio_dev);
|
||||
|
||||
/* Initiate the Industrial I/O device */
|
||||
indio_dev->name = spi_get_device_id(spi)->name;
|
||||
indio_dev->modes = INDIO_DIRECT_MODE;
|
||||
|
@ -323,9 +323,7 @@ static int ads1015_set_power_state(struct ads1015_data *data, bool on)
|
||||
struct device *dev = regmap_get_device(data->regmap);
|
||||
|
||||
if (on) {
|
||||
ret = pm_runtime_get_sync(dev);
|
||||
if (ret < 0)
|
||||
pm_runtime_put_noidle(dev);
|
||||
ret = pm_runtime_resume_and_get(dev);
|
||||
} else {
|
||||
pm_runtime_mark_last_busy(dev);
|
||||
ret = pm_runtime_put_autosuspend(dev);
|
||||
@ -1070,7 +1068,6 @@ static int ads1015_remove(struct i2c_client *client)
|
||||
|
||||
pm_runtime_disable(&client->dev);
|
||||
pm_runtime_set_suspended(&client->dev);
|
||||
pm_runtime_put_noidle(&client->dev);
|
||||
|
||||
/* power down single shot mode */
|
||||
return ads1015_set_conv_mode(data, ADS1015_SINGLESHOT);
|
||||
|
@ -327,8 +327,6 @@ static int ads124s_probe(struct spi_device *spi)
|
||||
|
||||
ads124s_priv->chip_info = &ads124s_chip_info_tbl[spi_id->driver_data];
|
||||
|
||||
spi_set_drvdata(spi, indio_dev);
|
||||
|
||||
ads124s_priv->spi = spi;
|
||||
|
||||
indio_dev->name = spi_id->name;
|
||||
|
@ -383,7 +383,8 @@ static irqreturn_t ads8688_trigger_handler(int irq, void *p)
|
||||
{
|
||||
struct iio_poll_func *pf = p;
|
||||
struct iio_dev *indio_dev = pf->indio_dev;
|
||||
u16 buffer[ADS8688_MAX_CHANNELS + sizeof(s64)/sizeof(u16)];
|
||||
/* Ensure naturally aligned timestamp */
|
||||
u16 buffer[ADS8688_MAX_CHANNELS + sizeof(s64)/sizeof(u16)] __aligned(8);
|
||||
int i, j = 0;
|
||||
|
||||
for (i = 0; i < indio_dev->masklength; i++) {
|
||||
|
@ -639,8 +639,6 @@ static int tsc2046_adc_probe(struct spi_device *spi)
|
||||
priv = iio_priv(indio_dev);
|
||||
priv->dcfg = dcfg;
|
||||
|
||||
spi_set_drvdata(spi, indio_dev);
|
||||
|
||||
priv->spi = spi;
|
||||
|
||||
indio_dev->name = TI_TSC2046_NAME;
|
||||
|
@ -410,11 +410,9 @@ static int atlas_buffer_postenable(struct iio_dev *indio_dev)
|
||||
struct atlas_data *data = iio_priv(indio_dev);
|
||||
int ret;
|
||||
|
||||
ret = pm_runtime_get_sync(&data->client->dev);
|
||||
if (ret < 0) {
|
||||
pm_runtime_put_noidle(&data->client->dev);
|
||||
ret = pm_runtime_resume_and_get(&data->client->dev);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
||||
return atlas_set_interrupt(data, true);
|
||||
}
|
||||
@ -487,11 +485,9 @@ static int atlas_read_measurement(struct atlas_data *data, int reg, __be32 *val)
|
||||
int suspended = pm_runtime_suspended(dev);
|
||||
int ret;
|
||||
|
||||
ret = pm_runtime_get_sync(dev);
|
||||
if (ret < 0) {
|
||||
pm_runtime_put_noidle(dev);
|
||||
ret = pm_runtime_resume_and_get(dev);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (suspended)
|
||||
msleep(data->chip->delay);
|
||||
@ -741,7 +737,6 @@ static int atlas_remove(struct i2c_client *client)
|
||||
|
||||
pm_runtime_disable(&client->dev);
|
||||
pm_runtime_set_suspended(&client->dev);
|
||||
pm_runtime_put_noidle(&client->dev);
|
||||
|
||||
return atlas_set_powermode(data, 0);
|
||||
}
|
||||
|
@ -3,18 +3,12 @@
|
||||
* HID Sensors Driver
|
||||
* Copyright (c) 2012, Intel Corporation.
|
||||
*/
|
||||
#include <linux/device.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/irq.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/time.h>
|
||||
|
||||
#include <linux/hid-sensor-hub.h>
|
||||
#include <linux/iio/iio.h>
|
||||
#include <linux/iio/sysfs.h>
|
||||
|
||||
#define HZ_PER_MHZ 1000000L
|
||||
|
||||
@ -176,7 +170,7 @@ s32 hid_sensor_read_poll_value(struct hid_sensor_common *st)
|
||||
|
||||
return value;
|
||||
}
|
||||
EXPORT_SYMBOL(hid_sensor_read_poll_value);
|
||||
EXPORT_SYMBOL_NS(hid_sensor_read_poll_value, IIO_HID_ATTRIBUTES);
|
||||
|
||||
int hid_sensor_read_samp_freq_value(struct hid_sensor_common *st,
|
||||
int *val1, int *val2)
|
||||
@ -203,7 +197,7 @@ int hid_sensor_read_samp_freq_value(struct hid_sensor_common *st,
|
||||
|
||||
return IIO_VAL_INT_PLUS_MICRO;
|
||||
}
|
||||
EXPORT_SYMBOL(hid_sensor_read_samp_freq_value);
|
||||
EXPORT_SYMBOL_NS(hid_sensor_read_samp_freq_value, IIO_HID);
|
||||
|
||||
int hid_sensor_write_samp_freq_value(struct hid_sensor_common *st,
|
||||
int val1, int val2)
|
||||
@ -238,7 +232,7 @@ int hid_sensor_write_samp_freq_value(struct hid_sensor_common *st,
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(hid_sensor_write_samp_freq_value);
|
||||
EXPORT_SYMBOL_NS(hid_sensor_write_samp_freq_value, IIO_HID);
|
||||
|
||||
int hid_sensor_read_raw_hyst_value(struct hid_sensor_common *st,
|
||||
int *val1, int *val2)
|
||||
@ -261,7 +255,7 @@ int hid_sensor_read_raw_hyst_value(struct hid_sensor_common *st,
|
||||
|
||||
return IIO_VAL_INT_PLUS_MICRO;
|
||||
}
|
||||
EXPORT_SYMBOL(hid_sensor_read_raw_hyst_value);
|
||||
EXPORT_SYMBOL_NS(hid_sensor_read_raw_hyst_value, IIO_HID);
|
||||
|
||||
int hid_sensor_read_raw_hyst_rel_value(struct hid_sensor_common *st, int *val1,
|
||||
int *val2)
|
||||
@ -283,7 +277,7 @@ int hid_sensor_read_raw_hyst_rel_value(struct hid_sensor_common *st, int *val1,
|
||||
|
||||
return IIO_VAL_INT_PLUS_MICRO;
|
||||
}
|
||||
EXPORT_SYMBOL(hid_sensor_read_raw_hyst_rel_value);
|
||||
EXPORT_SYMBOL_NS(hid_sensor_read_raw_hyst_rel_value, IIO_HID);
|
||||
|
||||
|
||||
int hid_sensor_write_raw_hyst_value(struct hid_sensor_common *st,
|
||||
@ -315,7 +309,7 @@ int hid_sensor_write_raw_hyst_value(struct hid_sensor_common *st,
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(hid_sensor_write_raw_hyst_value);
|
||||
EXPORT_SYMBOL_NS(hid_sensor_write_raw_hyst_value, IIO_HID);
|
||||
|
||||
int hid_sensor_write_raw_hyst_rel_value(struct hid_sensor_common *st,
|
||||
int val1, int val2)
|
||||
@ -346,7 +340,7 @@ int hid_sensor_write_raw_hyst_rel_value(struct hid_sensor_common *st,
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(hid_sensor_write_raw_hyst_rel_value);
|
||||
EXPORT_SYMBOL_NS(hid_sensor_write_raw_hyst_rel_value, IIO_HID);
|
||||
|
||||
/*
|
||||
* This fuction applies the unit exponent to the scale.
|
||||
@ -430,14 +424,14 @@ int hid_sensor_format_scale(u32 usage_id,
|
||||
|
||||
return IIO_VAL_INT_PLUS_NANO;
|
||||
}
|
||||
EXPORT_SYMBOL(hid_sensor_format_scale);
|
||||
EXPORT_SYMBOL_NS(hid_sensor_format_scale, IIO_HID);
|
||||
|
||||
int64_t hid_sensor_convert_timestamp(struct hid_sensor_common *st,
|
||||
int64_t raw_value)
|
||||
{
|
||||
return st->timestamp_ns_scale * raw_value;
|
||||
}
|
||||
EXPORT_SYMBOL(hid_sensor_convert_timestamp);
|
||||
EXPORT_SYMBOL_NS(hid_sensor_convert_timestamp, IIO_HID);
|
||||
|
||||
static
|
||||
int hid_sensor_get_reporting_interval(struct hid_sensor_hub_device *hsdev,
|
||||
@ -484,7 +478,7 @@ int hid_sensor_get_report_latency(struct hid_sensor_common *st)
|
||||
|
||||
return value;
|
||||
}
|
||||
EXPORT_SYMBOL(hid_sensor_get_report_latency);
|
||||
EXPORT_SYMBOL_NS(hid_sensor_get_report_latency, IIO_HID_ATTRIBUTES);
|
||||
|
||||
int hid_sensor_set_report_latency(struct hid_sensor_common *st, int latency_ms)
|
||||
{
|
||||
@ -492,13 +486,13 @@ int hid_sensor_set_report_latency(struct hid_sensor_common *st, int latency_ms)
|
||||
st->report_latency.index,
|
||||
sizeof(latency_ms), &latency_ms);
|
||||
}
|
||||
EXPORT_SYMBOL(hid_sensor_set_report_latency);
|
||||
EXPORT_SYMBOL_NS(hid_sensor_set_report_latency, IIO_HID_ATTRIBUTES);
|
||||
|
||||
bool hid_sensor_batch_mode_supported(struct hid_sensor_common *st)
|
||||
{
|
||||
return st->report_latency.index > 0 && st->report_latency.report_id > 0;
|
||||
}
|
||||
EXPORT_SYMBOL(hid_sensor_batch_mode_supported);
|
||||
EXPORT_SYMBOL_NS(hid_sensor_batch_mode_supported, IIO_HID_ATTRIBUTES);
|
||||
|
||||
int hid_sensor_parse_common_attributes(struct hid_sensor_hub_device *hsdev,
|
||||
u32 usage_id,
|
||||
@ -590,7 +584,7 @@ int hid_sensor_parse_common_attributes(struct hid_sensor_hub_device *hsdev,
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(hid_sensor_parse_common_attributes);
|
||||
EXPORT_SYMBOL_NS(hid_sensor_parse_common_attributes, IIO_HID);
|
||||
|
||||
MODULE_AUTHOR("Srinivas Pandruvada <srinivas.pandruvada@intel.com>");
|
||||
MODULE_DESCRIPTION("HID Sensor common attribute processing");
|
||||
|
@ -6,16 +6,13 @@
|
||||
#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/workqueue.h>
|
||||
#include <linux/iio/iio.h>
|
||||
#include <linux/iio/trigger.h>
|
||||
#include <linux/iio/triggered_buffer.h>
|
||||
#include <linux/iio/trigger_consumer.h>
|
||||
#include <linux/iio/buffer.h>
|
||||
#include <linux/iio/sysfs.h>
|
||||
#include "hid-sensor-trigger.h"
|
||||
|
||||
@ -150,7 +147,7 @@ static int _hid_sensor_power_state(struct hid_sensor_common *st, bool state)
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(hid_sensor_power_state);
|
||||
EXPORT_SYMBOL_NS(hid_sensor_power_state, IIO_HID);
|
||||
|
||||
int hid_sensor_power_state(struct hid_sensor_common *st, bool state)
|
||||
{
|
||||
@ -225,7 +222,7 @@ void hid_sensor_remove_trigger(struct iio_dev *indio_dev,
|
||||
iio_trigger_free(attrb->trigger);
|
||||
iio_triggered_buffer_cleanup(indio_dev);
|
||||
}
|
||||
EXPORT_SYMBOL(hid_sensor_remove_trigger);
|
||||
EXPORT_SYMBOL_NS(hid_sensor_remove_trigger, IIO_HID);
|
||||
|
||||
static const struct iio_trigger_ops hid_sensor_trigger_ops = {
|
||||
.set_trigger_state = &hid_sensor_data_rdy_trigger_set_state,
|
||||
@ -291,7 +288,7 @@ error_triggered_buffer_cleanup:
|
||||
iio_triggered_buffer_cleanup(indio_dev);
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL(hid_sensor_setup_trigger);
|
||||
EXPORT_SYMBOL_NS(hid_sensor_setup_trigger, IIO_HID);
|
||||
|
||||
static int __maybe_unused hid_sensor_suspend(struct device *dev)
|
||||
{
|
||||
@ -321,8 +318,9 @@ const struct dev_pm_ops hid_sensor_pm_ops = {
|
||||
SET_RUNTIME_PM_OPS(hid_sensor_suspend,
|
||||
hid_sensor_runtime_resume, NULL)
|
||||
};
|
||||
EXPORT_SYMBOL(hid_sensor_pm_ops);
|
||||
EXPORT_SYMBOL_NS(hid_sensor_pm_ops, IIO_HID);
|
||||
|
||||
MODULE_AUTHOR("Srinivas Pandruvada <srinivas.pandruvada@intel.com>");
|
||||
MODULE_DESCRIPTION("HID Sensor trigger processing");
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_IMPORT_NS(IIO_HID_ATTRIBUTES);
|
||||
|
@ -9,6 +9,9 @@
|
||||
#include <linux/pm.h>
|
||||
#include <linux/pm_runtime.h>
|
||||
|
||||
struct hid_sensor_common;
|
||||
struct iio_dev;
|
||||
|
||||
extern const struct dev_pm_ops hid_sensor_pm_ops;
|
||||
|
||||
int hid_sensor_setup_trigger(struct iio_dev *indio_dev, const char *name,
|
||||
|
@ -1,4 +1,4 @@
|
||||
# SPDX - License - Identifier : GPL - 2.0 - only
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
#
|
||||
# Makefile for the IIO over SCMI
|
||||
#
|
||||
|
@ -34,6 +34,7 @@ config IIO_SIMPLE_DUMMY_BUFFER
|
||||
select IIO_BUFFER
|
||||
select IIO_TRIGGER
|
||||
select IIO_KFIFO_BUF
|
||||
select IIO_TRIGGERED_BUFFER
|
||||
help
|
||||
Add buffered data capture to the simple dummy driver.
|
||||
|
||||
|
@ -563,8 +563,10 @@ static int adf4350_probe(struct spi_device *spi)
|
||||
|
||||
st->lock_detect_gpiod = devm_gpiod_get_optional(&spi->dev, NULL,
|
||||
GPIOD_IN);
|
||||
if (IS_ERR(st->lock_detect_gpiod))
|
||||
return PTR_ERR(st->lock_detect_gpiod);
|
||||
if (IS_ERR(st->lock_detect_gpiod)) {
|
||||
ret = PTR_ERR(st->lock_detect_gpiod);
|
||||
goto error_disable_reg;
|
||||
}
|
||||
|
||||
if (pdata->power_up_frequency) {
|
||||
ret = adf4350_set_freq(st, pdata->power_up_frequency);
|
||||
|
@ -6,13 +6,10 @@
|
||||
#include <linux/device.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/irq.h>
|
||||
#include <linux/mod_devicetable.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/hid-sensor-hub.h>
|
||||
#include <linux/iio/iio.h>
|
||||
#include <linux/iio/sysfs.h>
|
||||
#include <linux/iio/buffer.h>
|
||||
#include "../common/hid-sensors/hid-sensor-trigger.h"
|
||||
|
||||
@ -400,3 +397,4 @@ module_platform_driver(hid_gyro_3d_platform_driver);
|
||||
MODULE_DESCRIPTION("HID Sensor Gyroscope 3D");
|
||||
MODULE_AUTHOR("Srinivas Pandruvada <srinivas.pandruvada@intel.com>");
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_IMPORT_NS(IIO_HID);
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <linux/iio/buffer.h>
|
||||
#include <linux/iio/iio.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/mod_devicetable.h>
|
||||
#include <linux/platform_device.h>
|
||||
|
||||
#include "hid-sensor-trigger.h"
|
||||
@ -295,3 +296,4 @@ module_platform_driver(hid_humidity_platform_driver);
|
||||
MODULE_DESCRIPTION("HID Environmental humidity sensor");
|
||||
MODULE_AUTHOR("Song Hongyan <hongyan.song@intel.com>");
|
||||
MODULE_LICENSE("GPL v2");
|
||||
MODULE_IMPORT_NS(IIO_HID);
|
||||
|
@ -1157,8 +1157,6 @@ static int adis16400_probe(struct spi_device *spi)
|
||||
return -ENOMEM;
|
||||
|
||||
st = iio_priv(indio_dev);
|
||||
/* this is only used for removal purposes */
|
||||
spi_set_drvdata(spi, indio_dev);
|
||||
|
||||
/* setup the industrialio driver allocated elements */
|
||||
st->variant = &adis16400_chips[spi_get_device_id(spi)->driver_data];
|
||||
|
@ -387,8 +387,6 @@ static int adis16460_probe(struct spi_device *spi)
|
||||
if (indio_dev == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
spi_set_drvdata(spi, indio_dev);
|
||||
|
||||
st = iio_priv(indio_dev);
|
||||
|
||||
st->chip_info = &adis16460_chip_info;
|
||||
|
@ -1328,7 +1328,6 @@ static int adis16475_probe(struct spi_device *spi)
|
||||
return -ENOMEM;
|
||||
|
||||
st = iio_priv(indio_dev);
|
||||
spi_set_drvdata(spi, indio_dev);
|
||||
|
||||
st->info = device_get_match_data(&spi->dev);
|
||||
if (!st->info)
|
||||
|
@ -1406,8 +1406,6 @@ static int adis16480_probe(struct spi_device *spi)
|
||||
if (indio_dev == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
spi_set_drvdata(spi, indio_dev);
|
||||
|
||||
st = iio_priv(indio_dev);
|
||||
|
||||
st->chip_info = &adis16480_chip_info[id->driver_data];
|
||||
|
@ -570,11 +570,9 @@ static int inv_mpu6050_read_channel_data(struct iio_dev *indio_dev,
|
||||
freq_hz = INV_MPU6050_DIVIDER_TO_FIFO_RATE(st->chip_config.divider);
|
||||
period_us = 1000000 / freq_hz;
|
||||
|
||||
result = pm_runtime_get_sync(pdev);
|
||||
if (result < 0) {
|
||||
pm_runtime_put_noidle(pdev);
|
||||
result = pm_runtime_resume_and_get(pdev);
|
||||
if (result)
|
||||
return result;
|
||||
}
|
||||
|
||||
switch (chan->type) {
|
||||
case IIO_ANGL_VEL:
|
||||
@ -812,11 +810,9 @@ static int inv_mpu6050_write_raw(struct iio_dev *indio_dev,
|
||||
return result;
|
||||
|
||||
mutex_lock(&st->lock);
|
||||
result = pm_runtime_get_sync(pdev);
|
||||
if (result < 0) {
|
||||
pm_runtime_put_noidle(pdev);
|
||||
result = pm_runtime_resume_and_get(pdev);
|
||||
if (result)
|
||||
goto error_write_raw_unlock;
|
||||
}
|
||||
|
||||
switch (mask) {
|
||||
case IIO_CHAN_INFO_SCALE:
|
||||
@ -930,11 +926,9 @@ inv_mpu6050_fifo_rate_store(struct device *dev, struct device_attribute *attr,
|
||||
result = 0;
|
||||
goto fifo_rate_fail_unlock;
|
||||
}
|
||||
result = pm_runtime_get_sync(pdev);
|
||||
if (result < 0) {
|
||||
pm_runtime_put_noidle(pdev);
|
||||
result = pm_runtime_resume_and_get(pdev);
|
||||
if (result)
|
||||
goto fifo_rate_fail_unlock;
|
||||
}
|
||||
|
||||
result = regmap_write(st->map, st->reg->sample_rate_div, d);
|
||||
if (result)
|
||||
@ -1314,8 +1308,7 @@ static int inv_check_and_setup_chip(struct inv_mpu6050_state *st)
|
||||
for (i = 0; i < INV_NUM_PARTS; ++i) {
|
||||
if (regval == hw_info[i].whoami) {
|
||||
dev_warn(regmap_get_device(st->map),
|
||||
"whoami mismatch got %#02x (%s)"
|
||||
"expected %#02hhx (%s)\n",
|
||||
"whoami mismatch got 0x%02x (%s) expected 0x%02x (%s)\n",
|
||||
regval, hw_info[i].name,
|
||||
st->hw->whoami, st->hw->name);
|
||||
break;
|
||||
@ -1323,7 +1316,7 @@ static int inv_check_and_setup_chip(struct inv_mpu6050_state *st)
|
||||
}
|
||||
if (i >= INV_NUM_PARTS) {
|
||||
dev_err(regmap_get_device(st->map),
|
||||
"invalid whoami %#02x expected %#02hhx (%s)\n",
|
||||
"invalid whoami 0x%02x expected 0x%02x (%s)\n",
|
||||
regval, st->hw->whoami, st->hw->name);
|
||||
return -ENODEV;
|
||||
}
|
||||
@ -1422,7 +1415,6 @@ static void inv_mpu_pm_disable(void *data)
|
||||
{
|
||||
struct device *dev = data;
|
||||
|
||||
pm_runtime_put_sync_suspend(dev);
|
||||
pm_runtime_disable(dev);
|
||||
}
|
||||
|
||||
|
@ -173,11 +173,9 @@ static int inv_mpu6050_set_enable(struct iio_dev *indio_dev, bool enable)
|
||||
|
||||
if (enable) {
|
||||
scan = inv_scan_query(indio_dev);
|
||||
result = pm_runtime_get_sync(pdev);
|
||||
if (result < 0) {
|
||||
pm_runtime_put_noidle(pdev);
|
||||
result = pm_runtime_resume_and_get(pdev);
|
||||
if (result)
|
||||
return result;
|
||||
}
|
||||
/*
|
||||
* In case autosuspend didn't trigger, turn off first not
|
||||
* required sensors.
|
||||
|
@ -6,13 +6,10 @@
|
||||
#include <linux/device.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/irq.h>
|
||||
#include <linux/mod_devicetable.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/hid-sensor-hub.h>
|
||||
#include <linux/iio/iio.h>
|
||||
#include <linux/iio/sysfs.h>
|
||||
#include <linux/iio/buffer.h>
|
||||
#include "../common/hid-sensors/hid-sensor-trigger.h"
|
||||
|
||||
@ -392,3 +389,4 @@ module_platform_driver(hid_als_platform_driver);
|
||||
MODULE_DESCRIPTION("HID Sensor ALS");
|
||||
MODULE_AUTHOR("Srinivas Pandruvada <srinivas.pandruvada@intel.com>");
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_IMPORT_NS(IIO_HID);
|
||||
|
@ -6,13 +6,10 @@
|
||||
#include <linux/device.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/irq.h>
|
||||
#include <linux/mod_devicetable.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/hid-sensor-hub.h>
|
||||
#include <linux/iio/iio.h>
|
||||
#include <linux/iio/sysfs.h>
|
||||
#include <linux/iio/buffer.h>
|
||||
#include "../common/hid-sensors/hid-sensor-trigger.h"
|
||||
|
||||
@ -350,3 +347,4 @@ module_platform_driver(hid_prox_platform_driver);
|
||||
MODULE_DESCRIPTION("HID Sensor Proximity");
|
||||
MODULE_AUTHOR("Archana Patni <archana.patni@intel.com>");
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_IMPORT_NS(IIO_HID);
|
||||
|
@ -32,9 +32,12 @@
|
||||
#define LTR501_PART_ID 0x86
|
||||
#define LTR501_MANUFAC_ID 0x87
|
||||
#define LTR501_ALS_DATA1 0x88 /* 16-bit, little endian */
|
||||
#define LTR501_ALS_DATA1_UPPER 0x89 /* upper 8 bits of LTR501_ALS_DATA1 */
|
||||
#define LTR501_ALS_DATA0 0x8a /* 16-bit, little endian */
|
||||
#define LTR501_ALS_DATA0_UPPER 0x8b /* upper 8 bits of LTR501_ALS_DATA0 */
|
||||
#define LTR501_ALS_PS_STATUS 0x8c
|
||||
#define LTR501_PS_DATA 0x8d /* 16-bit, little endian */
|
||||
#define LTR501_PS_DATA_UPPER 0x8e /* upper 8 bits of LTR501_PS_DATA */
|
||||
#define LTR501_INTR 0x8f /* output mode, polarity, mode */
|
||||
#define LTR501_PS_THRESH_UP 0x90 /* 11 bit, ps upper threshold */
|
||||
#define LTR501_PS_THRESH_LOW 0x92 /* 11 bit, ps lower threshold */
|
||||
@ -149,7 +152,7 @@ struct ltr501_chip_info {
|
||||
struct ltr501_data {
|
||||
struct i2c_client *client;
|
||||
struct mutex lock_als, lock_ps;
|
||||
struct ltr501_chip_info *chip_info;
|
||||
const struct ltr501_chip_info *chip_info;
|
||||
u8 als_contr, ps_contr;
|
||||
int als_period, ps_period; /* period in micro seconds */
|
||||
struct regmap *regmap;
|
||||
@ -406,18 +409,19 @@ static int ltr501_read_als(const struct ltr501_data *data, __le16 buf[2])
|
||||
|
||||
static int ltr501_read_ps(const struct ltr501_data *data)
|
||||
{
|
||||
int ret, status;
|
||||
__le16 status;
|
||||
int ret;
|
||||
|
||||
ret = ltr501_drdy(data, LTR501_STATUS_PS_RDY);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
ret = regmap_bulk_read(data->regmap, LTR501_PS_DATA,
|
||||
&status, 2);
|
||||
&status, sizeof(status));
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
return status;
|
||||
return le16_to_cpu(status);
|
||||
}
|
||||
|
||||
static int ltr501_read_intr_prst(const struct ltr501_data *data,
|
||||
@ -735,7 +739,7 @@ static int ltr501_write_raw(struct iio_dev *indio_dev,
|
||||
{
|
||||
struct ltr501_data *data = iio_priv(indio_dev);
|
||||
int i, ret, freq_val, freq_val2;
|
||||
struct ltr501_chip_info *info = data->chip_info;
|
||||
const struct ltr501_chip_info *info = data->chip_info;
|
||||
|
||||
ret = iio_device_claim_direct_mode(indio_dev);
|
||||
if (ret)
|
||||
@ -1082,7 +1086,7 @@ static ssize_t ltr501_show_proximity_scale_avail(struct device *dev,
|
||||
char *buf)
|
||||
{
|
||||
struct ltr501_data *data = iio_priv(dev_to_iio_dev(dev));
|
||||
struct ltr501_chip_info *info = data->chip_info;
|
||||
const struct ltr501_chip_info *info = data->chip_info;
|
||||
ssize_t len = 0;
|
||||
int i;
|
||||
|
||||
@ -1104,7 +1108,7 @@ static ssize_t ltr501_show_intensity_scale_avail(struct device *dev,
|
||||
char *buf)
|
||||
{
|
||||
struct ltr501_data *data = iio_priv(dev_to_iio_dev(dev));
|
||||
struct ltr501_chip_info *info = data->chip_info;
|
||||
const struct ltr501_chip_info *info = data->chip_info;
|
||||
ssize_t len = 0;
|
||||
int i;
|
||||
|
||||
@ -1184,7 +1188,7 @@ static const struct iio_info ltr301_info = {
|
||||
.write_event_config = <r501_write_event_config,
|
||||
};
|
||||
|
||||
static struct ltr501_chip_info ltr501_chip_info_tbl[] = {
|
||||
static const struct ltr501_chip_info ltr501_chip_info_tbl[] = {
|
||||
[ltr501] = {
|
||||
.partid = 0x08,
|
||||
.als_gain = ltr501_als_gain_tbl,
|
||||
@ -1205,7 +1209,7 @@ static struct ltr501_chip_info ltr501_chip_info_tbl[] = {
|
||||
.als_gain_tbl_size = ARRAY_SIZE(ltr559_als_gain_tbl),
|
||||
.ps_gain = ltr559_ps_gain_tbl,
|
||||
.ps_gain_tbl_size = ARRAY_SIZE(ltr559_ps_gain_tbl),
|
||||
.als_mode_active = BIT(1),
|
||||
.als_mode_active = BIT(0),
|
||||
.als_gain_mask = BIT(2) | BIT(3) | BIT(4),
|
||||
.als_gain_shift = 2,
|
||||
.info = <r501_info,
|
||||
@ -1354,9 +1358,12 @@ static bool ltr501_is_volatile_reg(struct device *dev, unsigned int reg)
|
||||
{
|
||||
switch (reg) {
|
||||
case LTR501_ALS_DATA1:
|
||||
case LTR501_ALS_DATA1_UPPER:
|
||||
case LTR501_ALS_DATA0:
|
||||
case LTR501_ALS_DATA0_UPPER:
|
||||
case LTR501_ALS_PS_STATUS:
|
||||
case LTR501_PS_DATA:
|
||||
case LTR501_PS_DATA_UPPER:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
|
@ -352,22 +352,22 @@ static int si1133_parse_response_err(struct device *dev, u32 resp, u8 cmd)
|
||||
|
||||
switch (resp) {
|
||||
case SI1133_ERR_OUTPUT_BUFFER_OVERFLOW:
|
||||
dev_warn(dev, "Output buffer overflow: %#02hhx\n", cmd);
|
||||
dev_warn(dev, "Output buffer overflow: 0x%02x\n", cmd);
|
||||
return -EOVERFLOW;
|
||||
case SI1133_ERR_SATURATION_ADC_OR_OVERFLOW_ACCUMULATION:
|
||||
dev_warn(dev, "Saturation of the ADC or overflow of accumulation: %#02hhx\n",
|
||||
dev_warn(dev, "Saturation of the ADC or overflow of accumulation: 0x%02x\n",
|
||||
cmd);
|
||||
return -EOVERFLOW;
|
||||
case SI1133_ERR_INVALID_LOCATION_CMD:
|
||||
dev_warn(dev,
|
||||
"Parameter access to an invalid location: %#02hhx\n",
|
||||
"Parameter access to an invalid location: 0x%02x\n",
|
||||
cmd);
|
||||
return -EINVAL;
|
||||
case SI1133_ERR_INVALID_CMD:
|
||||
dev_warn(dev, "Invalid command %#02hhx\n", cmd);
|
||||
dev_warn(dev, "Invalid command 0x%02x\n", cmd);
|
||||
return -EINVAL;
|
||||
default:
|
||||
dev_warn(dev, "Unknown error %#02hhx\n", cmd);
|
||||
dev_warn(dev, "Unknown error 0x%02x\n", cmd);
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
@ -400,7 +400,7 @@ static int si1133_command(struct si1133_data *data, u8 cmd)
|
||||
|
||||
err = regmap_write(data->regmap, SI1133_REG_COMMAND, cmd);
|
||||
if (err) {
|
||||
dev_warn(dev, "Failed to write command %#02hhx, ret=%d\n", cmd,
|
||||
dev_warn(dev, "Failed to write command 0x%02x, ret=%d\n", cmd,
|
||||
err);
|
||||
goto out;
|
||||
}
|
||||
@ -425,7 +425,7 @@ static int si1133_command(struct si1133_data *data, u8 cmd)
|
||||
SI1133_CMD_TIMEOUT_MS * 1000);
|
||||
if (err) {
|
||||
dev_warn(dev,
|
||||
"Failed to read command %#02hhx, ret=%d\n",
|
||||
"Failed to read command 0x%02x, ret=%d\n",
|
||||
cmd, err);
|
||||
goto out;
|
||||
}
|
||||
@ -978,11 +978,11 @@ static int si1133_validate_ids(struct iio_dev *iio_dev)
|
||||
return err;
|
||||
|
||||
dev_info(&iio_dev->dev,
|
||||
"Device ID part %#02hhx rev %#02hhx mfr %#02hhx\n",
|
||||
"Device ID part 0x%02x rev 0x%02x mfr 0x%02x\n",
|
||||
part_id, rev_id, mfr_id);
|
||||
if (part_id != SI1133_PART_ID) {
|
||||
dev_err(&iio_dev->dev,
|
||||
"Part ID mismatch got %#02hhx, expected %#02x\n",
|
||||
"Part ID mismatch got 0x%02x, expected 0x%02x\n",
|
||||
part_id, SI1133_PART_ID);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
@ -271,7 +271,7 @@ static int si1145_command(struct si1145_data *data, u8 cmd)
|
||||
if ((ret & ~SI1145_RSP_COUNTER_MASK) == 0) {
|
||||
if (ret == data->rsp_seq) {
|
||||
if (time_after(jiffies, stop_jiffies)) {
|
||||
dev_warn(dev, "timeout on command %#02hhx\n",
|
||||
dev_warn(dev, "timeout on command 0x%02x\n",
|
||||
cmd);
|
||||
ret = -ETIMEDOUT;
|
||||
break;
|
||||
@ -291,12 +291,12 @@ static int si1145_command(struct si1145_data *data, u8 cmd)
|
||||
ret = -EIO;
|
||||
} else {
|
||||
if (ret == SI1145_RSP_INVALID_SETTING) {
|
||||
dev_warn(dev, "INVALID_SETTING error on command %#02hhx\n",
|
||||
dev_warn(dev, "INVALID_SETTING error on command 0x%02x\n",
|
||||
cmd);
|
||||
ret = -EINVAL;
|
||||
} else {
|
||||
/* All overflows are treated identically */
|
||||
dev_dbg(dev, "overflow, ret=%d, cmd=%#02hhx\n",
|
||||
dev_dbg(dev, "overflow, ret=%d, cmd=0x%02x\n",
|
||||
ret, cmd);
|
||||
ret = -EOVERFLOW;
|
||||
}
|
||||
@ -1299,10 +1299,10 @@ static int si1145_probe(struct i2c_client *client,
|
||||
SI1145_REG_SEQ_ID);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
dev_info(&client->dev, "device ID part %#02hhx rev %#02hhx seq %#02hhx\n",
|
||||
dev_info(&client->dev, "device ID part 0x%02x rev 0x%02x seq 0x%02x\n",
|
||||
part_id, rev_id, seq_id);
|
||||
if (part_id != data->part_info->part) {
|
||||
dev_err(&client->dev, "part ID mismatch got %#02hhx, expected %#02x\n",
|
||||
dev_err(&client->dev, "part ID mismatch got 0x%02x, expected 0x%02x\n",
|
||||
part_id, data->part_info->part);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
@ -535,7 +535,8 @@ static int tcs3472_probe(struct i2c_client *client,
|
||||
return 0;
|
||||
|
||||
free_irq:
|
||||
free_irq(client->irq, indio_dev);
|
||||
if (client->irq)
|
||||
free_irq(client->irq, indio_dev);
|
||||
buffer_cleanup:
|
||||
iio_triggered_buffer_cleanup(indio_dev);
|
||||
return ret;
|
||||
@ -563,7 +564,8 @@ static int tcs3472_remove(struct i2c_client *client)
|
||||
struct iio_dev *indio_dev = i2c_get_clientdata(client);
|
||||
|
||||
iio_device_unregister(indio_dev);
|
||||
free_irq(client->irq, indio_dev);
|
||||
if (client->irq)
|
||||
free_irq(client->irq, indio_dev);
|
||||
iio_triggered_buffer_cleanup(indio_dev);
|
||||
tcs3472_powerdown(iio_priv(indio_dev));
|
||||
|
||||
|
@ -908,7 +908,7 @@ static irqreturn_t vcnl4010_trigger_handler(int irq, void *p)
|
||||
struct iio_dev *indio_dev = pf->indio_dev;
|
||||
struct vcnl4000_data *data = iio_priv(indio_dev);
|
||||
const unsigned long *active_scan_mask = indio_dev->active_scan_mask;
|
||||
u16 buffer[8] = {0}; /* 1x16-bit + ts */
|
||||
u16 buffer[8] __aligned(8) = {0}; /* 1x16-bit + naturally aligned ts */
|
||||
bool data_read = false;
|
||||
unsigned long isr;
|
||||
int val = 0;
|
||||
|
@ -102,7 +102,8 @@ static irqreturn_t vcnl4035_trigger_consumer_handler(int irq, void *p)
|
||||
struct iio_poll_func *pf = p;
|
||||
struct iio_dev *indio_dev = pf->indio_dev;
|
||||
struct vcnl4035_data *data = iio_priv(indio_dev);
|
||||
u8 buffer[ALIGN(sizeof(u16), sizeof(s64)) + sizeof(s64)];
|
||||
/* Ensure naturally aligned timestamp */
|
||||
u8 buffer[ALIGN(sizeof(u16), sizeof(s64)) + sizeof(s64)] __aligned(8);
|
||||
int ret;
|
||||
|
||||
ret = regmap_read(data->regmap, VCNL4035_ALS_DATA, (int *)buffer);
|
||||
|
@ -6,13 +6,9 @@
|
||||
#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/mod_devicetable.h>
|
||||
#include <linux/hid-sensor-hub.h>
|
||||
#include <linux/iio/iio.h>
|
||||
#include <linux/iio/sysfs.h>
|
||||
#include <linux/iio/buffer.h>
|
||||
#include "../common/hid-sensors/hid-sensor-trigger.h"
|
||||
|
||||
@ -587,3 +583,4 @@ module_platform_driver(hid_magn_3d_platform_driver);
|
||||
MODULE_DESCRIPTION("HID Sensor Magnetometer 3D");
|
||||
MODULE_AUTHOR("Srinivas Pandruvada <srinivas.pandruvada@intel.com>");
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_IMPORT_NS(IIO_HID);
|
||||
|
@ -78,7 +78,8 @@ struct rm3100_data {
|
||||
bool use_interrupt;
|
||||
int conversion_time;
|
||||
int scale;
|
||||
u8 buffer[RM3100_SCAN_BYTES];
|
||||
/* Ensure naturally aligned timestamp */
|
||||
u8 buffer[RM3100_SCAN_BYTES] __aligned(8);
|
||||
struct iio_trigger *drdy_trig;
|
||||
|
||||
/*
|
||||
|
@ -7,13 +7,10 @@
|
||||
#include <linux/device.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/irq.h>
|
||||
#include <linux/mod_devicetable.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/hid-sensor-hub.h>
|
||||
#include <linux/iio/iio.h>
|
||||
#include <linux/iio/sysfs.h>
|
||||
#include <linux/iio/buffer.h>
|
||||
#include "../common/hid-sensors/hid-sensor-trigger.h"
|
||||
|
||||
@ -425,3 +422,4 @@ module_platform_driver(hid_incl_3d_platform_driver);
|
||||
MODULE_DESCRIPTION("HID Sensor Inclinometer 3D");
|
||||
MODULE_AUTHOR("Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>");
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_IMPORT_NS(IIO_HID);
|
||||
|
@ -7,9 +7,7 @@
|
||||
#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/mod_devicetable.h>
|
||||
#include <linux/hid-sensor-hub.h>
|
||||
#include <linux/iio/iio.h>
|
||||
#include <linux/iio/sysfs.h>
|
||||
@ -373,3 +371,4 @@ module_platform_driver(hid_dev_rot_platform_driver);
|
||||
MODULE_DESCRIPTION("HID Sensor Device Rotation");
|
||||
MODULE_AUTHOR("Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>");
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_IMPORT_NS(IIO_HID);
|
||||
|
@ -7,6 +7,8 @@
|
||||
#include <linux/iio/buffer.h>
|
||||
#include <linux/iio/iio.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/mod_devicetable.h>
|
||||
|
||||
#include "../common/hid-sensors/hid-sensor-trigger.h"
|
||||
|
||||
@ -376,3 +378,4 @@ module_platform_driver(hid_hinge_platform_driver);
|
||||
MODULE_DESCRIPTION("HID Sensor INTEL Hinge");
|
||||
MODULE_AUTHOR("Ye Xiang <xiang.ye@intel.com>");
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_IMPORT_NS(IIO_HID);
|
||||
|
@ -6,13 +6,10 @@
|
||||
#include <linux/device.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/irq.h>
|
||||
#include <linux/mod_devicetable.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/hid-sensor-hub.h>
|
||||
#include <linux/iio/iio.h>
|
||||
#include <linux/iio/sysfs.h>
|
||||
#include <linux/iio/buffer.h>
|
||||
#include "../common/hid-sensors/hid-sensor-trigger.h"
|
||||
|
||||
@ -357,3 +354,4 @@ module_platform_driver(hid_press_platform_driver);
|
||||
MODULE_DESCRIPTION("HID Sensor Pressure");
|
||||
MODULE_AUTHOR("Archana Patni <archana.patni@intel.com>");
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_IMPORT_NS(IIO_HID);
|
||||
|
@ -250,7 +250,9 @@ static int icp10100_get_measures(struct icp10100_state *st,
|
||||
__be16 measures[3];
|
||||
int ret;
|
||||
|
||||
pm_runtime_get_sync(&st->client->dev);
|
||||
ret = pm_runtime_resume_and_get(&st->client->dev);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
mutex_lock(&st->lock);
|
||||
cmd = &icp10100_cmd_measure[st->mode];
|
||||
@ -525,7 +527,6 @@ static void icp10100_pm_disable(void *data)
|
||||
{
|
||||
struct device *dev = data;
|
||||
|
||||
pm_runtime_put_sync_suspend(dev);
|
||||
pm_runtime_disable(dev);
|
||||
}
|
||||
|
||||
|
@ -938,7 +938,7 @@ static irqreturn_t isl29501_trigger_handler(int irq, void *p)
|
||||
struct iio_dev *indio_dev = pf->indio_dev;
|
||||
struct isl29501_private *isl29501 = iio_priv(indio_dev);
|
||||
const unsigned long *active_mask = indio_dev->active_scan_mask;
|
||||
u32 buffer[4] = {}; /* 1x16-bit + ts */
|
||||
u32 buffer[4] __aligned(8) = {}; /* 1x16-bit + naturally aligned ts */
|
||||
|
||||
if (test_bit(ISL29501_DISTANCE_SCAN_INDEX, active_mask))
|
||||
isl29501_register_read(isl29501, REG_DISTANCE, buffer);
|
||||
|
@ -158,7 +158,9 @@ static int lidar_get_measurement(struct lidar_data *data, u16 *reg)
|
||||
int tries = 10;
|
||||
int ret;
|
||||
|
||||
pm_runtime_get_sync(&client->dev);
|
||||
ret = pm_runtime_resume_and_get(&client->dev);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
/* start sample */
|
||||
ret = lidar_write_control(data, LIDAR_REG_CONTROL_ACQUIRE);
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <linux/iio/buffer.h>
|
||||
#include <linux/iio/iio.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/mod_devicetable.h>
|
||||
#include <linux/platform_device.h>
|
||||
|
||||
#include "../common/hid-sensors/hid-sensor-trigger.h"
|
||||
@ -291,3 +292,4 @@ module_platform_driver(hid_temperature_platform_driver);
|
||||
MODULE_DESCRIPTION("HID Environmental temperature sensor");
|
||||
MODULE_AUTHOR("Song Hongyan <hongyan.song@intel.com>");
|
||||
MODULE_LICENSE("GPL v2");
|
||||
MODULE_IMPORT_NS(IIO_HID);
|
||||
|
@ -328,3 +328,4 @@ module_platform_driver(hid_time_platform_driver);
|
||||
MODULE_DESCRIPTION("HID Sensor Time");
|
||||
MODULE_AUTHOR("Alexander Holler <holler@ahsoftware.de>");
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_IMPORT_NS(IIO_HID);
|
||||
|
@ -26,6 +26,7 @@ struct ad_sd_calib_data {
|
||||
};
|
||||
|
||||
struct ad_sigma_delta;
|
||||
struct device;
|
||||
struct iio_dev;
|
||||
|
||||
/**
|
||||
@ -132,8 +133,7 @@ int ad_sd_calibrate_all(struct ad_sigma_delta *sigma_delta,
|
||||
int ad_sd_init(struct ad_sigma_delta *sigma_delta, struct iio_dev *indio_dev,
|
||||
struct spi_device *spi, const struct ad_sigma_delta_info *info);
|
||||
|
||||
int ad_sd_setup_buffer_and_trigger(struct iio_dev *indio_dev);
|
||||
void ad_sd_cleanup_buffer_and_trigger(struct iio_dev *indio_dev);
|
||||
int devm_ad_sd_setup_buffer_and_trigger(struct device *dev, struct iio_dev *indio_dev);
|
||||
|
||||
int ad_sd_validate_trigger(struct iio_dev *indio_dev, struct iio_trigger *trig);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user