From patchwork Wed Feb 8 05:43:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tang yuantian X-Patchwork-Id: 9561827 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8F50860434 for ; Wed, 8 Feb 2017 07:32:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7F92E27DCD for ; Wed, 8 Feb 2017 07:32:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 72E5D28491; Wed, 8 Feb 2017 07:32:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BAC6F27DCD for ; Wed, 8 Feb 2017 07:32:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932132AbdBHHca (ORCPT ); Wed, 8 Feb 2017 02:32:30 -0500 Received: from mail-cys01nam02on0083.outbound.protection.outlook.com ([104.47.37.83]:36096 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932092AbdBHHc2 (ORCPT ); Wed, 8 Feb 2017 02:32:28 -0500 Received: from BN3PR03CA0099.namprd03.prod.outlook.com (10.174.66.17) by DM2PR0301MB0735.namprd03.prod.outlook.com (10.160.97.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.888.16; Wed, 8 Feb 2017 05:56:51 +0000 Received: from BL2FFO11FD008.protection.gbl (2a01:111:f400:7c09::122) by BN3PR03CA0099.outlook.office365.com (2603:10b6:400:4::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.888.16 via Frontend Transport; Wed, 8 Feb 2017 05:56:50 +0000 Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none; nxp.com; dmarc=fail action=none header.from=nxp.com; nxp.com; dkim=none (message not signed) header.d=none; Received-SPF: Fail (protection.outlook.com: domain of nxp.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 BL2FFO11FD008.mail.protection.outlook.com (10.173.161.4) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.888.7 via Frontend Transport; Wed, 8 Feb 2017 05:56:45 +0000 Received: from titan.ap.freescale.net ([10.192.208.233]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id v185uaDp013784; Tue, 7 Feb 2017 22:56:41 -0700 From: To: CC: , , , , , Tang Yuantian , Scott Wood , Tang Yuantian Subject: [PATCH 2/2 v2] cpufreq: qoriq: Don't look at clock implementation details Date: Wed, 8 Feb 2017 13:43:05 +0800 Message-ID: <1486532585-36463-2-git-send-email-yuantian.tang@nxp.com> X-Mailer: git-send-email 2.1.0.27.g96db324 In-Reply-To: <1486532585-36463-1-git-send-email-yuantian.tang@nxp.com> References: <1486532585-36463-1-git-send-email-yuantian.tang@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131310070109279986; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.158.2; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(336005)(7916002)(39400400002)(39450400003)(39380400002)(39860400002)(39840400002)(39850400002)(39410400002)(2980300002)(1110001)(1109001)(339900001)(189002)(199003)(85426001)(97736004)(33646002)(2950100002)(50226002)(47776003)(6666003)(76176999)(92566002)(305945005)(2351001)(106466001)(5660300001)(53936002)(50986999)(5003940100001)(105606002)(626004)(86152003)(8656002)(68736007)(6916009)(77096006)(81156014)(2876002)(4326007)(2906002)(50466002)(104016004)(54906002)(48376002)(356003)(69596002)(81166006)(86362001)(36756003)(189998001)(8936002)(110136004)(38730400002)(8676002)(21314002); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR0301MB0735; H:az84smr01.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD008; 1:9eA7s1dbVDkxx58+K1hAif1zgA0hy1t2USl0v2byUgs2libut7kebc8auYC/NoEgFQNwp/gmoZRFpoivl20Y6J/8iouyRqETC2F30O+AhPT/Mbv3a7cy12YOYBp242pM/vfIJaU4Cftpx/m8IjwzwgkHF1hUQ8pAtlHrzmGLz9i8ryHC8q50TA8oSdmY1oQcwE3owpHLzOSgKOQjXfgg4eIivLwtKnPUBW9bYQsuJ9/wabX1iyNTHzpy7V3BbvViuHZtrQrwBGLjaCsz4cm1a7niQjCL6WR0PfDyWmVwLwEHI48YX4F3Bc5M646slUOO90Ov71CZJHvuUD+wTQagOk8ro1Dm4HRwSlRHUEKOAXXk1wc+rFzLra1cshh/SZlV04ZtZTyJ7jvyuDusRyzcQRockcSdPr6XcvStfIQx6n2TErAyoApjFh0KaTGEnLZa2Dl1Yn9A3YFhKlR3A9Gsnv4igH7aPgniI5ABkTBKugWwu5NhXmTlg7hDR+rPhAjIL5MTuLz9PbL+A9w1DdQ3Rf1JlZYHiaZNcOGEErwstudrRD6LgHiyQhlH8lFBtOLfQ8qAAhwJNhYGI/Aq13MgKzN28/8w7SAJKmiF3k/GeP3GwBwur0y8PJ1IcHKSACP1AC5c7YQPw1su9TJvdchUTG1LVbVVmn/4kNZOaIjwoIB1u1Xs2k+LHB6sM2dEe6EYxNuwUw9d0S7M2+YofJCpaPDWDanmRN96MB3Bz+G6tj+KnsoX9CQQ0O+zxeli3egyUDYxnksxw3rWeO2u1jii8Q== MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: bfab985f-4509-4dec-3591-08d44fe746c0 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:DM2PR0301MB0735; X-Microsoft-Exchange-Diagnostics: 1; DM2PR0301MB0735; 3:x884UPm4tAhKSuWUEeroYiKZCQumC+Rf9JaKYx2lhe7/QWsqr1T10yrj5JBnLSCjDn9mCjX0VMRAjqm55y1bMlUpw7upStasUijSzgeegOILUPlOy7xLbzqGibaBRcH9+6zLDyfg8BFjvBEfA943w++CAus8/aNdTjDneSkIFJODFGr7C2DZRiQvdhp1VCOpVO54bHA91QkvQO04Fv+QYM3irMtPbgeqTx82rdgdMtKshAevBBFzGEugkBUMmIe1SCAbN05/KnY4AtUHI3F8ovrLrE79rVB2+rGXIRcersm+whzGY5XrbHd7KK7z4ghPCl4wv2C5qYdtAHxfw7a4/Hd6nbebHE49UuHxp2sepv4UNMExp98yxRcB43qKrgf4; 25:agot5+Eesu5fhtxbh5LQIqqDieiBoYaPto2KYKTS3YihIcqB8qmbtfwd+CiOyjTxVb6KxcwkVkwuYoMaXGJ55YoSj2oKl8uHdCW23rkiIb/fYS0NVZNDUD8CCVgZITnSe7JD86G27OxefLPABmuntYRoQGT12EHzVfIqENeRdD2WkfSThaCAn2G+CaNt8K1O9PR0hxNUEIExZVcVFTKu3SN1kHQSBnT+0yd7Ic+Cufc6q17AqaLvaAFG0z22hfTJImJS2mb21WjyyIsLKGApzBSjni0zCFPxC2U627HYzZs4LjNB7TE4PdjtX0geDa9XF5HY4guEqGO44bL2HGZOK0/UNAD4GoOmP9OIsS2kZZhroiAZLHX1PqSwjq0iVJ0tfOJq8Mq0IxLP0tVGERJ6tR1BOVVkE7td3SeEfoIKfx0Sr2Oqd3X9Ehe9yEU9PqFVLiE11bI1jwP7B7IH+S8ntw== X-Microsoft-Exchange-Diagnostics: 1; DM2PR0301MB0735; 31:QPLXnbfuWr+PRMHt0JnzuaR5QlsYkebqqKKj7aKrFH9Pbk8fUqZg88ZcpTuSILDsV7wZM4JnfUofi1uZW8DF8phVB4D6LoTLvVtoH3uHigLNc6gCCIb+Pq9XWUX2ftPdMcNp7yH6zxnl4TypYSp5u5s2i5z6YHfQyKtNg4ui4CkqXhi6ScEbhLgkBNSg7Mdzrh1VYvMbZxFeozywBeXLdJCH9Ob9Ygx/oxmrEelpmUZgy+h+32KB5qJP1MyQsezucTwzLcO8yH+hXUHDrNzi3Io/pyt9FOtbwkDhGO+s3C8= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6095060)(601004)(2401047)(20170203043)(13018025)(13017025)(13015025)(2017020702029)(13024025)(8121501046)(13023025)(5005006)(10201501046)(3002001)(6055026)(6096035)(20161123563025)(20161123559025)(20161123561025)(20161123556025)(20161123565025); SRVR:DM2PR0301MB0735; BCL:0; PCL:0; RULEID:(400006); SRVR:DM2PR0301MB0735; X-Microsoft-Exchange-Diagnostics: 1; DM2PR0301MB0735; 4:buC5gEgE2TSuid2xi1r63Ux+Iq5BuEEQ1M9Gt2o7W9RGSzhRlbxSo1W7QKsFUj4q7juq/8VhHJPJh5x3MBtb3xV4Tbb+vE8HrjOfx8vACDp4fYPdsT+93OrKcABI2HwpvTxDFE3RzgcLqaq6t8SFCB8Mh3R+GLEf8KQMx55tPQr/4wAlZ4Adtql6gSkPdjsn1dlWOPdbOrJwycBiSCu3vA7suz2O1GfyLIXQMVStVQBctvVHv1UHJvw56idxoxY454pPk0yuBQgh+ux3nUd8TUspMBRFoRT5VOWMQO6MkfVzqRss5CxDqYCzKXtEgPBQst+aCZWY2eHUSl8q+PZ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qBY+UndlGsuAfdCxtC4G7m446MgC?= =?us-ascii?Q?fwJTY6n1Lw9ybzWAWTh7fxuMyeVjVBTxLLXYnahrwQ0TbXqZq/D6eELrIvjh?= =?us-ascii?Q?by4NJI5VEm3dEYMhVLNM25ZLN8370NJ6f71BjVx/JMGk4etqnInHPqfJo5p8?= =?us-ascii?Q?YsBTz9FKiMa05iFPuyKPtfBWcibsK28wnWTfS8jv43uGRosFGShfX3gfGkhm?= =?us-ascii?Q?aLNwn7nsmAcdfh4HZdEE9QI4wjqXgtz9Qqr3FKLsM+RjVokbrhAWwjxWvmQD?= =?us-ascii?Q?0anMFgJHja9apPMhOOFWKavbznV1y2MS5qvec82UpABrj0L10NunRxHaehc5?= =?us-ascii?Q?tmB20eMV03KXLWhwfl0IIdZ3K14u6Is9o5+Ne71MpEScOK4np41P95qQoInU?= =?us-ascii?Q?AdbDSCS7amY93vVcOQlPIAPjfBQvqKCNPAjmlAA+op3ZmdVeNUSXgaRaXQXR?= =?us-ascii?Q?1/IqopThpTCekMPe4DOC29X1vsGQz8bUypVd/YATPnkYTa3ToftODrrr5+oB?= =?us-ascii?Q?52OGEWQxj4ft6qdl5v2DAv1ZXOtnqgsmAOlk+npT2i0DikpWCzweFB19CSyD?= =?us-ascii?Q?tvCdm8Aez2s0Ov1vD0dzWH6K9USjw2khrrv5PLXQdhpEwRXLdXG7yJ6Ew4Ti?= =?us-ascii?Q?H0OPlAaMcExpGvauWYAdWcZ07bS4Lvl6i1RPBTQzKzWIXJoAPYbiRR8B9CqK?= =?us-ascii?Q?6CJ2zR/d8K5LeLDsZadZ4tWZZFUiZ9OF52a+m870RT/0e5rdie0d+/gVazjI?= =?us-ascii?Q?ntZdYtuj1+Q63edduDKYvTLfylKIygmIsqwanPuwVuYT0hb4gy1nzTrnIHmc?= =?us-ascii?Q?5a/apLBohlSTV1AZi51YbEsufr03Vl68kQcjS8/R/aEdgkiiN8l3rXJlSOk1?= =?us-ascii?Q?fJPMqkahMz65HeSRhvkmb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fGW2D01HFtfovu0f15aTNQy4wICvGFtWeOG8wdTvVNVICJXlqiSY0Qkdsg6KeOsdT+PWOr42pP7KW2VEEQAXgc6NBHpQOHcIqPocuFEjjprCbd4PSgqmB9nkcqQ2AJsN7rtyGZbYDILlDOpH135D5D23hCBhYZo07WvdIx5MUEmp5Oya+5cbxAgqQwr5RjEk/dBBIerWKS/uLORQUI6+jLOe2+1mJkHw+HuVhEKQW5IbWNUnbftwNmVEVKaKuYMC5cu62aCYD5QDoP6gPCqfZWQtfdd0r9ejyslrrBQY/cRpEC4g7w/LIclv2wotk22WzLIYX57WM9yTB9DgMhYwo7vG1sYt7ACWZWCYeIjS364q5EufQVdJo6eZMP9T2rT3fp6CknczdP8sSEa3uGLui6drBftEbmasR4amPH0WrvS0w0vA== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Feb 2017 05:56:45.1091 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.158.2]; Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR0301MB0735 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Tang Yuantian 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 now that 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. We can now rely on the clock driver to ensure that the mux only exposes options that are valid. The cpufreq 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) -- and the frequency mask mechanism made assumptions about particular parent clock indices that are no longer valid. Signed-off-by: Scott Wood Signed-off-by: Tang Yuantian Acked-by: Viresh Kumar --- v2: - added more soc compatible strings drivers/cpufreq/qoriq-cpufreq.c | 145 +++++++++++++--------------------------- 1 file changed, 48 insertions(+), 97 deletions(-) diff --git a/drivers/cpufreq/qoriq-cpufreq.c b/drivers/cpufreq/qoriq-cpufreq.c index 53d8c3f..eee83c1 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 @@ -37,53 +38,20 @@ struct cpu_data { struct thermal_cooling_device *cdev; }; +/* + * Don't use cpufreq on this SoC -- used when the SoC would have otherwise + * matched a more generic compatible. + */ +#define SOC_BLACKLIST 1 + /** * struct soc_data - SoC specific data - * @freq_mask: mask the disallowed frequencies - * @flag: unique flags + * @flags: SOC_xxx */ 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, - }, + u32 flags; }; -/* - * 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; @@ -101,9 +69,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; @@ -112,37 +81,28 @@ 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; int i; - np = cpu_to_clk_node(policy->cpu); - if (!np) - return; - 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) + if (clk_is_match(policy->clk, clk)) cpumask_set_cpu(i, dstp); - - of_node_put(clk_np); } - of_node_put(np); } /* reduce the duplicated frequencies in frequency table */ @@ -200,8 +160,9 @@ 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; + const struct clk_hw *hwclk; struct cpufreq_frequency_table *table; struct cpu_data *data; unsigned int cpu = policy->cpu; @@ -221,17 +182,13 @@ 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; - } + hwclk = __clk_get_hw(policy->clk); + count = clk_hw_get_num_parents(hwclk); - 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); @@ -240,23 +197,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 = of_clk_get(pnode, i); + clk = clk_hw_get_parent_by_index(hwclk, i)->clk; 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); @@ -290,10 +235,7 @@ static int qoriq_cpufreq_cpu_init(struct cpufreq_policy *policy) 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); @@ -357,12 +299,25 @@ static struct cpufreq_driver qoriq_cpufreq_driver = { .attr = cpufreq_generic_attr, }; +static const struct soc_data blacklist = { + .flags = SOC_BLACKLIST, +}; + 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], }, + /* e6500 cannot use cpufreq due to erratum A-008083 */ + { .compatible = "fsl,b4420-clockgen", &blacklist }, + { .compatible = "fsl,b4860-clockgen", &blacklist }, + { .compatible = "fsl,t2080-clockgen", &blacklist }, + { .compatible = "fsl,t4240-clockgen", &blacklist }, + + { .compatible = "fsl,ls1012a-clockgen", }, + { .compatible = "fsl,ls1021a-clockgen", }, + { .compatible = "fsl,ls1043a-clockgen", }, + { .compatible = "fsl,ls1046a-clockgen", }, + { .compatible = "fsl,ls1088a-clockgen", }, + { .compatible = "fsl,ls2080a-clockgen", }, + { .compatible = "fsl,p4080-clockgen", }, + { .compatible = "fsl,qoriq-clockgen-1.0", }, { .compatible = "fsl,qoriq-clockgen-2.0", }, {} }; @@ -380,16 +335,12 @@ static int __init qoriq_cpufreq_init(void) 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); + if (data && data->flags & SOC_BLACKLIST) + return -ENODEV; + ret = cpufreq_register_driver(&qoriq_cpufreq_driver); if (!ret) pr_info("Freescale QorIQ CPU frequency scaling driver\n");