From patchwork Fri Jun 19 02:49:12 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Scott Wood X-Patchwork-Id: 6642951 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 65A099F40A for ; Fri, 19 Jun 2015 04:23:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8665A20616 for ; Fri, 19 Jun 2015 04:23:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6A84320618 for ; Fri, 19 Jun 2015 04:23:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751226AbbFSEXQ (ORCPT ); Fri, 19 Jun 2015 00:23:16 -0400 Received: from mail-bn1on0132.outbound.protection.outlook.com ([157.56.110.132]:7864 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751284AbbFSEXQ (ORCPT ); Fri, 19 Jun 2015 00:23:16 -0400 Authentication-Results: linaro.org; dkim=none (message not signed) header.d=none; Received: from snotra.am.freescale.net (192.88.168.50) by BLUPR03MB1475.namprd03.prod.outlook.com (10.163.81.17) with Microsoft SMTP Server (TLS) id 15.1.190.14; Fri, 19 Jun 2015 02:49:33 +0000 From: Scott Wood To: Mike Turquette , Tang Yuantian CC: "Rafael J. Wysocki" , Liberman Igal-B31950 , Bucur Madalin-Cristian-B32716 , , , , , , "Scott Wood" Subject: [RFC PATCH 2/8] cpufreq: qoriq: Don't look at clock implementation details Date: Thu, 18 Jun 2015 21:49:12 -0500 Message-ID: <1434682158-7243-3-git-send-email-scottwood@freescale.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1434682158-7243-1-git-send-email-scottwood@freescale.com> References: <1434682158-7243-1-git-send-email-scottwood@freescale.com> MIME-Version: 1.0 X-Originating-IP: [192.88.168.50] X-ClientProxiedBy: BLUPR08CA0070.namprd08.prod.outlook.com (10.141.200.50) To BLUPR03MB1475.namprd03.prod.outlook.com (25.163.81.17) X-Microsoft-Exchange-Diagnostics: 1; BLUPR03MB1475; 2:yd+113X9l9o18MrtzeImDcr3FgXdoEriC+LjmpEc42EhRE4vaav/4TEN/kvMouY6; 2:RVtQPyJloAvPzqwy0AIr9pVj7ajAWSG5pKE2mSrAP06AjLtnk2iE5mN4P0pf1UhgATcngYZWeE6rBI8ZZCL64fcys8MP1QVUKT9SxJtf//MqFC0VwwiNv2lpsITr9K5hjqGhhZlYg6aKI2fqrrsffQ==; 6:9ICsYOLhQuX3jSOVtnTZro4Zve46/JRYLetcLnrGxLum52bpCkGpvkKbTDJLWbZVD4YrlrUdlCGRMdy1ROyShdGTptuJ/7RLutVkNnxEMh32gK0MtlP/1iUTKJ4pzdbxfWbpqJogFu8++VbOQErVhT1a+DvdiJB5hIqZ+cTNAi41KxM36ET8VEv42HaoCigkK76sID84z+CLJbfWG8bIEGPR3KMoIvaHYmC6tzSgbgUzZQsDam4Qb2DkdYGOzRzGso56P0a8zgRTHmaQgmyCnEZ3OF1RUF1lXK+F7H8B1l+yVDF8FcvioXPdw0FuKktrvbQbLerYX+Q2MnOKFgKHRm3j7QojmRRMP5fZeskcdBuh47S0j1PCfoJvtAYKgid7oEB6VCsEdzKuZz0HH9PFZdbM9erlv5jiKGIiVPloKnESYUF7ETzbse29W3wBjmEmSdgW55Z5QmycyZ2LwPAfc+rm5KB2JiH4edd7k+qf9K0r8IyF1LRMyPzdcnaamETOpwC9E5WbMK0it0ea0QRm9/dX9I/bjKRzgUyhTTX+chkilV7kaUpV2o8PUHvumtnA+5mJ4QkK4mz2q/sCnyG58PNXLmMEhwtpcJqcV2EOOjs= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BLUPR03MB1475; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(5005006)(3002001); SRVR:BLUPR03MB1475; BCL:0; PCL:0; RULEID:; SRVR:BLUPR03MB1475; X-Microsoft-Exchange-Diagnostics: 1; BLUPR03MB1475; 3:oM/MMk5aZicixZGnPprFcM4zwZvghDaX2GYpa1IUP8RZJJt41f/aEXSXSZ4p5N16kQut+jmkOojdHrbGlpCSKP7qc5QCsdTcrXkWoT7447DBj8YclPKkRTCbVhcNdezOAM0mUW2rhuFHQru35l4Jqjb1W8ob4j6PljagKxFrsF+q/Ahds3U4FHEXbKm0QS4huQsv7HarctPAp6jidCiPruDw/qakT7v7DMMQPQIsEp4LnaA8VywUR7fwqjoyNSbA3VuXV//AsySJOE+stvVd2c3HsjvNgXzvoTHyZCYv/WI= X-Forefront-PRVS: 0612E553B4 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6009001)(86362001)(77096005)(33646002)(76176999)(40100003)(87976001)(122386002)(36756003)(50466002)(189998001)(50986999)(50226001)(92566002)(48376002)(62966003)(77156002)(229853001)(42186005)(5001960100002)(19580395003)(107886002)(2950100001)(46102003)(66066001)(19580405001)(47776003)(5001770100001)(4001450100001)(217873001)(4001430100001); DIR:OUT; SFP:1102; SCL:1; SRVR:BLUPR03MB1475; H:snotra.am.freescale.net; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BLUPR03MB1475; 9:5Ahcqvm9N/TTQJu4DTJH82SfBOGWtaekCW6b76cOYq6xbJQuEL9W3Z8Cp5LDtu1X9vKpAwod3JdwdN9wzyn/B023dAlSnWM2LOFsaKBwZLY2QYflFu6X0Dr8VLCnEaqbCxyBr5VhaeYd0Ox8TIjgVI1sbp5baLYXDn5E6kWjmKitjacr5B8obWjZC5WU5i1Yx+/g5vF/NCDrzqDV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X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jun 2015 02:49:33.0878 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR03MB1475 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 Get the CPU clock's potential parent clocks from the clock interface itself, rather than manually parsing the clocks property to find a phandle, looking at the clock-names property of that, and assuming that those are valid parent clocks for the cpu clock. This is necessary for cpufreq to continue working once the clocks are generated based on the clock driver's knowledge of the chip rather than a fragile device-tree description of the mux options. Signed-off-by: Scott Wood --- drivers/cpufreq/qoriq-cpufreq.c | 47 ++++++++++++++++------------------------- 1 file changed, 18 insertions(+), 29 deletions(-) diff --git a/drivers/cpufreq/qoriq-cpufreq.c b/drivers/cpufreq/qoriq-cpufreq.c index 358f075..32ab99e 100644 --- a/drivers/cpufreq/qoriq-cpufreq.c +++ b/drivers/cpufreq/qoriq-cpufreq.c @@ -11,6 +11,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include +#include #include #include #include @@ -99,9 +100,10 @@ static u32 get_bus_freq(void) return sysfreq; } -static struct device_node *cpu_to_clk_node(int cpu) +static struct clk *cpu_to_clk(int cpu) { - struct device_node *np, *clk_np; + struct device_node *np; + struct clk *clk; if (!cpu_present(cpu)) return NULL; @@ -110,37 +112,32 @@ static struct device_node *cpu_to_clk_node(int cpu) if (!np) return NULL; - clk_np = of_parse_phandle(np, "clocks", 0); - if (!clk_np) - return NULL; - + clk = of_clk_get(np, 0); of_node_put(np); - - return clk_np; + return clk; } /* traverse cpu nodes to get cpu mask of sharing clock wire */ static void set_affected_cpus(struct cpufreq_policy *policy) { - struct device_node *np, *clk_np; struct cpumask *dstp = policy->cpus; + struct clk *clk; + const char *ourname, *theirname; int i; - np = cpu_to_clk_node(policy->cpu); - if (!np) - return; + ourname = __clk_get_name(policy->clk); for_each_present_cpu(i) { - clk_np = cpu_to_clk_node(i); - if (!clk_np) + clk = cpu_to_clk(i); + if (IS_ERR(clk)) { + pr_err("%s: no clock for cpu %d\n", __func__, i); continue; + } - if (clk_np == np) + theirname = __clk_get_name(clk); + if (!strcmp(ourname, theirname)) cpumask_set_cpu(i, dstp); - - of_node_put(clk_np); } - of_node_put(np); } /* reduce the duplicated frequencies in frequency table */ @@ -219,17 +216,12 @@ static int qoriq_cpufreq_cpu_init(struct cpufreq_policy *policy) goto err_nomem2; } - pnode = of_parse_phandle(np, "clocks", 0); - if (!pnode) { - pr_err("%s: could not get clock information\n", __func__); - goto err_nomem2; - } + count = __clk_get_num_parents(policy->clk); - count = of_property_count_strings(pnode, "clock-names"); data->pclk = kcalloc(count, sizeof(struct clk *), GFP_KERNEL); if (!data->pclk) { pr_err("%s: no memory\n", __func__); - goto err_node; + goto err_nomem2; } table = kcalloc(count + 1, sizeof(*table), GFP_KERNEL); @@ -244,7 +236,7 @@ static int qoriq_cpufreq_cpu_init(struct cpufreq_policy *policy) mask = 0x0; for (i = 0; i < count; i++) { - clk = of_clk_get(pnode, i); + clk = clk_get_parent_by_index(policy->clk, i); data->pclk[i] = clk; freq = clk_get_rate(clk); /* @@ -288,10 +280,7 @@ err_nomem1: kfree(table); err_pclk: kfree(data->pclk); -err_node: - of_node_put(pnode); err_nomem2: - policy->driver_data = NULL; kfree(data); err_np: of_node_put(np);