summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDeepak Kodihalli <dkodihal@in.ibm.com>2017-03-02 02:32:45 -0600
committerDeepak Kodihalli <dkodihal@in.ibm.com>2017-03-02 02:32:45 -0600
commit65682175eaaf95182deba9617d47f676b2974dab (patch)
treef2a43e290c10b0abae23efb4d783b0f448f9c9d1
parent1c7a8890b74ba1fb53a0f5010600482f6741127d (diff)
downloadphosphor-mrw-tools-65682175eaaf95182deba9617d47f676b2974dab.tar.gz
phosphor-mrw-tools-65682175eaaf95182deba9617d47f676b2974dab.zip
callouts: refactor: merge i2c and fsi callouts
Merge gen_i2c_callouts.pl and gen_proc_fsi_callouts.pl to a single gen_callouts.pl. The idea as to have a unified output generated for callouts, irrespective of bus type. The output will be in YAML, as follows: <sysfs path> : <Inventory path to be called out> This will simplify usage for the FRU management code, as well as it should be easier to support other bus types. Change-Id: I8793be1207d905af1eb83b5b04383da39efbe02f Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
-rwxr-xr-xgen_callouts.pl127
-rwxr-xr-xgen_i2c_callouts.pl77
-rwxr-xr-xgen_proc_fsi_callouts.pl81
3 files changed, 127 insertions, 158 deletions
diff --git a/gen_callouts.pl b/gen_callouts.pl
new file mode 100755
index 0000000..7e0b9e1
--- /dev/null
+++ b/gen_callouts.pl
@@ -0,0 +1,127 @@
+#! /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);
+
+
+# paths
+my $i2cPath = "/sys/devices/platform/ahb/ahb:apb/1e78a000.i2c/i2c-<port>/i2c-<port>/<port>-00<address>";
+my $fsiMasterPath = "/sys/devices/platform/fsi-master/slave\@00:00";
+my $fsiSlavePath = "/sys/devices/hub\@00/slave\@<link>:00";
+
+
+open(my $fh, '>', $outFile) or die "Could not open file '$outFile' $!";
+
+genI2CCallouts();
+genProcFSICallouts();
+
+close $fh;
+
+
+sub genI2CCallouts
+{
+ 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)
+ {
+ for my $s(@{$masters{$m}})
+ {
+ my $addr = $targets->getAttribute($s,"I2C_ADDRESS");
+ $addr = Util::adjustI2CAddress(hex($addr));
+ $addr = substr $addr, 2; # strip 0x
+ my $path = $i2cPath;
+ $path =~ s/<port>/$m/g;
+ $path =~ s/<address>/$addr/g;
+ print $fh $path.": ";
+ my $fru = Util::getEnclosingFru($targets, $s);
+ print $fh Util::getObmcName(\@inventory, $fru)."\n";
+ }
+ }
+}
+
+
+sub genProcFSICallouts
+{
+ my @procs;
+ for my $target (keys %{$targets->getAllTargets()})
+ {
+ if ($targets->getType($target) eq "PROC")
+ {
+ push @procs, $target;
+ }
+ }
+
+ for my $proc (@procs)
+ {
+ my $connections = $targets->findConnections($proc, "FSIM");
+ if ("" ne $connections)
+ {
+ # This is a master processor
+ my $path = $fsiMasterPath; # revisit on a multinode system
+ my $fru = Util::getEnclosingFru($targets, $proc);
+ print $fh $path.": ".Util::getObmcName(\@inventory, $fru);
+ for my $fsi (@{$connections->{CONN}})
+ {
+ my $master = $fsi->{SOURCE};
+ my $slave = $fsi->{DEST};
+ my $link = $targets->getAttribute($master, "FSI_LINK");
+ $link = substr $link, 2; # strip 0x
+ my $fru = Util::getEnclosingFru($targets, $slave);
+ $path = $fsiSlavePath;
+ $path =~ s/<link>/$link/g;
+ print $fh "\n".$path.": ".Util::getObmcName(\@inventory, $fru);
+ }
+ }
+ }
+}
+
+
+sub printUsage
+{
+ print "
+ $0 -m [MRW file] -o [Output filename]\n";
+ exit(1);
+}
diff --git a/gen_i2c_callouts.pl b/gen_i2c_callouts.pl
deleted file mode 100755
index 587c86f..0000000
--- a/gen_i2c_callouts.pl
+++ /dev/null
@@ -1,77 +0,0 @@
-#! /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);
-}
diff --git a/gen_proc_fsi_callouts.pl b/gen_proc_fsi_callouts.pl
deleted file mode 100755
index 41c7ab4..0000000
--- a/gen_proc_fsi_callouts.pl
+++ /dev/null
@@ -1,81 +0,0 @@
-#! /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' $!";
-
-
-# MRW/Targets.pm doesn't seem to tell me which the master proc(s) are.
-# Find those out.
-my @procs;
-for my $target (keys %{$targets->getAllTargets()})
-{
- if ($targets->getType($target) eq "PROC")
- {
- push @procs, $target;
- }
-}
-
-for my $proc (@procs)
-{
- my $connections = $targets->findConnections($proc, "FSIM");
- if ("" ne $connections)
- {
- # This is a master processor
- my $link = "0x00"; # revisit on a multinode system
- my $fru = Util::getEnclosingFru($targets, $proc);
- print $fh $link.": ".Util::getObmcName(\@inventory, $fru);
- for my $fsi (@{$connections->{CONN}})
- {
- my $master = $fsi->{SOURCE};
- my $slave = $fsi->{DEST};
- my $link = $targets->getAttribute($master, "FSI_LINK");
- my $fru = Util::getEnclosingFru($targets, $slave);
- print $fh "\n".$link.": ".Util::getObmcName(\@inventory, $fru);
- }
- }
-}
-
-
-close $fh;
-
-
-sub printUsage
-{
- print "
- $0 -m [MRW file] -o [Output filename]\n";
- exit(1);
-}
OpenPOWER on IntegriCloud