0001
0002
0003
0004
0005
0006 #ifndef __TEGRA_CLK_H
0007 #define __TEGRA_CLK_H
0008
0009 #include <linux/clk-provider.h>
0010 #include <linux/clkdev.h>
0011 #include <linux/delay.h>
0012
0013 #define CLK_OUT_ENB_L 0x010
0014 #define CLK_OUT_ENB_H 0x014
0015 #define CLK_OUT_ENB_U 0x018
0016 #define CLK_OUT_ENB_V 0x360
0017 #define CLK_OUT_ENB_W 0x364
0018 #define CLK_OUT_ENB_X 0x280
0019 #define CLK_OUT_ENB_Y 0x298
0020 #define CLK_ENB_PLLP_OUT_CPU BIT(31)
0021 #define CLK_OUT_ENB_SET_L 0x320
0022 #define CLK_OUT_ENB_CLR_L 0x324
0023 #define CLK_OUT_ENB_SET_H 0x328
0024 #define CLK_OUT_ENB_CLR_H 0x32c
0025 #define CLK_OUT_ENB_SET_U 0x330
0026 #define CLK_OUT_ENB_CLR_U 0x334
0027 #define CLK_OUT_ENB_SET_V 0x440
0028 #define CLK_OUT_ENB_CLR_V 0x444
0029 #define CLK_OUT_ENB_SET_W 0x448
0030 #define CLK_OUT_ENB_CLR_W 0x44c
0031 #define CLK_OUT_ENB_SET_X 0x284
0032 #define CLK_OUT_ENB_CLR_X 0x288
0033 #define CLK_OUT_ENB_SET_Y 0x29c
0034 #define CLK_OUT_ENB_CLR_Y 0x2a0
0035
0036 #define RST_DEVICES_L 0x004
0037 #define RST_DEVICES_H 0x008
0038 #define RST_DEVICES_U 0x00C
0039 #define RST_DEVICES_V 0x358
0040 #define RST_DEVICES_W 0x35C
0041 #define RST_DEVICES_X 0x28C
0042 #define RST_DEVICES_Y 0x2a4
0043 #define RST_DEVICES_SET_L 0x300
0044 #define RST_DEVICES_CLR_L 0x304
0045 #define RST_DEVICES_SET_H 0x308
0046 #define RST_DEVICES_CLR_H 0x30c
0047 #define RST_DEVICES_SET_U 0x310
0048 #define RST_DEVICES_CLR_U 0x314
0049 #define RST_DEVICES_SET_V 0x430
0050 #define RST_DEVICES_CLR_V 0x434
0051 #define RST_DEVICES_SET_W 0x438
0052 #define RST_DEVICES_CLR_W 0x43c
0053 #define RST_DEVICES_SET_X 0x290
0054 #define RST_DEVICES_CLR_X 0x294
0055 #define RST_DEVICES_SET_Y 0x2a8
0056 #define RST_DEVICES_CLR_Y 0x2ac
0057
0058
0059
0060
0061
0062
0063
0064 #define TEGRA210_CLK_ENB_VLD_MSK_L 0xdcd7dff9
0065 #define TEGRA210_CLK_ENB_VLD_MSK_H 0x87d1f3e7
0066 #define TEGRA210_CLK_ENB_VLD_MSK_U 0xf3fed3fa
0067 #define TEGRA210_CLK_ENB_VLD_MSK_V 0xffc18cfb
0068 #define TEGRA210_CLK_ENB_VLD_MSK_W 0x793fb7ff
0069 #define TEGRA210_CLK_ENB_VLD_MSK_X 0x3fe66fff
0070 #define TEGRA210_CLK_ENB_VLD_MSK_Y 0xfc1fc7ff
0071
0072
0073
0074
0075
0076
0077
0078
0079 struct tegra_clk_sync_source {
0080 struct clk_hw hw;
0081 unsigned long rate;
0082 unsigned long max_rate;
0083 };
0084
0085 #define to_clk_sync_source(_hw) \
0086 container_of(_hw, struct tegra_clk_sync_source, hw)
0087
0088 extern const struct clk_ops tegra_clk_sync_source_ops;
0089 extern int *periph_clk_enb_refcnt;
0090
0091 struct clk *tegra_clk_register_sync_source(const char *name,
0092 unsigned long max_rate);
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116 struct tegra_clk_frac_div {
0117 struct clk_hw hw;
0118 void __iomem *reg;
0119 u8 flags;
0120 u8 shift;
0121 u8 width;
0122 u8 frac_width;
0123 spinlock_t *lock;
0124 };
0125
0126 #define to_clk_frac_div(_hw) container_of(_hw, struct tegra_clk_frac_div, hw)
0127
0128 #define TEGRA_DIVIDER_ROUND_UP BIT(0)
0129 #define TEGRA_DIVIDER_FIXED BIT(1)
0130 #define TEGRA_DIVIDER_INT BIT(2)
0131 #define TEGRA_DIVIDER_UART BIT(3)
0132
0133 extern const struct clk_ops tegra_clk_frac_div_ops;
0134 struct clk *tegra_clk_register_divider(const char *name,
0135 const char *parent_name, void __iomem *reg,
0136 unsigned long flags, u8 clk_divider_flags, u8 shift, u8 width,
0137 u8 frac_width, spinlock_t *lock);
0138 struct clk *tegra_clk_register_mc(const char *name, const char *parent_name,
0139 void __iomem *reg, spinlock_t *lock);
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153
0154
0155
0156
0157
0158
0159
0160
0161
0162
0163
0164 struct tegra_clk_pll_freq_table {
0165 unsigned long input_rate;
0166 unsigned long output_rate;
0167 u32 n;
0168 u32 m;
0169 u8 p;
0170 u8 cpcon;
0171 u16 sdm_data;
0172 };
0173
0174
0175
0176
0177
0178
0179
0180 struct pdiv_map {
0181 u8 pdiv;
0182 u8 hw_val;
0183 };
0184
0185
0186
0187
0188
0189
0190
0191
0192
0193
0194
0195
0196
0197
0198 struct div_nmp {
0199 u8 divn_shift;
0200 u8 divn_width;
0201 u8 divm_shift;
0202 u8 divm_width;
0203 u8 divp_shift;
0204 u8 divp_width;
0205 u8 override_divn_shift;
0206 u8 override_divm_shift;
0207 u8 override_divp_shift;
0208 };
0209
0210 #define MAX_PLL_MISC_REG_COUNT 6
0211
0212 struct tegra_clk_pll;
0213
0214
0215
0216
0217
0218
0219
0220
0221
0222
0223
0224
0225
0226
0227
0228
0229
0230
0231
0232
0233
0234
0235
0236
0237
0238
0239
0240
0241
0242
0243
0244
0245
0246
0247
0248
0249
0250
0251
0252
0253
0254
0255
0256
0257
0258
0259
0260
0261
0262
0263
0264
0265
0266
0267
0268
0269
0270
0271
0272
0273
0274
0275
0276
0277
0278
0279
0280
0281
0282
0283
0284
0285
0286
0287
0288
0289
0290
0291
0292
0293
0294
0295
0296
0297
0298
0299
0300 struct tegra_clk_pll_params {
0301 unsigned long input_min;
0302 unsigned long input_max;
0303 unsigned long cf_min;
0304 unsigned long cf_max;
0305 unsigned long vco_min;
0306 unsigned long vco_max;
0307
0308 u32 base_reg;
0309 u32 misc_reg;
0310 u32 lock_reg;
0311 u32 lock_mask;
0312 u32 lock_enable_bit_idx;
0313 u32 iddq_reg;
0314 u32 iddq_bit_idx;
0315 u32 reset_reg;
0316 u32 reset_bit_idx;
0317 u32 sdm_din_reg;
0318 u32 sdm_din_mask;
0319 u32 sdm_ctrl_reg;
0320 u32 sdm_ctrl_en_mask;
0321 u32 ssc_ctrl_reg;
0322 u32 ssc_ctrl_en_mask;
0323 u32 aux_reg;
0324 u32 dyn_ramp_reg;
0325 u32 ext_misc_reg[MAX_PLL_MISC_REG_COUNT];
0326 u32 pmc_divnm_reg;
0327 u32 pmc_divp_reg;
0328 u32 flags;
0329 int stepa_shift;
0330 int stepb_shift;
0331 int lock_delay;
0332 int max_p;
0333 bool defaults_set;
0334 const struct pdiv_map *pdiv_tohw;
0335 struct div_nmp *div_nmp;
0336 struct tegra_clk_pll_freq_table *freq_table;
0337 unsigned long fixed_rate;
0338 u16 mdiv_default;
0339 u32 (*round_p_to_pdiv)(u32 p, u32 *pdiv);
0340 void (*set_gain)(struct tegra_clk_pll_freq_table *cfg);
0341 int (*calc_rate)(struct clk_hw *hw,
0342 struct tegra_clk_pll_freq_table *cfg,
0343 unsigned long rate, unsigned long parent_rate);
0344 unsigned long (*adjust_vco)(struct tegra_clk_pll_params *pll_params,
0345 unsigned long parent_rate);
0346 void (*set_defaults)(struct tegra_clk_pll *pll);
0347 int (*dyn_ramp)(struct tegra_clk_pll *pll,
0348 struct tegra_clk_pll_freq_table *cfg);
0349 int (*pre_rate_change)(void);
0350 void (*post_rate_change)(void);
0351 };
0352
0353 #define TEGRA_PLL_USE_LOCK BIT(0)
0354 #define TEGRA_PLL_HAS_CPCON BIT(1)
0355 #define TEGRA_PLL_SET_LFCON BIT(2)
0356 #define TEGRA_PLL_SET_DCCON BIT(3)
0357 #define TEGRA_PLLU BIT(4)
0358 #define TEGRA_PLLM BIT(5)
0359 #define TEGRA_PLL_FIXED BIT(6)
0360 #define TEGRA_PLLE_CONFIGURE BIT(7)
0361 #define TEGRA_PLL_LOCK_MISC BIT(8)
0362 #define TEGRA_PLL_BYPASS BIT(9)
0363 #define TEGRA_PLL_HAS_LOCK_ENABLE BIT(10)
0364 #define TEGRA_MDIV_NEW BIT(11)
0365 #define TEGRA_PLLMB BIT(12)
0366 #define TEGRA_PLL_VCO_OUT BIT(13)
0367
0368
0369
0370
0371
0372
0373
0374
0375
0376
0377 struct tegra_clk_pll {
0378 struct clk_hw hw;
0379 void __iomem *clk_base;
0380 void __iomem *pmc;
0381 spinlock_t *lock;
0382 struct tegra_clk_pll_params *params;
0383 };
0384
0385 #define to_clk_pll(_hw) container_of(_hw, struct tegra_clk_pll, hw)
0386
0387
0388
0389
0390
0391
0392
0393
0394
0395 struct tegra_audio_clk_info {
0396 char *name;
0397 struct tegra_clk_pll_params *pll_params;
0398 int clk_id;
0399 char *parent;
0400 };
0401
0402 extern const struct clk_ops tegra_clk_pll_ops;
0403 extern const struct clk_ops tegra_clk_plle_ops;
0404 struct clk *tegra_clk_register_pll(const char *name, const char *parent_name,
0405 void __iomem *clk_base, void __iomem *pmc,
0406 unsigned long flags, struct tegra_clk_pll_params *pll_params,
0407 spinlock_t *lock);
0408
0409 struct clk *tegra_clk_register_plle(const char *name, const char *parent_name,
0410 void __iomem *clk_base, void __iomem *pmc,
0411 unsigned long flags, struct tegra_clk_pll_params *pll_params,
0412 spinlock_t *lock);
0413
0414 struct clk *tegra_clk_register_pllxc(const char *name, const char *parent_name,
0415 void __iomem *clk_base, void __iomem *pmc,
0416 unsigned long flags,
0417 struct tegra_clk_pll_params *pll_params,
0418 spinlock_t *lock);
0419
0420 struct clk *tegra_clk_register_pllm(const char *name, const char *parent_name,
0421 void __iomem *clk_base, void __iomem *pmc,
0422 unsigned long flags,
0423 struct tegra_clk_pll_params *pll_params,
0424 spinlock_t *lock);
0425
0426 struct clk *tegra_clk_register_pllc(const char *name, const char *parent_name,
0427 void __iomem *clk_base, void __iomem *pmc,
0428 unsigned long flags,
0429 struct tegra_clk_pll_params *pll_params,
0430 spinlock_t *lock);
0431
0432 struct clk *tegra_clk_register_pllre(const char *name, const char *parent_name,
0433 void __iomem *clk_base, void __iomem *pmc,
0434 unsigned long flags,
0435 struct tegra_clk_pll_params *pll_params,
0436 spinlock_t *lock, unsigned long parent_rate);
0437
0438 struct clk *tegra_clk_register_pllre_tegra210(const char *name,
0439 const char *parent_name, void __iomem *clk_base,
0440 void __iomem *pmc, unsigned long flags,
0441 struct tegra_clk_pll_params *pll_params,
0442 spinlock_t *lock, unsigned long parent_rate);
0443
0444 struct clk *tegra_clk_register_plle_tegra114(const char *name,
0445 const char *parent_name,
0446 void __iomem *clk_base, unsigned long flags,
0447 struct tegra_clk_pll_params *pll_params,
0448 spinlock_t *lock);
0449
0450 struct clk *tegra_clk_register_plle_tegra210(const char *name,
0451 const char *parent_name,
0452 void __iomem *clk_base, unsigned long flags,
0453 struct tegra_clk_pll_params *pll_params,
0454 spinlock_t *lock);
0455
0456 struct clk *tegra_clk_register_pllc_tegra210(const char *name,
0457 const char *parent_name, void __iomem *clk_base,
0458 void __iomem *pmc, unsigned long flags,
0459 struct tegra_clk_pll_params *pll_params,
0460 spinlock_t *lock);
0461
0462 struct clk *tegra_clk_register_pllss_tegra210(const char *name,
0463 const char *parent_name, void __iomem *clk_base,
0464 unsigned long flags,
0465 struct tegra_clk_pll_params *pll_params,
0466 spinlock_t *lock);
0467
0468 struct clk *tegra_clk_register_pllss(const char *name, const char *parent_name,
0469 void __iomem *clk_base, unsigned long flags,
0470 struct tegra_clk_pll_params *pll_params,
0471 spinlock_t *lock);
0472
0473 struct clk *tegra_clk_register_pllmb(const char *name, const char *parent_name,
0474 void __iomem *clk_base, void __iomem *pmc,
0475 unsigned long flags,
0476 struct tegra_clk_pll_params *pll_params,
0477 spinlock_t *lock);
0478
0479 struct clk *tegra_clk_register_pllu(const char *name, const char *parent_name,
0480 void __iomem *clk_base, unsigned long flags,
0481 struct tegra_clk_pll_params *pll_params,
0482 spinlock_t *lock);
0483
0484 struct clk *tegra_clk_register_pllu_tegra114(const char *name,
0485 const char *parent_name,
0486 void __iomem *clk_base, unsigned long flags,
0487 struct tegra_clk_pll_params *pll_params,
0488 spinlock_t *lock);
0489
0490 struct clk *tegra_clk_register_pllu_tegra210(const char *name,
0491 const char *parent_name,
0492 void __iomem *clk_base, unsigned long flags,
0493 struct tegra_clk_pll_params *pll_params,
0494 spinlock_t *lock);
0495
0496
0497
0498
0499
0500
0501
0502
0503
0504
0505
0506 struct tegra_clk_pll_out {
0507 struct clk_hw hw;
0508 void __iomem *reg;
0509 u8 enb_bit_idx;
0510 u8 rst_bit_idx;
0511 spinlock_t *lock;
0512 u8 flags;
0513 };
0514
0515 #define to_clk_pll_out(_hw) container_of(_hw, struct tegra_clk_pll_out, hw)
0516
0517 extern const struct clk_ops tegra_clk_pll_out_ops;
0518 struct clk *tegra_clk_register_pll_out(const char *name,
0519 const char *parent_name, void __iomem *reg, u8 enb_bit_idx,
0520 u8 rst_bit_idx, unsigned long flags, u8 pll_div_flags,
0521 spinlock_t *lock);
0522
0523
0524
0525
0526
0527
0528
0529
0530
0531
0532
0533 struct tegra_clk_periph_regs {
0534 u32 enb_reg;
0535 u32 enb_set_reg;
0536 u32 enb_clr_reg;
0537 u32 rst_reg;
0538 u32 rst_set_reg;
0539 u32 rst_clr_reg;
0540 };
0541
0542
0543
0544
0545
0546
0547
0548
0549
0550
0551
0552
0553
0554
0555
0556
0557
0558
0559
0560
0561 struct tegra_clk_periph_gate {
0562 u32 magic;
0563 struct clk_hw hw;
0564 void __iomem *clk_base;
0565 u8 flags;
0566 int clk_num;
0567 int *enable_refcnt;
0568 const struct tegra_clk_periph_regs *regs;
0569 };
0570
0571 #define to_clk_periph_gate(_hw) \
0572 container_of(_hw, struct tegra_clk_periph_gate, hw)
0573
0574 #define TEGRA_CLK_PERIPH_GATE_MAGIC 0x17760309
0575
0576 #define TEGRA_PERIPH_NO_RESET BIT(0)
0577 #define TEGRA_PERIPH_ON_APB BIT(2)
0578 #define TEGRA_PERIPH_WAR_1005168 BIT(3)
0579 #define TEGRA_PERIPH_NO_DIV BIT(4)
0580 #define TEGRA_PERIPH_NO_GATE BIT(5)
0581
0582 extern const struct clk_ops tegra_clk_periph_gate_ops;
0583 struct clk *tegra_clk_register_periph_gate(const char *name,
0584 const char *parent_name, u8 gate_flags, void __iomem *clk_base,
0585 unsigned long flags, int clk_num, int *enable_refcnt);
0586
0587 struct tegra_clk_periph_fixed {
0588 struct clk_hw hw;
0589 void __iomem *base;
0590 const struct tegra_clk_periph_regs *regs;
0591 unsigned int mul;
0592 unsigned int div;
0593 unsigned int num;
0594 };
0595
0596 struct clk *tegra_clk_register_periph_fixed(const char *name,
0597 const char *parent,
0598 unsigned long flags,
0599 void __iomem *base,
0600 unsigned int mul,
0601 unsigned int div,
0602 unsigned int num);
0603
0604
0605
0606
0607
0608
0609
0610
0611
0612
0613
0614
0615
0616 struct tegra_clk_periph {
0617 u32 magic;
0618 struct clk_hw hw;
0619 struct clk_mux mux;
0620 struct tegra_clk_frac_div divider;
0621 struct tegra_clk_periph_gate gate;
0622
0623 const struct clk_ops *mux_ops;
0624 const struct clk_ops *div_ops;
0625 const struct clk_ops *gate_ops;
0626 };
0627
0628 #define to_clk_periph(_hw) container_of(_hw, struct tegra_clk_periph, hw)
0629
0630 #define TEGRA_CLK_PERIPH_MAGIC 0x18221223
0631
0632 extern const struct clk_ops tegra_clk_periph_ops;
0633 struct clk *tegra_clk_register_periph(const char *name,
0634 const char * const *parent_names, int num_parents,
0635 struct tegra_clk_periph *periph, void __iomem *clk_base,
0636 u32 offset, unsigned long flags);
0637 struct clk *tegra_clk_register_periph_nodiv(const char *name,
0638 const char * const *parent_names, int num_parents,
0639 struct tegra_clk_periph *periph, void __iomem *clk_base,
0640 u32 offset);
0641
0642 #define TEGRA_CLK_PERIPH(_mux_shift, _mux_mask, _mux_flags, \
0643 _div_shift, _div_width, _div_frac_width, \
0644 _div_flags, _clk_num,\
0645 _gate_flags, _table, _lock) \
0646 { \
0647 .mux = { \
0648 .flags = _mux_flags, \
0649 .shift = _mux_shift, \
0650 .mask = _mux_mask, \
0651 .table = _table, \
0652 .lock = _lock, \
0653 }, \
0654 .divider = { \
0655 .flags = _div_flags, \
0656 .shift = _div_shift, \
0657 .width = _div_width, \
0658 .frac_width = _div_frac_width, \
0659 .lock = _lock, \
0660 }, \
0661 .gate = { \
0662 .flags = _gate_flags, \
0663 .clk_num = _clk_num, \
0664 }, \
0665 .mux_ops = &clk_mux_ops, \
0666 .div_ops = &tegra_clk_frac_div_ops, \
0667 .gate_ops = &tegra_clk_periph_gate_ops, \
0668 }
0669
0670 struct tegra_periph_init_data {
0671 const char *name;
0672 int clk_id;
0673 union {
0674 const char *const *parent_names;
0675 const char *parent_name;
0676 } p;
0677 int num_parents;
0678 struct tegra_clk_periph periph;
0679 u32 offset;
0680 const char *con_id;
0681 const char *dev_id;
0682 unsigned long flags;
0683 };
0684
0685 #define TEGRA_INIT_DATA_TABLE(_name, _con_id, _dev_id, _parent_names, _offset,\
0686 _mux_shift, _mux_mask, _mux_flags, _div_shift, \
0687 _div_width, _div_frac_width, _div_flags, \
0688 _clk_num, _gate_flags, _clk_id, _table, \
0689 _flags, _lock) \
0690 { \
0691 .name = _name, \
0692 .clk_id = _clk_id, \
0693 .p.parent_names = _parent_names, \
0694 .num_parents = ARRAY_SIZE(_parent_names), \
0695 .periph = TEGRA_CLK_PERIPH(_mux_shift, _mux_mask, \
0696 _mux_flags, _div_shift, \
0697 _div_width, _div_frac_width, \
0698 _div_flags, _clk_num, \
0699 _gate_flags, _table, _lock), \
0700 .offset = _offset, \
0701 .con_id = _con_id, \
0702 .dev_id = _dev_id, \
0703 .flags = _flags \
0704 }
0705
0706 #define TEGRA_INIT_DATA(_name, _con_id, _dev_id, _parent_names, _offset,\
0707 _mux_shift, _mux_width, _mux_flags, _div_shift, \
0708 _div_width, _div_frac_width, _div_flags, \
0709 _clk_num, _gate_flags, _clk_id) \
0710 TEGRA_INIT_DATA_TABLE(_name, _con_id, _dev_id, _parent_names, _offset,\
0711 _mux_shift, BIT(_mux_width) - 1, _mux_flags, \
0712 _div_shift, _div_width, _div_frac_width, _div_flags, \
0713 _clk_num, _gate_flags, _clk_id,\
0714 NULL, 0, NULL)
0715
0716 struct clk *tegra_clk_register_periph_data(void __iomem *clk_base,
0717 struct tegra_periph_init_data *init);
0718
0719
0720
0721
0722
0723
0724
0725
0726
0727
0728
0729
0730
0731
0732
0733
0734
0735
0736
0737
0738
0739 struct tegra_clk_super_mux {
0740 struct clk_hw hw;
0741 void __iomem *reg;
0742 struct tegra_clk_frac_div frac_div;
0743 const struct clk_ops *div_ops;
0744 u8 width;
0745 u8 flags;
0746 u8 div2_index;
0747 u8 pllx_index;
0748 spinlock_t *lock;
0749 };
0750
0751 #define to_clk_super_mux(_hw) container_of(_hw, struct tegra_clk_super_mux, hw)
0752
0753 #define TEGRA_DIVIDER_2 BIT(0)
0754 #define TEGRA210_CPU_CLK BIT(1)
0755 #define TEGRA20_SUPER_CLK BIT(2)
0756
0757 extern const struct clk_ops tegra_clk_super_ops;
0758 struct clk *tegra_clk_register_super_mux(const char *name,
0759 const char **parent_names, u8 num_parents,
0760 unsigned long flags, void __iomem *reg, u8 clk_super_flags,
0761 u8 width, u8 pllx_index, u8 div2_index, spinlock_t *lock);
0762 struct clk *tegra_clk_register_super_clk(const char *name,
0763 const char * const *parent_names, u8 num_parents,
0764 unsigned long flags, void __iomem *reg, u8 clk_super_flags,
0765 spinlock_t *lock);
0766 struct clk *tegra_clk_register_super_cclk(const char *name,
0767 const char * const *parent_names, u8 num_parents,
0768 unsigned long flags, void __iomem *reg, u8 clk_super_flags,
0769 spinlock_t *lock);
0770 int tegra_cclk_pre_pllx_rate_change(void);
0771 void tegra_cclk_post_pllx_rate_change(void);
0772
0773
0774
0775
0776
0777
0778
0779
0780
0781
0782
0783 struct tegra_sdmmc_mux {
0784 struct clk_hw hw;
0785 void __iomem *reg;
0786 spinlock_t *lock;
0787 const struct clk_ops *gate_ops;
0788 struct tegra_clk_periph_gate gate;
0789 u8 div_flags;
0790 };
0791
0792 #define to_clk_sdmmc_mux(_hw) container_of(_hw, struct tegra_sdmmc_mux, hw)
0793
0794 struct clk *tegra_clk_register_sdmmc_mux_div(const char *name,
0795 void __iomem *clk_base, u32 offset, u32 clk_num, u8 div_flags,
0796 unsigned long flags, void *lock);
0797
0798
0799
0800
0801
0802
0803
0804
0805 struct tegra_clk_init_table {
0806 unsigned int clk_id;
0807 unsigned int parent_id;
0808 unsigned long rate;
0809 int state;
0810 };
0811
0812
0813
0814
0815
0816
0817 struct tegra_clk_duplicate {
0818 int clk_id;
0819 struct clk_lookup lookup;
0820 };
0821
0822 #define TEGRA_CLK_DUPLICATE(_clk_id, _dev, _con) \
0823 { \
0824 .clk_id = _clk_id, \
0825 .lookup = { \
0826 .dev_id = _dev, \
0827 .con_id = _con, \
0828 }, \
0829 }
0830
0831 struct tegra_clk {
0832 int dt_id;
0833 bool present;
0834 };
0835
0836 struct tegra_devclk {
0837 int dt_id;
0838 char *dev_id;
0839 char *con_id;
0840 };
0841
0842 void tegra_init_special_resets(unsigned int num, int (*assert)(unsigned long),
0843 int (*deassert)(unsigned long));
0844
0845 void tegra_init_from_table(struct tegra_clk_init_table *tbl,
0846 struct clk *clks[], int clk_max);
0847
0848 void tegra_init_dup_clks(struct tegra_clk_duplicate *dup_list,
0849 struct clk *clks[], int clk_max);
0850
0851 const struct tegra_clk_periph_regs *get_reg_bank(int clkid);
0852 struct clk **tegra_clk_init(void __iomem *clk_base, int num, int periph_banks);
0853
0854 struct clk **tegra_lookup_dt_id(int clk_id, struct tegra_clk *tegra_clk);
0855
0856 void tegra_add_of_provider(struct device_node *np, void *clk_src_onecell_get);
0857 void tegra_register_devclks(struct tegra_devclk *dev_clks, int num);
0858
0859 void tegra_audio_clk_init(void __iomem *clk_base,
0860 void __iomem *pmc_base, struct tegra_clk *tegra_clks,
0861 struct tegra_audio_clk_info *audio_info,
0862 unsigned int num_plls, unsigned long sync_max_rate);
0863
0864 void tegra_periph_clk_init(void __iomem *clk_base, void __iomem *pmc_base,
0865 struct tegra_clk *tegra_clks,
0866 struct tegra_clk_pll_params *pll_params);
0867
0868 void tegra_fixed_clk_init(struct tegra_clk *tegra_clks);
0869 int tegra_osc_clk_init(void __iomem *clk_base, struct tegra_clk *clks,
0870 unsigned long *input_freqs, unsigned int num,
0871 unsigned int clk_m_div, unsigned long *osc_freq,
0872 unsigned long *pll_ref_freq);
0873 void tegra_super_clk_gen4_init(void __iomem *clk_base,
0874 void __iomem *pmc_base, struct tegra_clk *tegra_clks,
0875 struct tegra_clk_pll_params *pll_params);
0876 void tegra_super_clk_gen5_init(void __iomem *clk_base,
0877 void __iomem *pmc_base, struct tegra_clk *tegra_clks,
0878 struct tegra_clk_pll_params *pll_params);
0879
0880 #ifdef CONFIG_TEGRA124_CLK_EMC
0881 struct clk *tegra124_clk_register_emc(void __iomem *base, struct device_node *np,
0882 spinlock_t *lock);
0883 bool tegra124_clk_emc_driver_available(struct clk_hw *emc_hw);
0884 #else
0885 static inline struct clk *
0886 tegra124_clk_register_emc(void __iomem *base, struct device_node *np,
0887 spinlock_t *lock)
0888 {
0889 return NULL;
0890 }
0891
0892 static inline bool tegra124_clk_emc_driver_available(struct clk_hw *emc_hw)
0893 {
0894 return false;
0895 }
0896 #endif
0897
0898 void tegra114_clock_tune_cpu_trimmers_high(void);
0899 void tegra114_clock_tune_cpu_trimmers_low(void);
0900 void tegra114_clock_tune_cpu_trimmers_init(void);
0901 void tegra114_clock_assert_dfll_dvco_reset(void);
0902 void tegra114_clock_deassert_dfll_dvco_reset(void);
0903
0904 typedef void (*tegra_clk_apply_init_table_func)(void);
0905 extern tegra_clk_apply_init_table_func tegra_clk_apply_init_table;
0906 int tegra_pll_wait_for_lock(struct tegra_clk_pll *pll);
0907 u16 tegra_pll_get_fixed_mdiv(struct clk_hw *hw, unsigned long input_rate);
0908 int tegra_pll_p_div_to_hw(struct tegra_clk_pll *pll, u8 p_div);
0909 int div_frac_get(unsigned long rate, unsigned parent_rate, u8 width,
0910 u8 frac_width, u8 flags);
0911 void tegra_clk_osc_resume(void __iomem *clk_base);
0912 void tegra_clk_set_pllp_out_cpu(bool enable);
0913 void tegra_clk_periph_suspend(void);
0914 void tegra_clk_periph_resume(void);
0915
0916
0917
0918 #define fence_udelay(delay, reg) \
0919 do { \
0920 readl(reg); \
0921 udelay(delay); \
0922 } while (0)
0923
0924 bool tegra20_clk_emc_driver_available(struct clk_hw *emc_hw);
0925 struct clk *tegra20_clk_register_emc(void __iomem *ioaddr, bool low_jitter);
0926
0927 struct clk *tegra210_clk_register_emc(struct device_node *np,
0928 void __iomem *regs);
0929
0930 struct clk *tegra_clk_dev_register(struct clk_hw *hw);
0931
0932 #endif