You've already forked linux-apfs
mirror of
https://github.com/linux-apfs/linux-apfs.git
synced 2026-05-01 15:00:59 -07:00
Merge tag 'iio-for-4.12b' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next
Jonathan writes:
2nd set of new device support, features and cleanups for IIO in the 4.12 cycle
A good collection of outreachy related patches in here - mostly staging
driver cleanup. Also a fair number of patches added explicit OF device ID
tables for i2c drivers - a precursor to dropping (eventually) the implicit
probing.
New Device Support
* Allwinner SoC ADC.
- So far covers the sun4i-a10, sun5i-a13 and sun6i-a31 general purpose ADCs,
including thermal side of things.
This missed the last cycle due to my incompetence, so good to get in now,
particularly as various patches dependent on it are appearing.
* ltc2632
- new driver supporting ltc2632-l12, ltc2632-l10, ltc2632-l8, ltc2632-h12,
ltc-2632-h10, ltc-2632-h8 dacs
Cleanups
* Documentation
- drop a broken reference to i2c/trivial-devices
* ad2s1200
- drop & from function pointers for consistency.
* ad2s1210
- formatting fixes.
* ad7152
- octal permissions instead of symbolic.
- drop & from function pointers for consistent usage.
* ad7192
- drop & from function pointers for consistent usage.
* ad7280
- replace core mlock usage with a local lock as mlock is intended only to
protect the current device state (direct reads, or triggered and buffered)
* ad7746
- drop & from function pointers for consistent usage.
- replace core mlock usage with a local lock as mlock is intended only to
protect the current device state (direct reads, or triggered and buffered)
* ad7754
- move contents of header file into source file as not used anywhere else.
* ad7759
- move contents of header file into source file as not used anywhere else.
* ad7780
- drop & from function pointers for consistent usage.
* ad7832
- replace core mlock usage with a local lock as mlock is intended only to
protect the current device state (direct reads, or triggered and buffered)
* ad9834
- replace core mlock usage with a local lock as mlock is intended only to
protect the current device state (direct reads, or triggered and buffered)
- drop an unnecessary goto in favour of direct return.
* adis16060
- drop & from function pointers as inconsistent.
* adis16201
- drop a local mutex as the adis core already protects everything necessary.
- drop & from function pointers for consistent usage.
* adis16203
- drop & from function pointers for consistent usage.
* adis16209
- drop a local mutex as the adis core already protects everything necessary.
- use an enum for scan index giving slightly nicer code.
- drop & from function pointers for consistent usage.
* adis16240
- drop a local mutex as the adis core already protects everything necessary.
- use an enum for scan index giving slightly nicer code.
- drop & from function pointers for consistent usage.
* apds9960
- add OF device ID table.
* bma180
- add OF device ID table.
- prefer unsigned int to bare use of unsigned.
* bmc150_magn
- add OF device ID table.
* hmp03
- add OF device ID table.
* ina2xx
- add OF device ID table.
* itg3200
- add OF device ID table.
* mag3110
- add OF device ID table.
* max11100
- remove .owner field as it is set by the spi core.
* max5821
- add .of_match_table set to the ID table which was present but not used.
* mcp4725
- add OF device ID table.
* mlx96014
- add OF device ID table.
* mma7455
- add OF device ID table.
* mma7660
- add OF device ID table.
* mpl3115
- add OF device ID table.
* mpu6050
- add OF device ID table.
* pc104
- mask pc104 drivers behind a global pc104 config option.
* ti-ads1015
- add OF device ID table.
* tsl2563
- add OF device ID table.
* us5182d
- add OF device ID table.
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
Linear Technology LTC2632 DAC device driver
|
||||
|
||||
Required properties:
|
||||
- compatible: Has to contain one of the following:
|
||||
lltc,ltc2632-l12
|
||||
lltc,ltc2632-l10
|
||||
lltc,ltc2632-l8
|
||||
lltc,ltc2632-h12
|
||||
lltc,ltc2632-h10
|
||||
lltc,ltc2632-h8
|
||||
|
||||
Property rules described in Documentation/devicetree/bindings/spi/spi-bus.txt
|
||||
apply. In particular, "reg" and "spi-max-frequency" properties must be given.
|
||||
|
||||
Example:
|
||||
|
||||
spi_master {
|
||||
dac: ltc2632@0 {
|
||||
compatible = "lltc,ltc2632-l12";
|
||||
reg = <0>; /* CS0 */
|
||||
spi-max-frequency = <1000000>;
|
||||
};
|
||||
};
|
||||
@@ -3024,7 +3024,6 @@ CAPELLA MICROSYSTEMS LIGHT SENSOR DRIVER
|
||||
M: Kevin Tsai <ktsai@capellamicro.com>
|
||||
S: Maintained
|
||||
F: drivers/iio/light/cm*
|
||||
F: Documentation/devicetree/bindings/i2c/trivial-admin-guide/devices.rst
|
||||
|
||||
CAVIUM THUNDERX2 ARM64 SOC
|
||||
M: Jayachandran C <jnair@caviumnetworks.com>
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/of_device.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/bitops.h>
|
||||
#include <linux/slab.h>
|
||||
@@ -32,7 +33,7 @@
|
||||
#define BMA180_DRV_NAME "bma180"
|
||||
#define BMA180_IRQ_NAME "bma180_event"
|
||||
|
||||
enum {
|
||||
enum chip_ids {
|
||||
BMA180,
|
||||
BMA250,
|
||||
};
|
||||
@@ -41,11 +42,11 @@ struct bma180_data;
|
||||
|
||||
struct bma180_part_info {
|
||||
const struct iio_chan_spec *channels;
|
||||
unsigned num_channels;
|
||||
unsigned int num_channels;
|
||||
const int *scale_table;
|
||||
unsigned num_scales;
|
||||
unsigned int num_scales;
|
||||
const int *bw_table;
|
||||
unsigned num_bw;
|
||||
unsigned int num_bw;
|
||||
|
||||
u8 int_reset_reg, int_reset_mask;
|
||||
u8 sleep_reg, sleep_mask;
|
||||
@@ -408,7 +409,7 @@ err:
|
||||
dev_err(&data->client->dev, "failed to disable the chip\n");
|
||||
}
|
||||
|
||||
static ssize_t bma180_show_avail(char *buf, const int *vals, unsigned n,
|
||||
static ssize_t bma180_show_avail(char *buf, const int *vals, unsigned int n,
|
||||
bool micros)
|
||||
{
|
||||
size_t len = 0;
|
||||
@@ -707,6 +708,7 @@ static int bma180_probe(struct i2c_client *client,
|
||||
{
|
||||
struct bma180_data *data;
|
||||
struct iio_dev *indio_dev;
|
||||
enum chip_ids chip;
|
||||
int ret;
|
||||
|
||||
indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
|
||||
@@ -716,7 +718,11 @@ static int bma180_probe(struct i2c_client *client,
|
||||
data = iio_priv(indio_dev);
|
||||
i2c_set_clientdata(client, indio_dev);
|
||||
data->client = client;
|
||||
data->part_info = &bma180_part_info[id->driver_data];
|
||||
if (client->dev.of_node)
|
||||
chip = (enum chip_ids)of_device_get_match_data(&client->dev);
|
||||
else
|
||||
chip = id->driver_data;
|
||||
data->part_info = &bma180_part_info[chip];
|
||||
|
||||
ret = data->part_info->chip_config(data);
|
||||
if (ret < 0)
|
||||
@@ -844,10 +850,24 @@ static struct i2c_device_id bma180_ids[] = {
|
||||
|
||||
MODULE_DEVICE_TABLE(i2c, bma180_ids);
|
||||
|
||||
static const struct of_device_id bma180_of_match[] = {
|
||||
{
|
||||
.compatible = "bosch,bma180",
|
||||
.data = (void *)BMA180
|
||||
},
|
||||
{
|
||||
.compatible = "bosch,bma250",
|
||||
.data = (void *)BMA250
|
||||
},
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, bma180_of_match);
|
||||
|
||||
static struct i2c_driver bma180_driver = {
|
||||
.driver = {
|
||||
.name = "bma180",
|
||||
.pm = BMA180_PM_OPS,
|
||||
.of_match_table = bma180_of_match,
|
||||
},
|
||||
.probe = bma180_probe,
|
||||
.remove = bma180_remove,
|
||||
|
||||
@@ -41,12 +41,20 @@ static const struct i2c_device_id mma7455_i2c_ids[] = {
|
||||
};
|
||||
MODULE_DEVICE_TABLE(i2c, mma7455_i2c_ids);
|
||||
|
||||
static const struct of_device_id mma7455_of_match[] = {
|
||||
{ .compatible = "fsl,mma7455" },
|
||||
{ .compatible = "fsl,mma7456" },
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, mma7455_of_match);
|
||||
|
||||
static struct i2c_driver mma7455_i2c_driver = {
|
||||
.probe = mma7455_i2c_probe,
|
||||
.remove = mma7455_i2c_remove,
|
||||
.id_table = mma7455_i2c_ids,
|
||||
.driver = {
|
||||
.name = "mma7455-i2c",
|
||||
.of_match_table = mma7455_of_match,
|
||||
},
|
||||
};
|
||||
module_i2c_driver(mma7455_i2c_driver);
|
||||
|
||||
@@ -253,6 +253,12 @@ static const struct i2c_device_id mma7660_i2c_id[] = {
|
||||
};
|
||||
MODULE_DEVICE_TABLE(i2c, mma7660_i2c_id);
|
||||
|
||||
static const struct of_device_id mma7660_of_match[] = {
|
||||
{ .compatible = "fsl,mma7660" },
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, mma7660_of_match);
|
||||
|
||||
static const struct acpi_device_id mma7660_acpi_id[] = {
|
||||
{"MMA7660", 0},
|
||||
{}
|
||||
@@ -264,6 +270,7 @@ static struct i2c_driver mma7660_driver = {
|
||||
.driver = {
|
||||
.name = "mma7660",
|
||||
.pm = MMA7660_PM_OPS,
|
||||
.of_match_table = mma7660_of_match,
|
||||
.acpi_match_table = ACPI_PTR(mma7660_acpi_id),
|
||||
},
|
||||
.probe = mma7660_probe,
|
||||
|
||||
+18
-1
@@ -546,7 +546,7 @@ config STM32_ADC
|
||||
|
||||
config STX104
|
||||
tristate "Apex Embedded Systems STX104 driver"
|
||||
depends on X86 && ISA_BUS_API
|
||||
depends on PC104 && X86 && ISA_BUS_API
|
||||
select GPIOLIB
|
||||
help
|
||||
Say yes here to build support for the Apex Embedded Systems STX104
|
||||
@@ -559,6 +559,23 @@ config STX104
|
||||
The base port addresses for the devices may be configured via the base
|
||||
array module parameter.
|
||||
|
||||
config SUN4I_GPADC
|
||||
tristate "Support for the Allwinner SoCs GPADC"
|
||||
depends on IIO
|
||||
depends on MFD_SUN4I_GPADC
|
||||
help
|
||||
Say yes here to build support for Allwinner (A10, A13 and A31) SoCs
|
||||
GPADC. This ADC provides 4 channels which can be used as an ADC or as
|
||||
a touchscreen input and one channel for thermal sensor.
|
||||
|
||||
The thermal sensor slows down ADC readings and can be disabled by
|
||||
disabling CONFIG_THERMAL_OF. However, the thermal sensor should be
|
||||
enabled by default since the SoC temperature is usually more critical
|
||||
than ADC readings.
|
||||
|
||||
To compile this driver as a module, choose M here: the module will be
|
||||
called sun4i-gpadc-iio.
|
||||
|
||||
config TI_ADC081C
|
||||
tristate "Texas Instruments ADC081C/ADC101C/ADC121C family"
|
||||
depends on I2C
|
||||
|
||||
@@ -49,6 +49,7 @@ obj-$(CONFIG_RCAR_GYRO_ADC) += rcar-gyroadc.o
|
||||
obj-$(CONFIG_ROCKCHIP_SARADC) += rockchip_saradc.o
|
||||
obj-$(CONFIG_SPEAR_ADC) += spear_adc.o
|
||||
obj-$(CONFIG_STX104) += stx104.o
|
||||
obj-$(CONFIG_SUN4I_GPADC) += sun4i-gpadc-iio.o
|
||||
obj-$(CONFIG_STM32_ADC_CORE) += stm32-adc-core.o
|
||||
obj-$(CONFIG_STM32_ADC) += stm32-adc.o
|
||||
obj-$(CONFIG_TI_ADC081C) += ti-adc081c.o
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <linux/iio/sysfs.h>
|
||||
#include <linux/kthread.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/of_device.h>
|
||||
#include <linux/regmap.h>
|
||||
#include <linux/util_macros.h>
|
||||
|
||||
@@ -635,6 +636,7 @@ static int ina2xx_probe(struct i2c_client *client,
|
||||
struct iio_dev *indio_dev;
|
||||
struct iio_buffer *buffer;
|
||||
unsigned int val;
|
||||
enum ina2xx_ids type;
|
||||
int ret;
|
||||
|
||||
indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*chip));
|
||||
@@ -652,7 +654,11 @@ static int ina2xx_probe(struct i2c_client *client,
|
||||
return PTR_ERR(chip->regmap);
|
||||
}
|
||||
|
||||
chip->config = &ina2xx_config[id->driver_data];
|
||||
if (client->dev.of_node)
|
||||
type = (enum ina2xx_ids)of_device_get_match_data(&client->dev);
|
||||
else
|
||||
type = id->driver_data;
|
||||
chip->config = &ina2xx_config[type];
|
||||
|
||||
mutex_init(&chip->state_lock);
|
||||
|
||||
@@ -726,9 +732,35 @@ static const struct i2c_device_id ina2xx_id[] = {
|
||||
};
|
||||
MODULE_DEVICE_TABLE(i2c, ina2xx_id);
|
||||
|
||||
static const struct of_device_id ina2xx_of_match[] = {
|
||||
{
|
||||
.compatible = "ti,ina219",
|
||||
.data = (void *)ina219
|
||||
},
|
||||
{
|
||||
.compatible = "ti,ina220",
|
||||
.data = (void *)ina219
|
||||
},
|
||||
{
|
||||
.compatible = "ti,ina226",
|
||||
.data = (void *)ina226
|
||||
},
|
||||
{
|
||||
.compatible = "ti,ina230",
|
||||
.data = (void *)ina226
|
||||
},
|
||||
{
|
||||
.compatible = "ti,ina231",
|
||||
.data = (void *)ina226
|
||||
},
|
||||
{},
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, ina2xx_of_match);
|
||||
|
||||
static struct i2c_driver ina2xx_driver = {
|
||||
.driver = {
|
||||
.name = KBUILD_MODNAME,
|
||||
.of_match_table = ina2xx_of_match,
|
||||
},
|
||||
.probe = ina2xx_probe,
|
||||
.remove = ina2xx_remove,
|
||||
|
||||
@@ -167,7 +167,6 @@ MODULE_DEVICE_TABLE(of, max11100_ids);
|
||||
static struct spi_driver max11100_driver = {
|
||||
.driver = {
|
||||
.name = "max11100",
|
||||
.owner = THIS_MODULE,
|
||||
.of_match_table = of_match_ptr(max11100_ids),
|
||||
},
|
||||
.probe = max11100_probe,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/of_device.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/regmap.h>
|
||||
@@ -55,7 +56,7 @@
|
||||
#define ADS1015_DEFAULT_DATA_RATE 4
|
||||
#define ADS1015_DEFAULT_CHAN 0
|
||||
|
||||
enum {
|
||||
enum chip_ids {
|
||||
ADS1015,
|
||||
ADS1115,
|
||||
};
|
||||
@@ -578,6 +579,7 @@ static int ads1015_probe(struct i2c_client *client,
|
||||
struct iio_dev *indio_dev;
|
||||
struct ads1015_data *data;
|
||||
int ret;
|
||||
enum chip_ids chip;
|
||||
|
||||
indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
|
||||
if (!indio_dev)
|
||||
@@ -593,7 +595,11 @@ static int ads1015_probe(struct i2c_client *client,
|
||||
indio_dev->name = ADS1015_DRV_NAME;
|
||||
indio_dev->modes = INDIO_DIRECT_MODE;
|
||||
|
||||
switch (id->driver_data) {
|
||||
if (client->dev.of_node)
|
||||
chip = (enum chip_ids)of_device_get_match_data(&client->dev);
|
||||
else
|
||||
chip = id->driver_data;
|
||||
switch (chip) {
|
||||
case ADS1015:
|
||||
indio_dev->channels = ads1015_channels;
|
||||
indio_dev->num_channels = ARRAY_SIZE(ads1015_channels);
|
||||
@@ -698,9 +704,23 @@ static const struct i2c_device_id ads1015_id[] = {
|
||||
};
|
||||
MODULE_DEVICE_TABLE(i2c, ads1015_id);
|
||||
|
||||
static const struct of_device_id ads1015_of_match[] = {
|
||||
{
|
||||
.compatible = "ti,ads1015",
|
||||
.data = (void *)ADS1015
|
||||
},
|
||||
{
|
||||
.compatible = "ti,ads1115",
|
||||
.data = (void *)ADS1115
|
||||
},
|
||||
{}
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, ads1015_of_match);
|
||||
|
||||
static struct i2c_driver ads1015_driver = {
|
||||
.driver = {
|
||||
.name = ADS1015_DRV_NAME,
|
||||
.of_match_table = ads1015_of_match,
|
||||
.pm = &ads1015_pm_ops,
|
||||
},
|
||||
.probe = ads1015_probe,
|
||||
|
||||
@@ -7,7 +7,7 @@ menu "Counters"
|
||||
|
||||
config 104_QUAD_8
|
||||
tristate "ACCES 104-QUAD-8 driver"
|
||||
depends on X86 && ISA_BUS_API
|
||||
depends on PC104 && X86 && ISA_BUS_API
|
||||
help
|
||||
Say yes here to build support for the ACCES 104-QUAD-8 quadrature
|
||||
encoder counter/interface device family (104-QUAD-8, 104-QUAD-4).
|
||||
|
||||
@@ -118,6 +118,16 @@ config AD5624R_SPI
|
||||
Say yes here to build support for Analog Devices AD5624R, AD5644R and
|
||||
AD5664R converters (DAC). This driver uses the common SPI interface.
|
||||
|
||||
config LTC2632
|
||||
tristate "Linear Technology LTC2632-12/10/8 DAC spi driver"
|
||||
depends on SPI
|
||||
help
|
||||
Say yes here to build support for Linear Technology
|
||||
LTC2632-12, LTC2632-10, LTC2632-8 converters (DAC).
|
||||
|
||||
To compile this driver as a module, choose M here: the
|
||||
module will be called ltc2632.
|
||||
|
||||
config AD5686
|
||||
tristate "Analog Devices AD5686R/AD5685R/AD5684R DAC SPI driver"
|
||||
depends on SPI
|
||||
|
||||
@@ -24,6 +24,7 @@ obj-$(CONFIG_AD8801) += ad8801.o
|
||||
obj-$(CONFIG_CIO_DAC) += cio-dac.o
|
||||
obj-$(CONFIG_DPOT_DAC) += dpot-dac.o
|
||||
obj-$(CONFIG_LPC18XX_DAC) += lpc18xx_dac.o
|
||||
obj-$(CONFIG_LTC2632) += ltc2632.o
|
||||
obj-$(CONFIG_M62332) += m62332.o
|
||||
obj-$(CONFIG_MAX517) += max517.o
|
||||
obj-$(CONFIG_MAX5821) += max5821.o
|
||||
|
||||
@@ -0,0 +1,314 @@
|
||||
/*
|
||||
* LTC2632 Digital to analog convertors spi driver
|
||||
*
|
||||
* Copyright 2017 Maxime Roussin-Bélanger
|
||||
*
|
||||
* Licensed under the GPL-2.
|
||||
*/
|
||||
|
||||
#include <linux/device.h>
|
||||
#include <linux/spi/spi.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/iio/iio.h>
|
||||
|
||||
#define LTC2632_DAC_CHANNELS 2
|
||||
|
||||
#define LTC2632_ADDR_DAC0 0x0
|
||||
#define LTC2632_ADDR_DAC1 0x1
|
||||
|
||||
#define LTC2632_CMD_WRITE_INPUT_N 0x0
|
||||
#define LTC2632_CMD_UPDATE_DAC_N 0x1
|
||||
#define LTC2632_CMD_WRITE_INPUT_N_UPDATE_ALL 0x2
|
||||
#define LTC2632_CMD_WRITE_INPUT_N_UPDATE_N 0x3
|
||||
#define LTC2632_CMD_POWERDOWN_DAC_N 0x4
|
||||
#define LTC2632_CMD_POWERDOWN_CHIP 0x5
|
||||
#define LTC2632_CMD_INTERNAL_REFER 0x6
|
||||
#define LTC2632_CMD_EXTERNAL_REFER 0x7
|
||||
|
||||
/**
|
||||
* struct ltc2632_chip_info - chip specific information
|
||||
* @channels: channel spec for the DAC
|
||||
* @vref_mv: reference voltage
|
||||
*/
|
||||
struct ltc2632_chip_info {
|
||||
const struct iio_chan_spec *channels;
|
||||
const int vref_mv;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct ltc2632_state - driver instance specific data
|
||||
* @spi_dev: pointer to the spi_device struct
|
||||
* @powerdown_cache_mask used to show current channel powerdown state
|
||||
*/
|
||||
struct ltc2632_state {
|
||||
struct spi_device *spi_dev;
|
||||
unsigned int powerdown_cache_mask;
|
||||
};
|
||||
|
||||
enum ltc2632_supported_device_ids {
|
||||
ID_LTC2632L12,
|
||||
ID_LTC2632L10,
|
||||
ID_LTC2632L8,
|
||||
ID_LTC2632H12,
|
||||
ID_LTC2632H10,
|
||||
ID_LTC2632H8,
|
||||
};
|
||||
|
||||
static int ltc2632_spi_write(struct spi_device *spi,
|
||||
u8 cmd, u8 addr, u16 val, u8 shift)
|
||||
{
|
||||
u32 data;
|
||||
u8 msg[3];
|
||||
|
||||
/*
|
||||
* The input shift register is 24 bits wide.
|
||||
* The next four are the command bits, C3 to C0,
|
||||
* followed by the 4-bit DAC address, A3 to A0, and then the
|
||||
* 12-, 10-, 8-bit data-word. The data-word comprises the 12-,
|
||||
* 10-, 8-bit input code followed by 4, 6, or 8 don't care bits.
|
||||
*/
|
||||
data = (cmd << 20) | (addr << 16) | (val << shift);
|
||||
msg[0] = data >> 16;
|
||||
msg[1] = data >> 8;
|
||||
msg[2] = data;
|
||||
|
||||
return spi_write(spi, msg, sizeof(msg));
|
||||
}
|
||||
|
||||
static int ltc2632_read_raw(struct iio_dev *indio_dev,
|
||||
struct iio_chan_spec const *chan,
|
||||
int *val,
|
||||
int *val2,
|
||||
long m)
|
||||
{
|
||||
struct ltc2632_chip_info *chip_info;
|
||||
|
||||
const struct ltc2632_state *st = iio_priv(indio_dev);
|
||||
const struct spi_device_id *spi_dev_id = spi_get_device_id(st->spi_dev);
|
||||
|
||||
chip_info = (struct ltc2632_chip_info *)spi_dev_id->driver_data;
|
||||
|
||||
switch (m) {
|
||||
case IIO_CHAN_INFO_SCALE:
|
||||
*val = chip_info->vref_mv;
|
||||
*val2 = chan->scan_type.realbits;
|
||||
return IIO_VAL_FRACTIONAL_LOG2;
|
||||
}
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static int ltc2632_write_raw(struct iio_dev *indio_dev,
|
||||
struct iio_chan_spec const *chan,
|
||||
int val,
|
||||
int val2,
|
||||
long mask)
|
||||
{
|
||||
struct ltc2632_state *st = iio_priv(indio_dev);
|
||||
|
||||
switch (mask) {
|
||||
case IIO_CHAN_INFO_RAW:
|
||||
if (val >= (1 << chan->scan_type.realbits) || val < 0)
|
||||
return -EINVAL;
|
||||
|
||||
return ltc2632_spi_write(st->spi_dev,
|
||||
LTC2632_CMD_WRITE_INPUT_N_UPDATE_N,
|
||||
chan->address, val,
|
||||
chan->scan_type.shift);
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
static ssize_t ltc2632_read_dac_powerdown(struct iio_dev *indio_dev,
|
||||
uintptr_t private,
|
||||
const struct iio_chan_spec *chan,
|
||||
char *buf)
|
||||
{
|
||||
struct ltc2632_state *st = iio_priv(indio_dev);
|
||||
|
||||
return sprintf(buf, "%d\n",
|
||||
!!(st->powerdown_cache_mask & (1 << chan->channel)));
|
||||
}
|
||||
|
||||
static ssize_t ltc2632_write_dac_powerdown(struct iio_dev *indio_dev,
|
||||
uintptr_t private,
|
||||
const struct iio_chan_spec *chan,
|
||||
const char *buf,
|
||||
size_t len)
|
||||
{
|
||||
bool pwr_down;
|
||||
int ret;
|
||||
struct ltc2632_state *st = iio_priv(indio_dev);
|
||||
|
||||
ret = strtobool(buf, &pwr_down);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (pwr_down)
|
||||
st->powerdown_cache_mask |= (1 << chan->channel);
|
||||
else
|
||||
st->powerdown_cache_mask &= ~(1 << chan->channel);
|
||||
|
||||
ret = ltc2632_spi_write(st->spi_dev,
|
||||
LTC2632_CMD_POWERDOWN_DAC_N,
|
||||
chan->channel, 0, 0);
|
||||
|
||||
return ret ? ret : len;
|
||||
}
|
||||
|
||||
static const struct iio_info ltc2632_info = {
|
||||
.write_raw = ltc2632_write_raw,
|
||||
.read_raw = ltc2632_read_raw,
|
||||
.driver_module = THIS_MODULE,
|
||||
};
|
||||
|
||||
static const struct iio_chan_spec_ext_info ltc2632_ext_info[] = {
|
||||
{
|
||||
.name = "powerdown",
|
||||
.read = ltc2632_read_dac_powerdown,
|
||||
.write = ltc2632_write_dac_powerdown,
|
||||
.shared = IIO_SEPARATE,
|
||||
},
|
||||
{ },
|
||||
};
|
||||
|
||||
#define LTC2632_CHANNEL(_chan, _bits) { \
|
||||
.type = IIO_VOLTAGE, \
|
||||
.indexed = 1, \
|
||||
.output = 1, \
|
||||
.channel = (_chan), \
|
||||
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
|
||||
.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \
|
||||
.address = (_chan), \
|
||||
.scan_type = { \
|
||||
.realbits = (_bits), \
|
||||
.shift = 16 - (_bits), \
|
||||
}, \
|
||||
.ext_info = ltc2632_ext_info, \
|
||||
}
|
||||
|
||||
#define DECLARE_LTC2632_CHANNELS(_name, _bits) \
|
||||
const struct iio_chan_spec _name ## _channels[] = { \
|
||||
LTC2632_CHANNEL(0, _bits), \
|
||||
LTC2632_CHANNEL(1, _bits), \
|
||||
}
|
||||
|
||||
static DECLARE_LTC2632_CHANNELS(ltc2632l12, 12);
|
||||
static DECLARE_LTC2632_CHANNELS(ltc2632l10, 10);
|
||||
static DECLARE_LTC2632_CHANNELS(ltc2632l8, 8);
|
||||
|
||||
static DECLARE_LTC2632_CHANNELS(ltc2632h12, 12);
|
||||
static DECLARE_LTC2632_CHANNELS(ltc2632h10, 10);
|
||||
static DECLARE_LTC2632_CHANNELS(ltc2632h8, 8);
|
||||
|
||||
static const struct ltc2632_chip_info ltc2632_chip_info_tbl[] = {
|
||||
[ID_LTC2632L12] = {
|
||||
.channels = ltc2632l12_channels,
|
||||
.vref_mv = 2500,
|
||||
},
|
||||
[ID_LTC2632L10] = {
|
||||
.channels = ltc2632l10_channels,
|
||||
.vref_mv = 2500,
|
||||
},
|
||||
[ID_LTC2632L8] = {
|
||||
.channels = ltc2632l8_channels,
|
||||
.vref_mv = 2500,
|
||||
},
|
||||
[ID_LTC2632H12] = {
|
||||
.channels = ltc2632h12_channels,
|
||||
.vref_mv = 4096,
|
||||
},
|
||||
[ID_LTC2632H10] = {
|
||||
.channels = ltc2632h10_channels,
|
||||
.vref_mv = 4096,
|
||||
},
|
||||
[ID_LTC2632H8] = {
|
||||
.channels = ltc2632h8_channels,
|
||||
.vref_mv = 4096,
|
||||
},
|
||||
};
|
||||
|
||||
static int ltc2632_probe(struct spi_device *spi)
|
||||
{
|
||||
struct ltc2632_state *st;
|
||||
struct iio_dev *indio_dev;
|
||||
struct ltc2632_chip_info *chip_info;
|
||||
int ret;
|
||||
|
||||
indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
|
||||
if (!indio_dev)
|
||||
return -ENOMEM;
|
||||
|
||||
st = iio_priv(indio_dev);
|
||||
|
||||
spi_set_drvdata(spi, indio_dev);
|
||||
st->spi_dev = spi;
|
||||
|
||||
chip_info = (struct ltc2632_chip_info *)
|
||||
spi_get_device_id(spi)->driver_data;
|
||||
|
||||
indio_dev->dev.parent = &spi->dev;
|
||||
indio_dev->name = dev_of_node(&spi->dev) ? dev_of_node(&spi->dev)->name
|
||||
: spi_get_device_id(spi)->name;
|
||||
indio_dev->info = <c2632_info;
|
||||
indio_dev->modes = INDIO_DIRECT_MODE;
|
||||
indio_dev->channels = chip_info->channels;
|
||||
indio_dev->num_channels = LTC2632_DAC_CHANNELS;
|
||||
|
||||
ret = ltc2632_spi_write(spi, LTC2632_CMD_INTERNAL_REFER, 0, 0, 0);
|
||||
if (ret) {
|
||||
dev_err(&spi->dev,
|
||||
"Set internal reference command failed, %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return devm_iio_device_register(&spi->dev, indio_dev);
|
||||
}
|
||||
|
||||
static const struct spi_device_id ltc2632_id[] = {
|
||||
{ "ltc2632-l12", (kernel_ulong_t)<c2632_chip_info_tbl[ID_LTC2632L12] },
|
||||
{ "ltc2632-l10", (kernel_ulong_t)<c2632_chip_info_tbl[ID_LTC2632L10] },
|
||||
{ "ltc2632-l8", (kernel_ulong_t)<c2632_chip_info_tbl[ID_LTC2632L8] },
|
||||
{ "ltc2632-h12", (kernel_ulong_t)<c2632_chip_info_tbl[ID_LTC2632H12] },
|
||||
{ "ltc2632-h10", (kernel_ulong_t)<c2632_chip_info_tbl[ID_LTC2632H10] },
|
||||
{ "ltc2632-h8", (kernel_ulong_t)<c2632_chip_info_tbl[ID_LTC2632H8] },
|
||||
{}
|
||||
};
|
||||
MODULE_DEVICE_TABLE(spi, ltc2632_id);
|
||||
|
||||
static struct spi_driver ltc2632_driver = {
|
||||
.driver = {
|
||||
.name = "ltc2632",
|
||||
},
|
||||
.probe = ltc2632_probe,
|
||||
.id_table = ltc2632_id,
|
||||
};
|
||||
module_spi_driver(ltc2632_driver);
|
||||
|
||||
static const struct of_device_id ltc2632_of_match[] = {
|
||||
{
|
||||
.compatible = "lltc,ltc2632-l12",
|
||||
.data = <c2632_chip_info_tbl[ID_LTC2632L12]
|
||||
}, {
|
||||
.compatible = "lltc,ltc2632-l10",
|
||||
.data = <c2632_chip_info_tbl[ID_LTC2632L10]
|
||||
}, {
|
||||
.compatible = "lltc,ltc2632-l8",
|
||||
.data = <c2632_chip_info_tbl[ID_LTC2632L8]
|
||||
}, {
|
||||
.compatible = "lltc,ltc2632-h12",
|
||||
.data = <c2632_chip_info_tbl[ID_LTC2632H12]
|
||||
}, {
|
||||
.compatible = "lltc,ltc2632-h10",
|
||||
.data = <c2632_chip_info_tbl[ID_LTC2632H10]
|
||||
}, {
|
||||
.compatible = "lltc,ltc2632-h8",
|
||||
.data = <c2632_chip_info_tbl[ID_LTC2632H8]
|
||||
},
|
||||
{}
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, ltc2632_of_match);
|
||||
|
||||
MODULE_AUTHOR("Maxime Roussin-Belanger <maxime.roussinbelanger@gmail.com>");
|
||||
MODULE_DESCRIPTION("LTC2632 DAC SPI driver");
|
||||
MODULE_LICENSE("GPL v2");
|
||||
@@ -392,6 +392,7 @@ MODULE_DEVICE_TABLE(of, max5821_of_match);
|
||||
static struct i2c_driver max5821_driver = {
|
||||
.driver = {
|
||||
.name = "max5821",
|
||||
.of_match_table = max5821_of_match,
|
||||
.pm = MAX5821_PM_OPS,
|
||||
},
|
||||
.probe = max5821_probe,
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <linux/err.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/regulator/consumer.h>
|
||||
#include <linux/of_device.h>
|
||||
#include <linux/of.h>
|
||||
|
||||
#include <linux/iio/iio.h>
|
||||
@@ -199,7 +200,7 @@ static ssize_t mcp4725_write_powerdown(struct iio_dev *indio_dev,
|
||||
return len;
|
||||
}
|
||||
|
||||
enum {
|
||||
enum chip_id {
|
||||
MCP4725,
|
||||
MCP4726,
|
||||
};
|
||||
@@ -406,7 +407,10 @@ static int mcp4725_probe(struct i2c_client *client,
|
||||
data = iio_priv(indio_dev);
|
||||
i2c_set_clientdata(client, indio_dev);
|
||||
data->client = client;
|
||||
data->id = id->driver_data;
|
||||
if (client->dev.of_node)
|
||||
data->id = (enum chip_id)of_device_get_match_data(&client->dev);
|
||||
else
|
||||
data->id = id->driver_data;
|
||||
pdata = dev_get_platdata(&client->dev);
|
||||
|
||||
if (!pdata) {
|
||||
@@ -525,9 +529,25 @@ static const struct i2c_device_id mcp4725_id[] = {
|
||||
};
|
||||
MODULE_DEVICE_TABLE(i2c, mcp4725_id);
|
||||
|
||||
#ifdef CONFIG_OF
|
||||
static const struct of_device_id mcp4725_of_match[] = {
|
||||
{
|
||||
.compatible = "microchip,mcp4725",
|
||||
.data = (void *)MCP4725
|
||||
},
|
||||
{
|
||||
.compatible = "microchip,mcp4726",
|
||||
.data = (void *)MCP4726
|
||||
},
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, mcp4725_of_match);
|
||||
#endif
|
||||
|
||||
static struct i2c_driver mcp4725_driver = {
|
||||
.driver = {
|
||||
.name = MCP4725_DRV_NAME,
|
||||
.of_match_table = of_match_ptr(mcp4725_of_match),
|
||||
.pm = MCP4725_PM_OPS,
|
||||
},
|
||||
.probe = mcp4725_probe,
|
||||
|
||||
@@ -377,9 +377,16 @@ static const struct i2c_device_id itg3200_id[] = {
|
||||
};
|
||||
MODULE_DEVICE_TABLE(i2c, itg3200_id);
|
||||
|
||||
static const struct of_device_id itg3200_of_match[] = {
|
||||
{ .compatible = "invensense,itg3200" },
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, itg3200_of_match);
|
||||
|
||||
static struct i2c_driver itg3200_driver = {
|
||||
.driver = {
|
||||
.name = "itg3200",
|
||||
.of_match_table = itg3200_of_match,
|
||||
.pm = &itg3200_pm_ops,
|
||||
},
|
||||
.id_table = itg3200_id,
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/iio/iio.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/of_device.h>
|
||||
#include "inv_mpu_iio.h"
|
||||
|
||||
static const struct regmap_config inv_mpu_regmap_config = {
|
||||
@@ -69,7 +70,8 @@ static int inv_mpu6050_deselect_bypass(struct i2c_mux_core *muxc, u32 chan_id)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const char *inv_mpu_match_acpi_device(struct device *dev, int *chip_id)
|
||||
static const char *inv_mpu_match_acpi_device(struct device *dev,
|
||||
enum inv_devices *chip_id)
|
||||
{
|
||||
const struct acpi_device_id *id;
|
||||
|
||||
@@ -93,7 +95,8 @@ static int inv_mpu_probe(struct i2c_client *client,
|
||||
const struct i2c_device_id *id)
|
||||
{
|
||||
struct inv_mpu6050_state *st;
|
||||
int result, chip_type;
|
||||
int result;
|
||||
enum inv_devices chip_type;
|
||||
struct regmap *regmap;
|
||||
const char *name;
|
||||
|
||||
@@ -101,8 +104,13 @@ static int inv_mpu_probe(struct i2c_client *client,
|
||||
I2C_FUNC_SMBUS_I2C_BLOCK))
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
if (id) {
|
||||
chip_type = (int)id->driver_data;
|
||||
if (client->dev.of_node) {
|
||||
chip_type = (enum inv_devices)
|
||||
of_device_get_match_data(&client->dev);
|
||||
name = client->name;
|
||||
} else if (id) {
|
||||
chip_type = (enum inv_devices)
|
||||
id->driver_data;
|
||||
name = id->name;
|
||||
} else if (ACPI_HANDLE(&client->dev)) {
|
||||
name = inv_mpu_match_acpi_device(&client->dev, &chip_type);
|
||||
@@ -176,6 +184,27 @@ static const struct i2c_device_id inv_mpu_id[] = {
|
||||
|
||||
MODULE_DEVICE_TABLE(i2c, inv_mpu_id);
|
||||
|
||||
static const struct of_device_id inv_of_match[] = {
|
||||
{
|
||||
.compatible = "invensense,mpu6050",
|
||||
.data = (void *)INV_MPU6050
|
||||
},
|
||||
{
|
||||
.compatible = "invensense,mpu6500",
|
||||
.data = (void *)INV_MPU6500
|
||||
},
|
||||
{
|
||||
.compatible = "invensense,mpu9150",
|
||||
.data = (void *)INV_MPU9150
|
||||
},
|
||||
{
|
||||
.compatible = "invensense,icm20608",
|
||||
.data = (void *)INV_ICM20608
|
||||
},
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, inv_of_match);
|
||||
|
||||
static const struct acpi_device_id inv_acpi_match[] = {
|
||||
{"INVN6500", INV_MPU6500},
|
||||
{ },
|
||||
@@ -188,6 +217,7 @@ static struct i2c_driver inv_mpu_driver = {
|
||||
.remove = inv_mpu_remove,
|
||||
.id_table = inv_mpu_id,
|
||||
.driver = {
|
||||
.of_match_table = inv_of_match,
|
||||
.acpi_match_table = ACPI_PTR(inv_acpi_match),
|
||||
.name = "inv-mpu6050-i2c",
|
||||
.pm = &inv_mpu_pmops,
|
||||
|
||||
@@ -1122,9 +1122,16 @@ static const struct i2c_device_id apds9960_id[] = {
|
||||
};
|
||||
MODULE_DEVICE_TABLE(i2c, apds9960_id);
|
||||
|
||||
static const struct of_device_id apds9960_of_match[] = {
|
||||
{ .compatible = "avago,apds9960" },
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, apds9960_of_match);
|
||||
|
||||
static struct i2c_driver apds9960_driver = {
|
||||
.driver = {
|
||||
.name = APDS9960_DRV_NAME,
|
||||
.of_match_table = apds9960_of_match,
|
||||
.pm = &apds9960_pm_ops,
|
||||
},
|
||||
.probe = apds9960_probe,
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user