berlin2-div.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * Copyright (c) 2014 Marvell Technology Group Ltd.
  3. *
  4. * Alexandre Belloni <alexandre.belloni@free-electrons.com>
  5. * Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms and conditions of the GNU General Public License,
  9. * version 2, as published by the Free Software Foundation.
  10. *
  11. * This program is distributed in the hope it will be useful, but WITHOUT
  12. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  14. * more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along with
  17. * this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #ifndef __BERLIN2_DIV_H
  20. #define __BERLIN2_DIV_H
  21. struct clk_hw;
  22. #define BERLIN2_DIV_HAS_GATE BIT(0)
  23. #define BERLIN2_DIV_HAS_MUX BIT(1)
  24. #define BERLIN2_PLL_SELECT(_off, _sh) \
  25. .pll_select_offs = _off, \
  26. .pll_select_shift = _sh
  27. #define BERLIN2_PLL_SWITCH(_off, _sh) \
  28. .pll_switch_offs = _off, \
  29. .pll_switch_shift = _sh
  30. #define BERLIN2_DIV_SELECT(_off, _sh) \
  31. .div_select_offs = _off, \
  32. .div_select_shift = _sh
  33. #define BERLIN2_DIV_SWITCH(_off, _sh) \
  34. .div_switch_offs = _off, \
  35. .div_switch_shift = _sh
  36. #define BERLIN2_DIV_D3SWITCH(_off, _sh) \
  37. .div3_switch_offs = _off, \
  38. .div3_switch_shift = _sh
  39. #define BERLIN2_DIV_GATE(_off, _sh) \
  40. .gate_offs = _off, \
  41. .gate_shift = _sh
  42. #define BERLIN2_SINGLE_DIV(_off) \
  43. BERLIN2_DIV_GATE(_off, 0), \
  44. BERLIN2_PLL_SELECT(_off, 1), \
  45. BERLIN2_PLL_SWITCH(_off, 4), \
  46. BERLIN2_DIV_SWITCH(_off, 5), \
  47. BERLIN2_DIV_D3SWITCH(_off, 6), \
  48. BERLIN2_DIV_SELECT(_off, 7)
  49. struct berlin2_div_map {
  50. u16 pll_select_offs;
  51. u16 pll_switch_offs;
  52. u16 div_select_offs;
  53. u16 div_switch_offs;
  54. u16 div3_switch_offs;
  55. u16 gate_offs;
  56. u8 pll_select_shift;
  57. u8 pll_switch_shift;
  58. u8 div_select_shift;
  59. u8 div_switch_shift;
  60. u8 div3_switch_shift;
  61. u8 gate_shift;
  62. };
  63. struct berlin2_div_data {
  64. const char *name;
  65. const u8 *parent_ids;
  66. int num_parents;
  67. unsigned long flags;
  68. struct berlin2_div_map map;
  69. u8 div_flags;
  70. };
  71. struct clk_hw *
  72. berlin2_div_register(const struct berlin2_div_map *map,
  73. void __iomem *base, const char *name, u8 div_flags,
  74. const char **parent_names, int num_parents,
  75. unsigned long flags, spinlock_t *lock);
  76. #endif /* __BERLIN2_DIV_H */