コード例 #1
0
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)
コード例 #2
0
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)
コード例 #3
0
def setup_board_tolerance_gpio(board_tolerance_gpio_table,
                               board_gpioOffsetDic, validate=True):
    gpio_configured = []
    regs = []
    for gpio in board_tolerance_gpio_table:
        if not (gpio.gpio).startswith('GPIO'):
            continue
        gpio_val = openbmc_gpio.gpio_name2value(gpio.gpio)
        offset = int(gpio_val / 32)
        phy_addr = board_gpioOffsetDic[str(offset)]
        bit = gpio_val % 32
        # config the devmem and write through to the hw
        reg = soc_get_tolerance_reg(phy_addr)
        reg.set_bit(bit)
        regs.append(reg)

    for reg in regs:
        reg.write()

        # export gpio
    for gpio in board_tolerance_gpio_table:
        openbmc_gpio.gpio_export(gpio.gpio, gpio.shadow)
        def_val = openbmc_gpio.gpio_get(gpio.gpio, change_direction=False)
        if def_val == 1:
            openbmc_gpio.gpio_set(gpio.gpio, 1)
        else:
            openbmc_gpio.gpio_set(gpio.gpio, 0)
コード例 #4
0
def set_func(args):
    openbmc_gpio.gpio_set(args.gpio,
                          args.value,
                          change_direction=False if args.keep else True)
コード例 #5
0
ファイル: openbmc_gpio_util.py プロジェクト: HengWang/openbmc
def set_func(args):
    openbmc_gpio.gpio_set(args.gpio, args.value,
                          change_direction=False if args.keep else True)