]>
Commit | Line | Data |
---|---|---|
b886d83c | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
bda00303 RJ |
2 | /* |
3 | * Marvell PXA family clocks | |
4 | * | |
5 | * Copyright (C) 2014 Robert Jarzmik | |
6 | * | |
7 | * Common clock code for PXA clocks ("CKEN" type clocks + DT) | |
bda00303 RJ |
8 | */ |
9 | #ifndef _CLK_PXA_ | |
10 | #define _CLK_PXA_ | |
11 | ||
9fe69429 RJ |
12 | #define CLKCFG_TURBO 0x1 |
13 | #define CLKCFG_FCS 0x2 | |
14 | #define CLKCFG_HALFTURBO 0x4 | |
15 | #define CLKCFG_FASTBUS 0x8 | |
16 | ||
bda00303 | 17 | #define PARENTS(name) \ |
4a1caed3 | 18 | static const char *const name ## _parents[] __initconst |
bda00303 RJ |
19 | #define MUX_RO_RATE_RO_OPS(name, clk_name) \ |
20 | static struct clk_hw name ## _mux_hw; \ | |
21 | static struct clk_hw name ## _rate_hw; \ | |
6487649e | 22 | static const struct clk_ops name ## _mux_ops = { \ |
bda00303 RJ |
23 | .get_parent = name ## _get_parent, \ |
24 | .set_parent = dummy_clk_set_parent, \ | |
25 | }; \ | |
6487649e | 26 | static const struct clk_ops name ## _rate_ops = { \ |
bda00303 RJ |
27 | .recalc_rate = name ## _get_rate, \ |
28 | }; \ | |
14dd5b01 | 29 | static struct clk * __init clk_register_ ## name(void) \ |
bda00303 RJ |
30 | { \ |
31 | return clk_register_composite(NULL, clk_name, \ | |
32 | name ## _parents, \ | |
33 | ARRAY_SIZE(name ## _parents), \ | |
34 | &name ## _mux_hw, &name ## _mux_ops, \ | |
35 | &name ## _rate_hw, &name ## _rate_ops, \ | |
36 | NULL, NULL, CLK_GET_RATE_NOCACHE); \ | |
37 | } | |
38 | ||
9fe69429 RJ |
39 | #define RATE_RO_OPS(name, clk_name) \ |
40 | static struct clk_hw name ## _rate_hw; \ | |
6487649e | 41 | static const struct clk_ops name ## _rate_ops = { \ |
9fe69429 RJ |
42 | .recalc_rate = name ## _get_rate, \ |
43 | }; \ | |
44 | static struct clk * __init clk_register_ ## name(void) \ | |
45 | { \ | |
46 | return clk_register_composite(NULL, clk_name, \ | |
47 | name ## _parents, \ | |
48 | ARRAY_SIZE(name ## _parents), \ | |
49 | NULL, NULL, \ | |
50 | &name ## _rate_hw, &name ## _rate_ops, \ | |
51 | NULL, NULL, CLK_GET_RATE_NOCACHE); \ | |
52 | } | |
53 | ||
54 | #define RATE_OPS(name, clk_name) \ | |
bda00303 | 55 | static struct clk_hw name ## _rate_hw; \ |
6487649e | 56 | static const struct clk_ops name ## _rate_ops = { \ |
bda00303 | 57 | .recalc_rate = name ## _get_rate, \ |
9fe69429 RJ |
58 | .set_rate = name ## _set_rate, \ |
59 | .determine_rate = name ## _determine_rate, \ | |
bda00303 | 60 | }; \ |
14dd5b01 | 61 | static struct clk * __init clk_register_ ## name(void) \ |
bda00303 RJ |
62 | { \ |
63 | return clk_register_composite(NULL, clk_name, \ | |
64 | name ## _parents, \ | |
65 | ARRAY_SIZE(name ## _parents), \ | |
66 | NULL, NULL, \ | |
67 | &name ## _rate_hw, &name ## _rate_ops, \ | |
68 | NULL, NULL, CLK_GET_RATE_NOCACHE); \ | |
69 | } | |
70 | ||
9fe69429 RJ |
71 | #define MUX_OPS(name, clk_name, flags) \ |
72 | static struct clk_hw name ## _mux_hw; \ | |
73 | static const struct clk_ops name ## _mux_ops = { \ | |
74 | .get_parent = name ## _get_parent, \ | |
75 | .set_parent = name ## _set_parent, \ | |
76 | .determine_rate = name ## _determine_rate, \ | |
77 | }; \ | |
78 | static struct clk * __init clk_register_ ## name(void) \ | |
79 | { \ | |
80 | return clk_register_composite(NULL, clk_name, \ | |
81 | name ## _parents, \ | |
82 | ARRAY_SIZE(name ## _parents), \ | |
83 | &name ## _mux_hw, &name ## _mux_ops, \ | |
84 | NULL, NULL, \ | |
85 | NULL, NULL, \ | |
86 | CLK_GET_RATE_NOCACHE | flags); \ | |
87 | } | |
88 | ||
bda00303 RJ |
89 | /* |
90 | * CKEN clock type | |
91 | * This clock takes it source from 2 possible parents : | |
92 | * - a low power parent | |
93 | * - a normal parent | |
94 | * | |
95 | * +------------+ +-----------+ | |
96 | * | Low Power | --- | x mult_lp | | |
97 | * | Clock | | / div_lp |\ | |
98 | * +------------+ +-----------+ \+-----+ +-----------+ | |
99 | * | Mux |---| CKEN gate | | |
100 | * +------------+ +-----------+ /+-----+ +-----------+ | |
101 | * | High Power | | x mult_hp |/ | |
102 | * | Clock | --- | / div_hp | | |
103 | * +------------+ +-----------+ | |
104 | */ | |
14dd5b01 | 105 | struct desc_clk_cken { |
bda00303 RJ |
106 | struct clk_hw hw; |
107 | int ckid; | |
108 | const char *name; | |
109 | const char *dev_id; | |
110 | const char *con_id; | |
22109785 | 111 | const char * const *parent_names; |
bda00303 RJ |
112 | struct clk_fixed_factor lp; |
113 | struct clk_fixed_factor hp; | |
114 | struct clk_gate gate; | |
115 | bool (*is_in_low_power)(void); | |
116 | const unsigned long flags; | |
117 | }; | |
118 | ||
119 | #define PXA_CKEN(_dev_id, _con_id, _name, parents, _mult_lp, _div_lp, \ | |
120 | _mult_hp, _div_hp, is_lp, _cken_reg, _cken_bit, flag) \ | |
121 | { .ckid = CLK_ ## _name, .name = #_name, \ | |
122 | .dev_id = _dev_id, .con_id = _con_id, .parent_names = parents,\ | |
123 | .lp = { .mult = _mult_lp, .div = _div_lp }, \ | |
124 | .hp = { .mult = _mult_hp, .div = _div_hp }, \ | |
125 | .is_in_low_power = is_lp, \ | |
126 | .gate = { .reg = (void __iomem *)_cken_reg, .bit_idx = _cken_bit }, \ | |
127 | .flags = flag, \ | |
128 | } | |
129 | #define PXA_CKEN_1RATE(dev_id, con_id, name, parents, cken_reg, \ | |
130 | cken_bit, flag) \ | |
131 | PXA_CKEN(dev_id, con_id, name, parents, 1, 1, 1, 1, \ | |
132 | NULL, cken_reg, cken_bit, flag) | |
133 | ||
9fe69429 RJ |
134 | struct pxa2xx_freq { |
135 | unsigned long cpll; | |
136 | unsigned int membus_khz; | |
137 | unsigned int cccr; | |
138 | unsigned int div2; | |
139 | unsigned int clkcfg; | |
140 | }; | |
141 | ||
e0a3862c | 142 | static inline int dummy_clk_set_parent(struct clk_hw *hw, u8 index) |
bda00303 RJ |
143 | { |
144 | return 0; | |
145 | } | |
146 | ||
147 | extern void clkdev_pxa_register(int ckid, const char *con_id, | |
148 | const char *dev_id, struct clk *clk); | |
14dd5b01 | 149 | extern int clk_pxa_cken_init(const struct desc_clk_cken *clks, int nb_clks); |
6f8a444a | 150 | void clk_pxa_dt_common_init(struct device_node *np); |
bda00303 | 151 | |
9fe69429 RJ |
152 | void pxa2xx_core_turbo_switch(bool on); |
153 | void pxa2xx_cpll_change(struct pxa2xx_freq *freq, | |
84558ff7 SB |
154 | u32 (*mdrefr_dri)(unsigned int), void __iomem *mdrefr, |
155 | void __iomem *cccr); | |
9fe69429 RJ |
156 | int pxa2xx_determine_rate(struct clk_rate_request *req, |
157 | struct pxa2xx_freq *freqs, int nb_freqs); | |
158 | ||
bda00303 | 159 | #endif |