From patchwork Tue Sep 25 16:36:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aisheng Dong X-Patchwork-Id: 10614557 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A86C415A6 for ; Tue, 25 Sep 2018 16:52:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 981F42AA0E for ; Tue, 25 Sep 2018 16:52:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8C8282AA3A; Tue, 25 Sep 2018 16:52:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CF1592AA0E for ; Tue, 25 Sep 2018 16:51:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726690AbeIYXAT (ORCPT ); Tue, 25 Sep 2018 19:00:19 -0400 Received: from mail-he1eur01on0061.outbound.protection.outlook.com ([104.47.0.61]:40420 "EHLO EUR01-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726139AbeIYXAS (ORCPT ); Tue, 25 Sep 2018 19:00:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=So/yFYc90VXp38Ulr+pZZdUkhNKgNp0G85Z7yeBxVYA=; b=DhgoI4fKDUBNPp676EC6vj4+xDorVzZQzabS9eYhrdoQDaKa+Q6N15WVHMatqXcKmwj7JZkq7fOgZbctSl0/sk39QJWIoBEWp1S+f833M17qowei+KGifDnJYCPnqGmxA+CxLsqzCieZeiE/Qgt/gOgpf2jDSb+FK6qqmWzW7AM= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=aisheng.dong@nxp.com; Received: from shlinux2.ap.freescale.net (119.31.174.66) by DB7PR04MB4219.eurprd04.prod.outlook.com (2603:10a6:5:27::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1164.25; Tue, 25 Sep 2018 16:51:49 +0000 From: Dong Aisheng To: linux-arm-kernel@lists.infradead.org Cc: dongas86@gmail.com, kernel@pengutronix.de, shawnguo@kernel.org, fabio.estevam@nxp.com, linux-imx@nxp.com, rjw@rjwysocki.net, ulf.hansson@linaro.org, khilman@kernel.org, linux-pm@vger.kernel.org, Dong Aisheng Subject: [PATCH V2 2/2] firmware: imx: add SCU power domain driver Date: Wed, 26 Sep 2018 00:36:31 +0800 Message-Id: <1537893391-31084-3-git-send-email-aisheng.dong@nxp.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1537893391-31084-1-git-send-email-aisheng.dong@nxp.com> References: <1537893391-31084-1-git-send-email-aisheng.dong@nxp.com> MIME-Version: 1.0 X-Originating-IP: [119.31.174.66] X-ClientProxiedBy: HK0PR03CA0047.apcprd03.prod.outlook.com (2603:1096:203:2f::35) To DB7PR04MB4219.eurprd04.prod.outlook.com (2603:10a6:5:27::16) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5a8a050e-9877-4833-40ac-08d62307325d X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989299)(4534165)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020);SRVR:DB7PR04MB4219; X-Microsoft-Exchange-Diagnostics: 1;DB7PR04MB4219;3:FrnI7hGNNNx2C8e/nuBMip+gwnJoZCfOSKXJrlYcyQAnfzd0vACvZbq4Aubf+qYczOq9EDs7w4WdjxaEsRknrgEuGXrARMXgZQQFr6Ie0xFahlT4q5Nd7nuzwy9o1i59aSQG9AQlbrgGnoFuTceCU4nFurveNrjs5KwbUHTrPaDEOr0uZQ/8mJ6J6xzrzRabWphXP1NsnKmcE3/p5V6azZIug/5HsgxZSgFLaLohWupp2ginTAtQ/enwaNKSni3R;25:R1QpOJwtJfxcmQIwwQt8oHN3fk54j/Atu0VIFTARq6Y31Sv6oWf3Y0+wSKm7NIBO074OhBJRfJAI0u/2NJYG+nmiVnUIxz4VBfcj/lheMQl3WEMVR4bqzGkuepWqFlkz0T8Ay0LOUqmtbP3dBvDtoDq+UmakrGy5SlCRdvBYHmbP5g9wm8f1wodHf2FWvTY/GQdvIqScrha6qNjUkldeLMY1ZV4g4RU/i8m58a83Yc1azuj7ijaLF08/PY63Z8bC5gvCUBT/QCW4el+f2R/sT5MJzCXIyREQEU7mOvBKn0m6q+QuGnHVh6nuFdVl7Rl1pF9Upkv2d+AZxcAAgS/Big==;31:kPk7wH0W6ZNQFvK6VxoECNuFa+xI1zbql9rnV+DVWOIwAUt7VGyLixUuER7ZMW/tgJoDxGUqlsvp1dOQ8M0Qc+A0LZDJSyA8s1ZGrXyyfSAoOgUorTCSmlVURwvt8eicIftdWTepx5jNpTHG1xINSruxJC8fe5CzUaYJ9Ew2RwskjV1tuy0zEveUdtHmd1L7mzIYjOtnpnr4DobzG6J119SFbP/9XKtLqJJxfnYXbLM= X-MS-TrafficTypeDiagnostic: DB7PR04MB4219: X-Microsoft-Exchange-Diagnostics: 1;DB7PR04MB4219;20:0Ixww4v2+VN731nwh8OgikbETKfNiZnB5E9wdNzF8VjQ+XmsBOeyRz8sm3+N0580solhnfxEFCdPC0OC9dHmd43q0dXLzTwY2GqWL9dEUWwuzDPkBfeD0q8Go30U+fqlls1WrZ8cNe3hCyeIZCeK9ag2Y+bKtqw4/+UhYhRXN133HXg7gOt66ty/EUp/LAh9u7uKcKvWHfdd5O15CniF5dxifUXIvdg8SvpD/iuJ1Z6+54p6hZMlcRDobYdszJh3AMHeFdDqyyRyDlg9AZjGWLh2MzZVDV6tikMVTPGrpl4sQKaTR1fgOoJm6WMoCcPT+sBbhpbWXXw7Rfyx15qbefaMlq9zs42eTPJub5yeDNIezVxGd8yCu9SwaJd6qSselVXsBuEUdCPTvzbOPNaux3Tfx6+nSjuqZZSFkD9kttWPtPQUSIbI1cDoAnx/DZXouHP6qPPilESKCUsgHSAE6WfZr2juCVIqjDzcE0LoAAc5xGGeUPfnhQBMLPpvcC+S;4:LeEYvS4Bp0QGvj2OcMKRrVuLxRnpOoZQ6m6bk2CHKY+GUw73oL40IkxB6/IgRCsnLR34k3aOCLjr2jkkaB7YZACuTlMzYvB+IRxLx2zrurAuFoY3TZYsKxoLEIAjVh5n2z6eXp1oLJ6kwyASTT6CzmEOfDraW61T/n1S9kTZ7+oN0WXUWLkRRaOKApfer/N+5yRzdfS7uUMPtao9WbL3nUHr/5Z8SMNT4UcT+7vihQdqIqAAWsOcZiVRn0rDYYz26tTSlenF1RjIDq7waXRs37wn7cIpjiBmTWZwvp25cgnaeC0RmBte2ccjlj6ZWREpKv/dsDumXRhQ7IexloAojecFm8fnbBiEWnhJIqZa5CelO1a9cZO8IAB9CGkaTlg/ X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(269456686620040)(185117386973197)(9452136761055); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3231355)(944501410)(52105095)(93006095)(93001095)(3002001)(10201501046)(6055026)(149066)(150027)(6041310)(20161123564045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123562045)(201708071742011)(7699051);SRVR:DB7PR04MB4219;BCL:0;PCL:0;RULEID:;SRVR:DB7PR04MB4219; X-Forefront-PRVS: 08062C429B X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(979002)(136003)(396003)(346002)(376002)(366004)(39860400002)(189003)(199004)(54534003)(68736007)(476003)(66066001)(105586002)(86362001)(14444005)(6666003)(486006)(7736002)(39060400002)(47776003)(106356001)(2361001)(6506007)(51416003)(11346002)(36756003)(34290500001)(446003)(97736004)(16586007)(2616005)(956004)(316002)(52116002)(386003)(76176011)(16526019)(8936002)(5660300001)(81156014)(50226002)(8676002)(81166006)(6512007)(6916009)(4326008)(26005)(53936002)(478600001)(6486002)(305945005)(2351001)(25786009)(2906002)(50466002)(6116002)(3846002)(48376002)(186003)(969003)(989001)(999001)(1009001)(1019001);DIR:OUT;SFP:1101;SCL:1;SRVR:DB7PR04MB4219;H:shlinux2.ap.freescale.net;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; Received-SPF: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: 1;DB7PR04MB4219;23:KVO6cUGarAAgHzTjJGW1KQffcFxCD/AY+c93t9n60rMr6NR0x9YB3sYO9Io0rokYheITGgxcmq0W4zYexfZHX0uwRQMiY1VvsIhDTVNg+pRyvdRkHfc2FAUp2GchIYPKLYlvbQP0JK5TardFMq0rn5L9kFUc3mh6IxrRAwy5IHinfKVUXuKZb5JFZSSwqb/jzJNMDNwCft4+mC1Cw615vqFuA+bMzeh3jtUnjMLSuL3q1b1tKATtVzhjEEivcz1WTF36lx1EBIOJ4RSo3qp+L+cEJxsjK736nHw43iL16NQHZOgKKrVJop7/nCipa6WCqrkIR+P4MgHjYCL2IlYT9bNM5JUibc0zfHWiSW06jFwLBCJ/V5FbUsRKt9BdlV8VimIG9BVMFtq+0ehCbxywwcLbJ0UHwcIlMEezgzanECCHGp2noFkOF0i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+Mmf/R1SSSO3xkfrqKZVjTY42wsqVSYtv+Tv+K1Vdg1oaZz+jIAdqEoA2Y1vwa2TsykYlr4eMCPUQduM46gcFvEMUzotphkqI5SbrRyDx3+2KgxuJ88yy0eqFEeK SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Sep 2018 16:51:49.6218 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5a8a050e-9877-4833-40ac-08d62307325d X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR04MB4219 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Some i.MX SoCs contain a system controller that is responsible for controlling the state of the IPs that are present. Communication between the host processor running an OS and the system controller happens through a SCU protocol. This patch adds SCU protocol based power domains drivers. Cc: Shawn Guo Cc: Sascha Hauer Cc: Fabio Estevam Cc: "Rafael J. Wysocki" Cc: Kevin Hilman Cc: linux-pm@vger.kernel.org Reviewed-by: Ulf Hansson Signed-off-by: Dong Aisheng --- ChangeLog: v1->v2: * move into drivers/firmware/imx * Implement sc_pm_set_resource_power_mode() API in the driver instead of call it via SCU API according to Sascha's suggestion --- drivers/firmware/imx/Kconfig | 6 ++ drivers/firmware/imx/Makefile | 3 +- drivers/firmware/imx/scu-pd.c | 175 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 183 insertions(+), 1 deletion(-) create mode 100644 drivers/firmware/imx/scu-pd.c diff --git a/drivers/firmware/imx/Kconfig b/drivers/firmware/imx/Kconfig index b170c28..6a7a7c2 100644 --- a/drivers/firmware/imx/Kconfig +++ b/drivers/firmware/imx/Kconfig @@ -9,3 +9,9 @@ config IMX_SCU This driver manages the IPC interface between host CPU and the SCU firmware running on M4. + +config IMX_SCU_PD + bool "IMX SCU Power Domain driver" + depends on IMX_SCU + help + The System Controller Firmware (SCFW) based power domain driver. diff --git a/drivers/firmware/imx/Makefile b/drivers/firmware/imx/Makefile index 0ac04df..1b2e15b 100644 --- a/drivers/firmware/imx/Makefile +++ b/drivers/firmware/imx/Makefile @@ -1,2 +1,3 @@ # SPDX-License-Identifier: GPL-2.0 -obj-$(CONFIG_IMX_SCU) += imx-scu.o misc.o +obj-$(CONFIG_IMX_SCU) += imx-scu.o misc.o +obj-$(CONFIG_IMX_SCU_PD) += scu-pd.o diff --git a/drivers/firmware/imx/scu-pd.c b/drivers/firmware/imx/scu-pd.c new file mode 100644 index 0000000..d6d5771 --- /dev/null +++ b/drivers/firmware/imx/scu-pd.c @@ -0,0 +1,175 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2016 Freescale Semiconductor, Inc. + * Copyright 2017~2018 NXP + * Dong Aisheng + * + * Implementation of the SCU based Power Domains + */ + +#define pr_fmt(fmt) "scu_pd: " fmt + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +struct imx_sc_pm_domain { + struct generic_pm_domain pd; + sc_rsrc_t rsrc_id; +}; + +static struct sc_ipc *pm_ipc_handle; + +/* SCU Power Mode Protocol definition */ +struct imx_sc_msg_req_set_resource_power_mode { + struct sc_rpc_msg hdr; + u16 resource; + u8 mode; +} __packed; + +static int imx_sc_pd_power(struct generic_pm_domain *domain, bool power_on) +{ + struct imx_sc_msg_req_set_resource_power_mode msg; + struct sc_rpc_msg *hdr = &msg.hdr; + struct imx_sc_pm_domain *pd; + sc_err_t sci_err; + int ret; + + pd = container_of(domain, struct imx_sc_pm_domain, pd); + + hdr->ver = SC_RPC_VERSION; + hdr->svc = (uint8_t)SC_RPC_SVC_PM; + hdr->func = (uint8_t)PM_FUNC_SET_RESOURCE_POWER_MODE; + hdr->size = 2; + + msg.resource = pd->rsrc_id; + msg.mode = power_on ? SC_PM_PW_MODE_ON : SC_PM_PW_MODE_LP; + + ret = imx_scu_call_rpc(pm_ipc_handle, &msg, true); + if (ret) + return ret; + + sci_err = (sc_err_t)hdr->func; + if (sci_err) { + pr_err("failed to power %s resource %d ret %d\n", + power_on ? "up" : "off", pd->rsrc_id, sci_err); + return -EPERM; + } + + return 0; +} + +static int imx_sc_pd_power_on(struct generic_pm_domain *domain) +{ + return imx_sc_pd_power(domain, true); +} + +static int imx_sc_pd_power_off(struct generic_pm_domain *domain) +{ + return imx_sc_pd_power(domain, false); +} + +static struct generic_pm_domain *imx_sc_pm_add_one_domain( + struct device_node *np, + struct generic_pm_domain *genpd_parent) +{ + struct imx_sc_pm_domain *imx_sc_pd; + sc_rsrc_t rsrc_id; + int ret; + + imx_sc_pd = kzalloc(sizeof(*imx_sc_pd), GFP_KERNEL); + if (!imx_sc_pd) + return ERR_PTR(-ENOMEM); + + if (!of_property_read_u32(np, "reg", &rsrc_id)) { + if (rsrc_id > SC_R_LAST) { + pr_warn("%pOF: invalid rsrc id %d found", np, rsrc_id); + ret = -EINVAL; + goto err; + } + imx_sc_pd->rsrc_id = rsrc_id; + } else { + imx_sc_pd->rsrc_id = SC_R_LAST; + } + + if (imx_sc_pd->rsrc_id != SC_R_LAST) { + imx_sc_pd->pd.power_off = imx_sc_pd_power_off; + imx_sc_pd->pd.power_on = imx_sc_pd_power_on; + } + + imx_sc_pd->pd.name = np->name; + + ret = pm_genpd_init(&imx_sc_pd->pd, NULL, true); + if (ret < 0) + goto err; + + if (genpd_parent) { + ret = pm_genpd_add_subdomain(genpd_parent, &imx_sc_pd->pd); + if (ret) + goto err; + } + + ret = of_genpd_add_provider_simple(np, &imx_sc_pd->pd); + if (!ret) + return &imx_sc_pd->pd; + + pm_genpd_remove_subdomain(genpd_parent, &imx_sc_pd->pd); + +err: + pr_warn("failed to add PM domain %pOF: %d\n", np, ret); + kfree(imx_sc_pd); + return ERR_PTR(ret); +} + +static void imx_sc_pm_add_pm_domains(struct device_node *parent, + struct generic_pm_domain *genpd_parent) +{ + struct generic_pm_domain *pd; + struct device_node *np; + + for_each_child_of_node(parent, np) { + pd = imx_sc_pm_add_one_domain(np, genpd_parent); + if (!IS_ERR(pd)) + imx_sc_pm_add_pm_domains(np, pd); + } +} + +static int imx_sc_pd_probe(struct platform_device *pdev) +{ + struct device_node *np = pdev->dev.of_node; + int ret; + + ret = imx_scu_get_handle(&pm_ipc_handle); + if (ret) + return ret; + + imx_sc_pm_add_pm_domains(np, NULL); + + return 0; +} + +static const struct of_device_id imx_sc_pd_match[] = { + { .compatible = "fsl,scu-pd", }, + { /* sentinel */ } +}; + +static struct platform_driver imx_sc_pd_driver = { + .driver = { + .name = "imx-scu-pd", + .of_match_table = imx_sc_pd_match, + }, + .probe = imx_sc_pd_probe, +}; +builtin_platform_driver(imx_sc_pd_driver); + +MODULE_AUTHOR("Dong Aisheng "); +MODULE_DESCRIPTION("IMX SCU Power Domain driver"); +MODULE_LICENSE("GPL v2");