18 #include <linux/kernel.h>
19 #include <linux/module.h>
21 #include <linux/slab.h>
22 #include <linux/i2c.h>
24 #include <linux/device.h>
27 #define MCP3021_VDD_MAX 5500
28 #define MCP3021_VDD_MIN 2700
29 #define MCP3021_VDD_REF 3300
32 #define MCP3021_SAR_SHIFT 2
33 #define MCP3021_SAR_MASK 0x3ff
35 #define MCP3021_OUTPUT_RES 10
36 #define MCP3021_OUTPUT_SCALE 4
38 #define MCP3221_SAR_SHIFT 0
39 #define MCP3221_SAR_MASK 0xfff
40 #define MCP3221_OUTPUT_RES 12
41 #define MCP3221_OUTPUT_SCALE 1
103 reg = mcp3021_read16(client);
107 in_input = volts_from_reg(data, reg);
109 return sprintf(buf,
"%d\n", in_input);
114 static int mcp3021_probe(
struct i2c_client *client,
128 i2c_set_clientdata(client, data);
130 switch (id->driver_data) {
146 if (client->
dev.platform_data) {
147 data->
vdd = *(
u32 *)client->
dev.platform_data;
170 static int mcp3021_remove(
struct i2c_client *client)
191 .probe = mcp3021_probe,
192 .remove = mcp3021_remove,
193 .id_table = mcp3021_id,