From patchwork Fri Mar 12 12:00:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 398594 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp1132881jai; Fri, 12 Mar 2021 04:01:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJyk45NXeumOnsyYYB0Y3pxmgjohaDQzsc894D8aI0LgX/4kM2wLLWNNSj+QKmaRCnzeopFB X-Received: by 2002:a17:906:144d:: with SMTP id q13mr6263639ejc.458.1615550478062; Fri, 12 Mar 2021 04:01:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615550478; cv=none; d=google.com; s=arc-20160816; b=lHkDRtAwXa8jD4LaBJiORGWevPxdlOa/zSvyVGFmIB5Uw3IK8c7v2P23aEzkr8ADtm Kx55wWY8fpv0+WImOqQDrNBqLvUOH8oJn7+QXzFarqSCYQYAbzKxsTQw+igEhJA1rrUZ eYHOXJ8UDZssRh09vYuQV6IXRCddcbXW9WF1u1pg74qyIavY68JHOWZ7KXOyoHyhKMVB ugHKKosKtwdh6Rz0THz7T5Crwf5uCRHBgFt0tDETHoYEXxj2TawVvwroxEo+FdPpIsJb UzRcXjZs8BlPXkR0S7EMwKXviCDs9t1CFXMSkrg0s18A6G5oIJi1jPJYZWMCdKBFAM39 lvDg== 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=j1DVrtDjiNfpMvwpqyQlbpz2bqVmuofXtsZIJDWEwa0=; b=ZjSMYI7RIhxlXccMTXAdioPBx9ZetZ/8jBAwRi2Ox4HvWS8BhjqFeHIOOk8jxuJGNh PG3iUUHkPtsrAkFnkb6kYeKpYBsMCmUABgIi4C7SxM4Z7WGZof4W5CWEbr0w/16jfgQ6 v+x19TERLx3KjDkCaEmNoBLhqzJApEvqE3E+30emuPvHV0Phc3YR2x2/j/iKRihst8cD QHoh7aJQ49S29SqDSZZsEerBZf7+A7uWSseI++ORilaRwmI4FMFO/AQ3fwqV8M3ox2nf CGGyK0ZQRV8GireThC/n75kaaSht7O8T6Acm6L7h0/A4dZTUcDyISD5perQdo6V98n8A q7Ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SsCoXK0S; 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 n20si3843636ejx.104.2021.03.12.04.01.17; Fri, 12 Mar 2021 04:01:18 -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=SsCoXK0S; 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 S231277AbhCLMAr (ORCPT + 6 others); Fri, 12 Mar 2021 07:00:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231344AbhCLMA0 (ORCPT ); Fri, 12 Mar 2021 07:00:26 -0500 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE3CBC061763 for ; Fri, 12 Mar 2021 04:00:25 -0800 (PST) Received: by mail-wr1-x430.google.com with SMTP id b18so4654741wrn.6 for ; Fri, 12 Mar 2021 04:00:25 -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=j1DVrtDjiNfpMvwpqyQlbpz2bqVmuofXtsZIJDWEwa0=; b=SsCoXK0SqP0VUwLVdEmtmSTcvDgX8/74fLxQMnWyD7ZTwKchBMev4r9vaO08c0mVVp gYoHGT0OA/Vu0WXUMuBU5+W0uAGX4Xq/L/Tj/AmPJhVAJzgEHvD8d5ddokosquklWarE xUfpA/R+p0fY3DkdSn7g4PhM6EA220jfY5T7lpng1KZI7kRUpchcDjZ9LWhZTN9XhRoP HkCNgyevql9QEg3yaurq/S76tdyqGd2KrxR/pUFJqEIJlk5hPj+2iWvTg8JzWGz3EKmK KHbeT5q+mvuXjKKSTwGqHPUtAOot0c9X2Ai8YWYJPo3UVd7wNwlOCM2jbZSxoxYSUHN+ TvVA== 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=j1DVrtDjiNfpMvwpqyQlbpz2bqVmuofXtsZIJDWEwa0=; b=o1Zxz78GKXmm+HiNh787ITycmZY354Dntns9YfdL9lsxGkXWcpxyEmvmJED+XqSpkz mNm7lTdesmnKlS9pHnfqDUvhEsHCJwCRhKYzESzMEIEaQueyHsv+9NCAZhDM+Ot7RSTH EdbE6ZQ/qzNz8Y7OczM38DP74cLs6BvfMmYde9XQXK7lIAMI9tEbPdlPxByz+sy4NkeK BZ/QYzcgJxI+ACJKjcoKknc9n8dmyupMJLnOGDR3sqsiM3n894NHU0d1ZpL8IKGi8ZxZ 8k9buMd1zXMdaanecQWFW9kWdKMMQUFTWKQNPFPyRpSFpX3tZbZdrXcGfBcAKzRI8pO2 avdQ== X-Gm-Message-State: AOAM530KUDX8NArNCvmrndSoEfA3jkyc3khxnWv8BHdyzmi4nxZf/PSb L95Hj5SdAa4yeNU4NvJHNBh12Q== X-Received: by 2002:adf:f4ce:: with SMTP id h14mr13589603wrp.257.1615550424486; Fri, 12 Mar 2021 04:00:24 -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 h25sm2268315wml.32.2021.03.12.04.00.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Mar 2021 04:00:23 -0800 (PST) From: Srinivas Kandagatla To: vkoul@kernel.org Cc: yung-chuan.liao@linux.intel.com, pierre-louis.bossart@linux.intel.com, sanyog.r.kale@intel.com, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, robh@kernel.org, devicetree@vger.kernel.org, Srinivas Kandagatla Subject: [PATCH v4 1/9] dt-bindings: soundwire: qcom: clarify data port bus parameters Date: Fri, 12 Mar 2021 12:00:01 +0000 Message-Id: <20210312120009.22386-2-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20210312120009.22386-1-srinivas.kandagatla@linaro.org> References: <20210312120009.22386-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Some of the parameters for data ports are not applicable or not implemented in IP. So mark them as invalid/not applicable in DT so that controller is aware of this. Add comment to these bindings to provide more clarity on the values! Signed-off-by: Srinivas Kandagatla --- .../bindings/soundwire/qcom,sdw.txt | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) -- 2.21.0 Acked-by: Rob Herring diff --git a/Documentation/devicetree/bindings/soundwire/qcom,sdw.txt b/Documentation/devicetree/bindings/soundwire/qcom,sdw.txt index b104be131235..b93a2b3e029d 100644 --- a/Documentation/devicetree/bindings/soundwire/qcom,sdw.txt +++ b/Documentation/devicetree/bindings/soundwire/qcom,sdw.txt @@ -54,6 +54,8 @@ board specific bus parameters. Value type: Definition: should specify payload transport window offset1 of each data port. Out ports followed by In ports. + Value of 0xFF indicates that this option is not implemented + or applicable for the respective data port. More info in MIPI Alliance SoundWire 1.0 Specifications. - qcom,ports-offset2: @@ -61,6 +63,8 @@ board specific bus parameters. Value type: Definition: should specify payload transport window offset2 of each data port. Out ports followed by In ports. + Value of 0xFF indicates that this option is not implemented + or applicable for the respective data port. More info in MIPI Alliance SoundWire 1.0 Specifications. - qcom,ports-sinterval-low: @@ -69,12 +73,16 @@ board specific bus parameters. Definition: should be sample interval low of each data port. Out ports followed by In ports. Used for Sample Interval calculation. + Value of 0xFF indicates that this option is not implemented + or applicable for the respective data port. More info in MIPI Alliance SoundWire 1.0 Specifications. - qcom,ports-word-length: Usage: optional Value type: Definition: should be size of payload channel sample. + Value of 0xFF indicates that this option is not implemented + or applicable for the respective data port. More info in MIPI Alliance SoundWire 1.0 Specifications. - qcom,ports-block-pack-mode: @@ -84,6 +92,8 @@ board specific bus parameters. 0 to indicate Blocks are per Channel 1 to indicate Blocks are per Port. Out ports followed by In ports. + Value of 0xFF indicates that this option is not implemented + or applicable for the respective data port. More info in MIPI Alliance SoundWire 1.0 Specifications. - qcom,ports-block-group-count: @@ -92,6 +102,8 @@ board specific bus parameters. Definition: should be in range 1 to 4 to indicate how many sample intervals are combined into a payload. Out ports followed by In ports. + Value of 0xFF indicates that this option is not implemented + or applicable for the respective data port. More info in MIPI Alliance SoundWire 1.0 Specifications. - qcom,ports-lane-control: @@ -100,6 +112,8 @@ board specific bus parameters. Definition: should be in range 0 to 7 to identify which data lane the data port uses. Out ports followed by In ports. + Value of 0xFF indicates that this option is not implemented + or applicable for the respective data port. More info in MIPI Alliance SoundWire 1.0 Specifications. - qcom,ports-hstart: @@ -109,6 +123,8 @@ board specific bus parameters. SoundWire Frame, i.e. left edge of the Transport sub-frame for each port. Values between 0 and 15 are valid. Out ports followed by In ports. + Value of 0xFF indicates that this option is not implemented + or applicable for the respective data port. More info in MIPI Alliance SoundWire 1.0 Specifications. - qcom,ports-hstop: @@ -118,6 +134,8 @@ board specific bus parameters. SoundWire Frame, i.e. the right edge of the Transport sub-frame for each port. Values between 0 and 15 are valid. Out ports followed by In ports. + Value of 0xFF indicates that this option is not implemented + or applicable for the respective data port. More info in MIPI Alliance SoundWire 1.0 Specifications. - qcom,dports-type: @@ -128,6 +146,8 @@ board specific bus parameters. 1 for simple ports 2 for full port Out ports followed by In ports. + Value of 0xFF indicates that this option is not implemented + or applicable for the respective data port. More info in MIPI Alliance SoundWire 1.0 Specifications. Note: From patchwork Fri Mar 12 12:00:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 398593 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp1132875jai; Fri, 12 Mar 2021 04:01:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJxqCOz+nw2Vy0s7AvTGJ0VjzafJfyUX+kmIbeanlSUGHkdlm7tAFttSQgfEOMGDaBh+7yB8 X-Received: by 2002:a17:906:add7:: with SMTP id lb23mr7993598ejb.273.1615550477641; Fri, 12 Mar 2021 04:01:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615550477; cv=none; d=google.com; s=arc-20160816; b=ffeNPLntAKQjjg/t6Ubl9qNUIsUuSOJypCDoZkxLiu9PQrrpHpez2sxFRO5YTzhfdH R3LyPR8JAp6swugiHe/FbcdlYUvDFXQJJ0Q4Pe2pt9iRaByROj8Cx2KR7kucgZ6VGIgP W7mT6L5aur43fnpi68Y/5oeBDYyqdCn8/fA9OTuuSZf1zdNDMSLo8yExoYeR2GRpGZKa ApFyNRqQx3zZgYvJe9UK3KA9+KaTnYJzw2N5pDL6E3+1AbQ5r79g7LJE9QaP2Ktx11hY Hxthwzy8m4aEetbxxElrPXLa5wOKZZhHep4s4tDQDHH0nJeqrk/lVyiVVgKmTuT5MUfy WcLA== 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=vjCwhXkTcjDJX30N7p1sgiT7lCukaqPSq772C/Arz7w=; b=fNSi6UDOPP/fU6OSFjV32IJ3Dh59EiSyu35rRKfYseN517ZPj8aQxXyYNwpcvfk/9e OG0ymmiamW+EsYp7wQHwh7nrPRmtCz/ltW0Lb56oYqnyztxUOFLF8ws+RVRBo5LdNW4b VNovgcxGGRW0Png5fnwkn1YZZ/dd7T2ka9u4D8G6l2YPak+uEQz3Gnp57xhoFnO/gKeU UkjtkO99a9DfAK9ojMYJQGjRXTmiJh82cFeAeQaNIosJ+2GHjPv4y9lEm1DlY2DW8zOj SSIMhWie+8uHNjEFz1sCSv8gHF7mhu8K1ucNApM0wZrhHOiHGmy0ohsuCrUb1rwVePao RY4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tOL5bRGO; 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 n20si3843636ejx.104.2021.03.12.04.01.17; Fri, 12 Mar 2021 04:01:17 -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=tOL5bRGO; 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 S231449AbhCLMAp (ORCPT + 6 others); Fri, 12 Mar 2021 07:00:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231379AbhCLMA1 (ORCPT ); Fri, 12 Mar 2021 07:00:27 -0500 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1FFAC061764 for ; Fri, 12 Mar 2021 04:00:26 -0800 (PST) Received: by mail-wm1-x334.google.com with SMTP id c76-20020a1c9a4f0000b029010c94499aedso15639289wme.0 for ; Fri, 12 Mar 2021 04:00:26 -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=vjCwhXkTcjDJX30N7p1sgiT7lCukaqPSq772C/Arz7w=; b=tOL5bRGOjDR3RW055SKScByHKqecPbtN1WvXYv7uCLab4WHK3ICbBOX/j2FV0Etisw pGg4hr9f8bN2GQUqAd9dnIvbYlhr87O0ODQ2sE+fULGlbtDImHvUiL2QL/HTM54k0nTm IoOOq1Pb0PTgontlaiUICUx2Wt9Y7c/iOXbRQY/DXy3JJCTU1uhPg7qTqubhCJEMe4PY FrjzLmSva/g7h9d4mTRXemdN7jehqTWUOhQ10JKxujKCA6hLaVdS+7A6RDgiYk2nZyZ5 iQ/tE/H2sAPFlZTD0O7RVUkkRVPPVsZ34l6whBhEvQen1211bCsgV0pvVkXhRIZtoBGX sAkg== 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=vjCwhXkTcjDJX30N7p1sgiT7lCukaqPSq772C/Arz7w=; b=cnPlBLooZHd7wDNWUFzTHdUBnvpxzj0ha27gHOyzX1Y4wXEyn1D+tYTjriEvbt78ca ti2taF2jDFN6PNfDdsGg/vj9APEmhjTf6EKqf+fP+gaPch3Ea7ykFG1EZ+S91hXHTu2H VX+9nKFH8HOW768gAT9K1yGNgRJ1/hZ+9WNNISTwpYcWyk98pt4w+twPHOQMUfeUyN2k UysX32yFipmZBIdMifmJQPWLBCojyzxe9WkYqEOn4CKpIB1w7mpWz0xBN2IZLA76cvLn rxbct8406Ae3E1h4Vy+Gt4WTRNPflSbrbvU8Q55DQg+Uxy+oAETSTezvlRvYq8FhuZ6/ usvw== X-Gm-Message-State: AOAM531FH7qibeGy8WEpnvqk92AZ4sLktkoZslRNODAaj1jMl3pu3FZR GB8rhi8B8QLFvEtHC0uLB6G9hg== X-Received: by 2002:a1c:bc06:: with SMTP id m6mr12544945wmf.18.1615550425477; Fri, 12 Mar 2021 04:00:25 -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 h25sm2268315wml.32.2021.03.12.04.00.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Mar 2021 04:00:25 -0800 (PST) From: Srinivas Kandagatla To: vkoul@kernel.org Cc: yung-chuan.liao@linux.intel.com, pierre-louis.bossart@linux.intel.com, sanyog.r.kale@intel.com, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, robh@kernel.org, devicetree@vger.kernel.org, Srinivas Kandagatla Subject: [PATCH v4 2/9] soundwire: qcom: add support to missing transport params Date: Fri, 12 Mar 2021 12:00:02 +0000 Message-Id: <20210312120009.22386-3-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20210312120009.22386-1-srinivas.kandagatla@linaro.org> References: <20210312120009.22386-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Some of the transport parameters derived from device tree are not fully parsed by the driver. This patch adds support to parse those missing parameters. Signed-off-by: Srinivas Kandagatla --- drivers/soundwire/qcom.c | 107 ++++++++++++++++++++++++++++++++++----- 1 file changed, 95 insertions(+), 12 deletions(-) -- 2.21.0 diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c index 39222b04a2e0..d05e41f68658 100644 --- a/drivers/soundwire/qcom.c +++ b/drivers/soundwire/qcom.c @@ -54,7 +54,13 @@ #define SWRM_MCP_SLV_STATUS 0x1090 #define SWRM_MCP_SLV_STATUS_MASK GENMASK(1, 0) #define SWRM_DP_PORT_CTRL_BANK(n, m) (0x1124 + 0x100 * (n - 1) + 0x40 * m) +#define SWRM_DP_PORT_CTRL_2_BANK(n, m) (0x1128 + 0x100 * (n - 1) + 0x40 * m) +#define SWRM_DP_BLOCK_CTRL_1(n) (0x112C + 0x100 * (n - 1)) +#define SWRM_DP_BLOCK_CTRL2_BANK(n, m) (0x1130 + 0x100 * (n - 1) + 0x40 * m) +#define SWRM_DP_PORT_HCTRL_BANK(n, m) (0x1134 + 0x100 * (n - 1) + 0x40 * m) #define SWRM_DP_BLOCK_CTRL3_BANK(n, m) (0x1138 + 0x100 * (n - 1) + 0x40 * m) +#define SWRM_DIN_DPn_PCM_PORT_CTRL(n) (0x1054 + 0x100 * (n - 1)) + #define SWRM_DP_PORT_CTRL_EN_CHAN_SHFT 0x18 #define SWRM_DP_PORT_CTRL_OFFSET2_SHFT 0x10 #define SWRM_DP_PORT_CTRL_OFFSET1_SHFT 0x08 @@ -73,12 +79,20 @@ #define QCOM_SDW_MAX_PORTS 14 #define DEFAULT_CLK_FREQ 9600000 #define SWRM_MAX_DAIS 0xF +#define SWR_INVALID_PARAM 0xFF +#define SWR_HSTOP_MAX_VAL 0xF +#define SWR_HSTART_MIN_VAL 0x0 struct qcom_swrm_port_config { u8 si; u8 off1; u8 off2; u8 bp_mode; + u8 hstart; + u8 hstop; + u8 word_length; + u8 blk_group_count; + u8 lane_control; }; struct qcom_swrm_ctrl { @@ -396,8 +410,11 @@ static int qcom_swrm_port_params(struct sdw_bus *bus, struct sdw_port_params *p_params, unsigned int bank) { - /* TBD */ - return 0; + struct qcom_swrm_ctrl *ctrl = to_qcom_sdw(bus); + + return ctrl->reg_write(ctrl, SWRM_DP_BLOCK_CTRL_1(p_params->num), + p_params->bps - 1); + } static int qcom_swrm_transport_params(struct sdw_bus *bus, @@ -405,20 +422,45 @@ static int qcom_swrm_transport_params(struct sdw_bus *bus, enum sdw_reg_bank bank) { struct qcom_swrm_ctrl *ctrl = to_qcom_sdw(bus); + struct qcom_swrm_port_config *pcfg; u32 value; int reg = SWRM_DP_PORT_CTRL_BANK((params->port_num), bank); int ret; - value = params->offset1 << SWRM_DP_PORT_CTRL_OFFSET1_SHFT; - value |= params->offset2 << SWRM_DP_PORT_CTRL_OFFSET2_SHFT; - value |= params->sample_interval - 1; + pcfg = &ctrl->pconfig[params->port_num - 1]; + + value = pcfg->off1 << SWRM_DP_PORT_CTRL_OFFSET1_SHFT; + value |= pcfg->off2 << SWRM_DP_PORT_CTRL_OFFSET2_SHFT; + value |= pcfg->si; ret = ctrl->reg_write(ctrl, reg, value); - if (!ret && params->blk_pkg_mode) { - reg = SWRM_DP_BLOCK_CTRL3_BANK(params->port_num, bank); + if (pcfg->lane_control != SWR_INVALID_PARAM) { + reg = SWRM_DP_PORT_CTRL_2_BANK(params->port_num, bank); + value = pcfg->lane_control; + ret = ctrl->reg_write(ctrl, reg, value); + } + + if (pcfg->blk_group_count != SWR_INVALID_PARAM) { + reg = SWRM_DP_BLOCK_CTRL2_BANK(params->port_num, bank); + value = pcfg->blk_group_count; + ret = ctrl->reg_write(ctrl, reg, value); + } + + if (pcfg->hstart != SWR_INVALID_PARAM + && pcfg->hstop != SWR_INVALID_PARAM) { + reg = SWRM_DP_PORT_HCTRL_BANK(params->port_num, bank); + value = (pcfg->hstop << 4) | pcfg->hstart; + ret = ctrl->reg_write(ctrl, reg, value); + } else { + reg = SWRM_DP_PORT_HCTRL_BANK(params->port_num, bank); + value = (SWR_HSTOP_MAX_VAL << 4) | SWR_HSTART_MIN_VAL; + ret = ctrl->reg_write(ctrl, reg, value); + } - ret = ctrl->reg_write(ctrl, reg, 1); + if (pcfg->bp_mode != SWR_INVALID_PARAM) { + reg = SWRM_DP_BLOCK_CTRL3_BANK(params->port_num, bank); + ret = ctrl->reg_write(ctrl, reg, pcfg->bp_mode); } return ret; @@ -468,10 +510,13 @@ static int qcom_swrm_compute_params(struct sdw_bus *bus) list_for_each_entry(p_rt, &m_rt->port_list, port_node) { pcfg = &ctrl->pconfig[p_rt->num - 1]; p_rt->transport_params.port_num = p_rt->num; - p_rt->transport_params.sample_interval = pcfg->si + 1; - p_rt->transport_params.offset1 = pcfg->off1; - p_rt->transport_params.offset2 = pcfg->off2; - p_rt->transport_params.blk_pkg_mode = pcfg->bp_mode; + if (pcfg->word_length != SWR_INVALID_PARAM) { + sdw_fill_port_params(&p_rt->port_params, + p_rt->num, pcfg->word_length + 1, + SDW_PORT_FLOW_MODE_ISOCH, + SDW_PORT_DATA_MODE_NORMAL); + } + } list_for_each_entry(s_rt, &m_rt->slave_rt_list, m_rt_node) { @@ -489,6 +534,18 @@ static int qcom_swrm_compute_params(struct sdw_bus *bus) p_rt->transport_params.offset1 = pcfg->off1; p_rt->transport_params.offset2 = pcfg->off2; p_rt->transport_params.blk_pkg_mode = pcfg->bp_mode; + p_rt->transport_params.blk_grp_ctrl = pcfg->blk_group_count; + + p_rt->transport_params.hstart = pcfg->hstart; + p_rt->transport_params.hstop = pcfg->hstop; + p_rt->transport_params.lane_ctrl = pcfg->lane_control; + if (pcfg->word_length != SWR_INVALID_PARAM) { + sdw_fill_port_params(&p_rt->port_params, + p_rt->num, + pcfg->word_length + 1, + SDW_PORT_FLOW_MODE_ISOCH, + SDW_PORT_DATA_MODE_NORMAL); + } i++; } } @@ -744,6 +801,11 @@ static int qcom_swrm_get_port_config(struct qcom_swrm_ctrl *ctrl) u8 off2[QCOM_SDW_MAX_PORTS]; u8 si[QCOM_SDW_MAX_PORTS]; u8 bp_mode[QCOM_SDW_MAX_PORTS] = { 0, }; + u8 hstart[QCOM_SDW_MAX_PORTS]; + u8 hstop[QCOM_SDW_MAX_PORTS]; + u8 word_length[QCOM_SDW_MAX_PORTS]; + u8 blk_group_count[QCOM_SDW_MAX_PORTS]; + u8 lane_control[QCOM_SDW_MAX_PORTS]; int i, ret, nports, val; ctrl->reg_read(ctrl, SWRM_COMP_PARAMS, &val); @@ -791,11 +853,32 @@ static int qcom_swrm_get_port_config(struct qcom_swrm_ctrl *ctrl) ret = of_property_read_u8_array(np, "qcom,ports-block-pack-mode", bp_mode, nports); + + memset(hstart, SWR_INVALID_PARAM, QCOM_SDW_MAX_PORTS); + of_property_read_u8_array(np, "qcom,ports-hstart", hstart, nports); + + memset(hstop, SWR_INVALID_PARAM, QCOM_SDW_MAX_PORTS); + of_property_read_u8_array(np, "qcom,ports-hstop", hstop, nports); + + memset(word_length, SWR_INVALID_PARAM, QCOM_SDW_MAX_PORTS); + of_property_read_u8_array(np, "qcom,ports-word-length", word_length, nports); + + memset(blk_group_count, SWR_INVALID_PARAM, QCOM_SDW_MAX_PORTS); + of_property_read_u8_array(np, "qcom,ports-block-group-count", blk_group_count, nports); + + memset(lane_control, SWR_INVALID_PARAM, QCOM_SDW_MAX_PORTS); + of_property_read_u8_array(np, "qcom,ports-lane-control", lane_control, nports); + for (i = 0; i < nports; i++) { ctrl->pconfig[i].si = si[i]; ctrl->pconfig[i].off1 = off1[i]; ctrl->pconfig[i].off2 = off2[i]; ctrl->pconfig[i].bp_mode = bp_mode[i]; + ctrl->pconfig[i].hstart = hstart[i]; + ctrl->pconfig[i].hstop = hstop[i]; + ctrl->pconfig[i].word_length = word_length[i]; + ctrl->pconfig[i].blk_group_count = blk_group_count[i]; + ctrl->pconfig[i].lane_control = lane_control[i]; } return 0; From patchwork Fri Mar 12 12:00:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 398596 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp1132901jai; Fri, 12 Mar 2021 04:01:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJzfBgl+5SRH/CHdQWkWJsyp36jujvcCN/wZ2xCTOVUOfs3jeFTam3Hb9QbfLzq1kCMWD1TR X-Received: by 2002:a50:82c5:: with SMTP id 63mr13546148edg.97.1615550478783; Fri, 12 Mar 2021 04:01:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615550478; cv=none; d=google.com; s=arc-20160816; b=zmbV20dBBgBD4UHcjI2sAzOwsa6wP6haL9wlWMVL4PKwYs212EzJQt/3t30052FWhP 6k5WbgLiSjfyEz8+q+cz+pY10mFzto+oh5U+qPKkDdP6RggbkvgNm8aQtkfUeXGGfOku hCJuquoDJkqzY4ak68WZv0MjyZbgN5L7ywXQsCHq0MW3fVrm6lhQ62nlISjqK1ada0aq 3Ni7EfHsls02XRmMo6UuF3MkPyegY8Fsmsyin5c6fjLEFBm9VYBcjm1jQBxBsYo3RDxY d5a3o0kDS6PdYTZsoBgsCfrZH2Fdx2rFsFY9TyTTMEhdsbDLjpyelLgccLEqNg7Kv32u vD4A== 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=89jJJI1ffi4hnNcNYiPeSLf8W7Z3c/bGcDU6aGLT2Ls=; b=pVfoYW5aavrtp/1aFHQbNvpg0C93ELhsEl+Hvkz/z7DvVlLl5zzjY3InUZO7AaSBPD dzF+46G2ax6sC4ZJYGTqTt+x3iXZEIyZFs0yyCKsg0Anggo8IdPBpueLI2uz9kulvcf5 NWJXuVnjsuXsTDo3I6fAyxCcFh0QgWjDb1DJfIJlmTVcEZDJWYYDZ+WvHNlqXGG6wb5M 55NE2VS01KWD9tUktOqA5BxMmqPvkFAUOZ9fwgYqkODYbWxVGbU+eYm5wxxH7Jwiu8j1 PcQjy/RzrxCsuV6osOsrsuRe3Wxq9+VemMd5WvYUBdNsA7TM2EgvFp4KvJPgPpl7skid cyRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VPcCNNRM; 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 n20si3843636ejx.104.2021.03.12.04.01.18; Fri, 12 Mar 2021 04:01:18 -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=VPcCNNRM; 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 S231294AbhCLMAu (ORCPT + 6 others); Fri, 12 Mar 2021 07:00:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229900AbhCLMA2 (ORCPT ); Fri, 12 Mar 2021 07:00:28 -0500 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA5E2C061574 for ; Fri, 12 Mar 2021 04:00:27 -0800 (PST) Received: by mail-wr1-x429.google.com with SMTP id b9so1632997wrt.8 for ; Fri, 12 Mar 2021 04:00:27 -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=89jJJI1ffi4hnNcNYiPeSLf8W7Z3c/bGcDU6aGLT2Ls=; b=VPcCNNRMNGUANJrpDhkonXZbUKAPee9KliJEUDnszC8VzRBxCddmKbpb8Bz/nUivaL Jq2WWzxFvckdpdX9YAo265si9aLz+xeUeawU2QRX7zIUfg9Gl5CVu4/pH5V4NChoTmgk /5EvxAsWGGFjC0BdoItn+GTQQ93krkt+mhi3j5llmUaCZmf0fJjOOWp6HZEgR0M42PzU hyH5IZi4vtwhrwuY4DNgKq8o/jC2NDYcee9pN3vU7qb09eX0ezhO9t/jWukXnve85Dcl VI/5UTQgK43IGKXwycgkjxnaIzAGpPFE/4Itx6QfSUh8lEZlg1aWv3dlqVSo/KL8DnTb 1vnw== 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=89jJJI1ffi4hnNcNYiPeSLf8W7Z3c/bGcDU6aGLT2Ls=; b=blftbgoDyJMCEi94sn0SlX5Vk+27FxDzzWT5NwTsiNSV0Ypf4hq16Hol4waf9hayj6 no20nzlB4czdHoEwI5ORsNNv3Pv71RPn/bU+5XXEqKtKq9JBlUWUYfAwW9OXdIQ/du3o s5jpWjgx5/i0vbAdKp2rOT1fuhE07KqdNfTwdutYAbbApGvAwpp1Cc+MPpmeyV/h3VkI PhtcsYVXvujGOrmGq9tS9BzKBTQUaZNDIe0J4t4L1WPEBLi8xohT33Z29Hn6gMKxyymU S6/FcZenIZ1fi8EA3VNmHyYcKFBTrXjNlehhNuENJNBxbh5DQBYBeatMgOeARigrWgle FSCg== X-Gm-Message-State: AOAM530VCUnWiybxF8zLuNzeJaVFxWYKsxiXQjsAR5qM2GUjSL3Fv5aR Qg2FBo05zevx2LeLRCtBuJmDkw== X-Received: by 2002:a5d:4e52:: with SMTP id r18mr14297099wrt.28.1615550426535; Fri, 12 Mar 2021 04:00:26 -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 h25sm2268315wml.32.2021.03.12.04.00.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Mar 2021 04:00:26 -0800 (PST) From: Srinivas Kandagatla To: vkoul@kernel.org Cc: yung-chuan.liao@linux.intel.com, pierre-louis.bossart@linux.intel.com, sanyog.r.kale@intel.com, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, robh@kernel.org, devicetree@vger.kernel.org, Srinivas Kandagatla Subject: [PATCH v4 3/9] soundwire: qcom: set continue execution flag for ignored commands Date: Fri, 12 Mar 2021 12:00:03 +0000 Message-Id: <20210312120009.22386-4-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20210312120009.22386-1-srinivas.kandagatla@linaro.org> References: <20210312120009.22386-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org version 1.5.1 and higher IPs of this controller required to set continue execution on ignored command flag. This patch sets this flag. Signed-off-by: Srinivas Kandagatla --- drivers/soundwire/qcom.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) -- 2.21.0 diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c index d05e41f68658..43ec22a5e332 100644 --- a/drivers/soundwire/qcom.c +++ b/drivers/soundwire/qcom.c @@ -40,6 +40,7 @@ #define SWRM_CMD_FIFO_CMD 0x308 #define SWRM_CMD_FIFO_STATUS 0x30C #define SWRM_CMD_FIFO_CFG_ADDR 0x314 +#define SWRM_CONTINUE_EXEC_ON_CMD_IGNORE BIT(31) #define SWRM_RD_WR_CMD_RETRIES 0x7 #define SWRM_CMD_FIFO_RD_FIFO_ADDR 0x318 #define SWRM_ENUMERATOR_CFG_ADDR 0x500 @@ -343,7 +344,15 @@ static int qcom_swrm_init(struct qcom_swrm_ctrl *ctrl) ctrl->reg_write(ctrl, SWRM_MCP_CFG_ADDR, val); /* Configure number of retries of a read/write cmd */ - ctrl->reg_write(ctrl, SWRM_CMD_FIFO_CFG_ADDR, SWRM_RD_WR_CMD_RETRIES); + if (ctrl->version > 0x01050001) { + /* Only for versions >= 1.5.1 */ + ctrl->reg_write(ctrl, SWRM_CMD_FIFO_CFG_ADDR, + SWRM_RD_WR_CMD_RETRIES | + SWRM_CONTINUE_EXEC_ON_CMD_IGNORE); + } else { + ctrl->reg_write(ctrl, SWRM_CMD_FIFO_CFG_ADDR, + SWRM_RD_WR_CMD_RETRIES); + } /* Set IRQ to PULSE */ ctrl->reg_write(ctrl, SWRM_COMP_CFG_ADDR, From patchwork Fri Mar 12 12:00:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 398598 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp1132916jai; Fri, 12 Mar 2021 04:01:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJzoYg7PEykps6ogVEEMp7aoIMNU1DUpTmICAqV9lQbPTTVZZ/Gw0AeIqVmawfUdzQ/Ub7Mu X-Received: by 2002:a17:906:5295:: with SMTP id c21mr8097673ejm.67.1615550479572; Fri, 12 Mar 2021 04:01:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615550479; cv=none; d=google.com; s=arc-20160816; b=RHralPdAeYhzBBGBvscQW/8m39+3Bmk5y8VEXsO5rLtiR9H94cNdDpP+k02D6e2heV I1P4bad2HXhUmzoyGRJINHpyveFUdQy7pyc7PZ+1dW6TqCEyzuV76mJXUH/oZ73N9/51 zSQ4XQzOn19hdutl0qI71MV3/rl4BAmQlzQ/AaXIhz8NTe3YKNUmJDU6Y8YBTZP5BQMw b86Uv28Z4lKAiie4r5mfQSdKm6PswdFqS6Goe+J/P/WNkIki06oHuimOI1vSPzVluaCH Lna+0sp/475wUEnKr5+AMRpbLQbxxSfTIuXB3VcccregXoNyz4bzBw28L2N+QJbZyyee /ZCA== 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=q5UMSCe0vmgofjLfGXC2dqndVDx3SCra42urjGkx2FI=; b=kZFytC1bAVACN4PCwaHQWo82V5IWS0AVNArAq8LuhUoXHOPIPHj/p5EiHyy4rsfruX FkF7GCV+tiYpew7iemowU4629F2RyI5WJsFDLSqSVE0+gjPwUazK3W9fnf0dj/m9Kjdq C0TUq8/fUITGWH0XQPtvhdn8WfMlNQ5RysP4gWKrtg5J+SLP6vfCeFpojXa4/kUibQ/O yqwnOCs766//+4d8uA8+rQhaKZS3mSUTKnkX9ZGFE0Kk6YU3STZaBWefqptx5iKID3AV 4dzGRYUlhImPugiUzKo9SCQU9QRRursmeplrqyOOE1fqcY0Vx5rIaxAQtcvQ/ho+UXY/ GjTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Nt9ZBV3n; 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 n20si3843636ejx.104.2021.03.12.04.01.19; Fri, 12 Mar 2021 04:01:19 -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=Nt9ZBV3n; 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 S231379AbhCLMAu (ORCPT + 6 others); Fri, 12 Mar 2021 07:00:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229909AbhCLMA3 (ORCPT ); Fri, 12 Mar 2021 07:00:29 -0500 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A97DCC061761 for ; Fri, 12 Mar 2021 04:00:28 -0800 (PST) Received: by mail-wm1-x336.google.com with SMTP id j4-20020a05600c4104b029010c62bc1e20so15038410wmi.3 for ; Fri, 12 Mar 2021 04:00:28 -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=q5UMSCe0vmgofjLfGXC2dqndVDx3SCra42urjGkx2FI=; b=Nt9ZBV3nfcXevgLOhmcv3mpcPVnLP6rZ1H0C09HFJfJtby13DIfhYUYaGYGm4s6rW7 D+ky2wsBj3cfmw8DTRi52RAOwccl6WfgDFxOjCKSghzT7xvvkYDcyCWiuuNiyvxRpj7y 5eeMUVEkF8AU7Xe/TrlSPw1GMFtMFvc2nWTj2MWQhGsoKx/7+CwZlG6fMQf00mzFKqrr AkrSpa1he6GRmqssvShKBz1p4KF3Mh8TuJWdciUYh+fhu4K4QN8+HVN9O9duSje8MSLy oNt2CXgBch/3YXCXrvMTmKGPYvsjQFa6lTQOorWRAsDCPgPR5x8K2zhn0YiP7uQvZwdE Ns7Q== 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=q5UMSCe0vmgofjLfGXC2dqndVDx3SCra42urjGkx2FI=; b=jL+GglkBATU/BRsIOgcQ2BGrNtpVTOXWzutaiyac5jsm0PRbF5aUMCOXRtvVema2o5 slKSuCUlst5mvRDsj+Sj/dCpYcjOc46FuYM0W9LF+dRAJ8oB65G5XJA6/nyki1HRdEDd TrSNWkv/ny0WGJbjCCPV2g1tWK8Lihr9ydWCFIOsIIpQjXF19MaSbkOya9tW7qI6sOD/ zK/ShtBURPHK00uGiviV2Or7H/cZ6ztMryLCD3crjBsm4CecFoAeZW374ybhOtrog8aL IbCqUjkgK4gTteMpEEYB8M9/NmPNMFJiP2SBj7N/8eifnSaScfkW2U+hhMsDbxhv8Cpe f6pw== X-Gm-Message-State: AOAM533uyHnlwCK58o6MkpS2RmQQZ8XKQ9K474ddHaFEijniNeblEeDK 7idVniFckJTjdVW5NfUBTcPrZw== X-Received: by 2002:a1c:4c17:: with SMTP id z23mr12918925wmf.17.1615550427439; Fri, 12 Mar 2021 04:00:27 -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 h25sm2268315wml.32.2021.03.12.04.00.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Mar 2021 04:00:27 -0800 (PST) From: Srinivas Kandagatla To: vkoul@kernel.org Cc: yung-chuan.liao@linux.intel.com, pierre-louis.bossart@linux.intel.com, sanyog.r.kale@intel.com, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, robh@kernel.org, devicetree@vger.kernel.org, Srinivas Kandagatla Subject: [PATCH v4 4/9] soundwire: qcom: start the clock during initialization Date: Fri, 12 Mar 2021 12:00:04 +0000 Message-Id: <20210312120009.22386-5-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20210312120009.22386-1-srinivas.kandagatla@linaro.org> References: <20210312120009.22386-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Start the clock during initialization, doing this explicitly will add more clarity when we are adding clock stop feature. Signed-off-by: Srinivas Kandagatla --- drivers/soundwire/qcom.c | 3 +++ 1 file changed, 3 insertions(+) -- 2.21.0 diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c index 43ec22a5e332..2bcb4362f0e0 100644 --- a/drivers/soundwire/qcom.c +++ b/drivers/soundwire/qcom.c @@ -47,6 +47,8 @@ #define SWRM_MCP_FRAME_CTRL_BANK_ADDR(m) (0x101C + 0x40 * (m)) #define SWRM_MCP_FRAME_CTRL_BANK_COL_CTRL_BMSK GENMASK(2, 0) #define SWRM_MCP_FRAME_CTRL_BANK_ROW_CTRL_BMSK GENMASK(7, 3) +#define SWRM_MCP_BUS_CTRL 0x1044 +#define SWRM_MCP_BUS_CLK_START BIT(1) #define SWRM_MCP_CFG_ADDR 0x1048 #define SWRM_MCP_CFG_MAX_NUM_OF_CMD_NO_PINGS_BMSK GENMASK(21, 17) #define SWRM_DEF_CMD_NO_PINGS 0x1f @@ -343,6 +345,7 @@ static int qcom_swrm_init(struct qcom_swrm_ctrl *ctrl) u32p_replace_bits(&val, SWRM_DEF_CMD_NO_PINGS, SWRM_MCP_CFG_MAX_NUM_OF_CMD_NO_PINGS_BMSK); ctrl->reg_write(ctrl, SWRM_MCP_CFG_ADDR, val); + ctrl->reg_write(ctrl, SWRM_MCP_BUS_CTRL, SWRM_MCP_BUS_CLK_START); /* Configure number of retries of a read/write cmd */ if (ctrl->version > 0x01050001) { /* Only for versions >= 1.5.1 */ From patchwork Fri Mar 12 12:00:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 398597 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp1132909jai; Fri, 12 Mar 2021 04:01:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJyNj1JUs++LvpyfcZ0Xx7jpWakQf4Y707SGyHbdmgyFKWKCQL7i2PnsCwdCg9XGwgA8HPPk X-Received: by 2002:aa7:db53:: with SMTP id n19mr14123302edt.330.1615550479226; Fri, 12 Mar 2021 04:01:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615550479; cv=none; d=google.com; s=arc-20160816; b=fytM49m7b2VZxLhR+nKT0PinvhEdtAELUvbG2/7uNu2fPFrZQxlc7rkcseGl7lXHWA De1EnSBPKoadh0eCkBiCCMuFVb9fonBha8vgFNt+wMLpSOsfNUDvZEm+fST3V2vCTSRx 7UZYZnBEtxec1SWKgbcEUZ10JwO4LQAOmDmKhTieb9iOzG0h7kmwg8UTbHR79b+vp7Tm cRk/nhLYRhAl3CVcnIOAYnTMmGClGMDJjyHhKNDEgaFfJJd8I57mLmL5GFez03l1fQHY y9Tj17WzRYCngBuqAmeEr7fdTHL2hTAoTZEsar+V+ADUkwCZbltt9nxn0bsTwoa0xBrn zmMA== 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=eu+8iKEb0s9zPKk6iyGSaP+h4q5lsr2WR43z0/30Uhg=; b=feK5S0W4/LFYo404vpjGapmSQKbtlroQThF9lPnxG82ubC4h6wYjKGfkVEyCSYlz/g IXQzHGYssxuJYjKCW9D3NmRG+pN9GlqjlwNFt6uOzKadaA7NiMlvGBr+QB9FCorIE2Jy TWNeEnhvURFKARp0O4ey86sBShGfNO8rnuXn6hOLCkB2hjy74bU9Is/HO9xwGEemxhC9 ZFxQyRQFcyrzVgR+zboH4pTTgDTESbQoPa94/FlGdHjV4oAClvQV72X3zQKKrsiJ/q+n Qw5IjnYeJio68CO5AVGUH9UGQwRcYTsZ7cOOl/hgad+77xAP+14KE+Ef1gQRApreqTHk i65g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="ybrtP/YW"; 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 n20si3843636ejx.104.2021.03.12.04.01.19; Fri, 12 Mar 2021 04:01:19 -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="ybrtP/YW"; 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 S229909AbhCLMAv (ORCPT + 6 others); Fri, 12 Mar 2021 07:00:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231409AbhCLMAa (ORCPT ); Fri, 12 Mar 2021 07:00:30 -0500 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E15D0C061574 for ; Fri, 12 Mar 2021 04:00:29 -0800 (PST) Received: by mail-wm1-x336.google.com with SMTP id t5-20020a1c77050000b029010e62cea9deso15010952wmi.0 for ; Fri, 12 Mar 2021 04:00:29 -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=eu+8iKEb0s9zPKk6iyGSaP+h4q5lsr2WR43z0/30Uhg=; b=ybrtP/YWV8A2jzXYFVjd7k520De78VY2OVAFZh4ayBepxT0MZuopSSz0TdtHZ/jYFd QUk137Q1WznH30kY6uOCn4iWU5qxEOz7vxFq5cioFG3kjgvTDnoeQgxgXM+a6TJvCQMx Zm69kKs+JmU+BRaYIv778P47LPFxQwYH1vDJ9Lfzj9JTc7VtHxdzRbrs8X8j84e9Wk+M LK5VeZAkGUkPPRdcZU/lGH9o7t1/slcuBSAhTydugTtCXgYbuIw3lCq6TFCheVPbcGtQ G5jJVW0tWMxAhx+f9sMsrOf9CkPhGvdv1F4pr3P3hDGELcwcmNO27NkRT3tf9/wmhvby QuWg== 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=eu+8iKEb0s9zPKk6iyGSaP+h4q5lsr2WR43z0/30Uhg=; b=qAXtvrgJzBP+Am9oDSTchaiy3FqRAE7gGBTzUMH/1SNXXcNoUhuRHnWDlu1ze4+kaI dSEALe9nujVWUm8IvM4dL5fG7O7gOSWcBVM/BO0WFjTBJRxCgDkitejzcgHCEVbQHhXW VG5s8XAXzCZHzCzl8+pW2gKcVzLrI92He2Z5M6MKL3aL0tvs6lJlXCEv6yy363wjKBPv KyB1P1t88FTCxMZScClwzyh+aRiGX7zycHX5To3GESQwe/seZBFgU7bCc6Upig6u7IQL 5/4Zn2pUxf8qItTTxQVeEdW5AO75/KL6hZACrvGw3x0qfumzcJbRMf0ijylHZxoAGHIJ LQig== X-Gm-Message-State: AOAM530bp782iVT4b+cBFjaDcyqeUDBHUfpjqrPdTeFm+Waoj+LKpgIc o/DP4jW/3fF/FKG9bufSKDkldw== X-Received: by 2002:a1c:4145:: with SMTP id o66mr7917581wma.68.1615550428566; Fri, 12 Mar 2021 04:00:28 -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 h25sm2268315wml.32.2021.03.12.04.00.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Mar 2021 04:00:28 -0800 (PST) From: Srinivas Kandagatla To: vkoul@kernel.org Cc: yung-chuan.liao@linux.intel.com, pierre-louis.bossart@linux.intel.com, sanyog.r.kale@intel.com, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, robh@kernel.org, devicetree@vger.kernel.org, Srinivas Kandagatla Subject: [PATCH v4 5/9] soundwire: qcom: update register read/write routine Date: Fri, 12 Mar 2021 12:00:05 +0000 Message-Id: <20210312120009.22386-6-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20210312120009.22386-1-srinivas.kandagatla@linaro.org> References: <20210312120009.22386-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org In the existing code every soundwire register read and register write are kinda blocked. Each of these are using a special command id that generates interrupt after it successfully finishes. This is really overhead, limiting and not really necessary unless we are doing something special. We can simply read/write the fifo that should also give exactly what we need! This will also allow to read/write registers in interrupt context, which was not possible with the special command approach. With previous approach number of interrupts generated after enumeration are around 130: $ cat /proc/interrupts | grep soundwire 21: 130 0 0 0 0 0 0 0 GICv3 234 Edge soundwire after this patch they are just 3 interrupts $ cat /proc/interrupts | grep soundwire 21: 3 0 0 0 0 0 0 0 GICv3 234 Edge soundwire This has significantly not only reduced interrupting CPU during enumeration but also during streaming! Signed-off-by: Srinivas Kandagatla --- drivers/soundwire/qcom.c | 178 ++++++++++++++++++++++----------------- 1 file changed, 99 insertions(+), 79 deletions(-) -- 2.21.0 diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c index 2bcb4362f0e0..0cbd611fb8c6 100644 --- a/drivers/soundwire/qcom.c +++ b/drivers/soundwire/qcom.c @@ -38,11 +38,13 @@ #define SWRM_CMD_FIFO_WR_CMD 0x300 #define SWRM_CMD_FIFO_RD_CMD 0x304 #define SWRM_CMD_FIFO_CMD 0x308 +#define SWRM_CMD_FIFO_FLUSH 0x1 #define SWRM_CMD_FIFO_STATUS 0x30C #define SWRM_CMD_FIFO_CFG_ADDR 0x314 #define SWRM_CONTINUE_EXEC_ON_CMD_IGNORE BIT(31) #define SWRM_RD_WR_CMD_RETRIES 0x7 #define SWRM_CMD_FIFO_RD_FIFO_ADDR 0x318 +#define SWRM_RD_FIFO_CMD_ID_MASK GENMASK(11, 8) #define SWRM_ENUMERATOR_CFG_ADDR 0x500 #define SWRM_MCP_FRAME_CTRL_BANK_ADDR(m) (0x101C + 0x40 * (m)) #define SWRM_MCP_FRAME_CTRL_BANK_COL_CTRL_BMSK GENMASK(2, 0) @@ -78,13 +80,16 @@ #define SWRM_SPECIAL_CMD_ID 0xF #define MAX_FREQ_NUM 1 #define TIMEOUT_MS (2 * HZ) -#define QCOM_SWRM_MAX_RD_LEN 0xf +#define QCOM_SWRM_MAX_RD_LEN 0x1 #define QCOM_SDW_MAX_PORTS 14 #define DEFAULT_CLK_FREQ 9600000 #define SWRM_MAX_DAIS 0xF #define SWR_INVALID_PARAM 0xFF #define SWR_HSTOP_MAX_VAL 0xF #define SWR_HSTART_MIN_VAL 0x0 +#define SWR_BROADCAST_CMD_ID 0x0F +#define SWR_MAX_CMD_ID 14 +#define MAX_FIFO_RD_RETRY 3 struct qcom_swrm_port_config { u8 si; @@ -103,10 +108,8 @@ struct qcom_swrm_ctrl { struct device *dev; struct regmap *regmap; void __iomem *mmio; - struct completion *comp; + struct completion broadcast; struct work_struct slave_work; - /* read/write lock */ - spinlock_t comp_lock; /* Port alloc/free lock */ struct mutex port_lock; struct clk *hclk; @@ -120,6 +123,8 @@ struct qcom_swrm_ctrl { int rows_index; unsigned long dout_port_mask; unsigned long din_port_mask; + u8 rcmd_id; + u8 wcmd_id; struct qcom_swrm_port_config pconfig[QCOM_SDW_MAX_PORTS]; struct sdw_stream_runtime *sruntime[SWRM_MAX_DAIS]; enum sdw_slave_status status[SDW_MAX_DEVICES]; @@ -198,77 +203,105 @@ static int qcom_swrm_cpu_reg_write(struct qcom_swrm_ctrl *ctrl, int reg, return SDW_CMD_OK; } -static int qcom_swrm_cmd_fifo_wr_cmd(struct qcom_swrm_ctrl *ctrl, u8 cmd_data, - u8 dev_addr, u16 reg_addr) +static u32 swrm_get_packed_reg_val(u8 *cmd_id, u8 cmd_data, + u8 dev_addr, u16 reg_addr) { - DECLARE_COMPLETION_ONSTACK(comp); - unsigned long flags; u32 val; - int ret; - - spin_lock_irqsave(&ctrl->comp_lock, flags); - ctrl->comp = ∁ - spin_unlock_irqrestore(&ctrl->comp_lock, flags); - val = SWRM_REG_VAL_PACK(cmd_data, dev_addr, - SWRM_SPECIAL_CMD_ID, reg_addr); - ret = ctrl->reg_write(ctrl, SWRM_CMD_FIFO_WR_CMD, val); - if (ret) - goto err; - - ret = wait_for_completion_timeout(ctrl->comp, - msecs_to_jiffies(TIMEOUT_MS)); + u8 id = *cmd_id; - if (!ret) - ret = SDW_CMD_IGNORED; - else - ret = SDW_CMD_OK; -err: - spin_lock_irqsave(&ctrl->comp_lock, flags); - ctrl->comp = NULL; - spin_unlock_irqrestore(&ctrl->comp_lock, flags); + if (id != SWR_BROADCAST_CMD_ID) { + if (id < SWR_MAX_CMD_ID) + id += 1; + else + id = 0; + *cmd_id = id; + } + val = SWRM_REG_VAL_PACK(cmd_data, dev_addr, id, reg_addr); - return ret; + return val; } -static int qcom_swrm_cmd_fifo_rd_cmd(struct qcom_swrm_ctrl *ctrl, - u8 dev_addr, u16 reg_addr, - u32 len, u8 *rval) + +static int qcom_swrm_cmd_fifo_wr_cmd(struct qcom_swrm_ctrl *swrm, u8 cmd_data, + u8 dev_addr, u16 reg_addr) { - int i, ret; - u32 val; - DECLARE_COMPLETION_ONSTACK(comp); - unsigned long flags; - spin_lock_irqsave(&ctrl->comp_lock, flags); - ctrl->comp = ∁ - spin_unlock_irqrestore(&ctrl->comp_lock, flags); + u32 val; + int ret = 0; + u8 cmd_id = 0x0; - val = SWRM_REG_VAL_PACK(len, dev_addr, SWRM_SPECIAL_CMD_ID, reg_addr); - ret = ctrl->reg_write(ctrl, SWRM_CMD_FIFO_RD_CMD, val); - if (ret) - goto err; + if (dev_addr == SDW_BROADCAST_DEV_NUM) { + cmd_id = SWR_BROADCAST_CMD_ID; + val = swrm_get_packed_reg_val(&cmd_id, cmd_data, + dev_addr, reg_addr); + } else { + val = swrm_get_packed_reg_val(&swrm->wcmd_id, cmd_data, + dev_addr, reg_addr); + } - ret = wait_for_completion_timeout(ctrl->comp, - msecs_to_jiffies(TIMEOUT_MS)); + swrm->reg_write(swrm, SWRM_CMD_FIFO_WR_CMD, val); + + /* version 1.3 or less */ + if (swrm->version <= 0x01030000) + usleep_range(150, 155); + + if (cmd_id == SWR_BROADCAST_CMD_ID) { + /* + * sleep for 10ms for MSM soundwire variant to allow broadcast + * command to complete. + */ + ret = wait_for_completion_timeout(&swrm->broadcast, + msecs_to_jiffies(TIMEOUT_MS)); + if (!ret) + ret = SDW_CMD_IGNORED; + else + ret = SDW_CMD_OK; - if (!ret) { - ret = SDW_CMD_IGNORED; - goto err; } else { ret = SDW_CMD_OK; } + return ret; +} - for (i = 0; i < len; i++) { - ctrl->reg_read(ctrl, SWRM_CMD_FIFO_RD_FIFO_ADDR, &val); - rval[i] = val & 0xFF; - } +static int qcom_swrm_cmd_fifo_rd_cmd(struct qcom_swrm_ctrl *swrm, + u8 dev_addr, u16 reg_addr, + u32 len, u8 *rval) +{ + u32 cmd_data, cmd_id, val, retry_attempt = 0; + + val = swrm_get_packed_reg_val(&swrm->rcmd_id, len, dev_addr, reg_addr); + + /* wait for FIFO RD to complete to avoid overflow */ + usleep_range(100, 105); + swrm->reg_write(swrm, SWRM_CMD_FIFO_RD_CMD, val); + /* wait for FIFO RD CMD complete to avoid overflow */ + usleep_range(250, 255); + + do { + swrm->reg_read(swrm, SWRM_CMD_FIFO_RD_FIFO_ADDR, &cmd_data); + rval[0] = cmd_data & 0xFF; + cmd_id = FIELD_GET(SWRM_RD_FIFO_CMD_ID_MASK, cmd_data); + + if (cmd_id != swrm->rcmd_id) { + if (retry_attempt < (MAX_FIFO_RD_RETRY - 1)) { + /* wait 500 us before retry on fifo read failure */ + usleep_range(500, 505); + swrm->reg_write(swrm, SWRM_CMD_FIFO_CMD, + SWRM_CMD_FIFO_FLUSH); + swrm->reg_write(swrm, SWRM_CMD_FIFO_RD_CMD, val); + } + retry_attempt++; + } else { + return SDW_CMD_OK; + } -err: - spin_lock_irqsave(&ctrl->comp_lock, flags); - ctrl->comp = NULL; - spin_unlock_irqrestore(&ctrl->comp_lock, flags); + } while (retry_attempt < MAX_FIFO_RD_RETRY); - return ret; + dev_err(swrm->dev, "failed to read fifo: reg: 0x%x, rcmd_id: 0x%x,\ + dev_num: 0x%x, cmd_data: 0x%x\n", + reg_addr, swrm->rcmd_id, dev_addr, cmd_data); + + return SDW_CMD_IGNORED; } static void qcom_swrm_get_device_status(struct qcom_swrm_ctrl *ctrl) @@ -291,7 +324,6 @@ static irqreturn_t qcom_swrm_irq_handler(int irq, void *dev_id) { struct qcom_swrm_ctrl *ctrl = dev_id; u32 sts, value; - unsigned long flags; ctrl->reg_read(ctrl, SWRM_INTERRUPT_STATUS, &sts); @@ -304,8 +336,10 @@ static irqreturn_t qcom_swrm_irq_handler(int irq, void *dev_id) } if ((sts & SWRM_INTERRUPT_STATUS_NEW_SLAVE_ATTACHED) || - sts & SWRM_INTERRUPT_STATUS_CHANGE_ENUM_SLAVE_STATUS) - schedule_work(&ctrl->slave_work); + sts & SWRM_INTERRUPT_STATUS_CHANGE_ENUM_SLAVE_STATUS) { + qcom_swrm_get_device_status(ctrl); + sdw_handle_slave_status(&ctrl->bus, ctrl->status); + } /** * clear the interrupt before complete() is called, as complete can @@ -314,15 +348,12 @@ static irqreturn_t qcom_swrm_irq_handler(int irq, void *dev_id) */ ctrl->reg_write(ctrl, SWRM_INTERRUPT_CLEAR, sts); - if (sts & SWRM_INTERRUPT_STATUS_SPECIAL_CMD_ID_FINISHED) { - spin_lock_irqsave(&ctrl->comp_lock, flags); - if (ctrl->comp) - complete(ctrl->comp); - spin_unlock_irqrestore(&ctrl->comp_lock, flags); - } + if (sts & SWRM_INTERRUPT_STATUS_SPECIAL_CMD_ID_FINISHED) + complete(&ctrl->broadcast); return IRQ_HANDLED; } + static int qcom_swrm_init(struct qcom_swrm_ctrl *ctrl) { u32 val; @@ -570,16 +601,6 @@ static u32 qcom_swrm_freq_tbl[MAX_FREQ_NUM] = { DEFAULT_CLK_FREQ, }; -static void qcom_swrm_slave_wq(struct work_struct *work) -{ - struct qcom_swrm_ctrl *ctrl = - container_of(work, struct qcom_swrm_ctrl, slave_work); - - qcom_swrm_get_device_status(ctrl); - sdw_handle_slave_status(&ctrl->bus, ctrl->status); -} - - static void qcom_swrm_stream_free_ports(struct qcom_swrm_ctrl *ctrl, struct sdw_stream_runtime *stream) { @@ -947,9 +968,8 @@ static int qcom_swrm_probe(struct platform_device *pdev) ctrl->dev = dev; dev_set_drvdata(&pdev->dev, ctrl); - spin_lock_init(&ctrl->comp_lock); mutex_init(&ctrl->port_lock); - INIT_WORK(&ctrl->slave_work, qcom_swrm_slave_wq); + init_completion(&ctrl->broadcast); ctrl->bus.ops = &qcom_swrm_ops; ctrl->bus.port_ops = &qcom_swrm_port_ops; From patchwork Fri Mar 12 12:00:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 398600 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp1132948jai; Fri, 12 Mar 2021 04:01:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJzggiVSh8i3YzQQqM7rwo/RwPW4hPoF8yPrvEUC+RqyfuRue7vLnEA1924FK4UjYuhrYD+c X-Received: by 2002:a50:82c5:: with SMTP id 63mr13546393edg.97.1615550481235; Fri, 12 Mar 2021 04:01:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615550481; cv=none; d=google.com; s=arc-20160816; b=ADc9OfYZxXUHbiXm4cFwbXZ2aBmPi5gTwxp8tyZMrNqPPpwNQHKKtZCAvmon6FmG3M Z7oEvMFloF9wEm5FFDaPe/IOfaZzbXYJNICNVh2nFhLupPL1jVxlJ3XonHh35DhY0POb mZN8vM+dtUz0f7/yBSz067fSYzq6ju/nEM4q2vOQYuFTraOtmWUs230CsmbE4T3AvcyY dd14ibwzXycdJz2bE5UZHOMnVd8xE83ws7KrnlQOx2fqOeCFmiT29YefgD816/AU72f+ 69O0TDcB4lZbnA1CKJBxEZuR8jPgMeu9YQ/lpnwflNi+Fn4dLH/zdzX3RbRBxKojj6s6 Ol7Q== 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=PyVet0MMNWzuhpz0LymeggNR30pG1D8Q6fhrbm8pPJQ=; b=bXsfThcUByU8Kyrl6oNtBWUH0NxI+NnP1PI6nvbSz9XNpq4abDhPUMg5OKXdL9fmYV QZ3S0WevpB0yvjbgSPSD5FItmftn/QHEsi0kgLXIbWamgSkgPetI3/Xfkbep7YPXk3LF pHEmkM0BTogJ4BMlFR+ml54hvox/6Rj5gJ+Gj/lMyRC5S95Q7hUG0p24GzSZqGniJAt9 VuvpiQUkQ9Xi2v+KpyTzIdKlm0Ue7R+HJsgg98P9OBRaNyzzJdL0My7xaF7LPUUZEOcl d0gsAioZ+YIGkPb5EPGKNsLgJ4EwDN7LFa4L3Z25ZpxF6HVsEhGIRdXCBVOL5+qG5mhd EFEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yuAwZqI5; 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 n20si3843636ejx.104.2021.03.12.04.01.21; Fri, 12 Mar 2021 04:01:21 -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=yuAwZqI5; 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 S231409AbhCLMAw (ORCPT + 6 others); Fri, 12 Mar 2021 07:00:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231421AbhCLMAb (ORCPT ); Fri, 12 Mar 2021 07:00:31 -0500 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14F06C061574 for ; Fri, 12 Mar 2021 04:00:31 -0800 (PST) Received: by mail-wm1-x32b.google.com with SMTP id r10-20020a05600c35cab029010c946c95easo15017763wmq.4 for ; Fri, 12 Mar 2021 04:00:31 -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=PyVet0MMNWzuhpz0LymeggNR30pG1D8Q6fhrbm8pPJQ=; b=yuAwZqI5hE3Nk1PQHMW8alNtebLpjAxb00I/vDK2HYDGwbW19/3HnDctnAOISkpyKL /Yzey65rKRNHS924Cl1SQbOYbsfXCpf4/YjODLbIDtAqGBf6KbGRmU5oKxkBenIWKmr7 buIa65ePyv/64ORhiczgM6Dqrl0lvpw9J3EdVr6y5J4R5g+5WmJjjY8Q3xhsudxqeOe+ UVueMLxryIVAgUG+BhBZRG24VhrCcHSdWiPNKY2u0lc8QrUXnfiqMhZhSmIr8fJ98h4t ZsbB2KJwG2sjOelLn4VjIcJScq0cyZvJ5gZ+7PTXNDc2Lynp6VOoNHpFt52YSSyWtZ8u quOg== 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=PyVet0MMNWzuhpz0LymeggNR30pG1D8Q6fhrbm8pPJQ=; b=BJ/biKTJDJTYoRB6gbkYg8gcZeKLCqfL10hIYynyZC8p4lAo8npiDZUNGT5lrbBot/ qbkL/JmiN7SVLuv2i9d9Xg3fQKrU41Vh37g3A+6U3EcfTxg0ff07tga9PG7PGZHy10yN o7jdNrQmUcqD+AIGDJSQ6K6U71cuFivp03Zca0NeZer4kfk5KJYrMUGH4L9z2Wj+XIup 1zHppWQt+U4XUGEPtqNhi604EeJleB8MnL3i/KwobESqBiMbhsVc6a+tHLvQQ/s8zKWw WTmwycoHss0K5lYl5VPpOzCLLIcErJ8yApvJ874cbJW9qqGzszntD/9bykfrSSbGBhP9 NPxQ== X-Gm-Message-State: AOAM533WFEM5Y3q5tSQAiYaAUjxuZiiBATPmNhPkvqW1n1uSc9nfKdzm Cyli8ZkfBnj6+p/TLGKEE7w+Gg== X-Received: by 2002:a1c:1dd4:: with SMTP id d203mr12574908wmd.83.1615550429802; Fri, 12 Mar 2021 04:00:29 -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 h25sm2268315wml.32.2021.03.12.04.00.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Mar 2021 04:00:29 -0800 (PST) From: Srinivas Kandagatla To: vkoul@kernel.org Cc: yung-chuan.liao@linux.intel.com, pierre-louis.bossart@linux.intel.com, sanyog.r.kale@intel.com, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, robh@kernel.org, devicetree@vger.kernel.org, Srinivas Kandagatla Subject: [PATCH v4 6/9] soundwire: qcom: add support to new interrupts Date: Fri, 12 Mar 2021 12:00:06 +0000 Message-Id: <20210312120009.22386-7-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20210312120009.22386-1-srinivas.kandagatla@linaro.org> References: <20210312120009.22386-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Add support to new interrupts which includes reporting some of the error interrupts and adding support to SLAVE pending interrupt! This patch also changes the interrupt handler behaviour on handling any pending interrupts by checking it before returning out of irq handler. Signed-off-by: Srinivas Kandagatla --- drivers/soundwire/qcom.c | 161 ++++++++++++++++++++++++++++++++------- 1 file changed, 135 insertions(+), 26 deletions(-) -- 2.21.0 diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c index 0cbd611fb8c6..6a563fb52444 100644 --- a/drivers/soundwire/qcom.c +++ b/drivers/soundwire/qcom.c @@ -28,10 +28,21 @@ #define SWRM_COMP_PARAMS_DIN_PORTS_MASK GENMASK(9, 5) #define SWRM_INTERRUPT_STATUS 0x200 #define SWRM_INTERRUPT_STATUS_RMSK GENMASK(16, 0) +#define SWRM_INTERRUPT_STATUS_SLAVE_PEND_IRQ BIT(0) #define SWRM_INTERRUPT_STATUS_NEW_SLAVE_ATTACHED BIT(1) #define SWRM_INTERRUPT_STATUS_CHANGE_ENUM_SLAVE_STATUS BIT(2) +#define SWRM_INTERRUPT_STATUS_MASTER_CLASH_DET BIT(3) +#define SWRM_INTERRUPT_STATUS_RD_FIFO_OVERFLOW BIT(4) +#define SWRM_INTERRUPT_STATUS_RD_FIFO_UNDERFLOW BIT(5) +#define SWRM_INTERRUPT_STATUS_WR_CMD_FIFO_OVERFLOW BIT(6) #define SWRM_INTERRUPT_STATUS_CMD_ERROR BIT(7) +#define SWRM_INTERRUPT_STATUS_DOUT_PORT_COLLISION BIT(8) +#define SWRM_INTERRUPT_STATUS_READ_EN_RD_VALID_MISMATCH BIT(9) #define SWRM_INTERRUPT_STATUS_SPECIAL_CMD_ID_FINISHED BIT(10) +#define SWRM_INTERRUPT_STATUS_BUS_RESET_FINISHED_V2 BIT(13) +#define SWRM_INTERRUPT_STATUS_CLK_STOP_FINISHED_V2 BIT(14) +#define SWRM_INTERRUPT_STATUS_EXT_CLK_STOP_WAKEUP BIT(16) +#define SWRM_INTERRUPT_MAX 17 #define SWRM_INTERRUPT_MASK_ADDR 0x204 #define SWRM_INTERRUPT_CLEAR 0x208 #define SWRM_INTERRUPT_CPU_EN 0x210 @@ -58,6 +69,7 @@ #define SWRM_MCP_STATUS_BANK_NUM_MASK BIT(0) #define SWRM_MCP_SLV_STATUS 0x1090 #define SWRM_MCP_SLV_STATUS_MASK GENMASK(1, 0) +#define SWRM_MCP_SLV_STATUS_SZ 2 #define SWRM_DP_PORT_CTRL_BANK(n, m) (0x1124 + 0x100 * (n - 1) + 0x40 * m) #define SWRM_DP_PORT_CTRL_2_BANK(n, m) (0x1128 + 0x100 * (n - 1) + 0x40 * m) #define SWRM_DP_BLOCK_CTRL_1(n) (0x112C + 0x100 * (n - 1)) @@ -123,6 +135,7 @@ struct qcom_swrm_ctrl { int rows_index; unsigned long dout_port_mask; unsigned long din_port_mask; + u32 intr_mask; u8 rcmd_id; u8 wcmd_id; struct qcom_swrm_port_config pconfig[QCOM_SDW_MAX_PORTS]; @@ -304,6 +317,25 @@ static int qcom_swrm_cmd_fifo_rd_cmd(struct qcom_swrm_ctrl *swrm, return SDW_CMD_IGNORED; } +static int qcom_swrm_get_alert_slave_dev_num(struct qcom_swrm_ctrl *ctrl) +{ + u32 val, status; + int dev_num; + + ctrl->reg_read(ctrl, SWRM_MCP_SLV_STATUS, &val); + + for (dev_num = 0; dev_num < SDW_MAX_DEVICES; dev_num++) { + status = (val >> (dev_num * SWRM_MCP_SLV_STATUS_SZ)); + + if ((status & SWRM_MCP_SLV_STATUS_MASK) == SDW_SLAVE_ALERT) { + ctrl->status[dev_num] = status; + return dev_num; + } + } + + return -EINVAL; +} + static void qcom_swrm_get_device_status(struct qcom_swrm_ctrl *ctrl) { u32 val; @@ -322,36 +354,112 @@ static void qcom_swrm_get_device_status(struct qcom_swrm_ctrl *ctrl) static irqreturn_t qcom_swrm_irq_handler(int irq, void *dev_id) { - struct qcom_swrm_ctrl *ctrl = dev_id; - u32 sts, value; + struct qcom_swrm_ctrl *swrm = dev_id; + u32 value, intr_sts, intr_sts_masked; + u32 i; + u8 devnum = 0; + int ret = IRQ_HANDLED; - ctrl->reg_read(ctrl, SWRM_INTERRUPT_STATUS, &sts); + swrm->reg_read(swrm, SWRM_INTERRUPT_STATUS, &intr_sts); + intr_sts_masked = intr_sts & swrm->intr_mask; - if (sts & SWRM_INTERRUPT_STATUS_CMD_ERROR) { - ctrl->reg_read(ctrl, SWRM_CMD_FIFO_STATUS, &value); - dev_err_ratelimited(ctrl->dev, - "CMD error, fifo status 0x%x\n", - value); - ctrl->reg_write(ctrl, SWRM_CMD_FIFO_CMD, 0x1); - } - - if ((sts & SWRM_INTERRUPT_STATUS_NEW_SLAVE_ATTACHED) || - sts & SWRM_INTERRUPT_STATUS_CHANGE_ENUM_SLAVE_STATUS) { - qcom_swrm_get_device_status(ctrl); - sdw_handle_slave_status(&ctrl->bus, ctrl->status); - } - - /** - * clear the interrupt before complete() is called, as complete can - * schedule new read/writes which require interrupts, clearing the - * interrupt would avoid missing interrupts in such cases. - */ - ctrl->reg_write(ctrl, SWRM_INTERRUPT_CLEAR, sts); + do { + for (i = 0; i < SWRM_INTERRUPT_MAX; i++) { + value = intr_sts_masked & (1 << i); + if (!value) + continue; + + switch (value) { + case SWRM_INTERRUPT_STATUS_SLAVE_PEND_IRQ: + devnum = qcom_swrm_get_alert_slave_dev_num(swrm); + if (devnum < 0) { + dev_err_ratelimited(swrm->dev, + "no slave alert found.spurious interrupt\n"); + } else { + sdw_handle_slave_status(&swrm->bus, swrm->status); + } - if (sts & SWRM_INTERRUPT_STATUS_SPECIAL_CMD_ID_FINISHED) - complete(&ctrl->broadcast); + break; + case SWRM_INTERRUPT_STATUS_NEW_SLAVE_ATTACHED: + case SWRM_INTERRUPT_STATUS_CHANGE_ENUM_SLAVE_STATUS: + dev_err_ratelimited(swrm->dev, "%s: SWR new slave attached\n", + __func__); + qcom_swrm_get_device_status(swrm); + sdw_handle_slave_status(&swrm->bus, swrm->status); + break; + case SWRM_INTERRUPT_STATUS_MASTER_CLASH_DET: + dev_err_ratelimited(swrm->dev, + "%s: SWR bus clsh detected\n", + __func__); + swrm->intr_mask &= ~SWRM_INTERRUPT_STATUS_MASTER_CLASH_DET; + swrm->reg_write(swrm, SWRM_INTERRUPT_CPU_EN, swrm->intr_mask); + break; + case SWRM_INTERRUPT_STATUS_RD_FIFO_OVERFLOW: + swrm->reg_read(swrm, SWRM_CMD_FIFO_STATUS, &value); + dev_err_ratelimited(swrm->dev, + "%s: SWR read FIFO overflow fifo status 0x%x\n", + __func__, value); + break; + case SWRM_INTERRUPT_STATUS_RD_FIFO_UNDERFLOW: + swrm->reg_read(swrm, SWRM_CMD_FIFO_STATUS, &value); + dev_err_ratelimited(swrm->dev, + "%s: SWR read FIFO underflow fifo status 0x%x\n", + __func__, value); + break; + case SWRM_INTERRUPT_STATUS_WR_CMD_FIFO_OVERFLOW: + swrm->reg_read(swrm, SWRM_CMD_FIFO_STATUS, &value); + dev_err(swrm->dev, + "%s: SWR write FIFO overflow fifo status %x\n", + __func__, value); + swrm->reg_write(swrm, SWRM_CMD_FIFO_CMD, 0x1); + break; + case SWRM_INTERRUPT_STATUS_CMD_ERROR: + swrm->reg_read(swrm, SWRM_CMD_FIFO_STATUS, &value); + dev_err_ratelimited(swrm->dev, + "%s: SWR CMD error, fifo status 0x%x, flushing fifo\n", + __func__, value); + swrm->reg_write(swrm, SWRM_CMD_FIFO_CMD, 0x1); + break; + case SWRM_INTERRUPT_STATUS_DOUT_PORT_COLLISION: + dev_err_ratelimited(swrm->dev, + "%s: SWR Port collision detected\n", + __func__); + swrm->intr_mask &= ~SWRM_INTERRUPT_STATUS_DOUT_PORT_COLLISION; + swrm->reg_write(swrm, + SWRM_INTERRUPT_CPU_EN, swrm->intr_mask); + break; + case SWRM_INTERRUPT_STATUS_READ_EN_RD_VALID_MISMATCH: + dev_err_ratelimited(swrm->dev, + "%s: SWR read enable valid mismatch\n", + __func__); + swrm->intr_mask &= + ~SWRM_INTERRUPT_STATUS_READ_EN_RD_VALID_MISMATCH; + swrm->reg_write(swrm, + SWRM_INTERRUPT_CPU_EN, swrm->intr_mask); + break; + case SWRM_INTERRUPT_STATUS_SPECIAL_CMD_ID_FINISHED: + complete(&swrm->broadcast); + break; + case SWRM_INTERRUPT_STATUS_BUS_RESET_FINISHED_V2: + break; + case SWRM_INTERRUPT_STATUS_CLK_STOP_FINISHED_V2: + break; + case SWRM_INTERRUPT_STATUS_EXT_CLK_STOP_WAKEUP: + break; + default: + dev_err_ratelimited(swrm->dev, + "%s: SWR unknown interrupt value: %d\n", + __func__, value); + ret = IRQ_NONE; + break; + } + } + swrm->reg_write(swrm, SWRM_INTERRUPT_CLEAR, intr_sts); + swrm->reg_read(swrm, SWRM_INTERRUPT_STATUS, &intr_sts); + intr_sts_masked = intr_sts & swrm->intr_mask; + } while (intr_sts_masked); - return IRQ_HANDLED; + return ret; } static int qcom_swrm_init(struct qcom_swrm_ctrl *ctrl) @@ -367,6 +475,7 @@ static int qcom_swrm_init(struct qcom_swrm_ctrl *ctrl) /* Disable Auto enumeration */ ctrl->reg_write(ctrl, SWRM_ENUMERATOR_CFG_ADDR, 0); + ctrl->intr_mask = SWRM_INTERRUPT_STATUS_RMSK; /* Mask soundwire interrupts */ ctrl->reg_write(ctrl, SWRM_INTERRUPT_MASK_ADDR, SWRM_INTERRUPT_STATUS_RMSK); From patchwork Fri Mar 12 12:00:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 398602 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp1132970jai; Fri, 12 Mar 2021 04:01:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJzk8NqZiZ1k6g4cI+tHHhS0V6wORSRsx6QL+QleILl+05PsLUDHJeFbg9tVQ4sp870FxA04 X-Received: by 2002:a05:6402:510b:: with SMTP id m11mr13797816edd.103.1615550482426; Fri, 12 Mar 2021 04:01:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615550482; cv=none; d=google.com; s=arc-20160816; b=RtsD1GMVeNnVYD9KW4hCTyWNZvMfKXAwtxvF1WppdbPy89EbL3XmFUUStJPtDvh1vG wZTVCZkVYhP8/cvm+i45RVQZRNUmJIkCEIMw8uph5ZxujqgS4uONF7NJTc85WB7i9Ht9 JfbG5CxhpAwGbMYWvjrgcf/Fs35b9W8Cp68zG9kNP9bYgqqQkbZh/ivKdcL9eANmv74j RqvICHzMYeS/aKZ8MsDQMf2io6EGIl0IfgigUwEYDC9E0fz5KlGyN9MER++RFjHe8tSh iifiXFi6g5g+fqBVgPLazKsMws6Jn72OKQLcZ6xVyIl/zrIk/hwtvUo36MFcqKUvWL5e nn8A== 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=ns+tspE3TpNVqG5EYUwkfh0nuT4Nkt3p2sWFNFRFG3w=; b=NwYMz9S76+X7b+LSJCwl+SwPfN26LNcs5cqQwJsWC5GV84Xp95xtWzeUO3Gm6LXyG3 KSVA19bEByYtOeuiPXbOhrFjiPFjRTo/WM73jVorjm6r1lUC0khu4fphxHfRB+vap2O5 CXJcwa47cVL9WSUln7zjMhNZJWMcTAYeD3iRuUuWKX8qumG/He5v+QLc6tj187T+OyZe dPe4cUpeROjKnm7+MD4n3DTvPSfnRw7KArEHJco4fpySUROzbnvPgG3KpJwYm8GL1Kl+ ckPk/fUOAY+Jbnbw23/02eQ0HzuV8CLKqGACFj4bucZMF3RcOZtnlXEv5oF5xZvORTiD ZIGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=P6+peZvD; 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 n20si3843636ejx.104.2021.03.12.04.01.22; Fri, 12 Mar 2021 04:01:22 -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=P6+peZvD; 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 S231439AbhCLMAx (ORCPT + 6 others); Fri, 12 Mar 2021 07:00:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231437AbhCLMAc (ORCPT ); Fri, 12 Mar 2021 07:00:32 -0500 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A1D9C061761 for ; Fri, 12 Mar 2021 04:00:32 -0800 (PST) Received: by mail-wr1-x42e.google.com with SMTP id l11so4655922wrp.7 for ; Fri, 12 Mar 2021 04:00:32 -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=ns+tspE3TpNVqG5EYUwkfh0nuT4Nkt3p2sWFNFRFG3w=; b=P6+peZvDODkplKd7B975gw81MJr7jqWIWBOCgEwcQ6jwIjBbL1A4fSfPMJubO9u/HI klsjbXDAggxVo9agrb0jMULcytEzWovafXLqeTCJPvnRVuG451MUOen4ZgTsVM2xkmPx DP9VCq/2rpA3kT9bLXvhQb/qWsKgd860Kvp4RuYkjt82c9UgfGZHbDma2ONT3f5uiqjL Pwj//Vr/Sac6hv2F4v3XuEZEVPoDILbXRZzgFSDFcTzf49sp9XrwfQ4NBP6fpT2Cs8IF hIS8V8ZOPlc4RmjO3OSHfUKRPmjyHP8VyroNx0+sTrQT0WluViH1T5wWPBQy0ZEpZsNU feew== 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=ns+tspE3TpNVqG5EYUwkfh0nuT4Nkt3p2sWFNFRFG3w=; b=jDjBc8ixcDuAfSMPRCFILIqwoBkqlCNiz+GlNNA3yUDOygyZ30sI0yYqcsaKmZHjnb DC6k92eV7w6nVkffUJlWFJYJAt26TQP1Xiw0M/ZLx11jeHuCBle448zFBVI39m1GAYqX myR5o8oMFf/ZRYDPnXtSvyIEGXNydcRrXPHe2m2GgfESXQnPsi76pt/EBWRkaUqL7d25 3Q3xpbSvp1hyexU6yjIcqb64ir2IKguIxj4ipHlM+pktH++t2BzcuNo/eIFGygNN91KA ZB9EaJWH8HfPF5VeYM5GwwBa+cge9/hvgBUgImYbP/0kT9LJbbaaPr3n8+wYA79eE6f9 Qrxg== X-Gm-Message-State: AOAM533mjgsPWpW5FFgKE1O3PQDvsJimQm17n1ws4omRvejQZ8Ht4HWv 5juZBb9SgvJFQ5d4WTE9oYW7Iw== X-Received: by 2002:adf:fe48:: with SMTP id m8mr13403133wrs.135.1615550430888; Fri, 12 Mar 2021 04:00:30 -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 h25sm2268315wml.32.2021.03.12.04.00.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Mar 2021 04:00:30 -0800 (PST) From: Srinivas Kandagatla To: vkoul@kernel.org Cc: yung-chuan.liao@linux.intel.com, pierre-louis.bossart@linux.intel.com, sanyog.r.kale@intel.com, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, robh@kernel.org, devicetree@vger.kernel.org, Srinivas Kandagatla Subject: [PATCH v4 7/9] soundwire: export sdw_compare_devid() and sdw_extract_slave_id() Date: Fri, 12 Mar 2021 12:00:07 +0000 Message-Id: <20210312120009.22386-8-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20210312120009.22386-1-srinivas.kandagatla@linaro.org> References: <20210312120009.22386-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Exporting these two functions makes sense as it can be used by other controllers like Qualcomm during auto-enumeration! Signed-off-by: Srinivas Kandagatla --- drivers/soundwire/bus.c | 4 +++- include/linux/soundwire/sdw.h | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) -- 2.21.0 diff --git a/drivers/soundwire/bus.c b/drivers/soundwire/bus.c index 46885429928a..6d7708964735 100644 --- a/drivers/soundwire/bus.c +++ b/drivers/soundwire/bus.c @@ -603,7 +603,7 @@ static struct sdw_slave *sdw_get_slave(struct sdw_bus *bus, int i) return NULL; } -static int sdw_compare_devid(struct sdw_slave *slave, struct sdw_slave_id id) +int sdw_compare_devid(struct sdw_slave *slave, struct sdw_slave_id id) { if (slave->id.mfg_id != id.mfg_id || slave->id.part_id != id.part_id || @@ -614,6 +614,7 @@ static int sdw_compare_devid(struct sdw_slave *slave, struct sdw_slave_id id) return 0; } +EXPORT_SYMBOL(sdw_compare_devid); /* called with bus_lock held */ static int sdw_get_device_num(struct sdw_slave *slave) @@ -698,6 +699,7 @@ void sdw_extract_slave_id(struct sdw_bus *bus, "SDW Slave class_id 0x%02x, mfg_id 0x%04x, part_id 0x%04x, unique_id 0x%x, version 0x%x\n", id->class_id, id->mfg_id, id->part_id, id->unique_id, id->sdw_version); } +EXPORT_SYMBOL(sdw_extract_slave_id); static int sdw_program_device_num(struct sdw_bus *bus) { diff --git a/include/linux/soundwire/sdw.h b/include/linux/soundwire/sdw.h index b032d6ac0b39..c677ab1013ab 100644 --- a/include/linux/soundwire/sdw.h +++ b/include/linux/soundwire/sdw.h @@ -1011,5 +1011,7 @@ int sdw_write_no_pm(struct sdw_slave *slave, u32 addr, u8 value); int sdw_read_no_pm(struct sdw_slave *slave, u32 addr); int sdw_nread(struct sdw_slave *slave, u32 addr, size_t count, u8 *val); int sdw_nwrite(struct sdw_slave *slave, u32 addr, size_t count, u8 *val); +int sdw_compare_devid(struct sdw_slave *slave, struct sdw_slave_id id); +void sdw_extract_slave_id(struct sdw_bus *bus, u64 addr, struct sdw_slave_id *id); #endif /* __SOUNDWIRE_H */ From patchwork Fri Mar 12 12:00:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 398599 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp1132940jai; Fri, 12 Mar 2021 04:01:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJyRzh1p7faPXsgSD5gla3u3jKDYcGTp/FBTwZ11by+81UVlnxjKuiKO3klLZ9k/sQyWUEBf X-Received: by 2002:a17:906:3b41:: with SMTP id h1mr7783150ejf.506.1615550480829; Fri, 12 Mar 2021 04:01:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615550480; cv=none; d=google.com; s=arc-20160816; b=KIky2qLL0AmSEVYGL2hHngSNtxQ216rscEpDApHzHP3vX2fC8VIY9XDCGO/j3zoOcc jpEu1We2Ia6SdaclS1n4l66+mcQtAuVsEYaAvlwjBmnDT2TWh/nhHHWN9sOZinHLajEk 12z+CqRmaW2liLMGq11YwdLLa0DTcBCf3d3XlK1DlifylthBSJPQsVQo9wYVzZL+8lwX NLEraRdSttBjlIDT4qMjxXTEXrdFqSYR3iontGX/eho+zsQfJruuwr7wUQKWgLnP01WK dBBHDH2XFw9N1hoEFc0hFUyX4nVPnf2zjlYSQsh7E9O16pL5HpBSBOZ9Vp4c+h6jxBN2 gF8w== 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=McMRGa+k2wYhi+9vmCrUwcgebhPfYzfC04NyJL/Hc1k=; b=gaoFS0et/7u2FKKtKfz8YunBicCkRoMQGH7zz8BcrqvwkHAB3tUSX19gCFxfxFytYM Wl0xIZWxoC9V/FBWYuH7AQUKFaBEJDOEq5K6MDaQ+pkFeSXorTjqHwd8R6SyRKlrZ4Hh r/fCCbrRd8C2Mn8W0/k9+b4T7Yuu7Q8gQIeUaR7QAPVYBEtWogApYdZtsJDjoxeXO+4G GFl+u1Im+sbdem8Q+keXuEwW95n0RzHum0FMW4dWTuvWr6vhWjJrfnT0w3spb9qz+iuc dCRiyHM/j2KZce52famddiF7PGPFCY+fz9Qt/s/KziKhGQhY4HZSJmuC4YbgeWKmZCE5 ousA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=n9tFVto6; 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 n20si3843636ejx.104.2021.03.12.04.01.20; Fri, 12 Mar 2021 04:01:20 -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=n9tFVto6; 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 S231458AbhCLMAx (ORCPT + 6 others); Fri, 12 Mar 2021 07:00:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231439AbhCLMAd (ORCPT ); Fri, 12 Mar 2021 07:00:33 -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 1BB39C061574 for ; Fri, 12 Mar 2021 04:00:33 -0800 (PST) Received: by mail-wr1-x436.google.com with SMTP id l12so4664181wry.2 for ; Fri, 12 Mar 2021 04:00:33 -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=McMRGa+k2wYhi+9vmCrUwcgebhPfYzfC04NyJL/Hc1k=; b=n9tFVto6RRq8v6s1Rub2Qm0ophWbFgmh9Ud/YccjDR3kMoMIcuXtN4PuH9bDyb4Ez5 z92NLQrilIoMeI++fWg+xbzTYOL+3dtmXjnr17qt748thtz1RIHlaWCcchsjBtDUUndh QRTzZ1ABy9K8LFdZzwGcZJ/aQ9l7l26zg3R5KR8XZN8GGvihSP4N3TUILQo6ffOQKiiF dA2MQRu5KGVbreOncoqYELOWlS565l8lO0LOEnNazdq9eVFwccXEXXE+gCl/OLL+jC7X cYNFR3w4oz6xh5f700LqhTXiZSGSav+0lJMIEiN5Tj8v4ssaKTo7vs3Y/emepHljblnA mHLw== 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=McMRGa+k2wYhi+9vmCrUwcgebhPfYzfC04NyJL/Hc1k=; b=CSVDckzpE+iZbnERNlq6xSwSETCEMs39RJKdlnaaeMeLjfTHsPlXbFbUPMJvWN5Vkp 9aDXiAdlKqJwb7L/k3dIJBVWThGeaB0RdTwDVyPB6/I94NyyyMN/xtTLKaOwSFAfPSdd UcA7Y9ABDM/KfQFm7u2QOG0mNdV5Dfm6Cl1aMSmZfXhVkoSMufF1vUT+vL6m93C7JN3Y W6VE8Bw3RFNaOoNbbvj2ZBeW1bot6a1axRP6F0/jCplqIaejqZssX+GEP4wpTYnRuicr CM+RZvnpiohoPoic5sGZ75Y9xY6bV5idO+9PPXXm5uTh2bd5Zzhk3A6vfU35JZ0858Dd wYXA== X-Gm-Message-State: AOAM532BQCudrO1SD6hX7O4ueAeOYBp6+ggXvk5XEeKGJ5c2hsWXGK7z BLwEXawjCWuIrwZ77VyFnMiujA== X-Received: by 2002:a5d:4485:: with SMTP id j5mr13343571wrq.339.1615550431803; Fri, 12 Mar 2021 04:00:31 -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 h25sm2268315wml.32.2021.03.12.04.00.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Mar 2021 04:00:31 -0800 (PST) From: Srinivas Kandagatla To: vkoul@kernel.org Cc: yung-chuan.liao@linux.intel.com, pierre-louis.bossart@linux.intel.com, sanyog.r.kale@intel.com, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, robh@kernel.org, devicetree@vger.kernel.org, Srinivas Kandagatla Subject: [PATCH v4 8/9] soundwire: qcom: add auto enumeration support Date: Fri, 12 Mar 2021 12:00:08 +0000 Message-Id: <20210312120009.22386-9-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20210312120009.22386-1-srinivas.kandagatla@linaro.org> References: <20210312120009.22386-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Qualcomm SoundWire controller supports Auto Enumeration of the devices within the IP. This patch enables support for this feature. Signed-off-by: Srinivas Kandagatla --- drivers/soundwire/qcom.c | 86 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 81 insertions(+), 5 deletions(-) -- 2.21.0 Reported-by: kernel test robot diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c index 6a563fb52444..c6c923329b15 100644 --- a/drivers/soundwire/qcom.c +++ b/drivers/soundwire/qcom.c @@ -57,6 +57,8 @@ #define SWRM_CMD_FIFO_RD_FIFO_ADDR 0x318 #define SWRM_RD_FIFO_CMD_ID_MASK GENMASK(11, 8) #define SWRM_ENUMERATOR_CFG_ADDR 0x500 +#define SWRM_ENUMERATOR_SLAVE_DEV_ID_1(m) (0x530 + 0x8 * (m)) +#define SWRM_ENUMERATOR_SLAVE_DEV_ID_2(m) (0x534 + 0x8 * (m)) #define SWRM_MCP_FRAME_CTRL_BANK_ADDR(m) (0x101C + 0x40 * (m)) #define SWRM_MCP_FRAME_CTRL_BANK_COL_CTRL_BMSK GENMASK(2, 0) #define SWRM_MCP_FRAME_CTRL_BANK_ROW_CTRL_BMSK GENMASK(7, 3) @@ -143,6 +145,7 @@ struct qcom_swrm_ctrl { enum sdw_slave_status status[SDW_MAX_DEVICES]; int (*reg_read)(struct qcom_swrm_ctrl *ctrl, int reg, u32 *val); int (*reg_write)(struct qcom_swrm_ctrl *ctrl, int reg, int val); + u32 slave_status; }; struct qcom_swrm_data { @@ -342,6 +345,7 @@ static void qcom_swrm_get_device_status(struct qcom_swrm_ctrl *ctrl) int i; ctrl->reg_read(ctrl, SWRM_MCP_SLV_STATUS, &val); + ctrl->slave_status = val; for (i = 0; i < SDW_MAX_DEVICES; i++) { u32 s; @@ -352,10 +356,74 @@ static void qcom_swrm_get_device_status(struct qcom_swrm_ctrl *ctrl) } } +static void qcom_swrm_set_slave_dev_num(struct sdw_bus *bus, + struct sdw_slave *slave, int devnum) +{ + struct qcom_swrm_ctrl *ctrl = to_qcom_sdw(bus); + u32 status; + + ctrl->reg_read(ctrl, SWRM_MCP_SLV_STATUS, &status); + status = (status >> (devnum * SWRM_MCP_SLV_STATUS_SZ)); + status &= SWRM_MCP_SLV_STATUS_MASK; + + if (status == SDW_SLAVE_ATTACHED) { + if (slave) + slave->dev_num = devnum; + mutex_lock(&bus->bus_lock); + set_bit(devnum, bus->assigned); + mutex_unlock(&bus->bus_lock); + } +} + +static int qcom_swrm_enumerate(struct sdw_bus *bus) +{ + struct qcom_swrm_ctrl *ctrl = to_qcom_sdw(bus); + struct sdw_slave *slave, *_s; + struct sdw_slave_id id; + u32 val1, val2; + bool found; + u64 addr; + int i; + char *buf1 = (char *)&val1, *buf2 = (char *)&val2; + + for (i = 1; i <= SDW_MAX_DEVICES; i++) { + /*SCP_Devid5 - Devid 4*/ + ctrl->reg_read(ctrl, SWRM_ENUMERATOR_SLAVE_DEV_ID_1(i), &val1); + + /*SCP_Devid3 - DevId 2 Devid 1 Devid 0*/ + ctrl->reg_read(ctrl, SWRM_ENUMERATOR_SLAVE_DEV_ID_2(i), &val2); + + if (!val1 && !val2) + break; + + addr = buf2[1] | (buf2[0] << 8) | (buf1[3] << 16) | + ((u64)buf1[2] << 24) | ((u64)buf1[1] << 32) | + ((u64)buf1[0] << 40); + + sdw_extract_slave_id(bus, addr, &id); + found = false; + /* Now compare with entries */ + list_for_each_entry_safe(slave, _s, &bus->slaves, node) { + if (sdw_compare_devid(slave, id) == 0) { + qcom_swrm_set_slave_dev_num(bus, slave, i); + found = true; + break; + } + } + + if (!found) { + qcom_swrm_set_slave_dev_num(bus, NULL, i); + sdw_slave_add(bus, &id, NULL); + } + } + + return 0; +} + static irqreturn_t qcom_swrm_irq_handler(int irq, void *dev_id) { struct qcom_swrm_ctrl *swrm = dev_id; - u32 value, intr_sts, intr_sts_masked; + u32 value, intr_sts, intr_sts_masked, slave_status; u32 i; u8 devnum = 0; int ret = IRQ_HANDLED; @@ -384,8 +452,15 @@ static irqreturn_t qcom_swrm_irq_handler(int irq, void *dev_id) case SWRM_INTERRUPT_STATUS_CHANGE_ENUM_SLAVE_STATUS: dev_err_ratelimited(swrm->dev, "%s: SWR new slave attached\n", __func__); - qcom_swrm_get_device_status(swrm); - sdw_handle_slave_status(&swrm->bus, swrm->status); + swrm->reg_read(swrm, SWRM_MCP_SLV_STATUS, &slave_status); + if (swrm->slave_status == slave_status) { + dev_err(swrm->dev, "Slave status not changed %x\n", + slave_status); + } else { + qcom_swrm_get_device_status(swrm); + qcom_swrm_enumerate(&swrm->bus); + sdw_handle_slave_status(&swrm->bus, swrm->status); + } break; case SWRM_INTERRUPT_STATUS_MASTER_CLASH_DET: dev_err_ratelimited(swrm->dev, @@ -472,8 +547,8 @@ static int qcom_swrm_init(struct qcom_swrm_ctrl *ctrl) ctrl->reg_write(ctrl, SWRM_MCP_FRAME_CTRL_BANK_ADDR(0), val); - /* Disable Auto enumeration */ - ctrl->reg_write(ctrl, SWRM_ENUMERATOR_CFG_ADDR, 0); + /* Enable Auto enumeration */ + ctrl->reg_write(ctrl, SWRM_ENUMERATOR_CFG_ADDR, 1); ctrl->intr_mask = SWRM_INTERRUPT_STATUS_RMSK; /* Mask soundwire interrupts */ @@ -507,6 +582,7 @@ static int qcom_swrm_init(struct qcom_swrm_ctrl *ctrl) ctrl->reg_write(ctrl, SWRM_INTERRUPT_CPU_EN, SWRM_INTERRUPT_STATUS_RMSK); } + ctrl->slave_status = 0; return 0; } From patchwork Fri Mar 12 12:00:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 398601 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp1132962jai; Fri, 12 Mar 2021 04:01:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJzAjw7UJul9f3yGwxHXdx+f6AYTuhPu+3M9JvjXTxE7bevtG4YqDCFOBe7c2SiWi6R6JuX7 X-Received: by 2002:a17:906:144d:: with SMTP id q13mr6264066ejc.458.1615550482052; Fri, 12 Mar 2021 04:01:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615550482; cv=none; d=google.com; s=arc-20160816; b=vm5oyrYM2pZBN9zYoxBNOMlJzxp901EUMaUldGdJDiFjBWq+rOxg66gWlCByzA7EHe cWimVkSBwJOM3qoOJ3GgYv3HYS2JL/US3iNg7iJyxVaQ6HS7HeyY0fCgLOlBlzLhjOiV NnTO1JG1aAfRVGqIQKbDOSHc5+pShAK7q05Z9Csh3Wm0oQjbuQ2EAYik7NAKhYx3spbw lobWzBSANu8FjlH+hQTMDGFFmsmBCyOZ4HP3XGkCMGzEzDHw5JZ0cR8JMjmq3cMwffJA v4lMNW/m6c1cpkMSPHmCBVTQPjxSz6NvR2mtKf6Sv4ri7amT+/aLZ2s7R1LeQwvxKXbY QMCQ== 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=yEstJ8fSJSpfc6e8Q0vMn1tWonCjZtnzF+5445SF5Qs=; b=GbqlfF38r8so+sBwpM8rBGKycBt1WgC/+cgPkNATwDOQHMDj2TMBPkc2ONaO8OaCEJ J9p8zoNLezf/nAqX08fTsK60XW3oCBP7mBoUvJ+iBm08+yHF0TQvI0Sa+G7+0JjseiSU RznXJapfaI9EbTQi/q8GaYSpQgkPJV13JExEBGmcHqtkrcJARQkAccNfzZj+/xhunL9W Tr8nsgyVIxJUlWo8IbwTzxEZYruyNn69FC7jWT5egH7dwBVHmv5NOHoPg7Dql4jPJZ5Y Qyg0dkAyu0oo0ZiMglNUKoRjnW4LABbX74aPk2oy7R93+A7b9gQBjCf9VZx18/L8DpCq 7PDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yXkq2KLA; 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 n20si3843636ejx.104.2021.03.12.04.01.21; Fri, 12 Mar 2021 04:01:22 -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=yXkq2KLA; 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 S231317AbhCLMAy (ORCPT + 6 others); Fri, 12 Mar 2021 07:00:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231444AbhCLMAe (ORCPT ); Fri, 12 Mar 2021 07:00:34 -0500 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BB20C061574 for ; Fri, 12 Mar 2021 04:00:34 -0800 (PST) Received: by mail-wr1-x433.google.com with SMTP id t9so1626586wrn.11 for ; Fri, 12 Mar 2021 04:00:33 -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=yEstJ8fSJSpfc6e8Q0vMn1tWonCjZtnzF+5445SF5Qs=; b=yXkq2KLAbC7KzixcJj2Z96/TbUF5rxrVRAuXgmyNmPkUsbt00yQDUAtePfvJpDGkBq Q9AdySyXNnOdzKSxPbO/ssZolk7JeniO5InutNFtUM0ERNxCG3ID43kJuDgkbMgNovEY mZGbxSn+fGUz3jnIQC08dXvh3eoNP8Z6850z4rizDVZe6I1LBkISACd5EbB0ag9zxyhN dWGf8DDFmDsEr94j30r1q5+PwHX7k1qnCnWBDhSMQV/EK7Tl8wcw1lvW/KarPTytmy1e kfZUWS9r00Ewl1SYyRqwDW+oxCD3VvLvvKc+eeezMk0NxU2zuKNEVYgeCcowcJVFaCzK LEGg== 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=yEstJ8fSJSpfc6e8Q0vMn1tWonCjZtnzF+5445SF5Qs=; b=I3vGVkl7VoOB0kmSpEwnWUnYe5SgX3Kf8gF5QpDuOXxPftNP+VQhHctE34vFCgmUIM YL7ccDeJUaHjZ9JlEHsKf/dqaGGLMWwuIIDqY6jNuSVRvUX4xxx/qq3eu3pvboBANaE3 dRZSSY5PKZH1F6ic8CGQPR+RsicxD+5atiE5DgJqJeJrOj5w1g3Dz1AmsDVhC4QsAIvr AqXpw8oqqm3tDaEDlEGfSgaBRSrZckjB/yLBdf251LVMEpWuDyJPkTC+frJlB7Moaiue fFzk/YHk0SH70CLAj/4usGJPcMzHxv3LwnIXkYp0AUS4w6iM0PtQqLF1ZEQq2qADIqwq r6Sw== X-Gm-Message-State: AOAM532q0qFot72h+2AtLvQs794JXzp62EvoIolJ/eNsi7Yxzyy0A5YM cExlxMQQxJZ9U1LFHDZrca7JNQ== X-Received: by 2002:a5d:4564:: with SMTP id a4mr13642592wrc.3.1615550432808; Fri, 12 Mar 2021 04:00:32 -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 h25sm2268315wml.32.2021.03.12.04.00.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Mar 2021 04:00:32 -0800 (PST) From: Srinivas Kandagatla To: vkoul@kernel.org Cc: yung-chuan.liao@linux.intel.com, pierre-louis.bossart@linux.intel.com, sanyog.r.kale@intel.com, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, robh@kernel.org, devicetree@vger.kernel.org, Srinivas Kandagatla Subject: [PATCH v4 9/9] soundwire: qcom: wait for enumeration to be complete in probe Date: Fri, 12 Mar 2021 12:00:09 +0000 Message-Id: <20210312120009.22386-10-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20210312120009.22386-1-srinivas.kandagatla@linaro.org> References: <20210312120009.22386-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Signed-off-by: Srinivas Kandagatla --- drivers/soundwire/qcom.c | 5 +++++ 1 file changed, 5 insertions(+) -- 2.21.0 diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c index c6c923329b15..706d44200a36 100644 --- a/drivers/soundwire/qcom.c +++ b/drivers/soundwire/qcom.c @@ -123,6 +123,7 @@ struct qcom_swrm_ctrl { struct regmap *regmap; void __iomem *mmio; struct completion broadcast; + struct completion enumeration; struct work_struct slave_work; /* Port alloc/free lock */ struct mutex port_lock; @@ -417,6 +418,7 @@ static int qcom_swrm_enumerate(struct sdw_bus *bus) } } + complete(&ctrl->enumeration); return 0; } @@ -1155,6 +1157,7 @@ static int qcom_swrm_probe(struct platform_device *pdev) dev_set_drvdata(&pdev->dev, ctrl); mutex_init(&ctrl->port_lock); init_completion(&ctrl->broadcast); + init_completion(&ctrl->enumeration); ctrl->bus.ops = &qcom_swrm_ops; ctrl->bus.port_ops = &qcom_swrm_port_ops; @@ -1201,6 +1204,8 @@ static int qcom_swrm_probe(struct platform_device *pdev) } qcom_swrm_init(ctrl); + wait_for_completion_timeout(&ctrl->enumeration, + msecs_to_jiffies(TIMEOUT_MS)); ret = qcom_swrm_register_dais(ctrl); if (ret) goto err_master_add;