summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDeepak Kodihalli <dkodihal@in.ibm.com>2017-02-22 04:21:09 -0600
committerPatrick Williams <patrick@stwcx.xyz>2017-02-24 16:14:30 +0000
commitc54679c7f96c8391b81869eed775a8617fd954bc (patch)
tree386e22a7c136a8a20989660b2d8e1c77378f751b
parent9283add2b13b43e50248c612a5b2dfbed9a39903 (diff)
downloadphosphor-mrw-tools-c54679c7f96c8391b81869eed775a8617fd954bc.tar.gz
phosphor-mrw-tools-c54679c7f96c8391b81869eed775a8617fd954bc.zip
callouts: add script to generate I2C callouts
The script writes I2C callout information to an output file in the following YAML format: I2C Port number: I2C address: FRU path Only those I2C ports that the BMC can talk to are considered. Change-Id: Id673b114f77f9763514a3dd3f6ba95568983f4c6 Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
-rwxr-xr-xgen_i2c_callouts.pl77
1 files changed, 77 insertions, 0 deletions
diff --git a/gen_i2c_callouts.pl b/gen_i2c_callouts.pl
new file mode 100755
index 0000000..587c86f
--- /dev/null
+++ b/gen_i2c_callouts.pl
@@ -0,0 +1,77 @@
+#! /usr/bin/perl
+use strict;
+use warnings;
+
+
+use mrw::Targets;
+use mrw::Inventory;
+use mrw::Util;
+use Getopt::Long;
+
+
+my $mrwFile = "";
+my $outFile = "";
+
+
+GetOptions(
+"m=s" => \$mrwFile,
+"o=s" => \$outFile,
+)
+or printUsage();
+
+
+if (($mrwFile eq "") or ($outFile eq ""))
+{
+ printUsage();
+}
+
+
+# Load system MRW
+my $targets = Targets->new;
+$targets->loadXML($mrwFile);
+
+
+# Load inventory
+my @inventory = Inventory::getInventory($targets);
+
+
+open(my $fh, '>', $outFile) or die "Could not open file '$outFile' $!";
+
+
+my $bmc = Util::getBMCTarget($targets);
+my $connections = $targets->findConnections($bmc, "I2C");
+# hash of arrays - {I2C master port : list of connected slave Targets}
+my %masters;
+
+for my $i2c (@{$connections->{CONN}})
+{
+ my $master = $i2c->{SOURCE};
+ my $port = $targets->getAttribute($master,"I2C_PORT");
+ $port = Util::adjustI2CPort($port);
+ my $slave = $i2c->{DEST};
+ push(@{$masters{$port}}, $slave);
+}
+
+for my $m (keys %masters)
+{
+ print $fh $m.":\n";
+ for my $s(@{$masters{$m}})
+ {
+ my $addr = $targets->getAttribute($s,"I2C_ADDRESS");
+ $addr = Util::adjustI2CAddress(hex($addr));
+ print $fh " ".$addr.": ";
+ my $fru = Util::getEnclosingFru($targets, $s);
+ print $fh Util::getObmcName(\@inventory, $fru)."\n";
+ }
+}
+
+
+close $fh;
+
+
+sub printUsage
+{
+ print "
+ $0 -m [MRW file] -o [Output filename]\n";
+ exit(1);
+}
OpenPOWER on IntegriCloud