aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/clk/tegra
diff options
context:
space:
mode:
authorPeter De Schrijver <pdeschrijver@nvidia.com>2013-11-18 10:11:37 -0500
committerPeter De Schrijver <pdeschrijver@nvidia.com>2013-11-26 11:46:52 -0500
commitbc44275b8ea2df7c77658b08955ec545a37560ab (patch)
treebd3e7d05833d75a4097dfc86cc507826b5d4cc34 /drivers/clk/tegra
parent2b239077d1e2061c65763dcf57ab978ae5261559 (diff)
clk: tegra: add locking to periph clks
Tegra124 has periph clocks which share the hw register. Hence locking is required. Signed-off-by: Peter De Schrijver <pdeschrijver@nvidia.com> Signed-off-by: Thierry Reding <treding@nvidia.com>
Diffstat (limited to 'drivers/clk/tegra')
-rw-r--r--drivers/clk/tegra/clk-tegra-periph.c33
-rw-r--r--drivers/clk/tegra/clk.h10
2 files changed, 24 insertions, 19 deletions
diff --git a/drivers/clk/tegra/clk-tegra-periph.c b/drivers/clk/tegra/clk-tegra-periph.c
index 9b04139f331d..e8d6f2f20141 100644
--- a/drivers/clk/tegra/clk-tegra-periph.c
+++ b/drivers/clk/tegra/clk-tegra-periph.c
@@ -118,75 +118,78 @@
118 _clk_num, _gate_flags, _clk_id) \ 118 _clk_num, _gate_flags, _clk_id) \
119 TEGRA_INIT_DATA_TABLE(_name, NULL, NULL, _parents, _offset,\ 119 TEGRA_INIT_DATA_TABLE(_name, NULL, NULL, _parents, _offset,\
120 30, MASK(2), 0, 0, 8, 1, TEGRA_DIVIDER_ROUND_UP, \ 120 30, MASK(2), 0, 0, 8, 1, TEGRA_DIVIDER_ROUND_UP, \
121 _clk_num, _gate_flags, _clk_id, _parents##_idx, 0) 121 _clk_num, _gate_flags, _clk_id, _parents##_idx, 0,\
122 NULL)
122 123
123#define MUX_FLAGS(_name, _parents, _offset,\ 124#define MUX_FLAGS(_name, _parents, _offset,\
124 _clk_num, _gate_flags, _clk_id, flags)\ 125 _clk_num, _gate_flags, _clk_id, flags)\
125 TEGRA_INIT_DATA_TABLE(_name, NULL, NULL, _parents, _offset,\ 126 TEGRA_INIT_DATA_TABLE(_name, NULL, NULL, _parents, _offset,\
126 30, MASK(2), 0, 0, 8, 1, TEGRA_DIVIDER_ROUND_UP,\ 127 30, MASK(2), 0, 0, 8, 1, TEGRA_DIVIDER_ROUND_UP,\
127 _clk_num, _gate_flags, _clk_id, _parents##_idx, flags) 128 _clk_num, _gate_flags, _clk_id, _parents##_idx, flags,\
129 NULL)
128 130
129#define MUX8(_name, _parents, _offset, \ 131#define MUX8(_name, _parents, _offset, \
130 _clk_num, _gate_flags, _clk_id) \ 132 _clk_num, _gate_flags, _clk_id) \
131 TEGRA_INIT_DATA_TABLE(_name, NULL, NULL, _parents, _offset,\ 133 TEGRA_INIT_DATA_TABLE(_name, NULL, NULL, _parents, _offset,\
132 29, MASK(3), 0, 0, 8, 1, TEGRA_DIVIDER_ROUND_UP,\ 134 29, MASK(3), 0, 0, 8, 1, TEGRA_DIVIDER_ROUND_UP,\
133 _clk_num, _gate_flags, _clk_id, _parents##_idx, 0) 135 _clk_num, _gate_flags, _clk_id, _parents##_idx, 0,\
136 NULL)
134 137
135#define INT(_name, _parents, _offset, \ 138#define INT(_name, _parents, _offset, \
136 _clk_num, _gate_flags, _clk_id) \ 139 _clk_num, _gate_flags, _clk_id) \
137 TEGRA_INIT_DATA_TABLE(_name, NULL, NULL, _parents, _offset,\ 140 TEGRA_INIT_DATA_TABLE(_name, NULL, NULL, _parents, _offset,\
138 30, MASK(2), 0, 0, 8, 1, TEGRA_DIVIDER_INT| \ 141 30, MASK(2), 0, 0, 8, 1, TEGRA_DIVIDER_INT| \
139 TEGRA_DIVIDER_ROUND_UP, _clk_num, _gate_flags,\ 142 TEGRA_DIVIDER_ROUND_UP, _clk_num, _gate_flags,\
140 _clk_id, _parents##_idx, 0) 143 _clk_id, _parents##_idx, 0, NULL)
141 144
142#define INT_FLAGS(_name, _parents, _offset,\ 145#define INT_FLAGS(_name, _parents, _offset,\
143 _clk_num, _gate_flags, _clk_id, flags)\ 146 _clk_num, _gate_flags, _clk_id, flags)\
144 TEGRA_INIT_DATA_TABLE(_name, NULL, NULL, _parents, _offset,\ 147 TEGRA_INIT_DATA_TABLE(_name, NULL, NULL, _parents, _offset,\
145 30, MASK(2), 0, 0, 8, 1, TEGRA_DIVIDER_INT| \ 148 30, MASK(2), 0, 0, 8, 1, TEGRA_DIVIDER_INT| \
146 TEGRA_DIVIDER_ROUND_UP, _clk_num, _gate_flags,\ 149 TEGRA_DIVIDER_ROUND_UP, _clk_num, _gate_flags,\
147 _clk_id, _parents##_idx, flags) 150 _clk_id, _parents##_idx, flags, NULL)
148 151
149#define INT8(_name, _parents, _offset,\ 152#define INT8(_name, _parents, _offset,\
150 _clk_num, _gate_flags, _clk_id) \ 153 _clk_num, _gate_flags, _clk_id) \
151 TEGRA_INIT_DATA_TABLE(_name, NULL, NULL, _parents, _offset,\ 154 TEGRA_INIT_DATA_TABLE(_name, NULL, NULL, _parents, _offset,\
152 29, MASK(3), 0, 0, 8, 1, TEGRA_DIVIDER_INT| \ 155 29, MASK(3), 0, 0, 8, 1, TEGRA_DIVIDER_INT| \
153 TEGRA_DIVIDER_ROUND_UP, _clk_num, _gate_flags,\ 156 TEGRA_DIVIDER_ROUND_UP, _clk_num, _gate_flags,\
154 _clk_id, _parents##_idx, 0) 157 _clk_id, _parents##_idx, 0, NULL)
155 158
156#define UART(_name, _parents, _offset,\ 159#define UART(_name, _parents, _offset,\
157 _clk_num, _clk_id) \ 160 _clk_num, _clk_id) \
158 TEGRA_INIT_DATA_TABLE(_name, NULL, NULL, _parents, _offset,\ 161 TEGRA_INIT_DATA_TABLE(_name, NULL, NULL, _parents, _offset,\
159 30, MASK(2), 0, 0, 16, 1, TEGRA_DIVIDER_UART| \ 162 30, MASK(2), 0, 0, 16, 1, TEGRA_DIVIDER_UART| \
160 TEGRA_DIVIDER_ROUND_UP, _clk_num, 0, _clk_id,\ 163 TEGRA_DIVIDER_ROUND_UP, _clk_num, 0, _clk_id,\
161 _parents##_idx, 0) 164 _parents##_idx, 0, NULL)
162 165
163#define I2C(_name, _parents, _offset,\ 166#define I2C(_name, _parents, _offset,\
164 _clk_num, _clk_id) \ 167 _clk_num, _clk_id) \
165 TEGRA_INIT_DATA_TABLE(_name, NULL, NULL, _parents, _offset,\ 168 TEGRA_INIT_DATA_TABLE(_name, NULL, NULL, _parents, _offset,\
166 30, MASK(2), 0, 0, 16, 0, TEGRA_DIVIDER_ROUND_UP,\ 169 30, MASK(2), 0, 0, 16, 0, TEGRA_DIVIDER_ROUND_UP,\
167 _clk_num, 0, _clk_id, _parents##_idx, 0) 170 _clk_num, 0, _clk_id, _parents##_idx, 0, NULL)
168 171
169#define XUSB(_name, _parents, _offset, \ 172#define XUSB(_name, _parents, _offset, \
170 _clk_num, _gate_flags, _clk_id) \ 173 _clk_num, _gate_flags, _clk_id) \
171 TEGRA_INIT_DATA_TABLE(_name, NULL, NULL, _parents, _offset, \ 174 TEGRA_INIT_DATA_TABLE(_name, NULL, NULL, _parents, _offset, \
172 29, MASK(3), 0, 0, 8, 1, TEGRA_DIVIDER_INT| \ 175 29, MASK(3), 0, 0, 8, 1, TEGRA_DIVIDER_INT| \
173 TEGRA_DIVIDER_ROUND_UP, _clk_num, _gate_flags,\ 176 TEGRA_DIVIDER_ROUND_UP, _clk_num, _gate_flags,\
174 _clk_id, _parents##_idx, 0) 177 _clk_id, _parents##_idx, 0, NULL)
175 178
176#define AUDIO(_name, _offset, _clk_num,\ 179#define AUDIO(_name, _offset, _clk_num,\
177 _gate_flags, _clk_id) \ 180 _gate_flags, _clk_id) \
178 TEGRA_INIT_DATA_TABLE(_name, NULL, NULL, mux_d_audio_clk, \ 181 TEGRA_INIT_DATA_TABLE(_name, NULL, NULL, mux_d_audio_clk, \
179 _offset, 16, 0xE01F, 0, 0, 8, 1, \ 182 _offset, 16, 0xE01F, 0, 0, 8, 1, \
180 TEGRA_DIVIDER_ROUND_UP, _clk_num, _gate_flags, \ 183 TEGRA_DIVIDER_ROUND_UP, _clk_num, _gate_flags, \
181 _clk_id, mux_d_audio_clk_idx, 0) 184 _clk_id, mux_d_audio_clk_idx, 0, NULL)
182 185
183#define NODIV(_name, _parents, _offset, \ 186#define NODIV(_name, _parents, _offset, \
184 _mux_shift, _mux_mask, _clk_num, \ 187 _mux_shift, _mux_mask, _clk_num, \
185 _gate_flags, _clk_id) \ 188 _gate_flags, _clk_id, _lock) \
186 TEGRA_INIT_DATA_TABLE(_name, NULL, NULL, _parents, _offset,\ 189 TEGRA_INIT_DATA_TABLE(_name, NULL, NULL, _parents, _offset,\
187 _mux_shift, _mux_mask, 0, 0, 0, 0, 0,\ 190 _mux_shift, _mux_mask, 0, 0, 0, 0, 0,\
188 _clk_num, (_gate_flags) | TEGRA_PERIPH_NO_DIV,\ 191 _clk_num, (_gate_flags) | TEGRA_PERIPH_NO_DIV,\
189 _clk_id, _parents##_idx, 0) 192 _clk_id, _parents##_idx, 0, _lock)
190 193
191#define GATE(_name, _parent_name, \ 194#define GATE(_name, _parent_name, \
192 _clk_num, _gate_flags, _clk_id, _flags) \ 195 _clk_num, _gate_flags, _clk_id, _flags) \
@@ -195,7 +198,7 @@
195 .clk_id = _clk_id, \ 198 .clk_id = _clk_id, \
196 .p.parent_name = _parent_name, \ 199 .p.parent_name = _parent_name, \
197 .periph = TEGRA_CLK_PERIPH(0, 0, 0, 0, 0, 0, 0, \ 200 .periph = TEGRA_CLK_PERIPH(0, 0, 0, 0, 0, 0, 0, \
198 _clk_num, _gate_flags, 0), \ 201 _clk_num, _gate_flags, 0, NULL), \
199 .flags = _flags \ 202 .flags = _flags \
200 } 203 }
201 204
@@ -414,8 +417,8 @@ static struct tegra_periph_init_data periph_clks[] = {
414 MUX8("soc_therm", mux_pllm_pllc_pllp_plla, CLK_SOURCE_SOC_THERM, 78, TEGRA_PERIPH_ON_APB, tegra_clk_soc_therm), 417 MUX8("soc_therm", mux_pllm_pllc_pllp_plla, CLK_SOURCE_SOC_THERM, 78, TEGRA_PERIPH_ON_APB, tegra_clk_soc_therm),
415 MUX8("vi_sensor", mux_pllm_pllc2_c_c3_pllp_plla, CLK_SOURCE_VI_SENSOR, 20, TEGRA_PERIPH_NO_RESET, tegra_clk_vi_sensor_8), 418 MUX8("vi_sensor", mux_pllm_pllc2_c_c3_pllp_plla, CLK_SOURCE_VI_SENSOR, 20, TEGRA_PERIPH_NO_RESET, tegra_clk_vi_sensor_8),
416 MUX_FLAGS("csite", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_CSITE, 73, TEGRA_PERIPH_ON_APB, tegra_clk_csite, CLK_IGNORE_UNUSED), 419 MUX_FLAGS("csite", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_CSITE, 73, TEGRA_PERIPH_ON_APB, tegra_clk_csite, CLK_IGNORE_UNUSED),
417 NODIV("disp1", mux_pllp_pllm_plld_plla_pllc_plld2_clkm, CLK_SOURCE_DISP1, 29, 7, 27, 0, tegra_clk_disp1), 420 NODIV("disp1", mux_pllp_pllm_plld_plla_pllc_plld2_clkm, CLK_SOURCE_DISP1, 29, 7, 27, 0, tegra_clk_disp1, NULL),
418 NODIV("disp2", mux_pllp_pllm_plld_plla_pllc_plld2_clkm, CLK_SOURCE_DISP2, 29, 7, 26, 0, tegra_clk_disp2), 421 NODIV("disp2", mux_pllp_pllm_plld_plla_pllc_plld2_clkm, CLK_SOURCE_DISP2, 29, 7, 26, 0, tegra_clk_disp2, NULL),
419 UART("uarta", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_UARTA, 6, tegra_clk_uarta), 422 UART("uarta", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_UARTA, 6, tegra_clk_uarta),
420 UART("uartb", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_UARTB, 7, tegra_clk_uartb), 423 UART("uartb", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_UARTB, 7, tegra_clk_uartb),
421 UART("uartc", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_UARTC, 55, tegra_clk_uartc), 424 UART("uartc", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_UARTC, 55, tegra_clk_uartc),
diff --git a/drivers/clk/tegra/clk.h b/drivers/clk/tegra/clk.h
index 7f110acfe2a1..f984ebed9f1f 100644
--- a/drivers/clk/tegra/clk.h
+++ b/drivers/clk/tegra/clk.h
@@ -439,19 +439,21 @@ struct clk *tegra_clk_register_periph_nodiv(const char *name,
439#define TEGRA_CLK_PERIPH(_mux_shift, _mux_mask, _mux_flags, \ 439#define TEGRA_CLK_PERIPH(_mux_shift, _mux_mask, _mux_flags, \
440 _div_shift, _div_width, _div_frac_width, \ 440 _div_shift, _div_width, _div_frac_width, \
441 _div_flags, _clk_num,\ 441 _div_flags, _clk_num,\
442 _gate_flags, _table) \ 442 _gate_flags, _table, _lock) \
443 { \ 443 { \
444 .mux = { \ 444 .mux = { \
445 .flags = _mux_flags, \ 445 .flags = _mux_flags, \
446 .shift = _mux_shift, \ 446 .shift = _mux_shift, \
447 .mask = _mux_mask, \ 447 .mask = _mux_mask, \
448 .table = _table, \ 448 .table = _table, \
449 .lock = _lock, \
449 }, \ 450 }, \
450 .divider = { \ 451 .divider = { \
451 .flags = _div_flags, \ 452 .flags = _div_flags, \
452 .shift = _div_shift, \ 453 .shift = _div_shift, \
453 .width = _div_width, \ 454 .width = _div_width, \
454 .frac_width = _div_frac_width, \ 455 .frac_width = _div_frac_width, \
456 .lock = _lock, \
455 }, \ 457 }, \
456 .gate = { \ 458 .gate = { \
457 .flags = _gate_flags, \ 459 .flags = _gate_flags, \
@@ -481,7 +483,7 @@ struct tegra_periph_init_data {
481 _mux_shift, _mux_mask, _mux_flags, _div_shift, \ 483 _mux_shift, _mux_mask, _mux_flags, _div_shift, \
482 _div_width, _div_frac_width, _div_flags, \ 484 _div_width, _div_frac_width, _div_flags, \
483 _clk_num, _gate_flags, _clk_id, _table, \ 485 _clk_num, _gate_flags, _clk_id, _table, \
484 _flags) \ 486 _flags, _lock) \
485 { \ 487 { \
486 .name = _name, \ 488 .name = _name, \
487 .clk_id = _clk_id, \ 489 .clk_id = _clk_id, \
@@ -491,7 +493,7 @@ struct tegra_periph_init_data {
491 _mux_flags, _div_shift, \ 493 _mux_flags, _div_shift, \
492 _div_width, _div_frac_width, \ 494 _div_width, _div_frac_width, \
493 _div_flags, _clk_num, \ 495 _div_flags, _clk_num, \
494 _gate_flags, _table), \ 496 _gate_flags, _table, _lock), \
495 .offset = _offset, \ 497 .offset = _offset, \
496 .con_id = _con_id, \ 498 .con_id = _con_id, \
497 .dev_id = _dev_id, \ 499 .dev_id = _dev_id, \
@@ -506,7 +508,7 @@ struct tegra_periph_init_data {
506 _mux_shift, BIT(_mux_width) - 1, _mux_flags, \ 508 _mux_shift, BIT(_mux_width) - 1, _mux_flags, \
507 _div_shift, _div_width, _div_frac_width, _div_flags, \ 509 _div_shift, _div_width, _div_frac_width, _div_flags, \
508 _clk_num, _gate_flags, _clk_id,\ 510 _clk_num, _gate_flags, _clk_id,\
509 NULL, 0) 511 NULL, 0, NULL)
510 512
511/** 513/**
512 * struct clk_super_mux - super clock 514 * struct clk_super_mux - super clock