• Andrew Jeffery's avatar
    pinctrl: aspeed: Add multiple pin group support for functions · e7a96b0b
    Andrew Jeffery authored
    The AST2400 and AST2500 SoCs only exposed one pin group per function.
    Lone pin groups drove some implementation simplifications in the ASPEED
    pinmux infrastructure that is now invalid for the AST2600, which
    supports multiple groups per function for some functions on the chip
    (SMBus Alert pins and UARTs among others).
    
    This patch reworks the macro jungle to enable support for multiple pin
    groups. In the process we inflict some collateral damage on the existing
    AST2400 and AST2500 drivers, but the rework is mostly a relatively
    straight-forward, automated transform of adding the pin name as an
    argument to some macro calls and implementing wrappers to paper over
    groups in the cases where there aren't multiple.
    
    As previously documented, the macro infrastructure exposes mux
    configuration as symbols in the source file which are used to detect
    accidental duplication. Previously these symbols were named in terms of
    the signal for a given expression. As the AST2600 supports multiple pin
    groups for a function, the signal name on its own is no-longer unique,
    and we must switch to the (signal, group) tuple. However, this means
    that we can no-longer derive the signal expression symbol name from the
    signal name alone, which among other cases, impacts the operation of the
    PIN_DECL_x() macros.
    
    To fix that and avoid requiring we awkwardly provide the associated
    group name for every signal for every PIN_DECL_x() invocation, instead
    opportunistically alias the name of the signal expression symbol from
    the unique (signal, group) tuple to the also unique (pin, signal) tuple,
    then reference the alias symbol in the tables generated by PIN_DECL_x().
    This way we do not require extra group parameters for PIN_DECL_x() as
    the pin name was already provided as an argument, and instead simply
    require that the pin name be provided to the expression declaration
    macros in order to generate the alias symbol.
    
    The patch implements the alias strategy and fixes up all the expression
    definition macro calls in the AST2400 and AST2500 drivers to account for
    pin groups. Given the implementation strategy has the property that
    compilation either fails or loudly warns for bad pin descriptions, this
    patch is theoretically tested by successfully compiling both affected
    drivers. For a more practical test I've inspected the diff of the
    content of the pinctrl debugfs entries before and after the patch under
    qemu; all pins, functions and groups match.
    Signed-off-by: default avatarAndrew Jeffery <andrew@aj.id.au>
    Link: https://lore.kernel.org/r/20190729055604.13239-5-andrew@aj.id.auSigned-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
    e7a96b0b
pinctrl-aspeed-g5.c 97.8 KB