clock.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. /*
  2. * arch/arm/mach-tegra/include/mach/clock.h
  3. *
  4. * Copyright (C) 2010 Google, Inc.
  5. *
  6. * Author:
  7. * Colin Cross <ccross@google.com>
  8. *
  9. * This software is licensed under the terms of the GNU General Public
  10. * License version 2, as published by the Free Software Foundation, and
  11. * may be copied, distributed, and modified under those terms.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. */
  19. #ifndef __MACH_TEGRA_CLOCK_H
  20. #define __MACH_TEGRA_CLOCK_H
  21. #include <linux/list.h>
  22. #include <linux/clkdev.h>
  23. #define DIV_BUS (1 << 0)
  24. #define DIV_U71 (1 << 1)
  25. #define DIV_U71_FIXED (1 << 2)
  26. #define DIV_2 (1 << 3)
  27. #define DIV_U16 (1 << 4)
  28. #define PLL_FIXED (1 << 5)
  29. #define PLL_HAS_CPCON (1 << 6)
  30. #define MUX (1 << 7)
  31. #define PLLD (1 << 8)
  32. #define PERIPH_NO_RESET (1 << 9)
  33. #define PERIPH_NO_ENB (1 << 10)
  34. #define PERIPH_EMC_ENB (1 << 11)
  35. #define PERIPH_MANUAL_RESET (1 << 12)
  36. #define PLL_ALT_MISC_REG (1 << 13)
  37. #define PLLU (1 << 14)
  38. #define ENABLE_ON_INIT (1 << 28)
  39. struct clk;
  40. struct regulator;
  41. struct dvfs_table {
  42. unsigned long rate;
  43. int millivolts;
  44. };
  45. struct dvfs_process_id_table {
  46. int process_id;
  47. struct dvfs_table *table;
  48. };
  49. struct dvfs {
  50. struct regulator *reg;
  51. struct dvfs_table *table;
  52. int max_millivolts;
  53. int process_id_table_length;
  54. const char *reg_id;
  55. bool cpu;
  56. struct dvfs_process_id_table process_id_table[];
  57. };
  58. struct clk_mux_sel {
  59. struct clk *input;
  60. u32 value;
  61. };
  62. struct clk_pll_table {
  63. unsigned long input_rate;
  64. unsigned long output_rate;
  65. u16 n;
  66. u16 m;
  67. u8 p;
  68. u8 cpcon;
  69. };
  70. struct clk_ops {
  71. void (*init)(struct clk *);
  72. int (*enable)(struct clk *);
  73. void (*disable)(struct clk *);
  74. int (*set_parent)(struct clk *, struct clk *);
  75. int (*set_rate)(struct clk *, unsigned long);
  76. long (*round_rate)(struct clk *, unsigned long);
  77. };
  78. enum clk_state {
  79. UNINITIALIZED = 0,
  80. ON,
  81. OFF,
  82. };
  83. struct clk {
  84. /* node for master clocks list */
  85. struct list_head node;
  86. struct list_head children; /* list of children */
  87. struct list_head sibling; /* node for children */
  88. #ifdef CONFIG_DEBUG_FS
  89. struct dentry *dent;
  90. struct dentry *parent_dent;
  91. #endif
  92. struct clk_ops *ops;
  93. struct clk *parent;
  94. struct clk_lookup lookup;
  95. unsigned long rate;
  96. unsigned long max_rate;
  97. u32 flags;
  98. u32 refcnt;
  99. const char *name;
  100. u32 reg;
  101. u32 reg_shift;
  102. unsigned int clk_num;
  103. enum clk_state state;
  104. #ifdef CONFIG_DEBUG_FS
  105. bool set;
  106. #endif
  107. /* PLL */
  108. unsigned long input_min;
  109. unsigned long input_max;
  110. unsigned long cf_min;
  111. unsigned long cf_max;
  112. unsigned long vco_min;
  113. unsigned long vco_max;
  114. const struct clk_pll_table *pll_table;
  115. /* DIV */
  116. u32 div;
  117. u32 mul;
  118. /* MUX */
  119. const struct clk_mux_sel *inputs;
  120. u32 sel;
  121. u32 reg_mask;
  122. /* Virtual cpu clock */
  123. struct clk *main;
  124. struct clk *backup;
  125. struct dvfs *dvfs;
  126. };
  127. struct clk_duplicate {
  128. const char *name;
  129. struct clk_lookup lookup;
  130. };
  131. struct tegra_clk_init_table {
  132. const char *name;
  133. const char *parent;
  134. unsigned long rate;
  135. bool enabled;
  136. };
  137. void tegra2_init_clocks(void);
  138. void tegra2_periph_reset_deassert(struct clk *c);
  139. void tegra2_periph_reset_assert(struct clk *c);
  140. void clk_init(struct clk *clk);
  141. struct clk *tegra_get_clock_by_name(const char *name);
  142. unsigned long clk_measure_input_freq(void);
  143. void clk_disable_locked(struct clk *c);
  144. int clk_enable_locked(struct clk *c);
  145. int clk_set_parent_locked(struct clk *c, struct clk *parent);
  146. int clk_set_rate_locked(struct clk *c, unsigned long rate);
  147. int clk_reparent(struct clk *c, struct clk *parent);
  148. void tegra_clk_init_from_table(struct tegra_clk_init_table *table);
  149. #endif