• Richard Fitzgerald's avatar
    ASoC: cs42l42: Correct configuring of switch inversion from ts-inv · 778a0cbe
    Richard Fitzgerald authored
    
    
    The setting from the cirrus,ts-inv property should be applied to the
    TIP_SENSE_INV bit, as this is the one that actually affects the jack
    detect block. The TS_INV bit only swaps the meaning of the PLUG and
    UNPLUG interrupts and should always be 1 for the interrupts to have
    the normal meaning.
    
    Due to some misunderstanding the driver had been implemented to
    configure the TS_INV bit based on the jack switch polarity. This made
    the interrupts behave the correct way around, but left the jack detect
    block, button detect and analogue circuits always interpreting an open
    switch as unplugged.
    
    The signal chain inside the codec is:
    
    SENSE pin -> TIP_SENSE_INV -> TS_INV -> (invert) -> interrupts
                      |
                      v
                 Jack detect,
              button detect and
                analog control
    
    As the TIP_SENSE_INV already performs the necessary inversion the
    TS_INV bit never needs to change. It must always be 1 to yield the
    expected interrupt behaviour.
    
    Some extra confusion has arisen because of the additional invert in the
    interrupt path, meaning that a value applied to the TS_INV bit produces
    the opposite effect of applying it to the TIP_SENSE_INV bit. The ts-inv
    property has therefore always had the opposite effect to what might be
    expected (0 = inverted, 1 = not inverted). To maintain the meaning of
    the ts-inv property it must be inverted when applied to TIP_SENSE_INV.
    Signed-off-by: default avatarRichard Fitzgerald <rf@opensource.cirrus.com>
    Fixes: 2c394ca7 ("ASoC: Add support for CS42L42 codec")
    Link: https://lore.kernel.org/r/20211028140902.11786-3-rf@opensource.cirrus.com
    
    Signed-off-by: default avatarMark Brown <broonie@kernel.org>
    778a0cbe
cs42l42.c 66.4 KB