| 4285 | | for ($i = 0x2a; $i <= 0x3d; $i++) { |
| 4286 | | $reg = i2c_smbus_read_byte_data($file, $i); |
| 4287 | | return if i2c_smbus_read_byte_data($file, $i+0x40) != $reg; |
| 4288 | | return if i2c_smbus_read_byte_data($file, $i+0x80) != $reg; |
| 4289 | | return if i2c_smbus_read_byte_data($file, $i+0xc0) != $reg; |
| 4290 | | } |
| 4291 | | |
| 4292 | | # Refine a bit by checking whether limits are in the correct order |
| 4293 | | # (min<max for voltages, hyst<max for temperature). Since it is still |
| 4294 | | # possible that the chip is an LM80 with limits not properly set, |
| 4295 | | # a few "errors" are tolerated. |
| 4296 | | my $confidence = 0; |
| 4297 | | for ($i = 0x2a; $i <= 0x3a; $i++) { |
| | 4294 | if ($chip == 0) { |
| | 4295 | for ($i = 0x2a; $i <= 0x3d; $i++) { |
| | 4296 | $reg = i2c_smbus_read_byte_data($file, $i); |
| | 4297 | return if i2c_smbus_read_byte_data($file, $i+0x40) != $reg; |
| | 4298 | return if i2c_smbus_read_byte_data($file, $i+0x80) != $reg; |
| | 4299 | return if i2c_smbus_read_byte_data($file, $i+0xc0) != $reg; |
| | 4300 | } |
| | 4301 | |
| | 4302 | # Refine a bit by checking whether limits are in the correct order |
| | 4303 | # (min<max for voltages, hyst<max for temperature). Since it is still |
| | 4304 | # possible that the chip is an LM80 with limits not properly set, |
| | 4305 | # a few "errors" are tolerated. |
| | 4306 | my $confidence = 0; |
| | 4307 | for ($i = 0x2a; $i <= 0x3a; $i++) { |
| | 4308 | $confidence++ |
| | 4309 | if i2c_smbus_read_byte_data($file, $i) < i2c_smbus_read_byte_data($file, $i+1); |
| | 4310 | } |
| | 4311 | # hot temp<OS temp |
| 4299 | | if i2c_smbus_read_byte_data($file, $i) < i2c_smbus_read_byte_data($file, $i+1); |
| 4300 | | } |
| 4301 | | # hot temp<OS temp |
| 4302 | | $confidence++ |
| 4303 | | if i2c_smbus_read_byte_data($file, 0x38) < i2c_smbus_read_byte_data($file, 0x3a); |
| 4304 | | |
| 4305 | | # Negative temperature limits are unlikely. |
| 4306 | | for ($i = 0x3a; $i <= 0x3d; $i++) { |
| 4307 | | $confidence++ if (i2c_smbus_read_byte_data($file, $i) & 0x80) == 0; |
| 4308 | | } |
| 4309 | | |
| 4310 | | # $confidence is between 0 and 14 |
| 4311 | | $confidence = ($confidence >> 1) - 4; |
| 4312 | | # $confidence is now between -4 and 3 |
| 4313 | | |
| 4314 | | return unless $confidence > 0; |
| 4315 | | |
| 4316 | | return $confidence; |
| | 4313 | if i2c_smbus_read_byte_data($file, 0x38) < i2c_smbus_read_byte_data($file, 0x3a); |
| | 4314 | |
| | 4315 | # Negative temperature limits are unlikely. |
| | 4316 | for ($i = 0x3a; $i <= 0x3d; $i++) { |
| | 4317 | $confidence++ if (i2c_smbus_read_byte_data($file, $i) & 0x80) == 0; |
| | 4318 | } |
| | 4319 | |
| | 4320 | # $confidence is between 0 and 14 |
| | 4321 | $confidence = ($confidence >> 1) - 4; |
| | 4322 | # $confidence is now between -4 and 3 |
| | 4323 | |
| | 4324 | return unless $confidence > 0; |
| | 4325 | return $confidence; |
| | 4326 | } elsif ($chip == 1) { |
| | 4327 | return if (i2c_smbus_read_byte_data($file, 0x07) & 0xfe) != 0; |
| | 4328 | return if i2c_smbus_read_byte_data($file, 0x3e) != 0x01; |
| | 4329 | return if i2c_smbus_read_byte_data($file, 0x3f) != 0x08; |
| | 4330 | |
| | 4331 | return 6; |
| | 4332 | } |