Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp952496imm; Tue, 3 Jul 2018 02:59:13 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcbd3W0V3Xjpoj7YaJlTRCuVgC/QFeLItNh0kXhF9YZsz/0DB9BfE4jtI0lEu42o5f8AX+D X-Received: by 2002:a17:902:700a:: with SMTP id y10-v6mr9828447plk.249.1530611953145; Tue, 03 Jul 2018 02:59:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530611953; cv=none; d=google.com; s=arc-20160816; b=MtcTWyR7p3OxWj3iXRx5DLZqW3aDMC/GbOQZM6L9DAkbpOairLd5YmWboFn1JbOz9s Jbq0xrfnTyBwzV5+xfzjApHfGMcTSoRFJ8kDTpcRWMK9eFKhB8XiomHb5Gne75rsUFTI cvLfeCfqi+GKRRJz+ue50np7IP2EPdwSlXZHa9TZxsqQEKZhjE4OkdP+2ZQoaxNg4GI8 QXpL7Gtv9Nw1AG9F3OWViApbkNx+WgA6hjOgIwwBQeaz21E72s61V8xrenXBeGrY+HNc qauFoFeyHnCoW9mSgHhOqqQ7ialIdAdatdhl3Z2S8w0AcjVDZjX60WhJWSCMihnN4XMa l/dA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id :dkim-signature:arc-authentication-results; bh=hw+7XphhYRlXjNsAWUjVJoncDHOf8u+qmrZ0TxMwF/I=; b=HgMmN/BNrAm9JsHsya9Q52s+4IcwnySwEm1EQMcY88lrmG6FD/g2zgLd9Nzqbc8kwb GDDWGMTrlMwp235DAsTSQp7cRUAXMQB/L82wPe/wDmv96yHhsakBQxlO/T5uI4JAaoX+ SIkw9UbXJEIrPOkvHTjAhJBYc6O1ukLabh5aTjLT/Z7bZvalfzmR/0UmPOM6XIigVoFz 5HDwSdS1eDd3PGfDgJySp3/i5JU+Kf3TbGnQBcAecNRRHTKGeWyqGdLQdsLRC4UP0h+6 Z4Ygq4yeVHJpg7AhYAlluG8RC7YwcylXcJ6NvXhszHfMDO+VgWDAeuwqeqjU8A/uZibK gKEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=n2q2+KHQ; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w13-v6si685688pgt.226.2018.07.03.02.58.58; Tue, 03 Jul 2018 02:59:13 -0700 (PDT) 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=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=n2q2+KHQ; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754713AbeGCJ5n (ORCPT + 99 others); Tue, 3 Jul 2018 05:57:43 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:51563 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754645AbeGCJ5l (ORCPT ); Tue, 3 Jul 2018 05:57:41 -0400 Received: by mail-wm0-f68.google.com with SMTP id s12-v6so1649163wmc.1 for ; Tue, 03 Jul 2018 02:57:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=message-id:subject:from:to:cc:date:in-reply-to:references :mime-version:content-transfer-encoding; bh=hw+7XphhYRlXjNsAWUjVJoncDHOf8u+qmrZ0TxMwF/I=; b=n2q2+KHQ2/7wf+xbQy9GgvFO6yop9QvkbVDbY1IDLZlDaFP9AMXV78OVFlvMZO4WYI LwfI7dEcH9fFvnivHsFsvzG42LUfZ6zRqWWhlKEWcWeyIScIcYvMzS0JlkQeTBxVF0Aq FwTptZpJo0LxuvqvEh9Tycb0xjBSnjEX/Ys/BHtgPUYk2V8QSDrKBaNGGh6G9dddKxrc LC6lR9SeBK3t6M0vaSN82sbDpC/fUgrXvFBb3i+GrUvvOcV4HiO8wwo+OO72CSf7x934 WWEtnVM58wv9id4BdubvC1nvhG/pgF8xorVq+EJoGP7l40Q5S0CXk7e/e8PZnoXjp0JH WHDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:mime-version:content-transfer-encoding; bh=hw+7XphhYRlXjNsAWUjVJoncDHOf8u+qmrZ0TxMwF/I=; b=rqKQdKqFyUNKy9Du3UlaCwKfxr+g+ZlAwfWB/eKB4Zh6Kz/QAHEKhraDY4ignYyL7T GGBMtvQWl+SCsMmnxGqlad+4AE6T4iT594PUL6TosbIOwZNzIc9RcCYLW5QpB+m4JU9+ KFz+DNSuV9WGCWcMeEC8BrZ11bNjv+xWdzPI5bcs13iU+CJsPi3K7K4HJ7WErkH7Vlok ScYg6K8Cx4zbIGTOiHfi2QzxgcQsblqR92ZISOJbbvjtvPoln85mF2R9oNiDZm9qq32D dDLWOhxzG7YQh0zlMvLjh59ZNo7ky7Gitmjh0e+8thZfXseKV5FKL0OXdSPrr3S9kEbS O6GQ== X-Gm-Message-State: APt69E018q6xB4zlHY2gPIaWU1Z+T9NIDiLlPuW5dzQl4SgFG5b8aEEH vOeEdj2NOv3KhCCq+AF3bKh5pw== X-Received: by 2002:a1c:8647:: with SMTP id i68-v6mr10583568wmd.28.1530611860034; Tue, 03 Jul 2018 02:57:40 -0700 (PDT) Received: from boomer ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id b15-v6sm901212wri.14.2018.07.03.02.57.39 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Jul 2018 02:57:39 -0700 (PDT) Message-ID: <1530611858.2900.201.camel@baylibre.com> Subject: Re: [PATCH v4] clk: add duty cycle support From: Jerome Brunet To: Geert Uytterhoeven Cc: Michael Turquette , Stephen Boyd , Russell King , Thierry Reding , Kevin Hilman , linux-clk , Linux Kernel Mailing List Date: Tue, 03 Jul 2018 11:57:38 +0200 In-Reply-To: References: <20180619144141.8506-1-jbrunet@baylibre.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.26.6 (3.26.6-1.fc27) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2018-07-03 at 11:27 +0200, Geert Uytterhoeven wrote: > Hi Jerome, > > On Tue, Jun 19, 2018 at 4:42 PM Jerome Brunet wrote: > > Add the possibility to apply and query the clock signal duty cycle ratio. > > > > This is useful when the duty cycle of the clock signal depends on some > > other parameters controlled by the clock framework. > > > > For example, the duty cycle of a divider may depends on the raw divider > > setting (ratio = N / div) , which is controlled by the CCF. In such case, > > going through the pwm framework to control the duty cycle ratio of this > > clock would be a burden. > > > > A clock provider is not required to implement the operation to set and get > > the duty cycle. If it does not implement .get_duty_cycle(), the ratio is > > assumed to be 50%. > > > > This change also adds a new flag, CLK_DUTY_CYCLE_PARENT. This flag should > > be used to indicate that a clock, such as gates and muxes, may inherit > > the duty cycle ratio of its parent clock. If a clock does not provide a > > get_duty_cycle() callback and has CLK_DUTY_CYCLE_PARENT, then the call > > will be directly forwarded to its parent clock, if any. For > > set_duty_cycle(), the clock should also have CLK_SET_RATE_PARENT for the > > call to be forwarded > > > > Signed-off-by: Jerome Brunet > > Thanks for your patch! > > > --- > > The series has been developed to handled the sample clocks provided by > > audio clock controller of amlogic's A113 SoC. To support i2s modes, this > > clock need to have a 50% duty cycle ratio, while it should be just one > > pulse of the parent clock in dsp modes. > > "one pulse" means num = 1, den = the clock rate, right? No, it would be num = 1, den = divider > > > --- a/include/linux/clk-provider.h > > +++ b/include/linux/clk-provider.h > > @@ -66,6 +68,17 @@ struct clk_rate_request { > > struct clk_hw *best_parent_hw; > > }; > > > > +/** > > + * struct clk_duty - Struture encoding the duty cycle ratio of a clock > > + * > > + * @num: Numerator of the duty cycle ratio > > + * @den: Denominator of the duty cycle ratio > > + */ > > +struct clk_duty { > > + unsigned int num; > > + unsigned int den; > > So shouldn't both fields be "unsigned long" instead, to match clock rates? > (Yes, I do know we don't support +4.3 GHz clock rates on 32-bit yet ;-) Not sure we need to match clock rates, long seems a bit too much. In the end, all we want a ratio, so a [0 - 1] number. Fraction using unsigned int already provide a pretty good precision (around 0.0002 ppm with 32bit) Do you have a use case where you need more than that ? > > Also, you may want to have a higher precision than degrees for the > phase property when handling pulses. Is this comment related to this patch ? > > Gr{oetje,eeting}s, > > Geert > > -- > Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org > > In personal conversations with technical people, I call myself a hacker. But > when I'm talking to journalists I just say "programmer" or something like that. > -- Linus Torvalds