From patchwork Fri Sep 11 15:41:05 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bai Ping X-Patchwork-Id: 7158041 X-Patchwork-Delegate: rjw@sisk.pl Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D178A9F314 for ; Fri, 11 Sep 2015 07:37:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DA62020838 for ; Fri, 11 Sep 2015 07:37:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BAA6D2055B for ; Fri, 11 Sep 2015 07:37:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751514AbbIKHhn (ORCPT ); Fri, 11 Sep 2015 03:37:43 -0400 Received: from mail-bn1bn0108.outbound.protection.outlook.com ([157.56.110.108]:15968 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751296AbbIKHhl (ORCPT ); Fri, 11 Sep 2015 03:37:41 -0400 Received: from BLUPR03CA003.namprd03.prod.outlook.com (10.255.124.20) by BLUPR03MB487.namprd03.prod.outlook.com (10.141.79.27) with Microsoft SMTP Server (TLS) id 15.1.262.15; Fri, 11 Sep 2015 07:37:39 +0000 Received: from BN1BFFO11FD048.protection.gbl (10.255.124.4) by BLUPR03CA003.outlook.office365.com (10.255.124.20) with Microsoft SMTP Server (TLS) id 15.1.268.17 via Frontend Transport; Fri, 11 Sep 2015 07:37:39 +0000 Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=freescale.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=freescale.com; Received-SPF: Fail (protection.outlook.com: domain of freescale.com does not designate 192.88.158.2 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.158.2; helo=az84smr01.freescale.net; Received: from az84smr01.freescale.net (192.88.158.2) by BN1BFFO11FD048.mail.protection.outlook.com (10.58.145.3) with Microsoft SMTP Server (TLS) id 15.1.262.18 via Frontend Transport; Fri, 11 Sep 2015 07:37:39 +0000 Received: from b51503-01.ap.freescale.net (b51503-01.ap.freescale.net [10.193.102.227]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id t8B7bZSd021155; Fri, 11 Sep 2015 00:37:36 -0700 From: Bai Ping To: CC: , , Subject: [PATCH v2] cpufreq: imx: update the clock switch flow to support imx6ul Date: Fri, 11 Sep 2015 23:41:05 +0800 Message-ID: <1441986065-8821-1-git-send-email-b51503@freescale.com> X-Mailer: git-send-email 1.9.1 X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD048; 1:CHadrjsITrHtdYWejwb/DdNHFdf/Ng9YHQt9cUDu6NA09J7dYfiptTnbyNoHW0jpIbczigSrC7EHPncvqwXxDnYgOMQgXidZdhAgxiOvPTaTcUEJXudDdch2G6+07UbaVOl30a31dnQyCZqPxgTfa0HlnU1A5XJDb7DuYHxOMbe8ld5CYs/GTQwSlzSv3vm5E828qizj+p29+KQiGODa+7g2zfBObUG45uuh90/99iGtYj3yOLUShpq8f1x6/wSTUTPieD0GnHKUzmUKQxnZWSsq4xnZo5oum52dF1hv8HnS2gAdhLTbkxm/KCHjAgrWKPXvrhmjPTB8mJVsMu+PlL1ua4AUfhzLEGlMIuGy8DYH1dN8yYORNCM4IK50dXpO X-Forefront-Antispam-Report: CIP:192.88.158.2; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(2980300002)(1110001)(1109001)(339900001)(189002)(199003)(110136002)(5001860100001)(5001830100001)(189998001)(77096005)(68736005)(5001960100002)(46102003)(77156002)(36756003)(87936001)(97736004)(85426001)(5003940100001)(50226001)(64706001)(11100500001)(62966003)(81156007)(4001540100001)(19580395003)(47776003)(50986999)(92566002)(5007970100001)(33646002)(50466002)(104016003)(6806004)(19580405001)(48376002)(229853001)(2351001)(69596002)(106466001)(105606002)(32563001); DIR:OUT; SFP:1102; SCL:1; SRVR:BLUPR03MB487; H:az84smr01.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Exchange-Diagnostics: 1; BLUPR03MB487; 2:whxYjQ299F9qIvKZvjiVKg8iQ1CWyCKXHFFFIh+sl6SSYJsnd2LO9NydPROKw5oR/IMRFkVG4w4Tw2e0WXekZbFFZB7lSzDSITRyC+tWeDX0FAsiEhk1BG1IOryIyTZbXsAULpQhmUui5YmTEe+QtzIBENq3CfE5i2lEYsUjFYY=; 3:IHzjzzbv83m1+7tZ58vz62QHaEg5+MUCJkX8zh6c9huxl+61IV/ErTGkEmzOOYek70nXBitPBb/dUNiRLpgLSGnslv9yfzu0EUs9iDiYcX4E/UUW5TrbazVMUTfOTAoj8ZaI+PGxwRa106Okoi5im7aATOLFUs2HYzFVJfZVaVwTpt3o1ZgHgZ1jye6nFSfvRo0/DeKlenOb7Van1xk1gXs525OK7GWONNLyWs/GpWk=; 25:Dar2BVMRxSWZvI1DGwKarWg9YrsjnKHlmGvpkNXDFZntQEjo5HMTgwQ/4EDNSO0FmE5hJvzTjtvu4MDcadVVV4RncuNMNi33p5t8IZ9c41GgeaA49fMqtU/NxlRR01UUCcrE4TsCgEaCXMgZ1I9HYrjWOjae20jSbkslFr8zZ/IncCdWsVgETEBQ5Zb/mKAHvkDnVlkNCWWF3uz7WPBzFxPcyRKZLu+bI2LSmUzwK6AoKt9hCI7usFLCgURCQkXq28xTpYbbhHkN5Z6kFFHt8w== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BLUPR03MB487; X-Microsoft-Exchange-Diagnostics: 1; BLUPR03MB487; 20:W7FtwFDvRYpy1+vC6IE9UoCviJ2p9BGbZ+VZP5yoqUOxi2Wdutlvl5/OiViv47CjIBYw76BG8Qy+FhFIKXySaePg1cJUtX4d7DgIv8/2tx4t22Au/h8bLVWJjIyRAw55LXuIWr5WnVOGnr5XRBfpGZVGwVqCv4EDXnzkMCY72TuoBF3l3jar9NNlii8gAmDS42rbAdTf4iB0TfEk7zI3vs8yrHV/RNV97Jq701/jXFAzlBrWR8c0oGPwbTJ3pRX7ULpqq1DdJxESvbUZhMxSWPQ97FW5RD3b2GrSjNqFPEWPdOn7PrG3e5uGEy7QxBqKeZVA4um0I+M2laWHxANzW2iLrbi+2GF6bXcEtJ8p+mw=; 4:h5RiKOrqCM9fpzola0XrxrtAQxAJN3T9b8fz+KJl1f6jpvflI5I6/T2pNLYqT8NdojdTOdKH1lHqZHbxsL7eTfck0r9H7YfIhZwXVj4O9k13x4VQFXYqhEtph2PiBLBDpI1Gwz2M15ZuIZjJfL+sP8+NVVZ025sJ85kGOQFAma3QGmQHCuDKsHB+VWwuySE9HAOvcAH/N7KCqXDEuPI27OynoxMvTyPYPGoo8szYa7aWO7eFDzp14Tds5A9+RwnK0GkvdXP/5FJVLu9Lb3uZRLGmAyFKAwQx36L0sbCr/+t3sMI3u700QkJrqDhkZMkQ X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(5005006)(8121501046)(3002001); SRVR:BLUPR03MB487; BCL:0; PCL:0; RULEID:; SRVR:BLUPR03MB487; X-Forefront-PRVS: 06968FD8C4 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BLUPR03MB487; 23:PE25dOUy802UUg7kvbnJ4kkOACUaZtInmwnkUUACln?= =?us-ascii?Q?o9ukifnYwoUnL5bqItIpbWsTVaVc5NU8M4WGBkmC8NvNvipF47oVJ/shmlTf?= =?us-ascii?Q?+gNvSuo+IGOa0ICAXz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ascii?Q?jF/+yzvIoqJGh3Jn/G8EZJfPX+vHEaeWNaXcdcVcbOrGxrMcGqToRx7IL9x4?= =?us-ascii?Q?uJwogsJKHaJA3OpoF8M+62ISw5tZFqjXnVJuX8DXO+A+ZMOuqN4UreQmJ8z8?= =?us-ascii?Q?jYEIr4N1XtNh05X+6rHuVpj+8FtJqnuUovS4JQOTfTwBHAlbBWIkQVfypSsu?= =?us-ascii?Q?vd5l2VYvRQ7MI=3D?= X-Microsoft-Exchange-Diagnostics: 1; BLUPR03MB487; 5:CBVui+IekFH4L/ydJsHm9yxOjGa6k2xUMLSF5dZtIr3o2iB3+OsvWl3lX6rFJr7/R5ELU56BIK9cJln5AF0acMwDOy6WQul0xTkBKGGpxTgNeMSYCEDuvzB2NsrJNyzAK5LXRitAUBTpJMbketMU9Q==; 24:jmEIJ0QnAt0t3NsZoWGiRKuIJUqVz6RaisKZjWSEWGoKlatY3mJLMgTyK/P4V0JPO8kd6J5JBWibTZ1LYFyxOcXpJUxiPXLKcrksYJAonnY=; 20:uP+c60UquOZfuSNDzNwrA3/5mhkvUf7bnmD67dqjVvGKAqwQ9h5ifFYrYx2/9DozDdWF9/OBJvCuApa96NtHJg== SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Sep 2015 07:37:39.0508 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d; Ip=[192.88.158.2]; Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR03MB487 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00, DATE_IN_FUTURE_06_12, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP For i.MX6UL, the clock switch flow is slightly different from other i.MX6 SOCs. It has a 'secondary_sel' clk that will be used when the CPU freq is higher than 396MHz. So the clock switch flow in 'set_target' callback need to update to support i.MX6UL in the common i.MX6 SOC cpufreq driver. Signed-off-by: Bai Ping Acked-by: Viresh Kumar --- change for v2: add the missed 'clk_put' in imx6q_cpufreq_remove(). drivers/cpufreq/imx6q-cpufreq.c | 50 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 45 insertions(+), 5 deletions(-) diff --git a/drivers/cpufreq/imx6q-cpufreq.c b/drivers/cpufreq/imx6q-cpufreq.c index 380a90d..9b4a7bd 100644 --- a/drivers/cpufreq/imx6q-cpufreq.c +++ b/drivers/cpufreq/imx6q-cpufreq.c @@ -30,6 +30,10 @@ static struct clk *pll1_sw_clk; static struct clk *step_clk; static struct clk *pll2_pfd2_396m_clk; +/* clk used by i.MX6UL */ +static struct clk *pll2_bus_clk; +static struct clk *secondary_sel_clk; + static struct device *cpu_dev; static bool free_opp; static struct cpufreq_frequency_table *freq_table; @@ -91,16 +95,36 @@ static int imx6q_set_target(struct cpufreq_policy *policy, unsigned int index) * The setpoints are selected per PLL/PDF frequencies, so we need to * reprogram PLL for frequency scaling. The procedure of reprogramming * PLL1 is as below. - * + * For i.MX6UL, it has a secondary clk mux, the cpu frequency change + * flow is slightly different from other i.MX6 OSC. + * The cpu frequeny change flow for i.MX6(except i.MX6UL) is as below: * - Enable pll2_pfd2_396m_clk and reparent pll1_sw_clk to it * - Reprogram pll1_sys_clk and reparent pll1_sw_clk back to it * - Disable pll2_pfd2_396m_clk */ - clk_set_parent(step_clk, pll2_pfd2_396m_clk); - clk_set_parent(pll1_sw_clk, step_clk); - if (freq_hz > clk_get_rate(pll2_pfd2_396m_clk)) { - clk_set_rate(pll1_sys_clk, new_freq * 1000); + if (of_machine_is_compatible("fsl,imx6ul")) { + /* + * When changing pll1_sw_clk's parent to pll1_sys_clk, + * CPU may run at higher than 528MHz, this will lead to + * the system unstable if the voltage is lower than the + * voltage of 528MHz, so lower the CPU frequency to one + * half before changing CPU frequency. + */ + clk_set_rate(arm_clk, (old_freq >> 1) * 1000); clk_set_parent(pll1_sw_clk, pll1_sys_clk); + if (freq_hz > clk_get_rate(pll2_pfd2_396m_clk)) + clk_set_parent(secondary_sel_clk, pll2_bus_clk); + else + clk_set_parent(secondary_sel_clk, pll2_pfd2_396m_clk); + clk_set_parent(step_clk, secondary_sel_clk); + clk_set_parent(pll1_sw_clk, step_clk); + } else { + clk_set_parent(step_clk, pll2_pfd2_396m_clk); + clk_set_parent(pll1_sw_clk, step_clk); + if (freq_hz > clk_get_rate(pll2_pfd2_396m_clk)) { + clk_set_rate(pll1_sys_clk, new_freq * 1000); + clk_set_parent(pll1_sw_clk, pll1_sys_clk); + } } /* Ensure the arm clock divider is what we expect */ @@ -186,6 +210,16 @@ static int imx6q_cpufreq_probe(struct platform_device *pdev) goto put_clk; } + if (of_machine_is_compatible("fsl,imx6ul")) { + pll2_bus_clk = clk_get(cpu_dev, "pll2_bus"); + secondary_sel_clk = clk_get(cpu_dev, "secondary_sel"); + if (IS_ERR(pll2_bus_clk) || IS_ERR(secondary_sel_clk)) { + dev_err(cpu_dev, "failed to get clocks specific to imx6ul\n"); + ret = -ENOENT; + goto put_clk; + } + } + arm_reg = regulator_get(cpu_dev, "arm"); pu_reg = regulator_get_optional(cpu_dev, "pu"); soc_reg = regulator_get(cpu_dev, "soc"); @@ -331,6 +365,10 @@ put_clk: clk_put(step_clk); if (!IS_ERR(pll2_pfd2_396m_clk)) clk_put(pll2_pfd2_396m_clk); + if (!IS_ERR(pll2_bus_clk)) + clk_put(pll2_bus_clk); + if (!IS_ERR(secondary_sel_clk)) + clk_put(secondary_sel_clk); of_node_put(np); return ret; } @@ -350,6 +388,8 @@ static int imx6q_cpufreq_remove(struct platform_device *pdev) clk_put(pll1_sw_clk); clk_put(step_clk); clk_put(pll2_pfd2_396m_clk); + clk_put(pll2_bus_clk); + clk_put(secondary_sel_clk); return 0; }