Skip to content

Commit

Permalink
clk: vt8500: parse pmc_base from clock driver
Browse files Browse the repository at this point in the history
Currently, clock providers for vt8500 depend on machine_init providing
pmc_base address before calling of_clk_init. With upcoming arch-wide
.time_init calling of_clk_init, we should make clock providers independent
of mach code. This adds a pmc_base parsing helper to current clock provider
that gets called if there is no pmc_base set, yet.

Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Acked-by: Tony Prisk <linux@prisktech.co.nz>
Acked-by: Mike Turquette <mturquette@linaro.org>
  • Loading branch information
shesselba committed Sep 29, 2013
1 parent be08045 commit f9e4a18
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions drivers/clk/clk-vt8500.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,14 @@

#include <linux/io.h>
#include <linux/of.h>
#include <linux/of_address.h>
#include <linux/slab.h>
#include <linux/bitops.h>
#include <linux/clkdev.h>
#include <linux/clk-provider.h>

#define LEGACY_PMC_BASE 0xD8130000

/* All clocks share the same lock as none can be changed concurrently */
static DEFINE_SPINLOCK(_lock);

Expand Down Expand Up @@ -53,6 +56,21 @@ struct clk_pll {

static void __iomem *pmc_base;

static __init void vtwm_set_pmc_base(void)
{
struct device_node *np =
of_find_compatible_node(NULL, NULL, "via,vt8500-pmc");

if (np)
pmc_base = of_iomap(np, 0);
else
pmc_base = ioremap(LEGACY_PMC_BASE, 0x1000);
of_node_put(np);

if (!pmc_base)
pr_err("%s:of_iomap(pmc) failed\n", __func__);
}

#define to_clk_device(_hw) container_of(_hw, struct clk_device, hw)

#define VT8500_PMC_BUSY_MASK 0x18
Expand Down Expand Up @@ -222,6 +240,9 @@ static __init void vtwm_device_clk_init(struct device_node *node)
int rc;
int clk_init_flags = 0;

if (!pmc_base)
vtwm_set_pmc_base();

dev_clk = kzalloc(sizeof(*dev_clk), GFP_KERNEL);
if (WARN_ON(!dev_clk))
return;
Expand Down Expand Up @@ -636,6 +657,9 @@ static __init void vtwm_pll_clk_init(struct device_node *node, int pll_type)
struct clk_init_data init;
int rc;

if (!pmc_base)
vtwm_set_pmc_base();

rc = of_property_read_u32(node, "reg", &reg);
if (WARN_ON(rc))
return;
Expand Down

0 comments on commit f9e4a18

Please sign in to comment.