diff options
Diffstat (limited to 'common/recipes-utils/openbmc-gpio')
5 files changed, 61 insertions, 90 deletions
diff --git a/common/recipes-utils/openbmc-gpio/files/openbmc_gpio_setup.py b/common/recipes-utils/openbmc-gpio/files/openbmc_gpio_setup.py deleted file mode 100644 index 7c126d9..0000000 --- a/common/recipes-utils/openbmc-gpio/files/openbmc_gpio_setup.py +++ /dev/null @@ -1,76 +0,0 @@ -#!/usr/bin/python -tt -# Copyright 2015-present Facebook. All rights reserved. -# -# This program file is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the -# Free Software Foundation; version 2 of the License. -# -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program in a file named COPYING; if not, write to the -# Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, -# Boston, MA 02110-1301 USA -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function -from __future__ import unicode_literals - -from board_gpio_table import board_gpio_table -from soc_gpio_table import soc_gpio_table - -import openbmc_gpio -import openbmc_gpio_table - -import logging -import sys - - -def setup_board_gpio(soc_gpio_table, board_gpio_table, validate=True): - soc = openbmc_gpio_table.SocGPIOTable(soc_gpio_table) - gpio_configured = [] - for gpio in board_gpio_table: - try: - soc.config_function(gpio.gpio, write_through=False) - gpio_configured.append(gpio.gpio) - except openbmc_gpio_table.ConfigUnknownFunction as e: - # not multiple-function GPIO pin - pass - except openbmc_gpio_table.NotSmartEnoughException as e: - logging.error('Failed to configure "%s" for "%s": %s' - % (gpio.gpio, gpio.shadow, str(e))) - - soc.write_to_hw() - - if validate: - all_functions = set(soc.get_active_functions(refresh=True)) - for gpio in gpio_configured: - if gpio not in all_functions: - raise Exception('Failed to configure function "%s"' % gpio) - - for gpio in board_gpio_table: - openbmc_gpio.gpio_export(gpio.gpio, gpio.shadow) - if gpio.value == openbmc_gpio_table.GPIO_INPUT: - continue - elif gpio.value == openbmc_gpio_table.GPIO_OUT_HIGH: - openbmc_gpio.gpio_set(gpio.gpio, 1) - elif gpio.value == openbmc_gpio_table.GPIO_OUT_LOW: - openbmc_gpio.gpio_set(gpio.gpio, 0) - else: - raise Exception('Invalid value "%s"' % gpio.value) - -def main(): - print('Setting up GPIOs ... ', end='') - sys.stdout.flush() - openbmc_gpio.setup_shadow() - setup_board_gpio(soc_gpio_table, board_gpio_table) - print('Done') - sys.stdout.flush() - return 0 - -if __name__ == '__main__': - sys.exit(main()) diff --git a/common/recipes-utils/openbmc-gpio/files/openbmc_gpio_table.py b/common/recipes-utils/openbmc-gpio/files/openbmc_gpio_table.py index dda8a98..d188dcb 100644 --- a/common/recipes-utils/openbmc-gpio/files/openbmc_gpio_table.py +++ b/common/recipes-utils/openbmc-gpio/files/openbmc_gpio_table.py @@ -21,6 +21,7 @@ from __future__ import unicode_literals from soc_gpio import soc_get_register +import openbmc_gpio import logging import os import sys @@ -267,3 +268,36 @@ class BoardGPIO(object): self.gpio = gpio self.shadow = shadow self.value = value + +def setup_board_gpio(soc_gpio_table, board_gpio_table, validate=True): + soc = SocGPIOTable(soc_gpio_table) + gpio_configured = [] + for gpio in board_gpio_table: + try: + soc.config_function(gpio.gpio, write_through=False) + gpio_configured.append(gpio.gpio) + except ConfigUnknownFunction as e: + # not multiple-function GPIO pin + pass + except NotSmartEnoughException as e: + logging.error('Failed to configure "%s" for "%s": %s' + % (gpio.gpio, gpio.shadow, str(e))) + + soc.write_to_hw() + + if validate: + all_functions = set(soc.get_active_functions(refresh=True)) + for gpio in gpio_configured: + if gpio not in all_functions: + raise Exception('Failed to configure function "%s"' % gpio) + + for gpio in board_gpio_table: + openbmc_gpio.gpio_export(gpio.gpio, gpio.shadow) + if gpio.value == GPIO_INPUT: + continue + elif gpio.value == GPIO_OUT_HIGH: + openbmc_gpio.gpio_set(gpio.gpio, 1) + elif gpio.value == GPIO_OUT_LOW: + openbmc_gpio.gpio_set(gpio.gpio, 0) + else: + raise Exception('Invalid value "%s"' % gpio.value) diff --git a/common/recipes-utils/openbmc-gpio/files/setup.py b/common/recipes-utils/openbmc-gpio/files/setup.py index 59c7de4..bf7be3d 100644 --- a/common/recipes-utils/openbmc-gpio/files/setup.py +++ b/common/recipes-utils/openbmc-gpio/files/setup.py @@ -18,6 +18,7 @@ from distutils.core import setup +from setup_board import board_py_modules setup( name = 'openbmc-gpio', @@ -31,6 +32,6 @@ setup( 'phymemory', 'soc_gpio', 'soc_gpio_table', - 'board_gpio_table', - ], + 'board_gpio_table', ] + + board_py_modules , ) diff --git a/common/recipes-utils/openbmc-gpio/files/setup_board.py b/common/recipes-utils/openbmc-gpio/files/setup_board.py new file mode 100644 index 0000000..aff7398 --- /dev/null +++ b/common/recipes-utils/openbmc-gpio/files/setup_board.py @@ -0,0 +1,23 @@ +# Copyright 2015-present Facebook. All rights reserved. +# +# This program file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program in a file named COPYING; if not, write to the +# Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301 USA + +# This is a dummy board GPIO table. If this is included in the final image, +# please double check the configuration of your image to define the correct +# GPIO table to be used for your board. + +board_py_modules = [ +] diff --git a/common/recipes-utils/openbmc-gpio/openbmc-gpio_0.1.bb b/common/recipes-utils/openbmc-gpio/openbmc-gpio_0.1.bb index 6bf4cc1..a2b46d4 100644 --- a/common/recipes-utils/openbmc-gpio/openbmc-gpio_0.1.bb +++ b/common/recipes-utils/openbmc-gpio/openbmc-gpio_0.1.bb @@ -25,12 +25,12 @@ SRC_URI = " \ file://board_gpio_table.py \ file://openbmc_gpio.py \ file://openbmc_gpio_table.py \ - file://openbmc_gpio_setup.py \ file://openbmc_gpio_util.py \ file://phymemory.py \ file://setup.py \ file://soc_gpio.py \ file://soc_gpio_table.py \ + file://setup_board.py \ " S = "${WORKDIR}" @@ -41,9 +41,6 @@ OPENBMC_GPIO_UTILS = " \ OPENBMC_GPIO_SOC_TABLE = "soc_gpio_table.py" -# Change OPENBMC_GPIO_SETUP to "0" to exclude openbmc_gpio_setup.py from the image -OPENBMC_GPIO_SETUP = "1" - inherit distutils DEPENDS_${PN} = "python python-distribute update-rc.d-native" @@ -63,13 +60,5 @@ do_install_append() { for f in ${OPENBMC_GPIO_UTILS}; do install -m 755 $f ${localbindir}/${f} done - - install -d ${D}${sysconfdir}/init.d - install -d ${D}${sysconfdir}/rcS.d - if [ "${OPENBMC_GPIO_SETUP}" == "1" ]; then - install -m 755 openbmc_gpio_setup.py ${D}${sysconfdir}/init.d/openbmc_gpio_setup.py - update-rc.d -r ${D} openbmc_gpio_setup.py start 59 S . - fi } -FILES_${PN} += "/usr/local/bin ${sysconfdir}" |