pacman: Add script to generate servod config files

Pacman config files currently consist of a python file with information
about sensors, rails and GPIOs. This commit adds the
`gen_servod_config.py` script to generate servod config files from the
config files used by pacman. Example snippet of generated output:
```
config_type='servod'

inas = [
    ('pac1954', '0x10:0', 'ppvar_vddcr', 0.6, 0.003, 'rem', True),
    ('pac1954', '0x10:1', 'ppvar_vddcr_soc', 0.6, 0.01, 'rem', True),
    ('pac1954', '0x10:2', 'pp1800_s0', 1.8, 0.01, 'rem', True),
    ('pac1954', '0x10:3', 'pp1800_s5', 1.8, 0.03, 'rem', True),
```

BUG=b:231983768
TEST=Ran generated config through servod's `generate_ina_controls.py`

Change-Id: I51bef6fe9b643d0b6b8d8c18e64e11a01d65b0e8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/dev-util/+/3688611
Commit-Queue: Ruben Rodriguez Buchillon <coconutruben@chromium.org>
Reviewed-by: Ruben Rodriguez Buchillon <coconutruben@chromium.org>
Tested-by: Robert Zieba <robertzieba@google.com>
Auto-Submit: Robert Zieba <robertzieba@google.com>
diff --git a/contrib/power_measurement/pacman/gen_servod_config.py b/contrib/power_measurement/pacman/gen_servod_config.py
new file mode 100755
index 0000000..96b25a1
--- /dev/null
+++ b/contrib/power_measurement/pacman/gen_servod_config.py
@@ -0,0 +1,49 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+
+# Copyright 2022 The ChromiumOS Authors.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+"""Utility to convert pacman configs to servod xml configs"""
+
+import argparse
+import pathlib
+
+import pacconfig
+
+
+def write_servod_config(config, outpath):
+    """Converts pacman config to servod config"""
+    f = open(outpath, 'w')
+
+    f.write('# Generated from pacman board config\n')
+    f.write("config_type='servod'\n\n")
+    f.write('inas = [\n')
+    for pac in config.pacs:
+        f.write((f"    ('pac1954', '{pac.addr:#x}:{pac.channel}', "
+            f"'{pac.name.lower()}', {pac.nom}, {pac.rsense}, 'rem', True),\n"))
+
+    f.write(']')
+    f.close()
+
+
+def main():
+    """main function"""
+    parser = argparse.ArgumentParser()
+    parser.add_argument(
+        '-o',
+        '--output',
+        type=pathlib.Path
+    )
+    parser.add_argument(
+        'input',
+        type=pathlib.Path
+    )
+
+    args = parser.parse_args()
+
+    config = pacconfig.PacConfig(args.input)
+    write_servod_config(config, args.output)
+
+if __name__ == '__main__':
+    main()