Commit 8e9285b0bb2ab48924032147baa29699c0bbee7c
1 parent
bbd8decd41
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
hwmon: (nct6775) Detect and report additional temperature sources
Scan all temperature sources used for fan control and report if additional monitoring registers are available. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Showing 1 changed file with 33 additions and 0 deletions Side-by-side Diff
drivers/hwmon/nct6775.c
... | ... | @@ -3364,6 +3364,32 @@ |
3364 | 3364 | return 0; |
3365 | 3365 | } |
3366 | 3366 | |
3367 | +static void add_temp_sensors(struct nct6775_data *data, const u16 *regp, | |
3368 | + int *available, int *mask) | |
3369 | +{ | |
3370 | + int i; | |
3371 | + u8 src; | |
3372 | + | |
3373 | + for (i = 0; i < data->pwm_num && *available; i++) { | |
3374 | + int index; | |
3375 | + | |
3376 | + if (!regp[i]) | |
3377 | + continue; | |
3378 | + src = nct6775_read_value(data, regp[i]); | |
3379 | + src &= 0x1f; | |
3380 | + if (!src || (*mask & (1 << src))) | |
3381 | + continue; | |
3382 | + if (src >= data->temp_label_num || | |
3383 | + !strlen(data->temp_label[src])) | |
3384 | + continue; | |
3385 | + | |
3386 | + index = __ffs(*available); | |
3387 | + nct6775_write_value(data, data->REG_TEMP_SOURCE[index], src); | |
3388 | + *available &= ~(1 << index); | |
3389 | + *mask |= 1 << src; | |
3390 | + } | |
3391 | +} | |
3392 | + | |
3367 | 3393 | static int nct6775_probe(struct platform_device *pdev) |
3368 | 3394 | { |
3369 | 3395 | struct device *dev = &pdev->dev; |
... | ... | @@ -3613,6 +3639,13 @@ |
3613 | 3639 | |
3614 | 3640 | mask |= 1 << src; |
3615 | 3641 | } |
3642 | + | |
3643 | + /* | |
3644 | + * Now find unmonitored temperature registers and enable monitoring | |
3645 | + * if additional monitoring registers are available. | |
3646 | + */ | |
3647 | + add_temp_sensors(data, data->REG_TEMP_SEL, &available, &mask); | |
3648 | + add_temp_sensors(data, data->REG_WEIGHT_TEMP_SEL, &available, &mask); | |
3616 | 3649 | |
3617 | 3650 | mask = 0; |
3618 | 3651 | s = NUM_TEMP_FIXED; /* First dynamic temperature attribute */ |