max77804k.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. /*
  2. * max77804k.h - Driver for the Maxim 77804k
  3. *
  4. * Copyright (C) 2011 Samsung Electrnoics
  5. * SangYoung Son <hello.son@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 max8997.h
  22. *
  23. * MAX77804K has Charger, Flash LED, Haptic, MUIC devices.
  24. * The devices share the same I2C bus and included in
  25. * this mfd driver.
  26. */
  27. #ifndef __LINUX_MFD_MAX77804K_H
  28. #define __LINUX_MFD_MAX77804K_H
  29. #include <linux/regulator/consumer.h>
  30. #include <linux/battery/sec_charger.h>
  31. enum {
  32. #if defined (CONFIG_MUIC_MAX77804K_SUPPORT_LANHUB)
  33. MAX77804K_MUIC_NONE = -1,
  34. #endif
  35. MAX77804K_MUIC_DETACHED = 0,
  36. MAX77804K_MUIC_ATTACHED
  37. };
  38. enum {
  39. PATH_OPEN = 0,
  40. PATH_USB_AP,
  41. PATH_AUDIO,
  42. PATH_UART_AP,
  43. PATH_USB_CP,
  44. PATH_UART_CP,
  45. };
  46. /* ATTACHED Dock Type */
  47. enum {
  48. MAX77804K_MUIC_DOCK_DETACHED,
  49. MAX77804K_MUIC_DOCK_DESKDOCK,
  50. MAX77804K_MUIC_DOCK_CARDOCK,
  51. MAX77804K_MUIC_DOCK_AUDIODOCK = 7,
  52. MAX77804K_MUIC_DOCK_SMARTDOCK = 8,
  53. #if defined(CONFIG_MUIC_MAX77804K_SUPPORT_HMT_DETECTION)
  54. MAX77804K_MUIC_DOCK_HMT = 11,
  55. #endif
  56. };
  57. /* MAX77686 regulator IDs */
  58. enum max77804k_regulators {
  59. MAX77804K_ESAFEOUT1 = 0,
  60. MAX77804K_ESAFEOUT2,
  61. MAX77804K_CHARGER,
  62. MAX77804K_REG_MAX,
  63. };
  64. struct max77804k_charger_reg_data {
  65. u8 addr;
  66. u8 data;
  67. };
  68. struct max77804k_charger_platform_data {
  69. struct max77804k_charger_reg_data *init_data;
  70. int num_init_data;
  71. sec_battery_platform_data_t *sec_battery;
  72. #if defined(CONFIG_WIRELESS_CHARGING) || defined(CONFIG_CHARGER_MAX77804K)
  73. int wpc_irq_gpio;
  74. int vbus_irq_gpio;
  75. bool wc_pwr_det;
  76. #endif
  77. };
  78. #ifdef CONFIG_SS_VIBRATOR
  79. #define MAX8997_MOTOR_REG_CONFIG2 0x2
  80. #define MOTOR_LRA (1<<7)
  81. #define MOTOR_EN (1<<6)
  82. #define EXT_PWM (0<<5)
  83. #define DIVIDER_128 (1<<1)
  84. #define DIVIDER_256 0x3
  85. struct max77804k_haptic_platform_data {
  86. u32 max_timeout;
  87. u32 duty;
  88. u32 period;
  89. u32 reg2;
  90. u32 pwm_id;
  91. };
  92. #endif
  93. #ifdef CONFIG_LEDS_MAX77804K
  94. struct max77804k_led_platform_data;
  95. #endif
  96. struct max77804k_regulator_data {
  97. int id;
  98. struct regulator_init_data *initdata;
  99. };
  100. struct max77804k_platform_data {
  101. /* IRQ */
  102. u32 irq_base;
  103. u32 irq_base_flags;
  104. int irq_gpio;
  105. u32 irq_gpio_flags;
  106. unsigned int wc_irq_gpio;
  107. bool wakeup;
  108. struct max77804k_muic_data *muic_data;
  109. struct max77804k_regulator_data *regulators;
  110. int num_regulators;
  111. #ifdef CONFIG_SS_VIBRATOR
  112. /* haptic motor data */
  113. struct max77804k_haptic_platform_data *haptic_data;
  114. #endif
  115. #ifdef CONFIG_LEDS_MAX77804K
  116. /* led (flash/torch) data */
  117. struct max77804k_led_platform_data *led_data;
  118. #endif
  119. #if defined(CONFIG_CHARGER_MAX77804K)
  120. sec_battery_platform_data_t *charger_data;
  121. #endif
  122. };
  123. enum cable_type_muic;
  124. struct max77804k_muic_data {
  125. #if !defined(CONFIG_EXTCON)
  126. void (*usb_cb) (u8 attached);
  127. void (*uart_cb) (u8 attached);
  128. int (*charger_cb) (enum cable_type_muic);
  129. void (*dock_cb) (int type);
  130. void (*mhl_cb) (int attached);
  131. void (*init_cb) (void);
  132. int (*set_safeout) (int path);
  133. bool(*is_mhl_attached) (void);
  134. int (*cfg_uart_gpio) (void);
  135. void (*jig_uart_cb) (int path);
  136. int (*host_notify_cb) (int enable);
  137. int gpio_usb_sel;
  138. int sw_path;
  139. int uart_path;
  140. void (*jig_state) (int jig_state);
  141. #else
  142. int usb_sel;
  143. int uart_sel;
  144. #endif
  145. };
  146. #ifdef CONFIG_MFD_MAX77804K
  147. extern struct max77804k_muic_data max77804k_muic;
  148. extern struct max77804k_regulator_data max77804k_regulators[];
  149. extern int muic_otg_control(int enable);
  150. extern struct max77804k_haptic_platform_data max77804k_haptic_pdata;
  151. extern struct max77804k_led_platform_data max77804k_led_pdata;
  152. extern int max77804k_muic_set_safeout(int path);
  153. #ifndef CONFIG_USB_DWC3
  154. extern void sec_otg_set_vbus_state(int online);
  155. extern int sec_otg_notify(int event);
  156. #endif
  157. #endif
  158. #if defined (CONFIG_VIDEO_MHL_V2) || defined (CONFIG_VIDEO_MHL_SII8246)
  159. int acc_register_notifier(struct notifier_block *nb);
  160. #endif
  161. #endif /* __LINUX_MFD_MAX77804K_H */