From patchwork Thu Mar 9 08:15:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Tang X-Patchwork-Id: 9612697 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 F1F51602B4 for ; Thu, 9 Mar 2017 08:33:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CC0D0285AE for ; Thu, 9 Mar 2017 08:33:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C00D6285D4; Thu, 9 Mar 2017 08:33:04 +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=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 2957B285AE for ; Thu, 9 Mar 2017 08:33:04 +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=4BmD4h95r7OJci+ATE/6aDOL+Q+MXSN4O9zBLecLG5c=; b=kgDm426r/5xv2u x5ITCkBjG+MjQLroS9NlrRck6HP9hu5Igoc8Ml+2mCnLp3z2eaIRsb5uC7H+6a0c64uhrNVNxmBGv buOZLyAVTmNeaMpFqIqBock8Lzz5EpJovB8VNFS9CnYNrl1BmsPOs2X7l2DRfmxnzkLPCIqlZiCUA /pZ6BlFfJsGN9yRFbIGybcdVJoEqRhvxgWXNiM3cqEwqSTgBVpJNHSSLEH7GqNhIa0vl9bqhS2dsH WTZzFv/fmZ19+gRmVL7kvJH1FNCXmTdobNsuXd0F8yV4lUptP/LqpKQICbCeHNVUDLpL+JVNdLx3Y gEzdYJgeS4x7+OpYjiDw==; 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 1cltVH-0000nI-JF; Thu, 09 Mar 2017 08:32:55 +0000 Received: from mail-dm3nam03on0045.outbound.protection.outlook.com ([104.47.41.45] helo=NAM03-DM3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cltS5-0005JO-Mg for linux-arm-kernel@lists.infradead.org; Thu, 09 Mar 2017 08:29:39 +0000 Received: from BN6PR03CA0033.namprd03.prod.outlook.com (10.175.124.19) by DM5PR03MB2954.namprd03.prod.outlook.com (10.175.106.140) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.961.14; Thu, 9 Mar 2017 08:29:15 +0000 Received: from BL2FFO11FD050.protection.gbl (2a01:111:f400:7c09::109) by BN6PR03CA0033.outlook.office365.com (2603:10b6:404:10c::19) 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; Thu, 9 Mar 2017 08:29:15 +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; 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 BL2FFO11FD050.mail.protection.outlook.com (10.173.161.212) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.947.7 via Frontend Transport; Thu, 9 Mar 2017 08:29:10 +0000 Received: from titan.ap.freescale.net ([10.192.208.233]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id v298T6XB031995; Thu, 9 Mar 2017 01:29:07 -0700 From: YuanTian Tang To: , Subject: [PATCH] cpufreq: qoriq: enhance bus frequency calculation Date: Thu, 9 Mar 2017 16:15:06 +0800 Message-ID: <1489047306-31818-1-git-send-email-andy.tang@nxp.com> X-Mailer: git-send-email 2.1.0.27.g96db324 X-EOPAttributedMessage: 0 X-Matching-Connectors: 131335217554370767; (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)(2980300002)(1110001)(1109001)(339900001)(189002)(199003)(9170700003)(105606002)(47776003)(53936002)(8676002)(8936002)(50226002)(50986999)(77096006)(86362001)(356003)(36756003)(106466001)(85426001)(305945005)(104016004)(8656002)(38730400002)(4326008)(54906002)(81166006)(2906002)(189998001)(48376002)(50466002)(5660300001)(33646002)(5003940100001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR03MB2954; H:az84smr01.freescale.net; FPR:; SPF:Fail; MLV:ovrnspm; MX:1; A:1; PTR:InfoDomainNonexistent; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD050; 1:bjyjX7plsUipPViCNrKo+Mvf5H5TUrwYR8NvrgAOAiXeZOj0ImEkqvHZvl+6lWDGmuzDaxpw5LDtLSM99EiGSb1MSLJw1K6BKUUCE1iFD+K715F6jrTA+vPOTPzffpEI2TbI3usnES97/RkyTwOudTfqq3GiubxplM59mhw8DtLZp5BhHo2jJtDia+/zoh8dbvVHCQ52a6Nvr9rcN1+SRUFGW4SuWKWpVi4MXoj573jkNHG1sjyJnpCiqMiOZVHKtyxLLNfojk2RE252BA9EM4NR+9cdSSdbwr0+kcUEpvxSJweTll8o85e0byfAAoA4NxzaymbAcPIITLjtI3lw83RSjqPMVxnNDp7ltqyrsmXp6ZRU5TnDuDBQeYXS6TiS8ytYXjQdLIMLnTCPwZ5bw0d7YHDHNnR6B50Dnrtxu24h7YTw8JrhT820ou85Tk87iY6bd6jaWYwQGM6y/26B6puzijTXtiRwo/cZHOEEC0QWceSMBnCjf8hgFSdPD7yg3QOXqiUJiZxS5LQ2g1OrAXIywVRZhYhCbBanl5/JtG1xAW7Cnvb+buAq20T56ZF+WCSijAACY1YDu5UkoU3Lea0WTy0zw3VwQXpis3mCjwGBXcpnL9TP//su6USbO9WjQ6GGmiW4cHkoX8PylZefwRPlOQ/os8Cgx5/MLmDm2o4fitrTSHwuRN/Qn7Po8QRuk5/De7MDx3S7sxKNdHf9Gg== MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: a6d56fad-1ac9-4bb1-4f71-08d466c65f48 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:DM5PR03MB2954; X-Microsoft-Exchange-Diagnostics: 1; DM5PR03MB2954; 3:ayQklgoCFWXM9/38CJt6HEKmYWOHfpmYnAGE+e9OpGzZ7CV+2Kf6qrsv62RdnizBR9WyfxLoSzoQ75Iis7ZQNy3Lse7PFth6ktTXaBAmnI6XRCEjZzYaQYBS/DIaZ1VALBq//uvu4NpIDcBjiW8JPqojML/p2Mll7iK3m/q5JSIEHrJvSeAm97Pco4sSHj3T9lJCR53SaE1PX4OgO5tecOAYndcpRM47ySH5YTib4hBsaCfkeq6hnEgcxDrH8TaXKY8Qn6HzzNDkCEAEr9T5rE4Af2X/6jYk+eHWeLkQAdkiCXekkmxXxlLCi5EUs+SvIwvgueLe8KnG6RkH3OQRJx7jQPE/pajXkurX/r0TLSg=; 25:EhLjJfaPk2YV/oh2apgmpU+dUmlZn8rUsn3X4ZM+dkVKnqWBquZ0nN5AvyhonQT/YV1ny6tjMXchxx9tTghUcjS3t1LaOB09ScnXvG8yyJgzz9aelmBlkT0RkxWVY8pWvAEi0UzbTMvKniKwXxvzZfD2DqOVeucPd2ZkfXS29BDI20S3ww+qLIRLNiVBZmdT4lF6UTQs+U1gC5eI1PaMBjymNUkHb6CZFpA49Z2cPNQsJkRT1D8rwKxOSWksAY2NLe2zgxiM86o3WO1kL3awNlp2+XbsCnXRdOfuqpb9saVbw4NxvcGlmxkIcXfXlg06eVsPcF3Y+nQLptRckP/oigHZ8FBJoq2hrtheP5hPTDHODLcU1Mg9CFyp17EzpbGNoGss1UsvPp1+4fL19vyV+nEzchYzAu7+EruGBCouEePQZbNGDL/DzqOCiWA5AM/i8DHlG+bl9sZgKjIr/r7OsQ== X-Microsoft-Exchange-Diagnostics: 1; DM5PR03MB2954; 31:InzFYHBfSwmgmZBQLrYUQGHljTw7QYnKLEmky6hQ2ctzHipjxSqnkr0KjIJN4TLc36Gv9b6MdJNudz5KNeqMvAev9GnRCqs6WqG7ZUkzT+jDXV3gmin43RE/q0wRU9L9lOjpOF/kshTprM/Yw0uDdhTK85N7Z79P+AkrKUiAldcdOxyZEuz0saWxRQtvYTfT4XUIyF8c6qVedUV11IeUinGfR+vQaluIzT8jNBDH+J15KVPHtBjG6Nt7IZ6VE1YYCKsejTCuGXXsWj24AmI60Q== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197)(204673448043490); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6095060)(601004)(2401047)(8121501046)(5005006)(13017025)(13015025)(13024025)(13023025)(13018025)(10201501046)(3002001)(6055026)(6096035)(20161123556025)(20161123563025)(20161123561025)(20161123565025)(20161123559025); SRVR:DM5PR03MB2954; BCL:0; PCL:0; RULEID:(400006); SRVR:DM5PR03MB2954; X-Microsoft-Exchange-Diagnostics: 1; DM5PR03MB2954; 4:ER40D4F6ZC6TYdqwOduEa0+harqDgk0U29POh/zMcHibLTZW44/bb88yVol5rBz7yf9O2z4JBdTJ9ucMxOBFQ5dNluPbJd03U40wvuyOJyfCMd3+bbxMupagEOQn2BLID4RTrA7qe9DBVPuj36r6JZkA6ubDdhqbEDPGqE+6pRaYGkwF3l8EjDaOnRQI6ssY7oNRyNThF3DbGinxP9gVOx0uHySBNqpasfdXiR6TTXW2OqJEpE2QQ0IKqB6gzUq7gjq9GsNacXyO6SI6GgEiZ1aUNYzHOb4ibLK03df6GDbeMzBhIVpI7vX1wcoqEC49ZJZW5JpgVo0KvVRoGuMaifGagzBRHQvrh0YOL3wMbkfOweAnZ6XU7576w9J7HWOt85KPHlzHZJwAEX6lbyMAKtXzSdrT/n9V3wybiEZbywvWQBsx8hzrTPcngt5tQXa0sY/ytgstHHMrAUreg1+LKJCioRzZJJHaloTV+IcjfGulI3XvL396irpgFUEjqUq5MtZZle/LCJZ/iV/GYO/4Cs50Va0wvNc2Ewt9lYX87rOadFbMbFjqoZ0KvUzWf2XkQ1sa32D/MSr2/bqjv6aTV/2bqF4uISWzRWjGnW49j18jw8jfmAsx0RrJRyw92LVqdWhAeHIgCzcSxJY11p2dbNglbF2/f5tGDFLsb/j2EPAouvnGnk+1MHsDnkhhyuQ03sUtZAkjY+0xsDzlaLUS+oYryeNxyIZvunRfAShD8QOfLrCh/bkAOOPPwQWMBuwWRE8K5tGcaBjW3QUnYwZ12A== X-Forefront-PRVS: 0241D5F98C X-Microsoft-Exchange-Diagnostics: 1; DM5PR03MB2954; 23:clrQgn9t+dH39xUJItK6eX/VxORWPb5x8TYikxWqKKG39V4AhzxlmveoaFGb+Mlz9vWRLJ+y59Si6NnM91yE6mMI3Y3jyTXchU2pKVRF4wIDsrgBXec52h9/ia+Q6wkgFt5bKUwpdTz6ukHRp+HPjqWpVxc1Slbg2NkZe+qJ96zCi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PsG1TEvl44HYwNk5GC0TT1ASBEwQCQgDa7kFDmiZYCYMyDZDnisDXhQoQHgAbepb30yTNtSa4ZpghB/x+TLmaOFX2VQQ3kAb6/Dfvg6RMy5HAGb5D5T2zcvwdhIgwY+0=; 5:g7VN3ZnAiQk8lgDk+0yQAAtb4Dd9aqlYwMhUhcjFieqcCJUjzRy3RNSDe1ll6WFxU8e86CTCQa02oBP7HSUUfocLidVJUJy+73sB+Ys3tueW/EnUy9y0e0w8rQL6ZfG0/SEn7MfnFPvZ7GfB8L2bmiHze0UwGxEVymLEyTo5RUnrcJQdbfJDvZTmtVhFDCsf; 24:hPIcjWjuTTxq6dRTrvTYdPsCGvpz1YozKXugmsKpuT7XTu9fVPf2qhtOjTxMRYB2xl3ON2xOJaMGBiCcXScR6tlOIBYepmxY6AIG12LULeI= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM5PR03MB2954; 7:VtwZvsoRszNPLdGDgTb4uB8k3r4qw7DJzOgS41NR2jd4Eot2w8s0Gs1ltnW2Ncikqc+Y+KMR7odo6OQbI5s3x5kagZ3NbOx1FDWASciLFyXlNpeeYGvgbPGoVwsoHMHfo3u6iIiymcJg5fN7FzZSczB7mihM9xaeISWpJ6i2Bs89xSplNbQVyHp0tUPzhwysR0sCVybKeTiuRzVaityj1BJAHuJxxEYoZ41FX0T19wkckQxgWoCIpZuW8TitKSnxN5GLr1ZGm565wUkFdCyRgSIo4RWmhomDmYZR2yb/W5G/mMw9o9U2qxRbwMGLHgN2Mwms2QSvm12mv3JSWVlexA== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Mar 2017 08:29:10.0863 (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: DM5PR03MB2954 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170309_002937_851475_23EC5EF7 X-CRM114-Status: GOOD ( 11.97 ) 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: Tang Yuantian , 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 From: Tang Yuantian 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 --- 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..0f22e40 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)