clock.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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/clkdev.h>
  22. #include <linux/list.h>
  23. #include <linux/spinlock.h>
  24. #include <mach/clk.h>
  25. #define DIV_BUS (1 << 0)
  26. #define DIV_U71 (1 << 1)
  27. #define DIV_U71_FIXED (1 << 2)
  28. #define DIV_2 (1 << 3)
  29. #define DIV_U16 (1 << 4)
  30. #define PLL_FIXED (1 << 5)
  31. #define PLL_HAS_CPCON (1 << 6)
  32. #define MUX (1 << 7)
  33. #define PLLD (1 << 8)
  34. #define PERIPH_NO_RESET (1 << 9)
  35. #define PERIPH_NO_ENB (1 << 10)
  36. #define PERIPH_EMC_ENB (1 << 11)
  37. #define PERIPH_MANUAL_RESET (1 << 12)
  38. #define PLL_ALT_MISC_REG (1 << 13)
  39. #define PLLU (1 << 14)
  40. #define PLLX (1 << 15)
  41. #define MUX_PWM (1 << 16)
  42. #define MUX8 (1 << 17)
  43. #define DIV_U71_UART (1 << 18)
  44. #define MUX_CLK_OUT (1 << 19)
  45. #define PLLM (1 << 20)
  46. #define DIV_U71_INT (1 << 21)
  47. #define DIV_U71_IDLE (1 << 22)
  48. #define ENABLE_ON_INIT (1 << 28)
  49. #define PERIPH_ON_APB (1 << 29)
  50. struct clk;
  51. struct clk_mux_sel {
  52. struct clk *input;
  53. u32 value;
  54. };
  55. struct clk_pll_freq_table {
  56. unsigned long input_rate;
  57. unsigned long output_rate;
  58. u16 n;
  59. u16 m;
  60. u8 p;
  61. u8 cpcon;
  62. };
  63. struct clk_ops {
  64. void (*init)(struct clk *);
  65. int (*enable)(struct clk *);
  66. void (*disable)(struct clk *);
  67. int (*set_parent)(struct clk *, struct clk *);
  68. int (*set_rate)(struct clk *, unsigned long);
  69. long (*round_rate)(struct clk *, unsigned long);
  70. void (*reset)(struct clk *, bool);
  71. int (*clk_cfg_ex)(struct clk *,
  72. enum tegra_clk_ex_param, u32);
  73. };
  74. enum clk_state {
  75. UNINITIALIZED = 0,
  76. ON,
  77. OFF,
  78. };
  79. struct clk {
  80. /* node for master clocks list */
  81. struct list_head node; /* node for list of all clocks */
  82. struct clk_lookup lookup;
  83. #ifdef CONFIG_DEBUG_FS
  84. struct dentry *dent;
  85. #endif
  86. bool set;
  87. struct clk_ops *ops;
  88. unsigned long rate;
  89. unsigned long max_rate;
  90. unsigned long min_rate;
  91. u32 flags;
  92. const char *name;
  93. u32 refcnt;
  94. enum clk_state state;
  95. struct clk *parent;
  96. u32 div;
  97. u32 mul;
  98. const struct clk_mux_sel *inputs;
  99. u32 reg;
  100. u32 reg_shift;
  101. struct list_head shared_bus_list;
  102. union {
  103. struct {
  104. unsigned int clk_num;
  105. } periph;
  106. struct {
  107. unsigned long input_min;
  108. unsigned long input_max;
  109. unsigned long cf_min;
  110. unsigned long cf_max;
  111. unsigned long vco_min;
  112. unsigned long vco_max;
  113. const struct clk_pll_freq_table *freq_table;
  114. int lock_delay;
  115. unsigned long fixed_rate;
  116. } pll;
  117. struct {
  118. u32 sel;
  119. u32 reg_mask;
  120. } mux;
  121. struct {
  122. struct clk *main;
  123. struct clk *backup;
  124. } cpu;
  125. struct {
  126. struct list_head node;
  127. bool enabled;
  128. unsigned long rate;
  129. } shared_bus_user;
  130. } u;
  131. spinlock_t spinlock;
  132. };
  133. struct clk_duplicate {
  134. const char *name;
  135. struct clk_lookup lookup;
  136. };
  137. struct tegra_clk_init_table {
  138. const char *name;
  139. const char *parent;
  140. unsigned long rate;
  141. bool enabled;
  142. };
  143. void tegra2_init_clocks(void);
  144. void tegra30_init_clocks(void);
  145. void clk_init(struct clk *clk);
  146. struct clk *tegra_get_clock_by_name(const char *name);
  147. int clk_reparent(struct clk *c, struct clk *parent);
  148. void tegra_clk_init_from_table(struct tegra_clk_init_table *table);
  149. unsigned long clk_get_rate_locked(struct clk *c);
  150. int clk_set_rate_locked(struct clk *c, unsigned long rate);
  151. #endif