meta-google- ipmi-config: Add google-version support

Read GBMC_VERSION and configure the ipmi firmware revision with the
major/minor. The aux is used for the point and subpoint. This allow gBMC
to remove the internal patch that we used to support our versioning
format.

Requires the change in
https://gerrit.openbmc.org/c/openbmc/phosphor-host-ipmid/+/54147/

Tested:
With firmware_revision in dev_id.json
```
$ cat /usr/share/ipmi-providers/dev_id.json
$ ipmitool mc info
{
    "id": 0,
    "revision": 0,
    "addn_dev_support": 0,
    "firmware_revision": {
        "major": 35,
        "minor": 16
    },
    "manuf_id": 11129,
    "prod_id": 14426,
    "aux": 0
}

ipmitool mc info
Device ID                 : 0
Device Revision           : 0
Firmware Revision         : 35.10
IPMI Version              : 2.0
Manufacturer ID           : 11129
Manufacturer Name         : Google, Inc.
Product ID                : 14426 (0x385a)
Product Name              : Unknown (0x385A)
Device Available          : yes
Provides Device SDRs      : no
Additional Device Support :
Aux Firmware Rev Info     :
    0x00
    0x00
    0x00
    0x00
```

Change-Id: I64ed6f54612d45732e366a2b245d33db00540093
Signed-off-by: Willy Tu <wltu@google.com>
diff --git a/meta-google/recipes-phosphor/ipmi/phosphor-ipmi-config.bbappend b/meta-google/recipes-phosphor/ipmi/phosphor-ipmi-config.bbappend
index 2f2d9e0..1ae7459 100644
--- a/meta-google/recipes-phosphor/ipmi/phosphor-ipmi-config.bbappend
+++ b/meta-google/recipes-phosphor/ipmi/phosphor-ipmi-config.bbappend
@@ -41,3 +41,38 @@
     echo "[]" > ${D}${datadir}/ipmi-providers/entity-map.json
   fi
 }
+
+python do_gbmc_version () {
+  import json
+
+  if d.getVar('GBMC_VERSION') is None:
+    return
+
+  version = d.getVar('GBMC_VERSION').split('.')
+  major = min(int(version[0]), 0x7F) & 0x7F
+  minor = min(int(version[1]), 99)
+  minor = int(minor / 10) * 16 + minor % 10;
+  point = int(version[2])
+  subpoint = int(version[3])
+
+  dev_id = {
+    "id": 0,
+    "revision": 0,
+    "addn_dev_support": 0,
+    "firmware_revision": {
+      "major": major,
+      "minor": minor
+    },
+    "manuf_id": 11129,
+    "prod_id": 14426,
+    "aux": subpoint << 16 | (0xFFFF & point)
+  }
+
+  dir = d.getVar('WORKDIR')
+  os.makedirs(dir, exist_ok=True)
+  path = os.path.join(dir, 'dev_id.json')
+  with open(path, 'w') as f:
+    json.dump(dev_id, f, sort_keys=True, indent=4)
+}
+
+addtask gbmc_version before do_install