clk-factors.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __MACH_SUNXI_CLK_FACTORS_H
  3. #define __MACH_SUNXI_CLK_FACTORS_H
  4. #include <linux/clk-provider.h>
  5. #include <linux/spinlock.h>
  6. #define SUNXI_FACTORS_NOT_APPLICABLE (0)
  7. struct clk_factors_config {
  8. u8 nshift;
  9. u8 nwidth;
  10. u8 kshift;
  11. u8 kwidth;
  12. u8 mshift;
  13. u8 mwidth;
  14. u8 pshift;
  15. u8 pwidth;
  16. u8 n_start;
  17. };
  18. struct factors_request {
  19. unsigned long rate;
  20. unsigned long parent_rate;
  21. u8 parent_index;
  22. u8 n;
  23. u8 k;
  24. u8 m;
  25. u8 p;
  26. };
  27. struct factors_data {
  28. int enable;
  29. int mux;
  30. int muxmask;
  31. const struct clk_factors_config *table;
  32. void (*getter)(struct factors_request *req);
  33. void (*recalc)(struct factors_request *req);
  34. const char *name;
  35. };
  36. struct clk_factors {
  37. struct clk_hw hw;
  38. void __iomem *reg;
  39. const struct clk_factors_config *config;
  40. void (*get_factors)(struct factors_request *req);
  41. void (*recalc)(struct factors_request *req);
  42. spinlock_t *lock;
  43. /* for cleanup */
  44. struct clk_mux *mux;
  45. struct clk_gate *gate;
  46. };
  47. struct clk *sunxi_factors_register(struct device_node *node,
  48. const struct factors_data *data,
  49. spinlock_t *lock,
  50. void __iomem *reg);
  51. struct clk *sunxi_factors_register_critical(struct device_node *node,
  52. const struct factors_data *data,
  53. spinlock_t *lock,
  54. void __iomem *reg);
  55. void sunxi_factors_unregister(struct device_node *node, struct clk *clk);
  56. #endif