rohm-bd957x.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /* Copyright (C) 2021 ROHM Semiconductors */
  3. #ifndef __LINUX_MFD_BD957X_H__
  4. #define __LINUX_MFD_BD957X_H__
  5. enum {
  6. BD957X_VD50,
  7. BD957X_VD18,
  8. BD957X_VDDDR,
  9. BD957X_VD10,
  10. BD957X_VOUTL1,
  11. BD957X_VOUTS1,
  12. };
  13. /*
  14. * The BD9576 has own IRQ 'blocks' for:
  15. * - I2C/thermal,
  16. * - Over voltage protection
  17. * - Short-circuit protection
  18. * - Over current protection
  19. * - Over voltage detection
  20. * - Under voltage detection
  21. * - Under voltage protection
  22. * - 'system interrupt'.
  23. *
  24. * Each of the blocks have a status register giving more accurate IRQ source
  25. * information - for example which of the regulators have over-voltage.
  26. *
  27. * On top of this, there is "main IRQ" status register where each bit indicates
  28. * which of sub-blocks have active IRQs. Fine. That would fit regmap-irq main
  29. * status handling. Except that:
  30. * - Only some sub-IRQs can be masked.
  31. * - The IRQ informs us about fault-condition, not when fault state changes.
  32. * The IRQ line it is kept asserted until the detected condition is acked
  33. * AND cleared in HW. This is annoying for IRQs like the one informing high
  34. * temperature because if IRQ is not disabled it keeps the CPU in IRQ
  35. * handling loop.
  36. *
  37. * For now we do just use the main-IRQ register as source for our IRQ
  38. * information and bind the regmap-irq to this. We leave fine-grained sub-IRQ
  39. * register handling to handlers in sub-devices. The regulator driver shall
  40. * read which regulators are source for problem - or if the detected error is
  41. * regulator temperature error. The sub-drivers do also handle masking of "sub-
  42. * IRQs" if this is supported/needed.
  43. *
  44. * To overcome the problem with HW keeping IRQ asserted we do call
  45. * disable_irq_nosync() from sub-device handler and add a delayed work to
  46. * re-enable IRQ roughly 1 second later. This should keep our CPU out of
  47. * busy-loop.
  48. */
  49. #define IRQS_SILENT_MS 1000
  50. enum {
  51. BD9576_INT_THERM,
  52. BD9576_INT_OVP,
  53. BD9576_INT_SCP,
  54. BD9576_INT_OCP,
  55. BD9576_INT_OVD,
  56. BD9576_INT_UVD,
  57. BD9576_INT_UVP,
  58. BD9576_INT_SYS,
  59. };
  60. #define BD957X_REG_SMRB_ASSERT 0x15
  61. #define BD957X_REG_PMIC_INTERNAL_STAT 0x20
  62. #define BD957X_REG_INT_THERM_STAT 0x23
  63. #define BD957X_REG_INT_THERM_MASK 0x24
  64. #define BD957X_REG_INT_OVP_STAT 0x25
  65. #define BD957X_REG_INT_SCP_STAT 0x26
  66. #define BD957X_REG_INT_OCP_STAT 0x27
  67. #define BD957X_REG_INT_OVD_STAT 0x28
  68. #define BD957X_REG_INT_UVD_STAT 0x29
  69. #define BD957X_REG_INT_UVP_STAT 0x2a
  70. #define BD957X_REG_INT_SYS_STAT 0x2b
  71. #define BD957X_REG_INT_SYS_MASK 0x2c
  72. #define BD957X_REG_INT_MAIN_STAT 0x30
  73. #define BD957X_REG_INT_MAIN_MASK 0x31
  74. #define UVD_IRQ_VALID_MASK 0x6F
  75. #define OVD_IRQ_VALID_MASK 0x2F
  76. #define BD957X_MASK_INT_MAIN_THERM BIT(0)
  77. #define BD957X_MASK_INT_MAIN_OVP BIT(1)
  78. #define BD957X_MASK_INT_MAIN_SCP BIT(2)
  79. #define BD957X_MASK_INT_MAIN_OCP BIT(3)
  80. #define BD957X_MASK_INT_MAIN_OVD BIT(4)
  81. #define BD957X_MASK_INT_MAIN_UVD BIT(5)
  82. #define BD957X_MASK_INT_MAIN_UVP BIT(6)
  83. #define BD957X_MASK_INT_MAIN_SYS BIT(7)
  84. #define BD957X_MASK_INT_ALL 0xff
  85. #define BD957X_REG_WDT_CONF 0x16
  86. #define BD957X_REG_POW_TRIGGER1 0x41
  87. #define BD957X_REG_POW_TRIGGER2 0x42
  88. #define BD957X_REG_POW_TRIGGER3 0x43
  89. #define BD957X_REG_POW_TRIGGER4 0x44
  90. #define BD957X_REG_POW_TRIGGERL1 0x45
  91. #define BD957X_REG_POW_TRIGGERS1 0x46
  92. #define BD957X_REGULATOR_EN_MASK 0xff
  93. #define BD957X_REGULATOR_DIS_VAL 0xff
  94. #define BD957X_VSEL_REG_MASK 0xff
  95. #define BD957X_MASK_VOUT1_TUNE 0x87
  96. #define BD957X_MASK_VOUT2_TUNE 0x87
  97. #define BD957X_MASK_VOUT3_TUNE 0x1f
  98. #define BD957X_MASK_VOUT4_TUNE 0x1f
  99. #define BD957X_MASK_VOUTL1_TUNE 0x87
  100. #define BD957X_REG_VOUT1_TUNE 0x50
  101. #define BD957X_REG_VOUT2_TUNE 0x53
  102. #define BD957X_REG_VOUT3_TUNE 0x56
  103. #define BD957X_REG_VOUT4_TUNE 0x59
  104. #define BD957X_REG_VOUTL1_TUNE 0x5c
  105. #define BD9576_REG_VOUT1_OVD 0x51
  106. #define BD9576_REG_VOUT1_UVD 0x52
  107. #define BD9576_REG_VOUT2_OVD 0x54
  108. #define BD9576_REG_VOUT2_UVD 0x55
  109. #define BD9576_REG_VOUT3_OVD 0x57
  110. #define BD9576_REG_VOUT3_UVD 0x58
  111. #define BD9576_REG_VOUT4_OVD 0x5a
  112. #define BD9576_REG_VOUT4_UVD 0x5b
  113. #define BD9576_REG_VOUTL1_OVD 0x5d
  114. #define BD9576_REG_VOUTL1_UVD 0x5e
  115. #define BD9576_MASK_XVD 0x7f
  116. #define BD9576_REG_VOUT1S_OCW 0x5f
  117. #define BD9576_REG_VOUT1S_OCP 0x60
  118. #define BD9576_MASK_VOUT1S_OCW 0x3f
  119. #define BD9576_MASK_VOUT1S_OCP 0x3f
  120. #define BD957X_MAX_REGISTER 0x61
  121. #endif