clock.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. #include <linux/list.h>
  14. #include <asm/clkdev.h>
  15. #define DAVINCI_PLL1_BASE 0x01c40800
  16. #define DAVINCI_PLL2_BASE 0x01c40c00
  17. #define MAX_PLL 2
  18. /* PLL/Reset register offsets */
  19. #define PLLCTL 0x100
  20. #define PLLCTL_PLLEN BIT(0)
  21. #define PLLCTL_PLLPWRDN BIT(1)
  22. #define PLLCTL_PLLRST BIT(3)
  23. #define PLLCTL_PLLDIS BIT(4)
  24. #define PLLCTL_PLLENSRC BIT(5)
  25. #define PLLCTL_CLKMODE BIT(8)
  26. #define PLLM 0x110
  27. #define PLLM_PLLM_MASK 0xff
  28. #define PREDIV 0x114
  29. #define PLLDIV1 0x118
  30. #define PLLDIV2 0x11c
  31. #define PLLDIV3 0x120
  32. #define POSTDIV 0x128
  33. #define BPDIV 0x12c
  34. #define PLLCMD 0x138
  35. #define PLLSTAT 0x13c
  36. #define PLLALNCTL 0x140
  37. #define PLLDCHANGE 0x144
  38. #define PLLCKEN 0x148
  39. #define PLLCKSTAT 0x14c
  40. #define PLLSYSTAT 0x150
  41. #define PLLDIV4 0x160
  42. #define PLLDIV5 0x164
  43. #define PLLDIV6 0x168
  44. #define PLLDIV7 0x16c
  45. #define PLLDIV8 0x170
  46. #define PLLDIV9 0x174
  47. #define PLLDIV_EN BIT(15)
  48. #define PLLDIV_RATIO_MASK 0x1f
  49. struct pll_data {
  50. u32 phys_base;
  51. void __iomem *base;
  52. u32 num;
  53. u32 flags;
  54. u32 input_rate;
  55. };
  56. #define PLL_HAS_PREDIV 0x01
  57. #define PLL_HAS_POSTDIV 0x02
  58. struct clk {
  59. struct list_head node;
  60. struct module *owner;
  61. const char *name;
  62. unsigned long rate;
  63. u8 usecount;
  64. u8 lpsc;
  65. u8 gpsc;
  66. u32 flags;
  67. struct clk *parent;
  68. struct list_head children; /* list of children */
  69. struct list_head childnode; /* parent's child list node */
  70. struct pll_data *pll_data;
  71. u32 div_reg;
  72. unsigned long (*recalc) (struct clk *);
  73. int (*set_rate) (struct clk *clk, unsigned long rate);
  74. int (*round_rate) (struct clk *clk, unsigned long rate);
  75. };
  76. /* Clock flags: SoC-specific flags start at BIT(16) */
  77. #define ALWAYS_ENABLED BIT(1)
  78. #define CLK_PSC BIT(2)
  79. #define PSC_DSP BIT(3) /* PSC uses DSP domain, not ARM */
  80. #define CLK_PLL BIT(4) /* PLL-derived clock */
  81. #define PRE_PLL BIT(5) /* source is before PLL mult/div */
  82. struct davinci_clk {
  83. struct clk_lookup lk;
  84. };
  85. #define CLK(dev, con, ck) \
  86. { \
  87. .lk = { \
  88. .dev_id = dev, \
  89. .con_id = con, \
  90. .clk = ck, \
  91. }, \
  92. }
  93. int davinci_clk_init(struct davinci_clk *clocks);
  94. int davinci_set_pllrate(struct pll_data *pll, unsigned int prediv,
  95. unsigned int mult, unsigned int postdiv);
  96. extern struct platform_device davinci_wdt_device;
  97. #endif