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");