diff options
author | Matt Spinler <spinler@us.ibm.com> | 2017-01-09 15:45:14 -0600 |
---|---|---|
committer | Matt Spinler <spinler@us.ibm.com> | 2017-01-17 10:27:28 -0600 |
commit | c79b21f481af173d89dc882dda37ca07a7d29807 (patch) | |
tree | 8651f02863da78b680db6e4bf76d8beff17cf013 /hwmon.pl | |
parent | 8df7be8f60050469b8989e9656b061bc6c3c37f1 (diff) | |
download | phosphor-mrw-tools-c79b21f481af173d89dc882dda37ca07a7d29807.tar.gz phosphor-mrw-tools-c79b21f481af173d89dc882dda37ca07a7d29807.zip |
Get I2C and hwmon attributes for hwmon entries
Find attributes in the MRW needed for the conf files.
Change-Id: I26754faa0ca66f265c054f44d36149041e06e458
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Diffstat (limited to 'hwmon.pl')
-rwxr-xr-x | hwmon.pl | 56 |
1 files changed, 56 insertions, 0 deletions
@@ -55,12 +55,68 @@ sub getI2CSensors my %entry; $entry{type} = I2C_TYPE; $entry{name} = lc $g_targetObj->getInstanceName($chip); + getHwmonAttributes(\@hwmonUnits, \%entry); + getI2CAttributes($i2c, \%entry); push @$hwmon, { %entry }; } } +#Reads the hwmon related attributes from the HWMON_FEATURE +#complex attribute and adds them to the hash. +sub getHwmonAttributes +{ + my ($units, $entry) = @_; + my %hwmonFeatures; + + for my $unit (@$units) { + + #The hwmon name, like 'in1', 'temp1', 'fan1', etc + my $hwmon = $g_targetObj->getAttributeField($unit, + "HWMON_FEATURE", + "HWMON_NAME"); + + #The useful name for this feature, like 'ambient' + my $name = $g_targetObj->getAttributeField($unit, + "HWMON_FEATURE", + "DESCRIPTIVE_NAME"); + $hwmonFeatures{$hwmon}{label} = $name; + + #Thresholds are optional, ignore if NA + my $warnHigh = $g_targetObj->getAttributeField($unit, + "HWMON_FEATURE", + "WARN_HIGH"); + if (($warnHigh ne "") && ($warnHigh ne "NA")) { + $hwmonFeatures{$hwmon}{warnhigh} = $warnHigh; + } + + my $warnLow = $g_targetObj->getAttributeField($unit, + "HWMON_FEATURE", + "WARN_LOW"); + if (($warnLow ne "") && ($warnLow ne "NA")) { + $hwmonFeatures{$hwmon}{warnlow} = $warnLow; + } + + my $critHigh = $g_targetObj->getAttributeField($unit, + "HWMON_FEATURE", + "CRIT_HIGH"); + if (($critHigh ne "") && ($critHigh ne "NA")) { + $hwmonFeatures{$hwmon}{crithigh} = $critHigh; + } + + my $critLow = $g_targetObj->getAttributeField($unit, + "HWMON_FEATURE", + "CRIT_LOW"); + if (($critLow ne "") && ($critHigh ne "NA")) { + $hwmonFeatures{$hwmon}{critlow} = $critLow; + } + } + + $entry->{hwmon} = { %hwmonFeatures }; +} + + #Reads the I2C attributes for the chip and adds them to the hash. #This includes the i2C address, and register base address and #offset for the I2C bus the chip is on. |