From patchwork Sat Aug 15 06:41:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Scott Wood X-Patchwork-Id: 7020481 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 DC4C79F39D for ; Sat, 15 Aug 2015 06:42:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DBEB320630 for ; Sat, 15 Aug 2015 06:42:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C8AA520636 for ; Sat, 15 Aug 2015 06:42:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751125AbbHOGmP (ORCPT ); Sat, 15 Aug 2015 02:42:15 -0400 Received: from mail-bn1on0113.outbound.protection.outlook.com ([157.56.110.113]:22688 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751138AbbHOGmI (ORCPT ); Sat, 15 Aug 2015 02:42:08 -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:42:02 +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 4/5] cpufreq: qoriq: Remove frequency masking and minimum Date: Sat, 15 Aug 2015 01:41:21 -0500 Message-ID: <1439620882-20449-5-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:W0Kz9WeqrgfKJ++IDxnS7CeJVSNM7xm5JQpHjwuNAhsZmFNH7LHY4bdvUTipuUVstIrT1nRV9UlfEbdwxcL3QYBYAujPmyRL9GNEKKwN6MwpxvUiRbtHKZ5/GFFFGsQpXz2aXGXmHeSDNl0nmi0udPGG79Q/AWuIdPsWm2uOoZI=; 3:zzR8DTThS4HezeuLKIZMHfFWxwEq0oBBKgmV/vV9xtyjLhoGW1KiULQC9DKuGQfz1PM2HDse5aSjqtqGT8NcogQ3l5E2A3P4lRkParHxeY5oD7tqj4GUELKRbnccRPTpcXCMNBcLdhXWEu2bqOYUug==; 25:BX2TiJ8HQcx+QQKjRiMxnnATHVyjdM3KaLwCp1v7/ffETSpaYAGswubDJ2EWkqxMmJvZJUIQLk8iSoGScddK2nnmmgRS8XgJXoTPlWia0Bj6zfxs1TBG++aPc4eBCr+prK1JOsMgxXjavNU2IdHpaYOpslpnsI7aBQsSjWpfFI627cA0U9Pzvp+zG6gKNox5SAkk/OZ7Rdm4+tTw7+GShGPsp1X8ejRTEp+KF8gBbuZO2cZZI5mgEcdY0G1p3BDPKLM98p3te/tdYsb1Jms2bg== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY1PR03MB1483; X-Microsoft-Exchange-Diagnostics: 1; BY1PR03MB1483; 20:tJqAnovmp5KHz7cyfDdnqVOMNakHkrrk7BCD3JrkMUguzgu9XFICxV/HPIWlkIlwpyus1NSe+CHXpaw8ZvVkM8UqcVeO+sINqDuL4GinvpaiX0vMulsb36EQO9iM9kR2lpPNhuooewgXjDX3nAwkyivtta1K1efH02usUqFjJsgxZkWeXS6jhszZote+f3i1CcCHeU3kR1qeY0OQCGPkpr/HVUcAAcc0HSfZ9pQtEt1CnJKrkzgwhrLZL48Si2wpnMNQ/xhm2/WuojN0OTRH3RSE2hXLLF+V4a2WDzvA0gzdXboSTyK27QI0eEF9ecG13CaZJ91IftGcdhP3VnGxrDuuauIGl7TrT15yxQ0OrZy9iZ2qAlpcGAQL7qGhQpyhm4o3dUKBHds1AI/+gdUq0ElgynSwN0breU5RAH9/ORIv9LBUOeK//jDId7IgdXPCmouLet52ecEyGt8uP9zvCBlViuqIBZ1doDP5qBdtn4dVX/4fO4Gq1CBah8eb6dWb; 4:8fFPkj4WZwYUUgyDeADE1j3zx8Wtg34kw0p+z6v/EujbKRV38wxVZG8AJxzoVsaJ3Fj6DNTuOw9Rhj5Pv7LhJYATBAd+KOH+DugoBS8+vsw1whTmM7ikCMnoGw9SGv2dIjR1rm5+QOHxWgI8v4lyR5qlZ3lNf6G4OBqDiHpU12MQlLtHTd3IDBsCiEiGd4WZbzUUniPKJBml0kBP5qgmXWV9kP9I0BKlMpL6yovYgHxa8EdPqQnDULXO9thHWIWlR6ovoamXVUMsCE8FE4N3jXLrFeAvR8hUtGDRhFsWnzE0eLFvXfH0J6Qdz73Kd4WQ 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:juLHHv/L4p2OHIbkTrEYOpFiR1am3BMVUEF37Pqnr?= =?us-ascii?Q?6oGCxseeDJVMunN7XwRtQL/lEbGhCmJTgU+dwtXFlxfum46B1BIWcyeMtqXD?= =?us-ascii?Q?T91NbqoE5vxhC2wffjhg6mkikXeXNhIy2yh5SrNwKizWp2Qq3pC8dRzLT7tB?= =?us-ascii?Q?wwQ3Tb0oYmFXiYqjih4id153rHf7yXpl/Jg9LMV+eGbOBAKHsG9tvJY5TVYh?= =?us-ascii?Q?8vU7iGplEawa0x0N2ROggf9ITbz/Rcp2ZN3s7GaaNHx+BPpfggLigVGXvDzM?= =?us-ascii?Q?VWLMFaug6ny2/Ox2kqfMjZSfHK8yO6Zp1zaHkov4Vp73L4te9ABzpZ6MqjgW?= =?us-ascii?Q?mpv4hsoScWFf1/4slheqXG8+O4YrWb5XMG2DhewlT6wxbgoBTwxWBuxZ7N01?= =?us-ascii?Q?4Q6032iDPdAbxou1UpmqtkDC8mL+5X44PPKD9eaYStU215idyj4OQAU30viL?= =?us-ascii?Q?tx4PJxCTvDAajJGLLdpXKC6GNAwBkKG8+ar/BiXrj0ZSajB+V3jCmWARN3HH?= =?us-ascii?Q?X5e2mf15tDOu+seEQ2rW9T1FpDW9YvNVe3V//74VnkFyYOD24fCHoLQ8u57F?= =?us-ascii?Q?JZ1WNfHPqx39crX7/SZ2u31RMLRYbI3fbThXYeZy+IrBdjxJh3D1hYCA2Vc8?= =?us-ascii?Q?Eep1nMl8tJFMeLAhS1/bRYKEIwrJYi/b8SP4NVZPWiQOzdSmb8O75bPPPEt9?= =?us-ascii?Q?ahT+1iniMzcBTa7igyas1uhwZhKPpwVE6M9lmWtc6u36RvuT0NQItHCQK5gd?= =?us-ascii?Q?UxMU38QJrGtbY1ab8/1Xzapy7Fx4u1WS1LIp57HBhJx+3xL5v2uk6OGVA0oF?= =?us-ascii?Q?qhDQdDqN9yWHqLlHeviv4jv9/7jvqVnVVQCK0svNnFkuBy9DGbmKTa6jPX8x?= =?us-ascii?Q?8mHW91C+cjmljHlfNr6imOllreTtNk7MIelrCd2cir11xVTwQJ8fpX2MaOqB?= =?us-ascii?Q?iTBh3y/Akc79T3ZzpQaGF9rvvdIkMsqAARw9/2GcLjPW5nymNMOtEytx8heO?= =?us-ascii?Q?mZrt79c2zkoYpGzVeleEKsPJkKQZWTpMztI3juJgS71lWvIZWlLp/AmFYQO6?= =?us-ascii?Q?NknDy5uGPHFhbI1delbJUCyHo0iPFA6yAJ6xDC6mjXJMK6qEL6dMhSHwo0Hv?= =?us-ascii?Q?O1E7XDF5JGm+NkMFjnRpkv/h2rAsypR7zZhjucmTznxzwfEZr8z/Q=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; BY1PR03MB1483; 5:VQOsp3dQrEf6+ZVGRKHxGsFSla7Wx359n2Xpb6xtydjJWot8WwAB/QR1Uwy7gKmLe6EH31L6uZBNnCjYkYqeSGXF1mkpFLBE0Duq7McPejwuN8ZAs45cMeT6niP8CNZhn8hZKYy4clJtQSyYrLBMcw==; 24:QKy/A1Z2NXEhulRLtZLQFZ0uJfE03+3MwV/7WLbTDqrQykKlIi9UzkBxYcs8tvGpPoMLuU+Rek2hs7cPDI73JoA9DMmbCfCHlrrLvyq1M3M=; 20:nEJfjSGdzsE3lu841J8w2ujQb6fOplsUXfT/rlxzBatbPmOuoelVl7cP/AvbXATneeDat8zJDXHBSe4Wc2sw8Q== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Aug 2015 06:42:02.1271 (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 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 --- v2: non-RFC 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)