clk-pxa.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*
  2. * Marvell PXA family clocks
  3. *
  4. * Copyright (C) 2014 Robert Jarzmik
  5. *
  6. * Common clock code for PXA clocks ("CKEN" type clocks + DT)
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; version 2 of the License.
  11. *
  12. */
  13. #ifndef _CLK_PXA_
  14. #define _CLK_PXA_
  15. #define PARENTS(name) \
  16. static const char *const name ## _parents[] __initconst
  17. #define MUX_RO_RATE_RO_OPS(name, clk_name) \
  18. static struct clk_hw name ## _mux_hw; \
  19. static struct clk_hw name ## _rate_hw; \
  20. static struct clk_ops name ## _mux_ops = { \
  21. .get_parent = name ## _get_parent, \
  22. .set_parent = dummy_clk_set_parent, \
  23. }; \
  24. static struct clk_ops name ## _rate_ops = { \
  25. .recalc_rate = name ## _get_rate, \
  26. }; \
  27. static struct clk * __init clk_register_ ## name(void) \
  28. { \
  29. return clk_register_composite(NULL, clk_name, \
  30. name ## _parents, \
  31. ARRAY_SIZE(name ## _parents), \
  32. &name ## _mux_hw, &name ## _mux_ops, \
  33. &name ## _rate_hw, &name ## _rate_ops, \
  34. NULL, NULL, CLK_GET_RATE_NOCACHE); \
  35. }
  36. #define RATE_RO_OPS(name, clk_name) \
  37. static struct clk_hw name ## _rate_hw; \
  38. static struct clk_ops name ## _rate_ops = { \
  39. .recalc_rate = name ## _get_rate, \
  40. }; \
  41. static struct clk * __init clk_register_ ## name(void) \
  42. { \
  43. return clk_register_composite(NULL, clk_name, \
  44. name ## _parents, \
  45. ARRAY_SIZE(name ## _parents), \
  46. NULL, NULL, \
  47. &name ## _rate_hw, &name ## _rate_ops, \
  48. NULL, NULL, CLK_GET_RATE_NOCACHE); \
  49. }
  50. /*
  51. * CKEN clock type
  52. * This clock takes it source from 2 possible parents :
  53. * - a low power parent
  54. * - a normal parent
  55. *
  56. * +------------+ +-----------+
  57. * | Low Power | --- | x mult_lp |
  58. * | Clock | | / div_lp |\
  59. * +------------+ +-----------+ \+-----+ +-----------+
  60. * | Mux |---| CKEN gate |
  61. * +------------+ +-----------+ /+-----+ +-----------+
  62. * | High Power | | x mult_hp |/
  63. * | Clock | --- | / div_hp |
  64. * +------------+ +-----------+
  65. */
  66. struct desc_clk_cken {
  67. struct clk_hw hw;
  68. int ckid;
  69. const char *name;
  70. const char *dev_id;
  71. const char *con_id;
  72. const char * const *parent_names;
  73. struct clk_fixed_factor lp;
  74. struct clk_fixed_factor hp;
  75. struct clk_gate gate;
  76. bool (*is_in_low_power)(void);
  77. const unsigned long flags;
  78. };
  79. #define PXA_CKEN(_dev_id, _con_id, _name, parents, _mult_lp, _div_lp, \
  80. _mult_hp, _div_hp, is_lp, _cken_reg, _cken_bit, flag) \
  81. { .ckid = CLK_ ## _name, .name = #_name, \
  82. .dev_id = _dev_id, .con_id = _con_id, .parent_names = parents,\
  83. .lp = { .mult = _mult_lp, .div = _div_lp }, \
  84. .hp = { .mult = _mult_hp, .div = _div_hp }, \
  85. .is_in_low_power = is_lp, \
  86. .gate = { .reg = (void __iomem *)_cken_reg, .bit_idx = _cken_bit }, \
  87. .flags = flag, \
  88. }
  89. #define PXA_CKEN_1RATE(dev_id, con_id, name, parents, cken_reg, \
  90. cken_bit, flag) \
  91. PXA_CKEN(dev_id, con_id, name, parents, 1, 1, 1, 1, \
  92. NULL, cken_reg, cken_bit, flag)
  93. static int dummy_clk_set_parent(struct clk_hw *hw, u8 index)
  94. {
  95. return 0;
  96. }
  97. extern void clkdev_pxa_register(int ckid, const char *con_id,
  98. const char *dev_id, struct clk *clk);
  99. extern int clk_pxa_cken_init(const struct desc_clk_cken *clks, int nb_clks);
  100. void clk_pxa_dt_common_init(struct device_node *np);
  101. #endif