From patchwork Tue Jan 29 01:55:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 10785313 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8E4F513B5 for ; Tue, 29 Jan 2019 01:56:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7F3222AC4E for ; Tue, 29 Jan 2019 01:56:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 73C892AD6D; Tue, 29 Jan 2019 01:56:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2B37E2AC4E for ; Tue, 29 Jan 2019 01:56:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727322AbfA2B4E (ORCPT ); Mon, 28 Jan 2019 20:56:04 -0500 Received: from mail-pf1-f195.google.com ([209.85.210.195]:44425 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727323AbfA2Bzy (ORCPT ); Mon, 28 Jan 2019 20:55:54 -0500 Received: by mail-pf1-f195.google.com with SMTP id u6so8873938pfh.11 for ; Mon, 28 Jan 2019 17:55:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gji32VkUeCkRxiH9mP+AVAmiusPVWMB1ViiGWccVEm0=; b=if5BJhOTMgRmISQRpJ3xFZzCEC7YMFAijTQxrWOvLcZZrCsLcrCrPg9bfsp4xRvltz 9W+LfLECCh7NouIuswObxi/mSMWhQL28P7kH4/mNpOhBk8h8xXmVuoH8uAK6GZx9gfwe TgzMp2yBxkHWDaE/XbtsWUcyp8IANp1eGSYYc= 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=gji32VkUeCkRxiH9mP+AVAmiusPVWMB1ViiGWccVEm0=; b=S5BHp/D2kfn2BJ87Y4vjsVeHcwqxW6Fw7UrwsOaSG47aUStJRaNGoDgUUXv9mPRVpW 5WPyaqMIik2K97SqZOmMqtz1C+JNCqjNYcUffmakRBtSjQbsomWrNovYAJmfkUrPAiQT 1/ZXX8HjXPC0pvrAdIObpAQjQsXSQgTKf9byuCaNT+K5Vth9C43ECo9DgRVqvMkIQFmA miIVpGjSe8rA7PfPhO3xNDDMY8bVGPGHqWdjuJwmRonJO1raW021QVxIMhwcaEW4U5hr 3lqe029e4tlnpxM7Vln5AEoZpqZeStx9pYfAWa769mCk9CHP5RgzQfPfFjcL4EPUBw9u 8c4g== X-Gm-Message-State: AJcUukfMSsksFWBnbZ8F2Bp7dGMSTn6i36u2AWov7Wx6mjrM1D+tMYmH N8edpcYdRDKrZARY0/sAz5FgHA== X-Google-Smtp-Source: ALg8bN5ERw1GU45DC++AuwfXEApEUb3qSQtkp1lhzdWUfT8L6lhNrZdWZg5sQ0IRaOTQy4KysX+Ejw== X-Received: by 2002:a65:484c:: with SMTP id i12mr21807451pgs.309.1548726953832; Mon, 28 Jan 2019 17:55:53 -0800 (PST) Received: from smtp.gmail.com ([2620:15c:202:1:fa53:7765:582b:82b9]) by smtp.gmail.com with ESMTPSA id g15sm142911530pfj.131.2019.01.28.17.55.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Jan 2019 17:55:53 -0800 (PST) From: Stephen Boyd To: linux-kernel@vger.kernel.org Cc: Rajendra Nayak , linux-arm-msm@vger.kernel.org, linux-pm@vger.kernel.org, linux-serial@vger.kernel.org, linux-spi@vger.kernel.org, Ulf Hansson , Viresh Kumar , Doug Anderson Subject: [RFC/PATCH 4/5] spi: spi-geni-qcom: Use OPP API to set clk/perf state Date: Mon, 28 Jan 2019 17:55:46 -0800 Message-Id: <20190129015547.213276-5-swboyd@chromium.org> X-Mailer: git-send-email 2.20.1.495.gaa96b0ce6b-goog In-Reply-To: <20190129015547.213276-1-swboyd@chromium.org> References: <20190129015547.213276-1-swboyd@chromium.org> MIME-Version: 1.0 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Rajendra Nayak geni spi needs to express a perforamnce state requirement on CX depending on the frequency of the clock rates. Use OPP table from DT to register with OPP framework and use dev_pm_opp_set_rate() to set the clk/perf state. Signed-off-by: Rajendra Nayak Signed-off-by: Stephen Boyd --- drivers/spi/spi-geni-qcom.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi-geni-qcom.c b/drivers/spi/spi-geni-qcom.c index fdb7cb88fb56..3ffb6b25b58d 100644 --- a/drivers/spi/spi-geni-qcom.c +++ b/drivers/spi/spi-geni-qcom.c @@ -116,9 +116,9 @@ static int get_spi_clk_cfg(unsigned int speed_hz, dev_dbg(mas->dev, "req %u=>%u sclk %lu, idx %d, div %d\n", speed_hz, actual_hz, sclk_freq, *clk_idx, *clk_div); - ret = clk_set_rate(se->clk, sclk_freq); + ret = dev_pm_opp_set_rate(mas->dev, sclk_freq); if (ret) - dev_err(mas->dev, "clk_set_rate failed %d\n", ret); + dev_err(mas->dev, "dev_pm_opp_set_rate failed %d\n", ret); return ret; } @@ -564,6 +564,12 @@ static int spi_geni_probe(struct platform_device *pdev) if (!spi) return -ENOMEM; + ret = dev_pm_opp_of_add_table(&pdev->dev); + if (ret < 0) { + dev_err(&pdev->dev, "failed to init OPP table: %d\n", ret); + return ret; + } + platform_set_drvdata(pdev, spi); mas = spi_master_get_devdata(spi); mas->irq = irq; @@ -629,6 +635,8 @@ static int __maybe_unused spi_geni_runtime_suspend(struct device *dev) struct spi_master *spi = dev_get_drvdata(dev); struct spi_geni_master *mas = spi_master_get_devdata(spi); + /* Drop the performance state vote */ + dev_pm_opp_set_rate(dev, 0); return geni_se_resources_off(&mas->se); }