22 #include <linux/kernel.h>
23 #include <linux/module.h>
26 #include <linux/slab.h>
27 #include <linux/i2c.h>
33 #define UCD9000_MONITOR_CONFIG 0xd5
34 #define UCD9000_NUM_PAGES 0xd6
35 #define UCD9000_FAN_CONFIG_INDEX 0xe7
36 #define UCD9000_FAN_CONFIG 0xe8
37 #define UCD9000_DEVICE_ID 0xfd
39 #define UCD9000_MON_TYPE(x) (((x) >> 5) & 0x07)
40 #define UCD9000_MON_PAGE(x) ((x) & 0x0f)
42 #define UCD9000_MON_VOLTAGE 1
43 #define UCD9000_MON_TEMPERATURE 2
44 #define UCD9000_MON_CURRENT 3
45 #define UCD9000_MON_VOLTAGE_HW 4
47 #define UCD9000_NUM_FAN 4
53 #define to_ucd9000_data(_info) container_of(_info, struct ucd9000_data, info)
80 ret = ucd9000_get_fan_config(client, 0);
83 fan_config = ret << 4;
84 ret = ucd9000_get_fan_config(client, 1);
94 ret = ucd9000_get_fan_config(client, 2);
97 fan_config = ret << 4;
98 ret = ucd9000_get_fan_config(client, 3);
121 static int ucd9000_probe(
struct i2c_client *client,
130 if (!i2c_check_functionality(client->
adapter,
138 dev_err(&client->
dev,
"Failed to read device ID\n");
141 block_buffer[
ret] =
'\0';
142 dev_info(&client->
dev,
"Device ID %s\n", block_buffer);
144 for (mid = ucd9000_id; mid->
name[0]; mid++) {
149 dev_err(&client->
dev,
"Unsupported device\n");
153 if (id->driver_data !=
ucd9000 && id->driver_data != mid->driver_data)
154 dev_notice(&client->
dev,
155 "Device mismatch: Configured %s, detected %s\n",
167 "Failed to read number of active pages\n");
172 dev_err(&client->
dev,
"No pages configured\n");
183 dev_err(&client->
dev,
"Failed to read configuration data\n");
186 for (i = 0; i <
ret; i++) {
189 if (page >= info->
pages)
237 .probe = ucd9000_probe,
239 .id_table = ucd9000_id,