2019-05-24 10:04:09 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
ad525x_dpot: add support for SPI parts
Split the bus logic out into separate files so that we can handle I2C and
SPI busses independently. The new SPI bus logic brings in support for a
lot more parts:
AD5160, AD5161, AD5162, AD5165, AD5200, AD5201, AD5203,
AD5204, AD5206, AD5207, AD5231, AD5232, AD5233, AD5235,
AD5260, AD5262, AD5263, AD5290, AD5291, AD5292, AD5293,
AD7376, AD8400, AD8402, AD8403, ADN2850
[randy.dunlap@oracle.com: fix ad525X_dpot build]
Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2010-05-24 21:33:14 +00:00
|
|
|
/*
|
|
|
|
* Driver for the Analog Devices digital potentiometers (I2C bus)
|
|
|
|
*
|
2011-11-18 10:05:11 +00:00
|
|
|
* Copyright (C) 2010-2011 Michael Hennerich, Analog Devices Inc.
|
ad525x_dpot: add support for SPI parts
Split the bus logic out into separate files so that we can handle I2C and
SPI busses independently. The new SPI bus logic brings in support for a
lot more parts:
AD5160, AD5161, AD5162, AD5165, AD5200, AD5201, AD5203,
AD5204, AD5206, AD5207, AD5231, AD5232, AD5233, AD5235,
AD5260, AD5262, AD5263, AD5290, AD5291, AD5292, AD5293,
AD7376, AD8400, AD8402, AD8403, ADN2850
[randy.dunlap@oracle.com: fix ad525X_dpot build]
Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2010-05-24 21:33:14 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/i2c.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
|
|
|
|
#include "ad525x_dpot.h"
|
|
|
|
|
|
|
|
/* I2C bus functions */
|
|
|
|
static int write_d8(void *client, u8 val)
|
|
|
|
{
|
|
|
|
return i2c_smbus_write_byte(client, val);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int write_r8d8(void *client, u8 reg, u8 val)
|
|
|
|
{
|
|
|
|
return i2c_smbus_write_byte_data(client, reg, val);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int write_r8d16(void *client, u8 reg, u16 val)
|
|
|
|
{
|
|
|
|
return i2c_smbus_write_word_data(client, reg, val);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int read_d8(void *client)
|
|
|
|
{
|
|
|
|
return i2c_smbus_read_byte(client);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int read_r8d8(void *client, u8 reg)
|
|
|
|
{
|
|
|
|
return i2c_smbus_read_byte_data(client, reg);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int read_r8d16(void *client, u8 reg)
|
|
|
|
{
|
|
|
|
return i2c_smbus_read_word_data(client, reg);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct ad_dpot_bus_ops bops = {
|
|
|
|
.read_d8 = read_d8,
|
|
|
|
.read_r8d8 = read_r8d8,
|
|
|
|
.read_r8d16 = read_r8d16,
|
|
|
|
.write_d8 = write_d8,
|
|
|
|
.write_r8d8 = write_r8d8,
|
|
|
|
.write_r8d16 = write_r8d16,
|
|
|
|
};
|
|
|
|
|
2012-11-19 18:23:05 +00:00
|
|
|
static int ad_dpot_i2c_probe(struct i2c_client *client,
|
ad525x_dpot: add support for SPI parts
Split the bus logic out into separate files so that we can handle I2C and
SPI busses independently. The new SPI bus logic brings in support for a
lot more parts:
AD5160, AD5161, AD5162, AD5165, AD5200, AD5201, AD5203,
AD5204, AD5206, AD5207, AD5231, AD5232, AD5233, AD5235,
AD5260, AD5262, AD5263, AD5290, AD5291, AD5292, AD5293,
AD7376, AD8400, AD8402, AD8403, ADN2850
[randy.dunlap@oracle.com: fix ad525X_dpot build]
Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2010-05-24 21:33:14 +00:00
|
|
|
const struct i2c_device_id *id)
|
|
|
|
{
|
|
|
|
struct ad_dpot_bus_data bdata = {
|
|
|
|
.client = client,
|
|
|
|
.bops = &bops,
|
|
|
|
};
|
|
|
|
|
|
|
|
if (!i2c_check_functionality(client->adapter,
|
|
|
|
I2C_FUNC_SMBUS_WORD_DATA)) {
|
|
|
|
dev_err(&client->dev, "SMBUS Word Data not Supported\n");
|
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
|
2011-11-18 10:05:11 +00:00
|
|
|
return ad_dpot_probe(&client->dev, &bdata, id->driver_data, id->name);
|
ad525x_dpot: add support for SPI parts
Split the bus logic out into separate files so that we can handle I2C and
SPI busses independently. The new SPI bus logic brings in support for a
lot more parts:
AD5160, AD5161, AD5162, AD5165, AD5200, AD5201, AD5203,
AD5204, AD5206, AD5207, AD5231, AD5232, AD5233, AD5235,
AD5260, AD5262, AD5263, AD5290, AD5291, AD5292, AD5293,
AD7376, AD8400, AD8402, AD8403, ADN2850
[randy.dunlap@oracle.com: fix ad525X_dpot build]
Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2010-05-24 21:33:14 +00:00
|
|
|
}
|
|
|
|
|
2012-11-19 18:26:02 +00:00
|
|
|
static int ad_dpot_i2c_remove(struct i2c_client *client)
|
ad525x_dpot: add support for SPI parts
Split the bus logic out into separate files so that we can handle I2C and
SPI busses independently. The new SPI bus logic brings in support for a
lot more parts:
AD5160, AD5161, AD5162, AD5165, AD5200, AD5201, AD5203,
AD5204, AD5206, AD5207, AD5231, AD5232, AD5233, AD5235,
AD5260, AD5262, AD5263, AD5290, AD5291, AD5292, AD5293,
AD7376, AD8400, AD8402, AD8403, ADN2850
[randy.dunlap@oracle.com: fix ad525X_dpot build]
Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2010-05-24 21:33:14 +00:00
|
|
|
{
|
2021-10-12 15:39:36 +00:00
|
|
|
ad_dpot_remove(&client->dev);
|
|
|
|
return 0;
|
ad525x_dpot: add support for SPI parts
Split the bus logic out into separate files so that we can handle I2C and
SPI busses independently. The new SPI bus logic brings in support for a
lot more parts:
AD5160, AD5161, AD5162, AD5165, AD5200, AD5201, AD5203,
AD5204, AD5206, AD5207, AD5231, AD5232, AD5233, AD5235,
AD5260, AD5262, AD5263, AD5290, AD5291, AD5292, AD5293,
AD7376, AD8400, AD8402, AD8403, ADN2850
[randy.dunlap@oracle.com: fix ad525X_dpot build]
Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2010-05-24 21:33:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct i2c_device_id ad_dpot_id[] = {
|
|
|
|
{"ad5258", AD5258_ID},
|
|
|
|
{"ad5259", AD5259_ID},
|
|
|
|
{"ad5251", AD5251_ID},
|
|
|
|
{"ad5252", AD5252_ID},
|
|
|
|
{"ad5253", AD5253_ID},
|
|
|
|
{"ad5254", AD5254_ID},
|
|
|
|
{"ad5255", AD5255_ID},
|
2010-05-24 21:33:15 +00:00
|
|
|
{"ad5241", AD5241_ID},
|
|
|
|
{"ad5242", AD5242_ID},
|
|
|
|
{"ad5243", AD5243_ID},
|
|
|
|
{"ad5245", AD5245_ID},
|
|
|
|
{"ad5246", AD5246_ID},
|
|
|
|
{"ad5247", AD5247_ID},
|
|
|
|
{"ad5248", AD5248_ID},
|
2010-05-24 21:33:15 +00:00
|
|
|
{"ad5280", AD5280_ID},
|
|
|
|
{"ad5282", AD5282_ID},
|
|
|
|
{"adn2860", ADN2860_ID},
|
2010-05-24 21:33:16 +00:00
|
|
|
{"ad5273", AD5273_ID},
|
2011-11-01 00:11:12 +00:00
|
|
|
{"ad5161", AD5161_ID},
|
2010-05-24 21:33:16 +00:00
|
|
|
{"ad5171", AD5171_ID},
|
|
|
|
{"ad5170", AD5170_ID},
|
|
|
|
{"ad5172", AD5172_ID},
|
|
|
|
{"ad5173", AD5173_ID},
|
2010-10-26 21:22:36 +00:00
|
|
|
{"ad5272", AD5272_ID},
|
|
|
|
{"ad5274", AD5274_ID},
|
ad525x_dpot: add support for SPI parts
Split the bus logic out into separate files so that we can handle I2C and
SPI busses independently. The new SPI bus logic brings in support for a
lot more parts:
AD5160, AD5161, AD5162, AD5165, AD5200, AD5201, AD5203,
AD5204, AD5206, AD5207, AD5231, AD5232, AD5233, AD5235,
AD5260, AD5262, AD5263, AD5290, AD5291, AD5292, AD5293,
AD7376, AD8400, AD8402, AD8403, ADN2850
[randy.dunlap@oracle.com: fix ad525X_dpot build]
Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2010-05-24 21:33:14 +00:00
|
|
|
{}
|
|
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(i2c, ad_dpot_id);
|
|
|
|
|
|
|
|
static struct i2c_driver ad_dpot_i2c_driver = {
|
|
|
|
.driver = {
|
|
|
|
.name = "ad_dpot",
|
|
|
|
},
|
|
|
|
.probe = ad_dpot_i2c_probe,
|
2012-11-19 18:21:23 +00:00
|
|
|
.remove = ad_dpot_i2c_remove,
|
ad525x_dpot: add support for SPI parts
Split the bus logic out into separate files so that we can handle I2C and
SPI busses independently. The new SPI bus logic brings in support for a
lot more parts:
AD5160, AD5161, AD5162, AD5165, AD5200, AD5201, AD5203,
AD5204, AD5206, AD5207, AD5231, AD5232, AD5233, AD5235,
AD5260, AD5262, AD5263, AD5290, AD5291, AD5292, AD5293,
AD7376, AD8400, AD8402, AD8403, ADN2850
[randy.dunlap@oracle.com: fix ad525X_dpot build]
Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2010-05-24 21:33:14 +00:00
|
|
|
.id_table = ad_dpot_id,
|
|
|
|
};
|
|
|
|
|
2012-01-22 07:36:45 +00:00
|
|
|
module_i2c_driver(ad_dpot_i2c_driver);
|
ad525x_dpot: add support for SPI parts
Split the bus logic out into separate files so that we can handle I2C and
SPI busses independently. The new SPI bus logic brings in support for a
lot more parts:
AD5160, AD5161, AD5162, AD5165, AD5200, AD5201, AD5203,
AD5204, AD5206, AD5207, AD5231, AD5232, AD5233, AD5235,
AD5260, AD5262, AD5263, AD5290, AD5291, AD5292, AD5293,
AD7376, AD8400, AD8402, AD8403, ADN2850
[randy.dunlap@oracle.com: fix ad525X_dpot build]
Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2010-05-24 21:33:14 +00:00
|
|
|
|
2018-08-14 11:30:18 +00:00
|
|
|
MODULE_AUTHOR("Michael Hennerich <michael.hennerich@analog.com>");
|
ad525x_dpot: add support for SPI parts
Split the bus logic out into separate files so that we can handle I2C and
SPI busses independently. The new SPI bus logic brings in support for a
lot more parts:
AD5160, AD5161, AD5162, AD5165, AD5200, AD5201, AD5203,
AD5204, AD5206, AD5207, AD5231, AD5232, AD5233, AD5235,
AD5260, AD5262, AD5263, AD5290, AD5291, AD5292, AD5293,
AD7376, AD8400, AD8402, AD8403, ADN2850
[randy.dunlap@oracle.com: fix ad525X_dpot build]
Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2010-05-24 21:33:14 +00:00
|
|
|
MODULE_DESCRIPTION("digital potentiometer I2C bus driver");
|
|
|
|
MODULE_LICENSE("GPL");
|