blob: e735107ddab002e5c01258275ab22eacacdbb82d [file] [log] [blame]
Andrew Bresticker8e4b7722015-02-24 19:56:02 -08001/*
2 * Copyright (C) 2014 Google, Inc.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License,
6 * version 2, as published by the Free Software Foundation.
7 */
8
9#ifndef __PISTACHIO_CLK_H
10#define __PISTACHIO_CLK_H
11
12#include <linux/clk-provider.h>
13
14struct pistachio_gate {
15 unsigned int id;
16 unsigned long reg;
17 unsigned int shift;
18 const char *name;
19 const char *parent;
20};
21
22#define GATE(_id, _name, _pname, _reg, _shift) \
23 { \
24 .id = _id, \
25 .reg = _reg, \
26 .shift = _shift, \
27 .name = _name, \
28 .parent = _pname, \
29 }
30
31struct pistachio_mux {
32 unsigned int id;
33 unsigned long reg;
34 unsigned int shift;
35 unsigned int num_parents;
36 const char *name;
37 const char **parents;
38};
39
40#define PNAME(x) static const char *x[] __initconst
41
42#define MUX(_id, _name, _pnames, _reg, _shift) \
43 { \
44 .id = _id, \
45 .reg = _reg, \
46 .shift = _shift, \
47 .name = _name, \
48 .parents = _pnames, \
49 .num_parents = ARRAY_SIZE(_pnames) \
50 }
51
52
53struct pistachio_div {
54 unsigned int id;
55 unsigned long reg;
56 unsigned int width;
57 unsigned int div_flags;
58 const char *name;
59 const char *parent;
60};
61
62#define DIV(_id, _name, _pname, _reg, _width) \
63 { \
64 .id = _id, \
65 .reg = _reg, \
66 .width = _width, \
67 .div_flags = 0, \
68 .name = _name, \
69 .parent = _pname, \
70 }
71
72#define DIV_F(_id, _name, _pname, _reg, _width, _div_flags) \
73 { \
74 .id = _id, \
75 .reg = _reg, \
76 .width = _width, \
77 .div_flags = _div_flags, \
78 .name = _name, \
79 .parent = _pname, \
80 }
81
82struct pistachio_fixed_factor {
83 unsigned int id;
84 unsigned int div;
85 const char *name;
86 const char *parent;
87};
88
89#define FIXED_FACTOR(_id, _name, _pname, _div) \
90 { \
91 .id = _id, \
92 .div = _div, \
93 .name = _name, \
94 .parent = _pname, \
95 }
96
97struct pistachio_clk_provider {
98 struct device_node *node;
99 void __iomem *base;
100 struct clk_onecell_data clk_data;
101};
102
103extern struct pistachio_clk_provider *
104pistachio_clk_alloc_provider(struct device_node *node, unsigned int num_clks);
105extern void pistachio_clk_register_provider(struct pistachio_clk_provider *p);
106
107extern void pistachio_clk_register_gate(struct pistachio_clk_provider *p,
108 struct pistachio_gate *gate,
109 unsigned int num);
110extern void pistachio_clk_register_mux(struct pistachio_clk_provider *p,
111 struct pistachio_mux *mux,
112 unsigned int num);
113extern void pistachio_clk_register_div(struct pistachio_clk_provider *p,
114 struct pistachio_div *div,
115 unsigned int num);
116extern void
117pistachio_clk_register_fixed_factor(struct pistachio_clk_provider *p,
118 struct pistachio_fixed_factor *ff,
119 unsigned int num);
120
121extern void pistachio_clk_force_enable(struct pistachio_clk_provider *p,
122 unsigned int *clk_ids, unsigned int num);
123
124#endif