From patchwork Tue Sep 12 14:30:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephan Gerhold X-Patchwork-Id: 138346 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp583507vqx; Tue, 12 Sep 2023 11:00:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG0hj7IVIq8UhZSlh7C8+3nJ1Rjicbf6Ryb05u5tLUWrNaJtj2cgmC6OIj7yZmMVXuYEDns X-Received: by 2002:a17:90a:d593:b0:273:4b39:e5b9 with SMTP id v19-20020a17090ad59300b002734b39e5b9mr12845pju.4.1694541635116; Tue, 12 Sep 2023 11:00:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694541635; cv=none; d=google.com; s=arc-20160816; b=v5ac7EL2sXwIU6yOK/EVE1/EwnR0wBLTSg8grs2H89Gpzucv6jY6oI2ww185FI2f5I xrxd/eAXVQf9XF1fcdd5qklcUqF1mUBvsvOSOyJppAoqdZV4WJKO+7ptFqqXML1Uuso9 tNm/Lu9zfwaJkye+Sw/FobuVHr1r557vb0gh2pyKeXc6kKQW99AJzOOvInoHD5FEJ3iu JPS6iBKch7vIJCa6POYDrafK3ECpJtWkUkuYn18F0jDhXkF/eUutmWtAgoLM8cyIJff8 w1sBEXNbinsWtSJyEGF1K70D5YSBJQSwDVCZ8ynzie2gzvSa89i8dd4thIqUBIX+GFlk 5RZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=e0RspZwtHY4b6xeF+Vsx+c1salPGf7KUDftS+3xrVTM=; fh=10DQ9cLgm4jgsgyilmWpXaSieUpiqS1iqWfjfWaX8GI=; b=ubpbOaGdaQKRgYvupuDXblc88tawHlkgLX3kbsvm4XvituL6GGJnw/HSnAl5ayXvE+ ATRBSB7aoMugvjWYt2akgjhUuipbbM908HLBUthYiual+1kMg3OL6bygmmHaG8buuVx9 Lxet/oCDHynxyH8ABSrtEfEzUbZy0qDKi8p57rCKZ3CjJ3ynfpBgrZNpSeKSEtjLLiTo PFSiL60qqjDTWUG/KcwDFb0tlbCh3zJA8Hbna2B5BrjbFeVPvhIOiI9IcANUFIrHTlgH UPNTlR7cRzBglZ87MRHeHB8pF/4sTgJkrUfBgsjJEiI3clrvJLLGo/2ZWUnIocW93olG cfZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernkonzept.com header.s=mx1 header.b=D8tMDnO2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernkonzept.com Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id mi4-20020a17090b4b4400b00271bea73dcesi10693639pjb.96.2023.09.12.11.00.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 11:00:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@kernkonzept.com header.s=mx1 header.b=D8tMDnO2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernkonzept.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 55E73808AB84; Tue, 12 Sep 2023 07:31:17 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.8 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235952AbjILOa6 (ORCPT + 37 others); Tue, 12 Sep 2023 10:30:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235741AbjILOaz (ORCPT ); Tue, 12 Sep 2023 10:30:55 -0400 Received: from mx.kernkonzept.com (serv1.kernkonzept.com [IPv6:2a01:4f8:1c1c:b490::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B952118; Tue, 12 Sep 2023 07:30:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=kernkonzept.com; s=mx1; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From: Reply-To:Content-ID:Content-Description; bh=e0RspZwtHY4b6xeF+Vsx+c1salPGf7KUDftS+3xrVTM=; b=D8tMDnO24+Gcj2XS/qcJZVEek4 1iIPIOQy+bYEclNUMc81yKtm0lqpToj0AD/LQp37m33Mk2CtW29mvHO2dd8qrc7/t7qxosfnRZ8R5 GVmBwHjPVyH4xicTvOmSPU2uO2ZEBjOUmAQvrPpds4HP5LJNPpIOdGUS8NsFKGF/T4CW490t2yrVM MLaF2vMCJ9+ZG8V0aaYh4KNLPk8FqKoU2O+H2KbdFse9fpVrb2DBqVjF/lTyQV1PNYFC0gjiOjg9A Ge3ArM4LitLiFZzS8o9V5NY80vIodpUW51EW6QlasO0gcjbK4wjMqE/JkqO9yT/mxuNzF44v9rpQA e/JUTaJg==; Received: from [10.22.3.24] (helo=serv1.dd1.int.kernkonzept.com) by mx.kernkonzept.com with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.96) id 1qg4Pf-0034i9-2Z; Tue, 12 Sep 2023 16:30:47 +0200 From: Stephan Gerhold Date: Tue, 12 Sep 2023 16:30:36 +0200 Subject: [PATCH 1/4] spi: dt-bindings: qup: Document power-domains and OPP MIME-Version: 1.0 Message-Id: <20230912-spi-qup-dvfs-v1-1-3e38aa09c2bd@kernkonzept.com> References: <20230912-spi-qup-dvfs-v1-0-3e38aa09c2bd@kernkonzept.com> In-Reply-To: <20230912-spi-qup-dvfs-v1-0-3e38aa09c2bd@kernkonzept.com> To: Mark Brown Cc: Andy Gross , Bjorn Andersson , Konrad Dybcio , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Krzysztof Kozlowski , linux-arm-msm@vger.kernel.org, linux-spi@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Stephan Gerhold X-Mailer: b4 0.12.3 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Tue, 12 Sep 2023 07:31:17 -0700 (PDT) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776855689797529344 X-GMAIL-MSGID: 1776855689797529344 Document power-domains and operating-points-v2 to allow making performance state votes for certain clock frequencies of the SPI QUP controller. Signed-off-by: Stephan Gerhold Reviewed-by: Krzysztof Kozlowski --- Documentation/devicetree/bindings/spi/qcom,spi-qup.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Documentation/devicetree/bindings/spi/qcom,spi-qup.yaml b/Documentation/devicetree/bindings/spi/qcom,spi-qup.yaml index 93f14dd01afc..1e498a791406 100644 --- a/Documentation/devicetree/bindings/spi/qcom,spi-qup.yaml +++ b/Documentation/devicetree/bindings/spi/qcom,spi-qup.yaml @@ -47,6 +47,11 @@ properties: interrupts: maxItems: 1 + operating-points-v2: true + + power-domains: + maxItems: 1 + reg: maxItems: 1 @@ -63,6 +68,7 @@ examples: - | #include #include + #include spi@7575000 { compatible = "qcom,spi-qup-v2.2.1"; @@ -76,6 +82,8 @@ examples: pinctrl-1 = <&blsp1_spi1_sleep>; dmas = <&blsp1_dma 12>, <&blsp1_dma 13>; dma-names = "tx", "rx"; + power-domains = <&rpmpd MSM8996_VDDCX>; + operating-points-v2 = <&spi_opp_table>; #address-cells = <1>; #size-cells = <0>; }; From patchwork Tue Sep 12 14:30:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephan Gerhold X-Patchwork-Id: 138369 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp604075vqx; Tue, 12 Sep 2023 11:34:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGkxV2RvKNzPpzykYLLPMul/fT7V6dyUCYDQedKVkWy7kkLNAm61RjCyRXbu2fmpxCUIhpk X-Received: by 2002:a05:6a20:1596:b0:132:cd2d:16fd with SMTP id h22-20020a056a20159600b00132cd2d16fdmr286339pzj.38.1694543685170; Tue, 12 Sep 2023 11:34:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694543685; cv=none; d=google.com; s=arc-20160816; b=rj2UoylvRAgSCQGX7pu8zoSb7NgdQPWWSvVGGjKXieTIU+EvqQkRPmOxWRIlQQrdj0 dsQcKHrq56HP0yD5tB8qMoQSL51lMLu3hyeXZW/8MSXpIR8WZqML7OecSrLnESgK9uLL KFLIO+YVhiobkyqVBGSJ6+SGAIPBX0ubOCn2lUwGtMzmvY4lKzpqFs3IFvuql6Rlev2L 9kEsy0cUA8k1TMPv8HVMpNAxqu09PfmwU8r1cuDjqxi645nSGPf0PQ1KcG8EhXr8kqlH XWOVOljXz4GuQGnplJgbYmPBBD7aDYiTKObGDiG0IqpeL4etqSyGhYaAbxG1Hd85z/8M PIXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=rEE4gT/tRGbf35OMgrGbj+X9eBd0L0DdayGyn6TPmts=; fh=10DQ9cLgm4jgsgyilmWpXaSieUpiqS1iqWfjfWaX8GI=; b=noevk+WIa6Pz9S9XxQOcyV8fO8/PYKKEl6pcUQLJNR8jFKpHS3bQ8EptPhxIkmZVFW QWIIFRsS62m4S7h1Pc2ZgMrO+IJT6HaTD39uTKl8RDAM2/N9/zPljOF0IXiiDA30nmda zwgYZQKJwr8XyU0OGlub/Ww1wvXrwFfcbJVorFf5hq7qDgTGIGQzQeXIBY9YB0a88Vrj BuDjySnQ74LHerPFEOD0LgzthZCy3qAbp822CVN5R+uCgmDFXVqFx714kDfZ5oljiRRT 8sPsnN7jgAWpno+g+rX0ftz+f4R/KNvT8ynQNKc206bphpQqDf+6icGtuGYZlznP5HcQ ANfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernkonzept.com header.s=mx1 header.b=If7ahky9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernkonzept.com Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id b10-20020a17090a8c8a00b00263f3d759cdsi8051415pjo.78.2023.09.12.11.34.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 11:34:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@kernkonzept.com header.s=mx1 header.b=If7ahky9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernkonzept.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 9E4498057E44; Tue, 12 Sep 2023 07:31:14 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.8 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235957AbjILObA (ORCPT + 37 others); Tue, 12 Sep 2023 10:31:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34148 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235943AbjILOa4 (ORCPT ); Tue, 12 Sep 2023 10:30:56 -0400 Received: from mx.kernkonzept.com (serv1.kernkonzept.com [IPv6:2a01:4f8:1c1c:b490::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1196115; Tue, 12 Sep 2023 07:30:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=kernkonzept.com; s=mx1; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From: Reply-To:Content-ID:Content-Description; bh=rEE4gT/tRGbf35OMgrGbj+X9eBd0L0DdayGyn6TPmts=; b=If7ahky9w1DlTHvZVwPjdXaUhG uzw/xgQUkaQFZo0UncDcb1RLsv11cVx86U8n4TZNz44co85KwarmWAo2cgqzWEkA0U6DvPKL5podl PHU2ld2VKUR/ELYnFRD+JPqna6dJbUqpNTEDBGrlPBpTb2HxcpKPbSrz0sXIH4jQswjclmOixwgK+ ahDObNbGf3QnPb09K5t0nYDxgtXMefVWjmEaPcnzz4yzXM8iTJFn0YexibFfkC1+yBbyVPo1R0bh2 yIcaGVH/ypO+kF3rumVvOzpy0ECG2mc05akA88d/BJfHX+SOpHmR6Hp4sZWjqlGn+uNgE6sLPfu2l rD0pT2LA==; Received: from [10.22.3.24] (helo=serv1.dd1.int.kernkonzept.com) by mx.kernkonzept.com with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.96) id 1qg4Ph-0034i9-1L; Tue, 12 Sep 2023 16:30:49 +0200 From: Stephan Gerhold Date: Tue, 12 Sep 2023 16:30:37 +0200 Subject: [PATCH 2/4] spi: qup: Parse OPP table for DVFS support MIME-Version: 1.0 Message-Id: <20230912-spi-qup-dvfs-v1-2-3e38aa09c2bd@kernkonzept.com> References: <20230912-spi-qup-dvfs-v1-0-3e38aa09c2bd@kernkonzept.com> In-Reply-To: <20230912-spi-qup-dvfs-v1-0-3e38aa09c2bd@kernkonzept.com> To: Mark Brown Cc: Andy Gross , Bjorn Andersson , Konrad Dybcio , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Krzysztof Kozlowski , linux-arm-msm@vger.kernel.org, linux-spi@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Stephan Gerhold X-Mailer: b4 0.12.3 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Tue, 12 Sep 2023 07:31:14 -0700 (PDT) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776857839338690088 X-GMAIL-MSGID: 1776857839338690088 Parse the OPP table from the device tree and use dev_pm_opp_set_rate() instead of clk_set_rate() to allow making performance state for power domains specified in the OPP table. This is needed to guarantee correct behavior of the clock, especially with the higher clock/SPI bus frequencies. Signed-off-by: Stephan Gerhold Acked-by: Konrad Dybcio --- drivers/spi/spi-qup.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-qup.c b/drivers/spi/spi-qup.c index 4b6f6b25219b..bf043be3a2a9 100644 --- a/drivers/spi/spi-qup.c +++ b/drivers/spi/spi-qup.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -667,7 +668,7 @@ static int spi_qup_io_prep(struct spi_device *spi, struct spi_transfer *xfer) return -EIO; } - ret = clk_set_rate(controller->cclk, xfer->speed_hz); + ret = dev_pm_opp_set_rate(controller->dev, xfer->speed_hz); if (ret) { dev_err(controller->dev, "fail to set frequency %d", xfer->speed_hz); @@ -1027,6 +1028,15 @@ static int spi_qup_probe(struct platform_device *pdev) return -ENXIO; } + ret = devm_pm_opp_set_clkname(dev, "core"); + if (ret) + return ret; + + /* OPP table is optional */ + ret = devm_pm_opp_of_add_table(dev); + if (ret && ret != -ENODEV) + return dev_err_probe(dev, ret, "invalid OPP table\n"); + host = spi_alloc_host(dev, sizeof(struct spi_qup)); if (!host) { dev_err(dev, "cannot allocate host\n"); From patchwork Tue Sep 12 14:30:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephan Gerhold X-Patchwork-Id: 138336 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp568075vqx; Tue, 12 Sep 2023 10:31:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGsmMgqhZbP4AgWrnTkJ5iYz0hfMqs+QHzGTYBKaVsbEywynrF308jHc27krD6ss8UH4gaM X-Received: by 2002:a17:90a:130d:b0:271:af7b:7c5e with SMTP id h13-20020a17090a130d00b00271af7b7c5emr10916488pja.44.1694539899260; Tue, 12 Sep 2023 10:31:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694539899; cv=none; d=google.com; s=arc-20160816; b=Jr2yLatOLjYxCLJ0pxAMLihKJtPaIxxTEfeDeF18tU97QTOU5JLa978+xANyjrzUcO tvr7iQMm/HmnbuEYeThhIpNqG8ML+XFyG2UlTja68YP1fWFvUruXlTNIw/CLXF7lq3EL Dtx+oxnn1VLQQmIu/G2WtMRPgLoWuRM7wYEf/pk86kY/RbPh7M0auhbGsMIvFs5QcPtY jW8Hx5yUB1yd+oQCkalhrUGBkfSxbVx4TmKXsU8QgVdkKPu7Or2HvSzhsloyDd62mGY1 re6kksQG35Sis6MAY17iQIrXz13nYykThoEPLY8YIy5ACaKZThFuemcesVdtR46vkj9d 4VZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=rqAqXU+BauAuZhoJ6lkP5DQOkX1bFvCYekVfXB5a7v4=; fh=10DQ9cLgm4jgsgyilmWpXaSieUpiqS1iqWfjfWaX8GI=; b=eKGuJwWN66RTc2FSkEV/gGmSJpL8Aj2RaVtTPBFQx9QT4ipwKoFN3lHIp0HJ3xG8ro CZt1Nq8+dKpcCgV6YkhuUWT5lbcXv/qZPUf9j5GzR8+noggKS70o33cHuU5c621AhMdg ugcX8GOzmVj/2Z1rMgWPPrByC6iOR57W+2J3YfQuoEYq6NN/Qg8GfcL/Or9o3roOCVOp wEvRCtY0h6tZ10nl3SE1P7b4+ngKNOzU8/rkEd0StR9ivzSAt02K85DFYXzqB/ZgEVb+ swq9SN2vDKS5K9BDflFO6xuLGtrNM4uIEqhHIgMpZA+q1sY5gzrACbnw/FncfXw86R3U DspA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernkonzept.com header.s=mx1 header.b=GgHrrHIg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernkonzept.com Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id ot14-20020a17090b3b4e00b00262d1b39524si8838958pjb.116.2023.09.12.10.31.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 10:31:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernkonzept.com header.s=mx1 header.b=GgHrrHIg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernkonzept.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id E589281603AD; Tue, 12 Sep 2023 07:31:39 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235985AbjILObE (ORCPT + 37 others); Tue, 12 Sep 2023 10:31:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235955AbjILOa6 (ORCPT ); Tue, 12 Sep 2023 10:30:58 -0400 Received: from mx.kernkonzept.com (serv1.kernkonzept.com [IPv6:2a01:4f8:1c1c:b490::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61F77115; Tue, 12 Sep 2023 07:30:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=kernkonzept.com; s=mx1; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From: Reply-To:Content-ID:Content-Description; bh=rqAqXU+BauAuZhoJ6lkP5DQOkX1bFvCYekVfXB5a7v4=; b=GgHrrHIgtFRan0MheQxCydItfh ekI6z8r3PAlYr1ztBSOqu+VTwuTgU30ollUcc+9On7jCN6lrdTW5t+ufWif2ZMJ8cP6YSTcVoHIsy /KiNRrW5tQm2JWo029WCYDLPBpSXo+Ag3wS+ouooevmNh/CQ47Kdp1YxIaQKjDv9lodJlnrZJOszc K1O9n9nQ38uQTsgi8NcaVIhfE0ow29Yy2nwVqZehpT6rZY3KythGZcAqjjkvtNXnXJD+wWuT9U2Oc VcCmXOgOei5oKnn0NGptbKFMRzjiPeq4+Jxu8rt6v20gYhkcref5r4ORCbXiN0HeeqiRzHMed/dfq 62nNSxxw==; Received: from [10.22.3.24] (helo=serv1.dd1.int.kernkonzept.com) by mx.kernkonzept.com with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.96) id 1qg4Pj-0034i9-02; Tue, 12 Sep 2023 16:30:51 +0200 From: Stephan Gerhold Date: Tue, 12 Sep 2023 16:30:38 +0200 Subject: [PATCH 3/4] spi: dt-bindings: qup: Document interconnects MIME-Version: 1.0 Message-Id: <20230912-spi-qup-dvfs-v1-3-3e38aa09c2bd@kernkonzept.com> References: <20230912-spi-qup-dvfs-v1-0-3e38aa09c2bd@kernkonzept.com> In-Reply-To: <20230912-spi-qup-dvfs-v1-0-3e38aa09c2bd@kernkonzept.com> To: Mark Brown Cc: Andy Gross , Bjorn Andersson , Konrad Dybcio , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Krzysztof Kozlowski , linux-arm-msm@vger.kernel.org, linux-spi@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Stephan Gerhold X-Mailer: b4 0.12.3 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Tue, 12 Sep 2023 07:31:40 -0700 (PDT) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776853869400729660 X-GMAIL-MSGID: 1776853869400729660 When the SPI QUP controller is used together with a DMA engine it needs to vote for the interconnect path to the DRAM. Otherwise it may be unable to access the memory quickly enough. Signed-off-by: Stephan Gerhold Reviewed-by: Krzysztof Kozlowski --- Documentation/devicetree/bindings/spi/qcom,spi-qup.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Documentation/devicetree/bindings/spi/qcom,spi-qup.yaml b/Documentation/devicetree/bindings/spi/qcom,spi-qup.yaml index 1e498a791406..88be13268962 100644 --- a/Documentation/devicetree/bindings/spi/qcom,spi-qup.yaml +++ b/Documentation/devicetree/bindings/spi/qcom,spi-qup.yaml @@ -44,6 +44,9 @@ properties: - const: tx - const: rx + interconnects: + maxItems: 1 + interrupts: maxItems: 1 @@ -67,6 +70,7 @@ unevaluatedProperties: false examples: - | #include + #include #include #include @@ -84,6 +88,7 @@ examples: dma-names = "tx", "rx"; power-domains = <&rpmpd MSM8996_VDDCX>; operating-points-v2 = <&spi_opp_table>; + interconnects = <&pnoc MASTER_BLSP_1 &bimc SLAVE_EBI_CH0>; #address-cells = <1>; #size-cells = <0>; }; From patchwork Tue Sep 12 14:30:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephan Gerhold X-Patchwork-Id: 138508 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp773258vqx; Tue, 12 Sep 2023 17:49:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH+d/MlLqvXoqlbF0hIUMLYtmrb/cfzev/Nd+xwHJKAy3MiXPl+WOpcvYMphFeWZGkxxL+F X-Received: by 2002:a05:620a:2413:b0:76f:1aaa:1bee with SMTP id d19-20020a05620a241300b0076f1aaa1beemr1174413qkn.62.1694566184905; Tue, 12 Sep 2023 17:49:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694566184; cv=none; d=google.com; s=arc-20160816; b=cuanoQRBOdRuDx5jkav7G6qptUrVVU2JTbCwcb4byTwjcdW6lpHrMyJiphBEHpHBCs MRu50BTuVV3k/LC3f38bLxaybFhrbV6M+WR/iueN/wB/h2Zn//B4alZV9i/RzxLwYntA FLPWbO1kGXtm8OTxBujC4oAE77OnPtwNh+rbEuMkjQmBPk7Ts+GfMwJ+nDsmRzaV9q6V Ap9bikOfvCAkGEp0FfUtpMZxPT8YqqNDcRxQdf5/p2y8u5Hit6hNkvnBzc7mXnajRn1g hU1v0GFm4j397XlAMJKUoex3VzppjkGbRfKHNfCCYZbj0U6W0vzmqi1JzjUAmmI4om4G D5Gg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=d8aTXSfXKUiK1Xyz5/399gXFzKYpAJm1Z7s+7n6AgiA=; fh=10DQ9cLgm4jgsgyilmWpXaSieUpiqS1iqWfjfWaX8GI=; b=LZStGosdtcbl+lBLnSHSdRRYaZ0s2LEeAnCGCWdk63cFyYb3HLOwITZsPvFCI6ORUU V7YVaPm1geZFWGF3+ZETtrBhVg9rUkJVrwkoNSYDRbM0tGj9ccNepchuEcn1UC75wMYZ FoHl6+rQ6Rpju4jUGdQegdSUvxv3Pbmlf/4AHW4jMkYfnd4WJSGkMEbnmjnFBPX+G9Ms yDbbBD+VEhU2OnXIfWTOayCGJ25jjk1RqLDp4hw2Ky1v8dEa5KBg6/FLNWOum2FfeICK txRJG/fztcQYfwwez+XbqrcJMaaIJ6T48MM6HQRxHOLzd6fctRXk+WoQksZgf0fPkCmo +UfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernkonzept.com header.s=mx1 header.b=VW2OT9ME; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernkonzept.com Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id k7-20020a633d07000000b00565e98183d6si9097041pga.626.2023.09.12.17.49.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 17:49:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@kernkonzept.com header.s=mx1 header.b=VW2OT9ME; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernkonzept.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id E598580F7293; Tue, 12 Sep 2023 07:31:37 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235995AbjILObG (ORCPT + 37 others); Tue, 12 Sep 2023 10:31:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235968AbjILOa7 (ORCPT ); Tue, 12 Sep 2023 10:30:59 -0400 Received: from mx.kernkonzept.com (serv1.kernkonzept.com [IPv6:2a01:4f8:1c1c:b490::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC88FCC7; Tue, 12 Sep 2023 07:30:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=kernkonzept.com; s=mx1; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From: Reply-To:Content-ID:Content-Description; bh=d8aTXSfXKUiK1Xyz5/399gXFzKYpAJm1Z7s+7n6AgiA=; b=VW2OT9MEsssDRMkwh3Uc/UV/sU ZvJI7PAAq82QQLTuNMbZ4JB2NvSLaDDhCPziIIIXjoZuw5Si5G7cBoMsE6xSHv21w48NpUQnK+0aS xlAPsANfObrC1zT09ttft7W+z3JCpckVRiUodnA48hUGcsuU5GRfWlotgo1sSQ/yewjwa4Ld/fYdl nImSY9IBb27xYyDp8bkpdUjxhq30ecnHdGpf0m7nyf5FLHMUCl0mrXQXGHsMEw7GBj54hLCAAKRa7 hNAcKfTXX6fvIWrmTWQ9wqC2+4JOJBdElsYVcng7iofUJJ6jJIG88oT9CmsDCrBpjht7ereCuItgF jxnItlew==; Received: from [10.22.3.24] (helo=serv1.dd1.int.kernkonzept.com) by mx.kernkonzept.com with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.96) id 1qg4Pk-0034i9-1z; Tue, 12 Sep 2023 16:30:52 +0200 From: Stephan Gerhold Date: Tue, 12 Sep 2023 16:30:39 +0200 Subject: [PATCH 4/4] spi: qup: Vote for interconnect bandwidth to DRAM MIME-Version: 1.0 Message-Id: <20230912-spi-qup-dvfs-v1-4-3e38aa09c2bd@kernkonzept.com> References: <20230912-spi-qup-dvfs-v1-0-3e38aa09c2bd@kernkonzept.com> In-Reply-To: <20230912-spi-qup-dvfs-v1-0-3e38aa09c2bd@kernkonzept.com> To: Mark Brown Cc: Andy Gross , Bjorn Andersson , Konrad Dybcio , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Krzysztof Kozlowski , linux-arm-msm@vger.kernel.org, linux-spi@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Stephan Gerhold X-Mailer: b4 0.12.3 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Tue, 12 Sep 2023 07:31:38 -0700 (PDT) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776881431880327383 X-GMAIL-MSGID: 1776881431880327383 When the SPI QUP controller is used together with a DMA engine it needs to vote for the interconnect path to the DRAM. Otherwise it may be unable to access the memory quickly enough. The requested peak bandwidth is dependent on the SPI core/bus clock so that the bandwidth scales together with the selected SPI speed. To avoid sending votes too often the bandwidth is always requested when a transfer starts, but dropped only on runtime suspend. Runtime suspend should only happen if no transfer is active. After resumption we can defer the next vote until the first transfer actually happens. Signed-off-by: Stephan Gerhold --- The bandwidth calculation is taken over from Qualcomm's downstream/vendor driver [1]. Due to lack of documentation about the interconnect setup/behavior I cannot say exactly if this is right. Unfortunately, this is not implemented very consistently downstream... [1]: https://git.codelinaro.org/clo/la/kernel/msm-3.18/-/commit/deca0f346089d32941d6d8194ae9605554486413 --- drivers/spi/spi-qup.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/drivers/spi/spi-qup.c b/drivers/spi/spi-qup.c index bf043be3a2a9..e9c186bc530c 100644 --- a/drivers/spi/spi-qup.c +++ b/drivers/spi/spi-qup.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -122,11 +123,14 @@ #define SPI_DELAY_THRESHOLD 1 #define SPI_DELAY_RETRY 10 +#define SPI_BUS_WIDTH 8 + struct spi_qup { void __iomem *base; struct device *dev; struct clk *cclk; /* core clock */ struct clk *iclk; /* interface clock */ + struct icc_path *icc_path; /* interconnect to RAM */ int irq; spinlock_t lock; @@ -149,6 +153,8 @@ struct spi_qup { int mode; struct dma_slave_config rx_conf; struct dma_slave_config tx_conf; + + u32 bw_speed_hz; }; static int spi_qup_io_config(struct spi_device *spi, struct spi_transfer *xfer); @@ -181,6 +187,23 @@ static inline bool spi_qup_is_valid_state(struct spi_qup *controller) return opstate & QUP_STATE_VALID; } +static int spi_qup_vote_bw(struct spi_qup *controller, u32 speed_hz) +{ + u32 needed_peak_bw; + int ret; + + if (controller->bw_speed_hz == speed_hz) + return 0; + + needed_peak_bw = Bps_to_icc(speed_hz * SPI_BUS_WIDTH); + ret = icc_set_bw(controller->icc_path, 0, needed_peak_bw); + if (ret) + return ret; + + controller->bw_speed_hz = speed_hz; + return 0; +} + static int spi_qup_set_state(struct spi_qup *controller, u32 state) { unsigned long loop; @@ -675,6 +698,12 @@ static int spi_qup_io_prep(struct spi_device *spi, struct spi_transfer *xfer) return -EIO; } + ret = spi_qup_vote_bw(controller, xfer->speed_hz); + if (ret) { + dev_err(controller->dev, "fail to vote for ICC bandwidth: %d\n", ret); + return -EIO; + } + controller->w_size = DIV_ROUND_UP(xfer->bits_per_word, 8); controller->n_words = xfer->len / controller->w_size; @@ -994,6 +1023,7 @@ static void spi_qup_set_cs(struct spi_device *spi, bool val) static int spi_qup_probe(struct platform_device *pdev) { struct spi_controller *host; + struct icc_path *icc_path; struct clk *iclk, *cclk; struct spi_qup *controller; struct resource *res; @@ -1019,6 +1049,11 @@ static int spi_qup_probe(struct platform_device *pdev) if (IS_ERR(iclk)) return PTR_ERR(iclk); + icc_path = devm_of_icc_get(dev, NULL); + if (IS_ERR(icc_path)) + return dev_err_probe(dev, PTR_ERR(icc_path), + "failed to get interconnect path\n"); + /* This is optional parameter */ if (of_property_read_u32(dev->of_node, "spi-max-frequency", &max_freq)) max_freq = SPI_MAX_RATE; @@ -1070,6 +1105,7 @@ static int spi_qup_probe(struct platform_device *pdev) controller->base = base; controller->iclk = iclk; controller->cclk = cclk; + controller->icc_path = icc_path; controller->irq = irq; ret = spi_qup_init_dma(host, res->start); @@ -1190,6 +1226,7 @@ static int spi_qup_pm_suspend_runtime(struct device *device) writel_relaxed(config, controller->base + QUP_CONFIG); clk_disable_unprepare(controller->cclk); + spi_qup_vote_bw(controller, 0); clk_disable_unprepare(controller->iclk); return 0; @@ -1241,6 +1278,7 @@ static int spi_qup_suspend(struct device *device) return ret; clk_disable_unprepare(controller->cclk); + spi_qup_vote_bw(controller, 0); clk_disable_unprepare(controller->iclk); return 0; }