From 6dd6a90af510adcb674069d68682a5969d3bdc38 Mon Sep 17 00:00:00 2001 From: "Mark D. Studebaker" Date: Sat, 27 Mar 2004 02:50:11 +0000 Subject: [PATCH] add smart battery manager and charger detection git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@2392 7894878c-1315-0410-8ee3-d5d059ff63e0 --- CHANGES | 1 + prog/detect/sensors-detect | 55 +++++++++++++++++++++++++++++++++++++- 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 9f9792a2..d6ac09c0 100644 --- a/CHANGES +++ b/CHANGES @@ -40,6 +40,7 @@ ask CVS about it: Add a white list of IBM systems Drop support of undetectable adapters Fix smart battery detection + Add smart battery charger and manager detection Program sensors-detect-stat.pl: New diff --git a/prog/detect/sensors-detect b/prog/detect/sensors-detect index 3bcf82f6..8d0ca181 100755 --- a/prog/detect/sensors-detect +++ b/prog/detect/sensors-detect @@ -778,7 +778,8 @@ use subs qw(mtp008_detect lm78_detect lm78_isa_detect lm78_alias_detect adm1026_detect w83l785ts_detect lm83_detect lm90_detect saa1064_detect w83l784r_detect mozart_detect max6650_detect fscher_detect adm1029_detect adm1031_detect max6900_detect - m5879_detect pca9540_detect); + m5879_detect pca9540_detect smartbatt_mgr_detect + smartbatt_chgr_detect); # This is a list of all recognized chips. # Each entry must have the following fields: @@ -1280,6 +1281,18 @@ use subs qw(mtp008_detect lm78_detect lm78_isa_detect lm78_alias_detect isa_addrs => [ 0x0ca8 ], isa_detect => sub { ipmi_smic_detect @_ }, }, + { + name => "Smart Battery Charger", + driver => "to-be-written", + i2c_addrs => [0x09], + i2c_detect => sub { smartbatt_chgr_detect @_}, + }, + { + name => "Smart Battery Manager/Selector", + driver => "to-be-written", + i2c_addrs => [0x0a], + i2c_detect => sub { smartbatt_mgr_detect @_}, + }, { name => "Smart Battery", driver => "smartbatt", @@ -3908,6 +3921,46 @@ sub arp_detect return (1); } +# This checks for non-FFFF values for SpecInfo and Status. +# The address (0x09) is specified by the SMBus standard so it's likely +# that this really is a smart battery charger. +# $_[0]: A reference to the file descriptor to access this chip. +# We may assume an i2c_set_slave_addr was already done. +# $_[1]: Address +# Returns: 5 +sub smartbatt_chgr_detect +{ + my ($file,$addr) = @_; + # check some registers + if (i2c_smbus_read_word_data($file,0x11) == 0xffff) { + return; + } + if (i2c_smbus_read_word_data($file,0x13) == 0xffff) { + return; + } + return (5); +} + +# This checks for non-FFFF values for State and Info. +# The address (0x0a) is specified by the SMBus standard so it's likely +# that this really is a smart battery manager/selector. +# $_[0]: A reference to the file descriptor to access this chip. +# We may assume an i2c_set_slave_addr was already done. +# $_[1]: Address +# Returns: 5 +sub smartbatt_mgr_detect +{ + my ($file,$addr) = @_; + # check some registers + if (i2c_smbus_read_word_data($file,0x01) == 0xffff) { + return; + } + if (i2c_smbus_read_word_data($file,0x04) == 0xffff) { + return; + } + return (5); +} + # This checks for non-FFFF values for temperature, voltage, and current. # The address (0x0b) is specified by the SMBus standard so it's likely # that this really is a smart battery.