clock.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * This program is free software; you can redistribute it and/or modify
  3. * it under the terms of the GNU General Public License version 2 as
  4. * published by the Free Software Foundation.
  5. */
  6. #include <linux/clkdev.h>
  7. struct clkops {
  8. void (*enable)(struct clk *);
  9. void (*disable)(struct clk *);
  10. unsigned long (*getrate)(struct clk *);
  11. int (*setrate)(struct clk *, unsigned long);
  12. };
  13. struct clk {
  14. const struct clkops *ops;
  15. void __iomem *clk_rst; /* clock reset control register */
  16. int fnclksel; /* functional clock select (APBC) */
  17. uint32_t enable_val; /* value for clock enable (APMU) */
  18. unsigned long rate;
  19. int enabled;
  20. };
  21. extern struct clkops apbc_clk_ops;
  22. extern struct clkops apmu_clk_ops;
  23. #define APBC_CLK(_name, _reg, _fnclksel, _rate) \
  24. struct clk clk_##_name = { \
  25. .clk_rst = APBC_##_reg, \
  26. .fnclksel = _fnclksel, \
  27. .rate = _rate, \
  28. .ops = &apbc_clk_ops, \
  29. }
  30. #define APBC_CLK_OPS(_name, _reg, _fnclksel, _rate, _ops) \
  31. struct clk clk_##_name = { \
  32. .clk_rst = APBC_##_reg, \
  33. .fnclksel = _fnclksel, \
  34. .rate = _rate, \
  35. .ops = _ops, \
  36. }
  37. #define APMU_CLK(_name, _reg, _eval, _rate) \
  38. struct clk clk_##_name = { \
  39. .clk_rst = APMU_##_reg, \
  40. .enable_val = _eval, \
  41. .rate = _rate, \
  42. .ops = &apmu_clk_ops, \
  43. }
  44. #define APMU_CLK_OPS(_name, _reg, _eval, _rate, _ops) \
  45. struct clk clk_##_name = { \
  46. .clk_rst = APMU_##_reg, \
  47. .enable_val = _eval, \
  48. .rate = _rate, \
  49. .ops = _ops, \
  50. }
  51. #define INIT_CLKREG(_clk, _devname, _conname) \
  52. { \
  53. .clk = _clk, \
  54. .dev_id = _devname, \
  55. .con_id = _conname, \
  56. }
  57. extern struct clk clk_pxa168_gpio;
  58. extern struct clk clk_pxa168_timers;