You've already forked linux-apfs
mirror of
https://github.com/linux-apfs/linux-apfs.git
synced 2026-05-01 15:00:59 -07:00
Merge tag 'staging-4.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging
Pull staging and IIO updates from Greg KH: "Here is the "big" staging and IIO driver update for 4.15-rc1. Lots and lots of little changes, almost all minor code cleanups as the Outreachy application process happened during this development cycle. Also happened was a lot of IIO driver activity, and the typec USB code moving out of staging to drivers/usb (same commits are in the USB tree on a persistent branch to not cause merge issues.) Overall, it's a wash, I think we added a few hundred more lines than removed, but really only a few thousand were modified at all. All of these have been in linux-next for a while. There might be a merge issue with Al's vfs tree in the pi433 driver (take his changes, they are always better), and the media tree with some of the odd atomisp cleanups (take the media tree's version)" * tag 'staging-4.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: (507 commits) staging: lustre: add SPDX identifiers to all lustre files staging: greybus: Remove redundant license text staging: greybus: add SPDX identifiers to all greybus driver files staging: ccree: simplify ioread/iowrite staging: ccree: simplify registers access staging: ccree: simplify error handling logic staging: ccree: remove dead code staging: ccree: handle limiting of DMA masks staging: ccree: copy IV to DMAable memory staging: fbtft: remove redundant initialization of buf staging: sm750fb: Fix parameter mistake in poke32 staging: wilc1000: Fix bssid buffer offset in Txq staging: fbtft: fb_ssd1331: fix mirrored display staging: android: Fix checkpatch.pl error staging: greybus: loopback: convert loopback to use generic async operations staging: greybus: operation: add private data with get/set accessors staging: greybus: loopback: Fix iteration count on async path staging: greybus: loopback: Hold per-connection mutex across operations staging: greybus/loopback: use ktime_get() for time intervals staging: fsl-dpaa2/eth: Extra headroom in RX buffers ...
This commit is contained in:
@@ -522,6 +522,7 @@ Description:
|
|||||||
Specifies the output powerdown mode.
|
Specifies the output powerdown mode.
|
||||||
DAC output stage is disconnected from the amplifier and
|
DAC output stage is disconnected from the amplifier and
|
||||||
1kohm_to_gnd: connected to ground via an 1kOhm resistor,
|
1kohm_to_gnd: connected to ground via an 1kOhm resistor,
|
||||||
|
2.5kohm_to_gnd: connected to ground via a 2.5kOhm resistor,
|
||||||
6kohm_to_gnd: connected to ground via a 6kOhm resistor,
|
6kohm_to_gnd: connected to ground via a 6kOhm resistor,
|
||||||
20kohm_to_gnd: connected to ground via a 20kOhm resistor,
|
20kohm_to_gnd: connected to ground via a 20kOhm resistor,
|
||||||
90kohm_to_gnd: connected to ground via a 90kOhm resistor,
|
90kohm_to_gnd: connected to ground via a 90kOhm resistor,
|
||||||
@@ -1242,9 +1243,9 @@ What: /sys/.../iio:deviceX/in_distance_raw
|
|||||||
KernelVersion: 4.0
|
KernelVersion: 4.0
|
||||||
Contact: linux-iio@vger.kernel.org
|
Contact: linux-iio@vger.kernel.org
|
||||||
Description:
|
Description:
|
||||||
This attribute is used to read the distance covered by the user
|
This attribute is used to read the measured distance to an object
|
||||||
since the last reboot while activated. Units after application
|
or the distance covered by the user since the last reboot while
|
||||||
of scale are meters.
|
activated. Units after application of scale are meters.
|
||||||
|
|
||||||
What: /sys/bus/iio/devices/iio:deviceX/store_eeprom
|
What: /sys/bus/iio/devices/iio:deviceX/store_eeprom
|
||||||
KernelVersion: 3.4.0
|
KernelVersion: 3.4.0
|
||||||
|
|||||||
@@ -16,3 +16,13 @@ Description:
|
|||||||
the motion sensor is placed. For example, in a laptop a motion
|
the motion sensor is placed. For example, in a laptop a motion
|
||||||
sensor can be located on the base or on the lid. Current valid
|
sensor can be located on the base or on the lid. Current valid
|
||||||
values are 'base' and 'lid'.
|
values are 'base' and 'lid'.
|
||||||
|
|
||||||
|
What: /sys/bus/iio/devices/iio:deviceX/id
|
||||||
|
Date: Septembre 2017
|
||||||
|
KernelVersion: 4.14
|
||||||
|
Contact: linux-iio@vger.kernel.org
|
||||||
|
Description:
|
||||||
|
This attribute is exposed by the CrOS EC legacy accelerometer
|
||||||
|
driver and represents the sensor ID as exposed by the EC. This
|
||||||
|
ID is used by the Android sensor service hardware abstraction
|
||||||
|
layer (sensor HAL) through the Android container on ChromeOS.
|
||||||
|
|||||||
@@ -29,15 +29,29 @@ Required properties:
|
|||||||
"microchip,mcp3204"
|
"microchip,mcp3204"
|
||||||
"microchip,mcp3208"
|
"microchip,mcp3208"
|
||||||
"microchip,mcp3301"
|
"microchip,mcp3301"
|
||||||
|
"microchip,mcp3550-50"
|
||||||
|
"microchip,mcp3550-60"
|
||||||
|
"microchip,mcp3551"
|
||||||
|
"microchip,mcp3553"
|
||||||
|
|
||||||
NOTE: The use of the compatibles with no vendor prefix
|
NOTE: The use of the compatibles with no vendor prefix
|
||||||
is deprecated and only listed because old DT use them.
|
is deprecated and only listed because old DT use them.
|
||||||
|
|
||||||
|
- spi-cpha, spi-cpol (boolean):
|
||||||
|
Either SPI mode (0,0) or (1,1) must be used, so specify
|
||||||
|
none or both of spi-cpha, spi-cpol. The MCP3550/1/3
|
||||||
|
is more efficient in mode (1,1) as only 3 instead of
|
||||||
|
4 bytes need to be read from the ADC, but not all SPI
|
||||||
|
masters support it.
|
||||||
|
|
||||||
|
- vref-supply: Phandle to the external reference voltage supply.
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
spi_controller {
|
spi_controller {
|
||||||
mcp3x0x@0 {
|
mcp3x0x@0 {
|
||||||
compatible = "mcp3002";
|
compatible = "mcp3002";
|
||||||
reg = <0>;
|
reg = <0>;
|
||||||
spi-max-frequency = <1000000>;
|
spi-max-frequency = <1000000>;
|
||||||
|
vref-supply = <&vref_reg>;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ for the Thermal Controller which holds a phandle to the AUXADC.
|
|||||||
Required properties:
|
Required properties:
|
||||||
- compatible: Should be one of:
|
- compatible: Should be one of:
|
||||||
- "mediatek,mt2701-auxadc": For MT2701 family of SoCs
|
- "mediatek,mt2701-auxadc": For MT2701 family of SoCs
|
||||||
|
- "mediatek,mt2712-auxadc": For MT2712 family of SoCs
|
||||||
- "mediatek,mt7622-auxadc": For MT7622 family of SoCs
|
- "mediatek,mt7622-auxadc": For MT7622 family of SoCs
|
||||||
- "mediatek,mt8173-auxadc": For MT8173 family of SoCs
|
- "mediatek,mt8173-auxadc": For MT8173 family of SoCs
|
||||||
- reg: Address range of the AUXADC unit.
|
- reg: Address range of the AUXADC unit.
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
Maxim Integrated DS4422/DS4424 7-bit Sink/Source Current DAC Device Driver
|
||||||
|
|
||||||
|
Datasheet publicly available at:
|
||||||
|
https://datasheets.maximintegrated.com/en/ds/DS4422-DS4424.pdf
|
||||||
|
|
||||||
|
Required properties:
|
||||||
|
- compatible: Should be one of
|
||||||
|
maxim,ds4422
|
||||||
|
maxim,ds4424
|
||||||
|
- reg: Should contain the DAC I2C address
|
||||||
|
|
||||||
|
Optional properties:
|
||||||
|
- vcc-supply: Power supply is optional. If not defined, driver will ignore it.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
ds4224@10 {
|
||||||
|
compatible = "maxim,ds4424";
|
||||||
|
reg = <0x10>; /* When A0, A1 pins are ground */
|
||||||
|
vcc-supply = <&vcc_3v3>;
|
||||||
|
};
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
Texas Instruments 8/10/12-bit 2/4-channel DAC driver
|
||||||
|
|
||||||
|
Required properties:
|
||||||
|
- compatible: Must be one of:
|
||||||
|
"ti,dac082s085"
|
||||||
|
"ti,dac102s085"
|
||||||
|
"ti,dac122s085"
|
||||||
|
"ti,dac084s085"
|
||||||
|
"ti,dac104s085"
|
||||||
|
"ti,dac124s085"
|
||||||
|
- reg: Chip select number.
|
||||||
|
- spi-cpha, spi-cpol: SPI mode (0,1) or (1,0) must be used, so specify
|
||||||
|
either spi-cpha or spi-cpol (but not both).
|
||||||
|
- vref-supply: Phandle to the external reference voltage supply.
|
||||||
|
|
||||||
|
For other required and optional properties of SPI slave nodes please refer to
|
||||||
|
../../spi/spi-bus.txt.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
vref_2v5_reg: regulator-vref {
|
||||||
|
compatible = "regulator-fixed";
|
||||||
|
regulator-name = "2v5";
|
||||||
|
regulator-min-microvolt = <2500000>;
|
||||||
|
regulator-max-microvolt = <2500000>;
|
||||||
|
regulator-always-on;
|
||||||
|
};
|
||||||
|
|
||||||
|
dac@0 {
|
||||||
|
compatible = "ti,dac082s085";
|
||||||
|
reg = <0>;
|
||||||
|
spi-max-frequency = <40000000>;
|
||||||
|
spi-cpol;
|
||||||
|
vref-supply = <&vref_2v5_reg>;
|
||||||
|
};
|
||||||
@@ -20,9 +20,9 @@ Optional properties:
|
|||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
max30100@057 {
|
max30100@57 {
|
||||||
compatible = "maxim,max30100";
|
compatible = "maxim,max30100";
|
||||||
reg = <57>;
|
reg = <0x57>;
|
||||||
maxim,led-current-microamp = <24000 50000>;
|
maxim,led-current-microamp = <24000 50000>;
|
||||||
interrupt-parent = <&gpio1>;
|
interrupt-parent = <&gpio1>;
|
||||||
interrupts = <16 2>;
|
interrupts = <16 2>;
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ Optional properties:
|
|||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
max30100@57 {
|
max30102@57 {
|
||||||
compatible = "maxim,max30102";
|
compatible = "maxim,max30102";
|
||||||
reg = <0x57>;
|
reg = <0x57>;
|
||||||
maxim,red-led-current-microamp = <7000>;
|
maxim,red-led-current-microamp = <7000>;
|
||||||
|
|||||||
@@ -46,6 +46,8 @@ Accelerometers:
|
|||||||
- st,h3lis331dl-accel
|
- st,h3lis331dl-accel
|
||||||
- st,lng2dm-accel
|
- st,lng2dm-accel
|
||||||
- st,lis3l02dq
|
- st,lis3l02dq
|
||||||
|
- st,lis2dw12
|
||||||
|
- st,lis3dhh
|
||||||
|
|
||||||
Gyroscopes:
|
Gyroscopes:
|
||||||
- st,l3g4200d-gyro
|
- st,l3g4200d-gyro
|
||||||
@@ -71,3 +73,5 @@ Pressure sensors:
|
|||||||
- st,lps25h-press
|
- st,lps25h-press
|
||||||
- st,lps331ap-press
|
- st,lps331ap-press
|
||||||
- st,lps22hb-press
|
- st,lps22hb-press
|
||||||
|
- st,lps33hw
|
||||||
|
- st,lps35hw
|
||||||
|
|||||||
@@ -219,7 +219,8 @@ CONFIG_AD525X_DPOT_I2C=m
|
|||||||
CONFIG_ICS932S401=m
|
CONFIG_ICS932S401=m
|
||||||
CONFIG_APDS9802ALS=m
|
CONFIG_APDS9802ALS=m
|
||||||
CONFIG_ISL29003=m
|
CONFIG_ISL29003=m
|
||||||
CONFIG_TI_DAC7512=m
|
CONFIG_IIO=m
|
||||||
|
CONFIG_AD5446=m
|
||||||
CONFIG_EEPROM_AT24=m
|
CONFIG_EEPROM_AT24=m
|
||||||
CONFIG_SENSORS_LIS3_SPI=m
|
CONFIG_SENSORS_LIS3_SPI=m
|
||||||
CONFIG_IDE=m
|
CONFIG_IDE=m
|
||||||
|
|||||||
@@ -37,7 +37,8 @@ CONFIG_MTD_NAND_PXA3xx=y
|
|||||||
CONFIG_MTD_UBI=y
|
CONFIG_MTD_UBI=y
|
||||||
CONFIG_BLK_DEV_LOOP=y
|
CONFIG_BLK_DEV_LOOP=y
|
||||||
CONFIG_ISL29003=y
|
CONFIG_ISL29003=y
|
||||||
CONFIG_TI_DAC7512=y
|
CONFIG_IIO=y
|
||||||
|
CONFIG_AD5446=y
|
||||||
CONFIG_SCSI=y
|
CONFIG_SCSI=y
|
||||||
CONFIG_BLK_DEV_SD=y
|
CONFIG_BLK_DEV_SD=y
|
||||||
CONFIG_CHR_DEV_SG=y
|
CONFIG_CHR_DEV_SG=y
|
||||||
|
|||||||
@@ -148,6 +148,17 @@ config HID_SENSOR_ACCEL_3D
|
|||||||
To compile this driver as a module, choose M here: the
|
To compile this driver as a module, choose M here: the
|
||||||
module will be called hid-sensor-accel-3d.
|
module will be called hid-sensor-accel-3d.
|
||||||
|
|
||||||
|
config IIO_CROS_EC_ACCEL_LEGACY
|
||||||
|
tristate "ChromeOS EC Legacy Accelerometer Sensor"
|
||||||
|
select IIO_BUFFER
|
||||||
|
select IIO_TRIGGERED_BUFFER
|
||||||
|
select CROS_EC_LPC_REGISTER_DEVICE
|
||||||
|
help
|
||||||
|
Say yes here to get support for accelerometers on Chromebook using
|
||||||
|
legacy EC firmware.
|
||||||
|
Sensor data is retrieved through IO memory.
|
||||||
|
Newer devices should use IIO_CROS_EC_SENSORS.
|
||||||
|
|
||||||
config IIO_ST_ACCEL_3AXIS
|
config IIO_ST_ACCEL_3AXIS
|
||||||
tristate "STMicroelectronics accelerometers 3-Axis Driver"
|
tristate "STMicroelectronics accelerometers 3-Axis Driver"
|
||||||
depends on (I2C || SPI_MASTER) && SYSFS
|
depends on (I2C || SPI_MASTER) && SYSFS
|
||||||
@@ -219,8 +230,8 @@ config KXCJK1013
|
|||||||
select IIO_TRIGGERED_BUFFER
|
select IIO_TRIGGERED_BUFFER
|
||||||
help
|
help
|
||||||
Say Y here if you want to build a driver for the Kionix KXCJK-1013
|
Say Y here if you want to build a driver for the Kionix KXCJK-1013
|
||||||
triaxial acceleration sensor. This driver also supports KXCJ9-1008
|
triaxial acceleration sensor. This driver also supports KXCJ9-1008,
|
||||||
and KXTJ2-1009.
|
KXTJ2-1009 and KXTF9.
|
||||||
|
|
||||||
To compile this driver as a module, choose M here: the module will
|
To compile this driver as a module, choose M here: the module will
|
||||||
be called kxcjk-1013.
|
be called kxcjk-1013.
|
||||||
|
|||||||
@@ -44,6 +44,8 @@ obj-$(CONFIG_SCA3000) += sca3000.o
|
|||||||
obj-$(CONFIG_STK8312) += stk8312.o
|
obj-$(CONFIG_STK8312) += stk8312.o
|
||||||
obj-$(CONFIG_STK8BA50) += stk8ba50.o
|
obj-$(CONFIG_STK8BA50) += stk8ba50.o
|
||||||
|
|
||||||
|
obj-$(CONFIG_IIO_CROS_EC_ACCEL_LEGACY) += cros_ec_accel_legacy.o
|
||||||
|
|
||||||
obj-$(CONFIG_IIO_SSP_SENSORS_COMMONS) += ssp_accel_sensor.o
|
obj-$(CONFIG_IIO_SSP_SENSORS_COMMONS) += ssp_accel_sensor.o
|
||||||
|
|
||||||
obj-$(CONFIG_IIO_ST_ACCEL_3AXIS) += st_accel.o
|
obj-$(CONFIG_IIO_ST_ACCEL_3AXIS) += st_accel.o
|
||||||
|
|||||||
@@ -95,7 +95,6 @@ static int adxl345_read_raw(struct iio_dev *indio_dev,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const struct iio_info adxl345_info = {
|
static const struct iio_info adxl345_info = {
|
||||||
.driver_module = THIS_MODULE,
|
|
||||||
.read_raw = adxl345_read_raw,
|
.read_raw = adxl345_read_raw,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -536,7 +536,6 @@ static const struct iio_info bma180_info = {
|
|||||||
.attrs = &bma180_attrs_group,
|
.attrs = &bma180_attrs_group,
|
||||||
.read_raw = bma180_read_raw,
|
.read_raw = bma180_read_raw,
|
||||||
.write_raw = bma180_write_raw,
|
.write_raw = bma180_write_raw,
|
||||||
.driver_module = THIS_MODULE,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char * const bma180_power_modes[] = { "low_noise", "low_power" };
|
static const char * const bma180_power_modes[] = { "low_noise", "low_power" };
|
||||||
@@ -700,7 +699,6 @@ static int bma180_trig_try_reen(struct iio_trigger *trig)
|
|||||||
static const struct iio_trigger_ops bma180_trigger_ops = {
|
static const struct iio_trigger_ops bma180_trigger_ops = {
|
||||||
.set_trigger_state = bma180_data_rdy_trigger_set_state,
|
.set_trigger_state = bma180_data_rdy_trigger_set_state,
|
||||||
.try_reenable = bma180_trig_try_reen,
|
.try_reenable = bma180_trig_try_reen,
|
||||||
.owner = THIS_MODULE,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static int bma180_probe(struct i2c_client *client,
|
static int bma180_probe(struct i2c_client *client,
|
||||||
|
|||||||
@@ -186,7 +186,6 @@ static int bma220_write_raw(struct iio_dev *indio_dev,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const struct iio_info bma220_info = {
|
static const struct iio_info bma220_info = {
|
||||||
.driver_module = THIS_MODULE,
|
|
||||||
.read_raw = bma220_read_raw,
|
.read_raw = bma220_read_raw,
|
||||||
.write_raw = bma220_write_raw,
|
.write_raw = bma220_write_raw,
|
||||||
.attrs = &bma220_attribute_group,
|
.attrs = &bma220_attribute_group,
|
||||||
|
|||||||
@@ -1094,7 +1094,6 @@ static const struct iio_info bmc150_accel_info = {
|
|||||||
.write_event_value = bmc150_accel_write_event,
|
.write_event_value = bmc150_accel_write_event,
|
||||||
.write_event_config = bmc150_accel_write_event_config,
|
.write_event_config = bmc150_accel_write_event_config,
|
||||||
.read_event_config = bmc150_accel_read_event_config,
|
.read_event_config = bmc150_accel_read_event_config,
|
||||||
.driver_module = THIS_MODULE,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct iio_info bmc150_accel_info_fifo = {
|
static const struct iio_info bmc150_accel_info_fifo = {
|
||||||
@@ -1108,7 +1107,6 @@ static const struct iio_info bmc150_accel_info_fifo = {
|
|||||||
.validate_trigger = bmc150_accel_validate_trigger,
|
.validate_trigger = bmc150_accel_validate_trigger,
|
||||||
.hwfifo_set_watermark = bmc150_accel_set_watermark,
|
.hwfifo_set_watermark = bmc150_accel_set_watermark,
|
||||||
.hwfifo_flush_to_buffer = bmc150_accel_fifo_flush,
|
.hwfifo_flush_to_buffer = bmc150_accel_fifo_flush,
|
||||||
.driver_module = THIS_MODULE,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static const unsigned long bmc150_accel_scan_masks[] = {
|
static const unsigned long bmc150_accel_scan_masks[] = {
|
||||||
@@ -1200,7 +1198,6 @@ static int bmc150_accel_trigger_set_state(struct iio_trigger *trig,
|
|||||||
static const struct iio_trigger_ops bmc150_accel_trigger_ops = {
|
static const struct iio_trigger_ops bmc150_accel_trigger_ops = {
|
||||||
.set_trigger_state = bmc150_accel_trigger_set_state,
|
.set_trigger_state = bmc150_accel_trigger_set_state,
|
||||||
.try_reenable = bmc150_accel_trig_try_reen,
|
.try_reenable = bmc150_accel_trig_try_reen,
|
||||||
.owner = THIS_MODULE,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static int bmc150_accel_handle_roc_event(struct iio_dev *indio_dev)
|
static int bmc150_accel_handle_roc_event(struct iio_dev *indio_dev)
|
||||||
|
|||||||
@@ -0,0 +1,423 @@
|
|||||||
|
/*
|
||||||
|
* Driver for older Chrome OS EC accelerometer
|
||||||
|
*
|
||||||
|
* Copyright 2017 Google, Inc
|
||||||
|
*
|
||||||
|
* This software is licensed under the terms of the GNU General Public
|
||||||
|
* License version 2, as published by the Free Software Foundation, and
|
||||||
|
* may be copied, distributed, and modified under those terms.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* This driver uses the memory mapper cros-ec interface to communicate
|
||||||
|
* with the Chrome OS EC about accelerometer data.
|
||||||
|
* Accelerometer access is presented through iio sysfs.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <linux/delay.h>
|
||||||
|
#include <linux/device.h>
|
||||||
|
#include <linux/iio/buffer.h>
|
||||||
|
#include <linux/iio/iio.h>
|
||||||
|
#include <linux/iio/kfifo_buf.h>
|
||||||
|
#include <linux/iio/trigger_consumer.h>
|
||||||
|
#include <linux/iio/triggered_buffer.h>
|
||||||
|
#include <linux/kernel.h>
|
||||||
|
#include <linux/mfd/cros_ec.h>
|
||||||
|
#include <linux/mfd/cros_ec_commands.h>
|
||||||
|
#include <linux/module.h>
|
||||||
|
#include <linux/slab.h>
|
||||||
|
#include <linux/sysfs.h>
|
||||||
|
#include <linux/platform_device.h>
|
||||||
|
|
||||||
|
#define DRV_NAME "cros-ec-accel-legacy"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Sensor scale hard coded at 10 bits per g, computed as:
|
||||||
|
* g / (2^10 - 1) = 0.009586168; with g = 9.80665 m.s^-2
|
||||||
|
*/
|
||||||
|
#define ACCEL_LEGACY_NSCALE 9586168
|
||||||
|
|
||||||
|
/* Indices for EC sensor values. */
|
||||||
|
enum {
|
||||||
|
X,
|
||||||
|
Y,
|
||||||
|
Z,
|
||||||
|
MAX_AXIS,
|
||||||
|
};
|
||||||
|
|
||||||
|
/* State data for cros_ec_accel_legacy iio driver. */
|
||||||
|
struct cros_ec_accel_legacy_state {
|
||||||
|
struct cros_ec_device *ec;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Array holding data from a single capture. 2 bytes per channel
|
||||||
|
* for the 3 channels plus the timestamp which is always last and
|
||||||
|
* 8-bytes aligned.
|
||||||
|
*/
|
||||||
|
s16 capture_data[8];
|
||||||
|
s8 sign[MAX_AXIS];
|
||||||
|
u8 sensor_num;
|
||||||
|
};
|
||||||
|
|
||||||
|
static int ec_cmd_read_u8(struct cros_ec_device *ec, unsigned int offset,
|
||||||
|
u8 *dest)
|
||||||
|
{
|
||||||
|
return ec->cmd_readmem(ec, offset, 1, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int ec_cmd_read_u16(struct cros_ec_device *ec, unsigned int offset,
|
||||||
|
u16 *dest)
|
||||||
|
{
|
||||||
|
__le16 tmp;
|
||||||
|
int ret = ec->cmd_readmem(ec, offset, 2, &tmp);
|
||||||
|
|
||||||
|
*dest = le16_to_cpu(tmp);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* read_ec_until_not_busy() - Read from EC status byte until it reads not busy.
|
||||||
|
* @st: Pointer to state information for device.
|
||||||
|
*
|
||||||
|
* This function reads EC status until its busy bit gets cleared. It does not
|
||||||
|
* wait indefinitely and returns -EIO if the EC status is still busy after a
|
||||||
|
* few hundreds milliseconds.
|
||||||
|
*
|
||||||
|
* Return: 8-bit status if ok, -EIO on error
|
||||||
|
*/
|
||||||
|
static int read_ec_until_not_busy(struct cros_ec_accel_legacy_state *st)
|
||||||
|
{
|
||||||
|
struct cros_ec_device *ec = st->ec;
|
||||||
|
u8 status;
|
||||||
|
int attempts = 0;
|
||||||
|
|
||||||
|
ec_cmd_read_u8(ec, EC_MEMMAP_ACC_STATUS, &status);
|
||||||
|
while (status & EC_MEMMAP_ACC_STATUS_BUSY_BIT) {
|
||||||
|
/* Give up after enough attempts, return error. */
|
||||||
|
if (attempts++ >= 50)
|
||||||
|
return -EIO;
|
||||||
|
|
||||||
|
/* Small delay every so often. */
|
||||||
|
if (attempts % 5 == 0)
|
||||||
|
msleep(25);
|
||||||
|
|
||||||
|
ec_cmd_read_u8(ec, EC_MEMMAP_ACC_STATUS, &status);
|
||||||
|
}
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* read_ec_accel_data_unsafe() - Read acceleration data from EC shared memory.
|
||||||
|
* @st: Pointer to state information for device.
|
||||||
|
* @scan_mask: Bitmap of the sensor indices to scan.
|
||||||
|
* @data: Location to store data.
|
||||||
|
*
|
||||||
|
* This is the unsafe function for reading the EC data. It does not guarantee
|
||||||
|
* that the EC will not modify the data as it is being read in.
|
||||||
|
*/
|
||||||
|
static void read_ec_accel_data_unsafe(struct cros_ec_accel_legacy_state *st,
|
||||||
|
unsigned long scan_mask, s16 *data)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
int num_enabled = bitmap_weight(&scan_mask, MAX_AXIS);
|
||||||
|
|
||||||
|
/* Read all sensors enabled in scan_mask. Each value is 2 bytes. */
|
||||||
|
while (num_enabled--) {
|
||||||
|
i = find_next_bit(&scan_mask, MAX_AXIS, i);
|
||||||
|
ec_cmd_read_u16(st->ec,
|
||||||
|
EC_MEMMAP_ACC_DATA +
|
||||||
|
sizeof(s16) *
|
||||||
|
(1 + i + st->sensor_num * MAX_AXIS),
|
||||||
|
data);
|
||||||
|
*data *= st->sign[i];
|
||||||
|
i++;
|
||||||
|
data++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* read_ec_accel_data() - Read acceleration data from EC shared memory.
|
||||||
|
* @st: Pointer to state information for device.
|
||||||
|
* @scan_mask: Bitmap of the sensor indices to scan.
|
||||||
|
* @data: Location to store data.
|
||||||
|
*
|
||||||
|
* This is the safe function for reading the EC data. It guarantees that
|
||||||
|
* the data sampled was not modified by the EC while being read.
|
||||||
|
*
|
||||||
|
* Return: 0 if ok, -ve on error
|
||||||
|
*/
|
||||||
|
static int read_ec_accel_data(struct cros_ec_accel_legacy_state *st,
|
||||||
|
unsigned long scan_mask, s16 *data)
|
||||||
|
{
|
||||||
|
u8 samp_id = 0xff;
|
||||||
|
u8 status = 0;
|
||||||
|
int ret;
|
||||||
|
int attempts = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Continually read all data from EC until the status byte after
|
||||||
|
* all reads reflects that the EC is not busy and the sample id
|
||||||
|
* matches the sample id from before all reads. This guarantees
|
||||||
|
* that data read in was not modified by the EC while reading.
|
||||||
|
*/
|
||||||
|
while ((status & (EC_MEMMAP_ACC_STATUS_BUSY_BIT |
|
||||||
|
EC_MEMMAP_ACC_STATUS_SAMPLE_ID_MASK)) != samp_id) {
|
||||||
|
/* If we have tried to read too many times, return error. */
|
||||||
|
if (attempts++ >= 5)
|
||||||
|
return -EIO;
|
||||||
|
|
||||||
|
/* Read status byte until EC is not busy. */
|
||||||
|
ret = read_ec_until_not_busy(st);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
status = ret;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Store the current sample id so that we can compare to the
|
||||||
|
* sample id after reading the data.
|
||||||
|
*/
|
||||||
|
samp_id = status & EC_MEMMAP_ACC_STATUS_SAMPLE_ID_MASK;
|
||||||
|
|
||||||
|
/* Read all EC data, format it, and store it into data. */
|
||||||
|
read_ec_accel_data_unsafe(st, scan_mask, data);
|
||||||
|
|
||||||
|
/* Read status byte. */
|
||||||
|
ec_cmd_read_u8(st->ec, EC_MEMMAP_ACC_STATUS, &status);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int cros_ec_accel_legacy_read(struct iio_dev *indio_dev,
|
||||||
|
struct iio_chan_spec const *chan,
|
||||||
|
int *val, int *val2, long mask)
|
||||||
|
{
|
||||||
|
struct cros_ec_accel_legacy_state *st = iio_priv(indio_dev);
|
||||||
|
s16 data = 0;
|
||||||
|
int ret = IIO_VAL_INT;
|
||||||
|
|
||||||
|
switch (mask) {
|
||||||
|
case IIO_CHAN_INFO_RAW:
|
||||||
|
ret = read_ec_accel_data(st, (1 << chan->scan_index), &data);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
*val = data;
|
||||||
|
return IIO_VAL_INT;
|
||||||
|
case IIO_CHAN_INFO_SCALE:
|
||||||
|
*val = 0;
|
||||||
|
*val2 = ACCEL_LEGACY_NSCALE;
|
||||||
|
return IIO_VAL_INT_PLUS_NANO;
|
||||||
|
case IIO_CHAN_INFO_CALIBBIAS:
|
||||||
|
/* Calibration not supported. */
|
||||||
|
*val = 0;
|
||||||
|
return IIO_VAL_INT;
|
||||||
|
default:
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int cros_ec_accel_legacy_write(struct iio_dev *indio_dev,
|
||||||
|
struct iio_chan_spec const *chan,
|
||||||
|
int val, int val2, long mask)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Do nothing but don't return an error code to allow calibration
|
||||||
|
* script to work.
|
||||||
|
*/
|
||||||
|
if (mask == IIO_CHAN_INFO_CALIBBIAS)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct iio_info cros_ec_accel_legacy_info = {
|
||||||
|
.read_raw = &cros_ec_accel_legacy_read,
|
||||||
|
.write_raw = &cros_ec_accel_legacy_write,
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* cros_ec_accel_legacy_capture() - The trigger handler function
|
||||||
|
* @irq: The interrupt number.
|
||||||
|
* @p: Private data - always a pointer to the poll func.
|
||||||
|
*
|
||||||
|
* On a trigger event occurring, if the pollfunc is attached then this
|
||||||
|
* handler is called as a threaded interrupt (and hence may sleep). It
|
||||||
|
* is responsible for grabbing data from the device and pushing it into
|
||||||
|
* the associated buffer.
|
||||||
|
*
|
||||||
|
* Return: IRQ_HANDLED
|
||||||
|
*/
|
||||||
|
static irqreturn_t cros_ec_accel_legacy_capture(int irq, void *p)
|
||||||
|
{
|
||||||
|
struct iio_poll_func *pf = p;
|
||||||
|
struct iio_dev *indio_dev = pf->indio_dev;
|
||||||
|
struct cros_ec_accel_legacy_state *st = iio_priv(indio_dev);
|
||||||
|
|
||||||
|
/* Clear capture data. */
|
||||||
|
memset(st->capture_data, 0, sizeof(st->capture_data));
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Read data based on which channels are enabled in scan mask. Note
|
||||||
|
* that on a capture we are always reading the calibrated data.
|
||||||
|
*/
|
||||||
|
read_ec_accel_data(st, *indio_dev->active_scan_mask, st->capture_data);
|
||||||
|
|
||||||
|
iio_push_to_buffers_with_timestamp(indio_dev, (void *)st->capture_data,
|
||||||
|
iio_get_time_ns(indio_dev));
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Tell the core we are done with this trigger and ready for the
|
||||||
|
* next one.
|
||||||
|
*/
|
||||||
|
iio_trigger_notify_done(indio_dev->trig);
|
||||||
|
|
||||||
|
return IRQ_HANDLED;
|
||||||
|
}
|
||||||
|
|
||||||
|
static char *cros_ec_accel_legacy_loc_strings[] = {
|
||||||
|
[MOTIONSENSE_LOC_BASE] = "base",
|
||||||
|
[MOTIONSENSE_LOC_LID] = "lid",
|
||||||
|
[MOTIONSENSE_LOC_MAX] = "unknown",
|
||||||
|
};
|
||||||
|
|
||||||
|
static ssize_t cros_ec_accel_legacy_loc(struct iio_dev *indio_dev,
|
||||||
|
uintptr_t private,
|
||||||
|
const struct iio_chan_spec *chan,
|
||||||
|
char *buf)
|
||||||
|
{
|
||||||
|
struct cros_ec_accel_legacy_state *st = iio_priv(indio_dev);
|
||||||
|
|
||||||
|
return sprintf(buf, "%s\n",
|
||||||
|
cros_ec_accel_legacy_loc_strings[st->sensor_num +
|
||||||
|
MOTIONSENSE_LOC_BASE]);
|
||||||
|
}
|
||||||
|
|
||||||
|
static ssize_t cros_ec_accel_legacy_id(struct iio_dev *indio_dev,
|
||||||
|
uintptr_t private,
|
||||||
|
const struct iio_chan_spec *chan,
|
||||||
|
char *buf)
|
||||||
|
{
|
||||||
|
struct cros_ec_accel_legacy_state *st = iio_priv(indio_dev);
|
||||||
|
|
||||||
|
return sprintf(buf, "%d\n", st->sensor_num);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct iio_chan_spec_ext_info cros_ec_accel_legacy_ext_info[] = {
|
||||||
|
{
|
||||||
|
.name = "id",
|
||||||
|
.shared = IIO_SHARED_BY_ALL,
|
||||||
|
.read = cros_ec_accel_legacy_id,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.name = "location",
|
||||||
|
.shared = IIO_SHARED_BY_ALL,
|
||||||
|
.read = cros_ec_accel_legacy_loc,
|
||||||
|
},
|
||||||
|
{ }
|
||||||
|
};
|
||||||
|
|
||||||
|
#define CROS_EC_ACCEL_LEGACY_CHAN(_axis) \
|
||||||
|
{ \
|
||||||
|
.type = IIO_ACCEL, \
|
||||||
|
.channel2 = IIO_MOD_X + (_axis), \
|
||||||
|
.modified = 1, \
|
||||||
|
.info_mask_separate = \
|
||||||
|
BIT(IIO_CHAN_INFO_RAW) | \
|
||||||
|
BIT(IIO_CHAN_INFO_SCALE) | \
|
||||||
|
BIT(IIO_CHAN_INFO_CALIBBIAS), \
|
||||||
|
.info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SCALE), \
|
||||||
|
.ext_info = cros_ec_accel_legacy_ext_info, \
|
||||||
|
.scan_type = { \
|
||||||
|
.sign = 's', \
|
||||||
|
.realbits = 16, \
|
||||||
|
.storagebits = 16, \
|
||||||
|
}, \
|
||||||
|
} \
|
||||||
|
|
||||||
|
static struct iio_chan_spec ec_accel_channels[] = {
|
||||||
|
CROS_EC_ACCEL_LEGACY_CHAN(X),
|
||||||
|
CROS_EC_ACCEL_LEGACY_CHAN(Y),
|
||||||
|
CROS_EC_ACCEL_LEGACY_CHAN(Z),
|
||||||
|
IIO_CHAN_SOFT_TIMESTAMP(MAX_AXIS)
|
||||||
|
};
|
||||||
|
|
||||||
|
static int cros_ec_accel_legacy_probe(struct platform_device *pdev)
|
||||||
|
{
|
||||||
|
struct device *dev = &pdev->dev;
|
||||||
|
struct cros_ec_dev *ec = dev_get_drvdata(dev->parent);
|
||||||
|
struct cros_ec_sensor_platform *sensor_platform = dev_get_platdata(dev);
|
||||||
|
struct iio_dev *indio_dev;
|
||||||
|
struct cros_ec_accel_legacy_state *state;
|
||||||
|
int ret, i;
|
||||||
|
|
||||||
|
if (!ec || !ec->ec_dev) {
|
||||||
|
dev_warn(&pdev->dev, "No EC device found.\n");
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ec->ec_dev->cmd_readmem) {
|
||||||
|
dev_warn(&pdev->dev, "EC does not support direct reads.\n");
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*state));
|
||||||
|
if (!indio_dev)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
|
platform_set_drvdata(pdev, indio_dev);
|
||||||
|
state = iio_priv(indio_dev);
|
||||||
|
state->ec = ec->ec_dev;
|
||||||
|
state->sensor_num = sensor_platform->sensor_num;
|
||||||
|
|
||||||
|
indio_dev->dev.parent = dev;
|
||||||
|
indio_dev->name = pdev->name;
|
||||||
|
indio_dev->channels = ec_accel_channels;
|
||||||
|
/*
|
||||||
|
* Present the channel using HTML5 standard:
|
||||||
|
* need to invert X and Y and invert some lid axis.
|
||||||
|
*/
|
||||||
|
for (i = X ; i < MAX_AXIS; i++) {
|
||||||
|
switch (i) {
|
||||||
|
case X:
|
||||||
|
ec_accel_channels[X].scan_index = Y;
|
||||||
|
case Y:
|
||||||
|
ec_accel_channels[Y].scan_index = X;
|
||||||
|
case Z:
|
||||||
|
ec_accel_channels[Z].scan_index = Z;
|
||||||
|
}
|
||||||
|
if (state->sensor_num == MOTIONSENSE_LOC_LID && i != Y)
|
||||||
|
state->sign[i] = -1;
|
||||||
|
else
|
||||||
|
state->sign[i] = 1;
|
||||||
|
}
|
||||||
|
indio_dev->num_channels = ARRAY_SIZE(ec_accel_channels);
|
||||||
|
indio_dev->dev.parent = &pdev->dev;
|
||||||
|
indio_dev->info = &cros_ec_accel_legacy_info;
|
||||||
|
indio_dev->modes = INDIO_DIRECT_MODE;
|
||||||
|
|
||||||
|
ret = devm_iio_triggered_buffer_setup(dev, indio_dev, NULL,
|
||||||
|
cros_ec_accel_legacy_capture,
|
||||||
|
NULL);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
return devm_iio_device_register(dev, indio_dev);
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct platform_driver cros_ec_accel_platform_driver = {
|
||||||
|
.driver = {
|
||||||
|
.name = DRV_NAME,
|
||||||
|
},
|
||||||
|
.probe = cros_ec_accel_legacy_probe,
|
||||||
|
};
|
||||||
|
module_platform_driver(cros_ec_accel_platform_driver);
|
||||||
|
|
||||||
|
MODULE_DESCRIPTION("ChromeOS EC legacy accelerometer driver");
|
||||||
|
MODULE_AUTHOR("Gwendal Grignou <gwendal@chromium.org>");
|
||||||
|
MODULE_LICENSE("GPL");
|
||||||
|
MODULE_ALIAS("platform:" DRV_NAME);
|
||||||
@@ -88,7 +88,6 @@ static int da280_read_raw(struct iio_dev *indio_dev,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const struct iio_info da280_info = {
|
static const struct iio_info da280_info = {
|
||||||
.driver_module = THIS_MODULE,
|
|
||||||
.read_raw = da280_read_raw,
|
.read_raw = da280_read_raw,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -212,7 +212,6 @@ static int da311_read_raw(struct iio_dev *indio_dev,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const struct iio_info da311_info = {
|
static const struct iio_info da311_info = {
|
||||||
.driver_module = THIS_MODULE,
|
|
||||||
.read_raw = da311_read_raw,
|
.read_raw = da311_read_raw,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user