20 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
22 #include <linux/module.h>
24 #include <linux/slab.h>
33 #define DRVNAME "sch5627"
34 #define DEVNAME DRVNAME
36 #define SCH5627_HWMON_ID 0xa5
37 #define SCH5627_COMPANY_ID 0x5c
38 #define SCH5627_PRIMARY_ID 0xa0
40 #define SCH5627_REG_BUILD_CODE 0x39
41 #define SCH5627_REG_BUILD_ID 0x3a
42 #define SCH5627_REG_HWMON_ID 0x3c
43 #define SCH5627_REG_HWMON_REV 0x3d
44 #define SCH5627_REG_COMPANY_ID 0x3e
45 #define SCH5627_REG_PRIMARY_ID 0x3f
46 #define SCH5627_REG_CTRL 0x40
48 #define SCH5627_NO_TEMPS 8
49 #define SCH5627_NO_FANS 4
50 #define SCH5627_NO_IN 5
53 0x2B, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x180, 0x181 };
55 0xE2, 0xE1, 0xE1, 0xE5, 0xE5, 0xE6, 0x182, 0x182 };
57 0, 0, 1, 1, 0, 0, 0, 1 };
59 0x61, 0x57, 0x59, 0x5B, 0x5D, 0x5F, 0x184, 0x186 };
61 0x9B, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x1A8, 0x1A9 };
64 0x2C, 0x2E, 0x30, 0x32 };
66 0x62, 0x64, 0x66, 0x68 };
69 0x22, 0x23, 0x24, 0x25, 0x189 };
71 0xE4, 0xE4, 0xE3, 0xE3, 0x18A };
75 10745, 3660, 9765, 10745, 3660 };
76 static const char *
const SCH5627_IN_LABELS[
SCH5627_NO_IN] = {
77 "VCC",
"VTT",
"VBAT",
"VTR",
"V_IN" };
116 SCH5627_REG_TEMP_MSB[i],
117 SCH5627_REG_TEMP_LSN[i],
118 SCH5627_REG_TEMP_HIGH_NIBBLE[i]);
138 SCH5627_REG_IN_MSB[i],
139 SCH5627_REG_IN_LSN[i],
140 SCH5627_REG_IN_HIGH_NIBBLE[i]);
166 SCH5627_REG_TEMP_ABS[i]);
172 SCH5627_REG_TEMP_HIGH[i]);
179 SCH5627_REG_FAN_MIN[i]);
188 static int reg_to_temp(
u16 reg)
190 return (reg * 625) / 10 - 64000;
193 static int reg_to_temp_limit(
u8 reg)
195 return (reg - 64) * 1000;
198 static int reg_to_rpm(
u16 reg)
205 return 5400540 /
reg;
222 return PTR_ERR(data);
224 val = reg_to_temp(data->
temp[attr->
index]);
235 return PTR_ERR(data);
270 return PTR_ERR(data);
272 val = reg_to_rpm(data->
fan[attr->
index]);
286 return PTR_ERR(data);
312 return PTR_ERR(data);
315 data->
in[attr->
index] * SCH5627_REG_IN_FACTOR[attr->
index],
326 SCH5627_IN_LABELS[attr->
index]);
386 static struct attribute *sch5627_attributes[] = {
389 &sensor_dev_attr_temp1_input.dev_attr.attr,
390 &sensor_dev_attr_temp2_input.dev_attr.attr,
391 &sensor_dev_attr_temp3_input.dev_attr.attr,
392 &sensor_dev_attr_temp4_input.dev_attr.attr,
393 &sensor_dev_attr_temp5_input.dev_attr.attr,
394 &sensor_dev_attr_temp6_input.dev_attr.attr,
395 &sensor_dev_attr_temp7_input.dev_attr.attr,
396 &sensor_dev_attr_temp8_input.dev_attr.attr,
397 &sensor_dev_attr_temp1_fault.dev_attr.attr,
398 &sensor_dev_attr_temp2_fault.dev_attr.attr,
399 &sensor_dev_attr_temp3_fault.dev_attr.attr,
400 &sensor_dev_attr_temp4_fault.dev_attr.attr,
401 &sensor_dev_attr_temp5_fault.dev_attr.attr,
402 &sensor_dev_attr_temp6_fault.dev_attr.attr,
403 &sensor_dev_attr_temp7_fault.dev_attr.attr,
404 &sensor_dev_attr_temp8_fault.dev_attr.attr,
405 &sensor_dev_attr_temp1_max.dev_attr.attr,
406 &sensor_dev_attr_temp2_max.dev_attr.attr,
407 &sensor_dev_attr_temp3_max.dev_attr.attr,
408 &sensor_dev_attr_temp4_max.dev_attr.attr,
409 &sensor_dev_attr_temp5_max.dev_attr.attr,
410 &sensor_dev_attr_temp6_max.dev_attr.attr,
411 &sensor_dev_attr_temp7_max.dev_attr.attr,
412 &sensor_dev_attr_temp8_max.dev_attr.attr,
413 &sensor_dev_attr_temp1_crit.dev_attr.attr,
414 &sensor_dev_attr_temp2_crit.dev_attr.attr,
415 &sensor_dev_attr_temp3_crit.dev_attr.attr,
416 &sensor_dev_attr_temp4_crit.dev_attr.attr,
417 &sensor_dev_attr_temp5_crit.dev_attr.attr,
418 &sensor_dev_attr_temp6_crit.dev_attr.attr,
419 &sensor_dev_attr_temp7_crit.dev_attr.attr,
420 &sensor_dev_attr_temp8_crit.dev_attr.attr,
422 &sensor_dev_attr_fan1_input.dev_attr.attr,
423 &sensor_dev_attr_fan2_input.dev_attr.attr,
424 &sensor_dev_attr_fan3_input.dev_attr.attr,
425 &sensor_dev_attr_fan4_input.dev_attr.attr,
426 &sensor_dev_attr_fan1_fault.dev_attr.attr,
427 &sensor_dev_attr_fan2_fault.dev_attr.attr,
428 &sensor_dev_attr_fan3_fault.dev_attr.attr,
429 &sensor_dev_attr_fan4_fault.dev_attr.attr,
430 &sensor_dev_attr_fan1_min.dev_attr.attr,
431 &sensor_dev_attr_fan2_min.dev_attr.attr,
432 &sensor_dev_attr_fan3_min.dev_attr.attr,
433 &sensor_dev_attr_fan4_min.dev_attr.attr,
435 &sensor_dev_attr_in0_input.dev_attr.attr,
436 &sensor_dev_attr_in1_input.dev_attr.attr,
437 &sensor_dev_attr_in2_input.dev_attr.attr,
438 &sensor_dev_attr_in3_input.dev_attr.attr,
439 &sensor_dev_attr_in4_input.dev_attr.attr,
440 &sensor_dev_attr_in0_label.dev_attr.attr,
441 &sensor_dev_attr_in1_label.dev_attr.attr,
442 &sensor_dev_attr_in2_label.dev_attr.attr,
443 &sensor_dev_attr_in3_label.dev_attr.attr,
450 .attrs = sch5627_attributes,
471 int err, build_code, build_id, hwmon_rev,
val;
480 platform_set_drvdata(pdev, data);
488 pr_err(
"invalid %s id: 0x%02X (expected 0x%02X)\n",
"hwmon",
500 pr_err(
"invalid %s id: 0x%02X (expected 0x%02X)\n",
"company",
512 pr_err(
"invalid %s id: 0x%02X (expected 0x%02X)\n",
"primary",
520 if (build_code < 0) {
546 pr_err(
"hardware monitoring not enabled\n");
560 err = sch5627_read_limits(data);
565 pr_info(
"firmware build: code 0x%02X, id 0x%04X, hwmon: rev 0x%02X\n",
566 build_code, build_id, hwmon_rev);
582 (build_code << 24) | (build_id << 8) | hwmon_rev,
588 sch5627_remove(pdev);
597 .probe = sch5627_probe,
598 .remove = sch5627_remove,