dsi_pwr.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2016-2019, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef _DSI_PWR_H_
  6. #define _DSI_PWR_H_
  7. #include <linux/device.h>
  8. #include <linux/platform_device.h>
  9. #include <linux/types.h>
  10. #include <linux/regulator/consumer.h>
  11. struct dsi_parser_utils;
  12. /**
  13. * struct dsi_vreg - regulator information for DSI regulators
  14. * @vreg: Handle to the regulator.
  15. * @vreg_name: Regulator name.
  16. * @min_voltage: Minimum voltage in uV.
  17. * @max_voltage: Maximum voltage in uV.
  18. * @enable_load: Load, in uA, when enabled.
  19. * @disable_load: Load, in uA, when disabled.
  20. * @off_min_voltage: Minimum voltage in uV when regulator is disabled.
  21. * @pre_on_sleep: Sleep, in ms, before enabling the regulator.
  22. * @post_on_sleep: Sleep, in ms, after enabling the regulator.
  23. * @pre_off_sleep: Sleep, in ms, before disabling the regulator.
  24. * @post_off_sleep: Sleep, in ms, after disabling the regulator.
  25. */
  26. struct dsi_vreg {
  27. struct regulator *vreg;
  28. char vreg_name[32];
  29. u32 min_voltage;
  30. u32 max_voltage;
  31. u32 enable_load;
  32. u32 disable_load;
  33. u32 off_min_voltage;
  34. u32 pre_on_sleep;
  35. u32 post_on_sleep;
  36. u32 pre_off_sleep;
  37. u32 post_off_sleep;
  38. };
  39. /**
  40. * struct dsi_regulator_info - set of vregs that are turned on/off together.
  41. * @vregs: Array of dsi_vreg structures.
  42. * @count: Number of vregs.
  43. * @refcount: Reference counting for enabling.
  44. */
  45. struct dsi_regulator_info {
  46. struct dsi_vreg *vregs;
  47. u32 count;
  48. u32 refcount;
  49. };
  50. /**
  51. * dsi_pwr_of_get_vreg_data - parse regulator supply information
  52. * @of_node: Device of node to parse for supply information.
  53. * @regs: Pointer where regulator information will be copied to.
  54. * @supply_name: Name of the supply node.
  55. *
  56. * return: error code in case of failure or 0 for success.
  57. */
  58. int dsi_pwr_of_get_vreg_data(struct dsi_parser_utils *utils,
  59. struct dsi_regulator_info *regs,
  60. char *supply_name);
  61. /**
  62. * dsi_pwr_get_dt_vreg_data - parse regulator supply information
  63. * @dev: Device whose of_node needs to be parsed.
  64. * @regs: Pointer where regulator information will be copied to.
  65. * @supply_name: Name of the supply node.
  66. *
  67. * return: error code in case of failure or 0 for success.
  68. */
  69. int dsi_pwr_get_dt_vreg_data(struct device *dev,
  70. struct dsi_regulator_info *regs,
  71. char *supply_name);
  72. /**
  73. * dsi_pwr_enable_regulator() - enable a set of regulators
  74. * @regs: Pointer to set of regulators to enable or disable.
  75. * @enable: Enable/Disable regulators.
  76. *
  77. * return: error code in case of failure or 0 for success.
  78. */
  79. int dsi_pwr_enable_regulator(struct dsi_regulator_info *regs, bool enable);
  80. /**
  81. * dsi_pwr_panel_regulator_mode_set()
  82. * set regulator mode for OLED panel
  83. * @regs: Pointer to set of regulators to enable or disable.
  84. * @reg_name: Panel regulator name
  85. * @regulator_mode: Regulator mode values, like:
  86. * REGULATOR_MODE_INVALID
  87. * REGULATOR_MODE_FAST
  88. * REGULATOR_MODE_NORMAL
  89. * REGULATOR_MODE_IDLE
  90. * REGULATOR_MODE_STANDBY
  91. *
  92. * return: error code in case of failure or 0 for success.
  93. */
  94. int dsi_pwr_panel_regulator_mode_set(struct dsi_regulator_info *regs,
  95. const char *reg_name,
  96. int regulator_mode);
  97. #endif /* _DSI_PWR_H_ */