Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp869505ybl; Fri, 13 Dec 2019 05:58:31 -0800 (PST) X-Google-Smtp-Source: APXvYqyFTuPdVIQm9Qd08Mmo6k3ZZ3OQF/+tIsFYBBeeCSzCpWAxo7MmffwJKoGsgoLEE7wq9hpz X-Received: by 2002:a9d:7984:: with SMTP id h4mr15034531otm.297.1576245511245; Fri, 13 Dec 2019 05:58:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576245511; cv=none; d=google.com; s=arc-20160816; b=sKUxX54cQGPpD2gzrw0tl1lPBObPZFUIUJXaZpawFv3TJIx1NyCPYXdnlBiPi0ILFe a2XUDEcYYwOvd939uDKjk7BqM2Lh8apballTR6UDjQou6IV2NtaR5rmnAUFuUmoJ53Xq Ncd1Nqs68KJivWJclG9twrV0eXkSrUQsgkqlgo/upY6BCtxVhfaJnvtIx+u9KQl9sYzu JKFky4RCC1CE42A/MY/dyHoMtmb+A1G2C4h2r8edpRgOh9En5slxcSQ0Rj2cJgovjvaF FRjZiiuX7kXhEItY4uRQHTT+jfejSfh90eEsJxpAFTEegpHj5i84C5AwdIepnhGA6sY/ gc5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=Ng0J7VT6q7et93hoQowYvQqzLfb9VIPnBEUDJ7gqlTQ=; b=DfUCuch+PBVueFPuInazgUAeA6a+kwqn/cpDqfMhbgjUCM3jSgyLvAtyABKA/9BX7d eQqbspie+bo/oOcFRmDyF0CaeesfZoF2f4zjtn2wCL1rjCZWvSa3ggWQDJzonr8kc9oy UogAqJcE2hNLABuJMjJo0cxiy6rtJSacfkrOkSs6Rr9+aLwyH3pQ/Yhm5v3ZCBQaYKA0 2EV3QpoPYGXSbYOSukgCYTllEvSLMdEN485pz9SiUBp3hAu7gTrRdwDzYJzIIkZQzl/o jMCB9Q2rPdBm0xSMnAOQfCv7cdOoa8yQCYw7jNmyi2plYtcLSdiHQQVJ+3nmMu/vz/Vp T0WA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=a7VtdNfH; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h22si5138269otk.294.2019.12.13.05.58.19; Fri, 13 Dec 2019 05:58:31 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=a7VtdNfH; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727595AbfLMN4o (ORCPT + 99 others); Fri, 13 Dec 2019 08:56:44 -0500 Received: from mail-lj1-f196.google.com ([209.85.208.196]:44703 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727490AbfLMN4n (ORCPT ); Fri, 13 Dec 2019 08:56:43 -0500 Received: by mail-lj1-f196.google.com with SMTP id c19so2705316lji.11 for ; Fri, 13 Dec 2019 05:56:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Ng0J7VT6q7et93hoQowYvQqzLfb9VIPnBEUDJ7gqlTQ=; b=a7VtdNfHIVILhuTWgjDaH90Fod1yB199ZL5r5mn6i4THtWtQEmPH/80tBhAvFb2KbB yIdi/QHqtBtrv8HC1b3iZZ1tPyZjOfk/FQIjWMiX2h688sfN4AXvyKc5nzSFeTYvBSKE 7JlvVL8AGXd7X4Lpz8QGLCSGmZKW9577YuwJvHYfKT9afQZu4Wx/L55yqoShjOmsAjTk 4j/BN4Whchk2P92Zep2kex1nqoloN3cLNLkBhpQgfZFknQ3NmneYmojRpBhR+20laW4F P70/2ApsdcbiKLhVM13ta3Z0O1KKYVhkyhZ0fYXtmEgAu0629c6/T/AT4aHX82ooblbb VmjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Ng0J7VT6q7et93hoQowYvQqzLfb9VIPnBEUDJ7gqlTQ=; b=s2VZH/vlOh0Ik8aydPLbrAS80a3KkLUOVCWTXkih91s1QNM45SPGlL+j4WIYSgaNPe 700iy4enM1hrrRjmmkhHXJka91pqTb8fa3Yfo+aOcjpduBe+nTDU2f80cXdS7xWG0vcz NVbnX5jK94haG+JJ1REyBtYtR2JC0Nag//AnNoZrwq+bZOS+bsna6jPJv7CF/+Nn8zZE frqaRopxZIDYzyA1UfSQhf3AFSd0hOIm0DWYFXueii6AhC7+5xYrogUhkdoxFx7OKRL0 i2gJYJRlSjthLjpRc5SC8Go1hkzSf31zu+wwIGVKUwLyX8Ch97OJ54HEigCrrB44FmZi VQqA== X-Gm-Message-State: APjAAAWFRUQNirAHEB9Zv3SeC+JXPDwfZrLPTkt0dxNj4d0t7XXC7BcU KWTcPv37XMXbQJU6O5MO0tjE27EBzYvsi4GDutzEDg== X-Received: by 2002:a05:651c:1049:: with SMTP id x9mr9521183ljm.233.1576245401607; Fri, 13 Dec 2019 05:56:41 -0800 (PST) MIME-Version: 1.0 References: <20191205002503.13088-1-masneyb@onstation.org> <20191205002503.13088-2-masneyb@onstation.org> <0101016eee224b50-8a5545e2-837f-41c2-9574-b385e111a6b3-000000@us-west-2.amazonses.com> <20191210115153.GA10298@onstation.org> In-Reply-To: <20191210115153.GA10298@onstation.org> From: Linus Walleij Date: Fri, 13 Dec 2019 14:56:30 +0100 Message-ID: Subject: Re: [PATCH 1/7] clk: qcom: add support for setting the duty cycle To: Brian Masney Cc: Taniya Das , Stephen Boyd , Dmitry Torokhov , Rob Herring , Mark Rutland , Andy Gross , Bjorn Andersson , Michael Turquette , Linux Input , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , "linux-kernel@vger.kernel.org" , MSM , linux-clk Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Dec 10, 2019 at 12:52 PM Brian Masney wrote: > On Tue, Dec 10, 2019 at 04:47:35AM +0000, Taniya Das wrote: > > On 12/5/2019 5:54 AM, Brian Masney wrote: > > > I'm not sure about the relationship of the m, n, and d values, > > > especially how the 50% duty cycle is calculated by inverting the n > > > value, so that's why I'm saving the duty cycle ratio for > > > get_duty_cycle(). (...) > > > +static int clk_rcg2_set_duty_cycle(struct clk_hw *hw, struct clk_duty *duty) > > > +{ > > > + struct clk_rcg2 *rcg = to_clk_rcg2(hw); > > > + int ret, d_reg_val, mask; > > > + > > > + mask = BIT(rcg->mnd_width - 1) - 1; > > > + d_reg_val = mask - (((mask - 17) * duty->num) / duty->den); > > > + ret = __clk_rcg2_configure_with_duty_cycle(rcg, rcg->freq_tbl, > > > + d_reg_val, duty->num, > > > + duty->den); > > > > The duty-cycle calculation is not accurate. > > There is already a plan to submit the duty-cycle changes from my side. > > OK... I assume that the m and n values need to be changed as well. I > couldn't find any docs online about the meaning of the m, n, and d > values and how they relate to each other. I have also at times struggled to understand this. If someone could just in a very concise form describe how these rcg[2] clock dividers work and how m,n,d work that'd be GREAT. ASCII art etc would be a bonus :) Like with a patch with a big comment in drivers/clk/qcom/clk-rcg.h As these tend to be quite regularly reused and incarnated in ever new silicon a complete picture for developers would be much appreciated. Yours, Linus Walleij