From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755367AbcBEQDJ (ORCPT ); Fri, 5 Feb 2016 11:03:09 -0500 Received: from hqemgate16.nvidia.com ([216.228.121.65]:5131 "EHLO hqemgate16.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752891AbcBEQDH (ORCPT ); Fri, 5 Feb 2016 11:03:07 -0500 X-PGP-Universal: processed; by hqnvupgp08.nvidia.com on Fri, 05 Feb 2016 08:03:41 -0800 Subject: Re: [PATCH] clk: tegra: Fix divider settings for Tegra210 pll_a To: Jon Hunter , Peter De Schrijver , Stephen Warren , Thierry Reding , Alexandre Courbot References: <1454680897-9464-1-git-send-email-jonathanh@nvidia.com> CC: Michael Turquette , Stephen Boyd , , , From: Rhyland Klein Message-ID: <56B4C7B8.4090402@nvidia.com> Date: Fri, 5 Feb 2016 11:03:04 -0500 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: <1454680897-9464-1-git-send-email-jonathanh@nvidia.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/5/2016 9:01 AM, Jon Hunter wrote: > When setting the pll_a frequency, to what should be 368639844 Hz, the > actual output frequency of the pll is 737279687 Hz (as reported by the > debugfs clk_summary entry), which is double the expect frequency. The > calculations for the pll frequency appear to be correct and the problem > is caused by incorrect divider settings for the pll_a in the look-up > table of multipliers and dividers. The P dividers for all entries in the > table are all one less than they should be. Fix this by increasing the > value of the P dividers by 1 to get the expected rates. > > The rates in the table have been verified using the following equations: > > 1. Integer NDIV (SDM_DIN = 0) > fout = (fref * n) / (m * p) > > 2. Fractional NDIV > fout = (fref * (n + 0.5 + (SDM_DIN/8192))) / (m * p) > > Where SDM_DIN is a signed 16-bit value between 0xf000 and 0x1000. > > Signed-off-by: Jon Hunter > --- > > Thierry, Rhyland, please note that after this change, the pll_a settings > match those in the nvidia downstream 3.18 kernel for Tegra210. > > This was an issue we had before/around merging T210 driver. The tegra clock code was inconsistent in how it treated the pdiv. In some places it stored the direct HW value in the frequency table entry struct (like in the predefined frequencies like what you changed). Some places stored the translated (=_hw_to_p_div()). This is most commonly a difference in a factor of 2. I found when initially doing the T210 that most clocks I requested rates for came out at either 1/2 or 2x what I wanted depending on the path. I think when Thierry merged my series, he added some code to address this issue, as he saw it too I think. Depending on what his change was (to consistently store either pdiv or hw_val) then we may need to adjust ALL the predefined rates in the clk-tegra210 code. Thierry, do you remember off-hand what you changed for that? -rhyland -- nvpublic