clock.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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 clk_mux_sel {
  41. struct clk *input;
  42. u32 value;
  43. };
  44. struct clk_pll_freq_table {
  45. unsigned long input_rate;
  46. unsigned long output_rate;
  47. u16 n;
  48. u16 m;
  49. u8 p;
  50. u8 cpcon;
  51. };
  52. struct clk_ops {
  53. void (*init)(struct clk *);
  54. int (*enable)(struct clk *);
  55. void (*disable)(struct clk *);
  56. int (*set_parent)(struct clk *, struct clk *);
  57. int (*set_rate)(struct clk *, unsigned long);
  58. long (*round_rate)(struct clk *, unsigned long);
  59. void (*reset)(struct clk *, bool);
  60. };
  61. enum clk_state {
  62. UNINITIALIZED = 0,
  63. ON,
  64. OFF,
  65. };
  66. struct clk {
  67. /* node for master clocks list */
  68. struct list_head node; /* node for list of all clocks */
  69. struct list_head children; /* list of children */
  70. struct list_head sibling; /* node for children */
  71. struct clk_lookup lookup;
  72. #ifdef CONFIG_DEBUG_FS
  73. struct dentry *dent;
  74. bool set;
  75. #endif
  76. struct clk_ops *ops;
  77. unsigned long rate;
  78. unsigned long max_rate;
  79. u32 flags;
  80. const char *name;
  81. u32 refcnt;
  82. enum clk_state state;
  83. struct clk *parent;
  84. u32 div;
  85. u32 mul;
  86. const struct clk_mux_sel *inputs;
  87. u32 reg;
  88. u32 reg_shift;
  89. union {
  90. struct {
  91. unsigned int clk_num;
  92. } periph;
  93. struct {
  94. unsigned long input_min;
  95. unsigned long input_max;
  96. unsigned long cf_min;
  97. unsigned long cf_max;
  98. unsigned long vco_min;
  99. unsigned long vco_max;
  100. const struct clk_pll_freq_table *freq_table;
  101. int lock_delay;
  102. } pll;
  103. struct {
  104. u32 sel;
  105. u32 reg_mask;
  106. } mux;
  107. struct {
  108. struct clk *main;
  109. struct clk *backup;
  110. } cpu;
  111. } u;
  112. };
  113. struct clk_duplicate {
  114. const char *name;
  115. struct clk_lookup lookup;
  116. };
  117. struct tegra_clk_init_table {
  118. const char *name;
  119. const char *parent;
  120. unsigned long rate;
  121. bool enabled;
  122. };
  123. void tegra2_init_clocks(void);
  124. void tegra2_periph_reset_deassert(struct clk *c);
  125. void tegra2_periph_reset_assert(struct clk *c);
  126. void clk_init(struct clk *clk);
  127. struct clk *tegra_get_clock_by_name(const char *name);
  128. unsigned long clk_measure_input_freq(void);
  129. void clk_disable_locked(struct clk *c);
  130. int clk_enable_locked(struct clk *c);
  131. int clk_set_parent_locked(struct clk *c, struct clk *parent);
  132. int clk_set_rate_locked(struct clk *c, unsigned long rate);
  133. int clk_reparent(struct clk *c, struct clk *parent);
  134. void tegra_clk_init_from_table(struct tegra_clk_init_table *table);
  135. #endif