gdsc.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * Copyright (c) 2015, The Linux Foundation. All rights reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 and
  6. * only version 2 as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. */
  13. #ifndef __QCOM_GDSC_H__
  14. #define __QCOM_GDSC_H__
  15. #include <linux/err.h>
  16. #include <linux/pm_domain.h>
  17. struct regmap;
  18. struct reset_controller_dev;
  19. /**
  20. * struct gdsc - Globally Distributed Switch Controller
  21. * @pd: generic power domain
  22. * @regmap: regmap for MMIO accesses
  23. * @gdscr: gsdc control register
  24. * @gds_hw_ctrl: gds_hw_ctrl register
  25. * @cxcs: offsets of branch registers to toggle mem/periph bits in
  26. * @cxc_count: number of @cxcs
  27. * @pwrsts: Possible powerdomain power states
  28. * @resets: ids of resets associated with this gdsc
  29. * @reset_count: number of @resets
  30. * @rcdev: reset controller
  31. */
  32. struct gdsc {
  33. struct generic_pm_domain pd;
  34. struct generic_pm_domain *parent;
  35. struct regmap *regmap;
  36. unsigned int gdscr;
  37. unsigned int gds_hw_ctrl;
  38. unsigned int *cxcs;
  39. unsigned int cxc_count;
  40. const u8 pwrsts;
  41. /* Powerdomain allowable state bitfields */
  42. #define PWRSTS_OFF BIT(0)
  43. #define PWRSTS_RET BIT(1)
  44. #define PWRSTS_ON BIT(2)
  45. #define PWRSTS_OFF_ON (PWRSTS_OFF | PWRSTS_ON)
  46. #define PWRSTS_RET_ON (PWRSTS_RET | PWRSTS_ON)
  47. const u8 flags;
  48. #define VOTABLE BIT(0)
  49. struct reset_controller_dev *rcdev;
  50. unsigned int *resets;
  51. unsigned int reset_count;
  52. };
  53. struct gdsc_desc {
  54. struct device *dev;
  55. struct gdsc **scs;
  56. size_t num;
  57. };
  58. #ifdef CONFIG_QCOM_GDSC
  59. int gdsc_register(struct gdsc_desc *desc, struct reset_controller_dev *,
  60. struct regmap *);
  61. void gdsc_unregister(struct gdsc_desc *desc);
  62. #else
  63. static inline int gdsc_register(struct gdsc_desc *desc,
  64. struct reset_controller_dev *rcdev,
  65. struct regmap *r)
  66. {
  67. return -ENOSYS;
  68. }
  69. static inline void gdsc_unregister(struct gdsc_desc *desc) {};
  70. #endif /* CONFIG_QCOM_GDSC */
  71. #endif /* __QCOM_GDSC_H__ */