clk-aspeed.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * Structures used by ASPEED clock drivers
  4. *
  5. * Copyright 2019 IBM Corp.
  6. */
  7. #include <linux/clk-provider.h>
  8. #include <linux/kernel.h>
  9. #include <linux/reset-controller.h>
  10. #include <linux/spinlock.h>
  11. struct clk_div_table;
  12. struct regmap;
  13. /**
  14. * struct aspeed_gate_data - Aspeed gated clocks
  15. * @clock_idx: bit used to gate this clock in the clock register
  16. * @reset_idx: bit used to reset this IP in the reset register. -1 if no
  17. * reset is required when enabling the clock
  18. * @name: the clock name
  19. * @parent_name: the name of the parent clock
  20. * @flags: standard clock framework flags
  21. */
  22. struct aspeed_gate_data {
  23. u8 clock_idx;
  24. s8 reset_idx;
  25. const char *name;
  26. const char *parent_name;
  27. unsigned long flags;
  28. };
  29. /**
  30. * struct aspeed_clk_gate - Aspeed specific clk_gate structure
  31. * @hw: handle between common and hardware-specific interfaces
  32. * @reg: register controlling gate
  33. * @clock_idx: bit used to gate this clock in the clock register
  34. * @reset_idx: bit used to reset this IP in the reset register. -1 if no
  35. * reset is required when enabling the clock
  36. * @flags: hardware-specific flags
  37. * @lock: register lock
  38. *
  39. * Some of the clocks in the Aspeed SoC must be put in reset before enabling.
  40. * This modified version of clk_gate allows an optional reset bit to be
  41. * specified.
  42. */
  43. struct aspeed_clk_gate {
  44. struct clk_hw hw;
  45. struct regmap *map;
  46. u8 clock_idx;
  47. s8 reset_idx;
  48. u8 flags;
  49. spinlock_t *lock;
  50. };
  51. #define to_aspeed_clk_gate(_hw) container_of(_hw, struct aspeed_clk_gate, hw)
  52. /**
  53. * struct aspeed_reset - Aspeed reset controller
  54. * @map: regmap to access the containing system controller
  55. * @rcdev: reset controller device
  56. */
  57. struct aspeed_reset {
  58. struct regmap *map;
  59. struct reset_controller_dev rcdev;
  60. };
  61. #define to_aspeed_reset(p) container_of((p), struct aspeed_reset, rcdev)
  62. /**
  63. * struct aspeed_clk_soc_data - Aspeed SoC specific divisor information
  64. * @div_table: Common divider lookup table
  65. * @eclk_div_table: Divider lookup table for ECLK
  66. * @mac_div_table: Divider lookup table for MAC (Ethernet) clocks
  67. * @calc_pll: Callback to maculate common PLL settings
  68. */
  69. struct aspeed_clk_soc_data {
  70. const struct clk_div_table *div_table;
  71. const struct clk_div_table *eclk_div_table;
  72. const struct clk_div_table *mac_div_table;
  73. struct clk_hw *(*calc_pll)(const char *name, u32 val);
  74. };