Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp311238imu; Wed, 2 Jan 2019 20:49:59 -0800 (PST) X-Google-Smtp-Source: ALg8bN5jarc2GzzVwMzm1peynxjxny3NFJ4wczCJMPGol7B6F6wrf2c3AymT08R9zpx0rMSSMi7U X-Received: by 2002:a63:e74b:: with SMTP id j11mr15980803pgk.397.1546490999067; Wed, 02 Jan 2019 20:49:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546490999; cv=none; d=google.com; s=arc-20160816; b=oKfWRpxqgu5X/NWgM8J28MP4dpA1bPbNxiplgrDKwh64NRywyexe2GvQA0lHfvYWHb HNA6CUOfakQN1RDE4jggwN1pOaTzpQrr7w3zwUBHgdOhI1MZL0UuOlIvHdzug+cCoD+z pTwv2CGimULRa7kZ2g6P0oPCv8FVOiTtErr7Y3xXJaEgheRm0zY3ThpUbP9Y7RP8jhXQ VpxBWkwEA0x9oRuSR8AikfnT8XbVu3E6S8iU8OFstG6Al/lZsYPrrWa2BbT2fd6TWxNQ 5mYNILpyOAglDECGTgsuBm0Fh/AneiVdmITUWp+swRRvn/0ubQrRsGQXUesOFomUR39r KmTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=thFpa+W1SI63LvDKRAZVs5xIhfA77m2jO3Zt+q2EF4g=; b=oxXMcL2XClwUZdx8FLiOM9P+H75UaPtlC42+VF+RgdGcI/SDXmour/V03h7DAvqvYV 9qB5CRCuSkFO7LAQO/H1aeBY4t0jEb+XloIpKztaMMaINN+ug85C2lpgf4b0WcGu4Y8d qEaNsJtZBAgvreugCq2+l+DzVJ6Ba/syaQ2gaY7NjTFFIm1OqPEKmgRmtjoukBuG4EeM Z+1xL05mo33W9gQtiuxgFQqnPoIF+0yDsgafeyCnlbWznrW6aW8TiqKNkdzqPSv8qoez 6tBSWu+lG/ZJNkuQujKLkxi0WrKB8Jt5QkX0ISFD38mlX+eue+oPGFeIqLYNui08peSp FBEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=cuSHDsRk; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g34si33376838pld.15.2019.01.02.20.49.44; Wed, 02 Jan 2019 20:49:59 -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; dkim=pass header.i=@chromium.org header.s=google header.b=cuSHDsRk; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726751AbfACBsk (ORCPT + 99 others); Wed, 2 Jan 2019 20:48:40 -0500 Received: from mail-qt1-f195.google.com ([209.85.160.195]:35153 "EHLO mail-qt1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726058AbfACBsk (ORCPT ); Wed, 2 Jan 2019 20:48:40 -0500 Received: by mail-qt1-f195.google.com with SMTP id v11so35501389qtc.2 for ; Wed, 02 Jan 2019 17:48:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=thFpa+W1SI63LvDKRAZVs5xIhfA77m2jO3Zt+q2EF4g=; b=cuSHDsRk/Yv120LPqBJbDTt4+9A/tCprKfqL1CZtDwCyovp4Vi5EMjnjGgJ6jD6C1J ysFnFqkcKMoQOEzLgfttRStGKky0n8KtEO8jPVy8j6/rervGaRMeEi8BCJAZPctIqj7j 5MoY8VY1rGhhGDVgxYAi5NeDk7tknj9o62h3I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=thFpa+W1SI63LvDKRAZVs5xIhfA77m2jO3Zt+q2EF4g=; b=sQ3DIsAH1NsMLUh+1aAoYLOnZ8pygd8u6suQvgeNoi9oC9Zm14edkHXV2lZj7jBrnM DMD9xluDnWXAmZD8X0f3EZsHaW7mwihYdKxcI8XrtBKY4QdKczNstrZ3A2r0VgbcbL9S GL3NNKDMZxRWLleGc/n6sWk11WwGNk0iyN03ImxEUS9zce0Je5Gy7+qwMfGrezVnW4r8 K8D4c57ev54L30yNyxRsxjyCxpC0ho98BQ8KkDwzfRaFK+JZ4MUJZ1qUgE8COtAS80uL daieJk/fngx612WBKiI2RtZHmFSXW8cpxnsUPitvh62O2wcTdNmHEvBcn4sJNmthAG6Y TnJA== X-Gm-Message-State: AA+aEWb0PQlPGZs9SCKF1xX7jS5packe6mHjzb+2wmz3yrRYy27kkDxD tgwLzCn6N4Uoz1ik039sZJejxT1N7ZUyK773rQ+rcQ== X-Received: by 2002:ac8:6b18:: with SMTP id w24mr45047408qts.144.1546480118762; Wed, 02 Jan 2019 17:48:38 -0800 (PST) MIME-Version: 1.0 References: <1546436644-19234-1-git-send-email-henryc.chen@mediatek.com> <1546436644-19234-4-git-send-email-henryc.chen@mediatek.com> In-Reply-To: <1546436644-19234-4-git-send-email-henryc.chen@mediatek.com> From: Nicolas Boichat Date: Thu, 3 Jan 2019 09:48:27 +0800 Message-ID: Subject: Re: [RFC PATCH 3/7] soc: mediatek: add support for the performance state To: Henry Chen Cc: Viresh Kumar , Stephen Boyd , Rob Herring , Matthias Brugger , Ulf Hansson , Mark Rutland , Fan Chen , Weiyi Lu , James Liao , Kees Cook , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-arm Mailing List , linux-mediatek@lists.infradead.org, lkml Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > + 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? > + > + 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 >