clk.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678
  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 tegra_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_mask: Bitmask for PLL lock status
  157. * @lock_enable_bit_idx: Bit index to enable PLL lock
  158. * @iddq_reg: PLL IDDQ register offset
  159. * @iddq_bit_idx: Bit index to enable PLL IDDQ
  160. * @aux_reg: AUX register offset
  161. * @dyn_ramp_reg: Dynamic ramp control register offset
  162. * @ext_misc_reg: Miscellaneous control register offsets
  163. * @pmc_divnm_reg: n, m divider PMC override register offset (PLLM)
  164. * @pmc_divp_reg: p divider PMC override register offset (PLLM)
  165. * @flags: PLL flags
  166. * @stepa_shift: Dynamic ramp step A field shift
  167. * @stepb_shift: Dynamic ramp step B field shift
  168. * @lock_delay: Delay in us if PLL lock is not used
  169. * @max_p: maximum value for the p divider
  170. * @pdiv_tohw: mapping of p divider to register values
  171. * @div_nmp: offsets and widths on n, m and p fields
  172. * @freq_table: array of frequencies supported by PLL
  173. * @fixed_rate: PLL rate if it is fixed
  174. *
  175. * Flags:
  176. * TEGRA_PLL_USE_LOCK - This flag indicated to use lock bits for
  177. * PLL locking. If not set it will use lock_delay value to wait.
  178. * TEGRA_PLL_HAS_CPCON - This flag indicates that CPCON value needs
  179. * to be programmed to change output frequency of the PLL.
  180. * TEGRA_PLL_SET_LFCON - This flag indicates that LFCON value needs
  181. * to be programmed to change output frequency of the PLL.
  182. * TEGRA_PLL_SET_DCCON - This flag indicates that DCCON value needs
  183. * to be programmed to change output frequency of the PLL.
  184. * TEGRA_PLLU - PLLU has inverted post divider. This flags indicated
  185. * that it is PLLU and invert post divider value.
  186. * TEGRA_PLLM - PLLM has additional override settings in PMC. This
  187. * flag indicates that it is PLLM and use override settings.
  188. * TEGRA_PLL_FIXED - We are not supposed to change output frequency
  189. * of some plls.
  190. * TEGRA_PLLE_CONFIGURE - Configure PLLE when enabling.
  191. * TEGRA_PLL_LOCK_MISC - Lock bit is in the misc register instead of the
  192. * base register.
  193. * TEGRA_PLL_BYPASS - PLL has bypass bit
  194. * TEGRA_PLL_HAS_LOCK_ENABLE - PLL has bit to enable lock monitoring
  195. */
  196. struct tegra_clk_pll_params {
  197. unsigned long input_min;
  198. unsigned long input_max;
  199. unsigned long cf_min;
  200. unsigned long cf_max;
  201. unsigned long vco_min;
  202. unsigned long vco_max;
  203. u32 base_reg;
  204. u32 misc_reg;
  205. u32 lock_reg;
  206. u32 lock_mask;
  207. u32 lock_enable_bit_idx;
  208. u32 iddq_reg;
  209. u32 iddq_bit_idx;
  210. u32 aux_reg;
  211. u32 dyn_ramp_reg;
  212. u32 ext_misc_reg[3];
  213. u32 pmc_divnm_reg;
  214. u32 pmc_divp_reg;
  215. u32 flags;
  216. int stepa_shift;
  217. int stepb_shift;
  218. int lock_delay;
  219. int max_p;
  220. struct pdiv_map *pdiv_tohw;
  221. struct div_nmp *div_nmp;
  222. struct tegra_clk_pll_freq_table *freq_table;
  223. unsigned long fixed_rate;
  224. };
  225. #define TEGRA_PLL_USE_LOCK BIT(0)
  226. #define TEGRA_PLL_HAS_CPCON BIT(1)
  227. #define TEGRA_PLL_SET_LFCON BIT(2)
  228. #define TEGRA_PLL_SET_DCCON BIT(3)
  229. #define TEGRA_PLLU BIT(4)
  230. #define TEGRA_PLLM BIT(5)
  231. #define TEGRA_PLL_FIXED BIT(6)
  232. #define TEGRA_PLLE_CONFIGURE BIT(7)
  233. #define TEGRA_PLL_LOCK_MISC BIT(8)
  234. #define TEGRA_PLL_BYPASS BIT(9)
  235. #define TEGRA_PLL_HAS_LOCK_ENABLE BIT(10)
  236. /**
  237. * struct tegra_clk_pll - Tegra PLL clock
  238. *
  239. * @hw: handle between common and hardware-specifix interfaces
  240. * @clk_base: address of CAR controller
  241. * @pmc: address of PMC, required to read override bits
  242. * @lock: register lock
  243. * @params: PLL parameters
  244. */
  245. struct tegra_clk_pll {
  246. struct clk_hw hw;
  247. void __iomem *clk_base;
  248. void __iomem *pmc;
  249. spinlock_t *lock;
  250. struct tegra_clk_pll_params *params;
  251. };
  252. #define to_clk_pll(_hw) container_of(_hw, struct tegra_clk_pll, hw)
  253. /**
  254. * struct tegra_audio_clk_info - Tegra Audio Clk Information
  255. *
  256. * @name: name for the audio pll
  257. * @pll_params: pll_params for audio pll
  258. * @clk_id: clk_ids for the audio pll
  259. * @parent: name of the parent of the audio pll
  260. */
  261. struct tegra_audio_clk_info {
  262. char *name;
  263. struct tegra_clk_pll_params *pll_params;
  264. int clk_id;
  265. char *parent;
  266. };
  267. extern const struct clk_ops tegra_clk_pll_ops;
  268. extern const struct clk_ops tegra_clk_plle_ops;
  269. struct clk *tegra_clk_register_pll(const char *name, const char *parent_name,
  270. void __iomem *clk_base, void __iomem *pmc,
  271. unsigned long flags, struct tegra_clk_pll_params *pll_params,
  272. spinlock_t *lock);
  273. struct clk *tegra_clk_register_plle(const char *name, const char *parent_name,
  274. void __iomem *clk_base, void __iomem *pmc,
  275. unsigned long flags, struct tegra_clk_pll_params *pll_params,
  276. spinlock_t *lock);
  277. struct clk *tegra_clk_register_pllxc(const char *name, const char *parent_name,
  278. void __iomem *clk_base, void __iomem *pmc,
  279. unsigned long flags,
  280. struct tegra_clk_pll_params *pll_params,
  281. spinlock_t *lock);
  282. struct clk *tegra_clk_register_pllm(const char *name, const char *parent_name,
  283. void __iomem *clk_base, void __iomem *pmc,
  284. unsigned long flags,
  285. struct tegra_clk_pll_params *pll_params,
  286. spinlock_t *lock);
  287. struct clk *tegra_clk_register_pllc(const char *name, const char *parent_name,
  288. void __iomem *clk_base, void __iomem *pmc,
  289. unsigned long flags,
  290. struct tegra_clk_pll_params *pll_params,
  291. spinlock_t *lock);
  292. struct clk *tegra_clk_register_pllre(const char *name, const char *parent_name,
  293. void __iomem *clk_base, void __iomem *pmc,
  294. unsigned long flags,
  295. struct tegra_clk_pll_params *pll_params,
  296. spinlock_t *lock, unsigned long parent_rate);
  297. struct clk *tegra_clk_register_plle_tegra114(const char *name,
  298. const char *parent_name,
  299. void __iomem *clk_base, unsigned long flags,
  300. struct tegra_clk_pll_params *pll_params,
  301. spinlock_t *lock);
  302. struct clk *tegra_clk_register_pllss(const char *name, const char *parent_name,
  303. void __iomem *clk_base, unsigned long flags,
  304. struct tegra_clk_pll_params *pll_params,
  305. spinlock_t *lock);
  306. /**
  307. * struct tegra_clk_pll_out - PLL divider down clock
  308. *
  309. * @hw: handle between common and hardware-specific interfaces
  310. * @reg: register containing the PLL divider
  311. * @enb_bit_idx: bit to enable/disable PLL divider
  312. * @rst_bit_idx: bit to reset PLL divider
  313. * @lock: register lock
  314. * @flags: hardware-specific flags
  315. */
  316. struct tegra_clk_pll_out {
  317. struct clk_hw hw;
  318. void __iomem *reg;
  319. u8 enb_bit_idx;
  320. u8 rst_bit_idx;
  321. spinlock_t *lock;
  322. u8 flags;
  323. };
  324. #define to_clk_pll_out(_hw) container_of(_hw, struct tegra_clk_pll_out, hw)
  325. extern const struct clk_ops tegra_clk_pll_out_ops;
  326. struct clk *tegra_clk_register_pll_out(const char *name,
  327. const char *parent_name, void __iomem *reg, u8 enb_bit_idx,
  328. u8 rst_bit_idx, unsigned long flags, u8 pll_div_flags,
  329. spinlock_t *lock);
  330. /**
  331. * struct tegra_clk_periph_regs - Registers controlling peripheral clock
  332. *
  333. * @enb_reg: read the enable status
  334. * @enb_set_reg: write 1 to enable clock
  335. * @enb_clr_reg: write 1 to disable clock
  336. * @rst_reg: read the reset status
  337. * @rst_set_reg: write 1 to assert the reset of peripheral
  338. * @rst_clr_reg: write 1 to deassert the reset of peripheral
  339. */
  340. struct tegra_clk_periph_regs {
  341. u32 enb_reg;
  342. u32 enb_set_reg;
  343. u32 enb_clr_reg;
  344. u32 rst_reg;
  345. u32 rst_set_reg;
  346. u32 rst_clr_reg;
  347. };
  348. /**
  349. * struct tegra_clk_periph_gate - peripheral gate clock
  350. *
  351. * @magic: magic number to validate type
  352. * @hw: handle between common and hardware-specific interfaces
  353. * @clk_base: address of CAR controller
  354. * @regs: Registers to control the peripheral
  355. * @flags: hardware-specific flags
  356. * @clk_num: Clock number
  357. * @enable_refcnt: array to maintain reference count of the clock
  358. *
  359. * Flags:
  360. * TEGRA_PERIPH_NO_RESET - This flag indicates that reset is not allowed
  361. * for this module.
  362. * TEGRA_PERIPH_MANUAL_RESET - This flag indicates not to reset module
  363. * after clock enable and driver for the module is responsible for
  364. * doing reset.
  365. * TEGRA_PERIPH_ON_APB - If peripheral is in the APB bus then read the
  366. * bus to flush the write operation in apb bus. This flag indicates
  367. * that this peripheral is in apb bus.
  368. * TEGRA_PERIPH_WAR_1005168 - Apply workaround for Tegra114 MSENC bug
  369. */
  370. struct tegra_clk_periph_gate {
  371. u32 magic;
  372. struct clk_hw hw;
  373. void __iomem *clk_base;
  374. u8 flags;
  375. int clk_num;
  376. int *enable_refcnt;
  377. struct tegra_clk_periph_regs *regs;
  378. };
  379. #define to_clk_periph_gate(_hw) \
  380. container_of(_hw, struct tegra_clk_periph_gate, hw)
  381. #define TEGRA_CLK_PERIPH_GATE_MAGIC 0x17760309
  382. #define TEGRA_PERIPH_NO_RESET BIT(0)
  383. #define TEGRA_PERIPH_MANUAL_RESET BIT(1)
  384. #define TEGRA_PERIPH_ON_APB BIT(2)
  385. #define TEGRA_PERIPH_WAR_1005168 BIT(3)
  386. #define TEGRA_PERIPH_NO_DIV BIT(4)
  387. #define TEGRA_PERIPH_NO_GATE BIT(5)
  388. extern const struct clk_ops tegra_clk_periph_gate_ops;
  389. struct clk *tegra_clk_register_periph_gate(const char *name,
  390. const char *parent_name, u8 gate_flags, void __iomem *clk_base,
  391. unsigned long flags, int clk_num, int *enable_refcnt);
  392. /**
  393. * struct clk-periph - peripheral clock
  394. *
  395. * @magic: magic number to validate type
  396. * @hw: handle between common and hardware-specific interfaces
  397. * @mux: mux clock
  398. * @divider: divider clock
  399. * @gate: gate clock
  400. * @mux_ops: mux clock ops
  401. * @div_ops: divider clock ops
  402. * @gate_ops: gate clock ops
  403. */
  404. struct tegra_clk_periph {
  405. u32 magic;
  406. struct clk_hw hw;
  407. struct clk_mux mux;
  408. struct tegra_clk_frac_div divider;
  409. struct tegra_clk_periph_gate gate;
  410. const struct clk_ops *mux_ops;
  411. const struct clk_ops *div_ops;
  412. const struct clk_ops *gate_ops;
  413. };
  414. #define to_clk_periph(_hw) container_of(_hw, struct tegra_clk_periph, hw)
  415. #define TEGRA_CLK_PERIPH_MAGIC 0x18221223
  416. extern const struct clk_ops tegra_clk_periph_ops;
  417. struct clk *tegra_clk_register_periph(const char *name,
  418. const char **parent_names, int num_parents,
  419. struct tegra_clk_periph *periph, void __iomem *clk_base,
  420. u32 offset, unsigned long flags);
  421. struct clk *tegra_clk_register_periph_nodiv(const char *name,
  422. const char **parent_names, int num_parents,
  423. struct tegra_clk_periph *periph, void __iomem *clk_base,
  424. u32 offset);
  425. #define TEGRA_CLK_PERIPH(_mux_shift, _mux_mask, _mux_flags, \
  426. _div_shift, _div_width, _div_frac_width, \
  427. _div_flags, _clk_num,\
  428. _gate_flags, _table, _lock) \
  429. { \
  430. .mux = { \
  431. .flags = _mux_flags, \
  432. .shift = _mux_shift, \
  433. .mask = _mux_mask, \
  434. .table = _table, \
  435. .lock = _lock, \
  436. }, \
  437. .divider = { \
  438. .flags = _div_flags, \
  439. .shift = _div_shift, \
  440. .width = _div_width, \
  441. .frac_width = _div_frac_width, \
  442. .lock = _lock, \
  443. }, \
  444. .gate = { \
  445. .flags = _gate_flags, \
  446. .clk_num = _clk_num, \
  447. }, \
  448. .mux_ops = &clk_mux_ops, \
  449. .div_ops = &tegra_clk_frac_div_ops, \
  450. .gate_ops = &tegra_clk_periph_gate_ops, \
  451. }
  452. struct tegra_periph_init_data {
  453. const char *name;
  454. int clk_id;
  455. union {
  456. const char **parent_names;
  457. const char *parent_name;
  458. } p;
  459. int num_parents;
  460. struct tegra_clk_periph periph;
  461. u32 offset;
  462. const char *con_id;
  463. const char *dev_id;
  464. unsigned long flags;
  465. };
  466. #define TEGRA_INIT_DATA_TABLE(_name, _con_id, _dev_id, _parent_names, _offset,\
  467. _mux_shift, _mux_mask, _mux_flags, _div_shift, \
  468. _div_width, _div_frac_width, _div_flags, \
  469. _clk_num, _gate_flags, _clk_id, _table, \
  470. _flags, _lock) \
  471. { \
  472. .name = _name, \
  473. .clk_id = _clk_id, \
  474. .p.parent_names = _parent_names, \
  475. .num_parents = ARRAY_SIZE(_parent_names), \
  476. .periph = TEGRA_CLK_PERIPH(_mux_shift, _mux_mask, \
  477. _mux_flags, _div_shift, \
  478. _div_width, _div_frac_width, \
  479. _div_flags, _clk_num, \
  480. _gate_flags, _table, _lock), \
  481. .offset = _offset, \
  482. .con_id = _con_id, \
  483. .dev_id = _dev_id, \
  484. .flags = _flags \
  485. }
  486. #define TEGRA_INIT_DATA(_name, _con_id, _dev_id, _parent_names, _offset,\
  487. _mux_shift, _mux_width, _mux_flags, _div_shift, \
  488. _div_width, _div_frac_width, _div_flags, \
  489. _clk_num, _gate_flags, _clk_id) \
  490. TEGRA_INIT_DATA_TABLE(_name, _con_id, _dev_id, _parent_names, _offset,\
  491. _mux_shift, BIT(_mux_width) - 1, _mux_flags, \
  492. _div_shift, _div_width, _div_frac_width, _div_flags, \
  493. _clk_num, _gate_flags, _clk_id,\
  494. NULL, 0, NULL)
  495. /**
  496. * struct clk_super_mux - super clock
  497. *
  498. * @hw: handle between common and hardware-specific interfaces
  499. * @reg: register controlling multiplexer
  500. * @width: width of the multiplexer bit field
  501. * @flags: hardware-specific flags
  502. * @div2_index: bit controlling divide-by-2
  503. * @pllx_index: PLLX index in the parent list
  504. * @lock: register lock
  505. *
  506. * Flags:
  507. * TEGRA_DIVIDER_2 - LP cluster has additional divider. This flag indicates
  508. * that this is LP cluster clock.
  509. */
  510. struct tegra_clk_super_mux {
  511. struct clk_hw hw;
  512. void __iomem *reg;
  513. u8 width;
  514. u8 flags;
  515. u8 div2_index;
  516. u8 pllx_index;
  517. spinlock_t *lock;
  518. };
  519. #define to_clk_super_mux(_hw) container_of(_hw, struct tegra_clk_super_mux, hw)
  520. #define TEGRA_DIVIDER_2 BIT(0)
  521. extern const struct clk_ops tegra_clk_super_ops;
  522. struct clk *tegra_clk_register_super_mux(const char *name,
  523. const char **parent_names, u8 num_parents,
  524. unsigned long flags, void __iomem *reg, u8 clk_super_flags,
  525. u8 width, u8 pllx_index, u8 div2_index, spinlock_t *lock);
  526. /**
  527. * struct clk_init_table - clock initialization table
  528. * @clk_id: clock id as mentioned in device tree bindings
  529. * @parent_id: parent clock id as mentioned in device tree bindings
  530. * @rate: rate to set
  531. * @state: enable/disable
  532. */
  533. struct tegra_clk_init_table {
  534. unsigned int clk_id;
  535. unsigned int parent_id;
  536. unsigned long rate;
  537. int state;
  538. };
  539. /**
  540. * struct clk_duplicate - duplicate clocks
  541. * @clk_id: clock id as mentioned in device tree bindings
  542. * @lookup: duplicate lookup entry for the clock
  543. */
  544. struct tegra_clk_duplicate {
  545. int clk_id;
  546. struct clk_lookup lookup;
  547. };
  548. #define TEGRA_CLK_DUPLICATE(_clk_id, _dev, _con) \
  549. { \
  550. .clk_id = _clk_id, \
  551. .lookup = { \
  552. .dev_id = _dev, \
  553. .con_id = _con, \
  554. }, \
  555. }
  556. struct tegra_clk {
  557. int dt_id;
  558. bool present;
  559. };
  560. struct tegra_devclk {
  561. int dt_id;
  562. char *dev_id;
  563. char *con_id;
  564. };
  565. void tegra_init_special_resets(unsigned int num, int (*assert)(unsigned long),
  566. int (*deassert)(unsigned long));
  567. void tegra_init_from_table(struct tegra_clk_init_table *tbl,
  568. struct clk *clks[], int clk_max);
  569. void tegra_init_dup_clks(struct tegra_clk_duplicate *dup_list,
  570. struct clk *clks[], int clk_max);
  571. struct tegra_clk_periph_regs *get_reg_bank(int clkid);
  572. struct clk **tegra_clk_init(void __iomem *clk_base, int num, int periph_banks);
  573. struct clk **tegra_lookup_dt_id(int clk_id, struct tegra_clk *tegra_clk);
  574. void tegra_add_of_provider(struct device_node *np);
  575. void tegra_register_devclks(struct tegra_devclk *dev_clks, int num);
  576. void tegra_audio_clk_init(void __iomem *clk_base,
  577. void __iomem *pmc_base, struct tegra_clk *tegra_clks,
  578. struct tegra_audio_clk_info *audio_info,
  579. unsigned int num_plls);
  580. void tegra_periph_clk_init(void __iomem *clk_base, void __iomem *pmc_base,
  581. struct tegra_clk *tegra_clks,
  582. struct tegra_clk_pll_params *pll_params);
  583. void tegra_pmc_clk_init(void __iomem *pmc_base, struct tegra_clk *tegra_clks);
  584. void tegra_fixed_clk_init(struct tegra_clk *tegra_clks);
  585. int tegra_osc_clk_init(void __iomem *clk_base, struct tegra_clk *clks,
  586. unsigned long *input_freqs, unsigned int num,
  587. unsigned int clk_m_div, unsigned long *osc_freq,
  588. unsigned long *pll_ref_freq);
  589. void tegra_super_clk_gen4_init(void __iomem *clk_base,
  590. void __iomem *pmc_base, struct tegra_clk *tegra_clks,
  591. struct tegra_clk_pll_params *pll_params);
  592. #ifdef CONFIG_TEGRA_CLK_EMC
  593. struct clk *tegra_clk_register_emc(void __iomem *base, struct device_node *np,
  594. spinlock_t *lock);
  595. #else
  596. static inline struct clk *tegra_clk_register_emc(void __iomem *base,
  597. struct device_node *np,
  598. spinlock_t *lock)
  599. {
  600. return NULL;
  601. }
  602. #endif
  603. void tegra114_clock_tune_cpu_trimmers_high(void);
  604. void tegra114_clock_tune_cpu_trimmers_low(void);
  605. void tegra114_clock_tune_cpu_trimmers_init(void);
  606. void tegra114_clock_assert_dfll_dvco_reset(void);
  607. void tegra114_clock_deassert_dfll_dvco_reset(void);
  608. typedef void (*tegra_clk_apply_init_table_func)(void);
  609. extern tegra_clk_apply_init_table_func tegra_clk_apply_init_table;
  610. #endif /* TEGRA_CLK_H */