From patchwork Sun Sep 30 00:53:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aisheng Dong X-Patchwork-Id: 10621041 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 505F1A6A for ; Sun, 30 Sep 2018 01:08:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3F0CD2917E for ; Sun, 30 Sep 2018 01:08:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 310C1291A2; Sun, 30 Sep 2018 01:08:15 +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 96B8E2917E for ; Sun, 30 Sep 2018 01:08:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726575AbeI3Hix (ORCPT ); Sun, 30 Sep 2018 03:38:53 -0400 Received: from mail-db5eur01on0069.outbound.protection.outlook.com ([104.47.2.69]:58271 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726442AbeI3Hix (ORCPT ); Sun, 30 Sep 2018 03:38:53 -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=wUP5lwANHFj4UEntJu5iwoaji4u1bWBp53OyLLi/jNk=; b=E/xScQne2KzLA0qigqI627w1W2gjM3JFSJ2vpzgTbcaQqC6PHpCMD+WeJRKqQkelRIMzaOVV8NCy/EvDYVHJt+4cC8LFBbNJLSGrqgT5k2xpj2SUoQmT/x5Ury1nrY6PfuOMKVBynATXsVmBoRjrsZdJ7Zw3RiomamEBh4ztdV8= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=aisheng.dong@nxp.com; Received: from shlinux2.ap.freescale.net (119.31.174.66) by AM0PR04MB4210.eurprd04.prod.outlook.com (2603:10a6:208:66::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1185.23; Sun, 30 Sep 2018 01:08:07 +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 V3 1/2] firmware: imx: add pm svc headfile Date: Sun, 30 Sep 2018 08:53:16 +0800 Message-Id: <1538268797-24830-2-git-send-email-aisheng.dong@nxp.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1538268797-24830-1-git-send-email-aisheng.dong@nxp.com> References: <1538268797-24830-1-git-send-email-aisheng.dong@nxp.com> MIME-Version: 1.0 X-Originating-IP: [119.31.174.66] X-ClientProxiedBy: HK0PR01CA0062.apcprd01.prod.exchangelabs.com (2603:1096:203:a6::26) To AM0PR04MB4210.eurprd04.prod.outlook.com (2603:10a6:208:66::20) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fb2262be-ef49-4311-2126-08d6267130b5 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:AM0PR04MB4210; X-Microsoft-Exchange-Diagnostics: 1;AM0PR04MB4210;3:c28bLoP5aG+vsY8L1h9RVIVGjWv8EtU7i1GUmqQ2Z0cZ0xqY7m40GoaOgbV9CgAOThIW888+Mrif/DzOMF9W3jgGP4wi7flwC86iWs+nN8Zo6ckEFnzHjE7RdRJthoaZlbnnh9vA7Isvr6R2BDpvhg44jhpGDNh0vRnSjTfxTiKV7wsUAnWlIvCLoNEtSVxe/M3WWu7pKVGqr0hRxGUQCWYHuup4FouJgdwRSWgAPKmzDGOv73rH8/twxQrWRaWw;25:FJQGFX/++1mIleLeCLhXjuFjoYSigXJR/g9JIe4K/LVWVOQqpdxsp0v+xTaHChpdRRaSR/X35pgOZC/gvxsGBsJUMDQy9A+tRXyu/PCcHGny/z3Vr/LNGJWrmhEpyZV6Aqrkk9dnUO0jzpM1mlKvTh/+xJw+k0qqQlSzxqTwk6F/t2CtHLqnZo2L9HqkhM8AhxbJVs+t+oJGybIebiz9WcK4+120V5S6T0MJRTMTPGSqMTwJcvFXN9qUFfOG5SODgq+Qv6l3EUkXyOFkmM/sojM9KSZhqfPT/EHvVjnHrRZ4bEM7aHtlYpECXJJef8r/HC6ItSJWrvIy7KaiNtwQmQ==;31:XaY+D7P7dvhyr7AjCo+bb3q5gpD9mfoyUfmb3fvemwWfaDOoA2NTVZNQMjExWvsz55Zq+82aclOq2sReWMJnpDm6yDJcgn15U/Mi0yTayNTdhThU41SZM20PVR/R3ZJuoPM2CYHZfecFdD9IpJDhhDB96PD0RyWpUhrEEFGCHct+ZRSUgjog7n/fluLLHuzKMDHRlIoJfcl/Mqtk+RIuQWFrJIBOclFiu4v6REyRCQ0= X-MS-TrafficTypeDiagnostic: AM0PR04MB4210: X-Microsoft-Exchange-Diagnostics: 1;AM0PR04MB4210;20:njfmZXwxdVMDesMpON3yHla4+WlN87sazb/I1Fw3kgANE6Iri7fNOx5iQLDOWuzMaiT/IXzw4bj+JpKDhuvSzTSJwrA90vQ/9krcaK4w3DmtOJG0nk/uDEkkZTzIy3wR64tTHBwc+KBWnZO0ORJvaONIqwf+gwX91MUnVGiSBw3AG2TLR5KHykfTPU5jxCnQ+sg/Sbfdfp9gLQv6T04ubiJXkU4NyuIfcQXT4GYcPXgyaPwjeb9eHMEeNwc4A5pZtwq5BiBgmS1oaifxWyLl8qYZRlt5hJ/N/qtzyJWf0ZEQReKu8/3hgLv7gDffxwXcv/EPvyUXSSiJ/qVerSlo7FFgL5irxqktKgEMdo/XOc9Hxl24nOfqLsiw8a1O4Dfo5+oxw4a1Kb3ey3RrD5hoU55K2JBCe+kHd6jx2lgaHzFy6MpZI7rLXvKva5NFmkvxMGVUOJJuTvI4r49wUza1cRjfCf96Z4dccBYUiwBZ4NRtoQYg3Jzii6APNQVuZPqv;4:quHKpuxl3aXpQ9fxXp+EokNkh8CW4xDTYf7xdyj6VI8q1FMqQJZyLHtsEo9X544/pqnZrJtbyTgRtJ66/babSaScSnsTZ+s3KqFToLNH9FfvUbt11cDK/rnpA5fHk7V9tBU1Qlb+18OkZY04+7ZGxRTMXirgElonuJgitNkWUR3QsA6VCLGQ75WjxG/MfKJ58kFzD3cMPvcLo8LSij7w9ZWhYssekszwsNd0Vhr0V2cYDlNAVor+v0w49Dd3S9WR4W2ucjG5TtrvOM9djs+BlECO0OnIwBdf/Cu/U8ea77Pcm0/EZLJnJ5DAboec3pV9Zm3uicmI0Z6DvCYYWdfsh5CyE5nyjMum3frrTTSLPdc= 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)(3002001)(3231355)(944501410)(52105095)(10201501046)(93006095)(93001095)(6055026)(149066)(150057)(6041310)(20161123558120)(20161123562045)(20161123560045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051);SRVR:AM0PR04MB4210;BCL:0;PCL:0;RULEID:;SRVR:AM0PR04MB4210; X-Forefront-PRVS: 08118EFC2B X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(396003)(376002)(346002)(366004)(39860400002)(136003)(199004)(189003)(16586007)(48376002)(50466002)(52116002)(6512007)(105586002)(106356001)(51416003)(446003)(2351001)(2361001)(316002)(486006)(6486002)(66066001)(11346002)(956004)(47776003)(476003)(2616005)(305945005)(5660300001)(4326008)(25786009)(6666003)(8676002)(26005)(81156014)(81166006)(186003)(16526019)(8936002)(3846002)(6116002)(50226002)(68736007)(97736004)(6916009)(7736002)(2906002)(39060400002)(36756003)(76176011)(53936002)(86362001)(386003)(478600001)(34290500001)(6506007);DIR:OUT;SFP:1101;SCL:1;SRVR:AM0PR04MB4210;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;AM0PR04MB4210;23:p/LWm0lfEPAYK3hLq0cCfPYGvfbgKZw7REqmw9X4kz2dnzYD/8xBnEC9WKKTkquS0alCLj2XHUltrICCyQzGGxyd+OAHLKEHKRTq8gU25XYY3xVtaajIVEa+bhpJfDnjMu1/iB8zYx69Y+J1gyLN/AYb4tCrr/F3Co82BZd54Gcs82LILTsc21CQZ+iP4KSOY6UemlY/qN970MyMPQ9Wh3iuTK5Y2B4vRooOS7y5dyK4lbX1swga4FAiDONyIF3fuj5tbKtpuKdYKmnkL+0WwGFWk1i50uwdy+eoj2/mGfhfOQvJnSPEjOgXW2kzokB0gtAAjOejNhTmNOlaUnlxTacBzDvHyziW/aNpWxIfP6bfC5PbQSveXTzcsXwOJ5EXBYmdZC+SuXsRAmCqQI05YZH/27pPpMKZG6Qk1l41Hx2Jx7xJ6JCSdXMqtahWCAAtGgtANTleAxOyVqh+jUirBFpj9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X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2018 01:08:07.6997 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fb2262be-ef49-4311-2126-08d6267130b5 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB4210 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 --- v2->v3: * name updated with IMX_SC prefix v1->v2: * new introduced --- include/soc/imx/scu/sci.h | 1 + include/soc/imx/scu/svc/pm.h | 85 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 include/soc/imx/scu/svc/pm.h diff --git a/include/soc/imx/scu/sci.h b/include/soc/imx/scu/sci.h index 4a60d70..b600f7e 100644 --- a/include/soc/imx/scu/sci.h +++ b/include/soc/imx/scu/sci.h @@ -14,4 +14,5 @@ #include #include +#include #endif /* _SC_SCI_H */ diff --git a/include/soc/imx/scu/svc/pm.h b/include/soc/imx/scu/svc/pm.h new file mode 100644 index 0000000..192dee3 --- /dev/null +++ b/include/soc/imx/scu/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 Sep 30 00:53:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aisheng Dong X-Patchwork-Id: 10621043 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 1B51316B1 for ; Sun, 30 Sep 2018 01:08:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0A4A52917E for ; Sun, 30 Sep 2018 01:08:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F2C2C291A2; Sun, 30 Sep 2018 01:08:20 +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 A52962917E for ; Sun, 30 Sep 2018 01:08:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726686AbeI3Hi7 (ORCPT ); Sun, 30 Sep 2018 03:38:59 -0400 Received: from mail-db5eur01on0082.outbound.protection.outlook.com ([104.47.2.82]:52784 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726442AbeI3Hi6 (ORCPT ); Sun, 30 Sep 2018 03:38:58 -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=fWPtQt51mt/wSQGn/HILGqPTkDyaXY7TH5DVVuXMH8o=; b=USVuqRScsc0Rv6h2cnteJevN8vaiPjZCBzrjaT98staG71gnduxyEnug9a9Pv2IeI/GXliawRB3fJuAs+esxmC2c4j5oh7Yl6pt23VMzGvFVoutrZANgx+uaokDv3NHLynzcttxFi5Ce7jkr/6KpuGyT920JlcarXeD1oL+0HBs= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=aisheng.dong@nxp.com; Received: from shlinux2.ap.freescale.net (119.31.174.66) by AM0PR04MB4210.eurprd04.prod.outlook.com (2603:10a6:208:66::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1185.23; Sun, 30 Sep 2018 01:08:11 +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 V3 2/2] firmware: imx: add SCU power domain driver Date: Sun, 30 Sep 2018 08:53:17 +0800 Message-Id: <1538268797-24830-3-git-send-email-aisheng.dong@nxp.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1538268797-24830-1-git-send-email-aisheng.dong@nxp.com> References: <1538268797-24830-1-git-send-email-aisheng.dong@nxp.com> MIME-Version: 1.0 X-Originating-IP: [119.31.174.66] X-ClientProxiedBy: HK0PR01CA0062.apcprd01.prod.exchangelabs.com (2603:1096:203:a6::26) To AM0PR04MB4210.eurprd04.prod.outlook.com (2603:10a6:208:66::20) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 80b6fe41-f8ba-4041-5a48-08d62671330f 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:AM0PR04MB4210; X-Microsoft-Exchange-Diagnostics: 1;AM0PR04MB4210;3:Kt6W1AcX4uMpOhg2GGESJZTPCNFXE8tprsQdzglVVJFgckVU/7Y2BwVDPA+f27+UeOcIGQt9UCRNsnn3uVTa4HbGdk7IqcuByprLVkhcRaejrYUeQ9fHgCeSNh2E6G1zqNPXnzhlQYtjhKEKzn7dJNaraAMqqufW9jyrZ9Kr1n18URBpkPiBZefrENPZ/b8Z1u315FB9gpHHLbYuN734BZYiUbLq1/a19ljSgEmQLmjZUkUIWnb4Uc0o7dBONR1s;25:fsxAy1h9Bz2uTW5ecDQYXQrgau8YQMJIBjj4zqDmFqyhozVd3AyEMjBYWskRBZO1B5iBBug+u4xVHnNDngdEw50NssoCL6nt5Zt4yjsi4iTHVScOjTbzJoFp3bMwtFF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sqw12KrpDQfPwNAA/Br9V9EopNetemOoQulfRiXA8AxvUpoIxU3DdeP1/Aml4MkmG48t9dC2DSdhIy8E4NMokVCe/yyAmJxpVjBamM9EvAI0OQUPwzy+gIhtfi255FTzn6ZLPEesA1I1K7bk37W2MfyL/VtV4nLwkhEHaGVrhdMTDeBx/9z6tgpXMG0me78vvMah0aINmhuXJ7RSpsQzXQDVOIUfHIdfGUhfqY5oh3rqUgW0hotBKEu1cVsQ7U6vqTk6GCVV5FYntcQsumyKPIEucSuyHIp4nMo+n2kYpltoAqJM0LdXhJ8/OhPDmWCojgYG0f9B9qssBSCoXlin7y 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)(3002001)(3231355)(944501410)(52105095)(10201501046)(93006095)(93001095)(6055026)(149066)(150057)(6041310)(20161123558120)(20161123562045)(20161123560045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051);SRVR:AM0PR04MB4210;BCL:0;PCL:0;RULEID:;SRVR:AM0PR04MB4210; X-Forefront-PRVS: 08118EFC2B X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(396003)(376002)(346002)(366004)(39860400002)(136003)(199004)(54534003)(189003)(16586007)(48376002)(50466002)(52116002)(6512007)(105586002)(106356001)(51416003)(446003)(2351001)(2361001)(316002)(486006)(6486002)(66066001)(11346002)(956004)(47776003)(476003)(2616005)(305945005)(5660300001)(4326008)(25786009)(8676002)(26005)(81156014)(81166006)(186003)(16526019)(8936002)(3846002)(6116002)(50226002)(68736007)(97736004)(6916009)(7736002)(2906002)(39060400002)(36756003)(14444005)(76176011)(53936002)(86362001)(386003)(478600001)(34290500001)(6506007);DIR:OUT;SFP:1101;SCL:1;SRVR:AM0PR04MB4210;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;AM0PR04MB4210;23:EaVK3zgAZv4ZTUW0XUE7nDYsW4CgqEryLaNKNzTE5/aPwD4n5uSxtBe4ZRoMpwc2NXEanG1j7r7y7ywxBj5tSeH1R5pyS+PhCH+vC32Ulap7RN/C42mACspQyENuf3bavTzeNjJ9WnEJ0pRkOxgPhhYwR7v3mOJ7iAtX26uovB3AY+dROGmXcanVZW+7ZXJ43wSPHvEGkSsyd3qUMkA8rglavFCNVw8g24ikRGwJxntvtEeRqiOtCLwqyLa4amJn88MNOeLw9X3s83z0Qa1uGFOTXk/WQjDv+JthmXm/Cmg36RxHBv+TImYacgAbz3gvLAPDjq6GpBpIkQNCXztrUrEMdqFqFXst1Ug9Lp5mJpRp3b3mna1ZSf3h8fvBnFw2tmHJuiE5szEuLsmgmSF8kNm8IrJQMDTM66g2RtH+N7CBcZ9ArJ/jWtjUyOAmNt1BevKKqVQSibT0rxBRhiJo8giPzbwLh0jyJOgViOdd7Hyei0K2SeZ6eJb5DXjneSOdiV+42hUHvfhmaoQflUKA3L3TW+vjSXcX223H7L9Vk0hCF0NPoJZFcfjkgRWgzP2MVMpKPTxRvrMy3mDubcoJ/G/VL14rC/sBIovtP3gErwM2kbBRTxC34wDdQ6cwyCsmgIf1FAydk12eJh1Ma7fit74/rJZuy7f66pQYnEffWzIUyKeBWv9P+K0EIwCrZt2G5DZUFwARHJHAx0J10VhcvnxNoaF7ywv5/8NZpg/PI1iNZN2m1opWnODawWYBU4043cksLf5CxWcHtsEmCwSSb+MR6EQ2tbxTA7Xrac82PWDXfs6VNtP8z4PzY6xXttorQHH1hjKZKBNJGcbU6WyFmmcr5qu4jSGWSXIpwlITODhl4/iCW53MNHmguCh1EnwDZ8+kql58xbe+wYd71kjB606mZJB8Gu4Spm5NJhICMI8C45Rh1QIEW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9UNbqgsHe4l8YpxKESnperUB9opCIyUKuTmk0do96pB4HM6aigvbRTWVW6DEzEkIaosN2SIc0GxNSC+9IdQDrmJagGZvJu7G9jqNXDQcCPOTpcd3yjLzDKJpYBfPwC8VDq82qHwwO6uw24PcRsyvsO60VIryZfcB3PMAP/ZEjnjPZ9w==;5:UaBwznu3m7hHpPZaaiuJuMKYEcn5BcFnrwwKMVGdQVhUXPiwrabpH3rH+PaDb0Y9TgebDr3314n0J5ptU7oimjmlljJ0ntKZY0zV1vCcFowP2m2JKZa3daULGlAt8y4PUi1jMpMl/cynT31ypb0UUuD2o60Dt9J108rMfb7AZfY=;7:HvJ8lwR5nvE4Ui6xZLm9N6Pf4W142BPXbi/hc4iSlkNcbzE07tT6Su0kQ9ThlKyVDPrTJQb34+NRVHdFh8DvwToHApxBbsMDhXENQUzR+QZBWrQP3BcUoqBVxvYccuJsIddJKFvi3hlLLwp+So4fKBZ1TNkKgNsawJpK9QXo91B6u0faSKlcKsQyz/PWY3ll+7nvQR63/g59HB1RYHOo8w2shCA3L67MZx6OHhGB4a9jkHhQDNz4tpRaeLOUvAGR SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2018 01:08:11.6425 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 80b6fe41-f8ba-4041-5a48-08d62671330f X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB4210 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: 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 | 168 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 176 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..69ed028 --- /dev/null +++ b/drivers/firmware/imx/scu-pd.c @@ -0,0 +1,168 @@ +// 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");