Commit 27f5a85f authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

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

Merge tag 'iio-for-3.18b' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next

Jonathan writes:

Second round of new IIO drivers, features and cleanups for the 3.18 cycle.

New drivers and part support
* Bosch bmg160 Gyroscope driver
* Dyna-Image al3320a ambient light sensor driver
* Bosh bmi055 gyroscope part driver (accelerometer part supported by bmc150)
* isl29018 - add support for isl29023 and isl29035
* kxcjk-1013 - add support for kxcj9-1008 and kxtj2-1009
* bmc150 - additional part support (BMI055 accelerometer part, BMA255,
  BMA222E, BMA250E and BMA280).  Different resolutions but otherwise similar
  parts.
* bma180 - add BMA250 (note different from the BMA250E support above despite
  the naming).  A lot of driver reworking lead up to this - described below.

New features
* kxcjk1013 - add threshold event support.
* rockchip - document DT bindings.
* isl29018 - ACPI support
* bma180 - enable use without IRQ

Cleanups
* Tree wide - drop owner field assignment if using the module_platform_driver
  helper as that assigns it anyway.
* kxcjk1013 - drop a redundant assignment of the current range and fix a
  a defined but not used warning.
* inv_mpu6050 - Remove an unnecessary cast form a void pointer.
* rockchip - drop and unused variable.
* at91_adc - make a local function static.
* st-sensors-core - correctly handle an error in setting in
  st_sensors_set_drdy_int_pin
* isl29018 - typo fix
* bmc150 - fix incorrect scale value for 16G range (Driver new this cycle)
* bmc150 - fix issues when CONFIG_PM_RUNTIME not set (Driver new this cycle)
* ad7606 - line length tidy up.
* bmg160 - set power state only if PM_RUNTIME is defined.
* ak8975 - fix some unnecessary casting between char * and const char *
* bma180 - prefix remaining bits and bobs with bma180_ and ensure consistent.
         - use a bool instead of an int for state (as its either on or off).
         - expose the temperature channel
         - statically allocate buffers to avoid need for update_scan_mode
           callback.
         - refactor to allow futher chip variants including support for part
           specific config and disable code + different resolutions.
parents caf382fe 2017cff2
What: /sys/bus/iio/devices/triggerX/name = "bmg160-any-motion-devX"
KernelVersion: 3.17
Contact: linux-iio@vger.kernel.org
Description:
The BMG160 gyro kernel module provides an additional trigger,
which sets driver in a mode, where data is pushed to the buffer
only when there is any motion.
Rockchip Successive Approximation Register (SAR) A/D Converter bindings
Required properties:
- compatible: Should be "rockchip,saradc"
- reg: physical base address of the controller and length of memory mapped
region.
- interrupts: The interrupt number to the cpu. The interrupt specifier format
depends on the interrupt controller.
- clocks: Must contain an entry for each entry in clock-names.
- clock-names: Shall be "saradc" for the converter-clock, and "apb_pclk" for
the peripheral clock.
- vref-supply: The regulator supply ADC reference voltage.
- #io-channel-cells: Should be 1, see ../iio-bindings.txt
Example:
saradc: saradc@2006c000 {
compatible = "rockchip,saradc";
reg = <0x2006c000 0x100>;
interrupts = <GIC_SPI 26 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&cru SCLK_SARADC>, <&cru PCLK_SARADC>;
clock-names = "saradc", "apb_pclk";
#io-channel-cells = <1>;
vref-supply = <&vcc18>;
};
...@@ -6,13 +6,13 @@ ...@@ -6,13 +6,13 @@
menu "Accelerometers" menu "Accelerometers"
config BMA180 config BMA180
tristate "Bosch BMA180 3-Axis Accelerometer Driver" tristate "Bosch BMA180/BMA250 3-Axis Accelerometer Driver"
depends on I2C depends on I2C
select IIO_BUFFER select IIO_BUFFER
select IIO_TRIGGERED_BUFFER select IIO_TRIGGERED_BUFFER
help help
Say Y here if you want to build a driver for the Bosch BMA180 Say Y here if you want to build a driver for the Bosch BMA180 or
triaxial acceleration sensor. BMA250 triaxial acceleration sensor.
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 bma180. module will be called bma180.
...@@ -23,7 +23,9 @@ config BMC150_ACCEL ...@@ -23,7 +23,9 @@ config BMC150_ACCEL
select IIO_BUFFER select IIO_BUFFER
select IIO_TRIGGERED_BUFFER select IIO_TRIGGERED_BUFFER
help help
Say yes here to build support for the Bosch BMC150 accelerometer. Say yes here to build support for the following Bosch accelerometers:
BMC150, BMI055, BMA250E, BMA222E, BMA255, BMA280.
Currently this only supports the device via an i2c interface. Currently this only supports the device via an i2c interface.
This is a combo module with both accelerometer and magnetometer. This is a combo module with both accelerometer and magnetometer.
...@@ -97,7 +99,8 @@ config KXCJK1013 ...@@ -97,7 +99,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. triaxial acceleration sensor. This driver also supports KXCJ9-1008
and KXTJ2-1009.
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.
......
This diff is collapsed.
This diff is collapsed.
...@@ -419,7 +419,6 @@ static struct platform_driver hid_accel_3d_platform_driver = { ...@@ -419,7 +419,6 @@ static struct platform_driver hid_accel_3d_platform_driver = {
.id_table = hid_accel_3d_ids, .id_table = hid_accel_3d_ids,
.driver = { .driver = {
.name = KBUILD_MODNAME, .name = KBUILD_MODNAME,
.owner = THIS_MODULE,
}, },
.probe = hid_accel_3d_probe, .probe = hid_accel_3d_probe,
.remove = hid_accel_3d_remove, .remove = hid_accel_3d_remove,
......
This diff is collapsed.
...@@ -266,7 +266,7 @@ static irqreturn_t at91_adc_trigger_handler(int irq, void *p) ...@@ -266,7 +266,7 @@ static irqreturn_t at91_adc_trigger_handler(int irq, void *p)
} }
/* Handler for classic adc channel eoc trigger */ /* Handler for classic adc channel eoc trigger */
void handle_adc_eoc_trigger(int irq, struct iio_dev *idev) static void handle_adc_eoc_trigger(int irq, struct iio_dev *idev)
{ {
struct at91_adc_state *st = iio_priv(idev); struct at91_adc_state *st = iio_priv(idev);
......
...@@ -723,7 +723,6 @@ static struct platform_driver exynos_adc_driver = { ...@@ -723,7 +723,6 @@ static struct platform_driver exynos_adc_driver = {
.remove = exynos_adc_remove, .remove = exynos_adc_remove,
.driver = { .driver = {
.name = "exynos-adc", .name = "exynos-adc",
.owner = THIS_MODULE,
.of_match_table = exynos_adc_match, .of_match_table = exynos_adc_match,
.pm = &exynos_adc_pm_ops, .pm = &exynos_adc_pm_ops,
}, },
......
...@@ -244,7 +244,6 @@ static struct platform_driver lp8788_adc_driver = { ...@@ -244,7 +244,6 @@ static struct platform_driver lp8788_adc_driver = {
.remove = lp8788_adc_remove, .remove = lp8788_adc_remove,
.driver = { .driver = {
.name = LP8788_DEV_ADC, .name = LP8788_DEV_ADC,
.owner = THIS_MODULE,
}, },
}; };
module_platform_driver(lp8788_adc_driver); module_platform_driver(lp8788_adc_driver);
......
...@@ -141,7 +141,6 @@ static int rockchip_saradc_probe(struct platform_device *pdev) ...@@ -141,7 +141,6 @@ static int rockchip_saradc_probe(struct platform_device *pdev)
struct resource *mem; struct resource *mem;
int ret; int ret;
int irq; int irq;
u32 rate;
if (!np) if (!np)
return -ENODEV; return -ENODEV;
......
...@@ -545,7 +545,6 @@ MODULE_DEVICE_TABLE(of, ti_adc_dt_ids); ...@@ -545,7 +545,6 @@ MODULE_DEVICE_TABLE(of, ti_adc_dt_ids);
static struct platform_driver tiadc_driver = { static struct platform_driver tiadc_driver = {
.driver = { .driver = {
.name = "TI-am335x-adc", .name = "TI-am335x-adc",
.owner = THIS_MODULE,
.pm = TIADC_PM_OPS, .pm = TIADC_PM_OPS,
.of_match_table = ti_adc_dt_ids, .of_match_table = ti_adc_dt_ids,
}, },
......
...@@ -883,7 +883,6 @@ static struct platform_driver twl4030_madc_driver = { ...@@ -883,7 +883,6 @@ static struct platform_driver twl4030_madc_driver = {
.remove = twl4030_madc_remove, .remove = twl4030_madc_remove,
.driver = { .driver = {
.name = "twl4030_madc", .name = "twl4030_madc",
.owner = THIS_MODULE,
.of_match_table = of_match_ptr(twl_madc_of_match), .of_match_table = of_match_ptr(twl_madc_of_match),
}, },
}; };
......
...@@ -994,7 +994,6 @@ static struct platform_driver twl6030_gpadc_driver = { ...@@ -994,7 +994,6 @@ static struct platform_driver twl6030_gpadc_driver = {
.remove = twl6030_gpadc_remove, .remove = twl6030_gpadc_remove,
.driver = { .driver = {
.name = DRIVER_NAME, .name = DRIVER_NAME,
.owner = THIS_MODULE,
.pm = &twl6030_gpadc_pm_ops, .pm = &twl6030_gpadc_pm_ops,
.of_match_table = of_twl6030_match_tbl, .of_match_table = of_twl6030_match_tbl,
}, },
......
...@@ -698,7 +698,6 @@ static struct platform_driver vf610_adc_driver = { ...@@ -698,7 +698,6 @@ static struct platform_driver vf610_adc_driver = {
.remove = vf610_adc_remove, .remove = vf610_adc_remove,
.driver = { .driver = {
.name = DRIVER_NAME, .name = DRIVER_NAME,
.owner = THIS_MODULE,
.of_match_table = vf610_adc_match, .of_match_table = vf610_adc_match,
.pm = &vf610_adc_pm_ops, .pm = &vf610_adc_pm_ops,
}, },
......
...@@ -145,7 +145,6 @@ static int vprbrd_adc_probe(struct platform_device *pdev) ...@@ -145,7 +145,6 @@ static int vprbrd_adc_probe(struct platform_device *pdev)
static struct platform_driver vprbrd_adc_driver = { static struct platform_driver vprbrd_adc_driver = {
.driver = { .driver = {
.name = "viperboard-adc", .name = "viperboard-adc",
.owner = THIS_MODULE,
}, },
.probe = vprbrd_adc_probe, .probe = vprbrd_adc_probe,
}; };
......
...@@ -306,8 +306,11 @@ int st_sensors_init_sensor(struct iio_dev *indio_dev, ...@@ -306,8 +306,11 @@ int st_sensors_init_sensor(struct iio_dev *indio_dev,
if (of_pdata) if (of_pdata)
pdata = of_pdata; pdata = of_pdata;
if (pdata) if (pdata) {
err = st_sensors_set_drdy_int_pin(indio_dev, pdata); err = st_sensors_set_drdy_int_pin(indio_dev, pdata);
if (err < 0)
return err;
}
err = st_sensors_set_enable(indio_dev, false); err = st_sensors_set_enable(indio_dev, false);
if (err < 0) if (err < 0)
......
...@@ -50,6 +50,17 @@ config ADXRS450 ...@@ -50,6 +50,17 @@ config ADXRS450
This driver can also be built as a module. If so, the module This driver can also be built as a module. If so, the module
will be called adxrs450. will be called adxrs450.
config BMG160
tristate "BOSCH BMG160 Gyro Sensor"
depends on I2C
select IIO_TRIGGERED_BUFFER if IIO_BUFFER
help
Say yes here to build support for Bosch BMG160 Tri-axis Gyro Sensor
driver. This driver also supports BMI055 gyroscope.
This driver can also be built as a module. If so, the module
will be called bmg160.
config HID_SENSOR_GYRO_3D config HID_SENSOR_GYRO_3D
depends on HID_SENSOR_HUB depends on HID_SENSOR_HUB
select IIO_BUFFER select IIO_BUFFER
......
...@@ -8,6 +8,7 @@ obj-$(CONFIG_ADIS16130) += adis16130.o ...@@ -8,6 +8,7 @@ obj-$(CONFIG_ADIS16130) += adis16130.o
obj-$(CONFIG_ADIS16136) += adis16136.o obj-$(CONFIG_ADIS16136) += adis16136.o
obj-$(CONFIG_ADIS16260) += adis16260.o obj-$(CONFIG_ADIS16260) += adis16260.o
obj-$(CONFIG_ADXRS450) += adxrs450.o obj-$(CONFIG_ADXRS450) += adxrs450.o
obj-$(CONFIG_BMG160) += bmg160.o
obj-$(CONFIG_HID_SENSOR_GYRO_3D) += hid-sensor-gyro-3d.o obj-$(CONFIG_HID_SENSOR_GYRO_3D) += hid-sensor-gyro-3d.o
......
This diff is collapsed.
...@@ -416,7 +416,6 @@ static struct platform_driver hid_gyro_3d_platform_driver = { ...@@ -416,7 +416,6 @@ static struct platform_driver hid_gyro_3d_platform_driver = {
.id_table = hid_gyro_3d_ids, .id_table = hid_gyro_3d_ids,
.driver = { .driver = {
.name = KBUILD_MODNAME, .name = KBUILD_MODNAME,
.owner = THIS_MODULE,
}, },
.probe = hid_gyro_3d_probe, .probe = hid_gyro_3d_probe,
.remove = hid_gyro_3d_remove, .remove = hid_gyro_3d_remove,
......
...@@ -281,7 +281,6 @@ static int dht11_probe(struct platform_device *pdev) ...@@ -281,7 +281,6 @@ static int dht11_probe(struct platform_device *pdev)
static struct platform_driver dht11_driver = { static struct platform_driver dht11_driver = {
.driver = { .driver = {
.name = DRIVER_NAME, .name = DRIVER_NAME,
.owner = THIS_MODULE,
.of_match_table = dht11_dt_ids, .of_match_table = dht11_dt_ids,
}, },
.probe = dht11_probe, .probe = dht11_probe,
......
...@@ -673,8 +673,7 @@ static int inv_mpu_probe(struct i2c_client *client, ...@@ -673,8 +673,7 @@ static int inv_mpu_probe(struct i2c_client *client,
st = iio_priv(indio_dev); st = iio_priv(indio_dev);
st->client = client; st->client = client;
pdata = (struct inv_mpu6050_platform_data pdata = dev_get_platdata(&client->dev);
*)dev_get_platdata(&client->dev);
if (pdata) if (pdata)
st->plat_data = *pdata; st->plat_data = *pdata;
/* power is turned on inside check chip type*/ /* power is turned on inside check chip type*/
......
...@@ -17,6 +17,16 @@ config ADJD_S311 ...@@ -17,6 +17,16 @@ config ADJD_S311
This driver can also be built as a module. If so, the module This driver can also be built as a module. If so, the module
will be called adjd_s311. will be called adjd_s311.
config AL3320A
tristate "AL3320A ambient light sensor"
depends on I2C
help
Say Y here if you want to build a driver for the Dyna Image AL3320A
ambient light sensor.
To compile this driver as a module, choose M here: the
module will be called al3320a.
config APDS9300 config APDS9300
tristate "APDS9300 ambient light sensor" tristate "APDS9300 ambient light sensor"
depends on I2C depends on I2C
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
# When adding new entries keep the list in alphabetical order # When adding new entries keep the list in alphabetical order
obj-$(CONFIG_ADJD_S311) += adjd_s311.o obj-$(CONFIG_ADJD_S311) += adjd_s311.o
obj-$(CONFIG_AL3320A) += al3320a.o
obj-$(CONFIG_APDS9300) += apds9300.o obj-$(CONFIG_APDS9300) += apds9300.o
obj-$(CONFIG_CM32181) += cm32181.o obj-$(CONFIG_CM32181) += cm32181.o
obj-$(CONFIG_CM36651) += cm36651.o obj-$(CONFIG_CM36651) += cm36651.o
......
/*
* AL3320A - Dyna Image Ambient Light Sensor
*
* Copyright (c) 2014, Intel Corporation.
*
* This file is subject to the terms and conditions of version 2 of
* the GNU General Public License. See the file COPYING in the main
* directory of this archive for more details.
*
* IIO driver for AL3320A (7-bit I2C slave address 0x1C).
*
* TODO: interrupt support, thresholds
*
*/
#include <linux/module.h>
#include <linux/init.h>
#include <linux/i2c.h>
#include <linux/iio/iio.h>
#include <linux/iio/sysfs.h>
#define AL3320A_DRV_NAME "al3320a"
#define AL3320A_REG_CONFIG 0x00
#define AL3320A_REG_STATUS 0x01
#define AL3320A_REG_INT 0x02
#define AL3320A_REG_WAIT 0x06
#define AL3320A_REG_CONFIG_RANGE 0x07
#define AL3320A_REG_PERSIST 0x08
#define AL3320A_REG_MEAN_TIME 0x09
#define AL3320A_REG_ADUMMY 0x0A
#define AL3320A_REG_DATA_LOW 0x22
#define AL3320A_REG_LOW_THRESH_LOW 0x30
#define AL3320A_REG_LOW_THRESH_HIGH 0x31
#define AL3320A_REG_HIGH_THRESH_LOW 0x32
#define AL3320A_REG_HIGH_THRESH_HIGH 0x33
#define AL3320A_CONFIG_DISABLE 0x00
#define AL3320A_CONFIG_ENABLE 0x01
#define AL3320A_GAIN_SHIFT 1
#define AL3320A_GAIN_MASK (BIT(2) | BIT(1))
/* chip params default values */
#define AL3320A_DEFAULT_MEAN_TIME 4
#define AL3320A_DEFAULT_WAIT_TIME 0 /* no waiting */
#define AL3320A_SCALE_AVAILABLE "0.512 0.128 0.032 0.01"
enum al3320a_range {
AL3320A_RANGE_1, /* 33.28 Klx */
AL3320A_RANGE_2, /* 8.32 Klx */
AL3320A_RANGE_3, /* 2.08 Klx */
AL3320A_RANGE_4 /* 0.65 Klx */
};
static const int al3320a_scales[][2] = {
{0, 512000}, {0, 128000}, {0, 32000}, {0, 10000}
};
struct al3320a_data {
struct i2c_client *client;
};
static const struct iio_chan_spec al3320a_channels[] = {
{
.type = IIO_LIGHT,
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
BIT(IIO_CHAN_INFO_SCALE),
}
};
static IIO_CONST_ATTR(in_illuminance_scale_available, AL3320A_SCALE_AVAILABLE);
static struct attribute *al3320a_attributes[] = {
&iio_const_attr_in_illuminance_scale_available.dev_attr.attr,
NULL,
};
static const struct attribute_group al3320a_attribute_group = {
.attrs = al3320a_attributes,
};
static int al3320a_init(struct al3320a_data *data)
{
int ret;
/* power on */
ret = i2c_smbus_write_byte_data(data->client, AL3320A_REG_CONFIG,
AL3320A_CONFIG_ENABLE);
if (ret < 0)
return ret;
ret = i2c_smbus_write_byte_data(data->client, AL3320A_REG_CONFIG_RANGE,
AL3320A_RANGE_3 << AL3320A_GAIN_SHIFT);
if (ret < 0)
return ret;
ret = i2c_smbus_write_byte_data(data->client, AL3320A_REG_MEAN_TIME,
AL3320A_DEFAULT_MEAN_TIME);
if (ret < 0)
return ret;
ret = i2c_smbus_write_byte_data(data->client, AL3320A_REG_WAIT,
AL3320A_DEFAULT_WAIT_TIME);
if (ret < 0)
return ret;
return 0;
}
static int al3320a_read_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan, int *val,
int *val2, long mask)
{
struct al3320a_data *data = iio_priv(indio_dev);
int ret;
switch (mask) {
case IIO_CHAN_INFO_RAW:
/*
* ALS ADC value is stored in two adjacent registers:
* - low byte of output is stored at AL3320A_REG_DATA_LOW
* - high byte of output is stored at AL3320A_REG_DATA_LOW + 1
*/
ret = i2c_smbus_read_word_data(data->client,
AL3320A_REG_DATA_LOW);
if (ret < 0)
return ret;
*val = ret;
return IIO_VAL_INT;
case IIO_CHAN_INFO_SCALE:
ret = i2c_smbus_read_byte_data(data->client,
AL3320A_REG_CONFIG_RANGE);
if (ret < 0)
return ret;
ret = (ret & AL3320A_GAIN_MASK) >> AL3320A_GAIN_SHIFT;
*val = al3320a_scales[ret][0];
*val2 = al3320a_scales[ret][1];
return IIO_VAL_INT_PLUS_MICRO;
}
return -EINVAL;
}
static int al3320a_write_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan, int val,
int val2, long mask)
{
struct al3320a_data *data = iio_priv(indio_dev);
int i;
switch (mask) {
case IIO_CHAN_INFO_SCALE:
for (i = 0; i < ARRAY_SIZE(al3320a_scales); i++) {
if (val == al3320a_scales[i][0] &&
val2 == al3320a_scales[i][1])
return i2c_smbus_write_byte_data(data->client,
AL3320A_REG_CONFIG_RANGE,
i << AL3320A_GAIN_SHIFT);
}
break;
}
return -EINVAL;
}
static const struct iio_info al3320a_info = {
.driver_module = THIS_MODULE,
.read_raw = al3320a_read_raw,
.write_raw = al3320a_write_raw,
.attrs = &al3320a_attribute_group,
};
static int al3320a_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct al3320a_data *data;
struct iio_dev *indio_dev;
int ret;
indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
if (!indio_dev)
return -ENOMEM;
data = iio_priv(indio_dev);
i2c_set_clientdata(client, indio_dev);
data->client = client;
indio_dev->dev.parent = &client->dev;
indio_dev->info = &al3320a_info;
indio_dev->name = AL3320A_DRV_NAME;
indio_dev->channels = al3320a_channels;
indio_dev->num_channels = ARRAY_SIZE(al3320a_channels);
indio_dev->modes = INDIO_DIRECT_MODE;
ret = al3320a_init(data);
if (ret < 0) {
dev_err(&client->dev, "al3320a chip init failed\n");
return ret;
}
return devm_iio_device_register(&client->dev, indio_dev);
}
static int al3320a_remove(struct i2c_client *client)
{
return i2c_smbus_write_byte_data(client, AL3320A_REG_CONFIG,
AL3320A_CONFIG_DISABLE);
}
static const struct i2c_device_id al3320a_id[] = {
{"al3320a", 0},
{}
};
MODULE_DEVICE_TABLE(i2c, al3320a_id);
static struct i2c_driver al3320a_driver = {
.driver = {
.name = AL3320A_DRV_NAME,
},
.probe = al3320a_probe,
.remove = al3320a_remove,
.id_table = al3320a_id,
};
module_i2c_driver(al3320a_driver);
MODULE_AUTHOR("Daniel Baluta <daniel.baluta@intel.com>");
MODULE_DESCRIPTION("AL3320A Ambient Light Sensor driver");
MODULE_LICENSE("GPL v2");
...@@ -381,7 +381,6 @@ static struct platform_driver hid_als_platform_driver = { ...@@ -381,7 +381,6 @@ static struct platform_driver hid_als_platform_driver = {
.id_table = hid_als_ids, .id_table = hid_als_ids,
.driver = { .driver = {
.name = KBUILD_MODNAME, .name = KBUILD_MODNAME,
.owner = THIS_MODULE,
}, },
.probe = hid_als_probe, .probe = hid_als_probe,
.remove = hid_als_remove, .remove = hid_als_remove,
......
...@@ -373,7 +373,6 @@ static struct platform_driver hid_prox_platform_driver = { ...@@ -373,7 +373,6 @@ static struct platform_driver hid_prox_platform_driver = {
.id_table = hid_prox_ids, .id_table = hid_prox_ids,
.driver = { .driver = {
.name = KBUILD_MODNAME, .name = KBUILD_MODNAME,
.owner = THIS_MODULE,
}, },
.probe = hid_prox_probe, .probe = hid_prox_probe,
.remove = hid_prox_remove, .remove = hid_prox_remove,
......
...@@ -915,7 +915,6 @@ static int lm3533_als_remove(struct platform_device *pdev) ...@@ -915,7 +915,6 @@ static int lm3533_als_remove(struct platform_device *pdev)
static struct platform_driver lm3533_als_driver = { static struct platform_driver lm3533_als_driver = {
.driver = { .driver = {
.name = "lm3533-als", .name = "lm3533-als",
.owner = THIS_MODULE,
}, },
.probe = lm3533_als_probe, .probe = lm3533_als_probe,
.remove = lm3533_als_remove, .remove = lm3533_als_remove,
......
...@@ -477,8 +477,8 @@ static const struct acpi_device_id ak_acpi_match[] = { ...@@ -477,8 +477,8 @@ static const struct acpi_device_id ak_acpi_match[] = {
}; };
MODULE_DEVICE_TABLE(acpi, ak_acpi_match); MODULE_DEVICE_TABLE(acpi, ak_acpi_match);
static char *ak8975_match_acpi_device(struct device *dev, static const char *ak8975_match_acpi_device(struct device *dev,
enum asahi_compass_chipset *chipset) enum asahi_compass_chipset *chipset)
{ {
const struct acpi_device_id *id; const struct acpi_device_id *id;
...@@ -487,7 +487,7 @@ static char *ak8975_match_acpi_device(struct device *dev, ...@@ -487,7 +487,7 @@ static char *ak8975_match_acpi_device(struct device *dev,
return NULL; return NULL;
*chipset = (int)id->driver_data; *chipset = (int)id->driver_data;
return (char *)dev_name(dev); return dev_name(dev);
} }
static int ak8975_probe(struct i2c_client *client, static int ak8975_probe(struct i2c_client *client,
...@@ -497,7 +497,7 @@ static int ak8975_probe(struct i2c_client *client, ...@@ -497,7 +497,7 @@ static int ak8975_probe(struct i2c_client *client,
struct iio_dev *indio_dev; struct iio_dev *indio_dev;
int eoc_gpio; int eoc_gpio;
int err; int err;
char *name = NULL; const char *name = NULL;
/* Grab and set up the supplied GPIO. */ /* Grab and set up the supplied GPIO. */
if (client->dev.platform_data) if (client->dev.platform_data)
...@@ -539,7 +539,7 @@ static int ak8975_probe(struct i2c_client *client, ...@@ -539,7 +539,7 @@ static int ak8975_probe(struct i2c_client *client,
if (id) { if (id) {
data->chipset = data->chipset =
(enum asahi_compass_chipset)(id->driver_data); (enum asahi_compass_chipset)(id->driver_data);
name = (char *) id->name; name = id->name;
} else if (ACPI_HANDLE(&client->dev)) } else if (ACPI_HANDLE(&client->dev))
name = ak8975_match_acpi_device(&client->dev, &data->chipset); name = ak8975_match_acpi_device(&client->dev, &data->chipset);
else else
......
...@@ -530,7 +530,6 @@ static struct platform_driver hid_magn_3d_platform_driver = { ...@@ -530,7 +530,6 @@ static struct platform_driver hid_magn_3d_platform_driver = {
.id_table = hid_magn_3d_ids, .id_table = hid_magn_3d_ids,
.driver = { .driver = {
.name = KBUILD_MODNAME, .name = KBUILD_MODNAME,
.owner = THIS_MODULE,
}, },
.probe = hid_magn_3d_probe, .probe = hid_magn_3d_probe,
.remove = hid_magn_3d_remove, .remove = hid_magn_3d_remove,
......
...@@ -437,7 +437,6 @@ static struct platform_driver hid_incl_3d_platform_driver = { ...@@ -437,7 +437,6 @@ static struct platform_driver hid_incl_3d_platform_driver = {
.id_table = hid_incl_3d_ids, .id_table = hid_incl_3d_ids,
.driver = { .driver = {
.name = KBUILD_MODNAME, .name = KBUILD_MODNAME,
.owner = THIS_MODULE,
}, },
.probe = hid_incl_3d_probe, .probe = hid_incl_3d_probe,
.remove = hid_incl_3d_remove, .remove = hid_incl_3d_remove,
......
...@@ -334,7 +334,6 @@ static struct platform_driver hid_dev_rot_platform_driver = { ...@@ -334,7 +334,6 @@ static struct platform_driver hid_dev_rot_platform_driver = {
.id_table = hid_dev_rot_ids, .id_table = hid_dev_rot_ids,
.driver = { .driver = {
.name = KBUILD_MODNAME, .name = KBUILD_MODNAME,
.owner = THIS_MODULE,
}, },
.probe = hid_dev_rot_probe, .probe = hid_dev_rot_probe,
.remove = hid_dev_rot_remove, .remove = hid_dev_rot_remove,
......
...@@ -382,7 +382,6 @@ static struct platform_driver hid_press_platform_driver = { ...@@ -382,7 +382,6 @@ static struct platform_driver hid_press_platform_driver = {
.id_table = hid_press_ids, .id_table = hid_press_ids,
.driver = { .driver = {
.name = KBUILD_MODNAME, .name = KBUILD_MODNAME,
.owner = THIS_MODULE,
}, },
.probe = hid_press_probe, .probe = hid_press_probe,
.remove = hid_press_remove, .remove = hid_press_remove,
......
...@@ -109,7 +109,6 @@ static struct platform_driver iio_interrupt_trigger_driver = { ...@@ -109,7 +109,6 @@ static struct platform_driver iio_interrupt_trigger_driver = {
.remove = iio_interrupt_trigger_remove, .remove = iio_interrupt_trigger_remove,
.driver = { .driver = {
.name = "iio_interrupt_trigger", .name = "iio_interrupt_trigger",
.owner = THIS_MODULE,
}, },
}; };
......
...@@ -140,7 +140,7 @@ static ssize_t ad7606_store_range(struct device *dev, ...@@ -140,7 +140,7 @@ static ssize_t ad7606_store_range(struct device *dev,
return count; return count;
} }
static IIO_DEVICE_ATTR(in_voltage_range, S_IRUGO | S_IWUSR, \ static IIO_DEVICE_ATTR(in_voltage_range, S_IRUGO | S_IWUSR,
ad7606_show_range, ad7606_store_range, 0); ad7606_show_range, ad7606_store_range, 0);
static IIO_CONST_ATTR(in_voltage_range_available, "5000 10000"); static IIO_CONST_ATTR(in_voltage_range_available, "5000 10000");
......
/* /*
* A iio driver for the light sensor ISL 29018. * A iio driver for the light sensor ISL 29018/29023/29035.
* *
* IIO driver for monitoring ambient light intensity in luxi, proximity * IIO driver for monitoring ambient light intensity in luxi, proximity
* sensing and infrared sensing. * sensing and infrared sensing.
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/iio/iio.h> #include <linux/iio/iio.h>
#include <linux/iio/sysfs.h> #include <linux/iio/sysfs.h>
#include <linux/acpi.h>
#define CONVERSION_TIME_MS 100 #define CONVERSION_TIME_MS 100
...@@ -58,10 +59,18 @@ ...@@ -58,10 +59,18 @@
#define ISL29018_TEST_SHIFT 0 #define ISL29018_TEST_SHIFT 0
#define ISL29018_TEST_MASK (0xFF << ISL29018_TEST_SHIFT) #define ISL29018_TEST_MASK (0xFF << ISL29018_TEST_SHIFT)
#define ISL29035_REG_DEVICE_ID 0x0F
#define ISL29035_DEVICE_ID_SHIFT 0x03
#define ISL29035_DEVICE_ID_MASK (0x7 << ISL29035_DEVICE_ID_SHIFT)
#define ISL29035_DEVICE_ID 0x5
#define ISL29035_BOUT_SHIFT 0x07
#define ISL29035_BOUT_MASK (0x01 << ISL29035_BOUT_SHIFT)
struct isl29018_chip { struct isl29018_chip {
struct device *dev; struct device *dev;
struct regmap *regmap; struct regmap *regmap;
struct mutex lock; struct mutex lock;
int type;
unsigned int lux_scale; unsigned int lux_scale;
unsigned int lux_uscale; unsigned int lux_uscale;
unsigned int range; unsigned int range;
...@@ -407,23 +416,35 @@ static int isl29018_read_raw(struct iio_dev *indio_dev, ...@@ -407,23 +416,35 @@ static int isl29018_read_raw(struct iio_dev *indio_dev,
return ret; return ret;
} }
#define ISL29018_LIGHT_CHANNEL { \
.type = IIO_LIGHT, \
.indexed = 1, \
.channel = 0, \
.info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) | \
BIT(IIO_CHAN_INFO_CALIBSCALE), \
}
#define ISL29018_IR_CHANNEL { \
.type = IIO_INTENSITY, \
.modified = 1, \
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
.channel2 = IIO_MOD_LIGHT_IR, \
}
#define ISL29018_PROXIMITY_CHANNEL { \
.type = IIO_PROXIMITY, \
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
}
static const struct iio_chan_spec isl29018_channels[] = { static const struct iio_chan_spec isl29018_channels[] = {
{ ISL29018_LIGHT_CHANNEL,
.type = IIO_LIGHT, ISL29018_IR_CHANNEL,
.indexed = 1, ISL29018_PROXIMITY_CHANNEL,
.channel = 0, };
.info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) |
BIT(IIO_CHAN_INFO_CALIBSCALE), static const struct iio_chan_spec isl29023_channels[] = {
}, { ISL29018_LIGHT_CHANNEL,
.type = IIO_INTENSITY, ISL29018_IR_CHANNEL,
.modified = 1,
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
.channel2 = IIO_MOD_LIGHT_IR,
}, {
/* Unindexed in current ABI. But perhaps it should be. */
.type = IIO_PROXIMITY,
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
}
}; };
static IIO_DEVICE_ATTR(range, S_IRUGO | S_IWUSR, show_range, store_range, 0); static IIO_DEVICE_ATTR(range, S_IRUGO | S_IWUSR, show_range, store_range, 0);
...@@ -447,16 +468,63 @@ static struct attribute *isl29018_attributes[] = { ...@@ -447,16 +468,63 @@ static struct attribute *isl29018_attributes[] = {
NULL NULL
}; };
static const struct attribute_group isl29108_group = { static struct attribute *isl29023_attributes[] = {
ISL29018_DEV_ATTR(range),
ISL29018_CONST_ATTR(range_available),
ISL29018_DEV_ATTR(adc_resolution),
ISL29018_CONST_ATTR(adc_resolution_available),
NULL
};
static const struct attribute_group isl29018_group = {
.attrs = isl29018_attributes, .attrs = isl29018_attributes,
}; };
static const struct attribute_group isl29023_group = {
.attrs = isl29023_attributes,
};
static int isl29035_detect(struct isl29018_chip *chip)
{
int status;
unsigned int id;
status = regmap_read(chip->regmap, ISL29035_REG_DEVICE_ID, &id);
if (status < 0) {
dev_err(chip->dev,
"Error reading ID register with error %d\n",
status);
return status;
}
id = (id & ISL29035_DEVICE_ID_MASK) >> ISL29035_DEVICE_ID_SHIFT;
if (id != ISL29035_DEVICE_ID)
return -ENODEV;
/* clear out brownout bit */
return regmap_update_bits(chip->regmap, ISL29035_REG_DEVICE_ID,
ISL29035_BOUT_MASK, 0);
}
enum {
isl29018,
isl29023,
isl29035,
};
static int isl29018_chip_init(struct isl29018_chip *chip) static int isl29018_chip_init(struct isl29018_chip *chip)
{ {
int status; int status;
unsigned int new_adc_bit; unsigned int new_adc_bit;
unsigned int new_range; unsigned int new_range;
if (chip->type == isl29035) {
status = isl29035_detect(chip);
if (status < 0)
return status;
}
/* Code added per Intersil Application Note 1534: /* Code added per Intersil Application Note 1534:
* When VDD sinks to approximately 1.8V or below, some of * When VDD sinks to approximately 1.8V or below, some of
* the part's registers may change their state. When VDD * the part's registers may change their state. When VDD
...@@ -510,8 +578,15 @@ static int isl29018_chip_init(struct isl29018_chip *chip) ...@@ -510,8 +578,15 @@ static int isl29018_chip_init(struct isl29018_chip *chip)
return 0; return 0;
} }
static const struct iio_info isl29108_info = { static const struct iio_info isl29018_info = {
.attrs = &isl29108_group, .attrs = &isl29018_group,
.driver_module = THIS_MODULE,
.read_raw = &isl29018_read_raw,
.write_raw = &isl29018_write_raw,
};
static const struct iio_info isl29023_info = {
.attrs = &isl29023_group,
.driver_module = THIS_MODULE, .driver_module = THIS_MODULE,
.read_raw = &isl29018_read_raw, .read_raw = &isl29018_read_raw,
.write_raw = &isl29018_write_raw, .write_raw = &isl29018_write_raw,
...@@ -524,6 +599,7 @@ static bool is_volatile_reg(struct device *dev, unsigned int reg) ...@@ -524,6 +599,7 @@ static bool is_volatile_reg(struct device *dev, unsigned int reg)
case ISL29018_REG_ADD_DATA_MSB: case ISL29018_REG_ADD_DATA_MSB:
case ISL29018_REG_ADD_COMMAND1: case ISL29018_REG_ADD_COMMAND1:
case ISL29018_REG_TEST: case ISL29018_REG_TEST:
case ISL29035_REG_DEVICE_ID:
return true; return true;
default: default:
return false; return false;
...@@ -543,12 +619,66 @@ static const struct regmap_config isl29018_regmap_config = { ...@@ -543,12 +619,66 @@ static const struct regmap_config isl29018_regmap_config = {
.cache_type = REGCACHE_RBTREE, .cache_type = REGCACHE_RBTREE,
}; };
/* isl29035_regmap_config: regmap configuration for ISL29035 */
static const struct regmap_config isl29035_regmap_config = {
.reg_bits = 8,
.val_bits = 8,
.volatile_reg = is_volatile_reg,
.max_register = ISL29035_REG_DEVICE_ID,
.num_reg_defaults_raw = ISL29035_REG_DEVICE_ID + 1,
.cache_type = REGCACHE_RBTREE,
};
struct chip_info {
const struct iio_chan_spec *channels;
int num_channels;
const struct iio_info *indio_info;
const struct regmap_config *regmap_cfg;
};
static const struct chip_info chip_info_tbl[] = {
[isl29018] = {
.channels = isl29018_channels,
.num_channels = ARRAY_SIZE(isl29018_channels),
.indio_info = &isl29018_info,
.regmap_cfg = &isl29018_regmap_config,
},
[isl29023] = {
.channels = isl29023_channels,
.num_channels = ARRAY_SIZE(isl29023_channels),
.indio_info = &isl29023_info,
.regmap_cfg = &isl29018_regmap_config,
},
[isl29035] = {
.channels = isl29023_channels,
.num_channels = ARRAY_SIZE(isl29023_channels),
.indio_info = &isl29023_info,
.regmap_cfg = &isl29035_regmap_config,
},
};
static const char *isl29018_match_acpi_device(struct device *dev, int *data)
{
const struct acpi_device_id *id;
id = acpi_match_device(dev->driver->acpi_match_table, dev);
if (!id)
return NULL;
*data = (int) id->driver_data;
return dev_name(dev);
}
static int isl29018_probe(struct i2c_client *client, static int isl29018_probe(struct i2c_client *client,
const struct i2c_device_id *id) const struct i2c_device_id *id)
{ {
struct isl29018_chip *chip; struct isl29018_chip *chip;
struct iio_dev *indio_dev; struct iio_dev *indio_dev;
int err; int err;
const char *name = NULL;
int dev_id = 0;
indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*chip)); indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*chip));
if (indio_dev == NULL) { if (indio_dev == NULL) {
...@@ -560,15 +690,25 @@ static int isl29018_probe(struct i2c_client *client, ...@@ -560,15 +690,25 @@ static int isl29018_probe(struct i2c_client *client,
i2c_set_clientdata(client, indio_dev); i2c_set_clientdata(client, indio_dev);
chip->dev = &client->dev; chip->dev = &client->dev;
if (id) {
name = id->name;
dev_id = id->driver_data;
}
if (ACPI_HANDLE(&client->dev))
name = isl29018_match_acpi_device(&client->dev, &dev_id);
mutex_init(&chip->lock); mutex_init(&chip->lock);
chip->type = dev_id;
chip->lux_scale = 1; chip->lux_scale = 1;
chip->lux_uscale = 0; chip->lux_uscale = 0;
chip->range = 1000; chip->range = 1000;
chip->adc_bit = 16; chip->adc_bit = 16;
chip->suspended = false; chip->suspended = false;
chip->regmap = devm_regmap_init_i2c(client, &isl29018_regmap_config); chip->regmap = devm_regmap_init_i2c(client,
chip_info_tbl[dev_id].regmap_cfg);
if (IS_ERR(chip->regmap)) { if (IS_ERR(chip->regmap)) {
err = PTR_ERR(chip->regmap); err = PTR_ERR(chip->regmap);
dev_err(chip->dev, "regmap initialization failed: %d\n", err); dev_err(chip->dev, "regmap initialization failed: %d\n", err);
...@@ -579,10 +719,10 @@ static int isl29018_probe(struct i2c_client *client, ...@@ -579,10 +719,10 @@ static int isl29018_probe(struct i2c_client *client,
if (err) if (err)
return err; return err;
indio_dev->info = &isl29108_info; indio_dev->info = chip_info_tbl[dev_id].indio_info;
indio_dev->channels = isl29018_channels; indio_dev->channels = chip_info_tbl[dev_id].channels;
indio_dev->num_channels = ARRAY_SIZE(isl29018_channels); indio_dev->num_channels = chip_info_tbl[dev_id].num_channels;
indio_dev->name = id->name; indio_dev->name = name;
indio_dev->dev.parent = &client->dev; indio_dev->dev.parent = &client->dev;
indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->modes = INDIO_DIRECT_MODE;
err = devm_iio_device_register(&client->dev, indio_dev); err = devm_iio_device_register(&client->dev, indio_dev);
...@@ -632,8 +772,18 @@ static SIMPLE_DEV_PM_OPS(isl29018_pm_ops, isl29018_suspend, isl29018_resume); ...@@ -632,8 +772,18 @@ static SIMPLE_DEV_PM_OPS(isl29018_pm_ops, isl29018_suspend, isl29018_resume);
#define ISL29018_PM_OPS NULL #define ISL29018_PM_OPS NULL
#endif #endif
static const struct acpi_device_id isl29018_acpi_match[] = {
{"ISL29018", isl29018},
{"ISL29023", isl29023},
{"ISL29035", isl29035},
{},
};
MODULE_DEVICE_TABLE(acpi, isl29018_acpi_match);
static const struct i2c_device_id isl29018_id[] = { static const struct i2c_device_id isl29018_id[] = {
{"isl29018", 0}, {"isl29018", isl29018},
{"isl29023", isl29023},
{"isl29035", isl29035},
{} {}
}; };
...@@ -641,6 +791,8 @@ MODULE_DEVICE_TABLE(i2c, isl29018_id); ...@@ -641,6 +791,8 @@ MODULE_DEVICE_TABLE(i2c, isl29018_id);
static const struct of_device_id isl29018_of_match[] = { static const struct of_device_id isl29018_of_match[] = {
{ .compatible = "isil,isl29018", }, { .compatible = "isil,isl29018", },
{ .compatible = "isil,isl29023", },
{ .compatible = "isil,isl29035", },
{ }, { },
}; };
MODULE_DEVICE_TABLE(of, isl29018_of_match); MODULE_DEVICE_TABLE(of, isl29018_of_match);
...@@ -649,6 +801,7 @@ static struct i2c_driver isl29018_driver = { ...@@ -649,6 +801,7 @@ static struct i2c_driver isl29018_driver = {
.class = I2C_CLASS_HWMON, .class = I2C_CLASS_HWMON,
.driver = { .driver = {
.name = "isl29018", .name = "isl29018",
.acpi_match_table = ACPI_PTR(isl29018_acpi_match),
.pm = ISL29018_PM_OPS, .pm = ISL29018_PM_OPS,
.owner = THIS_MODULE, .owner = THIS_MODULE,
.of_match_table = isl29018_of_match, .of_match_table = isl29018_of_match,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment