3rd phase of generating device tree from the MRW.
Added the aliases node, and fix some other minor issues.
Change-Id: I6bf8785bc1144022adfb858fd98787d80b26003a
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
diff --git a/gen_devtree.pl b/gen_devtree.pl
index 39040ba..e42eab0 100755
--- a/gen_devtree.pl
+++ b/gen_devtree.pl
@@ -46,6 +46,7 @@
printPropertyList($f, 1, "model", getSystemBMCModel());
printPropertyList($f, 1, "compatible", getBMCCompatibles());
+printNode($f, 1, "aliases", getAliases());
printNode($f, 1, "chosen", getChosen());
printNode($f, 1, "memory", getMemory($g_bmc));
@@ -55,7 +56,6 @@
printRootNodeEnd($f, 0);
-#TODO: I2C, aliases, pinctlr
printNodes($f, 0, getMacNodes());
printNodes($f, 0, getUARTNodes());
printNodes($f, 0, getVuartNodes());
@@ -64,6 +64,36 @@
exit 0;
+#Returns a hash that represents the 'aliases' node.
+#Will look like:
+# aliases {
+# name1 = &val1;
+# name2 = &val2;
+# ...
+# }
+sub getAliases()
+{
+ my %aliases;
+ my $name, my $val;
+
+ #The MRW supports up to 6 name and value pairs.
+ for (my $i = 1; $i <= 6; $i++) {
+ my $nameAttr = "name$i";
+ my $valAttr = "value$i";
+
+ $name = $g_targetObj->getAttributeField($g_bmc, "BMC_DT_ALIASES",
+ $nameAttr);
+ if ($name ne "") {
+ $val = $g_targetObj->getAttributeField($g_bmc, "BMC_DT_ALIASES",
+ $valAttr);
+ #The value will be printed as '&val'
+ $aliases{$name} = "(alias)$val";
+ }
+ }
+
+ return %aliases;
+}
+
#Return a hash that represents the 'chosen' node
#Will look like:
@@ -183,6 +213,7 @@
}
#now turn it into something like fmc@...
+ $regBase =~ s/^0x//;
$nodeName .= "@".$regBase;
if (!$g_targetObj->isBadAttribute($spi->{SOURCE},
@@ -382,7 +413,8 @@
{
my @nodes;
- my $connections = findConnections($g_bmc, "UART");
+ #Using U750 for legacy MRW reasons
+ my $connections = findConnections($g_bmc, "U750");
if ($connections eq "") {
print "WARNING: No UART buses found connected to the BMC\n";
@@ -506,12 +538,15 @@
{
my @compats;
- #The first one is from the MRW, the next one is more generic
- #and just <mfgr>-<model>.
+ #1st entry: <system mfgr>,<system name>-bmc
+ #2nd entry: <bmc mfgr>,<bmc model>
- if (!$g_targetObj->isBadAttribute($g_bmc, "BMC_DT_COMPATIBLE", "NA")) {
- my $attr = $g_targetObj->getAttribute($g_bmc, "BMC_DT_COMPATIBLE");
- push @compats, $attr;
+ foreach my $target (sort keys %{ $g_targetObj->getAllTargets() }) {
+ if ($g_targetObj->getType($target) eq "SYS") {
+ my $mfgr = $g_targetObj->getAttribute($target, "MANUFACTURER");
+ push @compats, lc "$mfgr,$g_systemName-bmc";
+ last;
+ }
}
push @compats, lc($g_bmcMfgr).",".lc($g_bmcModel);
@@ -653,7 +688,16 @@
sub printProperty()
{
my ($f, $level, $name, $val) = @_;
- print $f indent($level) . "$name = \"" . convertAlias($val) . "\";\n";
+ my $quote = "\"";
+
+ $val = convertAlias($val);
+
+ #properties with < > or single word aliases don't need quotes
+ if (($val =~ /<.*>/) || ($val =~ /^&\w+$/)) {
+ $quote = "";
+ }
+
+ print $f indent($level) . "$name = $quote$val$quote;\n";
}
@@ -806,6 +850,11 @@
}
}
+ #Match the Targets::findConnections return strategy
+ if (!keys %allConnections) {
+ return "";
+ }
+
return \%allConnections;
}