From patchwork Fri Mar 26 06:39:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 409469 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp1165118jai; Thu, 25 Mar 2021 23:42:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxKbM+iSDvmUANjj/C5bTZK78HWQgybNm6f6VexpxHuOvmD07/1LWNt3rjWQr0Qh0E8kzrK X-Received: by 2002:a17:906:340d:: with SMTP id c13mr13751089ejb.29.1616740920101; Thu, 25 Mar 2021 23:42:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616740920; cv=none; d=google.com; s=arc-20160816; b=N4tNsvynZA4CYroLeBFCvvbdysZ4Gw4y5SQVy2FyWE7I8cnR9ThaZbZ/354uVMzXB0 VTDaJiOYUR9I2mcQSo7D4Sl3GgCmXa5EwUkScXDRBsGh5W0oKi4vlA3SbrglST01gR3b +s8IJM4IinGDwztvnd3XKMXIETaUGOdPvVb/f5ldHOZiRLwyULOwhMxWelYOW3mTjFlW Y2Dkz1AQ1nx2T2GwQ9wNAdMUM1oPnfOlNxPoM1hEAZrk2L+HQAOQGnK37PtExug6QmMB 3CY81m/AcuBwzl2aK3dc4h8t4xB6ufcTXy98xhiTUFIPyjby9n8AabZjXPKMtop/KoOy Hpcw== 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=96IKLbOURC0YjosZF10ff1jryU9fCjeBBqqAs+cW9Zo=; b=RHt9mMsmghs3yaQrn+179uy9XVew6fKTzPmdO8N5Z5tKqZO7jfA6cWWDAowYtOsAVX IzJvFgZPWgrThch3wMMDARRRde51ELiN7aOlXoT26hPVech/e+TkH4qqvXcM0RZDYRL9 Q8vhyxoJ/D5lIvOrhdu8Vy6FgZPD8WLo5XLGVsu2Dpg1B5/mi4qrJrbYkdZ/mkVAkQLJ 6KWDav7Y11Fmh7g9oPQiDk8KHHVz2nh6b+9X6X0ORHW1Gahj2iMMDUVibkolbki28z6E kuNmjwBu6FeSkS6dqd4lNbE5sA6UJX0GYZ0pbci1UwZ3oqnKi8K6DexJb+b4QnmDTler 8Yxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cW1pVehn; 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 ce20si6378091edb.34.2021.03.25.23.41.59; Thu, 25 Mar 2021 23:42:00 -0700 (PDT) Received-SPF: pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cW1pVehn; 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 S229839AbhCZGl0 (ORCPT + 6 others); Fri, 26 Mar 2021 02:41:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230098AbhCZGlS (ORCPT ); Fri, 26 Mar 2021 02:41:18 -0400 Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D44CC0613B0 for ; Thu, 25 Mar 2021 23:41:18 -0700 (PDT) Received: by mail-ej1-x62a.google.com with SMTP id hq27so6747270ejc.9 for ; Thu, 25 Mar 2021 23:41:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=96IKLbOURC0YjosZF10ff1jryU9fCjeBBqqAs+cW9Zo=; b=cW1pVehnuPdBaHUoSa7c5YcBSX4O9GlWFResG9lRzoX2wocZ6LHCMOxTOGlmJOyt9Z QKsR/Q/WZXvnA7P4+ZWyZay2M3KIu82fSIpkFXVXw0Sef9ytgNO/x9Qmao0ZO4DuvS7Z lkj0oJApU3XAdkgLIUd+0xkRbeuNE17oAQIZlp1aXrFOUvuJIDteKHJtYP5HJssKiC6X V+KUra/wQ/2UqyEEF7iMKLQ23n35JT3Ae49Lkv4616m9ArEVdlvPsBfb2wOgDv5ICssB nGdBh+NaN+mbXpYDTi3wKoypqcRr+ZK2iSRbg7F3Rh6mp8ZURkWpM2nn/KMmBdhf92bX furQ== 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=96IKLbOURC0YjosZF10ff1jryU9fCjeBBqqAs+cW9Zo=; b=f9oZyj8g44SNFL0CAHQDX2Fhv11ry+8cBvBRYRlj4wUMIK5MtwpsrLewGPam+0vk+V cIWdSjzbY3KD26JdTuY88BBVLbAS2pMSQ1FDvju7mde3j+drANoepFZyLUzcQAfJWEKO f3zJ80rVfB+xL9AcCDOerWHEQPZ+zJVGbIaE0yd8DDPzgm6FHEDY4RCe1sest3qrbFWZ oqoX6l9QEYMYUJ7CF5wy+pTFzXz82iP5hFab4VrZja/aMwrpKmUdrOFvtz1xXXj6yhAp tmG1MWT0d22xz4zETjgtMymILD3jzos0ijaDBqNUE5urkvSlLSXqW8EFrLcrcuQygoUY L7Dg== X-Gm-Message-State: AOAM533Pz5fePjBMXRaP7M3gpB1QbLzjQFEh04Gp47IqG2muet2GFsaA 30ad7pGcbfUvGjN2FDtm/BpGUg== X-Received: by 2002:a17:906:1a4b:: with SMTP id j11mr13705536ejf.55.1616740877062; Thu, 25 Mar 2021 23:41:17 -0700 (PDT) Received: from srini-hackbox.lan (cpc86377-aztw32-2-0-cust226.18-1.cable.virginm.net. [92.233.226.227]) by smtp.gmail.com with ESMTPSA id ci22sm125325ejc.54.2021.03.25.23.41.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Mar 2021 23:41:16 -0700 (PDT) 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 v5 1/9] dt-bindings: soundwire: qcom: clarify data port bus parameters Date: Fri, 26 Mar 2021 06:39:36 +0000 Message-Id: <20210326063944.31683-2-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20210326063944.31683-1-srinivas.kandagatla@linaro.org> References: <20210326063944.31683-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 Acked-by: Rob Herring Reviewed-by: Pierre-Louis Bossart --- .../bindings/soundwire/qcom,sdw.txt | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) -- 2.21.0 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 26 06:39:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 409468 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp1165114jai; Thu, 25 Mar 2021 23:41:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwxYsLFXeSSO9VcJ9rVxmxVb5p+R+HCakLRZ4A/LvLW/6npqx1K6CdEcm4P7ee0IDy5JtWR X-Received: by 2002:aa7:d917:: with SMTP id a23mr13180572edr.122.1616740919754; Thu, 25 Mar 2021 23:41:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616740919; cv=none; d=google.com; s=arc-20160816; b=JpyFzQaIJJG2lquPEIgCQQJnQDn1wTXQ6xJTd9Etu7m4V05AJMmZ58U3UqjYa3laxL eqE2Cwax1cbTAegxSEUmttLWqOhwz7n1aR5PH+EgHwKYz4rPA4elZ1/sjn9R2KP0YT39 yySt2GrRDGFGK02GcnC2VA6KXTWLvh4Wfi+sWOz/eMbwaPSB/RH+z7S2q+7JLBo9uQ8F JDXBbKI+ZnlwunL+4/DH/TlE0JxMCiF4CRg96N7uWW2AoFPvq7Dnci4poMCD7zcfwJvQ h9t3IVPUjOHke+2Jz/figUt/oUDuuq9ypnLRNATdafdTOs8lmbihNzQFLvOcI65w1aNK ePmA== 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=yrsv2Wcm36Tutr6ABacUE+c4Ip9KYPFLtfy7d1EDOFI=; b=FsI9CAWCu2R198LJpBaMBR9RyEwDPztTV/R7PkFlrW/mAKtq0BM4u5zHFTa9v6en6A 5WpTc/zPv3n8Yqtv8WVfOcPn0QofnYYy2yg9ZZcmyqBg9QHOI0uIpyYwnLtex8fYrd5B IIGe/LXLwltdW2QRrvM+3d47ir0x5r8ojmG0xqrCaWvwS0XMh+YPaBPcREGSJipayfcx tH3m0klKHurzZCkWwTT9IFHwZMU502vSNOGAQ2RHpFt6mO1voj9QtFvJLEx5LovTo5dO HPafUcNQHgVqfWD6cFG2mq4sdMa++JeJ9dEGLcMAF6ErBwnupc4xj0FFHRk1QnkU9OEl SyeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qjhlG4wd; 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 ce20si6378091edb.34.2021.03.25.23.41.59; Thu, 25 Mar 2021 23:41:59 -0700 (PDT) Received-SPF: pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qjhlG4wd; 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 S230195AbhCZGl1 (ORCPT + 6 others); Fri, 26 Mar 2021 02:41:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230105AbhCZGlT (ORCPT ); Fri, 26 Mar 2021 02:41:19 -0400 Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D04EC0613B0 for ; Thu, 25 Mar 2021 23:41:19 -0700 (PDT) Received: by mail-ej1-x62b.google.com with SMTP id a7so6785866ejs.3 for ; Thu, 25 Mar 2021 23:41:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=yrsv2Wcm36Tutr6ABacUE+c4Ip9KYPFLtfy7d1EDOFI=; b=qjhlG4wd7NnoVdhmdpvNGRBsWEAKlQySfl7HAD0qjkEc2eE+7+0gvIqVN2VnL9KWww ziCyek6NYmVp29kUsuX+iBfiDsOtpuyp0j6umrwI/K6qMU2aSDUPI9ekIrZ1hoGLYWa6 bkcxlwuQj93e2f3or6+m//LzXiR910hLPcg9VW+PcatN++lJMfCU18iJSJpEH8tVT0yR BjEKHj9pfI7QQbXTDGp7MA8yv3ucp/9b7DmstwSTbRcKwziz5LsdxKXUHkxv6M0Jy79M kyf/Vm6JMtI/lCqaHPythHnvvQ5Kjd4yyUe2R1G2wEKk7NaqbSOwtyTM5xWPhoaBXwii cTqQ== 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=yrsv2Wcm36Tutr6ABacUE+c4Ip9KYPFLtfy7d1EDOFI=; b=lch4oFbFiEwQN44JkZWaeXNh5tLMq7VjNAmIO6MfkzTaJ3JQ5WGMzuX8gkMBEQlQgb mwyMZECxjRbZgN49DV+kQ5r6H34hqB5dQmIBYWWAizvSJqQZTXJkLBxsYvf+jno7vFpZ KFlbhVGQka+EsU2mKoyndvIA0c6BcBj70IgY1wM4bibJebZ70OJ69XqJf8teGrXQTWKt LL+fMlMc0xKhHR6Mx2opIvw8X4DYmKlEitQjvsWXx3CDpfBsEOCVP/A+NRBBt6T9Ovkl Qd3Axepm34SNUjlluQfYZMsgihFcgQhEdWoHmKSQNYVRXgk/20OZ2KLQu5paXn8TNKpu zT1w== X-Gm-Message-State: AOAM530VSbkKNxMqkkdsWJkyQhCc+zHvFOcl7wM1Hdz+z6chiGj2hBG4 Ee1zE0rnrdk5Ry8vM1qx+ELsyg== X-Received: by 2002:a17:906:9bdb:: with SMTP id de27mr13819151ejc.459.1616740878072; Thu, 25 Mar 2021 23:41:18 -0700 (PDT) Received: from srini-hackbox.lan (cpc86377-aztw32-2-0-cust226.18-1.cable.virginm.net. [92.233.226.227]) by smtp.gmail.com with ESMTPSA id ci22sm125325ejc.54.2021.03.25.23.41.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Mar 2021 23:41:17 -0700 (PDT) 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 v5 2/9] soundwire: qcom: add support to missing transport params Date: Fri, 26 Mar 2021 06:39:37 +0000 Message-Id: <20210326063944.31683-3-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20210326063944.31683-1-srinivas.kandagatla@linaro.org> References: <20210326063944.31683-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 Reviewed-by: Pierre-Louis Bossart --- 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 26 06:39:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 409470 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp1165123jai; Thu, 25 Mar 2021 23:42:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwcAXZ+aW3Wgvr+B9mUBRBmUlh2J1ZR6vX30OUTfAcVmGYeNWce+UzNyqeDwyRSTcrxJR52 X-Received: by 2002:a05:6402:3493:: with SMTP id v19mr13581867edc.355.1616740920985; Thu, 25 Mar 2021 23:42:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616740920; cv=none; d=google.com; s=arc-20160816; b=m/fDBVy2LmpDDM2BTz5LDdjfgc4mXbkUHPB35Dhyggn+OI0FO/dy6OrvQcasqCHAs+ IDg00MC6GnlF0eBEnx2XFPJqx59K3MGWd0fknyQM14VfXC/xBrlW4hSaIejVIOkI6xdL cFca4FDwUBXwiqpW1lp9/9pcacFIHHaJL9O9xlS7qI8NpRGIuDeh+xEXdk1dUu6/FakO 30Jd32Fyw3uEtm37Gy7BGACSgdMHvMNtrS2FKRNMj6sOdC51Tpy+R0BvJCA9/j/vsrO8 27Sds4Y3k9zl0takhxLAnJwTG9dO9H6oXCScPYWlfXnRhO5TvzFOydlilyJVgACeLMU7 gUtg== 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=pBsk7JwZ/LZ6cSzAnPDMM/93PskvajNpLm1bjDKAXDA=; b=o0qTJ1BJ36DHSwRUS891jy61yJCGE4itKbIMMU9bOv0ee1melB1XQYYkvG/cvKJKue S1UlC1YU1u4WIFFsag0v7B1qHw7okNKg6izkwWxjc/Uj7p7YrgZq5FVzp2dz9PxRjWGN t7HQy3+r1cPSj6SMki4PYAbS9NxDBrCq4hzXcUvnzvBTUpdB0ZXD00W+TzVdPWRZwMaU SozDQ3amxZiddNYhB01PNL9QpkL/7GYrM/Zq5LMptsoNU8ZQ7qSyo/9FNkxX1v/0MzNd R9j3pC2PzjGGKUBttcDwIBy+/ztQCOv+tRCTgZl9+j5gkq553d2FjxFYuGMKD0eP9BFP fX8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TtM2fa7P; 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 ce20si6378091edb.34.2021.03.25.23.42.00; Thu, 25 Mar 2021 23:42:00 -0700 (PDT) Received-SPF: pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TtM2fa7P; 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 S230105AbhCZGl2 (ORCPT + 6 others); Fri, 26 Mar 2021 02:41:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230107AbhCZGlW (ORCPT ); Fri, 26 Mar 2021 02:41:22 -0400 Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63728C0613AA for ; Thu, 25 Mar 2021 23:41:20 -0700 (PDT) Received: by mail-ej1-x630.google.com with SMTP id jy13so6784145ejc.2 for ; Thu, 25 Mar 2021 23:41:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pBsk7JwZ/LZ6cSzAnPDMM/93PskvajNpLm1bjDKAXDA=; b=TtM2fa7PbzOgQLB4fpw6IimpLrH2OIlw5m0waALp7JmZ+C3gb5XD8n3yBIREwNonVa eiYQVl4WckcL3VU5o6QVL9+Gt21DvsXfwX83rwmtT0IvG/p2VEz3u5m9IjoEA+B004RT g+GbAD9CBQbkk/Yaa2PmOIEq1C8DIPunDBpI2xttCSBMJG8BG7nj+xtBxiJp07agBWdY 2SYEGcnSUiOqGU0hsvdaYPL4c1pQ81TDFomf619Eo6/we+hcPB44KSSX92+wxneFaQi/ 3YulS9egaP/f79BP6NJ3BF/VuYgahZqoyMrzJYyfntol5uOV1EzXjFSdErmobMSOeNpM bAEw== 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=pBsk7JwZ/LZ6cSzAnPDMM/93PskvajNpLm1bjDKAXDA=; b=OuA7x9/ARbLxFg5lYLa7qwnnNF5bSQBJvltHMTK48ZqZUUnoWekI1IRDWP2kjoY+cj 6x7jj4sQn0nX36d6XAsiySe8lONNdHnEPDCA/jnRKgUf6R7G2vPQiz47LrB1BW1y+uNU /H0edaOdfe1p+fHsvwSW4ax7vgXpiQqnvI8vOv7jkBhtfbulyzV52bxM2zDKhQLx+ZBm yWkDehhepyWVjTQSrB6vl5Du7d6Blcok763X4g3UaGTwwJGz7hyI1qT/pTHcruvr+0XO wtLk7CwxlTPf84EAWs/VXL0M5z5DXams+sCPlmr/35XBm0AWMub6ol7lcSI+5o86tEqy PleQ== X-Gm-Message-State: AOAM533Aj+ZR4Rr+8sBPP83o3tGzjEZMu9ZAO2T/zsSYv1E0eQ8sOQZa s+4uBTLNRdDNKbyobBfGCKqoYQ== X-Received: by 2002:a17:906:72d1:: with SMTP id m17mr13391086ejl.118.1616740879057; Thu, 25 Mar 2021 23:41:19 -0700 (PDT) Received: from srini-hackbox.lan (cpc86377-aztw32-2-0-cust226.18-1.cable.virginm.net. [92.233.226.227]) by smtp.gmail.com with ESMTPSA id ci22sm125325ejc.54.2021.03.25.23.41.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Mar 2021 23:41:18 -0700 (PDT) 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 v5 3/9] soundwire: qcom: set continue execution flag for ignored commands Date: Fri, 26 Mar 2021 06:39:38 +0000 Message-Id: <20210326063944.31683-4-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20210326063944.31683-1-srinivas.kandagatla@linaro.org> References: <20210326063944.31683-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 Reviewed-by: Pierre-Louis Bossart --- 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 26 06:39:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 409471 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp1165316jai; Thu, 25 Mar 2021 23:42:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzXFrhaDGVdyvWmv11t26759nbAzKahAYj6XWhJhyc/XE5xtVD1Egh9yjKOWSTGz5c8Gx43 X-Received: by 2002:aa7:c907:: with SMTP id b7mr13202488edt.37.1616740950474; Thu, 25 Mar 2021 23:42:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616740950; cv=none; d=google.com; s=arc-20160816; b=Fq+aEn1mxHMk8waNi1H1Srj79yQPR0s2MzFdsIGJxi0zhgrIvo6Tdu6C723W0/v31n iEYgax4IL2Lm26cudFxuwV1WMclgQQTizucwKgH1xWhAWsJ2ITvJGC4kJp7rHLSlvHgk NNCaV7eubn2TmusajXWo0lQf1+nvW0X3urV8XtUaJYHPz+P6Oza8W0u2Di7YUCDrjwlo txs4egVBSFVxyth5Xxks8j/76oKAFqAQyYuRUeCZCYE0QUuI9HyhO+0hkvSomc6DwodH EpQVrZ+u/tM5ht/rLnoy7cj7SiGXMBHIkuvofL7J614VGKmQWeu0ByfkBIfts95rRuWi ZjEA== 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=9w26BSmosHoWqHb4DQ0FR/rFMhDz7pjkPie7BkwBXHY=; b=FIk7gPqgewAvnHO21sfgnHnL2z9Btxwynh5qXZ3QU7SEzTnWdNbZve2+Q9PyF/pPRy JBP5MDmhMiLgN2AuVK+l5vJ9pJ3I2m6RTZIGqAqr9TUzY6vfWKOigUEqcAvbFYwEN8BK EgN1BdoEy9Oxx8SXMb1OlfhBCZENcoUJc61qZbJbhyD+C14QaKwz67WwTn9bgPgnariQ gwlAmNFwfMlWqB1iK1cqMjywXliYlAJXJGYHXq4XWv75SU5d+WZj7s3YBCqxmO5OccUo uQ0Y0TDuPyXUqJMUIVEx/ujUXMrrqr1OHBg2935vCfa+fB4yMh09Xx6O0w+S8tRUcIgx CetQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xvmNm1nf; 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 p11si5754958ejg.105.2021.03.25.23.42.29; Thu, 25 Mar 2021 23:42:30 -0700 (PDT) Received-SPF: pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xvmNm1nf; 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 S230319AbhCZGl5 (ORCPT + 6 others); Fri, 26 Mar 2021 02:41:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230131AbhCZGlX (ORCPT ); Fri, 26 Mar 2021 02:41:23 -0400 Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78710C0613B2 for ; Thu, 25 Mar 2021 23:41:21 -0700 (PDT) Received: by mail-ed1-x531.google.com with SMTP id dm8so5084388edb.2 for ; Thu, 25 Mar 2021 23:41:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9w26BSmosHoWqHb4DQ0FR/rFMhDz7pjkPie7BkwBXHY=; b=xvmNm1nflRIeRx4LkKSGcrElPaSbjF1kN6QdiXw9op+BvHN1V7Jsui3LT/t16Kksh/ RUKvfI4eDhhoJ7iFtaSpqk5mNYgh/mQMq+14xsE7KfK7Q5E1StGvvuuTh63rEXc8O2up xr2yn98r4/w8XonH/U89vhJmJjUYwbBTtcVjWPO5CGb84EBxwRcwz6IM0ikFDD6eSa4A aHS69DHtyqniONA1PeBfIi+aWSvUGlgndvZdtXEW2C7fbQE9p1jXoCogP1n/nfiYQu15 I6cN5/AFcIC4KJsLnQkdf6iGTeWj6aU//HBeFGmilGb0K8y8jLPEYwM780wVxR5wDltp Xh+g== 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=9w26BSmosHoWqHb4DQ0FR/rFMhDz7pjkPie7BkwBXHY=; b=IubTga7DbhS+k1JBtDjzmOreMbjdS7fEfZBvt5ni6HwwHrDFfI5CiaJxitTjTUDD79 U8vu8+YMeOYtpY90gExb2bl+o+uBTk3A9p5P/0WIbuPUYJ5Izx8GXTVTXv5fkX7ScIMU AR+JFpAAWAc7XDmGAUtG4T+5w7aCDJYPGe9hyIlVlZl+I8qAN56mD2I9KCfZXcubeD5F 1zGzWIqhsSmU+CERsVw0V3IMD6FCfSH2jH91mHJQ6Ph6qn41AO6YcJtUEW0xL2DfzYQM FLK+qYETFr4GRFYqXUUNfPfoZzH7bA8f1G+CGFvMzQOcTAztu5Sh+hmJJGe/QMj3xc+B d95g== X-Gm-Message-State: AOAM532tNjAXpC/PVhfxOcm1zPBWK54Fgqi5SY7vXaxUP+voq1ibgwh8 765xAV2v6GLxtdgiGyd29IEOXw== X-Received: by 2002:a05:6402:104c:: with SMTP id e12mr12739081edu.108.1616740880178; Thu, 25 Mar 2021 23:41:20 -0700 (PDT) Received: from srini-hackbox.lan (cpc86377-aztw32-2-0-cust226.18-1.cable.virginm.net. [92.233.226.227]) by smtp.gmail.com with ESMTPSA id ci22sm125325ejc.54.2021.03.25.23.41.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Mar 2021 23:41:19 -0700 (PDT) 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 v5 4/9] soundwire: qcom: start the clock during initialization Date: Fri, 26 Mar 2021 06:39:39 +0000 Message-Id: <20210326063944.31683-5-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20210326063944.31683-1-srinivas.kandagatla@linaro.org> References: <20210326063944.31683-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 Reviewed-by: Pierre-Louis Bossart --- 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 26 06:39:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 409473 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp1165338jai; Thu, 25 Mar 2021 23:42:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzMxbZIdQwUBffg/nYmz8cYmsqaGMtWQBIgVCzi/dEgAlAgP5SA7oL4BF8SOi0EB8LwaZDQ X-Received: by 2002:a17:906:c08f:: with SMTP id f15mr13626329ejz.318.1616740951934; Thu, 25 Mar 2021 23:42:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616740951; cv=none; d=google.com; s=arc-20160816; b=CVnjoppZCq5gJ4MmPkOQ3qB/zYk8KA3nO4ywaVDDgpW9BHM3UwiTJRM/EWQOjCec1c UH9rfBGi6tzo+L9BfMMtpeH2la9JdVKjWrHLDOOAD+5CBSl7NEolyywzjQiUtyeR8g4a pVxRCNdY/zGdJPSypbK6v8aXLarK9f+sbpXWV3CyQewrfw5fwlQ7NTwKblVVnk89qoCq d1QG22a2DJMoG4PSh1QqpDYvlgHFGSeIUdrbdCCVMXiaVPIQMOh4bA7h08kpNrlMK1YU TGiXLbX0De3pCztcDK4y8ibyEo5N+xfjyK2JqI0bkIOVCP0u6kkAxOR0AD4sbdmN1/3v t9Ig== 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=tqsKmLEvrwdPhmuMzUrjlU9RFEkvVfbmgNXNut1H8ME=; b=QZyCywTVp800e+LmE7f7eRtA3iNwHC8Ga5s2kXnTUmMEva/bhBB1ZTUE8o8/ZepYSV 0UvNthv575GLiYqBS57nA9oxISfOjPOzru4hrPBhJWRd6V1OuHT/+tRYnWKbMMIdSq/t Vl1AlW/9GSTME8DtqTnBTVEjC9VwFQRbsOfEhNUlT68f50ysx8LQLvnKpWoiq4o8xw54 9PTEMMOtQZ/sxcZtQvrCNZGYFk5SN0wd//NTxbQ2OeakrhoBpaqp3xzwYGx40KuH2T/x +T62ZrsXfAXjXrye8fceHLTEER+y4EgDwsNMXfrHo0Ycg7x1YSafE9Y5tpCPkRsT4dpp +LKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="B/LjN6DL"; 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 p11si5754958ejg.105.2021.03.25.23.42.31; Thu, 25 Mar 2021 23:42:31 -0700 (PDT) Received-SPF: pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="B/LjN6DL"; 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 S230131AbhCZGl7 (ORCPT + 6 others); Fri, 26 Mar 2021 02:41:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230147AbhCZGlY (ORCPT ); Fri, 26 Mar 2021 02:41:24 -0400 Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E73AEC0613B4 for ; Thu, 25 Mar 2021 23:41:22 -0700 (PDT) Received: by mail-ed1-x536.google.com with SMTP id l18so5047566edc.9 for ; Thu, 25 Mar 2021 23:41:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=tqsKmLEvrwdPhmuMzUrjlU9RFEkvVfbmgNXNut1H8ME=; b=B/LjN6DLJvci+guequLaUflHU+kCCCVoBZLQUCm3vpvU5xGOdTIM1Ka9yWOUFtkcUl O/D9MST72Di52yOc4VpAB+JxsOV64SDv6crD3Y3cNt/kpzFZFM4CpicamrKstErYKsSX sJ5I7kQpFP7tUoJtEubbHOnqUjJPdMYs/9rex3j3M/MUU2NJK4Qx3MREZikoEu1lg6Jz Rzn4uPuCx2/IspgNBFArzr9jukIQXhlJzmzjxKKNlW8n3Hf3OfgRAMALdtwg5gWWzh/9 hyWamgRdQY6uU4DzMpu1jkRP1QBXRFJTwbRz+sm+Ghs9TZ6i7v1i5U4m9u7Lf0UlUaiA FOLA== 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=tqsKmLEvrwdPhmuMzUrjlU9RFEkvVfbmgNXNut1H8ME=; b=D6YB4vt2z/1Ln0n8Gkdc9mOpH/6uYJpWmIEuH30R5CuHQMu72HVTn5qzvCkqL9KJlC 0pGTTmX+X+3LVzrdXdBcQymnEJeFFU6FVxOs2CTVwA2mqcQ40JG9+/AWzB/O6jvCmoz2 saMzpLGyMV9xBjjfiU+BShcajJbe1DtKackuN+4nCGqKjud30fLshIehnokDcS7HmXGo tk9oYhdTea5diUOlWQtCKgr8HQH7N6xrvHaLhCY65p5rIAyX1+tRqz601Z9KQdpMnbtI CcS2/GUUPYrkZYR6U7xGJKSTZJ9QfKlANQUf1TtmYOIt4qTuYZjOH5MM3C6LWW1N8W5x 3BqQ== X-Gm-Message-State: AOAM53076TnHbMTivdY3afjOWHd+axg1VPo1g7I7WrpQN/Sqoy1Gn0bT +AJcTz46piDVg4LiBzFh+d6dSQ== X-Received: by 2002:aa7:c342:: with SMTP id j2mr13429464edr.8.1616740881327; Thu, 25 Mar 2021 23:41:21 -0700 (PDT) Received: from srini-hackbox.lan (cpc86377-aztw32-2-0-cust226.18-1.cable.virginm.net. [92.233.226.227]) by smtp.gmail.com with ESMTPSA id ci22sm125325ejc.54.2021.03.25.23.41.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Mar 2021 23:41:20 -0700 (PDT) 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 v5 5/9] soundwire: qcom: update register read/write routine Date: Fri, 26 Mar 2021 06:39:40 +0000 Message-Id: <20210326063944.31683-6-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20210326063944.31683-1-srinivas.kandagatla@linaro.org> References: <20210326063944.31683-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 Reviewed-by: Pierre-Louis Bossart --- 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 26 06:39:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 409472 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp1165324jai; Thu, 25 Mar 2021 23:42:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx8dyjz7P8ffwR8rKEcUdKjwvN9cb3ZD5pQJxBBPesOl7W/eoHp378atWx6qwmxaoM6dTC1 X-Received: by 2002:a17:907:d8b:: with SMTP id go11mr1456995ejc.167.1616740950859; Thu, 25 Mar 2021 23:42:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616740950; cv=none; d=google.com; s=arc-20160816; b=LbYCWqFPWNj6Q6LHU3PSlLRhpCCficBPtmX+FxT4ZrJS22fWjy0nOj4i99cOamaU0P qTHz7E7bcQ+oPJzzk0yRudxXc4P+LSr2OC3KD+fS5WgXlq38yXA4Qmys2YCkOv3m0IXX Vqe+z/hXLd6B2RFReZsSS69WMtn/ss32Fhbah6b4RdrAbQ07bjIqXJLwXFgEusViXrxn AnQKE+KuPW7cz0ZDQVDBwl1oa3/Mj+X6VCS8QWUhbbm7J7hcEkhxPEN6XzsP+bp+ciFP e1xLamM+/QZce6yuHNddkUyQfz9+/E15Q1vudGFnRA529z28z2pA9ZZ4QDi2TVKbnSrx E3Bw== 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=ENz5XBbvEDbbbtw8iA6jo2aOeQQAzNhPJSQZvZsIFcY=; b=Hd5XWDQp5PSKWFFBpUqJLmfMbaO0bwE+wc+uiWZdA49t6HVC85vHc4JpVRDewPrMW4 3zcfAxjgZGoxZKyErFcJGa5FeVvla76U6HYMp/UnRZPxJRF1ZL+85rggxHT3F7nclB5i E/B/8KiYcXyObc6LargbGa5YRSCJISjj4ce0RyUAz2vEHGNOUXKlp3C+UjwugkqXhuWm WYGFWe5TJ/y17weWEqvO7k31RaK1qb8IqhnoLRil/RaHTFPAcvv6AEX+HYnme3XtYKwR o3l0hNYHUwfgJGRzGPeDD2Gf+CHpwVfcpNIPLLD1ATZt9N2nV1hqpIFEGNczmKZZcrhO 6WkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=t0K+FB49; 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 p11si5754958ejg.105.2021.03.25.23.42.30; Thu, 25 Mar 2021 23:42:30 -0700 (PDT) Received-SPF: pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=t0K+FB49; 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 S230134AbhCZGl7 (ORCPT + 6 others); Fri, 26 Mar 2021 02:41:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230155AbhCZGlY (ORCPT ); Fri, 26 Mar 2021 02:41:24 -0400 Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ABA74C0613B5 for ; Thu, 25 Mar 2021 23:41:23 -0700 (PDT) Received: by mail-ed1-x534.google.com with SMTP id j3so5021750edp.11 for ; Thu, 25 Mar 2021 23:41:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ENz5XBbvEDbbbtw8iA6jo2aOeQQAzNhPJSQZvZsIFcY=; b=t0K+FB49i0EB8i0bKq6FlIB6jT/8VZNPaM0qKcZF8VlixXk8LlkAJHWNxAUqSmN5xB isO+N1x52Cbz/aCSrvnQCwf9nKriAK2PnNdDyf0Hp9kU8ZrYNVc4HuA9YkLhC9W4f2jm YLYVmr/ywto8tZXLdE4BtQalu5bzg+pNkGvpkR2Z0cpgiSh02RI14msKTDJyr67z+nEq wwodbIe6ADWAJieaV8AZTXhTWfbEUfKp4trCyQF7vcMt++pau3ClTpfSrDWSRpMLL9KA Z0eHnnaJmlW3MfpyYTTXVKbYmJbDo9Ayk4TcUBhhK9iBaSqVEpRkgd0ePrblQVFRwRAU /P2w== 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=ENz5XBbvEDbbbtw8iA6jo2aOeQQAzNhPJSQZvZsIFcY=; b=Hh+ufX80LRADiO7zoem6FFBr0ZZF+L2KL2NHzr5Xbl4e1uujAqFMGq7Xk4ELXiwiq6 3NpzapXgeSSbLmqU2dMmTqF8ZNDOOeX4nqWXUV/7ON7CDGjdzMoqVeGwM/kihoEXwZ0A Dse+ZiQXd496utI9+wj46JGZPtklN83UxfYiuuexkoCyKK9hrkcBvjto20vn6hFvc0rW 43cKO/d2vrCGLsY0NeZkEJlM/dgUqw2HEyjY5dvNCz7zqAoA+BG8T5Wy3Vm7HuhNb4fC lojbHBuqoOrLLzP4+sqZz3Zrtt1IvDTMrY3RFLASp3RKdnU9Q9I4ArPawoRHdAJJsCKO 2EBQ== X-Gm-Message-State: AOAM531/NQxa8Mu3aYZ4bTmP7mST3SITxz60RW3n0zwUZRj1YTtGfEvy Wb69DnT9IBSbgKFnWhDpq0Mpyg== X-Received: by 2002:a50:ed90:: with SMTP id h16mr13138677edr.101.1616740882396; Thu, 25 Mar 2021 23:41:22 -0700 (PDT) Received: from srini-hackbox.lan (cpc86377-aztw32-2-0-cust226.18-1.cable.virginm.net. [92.233.226.227]) by smtp.gmail.com with ESMTPSA id ci22sm125325ejc.54.2021.03.25.23.41.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Mar 2021 23:41:21 -0700 (PDT) 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 v5 6/9] soundwire: qcom: add support to new interrupts Date: Fri, 26 Mar 2021 06:39:41 +0000 Message-Id: <20210326063944.31683-7-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20210326063944.31683-1-srinivas.kandagatla@linaro.org> References: <20210326063944.31683-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 Reviewed-by: Pierre-Louis Bossart --- 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 26 06:39:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 409475 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp1165350jai; Thu, 25 Mar 2021 23:42:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzb74n7lwFL4sXAl20zUm21NOMBN+X1yd2RjfGzJQqNPE8WdWtu+/Bn05BGjPvH8k/rjTuz X-Received: by 2002:a17:906:4146:: with SMTP id l6mr13928046ejk.295.1616740952761; Thu, 25 Mar 2021 23:42:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616740952; cv=none; d=google.com; s=arc-20160816; b=MIaqIu9ryXFNnnMSH6Y8elocPFqNWP8RAViHAC4MzdrifDbFfIOqypsWSUCwWF2AEc hZ4Msv/8BQMKiD3wGFaNaybb7HxxsGHlPi/Vg7QQLApeHKq1QjyME1t41bUWgMStvgkx jA7HP+ge/Xz3wtgsSThazHjrLztFqlbecwnx02/SWbXc8X2xLg9HNd3WiWpM1RG5P3tC 1kxHo2hpCIeRI79FK1nO7W7gr0lxvtykGiL6hznm5X71h7CwSb74X2JNHpC81PetH1Hc vqah1Na8IR34afz+i2w9sY/oXZS/56AjSLYMScUlFKy3LPCGPgt6c2jiWkPiVEasgdCx exQw== 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=P8VaQolGFCOR51eNrv/jk6ZLBrbbZ7X7Ltpf1LoAnjQ=; b=bwmg1UxQmTo5mKR+lvO/UfWqAvmS/xUIeVEO8Ea/ZzmM6qYwlKQA7BRDOhVItGxRb5 kVgBUC2hVsq9jgIMZa+Ghu7KHOo5y3haAdMYGCd0meTKbNM4GLcWljM5UABPBPkRCQoO Er3d4hqm3POSx3KWlAAAbp2t4gOtnZERgXyYBeyFc7A95RWjy/N/AfxPSfomfD7QOMka 7iLttNEWlYUYDMq/R43NpGID7CrfTnG0LFv/ObOVMAHXESezVauZYfub2+7j27a3A/kY MXrbsrJVkpIzBDPmP6wq8KxcfI5z9Q2QxjLIgWZ/OhAudDJk1+DJtD7wFTpwbKK194aB zxqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="r/SymDir"; 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 p11si5754958ejg.105.2021.03.25.23.42.32; Thu, 25 Mar 2021 23:42:32 -0700 (PDT) Received-SPF: pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="r/SymDir"; 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 S230238AbhCZGmA (ORCPT + 6 others); Fri, 26 Mar 2021 02:42:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230182AbhCZGlZ (ORCPT ); Fri, 26 Mar 2021 02:41:25 -0400 Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC522C0613B0 for ; Thu, 25 Mar 2021 23:41:24 -0700 (PDT) Received: by mail-ed1-x531.google.com with SMTP id h13so5062120eds.5 for ; Thu, 25 Mar 2021 23:41:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=P8VaQolGFCOR51eNrv/jk6ZLBrbbZ7X7Ltpf1LoAnjQ=; b=r/SymDirP7YsfplabAthL2rjNIEsp2UpQhJ6IQeQAt3/I84Eynq5qj3dKhWsBQR25L EBBsBag5vV+/5jRLbAvlnNuKJfLDGFuctI6aeFt8PvZSCh6r1xcAO2czt/JbOeomouuc aW0dptOiPwQYDJiYCZkgHXSdkJpNqoGgQxnldzOvvj0NGKKnn0Qg1Po74+7FMe5YbLCv tNCDYWEdxvXieEB0EVWMuDx/nh11yG+8tnj58Q639qX0mSHLMcVe4XYVLMQ52Uob4PuR rrJS+hycvoLfGbgY6Gr4k/vE3013BDdBejvCU0kPC2go8TstO2TooFkSAiHnmL5aRvw1 5Lig== 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=P8VaQolGFCOR51eNrv/jk6ZLBrbbZ7X7Ltpf1LoAnjQ=; b=i3S/1aC4g8y89QUoi6zXmSJ3+g2R/ttLehQmDDsCz//XWEOoXn0KeSGxom/QQtCvBN p/mRrD9GjrJCIxOw7Tf5jbg9ipW4tFhgy3I9MTH1Q3MhHt9j/QEEX0MTVAvvgmS+qS5b AtD102may9FvdsuJgFPrJOU1ttK6Y1HwVhw2XxsJS70DmYO5pHjmS2sY9TX4UYRv1YSV 6eqQYXKrzbiKfcOURq+FRTeP5s6ciCN0w0Xihykmt/RuslSV1WAlahhf2vmWWJ0A5bQs N0P/UyP2SyZBktwGszp1iG4/e6cqcIRsIgKOcv25JunO6ETyWBqIlBl3ZGAyvP0TwUM+ 0jgA== X-Gm-Message-State: AOAM530ESxaPI71p44HivW5Py/A1XoE907opvXSYN/Mi8rlZHU2L9H6c SRtS/xi3thqBDg5VU8XoH7n4rw== X-Received: by 2002:a05:6402:2695:: with SMTP id w21mr13146872edd.99.1616740883626; Thu, 25 Mar 2021 23:41:23 -0700 (PDT) Received: from srini-hackbox.lan (cpc86377-aztw32-2-0-cust226.18-1.cable.virginm.net. [92.233.226.227]) by smtp.gmail.com with ESMTPSA id ci22sm125325ejc.54.2021.03.25.23.41.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Mar 2021 23:41:23 -0700 (PDT) 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 , kernel test robot Subject: [PATCH v5 7/9] soundwire: export sdw_compare_devid, sdw_extract_slave_id and sdw_slave_add Date: Fri, 26 Mar 2021 06:39:42 +0000 Message-Id: <20210326063944.31683-8-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20210326063944.31683-1-srinivas.kandagatla@linaro.org> References: <20210326063944.31683-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Exporting these three functions makes sense as it can be used by other controllers like Qualcomm during auto-enumeration! Reported-by: kernel test robot Signed-off-by: Srinivas Kandagatla --- drivers/soundwire/bus.c | 4 +++- drivers/soundwire/slave.c | 1 + include/linux/soundwire/sdw.h | 2 ++ 3 files changed, 6 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/drivers/soundwire/slave.c b/drivers/soundwire/slave.c index 180f38bd003b..92850e150d36 100644 --- a/drivers/soundwire/slave.c +++ b/drivers/soundwire/slave.c @@ -88,6 +88,7 @@ int sdw_slave_add(struct sdw_bus *bus, return ret; } +EXPORT_SYMBOL(sdw_slave_add); #if IS_ENABLED(CONFIG_ACPI) diff --git a/include/linux/soundwire/sdw.h b/include/linux/soundwire/sdw.h index 2f52d6609076..f9003ba056ba 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 26 06:39:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 409474 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp1165346jai; Thu, 25 Mar 2021 23:42:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxxO4LuOTKR0PyeLZ8OiW+Kp0A/dF//sDkKcG+I1FNI0y/XD/cVC+kGaqHR5q03BQgi4/86 X-Received: by 2002:a17:906:8308:: with SMTP id j8mr13214688ejx.339.1616740952382; Thu, 25 Mar 2021 23:42:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616740952; cv=none; d=google.com; s=arc-20160816; b=Pi8CehEoLSFT24TewkEPID6+0htWJ8+bdNuDwuIPu3gXmPEbcRKLPkL2MYqSBVRqkC QLeTCGDYOaAZICxKpyg1Phg6YPf87GxSlVLbYWhj50zclVzPiAXskJMY0lwBAwAum2R4 PlHEfUcsgOfclSuW+BAtORGIkBnW+nlbj2LPe4QG9pWK7NrSsnnCw5W9M3fiSzZVQSBe BsyRNA4m2XAr/WCatcEKfs1rbSqtaO7TRqCaGQX7usbVrEMp1nasqB/FQaqxQtc4d21D 0YH7vjzVgIa89K0Kk2kPnXl4xmWmrkGjg5CDEqsRXrLCABr/EZytsHFQYseicOMP5Ify KW8w== 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=n+0SLp5bys43157dIPELL3xi2LwO4Hd+7UwWQjJAfcc=; b=R3nGRaO4MOUzV2ApV/m8na1yDAkE9rNeZZck3lk17L7P7h8gEZ9s+mJXkljTv0iyWB d+I1bTExozo36hHmsTPxOwJMKbQK6FkgA6kDenmi9cj/M2ZWr/iwAdYQVw7ArUwCt2SZ x5/g8RFxnvaAMDKZIPPIkjL+g+D/7lXZrbn0fZX6n88SYOBm9qgN+MP4XrK1PT23E67d DIkmewGx9cr0zFy+FUqAnCACJjIbaykQqjv7+Q+OviHJKo5Ai4DVgmBo/3wjS08Jg5vz d3drXnA6qP8eH/xPMyN3mAYK3wQL5BUSe3drVAWqHnJcY9DSDtWhd3FBwzgAF+GSyX0H D+OQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="JoyAMkb/"; 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 p11si5754958ejg.105.2021.03.25.23.42.32; Thu, 25 Mar 2021 23:42:32 -0700 (PDT) Received-SPF: pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="JoyAMkb/"; 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 S230182AbhCZGmA (ORCPT + 6 others); Fri, 26 Mar 2021 02:42:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230191AbhCZGl0 (ORCPT ); Fri, 26 Mar 2021 02:41:26 -0400 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D59A5C0613B2 for ; Thu, 25 Mar 2021 23:41:25 -0700 (PDT) Received: by mail-ed1-x52a.google.com with SMTP id bx7so5029477edb.12 for ; Thu, 25 Mar 2021 23:41:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=n+0SLp5bys43157dIPELL3xi2LwO4Hd+7UwWQjJAfcc=; b=JoyAMkb/CytOSLNJEkTp63AUySgtJVGlnaeGsk3LbwZYQOUMwTiruvczpg6DNGjQAR o2xW20EAm6R97lv/lkN9XhJpXrCG7VdGuguIC9RaarehuzEEBD+7XEBarraCKEMT7ROY egLuGyKcaRR6rHzi4GD+jHywLlrp3U7IBrp7cV+HM0/vJ5mMX1FNeZCJA0O7jSiSPpkH R7S1wmIsroPI16FceH7EUrzdGvKF279UYYG1plhjmwqiPggvV6KDp1GuW1dk/VutwnwZ mkoOhY0EHq+CL84h1BG52bSoRKSFGH7JJsuAKPlvXthKrp0nttl7aI+nwUyTRcKfX4Py nJnQ== 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=n+0SLp5bys43157dIPELL3xi2LwO4Hd+7UwWQjJAfcc=; b=BEhzCBsnFAq79aJvjZh1gu0upc5Vzg4YOa/epJ/8G5kqRCqjMEWn24aKh3LUF5QSE/ Jtczk4w1bkXSrS4TIXGf1ugvJFx/nZayoEef7YmIvyw7cqHqzaa2pbW+MWvYO24+ydOm x9mH3T4glaKZR4jfBEpH43BqJpUB6K57fbmSsPLiEjERH2L12rusQ+duOHq1jYaPARQ2 Es1U5gSM/Xsh8sIvIrvqz1XCnAi1BlzWjKJhPNZy+gLP/9zz3KHOWteHOGtP3SRrUJMq OHf9QGW+2LWLd+DESq8vNt32DLOnULYA9DY/w60KiNzSdkBLOGVbmCEtiEE+PEx643kP BxwA== X-Gm-Message-State: AOAM530me+0NGiQVWpf++E95mBdGmsgEbLruyz236+sBYgRjoY8LqjHX Ftxf7VQOh4eCgEWYldyLMZDKrg== X-Received: by 2002:aa7:dd99:: with SMTP id g25mr12937150edv.230.1616740884618; Thu, 25 Mar 2021 23:41:24 -0700 (PDT) Received: from srini-hackbox.lan (cpc86377-aztw32-2-0-cust226.18-1.cable.virginm.net. [92.233.226.227]) by smtp.gmail.com with ESMTPSA id ci22sm125325ejc.54.2021.03.25.23.41.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Mar 2021 23:41:24 -0700 (PDT) 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 v5 8/9] soundwire: qcom: add auto enumeration support Date: Fri, 26 Mar 2021 06:39:43 +0000 Message-Id: <20210326063944.31683-9-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20210326063944.31683-1-srinivas.kandagatla@linaro.org> References: <20210326063944.31683-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 Reviewed-by: Pierre-Louis Bossart --- drivers/soundwire/qcom.c | 86 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 81 insertions(+), 5 deletions(-) -- 2.21.0 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 26 06:39:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 409476 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp1165366jai; Thu, 25 Mar 2021 23:42:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwFnr/SHkkk6qjIusvoADebEoY16HOnFZ5ngafFNl12jI2JCdIRmT/jeZf/Nk3MXsztAIUF X-Received: by 2002:a05:6402:430c:: with SMTP id m12mr13478498edc.138.1616740954678; Thu, 25 Mar 2021 23:42:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616740954; cv=none; d=google.com; s=arc-20160816; b=CAeBbAr1Q8lGsqIr7pNSRPcbAka9IgI4tFNvCzzlOXK7NUKprdSLNFh4Imv6lMd2nH OZ8/CaE6CkukoxR0Dgat4xmIXSsdnQJiregGpYyRY1l3z4BSAlwWE3rswsv3xr89OiPK duqJsmfPp2kaE4GkSB535eKgQxlw8+CTY0KQlqEWzPXGUvYIiVOeQMWLFK9vGzbEijuP 0P8Aq+J7hh7fzMknxf697g5A+43dJ9O7jzwGAweNkCrkmu1lKDVm27kg0zRyK6Kwm4Or S7PNY+aFODq4k3xY91dmkCch6bluco0ovlanV5MiAUJ0VXnoPF+zKY6tg1BFl3vSOlht zpGg== 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=JLx96J3P/z7SpklWGlSLOqViHHl5WXETT/eud7VOrQ4=; b=sOtrKVRLmnY15KrO7jp74gRYmq5N9C5hgje6GMREZoSyd1yacjbsCcUdL/xUdDUSUS Qg/EGmIfRK2OLv6fNDohBKoscto/P6MT6vy4nESBZYAzuEV5Uu+0cIO9p4c8rKXGxiGX raQ7Gb7OIYYaoQsTDKipZTcF/+6nVQbPfSqzU/5Vm1B0i5YTUIKRg3tQ3hGXaR3vWEkW HV9PKfa/QlM54ZtZ2rf2EgB81KH6RkgHHERMWF7a8yayVAJW2N1nNEv07g2z4uBdFZNr lbgpNA3JaWjv+kp0a3AEemQ6r1WxeV1feKwjKLM7dyqSe9SZA5LkZ46p3pRN5OLOmjF5 XzFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CKI6N9Bx; 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 p11si5754958ejg.105.2021.03.25.23.42.34; Thu, 25 Mar 2021 23:42:34 -0700 (PDT) Received-SPF: pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CKI6N9Bx; 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 S230250AbhCZGmB (ORCPT + 6 others); Fri, 26 Mar 2021 02:42:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230196AbhCZGl1 (ORCPT ); Fri, 26 Mar 2021 02:41:27 -0400 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 03D49C0613B4 for ; Thu, 25 Mar 2021 23:41:27 -0700 (PDT) Received: by mail-ej1-x635.google.com with SMTP id jy13so6784465ejc.2 for ; Thu, 25 Mar 2021 23:41:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JLx96J3P/z7SpklWGlSLOqViHHl5WXETT/eud7VOrQ4=; b=CKI6N9BxqTu7oc5cHbfAFTArbxQlLX407WNFxN/5fyZPddgwYnH+Lx7G6s8WXLxhnV /CNczXVcxGg3nppzl86S9e6pUrpRmZ9fX8fR4rxZy7HK+JKvzreZCCziTSNHQJJLBZso 2Es5mqKlyhjOn8n9XSMcjkn/EvAidELHMetKLpURwr+s2PLg89DiRmh8UVaO/9u0/qfD NejsgeU4GDFCpDT0Y4yxy28zAx3WAo+Y1QH3nXCtbmxC46USX8s6l1KZd+QjRk3Zh9eI f4VVIyuu1LQI9714F09FCQbzSa474qAF1YTILTtc0s3qv2bHhBYI7qxUljqXSBGnC6kp ZMBQ== 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=JLx96J3P/z7SpklWGlSLOqViHHl5WXETT/eud7VOrQ4=; b=HwYovdlsDtWw+G/icTqgLgHE2VBDsxMq1rY/BZ0dzYgyxKIXDS+C1P5/EZHnWKnfOo IkbLPo3XbqoWTyRvzUwHnDw/LmOKFEh2UWkxvvs02iomgi89Gg+qDIzs/jB3HOiFKypv 14aYnOZqada8I8lBAhlcvNc9oxFHSOkKTIH9cSEoSHUFUbw/n5NFIwRPImW3BxLXyDpD 2XxdxiKiWplyy6JOdpkVb1U/zYPrRg39oyPHsAU096tsFKUBwn7cH9nUEhfljCxYJqqJ JQTz8lxQ3js/AaOTfBFFFX8kwTPbWkJZTwgvDXzOBKr2GXbQxAhbRLV+ENFKce2Uk4wv p+6A== X-Gm-Message-State: AOAM532V8PeT8rwZv0ed5QHYCBCP/3cX4WOLbD6DgaHmZ0hiU12hrGBZ lR/odlzvyg1EDxnR4sypc9unbg== X-Received: by 2002:a17:906:a44f:: with SMTP id cb15mr13350392ejb.420.1616740885771; Thu, 25 Mar 2021 23:41:25 -0700 (PDT) Received: from srini-hackbox.lan (cpc86377-aztw32-2-0-cust226.18-1.cable.virginm.net. [92.233.226.227]) by smtp.gmail.com with ESMTPSA id ci22sm125325ejc.54.2021.03.25.23.41.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Mar 2021 23:41:25 -0700 (PDT) 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 v5 9/9] soundwire: qcom: wait for enumeration to be complete in probe Date: Fri, 26 Mar 2021 06:39:44 +0000 Message-Id: <20210326063944.31683-10-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20210326063944.31683-1-srinivas.kandagatla@linaro.org> References: <20210326063944.31683-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 Reviewed-by: Pierre-Louis Bossart --- 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;