Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(60)

Side by Side Diff: client/site_tests/hardware_GPIOSwitches/hardware_GPIOSwitches.py

Issue 1616002: GPIO button test (Closed)
Patch Set: Tested on proto machine, fix typo, iotools unpacking Created 10 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « client/site_tests/hardware_GPIOSwitches/control ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 __author__ = 'nsanders@chromium.org (Nick Sanders)'
6
7 import logging, os
8
9 from autotest_lib.client.bin import test, utils
10 from autotest_lib.client.common_lib import error
11
12 class hardware_GPIOSwitches(test.test):
13 version = 1
14
15
16 def init_sku_table(self):
17 self.sku_table = {
18 # SKU: gpio_read, recovery GPIO, developer mode,
19 # firmware writeprotect
20 'atom-proto': {'gpio_read': self.pinetrail_gpio_read,
21 'recovery': 6, 'developer': 7, 'fwwp': 10},
22 }
23
24
25 def setup(self):
26 self.job.setup_dep(['iotools'])
27 # create a empty srcdir to prevent the error that checks .version file
28 if not os.path.exists(self.srcdir):
29 os.mkdir(self.srcdir)
30
31
32 def run_once(self):
33 self.init_sku_table()
34 dep = 'iotools'
35 dep_dir = os.path.join(self.autodir, 'deps', dep)
36 self.job.install_pkg(dep, 'dep', dep_dir)
37
38 # TODO(nsanders): Detect actual system type here by HWQual ID (?)
39 # and redirect to the correct check.
40 # We're just checking for any Atom here, and hoping for the best.
41 try:
42 utils.system('cat /proc/cpuinfo | grep "model name" | '
43 'grep -qe "N4[0-9][0-9]"')
44 systemsku = 'atom-proto'
45 except:
46 systemsku = 'unknown'
47
48 # Look up hardware configuration.
49 if systemsku in self.sku_table:
50 table = self.sku_table[systemsku]
51 self.gpio_read = table['gpio_read']
52 self.recovery_gpio = table['recovery']
53 self.developer_gpio = table['developer']
54 self.fwwp_gpio = table['fwwp']
55 else:
56 raise error.TestError('System settings not defined for board %s' %
57 systemsku)
58
59 recovery, developer, fwwp = self.gpio_read()
60
61 keyvals = {}
62 keyvals['level_recovery'] = recovery
63 keyvals['level_developer'] = developer
64 keyvals['level_firmware_writeprotect'] = fwwp
65
66 self.write_perf_keyval(keyvals)
67
68
69 # Returns (recovery, developer, fwwp).
70 # Throws exception on error.
71 def pinetrail_gpio_read(self):
72 path = self.autodir + '/deps/iotools/'
73 # Generate symlinks for iotools.
74 utils.system(path + 'iotools --make-links')
75
76 # Tigerpoint LPC Interface.
77 tp_device = (0, 31, 0)
78 # TP io port location of GPIO registers.
79 tp_GPIOBASE = 0x48
80 # IO offset to check GPIO levels.
81 tp_GP_LVL_off = 0xc
82
83 tp_gpio_iobase_str = utils.system_output(path +
84 'pci_read32 %s %s %s %s' % (
85 tp_device[0], tp_device[1], tp_device[2], tp_GPIOBASE))
86 # Bottom bit of GPIOBASE is a flag indicating io space.
87 tp_gpio_iobase = long(tp_gpio_iobase_str, 16) & ~1
88
89 tp_gpio_mask_str = utils.system_output(path +
90 'io_read32 %s' % (
91 tp_gpio_iobase + tp_GP_LVL_off))
92
93 tp_gpio_mask = long(tp_gpio_mask_str, 16)
94 recovery = (tp_gpio_mask >> self.recovery_gpio) & 1
95 developer = (tp_gpio_mask >> self.developer_gpio) & 1
96 fwwp = (tp_gpio_mask >> self.fwwp_gpio) & 1
97
98 return recovery, developer, fwwp
OLDNEW
« no previous file with comments | « client/site_tests/hardware_GPIOSwitches/control ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698