clk-factors.h 1.1 KB

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