22 #include <linux/module.h>
24 #include <linux/i2c.h>
29 #include <linux/slab.h>
32 static const unsigned short normal_i2c[] = { 0x69,
I2C_CLIENT_END };
35 #define ICS932S401_REG_CFG2 0x01
36 #define ICS932S401_CFG1_SPREAD 0x01
37 #define ICS932S401_REG_CFG7 0x06
38 #define ICS932S401_FS_MASK 0x07
39 #define ICS932S401_REG_VENDOR_REV 0x07
40 #define ICS932S401_VENDOR 1
41 #define ICS932S401_VENDOR_MASK 0x0F
42 #define ICS932S401_REV 4
43 #define ICS932S401_REV_SHIFT 4
44 #define ICS932S401_REG_DEVICE 0x09
45 #define ICS932S401_DEVICE 11
46 #define ICS932S401_REG_CTRL 0x0A
47 #define ICS932S401_MN_ENABLED 0x80
48 #define ICS932S401_CPU_ALT 0x04
49 #define ICS932S401_SRC_ALT 0x08
50 #define ICS932S401_REG_CPU_M_CTRL 0x0B
51 #define ICS932S401_M_MASK 0x3F
52 #define ICS932S401_REG_CPU_N_CTRL 0x0C
53 #define ICS932S401_REG_CPU_SPREAD1 0x0D
54 #define ICS932S401_REG_CPU_SPREAD2 0x0E
55 #define ICS932S401_SPREAD_MASK 0x7FFF
56 #define ICS932S401_REG_SRC_M_CTRL 0x0F
57 #define ICS932S401_REG_SRC_N_CTRL 0x10
58 #define ICS932S401_REG_SRC_SPREAD1 0x11
59 #define ICS932S401_REG_SRC_SPREAD2 0x12
60 #define ICS932S401_REG_CPU_DIVISOR 0x13
61 #define ICS932S401_CPU_DIVISOR_SHIFT 4
62 #define ICS932S401_REG_PCISRC_DIVISOR 0x14
63 #define ICS932S401_SRC_DIVISOR_MASK 0x0F
64 #define ICS932S401_PCI_DIVISOR_SHIFT 4
67 #define BASE_CLOCK 14318
70 #define NUM_MIRRORED_REGS 15
91 #define SENSOR_REFRESH_INTERVAL (2 * HZ)
94 #define LIMIT_REFRESH_INTERVAL (60 * HZ)
117 static struct i2c_driver ics932s401_driver = {
120 .name =
"ics932s401",
122 .probe = ics932s401_probe,
123 .remove = ics932s401_remove,
124 .id_table = ics932s401_id,
125 .detect = ics932s401_detect,
126 .address_list = normal_i2c,
133 unsigned long local_jiffies =
jiffies;
149 data->
regs[regs_to_copy[
i]] = temp >> 8;
173 static const int fs_speeds[] = {
185 static const int divisors[] = {2, 3, 5, 15, 4, 6, 10, 30, 8, 12, 20, 60, 16,
213 return sprintf(buf,
"%d\n", calculate_cpu_freq(data));
224 freq = calculate_cpu_freq(data);
228 freq = fs_speeds[
fid];
241 return sprintf(buf,
"%d\n", freq);
269 return sprintf(buf,
"%d\n", calculate_src_freq(data));
280 freq = calculate_src_freq(data);
289 return sprintf(buf,
"%d\n", freq);
317 return sprintf(buf,
"%d\n", calculate_pci_freq(data));
328 freq = calculate_pci_freq(data);
332 return sprintf(buf,
"%d\n", freq);
355 static struct attribute *ics932s401_attr[] =
357 &dev_attr_spread_enabled.attr,
358 &dev_attr_cpu_clock_selection.attr,
359 &dev_attr_cpu_clock.attr,
360 &dev_attr_src_clock_selection.attr,
361 &dev_attr_src_clock.attr,
362 &dev_attr_pci_clock_selection.attr,
363 &dev_attr_pci_clock.attr,
364 &dev_attr_usb_clock.attr,
365 &dev_attr_ref_clock.attr,
366 &dev_attr_cpu_spread.attr,
367 &dev_attr_src_spread.attr,
377 if (devattr == &dev_attr_usb_clock)
379 else if (devattr == &dev_attr_ref_clock)
384 return sprintf(buf,
"%d\n", x);
398 if (devattr == &dev_attr_src_spread)
400 else if (devattr == &dev_attr_cpu_spread)
405 val = data->
regs[
reg] | (data->
regs[reg + 1] << 8);
409 val = 500000 * val / 16384;
410 return sprintf(buf,
"-0.%lu%%\n", val);
414 static int ics932s401_detect(
struct i2c_client *client,
436 dev_info(&adapter->
dev,
"Unknown revision %d\n", revision);
443 static int ics932s401_probe(
struct i2c_client *client,
455 i2c_set_clientdata(client, data);
461 data->
attrs.attrs = ics932s401_attr;
474 static int ics932s401_remove(
struct i2c_client *client)