drm/amdgpu: fix warning in scheduler
[deliverable/linux.git] / drivers / clk / versatile / clk-versatile.c
CommitLineData
401301cc 1/*
a54c959d
RH
2 * Clock driver for the ARM Integrator/AP, Integrator/CP, Versatile AB and
3 * Versatile PB boards.
401301cc
LW
4 * Copyright (C) 2012 Linus Walleij
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10#include <linux/clk-provider.h>
a613163d
LW
11#include <linux/clk.h>
12#include <linux/clkdev.h>
13#include <linux/err.h>
09c978bc
LW
14#include <linux/of.h>
15#include <linux/of_address.h>
a613163d
LW
16
17#include "clk-icst.h"
18
09c978bc 19#define INTEGRATOR_HDR_LOCK_OFFSET 0x14
a613163d 20
a54c959d
RH
21#define VERSATILE_SYS_OSCCLCD_OFFSET 0x1c
22#define VERSATILE_SYS_LOCK_OFFSET 0x20
23
09c978bc
LW
24/* Base offset for the core module */
25static void __iomem *cm_base;
26
27static const struct icst_params cp_auxosc_params = {
a613163d
LW
28 .vco_max = ICST525_VCO_MAX_5V,
29 .vco_min = ICST525_VCO_MIN,
30 .vd_min = 8,
31 .vd_max = 263,
32 .rd_min = 3,
33 .rd_max = 65,
34 .s2div = icst525_s2div,
35 .idx2s = icst525_idx2s,
36};
37
09c978bc
LW
38static const struct clk_icst_desc __initdata cm_auxosc_desc = {
39 .params = &cp_auxosc_params,
7a9ad671
LW
40 .vco_offset = 0x1c,
41 .lock_offset = INTEGRATOR_HDR_LOCK_OFFSET,
a613163d
LW
42};
43
a54c959d
RH
44static const struct icst_params versatile_auxosc_params = {
45 .vco_max = ICST307_VCO_MAX,
46 .vco_min = ICST307_VCO_MIN,
47 .vd_min = 4 + 8,
48 .vd_max = 511 + 8,
49 .rd_min = 1 + 2,
50 .rd_max = 127 + 2,
51 .s2div = icst307_s2div,
52 .idx2s = icst307_idx2s,
53};
54
55static const struct clk_icst_desc versatile_auxosc_desc __initconst = {
56 .params = &versatile_auxosc_params,
57 .vco_offset = VERSATILE_SYS_OSCCLCD_OFFSET,
58 .lock_offset = VERSATILE_SYS_LOCK_OFFSET,
59};
60static void __init cm_osc_setup(struct device_node *np,
61 const struct clk_icst_desc *desc)
a613163d 62{
09c978bc
LW
63 struct clk *clk = ERR_PTR(-EINVAL);
64 const char *clk_name = np->name;
bf6edb4b 65 const char *parent_name;
a613163d 66
09c978bc
LW
67 if (!cm_base) {
68 /* Remap the core module base if not done yet */
69 struct device_node *parent;
a613163d 70
09c978bc 71 parent = of_get_parent(np);
e52786ac 72 if (!parent) {
09c978bc
LW
73 pr_err("no parent on core module clock\n");
74 return;
75 }
76 cm_base = of_iomap(parent, 0);
77 if (!cm_base) {
78 pr_err("could not remap core module base\n");
79 return;
80 }
81 }
a613163d 82
bf6edb4b
LW
83 parent_name = of_clk_get_parent_name(np, 0);
84 clk = icst_clk_register(NULL, desc, clk_name, parent_name, cm_base);
09c978bc
LW
85 if (!IS_ERR(clk))
86 of_clk_add_provider(np, of_clk_src_simple_get, clk);
a613163d 87}
a54c959d
RH
88
89static void __init of_integrator_cm_osc_setup(struct device_node *np)
90{
91 cm_osc_setup(np, &cm_auxosc_desc);
92}
09c978bc
LW
93CLK_OF_DECLARE(integrator_cm_auxosc_clk,
94 "arm,integrator-cm-auxosc", of_integrator_cm_osc_setup);
a54c959d
RH
95
96static void __init of_versatile_cm_osc_setup(struct device_node *np)
97{
98 cm_osc_setup(np, &versatile_auxosc_desc);
99}
100CLK_OF_DECLARE(versatile_cm_auxosc_clk,
101 "arm,versatile-cm-auxosc", of_versatile_cm_osc_setup);
This page took 0.172819 seconds and 5 git commands to generate.