forked from Minki/linux
819c1de344
Add a CLK_SET_RATE_NO_REPARENT clock flag, which will prevent muxes being reparented during clk_set_rate. To avoid breaking existing platforms, all callers of clk_register_mux() are adjusted to pass the new flag. Platform maintainers are encouraged to remove the flag if they wish to allow mux reparenting on set_rate. Signed-off-by: James Hogan <james.hogan@imgtec.com> Reviewed-by: Stephen Boyd <sboyd@codeaurora.org> Cc: Mike Turquette <mturquette@linaro.org> Cc: Russell King <linux@arm.linux.org.uk> Cc: Sascha Hauer <kernel@pengutronix.de> Cc: Stephen Warren <swarren@wwwdotorg.org> Cc: Viresh Kumar <viresh.linux@gmail.com> Cc: Kukjin Kim <kgene.kim@samsung.com> Cc: Haojian Zhuang <haojian.zhuang@linaro.org> Cc: Chao Xie <xiechao.mail@gmail.com> Cc: Arnd Bergmann <arnd@arndb.de> Cc: "Emilio López" <emilio@elopez.com.ar> Cc: Gregory CLEMENT <gregory.clement@free-electrons.com> Cc: Maxime Ripard <maxime.ripard@free-electrons.com> Cc: Prashant Gaikwad <pgaikwad@nvidia.com> Cc: Thierry Reding <thierry.reding@gmail.com> Cc: Peter De Schrijver <pdeschrijver@nvidia.com> Cc: Pawel Moll <pawel.moll@arm.com> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Andrew Chew <achew@nvidia.com> Cc: Doug Anderson <dianders@chromium.org> Cc: Heiko Stuebner <heiko@sntech.de> Cc: Paul Walmsley <pwalmsley@nvidia.com> Cc: Sylwester Nawrocki <s.nawrocki@samsung.com> Cc: Thomas Abraham <thomas.abraham@linaro.org> Cc: Tomasz Figa <t.figa@samsung.com> Cc: linux-arm-kernel@lists.infradead.org Cc: linux-samsung-soc@vger.kernel.org Cc: spear-devel@list.st.com Cc: linux-tegra@vger.kernel.org Tested-by: Haojian Zhuang <haojian.zhuang@gmail.com> Acked-by: Stephen Warren <swarren@nvidia.com> [tegra] Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com> [sunxi] Acked-by: Sören Brinkmann <soren.brinkmann@xilinx.com> [Zynq] Signed-off-by: Mike Turquette <mturquette@linaro.org>
87 lines
2.4 KiB
C
87 lines
2.4 KiB
C
/*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
* published by the Free Software Foundation.
|
|
*
|
|
* 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.
|
|
*
|
|
* Copyright (C) 2012 ARM Limited
|
|
*/
|
|
|
|
#include <linux/amba/sp810.h>
|
|
#include <linux/clkdev.h>
|
|
#include <linux/clk-provider.h>
|
|
#include <linux/err.h>
|
|
#include <linux/vexpress.h>
|
|
|
|
static struct clk *vexpress_sp810_timerclken[4];
|
|
static DEFINE_SPINLOCK(vexpress_sp810_lock);
|
|
|
|
static void __init vexpress_sp810_init(void __iomem *base)
|
|
{
|
|
int i;
|
|
|
|
if (WARN_ON(!base))
|
|
return;
|
|
|
|
for (i = 0; i < ARRAY_SIZE(vexpress_sp810_timerclken); i++) {
|
|
char name[12];
|
|
const char *parents[] = {
|
|
"v2m:refclk32khz", /* REFCLK */
|
|
"v2m:refclk1mhz" /* TIMCLK */
|
|
};
|
|
|
|
snprintf(name, ARRAY_SIZE(name), "timerclken%d", i);
|
|
|
|
vexpress_sp810_timerclken[i] = clk_register_mux(NULL, name,
|
|
parents, 2, CLK_SET_RATE_NO_REPARENT,
|
|
base + SCCTRL, SCCTRL_TIMERENnSEL_SHIFT(i), 1,
|
|
0, &vexpress_sp810_lock);
|
|
|
|
if (WARN_ON(IS_ERR(vexpress_sp810_timerclken[i])))
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
static const char * const vexpress_clk_24mhz_periphs[] __initconst = {
|
|
"mb:uart0", "mb:uart1", "mb:uart2", "mb:uart3",
|
|
"mb:mmci", "mb:kmi0", "mb:kmi1"
|
|
};
|
|
|
|
void __init vexpress_clk_init(void __iomem *sp810_base)
|
|
{
|
|
struct clk *clk;
|
|
int i;
|
|
|
|
clk = clk_register_fixed_rate(NULL, "dummy_apb_pclk", NULL,
|
|
CLK_IS_ROOT, 0);
|
|
WARN_ON(clk_register_clkdev(clk, "apb_pclk", NULL));
|
|
|
|
clk = clk_register_fixed_rate(NULL, "v2m:clk_24mhz", NULL,
|
|
CLK_IS_ROOT, 24000000);
|
|
for (i = 0; i < ARRAY_SIZE(vexpress_clk_24mhz_periphs); i++)
|
|
WARN_ON(clk_register_clkdev(clk, NULL,
|
|
vexpress_clk_24mhz_periphs[i]));
|
|
|
|
clk = clk_register_fixed_rate(NULL, "v2m:refclk32khz", NULL,
|
|
CLK_IS_ROOT, 32768);
|
|
WARN_ON(clk_register_clkdev(clk, NULL, "v2m:wdt"));
|
|
|
|
clk = clk_register_fixed_rate(NULL, "v2m:refclk1mhz", NULL,
|
|
CLK_IS_ROOT, 1000000);
|
|
|
|
vexpress_sp810_init(sp810_base);
|
|
|
|
for (i = 0; i < ARRAY_SIZE(vexpress_sp810_timerclken); i++)
|
|
WARN_ON(clk_set_parent(vexpress_sp810_timerclken[i], clk));
|
|
|
|
WARN_ON(clk_register_clkdev(vexpress_sp810_timerclken[0],
|
|
"v2m-timer0", "sp804"));
|
|
WARN_ON(clk_register_clkdev(vexpress_sp810_timerclken[1],
|
|
"v2m-timer1", "sp804"));
|
|
}
|