From patchwork Mon Mar 15 16:56:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 400522 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp3591574jai; Mon, 15 Mar 2021 09:57:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwQ5Vzus/PvF39hwoqCAYlwDDrG5kADHntCuYl5zdSJQGc8qOoOkhSFHyL+mJ7qGtck+fXa X-Received: by 2002:a50:9ea7:: with SMTP id a36mr31459480edf.174.1615827462558; Mon, 15 Mar 2021 09:57:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615827462; cv=none; d=google.com; s=arc-20160816; b=oYrHrzuzoOEyJ9Pv+SmI2AkY/aXQR+vQddjTokuTgVO5LKg+wQj1TncZ0o2T2slKID ZYeJ1Xc/7N7YnxfosHY6g2Gji+urSpHPcVa4GI6DcX1hjOs4WFCjW1iPpNGVsYFLDJpF ljOm2nWm0svnca0+1esLOCJf91qCDrnu+5pFCaqon3HTGbySvZ+jdObIpuMhRnoON7wi CayvDlPis10cfA2HXlXIzQpRA3/35WGnvFXwcd8XACNDv3KF2KDlozxsW1XcrkWEVg30 PGZlztlXvA2iS+qnzXyf0TnmpctBV6muM52szW0gdlfGRIkKOyI0FscuLUbK4n5Qn3a2 YevA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6S4oc3H/pGD3ohc32wC+7IuRuvb/2oR7Yf16M/iJXA4=; b=GIqiwUPBcd9f18Fqwtjxhm8RjNwVgbTOr/DnFKSeNOatQmF/M/dbNHJQWxfW2JzCRf Rw5JA/YoZyncU4SEF/JBrhc+0hMZhtqAaqiqsULEgsBnxzryojG6dgUaHu7SPAwmlMIV ZP9f4GTrDv+bduaJ4Js4QXypZ7giuzN9tJRxdmC1S0pIVUFrCOkSMf9SJOTdA/oBqdz8 bui5uNfAWIwrFocp9py//fonuk7aC2g/mvQyZt82xJnrN3iE+pet7mfBNMI/Uu2BRqUj z0Al5z9pZUf19qUppgvprRLNZkmFDCPk8LEUdltJ7AAz2p8j3ksk41O1wzgtKluhYVli +KiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KRguXn6v; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p8si11752848edm.44.2021.03.15.09.57.42; Mon, 15 Mar 2021 09:57:42 -0700 (PDT) Received-SPF: pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KRguXn6v; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234285AbhCOQ5K (ORCPT + 6 others); Mon, 15 Mar 2021 12:57:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234348AbhCOQ46 (ORCPT ); Mon, 15 Mar 2021 12:56:58 -0400 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3CFC0C06174A for ; Mon, 15 Mar 2021 09:56:58 -0700 (PDT) Received: by mail-wm1-x32f.google.com with SMTP id r10-20020a05600c35cab029010c946c95easo19868752wmq.4 for ; Mon, 15 Mar 2021 09:56:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6S4oc3H/pGD3ohc32wC+7IuRuvb/2oR7Yf16M/iJXA4=; b=KRguXn6v6qWoSKXlekTUoqzfznIkwnBZk388f10HNP0qDrHICvrjYs9zpA07T0bvJ6 89p0lDFhapxhLq1535ZPsd2sRtkAxs27G7nMs/FG6YuNWkgR0+VqnhrfySnK9UgW10RV fzA+ELnQbNMT7oRP2BAxF28RzZvEW9GiV/zfv/HknWeAZIVLX+tFy9nDrtWp+P/xcZ74 ITZhRtK78sLj79myS0GaSIuMBHRpkGNs8c+986iaYdGRrrbx47xaW9AmypyaZj2E5yQH nsXob37tOIjHrOj4r9z4JUg9BuI+1+WG9YAQcehdTgao+qff7BeQ2C1GjGUel2pbzgNb o9vQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6S4oc3H/pGD3ohc32wC+7IuRuvb/2oR7Yf16M/iJXA4=; b=EBK5NzWfZl9XMFebnkj7LgNo48fjyokeJYXGtwaSSrbpr0qWPvWFO5K7bC0CjXie9A jLtxjm6deprk0NcA82eJ1OE7KKbE7v7ClOX+dwRXXnVQJonlfsEQHeO9AHiP+hNQ2C1V +z3Yekz66RWeWoGERzq9/nH8iDBwS0O2yA5zcFCVH+VSO9y8fJme2Tt9PnyUFBQcRCtG uA6FC611leudGQz8GslLFzEidGieqV2GbXU2iOF6Se1qX6sh33huaKAjZwDCBYWCCVz7 TTQO4Ty2ug4daPywMLPXAMpVhFqP1VMqXB+0Ot8WhEBjZ3QkTksI3dBiGtR5GnAMzNO8 Ld0g== X-Gm-Message-State: AOAM532/qE5tXRUhTwOqaAWrWzPHA9mS03ZreRJLA1tb3Zn8CLqntOmv UmxF1arNuvARh5AS0Toj2Mgrn3/mfpfCYw== X-Received: by 2002:a1c:c904:: with SMTP id f4mr647858wmb.14.1615827417008; Mon, 15 Mar 2021 09:56:57 -0700 (PDT) Received: from srini-hackbox.lan (cpc86377-aztw32-2-0-cust226.18-1.cable.virginm.net. [92.233.226.227]) by smtp.gmail.com with ESMTPSA id o2sm227656wmc.23.2021.03.15.09.56.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Mar 2021 09:56:56 -0700 (PDT) From: Srinivas Kandagatla To: broonie@kernel.org, vkoul@kernel.org Cc: robh@kernel.org, devicetree@vger.kernel.org, yung-chuan.liao@linux.intel.com, pierre-louis.bossart@linux.intel.com, sanyog.r.kale@intel.com, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, Srinivas Kandagatla Subject: [PATCH v4 3/5] soundwire: qcom: add static port map support Date: Mon, 15 Mar 2021 16:56:48 +0000 Message-Id: <20210315165650.13392-4-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20210315165650.13392-1-srinivas.kandagatla@linaro.org> References: <20210315165650.13392-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org SoundWire device ports are statically mapped to Controller ports during design. Add support to read these from SoundWire devices. This controller uses static port map info to setup bandwidth parameters for those ports. A generic port allocation is not possible in this cases! Signed-off-by: Srinivas Kandagatla --- drivers/soundwire/qcom.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) -- 2.21.0 diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c index 9e70c53e2c7b..39222b04a2e0 100644 --- a/drivers/soundwire/qcom.c +++ b/drivers/soundwire/qcom.c @@ -460,6 +460,8 @@ static int qcom_swrm_compute_params(struct sdw_bus *bus) struct sdw_slave_runtime *s_rt; struct sdw_port_runtime *p_rt; struct qcom_swrm_port_config *pcfg; + struct sdw_slave *slave; + unsigned int m_port; int i = 0; list_for_each_entry(m_rt, &bus->m_rt_list, bus_node) { @@ -473,8 +475,14 @@ static int qcom_swrm_compute_params(struct sdw_bus *bus) } list_for_each_entry(s_rt, &m_rt->slave_rt_list, m_rt_node) { + slave = s_rt->slave; list_for_each_entry(p_rt, &s_rt->port_list, port_node) { - pcfg = &ctrl->pconfig[i]; + m_port = slave->m_port_map[p_rt->num]; + /* port config starts at offset 0 so -1 from actual port number */ + if (m_port) + pcfg = &ctrl->pconfig[m_port - 1]; + else + pcfg = &ctrl->pconfig[i]; p_rt->transport_params.port_num = p_rt->num; p_rt->transport_params.sample_interval = pcfg->si + 1; @@ -535,8 +543,10 @@ static int qcom_swrm_stream_alloc_ports(struct qcom_swrm_ctrl *ctrl, struct sdw_master_runtime *m_rt; struct sdw_slave_runtime *s_rt; struct sdw_port_runtime *p_rt; + struct sdw_slave *slave; unsigned long *port_mask; int i, maxport, pn, nports = 0, ret = 0; + unsigned int m_port; mutex_lock(&ctrl->port_lock); list_for_each_entry(m_rt, &stream->master_list, stream_node) { @@ -549,9 +559,15 @@ static int qcom_swrm_stream_alloc_ports(struct qcom_swrm_ctrl *ctrl, } list_for_each_entry(s_rt, &m_rt->slave_rt_list, m_rt_node) { + slave = s_rt->slave; list_for_each_entry(p_rt, &s_rt->port_list, port_node) { + m_port = slave->m_port_map[p_rt->num]; /* Port numbers start from 1 - 14*/ - pn = find_first_zero_bit(port_mask, maxport); + if (m_port) + pn = m_port; + else + pn = find_first_zero_bit(port_mask, maxport); + if (pn > maxport) { dev_err(ctrl->dev, "All ports busy\n"); ret = -EBUSY;