Skip to contentSkip to conversation

ADM1031 / ADM1030 Driver

DISCUSSION Alexandre d'Alton 2 participants 6 messages May 19, 2005

lore
Share & tools
lore
#0 lore raw

Here is a patch that adds support for adm1030 / adm1031 chip on the linux-2.6.6-rc3 kernel.

Tested with adm1030 chip.

If the code is ok, I'll add documentation (how to use and inline comments) in order to submit the final version.

Jean: Concerning via686a chip driver, temps seems to be OK on my computer.

Alex.

Patch attached because my client wraps lines.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch-adm1031-2.6.6-rc3.diff
Type: text/x-patch
Size: 34129 bytes
Desc: not available
Url : http://lists.lm-sensors.org/pipermail/lm-sensors/attachments/20040428/324f3f3a/patch-adm1031-2.6.6-rc3.bin

#1 lore raw

Quoting Jean Delvare <[email protected]>:

Quoted 7 lines

Hi Alex,

Quoted 4 lines

ADM1031 driver with activation of monitoring by default.

removed tempX_enable files as they are for interrupt, not measurements.

Quoted 8 lines

I'm testing at the moment.

The fans are now starting as I load the driver (well, a few seconds after), and temperature monitoring works :)

Bugs found:

1* I cannot set temperature critical limits.

Found the bug. Fixed.

Quoted 3 lines

2* Whatever I set the PWM values to, the fans turn, probably to full speed.

It would help if you could send me the i2cdump for 2 or 3 values of PWM.

Quoted 4 lines

3* Fan speed values don't seem to be correct. They read 1323 (which seems to be the minimal value with divisor = 2) and 0, respectively, and never change. Since both fans are running at fast speed, it can't be.

Found why fan2 was reading 0 (input not activated.)

There are also 2 fan sensors alternatives (Digital or Analog), in the eval board there are 2 switches (S1 and S2) that have to be set to TACH1 and TACH2 as the default value for measurements is digital.

So will it be necessary to enable the user controlling the input type, by adding a fan_input_type file to control analog / digital input.

Quoted 2 lines

Also, your driver doesn't export alarms?

Not yet, In order to add that, I'd like to know how it has to work.

In the ADM1031, the alarm status register is cleared when read, so reading the alarm registers will clear the alarms. I wonder how to proceed.

Thanks for your feedbacks,

Signature · 3 lines
-------------------------------------------------
Alexandre d'ALTON
                              [email protected]
#2 lore raw
In reply to Alexandre d'Alton

Again a new version of adm1031 driver attached.

That version adds:

- add alarms file
- corrected bug on reading fan2 pwm
- setting either fan1_auto_channel or fan2_auto_channel to zero will
disable auto fan control
- disable sampling on update in order to have consistant values for
temp readings and their extended resolution bits.

Thanks,

Signature · 8 lines
Alexandre d'Alton <[email protected]>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: adm1031-linux-2.6.6-rc3.diff
Type: text/x-patch
Size: 34873 bytes
Desc: not available
Url : http://lists.lm-sensors.org/pipermail/lm-sensors/attachments/20040506/c6a8ec25/adm1031-linux-2.6.6-rc3.bin
#3 lore raw
In reply to Alexandre d'Alton

Hi Alex,

Quoted 4 lines

ADM1031 driver with activation of monitoring by default.

removed tempX_enable files as they are for interrupt, not measurements.

I'm testing at the moment.

The fans are now starting as I load the driver (well, a few seconds after), and temperature monitoring works :)

Bugs found:

1* I cannot set temperature critical limits.

2* Whatever I set the PWM values to, the fans turn, probably to full speed.

3* Fan speed values don't seem to be correct. They read 1323 (which seems to be the minimal value with divisor = 2) and 0, respectively, and never change. Since both fans are running at fast speed, it can't be.

Also, your driver doesn't export alarms?

Thanks.

Signature · 2 lines
Jean Delvare
http://khali.linux-fr.org/
#4 lore raw
In reply to Alexandre d'Alton
Quoted 5 lines
Quoted 2 lines

2* Whatever I set the PWM values to, the fans turn, probably to full speed.

It would help if you could send me the i2cdump for 2 or 3 values of PWM.

First dump, right after loading the driver (fan1_pwm and fan2_pwm read 80 and 0, respectively):

00: 91 7f 00 00 5d 5d e0 00 ff ff 19 1c 19 00 00 00    ??..]]?...???...
10: ff ff 5d 5d 3c 00 46 5d 50 00 64 5d 50 00 64 5d    ..]]<.F]P.d]P.d]
20: 5d 5d 55 50 41 61 61 5d 5d 5d 5d 5d 5d 5d 5d 5d    ]]UPAaa]]]]]]]]]
30: 5d 5d 5d 5d 5d 5d 5d 5d 5d 5d 5d 5d 5d 31 41 83    ]]]]]]]]]]]]]1A?

Second dump, after writting 42 to fan1_pwm and 240 to fan2_pwm (fan1_pwm and fan2_pwm now read 32 and 0, respectively):

00: 91 7f 00 00 5d 5d 4b 00 ff ff 1b 1d 1a 00 00 00    ??..]]K...???...
10: ff ff 5d 5d 3c 00 46 5d 50 00 64 5d 50 00 64 5d    ..]]<.F]P.d]P.d]
20: 5d 5d f2 50 41 61 61 5d 5d 5d 5d 5d 5d 5d 5d 5d    ]]?PAaa]]]]]]]]]
30: 5d 5d 5d 5d 5d 5d 5d 5d 5d 5d 5d 5d 5d 31 41 83    ]]]]]]]]]]]]]1A?

Third dump, after writing 180 to fan1_pwm and 12 to fan2_pwm (fan1_pwm and fan2_pwm now read 176 and 0, respectively):

00: 91 7f 00 00 5d 5d 9d 00 ff ff 1b 1d 1a 00 00 00    ??..]]?...???...
10: ff ff 5d 5d 3c 00 46 5d 50 00 64 5d 50 00 64 5d    ..]]<.F]P.d]P.d]
20: 5d 5d 0b 50 41 61 61 5d 5d 5d 5d 5d 5d 5d 5d 5d    ]]?PAaa]]]]]]]]]
30: 5d 5d 5d 5d 5d 5d 5d 5d 5d 5d 5d 5d 5d 31 41 83    ]]]]]]]]]]]]]1A?

Quick diffs reveal (unless I missed something) that only register 0x22 has changed (temperature measurement registers left appart).

0x55 means PWM1€, PWM2€ (matches the datasheet default) 0xf2 means PWM12, PWM2$0
0x0b means PWM16, PWM2=0

Basically, this means that reading is correct for PWM1 but not for PWM2, and writing is correct for both. The reason why I don't see fan change speeds is most probably because they are both in automatic mode.

(Hint for PWM2: I think you just need to add parenthesis in adm1031_update_device at the moment you retrieve the value; the masking and shifting are probably done in the wrong order; I'm surprised that gcc didn't warn us.)

(BTW: ADM1031_REG_PWM should be a simple define, not a macro.)

BTW, I don't seem to be able to switch to manual mode. Echoing 0 to either of fan1_auto_channel or fan2_auto_channel doesnt change the value returned by these files.

Quoted 10 lines
Quoted 4 lines

3* Fan speed values don't seem to be correct. They read 1323 (which seems to be the minimal value with divisor = 2) and 0, respectively, and never change. Since both fans are running at fast speed, it can't be.

Found why fan2 was reading 0 (input not activated.)

There are also 2 fan sensors alternatives (Digital or Analog), in the eval board there are 2 switches (S1 and S2) that have to be set to TACH1 and TACH2 as the default value for measurements is digital.

This is what they are set to on my board.

Quoted 2 lines

So will it be necessary to enable the user controlling the input type, by adding a fan_input_type file to control analog / digital input.

There is no provision for that in the sysfs interface for now. I wonder if anyone will use the analog method. I don't know how reliable it is. I think I would stick to digital mode for now, and see if someone complains. But if you want to implement it, just go.

Quoted 7 lines
Quoted 1 line

Also, your driver doesn't export alarms?

Not yet, In order to add that, I'd like to know how it has to work.

In the ADM1031, the alarm status register is cleared when read, so reading the alarm registers will clear the alarms. I wonder how to proceed.

Just export both status registers as a single bitfield and we'll see how it goes.

Quoted 1 line

Thanks for your feedbacks,

You're welcome.

Signature · 2 lines
Jean Delvare
http://khali.linux-fr.org/
#5 lore raw
In reply to Alexandre d'Alton
Quoted 10 lines

Again a new version of adm1031 driver attached.

That version adds:

- add alarms file
- corrected bug on reading fan2 pwm
- setting either fan1_auto_channel or fan2_auto_channel to zero will disable auto fan control
- disable sampling on update in order to have consistant values for temp readings and their extended resolution bits.

Your set_fan_div function seems broken to me. Near the end you compute a value in "reg" but never use it.

You have duplicate defines for configuration register bits. BTW, you seem to use numerical values instead of these constants in several places.

In update_device, you read configuration register 1 twice.

I don't seem to be able to write non-zero values to fanN_auto_channel.

Fan readings are broken. Fan 1 reads 0, fan 2 reads 1323 and doesn't change. If I change fan2_div, fan2_input changes. It shouldn't.

Changing PWM values didn't have any effect, even in manual mode.

At some point the driver disabled my chip. I couldn't reproduce it yet.

Long way to go... ;)

Signature · 2 lines
Jean Delvare
http://khali.linux-fr.org/