From: t.figa@samsung.com (Tomasz Figa)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 10/16] clk: samsung: pll: Add support for rate configuration of PLL45xx
Date: Wed, 21 Aug 2013 14:49:25 +0200 [thread overview]
Message-ID: <2043626.uA5zP9MS4G@amdc1227> (raw)
In-Reply-To: <CAKew6eVFC0kbQtWF+eH+h1deGhZosBD=X3ZgCXE1k4yndGrvLw@mail.gmail.com>
On Wednesday 21 of August 2013 17:48:44 Yadwinder Singh Brar wrote:
> Hi Tomasz,
>
> On Tue, Aug 20, 2013 at 11:01 PM, Tomasz Figa <t.figa@samsung.com> wrote:
> > This patch implements round_rate and set_rate callbacks of PLL45xx
> > driver to allow reconfiguration of PLL at runtime.
> >
> > Signed-off-by: Tomasz Figa <t.figa@samsung.com>
> > Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
> > ---
> >
> > drivers/clk/samsung/clk-pll.c | 109
> > +++++++++++++++++++++++++++++++++++++++++-
> > drivers/clk/samsung/clk-pll.h | 10 ++++
> > 2 files changed, 118 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/clk/samsung/clk-pll.c
> > b/drivers/clk/samsung/clk-pll.c index b0398d2..cb971cb 100644
> > --- a/drivers/clk/samsung/clk-pll.c
> > +++ b/drivers/clk/samsung/clk-pll.c
> > @@ -10,9 +10,12 @@
> >
> > */
> >
> > #include <linux/errno.h>
> >
> > +#include <linux/hrtimer.h>
> >
> > #include "clk.h"
> > #include "clk-pll.h"
> >
> > +#define PLL_TIMEOUT_MS 10
> > +
> >
> > struct samsung_clk_pll {
> >
> > struct clk_hw hw;
> > void __iomem *lock_reg;
> >
> > @@ -272,13 +275,20 @@ static const struct clk_ops
> > samsung_pll36xx_clk_min_ops = {>
> > /*
> >
> > * PLL45xx Clock Type
> > */
> >
> > +#define PLL4502_LOCK_FACTOR 400
> > +#define PLL4508_LOCK_FACTOR 240
> >
> > #define PLL45XX_MDIV_MASK (0x3FF)
> > #define PLL45XX_PDIV_MASK (0x3F)
> > #define PLL45XX_SDIV_MASK (0x7)
> >
> > +#define PLL45XX_AFC_MASK (0x1F)
> >
> > #define PLL45XX_MDIV_SHIFT (16)
> > #define PLL45XX_PDIV_SHIFT (8)
> > #define PLL45XX_SDIV_SHIFT (0)
> >
> > +#define PLL45XX_AFC_SHIFT (0)
> > +
> > +#define PLL45XX_ENABLE BIT(31)
> > +#define PLL45XX_LOCKED BIT(29)
> >
> > static unsigned long samsung_pll45xx_recalc_rate(struct clk_hw *hw,
> >
> > unsigned long parent_rate)
> >
> > @@ -301,8 +311,100 @@ static unsigned long
> > samsung_pll45xx_recalc_rate(struct clk_hw *hw,>
> > return (unsigned long)fvco;
> >
> > }
> >
> > +static bool samsung_pll45xx_mp_change(u32 pll_con0, u32 pll_con1,
> > + const struct samsung_pll_rate_table
> > *rate) +{
> > + u32 old_mdiv, old_pdiv, old_afc;
> > +
> > + old_mdiv = (pll_con0 >> PLL45XX_MDIV_SHIFT) &
> > PLL45XX_MDIV_MASK;
> > + old_pdiv = (pll_con0 >> PLL45XX_PDIV_SHIFT) &
> > PLL45XX_PDIV_MASK;
> > + old_afc = (pll_con1 >> PLL45XX_AFC_SHIFT) & PLL45XX_AFC_MASK;
>
> old_afc doesn't required in this function.
>
> > +
> > + return (old_mdiv != rate->mdiv || old_pdiv != rate->pdiv);
Actually it should be included in the comparison above. Thanks for
spotting.
> > +}
> > +
> > +static int samsung_pll45xx_set_rate(struct clk_hw *hw, unsigned long
> > drate, + unsigned long prate)
> > +{
> > + struct samsung_clk_pll *pll = to_clk_pll(hw);
> > + const struct samsung_pll_rate_table *rate;
> > + u32 con0, con1;
> > + ktime_t start;
> > +
> > + /* Get required rate settings from table */
> > + rate = samsung_get_pll_settings(pll, drate);
> > + if (!rate) {
> > + pr_err("%s: Invalid rate : %lu for pll clk %s\n",
> > __func__, + drate, __clk_get_name(hw->clk));
> > + return -EINVAL;
> > + }
> > +
> > + con0 = __raw_readl(pll->con_reg);
> > + con1 = __raw_readl(pll->con_reg + 0x4);
> > +
> > + if (!(samsung_pll45xx_mp_change(con0, con1, rate))) {
> > + /* If only s change, change just s value only*/
> > + con0 &= ~(PLL45XX_SDIV_MASK << PLL45XX_SDIV_SHIFT);
> > + con0 |= rate->sdiv << PLL45XX_SDIV_SHIFT;
> > + __raw_writel(con0, pll->con_reg);
> > +
> > + return 0;
> > + }
> > +
> > + /* Set PLL PMS values. */
> > + con0 &= ~((PLL45XX_MDIV_MASK << PLL45XX_MDIV_SHIFT) |
> > + (PLL45XX_PDIV_MASK << PLL45XX_PDIV_SHIFT) |
> > + (PLL45XX_SDIV_MASK << PLL45XX_SDIV_SHIFT));
> > + con0 |= (rate->mdiv << PLL45XX_MDIV_SHIFT) |
> > + (rate->pdiv << PLL45XX_PDIV_SHIFT) |
> > + (rate->sdiv << PLL45XX_SDIV_SHIFT);
> > +
> > + /* Set PLL AFC value. */
> > + con1 = __raw_readl(pll->con_reg + 0x4);
> > + con1 &= ~(PLL45XX_AFC_MASK << PLL45XX_AFC_SHIFT);
> > + con1 |= (rate->afc << PLL45XX_AFC_SHIFT);
> > +
>
> Do we need to take care of AFC_ENB also, if we are using AFC ?
I'm not really sure. The original vendor code seems to not touch this bit
at all, assuming that it has been configured by the bootloader.
We should take care for the AFC coefficient, though, as AFC might have been
enabled at bootup.
I'd like to hear an opinion from someone from SLSI. Kukjin, Jingoo, do you
know anything about this?
Best regards,
Tomasz
next prev parent reply other threads:[~2013-08-21 12:49 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-20 17:31 [PATCH 00/16] Exynos clock clean-up for 3.12 Tomasz Figa
2013-08-20 17:31 ` [PATCH 01/16] pwm: samsung: Update DT bindings documentation to cover clocks Tomasz Figa
2013-08-20 20:34 ` Stephen Warren
2013-08-20 22:32 ` Tomasz Figa
2013-08-20 17:31 ` [PATCH 02/16] ARM: dts: exynos4: Specify PWM clocks in PWM node Tomasz Figa
2013-08-20 17:31 ` [PATCH 03/16] clocksource: samsung_pwm_timer: Get clock from device tree Tomasz Figa
2013-08-20 17:31 ` [PATCH 04/16] clk: samsung: exynos4: Use separate aliases for cpufreq related clocks Tomasz Figa
2013-08-20 17:31 ` [PATCH 05/16] clk: samsung: Modify _get_rate() helper to use __clk_lookup() Tomasz Figa
2013-08-20 17:31 ` [PATCH 06/16] clk: samsung: exynos4: Remove unused static clkdev aliases Tomasz Figa
2013-08-20 17:31 ` [PATCH 07/16] clk: samsung: exynos4: Remove checks for DT node Tomasz Figa
2013-08-20 17:31 ` [PATCH 08/16] clk: samsung: exynos4: Rename exynos4_plls to exynos4x12_plls Tomasz Figa
2013-08-20 17:31 ` [PATCH 09/16] clk: samsung: pll: Use new registration method for PLL45xx Tomasz Figa
2013-08-21 13:17 ` Yadwinder Singh Brar
2013-08-22 19:59 ` Stephen Warren
2013-08-20 17:31 ` [PATCH 10/16] clk: samsung: pll: Add support for rate configuration of PLL45xx Tomasz Figa
2013-08-21 12:18 ` Yadwinder Singh Brar
2013-08-21 12:49 ` Tomasz Figa [this message]
2013-08-20 17:31 ` [PATCH 11/16] clk: samsung: pll: Use new registration method for PLL46xx Tomasz Figa
2013-08-20 17:31 ` [PATCH 12/16] clk: samsung: pll: Add support for rate configuration of PLL46xx Tomasz Figa
2013-08-21 12:32 ` Yadwinder Singh Brar
2013-08-21 12:44 ` Tomasz Figa
2013-08-21 13:12 ` Yadwinder Singh Brar
2013-08-20 17:31 ` [PATCH 13/16] clk: samsung: exynos4: Reorder registration of mout_vpllsrc Tomasz Figa
2013-08-20 17:31 ` [PATCH 14/16] clk: samsung: exynos4: Register PLL rate tables for Exynos4210 Tomasz Figa
2013-08-21 12:34 ` Yadwinder Singh Brar
2013-08-21 12:45 ` Tomasz Figa
2013-08-20 17:31 ` [PATCH 15/16] clk: samsung: exynos4: Register PLL rate tables for Exynos4x12 Tomasz Figa
2013-08-20 17:31 ` [PATCH 16/16] clk: samsung: exynos5250: Simplify registration of PLL rate tables Tomasz Figa
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=2043626.uA5zP9MS4G@amdc1227 \
--to=t.figa@samsung.com \
--cc=linux-arm-kernel@lists.infradead.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