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: 10785317 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 98250746 for ; Tue, 29 Jan 2019 01:56:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 89F812AC4E for ; Tue, 29 Jan 2019 01:56:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7E2842AD6D; Tue, 29 Jan 2019 01:56:15 +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 330202AC4E for ; Tue, 29 Jan 2019 01:56:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727483AbfA2B4E (ORCPT ); Mon, 28 Jan 2019 20:56:04 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:40342 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727309AbfA2Bzy (ORCPT ); Mon, 28 Jan 2019 20:55:54 -0500 Received: by mail-pg1-f193.google.com with SMTP id z10so8044922pgp.7 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=HasPrFzLAiaOfT8hq4E4hoBwCphMJbO6g8WgDL8D1rmGWWuZauMzzCE8UqVd0/ClmJ GUT0a8YjoMJOla8aJ0NS1/RDcuhctOCJMgpHqeNLo+fvlMIoHfX14pMRdfC6pMpWfWgh jlsTdetYSh2ggHnly2iC0GWPzsx0DfnM6v1H6E7fHeIzjbNddnuP78MaKeLtJ4weM9GW 8eAe00CYDNYnHcqtRGZqj/5iZFvlol4NocmQeeDr/S9RaagGQmGox8HMCvywbeF0Bn5Z gAnwDzx56js3YyC1JWnn0eMzZDPk47vnWt6XUCTOKKZSUM0avLoTKJRS9NUOE7dVv31h FNLQ== X-Gm-Message-State: AJcUukeWVb9fgUZRe4tKH3VIKGuUURqZnB1rR8tMSSkKaZ5bCUMzHfMt 6NZlnvxigzDwj25rsmP4KSNKRw== 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-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@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); }