clock.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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 <asm/clkdev.h>
  64. struct pll_data {
  65. u32 phys_base;
  66. void __iomem *base;
  67. u32 num;
  68. u32 flags;
  69. u32 input_rate;
  70. u32 div_ratio_mask;
  71. };
  72. #define PLL_HAS_PREDIV 0x01
  73. #define PLL_HAS_POSTDIV 0x02
  74. struct clk {
  75. struct list_head node;
  76. struct module *owner;
  77. const char *name;
  78. unsigned long rate;
  79. u8 usecount;
  80. u8 lpsc;
  81. u8 gpsc;
  82. u32 flags;
  83. struct clk *parent;
  84. struct list_head children; /* list of children */
  85. struct list_head childnode; /* parent's child list node */
  86. struct pll_data *pll_data;
  87. u32 div_reg;
  88. unsigned long (*recalc) (struct clk *);
  89. int (*set_rate) (struct clk *clk, unsigned long rate);
  90. int (*round_rate) (struct clk *clk, unsigned long rate);
  91. };
  92. /* Clock flags: SoC-specific flags start at BIT(16) */
  93. #define ALWAYS_ENABLED BIT(1)
  94. #define CLK_PSC BIT(2)
  95. #define PSC_DSP BIT(3) /* PSC uses DSP domain, not ARM */
  96. #define CLK_PLL BIT(4) /* PLL-derived clock */
  97. #define PRE_PLL BIT(5) /* source is before PLL mult/div */
  98. #define PSC_SWRSTDISABLE BIT(6) /* Disable state is SwRstDisable */
  99. #define CLK(dev, con, ck) \
  100. { \
  101. .dev_id = dev, \
  102. .con_id = con, \
  103. .clk = ck, \
  104. } \
  105. int davinci_clk_init(struct clk_lookup *clocks);
  106. int davinci_set_pllrate(struct pll_data *pll, unsigned int prediv,
  107. unsigned int mult, unsigned int postdiv);
  108. extern struct platform_device davinci_wdt_device;
  109. extern void davinci_watchdog_reset(struct platform_device *);
  110. #endif
  111. #endif