From patchwork Fri Mar 10 01:28:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Tang X-Patchwork-Id: 9614469 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 87FBD602B4 for ; Fri, 10 Mar 2017 01:43:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7A0A3286F1 for ; Fri, 10 Mar 2017 01:43:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6ED97286F4; Fri, 10 Mar 2017 01:43:19 +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=-1.9 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EFC17286F1 for ; Fri, 10 Mar 2017 01:43:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=SnTcRWod5vyND+J07xWOWWyy4WqCf+8wR9PP6KbG2DY=; b=lW1t7vXCErAQmc ch535R9/pi55iZYUW4AXGGU7Qm44aPF790wMFLydDSKGP+7yxy7QlYeKOOLnRfwwgucDEoTnKgKAJ WuL2RbcUSWxhUrK3IAqBXWFnq7XtY/pnfq3V4PlBMjUiU3Z4iH81mcA3elgCgPLtwQ2nFKsxA1Nki 98/nm+NfjWdeNgDIZtUojgrxv4z61l4q0CGctRTiB/Bzp1GU06CxvEOSsnI3nz3SoUKohIR9G9G4r ASHISCYVAkyziNUmbpxcASxmm/TLxrbG1KhFfWA6J4+e2SxQxn77n9TAAsSb5szYHdSulcSQ5skMQ z21sMC5ynb/OMuAAbKWw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cm9aN-0000V8-L0; Fri, 10 Mar 2017 01:43:15 +0000 Received: from mail-by2nam01on0042.outbound.protection.outlook.com ([104.47.34.42] helo=NAM01-BY2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cm9aJ-0000Rx-HI for linux-arm-kernel@lists.infradead.org; Fri, 10 Mar 2017 01:43:13 +0000 Received: from DM2PR03CA0034.namprd03.prod.outlook.com (10.141.96.33) by CY4PR03MB2949.namprd03.prod.outlook.com (10.175.116.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.947.12; Fri, 10 Mar 2017 01:42:49 +0000 Received: from BY2FFO11FD014.protection.gbl (2a01:111:f400:7c0c::161) by DM2PR03CA0034.outlook.office365.com (2a01:111:e400:2428::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.961.14 via Frontend Transport; Fri, 10 Mar 2017 01:42:49 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=fail action=none header.from=nxp.com; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BY2FFO11FD014.mail.protection.outlook.com (10.1.14.76) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.947.7 via Frontend Transport; Fri, 10 Mar 2017 01:42:48 +0000 Received: from titan.ap.freescale.net ([10.192.208.233]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id v2A1giaJ030777; Thu, 9 Mar 2017 18:42:45 -0700 From: Yuantian Tang To: , Subject: [PATCH v2] cpufreq: qoriq: enhance bus frequency calculation Date: Fri, 10 Mar 2017 09:28:43 +0800 Message-ID: <1489109323-11424-1-git-send-email-andy.tang@nxp.com> X-Mailer: git-send-email 2.1.0.27.g96db324 X-EOPAttributedMessage: 0 X-Matching-Connectors: 131335837692559678; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(336005)(39380400002)(39450400003)(39840400002)(39850400002)(39860400002)(39410400002)(39400400002)(2980300002)(1109001)(1110001)(339900001)(199003)(189002)(9170700003)(38730400002)(50986999)(4326008)(105606002)(53936002)(106466001)(48376002)(5660300001)(356003)(50466002)(47776003)(305945005)(33646002)(81166006)(36756003)(54906002)(104016004)(8656002)(2906002)(8936002)(50226002)(85426001)(86362001)(5003940100001)(77096006)(8676002)(189998001); DIR:OUT; SFP:1101; SCL:1; SRVR:CY4PR03MB2949; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; MLV:ovrnspm; A:1; MX:1; PTR:InfoDomainNonexistent; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD014; 1:MlvAyPIXSzW8s7m1ha+BsOC1Xfiy8Ml7vs89VReK/pvHTcf7pXV4zCH+CI93Y1YoUoa+0ubGUa83fAFTDhzngfR3fYD3wEsh+OUXe3tUoGp334Ww6ROlsFLxf+sxLKtMHyYP+/GVkU0Xe4S3p5oyYt+inaByMS9OQa5mqkSVdPMj2c5hB7qvcMzNSKq3MTN8kuoVF6TKOwTJjio9b3td1CBtTAarXYXO3kELe8Y+RpcV6kUj1heiF3fljCmMI20u9NeS/p28+ZsCVQ9LOvAhwKjJHNAujHOJLYssD4I/vdH7WYi013RG+ckmz5kCK5WasvZd+aZ4gkddjvyXczuA5XP+YQLZ0h4hJjVNC5bF9oD7kwUeE/zTxEDoSOyTapwJs8xRdNtAezPufLv8rTrssQ0Fqp7Q27PCSeCE2An1+qZ6Wn7+vJRVt7bDxZwooaVUMrGUtQLNTpN5rFYwES8eOqveOranq7PcwZ0BDNDNCjtNX5DffdBRbM2JSmjVimRezWVRdlU0fxUyr/M7IssVHgkAtF/HSBRzfkl1r+nd65OPXYVodiWpT8c2mIFakZ5Xv37O8cNJlL3Revsa4pl1Zj05e/JyH3HAR3mD08k0NpVzxdz9pZvnqnsBY8BM9flV2hZwD5m+So0V+HDhcY5VKQbckyp6pgNjDkMI4SDHi54N5pvF71+nMDU0kKH42jMxqz9mJhl3rspAEBLnRCyRhQ== MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: cec1d16c-7be5-47e5-7636-08d46756c255 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:CY4PR03MB2949; X-Microsoft-Exchange-Diagnostics: 1; CY4PR03MB2949; 3:xY7eRw7CjJQ6YrQPk5j0HX/tkiqwvB2Z4mmHUk0milHq8yx5lMesmMVaIdH4Yl8ZeqaQcBrkCbMbEDdJskaOf2p3jNoN8S+Hb5tCKwfuqWarVq/SUOve8MBAShvBDGrP7oOK+pXrmdmk2e9RjTm5+mgERxsHfybva6Sqyylke6mLO4HGlZJ3tnBWUlbV5O1XTyRqxR3YpsSct+en0kgKlUvX5/6BqEJxBIdl1DphQ8NJClZd4SFeacvXJnV7zQuxkiz7E6/LcsP9rXe+WPDuCTW/Hh4dJHpLDNMuKRw3otVv68TSQLFURX1f+DV3K1ahx8a/PMXL6+UKrJfVpG7qJTIO9NnRXEYOLIz2MezLnbpUUfzWzfMFQddfBIn6oG6s; 25:0SaHdf4qG5Tfdzho8HGs2yUq2Thwcecqog9iwJNASwh9HaTa8i79tumtaTXWu9bxPER3V0WCFtiTwkBfNESoJwhsieBk3UgE9/zi4AHOTqqE7ulig7zO/G6wqXjQnc5WmRw0xRJHEE99YqJBwNlzCPg+D28Uo8IuVYnj5aBQXAfibKlMC9nes3/8EoZcR67le5m3/DyQ0BncI2CymcL7m+/Z3Hcep0WwW5bm1YJ51MGXEXJQYFWJjPtth+MU6cvy5ev5gfno0Hc8QgoUb3nklhBulU2Ml1E5pbkg67cftjqOLCIJsRDNK+xi4z9G/qgiKkPESWAoqz+PJMFB3HcqnID5K+d94lFIlyD2SlSmFnGRfty3FcBG+Wz5oav80EgcG4Y09kkQzf4G660mcW6dz8RYrRqi7W7HKrEgHMf0vkyKQa29uOZC7XmAsubZ7sBls1voA4Mi9qxD4nrPIWtNsg== X-Microsoft-Exchange-Diagnostics: 1; CY4PR03MB2949; 31:OzcuZHRX0hwV3kQ/rakhne+LGj0a6EsJOt1au8y11WOMq0hEYOrxHhL7qz86T+WaN4NWPfKLAByJTwAFyAMr4KK5gMzcvNtlepFVh7Cf+4qBTXid428EC1iUbrgnduZlTq4vFYWazRj7wb86qylQcoGB/iELb5HQmzBWuNmVf3uRSdE+GwQn3q0XEmHeA98Aaw0puB4ZrxXAnw/DyMU8Y89bem7zpXURWghSmv8Us+u5hLCkbQjdmO9jYqt2G4ZMg9fkTETyNtmj/A80KUf8iUSLjFALlJVG8GzUOBxR91A= 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)(13024025)(13023025)(13018025)(13015025)(13017025)(8121501046)(5005006)(10201501046)(3002001)(6055026)(6096035)(20161123563025)(20161123565025)(20161123561025)(20161123556025)(20161123559025); SRVR:CY4PR03MB2949; BCL:0; PCL:0; RULEID:(400006); SRVR:CY4PR03MB2949; X-Microsoft-Exchange-Diagnostics: 1; CY4PR03MB2949; 4:BslqqYuGNJUQYghXPXyxF0q/XQlhoiF5V8QTDU5GYpQPs9hki0wIglrHpeWgyYcEKHSe4EAZOLQO3sM/9RZfQSgFw6ucgyN0EBp3nq/+wR3TX98k7bGAhhB7f3S/DpLoqn+KlzN1sMCBNKKyBTy9zNv53BmafEzdNxieAw1Mo27/mEiHyI1N/u88g+XUhi268LNfXey64HdaQO9+zjcnulzUx6jaWHjT6pdcN9qzR1uL6A9ENsT/xGWDPCbIPnv6zVuEPEu/Tq74DYno71ZOornyWYwH9iHsF9pJo/wE7SKHZyHT8UQkoFHnvzcKEjhdkpUOakk0Bbp6I/7aAT8QmxJyo+t7JuZHtaTPPTDL45VfkooPVhPX7719WrE5ISxirSHsayWAYAJuOGhNA+APexDm8FN517Al0wAqf7CzN9ezbGhs1v+ulD9TXjryNgr9oMoXrAt2cS1LdeWHPWorfSv3WxxnwQNaENmZp7rFhDoK+AGPQO1e0i4MdWH5CZY7O420Sv+oR8KnadCUdSwe7RlcE7U3gbT9BIlMaf06VhRJOhjoMit8w1XeCl95gufDKg8HwS3W2KFgz5mfbf/RDEH0zjjurrObmBtyW54ZA3JTzf/ycsUou+HY4wqq4ES9p1z2PjhxiU/Aekc4AC9+ZAoq+Qm+i6JNoMvkQ3SIaulevqf9goKxUdRN4rUcaYdf2tTMbV7M+YyWI3Y4/9/wMUM6oU1Tp0KYYGvG72jnFGwyiSlt+4VxoyRzQgCDWbsD X-Forefront-PRVS: 02426D11FE X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY4PR03MB2949; 23:KnK6pTwtQGm09jf+aO0dnOsWZDc8rAIWjyZx7/IEp?= =?us-ascii?Q?dYhgrD5WOUnsyf8Cu7F2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Zzmn?= =?us-ascii?Q?ZjVxd2dlAKun0+mwEXACHJ+JlPdEkQONj6peAkRYu+luFdXzEial0aqt/uaT?= =?us-ascii?Q?TI0/54DfgjjmjCBdKmcnrMR1Bb1AgtvLAdd/p6uFXlHMaclXg8iw3PWwrVIS?= =?us-ascii?Q?txebki/lBRwEhiCwxaON0medLEXzvYh0wBelrvR+W0raAooMw=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; CY4PR03MB2949; 6:pP3gEJ1TNuOOxMUJ1xmEnln7hgae5lzzxSQG+OsRnU0MZPC6DQV3M4hq3fT1f+DxGsYcozM5ND3hi4YWvwTNkljXOsH/v96M10M52dnWwmVUvu1O7sAEWtrr1JcRQEMMm88wTbaUlIi35lkKydQawIesajNri+/dtP59b1U+j1HG60GxTO1ka7VW8glrn11XVZdelm7bpnLtHw8KLHwWJqgXO9EcdXfhz1HEYuzX699Og120VK5+7nVCCqOFYwlgu+dWIw3kaWX2QkHybnvU0vYCdf4+jANnpu04DRLu52IcyBlJjz8Nga70XH9Gwj64ETsFiTrBGXQ3mdlev77Cj6bGhswL6AKJ4wtzmefD5HBXDp6yGllQEYVH4h9K83bPRvm43b38P1KVXvTFPR4bb5kMzXxWvbyzpYFhKxJDRNk=; 5:Oosm1wSxlB5SOk+Jx6iI0Qxpv4P4B0X+JbdMIrOapuv7Zbe8+3Pzq38DQY0SdZkaw0l6i6x3cjkU8DCN9kN19xYKb/XsY8puDVpJZ19m4lLWU67OMqHab52pK+dGY6b8/JeCkcDTHHHvVnurFDfZ5sapiuJFTL984WPNALQlHEvULz1Hg1BJeBdzHAbMCirb; 24:Ogv87lUGwyFGVZLnXNKzPL1NeLU3URuKrEYaxSx+19pgBOB3GBizJ2GZI9ZlUaKHUevvNrJOkcf54nwdHbnZqvXu/ITtMkN+dhsKWLM42hY= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY4PR03MB2949; 7:6ZkvEx7sEsCBJRTYDZvYu6D0ESnJkci0DodFtlqm6aTa2fOl6ECOxmhXDBrINe+2eT1p7BqLU9li6I6ZT2zfzOJskmFq3hlrxAZ2Gl1onlpSuYSgnVeWV48ar3XGzmbI3ekqMxfEweP8VN5gYMLgnzlt5iNI2cArND8zHMSkyYyEJq8TETQLhtcc7cmoX9vXp2ccgRH3bpH9fC+b+XMmIBBCbmMSdOseqmr3fzrFl234zcm+3yG0cukSBmMmcozugQBdFM6Gt2W9ch8YD4y+pYcdGDGJqEOPjFl2AMVb5X/MYgm+HInj+eWIo713JXwVc6BtlK7Dt7OZYLiBxGglyQ== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Mar 2017 01:42:48.9283 (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.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR03MB2949 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170309_174311_630086_C35E92E7 X-CRM114-Status: GOOD ( 15.02 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yuantian Tang , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP On some platforms, property device-type may be missed in soc node in dts which caused the bus-frequency can not be obtained correctly. This patch enhanced the bus-frequency calculation. When property device-type is missed in dts, bus-frequency will be obtained by looking up clock table to get platform clock and hence get its frequency. Signed-off-by: Tang Yuantian Acked-by: Viresh Kumar --- v2: -- fix alignment issue drivers/cpufreq/qoriq-cpufreq.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/drivers/cpufreq/qoriq-cpufreq.c b/drivers/cpufreq/qoriq-cpufreq.c index bfec1bc..e2ea433 100644 --- a/drivers/cpufreq/qoriq-cpufreq.c +++ b/drivers/cpufreq/qoriq-cpufreq.c @@ -52,17 +52,27 @@ static u32 get_bus_freq(void) { struct device_node *soc; u32 sysfreq; + struct clk *pltclk; + int ret; + /* get platform freq by searching bus-frequency property */ soc = of_find_node_by_type(NULL, "soc"); - if (!soc) - return 0; - - if (of_property_read_u32(soc, "bus-frequency", &sysfreq)) - sysfreq = 0; + if (soc) { + ret = of_property_read_u32(soc, "bus-frequency", &sysfreq); + of_node_put(soc); + if (!ret) + return sysfreq; + } - of_node_put(soc); + /* get platform freq by its clock name */ + pltclk = clk_get(NULL, "cg-pll0-div1"); + if (IS_ERR(pltclk)) { + pr_err("%s: can't get bus frequency %ld\n", + __func__, PTR_ERR(pltclk)); + return PTR_ERR(pltclk); + } - return sysfreq; + return clk_get_rate(pltclk); } static struct clk *cpu_to_clk(int cpu)