pmic8058-othc.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /* Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
  2. *
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License version 2 and
  5. * only version 2 as published by the Free Software Foundation.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. *
  12. */
  13. #ifndef __PMIC8058_OTHC_H__
  14. #define __PMIC8058_OTHC_H__
  15. /* Accessory detecion flags */
  16. #define OTHC_MICBIAS_DETECT BIT(0)
  17. #define OTHC_GPIO_DETECT BIT(1)
  18. #define OTHC_SWITCH_DETECT BIT(2)
  19. #define OTHC_ADC_DETECT BIT(3)
  20. enum othc_accessory_type {
  21. OTHC_NO_DEVICE = 0,
  22. OTHC_HEADSET = 1 << 0,
  23. OTHC_HEADPHONE = 1 << 1,
  24. OTHC_MICROPHONE = 1 << 2,
  25. OTHC_ANC_HEADSET = 1 << 3,
  26. OTHC_ANC_HEADPHONE = 1 << 4,
  27. OTHC_ANC_MICROPHONE = 1 << 5,
  28. OTHC_SVIDEO_OUT = 1 << 6,
  29. };
  30. struct accessory_adc_thres {
  31. int min_threshold;
  32. int max_threshold;
  33. };
  34. struct othc_accessory_info {
  35. unsigned int accessory;
  36. unsigned int detect_flags;
  37. unsigned int gpio;
  38. unsigned int active_low;
  39. unsigned int key_code;
  40. bool enabled;
  41. struct accessory_adc_thres adc_thres;
  42. };
  43. enum othc_headset_type {
  44. OTHC_HEADSET_NO,
  45. OTHC_HEADSET_NC,
  46. };
  47. struct othc_regulator_config {
  48. const char *regulator;
  49. unsigned int max_uV;
  50. unsigned int min_uV;
  51. };
  52. /* Signal control for OTHC module */
  53. enum othc_micbias_enable {
  54. /* Turn off MICBIAS signal */
  55. OTHC_SIGNAL_OFF,
  56. /* Turn on MICBIAS signal when TCXO is enabled */
  57. OTHC_SIGNAL_TCXO,
  58. /* Turn on MICBIAS signal when PWM is high or TCXO is enabled */
  59. OTHC_SIGNAL_PWM_TCXO,
  60. /* MICBIAS always enabled */
  61. OTHC_SIGNAL_ALWAYS_ON,
  62. };
  63. /* Number of MICBIAS lines supported by PMIC8058 */
  64. enum othc_micbias {
  65. OTHC_MICBIAS_0,
  66. OTHC_MICBIAS_1,
  67. OTHC_MICBIAS_2,
  68. OTHC_MICBIAS_MAX,
  69. };
  70. enum othc_micbias_capability {
  71. /* MICBIAS used only for BIAS with on/off capability */
  72. OTHC_MICBIAS,
  73. /* MICBIAS used to support HSED functionality */
  74. OTHC_MICBIAS_HSED,
  75. };
  76. struct othc_switch_info {
  77. u32 min_adc_threshold;
  78. u32 max_adc_threshold;
  79. u32 key_code;
  80. };
  81. struct othc_n_switch_config {
  82. u32 voltage_settling_time_ms;
  83. u8 num_adc_samples;
  84. uint32_t adc_channel;
  85. struct othc_switch_info *switch_info;
  86. u8 num_keys;
  87. bool default_sw_en;
  88. u8 default_sw_idx;
  89. };
  90. struct hsed_bias_config {
  91. enum othc_headset_type othc_headset;
  92. u16 othc_lowcurr_thresh_uA;
  93. u16 othc_highcurr_thresh_uA;
  94. u32 othc_hyst_prediv_us;
  95. u32 othc_period_clkdiv_us;
  96. u32 othc_hyst_clk_us;
  97. u32 othc_period_clk_us;
  98. int othc_wakeup;
  99. };
  100. /* Configuration data for HSED */
  101. struct othc_hsed_config {
  102. struct hsed_bias_config *hsed_bias_config;
  103. unsigned long detection_delay_ms;
  104. /* Switch configuration */
  105. unsigned long switch_debounce_ms;
  106. bool othc_support_n_switch; /* Set if supporting > 1 switch */
  107. struct othc_n_switch_config *switch_config;
  108. /* Accessory configuration */
  109. bool accessories_support;
  110. bool accessories_adc_support;
  111. uint32_t accessories_adc_channel;
  112. struct othc_accessory_info *accessories;
  113. int othc_num_accessories;
  114. int video_out_gpio;
  115. int ir_gpio;
  116. };
  117. struct pmic8058_othc_config_pdata {
  118. enum othc_micbias micbias_select;
  119. enum othc_micbias_enable micbias_enable;
  120. enum othc_micbias_capability micbias_capability;
  121. struct othc_hsed_config *hsed_config;
  122. const char *hsed_name;
  123. struct othc_regulator_config *micbias_regulator;
  124. };
  125. int pm8058_micbias_enable(enum othc_micbias micbias,
  126. enum othc_micbias_enable enable);
  127. int pm8058_othc_svideo_enable(enum othc_micbias micbias,
  128. bool enable);
  129. #endif /* __PMIC8058_OTHC_H__ */