1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Driver for the Analog Devices digital potentiometers (I2C bus)
5 * Copyright (C) 2010-2011 Michael Hennerich, Analog Devices Inc.
9 #include <linux/module.h>
11 #include "ad525x_dpot.h"
13 /* I2C bus functions */
14 static int write_d8(void *client, u8 val)
16 return i2c_smbus_write_byte(client, val);
19 static int write_r8d8(void *client, u8 reg, u8 val)
21 return i2c_smbus_write_byte_data(client, reg, val);
24 static int write_r8d16(void *client, u8 reg, u16 val)
26 return i2c_smbus_write_word_data(client, reg, val);
29 static int read_d8(void *client)
31 return i2c_smbus_read_byte(client);
34 static int read_r8d8(void *client, u8 reg)
36 return i2c_smbus_read_byte_data(client, reg);
39 static int read_r8d16(void *client, u8 reg)
41 return i2c_smbus_read_word_data(client, reg);
44 static const struct ad_dpot_bus_ops bops = {
46 .read_r8d8 = read_r8d8,
47 .read_r8d16 = read_r8d16,
49 .write_r8d8 = write_r8d8,
50 .write_r8d16 = write_r8d16,
53 static int ad_dpot_i2c_probe(struct i2c_client *client,
54 const struct i2c_device_id *id)
56 struct ad_dpot_bus_data bdata = {
61 if (!i2c_check_functionality(client->adapter,
62 I2C_FUNC_SMBUS_WORD_DATA)) {
63 dev_err(&client->dev, "SMBUS Word Data not Supported\n");
67 return ad_dpot_probe(&client->dev, &bdata, id->driver_data, id->name);
70 static int ad_dpot_i2c_remove(struct i2c_client *client)
72 ad_dpot_remove(&client->dev);
76 static const struct i2c_device_id ad_dpot_id[] = {
77 {"ad5258", AD5258_ID},
78 {"ad5259", AD5259_ID},
79 {"ad5251", AD5251_ID},
80 {"ad5252", AD5252_ID},
81 {"ad5253", AD5253_ID},
82 {"ad5254", AD5254_ID},
83 {"ad5255", AD5255_ID},
84 {"ad5241", AD5241_ID},
85 {"ad5242", AD5242_ID},
86 {"ad5243", AD5243_ID},
87 {"ad5245", AD5245_ID},
88 {"ad5246", AD5246_ID},
89 {"ad5247", AD5247_ID},
90 {"ad5248", AD5248_ID},
91 {"ad5280", AD5280_ID},
92 {"ad5282", AD5282_ID},
93 {"adn2860", ADN2860_ID},
94 {"ad5273", AD5273_ID},
95 {"ad5161", AD5161_ID},
96 {"ad5171", AD5171_ID},
97 {"ad5170", AD5170_ID},
98 {"ad5172", AD5172_ID},
99 {"ad5173", AD5173_ID},
100 {"ad5272", AD5272_ID},
101 {"ad5274", AD5274_ID},
104 MODULE_DEVICE_TABLE(i2c, ad_dpot_id);
106 static struct i2c_driver ad_dpot_i2c_driver = {
110 .probe = ad_dpot_i2c_probe,
111 .remove = ad_dpot_i2c_remove,
112 .id_table = ad_dpot_id,
115 module_i2c_driver(ad_dpot_i2c_driver);
117 MODULE_AUTHOR("Michael Hennerich <michael.hennerich@analog.com>");
118 MODULE_DESCRIPTION("digital potentiometer I2C bus driver");
119 MODULE_LICENSE("GPL");