All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jean Delvare <khali@linux-fr.org>
To: lm-sensors@vger.kernel.org
Subject: Re: [lm-sensors] Help needed for implementing&testing Fintek F75375
Date: Sat, 23 Jun 2007 12:29:36 +0000	[thread overview]
Message-ID: <20070623142936.580e8ce8@hyperion.delvare> (raw)
In-Reply-To: <5327.79319.qm@web25109.mail.ukl.yahoo.com>

Hi Christian,

On Mon, 18 Jun 2007 18:58:24 +0200 (CEST), Christian Emmerich wrote:
> I've attached a patch for Fintek F75373S support, 
> kernel module f75375s is required.
> 
> At the moment it is possible to read out 4 different voltage 
> values, 2 temperatures and 2 fans/pwm (i've only one fan 
> connected, so i could only verify that one of two is working
> correct).

OK, my review is below.

> I was not able to adjust fan speed using fancontrol, 
> i have to do it by hand.

Did pwmconfig work?

> sensors output looks like:
> mythtv@pc:~$ sensors F75373-*
> F75373-i2c-1-2d
> Adapter: SMBus nForce2 adapter at 5100
> VCC:       +1.72 V  (min =  +0.00 V, max =  +0.00 V)  
> V1:        +1.34 V  (min =  +0.00 V, max =  +0.00 V)  
> V2:        +1.01 V  (min =  +0.00 V, max =  +0.00 V)  
> V3:        +0.77 V  (min =  +0.00 V, max =  +0.00 V)  
> CPU Temp:    +50°C  (high =    +0°C, hyst =    +0°C)  
> Sys Temp:    +47°C  (high =    +0°C, hyst =    +0°C)  
> CPU Fan:  1866 RPM  (min =    0 RPM)
> CPU PWM:    31      (enable = 1)

Did you try setting limits?

> diff -urN lm-sensors_org/etc/sensors.conf.eg lm-sensors/etc/sensors.conf.eg
> --- lm-sensors_org/etc/sensors.conf.eg	2007-06-17 15:34:35.000000000 +0200
> +++ lm-sensors/etc/sensors.conf.eg	2007-06-17 16:54:34.000000000 +0200
> @@ -2880,3 +2880,36 @@
>  #   set fan4_min 1000
>  #   set fan5_min 1000
>  #   set fan6_min 1000
> +
> +
> +#
> +# Sample configuration for the Fintek F75373
> +#
> +chip "f75373-*"
> +
> +# Voltages
> +   label in0_input "VCC"
> +   label in1_input "V1"
> +   label in2_input "V2"
> +   label in3_input "V3"
> +
> +   compute in0_input  @/1000,@/1000
> +   compute in1_input  @/1000,@/1000
> +   compute in2_input  @/1000,@/1000
> +   compute in3_input  @/1000,@/1000

That's not correct, you should have "in0", "in1"... etc. here, not
"in0_input", "in1_input" etc? The fan and temperature symbols below are
correct.

Also, these compute lines don't make sense. The second formula is
supposed to be the reserve of the first formula, that's not the case
here.

Lastly, you really shouldn't have to divide the values by 1000. This
suggests that the magnitude wasn't set properly in libsensors (it
should be 3, I suggest it is 0). This issue is most probably related to
the incorrect symbol names.

> +
> +# Fans
> +   label fan1 "CPU Fan"
> +   label fan2 "Sys Fan"
> +
> +   compute fan1  ( 1.5 * 1000000 )/@,  ( 1.5 * 1000000 )/@
> +   compute fan2  ( 1.5 * 1000000 )/@,  ( 1.5 * 1000000 )/@

This means that the driver isn't reporting the values in RPM as it
should. Usually no compute statement is needed for fans.

> +
> +# Temperatures
> +   label temp1 "CPU Temp"
> +   label temp2 "Sys Temp"
> +   
> +# PWM
> +   label pwm1   "CPU PWM"
> +   label pwm2   "Sys PWM"
> +
> diff -urN lm-sensors_org/lib/chips.c lm-sensors/lib/chips.c
> --- lm-sensors_org/lib/chips.c	2007-06-17 15:34:32.000000000 +0200
> +++ lm-sensors/lib/chips.c	2007-06-17 15:57:49.000000000 +0200
> @@ -6108,6 +6108,64 @@
>      { { 0 }, 0 }
>    };
>  
> +
> +
> +#define SENSORS_F75373_IN_FEATURES(nr) \
> +        { { SENSORS_F75373_IN(nr), "in" #nr "_input", \
> +                NOMAP, NOMAP, R }, \
> +                NOSYSCTL, VALUE(3), 3 }, \

OK, the problem is here: This should be"in" #nr, not "in" #nr
"_input". This will fix your magnitude problem.

> +        { { SENSORS_F75373_IN_MIN(nr), "in" #nr "_min", \
> +                SENSORS_F75373_IN(nr), SENSORS_F75373_IN(nr), RW }, \
> +                NOSYSCTL, VALUE(2), 3 }, \

VALUE(1) (although it won't make a difference for a Linux 2.6 only
driver.

> +        { { SENSORS_F75373_IN_MAX(nr), "in" #nr "_max", \
> +                SENSORS_F75373_IN(nr), SENSORS_F75373_IN(nr), RW }, \
> +                NOSYSCTL, VALUE(2), 3 }
> +
> +#define SENSORS_F75373_TEMP_FEATURES(nr) \
> +        { { SENSORS_F75373_TEMP(nr), "temp" #nr "", \
> +                NOMAP, NOMAP, R }, \
> +                NOSYSCTL, VALUE(3), 3 }, \
> +        { { SENSORS_F75373_TEMP_MAX(nr), "temp" #nr "_max", \
> +                SENSORS_F75373_TEMP(nr), SENSORS_F75373_TEMP(nr), RW }, \
> +                NOSYSCTL, VALUE(1), 3 }, \
> +        { { SENSORS_F75373_TEMP_HYST(nr), "temp" #nr "_hyst", \
> +                SENSORS_F75373_TEMP(nr), NOMAP, R }, \
> +                NOSYSCTL, VALUE(1), 0 }

SENSORS_F75373_TEMP(nr) instead of NOMAP, VALUE(2) instead of VALUE(1),
and magnitude 3 instead of 0. Is it really read-only?

(Unless this isn't an hysteresis temperature at all - see below.)

> +
> +#define SENSORS_F75373_FAN_FEATURES(nr) \
> +        { { SENSORS_F75373_FAN(nr), "fan" #nr, \
> +                NOMAP, NOMAP, R }, \
> +                NOSYSCTL, VALUE(2), 0 }, \
> +        { { SENSORS_F75373_FAN_MAX(nr), "fan" #nr "_max", \
> +                SENSORS_F75373_FAN(nr), SENSORS_F75373_FAN(nr), RW }, \
> +                NOSYSCTL, VALUE(1), 0 }, \

Strange, I've never seen a fan speed sensor with a high limit. What
does it correspond to exactly? Why don't you display this value in
"sensors"?

> +        { { SENSORS_F75373_FAN_MIN(nr), "fan" #nr "_min", \
> +                SENSORS_F75373_FAN(nr), NOMAP, R }, \
> +                NOSYSCTL, VALUE(1), 0 }

SENSORS_F75373_FAN(nr) instead of NOMAP.

Is it really read-only?

> +
> +#define SENSORS_F75373_PWM_FEATURES(nr) \
> +        { { SENSORS_F75373_PWM(nr), "pwm" #nr, \
> +                NOMAP, NOMAP, RW }, \
> +                NOSYSCTL, VALUE(1), 0 }, \
> +        { { SENSORS_F75373_PWM_ENABLE(nr), "pwm" #nr "_enable", \
> +                SENSORS_F75373_PWM(nr), SENSORS_F75373_PWM(nr), RW }, \
> +                NOSYSCTL, VALUE(3), 0 }

In fact we don't include PWM stuff in libsensors. They are not sensors,
and are better handled using pwmconfig and fancontrol.

> +
> +static sensors_chip_feature f75373_features[] > +{
> +        SENSORS_F75373_IN_FEATURES(0),
> +        SENSORS_F75373_IN_FEATURES(1),
> +        SENSORS_F75373_IN_FEATURES(2),
> +        SENSORS_F75373_IN_FEATURES(3),
> +        SENSORS_F75373_TEMP_FEATURES(1),
> +        SENSORS_F75373_TEMP_FEATURES(2),
> +        SENSORS_F75373_FAN_FEATURES(1),
> +        SENSORS_F75373_FAN_FEATURES(2),
> +        SENSORS_F75373_PWM_FEATURES(1),
> +        SENSORS_F75373_PWM_FEATURES(2),
> +        { { 0 }, 0 }
> +};
> +
>  sensors_chip_features sensors_chip_features_list[] >  {
>   { SENSORS_LM78_PREFIX, lm78_features },
> @@ -6223,5 +6281,6 @@
>   { SENSORS_CORETEMP_PREFIX, coretemp_features },
>   { SENSORS_DME1737_PREFIX, dme1737_features },
>   { SENSORS_APPLESMC_PREFIX, applesmc_features },
> + { SENSORS_F75373_PREFIX, f75373_features },
>   { 0 }
>  };
> diff -urN lm-sensors_org/lib/chips.h lm-sensors/lib/chips.h
> --- lm-sensors_org/lib/chips.h	2007-06-17 15:34:32.000000000 +0200
> +++ lm-sensors/lib/chips.h	2007-06-17 16:53:25.000000000 +0200
> @@ -2312,4 +2312,28 @@
>  #define SENSORS_APPLESMC_FAN_MAX(n)		(0x61 + (n)) /* R */
>  #define SENSORS_APPLESMC_FAN_SAFE(n)		(0x81 + (n)) /* R */
>  
> +/* Fintek F75373 registers  */
> +
> +#define SENSORS_F75373_PREFIX "f75373"
> +
> +// voltage n from 0 to 3

No C++-style comments please. Use /* */.

> +#define SENSORS_F75373_IN(nr)           (0x10 + (nr))
> +#define SENSORS_F75373_IN_MAX(nr)       (0x20 + (nr) * 2 )
> +#define SENSORS_F75373_IN_MIN(nr)       (0x21 + (nr) * 2 )

Coding style: no space before closing parenthesis.

> +
> +// temp n from 0 to 1
> +#define SENSORS_F75373_TEMP(nr)         (0x14 + (nr))
> +#define SENSORS_F75373_TEMP_MAX(nr)     (0x28 + (nr) * 2 )
> +#define SENSORS_F75373_TEMP_HYST(nr)    (0x29 + (nr) * 2 )
> +
> +// fan n from 0 to 1
> +#define SENSORS_F75373_FAN(nr)          (0x16 + (nr) * 2 )
> +#define SENSORS_F75373_FAN_MIN(nr)      (0x26 + (nr) * 2 )
> +// FAN Full Speed Count Register Index 70h
> +#define SENSORS_F75373_FAN_MAX(nr)      (0x70 + (nr) * 0x10 )
> +
> +// pwm n from 0 to 1
> +#define SENSORS_F75373_PWM(nr)          (0x76 + (nr) * 0x10 )
> +#define SENSORS_F75373_PWM_ENABLE(nr)   (0x7D + (nr) * 0x10 )
> +

I hope that you realize that these numbers do NOT have to match the
register numbers in the chip? These numbers are completely arbitrary.
So please make them as simple as possible.

>  #endif /* def LIB_SENSORS_CHIPS_H */
> diff -urN lm-sensors_org/prog/sensors/chips.c lm-sensors/prog/sensors/chips.c
> --- lm-sensors_org/prog/sensors/chips.c	2007-06-17 15:34:33.000000000 +0200
> +++ lm-sensors/prog/sensors/chips.c	2007-06-17 16:29:50.000000000 +0200
> @@ -6131,6 +6131,114 @@
>  	}
>  }
>  
> +static void print_f75373_in(const sensors_chip_name *name, int i)
> +{
> +  char *label;
> +  double cur, min, max;
> +  int valid;
> +
> +  if (!sensors_get_label_and_valid(*name, SENSORS_F75373_IN(i), &label,
> +                                  &valid) &&
> +      !sensors_get_feature(*name, SENSORS_F75373_IN(i), &cur) &&
> +      !sensors_get_feature(*name, SENSORS_F75373_IN_MAX(i), &max) &&
> +      !sensors_get_feature(*name, SENSORS_F75373_IN_MIN(i), &min)) {
> +    if (valid) {
> +      print_label(label, 10);
> +      printf("%+6.2f V  (min = %+6.2f V, max = %+6.2f V)  \n",
> +             cur, min, max);

If you don't have any alarm flag to display, you can remove the spaces
before the newline.

> +    }
> +  } else {
> +    printf("ERROR: Can't get in%d data!\n", i);
> +  }
> +  free(label);
> +}
> +
> +static void print_f75373_temp(const sensors_chip_name *name, int i)
> +{
> +  char *label;
> +  double cur, max, alarm;
> +  int valid;
> +
> +  if (!sensors_get_label_and_valid(*name, SENSORS_F75373_TEMP(i), &label,
> +                                   &valid) &&
> +      !sensors_get_feature(*name, SENSORS_F75373_TEMP(i), &cur) &&
> +      !sensors_get_feature(*name, SENSORS_F75373_TEMP_MAX(i), &max) &&
> +      !sensors_get_feature(*name, SENSORS_F75373_TEMP_HYST(i), &alarm)
> +      ) {

Coding style: move this at the end of the previous line.

> +    if (valid) {
> +      print_label(label, 10);
> +      print_temp_info(cur, max, 0, HYST , 0, 0);
> +      printf("%s\n", alarm ? "ALARM" : "");
> +    }

This doesn't make sense. What is SENSORS_F75373_TEMP_HYST exactly? Why
do you display it as an alarm?


> +  } else {
> +    printf("ERROR: Can't get temp%d data!\n", i);
> +  }
> +  free(label);
> +}
> +
> +static void print_f75373_fan(const sensors_chip_name *name, int i)
> +{
> +  char *label;
> +  double cur, min;
> +  int valid;
> +
> +  if (!sensors_get_label_and_valid(*name, SENSORS_F75373_FAN(i), &label,
> +                                   &valid) &&
> +      !sensors_get_feature(*name, SENSORS_F75373_FAN(i), &cur) &&
> +      !sensors_get_feature(*name, SENSORS_F75373_FAN_MIN(i), &min)
> +     ){

Coding style: move this at the end of the previous line.

> +    if (valid) {
> +      print_label(label, 10);
> +      printf("%4.0f RPM  (min = %4.0f RPM)\n", 
> +             cur, min);
> +    }
> +  } else {
> +    printf("ERROR: Can't get fan%d data!\n", i);
> +  }
> +  free(label);
> +}
> +
> +static void print_f75373_pwm(const sensors_chip_name *name, int i)
> +{
> +  char *label;
> +  double cur, enable;
> +  int valid;
> +
> +  if (!sensors_get_label_and_valid(*name, SENSORS_F75373_PWM(i), &label,
> +                                   &valid) &&
> +      !sensors_get_feature(*name, SENSORS_F75373_PWM(i), &cur) &&
> +      !sensors_get_feature(*name, SENSORS_F75373_PWM_ENABLE(i), &enable)) {
> +    if (valid) {
> +      print_label(label, 10);
> +      printf("%4.0f      (enable = %1.0f)\n", cur, enable);
> +    }
> +  } else {
> +    printf("ERROR: Can't get pwm%d data!\n", i);
> +  }
> +  free(label);
> +}
> +
> +void print_f75373(const sensors_chip_name *name)
> +{
> +  int i;
> +
> +  for (i = 0; i < 4; i++) {
> +    print_f75373_in(name, i);
> +  }
> +
> +  for (i = 1; i < 3; i++) {

I'd suggest writing it i <= 2, to make it more visible that there are 2
temperature inputs, not 3. Same below for fans.

> +    print_f75373_temp(name, i);
> +  }
> +
> +  for (i = 1; i < 3; i++) {
> +    print_f75373_fan(name, i);
> +  }
> +
> +  for (i = 1; i < 3; i++) {
> +    print_f75373_pwm(name, i);
> +  }
> +}
> +
>  void print_unknown_chip(const sensors_chip_name *name)
>  {
>    int a,b,valid;
> diff -urN lm-sensors_org/prog/sensors/chips.h lm-sensors/prog/sensors/chips.h
> --- lm-sensors_org/prog/sensors/chips.h	2007-06-17 15:34:33.000000000 +0200
> +++ lm-sensors/prog/sensors/chips.h	2007-06-16 20:59:34.000000000 +0200
> @@ -78,5 +78,6 @@
>  extern void print_coretemp(const sensors_chip_name *name);
>  extern void print_dme1737(const sensors_chip_name *name);
>  extern void print_applesmc(const sensors_chip_name *name);
> +extern void print_f75373(const sensors_chip_name *name);
>  
>  #endif /* def PROG_SENSORS_CHIPS_H */
> diff -urN lm-sensors_org/prog/sensors/main.c lm-sensors/prog/sensors/main.c
> --- lm-sensors_org/prog/sensors/main.c	2007-06-17 15:34:33.000000000 +0200
> +++ lm-sensors/prog/sensors/main.c	2007-06-17 08:12:48.000000000 +0200
> @@ -424,6 +424,7 @@
>   	{ "coretemp", print_coretemp },
>   	{ "dme1737", print_dme1737 },
>  	{ "applesmc", print_applesmc },
> +	{ "F75373", print_f75373 },

Should be "f75373", no capital. I'm even surprised it worked with the
capital.

>  	{ NULL, NULL }
>  };
>  

Please update your patch and resend it.

Also, what about the F75375 support? As far as I know the f75375s driver
supports both chips, so it'd be nice to have user-space support for
both. Also, it might be less confusing to use F75375 for all the
libsensors defines, rather than F75373, so that they match the driver
name.

Thanks,
-- 
Jean Delvare

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

  parent reply	other threads:[~2007-06-23 12:29 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-12 17:29 [lm-sensors] Help needed for implementing&testing Fintek F75375 Christian Emmerich
2007-06-14 19:39 ` Jean Delvare
2007-06-15  6:53 ` Christian Emmerich
2007-06-17 14:14 ` Christian Emmerich
2007-06-18  8:18 ` Jean Delvare
2007-06-18 13:01 ` Christian Emmerich
2007-06-18 16:58 ` Christian Emmerich
2007-06-23 12:29 ` Jean Delvare [this message]
2007-06-25  5:19 ` Christian Emmerich
2007-06-26 18:19 ` Jean Delvare
2007-06-27 13:23 ` Riku Voipio
2007-06-27 19:41 ` Voipio Riku
2007-06-28  7:32 ` Christian Emmerich
2007-06-29  6:04 ` Jean Delvare
2007-07-10 19:44 ` Christian Emmerich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070623142936.580e8ce8@hyperion.delvare \
    --to=khali@linux-fr.org \
    --cc=lm-sensors@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.