From patchwork Fri Jun 19 02:49:17 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Scott Wood X-Patchwork-Id: 6642141 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 6BD67C0020 for ; Fri, 19 Jun 2015 03:21:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9610B2087F for ; Fri, 19 Jun 2015 03:21:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 969ED20937 for ; Fri, 19 Jun 2015 03:21:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932096AbbFSDVf (ORCPT ); Thu, 18 Jun 2015 23:21:35 -0400 Received: from mail-bn1on0114.outbound.protection.outlook.com ([157.56.110.114]:47577 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753395AbbFSDVa (ORCPT ); Thu, 18 Jun 2015 23:21:30 -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:41 +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 7/8] clk: qoriq: Expose OF clocks directly from the clockgen node Date: Thu, 18 Jun 2015 21:49:17 -0500 Message-ID: <1434682158-7243-8-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:qQy+QGbEjixXvPnyhDlmJuo93SrHtxwsGNLKqB5KppQ61pgxmB8bW/I5dXzT6itZ; 2:7qrugbspGqXtyAs1eg21BvqAZBSlui0tVrO9E6SVxRQSXZUqYpZD90auYbIT7ONhvac63riZz4b85c+RWLnBYeGmievcCb1NuTUh5nL7qxuGCfpZAzcbTYT3UF4UpeHwjY5YMbOyA2S+JXl4vPOJsA==; 6:onFELySSkREy+a5NAdovKCkIAjvSoIGJFwwDK5bNcedCsY0K05rvxuIF38824oK/o3mRjvdNkZSNWtk/gTsWGJUkO2TFvSQnCr1ky1u8KdlI/Ilzgz5KKv0CNXVQypEwRfMefKQbM6ERSCLmJcp9HPmlptANIUYsxI+rX6d3yLH6Y5Sc07/d2DS+IYX/Fzpc/mHBdb3iOOiA6X2TCzbbgdPN33Sic1ZhrWRfjSTSM5sBVWx3Oc21So6nZeJdPov2tsY03Xwo1DExaZbLSt1EezuTjBNOJh/8rtmb/+lqboNr3tO68qUeGIn7oSYSwax7DAn1uIapnLFvripe99Zzr8uOzuVClmIGNOBgU67f9lBu+KBC3xdwCDRpvuBU7Zm2FmMixW9/AeUZTsi+rvFcAXnjunsBVVSFDZVtV2RNUjkHB8GHz5d6M2NoUa+DTuAI4QQI6idW4kJLAWkq71wbEywndMciJ2ULNyhT+ZLEUsAgFUajNJwSIBICXm84EwakuMsUB0dU/hcGPLS3MTlluIn726QaAWXUlBqoP2GEnuqCGZFZVkUPpa1NDZm064jxdT/dbwUUWP2RiSLkgxx7vioofLSa9yGPj8DoKCZ5do8= 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:jh3jQsN3P+qV+0eL4PLtJt9EV3mVsaz8CMahPB/4W12eqMBERHUL6M7clQAuKZXtw8tIFLtwAqbFbTMbxee7yhrjzw9NnZFaOCW7IgRfupYrFQAGdHEpDD7Z4ezeRpnH7gAjpu40aRqxvY1xdk/IAzdIdLWlm7i52my6/hqsJfr+mxyf2x99UbAg+GxNPwtZqVd5Z0LBVaNI/mVUUgaQ53dpN/cX6dUVN1aqRd+XLrgc9S7XxRR4Wjuod/DbF1SqIkhnkNkg98aPgeJXCSo/LLjRCY4strc5sdtroVt9pNs= 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:kuwXcIO+9GVa/MAYb5K5kpW3DMTqfd2auL0ZzJu1tM83G8kyVtMaLQurLLdcVCyexoM3CzuDbmHgqxc8uBdtXgEy0Jj/5l3/xt99XkmQ0Jr9RHap/p9+Jwy/W9GJXxSe/lhbuBsbyrt5wO7LFPNoT8kvCDq0Lc+zxdDtRNiE8ftUrDDMBSIcLexbkm3+f5bb/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V0L9bVl5sih X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jun 2015 02:49:41.1193 (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 This allows the "clocks" property to be used in the absence of legacy nodes, and for clocks that the legacy nodes do not describe. Signed-off-by: Scott Wood --- drivers/clk/clk-qoriq.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 62 insertions(+), 1 deletion(-) diff --git a/drivers/clk/clk-qoriq.c b/drivers/clk/clk-qoriq.c index f6aa106..e408965 100644 --- a/drivers/clk/clk-qoriq.c +++ b/drivers/clk/clk-qoriq.c @@ -938,6 +938,61 @@ static void __init pltfrm_pll_init(struct device_node *np) legacy_pll_init(np, PLATFORM_PLL); } +static struct clk *clockgen_clk_get(struct of_phandle_args *clkspec, void *data) +{ + struct clockgen *cg = data; + struct clk *clk; + struct clockgen_pll *pll; + u32 type, idx; + + if (clkspec->args_count < 2) { + pr_err("%s: insufficient phandle args\n", __func__); + return ERR_PTR(-EINVAL); + } + + type = clkspec->args[0]; + idx = clkspec->args[1]; + + switch (type) { + case 0: + if (idx != 0) + goto bad_args; + clk = cg->sysclk; + break; + case 1: + if (idx >= ARRAY_SIZE(cg->cmux)) + goto bad_args; + clk = cg->cmux[idx]; + break; + case 2: + if (idx >= ARRAY_SIZE(cg->hwaccel)) + goto bad_args; + clk = cg->hwaccel[idx]; + break; + case 3: + if (idx >= ARRAY_SIZE(cg->fman)) + goto bad_args; + clk = cg->fman[idx]; + break; + case 4: + pll = &cg->pll[PLATFORM_PLL]; + if (idx >= ARRAY_SIZE(pll->div)) + goto bad_args; + clk = pll->div[idx].clk; + break; + default: + goto bad_args; + } + + if (!clk) + return ERR_PTR(-ENOENT); + return clk; + +bad_args: + pr_err("%s: Bad phandle args %u %u\n", __func__, type, idx); + return ERR_PTR(-EINVAL); +} + #ifdef CONFIG_PPC #include @@ -982,7 +1037,7 @@ static bool __init has_erratum_a4510(void) static void __init clockgen_init(struct device_node *np) { - int i; + int i, ret; clockgen.node = np; clockgen.regs = of_iomap(np, 0); @@ -1028,6 +1083,12 @@ static void __init clockgen_init(struct device_node *np) if (clockgen.info.init_periph) clockgen.info.init_periph(&clockgen); + ret = of_clk_add_provider(np, clockgen_clk_get, &clockgen); + if (ret) { + pr_err("%s: Couldn't register clk provider for node %s: %d\n", + __func__, np->name, ret); + } + return; err: iounmap(clockgen.regs);