gdsc.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. /* Powerdomain allowable state bitfields */
  20. #define PWRSTS_OFF BIT(0)
  21. #define PWRSTS_RET BIT(1)
  22. #define PWRSTS_ON BIT(2)
  23. #define PWRSTS_OFF_ON (PWRSTS_OFF | PWRSTS_ON)
  24. #define PWRSTS_RET_ON (PWRSTS_RET | PWRSTS_ON)
  25. /**
  26. * struct gdsc - Globally Distributed Switch Controller
  27. * @pd: generic power domain
  28. * @regmap: regmap for MMIO accesses
  29. * @gdscr: gsdc control register
  30. * @cxcs: offsets of branch registers to toggle mem/periph bits in
  31. * @cxc_count: number of @cxcs
  32. * @pwrsts: Possible powerdomain power states
  33. * @resets: ids of resets associated with this gdsc
  34. * @reset_count: number of @resets
  35. * @rcdev: reset controller
  36. */
  37. struct gdsc {
  38. struct generic_pm_domain pd;
  39. struct regmap *regmap;
  40. unsigned int gdscr;
  41. unsigned int *cxcs;
  42. unsigned int cxc_count;
  43. const u8 pwrsts;
  44. struct reset_controller_dev *rcdev;
  45. unsigned int *resets;
  46. unsigned int reset_count;
  47. };
  48. #ifdef CONFIG_QCOM_GDSC
  49. int gdsc_register(struct device *, struct gdsc **, size_t n,
  50. struct reset_controller_dev *, struct regmap *);
  51. void gdsc_unregister(struct device *);
  52. #else
  53. static inline int gdsc_register(struct device *d, struct gdsc **g, size_t n,
  54. struct reset_controller_dev *rcdev,
  55. struct regmap *r)
  56. {
  57. return -ENOSYS;
  58. }
  59. static inline void gdsc_unregister(struct device *d) {};
  60. #endif /* CONFIG_QCOM_GDSC */
  61. #endif /* __QCOM_GDSC_H__ */