From patchwork Sat Aug 15 06:41:18 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Scott Wood X-Patchwork-Id: 7020471 X-Patchwork-Delegate: rjw@sisk.pl Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D12A0C05AD for ; Sat, 15 Aug 2015 06:42:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D3BAC20630 for ; Sat, 15 Aug 2015 06:42:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A064F20632 for ; Sat, 15 Aug 2015 06:42:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750897AbbHOGmD (ORCPT ); Sat, 15 Aug 2015 02:42:03 -0400 Received: from mail-bn1on0139.outbound.protection.outlook.com ([157.56.110.139]:32378 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750943AbbHOGmA (ORCPT ); Sat, 15 Aug 2015 02:42:00 -0400 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=scottwood@freescale.com; Received: from snotra.am.freescale.net (192.88.168.50) by BY1PR03MB1483.namprd03.prod.outlook.com (10.162.210.141) with Microsoft SMTP Server (TLS) id 15.1.225.19; Sat, 15 Aug 2015 06:41:55 +0000 From: Scott Wood To: Mike Turquette , Tang Yuantian CC: "Rafael J. Wysocki" , Liberman Igal-B31950 , Bucur Madalin-Cristian-B32716 , , , , , Scott Wood Subject: [PATCH v2 1/5] cpufreq: qoriq: Don't look at clock implementation details Date: Sat, 15 Aug 2015 01:41:18 -0500 Message-ID: <1439620882-20449-2-git-send-email-scottwood@freescale.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1439620882-20449-1-git-send-email-scottwood@freescale.com> References: <1439620882-20449-1-git-send-email-scottwood@freescale.com> MIME-Version: 1.0 X-Originating-IP: [192.88.168.50] X-ClientProxiedBy: CO2PR20CA0002.namprd20.prod.outlook.com (25.163.96.12) To BY1PR03MB1483.namprd03.prod.outlook.com (25.162.210.141) X-Microsoft-Exchange-Diagnostics: 1; BY1PR03MB1483; 2:LNhiR/DyFGQrn7+H4mpD3TJ8vhXXgWC23VMsDFs6809vu2ov34qjD5CC1gO8GqpCtjZjMBXVLPxwWwI+aUEgMDlq6HMEjs/g81LQm+ERkp0yT/YlsryEvFvyhomrjxNvxrfeqCpcAAll/qK7SqGha9g4iHap5v1FiNA5MoKgmU4=; 3:LsiAzAEQdO5cobWdwMVd3nhLTxBnsJP2DgK88ByC7vfdQmSEAyU5tDVe3bgZ4iVRB2rvhONYe4bY3fW+iJsJMjM7PTmDrlM5qYHFbbMMtHgKDrw/B5ks/PiEI14MWg4YmyzG92fnR6PfUMqFampOyQ==; 25:6tqppN8Iqz21991hiLKwl0UuIlChJ39zGfWYMR3cYke52kxZesUZ8pH/JsSFhn8n/0FNrA5WdnJb9Ag3u04HrXQLVafZP0f8IpDGWUWFCohzg57zXL0hCZErcksTqDzOGp9A4ahhKKvHYAqY1Ni0O/EJ9ognTLcyXO5BTKV1gYRb3UYVV6+U6jjsUoIScFupHEY/XTldk7mTKh61EBE8KC9o21EwxNMNPgXRGRQ4WdcImZiWTVuWr19LFQWhiA0aEOSUmWrntd/XJHc8AVNH0w== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY1PR03MB1483; X-Microsoft-Exchange-Diagnostics: 1; BY1PR03MB1483; 20:n1G3q1wLwPSZU3cdx2tzUew+Gs8UJFIBbxGKvHE+7UvjIFj5cHeDhpLIIDymdqQFBfw+dEui7nCyq1UY0hFg3tVEyhPvdnK/+FzO70KjpwNlv1IqrLCIOg75ar2G/bc5t6M03m8yz6xA+FP46FUE1u7fisfnQaBtXXlRYjS8t4d76Whx73ZEVtfMDtw7+x+CPA0AKK7SQLBOfHfDikhTfJ77QfbXUz0DoyGs6fklXYlX46iGi41dPnDhPWFnFXaqgYc7dFs8fuExITj3M2u7FfNQ51t6VGfKxzItJfEoD+pcc/mu2nv5cTuF/ZolPOz/ZH4Mxh2FcrUx9HK7oodIyrW6ABMlAw2bQ9r1TKcIYem4qMF1QuXa74Mhro6e3MpiNjP9S60N5F9yyYiMaVakwwkegSvTTfiTAyoZXiSJzVQThVXzI94IIl+Dr0LzbI43TmbdKcSYe0PkWQQqT2vwcACOtM1HAPTmxLHxdeKzsCuyw0rt5AxfJJp1xxIHmHhG; 4:icW2g7rSeSI5k8erJiKqi/g2CLcUS8yhINoQrMYTNlGJ3/QOkusZPkRSAERMjNW6xg2mZWyWe4FR9iUnE+0DO4iuFQXBbXS0axXVAWlamTQTskkeMvHTIl8Hi1vjLyjgf3W1hywAxCNarlXuQb1NX7W+N2NxTuJCrN5qYGmQ1va1LWzR2bjK98+DTQT9KKxcKlYBzV+pa1Ijh86RnucHtn6Cc5N9uPM8PE16It0bdwkjc87KVatVNdf/Vn9ate9b1uhs4YA3IzgslYN1Za9znPkUlpLs+kQA025YtNDxlOxmyKTkloJYDSMfdl8iHLfN X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(8121501041)(5005006)(3002001); SRVR:BY1PR03MB1483; BCL:0; PCL:0; RULEID:; SRVR:BY1PR03MB1483; X-Forefront-PRVS: 06691A4183 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6009001)(199003)(189002)(77156002)(76176999)(101416001)(5003940100001)(86362001)(5001960100002)(87976001)(42186005)(48376002)(68736005)(77096005)(33646002)(19580405001)(5001860100001)(50986999)(107886002)(5001770100001)(36756003)(19580395003)(2950100001)(4001540100001)(81156007)(97736004)(46102003)(50466002)(5001830100001)(4001450100002)(64706001)(92566002)(47776003)(189998001)(106356001)(122386002)(105586002)(40100003)(62966003)(66066001)(229853001)(50226001)(4001430100001); DIR:OUT; SFP:1102; SCL:1; SRVR:BY1PR03MB1483; H:snotra.am.freescale.net; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: freescale.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY1PR03MB1483; 23:VbT9t+RY06vnW2hiVpipqC7P1xPACq/xc9d73OIa6?= =?us-ascii?Q?Rc9nNLtAirat9TCHyQY4NuYjgij1jm2TK90a7Pr3eynlV0rzt8EwlULxtT2e?= =?us-ascii?Q?pb6xvXKHLSmYuvSI2NjZXChuXmNQ4w1p1KCQ/vF7KgHExVH5OFJLzjouQEgk?= =?us-ascii?Q?DU1cH/j8Xs+bSD4xvz+k6p3XGe6RW94+gnHo8CavYgL5z7xnaGfSKFOF+S2R?= =?us-ascii?Q?gqoQ+0hOU4IGHYSzavcGyNhB4da7MMznQYZyjjCHAmg/Jr3HCuDOywOGZV87?= =?us-ascii?Q?iBe04ANCjSGlA5qvVmdlc+QRn8K02oQtsA6HiE84MGN2Otyx0lrIAdeceVi1?= =?us-ascii?Q?7S58xgbkkq5Cz3cgtkU4paKtRFOx6L0FkV+dae3ut9IiseAO9LZUbseYutWI?= =?us-ascii?Q?P9/roJ+I/cwRJZYT8zB3tQ09aa9LXF5dwYZ+8sembQJ4o2uEBFnvUzi96PR8?= =?us-ascii?Q?IKA07O85KzYj7N6uJie4L50wT98urt88H8jgHLgP2TeQMfNfTTBhiK0kfdrD?= =?us-ascii?Q?g49zL/uPjoo0Nv7yDPikMDiJjA0Ddl3fm1hhXM5W419+urMLG0kt7dPrUnqU?= =?us-ascii?Q?UsukQjviuKl7XoyZaGRReSSRwS2w4ajEd/l84HU7aDy5v1H/VzyijDNuavWG?= =?us-ascii?Q?B0fmTd1SVvRRsQeVBmOJmMwt54gXuQhrMkcUN09wQ5taqlCAiIpxmsaIee3v?= =?us-ascii?Q?VQbTVgbWcgAyGQQ6XtCaPalXxoCKSaVfrJN8BFttEqFsFRdCB+TEotv1EdhH?= =?us-ascii?Q?z2iXIL+0Vssh9Iecl88urkVGMwJS92UEFdrvk/hKWvfNyuKqiC16hfWkvGb/?= =?us-ascii?Q?mSrxgE0EMuSBFHZi0exDIVmK67sq6uZX4T52N6/2jJWZJG001OSygJvP2aKZ?= =?us-ascii?Q?R9+fwNgB/rl+quV0wwCsHFtvGZjxNwqe7wghnlq/I2gq0h5vTY35SWav4vyg?= =?us-ascii?Q?2Jqhx87UJk/HC//0YBGvqsP7dNBkBGLHS3gHG/sY7Jzr0OlXGoAZNOE1L+aC?= =?us-ascii?Q?Qx8cTT0chjPJSEQiWq0CoCSSsGEMjymAWAXC2VS2v/JtrswKeLVDkuHqdCfG?= =?us-ascii?Q?Cq1FiMjFso2DXHBVZY/vm9k0+49k5QxkTfetm83//PL6dSMQ0mFR0/te8RmH?= =?us-ascii?Q?aPksOWJI0NSw3PKos+WpuiPsBS9IWuTjLUdl8FslPqMiKXcsD4z+Q=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; BY1PR03MB1483; 5:puJao2M7rAKRKnTuUBh5i2A5DGFLuZLZ4QOiv1KLBU4pcfR48HrVO0w4OuLUzRZBhCz+kP3yrVW+G8Sxjz2TrW4mgBu4UoQccpX7yWS+Ib769O/kHq0VnRwT59Miz2guzsYIP0OuX6fjCUMvl6YLBg==; 24:5KOYTVUxh1v5V8T5TYq6v3oJCyGxV4DMvfLnJoRIAy6V+sptsMtNK/8iYR+vbu5xkBxE9MGhnIxDalpE89F/qgJODRbDAyh8CnqcAUpAmTE=; 20:zHgjx6gbRwu430kHm/lE8Xk+VM5eh81mLzgRjbhyrvbDpTA0dYcemm7tCv2eOwHiRky+5qCxi6nGZfjP19he4A== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Aug 2015 06:41:55.3076 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR03MB1483 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 --- v2: non-RFC 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);