From patchwork Fri Apr 27 18:56:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aisheng Dong X-Patchwork-Id: 10369655 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id ECFE86053F for ; Fri, 27 Apr 2018 18:57:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DD4EE29144 for ; Fri, 27 Apr 2018 18:57:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D232729257; Fri, 27 Apr 2018 18:57:49 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 A860829232 for ; Fri, 27 Apr 2018 18:57:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758684AbeD0S5l (ORCPT ); Fri, 27 Apr 2018 14:57:41 -0400 Received: from mail-db5eur01on0066.outbound.protection.outlook.com ([104.47.2.66]:39360 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1758596AbeD0S5i (ORCPT ); Fri, 27 Apr 2018 14:57:38 -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; bh=RrcuraqFGEN1pwVH5Rip2mESDkXIaLEcmxOBqvDc/ok=; b=l0MP+bskZsfofbXAoSPu7KRRDDTtbtksXLgYpL1t3JYpuO3Pl4rYBbWg80ArWgMI6q79uyneoWLdL72NalBHVBq4U6qJ3N/xB7l0Kf2kdNn/EEzh1fDM4pbtuYb+m+B7My+B/Q72ZsnTrLounJJGfJ8JYf7VcrAkeoRDXIBE4Yw= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=aisheng.dong@nxp.com; Received: from b29396-OptiPlex-7040.ap.freescale.net (119.31.174.66) by AM6PR04MB4213.eurprd04.prod.outlook.com (2603:10a6:209:4f::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.715.18; Fri, 27 Apr 2018 18:57:31 +0000 From: Dong Aisheng To: linux-clk@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, sboyd@kernel.org, mturquette@baylibre.com, shawnguo@kernel.org, fabio.estevam@nxp.com, linux-imx@nxp.com, kernel@pengutronix.de, Dong Aisheng Subject: [PATCH 06/12] clk: imx: scu: add scu clock gpr gate Date: Sat, 28 Apr 2018 02:56:37 +0800 Message-Id: <1524855403-15301-7-git-send-email-aisheng.dong@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1524855403-15301-1-git-send-email-aisheng.dong@nxp.com> References: <1524855403-15301-1-git-send-email-aisheng.dong@nxp.com> MIME-Version: 1.0 X-Originating-IP: [119.31.174.66] X-ClientProxiedBy: TYAPR01CA0025.jpnprd01.prod.outlook.com (2603:1096:404:28::13) To AM6PR04MB4213.eurprd04.prod.outlook.com (2603:10a6:209:4f::11) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:AM6PR04MB4213; X-Microsoft-Exchange-Diagnostics: 1; AM6PR04MB4213; 3:/iJmAVmQc1cXv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YfGU0fN6Vrc3tQnD+ajJ/5JVXQbB8E7HRXw+AYPh7biGUjYjI06k1iwjeEuH9A1vfPdGJ8J2MLFSiQgsiVOPPXq0g3JAyoqVv4SrHcX7IXwgbKvAsZ4PyASkjXnDsCc7gROYYPpndUnhhniH/OJc/VdT2cU5XUth6LU+7KARYycuHW4kF5ZtFuRWceEUycQ/gt0vU99gobmD1a0kRkWdj8js/2wTWchb3hP6kFEVIJZTC53O2uY6ZnsDlD54mfMlpsa1trXJ5OrqhEeYZ610eAbQlH/2RqEmLIMtA2CnDqXYfWAsxEF/lLWA6H0Ygqy68; 4:5rh3t3Sja1S5NSmHB7JnoL42m/Ld5QHn1BE4HmyMFGrRzzzH3kn95KcsygZy2beAleCJyOfy5Y96s1fvY7dBo4IN4Vt5AAnhKyeLWbahfNCf4NCLCjNozdHqcjof9NAxsXt7tHeDRkpJTiua1XTEb/ri0H1sutPRWQox01w3y50+YgaGAh8UIwOYzymTyRA3fbm9GRgWz+K7M6h1j2B89T2X4vm9J12EKFu+iGa9+GDg2TyMtXr6teibeOMaz2VCgP9UBIkSa19x7LBCvUrAYrLCcn1sDu9WFnosCkMJPz6aq8r2B/58YpZOUHtMrl0O X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(10201501046)(3002001)(3231232)(944501410)(52105095)(6055026)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123558120)(20161123564045)(20161123560045)(6072148)(201708071742011); SRVR:AM6PR04MB4213; BCL:0; PCL:0; RULEID:; SRVR:AM6PR04MB4213; X-Forefront-PRVS: 0655F9F006 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39860400002)(39380400002)(366004)(396003)(346002)(376002)(199004)(189003)(76176011)(97736004)(26005)(305945005)(48376002)(47776003)(16526019)(186003)(6116002)(50226002)(7736002)(16586007)(106356001)(36756003)(50466002)(2906002)(51416003)(66066001)(3846002)(52116002)(316002)(6506007)(105586002)(386003)(25786009)(8936002)(4326008)(5660300001)(81156014)(81166006)(486006)(8676002)(6916009)(11346002)(446003)(476003)(2351001)(956004)(86362001)(2616005)(2361001)(68736007)(6486002)(6512007)(59450400001)(478600001)(53936002); DIR:OUT; SFP:1101; SCL:1; SRVR:AM6PR04MB4213; H:b29396-OptiPlex-7040.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: =?us-ascii?Q?1; AM6PR04MB4213; 23:v6LBI6SDl2oibwxMlb/E7Sdxk1vTjEWD7mf403e5E?= =?us-ascii?Q?0JeLeFrtvTRxO5kraFC3UVYObKv5/MeJqpD6zkbcrRChcu4aHAosqNMS6za6?= =?us-ascii?Q?xnh6eA0wuoOPYvbghkH4UgG6GL5J3jmMeu8WRa2uWJVaVCnFbXHzaSoqp2jz?= =?us-ascii?Q?BQuGfjw8Rhq2MNlQrbOhEyhAOuM2JcD0FWIZGmm5SJJf4mrlm6rxqM2Vb2Ts?= =?us-ascii?Q?cH7qh82i+7aEHeFny/P2j8sahv4lS9TQwPyUrnVtXEIv+ZrNbP5WWuAQybYK?= =?us-ascii?Q?r2Jpc7qHbeNufOxhS17iXCJOeptHBLpHsDkqGFMFIc0TdpGVGPGeNCYxa7hp?= =?us-ascii?Q?O8dhG+Tz3PzR/rLUNCDN1+pg54aT9LgJMjUpgTVaFa+0ocDxFq9MCCQELKLu?= =?us-ascii?Q?Rar9U/iZeaI5HMi2JfR1E/A8s3/9Vk5ObJGSIxJgOlUT9BgrGoQMECpDBo9q?= =?us-ascii?Q?DM795CAu3KlLI4ldL03ykCRNKExhXDSolthcS36wolrQfQl9M1xiWau6zApd?= =?us-ascii?Q?7LCLhXA8krxg5kIwEZ5eLAtLiJH0P4kZULToVAd5LiWYWs1LGcM3G4qpfYfW?= =?us-ascii?Q?iUx7D2hYC3WRfUZWqi1JDV73b0Cji32YazF+Va8tY0EwU2ocMkD5jH4jlkON?= =?us-ascii?Q?EyG85JYrawSKFhZORQJK/bFcrRMbhAjThuUGv6vQ3E4zs5BEWaBK7e4WJ8mZ?= =?us-ascii?Q?/HRS2HSSIvVRU+83sE7eO8t+9CVq9N/oCPB1IEhZawblUfXLXrzBcl6QT/a8?= =?us-ascii?Q?Bs82DqplAyF7PUueUAVbshWOT+wzCjG/ouMASYmoLcsxD7DuyLixnUdm9zEM?= =?us-ascii?Q?I/tYqsFQsXKKGXg+zhGz2PagSNIArP8kA+dDx2e68nIQEnoJhd66z5jtzZQI?= =?us-ascii?Q?iblIuEk13pxSfXW3+PCOzfCKDw/VImLRfdBv+QAMMVK47AQdIeEB8EebfEmz?= =?us-ascii?Q?Jc08otYNTykn3foYSaR9LNAmGX8U8kWFoB4PiojTWkdrVQcCFAJ+3R9375au?= =?us-ascii?Q?mUVCpPtPFOsGbKek6YacK4DC30RnTXNbNs3zIve+ittKOmJyf+CmAo8NHAQX?= =?us-ascii?Q?oiw9l/ppG0p9hA0hH4sBkRpPFf57Fx1ocTB30brMdJWxaExp+/ISq4rRnTnc?= =?us-ascii?Q?kB/XZgC2HSpbX250aaw3ewEVqZBD9qTQEMLp8TXUhuLl98ScgHsYuOozwSBs?= =?us-ascii?Q?KaP00CLEMDngGKjRc1FTHk+jZdYMQ+ehwlnW7dQbIC8/FGI84VcVu6LLw=3D?= =?us-ascii?Q?=3D?= X-Microsoft-Antispam-Message-Info: oTqLh9v22rS0hnMEgsYQjIh4QnVE+hT0MAAN1qZJruNd+gYTRaAstLkg+aTCc0H85o1depnPjISD+jMNWx3OunVtCZI8qNoqFNqIZiv64LZ0nHdcSRXPbjgAPTCOlgZS6FCVgJl9LU/ACu7oKzM/qLUkNKMbNEb7AVBwz6oXN4D86SxS7ACe1qKN5lUnS/MQ X-Microsoft-Exchange-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U73Pbv4/mr0PW5tqwSmD/1594QbMuQS0cfqVbm0 X-MS-Office365-Filtering-Correlation-Id: dfea58d9-6840-4852-5bc5-08d5ac70bd76 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Apr 2018 18:57:31.9476 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dfea58d9-6840-4852-5bc5-08d5ac70bd76 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR04MB4213 Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add scu based clock gpr gate. Unlike the normal scu gate, such gates are controlled by GPR bits through SCU sc_misc_set_control API. Cc: Shawn Guo Cc: Sascha Hauer Cc: Fabio Estevam Cc: Stephen Boyd Cc: Michael Turquette Signed-off-by: Dong Aisheng --- drivers/clk/imx/scu/Makefile | 3 +- drivers/clk/imx/scu/clk-gate-gpr-scu.c | 84 ++++++++++++++++++++++++++++++++++ drivers/clk/imx/scu/clk-scu.h | 9 ++++ 3 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 drivers/clk/imx/scu/clk-gate-gpr-scu.c diff --git a/drivers/clk/imx/scu/Makefile b/drivers/clk/imx/scu/Makefile index 2abed17..25d3511 100644 --- a/drivers/clk/imx/scu/Makefile +++ b/drivers/clk/imx/scu/Makefile @@ -4,4 +4,5 @@ obj-$(CONFIG_MXC_CLK_SCU) += \ clk-scu.o \ clk-divider-scu.o \ clk-divider-gpr-scu.o \ - clk-gate-scu.o + clk-gate-scu.o \ + clk-gate-gpr-scu.o diff --git a/drivers/clk/imx/scu/clk-gate-gpr-scu.c b/drivers/clk/imx/scu/clk-gate-gpr-scu.c new file mode 100644 index 0000000..b55b857 --- /dev/null +++ b/drivers/clk/imx/scu/clk-gate-gpr-scu.c @@ -0,0 +1,84 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2016 Freescale Semiconductor, Inc. + * Copyright 2017~2018 NXP + * Dong Aisheng + */ + +#include +#include +#include +#include +#include + +#include "clk-scu.h" + +struct clk_gate_gpr_scu { + struct clk_hw hw; + sc_rsrc_t rsrc_id; + sc_ctrl_t gpr_id; + + /* default: enable 1 disable 0 */ + bool invert; +}; + +#define to_clk_gate_gpr_scu(_hw) container_of(_hw, struct clk_gate_gpr_scu, hw) + +static int clk_gate_gpr_scu_enable(struct clk_hw *hw) +{ + struct clk_gate_gpr_scu *gate = to_clk_gate_gpr_scu(hw); + + return sc_misc_set_control(ccm_ipc_handle, gate->rsrc_id, + gate->gpr_id, !gate->invert); +} + +static void clk_gate_gpr_scu_disable(struct clk_hw *hw) +{ + struct clk_gate_gpr_scu *gate = to_clk_gate_gpr_scu(hw); + sc_err_t sci_err; + + sci_err = sc_misc_set_control(ccm_ipc_handle, gate->rsrc_id, + gate->gpr_id, gate->invert); + if (sci_err) + pr_warn("%s: %s: clk disable failed %d\n", + __func__, clk_hw_get_name(hw), sci_err); +} + +static const struct clk_ops clk_gate_gpr_scu_ops = { + .enable = clk_gate_gpr_scu_enable, + .disable = clk_gate_gpr_scu_disable, +}; + +struct clk_hw *clk_register_gate_gpr_scu(const char *name, const char *parent_name, + sc_rsrc_t rsrc_id, sc_ctrl_t gpr_id, + bool invert_flag) +{ + struct clk_gate_gpr_scu *gate; + struct clk_init_data init; + struct clk_hw *hw; + int ret; + + gate = kzalloc(sizeof(*gate), GFP_KERNEL); + if (!gate) + return ERR_PTR(-ENOMEM); + + gate->rsrc_id = rsrc_id; + gate->gpr_id = gpr_id; + gate->invert = invert_flag; + + init.name = name; + init.ops = &clk_gate_gpr_scu_ops; + init.parent_names = parent_name ? &parent_name : NULL; + init.num_parents = parent_name ? 1 : 0; + + gate->hw.init = &init; + + hw = &gate->hw; + ret = clk_hw_register(NULL, hw); + if (ret) { + kfree(gate); + hw = ERR_PTR(ret); + } + + return hw; +} diff --git a/drivers/clk/imx/scu/clk-scu.h b/drivers/clk/imx/scu/clk-scu.h index c08dca1..e419035 100644 --- a/drivers/clk/imx/scu/clk-scu.h +++ b/drivers/clk/imx/scu/clk-scu.h @@ -59,4 +59,13 @@ static inline struct clk_hw *imx_clk_gate2_scu(const char *name, const char *par return clk_register_gate2_scu(name, parent, 0, reg, bit_idx, hw_gate); } +struct clk_hw *clk_register_gate_gpr_scu(const char *name, const char *parent_name, + sc_rsrc_t rsrc_id, sc_ctrl_t gpr_id, bool invert_flag); + +static inline struct clk_hw *imx_clk_gate_gpr_scu(const char *name, const char *parent, + sc_rsrc_t rsrc_id, sc_ctrl_t gpr_id, bool invert_flag) +{ + return clk_register_gate_gpr_scu(name, parent, rsrc_id, gpr_id, invert_flag); +} + #endif