diff options
author | Patrick Venture <venture@google.com> | 2019-03-04 19:54:12 +0300 |
---|---|---|
committer | Andrew Geissler <geissonator@yahoo.com> | 2019-03-05 16:19:33 +0300 |
commit | 4019e98dc59160d0ec06ad524a8afe8fdb2f4732 (patch) | |
tree | 555c9153dd4f177f6d610b580b3ff3853ce0afed /meta-quanta/meta-q71l/recipes-phosphor/spictrl/files/spimaster.py | |
parent | 5f3956a6a8529cff11da6504c3830db95bda842b (diff) | |
download | openbmc-4019e98dc59160d0ec06ad524a8afe8fdb2f4732.tar.xz |
meta-quanta: q71l: drop spictrl script
Drop the spimaster python script. This script let one, via devmem
accesses, change the SPI control to let the BMC access the BIOS flash
chip.
OpenBMC is aiming to drop python support, and this script was only a
proof-of-concept. If required, a linux driver should be written to
handle this.
(From meta-quanta rev: fa279684ea0fa59cd106c6955c92d2f9f539c3a0)
Change-Id: I74e4e62054b914013d230b834e882353eb70a67e
Signed-off-by: Patrick Venture <venture@google.com>
Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
Diffstat (limited to 'meta-quanta/meta-q71l/recipes-phosphor/spictrl/files/spimaster.py')
-rw-r--r-- | meta-quanta/meta-q71l/recipes-phosphor/spictrl/files/spimaster.py | 148 |
1 files changed, 0 insertions, 148 deletions
diff --git a/meta-quanta/meta-q71l/recipes-phosphor/spictrl/files/spimaster.py b/meta-quanta/meta-q71l/recipes-phosphor/spictrl/files/spimaster.py deleted file mode 100644 index dd08372b7..000000000 --- a/meta-quanta/meta-q71l/recipes-phosphor/spictrl/files/spimaster.py +++ /dev/null @@ -1,148 +0,0 @@ -# Copyright (C) 2017 Google Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -#!/usr/bin/env python -"""Basic utility for reading and writing registers on an ASPEED BMC. - -The values hardcoded are for the ASPEED AST2400. -""" - -import subprocess -import sys - -IO_TOOL = 'devmem' -PROTECTION_KEY = '0x1E6E2000' -HWTRAP = '0x1E6E2070' -# The AST2400 SCU Password (as int for write_register) -SCU_PASSWORD = 0x1688A8A8 - -# Bits 13:12 -SPI_MASK = 0xffffcfff -# Enable SPI Master -SPI_MASTER = 0x1000 -# Enable SPI Master and SPI Slave to AHB Bridge -SPI_MASTER_SLAVE = 0x2000 -# Enable SPI Pass-through -SPI_BYPASS = 0x3000 - - -def read_register(address): - """Run a tool to read a register value. - - This will convert it to an integer. - """ - - output = subprocess.check_output([IO_TOOL, address]).replace('\n', '') - value = int(output, 16) - return value - - -def write_register(address, value): - """Run a tool to write the 32-bit register value.""" - - subprocess.check_output([IO_TOOL, address, '32', '0x%x' % value]) - return - - -def set_master(value): - """Set Hardware Strapping to SPI Master.""" - - print 'Setting to "SPI Master"' - - masked = value & SPI_MASK - masked |= SPI_MASTER - - print 'setting: 0x%x' % masked - write_register(HWTRAP, masked) - - -def set_ahb_bridge(value): - """Set hardware strapping to spi master and spi-slave to ahb.""" - - print 'Setting to "SPI Master and SPI Slave to AHB Bridge"' - masked = value & SPI_MASK - masked |= SPI_MASTER_SLAVE - - print 'setting: 0x%x' % masked - write_register(HWTRAP, masked) - - -def set_bypass(value): - """Set hardware strappign to spi bypass.""" - - print 'Setting to "Enable SPI Pass-through"' - masked = value & SPI_MASK - masked |= SPI_BYPASS - - print 'setting: 0x%x' % masked - write_register(HWTRAP, masked) - - -def usage(): - """Print usage string.""" - - print 'usage: %s master|bridge|bypass' % sys.argv[0] - print 'master sets the BMC SPI to Master.' - print ('bridge sets the BMC SPI to Master-Slave bridge to AHB (for BIOS ' + - 'Update).') - print 'bypass sets the BMC SPI to Bypass (default).' - - -def main(): - """Main entry point for execution.""" - - if len(sys.argv) != 2: - usage() - sys.exit(-1) - - ctrl = sys.argv[1].lower() - if ctrl not in ('master', 'bridge', 'bypass'): - usage() - sys.exit(-1) - - locked = False - # Check if locked - value = read_register(PROTECTION_KEY) - if value == 1: - print 'Presently unlocked' - else: - print 'Presently locked' - locked = True - - # if Locked we need to unlock it. - if locked: - write_register(PROTECTION_KEY, SCU_PASSWORD) - - # Read the value. - value = read_register(HWTRAP) - if value & SPI_BYPASS == SPI_BYPASS: - print 'Presently set to bypass' - elif value & SPI_MASTER == SPI_MASTER: - print 'Presently set to master' - elif value & SPI_MASTER_SLAVE == SPI_MASTER_SLAVE: - print 'Presently set to master-slave' - - if ctrl == 'master': - set_master(value) - elif ctrl == 'bridge': - set_ahb_bridge(value) - elif ctrl == 'bypass': - set_bypass(value) - - # We leave it unlocked in case it was locked. - # we could lock it. - # TODO(venture): lock it by writing any non-password value. - -if __name__ == '__main__': - main() |