max8997.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. /*
  2. * max8997.h - Driver for the Maxim 8997/8966
  3. *
  4. * Copyright (C) 2009-2010 Samsung Electrnoics
  5. * MyungJoo Ham <myungjoo.ham@samsung.com>
  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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. *
  21. * This driver is based on max8998.h
  22. *
  23. * MAX8997 has PMIC, MUIC, HAPTIC, RTC, FLASH, and Fuel Gauge devices.
  24. * Except Fuel Gauge, every device shares the same I2C bus and included in
  25. * this mfd driver. Although the fuel gauge is included in the chip, it is
  26. * excluded from the driver because a) it has a different I2C bus from
  27. * others and b) it can be enabled simply by using MAX17042 driver.
  28. */
  29. #ifndef __LINUX_MFD_MAX8998_H
  30. #define __LINUX_MFD_MAX8998_H
  31. #include <linux/regulator/consumer.h>
  32. /* MAX8997/8966 regulator IDs */
  33. enum max8998_regulators {
  34. MAX8997_LDO1 = 0,
  35. MAX8997_LDO2,
  36. MAX8997_LDO3,
  37. MAX8997_LDO4,
  38. MAX8997_LDO5,
  39. MAX8997_LDO6,
  40. MAX8997_LDO7,
  41. MAX8997_LDO8,
  42. MAX8997_LDO9,
  43. MAX8997_LDO10,
  44. MAX8997_LDO11,
  45. MAX8997_LDO12,
  46. MAX8997_LDO13,
  47. MAX8997_LDO14,
  48. MAX8997_LDO15,
  49. MAX8997_LDO16,
  50. MAX8997_LDO17,
  51. MAX8997_LDO18,
  52. MAX8997_LDO21,
  53. MAX8997_BUCK1,
  54. MAX8997_BUCK2,
  55. MAX8997_BUCK3,
  56. MAX8997_BUCK4,
  57. MAX8997_BUCK5,
  58. MAX8997_BUCK6,
  59. MAX8997_BUCK7,
  60. MAX8997_EN32KHZ_AP,
  61. MAX8997_EN32KHZ_CP,
  62. MAX8997_ENVICHG,
  63. MAX8997_ESAFEOUT1,
  64. MAX8997_ESAFEOUT2,
  65. MAX8997_CHARGER_CV, /* control MBCCV of MBCCTRL3 */
  66. MAX8997_CHARGER, /* charger current, MBCCTRL4 */
  67. MAX8997_CHARGER_TOPOFF, /* MBCCTRL5 */
  68. MAX8997_REG_MAX,
  69. };
  70. struct max8997_regulator_data {
  71. int id;
  72. struct regulator_init_data *initdata;
  73. };
  74. enum max8997_muic_usb_type {
  75. MAX8997_USB_HOST,
  76. MAX8997_USB_DEVICE,
  77. };
  78. enum max8997_muic_charger_type {
  79. MAX8997_CHARGER_TYPE_NONE = 0,
  80. MAX8997_CHARGER_TYPE_USB,
  81. MAX8997_CHARGER_TYPE_DOWNSTREAM_PORT,
  82. MAX8997_CHARGER_TYPE_DEDICATED_CHG,
  83. MAX8997_CHARGER_TYPE_500MA,
  84. MAX8997_CHARGER_TYPE_1A,
  85. MAX8997_CHARGER_TYPE_DEAD_BATTERY = 7,
  86. };
  87. struct max8997_muic_reg_data {
  88. u8 addr;
  89. u8 data;
  90. };
  91. /**
  92. * struct max8997_muic_platform_data
  93. * @usb_callback: callback function for USB
  94. * inform callee of USB type (HOST or DEVICE)
  95. * and attached state(true or false)
  96. * @charger_callback: callback function for charger
  97. * inform callee of charger_type
  98. * and attached state(true or false)
  99. * @deskdock_callback: callback function for desk dock
  100. * inform callee of attached state(true or false)
  101. * @cardock_callback: callback function for car dock
  102. * inform callee of attached state(true or false)
  103. * @mhl_callback: callback function for MHL (Mobile High-definition Link)
  104. * inform callee of attached state(true or false)
  105. * @uart_callback: callback function for JIG UART
  106. * inform callee of attached state(true or false)
  107. * @init_data: array of max8997_muic_reg_data
  108. * used for initializing registers of MAX8997 MUIC device
  109. * @num_init_data: array size of init_data
  110. */
  111. struct max8997_muic_platform_data {
  112. void (*usb_callback)(enum max8997_muic_usb_type usb_type,
  113. bool attached);
  114. void (*charger_callback)(bool attached,
  115. enum max8997_muic_charger_type charger_type);
  116. void (*deskdock_callback) (bool attached);
  117. void (*cardock_callback) (bool attached);
  118. void (*mhl_callback) (bool attached);
  119. void (*uart_callback) (bool attached);
  120. struct max8997_muic_reg_data *init_data;
  121. int num_init_data;
  122. };
  123. enum max8997_haptic_motor_type {
  124. MAX8997_HAPTIC_ERM,
  125. MAX8997_HAPTIC_LRA,
  126. };
  127. enum max8997_haptic_pulse_mode {
  128. MAX8997_EXTERNAL_MODE,
  129. MAX8997_INTERNAL_MODE,
  130. };
  131. enum max8997_haptic_pwm_divisor {
  132. MAX8997_PWM_DIVISOR_32,
  133. MAX8997_PWM_DIVISOR_64,
  134. MAX8997_PWM_DIVISOR_128,
  135. MAX8997_PWM_DIVISOR_256,
  136. };
  137. /**
  138. * max8997_haptic_platform_data
  139. * @pwm_channel_id: channel number of PWM device
  140. * valid for MAX8997_EXTERNAL_MODE
  141. * @pwm_period: period in nano second for PWM device
  142. * valid for MAX8997_EXTERNAL_MODE
  143. * @type: motor type
  144. * @mode: pulse mode
  145. * MAX8997_EXTERNAL_MODE: external PWM device is used to control motor
  146. * MAX8997_INTERNAL_MODE: internal pulse generator is used to control motor
  147. * @pwm_divisor: divisor for external PWM device
  148. * @internal_mode_pattern: internal mode pattern for internal mode
  149. * [0 - 3]: valid pattern number
  150. * @pattern_cycle: the number of cycles of the waveform
  151. * for the internal mode pattern
  152. * [0 - 15]: available cycles
  153. * @pattern_signal_period: period of the waveform for the internal mode pattern
  154. * [0 - 255]: available period
  155. */
  156. struct max8997_haptic_platform_data {
  157. unsigned int pwm_channel_id;
  158. unsigned int pwm_period;
  159. enum max8997_haptic_motor_type type;
  160. enum max8997_haptic_pulse_mode mode;
  161. enum max8997_haptic_pwm_divisor pwm_divisor;
  162. unsigned int internal_mode_pattern;
  163. unsigned int pattern_cycle;
  164. unsigned int pattern_signal_period;
  165. };
  166. enum max8997_led_mode {
  167. MAX8997_NONE,
  168. MAX8997_FLASH_MODE,
  169. MAX8997_MOVIE_MODE,
  170. MAX8997_FLASH_PIN_CONTROL_MODE,
  171. MAX8997_MOVIE_PIN_CONTROL_MODE,
  172. };
  173. /**
  174. * struct max8997_led_platform_data
  175. * The number of LED devices for MAX8997 is two
  176. * @mode: LED mode for each LED device
  177. * @brightness: initial brightness for each LED device
  178. * range:
  179. * [0 - 31]: MAX8997_FLASH_MODE and MAX8997_FLASH_PIN_CONTROL_MODE
  180. * [0 - 15]: MAX8997_MOVIE_MODE and MAX8997_MOVIE_PIN_CONTROL_MODE
  181. */
  182. struct max8997_led_platform_data {
  183. enum max8997_led_mode mode[2];
  184. u8 brightness[2];
  185. };
  186. struct max8997_platform_data {
  187. /* IRQ */
  188. int irq_base;
  189. int ono;
  190. int wakeup;
  191. /* ---- PMIC ---- */
  192. struct max8997_regulator_data *regulators;
  193. int num_regulators;
  194. /*
  195. * SET1~3 DVS GPIOs control Buck1, 2, and 5 simultaneously. Therefore,
  196. * With buckx_gpiodvs enabled, the buckx cannot be controlled
  197. * independently. To control buckx (of 1, 2, and 5) independently,
  198. * disable buckx_gpiodvs and control with BUCKxDVS1 register.
  199. *
  200. * When buckx_gpiodvs and bucky_gpiodvs are both enabled, set_voltage
  201. * on buckx will change the voltage of bucky at the same time.
  202. *
  203. */
  204. bool ignore_gpiodvs_side_effect;
  205. int buck125_gpios[3]; /* GPIO of [0]SET1, [1]SET2, [2]SET3 */
  206. int buck125_default_idx; /* Default value of SET1, 2, 3 */
  207. unsigned int buck1_voltage[8]; /* buckx_voltage in uV */
  208. bool buck1_gpiodvs;
  209. unsigned int buck2_voltage[8];
  210. bool buck2_gpiodvs;
  211. unsigned int buck5_voltage[8];
  212. bool buck5_gpiodvs;
  213. /* ---- Charger control ---- */
  214. /* eoc stands for 'end of charge' */
  215. int eoc_mA; /* 50 ~ 200mA by 10mA step */
  216. /* charge Full Timeout */
  217. int timeout; /* 0 (no timeout), 5, 6, 7 hours */
  218. /* ---- MUIC ---- */
  219. struct max8997_muic_platform_data *muic_pdata;
  220. /* ---- HAPTIC ---- */
  221. struct max8997_haptic_platform_data *haptic_pdata;
  222. /* RTC: Not implemented */
  223. /* ---- LED ---- */
  224. struct max8997_led_platform_data *led_pdata;
  225. };
  226. #endif /* __LINUX_MFD_MAX8998_H */