mc13783-private.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. /*
  2. * Copyright 2009 Pengutronix, Sascha Hauer <s.hauer@pengutronix.de>
  3. *
  4. * Initial development of this code was funded by
  5. * Phytec Messtechnik GmbH, http://www.phytec.de
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20. */
  21. #ifndef __LINUX_MFD_MC13783_PRIV_H
  22. #define __LINUX_MFD_MC13783_PRIV_H
  23. #include <linux/platform_device.h>
  24. #include <linux/mfd/mc13783.h>
  25. #include <linux/mutex.h>
  26. #include <linux/interrupt.h>
  27. struct mc13783 {
  28. struct spi_device *spidev;
  29. struct mutex lock;
  30. int irq;
  31. int flags;
  32. irq_handler_t irqhandler[MC13783_NUM_IRQ];
  33. void *irqdata[MC13783_NUM_IRQ];
  34. /* XXX these should go as platformdata to the regulator subdevice */
  35. struct mc13783_regulator_init_data *regulators;
  36. int num_regulators;
  37. };
  38. #define MC13783_REG_INTERRUPT_STATUS_0 0
  39. #define MC13783_REG_INTERRUPT_MASK_0 1
  40. #define MC13783_REG_INTERRUPT_SENSE_0 2
  41. #define MC13783_REG_INTERRUPT_STATUS_1 3
  42. #define MC13783_REG_INTERRUPT_MASK_1 4
  43. #define MC13783_REG_INTERRUPT_SENSE_1 5
  44. #define MC13783_REG_POWER_UP_MODE_SENSE 6
  45. #define MC13783_REG_REVISION 7
  46. #define MC13783_REG_SEMAPHORE 8
  47. #define MC13783_REG_ARBITRATION_PERIPHERAL_AUDIO 9
  48. #define MC13783_REG_ARBITRATION_SWITCHERS 10
  49. #define MC13783_REG_ARBITRATION_REGULATORS_0 11
  50. #define MC13783_REG_ARBITRATION_REGULATORS_1 12
  51. #define MC13783_REG_POWER_CONTROL_0 13
  52. #define MC13783_REG_POWER_CONTROL_1 14
  53. #define MC13783_REG_POWER_CONTROL_2 15
  54. #define MC13783_REG_REGEN_ASSIGNMENT 16
  55. #define MC13783_REG_CONTROL_SPARE 17
  56. #define MC13783_REG_MEMORY_A 18
  57. #define MC13783_REG_MEMORY_B 19
  58. #define MC13783_REG_RTC_TIME 20
  59. #define MC13783_REG_RTC_ALARM 21
  60. #define MC13783_REG_RTC_DAY 22
  61. #define MC13783_REG_RTC_DAY_ALARM 23
  62. #define MC13783_REG_SWITCHERS_0 24
  63. #define MC13783_REG_SWITCHERS_1 25
  64. #define MC13783_REG_SWITCHERS_2 26
  65. #define MC13783_REG_SWITCHERS_3 27
  66. #define MC13783_REG_SWITCHERS_4 28
  67. #define MC13783_REG_SWITCHERS_5 29
  68. #define MC13783_REG_REGULATOR_SETTING_0 30
  69. #define MC13783_REG_REGULATOR_SETTING_1 31
  70. #define MC13783_REG_REGULATOR_MODE_0 32
  71. #define MC13783_REG_REGULATOR_MODE_1 33
  72. #define MC13783_REG_POWER_MISCELLANEOUS 34
  73. #define MC13783_REG_POWER_SPARE 35
  74. #define MC13783_REG_AUDIO_RX_0 36
  75. #define MC13783_REG_AUDIO_RX_1 37
  76. #define MC13783_REG_AUDIO_TX 38
  77. #define MC13783_REG_AUDIO_SSI_NETWORK 39
  78. #define MC13783_REG_AUDIO_CODEC 40
  79. #define MC13783_REG_AUDIO_STEREO_DAC 41
  80. #define MC13783_REG_AUDIO_SPARE 42
  81. #define MC13783_REG_ADC_0 43
  82. #define MC13783_REG_ADC_1 44
  83. #define MC13783_REG_ADC_2 45
  84. #define MC13783_REG_ADC_3 46
  85. #define MC13783_REG_ADC_4 47
  86. #define MC13783_REG_CHARGER 48
  87. #define MC13783_REG_USB 49
  88. #define MC13783_REG_CHARGE_USB_SPARE 50
  89. #define MC13783_REG_LED_CONTROL_0 51
  90. #define MC13783_REG_LED_CONTROL_1 52
  91. #define MC13783_REG_LED_CONTROL_2 53
  92. #define MC13783_REG_LED_CONTROL_3 54
  93. #define MC13783_REG_LED_CONTROL_4 55
  94. #define MC13783_REG_LED_CONTROL_5 56
  95. #define MC13783_REG_SPARE 57
  96. #define MC13783_REG_TRIM_0 58
  97. #define MC13783_REG_TRIM_1 59
  98. #define MC13783_REG_TEST_0 60
  99. #define MC13783_REG_TEST_1 61
  100. #define MC13783_REG_TEST_2 62
  101. #define MC13783_REG_TEST_3 63
  102. #define MC13783_REG_NB 64
  103. /*
  104. * Reg Regulator Mode 0
  105. */
  106. #define MC13783_REGCTRL_VAUDIO_EN (1 << 0)
  107. #define MC13783_REGCTRL_VAUDIO_STBY (1 << 1)
  108. #define MC13783_REGCTRL_VAUDIO_MODE (1 << 2)
  109. #define MC13783_REGCTRL_VIOHI_EN (1 << 3)
  110. #define MC13783_REGCTRL_VIOHI_STBY (1 << 4)
  111. #define MC13783_REGCTRL_VIOHI_MODE (1 << 5)
  112. #define MC13783_REGCTRL_VIOLO_EN (1 << 6)
  113. #define MC13783_REGCTRL_VIOLO_STBY (1 << 7)
  114. #define MC13783_REGCTRL_VIOLO_MODE (1 << 8)
  115. #define MC13783_REGCTRL_VDIG_EN (1 << 9)
  116. #define MC13783_REGCTRL_VDIG_STBY (1 << 10)
  117. #define MC13783_REGCTRL_VDIG_MODE (1 << 11)
  118. #define MC13783_REGCTRL_VGEN_EN (1 << 12)
  119. #define MC13783_REGCTRL_VGEN_STBY (1 << 13)
  120. #define MC13783_REGCTRL_VGEN_MODE (1 << 14)
  121. #define MC13783_REGCTRL_VRFDIG_EN (1 << 15)
  122. #define MC13783_REGCTRL_VRFDIG_STBY (1 << 16)
  123. #define MC13783_REGCTRL_VRFDIG_MODE (1 << 17)
  124. #define MC13783_REGCTRL_VRFREF_EN (1 << 18)
  125. #define MC13783_REGCTRL_VRFREF_STBY (1 << 19)
  126. #define MC13783_REGCTRL_VRFREF_MODE (1 << 20)
  127. #define MC13783_REGCTRL_VRFCP_EN (1 << 21)
  128. #define MC13783_REGCTRL_VRFCP_STBY (1 << 22)
  129. #define MC13783_REGCTRL_VRFCP_MODE (1 << 23)
  130. /*
  131. * Reg Regulator Mode 1
  132. */
  133. #define MC13783_REGCTRL_VSIM_EN (1 << 0)
  134. #define MC13783_REGCTRL_VSIM_STBY (1 << 1)
  135. #define MC13783_REGCTRL_VSIM_MODE (1 << 2)
  136. #define MC13783_REGCTRL_VESIM_EN (1 << 3)
  137. #define MC13783_REGCTRL_VESIM_STBY (1 << 4)
  138. #define MC13783_REGCTRL_VESIM_MODE (1 << 5)
  139. #define MC13783_REGCTRL_VCAM_EN (1 << 6)
  140. #define MC13783_REGCTRL_VCAM_STBY (1 << 7)
  141. #define MC13783_REGCTRL_VCAM_MODE (1 << 8)
  142. #define MC13783_REGCTRL_VRFBG_EN (1 << 9)
  143. #define MC13783_REGCTRL_VRFBG_STBY (1 << 10)
  144. #define MC13783_REGCTRL_VVIB_EN (1 << 11)
  145. #define MC13783_REGCTRL_VRF1_EN (1 << 12)
  146. #define MC13783_REGCTRL_VRF1_STBY (1 << 13)
  147. #define MC13783_REGCTRL_VRF1_MODE (1 << 14)
  148. #define MC13783_REGCTRL_VRF2_EN (1 << 15)
  149. #define MC13783_REGCTRL_VRF2_STBY (1 << 16)
  150. #define MC13783_REGCTRL_VRF2_MODE (1 << 17)
  151. #define MC13783_REGCTRL_VMMC1_EN (1 << 18)
  152. #define MC13783_REGCTRL_VMMC1_STBY (1 << 19)
  153. #define MC13783_REGCTRL_VMMC1_MODE (1 << 20)
  154. #define MC13783_REGCTRL_VMMC2_EN (1 << 21)
  155. #define MC13783_REGCTRL_VMMC2_STBY (1 << 22)
  156. #define MC13783_REGCTRL_VMMC2_MODE (1 << 23)
  157. /*
  158. * Reg Regulator Misc.
  159. */
  160. #define MC13783_REGCTRL_GPO1_EN (1 << 6)
  161. #define MC13783_REGCTRL_GPO2_EN (1 << 8)
  162. #define MC13783_REGCTRL_GPO3_EN (1 << 10)
  163. #define MC13783_REGCTRL_GPO4_EN (1 << 12)
  164. #define MC13783_REGCTRL_VIBPINCTRL (1 << 14)
  165. /*
  166. * Reg Switcher 4
  167. */
  168. #define MC13783_SWCTRL_SW1A_MODE (1 << 0)
  169. #define MC13783_SWCTRL_SW1A_STBY_MODE (1 << 2)
  170. #define MC13783_SWCTRL_SW1A_DVS_SPEED (1 << 6)
  171. #define MC13783_SWCTRL_SW1A_PANIC_MODE (1 << 8)
  172. #define MC13783_SWCTRL_SW1A_SOFTSTART (1 << 9)
  173. #define MC13783_SWCTRL_SW1B_MODE (1 << 10)
  174. #define MC13783_SWCTRL_SW1B_STBY_MODE (1 << 12)
  175. #define MC13783_SWCTRL_SW1B_DVS_SPEED (1 << 14)
  176. #define MC13783_SWCTRL_SW1B_PANIC_MODE (1 << 16)
  177. #define MC13783_SWCTRL_SW1B_SOFTSTART (1 << 17)
  178. #define MC13783_SWCTRL_PLL_EN (1 << 18)
  179. #define MC13783_SWCTRL_PLL_FACTOR (1 << 19)
  180. /*
  181. * Reg Switcher 5
  182. */
  183. #define MC13783_SWCTRL_SW2A_MODE (1 << 0)
  184. #define MC13783_SWCTRL_SW2A_STBY_MODE (1 << 2)
  185. #define MC13783_SWCTRL_SW2A_DVS_SPEED (1 << 6)
  186. #define MC13783_SWCTRL_SW2A_PANIC_MODE (1 << 8)
  187. #define MC13783_SWCTRL_SW2A_SOFTSTART (1 << 9)
  188. #define MC13783_SWCTRL_SW2B_MODE (1 << 10)
  189. #define MC13783_SWCTRL_SW2B_STBY_MODE (1 << 12)
  190. #define MC13783_SWCTRL_SW2B_DVS_SPEED (1 << 14)
  191. #define MC13783_SWCTRL_SW2B_PANIC_MODE (1 << 16)
  192. #define MC13783_SWCTRL_SW2B_SOFTSTART (1 << 17)
  193. #define MC13783_SWSET_SW3 (1 << 18)
  194. #define MC13783_SWCTRL_SW3_EN (1 << 20)
  195. #define MC13783_SWCTRL_SW3_STBY (1 << 21)
  196. #define MC13783_SWCTRL_SW3_MODE (1 << 22)
  197. static inline int mc13783_set_bits(struct mc13783 *mc13783, unsigned int offset,
  198. u32 mask, u32 val)
  199. {
  200. int ret;
  201. mc13783_lock(mc13783);
  202. ret = mc13783_reg_rmw(mc13783, offset, mask, val);
  203. mc13783_unlock(mc13783);
  204. return ret;
  205. }
  206. #endif /* __LINUX_MFD_MC13783_PRIV_H */