21 #include <linux/kernel.h>
23 #include <linux/module.h>
25 #include <linux/i2c.h>
31 #include <linux/slab.h>
38 #define ATXP1_VID 0x00
39 #define ATXP1_CVID 0x01
40 #define ATXP1_GPIO1 0x06
41 #define ATXP1_GPIO2 0x0a
42 #define ATXP1_VIDENA 0x20
43 #define ATXP1_VIDMASK 0x1f
44 #define ATXP1_GPIO1MASK 0x0f
46 static const unsigned short normal_i2c[] = { 0x37, 0x4e,
I2C_CLIENT_END };
66 .remove = atxp1_remove,
68 .detect = atxp1_detect,
69 .address_list = normal_i2c,
92 data = i2c_get_clientdata(client);
120 data = atxp1_update_device(dev);
130 const char *buf,
size_t count)
139 data = atxp1_update_device(dev);
141 err = kstrtoul(buf, 10, &vcore);
149 vid = vid_to_reg(vcore, data->
vrm);
152 dev_err(dev,
"VID calculation failed.\n");
163 cvid = data->
reg.cpu_vid;
169 dev_dbg(dev,
"Setting VCore to %d mV (0x%02x)\n", (
int)vcore, vid);
173 for (; cvid >=
vid; cvid--)
177 for (; cvid <=
vid; cvid++)
201 data = atxp1_update_device(dev);
218 data = atxp1_update_device(dev);
220 err = kstrtoul(buf, 16, &value);
227 dev_info(dev,
"Writing 0x%x to GPIO1.\n", (
unsigned int)value);
250 data = atxp1_update_device(dev);
252 size =
sprintf(buf,
"0x%02x\n", data->
reg.gpio2);
259 const char *buf,
size_t count)
261 struct atxp1_data *data = atxp1_update_device(dev);
266 err = kstrtoul(buf, 16, &value);
271 if (value != data->
reg.gpio2) {
272 dev_info(dev,
"Writing 0x%x to GPIO1.\n", (
unsigned int)value);
288 static struct attribute *atxp1_attributes[] = {
289 &dev_attr_gpio1.attr,
290 &dev_attr_gpio2.attr,
291 &dev_attr_cpu0_vid.attr,
296 .attrs = atxp1_attributes,
301 static int atxp1_detect(
struct i2c_client *new_client,
331 if ((temp != 90) && (temp != 91)) {
332 dev_err(&adapter->
dev,
"atxp1: Not supporting VRM %d.%d\n",
333 temp / 10, temp % 10);
342 static int atxp1_probe(
struct i2c_client *new_client,
356 i2c_set_clientdata(new_client, data);
369 goto exit_remove_files;
373 data->
vrm / 10, data->
vrm % 10);
382 static int atxp1_remove(
struct i2c_client *client)
384 struct atxp1_data *data = i2c_get_clientdata(client);