From patchwork Wed Oct 10 10:32:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aisheng Dong X-Patchwork-Id: 10634331 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 9C43969B4 for ; Wed, 10 Oct 2018 10:32:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6932229D19 for ; Wed, 10 Oct 2018 10:32:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5851029D28; Wed, 10 Oct 2018 10:32:54 +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 DCCE529C87 for ; Wed, 10 Oct 2018 10:32:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726523AbeJJRyV (ORCPT ); Wed, 10 Oct 2018 13:54:21 -0400 Received: from mail-eopbgr30048.outbound.protection.outlook.com ([40.107.3.48]:16208 "EHLO EUR03-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726761AbeJJRyU (ORCPT ); Wed, 10 Oct 2018 13:54:20 -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=1bq2HDHlXUMtVIGlAbWW+7lmqa0jiaIGA6ACBh4bfHY=; b=uG1nfX4Pld4d+yANMhXloPklLiZEflOaEdzn3tEL8aOP1qJgZE9k99/jU83IIU4ocMEa4ddYpeR6W1n0RpWocapAEHcucUlX3bl9/DttZAYrPz7PPiyqsbJjDq3fGpfIFmp0qJP8cP2mxvk8xhMS7RXkqZndLA/3iGdd4kAoW30= Received: from VI1PR04MB4222.eurprd04.prod.outlook.com (52.134.31.21) by VI1PR04MB3120.eurprd04.prod.outlook.com (10.170.229.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1207.28; Wed, 10 Oct 2018 10:32:46 +0000 Received: from VI1PR04MB4222.eurprd04.prod.outlook.com ([fe80::e488:f49c:44a3:dc77]) by VI1PR04MB4222.eurprd04.prod.outlook.com ([fe80::e488:f49c:44a3:dc77%3]) with mapi id 15.20.1207.029; Wed, 10 Oct 2018 10:32:46 +0000 From: "A.s. Dong" To: "linux-arm-kernel@lists.infradead.org" CC: "dongas86@gmail.com" , "kernel@pengutronix.de" , "shawnguo@kernel.org" , Fabio Estevam , dl-linux-imx , "rjw@rjwysocki.net" , "ulf.hansson@linaro.org" , "khilman@kernel.org" , "linux-pm@vger.kernel.org" , "A.s. Dong" Subject: [PATCH V5 1/2] firmware: imx: add pm svc headfile Thread-Topic: [PATCH V5 1/2] firmware: imx: add pm svc headfile Thread-Index: AQHUYISVbyQmP6JXS0aSkGDtRaLj4w== Date: Wed, 10 Oct 2018 10:32:45 +0000 Message-ID: <1539166644-29215-2-git-send-email-aisheng.dong@nxp.com> References: <1539166644-29215-1-git-send-email-aisheng.dong@nxp.com> In-Reply-To: <1539166644-29215-1-git-send-email-aisheng.dong@nxp.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 1.9.1 x-clientproxiedby: HK0PR04CA0009.apcprd04.prod.outlook.com (2603:1096:203:36::21) To VI1PR04MB4222.eurprd04.prod.outlook.com (2603:10a6:803:3e::21) authentication-results: spf=none (sender IP is ) smtp.mailfrom=aisheng.dong@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [119.31.174.66] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;VI1PR04MB3120;6:1RDiK6NwXen53ay8RGstMSmfYhpi4z8Ivj64rwss/O74KmI6qIKPaP7jUbHQ+95Ya69rJWD0hhuPeqR7rVXni/pjqCIWV22vvbIowjl6sWl96oS2pehWu26FQKp0xbEragVGeRP7ZeskiBmSBdJ42MG26QopXsYfOgGtftlFaufkkCc0hnUOEA+6+B/aTcYtOikUHlecsV4l4oPr+FCdCMD6dHPI8fa7i+J5hD5HyfM/eOnW+BSOiQIZ8N/ZNJUVTTVr4oQ3n683CsJQnhVapOwJH8BN0wlWgqFtaIQXN3Muhx+H8ryStchnrEnJKWOv5XdJm0uR0sFrRCV7YeRZjmy0359znzYd6+ku7RWgSx0qCmJ5RDpSRtX7CIhnsQWfWOsoXkG4xfNUr4c3RELQTb/d+8b6CE5gbTZQAlPusfdQa8YZNTTrO2Z8b3WMdDJFenk8kN/uXLSLmQKxpEINvQ==;5:+tiUXWyP5G5wx02y+BwCgNyWf3Re7EWxYxvVHo/bWc2OY8xGdKh8YvK4BtElUT0u/PqGGaJzltExr4wg5/f2diVXjABgjpJZPsI9j6Ng9Kn8xtCatcP0MJdnQKC/ZGHo09xlua/ZiELNNVtk+R2QLIc1gycWv/DNcmPDnVyJKNw=;7:t6MAzpL+vjnEWeJl0W71Yx6SYDyldv1lw/+jUH8wMON3kZACPOmcSfleubgBrBIh65f6Yxn7w0uTQSpwX2DJ/De2RKnntHm7KbaGnfOt6H6JTZ8TjdEj7HDiujZEHdVc8bVPR2VwM+bCsPlckV4H1atV2meh10ZwFucsdwNH/izLli8oGyzzj2oeJSv36tWRL95ERi85Gb/BH7nqpA/ViFeYhzhOVjc0BeETfU9MnV1/ioxnaWcHGT1XkdAU24Ct x-ms-office365-filtering-correlation-id: 67f1ded8-b3cd-4a6c-309f-08d62e9bb76b x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020);SRVR:VI1PR04MB3120; x-ms-traffictypediagnostic: VI1PR04MB3120: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(269456686620040)(185117386973197); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(10201501046)(3002001)(3231355)(944501410)(52105095)(6055026)(149066)(150057)(6041310)(20161123560045)(20161123564045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(201708071742011)(7699051)(76991055);SRVR:VI1PR04MB3120;BCL:0;PCL:0;RULEID:;SRVR:VI1PR04MB3120; x-forefront-prvs: 08213D42D3 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(39860400002)(366004)(396003)(346002)(136003)(376002)(189003)(199004)(6116002)(5640700003)(316002)(71200400001)(71190400001)(26005)(39060400002)(68736007)(3846002)(25786009)(446003)(486006)(5250100002)(4326008)(2501003)(102836004)(2351001)(2616005)(476003)(97736004)(106356001)(105586002)(11346002)(478600001)(99286004)(386003)(53936002)(6506007)(5660300001)(66066001)(54906003)(2906002)(256004)(14444005)(305945005)(86362001)(2900100001)(50226002)(81166006)(7736002)(8676002)(14454004)(6436002)(6916009)(8936002)(6512007)(76176011)(52116002)(81156014)(36756003)(6486002)(186003);DIR:OUT;SFP:1101;SCL:1;SRVR:VI1PR04MB3120;H:VI1PR04MB4222.eurprd04.prod.outlook.com;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-antispam-message-info: xnYsJdbnuhcddGKtAbqoYmwllfFeZTnqeHxAbvHXkpVeWXa46JdjW6IlQuT8xgW8x86Ay8f0gR5MWVLQjiI0Hkbyz4t9YQdBaTW+1y5oP/kJAcMgnP4F2DW8Uugm/k+9k2oYEABTEGlALf1lZ+DjnhxSBegmXpqo7x45HHsIindx8uJZfO1tHX0lxUhAtlX7EslrB0dJX7RisDu4YfR315bbqd/E1ft9ZQQeOr0xHySSJrHo9V1FCP0Vbodg3LN0WYhDAG4ZFzl14pUbJ3zUhd12ZaopKwppy2n8t2u9qadikxd0SS0lo7eIcLrwr3bEqY61226qtqYcUcUMT8Q7ZrukSxAOT/tgoAju/DOlegw= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 67f1ded8-b3cd-4a6c-309f-08d62e9bb76b X-MS-Exchange-CrossTenant-originalarrivaltime: 10 Oct 2018 10:32:45.8612 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB3120 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 Add SCU PM SVC related protocol definitions which will be used by a number of PM functions like Power Domain, Clock, Reset and etc. The detailed implementation of each function will put in the individual function drivers. Cc: Shawn Guo Cc: Sascha Hauer Signed-off-by: Dong Aisheng --- v3->v4: * update firmware headfile patch from include/soc/imx to include/linux/firmware/imx v2->v3: * name updated with IMX_SC prefix v1->v2: * new introduced --- include/linux/firmware/imx/sci.h | 1 + include/linux/firmware/imx/svc/pm.h | 85 +++++++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 include/linux/firmware/imx/svc/pm.h diff --git a/include/linux/firmware/imx/sci.h b/include/linux/firmware/imx/sci.h index 29ada60..ebc5509 100644 --- a/include/linux/firmware/imx/sci.h +++ b/include/linux/firmware/imx/sci.h @@ -14,4 +14,5 @@ #include #include +#include #endif /* _SC_SCI_H */ diff --git a/include/linux/firmware/imx/svc/pm.h b/include/linux/firmware/imx/svc/pm.h new file mode 100644 index 0000000..ee5a7bb --- /dev/null +++ b/include/linux/firmware/imx/svc/pm.h @@ -0,0 +1,85 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright (C) 2016 Freescale Semiconductor, Inc. + * Copyright 2017~2018 NXP + * + * Header file containing the public API for the System Controller (SC) + * Power Management (PM) function. This includes functions for power state + * control, clock control, reset control, and wake-up event control. + * + * PM_SVC (SVC) Power Management Service + * + * Module for the Power Management (PM) service. + */ + +#ifndef _SC_PM_API_H +#define _SC_PM_API_H + +#include + +/* + * This type is used to indicate RPC PM function calls. + */ +enum imx_sc_pm_func { + IMX_SC_PM_FUNC_UNKNOWN = 0, + IMX_SC_PM_FUNC_SET_SYS_POWER_MODE = 19, + IMX_SC_PM_FUNC_SET_PARTITION_POWER_MODE = 1, + IMX_SC_PM_FUNC_GET_SYS_POWER_MODE = 2, + IMX_SC_PM_FUNC_SET_RESOURCE_POWER_MODE = 3, + IMX_SC_PM_FUNC_GET_RESOURCE_POWER_MODE = 4, + IMX_SC_PM_FUNC_REQ_LOW_POWER_MODE = 16, + IMX_SC_PM_FUNC_SET_CPU_RESUME_ADDR = 17, + IMX_SC_PM_FUNC_REQ_SYS_IF_POWER_MODE = 18, + IMX_SC_PM_FUNC_SET_CLOCK_RATE = 5, + IMX_SC_PM_FUNC_GET_CLOCK_RATE = 6, + IMX_SC_PM_FUNC_CLOCK_ENABLE = 7, + IMX_SC_PM_FUNC_SET_CLOCK_PARENT = 14, + IMX_SC_PM_FUNC_GET_CLOCK_PARENT = 15, + IMX_SC_PM_FUNC_RESET = 13, + IMX_SC_PM_FUNC_RESET_REASON = 10, + IMX_SC_PM_FUNC_BOOT = 8, + IMX_SC_PM_FUNC_REBOOT = 9, + IMX_SC_PM_FUNC_REBOOT_PARTITION = 12, + IMX_SC_PM_FUNC_CPU_START = 11, +}; + +/* + * Defines for ALL parameters + */ +#define IMX_SC_PM_CLK_ALL UINT8_MAX /* All clocks */ + +/* + * Defines for SC PM Power Mode + */ +#define IMX_SC_PM_PW_MODE_OFF 0 /* Power off */ +#define IMX_SC_PM_PW_MODE_STBY 1 /* Power in standby */ +#define IMX_SC_PM_PW_MODE_LP 2 /* Power in low-power */ +#define IMX_SC_PM_PW_MODE_ON 3 /* Power on */ + +/* + * Defines for SC PM CLK + */ +#define IMX_SC_PM_CLK_SLV_BUS 0 /* Slave bus clock */ +#define IMX_SC_PM_CLK_MST_BUS 1 /* Master bus clock */ +#define IMX_SC_PM_CLK_PER 2 /* Peripheral clock */ +#define IMX_SC_PM_CLK_PHY 3 /* Phy clock */ +#define IMX_SC_PM_CLK_MISC 4 /* Misc clock */ +#define IMX_SC_PM_CLK_MISC0 0 /* Misc 0 clock */ +#define IMX_SC_PM_CLK_MISC1 1 /* Misc 1 clock */ +#define IMX_SC_PM_CLK_MISC2 2 /* Misc 2 clock */ +#define IMX_SC_PM_CLK_MISC3 3 /* Misc 3 clock */ +#define IMX_SC_PM_CLK_MISC4 4 /* Misc 4 clock */ +#define IMX_SC_PM_CLK_CPU 2 /* CPU clock */ +#define IMX_SC_PM_CLK_PLL 4 /* PLL */ +#define IMX_SC_PM_CLK_BYPASS 4 /* Bypass clock */ + +/* + * Defines for SC PM CLK Parent + */ +#define IMX_SC_PM_PARENT_XTAL 0 /* Parent is XTAL. */ +#define IMX_SC_PM_PARENT_PLL0 1 /* Parent is PLL0 */ +#define IMX_SC_PM_PARENT_PLL1 2 /* Parent is PLL1 or PLL0/2 */ +#define IMX_SC_PM_PARENT_PLL2 3 /* Parent in PLL2 or PLL0/4 */ +#define IMX_SC_PM_PARENT_BYPS 4 /* Parent is a bypass clock. */ + +#endif /* _SC_PM_API_H */ From patchwork Wed Oct 10 10:32:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aisheng Dong X-Patchwork-Id: 10634335 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 EF5D269B5 for ; Wed, 10 Oct 2018 10:32:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C354829C87 for ; Wed, 10 Oct 2018 10:32:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B784629D13; Wed, 10 Oct 2018 10:32:59 +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 B317129D09 for ; Wed, 10 Oct 2018 10:32:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726984AbeJJRy1 (ORCPT ); Wed, 10 Oct 2018 13:54:27 -0400 Received: from mail-eopbgr30041.outbound.protection.outlook.com ([40.107.3.41]:13440 "EHLO EUR03-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726656AbeJJRy0 (ORCPT ); Wed, 10 Oct 2018 13:54:26 -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=xHhvKDSTrcPGCLjZo7a/XLMWuRc+fgkJXb0Xtd23iU4=; b=WddthI15ghiJ5f95UQ5KfAihfAndh9uwbzBsWC4VJvns2yHSUhngnG6jjTCZsCQ9YPpoESuztA7eAnqjeaGMKSZiVUlrCQf0kmOLGFlPVCx2TblMDXk5B5+xlpu3Az3L4neTiRFIBBPHn6xidL93xUmadJ05ivWPUb15cUd00es= Received: from VI1PR04MB4222.eurprd04.prod.outlook.com (52.134.31.21) by VI1PR04MB3120.eurprd04.prod.outlook.com (10.170.229.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1207.28; Wed, 10 Oct 2018 10:32:51 +0000 Received: from VI1PR04MB4222.eurprd04.prod.outlook.com ([fe80::e488:f49c:44a3:dc77]) by VI1PR04MB4222.eurprd04.prod.outlook.com ([fe80::e488:f49c:44a3:dc77%3]) with mapi id 15.20.1207.029; Wed, 10 Oct 2018 10:32:51 +0000 From: "A.s. Dong" To: "linux-arm-kernel@lists.infradead.org" CC: "dongas86@gmail.com" , "kernel@pengutronix.de" , "shawnguo@kernel.org" , Fabio Estevam , dl-linux-imx , "rjw@rjwysocki.net" , "ulf.hansson@linaro.org" , "khilman@kernel.org" , "linux-pm@vger.kernel.org" , "A.s. Dong" Subject: [PATCH V5 2/2] firmware: imx: add SCU power domain driver Thread-Topic: [PATCH V5 2/2] firmware: imx: add SCU power domain driver Thread-Index: AQHUYISYXesONuMyqUefaO6FgF9X4w== Date: Wed, 10 Oct 2018 10:32:50 +0000 Message-ID: <1539166644-29215-3-git-send-email-aisheng.dong@nxp.com> References: <1539166644-29215-1-git-send-email-aisheng.dong@nxp.com> In-Reply-To: <1539166644-29215-1-git-send-email-aisheng.dong@nxp.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 1.9.1 x-clientproxiedby: HK0PR04CA0009.apcprd04.prod.outlook.com (2603:1096:203:36::21) To VI1PR04MB4222.eurprd04.prod.outlook.com (2603:10a6:803:3e::21) authentication-results: spf=none (sender IP is ) smtp.mailfrom=aisheng.dong@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [119.31.174.66] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;VI1PR04MB3120;6:QTp1exFHppIKtYXjep/kIdODHYbyeuRY6Xt20kKNnmRwdJIuNFJrDVJPF+r1eZw6+PDsE06iZqx0sfr3FzQuzc7AKKhjUR0qPEzpFYeDL4zP8tFCFrRYowNboLn49sAms2u79a4JDS2HhsQ67IpitsrjQ2U3YRu4K3tccWI1bHYMN74+Lm9vNrqGjhqipd4T1bP5LzquDgE4117H1vJvdvdPMVzbFdvVFPEBgRVWcI4yFtBZX5Pum5071t5cLHnDhsDBafOENY25AsYEId6UP58DzE8MuID4IqwQxLiLLrMykfWPOpl/CnVJpNfv7v85R1cV7mq5ey7HVxgpvz/bi9Xp6MrVvKiRdCF9NbTF36A7uCWd2wxRvxhyaP2Ov0pMu1ufG2ffGg3t6W5yR/mycN2VXqTb1gb5SyaTX3yFX/wKljbfKSI07c4XSUpxPh5J5S04FELEzMkQiHusr6JkLg==;5:em2OySt5j/R+oMWRFLlMJMHRvyb8QHQ7uHn9sGskZeY27+G7O4EN7SdJtOZ4dSvhhatG6gABcyXIAQN6d/b+LGf2MzKbDxc3tW6DmKlYunfvh2w2rV1BjAhCiLWLC3FkgIRajdg7dxv5nhxMIj4Temm/hoQhVys0a2wc/l0GOzE=;7:9YOjejQ5XOjN4wNTuIptGdeY6ousGgX5iBLuBjsLfWhS2wMSCQnWIqMBmYulms9Y+L1oeB5GbbzHHM/y0IMb7THxjhS0saiangiep1VsDKRitGR/3P427a+vOzqBcvsw9j+gLS9Q9cvRIO7D0oniRE5DJAOPqpsfunjgGh1Re7765LSjCDfHpXQ9KqXjSLGR07Wprkoq7QHoICJFuCm4yeMF5tIb1lAeMmKTIbLZYlLMDNsqSTi+UuQoxqaAA8Zs x-ms-office365-filtering-correlation-id: c621cb70-f1a4-4613-9954-08d62e9bbaa3 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020);SRVR:VI1PR04MB3120; x-ms-traffictypediagnostic: VI1PR04MB3120: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(269456686620040)(9452136761055)(185117386973197); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(10201501046)(3002001)(3231355)(944501410)(52105095)(6055026)(149066)(150057)(6041310)(20161123560045)(20161123564045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(201708071742011)(7699051)(76991055);SRVR:VI1PR04MB3120;BCL:0;PCL:0;RULEID:;SRVR:VI1PR04MB3120; x-forefront-prvs: 08213D42D3 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(39860400002)(366004)(396003)(346002)(136003)(376002)(54534003)(189003)(199004)(6116002)(5640700003)(316002)(71200400001)(71190400001)(26005)(39060400002)(68736007)(3846002)(25786009)(446003)(486006)(5250100002)(4326008)(2501003)(102836004)(2351001)(2616005)(476003)(97736004)(106356001)(105586002)(11346002)(478600001)(99286004)(386003)(53936002)(6506007)(5660300001)(66066001)(54906003)(2906002)(256004)(14444005)(305945005)(575784001)(86362001)(2900100001)(50226002)(81166006)(7736002)(8676002)(14454004)(6436002)(6916009)(8936002)(6512007)(76176011)(52116002)(81156014)(36756003)(6486002)(186003);DIR:OUT;SFP:1101;SCL:1;SRVR:VI1PR04MB3120;H:VI1PR04MB4222.eurprd04.prod.outlook.com;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-antispam-message-info: hQd5uoAfn0Fe2Lq8WPVn5J30cz2QAwFGJfGShOj0feadTB+8vsZNMrKy3yDByv07wujdw6O31378vTVUM6jw3VsWk5t52soQDGUNA/ti2/N5CalZl0v5vKENUPeu9m6IMOsVgDpSF6dXHOhE17dKynhl31WaPpZ6cy5JKEhABR53/kRT/1yk3oaF3qLhiEl+ZhbvgbvfBUiN8+AAFKcLFsbdS8sgxc12+KDv/Y8vGOl1XTZEqb4sZfH3y2UM4urduVELu78OMcDnBBNe09VGOqk/H50J+ss3IPNPEIoqGZmWxItzjHAoQjAzw4K4q3SouHCOX6s/aokuV4DuL0c9bnPze8lRJBB5JCLt7a8UyRs= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: c621cb70-f1a4-4613-9954-08d62e9bbaa3 X-MS-Exchange-CrossTenant-originalarrivaltime: 10 Oct 2018 10:32:50.8968 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB3120 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: v4->v5: * minor improvements according to Sascha's suggestions v3->v4: * update firmware headfile patch from include/soc/imx to include/linux/firmware/imx v2->v3: * name of structures/enums updated with imx_sc prefix 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 | 164 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 172 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..fe0a093 --- /dev/null +++ b/drivers/firmware/imx/scu-pd.c @@ -0,0 +1,164 @@ +// 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; + u32 rsrc_id; +}; + +static struct imx_sc_ipc *pm_ipc_handle; + +/* SCU Power Mode Protocol definition */ +struct imx_sc_msg_req_set_resource_power_mode { + struct imx_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 imx_sc_rpc_msg *hdr = &msg.hdr; + struct imx_sc_pm_domain *pd; + int ret; + + pd = container_of(domain, struct imx_sc_pm_domain, pd); + + hdr->ver = IMX_SC_RPC_VERSION; + hdr->svc = (uint8_t)IMX_SC_RPC_SVC_PM; + hdr->func = (uint8_t)IMX_SC_PM_FUNC_SET_RESOURCE_POWER_MODE; + hdr->size = 2; + + msg.resource = pd->rsrc_id; + msg.mode = power_on ? IMX_SC_PM_PW_MODE_ON : IMX_SC_PM_PW_MODE_LP; + + ret = imx_scu_call_rpc(pm_ipc_handle, &msg, true); + if (ret) + pr_err("failed to power %s resource %d ret %d\n", + power_on ? "up" : "off", pd->rsrc_id, ret); + + return ret; +} + +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; + u32 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 >= IMX_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; + imx_sc_pd->pd.power_off = imx_sc_pd_power_off; + imx_sc_pd->pd.power_on = imx_sc_pd_power_on; + } else { + imx_sc_pd->rsrc_id = IMX_SC_R_LAST; + } + + 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");