From patchwork Fri Jun 19 02:49:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Scott Wood X-Patchwork-Id: 6642121 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 AEF709F326 for ; Fri, 19 Jun 2015 03:04:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B19462092F for ; Fri, 19 Jun 2015 03:04:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 99F392092D for ; Fri, 19 Jun 2015 03:04:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751734AbbFSDD7 (ORCPT ); Thu, 18 Jun 2015 23:03:59 -0400 Received: from mail-bn1bon0138.outbound.protection.outlook.com ([157.56.111.138]:34202 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752228AbbFSDD7 (ORCPT ); Thu, 18 Jun 2015 23:03:59 -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:39 +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 6/8] cpufreq: qoriq: Remove frequency masking and minimum Date: Thu, 18 Jun 2015 21:49:16 -0500 Message-ID: <1434682158-7243-7-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:YQH2/jh0hGuBKYZq48bfZhQKFEPcXNyVnr8nKHtCJ8mnF8q58JXQQfnH8THRxlmW; 2:ZLumxvhIGtQWm7U/rUkZtXxs7gYaDMJauqjikurtwshBjvlC65+/t+a2uCHjsCVp4M5Lu02LogqnpUtcOsmOjl7iwmZdz2qPvjHMWywopN/2t57EzPoWW4wpsRKBnCRluwWlX641sfFkzZlXUCXGEA==; 6:HJgo6dhab00cJqdcaN3bDraZYl8/yPHW+s8v39WHtZ0q2xWJ+8a5kJ4Xx/wTkewOYSXN+2inG7DUHAAVtc7kqf3nKprdMZcGnIs3FJZa3V1CngWaFz4+1rf1H/1wnqckZmXIwD7UChyt75akQdUQ3fh0I3lmFdf3Z4T84caC7DJrMCmsZNJo+Met/7toKlEpVEBMTJmZjKnzm6YZl3tEKXEOeuVxlfBW6UP3POgFC8YxvqsWZ/jIjOem16OPUwePU3hWOWHTHbG9IvCXUBECDOwaQpiAEX+DNE71cPmQ9ISYadipAVRgo7d6Yr0EGn5reWmbs0707qf7DCzhxRqHifoB0wnQ4O1QN9ulf4ON8x5fHlCVgG5YUr0rHodDtn4wjzUnisTToGjbo0aaimS05V6XaAK+/NGvz+AF+v6SMnU0D8zNZG5+vl0ftzjV9wgoRvmf96qYKm61hS8X2hbtOURFAQti8DApd1wGWUT5hSP5Q4wpWHngYT7KmHTabrsyir7gSc8V3RWzJW5vUT/+PS3b12Bik0/z3biaBFfWIDv3Xv3BIdJaKWmcddkXXbLX8yXyP0zHgAo/yfYeJYvFBO0aweO8PQ8F/ERad2it85w= 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:pVVrJXeDRCEN2h/JKOza9iJxJ/q1kvITuGvbd8gPQwQ5b5FJF9sReWq3oQ56cReUWnlTpZGvnP0oXx6Mp1i1bpP8ehccBXQ6lXT3CSAwz6Q4SgcyHHA0yupNg5LdXJO3zSvE5MlG11waaXarMfRa6Omye+n4H98k4IQl031XkOdmDbFvZ04tHgoKB9T/N7fL7qh4CXHPhefenN0pbGUBkyVvhdDjJUw6nNfvo8zQlB3pZ6pQelER/EaIpYRZd5Qj3EM3RG0IWKGRaHBzLejQ/0JScjyLZUWWxFDv8PjI05g= 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:R0t9JIUWYTcr4M64SoHfDDcIQq15jQbpgDKzLSIHKa52swKk8M3LkRnFQibndup2HBuVq+z4p/4TpG9jyaByCWrMr2Iw942RrV3I8wl2H2iYaswaRfiVG9KrdSG2HuYtSC7MFiPmm1kSEiTq4nmJfLKTGckRcnBvzqN5T52P1/RzplwAiQDcseS2i4dQ4YGbnaOoNJU2HsGh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ale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jun 2015 02:49:39.4318 (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 The clock driver now takes care of ensuring that the mux only exposes options that are valid. The driver was currently being overly conservative in some cases -- for example, the "min_cpufreq = get_bus_freq()" restriction only applies to chips with erratum A-004510, and whether the freq_mask used on p5020 is needed depends on the actual frequencies of the PLLs (FWIW, p5040 has a similar limitation but its .freq_mask was zero). Further, the freq_mask mechanism makes assumptions about the number and order of the clock parents. The new driver does not adhere to those assumptions (in particular, it removes invalid options). Signed-off-by: Scott Wood --- drivers/cpufreq/qoriq-cpufreq.c | 92 +---------------------------------------- 1 file changed, 2 insertions(+), 90 deletions(-) diff --git a/drivers/cpufreq/qoriq-cpufreq.c b/drivers/cpufreq/qoriq-cpufreq.c index 32ab99e..514395f 100644 --- a/drivers/cpufreq/qoriq-cpufreq.c +++ b/drivers/cpufreq/qoriq-cpufreq.c @@ -36,53 +36,6 @@ struct cpu_data { struct cpufreq_frequency_table *table; }; -/** - * struct soc_data - SoC specific data - * @freq_mask: mask the disallowed frequencies - * @flag: unique flags - */ -struct soc_data { - u32 freq_mask[4]; - u32 flag; -}; - -#define FREQ_MASK 1 -/* see hardware specification for the allowed frqeuencies */ -static const struct soc_data sdata[] = { - { /* used by p2041 and p3041 */ - .freq_mask = {0x8, 0x8, 0x2, 0x2}, - .flag = FREQ_MASK, - }, - { /* used by p5020 */ - .freq_mask = {0x8, 0x2}, - .flag = FREQ_MASK, - }, - { /* used by p4080, p5040 */ - .freq_mask = {0}, - .flag = 0, - }, -}; - -/* - * the minimum allowed core frequency, in Hz - * for chassis v1.0, >= platform frequency - * for chassis v2.0, >= platform frequency / 2 - */ -static u32 min_cpufreq; -static const u32 *fmask; - -#if defined(CONFIG_ARM) -static int get_cpu_physical_id(int cpu) -{ - return topology_core_id(cpu); -} -#else -static int get_cpu_physical_id(int cpu) -{ - return get_hard_smp_processor_id(cpu); -} -#endif - static u32 get_bus_freq(void) { struct device_node *soc; @@ -195,7 +148,7 @@ static int qoriq_cpufreq_cpu_init(struct cpufreq_policy *policy) { struct device_node *np, *pnode; int i, count, ret; - u32 freq, mask; + u32 freq; struct clk *clk; struct cpufreq_frequency_table *table; struct cpu_data *data; @@ -230,23 +183,11 @@ static int qoriq_cpufreq_cpu_init(struct cpufreq_policy *policy) goto err_pclk; } - if (fmask) - mask = fmask[get_cpu_physical_id(cpu)]; - else - mask = 0x0; - for (i = 0; i < count; i++) { clk = clk_get_parent_by_index(policy->clk, i); data->pclk[i] = clk; freq = clk_get_rate(clk); - /* - * the clock is valid if its frequency is not masked - * and large than minimum allowed frequency. - */ - if (freq < min_cpufreq || (mask & (1 << i))) - table[i].frequency = CPUFREQ_ENTRY_INVALID; - else - table[i].frequency = freq / 1000; + table[i].frequency = freq / 1000; table[i].driver_data = i; } freq_table_redup(table, count); @@ -321,38 +262,9 @@ static struct cpufreq_driver qoriq_cpufreq_driver = { .attr = cpufreq_generic_attr, }; -static const struct of_device_id node_matches[] __initconst = { - { .compatible = "fsl,p2041-clockgen", .data = &sdata[0], }, - { .compatible = "fsl,p3041-clockgen", .data = &sdata[0], }, - { .compatible = "fsl,p5020-clockgen", .data = &sdata[1], }, - { .compatible = "fsl,p4080-clockgen", .data = &sdata[2], }, - { .compatible = "fsl,p5040-clockgen", .data = &sdata[2], }, - { .compatible = "fsl,qoriq-clockgen-2.0", }, - {} -}; - static int __init qoriq_cpufreq_init(void) { int ret; - struct device_node *np; - const struct of_device_id *match; - const struct soc_data *data; - - np = of_find_matching_node(NULL, node_matches); - if (!np) - return -ENODEV; - - match = of_match_node(node_matches, np); - data = match->data; - if (data) { - if (data->flag) - fmask = data->freq_mask; - min_cpufreq = get_bus_freq(); - } else { - min_cpufreq = get_bus_freq() / 2; - } - - of_node_put(np); ret = cpufreq_register_driver(&qoriq_cpufreq_driver); if (!ret)