clock.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /*
  2. * TI C64X clock definitions
  3. *
  4. * Copyright (C) 2010, 2011 Texas Instruments.
  5. * Contributed by: Mark Salter <msalter@redhat.com>
  6. *
  7. * Copied heavily from arm/mach-davinci/clock.h, so:
  8. *
  9. * Copyright (C) 2006-2007 Texas Instruments.
  10. * Copyright (C) 2008-2009 Deep Root Systems, LLC
  11. *
  12. * This program is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License version 2 as
  14. * published by the Free Software Foundation.
  15. */
  16. #ifndef _ASM_C6X_CLOCK_H
  17. #define _ASM_C6X_CLOCK_H
  18. #ifndef __ASSEMBLER__
  19. #include <linux/list.h>
  20. /* PLL/Reset register offsets */
  21. #define PLLCTL 0x100
  22. #define PLLM 0x110
  23. #define PLLPRE 0x114
  24. #define PLLDIV1 0x118
  25. #define PLLDIV2 0x11c
  26. #define PLLDIV3 0x120
  27. #define PLLPOST 0x128
  28. #define PLLCMD 0x138
  29. #define PLLSTAT 0x13c
  30. #define PLLALNCTL 0x140
  31. #define PLLDCHANGE 0x144
  32. #define PLLCKEN 0x148
  33. #define PLLCKSTAT 0x14c
  34. #define PLLSYSTAT 0x150
  35. #define PLLDIV4 0x160
  36. #define PLLDIV5 0x164
  37. #define PLLDIV6 0x168
  38. #define PLLDIV7 0x16c
  39. #define PLLDIV8 0x170
  40. #define PLLDIV9 0x174
  41. #define PLLDIV10 0x178
  42. #define PLLDIV11 0x17c
  43. #define PLLDIV12 0x180
  44. #define PLLDIV13 0x184
  45. #define PLLDIV14 0x188
  46. #define PLLDIV15 0x18c
  47. #define PLLDIV16 0x190
  48. /* PLLM register bits */
  49. #define PLLM_PLLM_MASK 0xff
  50. #define PLLM_VAL(x) ((x) - 1)
  51. /* PREDIV register bits */
  52. #define PLLPREDIV_EN BIT(15)
  53. #define PLLPREDIV_VAL(x) ((x) - 1)
  54. /* PLLCTL register bits */
  55. #define PLLCTL_PLLEN BIT(0)
  56. #define PLLCTL_PLLPWRDN BIT(1)
  57. #define PLLCTL_PLLRST BIT(3)
  58. #define PLLCTL_PLLDIS BIT(4)
  59. #define PLLCTL_PLLENSRC BIT(5)
  60. #define PLLCTL_CLKMODE BIT(8)
  61. /* PLLCMD register bits */
  62. #define PLLCMD_GOSTAT BIT(0)
  63. /* PLLSTAT register bits */
  64. #define PLLSTAT_GOSTAT BIT(0)
  65. /* PLLDIV register bits */
  66. #define PLLDIV_EN BIT(15)
  67. #define PLLDIV_RATIO_MASK 0x1f
  68. #define PLLDIV_RATIO(x) ((x) - 1)
  69. struct pll_data;
  70. struct clk {
  71. struct list_head node;
  72. struct module *owner;
  73. const char *name;
  74. unsigned long rate;
  75. int usecount;
  76. u32 flags;
  77. struct clk *parent;
  78. struct list_head children; /* list of children */
  79. struct list_head childnode; /* parent's child list node */
  80. struct pll_data *pll_data;
  81. u32 div;
  82. unsigned long (*recalc) (struct clk *);
  83. int (*set_rate) (struct clk *clk, unsigned long rate);
  84. int (*round_rate) (struct clk *clk, unsigned long rate);
  85. };
  86. /* Clock flags: SoC-specific flags start at BIT(16) */
  87. #define ALWAYS_ENABLED BIT(1)
  88. #define CLK_PLL BIT(2) /* PLL-derived clock */
  89. #define PRE_PLL BIT(3) /* source is before PLL mult/div */
  90. #define FIXED_DIV_PLL BIT(4) /* fixed divisor from PLL */
  91. #define FIXED_RATE_PLL BIT(5) /* fixed output rate PLL */
  92. #define MAX_PLL_SYSCLKS 16
  93. struct pll_data {
  94. void __iomem *base;
  95. u32 num;
  96. u32 flags;
  97. u32 input_rate;
  98. u32 bypass_delay; /* in loops */
  99. u32 reset_delay; /* in loops */
  100. u32 lock_delay; /* in loops */
  101. struct clk sysclks[MAX_PLL_SYSCLKS + 1];
  102. };
  103. /* pll_data flag bit */
  104. #define PLL_HAS_PRE BIT(0)
  105. #define PLL_HAS_MUL BIT(1)
  106. #define PLL_HAS_POST BIT(2)
  107. #define CLK(dev, con, ck) \
  108. { \
  109. .dev_id = dev, \
  110. .con_id = con, \
  111. .clk = ck, \
  112. } \
  113. extern void c6x_clks_init(struct clk_lookup *clocks);
  114. extern int clk_register(struct clk *clk);
  115. extern void clk_unregister(struct clk *clk);
  116. extern void c64x_setup_clocks(void);
  117. extern struct pll_data c6x_soc_pll1;
  118. extern struct clk clkin1;
  119. extern struct clk c6x_core_clk;
  120. extern struct clk c6x_i2c_clk;
  121. extern struct clk c6x_watchdog_clk;
  122. extern struct clk c6x_mcbsp1_clk;
  123. extern struct clk c6x_mcbsp2_clk;
  124. extern struct clk c6x_mdio_clk;
  125. #endif
  126. #endif /* _ASM_C6X_CLOCK_H */