aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Zinoviev <me@ch1p.io>2021-02-10 15:27:31 +0300
committerEvgeny Zinoviev <me@ch1p.io>2021-02-10 15:27:31 +0300
commitb1918fd7dde901388dc215ca7779e8e41dbb7df6 (patch)
tree148789d364c765f3dbe1cd2c06dcbe1010ed8925
parent097752bcb135407f404fd8b6478a31b1e24a7f97 (diff)
support multiple models as they all use the same gpios
-rw-r--r--README6
-rwxr-xr-xget_macbook_ramconfig80
-rwxr-xr-xget_mbp101_ramcfg50
3 files changed, 85 insertions, 51 deletions
diff --git a/README b/README
index b108e81..0702a30 100644
--- a/README
+++ b/README
@@ -1,5 +1,9 @@
USAGE
- sudo inteltool -g | get_mbp101_ramcfg
+ sudo inteltool -g | get_macbook_ramcfg -m <MODEL>
+
+MODELS
+ mbp101 - MacBook Pro 10,1
+ mba52 - MacBook Air 5,2
LICENSE
BSD-2c
diff --git a/get_macbook_ramconfig b/get_macbook_ramconfig
new file mode 100755
index 0000000..d3a32b1
--- /dev/null
+++ b/get_macbook_ramconfig
@@ -0,0 +1,80 @@
+#!/usr/bin/env python3
+import sys
+import argparse
+
+
+ramconfigs = {
+ 'mba52': (
+ '4b_hynix',
+ None,
+ '8g_hynix',
+ None,
+ '4g_samsung',
+ None,
+ '8g_samsung',
+ None,
+ None,
+ None,
+ None,
+ None,
+ '4g_elpida',
+ None,
+ '8g_elpida',
+ ),
+ 'mbp101': (
+ '4g_hynix_1600s',
+ '1g_samsung_1600',
+ '4g_samsung_1600s',
+ '1g_hynix_1600',
+ '4g_elpida_1600s',
+ '2g_samsung_1600',
+ '2g_samsung_1333',
+ '2g_hynix_1600',
+ '4g_samsung_1600',
+ '4g_hynix_1600',
+ '2g_elpida_1600s',
+ '2g_elpida_1600',
+ '4g_elpida_1600',
+ '2g_samsung_1600s',
+ '2g_hynix_1600s'
+ )
+}
+
+
+def main():
+ parser = argparse.ArgumentParser()
+ parser.add_argument('-m', '--model',
+ choices=list(ramconfigs.keys()),
+ help='MacBook model',
+ required=True)
+
+ args = parser.parse_args()
+
+ configs = ramconfigs[args.model]
+
+ reg = None
+ for line in sys.stdin:
+ line = line.strip()
+ if not line.endswith('(GPIO_LVL3)'):
+ continue
+
+ reg = int(line.split(' ')[1], 16)
+ break
+
+ if reg is None:
+ raise Exceptions("failed to parse gpio registers")
+
+ # GPIO68..GPIO71
+ ramcfg = (reg >> 4) & 0xf
+
+ # reverse bit order
+ ramcfg = int('{:04b}'.format(ramcfg)[::-1], 2)
+
+ if ramcfg >= len(configs) or configs[ramcfg] is None:
+ print("unsupported memory configuration %d" % ramcfg)
+ else:
+ print("%s (RAMCFG=%01x)" % (configs[ramcfg], ramcfg))
+
+
+if __name__ == '__main__':
+ main()
diff --git a/get_mbp101_ramcfg b/get_mbp101_ramcfg
deleted file mode 100755
index 7cead1e..0000000
--- a/get_mbp101_ramcfg
+++ /dev/null
@@ -1,50 +0,0 @@
-#!/usr/bin/env python3
-import sys
-
-
-ramconfigs = (
- '4g_hynix_1600s',
- '1g_samsung_1600',
- '4g_samsung_1600s',
- '1g_hynix_1600',
- '4g_elpida_1600s',
- '2g_samsung_1600',
- '2g_samsung_1333',
- '2g_hynix_1600',
- '4g_samsung_1600',
- '4g_hynix_1600',
- '2g_elpida_1600s',
- '2g_elpida_1600',
- '4g_elpida_1600',
- '2g_samsung_1600s',
- '2g_hynix_1600s'
-)
-
-
-def main():
- reg = None
- for line in sys.stdin:
- line = line.strip()
- if not line.endswith('(GPIO_LVL3)'):
- continue
-
- reg = int(line.split(' ')[1], 16)
- break
-
- if reg is None:
- raise Exceptions("failed to parse gpio registers")
-
- # GPIO68..GPIO71
- ramcfg = (reg >> 4) & 0xf
-
- # reverse bit order
- ramcfg = int('{:04b}'.format(ramcfg)[::-1], 2)
-
- if ramcfg >= len(ramconfigs):
- print("unsupported memory configuration %d" % ramcfg)
- else:
- print(ramconfigs[ramcfg])
-
-
-if __name__ == '__main__':
- main()