• Geert Uytterhoeven's avatar
    spi: Add generic support for unused native cs with cs-gpios · 7d93aecd
    Geert Uytterhoeven authored
    Some SPI master controllers always drive a native chip select when
    performing a transfer.  Hence when using both native and GPIO chip
    selects, at least one native chip select must be left unused, to be
    driven when performing transfers with slave devices using GPIO chip
    selects.
    
    Currently, to find an unused native chip select, SPI controller drivers
    need to parse and process cs-gpios theirselves.  This is not only
    duplicated in each driver that needs it, but also duplicates part of the
    work done later at SPI controller registration time.  Note that this
    cannot be done after spi_register_controller() returns, as at that time,
    slave devices may have been probed already.
    
    Hence add generic support to the SPI subsystem for finding an unused
    native chip select.  Optionally, this unused native chip select, and all
    other in-use native chip selects, can be validated against the maximum
    number of native chip selects available on the controller hardware.
    Signed-off-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
    Link: https://lore.kernel.org/r/20200102133822.29346-2-geert+renesas@glider.beSigned-off-by: default avatarMark Brown <broonie@kernel.org>
    7d93aecd
spi.h 55.7 KB