Third set of new functionality and cleanups for IIO in the 3.13 cycle.
Driver New Functionality * MXS - new interrupt driven touch screen support for i.MX23/28. Old polled implementation dropped. Driver Cleanups * Some spi_sync boilerplate dropped by using spi_sync_transfer * Some switching of drivers to the fractional type for scale reading. Moves the ugly calculation into one place. * Fix the documentation for *_voltage_scale which is never been correct or as implemented in any driver. * HID sensor hub and children : Open the sensor hub only when someone cares. * hmc5843 - various minor -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.21 (GNU/Linux) iQIcBAABAgAGBQJSUarRAAoJEFSFNJnE9BaIFw4P/j5zve2C/I2v/00mzH2W/zvo clpQ7JKH4wQMmBisua9pHyaE40sErNjoX2XVan7alTr901HiUoxSLmik7Jvh05C6 uwtIFdu0oRNrU2T/kHWYj/xMPPFV3OxATAO7Nn/HNvxXPbGbRUkF7P1+bker+IjF zKMZSZCUrfG2Sqs9+jtvpB6lKXNG6ndkNXPAyaqlRaJuYd3ea6EvowOVvGBAoNnM bU4Y+juHcWW3MieVeBiuIMU7GEyXXDQRjIt4x7gkRWTn2tY0eeBT8yh3V+18vsNQ sp24yCUVR5/3hDb86izGMYo+3bv2XycqGOdvBdPa2QfNIkgdVjd+MvRhqcol1W6o MaNurmmvzYOORuo1dWu9M44uQuo9HxO5tf9c1vemxxFkiHAMKTiG2JRphl+aofrB xxbI6g8XypPO8DlVmIGPScHVtD8qf1c3kJtTXO634zwhKnftL4h9ROox0xajBRlg JPDXtkceIomky76zPjKq+9g68QRyd/TqIQl9l6EdTsAdcN2kiXkt3PDOM8FWh0sn 6dhxIVQ6WQHRZ0oWk0iaMpTwyekeRZY6dHVsnOld/Lw4v6B3yxEWb3TFBMeJ21m8 m/vC8e/Hw1DFtxjqDi4Nlkb4krlbaj1cR/xhIt8w4fU9Hdcj+3rdTZiDNBFn19EI AprCOdGOYunw8CrhRnXs =g8ZE -----END PGP SIGNATURE----- Merge tag 'iio-for-3.13c' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next Jonathan writes: Third set of new functionality and cleanups for IIO in the 3.13 cycle. Driver New Functionality * MXS - new interrupt driven touch screen support for i.MX23/28. Old polled implementation dropped. Driver Cleanups * Some spi_sync boilerplate dropped by using spi_sync_transfer * Some switching of drivers to the fractional type for scale reading. Moves the ugly calculation into one place. * Fix the documentation for *_voltage_scale which is never been correct or as implemented in any driver. * HID sensor hub and children : Open the sensor hub only when someone cares. * hmc5843 - various minor
This commit is contained in:
commit
eb3e6ae960
@ -79,7 +79,7 @@ Description:
|
||||
correspond to externally available input one of the named
|
||||
versions may be used. The number must always be specified and
|
||||
unique to allow association with event codes. Units after
|
||||
application of scale and offset are microvolts.
|
||||
application of scale and offset are millivolts.
|
||||
|
||||
What: /sys/bus/iio/devices/iio:deviceX/in_voltageY-voltageZ_raw
|
||||
KernelVersion: 2.6.35
|
||||
@ -90,7 +90,7 @@ Description:
|
||||
physically equivalent inputs when non differential readings are
|
||||
separately available. In differential only parts, then all that
|
||||
is required is a consistent labeling. Units after application
|
||||
of scale and offset are microvolts.
|
||||
of scale and offset are millivolts.
|
||||
|
||||
What: /sys/bus/iio/devices/iio:deviceX/in_capacitanceY_raw
|
||||
KernelVersion: 3.2
|
||||
|
@ -1,7 +1,8 @@
|
||||
* Freescale i.MX28 LRADC device driver
|
||||
|
||||
Required properties:
|
||||
- compatible: Should be "fsl,imx28-lradc"
|
||||
- compatible: Should be "fsl,imx23-lradc" for i.MX23 SoC and "fsl,imx28-lradc"
|
||||
for i.MX28 SoC
|
||||
- reg: Address and length of the register set for the device
|
||||
- interrupts: Should contain the LRADC interrupts
|
||||
|
||||
@ -9,13 +10,38 @@ Optional properties:
|
||||
- fsl,lradc-touchscreen-wires: Number of wires used to connect the touchscreen
|
||||
to LRADC. Valid value is either 4 or 5. If this
|
||||
property is not present, then the touchscreen is
|
||||
disabled.
|
||||
disabled. 5 wires is valid for i.MX28 SoC only.
|
||||
- fsl,ave-ctrl: number of samples per direction to calculate an average value.
|
||||
Allowed value is 1 ... 31, default is 4
|
||||
- fsl,ave-delay: delay between consecutive samples. Allowed value is
|
||||
1 ... 2047. It is used if 'fsl,ave-ctrl' > 1, counts at
|
||||
2 kHz and its default is 2 (= 1 ms)
|
||||
- fsl,settling: delay between plate switch to next sample. Allowed value is
|
||||
1 ... 2047. It counts at 2 kHz and its default is
|
||||
10 (= 5 ms)
|
||||
|
||||
Examples:
|
||||
Example for i.MX23 SoC:
|
||||
|
||||
lradc@80050000 {
|
||||
compatible = "fsl,imx23-lradc";
|
||||
reg = <0x80050000 0x2000>;
|
||||
interrupts = <36 37 38 39 40 41 42 43 44>;
|
||||
status = "okay";
|
||||
fsl,lradc-touchscreen-wires = <4>;
|
||||
fsl,ave-ctrl = <4>;
|
||||
fsl,ave-delay = <2>;
|
||||
fsl,settling = <10>;
|
||||
};
|
||||
|
||||
Example for i.MX28 SoC:
|
||||
|
||||
lradc@80050000 {
|
||||
compatible = "fsl,imx28-lradc";
|
||||
reg = <0x80050000 0x2000>;
|
||||
interrupts = <10 14 15 16 17 18 19
|
||||
20 21 22 23 24 25>;
|
||||
interrupts = <10 14 15 16 17 18 19 20 21 22 23 24 25>;
|
||||
status = "okay";
|
||||
fsl,lradc-touchscreen-wires = <5>;
|
||||
fsl,ave-ctrl = <4>;
|
||||
fsl,ave-delay = <2>;
|
||||
fsl,settling = <10>;
|
||||
};
|
||||
|
@ -430,6 +430,7 @@
|
||||
reg = <0x80050000 0x2000>;
|
||||
interrupts = <36 37 38 39 40 41 42 43 44>;
|
||||
status = "disabled";
|
||||
clocks = <&clks 26>;
|
||||
};
|
||||
|
||||
spdif@80054000 {
|
||||
|
@ -183,6 +183,10 @@
|
||||
|
||||
lradc@80050000 {
|
||||
status = "okay";
|
||||
fsl,lradc-touchscreen-wires = <4>;
|
||||
fsl,ave-ctrl = <4>;
|
||||
fsl,ave-delay = <2>;
|
||||
fsl,settling = <10>;
|
||||
};
|
||||
|
||||
i2c0: i2c@80058000 {
|
||||
|
@ -902,6 +902,7 @@
|
||||
interrupts = <10 14 15 16 17 18 19
|
||||
20 21 22 23 24 25>;
|
||||
status = "disabled";
|
||||
clocks = <&clks 41>;
|
||||
};
|
||||
|
||||
spdif: spdif@80054000 {
|
||||
|
@ -465,6 +465,39 @@ static int sensor_hub_raw_event(struct hid_device *hdev,
|
||||
return 1;
|
||||
}
|
||||
|
||||
int sensor_hub_device_open(struct hid_sensor_hub_device *hsdev)
|
||||
{
|
||||
int ret = 0;
|
||||
struct sensor_hub_data *data = hid_get_drvdata(hsdev->hdev);
|
||||
|
||||
mutex_lock(&data->mutex);
|
||||
if (!hsdev->ref_cnt) {
|
||||
ret = hid_hw_open(hsdev->hdev);
|
||||
if (ret) {
|
||||
hid_err(hsdev->hdev, "failed to open hid device\n");
|
||||
mutex_unlock(&data->mutex);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
hsdev->ref_cnt++;
|
||||
mutex_unlock(&data->mutex);
|
||||
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(sensor_hub_device_open);
|
||||
|
||||
void sensor_hub_device_close(struct hid_sensor_hub_device *hsdev)
|
||||
{
|
||||
struct sensor_hub_data *data = hid_get_drvdata(hsdev->hdev);
|
||||
|
||||
mutex_lock(&data->mutex);
|
||||
hsdev->ref_cnt--;
|
||||
if (!hsdev->ref_cnt)
|
||||
hid_hw_close(hsdev->hdev);
|
||||
mutex_unlock(&data->mutex);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(sensor_hub_device_close);
|
||||
|
||||
static int sensor_hub_probe(struct hid_device *hdev,
|
||||
const struct hid_device_id *id)
|
||||
{
|
||||
@ -506,12 +539,6 @@ static int sensor_hub_probe(struct hid_device *hdev,
|
||||
hid_err(hdev, "hw start failed\n");
|
||||
return ret;
|
||||
}
|
||||
ret = hid_hw_open(hdev);
|
||||
if (ret) {
|
||||
hid_err(hdev, "failed to open input interrupt pipe\n");
|
||||
goto err_stop_hw;
|
||||
}
|
||||
|
||||
INIT_LIST_HEAD(&sd->dyn_callback_list);
|
||||
sd->hid_sensor_client_cnt = 0;
|
||||
report_enum = &hdev->report_enum[HID_INPUT_REPORT];
|
||||
@ -520,7 +547,7 @@ static int sensor_hub_probe(struct hid_device *hdev,
|
||||
if (dev_cnt > HID_MAX_PHY_DEVICES) {
|
||||
hid_err(hdev, "Invalid Physical device count\n");
|
||||
ret = -EINVAL;
|
||||
goto err_close;
|
||||
goto err_stop_hw;
|
||||
}
|
||||
sd->hid_sensor_hub_client_devs = kzalloc(dev_cnt *
|
||||
sizeof(struct mfd_cell),
|
||||
@ -528,7 +555,7 @@ static int sensor_hub_probe(struct hid_device *hdev,
|
||||
if (sd->hid_sensor_hub_client_devs == NULL) {
|
||||
hid_err(hdev, "Failed to allocate memory for mfd cells\n");
|
||||
ret = -ENOMEM;
|
||||
goto err_close;
|
||||
goto err_stop_hw;
|
||||
}
|
||||
list_for_each_entry(report, &report_enum->report_list, list) {
|
||||
hid_dbg(hdev, "Report id:%x\n", report->id);
|
||||
@ -565,8 +592,6 @@ err_free_names:
|
||||
for (i = 0; i < sd->hid_sensor_client_cnt ; ++i)
|
||||
kfree(sd->hid_sensor_hub_client_devs[i].name);
|
||||
kfree(sd->hid_sensor_hub_client_devs);
|
||||
err_close:
|
||||
hid_hw_close(hdev);
|
||||
err_stop_hw:
|
||||
hid_hw_stop(hdev);
|
||||
|
||||
|
@ -27,7 +27,7 @@
|
||||
struct ad7266_state {
|
||||
struct spi_device *spi;
|
||||
struct regulator *reg;
|
||||
unsigned long vref_uv;
|
||||
unsigned long vref_mv;
|
||||
|
||||
struct spi_transfer single_xfer[3];
|
||||
struct spi_message single_msg;
|
||||
@ -156,7 +156,7 @@ static int ad7266_read_raw(struct iio_dev *indio_dev,
|
||||
struct iio_chan_spec const *chan, int *val, int *val2, long m)
|
||||
{
|
||||
struct ad7266_state *st = iio_priv(indio_dev);
|
||||
unsigned long scale_uv;
|
||||
unsigned long scale_mv;
|
||||
int ret;
|
||||
|
||||
switch (m) {
|
||||
@ -174,16 +174,15 @@ static int ad7266_read_raw(struct iio_dev *indio_dev,
|
||||
|
||||
return IIO_VAL_INT;
|
||||
case IIO_CHAN_INFO_SCALE:
|
||||
scale_uv = (st->vref_uv * 100);
|
||||
scale_mv = st->vref_mv;
|
||||
if (st->mode == AD7266_MODE_DIFF)
|
||||
scale_uv *= 2;
|
||||
scale_mv *= 2;
|
||||
if (st->range == AD7266_RANGE_2VREF)
|
||||
scale_uv *= 2;
|
||||
scale_mv *= 2;
|
||||
|
||||
scale_uv >>= chan->scan_type.realbits;
|
||||
*val = scale_uv / 100000;
|
||||
*val2 = (scale_uv % 100000) * 10;
|
||||
return IIO_VAL_INT_PLUS_MICRO;
|
||||
*val = scale_mv;
|
||||
*val2 = chan->scan_type.realbits;
|
||||
return IIO_VAL_FRACTIONAL_LOG2;
|
||||
case IIO_CHAN_INFO_OFFSET:
|
||||
if (st->range == AD7266_RANGE_2VREF &&
|
||||
st->mode != AD7266_MODE_DIFF)
|
||||
@ -414,10 +413,10 @@ static int ad7266_probe(struct spi_device *spi)
|
||||
if (ret < 0)
|
||||
goto error_disable_reg;
|
||||
|
||||
st->vref_uv = ret;
|
||||
st->vref_mv = ret / 1000;
|
||||
} else {
|
||||
/* Use internal reference */
|
||||
st->vref_uv = 2500000;
|
||||
st->vref_mv = 2500;
|
||||
}
|
||||
|
||||
if (pdata) {
|
||||
|
@ -127,10 +127,9 @@ static int ad7476_read_raw(struct iio_dev *indio_dev,
|
||||
} else {
|
||||
scale_uv = st->chip_info->int_vref_uv;
|
||||
}
|
||||
scale_uv >>= chan->scan_type.realbits;
|
||||
*val = scale_uv / 1000;
|
||||
*val2 = (scale_uv % 1000) * 1000;
|
||||
return IIO_VAL_INT_PLUS_MICRO;
|
||||
*val = scale_uv / 1000;
|
||||
*val2 = chan->scan_type.realbits;
|
||||
return IIO_VAL_FRACTIONAL_LOG2;
|
||||
}
|
||||
return -EINVAL;
|
||||
}
|
||||
|
@ -202,7 +202,6 @@ static int ad7791_read_raw(struct iio_dev *indio_dev,
|
||||
{
|
||||
struct ad7791_state *st = iio_priv(indio_dev);
|
||||
bool unipolar = !!(st->mode & AD7791_MODE_UNIPOLAR);
|
||||
unsigned long long scale_pv;
|
||||
|
||||
switch (info) {
|
||||
case IIO_CHAN_INFO_RAW:
|
||||
@ -220,23 +219,26 @@ static int ad7791_read_raw(struct iio_dev *indio_dev,
|
||||
case IIO_CHAN_INFO_SCALE:
|
||||
/* The monitor channel uses an internal reference. */
|
||||
if (chan->address == AD7791_CH_AVDD_MONITOR) {
|
||||
scale_pv = 5850000000000ULL;
|
||||
/*
|
||||
* The signal is attenuated by a factor of 5 and
|
||||
* compared against a 1.17V internal reference.
|
||||
*/
|
||||
*val = 1170 * 5;
|
||||
} else {
|
||||
int voltage_uv;
|
||||
|
||||
voltage_uv = regulator_get_voltage(st->reg);
|
||||
if (voltage_uv < 0)
|
||||
return voltage_uv;
|
||||
scale_pv = (unsigned long long)voltage_uv * 1000000;
|
||||
|
||||
*val = voltage_uv / 1000;
|
||||
}
|
||||
if (unipolar)
|
||||
scale_pv >>= chan->scan_type.realbits;
|
||||
*val2 = chan->scan_type.realbits;
|
||||
else
|
||||
scale_pv >>= chan->scan_type.realbits - 1;
|
||||
*val2 = do_div(scale_pv, 1000000000);
|
||||
*val = scale_pv;
|
||||
*val2 = chan->scan_type.realbits - 1;
|
||||
|
||||
return IIO_VAL_INT_PLUS_NANO;
|
||||
return IIO_VAL_FRACTIONAL_LOG2;
|
||||
}
|
||||
|
||||
return -EINVAL;
|
||||
|
@ -366,9 +366,9 @@ static int at91_adc_read_raw(struct iio_dev *idev,
|
||||
return IIO_VAL_INT;
|
||||
|
||||
case IIO_CHAN_INFO_SCALE:
|
||||
*val = (st->vref_mv * 1000) >> chan->scan_type.realbits;
|
||||
*val2 = 0;
|
||||
return IIO_VAL_INT_PLUS_MICRO;
|
||||
*val = st->vref_mv;
|
||||
*val2 = chan->scan_type.realbits;
|
||||
return IIO_VAL_FRACTIONAL_LOG2;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -397,7 +397,6 @@ static int max1363_read_raw(struct iio_dev *indio_dev,
|
||||
{
|
||||
struct max1363_state *st = iio_priv(indio_dev);
|
||||
int ret;
|
||||
unsigned long scale_uv;
|
||||
|
||||
switch (m) {
|
||||
case IIO_CHAN_INFO_RAW:
|
||||
@ -406,10 +405,9 @@ static int max1363_read_raw(struct iio_dev *indio_dev,
|
||||
return ret;
|
||||
return IIO_VAL_INT;
|
||||
case IIO_CHAN_INFO_SCALE:
|
||||
scale_uv = st->vref_uv >> st->chip_info->bits;
|
||||
*val = scale_uv / 1000;
|
||||
*val2 = (scale_uv % 1000) * 1000;
|
||||
return IIO_VAL_INT_PLUS_MICRO;
|
||||
*val = st->vref_uv / 1000;
|
||||
*val2 = st->chip_info->bits;
|
||||
return IIO_VAL_FRACTIONAL_LOG2;
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
|
@ -34,6 +34,12 @@ static int hid_sensor_data_rdy_trigger_set_state(struct iio_trigger *trig,
|
||||
struct hid_sensor_common *st = iio_trigger_get_drvdata(trig);
|
||||
int state_val;
|
||||
|
||||
if (state) {
|
||||
if (sensor_hub_device_open(st->hsdev))
|
||||
return -EIO;
|
||||
} else
|
||||
sensor_hub_device_close(st->hsdev);
|
||||
|
||||
state_val = state ? 1 : 0;
|
||||
if (IS_ENABLED(CONFIG_HID_SENSOR_ENUM_BASE_QUIRKS))
|
||||
++state_val;
|
||||
|
@ -239,10 +239,9 @@ static int ad5064_read_raw(struct iio_dev *indio_dev,
|
||||
if (scale_uv < 0)
|
||||
return scale_uv;
|
||||
|
||||
scale_uv = (scale_uv * 100) >> chan->scan_type.realbits;
|
||||
*val = scale_uv / 100000;
|
||||
*val2 = (scale_uv % 100000) * 10;
|
||||
return IIO_VAL_INT_PLUS_MICRO;
|
||||
*val = scale_uv / 1000;
|
||||
*val2 = chan->scan_type.realbits;
|
||||
return IIO_VAL_FRACTIONAL_LOG2;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -379,15 +379,14 @@ static int ad5360_read_raw(struct iio_dev *indio_dev,
|
||||
*val = ret >> chan->scan_type.shift;
|
||||
return IIO_VAL_INT;
|
||||
case IIO_CHAN_INFO_SCALE:
|
||||
/* vout = 4 * vref * dac_code */
|
||||
scale_uv = ad5360_get_channel_vref(st, chan->channel) * 4 * 100;
|
||||
scale_uv = ad5360_get_channel_vref(st, chan->channel);
|
||||
if (scale_uv < 0)
|
||||
return scale_uv;
|
||||
|
||||
scale_uv >>= (chan->scan_type.realbits);
|
||||
*val = scale_uv / 100000;
|
||||
*val2 = (scale_uv % 100000) * 10;
|
||||
return IIO_VAL_INT_PLUS_MICRO;
|
||||
/* vout = 4 * vref * dac_code */
|
||||
*val = scale_uv * 4 / 1000;
|
||||
*val2 = chan->scan_type.realbits;
|
||||
return IIO_VAL_FRACTIONAL_LOG2;
|
||||
case IIO_CHAN_INFO_CALIBBIAS:
|
||||
ret = ad5360_read(indio_dev, AD5360_READBACK_OFFSET,
|
||||
chan->address);
|
||||
|
@ -204,7 +204,6 @@ static int ad5380_read_raw(struct iio_dev *indio_dev,
|
||||
struct iio_chan_spec const *chan, int *val, int *val2, long info)
|
||||
{
|
||||
struct ad5380_state *st = iio_priv(indio_dev);
|
||||
unsigned long scale_uv;
|
||||
int ret;
|
||||
|
||||
switch (info) {
|
||||
@ -225,10 +224,9 @@ static int ad5380_read_raw(struct iio_dev *indio_dev,
|
||||
val -= (1 << chan->scan_type.realbits) / 2;
|
||||
return IIO_VAL_INT;
|
||||
case IIO_CHAN_INFO_SCALE:
|
||||
scale_uv = ((2 * st->vref) >> chan->scan_type.realbits) * 100;
|
||||
*val = scale_uv / 100000;
|
||||
*val2 = (scale_uv % 100000) * 10;
|
||||
return IIO_VAL_INT_PLUS_MICRO;
|
||||
*val = 2 * st->vref;
|
||||
*val2 = chan->scan_type.realbits;
|
||||
return IIO_VAL_FRACTIONAL_LOG2;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -271,72 +269,72 @@ static const struct ad5380_chip_info ad5380_chip_info_tbl[] = {
|
||||
[ID_AD5380_3] = {
|
||||
.channel_template = AD5380_CHANNEL(14),
|
||||
.num_channels = 40,
|
||||
.int_vref = 1250000,
|
||||
.int_vref = 1250,
|
||||
},
|
||||
[ID_AD5380_5] = {
|
||||
.channel_template = AD5380_CHANNEL(14),
|
||||
.num_channels = 40,
|
||||
.int_vref = 2500000,
|
||||
.int_vref = 2500,
|
||||
},
|
||||
[ID_AD5381_3] = {
|
||||
.channel_template = AD5380_CHANNEL(12),
|
||||
.num_channels = 16,
|
||||
.int_vref = 1250000,
|
||||
.int_vref = 1250,
|
||||
},
|
||||
[ID_AD5381_5] = {
|
||||
.channel_template = AD5380_CHANNEL(12),
|
||||
.num_channels = 16,
|
||||
.int_vref = 2500000,
|
||||
.int_vref = 2500,
|
||||
},
|
||||
[ID_AD5382_3] = {
|
||||
.channel_template = AD5380_CHANNEL(14),
|
||||
.num_channels = 32,
|
||||
.int_vref = 1250000,
|
||||
.int_vref = 1250,
|
||||
},
|
||||
[ID_AD5382_5] = {
|
||||
.channel_template = AD5380_CHANNEL(14),
|
||||
.num_channels = 32,
|
||||
.int_vref = 2500000,
|
||||
.int_vref = 2500,
|
||||
},
|
||||
[ID_AD5383_3] = {
|
||||
.channel_template = AD5380_CHANNEL(12),
|
||||
.num_channels = 32,
|
||||
.int_vref = 1250000,
|
||||
.int_vref = 1250,
|
||||
},
|
||||
[ID_AD5383_5] = {
|
||||
.channel_template = AD5380_CHANNEL(12),
|
||||
.num_channels = 32,
|
||||
.int_vref = 2500000,
|
||||
.int_vref = 2500,
|
||||
},
|
||||
[ID_AD5390_3] = {
|
||||
.channel_template = AD5380_CHANNEL(14),
|
||||
.num_channels = 16,
|
||||
.int_vref = 1250000,
|
||||
.int_vref = 1250,
|
||||
},
|
||||
[ID_AD5390_5] = {
|
||||
.channel_template = AD5380_CHANNEL(14),
|
||||
.num_channels = 16,
|
||||
.int_vref = 2500000,
|
||||
.int_vref = 2500,
|
||||
},
|
||||
[ID_AD5391_3] = {
|
||||
.channel_template = AD5380_CHANNEL(12),
|
||||
.num_channels = 16,
|
||||
.int_vref = 1250000,
|
||||
.int_vref = 1250,
|
||||
},
|
||||
[ID_AD5391_5] = {
|
||||
.channel_template = AD5380_CHANNEL(12),
|
||||
.num_channels = 16,
|
||||
.int_vref = 2500000,
|
||||
.int_vref = 2500,
|
||||
},
|
||||
[ID_AD5392_3] = {
|
||||
.channel_template = AD5380_CHANNEL(14),
|
||||
.num_channels = 8,
|
||||
.int_vref = 1250000,
|
||||
.int_vref = 1250,
|
||||
},
|
||||
[ID_AD5392_5] = {
|
||||
.channel_template = AD5380_CHANNEL(14),
|
||||
.num_channels = 8,
|
||||
.int_vref = 2500000,
|
||||
.int_vref = 2500,
|
||||
},
|
||||
};
|
||||
|
||||
@ -395,7 +393,7 @@ static int ad5380_probe(struct device *dev, struct regmap *regmap,
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (st->chip_info->int_vref == 2500000)
|
||||
if (st->chip_info->int_vref == 2500)
|
||||
ctrl |= AD5380_CTRL_INT_VREF_2V5;
|
||||
|
||||
st->vref_reg = devm_regulator_get(dev, "vref");
|
||||
@ -411,7 +409,7 @@ static int ad5380_probe(struct device *dev, struct regmap *regmap,
|
||||
if (ret < 0)
|
||||
goto error_disable_reg;
|
||||
|
||||
st->vref = ret;
|
||||
st->vref = ret / 1000;
|
||||
} else {
|
||||
st->vref = st->chip_info->int_vref;
|
||||
ctrl |= AD5380_CTRL_INT_VREF_EN;
|
||||
|
@ -281,18 +281,11 @@ static inline unsigned int ad5421_get_offset(struct ad5421_state *st)
|
||||
return (min * (1 << 16)) / (max - min);
|
||||
}
|
||||
|
||||
static inline unsigned int ad5421_get_scale(struct ad5421_state *st)
|
||||
{
|
||||
unsigned int min, max;
|
||||
|
||||
ad5421_get_current_min_max(st, &min, &max);
|
||||
return ((max - min) * 1000) / (1 << 16);
|
||||
}
|
||||
|
||||
static int ad5421_read_raw(struct iio_dev *indio_dev,
|
||||
struct iio_chan_spec const *chan, int *val, int *val2, long m)
|
||||
{
|
||||
struct ad5421_state *st = iio_priv(indio_dev);
|
||||
unsigned int min, max;
|
||||
int ret;
|
||||
|
||||
if (chan->type != IIO_CURRENT)
|
||||
@ -306,9 +299,10 @@ static int ad5421_read_raw(struct iio_dev *indio_dev,
|
||||
*val = ret;
|
||||
return IIO_VAL_INT;
|
||||
case IIO_CHAN_INFO_SCALE:
|
||||
*val = 0;
|
||||
*val2 = ad5421_get_scale(st);
|
||||
return IIO_VAL_INT_PLUS_MICRO;
|
||||
ad5421_get_current_min_max(st, &min, &max);
|
||||
*val = max - min;
|
||||
*val2 = (1 << 16) * 1000;
|
||||
return IIO_VAL_FRACTIONAL;
|
||||
case IIO_CHAN_INFO_OFFSET:
|
||||
*val = ad5421_get_offset(st);
|
||||
return IIO_VAL_INT;
|
||||
|
@ -163,18 +163,15 @@ static int ad5446_read_raw(struct iio_dev *indio_dev,
|
||||
long m)
|
||||
{
|
||||
struct ad5446_state *st = iio_priv(indio_dev);
|
||||
unsigned long scale_uv;
|
||||
|
||||
switch (m) {
|
||||
case IIO_CHAN_INFO_RAW:
|
||||
*val = st->cached_val;
|
||||
return IIO_VAL_INT;
|
||||
case IIO_CHAN_INFO_SCALE:
|
||||
scale_uv = (st->vref_mv * 1000) >> chan->scan_type.realbits;
|
||||
*val = scale_uv / 1000;
|
||||
*val2 = (scale_uv % 1000) * 1000;
|
||||
return IIO_VAL_INT_PLUS_MICRO;
|
||||
|
||||
*val = st->vref_mv;
|
||||
*val2 = chan->scan_type.realbits;
|
||||
return IIO_VAL_FRACTIONAL_LOG2;
|
||||
}
|
||||
return -EINVAL;
|
||||
}
|
||||
|
@ -101,7 +101,6 @@ static int ad5449_read(struct iio_dev *indio_dev, unsigned int addr,
|
||||
{
|
||||
struct ad5449 *st = iio_priv(indio_dev);
|
||||
int ret;
|
||||
struct spi_message msg;
|
||||
struct spi_transfer t[] = {
|
||||
{
|
||||
.tx_buf = &st->data[0],
|
||||
@ -114,15 +113,11 @@ static int ad5449_read(struct iio_dev *indio_dev, unsigned int addr,
|
||||
},
|
||||
};
|
||||
|
||||
spi_message_init(&msg);
|
||||
spi_message_add_tail(&t[0], &msg);
|
||||
spi_message_add_tail(&t[1], &msg);
|
||||
|
||||
mutex_lock(&indio_dev->mlock);
|
||||
st->data[0] = cpu_to_be16(addr << 12);
|
||||
st->data[1] = cpu_to_be16(AD5449_CMD_NOOP);
|
||||
|
||||
ret = spi_sync(st->spi, &msg);
|
||||
ret = spi_sync_transfer(st->spi, t, ARRAY_SIZE(t));
|
||||
if (ret < 0)
|
||||
goto out_unlock;
|
||||
|
||||
|
@ -100,7 +100,6 @@ static int ad5504_read_raw(struct iio_dev *indio_dev,
|
||||
long m)
|
||||
{
|
||||
struct ad5504_state *st = iio_priv(indio_dev);
|
||||
unsigned long scale_uv;
|
||||
int ret;
|
||||
|
||||
switch (m) {
|
||||
@ -113,11 +112,9 @@ static int ad5504_read_raw(struct iio_dev *indio_dev,
|
||||
|
||||
return IIO_VAL_INT;
|
||||
case IIO_CHAN_INFO_SCALE:
|
||||
scale_uv = (st->vref_mv * 1000) >> chan->scan_type.realbits;
|
||||
*val = scale_uv / 1000;
|
||||
*val2 = (scale_uv % 1000) * 1000;
|
||||
return IIO_VAL_INT_PLUS_MICRO;
|
||||
|
||||
*val = st->vref_mv;
|
||||
*val2 = chan->scan_type.realbits;
|
||||
return IIO_VAL_FRACTIONAL_LOG2;
|
||||
}
|
||||
return -EINVAL;
|
||||
}
|
||||
|
@ -50,15 +50,12 @@ static int ad5624r_read_raw(struct iio_dev *indio_dev,
|
||||
long m)
|
||||
{
|
||||
struct ad5624r_state *st = iio_priv(indio_dev);
|
||||
unsigned long scale_uv;
|
||||
|
||||
switch (m) {
|
||||
case IIO_CHAN_INFO_SCALE:
|
||||
scale_uv = (st->vref_mv * 1000) >> chan->scan_type.realbits;
|
||||
*val = scale_uv / 1000;
|
||||
*val2 = (scale_uv % 1000) * 1000;
|
||||
return IIO_VAL_INT_PLUS_MICRO;
|
||||
|
||||
*val = st->vref_mv;
|
||||
*val2 = chan->scan_type.realbits;
|
||||
return IIO_VAL_FRACTIONAL_LOG2;
|
||||
}
|
||||
return -EINVAL;
|
||||
}
|
||||
|
@ -201,7 +201,6 @@ static int ad5686_read_raw(struct iio_dev *indio_dev,
|
||||
long m)
|
||||
{
|
||||
struct ad5686_state *st = iio_priv(indio_dev);
|
||||
unsigned long scale_uv;
|
||||
int ret;
|
||||
|
||||
switch (m) {
|
||||
@ -214,12 +213,9 @@ static int ad5686_read_raw(struct iio_dev *indio_dev,
|
||||
*val = ret;
|
||||
return IIO_VAL_INT;
|
||||
case IIO_CHAN_INFO_SCALE:
|
||||
scale_uv = (st->vref_mv * 100000)
|
||||
>> (chan->scan_type.realbits);
|
||||
*val = scale_uv / 100000;
|
||||
*val2 = (scale_uv % 100000) * 10;
|
||||
return IIO_VAL_INT_PLUS_MICRO;
|
||||
|
||||
*val = st->vref_mv;
|
||||
*val2 = chan->scan_type.realbits;
|
||||
return IIO_VAL_FRACTIONAL_LOG2;
|
||||
}
|
||||
return -EINVAL;
|
||||
}
|
||||
|
@ -253,15 +253,6 @@ static inline int ad5755_get_offset(struct ad5755_state *st,
|
||||
return (min * (1 << chan->scan_type.realbits)) / (max - min);
|
||||
}
|
||||
|
||||
static inline int ad5755_get_scale(struct ad5755_state *st,
|
||||
struct iio_chan_spec const *chan)
|
||||
{
|
||||
int min, max;
|
||||
|
||||
ad5755_get_min_max(st, chan, &min, &max);
|
||||
return ((max - min) * 1000000000ULL) >> chan->scan_type.realbits;
|
||||
}
|
||||
|
||||
static int ad5755_chan_reg_info(struct ad5755_state *st,
|
||||
struct iio_chan_spec const *chan, long info, bool write,
|
||||
unsigned int *reg, unsigned int *shift, unsigned int *offset)
|
||||
@ -303,13 +294,15 @@ static int ad5755_read_raw(struct iio_dev *indio_dev,
|
||||
{
|
||||
struct ad5755_state *st = iio_priv(indio_dev);
|
||||
unsigned int reg, shift, offset;
|
||||
int min, max;
|
||||
int ret;
|
||||
|
||||
switch (info) {
|
||||
case IIO_CHAN_INFO_SCALE:
|
||||
*val = 0;
|
||||
*val2 = ad5755_get_scale(st, chan);
|
||||
return IIO_VAL_INT_PLUS_NANO;
|
||||
ad5755_get_min_max(st, chan, &min, &max);
|
||||
*val = max - min;
|
||||
*val2 = chan->scan_type.realbits;
|
||||
return IIO_VAL_FRACTIONAL_LOG2;
|
||||
case IIO_CHAN_INFO_OFFSET:
|
||||
*val = ad5755_get_offset(st, chan);
|
||||
return IIO_VAL_INT;
|
||||
|
@ -217,7 +217,6 @@ static int ad5764_read_raw(struct iio_dev *indio_dev,
|
||||
struct iio_chan_spec const *chan, int *val, int *val2, long info)
|
||||
{
|
||||
struct ad5764_state *st = iio_priv(indio_dev);
|
||||
unsigned long scale_uv;
|
||||
unsigned int reg;
|
||||
int vref;
|
||||
int ret;
|
||||
@ -245,15 +244,14 @@ static int ad5764_read_raw(struct iio_dev *indio_dev,
|
||||
*val = sign_extend32(*val, 5);
|
||||
return IIO_VAL_INT;
|
||||
case IIO_CHAN_INFO_SCALE:
|
||||
/* vout = 4 * vref + ((dac_code / 65535) - 0.5) */
|
||||
/* vout = 4 * vref + ((dac_code / 65536) - 0.5) */
|
||||
vref = ad5764_get_channel_vref(st, chan->channel);
|
||||
if (vref < 0)
|
||||
return vref;
|
||||
|
||||
scale_uv = (vref * 4 * 100) >> chan->scan_type.realbits;
|
||||
*val = scale_uv / 100000;
|
||||
*val2 = (scale_uv % 100000) * 10;
|
||||
return IIO_VAL_INT_PLUS_MICRO;
|
||||
*val = vref * 4 / 1000;
|
||||
*val2 = chan->scan_type.realbits;
|
||||
return IIO_VAL_FRACTIONAL_LOG2;
|
||||
case IIO_CHAN_INFO_OFFSET:
|
||||
*val = -(1 << chan->scan_type.realbits) / 2;
|
||||
return IIO_VAL_INT;
|
||||
|
@ -270,9 +270,9 @@ static int ad5791_read_raw(struct iio_dev *indio_dev,
|
||||
*val >>= chan->scan_type.shift;
|
||||
return IIO_VAL_INT;
|
||||
case IIO_CHAN_INFO_SCALE:
|
||||
*val = 0;
|
||||
*val2 = (((u64)st->vref_mv) * 1000000ULL) >> chan->scan_type.realbits;
|
||||
return IIO_VAL_INT_PLUS_MICRO;
|
||||
*val = st->vref_mv;
|
||||
*val2 = (1 << chan->scan_type.realbits) - 1;
|
||||
return IIO_VAL_FRACTIONAL;
|
||||
case IIO_CHAN_INFO_OFFSET:
|
||||
val64 = (((u64)st->vref_neg_mv) << chan->scan_type.realbits);
|
||||
do_div(val64, st->vref_mv);
|
||||
|
@ -82,15 +82,13 @@ static int max517_read_raw(struct iio_dev *indio_dev,
|
||||
long m)
|
||||
{
|
||||
struct max517_data *data = iio_priv(indio_dev);
|
||||
unsigned int scale_uv;
|
||||
|
||||
switch (m) {
|
||||
case IIO_CHAN_INFO_SCALE:
|
||||
/* Corresponds to Vref / 2^(bits) */
|
||||
scale_uv = (data->vref_mv[chan->channel] * 1000) >> 8;
|
||||
*val = scale_uv / 1000000;
|
||||
*val2 = scale_uv % 1000000;
|
||||
return IIO_VAL_INT_PLUS_MICRO;
|
||||
*val = data->vref_mv[chan->channel];
|
||||
*val2 = 8;
|
||||
return IIO_VAL_FRACTIONAL_LOG2;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -239,17 +239,15 @@ static int mcp4725_read_raw(struct iio_dev *indio_dev,
|
||||
int *val, int *val2, long mask)
|
||||
{
|
||||
struct mcp4725_data *data = iio_priv(indio_dev);
|
||||
unsigned long scale_uv;
|
||||
|
||||
switch (mask) {
|
||||
case IIO_CHAN_INFO_RAW:
|
||||
*val = data->dac_value;
|
||||
return IIO_VAL_INT;
|
||||
case IIO_CHAN_INFO_SCALE:
|
||||
scale_uv = (data->vref_mv * 1000) >> 12;
|
||||
*val = scale_uv / 1000000;
|
||||
*val2 = scale_uv % 1000000;
|
||||
return IIO_VAL_INT_PLUS_MICRO;
|
||||
*val = data->vref_mv;
|
||||
*val2 = 12;
|
||||
return IIO_VAL_FRACTIONAL_LOG2;
|
||||
}
|
||||
return -EINVAL;
|
||||
}
|
||||
|
@ -51,7 +51,6 @@ static int adis16080_read_sample(struct iio_dev *indio_dev,
|
||||
u16 addr, int *val)
|
||||
{
|
||||
struct adis16080_state *st = iio_priv(indio_dev);
|
||||
struct spi_message m;
|
||||
int ret;
|
||||
struct spi_transfer t[] = {
|
||||
{
|
||||
@ -66,11 +65,7 @@ static int adis16080_read_sample(struct iio_dev *indio_dev,
|
||||
|
||||
st->buf = cpu_to_be16(addr | ADIS16080_DIN_WRITE);
|
||||
|
||||
spi_message_init(&m);
|
||||
spi_message_add_tail(&t[0], &m);
|
||||
spi_message_add_tail(&t[1], &m);
|
||||
|
||||
ret = spi_sync(st->us, &m);
|
||||
ret = spi_sync_transfer(st->us, t, ARRAY_SIZE(t));
|
||||
if (ret == 0)
|
||||
*val = sign_extend32(be16_to_cpu(st->buf), 11);
|
||||
|
||||
|
@ -47,7 +47,6 @@ static int adis16130_spi_read(struct iio_dev *indio_dev, u8 reg_addr, u32 *val)
|
||||
{
|
||||
int ret;
|
||||
struct adis16130_state *st = iio_priv(indio_dev);
|
||||
struct spi_message msg;
|
||||
struct spi_transfer xfer = {
|
||||
.tx_buf = st->buf,
|
||||
.rx_buf = st->buf,
|
||||
@ -59,10 +58,7 @@ static int adis16130_spi_read(struct iio_dev *indio_dev, u8 reg_addr, u32 *val)
|
||||
st->buf[0] = ADIS16130_CON_RD | reg_addr;
|
||||
st->buf[1] = st->buf[2] = st->buf[3] = 0;
|
||||
|
||||
spi_message_init(&msg);
|
||||
spi_message_add_tail(&xfer, &msg);
|
||||
ret = spi_sync(st->us, &msg);
|
||||
|
||||
ret = spi_sync_transfer(st->us, &xfer, 1);
|
||||
if (ret == 0)
|
||||
*val = (st->buf[1] << 16) | (st->buf[2] << 8) | st->buf[3];
|
||||
mutex_unlock(&st->buf_lock);
|
||||
|
@ -90,7 +90,6 @@ static int adxrs450_spi_read_reg_16(struct iio_dev *indio_dev,
|
||||
u8 reg_address,
|
||||
u16 *val)
|
||||
{
|
||||
struct spi_message msg;
|
||||
struct adxrs450_state *st = iio_priv(indio_dev);
|
||||
u32 tx;
|
||||
int ret;
|
||||
@ -114,10 +113,7 @@ static int adxrs450_spi_read_reg_16(struct iio_dev *indio_dev,
|
||||
tx |= ADXRS450_P;
|
||||
|
||||
st->tx = cpu_to_be32(tx);
|
||||
spi_message_init(&msg);
|
||||
spi_message_add_tail(&xfers[0], &msg);
|
||||
spi_message_add_tail(&xfers[1], &msg);
|
||||
ret = spi_sync(st->us, &msg);
|
||||
ret = spi_sync_transfer(st->us, xfers, ARRAY_SIZE(xfers));
|
||||
if (ret) {
|
||||
dev_err(&st->us->dev, "problem while reading 16 bit register 0x%02x\n",
|
||||
reg_address);
|
||||
@ -169,7 +165,6 @@ static int adxrs450_spi_write_reg_16(struct iio_dev *indio_dev,
|
||||
**/
|
||||
static int adxrs450_spi_sensor_data(struct iio_dev *indio_dev, s16 *val)
|
||||
{
|
||||
struct spi_message msg;
|
||||
struct adxrs450_state *st = iio_priv(indio_dev);
|
||||
int ret;
|
||||
struct spi_transfer xfers[] = {
|
||||
@ -188,10 +183,7 @@ static int adxrs450_spi_sensor_data(struct iio_dev *indio_dev, s16 *val)
|
||||
mutex_lock(&st->buf_lock);
|
||||
st->tx = cpu_to_be32(ADXRS450_SENSOR_DATA);
|
||||
|
||||
spi_message_init(&msg);
|
||||
spi_message_add_tail(&xfers[0], &msg);
|
||||
spi_message_add_tail(&xfers[1], &msg);
|
||||
ret = spi_sync(st->us, &msg);
|
||||
ret = spi_sync_transfer(st->us, xfers, ARRAY_SIZE(xfers));
|
||||
if (ret) {
|
||||
dev_err(&st->us->dev, "Problem while reading sensor data\n");
|
||||
goto error_ret;
|
||||
|
@ -275,6 +275,12 @@ static int hid_time_probe(struct platform_device *pdev)
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = sensor_hub_device_open(hsdev);
|
||||
if (ret) {
|
||||
dev_err(&pdev->dev, "failed to open sensor hub device!\n");
|
||||
goto err_open;
|
||||
}
|
||||
|
||||
time_state->rtc = devm_rtc_device_register(&pdev->dev,
|
||||
"hid-sensor-time", &hid_time_rtc_ops,
|
||||
THIS_MODULE);
|
||||
@ -282,17 +288,24 @@ static int hid_time_probe(struct platform_device *pdev)
|
||||
if (IS_ERR_OR_NULL(time_state->rtc)) {
|
||||
ret = time_state->rtc ? PTR_ERR(time_state->rtc) : -ENODEV;
|
||||
time_state->rtc = NULL;
|
||||
sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_TIME);
|
||||
dev_err(&pdev->dev, "rtc device register failed!\n");
|
||||
goto err_rtc;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
err_rtc:
|
||||
sensor_hub_device_close(hsdev);
|
||||
err_open:
|
||||
sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_TIME);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int hid_time_remove(struct platform_device *pdev)
|
||||
{
|
||||
struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data;
|
||||
|
||||
sensor_hub_device_close(hsdev);
|
||||
sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_TIME);
|
||||
|
||||
return 0;
|
||||
|
@ -13,6 +13,17 @@ Would be nice
|
||||
3) Expand device set. Lots of other maxim adc's have very
|
||||
similar interfaces.
|
||||
|
||||
MXS LRADC driver:
|
||||
This is a classic MFD device as it combines the following subdevices
|
||||
- touchscreen controller (input subsystem related device)
|
||||
- general purpose ADC channels
|
||||
- battery voltage monitor (power subsystem related device)
|
||||
- die temperature monitor (thermal management)
|
||||
|
||||
At least the battery voltage and die temperature feature is required in-kernel
|
||||
by a driver of the SoC's battery charging unit to avoid any damage to the
|
||||
silicon and the battery.
|
||||
|
||||
TSL2561
|
||||
Would be nice
|
||||
1) Open question of userspace vs kernel space balance when
|
||||
|
@ -102,7 +102,6 @@ static ssize_t adis16220_capture_buffer_read(struct iio_dev *indio_dev,
|
||||
int addr)
|
||||
{
|
||||
struct adis16220_state *st = iio_priv(indio_dev);
|
||||
struct spi_message msg;
|
||||
struct spi_transfer xfers[] = {
|
||||
{
|
||||
.tx_buf = st->tx,
|
||||
@ -147,10 +146,7 @@ static ssize_t adis16220_capture_buffer_read(struct iio_dev *indio_dev,
|
||||
}
|
||||
xfers[1].len = count;
|
||||
|
||||
spi_message_init(&msg);
|
||||
spi_message_add_tail(&xfers[0], &msg);
|
||||
spi_message_add_tail(&xfers[1], &msg);
|
||||
ret = spi_sync(st->adis.spi, &msg);
|
||||
ret = spi_sync_transfer(st->adis.spi, xfers, ARRAY_SIZE(xfers));
|
||||
if (ret) {
|
||||
|
||||
mutex_unlock(&st->buf_lock);
|
||||
|
@ -783,7 +783,6 @@ static int ad7280_read_raw(struct iio_dev *indio_dev,
|
||||
long m)
|
||||
{
|
||||
struct ad7280_state *st = iio_priv(indio_dev);
|
||||
unsigned int scale_uv;
|
||||
int ret;
|
||||
|
||||
switch (m) {
|
||||
@ -804,13 +803,12 @@ static int ad7280_read_raw(struct iio_dev *indio_dev,
|
||||
return IIO_VAL_INT;
|
||||
case IIO_CHAN_INFO_SCALE:
|
||||
if ((chan->address & 0xFF) <= AD7280A_CELL_VOLTAGE_6)
|
||||
scale_uv = (4000 * 1000) >> AD7280A_BITS;
|
||||
*val = 4000;
|
||||
else
|
||||
scale_uv = (5000 * 1000) >> AD7280A_BITS;
|
||||
*val = 5000;
|
||||
|
||||
*val = scale_uv / 1000;
|
||||
*val2 = (scale_uv % 1000) * 1000;
|
||||
return IIO_VAL_INT_PLUS_MICRO;
|
||||
*val2 = AD7280A_BITS;
|
||||
return IIO_VAL_FRACTIONAL_LOG2;
|
||||
}
|
||||
return -EINVAL;
|
||||
}
|
||||
|
@ -85,7 +85,6 @@ static int ad7606_read_raw(struct iio_dev *indio_dev,
|
||||
{
|
||||
int ret;
|
||||
struct ad7606_state *st = iio_priv(indio_dev);
|
||||
unsigned int scale_uv;
|
||||
|
||||
switch (m) {
|
||||
case IIO_CHAN_INFO_RAW:
|
||||
@ -101,11 +100,9 @@ static int ad7606_read_raw(struct iio_dev *indio_dev,
|
||||
*val = (short) ret;
|
||||
return IIO_VAL_INT;
|
||||
case IIO_CHAN_INFO_SCALE:
|
||||
scale_uv = (st->range * 1000 * 2)
|
||||
>> st->chip_info->channels[0].scan_type.realbits;
|
||||
*val = scale_uv / 1000;
|
||||
*val2 = (scale_uv % 1000) * 1000;
|
||||
return IIO_VAL_INT_PLUS_MICRO;
|
||||
*val = st->range * 2;
|
||||
*val2 = st->chip_info->channels[0].scan_type.realbits;
|
||||
return IIO_VAL_FRACTIONAL_LOG2;
|
||||
}
|
||||
return -EINVAL;
|
||||
}
|
||||
|
@ -90,17 +90,14 @@ static int ad7780_read_raw(struct iio_dev *indio_dev,
|
||||
long m)
|
||||
{
|
||||
struct ad7780_state *st = iio_priv(indio_dev);
|
||||
unsigned long scale_uv;
|
||||
|
||||
switch (m) {
|
||||
case IIO_CHAN_INFO_RAW:
|
||||
return ad_sigma_delta_single_conversion(indio_dev, chan, val);
|
||||
case IIO_CHAN_INFO_SCALE:
|
||||
scale_uv = (st->int_vref_mv * 100000 * st->gain)
|
||||
>> (chan->scan_type.realbits - 1);
|
||||
*val = scale_uv / 100000;
|
||||
*val2 = (scale_uv % 100000) * 10;
|
||||
return IIO_VAL_INT_PLUS_MICRO;
|
||||
*val = st->int_vref_mv * st->gain;
|
||||
*val2 = chan->scan_type.realbits - 1;
|
||||
return IIO_VAL_FRACTIONAL_LOG2;
|
||||
case IIO_CHAN_INFO_OFFSET:
|
||||
*val -= (1 << (chan->scan_type.realbits - 1));
|
||||
return IIO_VAL_INT;
|
||||
|
@ -163,7 +163,6 @@ static int ad799x_read_raw(struct iio_dev *indio_dev,
|
||||
{
|
||||
int ret;
|
||||
struct ad799x_state *st = iio_priv(indio_dev);
|
||||
unsigned int scale_uv;
|
||||
|
||||
switch (m) {
|
||||
case IIO_CHAN_INFO_RAW:
|
||||
@ -180,10 +179,9 @@ static int ad799x_read_raw(struct iio_dev *indio_dev,
|
||||
RES_MASK(chan->scan_type.realbits);
|
||||
return IIO_VAL_INT;
|
||||
case IIO_CHAN_INFO_SCALE:
|
||||
scale_uv = (st->int_vref_mv * 1000) >> chan->scan_type.realbits;
|
||||
*val = scale_uv / 1000;
|
||||
*val2 = (scale_uv % 1000) * 1000;
|
||||
return IIO_VAL_INT_PLUS_MICRO;
|
||||
*val = st->int_vref_mv;
|
||||
*val2 = chan->scan_type.realbits;
|
||||
return IIO_VAL_FRACTIONAL_LOG2;
|
||||
}
|
||||
return -EINVAL;
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -168,10 +168,9 @@ static int spear_read_raw(struct iio_dev *indio_dev,
|
||||
return IIO_VAL_INT;
|
||||
|
||||
case IIO_CHAN_INFO_SCALE:
|
||||
scale_mv = (info->vref_external * 1000) >> DATA_BITS;
|
||||
*val = scale_mv / 1000;
|
||||
*val2 = (scale_mv % 1000) * 1000;
|
||||
return IIO_VAL_INT_PLUS_MICRO;
|
||||
*val = info->vref_external;
|
||||
*val2 = DATA_BITS;
|
||||
return IIO_VAL_FRACTIONAL_LOG2;
|
||||
}
|
||||
|
||||
return -EINVAL;
|
||||
|
@ -656,20 +656,21 @@ static int ad7746_read_raw(struct iio_dev *indio_dev,
|
||||
switch (chan->type) {
|
||||
case IIO_CAPACITANCE:
|
||||
/* 8.192pf / 2^24 */
|
||||
*val2 = 488;
|
||||
*val = 0;
|
||||
*val2 = 488;
|
||||
ret = IIO_VAL_INT_PLUS_NANO;
|
||||
break;
|
||||
case IIO_VOLTAGE:
|
||||
/* 1170mV / 2^23 */
|
||||
*val2 = 139475;
|
||||
*val = 0;
|
||||
*val = 1170;
|
||||
*val2 = 23;
|
||||
ret = IIO_VAL_FRACTIONAL_LOG2;
|
||||
break;
|
||||
default:
|
||||
ret = -EINVAL;
|
||||
goto out;
|
||||
ret = -EINVAL;
|
||||
break;
|
||||
}
|
||||
|
||||
ret = IIO_VAL_INT_PLUS_NANO;
|
||||
break;
|
||||
default:
|
||||
ret = -EINVAL;
|
||||
|
@ -67,7 +67,6 @@ static ssize_t ad9852_set_parameter(struct device *dev,
|
||||
const char *buf,
|
||||
size_t len)
|
||||
{
|
||||
struct spi_message msg;
|
||||
struct spi_transfer xfer;
|
||||
int ret;
|
||||
struct ad9852_config *config = (struct ad9852_config *)buf;
|
||||
@ -78,99 +77,77 @@ static ssize_t ad9852_set_parameter(struct device *dev,
|
||||
xfer.tx_buf = &config->phajst0[0];
|
||||
mutex_lock(&st->lock);
|
||||
|
||||
spi_message_init(&msg);
|
||||
spi_message_add_tail(&xfer, &msg);
|
||||
ret = spi_sync(st->sdev, &msg);
|
||||
ret = spi_sync_transfer(st->sdev, &xfer, 1);
|
||||
if (ret)
|
||||
goto error_ret;
|
||||
|
||||
xfer.len = 3;
|
||||
xfer.tx_buf = &config->phajst1[0];
|
||||
|
||||
spi_message_init(&msg);
|
||||
spi_message_add_tail(&xfer, &msg);
|
||||
ret = spi_sync(st->sdev, &msg);
|
||||
ret = spi_sync_transfer(st->sdev, &xfer, 1);
|
||||
if (ret)
|
||||
goto error_ret;
|
||||
|
||||
xfer.len = 6;
|
||||
xfer.tx_buf = &config->fretun1[0];
|
||||
|
||||
spi_message_init(&msg);
|
||||
spi_message_add_tail(&xfer, &msg);
|
||||
ret = spi_sync(st->sdev, &msg);
|
||||
ret = spi_sync_transfer(st->sdev, &xfer, 1);
|
||||
if (ret)
|
||||
goto error_ret;
|
||||
|
||||
xfer.len = 6;
|
||||
xfer.tx_buf = &config->fretun2[0];
|
||||
|
||||
spi_message_init(&msg);
|
||||
spi_message_add_tail(&xfer, &msg);
|
||||
ret = spi_sync(st->sdev, &msg);
|
||||
ret = spi_sync_transfer(st->sdev, &xfer, 1);
|
||||
if (ret)
|
||||
goto error_ret;
|
||||
|
||||
xfer.len = 6;
|
||||
xfer.tx_buf = &config->dltafre[0];
|
||||
|
||||
spi_message_init(&msg);
|
||||
spi_message_add_tail(&xfer, &msg);
|
||||
ret = spi_sync(st->sdev, &msg);
|
||||
ret = spi_sync_transfer(st->sdev, &xfer, 1);
|
||||
if (ret)
|
||||
goto error_ret;
|
||||
|
||||
xfer.len = 5;
|
||||
xfer.tx_buf = &config->updtclk[0];
|
||||
|
||||
spi_message_init(&msg);
|
||||
spi_message_add_tail(&xfer, &msg);
|
||||
ret = spi_sync(st->sdev, &msg);
|
||||
ret = spi_sync_transfer(st->sdev, &xfer, 1);
|
||||
if (ret)
|
||||
goto error_ret;
|
||||
|
||||
xfer.len = 4;
|
||||
xfer.tx_buf = &config->ramprat[0];
|
||||
|
||||
spi_message_init(&msg);
|
||||
spi_message_add_tail(&xfer, &msg);
|
||||
ret = spi_sync(st->sdev, &msg);
|
||||
ret = spi_sync_transfer(st->sdev, &xfer, 1);
|
||||
if (ret)
|
||||
goto error_ret;
|
||||
|
||||
xfer.len = 5;
|
||||
xfer.tx_buf = &config->control[0];
|
||||
|
||||
spi_message_init(&msg);
|
||||
spi_message_add_tail(&xfer, &msg);
|
||||
ret = spi_sync(st->sdev, &msg);
|
||||
ret = spi_sync_transfer(st->sdev, &xfer, 1);
|
||||
if (ret)
|
||||
goto error_ret;
|
||||
|
||||
xfer.len = 3;
|
||||
xfer.tx_buf = &config->outpskm[0];
|
||||
|
||||
spi_message_init(&msg);
|
||||
spi_message_add_tail(&xfer, &msg);
|
||||
ret = spi_sync(st->sdev, &msg);
|
||||
ret = spi_sync_transfer(st->sdev, &xfer, 1);
|
||||
if (ret)
|
||||
goto error_ret;
|
||||
|
||||
xfer.len = 2;
|
||||
xfer.tx_buf = &config->outpskr[0];
|
||||
|
||||
spi_message_init(&msg);
|
||||
spi_message_add_tail(&xfer, &msg);
|
||||
ret = spi_sync(st->sdev, &msg);
|
||||
ret = spi_sync_transfer(st->sdev, &xfer, 1);
|
||||
if (ret)
|
||||
goto error_ret;
|
||||
|
||||
xfer.len = 3;
|
||||
xfer.tx_buf = &config->daccntl[0];
|
||||
|
||||
spi_message_init(&msg);
|
||||
spi_message_add_tail(&xfer, &msg);
|
||||
ret = spi_sync(st->sdev, &msg);
|
||||
ret = spi_sync_transfer(st->sdev, &xfer, 1);
|
||||
if (ret)
|
||||
goto error_ret;
|
||||
error_ret:
|
||||
|
@ -119,7 +119,6 @@ static ssize_t ad9910_set_parameter(struct device *dev,
|
||||
const char *buf,
|
||||
size_t len)
|
||||
{
|
||||
struct spi_message msg;
|
||||
struct spi_transfer xfer;
|
||||
int ret;
|
||||
struct ad9910_config *config = (struct ad9910_config *)buf;
|
||||
@ -130,152 +129,118 @@ static ssize_t ad9910_set_parameter(struct device *dev,
|
||||
xfer.tx_buf = &config->auxdac[0];
|
||||
mutex_lock(&st->lock);
|
||||
|
||||
spi_message_init(&msg);
|
||||
spi_message_add_tail(&xfer, &msg);
|
||||
ret = spi_sync(st->sdev, &msg);
|
||||
ret = spi_sync_transfer(st->sdev, &xfer, 1);
|
||||
if (ret)
|
||||
goto error_ret;
|
||||
|
||||
xfer.len = 5;
|
||||
xfer.tx_buf = &config->ioupd[0];
|
||||
|
||||
spi_message_init(&msg);
|
||||
spi_message_add_tail(&xfer, &msg);
|
||||
ret = spi_sync(st->sdev, &msg);
|
||||
ret = spi_sync_transfer(st->sdev, &xfer, 1);
|
||||
if (ret)
|
||||
goto error_ret;
|
||||
|
||||
xfer.len = 5;
|
||||
xfer.tx_buf = &config->ftw[0];
|
||||
|
||||
spi_message_init(&msg);
|
||||
spi_message_add_tail(&xfer, &msg);
|
||||
ret = spi_sync(st->sdev, &msg);
|
||||
ret = spi_sync_transfer(st->sdev, &xfer, 1);
|
||||
if (ret)
|
||||
goto error_ret;
|
||||
|
||||
xfer.len = 3;
|
||||
xfer.tx_buf = &config->pow[0];
|
||||
|
||||
spi_message_init(&msg);
|
||||
spi_message_add_tail(&xfer, &msg);
|
||||
ret = spi_sync(st->sdev, &msg);
|
||||
ret = spi_sync_transfer(st->sdev, &xfer, 1);
|
||||
if (ret)
|
||||
goto error_ret;
|
||||
|
||||
xfer.len = 5;
|
||||
xfer.tx_buf = &config->asf[0];
|
||||
|
||||
spi_message_init(&msg);
|
||||
spi_message_add_tail(&xfer, &msg);
|
||||
ret = spi_sync(st->sdev, &msg);
|
||||
ret = spi_sync_transfer(st->sdev, &xfer, 1);
|
||||
if (ret)
|
||||
goto error_ret;
|
||||
|
||||
xfer.len = 5;
|
||||
xfer.tx_buf = &config->multc[0];
|
||||
|
||||
spi_message_init(&msg);
|
||||
spi_message_add_tail(&xfer, &msg);
|
||||
ret = spi_sync(st->sdev, &msg);
|
||||
ret = spi_sync_transfer(st->sdev, &xfer, 1);
|
||||
if (ret)
|
||||
goto error_ret;
|
||||
|
||||
xfer.len = 9;
|
||||
xfer.tx_buf = &config->dig_rampl[0];
|
||||
|
||||
spi_message_init(&msg);
|
||||
spi_message_add_tail(&xfer, &msg);
|
||||
ret = spi_sync(st->sdev, &msg);
|
||||
ret = spi_sync_transfer(st->sdev, &xfer, 1);
|
||||
if (ret)
|
||||
goto error_ret;
|
||||
|
||||
xfer.len = 9;
|
||||
xfer.tx_buf = &config->dig_ramps[0];
|
||||
|
||||
spi_message_init(&msg);
|
||||
spi_message_add_tail(&xfer, &msg);
|
||||
ret = spi_sync(st->sdev, &msg);
|
||||
ret = spi_sync_transfer(st->sdev, &xfer, 1);
|
||||
if (ret)
|
||||
goto error_ret;
|
||||
|
||||
xfer.len = 5;
|
||||
xfer.tx_buf = &config->dig_rampr[0];
|
||||
|
||||
spi_message_init(&msg);
|
||||
spi_message_add_tail(&xfer, &msg);
|
||||
ret = spi_sync(st->sdev, &msg);
|
||||
ret = spi_sync_transfer(st->sdev, &xfer, 1);
|
||||
if (ret)
|
||||
goto error_ret;
|
||||
|
||||
xfer.len = 9;
|
||||
xfer.tx_buf = &config->sin_tonep0[0];
|
||||
|
||||
spi_message_init(&msg);
|
||||
spi_message_add_tail(&xfer, &msg);
|
||||
ret = spi_sync(st->sdev, &msg);
|
||||
ret = spi_sync_transfer(st->sdev, &xfer, 1);
|
||||
if (ret)
|
||||
goto error_ret;
|
||||
|
||||
xfer.len = 9;
|
||||
xfer.tx_buf = &config->sin_tonep1[0];
|
||||
|
||||
spi_message_init(&msg);
|
||||
spi_message_add_tail(&xfer, &msg);
|
||||
ret = spi_sync(st->sdev, &msg);
|
||||
ret = spi_sync_transfer(st->sdev, &xfer, 1);
|
||||
if (ret)
|
||||
goto error_ret;
|
||||
|
||||
xfer.len = 9;
|
||||
xfer.tx_buf = &config->sin_tonep2[0];
|
||||
|
||||
spi_message_init(&msg);
|
||||
spi_message_add_tail(&xfer, &msg);
|
||||
ret = spi_sync(st->sdev, &msg);
|
||||
ret = spi_sync_transfer(st->sdev, &xfer, 1);
|
||||
if (ret)
|
||||
goto error_ret;
|
||||
xfer.len = 9;
|
||||
xfer.tx_buf = &config->sin_tonep3[0];
|
||||
|
||||
spi_message_init(&msg);
|
||||
spi_message_add_tail(&xfer, &msg);
|
||||
ret = spi_sync(st->sdev, &msg);
|
||||
ret = spi_sync_transfer(st->sdev, &xfer, 1);
|
||||
if (ret)
|
||||
goto error_ret;
|
||||
|
||||
xfer.len = 9;
|
||||
xfer.tx_buf = &config->sin_tonep4[0];
|
||||
|
||||
spi_message_init(&msg);
|
||||
spi_message_add_tail(&xfer, &msg);
|
||||
ret = spi_sync(st->sdev, &msg);
|
||||
ret = spi_sync_transfer(st->sdev, &xfer, 1);
|
||||
if (ret)
|
||||
goto error_ret;
|
||||
|
||||
xfer.len = 9;
|
||||
xfer.tx_buf = &config->sin_tonep5[0];
|
||||
|
||||
spi_message_init(&msg);
|
||||
spi_message_add_tail(&xfer, &msg);
|
||||
ret = spi_sync(st->sdev, &msg);
|
||||
ret = spi_sync_transfer(st->sdev, &xfer, 1);
|
||||
if (ret)
|
||||
goto error_ret;
|
||||
|
||||
xfer.len = 9;
|
||||
xfer.tx_buf = &config->sin_tonep6[0];
|
||||
|
||||
spi_message_init(&msg);
|
||||
spi_message_add_tail(&xfer, &msg);
|
||||
ret = spi_sync(st->sdev, &msg);
|
||||
ret = spi_sync_transfer(st->sdev, &xfer, 1);
|
||||
if (ret)
|
||||
goto error_ret;
|
||||
|
||||
xfer.len = 9;
|
||||
xfer.tx_buf = &config->sin_tonep7[0];
|
||||
|
||||
spi_message_init(&msg);
|
||||
spi_message_add_tail(&xfer, &msg);
|
||||
ret = spi_sync(st->sdev, &msg);
|
||||
ret = spi_sync_transfer(st->sdev, &xfer, 1);
|
||||
if (ret)
|
||||
goto error_ret;
|
||||
error_ret:
|
||||
@ -288,7 +253,6 @@ static IIO_DEVICE_ATTR(dds, S_IWUSR, NULL, ad9910_set_parameter, 0);
|
||||
|
||||
static void ad9910_init(struct ad9910_state *st)
|
||||
{
|
||||
struct spi_message msg;
|
||||
struct spi_transfer xfer;
|
||||
int ret;
|
||||
u8 cfr[5];
|
||||
@ -304,9 +268,7 @@ static void ad9910_init(struct ad9910_state *st)
|
||||
xfer.len = 5;
|
||||
xfer.tx_buf = 𝔠
|
||||
|
||||
spi_message_init(&msg);
|
||||
spi_message_add_tail(&xfer, &msg);
|
||||
ret = spi_sync(st->sdev, &msg);
|
||||
ret = spi_sync_transfer(st->sdev, &xfer, 1);
|
||||
if (ret)
|
||||
goto error_ret;
|
||||
|
||||
@ -319,9 +281,7 @@ static void ad9910_init(struct ad9910_state *st)
|
||||
xfer.len = 5;
|
||||
xfer.tx_buf = 𝔠
|
||||
|
||||
spi_message_init(&msg);
|
||||
spi_message_add_tail(&xfer, &msg);
|
||||
ret = spi_sync(st->sdev, &msg);
|
||||
ret = spi_sync_transfer(st->sdev, &xfer, 1);
|
||||
if (ret)
|
||||
goto error_ret;
|
||||
|
||||
@ -334,9 +294,7 @@ static void ad9910_init(struct ad9910_state *st)
|
||||
xfer.len = 5;
|
||||
xfer.tx_buf = 𝔠
|
||||
|
||||
spi_message_init(&msg);
|
||||
spi_message_add_tail(&xfer, &msg);
|
||||
ret = spi_sync(st->sdev, &msg);
|
||||
ret = spi_sync_transfer(st->sdev, &xfer, 1);
|
||||
if (ret)
|
||||
goto error_ret;
|
||||
|
||||
|
@ -60,7 +60,6 @@ static ssize_t ad9951_set_parameter(struct device *dev,
|
||||
const char *buf,
|
||||
size_t len)
|
||||
{
|
||||
struct spi_message msg;
|
||||
struct spi_transfer xfer;
|
||||
int ret;
|
||||
struct ad9951_config *config = (struct ad9951_config *)buf;
|
||||
@ -71,36 +70,28 @@ static ssize_t ad9951_set_parameter(struct device *dev,
|
||||
xfer.tx_buf = &config->asf[0];
|
||||
mutex_lock(&st->lock);
|
||||
|
||||
spi_message_init(&msg);
|
||||
spi_message_add_tail(&xfer, &msg);
|
||||
ret = spi_sync(st->sdev, &msg);
|
||||
ret = spi_sync_transfer(st->sdev, &xfer, 1);
|
||||
if (ret)
|
||||
goto error_ret;
|
||||
|
||||
xfer.len = 2;
|
||||
xfer.tx_buf = &config->arr[0];
|
||||
|
||||
spi_message_init(&msg);
|
||||
spi_message_add_tail(&xfer, &msg);
|
||||
ret = spi_sync(st->sdev, &msg);
|
||||
ret = spi_sync_transfer(st->sdev, &xfer, 1);
|
||||
if (ret)
|
||||
goto error_ret;
|
||||
|
||||
xfer.len = 5;
|
||||
xfer.tx_buf = &config->ftw0[0];
|
||||
|
||||
spi_message_init(&msg);
|
||||
spi_message_add_tail(&xfer, &msg);
|
||||
ret = spi_sync(st->sdev, &msg);
|
||||
ret = spi_sync_transfer(st->sdev, &xfer, 1);
|
||||
if (ret)
|
||||
goto error_ret;
|
||||
|
||||
xfer.len = 3;
|
||||
xfer.tx_buf = &config->ftw1[0];
|
||||
|
||||
spi_message_init(&msg);
|
||||
spi_message_add_tail(&xfer, &msg);
|
||||
ret = spi_sync(st->sdev, &msg);
|
||||
ret = spi_sync_transfer(st->sdev, &xfer, 1);
|
||||
if (ret)
|
||||
goto error_ret;
|
||||
error_ret:
|
||||
@ -113,7 +104,6 @@ static IIO_DEVICE_ATTR(dds, S_IWUSR, NULL, ad9951_set_parameter, 0);
|
||||
|
||||
static void ad9951_init(struct ad9951_state *st)
|
||||
{
|
||||
struct spi_message msg;
|
||||
struct spi_transfer xfer;
|
||||
int ret;
|
||||
u8 cfr[5];
|
||||
@ -129,9 +119,7 @@ static void ad9951_init(struct ad9951_state *st)
|
||||
xfer.len = 5;
|
||||
xfer.tx_buf = 𝔠
|
||||
|
||||
spi_message_init(&msg);
|
||||
spi_message_add_tail(&xfer, &msg);
|
||||
ret = spi_sync(st->sdev, &msg);
|
||||
ret = spi_sync_transfer(st->sdev, &xfer, 1);
|
||||
if (ret)
|
||||
goto error_ret;
|
||||
|
||||
@ -143,9 +131,7 @@ static void ad9951_init(struct ad9951_state *st)
|
||||
xfer.len = 4;
|
||||
xfer.tx_buf = 𝔠
|
||||
|
||||
spi_message_init(&msg);
|
||||
spi_message_add_tail(&xfer, &msg);
|
||||
ret = spi_sync(st->sdev, &msg);
|
||||
ret = spi_sync_transfer(st->sdev, &xfer, 1);
|
||||
if (ret)
|
||||
goto error_ret;
|
||||
|
||||
|
@ -29,16 +29,11 @@
|
||||
#define HMC5843_CONFIG_REG_B 0x01
|
||||
#define HMC5843_MODE_REG 0x02
|
||||
#define HMC5843_DATA_OUT_X_MSB_REG 0x03
|
||||
#define HMC5843_DATA_OUT_X_LSB_REG 0x04
|
||||
#define HMC5843_DATA_OUT_Y_MSB_REG 0x05
|
||||
#define HMC5843_DATA_OUT_Y_LSB_REG 0x06
|
||||
#define HMC5843_DATA_OUT_Z_MSB_REG 0x07
|
||||
#define HMC5843_DATA_OUT_Z_LSB_REG 0x08
|
||||
/* Beware: Y and Z are exchanged on HMC5883 */
|
||||
#define HMC5883_DATA_OUT_Z_MSB_REG 0x05
|
||||
#define HMC5883_DATA_OUT_Z_LSB_REG 0x06
|
||||
#define HMC5883_DATA_OUT_Y_MSB_REG 0x07
|
||||
#define HMC5883_DATA_OUT_Y_LSB_REG 0x08
|
||||
#define HMC5843_STATUS_REG 0x09
|
||||
|
||||
enum hmc5843_ids {
|
||||
@ -56,17 +51,11 @@ enum hmc5843_ids {
|
||||
#define HMC5843_RANGE_GAIN_DEFAULT 0x01
|
||||
#define HMC5843_RANGE_GAIN_MAX 0x07
|
||||
|
||||
/*
|
||||
* Device status
|
||||
*/
|
||||
/* Device status */
|
||||
#define HMC5843_DATA_READY 0x01
|
||||
#define HMC5843_DATA_OUTPUT_LOCK 0x02
|
||||
/* Does not exist on HMC5883, not used */
|
||||
#define HMC5843_VOLTAGE_REGULATOR_ENABLED 0x04
|
||||
|
||||
/*
|
||||
* Mode register configuration
|
||||
*/
|
||||
/* Mode register configuration */
|
||||
#define HMC5843_MODE_CONVERSION_CONTINUOUS 0x00
|
||||
#define HMC5843_MODE_CONVERSION_SINGLE 0x01
|
||||
#define HMC5843_MODE_IDLE 0x02
|
||||
@ -78,21 +67,18 @@ enum hmc5843_ids {
|
||||
* HMC5883: Typical data output rate
|
||||
*/
|
||||
#define HMC5843_RATE_OFFSET 0x02
|
||||
#define HMC5843_RATE_DEFAULT 0x04
|
||||
#define HMC5843_RATE_BITMASK 0x1C
|
||||
#define HMC5843_RATE_NOT_USED 0x07
|
||||
|
||||
/*
|
||||
* Device measurement configuration
|
||||
*/
|
||||
/* Device measurement configuration */
|
||||
#define HMC5843_MEAS_CONF_NORMAL 0x00
|
||||
#define HMC5843_MEAS_CONF_POSITIVE_BIAS 0x01
|
||||
#define HMC5843_MEAS_CONF_NEGATIVE_BIAS 0x02
|
||||
#define HMC5843_MEAS_CONF_NOT_USED 0x03
|
||||
#define HMC5843_MEAS_CONF_MASK 0x03
|
||||
|
||||
/*
|
||||
* Scaling factors: 10000000/Gain
|
||||
*/
|
||||
/* Scaling factors: 10000000/Gain */
|
||||
static const int hmc5843_regval_to_nanoscale[] = {
|
||||
6173, 7692, 10309, 12821, 18868, 21739, 25641, 35714
|
||||
};
|
||||
@ -164,24 +150,26 @@ static const int hmc5883l_regval_to_input_field_mga[] = {
|
||||
* 6 | 50 | 75
|
||||
* 7 | Not used | Not used
|
||||
*/
|
||||
static const char * const hmc5843_regval_to_sample_freq[] = {
|
||||
"0.5", "1", "2", "5", "10", "20", "50",
|
||||
static const int hmc5843_regval_to_samp_freq[7][2] = {
|
||||
{0, 500000}, {1, 0}, {2, 0}, {5, 0}, {10, 0}, {20, 0}, {50, 0}
|
||||
};
|
||||
|
||||
static const char * const hmc5883_regval_to_sample_freq[] = {
|
||||
"0.75", "1.5", "3", "7.5", "15", "30", "75",
|
||||
static const int hmc5883_regval_to_samp_freq[7][2] = {
|
||||
{0, 750000}, {1, 500000}, {3, 0}, {7, 500000}, {15, 0}, {30, 0},
|
||||
{75, 0}
|
||||
};
|
||||
|
||||
/* Describe chip variants */
|
||||
struct hmc5843_chip_info {
|
||||
const struct iio_chan_spec *channels;
|
||||
const char * const *regval_to_sample_freq;
|
||||
const int (*regval_to_samp_freq)[2];
|
||||
const int *regval_to_input_field_mga;
|
||||
const int *regval_to_nanoscale;
|
||||
};
|
||||
|
||||
/* Each client has this additional data */
|
||||
struct hmc5843_data {
|
||||
struct i2c_client *client;
|
||||
struct mutex lock;
|
||||
u8 rate;
|
||||
u8 meas_conf;
|
||||
@ -200,18 +188,15 @@ static s32 hmc5843_configure(struct i2c_client *client,
|
||||
}
|
||||
|
||||
/* Return the measurement value from the specified channel */
|
||||
static int hmc5843_read_measurement(struct iio_dev *indio_dev,
|
||||
int address,
|
||||
int *val)
|
||||
static int hmc5843_read_measurement(struct hmc5843_data *data,
|
||||
int address, int *val)
|
||||
{
|
||||
struct i2c_client *client = to_i2c_client(indio_dev->dev.parent);
|
||||
struct hmc5843_data *data = iio_priv(indio_dev);
|
||||
s32 result;
|
||||
int tries = 150;
|
||||
|
||||
mutex_lock(&data->lock);
|
||||
while (tries-- > 0) {
|
||||
result = i2c_smbus_read_byte_data(client,
|
||||
result = i2c_smbus_read_byte_data(data->client,
|
||||
HMC5843_STATUS_REG);
|
||||
if (result & HMC5843_DATA_READY)
|
||||
break;
|
||||
@ -219,12 +204,12 @@ static int hmc5843_read_measurement(struct iio_dev *indio_dev,
|
||||
}
|
||||
|
||||
if (tries < 0) {
|
||||
dev_err(&client->dev, "data not ready\n");
|
||||
dev_err(&data->client->dev, "data not ready\n");
|
||||
mutex_unlock(&data->lock);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
result = i2c_smbus_read_word_swapped(client, address);
|
||||
result = i2c_smbus_read_word_swapped(data->client, address);
|
||||
mutex_unlock(&data->lock);
|
||||
if (result < 0)
|
||||
return -EINVAL;
|
||||
@ -318,15 +303,13 @@ static IIO_DEVICE_ATTR(operating_mode,
|
||||
* and BN.
|
||||
*
|
||||
*/
|
||||
static s32 hmc5843_set_meas_conf(struct i2c_client *client,
|
||||
u8 meas_conf)
|
||||
static s32 hmc5843_set_meas_conf(struct hmc5843_data *data, u8 meas_conf)
|
||||
{
|
||||
struct iio_dev *indio_dev = i2c_get_clientdata(client);
|
||||
struct hmc5843_data *data = iio_priv(indio_dev);
|
||||
u8 reg_val;
|
||||
reg_val = (meas_conf & HMC5843_MEAS_CONF_MASK) |
|
||||
(data->rate << HMC5843_RATE_OFFSET);
|
||||
return i2c_smbus_write_byte_data(client, HMC5843_CONFIG_REG_A, reg_val);
|
||||
return i2c_smbus_write_byte_data(data->client, HMC5843_CONFIG_REG_A,
|
||||
reg_val);
|
||||
}
|
||||
|
||||
static ssize_t hmc5843_show_measurement_configuration(struct device *dev,
|
||||
@ -344,7 +327,6 @@ static ssize_t hmc5843_set_measurement_configuration(struct device *dev,
|
||||
size_t count)
|
||||
{
|
||||
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
||||
struct i2c_client *client = to_i2c_client(indio_dev->dev.parent);
|
||||
struct hmc5843_data *data = iio_priv(indio_dev);
|
||||
unsigned long meas_conf = 0;
|
||||
int error;
|
||||
@ -357,7 +339,7 @@ static ssize_t hmc5843_set_measurement_configuration(struct device *dev,
|
||||
|
||||
mutex_lock(&data->lock);
|
||||
dev_dbg(dev, "set measurement configuration to %lu\n", meas_conf);
|
||||
if (hmc5843_set_meas_conf(client, meas_conf)) {
|
||||
if (hmc5843_set_meas_conf(data, meas_conf)) {
|
||||
count = -EINVAL;
|
||||
goto exit;
|
||||
}
|
||||
@ -374,110 +356,61 @@ static IIO_DEVICE_ATTR(meas_conf,
|
||||
hmc5843_set_measurement_configuration,
|
||||
0);
|
||||
|
||||
static ssize_t hmc5843_show_sampling_frequencies_available(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
char *buf)
|
||||
static ssize_t hmc5843_show_int_plus_micros(char *buf,
|
||||
const int (*vals)[2], int n)
|
||||
{
|
||||
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
||||
struct hmc5843_data *data = iio_priv(indio_dev);
|
||||
ssize_t total_n = 0;
|
||||
size_t len = 0;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < HMC5843_RATE_NOT_USED; i++) {
|
||||
ssize_t n = sprintf(buf, "%s ", data->variant->regval_to_sample_freq[i]);
|
||||
buf += n;
|
||||
total_n += n;
|
||||
}
|
||||
for (i = 0; i < n; i++)
|
||||
len += scnprintf(buf + len, PAGE_SIZE - len,
|
||||
"%d.%d ", vals[i][0], vals[i][1]);
|
||||
|
||||
/* replace trailing space by newline */
|
||||
buf[-1] = '\n';
|
||||
buf[len - 1] = '\n';
|
||||
|
||||
return total_n;
|
||||
return len;
|
||||
}
|
||||
|
||||
static IIO_DEV_ATTR_SAMP_FREQ_AVAIL(hmc5843_show_sampling_frequencies_available);
|
||||
|
||||
static s32 hmc5843_set_rate(struct i2c_client *client,
|
||||
u8 rate)
|
||||
static int hmc5843_check_int_plus_micros(const int (*vals)[2], int n,
|
||||
int val, int val2)
|
||||
{
|
||||
struct iio_dev *indio_dev = i2c_get_clientdata(client);
|
||||
struct hmc5843_data *data = iio_priv(indio_dev);
|
||||
u8 reg_val;
|
||||
|
||||
if (rate >= HMC5843_RATE_NOT_USED) {
|
||||
dev_err(&client->dev,
|
||||
"data output rate is not supported\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
reg_val = data->meas_conf | (rate << HMC5843_RATE_OFFSET);
|
||||
return i2c_smbus_write_byte_data(client, HMC5843_CONFIG_REG_A, reg_val);
|
||||
}
|
||||
|
||||
static int hmc5843_check_sampling_frequency(struct hmc5843_data *data,
|
||||
const char *buf)
|
||||
{
|
||||
const char * const *samp_freq = data->variant->regval_to_sample_freq;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < HMC5843_RATE_NOT_USED; i++) {
|
||||
if (sysfs_streq(buf, samp_freq[i]))
|
||||
for (i = 0; i < n; i++) {
|
||||
if (val == vals[i][0] && val2 == vals[i][1])
|
||||
return i;
|
||||
}
|
||||
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static ssize_t hmc5843_set_sampling_frequency(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
const char *buf, size_t count)
|
||||
static ssize_t hmc5843_show_samp_freq_avail(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct hmc5843_data *data = iio_priv(dev_to_iio_dev(dev));
|
||||
|
||||
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
||||
struct i2c_client *client = to_i2c_client(indio_dev->dev.parent);
|
||||
struct hmc5843_data *data = iio_priv(indio_dev);
|
||||
int rate;
|
||||
|
||||
rate = hmc5843_check_sampling_frequency(data, buf);
|
||||
if (rate < 0) {
|
||||
dev_err(&client->dev,
|
||||
"sampling frequency is not supported\n");
|
||||
return rate;
|
||||
}
|
||||
|
||||
mutex_lock(&data->lock);
|
||||
dev_dbg(dev, "set rate to %d\n", rate);
|
||||
if (hmc5843_set_rate(client, rate)) {
|
||||
count = -EINVAL;
|
||||
goto exit;
|
||||
}
|
||||
data->rate = rate;
|
||||
|
||||
exit:
|
||||
mutex_unlock(&data->lock);
|
||||
return count;
|
||||
return hmc5843_show_int_plus_micros(buf,
|
||||
data->variant->regval_to_samp_freq, HMC5843_RATE_NOT_USED);
|
||||
}
|
||||
|
||||
static ssize_t hmc5843_show_sampling_frequency(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
||||
struct i2c_client *client = to_i2c_client(indio_dev->dev.parent);
|
||||
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
|
||||
struct hmc5843_data *data = iio_priv(indio_dev);
|
||||
s32 rate;
|
||||
static IIO_DEV_ATTR_SAMP_FREQ_AVAIL(hmc5843_show_samp_freq_avail);
|
||||
|
||||
rate = i2c_smbus_read_byte_data(client, this_attr->address);
|
||||
if (rate < 0)
|
||||
return rate;
|
||||
rate = (rate & HMC5843_RATE_BITMASK) >> HMC5843_RATE_OFFSET;
|
||||
return sprintf(buf, "%s\n", data->variant->regval_to_sample_freq[rate]);
|
||||
static s32 hmc5843_set_rate(struct hmc5843_data *data, u8 rate)
|
||||
{
|
||||
u8 reg_val = data->meas_conf | (rate << HMC5843_RATE_OFFSET);
|
||||
|
||||
return i2c_smbus_write_byte_data(data->client, HMC5843_CONFIG_REG_A,
|
||||
reg_val);
|
||||
}
|
||||
|
||||
static IIO_DEVICE_ATTR(sampling_frequency,
|
||||
S_IWUSR | S_IRUGO,
|
||||
hmc5843_show_sampling_frequency,
|
||||
hmc5843_set_sampling_frequency,
|
||||
HMC5843_CONFIG_REG_A);
|
||||
static int hmc5843_check_samp_freq(struct hmc5843_data *data,
|
||||
int val, int val2)
|
||||
{
|
||||
return hmc5843_check_int_plus_micros(
|
||||
data->variant->regval_to_samp_freq, HMC5843_RATE_NOT_USED,
|
||||
val, val2);
|
||||
}
|
||||
|
||||
static ssize_t hmc5843_show_range_gain(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
@ -497,7 +430,6 @@ static ssize_t hmc5843_set_range_gain(struct device *dev,
|
||||
size_t count)
|
||||
{
|
||||
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
||||
struct i2c_client *client = to_i2c_client(indio_dev->dev.parent);
|
||||
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
|
||||
struct hmc5843_data *data = iio_priv(indio_dev);
|
||||
unsigned long range = 0;
|
||||
@ -518,7 +450,7 @@ static ssize_t hmc5843_set_range_gain(struct device *dev,
|
||||
|
||||
data->range = range;
|
||||
range = range << HMC5843_RANGE_GAIN_OFFSET;
|
||||
if (i2c_smbus_write_byte_data(client, this_attr->address, range))
|
||||
if (i2c_smbus_write_byte_data(data->client, this_attr->address, range))
|
||||
count = -EINVAL;
|
||||
|
||||
exit:
|
||||
@ -534,31 +466,58 @@ static IIO_DEVICE_ATTR(in_magn_range,
|
||||
|
||||
static int hmc5843_read_raw(struct iio_dev *indio_dev,
|
||||
struct iio_chan_spec const *chan,
|
||||
int *val, int *val2,
|
||||
long mask)
|
||||
int *val, int *val2, long mask)
|
||||
{
|
||||
struct hmc5843_data *data = iio_priv(indio_dev);
|
||||
|
||||
switch (mask) {
|
||||
case IIO_CHAN_INFO_RAW:
|
||||
return hmc5843_read_measurement(indio_dev,
|
||||
chan->address,
|
||||
val);
|
||||
return hmc5843_read_measurement(data, chan->address, val);
|
||||
case IIO_CHAN_INFO_SCALE:
|
||||
*val = 0;
|
||||
*val2 = data->variant->regval_to_nanoscale[data->range];
|
||||
return IIO_VAL_INT_PLUS_NANO;
|
||||
case IIO_CHAN_INFO_SAMP_FREQ:
|
||||
*val = data->variant->regval_to_samp_freq[data->rate][0];
|
||||
*val2 = data->variant->regval_to_samp_freq[data->rate][1];
|
||||
return IIO_VAL_INT_PLUS_MICRO;
|
||||
}
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static int hmc5843_write_raw(struct iio_dev *indio_dev,
|
||||
struct iio_chan_spec const *chan,
|
||||
int val, int val2, long mask)
|
||||
{
|
||||
struct hmc5843_data *data = iio_priv(indio_dev);
|
||||
int ret, rate;
|
||||
|
||||
switch (mask) {
|
||||
case IIO_CHAN_INFO_SAMP_FREQ:
|
||||
rate = hmc5843_check_samp_freq(data, val, val2);
|
||||
if (rate < 0)
|
||||
return -EINVAL;
|
||||
|
||||
mutex_lock(&data->lock);
|
||||
ret = hmc5843_set_rate(data, rate);
|
||||
if (ret >= 0)
|
||||
data->rate = rate;
|
||||
mutex_unlock(&data->lock);
|
||||
|
||||
return ret;
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
#define HMC5843_CHANNEL(axis, addr) \
|
||||
{ \
|
||||
.type = IIO_MAGN, \
|
||||
.modified = 1, \
|
||||
.channel2 = IIO_MOD_##axis, \
|
||||
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
|
||||
.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \
|
||||
.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) | \
|
||||
BIT(IIO_CHAN_INFO_SAMP_FREQ), \
|
||||
.address = addr \
|
||||
}
|
||||
|
||||
@ -577,7 +536,6 @@ static const struct iio_chan_spec hmc5883_channels[] = {
|
||||
static struct attribute *hmc5843_attributes[] = {
|
||||
&iio_dev_attr_meas_conf.dev_attr.attr,
|
||||
&iio_dev_attr_operating_mode.dev_attr.attr,
|
||||
&iio_dev_attr_sampling_frequency.dev_attr.attr,
|
||||
&iio_dev_attr_in_magn_range.dev_attr.attr,
|
||||
&iio_dev_attr_sampling_frequency_available.dev_attr.attr,
|
||||
NULL
|
||||
@ -590,49 +548,40 @@ static const struct attribute_group hmc5843_group = {
|
||||
static const struct hmc5843_chip_info hmc5843_chip_info_tbl[] = {
|
||||
[HMC5843_ID] = {
|
||||
.channels = hmc5843_channels,
|
||||
.regval_to_sample_freq = hmc5843_regval_to_sample_freq,
|
||||
.regval_to_samp_freq = hmc5843_regval_to_samp_freq,
|
||||
.regval_to_input_field_mga =
|
||||
hmc5843_regval_to_input_field_mga,
|
||||
.regval_to_nanoscale = hmc5843_regval_to_nanoscale,
|
||||
},
|
||||
[HMC5883_ID] = {
|
||||
.channels = hmc5883_channels,
|
||||
.regval_to_sample_freq = hmc5883_regval_to_sample_freq,
|
||||
.regval_to_samp_freq = hmc5883_regval_to_samp_freq,
|
||||
.regval_to_input_field_mga =
|
||||
hmc5883_regval_to_input_field_mga,
|
||||
.regval_to_nanoscale = hmc5883_regval_to_nanoscale,
|
||||
},
|
||||
[HMC5883L_ID] = {
|
||||
.channels = hmc5883_channels,
|
||||
.regval_to_sample_freq = hmc5883_regval_to_sample_freq,
|
||||
.regval_to_samp_freq = hmc5883_regval_to_samp_freq,
|
||||
.regval_to_input_field_mga =
|
||||
hmc5883l_regval_to_input_field_mga,
|
||||
.regval_to_nanoscale = hmc5883l_regval_to_nanoscale,
|
||||
},
|
||||
};
|
||||
|
||||
/* Called when we have found a new HMC58X3 */
|
||||
static void hmc5843_init_client(struct i2c_client *client,
|
||||
const struct i2c_device_id *id)
|
||||
static void hmc5843_init(struct hmc5843_data *data)
|
||||
{
|
||||
struct iio_dev *indio_dev = i2c_get_clientdata(client);
|
||||
struct hmc5843_data *data = iio_priv(indio_dev);
|
||||
|
||||
data->variant = &hmc5843_chip_info_tbl[id->driver_data];
|
||||
indio_dev->channels = data->variant->channels;
|
||||
indio_dev->num_channels = 3;
|
||||
hmc5843_set_meas_conf(client, data->meas_conf);
|
||||
hmc5843_set_rate(client, data->rate);
|
||||
hmc5843_configure(client, data->operating_mode);
|
||||
i2c_smbus_write_byte_data(client, HMC5843_CONFIG_REG_B, data->range);
|
||||
mutex_init(&data->lock);
|
||||
|
||||
pr_info("%s initialized\n", id->name);
|
||||
hmc5843_set_meas_conf(data, HMC5843_MEAS_CONF_NORMAL);
|
||||
hmc5843_set_rate(data, HMC5843_RATE_DEFAULT);
|
||||
hmc5843_configure(data->client, HMC5843_MODE_CONVERSION_CONTINUOUS);
|
||||
i2c_smbus_write_byte_data(data->client, HMC5843_CONFIG_REG_B,
|
||||
HMC5843_RANGE_GAIN_DEFAULT);
|
||||
}
|
||||
|
||||
static const struct iio_info hmc5843_info = {
|
||||
.attrs = &hmc5843_group,
|
||||
.read_raw = &hmc5843_read_raw,
|
||||
.write_raw = &hmc5843_write_raw,
|
||||
.driver_module = THIS_MODULE,
|
||||
};
|
||||
|
||||
@ -649,17 +598,19 @@ static int hmc5843_probe(struct i2c_client *client,
|
||||
|
||||
/* default settings at probe */
|
||||
data = iio_priv(indio_dev);
|
||||
data->meas_conf = HMC5843_MEAS_CONF_NORMAL;
|
||||
data->range = HMC5843_RANGE_GAIN_DEFAULT;
|
||||
data->operating_mode = HMC5843_MODE_CONVERSION_CONTINUOUS;
|
||||
data->client = client;
|
||||
data->variant = &hmc5843_chip_info_tbl[id->driver_data];
|
||||
mutex_init(&data->lock);
|
||||
|
||||
i2c_set_clientdata(client, indio_dev);
|
||||
hmc5843_init_client(client, id);
|
||||
|
||||
indio_dev->info = &hmc5843_info;
|
||||
indio_dev->name = id->name;
|
||||
indio_dev->dev.parent = &client->dev;
|
||||
indio_dev->modes = INDIO_DIRECT_MODE;
|
||||
indio_dev->channels = data->variant->channels;
|
||||
indio_dev->num_channels = 3;
|
||||
|
||||
hmc5843_init(data);
|
||||
|
||||
err = iio_device_register(indio_dev);
|
||||
if (err)
|
||||
@ -687,10 +638,10 @@ static int hmc5843_suspend(struct device *dev)
|
||||
|
||||
static int hmc5843_resume(struct device *dev)
|
||||
{
|
||||
struct i2c_client *client = to_i2c_client(dev);
|
||||
struct hmc5843_data *data = iio_priv(i2c_get_clientdata(client));
|
||||
struct hmc5843_data *data = iio_priv(i2c_get_clientdata(
|
||||
to_i2c_client(dev)));
|
||||
|
||||
hmc5843_configure(client, data->operating_mode);
|
||||
hmc5843_configure(data->client, data->operating_mode);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -47,11 +47,13 @@ struct hid_sensor_hub_attribute_info {
|
||||
* @hdev: Stores the hid instance.
|
||||
* @vendor_id: Vendor id of hub device.
|
||||
* @product_id: Product id of hub device.
|
||||
* @ref_cnt: Number of MFD clients have opened this device
|
||||
*/
|
||||
struct hid_sensor_hub_device {
|
||||
struct hid_device *hdev;
|
||||
u32 vendor_id;
|
||||
u32 product_id;
|
||||
int ref_cnt;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -74,6 +76,22 @@ struct hid_sensor_hub_callbacks {
|
||||
void *priv);
|
||||
};
|
||||
|
||||
/**
|
||||
* sensor_hub_device_open() - Open hub device
|
||||
* @hsdev: Hub device instance.
|
||||
*
|
||||
* Used to open hid device for sensor hub.
|
||||
*/
|
||||
int sensor_hub_device_open(struct hid_sensor_hub_device *hsdev);
|
||||
|
||||
/**
|
||||
* sensor_hub_device_clode() - Close hub device
|
||||
* @hsdev: Hub device instance.
|
||||
*
|
||||
* Used to clode hid device for sensor hub.
|
||||
*/
|
||||
void sensor_hub_device_close(struct hid_sensor_hub_device *hsdev);
|
||||
|
||||
/* Registration functions */
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user