From patchwork Wed Mar 22 16:53:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonard Crestez X-Patchwork-Id: 9639465 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 A2824601E9 for ; Wed, 22 Mar 2017 17:01:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 945B628474 for ; Wed, 22 Mar 2017 17:01:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 88BFC28477; Wed, 22 Mar 2017 17:01:31 +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=-1.9 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D5DC428474 for ; Wed, 22 Mar 2017 17:01:30 +0000 (UTC) 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:References:In-Reply-To: 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=1O7C7xmhrtgCWO55gNOAon7ziyjZBiUQLjEMF/GvCoU=; b=T0GwFZFi+I7JLI 1eM261SqemWHNCvuKjQSvxEdrRA0EbONxZgzfDNEplMopKcCmWbvpChpQde3fQo7wVWKKNpvnfXtL UmWACyWKGlsj+JYpEn95rmbiUV3m5v2lEhDHJ73x2qXR70Ejc39AkFps/csA4vsgHcVmT9A/B51Nq ZCX/eckSdxlzQrM/2x3VltAupZalHkuT6QlebcrzH6NQKYiAE7AFdHPMZ0Jh1IXu0emzKQ6P9KZnP MyoSsxA1lu2yi2ceh03rWUaumr88kBxWdKpTJ8oBJbSoFiSBTkm69Z0FxYCXdjfE9gbhaTlYWG70A 17ueiZZGZI0SznbrkJOg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cqjdX-0000pM-RF; Wed, 22 Mar 2017 17:01:27 +0000 Received: from mail-co1nam03on0626.outbound.protection.outlook.com ([2a01:111:f400:fe48::626] helo=NAM03-CO1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cqjWY-0002vq-Iv for linux-arm-kernel@lists.infradead.org; Wed, 22 Mar 2017 16:54:21 +0000 Received: from BN3PR0301CA0011.namprd03.prod.outlook.com (10.160.180.149) by BN6PR03MB2785.namprd03.prod.outlook.com (10.173.144.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.947.12; Wed, 22 Mar 2017 16:53:52 +0000 Received: from BN1AFFO11FD036.protection.gbl (2a01:111:f400:7c10::185) by BN3PR0301CA0011.outlook.office365.com (2a01:111:e400:4000::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.991.14 via Frontend Transport; Wed, 22 Mar 2017 16:53:53 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=fail action=none header.from=nxp.com; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BN1AFFO11FD036.mail.protection.outlook.com (10.58.52.240) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.977.7 via Frontend Transport; Wed, 22 Mar 2017 16:53:52 +0000 Received: from fsr-ub1664-115.ea.freescale.net (fsr-ub1664-115.ea.freescale.net [10.171.73.212]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id v2MGrKXf024800; Wed, 22 Mar 2017 09:53:48 -0700 From: Leonard Crestez To: Mark Brown , Liam Girdwood , Viresh Kumar , "Rafael J. Wysocki" , Shawn Guo , Sascha Hauer Subject: [RFC 7/8] cpufreq: imx6q: Initialize LDO bypass Date: Wed, 22 Mar 2017 18:53:09 +0200 Message-ID: <75ec3ea8fe812b4cf689e0c130358e81aa7fbd13.1490199005.git.leonard.crestez@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: X-EOPAttributedMessage: 0 X-Matching-Connectors: 131346752327610388; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(336005)(39450400003)(39840400002)(39860400002)(39380400002)(39850400002)(39400400002)(39410400002)(2980300002)(1109001)(1110001)(339900001)(199003)(189002)(9170700003)(39060400002)(104016004)(38730400002)(85426001)(356003)(105606002)(5003940100001)(305945005)(81166006)(2906002)(2950100002)(5660300001)(106466001)(6666003)(7416002)(118296001)(36756003)(4326008)(8656002)(53936002)(54906002)(33646002)(575784001)(8676002)(86362001)(50226002)(8936002)(47776003)(50466002)(48376002)(77096006)(50986999)(76176999)(189998001)(32563001); DIR:OUT; SFP:1101; SCL:1; SRVR:BN6PR03MB2785; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; MLV:ovrnspm; A:1; MX:1; PTR:InfoDomainNonexistent; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11FD036; 1:9vng6KRur7bDIldMRhz4A+KKclAuUr49EBeqbrq3IOMOL3efahKAu0HnPfIL6lLwjrRSBJYJoa86W/tlJZ/WjLOURMFZ/6fDidPGA8lSUG+vAUU0M1V9v7vGFYoaO4r7liIipN27s5rdxVO+A10nPJLvdwhuFJ2bWijIDeeE7+AvwJ8KTFEy06uX+I6w8UdQ8Ux2eZTJNzT+FMzzKOOrVwyJh4p4xsHmXhM+5jeMBRMa4x88ZMQ0AFTZ8mBtnz8FULOqdVEtWetefMnyrIEU68iMqvrUPGrAmHcy6ppy/eRBTTWhDW3jNPQ3BIcnZjsEWE2c3bBGHe4kUYC9vfWt86YuwyEcQaxSkWcAjQs6y/c+P6cSHU7EzFCD2kpK6hJbrU7+smmNbhnIBrMKqnJTC5d3O9T2ypAqV78VMORW9fcA9RXEjZZBb1wh1N7EaCLbKDBsnmdphlfgf81k0Zryl5J3DJx2UfilnOyw72jGmCc4lVkWwikj2yqSBQrDVEXeHvC5/qaH/wvUiRLm46ISlJWSWrH+9sYbS4EWhU/T+ePnv8YAcohAh/zl05XNkb9DwknsXaVN+4hYTlVL+sSaJHHMmdaKpQDH9y0JMo4WJ6u5y1tUlyohyBOLAt7WIkeH MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: b91556e6-a679-4c79-0eb2-08d471440558 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:BN6PR03MB2785; X-Microsoft-Exchange-Diagnostics: 1; BN6PR03MB2785; 3:8dGPon6eozCEfuBnLFSL5vsYcUIgW1uZ23o4ZxfCX64xrDTpqCJJuBrNCFJtOdp/7au66Qwzue+EhHEMvWZUpSxv2EPcuSUaAVnJ2mJxZJlHAZpPEp2O8WgzlSXod8clqpIJ2v08nqJEXRwyOV9uU1koSjFAWkvgXBRVw+Z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-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6095060)(601004)(2401047)(13024025)(13023025)(13017025)(13018025)(13015025)(8121501046)(5005006)(10201501046)(3002001)(6055026)(6096035)(20161123561025)(20161123563025)(20161123565025)(20161123559025)(20161123556025); SRVR:BN6PR03MB2785; BCL:0; PCL:0; RULEID:(400006); SRVR:BN6PR03MB2785; X-Microsoft-Exchange-Diagnostics: 1; BN6PR03MB2785; 4:Zk70N0D8J8dO2H+cVk08xCpXqMlM59YgiyqzIBnVXamp/cBovYBu7leTMxBX7oRVbkneCsbSpU/UQow5E3Sz19xO5+BTucCIT1EEvC9NhkdG66Z5ryMK+6PPArtQQqhgTNJcv303WhyTxTUTObi1Acn0R4vF6ouDO8kGxJOfnw0xYkQJptZUpS7Y3WybXvDnk+9cJ8OHOi9ZCE8ZaTORyMsHwKi6rYlr3ao5Gi5Mm1C2i28Vhsj6lj6gZvKx7rRuQfQXBhh/SsKs/8mRqWaUaEu8fCtuCDtRYWTVA4YPU4a6p7/knYPvLGScq1w8cnHHMZj4RBa5zlff8EFuC44+RdhkHO7fl977xkSYtqWyjTYLHsXe1viv/YAWTD9jf/sYwXkhXW0k4EKtlXodPe60rBvcbtqNHptIJ7PWC05SLKr6d6t6/opdnmIeaKR4FStE8bVilUxNn+uLMyAvUfIlwe+pxhgN8SRRypu0pvEKiFfVW+NZmzxS33UBxJV+4h1WUCljAOUbO6XMkC4HCJYKmbdxs6Epyy1uw+pipLPwO+irucg0h+FwSOjnIeW8jmaKiQ8HtnBlNuqhhW73wJPk2etVCyeP/EleZYcjaQL7Rgai89zGbeaOTy6NAmJPGeYt6r5GSI7K6BUKaPJpbFeMPgRh/3gTg4MRZFtnRmcfwYQ9+dsC+XccHgN9NuXmHHECUPuaW2VXb4K6ispciiYUFO0EYqskSxFDBfUkLYXbyWPIDQB2MO839WIKkgO2q55n X-Forefront-PRVS: 02543CD7CD X-Microsoft-Exchange-Diagnostics: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0SDkb3MeUouFf1NN3ICRQHD6WfR6l9XZOHuZdyC+gTskNpiE9US5R7iJjJcg+g/kinFm362/LuHhSuyXdkBSKS47Hd+N0tN6; 24:k7YLL3m+EEnI7oLwghq3szvqUTdrB9FxQv//mGOjmE6PbSxGXI273RAlS/aqrB1kv2iTMo0MTM2UlUXDVkGy8cxHeFAAH9+hpi/E+85I6Ao= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BN6PR03MB2785; 7:GVZfO4QCQ6n4xyEe40TBJCVPcgMEE7mslsiqPmALv4eTiL8rjbnL2yJpd8PrhuAUiXepLrvc2W5JimNEPzu2+HASMXzr+G2ZN9vLJyi5cTSm86ef6HKOq5DXFnror3rqc2zHrpu7KHVMb6XDouj70lBuuSfHED2mnhutcfcF2MRq7UjyPDrs4eqdCuNEox7ke0Gnu2hw/tQdgl1WWD6vBJJ0D+JB1ain1oYmln2P1b9A5sz9+We1xf83GLk+tk3lCLp0O9x0FdTDYx6tmSW9MxtzZS+Fb20sKsD3eMBGy9ujlcy93hKndRuQXXVpqg+Z2AvwRSsK06E+Xhdt60Ss7A== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Mar 2017 16:53:52.4802 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR03MB2785 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170322_095414_975504_DCF249BB X-CRM114-Status: GOOD ( 23.31 ) 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: Mark Rutland , devicetree@vger.kernel.org, Leonard Crestez , Anson Huang , Irina Tirdea , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Rob Herring , Octavian Purdila , Fabio Estevam , Robin Gong , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Several imx6* socs have three built-in regulators LDO_ARM LDO_SOC and LDO_PU used to control internal chip voltages. "ldo-bypass" mode refers to placing these regulators in bypass mode and controlling voltages from an external power management chip instead. This is intended to save power at the expense of an extra PMIC on the board. The voltages for these regulators are controlled from the imxq6 cpufreq driver so it makes sense to also control LDO bypass from here. The gpc driver also fetches a reference to LDO_PU and uses it to gate power to graphics blocks. The LDO regulator has a minimum dropout voltage of 125mv so enabling bypass mode will raise the effective voltage by that amount. We need set the minimum frequency first to avoid overvolting when enabling LDO bypass. The binding is an u32 fsl,ldo-bypass in the gpc node because that's how it was defined in the freescale vendor tree for a long time and compatibility is desirable. Otherwise it would be a bool. Some versions of u-boot shipped by freescale check this same property and set regulators in bypass mode before linux actually starts so we check for that scenario as well and finish early. Signed-off-by: Leonard Crestez --- .../devicetree/bindings/power/fsl,imx-gpc.txt | 4 + arch/arm/mach-imx/gpc.c | 7 + drivers/cpufreq/imx6q-cpufreq.c | 171 +++++++++++++++++++++ 3 files changed, 182 insertions(+) diff --git a/Documentation/devicetree/bindings/power/fsl,imx-gpc.txt b/Documentation/devicetree/bindings/power/fsl,imx-gpc.txt index 65cc034..8a7584b 100644 --- a/Documentation/devicetree/bindings/power/fsl,imx-gpc.txt +++ b/Documentation/devicetree/bindings/power/fsl,imx-gpc.txt @@ -11,6 +11,10 @@ Required properties: datasheet - interrupts: Should contain GPC interrupt request 1 - pu-supply: Link to the LDO regulator powering the PU power domain +- fsl,ldo-bypass: Should be 0 or 1 to enable LDO bypass mode (default 0). + This is performed in cooperation with cpufreq. Some versions of uboot will + also look at this property and set the arm and soc regulators in bypass mode + before linux. - clocks: Clock phandles to devices in the PU power domain that need to be enabled during domain power-up for reset propagation. - #power-domain-cells: Should be 1, see below: diff --git a/arch/arm/mach-imx/gpc.c b/arch/arm/mach-imx/gpc.c index ce64d11..62a2555 100644 --- a/arch/arm/mach-imx/gpc.c +++ b/arch/arm/mach-imx/gpc.c @@ -22,6 +22,7 @@ #include #include #include +#include #include "common.h" #include "hardware.h" @@ -461,6 +462,12 @@ static int imx_gpc_probe(struct platform_device *pdev) if (!of_property_read_bool(pdev->dev.of_node, "#power-domain-cells")) return 0; + /* wait for cpufreq to initialize before using pu_reg */ + if (IS_ENABLED(CONFIG_ARM_IMX6Q_CPUFREQ) && cpufreq_get_current_driver() == NULL) { + dev_dbg(&pdev->dev, "cpufreq driver not ready, retry\n"); + return -EPROBE_DEFER; + } + pu_reg = devm_regulator_get_optional(&pdev->dev, "pu"); if (PTR_ERR(pu_reg) == -ENODEV) pu_reg = NULL; diff --git a/drivers/cpufreq/imx6q-cpufreq.c b/drivers/cpufreq/imx6q-cpufreq.c index e2c1fbf..a0c11ed 100644 --- a/drivers/cpufreq/imx6q-cpufreq.c +++ b/drivers/cpufreq/imx6q-cpufreq.c @@ -159,8 +159,179 @@ static int imx6q_set_target(struct cpufreq_policy *policy, unsigned int index) return 0; } +/* + * Enable ldo-bypass mode if configured and not already performed by u-boot + */ +static int imx6q_cpufreq_init_ldo_bypass(void) +{ + struct device_node *gpc_node; + unsigned long old_freq_hz; + int i, old_freq_index; + u32 bypass = 0; + int ret = 0, ret2; + + /* Read ldo-bypass property */ + gpc_node = of_find_compatible_node(NULL, NULL, "fsl,imx6q-gpc"); + if (!gpc_node) + return 0; + ret = of_property_read_u32(gpc_node, "fsl,ldo-bypass", &bypass); + if (ret && ret != -EINVAL) + dev_warn(cpu_dev, "failed reading fsl,ldo-bypass property: %d\n", ret); + if (!bypass) + goto out; + + /* + * Freescale u-boot handles ldo-bypass by setting + * arm/soc in bypass and vddpu disabled. + * + * If this is the case we don't need any special freq lowering. + */ + if (regulator_is_bypass(arm_reg) == 1 && + regulator_is_bypass(soc_reg) == 1) + { + dev_info(cpu_dev, "vddarm and vddsoc already in bypass\n"); + if (IS_ERR(pu_reg)) { + ret = 0; + goto out; + } else if (regulator_is_enabled(pu_reg) == 0) { + ret = regulator_allow_bypass(pu_reg, true); + if (ret) { + dev_err(cpu_dev, "failed to enable vddpu bypass: %d\n", ret); + goto out; + } + ret = regulator_is_bypass(pu_reg); + if (ret != 1) { + ret = -EINVAL; + dev_err(cpu_dev, "failed bypass check for vddpu: %d\n", ret); + goto out; + } + ret = 0; + goto out; + } else if (regulator_is_bypass(pu_reg) == 1) { + dev_info(cpu_dev, "vddpu also already in bypass\n"); + ret = 0; + goto out; + } else + dev_info(cpu_dev, "Need frequency lowering to set vddpu in bypass\n"); + } + + /* + * Enable LDO bypass from kernel. + * + * The LDO regulator has a minimum dropout voltage of 125mv so enabling + * bypass mode will raise the effective voltage by that amount. + * + * We set the minimum frequency first to avoid overvolting. + */ + + /* Find current freq so we can restore it. */ + old_freq_hz = clk_get_rate(arm_clk); + if (!old_freq_hz) { + dev_err(cpu_dev, "failed to determine current arm freq\n"); + goto out; + } + old_freq_index = 0; + for (i = 1; i < soc_opp_count; ++i) { + if (abs(freq_table[old_freq_index].frequency - old_freq_hz) > + abs(freq_table[i].frequency - old_freq_hz)) { + old_freq_index = i; + } + } + dev_dbg(cpu_dev, "current freq %lu Mhz index %d\n", + old_freq_hz / 1000000, old_freq_index); + + dev_info(cpu_dev, "enabling ldo_bypass\n"); + ret = imx6q_set_target(NULL, 0); + if (ret) { + dev_warn(cpu_dev, "Failed to lower frequency: %d\n", ret); + goto out; + } + + ret = regulator_allow_bypass(arm_reg, true); + if (ret) { + dev_err(cpu_dev, "failed to enable bypass for vddarm: %d\n", ret); + goto out_restore_cpufreq; + } + ret = regulator_allow_bypass(soc_reg, true); + if (ret) { + dev_err(cpu_dev, "failed to enable bypass for vddsoc: %d\n", ret); + goto out_restore_arm_reg; + } + if (!IS_ERR(pu_reg)) { + ret = regulator_allow_bypass(pu_reg, true); + if (ret) { + dev_err(cpu_dev, "failed to enable bypass for vddsoc: %d\n", ret); + goto out_restore_soc_reg; + } + } + + /* + * We need to do get_bypass afterwards because allow_bypass does not + * actually guarantee bypass mode was entered if it returns 0. In + * theory there might be another used. + */ + ret = regulator_is_bypass(arm_reg); + if (ret != 1) { + ret = -EINVAL; + dev_err(cpu_dev, "failed bypass check for vddarm: %d\n", ret); + goto out_restore_pu_reg; + } + ret = regulator_is_bypass(soc_reg); + if (ret != 1) { + ret = -EINVAL; + dev_err(cpu_dev, "failed bypass check for vddsoc: %d\n", ret); + goto out_restore_pu_reg; + } + if (!IS_ERR(pu_reg)) { + ret = regulator_is_bypass(pu_reg); + if (ret != 1) { + ret = -EINVAL; + dev_err(cpu_dev, "failed bypass check for vddpu: %d\n", ret); + goto out_restore_pu_reg; + } + } + + ret = imx6q_set_target(NULL, old_freq_index); + if (ret) + dev_warn(cpu_dev, "Failed to restore frequency: %d\n", ret); + /* Success! */ + ret = 0; + goto out; + +out_restore_pu_reg: + if (!IS_ERR(pu_reg)) { + ret2 = regulator_allow_bypass(pu_reg, false); + if (ret2) + dev_err(cpu_dev, "failed to restore vddpu: %d\n", ret2); + } +out_restore_arm_reg: + ret2 = regulator_allow_bypass(arm_reg, false); + if (ret2) + dev_err(cpu_dev, "failed to restore vddarm: %d\n", ret2); +out_restore_soc_reg: + ret2 = regulator_allow_bypass(soc_reg, false); + if (ret2) + dev_err(cpu_dev, "failed to restore vddsoc: %d\n", ret2); +out_restore_cpufreq: + ret2 = imx6q_set_target(NULL, old_freq_index); + if (ret2) + dev_warn(cpu_dev, "Failed to restore frequency: %d\n", ret2); + +out: + of_node_put(gpc_node); + return ret; +} + static int imx6q_cpufreq_init(struct cpufreq_policy *policy) { + int ret; + + ret = imx6q_cpufreq_init_ldo_bypass(); + if (ret) { + dev_err(cpu_dev, "failed to enable ldo_bypass: %d\n", ret); + return ret; + } + policy->clk = arm_clk; policy->suspend_freq = freq_table[soc_opp_count - 1].frequency; return cpufreq_generic_init(policy, freq_table, transition_latency);