23 #include <linux/module.h>
29 #include <linux/pci.h>
31 #include <linux/slab.h>
33 #define DRVNAME "i5k_amb"
35 #define I5K_REG_AMB_BASE_ADDR 0x48
36 #define I5K_REG_AMB_LEN_ADDR 0x50
37 #define I5K_REG_CHAN0_PRESENCE_ADDR 0x64
38 #define I5K_REG_CHAN1_PRESENCE_ADDR 0x66
40 #define AMB_REG_TEMP_MIN_ADDR 0x80
41 #define AMB_REG_TEMP_MID_ADDR 0x81
42 #define AMB_REG_TEMP_MAX_ADDR 0x82
43 #define AMB_REG_TEMP_STATUS_ADDR 0x84
44 #define AMB_REG_TEMP_ADDR 0x85
46 #define AMB_CONFIG_SIZE 2048
47 #define AMB_FUNC_3_OFFSET 768
49 static unsigned long amb_reg_temp_status(
unsigned int amb)
55 static unsigned long amb_reg_temp_min(
unsigned int amb)
61 static unsigned long amb_reg_temp_mid(
unsigned int amb)
67 static unsigned long amb_reg_temp_max(
unsigned int amb)
73 static unsigned long amb_reg_temp(
unsigned int amb)
79 #define MAX_MEM_CHANNELS 4
80 #define MAX_AMBS_PER_CHANNEL 16
81 #define MAX_AMBS (MAX_MEM_CHANNELS * \
83 #define CHANNEL_SHIFT 4
92 #define REAL_MAX_AMBS_PER_CHANNEL 15
93 #define KNOBS_PER_AMB 6
95 static unsigned long amb_num_from_reg(
unsigned int byte_num,
unsigned int bit)
100 #define AMB_SYSFS_NAME_LEN 16
146 if (!(amb_read_byte(data, amb_reg_temp_status(attr->
index)) & 0x20) &&
147 (amb_read_byte(data, amb_reg_temp_status(attr->
index)) & 0x8))
161 int ret = kstrtoul(buf, 10, &temp);
169 amb_write_byte(data, amb_reg_temp_min(attr->
index), temp);
181 int ret = kstrtoul(buf, 10, &temp);
189 amb_write_byte(data, amb_reg_temp_mid(attr->
index), temp);
201 int ret = kstrtoul(buf, 10, &temp);
209 amb_write_byte(data, amb_reg_temp_max(attr->
index), temp);
220 500 * amb_read_byte(data, amb_reg_temp_min(attr->
index)));
230 500 * amb_read_byte(data, amb_reg_temp_mid(attr->
index)));
240 500 * amb_read_byte(data, amb_reg_temp_max(attr->
index)));
250 500 * amb_read_byte(data, amb_reg_temp(attr->
index)));
285 for (j = 0; j < REAL_MAX_AMBS_PER_CHANNEL; j++, c >>= 1) {
288 k = amb_num_from_reg(i, j);
297 iattr->
s_attr.dev_attr.attr.name = iattr->
name;
299 iattr->
s_attr.dev_attr.show = show_label;
312 iattr->
s_attr.dev_attr.attr.name = iattr->
name;
314 iattr->
s_attr.dev_attr.show = show_amb_temp;
327 iattr->
s_attr.dev_attr.attr.name = iattr->
name;
329 iattr->
s_attr.dev_attr.show = show_amb_min;
330 iattr->
s_attr.dev_attr.store = store_amb_min;
343 iattr->
s_attr.dev_attr.attr.name = iattr->
name;
345 iattr->
s_attr.dev_attr.show = show_amb_mid;
346 iattr->
s_attr.dev_attr.store = store_amb_mid;
359 iattr->
s_attr.dev_attr.attr.name = iattr->
name;
361 iattr->
s_attr.dev_attr.show = show_amb_max;
362 iattr->
s_attr.dev_attr.store = store_amb_max;
375 iattr->
s_attr.dev_attr.attr.name = iattr->
name;
377 iattr->
s_attr.dev_attr.show = show_amb_alarm;
452 dev_err(&pcidev->
dev,
"AMB region too small!\n");
475 amb_present[0] = val16;
479 amb_present[1] = val16;
519 res = i5k_find_amb_registers(data, chipset_ids[i].
err);
523 }
while (chipset_ids[i].
err);
529 res = i5k_channel_probe(&data->
amb_present[0], chipset_ids[i].fbd0);
534 i5k_channel_probe(&data->
amb_present[2], chipset_ids[i].fbd0 + 1);
549 platform_set_drvdata(pdev, data);
551 res = i5k_amb_hwmon_init(pdev);
553 goto err_init_failed;
559 platform_set_drvdata(pdev,
NULL);
579 platform_set_drvdata(pdev,
NULL);
589 .probe = i5k_amb_probe,
593 static int __init i5k_amb_init(
void)
608 static void __exit i5k_amb_exit(
void)