From patchwork Sun Oct 7 13:10:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aisheng Dong X-Patchwork-Id: 10629631 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 0989A112B for ; Sun, 7 Oct 2018 13:25:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DD42129171 for ; Sun, 7 Oct 2018 13:25:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D11C429206; Sun, 7 Oct 2018 13:25:42 +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 4E3FF29230 for ; Sun, 7 Oct 2018 13:25:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727772AbeJGUcw (ORCPT ); Sun, 7 Oct 2018 16:32:52 -0400 Received: from mail-ve1eur01on0077.outbound.protection.outlook.com ([104.47.1.77]:4640 "EHLO EUR01-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726803AbeJGUcw (ORCPT ); Sun, 7 Oct 2018 16:32:52 -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=pAXTFMSDSJclu2oTmE6incz1DdLpfWEJB8AnUUMIEPY=; b=RUY3QQzBO2I/r/+uVfjSkgKhL4D/EPiabKPOF2GYfe/vXbtZE1aUy5+jHJx0pVWMo7yH1MJ/1973dq6iM1P6kO0/jm5YD1TYFYrxCa/LwTcA/XNYI6coH15afyDKjutxMg4Gv2+8YLXGneL76KdqYdMR21lQgjA2R37WZs4ugQQ= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=aisheng.dong@nxp.com; Received: from shlinux2.ap.freescale.net (119.31.174.66) by AM6PR04MB4215.eurprd04.prod.outlook.com (2603:10a6:209:4f::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1207.18; Sun, 7 Oct 2018 13:25:31 +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 V4 1/2] firmware: imx: add pm svc headfile Date: Sun, 7 Oct 2018 21:10:06 +0800 Message-Id: <1538917807-1921-2-git-send-email-aisheng.dong@nxp.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1538917807-1921-1-git-send-email-aisheng.dong@nxp.com> References: <1538917807-1921-1-git-send-email-aisheng.dong@nxp.com> MIME-Version: 1.0 X-Originating-IP: [119.31.174.66] X-ClientProxiedBy: HK0PR01CA0045.apcprd01.prod.exchangelabs.com (2603:1096:203:3e::33) To AM6PR04MB4215.eurprd04.prod.outlook.com (2603:10a6:209:4f::13) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4667021f-8d3d-4039-ff17-08d62c585d22 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:AM6PR04MB4215; X-Microsoft-Exchange-Diagnostics: 1;AM6PR04MB4215;3:o+/ZcsgDZDvesNqCKBgWwPprHntYIIX0QX2idRxSf7GSHfGvpAbXFHVt2RYj0EOxVS8KL4LxSAN1SIsKgJCs8TN7q56ON/+rAO4gR0T9oXBhsUr1664qokJUnlBIH281j05f7OJge36apZXlawyoMlQrWb3he6zFpb41UkY5gHsE8tzjniQYcTayqqnLpB2XsJ5dSR02WHXBexZ83TCM7NYbeaoq8yvw01k/LFbkFuzFG+nS1s8ZvLou3UCOyZUM;25:mVY/pT8QNuZPEMu2JIM/KPYT7tXjKT+SNlf4z3j91Yj9XtCd7tgJciyozMX6QSQj0H07fyPUGlx+yeSQC4lUawYPVx2zKYxKE2wWHZdhMaNspxA6OnUbJCy8/lYTka8as+ay0a/5majjMWhzGoEFpKfs2hyWLQrhdr+qQIG+29POcsSz/9KaQZjZGLYNguctlQDMPdHB6wAaXGtxXqD1QiTNAmppiN+wXisml9z9cwnf24Tk01fI35LtSyyxab7Zalai2zj3E26FD5mqgJfN8c1o63LqSjhOvopDaeoBOlg5tkdcnIbn5+fqyiAosrj7oMsbF7pqWyeiIKx0r0OuyA==;31:fcgw43FG1U+JaKwVU5K+tLjudIx6Vh2I1+DCMliMPnFOv/tuMqjEHVFlFavEyJ5fM3bjT3nvTvV7jYZ9th1vNNn9sJ/JdSOzeGXHQnH7wSaFOzRAhVb6Z6gYPxFFwGP+kGFG3GL8Drt3jHPcKz9V+boleOih4giwedb9ZJxItYG4uj2xliu812y0ujVxpWl/4ouY9K9VtQ7LS+L7kueahQ3iylzsb7B2rcxY6ir+vQ0= X-MS-TrafficTypeDiagnostic: AM6PR04MB4215: X-Microsoft-Exchange-Diagnostics: 1;AM6PR04MB4215;20:1gXsT5z963bYUu3HRgaBwQOH2m/b82YgWcJIASkjX96cyYz1agHBF+9BU1vyh5deBlDtFNrnJBJEIZfV73514VBXlmjtRLlAMrf8d48BhaBSQBnomTiD/1TzK2Q6FyWdZLuYIjSHjnpX4QgqKT1A37N7SZ1F1NYgJoTv/GXiGYleSQYtiPRyExf3v2qXW77WIxrGn/rGL21SbAA6rv/8FVHbcjgpaDeM8tfgZf4E/nck0vndnELJlEKeZFspwEiPpEd3OnE4GCr2IVTRJWbOfJ6mTqlkzBSei/IVyBJCzz4U9RMuSknA0EGlqSkTLHwqQg/+EDB/xMtqfAN/vtnhnEd9HJPZLA1yjoweBrR5J9wD8+8zA7Y8NPmnRllSHrq+uX9bV/LXZtlkIjRcDkm8pYZUYe4QIJqifQPjR2nQxAgbvD6rkPWPu9D1H2Fud8+8W69d1a1/PpqlZ0Vx8P5IB9t7Rxyz5mV4pLOioEOBZiXSuxrSqSECsKedEB3XjtAa;4:7yYSIgD9XcZ70dyZIoIDtet1lCQ7NoZGVtAqagANJEGAVtnP4oqHDRO/ERdRR9+4jGyYf0U03PKP00hJW4764nGtGzu+YdbFz3VYtVrcjbjg+AzwaVFRxF0lR7jCWQ522O++tbnmgbaG/xw1SS/7n/0LHcsUb5MkFl2PehB3yvAhm3xjA6D0YeT8vlDc2HWlFFjh3WmeFgvqp5p6wnPrRoqwMWroPKvzdra+nPdP7I8ssLI5ZNRMvn/NJMkk8LeINKpa7YRAKuOAekMcmgQ1vFZ66uCVcj+RGK6ZmEs6yjirIbERarOff98eqraEphWks9AF6K6oNa0sry3ZRsMdOczcstB/ZFf5PFZ6f+1+8vk= 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)(20161123558120)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123560045)(201708071742011)(7699051);SRVR:AM6PR04MB4215;BCL:0;PCL:0;RULEID:;SRVR:AM6PR04MB4215; X-Forefront-PRVS: 0818724663 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(39850400004)(376002)(346002)(366004)(136003)(396003)(199004)(189003)(4326008)(16586007)(39060400002)(8936002)(8676002)(86362001)(2906002)(106356001)(50226002)(478600001)(2361001)(52116002)(51416003)(36756003)(68736007)(81166006)(2351001)(76176011)(81156014)(6486002)(14444005)(105586002)(316002)(6506007)(386003)(48376002)(16526019)(186003)(97736004)(6512007)(50466002)(476003)(2616005)(956004)(11346002)(53936002)(446003)(486006)(3846002)(6116002)(7736002)(305945005)(25786009)(66066001)(6666003)(6916009)(5660300001)(26005)(47776003);DIR:OUT;SFP:1101;SCL:1;SRVR:AM6PR04MB4215;H:shlinux2.ap.freescale.net;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; Received-SPF: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: 1;AM6PR04MB4215;23:fI0yRQ4NZfOw98TvqxWn3SJPWcFEV8CvIqiWqhv4C8DGk7qH39bMi+mWjvKObgdlyYDCEC1zYd5TUzqumTI7eO43O5GSH/htadkVUWCXTlF7IAlaySZh8epgRZcYr6id8DabQNtC6ERAmT2/WwLas+QZjgn7Zeus9QmZID6PixF2kNFRZgQ8k+s8qjhqVzCB7Q9mwLhLtxrC+A2X+wwnSs88hCMRyBQzE0piDpXToLMerB4a8VO1tcTMW1r9PAgNs7TkAg2sVgofZpoNpJyJp3VY5Abu5XivfyEhB0X+cDsvFRuWcjSNWsuB4LQK7Mz9c8NU7M338QZ2TLY5sajv+BrmZYn+yJECP7EJW6A5x8bApu7VOuO5KMNYbZ4BFfF9aY9zDOhdXK/WVJVG4auzpIxBA9as51lxyPvinkciXKAZkUJhufIRAtyl139xO1ph9Qtgy5oOIb/fEQay8IgDPrmJvxy6rfDGmiWZ4q9HK5B4Jwuk5MYtdtyaUqded75H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UC21K8N7S5K//kvxW4StC/SB5Wb3Vz31c3DpPMIsSTg74f2OW5hA6EnJRg= X-Microsoft-Exchange-Diagnostics: 1;AM6PR04MB4215;6:ZEIRlM34s08LAaFFncbCwQKoT1JAG/DLhtRo6B0WIyJKpL5dF2cBxw6yehI3MpBAVd3RPrqo90AMMD96pPfs/G9SwROmRK0bWo8Q4G8vaxTImlCWweLGfBtTz+4wXiXWQ++6NWRxKEvRWISBkat4TWnGzuq+r/lBXdtxkD5E9Di7BmbtTjJYk3t9yaQ/q47mGNwaL0cX1VHT0JKNx3KrsYYco3SzCzsJeJhbAB3wobIiRlt70Y2fkl90tbm9ymgAsozAQYGpEG68tkXzDkYxI88wSLhnVPrzYQmCWVptQSIygfjY0watWCSb1KSiC7FWIL4OowYos3YRvSHVFnPoeboP5lasr/32YDEViLksjfqtgHAM5j4gDTLvG9BaBn6WkwP2N5cZ0PZFgva2btbA/ZV74pnNCqD3UOprd5Cau3dNuuhym7L8XBh2BNMa0Tve2n1ctqHxMqVfRgwoDRb6xA==;5:45lC/Bee5Kuek9vqVlujrKQBBi7DA4E4EJfXcVmt76JO2mVVYgCJ7nHkpGTbBLsNEW0CHwvW6qXSvhp72DZt7lKh2pcAuwwfyhYjrbQrU9SutFcCY4BR3A9u7FtDugoylsfm9uvzg+hQmREi04fOeaIaROVXrtImPWqvn6uZC84=;7:uDzDiQnEyVlV/4efhIaiyWrLBTy4aVgkVMpFLKwR/DtJTv5bQopHzRQXv0p8He0KR8vzPKi++Lv8icOp3NGQ4LactmOs30neyeaKgan2LaM4WiLSSTOTOd46yyd1IRSpbJoIni+Jghv6qO5/wtKRZVX1PRxGjSZLKaolUk/3dQUX+bQa5zBx9O9SkGGbO/J8Venih26GteLLOV1DpdD1Tm/Hkow4rtrfdu0c26NXXlj7X+6ShU/FO8tV1IijUmsQ SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Oct 2018 13:25:31.8349 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4667021f-8d3d-4039-ff17-08d62c585d22 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR04MB4215 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 Sun Oct 7 13:10:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aisheng Dong X-Patchwork-Id: 10629635 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 73546112B for ; Sun, 7 Oct 2018 13:26:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 51BD029171 for ; Sun, 7 Oct 2018 13:26:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4404529206; Sun, 7 Oct 2018 13:26:02 +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 80A2629171 for ; Sun, 7 Oct 2018 13:26:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727802AbeJGUdN (ORCPT ); Sun, 7 Oct 2018 16:33:13 -0400 Received: from mail-ve1eur01on0079.outbound.protection.outlook.com ([104.47.1.79]:39997 "EHLO EUR01-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726803AbeJGUdN (ORCPT ); Sun, 7 Oct 2018 16:33:13 -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=ot0pGC1L4qTHTCMImhoRCHgnW0Yr2Ca9NE/d36QhgGw=; b=e48v8cmuJTSC2OeS/4OCZXiaQjI/BweSTTUuF6KP8mQyQq7ioF0UjRjEXDmDN0yIY6L5EdfniSyNzLh9BTPEXkHDdeVIZhroEu+w3W8AkoDtUFxNu6bts9j8eYvNk9pV1324N5i92+1kUtH0SBW9oAf+porwDg6je9x42pKmWc8= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=aisheng.dong@nxp.com; Received: from shlinux2.ap.freescale.net (119.31.174.66) by AM6PR04MB4215.eurprd04.prod.outlook.com (2603:10a6:209:4f::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1207.18; Sun, 7 Oct 2018 13:25:35 +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 V4 2/2] firmware: imx: add SCU power domain driver Date: Sun, 7 Oct 2018 21:10:07 +0800 Message-Id: <1538917807-1921-3-git-send-email-aisheng.dong@nxp.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1538917807-1921-1-git-send-email-aisheng.dong@nxp.com> References: <1538917807-1921-1-git-send-email-aisheng.dong@nxp.com> MIME-Version: 1.0 X-Originating-IP: [119.31.174.66] X-ClientProxiedBy: HK0PR01CA0045.apcprd01.prod.exchangelabs.com (2603:1096:203:3e::33) To AM6PR04MB4215.eurprd04.prod.outlook.com (2603:10a6:209:4f::13) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a3ffa372-796b-497b-0c58-08d62c585f76 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:AM6PR04MB4215; X-Microsoft-Exchange-Diagnostics: 1;AM6PR04MB4215;3:pFEALRkzRtsapNyC7Ddpkirr2ggNU+eclziOCgxIuWVm5BXch1rse21MuaZl4QP0jiI2FRAjGoSEMRLajG4mszSoPFB/KvvqfJDBJyLLOr1brGSHKYmy/SwL2oPS85vFZkLhXDrx+7AZXDgoCqtF3anK5wN3rCpkcfa+E3mgKtO1hco1ezhGYkP5JKrDA51Y3YrYmPutZupEp3U3iH5WUsrnAEQjlgOuvwmItIR85c4mczLtBxJiUXcFexhNZU5n;25:sKAG76eynCIa8J8p4UIGRxore6Z8oJJn6XpM1i0aSeT8i5WolDF2MKzmwEcq4ex46uD6LsDl298TiZ8MXiWZclgwndvdbjtTJ7pt865IfDvz/QpfVcbpr+XWZO5GZM9Ij7ApIPOi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7UImbXaSnyeVZTxIOelMGDlSCXWtAsHiewJMIdY/bW+S7N3JAbo3EVMaD9lhKTO80uBhIS7VB5/TxD4Exi7AKCDnwU7ydnfiwJzxRBSv+XZpLB8hvEhA1wRqfL2WQ3AjylBJyz+oGy9XrfyPRsoq2uguX+obnBOHVYZTVTLz/i+5eJZGjKql80VYtg2dPmp27GJ6zCEIxTOV1AVrCM4iRLmem6FGttEZ1xMnbXcETUNLkOvAf5q1NQALNIBcjYMgCO71CTUx9xbAacD3sBh1I1dr7w+sMvX4VfaivQJn6fJ4+PHHHxGd1Z0DDo5B+rwf1xpLH73d 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)(93006095)(93001095)(10201501046)(3002001)(3231355)(944501410)(52105095)(6055026)(149066)(150057)(6041310)(20161123558120)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123560045)(201708071742011)(7699051);SRVR:AM6PR04MB4215;BCL:0;PCL:0;RULEID:;SRVR:AM6PR04MB4215; X-Forefront-PRVS: 0818724663 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(39850400004)(376002)(346002)(366004)(136003)(396003)(54534003)(199004)(189003)(4326008)(16586007)(39060400002)(8936002)(8676002)(86362001)(2906002)(106356001)(50226002)(478600001)(2361001)(52116002)(51416003)(36756003)(68736007)(81166006)(2351001)(76176011)(81156014)(6486002)(14444005)(105586002)(316002)(6506007)(386003)(48376002)(16526019)(186003)(97736004)(6512007)(50466002)(476003)(2616005)(956004)(11346002)(53936002)(446003)(486006)(3846002)(6116002)(7736002)(305945005)(25786009)(66066001)(6666003)(6916009)(5660300001)(26005)(47776003);DIR:OUT;SFP:1101;SCL:1;SRVR:AM6PR04MB4215;H:shlinux2.ap.freescale.net;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; Received-SPF: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: 1;AM6PR04MB4215;23:Gap3qtYXoZziH+Ly+DmDLzheKy9C3H/0xLXpb0wD0wu7iMQggzuJkTr5OjkvqLkXETwO4Ax2ujSsASsAGOGbBi+sEolvMGBTtQ/UtX6A7qFajtiJmZLOvP4nZBvkb9AE/S110m9N9ZXGx8ZSwCLBJyPmmAbjMZkfV5oZ+zRAVUpjsk3IgoBw6DbjTarxpXCQoUWwPLVU3daclgPY1fv26A1cO4Dr7nndk2yAszhkOLub/Sr69iBzEYQM9+jxp52lH9trDJuFjkOMCxcA1RUNL/q9aZQ7ksm22v6b+Zdu5gholcaQqG/yhkdSYxbIHrmbnRR2uCL+PuM67zrnLbQRI6M3Ij8vyGN9Q1thNV1KOlu6BpmTNnq+EdWDfO5QwxxMqiRYUJvgQ3gct0vK5VrWmbaN4jHdDvmmXu1Kbo4kPHLjK8apX+Qj8jkRS8KsPO5fWMgAQh1XtkXDVoYGzu/xYNjjv8k8VDCMgsIhzGdvZtEDGRUcOwhfDAhznA1h/f4Qw94Kv5iaODDmrIH3EBTynBMo9t2sgDavZPWK5JU/+vWxKIYA1T63GpcxNaZ2tsizyEa0nBeJYGX6Gz4SXNziYFMZ/KTqZIiH/Ktba95c7sSCJzCfMYCq9q9QuYcpRilwQWWMnDa+trckmd0IUv3670/zY+WfOd88SqpWZI4ZNTfjWOulmVxVCgAFMdJn36hBm2/FiKoqAHAwOKAY/Fe9j/S4/IFRBkaCaCSwJLd4TadaRCmEo8mLGlQ8tiH9/t48QwrsV/Kn6Cq3au2r8kgIcaYlMoOUo9gizPqXW/Vl+PQXmUeC8DqkrLICWUb3ekJrlOq4POv1DGP5F86JgGFOOgv1PmCAInTB3+n/LFFN8ZLonvvpdZPQApGp9BpYWdrTcicmsF+R9nZu0Rd+Ii/MMh6UO4RF+LHxY7Se6lwn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fnPbZ9Ju5k3L/gzEpRXaM+DtOX+DNOcu+L2CG7HsvwvbHzW7jdgG5r9M8RQa7kRBkbJuPOVuCSVOU9hEhi5UCjUCFJaMrvaccKDmGW3ISwHojZqCS2BUY40tZfeTLHcy47EUW3Mz+DUw9b6fhG7BSxg==;5:hllROtXR+f5ugSMB7KDgUVAwzxvOfmEhgQI9v1ANexcG4nkJ+y13U6zf8Nei7gnAcPHFlcyZIJjwZftJuu9HNj+YZHaQKs/FcVxD7qF/hGblHYWM79X5cUr8OHPPr+O4yLJhISolofy7jqH6kIO8hFfTJyhzBfFErhwck88xFR0=;7:zUJlfngHKlH18JVdD8HHbWuOFEbFMqLIg7AsSkMZSmCgWM+2XZc8bp6vfktEjQmE9VdMf9Sj/1IBwZnF8UOr4wf+vCqHJu8TT6f0l3M9A9e03Ott1ZndYqqnU/tJmtdimUSS87tBUogzty1NWziCphXJpg04/w/26nkU5jAdfdAFDDkJ5+aLSUot5MsntiemUXefYNQiZIYUHFpcFENvyeqlvkQW1lYAAmXfOctmxnXiams1+sdqOVfoHtDBiUAI SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Oct 2018 13:25:35.7297 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a3ffa372-796b-497b-0c58-08d62c585f76 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR04MB4215 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: 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 | 167 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 175 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..af5b9e4 --- /dev/null +++ b/drivers/firmware/imx/scu-pd.c @@ -0,0 +1,167 @@ +// 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; + } else { + imx_sc_pd->rsrc_id = IMX_SC_R_LAST; + } + + if (imx_sc_pd->rsrc_id != IMX_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");