From: t.figa@samsung.com (Tomasz Figa)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH V2 06/10] clk/samsung: add support for pll2650xx
Date: Thu, 23 Jan 2014 19:46:03 +0100 [thread overview]
Message-ID: <52E1636B.70702@samsung.com> (raw)
In-Reply-To: <1389099548-14649-7-git-send-email-rahul.sharma@samsung.com>
Hi Rahul,
On 07.01.2014 13:59, Rahul Sharma wrote:
> Add support for pll2650xx in samsung pll file. This pll variant
> is close to pll36xx but uses CON2 registers instead of CON1.
>
> Aud_pll in Exynos5260 is pll2650xx and uses this code.
>
> Signed-off-by: Rahul Sharma <rahul.sharma@samsung.com>
> ---
> drivers/clk/samsung/clk-pll.c | 101 +++++++++++++++++++++++++++++++++++++++++
> drivers/clk/samsung/clk-pll.h | 2 +-
> 2 files changed, 102 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/clk/samsung/clk-pll.c b/drivers/clk/samsung/clk-pll.c
> index 08f85ae..35cbc60 100644
> --- a/drivers/clk/samsung/clk-pll.c
> +++ b/drivers/clk/samsung/clk-pll.c
> @@ -812,6 +812,101 @@ static const struct clk_ops samsung_pll2550xx_clk_min_ops = {
> .recalc_rate = samsung_pll2550xx_recalc_rate,
> };
>
> +/*
> + * PLL2650XX Clock Type
> + */
> +
> +/* Maximum lock time can be 3000 * PDIV cycles */
> +#define PLL2650XX_LOCK_FACTOR (3000)
> +
> +#define PLL2650XX_MDIV_SHIFT (9)
> +#define PLL2650XX_PDIV_SHIFT (3)
> +#define PLL2650XX_SDIV_SHIFT (0)
> +#define PLL2650XX_KDIV_SHIFT (0)
> +#define PLL2650XX_MDIV_MASK (0x1ff)
> +#define PLL2650XX_PDIV_MASK (0x3f)
> +#define PLL2650XX_SDIV_MASK (0x7)
> +#define PLL2650XX_KDIV_MASK (0xffff)
> +#define PLL2650XX_PLL_ENABLE_SHIFT (23)
> +#define PLL2650XX_PLL_LOCKTIME_SHIFT (21)
> +#define PLL2650XX_PLL_FOUTMASK_SHIFT (31)
For single bit fields it would be better to use simple definitions,
using BIT() macro, such as
#define PLL2650XX_PLL_ENABLE BIT(23)
and then using it with | or & ~ operators directly.
Also there is no need for parentheses around simple integers.
> +
> +static unsigned long samsung_pll2650xx_recalc_rate(struct clk_hw *hw,
> + unsigned long parent_rate)
> +{
> + struct samsung_clk_pll *pll = to_clk_pll(hw);
> + u32 mdiv, pdiv, sdiv, pll_con0, pll_con2;
> + s16 kdiv;
> + u64 fvco = parent_rate;
> +
> + pll_con0 = __raw_readl(pll->con_reg);
> + pll_con2 = __raw_readl(pll->con_reg + 8);
> + mdiv = (pll_con0 >> PLL2650XX_MDIV_SHIFT) & PLL2650XX_MDIV_MASK;
> + pdiv = (pll_con0 >> PLL2650XX_PDIV_SHIFT) & PLL2650XX_PDIV_MASK;
> + sdiv = (pll_con0 >> PLL2650XX_SDIV_SHIFT) & PLL2650XX_SDIV_MASK;
> + kdiv = (s16)(pll_con2 & PLL2650XX_KDIV_MASK);
> +
> + fvco *= (mdiv << 16) + kdiv;
> + do_div(fvco, (pdiv << sdiv));
> + fvco >>= 16;
> +
> + return (unsigned long)fvco;
> +}
> +
> +static int samsung_pll2650xx_set_rate(struct clk_hw *hw, unsigned long drate,
> + unsigned long parent_rate)
> +{
> + struct samsung_clk_pll *pll = to_clk_pll(hw);
> + u32 tmp, pll_con0, pll_con2;
> + const struct samsung_pll_rate_table *rate;
> +
> + 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;
> + }
> +
> + pll_con0 = __raw_readl(pll->con_reg);
> + pll_con2 = __raw_readl(pll->con_reg + 8);
> +
> + /* Change PLL PMS values */
> + pll_con0 &= ~(PLL2650XX_MDIV_MASK << PLL2650XX_MDIV_SHIFT |
> + PLL2650XX_PDIV_MASK << PLL2650XX_PDIV_SHIFT |
> + PLL2650XX_SDIV_MASK << PLL2650XX_SDIV_SHIFT);
> + pll_con0 |= rate->mdiv << PLL2650XX_MDIV_SHIFT;
> + pll_con0 |= rate->pdiv << PLL2650XX_PDIV_SHIFT;
> + pll_con0 |= rate->sdiv << PLL2650XX_SDIV_SHIFT;
> + pll_con0 |= 1 << PLL2650XX_PLL_ENABLE_SHIFT;
> + pll_con0 |= 1 << PLL2650XX_PLL_FOUTMASK_SHIFT;
> +
> + pll_con2 &= ~(PLL2650XX_KDIV_MASK << PLL2650XX_KDIV_SHIFT);
> + pll_con2 |= ((~(rate->kdiv) + 1) & PLL2650XX_KDIV_MASK)
> + << PLL2650XX_KDIV_SHIFT;
Huh? This looks suspiciously. Why KDIV needs to be negated and increased
by 1?
> +
> + /* Set PLL lock time. */
> + __raw_writel(PLL2650XX_LOCK_FACTOR * rate->pdiv, pll->lock_reg);
> +
> + __raw_writel(pll_con0, pll->con_reg);
> + __raw_writel(pll_con2, pll->con_reg + 8);
> +
> + do {
> + tmp = __raw_readl(pll->con_reg);
> + } while (!(tmp & (0x1 << PLL2650XX_PLL_LOCKTIME_SHIFT)));
Is the right bit being checked here? On other PLLs it's 29th bit named
LOCK_STAT. Could you confirm this?
> +
> + return 0;
> +}
> +
> +static const struct clk_ops samsung_pll2650xx_clk_ops = {
> + .recalc_rate = samsung_pll2650xx_recalc_rate,
> + .set_rate = samsung_pll2650xx_set_rate,
> + .round_rate = samsung_pll_round_rate,
> +};
> +
> +static const struct clk_ops samsung_pll2650xx_clk_min_ops = {
> + .recalc_rate = samsung_pll2650xx_recalc_rate,
> +};
> +
> static void __init _samsung_clk_register_pll(struct samsung_clk_provider *ctx,
> struct samsung_pll_clock *pll_clk,
> void __iomem *base)
> @@ -895,6 +990,12 @@ static void __init _samsung_clk_register_pll(struct samsung_clk_provider *ctx,
> else
> init.ops = &samsung_pll2550xx_clk_ops;
> break;
> + case pll_2650xx:
> + if (!pll->rate_table)
> + init.ops = &samsung_pll2650xx_clk_min_ops;
> + else
> + init.ops = &samsung_pll2650xx_clk_ops;
> + break;
> default:
> pr_warn("%s: Unknown pll type for pll clk %s\n",
> __func__, pll_clk->name);
> diff --git a/drivers/clk/samsung/clk-pll.h b/drivers/clk/samsung/clk-pll.h
> index e106470..b326e94 100644
> --- a/drivers/clk/samsung/clk-pll.h
> +++ b/drivers/clk/samsung/clk-pll.h
> @@ -26,6 +26,7 @@ enum samsung_pll_type {
> pll_6552,
> pll_6553,
> pll_2550xx,
> + pll_2650xx,
> };
>
> #define PLL_35XX_RATE(_rate, _m, _p, _s) \
> @@ -93,5 +94,4 @@ struct samsung_pll_rate_table {
> extern struct clk * __init samsung_clk_register_pll2550x(const char *name,
> const char *pname, const void __iomem *reg_base,
> const unsigned long offset);
> -
Not a part of this change.
Best regards,
Tomasz
next prev parent reply other threads:[~2014-01-23 18:46 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-07 12:58 [PATCH V2 00/10] exynos: add basic support for exynos5260 SoC Rahul Sharma
2014-01-07 12:58 ` [PATCH V2 01/10] clk/exynos5410: move suspend/resume handling to SoC driver Rahul Sharma
2014-01-23 18:19 ` Tomasz Figa
2014-01-07 12:59 ` [PATCH V2 02/10] ARM: EXYNOS: initial board support for exynos5260 SoC Rahul Sharma
2014-01-07 13:24 ` Arnd Bergmann
2014-01-08 5:32 ` Rahul Sharma
2014-01-07 12:59 ` [PATCH V2 03/10] pinctrl: exynos: add exynos5260 SoC specific data Rahul Sharma
2014-01-07 13:31 ` Arnd Bergmann
2014-01-23 18:38 ` Tomasz Figa
2014-01-07 12:59 ` [PATCH V2 04/10] clk/samsung: add support for multiple clock providers Rahul Sharma
2014-01-23 18:24 ` Tomasz Figa
2014-01-07 12:59 ` [PATCH V2 05/10] clk/samsung: add support for pll2550xx Rahul Sharma
2014-01-23 18:40 ` Tomasz Figa
2014-01-07 12:59 ` [PATCH V2 06/10] clk/samsung: add support for pll2650xx Rahul Sharma
2014-01-23 18:46 ` Tomasz Figa [this message]
2014-01-07 12:59 ` [PATCH V2 07/10] clk/exynos5260: add macros and documentation for exynos5260 Rahul Sharma
2014-01-07 12:59 ` [PATCH V2 08/10] clk/exynos5260: add clock file " Rahul Sharma
2014-01-07 12:59 ` [PATCH V2 09/10] ARM: dts: add dts files for exynos5260 SoC Rahul Sharma
2014-01-07 12:59 ` [PATCH V2 10/10] ARM: dts: add dts files for xyref5260 board Rahul Sharma
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=52E1636B.70702@samsung.com \
--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;
as well as URLs for NNTP newsgroup(s).