From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.4 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,UNPARSEABLE_RELAY,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 23E53C43387 for ; Thu, 3 Jan 2019 14:16:54 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E60D32073D for ; Thu, 3 Jan 2019 14:16:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="OoQhCxR0" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E60D32073D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Date:To:From:Subject:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=pHyrj5Ujk33/ex90/NqKdmH05jzFfs9+dwirfjIclvM=; b=OoQhCxR0iWaZsb /xrdXn+uMgeL41hA0vAcRWLbQUTWhhYOSXsKxVk+WqCAsWfpZZ8yy8sZE7MkhQdIDIntFszDcBdfl 3kKn91oNkK8k/gz7ey/gz7ypQbbiqEO1l1ftFR44ik6QcU9EVXqLNy0+9W4kW7itCK2SprRO6TWNr KJ10wBGdSHZqz8WIh8xVjiFcpbwC1vSupmbjSyXN/e+rJRoT5ZLPRFRfSnP/q3ih4oYWdx7U12Xst oqLz3hARN09CYsRF6FXbzG26L8pLojswuOLPaGwiDRDXUmzLCERGJwzYHiOSLp5EInx5iRJhb9Ohf i7ynoFlIPQ20wMz7LC1Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gf3nk-0000yB-Q1; Thu, 03 Jan 2019 14:16:48 +0000 Received: from mailgw01.mediatek.com ([216.200.240.184]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gf3ng-0000x0-IL; Thu, 03 Jan 2019 14:16:46 +0000 X-UUID: f4bc6e08930c4d6fb372a9037d6363a9-20190103 X-UUID: f4bc6e08930c4d6fb372a9037d6363a9-20190103 Received: from mtkcas67.mediatek.inc [(172.29.193.45)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLS) with ESMTP id 1587926278; Thu, 03 Jan 2019 06:16:38 -0800 Received: from MTKMBS02N2.mediatek.inc (172.21.101.101) by MTKMBS62DR.mediatek.inc (172.29.94.18) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Thu, 3 Jan 2019 06:16:36 -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 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> X-Mailer: Evolution 3.10.4-0ubuntu2 MIME-Version: 1.0 X-TM-SNTS-SMTP: 20133DFCC9BD558BAEE30AE3E94BE961769B75F3AC7540A52EECFF7041C9A3C32000:8 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190103_061644_615563_C165BBD5 X-CRM114-Status: GOOD ( 20.05 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , James Liao , Ulf Hansson , Kees Cook , Weiyi Lu , linux-pm@vger.kernel.org, Stephen Boyd , Viresh Kumar , lkml , Fan Chen , devicetree@vger.kernel.org, Rob Herring , linux-mediatek@lists.infradead.org, Matthias Brugger , linux-arm Mailing List Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.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 > > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel