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)
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 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 offset = openbmc_gpio.gpio_name_to_offset(gpio.gpio) group_index = int(offset / 32) phy_addr = board_gpioOffsetDic[str(group_index)] bit = offset % 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_value(gpio.gpio, change_direction=False) if def_val == 1: openbmc_gpio.gpio_set_value(gpio.gpio, 1) else: openbmc_gpio.gpio_set_value(gpio.gpio, 0)
def export_func(args): openbmc_gpio.gpio_export(args.gpio, args.shadow)