clock.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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 <asm/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 PLL_FIXED (1 << 4)
  28. #define PLL_HAS_CPCON (1 << 5)
  29. #define MUX (1 << 6)
  30. #define PLLD (1 << 7)
  31. #define PERIPH_NO_RESET (1 << 8)
  32. #define PERIPH_NO_ENB (1 << 9)
  33. #define PERIPH_EMC_ENB (1 << 10)
  34. #define PERIPH_MANUAL_RESET (1 << 11)
  35. #define PLL_ALT_MISC_REG (1 << 12)
  36. #define ENABLE_ON_INIT (1 << 28)
  37. struct clk;
  38. struct clk_mux_sel {
  39. struct clk *input;
  40. u32 value;
  41. };
  42. struct clk_pll_table {
  43. unsigned long input_rate;
  44. unsigned long output_rate;
  45. u16 n;
  46. u16 m;
  47. u8 p;
  48. u8 cpcon;
  49. };
  50. struct clk_ops {
  51. void (*init)(struct clk *);
  52. int (*enable)(struct clk *);
  53. void (*disable)(struct clk *);
  54. void (*recalc)(struct clk *);
  55. int (*set_parent)(struct clk *, struct clk *);
  56. int (*set_rate)(struct clk *, unsigned long);
  57. unsigned long (*get_rate)(struct clk *);
  58. long (*round_rate)(struct clk *, unsigned long);
  59. unsigned long (*recalculate_rate)(struct clk *);
  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;
  69. struct list_head children; /* list of children */
  70. struct list_head sibling; /* node for children */
  71. #ifdef CONFIG_DEBUG_FS
  72. struct dentry *dent;
  73. struct dentry *parent_dent;
  74. #endif
  75. struct clk_ops *ops;
  76. struct clk *parent;
  77. struct clk_lookup lookup;
  78. unsigned long rate;
  79. u32 flags;
  80. u32 refcnt;
  81. const char *name;
  82. u32 reg;
  83. u32 reg_shift;
  84. unsigned int clk_num;
  85. enum clk_state state;
  86. #ifdef CONFIG_DEBUG_FS
  87. bool set;
  88. #endif
  89. /* PLL */
  90. unsigned long input_min;
  91. unsigned long input_max;
  92. unsigned long cf_min;
  93. unsigned long cf_max;
  94. unsigned long vco_min;
  95. unsigned long vco_max;
  96. u32 m;
  97. u32 n;
  98. u32 p;
  99. u32 cpcon;
  100. const struct clk_pll_table *pll_table;
  101. /* DIV */
  102. u32 div;
  103. u32 mul;
  104. /* MUX */
  105. const struct clk_mux_sel *inputs;
  106. u32 sel;
  107. u32 reg_mask;
  108. };
  109. struct clk_duplicate {
  110. const char *name;
  111. struct clk_lookup lookup;
  112. };
  113. struct tegra_clk_init_table {
  114. const char *name;
  115. const char *parent;
  116. unsigned long rate;
  117. bool enabled;
  118. };
  119. void tegra2_init_clocks(void);
  120. void tegra2_periph_reset_deassert(struct clk *c);
  121. void tegra2_periph_reset_assert(struct clk *c);
  122. void clk_init(struct clk *clk);
  123. struct clk *tegra_get_clock_by_name(const char *name);
  124. unsigned long clk_measure_input_freq(void);
  125. void clk_disable_locked(struct clk *c);
  126. int clk_enable_locked(struct clk *c);
  127. int clk_set_parent_locked(struct clk *c, struct clk *parent);
  128. int clk_reparent(struct clk *c, struct clk *parent);
  129. void tegra_clk_init_from_table(struct tegra_clk_init_table *table);
  130. #endif