clock.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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. #define DIV_BUS (1 << 0)
  25. #define DIV_U71 (1 << 1)
  26. #define DIV_U71_FIXED (1 << 2)
  27. #define DIV_2 (1 << 3)
  28. #define DIV_U16 (1 << 4)
  29. #define PLL_FIXED (1 << 5)
  30. #define PLL_HAS_CPCON (1 << 6)
  31. #define MUX (1 << 7)
  32. #define PLLD (1 << 8)
  33. #define PERIPH_NO_RESET (1 << 9)
  34. #define PERIPH_NO_ENB (1 << 10)
  35. #define PERIPH_EMC_ENB (1 << 11)
  36. #define PERIPH_MANUAL_RESET (1 << 12)
  37. #define PLL_ALT_MISC_REG (1 << 13)
  38. #define PLLU (1 << 14)
  39. #define ENABLE_ON_INIT (1 << 28)
  40. struct clk;
  41. struct clk_mux_sel {
  42. struct clk *input;
  43. u32 value;
  44. };
  45. struct clk_pll_freq_table {
  46. unsigned long input_rate;
  47. unsigned long output_rate;
  48. u16 n;
  49. u16 m;
  50. u8 p;
  51. u8 cpcon;
  52. };
  53. struct clk_ops {
  54. void (*init)(struct clk *);
  55. int (*enable)(struct clk *);
  56. void (*disable)(struct clk *);
  57. int (*set_parent)(struct clk *, struct clk *);
  58. int (*set_rate)(struct clk *, unsigned long);
  59. long (*round_rate)(struct clk *, unsigned long);
  60. void (*reset)(struct clk *, bool);
  61. };
  62. enum clk_state {
  63. UNINITIALIZED = 0,
  64. ON,
  65. OFF,
  66. };
  67. struct clk {
  68. /* node for master clocks list */
  69. struct list_head node; /* node for list of all clocks */
  70. struct clk_lookup lookup;
  71. #ifdef CONFIG_DEBUG_FS
  72. struct dentry *dent;
  73. #endif
  74. bool set;
  75. struct clk_ops *ops;
  76. unsigned long rate;
  77. unsigned long max_rate;
  78. unsigned long min_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. struct list_head shared_bus_list;
  90. union {
  91. struct {
  92. unsigned int clk_num;
  93. } periph;
  94. struct {
  95. unsigned long input_min;
  96. unsigned long input_max;
  97. unsigned long cf_min;
  98. unsigned long cf_max;
  99. unsigned long vco_min;
  100. unsigned long vco_max;
  101. const struct clk_pll_freq_table *freq_table;
  102. int lock_delay;
  103. } pll;
  104. struct {
  105. u32 sel;
  106. u32 reg_mask;
  107. } mux;
  108. struct {
  109. struct clk *main;
  110. struct clk *backup;
  111. } cpu;
  112. struct {
  113. struct list_head node;
  114. bool enabled;
  115. unsigned long rate;
  116. } shared_bus_user;
  117. } u;
  118. spinlock_t spinlock;
  119. };
  120. struct clk_duplicate {
  121. const char *name;
  122. struct clk_lookup lookup;
  123. };
  124. struct tegra_clk_init_table {
  125. const char *name;
  126. const char *parent;
  127. unsigned long rate;
  128. bool enabled;
  129. };
  130. void tegra2_init_clocks(void);
  131. void tegra2_periph_reset_deassert(struct clk *c);
  132. void tegra2_periph_reset_assert(struct clk *c);
  133. void clk_init(struct clk *clk);
  134. struct clk *tegra_get_clock_by_name(const char *name);
  135. unsigned long clk_measure_input_freq(void);
  136. int clk_reparent(struct clk *c, struct clk *parent);
  137. void tegra_clk_init_from_table(struct tegra_clk_init_table *table);
  138. unsigned long clk_get_rate_locked(struct clk *c);
  139. int clk_set_rate_locked(struct clk *c, unsigned long rate);
  140. void tegra2_sdmmc_tap_delay(struct clk *c, int delay);
  141. #endif