From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=BAD_ENC_HEADER,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9659DC43381 for ; Tue, 26 Feb 2019 05:18:00 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6329F213A2 for ; Tue, 26 Feb 2019 05:18:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="OMis4AF1"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="Bm2bgd4f" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6329F213A2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nxp.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:In-Reply-To:References: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=V9fnVtyD1hpxb8ZhTEAaKMe7x6oG7/dRz8DnWwEGvYU=; b=OMis4AF1evuiM6 wNkaCMJALBNq+dsDpon1TNSIf0hacgkGDOJ7J0fFUyR65RO986N6ERw50Z/QfBhoRseZMdtQGHlMT 5zFsIbyzsL3PlV6oxnH7f0svJwaw2xaaQzWuuIXsvTN2fJsgpwhU61ZDxvA1x3g2BmCaybYQkUhQ7 M2BG77o2VSp4EpJmtrnq4j/tnkWxoNU6Nr8P0g8Q1Ol81D9Zf7tHvpS/h9do4r1Tf6a//7UA2DRR7 zLVaO0s3i4PR4c6sNAXy13Ei3aQKfzd9ccJB1HuWtU/CKRVffSkylMK9BwMqIycwBgR7p2aXuRzHF NTOIC6/8oQ5jDFVb+i/Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gyV7o-0005bL-Sv; Tue, 26 Feb 2019 05:17:52 +0000 Received: from mail-eopbgr60065.outbound.protection.outlook.com ([40.107.6.65] helo=EUR04-DB3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gyV7e-0005PJ-5A for linux-arm-kernel@lists.infradead.org; Tue, 26 Feb 2019 05:17:43 +0000 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=kdG4fpdIqcF7kNKFaEbKoo9Qzhi8tF1AwxgmkSX7Wj0=; b=Bm2bgd4fgJX9LbTUKd0CayzevDSPwYZ854JsufOqLsq++S2f5b01+X8HkZfs3u9vXKRbg7iVJgTlBDX52FlKgcnlURzjMVRamASRo3kB/DCuYAtk0T1JwST6wAt84iNYTnJNeBzsTBGdgD+aJ7+EZAul860z15EwTKcitWjUPfo= Received: from DB3PR0402MB3916.eurprd04.prod.outlook.com (52.134.72.18) by DB3PR0402MB3849.eurprd04.prod.outlook.com (52.134.71.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1643.18; Tue, 26 Feb 2019 05:17:36 +0000 Received: from DB3PR0402MB3916.eurprd04.prod.outlook.com ([fe80::1cb4:3e1c:fc85:7ed7]) by DB3PR0402MB3916.eurprd04.prod.outlook.com ([fe80::1cb4:3e1c:fc85:7ed7%2]) with mapi id 15.20.1643.019; Tue, 26 Feb 2019 05:17:36 +0000 From: Anson Huang To: "robh+dt@kernel.org" , "mark.rutland@arm.com" , "shawnguo@kernel.org" , "s.hauer@pengutronix.de" , "kernel@pengutronix.de" , "festevam@gmail.com" , "mturquette@baylibre.com" , "sboyd@kernel.org" , Aisheng Dong , Daniel Baluta , "devicetree@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , "linux-clk@vger.kernel.org" Subject: [PATCH V7 2/2] clk: imx: scu: add cpu frequency scaling support Thread-Topic: [PATCH V7 2/2] clk: imx: scu: add cpu frequency scaling support Thread-Index: AQHUzZKWDxpx7VRUrEmeH+eTWwjydA== Date: Tue, 26 Feb 2019 05:17:36 +0000 Message-ID: <1551157967-30925-2-git-send-email-Anson.Huang@nxp.com> References: <1551157967-30925-1-git-send-email-Anson.Huang@nxp.com> In-Reply-To: <1551157967-30925-1-git-send-email-Anson.Huang@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.7.4 x-clientproxiedby: HK2PR0302CA0006.apcprd03.prod.outlook.com (2603:1096:202::16) To DB3PR0402MB3916.eurprd04.prod.outlook.com (2603:10a6:8:10::18) authentication-results: spf=none (sender IP is ) smtp.mailfrom=anson.huang@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [119.31.174.66] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: fce1026b-800d-4c4f-cff1-08d69ba9b86b x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(4618075)(2017052603328)(7153060)(7193020); SRVR:DB3PR0402MB3849; x-ms-traffictypediagnostic: DB3PR0402MB3849: x-microsoft-exchange-diagnostics: =?iso-8859-1?Q?1; DB3PR0402MB3849; 23:C3GI9+8qGDAvbm1dRcPq13fUD4xJypsmsym1l?= =?iso-8859-1?Q?Dgs4O3iLfbEvUL0fjRLQbcmmFV2VTusIsg7dsbwT/D9WMLZB0/kVqzM7gu?= =?iso-8859-1?Q?AcPMUqyM5u7qZHSqnGEvB7VJGnXnzvUps90hFrAFENSWp0MrSSfnw4ThHh?= =?iso-8859-1?Q?qRTkS29VjX157KDq8xPYjjSc3HxabGgFAXCxwpgWo7AisN2oWYdNLwMg90?= =?iso-8859-1?Q?aBtY3EXGr3nxfnpGDRgXngJmPTabGqZ7Ch4vTk4nIqdihrxP7IVFNZPTDs?= =?iso-8859-1?Q?9ygRaHVk+wMUQZVUDtNeJor0seGG7kNLuSequwzxq8taPD0EvQfkAeUsS0?= =?iso-8859-1?Q?bXSnCdcuo886ynvKUkQfdoN/TFNI4JupacOVeLLx/NoP1FUV2LAhiY6/NZ?= =?iso-8859-1?Q?VIqOwRTBztemQOnDafGV9+7NsumLn7TMj1N+HImGz5hwt4k6Qcdvj9HOzi?= =?iso-8859-1?Q?3LcOPx0ryiPGo53NJlNRyLV1x/x4u2+FF3GlBIR83pThW2jNtItekm4waP?= =?iso-8859-1?Q?1wv4J1svlzubsNZhZJDXIUhrpL/m6I1+IoQe2LaBsWP6M32jfpUxbnEgHB?= =?iso-8859-1?Q?rDrCFC5cR+Kq+rKcRn/hNeDouJYTIIcsVYzKgsUCqXCekdtCO3CudWvGPx?= =?iso-8859-1?Q?BbnalpZYGHStHFKOggRuB72AvD6IAJOlKyVIwfM0nRqHomtCjB6ucOHlDl?= =?iso-8859-1?Q?UMXkIgexGFIEdMV5aLhpfhyYX1GkXZjETEvRcOp/vaf8AqmdLt52Qosy66?= =?iso-8859-1?Q?ZVIdwbXAnngU4X+qAW6KnbkiTdAEf1JgupGqKKXr3APyqwkOhMYzTmy1Om?= =?iso-8859-1?Q?P0kVEfnjJTIPxIkP0rxXszJPZgYLA5J38LmrbbJQtQ0nEx/R21uuv7p/A6?= =?iso-8859-1?Q?NFHby+UQgZsmET2YYzT4tDMfkDXm7Y/sKuabfjANR7ca4y3ETVV2hU3HsV?= =?iso-8859-1?Q?PKZqj2HX3IKSwyJP7dKcTyEBpBeJK0KHHXfhWV2yFCXAAnjG4sq+GlEeOa?= =?iso-8859-1?Q?xjiedWByWaBUpG3FodFhRB4b8K3Da7fIcghXAuAD5u2m7Cv8kFAh1s2jtm?= =?iso-8859-1?Q?OK8f41xyFmHvJs67ST3OJRXtN8s7L59m/3tBCCvMGpzuQ5lEVOdZ8Db2MZ?= =?iso-8859-1?Q?atNpyos/jBWcbB/YGnvO8WLirM6xDage0BN0DPbAk8exgM33Dvjac7GogE?= =?iso-8859-1?Q?tELFrkHMWFbJ0uEEoD7HfuiEId6IDK6b8VSff6vlK8UQv08XAstWux4PSd?= =?iso-8859-1?Q?ZSfWMGVcZedy15xHsVJdBL6hvZ0C+w9t/k1YDqT1VrVzQq760KA0OcKz00?= =?iso-8859-1?Q?oSjkORWq4NXLlbqqSj/aEtPuu?= x-microsoft-antispam-prvs: x-forefront-prvs: 096029FF66 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(136003)(346002)(376002)(396003)(39860400002)(366004)(199004)(189003)(6512007)(476003)(6486002)(186003)(2616005)(102836004)(26005)(76176011)(52116002)(4326008)(446003)(2501003)(86362001)(14454004)(11346002)(81166006)(6436002)(8676002)(81156014)(305945005)(2201001)(5660300002)(106356001)(97736004)(71200400001)(71190400001)(7736002)(105586002)(8936002)(486006)(7416002)(110136005)(99286004)(50226002)(36756003)(66066001)(68736007)(386003)(6506007)(478600001)(3846002)(6116002)(53936002)(14444005)(256004)(316002)(25786009)(2906002)(921003)(1121003); DIR:OUT; SFP:1101; SCL:1; SRVR:DB3PR0402MB3849; H:DB3PR0402MB3916.eurprd04.prod.outlook.com; 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-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: jRhZHiVdPNmhKA1SNHTxRjsb70N4mhuC3cOqDZUuWsHfsP+lhru6F6Z7jYp+2KKU/3P+BAfRwC+TlT/CeQ9IaTUZd2YNBjZ1p/CnOWq2iZHOamhBrr9ijUEGIaR+BfVYPb5Zl+agm8Ziq6b0q5m00enjM79qMDhhu3rjdJJVP/TcZ3xHt1kYq7b7P5PZLYjjqx7amxXtpDFGK3hNkDKcF6nhd2Ih+eZUSntl5xmF6xCY41FfZ+0+h4uD+Ml9QTZL4I3ZH2pVLvqCLFgOY0+O4K179xI5guSJdVPPchzBQfQqQ8chmdzwC/fRU0CCx4VnfPe9o8JmUIZ6bKCaJLwgSz77JL6b6XV1fARUsWJLp4PejeLEq/XbcRBRVME0QEXkUelWjfw5CNK+23LkgjJ+4ZGahh9z0sIDExot+MxyCUo= MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: fce1026b-800d-4c4f-cff1-08d69ba9b86b X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Feb 2019 05:17:31.9544 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3PR0402MB3849 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190225_211742_194870_764A91A7 X-CRM114-Status: GOOD ( 14.76 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dl-linux-imx Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On NXP's i.MX SoCs with system controller inside, CPU frequency scaling can ONLY be done by system controller firmware, and it can ONLY be requested from secure mode, so Linux kernel has to call ARM SMC to trap to ARM-Trusted-Firmware to request system controller firmware to do CPU frequency scaling. This patch adds i.MX system controller CPU frequency scaling support, it reuses cpufreq-dt driver and implement the CPU frequency scaling inside SCU clock driver. Signed-off-by: Anson Huang --- Changes since V6: - add return fail to clk_scu_atf_set_cpu_rate() when the resource ID is NOT expected, this is to avoid warning of uninitialized data usage. --- drivers/clk/imx/clk-scu.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/drivers/clk/imx/clk-scu.c b/drivers/clk/imx/clk-scu.c index f460526..fbef740 100644 --- a/drivers/clk/imx/clk-scu.c +++ b/drivers/clk/imx/clk-scu.c @@ -4,12 +4,17 @@ * Dong Aisheng */ +#include +#include #include #include #include #include "clk-scu.h" +#define IMX_SIP_CPUFREQ 0xC2000001 +#define IMX_SIP_SET_CPUFREQ 0x00 + static struct imx_sc_ipc *ccm_ipc_handle; /* @@ -180,6 +185,25 @@ static long clk_scu_round_rate(struct clk_hw *hw, unsigned long rate, return rate; } +static int clk_scu_atf_set_cpu_rate(struct clk_hw *hw, unsigned long rate, + unsigned long parent_rate) +{ + struct clk_scu *clk = to_clk_scu(hw); + struct arm_smccc_res res; + unsigned long cluster_id; + + if (clk->rsrc_id == IMX_SC_R_A35) + cluster_id = 0; + else + return -EINVAL; + + /* CPU frequency scaling can ONLY be done by ARM-Trusted-Firmware */ + arm_smccc_smc(IMX_SIP_CPUFREQ, IMX_SIP_SET_CPUFREQ, + cluster_id, rate, 0, 0, 0, 0, &res); + + return 0; +} + /* * clk_scu_set_rate - Set rate for a SCU clock * @hw: clock to change rate for @@ -312,6 +336,14 @@ static const struct clk_ops clk_scu_ops = { .unprepare = clk_scu_unprepare, }; +static const struct clk_ops clk_scu_cpu_ops = { + .recalc_rate = clk_scu_recalc_rate, + .round_rate = clk_scu_round_rate, + .set_rate = clk_scu_atf_set_cpu_rate, + .prepare = clk_scu_prepare, + .unprepare = clk_scu_unprepare, +}; + struct clk_hw *__imx_clk_scu(const char *name, const char * const *parents, int num_parents, u32 rsrc_id, u8 clk_type) { @@ -329,6 +361,10 @@ struct clk_hw *__imx_clk_scu(const char *name, const char * const *parents, init.name = name; init.ops = &clk_scu_ops; + if (rsrc_id == IMX_SC_R_A35) + init.ops = &clk_scu_cpu_ops; + else + init.ops = &clk_scu_ops; init.parent_names = parents; init.num_parents = num_parents; -- 2.7.4 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel