From: Stephen Boyd <sboyd@codeaurora.org>
To: Tirupathi Reddy T <tirupath@codeaurora.org>
Cc: mturquette@baylibre.com, robh+dt@kernel.org,
mark.rutland@arm.com, andy.gross@linaro.org,
david.brown@linaro.org, linux-clk@vger.kernel.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org
Subject: Re: [PATCH V1] clk: qcom: Add qpnp clock divider support
Date: Tue, 18 Jul 2017 16:08:27 -0700 [thread overview]
Message-ID: <20170718230827.GE18179@codeaurora.org> (raw)
In-Reply-To: <f488d813-9dcc-4d32-c40c-fa15bfdd2cf9@codeaurora.org>
On 07/18, Tirupathi Reddy T wrote:
>
> On 7/15/2017 2:38 AM, Stephen Boyd wrote:
> >On 07/13, Tirupathi Reddy wrote:
> >>diff --git a/Documentation/devicetree/bindings/clock/clk-qpnp-div.txt b/Documentation/devicetree/bindings/clock/clk-qpnp-div.txt
> >>new file mode 100644
> >>index 0000000..03b7b70
> >>--- /dev/null
> >>+++ b/Documentation/devicetree/bindings/clock/clk-qpnp-div.txt
> >>@@ -0,0 +1,52 @@
> >>+Qualcomm Technologies, Inc. QPNP clock divider (clkdiv)
> >>+
> >>+clkdiv configures the clock frequency of a set of outputs on the PMIC.
> >>+These clocks are typically wired through alternate functions on
> >>+gpio pins.
> >>+
> >>+=======================
> >>+Supported Properties
> >>+=======================
> >>+
> >>+- compatible
> >>+ Usage: required
> >>+ Value type: <string>
> >>+ Definition: should be "qcom,qpnp-clkdiv".
> >>+
> >>+- reg
> >>+ Usage: required
> >>+ Value type: <prop-encoded-array>
> >>+ Definition: Addresses and sizes for the memory of this CLKDIV
> >>+ peripheral.
> >>+
> >>+- qcom,cxo-freq
> >>+ Usage: required
> >>+ Value type: <u32>
> >>+ Definition: The frequency of the crystal oscillator (CXO) clock in Hz.
> >CXO should be a parent clk then. This could have clocks and
> >clock-names properties for that and then be hooked up to
> >xo_board.
> Sure. I will address in the next patch set.
> >>+
> >>+- qcom,clkdiv-id
> >>+ Usage: required
> >>+ Value type: <u32>
> >>+ Definition: Integer value specifies the hardware identifier of this
> >>+ CLKDIV peripheral.
> >This is to name the clk? You could use clock-output-names as
> >that's more standard. But this is also sort of confusing. If
> >there are multiple clkdivs then it would be good to combine them
> >into one device node assuming they're all next to each other.
> >This would be similar to how we handle gpios and regulators. Then
> >the naming is simple enough to be an incrementing number.
> Yes, multiple clkdivs present. We add sub-nodes for each clkdiv and
> parse them inside driver as separate clock.
Please just roll them all into one node instead of a node per
clk on the PMIC.
> >>+#define Q_DIV_PERIOD_NS(cxo_clk, div) (NSEC_PER_SEC / (cxo_clk / div))
> >>+#define Q_ENABLE_DELAY_NS(cxo_clk, div) (2 * Q_CXO_PERIOD_NS(cxo_clk) + \
> >>+ (3 * Q_DIV_PERIOD_NS(cxo_clk, div)))
> >>+#define Q_DISABLE_DELAY_NS(cxo_clk, div) \
> >>+ (3 * Q_DIV_PERIOD_NS(cxo_clk, div))
> >>+
> >>+#define CLK_QPNP_DIV_OFFSET 1
> >>+
> >>+enum q_clk_div_factor {
> >>+ Q_CLKDIV_XO_DIV_1_0 = 0,
> >>+ Q_CLKDIV_XO_DIV_1,
> >>+ Q_CLKDIV_XO_DIV_2,
> >>+ Q_CLKDIV_XO_DIV_4,
> >>+ Q_CLKDIV_XO_DIV_8,
> >>+ Q_CLKDIV_XO_DIV_16,
> >>+ Q_CLKDIV_XO_DIV_32,
> >>+ Q_CLKDIV_XO_DIV_64,
> >>+ Q_CLKDIV_MAX_ALLOWED,
> >Please make #defines for these instead of enum.
> We used enum primarily for easy debug at runtime. For an example,
> The "div_factor" field
> of "struct q_clkdiv" would always show the enumerated value which
> would help in
> determining the configured absolute divider value rather than
> spending time in mapping
> register bit values to absolute divider value.
Ok. I can't find a good reference, but typically we don't do this
in kernel drivers and just use #defines instead. Please just do
that. It seems simple enough to know to translate the number to a
power of 2 after reading it.
> >
> >>+};
> >>+
> >>+enum q_clkdiv_state {
> >>+ DISABLE = false,
> >>+ ENABLE = true,
> >>+};
> >Uh no. Just use bool.
> Sure. I will address in the next patch set.
> >
> >>+
> >>+struct q_clkdiv {
> >>+ struct regmap *regmap;
> >>+ struct device *dev;
> >>+
> >>+ u16 base;
> >>+ spinlock_t lock;
> >>+
> >>+ /* clock properties */
> >>+ struct clk_hw hw;
> >>+ unsigned int cxo_hz;
> >Drop.
> cxo_hz is required to be populated at driver initialization and
> being used at runtime
> for calculating the div value to be applied.
> >
> >>+ enum q_clk_div_factor div_factor;
> >>+ bool enabled;
> >Shouldn't be needed. Read the hardware instead.
> This enabled field is required for the typical handling of set_rate
> in qpnp_clkdiv_config_freq_div().
You can't read the hardware in set_rate op?
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
next prev parent reply other threads:[~2017-07-18 23:08 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-13 11:32 [PATCH V1]: clk: qcom: support qpnp clock divider configuration Tirupathi Reddy
2017-07-13 11:32 ` [PATCH V1] clk: qcom: Add qpnp clock divider support Tirupathi Reddy
[not found] ` <1499945536-18281-2-git-send-email-tirupath-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2017-07-14 21:08 ` Stephen Boyd
2017-07-18 11:35 ` Tirupathi Reddy T
2017-07-18 23:08 ` Stephen Boyd [this message]
2017-07-13 17:50 ` [PATCH V1]: clk: qcom: support qpnp clock divider configuration Stephen Boyd
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=20170718230827.GE18179@codeaurora.org \
--to=sboyd@codeaurora.org \
--cc=andy.gross@linaro.org \
--cc=david.brown@linaro.org \
--cc=devicetree@vger.kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-soc@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mturquette@baylibre.com \
--cc=robh+dt@kernel.org \
--cc=tirupath@codeaurora.org \
/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).