clk.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635
  1. /*
  2. * Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved.
  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. * This program is distributed in the hope it will be useful, but WITHOUT
  9. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  11. * more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #ifndef __TEGRA_CLK_H
  17. #define __TEGRA_CLK_H
  18. #include <linux/clk-provider.h>
  19. #include <linux/clkdev.h>
  20. /**
  21. * struct tegra_clk_sync_source - external clock source from codec
  22. *
  23. * @hw: handle between common and hardware-specific interfaces
  24. * @rate: input frequency from source
  25. * @max_rate: max rate allowed
  26. */
  27. struct tegra_clk_sync_source {
  28. struct clk_hw hw;
  29. unsigned long rate;
  30. unsigned long max_rate;
  31. };
  32. #define to_clk_sync_source(_hw) \
  33. container_of(_hw, struct tegra_clk_sync_source, hw)
  34. extern const struct clk_ops tegra_clk_sync_source_ops;
  35. extern int *periph_clk_enb_refcnt;
  36. struct clk *tegra_clk_register_sync_source(const char *name,
  37. unsigned long fixed_rate, unsigned long max_rate);
  38. /**
  39. * struct tegra_clk_frac_div - fractional divider clock
  40. *
  41. * @hw: handle between common and hardware-specific interfaces
  42. * @reg: register containing divider
  43. * @flags: hardware-specific flags
  44. * @shift: shift to the divider bit field
  45. * @width: width of the divider bit field
  46. * @frac_width: width of the fractional bit field
  47. * @lock: register lock
  48. *
  49. * Flags:
  50. * TEGRA_DIVIDER_ROUND_UP - This flags indicates to round up the divider value.
  51. * TEGRA_DIVIDER_FIXED - Fixed rate PLL dividers has addition override bit, this
  52. * flag indicates that this divider is for fixed rate PLL.
  53. * TEGRA_DIVIDER_INT - Some modules can not cope with the duty cycle when
  54. * fraction bit is set. This flags indicates to calculate divider for which
  55. * fracton bit will be zero.
  56. * TEGRA_DIVIDER_UART - UART module divider has additional enable bit which is
  57. * set when divider value is not 0. This flags indicates that the divider
  58. * is for UART module.
  59. */
  60. struct tegra_clk_frac_div {
  61. struct clk_hw hw;
  62. void __iomem *reg;
  63. u8 flags;
  64. u8 shift;
  65. u8 width;
  66. u8 frac_width;
  67. spinlock_t *lock;
  68. };
  69. #define to_clk_frac_div(_hw) container_of(_hw, struct tegra_clk_frac_div, hw)
  70. #define TEGRA_DIVIDER_ROUND_UP BIT(0)
  71. #define TEGRA_DIVIDER_FIXED BIT(1)
  72. #define TEGRA_DIVIDER_INT BIT(2)
  73. #define TEGRA_DIVIDER_UART BIT(3)
  74. extern const struct clk_ops tegra_clk_frac_div_ops;
  75. struct clk *tegra_clk_register_divider(const char *name,
  76. const char *parent_name, void __iomem *reg,
  77. unsigned long flags, u8 clk_divider_flags, u8 shift, u8 width,
  78. u8 frac_width, spinlock_t *lock);
  79. struct clk *tegra_clk_register_mc(const char *name, const char *parent_name,
  80. void __iomem *reg, spinlock_t *lock);
  81. /*
  82. * Tegra PLL:
  83. *
  84. * In general, there are 3 requirements for each PLL
  85. * that SW needs to be comply with.
  86. * (1) Input frequency range (REF).
  87. * (2) Comparison frequency range (CF). CF = REF/DIVM.
  88. * (3) VCO frequency range (VCO). VCO = CF * DIVN.
  89. *
  90. * The final PLL output frequency (FO) = VCO >> DIVP.
  91. */
  92. /**
  93. * struct tegra_clk_pll_freq_table - PLL frequecy table
  94. *
  95. * @input_rate: input rate from source
  96. * @output_rate: output rate from PLL for the input rate
  97. * @n: feedback divider
  98. * @m: input divider
  99. * @p: post divider
  100. * @cpcon: charge pump current
  101. */
  102. struct tegra_clk_pll_freq_table {
  103. unsigned long input_rate;
  104. unsigned long output_rate;
  105. u16 n;
  106. u16 m;
  107. u8 p;
  108. u8 cpcon;
  109. };
  110. /**
  111. * struct pdiv_map - map post divider to hw value
  112. *
  113. * @pdiv: post divider
  114. * @hw_val: value to be written to the PLL hw
  115. */
  116. struct pdiv_map {
  117. u8 pdiv;
  118. u8 hw_val;
  119. };
  120. /**
  121. * struct div_nmp - offset and width of m,n and p fields
  122. *
  123. * @divn_shift: shift to the feedback divider bit field
  124. * @divn_width: width of the feedback divider bit field
  125. * @divm_shift: shift to the input divider bit field
  126. * @divm_width: width of the input divider bit field
  127. * @divp_shift: shift to the post divider bit field
  128. * @divp_width: width of the post divider bit field
  129. * @override_divn_shift: shift to the feedback divider bitfield in override reg
  130. * @override_divm_shift: shift to the input divider bitfield in override reg
  131. * @override_divp_shift: shift to the post divider bitfield in override reg
  132. */
  133. struct div_nmp {
  134. u8 divn_shift;
  135. u8 divn_width;
  136. u8 divm_shift;
  137. u8 divm_width;
  138. u8 divp_shift;
  139. u8 divp_width;
  140. u8 override_divn_shift;
  141. u8 override_divm_shift;
  142. u8 override_divp_shift;
  143. };
  144. /**
  145. * struct clk_pll_params - PLL parameters
  146. *
  147. * @input_min: Minimum input frequency
  148. * @input_max: Maximum input frequency
  149. * @cf_min: Minimum comparison frequency
  150. * @cf_max: Maximum comparison frequency
  151. * @vco_min: Minimum VCO frequency
  152. * @vco_max: Maximum VCO frequency
  153. * @base_reg: PLL base reg offset
  154. * @misc_reg: PLL misc reg offset
  155. * @lock_reg: PLL lock reg offset
  156. * @lock_bit_idx: Bit index for PLL lock status
  157. * @lock_enable_bit_idx: Bit index to enable PLL lock
  158. * @lock_delay: Delay in us if PLL lock is not used
  159. */
  160. struct tegra_clk_pll_params {
  161. unsigned long input_min;
  162. unsigned long input_max;
  163. unsigned long cf_min;
  164. unsigned long cf_max;
  165. unsigned long vco_min;
  166. unsigned long vco_max;
  167. u32 base_reg;
  168. u32 misc_reg;
  169. u32 lock_reg;
  170. u32 lock_mask;
  171. u32 lock_enable_bit_idx;
  172. u32 iddq_reg;
  173. u32 iddq_bit_idx;
  174. u32 aux_reg;
  175. u32 dyn_ramp_reg;
  176. u32 ext_misc_reg[3];
  177. u32 pmc_divnm_reg;
  178. u32 pmc_divp_reg;
  179. u32 flags;
  180. int stepa_shift;
  181. int stepb_shift;
  182. int lock_delay;
  183. int max_p;
  184. struct pdiv_map *pdiv_tohw;
  185. struct div_nmp *div_nmp;
  186. struct tegra_clk_pll_freq_table *freq_table;
  187. unsigned long fixed_rate;
  188. };
  189. /**
  190. * struct tegra_clk_pll - Tegra PLL clock
  191. *
  192. * @hw: handle between common and hardware-specifix interfaces
  193. * @clk_base: address of CAR controller
  194. * @pmc: address of PMC, required to read override bits
  195. * @freq_table: array of frequencies supported by PLL
  196. * @params: PLL parameters
  197. * @flags: PLL flags
  198. * @fixed_rate: PLL rate if it is fixed
  199. * @lock: register lock
  200. *
  201. * Flags:
  202. * TEGRA_PLL_USE_LOCK - This flag indicated to use lock bits for
  203. * PLL locking. If not set it will use lock_delay value to wait.
  204. * TEGRA_PLL_HAS_CPCON - This flag indicates that CPCON value needs
  205. * to be programmed to change output frequency of the PLL.
  206. * TEGRA_PLL_SET_LFCON - This flag indicates that LFCON value needs
  207. * to be programmed to change output frequency of the PLL.
  208. * TEGRA_PLL_SET_DCCON - This flag indicates that DCCON value needs
  209. * to be programmed to change output frequency of the PLL.
  210. * TEGRA_PLLU - PLLU has inverted post divider. This flags indicated
  211. * that it is PLLU and invert post divider value.
  212. * TEGRA_PLLM - PLLM has additional override settings in PMC. This
  213. * flag indicates that it is PLLM and use override settings.
  214. * TEGRA_PLL_FIXED - We are not supposed to change output frequency
  215. * of some plls.
  216. * TEGRA_PLLE_CONFIGURE - Configure PLLE when enabling.
  217. * TEGRA_PLL_LOCK_MISC - Lock bit is in the misc register instead of the
  218. * base register.
  219. * TEGRA_PLL_BYPASS - PLL has bypass bit
  220. * TEGRA_PLL_HAS_LOCK_ENABLE - PLL has bit to enable lock monitoring
  221. */
  222. struct tegra_clk_pll {
  223. struct clk_hw hw;
  224. void __iomem *clk_base;
  225. void __iomem *pmc;
  226. spinlock_t *lock;
  227. struct tegra_clk_pll_params *params;
  228. };
  229. #define to_clk_pll(_hw) container_of(_hw, struct tegra_clk_pll, hw)
  230. #define TEGRA_PLL_USE_LOCK BIT(0)
  231. #define TEGRA_PLL_HAS_CPCON BIT(1)
  232. #define TEGRA_PLL_SET_LFCON BIT(2)
  233. #define TEGRA_PLL_SET_DCCON BIT(3)
  234. #define TEGRA_PLLU BIT(4)
  235. #define TEGRA_PLLM BIT(5)
  236. #define TEGRA_PLL_FIXED BIT(6)
  237. #define TEGRA_PLLE_CONFIGURE BIT(7)
  238. #define TEGRA_PLL_LOCK_MISC BIT(8)
  239. #define TEGRA_PLL_BYPASS BIT(9)
  240. #define TEGRA_PLL_HAS_LOCK_ENABLE BIT(10)
  241. extern const struct clk_ops tegra_clk_pll_ops;
  242. extern const struct clk_ops tegra_clk_plle_ops;
  243. struct clk *tegra_clk_register_pll(const char *name, const char *parent_name,
  244. void __iomem *clk_base, void __iomem *pmc,
  245. unsigned long flags, struct tegra_clk_pll_params *pll_params,
  246. spinlock_t *lock);
  247. struct clk *tegra_clk_register_plle(const char *name, const char *parent_name,
  248. void __iomem *clk_base, void __iomem *pmc,
  249. unsigned long flags, struct tegra_clk_pll_params *pll_params,
  250. spinlock_t *lock);
  251. struct clk *tegra_clk_register_pllxc(const char *name, const char *parent_name,
  252. void __iomem *clk_base, void __iomem *pmc,
  253. unsigned long flags,
  254. struct tegra_clk_pll_params *pll_params,
  255. spinlock_t *lock);
  256. struct clk *tegra_clk_register_pllm(const char *name, const char *parent_name,
  257. void __iomem *clk_base, void __iomem *pmc,
  258. unsigned long flags,
  259. struct tegra_clk_pll_params *pll_params,
  260. spinlock_t *lock);
  261. struct clk *tegra_clk_register_pllc(const char *name, const char *parent_name,
  262. void __iomem *clk_base, void __iomem *pmc,
  263. unsigned long flags,
  264. struct tegra_clk_pll_params *pll_params,
  265. spinlock_t *lock);
  266. struct clk *tegra_clk_register_pllre(const char *name, const char *parent_name,
  267. void __iomem *clk_base, void __iomem *pmc,
  268. unsigned long flags,
  269. struct tegra_clk_pll_params *pll_params,
  270. spinlock_t *lock, unsigned long parent_rate);
  271. struct clk *tegra_clk_register_plle_tegra114(const char *name,
  272. const char *parent_name,
  273. void __iomem *clk_base, unsigned long flags,
  274. struct tegra_clk_pll_params *pll_params,
  275. spinlock_t *lock);
  276. struct clk *tegra_clk_register_pllss(const char *name, const char *parent_name,
  277. void __iomem *clk_base, unsigned long flags,
  278. struct tegra_clk_pll_params *pll_params,
  279. spinlock_t *lock);
  280. /**
  281. * struct tegra_clk_pll_out - PLL divider down clock
  282. *
  283. * @hw: handle between common and hardware-specific interfaces
  284. * @reg: register containing the PLL divider
  285. * @enb_bit_idx: bit to enable/disable PLL divider
  286. * @rst_bit_idx: bit to reset PLL divider
  287. * @lock: register lock
  288. * @flags: hardware-specific flags
  289. */
  290. struct tegra_clk_pll_out {
  291. struct clk_hw hw;
  292. void __iomem *reg;
  293. u8 enb_bit_idx;
  294. u8 rst_bit_idx;
  295. spinlock_t *lock;
  296. u8 flags;
  297. };
  298. #define to_clk_pll_out(_hw) container_of(_hw, struct tegra_clk_pll_out, hw)
  299. extern const struct clk_ops tegra_clk_pll_out_ops;
  300. struct clk *tegra_clk_register_pll_out(const char *name,
  301. const char *parent_name, void __iomem *reg, u8 enb_bit_idx,
  302. u8 rst_bit_idx, unsigned long flags, u8 pll_div_flags,
  303. spinlock_t *lock);
  304. /**
  305. * struct tegra_clk_periph_regs - Registers controlling peripheral clock
  306. *
  307. * @enb_reg: read the enable status
  308. * @enb_set_reg: write 1 to enable clock
  309. * @enb_clr_reg: write 1 to disable clock
  310. * @rst_reg: read the reset status
  311. * @rst_set_reg: write 1 to assert the reset of peripheral
  312. * @rst_clr_reg: write 1 to deassert the reset of peripheral
  313. */
  314. struct tegra_clk_periph_regs {
  315. u32 enb_reg;
  316. u32 enb_set_reg;
  317. u32 enb_clr_reg;
  318. u32 rst_reg;
  319. u32 rst_set_reg;
  320. u32 rst_clr_reg;
  321. };
  322. /**
  323. * struct tegra_clk_periph_gate - peripheral gate clock
  324. *
  325. * @magic: magic number to validate type
  326. * @hw: handle between common and hardware-specific interfaces
  327. * @clk_base: address of CAR controller
  328. * @regs: Registers to control the peripheral
  329. * @flags: hardware-specific flags
  330. * @clk_num: Clock number
  331. * @enable_refcnt: array to maintain reference count of the clock
  332. *
  333. * Flags:
  334. * TEGRA_PERIPH_NO_RESET - This flag indicates that reset is not allowed
  335. * for this module.
  336. * TEGRA_PERIPH_MANUAL_RESET - This flag indicates not to reset module
  337. * after clock enable and driver for the module is responsible for
  338. * doing reset.
  339. * TEGRA_PERIPH_ON_APB - If peripheral is in the APB bus then read the
  340. * bus to flush the write operation in apb bus. This flag indicates
  341. * that this peripheral is in apb bus.
  342. * TEGRA_PERIPH_WAR_1005168 - Apply workaround for Tegra114 MSENC bug
  343. */
  344. struct tegra_clk_periph_gate {
  345. u32 magic;
  346. struct clk_hw hw;
  347. void __iomem *clk_base;
  348. u8 flags;
  349. int clk_num;
  350. int *enable_refcnt;
  351. struct tegra_clk_periph_regs *regs;
  352. };
  353. #define to_clk_periph_gate(_hw) \
  354. container_of(_hw, struct tegra_clk_periph_gate, hw)
  355. #define TEGRA_CLK_PERIPH_GATE_MAGIC 0x17760309
  356. #define TEGRA_PERIPH_NO_RESET BIT(0)
  357. #define TEGRA_PERIPH_MANUAL_RESET BIT(1)
  358. #define TEGRA_PERIPH_ON_APB BIT(2)
  359. #define TEGRA_PERIPH_WAR_1005168 BIT(3)
  360. #define TEGRA_PERIPH_NO_DIV BIT(4)
  361. #define TEGRA_PERIPH_NO_GATE BIT(5)
  362. extern const struct clk_ops tegra_clk_periph_gate_ops;
  363. struct clk *tegra_clk_register_periph_gate(const char *name,
  364. const char *parent_name, u8 gate_flags, void __iomem *clk_base,
  365. unsigned long flags, int clk_num, int *enable_refcnt);
  366. /**
  367. * struct clk-periph - peripheral clock
  368. *
  369. * @magic: magic number to validate type
  370. * @hw: handle between common and hardware-specific interfaces
  371. * @mux: mux clock
  372. * @divider: divider clock
  373. * @gate: gate clock
  374. * @mux_ops: mux clock ops
  375. * @div_ops: divider clock ops
  376. * @gate_ops: gate clock ops
  377. */
  378. struct tegra_clk_periph {
  379. u32 magic;
  380. struct clk_hw hw;
  381. struct clk_mux mux;
  382. struct tegra_clk_frac_div divider;
  383. struct tegra_clk_periph_gate gate;
  384. const struct clk_ops *mux_ops;
  385. const struct clk_ops *div_ops;
  386. const struct clk_ops *gate_ops;
  387. };
  388. #define to_clk_periph(_hw) container_of(_hw, struct tegra_clk_periph, hw)
  389. #define TEGRA_CLK_PERIPH_MAGIC 0x18221223
  390. extern const struct clk_ops tegra_clk_periph_ops;
  391. struct clk *tegra_clk_register_periph(const char *name,
  392. const char **parent_names, int num_parents,
  393. struct tegra_clk_periph *periph, void __iomem *clk_base,
  394. u32 offset, unsigned long flags);
  395. struct clk *tegra_clk_register_periph_nodiv(const char *name,
  396. const char **parent_names, int num_parents,
  397. struct tegra_clk_periph *periph, void __iomem *clk_base,
  398. u32 offset);
  399. #define TEGRA_CLK_PERIPH(_mux_shift, _mux_mask, _mux_flags, \
  400. _div_shift, _div_width, _div_frac_width, \
  401. _div_flags, _clk_num,\
  402. _gate_flags, _table, _lock) \
  403. { \
  404. .mux = { \
  405. .flags = _mux_flags, \
  406. .shift = _mux_shift, \
  407. .mask = _mux_mask, \
  408. .table = _table, \
  409. .lock = _lock, \
  410. }, \
  411. .divider = { \
  412. .flags = _div_flags, \
  413. .shift = _div_shift, \
  414. .width = _div_width, \
  415. .frac_width = _div_frac_width, \
  416. .lock = _lock, \
  417. }, \
  418. .gate = { \
  419. .flags = _gate_flags, \
  420. .clk_num = _clk_num, \
  421. }, \
  422. .mux_ops = &clk_mux_ops, \
  423. .div_ops = &tegra_clk_frac_div_ops, \
  424. .gate_ops = &tegra_clk_periph_gate_ops, \
  425. }
  426. struct tegra_periph_init_data {
  427. const char *name;
  428. int clk_id;
  429. union {
  430. const char **parent_names;
  431. const char *parent_name;
  432. } p;
  433. int num_parents;
  434. struct tegra_clk_periph periph;
  435. u32 offset;
  436. const char *con_id;
  437. const char *dev_id;
  438. unsigned long flags;
  439. };
  440. #define TEGRA_INIT_DATA_TABLE(_name, _con_id, _dev_id, _parent_names, _offset,\
  441. _mux_shift, _mux_mask, _mux_flags, _div_shift, \
  442. _div_width, _div_frac_width, _div_flags, \
  443. _clk_num, _gate_flags, _clk_id, _table, \
  444. _flags, _lock) \
  445. { \
  446. .name = _name, \
  447. .clk_id = _clk_id, \
  448. .p.parent_names = _parent_names, \
  449. .num_parents = ARRAY_SIZE(_parent_names), \
  450. .periph = TEGRA_CLK_PERIPH(_mux_shift, _mux_mask, \
  451. _mux_flags, _div_shift, \
  452. _div_width, _div_frac_width, \
  453. _div_flags, _clk_num, \
  454. _gate_flags, _table, _lock), \
  455. .offset = _offset, \
  456. .con_id = _con_id, \
  457. .dev_id = _dev_id, \
  458. .flags = _flags \
  459. }
  460. #define TEGRA_INIT_DATA(_name, _con_id, _dev_id, _parent_names, _offset,\
  461. _mux_shift, _mux_width, _mux_flags, _div_shift, \
  462. _div_width, _div_frac_width, _div_flags, \
  463. _clk_num, _gate_flags, _clk_id) \
  464. TEGRA_INIT_DATA_TABLE(_name, _con_id, _dev_id, _parent_names, _offset,\
  465. _mux_shift, BIT(_mux_width) - 1, _mux_flags, \
  466. _div_shift, _div_width, _div_frac_width, _div_flags, \
  467. _clk_num, _gate_flags, _clk_id,\
  468. NULL, 0, NULL)
  469. /**
  470. * struct clk_super_mux - super clock
  471. *
  472. * @hw: handle between common and hardware-specific interfaces
  473. * @reg: register controlling multiplexer
  474. * @width: width of the multiplexer bit field
  475. * @flags: hardware-specific flags
  476. * @div2_index: bit controlling divide-by-2
  477. * @pllx_index: PLLX index in the parent list
  478. * @lock: register lock
  479. *
  480. * Flags:
  481. * TEGRA_DIVIDER_2 - LP cluster has additional divider. This flag indicates
  482. * that this is LP cluster clock.
  483. */
  484. struct tegra_clk_super_mux {
  485. struct clk_hw hw;
  486. void __iomem *reg;
  487. u8 width;
  488. u8 flags;
  489. u8 div2_index;
  490. u8 pllx_index;
  491. spinlock_t *lock;
  492. };
  493. #define to_clk_super_mux(_hw) container_of(_hw, struct tegra_clk_super_mux, hw)
  494. #define TEGRA_DIVIDER_2 BIT(0)
  495. extern const struct clk_ops tegra_clk_super_ops;
  496. struct clk *tegra_clk_register_super_mux(const char *name,
  497. const char **parent_names, u8 num_parents,
  498. unsigned long flags, void __iomem *reg, u8 clk_super_flags,
  499. u8 width, u8 pllx_index, u8 div2_index, spinlock_t *lock);
  500. /**
  501. * struct clk_init_tabel - clock initialization table
  502. * @clk_id: clock id as mentioned in device tree bindings
  503. * @parent_id: parent clock id as mentioned in device tree bindings
  504. * @rate: rate to set
  505. * @state: enable/disable
  506. */
  507. struct tegra_clk_init_table {
  508. unsigned int clk_id;
  509. unsigned int parent_id;
  510. unsigned long rate;
  511. int state;
  512. };
  513. /**
  514. * struct clk_duplicate - duplicate clocks
  515. * @clk_id: clock id as mentioned in device tree bindings
  516. * @lookup: duplicate lookup entry for the clock
  517. */
  518. struct tegra_clk_duplicate {
  519. int clk_id;
  520. struct clk_lookup lookup;
  521. };
  522. #define TEGRA_CLK_DUPLICATE(_clk_id, _dev, _con) \
  523. { \
  524. .clk_id = _clk_id, \
  525. .lookup = { \
  526. .dev_id = _dev, \
  527. .con_id = _con, \
  528. }, \
  529. }
  530. struct tegra_clk {
  531. int dt_id;
  532. bool present;
  533. };
  534. struct tegra_devclk {
  535. int dt_id;
  536. char *dev_id;
  537. char *con_id;
  538. };
  539. void tegra_init_from_table(struct tegra_clk_init_table *tbl,
  540. struct clk *clks[], int clk_max);
  541. void tegra_init_dup_clks(struct tegra_clk_duplicate *dup_list,
  542. struct clk *clks[], int clk_max);
  543. struct tegra_clk_periph_regs *get_reg_bank(int clkid);
  544. struct clk **tegra_clk_init(void __iomem *clk_base, int num, int periph_banks);
  545. struct clk **tegra_lookup_dt_id(int clk_id, struct tegra_clk *tegra_clk);
  546. void tegra_add_of_provider(struct device_node *np);
  547. void tegra_register_devclks(struct tegra_devclk *dev_clks, int num);
  548. void tegra_audio_clk_init(void __iomem *clk_base,
  549. void __iomem *pmc_base, struct tegra_clk *tegra_clks,
  550. struct tegra_clk_pll_params *pll_params);
  551. void tegra_periph_clk_init(void __iomem *clk_base, void __iomem *pmc_base,
  552. struct tegra_clk *tegra_clks,
  553. struct tegra_clk_pll_params *pll_params);
  554. void tegra_pmc_clk_init(void __iomem *pmc_base, struct tegra_clk *tegra_clks);
  555. void tegra_fixed_clk_init(struct tegra_clk *tegra_clks);
  556. int tegra_osc_clk_init(void __iomem *clk_base, struct tegra_clk *tegra_clks,
  557. unsigned long *input_freqs, int num,
  558. unsigned long *osc_freq,
  559. unsigned long *pll_ref_freq);
  560. void tegra_super_clk_gen4_init(void __iomem *clk_base,
  561. void __iomem *pmc_base, struct tegra_clk *tegra_clks,
  562. struct tegra_clk_pll_params *pll_params);
  563. void tegra114_clock_tune_cpu_trimmers_high(void);
  564. void tegra114_clock_tune_cpu_trimmers_low(void);
  565. void tegra114_clock_tune_cpu_trimmers_init(void);
  566. void tegra114_clock_assert_dfll_dvco_reset(void);
  567. void tegra114_clock_deassert_dfll_dvco_reset(void);
  568. typedef void (*tegra_clk_apply_init_table_func)(void);
  569. extern tegra_clk_apply_init_table_func tegra_clk_apply_init_table;
  570. #endif /* TEGRA_CLK_H */