clocks.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * Common Clock definitions for various kernel files
  3. *
  4. * Copyright 2007-2008 Analog Devices Inc.
  5. *
  6. * Licensed under the GPL-2 or later.
  7. */
  8. #ifndef _BFIN_CLOCKS_H
  9. #define _BFIN_CLOCKS_H
  10. #include <asm/dpmc.h>
  11. #ifdef CONFIG_CCLK_DIV_1
  12. # define CONFIG_CCLK_ACT_DIV CCLK_DIV1
  13. # define CONFIG_CCLK_DIV 1
  14. #endif
  15. #ifdef CONFIG_CCLK_DIV_2
  16. # define CONFIG_CCLK_ACT_DIV CCLK_DIV2
  17. # define CONFIG_CCLK_DIV 2
  18. #endif
  19. #ifdef CONFIG_CCLK_DIV_4
  20. # define CONFIG_CCLK_ACT_DIV CCLK_DIV4
  21. # define CONFIG_CCLK_DIV 4
  22. #endif
  23. #ifdef CONFIG_CCLK_DIV_8
  24. # define CONFIG_CCLK_ACT_DIV CCLK_DIV8
  25. # define CONFIG_CCLK_DIV 8
  26. #endif
  27. #ifndef CONFIG_PLL_BYPASS
  28. # ifndef CONFIG_CLKIN_HALF
  29. # define CONFIG_VCO_HZ (CONFIG_CLKIN_HZ * CONFIG_VCO_MULT)
  30. # else
  31. # define CONFIG_VCO_HZ ((CONFIG_CLKIN_HZ * CONFIG_VCO_MULT)/2)
  32. # endif
  33. # define CONFIG_CCLK_HZ (CONFIG_VCO_HZ/CONFIG_CCLK_DIV)
  34. # define CONFIG_SCLK_HZ (CONFIG_VCO_HZ/CONFIG_SCLK_DIV)
  35. #else
  36. # define CONFIG_VCO_HZ (CONFIG_CLKIN_HZ)
  37. # define CONFIG_CCLK_HZ (CONFIG_CLKIN_HZ)
  38. # define CONFIG_SCLK_HZ (CONFIG_CLKIN_HZ)
  39. # define CONFIG_VCO_MULT 0
  40. #endif
  41. #include <linux/clk.h>
  42. struct clk_ops {
  43. unsigned long (*get_rate)(struct clk *clk);
  44. unsigned long (*round_rate)(struct clk *clk, unsigned long rate);
  45. int (*set_rate)(struct clk *clk, unsigned long rate);
  46. int (*enable)(struct clk *clk);
  47. int (*disable)(struct clk *clk);
  48. };
  49. struct clk {
  50. struct clk *parent;
  51. const char *name;
  52. unsigned long rate;
  53. spinlock_t lock;
  54. u32 flags;
  55. const struct clk_ops *ops;
  56. void __iomem *reg;
  57. u32 mask;
  58. u32 shift;
  59. };
  60. int clk_init(void);
  61. #endif