• Serge Semin's avatar
    gpio: dwapb: Add ngpios DT-property support · 7569486d
    Serge Semin authored
    Indeed generic GPIO DT-schema implies that number of GPIOs should be
    described by the "ngpios" property located under a GPIO-provider DT node.
    In that case it's redundant to have a vendor-specific "snps,nr-gpios"
    property describing the same setting. Moreover it might be errors prone.
    
    Since commit 93d2e432 ("of: platform: Batch fwnode parsing when adding
    all top level devices") the fwnode parsing is resumed after the vast
    majority of the platform devices are added. Implicitly that commit
    activates re-parsing of the whole device tree GPIOs-phandle properties
    detected having "-gpio/-gpios" suffixes. Since the vendor-specific number
    of GPIOs property is defined with "-gpios" suffix, then of_link_property()
    will consider it as a suffix-property with "#gpio-cells" structure, which
    obviously it doesn't have. As a result for two DW APB GPIO controllers
    we'll have the next errors printed.
    
    OF: /bus@1f059000/gpio@1f044000/gpio-port@0: could not find phandle
    OF: /bus@1f059000/gpio@1f045000/gpio-port@0: could not get #gpio-cells for /opp-table
    OF: /bus@1f059000/gpio@1f044000/gpio-port@0: could not find phandle
    OF: /bus@1f059000/gpio@1f045000/gpio-port@0: could not get #gpio-cells for /opp-table
    
    See, the kernel fwnode parsing procedure even tried to resolve the phandle
    ID, which it thought was the opp-table DT-node, while in fact it was just
    a number "32". What would happen if that magic number actually referred to
    a GPIO DT-node with "#gpio-cells" property defined?..
    
    In order to fix the problem let's mark the "snps,nr-gpios" property as
    deprecated and add the generic "ngpios" property support with the same
    purpose as the deprecated one. That and the errors log above shall
    motivate the platform developer to convert the DW APB GPIO DT-nodes to
    using the standard number of GPIOs property.
    Signed-off-by: default avatarSerge Semin <Sergey.Semin@baikalelectronics.ru>
    Reviewed-by: default avatarAndy Shevchenko <andy.shevchenko@gmail.com>
    Link: https://lore.kernel.org/r/20200730152808.2955-3-Sergey.Semin@baikalelectronics.ruSigned-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
    7569486d
gpio-dwapb.c 20.2 KB