Add detection of SMSC EMC2103 to
Hi Steve,
Quoted 13 lines · Steve Glendinning
This patch allows the sensors-detect script to detect the SMSC EMC2103 family of temperature sensors and fan controllers.
Signed-off-by Steve Glendinning <[email protected]>--- prog/detect/sensors-detect | 20 ++++++++++++++++++++ 1 files changed, 20 insertions(+), 0 deletions(-)prog/detect/sensors-detect +0
-0
prog/detect/sensors-detect use vars qw(@i2c_adapter_names); · line 1134
Quoted 5 lines
prog/detect/sensors-detect +2
-0@@ -1130,6 +1130,11 @@ use vars qw(@i2c_adapter_names); i2c_addrs => [0x2c..0x2e], i2c_detect => sub { dme1737_detect(@_, 2); }, }, { + name => "SMSC EMC2103", + driver => "smscemc",
I don't much like this driver name. This driver won't support all the SMSC EMC series, so it's confusing. If nothing else, the EMC1403, EMC6D100, EMC6D101, EMC6D102 and EMC6D103 are already supported by two other drivers (emc1403 and lm85). And there are many other SMSC EMC chips, and I doubt they will all be compatible with the EMC2103, right? So I would much prefer that you name your driver "emc2103".
Quoted 7 lines
prog/detect/sensors-detect +3
-0+ i2c_addrs => [0x2e], + i2c_detect => sub { smsc_emc2103_detect(@_); }, + }, { name => "Fintek F75121R/F75122R/RG (VID+GPIO)", driver => "to-be-written", i2c_addrs => [0x4e], # 0x37 not probed
prog/detect/sensors-detect sub smsc47m192_detect · line 5090
Quoted 7 lines
prog/detect/sensors-detect +4
-0@@ -5079,6 +5084,21 @@ sub smsc47m192_detect return ($addr = 0x2d ? 6 : 5); } +# Registers used: +# 0xFD: Product ID +# 0xFE: Manufacturer ID +# 0xFF: Revision
Your detection routine below doesn't actually use register 0xff. It should if possible: this would make the detection more robust.
prog/detect/sensors-detect sub smsc47m192_detect · line 5099
Quoted 9 lines
prog/detect/sensors-detect +9
-0+sub smsc_emc2103_detect +{ + my ($file, $addr) = @_; + return unless i2c_smbus_read_byte_data($file, 0xFE) = 0x5D; + + my $product = i2c_smbus_read_byte_data($file, 0xFD); + return unless (($product = 0x24) || ($product = 0x26)); + + return 8;
You can't grant such a high confidence value after checking only 15
bits: it would rather be confidence 5 or 6.
Also, the detection registers seem similar to the EMC1403's, so it might make sense to reuse function emc1403_detect for the EMC2103, instead of writing a new one.
Quoted 5 lines
prog/detect/sensors-detect +2
-0+} + # Chip to detect: 1 = DME1737, 2 = SCH5027 # Registers used: # 0x3E: Manufacturer ID
Signature · 7 lines
Jean Delvare http://khali.linux-fr.org/wishlist.html _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Hi Jean,
Quoted 9 lines
Quoted 9 lines
prog/detect/sensors-detect +1
-0@@ -1130,6 +1130,11 @@ use vars qw(@i2c_adapter_names); i2c_addrs => [0x2c..0x2e], i2c_detect => sub { dme1737_detect(@_, 2); }, }, { + name => "SMSC EMC2103",
Quoted 8 lines
prog/detect/sensors-detect use vars qw(@i2c_adapter_names); · line 1134
Quoted 1 line
prog/detect/sensors-detect +1
-0+ driver => "smscemc",I don't much like this driver name. This driver won't support all the SMSC EMC series, so it's confusing. If nothing else, the EMC1403, EMC6D100, EMC6D101, EMC6D102 and EMC6D103 are already supported by two other drivers (emc1403 and lm85). And there are many other SMSC EMC chips, and I doubt they will all be compatible with the EMC2103, right? So I would much prefer that you name your driver "emc2103".
Right now this driver only supports the EMC2103 family, but it is intended to support a whole family of parts in future - hence the quite generic name.
I've submitted a new version of the driver for review with the name emc2103,
but I'm unsure of the impact of this. If we want to add support for more devices after this is merged can we rename it?
Quoted 10 lines
Quoted 10 lines
prog/detect/sensors-detect +3
-0+ i2c_addrs => [0x2e], + i2c_detect => sub { smsc_emc2103_detect(@_); }, + }, { name => "Fintek F75121R/F75122R/RG (VID+GPIO)", driver => "to-be-written", i2c_addrs => [0x4e], # 0x37 not probed@@ -5079,6 +5084,21 @@ sub smsc47m192_detect return ($addr = 0x2d ? 6 : 5); }
Quoted 7 lines
prog/detect/sensors-detect sub smsc47m192_detect · line 5090
Quoted 4 lines
prog/detect/sensors-detect +4
-0+# Registers used: +# 0xFD: Product ID +# 0xFE: Manufacturer ID +# 0xFF: RevisionYour detection routine below doesn't actually use register
0xff. It should if possible: this would make the detection more robust.
What should the detection policy be for this? All the devices I currently have access to have a revision register value of 1, so should the driver only allow this specifically tested revision? I notice that's what the newly added emc1403 driver does. I guess this would mean that we'll have to submit patches to allow support for newer revisions?
Future revisions *should* be 100% register compatible, but obviously we can't actually test this as they don't exist yet!
Quoted 4 lines
Quoted 4 lines
prog/detect/sensors-detect +4
-0+sub smsc_emc2103_detect +{ + my ($file, $addr) = @_; + return unless i2c_smbus_read_byte_data($file, 0xFE) = 0x5D;
Quoted 8 lines
prog/detect/sensors-detect sub smsc47m192_detect · line 5099
Quoted 5 lines
prog/detect/sensors-detect +5
-0+ + my $product = i2c_smbus_read_byte_data($file, 0xFD); + return unless (($product = 0x24) || ($product = 0x26)); + + return 8;You can't grant such a high confidence value after checking only 15
bits: it would rather be confidence 5 or 6.
Ok, I'll update this.
Quoted 3 lines
Also, the detection registers seem similar to the EMC1403's, so it might make sense to reuse function
emc1403_detectfor the EMC2103, instead of writing a new one.
Ahh, I actually wrote the sensors-detect routine before the EMC1403 support was merged. This definitely makes sense, the patch is much smaller now.
Steve
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Hi Steve,
Quoted 20 lines · On Sun, 6 Jun 2010 18:32:21 +0100, [email protected] wrote:
Hi Jean,
Quoted 9 lines
Quoted 9 lines
prog/detect/sensors-detect +1
-0@@ -1130,6 +1130,11 @@ use vars qw(@i2c_adapter_names); i2c_addrs => [0x2c..0x2e], i2c_detect => sub { dme1737_detect(@_, 2); }, }, { + name => "SMSC EMC2103",Quoted 8 lines
prog/detect/sensors-detect use vars qw(@i2c_adapter_names); · line 1134
Quoted 1 line
prog/detect/sensors-detect +1
-0+ driver => "smscemc",I don't much like this driver name. This driver won't support all the SMSC EMC series, so it's confusing. If nothing else, the EMC1403, EMC6D100, EMC6D101, EMC6D102 and EMC6D103 are already supported by two other drivers (emc1403 and lm85). And there are many other SMSC EMC chips, and I doubt they will all be compatible with the EMC2103, right? So I would much prefer that you name your driver "emc2103".
Quoted 7 lines
Right now this driver only supports the EMC2103 family, but it is intended to support a whole family of parts in future - hence the quite generic name.
I've submitted a new version of the driver for review with the name emc2103,
but I'm unsure of the impact of this. If we want to add support for more devices after this is merged can we rename it?
We carefully avoid renaming drivers, as it breaks existing configurations. But there is no reason to rename a driver just because you add support for a new device. Almost all hwmon drivers are named after the first device that was supported, and this is just fine. This simply means that driver blah is for device BLAH and compatibles. It is way less confusing that using generic driver names which cover many more chips than the driver actually supports.
Quoted 18 lines
Quoted 10 lines
Quoted 10 lines
prog/detect/sensors-detect +3
-0+ i2c_addrs => [0x2e], + i2c_detect => sub { smsc_emc2103_detect(@_); }, + }, { name => "Fintek F75121R/F75122R/RG (VID+GPIO)", driver => "to-be-written", i2c_addrs => [0x4e], # 0x37 not probed@@ -5079,6 +5084,21 @@ sub smsc47m192_detect return ($addr = 0x2d ? 6 : 5); }Quoted 7 lines
prog/detect/sensors-detect sub smsc47m192_detect · line 5090
Quoted 4 lines
prog/detect/sensors-detect +4
-0+# Registers used: +# 0xFD: Product ID +# 0xFE: Manufacturer ID +# 0xFF: RevisionYour detection routine below doesn't actually use register
0xff. It should if possible: this would make the detection more robust.
Quoted 6 lines
What should the detection policy be for this? All the devices I currently have access to have a revision register value of 1, so should the driver only allow this specifically tested revision? I notice that's what the newly added emc1403 driver does. I guess this would mean that we'll have to submit patches to allow support for newer revisions?
Correct.
Quoted 2 lines
Future revisions *should* be 100% register compatible, but obviously we can't actually test this as they don't exist yet!
This is a never-ending debate, as each approach as its pros and cons. Strict revision checking is safer, it avoids misdetections and guarantees that newer revisions are validated before we claim supporting them. But it also means that new revisions have no chance to work out the box, while in almost all cases they really should.
An intermediate approach is to allow all known revisions values + all foreseeable ones. For example, if you know of revision 1, and you expect only a couple future revisions of the chip, you may decide to allow range 1-3. This approach has my preference, but in the end I'm not enforcing it, it's really up to every driver author.
Quoted 15 lines
Quoted 4 lines
Quoted 4 lines
prog/detect/sensors-detect +4
-0+sub smsc_emc2103_detect +{ + my ($file, $addr) = @_; + return unless i2c_smbus_read_byte_data($file, 0xFE) = 0x5D;Quoted 8 lines
prog/detect/sensors-detect sub smsc47m192_detect · line 5099
Quoted 5 lines
prog/detect/sensors-detect +5
-0+ + my $product = i2c_smbus_read_byte_data($file, 0xFD); + return unless (($product = 0x24) || ($product = 0x26)); + + return 8;You can't grant such a high confidence value after checking only 15
bits: it would rather be confidence 5 or 6.Ok, I'll update this.
Quoted 7 lines
Quoted 3 lines
Also, the detection registers seem similar to the EMC1403's, so it might make sense to reuse function
emc1403_detectfor the EMC2103, instead of writing a new one.Ahh, I actually wrote the sensors-detect routine before the EMC1403 support was merged. This definitely makes sense, the patch is much smaller now.
Great, thank you.
Signature · 6 lines
Jean Delvare _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Hi Steve,
Quoted 34 lines · Steve Glendinning
This patch allows the sensors-detect script to detect the SMSC EMC2103 family of temperature sensors and fan controllers.
Signed-off-by Steve Glendinning <[email protected]>--- prog/detect/sensors-detect | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletions(-)prog/detect/sensors-detect +6
-1@@ -1130,6 +1130,11 @@ use vars qw(@i2c_adapter_names); i2c_addrs => [0x2c..0x2e], i2c_detect => sub { dme1737_detect(@_, 2); }, }, { + name => "SMSC EMC2103", + driver => "emc2103", + i2c_addrs => [0x2e], + i2c_detect => sub { emc1403_detect(@_, 2); }, + }, { name => "Fintek F75121R/F75122R/RG (VID+GPIO)", driver => "to-be-written", i2c_addrs => [0x4e], # 0x37 not probed@@ -5143,7 +5148,7 @@ sub fintek_detect return 7; } -# Chip to detect: 0 = EMC1403, 1 = EMC1404 +# Chip to detect: 0 = EMC1403, 1 = EMC1404, 2 = EMC2103 # Registers used: # 0xfd: Device ID register # 0xfe: Vendor ID register
prog/detect/sensors-detect sub emc1403_detect · line 5176
Quoted 9 lines
prog/detect/sensors-detect +3
-0@@ -5163,6 +5168,9 @@ sub emc1403_detect } elsif ($chip = 1) { return unless $dev_id = 0x25; return unless $rev = 0x01; + } elsif ($chip = 2) { + return unless ($dev_id = 0x24) || ($dev_id = 0x26); + return unless $rev = 0x01; } return 6;
Patch applied, thanks.
Signature · 6 lines
Jean Delvare _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors