sandbox-clk.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * Copyright (C) 2019
  4. * Lukasz Majewski, DENX Software Engineering, lukma@denx.de
  5. */
  6. #ifndef __SANDBOX_CLK_H__
  7. #define __SANDBOX_CLK_H__
  8. #include <linux/clk-provider.h>
  9. enum {
  10. SANDBOX_CLK_PLL2 = 1,
  11. SANDBOX_CLK_PLL3,
  12. SANDBOX_CLK_PLL3_60M,
  13. SANDBOX_CLK_PLL3_80M,
  14. SANDBOX_CLK_ECSPI_ROOT,
  15. SANDBOX_CLK_ECSPI0,
  16. SANDBOX_CLK_ECSPI1,
  17. SANDBOX_CLK_USDHC1_SEL,
  18. SANDBOX_CLK_USDHC2_SEL,
  19. SANDBOX_CLK_I2C,
  20. SANDBOX_CLK_I2C_ROOT,
  21. };
  22. enum sandbox_pllv3_type {
  23. SANDBOX_PLLV3_GENERIC,
  24. SANDBOX_PLLV3_USB,
  25. };
  26. struct clk *sandbox_clk_pllv3(enum sandbox_pllv3_type type, const char *name,
  27. const char *parent_name, void __iomem *base,
  28. u32 div_mask);
  29. static inline struct clk *sandbox_clk_fixed_factor(const char *name,
  30. const char *parent,
  31. unsigned int mult,
  32. unsigned int div)
  33. {
  34. return clk_register_fixed_factor(NULL, name, parent,
  35. CLK_SET_RATE_PARENT, mult, div);
  36. }
  37. static inline struct clk *sandbox_clk_divider(const char *name,
  38. const char *parent,
  39. void __iomem *reg, u8 shift,
  40. u8 width)
  41. {
  42. return clk_register_divider(NULL, name, parent, CLK_SET_RATE_PARENT,
  43. reg, shift, width, 0);
  44. }
  45. struct clk *sandbox_clk_register_gate2(struct device *dev, const char *name,
  46. const char *parent_name,
  47. unsigned long flags,
  48. void __iomem *reg, u8 bit_idx,
  49. u8 cgr_val, u8 clk_gate_flags);
  50. static inline struct clk *sandbox_clk_gate2(const char *name,
  51. const char *parent,
  52. void __iomem *reg, u8 shift)
  53. {
  54. return sandbox_clk_register_gate2(NULL, name, parent,
  55. CLK_SET_RATE_PARENT, reg, shift,
  56. 0x3, 0);
  57. }
  58. static inline struct clk *sandbox_clk_mux(const char *name, void __iomem *reg,
  59. u8 shift, u8 width,
  60. const char * const *parents,
  61. int num_parents)
  62. {
  63. return clk_register_mux(NULL, name, parents, num_parents,
  64. CLK_SET_RATE_NO_REPARENT, reg, shift,
  65. width, 0);
  66. }
  67. int sandbox_clk_enable_count(struct clk *clk);
  68. #endif /* __SANDBOX_CLK_H__ */