clock.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * linux/arch/arm/mach-omap1/clock.h
  4. *
  5. * Copyright (C) 2004 - 2005, 2009 Nokia corporation
  6. * Written by Tuukka Tikkanen <[email protected]>
  7. * Based on clocks.h by Tony Lindgren, Gordon McNutt and RidgeRun, Inc
  8. */
  9. #ifndef __ARCH_ARM_MACH_OMAP1_CLOCK_H
  10. #define __ARCH_ARM_MACH_OMAP1_CLOCK_H
  11. #include <linux/clk.h>
  12. #include <linux/clkdev.h>
  13. #include <linux/clk-provider.h>
  14. struct module;
  15. struct omap1_clk;
  16. struct omap_clk {
  17. u16 cpu;
  18. struct clk_lookup lk;
  19. };
  20. #define CLK(dev, con, ck, cp) \
  21. { \
  22. .cpu = cp, \
  23. .lk = { \
  24. .dev_id = dev, \
  25. .con_id = con, \
  26. .clk_hw = ck, \
  27. }, \
  28. }
  29. /* Platform flags for the clkdev-OMAP integration code */
  30. #define CK_310 (1 << 0)
  31. #define CK_7XX (1 << 1) /* 7xx, 850 */
  32. #define CK_1510 (1 << 2)
  33. #define CK_16XX (1 << 3) /* 16xx, 17xx, 5912 */
  34. #define CK_1710 (1 << 4) /* 1710 extra for rate selection */
  35. /**
  36. * struct clkops - some clock function pointers
  37. * @enable: fn ptr that enables the current clock in hardware
  38. * @disable: fn ptr that enables the current clock in hardware
  39. * @allow_idle: fn ptr that enables autoidle for the current clock in hardware
  40. */
  41. struct clkops {
  42. int (*enable)(struct omap1_clk *clk);
  43. void (*disable)(struct omap1_clk *clk);
  44. };
  45. /*
  46. * struct clk.flags possibilities
  47. *
  48. * XXX document the rest of the clock flags here
  49. */
  50. #define ENABLE_REG_32BIT (1 << 0) /* Use 32-bit access */
  51. #define CLOCK_IDLE_CONTROL (1 << 1)
  52. #define CLOCK_NO_IDLE_PARENT (1 << 2)
  53. /**
  54. * struct omap1_clk - OMAP1 struct clk
  55. * @hw: struct clk_hw for common clock framework integration
  56. * @ops: struct clkops * for this clock
  57. * @rate: current clock rate
  58. * @enable_reg: register to write to enable the clock (see @enable_bit)
  59. * @recalc: fn ptr that returns the clock's current rate
  60. * @set_rate: fn ptr that can change the clock's current rate
  61. * @round_rate: fn ptr that can round the clock's current rate
  62. * @init: fn ptr to do clock-specific initialization
  63. * @enable_bit: bitshift to write to enable/disable the clock (see @enable_reg)
  64. * @fixed_div: when > 0, this clock's rate is its parent's rate / @fixed_div
  65. * @flags: see "struct clk.flags possibilities" above
  66. * @rate_offset: bitshift for rate selection bitfield (OMAP1 only)
  67. */
  68. struct omap1_clk {
  69. struct clk_hw hw;
  70. const struct clkops *ops;
  71. unsigned long rate;
  72. void __iomem *enable_reg;
  73. unsigned long (*recalc)(struct omap1_clk *clk, unsigned long rate);
  74. int (*set_rate)(struct omap1_clk *clk, unsigned long rate,
  75. unsigned long p_rate);
  76. long (*round_rate)(struct omap1_clk *clk, unsigned long rate,
  77. unsigned long *p_rate);
  78. int (*init)(struct omap1_clk *clk);
  79. u8 enable_bit;
  80. u8 fixed_div;
  81. u8 flags;
  82. u8 rate_offset;
  83. };
  84. #define to_omap1_clk(_hw) container_of(_hw, struct omap1_clk, hw)
  85. void propagate_rate(struct omap1_clk *clk);
  86. unsigned long followparent_recalc(struct omap1_clk *clk, unsigned long p_rate);
  87. unsigned long omap_fixed_divisor_recalc(struct omap1_clk *clk, unsigned long p_rate);
  88. extern struct omap1_clk dummy_ck;
  89. int omap1_clk_init(void);
  90. void omap1_clk_late_init(void);
  91. unsigned long omap1_ckctl_recalc(struct omap1_clk *clk, unsigned long p_rate);
  92. long omap1_round_sossi_rate(struct omap1_clk *clk, unsigned long rate, unsigned long *p_rate);
  93. int omap1_set_sossi_rate(struct omap1_clk *clk, unsigned long rate, unsigned long p_rate);
  94. unsigned long omap1_sossi_recalc(struct omap1_clk *clk, unsigned long p_rate);
  95. unsigned long omap1_ckctl_recalc_dsp_domain(struct omap1_clk *clk, unsigned long p_rate);
  96. int omap1_clk_set_rate_dsp_domain(struct omap1_clk *clk, unsigned long rate,
  97. unsigned long p_rate);
  98. long omap1_round_uart_rate(struct omap1_clk *clk, unsigned long rate, unsigned long *p_rate);
  99. int omap1_set_uart_rate(struct omap1_clk *clk, unsigned long rate, unsigned long p_rate);
  100. unsigned long omap1_uart_recalc(struct omap1_clk *clk, unsigned long p_rate);
  101. int omap1_set_ext_clk_rate(struct omap1_clk *clk, unsigned long rate, unsigned long p_rate);
  102. long omap1_round_ext_clk_rate(struct omap1_clk *clk, unsigned long rate, unsigned long *p_rate);
  103. int omap1_init_ext_clk(struct omap1_clk *clk);
  104. int omap1_select_table_rate(struct omap1_clk *clk, unsigned long rate, unsigned long p_rate);
  105. long omap1_round_to_table_rate(struct omap1_clk *clk, unsigned long rate, unsigned long *p_rate);
  106. int omap1_clk_set_rate_ckctl_arm(struct omap1_clk *clk, unsigned long rate, unsigned long p_rate);
  107. long omap1_clk_round_rate_ckctl_arm(struct omap1_clk *clk, unsigned long rate,
  108. unsigned long *p_rate);
  109. struct uart_clk {
  110. struct omap1_clk clk;
  111. unsigned long sysc_addr;
  112. };
  113. /* Provide a method for preventing idling some ARM IDLECT clocks */
  114. struct arm_idlect1_clk {
  115. struct omap1_clk clk;
  116. unsigned long no_idle_count;
  117. __u8 idlect_shift;
  118. };
  119. /* ARM_CKCTL bit shifts */
  120. #define CKCTL_PERDIV_OFFSET 0
  121. #define CKCTL_LCDDIV_OFFSET 2
  122. #define CKCTL_ARMDIV_OFFSET 4
  123. #define CKCTL_DSPDIV_OFFSET 6
  124. #define CKCTL_TCDIV_OFFSET 8
  125. #define CKCTL_DSPMMUDIV_OFFSET 10
  126. /*#define ARM_TIMXO 12*/
  127. #define EN_DSPCK 13
  128. /*#define ARM_INTHCK_SEL 14*/ /* Divide-by-2 for mpu inth_ck */
  129. /* DSP_CKCTL bit shifts */
  130. #define CKCTL_DSPPERDIV_OFFSET 0
  131. /* ARM_IDLECT2 bit shifts */
  132. #define EN_WDTCK 0
  133. #define EN_XORPCK 1
  134. #define EN_PERCK 2
  135. #define EN_LCDCK 3
  136. #define EN_LBCK 4 /* Not on 1610/1710 */
  137. /*#define EN_HSABCK 5*/
  138. #define EN_APICK 6
  139. #define EN_TIMCK 7
  140. #define DMACK_REQ 8
  141. #define EN_GPIOCK 9 /* Not on 1610/1710 */
  142. /*#define EN_LBFREECK 10*/
  143. #define EN_CKOUT_ARM 11
  144. /* ARM_IDLECT3 bit shifts */
  145. #define EN_OCPI_CK 0
  146. #define EN_TC1_CK 2
  147. #define EN_TC2_CK 4
  148. /* DSP_IDLECT2 bit shifts (0,1,2 are same as for ARM_IDLECT2) */
  149. #define EN_DSPTIMCK 5
  150. /* Various register defines for clock controls scattered around OMAP chip */
  151. #define SDW_MCLK_INV_BIT 2 /* In ULPD_CLKC_CTRL */
  152. #define USB_MCLK_EN_BIT 4 /* In ULPD_CLKC_CTRL */
  153. #define USB_HOST_HHC_UHOST_EN 9 /* In MOD_CONF_CTRL_0 */
  154. #define SWD_ULPD_PLL_CLK_REQ 1 /* In SWD_CLK_DIV_CTRL_SEL */
  155. #define COM_ULPD_PLL_CLK_REQ 1 /* In COM_CLK_DIV_CTRL_SEL */
  156. #define SWD_CLK_DIV_CTRL_SEL 0xfffe0874
  157. #define COM_CLK_DIV_CTRL_SEL 0xfffe0878
  158. #define SOFT_REQ_REG 0xfffe0834
  159. #define SOFT_REQ_REG2 0xfffe0880
  160. extern __u32 arm_idlect1_mask;
  161. extern struct omap1_clk *api_ck_p, *ck_dpll1_p, *ck_ref_p;
  162. extern const struct clkops clkops_dspck;
  163. extern const struct clkops clkops_uart_16xx;
  164. extern const struct clkops clkops_generic;
  165. /* used for passing SoC type to omap1_{select,round_to}_table_rate() */
  166. extern u32 cpu_mask;
  167. extern const struct clk_ops omap1_clk_null_ops;
  168. extern const struct clk_ops omap1_clk_gate_ops;
  169. extern const struct clk_ops omap1_clk_rate_ops;
  170. extern const struct clk_ops omap1_clk_full_ops;
  171. #endif