Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Driver for the Analog Devices digital potentiometers (I2C bus)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Copyright (C) 2010-2011 Michael Hennerich, Analog Devices Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #include <linux/i2c.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include "ad525x_dpot.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) /* I2C bus functions */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) static int write_d8(void *client, u8 val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 	return i2c_smbus_write_byte(client, val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) static int write_r8d8(void *client, u8 reg, u8 val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 	return i2c_smbus_write_byte_data(client, reg, val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) static int write_r8d16(void *client, u8 reg, u16 val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 	return i2c_smbus_write_word_data(client, reg, val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) static int read_d8(void *client)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	return i2c_smbus_read_byte(client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) static int read_r8d8(void *client, u8 reg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	return i2c_smbus_read_byte_data(client, reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) static int read_r8d16(void *client, u8 reg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	return i2c_smbus_read_word_data(client, reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) static const struct ad_dpot_bus_ops bops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	.read_d8	= read_d8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	.read_r8d8	= read_r8d8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	.read_r8d16	= read_r8d16,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	.write_d8	= write_d8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	.write_r8d8	= write_r8d8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	.write_r8d16	= write_r8d16,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) static int ad_dpot_i2c_probe(struct i2c_client *client,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 				      const struct i2c_device_id *id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	struct ad_dpot_bus_data bdata = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 		.client = client,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 		.bops = &bops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	if (!i2c_check_functionality(client->adapter,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 				     I2C_FUNC_SMBUS_WORD_DATA)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 		dev_err(&client->dev, "SMBUS Word Data not Supported\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	return ad_dpot_probe(&client->dev, &bdata, id->driver_data, id->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) static int ad_dpot_i2c_remove(struct i2c_client *client)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	return ad_dpot_remove(&client->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) static const struct i2c_device_id ad_dpot_id[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	{"ad5258", AD5258_ID},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	{"ad5259", AD5259_ID},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	{"ad5251", AD5251_ID},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	{"ad5252", AD5252_ID},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	{"ad5253", AD5253_ID},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	{"ad5254", AD5254_ID},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	{"ad5255", AD5255_ID},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	{"ad5241", AD5241_ID},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	{"ad5242", AD5242_ID},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	{"ad5243", AD5243_ID},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	{"ad5245", AD5245_ID},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	{"ad5246", AD5246_ID},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	{"ad5247", AD5247_ID},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	{"ad5248", AD5248_ID},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	{"ad5280", AD5280_ID},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	{"ad5282", AD5282_ID},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	{"adn2860", ADN2860_ID},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	{"ad5273", AD5273_ID},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	{"ad5161", AD5161_ID},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	{"ad5171", AD5171_ID},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	{"ad5170", AD5170_ID},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	{"ad5172", AD5172_ID},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	{"ad5173", AD5173_ID},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	{"ad5272", AD5272_ID},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	{"ad5274", AD5274_ID},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	{}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) MODULE_DEVICE_TABLE(i2c, ad_dpot_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) static struct i2c_driver ad_dpot_i2c_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	.driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 		.name	= "ad_dpot",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	.probe		= ad_dpot_i2c_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	.remove		= ad_dpot_i2c_remove,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	.id_table	= ad_dpot_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) module_i2c_driver(ad_dpot_i2c_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) MODULE_AUTHOR("Michael Hennerich <michael.hennerich@analog.com>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) MODULE_DESCRIPTION("digital potentiometer I2C bus driver");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) MODULE_LICENSE("GPL");