clock.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. /*
  2. * TI DaVinci clock definitions
  3. *
  4. * Copyright (C) 2006-2007 Texas Instruments.
  5. * Copyright (C) 2008-2009 Deep Root Systems, LLC
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. */
  11. #ifndef __ARCH_ARM_DAVINCI_CLOCK_H
  12. #define __ARCH_ARM_DAVINCI_CLOCK_H
  13. #define DAVINCI_PLL1_BASE 0x01c40800
  14. #define DAVINCI_PLL2_BASE 0x01c40c00
  15. #define MAX_PLL 2
  16. /* PLL/Reset register offsets */
  17. #define PLLCTL 0x100
  18. #define PLLCTL_PLLEN BIT(0)
  19. #define PLLCTL_PLLPWRDN BIT(1)
  20. #define PLLCTL_PLLRST BIT(3)
  21. #define PLLCTL_PLLDIS BIT(4)
  22. #define PLLCTL_PLLENSRC BIT(5)
  23. #define PLLCTL_CLKMODE BIT(8)
  24. #define PLLM 0x110
  25. #define PLLM_PLLM_MASK 0xff
  26. #define PREDIV 0x114
  27. #define PLLDIV1 0x118
  28. #define PLLDIV2 0x11c
  29. #define PLLDIV3 0x120
  30. #define POSTDIV 0x128
  31. #define BPDIV 0x12c
  32. #define PLLCMD 0x138
  33. #define PLLSTAT 0x13c
  34. #define PLLALNCTL 0x140
  35. #define PLLDCHANGE 0x144
  36. #define PLLCKEN 0x148
  37. #define PLLCKSTAT 0x14c
  38. #define PLLSYSTAT 0x150
  39. #define PLLDIV4 0x160
  40. #define PLLDIV5 0x164
  41. #define PLLDIV6 0x168
  42. #define PLLDIV7 0x16c
  43. #define PLLDIV8 0x170
  44. #define PLLDIV9 0x174
  45. #define PLLDIV_EN BIT(15)
  46. #define PLLDIV_RATIO_MASK 0x1f
  47. /*
  48. * OMAP-L138 system reference guide recommends a wait for 4 OSCIN/CLKIN
  49. * cycles to ensure that the PLLC has switched to bypass mode. Delay of 1us
  50. * ensures we are good for all > 4MHz OSCIN/CLKIN inputs. Typically the input
  51. * is ~25MHz. Units are micro seconds.
  52. */
  53. #define PLL_BYPASS_TIME 1
  54. /* From OMAP-L138 datasheet table 6-4. Units are micro seconds */
  55. #define PLL_RESET_TIME 1
  56. /*
  57. * From OMAP-L138 datasheet table 6-4; assuming prediv = 1, sqrt(pllm) = 4
  58. * Units are micro seconds.
  59. */
  60. #define PLL_LOCK_TIME 20
  61. #ifndef __ASSEMBLER__
  62. #include <linux/list.h>
  63. #include <linux/clkdev.h>
  64. #define PLLSTAT_GOSTAT BIT(0)
  65. #define PLLCMD_GOSET BIT(0)
  66. struct pll_data {
  67. u32 phys_base;
  68. void __iomem *base;
  69. u32 num;
  70. u32 flags;
  71. u32 input_rate;
  72. u32 div_ratio_mask;
  73. };
  74. #define PLL_HAS_PREDIV 0x01
  75. #define PLL_HAS_POSTDIV 0x02
  76. struct clk {
  77. struct list_head node;
  78. struct module *owner;
  79. const char *name;
  80. unsigned long rate;
  81. unsigned long maxrate; /* H/W supported max rate */
  82. u8 usecount;
  83. u8 lpsc;
  84. u8 gpsc;
  85. u8 domain;
  86. u32 flags;
  87. struct clk *parent;
  88. struct list_head children; /* list of children */
  89. struct list_head childnode; /* parent's child list node */
  90. struct pll_data *pll_data;
  91. u32 div_reg;
  92. unsigned long (*recalc) (struct clk *);
  93. int (*set_rate) (struct clk *clk, unsigned long rate);
  94. int (*round_rate) (struct clk *clk, unsigned long rate);
  95. int (*reset) (struct clk *clk, bool reset);
  96. void (*clk_enable) (struct clk *clk);
  97. void (*clk_disable) (struct clk *clk);
  98. int (*set_parent) (struct clk *clk, struct clk *parent);
  99. };
  100. /* Clock flags: SoC-specific flags start at BIT(16) */
  101. #define ALWAYS_ENABLED BIT(1)
  102. #define CLK_PSC BIT(2)
  103. #define CLK_PLL BIT(3) /* PLL-derived clock */
  104. #define PRE_PLL BIT(4) /* source is before PLL mult/div */
  105. #define PSC_SWRSTDISABLE BIT(5) /* Disable state is SwRstDisable */
  106. #define PSC_FORCE BIT(6) /* Force module state transtition */
  107. #define PSC_LRST BIT(8) /* Use local reset on enable/disable */
  108. #define CLK(dev, con, ck) \
  109. { \
  110. .dev_id = dev, \
  111. .con_id = con, \
  112. .clk = ck, \
  113. } \
  114. int davinci_clk_init(struct clk_lookup *clocks);
  115. int davinci_set_pllrate(struct pll_data *pll, unsigned int prediv,
  116. unsigned int mult, unsigned int postdiv);
  117. int davinci_set_sysclk_rate(struct clk *clk, unsigned long rate);
  118. int davinci_set_refclk_rate(unsigned long rate);
  119. int davinci_simple_set_rate(struct clk *clk, unsigned long rate);
  120. int davinci_clk_reset(struct clk *clk, bool reset);
  121. extern struct platform_device davinci_wdt_device;
  122. extern void davinci_watchdog_reset(struct platform_device *);
  123. #endif
  124. #endif