ADM1030 Driver (+auto fan speed interface proposal)
Quoted 2 lines
So, if I get you, if it is easier to read to define more than one set macro or function, I can do it ?
I guess that this is mostly a matter of personal taste. Not everybody would agree with me for sure. You are coding the driver, I am not, so as long as what you do works and doesn't have visible drawbacks, I have no objection.
That said, see my proposal for a common fan auto speed interface and you'll understand that more "set" functions will need specific code anyway.
Quoted 2 lines
Yes, it is the TACH register. I have to implement the access to that register.
OK, so it was really missing.
Quoted 1 line
Quoted 1 line
More on automatic PWM after lunch ;)
Here we are. I just took a look at the IT8712 datasheet and their SmartGuardian feature is in fact very similar to the ADM1030's automatic fan speed mode (more similar than I expected actually).
The IT8712 defines the following values:
1* a temperature over which the fan starts spinning;
2* a temperature over which the fan goes full speed;
3* a temperature below which the fan stops completely (so this is an hysteresis value for 1*);
4* a PWM value for 1*;
5* a slope (in PWM/degree) to define the PWM value between 1* and 2*.
Let's compare with the ADM030 which has:
1* a temperature over which the fan starts spinning;
2* a range of temperature after Tmin for which the fan has variable PWM (this is another way to define Tmax);
4* a PWM value for 1*;
The hysteresis value (3*) is hardcoded to Tmin - 5 degrees.
The slope is automatically defined so that PWM = 100% at Tmax.
So all in all I think that we could define the following sysfs files to represent them both:
fan1_auto_temp_offfan1_auto_temp_minfan1_auto_temp_maxfan1_auto_pwm_minfan1_auto_pwm_max
(Or we can swap the last two members, I don't know what is best.)
Depending on the chip, not all values would be RW, and in some cases you
would have to compute and possibly round values to be written to the registers. As an example of this, for the ADM1030, writing to fan1_auto_temp_max would actually write to the SLOPE register.
Still for the ADM1030, fan1_auto_temp_off would be read-only and report 5 degrees less than fan1_auto_temp_min. fan1_auto_pwm_max would be read-only and report 255.
I hope you get my point now. I inisist on the fact that having a common interface for all chips would be really great, the same way we did for the temperatures, fans and voltage readings and limits. If we simply exports the registers values, then all the "smartness" will belong to the userspace and writing specific drivers is pointless. If on the other hand drivers are made in such a way that they offer a common interface to the user-space applications, regardless to the physical implementation of the concepts, then the user-space apps (and mainly libsensors) can be reduced to their simplest expression and freed of any chip-specific code. This is what I do aim at.
Alexandre, please tell me if my knowledge of the ADM1030 is correct and confirm that the proposed interface would be possible to implement for this chip.
I yet have to check how Winbond's auto fan speed regulation works. I think that some chips (including other IT87 chips) have more "trip points" (I think that's how they call it) so we may have to add more files later, which would only be implemented by chips which need it:
fan1_auto_temp_lowfan1_auto_temp_mediumfan1_auto_pwm_lowfan1_auto_pwm_medium
Or we can even ignore these extra features and automatically set them according to min and max values (linearly). I'm not really sure that non-linear control adds much value and is worth the complexity.
OK, this is just a draft at the moment, comments and objections are welcome. I'm simply using this new driver as an experiment subject so as to settle good guidelines for the other drivers to follow later.
Signature · 2 lines
Jean Delvare http://www.ensicaen.ismra.fr/~delvare/
Quoting Jean Delvare <[email protected]>:
Quoted 31 lines
Quoted 2 lines
So, if I get you, if it is easier to read to define more than one set macro or function, I can do it ?
I guess that this is mostly a matter of personal taste. Not everybody would agree with me for sure. You are coding the driver, I am not, so as long as what you do works and doesn't have visible drawbacks, I have no objection.
That said, see my proposal for a common fan auto speed interface and you'll understand that more "set" functions will need specific code anyway.
Quoted 2 lines
Yes, it is the TACH register. I have to implement the access to that register.
OK, so it was really missing.
Quoted 1 line
Quoted 1 line
More on automatic PWM after lunch ;)
Here we are. I just took a look at the IT8712 datasheet and their SmartGuardian feature is in fact very similar to the ADM1030's automatic fan speed mode (more similar than I expected actually).
The IT8712 defines the following values:
1* a temperature over which the fan starts spinning;
2* a temperature over which the fan goes full speed;
3* a temperature below which the fan stops completely (so this is an hysteresis value for 1*);
4* a PWM value for 1*;
5* a slope (in PWM/degree) to define the PWM value between 1* and 2*.
Quoted 5 lines
Let's compare with the ADM030 which has:
1* a temperature over which the fan starts spinning;
2* a range of temperature after Tmin for which the fan has variable PWM (this is another way to define Tmax);
4* a PWM value for 1*;
Actually, the (4*) item, when in automatic mode, define the minimum speed at which the fan will rotate. Even if Temp < (1*)
Quoted 37 lines
The hysteresis value (3*) is hardcoded to Tmin - 5 degrees.
The slope is automatically defined so that PWM = 100% at Tmax.
So all in all I think that we could define the following sysfs files to represent them both:
fan1_auto_temp_offfan1_auto_temp_minfan1_auto_temp_maxfan1_auto_pwm_minfan1_auto_pwm_max(Or we can swap the last two members, I don't know what is best.)
Depending on the chip, not all values would be RW, and in some cases you
would have to compute and possibly round values to be written to the registers. As an example of this, for the ADM1030, writing tofan1_auto_temp_maxwould actually write to the SLOPE register.Still for the ADM1030,
fan1_auto_temp_offwould be read-only and report 5 degrees less thanfan1_auto_temp_min.fan1_auto_pwm_maxwould be read-only and report 255.I hope you get my point now. I inisist on the fact that having a common interface for all chips would be really great, the same way we did for the temperatures, fans and voltage readings and limits. If we simply exports the registers values, then all the "smartness" will belong to the userspace and writing specific drivers is pointless. If on the other hand drivers are made in such a way that they offer a common interface to the user-space applications, regardless to the physical implementation of the concepts, then the user-space apps (and mainly libsensors) can be reduced to their simplest expression and freed of any chip-specific code. This is what I do aim at.
Quoted 3 lines
Alexandre, please tell me if my knowledge of the ADM1030 is correct and confirm that the proposed interface would be possible to implement for this chip.
I do not see anything to add. The way you describe to handle that feature seems to be applicable to tha adm1030.
I would just add a file to activate the automatic mode. (It is not activated by default.) and to select on which temp channel the automatic mode reacts. (temp1, temp2, temp3 or max value of the three.)
I will implement the set of files that you described.
Quoted 11 lines
I yet have to check how Winbond's auto fan speed regulation works. I think that some chips (including other IT87 chips) have more "trip points" (I think that's how they call it) so we may have to add more files later, which would only be implemented by chips which need it:
fan1_auto_temp_lowfan1_auto_temp_mediumfan1_auto_pwm_lowfan1_auto_pwm_medium
Quoted 7 lines
Or we can even ignore these extra features and automatically set them according to min and max values (linearly). I'm not really sure that non-linear control adds much value and is worth the complexity.
OK, this is just a draft at the moment, comments and objections are welcome. I'm simply using this new driver as an experiment subject so as to settle good guidelines for the other drivers to follow later.
I think it is a good idea.
Quoted 7 lines
Signature · 3 lines
-- Jean Delvare http://www.ensicaen.ismra.fr/~delvare/
Signature · 3 lines
-------------------------------------------------
Alexandre d'ALTON
[email protected]Quoted 8 lines
Quoted 5 lines
Let's compare with the ADM030 which has:
1* a temperature over which the fan starts spinning;
2* a range of temperature after Tmin for which the fan has variable PWM (this is another way to define Tmax);
4* a PWM value for 1*;Actually, the (4*) item, when in automatic mode, define the minimum speed at which the fan will rotate. Even if Temp < (1*)
This doesn't match the graph page 12 of the ADM1030-A datasheet. If I read it correctly, PWM (4*) applies if (1*) - 5 < T < (1*).
Quoted 2 lines
I would just add a file to activate the automatic mode. (It is not activated by default.)
fan1_auto_enable?
Quoted 2 lines
and to select on which temp channel the automatic mode reacts. (temp1, temp2, temp3 or max value of the three.)
I don't know if IT87 or Winbond chips can select that. I guess that "fan1_auto_temp_channel" would be a correct name?
Note that I don't have strong opinions on the names except that they must be standardized and self-expressive. The more important (and difficult) problem is to ensure that all known chips (and it possible future ones) will fit into the chose interface.
Signature · 2 lines
Jean Delvare http://www.ensicaen.ismra.fr/~delvare/
Quoting Jean Delvare <[email protected]>:
Quoted 11 lines
Quoted 8 lines
Quoted 5 lines
Let's compare with the ADM030 which has:
1* a temperature over which the fan starts spinning;
2* a range of temperature after Tmin for which the fan has variable PWM (this is another way to define Tmax);
4* a PWM value for 1*;Actually, the (4*) item, when in automatic mode, define the minimum speed at which the fan will rotate. Even if Temp < (1*)
This doesn't match the graph page 12 of the ADM1030-A datasheet. If I read it correctly, PWM (4*) applies if (1*) - 5 < T < (1*).
OK, just read back, it's clear. Sorry.
Quoted 22 lines
Quoted 3 lines
I would just add a file to activate the automatic mode. (It is not activated by default.)
fan1_auto_enable?Quoted 2 lines
and to select on which temp channel the automatic mode reacts. (temp1, temp2, temp3 or max value of the three.)
I don't know if IT87 or Winbond chips can select that. I guess that "
fan1_auto_temp_channel" would be a correct name?Note that I don't have strong opinions on the names except that they must be standardized and self-expressive. The more important (and difficult) problem is to ensure that all known chips (and it possible future ones) will fit into the chose interface.
Signature · 2 lines
Jean Delvare http://www.ensicaen.ismra.fr/~delvare/
Signature · 3 lines
-------------------------------------------------
Alexandre d'ALTON
[email protected]Quoting Philip Pokorny <[email protected]>:
Quoted 62 lines
Quoted 15 lines · Alexandre d'Alton
Quoting Jean Delvare <[email protected]>:
Quoted 11 lines
Quoted 11 lines
Quoted 7 lines
Let's compare with the ADM030 which has:
1* a temperature over which the fan starts spinning;
2* a range of temperature after Tmin for which the fan has variable PWM (this is another way to define Tmax);
4* a PWM value for 1*;Actually, the (4*) item, when in automatic mode, define the minimum speed at which the fan will rotate. Even if Temp < (1*)
Quoted 32 lines
Quoted 4 lines
This doesn't match the graph page 12 of the ADM1030-A datasheet. If I read it correctly, PWM (4*) applies if (1*) - 5 < T < (1*).
OK, just read back, it's clear. Sorry.
Quoted 23 lines
Quoted 4 lines
I would just add a file to activate the automatic mode. (It is not activated by default.)
fan1_auto_enable?Quoted 4 lines
and to select on which temp channel the automatic mode reacts. (temp1, temp2, temp3 or max value of the three.)
I don't know if IT87 or Winbond chips can select that. I guess that "
fan1_auto_temp_channel" would be a correct name?Note that I don't have strong opinions on the names except that they must be standardized and self-expressive. The more important (and difficult) problem is to ensure that all known chips (and it possible future ones) will fit into the chose interface.
In the LM85/ADM1027 driver it's called
pwm1_zone.It has the values:
-1: PWM disabled, fan at 100% -2: PWM under manual control ('pwm1' or 'pwm1_value' is writable) 1: PWM is controlled by temp1_input 2: PWM is controlled by temp2_input 123: PWM is controlled by max value of all three 0: PWM disabled, fan at 0%The other parameters have equivalents in the lm85 driver as well.
Quoted 7 lines
zone#_limit (fan "turn on" temperature (1*))
zone#_hyst (range below limit fan remains on. Fixed at 5 deg in
this chip?)
zone#_range (temperature range (2*))
pwm#_min (PWM value at low limit. (4*)):v)
Seems to be a good approach, and it has the advantage of already beeing implemented on some drivers.
Jean, what do you think about that ?
Signature · 3 lines
-------------------------------------------------
Alexandre d'ALTON
[email protected]Quoted 16 lines
Quoted 11 lines
In the LM85/ADM1027 driver it's called
pwm1_zone.It has the values:
-1: PWM disabled, fan at 100%
-2: PWM under manual control ('pwm1' or 'pwm1_value' is
writable)
1: PWM is controlled bytemp1_input
2: PWM is controlled bytemp2_input
123: PWM is controlled by max value of all three
0: PWM disabled, fan at 0%Quoted 4 lines
The other parameters have equivalents in the lm85 driver as well.
zone#_limit (fan "turn on" temperature (1*))
zone#_hyst (range below limit fan remains on. Fixed at 5 degin
Quoted 8 lines
Quoted 5 lines
this chip?)
zone#_range (temperature range (2*))
pwm#_min (PWM value at low limit. (4*)):v)
Seems to be a good approach, and it has the advantage of already beeing implemented on some drivers.
I think that the lm85 driver is actually the only one to do that. Since it isn't standardized yet, I have to say I do not consider much benefit in following what was done. Not that I denigrate Philip's work, nor does it mean that I dislike his approach. All I mean is that if it happens that this doesn't cover the other chips correctly, or doesn't fit in the "file names are self-descriptive" rule, we better change what exists in the name of uniformity.
Quoted 1 line
Jean, what do you think about that ?
First of all I have to say that I completely ignored that one driver already has auto fan speed support. Thanks Philip for joining the conversation and providing some insight about how you did implement it on your side.
Here are the drawbacks I see at first sight:
1* pwm1_zone = -1 is what other drivers implement with pwm1_enable =
0. I would like to avoid having two ways to express the same thing if possible. OTOH, one will wonder what happens if a user sets pwm1_enable = 0 and pwm1_auto at the same time. I don't really know and think that it'll probably depend on chip's implementation (depends if there are two separate bits in the chip, or one three-state value).
Likewise, pwm1_zone = 0 is (more or less) pwm_enable = 1 && pwm1 = 0,
and pwm1_zone = -1 is pwm_enable = 1.
I think we better stick to the one file - one value (i.e. one meaning) philosophy. Philip, I guess that the idea of setting these different things in a single value were inspired by the way the LM85 implements it?
2* About the range: the same way we decided that hysteresis values should be expressed as absolute temperatures and not a difference relative to another limits, I think we should express the max temp (for auto fan control) as an absolute value and not a range from the min temp. The fact that some (most?) chips use a range is obviously made so as to spare a few bits in the registers. The userspace doesn't care about these implementation details.
3* I was thinking that what is named pwm1_zone in lm85 could be a bitfield. Each bit links the corresponding temperature channel to this PWM. That way we are sure we can extend the values in a consistent way if a later chip has more than 3 temperature channels, and if it allows to link more than one, but less than all, channels to a given PWM.
Anyway, this proves that we *really* need to discuss a bit more about a common interface to this functionality. I will try to read as much as possible about the various implementations (IT87, LM85, ADM1030 and W836x7) before the end of the week so as to make sure that I understand how things do work. I invite each of you to do the same so that our discussion is as constructive as possible.
Thanks a lot.
Signature · 2 lines
Jean Delvare http://www.ensicaen.ismra.fr/~delvare/
Quoted 15 lines · Alexandre d'Alton
Quoting Jean Delvare <[email protected]>:
Quoted 11 lines
Quoted 11 lines
Quoted 7 lines
Let's compare with the ADM030 which has:
1* a temperature over which the fan starts spinning;
2* a range of temperature after Tmin for which the fan has variable PWM (this is another way to define Tmax);
4* a PWM value for 1*;Actually, the (4*) item, when in automatic mode, define the minimum speed at which the fan will rotate. Even if Temp < (1*)
Quoted 32 lines
Quoted 4 lines
This doesn't match the graph page 12 of the ADM1030-A datasheet. If I read it correctly, PWM (4*) applies if (1*) - 5 < T < (1*).
OK, just read back, it's clear. Sorry.
Quoted 23 lines
Quoted 4 lines
I would just add a file to activate the automatic mode. (It is not activated by default.)
fan1_auto_enable?Quoted 4 lines
and to select on which temp channel the automatic mode reacts. (temp1, temp2, temp3 or max value of the three.)
I don't know if IT87 or Winbond chips can select that. I guess that "
fan1_auto_temp_channel" would be a correct name?Note that I don't have strong opinions on the names except that they must be standardized and self-expressive. The more important (and difficult) problem is to ensure that all known chips (and it possible future ones) will fit into the chose interface.
In the LM85/ADM1027 driver it's called pwm1_zone.
It has the values:
-1: PWM disabled, fan at 100%
-2: PWM under manual control ('pwm1' or 'pwm1_value' is writable)
1: PWM is controlled by temp1_input
2: PWM is controlled by temp2_input
123: PWM is controlled by max value of all three
0: PWM disabled, fan at 0%The other parameters have equivalents in the lm85 driver as well.
zone#_limit (fan "turn on" temperature (1*))
zone#_hyst (range below limit fan remains on. Fixed at 5 deg in
this chip?)
zone#_range (temperature range (2*))
pwm#_min (PWM value at low limit. (4*))
:v)
Quoting Jean Delvare <[email protected]>:
Quoted 72 lines
Quoted 16 lines
Quoted 11 lines
In the LM85/ADM1027 driver it's called
pwm1_zone.It has the values:
-1: PWM disabled, fan at 100%
-2: PWM under manual control ('pwm1' or 'pwm1_value' is
writable)
1: PWM is controlled bytemp1_input
2: PWM is controlled bytemp2_input
123: PWM is controlled by max value of all three
0: PWM disabled, fan at 0%Quoted 4 lines
The other parameters have equivalents in the lm85 driver as well.
zone#_limit (fan "turn on" temperature (1*))
zone#_hyst (range below limit fan remains on. Fixed at 5 degin
Quoted 8 lines
Quoted 5 lines
this chip?)
zone#_range (temperature range (2*))
pwm#_min (PWM value at low limit. (4*)):v)
Seems to be a good approach, and it has the advantage of already beeing implemented on some drivers.
I think that the lm85 driver is actually the only one to do that. Since it isn't standardized yet, I have to say I do not consider much benefit in following what was done. Not that I denigrate Philip's work, nor does it mean that I dislike his approach. All I mean is that if it happens that this doesn't cover the other chips correctly, or doesn't fit in the "file names are self-descriptive" rule, we better change what exists in the name of uniformity.
Quoted 1 line
Jean, what do you think about that ?
First of all I have to say that I completely ignored that one driver already has auto fan speed support. Thanks Philip for joining the conversation and providing some insight about how you did implement it on your side.
Here are the drawbacks I see at first sight:
1*
pwm1_zone= -1 is what other drivers implement withpwm1_enable=
0. I would like to avoid having two ways to express the same thing if possible. OTOH, one will wonder what happens if a user setspwm1_enable= 0 andpwm1_autoat the same time. I don't really know and think that it'll probably depend on chip's implementation (depends if there are two separate bits in the chip, or one three-state value).Likewise,
pwm1_zone= 0 is (more or less)pwm_enable= 1 && pwm1 = 0,
andpwm1_zone= -1 ispwm_enable= 1.I think we better stick to the one file - one value (i.e. one meaning) philosophy. Philip, I guess that the idea of setting these different things in a single value were inspired by the way the LM85 implements it?
2* About the range: the same way we decided that hysteresis values should be expressed as absolute temperatures and not a difference relative to another limits, I think we should express the max temp (for auto fan control) as an absolute value and not a range from the min temp. The fact that some (most?) chips use a range is obviously made so as to spare a few bits in the registers. The userspace doesn't care about these implementation details.
3* I was thinking that what is named
pwm1_zonein lm85 could be a bitfield. Each bit links the corresponding temperature channel to this PWM. That way we are sure we can extend the values in a consistent way if a later chip has more than 3 temperature channels, and if it allows to link more than one, but less than all, channels to a given PWM.
Quoted 6 lines
Anyway, this proves that we *really* need to discuss a bit more about a common interface to this functionality. I will try to read as much as possible about the various implementations (IT87, LM85, ADM1030 and W836x7) before the end of the week so as to make sure that I understand how things do work. I invite each of you to do the same so that our discussion is as constructive as possible.
I'll do the same.
Quoted 8 lines
Thanks a lot.
Signature · 2 lines
Jean Delvare http://www.ensicaen.ismra.fr/~delvare/
Signature · 3 lines
-------------------------------------------------
Alexandre d'ALTON
[email protected]