From: "Heiko Stübner" <heiko@sntech.de>
To: Elaine Zhang <zhangqing@rock-chips.com>,
sboyd@kernel.org, mturquette@baylibre.com
Cc: robh+dt@kernel.org, mark.rutland@arm.com,
linux-clk@vger.kernel.org, devicetree@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org,
cl@rock-chips.com, xxx@rock-chips.com, xf@rock-chips.com,
huangtao@rock-chips.com
Subject: Re: [PATCH v1 3/4] clk: rockchip: add support for half divider
Date: Thu, 07 Jun 2018 12:57:04 +0200 [thread overview]
Message-ID: <2360735.SLDx3PN3Y9@diego> (raw)
In-Reply-To: <1528340786-462-4-git-send-email-zhangqing@rock-chips.com>
Hi Elaine,
looks good to me overall, some minor things below.
Am Donnerstag, 7. Juni 2018, 05:06:25 CEST schrieb Elaine Zhang:
> The new Rockchip socs have optional half divider,
> so we use "branch_half_divider" + "COMPOSITE_NOMUX_HALFDIV \ DIV_HALF"
> to hook that special divider clock-type into our clock-tree.
>
> Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com>
Please provide a bit more explanation on how this clock type, so
people reading the git log later can understand how the divider works.
> ---
> drivers/clk/rockchip/Makefile | 1 +
> drivers/clk/rockchip/clk-half-divider.c | 235
> ++++++++++++++++++++++++++++++++ drivers/clk/rockchip/clk.c |
> 10 ++
> drivers/clk/rockchip/clk.h | 45 ++++++
> 4 files changed, 291 insertions(+)
> create mode 100644 drivers/clk/rockchip/clk-half-divider.c
>
> diff --git a/drivers/clk/rockchip/Makefile b/drivers/clk/rockchip/Makefile
> index 59b8d320960a..023f83ad3429 100644
> --- a/drivers/clk/rockchip/Makefile
> +++ b/drivers/clk/rockchip/Makefile
> @@ -7,6 +7,7 @@ obj-y += clk-rockchip.o
> obj-y += clk.o
> obj-y += clk-pll.o
> obj-y += clk-cpu.o
> +obj-y += clk-half-divider.o
all other entries use tabs as spacers between obj-y and the +=
> obj-y += clk-inverter.o
> obj-y += clk-mmc-phase.o
> obj-y += clk-muxgrf.o
> diff --git a/drivers/clk/rockchip/clk-half-divider.c
> b/drivers/clk/rockchip/clk-half-divider.c new file mode 100644
> index 000000000000..23830de254ec
> --- /dev/null
> +++ b/drivers/clk/rockchip/clk-half-divider.c
> @@ -0,0 +1,235 @@
> +/*
copyright line missing?
> + *
> + * This software is licensed under the terms of the GNU General Public
> + * License version 2, as published by the Free Software Foundation, and
> + * may be copied, distributed, and modified under those terms.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + */
> +
> +#include <linux/slab.h>
> +#include <linux/bitops.h>
> +#include <linux/regmap.h>
> +#include <linux/clk.h>
> +#include <linux/clk-provider.h>
> +#include "clk.h"
> +
> +#define div_mask(width) ((1 << (width)) - 1)
> +
> +static bool _is_best_half_div(unsigned long rate, unsigned long now,
> + unsigned long best, unsigned long flags)
> +{
> + if (flags & CLK_DIVIDER_ROUND_CLOSEST)
> + return abs(rate - now) < abs(rate - best);
> +
> + return now <= rate && now > best;
> +}
> +
> +static unsigned long clk_half_divider_recalc_rate(struct clk_hw *hw,
> + unsigned long parent_rate)
> +{
> + struct clk_divider *divider = to_clk_divider(hw);
While I find it very cool that we can reuse the clk_divider struct
and see no issue doing it, I'm hoping for either Mike or Stephen
to indicate if we're allowed to do that ;-)
> +const struct clk_ops clk_half_divider_ops = {
> + .recalc_rate = clk_half_divider_recalc_rate,
> + .round_rate = clk_half_divider_round_rate,
> + .set_rate = clk_half_divider_set_rate,
> +};
> +EXPORT_SYMBOL_GPL(clk_half_divider_ops);
this is only used locally in rockchip_clk_register_halfdiv, so doesn't
need to be exported.
Heiko
next prev parent reply other threads:[~2018-06-07 10:57 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-07 3:06 [PATCH v1 0/4] clk: rockchip: support clock controller for px30 SoC Elaine Zhang
2018-06-07 3:06 ` [PATCH v1 1/4] dt-bindings: add bindings for px30 clock controller Elaine Zhang
2018-06-07 3:06 ` [PATCH v1 2/4] clk: rockchip: add dt-binding header for px30 Elaine Zhang
2018-06-07 7:56 ` Heiko Stübner
2018-06-07 3:06 ` [PATCH v1 3/4] clk: rockchip: add support for half divider Elaine Zhang
2018-06-07 10:57 ` Heiko Stübner [this message]
2018-06-07 3:06 ` [PATCH v1 4/4] clk: rockchip: add clock controller for px30 Elaine Zhang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2360735.SLDx3PN3Y9@diego \
--to=heiko@sntech.de \
--cc=cl@rock-chips.com \
--cc=devicetree@vger.kernel.org \
--cc=huangtao@rock-chips.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=mark.rutland@arm.com \
--cc=mturquette@baylibre.com \
--cc=robh+dt@kernel.org \
--cc=sboyd@kernel.org \
--cc=xf@rock-chips.com \
--cc=xxx@rock-chips.com \
--cc=zhangqing@rock-chips.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).