Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp20090imu; Thu, 3 Jan 2019 13:10:17 -0800 (PST) X-Google-Smtp-Source: ALg8bN696KWhP6PJDU1B+Lex3vvQ9m7nGjo4KHvcNqk5XeDkuSQJDBxAI74tbbB0+126jf03cUdB X-Received: by 2002:a63:680a:: with SMTP id d10mr18535348pgc.396.1546549817288; Thu, 03 Jan 2019 13:10:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546549817; cv=none; d=google.com; s=arc-20160816; b=P/HZ0+x+O9iYU8A5PcPc1+rz4ckaofkS1Lp+L5BQ3Ui8G7Rjf8rq34SCqkiUpRi8uf cO9l+E9snpNotrzJocR+bk/AbACD3SwYGROm8qNXBk5Yj92dVeWKCaMV28A6cA6HY61E 7QwerU11u/S4rVb7s4Dok48mGILXN2r6WsjByIXklNRBYSDmGZgCfm7papnIn+v5qO1q ep9qsyZ/Ut33uFSeaWGEU1xfJ5GkspAn3x8fvkhshveWCz+PBzKIQtvBOHJJMuImXjVn MmL1qbUiJdAs+iu613CltCuN5L4ArKgNYI1mNdQV/MK1tPAYl6P/f4QUz2/E8PfUZpoZ HFxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id; bh=5sQLY6NnoaK1uPkoP9RKyZ6UNcOMdKehHpeseXbrPe0=; b=lG8i2QubGm/WL0PBHSi5EI0vs3X2xmuBljk4ISNA2G9RuyzVao5DdM3pG/n6EIs1zO Im7lKTcCUxndL0QuMCniKzd09vY9aAFDvnFkKtZVuGHJRtv3dDgMFfxO8n43St3l6nO4 oj51IRRRJDy6ieAdnGnnW/FL+W9TCGgi1e9LOTBaicAPvb1P4R73gc7okupvvC8hnPMj A8J6qKKiJm55HU1jZBlhK3eN8GCRrXwllAQHpY5tBIA1V3e0wRsf/CQGCdJNNwFGGV+f W2qKphFslj6R/NkHbgC6+MvTGHsMKKWMosC/H0vS8bKggBmt9anqr6gpzZa8cBFisirJ tERw== 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 b3si12433422pld.282.2019.01.03.13.10.02; Thu, 03 Jan 2019 13:10:17 -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 S1731027AbfACOQh (ORCPT + 99 others); Thu, 3 Jan 2019 09:16:37 -0500 Received: from mailgw01.mediatek.com ([210.61.82.183]:37988 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726710AbfACOQh (ORCPT ); Thu, 3 Jan 2019 09:16:37 -0500 X-UUID: 7a2009ed0fdf4d60bb27d221510e87db-20190103 X-UUID: 7a2009ed0fdf4d60bb27d221510e87db-20190103 Received: from mtkexhb02.mediatek.inc [(172.21.101.103)] by mailgw01.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 1859930055; Thu, 03 Jan 2019 22:16:30 +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; Thu, 3 Jan 2019 22:16:28 +0800 Received: from [172.21.77.4] (172.21.77.4) by mtkcas09.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Thu, 3 Jan 2019 22:16:28 +0800 Message-ID: <1546524988.6818.54.camel@mtksdaap41> Subject: Re: [RFC PATCH 3/7] soc: mediatek: add support for the performance state From: Henry Chen To: Nicolas Boichat CC: Viresh Kumar , Stephen Boyd , "Rob Herring" , Matthias Brugger , Ulf Hansson , Mark Rutland , Fan Chen , Weiyi Lu , "James Liao" , Kees Cook , , , "linux-arm Mailing List" , , lkml Date: Thu, 3 Jan 2019 22:16:28 +0800 In-Reply-To: References: <1546436644-19234-1-git-send-email-henryc.chen@mediatek.com> <1546436644-19234-4-git-send-email-henryc.chen@mediatek.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.10.4-0ubuntu2 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-TM-SNTS-SMTP: 20133DFCC9BD558BAEE30AE3E94BE961769B75F3AC7540A52EECFF7041C9A3C32000:8 X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2019-01-03 at 09:48 +0800, Nicolas Boichat wrote: > On Wed, Jan 2, 2019 at 10:01 PM Henry Chen wrote: > > > > 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); > > nit: This (just) fits in 80 chars. Try again and get 81 chars :) > > > + 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; > > + } > > + } > > Do we need a sanity check here, if i == pd_data->num_domains? Oops. It needed, thanks for remind. > > > + > > + 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 > >