Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp337564imu; Wed, 2 Jan 2019 07:38:52 -0800 (PST) X-Google-Smtp-Source: ALg8bN5xGu7UHkgrqGnP00KkYbhMuzOo5mPm7SAhd7a+WNRTlbkXk3ioos4lO4wgkw9M0oS6kwlT X-Received: by 2002:a63:451a:: with SMTP id s26mr14065629pga.150.1546443532827; Wed, 02 Jan 2019 07:38:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546443532; cv=none; d=google.com; s=arc-20160816; b=0gJ5fu1K8a7DTAB9eOuOwO0NcdCBkkBHx/aiJh4uD3XS1TvARMCtOoCYNQMq8hv0x6 PZfPw3tPt6QYTneOV+I8ItemdAP4ZRxY8CwV9+/le5q27FVZ/z224L/LgO+2H/JGlm0P hbS91h8I2JTzV+OSePJSfqxLfKaKRu6AXHN63jm7OzXyDRZ4+//hiOw9F+8gUWhp/cPq qTxS15B5KT+dWKrfhlzZAvwOOkO/0rt63eLx29DsQK/jrHV0Ym94fXqAQlvFkADRdGxY GPzQZ6gr0Jkq9GKbauS5eC4jojhUczpTl+kq9Lix/GRcWY5vMMIDN4h1i0ZlEHbAuX+N sk6Q== 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=QKt40dzL2a5teJ/u7k+Dug2oV5tRSg66nz1wiyLapXsM8W1wVnboE9/5sBXDSeCxRu KcmIu8uqtamTFYH2fIv+6vXb5hhGkwUHmmzDsMF3dDb9nTGaVQ739YIRZZmZLUoPIEGX u/VqgWwlZGgqJlXyNJ5UAPBqgJp/NVEn0+Qvrhlq1GyCS6GGE/WBzA7C58hkpZn5RGeK VB1wR32lJm377mTV6m1pxH0I3ZSzvbw3NjXwyt+5YEGbr18ubHRsYbqK823U7EdIYojB xxKxcllbBpcIDxTFjy7ArBMHfUbYuDua6xrb+9OSm0Bvz1m+wyukBY5xlzz431CIDFwr oQOw== 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 z61si12106005plb.49.2019.01.02.07.38.38; Wed, 02 Jan 2019 07:38:52 -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 S1729725AbfABOLF (ORCPT + 99 others); Wed, 2 Jan 2019 09:11:05 -0500 Received: from mailgw02.mediatek.com ([210.61.82.184]:12335 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1728983AbfABOKc (ORCPT ); Wed, 2 Jan 2019 09:10:32 -0500 X-UUID: 230062ad104c4f09b58bfb842d54505e-20190102 X-UUID: 230062ad104c4f09b58bfb842d54505e-20190102 Received: from mtkcas09.mediatek.inc [(172.21.101.178)] by mailgw02.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 1737905816; Wed, 02 Jan 2019 22:10:28 +0800 Received: from mtkcas09.mediatek.inc (172.21.101.178) by mtkmbs01n2.mediatek.inc (172.21.101.79) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Wed, 2 Jan 2019 22:10:26 +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:10:26 +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 RESEND PATCH 3/7] soc: mediatek: add support for the performance state Date: Wed, 2 Jan 2019 22:09:54 +0800 Message-ID: <1546438198-1677-4-git-send-email-henryc.chen@mediatek.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1546438198-1677-1-git-send-email-henryc.chen@mediatek.com> References: <1546438198-1677-1-git-send-email-henryc.chen@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-TM-SNTS-SMTP: 5C466D51986E1AC154E56F047E4429BF8A93C06EC63D993862788E22D55C0FEB2000: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 | 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