Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1517408 > unrolled thread
| Started by | Maxime Ripard <maxime.ripard@free-electrons.com> |
|---|---|
| First post | 2016-11-08 18:30 +0100 |
| Last post | 2016-11-13 05:00 +0100 |
| Articles | 3 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH 2/10] clk: sunxi-ng: nkm: Deal with fixed post dividers Maxime Ripard <maxime.ripard@free-electrons.com> - 2016-11-08 18:30 +0100
Re: [PATCH 2/10] clk: sunxi-ng: nkm: Deal with fixed post dividers Chen-Yu Tsai <wens@csie.org> - 2016-11-13 04:50 +0100
Re: [PATCH 2/10] clk: sunxi-ng: nkm: Deal with fixed post dividers Chen-Yu Tsai <wens@csie.org> - 2016-11-13 05:00 +0100
| From | Maxime Ripard <maxime.ripard@free-electrons.com> |
|---|---|
| Date | 2016-11-08 18:30 +0100 |
| Subject | [PATCH 2/10] clk: sunxi-ng: nkm: Deal with fixed post dividers |
| Message-ID | <sBinD-3Pq-9@gated-at.bofh.it> |
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
---
drivers/clk/sunxi-ng/ccu_nkm.c | 17 ++++++++++++++---
drivers/clk/sunxi-ng/ccu_nkm.h | 2 ++
2 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/drivers/clk/sunxi-ng/ccu_nkm.c b/drivers/clk/sunxi-ng/ccu_nkm.c
index 9b840a47a94d..fd3c6a9d987c 100644
--- a/drivers/clk/sunxi-ng/ccu_nkm.c
+++ b/drivers/clk/sunxi-ng/ccu_nkm.c
@@ -75,7 +75,7 @@ static unsigned long ccu_nkm_recalc_rate(struct clk_hw *hw,
unsigned long parent_rate)
{
struct ccu_nkm *nkm = hw_to_ccu_nkm(hw);
- unsigned long n, m, k;
+ unsigned long rate, n, m, k;
u32 reg;
reg = readl(nkm->common.base + nkm->common.reg);
@@ -89,7 +89,11 @@ static unsigned long ccu_nkm_recalc_rate(struct clk_hw *hw,
m = reg >> nkm->m.shift;
m &= (1 << nkm->m.width) - 1;
- return parent_rate * (n + 1) * (k + 1) / (m + 1);
+ rate = parent_rate * (n + 1) * (k + 1) / (m + 1);
+ if (nkm->common.features & CCU_FEATURE_FIXED_POSTDIV)
+ rate /= nkm->fixed_post_div;
+
+ return rate;
}
static unsigned long ccu_nkm_round_rate(struct ccu_mux_internal *mux,
@@ -100,6 +104,9 @@ static unsigned long ccu_nkm_round_rate(struct ccu_mux_internal *mux,
struct ccu_nkm *nkm = data;
struct _ccu_nkm _nkm;
+ if (nkm->common.features & CCU_FEATURE_FIXED_POSTDIV)
+ rate *= nkm->fixed_post_div;
+
_nkm.min_n = nkm->n.min;
_nkm.max_n = 1 << nkm->n.width;
_nkm.min_k = nkm->k.min;
@@ -109,7 +116,11 @@ static unsigned long ccu_nkm_round_rate(struct ccu_mux_internal *mux,
ccu_nkm_find_best(parent_rate, rate, &_nkm);
- return parent_rate * _nkm.n * _nkm.k / _nkm.m;
+ rate = parent_rate * _nkm.n * _nkm.k / _nkm.m;
+ if (nkm->common.features & CCU_FEATURE_FIXED_POSTDIV)
+ rate = rate / nkm->fixed_post_div;
+
+ return rate;
}
static int ccu_nkm_determine_rate(struct clk_hw *hw,
diff --git a/drivers/clk/sunxi-ng/ccu_nkm.h b/drivers/clk/sunxi-ng/ccu_nkm.h
index 34580894f4d1..0f1dbca25719 100644
--- a/drivers/clk/sunxi-ng/ccu_nkm.h
+++ b/drivers/clk/sunxi-ng/ccu_nkm.h
@@ -32,6 +32,8 @@ struct ccu_nkm {
struct ccu_mult_internal n;
struct ccu_mult_internal k;
struct ccu_div_internal m;
+
+ unsigned int fixed_post_div;
struct ccu_mux_internal mux;
struct ccu_common common;
--
git-series 0.8.11
[toc] | [next] | [standalone]
| From | Chen-Yu Tsai <wens@csie.org> |
|---|---|
| Date | 2016-11-13 04:50 +0100 |
| Message-ID | <sCTXP-37t-1@gated-at.bofh.it> |
| In reply to | #1517408 |
On Wed, Nov 9, 2016 at 1:23 AM, Maxime Ripard
<maxime.ripard@free-electrons.com> wrote:
It'd be better if you mentioned what clock needs this.
> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
> ---
> drivers/clk/sunxi-ng/ccu_nkm.c | 17 ++++++++++++++---
> drivers/clk/sunxi-ng/ccu_nkm.h | 2 ++
> 2 files changed, 16 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/clk/sunxi-ng/ccu_nkm.c b/drivers/clk/sunxi-ng/ccu_nkm.c
> index 9b840a47a94d..fd3c6a9d987c 100644
> --- a/drivers/clk/sunxi-ng/ccu_nkm.c
> +++ b/drivers/clk/sunxi-ng/ccu_nkm.c
> @@ -75,7 +75,7 @@ static unsigned long ccu_nkm_recalc_rate(struct clk_hw *hw,
> unsigned long parent_rate)
> {
> struct ccu_nkm *nkm = hw_to_ccu_nkm(hw);
> - unsigned long n, m, k;
> + unsigned long rate, n, m, k;
> u32 reg;
>
> reg = readl(nkm->common.base + nkm->common.reg);
> @@ -89,7 +89,11 @@ static unsigned long ccu_nkm_recalc_rate(struct clk_hw *hw,
> m = reg >> nkm->m.shift;
> m &= (1 << nkm->m.width) - 1;
>
> - return parent_rate * (n + 1) * (k + 1) / (m + 1);
> + rate = parent_rate * (n + 1) * (k + 1) / (m + 1);
> + if (nkm->common.features & CCU_FEATURE_FIXED_POSTDIV)
> + rate /= nkm->fixed_post_div;
> +
> + return rate;
> }
>
> static unsigned long ccu_nkm_round_rate(struct ccu_mux_internal *mux,
> @@ -100,6 +104,9 @@ static unsigned long ccu_nkm_round_rate(struct ccu_mux_internal *mux,
> struct ccu_nkm *nkm = data;
> struct _ccu_nkm _nkm;
>
> + if (nkm->common.features & CCU_FEATURE_FIXED_POSTDIV)
> + rate *= nkm->fixed_post_div;
> +
> _nkm.min_n = nkm->n.min;
> _nkm.max_n = 1 << nkm->n.width;
> _nkm.min_k = nkm->k.min;
> @@ -109,7 +116,11 @@ static unsigned long ccu_nkm_round_rate(struct ccu_mux_internal *mux,
>
> ccu_nkm_find_best(parent_rate, rate, &_nkm);
>
> - return parent_rate * _nkm.n * _nkm.k / _nkm.m;
> + rate = parent_rate * _nkm.n * _nkm.k / _nkm.m;
> + if (nkm->common.features & CCU_FEATURE_FIXED_POSTDIV)
> + rate = rate / nkm->fixed_post_div;
> +
> + return rate;
> }
>
You also need to handle this in the set_rate callback. You might need
to read back
the parent index value to determine if the post divider applies, as
this clock supports
a mux. Or don't support mux + post-div, and leave a TODO note.
ChenYu
> static int ccu_nkm_determine_rate(struct clk_hw *hw,
> diff --git a/drivers/clk/sunxi-ng/ccu_nkm.h b/drivers/clk/sunxi-ng/ccu_nkm.h
> index 34580894f4d1..0f1dbca25719 100644
> --- a/drivers/clk/sunxi-ng/ccu_nkm.h
> +++ b/drivers/clk/sunxi-ng/ccu_nkm.h
> @@ -32,6 +32,8 @@ struct ccu_nkm {
> struct ccu_mult_internal n;
> struct ccu_mult_internal k;
> struct ccu_div_internal m;
> +
> + unsigned int fixed_post_div;
> struct ccu_mux_internal mux;
>
> struct ccu_common common;
> --
> git-series 0.8.11
[toc] | [prev] | [next] | [standalone]
| From | Chen-Yu Tsai <wens@csie.org> |
|---|---|
| Date | 2016-11-13 05:00 +0100 |
| Message-ID | <sCU7v-3aX-7@gated-at.bofh.it> |
| In reply to | #1520458 |
On Sun, Nov 13, 2016 at 11:48 AM, Chen-Yu Tsai <wens@csie.org> wrote:
> On Wed, Nov 9, 2016 at 1:23 AM, Maxime Ripard
> <maxime.ripard@free-electrons.com> wrote:
>
> It'd be better if you mentioned what clock needs this.
>
>> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
>> ---
>> drivers/clk/sunxi-ng/ccu_nkm.c | 17 ++++++++++++++---
>> drivers/clk/sunxi-ng/ccu_nkm.h | 2 ++
>> 2 files changed, 16 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/clk/sunxi-ng/ccu_nkm.c b/drivers/clk/sunxi-ng/ccu_nkm.c
>> index 9b840a47a94d..fd3c6a9d987c 100644
>> --- a/drivers/clk/sunxi-ng/ccu_nkm.c
>> +++ b/drivers/clk/sunxi-ng/ccu_nkm.c
>> @@ -75,7 +75,7 @@ static unsigned long ccu_nkm_recalc_rate(struct clk_hw *hw,
>> unsigned long parent_rate)
>> {
>> struct ccu_nkm *nkm = hw_to_ccu_nkm(hw);
>> - unsigned long n, m, k;
>> + unsigned long rate, n, m, k;
>> u32 reg;
>>
>> reg = readl(nkm->common.base + nkm->common.reg);
>> @@ -89,7 +89,11 @@ static unsigned long ccu_nkm_recalc_rate(struct clk_hw *hw,
>> m = reg >> nkm->m.shift;
>> m &= (1 << nkm->m.width) - 1;
>>
>> - return parent_rate * (n + 1) * (k + 1) / (m + 1);
>> + rate = parent_rate * (n + 1) * (k + 1) / (m + 1);
>> + if (nkm->common.features & CCU_FEATURE_FIXED_POSTDIV)
>> + rate /= nkm->fixed_post_div;
>> +
>> + return rate;
>> }
>>
>> static unsigned long ccu_nkm_round_rate(struct ccu_mux_internal *mux,
>> @@ -100,6 +104,9 @@ static unsigned long ccu_nkm_round_rate(struct ccu_mux_internal *mux,
>> struct ccu_nkm *nkm = data;
>> struct _ccu_nkm _nkm;
>>
>> + if (nkm->common.features & CCU_FEATURE_FIXED_POSTDIV)
>> + rate *= nkm->fixed_post_div;
>> +
>> _nkm.min_n = nkm->n.min;
>> _nkm.max_n = 1 << nkm->n.width;
>> _nkm.min_k = nkm->k.min;
>> @@ -109,7 +116,11 @@ static unsigned long ccu_nkm_round_rate(struct ccu_mux_internal *mux,
>>
>> ccu_nkm_find_best(parent_rate, rate, &_nkm);
>>
>> - return parent_rate * _nkm.n * _nkm.k / _nkm.m;
>> + rate = parent_rate * _nkm.n * _nkm.k / _nkm.m;
>> + if (nkm->common.features & CCU_FEATURE_FIXED_POSTDIV)
>> + rate = rate / nkm->fixed_post_div;
>> +
>> + return rate;
>> }
>>
>
> You also need to handle this in the set_rate callback. You might need
> to read back
> the parent index value to determine if the post divider applies, as
> this clock supports
> a mux. Or don't support mux + post-div, and leave a TODO note.
Was thinking pre-dividers... sorry. Please ignore the second parent
index part.
ChenYu
>
> ChenYu
>
>> static int ccu_nkm_determine_rate(struct clk_hw *hw,
>> diff --git a/drivers/clk/sunxi-ng/ccu_nkm.h b/drivers/clk/sunxi-ng/ccu_nkm.h
>> index 34580894f4d1..0f1dbca25719 100644
>> --- a/drivers/clk/sunxi-ng/ccu_nkm.h
>> +++ b/drivers/clk/sunxi-ng/ccu_nkm.h
>> @@ -32,6 +32,8 @@ struct ccu_nkm {
>> struct ccu_mult_internal n;
>> struct ccu_mult_internal k;
>> struct ccu_div_internal m;
>> +
>> + unsigned int fixed_post_div;
>> struct ccu_mux_internal mux;
>>
>> struct ccu_common common;
>> --
>> git-series 0.8.11
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web