clk.h 19 KB

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