Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4691040yba; Tue, 30 Apr 2019 02:47:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqzP/ytdHf6LLy+E+js+uIVVWMXD8D0PdthNYe0/3ajhAjnC6lBw1MMA2rqbEaPlnm1wDZYl X-Received: by 2002:a17:902:8bc3:: with SMTP id r3mr22993942plo.53.1556617622632; Tue, 30 Apr 2019 02:47:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556617622; cv=none; d=google.com; s=arc-20160816; b=HF47NaJMWZuBxMMJO8X02+mh5ujqasAX01VQ16LKKSZucQzREJErZI2+5PaO//8HKv GWi7UAEFZqFy0GPoPqeCtR1Qn8GtXoMoIs6NYZ8mdI7Xwo7ZtuoayXRle+w7rCWGl98O e/IGl5mKknP/SfEyHeAE/xcwiMnRKQNmV7ESJkAeG2csLKmX46yg9MNeRyA4XStJ3HPg WF1cN3rEXrHGbUxTM7SlZS9mE2Y5pMMVTrdegGvupI55aRXRhb4UG16AeinmmYkbsmFk rFcj7Pjn7j4K+8Zwq/FnpmCzvm7Htz5lZceqngx3i47ai1561S3JYIaezgqDq/buT2zD Q11g== 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=O7+zYQqNLnX2XDcjqQWLG4mHCyH2ratGQ7iWFMZQC2c=; b=Wxdho2CExq9Fb6/0FFA8MtdBGHyvaZzIjPSnRLzy9vug6qtM4eWjl2GG3wLuxn7YMx v/viK6yxdVoLwKWZ6+v0skL8nSaRzVLgZYjQyLoSS1WErt0ygSnbpHowfPPtaQMI0dMD IlUx3d2JhK2DV/9zylOzr0HzSxZ/IPZd+PB38Rr+GDz9Vz+nDP/uYGlThjJxOeRnnp/8 AZKx5kLYv0XVkE4IVRXE/R1vpGR9J9yjpo0Yqo+iWLUfr6ki6VhstNdPh6qEF5iOqFlX oDsYf0ih7et5xFd1UvRI5Krw5FaG5wPnSy0G0bpuL8D5UaEWgw/jfY5rbRg8p0x6y/1h 8/tw== 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 a1si21605867pgh.517.2019.04.30.02.46.35; Tue, 30 Apr 2019 02:47:02 -0700 (PDT) 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 S1726769AbfD3Jpd (ORCPT + 99 others); Tue, 30 Apr 2019 05:45:33 -0400 Received: from mailgw01.mediatek.com ([210.61.82.183]:63902 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1727096AbfD3Jpb (ORCPT ); Tue, 30 Apr 2019 05:45:31 -0400 X-UUID: 4de84ea105dc4c12989653f56b830b3a-20190430 X-UUID: 4de84ea105dc4c12989653f56b830b3a-20190430 Received: from mtkcas07.mediatek.inc [(172.21.101.84)] by mailgw01.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 1725120801; Tue, 30 Apr 2019 17:45:21 +0800 Received: from mtkcas09.mediatek.inc (172.21.101.178) by mtkmbs02n2.mediatek.inc (172.21.101.101) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Tue, 30 Apr 2019 17:45:19 +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; Tue, 30 Apr 2019 17:45:19 +0800 From: Henry Chen To: Georgi Djakov , Rob Herring , Matthias Brugger , Viresh Kumar , Stephen Boyd CC: Nicolas Boichat , Fan Chen , James Liao , Weiyi Lu , , , , , Henry Chen Subject: [RFC V2 03/11] soc: mediatek: add support for the performance state Date: Tue, 30 Apr 2019 16:50:57 +0800 Message-ID: <1556614265-12745-4-git-send-email-henryc.chen@mediatek.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1556614265-12745-1-git-send-email-henryc.chen@mediatek.com> References: <1556614265-12745-1-git-send-email-henryc.chen@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-TM-SNTS-SMTP: 3237D3CA08FF8E8F307433A610F0F2EB87419DAB5EF29E037680A1C513F1CA872000:8 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 | 53 +++++++++++++++++++++++++++++++++++++++ drivers/soc/mediatek/mtk-scpsys.h | 22 ++++++++++++++++ 2 files changed, 75 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 f1d82cd..be8c948 100644 --- a/drivers/soc/mediatek/mtk-scpsys.c +++ b/drivers/soc/mediatek/mtk-scpsys.c @@ -10,7 +10,9 @@ #include #include #include +#include #include +#include #include #include @@ -21,6 +23,7 @@ #include #include #include +#include "mtk-scpsys.h" #define MTK_POLL_DELAY_US 10 #define MTK_POLL_TIMEOUT USEC_PER_SEC @@ -188,6 +191,18 @@ struct scp_soc_data { bool bus_prot_reg_update; }; +static 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; @@ -519,6 +534,41 @@ 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; + } + } + + if (i == pd_data->num_domains) + return 0; + + 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) +{ + return dev_pm_opp_get_level(opp); +} + 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, @@ -642,6 +692,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