clock.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /*
  2. * arch/arm/mach-tegra/include/mach/clock.h
  3. *
  4. * Copyright (C) 2010 Google, Inc.
  5. * Copyright (c) 2012 NVIDIA CORPORATION. All rights reserved.
  6. *
  7. * Author:
  8. * Colin Cross <ccross@google.com>
  9. *
  10. * This software is licensed under the terms of the GNU General Public
  11. * License version 2, as published by the Free Software Foundation, and
  12. * may be copied, distributed, and modified under those terms.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. */
  20. #ifndef __MACH_TEGRA_CLOCK_H
  21. #define __MACH_TEGRA_CLOCK_H
  22. #include <linux/clk-provider.h>
  23. #include <linux/clkdev.h>
  24. #include <linux/list.h>
  25. #include <mach/clk.h>
  26. #define DIV_BUS (1 << 0)
  27. #define DIV_U71 (1 << 1)
  28. #define DIV_U71_FIXED (1 << 2)
  29. #define DIV_2 (1 << 3)
  30. #define DIV_U16 (1 << 4)
  31. #define PLL_FIXED (1 << 5)
  32. #define PLL_HAS_CPCON (1 << 6)
  33. #define MUX (1 << 7)
  34. #define PLLD (1 << 8)
  35. #define PERIPH_NO_RESET (1 << 9)
  36. #define PERIPH_NO_ENB (1 << 10)
  37. #define PERIPH_EMC_ENB (1 << 11)
  38. #define PERIPH_MANUAL_RESET (1 << 12)
  39. #define PLL_ALT_MISC_REG (1 << 13)
  40. #define PLLU (1 << 14)
  41. #define PLLX (1 << 15)
  42. #define MUX_PWM (1 << 16)
  43. #define MUX8 (1 << 17)
  44. #define DIV_U71_UART (1 << 18)
  45. #define MUX_CLK_OUT (1 << 19)
  46. #define PLLM (1 << 20)
  47. #define DIV_U71_INT (1 << 21)
  48. #define DIV_U71_IDLE (1 << 22)
  49. #define ENABLE_ON_INIT (1 << 28)
  50. #define PERIPH_ON_APB (1 << 29)
  51. struct clk_tegra;
  52. #define to_clk_tegra(_hw) container_of(_hw, struct clk_tegra, hw)
  53. struct clk_mux_sel {
  54. struct clk *input;
  55. u32 value;
  56. };
  57. struct clk_pll_freq_table {
  58. unsigned long input_rate;
  59. unsigned long output_rate;
  60. u16 n;
  61. u16 m;
  62. u8 p;
  63. u8 cpcon;
  64. };
  65. enum clk_state {
  66. UNINITIALIZED = 0,
  67. ON,
  68. OFF,
  69. };
  70. struct clk_tegra {
  71. /* node for master clocks list */
  72. struct list_head node; /* node for list of all clocks */
  73. struct clk_lookup lookup;
  74. struct clk_hw hw;
  75. bool set;
  76. unsigned long fixed_rate;
  77. unsigned long max_rate;
  78. unsigned long min_rate;
  79. u32 flags;
  80. const char *name;
  81. enum clk_state state;
  82. u32 div;
  83. u32 mul;
  84. u32 reg;
  85. u32 reg_shift;
  86. struct list_head shared_bus_list;
  87. union {
  88. struct {
  89. unsigned int clk_num;
  90. } periph;
  91. struct {
  92. unsigned long input_min;
  93. unsigned long input_max;
  94. unsigned long cf_min;
  95. unsigned long cf_max;
  96. unsigned long vco_min;
  97. unsigned long vco_max;
  98. const struct clk_pll_freq_table *freq_table;
  99. int lock_delay;
  100. unsigned long fixed_rate;
  101. } pll;
  102. struct {
  103. u32 sel;
  104. u32 reg_mask;
  105. } mux;
  106. struct {
  107. struct clk *main;
  108. struct clk *backup;
  109. } cpu;
  110. struct {
  111. struct list_head node;
  112. bool enabled;
  113. unsigned long rate;
  114. } shared_bus_user;
  115. } u;
  116. void (*reset)(struct clk_hw *, bool);
  117. int (*clk_cfg_ex)(struct clk_hw *, enum tegra_clk_ex_param, u32);
  118. };
  119. struct clk_duplicate {
  120. const char *name;
  121. struct clk_lookup lookup;
  122. };
  123. struct tegra_clk_init_table {
  124. const char *name;
  125. const char *parent;
  126. unsigned long rate;
  127. bool enabled;
  128. };
  129. void tegra_clk_add(struct clk *c);
  130. void tegra2_init_clocks(void);
  131. void tegra30_init_clocks(void);
  132. struct clk *tegra_get_clock_by_name(const char *name);
  133. void tegra_clk_init_from_table(struct tegra_clk_init_table *table);
  134. #endif