core.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. /*
  2. * core.h
  3. *
  4. * copyright (c) 2011 Samsung Electronics Co., Ltd
  5. * http://www.samsung.com
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License as published by the
  9. * Free Software Foundation; either version 2 of the License, or (at your
  10. * option) any later version.
  11. *
  12. */
  13. #ifndef __LINUX_MFD_SEC_CORE_H
  14. #define __LINUX_MFD_SEC_CORE_H
  15. /* Macros to represent minimum voltages for LDO/BUCK */
  16. #define MIN_3000_MV 3000000
  17. #define MIN_2500_MV 2500000
  18. #define MIN_2000_MV 2000000
  19. #define MIN_1800_MV 1800000
  20. #define MIN_1500_MV 1500000
  21. #define MIN_1400_MV 1400000
  22. #define MIN_1000_MV 1000000
  23. #define MIN_900_MV 900000
  24. #define MIN_850_MV 850000
  25. #define MIN_800_MV 800000
  26. #define MIN_750_MV 750000
  27. #define MIN_600_MV 600000
  28. /* Macros to represent steps for LDO/BUCK */
  29. #define STEP_50_MV 50000
  30. #define STEP_25_MV 25000
  31. #define STEP_12_5_MV 12500
  32. #define STEP_6_25_MV 6250
  33. enum sec_device_type {
  34. S5M8751X,
  35. S5M8763X,
  36. S5M8767X,
  37. S2MPA01,
  38. S2MPS11X,
  39. S2MPS14X,
  40. S2MPU02,
  41. };
  42. /**
  43. * struct sec_pmic_dev - s2m/s5m master device for sub-drivers
  44. * @dev: Master device of the chip
  45. * @pdata: Platform data populated with data from DTS
  46. * or board files
  47. * @regmap_pmic: Regmap associated with PMIC's I2C address
  48. * @i2c: I2C client of the main driver
  49. * @device_type: Type of device, matches enum sec_device_type
  50. * @irq_base: Base IRQ number for device, required for IRQs
  51. * @irq: Generic IRQ number for device
  52. * @irq_data: Runtime data structure for IRQ controller
  53. * @ono: Power onoff IRQ number for s5m87xx
  54. * @wakeup: Whether or not this is a wakeup device
  55. * @wtsr_smpl: Whether or not to enable in RTC driver the Watchdog
  56. * Timer Software Reset (registers set to default value
  57. * after PWRHOLD falling) and Sudden Momentary Power Loss
  58. * (PMIC will enter power on sequence after short drop in
  59. * VBATT voltage).
  60. */
  61. struct sec_pmic_dev {
  62. struct device *dev;
  63. struct sec_platform_data *pdata;
  64. struct regmap *regmap_pmic;
  65. struct i2c_client *i2c;
  66. unsigned long device_type;
  67. int irq_base;
  68. int irq;
  69. struct regmap_irq_chip_data *irq_data;
  70. int ono;
  71. bool wakeup;
  72. bool wtsr_smpl;
  73. };
  74. int sec_irq_init(struct sec_pmic_dev *sec_pmic);
  75. void sec_irq_exit(struct sec_pmic_dev *sec_pmic);
  76. int sec_irq_resume(struct sec_pmic_dev *sec_pmic);
  77. struct sec_platform_data {
  78. struct sec_regulator_data *regulators;
  79. struct sec_opmode_data *opmode;
  80. int device_type;
  81. int num_regulators;
  82. int irq_base;
  83. int (*cfg_pmic_irq)(void);
  84. int ono;
  85. bool wakeup;
  86. bool buck_voltage_lock;
  87. int buck_gpios[3];
  88. int buck_ds[3];
  89. unsigned int buck2_voltage[8];
  90. bool buck2_gpiodvs;
  91. unsigned int buck3_voltage[8];
  92. bool buck3_gpiodvs;
  93. unsigned int buck4_voltage[8];
  94. bool buck4_gpiodvs;
  95. int buck_set1;
  96. int buck_set2;
  97. int buck_set3;
  98. int buck2_enable;
  99. int buck3_enable;
  100. int buck4_enable;
  101. int buck_default_idx;
  102. int buck2_default_idx;
  103. int buck3_default_idx;
  104. int buck4_default_idx;
  105. int buck_ramp_delay;
  106. int buck2_ramp_delay;
  107. int buck34_ramp_delay;
  108. int buck5_ramp_delay;
  109. int buck16_ramp_delay;
  110. int buck7810_ramp_delay;
  111. int buck9_ramp_delay;
  112. int buck24_ramp_delay;
  113. int buck3_ramp_delay;
  114. int buck7_ramp_delay;
  115. int buck8910_ramp_delay;
  116. bool buck1_ramp_enable;
  117. bool buck2_ramp_enable;
  118. bool buck3_ramp_enable;
  119. bool buck4_ramp_enable;
  120. bool buck6_ramp_enable;
  121. int buck2_init;
  122. int buck3_init;
  123. int buck4_init;
  124. };
  125. /**
  126. * sec_regulator_data - regulator data
  127. * @id: regulator id
  128. * @initdata: regulator init data (contraints, supplies, ...)
  129. */
  130. struct sec_regulator_data {
  131. int id;
  132. struct regulator_init_data *initdata;
  133. struct device_node *reg_node;
  134. int ext_control_gpio;
  135. };
  136. /*
  137. * sec_opmode_data - regulator operation mode data
  138. * @id: regulator id
  139. * @mode: regulator operation mode
  140. */
  141. struct sec_opmode_data {
  142. int id;
  143. unsigned int mode;
  144. };
  145. /*
  146. * samsung regulator operation mode
  147. * SEC_OPMODE_OFF Regulator always OFF
  148. * SEC_OPMODE_ON Regulator always ON
  149. * SEC_OPMODE_LOWPOWER Regulator is on in low-power mode
  150. * SEC_OPMODE_SUSPEND Regulator is changed by PWREN pin
  151. * If PWREN is high, regulator is on
  152. * If PWREN is low, regulator is off
  153. */
  154. enum sec_opmode {
  155. SEC_OPMODE_OFF,
  156. SEC_OPMODE_ON,
  157. SEC_OPMODE_LOWPOWER,
  158. SEC_OPMODE_SUSPEND,
  159. };
  160. #endif /* __LINUX_MFD_SEC_CORE_H */