lkml.org 
[lkml]   [2023]   [Apr]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 3/6] ASoC: codecs: wcd938x: Check for enumeration before using TX device
    Date
    Qualcomm WCD938x Soundwire codecs come as two Soundwire devices - TX
    and RX - on two Soundwire buses. In DTS they are represented as three
    device nodes: Soundwire TX, Soundwire RX and the platform codec node
    (binding to this driver).

    Probing (and Soundwire enumeration) of all devices can happen in any
    order, but only the Soundwire TX WCD938x device is used for accessing
    actual WCD938x registers. It is possible that component bind() in the
    platform driver will be called too early, before the Soundwire TX device
    is fully enumerated. This might work or might not, but we cannot handle
    it correctly from the codec driver. It's job for Soundwire master to
    bring up devices in correct order. At least add some simple warning, so
    such condition will not be undetected.

    Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

    ---

    Cc: Patrick Lai <quic_plai@quicinc.com>
    ---
    sound/soc/codecs/wcd938x.c | 11 +++++++++++
    1 file changed, 11 insertions(+)

    diff --git a/sound/soc/codecs/wcd938x.c b/sound/soc/codecs/wcd938x.c
    index 212667a7249c..e8e07e120fa1 100644
    --- a/sound/soc/codecs/wcd938x.c
    +++ b/sound/soc/codecs/wcd938x.c
    @@ -77,6 +77,8 @@
    #define WCD938X_MBHC_MOISTURE_RREF R_24_KOHM
    #define WCD_MBHC_HS_V_MAX 1600

    +#define WCD938X_ENUM_TIMEOUT_MS 500
    +
    #define WCD938X_EAR_PA_GAIN_TLV(xname, reg, shift, max, invert, tlv_array) \
    { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
    .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
    @@ -4425,6 +4427,15 @@ static int wcd938x_bind(struct device *dev)
    wcd938x->sdw_priv[AIF1_PB]->slave_irq = wcd938x->virq;
    wcd938x->sdw_priv[AIF1_CAP]->slave_irq = wcd938x->virq;

    + /*
    + * Before any TX slave regmap usage, be sure the TX slave is actually
    + * enumerated.
    + */
    + ret = wait_for_completion_timeout(&wcd938x->tx_sdw_dev->enumeration_complete,
    + msecs_to_jiffies(WCD938X_ENUM_TIMEOUT_MS));
    + if (!ret)
    + dev_warn(dev, "Enumeration timeout in bind, possible failures in accessing registers\n");
    +
    ret = wcd938x_set_micbias_data(wcd938x);
    if (ret < 0) {
    dev_err(dev, "%s: bad micbias pdata\n", __func__);
    --
    2.34.1
    \
     
     \ /
      Last update: 2023-04-20 12:18    [W:5.924 / U:0.012 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site