From patchwork Tue Sep 19 11:59:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephan Gerhold X-Patchwork-Id: 142054 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp3604191vqi; Tue, 19 Sep 2023 11:45:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG2BZ+D9sqXZ7YuxggdG54pXTp0pZE3XlxVU72j5tlgQaUlA7AsYZn/jcmmj0DgQGfAuIH9 X-Received: by 2002:a05:6a20:840d:b0:154:6480:83b4 with SMTP id c13-20020a056a20840d00b00154648083b4mr504230pzd.14.1695149102214; Tue, 19 Sep 2023 11:45:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695149102; cv=none; d=google.com; s=arc-20160816; b=xJSI2+a2IVE8BlkbhCXVXfyZayXzishm4FJysxR/8ps9XOdkv9ncK/fmfuTOkcO61g mTDpsR8hpCV0VRA7rcvPeE5ftRdiDXpw5OiLi2fFyuxwwP8tynrIxvqcmsSr5vZYNK+z D3DPzQfBpdwRpvjmwEQnQItCWxXRL/wctLPRL+LUHqIi8uQo6zeTtffuN0A2JXKCj9h0 8QCLy1Z+m7N8l0AVpyZkt7/pU823RhQHUuKSYkoUmADFf1vdV56bTH3scHHqsWrCF4AV 3rygFtb+20Y/WSS4iPzw8eej6Uh5P2YU74uyxnVh3vie3ywATNCrL6+By9NmxSGAXpPv 7nSg== 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=7Gt4TKjLSJcXOSLnXDaTB2+6o7ALKK+hltx0sbV1x1k=; fh=mHtE22rw26zT1C92+7aL8X5xYl1wIu9e3YZGdL6Rd5o=; b=oyIW9w/9MnTN9p6J/UzqdvzIaGQgYRa9SOYVOdpGBZ6oyKQaEhoiBbHK7kZNsrHBfP SDxQZ640Hn9/XZQGg0e4McBn+v/E6EF9RCk0t3SNvnUGFEcJhEghwaZjYzghn7bhLFLX wuL1q6O/WntqQckwzaKAFKVi4lA5SykKltPccdZVLuv0bng45O+g9AMDwKerfW3NyY1A 0nRplnmLiz3sSypH287FYMIVcJVSAR2F0084ux3fmBV1E9i3Qtzr3zI+ctuolV+B6Zm1 PF7qpJcizrb12J86oBmHJmp8cO4ieWJ2SPqw0qQvIDGUEa0+1/yK75cumqfYTzpmy5G3 obkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernkonzept.com header.s=mx1 header.b=pMDkiW9e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id b66-20020a636745000000b005774635c69dsi10058056pgc.66.2023.09.19.11.45.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 11:45:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@kernkonzept.com header.s=mx1 header.b=pMDkiW9e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (Postfix) with ESMTP id 14DCF81E556F; Tue, 19 Sep 2023 05:01:03 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231195AbjISMAL (ORCPT + 26 others); Tue, 19 Sep 2023 08:00:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60242 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229853AbjISMAF (ORCPT ); Tue, 19 Sep 2023 08:00:05 -0400 Received: from mx.kernkonzept.com (serv1.kernkonzept.com [IPv6:2a01:4f8:1c1c:b490::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 972F1E3; Tue, 19 Sep 2023 04:59:59 -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=7Gt4TKjLSJcXOSLnXDaTB2+6o7ALKK+hltx0sbV1x1k=; b=pMDkiW9exbVAQG4r2+8jAeOpkh d20oAnv9G45lYOiYcJHFKl3l1Fs1RKNNNZ+5/iBHEnRWxhJtHEe7+uyx1sB6p4DldiJ2n8XAxXzg6 37kVueDxjq/Wm8IsJxz5j36P8GM7E3vy7dIdMPIxNynUqi+YD8eLR8Ew3fiubq847I/2w7QlF9iqF KfluCoEnHsYdEpwNCHb1Im8+jEjodiSGnWy9yWBFLNIbh/HspBCqx/rAns+e3stYK1RySc2E9yXDb Rz1bNzn7d1hLHBZIjo9+zzfq8PQ+y8wqi9INOUY+fwd+ioKT7sww9r+driM5UN3MajdA3+3kXEcXx BsVbYx2w==; 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 1qiZOW-004b4T-28; Tue, 19 Sep 2023 13:59:56 +0200 From: Stephan Gerhold Date: Tue, 19 Sep 2023 13:59:49 +0200 Subject: [PATCH v2 2/4] spi: qup: Parse OPP table for DVFS support MIME-Version: 1.0 Message-Id: <20230919-spi-qup-dvfs-v2-2-1bac2e9ab8db@kernkonzept.com> References: <20230919-spi-qup-dvfs-v2-0-1bac2e9ab8db@kernkonzept.com> In-Reply-To: <20230919-spi-qup-dvfs-v2-0-1bac2e9ab8db@kernkonzept.com> To: Mark Brown Cc: Andy Gross , Bjorn Andersson , Konrad Dybcio , Rob Herring , Krzysztof Kozlowski , Conor Dooley , 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 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 pete.vger.email 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 (pete.vger.email [0.0.0.0]); Tue, 19 Sep 2023 05:01:03 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777492665139681347 X-GMAIL-MSGID: 1777492665139681347 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. Acked-by: Konrad Dybcio Signed-off-by: Stephan Gerhold --- 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");