Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp324474imu; Wed, 2 Jan 2019 07:23:51 -0800 (PST) X-Google-Smtp-Source: ALg8bN4mSj+qRWqTqo4nNUiFtJwtLeAzwWUcBgDAd5XKuojGDk5i91BxM5BJeG51TEcV5flSMFp+ X-Received: by 2002:a63:f658:: with SMTP id u24mr14006584pgj.267.1546442631456; Wed, 02 Jan 2019 07:23:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546442631; cv=none; d=google.com; s=arc-20160816; b=C3J2JAwdLnOoBKx0mN8sMnisr4HAVk2SW4vnswpC/+Z81szBUpXdqEFSZLW55E19l7 JSsLwG5OiwQWmLceWKDRqMwJnI3peUQZz14E9h5XB9kG9TN4kx4w5C7n4d85Nz/GEt57 gxYdVyalLtRfIIVHgm1aMNDdNQqTkoztq2eCvJ5mYKYRXneWKTPegMVOQkYsDZIiT1LV g5Ff7EeUEOHPpUzjVujEmshmo8TiXYHrtvO8ufa7JyuEWGcRF2Osal1j90nNs0mVG+jy UxmSJ8yrlVsKaNBPnujabbL/RKNolQRVh0sLRZzZ2CMr0sBno8D65/dcqyldQAGBY0Sa C39Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=nL0tsiHg8bAoHjq1l6FB+P8GGa22ObhgE1bqssmk0DM=; b=oc4cvo+x1G9QGN1OeVdYsx+CjJH0S9dMr4BJLRaezOfH/djjriGQlD/fAY7l8dAwRF hm7t7Kb2baQChXZrovqb8Afy+TrH4lo+PjiuVhvlV/eGCqgkVjI9kDPskyrrXOqscunt bN2CGft9Mzctls5m5JocvGDB+6FTeNqqZermcoAoJheBI3uKzgrPg5xibGFzbSzpxp70 8f44EglDcyzgLpXwY6+42R16cs0pr/gq+/+5WF4Mmqms9pfZkKWL9NQf3JesOK7Yt2iI AiTryEKrqUpwMiFc6rseJgvbVrBv9sJDq6/GH8eiZYIO9YqVfkHBcaP43muIJBjgoURK PJbA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x32si23940583pgk.309.2019.01.02.07.23.36; Wed, 02 Jan 2019 07:23:51 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730041AbfABOBJ (ORCPT + 99 others); Wed, 2 Jan 2019 09:01:09 -0500 Received: from mailgw01.mediatek.com ([210.61.82.183]:1870 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1729412AbfABOBH (ORCPT ); Wed, 2 Jan 2019 09:01:07 -0500 X-UUID: a8eb4142ffac4cb99784bb5fba787142-20190102 X-UUID: a8eb4142ffac4cb99784bb5fba787142-20190102 Received: from mtkcas06.mediatek.inc [(172.21.101.30)] by mailgw01.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 1560076886; Wed, 02 Jan 2019 22:00:57 +0800 Received: from mtkcas09.mediatek.inc (172.21.101.178) by mtkmbs03n1.mediatek.inc (172.21.101.181) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Wed, 2 Jan 2019 22:00:56 +0800 Received: from mtkslt205.mediatek.inc (10.21.15.75) by mtkcas09.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Wed, 2 Jan 2019 22:00:56 +0800 From: Henry Chen To: Viresh Kumar , Stephen Boyd , Rob Herring , Matthias Brugger , Ulf Hansson CC: Mark Rutland , Fan Chen , Weiyi Lu , James Liao , Kees Cook , , , , , , Henry Chen Subject: [RFC PATCH 3/7] soc: mediatek: add support for the performance state Date: Wed, 2 Jan 2019 21:44:00 +0800 Message-ID: <1546436644-19234-4-git-send-email-henryc.chen@mediatek.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1546436644-19234-1-git-send-email-henryc.chen@mediatek.com> References: <1546436644-19234-1-git-send-email-henryc.chen@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Support power domain performance state, add header file for scp event. Signed-off-by: Henry Chen --- drivers/soc/mediatek/mtk-scpsys.c | 60 +++++++++++++++++++++++++++++++++++++++ drivers/soc/mediatek/mtk-scpsys.h | 22 ++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 drivers/soc/mediatek/mtk-scpsys.h diff --git a/drivers/soc/mediatek/mtk-scpsys.c b/drivers/soc/mediatek/mtk-scpsys.c index 58d84fe..90102ae 100644 --- a/drivers/soc/mediatek/mtk-scpsys.c +++ b/drivers/soc/mediatek/mtk-scpsys.c @@ -11,7 +11,9 @@ #include #include #include +#include #include +#include #include #include @@ -22,6 +24,7 @@ #include #include #include +#include "mtk-scpsys.h" #define MTK_POLL_DELAY_US 10 #define MTK_POLL_TIMEOUT (jiffies_to_usecs(HZ)) @@ -187,6 +190,18 @@ struct scp_soc_data { bool bus_prot_reg_update; }; +BLOCKING_NOTIFIER_HEAD(scpsys_notifier_list); + +int register_scpsys_notifier(struct notifier_block *nb) +{ + return blocking_notifier_chain_register(&scpsys_notifier_list, nb); +} + +int unregister_scpsys_notifier(struct notifier_block *nb) +{ + return blocking_notifier_chain_unregister(&scpsys_notifier_list, nb); +} + static int scpsys_domain_is_on(struct scp_domain *scpd) { struct scp *scp = scpd->scp; @@ -536,6 +551,48 @@ static void init_clks(struct platform_device *pdev, struct clk **clk) clk[i] = devm_clk_get(&pdev->dev, clk_names[i]); } +static int mtk_pd_set_performance(struct generic_pm_domain *genpd, + unsigned int state) +{ + int i; + struct scp_domain *scpd = + container_of(genpd, struct scp_domain, genpd); + struct scp_event_data scpe; + struct scp *scp = scpd->scp; + struct genpd_onecell_data *pd_data = &scp->pd_data; + + for (i = 0; i < pd_data->num_domains; i++) { + if (genpd == pd_data->domains[i]) { + dev_dbg(scp->dev, "%d. %s = %d\n", + i, genpd->name, state); + break; + } + } + + scpe.event_type = MTK_SCPSYS_PSTATE; + scpe.genpd = genpd; + scpe.domain_id = i; + blocking_notifier_call_chain(&scpsys_notifier_list, state, &scpe); + + return 0; +} + +static unsigned int mtk_pd_get_performance(struct generic_pm_domain *genpd, + struct dev_pm_opp *opp) +{ + struct device_node *np; + unsigned int state; + + np = dev_pm_opp_get_of_node(opp); + + if (of_property_read_u32(np, "mtk,level", &state)) + return 0; + + of_node_put(np); + + return state; +} + static struct scp *init_scp(struct platform_device *pdev, const struct scp_domain_data *scp_domain_data, int num, const struct scp_ctrl_reg *scp_ctrl_reg, @@ -659,6 +716,9 @@ static struct scp *init_scp(struct platform_device *pdev, genpd->power_on = scpsys_power_on; if (MTK_SCPD_CAPS(scpd, MTK_SCPD_ACTIVE_WAKEUP)) genpd->flags |= GENPD_FLAG_ACTIVE_WAKEUP; + + genpd->set_performance_state = mtk_pd_set_performance; + genpd->opp_to_performance_state = mtk_pd_get_performance; } return scp; diff --git a/drivers/soc/mediatek/mtk-scpsys.h b/drivers/soc/mediatek/mtk-scpsys.h new file mode 100644 index 0000000..c1e8325 --- /dev/null +++ b/drivers/soc/mediatek/mtk-scpsys.h @@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: GPL-2.0 + * + * Copyright (c) 2018 MediaTek Inc. + */ + +#ifndef __MTK_SCPSYS_H__ +#define __MTK_SCPSYS_H__ + +struct scp_event_data { + int event_type; + int domain_id; + struct generic_pm_domain *genpd; +}; + +enum scp_event_type { + MTK_SCPSYS_PSTATE, +}; + +int register_scpsys_notifier(struct notifier_block *nb); +int unregister_scpsys_notifier(struct notifier_block *nb); + +#endif /* __MTK_SCPSYS_H__ */ -- 1.9.1