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: 10785309 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 A8A6313B5 for ; Tue, 29 Jan 2019 01:55:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 976502AC4E for ; Tue, 29 Jan 2019 01:55:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8BBC62AD6D; Tue, 29 Jan 2019 01:55:59 +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=ham 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 367552AC4E for ; Tue, 29 Jan 2019 01:55:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726995AbfA2Bz5 (ORCPT ); Mon, 28 Jan 2019 20:55:57 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:45187 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727320AbfA2Bzy (ORCPT ); Mon, 28 Jan 2019 20:55:54 -0500 Received: by mail-pg1-f194.google.com with SMTP id y4so8031783pgc.12 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=SLV/YjULHqZLw6eeNWENRUL49FaeTiVRSp/fhuk+o7A1W8YB5Sk+IwynSARhD78vht h695qnPqDSvFV8OLE6ymMit1QofL8o00AlkN5tNF+tKUBDlVn3qLwQClktM+lqjpXSUN L5fKtSQIPWimCK1H8WY6jup4F2aVWW+neeLJF0gAIdsJ5HgX131x4SDfqiwbjz8eKwRm E7RVxUthn/I4u0TRVl/SQk/h83feOSvgWVIDkTesKVlnMrDPunPDBxQhSH/Ei14DMj/n hzhDmUWrft1gbyz1H4icYt86uNij34I+14AA0K3N0/VZM8AMqm8Nx2MvdugdaQhsah7N CF+w== X-Gm-Message-State: AJcUukexEkM7upvAjyyuQhmlDvu3GtyZbBt5CIj9GH1qAZoGiTQfKLeP j5ncW2+YbgyRh8ftdETHuTlkmw== 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-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@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); }