aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/clk/tegra/clk.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/clk/tegra/clk.h')
-rw-r--r--drivers/clk/tegra/clk.h116
1 files changed, 75 insertions, 41 deletions
diff --git a/drivers/clk/tegra/clk.h b/drivers/clk/tegra/clk.h
index 07cfacd91686..16ec8d6bb87f 100644
--- a/drivers/clk/tegra/clk.h
+++ b/drivers/clk/tegra/clk.h
@@ -37,6 +37,8 @@ struct tegra_clk_sync_source {
37 container_of(_hw, struct tegra_clk_sync_source, hw) 37 container_of(_hw, struct tegra_clk_sync_source, hw)
38 38
39extern const struct clk_ops tegra_clk_sync_source_ops; 39extern const struct clk_ops tegra_clk_sync_source_ops;
40extern int *periph_clk_enb_refcnt;
41
40struct clk *tegra_clk_register_sync_source(const char *name, 42struct clk *tegra_clk_register_sync_source(const char *name,
41 unsigned long fixed_rate, unsigned long max_rate); 43 unsigned long fixed_rate, unsigned long max_rate);
42 44
@@ -188,12 +190,15 @@ struct tegra_clk_pll_params {
188 u32 ext_misc_reg[3]; 190 u32 ext_misc_reg[3];
189 u32 pmc_divnm_reg; 191 u32 pmc_divnm_reg;
190 u32 pmc_divp_reg; 192 u32 pmc_divp_reg;
193 u32 flags;
191 int stepa_shift; 194 int stepa_shift;
192 int stepb_shift; 195 int stepb_shift;
193 int lock_delay; 196 int lock_delay;
194 int max_p; 197 int max_p;
195 struct pdiv_map *pdiv_tohw; 198 struct pdiv_map *pdiv_tohw;
196 struct div_nmp *div_nmp; 199 struct div_nmp *div_nmp;
200 struct tegra_clk_pll_freq_table *freq_table;
201 unsigned long fixed_rate;
197}; 202};
198 203
199/** 204/**
@@ -233,10 +238,7 @@ struct tegra_clk_pll {
233 struct clk_hw hw; 238 struct clk_hw hw;
234 void __iomem *clk_base; 239 void __iomem *clk_base;
235 void __iomem *pmc; 240 void __iomem *pmc;
236 u32 flags;
237 unsigned long fixed_rate;
238 spinlock_t *lock; 241 spinlock_t *lock;
239 struct tegra_clk_pll_freq_table *freq_table;
240 struct tegra_clk_pll_params *params; 242 struct tegra_clk_pll_params *params;
241}; 243};
242 244
@@ -258,56 +260,49 @@ extern const struct clk_ops tegra_clk_pll_ops;
258extern const struct clk_ops tegra_clk_plle_ops; 260extern const struct clk_ops tegra_clk_plle_ops;
259struct clk *tegra_clk_register_pll(const char *name, const char *parent_name, 261struct clk *tegra_clk_register_pll(const char *name, const char *parent_name,
260 void __iomem *clk_base, void __iomem *pmc, 262 void __iomem *clk_base, void __iomem *pmc,
261 unsigned long flags, unsigned long fixed_rate, 263 unsigned long flags, struct tegra_clk_pll_params *pll_params,
262 struct tegra_clk_pll_params *pll_params, u32 pll_flags, 264 spinlock_t *lock);
263 struct tegra_clk_pll_freq_table *freq_table, spinlock_t *lock);
264 265
265struct clk *tegra_clk_register_plle(const char *name, const char *parent_name, 266struct clk *tegra_clk_register_plle(const char *name, const char *parent_name,
266 void __iomem *clk_base, void __iomem *pmc, 267 void __iomem *clk_base, void __iomem *pmc,
267 unsigned long flags, unsigned long fixed_rate, 268 unsigned long flags, struct tegra_clk_pll_params *pll_params,
268 struct tegra_clk_pll_params *pll_params, u32 pll_flags, 269 spinlock_t *lock);
269 struct tegra_clk_pll_freq_table *freq_table, spinlock_t *lock);
270 270
271struct clk *tegra_clk_register_pllxc(const char *name, const char *parent_name, 271struct clk *tegra_clk_register_pllxc(const char *name, const char *parent_name,
272 void __iomem *clk_base, void __iomem *pmc, 272 void __iomem *clk_base, void __iomem *pmc,
273 unsigned long flags, unsigned long fixed_rate, 273 unsigned long flags,
274 struct tegra_clk_pll_params *pll_params, 274 struct tegra_clk_pll_params *pll_params,
275 u32 pll_flags,
276 struct tegra_clk_pll_freq_table *freq_table,
277 spinlock_t *lock); 275 spinlock_t *lock);
278 276
279struct clk *tegra_clk_register_pllm(const char *name, const char *parent_name, 277struct clk *tegra_clk_register_pllm(const char *name, const char *parent_name,
280 void __iomem *clk_base, void __iomem *pmc, 278 void __iomem *clk_base, void __iomem *pmc,
281 unsigned long flags, unsigned long fixed_rate, 279 unsigned long flags,
282 struct tegra_clk_pll_params *pll_params, 280 struct tegra_clk_pll_params *pll_params,
283 u32 pll_flags,
284 struct tegra_clk_pll_freq_table *freq_table,
285 spinlock_t *lock); 281 spinlock_t *lock);
286 282
287struct clk *tegra_clk_register_pllc(const char *name, const char *parent_name, 283struct clk *tegra_clk_register_pllc(const char *name, const char *parent_name,
288 void __iomem *clk_base, void __iomem *pmc, 284 void __iomem *clk_base, void __iomem *pmc,
289 unsigned long flags, unsigned long fixed_rate, 285 unsigned long flags,
290 struct tegra_clk_pll_params *pll_params, 286 struct tegra_clk_pll_params *pll_params,
291 u32 pll_flags,
292 struct tegra_clk_pll_freq_table *freq_table,
293 spinlock_t *lock); 287 spinlock_t *lock);
294 288
295struct clk *tegra_clk_register_pllre(const char *name, const char *parent_name, 289struct clk *tegra_clk_register_pllre(const char *name, const char *parent_name,
296 void __iomem *clk_base, void __iomem *pmc, 290 void __iomem *clk_base, void __iomem *pmc,
297 unsigned long flags, unsigned long fixed_rate, 291 unsigned long flags,
298 struct tegra_clk_pll_params *pll_params, 292 struct tegra_clk_pll_params *pll_params,
299 u32 pll_flags,
300 struct tegra_clk_pll_freq_table *freq_table,
301 spinlock_t *lock, unsigned long parent_rate); 293 spinlock_t *lock, unsigned long parent_rate);
302 294
303struct clk *tegra_clk_register_plle_tegra114(const char *name, 295struct clk *tegra_clk_register_plle_tegra114(const char *name,
304 const char *parent_name, 296 const char *parent_name,
305 void __iomem *clk_base, unsigned long flags, 297 void __iomem *clk_base, unsigned long flags,
306 unsigned long fixed_rate,
307 struct tegra_clk_pll_params *pll_params, 298 struct tegra_clk_pll_params *pll_params,
308 struct tegra_clk_pll_freq_table *freq_table,
309 spinlock_t *lock); 299 spinlock_t *lock);
310 300
301struct clk *tegra_clk_register_pllss(const char *name, const char *parent_name,
302 void __iomem *clk_base, unsigned long flags,
303 struct tegra_clk_pll_params *pll_params,
304 spinlock_t *lock);
305
311/** 306/**
312 * struct tegra_clk_pll_out - PLL divider down clock 307 * struct tegra_clk_pll_out - PLL divider down clock
313 * 308 *
@@ -395,13 +390,13 @@ struct tegra_clk_periph_gate {
395#define TEGRA_PERIPH_MANUAL_RESET BIT(1) 390#define TEGRA_PERIPH_MANUAL_RESET BIT(1)
396#define TEGRA_PERIPH_ON_APB BIT(2) 391#define TEGRA_PERIPH_ON_APB BIT(2)
397#define TEGRA_PERIPH_WAR_1005168 BIT(3) 392#define TEGRA_PERIPH_WAR_1005168 BIT(3)
393#define TEGRA_PERIPH_NO_DIV BIT(4)
394#define TEGRA_PERIPH_NO_GATE BIT(5)
398 395
399void tegra_periph_reset(struct tegra_clk_periph_gate *gate, bool assert);
400extern const struct clk_ops tegra_clk_periph_gate_ops; 396extern const struct clk_ops tegra_clk_periph_gate_ops;
401struct clk *tegra_clk_register_periph_gate(const char *name, 397struct clk *tegra_clk_register_periph_gate(const char *name,
402 const char *parent_name, u8 gate_flags, void __iomem *clk_base, 398 const char *parent_name, u8 gate_flags, void __iomem *clk_base,
403 unsigned long flags, int clk_num, 399 unsigned long flags, int clk_num, int *enable_refcnt);
404 struct tegra_clk_periph_regs *pregs, int *enable_refcnt);
405 400
406/** 401/**
407 * struct clk-periph - peripheral clock 402 * struct clk-periph - peripheral clock
@@ -443,26 +438,26 @@ struct clk *tegra_clk_register_periph_nodiv(const char *name,
443 438
444#define TEGRA_CLK_PERIPH(_mux_shift, _mux_mask, _mux_flags, \ 439#define TEGRA_CLK_PERIPH(_mux_shift, _mux_mask, _mux_flags, \
445 _div_shift, _div_width, _div_frac_width, \ 440 _div_shift, _div_width, _div_frac_width, \
446 _div_flags, _clk_num, _enb_refcnt, _regs, \ 441 _div_flags, _clk_num,\
447 _gate_flags, _table) \ 442 _gate_flags, _table, _lock) \
448 { \ 443 { \
449 .mux = { \ 444 .mux = { \
450 .flags = _mux_flags, \ 445 .flags = _mux_flags, \
451 .shift = _mux_shift, \ 446 .shift = _mux_shift, \
452 .mask = _mux_mask, \ 447 .mask = _mux_mask, \
453 .table = _table, \ 448 .table = _table, \
449 .lock = _lock, \
454 }, \ 450 }, \
455 .divider = { \ 451 .divider = { \
456 .flags = _div_flags, \ 452 .flags = _div_flags, \
457 .shift = _div_shift, \ 453 .shift = _div_shift, \
458 .width = _div_width, \ 454 .width = _div_width, \
459 .frac_width = _div_frac_width, \ 455 .frac_width = _div_frac_width, \
456 .lock = _lock, \
460 }, \ 457 }, \
461 .gate = { \ 458 .gate = { \
462 .flags = _gate_flags, \ 459 .flags = _gate_flags, \
463 .clk_num = _clk_num, \ 460 .clk_num = _clk_num, \
464 .enable_refcnt = _enb_refcnt, \
465 .regs = _regs, \
466 }, \ 461 }, \
467 .mux_ops = &clk_mux_ops, \ 462 .mux_ops = &clk_mux_ops, \
468 .div_ops = &tegra_clk_frac_div_ops, \ 463 .div_ops = &tegra_clk_frac_div_ops, \
@@ -472,7 +467,10 @@ struct clk *tegra_clk_register_periph_nodiv(const char *name,
472struct tegra_periph_init_data { 467struct tegra_periph_init_data {
473 const char *name; 468 const char *name;
474 int clk_id; 469 int clk_id;
475 const char **parent_names; 470 union {
471 const char **parent_names;
472 const char *parent_name;
473 } p;
476 int num_parents; 474 int num_parents;
477 struct tegra_clk_periph periph; 475 struct tegra_clk_periph periph;
478 u32 offset; 476 u32 offset;
@@ -483,20 +481,19 @@ struct tegra_periph_init_data {
483 481
484#define TEGRA_INIT_DATA_TABLE(_name, _con_id, _dev_id, _parent_names, _offset,\ 482#define TEGRA_INIT_DATA_TABLE(_name, _con_id, _dev_id, _parent_names, _offset,\
485 _mux_shift, _mux_mask, _mux_flags, _div_shift, \ 483 _mux_shift, _mux_mask, _mux_flags, _div_shift, \
486 _div_width, _div_frac_width, _div_flags, _regs, \ 484 _div_width, _div_frac_width, _div_flags, \
487 _clk_num, _enb_refcnt, _gate_flags, _clk_id, _table,\ 485 _clk_num, _gate_flags, _clk_id, _table, \
488 _flags) \ 486 _flags, _lock) \
489 { \ 487 { \
490 .name = _name, \ 488 .name = _name, \
491 .clk_id = _clk_id, \ 489 .clk_id = _clk_id, \
492 .parent_names = _parent_names, \ 490 .p.parent_names = _parent_names, \
493 .num_parents = ARRAY_SIZE(_parent_names), \ 491 .num_parents = ARRAY_SIZE(_parent_names), \
494 .periph = TEGRA_CLK_PERIPH(_mux_shift, _mux_mask, \ 492 .periph = TEGRA_CLK_PERIPH(_mux_shift, _mux_mask, \
495 _mux_flags, _div_shift, \ 493 _mux_flags, _div_shift, \
496 _div_width, _div_frac_width, \ 494 _div_width, _div_frac_width, \
497 _div_flags, _clk_num, \ 495 _div_flags, _clk_num, \
498 _enb_refcnt, _regs, \ 496 _gate_flags, _table, _lock), \
499 _gate_flags, _table), \
500 .offset = _offset, \ 497 .offset = _offset, \
501 .con_id = _con_id, \ 498 .con_id = _con_id, \
502 .dev_id = _dev_id, \ 499 .dev_id = _dev_id, \
@@ -505,13 +502,13 @@ struct tegra_periph_init_data {
505 502
506#define TEGRA_INIT_DATA(_name, _con_id, _dev_id, _parent_names, _offset,\ 503#define TEGRA_INIT_DATA(_name, _con_id, _dev_id, _parent_names, _offset,\
507 _mux_shift, _mux_width, _mux_flags, _div_shift, \ 504 _mux_shift, _mux_width, _mux_flags, _div_shift, \
508 _div_width, _div_frac_width, _div_flags, _regs, \ 505 _div_width, _div_frac_width, _div_flags, \
509 _clk_num, _enb_refcnt, _gate_flags, _clk_id) \ 506 _clk_num, _gate_flags, _clk_id) \
510 TEGRA_INIT_DATA_TABLE(_name, _con_id, _dev_id, _parent_names, _offset,\ 507 TEGRA_INIT_DATA_TABLE(_name, _con_id, _dev_id, _parent_names, _offset,\
511 _mux_shift, BIT(_mux_width) - 1, _mux_flags, \ 508 _mux_shift, BIT(_mux_width) - 1, _mux_flags, \
512 _div_shift, _div_width, _div_frac_width, _div_flags, \ 509 _div_shift, _div_width, _div_frac_width, _div_flags, \
513 _regs, _clk_num, _enb_refcnt, _gate_flags, _clk_id,\ 510 _clk_num, _gate_flags, _clk_id,\
514 NULL, 0) 511 NULL, 0, NULL)
515 512
516/** 513/**
517 * struct clk_super_mux - super clock 514 * struct clk_super_mux - super clock
@@ -581,12 +578,49 @@ struct tegra_clk_duplicate {
581 }, \ 578 }, \
582 } 579 }
583 580
581struct tegra_clk {
582 int dt_id;
583 bool present;
584};
585
586struct tegra_devclk {
587 int dt_id;
588 char *dev_id;
589 char *con_id;
590};
591
584void tegra_init_from_table(struct tegra_clk_init_table *tbl, 592void tegra_init_from_table(struct tegra_clk_init_table *tbl,
585 struct clk *clks[], int clk_max); 593 struct clk *clks[], int clk_max);
586 594
587void tegra_init_dup_clks(struct tegra_clk_duplicate *dup_list, 595void tegra_init_dup_clks(struct tegra_clk_duplicate *dup_list,
588 struct clk *clks[], int clk_max); 596 struct clk *clks[], int clk_max);
589 597
598struct tegra_clk_periph_regs *get_reg_bank(int clkid);
599struct clk **tegra_clk_init(void __iomem *clk_base, int num, int periph_banks);
600
601struct clk **tegra_lookup_dt_id(int clk_id, struct tegra_clk *tegra_clk);
602
603void tegra_add_of_provider(struct device_node *np);
604void tegra_register_devclks(struct tegra_devclk *dev_clks, int num);
605
606void tegra_audio_clk_init(void __iomem *clk_base,
607 void __iomem *pmc_base, struct tegra_clk *tegra_clks,
608 struct tegra_clk_pll_params *pll_params);
609
610void tegra_periph_clk_init(void __iomem *clk_base, void __iomem *pmc_base,
611 struct tegra_clk *tegra_clks,
612 struct tegra_clk_pll_params *pll_params);
613
614void tegra_pmc_clk_init(void __iomem *pmc_base, struct tegra_clk *tegra_clks);
615void tegra_fixed_clk_init(struct tegra_clk *tegra_clks);
616int tegra_osc_clk_init(void __iomem *clk_base, struct tegra_clk *tegra_clks,
617 unsigned long *input_freqs, int num,
618 unsigned long *osc_freq,
619 unsigned long *pll_ref_freq);
620void tegra_super_clk_gen4_init(void __iomem *clk_base,
621 void __iomem *pmc_base, struct tegra_clk *tegra_clks,
622 struct tegra_clk_pll_params *pll_params);
623
590void tegra114_clock_tune_cpu_trimmers_high(void); 624void tegra114_clock_tune_cpu_trimmers_high(void);
591void tegra114_clock_tune_cpu_trimmers_low(void); 625void tegra114_clock_tune_cpu_trimmers_low(void);
592void tegra114_clock_tune_cpu_trimmers_init(void); 626void tegra114_clock_tune_cpu_trimmers_init(void);