From patchwork Tue Mar 30 14:47:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 411738 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp4527223jai; Tue, 30 Mar 2021 07:48:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJytYZdPnNipRNM1QphvN/WlB8a90Qd+OB6Kp7JsU9VHTETRSzAlTkAjMP7cFJTlNORyFnpZ X-Received: by 2002:a17:907:1b06:: with SMTP id mp6mr23353832ejc.292.1617115710146; Tue, 30 Mar 2021 07:48:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617115710; cv=none; d=google.com; s=arc-20160816; b=t/fg2OhTyeR+2AfFv2oDzP4V3F1RWKVnub43WGtFSUOZ5rOqaVdt74nuOyxW6QwjHR bkFfoBZ8rK267XWYdXUHXeMRMW65JZ3C3feUn4rUkPo17vO/bB3gEafF7qs8PCOrGJYN PKfR/3s8wgkcH8vbojcvVSKzE6i9dZqVxdzwtye1UCDQ3sXT3UdgpQLw3T3ly8VVNcp6 pZap8Klv9bDxiwoelrA2Lv4L9TYGEcxMz8uUziMIiwtNUITSXFnx17yU2+zjQ99eOm+T pumqbLw01OZ+5sQ6uIXRE2gFyRJpqn5E0IrIoE45VGENhs2CkcOQqEFDoOjXZ/7PxbwQ yUIg== 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=MGT2UsiB1vfe6cz7CVcyz8NRPNJ5hxJUdAcSYe97B88tcPYHCUCD4tVTUQI3ZqgceY h+2iu6KvVBEqBa1TMUEKBo73RVvCLUXrvuqt5qxARO03+YSpRQ6d3LGwJHn7apWsiVZe nphM5bKBneYqK5STtVtumR543jm2PnjpJ92lXFLzkQPwAZHEkymYjpsCiDrvmxQ656y4 TBigYuUyL1lnBzLDlq/bIc1/mB8gwbGn2kDIcH0VCYV4VQOKbB8eWFNMIyGTy+E5ie7D 7N39drE4EgeS3DJOWEELcXIEGDdEzK3z4OMvUciNm/cLVY8pyOpQaXwy06/iYwVzBS1/ X4OA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=B+vUmE2a; 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 s5si15278409ejx.287.2021.03.30.07.48.30; Tue, 30 Mar 2021 07:48: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=B+vUmE2a; 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 S231992AbhC3Or5 (ORCPT + 6 others); Tue, 30 Mar 2021 10:47:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232224AbhC3Orc (ORCPT ); Tue, 30 Mar 2021 10:47:32 -0400 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71A53C061764 for ; Tue, 30 Mar 2021 07:47:31 -0700 (PDT) Received: by mail-ej1-x62d.google.com with SMTP id jy13so25284782ejc.2 for ; Tue, 30 Mar 2021 07:47:31 -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=B+vUmE2atWiIRf7GIibr3udvr0xoOQgMm1tLReuc+eaDWeQuoxFRgDgF5NZp+OUeg/ zTN0qo2hY9Xapgy7PcQPcU7Paw28NSnYH9yUPEX76DZ0N1YiIqo+n2F3CXdDE84XiOxI rSiS9Ig3JGTfhrucrIlMPvAyWb9BOghGud31nBJ9/TMvfuaLQBU00g3OxjfCC513zepJ WXeWabkFTQjEur1soBDV3KNhfRUPKc46vTL9MKNUWBDsUCzjguqsJF3ycu24jYWW1kWY /a1jRj5qE/VqcD9MfBiJrC9I7h35N8gdBbPT3skv2AzUTfHlK082f/RxkhQTCjMq2SU4 J/XA== 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=OLAyYjXI4+J1r6HfD4JHxPGaz5iFyA7Vsq1sH1aK3TuRGW1U8nMa201OU2D8bP1xDz Hq2xlD2CRcnHV7WWjWbul9LXc2zXKZyvJPN0950ZHkgrPa0GtOEKtcuoq2UVZlaf4FZ+ 1CKT0tUQB/26j80YMlKGBaBbLbU3oBz+rwjfJCUj+Pd0OjvOHR7zsZBC8sEtLcF1/Eg1 jsaV1D2aUkUW7olR7c7WCquqJazQNKfC/EpOlnK09OMJED6K8OeozIS5U7DJml2GlDPt Ax5sIqaz1qtS1zjbJajuuzAUZfQ+wuB2a+m43sT1WOEloYY3pw8qaIApWsNHmKULJ6fw vshg== X-Gm-Message-State: AOAM532NiJD4JeylPb0b5Bl6R36Gn+V+KoD079Uf4fSGnC4xPo+BpSNS g9oY+2dYpu0TKMTNIieTV/uOIWa2zeKKeg== X-Received: by 2002:a17:907:2642:: with SMTP id ar2mr33729453ejc.145.1617115650095; Tue, 30 Mar 2021 07:47:30 -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 n16sm11520383edr.42.2021.03.30.07.47.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Mar 2021 07:47:29 -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 v6 1/9] dt-bindings: soundwire: qcom: clarify data port bus parameters Date: Tue, 30 Mar 2021 15:47:11 +0100 Message-Id: <20210330144719.13284-2-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20210330144719.13284-1-srinivas.kandagatla@linaro.org> References: <20210330144719.13284-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 Tue Mar 30 14:47:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 411737 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp4527213jai; Tue, 30 Mar 2021 07:48:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw99GlokoZ3s1kZGzsTv/CtDJ/nUteIjcdopDO5iBxWjYOzK/krZzumpbxvn/zevA8HACWh X-Received: by 2002:a17:907:77d4:: with SMTP id kz20mr34251924ejc.93.1617115709742; Tue, 30 Mar 2021 07:48:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617115709; cv=none; d=google.com; s=arc-20160816; b=ZKkQVDt424jM4NBrcWNs78uvGBK5JOGCUI+P4pgj1NHlu1tcVF6tq+uOSRXTlct+08 reeRFYuXBke5A1TF/htEYlKxHvuZaS5EqZ3Mh7lHRY9fPxqn7OT/yeIXCg3pb88rAq9P rQWksPrkuNhySNODgBa+kWv3vJSgu9jRcmysh5JBxcWuZ5tV6+fTdlK3tF3pASTB3ieh SbNEN98aF0BgIdmDsgle/11gfDgIqTcFp14KIe+0NIs15p8ieyNlVrNU2cSg0z0dA3n0 UMkGRPGANSpji+nXdHRdoOPtd40Er1dBaq8p2/pfef+j7clL8U2vWXEcrsUyhbgnF0j/ B3rg== 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=bpOUje0l4Epz+I2306iaU5JnH7E9pQPYrzkoakZIyLE=; b=h3WF92X3XnyO8gJQRM1It/cSQHIYYBbVGtHIqHa6/1SSpDeNtJ/hRNi9+8PrGruznS vae1P0+f763i0rNU7o8fKPUv9WtFmcgeU98Y0MEtQrljTMN6alnFAfPnZz7lEx6fVWH5 hSQRR2jUUHWH0coGII5MRYQFD8OgXPeiFDi+y2dh30B3jYIrwCLNAzPoN+CMX19I3gKx wM0QU9ZMm6bdvW6OQoDpqfLmpWQ2TmuOsZCTmFqEECB3NRkGItET81V7Py+z7ETZROAG /1ukC2ap46ykj4N0mhZn+6VSJsGCHsUjczWMcTBLtV7CYPbz3Ryhx75MXTu0ElZtl3kD p+/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Hty1V+sN; 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 s5si15278409ejx.287.2021.03.30.07.48.29; Tue, 30 Mar 2021 07:48:29 -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=Hty1V+sN; 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 S232032AbhC3Or5 (ORCPT + 6 others); Tue, 30 Mar 2021 10:47:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231959AbhC3Orc (ORCPT ); Tue, 30 Mar 2021 10:47:32 -0400 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79A30C0613D8 for ; Tue, 30 Mar 2021 07:47:32 -0700 (PDT) Received: by mail-ej1-x62d.google.com with SMTP id u21so25192455ejo.13 for ; Tue, 30 Mar 2021 07:47:32 -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=bpOUje0l4Epz+I2306iaU5JnH7E9pQPYrzkoakZIyLE=; b=Hty1V+sNzwkNNSTnJbWF+belUQ/1Ek2tUYKo78YdSHyREY/EHLLLxe7DiLz52L+6ph 2BZH+uENW7iLNQhx8POvH7wQnCjbiI3MP5w4y2hv4pG+/A0cKEtPu766dCCiLzP4nYO6 28Zn6xHTyM+/is6HtHMvnfwg0se7LVOmBYhmbAh2b7e2azq3fUV9jQvPyH4SKwrcoYpG EVA1OeqsKHuTK+JD/rJdcnQ1RThfUEZrrHCF/a6lwnmUQE4CCRQWNZFr087AaL+4JlZk 3DWXsr4aj/320umH+YyaNbU5ijxURqwjF0GnJV9hB9MKcQHmAyUpX8tUCClOKvJha7jy OHlw== 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=bpOUje0l4Epz+I2306iaU5JnH7E9pQPYrzkoakZIyLE=; b=iZPpsh28aDrKthhPaoKKDbStIMndaDcmRkE9YmOACzuOgWaGKLYrAhP1vpbWulOXve 4j+j8FC0XzusVXYanLya0nl/sodhD/mAwusd0QgaQb9c4gCb2QyZZ6g06HZp9xp65VNK qnGGTmIP5RE324dxm90RjXNHplTJ8EuEoLNAv7jgYCDg7hoGaPM6RxFm5BEdkIJOKuWg cUXCHV6TSzE5bS5+A2BeEQNQ2bPZun38EU2oZ13NE3OeGeCNorSHx6yu981moZlIjVxK GxBtgs8oQaKn/Ri/XNqHjHQD4+T4V44caGg7/VobyB0s65eSWndMVd7l74VQeskGN1wN TDsg== X-Gm-Message-State: AOAM532cby+dLao7VMQHzJ9IM4QIYlKzVQnxqzqv8kBCJRP92I1OaQGX 2iXhqr1ERscPpspiNPT95Q91yQ== X-Received: by 2002:a17:906:2dc1:: with SMTP id h1mr34166268eji.460.1617115651171; Tue, 30 Mar 2021 07:47:31 -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 n16sm11520383edr.42.2021.03.30.07.47.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Mar 2021 07:47:30 -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 v6 2/9] soundwire: qcom: add support to missing transport params Date: Tue, 30 Mar 2021 15:47:12 +0100 Message-Id: <20210330144719.13284-3-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20210330144719.13284-1-srinivas.kandagatla@linaro.org> References: <20210330144719.13284-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 | 106 ++++++++++++++++++++++++++++++++++----- 1 file changed, 94 insertions(+), 12 deletions(-) -- 2.21.0 diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c index 277f711e374d..fdcb8ffb4284 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); + } - ret = ctrl->reg_write(ctrl, reg, 1); + 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); + } + + 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; @@ -466,10 +508,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) { @@ -481,6 +526,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++; } } @@ -728,6 +785,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); @@ -775,11 +837,31 @@ static int qcom_swrm_get_port_config(struct qcom_swrm_ctrl *ctrl) if (ret) return ret; + 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 Tue Mar 30 14:47:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 411740 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp4527246jai; Tue, 30 Mar 2021 07:48:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy+B+pTkI0uIpf73T0CylquK6SvYM4xEROHdjbASPacvXBOSxCQW2iVihTmMlshzXJkP6y4 X-Received: by 2002:a05:6402:b2d:: with SMTP id bo13mr33848182edb.120.1617115711444; Tue, 30 Mar 2021 07:48:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617115711; cv=none; d=google.com; s=arc-20160816; b=fBqAuZkE/1kAViP+W1e0NGfuvOfAQ0wlNBHuqw0A+15bPMNqD0TP+Rn4EgedF3jOMO MUlJ+JD63rPER+Ytrie24bEHCW7qcab3cv0LJ2HUkMAxaB5BANwhLCvJf5LqyiFsR8vQ nVoM2kZ5zFAjoXZcD5oJ8NvyRI6HEnXRwutIz0k1YxWQofTQtNEk3/7oeD7ViTP+TMy5 QTTPCXk9Nfu1TXHrcx3hfIezTKf2ljDeaJWRVWgBjjOZhKLNNgOOe3oNJwib+naz+WM8 4mKmLKBeYMgXv7PFubdNQ8RDGV0vp6nBHkGgX+8+XV7icgfwak57d6UAOIsSECUPDcY7 4uxw== 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=iTtGVN1pUyN9IaMWG8AM0yqz3LAm7zkZxHqujW1MyRQ=; b=L8bndsAnSEGa8rUmtxN0dterEpmDwurGhN8Ihh4yb3xRxodMkZDuuYajps4D6XdQ6S LX1I2lxN2dGA+W6l4GG7aIAdGhP8arl2u+9B/+gEep3QvErlhghjHDKlaxJm3I120rT8 z0MN9qdNMRotgPBzhkrMEQRJufr4LknlZGBJeqiRqr6985T4oYmRpGXiDjIapP6BYr1i kIeE8SG6Ux2uuXpUIyUaONyn1cycM+YpMkOfPrSeZVM/Mp0Rm0ftKFj3SgzGTHPT2aoC X3W/uiqHApr+xPFjH6wAx0DEH8J6JKeoI7XRSAE4nS/e6Fw3v6O7uIb3DY09C7/fZWt3 Lhqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="OPl/oeJN"; 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 s5si15278409ejx.287.2021.03.30.07.48.31; Tue, 30 Mar 2021 07:48: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="OPl/oeJN"; 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 S231579AbhC3Or6 (ORCPT + 6 others); Tue, 30 Mar 2021 10:47:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231985AbhC3Ore (ORCPT ); Tue, 30 Mar 2021 10:47:34 -0400 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9827C061762 for ; Tue, 30 Mar 2021 07:47:33 -0700 (PDT) Received: by mail-ej1-x62c.google.com with SMTP id e14so25190154ejz.11 for ; Tue, 30 Mar 2021 07:47:33 -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=iTtGVN1pUyN9IaMWG8AM0yqz3LAm7zkZxHqujW1MyRQ=; b=OPl/oeJNk1DkH3MimaRAzXR8S0CUMSUyo2Ud1RE6hDwPmdkI8wMy0A30fs+TS/lPTU 0Kfu9ZygeGFVfOewRYqG3vD0BFuTRezb/jQpc1hrg3QMKV9PiO5bXp2K1AJVa8mywcwp A/aydET0pYuZ+rNkZ0xZGiVgz1H8PfklTGjcWlUXtOJ2Dh1thm4pgT/OHhBp/uUASTHg Ot17dpVDByMQJshKvoM/dbWZWbmWodQG7/W66rajHNY0QxL5L9jm3kfMcBfn2Joum+Br 3N3+B+wUDUcP8N3aOniCFspsPbCSynweGhUTq3HUdNn7UP+wEcWFopF+HS7fZn8SUEuR dgnA== 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=iTtGVN1pUyN9IaMWG8AM0yqz3LAm7zkZxHqujW1MyRQ=; b=XhoOng8GHhoYGQlQYgsXPhYzUibnOxrSmWclApXmUXun5V8RS3UGHNGKE32VrN3hr7 3njod/HZA0W+7dsblHBwuGzLLxWf+u9i2SwFpynVjui8Ngi6sUK3mZkWwCDT2xK1XRyr +BP+IqbMhNtYWwc+40U/IJ95aKqglkMw1TpmazjklQV99M1POkycfcXpx4d/aOUKeta5 +Bz8iMUGiIbNUGpCbYhLCotDwSR4S2MoHRmeaZ6fMWsbmEziJ3zkgw5nF2EQvb4WPDy4 THt5eJabaHp7dhktnZlYm0ZAHydE5rXnXSAsvlHlapn256kJIy28P+9+wm8bB0+YYEw4 2DFA== X-Gm-Message-State: AOAM530MX8lYKluJ63Utu1e+2nYrujgc1zYuv87b3yQC2cg3qlBtwUXY Xm3ffR0FOereQ5YL7PWg5uOKJA== X-Received: by 2002:a17:906:495a:: with SMTP id f26mr32959469ejt.271.1617115652384; Tue, 30 Mar 2021 07:47:32 -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 n16sm11520383edr.42.2021.03.30.07.47.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Mar 2021 07:47:31 -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 v6 3/9] soundwire: qcom: set continue execution flag for ignored commands Date: Tue, 30 Mar 2021 15:47:13 +0100 Message-Id: <20210330144719.13284-4-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20210330144719.13284-1-srinivas.kandagatla@linaro.org> References: <20210330144719.13284-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 fdcb8ffb4284..edc77d18c245 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 Tue Mar 30 14:47:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 411739 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp4527238jai; Tue, 30 Mar 2021 07:48:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyYn5w0mG2VXPzAeqxN3va/0U2bcYNk/U3RbLYVV5t0HIq51lM8q0qlOpPsTwuxKzdilcFc X-Received: by 2002:a05:6402:105a:: with SMTP id e26mr34219851edu.164.1617115711042; Tue, 30 Mar 2021 07:48:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617115711; cv=none; d=google.com; s=arc-20160816; b=QiVO4jWN7d4FGduSXA5R8S1q6Wk5K17Uwj/OGokKByRL/49zshPzn+xmYJKueL8uFF NH+eL7SLs12zD7q6XptBIhiuJAeFo948HQeD9Lkd1dBNuyzeuXtipXpw8W8xR5IV4nEE 0Tzt6kz2cPt6dwYb5YzSDuGpg5LFw1y2aDH+HNYA1xXzbqC5HlTUawndjrnifQcjq1/r JshIZEBMbjrf6v5giMyAZSTlhruom5APz2bkfqTmvIBR/IZ3fHD2ovoSBD9Ev9t646Co MsDr3uLUBpc3QbQKOy1PNnIPx8UtEvwKZSfkEWyy/ineWV1/69bk+SiNiFtrkg/7ugLD u8fg== 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=4+hsU/8RBl6lSSICk7jMUthsu/0q86iC66VLDGyTgJc=; b=kSFQQG8MZTUGPRJ20wi3blm4C6xLjOgXMEH1aYayxB8cMhFZtELCglzcqGqUzazK6t PgasfU0+fN7Kcvi33J56Co+3Tw12e8IH1JLrqb1WA9qaQ9cCm1TkCsT35VSOjwFJ8D4C PrPalobu4v4/1GO7Uq5wo+REM4gk5Xm5Q1+nyW/cSCedX2Q5eLoVyVAGlfQ7bBoCoyxQ jkHE3YxQheHB4kwuXlZlwswvA2Q+DLgDHx69ZunfTGoAsdxOWcAsng6PFzOcOn5aB2le r5dndCPHvqomd/mkMvqhgSd3q4h/9maTauoBqmooWUdJPESYtRJkgxtGI3yFFhCBzwYo bSvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mH8sSvUf; 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 s5si15278409ejx.287.2021.03.30.07.48.30; Tue, 30 Mar 2021 07:48: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=mH8sSvUf; 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 S232048AbhC3Or6 (ORCPT + 6 others); Tue, 30 Mar 2021 10:47:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232249AbhC3Orf (ORCPT ); Tue, 30 Mar 2021 10:47:35 -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 A79F1C061574 for ; Tue, 30 Mar 2021 07:47:34 -0700 (PDT) Received: by mail-ed1-x536.google.com with SMTP id l18so18537463edc.9 for ; Tue, 30 Mar 2021 07:47:34 -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=4+hsU/8RBl6lSSICk7jMUthsu/0q86iC66VLDGyTgJc=; b=mH8sSvUfDbRY2Ewaz01LJDF0WZ94V4hv2vB5u1PRwCMZi/Qi4FQOm6yXvQBoKfYBny i/w2jpGrJLqgFcKE0xqHPRDA1fZXPvwJAGiTzi+M5jil4xxxJDYfSp6OhQl+bZ0igZmP Tc6aYUaCdje9jiRHOH4gslmlnUEoAYkcl1VvNtEu8f09wkXZJM+rHjBvIbrg+Jthtf1y DO1zcxRnE5RJPNF6eRDDGgUu9+ykJloerxZuAjoGtoXhCuHZ1mu45E1LGobWOeI5qeTZ HHiUZbp1gnS3sFTlo/14WbAdeLxDlz3FNmCBNnb6dti2QGr/yohV13wCFK8FkLM6NQpM AKjw== 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=4+hsU/8RBl6lSSICk7jMUthsu/0q86iC66VLDGyTgJc=; b=W2RnIVvA1tWy4n1MBeVZX8VOLhU+PcPtPJL5kMPgj2qoSj1tZQ248+0aJimZgtyhFk Rqy3zVgHgi7qQ+Ah/gDZKt/pYIW4kmckCurea/vAr8Ur5lforXhGw6Xym4CXQcJIZ54G yruwUtM/OrmkP9JNq4LNlziIlKPbQR4eUzOiBcL5BMD8c72DR6Eu95PkxAAMa4onQn/g /2/HTIJD84v61KkCye70rMOC7Oq2iOg7HOd87bGKNwQME35M1yxUI47C4fgOWcgFmu6X pC5wKr7f+itY5Mp0Bi2SN9/l7t+fQAcXy/vDtpPMXF5tVFaFF5nBqltzYqqPtNCDdtDM 0n8A== X-Gm-Message-State: AOAM533CT1+cpQUf82pFSYZcytsCtOaF3nP1FcCu/qJzFSEW/LddTf3/ wiEU9eUBXqkgUO8ToFEcUF7hEw== X-Received: by 2002:a05:6402:35cd:: with SMTP id z13mr34346153edc.21.1617115653480; Tue, 30 Mar 2021 07:47:33 -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 n16sm11520383edr.42.2021.03.30.07.47.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Mar 2021 07:47:33 -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 v6 4/9] soundwire: qcom: start the clock during initialization Date: Tue, 30 Mar 2021 15:47:14 +0100 Message-Id: <20210330144719.13284-5-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20210330144719.13284-1-srinivas.kandagatla@linaro.org> References: <20210330144719.13284-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 edc77d18c245..0f2167433d2f 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 Tue Mar 30 14:47:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 411742 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp4527269jai; Tue, 30 Mar 2021 07:48:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzGxFA+wgcsGHRJjvMeeZESqJoDcH9vlR9AtM9+HBytkNnEajHzw5Hq18gSeDixHmolBsAX X-Received: by 2002:aa7:dc49:: with SMTP id g9mr33267695edu.60.1617115712614; Tue, 30 Mar 2021 07:48:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617115712; cv=none; d=google.com; s=arc-20160816; b=OVbG/fQvrmOsAWdyJ7WAgkgRZUOArg2cXhbLE6K3qKnjSfxLd2Vv7Ufwlit5gt3Y1B s5vUR9DGuvbFLNW3UxihuNltkPigtkm4M6wZfxSDZVBRNCz0wKfg1jzlMUMgJaKGxAjS Twsif8JO7c2Y4E9peGaXC8tCJy54yEdkYfqgPIsfrLK3G4YBRt/nreMs0uz6+6EwanYe R4keOTtr4H8RJ6h6RL+BT+Go9UPVI+IqMYm2h1jgJPtBFxQanHDwPT3b3zjyCti865Pq Fc6uHszZCLfKHs3epK9pt0XV4zeOJGPB10ETntMVE02b4JRy5SKMAuNnFl6N1HUfze8T Kz8w== 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=NagpBPmewIGobpClYjbr4VbFIIG7lSH4M1EpdzRLCM8=; b=d0mRw2UX042kixunwxAYBb7YIF3JMFtms6JyEB8ZbOlB269OiszCpeL/JBFsGpavdN nCp6zZZrTevTBDZMJ6gv4p0tNT4VH+ElZ7EjAlaybOUC21dmnsaIRcl1dCrLpzplwBu9 RT82HTzqHIM5uQ44cjOOGV5xc13/dOt4sNE3H3h7wqaefzedJ0pIbxl8AkGarSRD4iXl fBO4veW/TEf8KHuiAoeUfhuC5sbjILknJsznwLA/BDlCQo8dlaS3kxheDgktie1VqkRK nzKUXmwNozI3mbCKQjt4KAA1ZpWdY5ZurHRs9i0hmv8qivCyxf0wahgolG3m/6nHwjXM LQcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RLzBjFWN; 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 s5si15278409ejx.287.2021.03.30.07.48.32; Tue, 30 Mar 2021 07:48: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=RLzBjFWN; 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 S232085AbhC3Or7 (ORCPT + 6 others); Tue, 30 Mar 2021 10:47:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231967AbhC3Org (ORCPT ); Tue, 30 Mar 2021 10:47:36 -0400 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F130AC061574 for ; Tue, 30 Mar 2021 07:47:35 -0700 (PDT) Received: by mail-ej1-x634.google.com with SMTP id u21so25192769ejo.13 for ; Tue, 30 Mar 2021 07:47:35 -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=NagpBPmewIGobpClYjbr4VbFIIG7lSH4M1EpdzRLCM8=; b=RLzBjFWNwg/cj6Rn4q8332vODvASUggc4aCUDQccYpPpzSqZR6EgYKwxE2am2jc9Mm +DZKJMqaALfM3cOEhJ3H7JHILrE7ONMon9f5q9JmFvmuV8yDRkUJf+CqK8U8znCYLI0z AjlgNgF4zhtGN1sun8mhfXAmGJ6XRVsNvUsH+peWRl0DUDro/1SEJWnl0HQG/RG/08oJ InK+GE5GD7fTJvPL851HwgkSeRxmAancoCeD9FYEE/zDqETv523VD80VoH4WQq9CeDWq 53J24qDfINq5AzWA9wZgqllx6OA/mWAVuaOsmvSQo1PScatJGC7Q1X9y29MK+M8pnXhd 5u2A== 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=NagpBPmewIGobpClYjbr4VbFIIG7lSH4M1EpdzRLCM8=; b=oJQD2LrnFAZBmSbMkGSvCEgYFb9blo+Qpl7fKRXbsNa0DodLZ1i0+dw9o8cZxLP+cQ oMZBQiB2sYt4Dbb40FS707nbvjNidRutjw41/W34iFpLFdZNHTMrVF2cRC6ligQyB9ij LLVv7mRUe/6sN9cYvyf5DOM2lU7mpv//Dh2JK/wl0D1Wr04xZObsZQyNhELzJfFvwmwf cZMIR45y+ej597niIvYckxLLD6/iegNNEPt0kcjW/82e2Cu6tc4R3GAi1Im1Pz985uXi XaG0EuK9w2ywjSSE/Pq/dI0I0FRYtSs/GLHMDEUHKcl32sqW1Beuw+J9Xa2wXtzCm2mk 2X9w== X-Gm-Message-State: AOAM531nwZjXJ90aMAh6P8Vv8qDe65dPlaam0UvBRuCo1kiTn3wMH43m E/tcIGRq9o/iGuyjUWugBtKsHQ== X-Received: by 2002:a17:906:7c48:: with SMTP id g8mr34654915ejp.138.1617115654703; Tue, 30 Mar 2021 07:47:34 -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 n16sm11520383edr.42.2021.03.30.07.47.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Mar 2021 07:47:34 -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 v6 5/9] soundwire: qcom: update register read/write routine Date: Tue, 30 Mar 2021 15:47:15 +0100 Message-Id: <20210330144719.13284-6-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20210330144719.13284-1-srinivas.kandagatla@linaro.org> References: <20210330144719.13284-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 | 179 ++++++++++++++++++++++----------------- 1 file changed, 100 insertions(+), 79 deletions(-) -- 2.21.0 diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c index 0f2167433d2f..faa4c84dcf61 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,106 @@ 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)); + /* Its assumed that write is okay as we do not get any status back */ + 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 +325,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 +337,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 +349,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; @@ -562,16 +594,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) { @@ -930,9 +952,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 Tue Mar 30 14:47:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 411741 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp4527261jai; Tue, 30 Mar 2021 07:48:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy7xgS/nubzWfUcl2eEvhamMldOdHGsJqbB2poGl++gSm8YvC8Uc7CBIdO1RJJpx8xEeK4Z X-Received: by 2002:a17:906:f88a:: with SMTP id lg10mr34553977ejb.39.1617115712252; Tue, 30 Mar 2021 07:48:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617115712; cv=none; d=google.com; s=arc-20160816; b=0yltL/3B835q21gMbWQYJ3onU++00kTqMT5N0qEIP/ccWmwNqT1u5TGLA7B6yrBuBx SjsbPIHgLdlKR0ueZlo1znpk+Phil/jPJF4eZAQyQwRn3HZXFuvN17FVI+g9AZOtL9/J LFL5rMVYBkxkHl/xfHj5FsnY2oVlMnPXfIP3b9LUP53H6XLKjXTG7pFQmGfpW921s2Jq MFUKrv9MQiowcUSnW+Hc2LN2bCOFUL0tstU/OHhm93usivQmp7wWpvPi1a0I2c+n9ezW 9P542upQGdCCCoIMd/aGSj4YNoxNOWF53SlLPPSUyppgTrqBzPhJ7wFDlNwkb4e82Ih5 YfrA== 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=TDuvVae9dYMWTsMVJn0mH5E7CRtvLZp7LEy51JWIliw=; b=INVqW7ckTdZgiBPB5/Lr1Xa8bXC/zsnmtWOEZmoMFAh28+JoWi9CRlOnd1N0BpfInW Ja5lEHCzLkY+U5yGV4m+9ruh+ZDfDQlv69EE8+hSegbAFPB8GInTTzMqxCEc3/TsoCQR ivkpnLHg52se4jeNDaTFekzKxvK2xvZijq5u/zmYYG2aCthOnI8rZIpqeSZLuIxUuh/C UgSD4mnkf1ikTSFssOAyFxeLdYb773thBfHP/aHiueq8alVNspr+y9Hso6UPu6ewjMln p4dXGfAJV8sv017JKVn/a4uIEegANx5fUQrMdFg39x4+Fa3lIAw47caF5W6AO4U3v26E ySGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LdyZGd8e; 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 s5si15278409ejx.287.2021.03.30.07.48.32; Tue, 30 Mar 2021 07:48: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=LdyZGd8e; 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 S231967AbhC3Or7 (ORCPT + 6 others); Tue, 30 Mar 2021 10:47:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232014AbhC3Orh (ORCPT ); Tue, 30 Mar 2021 10:47:37 -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 30767C061762 for ; Tue, 30 Mar 2021 07:47:37 -0700 (PDT) Received: by mail-ed1-x531.google.com with SMTP id j3so18486019edp.11 for ; Tue, 30 Mar 2021 07:47:37 -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=TDuvVae9dYMWTsMVJn0mH5E7CRtvLZp7LEy51JWIliw=; b=LdyZGd8expr8h/EjgU0bBssrnLLgR7ljmGONAfHq0hFiB/MRuV04JeCDTXIYLGr+ZW rgE/fgtZVDtOYaYn1mnnRmprDdTtcShbtcJXSlgB/jHRO67eeJWkEuAnY2yB8JCvbjoh vUzBqyovHbCpc6IwyOpD85qrtaygFSKcRZHS8mDfuPL0VYxcu3eUtPmObS8jLRY+oqpE Uk8r8E/PB6nS+d9qXQ2oPtBfs1Fyu4ldVRhVwVa6he4Fdw57Bc3W1WLim3o5zQTFcosp tfymGYq+Q2xUK7U51DtFN9i9L+imbUJc3ZrYPQSDMMbFPtI7ZWFsxruWrduUh3iNkH9O e8vA== 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=TDuvVae9dYMWTsMVJn0mH5E7CRtvLZp7LEy51JWIliw=; b=g3ID4sRjAoef5gyI0UkpAvzuiZfayl2X4UxuheS8get5zcldUO7zUL+63G1XZzM+6N BJhMPjAVZj338nfWvJppGpFs+lNOh1tRataZmpdoputYfphyrjrmUxXL1lqllKwAVwUM kTdgPCPXm6zymFRq5nHxVocjrxvhXcIAP69COZFx36dPgpfIv+Z3Hs800XKGbZEn/KU8 fqFa1fUabyFoGBWYWjIKJ8El+9CVrRJ58zVqyHmj047X9aqFuB3DyxgNc4ymfF3Qkf7J IEiQpiF3GVl3U7XDQRJxy1muGmD/DikpKfat545TeiFj9GtNj1auRabHzYu+0ZK127A8 r7Cw== X-Gm-Message-State: AOAM531DH19FTl7B9Gp2btuIJ/D4j1isA7/5wyGMm10WPeY9cOeZhPFL Ua0sWrgNuPwSWLo9+3BHcAWR4g== X-Received: by 2002:a05:6402:518c:: with SMTP id q12mr22050828edd.11.1617115655904; Tue, 30 Mar 2021 07:47:35 -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 n16sm11520383edr.42.2021.03.30.07.47.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Mar 2021 07:47:35 -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 v6 6/9] soundwire: qcom: add support to new interrupts Date: Tue, 30 Mar 2021 15:47:16 +0100 Message-Id: <20210330144719.13284-7-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20210330144719.13284-1-srinivas.kandagatla@linaro.org> References: <20210330144719.13284-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 faa4c84dcf61..1ad07784db4b 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]; @@ -305,6 +318,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; @@ -323,36 +355,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 & BIT(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) @@ -368,6 +476,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 Tue Mar 30 14:47:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 411745 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp4527299jai; Tue, 30 Mar 2021 07:48:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyQ43nkI88QJCLhyWb5T4xnDs9WWUDZg3ok3+HX4taHwWMZJjmowylTJS3HHe5VousCERSh X-Received: by 2002:a17:906:32da:: with SMTP id k26mr33640784ejk.483.1617115714207; Tue, 30 Mar 2021 07:48:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617115714; cv=none; d=google.com; s=arc-20160816; b=xHplJe18MLkkaq+bMaStxBL3WMWSiVWwAFTmWprznt+YRdaUfIZOp6tro5A6ILX7R3 zZ4ZYHOsjXAE1W0xmxEvlFH9gtwFIswgLhKk+Uk+wFk4WliZLzGBR6L4l9uO5FPfTz9Y uPCnReWNtJAg8MAJhDfyXejN5Z943/+zmgL7dyhetmwqYeI6gfdVPcpr45pxO26y1QcR SfQB5fDnVNthOJGGTu5iBdcoARj3e8hrSS+oazKFrMP1jZEvHTpWPHxOz4V1OSGkVf9u UGj/llq25Zsq2wB15QMXowX1TD0eVx+UZMx++xi3hSxEhq0o3IezShFngXqqFP727Jhi bc6w== 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=p958/KgSVdF5+9QpbHuTIEsCC6E24Ycmg43m5LKY0o4=; b=FPCNpyFoU53JoG1A4anGpBHRB/SgqafiYMOb74XCDCl8zigD+OQ+uG2uZ74nIGDeda UysVKZAvQ5GgIbxoeLAPMuePYLy50KEmQ5Qq/EF4WlHSoUmBARLYnNTIMgfhdhOn5YRm Ki0e+efLZyvHd+z05mDzUl8cDfe/asKIhHe+o9Q85ryhfJ3X8IDfJJ56YURRqV5AVyZG a0Ic11lEwBFr6RmdBf8eQrv7UNwetNJygHe1TM/SfIQaKMN/9VIWsbTXs0usLcopZxKe IEOE8T4ovWNrnJ1y8J+ddUoEaKKoAq5kqgBDUdjBhy8tpbU+vQ9W2NxRYCcAaci0ttKh ibNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TijfAYCV; 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 s5si15278409ejx.287.2021.03.30.07.48.34; Tue, 30 Mar 2021 07:48: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=TijfAYCV; 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 S232014AbhC3OsA (ORCPT + 6 others); Tue, 30 Mar 2021 10:48:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232019AbhC3Ori (ORCPT ); Tue, 30 Mar 2021 10:47:38 -0400 Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30029C061762 for ; Tue, 30 Mar 2021 07:47:38 -0700 (PDT) Received: by mail-ed1-x535.google.com with SMTP id bf3so18530275edb.6 for ; Tue, 30 Mar 2021 07:47:38 -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=p958/KgSVdF5+9QpbHuTIEsCC6E24Ycmg43m5LKY0o4=; b=TijfAYCV9yntgSN/zpB4NqshxbZFEgPMvpo6bQnDNJenVWSFlXYCDW5B7GD/pPU1EZ e1PnMb1qRT3KM/JmPorV7rQQFFR10NzUOUjQk3FSITerXhbD+t98MYD791dndRthzCDK UxaMM5CyIjEphTUUWlydQDAv/oSzcbFw4+5IhCLrhFu14+gJB3I2Y3ScqiR5zsg1w9yt chPtx8zuQxg3U1TpWAiiKB1cQ04ito8ghvAe7ta274P9FXr2cXlV15x2t56CYdMOiWeJ OdSrh4cfNQdwONHa6IvIh05sQaOJu48JGQZpMPQKadVCQdJTUAz3fzF6Eyiec+Z78N92 QfGg== 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=p958/KgSVdF5+9QpbHuTIEsCC6E24Ycmg43m5LKY0o4=; b=Kzb2W00FX8918ZbZyi12qszPk7964jOh1BW/HG4jcAdpU5S/Ki13y3VVJ1hrkxq3qT oeUh5sLw6jD/Q152Bztmvl2FwQfwx983zkQeXj7+eXZjh7NtEReVmikjhSu54TiSFgSB U0OMAE9mxypY5Uc3N3tDDqY7RRq2xysafI/9Ms/OWiGXemKXSQyfYPmwYOue4NTO1Seg sLNFn7eB7WDm285R4z8FcDxjbC/FS7haqHJN8OAbChq9j5C6CvrlhKx+2GwsRBMfU/k7 5+But40EahUuCSmAkHSPc161oLftoCZoAxEkmfGtwJBeeShwue5oXHhCwBAQ43bZYDTw /I9g== X-Gm-Message-State: AOAM532klRCsb4Nu6QYEOo0ZAeOwzQe1aRb0m7/v5hM6TtkKOVfVioDf DYmHvXMIx92d32i0l+1YImnnsw== X-Received: by 2002:a50:e80c:: with SMTP id e12mr34395379edn.229.1617115656985; Tue, 30 Mar 2021 07:47:36 -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 n16sm11520383edr.42.2021.03.30.07.47.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Mar 2021 07:47:36 -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 v6 7/9] soundwire: export sdw_compare_devid, sdw_extract_slave_id and sdw_slave_add Date: Tue, 30 Mar 2021 15:47:17 +0100 Message-Id: <20210330144719.13284-8-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20210330144719.13284-1-srinivas.kandagatla@linaro.org> References: <20210330144719.13284-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 9bd83c91a873..a9e0aa72654d 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 112b21967c7a..0eed38a79c6d 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 350436db6ddb..5ff9a8f37e91 100644 --- a/include/linux/soundwire/sdw.h +++ b/include/linux/soundwire/sdw.h @@ -1039,5 +1039,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 Tue Mar 30 14:47:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 411744 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp4527293jai; Tue, 30 Mar 2021 07:48:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyN6c7WTksgvSQOILYjiV25JhmYeVN5BTDnhrs/ZpwuOi0xUHyy2Jy6xi4GFRA9NLt3dQO8 X-Received: by 2002:a17:906:b202:: with SMTP id p2mr15386943ejz.244.1617115713846; Tue, 30 Mar 2021 07:48:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617115713; cv=none; d=google.com; s=arc-20160816; b=F7C5xVDma1/EKOBDwyi0h/aU1BKGJwKAdYh93jt3P5fsqXqRVXJdxeczKRyQqfOGr/ 8C22ShufLL0B6u3H5YdSeltG+VrmK732tBaz1hf/+RjvHO7JGDykMmNECDaA2pBxTfyQ j76qDZ+rA+GEazcY15aRsJoqPeYlMWGFSRmRH0WQTtvU69C2VmkDhBAV3+XFS+xQ1TBt DD7rDYYdRKQ3yG0VQ1cb61Rqe9OIj8Y09up+LGq0sy6KaiYPXRhL3p8IGpu3eShmuvXb Tj7g2YopVgC8p/KpRLzPXGbx04AG76P9ZCeJTuBhBYs/BaSB7nnQ4GLak8P+138lkhwr 5U0Q== 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=EdgRcDUqvxdVTHvtsiK+mNjOO9P7JIyTzvTk1ge6DVA=; b=IsEfoFf6IB/ENvK4PmHPmE0hU/Q4LrNYjXBf6u5DmGI7WXGsEgvXTFNk5LVNFvnyvU HtmzM9+eysGbkIn36X5/tDAn+MWvPoq54Wn1efwE32S0JSuOcpV/D5YD301iT76kPU6Z kjv0ZCQ+m+2dxqcuNt77d+OKkrffWdPew1GyQZjfppmy7C5jxtq6GqBIMWCqdcQkbVvK NAjXjBXmlgzxKyBJAmc+BDa4un+qK8Qi/OQ4oCKAkDfn7z14btgVDZy2pM8JWmekol/u d4Y1r9jcYeU/mcv1Pax2HPKFS2Ay/iMprBPkYdlPEaTpIg5MAl7D805NEo+p7U8dd39s wmoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="yWKXS/Es"; 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 s5si15278409ejx.287.2021.03.30.07.48.33; Tue, 30 Mar 2021 07:48:33 -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="yWKXS/Es"; 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 S232167AbhC3OsA (ORCPT + 6 others); Tue, 30 Mar 2021 10:48:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232010AbhC3Orj (ORCPT ); Tue, 30 Mar 2021 10:47:39 -0400 Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D58EC061574 for ; Tue, 30 Mar 2021 07:47:39 -0700 (PDT) Received: by mail-ed1-x532.google.com with SMTP id y6so18570259eds.1 for ; Tue, 30 Mar 2021 07:47:39 -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=EdgRcDUqvxdVTHvtsiK+mNjOO9P7JIyTzvTk1ge6DVA=; b=yWKXS/Esu+CP2JquUFXRo6KE9qfV1tTmADTCc/bVxdfep0umEFUcdQDMmJ/7p1x6Ke 9KnSw1OE+TQt7H25ba18usowtLygxkWqy+dpSParPsI5gQTQzKpnH7lIodsK86XGL3Yj QBe0ylgicHprDdGEgq7Mph3De/ZMaTxLBijn87ee8bFGowFbl38O7RjK5wMcU8i20V7D j10PHM5lynvpyQTu2mLII+1PEetgiyytd9GnXT12L1rlaD9i5k3L6pgOTbLrEZJQPwkD VhytMx6IgvL9HBzhir6QD40YxhGnGzxQ+PyaHbN6O2a6PG69juRKeCMqvgDWAZZmpIhN AMTQ== 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=EdgRcDUqvxdVTHvtsiK+mNjOO9P7JIyTzvTk1ge6DVA=; b=tU7A0eWha+ayNMPhdpMBYyvamAFZ5JkRIGygSjFzgZFzLfamY4udf97RQlO4NMz7// MKqh66VFeaR6rLjJNs1kKfHnbSM155d7XbA35EYQM1BzNJn0SxtKWO3qyZmvmUzWzUmn O0cSXJ89kaUn0yLdb8RoA3/Zn+ks79FK+psoF4j02HQLwh+LgsRWzd5mpes25+6+s27/ 7YU+I3hz+4d6V8YRHWL/1//2hdkijvjuIbFm/PX6Nftf5HLlyoLNLvaiFiTHvfhIfItb 57bN9j5yshuA7RN4GIFbZQ+V4uhiwS+9EqY1dijRrahDoPxpSw3c3fUihTjm/AWEVNZs ISZg== X-Gm-Message-State: AOAM533QO7uBCs267jR9AAIF/xt67jo8z2QndVANlpRRhGUyUEV8cpb6 5c9KFQ9h7vhD0vtZDFh0PwdWbHZbEQoGYQ== X-Received: by 2002:aa7:cb0a:: with SMTP id s10mr33735147edt.36.1617115658080; Tue, 30 Mar 2021 07:47:38 -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 n16sm11520383edr.42.2021.03.30.07.47.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Mar 2021 07:47:37 -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 v6 8/9] soundwire: qcom: add auto enumeration support Date: Tue, 30 Mar 2021 15:47:18 +0100 Message-Id: <20210330144719.13284-9-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20210330144719.13284-1-srinivas.kandagatla@linaro.org> References: <20210330144719.13284-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 1ad07784db4b..b1dbaf8263e5 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 { @@ -343,6 +346,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; @@ -353,10 +357,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; @@ -385,8 +453,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, @@ -473,8 +548,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 */ @@ -508,6 +583,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 Tue Mar 30 14:47:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 411743 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp4527284jai; Tue, 30 Mar 2021 07:48:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx7YTatt9/GIFgoT43BVpWq3ADngGUgiSk9rq5xyLtJaXKNYov3xz7yAx+V4HSA9LIh1zFm X-Received: by 2002:a05:6402:38d:: with SMTP id o13mr33698088edv.337.1617115713504; Tue, 30 Mar 2021 07:48:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617115713; cv=none; d=google.com; s=arc-20160816; b=B3rtpJeRtqLSkzvYIbBH0kBhB3EoHIHNip0VrXK0C2345Mg3duaxkawl0/ZuhihRHI 5Tzir7c2VxPW5fjhdys6CFElCPlLf1f5aQ4OatGDocpJt3D6D0cW9WQ522mqGJZ4sMjg SY+Vn+5cg4k+3GAwhtKtzuEiGY8tc48ne59+e+3WuEOGhPcTAKMSLJ8OD2pG7XZYKjJv T0y8N0DF/5Gwrugq0CuYFSM6Nlabg4BnXUtX2JWoqMUFNkCu8TNGPKd7uzbvr4aRWHLH LJrUbvZUq0UPkCKrVVVvjIKTJ2ixU/k6idAX2CV5H8+0vuA0hsfj7J710RKcT8sjap/W udDg== 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=44ifFplI0M1D1DckCDMMSyPyGzm+QYpn2WgKJJ6m1Dc=; b=UJ3XIQL0cMOTPV3/XjmPqy53soyAjfPQvEjvdzJOcmtEohirGj9eOzIJhG3UNVDO7R 1vqeGBFu+yGHWiA6hEXU9FR+ETmvEAzjU/djzJfDYixf8uxnUWse3+O+X8RqiPA5vbNZ 5YnBg1Zf/bktsvKmis9hON07YVrL0mP4+k0fhp3JHpQgUqVoy7JRaUQjVLDLjKdcPeUF 54OLAO0iOTVstc9k5j+mI4rpKYkfrSSXwTCFn31VLtTVe5hTwDDL9io9wEcSGKTQnQJ7 phcvqtT8KAhoh3FZidPWbto8k6ImdKS2ZgVy84k1+GqBRimv33VmYohKj77ms/sxqjf7 s31g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xLCLDpHM; 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 s5si15278409ejx.287.2021.03.30.07.48.33; Tue, 30 Mar 2021 07:48:33 -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=xLCLDpHM; 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 S232184AbhC3OsB (ORCPT + 6 others); Tue, 30 Mar 2021 10:48:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232067AbhC3Ork (ORCPT ); Tue, 30 Mar 2021 10:47:40 -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 9779FC061762 for ; Tue, 30 Mar 2021 07:47:40 -0700 (PDT) Received: by mail-ed1-x536.google.com with SMTP id y6so18570354eds.1 for ; Tue, 30 Mar 2021 07:47:40 -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=44ifFplI0M1D1DckCDMMSyPyGzm+QYpn2WgKJJ6m1Dc=; b=xLCLDpHM9R/bUfHs+E17waH6zoZ8VtDejQLi78o+qu4KVyZQ332UT2krsuSGNdexNt +ly5XQBwsj77bQCy0TWWDlNTw4A9SAUKu4UNdwyKjLlRWCoCacskUHQpqibGDqy3KPCL //OhpwpNB3m7XUr5i1lbSRKKnlyXb6juD3w1YhtFq/4u5XZSXG3aFR1nzbcwObGFhICp vf2g2ifUvwA6LfMP8ZqLBR2NhhnKOp4UHson/zsj6OmeycRmU8goEpIzmc0ZoqPEAPJ7 2j6P2ci+4SfCa1MrSTKg/LOayyMw8DpI7WbbXtNOPkC4FgY8Lo2638XHPOVubTO116Pe /iAQ== 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=44ifFplI0M1D1DckCDMMSyPyGzm+QYpn2WgKJJ6m1Dc=; b=eU8gBOoMHiGY1JY1jfW/VCV2LJCPt4pIChHzhDPhppqMPGf4o/NsJA3eoYczIDeK7d IKPCw9gBBZBm+RzPtzkSEaklj9HP78TYzwBGjaS+WCm5UHDSg/t00U4D52VluUmIO6FI 9u9+MO3zlaZbP3pf7cu7GQrLhsZQc4ea2lVEVt9gZVfVfbBbUo8/Lm73n2u8lHtg9Bm3 CJSZ9Ihv5+p9HK0CwNPMvKmWCIwxzEQT71DV76pT/EHQL/ZJ4xD+OEU+qI+/UrxxjSAd 15HhniTk3Quy7zAMqomGFHnYVQ9vLIXt5C7sTCixY1h9cxvuHdp+lpXTC5YV5sIB1fhZ iSOw== X-Gm-Message-State: AOAM532wuqKpSbtDxd/6WXnWYk1LeCGVziIoMuLXp+j1g+Z79fZah4eN t04n2zv/MLgX/piBjf8FxW6TIw== X-Received: by 2002:a05:6402:3486:: with SMTP id v6mr33926624edc.109.1617115659363; Tue, 30 Mar 2021 07:47:39 -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 n16sm11520383edr.42.2021.03.30.07.47.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Mar 2021 07:47:38 -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 v6 9/9] soundwire: qcom: wait for enumeration to be complete in probe Date: Tue, 30 Mar 2021 15:47:19 +0100 Message-Id: <20210330144719.13284-10-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20210330144719.13284-1-srinivas.kandagatla@linaro.org> References: <20210330144719.13284-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 b1dbaf8263e5..b08ecb9b418c 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; @@ -418,6 +419,7 @@ static int qcom_swrm_enumerate(struct sdw_bus *bus) } } + complete(&ctrl->enumeration); return 0; } @@ -1139,6 +1141,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; @@ -1185,6 +1188,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;