From patchwork Tue Mar 9 14:15:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 395989 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp2621078jai; Tue, 9 Mar 2021 06:16:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJwzCqknlHX2i1RC8ZxAMOlY8lcBtk/OHZoWY8fgHSML0ImK5y+99vuEh+RaNx0kIIEQvCDx X-Received: by 2002:a17:906:b80c:: with SMTP id dv12mr20763125ejb.110.1615299393874; Tue, 09 Mar 2021 06:16:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615299393; cv=none; d=google.com; s=arc-20160816; b=DmimlPKn9cTwHslRC6opUggvNsadvPRYTGBLnuwi2JmuO1OgP8Sj3qXJDwVd56fr1B E7g94sI0t8iZ2Vgw4fBdUepgpVKsS18KaF3Qyj0ni3ahVKbQdXW4kMuVU0187+TS2jCd kzbbzC1Mz8adhdQxmI/eNOhhLifRru+h4Let1fwOXGNOcaVerHCF6m8Jos0w3S3vHfWE WZjcH0daBm2HHIbaaqF5pyttscl5WwvVQXcaZd2dCMNXmvaYVz6Ar31TUQveho4kpM3F AGS+6dzbyCD8nNNJlrI7DABoxmju6xabfpwj6Jlt/4EjMPgVsBVYugCk4DUWIchOCj5N e7tA== 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=Ol6OkkC2nUnq8Y6A1v6xDdX14ho/H0K1X/8pX5FNFEo=; b=0u+VAVYYgj87yK70yBIdvhFEEPI+4ljW+KWV5qLKuO6dKwLQdKojxFmQFGLETFCjOi MLIvpJ0FIBClK+ivJaArEPPxS4iTY0NGmhPsJ6XH/KxWrb9qQE29f/E1ife5yiEImvY+ DYd2kOL7CPQoPur8KhRayPEl3UB1q5ObKDsokxr32un1T7fVn6N6AZEPT1vItGk3yzFr yEGZXMLCxSC7PxeNX/5LaO3lW36lFZKIBHYxG8USX1RTEaJXQVI4PpgAdDUEKtKyvj3M o8lbBMIs0cGV0+hcWNzAXLw+U6goDQkfDo1RgNsk6KvcQAB8uYH5BNtIP4joO2WM+CQU 5HGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VS6jbPEB; 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 h26si9227740edq.453.2021.03.09.06.16.33; Tue, 09 Mar 2021 06:16:33 -0800 (PST) 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=VS6jbPEB; 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 S230403AbhCIOQB (ORCPT + 6 others); Tue, 9 Mar 2021 09:16:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230490AbhCIOPh (ORCPT ); Tue, 9 Mar 2021 09:15:37 -0500 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BCBAEC06175F for ; Tue, 9 Mar 2021 06:15:36 -0800 (PST) Received: by mail-wr1-x436.google.com with SMTP id d15so15907009wrv.5 for ; Tue, 09 Mar 2021 06:15:36 -0800 (PST) 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=Ol6OkkC2nUnq8Y6A1v6xDdX14ho/H0K1X/8pX5FNFEo=; b=VS6jbPEBrW4C2FdnvkFOBPnTbV0uD/pIpsf1p+n3Eh2OqdKgSICyT5VXU2/IdSZ54f rYdTXRYRRhuhJW1X9+bIjk5EWynJCtJuAPkTRePPYK3v8FhgGgy4BKP1cCn3H05ioo2p 1Xj/fZ17Br0/nUqpmPVkF0aSGAuGGKFc2WURtEbIaX+4yUH4hTBU5hYI0RC/KswRDXtP MsOPTqai2Vs4P/+xxasDuCQ7I2OZMSLjbaSQgzWqAczd/0nthktjo1z7mnwBqSceG7E1 hWLAz4kdK8sieuhZtotcsL0XWJHXHUvofCpP4qNHXJQwqinUFddQ3oe5c/mF2kdYusSu or2A== 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=Ol6OkkC2nUnq8Y6A1v6xDdX14ho/H0K1X/8pX5FNFEo=; b=gGG8hjvQVGYX3kWPsiRi09GrCkuWlks/6vOb7dTWvbubKsx4a2jKFjzCSl99SQg/jo a4DFbMupzR6AualqovsxulEkcJnHtLEiA/WHrjWLStnCjH7U8tYHWmw2S781eDj0AmuH rM98elvy+nyyp+zMJgOzAiZ+CjCtw9YaKGUdZWTd/ZwYO9qyr5EAh0557bW/e6SLeAyX oWGZka1K/m+4mQCQUN2Y+6HGxXiDMhe2DCUk3IX3gFjGPdSriWtpKzSWwIwI/vx+uMYj 3seb0RHuSU4H3K9Cz38ek8DmQmlx282CJI9KbO85uZJjpoaSJoqCNMORZAMAW0PyOOH8 1g0w== X-Gm-Message-State: AOAM533p9Oy/qTa3UOaQBA++rf3ZEZkYHNwvdr2GN8GjBayu+6hJl8Uf HAcBvVGkayX9EL0EAcZuvo3zKw== X-Received: by 2002:adf:f292:: with SMTP id k18mr28854329wro.335.1615299335594; Tue, 09 Mar 2021 06:15:35 -0800 (PST) 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 u20sm28007579wru.6.2021.03.09.06.15.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Mar 2021 06:15:35 -0800 (PST) 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 v2 3/5] soundwire: qcom: add static port map support Date: Tue, 9 Mar 2021 14:15:12 +0000 Message-Id: <20210309141514.24744-4-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20210309141514.24744-1-srinivas.kandagatla@linaro.org> References: <20210309141514.24744-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 | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) -- 2.21.0 diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c index f4f1c5f2af0b..b4d1aaf535c5 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,13 @@ 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 - 1]; + 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 +542,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 +558,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 - 1]; /* 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;